@contrail/cli 3.6.0-alpha-8-alpha.85a73d5 → 3.6.0-alpha.a5acc88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +115 -52
- package/dist/auth/login.spec.js +100 -0
- package/dist/auth/sso.d.ts +36 -0
- package/dist/auth/sso.js +174 -0
- package/dist/auth/sso.spec.js +148 -0
- package/dist/basecommand.js +2 -2
- 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.d.ts +0 -1
- 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/sso.spec.d.ts} +0 -0
|
@@ -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);
|