@configura/web-api 1.3.0-alpha.3 → 1.3.0
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/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +502 -448
- package/dist/CatalogueAPI.js +206 -206
- package/dist/CfgMeasure.d.ts +33 -0
- package/dist/CfgMeasure.js +30 -0
- package/dist/CfgProduct.d.ts +217 -116
- package/dist/CfgProduct.js +634 -588
- package/dist/index.d.ts +16 -15
- package/dist/index.js +16 -15
- package/dist/material/CfgMaterialMapping.d.ts +7 -7
- package/dist/material/CfgMaterialMapping.js +181 -176
- 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 +160 -134
- package/dist/productConfiguration/CfgFeature.js +593 -483
- package/dist/productConfiguration/CfgOption.d.ts +128 -112
- package/dist/productConfiguration/CfgOption.js +394 -293
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +120 -50
- package/dist/productConfiguration/CfgProductConfiguration.js +307 -198
- package/dist/productConfiguration/filters.d.ts +7 -7
- package/dist/productConfiguration/filters.js +29 -29
- package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
- package/dist/productConfiguration/productParamsGenerator.js +51 -51
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -9
- package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -61
- package/dist/productLoader.d.ts +33 -11
- package/dist/productLoader.js +49 -41
- package/dist/tests/testData/collectorForTest.d.ts +73 -73
- package/dist/tests/testData/collectorForTest.js +195 -195
- package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
- package/dist/tests/testData/dummyProductForTest.js +36 -35
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +32 -32
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +381 -368
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +205 -199
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +195 -189
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1119 -1117
- package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +28 -28
- package/dist/tests/testData/testDataProductAggregatedPrice.js +210 -205
- package/dist/tests/testData/testDataUpcharge.d.ts +29 -29
- package/dist/tests/testData/testDataUpcharge.js +163 -159
- package/dist/utilitiesCatalogueData.d.ts +22 -20
- package/dist/utilitiesCatalogueData.js +64 -64
- package/dist/utilitiesCataloguePermission.d.ts +39 -39
- package/dist/utilitiesCataloguePermission.js +84 -84
- package/dist/utilitiesNumericValues.d.ts +25 -0
- package/dist/utilitiesNumericValues.js +109 -0
- package/package.json +3 -3
|
@@ -1,159 +1,163 @@
|
|
|
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
|
-
const Prd = () => ({
|
|
14
|
-
uuid: "Prd",
|
|
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
|
-
|
|
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
|
-
code: "
|
|
67
|
-
description: "",
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
+
const Prd = () => ({
|
|
14
|
+
uuid: "Prd",
|
|
15
|
+
unit: "m",
|
|
16
|
+
features: [
|
|
17
|
+
{
|
|
18
|
+
code: "NoUpcharge",
|
|
19
|
+
description: "",
|
|
20
|
+
numericOrder: false,
|
|
21
|
+
options: [
|
|
22
|
+
{
|
|
23
|
+
code: "A",
|
|
24
|
+
description: "",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
code: "B",
|
|
28
|
+
description: "",
|
|
29
|
+
upcharge: undefined,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
code: "C",
|
|
33
|
+
description: "",
|
|
34
|
+
upcharge: 0,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
code: "WithUpcharge",
|
|
40
|
+
description: "",
|
|
41
|
+
numericOrder: false,
|
|
42
|
+
options: [
|
|
43
|
+
{
|
|
44
|
+
code: "A",
|
|
45
|
+
description: "",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
code: "B",
|
|
49
|
+
description: "",
|
|
50
|
+
upcharge: undefined,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
code: "C",
|
|
54
|
+
description: "",
|
|
55
|
+
upcharge: 10,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
code: "WithUpchargeSelectMany",
|
|
61
|
+
description: "",
|
|
62
|
+
numericOrder: false,
|
|
63
|
+
optional: true,
|
|
64
|
+
options: [
|
|
65
|
+
{
|
|
66
|
+
code: "A",
|
|
67
|
+
description: "",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
code: "B",
|
|
71
|
+
description: "",
|
|
72
|
+
upcharge: undefined,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
code: "C",
|
|
76
|
+
description: "",
|
|
77
|
+
upcharge: 10,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
productData: {
|
|
83
|
+
sku: "Prd",
|
|
84
|
+
partsData: {
|
|
85
|
+
basePrice: 40,
|
|
86
|
+
currency: "EURO",
|
|
87
|
+
listPrice: 50,
|
|
88
|
+
pkgCount: 0,
|
|
89
|
+
styleNr: "",
|
|
90
|
+
selOptions: [
|
|
91
|
+
{
|
|
92
|
+
code: "!~!",
|
|
93
|
+
feature: "NoUpcharge",
|
|
94
|
+
featDesc: "",
|
|
95
|
+
next: {
|
|
96
|
+
A: {
|
|
97
|
+
code: "A",
|
|
98
|
+
feature: "NoUpcharge",
|
|
99
|
+
featDesc: "",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
code: "!~!",
|
|
105
|
+
feature: "WithUpcharge",
|
|
106
|
+
featDesc: "",
|
|
107
|
+
next: {
|
|
108
|
+
A: {
|
|
109
|
+
code: "A",
|
|
110
|
+
feature: "WithUpcharge",
|
|
111
|
+
featDesc: "",
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
code: "!~!",
|
|
117
|
+
feature: "WithUpchargeSelectMany",
|
|
118
|
+
featDesc: "",
|
|
119
|
+
next: {
|
|
120
|
+
A: {
|
|
121
|
+
code: "A",
|
|
122
|
+
feature: "WithUpchargeSelectMany",
|
|
123
|
+
featDesc: "",
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
rootFeatureRefs: [
|
|
131
|
+
{ code: "NoUpcharge" },
|
|
132
|
+
{ code: "WithUpcharge" },
|
|
133
|
+
{ code: "WithUpchargeSelectMany" },
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
const getProduct = (params) => __awaiter(void 0, void 0, void 0, function* () { return Prd(); });
|
|
137
|
+
export const getUpchargeProduct = (testFunc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
+
const productLoader = {
|
|
139
|
+
getProduct,
|
|
140
|
+
postValidate: (params, _body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
+
const productData = (yield getProduct(params)).productData;
|
|
142
|
+
const validateResponse = {
|
|
143
|
+
uuid: "",
|
|
144
|
+
validated: true,
|
|
145
|
+
productData,
|
|
146
|
+
};
|
|
147
|
+
return validateResponse;
|
|
148
|
+
}),
|
|
149
|
+
};
|
|
150
|
+
const product = yield CfgProduct.make(productLoader, "lang", dummyCatId, "Table");
|
|
151
|
+
const collect = new Collector(product);
|
|
152
|
+
const beforeSnapshot = collect.takeSnapshot();
|
|
153
|
+
yield testFunc(product);
|
|
154
|
+
const afterSnapshot = collect.takeSnapshot();
|
|
155
|
+
const diff = collect.compareSnapshot(beforeSnapshot, afterSnapshot);
|
|
156
|
+
const notifications = collect.notifications;
|
|
157
|
+
return {
|
|
158
|
+
beforeSnapshot: Collector.stripRefsForWrapper(beforeSnapshot),
|
|
159
|
+
afterSnapshot: Collector.stripRefsForWrapper(afterSnapshot),
|
|
160
|
+
diff,
|
|
161
|
+
notifications,
|
|
162
|
+
};
|
|
163
|
+
});
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { CatalogueParams, GetProductParams, Model, Prices, ProductData, ProductResponse, SelectedOption, ValidateResponse } from "./CatalogueAPI";
|
|
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<ProductData, "models"> & {
|
|
7
|
-
models?: RootNodeSource[];
|
|
8
|
-
};
|
|
9
|
-
export declare type CfgProductResponse = Omit<ProductResponse, "productData"> & {
|
|
10
|
-
productData: CfgProductData;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export declare function
|
|
17
|
-
|
|
18
|
-
export declare function
|
|
19
|
-
export declare
|
|
20
|
-
export declare
|
|
1
|
+
import { CatalogueParams, GetProductParams, Model, Prices, ProductData, ProductResponse, SelectedOption, ValidateResponse } from "./CatalogueAPI";
|
|
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<ProductData, "models"> & {
|
|
7
|
+
models?: RootNodeSource[];
|
|
8
|
+
};
|
|
9
|
+
export declare type CfgProductResponse = Omit<ProductResponse, "productData"> & {
|
|
10
|
+
productData: CfgProductData;
|
|
11
|
+
};
|
|
12
|
+
/** This must be kept in sync with ValidateResponse. */
|
|
13
|
+
export declare type CfgValidateResponse = Omit<ValidateResponse, "productData"> & {
|
|
14
|
+
productData: CfgProductData;
|
|
15
|
+
};
|
|
16
|
+
export declare function isModel(arg: any): arg is Model;
|
|
17
|
+
/** Replace empty strings with "-" for compatibility with the API. */
|
|
18
|
+
export declare function correctDefaultsOnCatalogueParams(catId: CatalogueParams): CatalogueParams;
|
|
19
|
+
export declare function recursivelyGetPriceCodeValue(priceCodes: string[], prices: Prices | undefined): number | undefined;
|
|
20
|
+
export declare function comparePricesObjects(prices1: Prices | undefined, prices2: Prices | undefined): boolean;
|
|
21
|
+
export declare const decodeCatalogueParams: <T extends CatalogueParams>(params: T) => T;
|
|
22
|
+
export declare const decodeProductParams: <T extends GetProductParams>(params: T) => T;
|
|
21
23
|
//# sourceMappingURL=utilitiesCatalogueData.d.ts.map
|
|
@@ -1,64 +1,64 @@
|
|
|
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
|
-
const { code, next } = option;
|
|
6
|
-
p += "_{" + code;
|
|
7
|
-
if (next === undefined) {
|
|
8
|
-
return p;
|
|
9
|
-
}
|
|
10
|
-
for (const key of Object.keys(next)) {
|
|
11
|
-
const innerOption = next[key];
|
|
12
|
-
p += "_{" + key + "_" + makeSelOptionsKey([innerOption]) + "_}";
|
|
13
|
-
}
|
|
14
|
-
p += "_}";
|
|
15
|
-
return p;
|
|
16
|
-
}, "");
|
|
17
|
-
export function isModel(arg) {
|
|
18
|
-
return arg.cid !== undefined && arg.uri !== undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function correctDefaultsOnCatalogueParams(catId) {
|
|
22
|
-
// Enterprise, prdCat and vendor have to be set, so we don't try and fix those
|
|
23
|
-
return {
|
|
24
|
-
enterprise: catId.enterprise,
|
|
25
|
-
prdCat: catId.prdCat,
|
|
26
|
-
prdCatVersion: catId.prdCatVersion || "-",
|
|
27
|
-
priceList: catId.priceList || "-",
|
|
28
|
-
vendor: catId.vendor,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export function recursivelyGetPriceCodeValue(priceCodes, prices) {
|
|
32
|
-
while (prices) {
|
|
33
|
-
for (const name of priceCodes) {
|
|
34
|
-
const priceCodeUpcharge = prices === null || prices === void 0 ? void 0 : prices.values[name];
|
|
35
|
-
if (priceCodeUpcharge !== undefined) {
|
|
36
|
-
return priceCodeUpcharge;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
prices = prices.parent;
|
|
40
|
-
}
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
export function comparePricesObjects(prices1, prices2) {
|
|
44
|
-
if (prices1 === undefined && prices2 === undefined) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
if (prices1 === undefined || prices2 === undefined) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
const parent1 = prices1.parent;
|
|
51
|
-
const parent2 = prices2.parent;
|
|
52
|
-
if (!comparePricesObjects(parent1, parent2)) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return shallowCompareDictionaries(prices1.values, prices2.values);
|
|
56
|
-
}
|
|
57
|
-
export const decodeCatalogueParams = (params) => {
|
|
58
|
-
const decoded = 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) });
|
|
59
|
-
return decoded;
|
|
60
|
-
};
|
|
61
|
-
export const decodeProductParams = (params) => {
|
|
62
|
-
const decoded = Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) });
|
|
63
|
-
return decoded;
|
|
64
|
-
};
|
|
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
|
+
const { code, next } = option;
|
|
6
|
+
p += "_{" + code;
|
|
7
|
+
if (next === undefined) {
|
|
8
|
+
return p;
|
|
9
|
+
}
|
|
10
|
+
for (const key of Object.keys(next)) {
|
|
11
|
+
const innerOption = next[key];
|
|
12
|
+
p += "_{" + key + "_" + makeSelOptionsKey([innerOption]) + "_}";
|
|
13
|
+
}
|
|
14
|
+
p += "_}";
|
|
15
|
+
return p;
|
|
16
|
+
}, "");
|
|
17
|
+
export function isModel(arg) {
|
|
18
|
+
return arg.cid !== undefined && arg.uri !== undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Replace empty strings with "-" for compatibility with the API. */
|
|
21
|
+
export function correctDefaultsOnCatalogueParams(catId) {
|
|
22
|
+
// Enterprise, prdCat and vendor have to be set, so we don't try and fix those
|
|
23
|
+
return {
|
|
24
|
+
enterprise: catId.enterprise,
|
|
25
|
+
prdCat: catId.prdCat,
|
|
26
|
+
prdCatVersion: catId.prdCatVersion || "-",
|
|
27
|
+
priceList: catId.priceList || "-",
|
|
28
|
+
vendor: catId.vendor,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function recursivelyGetPriceCodeValue(priceCodes, prices) {
|
|
32
|
+
while (prices) {
|
|
33
|
+
for (const name of priceCodes) {
|
|
34
|
+
const priceCodeUpcharge = prices === null || prices === void 0 ? void 0 : prices.values[name];
|
|
35
|
+
if (priceCodeUpcharge !== undefined) {
|
|
36
|
+
return priceCodeUpcharge;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
prices = prices.parent;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
export function comparePricesObjects(prices1, prices2) {
|
|
44
|
+
if (prices1 === undefined && prices2 === undefined) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (prices1 === undefined || prices2 === undefined) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const parent1 = prices1.parent;
|
|
51
|
+
const parent2 = prices2.parent;
|
|
52
|
+
if (!comparePricesObjects(parent1, parent2)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return shallowCompareDictionaries(prices1.values, prices2.values);
|
|
56
|
+
}
|
|
57
|
+
export const decodeCatalogueParams = (params) => {
|
|
58
|
+
const decoded = 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) });
|
|
59
|
+
return decoded;
|
|
60
|
+
};
|
|
61
|
+
export const decodeProductParams = (params) => {
|
|
62
|
+
const decoded = Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) });
|
|
63
|
+
return decoded;
|
|
64
|
+
};
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { CatalogueParams, CataloguePermission } from "./CatalogueAPI.js";
|
|
2
|
-
interface CataloguePermissionByEnterpriseKey {
|
|
3
|
-
[key: string]: CataloguePermission[];
|
|
4
|
-
}
|
|
5
|
-
export declare const groupAndSortCataloguePermissions: (cataloguePermissions: CataloguePermission[]) => CataloguePermissionByEnterpriseKey;
|
|
6
|
-
export declare const isParamSet: (param: string) => boolean;
|
|
7
|
-
export declare const createCataloguePermissionsFilter: (enterprise: string, prdCat: string, prdCatVersion: string, priceList: string, vendor: string) => (perm: CataloguePermission) => 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
|
-
* @param cataloguePermissions
|
|
14
|
-
* @param enterprise
|
|
15
|
-
* @param prdCat
|
|
16
|
-
* @param priceList
|
|
17
|
-
* @param vendor
|
|
18
|
-
*/
|
|
19
|
-
export declare const getPrdCatVersionFromPermissions: (cataloguePermissions: CataloguePermission[], enterprise: string, prdCat: string, priceList: string, vendor: string) => string | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
|
|
22
|
-
* This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
|
|
23
|
-
* permissions. If it fails to find any applicable permissions the original value is returned.
|
|
24
|
-
* @param auth
|
|
25
|
-
* @param params
|
|
26
|
-
*/
|
|
27
|
-
export declare const getPrdCatVersionOrLatestFromPermissions: (params: CatalogueParams, cataloguePermissions: CataloguePermission[]) => string;
|
|
28
|
-
/**
|
|
29
|
-
* Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
|
|
30
|
-
* This method will, if the prdCatVersion is not set, fetch the highest available from the
|
|
31
|
-
* cataloguePermissions and insert it into a copy of the original params. If it fails to find any
|
|
32
|
-
* applicable auth-permissions the original value is returned.
|
|
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 { CatalogueParams, CataloguePermission } from "./CatalogueAPI.js";
|
|
2
|
+
interface CataloguePermissionByEnterpriseKey {
|
|
3
|
+
[key: string]: CataloguePermission[];
|
|
4
|
+
}
|
|
5
|
+
export declare const groupAndSortCataloguePermissions: (cataloguePermissions: CataloguePermission[]) => CataloguePermissionByEnterpriseKey;
|
|
6
|
+
export declare const isParamSet: (param: string) => boolean;
|
|
7
|
+
export declare const createCataloguePermissionsFilter: (enterprise: string, prdCat: string, prdCatVersion: string, priceList: string, vendor: string) => (perm: CataloguePermission) => 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
|
+
* @param cataloguePermissions
|
|
14
|
+
* @param enterprise
|
|
15
|
+
* @param prdCat
|
|
16
|
+
* @param priceList
|
|
17
|
+
* @param vendor
|
|
18
|
+
*/
|
|
19
|
+
export declare const getPrdCatVersionFromPermissions: (cataloguePermissions: CataloguePermission[], enterprise: string, prdCat: string, priceList: string, vendor: string) => string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
|
|
22
|
+
* This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
|
|
23
|
+
* permissions. If it fails to find any applicable permissions the original value is returned.
|
|
24
|
+
* @param auth
|
|
25
|
+
* @param params
|
|
26
|
+
*/
|
|
27
|
+
export declare const getPrdCatVersionOrLatestFromPermissions: (params: CatalogueParams, cataloguePermissions: CataloguePermission[]) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
|
|
30
|
+
* This method will, if the prdCatVersion is not set, fetch the highest available from the
|
|
31
|
+
* cataloguePermissions and insert it into a copy of the original params. If it fails to find any
|
|
32
|
+
* applicable auth-permissions the original value is returned.
|
|
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 {};
|
|
40
40
|
//# sourceMappingURL=utilitiesCataloguePermission.d.ts.map
|