@contrail/cli 2.1.14 → 2.1.16

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.14 darwin-arm64 node-v18.13.0
18
+ @contrail/cli/2.1.16 darwin-arm64 node-v18.13.0
19
19
  $ contrail --help [COMMAND]
20
20
  USAGE
21
21
  $ contrail COMMAND
@@ -1,6 +1,6 @@
1
1
  import { App, AppOrg, AppVersion, WorkflowDefinition } from '../interfaces';
2
- export declare function getWorkflowTemplateDefinitionsForApp(options: {
3
- appId: string;
2
+ export declare function getWorkflowTemplateDefinitionsForAppVersion(options: {
3
+ appVersionId: string;
4
4
  }): Promise<WorkflowDefinition[]>;
5
5
  export declare function getAppVersions(app: any): Promise<AppVersion[]>;
6
6
  export declare function upgradeAppVersion(appOrg: any, appVersionId: any): Promise<AppOrg>;
package/dist/api/apps.js CHANGED
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAvailableApps = exports.installAppToOrg = exports.getInstalledApps = exports.deleteAppOrg = exports.upgradeAppVersion = exports.getAppVersions = exports.getWorkflowTemplateDefinitionsForApp = void 0;
3
+ exports.getAvailableApps = exports.installAppToOrg = exports.getInstalledApps = exports.deleteAppOrg = exports.upgradeAppVersion = exports.getAppVersions = exports.getWorkflowTemplateDefinitionsForAppVersion = void 0;
4
4
  const auth_1 = require("../auth/auth");
5
5
  const sdk_1 = require("@contrail/sdk");
6
- async function getWorkflowTemplateDefinitionsForApp(options) {
6
+ async function getWorkflowTemplateDefinitionsForAppVersion(options) {
7
7
  return await new sdk_1.Entities().get({
8
8
  entityName: 'event-workflow-template-definition',
9
9
  criteria: {
10
- ownerKey: `app:${options.appId}`
10
+ ownerKey: `appVersion:${options.appVersionId}`
11
11
  }
12
12
  });
13
13
  }
14
- exports.getWorkflowTemplateDefinitionsForApp = getWorkflowTemplateDefinitionsForApp;
14
+ exports.getWorkflowTemplateDefinitionsForAppVersion = getWorkflowTemplateDefinitionsForAppVersion;
15
15
  async function getAppVersions(app) {
16
16
  return await new sdk_1.Entities().get({
17
17
  entityName: 'app-version',
@@ -82,7 +82,7 @@ class InstallApp extends core_1.Command {
82
82
  }
83
83
  }
84
84
  if (flags.installWorkflowTemplates) {
85
- const workflowTemplateDefinitions = await (0, apps_1.getWorkflowTemplateDefinitionsForApp)({ appId: app.id });
85
+ const workflowTemplateDefinitions = await (0, apps_1.getWorkflowTemplateDefinitionsForAppVersion)({ appVersionId: appOrg.appVersionId });
86
86
  if (!workflowTemplateDefinitions.length) {
87
87
  return;
88
88
  }
@@ -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,21 +1,21 @@
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
- return app.identifier + ':' + actionKey;
18
+ return `${app.identifier}@${app.latestAppVersionId}:${actionKey}`;
19
19
  }
20
20
  exports.getActionDeclarationIdentifier = getActionDeclarationIdentifier;
21
21
  async function deleteAction(actionId) {
@@ -25,24 +25,17 @@ 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
- let appActionIdentifiers = [];
32
31
  if (appDeclaration.actions) {
33
32
  const localActionKeys = Object.keys(appDeclaration.actions);
34
- appActionIdentifiers = localActionKeys.map(x => getActionDeclarationIdentifier(x, app));
35
33
  if ((localActionKeys === null || localActionKeys === void 0 ? void 0 : localActionKeys.length) > 0) {
36
34
  for (const actionKey of localActionKeys) {
37
35
  await this.deployAction(actionKey, appDeclaration.actions[actionKey], app, existingActions);
38
36
  }
39
37
  }
40
38
  }
41
- const toDelete = existingActions.filter(x => !appActionIdentifiers.includes(x.identifier));
42
- for (const action of toDelete) {
43
- console.log(`%s \tDeleting action: ${action.identifier}`, chalk_1.default.yellow.bold('ACTION'));
44
- await deleteAction(action.id);
45
- }
46
39
  }
47
40
  async deployAction(actionKey, actionDeclaration, app, existingActions) {
48
41
  console.log(`%s \tDeploying action: ${actionKey}`, chalk_1.default.yellow.bold('ACTION'));
@@ -63,7 +56,8 @@ class ActionsDeployer {
63
56
  const newObject = {
64
57
  identifier: getActionDeclarationIdentifier(actionKey, app),
65
58
  name: actionDeclaration.name,
66
- ownerKey: `app:${app.id}`,
59
+ internal: actionDeclaration.internal,
60
+ ownerKey: `appVersion:${app.latestAppVersionId}`,
67
61
  public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
68
62
  configProperties,
69
63
  async: actionDeclaration.async,
@@ -89,6 +83,8 @@ class ActionsDeployer {
89
83
  }
90
84
  const updates = {
91
85
  name: actionDeclaration.name,
86
+ internal: actionDeclaration.internal,
87
+ ownerKey: `appVersion:${app.latestAppVersionId}`,
92
88
  public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
93
89
  configProperties,
94
90
  async: actionDeclaration.async,
@@ -73,13 +73,13 @@ 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;
@@ -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);
@@ -11,8 +11,8 @@ const actions_deployer_1 = require("../app/actions-deployer");
11
11
  const interface_converters_1 = require("../../interface-converters");
12
12
  class WorkflowTemplateDefinitionDeployer {
13
13
  async cliInstallWorkflowTemplateDefinitions() {
14
- const installedApps = await (0, apps_1.getInstalledApps)();
15
- if (!installedApps.length) {
14
+ const installedAppOrgs = await (0, apps_1.getInstalledApps)();
15
+ if (!installedAppOrgs.length) {
16
16
  console.log('%s \nNo apps are currently installed. You must install an app before installing its associated workflow template definitions.', chalk_1.default.red.bold('WORKFLOW DEFINITION'));
17
17
  return;
18
18
  }
@@ -20,10 +20,10 @@ class WorkflowTemplateDefinitionDeployer {
20
20
  type: 'list',
21
21
  name: 'appIdentifier',
22
22
  message: 'Which app\'s workflow would you like to install?',
23
- choices: installedApps.map(x => x.app.identifier)
23
+ choices: installedAppOrgs.map(x => x.app.identifier)
24
24
  }]);
25
- const app = installedApps.find(x => x.app.identifier === answers.appIdentifier).app;
26
- const workflowTemplateDefinitions = await (0, apps_1.getWorkflowTemplateDefinitionsForApp)({ appId: app.id });
25
+ const appOrg = installedAppOrgs.find(x => x.app.identifier === answers.appIdentifier);
26
+ const workflowTemplateDefinitions = await (0, apps_1.getWorkflowTemplateDefinitionsForAppVersion)({ appVersionId: appOrg.appVersionId });
27
27
  for (const definition of workflowTemplateDefinitions) {
28
28
  console.log(chalk_1.default.yellow.bold(`- ${definition.name}`));
29
29
  }
@@ -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,
@@ -57,10 +58,10 @@ class WorkflowTemplateDefinitionDeployer {
57
58
  console.log(`%s \n ${workflowTemplateDefinitionsToInstall.length} workflows installed`, chalk_1.default.green.bold('WORKFLOW DEFINITION'));
58
59
  }
59
60
  async listWorkflowTemplateDefinitions() {
60
- const installedApps = await (0, apps_1.getInstalledApps)();
61
+ const installedAppOrgs = await (0, apps_1.getInstalledApps)();
61
62
  const workflowTemplateDefinitions = [];
62
- for (const appOrg of installedApps) {
63
- workflowTemplateDefinitions.push(...await (await (0, apps_1.getWorkflowTemplateDefinitionsForApp)({ appId: appOrg.appId })).map(x => {
63
+ for (const appOrg of installedAppOrgs) {
64
+ workflowTemplateDefinitions.push(...await (await (0, apps_1.getWorkflowTemplateDefinitionsForAppVersion)({ appVersionId: appOrg.appVersionId })).map(x => {
64
65
  return {
65
66
  appName: appOrg.app.name,
66
67
  workflowName: x.name,
@@ -73,7 +74,7 @@ class WorkflowTemplateDefinitionDeployer {
73
74
  }
74
75
  async deployWorkflowTemplateDefinitions(appDeclaration, app) {
75
76
  // FETCH ALL WORKFLOWS FROM THE API.
76
- const existingWorkflows = await (0, apps_1.getWorkflowTemplateDefinitionsForApp)({ appId: app.id });
77
+ const existingWorkflows = await (0, apps_1.getWorkflowTemplateDefinitionsForAppVersion)({ appVersionId: app.latestAppVersionId });
77
78
  // UPSERT / DELETE BASED ON WORKFLOW IDENTIFIER
78
79
  console.log('%s \tDeploying workflow definitions.', chalk_1.default.yellow.bold('WORKFLOW DEFINITION'));
79
80
  if (appDeclaration.workflows) {
@@ -83,12 +84,6 @@ class WorkflowTemplateDefinitionDeployer {
83
84
  await this.deployWorkflow(workflowKey, appDeclaration.workflows[workflowKey], app, existingWorkflows);
84
85
  }
85
86
  }
86
- // remove old templates that were removed by the app publisher
87
- const localIdentifiers = localWorkflows.map(x => this.getWorkflowDeclarationIdentifier(x, app));
88
- const workflowTemplateDefinitionsToDelete = existingWorkflows.filter(x => !localIdentifiers.includes(x.identifier));
89
- for (const templateToDelete of workflowTemplateDefinitionsToDelete) {
90
- await (0, event_workflow_template_definition_1.deleteWorkflowTemplateDefinition)(templateToDelete.id);
91
- }
92
87
  }
93
88
  }
94
89
  async deployWorkflow(workflowKey, workflow, app, existingWorkflows) {
@@ -106,7 +101,8 @@ class WorkflowTemplateDefinitionDeployer {
106
101
  const newObject = {
107
102
  identifier: this.getWorkflowDeclarationIdentifier(workflowKey, app),
108
103
  name: workflowDeclaration.name,
109
- ownerKey: `app:${app.id}`,
104
+ ownerKey: `appVersion:${app.latestAppVersionId}`,
105
+ builtIn: workflowDeclaration.builtIn,
110
106
  triggerKey: workflowDeclaration.triggerKey,
111
107
  workflowDefinition: workflowDeclaration.workflowDefinition,
112
108
  public: workflowDeclaration.public,
@@ -120,7 +116,7 @@ class WorkflowTemplateDefinitionDeployer {
120
116
  }
121
117
  async populateActionIds(workflowDefinition, app) {
122
118
  var _a;
123
- const availableAppActions = await (0, actions_deployer_1.getActionsForApp)(app);
119
+ const availableAppActions = await (0, actions_deployer_1.getActionsForAppVersion)(app);
124
120
  if (!((_a = workflowDefinition.workflowDefinition) === null || _a === void 0 ? void 0 : _a.paths)) {
125
121
  return;
126
122
  }
@@ -142,6 +138,8 @@ class WorkflowTemplateDefinitionDeployer {
142
138
  await this.populateActionIds(workflowDefinition, app);
143
139
  const updates = Object.assign(new Object(), {
144
140
  name: workflowDefinition.name,
141
+ builtIn: workflowDefinition.builtIn,
142
+ ownerKey: `appVersion:${app.latestAppVersionId}`,
145
143
  triggerKey: workflowDefinition.triggerKey,
146
144
  workflowDefinition: workflowDefinition.workflowDefinition,
147
145
  messageGroupId: workflowDefinition.messageGroupId,
@@ -152,7 +150,7 @@ class WorkflowTemplateDefinitionDeployer {
152
150
  return updatedWorkflowDefinition;
153
151
  }
154
152
  getWorkflowDeclarationIdentifier(actionKey, app) {
155
- return app.identifier + ':' + actionKey;
153
+ return `${app.identifier}@${app.latestAppVersionId}:${actionKey}`;
156
154
  }
157
155
  }
158
156
  exports.WorkflowTemplateDefinitionDeployer = WorkflowTemplateDefinitionDeployer;
@@ -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,
@@ -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;
@@ -71,6 +73,7 @@ export interface WorkflowTemplate {
71
73
  id?: string;
72
74
  identifier?: string;
73
75
  name: string;
76
+ builtIn?: boolean;
74
77
  triggerKey: string;
75
78
  workflowDefinition: WorkflowDefinitionPaths;
76
79
  isActive: boolean;
@@ -201,6 +204,7 @@ export interface EventWorkflowActionDefinition {
201
204
  id?: string;
202
205
  identifier?: string;
203
206
  name?: string;
207
+ internal?: boolean;
204
208
  executeFunctionString?: string;
205
209
  ownerKey?: string;
206
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.1.14",
2
+ "version": "2.1.16",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "2.1.14",
3
+ "version": "2.1.16",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",