@configura/web-api 2.2.0-alpha.1 → 2.2.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.
Files changed (102) 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 +633 -633
  5. package/dist/CatalogueAPI.js +312 -312
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +359 -344
  9. package/dist/CfgProduct.js +1005 -992
  10. package/dist/CfgReferencePathHelper.d.ts +26 -26
  11. package/dist/CfgReferencePathHelper.js +26 -26
  12. package/dist/index.d.ts +24 -24
  13. package/dist/index.js +24 -24
  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 -54
  21. package/dist/io/CfgIOProdConfConnector.js +139 -139
  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 -15
  27. package/dist/io/CfgObservableStateToProdConfConnector.js +17 -17
  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 -17
  33. package/dist/io/CfgWindowMessageToProdConfConnector.js +19 -19
  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 +199 -199
  47. package/dist/productConfiguration/CfgFeature.js +691 -691
  48. package/dist/productConfiguration/CfgOption.d.ts +160 -160
  49. package/dist/productConfiguration/CfgOption.js +464 -464
  50. package/dist/productConfiguration/CfgProductConfiguration.d.ts +136 -129
  51. package/dist/productConfiguration/CfgProductConfiguration.js +355 -346
  52. package/dist/productConfiguration/filters.d.ts +17 -17
  53. package/dist/productConfiguration/filters.js +141 -141
  54. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  55. package/dist/productConfiguration/productParamsGenerator.js +65 -65
  56. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
  57. package/dist/productConfiguration/utilitiesProductConfiguration.js +89 -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/testDataConstraints.d.ts +3 -3
  85. package/dist/tests/testData/testDataConstraints.js +174 -174
  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 -189
  92. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  93. package/dist/tests/testData/testDataUpcharge.js +121 -121
  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/utilitiesConfiguration.d.ts +28 -28
  99. package/dist/utilitiesConfiguration.js +200 -200
  100. package/dist/utilitiesNumericValues.d.ts +24 -24
  101. package/dist/utilitiesNumericValues.js +114 -114
  102. package/package.json +3 -3
@@ -1,18 +1,18 @@
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;
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;
18
18
  //# sourceMappingURL=filters.d.ts.map
@@ -1,141 +1,141 @@
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
+ 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,65 +1,65 @@
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
- try {
33
- const product = yield __await(CfgProduct.make(api, Object.assign(Object.assign({}, catalogueParams), { partNumber: prdRef.partNr }), settings));
34
- const getProductDuration = performance.now() - startTime;
35
- yield yield __await({
36
- applicationAreasResponse,
37
- catalogueCount,
38
- catalogueIndex,
39
- catalogueParams,
40
- getProductDuration,
41
- product,
42
- productCount,
43
- productIndex,
44
- });
45
- }
46
- catch (e) {
47
- const err = e;
48
- // Product load error, for example missing CmSym files.
49
- // Safe to continue loading the next product.
50
- const split = err.message.indexOf(", request ID: ");
51
- if (split > -1) {
52
- // The request ID part of the error from the server is mostly just spam and
53
- // makes it harder to read list of errors, so remove it.
54
- err.message = err.message.slice(0, split);
55
- }
56
- yield yield __await(toError(e));
57
- }
58
- }
59
- }
60
- catch (e) {
61
- yield yield __await(toError(e));
62
- }
63
- }
64
- });
65
- }
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
+ try {
33
+ const product = yield __await(CfgProduct.make(api, Object.assign(Object.assign({}, catalogueParams), { partNumber: prdRef.partNr }), settings));
34
+ const getProductDuration = performance.now() - startTime;
35
+ yield yield __await({
36
+ applicationAreasResponse,
37
+ catalogueCount,
38
+ catalogueIndex,
39
+ catalogueParams,
40
+ getProductDuration,
41
+ product,
42
+ productCount,
43
+ productIndex,
44
+ });
45
+ }
46
+ catch (e) {
47
+ const err = e;
48
+ // Product load error, for example missing CmSym files.
49
+ // Safe to continue loading the next product.
50
+ const split = err.message.indexOf(", request ID: ");
51
+ if (split > -1) {
52
+ // The request ID part of the error from the server is mostly just spam and
53
+ // makes it harder to read list of errors, so remove it.
54
+ err.message = err.message.slice(0, split);
55
+ }
56
+ yield yield __await(toError(e));
57
+ }
58
+ }
59
+ }
60
+ catch (e) {
61
+ yield yield __await(toError(e));
62
+ }
63
+ }
64
+ });
65
+ }
@@ -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