@configura/web-api 3.0.0-alpha.1 → 3.0.0-alpha.3
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/dist/CatalogueAPI.d.ts +68 -1
- package/dist/CatalogueAPI.js +184 -219
- package/dist/CfgMeasure.js +1 -2
- package/dist/CfgProduct.d.ts +22 -3
- package/dist/CfgProduct.js +172 -162
- package/dist/io/CfgIOManager.js +2 -11
- package/dist/io/CfgIOProdConfConnector.js +14 -25
- package/dist/io/CfgObservableStateManager.js +1 -1
- package/dist/productConfiguration/CfgFeature.d.ts +5 -0
- package/dist/productConfiguration/CfgFeature.js +68 -53
- package/dist/productConfiguration/CfgOption.d.ts +8 -0
- package/dist/productConfiguration/CfgOption.js +68 -73
- package/dist/productConfiguration/CfgProductConfiguration.js +22 -34
- package/dist/productConfiguration/productParamsGenerator.js +43 -57
- package/dist/productLoader.js +2 -13
- package/dist/syncGroups/SyncGroupsHandler.js +60 -83
- package/dist/syncGroups/SyncGroupsPathHelper.js +5 -5
- package/dist/syncGroups/SyncGroupsState.js +4 -5
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +19 -1
- package/dist/syncGroups/SyncGroupsTransaction.js +352 -303
- package/dist/tasks/TaskHandler.js +53 -64
- package/dist/tests/testData/dummyProductForTest.js +4 -1
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +18 -21
- package/dist/tests/testData/testDataCachedGetProduct.js +20 -20
- package/dist/tests/testData/testDataCachedPostValidate.js +6 -15
- package/dist/tests/testData/testDataProductAggregatedPrice.js +21 -21
- package/dist/tests/testData/testDataUpcharge.js +31 -22
- package/dist/utilitiesCatalogueData.js +21 -9
- package/dist/utilitiesCataloguePermission.js +5 -2
- package/dist/utilitiesConfiguration.js +21 -23
- package/package.json +3 -3
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { augmentErrorMessage, Observable } from "@configura/web-utilities";
|
|
11
2
|
import { dtoExportFormatNames, dtoRenderFormatNames, } from "../CatalogueAPI.js";
|
|
12
3
|
import { convertDtoProductConfToV1 } from "../utilitiesConfiguration.js";
|
|
@@ -26,7 +17,7 @@ export class _TaskHandlerInternal {
|
|
|
26
17
|
task.abort();
|
|
27
18
|
}
|
|
28
19
|
};
|
|
29
|
-
this.start = (format, product, renderParams, getPreviewUrl) =>
|
|
20
|
+
this.start = async (format, product, renderParams, getPreviewUrl) => {
|
|
30
21
|
if (isRenderFormat(format)) {
|
|
31
22
|
if (!this.hasRender) {
|
|
32
23
|
throw new Error("Render has not been activated for this Catalogue");
|
|
@@ -34,18 +25,18 @@ export class _TaskHandlerInternal {
|
|
|
34
25
|
if (renderParams === undefined) {
|
|
35
26
|
throw new Error("renderParams must be set for render");
|
|
36
27
|
}
|
|
37
|
-
|
|
28
|
+
await TaskRender.make(this, format, product, renderParams, getPreviewUrl);
|
|
38
29
|
return;
|
|
39
30
|
}
|
|
40
31
|
if (isExportFormat(format)) {
|
|
41
32
|
if (!this.hasExport) {
|
|
42
33
|
throw new Error("Export has not been activated for this Catalogue");
|
|
43
34
|
}
|
|
44
|
-
|
|
35
|
+
await TaskExport.make(this, format, product, getPreviewUrl);
|
|
45
36
|
return;
|
|
46
37
|
}
|
|
47
38
|
throw new Error("Unknown export format");
|
|
48
|
-
}
|
|
39
|
+
};
|
|
49
40
|
}
|
|
50
41
|
get hasExport() {
|
|
51
42
|
return this.api.hasFeature("export");
|
|
@@ -77,7 +68,7 @@ export class TaskHandler {
|
|
|
77
68
|
constructor(_internal) {
|
|
78
69
|
this._internal = _internal;
|
|
79
70
|
this.destroy = () => this._internal.destroy();
|
|
80
|
-
this.start = (format, product, renderParams, getPreviewUrl) =>
|
|
71
|
+
this.start = async (format, product, renderParams, getPreviewUrl) => this._internal.start(format, product, renderParams, getPreviewUrl);
|
|
81
72
|
this.listenForChange = (l) => this._internal.changeObservable.listen(l);
|
|
82
73
|
this.stopListenForChange = (l) => this._internal.changeObservable.stopListen(l);
|
|
83
74
|
}
|
|
@@ -110,41 +101,41 @@ export class Task {
|
|
|
110
101
|
this.taskHandler = taskHandler;
|
|
111
102
|
this.format = format;
|
|
112
103
|
this._status = "pending";
|
|
113
|
-
this._start = () =>
|
|
114
|
-
const result =
|
|
104
|
+
this._start = async () => {
|
|
105
|
+
const result = await this.postInit();
|
|
115
106
|
this._uuid = result.uuid;
|
|
116
107
|
this._created = result.created;
|
|
117
108
|
this._modified = result.modified;
|
|
118
109
|
this.setStatus(result.status);
|
|
119
110
|
this.scheduleRefresh();
|
|
120
|
-
}
|
|
121
|
-
this.startAndRegister = () =>
|
|
111
|
+
};
|
|
112
|
+
this.startAndRegister = async () => {
|
|
122
113
|
try {
|
|
123
|
-
|
|
114
|
+
await this._start();
|
|
124
115
|
this.taskHandler.addTask(this);
|
|
125
116
|
}
|
|
126
117
|
catch (e) {
|
|
127
118
|
this.setStatus("failed");
|
|
128
119
|
throw e;
|
|
129
120
|
}
|
|
130
|
-
}
|
|
131
|
-
this.restart = () =>
|
|
121
|
+
};
|
|
122
|
+
this.restart = async () => {
|
|
132
123
|
try {
|
|
133
124
|
this.stop();
|
|
134
125
|
this.setStatus("pending");
|
|
135
|
-
|
|
126
|
+
await this._start();
|
|
136
127
|
}
|
|
137
128
|
catch (e) {
|
|
138
129
|
this.setStatus("failed");
|
|
139
130
|
throw e;
|
|
140
131
|
}
|
|
141
|
-
}
|
|
132
|
+
};
|
|
142
133
|
this.scheduleRefresh = () => {
|
|
143
134
|
this._timerId = setTimeout(this.refresh, 1000);
|
|
144
135
|
};
|
|
145
|
-
this.refresh = () =>
|
|
136
|
+
this.refresh = async () => {
|
|
146
137
|
try {
|
|
147
|
-
const result =
|
|
138
|
+
const result = await this.pollStatus();
|
|
148
139
|
this._modified = result.modified;
|
|
149
140
|
const status = result.status;
|
|
150
141
|
switch (status) {
|
|
@@ -169,7 +160,7 @@ export class Task {
|
|
|
169
160
|
this.setStatus("failed");
|
|
170
161
|
console.error(e);
|
|
171
162
|
}
|
|
172
|
-
}
|
|
163
|
+
};
|
|
173
164
|
this.abort = () => {
|
|
174
165
|
this._status = "abandoned";
|
|
175
166
|
this.stop();
|
|
@@ -227,50 +218,48 @@ class TaskRender extends Task {
|
|
|
227
218
|
super(taskHandler, format, product, getPreviewUrl);
|
|
228
219
|
this.taskParams = taskParams;
|
|
229
220
|
}
|
|
230
|
-
static make(taskHandler, format, product, taskParams, getPreviewUrl) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return t;
|
|
235
|
-
});
|
|
221
|
+
static async make(taskHandler, format, product, taskParams, getPreviewUrl) {
|
|
222
|
+
const t = new TaskRender(taskHandler, format, product, taskParams, getPreviewUrl);
|
|
223
|
+
await t.startAndRegister();
|
|
224
|
+
return t;
|
|
236
225
|
}
|
|
237
|
-
postInit() {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
226
|
+
async postInit() {
|
|
227
|
+
try {
|
|
228
|
+
return (await this.taskHandler.api.postRender(this._productParams, {
|
|
229
|
+
...this._apiSelection,
|
|
230
|
+
...this.taskParams,
|
|
231
|
+
format: this.format,
|
|
232
|
+
width: Math.floor(this.taskParams.width),
|
|
233
|
+
height: Math.floor(this.taskParams.height),
|
|
234
|
+
})).renderStatus;
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
throw augmentErrorMessage(e, "Start render request failure");
|
|
238
|
+
}
|
|
246
239
|
}
|
|
247
|
-
pollStatus() {
|
|
248
|
-
return
|
|
249
|
-
return (yield this.taskHandler.api.getRenderById({ uuid: this.uuid })).renderStatus;
|
|
250
|
-
});
|
|
240
|
+
async pollStatus() {
|
|
241
|
+
return (await this.taskHandler.api.getRenderById({ uuid: this.uuid })).renderStatus;
|
|
251
242
|
}
|
|
252
243
|
}
|
|
253
244
|
class TaskExport extends Task {
|
|
254
|
-
static make(taskHandler, format, product, getPreviewUrl) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return t;
|
|
259
|
-
});
|
|
245
|
+
static async make(taskHandler, format, product, getPreviewUrl) {
|
|
246
|
+
const t = new TaskExport(taskHandler, format, product, getPreviewUrl);
|
|
247
|
+
await t.startAndRegister();
|
|
248
|
+
return t;
|
|
260
249
|
}
|
|
261
|
-
postInit() {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
250
|
+
async postInit() {
|
|
251
|
+
try {
|
|
252
|
+
return (await this.taskHandler.api.postExport(this._productParams, {
|
|
253
|
+
...this._apiSelection,
|
|
254
|
+
format: this.format,
|
|
255
|
+
preferUnzipped: true,
|
|
256
|
+
})).exportStatus;
|
|
257
|
+
}
|
|
258
|
+
catch (e) {
|
|
259
|
+
throw augmentErrorMessage(e, "Start export request failure");
|
|
260
|
+
}
|
|
270
261
|
}
|
|
271
|
-
pollStatus() {
|
|
272
|
-
return
|
|
273
|
-
return (yield this.taskHandler.api.getExportById({ uuid: this.uuid })).exportStatus;
|
|
274
|
-
});
|
|
262
|
+
async pollStatus() {
|
|
263
|
+
return (await this.taskHandler.api.getExportById({ uuid: this.uuid })).exportStatus;
|
|
275
264
|
}
|
|
276
265
|
}
|
|
@@ -29,4 +29,7 @@ export const getDummyCfgProduct = () => CfgProduct.make({
|
|
|
29
29
|
postValidate: () => {
|
|
30
30
|
throw new Error("Should not be used");
|
|
31
31
|
},
|
|
32
|
-
},
|
|
32
|
+
}, {
|
|
33
|
+
...dummyCatId,
|
|
34
|
+
partNumber: "partNumber",
|
|
35
|
+
});
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { CfgProduct } from "../../CfgProduct.js";
|
|
11
2
|
import { Collector } from "./collectorForTest.js";
|
|
12
3
|
import { dummyCatId } from "./dummyProductForTest.js";
|
|
@@ -20,12 +11,18 @@ const A = () => ({
|
|
|
20
11
|
description: "",
|
|
21
12
|
numericOrder: false,
|
|
22
13
|
options: [
|
|
23
|
-
|
|
14
|
+
{
|
|
15
|
+
...letterOptions[0],
|
|
16
|
+
additionalProductRefs: [
|
|
24
17
|
{ refKey: "C_0", catId: dummyCatId, partNumber: "C" },
|
|
25
18
|
{ refKey: "B_0", catId: dummyCatId, partNumber: "B" },
|
|
26
|
-
]
|
|
19
|
+
],
|
|
20
|
+
},
|
|
27
21
|
letterOptions[1],
|
|
28
|
-
|
|
22
|
+
{
|
|
23
|
+
...letterOptions[2],
|
|
24
|
+
additionalProductRefs: [{ refKey: "D", catId: dummyCatId, partNumber: "D" }],
|
|
25
|
+
},
|
|
29
26
|
],
|
|
30
27
|
},
|
|
31
28
|
{
|
|
@@ -217,11 +214,11 @@ export const getTestProduct = (params) => {
|
|
|
217
214
|
}
|
|
218
215
|
throw new Error("No such part");
|
|
219
216
|
};
|
|
220
|
-
export const cfgProductTest = (testFunc, prepFunc) =>
|
|
221
|
-
const product =
|
|
217
|
+
export const cfgProductTest = async (testFunc, prepFunc) => {
|
|
218
|
+
const product = await CfgProduct.make({
|
|
222
219
|
getProduct: getTestProduct,
|
|
223
|
-
postValidate: (params, _body) =>
|
|
224
|
-
const productData = (
|
|
220
|
+
postValidate: async (params, _body) => {
|
|
221
|
+
const productData = (await getTestProduct(params)).productData;
|
|
225
222
|
const partNumber = params.partNumber;
|
|
226
223
|
if (partNumber !== "D") {
|
|
227
224
|
productData.partsData.selOptions = [
|
|
@@ -262,14 +259,14 @@ export const cfgProductTest = (testFunc, prepFunc) => __awaiter(void 0, void 0,
|
|
|
262
259
|
};
|
|
263
260
|
collect.pushNotification(`Validate ${params.enterprise} ${params.prdCat} ${params.prdCatVersion} ${params.priceList} ${params.vendor} ${params.partNumber}`);
|
|
264
261
|
return validateResponse;
|
|
265
|
-
}
|
|
266
|
-
},
|
|
262
|
+
},
|
|
263
|
+
}, { ...dummyCatId, partNumber: "A" });
|
|
267
264
|
if (prepFunc !== undefined) {
|
|
268
|
-
|
|
265
|
+
await prepFunc(product);
|
|
269
266
|
}
|
|
270
267
|
const collect = new Collector(product);
|
|
271
268
|
const beforeSnapshot = collect.takeSnapshot();
|
|
272
|
-
|
|
269
|
+
await testFunc(product);
|
|
273
270
|
const afterSnapshot = collect.takeSnapshot();
|
|
274
271
|
const diff = collect.compareSnapshot(beforeSnapshot, afterSnapshot);
|
|
275
272
|
const notifications = collect.notifications;
|
|
@@ -279,4 +276,4 @@ export const cfgProductTest = (testFunc, prepFunc) => __awaiter(void 0, void 0,
|
|
|
279
276
|
diff,
|
|
280
277
|
notifications,
|
|
281
278
|
};
|
|
282
|
-
}
|
|
279
|
+
};
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { CfgProduct } from "../../CfgProduct.js";
|
|
11
2
|
import { wrapWithGetProductCache } from "../../productLoader.js";
|
|
12
3
|
import { dummyCatId } from "./dummyProductForTest.js";
|
|
@@ -21,12 +12,21 @@ const A = () => ({
|
|
|
21
12
|
description: "",
|
|
22
13
|
numericOrder: false,
|
|
23
14
|
options: [
|
|
24
|
-
|
|
15
|
+
{
|
|
16
|
+
...letterOptions[0],
|
|
17
|
+
additionalProductRefs: [
|
|
25
18
|
{ refKey: "C_0", catId: dummyCatId, partNumber: "C" },
|
|
26
19
|
{ refKey: "B_0", catId: dummyCatId, partNumber: "B" },
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
...letterOptions[1],
|
|
24
|
+
additionalProductRefs: [{ refKey: "E", catId: dummyCatId, partNumber: "E" }],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
...letterOptions[2],
|
|
28
|
+
additionalProductRefs: [{ refKey: "D", catId: dummyCatId, partNumber: "D" }],
|
|
29
|
+
},
|
|
30
30
|
],
|
|
31
31
|
},
|
|
32
32
|
],
|
|
@@ -148,12 +148,12 @@ export const getTestProduct = (params, validateCall) => {
|
|
|
148
148
|
}
|
|
149
149
|
throw new Error("No such part");
|
|
150
150
|
};
|
|
151
|
-
export const cachedProductLoaderTest = () =>
|
|
151
|
+
export const cachedProductLoaderTest = async () => {
|
|
152
152
|
prodKeyArray = [];
|
|
153
153
|
const productLoader = {
|
|
154
154
|
getProduct: getTestProduct,
|
|
155
|
-
postValidate: (params, _body) =>
|
|
156
|
-
const productData = (
|
|
155
|
+
postValidate: async (params, _body) => {
|
|
156
|
+
const productData = (await getTestProduct(params, true)).productData;
|
|
157
157
|
let code = letterOptionCodeA;
|
|
158
158
|
for (const test in _body.selOptions[0].next) {
|
|
159
159
|
code = test;
|
|
@@ -177,11 +177,11 @@ export const cachedProductLoaderTest = () => __awaiter(void 0, void 0, void 0, f
|
|
|
177
177
|
features: [],
|
|
178
178
|
};
|
|
179
179
|
return validateResponse;
|
|
180
|
-
}
|
|
180
|
+
},
|
|
181
181
|
};
|
|
182
|
-
const productWrapper =
|
|
182
|
+
const productWrapper = await CfgProduct.make({
|
|
183
183
|
getProduct: wrapWithGetProductCache(productLoader.getProduct.bind(productLoader)),
|
|
184
184
|
postValidate: productLoader.postValidate.bind(productLoader),
|
|
185
|
-
},
|
|
185
|
+
}, { ...dummyCatId, partNumber: "A" });
|
|
186
186
|
return productWrapper;
|
|
187
|
-
}
|
|
187
|
+
};
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { CfgProduct } from "../../CfgProduct.js";
|
|
11
2
|
import { dummyCatId } from "./dummyProductForTest.js";
|
|
12
3
|
const Table = () => ({
|
|
@@ -163,12 +154,12 @@ const getProduct = (params) => {
|
|
|
163
154
|
}
|
|
164
155
|
throw new Error("No such part");
|
|
165
156
|
};
|
|
166
|
-
export const cachedProductLoaderTest = () =>
|
|
157
|
+
export const cachedProductLoaderTest = async () => {
|
|
167
158
|
const validateCounter = { count: 0 };
|
|
168
159
|
const productLoader = {
|
|
169
160
|
getProduct,
|
|
170
|
-
postValidate: (params, _body) =>
|
|
171
|
-
const productData = (
|
|
161
|
+
postValidate: async (params, _body) => {
|
|
162
|
+
const productData = (await getProduct(params)).productData;
|
|
172
163
|
const validateResponse = {
|
|
173
164
|
uuid: "",
|
|
174
165
|
unit: "m",
|
|
@@ -178,8 +169,8 @@ export const cachedProductLoaderTest = () => __awaiter(void 0, void 0, void 0, f
|
|
|
178
169
|
};
|
|
179
170
|
validateCounter.count++;
|
|
180
171
|
return validateResponse;
|
|
181
|
-
}
|
|
172
|
+
},
|
|
182
173
|
};
|
|
183
|
-
const product =
|
|
174
|
+
const product = await CfgProduct.make(productLoader, { ...dummyCatId, partNumber: "Table" });
|
|
184
175
|
return { product, validateCounter };
|
|
185
|
-
}
|
|
176
|
+
};
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { CfgProduct } from "../../CfgProduct.js";
|
|
11
2
|
import { dummyCatId } from "./dummyProductForTest.js";
|
|
12
3
|
import { letterOptionCodeA, letterOptionCodeB, letterOptionCodeC, letterOptions, } from "./testDataOptions.js";
|
|
@@ -19,12 +10,21 @@ const A = () => ({
|
|
|
19
10
|
description: "",
|
|
20
11
|
numericOrder: false,
|
|
21
12
|
options: [
|
|
22
|
-
|
|
13
|
+
{
|
|
14
|
+
...letterOptions[0],
|
|
15
|
+
additionalProductRefs: [
|
|
23
16
|
{ refKey: "C_0", catId: dummyCatId, partNumber: "C" },
|
|
24
17
|
{ refKey: "B_0", catId: dummyCatId, partNumber: "B" },
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
...letterOptions[1],
|
|
22
|
+
additionalProductRefs: [{ refKey: "E", catId: dummyCatId, partNumber: "E" }],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
...letterOptions[2],
|
|
26
|
+
additionalProductRefs: [{ refKey: "D", catId: dummyCatId, partNumber: "D" }],
|
|
27
|
+
},
|
|
28
28
|
],
|
|
29
29
|
},
|
|
30
30
|
],
|
|
@@ -164,11 +164,11 @@ export function getSelOptions(option) {
|
|
|
164
164
|
];
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
export const cfgProductPriceTest = (testFunc, featureOption) =>
|
|
168
|
-
const cfgProduct =
|
|
167
|
+
export const cfgProductPriceTest = async (testFunc, featureOption) => {
|
|
168
|
+
const cfgProduct = await CfgProduct.make({
|
|
169
169
|
getProduct: getTestProduct,
|
|
170
|
-
postValidate: (params, _body) =>
|
|
171
|
-
const productData = (
|
|
170
|
+
postValidate: async (params, _body) => {
|
|
171
|
+
const productData = (await getTestProduct(params)).productData;
|
|
172
172
|
if (featureOption !== undefined && params.partNumber === "A") {
|
|
173
173
|
productData.partsData.selOptions = getSelOptions(featureOption);
|
|
174
174
|
}
|
|
@@ -180,10 +180,10 @@ export const cfgProductPriceTest = (testFunc, featureOption) => __awaiter(void 0
|
|
|
180
180
|
features: [],
|
|
181
181
|
};
|
|
182
182
|
return validateResponse;
|
|
183
|
-
}
|
|
184
|
-
},
|
|
183
|
+
},
|
|
184
|
+
}, { ...dummyCatId, partNumber: "A" });
|
|
185
185
|
if (testFunc !== undefined) {
|
|
186
|
-
|
|
186
|
+
await testFunc(cfgProduct);
|
|
187
187
|
}
|
|
188
188
|
return cfgProduct;
|
|
189
|
-
}
|
|
189
|
+
};
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { CfgProduct } from "../../CfgProduct.js";
|
|
11
2
|
import { Collector } from "./collectorForTest.js";
|
|
12
3
|
import { dummyCatId } from "./dummyProductForTest.js";
|
|
@@ -21,8 +12,14 @@ const Prd = () => ({
|
|
|
21
12
|
numericOrder: false,
|
|
22
13
|
options: [
|
|
23
14
|
letterOptions[0],
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
{
|
|
16
|
+
...letterOptions[1],
|
|
17
|
+
upcharge: undefined,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
...letterOptions[2],
|
|
21
|
+
upcharge: 0,
|
|
22
|
+
},
|
|
26
23
|
],
|
|
27
24
|
},
|
|
28
25
|
{
|
|
@@ -31,8 +28,14 @@ const Prd = () => ({
|
|
|
31
28
|
numericOrder: false,
|
|
32
29
|
options: [
|
|
33
30
|
letterOptions[0],
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
{
|
|
32
|
+
...letterOptions[1],
|
|
33
|
+
upcharge: undefined,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
...letterOptions[2],
|
|
37
|
+
upcharge: 10,
|
|
38
|
+
},
|
|
36
39
|
],
|
|
37
40
|
},
|
|
38
41
|
{
|
|
@@ -42,8 +45,14 @@ const Prd = () => ({
|
|
|
42
45
|
optional: true,
|
|
43
46
|
options: [
|
|
44
47
|
letterOptions[0],
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
{
|
|
49
|
+
...letterOptions[1],
|
|
50
|
+
upcharge: undefined,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
...letterOptions[2],
|
|
54
|
+
upcharge: 10,
|
|
55
|
+
},
|
|
47
56
|
],
|
|
48
57
|
},
|
|
49
58
|
],
|
|
@@ -90,11 +99,11 @@ const Prd = () => ({
|
|
|
90
99
|
],
|
|
91
100
|
});
|
|
92
101
|
const getProduct = (params) => Promise.resolve(Prd());
|
|
93
|
-
export const getUpchargeProduct = (testFunc) =>
|
|
102
|
+
export const getUpchargeProduct = async (testFunc) => {
|
|
94
103
|
const productLoader = {
|
|
95
104
|
getProduct,
|
|
96
|
-
postValidate: (params, _body) =>
|
|
97
|
-
const productData = (
|
|
105
|
+
postValidate: async (params, _body) => {
|
|
106
|
+
const productData = (await getProduct(params)).productData;
|
|
98
107
|
const validateResponse = {
|
|
99
108
|
uuid: "",
|
|
100
109
|
unit: "m",
|
|
@@ -103,12 +112,12 @@ export const getUpchargeProduct = (testFunc) => __awaiter(void 0, void 0, void 0
|
|
|
103
112
|
features: [],
|
|
104
113
|
};
|
|
105
114
|
return validateResponse;
|
|
106
|
-
}
|
|
115
|
+
},
|
|
107
116
|
};
|
|
108
|
-
const product =
|
|
117
|
+
const product = await CfgProduct.make(productLoader, { ...dummyCatId, partNumber: "Table" });
|
|
109
118
|
const collect = new Collector(product);
|
|
110
119
|
const beforeSnapshot = collect.takeSnapshot();
|
|
111
|
-
|
|
120
|
+
await testFunc(product);
|
|
112
121
|
const afterSnapshot = collect.takeSnapshot();
|
|
113
122
|
const diff = collect.compareSnapshot(beforeSnapshot, afterSnapshot);
|
|
114
123
|
const notifications = collect.notifications;
|
|
@@ -118,4 +127,4 @@ export const getUpchargeProduct = (testFunc) => __awaiter(void 0, void 0, void 0
|
|
|
118
127
|
diff,
|
|
119
128
|
notifications,
|
|
120
129
|
};
|
|
121
|
-
}
|
|
130
|
+
};
|
|
@@ -11,10 +11,9 @@ export const makeProductKey = (prod) => `${makeCatalogueKey(prod)}-${prod.partNu
|
|
|
11
11
|
* Makes a string from selected options, can be used as a key for a selection.
|
|
12
12
|
*/
|
|
13
13
|
export const makeSelOptionsKey = (options) => options.reduce((p, option) => {
|
|
14
|
-
var _a;
|
|
15
14
|
const { code, numericValue, next } = option;
|
|
16
15
|
p += `_{${code}`;
|
|
17
|
-
p += numericValue === undefined ? "" : `_${numericValue.value}${
|
|
16
|
+
p += numericValue === undefined ? "" : `_${numericValue.value}${numericValue.unit ?? ""}`;
|
|
18
17
|
if (next === undefined) {
|
|
19
18
|
return p;
|
|
20
19
|
}
|
|
@@ -38,12 +37,16 @@ export function isModel(arg) {
|
|
|
38
37
|
/** Replace empty strings with "-" for compatibility with the API. */
|
|
39
38
|
export function correctDefaultsOnCatalogueParams(catId) {
|
|
40
39
|
// Enterprise, prdCat and vendor have to be set, so we don't try and fix those
|
|
41
|
-
return
|
|
40
|
+
return {
|
|
41
|
+
...catId,
|
|
42
|
+
prdCatVersion: catId.prdCatVersion || "-",
|
|
43
|
+
priceList: catId.priceList || "-",
|
|
44
|
+
};
|
|
42
45
|
}
|
|
43
46
|
export function recursivelyGetPriceCodeValue(priceCodes, prices) {
|
|
44
47
|
while (prices) {
|
|
45
48
|
for (const name of priceCodes) {
|
|
46
|
-
const priceCodeUpcharge = prices
|
|
49
|
+
const priceCodeUpcharge = prices?.values[name];
|
|
47
50
|
if (priceCodeUpcharge !== undefined) {
|
|
48
51
|
return priceCodeUpcharge;
|
|
49
52
|
}
|
|
@@ -66,8 +69,18 @@ export function comparePricesObjects(prices1, prices2) {
|
|
|
66
69
|
}
|
|
67
70
|
return shallowCompareDictionaries(prices1.values, prices2.values);
|
|
68
71
|
}
|
|
69
|
-
export const decodeCatalogueParams = (params) => (
|
|
70
|
-
|
|
72
|
+
export const decodeCatalogueParams = (params) => ({
|
|
73
|
+
...params,
|
|
74
|
+
enterprise: decodeURIComponent(params.enterprise),
|
|
75
|
+
prdCat: decodeURIComponent(params.prdCat),
|
|
76
|
+
prdCatVersion: decodeURIComponent(params.prdCatVersion),
|
|
77
|
+
priceList: decodeURIComponent(params.priceList),
|
|
78
|
+
vendor: decodeURIComponent(params.vendor),
|
|
79
|
+
});
|
|
80
|
+
export const decodeProductParams = (params) => ({
|
|
81
|
+
...decodeCatalogueParams(params),
|
|
82
|
+
partNumber: decodeURIComponent(params.partNumber),
|
|
83
|
+
});
|
|
71
84
|
export function isSameCatalogueParams(left, right) {
|
|
72
85
|
return (left.cid === right.cid &&
|
|
73
86
|
left.enterprise === right.enterprise &&
|
|
@@ -83,15 +96,14 @@ export function isSameOrientation(left, right) {
|
|
|
83
96
|
return left.pitch === right.pitch && left.roll === right.roll && left.yaw === right.yaw;
|
|
84
97
|
}
|
|
85
98
|
export function isSameAnchor(left, right) {
|
|
86
|
-
var _a, _b;
|
|
87
99
|
if (left.code !== right.code) {
|
|
88
100
|
return false;
|
|
89
101
|
}
|
|
90
102
|
if (left.anchorPoint !== right.anchorPoint) {
|
|
91
103
|
return false;
|
|
92
104
|
}
|
|
93
|
-
const leftMeasurePriorities =
|
|
94
|
-
const rightMeasurePriorities =
|
|
105
|
+
const leftMeasurePriorities = left.measurePriority ?? [];
|
|
106
|
+
const rightMeasurePriorities = right.measurePriority ?? [];
|
|
95
107
|
if (leftMeasurePriorities.length !== rightMeasurePriorities.length) {
|
|
96
108
|
return false;
|
|
97
109
|
}
|
|
@@ -35,7 +35,7 @@ export const createCataloguePermissionsFilter = (catParams) => {
|
|
|
35
35
|
* string compare.
|
|
36
36
|
*/
|
|
37
37
|
export const getPrdCatVersionFromPermissions = (cataloguePermissions, catParams) => {
|
|
38
|
-
const filter = createCataloguePermissionsFilter(
|
|
38
|
+
const filter = createCataloguePermissionsFilter({ ...catParams, prdCatVersion: undefined });
|
|
39
39
|
const applicablePermissions = cataloguePermissions.filter(filter);
|
|
40
40
|
return applicablePermissions.reduce((pVersion, c) => {
|
|
41
41
|
const cVersion = c.prdCatVersion;
|
|
@@ -72,4 +72,7 @@ export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermiss
|
|
|
72
72
|
* cataloguePermissions and insert it into a copy of the original params. If it fails to find any
|
|
73
73
|
* applicable auth-permissions the original value is returned.
|
|
74
74
|
*/
|
|
75
|
-
export const fillMissingPrdCatVersionFromPermissions = (params, cataloguePermissions) => (
|
|
75
|
+
export const fillMissingPrdCatVersionFromPermissions = (params, cataloguePermissions) => ({
|
|
76
|
+
...params,
|
|
77
|
+
prdCatVersion: getPrdCatVersionOrLatestFromPermissions(params, cataloguePermissions),
|
|
78
|
+
});
|