@contrail/cli 3.5.4-alpha.103cd15 → 3.5.4-alpha.3c3e1b7
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 +57 -12
- package/dist/api/org-config.d.ts +3 -0
- package/dist/api/org-config.js +28 -0
- package/dist/auth/login.js +28 -18
- package/dist/auth/login.spec.js +77 -0
- package/dist/commands/groups/export.js +1 -13
- package/dist/commands/groups/import.js +2 -15
- package/dist/commands/instance/import.d.ts +14 -0
- package/dist/commands/instance/import.js +27 -5
- package/dist/commands/instance/import.spec.d.ts +1 -0
- package/dist/commands/instance/import.spec.js +57 -0
- package/dist/commands/org-config/export.d.ts +13 -0
- package/dist/commands/org-config/export.js +74 -0
- package/dist/commands/org-config/import.d.ts +12 -0
- package/dist/commands/org-config/import.js +63 -0
- package/dist/commands/types/getAll.js +2 -0
- package/dist/commands/types/loadAll.d.ts +13 -1
- package/dist/commands/types/loadAll.js +41 -4
- package/dist/commands/types/loadAll.spec.d.ts +1 -0
- package/dist/commands/types/loadAll.spec.js +77 -0
- package/dist/commands/types/mergeOptionSets.js +2 -9
- package/dist/commands/types/mergeTypeProperties.js +2 -6
- package/dist/commands/types/parseOptionSetsLocalFiles.js +3 -7
- package/dist/commands/types/uploadTypeOverrides.d.ts +10 -0
- package/dist/commands/types/uploadTypeOverrides.js +19 -8
- package/dist/commands/types/uploadTypeOverrides.spec.d.ts +1 -0
- package/dist/commands/types/uploadTypeOverrides.spec.js +60 -0
- package/dist/commands/users/export.js +1 -13
- package/dist/commands/users/import.js +2 -15
- package/dist/commands/workflow-templates/export.d.ts +2 -3
- package/dist/commands/workflow-templates/export.js +23 -117
- package/dist/helpers/error-helpers.d.ts +9 -0
- package/dist/helpers/error-helpers.js +35 -0
- package/dist/helpers/file-helpers.d.ts +2 -0
- package/dist/helpers/file-helpers.js +25 -1
- package/dist/helpers/projects/helpers.js +2 -6
- package/dist/helpers/types/type-parser.js +9 -15
- package/dist/helpers/workflow-templates/helper.d.ts +0 -1
- package/dist/helpers/workflow-templates/helper.js +3 -28
- package/oclif.manifest.json +122 -15
- package/package.json +4 -1
|
@@ -1,39 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.exportWorkflows = exports.DEFAULT_FILE_LOCATION = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path = tslib_1.__importStar(require("path"));
|
|
6
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
9
7
|
const login_1 = require("../../auth/login");
|
|
10
|
-
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
11
8
|
const core_1 = require("@oclif/core");
|
|
12
9
|
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
13
10
|
const event_workflow_templates_1 = require("../../api/event-workflow-templates");
|
|
14
|
-
const schedules_1 = require("../../api/schedules");
|
|
15
|
-
const apps_1 = require("../../api/apps");
|
|
16
11
|
const helper_1 = require("../../helpers/workflow-templates/helper");
|
|
17
12
|
const basecommand_1 = require("../../basecommand");
|
|
13
|
+
exports.DEFAULT_FILE_LOCATION = 'workflows.yml';
|
|
18
14
|
class ExportWorkflows extends basecommand_1.BaseCommand {
|
|
19
|
-
static description = 'Export all workflows in the org.
|
|
15
|
+
static description = 'Export all workflows in the org.';
|
|
20
16
|
static examples = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'$ contrail workflow-templates export --outFile workflows.yml',
|
|
17
|
+
`$ contrail workflow-templates export
|
|
18
|
+
`,
|
|
24
19
|
];
|
|
25
20
|
static flags = {
|
|
26
21
|
...basecommand_1.BaseCommand.baseFlags,
|
|
27
22
|
outFile: core_1.Flags.string({
|
|
28
23
|
char: 'f',
|
|
29
|
-
description: '
|
|
24
|
+
description: 'The location for the file to be saved',
|
|
30
25
|
required: false,
|
|
31
|
-
|
|
32
|
-
dir: core_1.Flags.string({
|
|
33
|
-
char: 'd',
|
|
34
|
-
description: 'Directory to write per-app workflow files',
|
|
35
|
-
required: false,
|
|
36
|
-
default: '.',
|
|
26
|
+
default: exports.DEFAULT_FILE_LOCATION,
|
|
37
27
|
}),
|
|
38
28
|
overwrite: core_1.Flags.boolean({
|
|
39
29
|
description: 'Replaces existing files if they exist',
|
|
@@ -45,12 +35,7 @@ class ExportWorkflows extends basecommand_1.BaseCommand {
|
|
|
45
35
|
try {
|
|
46
36
|
await (0, login_1.authUser)();
|
|
47
37
|
this.log(`${chalk_1.default.blue.bold('START')} Getting Workflows.`);
|
|
48
|
-
|
|
49
|
-
await exportWorkflowsToFile(this.flags.outFile, this.flags.overwrite);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
await exportWorkflowsByApp(this.flags.dir ?? '.', this.flags.overwrite);
|
|
53
|
-
}
|
|
38
|
+
await exportWorkflows(this.flags.outFile ?? exports.DEFAULT_FILE_LOCATION, this.flags.overwrite);
|
|
54
39
|
this.log(`${chalk_1.default.yellow.bold('WORKFLOWS')} Done`);
|
|
55
40
|
}
|
|
56
41
|
catch (e) {
|
|
@@ -61,101 +46,22 @@ class ExportWorkflows extends basecommand_1.BaseCommand {
|
|
|
61
46
|
}
|
|
62
47
|
}
|
|
63
48
|
exports.default = ExportWorkflows;
|
|
64
|
-
async function
|
|
65
|
-
const
|
|
66
|
-
(0, event_workflow_templates_1.getExistingWorkflowTemplates)(),
|
|
67
|
-
(0, schedules_1.getExistingSchedules)(),
|
|
68
|
-
(0, apps_1.getInstalledApps)(),
|
|
69
|
-
]);
|
|
70
|
-
const appIdToIdentifier = new Map(installedApps
|
|
71
|
-
.filter((appOrg) => appOrg.appId && appOrg.app?.identifier)
|
|
72
|
-
.map((appOrg) => [appOrg.appId, appOrg.app.identifier]));
|
|
73
|
-
const workflowsByApp = new Map();
|
|
74
|
-
const unassigned = [];
|
|
75
|
-
for (const workflow of allWorkflowsInOrg) {
|
|
76
|
-
let appIdentifier = workflow.supportingAppId
|
|
77
|
-
? appIdToIdentifier.get(workflow.supportingAppId)
|
|
78
|
-
: undefined;
|
|
79
|
-
// If no supportingAppId, try to extract app identifier from workflow identifier
|
|
80
|
-
// Format: @{appIdentifier}@{randomId}:{workflowName}
|
|
81
|
-
if (!appIdentifier && workflow.identifier) {
|
|
82
|
-
const match = workflow.identifier.match(/^@([^@]+)@/);
|
|
83
|
-
if (match) {
|
|
84
|
-
// Keep the @ prefix in the appIdentifier
|
|
85
|
-
appIdentifier = `@${match[1]}`;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (appIdentifier) {
|
|
89
|
-
if (!workflowsByApp.has(appIdentifier)) {
|
|
90
|
-
workflowsByApp.set(appIdentifier, []);
|
|
91
|
-
}
|
|
92
|
-
const workflows = workflowsByApp.get(appIdentifier);
|
|
93
|
-
if (workflows) {
|
|
94
|
-
workflows.push(workflow);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
unassigned.push(workflow);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const resolvedDir = path.resolve(process.cwd(), outputDir);
|
|
102
|
-
for (const [appIdentifier, workflows] of workflowsByApp.entries()) {
|
|
103
|
-
const exportObj = { appIdentifier, workflows: [] };
|
|
104
|
-
for (const workflow of workflows) {
|
|
105
|
-
exportObj.workflows.push(await buildExportWorkflow(workflow, allSchedules));
|
|
106
|
-
}
|
|
107
|
-
const safeAppIdentifier = appIdentifier.replace(/[\\/]/g, '-');
|
|
108
|
-
const filePath = path.join(resolvedDir, `workflows-${safeAppIdentifier}.yml`);
|
|
109
|
-
await writeYamlFile(exportObj, filePath, overwrite);
|
|
110
|
-
console.log(`${chalk_1.default.green('EXPORTED')} ${filePath}`);
|
|
111
|
-
}
|
|
112
|
-
if (unassigned.length > 0) {
|
|
113
|
-
const unassignedObj = { workflows: [] };
|
|
114
|
-
for (const workflow of unassigned) {
|
|
115
|
-
unassignedObj.workflows.push(await buildExportWorkflow(workflow, allSchedules));
|
|
116
|
-
}
|
|
117
|
-
const unassignedFilePath = path.join(resolvedDir, 'workflows-unassigned.yml');
|
|
118
|
-
await writeYamlFile(unassignedObj, unassignedFilePath, overwrite);
|
|
119
|
-
console.log(`${chalk_1.default.yellow('EXPORTED')} ${unassignedFilePath} (unassigned workflows)`);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.exportWorkflowsByApp = exportWorkflowsByApp;
|
|
123
|
-
async function exportWorkflowsToFile(fileLocation, overwrite) {
|
|
124
|
-
const [allWorkflowsInOrg, allSchedules] = await Promise.all([
|
|
125
|
-
(0, event_workflow_templates_1.getExistingWorkflowTemplates)(),
|
|
126
|
-
(0, schedules_1.getExistingSchedules)(),
|
|
127
|
-
]);
|
|
49
|
+
async function exportWorkflows(fileLocation, overwrite) {
|
|
50
|
+
const allWorkflowsInOrg = await (0, event_workflow_templates_1.getExistingWorkflowTemplates)();
|
|
128
51
|
const workflowsObj = { workflows: [] };
|
|
129
52
|
for (const workflow of allWorkflowsInOrg) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
'isActive',
|
|
142
|
-
'messageGroup',
|
|
143
|
-
'dynamicMessageGroupId',
|
|
144
|
-
'parallelWorkerCount',
|
|
145
|
-
'workflowDefinition',
|
|
146
|
-
]);
|
|
147
|
-
const schedules = allSchedules.filter((s) => s.ownerReference === `event-workflow-template:${workflow.id}`);
|
|
148
|
-
if (schedules.length > 0) {
|
|
149
|
-
exportWorkflow.crons = schedules.map((s) => ({ name: s.name, cron: s.cron }));
|
|
150
|
-
}
|
|
151
|
-
await (0, helper_1.populateActionIdentifiers)(exportWorkflow);
|
|
152
|
-
(0, helper_1.extractShortActionKeys)(exportWorkflow);
|
|
153
|
-
return exportWorkflow;
|
|
154
|
-
}
|
|
155
|
-
async function writeYamlFile(data, absolutePath, overwrite) {
|
|
156
|
-
if (fs_1.default.existsSync(absolutePath)) {
|
|
157
|
-
await (0, file_helpers_1.safeFileOverwrite)(absolutePath, overwrite);
|
|
53
|
+
const exportWorkflow = lodash_1.default.pick(workflow, [
|
|
54
|
+
'triggerKey',
|
|
55
|
+
'workflowDefinition',
|
|
56
|
+
'name',
|
|
57
|
+
'isActive',
|
|
58
|
+
'identifier',
|
|
59
|
+
'messageGroup',
|
|
60
|
+
'dynamicMessageGroupId',
|
|
61
|
+
]);
|
|
62
|
+
await (0, helper_1.populateActionIdentifiers)(exportWorkflow);
|
|
63
|
+
workflowsObj.workflows.push(exportWorkflow);
|
|
158
64
|
}
|
|
159
|
-
|
|
160
|
-
fs_1.default.writeFileSync(absolutePath, js_yaml_1.default.dump(data), 'utf8');
|
|
65
|
+
await (0, file_helpers_1.saveData)(workflowsObj, fileLocation, overwrite);
|
|
161
66
|
}
|
|
67
|
+
exports.exportWorkflows = exportWorkflows;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a human readable message for an error thrown by the SDK or by the CLI.
|
|
3
|
+
*
|
|
4
|
+
* The SDK's ApiError is constructed with an undefined message and keeps the raw
|
|
5
|
+
* response body in `details` (usually a JSON string such as
|
|
6
|
+
* `{"message":"policy with identifier X not found","statusCode":400}`), so
|
|
7
|
+
* `${error}` only prints "Error". This digs the API message out of `details`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function describeError(error: any): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a human readable message for an error thrown by the SDK or by the CLI.
|
|
6
|
+
*
|
|
7
|
+
* The SDK's ApiError is constructed with an undefined message and keeps the raw
|
|
8
|
+
* response body in `details` (usually a JSON string such as
|
|
9
|
+
* `{"message":"policy with identifier X not found","statusCode":400}`), so
|
|
10
|
+
* `${error}` only prints "Error". This digs the API message out of `details`.
|
|
11
|
+
*/
|
|
12
|
+
function describeError(error) {
|
|
13
|
+
const details = error?.details;
|
|
14
|
+
if (typeof details === 'string' && details.length) {
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(details);
|
|
17
|
+
const message = parsed?.message;
|
|
18
|
+
if (Array.isArray(message)) {
|
|
19
|
+
return message.join(', ');
|
|
20
|
+
}
|
|
21
|
+
if (message) {
|
|
22
|
+
return String(message);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// not JSON, fall through and use the raw body
|
|
27
|
+
}
|
|
28
|
+
return details;
|
|
29
|
+
}
|
|
30
|
+
if (details?.message) {
|
|
31
|
+
return String(details.message);
|
|
32
|
+
}
|
|
33
|
+
return error?.message || String(error);
|
|
34
|
+
}
|
|
35
|
+
exports.describeError = describeError;
|
|
@@ -1,2 +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 saveData(data: any, fileLocation: string, overwrite: boolean): Promise<void>;
|
|
4
|
+
export declare function loadData(fileLocation: string): any;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCSVData = exports.safeFileOverwrite = void 0;
|
|
3
|
+
exports.loadData = exports.saveData = exports.parseCSVData = exports.safeFileOverwrite = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
7
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
6
9
|
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
7
10
|
const sync_1 = require("csv-parse/sync");
|
|
8
11
|
const PASS_FORCE_TO_OVERWRITE = 'Pass --overwrite to overwrite without prompting';
|
|
@@ -34,3 +37,24 @@ function parseCSVData(data) {
|
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
exports.parseCSVData = parseCSVData;
|
|
40
|
+
//saves data as yaml to fileLocation (resolved against the current directory), prompting before overwriting unless overwrite is passed
|
|
41
|
+
async function saveData(data, fileLocation, overwrite) {
|
|
42
|
+
const yamlStr = js_yaml_1.default.dump(data);
|
|
43
|
+
const pathToWrite = path.resolve(fileLocation);
|
|
44
|
+
if (fs_1.default.existsSync(pathToWrite)) {
|
|
45
|
+
await safeFileOverwrite(pathToWrite, overwrite);
|
|
46
|
+
}
|
|
47
|
+
fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
|
|
48
|
+
}
|
|
49
|
+
exports.saveData = saveData;
|
|
50
|
+
//loads yaml data from fileLocation (resolved against the current directory)
|
|
51
|
+
function loadData(fileLocation) {
|
|
52
|
+
const pathToRead = path.resolve(fileLocation);
|
|
53
|
+
try {
|
|
54
|
+
return js_yaml_1.default.load(fs_1.default.readFileSync(pathToRead, 'utf8'));
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.loadData = loadData;
|
|
@@ -8,6 +8,7 @@ const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
|
8
8
|
const sdk_1 = require("@contrail/sdk");
|
|
9
9
|
const util_1 = require("@contrail/util");
|
|
10
10
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
11
|
+
const file_helpers_1 = require("../file-helpers");
|
|
11
12
|
function getProjectFile(fileName) {
|
|
12
13
|
const CURRENT_DIR = process.cwd();
|
|
13
14
|
try {
|
|
@@ -42,7 +43,7 @@ async function exportProject(name) {
|
|
|
42
43
|
const allAssortments = [];
|
|
43
44
|
await getAssortmentsAndSubFolders(workspace.id, projectConfiguration.assortments, projectConfiguration.subFolders, allAssortments);
|
|
44
45
|
await convertRelationshipsInFolders(projectConfiguration, allAssortments);
|
|
45
|
-
saveData({ projectConfiguration: projectConfiguration }, name);
|
|
46
|
+
await (0, file_helpers_1.saveData)({ projectConfiguration: projectConfiguration }, `${name}-export.yml`, true);
|
|
46
47
|
}
|
|
47
48
|
exports.exportProject = exportProject;
|
|
48
49
|
async function getAssortmentsAndSubFolders(parentId, assortments, subFolders, allAssortments) {
|
|
@@ -160,8 +161,3 @@ function deleteNonUserKeys(assortment) {
|
|
|
160
161
|
delete assortment.updatedOn;
|
|
161
162
|
delete assortment.workspaceId;
|
|
162
163
|
}
|
|
163
|
-
function saveData(data, name) {
|
|
164
|
-
const yamlStr = js_yaml_1.default.dump(data);
|
|
165
|
-
const CURRENT_DIR = process.cwd();
|
|
166
|
-
fs_1.default.writeFileSync(path.join(CURRENT_DIR, `${name}-export.yml`), yamlStr, 'utf8');
|
|
167
|
-
}
|
|
@@ -4,12 +4,11 @@ exports.parseTypesFromFiles = exports.parseTypesFromTemplateAndDataFromLocalFile
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
6
|
const types_1 = require("@contrail/types");
|
|
7
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
7
|
const csvToJson = tslib_1.__importStar(require("csvtojson"));
|
|
9
8
|
const login_1 = require("../../auth/login");
|
|
10
9
|
const csv_parser_1 = require("../../helpers/types/csv-parser");
|
|
11
10
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
12
|
-
const
|
|
11
|
+
const file_helpers_1 = require("../file-helpers");
|
|
13
12
|
async function loadDataFromLocalCSV(fileName) {
|
|
14
13
|
const CURRENT_DIR = process.cwd();
|
|
15
14
|
try {
|
|
@@ -37,8 +36,8 @@ async function parseTypesFromLocalFiles(fileLocations) {
|
|
|
37
36
|
}
|
|
38
37
|
logger_1.default.info(`CSV imports were successful. ${csvJSONData?.length} total rows found.`);
|
|
39
38
|
const suggestions = (0, types_1.GetSuggestedTypes)(csvJSONData);
|
|
40
|
-
saveData(suggestions.OptionSets, 'parsed_optionSets.yml');
|
|
41
|
-
saveData({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml');
|
|
39
|
+
await (0, file_helpers_1.saveData)(suggestions.OptionSets, 'parsed_optionSets.yml', true);
|
|
40
|
+
await (0, file_helpers_1.saveData)({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml', true);
|
|
42
41
|
}
|
|
43
42
|
exports.parseTypesFromLocalFiles = parseTypesFromLocalFiles;
|
|
44
43
|
async function parseTypesFromTemplateFromLocalFiles(templateFileLocation, dataFileLocation) {
|
|
@@ -57,8 +56,8 @@ async function parseTypesFromTemplateFromLocalFiles(templateFileLocation, dataFi
|
|
|
57
56
|
throw e;
|
|
58
57
|
}
|
|
59
58
|
const types = (0, types_1.GetTypesFromTemplate)(templateCSVData, dataCSVData);
|
|
60
|
-
saveData(types.OptionSets, 'parsed_optionSets.yml');
|
|
61
|
-
saveData({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml');
|
|
59
|
+
await (0, file_helpers_1.saveData)(types.OptionSets, 'parsed_optionSets.yml', true);
|
|
60
|
+
await (0, file_helpers_1.saveData)({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml', true);
|
|
62
61
|
}
|
|
63
62
|
exports.parseTypesFromTemplateFromLocalFiles = parseTypesFromTemplateFromLocalFiles;
|
|
64
63
|
async function parseTypesFromTemplateAndDataFromLocalFiles(templateFileLocation, dataFileLocations) {
|
|
@@ -86,8 +85,8 @@ async function parseTypesFromTemplateAndDataFromLocalFiles(templateFileLocation,
|
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
const types = (0, types_1.GetTypesFromTemplateWithOptionSetsFromData)(templateCSVData, dataCSVData);
|
|
89
|
-
saveData(types.OptionSets, 'parsed_optionSets.yml');
|
|
90
|
-
saveData({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml');
|
|
88
|
+
await (0, file_helpers_1.saveData)(types.OptionSets, 'parsed_optionSets.yml', true);
|
|
89
|
+
await (0, file_helpers_1.saveData)({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml', true);
|
|
91
90
|
}
|
|
92
91
|
exports.parseTypesFromTemplateAndDataFromLocalFiles = parseTypesFromTemplateAndDataFromLocalFiles;
|
|
93
92
|
async function parseTypesFromFiles(fileIds) {
|
|
@@ -108,12 +107,7 @@ async function parseTypesFromFiles(fileIds) {
|
|
|
108
107
|
}
|
|
109
108
|
logger_1.default.info(`CSV downloads were successful. ${csvJSONData?.length} total rows found.`);
|
|
110
109
|
const suggestions = (0, types_1.GetSuggestedTypes)(csvJSONData);
|
|
111
|
-
saveData(suggestions.OptionSets, 'parsed_optionSets.yml');
|
|
112
|
-
saveData({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml');
|
|
110
|
+
await (0, file_helpers_1.saveData)(suggestions.OptionSets, 'parsed_optionSets.yml', true);
|
|
111
|
+
await (0, file_helpers_1.saveData)({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml', true);
|
|
113
112
|
}
|
|
114
113
|
exports.parseTypesFromFiles = parseTypesFromFiles;
|
|
115
|
-
function saveData(data, name) {
|
|
116
|
-
const yamlStr = js_yaml_1.default.dump(data);
|
|
117
|
-
const CURRENT_DIR = process.cwd();
|
|
118
|
-
fs_1.default.writeFileSync(path.resolve(path.join(CURRENT_DIR, name, yamlStr)), 'utf8');
|
|
119
|
-
}
|
|
@@ -18,4 +18,3 @@ export declare class WorkflowTemplateDeployer {
|
|
|
18
18
|
export declare function deleteWorkflowTemplates(): Promise<void>;
|
|
19
19
|
export declare function localDeployWorkflowTemplate(saveFileLocation: string): Promise<void>;
|
|
20
20
|
export declare function populateActionIdentifiers(workflowTemplate: WorkflowTemplate): Promise<void>;
|
|
21
|
-
export declare function extractShortActionKeys(workflowTemplate: WorkflowTemplate): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.populateActionIdentifiers = exports.localDeployWorkflowTemplate = exports.deleteWorkflowTemplates = exports.WorkflowTemplateDeployer = exports.getActionByIdentifier = exports.getWorkflowTemplateIdentifier = exports.LocalWorkflowTemplateDeployer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const util_1 = require("@contrail/util");
|
|
6
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
@@ -44,8 +44,6 @@ class LocalWorkflowTemplateDeployer {
|
|
|
44
44
|
isActive: workflowTemplate.isActive,
|
|
45
45
|
supportingAppId: workflowTemplate.supportingAppId,
|
|
46
46
|
messageGroupId: workflowTemplate.messageGroupId,
|
|
47
|
-
messageGroup: workflowTemplate.messageGroup,
|
|
48
|
-
dynamicMessageGroupId: workflowTemplate.dynamicMessageGroupId,
|
|
49
47
|
parallelWorkerCount: workflowTemplate.parallelWorkerCount,
|
|
50
48
|
};
|
|
51
49
|
const newWorkflowTemplate = await (0, event_workflow_templates_1.createWorkflowTemplate)(newObject);
|
|
@@ -57,11 +55,8 @@ class LocalWorkflowTemplateDeployer {
|
|
|
57
55
|
}
|
|
58
56
|
async populateActionIds(workflowTemplate, workflowKey, appIdentifier) {
|
|
59
57
|
const installedApps = await (0, apps_1.getInstalledApps)();
|
|
60
|
-
const appOrg = installedApps.find((x) => x.app
|
|
58
|
+
const appOrg = installedApps.find((x) => x.app.identifier === appIdentifier);
|
|
61
59
|
logger_1.default.info('workflow template:', JSON.stringify(workflowTemplate, null, 2));
|
|
62
|
-
if (!appOrg) {
|
|
63
|
-
throw new Error(`Could not find installed app with identifier "${appIdentifier}". Make sure the app is installed in this org before importing workflows.`);
|
|
64
|
-
}
|
|
65
60
|
if (!workflowTemplate?.workflowDefinition?.paths) {
|
|
66
61
|
return;
|
|
67
62
|
}
|
|
@@ -91,7 +86,7 @@ class LocalWorkflowTemplateDeployer {
|
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
async createWorkflowSchedule(workflowTemplate, workflowId) {
|
|
94
|
-
if (!workflowTemplate?.crons?.length) {
|
|
89
|
+
if (!workflowTemplate?.crons?.length || !workflowTemplate.id) {
|
|
95
90
|
return;
|
|
96
91
|
}
|
|
97
92
|
const crons = [];
|
|
@@ -163,8 +158,6 @@ class LocalWorkflowTemplateDeployer {
|
|
|
163
158
|
triggerKey: workflowTemplate.triggerKey,
|
|
164
159
|
builtIn: workflowTemplate.builtIn,
|
|
165
160
|
workflowDefinition: workflowTemplate.workflowDefinition,
|
|
166
|
-
messageGroupId: workflowTemplate.messageGroupId ?? existingWorkflowTemplate.messageGroupId,
|
|
167
|
-
messageGroup: workflowTemplate.messageGroup ?? existingWorkflowTemplate.messageGroup,
|
|
168
161
|
dynamicMessageGroupId: workflowTemplate.dynamicMessageGroupId ?? existingWorkflowTemplate.dynamicMessageGroupId,
|
|
169
162
|
parallelWorkerCount: workflowTemplate.parallelWorkerCount ?? existingWorkflowTemplate.parallelWorkerCount,
|
|
170
163
|
});
|
|
@@ -290,21 +283,3 @@ async function populateActionIdentifiers(workflowTemplate) {
|
|
|
290
283
|
}
|
|
291
284
|
}
|
|
292
285
|
exports.populateActionIdentifiers = populateActionIdentifiers;
|
|
293
|
-
function extractShortActionKeys(workflowTemplate) {
|
|
294
|
-
if (!workflowTemplate?.workflowDefinition?.paths) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
for (const wfPath of workflowTemplate.workflowDefinition.paths) {
|
|
298
|
-
if (!wfPath?.actionDefinitionConfigs) {
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
for (const actionConfig of wfPath.actionDefinitionConfigs) {
|
|
302
|
-
if (actionConfig.action?.includes(':')) {
|
|
303
|
-
// Full identifier format: "app-id@version:action-name" -> "action-name"
|
|
304
|
-
actionConfig.action = actionConfig.action.split(':').pop();
|
|
305
|
-
}
|
|
306
|
-
delete actionConfig.identifier;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
exports.extractShortActionKeys = extractShortActionKeys;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.5.4-alpha.
|
|
2
|
+
"version": "3.5.4-alpha.3c3e1b7",
|
|
3
3
|
"commands": {
|
|
4
4
|
"app:create": {
|
|
5
5
|
"id": "app:create",
|
|
@@ -1239,6 +1239,116 @@
|
|
|
1239
1239
|
}
|
|
1240
1240
|
}
|
|
1241
1241
|
},
|
|
1242
|
+
"org-config:export": {
|
|
1243
|
+
"id": "org-config:export",
|
|
1244
|
+
"description": "Export the org config for your Org",
|
|
1245
|
+
"strict": true,
|
|
1246
|
+
"pluginName": "@contrail/cli",
|
|
1247
|
+
"pluginAlias": "@contrail/cli",
|
|
1248
|
+
"pluginType": "core",
|
|
1249
|
+
"aliases": [],
|
|
1250
|
+
"examples": [
|
|
1251
|
+
"$ contrail org-config export\n"
|
|
1252
|
+
],
|
|
1253
|
+
"flags": {
|
|
1254
|
+
"logLevel": {
|
|
1255
|
+
"name": "logLevel",
|
|
1256
|
+
"type": "option",
|
|
1257
|
+
"char": "l",
|
|
1258
|
+
"description": "The Log Level",
|
|
1259
|
+
"required": false,
|
|
1260
|
+
"multiple": false,
|
|
1261
|
+
"options": [
|
|
1262
|
+
"error",
|
|
1263
|
+
"warn",
|
|
1264
|
+
"info",
|
|
1265
|
+
"debug"
|
|
1266
|
+
]
|
|
1267
|
+
},
|
|
1268
|
+
"alwaysConfirmEnv": {
|
|
1269
|
+
"name": "alwaysConfirmEnv",
|
|
1270
|
+
"type": "option",
|
|
1271
|
+
"char": "e",
|
|
1272
|
+
"description": "The Environment variables",
|
|
1273
|
+
"required": false,
|
|
1274
|
+
"multiple": false,
|
|
1275
|
+
"options": [
|
|
1276
|
+
"true",
|
|
1277
|
+
"false"
|
|
1278
|
+
],
|
|
1279
|
+
"default": "true"
|
|
1280
|
+
},
|
|
1281
|
+
"outDir": {
|
|
1282
|
+
"name": "outDir",
|
|
1283
|
+
"type": "option",
|
|
1284
|
+
"char": "d",
|
|
1285
|
+
"description": "The directory to which to export the org config data. Defaults to the current directory",
|
|
1286
|
+
"required": false,
|
|
1287
|
+
"multiple": false,
|
|
1288
|
+
"default": "."
|
|
1289
|
+
},
|
|
1290
|
+
"overwrite": {
|
|
1291
|
+
"name": "overwrite",
|
|
1292
|
+
"type": "boolean",
|
|
1293
|
+
"char": "f",
|
|
1294
|
+
"description": "Replaces any existing export files in outDir",
|
|
1295
|
+
"required": false,
|
|
1296
|
+
"allowNo": false
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
"args": {}
|
|
1300
|
+
},
|
|
1301
|
+
"org-config:import": {
|
|
1302
|
+
"id": "org-config:import",
|
|
1303
|
+
"description": "Upload an extracted org config",
|
|
1304
|
+
"strict": true,
|
|
1305
|
+
"pluginName": "@contrail/cli",
|
|
1306
|
+
"pluginAlias": "@contrail/cli",
|
|
1307
|
+
"pluginType": "core",
|
|
1308
|
+
"aliases": [],
|
|
1309
|
+
"examples": [
|
|
1310
|
+
"$ contrail org-config import\n"
|
|
1311
|
+
],
|
|
1312
|
+
"flags": {
|
|
1313
|
+
"logLevel": {
|
|
1314
|
+
"name": "logLevel",
|
|
1315
|
+
"type": "option",
|
|
1316
|
+
"char": "l",
|
|
1317
|
+
"description": "The Log Level",
|
|
1318
|
+
"required": false,
|
|
1319
|
+
"multiple": false,
|
|
1320
|
+
"options": [
|
|
1321
|
+
"error",
|
|
1322
|
+
"warn",
|
|
1323
|
+
"info",
|
|
1324
|
+
"debug"
|
|
1325
|
+
]
|
|
1326
|
+
},
|
|
1327
|
+
"alwaysConfirmEnv": {
|
|
1328
|
+
"name": "alwaysConfirmEnv",
|
|
1329
|
+
"type": "option",
|
|
1330
|
+
"char": "e",
|
|
1331
|
+
"description": "The Environment variables",
|
|
1332
|
+
"required": false,
|
|
1333
|
+
"multiple": false,
|
|
1334
|
+
"options": [
|
|
1335
|
+
"true",
|
|
1336
|
+
"false"
|
|
1337
|
+
],
|
|
1338
|
+
"default": "true"
|
|
1339
|
+
},
|
|
1340
|
+
"dir": {
|
|
1341
|
+
"name": "dir",
|
|
1342
|
+
"type": "option",
|
|
1343
|
+
"char": "d",
|
|
1344
|
+
"description": "The directory from which to import the org config data. Defaults to the current directory. The org config data will be loaded from $dir/org-config.yml",
|
|
1345
|
+
"required": false,
|
|
1346
|
+
"multiple": false,
|
|
1347
|
+
"default": "."
|
|
1348
|
+
}
|
|
1349
|
+
},
|
|
1350
|
+
"args": {}
|
|
1351
|
+
},
|
|
1242
1352
|
"projects:export": {
|
|
1243
1353
|
"id": "projects:export",
|
|
1244
1354
|
"description": "Export a project.",
|
|
@@ -1593,6 +1703,13 @@
|
|
|
1593
1703
|
"required": false,
|
|
1594
1704
|
"multiple": false,
|
|
1595
1705
|
"default": "."
|
|
1706
|
+
},
|
|
1707
|
+
"orgConfig": {
|
|
1708
|
+
"name": "orgConfig",
|
|
1709
|
+
"type": "boolean",
|
|
1710
|
+
"description": "Also load org config data from this directory. If not specified, you will be prompted.",
|
|
1711
|
+
"required": false,
|
|
1712
|
+
"allowNo": true
|
|
1596
1713
|
}
|
|
1597
1714
|
},
|
|
1598
1715
|
"args": {}
|
|
@@ -2956,16 +3073,14 @@
|
|
|
2956
3073
|
},
|
|
2957
3074
|
"workflow-templates:export": {
|
|
2958
3075
|
"id": "workflow-templates:export",
|
|
2959
|
-
"description": "Export all workflows in the org.
|
|
3076
|
+
"description": "Export all workflows in the org.",
|
|
2960
3077
|
"strict": true,
|
|
2961
3078
|
"pluginName": "@contrail/cli",
|
|
2962
3079
|
"pluginAlias": "@contrail/cli",
|
|
2963
3080
|
"pluginType": "core",
|
|
2964
3081
|
"aliases": [],
|
|
2965
3082
|
"examples": [
|
|
2966
|
-
"$ contrail workflow-templates export"
|
|
2967
|
-
"$ contrail workflow-templates export --dir ./workflows",
|
|
2968
|
-
"$ contrail workflow-templates export --outFile workflows.yml"
|
|
3083
|
+
"$ contrail workflow-templates export\n"
|
|
2969
3084
|
],
|
|
2970
3085
|
"flags": {
|
|
2971
3086
|
"logLevel": {
|
|
@@ -2999,18 +3114,10 @@
|
|
|
2999
3114
|
"name": "outFile",
|
|
3000
3115
|
"type": "option",
|
|
3001
3116
|
"char": "f",
|
|
3002
|
-
"description": "
|
|
3003
|
-
"required": false,
|
|
3004
|
-
"multiple": false
|
|
3005
|
-
},
|
|
3006
|
-
"dir": {
|
|
3007
|
-
"name": "dir",
|
|
3008
|
-
"type": "option",
|
|
3009
|
-
"char": "d",
|
|
3010
|
-
"description": "Directory to write per-app workflow files",
|
|
3117
|
+
"description": "The location for the file to be saved",
|
|
3011
3118
|
"required": false,
|
|
3012
3119
|
"multiple": false,
|
|
3013
|
-
"default": "."
|
|
3120
|
+
"default": "workflows.yml"
|
|
3014
3121
|
},
|
|
3015
3122
|
"overwrite": {
|
|
3016
3123
|
"name": "overwrite",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/cli",
|
|
3
|
-
"version": "3.5.4-alpha.
|
|
3
|
+
"version": "3.5.4-alpha.3c3e1b7",
|
|
4
4
|
"description": "VibeIQ's Contrail Platform CLI.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"contrail-cli": "./bin/run",
|
|
@@ -113,6 +113,9 @@
|
|
|
113
113
|
"groups": {
|
|
114
114
|
"description": "Export and import user groups"
|
|
115
115
|
},
|
|
116
|
+
"org-config": {
|
|
117
|
+
"description": "Export and import org-level configuration"
|
|
118
|
+
},
|
|
116
119
|
"webhooks": {
|
|
117
120
|
"description": "Manage VibeIQ webhooks"
|
|
118
121
|
},
|