@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.
Files changed (291) hide show
  1. package/README.md +178 -110
  2. package/dist/base/EnvoyAPI.d.ts +28 -0
  3. package/dist/base/EnvoyAPI.d.ts.map +1 -0
  4. package/dist/base/EnvoyAPI.js +121 -0
  5. package/dist/base/EnvoyPluginStoragePipeline.d.ts +51 -0
  6. package/dist/base/EnvoyPluginStoragePipeline.d.ts.map +1 -0
  7. package/dist/base/EnvoyPluginStoragePipeline.js +140 -0
  8. package/dist/constants.d.ts +5 -0
  9. package/dist/constants.d.ts.map +1 -0
  10. package/dist/constants.js +12 -0
  11. package/dist/factories/entryEventBodyFactory.d.ts +42 -0
  12. package/dist/factories/entryEventBodyFactory.d.ts.map +1 -0
  13. package/dist/factories/entryEventBodyFactory.js +105 -0
  14. package/dist/factories/eventBodyFactory.d.ts +18 -0
  15. package/dist/factories/eventBodyFactory.d.ts.map +1 -0
  16. package/dist/factories/eventBodyFactory.js +15 -0
  17. package/dist/factories/inviteEventBodyFactory.d.ts +38 -0
  18. package/dist/factories/inviteEventBodyFactory.d.ts.map +1 -0
  19. package/dist/factories/inviteEventBodyFactory.js +92 -0
  20. package/dist/factories/metaFactory.d.ts +10 -0
  21. package/dist/factories/metaFactory.d.ts.map +1 -0
  22. package/dist/factories/metaFactory.js +90 -0
  23. package/dist/factories/routeBodyFactory.d.ts +19 -0
  24. package/dist/factories/routeBodyFactory.d.ts.map +1 -0
  25. package/dist/factories/routeBodyFactory.js +15 -0
  26. package/dist/index.d.ts +52 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +74 -0
  29. package/dist/internal/EnvoyEntryEvent.d.ts +3 -0
  30. package/dist/internal/EnvoyEntryEvent.d.ts.map +1 -0
  31. package/dist/internal/EnvoyEntryEvent.js +2 -0
  32. package/dist/internal/EnvoyInviteEvent.d.ts +3 -0
  33. package/dist/internal/EnvoyInviteEvent.d.ts.map +1 -0
  34. package/dist/internal/EnvoyInviteEvent.js +2 -0
  35. package/dist/internal/EnvoyLocationEvent.d.ts +3 -0
  36. package/dist/internal/EnvoyLocationEvent.d.ts.map +1 -0
  37. package/dist/internal/EnvoyLocationEvent.js +2 -0
  38. package/dist/internal/EnvoyOption.d.ts +6 -0
  39. package/dist/internal/EnvoyOption.d.ts.map +1 -0
  40. package/dist/internal/EnvoyOption.js +2 -0
  41. package/dist/internal/EnvoyOptionsRouteParams.d.ts +7 -0
  42. package/dist/internal/EnvoyOptionsRouteParams.d.ts.map +1 -0
  43. package/dist/internal/EnvoyOptionsRouteParams.js +2 -0
  44. package/dist/internal/EnvoyOptionsRouteResponseBody.d.ts +4 -0
  45. package/dist/internal/EnvoyOptionsRouteResponseBody.d.ts.map +1 -0
  46. package/dist/internal/EnvoyOptionsRouteResponseBody.js +2 -0
  47. package/dist/internal/EnvoyPluginJobUpdate.d.ts +11 -0
  48. package/dist/internal/EnvoyPluginJobUpdate.d.ts.map +1 -0
  49. package/dist/internal/EnvoyPluginJobUpdate.js +2 -0
  50. package/dist/internal/EnvoyRemoteValueRouteResponseBody.d.ts +5 -0
  51. package/dist/internal/EnvoyRemoteValueRouteResponseBody.d.ts.map +1 -0
  52. package/dist/internal/EnvoyRemoteValueRouteResponseBody.js +2 -0
  53. package/dist/internal/EnvoySelectedValuesRouteParams.d.ts +5 -0
  54. package/dist/internal/EnvoySelectedValuesRouteParams.d.ts.map +1 -0
  55. package/dist/internal/EnvoySelectedValuesRouteParams.js +2 -0
  56. package/dist/internal/EnvoySelectedValuesRouteResponseBody.d.ts +4 -0
  57. package/dist/internal/EnvoySelectedValuesRouteResponseBody.d.ts.map +1 -0
  58. package/dist/internal/EnvoySelectedValuesRouteResponseBody.js +2 -0
  59. package/dist/internal/EnvoyStorageCommand.d.ts +42 -0
  60. package/dist/internal/EnvoyStorageCommand.d.ts.map +1 -0
  61. package/dist/internal/EnvoyStorageCommand.js +7 -0
  62. package/dist/internal/EnvoyStorageResult.d.ts +4 -0
  63. package/dist/internal/EnvoyStorageResult.d.ts.map +1 -0
  64. package/dist/internal/EnvoyStorageResult.js +2 -0
  65. package/dist/internal/HttpStatus.d.ts +13 -0
  66. package/dist/internal/HttpStatus.d.ts.map +1 -0
  67. package/dist/internal/HttpStatus.js +15 -0
  68. package/dist/mocks/EnvoyPluginJobMock.d.ts +12 -0
  69. package/dist/mocks/EnvoyPluginJobMock.d.ts.map +1 -0
  70. package/dist/mocks/EnvoyPluginJobMock.js +60 -0
  71. package/dist/mocks/EnvoyPluginStoragePipelineMock.d.ts +24 -0
  72. package/dist/mocks/EnvoyPluginStoragePipelineMock.d.ts.map +1 -0
  73. package/dist/mocks/EnvoyPluginStoragePipelineMock.js +212 -0
  74. package/dist/payloads/EntryPayload.d.ts +80 -0
  75. package/dist/payloads/EntryPayload.d.ts.map +1 -0
  76. package/dist/payloads/EntryPayload.js +28 -0
  77. package/dist/payloads/InvitePayload.d.ts +66 -0
  78. package/dist/payloads/InvitePayload.d.ts.map +1 -0
  79. package/dist/payloads/InvitePayload.js +24 -0
  80. package/dist/payloads/LocationPayload.d.ts +7 -0
  81. package/dist/payloads/LocationPayload.d.ts.map +1 -0
  82. package/dist/payloads/LocationPayload.js +2 -0
  83. package/dist/payloads/NotificationPayload.d.ts +54 -0
  84. package/dist/payloads/NotificationPayload.d.ts.map +1 -0
  85. package/dist/payloads/NotificationPayload.js +2 -0
  86. package/dist/resources/AgreementPageResource.d.ts +17 -0
  87. package/dist/resources/AgreementPageResource.d.ts.map +1 -0
  88. package/dist/resources/AgreementPageResource.js +2 -0
  89. package/dist/resources/AgreementResource.d.ts +24 -0
  90. package/dist/resources/AgreementResource.d.ts.map +1 -0
  91. package/dist/resources/AgreementResource.js +2 -0
  92. package/dist/resources/CompanyResource.d.ts +19 -0
  93. package/dist/resources/CompanyResource.d.ts.map +1 -0
  94. package/dist/resources/CompanyResource.js +2 -0
  95. package/dist/resources/CompanyRoleResource.d.ts +8 -0
  96. package/dist/resources/CompanyRoleResource.d.ts.map +1 -0
  97. package/dist/resources/CompanyRoleResource.js +2 -0
  98. package/dist/resources/CurrentUserResource.d.ts +8 -0
  99. package/dist/resources/CurrentUserResource.d.ts.map +1 -0
  100. package/dist/resources/CurrentUserResource.js +2 -0
  101. package/dist/resources/EmployeeResource.d.ts +43 -0
  102. package/dist/resources/EmployeeResource.d.ts.map +1 -0
  103. package/dist/resources/EmployeeResource.js +2 -0
  104. package/dist/resources/FlowResource.d.ts +31 -0
  105. package/dist/resources/FlowResource.d.ts.map +1 -0
  106. package/dist/resources/FlowResource.js +2 -0
  107. package/dist/resources/InviteResource.d.ts +86 -0
  108. package/dist/resources/InviteResource.d.ts.map +1 -0
  109. package/dist/resources/InviteResource.js +2 -0
  110. package/dist/resources/LocationResource.d.ts +64 -0
  111. package/dist/resources/LocationResource.d.ts.map +1 -0
  112. package/dist/resources/LocationResource.js +2 -0
  113. package/dist/resources/LocationRoleResource.d.ts +8 -0
  114. package/dist/resources/LocationRoleResource.d.ts.map +1 -0
  115. package/dist/resources/LocationRoleResource.js +2 -0
  116. package/dist/resources/SignInFieldPageResource.d.ts +17 -0
  117. package/dist/resources/SignInFieldPageResource.d.ts.map +1 -0
  118. package/dist/resources/SignInFieldPageResource.js +2 -0
  119. package/dist/resources/SignInFieldResource.d.ts +33 -0
  120. package/dist/resources/SignInFieldResource.d.ts.map +1 -0
  121. package/dist/resources/SignInFieldResource.js +2 -0
  122. package/dist/resources/UserResource.d.ts +13 -0
  123. package/dist/resources/UserResource.d.ts.map +1 -0
  124. package/dist/resources/UserResource.js +2 -0
  125. package/dist/sdk/EnvoyMeta.d.ts +96 -0
  126. package/dist/sdk/EnvoyMeta.d.ts.map +1 -0
  127. package/dist/sdk/EnvoyMeta.js +2 -0
  128. package/dist/sdk/EnvoyPluginAPI.d.ts +31 -0
  129. package/dist/sdk/EnvoyPluginAPI.d.ts.map +1 -0
  130. package/dist/sdk/EnvoyPluginAPI.js +205 -0
  131. package/dist/sdk/EnvoyPluginJob.d.ts +49 -0
  132. package/dist/sdk/EnvoyPluginJob.d.ts.map +1 -0
  133. package/dist/sdk/EnvoyPluginJob.js +99 -0
  134. package/dist/sdk/EnvoyPluginJobAttachment.d.ts +43 -0
  135. package/dist/sdk/EnvoyPluginJobAttachment.d.ts.map +1 -0
  136. package/dist/sdk/EnvoyPluginJobAttachment.js +2 -0
  137. package/dist/sdk/EnvoyPluginSDK.d.ts +100 -0
  138. package/dist/sdk/EnvoyPluginSDK.d.ts.map +1 -0
  139. package/dist/sdk/EnvoyPluginSDK.js +204 -0
  140. package/dist/sdk/EnvoyPluginStorage.d.ts +69 -0
  141. package/dist/sdk/EnvoyPluginStorage.d.ts.map +1 -0
  142. package/dist/sdk/EnvoyPluginStorage.js +78 -0
  143. package/dist/sdk/EnvoyRequest.d.ts +116 -0
  144. package/dist/sdk/EnvoyRequest.d.ts.map +1 -0
  145. package/dist/sdk/EnvoyRequest.js +7 -0
  146. package/dist/sdk/EnvoyResponse.d.ts +42 -0
  147. package/dist/sdk/EnvoyResponse.d.ts.map +1 -0
  148. package/dist/sdk/EnvoyResponse.js +2 -0
  149. package/dist/sdk/EnvoyStorageItem.d.ts +9 -0
  150. package/dist/sdk/EnvoyStorageItem.d.ts.map +1 -0
  151. package/dist/sdk/EnvoyStorageItem.js +2 -0
  152. package/dist/sdk/EnvoyUserAPI.d.ts +119 -0
  153. package/dist/sdk/EnvoyUserAPI.d.ts.map +1 -0
  154. package/dist/sdk/EnvoyUserAPI.js +493 -0
  155. package/dist/sdk/filters.d.ts +30 -0
  156. package/dist/sdk/filters.d.ts.map +1 -0
  157. package/dist/sdk/filters.js +72 -0
  158. package/dist/sdk/handlers.d.ts +125 -0
  159. package/dist/sdk/handlers.d.ts.map +1 -0
  160. package/dist/sdk/handlers.js +108 -0
  161. package/dist/sdk/loggers.d.ts +6 -0
  162. package/dist/sdk/loggers.d.ts.map +1 -0
  163. package/dist/sdk/loggers.js +161 -0
  164. package/dist/sdk/middleware.d.ts +19 -0
  165. package/dist/sdk/middleware.d.ts.map +1 -0
  166. package/dist/sdk/middleware.js +159 -0
  167. package/dist/util/EnvoyJWT.d.ts +17 -0
  168. package/dist/util/EnvoyJWT.d.ts.map +1 -0
  169. package/dist/util/EnvoyJWT.js +54 -0
  170. package/dist/util/EnvoySignatureVerifier.d.ts +26 -0
  171. package/dist/util/EnvoySignatureVerifier.d.ts.map +1 -0
  172. package/dist/util/EnvoySignatureVerifier.js +53 -0
  173. package/dist/util/axiosConstructor.d.ts +4 -0
  174. package/dist/util/axiosConstructor.d.ts.map +1 -0
  175. package/dist/util/axiosConstructor.js +58 -0
  176. package/dist/util/errorHandling.d.ts +2 -0
  177. package/dist/util/errorHandling.d.ts.map +1 -0
  178. package/dist/util/errorHandling.js +18 -0
  179. package/dist/util/json-api/JSONAPIData.d.ts +5 -0
  180. package/dist/util/json-api/JSONAPIData.d.ts.map +1 -0
  181. package/dist/util/json-api/JSONAPIData.js +2 -0
  182. package/dist/util/json-api/JSONAPIFilterParams.d.ts +5 -0
  183. package/dist/util/json-api/JSONAPIFilterParams.d.ts.map +1 -0
  184. package/dist/util/json-api/JSONAPIFilterParams.js +2 -0
  185. package/dist/util/json-api/JSONAPIModel.d.ts +10 -0
  186. package/dist/util/json-api/JSONAPIModel.d.ts.map +1 -0
  187. package/dist/util/json-api/JSONAPIModel.js +2 -0
  188. package/dist/util/json-api/JSONAPIPaginationParams.d.ts +9 -0
  189. package/dist/util/json-api/JSONAPIPaginationParams.d.ts.map +1 -0
  190. package/dist/util/json-api/JSONAPIPaginationParams.js +2 -0
  191. package/dist/util/json-api/JSONAPIParams.d.ts +4 -0
  192. package/dist/util/json-api/JSONAPIParams.d.ts.map +1 -0
  193. package/dist/util/json-api/JSONAPIParams.js +2 -0
  194. package/dist/util/json-api/JSONAPIResponse.d.ts +6 -0
  195. package/dist/util/json-api/JSONAPIResponse.d.ts.map +1 -0
  196. package/dist/util/json-api/JSONAPIResponse.js +2 -0
  197. package/package.json +48 -13
  198. package/src/base/EnvoyAPI.ts +87 -0
  199. package/src/base/EnvoyPluginStoragePipeline.ts +99 -0
  200. package/src/constants.ts +7 -0
  201. package/src/factories/entryEventBodyFactory.ts +124 -0
  202. package/src/factories/eventBodyFactory.ts +35 -0
  203. package/src/factories/inviteEventBodyFactory.ts +107 -0
  204. package/src/factories/metaFactory.ts +109 -0
  205. package/src/factories/routeBodyFactory.ts +37 -0
  206. package/src/index.ts +86 -0
  207. package/src/internal/EnvoyEntryEvent.ts +10 -0
  208. package/src/internal/EnvoyInviteEvent.ts +13 -0
  209. package/src/internal/EnvoyLocationEvent.ts +3 -0
  210. package/src/internal/EnvoyOption.ts +6 -0
  211. package/src/internal/EnvoyOptionsRouteParams.ts +7 -0
  212. package/src/internal/EnvoyOptionsRouteResponseBody.ts +4 -0
  213. package/src/internal/EnvoyPluginJobUpdate.ts +11 -0
  214. package/src/internal/EnvoyRemoteValueRouteResponseBody.ts +4 -0
  215. package/src/internal/EnvoySelectedValuesRouteParams.ts +5 -0
  216. package/src/internal/EnvoySelectedValuesRouteResponseBody.ts +4 -0
  217. package/src/internal/EnvoyStorageCommand.ts +60 -0
  218. package/src/internal/EnvoyStorageResult.ts +5 -0
  219. package/src/internal/HttpStatus.ts +12 -0
  220. package/src/mocks/EnvoyPluginJobMock.ts +33 -0
  221. package/src/mocks/EnvoyPluginStoragePipelineMock.ts +204 -0
  222. package/src/payloads/EntryPayload.ts +101 -0
  223. package/src/payloads/InvitePayload.ts +79 -0
  224. package/src/payloads/LocationPayload.ts +8 -0
  225. package/src/payloads/NotificationPayload.ts +54 -0
  226. package/src/resources/AgreementPageResource.ts +19 -0
  227. package/src/resources/AgreementResource.ts +26 -0
  228. package/src/resources/CompanyResource.ts +21 -0
  229. package/src/resources/CompanyRoleResource.ts +10 -0
  230. package/src/resources/CurrentUserResource.ts +10 -0
  231. package/src/resources/EmployeeResource.ts +47 -0
  232. package/src/resources/FlowResource.ts +35 -0
  233. package/src/resources/InviteResource.ts +92 -0
  234. package/src/resources/LocationResource.ts +68 -0
  235. package/src/resources/LocationRoleResource.ts +10 -0
  236. package/src/resources/SignInFieldPageResource.ts +23 -0
  237. package/src/resources/SignInFieldResource.ts +35 -0
  238. package/src/resources/UserResource.ts +14 -0
  239. package/src/sdk/EnvoyMeta.ts +101 -0
  240. package/src/sdk/EnvoyPluginAPI.ts +95 -0
  241. package/src/sdk/EnvoyPluginJob.ts +90 -0
  242. package/src/sdk/EnvoyPluginJobAttachment.ts +48 -0
  243. package/src/sdk/EnvoyPluginSDK.ts +185 -0
  244. package/src/sdk/EnvoyPluginStorage.ts +83 -0
  245. package/src/sdk/EnvoyRequest.ts +145 -0
  246. package/src/sdk/EnvoyResponse.ts +46 -0
  247. package/src/sdk/EnvoyStorageItem.ts +9 -0
  248. package/src/sdk/EnvoyUserAPI.ts +339 -0
  249. package/src/sdk/filters.ts +96 -0
  250. package/src/sdk/handlers.ts +234 -0
  251. package/src/sdk/loggers.ts +165 -0
  252. package/src/sdk/middleware.ts +101 -0
  253. package/src/util/EnvoyJWT.ts +51 -0
  254. package/src/util/EnvoySignatureVerifier.ts +61 -0
  255. package/src/util/axiosConstructor.ts +46 -0
  256. package/src/util/errorHandling.ts +15 -0
  257. package/src/util/json-api/JSONAPIData.ts +4 -0
  258. package/src/util/json-api/JSONAPIFilterParams.ts +5 -0
  259. package/src/util/json-api/JSONAPIModel.ts +10 -0
  260. package/src/util/json-api/JSONAPIPaginationParams.ts +12 -0
  261. package/src/util/json-api/JSONAPIParams.ts +3 -0
  262. package/src/util/json-api/JSONAPIResponse.ts +5 -0
  263. package/.eslintrc.js +0 -46
  264. package/.github/workflows/package.yaml +0 -43
  265. package/.github/workflows/test.yaml +0 -15
  266. package/asynchandler.md +0 -46
  267. package/envoyapi.md +0 -150
  268. package/envoyjwt.md +0 -46
  269. package/envoypluginjob.md +0 -106
  270. package/envoypluginsdk.md +0 -87
  271. package/envoypluginstorage.md +0 -95
  272. package/envoypluginstoragepipeline.md +0 -125
  273. package/envoysignatureverifier.md +0 -43
  274. package/errormiddleware.md +0 -41
  275. package/index.js +0 -49
  276. package/lib/EnvoyAPI.js +0 -564
  277. package/lib/EnvoyJWT.js +0 -72
  278. package/lib/EnvoyPluginJob.js +0 -124
  279. package/lib/EnvoyPluginSDK.js +0 -192
  280. package/lib/EnvoyPluginStorage.js +0 -121
  281. package/lib/EnvoyPluginStoragePipeline.js +0 -155
  282. package/lib/EnvoyResponseError.js +0 -18
  283. package/lib/EnvoySignatureVerifier.js +0 -67
  284. package/lib/HttpStatus.js +0 -20
  285. package/lib/asyncHandler.js +0 -17
  286. package/lib/axios.js +0 -34
  287. package/lib/errorMiddleware.js +0 -27
  288. package/lib/middleware.js +0 -110
  289. package/middleware.md +0 -53
  290. package/test/axios.test.js +0 -57
  291. 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;