@configura/web-api 3.0.0-alpha.0 → 3.0.0-alpha.2

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 (29) hide show
  1. package/dist/CatalogueAPI.d.ts +68 -1
  2. package/dist/CatalogueAPI.js +184 -219
  3. package/dist/CfgMeasure.js +1 -2
  4. package/dist/CfgProduct.js +131 -159
  5. package/dist/io/CfgIOManager.js +2 -11
  6. package/dist/io/CfgIOProdConfConnector.js +14 -25
  7. package/dist/io/CfgObservableStateManager.js +1 -1
  8. package/dist/productConfiguration/CfgFeature.d.ts +5 -0
  9. package/dist/productConfiguration/CfgFeature.js +64 -54
  10. package/dist/productConfiguration/CfgOption.d.ts +44 -0
  11. package/dist/productConfiguration/CfgOption.js +107 -71
  12. package/dist/productConfiguration/CfgProductConfiguration.js +22 -34
  13. package/dist/productConfiguration/productParamsGenerator.js +43 -57
  14. package/dist/productLoader.js +2 -13
  15. package/dist/syncGroups/SyncGroupsHandler.js +60 -83
  16. package/dist/syncGroups/SyncGroupsPathHelper.js +5 -5
  17. package/dist/syncGroups/SyncGroupsState.js +4 -5
  18. package/dist/syncGroups/SyncGroupsTransaction.js +259 -303
  19. package/dist/tasks/TaskHandler.js +53 -64
  20. package/dist/tests/testData/dummyProductForTest.js +4 -1
  21. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +18 -21
  22. package/dist/tests/testData/testDataCachedGetProduct.js +20 -20
  23. package/dist/tests/testData/testDataCachedPostValidate.js +6 -15
  24. package/dist/tests/testData/testDataProductAggregatedPrice.js +21 -21
  25. package/dist/tests/testData/testDataUpcharge.js +31 -22
  26. package/dist/utilitiesCatalogueData.js +21 -9
  27. package/dist/utilitiesCataloguePermission.js +5 -2
  28. package/dist/utilitiesConfiguration.js +21 -23
  29. package/package.json +3 -3
@@ -20,17 +20,16 @@ let hasInformedAboutProdParams = false;
20
20
  let hasInformedAboutGroupCode = false;
21
21
  let hasInformedAboutUnit = false;
22
22
  export const convertDtoProductConfToV1 = (conf, silenceWarnings = false) => {
23
- var _a, _b;
24
23
  if (!silenceWarnings && conf.prodParams !== undefined && !hasInformedAboutProdParams) {
25
24
  hasInformedAboutProdParams = true;
26
25
  console.info("Incoming DtoProductConf contains prodParams. These will be ignored.");
27
26
  }
28
27
  const result = {
29
- selOptions: ((_a = conf.features) !== null && _a !== void 0 ? _a : []).map((f) => ({
28
+ selOptions: (conf.features ?? []).map((f) => ({
30
29
  code: "!~!",
31
30
  next: convertDtoFeatureConfToApiSelection(f, silenceWarnings),
32
31
  })),
33
- additionalProducts: ((_b = conf.additionalProducts) !== null && _b !== void 0 ? _b : []).map((p) => convertDtoProductConfToV1(p, silenceWarnings)),
32
+ additionalProducts: (conf.additionalProducts ?? []).map((p) => convertDtoProductConfToV1(p, silenceWarnings)),
34
33
  selected: true,
35
34
  };
36
35
  if (isDtoProductConfAdditional(conf)) {
@@ -39,7 +38,7 @@ export const convertDtoProductConfToV1 = (conf, silenceWarnings = false) => {
39
38
  }
40
39
  return result;
41
40
  };
42
- export const convertDtoFeatureConfsToSelOptions = (features, silenceWarnings = false) => (features !== null && features !== void 0 ? features : []).map((f) => ({
41
+ export const convertDtoFeatureConfsToSelOptions = (features, silenceWarnings = false) => (features ?? []).map((f) => ({
43
42
  code: "!~!",
44
43
  next: convertDtoFeatureConfToApiSelection(f, silenceWarnings),
45
44
  }));
@@ -54,14 +53,14 @@ const convertDtoFeatureConfToApiSelection = (feature, silenceWarnings) => {
54
53
  console.info("Incoming DtoFeature contains a unit. It will be ignored.");
55
54
  }
56
55
  const result = {};
57
- for (const option of (options !== null && options !== void 0 ? options : []).filter((o) => o.selected)) {
56
+ for (const option of (options ?? []).filter((o) => o.selected)) {
58
57
  result[option.code] = convertDtoOptionConfToSelectedOption(option, silenceWarnings);
59
58
  }
60
59
  return result;
61
60
  };
62
61
  const convertDtoOptionConfToSelectedOption = (option, silenceWarnings) => {
63
62
  const { features, code, numericValue } = option;
64
- const selectionTrees = (features !== null && features !== void 0 ? features : []).map((f) => convertDtoFeatureConfToApiSelection(f, silenceWarnings));
63
+ const selectionTrees = (features ?? []).map((f) => convertDtoFeatureConfToApiSelection(f, silenceWarnings));
65
64
  const mergedSelectionTree = {};
66
65
  let anyItems = false;
67
66
  for (const selectionTree of selectionTrees) {
@@ -137,8 +136,8 @@ const jsonStringSwapCharsForUrl = (data) => data.replace(swapForUrlAdaptedRegex,
137
136
  throw new Error(`Unexpected char "${char}" in swap for URL`);
138
137
  }
139
138
  });
140
- const compactDtoProductConfJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => { var _a; return `"${(_a = longToShort.get(key)) !== null && _a !== void 0 ? _a : key}":`; });
141
- const expandDtoProductConfJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => { var _a; return `"${(_a = shortToLong.get(key)) !== null && _a !== void 0 ? _a : key}":`; });
139
+ const compactDtoProductConfJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => `"${longToShort.get(key) ?? key}":`);
140
+ const expandDtoProductConfJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => `"${shortToLong.get(key) ?? key}":`);
142
141
  /**
143
142
  * Serializes and compacts the configuration into a format especially suited for URLs
144
143
  */
@@ -162,10 +161,9 @@ export const compactStringToDtoProductConf = (versionAndConf) => {
162
161
  return JSON.parse(expandDtoProductConfJsonKeys(jsonStringSwapCharsForUrl(conf)));
163
162
  };
164
163
  export const stripExtendedDataFromDtoProductConf = (conf, toStrip) => {
165
- var _a, _b;
166
164
  const stripped = {
167
- features: (_a = conf.features) === null || _a === void 0 ? void 0 : _a.map((f) => stripExtendedDataFromDtoFeatureConf(f, toStrip)),
168
- additionalProducts: (_b = conf.additionalProducts) === null || _b === void 0 ? void 0 : _b.map(stripExtendedDataFromDtoAdditionalProductConfiguration),
165
+ features: conf.features?.map((f) => stripExtendedDataFromDtoFeatureConf(f, toStrip)),
166
+ additionalProducts: conf.additionalProducts?.map(stripExtendedDataFromDtoAdditionalProductConfiguration),
169
167
  };
170
168
  if ((toStrip & CfgProdConfParts.SyncGroupState) !== CfgProdConfParts.SyncGroupState) {
171
169
  stripped.syncGroupState = conf.syncGroupState;
@@ -175,12 +173,15 @@ export const stripExtendedDataFromDtoProductConf = (conf, toStrip) => {
175
173
  }
176
174
  return stripped;
177
175
  };
178
- const stripExtendedDataFromDtoAdditionalProductConfiguration = (conf, toStrip) => (Object.assign(Object.assign({}, stripExtendedDataFromDtoProductConf(conf, toStrip)), { refKey: conf.refKey, selected: conf.selected }));
176
+ const stripExtendedDataFromDtoAdditionalProductConfiguration = (conf, toStrip) => ({
177
+ ...stripExtendedDataFromDtoProductConf(conf, toStrip),
178
+ refKey: conf.refKey,
179
+ selected: conf.selected,
180
+ });
179
181
  const stripExtendedDataFromDtoFeatureConf = (conf, toStrip) => {
180
- var _a;
181
182
  const stripped = {
182
183
  code: conf.code,
183
- options: (_a = conf.options) === null || _a === void 0 ? void 0 : _a.map((o) => stripExtendedDataFromDtoOptionConf(o, toStrip)),
184
+ options: conf.options?.map((o) => stripExtendedDataFromDtoOptionConf(o, toStrip)),
184
185
  };
185
186
  if ((toStrip & CfgProdConfParts.ExtendedData) !== CfgProdConfParts.ExtendedData) {
186
187
  // Keep in sync with getDtoConf in CfgFeature
@@ -189,12 +190,9 @@ const stripExtendedDataFromDtoFeatureConf = (conf, toStrip) => {
189
190
  }
190
191
  return stripped;
191
192
  };
192
- const stripExtendedDataFromDtoOptionConf = (conf, toStrip) => {
193
- var _a;
194
- return ({
195
- code: conf.code,
196
- selected: conf.selected,
197
- numericValue: conf.numericValue,
198
- features: (_a = conf.features) === null || _a === void 0 ? void 0 : _a.map((f) => stripExtendedDataFromDtoFeatureConf(f, toStrip)),
199
- });
200
- };
193
+ const stripExtendedDataFromDtoOptionConf = (conf, toStrip) => ({
194
+ code: conf.code,
195
+ selected: conf.selected,
196
+ numericValue: conf.numericValue,
197
+ features: conf.features?.map((f) => stripExtendedDataFromDtoFeatureConf(f, toStrip)),
198
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@configura/web-utilities": "3.0.0-alpha.0"
26
+ "@configura/web-utilities": "3.0.0-alpha.2"
27
27
  },
28
- "gitHead": "9fe91599222572a8625a70c03d745f1f2e5eb85b"
28
+ "gitHead": "5b72d2813b949b3ccef8f1864382b9153593962b"
29
29
  }