@configura/web-api 3.0.0-alpha.1 → 3.0.0-alpha.3
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.
- package/dist/CatalogueAPI.d.ts +68 -1
- package/dist/CatalogueAPI.js +184 -219
- package/dist/CfgMeasure.js +1 -2
- package/dist/CfgProduct.d.ts +22 -3
- package/dist/CfgProduct.js +172 -162
- package/dist/io/CfgIOManager.js +2 -11
- package/dist/io/CfgIOProdConfConnector.js +14 -25
- package/dist/io/CfgObservableStateManager.js +1 -1
- package/dist/productConfiguration/CfgFeature.d.ts +5 -0
- package/dist/productConfiguration/CfgFeature.js +68 -53
- package/dist/productConfiguration/CfgOption.d.ts +8 -0
- package/dist/productConfiguration/CfgOption.js +68 -73
- package/dist/productConfiguration/CfgProductConfiguration.js +22 -34
- package/dist/productConfiguration/productParamsGenerator.js +43 -57
- package/dist/productLoader.js +2 -13
- package/dist/syncGroups/SyncGroupsHandler.js +60 -83
- package/dist/syncGroups/SyncGroupsPathHelper.js +5 -5
- package/dist/syncGroups/SyncGroupsState.js +4 -5
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +19 -1
- package/dist/syncGroups/SyncGroupsTransaction.js +352 -303
- package/dist/tasks/TaskHandler.js +53 -64
- package/dist/tests/testData/dummyProductForTest.js +4 -1
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +18 -21
- package/dist/tests/testData/testDataCachedGetProduct.js +20 -20
- package/dist/tests/testData/testDataCachedPostValidate.js +6 -15
- package/dist/tests/testData/testDataProductAggregatedPrice.js +21 -21
- package/dist/tests/testData/testDataUpcharge.js +31 -22
- package/dist/utilitiesCatalogueData.js +21 -9
- package/dist/utilitiesCataloguePermission.js +5 -2
- package/dist/utilitiesConfiguration.js +21 -23
- 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: (
|
|
28
|
+
selOptions: (conf.features ?? []).map((f) => ({
|
|
30
29
|
code: "!~!",
|
|
31
30
|
next: convertDtoFeatureConfToApiSelection(f, silenceWarnings),
|
|
32
31
|
})),
|
|
33
|
-
additionalProducts: (
|
|
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
|
|
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
|
|
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
|
|
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) =>
|
|
141
|
-
const expandDtoProductConfJsonKeys = (data) => data.replace(jsonKeyRegex, (_, 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:
|
|
168
|
-
additionalProducts:
|
|
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) => (
|
|
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:
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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.
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
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.
|
|
26
|
+
"@configura/web-utilities": "3.0.0-alpha.3"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "4332ed866e78584bfa40bf2d6a3258108dc4093c"
|
|
29
29
|
}
|