@contrail/cli 2.1.15 → 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.15 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
  }
@@ -15,7 +15,7 @@ async function getActionsForAppVersion(app) {
15
15
  }
16
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) {
@@ -28,21 +28,14 @@ class ActionsDeployer {
28
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'));
@@ -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
  }
@@ -58,10 +58,10 @@ class WorkflowTemplateDefinitionDeployer {
58
58
  console.log(`%s \n ${workflowTemplateDefinitionsToInstall.length} workflows installed`, chalk_1.default.green.bold('WORKFLOW DEFINITION'));
59
59
  }
60
60
  async listWorkflowTemplateDefinitions() {
61
- const installedApps = await (0, apps_1.getInstalledApps)();
61
+ const installedAppOrgs = await (0, apps_1.getInstalledApps)();
62
62
  const workflowTemplateDefinitions = [];
63
- for (const appOrg of installedApps) {
64
- 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 => {
65
65
  return {
66
66
  appName: appOrg.app.name,
67
67
  workflowName: x.name,
@@ -74,7 +74,7 @@ class WorkflowTemplateDefinitionDeployer {
74
74
  }
75
75
  async deployWorkflowTemplateDefinitions(appDeclaration, app) {
76
76
  // FETCH ALL WORKFLOWS FROM THE API.
77
- const existingWorkflows = await (0, apps_1.getWorkflowTemplateDefinitionsForApp)({ appId: app.id });
77
+ const existingWorkflows = await (0, apps_1.getWorkflowTemplateDefinitionsForAppVersion)({ appVersionId: app.latestAppVersionId });
78
78
  // UPSERT / DELETE BASED ON WORKFLOW IDENTIFIER
79
79
  console.log('%s \tDeploying workflow definitions.', chalk_1.default.yellow.bold('WORKFLOW DEFINITION'));
80
80
  if (appDeclaration.workflows) {
@@ -84,12 +84,6 @@ class WorkflowTemplateDefinitionDeployer {
84
84
  await this.deployWorkflow(workflowKey, appDeclaration.workflows[workflowKey], app, existingWorkflows);
85
85
  }
86
86
  }
87
- // remove old templates that were removed by the app publisher
88
- const localIdentifiers = localWorkflows.map(x => this.getWorkflowDeclarationIdentifier(x, app));
89
- const workflowTemplateDefinitionsToDelete = existingWorkflows.filter(x => !localIdentifiers.includes(x.identifier));
90
- for (const templateToDelete of workflowTemplateDefinitionsToDelete) {
91
- await (0, event_workflow_template_definition_1.deleteWorkflowTemplateDefinition)(templateToDelete.id);
92
- }
93
87
  }
94
88
  }
95
89
  async deployWorkflow(workflowKey, workflow, app, existingWorkflows) {
@@ -156,7 +150,7 @@ class WorkflowTemplateDefinitionDeployer {
156
150
  return updatedWorkflowDefinition;
157
151
  }
158
152
  getWorkflowDeclarationIdentifier(actionKey, app) {
159
- return app.identifier + ':' + actionKey;
153
+ return `${app.identifier}@${app.latestAppVersionId}:${actionKey}`;
160
154
  }
161
155
  }
162
156
  exports.WorkflowTemplateDefinitionDeployer = WorkflowTemplateDefinitionDeployer;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.1.15",
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.15",
3
+ "version": "2.1.16",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",