@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.
- package/.eslintrc.json +5 -5
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +622 -622
- package/dist/CatalogueAPI.js +329 -329
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +344 -344
- package/dist/CfgProduct.js +990 -991
- package/dist/CfgReferencePathHelper.d.ts +26 -26
- package/dist/CfgReferencePathHelper.js +26 -26
- package/dist/index.d.ts +23 -23
- package/dist/index.js +23 -23
- package/dist/io/CfgHistoryManager.d.ts +83 -83
- package/dist/io/CfgHistoryManager.js +144 -144
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -21
- package/dist/io/CfgHistoryToProdConfConnector.js +50 -50
- package/dist/io/CfgIOManager.d.ts +53 -53
- package/dist/io/CfgIOManager.js +134 -134
- package/dist/io/CfgIOProdConfConnector.d.ts +54 -64
- package/dist/io/CfgIOProdConfConnector.js +137 -149
- package/dist/io/CfgIOWarningSupplier.d.ts +3 -3
- package/dist/io/CfgIOWarningSupplier.js +1 -1
- package/dist/io/CfgObservableStateManager.d.ts +25 -25
- package/dist/io/CfgObservableStateManager.js +69 -69
- package/dist/io/CfgObservableStateToProdConfConnector.d.ts +15 -14
- package/dist/io/CfgObservableStateToProdConfConnector.js +17 -16
- package/dist/io/CfgWindowEventManager.d.ts +21 -21
- package/dist/io/CfgWindowEventManager.js +38 -38
- package/dist/io/CfgWindowMessageManager.d.ts +40 -40
- package/dist/io/CfgWindowMessageManager.js +91 -91
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +17 -16
- package/dist/io/CfgWindowMessageToProdConfConnector.js +19 -18
- package/dist/io/index.d.ts +8 -8
- package/dist/io/index.js +8 -8
- package/dist/material/CfgMaterialMapping.d.ts +7 -7
- package/dist/material/CfgMaterialMapping.js +181 -181
- package/dist/material/CfgMtrlApplication.d.ts +18 -18
- package/dist/material/CfgMtrlApplication.js +43 -43
- package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
- package/dist/material/CfgMtrlApplicationSource.js +8 -8
- package/dist/material/CfgMtrlSource.d.ts +19 -19
- package/dist/material/CfgMtrlSource.js +40 -40
- package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
- package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
- package/dist/productConfiguration/CfgFeature.d.ts +192 -192
- package/dist/productConfiguration/CfgFeature.js +664 -663
- package/dist/productConfiguration/CfgOption.d.ts +157 -157
- package/dist/productConfiguration/CfgOption.js +444 -444
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +128 -128
- package/dist/productConfiguration/CfgProductConfiguration.js +331 -331
- package/dist/productConfiguration/filters.d.ts +17 -15
- package/dist/productConfiguration/filters.js +141 -70
- package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
- package/dist/productConfiguration/productParamsGenerator.js +51 -51
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
- package/dist/productConfiguration/utilitiesProductConfiguration.js +87 -87
- package/dist/productLoader.d.ts +33 -33
- package/dist/productLoader.js +49 -49
- package/dist/syncGroups/SyncGroupsApplyMode.d.ts +20 -20
- package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
- package/dist/syncGroups/SyncGroupsHandler.d.ts +47 -47
- package/dist/syncGroups/SyncGroupsHandler.js +370 -370
- package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
- package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
- package/dist/syncGroups/SyncGroupsState.d.ts +39 -39
- package/dist/syncGroups/SyncGroupsState.js +167 -167
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
- package/dist/syncGroups/SyncGroupsTransaction.js +589 -589
- package/dist/tasks/TaskHandler.d.ts +77 -77
- package/dist/tasks/TaskHandler.js +276 -276
- package/dist/tasks/formats.d.ts +4 -4
- package/dist/tasks/formats.js +7 -7
- package/dist/tests/testData/collectorForTest.d.ts +73 -73
- package/dist/tests/testData/collectorForTest.js +194 -194
- package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
- package/dist/tests/testData/dummyProductForTest.js +32 -32
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +282 -282
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +187 -187
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +185 -185
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
- package/dist/tests/testData/testDataOptions.d.ts +12 -12
- package/dist/tests/testData/testDataOptions.js +60 -60
- package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
- package/dist/tests/testData/testDataProductAggregatedPrice.js +189 -189
- package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
- package/dist/tests/testData/testDataUpcharge.js +121 -121
- package/dist/utilitiesCatalogueData.d.ts +47 -47
- package/dist/utilitiesCatalogueData.js +180 -180
- package/dist/utilitiesCataloguePermission.d.ts +38 -38
- package/dist/utilitiesCataloguePermission.js +79 -79
- package/dist/{ConfigurationConverter.d.ts → utilitiesConfiguration.d.ts} +29 -18
- package/dist/{ConfigurationConverter.js → utilitiesConfiguration.js} +200 -175
- package/dist/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +114 -114
- package/package.json +3 -3
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { Filters
|
|
2
|
-
import { DtoCatalogueParams, DtoLevel, DtoProductRef } from "../CatalogueAPI.js";
|
|
3
|
-
export declare function applyCatalogueFilters<T extends DtoCatalogueParams>(filters: Filters<DtoCatalogueParams>, catalogues: T[]): [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @param
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { Filters } from "@configura/web-utilities";
|
|
2
|
+
import { DtoCatalogueParams, DtoLevel, DtoProductRef } from "../CatalogueAPI.js";
|
|
3
|
+
export declare function applyCatalogueFilters<T extends DtoCatalogueParams>(filters: Filters<DtoCatalogueParams>, catalogues: T[]): [{
|
|
4
|
+
[K in keyof DtoCatalogueParams]: string[];
|
|
5
|
+
}, T[]];
|
|
6
|
+
export interface ProductRefParams {
|
|
7
|
+
partNr: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function applyProductRefFilters(filters: Filters<ProductRefParams>, productRefs: DtoProductRef[]): [string[], DtoProductRef[]];
|
|
10
|
+
/**
|
|
11
|
+
* Clones the table of content levels tree.
|
|
12
|
+
* Filters to only include passed products.
|
|
13
|
+
* @param levels The original data
|
|
14
|
+
* @param prdRefsFilter Products not in this array are removed
|
|
15
|
+
* @param showEmpty Shall empty levels be shown?
|
|
16
|
+
*/
|
|
17
|
+
export declare function cloneFilterSortLevels(levels: DtoLevel[], prdRefsFilter: DtoProductRef[], showEmpty: boolean, doSort?: boolean): DtoLevel[] | undefined;
|
|
16
18
|
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -1,70 +1,141 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
import { shuffle } from "@configura/web-utilities";
|
|
2
|
+
function filterAndSort(propertyValuesToT, property, filtersByProperty, availablePropertyValuesByProperty) {
|
|
3
|
+
const availablePropertyValues = availablePropertyValuesByProperty[property];
|
|
4
|
+
for (const key of propertyValuesToT.keys()) {
|
|
5
|
+
availablePropertyValues.add(key);
|
|
6
|
+
}
|
|
7
|
+
let items;
|
|
8
|
+
const filter = filtersByProperty[property];
|
|
9
|
+
if (filter.mode === "exact") {
|
|
10
|
+
const { value: key } = filter;
|
|
11
|
+
if (key !== "-") {
|
|
12
|
+
const item = propertyValuesToT.get(key);
|
|
13
|
+
if (item === undefined) {
|
|
14
|
+
items = [];
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
items = [item];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (items === undefined) {
|
|
22
|
+
if (filter.mode === "random") {
|
|
23
|
+
items = shuffle(Array.from(propertyValuesToT.values()));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
items = Array.from(propertyValuesToT.entries())
|
|
27
|
+
.sort((l, r) => l[0].localeCompare(r[0], undefined, { sensitivity: "base" }))
|
|
28
|
+
.map((item) => item[1]);
|
|
29
|
+
}
|
|
30
|
+
if (filter.value > 0 && (filter.mode === "first" || filter.mode === "random")) {
|
|
31
|
+
items = items.slice(0, filter.value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return items;
|
|
35
|
+
}
|
|
36
|
+
function stringSetToSortedArray(s) {
|
|
37
|
+
return Array.from(s).sort((l, r) => l.localeCompare(r, undefined, { sensitivity: "base" }));
|
|
38
|
+
}
|
|
39
|
+
export function applyCatalogueFilters(filters, catalogues) {
|
|
40
|
+
const cataloguesAsTree = new Map();
|
|
41
|
+
for (const catalogueParams of catalogues) {
|
|
42
|
+
const { enterprise, prdCat, prdCatVersion, vendor, priceList } = catalogueParams;
|
|
43
|
+
let byEnterprise = cataloguesAsTree.get(enterprise);
|
|
44
|
+
if (byEnterprise === undefined) {
|
|
45
|
+
byEnterprise = new Map();
|
|
46
|
+
cataloguesAsTree.set(enterprise, byEnterprise);
|
|
47
|
+
}
|
|
48
|
+
let byPrdCat = byEnterprise.get(prdCat);
|
|
49
|
+
if (byPrdCat === undefined) {
|
|
50
|
+
byPrdCat = new Map();
|
|
51
|
+
byEnterprise.set(prdCat, byPrdCat);
|
|
52
|
+
}
|
|
53
|
+
let byPrdCatVersion = byPrdCat.get(prdCatVersion);
|
|
54
|
+
if (byPrdCatVersion === undefined) {
|
|
55
|
+
byPrdCatVersion = new Map();
|
|
56
|
+
byPrdCat.set(prdCatVersion, byPrdCatVersion);
|
|
57
|
+
}
|
|
58
|
+
let byVendor = byPrdCatVersion.get(vendor);
|
|
59
|
+
if (byVendor === undefined) {
|
|
60
|
+
byVendor = new Map();
|
|
61
|
+
byPrdCatVersion.set(vendor, byVendor);
|
|
62
|
+
}
|
|
63
|
+
if (byVendor.has(priceList)) {
|
|
64
|
+
console.warn(`Duplicate catalogue ${enterprise} ${prdCat} ${prdCatVersion} ${vendor} ${priceList}`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
byVendor.set(priceList, catalogueParams);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const filteredCatalogues = [];
|
|
71
|
+
const availablePropertyValues = {
|
|
72
|
+
enterprise: new Set(),
|
|
73
|
+
prdCat: new Set(),
|
|
74
|
+
prdCatVersion: new Set(),
|
|
75
|
+
vendor: new Set(),
|
|
76
|
+
priceList: new Set(),
|
|
77
|
+
};
|
|
78
|
+
filterAndSort(cataloguesAsTree, "enterprise", filters, availablePropertyValues).map((item) => filterAndSort(item, "prdCat", filters, availablePropertyValues).map((item) => filterAndSort(item, "prdCatVersion", filters, availablePropertyValues).map((item) => filterAndSort(item, "vendor", filters, availablePropertyValues).map((item) => filterAndSort(item, "priceList", filters, availablePropertyValues).forEach((item) => {
|
|
79
|
+
filteredCatalogues.push(item);
|
|
80
|
+
})))));
|
|
81
|
+
const availablePropertyValuesAsSortedArrays = {
|
|
82
|
+
enterprise: stringSetToSortedArray(availablePropertyValues.enterprise),
|
|
83
|
+
prdCat: stringSetToSortedArray(availablePropertyValues.prdCat),
|
|
84
|
+
prdCatVersion: stringSetToSortedArray(availablePropertyValues.prdCatVersion),
|
|
85
|
+
vendor: stringSetToSortedArray(availablePropertyValues.vendor),
|
|
86
|
+
priceList: stringSetToSortedArray(availablePropertyValues.priceList),
|
|
87
|
+
};
|
|
88
|
+
return [availablePropertyValuesAsSortedArrays, filteredCatalogues];
|
|
89
|
+
}
|
|
90
|
+
export function applyProductRefFilters(filters, productRefs) {
|
|
91
|
+
const map = new Map();
|
|
92
|
+
for (const productRef of productRefs) {
|
|
93
|
+
map.set(productRef.partNr, productRef);
|
|
94
|
+
}
|
|
95
|
+
const availablePropertyValues = {
|
|
96
|
+
partNr: new Set(),
|
|
97
|
+
};
|
|
98
|
+
const filtered = filterAndSort(map, "partNr", filters, availablePropertyValues);
|
|
99
|
+
return [stringSetToSortedArray(availablePropertyValues.partNr), filtered];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Clones the table of content levels tree.
|
|
103
|
+
* Filters to only include passed products.
|
|
104
|
+
* @param levels The original data
|
|
105
|
+
* @param prdRefsFilter Products not in this array are removed
|
|
106
|
+
* @param showEmpty Shall empty levels be shown?
|
|
107
|
+
*/
|
|
108
|
+
export function cloneFilterSortLevels(levels, prdRefsFilter, showEmpty, doSort = true) {
|
|
109
|
+
const newLevels = [];
|
|
110
|
+
for (const level of levels) {
|
|
111
|
+
// recursively fetch the next levels
|
|
112
|
+
let nextLevels;
|
|
113
|
+
if (level.lvls !== undefined) {
|
|
114
|
+
nextLevels = cloneFilterSortLevels(level.lvls, prdRefsFilter, showEmpty, doSort);
|
|
115
|
+
}
|
|
116
|
+
// filter out products
|
|
117
|
+
let newPrdRefs;
|
|
118
|
+
if (level.prdRefs !== undefined) {
|
|
119
|
+
newPrdRefs = level.prdRefs.filter((prod) => prdRefsFilter.some((p) => p.partNr === prod.prdRef));
|
|
120
|
+
}
|
|
121
|
+
// add copy of level if not empty
|
|
122
|
+
const addPrdRefs = showEmpty || (newPrdRefs !== undefined && newPrdRefs.length > 0);
|
|
123
|
+
if (nextLevels !== undefined || addPrdRefs) {
|
|
124
|
+
const newLevel = {
|
|
125
|
+
code: level.code,
|
|
126
|
+
description: level.description,
|
|
127
|
+
};
|
|
128
|
+
if (nextLevels !== undefined) {
|
|
129
|
+
newLevel.lvls = nextLevels;
|
|
130
|
+
}
|
|
131
|
+
if (addPrdRefs && newPrdRefs !== undefined) {
|
|
132
|
+
newLevel.prdRefs = newPrdRefs;
|
|
133
|
+
}
|
|
134
|
+
newLevels.push(newLevel);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (doSort) {
|
|
138
|
+
return newLevels.sort((l1, l2) => l1.description.toLocaleLowerCase().localeCompare(l2.description.toLocaleLowerCase()));
|
|
139
|
+
}
|
|
140
|
+
return newLevels;
|
|
141
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Filters } from "@configura/web-utilities";
|
|
2
|
-
import { CatalogueAPI, DtoApplicationAreasResponse, DtoCatalogueParamsWithCid, DtoCatalogueParamsWithCidAndLang } from "../CatalogueAPI.js";
|
|
3
|
-
import { CfgProduct, CfgProductSettings } from "../CfgProduct.js";
|
|
4
|
-
import { ProductRefParams } from "./filters.js";
|
|
5
|
-
export interface GeneratedProductConfiguration {
|
|
6
|
-
applicationAreasResponse: DtoApplicationAreasResponse;
|
|
7
|
-
catalogueCount: number;
|
|
8
|
-
catalogueIndex: number;
|
|
9
|
-
catalogueParams: DtoCatalogueParamsWithCidAndLang;
|
|
10
|
-
getProductDuration: number;
|
|
11
|
-
product: CfgProduct;
|
|
12
|
-
productCount: number;
|
|
13
|
-
productIndex: number;
|
|
14
|
-
}
|
|
15
|
-
export declare function generateProductConfigurations(api: CatalogueAPI, lang: string, catalogues: DtoCatalogueParamsWithCid[], filters: Filters<ProductRefParams>, settings?: Partial<CfgProductSettings>): AsyncIterableIterator<GeneratedProductConfiguration | Error>;
|
|
1
|
+
import { Filters } from "@configura/web-utilities";
|
|
2
|
+
import { CatalogueAPI, DtoApplicationAreasResponse, DtoCatalogueParamsWithCid, DtoCatalogueParamsWithCidAndLang } from "../CatalogueAPI.js";
|
|
3
|
+
import { CfgProduct, CfgProductSettings } from "../CfgProduct.js";
|
|
4
|
+
import { ProductRefParams } from "./filters.js";
|
|
5
|
+
export interface GeneratedProductConfiguration {
|
|
6
|
+
applicationAreasResponse: DtoApplicationAreasResponse;
|
|
7
|
+
catalogueCount: number;
|
|
8
|
+
catalogueIndex: number;
|
|
9
|
+
catalogueParams: DtoCatalogueParamsWithCidAndLang;
|
|
10
|
+
getProductDuration: number;
|
|
11
|
+
product: CfgProduct;
|
|
12
|
+
productCount: number;
|
|
13
|
+
productIndex: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function generateProductConfigurations(api: CatalogueAPI, lang: string, catalogues: DtoCatalogueParamsWithCid[], filters: Filters<ProductRefParams>, settings?: Partial<CfgProductSettings>): AsyncIterableIterator<GeneratedProductConfiguration | Error>;
|
|
16
16
|
//# sourceMappingURL=productParamsGenerator.d.ts.map
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
2
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
3
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
5
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
6
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
7
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
8
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
9
|
-
function fulfill(value) { resume("next", value); }
|
|
10
|
-
function reject(value) { resume("throw", value); }
|
|
11
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
12
|
-
};
|
|
13
|
-
import { toError } from "@configura/web-utilities";
|
|
14
|
-
import { CfgProduct } from "../CfgProduct.js";
|
|
15
|
-
import { applyProductRefFilters } from "./filters.js";
|
|
16
|
-
export function generateProductConfigurations(api, lang, catalogues, filters, settings) {
|
|
17
|
-
return __asyncGenerator(this, arguments, function* generateProductConfigurations_1() {
|
|
18
|
-
const catalogueCount = catalogues.length;
|
|
19
|
-
const catalogueEntries = catalogues.entries();
|
|
20
|
-
for (const [catalogueIndex, catalogueParamsWithoutLang] of catalogueEntries) {
|
|
21
|
-
const catalogueParams = Object.assign(Object.assign({}, catalogueParamsWithoutLang), { lang });
|
|
22
|
-
try {
|
|
23
|
-
const [applicationAreasResponse, toc] = yield __await(Promise.all([
|
|
24
|
-
api.getApplicationAreas(catalogueParams),
|
|
25
|
-
api.getTocFlat(catalogueParams),
|
|
26
|
-
]));
|
|
27
|
-
const [, productRefs] = applyProductRefFilters(filters, (toc === null || toc === void 0 ? void 0 : toc.prdRefs) || []);
|
|
28
|
-
const productCount = productRefs.length;
|
|
29
|
-
const productEntries = productRefs.entries();
|
|
30
|
-
for (const [productIndex, prdRef] of productEntries) {
|
|
31
|
-
const startTime = performance.now();
|
|
32
|
-
const product = yield __await(CfgProduct.make(api, Object.assign(Object.assign({}, catalogueParams), { partNumber: prdRef.partNr }), settings));
|
|
33
|
-
const getProductDuration = performance.now() - startTime;
|
|
34
|
-
yield yield __await({
|
|
35
|
-
applicationAreasResponse,
|
|
36
|
-
catalogueCount,
|
|
37
|
-
catalogueIndex,
|
|
38
|
-
catalogueParams,
|
|
39
|
-
getProductDuration,
|
|
40
|
-
product,
|
|
41
|
-
productCount,
|
|
42
|
-
productIndex,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
yield yield __await(toError(e));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
1
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
2
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
3
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
5
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
6
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
7
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
8
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
9
|
+
function fulfill(value) { resume("next", value); }
|
|
10
|
+
function reject(value) { resume("throw", value); }
|
|
11
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
12
|
+
};
|
|
13
|
+
import { toError } from "@configura/web-utilities";
|
|
14
|
+
import { CfgProduct } from "../CfgProduct.js";
|
|
15
|
+
import { applyProductRefFilters } from "./filters.js";
|
|
16
|
+
export function generateProductConfigurations(api, lang, catalogues, filters, settings) {
|
|
17
|
+
return __asyncGenerator(this, arguments, function* generateProductConfigurations_1() {
|
|
18
|
+
const catalogueCount = catalogues.length;
|
|
19
|
+
const catalogueEntries = catalogues.entries();
|
|
20
|
+
for (const [catalogueIndex, catalogueParamsWithoutLang] of catalogueEntries) {
|
|
21
|
+
const catalogueParams = Object.assign(Object.assign({}, catalogueParamsWithoutLang), { lang });
|
|
22
|
+
try {
|
|
23
|
+
const [applicationAreasResponse, toc] = yield __await(Promise.all([
|
|
24
|
+
api.getApplicationAreas(catalogueParams),
|
|
25
|
+
api.getTocFlat(catalogueParams),
|
|
26
|
+
]));
|
|
27
|
+
const [, productRefs] = applyProductRefFilters(filters, (toc === null || toc === void 0 ? void 0 : toc.prdRefs) || []);
|
|
28
|
+
const productCount = productRefs.length;
|
|
29
|
+
const productEntries = productRefs.entries();
|
|
30
|
+
for (const [productIndex, prdRef] of productEntries) {
|
|
31
|
+
const startTime = performance.now();
|
|
32
|
+
const product = yield __await(CfgProduct.make(api, Object.assign(Object.assign({}, catalogueParams), { partNumber: prdRef.partNr }), settings));
|
|
33
|
+
const getProductDuration = performance.now() - startTime;
|
|
34
|
+
yield yield __await({
|
|
35
|
+
applicationAreasResponse,
|
|
36
|
+
catalogueCount,
|
|
37
|
+
catalogueIndex,
|
|
38
|
+
catalogueParams,
|
|
39
|
+
getProductDuration,
|
|
40
|
+
product,
|
|
41
|
+
productCount,
|
|
42
|
+
productIndex,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
yield yield __await(toError(e));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { DtoAdditionalProductRef, DtoFeature, DtoFeatureRef } from "../CatalogueAPI.js";
|
|
2
|
-
import { _CfgProductInternal } from "../CfgProduct.js";
|
|
3
|
-
import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
|
|
4
|
-
import { CfgFeature } from "./CfgFeature.js";
|
|
5
|
-
import { _CfgOptionInternal } from "./CfgOption.js";
|
|
6
|
-
import { CfgProductConfiguration, _CfgProductConfigurationInternal } from "./CfgProductConfiguration.js";
|
|
7
|
-
/**
|
|
8
|
-
* Returns a new array of CfgFeatures that maps to the newFeatureRefs array. Uses CfgFeatures from
|
|
9
|
-
* currentFeatures if they can be found, otherwise makes new.
|
|
10
|
-
*/
|
|
11
|
-
export declare function syncCfgFeatures(newFeatureRefs: DtoFeatureRef[], currentFeatures: CfgFeature[], rawFeatures: DtoFeature[], parent: _CfgProductConfigurationInternal | _CfgOptionInternal, parentConfiguration: _CfgProductConfigurationInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal): CfgFeature[];
|
|
12
|
-
export declare function getMtrlPreview(mtrlApplications: CfgMtrlApplication[] | undefined): string | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Recursively find all additional product references given a product configuration.
|
|
15
|
-
* Only selected options are considered.
|
|
16
|
-
*/
|
|
17
|
-
export declare function collectAdditionalProductRefs(parent: CfgProductConfiguration): DtoAdditionalProductRef[];
|
|
1
|
+
import { DtoAdditionalProductRef, DtoFeature, DtoFeatureRef } from "../CatalogueAPI.js";
|
|
2
|
+
import { _CfgProductInternal } from "../CfgProduct.js";
|
|
3
|
+
import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
|
|
4
|
+
import { CfgFeature } from "./CfgFeature.js";
|
|
5
|
+
import { _CfgOptionInternal } from "./CfgOption.js";
|
|
6
|
+
import { CfgProductConfiguration, _CfgProductConfigurationInternal } from "./CfgProductConfiguration.js";
|
|
7
|
+
/**
|
|
8
|
+
* Returns a new array of CfgFeatures that maps to the newFeatureRefs array. Uses CfgFeatures from
|
|
9
|
+
* currentFeatures if they can be found, otherwise makes new.
|
|
10
|
+
*/
|
|
11
|
+
export declare function syncCfgFeatures(newFeatureRefs: DtoFeatureRef[], currentFeatures: CfgFeature[], rawFeatures: DtoFeature[], parent: _CfgProductConfigurationInternal | _CfgOptionInternal, parentConfiguration: _CfgProductConfigurationInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal): CfgFeature[];
|
|
12
|
+
export declare function getMtrlPreview(mtrlApplications: CfgMtrlApplication[] | undefined): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Recursively find all additional product references given a product configuration.
|
|
15
|
+
* Only selected options are considered.
|
|
16
|
+
*/
|
|
17
|
+
export declare function collectAdditionalProductRefs(parent: CfgProductConfiguration): DtoAdditionalProductRef[];
|
|
18
18
|
//# sourceMappingURL=utilitiesProductConfiguration.d.ts.map
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import { someMatch } from "@configura/web-utilities";
|
|
2
|
-
import { CfgFeature } from "./CfgFeature.js";
|
|
3
|
-
import { CfgOption } from "./CfgOption.js";
|
|
4
|
-
import { CfgProductConfiguration, } from "./CfgProductConfiguration.js";
|
|
5
|
-
/**
|
|
6
|
-
* Returns a new array of CfgFeatures that maps to the newFeatureRefs array. Uses CfgFeatures from
|
|
7
|
-
* currentFeatures if they can be found, otherwise makes new.
|
|
8
|
-
*/
|
|
9
|
-
export function syncCfgFeatures(newFeatureRefs, currentFeatures, rawFeatures, parent, parentConfiguration, parentProduct, rootProduct) {
|
|
10
|
-
const usedRawFeatures = newFeatureRefs
|
|
11
|
-
.map((r) => r.code)
|
|
12
|
-
.map((c) => {
|
|
13
|
-
const rawFeature = rawFeatures.find((f) => c === f.code);
|
|
14
|
-
if (rawFeature === undefined) {
|
|
15
|
-
throw new Error(`Feature not found. Requested feature code: "${c}".`);
|
|
16
|
-
}
|
|
17
|
-
return rawFeature;
|
|
18
|
-
});
|
|
19
|
-
const hasDuplicateDescription = someMatch(usedRawFeatures, (l, r) => {
|
|
20
|
-
return l.description.toLowerCase() === r.description.toLowerCase();
|
|
21
|
-
});
|
|
22
|
-
const newFeatures = [];
|
|
23
|
-
for (const f of usedRawFeatures) {
|
|
24
|
-
const fCode = f.code;
|
|
25
|
-
const fDescription = f.description;
|
|
26
|
-
// It is possible in Cat Creator to add the same Feature twice
|
|
27
|
-
// to the root of a Product. This fills no apparent purpose,
|
|
28
|
-
// and in CET the seem to behave as if they were the same.
|
|
29
|
-
// Removing the duplicates causes sync issues where the server
|
|
30
|
-
// expects all copies, and hence we short circuit them here
|
|
31
|
-
// by letting them refer to the same object instead.
|
|
32
|
-
const twin = newFeatures.find((f) => f.code === fCode);
|
|
33
|
-
if (twin !== undefined) {
|
|
34
|
-
newFeatures.push(twin);
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
// Description based code helps when switching between
|
|
38
|
-
// products with similar feature-options tree and trying
|
|
39
|
-
// to retain made selections
|
|
40
|
-
const key = fDescription + (fDescription === "" || hasDuplicateDescription ? fCode : "");
|
|
41
|
-
const existingFeature = currentFeatures.find((cfgF) => cfgF.code === fCode);
|
|
42
|
-
if (existingFeature !== undefined) {
|
|
43
|
-
if (hasDuplicateDescription) {
|
|
44
|
-
// HasDuplicateDescription could mean the key need to be more specific compared
|
|
45
|
-
// to the one we already have, so then we set it. An old duplicate description
|
|
46
|
-
// key will cause no harm as it is guaranteed to be at least as specific as this.
|
|
47
|
-
// Not changing the key will make React not rerender, so we don't change.
|
|
48
|
-
existingFeature._internal.key = key;
|
|
49
|
-
}
|
|
50
|
-
newFeatures.push(existingFeature);
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
newFeatures.push(CfgFeature.make(f, rawFeatures, key, parent, parentConfiguration, parentProduct, rootProduct));
|
|
54
|
-
}
|
|
55
|
-
return newFeatures;
|
|
56
|
-
}
|
|
57
|
-
export function getMtrlPreview(mtrlApplications) {
|
|
58
|
-
if (mtrlApplications === undefined) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const first = mtrlApplications[0];
|
|
62
|
-
if (first === undefined) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
return first.previewUrl;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Recursively find all additional product references given a product configuration.
|
|
69
|
-
* Only selected options are considered.
|
|
70
|
-
*/
|
|
71
|
-
export function collectAdditionalProductRefs(parent) {
|
|
72
|
-
function c(parent) {
|
|
73
|
-
const result = [];
|
|
74
|
-
if (parent instanceof CfgOption && parent.selected) {
|
|
75
|
-
result.push(...(parent.rawOption.additionalProductRefs || []));
|
|
76
|
-
}
|
|
77
|
-
if (parent instanceof CfgProductConfiguration || parent.selected) {
|
|
78
|
-
for (const feature of parent.features) {
|
|
79
|
-
for (const option of feature.options) {
|
|
80
|
-
result.push(...c(option));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
return c(parent);
|
|
87
|
-
}
|
|
1
|
+
import { someMatch } from "@configura/web-utilities";
|
|
2
|
+
import { CfgFeature } from "./CfgFeature.js";
|
|
3
|
+
import { CfgOption } from "./CfgOption.js";
|
|
4
|
+
import { CfgProductConfiguration, } from "./CfgProductConfiguration.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns a new array of CfgFeatures that maps to the newFeatureRefs array. Uses CfgFeatures from
|
|
7
|
+
* currentFeatures if they can be found, otherwise makes new.
|
|
8
|
+
*/
|
|
9
|
+
export function syncCfgFeatures(newFeatureRefs, currentFeatures, rawFeatures, parent, parentConfiguration, parentProduct, rootProduct) {
|
|
10
|
+
const usedRawFeatures = newFeatureRefs
|
|
11
|
+
.map((r) => r.code)
|
|
12
|
+
.map((c) => {
|
|
13
|
+
const rawFeature = rawFeatures.find((f) => c === f.code);
|
|
14
|
+
if (rawFeature === undefined) {
|
|
15
|
+
throw new Error(`Feature not found. Requested feature code: "${c}".`);
|
|
16
|
+
}
|
|
17
|
+
return rawFeature;
|
|
18
|
+
});
|
|
19
|
+
const hasDuplicateDescription = someMatch(usedRawFeatures, (l, r) => {
|
|
20
|
+
return l.description.toLowerCase() === r.description.toLowerCase();
|
|
21
|
+
});
|
|
22
|
+
const newFeatures = [];
|
|
23
|
+
for (const f of usedRawFeatures) {
|
|
24
|
+
const fCode = f.code;
|
|
25
|
+
const fDescription = f.description;
|
|
26
|
+
// It is possible in Cat Creator to add the same Feature twice
|
|
27
|
+
// to the root of a Product. This fills no apparent purpose,
|
|
28
|
+
// and in CET the seem to behave as if they were the same.
|
|
29
|
+
// Removing the duplicates causes sync issues where the server
|
|
30
|
+
// expects all copies, and hence we short circuit them here
|
|
31
|
+
// by letting them refer to the same object instead.
|
|
32
|
+
const twin = newFeatures.find((f) => f.code === fCode);
|
|
33
|
+
if (twin !== undefined) {
|
|
34
|
+
newFeatures.push(twin);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// Description based code helps when switching between
|
|
38
|
+
// products with similar feature-options tree and trying
|
|
39
|
+
// to retain made selections
|
|
40
|
+
const key = fDescription + (fDescription === "" || hasDuplicateDescription ? fCode : "");
|
|
41
|
+
const existingFeature = currentFeatures.find((cfgF) => cfgF.code === fCode);
|
|
42
|
+
if (existingFeature !== undefined) {
|
|
43
|
+
if (hasDuplicateDescription) {
|
|
44
|
+
// HasDuplicateDescription could mean the key need to be more specific compared
|
|
45
|
+
// to the one we already have, so then we set it. An old duplicate description
|
|
46
|
+
// key will cause no harm as it is guaranteed to be at least as specific as this.
|
|
47
|
+
// Not changing the key will make React not rerender, so we don't change.
|
|
48
|
+
existingFeature._internal.key = key;
|
|
49
|
+
}
|
|
50
|
+
newFeatures.push(existingFeature);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
newFeatures.push(CfgFeature.make(f, rawFeatures, key, parent, parentConfiguration, parentProduct, rootProduct));
|
|
54
|
+
}
|
|
55
|
+
return newFeatures;
|
|
56
|
+
}
|
|
57
|
+
export function getMtrlPreview(mtrlApplications) {
|
|
58
|
+
if (mtrlApplications === undefined) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const first = mtrlApplications[0];
|
|
62
|
+
if (first === undefined) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
return first.previewUrl;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Recursively find all additional product references given a product configuration.
|
|
69
|
+
* Only selected options are considered.
|
|
70
|
+
*/
|
|
71
|
+
export function collectAdditionalProductRefs(parent) {
|
|
72
|
+
function c(parent) {
|
|
73
|
+
const result = [];
|
|
74
|
+
if (parent instanceof CfgOption && parent.selected) {
|
|
75
|
+
result.push(...(parent.rawOption.additionalProductRefs || []));
|
|
76
|
+
}
|
|
77
|
+
if (parent instanceof CfgProductConfiguration || parent.selected) {
|
|
78
|
+
for (const feature of parent.features) {
|
|
79
|
+
for (const option of feature.options) {
|
|
80
|
+
result.push(...c(option));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
return c(parent);
|
|
87
|
+
}
|