@configura/web-api 1.6.0-iotest.2 → 1.6.1-alpha.1

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 (43) hide show
  1. package/dist/CfgProduct.d.ts +29 -10
  2. package/dist/CfgProduct.js +82 -47
  3. package/dist/index.d.ts +2 -4
  4. package/dist/index.js +2 -4
  5. package/dist/productConfiguration/CfgFeature.d.ts +2 -1
  6. package/dist/productConfiguration/CfgFeature.js +27 -8
  7. package/dist/productConfiguration/CfgOption.d.ts +21 -8
  8. package/dist/productConfiguration/CfgOption.js +26 -18
  9. package/dist/productConfiguration/CfgProductConfiguration.d.ts +1 -2
  10. package/dist/productConfiguration/CfgProductConfiguration.js +9 -8
  11. package/dist/syncGroups/SyncGroupsApplier.d.ts +20 -0
  12. package/dist/syncGroups/SyncGroupsApplier.js +520 -0
  13. package/dist/syncGroups/SyncGroupsApplyMode.d.ts +21 -0
  14. package/dist/syncGroups/SyncGroupsApplyMode.js +21 -0
  15. package/dist/syncGroups/SyncGroupsHandler.d.ts +31 -0
  16. package/dist/syncGroups/SyncGroupsHandler.js +71 -0
  17. package/dist/syncGroups/SyncGroupsPathHelper.d.ts +27 -0
  18. package/dist/syncGroups/SyncGroupsPathHelper.js +89 -0
  19. package/dist/syncGroups/SyncGroupsState.d.ts +20 -0
  20. package/dist/syncGroups/SyncGroupsState.js +108 -0
  21. package/dist/syncGroups/SyncGroupsTransaction.d.ts +51 -0
  22. package/dist/syncGroups/SyncGroupsTransaction.js +100 -0
  23. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +24 -95
  24. package/dist/tests/testData/testDataCachedGetProduct.js +8 -19
  25. package/dist/tests/testData/testDataOptions.d.ts +13 -0
  26. package/dist/tests/testData/testDataOptions.js +60 -0
  27. package/dist/tests/testData/testDataProductAggregatedPrice.js +12 -23
  28. package/dist/tests/testData/testDataUpcharge.js +16 -48
  29. package/dist/utilitiesCatalogueData.d.ts +7 -1
  30. package/dist/utilitiesCatalogueData.js +105 -4
  31. package/package.json +3 -3
  32. package/dist/io/CfgHistoryManager.d.ts +0 -30
  33. package/dist/io/CfgHistoryManager.js +0 -62
  34. package/dist/io/CfgHistoryToProdConfConnector.d.ts +0 -10
  35. package/dist/io/CfgHistoryToProdConfConnector.js +0 -20
  36. package/dist/io/CfgIOManager.d.ts +0 -29
  37. package/dist/io/CfgIOManager.js +0 -89
  38. package/dist/io/CfgIOProdConfConnector.d.ts +0 -33
  39. package/dist/io/CfgIOProdConfConnector.js +0 -100
  40. package/dist/io/CfgWindowMessageManager.d.ts +0 -13
  41. package/dist/io/CfgWindowMessageManager.js +0 -28
  42. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +0 -13
  43. package/dist/io/CfgWindowMessageToProdConfConnector.js +0 -17
@@ -1,33 +0,0 @@
1
- import { CfgProduct, CfgProductChangeNotification } from "../CfgProduct.js";
2
- import { CfgIOManager } from "./CfgIOManager.js";
3
- export declare type CfgProdConfMessage = {
4
- version: string;
5
- initial: boolean;
6
- prodConfAsString: string;
7
- };
8
- export declare const STAGE_PROD_CONF_MESSAGE_KEY = "stageProdConf";
9
- export declare const STAGE_PROD_CONF_MESSAGE_VERSION = "1.0";
10
- declare type ProdConfMessageCallback = (message: CfgProdConfMessage) => Promise<void>;
11
- declare type ProdConfStringCallback = (prodConfAsString: string) => Promise<void>;
12
- export declare abstract class CfgIOProdConfConnector<K extends keyof WindowEventMap, S, M extends CfgIOManager<K, S>> {
13
- protected readonly _ioManager: M;
14
- protected readonly _doValidate: boolean;
15
- protected _product: CfgProduct | undefined;
16
- private _stopListenToMessage;
17
- private _stopListenToProdConf;
18
- constructor(_ioManager: M, _doValidate: boolean);
19
- setProduct: (product: CfgProduct | undefined) => Promise<void>;
20
- protected abstract getInitialProdConf(): string | undefined;
21
- protected abstract makeSendData(prodConfAsString: string, initial: boolean): S;
22
- makeMessage(prodConfAsString: string, initial: boolean): CfgProdConfMessage;
23
- makeMessageListener(callback: ProdConfMessageCallback): (message: unknown) => Promise<void>;
24
- /**
25
- * Register the callback to listen for Product Configuration messages
26
- * @returns A function which when called will cancel listening
27
- */
28
- listenForMessage(callback: ProdConfMessageCallback): () => void;
29
- makeProdConfListener(callback: ProdConfStringCallback): (n: CfgProductChangeNotification) => void;
30
- listenForProdConf(product: CfgProduct, callback: ProdConfStringCallback): () => void;
31
- }
32
- export {};
33
- //# sourceMappingURL=CfgIOProdConfConnector.d.ts.map
@@ -1,100 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- export const STAGE_PROD_CONF_MESSAGE_KEY = "stageProdConf";
11
- export const STAGE_PROD_CONF_MESSAGE_VERSION = "1.0";
12
- export class CfgIOProdConfConnector {
13
- constructor(_ioManager, _doValidate) {
14
- this._ioManager = _ioManager;
15
- this._doValidate = _doValidate;
16
- this._stopListenToMessage = undefined;
17
- this._stopListenToProdConf = undefined;
18
- this.setProduct = (product) => __awaiter(this, void 0, void 0, function* () {
19
- var _a, _b;
20
- const currentProduct = this._product;
21
- const newProduct = product;
22
- this._product = newProduct;
23
- // If same product don't do anything at all
24
- if (currentProduct !== undefined &&
25
- newProduct !== undefined &&
26
- currentProduct.isBackedBySame(newProduct)) {
27
- return;
28
- }
29
- if (currentProduct !== undefined) {
30
- (_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
31
- (_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
32
- }
33
- if (newProduct === undefined) {
34
- return;
35
- }
36
- if (currentProduct === undefined) {
37
- const initialProdConf = this.getInitialProdConf();
38
- if (initialProdConf !== undefined) {
39
- yield newProduct.setFromApiSelectionString(initialProdConf, this._doValidate);
40
- }
41
- }
42
- this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, this.makeSendData(newProduct.getApiSelectionAsString(), true));
43
- this._stopListenToMessage = this.listenForMessage((message) => __awaiter(this, void 0, void 0, function* () {
44
- const prodConfAsString = message.prodConfAsString;
45
- if (prodConfAsString === newProduct.getApiSelectionAsString()) {
46
- return;
47
- }
48
- yield newProduct.setFromApiSelectionString(prodConfAsString, this._doValidate);
49
- }));
50
- this._stopListenToProdConf = this.listenForProdConf(newProduct, (prodConfAsString) => __awaiter(this, void 0, void 0, function* () {
51
- this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, this.makeSendData(prodConfAsString, false));
52
- }));
53
- });
54
- }
55
- makeMessage(prodConfAsString, initial) {
56
- return {
57
- version: STAGE_PROD_CONF_MESSAGE_VERSION,
58
- initial,
59
- prodConfAsString,
60
- };
61
- }
62
- makeMessageListener(callback) {
63
- return (message) => __awaiter(this, void 0, void 0, function* () {
64
- const prodConfMessage = message;
65
- const version = prodConfMessage.version;
66
- if (version !== "1.0") {
67
- console.error(`The a message was passed with an unsupported version "${version}". Currently only ${STAGE_PROD_CONF_MESSAGE_VERSION} is supported.`);
68
- return;
69
- }
70
- yield callback(prodConfMessage);
71
- });
72
- }
73
- /**
74
- * Register the callback to listen for Product Configuration messages
75
- * @returns A function which when called will cancel listening
76
- */
77
- listenForMessage(callback) {
78
- const ioManager = this._ioManager;
79
- const listener = this.makeMessageListener(callback);
80
- ioManager.listen(listener, STAGE_PROD_CONF_MESSAGE_KEY);
81
- return () => {
82
- ioManager.stopListen(listener);
83
- };
84
- }
85
- makeProdConfListener(callback) {
86
- return (n) => {
87
- if (!n.committed) {
88
- return;
89
- }
90
- callback(n.freshRef.getApiSelectionAsString());
91
- };
92
- }
93
- listenForProdConf(product, callback) {
94
- const listener = this.makeProdConfListener(callback);
95
- product.listenForChange(listener);
96
- return () => {
97
- product.stopListenForChange(listener);
98
- };
99
- }
100
- }
@@ -1,13 +0,0 @@
1
- import { CfgIOManager } from "./CfgIOManager.js";
2
- export declare type CfgWindowMessageManagerSendData = unknown;
3
- export declare class CfgWindowMessageManager extends CfgIOManager<"message", CfgWindowMessageManagerSendData> {
4
- private readonly _remoteEnds;
5
- private readonly _targetOrigin;
6
- private readonly _acceptableMessageOrigin?;
7
- constructor(_remoteEnds: Window[], _targetOrigin?: string, _acceptableMessageOrigin?: string | undefined);
8
- protected doSend(messageKey: string, data: unknown): void;
9
- protected _containerListener(event: MessageEvent<any>): void;
10
- protected readonly eventType = "message";
11
- protected getDataFromEvent(event: MessageEvent<any>): unknown;
12
- }
13
- //# sourceMappingURL=CfgWindowMessageManager.d.ts.map
@@ -1,28 +0,0 @@
1
- import { CfgIOManager } from "./CfgIOManager.js";
2
- export class CfgWindowMessageManager extends CfgIOManager {
3
- constructor(_remoteEnds, _targetOrigin = "*", _acceptableMessageOrigin) {
4
- super();
5
- this._remoteEnds = _remoteEnds;
6
- this._targetOrigin = _targetOrigin;
7
- this._acceptableMessageOrigin = _acceptableMessageOrigin;
8
- this.eventType = "message";
9
- }
10
- doSend(messageKey, data) {
11
- const container = CfgIOManager.makeContainer({
12
- [messageKey]: data,
13
- });
14
- for (const remoteEnd of this._remoteEnds) {
15
- remoteEnd.postMessage(container, this._targetOrigin);
16
- }
17
- }
18
- _containerListener(event) {
19
- if (this._acceptableMessageOrigin !== undefined &&
20
- event.origin !== this._acceptableMessageOrigin) {
21
- return;
22
- }
23
- super._containerListener(event);
24
- }
25
- getDataFromEvent(event) {
26
- return event.data;
27
- }
28
- }
@@ -1,13 +0,0 @@
1
- import { CfgIOProdConfConnector } from "./CfgIOProdConfConnector.js";
2
- import { CfgWindowMessageManager, CfgWindowMessageManagerSendData } from "./CfgWindowMessageManager.js";
3
- /**
4
- * Instantiating the class will expose your product to:
5
- * - Listen for configuration changes posted to this window
6
- * - Send configuration changes using sendMessage
7
- */
8
- export declare class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector<"message", CfgWindowMessageManagerSendData, CfgWindowMessageManager> {
9
- constructor(manager: CfgWindowMessageManager, doValidate?: boolean);
10
- protected getInitialProdConf(): string | undefined;
11
- protected makeSendData(prodConfAsString: string, initial: boolean): CfgWindowMessageManagerSendData;
12
- }
13
- //# sourceMappingURL=CfgWindowMessageToProdConfConnector.d.ts.map
@@ -1,17 +0,0 @@
1
- import { CfgIOProdConfConnector } from "./CfgIOProdConfConnector.js";
2
- /**
3
- * Instantiating the class will expose your product to:
4
- * - Listen for configuration changes posted to this window
5
- * - Send configuration changes using sendMessage
6
- */
7
- export class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector {
8
- constructor(manager, doValidate = true) {
9
- super(manager, doValidate);
10
- }
11
- getInitialProdConf() {
12
- return undefined;
13
- }
14
- makeSendData(prodConfAsString, initial) {
15
- return this.makeMessage(prodConfAsString, initial);
16
- }
17
- }