@configura/web-api 1.6.1-alpha.7 → 1.6.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.
- package/.eslintrc.json +18 -0
- package/dist/CatalogueAPI.d.ts +4 -9
- package/dist/CatalogueAPI.js +6 -3
- package/dist/CfgProduct.d.ts +31 -12
- package/dist/CfgProduct.js +124 -45
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/productConfiguration/CfgFeature.d.ts +13 -3
- package/dist/productConfiguration/CfgFeature.js +77 -52
- package/dist/productConfiguration/CfgOption.d.ts +30 -8
- package/dist/productConfiguration/CfgOption.js +49 -17
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +1 -1
- package/dist/productConfiguration/CfgProductConfiguration.js +4 -2
- package/dist/productConfiguration/filters.js +7 -7
- package/dist/syncGroups/SyncGroupsApplyMode.d.ts +21 -0
- package/dist/syncGroups/SyncGroupsApplyMode.js +21 -0
- package/dist/syncGroups/SyncGroupsHandler.d.ts +41 -0
- package/dist/syncGroups/SyncGroupsHandler.js +358 -0
- package/dist/syncGroups/SyncGroupsPathHelper.d.ts +27 -0
- package/dist/syncGroups/SyncGroupsPathHelper.js +90 -0
- package/dist/syncGroups/SyncGroupsState.d.ts +36 -0
- package/dist/syncGroups/SyncGroupsState.js +125 -0
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +155 -0
- package/dist/syncGroups/SyncGroupsTransaction.js +576 -0
- package/dist/tasks/TaskHandler.d.ts +1 -1
- package/dist/tasks/TaskHandler.js +20 -9
- package/dist/tests/testData/collectorForTest.d.ts +1 -1
- package/dist/tests/testData/collectorForTest.js +1 -2
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +3 -24
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +30 -101
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +1 -1
- package/dist/tests/testData/testDataCachedGetProduct.js +16 -27
- package/dist/tests/testData/testDataCachedPostValidate.js +5 -5
- package/dist/tests/testData/testDataOptions.d.ts +13 -0
- package/dist/tests/testData/testDataOptions.js +60 -0
- package/dist/tests/testData/testDataProductAggregatedPrice.js +19 -30
- package/dist/tests/testData/testDataUpcharge.d.ts +3 -24
- package/dist/tests/testData/testDataUpcharge.js +17 -49
- package/dist/utilitiesCatalogueData.d.ts +8 -2
- package/dist/utilitiesCatalogueData.js +105 -9
- package/dist/utilitiesCataloguePermission.d.ts +1 -3
- package/dist/utilitiesCataloguePermission.js +10 -14
- package/package.json +3 -3
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { CfgProduct } from "../../CfgProduct.js";
|
|
11
11
|
import { Collector } from "./collectorForTest.js";
|
|
12
12
|
import { dummyCatId } from "./dummyProductForTest.js";
|
|
13
|
+
import { letterOptionCodeA, letterOptions } from "./testDataOptions.js";
|
|
13
14
|
const Prd = () => ({
|
|
14
15
|
uuid: "Prd",
|
|
15
16
|
unit: "m",
|
|
@@ -19,20 +20,9 @@ const Prd = () => ({
|
|
|
19
20
|
description: "",
|
|
20
21
|
numericOrder: false,
|
|
21
22
|
options: [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
code: "B",
|
|
28
|
-
description: "",
|
|
29
|
-
upcharge: undefined,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
code: "C",
|
|
33
|
-
description: "",
|
|
34
|
-
upcharge: 0,
|
|
35
|
-
},
|
|
23
|
+
letterOptions[0],
|
|
24
|
+
Object.assign(Object.assign({}, letterOptions[1]), { upcharge: undefined }),
|
|
25
|
+
Object.assign(Object.assign({}, letterOptions[2]), { upcharge: 0 }),
|
|
36
26
|
],
|
|
37
27
|
},
|
|
38
28
|
{
|
|
@@ -40,20 +30,9 @@ const Prd = () => ({
|
|
|
40
30
|
description: "",
|
|
41
31
|
numericOrder: false,
|
|
42
32
|
options: [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
code: "B",
|
|
49
|
-
description: "",
|
|
50
|
-
upcharge: undefined,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
code: "C",
|
|
54
|
-
description: "",
|
|
55
|
-
upcharge: 10,
|
|
56
|
-
},
|
|
33
|
+
letterOptions[0],
|
|
34
|
+
Object.assign(Object.assign({}, letterOptions[1]), { upcharge: undefined }),
|
|
35
|
+
Object.assign(Object.assign({}, letterOptions[2]), { upcharge: 10 }),
|
|
57
36
|
],
|
|
58
37
|
},
|
|
59
38
|
{
|
|
@@ -62,20 +41,9 @@ const Prd = () => ({
|
|
|
62
41
|
numericOrder: false,
|
|
63
42
|
optional: true,
|
|
64
43
|
options: [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
code: "B",
|
|
71
|
-
description: "",
|
|
72
|
-
upcharge: undefined,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
code: "C",
|
|
76
|
-
description: "",
|
|
77
|
-
upcharge: 10,
|
|
78
|
-
},
|
|
44
|
+
letterOptions[0],
|
|
45
|
+
Object.assign(Object.assign({}, letterOptions[1]), { upcharge: undefined }),
|
|
46
|
+
Object.assign(Object.assign({}, letterOptions[2]), { upcharge: 10 }),
|
|
79
47
|
],
|
|
80
48
|
},
|
|
81
49
|
],
|
|
@@ -91,24 +59,24 @@ const Prd = () => ({
|
|
|
91
59
|
{
|
|
92
60
|
code: "!~!",
|
|
93
61
|
next: {
|
|
94
|
-
|
|
95
|
-
code:
|
|
62
|
+
[letterOptionCodeA]: {
|
|
63
|
+
code: letterOptionCodeA,
|
|
96
64
|
},
|
|
97
65
|
},
|
|
98
66
|
},
|
|
99
67
|
{
|
|
100
68
|
code: "!~!",
|
|
101
69
|
next: {
|
|
102
|
-
|
|
103
|
-
code:
|
|
70
|
+
[letterOptionCodeA]: {
|
|
71
|
+
code: letterOptionCodeA,
|
|
104
72
|
},
|
|
105
73
|
},
|
|
106
74
|
},
|
|
107
75
|
{
|
|
108
76
|
code: "!~!",
|
|
109
77
|
next: {
|
|
110
|
-
|
|
111
|
-
code:
|
|
78
|
+
[letterOptionCodeA]: {
|
|
79
|
+
code: letterOptionCodeA,
|
|
112
80
|
},
|
|
113
81
|
},
|
|
114
82
|
},
|
|
@@ -121,7 +89,7 @@ const Prd = () => ({
|
|
|
121
89
|
{ code: "WithUpchargeSelectMany" },
|
|
122
90
|
],
|
|
123
91
|
});
|
|
124
|
-
const getProduct = (params) =>
|
|
92
|
+
const getProduct = (params) => Promise.resolve(Prd());
|
|
125
93
|
export const getUpchargeProduct = (testFunc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
94
|
const productLoader = {
|
|
127
95
|
getProduct,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CatalogueParams, GetProductParams, Model, PartsData, Prices, ProductData, ProductResponse, SelectedOption, ValidateResponse } from "./CatalogueAPI.js";
|
|
1
|
+
import { AdditionalProductRef, CatalogueParams, GetProductParams, MeasureParam, Model, Orientation, PartsData, Prices, ProductData, ProductResponse, SelectedOption, Transform, ValidateResponse, Vector } from "./CatalogueAPI.js";
|
|
2
2
|
export declare const makeCatalogueKey: (cat: CatalogueParams) => string;
|
|
3
3
|
export declare const makeProductKey: (cat: CatalogueParams, pKey: string) => string;
|
|
4
4
|
export declare const makeSelOptionsKey: (options: SelectedOption[]) => string;
|
|
@@ -16,11 +16,17 @@ export declare type CfgProductResponse = Omit<ProductResponse, "productData"> &
|
|
|
16
16
|
export declare type CfgValidateResponse = Omit<ValidateResponse, "productData"> & {
|
|
17
17
|
productData: CfgProductData;
|
|
18
18
|
};
|
|
19
|
-
export declare function isModel(arg:
|
|
19
|
+
export declare function isModel(arg: unknown): arg is Model;
|
|
20
20
|
/** Replace empty strings with "-" for compatibility with the API. */
|
|
21
21
|
export declare function correctDefaultsOnCatalogueParams(catId: CatalogueParams): CatalogueParams;
|
|
22
22
|
export declare function recursivelyGetPriceCodeValue(priceCodes: string[], prices: Prices | undefined): number | undefined;
|
|
23
23
|
export declare function comparePricesObjects(prices1: Prices | undefined, prices2: Prices | undefined): boolean;
|
|
24
24
|
export declare const decodeCatalogueParams: <T extends CatalogueParams>(params: T) => T;
|
|
25
25
|
export declare const decodeProductParams: <T extends GetProductParams>(params: T) => T;
|
|
26
|
+
export declare function isSameCatalogueParams(left: CatalogueParams, right: CatalogueParams): boolean;
|
|
27
|
+
export declare function isSameVector(left: Vector, right: Vector): boolean;
|
|
28
|
+
export declare function isSameOrientation(left: Orientation, right: Orientation): boolean;
|
|
29
|
+
export declare function isSameAnchor(left: MeasureParam, right: MeasureParam): boolean;
|
|
30
|
+
export declare function isSameTransform(left: Transform, right: Transform): boolean;
|
|
31
|
+
export declare function isSameProductRef(left: AdditionalProductRef, right: AdditionalProductRef): boolean;
|
|
26
32
|
//# sourceMappingURL=utilitiesCatalogueData.d.ts.map
|
|
@@ -17,7 +17,7 @@ export const makeSelOptionsKey = (options) => options.reduce((p, option) => {
|
|
|
17
17
|
return p;
|
|
18
18
|
}, "");
|
|
19
19
|
export function isModel(arg) {
|
|
20
|
-
return arg
|
|
20
|
+
return typeof arg === "object" && arg !== null && "cid" in arg && "uri" in arg;
|
|
21
21
|
}
|
|
22
22
|
/** Replace empty strings with "-" for compatibility with the API. */
|
|
23
23
|
export function correctDefaultsOnCatalogueParams(catId) {
|
|
@@ -56,11 +56,107 @@ export function comparePricesObjects(prices1, prices2) {
|
|
|
56
56
|
}
|
|
57
57
|
return shallowCompareDictionaries(prices1.values, prices2.values);
|
|
58
58
|
}
|
|
59
|
-
export const decodeCatalogueParams = (params) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
+
}
|
|
@@ -33,8 +33,6 @@ export declare const getPrdCatVersionOrLatestFromPermissions: (params: Catalogue
|
|
|
33
33
|
* @param auth
|
|
34
34
|
* @param params
|
|
35
35
|
*/
|
|
36
|
-
export declare const fillMissingPrdCatVersionFromPermissions: <T extends CatalogueParams>(params: T, cataloguePermissions: CataloguePermission[]) => T
|
|
37
|
-
prdCatVersion: string;
|
|
38
|
-
};
|
|
36
|
+
export declare const fillMissingPrdCatVersionFromPermissions: <T extends CatalogueParams>(params: T, cataloguePermissions: CataloguePermission[]) => T;
|
|
39
37
|
export {};
|
|
40
38
|
//# sourceMappingURL=utilitiesCataloguePermission.d.ts.map
|
|
@@ -15,17 +15,15 @@ export const groupAndSortCataloguePermissions = (cataloguePermissions) => {
|
|
|
15
15
|
return cataloguePermissionByEnterpriseKey;
|
|
16
16
|
};
|
|
17
17
|
export const isParamSet = (param) => param !== "" && param !== "-";
|
|
18
|
-
export const createCataloguePermissionsFilter = (enterprise, prdCat, prdCatVersion, priceList, vendor) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
perm.priceLists.some((p) => priceList === p));
|
|
28
|
-
};
|
|
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));
|
|
29
27
|
/**
|
|
30
28
|
* Sometimes you will want to use the latest available prdCatVersion. This method will
|
|
31
29
|
* find the highest prdCatVersion version in the cataloguePermissions. If the versions are
|
|
@@ -79,6 +77,4 @@ export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermiss
|
|
|
79
77
|
* @param auth
|
|
80
78
|
* @param params
|
|
81
79
|
*/
|
|
82
|
-
export const fillMissingPrdCatVersionFromPermissions = (params, cataloguePermissions) => {
|
|
83
|
-
return Object.assign(Object.assign({}, params), { prdCatVersion: getPrdCatVersionOrLatestFromPermissions(params, cataloguePermissions) });
|
|
84
|
-
};
|
|
80
|
+
export const fillMissingPrdCatVersionFromPermissions = (params, cataloguePermissions) => (Object.assign(Object.assign({}, params), { prdCatVersion: getPrdCatVersionOrLatestFromPermissions(params, cataloguePermissions) }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/web-api",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@configura/web-utilities": "1.6.
|
|
26
|
+
"@configura/web-utilities": "1.6.2"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "7d15c3d75c39de15271da189ed1d0d5bfa719d79"
|
|
29
29
|
}
|