@configura/web-api 2.2.0-alpha.1 → 2.2.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.
- package/.eslintrc.json +5 -5
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +633 -633
- package/dist/CatalogueAPI.js +312 -312
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +359 -344
- package/dist/CfgProduct.js +1005 -992
- package/dist/CfgReferencePathHelper.d.ts +26 -26
- package/dist/CfgReferencePathHelper.js +26 -26
- package/dist/index.d.ts +24 -24
- package/dist/index.js +24 -24
- package/dist/io/CfgHistoryManager.d.ts +83 -83
- package/dist/io/CfgHistoryManager.js +144 -144
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -21
- package/dist/io/CfgHistoryToProdConfConnector.js +50 -50
- package/dist/io/CfgIOManager.d.ts +53 -53
- package/dist/io/CfgIOManager.js +134 -134
- package/dist/io/CfgIOProdConfConnector.d.ts +54 -54
- package/dist/io/CfgIOProdConfConnector.js +139 -139
- package/dist/io/CfgIOWarningSupplier.d.ts +3 -3
- package/dist/io/CfgIOWarningSupplier.js +1 -1
- package/dist/io/CfgObservableStateManager.d.ts +25 -25
- package/dist/io/CfgObservableStateManager.js +69 -69
- package/dist/io/CfgObservableStateToProdConfConnector.d.ts +15 -15
- package/dist/io/CfgObservableStateToProdConfConnector.js +17 -17
- package/dist/io/CfgWindowEventManager.d.ts +21 -21
- package/dist/io/CfgWindowEventManager.js +38 -38
- package/dist/io/CfgWindowMessageManager.d.ts +40 -40
- package/dist/io/CfgWindowMessageManager.js +91 -91
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +17 -17
- package/dist/io/CfgWindowMessageToProdConfConnector.js +19 -19
- package/dist/io/index.d.ts +8 -8
- package/dist/io/index.js +8 -8
- package/dist/material/CfgMaterialMapping.d.ts +7 -7
- package/dist/material/CfgMaterialMapping.js +181 -181
- package/dist/material/CfgMtrlApplication.d.ts +18 -18
- package/dist/material/CfgMtrlApplication.js +43 -43
- package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
- package/dist/material/CfgMtrlApplicationSource.js +8 -8
- package/dist/material/CfgMtrlSource.d.ts +19 -19
- package/dist/material/CfgMtrlSource.js +40 -40
- package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
- package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
- package/dist/productConfiguration/CfgFeature.d.ts +199 -199
- package/dist/productConfiguration/CfgFeature.js +691 -691
- package/dist/productConfiguration/CfgOption.d.ts +160 -160
- package/dist/productConfiguration/CfgOption.js +464 -464
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +136 -129
- package/dist/productConfiguration/CfgProductConfiguration.js +355 -346
- package/dist/productConfiguration/filters.d.ts +17 -17
- package/dist/productConfiguration/filters.js +141 -141
- package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
- package/dist/productConfiguration/productParamsGenerator.js +65 -65
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
- package/dist/productConfiguration/utilitiesProductConfiguration.js +89 -87
- package/dist/productLoader.d.ts +33 -33
- package/dist/productLoader.js +49 -49
- package/dist/syncGroups/SyncGroupsApplyMode.d.ts +20 -20
- package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
- package/dist/syncGroups/SyncGroupsHandler.d.ts +47 -47
- package/dist/syncGroups/SyncGroupsHandler.js +370 -370
- package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
- package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
- package/dist/syncGroups/SyncGroupsState.d.ts +39 -39
- package/dist/syncGroups/SyncGroupsState.js +167 -167
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
- package/dist/syncGroups/SyncGroupsTransaction.js +589 -589
- package/dist/tasks/TaskHandler.d.ts +77 -77
- package/dist/tasks/TaskHandler.js +276 -276
- package/dist/tasks/formats.d.ts +4 -4
- package/dist/tasks/formats.js +7 -7
- package/dist/tests/testData/collectorForTest.d.ts +73 -73
- package/dist/tests/testData/collectorForTest.js +194 -194
- package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
- package/dist/tests/testData/dummyProductForTest.js +32 -32
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +282 -282
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +187 -187
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +185 -185
- package/dist/tests/testData/testDataConstraints.d.ts +3 -3
- package/dist/tests/testData/testDataConstraints.js +174 -174
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
- package/dist/tests/testData/testDataOptions.d.ts +12 -12
- package/dist/tests/testData/testDataOptions.js +60 -60
- package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
- package/dist/tests/testData/testDataProductAggregatedPrice.js +189 -189
- package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
- package/dist/tests/testData/testDataUpcharge.js +121 -121
- package/dist/utilitiesCatalogueData.d.ts +47 -47
- package/dist/utilitiesCatalogueData.js +180 -180
- package/dist/utilitiesCataloguePermission.d.ts +38 -38
- package/dist/utilitiesCataloguePermission.js +79 -79
- package/dist/utilitiesConfiguration.d.ts +28 -28
- package/dist/utilitiesConfiguration.js +200 -200
- package/dist/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +114 -114
- 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) }));
|