@configura/web-api 1.3.0-alpha.0 → 1.3.0-alpha.4

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.
Files changed (53) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +1 -1
  3. package/dist/CatalogueAPI.d.ts +448 -448
  4. package/dist/CatalogueAPI.js +206 -206
  5. package/dist/CfgProduct.d.ts +116 -116
  6. package/dist/CfgProduct.js +588 -588
  7. package/dist/index.d.ts +15 -15
  8. package/dist/index.js +15 -15
  9. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  10. package/dist/material/CfgMaterialMapping.js +176 -176
  11. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  12. package/dist/material/CfgMtrlApplication.js +43 -43
  13. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  14. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  15. package/dist/material/CfgMtrlSource.d.ts +19 -19
  16. package/dist/material/CfgMtrlSource.js +40 -40
  17. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  18. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  19. package/dist/productConfiguration/CfgFeature.d.ts +134 -80
  20. package/dist/productConfiguration/CfgFeature.js +483 -451
  21. package/dist/productConfiguration/CfgOption.d.ts +112 -64
  22. package/dist/productConfiguration/CfgOption.js +293 -263
  23. package/dist/productConfiguration/CfgProductConfiguration.d.ts +50 -50
  24. package/dist/productConfiguration/CfgProductConfiguration.js +198 -198
  25. package/dist/productConfiguration/filters.d.ts +7 -7
  26. package/dist/productConfiguration/filters.js +29 -29
  27. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  28. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  29. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +9 -9
  30. package/dist/productConfiguration/utilitiesProductConfiguration.js +61 -61
  31. package/dist/productLoader.d.ts +11 -11
  32. package/dist/productLoader.js +41 -41
  33. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  34. package/dist/tests/testData/collectorForTest.js +195 -195
  35. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  36. package/dist/tests/testData/dummyProductForTest.js +35 -35
  37. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +32 -32
  38. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +368 -368
  39. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  40. package/dist/tests/testData/testDataCachedGetProduct.js +199 -199
  41. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  42. package/dist/tests/testData/testDataCachedPostValidate.js +189 -189
  43. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  44. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1117 -1117
  45. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +28 -28
  46. package/dist/tests/testData/testDataProductAggregatedPrice.js +205 -205
  47. package/dist/tests/testData/testDataUpcharge.d.ts +29 -29
  48. package/dist/tests/testData/testDataUpcharge.js +159 -159
  49. package/dist/utilitiesCatalogueData.d.ts +20 -18
  50. package/dist/utilitiesCatalogueData.js +64 -56
  51. package/dist/utilitiesCataloguePermission.d.ts +39 -39
  52. package/dist/utilitiesCataloguePermission.js +84 -84
  53. package/package.json +3 -3
@@ -1,368 +1,368 @@
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";
11
- import { Collector } from "./collectorForTest";
12
- import { dummyCatId } from "./dummyProductForTest";
13
- const A = () => ({
14
- uuid: "A",
15
- features: [
16
- {
17
- code: "featureA",
18
- description: "",
19
- options: [
20
- {
21
- code: "optionA",
22
- description: "",
23
- additionalProductRefs: [
24
- { refKey: "C_0", catId: dummyCatId, partNumber: "C" },
25
- { refKey: "B_0", catId: dummyCatId, partNumber: "B" },
26
- ],
27
- },
28
- {
29
- code: "optionB",
30
- description: "",
31
- },
32
- {
33
- code: "optionC",
34
- description: "",
35
- additionalProductRefs: [{ refKey: "D", catId: dummyCatId, partNumber: "D" }],
36
- },
37
- ],
38
- },
39
- {
40
- code: "featureX",
41
- description: "",
42
- options: [
43
- {
44
- code: "optionA",
45
- description: "",
46
- },
47
- {
48
- code: "optionB",
49
- description: "",
50
- },
51
- {
52
- code: "optionC",
53
- description: "",
54
- },
55
- ],
56
- },
57
- {
58
- code: "featureNotUsed",
59
- description: "",
60
- options: [
61
- {
62
- code: "optionA",
63
- description: "",
64
- },
65
- {
66
- code: "optionB",
67
- description: "",
68
- },
69
- ],
70
- },
71
- {
72
- code: "featureOptionCSelectedAtStart",
73
- description: "",
74
- options: [
75
- {
76
- code: "optionA",
77
- description: "",
78
- },
79
- {
80
- code: "optionB",
81
- description: "",
82
- },
83
- {
84
- code: "optionC",
85
- description: "",
86
- },
87
- ],
88
- },
89
- {
90
- code: "featureSelectMany",
91
- description: "",
92
- options: [
93
- {
94
- code: "optionA",
95
- description: "",
96
- },
97
- {
98
- code: "optionB",
99
- description: "",
100
- },
101
- {
102
- code: "optionC",
103
- description: "",
104
- },
105
- ],
106
- },
107
- ],
108
- productData: {
109
- sku: "A",
110
- partsData: {
111
- basePrice: 0,
112
- currency: "",
113
- listPrice: 0,
114
- pkgCount: 0,
115
- styleNr: "",
116
- selOptions: [
117
- {
118
- code: "!~!",
119
- feature: "featureA",
120
- featDesc: "",
121
- next: {
122
- optionA: {
123
- code: "optionA",
124
- feature: "featureA",
125
- featDesc: "",
126
- },
127
- },
128
- },
129
- {
130
- code: "!~!",
131
- feature: "featureX",
132
- featDesc: "",
133
- next: {
134
- optionB: {
135
- code: "optionB",
136
- feature: "featureX",
137
- featDesc: "",
138
- },
139
- },
140
- },
141
- {
142
- code: "!~!",
143
- feature: "featureOptionCSelectedAtStart",
144
- featDesc: "",
145
- next: {
146
- optionC: {
147
- code: "optionC",
148
- feature: "featureOptionCSelectedAtStart",
149
- featDesc: "",
150
- },
151
- },
152
- },
153
- ],
154
- },
155
- additionalProductRefs: [
156
- { refKey: "B_1", catId: dummyCatId, partNumber: "B", optional: true },
157
- ],
158
- },
159
- rootFeatureRefs: [
160
- { code: "featureA" },
161
- { code: "featureX" },
162
- { code: "featureOptionCSelectedAtStart" },
163
- ],
164
- });
165
- const B = () => ({
166
- uuid: "B",
167
- features: [
168
- {
169
- code: "featureI",
170
- description: "",
171
- options: [
172
- { code: "optionI0", description: "" },
173
- { code: "optionI1", description: "", featureRefs: [{ code: "featureII" }] },
174
- ],
175
- },
176
- {
177
- code: "featureII",
178
- description: "",
179
- options: [
180
- { code: "optionII0", description: "" },
181
- { code: "optionII1", description: "", featureRefs: [{ code: "featureIII" }] },
182
- ],
183
- },
184
- {
185
- code: "featureIII",
186
- description: "",
187
- options: [
188
- { code: "optionIII0", description: "" },
189
- { code: "optionIII1", description: "" },
190
- ],
191
- },
192
- ],
193
- productData: {
194
- sku: "B",
195
- partsData: {
196
- basePrice: 0,
197
- currency: "",
198
- listPrice: 0,
199
- pkgCount: 0,
200
- selOptions: [
201
- {
202
- code: "!~!",
203
- feature: "featureI",
204
- featDesc: "",
205
- next: {
206
- optionI0: {
207
- code: "optionI0",
208
- feature: "featureI",
209
- featDesc: "",
210
- },
211
- },
212
- },
213
- ],
214
- styleNr: "",
215
- },
216
- additionalProductRefs: [{ refKey: "C_0", catId: dummyCatId, partNumber: "C" }],
217
- },
218
- rootFeatureRefs: [{ code: "featureI" }],
219
- });
220
- const C = () => ({
221
- uuid: "C",
222
- features: [
223
- {
224
- code: "featureC",
225
- description: "",
226
- options: [
227
- {
228
- code: "optionA",
229
- description: "",
230
- },
231
- {
232
- code: "optionB",
233
- description: "",
234
- },
235
- {
236
- code: "optionC",
237
- description: "",
238
- },
239
- ],
240
- },
241
- ],
242
- productData: {
243
- sku: "C",
244
- partsData: {
245
- basePrice: 0,
246
- currency: "",
247
- listPrice: 0,
248
- pkgCount: 0,
249
- selOptions: [
250
- {
251
- code: "!~!",
252
- feature: "featureC",
253
- featDesc: "",
254
- next: {
255
- optionA: {
256
- code: "optionA",
257
- feature: "featureC",
258
- featDesc: "",
259
- },
260
- },
261
- },
262
- ],
263
- styleNr: "",
264
- },
265
- },
266
- rootFeatureRefs: [{ code: "featureC" }],
267
- });
268
- const D = () => ({
269
- uuid: "D",
270
- features: [],
271
- productData: {
272
- sku: "D",
273
- partsData: {
274
- basePrice: 0,
275
- currency: "",
276
- listPrice: 0,
277
- pkgCount: 0,
278
- selOptions: [],
279
- styleNr: "",
280
- },
281
- },
282
- rootFeatureRefs: [],
283
- });
284
- export const getTestProduct = (params) => __awaiter(void 0, void 0, void 0, function* () {
285
- const partNumber = params.partNumber;
286
- switch (partNumber) {
287
- case "A":
288
- return A();
289
- case "B":
290
- return B();
291
- case "C":
292
- return C();
293
- case "D":
294
- return D();
295
- }
296
- throw new Error("No such part");
297
- });
298
- export const cfgProductTest = (testFunc, prepFunc) => __awaiter(void 0, void 0, void 0, function* () {
299
- const product = yield CfgProduct.make({
300
- getProduct: getTestProduct,
301
- postValidate: (params, _body) => __awaiter(void 0, void 0, void 0, function* () {
302
- const productData = (yield getTestProduct(params)).productData;
303
- const feat = productData.partsData.selOptions[0].feature;
304
- productData.partsData.selOptions = [
305
- {
306
- code: "!~!",
307
- feature: feat,
308
- featDesc: "",
309
- next: {
310
- optionC: {
311
- code: "optionC",
312
- feature: feat,
313
- featDesc: "",
314
- },
315
- },
316
- },
317
- ];
318
- if (params.partNumber === "A") {
319
- productData.partsData.selOptions.push({
320
- code: "!~!",
321
- feature: "featureX",
322
- featDesc: "",
323
- next: {
324
- optionC: {
325
- code: "optionC",
326
- feature: "featureX",
327
- featDesc: "",
328
- },
329
- },
330
- });
331
- productData.partsData.selOptions.push({
332
- code: "!~!",
333
- feature: "featureOptionCSelectedAtStart",
334
- featDesc: "",
335
- next: {
336
- optionC: {
337
- code: "optionC",
338
- feature: "featureOptionCSelectedAtStart",
339
- featDesc: "",
340
- },
341
- },
342
- });
343
- }
344
- const validateResponse = {
345
- uuid: "",
346
- validated: true,
347
- productData,
348
- };
349
- collect.pushNotification(`Validate ${params.enterprise} ${params.prdCat} ${params.prdCatVersion} ${params.priceList} ${params.vendor} ${params.partNumber}`);
350
- return validateResponse;
351
- }),
352
- }, "lang", dummyCatId, "A");
353
- if (prepFunc !== undefined) {
354
- yield prepFunc(product);
355
- }
356
- const collect = new Collector(product);
357
- const beforeSnapshot = collect.takeSnapshot();
358
- yield testFunc(product);
359
- const afterSnapshot = collect.takeSnapshot();
360
- const diff = collect.compareSnapshot(beforeSnapshot, afterSnapshot);
361
- const notifications = collect.notifications;
362
- return {
363
- beforeSnapshot: Collector.stripRefsForWrapper(beforeSnapshot),
364
- afterSnapshot: Collector.stripRefsForWrapper(afterSnapshot),
365
- diff,
366
- notifications,
367
- };
368
- });
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";
11
+ import { Collector } from "./collectorForTest";
12
+ import { dummyCatId } from "./dummyProductForTest";
13
+ const A = () => ({
14
+ uuid: "A",
15
+ features: [
16
+ {
17
+ code: "featureA",
18
+ description: "",
19
+ options: [
20
+ {
21
+ code: "optionA",
22
+ description: "",
23
+ additionalProductRefs: [
24
+ { refKey: "C_0", catId: dummyCatId, partNumber: "C" },
25
+ { refKey: "B_0", catId: dummyCatId, partNumber: "B" },
26
+ ],
27
+ },
28
+ {
29
+ code: "optionB",
30
+ description: "",
31
+ },
32
+ {
33
+ code: "optionC",
34
+ description: "",
35
+ additionalProductRefs: [{ refKey: "D", catId: dummyCatId, partNumber: "D" }],
36
+ },
37
+ ],
38
+ },
39
+ {
40
+ code: "featureX",
41
+ description: "",
42
+ options: [
43
+ {
44
+ code: "optionA",
45
+ description: "",
46
+ },
47
+ {
48
+ code: "optionB",
49
+ description: "",
50
+ },
51
+ {
52
+ code: "optionC",
53
+ description: "",
54
+ },
55
+ ],
56
+ },
57
+ {
58
+ code: "featureNotUsed",
59
+ description: "",
60
+ options: [
61
+ {
62
+ code: "optionA",
63
+ description: "",
64
+ },
65
+ {
66
+ code: "optionB",
67
+ description: "",
68
+ },
69
+ ],
70
+ },
71
+ {
72
+ code: "featureOptionCSelectedAtStart",
73
+ description: "",
74
+ options: [
75
+ {
76
+ code: "optionA",
77
+ description: "",
78
+ },
79
+ {
80
+ code: "optionB",
81
+ description: "",
82
+ },
83
+ {
84
+ code: "optionC",
85
+ description: "",
86
+ },
87
+ ],
88
+ },
89
+ {
90
+ code: "featureSelectMany",
91
+ description: "",
92
+ options: [
93
+ {
94
+ code: "optionA",
95
+ description: "",
96
+ },
97
+ {
98
+ code: "optionB",
99
+ description: "",
100
+ },
101
+ {
102
+ code: "optionC",
103
+ description: "",
104
+ },
105
+ ],
106
+ },
107
+ ],
108
+ productData: {
109
+ sku: "A",
110
+ partsData: {
111
+ basePrice: 0,
112
+ currency: "",
113
+ listPrice: 0,
114
+ pkgCount: 0,
115
+ styleNr: "",
116
+ selOptions: [
117
+ {
118
+ code: "!~!",
119
+ feature: "featureA",
120
+ featDesc: "",
121
+ next: {
122
+ optionA: {
123
+ code: "optionA",
124
+ feature: "featureA",
125
+ featDesc: "",
126
+ },
127
+ },
128
+ },
129
+ {
130
+ code: "!~!",
131
+ feature: "featureX",
132
+ featDesc: "",
133
+ next: {
134
+ optionB: {
135
+ code: "optionB",
136
+ feature: "featureX",
137
+ featDesc: "",
138
+ },
139
+ },
140
+ },
141
+ {
142
+ code: "!~!",
143
+ feature: "featureOptionCSelectedAtStart",
144
+ featDesc: "",
145
+ next: {
146
+ optionC: {
147
+ code: "optionC",
148
+ feature: "featureOptionCSelectedAtStart",
149
+ featDesc: "",
150
+ },
151
+ },
152
+ },
153
+ ],
154
+ },
155
+ additionalProductRefs: [
156
+ { refKey: "B_1", catId: dummyCatId, partNumber: "B", optional: true },
157
+ ],
158
+ },
159
+ rootFeatureRefs: [
160
+ { code: "featureA" },
161
+ { code: "featureX" },
162
+ { code: "featureOptionCSelectedAtStart" },
163
+ ],
164
+ });
165
+ const B = () => ({
166
+ uuid: "B",
167
+ features: [
168
+ {
169
+ code: "featureI",
170
+ description: "",
171
+ options: [
172
+ { code: "optionI0", description: "" },
173
+ { code: "optionI1", description: "", featureRefs: [{ code: "featureII" }] },
174
+ ],
175
+ },
176
+ {
177
+ code: "featureII",
178
+ description: "",
179
+ options: [
180
+ { code: "optionII0", description: "" },
181
+ { code: "optionII1", description: "", featureRefs: [{ code: "featureIII" }] },
182
+ ],
183
+ },
184
+ {
185
+ code: "featureIII",
186
+ description: "",
187
+ options: [
188
+ { code: "optionIII0", description: "" },
189
+ { code: "optionIII1", description: "" },
190
+ ],
191
+ },
192
+ ],
193
+ productData: {
194
+ sku: "B",
195
+ partsData: {
196
+ basePrice: 0,
197
+ currency: "",
198
+ listPrice: 0,
199
+ pkgCount: 0,
200
+ selOptions: [
201
+ {
202
+ code: "!~!",
203
+ feature: "featureI",
204
+ featDesc: "",
205
+ next: {
206
+ optionI0: {
207
+ code: "optionI0",
208
+ feature: "featureI",
209
+ featDesc: "",
210
+ },
211
+ },
212
+ },
213
+ ],
214
+ styleNr: "",
215
+ },
216
+ additionalProductRefs: [{ refKey: "C_0", catId: dummyCatId, partNumber: "C" }],
217
+ },
218
+ rootFeatureRefs: [{ code: "featureI" }],
219
+ });
220
+ const C = () => ({
221
+ uuid: "C",
222
+ features: [
223
+ {
224
+ code: "featureC",
225
+ description: "",
226
+ options: [
227
+ {
228
+ code: "optionA",
229
+ description: "",
230
+ },
231
+ {
232
+ code: "optionB",
233
+ description: "",
234
+ },
235
+ {
236
+ code: "optionC",
237
+ description: "",
238
+ },
239
+ ],
240
+ },
241
+ ],
242
+ productData: {
243
+ sku: "C",
244
+ partsData: {
245
+ basePrice: 0,
246
+ currency: "",
247
+ listPrice: 0,
248
+ pkgCount: 0,
249
+ selOptions: [
250
+ {
251
+ code: "!~!",
252
+ feature: "featureC",
253
+ featDesc: "",
254
+ next: {
255
+ optionA: {
256
+ code: "optionA",
257
+ feature: "featureC",
258
+ featDesc: "",
259
+ },
260
+ },
261
+ },
262
+ ],
263
+ styleNr: "",
264
+ },
265
+ },
266
+ rootFeatureRefs: [{ code: "featureC" }],
267
+ });
268
+ const D = () => ({
269
+ uuid: "D",
270
+ features: [],
271
+ productData: {
272
+ sku: "D",
273
+ partsData: {
274
+ basePrice: 0,
275
+ currency: "",
276
+ listPrice: 0,
277
+ pkgCount: 0,
278
+ selOptions: [],
279
+ styleNr: "",
280
+ },
281
+ },
282
+ rootFeatureRefs: [],
283
+ });
284
+ export const getTestProduct = (params) => __awaiter(void 0, void 0, void 0, function* () {
285
+ const partNumber = params.partNumber;
286
+ switch (partNumber) {
287
+ case "A":
288
+ return A();
289
+ case "B":
290
+ return B();
291
+ case "C":
292
+ return C();
293
+ case "D":
294
+ return D();
295
+ }
296
+ throw new Error("No such part");
297
+ });
298
+ export const cfgProductTest = (testFunc, prepFunc) => __awaiter(void 0, void 0, void 0, function* () {
299
+ const product = yield CfgProduct.make({
300
+ getProduct: getTestProduct,
301
+ postValidate: (params, _body) => __awaiter(void 0, void 0, void 0, function* () {
302
+ const productData = (yield getTestProduct(params)).productData;
303
+ const feat = productData.partsData.selOptions[0].feature;
304
+ productData.partsData.selOptions = [
305
+ {
306
+ code: "!~!",
307
+ feature: feat,
308
+ featDesc: "",
309
+ next: {
310
+ optionC: {
311
+ code: "optionC",
312
+ feature: feat,
313
+ featDesc: "",
314
+ },
315
+ },
316
+ },
317
+ ];
318
+ if (params.partNumber === "A") {
319
+ productData.partsData.selOptions.push({
320
+ code: "!~!",
321
+ feature: "featureX",
322
+ featDesc: "",
323
+ next: {
324
+ optionC: {
325
+ code: "optionC",
326
+ feature: "featureX",
327
+ featDesc: "",
328
+ },
329
+ },
330
+ });
331
+ productData.partsData.selOptions.push({
332
+ code: "!~!",
333
+ feature: "featureOptionCSelectedAtStart",
334
+ featDesc: "",
335
+ next: {
336
+ optionC: {
337
+ code: "optionC",
338
+ feature: "featureOptionCSelectedAtStart",
339
+ featDesc: "",
340
+ },
341
+ },
342
+ });
343
+ }
344
+ const validateResponse = {
345
+ uuid: "",
346
+ validated: true,
347
+ productData,
348
+ };
349
+ collect.pushNotification(`Validate ${params.enterprise} ${params.prdCat} ${params.prdCatVersion} ${params.priceList} ${params.vendor} ${params.partNumber}`);
350
+ return validateResponse;
351
+ }),
352
+ }, "lang", dummyCatId, "A");
353
+ if (prepFunc !== undefined) {
354
+ yield prepFunc(product);
355
+ }
356
+ const collect = new Collector(product);
357
+ const beforeSnapshot = collect.takeSnapshot();
358
+ yield testFunc(product);
359
+ const afterSnapshot = collect.takeSnapshot();
360
+ const diff = collect.compareSnapshot(beforeSnapshot, afterSnapshot);
361
+ const notifications = collect.notifications;
362
+ return {
363
+ beforeSnapshot: Collector.stripRefsForWrapper(beforeSnapshot),
364
+ afterSnapshot: Collector.stripRefsForWrapper(afterSnapshot),
365
+ diff,
366
+ notifications,
367
+ };
368
+ });