@configura/web-api 1.6.1-alpha.7 → 2.0.0-alpha.1
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/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +551 -512
- package/dist/CatalogueAPI.js +293 -277
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +268 -239
- package/dist/CfgProduct.js +778 -668
- package/dist/CfgReferencePathHelper.d.ts +14 -0
- package/dist/CfgReferencePathHelper.js +13 -0
- package/dist/ConfigurationConverter.d.ts +5 -0
- package/dist/ConfigurationConverter.js +72 -0
- package/dist/index.d.ts +23 -18
- package/dist/index.js +23 -18
- package/dist/io/CfgHistoryManager.d.ts +51 -0
- package/dist/io/CfgHistoryManager.js +82 -0
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -0
- package/dist/io/CfgHistoryToProdConfConnector.js +56 -0
- package/dist/io/CfgIOManager.d.ts +49 -0
- package/dist/io/CfgIOManager.js +115 -0
- package/dist/io/CfgIOProdConfConnector.d.ts +53 -0
- package/dist/io/CfgIOProdConfConnector.js +141 -0
- package/dist/io/CfgObservableStateManager.d.ts +22 -0
- package/dist/io/CfgObservableStateManager.js +65 -0
- package/dist/io/CfgObservableStateToProdConfConnector.d.ts +15 -0
- package/dist/io/CfgObservableStateToProdConfConnector.js +16 -0
- package/dist/io/CfgWindowEventManager.d.ts +22 -0
- package/dist/io/CfgWindowEventManager.js +38 -0
- package/dist/io/CfgWindowMessageManager.d.ts +41 -0
- package/dist/io/CfgWindowMessageManager.js +84 -0
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +17 -0
- package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -0
- package/dist/io/index.d.ts +9 -0
- package/dist/io/index.js +8 -0
- 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 +187 -178
- package/dist/productConfiguration/CfgFeature.js +645 -611
- package/dist/productConfiguration/CfgOption.d.ts +151 -128
- package/dist/productConfiguration/CfgOption.js +416 -394
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +117 -120
- package/dist/productConfiguration/CfgProductConfiguration.js +307 -307
- package/dist/productConfiguration/filters.d.ts +15 -15
- package/dist/productConfiguration/filters.js +70 -70
- package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
- package/dist/productConfiguration/productParamsGenerator.js +51 -51
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
- package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -80
- package/dist/productLoader.d.ts +33 -33
- package/dist/productLoader.js +49 -49
- 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 +359 -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 +77 -78
- package/dist/tasks/TaskHandler.js +275 -265
- 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 -195
- package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
- package/dist/tests/testData/dummyProductForTest.js +32 -36
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -32
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +277 -348
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +185 -196
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +183 -183
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
- package/dist/tests/testData/testDataOptions.d.ts +13 -0
- package/dist/tests/testData/testDataOptions.js +60 -0
- package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
- package/dist/tests/testData/testDataProductAggregatedPrice.js +187 -198
- package/dist/tests/testData/testDataUpcharge.d.ts +8 -29
- package/dist/tests/testData/testDataUpcharge.js +119 -151
- package/dist/utilitiesCatalogueData.d.ts +33 -25
- package/dist/utilitiesCatalogueData.js +164 -66
- package/dist/utilitiesCataloguePermission.d.ts +32 -39
- package/dist/utilitiesCataloguePermission.js +76 -84
- package/dist/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +109 -109
- package/package.json +3 -3
|
@@ -1,151 +1,119 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { CfgProduct } from "../../CfgProduct.js";
|
|
11
|
-
import { Collector } from "./collectorForTest.js";
|
|
12
|
-
import { dummyCatId } from "./dummyProductForTest.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
code: "
|
|
40
|
-
description: "",
|
|
41
|
-
numericOrder: false,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
{ code: "WithUpcharge" },
|
|
121
|
-
{ code: "WithUpchargeSelectMany" },
|
|
122
|
-
],
|
|
123
|
-
});
|
|
124
|
-
const getProduct = (params) => __awaiter(void 0, void 0, void 0, function* () { return Prd(); });
|
|
125
|
-
export const getUpchargeProduct = (testFunc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
-
const productLoader = {
|
|
127
|
-
getProduct,
|
|
128
|
-
postValidate: (params, _body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
-
const productData = (yield getProduct(params)).productData;
|
|
130
|
-
const validateResponse = {
|
|
131
|
-
uuid: "",
|
|
132
|
-
validated: true,
|
|
133
|
-
productData,
|
|
134
|
-
};
|
|
135
|
-
return validateResponse;
|
|
136
|
-
}),
|
|
137
|
-
};
|
|
138
|
-
const product = yield CfgProduct.make(productLoader, "lang", dummyCatId, "Table");
|
|
139
|
-
const collect = new Collector(product);
|
|
140
|
-
const beforeSnapshot = collect.takeSnapshot();
|
|
141
|
-
yield testFunc(product);
|
|
142
|
-
const afterSnapshot = collect.takeSnapshot();
|
|
143
|
-
const diff = collect.compareSnapshot(beforeSnapshot, afterSnapshot);
|
|
144
|
-
const notifications = collect.notifications;
|
|
145
|
-
return {
|
|
146
|
-
beforeSnapshot: Collector.stripRefsForWrapper(beforeSnapshot),
|
|
147
|
-
afterSnapshot: Collector.stripRefsForWrapper(afterSnapshot),
|
|
148
|
-
diff,
|
|
149
|
-
notifications,
|
|
150
|
-
};
|
|
151
|
-
});
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { CfgProduct } from "../../CfgProduct.js";
|
|
11
|
+
import { Collector } from "./collectorForTest.js";
|
|
12
|
+
import { dummyCatId } from "./dummyProductForTest.js";
|
|
13
|
+
import { letterOptionCodeA, letterOptions } from "./testDataOptions.js";
|
|
14
|
+
const Prd = () => ({
|
|
15
|
+
uuid: "Prd",
|
|
16
|
+
unit: "m",
|
|
17
|
+
features: [
|
|
18
|
+
{
|
|
19
|
+
code: "NoUpcharge",
|
|
20
|
+
description: "",
|
|
21
|
+
numericOrder: false,
|
|
22
|
+
options: [
|
|
23
|
+
letterOptions[0],
|
|
24
|
+
Object.assign(Object.assign({}, letterOptions[1]), { upcharge: undefined }),
|
|
25
|
+
Object.assign(Object.assign({}, letterOptions[2]), { upcharge: 0 }),
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
code: "WithUpcharge",
|
|
30
|
+
description: "",
|
|
31
|
+
numericOrder: false,
|
|
32
|
+
options: [
|
|
33
|
+
letterOptions[0],
|
|
34
|
+
Object.assign(Object.assign({}, letterOptions[1]), { upcharge: undefined }),
|
|
35
|
+
Object.assign(Object.assign({}, letterOptions[2]), { upcharge: 10 }),
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
code: "WithUpchargeSelectMany",
|
|
40
|
+
description: "",
|
|
41
|
+
numericOrder: false,
|
|
42
|
+
optional: true,
|
|
43
|
+
options: [
|
|
44
|
+
letterOptions[0],
|
|
45
|
+
Object.assign(Object.assign({}, letterOptions[1]), { upcharge: undefined }),
|
|
46
|
+
Object.assign(Object.assign({}, letterOptions[2]), { upcharge: 10 }),
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
productData: {
|
|
51
|
+
sku: "Prd",
|
|
52
|
+
partsData: {
|
|
53
|
+
basePrice: 40,
|
|
54
|
+
currency: "EURO",
|
|
55
|
+
listPrice: 50,
|
|
56
|
+
pkgCount: 0,
|
|
57
|
+
styleNr: "",
|
|
58
|
+
selOptions: [
|
|
59
|
+
{
|
|
60
|
+
code: "!~!",
|
|
61
|
+
next: {
|
|
62
|
+
[letterOptionCodeA]: {
|
|
63
|
+
code: letterOptionCodeA,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
code: "!~!",
|
|
69
|
+
next: {
|
|
70
|
+
[letterOptionCodeA]: {
|
|
71
|
+
code: letterOptionCodeA,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
code: "!~!",
|
|
77
|
+
next: {
|
|
78
|
+
[letterOptionCodeA]: {
|
|
79
|
+
code: letterOptionCodeA,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
rootFeatureRefs: [
|
|
87
|
+
{ code: "NoUpcharge" },
|
|
88
|
+
{ code: "WithUpcharge" },
|
|
89
|
+
{ code: "WithUpchargeSelectMany" },
|
|
90
|
+
],
|
|
91
|
+
});
|
|
92
|
+
const getProduct = (params) => Promise.resolve(Prd());
|
|
93
|
+
export const getUpchargeProduct = (testFunc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
const productLoader = {
|
|
95
|
+
getProduct,
|
|
96
|
+
postValidate: (params, _body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
+
const productData = (yield getProduct(params)).productData;
|
|
98
|
+
const validateResponse = {
|
|
99
|
+
uuid: "",
|
|
100
|
+
validated: true,
|
|
101
|
+
productData,
|
|
102
|
+
};
|
|
103
|
+
return validateResponse;
|
|
104
|
+
}),
|
|
105
|
+
};
|
|
106
|
+
const product = yield CfgProduct.make(productLoader, Object.assign(Object.assign({}, dummyCatId), { partNumber: "Table" }));
|
|
107
|
+
const collect = new Collector(product);
|
|
108
|
+
const beforeSnapshot = collect.takeSnapshot();
|
|
109
|
+
yield testFunc(product);
|
|
110
|
+
const afterSnapshot = collect.takeSnapshot();
|
|
111
|
+
const diff = collect.compareSnapshot(beforeSnapshot, afterSnapshot);
|
|
112
|
+
const notifications = collect.notifications;
|
|
113
|
+
return {
|
|
114
|
+
beforeSnapshot: Collector.stripRefsForWrapper(beforeSnapshot),
|
|
115
|
+
afterSnapshot: Collector.stripRefsForWrapper(afterSnapshot),
|
|
116
|
+
diff,
|
|
117
|
+
notifications,
|
|
118
|
+
};
|
|
119
|
+
});
|
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const makeCatalogueKey: (cat:
|
|
3
|
-
export declare const makeProductKey: (cat:
|
|
4
|
-
export declare const makeSelOptionsKey: (options:
|
|
5
|
-
export declare type RootNodeSource =
|
|
6
|
-
export declare type CfgProductData = Omit<Omit<
|
|
7
|
-
models?: RootNodeSource[];
|
|
8
|
-
partsData: Omit<
|
|
9
|
-
selOptions:
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export declare type CfgProductResponse = Omit<
|
|
13
|
-
productData: CfgProductData;
|
|
14
|
-
};
|
|
15
|
-
/** This must be kept in sync with
|
|
16
|
-
export declare type CfgValidateResponse = Omit<
|
|
17
|
-
productData: CfgProductData;
|
|
18
|
-
};
|
|
19
|
-
export declare function isModel(arg:
|
|
20
|
-
/** Replace empty strings with "-" for compatibility with the API. */
|
|
21
|
-
export declare function correctDefaultsOnCatalogueParams(catId:
|
|
22
|
-
export declare function recursivelyGetPriceCodeValue(priceCodes: string[], prices:
|
|
23
|
-
export declare function comparePricesObjects(prices1:
|
|
24
|
-
export declare const decodeCatalogueParams: <T extends
|
|
25
|
-
export declare const decodeProductParams: <T extends
|
|
1
|
+
import { DtoAdditionalProductRef, DtoCatalogueParams, DtoCatalogueParamsWithLang, DtoCatalogueParamsWithoutCid, DtoMeasureParam, DtoModel, DtoOrientation, DtoPartsData, DtoPrices, DtoProductData, DtoProductParams, DtoProductParamsWithLang, DtoProductResponse, DtoSelectedOption, DtoTransform, DtoValidateResponse, DtoVector } from "./CatalogueAPI.js";
|
|
2
|
+
export declare const makeCatalogueKey: (cat: DtoCatalogueParams) => string;
|
|
3
|
+
export declare const makeProductKey: (cat: DtoCatalogueParams, pKey: string) => string;
|
|
4
|
+
export declare const makeSelOptionsKey: (options: DtoSelectedOption[]) => string;
|
|
5
|
+
export declare type RootNodeSource = DtoModel | File;
|
|
6
|
+
export declare type CfgProductData = Omit<Omit<DtoProductData, "models">, "partsData"> & {
|
|
7
|
+
models?: RootNodeSource[];
|
|
8
|
+
partsData: Omit<DtoPartsData, "selOptions"> & {
|
|
9
|
+
selOptions: DtoSelectedOption[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare type CfgProductResponse = Omit<DtoProductResponse, "productData"> & {
|
|
13
|
+
productData: CfgProductData;
|
|
14
|
+
};
|
|
15
|
+
/** This must be kept in sync with DtoValidateResponse. */
|
|
16
|
+
export declare type CfgValidateResponse = Omit<DtoValidateResponse, "productData"> & {
|
|
17
|
+
productData: CfgProductData;
|
|
18
|
+
};
|
|
19
|
+
export declare function isModel(arg: unknown): arg is DtoModel;
|
|
20
|
+
/** Replace empty strings with "-" for compatibility with the API. */
|
|
21
|
+
export declare function correctDefaultsOnCatalogueParams<T extends DtoCatalogueParamsWithoutCid>(catId: T): T;
|
|
22
|
+
export declare function recursivelyGetPriceCodeValue(priceCodes: string[], prices: DtoPrices | undefined): number | undefined;
|
|
23
|
+
export declare function comparePricesObjects(prices1: DtoPrices | undefined, prices2: DtoPrices | undefined): boolean;
|
|
24
|
+
export declare const decodeCatalogueParams: <T extends DtoCatalogueParamsWithoutCid>(params: T) => T;
|
|
25
|
+
export declare const decodeProductParams: <T extends DtoProductParams>(params: T) => T;
|
|
26
|
+
export declare function isSameCatalogueParams(left: DtoCatalogueParamsWithoutCid, right: DtoCatalogueParamsWithoutCid): boolean;
|
|
27
|
+
export declare function isSameVector(left: DtoVector, right: DtoVector): boolean;
|
|
28
|
+
export declare function isSameOrientation(left: DtoOrientation, right: DtoOrientation): boolean;
|
|
29
|
+
export declare function isSameAnchor(left: DtoMeasureParam, right: DtoMeasureParam): boolean;
|
|
30
|
+
export declare function isSameTransform(left: DtoTransform, right: DtoTransform): boolean;
|
|
31
|
+
export declare function isSameProductRef(left: DtoAdditionalProductRef, right: DtoAdditionalProductRef): boolean;
|
|
32
|
+
export declare const isSameDtoCatalogueParamsWithLang: (left: DtoCatalogueParamsWithLang, right: DtoCatalogueParamsWithLang) => boolean;
|
|
33
|
+
export declare const isSameDtoProductParamsWithLang: (left: DtoProductParamsWithLang, right: DtoProductParamsWithLang) => boolean;
|
|
26
34
|
//# sourceMappingURL=utilitiesCatalogueData.d.ts.map
|
|
@@ -1,66 +1,164 @@
|
|
|
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 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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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,40 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface CataloguePermissionByEnterpriseKey {
|
|
3
|
-
[key: string]:
|
|
4
|
-
}
|
|
5
|
-
export declare const groupAndSortCataloguePermissions: (cataloguePermissions:
|
|
6
|
-
export declare const isParamSet: (param: string) => boolean;
|
|
7
|
-
export declare const createCataloguePermissionsFilter: (enterprise: string, prdCat: string, prdCatVersion: string, priceList: string, vendor: string) => (perm:
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* @param auth
|
|
34
|
-
* @param params
|
|
35
|
-
*/
|
|
36
|
-
export declare const fillMissingPrdCatVersionFromPermissions: <T extends CatalogueParams>(params: T, cataloguePermissions: CataloguePermission[]) => T & {
|
|
37
|
-
prdCatVersion: string;
|
|
38
|
-
};
|
|
39
|
-
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: (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 {};
|
|
40
33
|
//# sourceMappingURL=utilitiesCataloguePermission.d.ts.map
|