@envoy/envoy-integrations-sdk 2.0.1-beta.5 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +178 -110
- package/dist/base/EnvoyAPI.d.ts +28 -0
- package/dist/base/EnvoyAPI.d.ts.map +1 -0
- package/dist/base/EnvoyAPI.js +121 -0
- package/dist/base/EnvoyPluginStoragePipeline.d.ts +51 -0
- package/dist/base/EnvoyPluginStoragePipeline.d.ts.map +1 -0
- package/dist/base/EnvoyPluginStoragePipeline.js +140 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +12 -0
- package/dist/factories/entryEventBodyFactory.d.ts +42 -0
- package/dist/factories/entryEventBodyFactory.d.ts.map +1 -0
- package/dist/factories/entryEventBodyFactory.js +105 -0
- package/dist/factories/eventBodyFactory.d.ts +18 -0
- package/dist/factories/eventBodyFactory.d.ts.map +1 -0
- package/dist/factories/eventBodyFactory.js +15 -0
- package/dist/factories/inviteEventBodyFactory.d.ts +38 -0
- package/dist/factories/inviteEventBodyFactory.d.ts.map +1 -0
- package/dist/factories/inviteEventBodyFactory.js +92 -0
- package/dist/factories/metaFactory.d.ts +10 -0
- package/dist/factories/metaFactory.d.ts.map +1 -0
- package/dist/factories/metaFactory.js +90 -0
- package/dist/factories/routeBodyFactory.d.ts +19 -0
- package/dist/factories/routeBodyFactory.d.ts.map +1 -0
- package/dist/factories/routeBodyFactory.js +15 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/internal/EnvoyEntryEvent.d.ts +3 -0
- package/dist/internal/EnvoyEntryEvent.d.ts.map +1 -0
- package/dist/internal/EnvoyEntryEvent.js +2 -0
- package/dist/internal/EnvoyInviteEvent.d.ts +3 -0
- package/dist/internal/EnvoyInviteEvent.d.ts.map +1 -0
- package/dist/internal/EnvoyInviteEvent.js +2 -0
- package/dist/internal/EnvoyLocationEvent.d.ts +3 -0
- package/dist/internal/EnvoyLocationEvent.d.ts.map +1 -0
- package/dist/internal/EnvoyLocationEvent.js +2 -0
- package/dist/internal/EnvoyOption.d.ts +6 -0
- package/dist/internal/EnvoyOption.d.ts.map +1 -0
- package/dist/internal/EnvoyOption.js +2 -0
- package/dist/internal/EnvoyOptionsRouteParams.d.ts +7 -0
- package/dist/internal/EnvoyOptionsRouteParams.d.ts.map +1 -0
- package/dist/internal/EnvoyOptionsRouteParams.js +2 -0
- package/dist/internal/EnvoyOptionsRouteResponseBody.d.ts +4 -0
- package/dist/internal/EnvoyOptionsRouteResponseBody.d.ts.map +1 -0
- package/dist/internal/EnvoyOptionsRouteResponseBody.js +2 -0
- package/dist/internal/EnvoyPluginJobUpdate.d.ts +11 -0
- package/dist/internal/EnvoyPluginJobUpdate.d.ts.map +1 -0
- package/dist/internal/EnvoyPluginJobUpdate.js +2 -0
- package/dist/internal/EnvoyRemoteValueRouteResponseBody.d.ts +5 -0
- package/dist/internal/EnvoyRemoteValueRouteResponseBody.d.ts.map +1 -0
- package/dist/internal/EnvoyRemoteValueRouteResponseBody.js +2 -0
- package/dist/internal/EnvoySelectedValuesRouteParams.d.ts +5 -0
- package/dist/internal/EnvoySelectedValuesRouteParams.d.ts.map +1 -0
- package/dist/internal/EnvoySelectedValuesRouteParams.js +2 -0
- package/dist/internal/EnvoySelectedValuesRouteResponseBody.d.ts +4 -0
- package/dist/internal/EnvoySelectedValuesRouteResponseBody.d.ts.map +1 -0
- package/dist/internal/EnvoySelectedValuesRouteResponseBody.js +2 -0
- package/dist/internal/EnvoyStorageCommand.d.ts +42 -0
- package/dist/internal/EnvoyStorageCommand.d.ts.map +1 -0
- package/dist/internal/EnvoyStorageCommand.js +7 -0
- package/dist/internal/EnvoyStorageResult.d.ts +4 -0
- package/dist/internal/EnvoyStorageResult.d.ts.map +1 -0
- package/dist/internal/EnvoyStorageResult.js +2 -0
- package/dist/internal/HttpStatus.d.ts +13 -0
- package/dist/internal/HttpStatus.d.ts.map +1 -0
- package/dist/internal/HttpStatus.js +15 -0
- package/dist/mocks/EnvoyPluginJobMock.d.ts +12 -0
- package/dist/mocks/EnvoyPluginJobMock.d.ts.map +1 -0
- package/dist/mocks/EnvoyPluginJobMock.js +60 -0
- package/dist/mocks/EnvoyPluginStoragePipelineMock.d.ts +24 -0
- package/dist/mocks/EnvoyPluginStoragePipelineMock.d.ts.map +1 -0
- package/dist/mocks/EnvoyPluginStoragePipelineMock.js +212 -0
- package/dist/payloads/EntryPayload.d.ts +80 -0
- package/dist/payloads/EntryPayload.d.ts.map +1 -0
- package/dist/payloads/EntryPayload.js +28 -0
- package/dist/payloads/InvitePayload.d.ts +66 -0
- package/dist/payloads/InvitePayload.d.ts.map +1 -0
- package/dist/payloads/InvitePayload.js +24 -0
- package/dist/payloads/LocationPayload.d.ts +7 -0
- package/dist/payloads/LocationPayload.d.ts.map +1 -0
- package/dist/payloads/LocationPayload.js +2 -0
- package/dist/payloads/NotificationPayload.d.ts +54 -0
- package/dist/payloads/NotificationPayload.d.ts.map +1 -0
- package/dist/payloads/NotificationPayload.js +2 -0
- package/dist/resources/AgreementPageResource.d.ts +17 -0
- package/dist/resources/AgreementPageResource.d.ts.map +1 -0
- package/dist/resources/AgreementPageResource.js +2 -0
- package/dist/resources/AgreementResource.d.ts +24 -0
- package/dist/resources/AgreementResource.d.ts.map +1 -0
- package/dist/resources/AgreementResource.js +2 -0
- package/dist/resources/CompanyResource.d.ts +19 -0
- package/dist/resources/CompanyResource.d.ts.map +1 -0
- package/dist/resources/CompanyResource.js +2 -0
- package/dist/resources/CompanyRoleResource.d.ts +8 -0
- package/dist/resources/CompanyRoleResource.d.ts.map +1 -0
- package/dist/resources/CompanyRoleResource.js +2 -0
- package/dist/resources/CurrentUserResource.d.ts +8 -0
- package/dist/resources/CurrentUserResource.d.ts.map +1 -0
- package/dist/resources/CurrentUserResource.js +2 -0
- package/dist/resources/EmployeeResource.d.ts +43 -0
- package/dist/resources/EmployeeResource.d.ts.map +1 -0
- package/dist/resources/EmployeeResource.js +2 -0
- package/dist/resources/FlowResource.d.ts +31 -0
- package/dist/resources/FlowResource.d.ts.map +1 -0
- package/dist/resources/FlowResource.js +2 -0
- package/dist/resources/InviteResource.d.ts +86 -0
- package/dist/resources/InviteResource.d.ts.map +1 -0
- package/dist/resources/InviteResource.js +2 -0
- package/dist/resources/LocationResource.d.ts +64 -0
- package/dist/resources/LocationResource.d.ts.map +1 -0
- package/dist/resources/LocationResource.js +2 -0
- package/dist/resources/LocationRoleResource.d.ts +8 -0
- package/dist/resources/LocationRoleResource.d.ts.map +1 -0
- package/dist/resources/LocationRoleResource.js +2 -0
- package/dist/resources/SignInFieldPageResource.d.ts +17 -0
- package/dist/resources/SignInFieldPageResource.d.ts.map +1 -0
- package/dist/resources/SignInFieldPageResource.js +2 -0
- package/dist/resources/SignInFieldResource.d.ts +33 -0
- package/dist/resources/SignInFieldResource.d.ts.map +1 -0
- package/dist/resources/SignInFieldResource.js +2 -0
- package/dist/resources/UserResource.d.ts +13 -0
- package/dist/resources/UserResource.d.ts.map +1 -0
- package/dist/resources/UserResource.js +2 -0
- package/dist/sdk/EnvoyMeta.d.ts +96 -0
- package/dist/sdk/EnvoyMeta.d.ts.map +1 -0
- package/dist/sdk/EnvoyMeta.js +2 -0
- package/dist/sdk/EnvoyPluginAPI.d.ts +31 -0
- package/dist/sdk/EnvoyPluginAPI.d.ts.map +1 -0
- package/dist/sdk/EnvoyPluginAPI.js +205 -0
- package/dist/sdk/EnvoyPluginJob.d.ts +49 -0
- package/dist/sdk/EnvoyPluginJob.d.ts.map +1 -0
- package/dist/sdk/EnvoyPluginJob.js +99 -0
- package/dist/sdk/EnvoyPluginJobAttachment.d.ts +43 -0
- package/dist/sdk/EnvoyPluginJobAttachment.d.ts.map +1 -0
- package/dist/sdk/EnvoyPluginJobAttachment.js +2 -0
- package/dist/sdk/EnvoyPluginSDK.d.ts +100 -0
- package/dist/sdk/EnvoyPluginSDK.d.ts.map +1 -0
- package/dist/sdk/EnvoyPluginSDK.js +204 -0
- package/dist/sdk/EnvoyPluginStorage.d.ts +69 -0
- package/dist/sdk/EnvoyPluginStorage.d.ts.map +1 -0
- package/dist/sdk/EnvoyPluginStorage.js +78 -0
- package/dist/sdk/EnvoyRequest.d.ts +116 -0
- package/dist/sdk/EnvoyRequest.d.ts.map +1 -0
- package/dist/sdk/EnvoyRequest.js +7 -0
- package/dist/sdk/EnvoyResponse.d.ts +42 -0
- package/dist/sdk/EnvoyResponse.d.ts.map +1 -0
- package/dist/sdk/EnvoyResponse.js +2 -0
- package/dist/sdk/EnvoyStorageItem.d.ts +9 -0
- package/dist/sdk/EnvoyStorageItem.d.ts.map +1 -0
- package/dist/sdk/EnvoyStorageItem.js +2 -0
- package/dist/sdk/EnvoyUserAPI.d.ts +119 -0
- package/dist/sdk/EnvoyUserAPI.d.ts.map +1 -0
- package/dist/sdk/EnvoyUserAPI.js +493 -0
- package/dist/sdk/filters.d.ts +30 -0
- package/dist/sdk/filters.d.ts.map +1 -0
- package/dist/sdk/filters.js +72 -0
- package/dist/sdk/handlers.d.ts +125 -0
- package/dist/sdk/handlers.d.ts.map +1 -0
- package/dist/sdk/handlers.js +108 -0
- package/dist/sdk/loggers.d.ts +6 -0
- package/dist/sdk/loggers.d.ts.map +1 -0
- package/dist/sdk/loggers.js +161 -0
- package/dist/sdk/middleware.d.ts +19 -0
- package/dist/sdk/middleware.d.ts.map +1 -0
- package/dist/sdk/middleware.js +159 -0
- package/dist/util/EnvoyJWT.d.ts +17 -0
- package/dist/util/EnvoyJWT.d.ts.map +1 -0
- package/dist/util/EnvoyJWT.js +54 -0
- package/dist/util/EnvoySignatureVerifier.d.ts +26 -0
- package/dist/util/EnvoySignatureVerifier.d.ts.map +1 -0
- package/dist/util/EnvoySignatureVerifier.js +53 -0
- package/dist/util/axiosConstructor.d.ts +4 -0
- package/dist/util/axiosConstructor.d.ts.map +1 -0
- package/dist/util/axiosConstructor.js +58 -0
- package/dist/util/errorHandling.d.ts +2 -0
- package/dist/util/errorHandling.d.ts.map +1 -0
- package/dist/util/errorHandling.js +18 -0
- package/dist/util/json-api/JSONAPIData.d.ts +5 -0
- package/dist/util/json-api/JSONAPIData.d.ts.map +1 -0
- package/dist/util/json-api/JSONAPIData.js +2 -0
- package/dist/util/json-api/JSONAPIFilterParams.d.ts +5 -0
- package/dist/util/json-api/JSONAPIFilterParams.d.ts.map +1 -0
- package/dist/util/json-api/JSONAPIFilterParams.js +2 -0
- package/dist/util/json-api/JSONAPIModel.d.ts +10 -0
- package/dist/util/json-api/JSONAPIModel.d.ts.map +1 -0
- package/dist/util/json-api/JSONAPIModel.js +2 -0
- package/dist/util/json-api/JSONAPIPaginationParams.d.ts +9 -0
- package/dist/util/json-api/JSONAPIPaginationParams.d.ts.map +1 -0
- package/dist/util/json-api/JSONAPIPaginationParams.js +2 -0
- package/dist/util/json-api/JSONAPIParams.d.ts +4 -0
- package/dist/util/json-api/JSONAPIParams.d.ts.map +1 -0
- package/dist/util/json-api/JSONAPIParams.js +2 -0
- package/dist/util/json-api/JSONAPIResponse.d.ts +6 -0
- package/dist/util/json-api/JSONAPIResponse.d.ts.map +1 -0
- package/dist/util/json-api/JSONAPIResponse.js +2 -0
- package/package.json +48 -13
- package/src/base/EnvoyAPI.ts +87 -0
- package/src/base/EnvoyPluginStoragePipeline.ts +99 -0
- package/src/constants.ts +7 -0
- package/src/factories/entryEventBodyFactory.ts +124 -0
- package/src/factories/eventBodyFactory.ts +35 -0
- package/src/factories/inviteEventBodyFactory.ts +107 -0
- package/src/factories/metaFactory.ts +109 -0
- package/src/factories/routeBodyFactory.ts +37 -0
- package/src/index.ts +86 -0
- package/src/internal/EnvoyEntryEvent.ts +10 -0
- package/src/internal/EnvoyInviteEvent.ts +13 -0
- package/src/internal/EnvoyLocationEvent.ts +3 -0
- package/src/internal/EnvoyOption.ts +6 -0
- package/src/internal/EnvoyOptionsRouteParams.ts +7 -0
- package/src/internal/EnvoyOptionsRouteResponseBody.ts +4 -0
- package/src/internal/EnvoyPluginJobUpdate.ts +11 -0
- package/src/internal/EnvoyRemoteValueRouteResponseBody.ts +4 -0
- package/src/internal/EnvoySelectedValuesRouteParams.ts +5 -0
- package/src/internal/EnvoySelectedValuesRouteResponseBody.ts +4 -0
- package/src/internal/EnvoyStorageCommand.ts +60 -0
- package/src/internal/EnvoyStorageResult.ts +5 -0
- package/src/internal/HttpStatus.ts +12 -0
- package/src/mocks/EnvoyPluginJobMock.ts +33 -0
- package/src/mocks/EnvoyPluginStoragePipelineMock.ts +204 -0
- package/src/payloads/EntryPayload.ts +101 -0
- package/src/payloads/InvitePayload.ts +79 -0
- package/src/payloads/LocationPayload.ts +8 -0
- package/src/payloads/NotificationPayload.ts +54 -0
- package/src/resources/AgreementPageResource.ts +19 -0
- package/src/resources/AgreementResource.ts +26 -0
- package/src/resources/CompanyResource.ts +21 -0
- package/src/resources/CompanyRoleResource.ts +10 -0
- package/src/resources/CurrentUserResource.ts +10 -0
- package/src/resources/EmployeeResource.ts +47 -0
- package/src/resources/FlowResource.ts +35 -0
- package/src/resources/InviteResource.ts +92 -0
- package/src/resources/LocationResource.ts +68 -0
- package/src/resources/LocationRoleResource.ts +10 -0
- package/src/resources/SignInFieldPageResource.ts +23 -0
- package/src/resources/SignInFieldResource.ts +35 -0
- package/src/resources/UserResource.ts +14 -0
- package/src/sdk/EnvoyMeta.ts +101 -0
- package/src/sdk/EnvoyPluginAPI.ts +95 -0
- package/src/sdk/EnvoyPluginJob.ts +90 -0
- package/src/sdk/EnvoyPluginJobAttachment.ts +48 -0
- package/src/sdk/EnvoyPluginSDK.ts +185 -0
- package/src/sdk/EnvoyPluginStorage.ts +83 -0
- package/src/sdk/EnvoyRequest.ts +145 -0
- package/src/sdk/EnvoyResponse.ts +46 -0
- package/src/sdk/EnvoyStorageItem.ts +9 -0
- package/src/sdk/EnvoyUserAPI.ts +339 -0
- package/src/sdk/filters.ts +96 -0
- package/src/sdk/handlers.ts +234 -0
- package/src/sdk/loggers.ts +165 -0
- package/src/sdk/middleware.ts +101 -0
- package/src/util/EnvoyJWT.ts +51 -0
- package/src/util/EnvoySignatureVerifier.ts +61 -0
- package/src/util/axiosConstructor.ts +46 -0
- package/src/util/errorHandling.ts +15 -0
- package/src/util/json-api/JSONAPIData.ts +4 -0
- package/src/util/json-api/JSONAPIFilterParams.ts +5 -0
- package/src/util/json-api/JSONAPIModel.ts +10 -0
- package/src/util/json-api/JSONAPIPaginationParams.ts +12 -0
- package/src/util/json-api/JSONAPIParams.ts +3 -0
- package/src/util/json-api/JSONAPIResponse.ts +5 -0
- package/.eslintrc.js +0 -46
- package/.github/workflows/package.yaml +0 -43
- package/.github/workflows/test.yaml +0 -15
- package/asynchandler.md +0 -46
- package/envoyapi.md +0 -150
- package/envoyjwt.md +0 -46
- package/envoypluginjob.md +0 -106
- package/envoypluginsdk.md +0 -87
- package/envoypluginstorage.md +0 -95
- package/envoypluginstoragepipeline.md +0 -125
- package/envoysignatureverifier.md +0 -43
- package/errormiddleware.md +0 -41
- package/index.js +0 -49
- package/lib/EnvoyAPI.js +0 -564
- package/lib/EnvoyJWT.js +0 -72
- package/lib/EnvoyPluginJob.js +0 -124
- package/lib/EnvoyPluginSDK.js +0 -192
- package/lib/EnvoyPluginStorage.js +0 -121
- package/lib/EnvoyPluginStoragePipeline.js +0 -155
- package/lib/EnvoyResponseError.js +0 -18
- package/lib/EnvoySignatureVerifier.js +0 -67
- package/lib/HttpStatus.js +0 -20
- package/lib/asyncHandler.js +0 -17
- package/lib/axios.js +0 -34
- package/lib/errorMiddleware.js +0 -27
- package/lib/middleware.js +0 -110
- package/middleware.md +0 -53
- package/test/axios.test.js +0 -57
- package/test/promises.test.js +0 -82
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Sync, each } from 'factory.ts';
|
|
2
|
+
import faker from 'faker';
|
|
3
|
+
|
|
4
|
+
import EntryPayload from '../payloads/EntryPayload';
|
|
5
|
+
import EnvoyEntryEvent from '../internal/EnvoyEntryEvent';
|
|
6
|
+
import { EnvoyUserAPIScope } from '../sdk/EnvoyUserAPI';
|
|
7
|
+
import eventBodyFactory from './eventBodyFactory';
|
|
8
|
+
|
|
9
|
+
export type EntryPayloadFactoryVisitorOptions = {
|
|
10
|
+
isProtectFlow: false,
|
|
11
|
+
isSignedIn: boolean,
|
|
12
|
+
hasEmail: boolean,
|
|
13
|
+
hasHost: boolean,
|
|
14
|
+
hasInvite: boolean,
|
|
15
|
+
hasDevice: boolean,
|
|
16
|
+
hasPhoneNumber?: boolean,
|
|
17
|
+
hasPhoto?: boolean,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type EntryPayloadFactoryProtectOptions = {
|
|
21
|
+
isProtectFlow: true,
|
|
22
|
+
isSignedIn: boolean,
|
|
23
|
+
hasPhoneNumber?: boolean,
|
|
24
|
+
hasPhoto?: boolean,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type EntryPayloadFactoryOptions = EntryPayloadFactoryVisitorOptions | EntryPayloadFactoryProtectOptions;
|
|
28
|
+
|
|
29
|
+
export const entryEventBodyFactoryDefaultIds = {
|
|
30
|
+
location: '1',
|
|
31
|
+
company: '1',
|
|
32
|
+
flow: '1',
|
|
33
|
+
invite: '1',
|
|
34
|
+
device: '1',
|
|
35
|
+
employee: '1',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function entryPayloadFactory(
|
|
39
|
+
options: EntryPayloadFactoryOptions,
|
|
40
|
+
ids: Partial<typeof entryEventBodyFactoryDefaultIds> = entryEventBodyFactoryDefaultIds,
|
|
41
|
+
): Sync.Factory<EntryPayload> {
|
|
42
|
+
const signedInDate = faker.date.past();
|
|
43
|
+
const allIds = { ...entryEventBodyFactoryDefaultIds, ...ids };
|
|
44
|
+
return Sync.makeFactory<EntryPayload>({
|
|
45
|
+
id: each((i) => `${i + 1}`),
|
|
46
|
+
type: 'entries',
|
|
47
|
+
attributes: {
|
|
48
|
+
'full-name': faker.name.findName(),
|
|
49
|
+
'phone-number': options.hasPhoneNumber ? faker.phone.phoneNumber() : undefined,
|
|
50
|
+
email: (options.isProtectFlow || options.hasEmail) ? faker.internet.email() : null,
|
|
51
|
+
'employee-screening-flow': options.isProtectFlow,
|
|
52
|
+
host: (!options.isProtectFlow && options.hasHost) ? faker.name.findName() : null,
|
|
53
|
+
'host-email': (!options.isProtectFlow && options.hasHost) ? faker.internet.email() : null,
|
|
54
|
+
'private-notes': null,
|
|
55
|
+
'signed-in-at': signedInDate.toISOString(),
|
|
56
|
+
'signed-out-at': options.isSignedIn ? undefined : faker.date.between(signedInDate, new Date()).toISOString(),
|
|
57
|
+
thumbnails: options.hasPhoto ? {
|
|
58
|
+
large: faker.image.avatar(),
|
|
59
|
+
original: faker.image.avatar(),
|
|
60
|
+
small: faker.image.avatar(),
|
|
61
|
+
} : {
|
|
62
|
+
large: null,
|
|
63
|
+
original: null,
|
|
64
|
+
small: null,
|
|
65
|
+
},
|
|
66
|
+
'flow-name': options.isProtectFlow ? 'Employee registration' : 'Visitor',
|
|
67
|
+
'user-data': [] as Array<{ field: string, value: string | null }>,
|
|
68
|
+
},
|
|
69
|
+
relationships: {
|
|
70
|
+
location: {
|
|
71
|
+
data: {
|
|
72
|
+
id: allIds.location,
|
|
73
|
+
type: 'locations',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
flow: {
|
|
77
|
+
data: {
|
|
78
|
+
id: allIds.flow,
|
|
79
|
+
type: 'flows',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
invite: (options.isProtectFlow || options.hasInvite) ? {
|
|
83
|
+
data: {
|
|
84
|
+
id: allIds.invite,
|
|
85
|
+
type: 'invites',
|
|
86
|
+
},
|
|
87
|
+
} : undefined,
|
|
88
|
+
device: (!options.isProtectFlow && options.hasDevice) ? {
|
|
89
|
+
data: {
|
|
90
|
+
id: allIds.device,
|
|
91
|
+
type: 'devices',
|
|
92
|
+
},
|
|
93
|
+
} : undefined,
|
|
94
|
+
employee: (options.isProtectFlow || options.hasHost) ? {
|
|
95
|
+
data: {
|
|
96
|
+
id: allIds.employee,
|
|
97
|
+
type: 'employees',
|
|
98
|
+
},
|
|
99
|
+
} : undefined,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type EntryEventBodyFactoryOptions<Config extends Record<string, unknown> = Record<string, never>> = {
|
|
105
|
+
event: EnvoyEntryEvent,
|
|
106
|
+
config: Partial<Config>,
|
|
107
|
+
payloadOptions: EntryPayloadFactoryOptions,
|
|
108
|
+
scope?: Array<EnvoyUserAPIScope>,
|
|
109
|
+
ids?: Partial<typeof entryEventBodyFactoryDefaultIds>,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export default function entryEventBodyFactory<Config extends Record<string, unknown> = Record<string, never>>(
|
|
113
|
+
options: EntryEventBodyFactoryOptions<Config>,
|
|
114
|
+
) {
|
|
115
|
+
const ids = options.ids || entryEventBodyFactoryDefaultIds;
|
|
116
|
+
return eventBodyFactory<EnvoyEntryEvent, Config, EntryPayload>({
|
|
117
|
+
event: options.event,
|
|
118
|
+
config: options.config,
|
|
119
|
+
scope: options.scope || [],
|
|
120
|
+
locationId: options.ids?.location || entryEventBodyFactoryDefaultIds.location,
|
|
121
|
+
companyId: options.ids?.company || entryEventBodyFactoryDefaultIds.company,
|
|
122
|
+
payload: entryPayloadFactory(options.payloadOptions, ids).build(),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EnvoyUserAPIScope } from '../sdk/EnvoyUserAPI';
|
|
2
|
+
import { eventMetaFactory } from './metaFactory';
|
|
3
|
+
|
|
4
|
+
export const eventBodyFactoryDefaultIds = {
|
|
5
|
+
locationId: '1',
|
|
6
|
+
companyId: '1',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type EventBodyFactoryOptions<Event, Config, Payload> = {
|
|
10
|
+
event: Event,
|
|
11
|
+
config: Partial<Config>,
|
|
12
|
+
payload: Payload,
|
|
13
|
+
scope: Array<EnvoyUserAPIScope>,
|
|
14
|
+
locationId?: string,
|
|
15
|
+
companyId?: string,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default function eventBodyFactory<
|
|
19
|
+
Event extends string = string,
|
|
20
|
+
Config extends Record<string, unknown> = Record<string, never>,
|
|
21
|
+
Payload extends Record<string, unknown> = Record<string, never>,
|
|
22
|
+
>(
|
|
23
|
+
options: EventBodyFactoryOptions<Event, Config, Payload>,
|
|
24
|
+
) {
|
|
25
|
+
return {
|
|
26
|
+
meta: eventMetaFactory<Config>(
|
|
27
|
+
options.event,
|
|
28
|
+
options.config,
|
|
29
|
+
options.scope,
|
|
30
|
+
options.locationId || eventBodyFactoryDefaultIds.locationId,
|
|
31
|
+
options.companyId || eventBodyFactoryDefaultIds.companyId,
|
|
32
|
+
).build(),
|
|
33
|
+
payload: options.payload,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Sync, each } from 'factory.ts';
|
|
2
|
+
import faker from 'faker';
|
|
3
|
+
|
|
4
|
+
import InvitePayload from '../payloads/InvitePayload';
|
|
5
|
+
import EnvoyInviteEvent from '../internal/EnvoyInviteEvent';
|
|
6
|
+
import { EnvoyUserAPIScope } from '../sdk/EnvoyUserAPI';
|
|
7
|
+
import eventBodyFactory from './eventBodyFactory';
|
|
8
|
+
|
|
9
|
+
export type InvitePayloadFactoryVisitorOptions = {
|
|
10
|
+
isProtectFlow: false,
|
|
11
|
+
hasEmail: boolean,
|
|
12
|
+
hasHost: boolean,
|
|
13
|
+
preregistrationComplete: boolean,
|
|
14
|
+
hasPhoto?: boolean,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type InvitePayloadFactoryProtectOptions = {
|
|
18
|
+
isProtectFlow: true,
|
|
19
|
+
preregistrationComplete: boolean,
|
|
20
|
+
hasPhoto?: boolean,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type InvitePayloadFactoryOptions = InvitePayloadFactoryVisitorOptions | InvitePayloadFactoryProtectOptions;
|
|
24
|
+
|
|
25
|
+
export const inviteEventBodyFactoryDefaultIds = {
|
|
26
|
+
location: '1',
|
|
27
|
+
company: '1',
|
|
28
|
+
flow: '1',
|
|
29
|
+
invite: '1',
|
|
30
|
+
device: '1',
|
|
31
|
+
employee: '1',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export function invitePayloadFactory(
|
|
35
|
+
options: InvitePayloadFactoryOptions,
|
|
36
|
+
ids: Partial<typeof inviteEventBodyFactoryDefaultIds> = inviteEventBodyFactoryDefaultIds,
|
|
37
|
+
): Sync.Factory<InvitePayload> {
|
|
38
|
+
const signedInDate = faker.date.past();
|
|
39
|
+
const allIds = { ...inviteEventBodyFactoryDefaultIds, ...ids };
|
|
40
|
+
return Sync.makeFactory<InvitePayload>({
|
|
41
|
+
id: each((i) => `${i + 1}`),
|
|
42
|
+
type: 'invites',
|
|
43
|
+
attributes: {
|
|
44
|
+
'employee-screening-flow': options.isProtectFlow,
|
|
45
|
+
'full-name': faker.name.findName(),
|
|
46
|
+
email: (options.isProtectFlow || options.hasEmail) ? faker.internet.email() : null,
|
|
47
|
+
'inviter-name': (!options.isProtectFlow && options.hasHost) ? faker.name.findName() : null,
|
|
48
|
+
'inviter-email': (!options.isProtectFlow && options.hasHost) ? faker.internet.email() : null,
|
|
49
|
+
'expected-arrival-time': faker.date.future().toISOString(),
|
|
50
|
+
'private-notes': null,
|
|
51
|
+
arrived: false,
|
|
52
|
+
'been-here-before': false,
|
|
53
|
+
'flow-name': options.isProtectFlow ? 'Employee registration' : 'Visitor',
|
|
54
|
+
'flow-id': allIds.flow,
|
|
55
|
+
'user-data': [] as Array<{ field: string, value: string | null }>,
|
|
56
|
+
'secret-token': faker.random.alphaNumeric(10),
|
|
57
|
+
'edit-token': faker.random.alphaNumeric(10),
|
|
58
|
+
'photo-url': faker.image.avatar(),
|
|
59
|
+
'qr-code': null,
|
|
60
|
+
'qr-code-sent-at': null,
|
|
61
|
+
'preregistration-complete': options.preregistrationComplete,
|
|
62
|
+
'reminder-sent-at': null,
|
|
63
|
+
},
|
|
64
|
+
relationships: {
|
|
65
|
+
location: {
|
|
66
|
+
data: {
|
|
67
|
+
id: allIds.location,
|
|
68
|
+
type: 'locations',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
flow: {
|
|
72
|
+
data: {
|
|
73
|
+
id: allIds.flow,
|
|
74
|
+
type: 'flows',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
employee: (options.isProtectFlow || options.hasHost) ? {
|
|
78
|
+
data: {
|
|
79
|
+
id: allIds.employee,
|
|
80
|
+
type: 'employees',
|
|
81
|
+
},
|
|
82
|
+
} : undefined,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type InviteEventBodyFactoryOptions<Config extends Record<string, unknown> = Record<string, never>> = {
|
|
88
|
+
event: EnvoyInviteEvent,
|
|
89
|
+
config: Partial<Config>,
|
|
90
|
+
payloadOptions: InvitePayloadFactoryOptions,
|
|
91
|
+
scope?: Array<EnvoyUserAPIScope>,
|
|
92
|
+
ids?: Partial<typeof inviteEventBodyFactoryDefaultIds>,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default function entryEventBodyFactory<Config extends Record<string, unknown> = Record<string, never>>(
|
|
96
|
+
options: InviteEventBodyFactoryOptions<Config>,
|
|
97
|
+
) {
|
|
98
|
+
const ids = options.ids || inviteEventBodyFactoryDefaultIds;
|
|
99
|
+
return eventBodyFactory<EnvoyInviteEvent, Config, InvitePayload>({
|
|
100
|
+
event: options.event,
|
|
101
|
+
config: options.config,
|
|
102
|
+
scope: options.scope || [],
|
|
103
|
+
locationId: options.ids?.location || inviteEventBodyFactoryDefaultIds.location,
|
|
104
|
+
companyId: options.ids?.company || inviteEventBodyFactoryDefaultIds.company,
|
|
105
|
+
payload: invitePayloadFactory(options.payloadOptions, ids).build(),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Sync } from 'factory.ts';
|
|
2
|
+
import faker from 'faker';
|
|
3
|
+
import {
|
|
4
|
+
EnvoyEventMeta,
|
|
5
|
+
EnvoyMetaAuth,
|
|
6
|
+
EnvoyMetaCompany,
|
|
7
|
+
EnvoyMetaJob,
|
|
8
|
+
EnvoyMetaLocation,
|
|
9
|
+
EnvoyRouteMeta,
|
|
10
|
+
} from '../sdk/EnvoyMeta';
|
|
11
|
+
import { EnvoyUserAPIScope } from '../sdk/EnvoyUserAPI';
|
|
12
|
+
|
|
13
|
+
export function jobFactory(name: string): Sync.Factory<EnvoyMetaJob> {
|
|
14
|
+
return Sync.makeFactory<EnvoyMetaJob>({
|
|
15
|
+
id: faker.datatype.uuid(),
|
|
16
|
+
identifier: faker.datatype.string(),
|
|
17
|
+
name,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function locationFactory(id: string): Sync.Factory<EnvoyMetaLocation> {
|
|
22
|
+
const cityName = faker.address.cityName();
|
|
23
|
+
const street = faker.address.streetAddress();
|
|
24
|
+
return Sync.makeFactory<EnvoyMetaLocation>({
|
|
25
|
+
id,
|
|
26
|
+
type: 'locations',
|
|
27
|
+
attributes: {
|
|
28
|
+
name: cityName,
|
|
29
|
+
'company-name-override': null,
|
|
30
|
+
timezone: faker.address.timeZone(),
|
|
31
|
+
locale: null,
|
|
32
|
+
address: street,
|
|
33
|
+
'address-line-one': street,
|
|
34
|
+
'address-line-two': null,
|
|
35
|
+
city: cityName,
|
|
36
|
+
state: faker.address.stateAbbr(),
|
|
37
|
+
country: faker.address.country(),
|
|
38
|
+
zip: faker.address.zipCode(),
|
|
39
|
+
longitude: null,
|
|
40
|
+
latitude: null,
|
|
41
|
+
'created-at': faker.date.past().toISOString(),
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function companyFactory(id: string): Sync.Factory<EnvoyMetaCompany> {
|
|
47
|
+
return Sync.makeFactory<EnvoyMetaCompany>({
|
|
48
|
+
id,
|
|
49
|
+
type: 'companies',
|
|
50
|
+
attributes: {
|
|
51
|
+
name: faker.company.companyName(),
|
|
52
|
+
active: true,
|
|
53
|
+
'created-at': faker.date.past().toISOString(),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function authFactory(): Sync.Factory<EnvoyMetaAuth> {
|
|
59
|
+
return Sync.makeFactory<EnvoyMetaAuth>({
|
|
60
|
+
token_type: 'Bearer',
|
|
61
|
+
access_token: faker.random.alphaNumeric(),
|
|
62
|
+
expires_in: faker.date.future().getSeconds(),
|
|
63
|
+
refresh_token: null,
|
|
64
|
+
refresh_token_expires_in: null,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function routeMetaFactory<
|
|
69
|
+
Config extends Record<string, unknown> = Record<string, never>,
|
|
70
|
+
Params extends Record<string, unknown> = Record<string, never>,
|
|
71
|
+
>(
|
|
72
|
+
route: string,
|
|
73
|
+
config: Partial<Config>,
|
|
74
|
+
params: Params,
|
|
75
|
+
scope: Array<EnvoyUserAPIScope>,
|
|
76
|
+
locationId: string,
|
|
77
|
+
companyId: string,
|
|
78
|
+
): Sync.Factory<EnvoyRouteMeta> {
|
|
79
|
+
return Sync.makeFactory<EnvoyRouteMeta>({
|
|
80
|
+
plugin_id: faker.datatype.uuid(),
|
|
81
|
+
install_id: Math.ceil(Math.abs(faker.datatype.number())).toString(),
|
|
82
|
+
location: locationFactory(locationId).build(),
|
|
83
|
+
company: companyFactory(companyId).build(),
|
|
84
|
+
auth: scope.length ? authFactory().build() : null,
|
|
85
|
+
forwarded_bearer_token: faker.random.alphaNumeric(),
|
|
86
|
+
route,
|
|
87
|
+
config,
|
|
88
|
+
params,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function eventMetaFactory<Config extends Record<string, unknown> = Record<string, never>>(
|
|
93
|
+
event: string,
|
|
94
|
+
config: Partial<Config>,
|
|
95
|
+
scope: Array<EnvoyUserAPIScope>,
|
|
96
|
+
locationId: string,
|
|
97
|
+
companyId: string,
|
|
98
|
+
): Sync.Factory<EnvoyEventMeta> {
|
|
99
|
+
return Sync.makeFactory<EnvoyEventMeta>({
|
|
100
|
+
plugin_id: faker.datatype.uuid(),
|
|
101
|
+
install_id: Math.ceil(Math.abs(faker.datatype.number())).toString(),
|
|
102
|
+
job: jobFactory(event).build(),
|
|
103
|
+
location: locationFactory(locationId).build(),
|
|
104
|
+
company: companyFactory(companyId).build(),
|
|
105
|
+
auth: scope.length ? authFactory().build() : null,
|
|
106
|
+
event,
|
|
107
|
+
config,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EnvoyUserAPIScope } from '../sdk/EnvoyUserAPI';
|
|
2
|
+
import { routeMetaFactory } from './metaFactory';
|
|
3
|
+
|
|
4
|
+
export const routeBodyFactoryDefaultIds = {
|
|
5
|
+
locationId: '1',
|
|
6
|
+
companyId: '1',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type RouteBodyFactoryOptions<Config, Params, Payload> = {
|
|
10
|
+
config: Partial<Config>,
|
|
11
|
+
params: Params,
|
|
12
|
+
payload: Payload,
|
|
13
|
+
scope?: Array<EnvoyUserAPIScope>,
|
|
14
|
+
locationId?: string,
|
|
15
|
+
companyId?: string,
|
|
16
|
+
route?: string,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default function routeBodyFactory<
|
|
20
|
+
Config extends Record<string, unknown> = Record<string, never>,
|
|
21
|
+
Params extends Record<string, unknown> = Record<string, never>,
|
|
22
|
+
Payload extends Record<string, unknown> = Record<string, never>,
|
|
23
|
+
>(
|
|
24
|
+
options: RouteBodyFactoryOptions<Config, Params, Payload>,
|
|
25
|
+
) {
|
|
26
|
+
return {
|
|
27
|
+
meta: routeMetaFactory<Config, Params>(
|
|
28
|
+
options.route || '',
|
|
29
|
+
options.config,
|
|
30
|
+
options.params,
|
|
31
|
+
options.scope || [],
|
|
32
|
+
options.locationId || routeBodyFactoryDefaultIds.locationId,
|
|
33
|
+
options.companyId || routeBodyFactoryDefaultIds.companyId,
|
|
34
|
+
).build(),
|
|
35
|
+
payload: options.payload,
|
|
36
|
+
};
|
|
37
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import './constants';
|
|
2
|
+
|
|
3
|
+
import EnvoyPluginStoragePipeline from './base/EnvoyPluginStoragePipeline';
|
|
4
|
+
|
|
5
|
+
import entryEventBodyFactory from './factories/entryEventBodyFactory';
|
|
6
|
+
import eventBodyFactory from './factories/eventBodyFactory';
|
|
7
|
+
import inviteEventBodyFactory from './factories/inviteEventBodyFactory';
|
|
8
|
+
import routeBodyFactory from './factories/routeBodyFactory';
|
|
9
|
+
|
|
10
|
+
import HttpStatus from './internal/HttpStatus';
|
|
11
|
+
|
|
12
|
+
import EnvoyPluginJobMock from './mocks/EnvoyPluginJobMock';
|
|
13
|
+
import EnvoyPluginStoragePipelineMock from './mocks/EnvoyPluginStoragePipelineMock';
|
|
14
|
+
|
|
15
|
+
import EntryPayload from './payloads/EntryPayload';
|
|
16
|
+
import InvitePayload from './payloads/InvitePayload';
|
|
17
|
+
|
|
18
|
+
import EnvoyMeta from './sdk/EnvoyMeta';
|
|
19
|
+
import EnvoyPluginJob from './sdk/EnvoyPluginJob';
|
|
20
|
+
import EnvoyPluginSDK from './sdk/EnvoyPluginSDK';
|
|
21
|
+
import EnvoyPluginStorage from './sdk/EnvoyPluginStorage';
|
|
22
|
+
import EnvoyRequest from './sdk/EnvoyRequest';
|
|
23
|
+
import EnvoyResponse from './sdk/EnvoyResponse';
|
|
24
|
+
import EnvoyStorageItem from './sdk/EnvoyStorageItem';
|
|
25
|
+
import EnvoyUserAPI from './sdk/EnvoyUserAPI';
|
|
26
|
+
import EnvoyPluginAPI from './sdk/EnvoyPluginAPI';
|
|
27
|
+
|
|
28
|
+
import EnvoyJWT from './util/EnvoyJWT';
|
|
29
|
+
import EnvoySignatureVerifier from './util/EnvoySignatureVerifier';
|
|
30
|
+
import JSONAPIData from './util/json-api/JSONAPIData';
|
|
31
|
+
|
|
32
|
+
export * from './factories/entryEventBodyFactory';
|
|
33
|
+
export * from './factories/eventBodyFactory';
|
|
34
|
+
export * from './factories/inviteEventBodyFactory';
|
|
35
|
+
export * from './factories/metaFactory';
|
|
36
|
+
export * from './factories/routeBodyFactory';
|
|
37
|
+
|
|
38
|
+
export * from './resources/AgreementPageResource';
|
|
39
|
+
export * from './resources/AgreementResource';
|
|
40
|
+
export * from './resources/CompanyResource';
|
|
41
|
+
export * from './resources/CompanyRoleResource';
|
|
42
|
+
export * from './resources/CurrentUserResource';
|
|
43
|
+
export * from './resources/EmployeeResource';
|
|
44
|
+
export * from './resources/FlowResource';
|
|
45
|
+
export * from './resources/InviteResource';
|
|
46
|
+
export * from './resources/LocationResource';
|
|
47
|
+
export * from './resources/LocationRoleResource';
|
|
48
|
+
export * from './resources/SignInFieldPageResource';
|
|
49
|
+
export * from './resources/SignInFieldResource';
|
|
50
|
+
export * from './resources/UserResource';
|
|
51
|
+
|
|
52
|
+
export * from './sdk/EnvoyMeta';
|
|
53
|
+
export * from './sdk/EnvoyRequest';
|
|
54
|
+
export * from './sdk/EnvoyResponse';
|
|
55
|
+
export * from './sdk/filters';
|
|
56
|
+
export * from './sdk/handlers';
|
|
57
|
+
export * from './sdk/loggers';
|
|
58
|
+
export * from './sdk/middleware';
|
|
59
|
+
|
|
60
|
+
export * from './util/EnvoySignatureVerifier';
|
|
61
|
+
export * from './util/axiosConstructor';
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
EntryPayload,
|
|
65
|
+
InvitePayload,
|
|
66
|
+
EnvoyJWT,
|
|
67
|
+
EnvoyMeta,
|
|
68
|
+
EnvoyPluginJob,
|
|
69
|
+
EnvoyPluginJobMock,
|
|
70
|
+
EnvoyPluginSDK,
|
|
71
|
+
EnvoyPluginStorage,
|
|
72
|
+
EnvoyPluginStoragePipeline,
|
|
73
|
+
EnvoyPluginStoragePipelineMock,
|
|
74
|
+
EnvoyRequest,
|
|
75
|
+
EnvoyResponse,
|
|
76
|
+
EnvoySignatureVerifier,
|
|
77
|
+
EnvoyStorageItem,
|
|
78
|
+
EnvoyPluginAPI,
|
|
79
|
+
EnvoyUserAPI,
|
|
80
|
+
JSONAPIData,
|
|
81
|
+
HttpStatus,
|
|
82
|
+
entryEventBodyFactory,
|
|
83
|
+
eventBodyFactory,
|
|
84
|
+
inviteEventBodyFactory,
|
|
85
|
+
routeBodyFactory,
|
|
86
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type EnvoyInviteEvent =
|
|
2
|
+
'invite_created' |
|
|
3
|
+
'invite_updated' |
|
|
4
|
+
'invite_removed' |
|
|
5
|
+
'upcoming_visit' |
|
|
6
|
+
'qr_code_sent' |
|
|
7
|
+
'employee_invite_created' |
|
|
8
|
+
'employee_invite_updated' |
|
|
9
|
+
'employee_invite_removed' |
|
|
10
|
+
'employee_upcoming_visit' |
|
|
11
|
+
string;
|
|
12
|
+
|
|
13
|
+
export default EnvoyInviteEvent;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import EnvoyPluginJobAttachment from '../sdk/EnvoyPluginJobAttachment';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export default interface EnvoyPluginJobUpdate {
|
|
7
|
+
status?: string,
|
|
8
|
+
status_message?: string,
|
|
9
|
+
failure_reason?: string,
|
|
10
|
+
attachments: Array<EnvoyPluginJobAttachment>,
|
|
11
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const UNIQUE_OPTIONS_DEFAULT_CHARS = '0123456789';
|
|
2
|
+
|
|
3
|
+
export const UNIQUE_OPTIONS_DEFAULT_SIZE = 12;
|
|
4
|
+
|
|
5
|
+
export const UNIQUE_NUM_OPTIONS_DEFAULT_MIN = 0;
|
|
6
|
+
|
|
7
|
+
export const UNIQUE_NUM_OPTIONS_DEFAULT_MAX = 9_007_199_254_740_991;
|
|
8
|
+
|
|
9
|
+
export interface EnvoyStorageSetUniqueOptions {
|
|
10
|
+
chars?: string,
|
|
11
|
+
size?: number,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface EnvoyStorageSetUniqueNumOptions {
|
|
15
|
+
min?: number,
|
|
16
|
+
max?: number,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface EnvoyBaseStorageCommand {
|
|
20
|
+
action: 'get' | 'set' | 'set_unique' | 'set_unique_num' | 'unset',
|
|
21
|
+
key: string,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface EnvoyGetStorageCommand extends EnvoyBaseStorageCommand {
|
|
25
|
+
action: 'get',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface EnvoySetStorageCommand extends EnvoyBaseStorageCommand {
|
|
29
|
+
action: 'set',
|
|
30
|
+
value: unknown,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface EnvoySetUniqueStorageCommand extends EnvoyBaseStorageCommand, EnvoyStorageSetUniqueOptions {
|
|
34
|
+
action: 'set_unique',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface EnvoySetUniqueNumStorageCommand extends EnvoyBaseStorageCommand, EnvoyStorageSetUniqueNumOptions {
|
|
38
|
+
action: 'set_unique_num',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface EnvoyUnsetStorageCommand extends EnvoyBaseStorageCommand {
|
|
42
|
+
action: 'unset',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface EnvoyListStorageCommand {
|
|
46
|
+
action: 'list',
|
|
47
|
+
page: number,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
type EnvoyStorageCommand = EnvoyGetStorageCommand
|
|
54
|
+
| EnvoySetStorageCommand
|
|
55
|
+
| EnvoySetUniqueStorageCommand
|
|
56
|
+
| EnvoySetUniqueNumStorageCommand
|
|
57
|
+
| EnvoyUnsetStorageCommand
|
|
58
|
+
| EnvoyListStorageCommand;
|
|
59
|
+
|
|
60
|
+
export default EnvoyStorageCommand;
|