@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
@@ -1,4 +1,4 @@
1
- import { readFileSync, access, promises as fsPromises, write } from 'fs';
1
+ import { promises as fsPromises } from 'fs';
2
2
  import { join } from 'path';
3
3
  import {homedir} from 'os';
4
4
  const userHomeDir = homedir();
@@ -7,16 +7,16 @@ const configFileLocation = join(configDirectoryLocation, 'config.json');
7
7
 
8
8
  export async function initializeVibeIQConfig() {
9
9
  try{
10
- await fsPromises.mkdir(configDirectoryLocation, {recursive: true})
10
+ await fsPromises.mkdir(configDirectoryLocation, {recursive: true});
11
11
  } catch (e) {
12
- console.error("could not initialize vibeiq directory")
13
- throw e
12
+ console.error('could not initialize vibeiq directory');
13
+ throw e;
14
14
  }
15
15
 
16
16
  try {
17
17
  await fsPromises.writeFile(configFileLocation, '{}');
18
18
  } catch (e) {
19
- console.error(`could not initialize config file (${configFileLocation}).`)
19
+ console.error(`could not initialize config file (${configFileLocation}).`);
20
20
  throw e;
21
21
  }
22
22
  }
@@ -38,18 +38,17 @@ export async function readVibeIQConfig() {
38
38
  }
39
39
  }
40
40
 
41
-
42
41
  export async function writeVibeIQConfig(config: Object) {
43
42
  try {
44
43
  await fsPromises.writeFile(configFileLocation, JSON.stringify(config, null, 2));
45
44
  } catch (e) {
46
45
  console.error(`Could not open config file (${configFileLocation}) for writing.`);
47
- throw e
46
+ throw e;
48
47
  }
49
48
  }
50
49
 
51
50
  export async function getConfig() {
52
- console.debug("getting config from file system")
51
+ console.debug('getting config from file system');
53
52
  return await readVibeIQConfig();
54
53
  }
55
54
 
@@ -67,10 +66,9 @@ export async function storeConfig(incomingConfig: Object, merge=true) {
67
66
  config = {
68
67
  ... await readVibeIQConfig(),
69
68
  ... incomingConfig
70
- }
69
+ };
71
70
  } else {
72
- config = incomingConfig
71
+ config = incomingConfig;
73
72
  }
74
73
  await writeVibeIQConfig(config);
75
74
  }
76
-
@@ -1,6 +1,6 @@
1
1
  import {deleteConfigs, readVibeIQConfig} from './config';
2
2
  export async function listConfig() {
3
- console.log(await readVibeIQConfig())
3
+ console.log(await readVibeIQConfig());
4
4
  }
5
5
 
6
6
  export async function removeConfig(args) {
package/src/interfaces.ts CHANGED
@@ -15,7 +15,6 @@ export interface AppDeclaration {
15
15
  appConfiguration: ConfigPropertyElements;
16
16
  triggers: { [key: string]: AppTriggerDeclaration };
17
17
  workflows?: { [key: string]: WorkflowDefinition|WorkflowTemplateDeclaration };
18
- isDockerBased?: boolean;
19
18
  dockerImageRef?: string;
20
19
  }
21
20
 
@@ -35,6 +34,7 @@ export interface AppActionDeclaration {
35
34
  name: string;
36
35
  description?: string;
37
36
  actionConfiguration?: ConfigPropertyElements;
37
+ async?: boolean; // defaults to false
38
38
  }
39
39
 
40
40
  export interface AppTriggerDeclaration {
@@ -44,7 +44,6 @@ export interface AppTriggerDeclaration {
44
44
  description?: string;
45
45
  }
46
46
 
47
-
48
47
  export interface WorkflowDefinition {
49
48
  id?: string;
50
49
  identifier: string;
@@ -105,10 +104,10 @@ export interface App {
105
104
  }
106
105
 
107
106
  export class ConfigProperty {
108
- slug: string;
109
- propertyType: string;
110
- options?: any[];
111
- label: string;
107
+ slug: string;
108
+ propertyType: string;
109
+ options?: any[];
110
+ label: string;
112
111
  }
113
112
 
114
113
  export interface EventWorkflowActionDefinition {
@@ -119,12 +118,12 @@ export interface EventWorkflowActionDefinition {
119
118
  ownerKey?: string;
120
119
  public?: boolean;
121
120
  configProperties?: ConfigProperty[];
122
- isDockerBased?: boolean;
121
+ async?: boolean;
123
122
  }
124
123
 
125
124
  export class TriggerKeyDefinition {
126
- name: string;
127
- description?: string;
128
- triggerKey: string;
125
+ name: string;
126
+ description?: string;
127
+ triggerKey: string;
129
128
  external?: boolean;
130
129
  }
@@ -1,5 +1,5 @@
1
1
  import csvToJson from 'csvtojson';
2
- import * as client from 'https'
2
+ import * as client from 'https';
3
3
  import { Entities } from '@contrail/sdk';
4
4
 
5
5
  export async function getCSVFromFile(loadFileId: string): Promise<any[]> {
@@ -11,12 +11,12 @@ export async function MergeOptionSets(args) {
11
11
  if (args?.length < 4) {
12
12
  throw new Error('File name must be included.');
13
13
  }
14
- console.log(`%s Importing local file`, chalk.yellow.bold('OPTION SET MERGE'));
14
+ console.log('%s Importing local file', chalk.yellow.bold('OPTION SET MERGE'));
15
15
  const fileLocation = args[3];
16
16
  console.log('Using File: ', fileLocation);
17
17
 
18
18
  await mergeOptionSets(fileLocation);
19
- console.log(`%s Merged`, chalk.yellow.bold('OPTION SET MERGE'));
19
+ console.log('%s Merged', chalk.yellow.bold('OPTION SET MERGE'));
20
20
 
21
21
  }
22
22
  catch (e) {
@@ -66,7 +66,7 @@ async function mergeOptionSets(fileLocation) {
66
66
  uploadedOptionSetsByName[optionSet.name] = optionSet;
67
67
  }
68
68
 
69
- const mergedOptionSets: any[] = []
69
+ const mergedOptionSets: any[] = [];
70
70
  for (const uploadedOptionSet of uploadedOptionSets) {
71
71
  const existing = currentOptionSetsByName[uploadedOptionSet.name];
72
72
  if (!existing) {
@@ -91,7 +91,7 @@ async function mergeOptionSets(fileLocation) {
91
91
  }
92
92
  }
93
93
 
94
- saveData({optionSets: mergedOptionSets})
94
+ saveData({optionSets: mergedOptionSets});
95
95
  }
96
96
 
97
97
  function mergeOptionSet(existingOptionSet: ReducedOptionSet, uploadedOptionSet: ReducedOptionSet) {
@@ -99,15 +99,15 @@ function mergeOptionSet(existingOptionSet: ReducedOptionSet, uploadedOptionSet:
99
99
  name: uploadedOptionSet.name,
100
100
  optionSet: uploadedOptionSet.optionSet,
101
101
  isArchived: uploadedOptionSet.isArchived,
102
- }
102
+ };
103
103
 
104
104
  for (const keyVal of existingOptionSet.optionSet) {
105
- const value = keyVal.value
106
- const display = keyVal.display
105
+ const value = keyVal.value;
106
+ const display = keyVal.display;
107
107
 
108
- const found = merged.optionSet.find(keyVal => keyVal.value === value)
108
+ const found = merged.optionSet.find(keyVal => keyVal.value === value);
109
109
  if (!found) {
110
- merged.optionSet.push({value, display})
110
+ merged.optionSet.push({value, display});
111
111
  }
112
112
 
113
113
  }
@@ -1,9 +1,8 @@
1
- import { ReducedOptionSet } from './interfaces';
2
1
  import fs from 'fs';
3
2
  import { getSeparatorByPlatform } from '../common';
4
3
  import { parseOptionSets } from '@contrail/types';
5
4
  import chalk from 'chalk';
6
- const csv = require('csvtojson')
5
+ const csv = require('csvtojson');
7
6
  const yaml = require('js-yaml');
8
7
 
9
8
  export async function ParseOptionSetsLocalFiles(args) {
@@ -11,12 +10,12 @@ export async function ParseOptionSetsLocalFiles(args) {
11
10
  if (args?.length < 4) {
12
11
  throw new Error('File name must be included.');
13
12
  }
14
- console.log(`%s Importing local file`, chalk.yellow.bold('OPTION SET PARSE'));
13
+ console.log('%s Importing local file', chalk.yellow.bold('OPTION SET PARSE'));
15
14
  const fileLocation = args[3];
16
15
  console.log('Using File: ', fileLocation);
17
16
 
18
17
  await parseOptionSetsLocalFiles(fileLocation);
19
- console.log(`%s Parsed`, chalk.yellow.bold('OPTION SET PARSE'));
18
+ console.log('%s Parsed', chalk.yellow.bold('OPTION SET PARSE'));
20
19
 
21
20
  }
22
21
  catch (e) {
@@ -35,7 +34,7 @@ async function loadOptionSetCSV(fileLocation) {
35
34
  const fullPath = TARGET_DIR + separator + fileLocation;
36
35
  console.log('Getting file from path: ', fullPath);
37
36
 
38
- return await csv().fromFile(fullPath)
37
+ return await csv().fromFile(fullPath);
39
38
  } catch (e) {
40
39
  throw new Error(`ERROR PARSING CSV: ${e}`);
41
40
  }
@@ -50,7 +49,7 @@ async function parseOptionSetsLocalFiles(fileLocation) {
50
49
  // }
51
50
 
52
51
  const parsedOptionSets = parseOptionSets(uploadedOptionData);
53
- saveData({optionSets: parsedOptionSets})
52
+ saveData({optionSets: parsedOptionSets});
54
53
  }
55
54
 
56
55
  function saveData(data) {
@@ -12,9 +12,9 @@ export async function UploadOptionSets(args) {
12
12
  const userConfig = await authUser();
13
13
  console.log(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk.blue.bold('START'));
14
14
 
15
- console.log(`%s Uploading`, chalk.yellow.bold('OPTION SETS'));
15
+ console.log('%s Uploading', chalk.yellow.bold('OPTION SETS'));
16
16
  await uploadOptionSets();
17
- console.log(`%s Uploaded`, chalk.yellow.bold('OPTION SETS'));
17
+ console.log('%s Uploaded', chalk.yellow.bold('OPTION SETS'));
18
18
 
19
19
  }
20
20
  catch (e) {
@@ -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';
@@ -8,17 +8,18 @@ import { getCSVFromFile } from './csv-parser';
8
8
 
9
9
  const yaml = require('js-yaml');
10
10
 
11
+ // This uses local files to get the data to parse into types
11
12
  export async function ParseTypesFromLocalFiles(args) {
12
13
  try {
13
14
  if (args?.length < 4) {
14
15
  throw new Error('File names must be included.');
15
16
  }
16
- console.log(`%s Parsing`, chalk.yellow.bold('TYPES AND OPTION SETS'));
17
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
17
18
  const fileLocations = (args as Array<string>).slice(3);
18
19
  console.log('Using File Location(s): ', fileLocations);
19
20
 
20
21
  await parseTypesFromLocalFiles(fileLocations);
21
- console.log(`%s Parsed`, chalk.yellow.bold('TYPES AND OPTION SETS'));
22
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
22
23
 
23
24
  }
24
25
  catch (e) {
@@ -29,17 +30,42 @@ export async function ParseTypesFromLocalFiles(args) {
29
30
  console.log('%s Parsing Complete.', chalk.green.bold('COMPLETE'));
30
31
  }
31
32
 
33
+ // This uses VibeIq file ids to get the data to parse into types
32
34
  export async function ParseTypesFromFiles(args) {
33
35
  try {
34
36
  if (args?.length < 4) {
35
37
  throw new Error('File ids must be included.');
36
38
  }
37
- console.log(`%s Parsing`, chalk.yellow.bold('TYPES AND OPTION SETS'));
39
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
38
40
  const fileIds = (args as Array<string>).slice(3);
39
41
  console.log('Using FileId(s): ', fileIds);
40
42
 
41
43
  await parseTypesFromFiles(fileIds);
42
- console.log(`%s Parsed`, chalk.yellow.bold('TYPES AND OPTION SETS'));
44
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
45
+
46
+ }
47
+ catch (e) {
48
+ console.log(`%s Parsing Failed. ${e}`, chalk.red.bold('FAIL'));
49
+ return;
50
+ }
51
+
52
+ console.log('%s Parsing Complete.', chalk.green.bold('COMPLETE'));
53
+ }
54
+
55
+ // This uses local files to get type template file and the data file to parse into types
56
+ export async function ParseTypesFromTemplateFromLocalFiles(args) {
57
+ try {
58
+ if (args?.length < 5) {
59
+ throw new Error('File names must be included.');
60
+ }
61
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
62
+ const templateFileLocation = args[3];
63
+ const dataFileLocation = args[4];
64
+ console.log('Using Template File Location: ', templateFileLocation);
65
+ console.log('Using Data File Location: ', dataFileLocation);
66
+
67
+ await parseTypesFromTemplateFromLocalFiles(templateFileLocation, dataFileLocation);
68
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
43
69
 
44
70
  }
45
71
  catch (e) {
@@ -57,7 +83,7 @@ async function loadDataFromLocalCSV(fileName) {
57
83
  const fullPath = CURRENT_DIR + separator + fileName;
58
84
 
59
85
  console.log('Getting file from path: ', fullPath);
60
- const csvData = await csvToJson.default().fromFile(fullPath);
86
+ const csvData = await csvToJson.default({flatKeys: true}).fromFile(fullPath);
61
87
 
62
88
  return csvData;
63
89
  } catch (e) {
@@ -83,9 +109,32 @@ async function parseTypesFromLocalFiles(fileLocations: string[]) {
83
109
  }
84
110
 
85
111
  console.log(`CSV imports were successful. ${csvJSONData?.length} total rows found.`);
86
- const suggestions = GetSuggestedTypes(csvJSONData)
87
- saveData({optionSets: suggestions.OptionSets}, 'parsed_optionSets.yml');
88
- saveData({typeProperties: suggestions.TypeProperties}, 'parsed_typeProperties.yml');
112
+ const suggestions = GetSuggestedTypes(csvJSONData);
113
+ saveData({ optionSets: suggestions.OptionSets }, 'parsed_optionSets.yml');
114
+ saveData({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml');
115
+ }
116
+
117
+ async function parseTypesFromTemplateFromLocalFiles(templateFileLocation: string, dataFileLocation: string) {
118
+
119
+ let templateCSVData: any[] = [];
120
+ let dataCSVData: any[] = [];
121
+ try {
122
+ console.log('Getting template from fileLocation: ', templateFileLocation);
123
+ templateCSVData = await loadDataFromLocalCSV(templateFileLocation);
124
+ console.log(`CSV import was successful. ${templateCSVData?.length} rows found.`);
125
+
126
+ console.log('Getting data from fileLocation: ', dataFileLocation);
127
+ dataCSVData = await loadDataFromLocalCSV(dataFileLocation);
128
+ console.log(`CSV import was successful. ${dataCSVData?.length} rows found.`);
129
+ }
130
+ catch (e) {
131
+ console.log('Error importing csv data.', e);
132
+ throw e;
133
+ }
134
+
135
+ const types = GetTypesFromTemplate(templateCSVData, dataCSVData);
136
+ saveData({ optionSets: types.OptionSets }, 'parsed_optionSets.yml');
137
+ saveData({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml');
89
138
  }
90
139
 
91
140
  async function parseTypesFromFiles(fileIds: string[]) {
@@ -107,10 +156,10 @@ async function parseTypesFromFiles(fileIds: string[]) {
107
156
  }
108
157
 
109
158
  console.log(`CSV downloads were successful. ${csvJSONData?.length} total rows found.`);
110
- const suggestions = GetSuggestedTypes(csvJSONData)
159
+ const suggestions = GetSuggestedTypes(csvJSONData);
111
160
 
112
- saveData({optionSets: suggestions.OptionSets}, 'parsed_optionSets.yml');
113
- saveData({typeProperties: suggestions.TypeProperties}, 'parsed_typeProperties.yml');
161
+ saveData({ optionSets: suggestions.OptionSets }, 'parsed_optionSets.yml');
162
+ saveData({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml');
114
163
  }
115
164
 
116
165
  function saveData(data, name) {
@@ -11,23 +11,23 @@ export async function getTypes(args) {
11
11
  try {
12
12
  const userConfig = await authUser();
13
13
  console.log(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk.blue.bold('START'));
14
- console.log(`%s Retrieving`, chalk.yellow.bold('OPTION SETS'));
14
+ console.log('%s Retrieving', chalk.yellow.bold('OPTION SETS'));
15
15
 
16
16
  const optionSets = await new Entities().get({
17
17
  entityName: 'type-property-option-set',
18
18
  });
19
19
  await getOptionSets(optionSets);
20
20
 
21
- console.log(`%s Retrieved`, chalk.yellow.bold('OPTION SETS'));
22
- console.log(`%s Retrieving`, chalk.yellow.bold('TYPES'));
21
+ console.log('%s Retrieved', chalk.yellow.bold('OPTION SETS'));
22
+ console.log('%s Retrieving', chalk.yellow.bold('TYPES'));
23
23
 
24
24
  const reducedTypes = await getReducedTypes(optionSets);
25
25
  const typesHolder = {
26
26
  types: reducedTypes,
27
27
  };
28
- saveData(typesHolder)
28
+ saveData(typesHolder);
29
29
 
30
- console.log(`%s Retrieved`, chalk.yellow.bold('TYPES'));
30
+ console.log('%s Retrieved', chalk.yellow.bold('TYPES'));
31
31
 
32
32
  }
33
33
  catch (e) {
@@ -12,7 +12,7 @@ export async function MergeTypeProperties(args) {
12
12
  if (args?.length < 5) {
13
13
  throw new Error('File name must be included along with a type path.');
14
14
  }
15
- console.log(`%s Importing local file`, chalk.yellow.bold('TYPE PROPERTIES MERGE'));
15
+ console.log('%s Importing local file', chalk.yellow.bold('TYPE PROPERTIES MERGE'));
16
16
  const fileLocation = args[3];
17
17
  console.log('Using File: ', fileLocation);
18
18
 
@@ -20,7 +20,7 @@ export async function MergeTypeProperties(args) {
20
20
  console.log('Using TypePaths: ', typePaths);
21
21
 
22
22
  await mergeTypeProperties(fileLocation, typePaths);
23
- console.log(`%s Merged`, chalk.yellow.bold('TYPE PROPERTIES MERGE'));
23
+ console.log('%s Merged', chalk.yellow.bold('TYPE PROPERTIES MERGE'));
24
24
 
25
25
  }
26
26
  catch (e) {
@@ -62,17 +62,17 @@ async function mergeTypeProperties(fileLocation, typePaths) {
62
62
  if (!foundType){
63
63
  console.log(`%s No Type found for: ${typePath}`, chalk.red.bold('WARNING'));
64
64
  }
65
- mergeType(foundType, uploadedTypeProperties)
65
+ mergeType(foundType, uploadedTypeProperties);
66
66
  }
67
67
 
68
- saveData({types: reducedTypes})
68
+ saveData({types: reducedTypes});
69
69
  }
70
70
 
71
71
  function mergeType(reducedType: ReducedType, typePropertiesToAdd: ReducedTypeProperty[]) {
72
72
  for (const typeProperty of typePropertiesToAdd) {
73
- const found = reducedType.typeProperties.find(tp => tp.slug === typeProperty.slug)
73
+ const found = reducedType.typeProperties.find(tp => tp.slug === typeProperty.slug);
74
74
  if (!found) {
75
- reducedType.typeProperties.push(typeProperty)
75
+ reducedType.typeProperties.push(typeProperty);
76
76
  }
77
77
  }
78
78
  }
@@ -1,21 +1,21 @@
1
1
  import { Entities, Request } from '@contrail/sdk';
2
- import { ReducedType, ReducedTypeProperty } from './interfaces';
2
+ import { ReducedType } from './interfaces';
3
3
  import chalk from 'chalk';
4
4
  import fs from 'fs';
5
5
  import { authUser } from '../auth/login';
6
6
  import { getSeparatorByPlatform } from '../common';
7
7
  import * as _ from 'lodash';
8
8
 
9
- const yaml = require('js-yaml');
9
+ import yaml from 'js-yaml';
10
10
 
11
- export async function uploadTypes(args) {
11
+ export async function uploadTypes() {
12
12
  try {
13
13
  const userConfig = await authUser();
14
14
  console.log(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk.blue.bold('START'));
15
15
 
16
- console.log(`%s Uploading`, chalk.yellow.bold('TYPES'));
16
+ console.log('%s Uploading', chalk.yellow.bold('TYPES'));
17
17
  await uploadReducedTypes();
18
- console.log(`%s Uploaded`, chalk.yellow.bold('TYPES'));
18
+ console.log('%s Uploaded', chalk.yellow.bold('TYPES'));
19
19
 
20
20
  }
21
21
  catch (e) {
@@ -155,27 +155,27 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
155
155
  await Request.request(
156
156
  `/types/${type.id}/type-properties`,
157
157
  {
158
- method: 'POST',
159
- body: JSON.stringify({
160
- isArchived: newPropertyType.isArchived,
161
- propertyType: newPropertyType.propertyType,
162
- slug: newPropertyType.slug,
163
- label: newPropertyType.label,
164
- editable: newPropertyType.editable,
165
- core: newPropertyType.core,
166
- typePropertyOptionSetId: optionSetIdByName[newPropertyType.typePropertyOptionSetName],
167
- formula: newPropertyType.formula,
168
- referencedTypeRootSlug: newPropertyType.referencedTypeRootSlug,
169
- defaultValue: newPropertyType.defaultValue,
170
- propertyLevel: newPropertyType.propertyLevel,
171
- formulaFunction: newPropertyType.formulaFunction,
172
- validationFunction: newPropertyType.validationFunction,
173
- }),
174
- headers: {
175
- 'Accept': 'application/json',
158
+ method: 'POST',
159
+ body: JSON.stringify({
160
+ isArchived: newPropertyType.isArchived,
161
+ propertyType: newPropertyType.propertyType,
162
+ slug: newPropertyType.slug,
163
+ label: newPropertyType.label,
164
+ editable: newPropertyType.editable,
165
+ core: newPropertyType.core,
166
+ typePropertyOptionSetId: optionSetIdByName[newPropertyType.typePropertyOptionSetName],
167
+ formula: newPropertyType.formula,
168
+ referencedTypeRootSlug: newPropertyType.referencedTypeRootSlug,
169
+ defaultValue: newPropertyType.defaultValue,
170
+ propertyLevel: newPropertyType.propertyLevel,
171
+ formulaFunction: newPropertyType.formulaFunction,
172
+ validationFunction: newPropertyType.validationFunction,
173
+ }),
174
+ headers: {
175
+ Accept: 'application/json',
176
176
  'Content-Type': 'application/json',
177
- },
178
- });
177
+ },
178
+ });
179
179
  }
180
180
  else if (found && !newPropertyType.inherited && !typePropertiesEqual(found, newPropertyType, optionSetIdByName)) {
181
181
  console.log('Updating Type-Property: ', newPropertyType.slug);
@@ -213,12 +213,12 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
213
213
  await Request.request(
214
214
  `/types/${type.id}/type-properties/${currentPropertyType.id}`,
215
215
  {
216
- method: 'DELETE',
217
- headers: {
218
- 'Accept': 'application/json',
216
+ method: 'DELETE',
217
+ headers: {
218
+ Accept: 'application/json',
219
219
  'Content-Type': 'application/json',
220
- },
221
- });
220
+ },
221
+ });
222
222
  }
223
223
  } catch (err) {
224
224
  throw new Error(`Error Deleting Properties: ${err}`);
@@ -261,4 +261,4 @@ function typePropertiesEqual(typeProperty1, typeProperty2, optionSetIdByName): b
261
261
  };
262
262
 
263
263
  return _.isEqual(reducedProperty1, reducedProperty2);
264
- }
264
+ }
@@ -1,8 +1,6 @@
1
1
  import { Entities } from '@contrail/sdk';
2
2
  import chalk from 'chalk';
3
- import { App, AppDeclaration, WorkflowTemplate, WorkflowTemplateDeclaration } from '../interfaces';
4
- import { getActionDeclarationIdentifier, getActionsForApp } from '../apps/deploy-app/actions-deployer'
5
- import { deleteWorkflowTemplate } from './workflowCommands';
3
+ import { WorkflowTemplate, WorkflowTemplateDeclaration } from '../interfaces';
6
4
 
7
5
  export class WorkflowTemplateDeployer {
8
6
  async deployWorkflows(wtDeclaration: WorkflowTemplateDeclaration) {
@@ -77,7 +75,7 @@ export class WorkflowTemplateDeployer {
77
75
  const actionEntity: any = await getActionByIdentifier(actionKey);
78
76
  actionConfiguration.id = actionEntity.id;
79
77
  } catch (e) {
80
- console.log(e)
78
+ console.log(e);
81
79
  }
82
80
  if(!actionConfiguration.id) {
83
81
  throw new Error(`Could not find action ${actionKey} declared in ${workflowKey}`);
@@ -35,7 +35,6 @@ export async function deployWorkflowTemplate() {
35
35
  await new WorkflowTemplateDeployer().deployWorkflows(wtDeclaration);
36
36
  }
37
37
 
38
-
39
38
  export async function listWorkflowTemplate() {
40
39
  await authUser();
41
40
  return await new WorkflowTemplateDeployer().listExistingWorkflowTemplates();
@@ -1,38 +1,38 @@
1
- async function execute(config, event, Functions) {
2
- const getBodyFromEvent = (config, event) => {
3
- let body = Functions.stringUtil.parseVariables(config.message, event);
4
- console.log('body: ', body);
5
- if (config.sendDetails) {
6
- const data = event;
7
- const properties = {};
8
- let addedProperty = false;
9
- for (const property of config.fieldsToForward) {
10
- const variableLevels = property.split('.');
11
- let replacementValue = data;
12
- for (let i = 0; i < variableLevels.length; i++) {
13
- replacementValue = replacementValue[variableLevels[i]];
14
- }
15
- properties[property] = replacementValue;
16
- addedProperty = true;
17
- }
18
- if (addedProperty) {
19
- body = body + ' Properties: ' + JSON.stringify(properties) + '.';
20
- }
21
- }
22
- return JSON.stringify({ text: body });
23
- };
24
- const body = getBodyFromEvent(config, event);
25
- console.log('Sending message: ', body);
26
- const response = await Functions.fetch(config.url, {
27
- method: 'POST',
28
- body: body,
29
- headers: { 'Content-Type': 'application/json' }
30
- });
31
- if (!response.ok) {
32
- console.log('Webhook event failed to publish');
33
- console.log('Response: ', JSON.stringify(response));
34
- }
35
- else {
36
- console.log('Published!');
37
- }
1
+ async function execute(config, event, Functions) {
2
+ const getBodyFromEvent = (config, event) => {
3
+ let body = Functions.stringUtil.parseVariables(config.message, event);
4
+ console.log('body: ', body);
5
+ if (config.sendDetails) {
6
+ const data = event;
7
+ const properties = {};
8
+ let addedProperty = false;
9
+ for (const property of config.fieldsToForward) {
10
+ const variableLevels = property.split('.');
11
+ let replacementValue = data;
12
+ for (let i = 0; i < variableLevels.length; i++) {
13
+ replacementValue = replacementValue[variableLevels[i]];
14
+ }
15
+ properties[property] = replacementValue;
16
+ addedProperty = true;
17
+ }
18
+ if (addedProperty) {
19
+ body = body + ' Properties: ' + JSON.stringify(properties) + '.';
20
+ }
21
+ }
22
+ return JSON.stringify({ text: body });
23
+ };
24
+ const body = getBodyFromEvent(config, event);
25
+ console.log('Sending message: ', body);
26
+ const response = await Functions.fetch(config.url, {
27
+ method: 'POST',
28
+ body: body,
29
+ headers: { 'Content-Type': 'application/json' }
30
+ });
31
+ if (!response.ok) {
32
+ console.log('Webhook event failed to publish');
33
+ console.log('Response: ', JSON.stringify(response));
34
+ }
35
+ else {
36
+ console.log('Published!');
37
+ }
38
38
  }
@@ -1,4 +1,4 @@
1
- export { } // Leave empty export - This allows for multiple files with a function named execute.
1
+ export { }; // Leave empty export - This allows for multiple files with a function named execute.
2
2
  async function execute(config, event, Functions) {
3
3
  const getBodyFromEvent = (config, event) => {
4
4
  let body = Functions.stringUtil.parseVariables(config.message, event);
@@ -4,7 +4,7 @@ appDescription: "Your app description."
4
4
  visibility: public
5
5
  publisher: "Your company name"
6
6
  version: 1.0
7
- isDockerBased: true # this flag should be deprecated since all apps should be docker-based anyway
7
+ # dockerImageRef: repo/name:tag
8
8
 
9
9
  # eventWorkflowTriggerKeyMapping will be used to parse an incoming event into a key that can trigger workflows
10
10
  # {} indicates a field on the event. You can use nested fields by separating the levels with a '.'