@contrail/cli 3.6.0-alpha.c22a682 → 3.6.0-alpha.c4e7620

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 (91) hide show
  1. package/README.md +182 -26
  2. package/dist/api/types.d.ts +35 -0
  3. package/dist/api/types.js +49 -1
  4. package/dist/auth/login.d.ts +0 -4
  5. package/dist/auth/login.js +52 -115
  6. package/dist/auth/login.spec.js +0 -98
  7. package/dist/basecommand.js +2 -2
  8. package/dist/commands/app/getApiKey.js +2 -2
  9. package/dist/commands/entities/create.d.ts +49 -0
  10. package/dist/commands/entities/create.js +618 -0
  11. package/dist/commands/entities/create.spec.js +581 -0
  12. package/dist/commands/entities/delete.d.ts +20 -0
  13. package/dist/commands/entities/delete.js +146 -0
  14. package/dist/commands/entities/get.d.ts +25 -0
  15. package/dist/commands/entities/get.js +298 -0
  16. package/dist/commands/entities/grammar.spec.d.ts +1 -0
  17. package/dist/commands/entities/grammar.spec.js +79 -0
  18. package/dist/commands/entities/output.spec.d.ts +1 -0
  19. package/dist/commands/entities/output.spec.js +72 -0
  20. package/dist/commands/entities/update.d.ts +32 -0
  21. package/dist/commands/entities/update.js +212 -0
  22. package/dist/commands/webhooks/delete.js +2 -3
  23. package/dist/common.d.ts +10 -1
  24. package/dist/common.js +37 -1
  25. package/dist/common.spec.d.ts +1 -0
  26. package/dist/common.spec.js +40 -0
  27. package/dist/helpers/config/config.d.ts +3 -3
  28. package/dist/helpers/config/config.js +3 -3
  29. package/dist/helpers/entities/assortment-items.d.ts +11 -0
  30. package/dist/helpers/entities/assortment-items.js +76 -0
  31. package/dist/helpers/entities/batchFetch.d.ts +11 -0
  32. package/dist/helpers/entities/batchFetch.js +50 -0
  33. package/dist/helpers/entities/index.d.ts +3 -0
  34. package/dist/helpers/entities/index.js +6 -0
  35. package/dist/helpers/entities/items.d.ts +6 -0
  36. package/dist/helpers/entities/items.js +60 -0
  37. package/dist/helpers/entities/items.spec.d.ts +1 -0
  38. package/dist/helpers/entities/items.spec.js +19 -0
  39. package/dist/helpers/entities/project-items.d.ts +2 -0
  40. package/dist/helpers/entities/project-items.js +44 -0
  41. package/dist/helpers/file-helpers.d.ts +1 -0
  42. package/dist/helpers/file-helpers.js +20 -3
  43. package/dist/helpers/propertySpecifications/dateRanges.d.ts +34 -0
  44. package/dist/helpers/propertySpecifications/dateRanges.js +91 -0
  45. package/dist/helpers/propertySpecifications/dateRanges.spec.d.ts +1 -0
  46. package/dist/helpers/propertySpecifications/dateRanges.spec.js +97 -0
  47. package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +39 -0
  48. package/dist/helpers/propertySpecifications/propertySpecifications.js +102 -0
  49. package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +1 -0
  50. package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +387 -0
  51. package/dist/helpers/propertySpecifications/propertyValues.d.ts +31 -0
  52. package/dist/helpers/propertySpecifications/propertyValues.js +132 -0
  53. package/dist/helpers/propertySpecifications/propertyValues.spec.d.ts +1 -0
  54. package/dist/helpers/propertySpecifications/propertyValues.spec.js +156 -0
  55. package/dist/logger.js +4 -1
  56. package/dist/logger.spec.d.ts +1 -0
  57. package/dist/logger.spec.js +12 -0
  58. package/node_modules/@contrail/entity-compare/package.json +6 -3
  59. package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
  60. package/node_modules/@contrail/loader/lib/constants.d.ts +0 -8
  61. package/node_modules/@contrail/loader/lib/constants.js +1 -9
  62. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +0 -4
  63. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +0 -57
  64. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +34 -492
  65. package/node_modules/@contrail/loader/lib/pipeline/validate.js +52 -2
  66. package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +85 -0
  67. package/node_modules/@contrail/loader/package.json +2 -2
  68. package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +1 -4
  69. package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
  70. package/node_modules/@contrail/sdk/lib/config/config.d.ts +3 -0
  71. package/node_modules/@contrail/sdk/lib/config/config.js +13 -7
  72. package/node_modules/@contrail/sdk/lib/core/request.js +6 -2
  73. package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +2 -0
  74. package/node_modules/@contrail/sdk/lib/entities/entities.client.js +3 -1
  75. package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +1 -0
  76. package/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +34 -0
  77. package/node_modules/@contrail/sdk/lib/image-search/image-search.js +42 -0
  78. package/node_modules/@contrail/sdk/lib/image-search/index.d.ts +1 -0
  79. package/node_modules/@contrail/sdk/lib/image-search/index.js +17 -0
  80. package/node_modules/@contrail/sdk/lib/index.d.ts +1 -0
  81. package/node_modules/@contrail/sdk/lib/index.js +1 -0
  82. package/node_modules/@contrail/sdk/package.json +1 -1
  83. package/node_modules/@contrail/sdk/scripts/replicate-bug.js +69 -0
  84. package/oclif.manifest.json +449 -50
  85. package/package.json +6 -12
  86. package/dist/auth/sso.d.ts +0 -36
  87. package/dist/auth/sso.js +0 -168
  88. package/dist/auth/sso.spec.js +0 -138
  89. package/dist/commands/login.d.ts +0 -12
  90. package/dist/commands/login.js +0 -25
  91. /package/dist/{auth/sso.spec.d.ts → commands/entities/create.spec.d.ts} +0 -0
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const types_1 = require("@contrail/types");
4
+ const propertyValues_1 = require("./propertyValues");
5
+ describe('castValueToPropertyType array coercion', () => {
6
+ it('should coerce a single value on a multi-value property to a one-element array', () => {
7
+ expect((0, propertyValues_1.castValueToPropertyType)('option', types_1.PropertyType.MultiSelect, 'colors')).toEqual([
8
+ 'option',
9
+ ]);
10
+ });
11
+ it('should pass arrays through on multi-value properties', () => {
12
+ expect((0, propertyValues_1.castValueToPropertyType)(['option', 'family'], types_1.PropertyType.MultiSelect, 'colors')).toEqual(['option', 'family']);
13
+ });
14
+ it('should keep a comma value literal on a multi-value property and warn with the repeated-key form', () => {
15
+ const consoleError = jest.spyOn(console, 'error').mockImplementation(() => undefined);
16
+ expect((0, propertyValues_1.castValueToPropertyType)('option,family', types_1.PropertyType.MultiSelect, 'colors')).toEqual([
17
+ 'option,family',
18
+ ]);
19
+ expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('colors=option colors=family'));
20
+ consoleError.mockRestore();
21
+ });
22
+ it('should cast each element of a repeated-key array on scalar property types', () => {
23
+ expect((0, propertyValues_1.castValueToPropertyType)(['1', '2'], types_1.PropertyType.Number, 'rank')).toEqual([1, 2]);
24
+ expect((0, propertyValues_1.castValueToPropertyType)(['true', 'false'], types_1.PropertyType.Boolean, 'isActive')).toEqual([
25
+ true,
26
+ false,
27
+ ]);
28
+ });
29
+ it('should keep commas literal on string properties without warning', () => {
30
+ const consoleError = jest.spyOn(console, 'error').mockImplementation(() => undefined);
31
+ expect((0, propertyValues_1.castValueToPropertyType)('my,name', types_1.PropertyType.String, 'name')).toBe('my,name');
32
+ expect(consoleError).not.toHaveBeenCalled();
33
+ consoleError.mockRestore();
34
+ });
35
+ });
36
+ describe('getPropertySlug', () => {
37
+ it('should suffix Id for an object reference', () => {
38
+ expect((0, propertyValues_1.getPropertySlug)({ slug: 'fabric', propertyType: types_1.PropertyType.ObjectReference })).toBe('fabricId');
39
+ });
40
+ it('should leave every other property type alone', () => {
41
+ expect((0, propertyValues_1.getPropertySlug)({ slug: 'name', propertyType: types_1.PropertyType.String })).toBe('name');
42
+ });
43
+ });
44
+ describe('castValuesToPropertyTypes', () => {
45
+ const typeProperties = [
46
+ { slug: 'isArchived', propertyType: types_1.PropertyType.Boolean },
47
+ { slug: 'rank', propertyType: types_1.PropertyType.Number },
48
+ { slug: 'fabric', propertyType: types_1.PropertyType.ObjectReference },
49
+ ];
50
+ it('should cast each value using its property type', () => {
51
+ const result = (0, propertyValues_1.castValuesToPropertyTypes)(new Map([
52
+ ['isArchived', 'false'],
53
+ ['rank', '3'],
54
+ ]), typeProperties);
55
+ expect(result).toEqual({ isArchived: false, rank: 3 });
56
+ });
57
+ it('should match an object reference by its suffixed slug', () => {
58
+ const result = (0, propertyValues_1.castValuesToPropertyTypes)(new Map([['fabricId', 'abc']]), typeProperties);
59
+ expect(result).toEqual({ fabricId: 'abc' });
60
+ });
61
+ it('should write a slug the type does not define through as a string', () => {
62
+ const result = (0, propertyValues_1.castValuesToPropertyTypes)(new Map([['unknown', 'false']]), typeProperties);
63
+ expect(result).toEqual({ unknown: 'false' });
64
+ });
65
+ it('should treat a missing type as defining no properties', () => {
66
+ expect((0, propertyValues_1.castValuesToPropertyTypes)(new Map([['isArchived', 'true']]))).toEqual({
67
+ isArchived: 'true',
68
+ });
69
+ });
70
+ });
71
+ describe('inferAndCastValue', () => {
72
+ it('should coerce a number only when it survives the round trip', () => {
73
+ expect((0, propertyValues_1.inferAndCastValue)('3650')).toBe(3650);
74
+ expect((0, propertyValues_1.inferAndCastValue)('12.5')).toBe(12.5);
75
+ expect((0, propertyValues_1.inferAndCastValue)('0')).toBe(0);
76
+ });
77
+ it('should keep numeric-looking strings that would not round trip', () => {
78
+ // hex=000000 appears in the create examples, and parseFloat would make it 0
79
+ expect((0, propertyValues_1.inferAndCastValue)('000000')).toBe('000000');
80
+ expect((0, propertyValues_1.inferAndCastValue)('007')).toBe('007');
81
+ expect((0, propertyValues_1.inferAndCastValue)('12.50')).toBe('12.50');
82
+ expect((0, propertyValues_1.inferAndCastValue)('1e5')).toBe('1e5');
83
+ });
84
+ it('should coerce exact booleans only', () => {
85
+ expect((0, propertyValues_1.inferAndCastValue)('true')).toBe(true);
86
+ expect((0, propertyValues_1.inferAndCastValue)('false')).toBe(false);
87
+ expect((0, propertyValues_1.inferAndCastValue)('True')).toBe('True');
88
+ });
89
+ it('should coerce ISO dates', () => {
90
+ expect((0, propertyValues_1.inferAndCastValue)('2025-09-15')).toBe('2025-09-15T00:00:00.000Z');
91
+ expect((0, propertyValues_1.inferAndCastValue)('not-a-date')).toBe('not-a-date');
92
+ });
93
+ it('should map over arrays and leave non-strings alone', () => {
94
+ expect((0, propertyValues_1.inferAndCastValue)(['1', 'x'])).toEqual([1, 'x']);
95
+ expect((0, propertyValues_1.inferAndCastValue)(7)).toBe(7);
96
+ });
97
+ });
98
+ describe('buildPropertyTypeMap', () => {
99
+ it('should give the first type precedence for a conflicting slug', () => {
100
+ const first = [{ slug: 'matchingProperty2', propertyType: types_1.PropertyType.Number }];
101
+ const second = [{ slug: 'matchingProperty2', propertyType: types_1.PropertyType.String }];
102
+ expect((0, propertyValues_1.buildPropertyTypeMap)([first, second]).get('matchingProperty2')).toBe(types_1.PropertyType.Number);
103
+ expect((0, propertyValues_1.buildPropertyTypeMap)([second, first]).get('matchingProperty2')).toBe(types_1.PropertyType.String);
104
+ });
105
+ it('should tolerate a type that could not be resolved', () => {
106
+ expect((0, propertyValues_1.buildPropertyTypeMap)([undefined]).size).toBe(0);
107
+ });
108
+ });
109
+ describe('castCriteriaValues', () => {
110
+ const typeProperties = [
111
+ { slug: 'isArchived', propertyType: types_1.PropertyType.Boolean },
112
+ { slug: 'optionSequence', propertyType: types_1.PropertyType.Sequence },
113
+ { slug: 'hex', propertyType: types_1.PropertyType.String },
114
+ ];
115
+ it('should cast a defined slug from its property type', () => {
116
+ expect((0, propertyValues_1.castCriteriaValues)(new Map([['isArchived', 'false']]), [typeProperties])).toEqual({
117
+ isArchived: false,
118
+ });
119
+ });
120
+ it('should cast the whole numeric family, not just Number', () => {
121
+ expect((0, propertyValues_1.castCriteriaValues)(new Map([['optionSequence', '3650']]), [typeProperties])).toEqual({
122
+ optionSequence: 3650,
123
+ });
124
+ });
125
+ it('should leave a defined string property alone', () => {
126
+ expect((0, propertyValues_1.castCriteriaValues)(new Map([['hex', '000000']]), [typeProperties])).toEqual({
127
+ hex: '000000',
128
+ });
129
+ });
130
+ it('should fall back to the value shape for an undefined slug', () => {
131
+ expect((0, propertyValues_1.castCriteriaValues)(new Map([['unknown', 'true']]), [typeProperties])).toEqual({
132
+ unknown: true,
133
+ });
134
+ });
135
+ it('should never coerce id or ids', () => {
136
+ expect((0, propertyValues_1.castCriteriaValues)(new Map([
137
+ ['id', '12345'],
138
+ ['ids', ['1', '2']],
139
+ ]), [])).toEqual({ id: '12345', ids: ['1', '2'] });
140
+ });
141
+ });
142
+ describe('castValuesToPropertyTypes never guesses', () => {
143
+ it('should write an undefined slug through unchanged', () => {
144
+ expect((0, propertyValues_1.castValuesToPropertyTypes)(new Map([['unknown', 'true']]), [])).toEqual({
145
+ unknown: 'true',
146
+ });
147
+ });
148
+ });
149
+ describe('Date casting', () => {
150
+ it('should name the slug and value for an unparseable date', () => {
151
+ expect(() => (0, propertyValues_1.castValueToPropertyType)('garbage', types_1.PropertyType.Date, 'createdOn')).toThrow('Invalid date value for createdOn: garbage');
152
+ });
153
+ it('should still convert a parseable date', () => {
154
+ expect((0, propertyValues_1.castValueToPropertyType)('2025-09-15', types_1.PropertyType.Date, 'createdOn')).toBe('2025-09-15T00:00:00.000Z');
155
+ });
156
+ });
package/dist/logger.js CHANGED
@@ -12,7 +12,10 @@ class Logger {
12
12
  debug: 'blue',
13
13
  };
14
14
  constructor() {
15
- const transport = new winston_1.transports.Console();
15
+ // All log output goes to stderr so stdout carries only command output (JSON)
16
+ const transport = new winston_1.transports.Console({
17
+ stderrLevels: ['error', 'warn', 'info', 'debug'],
18
+ });
16
19
  winston_1.default.addColors(this.colors);
17
20
  this.logger = (0, winston_1.createLogger)({
18
21
  level: 'info',
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const logger_1 = tslib_1.__importDefault(require("./logger"));
5
+ describe('logger', () => {
6
+ it('should write every log level to stderr so stdout carries only command output', () => {
7
+ const consoleTransport = logger_1.default.transports[0];
8
+ for (const level of ['error', 'warn', 'info', 'debug']) {
9
+ expect(consoleTransport.stderrLevels[level]).toBe(true);
10
+ }
11
+ });
12
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/entity-compare",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Library for comparing entities.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -14,7 +14,6 @@
14
14
  "author": "",
15
15
  "license": "ISC",
16
16
  "dependencies": {
17
- "@contrail/telemetry": "^2.0.0",
18
17
  "@contrail/util": "^1.3.0",
19
18
  "es6-promisify": "^6.1.1"
20
19
  },
@@ -26,7 +25,8 @@
26
25
  "ts-jest": "^29.1.1",
27
26
  "tslint": "^5.11.0",
28
27
  "tslint-config-prettier": "^1.18.0",
29
- "typescript": "^5.0.0"
28
+ "typescript": "^5.0.0",
29
+ "@contrail/telemetry": "^2.0.0"
30
30
  },
31
31
  "jest": {
32
32
  "moduleFileExtensions": [
@@ -41,5 +41,8 @@
41
41
  },
42
42
  "coverageDirectory": "../coverage",
43
43
  "testEnvironment": "node"
44
+ },
45
+ "peerDependencies": {
46
+ "@contrail/telemetry": "^2.0.0"
44
47
  }
45
48
  }
@@ -66,7 +66,7 @@ class ColumnDefinitionEvaluator {
66
66
  static getValue(value, row) {
67
67
  if (util_1.StringUtil.isString(value) && value.includes('{')) {
68
68
  try {
69
- const val = evaluate(util_1.StringUtil.parseVariables(value, row, true));
69
+ const val = evaluate(util_1.StringUtil.parseVariables(String(value), row, true));
70
70
  return val;
71
71
  }
72
72
  catch {
@@ -13,16 +13,8 @@ export declare const ENTITY_PROCESSOR_ERRORS: {
13
13
  readonly SINGLE_LOAD_TYPE: (entityType: string) => string;
14
14
  };
15
15
  export declare const ITEM_PROCESSOR_ERRORS: {
16
- readonly LOAD_TYPE_INVALID: "\"loadType\" must be either of values [\"ITEM\", \"PROJECT_ITEM\", \"ASSORTMENT\"] in the config file";
17
- readonly TYPEPATH_INVALID: "\"typePath\" must be \"item\" or \"item:<subtypepath>\" in the config file";
18
16
  readonly FAMILY_ID_EMPTY: "itemFamilyFederatedId is null or undefined or empty in the CSV file";
19
17
  readonly CONFLICTING_IDS: (ids: any) => string;
20
18
  };
21
19
  export declare const FEDERATED_ID_FETCH_MAX_URL_BYTES = 4000;
22
20
  export declare const FEDERATED_ID_FETCH_MAX_COUNT = 200;
23
- export declare const ITEM_PROCESSOR_WARNINGS: {
24
- readonly OPTIONNAME_UNMAPPED: "\"optionName\" is not found in the federatedMapping config, conditionalColumns config, or as a header in the CSV file.";
25
- readonly OPTIONNAME_NOT_FOUND: (optionName: string) => string;
26
- readonly OPTION_FEDERATED_ID_UNMAPPED: "\"itemOptionFederatedId\" is not found in the federatedMapping config, conditionalColumns config, or as a header in the CSV file.";
27
- readonly OPTION_FEDERATED_ID_NOT_FOUND: (itemOptionFederatedId: string) => string;
28
- };
@@ -1,6 +1,6 @@
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.COLOR_PROCESSOR_ERRORS = void 0;
3
+ 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
  };
@@ -16,16 +16,8 @@ exports.ENTITY_PROCESSOR_ERRORS = {
16
16
  SINGLE_LOAD_TYPE: (entityType) => `"loadType" must be single value "${entityType}" in the config file`,
17
17
  };
18
18
  exports.ITEM_PROCESSOR_ERRORS = {
19
- LOAD_TYPE_INVALID: '"loadType" must be either of values ["ITEM", "PROJECT_ITEM", "ASSORTMENT"] in the config file',
20
- TYPEPATH_INVALID: '"typePath" must be "item" or "item:<subtypepath>" in the config file',
21
19
  FAMILY_ID_EMPTY: 'itemFamilyFederatedId is null or undefined or empty in the CSV file',
22
20
  CONFLICTING_IDS: (ids) => `Found conflicting family federated Ids: ${ids}`,
23
21
  };
24
22
  exports.FEDERATED_ID_FETCH_MAX_URL_BYTES = 4000;
25
23
  exports.FEDERATED_ID_FETCH_MAX_COUNT = 200;
26
- exports.ITEM_PROCESSOR_WARNINGS = {
27
- OPTIONNAME_UNMAPPED: '"optionName" is not found in the federatedMapping config, conditionalColumns config, or as a header in the CSV file.',
28
- OPTIONNAME_NOT_FOUND: (optionName) => `"${optionName}" column not found in the CSV file`,
29
- OPTION_FEDERATED_ID_UNMAPPED: '"itemOptionFederatedId" is not found in the federatedMapping config, conditionalColumns config, or as a header in the CSV file.',
30
- OPTION_FEDERATED_ID_NOT_FOUND: (itemOptionFederatedId) => `"${itemOptionFederatedId}" column not found in the CSV file`,
31
- };
@@ -24,10 +24,6 @@ export declare class ItemProcessor extends BaseProcessorV2 {
24
24
  generalErrors: GeneralIssueDetails[];
25
25
  generalWarnings: GeneralIssueDetails[];
26
26
  };
27
- private static validateLoadType;
28
- private static validateTypePathMapping;
29
- private static validateOptionNameMapping;
30
- private static validateItemOptionFederatedIdMapping;
31
27
  private static validateFederatedIds;
32
28
  private static prepareDataWithConditionalValues;
33
29
  private static findConditionalColumn;
@@ -59,66 +59,9 @@ class ItemProcessor extends base_processor_v2_1.BaseProcessorV2 {
59
59
  if (returnImmediately) {
60
60
  return { errors, warnings, generalErrors, generalWarnings };
61
61
  }
62
- this.validateLoadType(config, generalErrors);
63
- this.validateTypePathMapping(data, generalErrors);
64
- this.validateOptionNameMapping(config, csvHeaders, generalWarnings);
65
- this.validateItemOptionFederatedIdMapping(config, csvHeaders, generalWarnings);
66
62
  this.validateFederatedIds(data, config, errors, generalErrors, csvHeaders);
67
63
  return { errors, warnings, generalErrors, generalWarnings };
68
64
  }
69
- static validateLoadType(config, generalErrors) {
70
- if (config?.loadType?.length &&
71
- !config.loadType.every((type) => [entity_types_1.LoadType.ITEM, entity_types_1.LoadType.PROJECT_ITEM, entity_types_1.LoadType.ASSORTMENT].includes(type))) {
72
- generalErrors.push({
73
- message: constants_1.ITEM_PROCESSOR_ERRORS.LOAD_TYPE_INVALID,
74
- issueType: entity_types_1.IssueType.CONFIG,
75
- });
76
- }
77
- }
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
- });
85
- }
86
- }
87
- static validateOptionNameMapping(config, csvHeaders, generalWarnings) {
88
- const optionNameInConditional = config?.conditionalColumns?.some((column) => column.toProperty === 'optionName');
89
- const optionNameInFederatedMapping = config?.federatedMappings?.optionName;
90
- const optionNameInCSV = csvHeaders.includes('optionName');
91
- if (!optionNameInFederatedMapping && !optionNameInCSV && !optionNameInConditional) {
92
- generalWarnings.push({
93
- message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
94
- issueType: entity_types_1.IssueType.CONFIG,
95
- });
96
- }
97
- else if (optionNameInFederatedMapping && !csvHeaders.includes(config.federatedMappings?.optionName)) {
98
- generalWarnings.push({
99
- message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_NOT_FOUND(config.federatedMappings?.optionName),
100
- issueType: entity_types_1.IssueType.CONFIG,
101
- });
102
- }
103
- }
104
- static validateItemOptionFederatedIdMapping(config, csvHeaders, generalWarnings) {
105
- const optionFederatedIdInConditional = config?.conditionalColumns?.some((column) => column.toProperty === 'itemOptionFederatedId');
106
- const optionFederatedIdInFederatedMapping = config?.federatedMappings?.itemOptionFederatedId;
107
- const optionFederatedIdInCSV = csvHeaders.includes('itemOptionFederatedId');
108
- if (!optionFederatedIdInFederatedMapping && !optionFederatedIdInCSV && !optionFederatedIdInConditional) {
109
- generalWarnings.push({
110
- message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_UNMAPPED,
111
- issueType: entity_types_1.IssueType.CONFIG,
112
- });
113
- }
114
- else if (optionFederatedIdInFederatedMapping &&
115
- !csvHeaders.includes(config.federatedMappings?.itemOptionFederatedId)) {
116
- generalWarnings.push({
117
- message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_NOT_FOUND(config.federatedMappings?.itemOptionFederatedId),
118
- issueType: entity_types_1.IssueType.CONFIG,
119
- });
120
- }
121
- }
122
65
  static validateFederatedIds(data, config, errors, generalErrors, csvHeaders) {
123
66
  const processedData = this.prepareDataWithConditionalValues(data, config);
124
67
  this.validateEmptyItemFamilyFederatedIds(processedData, config, errors);