@configura/web-api 2.0.0 → 2.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) 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 +622 -622
  5. package/dist/CatalogueAPI.js +329 -329
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +344 -344
  9. package/dist/CfgProduct.js +990 -991
  10. package/dist/CfgReferencePathHelper.d.ts +26 -26
  11. package/dist/CfgReferencePathHelper.js +26 -26
  12. package/dist/index.d.ts +23 -23
  13. package/dist/index.js +23 -23
  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 -64
  21. package/dist/io/CfgIOProdConfConnector.js +137 -149
  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 -14
  27. package/dist/io/CfgObservableStateToProdConfConnector.js +17 -16
  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 -16
  33. package/dist/io/CfgWindowMessageToProdConfConnector.js +19 -18
  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 +192 -192
  47. package/dist/productConfiguration/CfgFeature.js +664 -663
  48. package/dist/productConfiguration/CfgOption.d.ts +157 -157
  49. package/dist/productConfiguration/CfgOption.js +444 -444
  50. package/dist/productConfiguration/CfgProductConfiguration.d.ts +128 -128
  51. package/dist/productConfiguration/CfgProductConfiguration.js +331 -331
  52. package/dist/productConfiguration/filters.d.ts +17 -15
  53. package/dist/productConfiguration/filters.js +141 -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 +87 -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/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 +189 -189
  90. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  91. package/dist/tests/testData/testDataUpcharge.js +121 -121
  92. package/dist/utilitiesCatalogueData.d.ts +47 -47
  93. package/dist/utilitiesCatalogueData.js +180 -180
  94. package/dist/utilitiesCataloguePermission.d.ts +38 -38
  95. package/dist/utilitiesCataloguePermission.js +79 -79
  96. package/dist/{ConfigurationConverter.d.ts → utilitiesConfiguration.d.ts} +29 -18
  97. package/dist/{ConfigurationConverter.js → utilitiesConfiguration.js} +200 -175
  98. package/dist/utilitiesNumericValues.d.ts +24 -24
  99. package/dist/utilitiesNumericValues.js +114 -114
  100. package/package.json +3 -3
@@ -1,180 +1,180 @@
1
- import { shallowCompareDictionaries } from "@configura/web-utilities";
2
- /**
3
- * Makes a string from the params which can be used as a key in for example React. Language is not respected.
4
- */
5
- export const makeCatalogueKey = (cat) => `${cat.cid}-${cat.enterprise}-${cat.prdCat}-${cat.prdCatVersion}-${cat.priceList}-${cat.vendor}`;
6
- /**
7
- * Makes a string from the params which can be used as a key in for example React. Language is not respected.
8
- */
9
- export const makeProductKey = (prod) => `${makeCatalogueKey(prod)}-${prod.partNumber}`;
10
- /**
11
- * Makes a string from selected options, can be used as a key for a selection.
12
- */
13
- export const makeSelOptionsKey = (options) => options.reduce((p, option) => {
14
- var _a;
15
- const { code, numericValue, next } = option;
16
- p += `_{${code}`;
17
- p += numericValue === undefined ? "" : `_${numericValue.value}${(_a = numericValue.unit) !== null && _a !== void 0 ? _a : ""}`;
18
- if (next === undefined) {
19
- return p;
20
- }
21
- for (const key of Object.keys(next)) {
22
- const innerOption = next[key];
23
- p += `_{${key}_${makeSelOptionsKey([innerOption])}_}`;
24
- }
25
- p += "_}";
26
- return p;
27
- }, "");
28
- /**
29
- * Deep compare. Uses the JSON.stringify method for comparison
30
- * @returns true if equal. Key and array order is respected.
31
- */
32
- export function compareCfgProductData(pd1, pd2) {
33
- return JSON.stringify(pd1) === JSON.stringify(pd2);
34
- }
35
- export function isModel(arg) {
36
- return typeof arg === "object" && arg !== null && "cid" in arg && "uri" in arg;
37
- }
38
- /** Replace empty strings with "-" for compatibility with the API. */
39
- export function correctDefaultsOnCatalogueParams(catId) {
40
- // Enterprise, prdCat and vendor have to be set, so we don't try and fix those
41
- return Object.assign(Object.assign({}, catId), { prdCatVersion: catId.prdCatVersion || "-", priceList: catId.priceList || "-" });
42
- }
43
- export function recursivelyGetPriceCodeValue(priceCodes, prices) {
44
- while (prices) {
45
- for (const name of priceCodes) {
46
- const priceCodeUpcharge = prices === null || prices === void 0 ? void 0 : prices.values[name];
47
- if (priceCodeUpcharge !== undefined) {
48
- return priceCodeUpcharge;
49
- }
50
- }
51
- prices = prices.parent;
52
- }
53
- return undefined;
54
- }
55
- export function comparePricesObjects(prices1, prices2) {
56
- if (prices1 === undefined && prices2 === undefined) {
57
- return true;
58
- }
59
- if (prices1 === undefined || prices2 === undefined) {
60
- return false;
61
- }
62
- const parent1 = prices1.parent;
63
- const parent2 = prices2.parent;
64
- if (!comparePricesObjects(parent1, parent2)) {
65
- return false;
66
- }
67
- return shallowCompareDictionaries(prices1.values, prices2.values);
68
- }
69
- export const decodeCatalogueParams = (params) => (Object.assign(Object.assign({}, params), { enterprise: decodeURIComponent(params.enterprise), prdCat: decodeURIComponent(params.prdCat), prdCatVersion: decodeURIComponent(params.prdCatVersion), priceList: decodeURIComponent(params.priceList), vendor: decodeURIComponent(params.vendor) }));
70
- export const decodeProductParams = (params) => (Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) }));
71
- export function isSameCatalogueParams(left, right) {
72
- return (left.enterprise === right.enterprise &&
73
- left.prdCat === right.prdCat &&
74
- left.prdCatVersion === right.prdCatVersion &&
75
- left.priceList === right.priceList &&
76
- left.vendor === right.vendor);
77
- }
78
- export function isSameVector(left, right) {
79
- return left.x === right.x && left.y === right.y && left.z === right.z;
80
- }
81
- export function isSameOrientation(left, right) {
82
- return left.pitch === right.pitch && left.roll === right.roll && left.yaw === right.yaw;
83
- }
84
- export function isSameAnchor(left, right) {
85
- var _a, _b;
86
- if (left.code !== right.code) {
87
- return false;
88
- }
89
- if (left.anchorPoint !== right.anchorPoint) {
90
- return false;
91
- }
92
- const leftMeasurePriorities = (_a = left.measurePriority) !== null && _a !== void 0 ? _a : [];
93
- const rightMeasurePriorities = (_b = right.measurePriority) !== null && _b !== void 0 ? _b : [];
94
- if (leftMeasurePriorities.length !== rightMeasurePriorities.length) {
95
- return false;
96
- }
97
- if (leftMeasurePriorities.some((p, i) => p.url !== rightMeasurePriorities[i].url)) {
98
- return false;
99
- }
100
- return true;
101
- }
102
- export function isSameTransform(left, right) {
103
- const leftTransformPos = left.pos;
104
- const rightTransformPos = right.pos;
105
- const leftTransformRot = left.rot;
106
- const rightTransformRot = right.rot;
107
- const leftTransformScale = left.scale;
108
- const rightTransformScale = right.scale;
109
- if ((leftTransformPos === undefined) !== (rightTransformPos === undefined)) {
110
- return false;
111
- }
112
- if ((leftTransformRot === undefined) !== (rightTransformRot === undefined)) {
113
- return false;
114
- }
115
- if ((leftTransformScale === undefined) !== (rightTransformScale === undefined)) {
116
- return false;
117
- }
118
- if (leftTransformPos !== undefined &&
119
- rightTransformPos !== undefined &&
120
- !isSameVector(leftTransformPos, rightTransformPos)) {
121
- return false;
122
- }
123
- if (leftTransformRot !== undefined &&
124
- rightTransformRot !== undefined &&
125
- !isSameOrientation(leftTransformRot, rightTransformRot)) {
126
- return false;
127
- }
128
- if (leftTransformScale !== undefined &&
129
- rightTransformScale !== undefined &&
130
- !isSameVector(leftTransformScale, rightTransformScale)) {
131
- return false;
132
- }
133
- return true;
134
- }
135
- export function isSameProductRef(left, right) {
136
- if (left.refKey !== right.refKey) {
137
- return false;
138
- }
139
- if (left.partNumber !== right.partNumber) {
140
- return false;
141
- }
142
- if (!isSameCatalogueParams(left.catId, right.catId)) {
143
- return false;
144
- }
145
- if (left.refDescription !== right.refDescription) {
146
- return false;
147
- }
148
- const leftAnchor = left.anchor;
149
- const rightAnchor = right.anchor;
150
- if ((leftAnchor === undefined) !== (rightAnchor === undefined)) {
151
- return false;
152
- }
153
- if (leftAnchor !== undefined &&
154
- rightAnchor !== undefined &&
155
- !isSameAnchor(leftAnchor, rightAnchor)) {
156
- return false;
157
- }
158
- const leftTransform = left.transform;
159
- const rightTransform = right.transform;
160
- if ((leftTransform === undefined) !== (rightTransform === undefined)) {
161
- return false;
162
- }
163
- if (leftTransform !== undefined &&
164
- rightTransform !== undefined &&
165
- !isSameTransform(leftTransform, rightTransform)) {
166
- return false;
167
- }
168
- if (left.optional !== right.optional) {
169
- return false;
170
- }
171
- return true;
172
- }
173
- export const isSameDtoCatalogueParamsWithLang = (left, right) => left.cid === right.cid &&
174
- left.lang === right.lang &&
175
- left.enterprise === right.enterprise &&
176
- left.prdCat === right.prdCat &&
177
- left.prdCatVersion === right.prdCatVersion &&
178
- left.priceList === right.priceList &&
179
- left.vendor === right.vendor;
180
- export const isSameDtoProductParamsWithLang = (left, right) => isSameDtoCatalogueParamsWithLang(left, right) && left.partNumber === right.partNumber;
1
+ import { shallowCompareDictionaries } from "@configura/web-utilities";
2
+ /**
3
+ * Makes a string from the params which can be used as a key in for example React. Language is not respected.
4
+ */
5
+ export const makeCatalogueKey = (cat) => `${cat.cid}-${cat.enterprise}-${cat.prdCat}-${cat.prdCatVersion}-${cat.priceList}-${cat.vendor}`;
6
+ /**
7
+ * Makes a string from the params which can be used as a key in for example React. Language is not respected.
8
+ */
9
+ export const makeProductKey = (prod) => `${makeCatalogueKey(prod)}-${prod.partNumber}`;
10
+ /**
11
+ * Makes a string from selected options, can be used as a key for a selection.
12
+ */
13
+ export const makeSelOptionsKey = (options) => options.reduce((p, option) => {
14
+ var _a;
15
+ const { code, numericValue, next } = option;
16
+ p += `_{${code}`;
17
+ p += numericValue === undefined ? "" : `_${numericValue.value}${(_a = numericValue.unit) !== null && _a !== void 0 ? _a : ""}`;
18
+ if (next === undefined) {
19
+ return p;
20
+ }
21
+ for (const key of Object.keys(next)) {
22
+ const innerOption = next[key];
23
+ p += `_{${key}_${makeSelOptionsKey([innerOption])}_}`;
24
+ }
25
+ p += "_}";
26
+ return p;
27
+ }, "");
28
+ /**
29
+ * Deep compare. Uses the JSON.stringify method for comparison
30
+ * @returns true if equal. Key and array order is respected.
31
+ */
32
+ export function compareCfgProductData(pd1, pd2) {
33
+ return JSON.stringify(pd1) === JSON.stringify(pd2);
34
+ }
35
+ export function isModel(arg) {
36
+ return typeof arg === "object" && arg !== null && "cid" in arg && "uri" in arg;
37
+ }
38
+ /** Replace empty strings with "-" for compatibility with the API. */
39
+ export function correctDefaultsOnCatalogueParams(catId) {
40
+ // Enterprise, prdCat and vendor have to be set, so we don't try and fix those
41
+ return Object.assign(Object.assign({}, catId), { prdCatVersion: catId.prdCatVersion || "-", priceList: catId.priceList || "-" });
42
+ }
43
+ export function recursivelyGetPriceCodeValue(priceCodes, prices) {
44
+ while (prices) {
45
+ for (const name of priceCodes) {
46
+ const priceCodeUpcharge = prices === null || prices === void 0 ? void 0 : prices.values[name];
47
+ if (priceCodeUpcharge !== undefined) {
48
+ return priceCodeUpcharge;
49
+ }
50
+ }
51
+ prices = prices.parent;
52
+ }
53
+ return undefined;
54
+ }
55
+ export function comparePricesObjects(prices1, prices2) {
56
+ if (prices1 === undefined && prices2 === undefined) {
57
+ return true;
58
+ }
59
+ if (prices1 === undefined || prices2 === undefined) {
60
+ return false;
61
+ }
62
+ const parent1 = prices1.parent;
63
+ const parent2 = prices2.parent;
64
+ if (!comparePricesObjects(parent1, parent2)) {
65
+ return false;
66
+ }
67
+ return shallowCompareDictionaries(prices1.values, prices2.values);
68
+ }
69
+ export const decodeCatalogueParams = (params) => (Object.assign(Object.assign({}, params), { enterprise: decodeURIComponent(params.enterprise), prdCat: decodeURIComponent(params.prdCat), prdCatVersion: decodeURIComponent(params.prdCatVersion), priceList: decodeURIComponent(params.priceList), vendor: decodeURIComponent(params.vendor) }));
70
+ export const decodeProductParams = (params) => (Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) }));
71
+ export function isSameCatalogueParams(left, right) {
72
+ return (left.enterprise === right.enterprise &&
73
+ left.prdCat === right.prdCat &&
74
+ left.prdCatVersion === right.prdCatVersion &&
75
+ left.priceList === right.priceList &&
76
+ left.vendor === right.vendor);
77
+ }
78
+ export function isSameVector(left, right) {
79
+ return left.x === right.x && left.y === right.y && left.z === right.z;
80
+ }
81
+ export function isSameOrientation(left, right) {
82
+ return left.pitch === right.pitch && left.roll === right.roll && left.yaw === right.yaw;
83
+ }
84
+ export function isSameAnchor(left, right) {
85
+ var _a, _b;
86
+ if (left.code !== right.code) {
87
+ return false;
88
+ }
89
+ if (left.anchorPoint !== right.anchorPoint) {
90
+ return false;
91
+ }
92
+ const leftMeasurePriorities = (_a = left.measurePriority) !== null && _a !== void 0 ? _a : [];
93
+ const rightMeasurePriorities = (_b = right.measurePriority) !== null && _b !== void 0 ? _b : [];
94
+ if (leftMeasurePriorities.length !== rightMeasurePriorities.length) {
95
+ return false;
96
+ }
97
+ if (leftMeasurePriorities.some((p, i) => p.url !== rightMeasurePriorities[i].url)) {
98
+ return false;
99
+ }
100
+ return true;
101
+ }
102
+ export function isSameTransform(left, right) {
103
+ const leftTransformPos = left.pos;
104
+ const rightTransformPos = right.pos;
105
+ const leftTransformRot = left.rot;
106
+ const rightTransformRot = right.rot;
107
+ const leftTransformScale = left.scale;
108
+ const rightTransformScale = right.scale;
109
+ if ((leftTransformPos === undefined) !== (rightTransformPos === undefined)) {
110
+ return false;
111
+ }
112
+ if ((leftTransformRot === undefined) !== (rightTransformRot === undefined)) {
113
+ return false;
114
+ }
115
+ if ((leftTransformScale === undefined) !== (rightTransformScale === undefined)) {
116
+ return false;
117
+ }
118
+ if (leftTransformPos !== undefined &&
119
+ rightTransformPos !== undefined &&
120
+ !isSameVector(leftTransformPos, rightTransformPos)) {
121
+ return false;
122
+ }
123
+ if (leftTransformRot !== undefined &&
124
+ rightTransformRot !== undefined &&
125
+ !isSameOrientation(leftTransformRot, rightTransformRot)) {
126
+ return false;
127
+ }
128
+ if (leftTransformScale !== undefined &&
129
+ rightTransformScale !== undefined &&
130
+ !isSameVector(leftTransformScale, rightTransformScale)) {
131
+ return false;
132
+ }
133
+ return true;
134
+ }
135
+ export function isSameProductRef(left, right) {
136
+ if (left.refKey !== right.refKey) {
137
+ return false;
138
+ }
139
+ if (left.partNumber !== right.partNumber) {
140
+ return false;
141
+ }
142
+ if (!isSameCatalogueParams(left.catId, right.catId)) {
143
+ return false;
144
+ }
145
+ if (left.refDescription !== right.refDescription) {
146
+ return false;
147
+ }
148
+ const leftAnchor = left.anchor;
149
+ const rightAnchor = right.anchor;
150
+ if ((leftAnchor === undefined) !== (rightAnchor === undefined)) {
151
+ return false;
152
+ }
153
+ if (leftAnchor !== undefined &&
154
+ rightAnchor !== undefined &&
155
+ !isSameAnchor(leftAnchor, rightAnchor)) {
156
+ return false;
157
+ }
158
+ const leftTransform = left.transform;
159
+ const rightTransform = right.transform;
160
+ if ((leftTransform === undefined) !== (rightTransform === undefined)) {
161
+ return false;
162
+ }
163
+ if (leftTransform !== undefined &&
164
+ rightTransform !== undefined &&
165
+ !isSameTransform(leftTransform, rightTransform)) {
166
+ return false;
167
+ }
168
+ if (left.optional !== right.optional) {
169
+ return false;
170
+ }
171
+ return true;
172
+ }
173
+ export const isSameDtoCatalogueParamsWithLang = (left, right) => left.cid === right.cid &&
174
+ left.lang === right.lang &&
175
+ left.enterprise === right.enterprise &&
176
+ left.prdCat === right.prdCat &&
177
+ left.prdCatVersion === right.prdCatVersion &&
178
+ left.priceList === right.priceList &&
179
+ left.vendor === right.vendor;
180
+ export const isSameDtoProductParamsWithLang = (left, right) => isSameDtoCatalogueParamsWithLang(left, right) && left.partNumber === right.partNumber;
@@ -1,39 +1,39 @@
1
- import { DtoCatalogueParamsWithCid, DtoCataloguePermission } from "./CatalogueAPI.js";
2
- interface CataloguePermissionByEnterpriseKey {
3
- [key: string]: DtoCataloguePermission[];
4
- }
5
- export declare const groupAndSortCataloguePermissions: (cataloguePermissions: DtoCataloguePermission[]) => CataloguePermissionByEnterpriseKey;
6
- export declare const isParamSet: (param: string | undefined) => boolean;
7
- export declare const createCataloguePermissionsFilter: (catParams: Partial<DtoCatalogueParamsWithCid>) => (perm: DtoCataloguePermission) => boolean;
8
- /**
9
- * Sometimes you will want to use the latest available prdCatVersion. This method will
10
- * find the highest prdCatVersion version in the cataloguePermissions. If the versions are
11
- * numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
12
- * string compare.
13
- */
14
- export declare const getPrdCatVersionFromPermissions: (cataloguePermissions: DtoCataloguePermission[], catParams: {
15
- cid: number | undefined;
16
- enterprise: string | undefined;
17
- prdCat: string | undefined;
18
- priceList: string | undefined;
19
- vendor: string | undefined;
20
- }) => string | undefined;
21
- /**
22
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
23
- * This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
24
- * permissions. If it fails to find any applicable permissions the original value is returned.
25
- * @param auth
26
- * @param params
27
- */
28
- export declare const getPrdCatVersionOrLatestFromPermissions: (params: DtoCatalogueParamsWithCid, cataloguePermissions: DtoCataloguePermission[]) => string;
29
- /**
30
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
31
- * This method will, if the prdCatVersion is not set, fetch the highest available from the
32
- * cataloguePermissions and insert it into a copy of the original params. If it fails to find any
33
- * applicable auth-permissions the original value is returned.
34
- * @param auth
35
- * @param params
36
- */
37
- export declare const fillMissingPrdCatVersionFromPermissions: <T extends DtoCatalogueParamsWithCid>(params: T, cataloguePermissions: DtoCataloguePermission[]) => T;
38
- export {};
1
+ import { DtoCatalogueParamsWithCid, DtoCataloguePermission } from "./CatalogueAPI.js";
2
+ interface CataloguePermissionByEnterpriseKey {
3
+ [key: string]: DtoCataloguePermission[];
4
+ }
5
+ export declare const groupAndSortCataloguePermissions: (cataloguePermissions: DtoCataloguePermission[]) => CataloguePermissionByEnterpriseKey;
6
+ export declare const isParamSet: (param: string | undefined) => boolean;
7
+ export declare const createCataloguePermissionsFilter: (catParams: Partial<DtoCatalogueParamsWithCid>) => (perm: DtoCataloguePermission) => boolean;
8
+ /**
9
+ * Sometimes you will want to use the latest available prdCatVersion. This method will
10
+ * find the highest prdCatVersion version in the cataloguePermissions. If the versions are
11
+ * numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
12
+ * string compare.
13
+ */
14
+ export declare const getPrdCatVersionFromPermissions: (cataloguePermissions: DtoCataloguePermission[], catParams: {
15
+ cid: number | undefined;
16
+ enterprise: string | undefined;
17
+ prdCat: string | undefined;
18
+ priceList: string | undefined;
19
+ vendor: string | undefined;
20
+ }) => string | undefined;
21
+ /**
22
+ * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
23
+ * This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
24
+ * permissions. If it fails to find any applicable permissions the original value is returned.
25
+ * @param auth
26
+ * @param params
27
+ */
28
+ export declare const getPrdCatVersionOrLatestFromPermissions: (params: DtoCatalogueParamsWithCid, cataloguePermissions: DtoCataloguePermission[]) => string;
29
+ /**
30
+ * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
31
+ * This method will, if the prdCatVersion is not set, fetch the highest available from the
32
+ * cataloguePermissions and insert it into a copy of the original params. If it fails to find any
33
+ * applicable auth-permissions the original value is returned.
34
+ * @param auth
35
+ * @param params
36
+ */
37
+ export declare const fillMissingPrdCatVersionFromPermissions: <T extends DtoCatalogueParamsWithCid>(params: T, cataloguePermissions: DtoCataloguePermission[]) => T;
38
+ export {};
39
39
  //# sourceMappingURL=utilitiesCataloguePermission.d.ts.map
@@ -1,79 +1,79 @@
1
- export const groupAndSortCataloguePermissions = (cataloguePermissions) => {
2
- const cataloguePermissionByEnterpriseKey = {};
3
- cataloguePermissions
4
- // Sort by enterprise
5
- .sort((a, b) => a.enterprise.toLocaleLowerCase().localeCompare(b.enterprise.toLocaleLowerCase()))
6
- .forEach((c) => {
7
- const enterprise = c.enterprise.toLowerCase();
8
- if (cataloguePermissionByEnterpriseKey[enterprise] === undefined) {
9
- cataloguePermissionByEnterpriseKey[enterprise] = [];
10
- }
11
- cataloguePermissionByEnterpriseKey[enterprise].push(c);
12
- });
13
- // Sort by prdcat
14
- Object.keys(cataloguePermissionByEnterpriseKey).forEach((enterprise) => cataloguePermissionByEnterpriseKey[enterprise].sort((a, b) => a.prdCat.toLocaleLowerCase().localeCompare(b.prdCat.toLocaleLowerCase())));
15
- return cataloguePermissionByEnterpriseKey;
16
- };
17
- export const isParamSet = (param) => param !== undefined && param !== "" && param !== "-";
18
- export const createCataloguePermissionsFilter = (catParams) => {
19
- const { cid, enterprise, prdCat, prdCatVersion, vendor, priceList } = catParams;
20
- return (perm) => (cid === undefined || cid === perm.cid) &&
21
- (!isParamSet(enterprise) || enterprise === perm.enterprise) &&
22
- (!isParamSet(prdCat) || prdCat === perm.prdCat) &&
23
- (!isParamSet(prdCatVersion) || prdCatVersion === perm.prdCatVersion) &&
24
- (!isParamSet(vendor) ||
25
- perm.vendors === undefined ||
26
- perm.vendors.some((v) => vendor === v)) &&
27
- (!isParamSet(priceList) ||
28
- perm.priceLists === undefined ||
29
- perm.priceLists.some((p) => priceList === p));
30
- };
31
- /**
32
- * Sometimes you will want to use the latest available prdCatVersion. This method will
33
- * find the highest prdCatVersion version in the cataloguePermissions. If the versions are
34
- * numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
35
- * string compare.
36
- */
37
- export const getPrdCatVersionFromPermissions = (cataloguePermissions, catParams) => {
38
- const filter = createCataloguePermissionsFilter(Object.assign(Object.assign({}, catParams), { prdCatVersion: undefined }));
39
- const applicablePermissions = cataloguePermissions.filter(filter);
40
- return applicablePermissions.reduce((pVersion, c) => {
41
- const cVersion = c.prdCatVersion;
42
- if (pVersion === undefined) {
43
- return cVersion;
44
- }
45
- const pNum = parseFloat(pVersion);
46
- const cNum = parseFloat(cVersion);
47
- if (isNaN(pNum) || isNaN(cNum)) {
48
- return pVersion < cVersion ? cVersion : pVersion;
49
- }
50
- return pNum < cNum ? cVersion : pVersion;
51
- }, undefined);
52
- };
53
- /**
54
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
55
- * This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
56
- * permissions. If it fails to find any applicable permissions the original value is returned.
57
- * @param auth
58
- * @param params
59
- */
60
- export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermissions) => {
61
- const { prdCatVersion } = params;
62
- if (isParamSet(prdCatVersion)) {
63
- return prdCatVersion;
64
- }
65
- const highestFoundVersion = getPrdCatVersionFromPermissions(cataloguePermissions, params);
66
- if (highestFoundVersion === undefined) {
67
- return prdCatVersion;
68
- }
69
- return highestFoundVersion;
70
- };
71
- /**
72
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
73
- * This method will, if the prdCatVersion is not set, fetch the highest available from the
74
- * cataloguePermissions and insert it into a copy of the original params. If it fails to find any
75
- * applicable auth-permissions the original value is returned.
76
- * @param auth
77
- * @param params
78
- */
79
- export const fillMissingPrdCatVersionFromPermissions = (params, cataloguePermissions) => (Object.assign(Object.assign({}, params), { prdCatVersion: getPrdCatVersionOrLatestFromPermissions(params, cataloguePermissions) }));
1
+ export const groupAndSortCataloguePermissions = (cataloguePermissions) => {
2
+ const cataloguePermissionByEnterpriseKey = {};
3
+ cataloguePermissions
4
+ // Sort by enterprise
5
+ .sort((a, b) => a.enterprise.toLocaleLowerCase().localeCompare(b.enterprise.toLocaleLowerCase()))
6
+ .forEach((c) => {
7
+ const enterprise = c.enterprise.toLowerCase();
8
+ if (cataloguePermissionByEnterpriseKey[enterprise] === undefined) {
9
+ cataloguePermissionByEnterpriseKey[enterprise] = [];
10
+ }
11
+ cataloguePermissionByEnterpriseKey[enterprise].push(c);
12
+ });
13
+ // Sort by prdcat
14
+ Object.keys(cataloguePermissionByEnterpriseKey).forEach((enterprise) => cataloguePermissionByEnterpriseKey[enterprise].sort((a, b) => a.prdCat.toLocaleLowerCase().localeCompare(b.prdCat.toLocaleLowerCase())));
15
+ return cataloguePermissionByEnterpriseKey;
16
+ };
17
+ export const isParamSet = (param) => param !== undefined && param !== "" && param !== "-";
18
+ export const createCataloguePermissionsFilter = (catParams) => {
19
+ const { cid, enterprise, prdCat, prdCatVersion, vendor, priceList } = catParams;
20
+ return (perm) => (cid === undefined || cid === perm.cid) &&
21
+ (!isParamSet(enterprise) || enterprise === perm.enterprise) &&
22
+ (!isParamSet(prdCat) || prdCat === perm.prdCat) &&
23
+ (!isParamSet(prdCatVersion) || prdCatVersion === perm.prdCatVersion) &&
24
+ (!isParamSet(vendor) ||
25
+ perm.vendors === undefined ||
26
+ perm.vendors.some((v) => vendor === v)) &&
27
+ (!isParamSet(priceList) ||
28
+ perm.priceLists === undefined ||
29
+ perm.priceLists.some((p) => priceList === p));
30
+ };
31
+ /**
32
+ * Sometimes you will want to use the latest available prdCatVersion. This method will
33
+ * find the highest prdCatVersion version in the cataloguePermissions. If the versions are
34
+ * numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
35
+ * string compare.
36
+ */
37
+ export const getPrdCatVersionFromPermissions = (cataloguePermissions, catParams) => {
38
+ const filter = createCataloguePermissionsFilter(Object.assign(Object.assign({}, catParams), { prdCatVersion: undefined }));
39
+ const applicablePermissions = cataloguePermissions.filter(filter);
40
+ return applicablePermissions.reduce((pVersion, c) => {
41
+ const cVersion = c.prdCatVersion;
42
+ if (pVersion === undefined) {
43
+ return cVersion;
44
+ }
45
+ const pNum = parseFloat(pVersion);
46
+ const cNum = parseFloat(cVersion);
47
+ if (isNaN(pNum) || isNaN(cNum)) {
48
+ return pVersion < cVersion ? cVersion : pVersion;
49
+ }
50
+ return pNum < cNum ? cVersion : pVersion;
51
+ }, undefined);
52
+ };
53
+ /**
54
+ * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
55
+ * This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
56
+ * permissions. If it fails to find any applicable permissions the original value is returned.
57
+ * @param auth
58
+ * @param params
59
+ */
60
+ export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermissions) => {
61
+ const { prdCatVersion } = params;
62
+ if (isParamSet(prdCatVersion)) {
63
+ return prdCatVersion;
64
+ }
65
+ const highestFoundVersion = getPrdCatVersionFromPermissions(cataloguePermissions, params);
66
+ if (highestFoundVersion === undefined) {
67
+ return prdCatVersion;
68
+ }
69
+ return highestFoundVersion;
70
+ };
71
+ /**
72
+ * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
73
+ * This method will, if the prdCatVersion is not set, fetch the highest available from the
74
+ * cataloguePermissions and insert it into a copy of the original params. If it fails to find any
75
+ * applicable auth-permissions the original value is returned.
76
+ * @param auth
77
+ * @param params
78
+ */
79
+ export const fillMissingPrdCatVersionFromPermissions = (params, cataloguePermissions) => (Object.assign(Object.assign({}, params), { prdCatVersion: getPrdCatVersionOrLatestFromPermissions(params, cataloguePermissions) }));
@@ -1,18 +1,29 @@
1
- import { DtoAdditionalProductConf, DtoAdditionalProductConfiguration, DtoFeatureConf, DtoProductConf, DtoSelectedOption } from "./CatalogueAPI.js";
2
- /** Is the newer version of product configuration */
3
- export declare const isProductConf: (value: DtoAdditionalProductConfiguration | DtoProductConf) => value is DtoAdditionalProductConf;
4
- /** Is the older version of product configuration */
5
- export declare const isAdditionalProductConfiguration: (value: DtoAdditionalProductConfiguration | DtoProductConf) => value is DtoAdditionalProductConfiguration;
6
- export declare const isDtoProductConfAdditional: (value: DtoProductConf) => value is DtoAdditionalProductConf;
7
- export declare const convertDtoProductConfToV1: (conf: DtoProductConf, silenceWarnings?: boolean) => DtoAdditionalProductConfiguration;
8
- export declare const convertDtoFeatureConfsToSelOptions: (features: DtoFeatureConf[], silenceWarnings?: boolean) => DtoSelectedOption[];
9
- /**
10
- * Serializes and compacts the configuration into a format especially suited for URLs
11
- */
12
- export declare const dtoProductConfigurationToCompactString: (conf: DtoProductConf) => string;
13
- /**
14
- * Deserializes and inflates the configuration from the compacted format
15
- */
16
- export declare const compactStringToDtoProductConf: (versionAndConf: string) => DtoProductConf;
17
- export declare const stripExtendedDataFromDtoProductConf: (conf: DtoProductConf) => DtoProductConf;
18
- //# sourceMappingURL=ConfigurationConverter.d.ts.map
1
+ import { DtoAdditionalProductConf, DtoAdditionalProductConfiguration, DtoFeatureConf, DtoProductConf, DtoSelectedOption } from "./CatalogueAPI.js";
2
+ /**
3
+ * @param ExtendedData Extra data, i.e. units and groupCodes
4
+ * @param ProductParams What Product the conf is for, and the same for any Additional Products.
5
+ * @param SyncGroupState The current sync group state
6
+ */
7
+ export declare enum CfgProdConfParts {
8
+ NoExtra = 0,
9
+ ExtendedData = 1,
10
+ ProdParams = 2,
11
+ SyncGroupState = 4
12
+ }
13
+ /** Is the newer version of product configuration */
14
+ export declare const isProductConf: (value: DtoAdditionalProductConfiguration | DtoProductConf) => value is DtoAdditionalProductConf;
15
+ /** Is the older version of product configuration */
16
+ export declare const isAdditionalProductConfiguration: (value: DtoAdditionalProductConfiguration | DtoProductConf) => value is DtoAdditionalProductConfiguration;
17
+ export declare const isDtoProductConfAdditional: (value: DtoProductConf) => value is DtoAdditionalProductConf;
18
+ export declare const convertDtoProductConfToV1: (conf: DtoProductConf, silenceWarnings?: boolean) => DtoAdditionalProductConfiguration;
19
+ export declare const convertDtoFeatureConfsToSelOptions: (features: DtoFeatureConf[], silenceWarnings?: boolean) => DtoSelectedOption[];
20
+ /**
21
+ * Serializes and compacts the configuration into a format especially suited for URLs
22
+ */
23
+ export declare const dtoProductConfigurationToCompactString: (conf: DtoProductConf) => string;
24
+ /**
25
+ * Deserializes and inflates the configuration from the compacted format
26
+ */
27
+ export declare const compactStringToDtoProductConf: (versionAndConf: string) => DtoProductConf;
28
+ export declare const stripExtendedDataFromDtoProductConf: (conf: DtoProductConf, toStrip: CfgProdConfParts) => DtoProductConf;
29
+ //# sourceMappingURL=utilitiesConfiguration.d.ts.map