@contrail/cli 1.0.30 → 1.0.32

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.
Files changed (48) hide show
  1. package/.eslintrc.js +53 -0
  2. package/lib/apps/deploy-app/actions-deployer.js +12 -3
  3. package/lib/apps/deploy-app/app-deployer.js +2 -3
  4. package/lib/apps/deploy-app/app-template-parsers.js +1 -1
  5. package/lib/apps/deploy-app/docker-action-builder.d.ts +7 -7
  6. package/lib/apps/deploy-app/docker-action-builder.js +83 -83
  7. package/lib/apps/deploy-app/interfaces.d.ts +8 -8
  8. package/lib/apps/deploy-app/workflow-definition-deployer.js +1 -1
  9. package/lib/apps/deploy-app/workflow-deployer.d.ts +7 -7
  10. package/lib/apps/deploy-app/workflow-deployer.js +77 -77
  11. package/lib/auth/login.js +5 -5
  12. package/lib/cli.js +9 -2
  13. package/lib/colors/color-loader.js +8 -8
  14. package/lib/config/config.js +2 -2
  15. package/lib/interfaces.d.ts +2 -2
  16. package/lib/types/interfaces.js +1 -0
  17. package/lib/types/option-set-merger.js +2 -2
  18. package/lib/types/option-set-parser.js +2 -2
  19. package/lib/types/option-set-uploader.js +2 -2
  20. package/lib/types/parse-types.d.ts +1 -0
  21. package/lib/types/parse-types.js +47 -6
  22. package/lib/types/types-extractor.js +4 -4
  23. package/lib/types/types-properties-merger.js +2 -2
  24. package/lib/types/types-uploader.d.ts +1 -1
  25. package/lib/types/types-uploader.js +6 -6
  26. package/package.json +8 -6
  27. package/src/apps/deploy-app/actions-deployer.ts +17 -10
  28. package/src/apps/deploy-app/app-deployer.ts +3 -4
  29. package/src/apps/deploy-app/workflow-definition-deployer.ts +3 -3
  30. package/src/auth/login.ts +125 -125
  31. package/src/cli.ts +126 -120
  32. package/src/colors/color-loader.ts +16 -16
  33. package/src/config/config.ts +9 -11
  34. package/src/config/configCommands.ts +1 -1
  35. package/src/interfaces.ts +9 -10
  36. package/src/types/csv-parser.ts +1 -1
  37. package/src/types/option-set-merger.ts +9 -9
  38. package/src/types/option-set-parser.ts +5 -6
  39. package/src/types/option-set-uploader.ts +2 -2
  40. package/src/types/parse-types.ts +61 -12
  41. package/src/types/types-extractor.ts +5 -5
  42. package/src/types/types-properties-merger.ts +6 -6
  43. package/src/types/types-uploader.ts +31 -31
  44. package/src/workflows/workflow-template-deployer.ts +2 -4
  45. package/src/workflows/workflowCommands.ts +0 -1
  46. package/templates/javascript/actions/example/action.js +37 -37
  47. package/templates/typescript/actions/exampleAction.ts +1 -1
  48. package/templates/typescript/app.yml +1 -1
package/.eslintrc.js ADDED
@@ -0,0 +1,53 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es2021: true,
5
+ node: true
6
+
7
+ },
8
+ extends: [
9
+ 'eslint:recommended',
10
+ 'plugin:@typescript-eslint/eslint-recommended',
11
+ 'plugin:@typescript-eslint/recommended'
12
+ ],
13
+ parser: '@typescript-eslint/parser',
14
+ parserOptions: {
15
+ ecmaVersion: 'latest',
16
+ sourceType: 'module'
17
+ },
18
+ plugins: [
19
+ '@typescript-eslint',
20
+ 'unused-imports'
21
+ ],
22
+ rules: {
23
+ indent: [
24
+ 'error',
25
+ 2
26
+ ],
27
+ 'linebreak-style': [
28
+ 'error',
29
+ 'unix'
30
+ ],
31
+ 'quote-props': ['error', 'as-needed'],
32
+ quotes: [
33
+ 'error',
34
+ 'single'
35
+ ],
36
+ semi: [
37
+ 'error',
38
+ 'always'
39
+ ],
40
+ 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
41
+ 'no-trailing-spaces': 'error',
42
+ 'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
43
+ '@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],
44
+ '@typescript-eslint/no-explicit-any': 'off',
45
+ '@typescript-eslint/no-var-requires': 'warn',
46
+ 'no-unused-vars': 'off',
47
+ 'unused-imports/no-unused-imports': 'error',
48
+ 'unused-imports/no-unused-vars': [
49
+ 'warn',
50
+ { vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' }
51
+ ]
52
+ }
53
+ };
@@ -21,14 +21,21 @@ export class ActionsDeployer {
21
21
  const existingActions = await getActionsForApp(app);
22
22
  // UPSERT / DELETE BASED ON ACTION IDENTIFIER
23
23
  console.log('%s \tDeploying actions.', chalk.yellow.bold('ACTION'));
24
+ let appActionIdentifiers = [];
24
25
  if (appDeclaration.actions) {
25
- const localActions = Object.keys(appDeclaration.actions);
26
- if ((localActions === null || localActions === void 0 ? void 0 : localActions.length) > 0) {
27
- for (const actionKey of localActions) {
26
+ const localActionKeys = Object.keys(appDeclaration.actions);
27
+ appActionIdentifiers = localActionKeys.map(x => getActionDeclarationIdentifier(x, app));
28
+ if ((localActionKeys === null || localActionKeys === void 0 ? void 0 : localActionKeys.length) > 0) {
29
+ for (const actionKey of localActionKeys) {
28
30
  await this.deployAction(actionKey, appDeclaration.actions[actionKey], app, existingActions);
29
31
  }
30
32
  }
31
33
  }
34
+ const toDelete = existingActions.filter(x => !appActionIdentifiers.includes(x.identifier));
35
+ for (const action of toDelete) {
36
+ console.log(`%s \tDeleting action: ${action.identifier}`, chalk.yellow.bold('ACTION'));
37
+ await deleteAction(action.id);
38
+ }
32
39
  }
33
40
  async deployAction(actionKey, actionDeclaration, app, existingActions) {
34
41
  console.log(`%s \tDeploying action: ${actionKey}`, chalk.yellow.bold('ACTION'));
@@ -52,6 +59,7 @@ export class ActionsDeployer {
52
59
  ownerKey: `app:${app.id}`,
53
60
  public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
54
61
  configProperties,
62
+ async: actionDeclaration.async,
55
63
  };
56
64
  const functionString = await this.getFunction(actionDeclaration);
57
65
  if (functionString) {
@@ -76,6 +84,7 @@ export class ActionsDeployer {
76
84
  name: actionDeclaration.name,
77
85
  public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
78
86
  configProperties,
87
+ async: actionDeclaration.async,
79
88
  };
80
89
  const functionString = await this.getFunction(actionDeclaration);
81
90
  if (functionString) {
@@ -8,11 +8,11 @@ export class AppDeployer {
8
8
  async deploy(appDeclaration) {
9
9
  let app = await this.getExistingApp(appDeclaration);
10
10
  if (!app) {
11
- console.log(`%s Creating new app.`, chalk.yellow.bold('APP'));
11
+ console.log('%s Creating new app.', chalk.yellow.bold('APP'));
12
12
  app = await this.createNewApp(appDeclaration);
13
13
  }
14
14
  else {
15
- console.log(`%s Updating existing app.`, chalk.yellow.bold('APP'));
15
+ console.log('%s Updating existing app.', chalk.yellow.bold('APP'));
16
16
  app = await this.updateExistingApp(appDeclaration, app);
17
17
  }
18
18
  await new ActionsDeployer().deployActions(appDeclaration, app);
@@ -57,7 +57,6 @@ export class AppDeployer {
57
57
  keywords: appDeclaration.keywords,
58
58
  configProperties,
59
59
  triggerKeyDefinitions,
60
- isDockerBased: appDeclaration.isDockerBased,
61
60
  dockerImageRef: appDeclaration.dockerImageRef,
62
61
  };
63
62
  const app = await new Entities().create({ entityName: 'app', object: newApp });
@@ -25,7 +25,7 @@ export class ConfigPropertiesParser {
25
25
  const config = {
26
26
  label: declaration.label,
27
27
  slug: configKey,
28
- propertyType: declaration.propertyType,
28
+ propertyType: declaration.propertyType, // TODO should support options
29
29
  };
30
30
  if (declaration.options) {
31
31
  config.options = declaration.options;
@@ -1,10 +1,10 @@
1
1
  import { App, AppDeclaration, AppActionDeclaration } from '../../interfaces';
2
2
  export declare class ActionsDeployer {
3
- deployActions(appDeclaration: AppDeclaration, app: App): Promise<void>;
4
- getActionsForApp(app: App): Promise<any>;
5
- deployAction(actionKey: string, actionDeclaration: AppActionDeclaration, app: App, existingActions: Array<any>): Promise<void>;
6
- private createNewActionDefinition;
7
- private updateActionDefinition;
8
- getActionDeclarationIdentifier(actionKey: any, app: App): string;
9
- getFunction(actionDeclaration: AppActionDeclaration): Promise<string>;
3
+ deployActions(appDeclaration: AppDeclaration, app: App): Promise<void>;
4
+ getActionsForApp(app: App): Promise<any>;
5
+ deployAction(actionKey: string, actionDeclaration: AppActionDeclaration, app: App, existingActions: Array<any>): Promise<void>;
6
+ private createNewActionDefinition;
7
+ private updateActionDefinition;
8
+ getActionDeclarationIdentifier(actionKey: any, app: App): string;
9
+ getFunction(actionDeclaration: AppActionDeclaration): Promise<string>;
10
10
  }
@@ -4,94 +4,94 @@ import { ConfigPropertiesParser } from './app-template-parsers';
4
4
  import { getSeparatorByPlatform } from '../../common';
5
5
  import fs from 'fs';
6
6
  export class ActionsDeployer {
7
- async deployActions(appDeclaration, app) {
8
- // FETCH ALL ACTIONS FROM THE API.
9
- const existingActions = await this.getActionsForApp(app);
10
- // UPSERT / DELETE BASED ON ACTION IDENTIFIER
11
- console.log('%s \tDeploying actions.', chalk.yellow.bold('ACTION'));
12
- for (const actionKey of Object.keys(appDeclaration.actions)) {
13
- await this.deployAction(actionKey, appDeclaration.actions[actionKey], app, existingActions);
14
- }
7
+ async deployActions(appDeclaration, app) {
8
+ // FETCH ALL ACTIONS FROM THE API.
9
+ const existingActions = await this.getActionsForApp(app);
10
+ // UPSERT / DELETE BASED ON ACTION IDENTIFIER
11
+ console.log('%s \tDeploying actions.', chalk.yellow.bold('ACTION'));
12
+ for (const actionKey of Object.keys(appDeclaration.actions)) {
13
+ await this.deployAction(actionKey, appDeclaration.actions[actionKey], app, existingActions);
15
14
  }
16
- async getActionsForApp(app) {
17
- return await new Entities().get({
18
- entityName: 'event-workflow-action-definition',
19
- criteria: { ownerKey: `app:${app.id}` },
20
- });
15
+ }
16
+ async getActionsForApp(app) {
17
+ return await new Entities().get({
18
+ entityName: 'event-workflow-action-definition',
19
+ criteria: { ownerKey: `app:${app.id}` },
20
+ });
21
+ }
22
+ async deployAction(actionKey, actionDeclaration, app, existingActions) {
23
+ console.log(`%s \tDeploying action: ${actionKey}`, chalk.yellow.bold('ACTION'));
24
+ const identifier = this.getActionDeclarationIdentifier(actionKey, app);
25
+ const existingDefinition = existingActions.find(ad => ad.identifier === identifier);
26
+ if (!existingDefinition) {
27
+ await this.createNewActionDefinition(actionKey, actionDeclaration, app);
21
28
  }
22
- async deployAction(actionKey, actionDeclaration, app, existingActions) {
23
- console.log(`%s \tDeploying action: ${actionKey}`, chalk.yellow.bold('ACTION'));
24
- const identifier = this.getActionDeclarationIdentifier(actionKey, app);
25
- const existingDefinition = existingActions.find(ad => ad.identifier === identifier);
26
- if (!existingDefinition) {
27
- await this.createNewActionDefinition(actionKey, actionDeclaration, app);
28
- }
29
- else {
30
- await this.updateActionDefinition(existingDefinition, actionDeclaration);
31
- }
29
+ else {
30
+ await this.updateActionDefinition(existingDefinition, actionDeclaration);
32
31
  }
33
- async createNewActionDefinition(actionKey, actionDeclaration, app) {
34
- let configProperties;
35
- if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
36
- configProperties = ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
37
- }
38
- const newObject = {
39
- identifier: this.getActionDeclarationIdentifier(actionKey, app),
40
- name: actionDeclaration.name,
41
- ownerKey: `app:${app.id}`,
42
- public: app.public,
43
- configProperties,
44
- };
45
- const functionString = await this.getFunction(actionDeclaration);
46
- if (functionString) {
47
- newObject.executeFunctionString = functionString;
48
- }
49
- const actionDefinition = await new Entities().create({
50
- entityName: 'event-workflow-action-definition',
51
- object: newObject,
52
- });
53
- console.log(`%s Created new action definition: ${actionKey}`, chalk.yellow.bold('APP'));
54
- return actionDefinition;
32
+ }
33
+ async createNewActionDefinition(actionKey, actionDeclaration, app) {
34
+ let configProperties;
35
+ if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
36
+ configProperties = ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
55
37
  }
56
- async updateActionDefinition(existingActionDefinition, actionDeclaration) {
57
- let configProperties;
58
- if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
59
- configProperties = ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
60
- }
61
- else if (!(actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) && existingActionDefinition.configProperties) {
62
- configProperties = null;
63
- }
64
- const updates = {
65
- name: actionDeclaration.name,
66
- // public: actionDeclaration.public, // TODO - an actions visibility is allowed to change
67
- configProperties,
68
- };
69
- const functionString = await this.getFunction(actionDeclaration);
70
- if (functionString) {
71
- updates.executeFunctionString = functionString;
72
- }
73
- const actionDefinition = await new Entities().update({
74
- entityName: 'event-workflow-action-definition',
75
- id: existingActionDefinition.id,
76
- object: updates,
77
- });
78
- console.log(`%s Updated existing action definition: ${actionDefinition.identifier}`, chalk.yellow.bold('APP'));
79
- return actionDefinition;
38
+ const newObject = {
39
+ identifier: this.getActionDeclarationIdentifier(actionKey, app),
40
+ name: actionDeclaration.name,
41
+ ownerKey: `app:${app.id}`,
42
+ public: app.public,
43
+ configProperties,
44
+ };
45
+ const functionString = await this.getFunction(actionDeclaration);
46
+ if (functionString) {
47
+ newObject.executeFunctionString = functionString;
80
48
  }
81
- getActionDeclarationIdentifier(actionKey, app) {
82
- return app.identifier + ':' + actionKey;
49
+ const actionDefinition = await new Entities().create({
50
+ entityName: 'event-workflow-action-definition',
51
+ object: newObject,
52
+ });
53
+ console.log(`%s Created new action definition: ${actionKey}`, chalk.yellow.bold('APP'));
54
+ return actionDefinition;
55
+ }
56
+ async updateActionDefinition(existingActionDefinition, actionDeclaration) {
57
+ let configProperties;
58
+ if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
59
+ configProperties = ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
83
60
  }
84
- async getFunction(actionDeclaration) {
85
- if (!actionDeclaration.handler) {
86
- return;
87
- }
88
- if (!actionDeclaration.handler.endsWith('.js')) {
89
- throw new Error('Action handler must be a .js file.');
90
- }
91
- const CURRENT_DIR = process.cwd();
92
- const separator = getSeparatorByPlatform();
93
- const functionLocation = CURRENT_DIR + separator + actionDeclaration.handler;
94
- const content = fs.readFileSync(functionLocation);
95
- return content.toString();
61
+ else if (!(actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) && existingActionDefinition.configProperties) {
62
+ configProperties = null;
96
63
  }
64
+ const updates = {
65
+ name: actionDeclaration.name,
66
+ // public: actionDeclaration.public, // TODO - an actions visibility is allowed to change
67
+ configProperties,
68
+ };
69
+ const functionString = await this.getFunction(actionDeclaration);
70
+ if (functionString) {
71
+ updates.executeFunctionString = functionString;
72
+ }
73
+ const actionDefinition = await new Entities().update({
74
+ entityName: 'event-workflow-action-definition',
75
+ id: existingActionDefinition.id,
76
+ object: updates,
77
+ });
78
+ console.log(`%s Updated existing action definition: ${actionDefinition.identifier}`, chalk.yellow.bold('APP'));
79
+ return actionDefinition;
80
+ }
81
+ getActionDeclarationIdentifier(actionKey, app) {
82
+ return app.identifier + ':' + actionKey;
83
+ }
84
+ async getFunction(actionDeclaration) {
85
+ if (!actionDeclaration.handler) {
86
+ return;
87
+ }
88
+ if (!actionDeclaration.handler.endsWith('.js')) {
89
+ throw new Error('Action handler must be a .js file.');
90
+ }
91
+ const CURRENT_DIR = process.cwd();
92
+ const separator = getSeparatorByPlatform();
93
+ const functionLocation = CURRENT_DIR + separator + actionDeclaration.handler;
94
+ const content = fs.readFileSync(functionLocation);
95
+ return content.toString();
96
+ }
97
97
  }
@@ -53,10 +53,10 @@ export interface App {
53
53
  triggerKeyDefinitions?: TriggerKeyDefinition[];
54
54
  }
55
55
  export declare class ConfigProperty {
56
- slug: string;
57
- propertyType: string;
58
- options?: any[];
59
- label: string;
56
+ slug: string;
57
+ propertyType: string;
58
+ options?: any[];
59
+ label: string;
60
60
  }
61
61
  export interface EventWorkflowActionDefinition {
62
62
  id?: string;
@@ -69,8 +69,8 @@ export interface EventWorkflowActionDefinition {
69
69
  isDockerBased?: boolean;
70
70
  }
71
71
  export declare class TriggerKeyDefinition {
72
- name: string;
73
- description?: string;
74
- triggerKey: string;
75
- external?: boolean;
72
+ name: string;
73
+ description?: string;
74
+ triggerKey: string;
75
+ external?: boolean;
76
76
  }
@@ -53,7 +53,7 @@ export class WorkflowDefinitionDeployer {
53
53
  }
54
54
  async populateActionIds(workflowDefinition, app) {
55
55
  var _a;
56
- let availableAppActions = await getActionsForApp(app);
56
+ const availableAppActions = await getActionsForApp(app);
57
57
  if (!((_a = workflowDefinition.workflowDefinition) === null || _a === void 0 ? void 0 : _a.paths)) {
58
58
  return;
59
59
  }
@@ -1,10 +1,10 @@
1
1
  import { App, AppDeclaration, WorkflowTemplateDeclaration } from './interfaces';
2
2
  export declare class WorkflowDeployer {
3
- deployWorkflows(appDeclaration: AppDeclaration, app: App): Promise<void>;
4
- getWorkflowsForApp(app: App): Promise<any>;
5
- deployWorkflow(workflowKey: string, workflow: WorkflowTemplateDeclaration, app: App, existingWorkflows: Array<any>, appDeclaration: AppDeclaration): Promise<any>;
6
- private createNewWorkflowDefinition;
7
- private populateActionIds;
8
- private updateWorkflowDefinition;
9
- getWorkflowDeclarationIdentifier(actionKey: any, app: App): string;
3
+ deployWorkflows(appDeclaration: AppDeclaration, app: App): Promise<void>;
4
+ getWorkflowsForApp(app: App): Promise<any>;
5
+ deployWorkflow(workflowKey: string, workflow: WorkflowTemplateDeclaration, app: App, existingWorkflows: Array<any>, appDeclaration: AppDeclaration): Promise<any>;
6
+ private createNewWorkflowDefinition;
7
+ private populateActionIds;
8
+ private updateWorkflowDefinition;
9
+ getWorkflowDeclarationIdentifier(actionKey: any, app: App): string;
10
10
  }
@@ -2,86 +2,86 @@ import { Entities } from '@contrail/sdk';
2
2
  import chalk from 'chalk';
3
3
  import { getActionDeclarationIdentifier, getActionsForApp } from './actions-deployer';
4
4
  export class WorkflowDeployer {
5
- async deployWorkflows(appDeclaration, app) {
6
- // FETCH ALL WORKFLOWS FROM THE API.
7
- const existingWorkflows = await this.getWorkflowsForApp(app);
8
- // UPSERT / DELETE BASED ON WORKFLOW IDENTIFIER
9
- console.log('%s \tDeploying workflows.', chalk.yellow.bold('WORKFLOW'));
10
- for (const workflowKey of Object.keys(appDeclaration.workflows)) {
11
- await this.deployWorkflow(workflowKey, appDeclaration.workflows[workflowKey], app, existingWorkflows, appDeclaration);
12
- }
13
- }
14
- async getWorkflowsForApp(app) {
15
- return await new Entities().get({
16
- entityName: 'event-workflow-template',
17
- criteria: { ownerKey: `app:${app.id}` },
18
- });
5
+ async deployWorkflows(appDeclaration, app) {
6
+ // FETCH ALL WORKFLOWS FROM THE API.
7
+ const existingWorkflows = await this.getWorkflowsForApp(app);
8
+ // UPSERT / DELETE BASED ON WORKFLOW IDENTIFIER
9
+ console.log('%s \tDeploying workflows.', chalk.yellow.bold('WORKFLOW'));
10
+ for (const workflowKey of Object.keys(appDeclaration.workflows)) {
11
+ await this.deployWorkflow(workflowKey, appDeclaration.workflows[workflowKey], app, existingWorkflows, appDeclaration);
19
12
  }
20
- async deployWorkflow(workflowKey, workflow, app, existingWorkflows, appDeclaration) {
21
- console.log(`%s \tDeploying workflow: ${workflowKey}`, chalk.yellow.bold('WORKFLOW'));
22
- const identifier = this.getWorkflowDeclarationIdentifier(workflowKey, app);
23
- const existingDefinition = existingWorkflows.find(ad => ad.identifier === identifier);
24
- if (existingDefinition) {
25
- return await this.updateWorkflowDefinition(existingDefinition, workflow, app, appDeclaration);
26
- }
27
- return await this.createNewWorkflowDefinition(workflowKey, workflow, app, appDeclaration);
13
+ }
14
+ async getWorkflowsForApp(app) {
15
+ return await new Entities().get({
16
+ entityName: 'event-workflow-template',
17
+ criteria: { ownerKey: `app:${app.id}` },
18
+ });
19
+ }
20
+ async deployWorkflow(workflowKey, workflow, app, existingWorkflows, appDeclaration) {
21
+ console.log(`%s \tDeploying workflow: ${workflowKey}`, chalk.yellow.bold('WORKFLOW'));
22
+ const identifier = this.getWorkflowDeclarationIdentifier(workflowKey, app);
23
+ const existingDefinition = existingWorkflows.find(ad => ad.identifier === identifier);
24
+ if (existingDefinition) {
25
+ return await this.updateWorkflowDefinition(existingDefinition, workflow, app, appDeclaration);
28
26
  }
29
- async createNewWorkflowDefinition(workflowKey, workflowDeclaration, app, appDeclaration) {
30
- await this.populateActionIds(workflowDeclaration, appDeclaration, app);
31
- const newObject = {
32
- identifier: this.getWorkflowDeclarationIdentifier(workflowKey, app),
33
- name: workflowDeclaration.name,
34
- ownerKey: `app:${app.id}`,
35
- triggerKey: workflowDeclaration.triggerKey,
36
- workflowDefinition: workflowDeclaration.workflowDefinition,
37
- isActive: workflowDeclaration.isActive,
38
- supportingAppId: workflowDeclaration.supportingAppId,
39
- messageGroupId: workflowDeclaration.messageGroupId,
40
- parallelWorkerCount: workflowDeclaration.parallelWorkerCount,
41
- };
42
- const workflowTemplate = await new Entities().create({
43
- entityName: 'event-workflow-template',
44
- object: newObject,
45
- });
46
- console.log(`%s Created new workflow definition: ${workflowKey}`, chalk.yellow.bold('WORKFLOW'));
47
- return workflowTemplate;
27
+ return await this.createNewWorkflowDefinition(workflowKey, workflow, app, appDeclaration);
28
+ }
29
+ async createNewWorkflowDefinition(workflowKey, workflowDeclaration, app, appDeclaration) {
30
+ await this.populateActionIds(workflowDeclaration, appDeclaration, app);
31
+ const newObject = {
32
+ identifier: this.getWorkflowDeclarationIdentifier(workflowKey, app),
33
+ name: workflowDeclaration.name,
34
+ ownerKey: `app:${app.id}`,
35
+ triggerKey: workflowDeclaration.triggerKey,
36
+ workflowDefinition: workflowDeclaration.workflowDefinition,
37
+ isActive: workflowDeclaration.isActive,
38
+ supportingAppId: workflowDeclaration.supportingAppId,
39
+ messageGroupId: workflowDeclaration.messageGroupId,
40
+ parallelWorkerCount: workflowDeclaration.parallelWorkerCount,
41
+ };
42
+ const workflowTemplate = await new Entities().create({
43
+ entityName: 'event-workflow-template',
44
+ object: newObject,
45
+ });
46
+ console.log(`%s Created new workflow definition: ${workflowKey}`, chalk.yellow.bold('WORKFLOW'));
47
+ return workflowTemplate;
48
+ }
49
+ async populateActionIds(workflowDeclaration, appDeclaration, app) {
50
+ var _a;
51
+ let availableAppActions = await getActionsForApp(app);
52
+ if (!((_a = workflowDeclaration.workflowDefinition) === null || _a === void 0 ? void 0 : _a.paths)) {
53
+ return;
48
54
  }
49
- async populateActionIds(workflowDeclaration, appDeclaration, app) {
50
- var _a;
51
- let availableAppActions = await getActionsForApp(app);
52
- if (!((_a = workflowDeclaration.workflowDefinition) === null || _a === void 0 ? void 0 : _a.paths)) {
53
- return;
55
+ for (const path of workflowDeclaration.workflowDefinition.paths) {
56
+ if (!(path === null || path === void 0 ? void 0 : path.actionDefinitionConfigs)) {
57
+ continue;
58
+ }
59
+ for (const actionConfiguration of path.actionDefinitionConfigs) {
60
+ const actionKey = actionConfiguration.action;
61
+ const action = availableAppActions.find(action => action.identifier === getActionDeclarationIdentifier(actionKey, app));
62
+ if (!action) {
63
+ throw new Error(`Could not find action ${actionKey} declared in ${workflowDeclaration.name}`);
54
64
  }
55
- for (const path of workflowDeclaration.workflowDefinition.paths) {
56
- if (!(path === null || path === void 0 ? void 0 : path.actionDefinitionConfigs)) {
57
- continue;
58
- }
59
- for (const actionConfiguration of path.actionDefinitionConfigs) {
60
- const actionKey = actionConfiguration.action;
61
- const action = availableAppActions.find(action => action.identifier === getActionDeclarationIdentifier(actionKey, app));
62
- if (!action) {
63
- throw new Error(`Could not find action ${actionKey} declared in ${workflowDeclaration.name}`);
64
- }
65
- actionConfiguration.id = action.id;
66
- }
67
- }
68
- }
69
- async updateWorkflowDefinition(existingWorkflowDefinition, workflowDeclaration, app, appDeclaration) {
70
- await this.populateActionIds(workflowDeclaration, appDeclaration, app);
71
- const updates = Object.assign(new Object(), {
72
- name: workflowDeclaration.name,
73
- triggerKey: workflowDeclaration.triggerKey,
74
- workflowDefinition: workflowDeclaration.workflowDefinition
75
- });
76
- const updatedWorkflowDefinition = await new Entities().update({
77
- entityName: 'event-workflow-template',
78
- id: existingWorkflowDefinition.id,
79
- object: updates,
80
- });
81
- console.log(`%s Updated existing workflow definition: ${updatedWorkflowDefinition.identifier}`, chalk.yellow.bold('WORKFLOW'));
82
- return updatedWorkflowDefinition;
83
- }
84
- getWorkflowDeclarationIdentifier(actionKey, app) {
85
- return app.identifier + ':' + actionKey;
65
+ actionConfiguration.id = action.id;
66
+ }
86
67
  }
68
+ }
69
+ async updateWorkflowDefinition(existingWorkflowDefinition, workflowDeclaration, app, appDeclaration) {
70
+ await this.populateActionIds(workflowDeclaration, appDeclaration, app);
71
+ const updates = Object.assign(new Object(), {
72
+ name: workflowDeclaration.name,
73
+ triggerKey: workflowDeclaration.triggerKey,
74
+ workflowDefinition: workflowDeclaration.workflowDefinition
75
+ });
76
+ const updatedWorkflowDefinition = await new Entities().update({
77
+ entityName: 'event-workflow-template',
78
+ id: existingWorkflowDefinition.id,
79
+ object: updates,
80
+ });
81
+ console.log(`%s Updated existing workflow definition: ${updatedWorkflowDefinition.identifier}`, chalk.yellow.bold('WORKFLOW'));
82
+ return updatedWorkflowDefinition;
83
+ }
84
+ getWorkflowDeclarationIdentifier(actionKey, app) {
85
+ return app.identifier + ':' + actionKey;
86
+ }
87
87
  }
package/lib/auth/login.js CHANGED
@@ -8,13 +8,13 @@ const CONFIGURATION = {
8
8
  clientId: process.env.CONTRAIL_COGNITO_CLIENT_ID || '2oubek96sue5rsncovtqhs3scm',
9
9
  };
10
10
  export async function authUser() {
11
- console.debug("authorizing user");
11
+ console.debug('authorizing user');
12
12
  const config = await getConfig();
13
13
  if (config &&
14
14
  config.apiUserToken &&
15
15
  config.apiGateway &&
16
16
  config.orgSlug) {
17
- console.debug("populating auth config from fs config");
17
+ console.debug('populating auth config from fs config');
18
18
  Auth.config = {
19
19
  apiUserToken: config.apiUserToken,
20
20
  apiGateway: config.apiGateway,
@@ -25,7 +25,7 @@ export async function authUser() {
25
25
  return await refreshCurrentUserOrg();
26
26
  }
27
27
  catch (e) {
28
- console.log("Token expired. Requesting auth credentials...");
28
+ console.log('Token expired. Requesting auth credentials...');
29
29
  }
30
30
  }
31
31
  const questions = [];
@@ -120,11 +120,11 @@ async function setAuthContext(user, params) {
120
120
  return refreshCurrentUserOrg();
121
121
  }
122
122
  async function refreshCurrentUserOrg() {
123
- console.debug("refreshing current user org");
123
+ console.debug('refreshing current user org');
124
124
  const currentUser = await Request.request('/users/current', {
125
125
  method: 'GET',
126
126
  headers: {
127
- 'Accept': 'application/json',
127
+ Accept: 'application/json',
128
128
  'Content-Type': 'application/json',
129
129
  },
130
130
  });
package/lib/cli.js CHANGED
@@ -6,7 +6,7 @@ import { UploadOptionSets } from './types/option-set-uploader';
6
6
  import { ParseOptionSetsLocalFiles } from './types/option-set-parser';
7
7
  import { MergeOptionSets } from './types/option-set-merger';
8
8
  import { MergeTypeProperties } from './types/types-properties-merger';
9
- import { ParseTypesFromFiles, ParseTypesFromLocalFiles } from './types/parse-types';
9
+ import { ParseTypesFromFiles, ParseTypesFromLocalFiles, ParseTypesFromTemplateFromLocalFiles } from './types/parse-types';
10
10
  import { loadColors, deleteColors } from './colors/color-loader';
11
11
  import { listConfig, removeConfig } from './config/configCommands';
12
12
  import { deleteWorkflowTemplate, deployWorkflowTemplate, listWorkflowTemplate } from './workflows/workflowCommands';
@@ -62,7 +62,7 @@ export async function cli(args) {
62
62
  break;
63
63
  }
64
64
  case 'uploadTypes': {
65
- uploadTypes(args);
65
+ uploadTypes();
66
66
  break;
67
67
  }
68
68
  case 'uploadOptionSets': {
@@ -77,6 +77,10 @@ export async function cli(args) {
77
77
  ParseTypesFromLocalFiles(args);
78
78
  break;
79
79
  }
80
+ case 'parseTypesFromTemplateFromLocalFiles': {
81
+ ParseTypesFromTemplateFromLocalFiles(args);
82
+ break;
83
+ }
80
84
  case 'parseTypesFromFiles': {
81
85
  ParseTypesFromFiles(args);
82
86
  break;
@@ -200,6 +204,7 @@ const helpSections = [
200
204
  content: [
201
205
  'load Load colors from a CSV. Headers (name, hex, red,',
202
206
  '. green, blue) are required.',
207
+ // 'delete Delete all colors.',
203
208
  ],
204
209
  },
205
210
  {
@@ -221,6 +226,8 @@ const helpSections = [
221
226
  'parseOptionSetsLocalFiles <File Paths> Parse CSV files into OptionSets',
222
227
  'parseTypesFromLocalFiles <File Paths> Parse CSV files into Types and ',
223
228
  '. OptionSets from local files.\n',
229
+ 'parseTypesFromTemplateFromLocalFiles <File Paths> Parse CSV files into ',
230
+ '. Types and OptionSets from local files.\n',
224
231
  'parseTypesFromFiles <fileIds> Parse CSV files into Types and ',
225
232
  '. OptionSets from VibeIQ Files.\n',
226
233
  'mergeOptionSets <File Path> Merge the OptionSets from an existing',