@configura/web-api 2.1.0-alpha.3 → 2.2.0-alpha.0

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 (102) hide show
  1. package/.eslintrc.json +5 -5
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/CatalogueAPI.d.ts +633 -633
  5. package/dist/CatalogueAPI.js +309 -329
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +344 -344
  9. package/dist/CfgProduct.js +992 -990
  10. package/dist/CfgReferencePathHelper.d.ts +26 -26
  11. package/dist/CfgReferencePathHelper.js +26 -26
  12. package/dist/index.d.ts +24 -24
  13. package/dist/index.js +24 -24
  14. package/dist/io/CfgHistoryManager.d.ts +83 -83
  15. package/dist/io/CfgHistoryManager.js +144 -144
  16. package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -21
  17. package/dist/io/CfgHistoryToProdConfConnector.js +50 -50
  18. package/dist/io/CfgIOManager.d.ts +53 -53
  19. package/dist/io/CfgIOManager.js +134 -134
  20. package/dist/io/CfgIOProdConfConnector.d.ts +54 -54
  21. package/dist/io/CfgIOProdConfConnector.js +139 -137
  22. package/dist/io/CfgIOWarningSupplier.d.ts +3 -3
  23. package/dist/io/CfgIOWarningSupplier.js +1 -1
  24. package/dist/io/CfgObservableStateManager.d.ts +25 -25
  25. package/dist/io/CfgObservableStateManager.js +69 -69
  26. package/dist/io/CfgObservableStateToProdConfConnector.d.ts +15 -15
  27. package/dist/io/CfgObservableStateToProdConfConnector.js +17 -17
  28. package/dist/io/CfgWindowEventManager.d.ts +21 -21
  29. package/dist/io/CfgWindowEventManager.js +38 -38
  30. package/dist/io/CfgWindowMessageManager.d.ts +40 -40
  31. package/dist/io/CfgWindowMessageManager.js +91 -91
  32. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +17 -17
  33. package/dist/io/CfgWindowMessageToProdConfConnector.js +19 -19
  34. package/dist/io/index.d.ts +8 -8
  35. package/dist/io/index.js +8 -8
  36. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  37. package/dist/material/CfgMaterialMapping.js +181 -181
  38. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  39. package/dist/material/CfgMtrlApplication.js +43 -43
  40. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  41. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  42. package/dist/material/CfgMtrlSource.d.ts +19 -19
  43. package/dist/material/CfgMtrlSource.js +40 -40
  44. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  45. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  46. package/dist/productConfiguration/CfgFeature.d.ts +199 -199
  47. package/dist/productConfiguration/CfgFeature.js +691 -691
  48. package/dist/productConfiguration/CfgOption.d.ts +160 -160
  49. package/dist/productConfiguration/CfgOption.js +464 -464
  50. package/dist/productConfiguration/CfgProductConfiguration.d.ts +129 -129
  51. package/dist/productConfiguration/CfgProductConfiguration.js +346 -346
  52. package/dist/productConfiguration/filters.d.ts +17 -17
  53. package/dist/productConfiguration/filters.js +141 -141
  54. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  55. package/dist/productConfiguration/productParamsGenerator.js +65 -51
  56. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
  57. package/dist/productConfiguration/utilitiesProductConfiguration.js +87 -87
  58. package/dist/productLoader.d.ts +33 -33
  59. package/dist/productLoader.js +49 -49
  60. package/dist/syncGroups/SyncGroupsApplyMode.d.ts +20 -20
  61. package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
  62. package/dist/syncGroups/SyncGroupsHandler.d.ts +47 -47
  63. package/dist/syncGroups/SyncGroupsHandler.js +370 -370
  64. package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
  65. package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
  66. package/dist/syncGroups/SyncGroupsState.d.ts +39 -39
  67. package/dist/syncGroups/SyncGroupsState.js +167 -167
  68. package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
  69. package/dist/syncGroups/SyncGroupsTransaction.js +589 -589
  70. package/dist/tasks/TaskHandler.d.ts +77 -77
  71. package/dist/tasks/TaskHandler.js +276 -276
  72. package/dist/tasks/formats.d.ts +4 -4
  73. package/dist/tasks/formats.js +7 -7
  74. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  75. package/dist/tests/testData/collectorForTest.js +194 -194
  76. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  77. package/dist/tests/testData/dummyProductForTest.js +32 -32
  78. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
  79. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +282 -282
  80. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  81. package/dist/tests/testData/testDataCachedGetProduct.js +187 -187
  82. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  83. package/dist/tests/testData/testDataCachedPostValidate.js +185 -185
  84. package/dist/tests/testData/testDataConstraints.d.ts +3 -3
  85. package/dist/tests/testData/testDataConstraints.js +174 -174
  86. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  87. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
  88. package/dist/tests/testData/testDataOptions.d.ts +12 -12
  89. package/dist/tests/testData/testDataOptions.js +60 -60
  90. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
  91. package/dist/tests/testData/testDataProductAggregatedPrice.js +189 -189
  92. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  93. package/dist/tests/testData/testDataUpcharge.js +121 -121
  94. package/dist/utilitiesCatalogueData.d.ts +47 -47
  95. package/dist/utilitiesCatalogueData.js +180 -180
  96. package/dist/utilitiesCataloguePermission.d.ts +38 -38
  97. package/dist/utilitiesCataloguePermission.js +79 -79
  98. package/dist/utilitiesConfiguration.d.ts +28 -28
  99. package/dist/utilitiesConfiguration.js +200 -200
  100. package/dist/utilitiesNumericValues.d.ts +24 -24
  101. package/dist/utilitiesNumericValues.js +114 -114
  102. package/package.json +4 -4
@@ -1,137 +1,139 @@
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
- import { convertDtoProductConfToV1 } from "../utilitiesConfiguration.js";
11
- export const isCfgProdConfMessage = (data) => typeof data === "object" && data !== null && "version" in data && "conf" in data;
12
- export const isCfgProdConfMessageV1 = (data) => isCfgProdConfMessage(data) && data.version === "1.0";
13
- export const isCfgProdConfMessageV2 = (data) => isCfgProdConfMessage(data) && data.version === "2.0";
14
- export const getHighestVersionProdConfMessage = (subMessages) => subMessages
15
- .slice(1)
16
- .reduce((a, c) => (a.version < c.version ? c : a), subMessages[0]);
17
- export var CfgProdConfMessageVersions;
18
- (function (CfgProdConfMessageVersions) {
19
- CfgProdConfMessageVersions[CfgProdConfMessageVersions["V1dot0"] = 1] = "V1dot0";
20
- CfgProdConfMessageVersions[CfgProdConfMessageVersions["V2dot0"] = 2] = "V2dot0";
21
- })(CfgProdConfMessageVersions || (CfgProdConfMessageVersions = {}));
22
- export const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
23
- /**
24
- * Base class for connecting the product configuration to an IO channel
25
- */
26
- export class CfgIOProdConfConnector {
27
- constructor(_ioManager, _includeInSend // Only for v2.0
28
- ) {
29
- this._ioManager = _ioManager;
30
- this._includeInSend = _includeInSend;
31
- this._stopListenToMessage = undefined;
32
- this._stopListenToProdConf = undefined;
33
- this.setProduct = (product) => __awaiter(this, void 0, void 0, function* () {
34
- var _a, _b;
35
- const currentProduct = this._product;
36
- const newProduct = product;
37
- this._product = newProduct;
38
- // If same product don't do anything at all
39
- if (currentProduct !== undefined &&
40
- newProduct !== undefined &&
41
- currentProduct.isBackedBySame(newProduct)) {
42
- return;
43
- }
44
- if (currentProduct !== undefined) {
45
- (_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
46
- (_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
47
- }
48
- if (newProduct === undefined) {
49
- return;
50
- }
51
- this._send(this.makeSendData(newProduct.getDtoConf(this._includeInSend), true));
52
- this._stopListenToMessage = CfgIOProdConfConnector.listenForMessage((messages) => __awaiter(this, void 0, void 0, function* () {
53
- const subMessages = messages.subMessages;
54
- if (subMessages.length === 0) {
55
- console.warn(`${STAGE_PROD_CONF_MESSAGE_KEY} message without any submessages. Unexpected.`);
56
- return;
57
- }
58
- const highestVersionMessage = getHighestVersionProdConfMessage(subMessages);
59
- if (isCfgProdConfMessageV1(highestVersionMessage)) {
60
- yield newProduct.setApiSelection(highestVersionMessage.conf);
61
- return;
62
- }
63
- if (isCfgProdConfMessageV2(highestVersionMessage)) {
64
- yield newProduct.setDtoConf(highestVersionMessage.conf);
65
- return;
66
- }
67
- throw new Error("Unknown message version");
68
- }), this._ioManager);
69
- this._stopListenToProdConf = CfgIOProdConfConnector.listenForProdConf(newProduct, (conf) => __awaiter(this, void 0, void 0, function* () { return this._send(this.makeSendData(conf, false)); }), this._includeInSend);
70
- });
71
- this._send = (data) => this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, data);
72
- _ioManager.addWarningSupplier(this);
73
- }
74
- destroy() {
75
- var _a, _b;
76
- (_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
77
- (_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
78
- this._ioManager.removeWarningSupplier(this);
79
- }
80
- getWarnings() {
81
- const product = this._product;
82
- if (product !== undefined && product.hasRootFeaturesChanged) {
83
- return [
84
- "In at least one of the Products, Functional Selection has taken place, thereby changing what root Features are used. The SDK can not yet apply a serialized configuration in these cases. Extracting this data from the SDK for external applications can work, but reinserting the data into Stage will most likely fail.",
85
- ];
86
- }
87
- return [];
88
- }
89
- /**
90
- * Register the callback to listen for Product Configuration messages
91
- * @returns A function which when called will cancel listening
92
- */
93
- static listenForMessage(callback, ioManager) {
94
- const listener = this.makeMessageListener(callback);
95
- ioManager.listenForMessage(listener, STAGE_PROD_CONF_MESSAGE_KEY);
96
- return () => {
97
- ioManager.stopListenForMessage(listener);
98
- };
99
- }
100
- static listenForProdConf(product, callback, includeInSend) {
101
- const listener = this.makeProdConfListener(callback, includeInSend);
102
- product.listenForChange(listener);
103
- return () => {
104
- product.stopListenForChange(listener);
105
- };
106
- }
107
- }
108
- CfgIOProdConfConnector.makeMessage = (conf, initial, sendVersions) => {
109
- const result = [];
110
- if ((sendVersions & CfgProdConfMessageVersions.V1dot0) ===
111
- CfgProdConfMessageVersions.V1dot0) {
112
- const v1 = {
113
- version: "1.0",
114
- conf: convertDtoProductConfToV1(conf, true),
115
- };
116
- result.push(v1);
117
- }
118
- if ((sendVersions & CfgProdConfMessageVersions.V2dot0) ===
119
- CfgProdConfMessageVersions.V2dot0) {
120
- const v2 = {
121
- version: "2.0",
122
- conf,
123
- };
124
- result.push(v2);
125
- }
126
- return { subMessages: result, initial };
127
- };
128
- CfgIOProdConfConnector.makeMessageListener = (callback) => (message) => __awaiter(void 0, void 0, void 0, function* () {
129
- const prodConfMessage = message;
130
- yield callback(prodConfMessage);
131
- });
132
- CfgIOProdConfConnector.makeProdConfListener = (callback, includeInSend) => (n) => {
133
- if (!n.committed) {
134
- return;
135
- }
136
- callback(n.freshRef.getDtoConf(includeInSend));
137
- };
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
+ var _a;
11
+ import { convertDtoProductConfToV1 } from "../utilitiesConfiguration.js";
12
+ export const isCfgProdConfMessage = (data) => typeof data === "object" && data !== null && "version" in data && "conf" in data;
13
+ export const isCfgProdConfMessageV1 = (data) => isCfgProdConfMessage(data) && data.version === "1.0";
14
+ export const isCfgProdConfMessageV2 = (data) => isCfgProdConfMessage(data) && data.version === "2.0";
15
+ export const getHighestVersionProdConfMessage = (subMessages) => subMessages
16
+ .slice(1)
17
+ .reduce((a, c) => (a.version < c.version ? c : a), subMessages[0]);
18
+ export var CfgProdConfMessageVersions;
19
+ (function (CfgProdConfMessageVersions) {
20
+ CfgProdConfMessageVersions[CfgProdConfMessageVersions["V1dot0"] = 1] = "V1dot0";
21
+ CfgProdConfMessageVersions[CfgProdConfMessageVersions["V2dot0"] = 2] = "V2dot0";
22
+ })(CfgProdConfMessageVersions || (CfgProdConfMessageVersions = {}));
23
+ export const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
24
+ /**
25
+ * Base class for connecting the product configuration to an IO channel
26
+ */
27
+ export class CfgIOProdConfConnector {
28
+ constructor(_ioManager, _includeInSend // Only for v2.0
29
+ ) {
30
+ this._ioManager = _ioManager;
31
+ this._includeInSend = _includeInSend;
32
+ this._stopListenToMessage = undefined;
33
+ this._stopListenToProdConf = undefined;
34
+ this.setProduct = (product) => __awaiter(this, void 0, void 0, function* () {
35
+ var _b, _c;
36
+ const currentProduct = this._product;
37
+ const newProduct = product;
38
+ this._product = newProduct;
39
+ // If same product don't do anything at all
40
+ if (currentProduct !== undefined &&
41
+ newProduct !== undefined &&
42
+ currentProduct.isBackedBySame(newProduct)) {
43
+ return;
44
+ }
45
+ if (currentProduct !== undefined) {
46
+ (_b = this._stopListenToMessage) === null || _b === void 0 ? void 0 : _b.call(this);
47
+ (_c = this._stopListenToProdConf) === null || _c === void 0 ? void 0 : _c.call(this);
48
+ }
49
+ if (newProduct === undefined) {
50
+ return;
51
+ }
52
+ this._send(this.makeSendData(newProduct.getDtoConf(this._includeInSend), true));
53
+ this._stopListenToMessage = CfgIOProdConfConnector.listenForMessage((messages) => __awaiter(this, void 0, void 0, function* () {
54
+ const subMessages = messages.subMessages;
55
+ if (subMessages.length === 0) {
56
+ console.warn(`${STAGE_PROD_CONF_MESSAGE_KEY} message without any submessages. Unexpected.`);
57
+ return;
58
+ }
59
+ const highestVersionMessage = getHighestVersionProdConfMessage(subMessages);
60
+ if (isCfgProdConfMessageV1(highestVersionMessage)) {
61
+ yield newProduct.setApiSelection(highestVersionMessage.conf);
62
+ return;
63
+ }
64
+ if (isCfgProdConfMessageV2(highestVersionMessage)) {
65
+ yield newProduct.setDtoConf(highestVersionMessage.conf);
66
+ return;
67
+ }
68
+ throw new Error("Unknown message version");
69
+ }), this._ioManager);
70
+ this._stopListenToProdConf = CfgIOProdConfConnector.listenForProdConf(newProduct, (conf) => __awaiter(this, void 0, void 0, function* () { return this._send(this.makeSendData(conf, false)); }), this._includeInSend);
71
+ });
72
+ this._send = (data) => this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, data);
73
+ _ioManager.addWarningSupplier(this);
74
+ }
75
+ destroy() {
76
+ var _b, _c;
77
+ (_b = this._stopListenToMessage) === null || _b === void 0 ? void 0 : _b.call(this);
78
+ (_c = this._stopListenToProdConf) === null || _c === void 0 ? void 0 : _c.call(this);
79
+ this._ioManager.removeWarningSupplier(this);
80
+ }
81
+ getWarnings() {
82
+ const product = this._product;
83
+ if (product !== undefined && product.hasRootFeaturesChanged) {
84
+ return [
85
+ "In at least one of the Products, Functional Selection has taken place, thereby changing what root Features are used. The SDK can not yet apply a serialized configuration in these cases. Extracting this data from the SDK for external applications can work, but reinserting the data into Stage will most likely fail.",
86
+ ];
87
+ }
88
+ return [];
89
+ }
90
+ /**
91
+ * Register the callback to listen for Product Configuration messages
92
+ * @returns A function which when called will cancel listening
93
+ */
94
+ static listenForMessage(callback, ioManager) {
95
+ const listener = this.makeMessageListener(callback);
96
+ ioManager.listenForMessage(listener, STAGE_PROD_CONF_MESSAGE_KEY);
97
+ return () => {
98
+ ioManager.stopListenForMessage(listener);
99
+ };
100
+ }
101
+ static listenForProdConf(product, callback, includeInSend) {
102
+ const listener = this.makeProdConfListener(callback, includeInSend);
103
+ product.listenForChange(listener);
104
+ return () => {
105
+ product.stopListenForChange(listener);
106
+ };
107
+ }
108
+ }
109
+ _a = CfgIOProdConfConnector;
110
+ CfgIOProdConfConnector.makeMessage = (conf, initial, sendVersions) => {
111
+ const result = [];
112
+ if ((sendVersions & CfgProdConfMessageVersions.V1dot0) ===
113
+ CfgProdConfMessageVersions.V1dot0) {
114
+ const v1 = {
115
+ version: "1.0",
116
+ conf: convertDtoProductConfToV1(conf, true),
117
+ };
118
+ result.push(v1);
119
+ }
120
+ if ((sendVersions & CfgProdConfMessageVersions.V2dot0) ===
121
+ CfgProdConfMessageVersions.V2dot0) {
122
+ const v2 = {
123
+ version: "2.0",
124
+ conf,
125
+ };
126
+ result.push(v2);
127
+ }
128
+ return { subMessages: result, initial };
129
+ };
130
+ CfgIOProdConfConnector.makeMessageListener = (callback) => (message) => __awaiter(void 0, void 0, void 0, function* () {
131
+ const prodConfMessage = message;
132
+ yield callback(prodConfMessage);
133
+ });
134
+ CfgIOProdConfConnector.makeProdConfListener = (callback, includeInSend) => (n) => {
135
+ if (!n.committed) {
136
+ return;
137
+ }
138
+ callback(n.freshRef.getDtoConf(includeInSend));
139
+ };
@@ -1,4 +1,4 @@
1
- export interface CfgIOWarningSupplier {
2
- getWarnings(): string[];
3
- }
1
+ export interface CfgIOWarningSupplier {
2
+ getWarnings(): string[];
3
+ }
4
4
  //# sourceMappingURL=CfgIOWarningSupplier.d.ts.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,26 +1,26 @@
1
- import { Observable } from "@configura/web-utilities";
2
- import { CfgIOManager, IOManagerListener } from "./CfgIOManager.js";
3
- /**
4
- * This class is used to coordinate sending and receiving using the observable
5
- * state in the class. It handles messages sent from the connectors.
6
- */
7
- export declare class CfgObservableStateManager extends CfgIOManager<unknown> {
8
- private static _instance;
9
- static get instance(): CfgObservableStateManager;
10
- private constructor();
11
- readonly stateObservable: Observable<string>;
12
- private messagesState;
13
- get stateAsString(): string;
14
- set stateAsString(s: string);
15
- listenForStateChange(listener: (v: string) => void): void;
16
- stopListenForStateChange(listener: (v: string) => void): void;
17
- listenForMessage(l: IOManagerListener, messageKey: string): boolean;
18
- /**
19
- * Removes the listener
20
- */
21
- stopListenForMessage(l: IOManagerListener): boolean;
22
- private _stateListenerBound;
23
- private _stateListener;
24
- send(messageKey: string, data: unknown): void;
25
- }
1
+ import { Observable } from "@configura/web-utilities";
2
+ import { CfgIOManager, IOManagerListener } from "./CfgIOManager.js";
3
+ /**
4
+ * This class is used to coordinate sending and receiving using the observable
5
+ * state in the class. It handles messages sent from the connectors.
6
+ */
7
+ export declare class CfgObservableStateManager extends CfgIOManager<unknown> {
8
+ private static _instance;
9
+ static get instance(): CfgObservableStateManager;
10
+ private constructor();
11
+ readonly stateObservable: Observable<string>;
12
+ private messagesState;
13
+ get stateAsString(): string;
14
+ set stateAsString(s: string);
15
+ listenForStateChange(listener: (v: string) => void): void;
16
+ stopListenForStateChange(listener: (v: string) => void): void;
17
+ listenForMessage(l: IOManagerListener, messageKey: string): boolean;
18
+ /**
19
+ * Removes the listener
20
+ */
21
+ stopListenForMessage(l: IOManagerListener): boolean;
22
+ private _stateListenerBound;
23
+ private _stateListener;
24
+ send(messageKey: string, data: unknown): void;
25
+ }
26
26
  //# sourceMappingURL=CfgObservableStateManager.d.ts.map
@@ -1,69 +1,69 @@
1
- import { Observable } from "@configura/web-utilities";
2
- import { CfgIOManager } from "./CfgIOManager.js";
3
- /**
4
- * This class is used to coordinate sending and receiving using the observable
5
- * state in the class. It handles messages sent from the connectors.
6
- */
7
- export class CfgObservableStateManager extends CfgIOManager {
8
- constructor() {
9
- super();
10
- this.stateObservable = new Observable();
11
- this.messagesState = {};
12
- this._stateListenerBound = this._stateListener.bind(this);
13
- }
14
- static get instance() {
15
- if (this._instance === undefined) {
16
- this._instance = new CfgObservableStateManager();
17
- }
18
- return this._instance;
19
- }
20
- get stateAsString() {
21
- return JSON.stringify(CfgObservableStateManager.makeContainer(this.messagesState), null, 2);
22
- }
23
- set stateAsString(s) {
24
- this.stateObservable.notifyAll(s);
25
- }
26
- listenForStateChange(listener) {
27
- this.stateObservable.listen(listener);
28
- }
29
- stopListenForStateChange(listener) {
30
- this.stateObservable.stopListen(listener);
31
- }
32
- listenForMessage(l, messageKey) {
33
- const hadListeners = this.hasMessageListeners;
34
- const didStartListen = super.listenForMessage(l, messageKey);
35
- if (!hadListeners && didStartListen) {
36
- this.stateObservable.listen(this._stateListenerBound, this);
37
- }
38
- return didStartListen;
39
- }
40
- /**
41
- * Removes the listener
42
- */
43
- stopListenForMessage(l) {
44
- const didStopListen = super.stopListenForMessage(l);
45
- if (didStopListen && !this.hasMessageListeners) {
46
- this.stateObservable.stopListen(this._stateListenerBound);
47
- }
48
- return didStopListen;
49
- }
50
- _stateListener(data) {
51
- let asJson;
52
- try {
53
- asJson = JSON.parse(data);
54
- }
55
- catch (_a) {
56
- throw new Error("Not JSON data");
57
- }
58
- if (!CfgIOManager.isIOContainer(asJson)) {
59
- console.warn("Not a readable IO container");
60
- return;
61
- }
62
- this.messagesState = asJson.messages;
63
- super._containerListener(asJson);
64
- }
65
- send(messageKey, data) {
66
- this.messagesState[messageKey] = data;
67
- this.stateObservable.notifyAll(this.stateAsString, this);
68
- }
69
- }
1
+ import { Observable } from "@configura/web-utilities";
2
+ import { CfgIOManager } from "./CfgIOManager.js";
3
+ /**
4
+ * This class is used to coordinate sending and receiving using the observable
5
+ * state in the class. It handles messages sent from the connectors.
6
+ */
7
+ export class CfgObservableStateManager extends CfgIOManager {
8
+ constructor() {
9
+ super();
10
+ this.stateObservable = new Observable();
11
+ this.messagesState = {};
12
+ this._stateListenerBound = this._stateListener.bind(this);
13
+ }
14
+ static get instance() {
15
+ if (this._instance === undefined) {
16
+ this._instance = new CfgObservableStateManager();
17
+ }
18
+ return this._instance;
19
+ }
20
+ get stateAsString() {
21
+ return JSON.stringify(CfgObservableStateManager.makeContainer(this.messagesState), null, 2);
22
+ }
23
+ set stateAsString(s) {
24
+ this.stateObservable.notifyAll(s);
25
+ }
26
+ listenForStateChange(listener) {
27
+ this.stateObservable.listen(listener);
28
+ }
29
+ stopListenForStateChange(listener) {
30
+ this.stateObservable.stopListen(listener);
31
+ }
32
+ listenForMessage(l, messageKey) {
33
+ const hadListeners = this.hasMessageListeners;
34
+ const didStartListen = super.listenForMessage(l, messageKey);
35
+ if (!hadListeners && didStartListen) {
36
+ this.stateObservable.listen(this._stateListenerBound, this);
37
+ }
38
+ return didStartListen;
39
+ }
40
+ /**
41
+ * Removes the listener
42
+ */
43
+ stopListenForMessage(l) {
44
+ const didStopListen = super.stopListenForMessage(l);
45
+ if (didStopListen && !this.hasMessageListeners) {
46
+ this.stateObservable.stopListen(this._stateListenerBound);
47
+ }
48
+ return didStopListen;
49
+ }
50
+ _stateListener(data) {
51
+ let asJson;
52
+ try {
53
+ asJson = JSON.parse(data);
54
+ }
55
+ catch (_a) {
56
+ throw new Error("Not JSON data");
57
+ }
58
+ if (!CfgIOManager.isIOContainer(asJson)) {
59
+ console.warn("Not a readable IO container");
60
+ return;
61
+ }
62
+ this.messagesState = asJson.messages;
63
+ super._containerListener(asJson);
64
+ }
65
+ send(messageKey, data) {
66
+ this.messagesState[messageKey] = data;
67
+ this.stateObservable.notifyAll(this.stateAsString, this);
68
+ }
69
+ }
@@ -1,16 +1,16 @@
1
- import { DtoProductConf } from "../CatalogueAPI.js";
2
- import { CfgProdConfParts } from "../utilitiesConfiguration.js";
3
- import { CfgIOProdConfConnector, CfgProdConfMessage, CfgProdConfMessageVersions } from "./CfgIOProdConfConnector.js";
4
- import { CfgObservableStateManager } from "./CfgObservableStateManager.js";
5
- /**
6
- * Instantiating this will make the observable state update with the product configuration.
7
- * @param sendVersions What versions of the productConfiguration shall be sent? Multiple can be selected
8
- * @param includeExtendedDataInSend Only for version 2.0. Includes unit and groupCode.
9
- * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
10
- */
11
- export declare class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector<CfgProdConfMessage> {
12
- private _sendVersions;
13
- constructor(manager: CfgObservableStateManager, _sendVersions?: CfgProdConfMessageVersions, includeInSend?: CfgProdConfParts);
14
- protected makeSendData(conf: DtoProductConf, initial: boolean): CfgProdConfMessage;
15
- }
1
+ import { DtoProductConf } from "../CatalogueAPI.js";
2
+ import { CfgProdConfParts } from "../utilitiesConfiguration.js";
3
+ import { CfgIOProdConfConnector, CfgProdConfMessage, CfgProdConfMessageVersions } from "./CfgIOProdConfConnector.js";
4
+ import { CfgObservableStateManager } from "./CfgObservableStateManager.js";
5
+ /**
6
+ * Instantiating this will make the observable state update with the product configuration.
7
+ * @param sendVersions What versions of the productConfiguration shall be sent? Multiple can be selected
8
+ * @param includeExtendedDataInSend Only for version 2.0. Includes unit and groupCode.
9
+ * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
10
+ */
11
+ export declare class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector<CfgProdConfMessage> {
12
+ private _sendVersions;
13
+ constructor(manager: CfgObservableStateManager, _sendVersions?: CfgProdConfMessageVersions, includeInSend?: CfgProdConfParts);
14
+ protected makeSendData(conf: DtoProductConf, initial: boolean): CfgProdConfMessage;
15
+ }
16
16
  //# sourceMappingURL=CfgObservableStateToProdConfConnector.d.ts.map
@@ -1,17 +1,17 @@
1
- import { CfgProdConfParts } from "../utilitiesConfiguration.js";
2
- import { CfgIOProdConfConnector, CfgProdConfMessageVersions, } from "./CfgIOProdConfConnector.js";
3
- /**
4
- * Instantiating this will make the observable state update with the product configuration.
5
- * @param sendVersions What versions of the productConfiguration shall be sent? Multiple can be selected
6
- * @param includeExtendedDataInSend Only for version 2.0. Includes unit and groupCode.
7
- * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
8
- */
9
- export class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector {
10
- constructor(manager, _sendVersions = CfgProdConfMessageVersions.V2dot0, includeInSend = CfgProdConfParts.NoExtra) {
11
- super(manager, includeInSend);
12
- this._sendVersions = _sendVersions;
13
- }
14
- makeSendData(conf, initial) {
15
- return CfgIOProdConfConnector.makeMessage(conf, initial, this._sendVersions);
16
- }
17
- }
1
+ import { CfgProdConfParts } from "../utilitiesConfiguration.js";
2
+ import { CfgIOProdConfConnector, CfgProdConfMessageVersions, } from "./CfgIOProdConfConnector.js";
3
+ /**
4
+ * Instantiating this will make the observable state update with the product configuration.
5
+ * @param sendVersions What versions of the productConfiguration shall be sent? Multiple can be selected
6
+ * @param includeExtendedDataInSend Only for version 2.0. Includes unit and groupCode.
7
+ * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
8
+ */
9
+ export class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector {
10
+ constructor(manager, _sendVersions = CfgProdConfMessageVersions.V2dot0, includeInSend = CfgProdConfParts.NoExtra) {
11
+ super(manager, includeInSend);
12
+ this._sendVersions = _sendVersions;
13
+ }
14
+ makeSendData(conf, initial) {
15
+ return CfgIOProdConfConnector.makeMessage(conf, initial, this._sendVersions);
16
+ }
17
+ }
@@ -1,22 +1,22 @@
1
- import { CfgIOManager, IOManagerListener } from "./CfgIOManager.js";
2
- /**
3
- * Base class for classes handling input and output in globally shared environments, using
4
- * event listeners on the window object, for example the History API and window.message API.
5
- * These are global resources where data not being handled by Stage can appear.
6
- */
7
- export declare abstract class CfgWindowEventManager<K extends keyof WindowEventMap, S> extends CfgIOManager<S> {
8
- /**
9
- * Listen for the message messageKey being received. This can for example be the history stack
10
- * being popped or a window.message being received.
11
- */
12
- listenForMessage(l: IOManagerListener, messageKey: string): boolean;
13
- /**
14
- * Removes the listener
15
- */
16
- stopListenForMessage(l: IOManagerListener): boolean;
17
- private _windowEventListenerBound;
18
- private _windowEventListener;
19
- protected abstract readonly eventType: K;
20
- protected abstract getDataFromEvent(event: WindowEventMap[K]): unknown;
21
- }
1
+ import { CfgIOManager, IOManagerListener } from "./CfgIOManager.js";
2
+ /**
3
+ * Base class for classes handling input and output in globally shared environments, using
4
+ * event listeners on the window object, for example the History API and window.message API.
5
+ * These are global resources where data not being handled by Stage can appear.
6
+ */
7
+ export declare abstract class CfgWindowEventManager<K extends keyof WindowEventMap, S> extends CfgIOManager<S> {
8
+ /**
9
+ * Listen for the message messageKey being received. This can for example be the history stack
10
+ * being popped or a window.message being received.
11
+ */
12
+ listenForMessage(l: IOManagerListener, messageKey: string): boolean;
13
+ /**
14
+ * Removes the listener
15
+ */
16
+ stopListenForMessage(l: IOManagerListener): boolean;
17
+ private _windowEventListenerBound;
18
+ private _windowEventListener;
19
+ protected abstract readonly eventType: K;
20
+ protected abstract getDataFromEvent(event: WindowEventMap[K]): unknown;
21
+ }
22
22
  //# sourceMappingURL=CfgWindowEventManager.d.ts.map