@configura/web-api 2.0.0-alpha.8 → 2.0.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 (100) hide show
  1. package/.eslintrc.json +5 -18
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/CatalogueAPI.d.ts +622 -551
  5. package/dist/CatalogueAPI.js +329 -273
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +344 -268
  9. package/dist/CfgProduct.js +991 -780
  10. package/dist/CfgReferencePathHelper.d.ts +26 -13
  11. package/dist/CfgReferencePathHelper.js +26 -13
  12. package/dist/ConfigurationConverter.d.ts +17 -4
  13. package/dist/ConfigurationConverter.js +175 -72
  14. package/dist/index.d.ts +23 -23
  15. package/dist/index.js +23 -23
  16. package/dist/io/CfgHistoryManager.d.ts +83 -51
  17. package/dist/io/CfgHistoryManager.js +144 -82
  18. package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -20
  19. package/dist/io/CfgHistoryToProdConfConnector.js +50 -56
  20. package/dist/io/CfgIOManager.d.ts +53 -48
  21. package/dist/io/CfgIOManager.js +134 -115
  22. package/dist/io/CfgIOProdConfConnector.d.ts +64 -55
  23. package/dist/io/CfgIOProdConfConnector.js +149 -143
  24. package/dist/io/CfgIOWarningSupplier.d.ts +4 -0
  25. package/dist/io/CfgIOWarningSupplier.js +1 -0
  26. package/dist/io/CfgObservableStateManager.d.ts +25 -25
  27. package/dist/io/CfgObservableStateManager.js +69 -69
  28. package/dist/io/CfgObservableStateToProdConfConnector.d.ts +14 -15
  29. package/dist/io/CfgObservableStateToProdConfConnector.js +16 -17
  30. package/dist/io/CfgWindowEventManager.d.ts +21 -21
  31. package/dist/io/CfgWindowEventManager.js +38 -38
  32. package/dist/io/CfgWindowMessageManager.d.ts +40 -40
  33. package/dist/io/CfgWindowMessageManager.js +91 -87
  34. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +16 -17
  35. package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -19
  36. package/dist/io/index.d.ts +8 -8
  37. package/dist/io/index.js +8 -8
  38. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  39. package/dist/material/CfgMaterialMapping.js +181 -181
  40. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  41. package/dist/material/CfgMtrlApplication.js +43 -43
  42. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  43. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  44. package/dist/material/CfgMtrlSource.d.ts +19 -19
  45. package/dist/material/CfgMtrlSource.js +40 -40
  46. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  47. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  48. package/dist/productConfiguration/CfgFeature.d.ts +192 -187
  49. package/dist/productConfiguration/CfgFeature.js +663 -645
  50. package/dist/productConfiguration/CfgOption.d.ts +157 -151
  51. package/dist/productConfiguration/CfgOption.js +444 -416
  52. package/dist/productConfiguration/CfgProductConfiguration.d.ts +128 -117
  53. package/dist/productConfiguration/CfgProductConfiguration.js +331 -307
  54. package/dist/productConfiguration/filters.d.ts +15 -15
  55. package/dist/productConfiguration/filters.js +70 -70
  56. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  57. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  58. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
  59. package/dist/productConfiguration/utilitiesProductConfiguration.js +87 -80
  60. package/dist/productLoader.d.ts +33 -33
  61. package/dist/productLoader.js +49 -49
  62. package/dist/syncGroups/SyncGroupsApplyMode.d.ts +20 -20
  63. package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
  64. package/dist/syncGroups/SyncGroupsHandler.d.ts +47 -40
  65. package/dist/syncGroups/SyncGroupsHandler.js +370 -359
  66. package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
  67. package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
  68. package/dist/syncGroups/SyncGroupsState.d.ts +39 -35
  69. package/dist/syncGroups/SyncGroupsState.js +167 -125
  70. package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
  71. package/dist/syncGroups/SyncGroupsTransaction.js +589 -576
  72. package/dist/tasks/TaskHandler.d.ts +77 -77
  73. package/dist/tasks/TaskHandler.js +276 -275
  74. package/dist/tasks/formats.d.ts +4 -4
  75. package/dist/tasks/formats.js +7 -7
  76. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  77. package/dist/tests/testData/collectorForTest.js +194 -194
  78. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  79. package/dist/tests/testData/dummyProductForTest.js +32 -32
  80. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
  81. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +282 -277
  82. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  83. package/dist/tests/testData/testDataCachedGetProduct.js +187 -185
  84. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  85. package/dist/tests/testData/testDataCachedPostValidate.js +185 -183
  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 -187
  92. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  93. package/dist/tests/testData/testDataUpcharge.js +121 -119
  94. package/dist/utilitiesCatalogueData.d.ts +47 -42
  95. package/dist/utilitiesCatalogueData.js +180 -173
  96. package/dist/utilitiesCataloguePermission.d.ts +38 -38
  97. package/dist/utilitiesCataloguePermission.js +79 -79
  98. package/dist/utilitiesNumericValues.d.ts +24 -24
  99. package/dist/utilitiesNumericValues.js +114 -109
  100. package/package.json +3 -3
@@ -1,143 +1,149 @@
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 { convertDtoConfProdToV1 } from "../ConfigurationConverter.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, _doValidate, _includeExtendedDataInSend, // Only v2.0
28
- _includeProdParamsInSend // Only v2.0
29
- ) {
30
- this._ioManager = _ioManager;
31
- this._doValidate = _doValidate;
32
- this._includeExtendedDataInSend = _includeExtendedDataInSend;
33
- this._includeProdParamsInSend = _includeProdParamsInSend;
34
- this._stopListenToMessage = undefined;
35
- this._stopListenToProdConf = undefined;
36
- this.destroy = () => {
37
- var _a, _b;
38
- (_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
39
- (_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
40
- };
41
- this.setProduct = (product) => __awaiter(this, void 0, void 0, function* () {
42
- var _a, _b;
43
- const currentProduct = this._product;
44
- const newProduct = product;
45
- this._product = newProduct;
46
- // If same product don't do anything at all
47
- if (currentProduct !== undefined &&
48
- newProduct !== undefined &&
49
- currentProduct.isBackedBySame(newProduct)) {
50
- return;
51
- }
52
- if (currentProduct !== undefined) {
53
- (_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
54
- (_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
55
- }
56
- if (newProduct === undefined) {
57
- return;
58
- }
59
- // We only try to load initial configuration at first load
60
- if (currentProduct === undefined) {
61
- const initialProdConf = this.getInitialProdConf();
62
- if (initialProdConf !== undefined) {
63
- yield newProduct.setDtoConf(initialProdConf, this._doValidate);
64
- }
65
- }
66
- this._send(this.makeSendData(newProduct.getDtoConf(this._includeExtendedDataInSend, this._includeProdParamsInSend), true));
67
- this._stopListenToMessage = CfgIOProdConfConnector.listenForMessage((messages) => __awaiter(this, void 0, void 0, function* () {
68
- const subMessages = messages.subMessages;
69
- if (subMessages.length === 0) {
70
- console.warn(`${STAGE_PROD_CONF_MESSAGE_KEY} message without any submessages. Unexpected.`);
71
- return;
72
- }
73
- const highestVersionMessage = getHighestVersionProdConfMessage(subMessages);
74
- if (isCfgProdConfMessageV1(highestVersionMessage)) {
75
- yield newProduct.setApiSelection(highestVersionMessage.conf, this._doValidate);
76
- return;
77
- }
78
- if (isCfgProdConfMessageV2(highestVersionMessage)) {
79
- yield newProduct.setDtoConf(highestVersionMessage.conf, this._doValidate);
80
- return;
81
- }
82
- throw new Error("Unknown message version");
83
- }), this._ioManager);
84
- this._stopListenToProdConf = CfgIOProdConfConnector.listenForProdConf(newProduct, (conf) => __awaiter(this, void 0, void 0, function* () { return this._send(this.makeSendData(conf, false)); }), this._includeExtendedDataInSend, this._includeProdParamsInSend);
85
- });
86
- this._send = (data) => this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, data);
87
- }
88
- getInitialProdConf() {
89
- return undefined;
90
- }
91
- static makeMessage(conf, initial, sendVersions) {
92
- const result = [];
93
- if ((sendVersions & CfgProdConfMessageVersions.V1dot0) ===
94
- CfgProdConfMessageVersions.V1dot0) {
95
- const v1 = {
96
- version: "1.0",
97
- conf: convertDtoConfProdToV1(conf, true),
98
- };
99
- result.push(v1);
100
- }
101
- if ((sendVersions & CfgProdConfMessageVersions.V2dot0) ===
102
- CfgProdConfMessageVersions.V2dot0) {
103
- const v2 = {
104
- version: "2.0",
105
- conf,
106
- };
107
- result.push(v2);
108
- }
109
- return { subMessages: result, initial };
110
- }
111
- static makeMessageListener(callback) {
112
- return (message) => __awaiter(this, void 0, void 0, function* () {
113
- const prodConfMessage = message;
114
- yield callback(prodConfMessage);
115
- });
116
- }
117
- /**
118
- * Register the callback to listen for Product Configuration messages
119
- * @returns A function which when called will cancel listening
120
- */
121
- static listenForMessage(callback, ioManager) {
122
- const listener = this.makeMessageListener(callback);
123
- ioManager.listenForMessage(listener, STAGE_PROD_CONF_MESSAGE_KEY);
124
- return () => {
125
- ioManager.stopListenForMessage(listener);
126
- };
127
- }
128
- static makeProdConfListener(callback, includeExtendedDataInSend, includeProdParamsInSend) {
129
- return (n) => {
130
- if (!n.committed) {
131
- return;
132
- }
133
- callback(n.freshRef.getDtoConf(includeExtendedDataInSend, includeProdParamsInSend));
134
- };
135
- }
136
- static listenForProdConf(product, callback, includeExtendedDataInSend, includeProdParamsInSend) {
137
- const listener = this.makeProdConfListener(callback, includeExtendedDataInSend, includeProdParamsInSend);
138
- product.listenForChange(listener);
139
- return () => {
140
- product.stopListenForChange(listener);
141
- };
142
- }
143
- }
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 "../ConfigurationConverter.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
+ /**
23
+ * @param ExtendedData Includes extra data, i.e. units and groupCodes
24
+ * @param ProductParams Includes what Product this was generated for, and the same for any Additional Products.
25
+ * @param SyncGroupState Includes the current sync group state
26
+ */
27
+ export var CfgProdConfParts;
28
+ (function (CfgProdConfParts) {
29
+ CfgProdConfParts[CfgProdConfParts["NoExtra"] = 0] = "NoExtra";
30
+ CfgProdConfParts[CfgProdConfParts["ExtendedData"] = 1] = "ExtendedData";
31
+ CfgProdConfParts[CfgProdConfParts["ProdParams"] = 2] = "ProdParams";
32
+ CfgProdConfParts[CfgProdConfParts["SyncGroupState"] = 4] = "SyncGroupState";
33
+ })(CfgProdConfParts || (CfgProdConfParts = {}));
34
+ export const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
35
+ /**
36
+ * Base class for connecting the product configuration to an IO channel
37
+ */
38
+ export class CfgIOProdConfConnector {
39
+ constructor(_ioManager, _includeInSend // Only for v2.0
40
+ ) {
41
+ this._ioManager = _ioManager;
42
+ this._includeInSend = _includeInSend;
43
+ this._stopListenToMessage = undefined;
44
+ this._stopListenToProdConf = undefined;
45
+ this.setProduct = (product) => __awaiter(this, void 0, void 0, function* () {
46
+ var _a, _b;
47
+ const currentProduct = this._product;
48
+ const newProduct = product;
49
+ this._product = newProduct;
50
+ // If same product don't do anything at all
51
+ if (currentProduct !== undefined &&
52
+ newProduct !== undefined &&
53
+ currentProduct.isBackedBySame(newProduct)) {
54
+ return;
55
+ }
56
+ if (currentProduct !== undefined) {
57
+ (_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
58
+ (_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
59
+ }
60
+ if (newProduct === undefined) {
61
+ return;
62
+ }
63
+ this._send(this.makeSendData(newProduct.getDtoConf(this._includeInSend), true));
64
+ this._stopListenToMessage = CfgIOProdConfConnector.listenForMessage((messages) => __awaiter(this, void 0, void 0, function* () {
65
+ const subMessages = messages.subMessages;
66
+ if (subMessages.length === 0) {
67
+ console.warn(`${STAGE_PROD_CONF_MESSAGE_KEY} message without any submessages. Unexpected.`);
68
+ return;
69
+ }
70
+ const highestVersionMessage = getHighestVersionProdConfMessage(subMessages);
71
+ if (isCfgProdConfMessageV1(highestVersionMessage)) {
72
+ yield newProduct.setApiSelection(highestVersionMessage.conf);
73
+ return;
74
+ }
75
+ if (isCfgProdConfMessageV2(highestVersionMessage)) {
76
+ yield newProduct.setDtoConf(highestVersionMessage.conf);
77
+ return;
78
+ }
79
+ throw new Error("Unknown message version");
80
+ }), this._ioManager);
81
+ this._stopListenToProdConf = CfgIOProdConfConnector.listenForProdConf(newProduct, (conf) => __awaiter(this, void 0, void 0, function* () { return this._send(this.makeSendData(conf, false)); }), this._includeInSend);
82
+ });
83
+ this._send = (data) => this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, data);
84
+ _ioManager.addWarningSupplier(this);
85
+ }
86
+ destroy() {
87
+ var _a, _b;
88
+ (_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
89
+ (_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
90
+ this._ioManager.removeWarningSupplier(this);
91
+ }
92
+ getWarnings() {
93
+ const product = this._product;
94
+ if (product !== undefined && product.hasRootFeaturesChanged) {
95
+ return [
96
+ "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.",
97
+ ];
98
+ }
99
+ return [];
100
+ }
101
+ /**
102
+ * Register the callback to listen for Product Configuration messages
103
+ * @returns A function which when called will cancel listening
104
+ */
105
+ static listenForMessage(callback, ioManager) {
106
+ const listener = this.makeMessageListener(callback);
107
+ ioManager.listenForMessage(listener, STAGE_PROD_CONF_MESSAGE_KEY);
108
+ return () => {
109
+ ioManager.stopListenForMessage(listener);
110
+ };
111
+ }
112
+ static listenForProdConf(product, callback, includeInSend) {
113
+ const listener = this.makeProdConfListener(callback, includeInSend);
114
+ product.listenForChange(listener);
115
+ return () => {
116
+ product.stopListenForChange(listener);
117
+ };
118
+ }
119
+ }
120
+ CfgIOProdConfConnector.makeMessage = (conf, initial, sendVersions) => {
121
+ const result = [];
122
+ if ((sendVersions & CfgProdConfMessageVersions.V1dot0) ===
123
+ CfgProdConfMessageVersions.V1dot0) {
124
+ const v1 = {
125
+ version: "1.0",
126
+ conf: convertDtoProductConfToV1(conf, true),
127
+ };
128
+ result.push(v1);
129
+ }
130
+ if ((sendVersions & CfgProdConfMessageVersions.V2dot0) ===
131
+ CfgProdConfMessageVersions.V2dot0) {
132
+ const v2 = {
133
+ version: "2.0",
134
+ conf,
135
+ };
136
+ result.push(v2);
137
+ }
138
+ return { subMessages: result, initial };
139
+ };
140
+ CfgIOProdConfConnector.makeMessageListener = (callback) => (message) => __awaiter(void 0, void 0, void 0, function* () {
141
+ const prodConfMessage = message;
142
+ yield callback(prodConfMessage);
143
+ });
144
+ CfgIOProdConfConnector.makeProdConfListener = (callback, includeInSend) => (n) => {
145
+ if (!n.committed) {
146
+ return;
147
+ }
148
+ callback(n.freshRef.getDtoConf(includeInSend));
149
+ };
@@ -0,0 +1,4 @@
1
+ export interface CfgIOWarningSupplier {
2
+ getWarnings(): string[];
3
+ }
4
+ //# sourceMappingURL=CfgIOWarningSupplier.d.ts.map
@@ -0,0 +1 @@
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,15 @@
1
- import { DtoProductConfiguration } from "../CatalogueAPI.js";
2
- import { CfgIOProdConfConnector, CfgProdConfMessage, CfgProdConfMessageVersions } from "./CfgIOProdConfConnector.js";
3
- import { CfgObservableStateManager } from "./CfgObservableStateManager.js";
4
- /**
5
- * Instantiating this will make the observable state update with the product configuration.
6
- * @param doValidate Run server side product validation for incoming
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, doValidate?: boolean, _sendVersions?: CfgProdConfMessageVersions, includeExtendedDataInSend?: boolean, includeProdParamsInSend?: boolean);
14
- protected makeSendData(conf: DtoProductConfiguration, initial: boolean): CfgProdConfMessage;
15
- }
1
+ import { DtoProductConf } from "../CatalogueAPI.js";
2
+ import { CfgIOProdConfConnector, CfgProdConfMessage, CfgProdConfMessageVersions, CfgProdConfParts } from "./CfgIOProdConfConnector.js";
3
+ import { CfgObservableStateManager } from "./CfgObservableStateManager.js";
4
+ /**
5
+ * Instantiating this will make the observable state update with the product configuration.
6
+ * @param sendVersions What versions of the productConfiguration shall be sent? Multiple can be selected
7
+ * @param includeExtendedDataInSend Only for version 2.0. Includes unit and groupCode.
8
+ * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
9
+ */
10
+ export declare class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector<CfgProdConfMessage> {
11
+ private _sendVersions;
12
+ constructor(manager: CfgObservableStateManager, _sendVersions?: CfgProdConfMessageVersions, includeInSend?: CfgProdConfParts);
13
+ protected makeSendData(conf: DtoProductConf, initial: boolean): CfgProdConfMessage;
14
+ }
16
15
  //# sourceMappingURL=CfgObservableStateToProdConfConnector.d.ts.map
@@ -1,17 +1,16 @@
1
- import { CfgIOProdConfConnector, CfgProdConfMessageVersions, } from "./CfgIOProdConfConnector.js";
2
- /**
3
- * Instantiating this will make the observable state update with the product configuration.
4
- * @param doValidate Run server side product validation for incoming
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, doValidate = true, _sendVersions = CfgProdConfMessageVersions.V2dot0, includeExtendedDataInSend = false, includeProdParamsInSend = false) {
11
- super(manager, doValidate, includeExtendedDataInSend, includeProdParamsInSend);
12
- this._sendVersions = _sendVersions;
13
- }
14
- makeSendData(conf, initial) {
15
- return CfgIOProdConfConnector.makeMessage(conf, initial, this._sendVersions);
16
- }
17
- }
1
+ import { CfgIOProdConfConnector, CfgProdConfMessageVersions, CfgProdConfParts, } from "./CfgIOProdConfConnector.js";
2
+ /**
3
+ * Instantiating this will make the observable state update with the product configuration.
4
+ * @param sendVersions What versions of the productConfiguration shall be sent? Multiple can be selected
5
+ * @param includeExtendedDataInSend Only for version 2.0. Includes unit and groupCode.
6
+ * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
7
+ */
8
+ export class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector {
9
+ constructor(manager, _sendVersions = CfgProdConfMessageVersions.V2dot0, includeInSend = CfgProdConfParts.NoExtra) {
10
+ super(manager, includeInSend);
11
+ this._sendVersions = _sendVersions;
12
+ }
13
+ makeSendData(conf, initial) {
14
+ return CfgIOProdConfConnector.makeMessage(conf, initial, this._sendVersions);
15
+ }
16
+ }
@@ -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