@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,16 +1,16 @@
1
- import { Filters, Matches } 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[]): [Matches<DtoCatalogueParams>, T[]];
4
- export interface ProductRefParams {
5
- partNr: string;
6
- }
7
- export declare function applyProductRefFilters(filters: Filters<ProductRefParams>, productRefs: DtoProductRef[]): [Matches<ProductRefParams>, DtoProductRef[]];
8
- /**
9
- * Clones the table of content levels tree.
10
- * Filters to only include passed products.
11
- * @param levels The original data
12
- * @param prdRefsFilter Products not in this array are removed
13
- * @param showEmpty Shall empty levels be shown?
14
- */
15
- export declare function cloneFilterSortLevels(levels: DtoLevel[], prdRefsFilter: DtoProductRef[], showEmpty: boolean, doSort?: boolean): DtoLevel[] | undefined;
1
+ import { Filters, Matches } 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[]): [Matches<DtoCatalogueParams>, T[]];
4
+ export interface ProductRefParams {
5
+ partNr: string;
6
+ }
7
+ export declare function applyProductRefFilters(filters: Filters<ProductRefParams>, productRefs: DtoProductRef[]): [Matches<ProductRefParams>, DtoProductRef[]];
8
+ /**
9
+ * Clones the table of content levels tree.
10
+ * Filters to only include passed products.
11
+ * @param levels The original data
12
+ * @param prdRefsFilter Products not in this array are removed
13
+ * @param showEmpty Shall empty levels be shown?
14
+ */
15
+ export declare function cloneFilterSortLevels(levels: DtoLevel[], prdRefsFilter: DtoProductRef[], showEmpty: boolean, doSort?: boolean): DtoLevel[] | undefined;
16
16
  //# sourceMappingURL=filters.d.ts.map
@@ -1,70 +1,70 @@
1
- import { match, pick } from "@configura/web-utilities";
2
- export function applyCatalogueFilters(filters, catalogues) {
3
- const enterprise = match("enterprise", filters.enterprise, catalogues);
4
- const prdCat = match("prdCat", filters.prdCat, enterprise.matching);
5
- const prdCatVersion = match("prdCatVersion", filters.prdCatVersion, prdCat.matching);
6
- const vendor = match("vendor", filters.vendor, prdCatVersion.matching);
7
- const priceList = match("priceList", filters.priceList, vendor.matching);
8
- let picked = pick(filters.enterprise, priceList.matching);
9
- picked = pick(filters.prdCat, picked);
10
- picked = pick(filters.prdCatVersion, picked);
11
- picked = pick(filters.vendor, picked);
12
- picked = pick(filters.priceList, picked);
13
- const matches = {
14
- enterprise,
15
- prdCat,
16
- prdCatVersion,
17
- priceList,
18
- vendor,
19
- };
20
- return [matches, picked];
21
- }
22
- export function applyProductRefFilters(filters, productRefs) {
23
- const partNr = match("partNr", filters.partNr, productRefs);
24
- const result = pick(filters.partNr, partNr.matching);
25
- const args = {
26
- partNr,
27
- };
28
- return [args, result];
29
- }
30
- /**
31
- * Clones the table of content levels tree.
32
- * Filters to only include passed products.
33
- * @param levels The original data
34
- * @param prdRefsFilter Products not in this array are removed
35
- * @param showEmpty Shall empty levels be shown?
36
- */
37
- export function cloneFilterSortLevels(levels, prdRefsFilter, showEmpty, doSort = true) {
38
- const newLevels = [];
39
- for (const level of levels) {
40
- // recursively fetch the next levels
41
- let nextLevels;
42
- if (level.lvls !== undefined) {
43
- nextLevels = cloneFilterSortLevels(level.lvls, prdRefsFilter, showEmpty, doSort);
44
- }
45
- // filter out products
46
- let newPrdRefs;
47
- if (level.prdRefs !== undefined) {
48
- newPrdRefs = level.prdRefs.filter((prod) => prdRefsFilter.some((p) => p.partNr === prod.prdRef));
49
- }
50
- // add copy of level if not empty
51
- const addPrdRefs = showEmpty || (newPrdRefs !== undefined && newPrdRefs.length > 0);
52
- if (nextLevels !== undefined || addPrdRefs) {
53
- const newLevel = {
54
- code: level.code,
55
- description: level.description,
56
- };
57
- if (nextLevels !== undefined) {
58
- newLevel.lvls = nextLevels;
59
- }
60
- if (addPrdRefs && newPrdRefs !== undefined) {
61
- newLevel.prdRefs = newPrdRefs;
62
- }
63
- newLevels.push(newLevel);
64
- }
65
- }
66
- if (doSort) {
67
- return newLevels.sort((l1, l2) => l1.description.toLocaleLowerCase().localeCompare(l2.description.toLocaleLowerCase()));
68
- }
69
- return newLevels;
70
- }
1
+ import { match, pick } from "@configura/web-utilities";
2
+ export function applyCatalogueFilters(filters, catalogues) {
3
+ const enterprise = match("enterprise", filters.enterprise, catalogues);
4
+ const prdCat = match("prdCat", filters.prdCat, enterprise.matching);
5
+ const prdCatVersion = match("prdCatVersion", filters.prdCatVersion, prdCat.matching);
6
+ const vendor = match("vendor", filters.vendor, prdCatVersion.matching);
7
+ const priceList = match("priceList", filters.priceList, vendor.matching);
8
+ let picked = pick(filters.enterprise, priceList.matching);
9
+ picked = pick(filters.prdCat, picked);
10
+ picked = pick(filters.prdCatVersion, picked);
11
+ picked = pick(filters.vendor, picked);
12
+ picked = pick(filters.priceList, picked);
13
+ const matches = {
14
+ enterprise,
15
+ prdCat,
16
+ prdCatVersion,
17
+ priceList,
18
+ vendor,
19
+ };
20
+ return [matches, picked];
21
+ }
22
+ export function applyProductRefFilters(filters, productRefs) {
23
+ const partNr = match("partNr", filters.partNr, productRefs);
24
+ const result = pick(filters.partNr, partNr.matching);
25
+ const args = {
26
+ partNr,
27
+ };
28
+ return [args, result];
29
+ }
30
+ /**
31
+ * Clones the table of content levels tree.
32
+ * Filters to only include passed products.
33
+ * @param levels The original data
34
+ * @param prdRefsFilter Products not in this array are removed
35
+ * @param showEmpty Shall empty levels be shown?
36
+ */
37
+ export function cloneFilterSortLevels(levels, prdRefsFilter, showEmpty, doSort = true) {
38
+ const newLevels = [];
39
+ for (const level of levels) {
40
+ // recursively fetch the next levels
41
+ let nextLevels;
42
+ if (level.lvls !== undefined) {
43
+ nextLevels = cloneFilterSortLevels(level.lvls, prdRefsFilter, showEmpty, doSort);
44
+ }
45
+ // filter out products
46
+ let newPrdRefs;
47
+ if (level.prdRefs !== undefined) {
48
+ newPrdRefs = level.prdRefs.filter((prod) => prdRefsFilter.some((p) => p.partNr === prod.prdRef));
49
+ }
50
+ // add copy of level if not empty
51
+ const addPrdRefs = showEmpty || (newPrdRefs !== undefined && newPrdRefs.length > 0);
52
+ if (nextLevels !== undefined || addPrdRefs) {
53
+ const newLevel = {
54
+ code: level.code,
55
+ description: level.description,
56
+ };
57
+ if (nextLevels !== undefined) {
58
+ newLevel.lvls = nextLevels;
59
+ }
60
+ if (addPrdRefs && newPrdRefs !== undefined) {
61
+ newLevel.prdRefs = newPrdRefs;
62
+ }
63
+ newLevels.push(newLevel);
64
+ }
65
+ }
66
+ if (doSort) {
67
+ return newLevels.sort((l1, l2) => l1.description.toLocaleLowerCase().localeCompare(l2.description.toLocaleLowerCase()));
68
+ }
69
+ return newLevels;
70
+ }
@@ -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
+ }
@@ -1,34 +1,34 @@
1
- import { DtoProductParamsWithCidAndLang, DtoValidateRequest } from "./CatalogueAPI.js";
2
- import { CfgProductResponse, CfgValidateResponse } from "./utilitiesCatalogueData.js";
3
- export declare type GetProduct = (params: DtoProductParamsWithCidAndLang) => Promise<CfgProductResponse>;
4
- export declare type PostValidate = (params: DtoProductParamsWithCidAndLang, body: DtoValidateRequest) => Promise<CfgValidateResponse>;
5
- export declare type ProductLoader = {
6
- getProduct: GetProduct;
7
- postValidate: PostValidate;
8
- };
9
- /**
10
- * Wraps a getProduct function so that it caches for the time it lives.
11
- *
12
- * It has no cache invalidation or timeouts, so whatever ends up in the cache stays there
13
- * indefinitely. For this reason we recommend using this with caution.
14
- *
15
- * In our Example App we use it to cache the internal calls in additional products as in such a
16
- * product you tend to frequently get calls to same sub-product. Such as loading the same table leg
17
- * four times.
18
- */
19
- export declare function wrapWithGetProductCache(getProduct: GetProduct): GetProduct;
20
- /**
21
- * Wraps a postValidate function so that it caches for the time it lives.
22
- *
23
- * It has no cache invalidation or timeouts, so whatever ends up in the cache stays there
24
- * indefinitely. We recommend you do not use this unless you are really, really sure what you are
25
- * doing.
26
- *
27
- * The SDK uses it for additional products to avoid validating for example the same table legs four
28
- * times at the same time. There we make sure the this cache only stays in scope for one user
29
- * interaction. No longer than the actions caused by a user clicking an option.
30
- */
31
- export declare function wrapWithPostValidateCache(postValidate: PostValidate): PostValidate;
32
- /** Does both wrapWithGetProductCache and wrapWithPostValidateCache. */
33
- export declare function wrapWithCache(loader: ProductLoader): ProductLoader;
1
+ import { DtoProductParamsWithCidAndLang, DtoValidateRequest } from "./CatalogueAPI.js";
2
+ import { CfgProductResponse, CfgValidateResponse } from "./utilitiesCatalogueData.js";
3
+ export declare type GetProduct = (params: DtoProductParamsWithCidAndLang) => Promise<CfgProductResponse>;
4
+ export declare type PostValidate = (params: DtoProductParamsWithCidAndLang, body: DtoValidateRequest) => Promise<CfgValidateResponse>;
5
+ export declare type ProductLoader = {
6
+ getProduct: GetProduct;
7
+ postValidate: PostValidate;
8
+ };
9
+ /**
10
+ * Wraps a getProduct function so that it caches for the time it lives.
11
+ *
12
+ * It has no cache invalidation or timeouts, so whatever ends up in the cache stays there
13
+ * indefinitely. For this reason we recommend using this with caution.
14
+ *
15
+ * In our Example App we use it to cache the internal calls in additional products as in such a
16
+ * product you tend to frequently get calls to same sub-product. Such as loading the same table leg
17
+ * four times.
18
+ */
19
+ export declare function wrapWithGetProductCache(getProduct: GetProduct): GetProduct;
20
+ /**
21
+ * Wraps a postValidate function so that it caches for the time it lives.
22
+ *
23
+ * It has no cache invalidation or timeouts, so whatever ends up in the cache stays there
24
+ * indefinitely. We recommend you do not use this unless you are really, really sure what you are
25
+ * doing.
26
+ *
27
+ * The SDK uses it for additional products to avoid validating for example the same table legs four
28
+ * times at the same time. There we make sure the this cache only stays in scope for one user
29
+ * interaction. No longer than the actions caused by a user clicking an option.
30
+ */
31
+ export declare function wrapWithPostValidateCache(postValidate: PostValidate): PostValidate;
32
+ /** Does both wrapWithGetProductCache and wrapWithPostValidateCache. */
33
+ export declare function wrapWithCache(loader: ProductLoader): ProductLoader;
34
34
  //# sourceMappingURL=productLoader.d.ts.map