@configura/web-api 2.0.0 → 2.1.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 (100) 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 +622 -622
  5. package/dist/CatalogueAPI.js +329 -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 +990 -991
  10. package/dist/CfgReferencePathHelper.d.ts +26 -26
  11. package/dist/CfgReferencePathHelper.js +26 -26
  12. package/dist/index.d.ts +23 -23
  13. package/dist/index.js +23 -23
  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 -64
  21. package/dist/io/CfgIOProdConfConnector.js +137 -149
  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 -14
  27. package/dist/io/CfgObservableStateToProdConfConnector.js +17 -16
  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 -16
  33. package/dist/io/CfgWindowMessageToProdConfConnector.js +19 -18
  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 +192 -192
  47. package/dist/productConfiguration/CfgFeature.js +664 -663
  48. package/dist/productConfiguration/CfgOption.d.ts +157 -157
  49. package/dist/productConfiguration/CfgOption.js +444 -444
  50. package/dist/productConfiguration/CfgProductConfiguration.d.ts +128 -128
  51. package/dist/productConfiguration/CfgProductConfiguration.js +331 -331
  52. package/dist/productConfiguration/filters.d.ts +17 -15
  53. package/dist/productConfiguration/filters.js +141 -70
  54. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  55. package/dist/productConfiguration/productParamsGenerator.js +51 -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/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  85. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
  86. package/dist/tests/testData/testDataOptions.d.ts +12 -12
  87. package/dist/tests/testData/testDataOptions.js +60 -60
  88. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
  89. package/dist/tests/testData/testDataProductAggregatedPrice.js +189 -189
  90. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  91. package/dist/tests/testData/testDataUpcharge.js +121 -121
  92. package/dist/utilitiesCatalogueData.d.ts +47 -47
  93. package/dist/utilitiesCatalogueData.js +180 -180
  94. package/dist/utilitiesCataloguePermission.d.ts +38 -38
  95. package/dist/utilitiesCataloguePermission.js +79 -79
  96. package/dist/{ConfigurationConverter.d.ts → utilitiesConfiguration.d.ts} +29 -18
  97. package/dist/{ConfigurationConverter.js → utilitiesConfiguration.js} +200 -175
  98. package/dist/utilitiesNumericValues.d.ts +24 -24
  99. package/dist/utilitiesNumericValues.js +114 -114
  100. package/package.json +3 -3
@@ -1,149 +1,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
- 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
- };
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,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,15 +1,16 @@
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
- }
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
+ }
15
16
  //# sourceMappingURL=CfgObservableStateToProdConfConnector.d.ts.map
@@ -1,16 +1,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
+ 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