@configura/web-api 2.0.0-alpha.20 → 2.0.0-alpha.21

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 +597 -581
  5. package/dist/CatalogueAPI.js +328 -328
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +328 -330
  9. package/dist/CfgProduct.js +934 -879
  10. package/dist/CfgReferencePathHelper.d.ts +26 -26
  11. package/dist/CfgReferencePathHelper.js +26 -26
  12. package/dist/ConfigurationConverter.d.ts +17 -13
  13. package/dist/ConfigurationConverter.js +175 -166
  14. package/dist/index.d.ts +23 -23
  15. package/dist/index.js +23 -23
  16. package/dist/io/CfgHistoryManager.d.ts +83 -83
  17. package/dist/io/CfgHistoryManager.js +144 -150
  18. package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -17
  19. package/dist/io/CfgHistoryToProdConfConnector.js +50 -47
  20. package/dist/io/CfgIOManager.d.ts +53 -53
  21. package/dist/io/CfgIOManager.js +134 -134
  22. package/dist/io/CfgIOProdConfConnector.d.ts +64 -56
  23. package/dist/io/CfgIOProdConfConnector.js +149 -158
  24. package/dist/io/CfgIOWarningSupplier.d.ts +3 -3
  25. package/dist/io/CfgIOWarningSupplier.js +1 -1
  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 -14
  29. package/dist/io/CfgObservableStateToProdConfConnector.js +16 -16
  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 -91
  34. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +16 -16
  35. package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -18
  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 +189 -189
  49. package/dist/productConfiguration/CfgFeature.js +658 -658
  50. package/dist/productConfiguration/CfgOption.d.ts +151 -151
  51. package/dist/productConfiguration/CfgOption.js +422 -422
  52. package/dist/productConfiguration/CfgProductConfiguration.d.ts +129 -129
  53. package/dist/productConfiguration/CfgProductConfiguration.js +340 -340
  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 -87
  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 -43
  65. package/dist/syncGroups/SyncGroupsHandler.js +370 -363
  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 -589
  72. package/dist/tasks/TaskHandler.d.ts +77 -77
  73. package/dist/tasks/TaskHandler.js +276 -276
  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 -278
  82. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  83. package/dist/tests/testData/testDataCachedGetProduct.js +187 -186
  84. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  85. package/dist/tests/testData/testDataCachedPostValidate.js +185 -184
  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 -188
  92. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  93. package/dist/tests/testData/testDataUpcharge.js +121 -120
  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/utilitiesNumericValues.d.ts +24 -24
  99. package/dist/utilitiesNumericValues.js +114 -109
  100. package/package.json +3 -3
@@ -1,158 +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 { 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
- 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, _includeExtendedDataInSend, // Only for v2.0
28
- _includeProdParamsInSend // Only for v2.0
29
- ) {
30
- this._ioManager = _ioManager;
31
- this._includeExtendedDataInSend = _includeExtendedDataInSend;
32
- this._includeProdParamsInSend = _includeProdParamsInSend;
33
- this._stopListenToMessage = undefined;
34
- this._stopListenToProdConf = undefined;
35
- this.setProduct = (product) => __awaiter(this, void 0, void 0, function* () {
36
- var _a, _b;
37
- const currentProduct = this._product;
38
- const newProduct = product;
39
- this._product = newProduct;
40
- // If same product don't do anything at all
41
- if (currentProduct !== undefined &&
42
- newProduct !== undefined &&
43
- currentProduct.isBackedBySame(newProduct)) {
44
- return;
45
- }
46
- if (currentProduct !== undefined) {
47
- (_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
48
- (_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
49
- }
50
- if (newProduct === undefined) {
51
- return;
52
- }
53
- // We only try to load initial configuration at first load
54
- if (currentProduct === undefined) {
55
- try {
56
- const initialProdConf = this.getInitialProdConf();
57
- if (initialProdConf !== undefined) {
58
- yield newProduct.setDtoConf(initialProdConf);
59
- }
60
- }
61
- catch (err) {
62
- console.error(err);
63
- }
64
- }
65
- this._send(this.makeSendData(newProduct.getDtoConf(this._includeExtendedDataInSend, this._includeProdParamsInSend), true));
66
- this._stopListenToMessage = CfgIOProdConfConnector.listenForMessage((messages) => __awaiter(this, void 0, void 0, function* () {
67
- const subMessages = messages.subMessages;
68
- if (subMessages.length === 0) {
69
- console.warn(`${STAGE_PROD_CONF_MESSAGE_KEY} message without any submessages. Unexpected.`);
70
- return;
71
- }
72
- const highestVersionMessage = getHighestVersionProdConfMessage(subMessages);
73
- if (isCfgProdConfMessageV1(highestVersionMessage)) {
74
- yield newProduct.setApiSelection(highestVersionMessage.conf);
75
- return;
76
- }
77
- if (isCfgProdConfMessageV2(highestVersionMessage)) {
78
- yield newProduct.setDtoConf(highestVersionMessage.conf);
79
- return;
80
- }
81
- throw new Error("Unknown message version");
82
- }), this._ioManager);
83
- this._stopListenToProdConf = CfgIOProdConfConnector.listenForProdConf(newProduct, (conf) => __awaiter(this, void 0, void 0, function* () { return this._send(this.makeSendData(conf, false)); }), this._includeExtendedDataInSend, this._includeProdParamsInSend);
84
- });
85
- this._send = (data) => this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, data);
86
- _ioManager.addWarningSupplier(this);
87
- }
88
- destroy() {
89
- var _a, _b;
90
- (_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
91
- (_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
92
- this._ioManager.removeWarningSupplier(this);
93
- }
94
- getWarnings() {
95
- const product = this._product;
96
- if (product !== undefined && product.hasRootFeaturesChanged) {
97
- return [
98
- "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.",
99
- ];
100
- }
101
- return [];
102
- }
103
- getInitialProdConf() {
104
- return undefined;
105
- }
106
- static makeMessage(conf, initial, sendVersions) {
107
- const result = [];
108
- if ((sendVersions & CfgProdConfMessageVersions.V1dot0) ===
109
- CfgProdConfMessageVersions.V1dot0) {
110
- const v1 = {
111
- version: "1.0",
112
- conf: convertDtoProductConfToV1(conf, true),
113
- };
114
- result.push(v1);
115
- }
116
- if ((sendVersions & CfgProdConfMessageVersions.V2dot0) ===
117
- CfgProdConfMessageVersions.V2dot0) {
118
- const v2 = {
119
- version: "2.0",
120
- conf,
121
- };
122
- result.push(v2);
123
- }
124
- return { subMessages: result, initial };
125
- }
126
- static makeMessageListener(callback) {
127
- return (message) => __awaiter(this, void 0, void 0, function* () {
128
- const prodConfMessage = message;
129
- yield callback(prodConfMessage);
130
- });
131
- }
132
- /**
133
- * Register the callback to listen for Product Configuration messages
134
- * @returns A function which when called will cancel listening
135
- */
136
- static listenForMessage(callback, ioManager) {
137
- const listener = this.makeMessageListener(callback);
138
- ioManager.listenForMessage(listener, STAGE_PROD_CONF_MESSAGE_KEY);
139
- return () => {
140
- ioManager.stopListenForMessage(listener);
141
- };
142
- }
143
- static makeProdConfListener(callback, includeExtendedDataInSend, includeProdParamsInSend) {
144
- return (n) => {
145
- if (!n.committed) {
146
- return;
147
- }
148
- callback(n.freshRef.getDtoConf(includeExtendedDataInSend, includeProdParamsInSend));
149
- };
150
- }
151
- static listenForProdConf(product, callback, includeExtendedDataInSend, includeProdParamsInSend) {
152
- const listener = this.makeProdConfListener(callback, includeExtendedDataInSend, includeProdParamsInSend);
153
- product.listenForChange(listener);
154
- return () => {
155
- product.stopListenForChange(listener);
156
- };
157
- }
158
- }
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,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,15 @@
1
- import { DtoProductConf } 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 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, includeExtendedDataInSend?: boolean, includeProdParamsInSend?: boolean);
13
- protected makeSendData(conf: DtoProductConf, initial: boolean): CfgProdConfMessage;
14
- }
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
+ }
15
15
  //# sourceMappingURL=CfgObservableStateToProdConfConnector.d.ts.map
@@ -1,16 +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 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, includeExtendedDataInSend = false, includeProdParamsInSend = false) {
10
- super(manager, includeExtendedDataInSend, includeProdParamsInSend);
11
- this._sendVersions = _sendVersions;
12
- }
13
- makeSendData(conf, initial) {
14
- return CfgIOProdConfConnector.makeMessage(conf, initial, this._sendVersions);
15
- }
16
- }
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