@contrail/cli 3.6.0-alpha-8-alpha.85a73d5 → 3.6.0-alpha.a5acc88

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 (84) hide show
  1. package/README.md +26 -181
  2. package/dist/api/types.d.ts +0 -35
  3. package/dist/api/types.js +1 -49
  4. package/dist/auth/login.d.ts +4 -0
  5. package/dist/auth/login.js +115 -52
  6. package/dist/auth/login.spec.js +100 -0
  7. package/dist/auth/sso.d.ts +36 -0
  8. package/dist/auth/sso.js +174 -0
  9. package/dist/auth/sso.spec.js +148 -0
  10. package/dist/basecommand.js +2 -2
  11. package/dist/commands/app/getApiKey.js +2 -2
  12. package/dist/commands/login.d.ts +12 -0
  13. package/dist/commands/login.js +25 -0
  14. package/dist/common.d.ts +1 -4
  15. package/dist/common.js +1 -18
  16. package/dist/helpers/config/config.d.ts +3 -3
  17. package/dist/helpers/config/config.js +3 -3
  18. package/dist/helpers/file-helpers.d.ts +0 -1
  19. package/dist/helpers/file-helpers.js +3 -20
  20. package/dist/logger.js +1 -4
  21. package/node_modules/@contrail/entity-compare/package.json +3 -6
  22. package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
  23. package/node_modules/@contrail/loader/lib/constants.d.ts +8 -0
  24. package/node_modules/@contrail/loader/lib/constants.js +9 -1
  25. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +4 -0
  26. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +57 -0
  27. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +492 -34
  28. package/node_modules/@contrail/loader/lib/pipeline/validate.js +2 -52
  29. package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +0 -85
  30. package/node_modules/@contrail/loader/package.json +2 -2
  31. package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +4 -1
  32. package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
  33. package/node_modules/@contrail/sdk/lib/config/config.d.ts +0 -3
  34. package/node_modules/@contrail/sdk/lib/config/config.js +7 -13
  35. package/node_modules/@contrail/sdk/lib/core/request.js +2 -6
  36. package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +0 -2
  37. package/node_modules/@contrail/sdk/lib/entities/entities.client.js +1 -3
  38. package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +0 -1
  39. package/node_modules/@contrail/sdk/lib/index.d.ts +0 -1
  40. package/node_modules/@contrail/sdk/lib/index.js +0 -1
  41. package/node_modules/@contrail/sdk/package.json +1 -1
  42. package/oclif.manifest.json +50 -449
  43. package/package.json +12 -5
  44. package/dist/commands/entities/create.d.ts +0 -50
  45. package/dist/commands/entities/create.js +0 -633
  46. package/dist/commands/entities/create.spec.js +0 -583
  47. package/dist/commands/entities/delete.d.ts +0 -20
  48. package/dist/commands/entities/delete.js +0 -140
  49. package/dist/commands/entities/get.d.ts +0 -25
  50. package/dist/commands/entities/get.js +0 -269
  51. package/dist/commands/entities/grammar.spec.d.ts +0 -1
  52. package/dist/commands/entities/grammar.spec.js +0 -79
  53. package/dist/commands/entities/output.spec.d.ts +0 -1
  54. package/dist/commands/entities/output.spec.js +0 -72
  55. package/dist/commands/entities/update.d.ts +0 -32
  56. package/dist/commands/entities/update.js +0 -161
  57. package/dist/helpers/entities/assortment-items.d.ts +0 -11
  58. package/dist/helpers/entities/assortment-items.js +0 -76
  59. package/dist/helpers/entities/batchFetch.d.ts +0 -8
  60. package/dist/helpers/entities/batchFetch.js +0 -49
  61. package/dist/helpers/entities/index.d.ts +0 -3
  62. package/dist/helpers/entities/index.js +0 -6
  63. package/dist/helpers/entities/items.d.ts +0 -6
  64. package/dist/helpers/entities/items.js +0 -56
  65. package/dist/helpers/entities/items.spec.d.ts +0 -1
  66. package/dist/helpers/entities/items.spec.js +0 -19
  67. package/dist/helpers/entities/project-items.d.ts +0 -2
  68. package/dist/helpers/entities/project-items.js +0 -44
  69. package/dist/helpers/propertySpecifications/dateRanges.d.ts +0 -34
  70. package/dist/helpers/propertySpecifications/dateRanges.js +0 -83
  71. package/dist/helpers/propertySpecifications/dateRanges.spec.d.ts +0 -1
  72. package/dist/helpers/propertySpecifications/dateRanges.spec.js +0 -91
  73. package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +0 -39
  74. package/dist/helpers/propertySpecifications/propertySpecifications.js +0 -102
  75. package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +0 -1
  76. package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +0 -387
  77. package/dist/logger.spec.d.ts +0 -1
  78. package/dist/logger.spec.js +0 -12
  79. package/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +0 -34
  80. package/node_modules/@contrail/sdk/lib/image-search/image-search.js +0 -42
  81. package/node_modules/@contrail/sdk/lib/image-search/index.d.ts +0 -1
  82. package/node_modules/@contrail/sdk/lib/image-search/index.js +0 -17
  83. package/node_modules/@contrail/sdk/scripts/replicate-bug.js +0 -69
  84. /package/dist/{commands/entities/create.spec.d.ts → auth/sso.spec.d.ts} +0 -0
@@ -21,56 +21,514 @@ describe('Item Processor', () => {
21
21
  ],
22
22
  };
23
23
  describe('validateLoadFile', () => {
24
- it('should throw error for the duplicate itemOptionFederatedId', () => {
25
- const lineSheetData = [
24
+ it('should return general error if loadType is not correct', () => {
25
+ const data = [
26
26
  {
27
- itemName: 'foo',
28
- itemFamilyFederatedId: '1',
29
- itemOptionFederatedId: '11',
27
+ name: 'item1',
28
+ family_federated_id: 'family_1',
29
+ input_col_1: 'value_1',
30
+ input_col_2: 'value_2',
31
+ typePath: 'item',
30
32
  },
31
33
  {
32
- itemName: 'foo',
33
- itemFamilyFederatedId: '1',
34
- itemOptionFederatedId: '11',
34
+ name: 'item2',
35
+ family_federated_id: 'family_2',
36
+ input_col_1: 'value_3',
37
+ input_col_2: 'value_4',
38
+ typePath: 'item',
35
39
  },
36
40
  {
37
- itemName: 'bar',
38
- itemFamilyFederatedId: '2',
39
- itemOptionFederatedId: '12',
41
+ name: 'item3',
42
+ family_federated_id: 'family_3',
43
+ input_col_1: 'value_5',
44
+ input_col_2: 'value_6',
45
+ typePath: 'item',
40
46
  },
41
47
  ];
42
48
  const config = {
43
- loadType: ['ITEM'],
44
- federatedMappings: {
45
- name: 'itemName',
46
- itemFamilyFederatedId: 'itemFamilyFederatedId',
47
- },
49
+ ...loaderProcess,
50
+ loadType: ['INVALID'],
48
51
  };
49
- const result = item_processor_1.ItemProcessor.validateLoadFile(lineSheetData, config);
50
- expect(result.errors).toEqual([
52
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
53
+ expect(result.generalErrors).toEqual([
51
54
  {
52
- rowNumber: 2,
53
- columnIssues: [
55
+ message: constants_1.ITEM_PROCESSOR_ERRORS.LOAD_TYPE_INVALID,
56
+ issueType: entity_types_1.IssueType.CONFIG,
57
+ },
58
+ ]);
59
+ });
60
+ describe('validate typepath', () => {
61
+ it('should throw general error if typePath is incorrect', () => {
62
+ const data = [
63
+ {
64
+ name: 'item1',
65
+ family_federated_id: 'family_1',
66
+ input_col_1: 'value_1',
67
+ input_col_2: 'value_2',
68
+ },
69
+ {
70
+ name: 'item2',
71
+ family_federated_id: 'family_2',
72
+ input_col_1: 'value_3',
73
+ input_col_2: 'value_4',
74
+ },
75
+ {
76
+ name: 'item3',
77
+ family_federated_id: 'family_3',
78
+ input_col_1: 'value_5',
79
+ input_col_2: 'value_6',
80
+ },
81
+ ];
82
+ const config = {
83
+ ...loaderProcess,
84
+ conditionalColumns: [
54
85
  {
55
- columnName: 'itemOptionFederatedId',
56
- message: 'Duplicate federatedId found: 11',
57
- issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
58
- data: '{"itemName":"foo","itemFamilyFederatedId":"1","itemOptionFederatedId":"11"}',
86
+ toProperty: 'typePath',
87
+ default: 'custom-entity:',
59
88
  },
60
89
  ],
61
- },
62
- {
63
- rowNumber: 3,
64
- columnIssues: [
90
+ };
91
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
92
+ expect(result.generalErrors).toEqual([
93
+ {
94
+ message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
95
+ issueType: entity_types_1.IssueType.CONFIG,
96
+ },
97
+ ]);
98
+ });
99
+ it('should throw error if typepath is present in the config file but have incorrect typePath', () => {
100
+ const data = [
101
+ {
102
+ name: 'item1',
103
+ family_federated_id: 'family_1',
104
+ input_col_1: 'value_1',
105
+ input_col_2: 'value_2',
106
+ },
107
+ {
108
+ name: 'item2',
109
+ family_federated_id: 'family_2',
110
+ input_col_1: 'value_3',
111
+ input_col_2: 'value_4',
112
+ },
113
+ {
114
+ name: 'item3',
115
+ family_federated_id: 'family_3',
116
+ input_col_1: 'value_5',
117
+ input_col_2: 'value_6',
118
+ },
119
+ ];
120
+ const config = {
121
+ ...loaderProcess,
122
+ conditionalColumns: [
65
123
  {
66
- columnName: 'itemOptionFederatedId',
67
- message: 'Duplicate federatedId found: 11',
68
- issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
69
- data: '{"itemName":"foo","itemFamilyFederatedId":"1","itemOptionFederatedId":"11"}',
124
+ toProperty: 'typePath',
125
+ default: 'custom-entity1',
70
126
  },
71
127
  ],
72
- },
73
- ]);
128
+ };
129
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
130
+ expect(result.generalErrors).toEqual([
131
+ {
132
+ message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
133
+ issueType: entity_types_1.IssueType.CONFIG,
134
+ },
135
+ ]);
136
+ });
137
+ it('should throw error if typepath is present in the csv header but have incorrect typePath', () => {
138
+ const data = [
139
+ {
140
+ name: 'item1',
141
+ family_federated_id: 'family_1',
142
+ input_col_1: 'value_1',
143
+ input_col_2: 'value_2',
144
+ typePath: 'custom-entity1',
145
+ },
146
+ {
147
+ name: 'item2',
148
+ family_federated_id: 'family_2',
149
+ input_col_1: 'value_3',
150
+ input_col_2: 'value_4',
151
+ typePath: 'custom-entity1',
152
+ },
153
+ {
154
+ name: 'item3',
155
+ family_federated_id: 'family_3',
156
+ input_col_1: 'value_5',
157
+ input_col_2: 'value_6',
158
+ typePath: 'custom-entity1',
159
+ },
160
+ ];
161
+ const config = {
162
+ ...loaderProcess,
163
+ conditionalColumns: [],
164
+ };
165
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
166
+ expect(result.generalErrors).toEqual([
167
+ {
168
+ message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
169
+ issueType: entity_types_1.IssueType.CONFIG,
170
+ },
171
+ ]);
172
+ });
173
+ it('should throw error if typepath is not present in csv header', () => {
174
+ const data = [
175
+ {
176
+ name: 'item1',
177
+ family_federated_id: 'family_1',
178
+ input_col_1: 'value_1',
179
+ input_col_2: 'value_2',
180
+ },
181
+ {
182
+ name: 'item2',
183
+ family_federated_id: 'family_2',
184
+ input_col_1: 'value_3',
185
+ input_col_2: 'value_4',
186
+ },
187
+ {
188
+ name: 'item3',
189
+ family_federated_id: 'family_3',
190
+ input_col_1: 'value_5',
191
+ input_col_2: 'value_6',
192
+ },
193
+ ];
194
+ const config = {
195
+ ...loaderProcess,
196
+ conditionalColumns: [],
197
+ };
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);
235
+ expect(result.generalErrors).toEqual([]);
236
+ });
237
+ });
238
+ describe('validate itemOptionFederatedId', () => {
239
+ it('should validate optionFederatedId in conditional columns', () => {
240
+ const data = [{ name: 'test1', optionName: 'Test Option 1' }];
241
+ const config = {
242
+ ...loaderProcess,
243
+ conditionalColumns: [
244
+ {
245
+ toProperty: 'itemFamilyFederatedId',
246
+ default: 'test-{name}',
247
+ },
248
+ {
249
+ toProperty: 'itemOptionFederatedId',
250
+ default: 'test-{optionName}',
251
+ },
252
+ ],
253
+ };
254
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
255
+ expect(result.generalWarnings).not.toContainEqual({
256
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_UNMAPPED,
257
+ issueType: entity_types_1.IssueType.CONFIG,
258
+ });
259
+ });
260
+ it('should validate federatedId in CSV data', () => {
261
+ const data = [
262
+ {
263
+ itemFamilyFederatedId: 'test1',
264
+ itemOptionFederatedId: 'option1',
265
+ name: 'Test 1',
266
+ },
267
+ ];
268
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, loaderProcess);
269
+ expect(result.generalErrors).not.toContainEqual({
270
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_UNMAPPED,
271
+ issueType: entity_types_1.IssueType.CONFIG,
272
+ });
273
+ });
274
+ it('should validate federatedId in federatedMapping', () => {
275
+ const data = [{ code: 'test1', option: 'option1', name: 'Test 1' }];
276
+ const config = {
277
+ ...loaderProcess,
278
+ federatedMappings: {
279
+ itemFamilyFederatedId: 'code',
280
+ itemOptionFederatedId: 'option',
281
+ },
282
+ };
283
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
284
+ expect(result.generalErrors).not.toContainEqual({
285
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_UNMAPPED,
286
+ issueType: entity_types_1.IssueType.CONFIG,
287
+ });
288
+ });
289
+ it('should warning error if itemOptionfederatedId is missing in federatedmapping config, csv header and conditional column', () => {
290
+ const data = [{ name: 'color1', option: 'option1' }];
291
+ const config = {
292
+ id: 'mock-loader-process-id',
293
+ loadFileId: 'mock-load-file-id',
294
+ loadType: [entity_types_1.LoadType.COLOR],
295
+ status: entity_types_1.LoadStatus.COMPLETE,
296
+ conditionalColumns: [
297
+ {
298
+ toProperty: 'typePath',
299
+ default: 'color',
300
+ },
301
+ ],
302
+ federatedMappings: {
303
+ name: 'name',
304
+ optionName: 'option',
305
+ },
306
+ };
307
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
308
+ expect(result.generalWarnings).toEqual([
309
+ {
310
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_UNMAPPED,
311
+ issueType: entity_types_1.IssueType.CONFIG,
312
+ },
313
+ ]);
314
+ });
315
+ it('should return error if itemOptionFederatedId is mapped incorrectly in federatedMappings', () => {
316
+ const lineSheetData = [{ header1: 'value1', test1: 'test1' }];
317
+ const config = {
318
+ loadType: ['ITEM'],
319
+ federatedMappings: {
320
+ name: 'header1',
321
+ itemFamilyFederatedId: 'someId',
322
+ optionName: 'test1',
323
+ itemOptionFederatedId: 'test2',
324
+ },
325
+ };
326
+ const result = item_processor_1.ItemProcessor.validateLoadFile(lineSheetData, config);
327
+ expect(result.generalWarnings).toEqual([
328
+ {
329
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_NOT_FOUND('test2'),
330
+ issueType: entity_types_1.IssueType.CONFIG,
331
+ },
332
+ ]);
333
+ });
334
+ });
335
+ describe('validate itemOptionName', () => {
336
+ it('should validate optionName in conditional columns', () => {
337
+ const data = [{ federatedId: 'test1' }];
338
+ const config = {
339
+ ...loaderProcess,
340
+ federatedMappings: {},
341
+ conditionalColumns: [
342
+ {
343
+ toProperty: 'name',
344
+ default: 'Test {federatedId}',
345
+ },
346
+ {
347
+ toProperty: 'optionName',
348
+ default: 'Test1 {federatedId}',
349
+ },
350
+ ],
351
+ };
352
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
353
+ console.log(JSON.stringify(result, null, 2));
354
+ expect(result.generalWarnings).not.toContainEqual({
355
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
356
+ issueType: entity_types_1.IssueType.CONFIG,
357
+ });
358
+ });
359
+ it('should validate name in CSV data', () => {
360
+ const data = [{ federatedId: 'test1', name: 'Test 1', optionName: 'Option 1' }];
361
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, loaderProcess);
362
+ expect(result.generalWarnings).not.toContainEqual({
363
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
364
+ issueType: entity_types_1.IssueType.CONFIG,
365
+ });
366
+ });
367
+ it('should return warning if optionName is missing in federatedMappings, config and conditional column', () => {
368
+ const data = [{ id: 'custom-entity1', optionId: 'option1' }];
369
+ const config = {
370
+ ...loaderProcess,
371
+ loadType: [entity_types_1.LoadType.CUSTOM_ENTITY],
372
+ federatedMappings: {
373
+ federatedId: 'id',
374
+ itemOptionFederatedId: 'optionId',
375
+ },
376
+ };
377
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
378
+ expect(result.generalWarnings).toEqual([
379
+ {
380
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
381
+ issueType: entity_types_1.IssueType.CONFIG,
382
+ },
383
+ ]);
384
+ });
385
+ it('should validate name in federatedMapping', () => {
386
+ const data = [
387
+ {
388
+ federatedId: 'test1',
389
+ display_name: 'Test 1',
390
+ display_option: 'Option 1',
391
+ },
392
+ ];
393
+ const config = {
394
+ ...loaderProcess,
395
+ federatedMappings: {
396
+ name: 'display_name',
397
+ optionName: 'display_option',
398
+ },
399
+ };
400
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
401
+ expect(result.generalWarnings).not.toContainEqual({
402
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
403
+ issueType: entity_types_1.IssueType.CONFIG,
404
+ });
405
+ });
406
+ it('should return a warning if optionName is not mapped in federatedMappings', () => {
407
+ const data = [
408
+ {
409
+ name: 'item1',
410
+ family_federated_id: 'family_1',
411
+ input_col_1: 'value_1',
412
+ input_col_2: 'value_2',
413
+ },
414
+ {
415
+ name: 'item2',
416
+ family_federated_id: 'family_2',
417
+ input_col_1: 'value_3',
418
+ input_col_2: 'value_4',
419
+ },
420
+ {
421
+ name: 'item3',
422
+ family_federated_id: 'family_3',
423
+ input_col_1: 'value_5',
424
+ input_col_2: 'value_6',
425
+ },
426
+ ];
427
+ const config = {
428
+ ...loaderProcess,
429
+ conditionalColumns: [],
430
+ federatedMappings: {
431
+ itemFamilyFederatedId: 'family_federated_id',
432
+ itemOptionFederatedId: 'input_col_1',
433
+ },
434
+ };
435
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
436
+ expect(result.generalWarnings).toEqual([
437
+ {
438
+ message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
439
+ issueType: entity_types_1.IssueType.CONFIG,
440
+ },
441
+ ]);
442
+ });
443
+ it('should return a warning if optionName is mapped incorrectly in federatedMappings', () => {
444
+ const data = [
445
+ {
446
+ name: 'item1',
447
+ family_federated_id: 'family_1',
448
+ input_col_1: 'value_1',
449
+ input_col_2: 'value_2',
450
+ },
451
+ {
452
+ name: 'item2',
453
+ family_federated_id: 'family_2',
454
+ input_col_1: 'value_3',
455
+ input_col_2: 'value_4',
456
+ },
457
+ {
458
+ name: 'item3',
459
+ family_federated_id: 'family_3',
460
+ input_col_1: 'value_5',
461
+ input_col_2: 'value_6',
462
+ },
463
+ ];
464
+ const config = {
465
+ ...loaderProcess,
466
+ conditionalColumns: [],
467
+ federatedMappings: {
468
+ itemFamilyFederatedId: 'family_federated_id',
469
+ itemOptionFederatedId: 'input_col_1',
470
+ optionName: 'input_col_3',
471
+ },
472
+ };
473
+ const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
474
+ expect(result.generalWarnings).toEqual([
475
+ {
476
+ message: '"input_col_3" column not found in the CSV file',
477
+ issueType: entity_types_1.IssueType.CONFIG,
478
+ },
479
+ ]);
480
+ });
481
+ it('should throw error for the duplicate itemOptionFederatedId', () => {
482
+ const lineSheetData = [
483
+ {
484
+ itemName: 'foo',
485
+ itemFamilyFederatedId: '1',
486
+ itemOptionFederatedId: '11',
487
+ },
488
+ {
489
+ itemName: 'foo',
490
+ itemFamilyFederatedId: '1',
491
+ itemOptionFederatedId: '11',
492
+ },
493
+ {
494
+ itemName: 'bar',
495
+ itemFamilyFederatedId: '2',
496
+ itemOptionFederatedId: '12',
497
+ },
498
+ ];
499
+ const config = {
500
+ loadType: ['ITEM'],
501
+ federatedMappings: {
502
+ name: 'itemName',
503
+ itemFamilyFederatedId: 'itemFamilyFederatedId',
504
+ },
505
+ };
506
+ const result = item_processor_1.ItemProcessor.validateLoadFile(lineSheetData, config);
507
+ expect(result.errors).toEqual([
508
+ {
509
+ rowNumber: 2,
510
+ columnIssues: [
511
+ {
512
+ columnName: 'itemOptionFederatedId',
513
+ message: 'Duplicate federatedId found: 11',
514
+ issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
515
+ data: '{"itemName":"foo","itemFamilyFederatedId":"1","itemOptionFederatedId":"11"}',
516
+ },
517
+ ],
518
+ },
519
+ {
520
+ rowNumber: 3,
521
+ columnIssues: [
522
+ {
523
+ columnName: 'itemOptionFederatedId',
524
+ message: 'Duplicate federatedId found: 11',
525
+ issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
526
+ data: '{"itemName":"foo","itemFamilyFederatedId":"1","itemOptionFederatedId":"11"}',
527
+ },
528
+ ],
529
+ },
530
+ ]);
531
+ });
74
532
  });
75
533
  describe('validate duplicate optionName within family', () => {
76
534
  it('should return errors when options in the same family have duplicate optionNames', () => {
@@ -49,8 +49,6 @@ async function validate(rows, config, columnAnalysis, client) {
49
49
  }
50
50
  const processorIssues = runProcessorValidation(rows, config);
51
51
  issues.push(...processorIssues);
52
- const itemTypePathIssues = validateItemTypePath(rows, config);
53
- issues.push(...itemTypePathIssues);
54
52
  const itemNameIssues = validateItemNames(rows, config);
55
53
  issues.push(...itemNameIssues);
56
54
  const identifierConflictIssues = validateStaticIdentifierConflicts(config);
@@ -137,7 +135,7 @@ function runProcessorValidation(rows, config) {
137
135
  for (const error of validationResult?.generalErrors ?? []) {
138
136
  issues.push({
139
137
  severity: types_2.PreValidationSeverity.ERROR,
140
- category: issueTypeToCategory(error.issueType),
138
+ category: CONFIG_CATEGORY,
141
139
  columnName: '',
142
140
  propertySlug: '',
143
141
  propertyType: '',
@@ -148,7 +146,7 @@ function runProcessorValidation(rows, config) {
148
146
  for (const warning of validationResult?.generalWarnings ?? []) {
149
147
  issues.push({
150
148
  severity: types_2.PreValidationSeverity.WARNING,
151
- category: issueTypeToCategory(warning.issueType),
149
+ category: CONFIG_CATEGORY,
152
150
  columnName: '',
153
151
  propertySlug: '',
154
152
  propertyType: '',
@@ -398,54 +396,6 @@ function validateMultiSelectFormats(rows, typePropertyMaps) {
398
396
  }
399
397
  return issues;
400
398
  }
401
- function validateItemTypePath(rows, config) {
402
- const isItemCreate = config.loadType.includes(types_2.LoadType.ITEM);
403
- const isCustomEntity = config.loadType.includes(types_2.LoadType.CUSTOM_ENTITY);
404
- if (!isItemCreate && !isCustomEntity)
405
- return [];
406
- const issues = [];
407
- if (isItemCreate) {
408
- const invalidRows = [];
409
- forEachRow(rows, (row, rowNumber) => {
410
- const tp = row.typePath;
411
- const valid = tp === 'item' || (typeof tp === 'string' && tp.startsWith('item:') && tp.split(':')[1]?.length > 0);
412
- if (!valid)
413
- invalidRows.push({ row: rowNumber, value: String(tp ?? '') });
414
- });
415
- if (invalidRows.length > 0) {
416
- issues.push({
417
- severity: types_2.PreValidationSeverity.ERROR,
418
- category: MISSING_REQUIRED_FIELD_CATEGORY,
419
- columnName: 'typePath',
420
- propertySlug: 'typePath',
421
- propertyType: 'string',
422
- message: `"typePath" must be "item" or "item:<subtypepath>". ${invalidRows.length} row(s) have an invalid or missing typePath.`,
423
- affectedRows: invalidRows,
424
- });
425
- }
426
- }
427
- if (isCustomEntity) {
428
- const invalidRows = [];
429
- forEachRow(rows, (row, rowNumber) => {
430
- const tp = row.typePath;
431
- const valid = typeof tp === 'string' && tp.startsWith('custom-entity:') && tp.slice('custom-entity:'.length).length > 0;
432
- if (!valid)
433
- invalidRows.push({ row: rowNumber, value: String(tp ?? '') });
434
- });
435
- if (invalidRows.length > 0) {
436
- issues.push({
437
- severity: types_2.PreValidationSeverity.ERROR,
438
- category: MISSING_REQUIRED_FIELD_CATEGORY,
439
- columnName: 'typePath',
440
- propertySlug: 'typePath',
441
- propertyType: 'string',
442
- message: `"typePath" must be "custom-entity:<subtypepath>". ${invalidRows.length} row(s) have an invalid or missing typePath.`,
443
- affectedRows: invalidRows,
444
- });
445
- }
446
- }
447
- return issues;
448
- }
449
399
  function validateItemNames(rows, config) {
450
400
  const itemBasedLoadTypes = [types_2.LoadType.ITEM, types_2.LoadType.PROJECT_ITEM, types_2.LoadType.ASSORTMENT];
451
401
  const isItemBased = config.loadType.some((lt) => itemBasedLoadTypes.includes(lt));