@contrail/cli 3.6.0-alpha-8-alpha.85a73d5 → 3.6.0-alpha.5ecc188
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 +26 -181
- package/dist/api/types.d.ts +0 -35
- package/dist/api/types.js +1 -49
- package/dist/auth/login.d.ts +4 -0
- package/dist/auth/login.js +136 -56
- package/dist/auth/login.spec.js +117 -3
- package/dist/auth/sign-in-error.d.ts +7 -0
- package/dist/auth/sign-in-error.js +24 -0
- package/dist/auth/sign-in-error.spec.js +22 -0
- package/dist/auth/sso.d.ts +38 -0
- package/dist/auth/sso.js +184 -0
- package/dist/auth/sso.spec.js +191 -0
- package/dist/basecommand.d.ts +3 -0
- package/dist/basecommand.js +10 -3
- package/dist/commands/app/getApiKey.js +2 -2
- package/dist/commands/login.d.ts +12 -0
- package/dist/commands/login.js +25 -0
- package/dist/common.d.ts +1 -4
- package/dist/common.js +1 -18
- package/dist/helpers/config/config.d.ts +3 -3
- package/dist/helpers/config/config.js +3 -3
- package/dist/helpers/file-helpers.d.ts +0 -1
- package/dist/helpers/file-helpers.js +3 -20
- package/dist/logger.js +1 -4
- 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/sdk/.github/workflows/publish-to-npm.yml +4 -1
- package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
- package/node_modules/@contrail/sdk/lib/config/config.d.ts +0 -3
- package/node_modules/@contrail/sdk/lib/config/config.js +7 -13
- package/node_modules/@contrail/sdk/lib/core/request.js +2 -6
- package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +0 -2
- package/node_modules/@contrail/sdk/lib/entities/entities.client.js +1 -3
- package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +0 -1
- package/node_modules/@contrail/sdk/lib/index.d.ts +0 -1
- package/node_modules/@contrail/sdk/lib/index.js +0 -1
- package/node_modules/@contrail/sdk/package.json +1 -1
- package/oclif.manifest.json +50 -449
- package/package.json +12 -5
- package/dist/commands/entities/create.d.ts +0 -50
- package/dist/commands/entities/create.js +0 -633
- package/dist/commands/entities/create.spec.js +0 -583
- package/dist/commands/entities/delete.d.ts +0 -20
- package/dist/commands/entities/delete.js +0 -140
- package/dist/commands/entities/get.d.ts +0 -25
- package/dist/commands/entities/get.js +0 -269
- package/dist/commands/entities/grammar.spec.js +0 -79
- package/dist/commands/entities/output.spec.d.ts +0 -1
- package/dist/commands/entities/output.spec.js +0 -72
- package/dist/commands/entities/update.d.ts +0 -32
- package/dist/commands/entities/update.js +0 -161
- package/dist/helpers/entities/assortment-items.d.ts +0 -11
- package/dist/helpers/entities/assortment-items.js +0 -76
- package/dist/helpers/entities/batchFetch.d.ts +0 -8
- package/dist/helpers/entities/batchFetch.js +0 -49
- package/dist/helpers/entities/index.d.ts +0 -3
- package/dist/helpers/entities/index.js +0 -6
- package/dist/helpers/entities/items.d.ts +0 -6
- package/dist/helpers/entities/items.js +0 -56
- package/dist/helpers/entities/items.spec.d.ts +0 -1
- package/dist/helpers/entities/items.spec.js +0 -19
- package/dist/helpers/entities/project-items.d.ts +0 -2
- package/dist/helpers/entities/project-items.js +0 -44
- package/dist/helpers/propertySpecifications/dateRanges.d.ts +0 -34
- package/dist/helpers/propertySpecifications/dateRanges.js +0 -83
- package/dist/helpers/propertySpecifications/dateRanges.spec.d.ts +0 -1
- package/dist/helpers/propertySpecifications/dateRanges.spec.js +0 -91
- package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +0 -39
- package/dist/helpers/propertySpecifications/propertySpecifications.js +0 -102
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +0 -1
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +0 -387
- package/dist/logger.spec.d.ts +0 -1
- package/dist/logger.spec.js +0 -12
- package/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +0 -34
- package/node_modules/@contrail/sdk/lib/image-search/image-search.js +0 -42
- package/node_modules/@contrail/sdk/lib/image-search/index.d.ts +0 -1
- package/node_modules/@contrail/sdk/lib/image-search/index.js +0 -17
- package/node_modules/@contrail/sdk/scripts/replicate-bug.js +0 -69
- /package/dist/{commands/entities/create.spec.d.ts → auth/sign-in-error.spec.d.ts} +0 -0
- /package/dist/{commands/entities/grammar.spec.d.ts → auth/sso.spec.d.ts} +0 -0
package/dist/basecommand.js
CHANGED
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BaseCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
|
-
const common_1 = require("./common");
|
|
7
6
|
const logger_1 = tslib_1.__importDefault(require("./logger"));
|
|
7
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
8
|
const config_1 = require("./helpers/config/config");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
10
10
|
const login_1 = require("./auth/login");
|
|
11
|
+
const sign_in_error_1 = require("./auth/sign-in-error");
|
|
11
12
|
const baseFlags_1 = require("./baseFlags");
|
|
12
13
|
class BaseCommand extends core_1.Command {
|
|
13
14
|
static description = 'Global Flags';
|
|
@@ -48,11 +49,17 @@ class BaseCommand extends core_1.Command {
|
|
|
48
49
|
logger_1.default.level = config.logLevel;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
52
|
+
async catch(error) {
|
|
53
|
+
if (error instanceof sign_in_error_1.SignInError) {
|
|
54
|
+
this.error((0, sign_in_error_1.formatErrorForTerminal)(error), { exit: 1 });
|
|
55
|
+
}
|
|
56
|
+
return super.catch(error);
|
|
57
|
+
}
|
|
51
58
|
async confirmEnv() {
|
|
52
59
|
let config = await (0, config_1.getConfig)();
|
|
53
60
|
if ((0, lodash_1.keys)(config).length === 0) {
|
|
54
61
|
await (0, login_1.authUser)().catch((e) => {
|
|
55
|
-
console.log(`Error: ${e
|
|
62
|
+
console.log(`Error: ${(0, sign_in_error_1.formatErrorForTerminal)(e)}\n\nCheck if you are using the correct environment configuration and credentials.`);
|
|
56
63
|
this.exit(1);
|
|
57
64
|
});
|
|
58
65
|
config = await (0, config_1.getConfig)();
|
|
@@ -73,7 +80,7 @@ class BaseCommand extends core_1.Command {
|
|
|
73
80
|
choices: ['yes', 'no'],
|
|
74
81
|
default: 'no',
|
|
75
82
|
});
|
|
76
|
-
const { confirm } = await
|
|
83
|
+
const { confirm } = await inquirer_1.default.prompt(questions);
|
|
77
84
|
if (confirm === 'no') {
|
|
78
85
|
logger_1.default.info('Please use `contrail config use` command to choose the configuration or `contrail config set --environment=prod` to set different environment.');
|
|
79
86
|
this.exit(1);
|
|
@@ -35,7 +35,7 @@ class GetAPIKeyApp extends basecommand_1.BaseCommand {
|
|
|
35
35
|
},
|
|
36
36
|
];
|
|
37
37
|
const answers = await inquirer_1.default.prompt(questions);
|
|
38
|
-
|
|
38
|
+
logger_1.default.info(`App API key: (app:${answers.appApiKey})`);
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
41
|
const appFound = installedApps.find((x) => x.app.identifier === this.flags.appIdentifier);
|
|
@@ -43,7 +43,7 @@ class GetAPIKeyApp extends basecommand_1.BaseCommand {
|
|
|
43
43
|
logger_1.default.info('You do not have such an app installed');
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
logger_1.default.info(`App API key: (app:${appFound.apiKey.apiKey})`);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class Login extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
skipConfirmEnv: boolean;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
browser: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const basecommand_1 = require("../basecommand");
|
|
6
|
+
const login_1 = require("../auth/login");
|
|
7
|
+
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
8
|
+
class Login extends basecommand_1.BaseCommand {
|
|
9
|
+
static description = 'Sign in to VibeIQ with SSO or your email and password';
|
|
10
|
+
skipConfirmEnv = true;
|
|
11
|
+
static examples = ['$ contrail login', '$ contrail login --no-browser'];
|
|
12
|
+
static flags = {
|
|
13
|
+
...basecommand_1.BaseCommand.baseFlags,
|
|
14
|
+
browser: core_1.Flags.boolean({
|
|
15
|
+
description: 'Open a browser for SSO. Use --no-browser to paste a sign-in code instead.',
|
|
16
|
+
default: true,
|
|
17
|
+
allowNo: true,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
const context = await (0, login_1.signIn)({ shouldOpenBrowser: this.flags.browser });
|
|
22
|
+
logger_1.default.info(`Signed in to ${context.orgSlug}.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = Login;
|
package/dist/common.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
export declare function getSeparatorByPlatform(): string;
|
|
3
3
|
export declare function delay(ms: number): Promise<NodeJS.Timeout>;
|
|
4
|
-
export declare function removeSlash(string:
|
|
5
|
-
export declare function routeConsoleLogToStderr(): void;
|
|
6
|
-
export declare function sdkErrorMessage(reason: any): string;
|
|
7
|
-
export declare const promptOnStderr: any;
|
|
4
|
+
export declare function removeSlash(string: any): string;
|
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 });
|
|
@@ -9,10 +9,10 @@ export declare function readVibeIQConfig(): Promise<any>;
|
|
|
9
9
|
export declare function writeVibeIQConfig(config: any): Promise<void>;
|
|
10
10
|
export declare function storeVibeIQConfig(incomingConfig: any): Promise<void>;
|
|
11
11
|
export declare function createConfig(fileName: any): Promise<void>;
|
|
12
|
-
export declare function writeConfig(config: any, configName?: string
|
|
12
|
+
export declare function writeConfig(config: any, configName?: string): Promise<void>;
|
|
13
13
|
export declare function getConfig(): Promise<any>;
|
|
14
|
-
export declare function storeConfig(incomingConfig: any, configName?: string
|
|
14
|
+
export declare function storeConfig(incomingConfig: any, configName?: string, merge?: boolean): Promise<void>;
|
|
15
15
|
export declare function getConfigFiles(): Promise<any>;
|
|
16
16
|
export declare function getConfigContent(fileName: string): Promise<any>;
|
|
17
|
-
export declare function validateEnvironments(envName?:
|
|
17
|
+
export declare function validateEnvironments(envName?: any): Promise<any>;
|
|
18
18
|
export declare function checkTelemetry(cliVersion: string): Promise<void>;
|
|
@@ -46,13 +46,13 @@ exports.initializeVibeIQConfig = initializeVibeIQConfig;
|
|
|
46
46
|
async function readVibeIQConfig() {
|
|
47
47
|
let fileContent;
|
|
48
48
|
try {
|
|
49
|
-
fileContent = (await node_fs_1.promises.readFile(configFileLocation)).toString();
|
|
49
|
+
fileContent = await (await node_fs_1.promises.readFile(configFileLocation)).toString();
|
|
50
50
|
}
|
|
51
51
|
catch {
|
|
52
52
|
logger_1.default.debug(`failed to open config file (${configFileLocation}) for reading.`);
|
|
53
53
|
logger_1.default.debug('trying to initialize config file');
|
|
54
54
|
await initializeVibeIQConfig();
|
|
55
|
-
fileContent = (await node_fs_1.promises.readFile(configFileLocation)).toString();
|
|
55
|
+
fileContent = await (await node_fs_1.promises.readFile(configFileLocation)).toString();
|
|
56
56
|
}
|
|
57
57
|
try {
|
|
58
58
|
return JSON.parse(fileContent);
|
|
@@ -165,7 +165,7 @@ async function getConfigContent(fileName) {
|
|
|
165
165
|
return JSON.parse(fileContent);
|
|
166
166
|
}
|
|
167
167
|
catch (error) {
|
|
168
|
-
logger_1.default.error(`Failed to open/parse config file (${fileName}) might be malformed or not found
|
|
168
|
+
logger_1.default.error(`Failed to open/parse config file (${fileName}) might be malformed or not found.`);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
exports.getConfigContent = getConfigContent;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare function safeFileOverwrite(fileLocation: string, overwrite: boolean): Promise<boolean>;
|
|
2
2
|
export declare function parseCSVData(data: string): any;
|
|
3
|
-
export declare function parseFileAsJsonArray(fileName: string): any[];
|
|
4
3
|
export declare function saveData(data: any, fileLocation: string, overwrite: boolean): Promise<void>;
|
|
5
4
|
export declare function loadData(fileLocation: string): any;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadData = exports.saveData = exports.
|
|
3
|
+
exports.loadData = exports.saveData = 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',
|
|
@@ -37,23 +37,6 @@ function parseCSVData(data) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
exports.parseCSVData = parseCSVData;
|
|
40
|
-
function parseFileAsJsonArray(fileName) {
|
|
41
|
-
if (!fs_1.default.existsSync(fileName)) {
|
|
42
|
-
throw new Error(`File not found: ${fileName}`);
|
|
43
|
-
}
|
|
44
|
-
const fileContent = fs_1.default.readFileSync(fileName, 'utf-8');
|
|
45
|
-
try {
|
|
46
|
-
const jsonArray = JSON.parse(fileContent);
|
|
47
|
-
if (!Array.isArray(jsonArray)) {
|
|
48
|
-
throw new Error(`File content is not a valid JSON array: ${fileName}`);
|
|
49
|
-
}
|
|
50
|
-
return jsonArray;
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
throw new Error(`Error parsing JSON from file ${fileName}: ${error.message}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.parseFileAsJsonArray = parseFileAsJsonArray;
|
|
57
40
|
//saves data as yaml to fileLocation (resolved against the current directory), prompting before overwriting unless overwrite is passed
|
|
58
41
|
async function saveData(data, fileLocation, overwrite) {
|
|
59
42
|
const yamlStr = js_yaml_1.default.dump(data);
|
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.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);
|