@contrail/cli 3.5.0-alpha.dd20a19 → 3.5.1-alpha.68d57e0
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/README.md +1 -33
- package/node_modules/@contrail/loader/lib/color-processor.js +9 -23
- package/node_modules/@contrail/loader/lib/color-processor.spec.js +112 -62
- package/node_modules/@contrail/loader/lib/common/chunk-by-url-length.d.ts +1 -1
- package/node_modules/@contrail/loader/lib/common/chunk-by-url-length.js +2 -0
- package/node_modules/@contrail/loader/lib/common/chunk-by-url-length.spec.js +4 -0
- package/node_modules/@contrail/loader/lib/common/color-validation.d.ts +26 -0
- package/node_modules/@contrail/loader/lib/common/color-validation.js +163 -0
- package/node_modules/@contrail/loader/lib/common/color-validation.spec.js +102 -0
- package/node_modules/@contrail/loader/lib/common/size-range-helpers.js +0 -1
- package/node_modules/@contrail/loader/lib/constants.d.ts +0 -3
- package/node_modules/@contrail/loader/lib/constants.js +1 -4
- package/node_modules/@contrail/loader/lib/entities-v2/colors-v2/color-processor-v2.js +9 -23
- package/node_modules/@contrail/loader/lib/entities-v2/colors-v2/color-processor-v2.spec.js +112 -62
- package/node_modules/@contrail/loader/lib/entities-v2/entities-helper.js +0 -1
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/assortment-processor.js +0 -1
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +8 -22
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +43 -1
- package/node_modules/@contrail/loader/lib/pipeline/identifier-resolver.d.ts +5 -0
- package/node_modules/@contrail/loader/lib/pipeline/identifier-resolver.js +562 -0
- package/node_modules/@contrail/loader/lib/pipeline/identifier-resolver.spec.js +231 -0
- package/node_modules/@contrail/loader/lib/pipeline/item-execute-helpers.js +77 -3
- package/node_modules/@contrail/loader/lib/pipeline/item-execute-helpers.spec.js +82 -0
- package/node_modules/@contrail/loader/lib/pipeline/preview.js +0 -5
- package/node_modules/@contrail/loader/lib/pipeline/preview.spec.js +2 -2
- package/node_modules/@contrail/loader/lib/pipeline/project-item-execute-helpers.js +1 -1
- package/node_modules/@contrail/loader/lib/pipeline/transform.js +18 -0
- package/node_modules/@contrail/loader/lib/pipeline/transform.spec.js +3 -2
- package/node_modules/@contrail/loader/lib/pipeline/types.d.ts +5 -2
- package/node_modules/@contrail/loader/lib/pipeline/types.js +2 -0
- package/node_modules/@contrail/loader/lib/pipeline/validate.js +184 -437
- package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +157 -53
- package/node_modules/@contrail/loader/package.json +3 -2
- package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +120 -0
- package/node_modules/@contrail/sdk/lib/auth/login.js +42 -3
- package/node_modules/@contrail/sdk/lib/core/request.d.ts +3 -0
- package/node_modules/@contrail/sdk/lib/core/request.js +100 -4
- package/node_modules/@contrail/sdk/lib/entities/entities.client.js +1 -1
- package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +1 -0
- package/node_modules/@contrail/sdk/lib/files/files.d.ts +13 -3
- package/node_modules/@contrail/sdk/lib/files/files.js +66 -25
- package/node_modules/@contrail/sdk/package.json +4 -1
- package/node_modules/validate-color/LICENSE +21 -0
- package/node_modules/validate-color/README.md +265 -0
- package/node_modules/validate-color/lib/index.d.ts +10 -0
- package/node_modules/validate-color/lib/index.js +1 -0
- package/node_modules/validate-color/package.json +91 -0
- package/node_modules/validate-color/test/redos.js +29 -0
- package/oclif.manifest.json +1 -79
- package/package.json +3 -6
- package/dist/api/dash0/client.d.ts +0 -13
- package/dist/api/dash0/client.js +0 -53
- package/dist/api/dash0/spans.d.ts +0 -8
- package/dist/api/dash0/spans.js +0 -91
- package/dist/api/dash0/types.d.ts +0 -84
- package/dist/api/dash0/types.js +0 -4
- package/dist/commands/event-workflows/assess-impact.d.ts +0 -19
- package/dist/commands/event-workflows/assess-impact.js +0 -104
- package/dist/helpers/event-workflow-impact/aggregate.d.ts +0 -23
- package/dist/helpers/event-workflow-impact/aggregate.js +0 -49
- package/dist/helpers/event-workflow-impact/aggregate.spec.js +0 -109
- package/dist/helpers/event-workflow-impact/classify.d.ts +0 -13
- package/dist/helpers/event-workflow-impact/classify.js +0 -135
- package/dist/helpers/event-workflow-impact/classify.spec.js +0 -138
- package/dist/helpers/event-workflow-impact/render.d.ts +0 -12
- package/dist/helpers/event-workflow-impact/render.js +0 -62
- package/dist/helpers/event-workflow-impact/subtree.d.ts +0 -20
- package/dist/helpers/event-workflow-impact/subtree.js +0 -93
- package/dist/helpers/event-workflow-impact/subtree.spec.d.ts +0 -1
- package/dist/helpers/event-workflow-impact/subtree.spec.js +0 -103
- /package/{dist/helpers/event-workflow-impact/aggregate.spec.d.ts → node_modules/@contrail/loader/lib/common/color-validation.spec.d.ts} +0 -0
- /package/{dist/helpers/event-workflow-impact/classify.spec.d.ts → node_modules/@contrail/loader/lib/pipeline/identifier-resolver.spec.d.ts} +0 -0
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ITEM_PROCESSOR_WARNINGS = exports.FEDERATED_ID_FETCH_MAX_COUNT = exports.FEDERATED_ID_FETCH_MAX_URL_BYTES = exports.ITEM_PROCESSOR_ERRORS = exports.ENTITY_PROCESSOR_ERRORS = exports.CUSTOM_ENTITY_PROCESSOR_ERRORS = exports.
|
|
3
|
+
exports.ITEM_PROCESSOR_WARNINGS = exports.FEDERATED_ID_FETCH_MAX_COUNT = exports.FEDERATED_ID_FETCH_MAX_URL_BYTES = exports.ITEM_PROCESSOR_ERRORS = exports.ENTITY_PROCESSOR_ERRORS = exports.CUSTOM_ENTITY_PROCESSOR_ERRORS = exports.COLOR_PROCESSOR_ERRORS = void 0;
|
|
4
4
|
exports.COLOR_PROCESSOR_ERRORS = {
|
|
5
5
|
TYPEPATH_MISSING: '"typePath" with value "color" is required property but is not found in the federatedMapping config, conditionalColumns config, or as a header in the CSV file. Please add a mapping "typePath" mapping with value "color" with one of these methods, then try the load again.',
|
|
6
6
|
};
|
|
7
|
-
exports.COLOR_PROCESSOR_WARNINGS = {
|
|
8
|
-
HEX_IGNORED_WARNING: '"Hex" is ignored when red, green, and blue columns are present',
|
|
9
|
-
};
|
|
10
7
|
exports.CUSTOM_ENTITY_PROCESSOR_ERRORS = {
|
|
11
8
|
TYPEPATH_MISSING: '"typePath" with value "custom-entity:<subtypepath>" is required property but is not found in the federatedMapping config, conditionalColumns config, or as a header in the CSV file. Please add a mapping "typePath" mapping with value "custom-entity:<subtypepath>" with one of these methods, then try the load again.',
|
|
12
9
|
};
|
|
@@ -6,14 +6,7 @@ const util_1 = require("../../common/util");
|
|
|
6
6
|
const entity_processor_v2_1 = require("../entity-processor-v2");
|
|
7
7
|
const constants_1 = require("../../constants");
|
|
8
8
|
const base_processor_v2_1 = require("../base-processor-v2");
|
|
9
|
-
|
|
10
|
-
for (const row of data ?? []) {
|
|
11
|
-
if (row.hex?.startsWith('#')) {
|
|
12
|
-
row.hex = row.hex.slice(1);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
9
|
+
const color_validation_1 = require("../../common/color-validation");
|
|
17
10
|
class ColorProcessorV2 extends base_processor_v2_1.BaseProcessorV2 {
|
|
18
11
|
static requiredProperties = ['typePath', 'typeId', 'federatedId', 'name', 'hex', 'red', 'green', 'blue'];
|
|
19
12
|
static canAddProperty(allPropertiesSlugs, propertyName) {
|
|
@@ -23,7 +16,7 @@ class ColorProcessorV2 extends base_processor_v2_1.BaseProcessorV2 {
|
|
|
23
16
|
if (!data) {
|
|
24
17
|
return [];
|
|
25
18
|
}
|
|
26
|
-
return
|
|
19
|
+
return (0, color_validation_1.applyHexPriorityToRows)(data);
|
|
27
20
|
}
|
|
28
21
|
static validateLoadFile(data, config) {
|
|
29
22
|
const { errors, warnings, generalErrors, generalWarnings, csvHeaders, returnImmediately } = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
@@ -41,20 +34,13 @@ class ColorProcessorV2 extends base_processor_v2_1.BaseProcessorV2 {
|
|
|
41
34
|
if (duplicateFederatedIdErrors.length) {
|
|
42
35
|
errors.push(...duplicateFederatedIdErrors);
|
|
43
36
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const hasHexColumn = csvHeaders.includes(hexColumn);
|
|
52
|
-
if (hasHexColumn && hasRedColumn && hasGreenColumn && hasBlueColumn) {
|
|
53
|
-
generalWarnings.push({
|
|
54
|
-
message: constants_1.COLOR_PROCESSOR_WARNINGS.HEX_IGNORED_WARNING,
|
|
55
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
37
|
+
data.forEach((row, index) => {
|
|
38
|
+
const { rowErrors, rowWarnings } = (0, color_validation_1.buildColorRowIssues)(row, index + 2, config?.federatedMappings);
|
|
39
|
+
if (rowErrors)
|
|
40
|
+
errors.push(rowErrors);
|
|
41
|
+
if (rowWarnings)
|
|
42
|
+
warnings.push(rowWarnings);
|
|
43
|
+
});
|
|
58
44
|
return { errors, warnings, generalErrors, generalWarnings };
|
|
59
45
|
}
|
|
60
46
|
static validateTypePath(data, config, csvHeaders, generalErrors) {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const constants_1 = require("../../constants");
|
|
4
4
|
const color_processor_v2_1 = require("./color-processor-v2");
|
|
5
5
|
const entity_types_1 = require("@contrail/entity-types");
|
|
6
|
+
const color_validation_1 = require("../../common/color-validation");
|
|
6
7
|
describe('ColorProcessorV2', () => {
|
|
7
8
|
const loaderProcess = {
|
|
8
9
|
id: 'mock-loader-process-id',
|
|
@@ -219,72 +220,38 @@ describe('ColorProcessorV2', () => {
|
|
|
219
220
|
});
|
|
220
221
|
});
|
|
221
222
|
describe('color column validation', () => {
|
|
222
|
-
it('
|
|
223
|
+
it('warns per-row when both hex and RGB are populated (hex prioritized)', () => {
|
|
223
224
|
const data = [
|
|
224
|
-
{
|
|
225
|
-
name: 'test-color',
|
|
226
|
-
red: '255',
|
|
227
|
-
green: '0',
|
|
228
|
-
blue: '0',
|
|
229
|
-
hex: '#ff0000',
|
|
230
|
-
},
|
|
225
|
+
{ name: 'test-color', red: '255', green: '0', blue: '0', hex: '#ff0000' },
|
|
231
226
|
];
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
federatedMappings: {
|
|
235
|
-
...loaderProcess.federatedMappings,
|
|
236
|
-
red: 'red',
|
|
237
|
-
green: 'green',
|
|
238
|
-
blue: 'blue',
|
|
239
|
-
hex: 'hex',
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, config);
|
|
243
|
-
expect(result.generalWarnings).toContainEqual({
|
|
244
|
-
message: constants_1.COLOR_PROCESSOR_WARNINGS.HEX_IGNORED_WARNING,
|
|
245
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
it('should not warn when only RGB columns are present', () => {
|
|
249
|
-
const data = [
|
|
227
|
+
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, loaderProcess);
|
|
228
|
+
expect(result.warnings).toEqual([
|
|
250
229
|
{
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
...loaderProcess.federatedMappings,
|
|
261
|
-
red: 'red',
|
|
262
|
-
green: 'green',
|
|
263
|
-
blue: 'blue',
|
|
230
|
+
rowNumber: 2,
|
|
231
|
+
columnIssues: [
|
|
232
|
+
{
|
|
233
|
+
columnName: 'hex',
|
|
234
|
+
message: color_validation_1.COLOR_VALIDATION_MESSAGES.HEX_PRIORITIZED_OVER_RGB,
|
|
235
|
+
issueType: entity_types_1.IssueType.INVALID_DATA,
|
|
236
|
+
data: JSON.stringify(data[0]),
|
|
237
|
+
},
|
|
238
|
+
],
|
|
264
239
|
},
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
240
|
+
]);
|
|
241
|
+
});
|
|
242
|
+
it('does not warn when only RGB is populated and all components are valid', () => {
|
|
243
|
+
const data = [{ name: 'test-color', red: '255', green: '0', blue: '0' }];
|
|
244
|
+
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, loaderProcess);
|
|
245
|
+
expect(result.warnings).toEqual([]);
|
|
246
|
+
expect(result.errors).toEqual([]);
|
|
271
247
|
});
|
|
272
|
-
it('
|
|
248
|
+
it('does not warn when only a valid hex is populated', () => {
|
|
273
249
|
const data = [{ name: 'test-color', hex: '#ff0000' }];
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
...loaderProcess.federatedMappings,
|
|
278
|
-
hex: 'hex',
|
|
279
|
-
},
|
|
280
|
-
};
|
|
281
|
-
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, config);
|
|
282
|
-
expect(result.generalWarnings).not.toContainEqual({
|
|
283
|
-
message: constants_1.COLOR_PROCESSOR_WARNINGS.HEX_IGNORED_WARNING,
|
|
284
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
285
|
-
});
|
|
250
|
+
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, loaderProcess);
|
|
251
|
+
expect(result.warnings).toEqual([]);
|
|
252
|
+
expect(result.errors).toEqual([]);
|
|
286
253
|
});
|
|
287
|
-
it('
|
|
254
|
+
it('warns per-row when both hex and RGB are populated under federatedMappings', () => {
|
|
288
255
|
const data = [{ name: 'test-color', r: '255', g: '0', b: '0', hexcode: '#ff0000' }];
|
|
289
256
|
const config = {
|
|
290
257
|
...loaderProcess,
|
|
@@ -297,11 +264,94 @@ describe('ColorProcessorV2', () => {
|
|
|
297
264
|
},
|
|
298
265
|
};
|
|
299
266
|
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, config);
|
|
300
|
-
expect(result.
|
|
301
|
-
|
|
302
|
-
|
|
267
|
+
expect(result.warnings).toEqual([
|
|
268
|
+
{
|
|
269
|
+
rowNumber: 2,
|
|
270
|
+
columnIssues: [
|
|
271
|
+
{
|
|
272
|
+
columnName: 'hex',
|
|
273
|
+
message: color_validation_1.COLOR_VALIDATION_MESSAGES.HEX_PRIORITIZED_OVER_RGB,
|
|
274
|
+
issueType: entity_types_1.IssueType.INVALID_DATA,
|
|
275
|
+
data: JSON.stringify(data[0]),
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
]);
|
|
280
|
+
});
|
|
281
|
+
it('errors when hex is invalid', () => {
|
|
282
|
+
const data = [{ name: 'bad', hex: 'notahex' }];
|
|
283
|
+
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, loaderProcess);
|
|
284
|
+
expect(result.errors).toHaveLength(1);
|
|
285
|
+
expect(result.errors[0]).toMatchObject({
|
|
286
|
+
rowNumber: 2,
|
|
287
|
+
columnIssues: [
|
|
288
|
+
{
|
|
289
|
+
columnName: 'hex',
|
|
290
|
+
message: color_validation_1.COLOR_VALIDATION_MESSAGES.HEX_INVALID('notahex'),
|
|
291
|
+
issueType: entity_types_1.IssueType.INVALID_DATA,
|
|
292
|
+
},
|
|
293
|
+
],
|
|
303
294
|
});
|
|
304
295
|
});
|
|
296
|
+
it('errors when RGB is partially populated and hex is missing', () => {
|
|
297
|
+
const data = [{ name: 'partial', red: '255', green: '128' }];
|
|
298
|
+
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, loaderProcess);
|
|
299
|
+
expect(result.errors).toHaveLength(1);
|
|
300
|
+
expect(result.errors[0].rowNumber).toBe(2);
|
|
301
|
+
expect(result.errors[0].columnIssues).toEqual([
|
|
302
|
+
{
|
|
303
|
+
columnName: 'blue',
|
|
304
|
+
message: color_validation_1.COLOR_VALIDATION_MESSAGES.RGB_INCOMPLETE(['blue']),
|
|
305
|
+
issueType: entity_types_1.IssueType.INVALID_DATA,
|
|
306
|
+
data: JSON.stringify(data[0]),
|
|
307
|
+
},
|
|
308
|
+
]);
|
|
309
|
+
});
|
|
310
|
+
it('errors when an RGB component is out of range or non-numeric', () => {
|
|
311
|
+
const data = [
|
|
312
|
+
{ name: 'bad-red', red: '300', green: '0', blue: '0' },
|
|
313
|
+
{ name: 'nan-green', red: '10', green: 'foo', blue: '0' },
|
|
314
|
+
];
|
|
315
|
+
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, loaderProcess);
|
|
316
|
+
expect(result.errors).toHaveLength(2);
|
|
317
|
+
expect(result.errors[0]).toMatchObject({
|
|
318
|
+
rowNumber: 2,
|
|
319
|
+
columnIssues: [
|
|
320
|
+
{ columnName: 'red', message: color_validation_1.COLOR_VALIDATION_MESSAGES.RGB_OUT_OF_RANGE('red', '300') },
|
|
321
|
+
],
|
|
322
|
+
});
|
|
323
|
+
expect(result.errors[1]).toMatchObject({
|
|
324
|
+
rowNumber: 3,
|
|
325
|
+
columnIssues: [
|
|
326
|
+
{ columnName: 'green', message: color_validation_1.COLOR_VALIDATION_MESSAGES.RGB_OUT_OF_RANGE('green', 'foo') },
|
|
327
|
+
],
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
it('does not error when neither hex nor RGB are populated (defaults to black)', () => {
|
|
331
|
+
const data = [{ name: 'no-color' }];
|
|
332
|
+
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, loaderProcess);
|
|
333
|
+
expect(result.errors).toEqual([]);
|
|
334
|
+
expect(result.warnings).toEqual([]);
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
describe('transformData (hex priority)', () => {
|
|
338
|
+
it('strips red/green/blue when hex is valid', () => {
|
|
339
|
+
const data = [
|
|
340
|
+
{ hex: '#ff0000', red: '255', green: '0', blue: '0', name: 'red' },
|
|
341
|
+
];
|
|
342
|
+
const result = color_processor_v2_1.ColorProcessorV2.transformData(data);
|
|
343
|
+
expect(result).toEqual([{ hex: 'ff0000', name: 'red' }]);
|
|
344
|
+
});
|
|
345
|
+
it('keeps red/green/blue and removes empty hex when hex is missing', () => {
|
|
346
|
+
const data = [{ red: '255', green: '0', blue: '0', name: 'red' }];
|
|
347
|
+
const result = color_processor_v2_1.ColorProcessorV2.transformData(data);
|
|
348
|
+
expect(result).toEqual([{ red: '255', green: '0', blue: '0', name: 'red' }]);
|
|
349
|
+
});
|
|
350
|
+
it('defaults to #000000 (without hash) when neither hex nor full RGB is provided', () => {
|
|
351
|
+
const data = [{ name: 'fallback' }];
|
|
352
|
+
const result = color_processor_v2_1.ColorProcessorV2.transformData(data);
|
|
353
|
+
expect(result).toEqual([{ name: 'fallback', hex: color_validation_1.DEFAULT_HEX }]);
|
|
354
|
+
});
|
|
305
355
|
});
|
|
306
356
|
it('should return error if conditionalColumns format is incorrect', () => {
|
|
307
357
|
const data = [{ name: 'color1' }];
|
|
@@ -67,7 +67,6 @@ async function retryOnTimeout(client, callType, callParams, maxRetries = 3) {
|
|
|
67
67
|
}
|
|
68
68
|
exports.retryOnTimeout = retryOnTimeout;
|
|
69
69
|
function UpdateNeeded(incoming, existing, fieldsToSkip = [], fieldsToSkipIfOnlyOnExisting = [], type) {
|
|
70
|
-
console.debug('Comparing existing and incoming objects...');
|
|
71
70
|
const diffs = compareIncomingAndExisting(incoming, existing, fieldsToSkip, fieldsToSkipIfOnlyOnExisting, type);
|
|
72
71
|
return diffs?.length > 0;
|
|
73
72
|
}
|
|
@@ -253,7 +253,6 @@ class AssortmentProcessor extends base_processor_v2_1.BaseProcessorV2 {
|
|
|
253
253
|
}
|
|
254
254
|
static async loadObjects(client, data, passedItemsByFederatedId, assortmentId, assortmentIdentifier, typesByTypePath) {
|
|
255
255
|
const { allPropertiesSlugs, typePropertyToValueType } = await (0, item_helper_1.getAssortmentItemProperties)(client, this.requiredProperties, typesByTypePath);
|
|
256
|
-
console.debug('using assortment types:', JSON.stringify({ allPropertiesSlugs, typePropertyToValueType }, null, 2));
|
|
257
256
|
const { incomingAssortmentItems, badAssortmentItems } = this.processIncomingData(data, allPropertiesSlugs, typePropertyToValueType);
|
|
258
257
|
const targetAssortment = await (0, item_helper_1.getAssortment)(client, assortmentId, assortmentIdentifier, data);
|
|
259
258
|
if (!targetAssortment) {
|
|
@@ -60,7 +60,7 @@ class ItemProcessor extends base_processor_v2_1.BaseProcessorV2 {
|
|
|
60
60
|
return { errors, warnings, generalErrors, generalWarnings };
|
|
61
61
|
}
|
|
62
62
|
this.validateLoadType(config, generalErrors);
|
|
63
|
-
this.validateTypePathMapping(
|
|
63
|
+
this.validateTypePathMapping(data, generalErrors);
|
|
64
64
|
this.validateOptionNameMapping(config, csvHeaders, generalWarnings);
|
|
65
65
|
this.validateItemOptionFederatedIdMapping(config, csvHeaders, generalWarnings);
|
|
66
66
|
this.validateFederatedIds(data, config, errors, generalErrors, csvHeaders);
|
|
@@ -75,27 +75,13 @@ class ItemProcessor extends base_processor_v2_1.BaseProcessorV2 {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
static validateTypePathMapping(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
generalErrors.push({
|
|
86
|
-
message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
|
|
87
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else if (csvHeaders.includes('typePath')) {
|
|
92
|
-
const hasCorrectTypePath = data.every((row) => row.typePath === 'item' || (row.typePath?.startsWith('item:') && row.typePath?.split(':')[1]?.length > 0));
|
|
93
|
-
if (!hasCorrectTypePath) {
|
|
94
|
-
generalErrors.push({
|
|
95
|
-
message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
|
|
96
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
78
|
+
static validateTypePathMapping(data, generalErrors) {
|
|
79
|
+
const hasCorrectTypePath = data.every((row) => row.typePath === 'item' || (row.typePath?.startsWith('item:') && row.typePath?.split(':')[1]?.length > 0));
|
|
80
|
+
if (!hasCorrectTypePath) {
|
|
81
|
+
generalErrors.push({
|
|
82
|
+
message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
|
|
83
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
84
|
+
});
|
|
99
85
|
}
|
|
100
86
|
}
|
|
101
87
|
static validateOptionNameMapping(config, csvHeaders, generalWarnings) {
|
|
@@ -28,18 +28,21 @@ describe('Item Processor', () => {
|
|
|
28
28
|
family_federated_id: 'family_1',
|
|
29
29
|
input_col_1: 'value_1',
|
|
30
30
|
input_col_2: 'value_2',
|
|
31
|
+
typePath: 'item',
|
|
31
32
|
},
|
|
32
33
|
{
|
|
33
34
|
name: 'item2',
|
|
34
35
|
family_federated_id: 'family_2',
|
|
35
36
|
input_col_1: 'value_3',
|
|
36
37
|
input_col_2: 'value_4',
|
|
38
|
+
typePath: 'item',
|
|
37
39
|
},
|
|
38
40
|
{
|
|
39
41
|
name: 'item3',
|
|
40
42
|
family_federated_id: 'family_3',
|
|
41
43
|
input_col_1: 'value_5',
|
|
42
44
|
input_col_2: 'value_6',
|
|
45
|
+
typePath: 'item',
|
|
43
46
|
},
|
|
44
47
|
];
|
|
45
48
|
const config = {
|
|
@@ -167,7 +170,7 @@ describe('Item Processor', () => {
|
|
|
167
170
|
},
|
|
168
171
|
]);
|
|
169
172
|
});
|
|
170
|
-
it('should
|
|
173
|
+
it('should throw error if typepath is not present in csv header', () => {
|
|
171
174
|
const data = [
|
|
172
175
|
{
|
|
173
176
|
name: 'item1',
|
|
@@ -193,6 +196,42 @@ describe('Item Processor', () => {
|
|
|
193
196
|
conditionalColumns: [],
|
|
194
197
|
};
|
|
195
198
|
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
199
|
+
expect(result.generalErrors).toEqual([
|
|
200
|
+
{
|
|
201
|
+
message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
|
|
202
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
203
|
+
},
|
|
204
|
+
]);
|
|
205
|
+
});
|
|
206
|
+
it('should not throw error if every row has a valid typePath', () => {
|
|
207
|
+
const data = [
|
|
208
|
+
{
|
|
209
|
+
name: 'item1',
|
|
210
|
+
family_federated_id: 'family_1',
|
|
211
|
+
input_col_1: 'value_1',
|
|
212
|
+
input_col_2: 'value_2',
|
|
213
|
+
typePath: 'item',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: 'item2',
|
|
217
|
+
family_federated_id: 'family_2',
|
|
218
|
+
input_col_1: 'value_3',
|
|
219
|
+
input_col_2: 'value_4',
|
|
220
|
+
typePath: 'item:material:fabric:yarn',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'item3',
|
|
224
|
+
family_federated_id: 'family_3',
|
|
225
|
+
input_col_1: 'value_5',
|
|
226
|
+
input_col_2: 'value_6',
|
|
227
|
+
typePath: 'item:material:fabric:leather',
|
|
228
|
+
},
|
|
229
|
+
];
|
|
230
|
+
const config = {
|
|
231
|
+
...loaderProcess,
|
|
232
|
+
conditionalColumns: [],
|
|
233
|
+
};
|
|
234
|
+
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
196
235
|
expect(result.generalErrors).toEqual([]);
|
|
197
236
|
});
|
|
198
237
|
});
|
|
@@ -600,14 +639,17 @@ describe('Item Processor', () => {
|
|
|
600
639
|
{
|
|
601
640
|
itemFamilyFederatedId: '1',
|
|
602
641
|
name: 'foo',
|
|
642
|
+
typePath: 'item',
|
|
603
643
|
},
|
|
604
644
|
{
|
|
605
645
|
itemFamilyFederatedId: '1',
|
|
606
646
|
name: 'bar',
|
|
647
|
+
typePath: 'item',
|
|
607
648
|
},
|
|
608
649
|
{
|
|
609
650
|
itemFamilyFederatedId: '3',
|
|
610
651
|
name: 'test',
|
|
652
|
+
typePath: 'item',
|
|
611
653
|
},
|
|
612
654
|
];
|
|
613
655
|
const config = {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EntitiesClient, LoaderConfig, PreValidationIssue } from './types';
|
|
2
|
+
export declare function isProjectItemAndAssortmentLoad(config: LoaderConfig): boolean;
|
|
3
|
+
export declare function resolveIdentifiers(rows: Record<string, any>[], config: LoaderConfig, client?: EntitiesClient): Promise<{
|
|
4
|
+
issues: PreValidationIssue[];
|
|
5
|
+
}>;
|