@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,125 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { RequestHandler, Request, Response } from 'express';
|
|
3
|
+
import { EnvoyEntryEventRequest, EnvoyEventRequest, EnvoyInviteEventRequest, EnvoyLocationEventRequest, EnvoyMigrationRouteRequest, EnvoyNotificationEventRequest, EnvoyOptionsRouteRequest, EnvoyRemoteValueRouteRequest, EnvoySelectedValuesRouteRequest, EnvoyValidationRouteRequest } from './EnvoyRequest';
|
|
4
|
+
import EnvoyResponse, { EnvoyOptionsRouteResponse, EnvoyRemoteValueRouteResponse, EnvoySelectedValuesRouteResponse } from './EnvoyResponse';
|
|
5
|
+
declare type SomeObject = Record<string, unknown>;
|
|
6
|
+
declare type Result = Promise<void> | void;
|
|
7
|
+
/**
|
|
8
|
+
* Handle an entry event, such as `entry_sign_in`.
|
|
9
|
+
* @category Handler
|
|
10
|
+
*/
|
|
11
|
+
export declare type EntryEventHandler<Config = SomeObject, Additions = SomeObject> = (req: EnvoyEntryEventRequest<Config> & Additions, res: EnvoyResponse) => Result;
|
|
12
|
+
/**
|
|
13
|
+
* Handle an invite event, such as `invite_created`.
|
|
14
|
+
* @category Handler
|
|
15
|
+
*/
|
|
16
|
+
export declare type InviteEventHandler<Config = SomeObject, Additions = SomeObject> = (req: EnvoyInviteEventRequest<Config> & Additions, res: EnvoyResponse) => Result;
|
|
17
|
+
/**
|
|
18
|
+
* Handle an location event, such as `location_capacity_updated`.
|
|
19
|
+
* @category Handler
|
|
20
|
+
*/
|
|
21
|
+
export declare type LocationEventHandler<Config = SomeObject, Additions = SomeObject> = (req: EnvoyLocationEventRequest<Config> & Additions, res: EnvoyResponse) => Result;
|
|
22
|
+
/**
|
|
23
|
+
* Handle an notification event.
|
|
24
|
+
* @category Handler
|
|
25
|
+
*/
|
|
26
|
+
export declare type NotificationEventHandler<Config = SomeObject, Additions = SomeObject> = (req: EnvoyNotificationEventRequest<Config> & Additions, res: EnvoyResponse) => Result;
|
|
27
|
+
/**
|
|
28
|
+
* Handle a `plugin_uninstalled` event for cleaning up.
|
|
29
|
+
* @category Handler
|
|
30
|
+
*/
|
|
31
|
+
export declare type PluginUninstalledEventHandler<Config = SomeObject, Additions = SomeObject> = (req: EnvoyEventRequest<'plugin_uninstalled', never, Config> & Additions, res: EnvoyResponse) => Result;
|
|
32
|
+
/**
|
|
33
|
+
* Handle a "migration" route.
|
|
34
|
+
* @category Handler
|
|
35
|
+
*/
|
|
36
|
+
export declare type MigrationRouteHandler<OldConfig = SomeObject, NewConfig = SomeObject, Additions = SomeObject> = (req: EnvoyMigrationRouteRequest<OldConfig> & Additions, res: EnvoyResponse<NewConfig>) => Result;
|
|
37
|
+
/**
|
|
38
|
+
* Handle an "options" route.
|
|
39
|
+
* @category Handler
|
|
40
|
+
*/
|
|
41
|
+
export declare type OptionsRouteHandler<Config = SomeObject, Additions = SomeObject> = (req: EnvoyOptionsRouteRequest<Config> & Additions, res: EnvoyOptionsRouteResponse) => Result;
|
|
42
|
+
/**
|
|
43
|
+
* Handle a "remote value" route.
|
|
44
|
+
* @category Handler
|
|
45
|
+
*/
|
|
46
|
+
export declare type RemoteValueRouteHandler<Config = SomeObject, Additions = SomeObject> = (req: EnvoyRemoteValueRouteRequest<Config> & Additions, res: EnvoyRemoteValueRouteResponse) => Result;
|
|
47
|
+
/**
|
|
48
|
+
* Handle a "selected values" route.
|
|
49
|
+
* @category Handler
|
|
50
|
+
*/
|
|
51
|
+
export declare type SelectedValuesRouteHandler<Config = SomeObject, Additions = SomeObject> = (req: EnvoySelectedValuesRouteRequest<Config> & Additions, res: EnvoySelectedValuesRouteResponse) => Result;
|
|
52
|
+
/**
|
|
53
|
+
* Handle a "validation" route.
|
|
54
|
+
* @category Handler
|
|
55
|
+
*/
|
|
56
|
+
export declare type ValidationRouteHandler<Config = SomeObject, Payload = SomeObject, Additions = SomeObject> = (req: EnvoyValidationRouteRequest<Payload, Config> & Additions, res: EnvoyResponse<Partial<Config>>) => Result;
|
|
57
|
+
/**
|
|
58
|
+
* Wraps any express.js-based handlers
|
|
59
|
+
* to catch Promise-based errors.
|
|
60
|
+
*
|
|
61
|
+
* @category Handler
|
|
62
|
+
*/
|
|
63
|
+
export declare function asyncHandler<Req extends Request, Res extends Response>(handler: (req: Req, res: Res) => Result): RequestHandler;
|
|
64
|
+
/**
|
|
65
|
+
* Handler for entry events.
|
|
66
|
+
*
|
|
67
|
+
* @category Handler
|
|
68
|
+
*/
|
|
69
|
+
export declare function entryEventHandler<Config = SomeObject, Additions = SomeObject>(handler: EntryEventHandler<Config, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
70
|
+
/**
|
|
71
|
+
* Handler for invite events.
|
|
72
|
+
*
|
|
73
|
+
* @category Handler
|
|
74
|
+
*/
|
|
75
|
+
export declare function inviteEventHandler<Config = SomeObject, Additions = SomeObject>(handler: InviteEventHandler<Config, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
76
|
+
/**
|
|
77
|
+
* Handler for location events.
|
|
78
|
+
*
|
|
79
|
+
* @category Handler
|
|
80
|
+
*/
|
|
81
|
+
export declare function locationEventHandler<Config = SomeObject, Additions = SomeObject>(handler: LocationEventHandler<Config, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
82
|
+
/**
|
|
83
|
+
* Handler for a migration route.
|
|
84
|
+
*
|
|
85
|
+
* @category Handler
|
|
86
|
+
*/
|
|
87
|
+
export declare function migrationRouteHandler<OldConfig, NewConfig, Additions = SomeObject>(handler: MigrationRouteHandler<OldConfig, NewConfig, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
88
|
+
/**
|
|
89
|
+
* Handler for notification events.
|
|
90
|
+
*
|
|
91
|
+
* @category Handler
|
|
92
|
+
*/
|
|
93
|
+
export declare function notificationEventHandler<Config = SomeObject, Additions = SomeObject>(handler: NotificationEventHandler<Config, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
94
|
+
/**
|
|
95
|
+
* Handler for options URL routes.
|
|
96
|
+
*
|
|
97
|
+
* @category Handler
|
|
98
|
+
*/
|
|
99
|
+
export declare function optionsRouteHandler<Config = SomeObject, Additions = SomeObject>(handler: OptionsRouteHandler<Config, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
100
|
+
/**
|
|
101
|
+
* Handler for `plugin_uninstalled` events.
|
|
102
|
+
*
|
|
103
|
+
* @category Handler
|
|
104
|
+
*/
|
|
105
|
+
export declare function pluginUninstalledEventHandler<Config = SomeObject, Additions = SomeObject>(handler: PluginUninstalledEventHandler<Config, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
106
|
+
/**
|
|
107
|
+
* Handler for remote value URL routes.
|
|
108
|
+
*
|
|
109
|
+
* @category Handler
|
|
110
|
+
*/
|
|
111
|
+
export declare function remoteValueRouteHandler<Config = SomeObject, Additions = SomeObject>(handler: RemoteValueRouteHandler<Config, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
112
|
+
/**
|
|
113
|
+
* Handler for selected values URL routes.
|
|
114
|
+
*
|
|
115
|
+
* @category Handler
|
|
116
|
+
*/
|
|
117
|
+
export declare function selectedValuesRouteHandler<Config = SomeObject, Additions = SomeObject>(handler: SelectedValuesRouteHandler<Config, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
118
|
+
/**
|
|
119
|
+
* Handler for validation URL routes.
|
|
120
|
+
*
|
|
121
|
+
* @category Handler
|
|
122
|
+
*/
|
|
123
|
+
export declare function validationRouteHandler<Config = SomeObject, Payload = SomeObject, Additions = SomeObject>(handler: ValidationRouteHandler<Config, Payload, Additions>): RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
124
|
+
export {};
|
|
125
|
+
//# sourceMappingURL=handlers.d.ts.map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EAAE,SAAS,CAAC,8HAElD;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,GAAG,UAAU,EACnB,SAAS,GAAG,UAAU,EACpB,OAAO,EAAE,6BAA6B,CAAC,MAAM,EAAE,SAAS,CAAC,8HAE5D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,GAAG,UAAU,EACnB,SAAS,GAAG,UAAU,EACpB,OAAO,EAAE,uBAAuB,CAAC,MAAM,EAAE,SAAS,CAAC,8HAEtD;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,GAAG,UAAU,EACnB,SAAS,GAAG,UAAU,EACpB,OAAO,EAAE,0BAA0B,CAAC,MAAM,EAAE,SAAS,CAAC,8HAEzD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,GAAG,UAAU,EACnB,OAAO,GAAG,UAAU,EACpB,SAAS,GAAG,UAAU,EACpB,OAAO,EAAE,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,8HAE9D"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validationRouteHandler = exports.selectedValuesRouteHandler = exports.remoteValueRouteHandler = exports.pluginUninstalledEventHandler = exports.optionsRouteHandler = exports.notificationEventHandler = exports.migrationRouteHandler = exports.locationEventHandler = exports.inviteEventHandler = exports.entryEventHandler = exports.asyncHandler = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Wraps any express.js-based handlers
|
|
6
|
+
* to catch Promise-based errors.
|
|
7
|
+
*
|
|
8
|
+
* @category Handler
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line max-len
|
|
11
|
+
function asyncHandler(handler) {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
return function (req, res, next) {
|
|
15
|
+
void Promise.resolve().then(function () { return handler(req, res); }).catch(next);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.asyncHandler = asyncHandler;
|
|
19
|
+
/**
|
|
20
|
+
* Handler for entry events.
|
|
21
|
+
*
|
|
22
|
+
* @category Handler
|
|
23
|
+
*/
|
|
24
|
+
function entryEventHandler(handler) {
|
|
25
|
+
return asyncHandler(handler);
|
|
26
|
+
}
|
|
27
|
+
exports.entryEventHandler = entryEventHandler;
|
|
28
|
+
/**
|
|
29
|
+
* Handler for invite events.
|
|
30
|
+
*
|
|
31
|
+
* @category Handler
|
|
32
|
+
*/
|
|
33
|
+
function inviteEventHandler(handler) {
|
|
34
|
+
return asyncHandler(handler);
|
|
35
|
+
}
|
|
36
|
+
exports.inviteEventHandler = inviteEventHandler;
|
|
37
|
+
/**
|
|
38
|
+
* Handler for location events.
|
|
39
|
+
*
|
|
40
|
+
* @category Handler
|
|
41
|
+
*/
|
|
42
|
+
function locationEventHandler(handler) {
|
|
43
|
+
return asyncHandler(handler);
|
|
44
|
+
}
|
|
45
|
+
exports.locationEventHandler = locationEventHandler;
|
|
46
|
+
/**
|
|
47
|
+
* Handler for a migration route.
|
|
48
|
+
*
|
|
49
|
+
* @category Handler
|
|
50
|
+
*/
|
|
51
|
+
function migrationRouteHandler(handler) {
|
|
52
|
+
return asyncHandler(handler);
|
|
53
|
+
}
|
|
54
|
+
exports.migrationRouteHandler = migrationRouteHandler;
|
|
55
|
+
/**
|
|
56
|
+
* Handler for notification events.
|
|
57
|
+
*
|
|
58
|
+
* @category Handler
|
|
59
|
+
*/
|
|
60
|
+
function notificationEventHandler(handler) {
|
|
61
|
+
return asyncHandler(handler);
|
|
62
|
+
}
|
|
63
|
+
exports.notificationEventHandler = notificationEventHandler;
|
|
64
|
+
/**
|
|
65
|
+
* Handler for options URL routes.
|
|
66
|
+
*
|
|
67
|
+
* @category Handler
|
|
68
|
+
*/
|
|
69
|
+
function optionsRouteHandler(handler) {
|
|
70
|
+
return asyncHandler(handler);
|
|
71
|
+
}
|
|
72
|
+
exports.optionsRouteHandler = optionsRouteHandler;
|
|
73
|
+
/**
|
|
74
|
+
* Handler for `plugin_uninstalled` events.
|
|
75
|
+
*
|
|
76
|
+
* @category Handler
|
|
77
|
+
*/
|
|
78
|
+
function pluginUninstalledEventHandler(handler) {
|
|
79
|
+
return asyncHandler(handler);
|
|
80
|
+
}
|
|
81
|
+
exports.pluginUninstalledEventHandler = pluginUninstalledEventHandler;
|
|
82
|
+
/**
|
|
83
|
+
* Handler for remote value URL routes.
|
|
84
|
+
*
|
|
85
|
+
* @category Handler
|
|
86
|
+
*/
|
|
87
|
+
function remoteValueRouteHandler(handler) {
|
|
88
|
+
return asyncHandler(handler);
|
|
89
|
+
}
|
|
90
|
+
exports.remoteValueRouteHandler = remoteValueRouteHandler;
|
|
91
|
+
/**
|
|
92
|
+
* Handler for selected values URL routes.
|
|
93
|
+
*
|
|
94
|
+
* @category Handler
|
|
95
|
+
*/
|
|
96
|
+
function selectedValuesRouteHandler(handler) {
|
|
97
|
+
return asyncHandler(handler);
|
|
98
|
+
}
|
|
99
|
+
exports.selectedValuesRouteHandler = selectedValuesRouteHandler;
|
|
100
|
+
/**
|
|
101
|
+
* Handler for validation URL routes.
|
|
102
|
+
*
|
|
103
|
+
* @category Handler
|
|
104
|
+
*/
|
|
105
|
+
function validationRouteHandler(handler) {
|
|
106
|
+
return asyncHandler(handler);
|
|
107
|
+
}
|
|
108
|
+
exports.validationRouteHandler = validationRouteHandler;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
declare function envoyAxiosRequestLogger(config: AxiosRequestConfig): AxiosRequestConfig<any>;
|
|
3
|
+
declare function envoyAxiosResponseLogger(response: AxiosResponse): AxiosResponse<any, any>;
|
|
4
|
+
declare function envoyAxiosErrorLogger(error: AxiosError): void;
|
|
5
|
+
export { envoyAxiosRequestLogger, envoyAxiosResponseLogger, envoyAxiosErrorLogger };
|
|
6
|
+
//# sourceMappingURL=loggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggers.d.ts","sourceRoot":"","sources":["../../src/sdk/loggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItE,iBAAS,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,2BAkD1D;AAED,iBAAS,wBAAwB,CAAC,QAAQ,EAAE,aAAa,2BAoDxD;AAED,iBAAS,qBAAqB,CAAC,KAAK,EAAE,UAAU,QAoD/C;AAED,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.envoyAxiosErrorLogger = exports.envoyAxiosResponseLogger = exports.envoyAxiosRequestLogger = void 0;
|
|
7
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
var util_1 = __importDefault(require("util"));
|
|
9
|
+
function envoyAxiosRequestLogger(config) {
|
|
10
|
+
var log = console.log;
|
|
11
|
+
log('---------------- Axios Request ----------------\n');
|
|
12
|
+
if (config === null || config === void 0 ? void 0 : config.method) {
|
|
13
|
+
var boldMethodText = chalk_1.default.bold('Method:');
|
|
14
|
+
var method = config.method.toUpperCase();
|
|
15
|
+
switch (method) {
|
|
16
|
+
case 'GET':
|
|
17
|
+
log(boldMethodText + " " + chalk_1.default.green(method) + "\n");
|
|
18
|
+
break;
|
|
19
|
+
case 'PUT':
|
|
20
|
+
log(boldMethodText + " " + chalk_1.default.yellow(method) + "\n");
|
|
21
|
+
break;
|
|
22
|
+
case 'PATCH':
|
|
23
|
+
log(boldMethodText + " " + chalk_1.default.yellow(method) + "\n");
|
|
24
|
+
break;
|
|
25
|
+
case 'POST':
|
|
26
|
+
log(boldMethodText + " " + chalk_1.default.blue(method) + "\n");
|
|
27
|
+
break;
|
|
28
|
+
case 'DELETE':
|
|
29
|
+
log(boldMethodText + " " + chalk_1.default.red(method) + "\n");
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
log(boldMethodText + " " + method + "\n");
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
;
|
|
36
|
+
}
|
|
37
|
+
if ((config === null || config === void 0 ? void 0 : config.baseURL) && (config === null || config === void 0 ? void 0 : config.url)) {
|
|
38
|
+
log(chalk_1.default.bold('URL') + ": " + config.baseURL + "/" + config.url + "\n");
|
|
39
|
+
}
|
|
40
|
+
if (config === null || config === void 0 ? void 0 : config.headers) {
|
|
41
|
+
log(chalk_1.default.bold('Headers:') + " " + util_1.default.inspect(config === null || config === void 0 ? void 0 : config.headers) + "\n");
|
|
42
|
+
}
|
|
43
|
+
if (config === null || config === void 0 ? void 0 : config.auth) {
|
|
44
|
+
log(chalk_1.default.bold('Auth:') + " " + util_1.default.inspect(config === null || config === void 0 ? void 0 : config.auth) + "\n");
|
|
45
|
+
}
|
|
46
|
+
if (config === null || config === void 0 ? void 0 : config.params) {
|
|
47
|
+
log(chalk_1.default.bold('Params:') + " " + util_1.default.inspect(config === null || config === void 0 ? void 0 : config.params) + "\n");
|
|
48
|
+
}
|
|
49
|
+
if (config === null || config === void 0 ? void 0 : config.data) {
|
|
50
|
+
log(chalk_1.default.bold('Request Data:') + " " + util_1.default.inspect(config === null || config === void 0 ? void 0 : config.data) + "\n");
|
|
51
|
+
}
|
|
52
|
+
log('------------ End Of Axios Request ------------\n');
|
|
53
|
+
return config;
|
|
54
|
+
}
|
|
55
|
+
exports.envoyAxiosRequestLogger = envoyAxiosRequestLogger;
|
|
56
|
+
function envoyAxiosResponseLogger(response) {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
var log = console.log;
|
|
59
|
+
log('---------------- Axios Response ----------------\n');
|
|
60
|
+
if ((_a = response === null || response === void 0 ? void 0 : response.request) === null || _a === void 0 ? void 0 : _a.method) {
|
|
61
|
+
var boldMethodText = chalk_1.default.bold('Method:');
|
|
62
|
+
var method = response.request.method;
|
|
63
|
+
switch (method) {
|
|
64
|
+
case 'GET':
|
|
65
|
+
log(boldMethodText + " " + chalk_1.default.green(method) + "\n");
|
|
66
|
+
break;
|
|
67
|
+
case 'PUT':
|
|
68
|
+
log(boldMethodText + " " + chalk_1.default.yellow(method) + "\n");
|
|
69
|
+
break;
|
|
70
|
+
case 'PATCH':
|
|
71
|
+
log(boldMethodText + " " + chalk_1.default.yellow(method) + "\n");
|
|
72
|
+
break;
|
|
73
|
+
case 'POST':
|
|
74
|
+
log(boldMethodText + " " + chalk_1.default.blue(method) + "\n");
|
|
75
|
+
break;
|
|
76
|
+
case 'DELETE':
|
|
77
|
+
log(boldMethodText + " " + chalk_1.default.red(method) + "\n");
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
log(boldMethodText + " " + method + "\n");
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
;
|
|
84
|
+
}
|
|
85
|
+
if (((_b = response === null || response === void 0 ? void 0 : response.request) === null || _b === void 0 ? void 0 : _b.baseURL) && ((_c = response === null || response === void 0 ? void 0 : response.request) === null || _c === void 0 ? void 0 : _c.url)) {
|
|
86
|
+
log(chalk_1.default.bold('Request URL') + ": " + response.request.baseURL + "/" + response.request.url + "\n");
|
|
87
|
+
}
|
|
88
|
+
if ((response === null || response === void 0 ? void 0 : response.status) && (response === null || response === void 0 ? void 0 : response.statusText)) {
|
|
89
|
+
var boldStatusTitle = chalk_1.default.bold('Status:');
|
|
90
|
+
var boldStatusTextTitle = chalk_1.default.bold('Status Text:');
|
|
91
|
+
var status_1 = response.status;
|
|
92
|
+
var statusText = response.statusText;
|
|
93
|
+
if (199 < status_1 && status_1 < 300) {
|
|
94
|
+
log(boldStatusTitle + " " + chalk_1.default.green(status_1) + "\n");
|
|
95
|
+
log(boldStatusTextTitle + " " + chalk_1.default.green(statusText) + "\n");
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
log(boldStatusTitle + " " + chalk_1.default.red(status_1) + "\n");
|
|
99
|
+
log(boldStatusTextTitle + " " + chalk_1.default.red(statusText) + "\n");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
103
|
+
log(chalk_1.default.bold('Response Data:') + " " + util_1.default.inspect(response === null || response === void 0 ? void 0 : response.data) + "\n");
|
|
104
|
+
}
|
|
105
|
+
log('------------ End Of Axios Response ------------\n');
|
|
106
|
+
return response;
|
|
107
|
+
}
|
|
108
|
+
exports.envoyAxiosResponseLogger = envoyAxiosResponseLogger;
|
|
109
|
+
function envoyAxiosErrorLogger(error) {
|
|
110
|
+
var _a, _b, _c, _d, _e, _f;
|
|
111
|
+
var log = console.log;
|
|
112
|
+
log('---------------- Axios Error ----------------\n');
|
|
113
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.request) === null || _a === void 0 ? void 0 : _a.method) {
|
|
114
|
+
var boldMethodText = chalk_1.default.bold('Method:');
|
|
115
|
+
var method = error.request.method;
|
|
116
|
+
switch (method) {
|
|
117
|
+
case 'GET':
|
|
118
|
+
log(boldMethodText + " " + chalk_1.default.green(method) + "\n");
|
|
119
|
+
break;
|
|
120
|
+
case 'PUT':
|
|
121
|
+
log(boldMethodText + " " + chalk_1.default.yellow(method) + "\n");
|
|
122
|
+
break;
|
|
123
|
+
case 'PATCH':
|
|
124
|
+
log(boldMethodText + " " + chalk_1.default.yellow(method) + "\n");
|
|
125
|
+
break;
|
|
126
|
+
case 'POST':
|
|
127
|
+
log(boldMethodText + " " + chalk_1.default.blue(method) + "\n");
|
|
128
|
+
break;
|
|
129
|
+
case 'DELETE':
|
|
130
|
+
log(boldMethodText + " " + chalk_1.default.red(method) + "\n");
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
log(boldMethodText + " " + method + "\n");
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
;
|
|
137
|
+
}
|
|
138
|
+
if (((_b = error === null || error === void 0 ? void 0 : error.request) === null || _b === void 0 ? void 0 : _b.baseURL) && ((_c = error === null || error === void 0 ? void 0 : error.request) === null || _c === void 0 ? void 0 : _c.url)) {
|
|
139
|
+
log(chalk_1.default.bold('Request URL') + ": " + error.request.baseURL + "/" + error.request.url + "\n");
|
|
140
|
+
}
|
|
141
|
+
if (((_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.status) && ((_e = error === null || error === void 0 ? void 0 : error.response) === null || _e === void 0 ? void 0 : _e.statusText)) {
|
|
142
|
+
var boldStatusTitle = chalk_1.default.bold('Status:');
|
|
143
|
+
var boldStatusTextTitle = chalk_1.default.bold('Status Text:');
|
|
144
|
+
var status_2 = error.response.status;
|
|
145
|
+
var statusText = error.response.statusText;
|
|
146
|
+
if (199 < status_2 && status_2 < 300) {
|
|
147
|
+
log(boldStatusTitle + " " + chalk_1.default.green(status_2) + "\n");
|
|
148
|
+
log(boldStatusTextTitle + " " + chalk_1.default.green(statusText) + "\n");
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
log(boldStatusTitle + " " + chalk_1.default.red(status_2) + "\n");
|
|
152
|
+
log(boldStatusTextTitle + " " + chalk_1.default.red(statusText) + "\n");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if ((_f = error.response) === null || _f === void 0 ? void 0 : _f.data) {
|
|
156
|
+
log(chalk_1.default.bold('Response Data:') + " " + util_1.default.inspect(error.response.data) + "\n");
|
|
157
|
+
}
|
|
158
|
+
log('------------ End Of Axios Error ------------\n');
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
exports.envoyAxiosErrorLogger = envoyAxiosErrorLogger;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ErrorRequestHandler, RequestHandler } from 'express';
|
|
2
|
+
import { EnvoySignatureVerifierOptions } from '../util/EnvoySignatureVerifier';
|
|
3
|
+
/**
|
|
4
|
+
* Sets up an {@link EnvoyPluginSDK} object in the path `req.envoy`.
|
|
5
|
+
* Modifies the `res` object to include Envoy's helpers, per {@link EnvoyResponse}.
|
|
6
|
+
*
|
|
7
|
+
* Also verifies that the request is coming from Envoy,
|
|
8
|
+
* as well as managing the plugin access token lifecycle.
|
|
9
|
+
*
|
|
10
|
+
* @category Middleware
|
|
11
|
+
*/
|
|
12
|
+
export declare function envoyMiddleware(options?: EnvoySignatureVerifierOptions): RequestHandler;
|
|
13
|
+
/**
|
|
14
|
+
* Catches errors and sets the proper status code.
|
|
15
|
+
*
|
|
16
|
+
* @category Middleware
|
|
17
|
+
*/
|
|
18
|
+
export declare function errorMiddleware(onError?: (err: Error) => void): ErrorRequestHandler;
|
|
19
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/sdk/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,mBAAmB,EACnB,cAAc,EACf,MAAM,SAAS,CAAC;AAGjB,OAA+B,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAOvG;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,6BAA6B,GAAG,cAAc,CAyDvF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAe,GAAG,mBAAmB,CAU7F"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.errorMiddleware = exports.envoyMiddleware = void 0;
|
|
43
|
+
var body_parser_1 = __importDefault(require("body-parser"));
|
|
44
|
+
var HttpStatus_1 = __importDefault(require("../internal/HttpStatus"));
|
|
45
|
+
var EnvoySignatureVerifier_1 = __importDefault(require("../util/EnvoySignatureVerifier"));
|
|
46
|
+
var EnvoyRequest_1 = require("./EnvoyRequest");
|
|
47
|
+
var EnvoyPluginSDK_1 = __importDefault(require("./EnvoyPluginSDK"));
|
|
48
|
+
var EnvoyPluginAPI_1 = __importDefault(require("./EnvoyPluginAPI"));
|
|
49
|
+
/**
|
|
50
|
+
* Sets up an {@link EnvoyPluginSDK} object in the path `req.envoy`.
|
|
51
|
+
* Modifies the `res` object to include Envoy's helpers, per {@link EnvoyResponse}.
|
|
52
|
+
*
|
|
53
|
+
* Also verifies that the request is coming from Envoy,
|
|
54
|
+
* as well as managing the plugin access token lifecycle.
|
|
55
|
+
*
|
|
56
|
+
* @category Middleware
|
|
57
|
+
*/
|
|
58
|
+
function envoyMiddleware(options) {
|
|
59
|
+
var _this = this;
|
|
60
|
+
var signatureVerifier = new EnvoySignatureVerifier_1.default(options);
|
|
61
|
+
var verify = function (req, res, rawBody) {
|
|
62
|
+
req[EnvoyRequest_1.VERIFIED] = signatureVerifier.verify(req, rawBody);
|
|
63
|
+
};
|
|
64
|
+
var json = body_parser_1.default.json({ verify: verify });
|
|
65
|
+
var accessToken = null;
|
|
66
|
+
var threshold = 0;
|
|
67
|
+
return function (req, res, next) {
|
|
68
|
+
json(req, res, function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
69
|
+
var now, _a, rawAccessToken, expiresIn, envoyRequest, envoyResponse_1, error_1;
|
|
70
|
+
return __generator(this, function (_b) {
|
|
71
|
+
switch (_b.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
if (err) {
|
|
74
|
+
return [2 /*return*/, next(err)];
|
|
75
|
+
}
|
|
76
|
+
_b.label = 1;
|
|
77
|
+
case 1:
|
|
78
|
+
_b.trys.push([1, 4, , 5]);
|
|
79
|
+
now = Date.now();
|
|
80
|
+
if (!(now > threshold)) return [3 /*break*/, 3];
|
|
81
|
+
return [4 /*yield*/, EnvoyPluginAPI_1.default.loginAsPlugin()];
|
|
82
|
+
case 2:
|
|
83
|
+
_a = _b.sent(), rawAccessToken = _a.access_token, expiresIn = _a.expires_in;
|
|
84
|
+
accessToken = rawAccessToken;
|
|
85
|
+
threshold = now + (expiresIn * 1000) - (1000 * 60 * 10);
|
|
86
|
+
_b.label = 3;
|
|
87
|
+
case 3:
|
|
88
|
+
envoyRequest = req;
|
|
89
|
+
envoyResponse_1 = res;
|
|
90
|
+
envoyRequest.envoy = new EnvoyPluginSDK_1.default(envoyRequest.body, envoyRequest[EnvoyRequest_1.VERIFIED], accessToken);
|
|
91
|
+
/**
|
|
92
|
+
* Respond with "ongoing" for long jobs.
|
|
93
|
+
*/
|
|
94
|
+
envoyResponse_1.sendOngoing = function (message, debugInfo) {
|
|
95
|
+
if (message === void 0) { message = ''; }
|
|
96
|
+
if (debugInfo === void 0) { debugInfo = {}; }
|
|
97
|
+
envoyResponse_1.statusCode = HttpStatus_1.default.ONGOING;
|
|
98
|
+
envoyResponse_1.setHeader('Content-Type', 'application/json');
|
|
99
|
+
envoyResponse_1.end(JSON.stringify({ message: message, debugInfo: debugInfo }));
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Respond with "ignored" if no action will be performed.
|
|
103
|
+
*/
|
|
104
|
+
envoyResponse_1.sendIgnored = function (message, debugInfo) {
|
|
105
|
+
if (message === void 0) { message = ''; }
|
|
106
|
+
if (debugInfo === void 0) { debugInfo = {}; }
|
|
107
|
+
var attachments = [];
|
|
108
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
109
|
+
attachments[_i - 2] = arguments[_i];
|
|
110
|
+
}
|
|
111
|
+
envoyResponse_1.statusCode = HttpStatus_1.default.IGNORED;
|
|
112
|
+
envoyResponse_1.setHeader('Content-Type', 'application/json');
|
|
113
|
+
envoyResponse_1.end(JSON.stringify({ message: message, debugInfo: debugInfo, attachments: attachments }));
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Respond with "failed" in case of errors.
|
|
117
|
+
*/
|
|
118
|
+
envoyResponse_1.sendFailed = function (message, debugInfo) {
|
|
119
|
+
if (message === void 0) { message = ''; }
|
|
120
|
+
if (debugInfo === void 0) { debugInfo = {}; }
|
|
121
|
+
var attachments = [];
|
|
122
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
123
|
+
attachments[_i - 2] = arguments[_i];
|
|
124
|
+
}
|
|
125
|
+
envoyResponse_1.statusCode = HttpStatus_1.default.FAILED;
|
|
126
|
+
envoyResponse_1.setHeader('Content-Type', 'application/json');
|
|
127
|
+
envoyResponse_1.end(JSON.stringify({ message: message, debugInfo: debugInfo, attachments: attachments }));
|
|
128
|
+
};
|
|
129
|
+
next();
|
|
130
|
+
return [3 /*break*/, 5];
|
|
131
|
+
case 4:
|
|
132
|
+
error_1 = _b.sent();
|
|
133
|
+
next(error_1);
|
|
134
|
+
return [3 /*break*/, 5];
|
|
135
|
+
case 5: return [2 /*return*/];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}); });
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
exports.envoyMiddleware = envoyMiddleware;
|
|
142
|
+
/**
|
|
143
|
+
* Catches errors and sets the proper status code.
|
|
144
|
+
*
|
|
145
|
+
* @category Middleware
|
|
146
|
+
*/
|
|
147
|
+
function errorMiddleware(onError) {
|
|
148
|
+
if (onError === void 0) { onError = function () { }; }
|
|
149
|
+
return function (err, req, res, next) {
|
|
150
|
+
onError(err);
|
|
151
|
+
if (res.headersSent) {
|
|
152
|
+
return next(err);
|
|
153
|
+
}
|
|
154
|
+
res.statusCode = HttpStatus_1.default.UNEXPECTED_FAILURE;
|
|
155
|
+
res.setHeader('Content-Type', 'application/json');
|
|
156
|
+
res.end(JSON.stringify({ message: err.message }));
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
exports.errorMiddleware = errorMiddleware;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Algorithm, VerifyOptions } from 'jsonwebtoken';
|
|
2
|
+
export declare type EnvoyJWTAlgorithm = Algorithm;
|
|
3
|
+
export declare type EnvoyJWTDecodeOptions = VerifyOptions;
|
|
4
|
+
/**
|
|
5
|
+
* Helper to encode and decode JWTs.
|
|
6
|
+
*
|
|
7
|
+
* @category Helper
|
|
8
|
+
* @category Request Object
|
|
9
|
+
*/
|
|
10
|
+
export default class EnvoyJWT {
|
|
11
|
+
private secret;
|
|
12
|
+
private algorithm;
|
|
13
|
+
constructor(secret?: string, algorithm?: EnvoyJWTAlgorithm);
|
|
14
|
+
encode(subject: string | number | null, expiresIn: string | number | null, payload?: Record<string, unknown>): string;
|
|
15
|
+
decode(token: string, options?: EnvoyJWTDecodeOptions): Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=EnvoyJWT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvoyJWT.d.ts","sourceRoot":"","sources":["../../src/util/EnvoyJWT.ts"],"names":[],"mappings":"AAAA,OAAY,EAAe,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG1E,oBAAY,iBAAiB,GAAG,SAAS,CAAC;AAC1C,oBAAY,qBAAqB,GAAG,aAAa,CAAC;AAClD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,SAAS,CAAY;gBAEjB,MAAM,SAAY,EAAE,SAAS,GAAE,iBAA2B;IAQtE,MAAM,CACJ,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAC/B,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EACjC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACpC,MAAM;IAaT,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CASpF"}
|