@contrail/cli 3.6.0-alpha-8-alpha.694fd70 → 3.6.0-alpha-8-alpha.252e3f3
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 +50 -1
- package/dist/api/feature-flags.d.ts +3 -0
- package/dist/api/feature-flags.js +29 -0
- package/dist/api/users.d.ts +1 -0
- package/dist/api/users.js +10 -1
- package/dist/auth/login.js +38 -20
- package/dist/auth/login.spec.js +124 -0
- package/dist/basecommand.js +3 -3
- package/dist/commands/entities/create.d.ts +1 -0
- package/dist/commands/entities/create.js +8 -4
- package/dist/commands/entities/create.spec.js +4 -0
- package/dist/commands/entities/delete.d.ts +1 -0
- package/dist/commands/entities/delete.js +5 -2
- package/dist/commands/entities/get.d.ts +1 -0
- package/dist/commands/entities/get.js +4 -1
- package/dist/commands/entities/update.d.ts +1 -0
- package/dist/commands/entities/update.js +4 -1
- package/dist/commands/feature-flags/export.d.ts +19 -0
- package/dist/commands/feature-flags/export.js +66 -0
- package/dist/commands/feature-flags/export.spec.d.ts +1 -0
- package/dist/commands/feature-flags/export.spec.js +109 -0
- package/dist/commands/feature-flags/import.d.ts +42 -0
- package/dist/commands/feature-flags/import.js +191 -0
- package/dist/commands/feature-flags/import.spec.d.ts +1 -0
- package/dist/commands/feature-flags/import.spec.js +194 -0
- package/dist/commands/instance/export.d.ts +9 -0
- package/dist/commands/instance/export.js +18 -3
- package/dist/commands/instance/export.spec.d.ts +1 -0
- package/dist/commands/instance/export.spec.js +32 -0
- package/dist/commands/instance/import.d.ts +3 -0
- package/dist/commands/instance/import.js +5 -0
- package/dist/commands/instance/import.spec.js +4 -0
- package/dist/common.d.ts +1 -0
- package/dist/common.js +6 -1
- package/dist/helpers/config/config.d.ts +2 -0
- package/dist/helpers/config/config.js +6 -1
- package/dist/helpers/entities/assortment-items.d.ts +4 -2
- package/dist/helpers/entities/assortment-items.js +4 -1
- package/dist/helpers/file-helpers.js +2 -2
- package/node_modules/@contrail/entity-compare/package.json +3 -6
- package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
- package/node_modules/@contrail/loader/lib/constants.d.ts +8 -0
- package/node_modules/@contrail/loader/lib/constants.js +9 -1
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +4 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +57 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +492 -34
- package/node_modules/@contrail/loader/lib/pipeline/validate.js +2 -52
- package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +0 -85
- package/node_modules/@contrail/loader/package.json +2 -2
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +34 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/image-search.js +42 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/index.d.ts +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/index.js +17 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.d.ts +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.js +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/package.json +1 -1
- package/oclif.manifest.json +111 -1
- package/package.json +4 -1
|
@@ -11,6 +11,7 @@ const uploadTypePropertyPolicies_1 = require("../types/uploadTypePropertyPolicie
|
|
|
11
11
|
const uploadTypePolicies_1 = require("../types/uploadTypePolicies");
|
|
12
12
|
const uploadTypeOverrides_1 = require("../types/uploadTypeOverrides");
|
|
13
13
|
const import_3 = require("../org-config/import");
|
|
14
|
+
const import_4 = require("../feature-flags/import");
|
|
14
15
|
const basecommand_1 = require("../../basecommand");
|
|
15
16
|
class ImportInstance extends basecommand_1.BaseCommand {
|
|
16
17
|
static description = 'Import the data to an instance, including types and users';
|
|
@@ -40,6 +41,9 @@ exports.default = ImportInstance;
|
|
|
40
41
|
* 4. type overrides — after policies, because they reference policies, rule sets and option
|
|
41
42
|
* set hierarchies by slug and the API rejects the whole upload if any of them is missing
|
|
42
43
|
* 5. org config
|
|
44
|
+
* 6. feature flags — skipped with a log message when the user has no platform role,
|
|
45
|
+
* since applying them needs PLATFORM_ADMIN/PLATFORM_MANAGER but the rest of the
|
|
46
|
+
* import does not, and org admins are expected to run this command
|
|
43
47
|
*
|
|
44
48
|
* Fails (rejects) if the type overrides could not be applied, so the import does not
|
|
45
49
|
* report success while the org is missing customizations carried by overrides
|
|
@@ -53,5 +57,6 @@ async function importInstance(dir) {
|
|
|
53
57
|
await (0, uploadTypePolicies_1.uploadTypePolicies)(dir);
|
|
54
58
|
await (0, uploadTypeOverrides_1.uploadTypeOverrides)(dir);
|
|
55
59
|
await (0, import_3.uploadOrgConfig)(dir);
|
|
60
|
+
await (0, import_4.uploadFeatureFlagsIfPermitted)(dir);
|
|
56
61
|
}
|
|
57
62
|
exports.importInstance = importInstance;
|
|
@@ -8,6 +8,7 @@ const uploadTypePropertyPolicies_1 = require("../types/uploadTypePropertyPolicie
|
|
|
8
8
|
const uploadTypePolicies_1 = require("../types/uploadTypePolicies");
|
|
9
9
|
const uploadTypeOverrides_1 = require("../types/uploadTypeOverrides");
|
|
10
10
|
const import_4 = require("../org-config/import");
|
|
11
|
+
const import_5 = require("../feature-flags/import");
|
|
11
12
|
jest.mock('../types/loadAll');
|
|
12
13
|
jest.mock('../users/import');
|
|
13
14
|
jest.mock('../groups/import');
|
|
@@ -15,6 +16,7 @@ jest.mock('../types/uploadTypePropertyPolicies');
|
|
|
15
16
|
jest.mock('../types/uploadTypePolicies');
|
|
16
17
|
jest.mock('../types/uploadTypeOverrides');
|
|
17
18
|
jest.mock('../org-config/import');
|
|
19
|
+
jest.mock('../feature-flags/import');
|
|
18
20
|
const mocked = (fn) => fn;
|
|
19
21
|
const STEPS = [
|
|
20
22
|
loadAll_1.loadAll,
|
|
@@ -24,6 +26,7 @@ const STEPS = [
|
|
|
24
26
|
uploadTypePolicies_1.uploadTypePolicies,
|
|
25
27
|
uploadTypeOverrides_1.uploadTypeOverrides,
|
|
26
28
|
import_4.uploadOrgConfig,
|
|
29
|
+
import_5.uploadFeatureFlagsIfPermitted,
|
|
27
30
|
];
|
|
28
31
|
describe('importInstance', () => {
|
|
29
32
|
beforeEach(() => {
|
|
@@ -37,6 +40,7 @@ describe('importInstance', () => {
|
|
|
37
40
|
expect(mocked(loadAll_1.loadAll)).toHaveBeenCalledWith('export-dir', true, false);
|
|
38
41
|
expect(mocked(uploadTypeOverrides_1.uploadTypeOverrides)).toHaveBeenCalledWith('export-dir');
|
|
39
42
|
expect(mocked(import_4.uploadOrgConfig)).toHaveBeenCalledWith('export-dir');
|
|
43
|
+
expect(mocked(import_5.uploadFeatureFlagsIfPermitted)).toHaveBeenCalledWith('export-dir');
|
|
40
44
|
const order = STEPS.map((fn) => mocked(fn).mock.invocationCallOrder[0]);
|
|
41
45
|
// strictly increasing => called in exactly this order
|
|
42
46
|
for (let i = 1; i < order.length; i++) {
|
package/dist/common.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export declare function delay(ms: number): Promise<NodeJS.Timeout>;
|
|
|
4
4
|
export declare function removeSlash(string: string): string;
|
|
5
5
|
export declare function routeConsoleLogToStderr(): void;
|
|
6
6
|
export declare function sdkErrorMessage(reason: any): string;
|
|
7
|
+
export declare const promptOnStderr: any;
|
package/dist/common.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sdkErrorMessage = exports.routeConsoleLogToStderr = exports.removeSlash = exports.delay = exports.getSeparatorByPlatform = void 0;
|
|
3
|
+
exports.promptOnStderr = exports.sdkErrorMessage = exports.routeConsoleLogToStderr = exports.removeSlash = exports.delay = exports.getSeparatorByPlatform = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
4
6
|
function getSeparatorByPlatform() {
|
|
5
7
|
const isWin = process.platform === 'win32';
|
|
6
8
|
const separator = isWin ? '\\' : '/';
|
|
@@ -28,3 +30,6 @@ function sdkErrorMessage(reason) {
|
|
|
28
30
|
return reason?.message || reason?.details || String(reason);
|
|
29
31
|
}
|
|
30
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 });
|
|
@@ -3,6 +3,8 @@ export declare const ENVIRONMENTS: {
|
|
|
3
3
|
prod: string;
|
|
4
4
|
local: string;
|
|
5
5
|
};
|
|
6
|
+
export type EnvironmentName = keyof typeof ENVIRONMENTS;
|
|
7
|
+
export declare function findEnvironmentName(apiGateway: string): EnvironmentName | undefined;
|
|
6
8
|
export declare function initializeVibeIQConfig(): Promise<void>;
|
|
7
9
|
export declare function readVibeIQConfig(): Promise<any>;
|
|
8
10
|
export declare function writeVibeIQConfig(config: any): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkTelemetry = exports.validateEnvironments = exports.getConfigContent = exports.getConfigFiles = exports.storeConfig = exports.getConfig = exports.writeConfig = exports.createConfig = exports.storeVibeIQConfig = exports.writeVibeIQConfig = exports.readVibeIQConfig = exports.initializeVibeIQConfig = exports.ENVIRONMENTS = void 0;
|
|
3
|
+
exports.checkTelemetry = exports.validateEnvironments = exports.getConfigContent = exports.getConfigFiles = exports.storeConfig = exports.getConfig = exports.writeConfig = exports.createConfig = exports.storeVibeIQConfig = exports.writeVibeIQConfig = exports.readVibeIQConfig = exports.initializeVibeIQConfig = exports.findEnvironmentName = exports.ENVIRONMENTS = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
@@ -17,6 +17,11 @@ exports.ENVIRONMENTS = {
|
|
|
17
17
|
prod: 'https://api.vibeiq.com/prod/api',
|
|
18
18
|
local: 'http://localhost:3000/api',
|
|
19
19
|
};
|
|
20
|
+
function findEnvironmentName(apiGateway) {
|
|
21
|
+
const normalizedGateway = apiGateway?.trim().replace(/\/+$/, '').toLowerCase();
|
|
22
|
+
return Object.keys(exports.ENVIRONMENTS).find((name) => exports.ENVIRONMENTS[name] === normalizedGateway);
|
|
23
|
+
}
|
|
24
|
+
exports.findEnvironmentName = findEnvironmentName;
|
|
20
25
|
async function initializeVibeIQConfig() {
|
|
21
26
|
try {
|
|
22
27
|
await node_fs_1.promises.mkdir(configDirectoryLocation, { recursive: true });
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Item } from '@contrail/entity-types';
|
|
2
|
+
import { API_VERSION } from '@contrail/sdk';
|
|
2
3
|
export declare function throwIfInvalidAssortmentId(assortmentId: string): Promise<void>;
|
|
3
4
|
export declare function createAssortmentItem(assortmentItem: {
|
|
4
5
|
assortmentId: string;
|
|
5
6
|
itemId: string;
|
|
6
7
|
[key: string]: any;
|
|
7
|
-
},
|
|
8
|
-
skipHydrateRelationships
|
|
8
|
+
}, options?: {
|
|
9
|
+
skipHydrateRelationships?: boolean;
|
|
10
|
+
apiVersion?: API_VERSION;
|
|
9
11
|
}): Promise<any>;
|
|
10
12
|
export declare function findItemsNotInAssortment(assortmentId: string, count?: number): Promise<Item[]>;
|
|
@@ -15,15 +15,17 @@ 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, options = {}) {
|
|
19
19
|
const client = new sdk_1.Entities();
|
|
20
20
|
const { assortmentId, itemId } = assortmentItem;
|
|
21
|
+
const { skipHydrateRelationships = false, apiVersion } = options;
|
|
21
22
|
// add item to assortment
|
|
22
23
|
await client.create({
|
|
23
24
|
entityName: 'assortment',
|
|
24
25
|
id: assortmentId,
|
|
25
26
|
relation: 'items',
|
|
26
27
|
object: { itemIds: [itemId] },
|
|
28
|
+
apiVersion,
|
|
27
29
|
});
|
|
28
30
|
// Update assortment item with properties
|
|
29
31
|
const updated = await client.update({
|
|
@@ -31,6 +33,7 @@ async function createAssortmentItem(assortmentItem, { skipHydrateRelationships }
|
|
|
31
33
|
id: `${assortmentId}:${itemId}`,
|
|
32
34
|
object: assortmentItem,
|
|
33
35
|
skipHydrateRelationships,
|
|
36
|
+
apiVersion,
|
|
34
37
|
});
|
|
35
38
|
return updated;
|
|
36
39
|
}
|
|
@@ -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");
|
|
6
7
|
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 (0, common_1.promptOnStderr)([
|
|
19
19
|
{
|
|
20
20
|
type: 'confirm',
|
|
21
21
|
name: 'shouldOverwrite',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/entity-compare",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Library for comparing entities.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"author": "",
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@contrail/telemetry": "^2.0.0",
|
|
17
18
|
"@contrail/util": "^1.3.0",
|
|
18
19
|
"es6-promisify": "^6.1.1"
|
|
19
20
|
},
|
|
@@ -25,8 +26,7 @@
|
|
|
25
26
|
"ts-jest": "^29.1.1",
|
|
26
27
|
"tslint": "^5.11.0",
|
|
27
28
|
"tslint-config-prettier": "^1.18.0",
|
|
28
|
-
"typescript": "^5.0.0"
|
|
29
|
-
"@contrail/telemetry": "^2.0.0"
|
|
29
|
+
"typescript": "^5.0.0"
|
|
30
30
|
},
|
|
31
31
|
"jest": {
|
|
32
32
|
"moduleFileExtensions": [
|
|
@@ -41,8 +41,5 @@
|
|
|
41
41
|
},
|
|
42
42
|
"coverageDirectory": "../coverage",
|
|
43
43
|
"testEnvironment": "node"
|
|
44
|
-
},
|
|
45
|
-
"peerDependencies": {
|
|
46
|
-
"@contrail/telemetry": "^2.0.0"
|
|
47
44
|
}
|
|
48
45
|
}
|
|
@@ -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(
|
|
69
|
+
const val = evaluate(util_1.StringUtil.parseVariables(value, row, true));
|
|
70
70
|
return val;
|
|
71
71
|
}
|
|
72
72
|
catch {
|
|
@@ -13,8 +13,16 @@ 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";
|
|
16
18
|
readonly FAMILY_ID_EMPTY: "itemFamilyFederatedId is null or undefined or empty in the CSV file";
|
|
17
19
|
readonly CONFLICTING_IDS: (ids: any) => string;
|
|
18
20
|
};
|
|
19
21
|
export declare const FEDERATED_ID_FETCH_MAX_URL_BYTES = 4000;
|
|
20
22
|
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.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.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
|
};
|
|
@@ -16,8 +16,16 @@ 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',
|
|
19
21
|
FAMILY_ID_EMPTY: 'itemFamilyFederatedId is null or undefined or empty in the CSV file',
|
|
20
22
|
CONFLICTING_IDS: (ids) => `Found conflicting family federated Ids: ${ids}`,
|
|
21
23
|
};
|
|
22
24
|
exports.FEDERATED_ID_FETCH_MAX_URL_BYTES = 4000;
|
|
23
25
|
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,6 +24,10 @@ 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;
|
|
27
31
|
private static validateFederatedIds;
|
|
28
32
|
private static prepareDataWithConditionalValues;
|
|
29
33
|
private static findConditionalColumn;
|
|
@@ -59,9 +59,66 @@ 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);
|
|
62
66
|
this.validateFederatedIds(data, config, errors, generalErrors, csvHeaders);
|
|
63
67
|
return { errors, warnings, generalErrors, generalWarnings };
|
|
64
68
|
}
|
|
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
|
+
}
|
|
65
122
|
static validateFederatedIds(data, config, errors, generalErrors, csvHeaders) {
|
|
66
123
|
const processedData = this.prepareDataWithConditionalValues(data, config);
|
|
67
124
|
this.validateEmptyItemFamilyFederatedIds(processedData, config, errors);
|