@contrail/cli 2.1.12 → 2.1.15

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 CHANGED
@@ -15,7 +15,7 @@ $ npm install -g @contrail/cli
15
15
  $ contrail COMMAND
16
16
  running command...
17
17
  $ contrail (--version)
18
- @contrail/cli/2.1.12 darwin-arm64 node-v18.13.0
18
+ @contrail/cli/2.1.15 darwin-arm64 node-v18.13.0
19
19
  $ contrail --help [COMMAND]
20
20
  USAGE
21
21
  $ contrail COMMAND
@@ -88,6 +88,7 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
88
88
  * [`contrail workflow-template-definitions install`](#contrail-workflow-template-definitions-install)
89
89
  * [`contrail workflow-template-definitions list`](#contrail-workflow-template-definitions-list)
90
90
  * [`contrail workflow-templates delete`](#contrail-workflow-templates-delete)
91
+ * [`contrail workflow-templates export`](#contrail-workflow-templates-export)
91
92
  * [`contrail workflow-templates list`](#contrail-workflow-templates-list)
92
93
  * [`contrail workflow-templates load FILELOCATION`](#contrail-workflow-templates-load-filelocation)
93
94
 
@@ -1288,7 +1289,26 @@ DESCRIPTION
1288
1289
  Delete workflow templates from your org
1289
1290
 
1290
1291
  EXAMPLES
1291
- $ contrail workflow-template delete
1292
+ $ contrail workflow-templates delete
1293
+ ```
1294
+
1295
+ ## `contrail workflow-templates export`
1296
+
1297
+ Export all workflows in the org.
1298
+
1299
+ ```
1300
+ USAGE
1301
+ $ contrail workflow-templates export [-f <value>] [--overwrite]
1302
+
1303
+ FLAGS
1304
+ -f, --outFile=<value> [default: workflows.yml] The location for the file to be saved
1305
+ --overwrite Replaces existing files if they exist
1306
+
1307
+ DESCRIPTION
1308
+ Export all workflows in the org.
1309
+
1310
+ EXAMPLES
1311
+ $ contrail workflow-templates export
1292
1312
  ```
1293
1313
 
1294
1314
  ## `contrail workflow-templates list`
@@ -1303,7 +1323,7 @@ DESCRIPTION
1303
1323
  Lists the workflow templates in the org
1304
1324
 
1305
1325
  EXAMPLES
1306
- $ contrail workflow-template list
1326
+ $ contrail workflow-templates list
1307
1327
  ```
1308
1328
 
1309
1329
  ## `contrail workflow-templates load FILELOCATION`
@@ -1321,6 +1341,6 @@ DESCRIPTION
1321
1341
  Loads your workflow from a local file
1322
1342
 
1323
1343
  EXAMPLES
1324
- $ contrail workflow-template load <FILE_LOCATION>
1344
+ $ contrail workflow-templates load <FILE_LOCATION>
1325
1345
  ```
1326
1346
  <!-- commandsstop -->
@@ -1 +1,3 @@
1
+ import { EventWorkflowActionDefinition } from '../interfaces';
1
2
  export declare function getEventWorkflowActionDefinition(criteria: any): Promise<any>;
3
+ export declare function getEventWorkflowActionDefinitionById(id: string): Promise<EventWorkflowActionDefinition>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEventWorkflowActionDefinition = void 0;
3
+ exports.getEventWorkflowActionDefinitionById = exports.getEventWorkflowActionDefinition = void 0;
4
4
  const sdk_1 = require("@contrail/sdk");
5
5
  async function getEventWorkflowActionDefinition(criteria) {
6
6
  return await new sdk_1.Entities().get({
@@ -9,3 +9,10 @@ async function getEventWorkflowActionDefinition(criteria) {
9
9
  });
10
10
  }
11
11
  exports.getEventWorkflowActionDefinition = getEventWorkflowActionDefinition;
12
+ async function getEventWorkflowActionDefinitionById(id) {
13
+ return await new sdk_1.Entities().get({
14
+ entityName: 'event-workflow-action-definition',
15
+ id,
16
+ });
17
+ }
18
+ exports.getEventWorkflowActionDefinitionById = getEventWorkflowActionDefinitionById;
@@ -145,6 +145,6 @@ async function refreshCurrentUserOrg() {
145
145
  auth_1.Auth.config.orgId = org.orgId || org.id;
146
146
  }
147
147
  // cache config in the fs
148
- (0, config_1.storeConfig)(Object.assign({}, auth_1.Auth.config));
148
+ await (0, config_1.storeConfig)(Object.assign({}, auth_1.Auth.config));
149
149
  return Object.assign({}, auth_1.Auth.config);
150
150
  }
@@ -12,6 +12,6 @@ class DeleteWorkflowTemplates extends core_1.Command {
12
12
  exports.default = DeleteWorkflowTemplates;
13
13
  DeleteWorkflowTemplates.description = 'Delete workflow templates from your org';
14
14
  DeleteWorkflowTemplates.examples = [
15
- `$ contrail workflow-template delete
15
+ `$ contrail workflow-templates delete
16
16
  `,
17
17
  ];
@@ -0,0 +1,12 @@
1
+ import { Command } from "@oclif/core";
2
+ export declare const DEFAULT_FILE_LOCATION = "workflows.yml";
3
+ export default class ExportWorkflows extends Command {
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ outFile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
12
+ export declare function exportWorkflows(fileLocation: string, overwrite: boolean): Promise<void>;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exportWorkflows = exports.DEFAULT_FILE_LOCATION = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path = tslib_1.__importStar(require("path"));
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const fs_1 = tslib_1.__importDefault(require("fs"));
8
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
9
+ const login_1 = require("../../auth/login");
10
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
11
+ const core_1 = require("@oclif/core");
12
+ const file_helpers_1 = require("../../helpers/file-helpers");
13
+ const event_workflow_templates_1 = require("../../api/event-workflow-templates");
14
+ const helper_1 = require("../../helpers/workflow-templates/helper");
15
+ exports.DEFAULT_FILE_LOCATION = "workflows.yml";
16
+ class ExportWorkflows extends core_1.Command {
17
+ async run() {
18
+ var _a;
19
+ const { flags } = await this.parse(ExportWorkflows);
20
+ try {
21
+ await (0, login_1.authUser)();
22
+ this.log("%s Getting Workflows.", chalk_1.default.blue.bold("START"));
23
+ await exportWorkflows((_a = flags.outFile) !== null && _a !== void 0 ? _a : exports.DEFAULT_FILE_LOCATION, flags.overwrite);
24
+ this.log("%s Done", chalk_1.default.yellow.bold("WORKFLOWS"));
25
+ }
26
+ catch (e) {
27
+ this.log(`%s Workflows download Failed. ${e}`, chalk_1.default.red.bold("FAIL"));
28
+ return;
29
+ }
30
+ this.log("%s Workflows download Complete.", chalk_1.default.green.bold("COMPLETE"));
31
+ }
32
+ }
33
+ exports.default = ExportWorkflows;
34
+ ExportWorkflows.description = "Export all workflows in the org.";
35
+ ExportWorkflows.examples = [
36
+ `$ contrail workflow-templates export
37
+ `,
38
+ ];
39
+ ExportWorkflows.flags = {
40
+ outFile: core_1.Flags.string({
41
+ char: "f",
42
+ description: "The location for the file to be saved",
43
+ required: false,
44
+ default: exports.DEFAULT_FILE_LOCATION,
45
+ }),
46
+ overwrite: core_1.Flags.boolean({
47
+ description: "Replaces existing files if they exist",
48
+ required: false,
49
+ default: false,
50
+ }),
51
+ };
52
+ async function exportWorkflows(fileLocation, overwrite) {
53
+ const allWorkflowsInOrg = await (0, event_workflow_templates_1.getExistingWorkflowTemplates)();
54
+ let workflowsObj = { workflows: [] };
55
+ for (const workflow of allWorkflowsInOrg) {
56
+ const exportWorkflow = lodash_1.default.pick(workflow, [
57
+ "triggerKey",
58
+ "workflowDefinition",
59
+ "name",
60
+ "isActive",
61
+ "identifier",
62
+ ]);
63
+ await (0, helper_1.populateActionIdentifiers)(exportWorkflow);
64
+ workflowsObj.workflows.push(exportWorkflow);
65
+ }
66
+ await saveData(workflowsObj, fileLocation, overwrite);
67
+ }
68
+ exports.exportWorkflows = exportWorkflows;
69
+ async function saveData(data, fileLocation, overwrite) {
70
+ const yamlStr = js_yaml_1.default.dump(data);
71
+ const CURRENT_DIR = process.cwd();
72
+ const pathToWrite = path.resolve(path.join(CURRENT_DIR, fileLocation));
73
+ if (fs_1.default.existsSync(pathToWrite)) {
74
+ await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
75
+ }
76
+ fs_1.default.writeFileSync(pathToWrite, yamlStr, "utf8");
77
+ }
@@ -12,6 +12,6 @@ class ListWorkflowTemplates extends core_1.Command {
12
12
  exports.default = ListWorkflowTemplates;
13
13
  ListWorkflowTemplates.description = 'Lists the workflow templates in the org';
14
14
  ListWorkflowTemplates.examples = [
15
- `$ contrail workflow-template list
15
+ `$ contrail workflow-templates list
16
16
  `,
17
17
  ];
@@ -13,7 +13,7 @@ class LoadWorkflowTemplates extends core_1.Command {
13
13
  exports.default = LoadWorkflowTemplates;
14
14
  LoadWorkflowTemplates.description = 'Loads your workflow from a local file';
15
15
  LoadWorkflowTemplates.examples = [
16
- `$ contrail workflow-template load <FILE_LOCATION>
16
+ `$ contrail workflow-templates load <FILE_LOCATION>
17
17
  `,
18
18
  ];
19
19
  LoadWorkflowTemplates.args = {
@@ -1,5 +1,5 @@
1
1
  import { App, AppDeclaration, AppActionDeclaration } from '../../interfaces';
2
- export declare function getActionsForApp(app: App): Promise<any>;
2
+ export declare function getActionsForAppVersion(app: App): Promise<any>;
3
3
  export declare function getActionDeclarationIdentifier(actionKey: any, app: App): string;
4
4
  export declare function deleteAction(actionId: any): Promise<any>;
5
5
  export declare class ActionsDeployer {
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActionsDeployer = exports.deleteAction = exports.getActionDeclarationIdentifier = exports.getActionsForApp = void 0;
3
+ exports.ActionsDeployer = exports.deleteAction = exports.getActionDeclarationIdentifier = exports.getActionsForAppVersion = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const sdk_1 = require("@contrail/sdk");
6
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
7
  const app_template_parsers_1 = require("./app-template-parsers");
8
8
  const common_1 = require("../../common");
9
9
  const fs_1 = tslib_1.__importDefault(require("fs"));
10
- async function getActionsForApp(app) {
10
+ async function getActionsForAppVersion(app) {
11
11
  return await new sdk_1.Entities().get({
12
12
  entityName: 'event-workflow-action-definition',
13
- criteria: { ownerKey: `app:${app.id}` },
13
+ criteria: { ownerKey: `appVersion:${app.latestAppVersionId}` },
14
14
  });
15
15
  }
16
- exports.getActionsForApp = getActionsForApp;
16
+ exports.getActionsForAppVersion = getActionsForAppVersion;
17
17
  function getActionDeclarationIdentifier(actionKey, app) {
18
18
  return app.identifier + ':' + actionKey;
19
19
  }
@@ -25,7 +25,7 @@ exports.deleteAction = deleteAction;
25
25
  class ActionsDeployer {
26
26
  async deployActions(appDeclaration, app) {
27
27
  // FETCH ALL ACTIONS FROM THE API.
28
- const existingActions = await getActionsForApp(app);
28
+ const existingActions = await getActionsForAppVersion(app);
29
29
  // UPSERT / DELETE BASED ON ACTION IDENTIFIER
30
30
  console.log('%s \tDeploying actions.', chalk_1.default.yellow.bold('ACTION'));
31
31
  let appActionIdentifiers = [];
@@ -63,7 +63,8 @@ class ActionsDeployer {
63
63
  const newObject = {
64
64
  identifier: getActionDeclarationIdentifier(actionKey, app),
65
65
  name: actionDeclaration.name,
66
- ownerKey: `app:${app.id}`,
66
+ internal: actionDeclaration.internal,
67
+ ownerKey: `appVersion:${app.latestAppVersionId}`,
67
68
  public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
68
69
  configProperties,
69
70
  async: actionDeclaration.async,
@@ -89,6 +90,8 @@ class ActionsDeployer {
89
90
  }
90
91
  const updates = {
91
92
  name: actionDeclaration.name,
93
+ internal: actionDeclaration.internal,
94
+ ownerKey: `appVersion:${app.latestAppVersionId}`,
92
95
  public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
93
96
  configProperties,
94
97
  async: actionDeclaration.async,
@@ -73,20 +73,20 @@ class AppDeployer {
73
73
  console.log('Dry run, not creating app');
74
74
  return {};
75
75
  }
76
- const app = await new sdk_1.Entities().create({ entityName: 'app', object: newApp });
76
+ let app = await new sdk_1.Entities().create({ entityName: 'app', object: newApp });
77
77
  console.log(`%s Created new app: ${app.name}`, chalk_1.default.yellow.bold('APP'));
78
78
  const isDocker = Object.hasOwnProperty.call(appDeclaration, 'dockerImageRef');
79
79
  if (!isDocker) { // this is the expected default behavior
80
80
  const appCodePackage = await createNodePackage(appDeclaration.appIdentifier, this.debug, this.dryRun);
81
81
  app.appCodePackageId = appCodePackage.id;
82
- await new sdk_1.Entities().update({ entityName: 'app', object: app });
82
+ app = await new sdk_1.Entities().update({ entityName: 'app', id: app.id, object: app });
83
83
  console.log(`%s Updated app with code package: ${app.name}`, chalk_1.default.yellow.bold('APP'));
84
84
  }
85
85
  return app;
86
86
  }
87
87
  async updateExistingApp(appDeclaration, existingApp) {
88
88
  var _a;
89
- let configProperties;
89
+ let configProperties = null;
90
90
  if (appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.appConfiguration) {
91
91
  configProperties = app_template_parsers_1.ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration);
92
92
  }
@@ -129,7 +129,7 @@ class AppDeployer {
129
129
  async remove(appDeclaration) {
130
130
  let app = await this.getExistingApp(appDeclaration);
131
131
  if (app) {
132
- const actions = await (0, actions_deployer_1.getActionsForApp)(app);
132
+ const actions = await (0, actions_deployer_1.getActionsForAppVersion)(app);
133
133
  for (const action of actions) {
134
134
  console.log(`%s Deleting action: ${action.identifier}`, chalk_1.default.yellow.bold('APP'));
135
135
  await (0, actions_deployer_1.deleteAction)(action.id);
@@ -34,7 +34,7 @@ class WorkflowTemplateDefinitionDeployer {
34
34
  type: 'checkbox',
35
35
  name: 'workflowTemplateDefinitionsToInstall',
36
36
  message: 'Which workflow templates would you like to install?',
37
- choices: workflowTemplateDefinitions.map(x => { return { value: x.identifier, name: x.name }; }),
37
+ choices: workflowTemplateDefinitions.filter(x => !x.builtIn).map(x => { return { value: x.identifier, name: x.name }; }),
38
38
  }]);
39
39
  const workflowTemplateDefinitionsToInstall = workflowTemplateDefinitions.filter(x => answers.workflowTemplateDefinitionsToInstall.includes(x.identifier));
40
40
  answers = await inquirer_1.default.prompt([{
@@ -47,6 +47,7 @@ class WorkflowTemplateDefinitionDeployer {
47
47
  for (const definition of workflowTemplateDefinitionsToInstall) {
48
48
  const newObject = {
49
49
  name: definition.name,
50
+ builtIn: definition.builtIn,
50
51
  triggerKey: definition.triggerKey,
51
52
  workflowDefinition: definition.workflowDefinition,
52
53
  isActive: makeActive,
@@ -106,7 +107,8 @@ class WorkflowTemplateDefinitionDeployer {
106
107
  const newObject = {
107
108
  identifier: this.getWorkflowDeclarationIdentifier(workflowKey, app),
108
109
  name: workflowDeclaration.name,
109
- ownerKey: `app:${app.id}`,
110
+ ownerKey: `appVersion:${app.latestAppVersionId}`,
111
+ builtIn: workflowDeclaration.builtIn,
110
112
  triggerKey: workflowDeclaration.triggerKey,
111
113
  workflowDefinition: workflowDeclaration.workflowDefinition,
112
114
  public: workflowDeclaration.public,
@@ -120,7 +122,7 @@ class WorkflowTemplateDefinitionDeployer {
120
122
  }
121
123
  async populateActionIds(workflowDefinition, app) {
122
124
  var _a;
123
- const availableAppActions = await (0, actions_deployer_1.getActionsForApp)(app);
125
+ const availableAppActions = await (0, actions_deployer_1.getActionsForAppVersion)(app);
124
126
  if (!((_a = workflowDefinition.workflowDefinition) === null || _a === void 0 ? void 0 : _a.paths)) {
125
127
  return;
126
128
  }
@@ -142,6 +144,8 @@ class WorkflowTemplateDefinitionDeployer {
142
144
  await this.populateActionIds(workflowDefinition, app);
143
145
  const updates = Object.assign(new Object(), {
144
146
  name: workflowDefinition.name,
147
+ builtIn: workflowDefinition.builtIn,
148
+ ownerKey: `appVersion:${app.latestAppVersionId}`,
145
149
  triggerKey: workflowDefinition.triggerKey,
146
150
  workflowDefinition: workflowDefinition.workflowDefinition,
147
151
  messageGroupId: workflowDefinition.messageGroupId,
@@ -1,7 +1,7 @@
1
1
  import { WorkflowTemplate, WorkflowTemplateDeclaration } from '../../interfaces';
2
2
  export declare class LocalWorkflowTemplateDeployer {
3
3
  deployWorkflows(wtDeclaration: WorkflowTemplateDeclaration): Promise<void>;
4
- deployWorkflowTemplate(workflowKey: string, workflow: WorkflowTemplate, existingWorkflows: Array<any>): Promise<any>;
4
+ deployWorkflowTemplate(workflow: WorkflowTemplate, existingWorkflows: WorkflowTemplate[]): Promise<any>;
5
5
  private createNewWorkflowTemplate;
6
6
  private populateActionIds;
7
7
  private updateWorkflowTemplate;
@@ -15,3 +15,4 @@ export declare class WorkflowTemplateDeployer {
15
15
  }
16
16
  export declare function deleteWorkflowTemplates(): Promise<void>;
17
17
  export declare function localDeployWorkflowTemplate(saveFileLocation: string): Promise<void>;
18
+ export declare function populateActionIdentifiers(workflowTemplate: WorkflowTemplate): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.localDeployWorkflowTemplate = exports.deleteWorkflowTemplates = exports.WorkflowTemplateDeployer = exports.getActionByIdentifier = exports.getWorkflowTemplateIdentifier = exports.LocalWorkflowTemplateDeployer = void 0;
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 path = tslib_1.__importStar(require("path"));
6
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
@@ -17,19 +17,19 @@ class LocalWorkflowTemplateDeployer {
17
17
  const existingWorkflows = await (0, event_workflow_templates_1.getExistingWorkflowTemplates)();
18
18
  // UPSERT / DELETE BASED ON WORKFLOW TEMPLATES IDENTIFIER
19
19
  console.log('%s \tDeploying workflow templates.', chalk_1.default.yellow.bold('WORKFLOW TEMPLATES'));
20
- for (const workflowKey of Object.keys(wtDeclaration.workflows)) {
21
- await this.deployWorkflowTemplate(workflowKey, wtDeclaration.workflows[workflowKey], existingWorkflows);
20
+ for (const workflow of wtDeclaration.workflows) {
21
+ await this.deployWorkflowTemplate(workflow, existingWorkflows);
22
22
  }
23
23
  }
24
- async deployWorkflowTemplate(workflowKey, workflow, existingWorkflows) {
25
- console.log(`%s \tDeploying workflow: ${workflowKey}`, chalk_1.default.yellow.bold('WORKFLOW TEMPLATES'));
26
- const identifier = getWorkflowTemplateIdentifier(workflowKey);
24
+ async deployWorkflowTemplate(workflow, existingWorkflows) {
25
+ console.log(`%s \tDeploying workflow: ${workflow.triggerKey}`, chalk_1.default.yellow.bold('WORKFLOW TEMPLATES'));
26
+ const identifier = getWorkflowTemplateIdentifier(workflow.identifier);
27
27
  const existingTemplate = existingWorkflows.find(ad => ad.identifier === identifier);
28
28
  (0, interface_converters_1.convertWorkflow)(workflow);
29
29
  if (existingTemplate) {
30
- return await this.updateWorkflowTemplate(workflowKey, existingTemplate, workflow);
30
+ return await this.updateWorkflowTemplate(identifier, existingTemplate, workflow);
31
31
  }
32
- return await this.createNewWorkflowTemplate(workflowKey, workflow);
32
+ return await this.createNewWorkflowTemplate(identifier, workflow);
33
33
  }
34
34
  async createNewWorkflowTemplate(workflowKey, workflowTemplate) {
35
35
  await this.populateActionIds(workflowTemplate, workflowKey);
@@ -49,7 +49,7 @@ class LocalWorkflowTemplateDeployer {
49
49
  }
50
50
  async populateActionIds(workflowTemplate, workflowKey) {
51
51
  var _a;
52
- console.log('workflow tempalate:', JSON.stringify(workflowTemplate, null, 2));
52
+ console.log('workflow template:', JSON.stringify(workflowTemplate, null, 2));
53
53
  if (!((_a = workflowTemplate === null || workflowTemplate === void 0 ? void 0 : workflowTemplate.workflowDefinition) === null || _a === void 0 ? void 0 : _a.paths)) {
54
54
  return;
55
55
  }
@@ -78,6 +78,7 @@ class LocalWorkflowTemplateDeployer {
78
78
  const updates = Object.assign(new Object(), {
79
79
  name: workflowTemplate.name,
80
80
  triggerKey: workflowTemplate.triggerKey,
81
+ builtIn: workflowTemplate.builtIn,
81
82
  workflowDefinition: workflowTemplate.workflowDefinition,
82
83
  messageGroupId: (_a = workflowTemplate.messageGroupId) !== null && _a !== void 0 ? _a : existingWorkflowTemplate.messageGroupId,
83
84
  parallelWorkerCount: (_b = workflowTemplate.parallelWorkerCount) !== null && _b !== void 0 ? _b : existingWorkflowTemplate.parallelWorkerCount,
@@ -169,3 +170,29 @@ function loadTemplateConfig(saveFile) {
169
170
  throw new Error(`ERROR PARSING YAML: ${e}`);
170
171
  }
171
172
  }
173
+ async function populateActionIdentifiers(workflowTemplate) {
174
+ var _a;
175
+ if (!((_a = workflowTemplate === null || workflowTemplate === void 0 ? void 0 : workflowTemplate.workflowDefinition) === null || _a === void 0 ? void 0 : _a.paths)) {
176
+ return;
177
+ }
178
+ for (const path of workflowTemplate.workflowDefinition.paths) {
179
+ if (!(path === null || path === void 0 ? void 0 : path.actionDefinitionConfigs)) {
180
+ continue;
181
+ }
182
+ for (const actionConfiguration of path.actionDefinitionConfigs) {
183
+ const actionId = actionConfiguration.id;
184
+ try {
185
+ const actionEntity = await (0, event_workflow_action_definition_1.getEventWorkflowActionDefinitionById)(actionId);
186
+ actionConfiguration.action = actionEntity.identifier;
187
+ delete actionConfiguration.id;
188
+ }
189
+ catch (e) {
190
+ console.log(e);
191
+ }
192
+ if (!actionConfiguration.action) {
193
+ throw new Error(`Could not find action ${actionId}`);
194
+ }
195
+ }
196
+ }
197
+ }
198
+ exports.populateActionIdentifiers = populateActionIdentifiers;
@@ -39,6 +39,7 @@ export interface AppActionDeclaration {
39
39
  handler: string;
40
40
  public?: boolean;
41
41
  name: string;
42
+ internal?: boolean;
42
43
  description?: string;
43
44
  actionConfiguration?: ConfigPropertyElements;
44
45
  async?: boolean;
@@ -58,6 +59,7 @@ export interface WorkflowDefinition {
58
59
  ownerKey: string;
59
60
  isActive: boolean;
60
61
  public: boolean;
62
+ builtIn?: boolean;
61
63
  supportingAppId?: string;
62
64
  parallelism?: number;
63
65
  groupId?: string;
@@ -65,14 +67,13 @@ export interface WorkflowDefinition {
65
67
  parallelWorkerCount?: number;
66
68
  }
67
69
  export interface WorkflowTemplateDeclaration {
68
- workflows?: {
69
- [key: string]: WorkflowTemplate;
70
- };
70
+ workflows?: WorkflowTemplate[];
71
71
  }
72
72
  export interface WorkflowTemplate {
73
73
  id?: string;
74
74
  identifier?: string;
75
75
  name: string;
76
+ builtIn?: boolean;
76
77
  triggerKey: string;
77
78
  workflowDefinition: WorkflowDefinitionPaths;
78
79
  isActive: boolean;
@@ -203,6 +204,7 @@ export interface EventWorkflowActionDefinition {
203
204
  id?: string;
204
205
  identifier?: string;
205
206
  name?: string;
207
+ internal?: boolean;
206
208
  executeFunctionString?: string;
207
209
  ownerKey?: string;
208
210
  public?: boolean;
@@ -26,8 +26,28 @@ actions:
26
26
  message:
27
27
  label: "Additional message to log."
28
28
  propertyType: "string"
29
+ sayHello:
30
+ internal: true
31
+ name: "Say Hello"
32
+ description: "Prints hello world to the log."
33
+ async: false
29
34
 
30
35
  workflows:
36
+ friendlyGreeting:
37
+ builtIn: true
38
+ name: "Friendly Greeting"
39
+ triggerKey: "helloFoo"
40
+ isActive: true
41
+ public: true
42
+ concurrency: 3 # The maximum number of concurrent jobs to run for this workflow. Defaults to 5
43
+ workflowDefinition:
44
+ paths:
45
+ - conditional: "true"
46
+ actionDefinitionConfigs:
47
+ - action: sayHello
48
+ name: Say Hello
49
+
50
+
31
51
  logItemUpdate:
32
52
  name: "Item Update -> Log"
33
53
  triggerKey: item|update
@@ -11,7 +11,7 @@
11
11
  "access": "public"
12
12
  },
13
13
  "scripts": {
14
- "build": "tsc",
14
+ "build": "tsc; npx copyfiles assets/**/* dist/",
15
15
  "start": "nodemon --watch \"src/**/*.ts\" --exec ts-node src/main.ts",
16
16
  "debug": "nodemon -r ts-node/register --inspect=127.0.0.1:60002 --watch 'actions/**/*.ts' --exec node src/main.ts",
17
17
  "lint": "eslint . --fix",
@@ -4,15 +4,15 @@ import { Action, AppAction, AppActionCallBack, AppActionCallbackStatus, Logger }
4
4
  export class LogItemAction implements AppAction {
5
5
 
6
6
  @Action('logItem')
7
- public async execute(event, config: any, logger: Logger): Promise<AppActionCallBack> {
8
- logger.log('Starting Example Action');
9
- logger.log('Getting item from SDK');
7
+ public async execute(event, config: any): Promise<AppActionCallBack> {
8
+ console.log('Starting Example Action');
9
+ console.log('Getting item from SDK');
10
10
 
11
11
  const item = await new Entities().get({
12
12
  entityName: 'item',
13
13
  id: event.id,
14
14
  });
15
- logger.log('Got item: ', item);
15
+ console.log('Got item: ', item);
16
16
 
17
17
  return {
18
18
  output: {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.1.12",
2
+ "version": "2.1.15",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -1168,11 +1168,42 @@
1168
1168
  "pluginType": "core",
1169
1169
  "aliases": [],
1170
1170
  "examples": [
1171
- "$ contrail workflow-template delete\n"
1171
+ "$ contrail workflow-templates delete\n"
1172
1172
  ],
1173
1173
  "flags": {},
1174
1174
  "args": {}
1175
1175
  },
1176
+ "workflow-templates:export": {
1177
+ "id": "workflow-templates:export",
1178
+ "description": "Export all workflows in the org.",
1179
+ "strict": true,
1180
+ "pluginName": "@contrail/cli",
1181
+ "pluginAlias": "@contrail/cli",
1182
+ "pluginType": "core",
1183
+ "aliases": [],
1184
+ "examples": [
1185
+ "$ contrail workflow-templates export\n"
1186
+ ],
1187
+ "flags": {
1188
+ "outFile": {
1189
+ "name": "outFile",
1190
+ "type": "option",
1191
+ "char": "f",
1192
+ "description": "The location for the file to be saved",
1193
+ "required": false,
1194
+ "multiple": false,
1195
+ "default": "workflows.yml"
1196
+ },
1197
+ "overwrite": {
1198
+ "name": "overwrite",
1199
+ "type": "boolean",
1200
+ "description": "Replaces existing files if they exist",
1201
+ "required": false,
1202
+ "allowNo": false
1203
+ }
1204
+ },
1205
+ "args": {}
1206
+ },
1176
1207
  "workflow-templates:list": {
1177
1208
  "id": "workflow-templates:list",
1178
1209
  "description": "Lists the workflow templates in the org",
@@ -1182,7 +1213,7 @@
1182
1213
  "pluginType": "core",
1183
1214
  "aliases": [],
1184
1215
  "examples": [
1185
- "$ contrail workflow-template list\n"
1216
+ "$ contrail workflow-templates list\n"
1186
1217
  ],
1187
1218
  "flags": {},
1188
1219
  "args": {}
@@ -1196,7 +1227,7 @@
1196
1227
  "pluginType": "core",
1197
1228
  "aliases": [],
1198
1229
  "examples": [
1199
- "$ contrail workflow-template load <FILE_LOCATION>\n"
1230
+ "$ contrail workflow-templates load <FILE_LOCATION>\n"
1200
1231
  ],
1201
1232
  "flags": {},
1202
1233
  "args": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "2.1.12",
3
+ "version": "2.1.15",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",