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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 -551
  5. package/dist/CatalogueAPI.js +293 -293
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +268 -268
  9. package/dist/CfgProduct.js +778 -778
  10. package/dist/CfgReferencePathHelper.d.ts +13 -13
  11. package/dist/CfgReferencePathHelper.js +13 -13
  12. package/dist/ConfigurationConverter.d.ts +4 -4
  13. package/dist/ConfigurationConverter.js +72 -72
  14. package/dist/index.d.ts +23 -23
  15. package/dist/index.js +23 -23
  16. package/dist/io/CfgHistoryManager.d.ts +50 -50
  17. package/dist/io/CfgHistoryManager.js +82 -82
  18. package/dist/io/CfgHistoryToProdConfConnector.d.ts +20 -20
  19. package/dist/io/CfgHistoryToProdConfConnector.js +56 -56
  20. package/dist/io/CfgIOManager.d.ts +48 -48
  21. package/dist/io/CfgIOManager.js +115 -115
  22. package/dist/io/CfgIOProdConfConnector.d.ts +52 -52
  23. package/dist/io/CfgIOProdConfConnector.js +141 -141
  24. package/dist/io/CfgObservableStateManager.d.ts +21 -21
  25. package/dist/io/CfgObservableStateManager.js +65 -65
  26. package/dist/io/CfgObservableStateToProdConfConnector.d.ts +14 -14
  27. package/dist/io/CfgObservableStateToProdConfConnector.js +16 -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 +84 -84
  32. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +16 -16
  33. package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -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 +187 -187
  47. package/dist/productConfiguration/CfgFeature.js +645 -645
  48. package/dist/productConfiguration/CfgOption.d.ts +151 -151
  49. package/dist/productConfiguration/CfgOption.js +416 -416
  50. package/dist/productConfiguration/CfgProductConfiguration.d.ts +117 -117
  51. package/dist/productConfiguration/CfgProductConfiguration.js +307 -307
  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 -359
  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 -77
  71. package/dist/tasks/TaskHandler.js +275 -275
  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 +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 -33
  93. package/dist/utilitiesCatalogueData.js +173 -164
  94. package/dist/utilitiesCataloguePermission.d.ts +38 -32
  95. package/dist/utilitiesCataloguePermission.js +79 -76
  96. package/dist/utilitiesNumericValues.d.ts +24 -24
  97. package/dist/utilitiesNumericValues.js +109 -109
  98. package/package.json +3 -3
@@ -1,164 +1,173 @@
1
- import { shallowCompareDictionaries } from "@configura/web-utilities";
2
- export const makeCatalogueKey = (cat) => `${cat.cid}-${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 Object.assign(Object.assign({}, catId), { prdCatVersion: catId.prdCatVersion || "-", priceList: catId.priceList || "-" });
26
- }
27
- export function recursivelyGetPriceCodeValue(priceCodes, prices) {
28
- while (prices) {
29
- for (const name of priceCodes) {
30
- const priceCodeUpcharge = prices === null || prices === void 0 ? void 0 : prices.values[name];
31
- if (priceCodeUpcharge !== undefined) {
32
- return priceCodeUpcharge;
33
- }
34
- }
35
- prices = prices.parent;
36
- }
37
- return undefined;
38
- }
39
- export function comparePricesObjects(prices1, prices2) {
40
- if (prices1 === undefined && prices2 === undefined) {
41
- return true;
42
- }
43
- if (prices1 === undefined || prices2 === undefined) {
44
- return false;
45
- }
46
- const parent1 = prices1.parent;
47
- const parent2 = prices2.parent;
48
- if (!comparePricesObjects(parent1, parent2)) {
49
- return false;
50
- }
51
- return shallowCompareDictionaries(prices1.values, prices2.values);
52
- }
53
- 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) }));
54
- export const decodeProductParams = (params) => (Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) }));
55
- export function isSameCatalogueParams(left, right) {
56
- return (left.enterprise === right.enterprise &&
57
- left.prdCat === right.prdCat &&
58
- left.prdCatVersion === right.prdCatVersion &&
59
- left.priceList === right.priceList &&
60
- left.vendor === right.vendor);
61
- }
62
- export function isSameVector(left, right) {
63
- return left.x === right.x && left.y === right.y && left.z === right.z;
64
- }
65
- export function isSameOrientation(left, right) {
66
- return left.pitch === right.pitch && left.roll === right.roll && left.yaw === right.yaw;
67
- }
68
- export function isSameAnchor(left, right) {
69
- var _a, _b;
70
- if (left.code !== right.code) {
71
- return false;
72
- }
73
- if (left.anchorPoint !== right.anchorPoint) {
74
- return false;
75
- }
76
- const leftMeasurePriorities = (_a = left.measurePriority) !== null && _a !== void 0 ? _a : [];
77
- const rightMeasurePriorities = (_b = right.measurePriority) !== null && _b !== void 0 ? _b : [];
78
- if (leftMeasurePriorities.length !== rightMeasurePriorities.length) {
79
- return false;
80
- }
81
- if (leftMeasurePriorities.some((p, i) => p.url !== rightMeasurePriorities[i].url)) {
82
- return false;
83
- }
84
- return true;
85
- }
86
- export function isSameTransform(left, right) {
87
- const leftTransformPos = left.pos;
88
- const rightTransformPos = right.pos;
89
- const leftTransformRot = left.rot;
90
- const rightTransformRot = right.rot;
91
- const leftTransformScale = left.scale;
92
- const rightTransformScale = right.scale;
93
- if ((leftTransformPos === undefined) !== (rightTransformPos === undefined)) {
94
- return false;
95
- }
96
- if ((leftTransformRot === undefined) !== (rightTransformRot === undefined)) {
97
- return false;
98
- }
99
- if ((leftTransformScale === undefined) !== (rightTransformScale === undefined)) {
100
- return false;
101
- }
102
- if (leftTransformPos !== undefined &&
103
- rightTransformPos !== undefined &&
104
- !isSameVector(leftTransformPos, rightTransformPos)) {
105
- return false;
106
- }
107
- if (leftTransformRot !== undefined &&
108
- rightTransformRot !== undefined &&
109
- !isSameOrientation(leftTransformRot, rightTransformRot)) {
110
- return false;
111
- }
112
- if (leftTransformScale !== undefined &&
113
- rightTransformScale !== undefined &&
114
- !isSameVector(leftTransformScale, rightTransformScale)) {
115
- return false;
116
- }
117
- return true;
118
- }
119
- export function isSameProductRef(left, right) {
120
- if (left.refKey !== right.refKey) {
121
- return false;
122
- }
123
- if (left.partNumber !== right.partNumber) {
124
- return false;
125
- }
126
- if (!isSameCatalogueParams(left.catId, right.catId)) {
127
- return false;
128
- }
129
- if (left.refDescription !== right.refDescription) {
130
- return false;
131
- }
132
- const leftAnchor = left.anchor;
133
- const rightAnchor = right.anchor;
134
- if ((leftAnchor === undefined) !== (rightAnchor === undefined)) {
135
- return false;
136
- }
137
- if (leftAnchor !== undefined &&
138
- rightAnchor !== undefined &&
139
- !isSameAnchor(leftAnchor, rightAnchor)) {
140
- return false;
141
- }
142
- const leftTransform = left.transform;
143
- const rightTransform = right.transform;
144
- if ((leftTransform === undefined) !== (rightTransform === undefined)) {
145
- return false;
146
- }
147
- if (leftTransform !== undefined &&
148
- rightTransform !== undefined &&
149
- !isSameTransform(leftTransform, rightTransform)) {
150
- return false;
151
- }
152
- if (left.optional !== right.optional) {
153
- return false;
154
- }
155
- return true;
156
- }
157
- export const isSameDtoCatalogueParamsWithLang = (left, right) => left.cid === right.cid &&
158
- left.lang === right.lang &&
159
- left.enterprise === right.enterprise &&
160
- left.prdCat === right.prdCat &&
161
- left.prdCatVersion === right.prdCatVersion &&
162
- left.priceList === right.priceList &&
163
- left.vendor === right.vendor;
164
- 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
+ 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,33 +1,39 @@
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: (cid: number | undefined, enterprise: string | undefined, prdCat: string | undefined, prdCatVersion: string | undefined, priceList: string | undefined, vendor: string | undefined) => (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[], cid: number | undefined, enterprise: string | undefined, prdCat: string | undefined, priceList: string | undefined, vendor: string | undefined) => string | undefined;
15
- /**
16
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
17
- * This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
18
- * permissions. If it fails to find any applicable permissions the original value is returned.
19
- * @param auth
20
- * @param params
21
- */
22
- export declare const getPrdCatVersionOrLatestFromPermissions: (params: DtoCatalogueParams, cataloguePermissions: DtoCataloguePermission[]) => string;
23
- /**
24
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
25
- * This method will, if the prdCatVersion is not set, fetch the highest available from the
26
- * cataloguePermissions and insert it into a copy of the original params. If it fails to find any
27
- * applicable auth-permissions the original value is returned.
28
- * @param auth
29
- * @param params
30
- */
31
- export declare const fillMissingPrdCatVersionFromPermissions: <T extends DtoCatalogueParams>(params: T, cataloguePermissions: DtoCataloguePermission[]) => T;
32
- 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 {};
33
39
  //# sourceMappingURL=utilitiesCataloguePermission.d.ts.map
@@ -1,76 +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 = (cid, enterprise, prdCat, prdCatVersion, priceList, vendor) => (perm) => (cid === undefined || cid === perm.cid) &&
19
- (!isParamSet(enterprise) || enterprise === perm.enterprise) &&
20
- (!isParamSet(prdCat) || prdCat === perm.prdCat) &&
21
- (!isParamSet(prdCatVersion) || prdCatVersion === perm.prdCatVersion) &&
22
- (!isParamSet(vendor) ||
23
- perm.vendors === undefined ||
24
- perm.vendors.some((v) => vendor === v)) &&
25
- (!isParamSet(priceList) ||
26
- perm.priceLists === undefined ||
27
- perm.priceLists.some((p) => priceList === p));
28
- /**
29
- * Sometimes you will want to use the latest available prdCatVersion. This method will
30
- * find the highest prdCatVersion version in the cataloguePermissions. If the versions are
31
- * numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
32
- * string compare.
33
- */
34
- export const getPrdCatVersionFromPermissions = (cataloguePermissions, cid, enterprise, prdCat, priceList, vendor) => {
35
- const filter = createCataloguePermissionsFilter(cid, enterprise, prdCat, "-", priceList, vendor);
36
- const applicablePermissions = cataloguePermissions.filter(filter);
37
- return applicablePermissions.reduce((pVersion, c) => {
38
- const cVersion = c.prdCatVersion;
39
- if (pVersion === undefined) {
40
- return cVersion;
41
- }
42
- const pNum = parseFloat(pVersion);
43
- const cNum = parseFloat(cVersion);
44
- if (isNaN(pNum) || isNaN(cNum)) {
45
- return pVersion < cVersion ? cVersion : pVersion;
46
- }
47
- return pNum < cNum ? cVersion : pVersion;
48
- }, undefined);
49
- };
50
- /**
51
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
52
- * This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
53
- * permissions. If it fails to find any applicable permissions the original value is returned.
54
- * @param auth
55
- * @param params
56
- */
57
- export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermissions) => {
58
- const { cid, enterprise, prdCat, prdCatVersion, priceList, vendor } = params;
59
- if (isParamSet(prdCatVersion)) {
60
- return prdCatVersion;
61
- }
62
- const highestFoundVersion = getPrdCatVersionFromPermissions(cataloguePermissions, cid, enterprise, prdCat, priceList, vendor);
63
- if (highestFoundVersion === undefined) {
64
- return prdCatVersion;
65
- }
66
- return highestFoundVersion;
67
- };
68
- /**
69
- * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
70
- * This method will, if the prdCatVersion is not set, fetch the highest available from the
71
- * cataloguePermissions and insert it into a copy of the original params. If it fails to find any
72
- * applicable auth-permissions the original value is returned.
73
- * @param auth
74
- * @param params
75
- */
76
- 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 { 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
- }
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