@frankieone/one-sdk 0.6.7-rc.1 → 0.7.0-alpha
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 +1 -1
- package/dist/commit.txt +2 -2
- package/dist/esm/modules/biometrics/{types/events.d.ts → events.d.ts} +2 -2
- package/dist/esm/modules/biometrics/events.js.map +1 -0
- package/dist/esm/modules/biometrics/index.d.ts +12 -3
- package/dist/esm/modules/biometrics/index.js +58 -75
- package/dist/esm/modules/biometrics/index.js.map +1 -1
- package/dist/esm/modules/biometrics/parseConfiguration.d.ts +2 -4
- package/dist/esm/modules/biometrics/parseConfiguration.js +0 -1
- package/dist/esm/modules/biometrics/parseConfiguration.js.map +1 -1
- package/dist/esm/modules/biometrics/vendors/OcrLabs/Liveness.js.map +1 -0
- package/dist/esm/modules/biometrics/vendors/OcrLabs/index.d.ts +4 -0
- package/dist/esm/modules/biometrics/{wrappers → vendors}/OcrLabs/index.js +15 -20
- package/dist/esm/modules/biometrics/vendors/OcrLabs/index.js.map +1 -0
- package/dist/esm/modules/biometrics/vendors/OcrLabs/nolint_liveness-v3.1.1.min.umd.js.map +1 -0
- package/dist/esm/modules/biometrics/vendors/dummy-biometrics/green-tick-svg.js.map +1 -0
- package/dist/esm/modules/biometrics/vendors/dummy-biometrics/index.d.ts +3 -0
- package/dist/esm/modules/biometrics/{wrappers → vendors}/dummy-biometrics/index.js +10 -16
- package/dist/esm/modules/biometrics/vendors/dummy-biometrics/index.js.map +1 -0
- package/dist/esm/modules/common/index.d.ts +4 -3
- package/dist/esm/modules/common/index.js +4 -3
- package/dist/esm/modules/common/index.js.map +1 -1
- package/dist/esm/modules/common/modules/HOF.d.ts +7 -18
- package/dist/esm/modules/common/modules/HOF.js +26 -9
- package/dist/esm/modules/common/modules/HOF.js.map +1 -1
- package/dist/esm/modules/common/modules/eventHub.d.ts +2 -2
- package/dist/esm/modules/common/modules/vendorLoading.d.ts +69 -45
- package/dist/esm/modules/common/modules/vendorLoading.js +134 -67
- package/dist/esm/modules/common/modules/vendorLoading.js.map +1 -1
- package/dist/esm/modules/common/types/Accessors.d.ts +3 -3
- package/dist/esm/modules/common/types/RecipeConfiguration.js +2 -0
- package/dist/esm/modules/common/types/RecipeConfiguration.js.map +1 -0
- package/dist/esm/modules/configuration.d.ts +18 -0
- package/dist/esm/modules/configuration.js +16 -0
- package/dist/esm/modules/configuration.js.map +1 -0
- package/dist/esm/modules/device/constants.d.ts +1 -1
- package/dist/esm/modules/device/constants.js +8 -1
- package/dist/esm/modules/device/constants.js.map +1 -1
- package/dist/esm/modules/device/{types/events.d.ts → events.d.ts} +3 -4
- package/dist/esm/modules/device/events.js.map +1 -0
- package/dist/esm/modules/device/index.d.ts +22 -3
- package/dist/esm/modules/device/index.js +64 -84
- package/dist/esm/modules/device/index.js.map +1 -1
- package/dist/esm/modules/device/parseConfiguration.d.ts +2 -5
- package/dist/esm/modules/device/parseConfiguration.js +3 -4
- package/dist/esm/modules/device/parseConfiguration.js.map +1 -1
- package/dist/esm/modules/device/vendors/Sardine.d.ts +3 -2
- package/dist/esm/modules/device/vendors/Sardine.js +36 -34
- package/dist/esm/modules/device/vendors/Sardine.js.map +1 -1
- package/dist/esm/modules/device/vendors/Threatmetrix/index.d.ts +3 -2
- package/dist/esm/modules/device/vendors/Threatmetrix/index.js +18 -30
- package/dist/esm/modules/device/vendors/Threatmetrix/index.js.map +1 -1
- package/dist/esm/modules/federation/events.js.map +1 -0
- package/dist/esm/modules/federation/index.d.ts +12 -3
- package/dist/esm/modules/federation/index.js +46 -65
- package/dist/esm/modules/federation/index.js.map +1 -1
- package/dist/esm/modules/federation/parseConfiguration.d.ts +2 -2
- package/dist/esm/modules/federation/parseConfiguration.js +9 -9
- package/dist/esm/modules/federation/parseConfiguration.js.map +1 -1
- package/dist/esm/modules/federation/vendors/Singpass.d.ts +4 -3
- package/dist/esm/modules/federation/vendors/Singpass.js +16 -23
- package/dist/esm/modules/federation/vendors/Singpass.js.map +1 -1
- package/dist/esm/modules/frankie-client/index.d.ts +2 -2
- package/dist/esm/modules/frankie-client/index.js +8 -4
- package/dist/esm/modules/frankie-client/index.js.map +1 -1
- package/dist/esm/modules/index.d.ts +8 -3
- package/dist/esm/modules/index.js +19 -1
- package/dist/esm/modules/index.js.map +1 -1
- package/dist/esm/modules/individual/actions/documents.d.ts +1 -1
- package/dist/esm/modules/individual/actions/emitEvents.d.ts +1 -1
- package/dist/esm/modules/individual/actions/search.d.ts +1 -1
- package/dist/esm/modules/individual/actions/search.js.map +1 -1
- package/dist/esm/modules/individual/actions/submit.d.ts +2 -2
- package/dist/esm/modules/individual/actions/submit.js.map +1 -1
- package/dist/esm/modules/individual/{types/events.d.ts → events.d.ts} +1 -1
- package/dist/esm/modules/individual/events.js.map +1 -0
- package/dist/esm/modules/individual/index.d.ts +29 -2
- package/dist/esm/modules/individual/index.js +66 -67
- package/dist/esm/modules/individual/index.js.map +1 -1
- package/dist/esm/modules/meta.json +1 -1
- package/dist/esm/modules/ocr/actions/start.d.ts +2 -2
- package/dist/esm/modules/ocr/{types/events.d.ts → events.d.ts} +2 -2
- package/dist/esm/modules/ocr/events.js.map +1 -0
- package/dist/esm/modules/ocr/index.d.ts +29 -8
- package/dist/esm/modules/ocr/index.js +45 -52
- package/dist/esm/modules/ocr/index.js.map +1 -1
- package/dist/esm/modules/sdk/index.d.ts +1 -1
- package/dist/esm/modules/sdk/index.js +11 -11
- package/dist/esm/modules/sdk/index.js.map +1 -1
- package/dist/esm/modules/sdk/initialisation/componentLoader.d.ts +1 -1
- package/dist/esm/modules/sdk/initialisation/componentLoader.js +24 -10
- package/dist/esm/modules/sdk/initialisation/componentLoader.js.map +1 -1
- package/dist/esm/modules/sdk/initialisation/configurationParser.d.ts +9 -10
- package/dist/esm/modules/sdk/initialisation/configurationParser.js +39 -20
- package/dist/esm/modules/sdk/initialisation/configurationParser.js.map +1 -1
- package/dist/esm/modules/sdk/initialisation/sharedDependencies.d.ts +2 -3
- package/dist/esm/modules/sdk/initialisation/sharedDependencies.js +6 -4
- package/dist/esm/modules/sdk/initialisation/sharedDependencies.js.map +1 -1
- package/dist/esm/modules/sdk/types/{events.d.ts → globalEvents.d.ts} +2 -2
- package/dist/esm/modules/sdk/types/globalEvents.js +2 -0
- package/dist/esm/modules/sdk/types/globalEvents.js.map +1 -0
- package/dist/esm/modules/sdk/types/index.d.ts +5 -4
- package/dist/esm/modules/sdk/types/index.js +5 -4
- package/dist/esm/modules/sdk/types/index.js.map +1 -1
- package/dist/esm/modules/sdk/types/oneSDK.d.ts +13 -0
- package/dist/esm/modules/sdk/types/oneSDK.js +2 -0
- package/dist/esm/modules/sdk/types/oneSDK.js.map +1 -0
- package/dist/esm/modules/sdk/types/oneSDKModules.d.ts +82 -0
- package/dist/esm/modules/sdk/types/oneSDKModules.js +2 -0
- package/dist/esm/modules/sdk/types/oneSDKModules.js.map +1 -0
- package/dist/esm/modules/sdk/types/{configuration.d.ts → oneSDKParameters.d.ts} +6 -20
- package/dist/esm/modules/sdk/types/oneSDKParameters.js +8 -0
- package/dist/esm/modules/sdk/types/oneSDKParameters.js.map +1 -0
- package/dist/esm/modules/sdk/types/oneSDKVendorWrappers.d.ts +11 -0
- package/dist/esm/modules/sdk/types/oneSDKVendorWrappers.js +2 -0
- package/dist/esm/modules/sdk/types/oneSDKVendorWrappers.js.map +1 -0
- package/dist/esm/modules/session/SessionContext.d.ts +4 -1
- package/dist/esm/modules/session/SessionContext.js +6 -0
- package/dist/esm/modules/session/SessionContext.js.map +1 -1
- package/dist/esm/modules/session/index.d.ts +4 -5
- package/dist/esm/modules/session/index.js +21 -23
- package/dist/esm/modules/session/index.js.map +1 -1
- package/dist/esm/types/Primitives.d.ts +9 -1
- package/dist/esm/types/Utilities.d.ts +12 -0
- package/dist/release.txt +2 -2
- package/dist/umd/biometrics-dummy.js +1 -1
- package/dist/umd/biometrics-dummy.js.map +1 -1
- package/dist/umd/biometrics-ocrlabs.js +1 -1
- package/dist/umd/biometrics-ocrlabs.js.map +1 -1
- package/dist/umd/device-sardine.js +1 -1
- package/dist/umd/device-sardine.js.map +1 -1
- package/dist/umd/device-threatmetrix.js +1 -1
- package/dist/umd/device-threatmetrix.js.map +1 -1
- package/dist/umd/oneSdk.umd.js +1 -1
- package/dist/umd/oneSdk.umd.js.map +1 -1
- package/dist/version.txt +2 -2
- package/package.json +1 -1
- package/dist/esm/modules/biometrics/types/events.js.map +0 -1
- package/dist/esm/modules/biometrics/types/index.d.ts +0 -3
- package/dist/esm/modules/biometrics/types/index.js +0 -4
- package/dist/esm/modules/biometrics/types/index.js.map +0 -1
- package/dist/esm/modules/biometrics/types/module.d.ts +0 -8
- package/dist/esm/modules/biometrics/types/module.js +0 -2
- package/dist/esm/modules/biometrics/types/module.js.map +0 -1
- package/dist/esm/modules/biometrics/types/wrapper.d.ts +0 -19
- package/dist/esm/modules/biometrics/types/wrapper.js +0 -2
- package/dist/esm/modules/biometrics/types/wrapper.js.map +0 -1
- package/dist/esm/modules/biometrics/wrappers/OcrLabs/Liveness.js.map +0 -1
- package/dist/esm/modules/biometrics/wrappers/OcrLabs/index.d.ts +0 -3
- package/dist/esm/modules/biometrics/wrappers/OcrLabs/index.js.map +0 -1
- package/dist/esm/modules/biometrics/wrappers/OcrLabs/nolint_liveness-v3.1.1.min.umd.js.map +0 -1
- package/dist/esm/modules/biometrics/wrappers/dummy-biometrics/green-tick-svg.js.map +0 -1
- package/dist/esm/modules/biometrics/wrappers/dummy-biometrics/index.d.ts +0 -2
- package/dist/esm/modules/biometrics/wrappers/dummy-biometrics/index.js.map +0 -1
- package/dist/esm/modules/common/constants.d.ts +0 -8
- package/dist/esm/modules/common/constants.js +0 -11
- package/dist/esm/modules/common/constants.js.map +0 -1
- package/dist/esm/modules/common/types/Configuration.js +0 -2
- package/dist/esm/modules/common/types/Configuration.js.map +0 -1
- package/dist/esm/modules/device/types/events.js.map +0 -1
- package/dist/esm/modules/device/types/index.d.ts +0 -3
- package/dist/esm/modules/device/types/index.js +0 -4
- package/dist/esm/modules/device/types/index.js.map +0 -1
- package/dist/esm/modules/device/types/module.d.ts +0 -13
- package/dist/esm/modules/device/types/module.js +0 -2
- package/dist/esm/modules/device/types/module.js.map +0 -1
- package/dist/esm/modules/device/types/wrapper.d.ts +0 -34
- package/dist/esm/modules/device/types/wrapper.js +0 -2
- package/dist/esm/modules/device/types/wrapper.js.map +0 -1
- package/dist/esm/modules/federation/types/events.js.map +0 -1
- package/dist/esm/modules/federation/types/module.d.ts +0 -8
- package/dist/esm/modules/federation/types/module.js +0 -2
- package/dist/esm/modules/federation/types/module.js.map +0 -1
- package/dist/esm/modules/federation/types/wrapper.d.ts +0 -18
- package/dist/esm/modules/federation/types/wrapper.js +0 -2
- package/dist/esm/modules/federation/types/wrapper.js.map +0 -1
- package/dist/esm/modules/individual/types/events.js.map +0 -1
- package/dist/esm/modules/individual/types/index.d.ts +0 -2
- package/dist/esm/modules/individual/types/index.js +0 -3
- package/dist/esm/modules/individual/types/index.js.map +0 -1
- package/dist/esm/modules/individual/types/module.d.ts +0 -31
- package/dist/esm/modules/individual/types/module.js +0 -2
- package/dist/esm/modules/individual/types/module.js.map +0 -1
- package/dist/esm/modules/ocr/types/events.js.map +0 -1
- package/dist/esm/modules/ocr/types/index.d.ts +0 -2
- package/dist/esm/modules/ocr/types/index.js +0 -3
- package/dist/esm/modules/ocr/types/index.js.map +0 -1
- package/dist/esm/modules/ocr/types/module.d.ts +0 -26
- package/dist/esm/modules/ocr/types/module.js +0 -2
- package/dist/esm/modules/ocr/types/module.js.map +0 -1
- package/dist/esm/modules/sdk/types/components.d.ts +0 -25
- package/dist/esm/modules/sdk/types/components.js +0 -2
- package/dist/esm/modules/sdk/types/components.js.map +0 -1
- package/dist/esm/modules/sdk/types/configuration.js +0 -38
- package/dist/esm/modules/sdk/types/configuration.js.map +0 -1
- package/dist/esm/modules/sdk/types/events.js +0 -2
- package/dist/esm/modules/sdk/types/events.js.map +0 -1
- package/dist/esm/modules/sdk/types/module.d.ts +0 -16
- package/dist/esm/modules/sdk/types/module.js +0 -2
- package/dist/esm/modules/sdk/types/module.js.map +0 -1
- /package/dist/esm/modules/biometrics/{types/events.js → events.js} +0 -0
- /package/dist/esm/modules/biometrics/{wrappers → vendors}/OcrLabs/Liveness.d.ts +0 -0
- /package/dist/esm/modules/biometrics/{wrappers → vendors}/OcrLabs/Liveness.js +0 -0
- /package/dist/esm/modules/biometrics/{wrappers → vendors}/OcrLabs/nolint_liveness-v3.1.1.min.umd.js +0 -0
- /package/dist/esm/modules/biometrics/{wrappers → vendors}/dummy-biometrics/green-tick-svg.d.ts +0 -0
- /package/dist/esm/modules/biometrics/{wrappers → vendors}/dummy-biometrics/green-tick-svg.js +0 -0
- /package/dist/esm/modules/common/types/{Configuration.d.ts → RecipeConfiguration.d.ts} +0 -0
- /package/dist/esm/modules/device/{types/events.js → events.js} +0 -0
- /package/dist/esm/modules/federation/{types/events.d.ts → events.d.ts} +0 -0
- /package/dist/esm/modules/federation/{types/events.js → events.js} +0 -0
- /package/dist/esm/modules/individual/{types/events.js → events.js} +0 -0
- /package/dist/esm/modules/ocr/{types/events.js → events.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"green-tick-svg.js","sourceRoot":"","sources":["../../../../../../modules/biometrics/vendors/dummy-biometrics/green-tick-svg.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,EAAE,CACnC,QAAQ,KAAK,qUAAqU,CAAC"}
|
|
@@ -9,22 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { IDVClient } from "../../../frankie-client/clients/IDVClient";
|
|
11
11
|
import { svg as greentick } from "./green-tick-svg";
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
const BiometricsCapture = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
const { eventHub, idvClient, recipe: { biometrics: { is_synchronous: isSynchronous }, }, } = options;
|
|
12
|
+
export const initialise = (shared, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
const { mountElement } = options;
|
|
14
|
+
const idvClient = new IDVClient(shared.frankieClient);
|
|
15
|
+
yield idvClient.getToken();
|
|
16
|
+
mountElement.appendChild(yield BiometricsCapture(shared, Object.assign({ idvClient }, options)));
|
|
17
|
+
return {};
|
|
18
|
+
});
|
|
19
|
+
const BiometricsCapture = (shared, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const { recipe: { biometrics: { is_synchronous: isSynchronous }, }, } = shared;
|
|
21
|
+
const { idvClient, eventHub } = options;
|
|
28
22
|
const frame = document.createElement("div");
|
|
29
23
|
frame.style.position = "relative";
|
|
30
24
|
frame.style.height = "480px";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../modules/biometrics/vendors/dummy-biometrics/index.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,CAAC,MAAM,UAAU,GAInB,CAAO,MAAM,EAAE,OAAO,EAAE,EAAE;IAC5B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACjC,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACtD,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC3B,YAAY,CAAC,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,kBAAI,SAAS,IAAK,OAAO,EAAG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E;IACpC,IAAI,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE;QACvC,OAAO,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;KAC/E;;QAAM,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "../configuration";
|
|
2
2
|
export * from "./errors/OneSDKError";
|
|
3
|
+
export * from "./modules/HOF";
|
|
4
|
+
export * from "./modules/ReactiveStore";
|
|
3
5
|
export * from "./modules/base64";
|
|
4
6
|
export * from "./modules/env2url";
|
|
5
7
|
export * from "./modules/error";
|
|
6
8
|
export * from "./modules/eventHub";
|
|
7
9
|
export * from "./modules/loadAsyncAsset";
|
|
8
10
|
export * from "./modules/merge";
|
|
9
|
-
export * from "./modules/ReactiveStore";
|
|
10
11
|
export * from "./modules/vendorLoading";
|
|
11
12
|
export * from "./types/Accessors";
|
|
12
|
-
export * from "./types/
|
|
13
|
+
export * from "./types/RecipeConfiguration";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "../configuration";
|
|
2
2
|
export * from "./errors/OneSDKError";
|
|
3
|
+
export * from "./modules/HOF";
|
|
4
|
+
export * from "./modules/ReactiveStore";
|
|
3
5
|
export * from "./modules/base64";
|
|
4
6
|
export * from "./modules/env2url";
|
|
5
7
|
export * from "./modules/error";
|
|
6
8
|
export * from "./modules/eventHub";
|
|
7
9
|
export * from "./modules/loadAsyncAsset";
|
|
8
10
|
export * from "./modules/merge";
|
|
9
|
-
export * from "./modules/ReactiveStore";
|
|
10
11
|
export * from "./modules/vendorLoading";
|
|
11
12
|
export * from "./types/Accessors";
|
|
12
|
-
export * from "./types/
|
|
13
|
+
export * from "./types/RecipeConfiguration";
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
|
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
import { KeyOf } from "../../../types/index.js";
|
|
2
2
|
import { EventHub, EventsDictionary, ExtendedEvents } from "./eventHub";
|
|
3
3
|
declare type Runnable = (...args: any[]) => any;
|
|
4
|
-
|
|
5
|
-
* Ensures only one level of promises is provided
|
|
6
|
-
*/
|
|
7
|
-
declare type AsyncShallow<Value> = Promise<Awaited<Value>>;
|
|
8
|
-
declare type AsyncFunction<F extends Runnable> = (...args: Parameters<F>) => AsyncShallow<ReturnType<F>>;
|
|
9
|
-
declare type Options<Callback extends Runnable, Events extends EventsDictionary> = {
|
|
4
|
+
declare type BasicOptions<Callback extends Runnable> = {
|
|
10
5
|
condition: () => boolean;
|
|
11
6
|
run: Callback;
|
|
7
|
+
};
|
|
8
|
+
declare type OptionsWithCallback<Callback extends Runnable, Events extends EventsDictionary> = BasicOptions<Callback> & {
|
|
12
9
|
elseWaitFor: KeyOf<ExtendedEvents<Events>>;
|
|
13
|
-
|
|
10
|
+
on: EventHub<Events>;
|
|
11
|
+
timeoutMilliSecond?: number;
|
|
14
12
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* - runs the function "run" if "condition" is true,
|
|
18
|
-
* - otherwise it will wait for the event "elseWaitFor" to be emitted by "eventHub" to run the function
|
|
19
|
-
* @param run main function to be run
|
|
20
|
-
* @param condition function returning a boolean
|
|
21
|
-
* @param elseWaitFor string with the name of the event to trigger a retry
|
|
22
|
-
*
|
|
23
|
-
* @returns a function that takes the same parameters as "run" and returns a promise with the same results returned by "run"
|
|
24
|
-
*/
|
|
25
|
-
export declare const runIfWhen: <Callback extends Runnable, Events extends EventsDictionary>(opt: Options<Callback, Events>) => AsyncFunction<Callback>;
|
|
13
|
+
declare type Options<Callback extends Runnable, Events extends EventsDictionary> = BasicOptions<Callback> | OptionsWithCallback<Callback, Events>;
|
|
14
|
+
export declare function runIfWhen<Callback extends Runnable, Events extends EventsDictionary>(opt: Options<Callback, Events>): Callback;
|
|
26
15
|
/**
|
|
27
16
|
* runOnce
|
|
28
17
|
* - takes a function and an error message and returns an equivalent function that
|
|
@@ -19,15 +19,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
*
|
|
20
20
|
* @returns a function that takes the same parameters as "run" and returns a promise with the same results returned by "run"
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
const hasEventCallback = (option) => "elseWaitFor" in option;
|
|
23
|
+
export function runIfWhen(opt) {
|
|
24
|
+
const callback = (...args) => {
|
|
25
|
+
if (opt.condition())
|
|
26
|
+
return Promise.resolve(opt.run(...args));
|
|
27
|
+
else if (hasEventCallback(opt)) {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
const eventName = opt.elseWaitFor;
|
|
30
|
+
const eventCallback = () => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (timeout)
|
|
32
|
+
clearTimeout(timeout);
|
|
33
|
+
resolve(opt.run(...args));
|
|
34
|
+
});
|
|
35
|
+
const timeoutCallback = () => {
|
|
36
|
+
opt.on.off(eventName, eventCallback);
|
|
37
|
+
reject(`Timed out in ${opt.timeoutMilliSecond} milliseconds.`);
|
|
38
|
+
};
|
|
39
|
+
let timeout;
|
|
40
|
+
if (opt.timeoutMilliSecond)
|
|
41
|
+
timeout = setTimeout(timeoutCallback);
|
|
42
|
+
opt.on.on(eventName, eventCallback);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return callback;
|
|
47
|
+
}
|
|
31
48
|
/**
|
|
32
49
|
* runOnce
|
|
33
50
|
* - takes a function and an error message and returns an equivalent function that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HOF.js","sourceRoot":"","sources":["../../../../../modules/common/modules/HOF.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,mHAAmH;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"HOF.js","sourceRoot":"","sources":["../../../../../modules/common/modules/HOF.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,mHAAmH;;;;;;;;;;AA0BnH;;;;;;;;;GASG;AAEH,MAAM,gBAAgB,GAAG,CACvB,MAAyB,EACgB,EAAE,CAAC,aAAa,IAAI,MAAM,CAAC;AACtE,MAAM,UAAU,SAAS,CACvB,GAA8B;IAE9B,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;QACtC,IAAI,GAAG,CAAC,SAAS,EAAE;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;aACzD,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE;YAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrC,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC;gBAClC,MAAM,aAAa,GAAG,GAAS,EAAE;oBAC/B,IAAI,OAAO;wBAAE,YAAY,CAAC,OAAO,CAAC,CAAC;oBACnC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;gBAC5B,CAAC,CAAA,CAAC;gBACF,MAAM,eAAe,GAAG,GAAG,EAAE;oBAC3B,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;oBACrC,MAAM,CAAC,gBAAgB,GAAG,CAAC,kBAAkB,gBAAgB,CAAC,CAAC;gBACjE,CAAC,CAAC;gBACF,IAAI,OAAsC,CAAC;gBAC3C,IAAI,GAAG,CAAC,kBAAkB;oBAAE,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;gBAClE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;IAEF,OAAO,QAAoB,CAAC;AAC9B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAwB,IAAU,EAAE,YAAoB,EAAQ,EAAE;IACvF,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,OAAa,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE;QACxB,IAAI,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7B,SAAS,GAAG,IAAI,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -24,13 +24,13 @@ export declare type CommonEvents<Events extends EventsDictionary = EventsDiction
|
|
|
24
24
|
payload?: unknown;
|
|
25
25
|
}];
|
|
26
26
|
};
|
|
27
|
-
export declare type EventHub<ModuleEvents extends EventsDictionary =
|
|
27
|
+
export declare type EventHub<ModuleEvents extends EventsDictionary = EventsDictionary> = {
|
|
28
28
|
on: <EventName extends KeyOfExtendedEvents<ModuleEvents>>(eventName: EventName, listener: EventListenerCallback<ExtendedEvents<ModuleEvents>[EventName]>) => void;
|
|
29
29
|
off: <EventName extends KeyOfExtendedEvents<ModuleEvents>>(eventName: EventName, listener: EventListenerCallback<ExtendedEvents<ModuleEvents>[EventName]>) => void;
|
|
30
30
|
emit: <EventName extends KeyOfExtendedEvents<ModuleEvents>>(eventName: EventName, ...args: ExtendedEvents<ModuleEvents>[EventName]) => void;
|
|
31
31
|
hasListenersFor: <EventName extends KeyOfExtendedEvents<ModuleEvents>>(eventName: EventName) => boolean;
|
|
32
32
|
};
|
|
33
|
-
export declare type EventListener<Events extends EventsDictionary> = Omit<EventHub<Events>, "emit" | "intercept" | "hasListenersFor">;
|
|
33
|
+
export declare type EventListener<Events extends EventsDictionary = EventsDictionary> = Omit<EventHub<Events>, "emit" | "intercept" | "hasListenersFor">;
|
|
34
34
|
export declare type EventsDictionary = Record<string, unknown[]>;
|
|
35
35
|
export declare type EventListenerCallback<Arguments extends unknown[]> = (...args: Arguments) => void;
|
|
36
36
|
export declare type ExtendedEvents<Events extends EventsDictionary> = Events & CommonEvents<Events>;
|
|
@@ -1,48 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PublicModuleName } from "../../configuration";
|
|
2
|
+
import { SharedConfiguration } from "../../sdk/types";
|
|
3
|
+
import { Dictionary } from "../shared/models/general";
|
|
3
4
|
import { EventHub } from "./eventHub";
|
|
4
5
|
/**
|
|
5
|
-
* Helper function that defines a common logic to load and initialise vendor wrappers
|
|
6
|
+
* Helper Closure function that defines a common logic to load and initialise vendor wrappers
|
|
6
7
|
* as well as the events that are emitted in the process.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
* 1. "preInitialisation" is optional and prepares any data that you might need to be provided to "vendorLoader"
|
|
10
|
-
* 2. "vendorLoader" will take both all the options passed to "loadAndInitialiseVendor" as the first parameter, but also whatever is returned by "preInitialisation" as a second parameter
|
|
11
|
-
* 3. "onSuccess" will be called when the initialisation was completed without errors
|
|
12
|
-
* 4. "onError" will be called when any errors occurred anywhere in the chain
|
|
9
|
+
* This function (the factory) returns another function (the loader)
|
|
13
10
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
11
|
+
* The factory takes as parameters an object containing:
|
|
12
|
+
* 1. sharedConfiguration: SharedConfiguration, provided to all modules by default
|
|
13
|
+
* 2. vendorName: string,
|
|
14
|
+
* 3. vendorLoader: Function which parameters are
|
|
15
|
+
* - initialOptions: { sharedConfiguration vendorName }, provided above
|
|
16
|
+
* - wrapperOptions: options provided later to the loader function
|
|
17
|
+
* returns the loaded vendor wrapper module containing a function called "initialise"
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* The loader takes as parameters an object containing:
|
|
20
|
+
* 1. vendorWrapperOptions: Function which parameters are
|
|
21
|
+
* - initialOptions: { sharedConfiguration, vendorName }
|
|
22
|
+
* returns an object matching the required options passed to the "initialise" function mentioned above
|
|
23
|
+
* 2. "onSuccess" will be called with the Vendor Wrapper Context object as well as other parameters provided above. TBC
|
|
24
|
+
* 3. "onError" will be called with the Error object as well as other parameters provided above. TBC
|
|
20
25
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
26
|
+
* OBS 1: You may interrupt the initialisation chain by throwing an error or returning a rejected promise from any of the provided functions.
|
|
27
|
+
* OBS 2: Both vendorLoader and vendorWrapperOptions accept a shortcut version of their function
|
|
28
|
+
* - vendorLoader may be provided as a dictionary mapping vendorName to a dynamic import function
|
|
29
|
+
* ex: {
|
|
30
|
+
* vendorABC: () => import("relative file path or url to the vendor module exporting a 'initialise' function"),
|
|
31
|
+
* vendorXYZ: () => import("relative file path or url to the vendor module exporting a 'initialise' function"),
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* - vendorWrapperOptions may be provided as simply an object to be passed to the "initialise" function
|
|
35
|
+
*
|
|
36
|
+
* OBS 3: The vendor wrapper initialise function actually takes two parameters
|
|
37
|
+
* sharedConfiguration, which is provided by default
|
|
38
|
+
* vendorWrapperOptions, which is provided in the homonimous parameters of the loader function
|
|
39
|
+
*
|
|
40
|
+
* @param loaderOpts Required options for loading and initialising vendor wrappers
|
|
41
|
+
*
|
|
42
|
+
* @param options.vendorLoader ({ vendorName, sharedConfiguration }) => VendorModule OR Dictionary<VendorName, () => VendorModule
|
|
43
|
+
* @param options.onSuccess What happens after initialising the wrapperContext. Takes the context object as parameter
|
|
44
|
+
* @param options.onError What happens when an error is captured anywhere in the process. Takes the error object as parameter
|
|
45
|
+
*
|
|
46
|
+
* This function is a factory for the actual loader, with the signature
|
|
47
|
+
* 1) First generate the Vendor Wrapper Loader
|
|
48
|
+
* const loadVendor = mkVendorLoader(...options);
|
|
49
|
+
* 2) When its time, call the assynchronous vendorLoader
|
|
50
|
+
* const wrapperContext = await loadVendor(...options);
|
|
51
|
+
* 3) Subsequent calls to loadVendor will returned a cached wrapperContext object.
|
|
52
|
+
* wrapperContext === await loadVendor();
|
|
33
53
|
*/
|
|
34
|
-
export declare function
|
|
35
|
-
declare type
|
|
36
|
-
initialise: (...o: unknown[]) => Promise<Ctx>;
|
|
37
|
-
};
|
|
38
|
-
declare type VendorContext<VendorWrapper> = VendorWrapper extends VendorWrapperObject<infer Ctx> ? Ctx : never;
|
|
39
|
-
export declare type VendorLoader<Vendor extends string, WOpt, VWrap, Init> = (options: StaticOptions<Vendor, WOpt>, initData: Init) => Promise<VWrap>;
|
|
40
|
-
export declare type CommonVendorEvents<VendorName extends string> = {
|
|
54
|
+
export declare function mkVendorLoader<WrapperOptions, WrapperContext, InitData>(loaderOpts: LoaderOptions & VendorLoaderOptions<WrapperOptions, WrapperContext, InitData>): (callbacks: Callbacks<WrapperOptions, WrapperContext, InitData>) => Promise<WrapperContext>;
|
|
55
|
+
export declare type RequiredEvents = {
|
|
41
56
|
vendor_sdk_loaded: [{
|
|
42
|
-
|
|
57
|
+
componentName: PublicModuleName | "individual";
|
|
58
|
+
instanceName: string;
|
|
59
|
+
vendor: string;
|
|
43
60
|
}];
|
|
44
61
|
vendor_sdk_failed_loading: [{
|
|
45
|
-
vendor:
|
|
62
|
+
vendor: string;
|
|
46
63
|
errorObject: unknown;
|
|
47
64
|
}];
|
|
48
65
|
error: [{
|
|
@@ -50,17 +67,24 @@ export declare type CommonVendorEvents<VendorName extends string> = {
|
|
|
50
67
|
payload: unknown;
|
|
51
68
|
}];
|
|
52
69
|
};
|
|
53
|
-
declare type
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
declare type RequiredDependencies = {
|
|
71
|
+
eventHub: EventHub<RequiredEvents>;
|
|
72
|
+
};
|
|
73
|
+
declare type VendorWrapperImport<Opts, Ctx> = Promise<{
|
|
74
|
+
initialise: (b: SharedConfiguration, o: Opts) => Ctx | Promise<Ctx>;
|
|
75
|
+
}>;
|
|
76
|
+
declare type VendorWrapperImporter<Opts, Ctx, InitData> = (loaderOpts: LoaderOptions, wrapperOpts: Opts & InitData) => VendorWrapperImport<Opts, Ctx>;
|
|
77
|
+
declare type VendorLoaderOptions<Opts, Ctx, InitData> = {
|
|
78
|
+
vendorLoader: VendorWrapperImporter<Opts, Ctx, InitData> | Dictionary<VendorWrapperImporter<Opts, Ctx, InitData>>;
|
|
79
|
+
};
|
|
80
|
+
declare type LoaderOptions = {
|
|
81
|
+
vendorName: string;
|
|
82
|
+
sharedConfiguration: SharedConfiguration;
|
|
59
83
|
};
|
|
60
|
-
declare type
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
onSuccess
|
|
64
|
-
onError
|
|
84
|
+
declare type WrapperOptions<InitData, Opts> = InitData & Opts & RequiredDependencies;
|
|
85
|
+
declare type Callbacks<Opts extends Dictionary, Ctx, InitData extends Dictionary> = {
|
|
86
|
+
vendorWrapperOptions: WrapperOptions<InitData, Opts> | ((loaderOpts: LoaderOptions) => WrapperOptions<InitData, Opts>);
|
|
87
|
+
onSuccess?: (context: Ctx, loaderOpts: LoaderOptions, wrapperOpts: Opts) => void;
|
|
88
|
+
onError?: (error: Error, loaderOpts: LoaderOptions, wrapperOpts: Opts) => void;
|
|
65
89
|
};
|
|
66
90
|
export {};
|
|
@@ -1,79 +1,146 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import { OneSDKError } from "../errors/OneSDKError";
|
|
13
2
|
/**
|
|
14
|
-
* Helper function that defines a common logic to load and initialise vendor wrappers
|
|
3
|
+
* Helper Closure function that defines a common logic to load and initialise vendor wrappers
|
|
15
4
|
* as well as the events that are emitted in the process.
|
|
16
5
|
*
|
|
17
|
-
*
|
|
18
|
-
* 1. "preInitialisation" is optional and prepares any data that you might need to be provided to "vendorLoader"
|
|
19
|
-
* 2. "vendorLoader" will take both all the options passed to "loadAndInitialiseVendor" as the first parameter, but also whatever is returned by "preInitialisation" as a second parameter
|
|
20
|
-
* 3. "onSuccess" will be called when the initialisation was completed without errors
|
|
21
|
-
* 4. "onError" will be called when any errors occurred anywhere in the chain
|
|
6
|
+
* This function (the factory) returns another function (the loader)
|
|
22
7
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
8
|
+
* The factory takes as parameters an object containing:
|
|
9
|
+
* 1. sharedConfiguration: SharedConfiguration, provided to all modules by default
|
|
10
|
+
* 2. vendorName: string,
|
|
11
|
+
* 3. vendorLoader: Function which parameters are
|
|
12
|
+
* - initialOptions: { sharedConfiguration vendorName }, provided above
|
|
13
|
+
* - wrapperOptions: options provided later to the loader function
|
|
14
|
+
* returns the loaded vendor wrapper module containing a function called "initialise"
|
|
27
15
|
*
|
|
28
|
-
*
|
|
16
|
+
* The loader takes as parameters an object containing:
|
|
17
|
+
* 1. vendorWrapperOptions: Function which parameters are
|
|
18
|
+
* - initialOptions: { sharedConfiguration, vendorName }
|
|
19
|
+
* returns an object matching the required options passed to the "initialise" function mentioned above
|
|
20
|
+
* 2. "onSuccess" will be called with the Vendor Wrapper Context object as well as other parameters provided above. TBC
|
|
21
|
+
* 3. "onError" will be called with the Error object as well as other parameters provided above. TBC
|
|
29
22
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
23
|
+
* OBS 1: You may interrupt the initialisation chain by throwing an error or returning a rejected promise from any of the provided functions.
|
|
24
|
+
* OBS 2: Both vendorLoader and vendorWrapperOptions accept a shortcut version of their function
|
|
25
|
+
* - vendorLoader may be provided as a dictionary mapping vendorName to a dynamic import function
|
|
26
|
+
* ex: {
|
|
27
|
+
* vendorABC: () => import("relative file path or url to the vendor module exporting a 'initialise' function"),
|
|
28
|
+
* vendorXYZ: () => import("relative file path or url to the vendor module exporting a 'initialise' function"),
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* - vendorWrapperOptions may be provided as simply an object to be passed to the "initialise" function
|
|
32
|
+
*
|
|
33
|
+
* OBS 3: The vendor wrapper initialise function actually takes two parameters
|
|
34
|
+
* sharedConfiguration, which is provided by default
|
|
35
|
+
* vendorWrapperOptions, which is provided in the homonimous parameters of the loader function
|
|
36
|
+
*
|
|
37
|
+
* @param loaderOpts Required options for loading and initialising vendor wrappers
|
|
38
|
+
*
|
|
39
|
+
* @param options.vendorLoader ({ vendorName, sharedConfiguration }) => VendorModule OR Dictionary<VendorName, () => VendorModule
|
|
40
|
+
* @param options.onSuccess What happens after initialising the wrapperContext. Takes the context object as parameter
|
|
41
|
+
* @param options.onError What happens when an error is captured anywhere in the process. Takes the error object as parameter
|
|
42
|
+
*
|
|
43
|
+
* This function is a factory for the actual loader, with the signature
|
|
44
|
+
* 1) First generate the Vendor Wrapper Loader
|
|
45
|
+
* const loadVendor = mkVendorLoader(...options);
|
|
46
|
+
* 2) When its time, call the assynchronous vendorLoader
|
|
47
|
+
* const wrapperContext = await loadVendor(...options);
|
|
48
|
+
* 3) Subsequent calls to loadVendor will returned a cached wrapperContext object.
|
|
49
|
+
* wrapperContext === await loadVendor();
|
|
42
50
|
*/
|
|
43
|
-
export function
|
|
44
|
-
const {
|
|
51
|
+
export function mkVendorLoader(loaderOpts) {
|
|
52
|
+
const { vendorLoader, sharedConfiguration, vendorName } = loaderOpts;
|
|
53
|
+
const { globalEventHub, moduleMeta: { moduleName, instanceName }, } = sharedConfiguration;
|
|
45
54
|
// Store "telemetry-event-friendly" formatted component name for later use
|
|
46
|
-
const COMPONENT =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
const COMPONENT = moduleName.toUpperCase();
|
|
56
|
+
// Cache loaded context
|
|
57
|
+
let theLoadedContext;
|
|
58
|
+
// LoadTimeDependencies is the options passed to the wrapper at load time + eventHub + callbacks
|
|
59
|
+
const load = (callbacks) => {
|
|
60
|
+
const { onError = () => void 0, onSuccess = () => void 0, vendorWrapperOptions = () => void 0 } = callbacks;
|
|
61
|
+
// vendorWrapperOptions may be provided as either an object or a function that returns an object
|
|
62
|
+
// That object will be merged with the initialOptions.inject object and sent throught the chain of callbacks
|
|
63
|
+
// to be then used to initialise the vendor wrapper as the wrapperOptions object
|
|
64
|
+
const wrapperOpts = isOptionsObject(vendorWrapperOptions) ? vendorWrapperOptions : vendorWrapperOptions(loaderOpts);
|
|
65
|
+
// The vendorLoader may be provided as either a function that returns a Module object which exports an "initialise" function
|
|
66
|
+
// or as a dictionary of VendorName and a function without parameter that dynamically loads and returns said Module object
|
|
67
|
+
// If passed as a function, the vendorLoader will be called with
|
|
68
|
+
// --- 1) the object initialOptions { sharedConfiguration, vendorName, inject }
|
|
69
|
+
// --- 2) the object wrapperOptions, containing the wrapper initialisation options + the extra dependencies (eventHub and others)
|
|
70
|
+
// When importing a module, include a webpackChunkName magic comment to beautify the file output and facilitate debugging
|
|
71
|
+
// import(/* webpackChunkName: 'debug-friendly-name' */ "path/to/wrapper/file.ts")
|
|
72
|
+
// This import is in the format { initialise: VendorWrapperInitialiseFunction }, where
|
|
73
|
+
// VendorWrapperInitialiseFunction = (SharedConfiguration, WrapperOptions) => WrapperContext
|
|
74
|
+
const vendorImporter = typeof vendorLoader === "function" ? vendorLoader : vendorLoader[vendorName];
|
|
75
|
+
const { eventHub } = wrapperOpts;
|
|
76
|
+
return (Promise.resolve(vendorImporter === null || vendorImporter === void 0 ? void 0 : vendorImporter(loaderOpts, wrapperOpts))
|
|
77
|
+
.then((vendorWrapper) => {
|
|
78
|
+
const isDictionaryLoader = typeof vendorLoader === "object";
|
|
79
|
+
// If resulting loaded VendorModule is empty, throw error
|
|
80
|
+
if (!vendorWrapper) {
|
|
81
|
+
let errorMessage = `"Vendor not recognised: '${vendorName}'.`;
|
|
82
|
+
if (isDictionaryLoader)
|
|
83
|
+
errorMessage += ` Found keys were ${JSON.stringify(Object.keys(vendorLoader))}`;
|
|
84
|
+
throw new Error(errorMessage);
|
|
85
|
+
}
|
|
86
|
+
// If loaded VendorModule doesn't contain an initialise function, throw error
|
|
87
|
+
if (!vendorWrapper.initialise) {
|
|
88
|
+
const errorMessage = `Loaded vendor module '${vendorName}' doesn't contain an 'initialise' function`;
|
|
89
|
+
throw new Error(errorMessage);
|
|
90
|
+
}
|
|
91
|
+
return vendorWrapper;
|
|
92
|
+
})
|
|
93
|
+
// If there were no issues loading the vendor module, initialise it with the provided options
|
|
94
|
+
.then((vendorWrapper) => vendorWrapper.initialise(sharedConfiguration, wrapperOpts))
|
|
95
|
+
// After initialising the vendor wrapper, which will load any required extra vendor dependencies
|
|
96
|
+
// Conclude the process by emitting events and calling the onSuccess or the onError callbacks
|
|
97
|
+
.then((wrapperContext) => {
|
|
98
|
+
eventHub.emit("vendor_sdk_loaded", {
|
|
99
|
+
componentName: moduleName,
|
|
100
|
+
instanceName,
|
|
101
|
+
vendor: loaderOpts.vendorName,
|
|
102
|
+
});
|
|
103
|
+
globalEventHub.emit("telemetry", {
|
|
104
|
+
eventName: `${COMPONENT}:VENDOR_WRAPPER_LOADED`,
|
|
105
|
+
data: {
|
|
106
|
+
instanceName: instanceName,
|
|
107
|
+
vendor: loaderOpts.vendorName,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
onSuccess(wrapperContext, loaderOpts, wrapperOpts);
|
|
111
|
+
theLoadedContext = wrapperContext;
|
|
112
|
+
// Vendor Wrapper Context is provided to the onSuccess callback and
|
|
113
|
+
// also returned from the function call wrapped in a Promise
|
|
114
|
+
return wrapperContext;
|
|
115
|
+
})
|
|
116
|
+
.catch((errorObject) => {
|
|
117
|
+
const oneSdkError = new OneSDKError(`Vendor sdk '${loaderOpts.vendorName}' failed loading`, {
|
|
118
|
+
errorObject,
|
|
119
|
+
vendor: loaderOpts.vendorName,
|
|
120
|
+
});
|
|
121
|
+
eventHub.emit("vendor_sdk_failed_loading", { vendor: loaderOpts.vendorName, errorObject });
|
|
122
|
+
eventHub.emit("error", oneSdkError);
|
|
123
|
+
globalEventHub.emit("telemetry", {
|
|
124
|
+
eventName: `${COMPONENT}:VENDOR_FAILED_LOADING`,
|
|
125
|
+
data: {
|
|
126
|
+
instanceName: instanceName,
|
|
127
|
+
vendor: loaderOpts.vendorName,
|
|
128
|
+
},
|
|
129
|
+
error: errorObject,
|
|
130
|
+
});
|
|
131
|
+
onError(errorObject, loaderOpts, wrapperOpts);
|
|
132
|
+
return null;
|
|
67
133
|
}));
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
134
|
+
};
|
|
135
|
+
// What happens when calling the loader function
|
|
136
|
+
return function (callbacks) {
|
|
137
|
+
// If vendor wrapper is already cached internally, simply resolve to it without reloading anything else
|
|
138
|
+
if (theLoadedContext)
|
|
139
|
+
return Promise.resolve(theLoadedContext);
|
|
140
|
+
// Otherwise trigger the callback chain defined in "load"
|
|
141
|
+
else
|
|
142
|
+
return load(callbacks);
|
|
143
|
+
};
|
|
78
144
|
}
|
|
145
|
+
const isOptionsObject = (opts) => typeof opts === "object" && typeof opts.eventHub !== "undefined";
|
|
79
146
|
//# sourceMappingURL=vendorLoading.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vendorLoading.js","sourceRoot":"","sources":["../../../../../modules/common/modules/vendorLoading.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vendorLoading.js","sourceRoot":"","sources":["../../../../../modules/common/modules/vendorLoading.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,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AAE,EAAE;YACrB,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,eAAe,UAAU,CAAC,UAAU,kBAAkB,EAAE;gBAC1F,WAAW;gBACX,MAAM,EAAE,UAAU,CAAC,UAAU;aAC9B,CAAC,CAAC;YACH,QAAQ,CAAC,IAAI,CAAC,2BAA2B,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;YAC3F,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACpC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE;gBAC/B,SAAS,EAAE,GAAG,SAAS,wBAAwB;gBAC/C,IAAI,EAAE;oBACJ,YAAY,EAAE,YAAY;oBAC1B,MAAM,EAAE,UAAU,CAAC,UAAU;iBAC9B;gBACD,KAAK,EAAE,WAAW;aACnB,CAAC,CAAC;YACH,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;YAC9C,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CACL,CAAC;IACJ,CAAC,CAAC;IACF,gDAAgD;IAChD,OAAO,UAAU,SAA8D;QAC7E,uGAAuG;QACvG,IAAI,gBAAgB;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC/D,yDAAyD;;YACpD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC;AA6BD,MAAM,eAAe,GAAG,CAAC,IAAI,EAA4C,EAAE,CACzE,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,WAAW,CAAC"}
|
|
@@ -37,8 +37,8 @@ export interface ReadonlyAccessors<ValueType = unknown> {
|
|
|
37
37
|
* - fields marked with the "readonly" modifier will become ReadonlyAccessors
|
|
38
38
|
* - all other fields will become regular Accessors
|
|
39
39
|
*/
|
|
40
|
-
export declare type AccessorsDictionary<FieldsDictionary extends Dictionary> = {
|
|
41
|
-
[
|
|
40
|
+
export declare type AccessorsDictionary<FieldsDictionary extends Dictionary<unknown, "readwrite"> = Dictionary> = {
|
|
41
|
+
[ReadKey in ReadonlyKeys<FieldsDictionary>]: ReadonlyAccessors<FieldsDictionary[ReadKey]>;
|
|
42
42
|
} & {
|
|
43
43
|
[Field in Exclude<KeyOf<FieldsDictionary>, ReadonlyKeys<FieldsDictionary>>]: Accessors<FieldsDictionary[Field]>;
|
|
44
44
|
};
|
|
@@ -48,4 +48,4 @@ export declare type AccessorsDictionary<FieldsDictionary extends Dictionary> = {
|
|
|
48
48
|
*
|
|
49
49
|
* The "access" function is defined as (fieldName: string) => Accessor<values[fieldName]>
|
|
50
50
|
*/
|
|
51
|
-
export declare type AccessFunction<
|
|
51
|
+
export declare type AccessFunction<PublicAccessors extends Dictionary<unknown, "readwrite"> = Dictionary> = <FieldName extends KeyOf<PublicAccessors>>(field: FieldName) => PublicAccessors[FieldName];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecipeConfiguration.js","sourceRoot":"","sources":["../../../../../modules/common/types/RecipeConfiguration.ts"],"names":[],"mappings":""}
|