@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,493 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
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;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
65
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
66
|
+
};
|
|
67
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
+
var axios_1 = __importDefault(require("axios"));
|
|
69
|
+
var EnvoyAPI_1 = __importDefault(require("../base/EnvoyAPI"));
|
|
70
|
+
var constants_1 = require("../constants");
|
|
71
|
+
var axiosConstructor_1 = require("../util/axiosConstructor");
|
|
72
|
+
/**
|
|
73
|
+
* API endpoints for *user-scoped* tokens.
|
|
74
|
+
* To access Envoy resources, this is the API you'd want.
|
|
75
|
+
*
|
|
76
|
+
* @category API
|
|
77
|
+
* @category Request Object
|
|
78
|
+
*/
|
|
79
|
+
var EnvoyUserAPI = /** @class */ (function (_super) {
|
|
80
|
+
__extends(EnvoyUserAPI, _super);
|
|
81
|
+
function EnvoyUserAPI() {
|
|
82
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* {@link AgreementPageModel}
|
|
87
|
+
*/
|
|
88
|
+
EnvoyUserAPI.prototype.getAgreementPage = function (id, include) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
return [2 /*return*/, this.dataLoader.load({ type: 'agreement-pages', id: id, include: include })];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Requires `agreements.read` scope.
|
|
97
|
+
*/
|
|
98
|
+
EnvoyUserAPI.prototype.getAgreement = function (id, include) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
return [2 /*return*/, this.dataLoader.load({ type: 'agreements', id: id, include: include })];
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Requires `companies.read` scope.
|
|
107
|
+
*/
|
|
108
|
+
EnvoyUserAPI.prototype.getCompany = function (id, include) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
return [2 /*return*/, this.dataLoader.load({ type: 'companies', id: id, include: include })];
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Requires `employees.read` scope.
|
|
117
|
+
*/
|
|
118
|
+
EnvoyUserAPI.prototype.getEmployee = function (id, include) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
return __generator(this, function (_a) {
|
|
121
|
+
return [2 /*return*/, this.dataLoader.load({ type: 'employees', id: id, include: include })];
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Requires `flows.read` scope.
|
|
127
|
+
*/
|
|
128
|
+
EnvoyUserAPI.prototype.getFlow = function (id, include) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
return [2 /*return*/, this.dataLoader.load({ type: 'flows', id: id, include: include })];
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Requires `locations.read` scope.
|
|
137
|
+
*/
|
|
138
|
+
EnvoyUserAPI.prototype.getLocation = function (id, include) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
+
return __generator(this, function (_a) {
|
|
141
|
+
return [2 /*return*/, this.dataLoader.load({ type: 'locations', id: id, include: include })];
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Requires `sign-in-field-pages.read` scope.
|
|
147
|
+
*/
|
|
148
|
+
EnvoyUserAPI.prototype.getSignInFieldPage = function (id, include) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
150
|
+
return __generator(this, function (_a) {
|
|
151
|
+
return [2 /*return*/, this.dataLoader.load({ type: 'sign-in-field-pages', id: id, include: include })];
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Requires `sign-in-fields.read` scope.
|
|
157
|
+
*/
|
|
158
|
+
EnvoyUserAPI.prototype.getSignInField = function (id, include) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
return [2 /*return*/, this.dataLoader.load({ type: 'sign-in-fields', id: id, include: include })];
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Requires `employees.read` scope.
|
|
167
|
+
*/
|
|
168
|
+
EnvoyUserAPI.prototype.getEmployeeByEmail = function (email, include) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
var paginationParams, employee;
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
switch (_a.label) {
|
|
173
|
+
case 0:
|
|
174
|
+
paginationParams = {
|
|
175
|
+
filter: {
|
|
176
|
+
email: email,
|
|
177
|
+
},
|
|
178
|
+
page: {
|
|
179
|
+
limit: 1,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
return [4 /*yield*/, this.axios.get('/api/v3/employees', {
|
|
183
|
+
params: __assign({ include: include }, paginationParams),
|
|
184
|
+
})];
|
|
185
|
+
case 1:
|
|
186
|
+
employee = (_a.sent()).data.data[0];
|
|
187
|
+
return [2 /*return*/, employee];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Requires `employees.read` scope.
|
|
194
|
+
*/
|
|
195
|
+
EnvoyUserAPI.prototype.getEmployees = function (params) {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
+
var data;
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0: return [4 /*yield*/, this.axios.get('/api/v3/employees', { params: params })];
|
|
201
|
+
case 1:
|
|
202
|
+
data = (_a.sent()).data;
|
|
203
|
+
return [2 /*return*/, data.data];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Requires `flows.read` scope.
|
|
210
|
+
*/
|
|
211
|
+
EnvoyUserAPI.prototype.getFlows = function (params) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
var data;
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
switch (_a.label) {
|
|
216
|
+
case 0: return [4 /*yield*/, this.axios.get('/api/v3/flows', { params: params })];
|
|
217
|
+
case 1:
|
|
218
|
+
data = (_a.sent()).data;
|
|
219
|
+
return [2 /*return*/, data.data];
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Requires `locations.read` scope.
|
|
226
|
+
*/
|
|
227
|
+
EnvoyUserAPI.prototype.getLocations = function (params) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
+
var data;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0: return [4 /*yield*/, this.axios.get('/api/v3/locations', { params: params })];
|
|
233
|
+
case 1:
|
|
234
|
+
data = (_a.sent()).data;
|
|
235
|
+
return [2 /*return*/, data.data];
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Requires `sign-in-fields.read` scope.
|
|
242
|
+
*/
|
|
243
|
+
EnvoyUserAPI.prototype.getSignInFields = function (signInFieldPageId) {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
245
|
+
var data;
|
|
246
|
+
return __generator(this, function (_a) {
|
|
247
|
+
switch (_a.label) {
|
|
248
|
+
case 0: return [4 /*yield*/, this.axios.get("/api/v3/sign-in-field-pages/" + signInFieldPageId + "/sign-in-fields")];
|
|
249
|
+
case 1:
|
|
250
|
+
data = (_a.sent()).data;
|
|
251
|
+
return [2 /*return*/, data.data];
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Requires `invites.read` scope.
|
|
258
|
+
*/
|
|
259
|
+
EnvoyUserAPI.prototype.getInvites = function (params) {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
261
|
+
var data;
|
|
262
|
+
return __generator(this, function (_a) {
|
|
263
|
+
switch (_a.label) {
|
|
264
|
+
case 0: return [4 /*yield*/, this.axios.get('/api/v3/invites', { params: params })];
|
|
265
|
+
case 1:
|
|
266
|
+
data = (_a.sent()).data;
|
|
267
|
+
return [2 /*return*/, data.data];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
EnvoyUserAPI.prototype.me = function () {
|
|
273
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
274
|
+
var data;
|
|
275
|
+
return __generator(this, function (_a) {
|
|
276
|
+
switch (_a.label) {
|
|
277
|
+
case 0: return [4 /*yield*/, this.axios.get('/api/v2/users/me')];
|
|
278
|
+
case 1:
|
|
279
|
+
data = (_a.sent()).data;
|
|
280
|
+
return [2 /*return*/, data.data];
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Requires `invites.write` scope.
|
|
287
|
+
* May also require `invites.attest` scope if setting `attested: true`.
|
|
288
|
+
*/
|
|
289
|
+
EnvoyUserAPI.prototype.createInvite = function (invite) {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
291
|
+
var data;
|
|
292
|
+
return __generator(this, function (_a) {
|
|
293
|
+
switch (_a.label) {
|
|
294
|
+
case 0: return [4 /*yield*/, this.axios({
|
|
295
|
+
method: 'POST',
|
|
296
|
+
url: '/api/v3/invites',
|
|
297
|
+
data: { data: invite },
|
|
298
|
+
})];
|
|
299
|
+
case 1:
|
|
300
|
+
data = (_a.sent()).data;
|
|
301
|
+
return [2 /*return*/, data.data];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Requires `invites.write` scope.
|
|
308
|
+
*/
|
|
309
|
+
EnvoyUserAPI.prototype.updateInvite = function (inviteId, invite) {
|
|
310
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
311
|
+
var data;
|
|
312
|
+
return __generator(this, function (_a) {
|
|
313
|
+
switch (_a.label) {
|
|
314
|
+
case 0: return [4 /*yield*/, this.axios({
|
|
315
|
+
method: 'PUT',
|
|
316
|
+
url: "/api/v3/invites/" + inviteId,
|
|
317
|
+
data: { data: __assign(__assign({}, invite), { id: inviteId }) },
|
|
318
|
+
})];
|
|
319
|
+
case 1:
|
|
320
|
+
data = (_a.sent()).data;
|
|
321
|
+
return [2 /*return*/, data.data];
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Requires `invites.write` scope.
|
|
328
|
+
*/
|
|
329
|
+
EnvoyUserAPI.prototype.partialUpdateInvite = function (inviteId, invite) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
331
|
+
var data;
|
|
332
|
+
return __generator(this, function (_a) {
|
|
333
|
+
switch (_a.label) {
|
|
334
|
+
case 0: return [4 /*yield*/, this.axios({
|
|
335
|
+
method: 'PATCH',
|
|
336
|
+
url: "/api/v3/invites/" + inviteId,
|
|
337
|
+
data: { data: __assign(__assign({}, invite), { id: inviteId }) },
|
|
338
|
+
})];
|
|
339
|
+
case 1:
|
|
340
|
+
data = (_a.sent()).data;
|
|
341
|
+
return [2 /*return*/, data.data];
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Requires `invites.write` scope.
|
|
348
|
+
*/
|
|
349
|
+
EnvoyUserAPI.prototype.removeInvite = function (inviteId) {
|
|
350
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
351
|
+
return __generator(this, function (_a) {
|
|
352
|
+
switch (_a.label) {
|
|
353
|
+
case 0: return [4 /*yield*/, this.axios({
|
|
354
|
+
method: 'DELETE',
|
|
355
|
+
url: "/api/v3/invites/" + inviteId,
|
|
356
|
+
})];
|
|
357
|
+
case 1:
|
|
358
|
+
_a.sent();
|
|
359
|
+
return [2 /*return*/];
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Builds the authorize URL to redirect a user to initiate the auth code oauth2 flow.
|
|
366
|
+
*
|
|
367
|
+
* Upon completion, they will be redirected to `redirectURL`, with a `code` query param in the url.
|
|
368
|
+
*
|
|
369
|
+
* Use the {@link loginAsUserWithCode} method to exchange that code for an access token.
|
|
370
|
+
*/
|
|
371
|
+
EnvoyUserAPI.getAuthorizeURL = function (redirectURL, scope, clientId) {
|
|
372
|
+
if (clientId === void 0) { clientId = constants_1.envoyClientId; }
|
|
373
|
+
var url = new URL(constants_1.envoyBaseURL);
|
|
374
|
+
url.pathname = '/a/auth/v0/authorize';
|
|
375
|
+
url.searchParams.append('response_type', 'code');
|
|
376
|
+
url.searchParams.append('client_id', clientId);
|
|
377
|
+
url.searchParams.append('redirect_uri', redirectURL);
|
|
378
|
+
return url.href + "&scope=" + scope.join('+');
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Gets a user access token using `password` as the grant type (discouraged - use {@link loginAsUserWithCode} below).
|
|
382
|
+
*/
|
|
383
|
+
EnvoyUserAPI.loginAsUserWithPassword = function (username, password, scope, clientId, clientSecret) {
|
|
384
|
+
if (clientId === void 0) { clientId = constants_1.envoyClientId; }
|
|
385
|
+
if (clientSecret === void 0) { clientSecret = constants_1.envoyClientSecret; }
|
|
386
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
387
|
+
var data, error_1;
|
|
388
|
+
return __generator(this, function (_a) {
|
|
389
|
+
switch (_a.label) {
|
|
390
|
+
case 0:
|
|
391
|
+
_a.trys.push([0, 2, , 3]);
|
|
392
|
+
return [4 /*yield*/, axios_1.default({
|
|
393
|
+
auth: {
|
|
394
|
+
username: clientId,
|
|
395
|
+
password: clientSecret,
|
|
396
|
+
},
|
|
397
|
+
method: 'POST',
|
|
398
|
+
data: {
|
|
399
|
+
grant_type: 'password',
|
|
400
|
+
scope: scope,
|
|
401
|
+
username: username,
|
|
402
|
+
password: password,
|
|
403
|
+
},
|
|
404
|
+
url: '/a/auth/v0/token',
|
|
405
|
+
baseURL: constants_1.envoyBaseURL,
|
|
406
|
+
})];
|
|
407
|
+
case 1:
|
|
408
|
+
data = (_a.sent()).data;
|
|
409
|
+
return [2 /*return*/, data];
|
|
410
|
+
case 2:
|
|
411
|
+
error_1 = _a.sent();
|
|
412
|
+
throw axiosConstructor_1.sanitizeAxiosError(error_1);
|
|
413
|
+
case 3: return [2 /*return*/];
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* Gets a user access token using `code` as the grant type.
|
|
420
|
+
*/
|
|
421
|
+
EnvoyUserAPI.loginAsUserWithCode = function (code, scope, clientId, clientSecret) {
|
|
422
|
+
if (clientId === void 0) { clientId = constants_1.envoyClientId; }
|
|
423
|
+
if (clientSecret === void 0) { clientSecret = constants_1.envoyClientSecret; }
|
|
424
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
425
|
+
var data, error_2;
|
|
426
|
+
return __generator(this, function (_a) {
|
|
427
|
+
switch (_a.label) {
|
|
428
|
+
case 0:
|
|
429
|
+
_a.trys.push([0, 2, , 3]);
|
|
430
|
+
return [4 /*yield*/, axios_1.default({
|
|
431
|
+
auth: {
|
|
432
|
+
username: clientId,
|
|
433
|
+
password: clientSecret,
|
|
434
|
+
},
|
|
435
|
+
method: 'POST',
|
|
436
|
+
data: {
|
|
437
|
+
grant_type: 'authorization_code',
|
|
438
|
+
scope: scope,
|
|
439
|
+
code: code,
|
|
440
|
+
},
|
|
441
|
+
url: '/a/auth/v0/token',
|
|
442
|
+
baseURL: constants_1.envoyBaseURL,
|
|
443
|
+
})];
|
|
444
|
+
case 1:
|
|
445
|
+
data = (_a.sent()).data;
|
|
446
|
+
return [2 /*return*/, data];
|
|
447
|
+
case 2:
|
|
448
|
+
error_2 = _a.sent();
|
|
449
|
+
throw axiosConstructor_1.sanitizeAxiosError(error_2);
|
|
450
|
+
case 3: return [2 /*return*/];
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Gets a user access token using `plugin_install` as the grant type.
|
|
457
|
+
*/
|
|
458
|
+
EnvoyUserAPI.loginAsPluginInstaller = function (installId, clientId, clientSecret) {
|
|
459
|
+
if (clientId === void 0) { clientId = constants_1.envoyClientId; }
|
|
460
|
+
if (clientSecret === void 0) { clientSecret = constants_1.envoyClientSecret; }
|
|
461
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
462
|
+
var data, error_3;
|
|
463
|
+
return __generator(this, function (_a) {
|
|
464
|
+
switch (_a.label) {
|
|
465
|
+
case 0:
|
|
466
|
+
_a.trys.push([0, 2, , 3]);
|
|
467
|
+
return [4 /*yield*/, axios_1.default({
|
|
468
|
+
auth: {
|
|
469
|
+
username: clientId,
|
|
470
|
+
password: clientSecret,
|
|
471
|
+
},
|
|
472
|
+
method: 'POST',
|
|
473
|
+
data: {
|
|
474
|
+
grant_type: 'plugin_install',
|
|
475
|
+
install_id: installId,
|
|
476
|
+
},
|
|
477
|
+
url: '/a/auth/v0/token',
|
|
478
|
+
baseURL: constants_1.envoyBaseURL,
|
|
479
|
+
})];
|
|
480
|
+
case 1:
|
|
481
|
+
data = (_a.sent()).data;
|
|
482
|
+
return [2 /*return*/, data];
|
|
483
|
+
case 2:
|
|
484
|
+
error_3 = _a.sent();
|
|
485
|
+
throw axiosConstructor_1.sanitizeAxiosError(error_3);
|
|
486
|
+
case 3: return [2 /*return*/];
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
return EnvoyUserAPI;
|
|
492
|
+
}(EnvoyAPI_1.default));
|
|
493
|
+
exports.default = EnvoyUserAPI;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RequestHandler } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Will only proceed if the install's `config` has a truthy value for the given `key`.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function booleanFilterMiddleware<Config>(key: keyof Config, message: string): RequestHandler;
|
|
8
|
+
/**
|
|
9
|
+
* Will only proceed if the install's `config` has a truthy value for the given `employeeSignInEnabledKey`.
|
|
10
|
+
*
|
|
11
|
+
* @category Filter
|
|
12
|
+
* @category Middleware
|
|
13
|
+
*/
|
|
14
|
+
export declare function employeeSignInEnabledFilterMiddleware<Config>(employeeSignInEnabledKey: keyof Config, message?: string): RequestHandler;
|
|
15
|
+
/**
|
|
16
|
+
* Will not proceed if the employee who's signing in is present in the excluded employees list.
|
|
17
|
+
*
|
|
18
|
+
* @category Filter
|
|
19
|
+
* @category Middleware
|
|
20
|
+
*/
|
|
21
|
+
export declare function excludedEmployeesFilterMiddleware<Config>(excludeEmployeesKey: keyof Config, message?: string): RequestHandler;
|
|
22
|
+
/**
|
|
23
|
+
* Will only proceed if the entry has an invite
|
|
24
|
+
* and the install's `config` has a truthy value for the given `invitesOnlyKey`.
|
|
25
|
+
*
|
|
26
|
+
* @category Filter
|
|
27
|
+
* @category Middleware
|
|
28
|
+
*/
|
|
29
|
+
export declare function inviteOnlyEntryFilterMiddleware<Config>(invitesOnlyKey: keyof Config, message?: string): RequestHandler;
|
|
30
|
+
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/sdk/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,cAAc,EACf,MAAM,SAAS,CAAC;AAIjB;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAOlG;AAED;;;;;GAKG;AACH,wBAAgB,qCAAqC,CAAC,MAAM,EAC1D,wBAAwB,EAAE,MAAM,MAAM,EACtC,OAAO,SAA+B,GACrC,cAAc,CAEhB;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EACtD,mBAAmB,EAAE,MAAM,MAAM,EACjC,OAAO,SAAwC,GAC9C,cAAc,CAuBhB;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,EACpD,cAAc,EAAE,MAAM,MAAM,EAC5B,OAAO,SAA8B,GACpC,cAAc,CAehB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inviteOnlyEntryFilterMiddleware = exports.excludedEmployeesFilterMiddleware = exports.employeeSignInEnabledFilterMiddleware = exports.booleanFilterMiddleware = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Will only proceed if the install's `config` has a truthy value for the given `key`.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
function booleanFilterMiddleware(key, message) {
|
|
10
|
+
return function (req, res, next) {
|
|
11
|
+
if (req.envoy.meta.config[key]) {
|
|
12
|
+
return next();
|
|
13
|
+
}
|
|
14
|
+
res.sendIgnored(message);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.booleanFilterMiddleware = booleanFilterMiddleware;
|
|
18
|
+
/**
|
|
19
|
+
* Will only proceed if the install's `config` has a truthy value for the given `employeeSignInEnabledKey`.
|
|
20
|
+
*
|
|
21
|
+
* @category Filter
|
|
22
|
+
* @category Middleware
|
|
23
|
+
*/
|
|
24
|
+
function employeeSignInEnabledFilterMiddleware(employeeSignInEnabledKey, message) {
|
|
25
|
+
if (message === void 0) { message = 'Envoy Protect is disabled.'; }
|
|
26
|
+
return booleanFilterMiddleware(employeeSignInEnabledKey, message);
|
|
27
|
+
}
|
|
28
|
+
exports.employeeSignInEnabledFilterMiddleware = employeeSignInEnabledFilterMiddleware;
|
|
29
|
+
/**
|
|
30
|
+
* Will not proceed if the employee who's signing in is present in the excluded employees list.
|
|
31
|
+
*
|
|
32
|
+
* @category Filter
|
|
33
|
+
* @category Middleware
|
|
34
|
+
*/
|
|
35
|
+
function excludedEmployeesFilterMiddleware(excludeEmployeesKey, message) {
|
|
36
|
+
if (message === void 0) { message = 'Employee excluded from integration.'; }
|
|
37
|
+
return function (req, res, next) {
|
|
38
|
+
var _a;
|
|
39
|
+
var _b = req.envoy, config = _b.meta.config, payload = _b.payload;
|
|
40
|
+
if (!payload.attributes['employee-screening-flow']) {
|
|
41
|
+
return next();
|
|
42
|
+
}
|
|
43
|
+
var excludedEmployees = config[excludeEmployeesKey] || [];
|
|
44
|
+
if (!Array.isArray(excludedEmployees)) {
|
|
45
|
+
return next(new Error(excludeEmployeesKey + " is not an array."));
|
|
46
|
+
}
|
|
47
|
+
var employeeId = (_a = payload.relationships.employee) === null || _a === void 0 ? void 0 : _a.data.id;
|
|
48
|
+
if (!employeeId || !excludedEmployees.includes(employeeId)) {
|
|
49
|
+
return next();
|
|
50
|
+
}
|
|
51
|
+
res.sendIgnored(message);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.excludedEmployeesFilterMiddleware = excludedEmployeesFilterMiddleware;
|
|
55
|
+
/**
|
|
56
|
+
* Will only proceed if the entry has an invite
|
|
57
|
+
* and the install's `config` has a truthy value for the given `invitesOnlyKey`.
|
|
58
|
+
*
|
|
59
|
+
* @category Filter
|
|
60
|
+
* @category Middleware
|
|
61
|
+
*/
|
|
62
|
+
function inviteOnlyEntryFilterMiddleware(invitesOnlyKey, message) {
|
|
63
|
+
if (message === void 0) { message = 'Visitors must be invited.'; }
|
|
64
|
+
return function (req, res, next) {
|
|
65
|
+
var _a = req.envoy, config = _a.meta.config, payload = _a.payload;
|
|
66
|
+
if (!payload.relationships.invite && config[invitesOnlyKey]) {
|
|
67
|
+
return res.sendIgnored(message);
|
|
68
|
+
}
|
|
69
|
+
next();
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
exports.inviteOnlyEntryFilterMiddleware = inviteOnlyEntryFilterMiddleware;
|