@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
@@ -7,7 +7,7 @@ export async function deleteColors() {
7
7
  try {
8
8
  await authUser();
9
9
  const colors = await getExistingColors();
10
- console.log("Deleting %s colors", colors.length);
10
+ console.log('Deleting %s colors', colors.length);
11
11
  for (const color of colors) {
12
12
  await deleteColor(color);
13
13
  }
@@ -21,10 +21,10 @@ export async function deleteColors() {
21
21
  export async function loadColors() {
22
22
  try {
23
23
  await authUser();
24
- console.log(`%s Getting Existing Colors`, chalk.yellow.bold('COLORS'));
25
- console.log(`%s Uploading`, chalk.yellow.bold('COLORS'));
24
+ console.log('%s Getting Existing Colors', chalk.yellow.bold('COLORS'));
25
+ console.log('%s Uploading', chalk.yellow.bold('COLORS'));
26
26
  await uploadColors();
27
- console.log(`%s Uploaded`, chalk.yellow.bold('COLORS'));
27
+ console.log('%s Uploaded', chalk.yellow.bold('COLORS'));
28
28
  }
29
29
  catch (e) {
30
30
  console.log(`%s Loading Colors Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -33,7 +33,7 @@ export async function loadColors() {
33
33
  console.log('%s Loading Colors Complete.', chalk.green.bold('COMPLETE'));
34
34
  }
35
35
  async function getLocalColors() {
36
- console.log("loading colors from local file");
36
+ console.log('loading colors from local file');
37
37
  const TARGET_DIR = process.cwd();
38
38
  try {
39
39
  const separator = getSeparatorByPlatform();
@@ -45,10 +45,10 @@ async function getLocalColors() {
45
45
  }
46
46
  }
47
47
  async function getExistingColors() {
48
- console.log(`%s Getting Existing Colors`, chalk.yellow.bold('COLORS'));
48
+ console.log('%s Getting Existing Colors', chalk.yellow.bold('COLORS'));
49
49
  try {
50
50
  const result = await new Entities().get({ entityName: 'color', take: 3000 }); //, useSearch: false }); Not in EntitiesClientGetOptions yet
51
- console.log("Found %s existing colors", result.length);
51
+ console.log('Found %s existing colors', result.length);
52
52
  return result;
53
53
  }
54
54
  catch (e) {
@@ -69,7 +69,7 @@ async function uploadColors() {
69
69
  const existingNamesValues = existingColors.filter(x => x.name).map(x => x.name);
70
70
  for (const color of colors) {
71
71
  if (existingNamesValues.includes(color.name)) {
72
- console.log(`%s SKIPPING %s (%s)`, chalk.yellow.bold('COLORS'), color.hex, color.name);
72
+ console.log('%s SKIPPING %s (%s)', chalk.yellow.bold('COLORS'), color.hex, color.name);
73
73
  continue;
74
74
  }
75
75
  if (color.hex.length > 1 && color.hex[0] === '#') {
@@ -9,7 +9,7 @@ export async function initializeVibeIQConfig() {
9
9
  await fsPromises.mkdir(configDirectoryLocation, { recursive: true });
10
10
  }
11
11
  catch (e) {
12
- console.error("could not initialize vibeiq directory");
12
+ console.error('could not initialize vibeiq directory');
13
13
  throw e;
14
14
  }
15
15
  try {
@@ -48,7 +48,7 @@ export async function writeVibeIQConfig(config) {
48
48
  }
49
49
  }
50
50
  export async function getConfig() {
51
- console.debug("getting config from file system");
51
+ console.debug('getting config from file system');
52
52
  return await readVibeIQConfig();
53
53
  }
54
54
  export async function deleteConfigs(configNames) {
@@ -21,7 +21,6 @@ export interface AppDeclaration {
21
21
  workflows?: {
22
22
  [key: string]: WorkflowDefinition | WorkflowTemplateDeclaration;
23
23
  };
24
- isDockerBased?: boolean;
25
24
  dockerImageRef?: string;
26
25
  }
27
26
  export interface ConfigPropertyElements {
@@ -38,6 +37,7 @@ export interface AppActionDeclaration {
38
37
  name: string;
39
38
  description?: string;
40
39
  actionConfiguration?: ConfigPropertyElements;
40
+ async?: boolean;
41
41
  }
42
42
  export interface AppTriggerDeclaration {
43
43
  key: string;
@@ -116,7 +116,7 @@ export interface EventWorkflowActionDefinition {
116
116
  ownerKey?: string;
117
117
  public?: boolean;
118
118
  configProperties?: ConfigProperty[];
119
- isDockerBased?: boolean;
119
+ async?: boolean;
120
120
  }
121
121
  export declare class TriggerKeyDefinition {
122
122
  name: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -9,11 +9,11 @@ export async function MergeOptionSets(args) {
9
9
  if ((args === null || args === void 0 ? void 0 : args.length) < 4) {
10
10
  throw new Error('File name must be included.');
11
11
  }
12
- console.log(`%s Importing local file`, chalk.yellow.bold('OPTION SET MERGE'));
12
+ console.log('%s Importing local file', chalk.yellow.bold('OPTION SET MERGE'));
13
13
  const fileLocation = args[3];
14
14
  console.log('Using File: ', fileLocation);
15
15
  await mergeOptionSets(fileLocation);
16
- console.log(`%s Merged`, chalk.yellow.bold('OPTION SET MERGE'));
16
+ console.log('%s Merged', chalk.yellow.bold('OPTION SET MERGE'));
17
17
  }
18
18
  catch (e) {
19
19
  console.log(`%s Merge Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -9,11 +9,11 @@ export async function ParseOptionSetsLocalFiles(args) {
9
9
  if ((args === null || args === void 0 ? void 0 : args.length) < 4) {
10
10
  throw new Error('File name must be included.');
11
11
  }
12
- console.log(`%s Importing local file`, chalk.yellow.bold('OPTION SET PARSE'));
12
+ console.log('%s Importing local file', chalk.yellow.bold('OPTION SET PARSE'));
13
13
  const fileLocation = args[3];
14
14
  console.log('Using File: ', fileLocation);
15
15
  await parseOptionSetsLocalFiles(fileLocation);
16
- console.log(`%s Parsed`, chalk.yellow.bold('OPTION SET PARSE'));
16
+ console.log('%s Parsed', chalk.yellow.bold('OPTION SET PARSE'));
17
17
  }
18
18
  catch (e) {
19
19
  console.log(`%s PARSE Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -8,9 +8,9 @@ export async function UploadOptionSets(args) {
8
8
  try {
9
9
  const userConfig = await authUser();
10
10
  console.log(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk.blue.bold('START'));
11
- console.log(`%s Uploading`, chalk.yellow.bold('OPTION SETS'));
11
+ console.log('%s Uploading', chalk.yellow.bold('OPTION SETS'));
12
12
  await uploadOptionSets();
13
- console.log(`%s Uploaded`, chalk.yellow.bold('OPTION SETS'));
13
+ console.log('%s Uploaded', chalk.yellow.bold('OPTION SETS'));
14
14
  }
15
15
  catch (e) {
16
16
  console.log(`%s Types Upload Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -1,2 +1,3 @@
1
1
  export declare function ParseTypesFromLocalFiles(args: any): Promise<void>;
2
2
  export declare function ParseTypesFromFiles(args: any): Promise<void>;
3
+ export declare function ParseTypesFromTemplateFromLocalFiles(args: any): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { GetSuggestedTypes } from '@contrail/types';
1
+ import { GetSuggestedTypes, GetTypesFromTemplate } from '@contrail/types';
2
2
  import chalk from 'chalk';
3
3
  import fs from 'fs';
4
4
  import { getSeparatorByPlatform } from '../common';
@@ -6,16 +6,17 @@ import * as csvToJson from 'csvtojson';
6
6
  import { authUser } from '../auth/login';
7
7
  import { getCSVFromFile } from './csv-parser';
8
8
  const yaml = require('js-yaml');
9
+ // This uses local files to get the data to parse into types
9
10
  export async function ParseTypesFromLocalFiles(args) {
10
11
  try {
11
12
  if ((args === null || args === void 0 ? void 0 : args.length) < 4) {
12
13
  throw new Error('File names must be included.');
13
14
  }
14
- console.log(`%s Parsing`, chalk.yellow.bold('TYPES AND OPTION SETS'));
15
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
15
16
  const fileLocations = args.slice(3);
16
17
  console.log('Using File Location(s): ', fileLocations);
17
18
  await parseTypesFromLocalFiles(fileLocations);
18
- console.log(`%s Parsed`, chalk.yellow.bold('TYPES AND OPTION SETS'));
19
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
19
20
  }
20
21
  catch (e) {
21
22
  console.log(`%s Parsing Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -23,16 +24,37 @@ export async function ParseTypesFromLocalFiles(args) {
23
24
  }
24
25
  console.log('%s Parsing Complete.', chalk.green.bold('COMPLETE'));
25
26
  }
27
+ // This uses VibeIq file ids to get the data to parse into types
26
28
  export async function ParseTypesFromFiles(args) {
27
29
  try {
28
30
  if ((args === null || args === void 0 ? void 0 : args.length) < 4) {
29
31
  throw new Error('File ids must be included.');
30
32
  }
31
- console.log(`%s Parsing`, chalk.yellow.bold('TYPES AND OPTION SETS'));
33
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
32
34
  const fileIds = args.slice(3);
33
35
  console.log('Using FileId(s): ', fileIds);
34
36
  await parseTypesFromFiles(fileIds);
35
- console.log(`%s Parsed`, chalk.yellow.bold('TYPES AND OPTION SETS'));
37
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
38
+ }
39
+ catch (e) {
40
+ console.log(`%s Parsing Failed. ${e}`, chalk.red.bold('FAIL'));
41
+ return;
42
+ }
43
+ console.log('%s Parsing Complete.', chalk.green.bold('COMPLETE'));
44
+ }
45
+ // This uses local files to get type template file and the data file to parse into types
46
+ export async function ParseTypesFromTemplateFromLocalFiles(args) {
47
+ try {
48
+ if ((args === null || args === void 0 ? void 0 : args.length) < 5) {
49
+ throw new Error('File names must be included.');
50
+ }
51
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
52
+ const templateFileLocation = args[3];
53
+ const dataFileLocation = args[4];
54
+ console.log('Using Template File Location: ', templateFileLocation);
55
+ console.log('Using Data File Location: ', dataFileLocation);
56
+ await parseTypesFromTemplateFromLocalFiles(templateFileLocation, dataFileLocation);
57
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
36
58
  }
37
59
  catch (e) {
38
60
  console.log(`%s Parsing Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -46,7 +68,7 @@ async function loadDataFromLocalCSV(fileName) {
46
68
  const separator = getSeparatorByPlatform();
47
69
  const fullPath = CURRENT_DIR + separator + fileName;
48
70
  console.log('Getting file from path: ', fullPath);
49
- const csvData = await csvToJson.default().fromFile(fullPath);
71
+ const csvData = await csvToJson.default({ flatKeys: true }).fromFile(fullPath);
50
72
  return csvData;
51
73
  }
52
74
  catch (e) {
@@ -72,6 +94,25 @@ async function parseTypesFromLocalFiles(fileLocations) {
72
94
  saveData({ optionSets: suggestions.OptionSets }, 'parsed_optionSets.yml');
73
95
  saveData({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml');
74
96
  }
97
+ async function parseTypesFromTemplateFromLocalFiles(templateFileLocation, dataFileLocation) {
98
+ let templateCSVData = [];
99
+ let dataCSVData = [];
100
+ try {
101
+ console.log('Getting template from fileLocation: ', templateFileLocation);
102
+ templateCSVData = await loadDataFromLocalCSV(templateFileLocation);
103
+ console.log(`CSV import was successful. ${templateCSVData === null || templateCSVData === void 0 ? void 0 : templateCSVData.length} rows found.`);
104
+ console.log('Getting data from fileLocation: ', dataFileLocation);
105
+ dataCSVData = await loadDataFromLocalCSV(dataFileLocation);
106
+ console.log(`CSV import was successful. ${dataCSVData === null || dataCSVData === void 0 ? void 0 : dataCSVData.length} rows found.`);
107
+ }
108
+ catch (e) {
109
+ console.log('Error importing csv data.', e);
110
+ throw e;
111
+ }
112
+ const types = GetTypesFromTemplate(templateCSVData, dataCSVData);
113
+ saveData({ optionSets: types.OptionSets }, 'parsed_optionSets.yml');
114
+ saveData({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml');
115
+ }
75
116
  async function parseTypesFromFiles(fileIds) {
76
117
  await authUser();
77
118
  // get csv data
@@ -8,19 +8,19 @@ export async function getTypes(args) {
8
8
  try {
9
9
  const userConfig = await authUser();
10
10
  console.log(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk.blue.bold('START'));
11
- console.log(`%s Retrieving`, chalk.yellow.bold('OPTION SETS'));
11
+ console.log('%s Retrieving', chalk.yellow.bold('OPTION SETS'));
12
12
  const optionSets = await new Entities().get({
13
13
  entityName: 'type-property-option-set',
14
14
  });
15
15
  await getOptionSets(optionSets);
16
- console.log(`%s Retrieved`, chalk.yellow.bold('OPTION SETS'));
17
- console.log(`%s Retrieving`, chalk.yellow.bold('TYPES'));
16
+ console.log('%s Retrieved', chalk.yellow.bold('OPTION SETS'));
17
+ console.log('%s Retrieving', chalk.yellow.bold('TYPES'));
18
18
  const reducedTypes = await getReducedTypes(optionSets);
19
19
  const typesHolder = {
20
20
  types: reducedTypes,
21
21
  };
22
22
  saveData(typesHolder);
23
- console.log(`%s Retrieved`, chalk.yellow.bold('TYPES'));
23
+ console.log('%s Retrieved', chalk.yellow.bold('TYPES'));
24
24
  }
25
25
  catch (e) {
26
26
  console.log(`%s Types Retrieval Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -10,13 +10,13 @@ export async function MergeTypeProperties(args) {
10
10
  if ((args === null || args === void 0 ? void 0 : args.length) < 5) {
11
11
  throw new Error('File name must be included along with a type path.');
12
12
  }
13
- console.log(`%s Importing local file`, chalk.yellow.bold('TYPE PROPERTIES MERGE'));
13
+ console.log('%s Importing local file', chalk.yellow.bold('TYPE PROPERTIES MERGE'));
14
14
  const fileLocation = args[3];
15
15
  console.log('Using File: ', fileLocation);
16
16
  const typePaths = args.slice(4);
17
17
  console.log('Using TypePaths: ', typePaths);
18
18
  await mergeTypeProperties(fileLocation, typePaths);
19
- console.log(`%s Merged`, chalk.yellow.bold('TYPE PROPERTIES MERGE'));
19
+ console.log('%s Merged', chalk.yellow.bold('TYPE PROPERTIES MERGE'));
20
20
  }
21
21
  catch (e) {
22
22
  console.log(`%s Merge Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -1 +1 @@
1
- export declare function uploadTypes(args: any): Promise<void>;
1
+ export declare function uploadTypes(): Promise<void>;
@@ -4,14 +4,14 @@ import fs from 'fs';
4
4
  import { authUser } from '../auth/login';
5
5
  import { getSeparatorByPlatform } from '../common';
6
6
  import * as _ from 'lodash';
7
- const yaml = require('js-yaml');
8
- export async function uploadTypes(args) {
7
+ import yaml from 'js-yaml';
8
+ export async function uploadTypes() {
9
9
  try {
10
10
  const userConfig = await authUser();
11
11
  console.log(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk.blue.bold('START'));
12
- console.log(`%s Uploading`, chalk.yellow.bold('TYPES'));
12
+ console.log('%s Uploading', chalk.yellow.bold('TYPES'));
13
13
  await uploadReducedTypes();
14
- console.log(`%s Uploaded`, chalk.yellow.bold('TYPES'));
14
+ console.log('%s Uploaded', chalk.yellow.bold('TYPES'));
15
15
  }
16
16
  catch (e) {
17
17
  console.log(`%s Types Upload Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -146,7 +146,7 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
146
146
  validationFunction: newPropertyType.validationFunction,
147
147
  }),
148
148
  headers: {
149
- 'Accept': 'application/json',
149
+ Accept: 'application/json',
150
150
  'Content-Type': 'application/json',
151
151
  },
152
152
  });
@@ -186,7 +186,7 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
186
186
  await Request.request(`/types/${type.id}/type-properties/${currentPropertyType.id}`, {
187
187
  method: 'DELETE',
188
188
  headers: {
189
- 'Accept': 'application/json',
189
+ Accept: 'application/json',
190
190
  'Content-Type': 'application/json',
191
191
  },
192
192
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -17,14 +17,14 @@
17
17
  "scripts": {
18
18
  "build": "tsc",
19
19
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
20
- "lint": "tslint -p tsconfig.json",
20
+ "lint": "eslint . --fix",
21
21
  "test": "jest --watch"
22
22
  },
23
23
  "author": "",
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
26
  "@contrail/sdk": "^1.0.154",
27
- "@contrail/types": "^2.0.61",
27
+ "@contrail/types": "^2.0.69",
28
28
  "@contrail/util": "^1.0.17",
29
29
  "amazon-cognito-identity-js": "^5.2.3",
30
30
  "arg": "^4.0.1",
@@ -32,6 +32,7 @@
32
32
  "chalk": "^4.0.0",
33
33
  "command-line-usage": "^6.1.1",
34
34
  "csvtojson": "^2.0.10",
35
+ "eslint-plugin-unused-imports": "^2.0.0",
35
36
  "esm": "^3.2.25",
36
37
  "execa": "^5.0.0",
37
38
  "inquirer": "^8.2.0",
@@ -45,12 +46,13 @@
45
46
  "@types/jest": "^23.3.14",
46
47
  "@types/lodash": "^4.14.178",
47
48
  "@types/node": "^14.6.4",
49
+ "@typescript-eslint/eslint-plugin": "^5.32.0",
50
+ "@typescript-eslint/parser": "^5.32.0",
51
+ "eslint": "^8.21.0",
48
52
  "jest": "^29.3.1",
49
53
  "prettier": "^1.19.1",
50
54
  "ts-jest": "^29.0.3",
51
- "tslint": "^5.11.0",
52
- "tslint-config-prettier": "^1.18.0",
53
- "typescript": "^3.0.1"
55
+ "typescript": "^4.9.3"
54
56
  },
55
57
  "jest": {
56
58
  "moduleFileExtensions": [
@@ -6,7 +6,6 @@ import { getSeparatorByPlatform } from '../../common';
6
6
 
7
7
  import fs from 'fs';
8
8
 
9
-
10
9
  export async function getActionsForApp(app: App) {
11
10
  return await new Entities().get({
12
11
  entityName: 'event-workflow-action-definition',
@@ -14,16 +13,16 @@ export async function getActionsForApp(app: App) {
14
13
  });
15
14
  }
16
15
 
17
-
18
16
  export function getActionDeclarationIdentifier(actionKey, app: App) {
19
17
  return app.identifier + ':' + actionKey;
20
18
  }
21
19
 
22
- export async function deleteAction(actionId): Promise<any>{
20
+ export async function deleteAction(actionId): Promise<any> {
23
21
  return await new Entities().delete({ entityName: 'event-workflow-action-definition', id: actionId });
24
22
  }
25
23
 
26
24
  export class ActionsDeployer {
25
+
27
26
  async deployActions(appDeclaration: AppDeclaration, app: App) {
28
27
 
29
28
  // FETCH ALL ACTIONS FROM THE API.
@@ -31,16 +30,23 @@ export class ActionsDeployer {
31
30
 
32
31
  // UPSERT / DELETE BASED ON ACTION IDENTIFIER
33
32
  console.log('%s \tDeploying actions.', chalk.yellow.bold('ACTION'));
34
-
33
+ let appActionIdentifiers = [];
35
34
  if (appDeclaration.actions) {
36
- const localActions = Object.keys(appDeclaration.actions);
37
- if (localActions?.length > 0) {
38
- for (const actionKey of localActions) {
35
+ const localActionKeys = Object.keys(appDeclaration.actions);
36
+ appActionIdentifiers = localActionKeys.map(x => getActionDeclarationIdentifier(x, app));
37
+ if (localActionKeys?.length > 0) {
38
+ for (const actionKey of localActionKeys) {
39
39
  await this.deployAction(actionKey, appDeclaration.actions[actionKey], app, existingActions);
40
40
  }
41
41
  }
42
42
  }
43
+ const toDelete = existingActions.filter(x => !appActionIdentifiers.includes(x.identifier));
44
+ for (const action of toDelete) {
45
+ console.log(`%s \tDeleting action: ${action.identifier}`, chalk.yellow.bold('ACTION'));
46
+ await deleteAction(action.id);
47
+ }
43
48
  }
49
+
44
50
  async deployAction(actionKey: string, actionDeclaration: AppActionDeclaration, app: App, existingActions: Array<any>) {
45
51
  console.log(`%s \tDeploying action: ${actionKey}`, chalk.yellow.bold('ACTION'));
46
52
 
@@ -63,8 +69,9 @@ export class ActionsDeployer {
63
69
  identifier: getActionDeclarationIdentifier(actionKey, app),
64
70
  name: actionDeclaration.name,
65
71
  ownerKey: `app:${app.id}`,
66
- public: 'public' in actionDeclaration? actionDeclaration.public: app.public,
72
+ public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
67
73
  configProperties,
74
+ async: actionDeclaration.async,
68
75
  };
69
76
 
70
77
  const functionString = await this.getFunction(actionDeclaration);
@@ -94,8 +101,9 @@ export class ActionsDeployer {
94
101
 
95
102
  const updates: EventWorkflowActionDefinition = {
96
103
  name: actionDeclaration.name,
97
- public: 'public' in actionDeclaration? actionDeclaration.public: app.public,
104
+ public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
98
105
  configProperties,
106
+ async: actionDeclaration.async,
99
107
  };
100
108
 
101
109
  const functionString = await this.getFunction(actionDeclaration);
@@ -114,7 +122,6 @@ export class ActionsDeployer {
114
122
  return actionDefinition;
115
123
  }
116
124
 
117
-
118
125
  async getFunction(actionDeclaration: AppActionDeclaration): Promise<string> {
119
126
  if (!actionDeclaration.handler) {
120
127
  return;
@@ -10,10 +10,10 @@ export class AppDeployer {
10
10
  public async deploy(appDeclaration: AppDeclaration) {
11
11
  let app = await this.getExistingApp(appDeclaration);
12
12
  if (!app) {
13
- console.log(`%s Creating new app.`, chalk.yellow.bold('APP'));
13
+ console.log('%s Creating new app.', chalk.yellow.bold('APP'));
14
14
  app = await this.createNewApp(appDeclaration);
15
15
  } else {
16
- console.log(`%s Updating existing app.`, chalk.yellow.bold('APP'));
16
+ console.log('%s Updating existing app.', chalk.yellow.bold('APP'));
17
17
  app = await this.updateExistingApp(appDeclaration, app);
18
18
  }
19
19
  await new ActionsDeployer().deployActions(appDeclaration, app);
@@ -65,7 +65,6 @@ export class AppDeployer {
65
65
  keywords: appDeclaration.keywords,
66
66
  configProperties,
67
67
  triggerKeyDefinitions,
68
- isDockerBased: appDeclaration.isDockerBased,
69
68
  dockerImageRef: appDeclaration.dockerImageRef,
70
69
  };
71
70
  const app = await new Entities().create({ entityName: 'app', object: newApp });
@@ -105,7 +104,7 @@ export class AppDeployer {
105
104
  public async remove(appDeclaration: AppDeclaration) {
106
105
  let app = await this.getExistingApp(appDeclaration);
107
106
  if (app) {
108
- const actions = await getActionsForApp(app)
107
+ const actions = await getActionsForApp(app);
109
108
  for(const action of actions)
110
109
  {
111
110
  console.log(`%s Deleting action: ${action.identifier}`, chalk.yellow.bold('APP'));
@@ -1,7 +1,7 @@
1
1
  import { Entities } from '@contrail/sdk';
2
2
  import chalk from 'chalk';
3
3
  import { App, AppDeclaration, WorkflowDefinition } from '../../interfaces';
4
- import { getActionDeclarationIdentifier, getActionsForApp } from './actions-deployer'
4
+ import { getActionDeclarationIdentifier, getActionsForApp } from './actions-deployer';
5
5
 
6
6
  export class WorkflowDefinitionDeployer {
7
7
  async deployWorkflowDefinitions(appDeclaration: AppDeclaration, app: App) {
@@ -70,7 +70,7 @@ export class WorkflowDefinitionDeployer {
70
70
  }
71
71
 
72
72
  private async populateActionIds(workflowDefinition: WorkflowDefinition, app: App) {
73
- let availableAppActions = await getActionsForApp(app);
73
+ const availableAppActions = await getActionsForApp(app);
74
74
  if (!workflowDefinition.workflowDefinition?.paths) {
75
75
  return;
76
76
  }
@@ -82,7 +82,7 @@ export class WorkflowDefinitionDeployer {
82
82
  const actionKey = actionConfiguration.action;
83
83
  const action = availableAppActions.find(
84
84
  action => action.identifier === getActionDeclarationIdentifier(actionKey, app)
85
- )
85
+ );
86
86
  if (!action) {
87
87
  throw new Error(`Could not find action ${actionKey} declared in workflow definition ${workflowDefinition.name}`);
88
88
  }