@contrail/cli 3.6.0-alpha-8-alpha.252e3f3 → 3.6.0-alpha-8-alpha.c613d8e
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 +31 -58
- package/dist/auth/login.js +8 -9
- package/dist/basecommand.js +2 -2
- package/dist/commands/app/getApiKey.js +2 -2
- package/dist/commands/entities/create.d.ts +1 -13
- package/dist/commands/entities/create.js +31 -98
- package/dist/commands/entities/create.spec.js +3 -32
- package/dist/commands/entities/delete.d.ts +2 -6
- package/dist/commands/entities/delete.js +53 -72
- package/dist/commands/entities/get.d.ts +0 -4
- package/dist/commands/entities/get.js +15 -66
- package/dist/commands/entities/update.d.ts +2 -15
- package/dist/commands/entities/update.js +44 -80
- package/dist/common.d.ts +0 -3
- package/dist/common.js +1 -18
- package/dist/helpers/entities/assortment-items.d.ts +2 -4
- package/dist/helpers/entities/assortment-items.js +1 -4
- package/dist/helpers/file-helpers.js +2 -2
- package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +0 -8
- package/dist/helpers/propertySpecifications/propertySpecifications.js +9 -21
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +10 -20
- package/dist/logger.js +1 -4
- package/node_modules/@contrail/entity-compare/package.json +6 -3
- package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
- package/node_modules/@contrail/loader/lib/constants.d.ts +0 -8
- package/node_modules/@contrail/loader/lib/constants.js +1 -9
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +0 -4
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +0 -57
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +34 -492
- package/node_modules/@contrail/loader/lib/pipeline/validate.js +52 -2
- package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +85 -0
- package/node_modules/@contrail/loader/package.json +2 -2
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.d.ts +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.js +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/package.json +1 -1
- package/oclif.manifest.json +27 -99
- package/package.json +1 -1
- package/dist/commands/entities/grammar.spec.d.ts +0 -1
- package/dist/commands/entities/grammar.spec.js +0 -80
- package/dist/commands/entities/output.spec.d.ts +0 -1
- package/dist/commands/entities/output.spec.js +0 -72
- package/dist/logger.spec.d.ts +0 -1
- package/dist/logger.spec.js +0 -12
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +0 -34
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/image-search.js +0 -42
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/index.d.ts +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/index.js +0 -17
package/dist/common.d.ts
CHANGED
|
@@ -2,6 +2,3 @@
|
|
|
2
2
|
export declare function getSeparatorByPlatform(): string;
|
|
3
3
|
export declare function delay(ms: number): Promise<NodeJS.Timeout>;
|
|
4
4
|
export declare function removeSlash(string: string): string;
|
|
5
|
-
export declare function routeConsoleLogToStderr(): void;
|
|
6
|
-
export declare function sdkErrorMessage(reason: any): string;
|
|
7
|
-
export declare const promptOnStderr: any;
|
package/dist/common.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
3
|
+
exports.removeSlash = exports.delay = exports.getSeparatorByPlatform = void 0;
|
|
6
4
|
function getSeparatorByPlatform() {
|
|
7
5
|
const isWin = process.platform === 'win32';
|
|
8
6
|
const separator = isWin ? '\\' : '/';
|
|
@@ -18,18 +16,3 @@ function removeSlash(string) {
|
|
|
18
16
|
return string.replace(re, '-');
|
|
19
17
|
}
|
|
20
18
|
exports.removeSlash = removeSlash;
|
|
21
|
-
// The SDK and auth flow print request logs and token messages via bare
|
|
22
|
-
// console.log. A command whose stdout is a data contract must route those to
|
|
23
|
-
// stderr before any of that code runs.
|
|
24
|
-
function routeConsoleLogToStderr() {
|
|
25
|
-
console.log = (...args) => console.error(...args);
|
|
26
|
-
}
|
|
27
|
-
exports.routeConsoleLogToStderr = routeConsoleLogToStderr;
|
|
28
|
-
// SDK errors can carry an empty message with the response body in details
|
|
29
|
-
function sdkErrorMessage(reason) {
|
|
30
|
-
return reason?.message || reason?.details || String(reason);
|
|
31
|
-
}
|
|
32
|
-
exports.sdkErrorMessage = sdkErrorMessage;
|
|
33
|
-
// inquirer renders prompt UI to its output stream directly, bypassing the
|
|
34
|
-
// console.log redirect; stdout must stay data-only
|
|
35
|
-
exports.promptOnStderr = inquirer_1.default.createPromptModule({ output: process.stderr });
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Item } from '@contrail/entity-types';
|
|
2
|
-
import { API_VERSION } from '@contrail/sdk';
|
|
3
2
|
export declare function throwIfInvalidAssortmentId(assortmentId: string): Promise<void>;
|
|
4
3
|
export declare function createAssortmentItem(assortmentItem: {
|
|
5
4
|
assortmentId: string;
|
|
6
5
|
itemId: string;
|
|
7
6
|
[key: string]: any;
|
|
8
|
-
},
|
|
9
|
-
skipHydrateRelationships
|
|
10
|
-
apiVersion?: API_VERSION;
|
|
7
|
+
}, { skipHydrateRelationships }?: {
|
|
8
|
+
skipHydrateRelationships: boolean;
|
|
11
9
|
}): Promise<any>;
|
|
12
10
|
export declare function findItemsNotInAssortment(assortmentId: string, count?: number): Promise<Item[]>;
|
|
@@ -15,17 +15,15 @@ async function doesAssortmentExistById(id) {
|
|
|
15
15
|
const assortment = await client.get({ entityName: 'assortment', id });
|
|
16
16
|
return !!assortment;
|
|
17
17
|
}
|
|
18
|
-
async function createAssortmentItem(assortmentItem,
|
|
18
|
+
async function createAssortmentItem(assortmentItem, { skipHydrateRelationships } = { skipHydrateRelationships: false }) {
|
|
19
19
|
const client = new sdk_1.Entities();
|
|
20
20
|
const { assortmentId, itemId } = assortmentItem;
|
|
21
|
-
const { skipHydrateRelationships = false, apiVersion } = options;
|
|
22
21
|
// add item to assortment
|
|
23
22
|
await client.create({
|
|
24
23
|
entityName: 'assortment',
|
|
25
24
|
id: assortmentId,
|
|
26
25
|
relation: 'items',
|
|
27
26
|
object: { itemIds: [itemId] },
|
|
28
|
-
apiVersion,
|
|
29
27
|
});
|
|
30
28
|
// Update assortment item with properties
|
|
31
29
|
const updated = await client.update({
|
|
@@ -33,7 +31,6 @@ async function createAssortmentItem(assortmentItem, options = {}) {
|
|
|
33
31
|
id: `${assortmentId}:${itemId}`,
|
|
34
32
|
object: assortmentItem,
|
|
35
33
|
skipHydrateRelationships,
|
|
36
|
-
apiVersion,
|
|
37
34
|
});
|
|
38
35
|
return updated;
|
|
39
36
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadData = exports.saveData = exports.parseFileAsJsonArray = exports.parseCSVData = exports.safeFileOverwrite = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
|
-
const common_1 = require("../common");
|
|
7
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
8
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
9
9
|
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
10
10
|
const sync_1 = require("csv-parse/sync");
|
|
@@ -15,7 +15,7 @@ async function safeFileOverwrite(fileLocation, overwrite) {
|
|
|
15
15
|
logger_1.default.info(`overwriting ${fileLocation}`);
|
|
16
16
|
return true;
|
|
17
17
|
}
|
|
18
|
-
const answers = await
|
|
18
|
+
const answers = await inquirer_1.default.prompt([
|
|
19
19
|
{
|
|
20
20
|
type: 'confirm',
|
|
21
21
|
name: 'shouldOverwrite',
|
|
@@ -29,12 +29,4 @@ export type PropertySpecificationBySlug = Map<string, string | number | string[]
|
|
|
29
29
|
export type PropertySpecificationString = `${string}=${string}`;
|
|
30
30
|
export declare function parsePropertySpecification(spec: PropertySpecificationString): PropertySpecification;
|
|
31
31
|
export declare function parsePropertySpecificationsIntoMap(propertySpecifications: PropertySpecificationString[]): PropertySpecificationBySlug;
|
|
32
|
-
/**
|
|
33
|
-
* Splits command argv tokens (after the typePath) into positional ids and
|
|
34
|
-
* property specifications.
|
|
35
|
-
*/
|
|
36
|
-
export declare function partitionIdsAndSpecs(tokens: string[]): {
|
|
37
|
-
ids: string[];
|
|
38
|
-
specs: PropertySpecificationString[];
|
|
39
|
-
};
|
|
40
32
|
export declare function isValidPropertySpecification(maybeSpec: string): maybeSpec is PropertySpecificationString;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* contrail entities get loader-processes -- createdOn=2025-09-15..2025-09-16
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.isValidPropertySpecification = exports.
|
|
26
|
+
exports.isValidPropertySpecification = exports.parsePropertySpecificationsIntoMap = exports.parsePropertySpecification = void 0;
|
|
27
27
|
const dateRanges_1 = require("./dateRanges");
|
|
28
28
|
// Special tokens for empty strings
|
|
29
29
|
const DOUBLE_QUOTED_EMPTY = '""';
|
|
@@ -64,17 +64,16 @@ function parsePropertySpecificationsIntoMap(propertySpecifications) {
|
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
66
|
const { slug, value } = parsePropertySpecification(spec);
|
|
67
|
-
if (slug === '
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const existingIds = propertySpecBySlug.get(slug);
|
|
72
|
-
propertySpecBySlug.set(slug, Array.isArray(existingIds) ? [...existingIds, ...idsArray] : idsArray);
|
|
67
|
+
if (slug === 'roles' && value !== undefined) {
|
|
68
|
+
// Special handling for roles, which can be an array (only if value is not undefined)
|
|
69
|
+
const rolesArray = value.split(',').map((role) => role.trim());
|
|
70
|
+
propertySpecBySlug.set(slug, rolesArray);
|
|
73
71
|
continue;
|
|
74
72
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
if (slug === 'ids' && value !== undefined) {
|
|
74
|
+
// Special handling for ids, which can be an array (only if value is not undefined)
|
|
75
|
+
const idsArray = value.split(',').map((id) => id.trim());
|
|
76
|
+
propertySpecBySlug.set(slug, idsArray);
|
|
78
77
|
continue;
|
|
79
78
|
}
|
|
80
79
|
propertySpecBySlug.set(slug, value);
|
|
@@ -82,17 +81,6 @@ function parsePropertySpecificationsIntoMap(propertySpecifications) {
|
|
|
82
81
|
return propertySpecBySlug;
|
|
83
82
|
}
|
|
84
83
|
exports.parsePropertySpecificationsIntoMap = parsePropertySpecificationsIntoMap;
|
|
85
|
-
/**
|
|
86
|
-
* Splits command argv tokens (after the typePath) into positional ids and
|
|
87
|
-
* property specifications.
|
|
88
|
-
*/
|
|
89
|
-
function partitionIdsAndSpecs(tokens) {
|
|
90
|
-
return {
|
|
91
|
-
ids: tokens.filter((token) => !token.includes('=')),
|
|
92
|
-
specs: tokens.filter(isValidPropertySpecification),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
exports.partitionIdsAndSpecs = partitionIdsAndSpecs;
|
|
96
84
|
function isValidPropertySpecification(maybeSpec) {
|
|
97
85
|
try {
|
|
98
86
|
if ((0, dateRanges_1.isDateRangeSpecification)(maybeSpec)) {
|
|
@@ -142,17 +142,12 @@ describe('parsePropertySpecificationsIntoMap', () => {
|
|
|
142
142
|
expect(result.get('url')).toBe('https://example.com');
|
|
143
143
|
expect(result.size).toBe(3);
|
|
144
144
|
});
|
|
145
|
-
it('should
|
|
145
|
+
it('should handle duplicate slugs by overwriting with last value', () => {
|
|
146
146
|
const specs = ['name=first', 'name=second', 'name=third'];
|
|
147
147
|
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
148
|
-
expect(result.get('name')).
|
|
148
|
+
expect(result.get('name')).toBe('third');
|
|
149
149
|
expect(result.size).toBe(1);
|
|
150
150
|
});
|
|
151
|
-
it('should keep a single value scalar', () => {
|
|
152
|
-
const specs = ['status=archived'];
|
|
153
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
154
|
-
expect(result.get('status')).toBe('archived');
|
|
155
|
-
});
|
|
156
151
|
it('should handle property specifications with empty values', () => {
|
|
157
152
|
const specs = ['name=john', 'description=', 'notes=""'];
|
|
158
153
|
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
@@ -168,21 +163,21 @@ describe('parsePropertySpecificationsIntoMap', () => {
|
|
|
168
163
|
];
|
|
169
164
|
expect(() => (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs)).toThrow('Invalid property specification: invalid');
|
|
170
165
|
});
|
|
171
|
-
it('should
|
|
172
|
-
const specs = ['roles=option
|
|
166
|
+
it('should handle roles as comma-separated array', () => {
|
|
167
|
+
const specs = ['roles=option,family', 'name=Test'];
|
|
173
168
|
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
174
169
|
expect(result.get('roles')).toEqual(['option', 'family']);
|
|
175
170
|
expect(result.get('name')).toBe('Test');
|
|
176
171
|
});
|
|
177
|
-
it('should
|
|
178
|
-
const specs = ['roles=option
|
|
172
|
+
it('should handle roles as single value', () => {
|
|
173
|
+
const specs = ['roles=option'];
|
|
179
174
|
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
180
|
-
expect(result.get('roles')).
|
|
175
|
+
expect(result.get('roles')).toEqual(['option']);
|
|
181
176
|
});
|
|
182
|
-
it('should
|
|
183
|
-
const specs = ['
|
|
177
|
+
it('should trim whitespace in roles array', () => {
|
|
178
|
+
const specs = ['roles=option, family, variant'];
|
|
184
179
|
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
185
|
-
expect(result.get('
|
|
180
|
+
expect(result.get('roles')).toEqual(['option', 'family', 'variant']);
|
|
186
181
|
});
|
|
187
182
|
it('should handle ids as comma-separated array', () => {
|
|
188
183
|
const specs = ['ids=1,2,3', 'name=Test'];
|
|
@@ -190,11 +185,6 @@ describe('parsePropertySpecificationsIntoMap', () => {
|
|
|
190
185
|
expect(result.get('ids')).toEqual(['1', '2', '3']);
|
|
191
186
|
expect(result.get('name')).toBe('Test');
|
|
192
187
|
});
|
|
193
|
-
it('should accumulate repeated ids keys', () => {
|
|
194
|
-
const specs = ['ids=1,2', 'ids=3'];
|
|
195
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
196
|
-
expect(result.get('ids')).toEqual(['1', '2', '3']);
|
|
197
|
-
});
|
|
198
188
|
it('should handle ids as single value', () => {
|
|
199
189
|
const specs = ['ids=123'];
|
|
200
190
|
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
package/dist/logger.js
CHANGED
|
@@ -12,10 +12,7 @@ class Logger {
|
|
|
12
12
|
debug: 'blue',
|
|
13
13
|
};
|
|
14
14
|
constructor() {
|
|
15
|
-
|
|
16
|
-
const transport = new winston_1.transports.Console({
|
|
17
|
-
stderrLevels: ['error', 'warn', 'info', 'debug'],
|
|
18
|
-
});
|
|
15
|
+
const transport = new winston_1.transports.Console();
|
|
19
16
|
winston_1.default.addColors(this.colors);
|
|
20
17
|
this.logger = (0, winston_1.createLogger)({
|
|
21
18
|
level: 'info',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/entity-compare",
|
|
3
|
-
"version": "1.2.
|
|
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.
|
|
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);
|