@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,162 +1,173 @@
1
- import { shallowCompareDictionaries } from "@configura/web-utilities";
2
- export const makeCatalogueKey = (cat) => `${cat.enterprise}-${cat.prdCat}-${cat.prdCatVersion}-${cat.priceList}-${cat.vendor}`;
3
- export const makeProductKey = (cat, pKey) => `${makeCatalogueKey(cat)}-${pKey}`;
4
- export const makeSelOptionsKey = (options) => options.reduce((p, option) => {
5
- var _a;
6
- const { code, numericValue, next } = option;
7
- p += `_{${code}`;
8
- p += numericValue === undefined ? "" : `_${numericValue.value}${(_a = numericValue.unit) !== null && _a !== void 0 ? _a : ""}`;
9
- if (next === undefined) {
10
- return p;
11
- }
12
- for (const key of Object.keys(next)) {
13
- const innerOption = next[key];
14
- p += `_{${key}_${makeSelOptionsKey([innerOption])}_}`;
15
- }
16
- p += "_}";
17
- return p;
18
- }, "");
19
- export function isModel(arg) {
20
- return typeof arg === "object" && arg !== null && "cid" in arg && "uri" in arg;
21
- }
22
- /** Replace empty strings with "-" for compatibility with the API. */
23
- export function correctDefaultsOnCatalogueParams(catId) {
24
- // Enterprise, prdCat and vendor have to be set, so we don't try and fix those
25
- return {
26
- enterprise: catId.enterprise,
27
- prdCat: catId.prdCat,
28
- prdCatVersion: catId.prdCatVersion || "-",
29
- priceList: catId.priceList || "-",
30
- vendor: catId.vendor,
31
- };
32
- }
33
- export function recursivelyGetPriceCodeValue(priceCodes, prices) {
34
- while (prices) {
35
- for (const name of priceCodes) {
36
- const priceCodeUpcharge = prices === null || prices === void 0 ? void 0 : prices.values[name];
37
- if (priceCodeUpcharge !== undefined) {
38
- return priceCodeUpcharge;
39
- }
40
- }
41
- prices = prices.parent;
42
- }
43
- return undefined;
44
- }
45
- export function comparePricesObjects(prices1, prices2) {
46
- if (prices1 === undefined && prices2 === undefined) {
47
- return true;
48
- }
49
- if (prices1 === undefined || prices2 === undefined) {
50
- return false;
51
- }
52
- const parent1 = prices1.parent;
53
- const parent2 = prices2.parent;
54
- if (!comparePricesObjects(parent1, parent2)) {
55
- return false;
56
- }
57
- return shallowCompareDictionaries(prices1.values, prices2.values);
58
- }
59
- 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) }));
60
- export const decodeProductParams = (params) => (Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) }));
61
- export function isSameCatalogueParams(left, right) {
62
- return (left.enterprise === right.enterprise &&
63
- left.prdCat === right.prdCat &&
64
- left.prdCatVersion === right.prdCatVersion &&
65
- left.priceList === right.priceList &&
66
- left.vendor === right.vendor);
67
- }
68
- export function isSameVector(left, right) {
69
- return left.x === right.x && left.y === right.y && left.z === right.z;
70
- }
71
- export function isSameOrientation(left, right) {
72
- return left.pitch === right.pitch && left.roll === right.roll && left.yaw === right.yaw;
73
- }
74
- export function isSameAnchor(left, right) {
75
- var _a, _b;
76
- if (left.code !== right.code) {
77
- return false;
78
- }
79
- if (left.anchorPoint !== right.anchorPoint) {
80
- return false;
81
- }
82
- const leftMeasurePriorities = (_a = left.measurePriority) !== null && _a !== void 0 ? _a : [];
83
- const rightMeasurePriorities = (_b = right.measurePriority) !== null && _b !== void 0 ? _b : [];
84
- if (leftMeasurePriorities.length !== rightMeasurePriorities.length) {
85
- return false;
86
- }
87
- if (leftMeasurePriorities.some((p, i) => p.url !== rightMeasurePriorities[i].url)) {
88
- return false;
89
- }
90
- return true;
91
- }
92
- export function isSameTransform(left, right) {
93
- const leftTransformPos = left.pos;
94
- const rightTransformPos = right.pos;
95
- const leftTransformRot = left.rot;
96
- const rightTransformRot = right.rot;
97
- const leftTransformScale = left.scale;
98
- const rightTransformScale = right.scale;
99
- if ((leftTransformPos === undefined) !== (rightTransformPos === undefined)) {
100
- return false;
101
- }
102
- if ((leftTransformRot === undefined) !== (rightTransformRot === undefined)) {
103
- return false;
104
- }
105
- if ((leftTransformScale === undefined) !== (rightTransformScale === undefined)) {
106
- return false;
107
- }
108
- if (leftTransformPos !== undefined &&
109
- rightTransformPos !== undefined &&
110
- !isSameVector(leftTransformPos, rightTransformPos)) {
111
- return false;
112
- }
113
- if (leftTransformRot !== undefined &&
114
- rightTransformRot !== undefined &&
115
- !isSameOrientation(leftTransformRot, rightTransformRot)) {
116
- return false;
117
- }
118
- if (leftTransformScale !== undefined &&
119
- rightTransformScale !== undefined &&
120
- !isSameVector(leftTransformScale, rightTransformScale)) {
121
- return false;
122
- }
123
- return true;
124
- }
125
- export function isSameProductRef(left, right) {
126
- if (left.refKey !== right.refKey) {
127
- return false;
128
- }
129
- if (left.partNumber !== right.partNumber) {
130
- return false;
131
- }
132
- if (!isSameCatalogueParams(left.catId, right.catId)) {
133
- return false;
134
- }
135
- if (left.refDescription !== right.refDescription) {
136
- return false;
137
- }
138
- const leftAnchor = left.anchor;
139
- const rightAnchor = right.anchor;
140
- if ((leftAnchor === undefined) !== (rightAnchor === undefined)) {
141
- return false;
142
- }
143
- if (leftAnchor !== undefined &&
144
- rightAnchor !== undefined &&
145
- !isSameAnchor(leftAnchor, rightAnchor)) {
146
- return false;
147
- }
148
- const leftTransform = left.transform;
149
- const rightTransform = right.transform;
150
- if ((leftTransform === undefined) !== (rightTransform === undefined)) {
151
- return false;
152
- }
153
- if (leftTransform !== undefined &&
154
- rightTransform !== undefined &&
155
- !isSameTransform(leftTransform, rightTransform)) {
156
- return false;
157
- }
158
- if (left.optional !== right.optional) {
159
- return false;
160
- }
161
- return true;
162
- }
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
+ export function isModel(arg) {
29
+ return typeof arg === "object" && arg !== null && "cid" in arg && "uri" in arg;
30
+ }
31
+ /** Replace empty strings with "-" for compatibility with the API. */
32
+ export function correctDefaultsOnCatalogueParams(catId) {
33
+ // Enterprise, prdCat and vendor have to be set, so we don't try and fix those
34
+ return Object.assign(Object.assign({}, catId), { prdCatVersion: catId.prdCatVersion || "-", priceList: catId.priceList || "-" });
35
+ }
36
+ export function recursivelyGetPriceCodeValue(priceCodes, prices) {
37
+ while (prices) {
38
+ for (const name of priceCodes) {
39
+ const priceCodeUpcharge = prices === null || prices === void 0 ? void 0 : prices.values[name];
40
+ if (priceCodeUpcharge !== undefined) {
41
+ return priceCodeUpcharge;
42
+ }
43
+ }
44
+ prices = prices.parent;
45
+ }
46
+ return undefined;
47
+ }
48
+ export function comparePricesObjects(prices1, prices2) {
49
+ if (prices1 === undefined && prices2 === undefined) {
50
+ return true;
51
+ }
52
+ if (prices1 === undefined || prices2 === undefined) {
53
+ return false;
54
+ }
55
+ const parent1 = prices1.parent;
56
+ const parent2 = prices2.parent;
57
+ if (!comparePricesObjects(parent1, parent2)) {
58
+ return false;
59
+ }
60
+ return shallowCompareDictionaries(prices1.values, prices2.values);
61
+ }
62
+ 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) }));
63
+ export const decodeProductParams = (params) => (Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) }));
64
+ export function isSameCatalogueParams(left, right) {
65
+ return (left.enterprise === right.enterprise &&
66
+ left.prdCat === right.prdCat &&
67
+ left.prdCatVersion === right.prdCatVersion &&
68
+ left.priceList === right.priceList &&
69
+ left.vendor === right.vendor);
70
+ }
71
+ export function isSameVector(left, right) {
72
+ return left.x === right.x && left.y === right.y && left.z === right.z;
73
+ }
74
+ export function isSameOrientation(left, right) {
75
+ return left.pitch === right.pitch && left.roll === right.roll && left.yaw === right.yaw;
76
+ }
77
+ export function isSameAnchor(left, right) {
78
+ var _a, _b;
79
+ if (left.code !== right.code) {
80
+ return false;
81
+ }
82
+ if (left.anchorPoint !== right.anchorPoint) {
83
+ return false;
84
+ }
85
+ const leftMeasurePriorities = (_a = left.measurePriority) !== null && _a !== void 0 ? _a : [];
86
+ const rightMeasurePriorities = (_b = right.measurePriority) !== null && _b !== void 0 ? _b : [];
87
+ if (leftMeasurePriorities.length !== rightMeasurePriorities.length) {
88
+ return false;
89
+ }
90
+ if (leftMeasurePriorities.some((p, i) => p.url !== rightMeasurePriorities[i].url)) {
91
+ return false;
92
+ }
93
+ return true;
94
+ }
95
+ export function isSameTransform(left, right) {
96
+ const leftTransformPos = left.pos;
97
+ const rightTransformPos = right.pos;
98
+ const leftTransformRot = left.rot;
99
+ const rightTransformRot = right.rot;
100
+ const leftTransformScale = left.scale;
101
+ const rightTransformScale = right.scale;
102
+ if ((leftTransformPos === undefined) !== (rightTransformPos === undefined)) {
103
+ return false;
104
+ }
105
+ if ((leftTransformRot === undefined) !== (rightTransformRot === undefined)) {
106
+ return false;
107
+ }
108
+ if ((leftTransformScale === undefined) !== (rightTransformScale === undefined)) {
109
+ return false;
110
+ }
111
+ if (leftTransformPos !== undefined &&
112
+ rightTransformPos !== undefined &&
113
+ !isSameVector(leftTransformPos, rightTransformPos)) {
114
+ return false;
115
+ }
116
+ if (leftTransformRot !== undefined &&
117
+ rightTransformRot !== undefined &&
118
+ !isSameOrientation(leftTransformRot, rightTransformRot)) {
119
+ return false;
120
+ }
121
+ if (leftTransformScale !== undefined &&
122
+ rightTransformScale !== undefined &&
123
+ !isSameVector(leftTransformScale, rightTransformScale)) {
124
+ return false;
125
+ }
126
+ return true;
127
+ }
128
+ export function isSameProductRef(left, right) {
129
+ if (left.refKey !== right.refKey) {
130
+ return false;
131
+ }
132
+ if (left.partNumber !== right.partNumber) {
133
+ return false;
134
+ }
135
+ if (!isSameCatalogueParams(left.catId, right.catId)) {
136
+ return false;
137
+ }
138
+ if (left.refDescription !== right.refDescription) {
139
+ return false;
140
+ }
141
+ const leftAnchor = left.anchor;
142
+ const rightAnchor = right.anchor;
143
+ if ((leftAnchor === undefined) !== (rightAnchor === undefined)) {
144
+ return false;
145
+ }
146
+ if (leftAnchor !== undefined &&
147
+ rightAnchor !== undefined &&
148
+ !isSameAnchor(leftAnchor, rightAnchor)) {
149
+ return false;
150
+ }
151
+ const leftTransform = left.transform;
152
+ const rightTransform = right.transform;
153
+ if ((leftTransform === undefined) !== (rightTransform === undefined)) {
154
+ return false;
155
+ }
156
+ if (leftTransform !== undefined &&
157
+ rightTransform !== undefined &&
158
+ !isSameTransform(leftTransform, rightTransform)) {
159
+ return false;
160
+ }
161
+ if (left.optional !== right.optional) {
162
+ return false;
163
+ }
164
+ return true;
165
+ }
166
+ export const isSameDtoCatalogueParamsWithLang = (left, right) => left.cid === right.cid &&
167
+ left.lang === right.lang &&
168
+ left.enterprise === right.enterprise &&
169
+ left.prdCat === right.prdCat &&
170
+ left.prdCatVersion === right.prdCatVersion &&
171
+ left.priceList === right.priceList &&
172
+ left.vendor === right.vendor;
173
+ export const isSameDtoProductParamsWithLang = (left, right) => isSameDtoCatalogueParamsWithLang(left, right) && left.partNumber === right.partNumber;
@@ -1,38 +1,39 @@
1
- import { CatalogueParams, CataloguePermission } from "./CatalogueAPI.js";
2
- interface CataloguePermissionByEnterpriseKey {
3
- [key: string]: CataloguePermission[];
4
- }
5
- export declare const groupAndSortCataloguePermissions: (cataloguePermissions: CataloguePermission[]) => CataloguePermissionByEnterpriseKey;
6
- export declare const isParamSet: (param: string) => boolean;
7
- export declare const createCataloguePermissionsFilter: (enterprise: string, prdCat: string, prdCatVersion: string, priceList: string, vendor: string) => (perm: CataloguePermission) => 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
- * @param cataloguePermissions
14
- * @param enterprise
15
- * @param prdCat
16
- * @param priceList
17
- * @param vendor
18
- */
19
- export declare const getPrdCatVersionFromPermissions: (cataloguePermissions: CataloguePermission[], enterprise: string, prdCat: string, priceList: string, vendor: string) => string | undefined;
20
- /**
21
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
22
- * This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
23
- * permissions. If it fails to find any applicable permissions the original value is returned.
24
- * @param auth
25
- * @param params
26
- */
27
- export declare const getPrdCatVersionOrLatestFromPermissions: (params: CatalogueParams, cataloguePermissions: CataloguePermission[]) => string;
28
- /**
29
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
30
- * This method will, if the prdCatVersion is not set, fetch the highest available from the
31
- * cataloguePermissions and insert it into a copy of the original params. If it fails to find any
32
- * applicable auth-permissions the original value is returned.
33
- * @param auth
34
- * @param params
35
- */
36
- export declare const fillMissingPrdCatVersionFromPermissions: <T extends CatalogueParams>(params: T, cataloguePermissions: CataloguePermission[]) => T;
37
- export {};
1
+ import { DtoCatalogueParams, 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<DtoCatalogueParams>) => (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: DtoCatalogueParams, 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 DtoCatalogueParams>(params: T, cataloguePermissions: DtoCataloguePermission[]) => T;
38
+ export {};
38
39
  //# sourceMappingURL=utilitiesCataloguePermission.d.ts.map
@@ -1,80 +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 !== "" && param !== "-";
18
- export const createCataloguePermissionsFilter = (enterprise, prdCat, prdCatVersion, priceList, vendor) => (perm) => (!isParamSet(enterprise) || enterprise === perm.enterprise) &&
19
- (!isParamSet(prdCat) || prdCat === perm.prdCat) &&
20
- (!isParamSet(prdCatVersion) || prdCatVersion === perm.prdCatVersion) &&
21
- (!isParamSet(vendor) ||
22
- perm.vendors === undefined ||
23
- perm.vendors.some((v) => vendor === v)) &&
24
- (!isParamSet(priceList) ||
25
- perm.priceLists === undefined ||
26
- perm.priceLists.some((p) => priceList === p));
27
- /**
28
- * Sometimes you will want to use the latest available prdCatVersion. This method will
29
- * find the highest prdCatVersion version in the cataloguePermissions. If the versions are
30
- * numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
31
- * string compare.
32
- * @param cataloguePermissions
33
- * @param enterprise
34
- * @param prdCat
35
- * @param priceList
36
- * @param vendor
37
- */
38
- export const getPrdCatVersionFromPermissions = (cataloguePermissions, enterprise, prdCat, priceList, vendor) => {
39
- const filter = createCataloguePermissionsFilter(enterprise, prdCat, "-", priceList, vendor);
40
- const applicablePermissions = cataloguePermissions.filter(filter);
41
- return applicablePermissions.reduce((pVersion, c) => {
42
- const cVersion = c.prdCatVersion;
43
- if (pVersion === undefined) {
44
- return cVersion;
45
- }
46
- const pNum = parseFloat(pVersion);
47
- const cNum = parseFloat(cVersion);
48
- if (isNaN(pNum) || isNaN(cNum)) {
49
- return pVersion < cVersion ? cVersion : pVersion;
50
- }
51
- return pNum < cNum ? cVersion : pVersion;
52
- }, undefined);
53
- };
54
- /**
55
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
56
- * This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
57
- * permissions. If it fails to find any applicable permissions the original value is returned.
58
- * @param auth
59
- * @param params
60
- */
61
- export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermissions) => {
62
- const { enterprise, prdCat, prdCatVersion, priceList, vendor } = params;
63
- if (isParamSet(prdCatVersion)) {
64
- return prdCatVersion;
65
- }
66
- const highestFoundVersion = getPrdCatVersionFromPermissions(cataloguePermissions, enterprise, prdCat, priceList, vendor);
67
- if (highestFoundVersion === undefined) {
68
- return prdCatVersion;
69
- }
70
- return highestFoundVersion;
71
- };
72
- /**
73
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
74
- * This method will, if the prdCatVersion is not set, fetch the highest available from the
75
- * cataloguePermissions and insert it into a copy of the original params. If it fails to find any
76
- * applicable auth-permissions the original value is returned.
77
- * @param auth
78
- * @param params
79
- */
80
- 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,25 +1,25 @@
1
- import { CodeRange } from "./CatalogueAPI.js";
2
- export declare class NumericValuesSelection {
3
- constructor(rawRanges: CodeRange[]);
4
- readonly ranges: (NumericValueRangeDefinition | NumericValueDiscrete)[];
5
- includesValue(value: number): boolean;
6
- get first(): number;
7
- get legend(): string;
8
- }
9
- export declare class NumericValueDiscrete {
10
- readonly value: number;
11
- constructor(value: number);
12
- includesValue(value: number): boolean;
13
- get first(): number;
14
- get legend(): string;
15
- }
16
- export declare class NumericValueRangeDefinition {
17
- constructor(rawRange: CodeRange);
18
- readonly minValue: number;
19
- readonly maxValue: number;
20
- readonly increment: number | undefined;
21
- includesValue(value: number): boolean;
22
- get first(): number;
23
- get legend(): string;
24
- }
1
+ import { DtoCodeRange } from "./CatalogueAPI.js";
2
+ export declare class NumericValuesSelection {
3
+ constructor(rawRanges: DtoCodeRange[]);
4
+ readonly ranges: (NumericValueRangeDefinition | NumericValueDiscrete)[];
5
+ includesValue(value: number): boolean;
6
+ get first(): number;
7
+ get legend(): string;
8
+ }
9
+ export declare class NumericValueDiscrete {
10
+ readonly value: number;
11
+ constructor(value: number);
12
+ includesValue(value: number): boolean;
13
+ get first(): number;
14
+ get legend(): string;
15
+ }
16
+ export declare class NumericValueRangeDefinition {
17
+ constructor(rawRange: DtoCodeRange);
18
+ readonly minValue: number;
19
+ readonly maxValue: number;
20
+ readonly increment: number | undefined;
21
+ includesValue(value: number): boolean;
22
+ get first(): number;
23
+ get legend(): string;
24
+ }
25
25
  //# sourceMappingURL=utilitiesNumericValues.d.ts.map