@configura/web-api 1.6.1-alpha.4 → 1.6.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 +507 -511
- package/dist/CatalogueAPI.js +280 -273
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +258 -257
- package/dist/CfgProduct.js +747 -732
- package/dist/index.d.ts +20 -20
- package/dist/index.js +20 -20
- 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 +188 -179
- package/dist/productConfiguration/CfgFeature.js +636 -617
- package/dist/productConfiguration/CfgOption.d.ts +150 -150
- package/dist/productConfiguration/CfgOption.js +426 -426
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +120 -120
- package/dist/productConfiguration/CfgProductConfiguration.js +309 -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 +20 -20
- package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
- package/dist/syncGroups/SyncGroupsHandler.d.ts +40 -39
- package/dist/syncGroups/SyncGroupsHandler.js +358 -352
- package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
- package/dist/syncGroups/SyncGroupsPathHelper.js +90 -89
- package/dist/syncGroups/SyncGroupsState.d.ts +35 -25
- package/dist/syncGroups/SyncGroupsState.js +125 -111
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -50
- package/dist/syncGroups/SyncGroupsTransaction.js +576 -100
- package/dist/tasks/TaskHandler.d.ts +78 -78
- package/dist/tasks/TaskHandler.js +276 -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 +36 -36
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -32
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +277 -277
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +185 -185
- 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 +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 +187 -187
- package/dist/tests/testData/testDataUpcharge.d.ts +8 -29
- package/dist/tests/testData/testDataUpcharge.js +119 -119
- package/dist/utilitiesCatalogueData.d.ts +31 -31
- package/dist/utilitiesCatalogueData.js +162 -168
- package/dist/utilitiesCataloguePermission.d.ts +37 -39
- package/dist/utilitiesCataloguePermission.js +80 -84
- package/dist/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +109 -109
- package/package.json +3 -3
- package/dist/syncGroups/SyncGroupsApplier.d.ts +0 -20
- package/dist/syncGroups/SyncGroupsApplier.js +0 -520
|
@@ -1,119 +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
|
-
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) =>
|
|
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, "lang", dummyCatId, "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
|
+
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, "lang", dummyCatId, "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,32 +1,32 @@
|
|
|
1
|
-
import { AdditionalProductRef, CatalogueParams, GetProductParams, MeasureParam, Model, Orientation, PartsData, Prices, ProductData, ProductResponse, SelectedOption, Transform, ValidateResponse, Vector } from "./CatalogueAPI.js";
|
|
2
|
-
export declare const makeCatalogueKey: (cat: CatalogueParams) => string;
|
|
3
|
-
export declare const makeProductKey: (cat: CatalogueParams, pKey: string) => string;
|
|
4
|
-
export declare const makeSelOptionsKey: (options: SelectedOption[]) => string;
|
|
5
|
-
export declare type RootNodeSource = Model | File;
|
|
6
|
-
export declare type CfgProductData = Omit<Omit<ProductData, "models">, "partsData"> & {
|
|
7
|
-
models?: RootNodeSource[];
|
|
8
|
-
partsData: Omit<PartsData, "selOptions"> & {
|
|
9
|
-
selOptions: SelectedOption[];
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export declare type CfgProductResponse = Omit<ProductResponse, "productData"> & {
|
|
13
|
-
productData: CfgProductData;
|
|
14
|
-
};
|
|
15
|
-
/** This must be kept in sync with ValidateResponse. */
|
|
16
|
-
export declare type CfgValidateResponse = Omit<ValidateResponse, "productData"> & {
|
|
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: CatalogueParams): CatalogueParams;
|
|
22
|
-
export declare function recursivelyGetPriceCodeValue(priceCodes: string[], prices: Prices | undefined): number | undefined;
|
|
23
|
-
export declare function comparePricesObjects(prices1: Prices | undefined, prices2: Prices | undefined): boolean;
|
|
24
|
-
export declare const decodeCatalogueParams: <T extends CatalogueParams>(params: T) => T;
|
|
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;
|
|
1
|
+
import { AdditionalProductRef, CatalogueParams, GetProductParams, MeasureParam, Model, Orientation, PartsData, Prices, ProductData, ProductResponse, SelectedOption, Transform, ValidateResponse, Vector } from "./CatalogueAPI.js";
|
|
2
|
+
export declare const makeCatalogueKey: (cat: CatalogueParams) => string;
|
|
3
|
+
export declare const makeProductKey: (cat: CatalogueParams, pKey: string) => string;
|
|
4
|
+
export declare const makeSelOptionsKey: (options: SelectedOption[]) => string;
|
|
5
|
+
export declare type RootNodeSource = Model | File;
|
|
6
|
+
export declare type CfgProductData = Omit<Omit<ProductData, "models">, "partsData"> & {
|
|
7
|
+
models?: RootNodeSource[];
|
|
8
|
+
partsData: Omit<PartsData, "selOptions"> & {
|
|
9
|
+
selOptions: SelectedOption[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare type CfgProductResponse = Omit<ProductResponse, "productData"> & {
|
|
13
|
+
productData: CfgProductData;
|
|
14
|
+
};
|
|
15
|
+
/** This must be kept in sync with ValidateResponse. */
|
|
16
|
+
export declare type CfgValidateResponse = Omit<ValidateResponse, "productData"> & {
|
|
17
|
+
productData: CfgProductData;
|
|
18
|
+
};
|
|
19
|
+
export declare function isModel(arg: unknown): arg is Model;
|
|
20
|
+
/** Replace empty strings with "-" for compatibility with the API. */
|
|
21
|
+
export declare function correctDefaultsOnCatalogueParams(catId: CatalogueParams): CatalogueParams;
|
|
22
|
+
export declare function recursivelyGetPriceCodeValue(priceCodes: string[], prices: Prices | undefined): number | undefined;
|
|
23
|
+
export declare function comparePricesObjects(prices1: Prices | undefined, prices2: Prices | undefined): boolean;
|
|
24
|
+
export declare const decodeCatalogueParams: <T extends CatalogueParams>(params: T) => T;
|
|
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;
|
|
32
32
|
//# sourceMappingURL=utilitiesCatalogueData.d.ts.map
|
|
@@ -1,168 +1,162 @@
|
|
|
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
|
-
enterprise: catId.enterprise,
|
|
27
|
-
prdCat: catId.prdCat,
|
|
28
|
-
prdCatVersion: catId.prdCatVersion || "-",
|
|
29
|
-
priceList: catId.priceList || "-",
|
|
30
|
-
vendor: catId.vendor,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function recursivelyGetPriceCodeValue(priceCodes, prices) {
|
|
34
|
-
while (prices) {
|
|
35
|
-
for (const name of priceCodes) {
|
|
36
|
-
const priceCodeUpcharge = prices === null || prices === void 0 ? void 0 : prices.values[name];
|
|
37
|
-
if (priceCodeUpcharge !== undefined) {
|
|
38
|
-
return priceCodeUpcharge;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
prices = prices.parent;
|
|
42
|
-
}
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
export function comparePricesObjects(prices1, prices2) {
|
|
46
|
-
if (prices1 === undefined && prices2 === undefined) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
if (prices1 === undefined || prices2 === undefined) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
const parent1 = prices1.parent;
|
|
53
|
-
const parent2 = prices2.parent;
|
|
54
|
-
if (!comparePricesObjects(parent1, parent2)) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
return shallowCompareDictionaries(prices1.values, prices2.values);
|
|
58
|
-
}
|
|
59
|
-
export const decodeCatalogueParams = (params) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
export function
|
|
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
|
-
if ((
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (left.
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
if (left.
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
if (left.optional !== right.optional) {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
1
|
+
import { shallowCompareDictionaries } from "@configura/web-utilities";
|
|
2
|
+
export const makeCatalogueKey = (cat) => `${cat.enterprise}-${cat.prdCat}-${cat.prdCatVersion}-${cat.priceList}-${cat.vendor}`;
|
|
3
|
+
export const makeProductKey = (cat, pKey) => `${makeCatalogueKey(cat)}-${pKey}`;
|
|
4
|
+
export const makeSelOptionsKey = (options) => options.reduce((p, option) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const { code, numericValue, next } = option;
|
|
7
|
+
p += `_{${code}`;
|
|
8
|
+
p += numericValue === undefined ? "" : `_${numericValue.value}${(_a = numericValue.unit) !== null && _a !== void 0 ? _a : ""}`;
|
|
9
|
+
if (next === undefined) {
|
|
10
|
+
return p;
|
|
11
|
+
}
|
|
12
|
+
for (const key of Object.keys(next)) {
|
|
13
|
+
const innerOption = next[key];
|
|
14
|
+
p += `_{${key}_${makeSelOptionsKey([innerOption])}_}`;
|
|
15
|
+
}
|
|
16
|
+
p += "_}";
|
|
17
|
+
return p;
|
|
18
|
+
}, "");
|
|
19
|
+
export function isModel(arg) {
|
|
20
|
+
return typeof arg === "object" && arg !== null && "cid" in arg && "uri" in arg;
|
|
21
|
+
}
|
|
22
|
+
/** Replace empty strings with "-" for compatibility with the API. */
|
|
23
|
+
export function correctDefaultsOnCatalogueParams(catId) {
|
|
24
|
+
// Enterprise, prdCat and vendor have to be set, so we don't try and fix those
|
|
25
|
+
return {
|
|
26
|
+
enterprise: catId.enterprise,
|
|
27
|
+
prdCat: catId.prdCat,
|
|
28
|
+
prdCatVersion: catId.prdCatVersion || "-",
|
|
29
|
+
priceList: catId.priceList || "-",
|
|
30
|
+
vendor: catId.vendor,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function recursivelyGetPriceCodeValue(priceCodes, prices) {
|
|
34
|
+
while (prices) {
|
|
35
|
+
for (const name of priceCodes) {
|
|
36
|
+
const priceCodeUpcharge = prices === null || prices === void 0 ? void 0 : prices.values[name];
|
|
37
|
+
if (priceCodeUpcharge !== undefined) {
|
|
38
|
+
return priceCodeUpcharge;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
prices = prices.parent;
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
export function comparePricesObjects(prices1, prices2) {
|
|
46
|
+
if (prices1 === undefined && prices2 === undefined) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (prices1 === undefined || prices2 === undefined) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const parent1 = prices1.parent;
|
|
53
|
+
const parent2 = prices2.parent;
|
|
54
|
+
if (!comparePricesObjects(parent1, parent2)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return shallowCompareDictionaries(prices1.values, prices2.values);
|
|
58
|
+
}
|
|
59
|
+
export const decodeCatalogueParams = (params) => (Object.assign(Object.assign({}, params), { enterprise: decodeURIComponent(params.enterprise), prdCat: decodeURIComponent(params.prdCat), prdCatVersion: decodeURIComponent(params.prdCatVersion), priceList: decodeURIComponent(params.priceList), vendor: decodeURIComponent(params.vendor) }));
|
|
60
|
+
export const decodeProductParams = (params) => (Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) }));
|
|
61
|
+
export function isSameCatalogueParams(left, right) {
|
|
62
|
+
return (left.enterprise === right.enterprise &&
|
|
63
|
+
left.prdCat === right.prdCat &&
|
|
64
|
+
left.prdCatVersion === right.prdCatVersion &&
|
|
65
|
+
left.priceList === right.priceList &&
|
|
66
|
+
left.vendor === right.vendor);
|
|
67
|
+
}
|
|
68
|
+
export function isSameVector(left, right) {
|
|
69
|
+
return left.x === right.x && left.y === right.y && left.z === right.z;
|
|
70
|
+
}
|
|
71
|
+
export function isSameOrientation(left, right) {
|
|
72
|
+
return left.pitch === right.pitch && left.roll === right.roll && left.yaw === right.yaw;
|
|
73
|
+
}
|
|
74
|
+
export function isSameAnchor(left, right) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (left.code !== right.code) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (left.anchorPoint !== right.anchorPoint) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const leftMeasurePriorities = (_a = left.measurePriority) !== null && _a !== void 0 ? _a : [];
|
|
83
|
+
const rightMeasurePriorities = (_b = right.measurePriority) !== null && _b !== void 0 ? _b : [];
|
|
84
|
+
if (leftMeasurePriorities.length !== rightMeasurePriorities.length) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (leftMeasurePriorities.some((p, i) => p.url !== rightMeasurePriorities[i].url)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
export function isSameTransform(left, right) {
|
|
93
|
+
const leftTransformPos = left.pos;
|
|
94
|
+
const rightTransformPos = right.pos;
|
|
95
|
+
const leftTransformRot = left.rot;
|
|
96
|
+
const rightTransformRot = right.rot;
|
|
97
|
+
const leftTransformScale = left.scale;
|
|
98
|
+
const rightTransformScale = right.scale;
|
|
99
|
+
if ((leftTransformPos === undefined) !== (rightTransformPos === undefined)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
if ((leftTransformRot === undefined) !== (rightTransformRot === undefined)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if ((leftTransformScale === undefined) !== (rightTransformScale === undefined)) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (leftTransformPos !== undefined &&
|
|
109
|
+
rightTransformPos !== undefined &&
|
|
110
|
+
!isSameVector(leftTransformPos, rightTransformPos)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (leftTransformRot !== undefined &&
|
|
114
|
+
rightTransformRot !== undefined &&
|
|
115
|
+
!isSameOrientation(leftTransformRot, rightTransformRot)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if (leftTransformScale !== undefined &&
|
|
119
|
+
rightTransformScale !== undefined &&
|
|
120
|
+
!isSameVector(leftTransformScale, rightTransformScale)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
export function isSameProductRef(left, right) {
|
|
126
|
+
if (left.refKey !== right.refKey) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
if (left.partNumber !== right.partNumber) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
if (!isSameCatalogueParams(left.catId, right.catId)) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
if (left.refDescription !== right.refDescription) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
const leftAnchor = left.anchor;
|
|
139
|
+
const rightAnchor = right.anchor;
|
|
140
|
+
if ((leftAnchor === undefined) !== (rightAnchor === undefined)) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
if (leftAnchor !== undefined &&
|
|
144
|
+
rightAnchor !== undefined &&
|
|
145
|
+
!isSameAnchor(leftAnchor, rightAnchor)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
const leftTransform = left.transform;
|
|
149
|
+
const rightTransform = right.transform;
|
|
150
|
+
if ((leftTransform === undefined) !== (rightTransform === undefined)) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
if (leftTransform !== undefined &&
|
|
154
|
+
rightTransform !== undefined &&
|
|
155
|
+
!isSameTransform(leftTransform, rightTransform)) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
if (left.optional !== right.optional) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|