Skip to content

Commit 25db6b4

Browse files
author
Shaun Persad
committed
added location event support
1 parent 6e47419 commit 25db6b4

File tree

6 files changed

+45
-1
lines changed

6 files changed

+45
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@envoy/envoy-integrations-sdk",
3-
"version": "2.0.0-beta.0",
3+
"version": "2.0.0-beta.1",
44
"description": "SDK for building Envoy integrations.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import EnvoyUserAPI from './sdk/EnvoyUserAPI';
1212
import EnvoyPluginAPI from './sdk/EnvoyPluginAPI';
1313

1414
import EnvoyJWT from './util/EnvoyJWT';
15+
import EnvoySignatureVerifier from './util/EnvoySignatureVerifier';
1516
import JSONAPIData from './util/json-api/JSONAPIData';
1617

1718
export * from './resources/AgreementPageResource';
@@ -43,6 +44,7 @@ export {
4344
EnvoyPluginStorage,
4445
EnvoyRequest,
4546
EnvoyResponse,
47+
EnvoySignatureVerifier,
4648
EnvoyStorageItem,
4749
EnvoyPluginAPI,
4850
EnvoyUserAPI,

src/internal/EnvoyLocationEvent.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
type EnvoyLocationEvent = 'location_capacity_updated' | string;
2+
3+
export default EnvoyLocationEvent;

src/payloads/LocationPayload.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { LocationModel } from '../resources/LocationResource';
2+
3+
/**
4+
* @category Event
5+
*/
6+
type LocationPayload = LocationModel;
7+
8+
export default LocationPayload;

src/sdk/EnvoyRequest.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import EnvoyPluginSDK from './EnvoyPluginSDK';
33
import EnvoyMeta, { EnvoyEventMeta, EnvoyRouteMeta } from './EnvoyMeta';
44
import EntryPayload from '../payloads/EntryPayload';
55
import InvitePayload from '../payloads/InvitePayload';
6+
import LocationPayload from '../payloads/LocationPayload';
67
import EnvoyEntryEvent from '../internal/EnvoyEntryEvent';
78
import EnvoyInviteEvent from '../internal/EnvoyInviteEvent';
9+
import EnvoyLocationEvent from '../internal/EnvoyLocationEvent';
810
import EnvoyOptionsRouteResponseBody from '../internal/EnvoyOptionsRouteResponseBody';
911
import EnvoyOptionsRouteParams from '../internal/EnvoyOptionsRouteParams';
1012
import EnvoySelectedValuesRouteResponseBody from '../internal/EnvoySelectedValuesRouteResponseBody';
@@ -113,6 +115,15 @@ export type EnvoyEntryEventRequest<Config = Record<string, unknown>> =
113115
export type EnvoyInviteEventRequest<Config = Record<string, unknown>> =
114116
EnvoyEventRequest<EnvoyInviteEvent, InvitePayload, Config>;
115117

118+
/**
119+
* Use to type your `req` object in location event handlers,
120+
* such as handlers for `location_capacity_updated`.
121+
*
122+
* @category Request
123+
*/
124+
export type EnvoyLocationEventRequest<Config = Record<string, unknown>> =
125+
EnvoyEventRequest<EnvoyLocationEvent, LocationPayload, Config>;
126+
116127
/**
117128
* You probably won't need to use this type directly.
118129
* For routes, use {@link EnvoyRouteRequest},

src/sdk/handlers.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
EnvoyEntryEventRequest,
99
EnvoyEventRequest,
1010
EnvoyInviteEventRequest,
11+
EnvoyLocationEventRequest,
1112
EnvoyMigrationRouteRequest,
1213
EnvoyOptionsRouteRequest,
1314
EnvoyRemoteValueRouteRequest,
@@ -38,6 +39,13 @@ export type EntryEventHandler<Config = SomeObject, Additions = SomeObject> =
3839
export type InviteEventHandler<Config = SomeObject, Additions = SomeObject> =
3940
(req: EnvoyInviteEventRequest<Config> & Additions, res: EnvoyResponse) => Result;
4041

42+
/**
43+
* Handle an location event, such as `location_capacity_updated`.
44+
* @category Handler
45+
*/
46+
export type LocationEventHandler<Config = SomeObject, Additions = SomeObject> =
47+
(req: EnvoyLocationEventRequest<Config> & Additions, res: EnvoyResponse) => Result;
48+
4149
/**
4250
* Handle a `plugin_uninstalled` event for cleaning up.
4351
* @category Handler
@@ -119,6 +127,18 @@ export function inviteEventHandler<
119127
return asyncHandler(handler);
120128
}
121129

130+
/**
131+
* Handler for location events.
132+
*
133+
* @category Handler
134+
*/
135+
export function locationEventHandler<
136+
Config = SomeObject,
137+
Additions = SomeObject,
138+
>(handler: LocationEventHandler<Config, Additions>) {
139+
return asyncHandler(handler);
140+
}
141+
122142
/**
123143
* Handler for `plugin_uninstalled` events.
124144
*

0 commit comments

Comments
 (0)