@configura/web-api 1.6.1 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/.eslintrc.json +18 -18
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/CatalogueAPI.d.ts +551 -507
  5. package/dist/CatalogueAPI.js +293 -280
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +268 -258
  9. package/dist/CfgProduct.js +778 -747
  10. package/dist/CfgReferencePathHelper.d.ts +14 -0
  11. package/dist/CfgReferencePathHelper.js +13 -0
  12. package/dist/ConfigurationConverter.d.ts +5 -0
  13. package/dist/ConfigurationConverter.js +72 -0
  14. package/dist/index.d.ts +23 -20
  15. package/dist/index.js +23 -20
  16. package/dist/io/CfgHistoryManager.d.ts +51 -0
  17. package/dist/io/CfgHistoryManager.js +82 -0
  18. package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -0
  19. package/dist/io/CfgHistoryToProdConfConnector.js +56 -0
  20. package/dist/io/CfgIOManager.d.ts +49 -0
  21. package/dist/io/CfgIOManager.js +115 -0
  22. package/dist/io/CfgIOProdConfConnector.d.ts +53 -0
  23. package/dist/io/CfgIOProdConfConnector.js +141 -0
  24. package/dist/io/CfgObservableStateManager.d.ts +22 -0
  25. package/dist/io/CfgObservableStateManager.js +65 -0
  26. package/dist/io/CfgObservableStateToProdConfConnector.d.ts +15 -0
  27. package/dist/io/CfgObservableStateToProdConfConnector.js +16 -0
  28. package/dist/io/CfgWindowEventManager.d.ts +22 -0
  29. package/dist/io/CfgWindowEventManager.js +38 -0
  30. package/dist/io/CfgWindowMessageManager.d.ts +41 -0
  31. package/dist/io/CfgWindowMessageManager.js +84 -0
  32. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +17 -0
  33. package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -0
  34. package/dist/io/index.d.ts +9 -0
  35. package/dist/io/index.js +8 -0
  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 +187 -188
  47. package/dist/productConfiguration/CfgFeature.js +645 -636
  48. package/dist/productConfiguration/CfgOption.d.ts +151 -150
  49. package/dist/productConfiguration/CfgOption.js +416 -426
  50. package/dist/productConfiguration/CfgProductConfiguration.d.ts +117 -120
  51. package/dist/productConfiguration/CfgProductConfiguration.js +307 -309
  52. package/dist/productConfiguration/filters.d.ts +15 -15
  53. package/dist/productConfiguration/filters.js +70 -70
  54. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  55. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  56. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
  57. package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -80
  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 +40 -40
  63. package/dist/syncGroups/SyncGroupsHandler.js +359 -358
  64. package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
  65. package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
  66. package/dist/syncGroups/SyncGroupsState.d.ts +35 -35
  67. package/dist/syncGroups/SyncGroupsState.js +125 -125
  68. package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
  69. package/dist/syncGroups/SyncGroupsTransaction.js +576 -576
  70. package/dist/tasks/TaskHandler.d.ts +77 -78
  71. package/dist/tasks/TaskHandler.js +275 -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 -36
  78. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
  79. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +277 -277
  80. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  81. package/dist/tests/testData/testDataCachedGetProduct.js +185 -185
  82. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  83. package/dist/tests/testData/testDataCachedPostValidate.js +183 -183
  84. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  85. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
  86. package/dist/tests/testData/testDataOptions.d.ts +12 -12
  87. package/dist/tests/testData/testDataOptions.js +60 -60
  88. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
  89. package/dist/tests/testData/testDataProductAggregatedPrice.js +187 -187
  90. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  91. package/dist/tests/testData/testDataUpcharge.js +119 -119
  92. package/dist/utilitiesCatalogueData.d.ts +42 -31
  93. package/dist/utilitiesCatalogueData.js +173 -162
  94. package/dist/utilitiesCataloguePermission.d.ts +38 -37
  95. package/dist/utilitiesCataloguePermission.js +79 -80
  96. package/dist/utilitiesNumericValues.d.ts +24 -24
  97. package/dist/utilitiesNumericValues.js +109 -109
  98. package/package.json +3 -3
@@ -1,16 +1,16 @@
1
- import { Filters, Matches } from "@configura/web-utilities";
2
- import { CatalogueParams, Level, ProductRef } from "../CatalogueAPI.js";
3
- export declare function applyCatalogueFilters(filters: Filters<CatalogueParams>, catalogues: CatalogueParams[]): [Matches<CatalogueParams>, CatalogueParams[]];
4
- export interface ProductRefParams {
5
- partNr: string;
6
- }
7
- export declare function applyProductRefFilters(filters: Filters<ProductRefParams>, productRefs: ProductRef[]): [Matches<ProductRefParams>, ProductRef[]];
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: Level[], prdRefsFilter: ProductRef[], showEmpty: boolean, doSort?: boolean): Level[] | undefined;
1
+ import { Filters, Matches } from "@configura/web-utilities";
2
+ import { DtoCatalogueParamsWithoutCid, DtoLevel, DtoProductRef } from "../CatalogueAPI.js";
3
+ export declare function applyCatalogueFilters<T extends DtoCatalogueParamsWithoutCid>(filters: Filters<DtoCatalogueParamsWithoutCid>, catalogues: T[]): [Matches<DtoCatalogueParamsWithoutCid>, 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 { ApplicationAreasResponse, CatalogueAPI, CatalogueParams } from "../CatalogueAPI.js";
3
- import { CfgProduct, CfgProductSettings } from "../CfgProduct.js";
4
- import { ProductRefParams } from "./filters.js";
5
- export interface GeneratedProductConfiguration {
6
- applicationAreasResponse: ApplicationAreasResponse;
7
- catalogueCount: number;
8
- catalogueIndex: number;
9
- catalogueParams: CatalogueParams;
10
- getProductDuration: number;
11
- product: CfgProduct;
12
- productCount: number;
13
- productIndex: number;
14
- }
15
- export declare function generateProductConfigurations(api: CatalogueAPI, lang: string, catalogues: CatalogueParams[], filters: Filters<ProductRefParams>, settings?: Partial<CfgProductSettings>): AsyncIterableIterator<GeneratedProductConfiguration | Error>;
1
+ import { Filters } from "@configura/web-utilities";
2
+ import { CatalogueAPI, DtoApplicationAreasResponse, DtoCatalogueParams, DtoCatalogueParamsWithLang } 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: DtoCatalogueParamsWithLang;
10
+ getProductDuration: number;
11
+ product: CfgProduct;
12
+ productCount: number;
13
+ productIndex: number;
14
+ }
15
+ export declare function generateProductConfigurations(api: CatalogueAPI, lang: string, catalogues: DtoCatalogueParams[], 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, catalogueParams] of catalogueEntries) {
21
- const params = Object.assign(Object.assign({}, catalogueParams), { lang });
22
- try {
23
- const [applicationAreasResponse, toc] = yield __await(Promise.all([
24
- api.getApplicationAreas(params),
25
- api.getTocFlat(params),
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, lang, params, 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 { AdditionalProductRef, Feature, FeatureRef } 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: FeatureRef[], currentFeatures: CfgFeature[], allRawFeatures: Feature[], 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): AdditionalProductRef[];
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[], allRawFeatures: 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,80 +1,80 @@
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, allRawFeatures, parent, parentConfiguration, parentProduct, rootProduct) {
10
- const usedRawFeatures = newFeatureRefs
11
- .map((r) => r.code)
12
- .map((c) => {
13
- const rawFeature = allRawFeatures.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 && cfgF.key === key);
42
- if (existingFeature !== undefined) {
43
- newFeatures.push(existingFeature);
44
- continue;
45
- }
46
- newFeatures.push(CfgFeature.make(f, allRawFeatures, key, parent, parentConfiguration, parentProduct, rootProduct));
47
- }
48
- return newFeatures;
49
- }
50
- export function getMtrlPreview(mtrlApplications) {
51
- if (mtrlApplications === undefined) {
52
- return;
53
- }
54
- const first = mtrlApplications[0];
55
- if (first === undefined) {
56
- return;
57
- }
58
- return first.previewUrl;
59
- }
60
- /**
61
- * Recursively find all additional product references given a product configuration.
62
- * Only selected options are considered.
63
- */
64
- export function collectAdditionalProductRefs(parent) {
65
- function c(parent) {
66
- const result = [];
67
- if (parent instanceof CfgOption && parent.selected) {
68
- result.push(...(parent.rawOption.additionalProductRefs || []));
69
- }
70
- if (parent instanceof CfgProductConfiguration || parent.selected) {
71
- for (const feature of parent.features) {
72
- for (const option of feature.options) {
73
- result.push(...c(option));
74
- }
75
- }
76
- }
77
- return result;
78
- }
79
- return c(parent);
80
- }
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, allRawFeatures, parent, parentConfiguration, parentProduct, rootProduct) {
10
+ const usedRawFeatures = newFeatureRefs
11
+ .map((r) => r.code)
12
+ .map((c) => {
13
+ const rawFeature = allRawFeatures.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 && cfgF.key === key);
42
+ if (existingFeature !== undefined) {
43
+ newFeatures.push(existingFeature);
44
+ continue;
45
+ }
46
+ newFeatures.push(CfgFeature.make(f, allRawFeatures, key, parent, parentConfiguration, parentProduct, rootProduct));
47
+ }
48
+ return newFeatures;
49
+ }
50
+ export function getMtrlPreview(mtrlApplications) {
51
+ if (mtrlApplications === undefined) {
52
+ return;
53
+ }
54
+ const first = mtrlApplications[0];
55
+ if (first === undefined) {
56
+ return;
57
+ }
58
+ return first.previewUrl;
59
+ }
60
+ /**
61
+ * Recursively find all additional product references given a product configuration.
62
+ * Only selected options are considered.
63
+ */
64
+ export function collectAdditionalProductRefs(parent) {
65
+ function c(parent) {
66
+ const result = [];
67
+ if (parent instanceof CfgOption && parent.selected) {
68
+ result.push(...(parent.rawOption.additionalProductRefs || []));
69
+ }
70
+ if (parent instanceof CfgProductConfiguration || parent.selected) {
71
+ for (const feature of parent.features) {
72
+ for (const option of feature.options) {
73
+ result.push(...c(option));
74
+ }
75
+ }
76
+ }
77
+ return result;
78
+ }
79
+ return c(parent);
80
+ }
@@ -1,34 +1,34 @@
1
- import { GetProductParams, PostValidateParams, ValidateRequest } from "./CatalogueAPI.js";
2
- import { CfgProductResponse, CfgValidateResponse } from "./utilitiesCatalogueData.js";
3
- export declare type GetProduct = (params: GetProductParams) => Promise<CfgProductResponse>;
4
- export declare type PostValidate = (params: PostValidateParams, body: ValidateRequest) => 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 { DtoProductParamsWithLang, DtoValidateRequest } from "./CatalogueAPI.js";
2
+ import { CfgProductResponse, CfgValidateResponse } from "./utilitiesCatalogueData.js";
3
+ export declare type GetProduct = (params: DtoProductParamsWithLang) => Promise<CfgProductResponse>;
4
+ export declare type PostValidate = (params: DtoProductParamsWithLang, 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