@contrail/cli 1.0.31 → 1.0.33

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 (42) 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/workflow-definition-deployer.js +1 -1
  6. package/lib/auth/login.js +5 -5
  7. package/lib/cli.js +2 -1
  8. package/lib/colors/color-loader.js +8 -8
  9. package/lib/config/config.js +2 -2
  10. package/lib/interfaces.d.ts +2 -2
  11. package/lib/types/interfaces.js +1 -0
  12. package/lib/types/option-set-merger.js +2 -2
  13. package/lib/types/option-set-parser.js +2 -2
  14. package/lib/types/option-set-uploader.js +2 -2
  15. package/lib/types/parse-types.js +6 -6
  16. package/lib/types/types-extractor.js +4 -4
  17. package/lib/types/types-properties-merger.js +2 -2
  18. package/lib/types/types-uploader.d.ts +1 -1
  19. package/lib/types/types-uploader.js +6 -6
  20. package/package.json +8 -6
  21. package/src/apps/deploy-app/actions-deployer.ts +17 -10
  22. package/src/apps/deploy-app/app-deployer.ts +3 -4
  23. package/src/apps/deploy-app/workflow-definition-deployer.ts +3 -3
  24. package/src/auth/login.ts +124 -124
  25. package/src/cli.ts +115 -115
  26. package/src/colors/color-loader.ts +16 -16
  27. package/src/config/config.ts +9 -11
  28. package/src/config/configCommands.ts +1 -1
  29. package/src/interfaces.ts +9 -10
  30. package/src/types/csv-parser.ts +1 -1
  31. package/src/types/option-set-merger.ts +9 -9
  32. package/src/types/option-set-parser.ts +5 -6
  33. package/src/types/option-set-uploader.ts +2 -2
  34. package/src/types/parse-types.ts +9 -9
  35. package/src/types/types-extractor.ts +5 -5
  36. package/src/types/types-properties-merger.ts +6 -6
  37. package/src/types/types-uploader.ts +31 -31
  38. package/src/workflows/workflow-template-deployer.ts +2 -4
  39. package/src/workflows/workflowCommands.ts +0 -1
  40. package/templates/javascript/actions/example/action.js +37 -37
  41. package/templates/typescript/actions/exampleAction.ts +1 -1
  42. 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;
@@ -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
  }
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
@@ -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': {
@@ -204,6 +204,7 @@ const helpSections = [
204
204
  content: [
205
205
  'load Load colors from a CSV. Headers (name, hex, red,',
206
206
  '. green, blue) are required.',
207
+ // 'delete Delete all colors.',
207
208
  ],
208
209
  },
209
210
  {
@@ -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'));
@@ -12,11 +12,11 @@ export async function ParseTypesFromLocalFiles(args) {
12
12
  if ((args === null || args === void 0 ? void 0 : args.length) < 4) {
13
13
  throw new Error('File names must be included.');
14
14
  }
15
- console.log(`%s Parsing`, chalk.yellow.bold('TYPES AND OPTION SETS'));
15
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
16
16
  const fileLocations = args.slice(3);
17
17
  console.log('Using File Location(s): ', fileLocations);
18
18
  await parseTypesFromLocalFiles(fileLocations);
19
- console.log(`%s Parsed`, chalk.yellow.bold('TYPES AND OPTION SETS'));
19
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
20
20
  }
21
21
  catch (e) {
22
22
  console.log(`%s Parsing Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -30,11 +30,11 @@ export async function ParseTypesFromFiles(args) {
30
30
  if ((args === null || args === void 0 ? void 0 : args.length) < 4) {
31
31
  throw new Error('File ids must be included.');
32
32
  }
33
- console.log(`%s Parsing`, chalk.yellow.bold('TYPES AND OPTION SETS'));
33
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
34
34
  const fileIds = args.slice(3);
35
35
  console.log('Using FileId(s): ', fileIds);
36
36
  await parseTypesFromFiles(fileIds);
37
- console.log(`%s Parsed`, chalk.yellow.bold('TYPES AND OPTION SETS'));
37
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
38
38
  }
39
39
  catch (e) {
40
40
  console.log(`%s Parsing Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -48,13 +48,13 @@ export async function ParseTypesFromTemplateFromLocalFiles(args) {
48
48
  if ((args === null || args === void 0 ? void 0 : args.length) < 5) {
49
49
  throw new Error('File names must be included.');
50
50
  }
51
- console.log(`%s Parsing`, chalk.yellow.bold('TYPES AND OPTION SETS'));
51
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
52
52
  const templateFileLocation = args[3];
53
53
  const dataFileLocation = args[4];
54
54
  console.log('Using Template File Location: ', templateFileLocation);
55
55
  console.log('Using Data File Location: ', dataFileLocation);
56
56
  await parseTypesFromTemplateFromLocalFiles(templateFileLocation, dataFileLocation);
57
- console.log(`%s Parsed`, chalk.yellow.bold('TYPES AND OPTION SETS'));
57
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
58
58
  }
59
59
  catch (e) {
60
60
  console.log(`%s Parsing Failed. ${e}`, chalk.red.bold('FAIL'));
@@ -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.31",
3
+ "version": "1.0.33",
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.69",
27
+ "@contrail/types": "^2.0.70",
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'));