@contrail/cli 1.0.39 → 1.0.41

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 (60) hide show
  1. package/lib/api/apps.d.ts +13 -0
  2. package/lib/{apps/app-api.js → api/apps.js} +27 -1
  3. package/lib/api/event-workflow-action-definition.d.ts +1 -0
  4. package/lib/api/event-workflow-action-definition.js +7 -0
  5. package/lib/api/event-workflow-template-definition.d.ts +5 -0
  6. package/lib/api/event-workflow-template-definition.js +14 -0
  7. package/lib/api/event-workflow-templates.d.ts +7 -0
  8. package/lib/api/event-workflow-templates.js +25 -0
  9. package/lib/apps/deploy-app/app-deployer.js +4 -17
  10. package/lib/apps/install-app/app-installer.js +21 -4
  11. package/lib/apps/upgrade-app/app-upgrader.js +1 -1
  12. package/lib/cli.js +121 -45
  13. package/lib/config/config.d.ts +2 -2
  14. package/lib/config/configCommands.d.ts +1 -0
  15. package/lib/config/configCommands.js +25 -1
  16. package/lib/interfaces.d.ts +65 -1
  17. package/lib/interfaces.js +21 -0
  18. package/lib/types/parse-types.d.ts +1 -0
  19. package/lib/types/parse-types.js +48 -1
  20. package/lib/workflow-template-definitions/workflow-template-definition-commands.d.ts +2 -0
  21. package/lib/workflow-template-definitions/workflow-template-definition-commands.js +10 -0
  22. package/lib/workflow-template-definitions/workflow-template-definition-deployer.d.ts +12 -0
  23. package/lib/workflow-template-definitions/workflow-template-definition-deployer.js +148 -0
  24. package/lib/{workflows/workflow-template-deployer.d.ts → workflow-templates/local-workflow-template-deployer.d.ts} +1 -4
  25. package/lib/{workflows/workflow-template-deployer.js → workflow-templates/local-workflow-template-deployer.js} +9 -34
  26. package/lib/workflow-templates/workflow-template-commands.d.ts +4 -0
  27. package/lib/{workflows/workflowCommands.js → workflow-templates/workflow-template-commands.js} +9 -4
  28. package/lib/workflow-templates/workflow-template-deployer.d.ts +4 -0
  29. package/lib/workflow-templates/workflow-template-deployer.js +25 -0
  30. package/package.json +2 -2
  31. package/src/api/apps.ts +97 -0
  32. package/src/api/event-workflow-action-definition.ts +8 -0
  33. package/src/api/event-workflow-template-definition.ts +16 -0
  34. package/src/api/event-workflow-templates.ts +29 -0
  35. package/src/apps/deploy-app/app-deployer.ts +4 -19
  36. package/src/apps/install-app/app-installer.ts +34 -13
  37. package/src/apps/upgrade-app/app-upgrader.ts +1 -1
  38. package/src/cli.ts +123 -45
  39. package/src/config/config.ts +2 -2
  40. package/src/config/configCommands.ts +26 -1
  41. package/src/interfaces.ts +76 -6
  42. package/src/types/parse-types.ts +58 -1
  43. package/src/workflow-template-definitions/workflow-template-definition-commands.ts +13 -0
  44. package/src/workflow-template-definitions/workflow-template-definition-deployer.ts +182 -0
  45. package/src/{workflows/workflow-template-deployer.ts → workflow-templates/local-workflow-template-deployer.ts} +9 -38
  46. package/src/{workflows/workflowCommands.ts → workflow-templates/workflow-template-commands.ts} +10 -4
  47. package/src/workflow-templates/workflow-template-deployer.ts +29 -0
  48. package/lib/apps/app-api.d.ts +0 -6
  49. package/lib/apps/deploy-app/docker-action-builder.d.ts +0 -10
  50. package/lib/apps/deploy-app/docker-action-builder.js +0 -97
  51. package/lib/apps/deploy-app/interfaces.d.ts +0 -76
  52. package/lib/apps/deploy-app/interfaces.js +0 -4
  53. package/lib/apps/deploy-app/workflow-definition-deployer.d.ts +0 -10
  54. package/lib/apps/deploy-app/workflow-definition-deployer.js +0 -94
  55. package/lib/apps/deploy-app/workflow-deployer.d.ts +0 -10
  56. package/lib/apps/deploy-app/workflow-deployer.js +0 -87
  57. package/lib/workflows/workflowCommands.d.ts +0 -3
  58. package/src/apps/app-api.ts +0 -66
  59. package/src/apps/deploy-app/workflow-definition-deployer.ts +0 -118
  60. package/tslint.json +0 -57
@@ -1,8 +1,10 @@
1
1
  import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
3
  import { Entities } from '@contrail/sdk';
4
- import {authUser} from '../../auth/login';
5
- import { deleteAppOrg, getAvailableApps, getInstalledApps, installAppToOrg } from '../app-api';
4
+ import { authUser } from '../../auth/login';
5
+ import { deleteAppOrg, getAvailableApps, getInstalledApps, getWorkflowTemplateDefinitionsForApp, installAppToOrg } from '../../api/apps';
6
+ import { App } from '../../interfaces';
7
+ import { WorkflowTemplateDefinitionDeployer } from '../../workflow-template-definitions/workflow-template-definition-deployer';
6
8
 
7
9
  async function getConfigProperties(app) {
8
10
  const config = {};
@@ -30,14 +32,14 @@ export async function uninstallApp() {
30
32
  message: 'Which app would you like to uninstall?',
31
33
  choices: installedApps.map(x => x.app.identifier)
32
34
  }]);
33
- const appToDelete = installedApps.find(x=> x.app.identifier === answers.appIdentifier);
35
+ const appToDelete = installedApps.find(x => x.app.identifier === answers.appIdentifier);
34
36
  console.log('%s Uninstalling app', chalk.green.bold('APP INSTALLATION'));
35
37
  await deleteAppOrg(appToDelete.id);
36
38
  // eslint-disable-next-line no-constant-condition
37
39
  while (true) {
38
40
  await delay(1000);
39
- try{
40
- const appStillDeleting = await new Entities().get({entityName: 'app-org', id: appToDelete.id});
41
+ try {
42
+ const appStillDeleting = await new Entities().get({ entityName: 'app-org', id: appToDelete.id });
41
43
  if (!appStillDeleting) {
42
44
  break;
43
45
  }
@@ -52,7 +54,7 @@ export async function uninstallApp() {
52
54
 
53
55
  export async function installApp() {
54
56
  await authUser();
55
- const apps = await getAvailableApps();
57
+ const apps: App[] = await getAvailableApps();
56
58
  if (!apps.length) {
57
59
  throw new Error('No apps are available to install...');
58
60
  }
@@ -70,7 +72,7 @@ export async function installApp() {
70
72
  message: 'Which app would you like to install?',
71
73
  choices: installableApps.map(x => x.identifier)
72
74
  });
73
- const answers = await inquirer.prompt(questions);
75
+ let answers = await inquirer.prompt(questions);
74
76
  const app = installableApps.find(x => x.identifier === answers.appIdentifier);
75
77
  let configProperties: any;
76
78
  if (app.configProperties) {
@@ -82,24 +84,43 @@ export async function installApp() {
82
84
  // eslint-disable-next-line no-constant-condition
83
85
  while (true) {
84
86
  await delay(1000);
85
- try{
86
- const installingApp = await new Entities().get({entityName: 'app-org', id: appOrg.id});
87
+ try {
88
+ const installingApp = await new Entities().get({ entityName: 'app-org', id: appOrg.id });
87
89
  if (installingApp.status === 'READY') {
88
90
  console.log('%s App installed', chalk.green.bold('APP INSTALLATION'));
89
- return;
91
+ break;
90
92
  }
91
- if(installingApp.status === 'FAILED_INSTALLING') {
93
+ if (installingApp.status === 'FAILED_INSTALLING') {
92
94
  console.log('%s App installation failed', chalk.red.bold('APP INSTALLATION'));
93
95
  return;
94
96
  }
95
97
  process.stdout.write('.');
96
98
  } catch (e) {
99
+ console.log('%s App installation failed', chalk.red.bold('APP INSTALLATION'));
97
100
  console.log('Error is:', e);
98
- break;
101
+ return;
99
102
  }
100
103
  }
104
+
105
+ const workflowTemplateDefinitions = await getWorkflowTemplateDefinitionsForApp({ appId: app.id });
106
+ if (!workflowTemplateDefinitions.length) {
107
+ return;
108
+ }
109
+ answers = await inquirer.prompt([{
110
+ type: 'confirm',
111
+ name: 'shouldInstallWorkflows',
112
+ message: 'Would you like to install the Workflows associated with this app?',
113
+ default: false
114
+ }]);
115
+
116
+ if (!answers.shouldInstallWorkflows) {
117
+ console.log('%s Not installing associated app workflows', chalk.yellow.bold('APP INSTALLATION'));
118
+ return;
119
+ }
120
+
121
+ new WorkflowTemplateDefinitionDeployer().installWorkflowTemplateDefinitions(workflowTemplateDefinitions);
101
122
  }
102
123
 
103
124
  function delay(ms: number) {
104
- return new Promise( resolve => setTimeout(resolve, ms) );
125
+ return new Promise(resolve => setTimeout(resolve, ms));
105
126
  }
@@ -2,7 +2,7 @@ import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
3
  import { Entities } from '@contrail/sdk';
4
4
  import { authUser } from '../../auth/login';
5
- import { deleteAppOrg, getAppVersions, getAvailableApps, getInstalledApps, installAppToOrg, upgradeAppVersion } from '../app-api';
5
+ import { deleteAppOrg, getAppVersions, getAvailableApps, getInstalledApps, installAppToOrg, upgradeAppVersion } from '../../api/apps';
6
6
 
7
7
  async function getConfigProperties(app) {
8
8
  const config = {};
package/src/cli.ts CHANGED
@@ -7,12 +7,13 @@ import { UploadOptionSets } from './types/option-set-uploader';
7
7
  import { ParseOptionSetsLocalFiles } from './types/option-set-parser';
8
8
  import { MergeOptionSets } from './types/option-set-merger';
9
9
  import { MergeTypeProperties } from './types/types-properties-merger';
10
- import { ParseTypesFromFiles, ParseTypesFromLocalFiles, ParseTypesFromTemplateFromLocalFiles } from './types/parse-types';
10
+ import { ParseTypesFromFiles, ParseTypesFromLocalFiles, ParseTypesFromTemplateFromLocalFiles, ParseTypesFromTemplateAndDataFromLocalFiles } from './types/parse-types';
11
11
  import { loadColors, deleteColors } from './colors/color-loader';
12
- import { listConfig, removeConfig } from './config/configCommands';
13
- import { deleteWorkflowTemplate, deployWorkflowTemplate, listWorkflowTemplate } from './workflows/workflowCommands';
12
+ import { listConfig, removeConfig, setConfig } from './config/configCommands';
13
+ import { deleteWorkflowTemplates, localDeployWorkflowTemplate, listWorkflowTemplate } from './workflow-templates/workflow-template-commands';
14
14
  import { installApp, uninstallApp } from './apps/install-app/app-installer';
15
15
  import { upgradeApp } from './apps/upgrade-app/app-upgrader';
16
+ import { cliInstallWorkflowTemplateDefinitions, listWorkflowTemplateDefinitions } from './workflow-template-definitions/workflow-template-definition-commands';
16
17
  const cliUsage = require('command-line-usage');
17
18
 
18
19
  /**
@@ -22,8 +23,6 @@ const cliUsage = require('command-line-usage');
22
23
 
23
24
  export async function cli(args) {
24
25
  const fullCommand = args[2];
25
- let domain;
26
- let command;
27
26
  if (!fullCommand) {
28
27
  printIllegalCommand();
29
28
  return;
@@ -35,13 +34,18 @@ export async function cli(args) {
35
34
  return;
36
35
  }
37
36
 
38
- if (commandParts?.length < 2 && commandParts[0].toLowerCase() !== 'help' && commandParts[0].toLowerCase() !== '-help' && commandParts[0].toLowerCase() !== '--help') {
37
+ if (
38
+ commandParts?.length < 2 &&
39
+ commandParts[0].toLowerCase() !== 'help' &&
40
+ commandParts[0].toLowerCase() !== '-help' &&
41
+ commandParts[0].toLowerCase() !== '--help'
42
+ ) {
39
43
  printIllegalCommand();
40
44
  return;
41
45
  }
42
46
 
43
- domain = commandParts[0];
44
- command = commandParts[1];
47
+ const domain = commandParts[0];
48
+ const command = commandParts[1];
45
49
 
46
50
  switch (domain) {
47
51
  case 'app': {
@@ -102,6 +106,10 @@ export async function cli(args) {
102
106
  ParseTypesFromTemplateFromLocalFiles(args);
103
107
  break;
104
108
  }
109
+ case 'parseTypesFromTemplateAndDataFromLocalFiles': {
110
+ ParseTypesFromTemplateAndDataFromLocalFiles(args);
111
+ break;
112
+ }
105
113
  case 'parseTypesFromFiles': {
106
114
  ParseTypesFromFiles(args);
107
115
  break;
@@ -140,11 +148,11 @@ export async function cli(args) {
140
148
  case 'workflow-templates': {
141
149
  switch (command) {
142
150
  case 'load': {
143
- await deployWorkflowTemplate();
151
+ await localDeployWorkflowTemplate();
144
152
  break;
145
153
  }
146
154
  case 'delete': {
147
- await deleteWorkflowTemplate();
155
+ await deleteWorkflowTemplates();
148
156
  break;
149
157
  }
150
158
  case 'list': {
@@ -157,12 +165,32 @@ export async function cli(args) {
157
165
  }
158
166
  break;
159
167
  }
168
+ case 'workflow-template-definitions': {
169
+ switch (command) {
170
+ case 'install': {
171
+ await cliInstallWorkflowTemplateDefinitions();
172
+ break;
173
+ }
174
+ case 'list': {
175
+ await listWorkflowTemplateDefinitions();
176
+ break;
177
+ }
178
+ default: {
179
+ printIllegalCommand();
180
+ }
181
+ }
182
+ break;
183
+ }
160
184
  case 'config': {
161
185
  switch (command) {
162
186
  case 'list': {
163
187
  await listConfig();
164
188
  break;
165
189
  }
190
+ case 'set': {
191
+ await setConfig(args);
192
+ break;
193
+ }
166
194
  case 'remove': {
167
195
  await removeConfig(args);
168
196
  break;
@@ -218,55 +246,105 @@ const helpSections = [
218
246
  {
219
247
  header: 'App Commands - Domain: app',
220
248
  content: [
221
- 'create Create a new app workspace.',
222
- 'deploy Deploy your app.',
223
- 'deploy [OPTIONS] --template-only deploy event workflow as',
224
- '. a template directly to the org',
225
- 'deploy Deploy your app.',
226
- 'remove Remove your app.',
227
- 'install Install an app to your org.',
228
- 'uninstall Uninstall an app from your org.',
249
+ {
250
+ name: 'create',
251
+ summary: 'Create a new app workspace.'
252
+ },
253
+ {
254
+ name: 'deploy [--template-only]',
255
+ summary: 'Deploy your app. --template-only can be used to deploy event workflow as a template directly to the org'
256
+ },
257
+ {
258
+ name: 'remove',
259
+ summary: 'Remove your app.'
260
+ },
261
+ {
262
+ name: 'install',
263
+ summary: 'Install an app to your org.'
264
+ },
265
+ {
266
+ name: 'uninstall',
267
+ summary: 'Uninstall an app from your org.'
268
+ },
229
269
  ],
230
270
  },
231
271
  {
232
272
  header: 'Colors Commands - Domain: colors',
233
- content: [
234
- 'load Load colors from a CSV. Headers (name, hex, red,',
235
- '. green, blue) are required.',
236
- // 'delete Delete all colors.',
273
+ content: [{
274
+ name: 'load',
275
+ summary: 'Load colors from a CSV. Headers (name, hex, red, green, blue) are required'
276
+ }
277
+ // , {name: 'delete', summary: 'Delete all colors.'}
237
278
  ],
238
279
  },
239
280
  {
240
281
  header: 'Workflow Template Commands - Domain: workflow-templates',
241
282
  content: [
242
- 'deploy Deploy your workflow. Assumes a workflow.yml file.',
243
- 'delete Removes the workflows in the workflow.yml file.',
244
- 'list Lists the workflow templates in the org',
283
+ {
284
+ name: 'deploy',
285
+ summary: 'Deploy your workflow. Assumes a workflow.yml file.'
286
+ },
287
+ {
288
+ name: 'delete',
289
+ summary: 'Removes the workflows in the workflow.yml file.'
290
+ },
291
+ {
292
+ name: 'list',
293
+ summary: 'Lists the workflow templates in the org'
294
+ },
295
+ ],
296
+ },
297
+ {
298
+ header: 'Workflow Template Definition Commands - Domain: workflow-template-definitions',
299
+ content: [{
300
+ name: 'install',
301
+ summary: 'Install the template definitions of an app to your org'
302
+ },
303
+ {
304
+ name: 'list',
305
+ summary: 'Lists the workflow templates in the org'
306
+ }
245
307
  ],
246
308
  },
247
309
  {
248
310
  header: 'Type Commands - Domain: types',
249
311
  content: [
250
- 'getAll Get all OptionSets and Types for your Org.',
251
- 'uploadTypes Upload Types for your Org.',
252
- '. Types are uploaded from types.yml\n',
253
- 'uploadOptionSets Upload OptionSets for your Org.',
254
- '. OptionSets are loaded from option_sets.yml\n',
255
- 'parseOptionSetsLocalFiles <File Paths> Parse CSV files into OptionSets',
256
- 'parseTypesFromLocalFiles <File Paths> Parse CSV files into Types and ',
257
- '. OptionSets from local files.\n',
258
- 'parseTypesFromTemplateFromLocalFiles <File Paths> Parse CSV files into ',
259
- '. Types and OptionSets from local files.\n',
260
- 'parseTypesFromFiles <fileIds> Parse CSV files into Types and ',
261
- '. OptionSets from VibeIQ Files.\n',
262
- 'mergeOptionSets <File Path> Merge the OptionSets from an existing',
263
- '. org and the OptionSets passed in.',
264
- '. File must be .yml\n',
265
- 'mergeTypeProperties <File Path> <TypePaths> ',
266
- '. Merge the TypeProperties from an existing',
267
- '. org and the TypeProperties passed in.',
268
- '. Add to Types via TypePath',
269
- '. File must be .yml\n',
312
+ {
313
+ name: 'getAll',
314
+ summary: 'Get all OptionSets and Types for your Org.'
315
+ },
316
+ {
317
+ name: 'uploadTypes',
318
+ summary: 'Upload Types for your Org. Types are uploaded from types.yml\n'
319
+ },
320
+ {
321
+ name: 'uploadOptionSets',
322
+ summary: 'Upload OptionSets for your Org. OptionSets are loaded from option_sets.yml\n'
323
+ },
324
+ {
325
+ name: 'parseOptionSetsLocalFiles <File Paths>',
326
+ summary: 'Parse CSV files into OptionSets'
327
+ },
328
+ {
329
+ name: 'parseTypesFromLocalFiles <File Paths>',
330
+ summary: 'Parse CSV files into Types and OptionSets from local files.\n'
331
+ },
332
+ {
333
+ name: 'parseTypesFromTemplateFromLocalFiles <File Paths>',
334
+ summary: 'Parse CSV files into Types and OptionSets from local type template files.\n'
335
+ },
336
+ {
337
+ name: 'parseTypesFromTemplateAndDataFromLocalFiles <File Paths>',
338
+ summary: 'Parse CSV files into Types and OptionSets from local type template and data files.\n'
339
+ },
340
+ {
341
+ name: 'parseTypesFromFiles <fileIds>',
342
+ summary: 'Parse CSV files into Types and OptionSets from VibeIQ Files.\n File must be .yml\n'
343
+ },
344
+ {
345
+ name: 'mergeTypeProperties <File Path> <TypePaths>',
346
+ summary: 'Merge the TypeProperties from an existing org and the TypeProperties passed in. Add to Types via TypePath File must be .yml\n'
347
+ },
270
348
  ],
271
349
  },
272
350
  ];
@@ -38,7 +38,7 @@ export async function readVibeIQConfig() {
38
38
  }
39
39
  }
40
40
 
41
- export async function writeVibeIQConfig(config: Object) {
41
+ export async function writeVibeIQConfig(config: any) {
42
42
  try {
43
43
  await fsPromises.writeFile(configFileLocation, JSON.stringify(config, null, 2));
44
44
  } catch (e) {
@@ -60,7 +60,7 @@ export async function deleteConfigs(configNames: string[]) {
60
60
  await storeConfig(currentConfig, false);
61
61
  }
62
62
 
63
- export async function storeConfig(incomingConfig: Object, merge=true) {
63
+ export async function storeConfig(incomingConfig: any, merge=true) {
64
64
  let config;
65
65
  if (merge) {
66
66
  config = {
@@ -1,8 +1,33 @@
1
- import {deleteConfigs, readVibeIQConfig} from './config';
1
+ import {deleteConfigs, readVibeIQConfig, storeConfig} from './config';
2
2
  export async function listConfig() {
3
3
  console.log(await readVibeIQConfig());
4
4
  }
5
5
 
6
+ export async function setConfig(args) {
7
+ const helpConfigLine = `
8
+ Usage:
9
+ contrail config.set key1=value1 key2=value2
10
+ `;
11
+ if (args?.length < 4) {
12
+ console.log(helpConfigLine);
13
+ throw new Error('You need to pass at least one config to set');
14
+ }
15
+ const configsToSet = args.slice(3);
16
+ const config = {};
17
+ for(const conf of configsToSet) {
18
+ if(conf.length < 3 || conf.indexOf('=') <= 0) {
19
+ console.log(helpConfigLine);
20
+ throw new Error(`value ${conf} does not adhere to key1=value1 standard`);
21
+ }
22
+ const [key, value] = conf.split('=');
23
+ console.log('key and value:', key, value);
24
+ console.log(conf.split('='));
25
+ config[key] = value;
26
+ }
27
+ console.log('config is:', config);
28
+ await storeConfig(config);
29
+ }
30
+
6
31
  export async function removeConfig(args) {
7
32
  if (args?.length < 4) {
8
33
  throw new Error('At least one configuration must be included to be removed.');
package/src/interfaces.ts CHANGED
@@ -14,7 +14,7 @@ export interface AppDeclaration {
14
14
  actions?: { [key: string]: AppActionDeclaration };
15
15
  appConfiguration: ConfigPropertyElements;
16
16
  triggers: { [key: string]: AppTriggerDeclaration };
17
- workflows?: { [key: string]: WorkflowDefinition|WorkflowTemplateDeclaration };
17
+ workflows?: { [key: string]: WorkflowDefinition | WorkflowTemplateDeclaration };
18
18
  dockerImageRef?: string;
19
19
  }
20
20
 
@@ -23,9 +23,9 @@ export interface ConfigPropertyElements {
23
23
  }
24
24
 
25
25
  export interface ConfigPropertyElement {
26
- propertyType: string;
27
- options?: any[];
28
- label: string;
26
+ propertyType: string;
27
+ options?: any[];
28
+ label: string;
29
29
  dynamic?: boolean;
30
30
  }
31
31
 
@@ -45,6 +45,7 @@ export interface AppTriggerDeclaration {
45
45
  description?: string;
46
46
  }
47
47
 
48
+ // workflow-template and workflow-template-definition share the same interface
48
49
  export interface WorkflowDefinition {
49
50
  id?: string;
50
51
  identifier: string;
@@ -65,7 +66,7 @@ export interface WorkflowTemplateDeclaration {
65
66
 
66
67
  export interface WorkflowTemplate {
67
68
  id?: string;
68
- identifier: string;
69
+ identifier?: string;
69
70
  name: string;
70
71
  triggerKey: string;
71
72
  workflowDefinition: WorkflowDefinitionPaths;
@@ -87,7 +88,7 @@ export interface WorkflowConditional {
87
88
  export interface ActionDefinitionConfig {
88
89
  name: string;
89
90
  action: string;
90
- config?: {[key: string]: any};
91
+ config?: { [key: string]: any };
91
92
  id?: string;
92
93
  }
93
94
 
@@ -104,6 +105,75 @@ export interface App {
104
105
  triggerKeyDefinitions?: TriggerKeyDefinition[];
105
106
  }
106
107
 
108
+ export interface AppOrg {
109
+ id: string;
110
+ createdOn?: Date;
111
+ updatedOn?: Date;
112
+ createdById?: string;
113
+ updatedById?: string;
114
+ createdBy?: any;
115
+ updatedBy?: any;
116
+ orgId?: string;
117
+ status: AppOrgStatus;
118
+ appId?: string;
119
+ app?: App;
120
+ appVersionId?: string;
121
+ appVersion?: AppVersion;
122
+ apiKey?: AppApiKey;
123
+ appConfig?: any;
124
+ }
125
+
126
+ export enum AppOrgStatus {
127
+ INSTALLING = 'INSTALLING',
128
+ FAILED_INSTALLING = 'FAILED_INSTALLING',
129
+ READY = 'READY',
130
+ DELETING = 'DELETING',
131
+ FAILED_DELETING = 'FAILED_DELETING',
132
+ }
133
+
134
+ export enum AppVersionStatus {
135
+ PUBLISHING = 'PUBLISHING',
136
+ FAILED_PUBLISHING = 'FAILED_PUBLISHING',
137
+ PUBLISHED = 'PUBLISHED',
138
+ ARCHIVING = 'ARCHIVING',
139
+ FAILED_ARCHIVING = 'FAILED_ARCHIVING',
140
+ ARCHIVED = 'ARCHIVED',
141
+ }
142
+
143
+ export class AppVersion {
144
+ id: string;
145
+ createdOn?: Date;
146
+ updatedOn?: Date;
147
+ createdById?: string;
148
+ updatedById?: string;
149
+ createdBy?: any;
150
+ updatedBy?: any;
151
+ orgId?: string;
152
+ appId?: string;
153
+ app?: App;
154
+ appOrgs?: AppOrg[];
155
+ versionNumber: number;
156
+ status: AppVersionStatus;
157
+ eventWorkflowTriggerKeyMapping: string;
158
+ configProperties?: ConfigProperty[];
159
+ triggerKeyDefinitions?: TriggerKeyDefinition[];
160
+ dockerImageRef?: string;
161
+ }
162
+
163
+ export class AppApiKey {
164
+ id: string;
165
+ createdOn?: Date;
166
+ updatedOn?: Date;
167
+ createdById?: string;
168
+ updatedById?: string;
169
+ createdBy?: any;
170
+ updatedBy?: any;
171
+ orgId?: string;
172
+ appOrgId?: string;
173
+ appOrg?: AppOrg;
174
+ apiKey?: string;
175
+ }
176
+
107
177
  export class ConfigProperty {
108
178
  slug: string;
109
179
  propertyType: string;
@@ -1,4 +1,4 @@
1
- import { GetSuggestedTypes, GetTypesFromTemplate } from '@contrail/types';
1
+ import { GetSuggestedTypes, GetTypesFromTemplate, GetTypesFromTemplateWithOptionSetsFromData } from '@contrail/types';
2
2
  import chalk from 'chalk';
3
3
  import fs from 'fs';
4
4
  import { getSeparatorByPlatform } from '../common';
@@ -76,6 +76,30 @@ export async function ParseTypesFromTemplateFromLocalFiles(args) {
76
76
  console.log('%s Parsing Complete.', chalk.green.bold('COMPLETE'));
77
77
  }
78
78
 
79
+ export async function ParseTypesFromTemplateAndDataFromLocalFiles(args) {
80
+ try {
81
+ if (args?.length < 5) {
82
+ throw new Error('File names must be included.');
83
+ }
84
+ console.log('%s Parsing', chalk.yellow.bold('TYPES AND OPTION SETS'));
85
+ const templateFileLocation = args[3];
86
+ const dataFileLocations = (args as Array<string>).slice(4);
87
+
88
+ console.log('Using Template File Location: ', templateFileLocation);
89
+ console.log('Using Data File Location: ', dataFileLocations);
90
+
91
+ await parseTypesFromTemplateAndDataFromLocalFiles(templateFileLocation, dataFileLocations);
92
+ console.log('%s Parsed', chalk.yellow.bold('TYPES AND OPTION SETS'));
93
+
94
+ }
95
+ catch (e) {
96
+ console.log(`%s Parsing Failed. ${e}`, chalk.red.bold('FAIL'));
97
+ return;
98
+ }
99
+
100
+ console.log('%s Parsing Complete.', chalk.green.bold('COMPLETE'));
101
+ }
102
+
79
103
  async function loadDataFromLocalCSV(fileName) {
80
104
  const CURRENT_DIR = process.cwd();
81
105
  try {
@@ -137,6 +161,39 @@ async function parseTypesFromTemplateFromLocalFiles(templateFileLocation: string
137
161
  saveData({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml');
138
162
  }
139
163
 
164
+ async function parseTypesFromTemplateAndDataFromLocalFiles(templateFileLocation: string, dataFileLocations: string[]) {
165
+
166
+ let templateCSVData: any[] = [];
167
+ try {
168
+ console.log('Getting template from fileLocation: ', templateFileLocation);
169
+ templateCSVData = await loadDataFromLocalCSV(templateFileLocation);
170
+ console.log(`CSV import was successful. ${templateCSVData?.length} rows found.`);
171
+ }
172
+ catch (e) {
173
+ console.log('Error importing csv data.', e);
174
+ throw e;
175
+ }
176
+
177
+ const dataCSVData: any[] = [];
178
+ for (const dataFileLocation of dataFileLocations) {
179
+ try {
180
+ console.log('Getting data for dataFileLocation: ', dataFileLocation);
181
+ const csvData = await loadDataFromLocalCSV(dataFileLocation);
182
+
183
+ console.log(`CSV import was successful. ${csvData?.length} rows found. Adding to total rows.`);
184
+ dataCSVData.push(...csvData);
185
+ }
186
+ catch (e) {
187
+ console.log('Error importing csv data.', e);
188
+ throw e;
189
+ }
190
+ }
191
+
192
+ const types = GetTypesFromTemplateWithOptionSetsFromData(templateCSVData, dataCSVData);
193
+ saveData({ optionSets: types.OptionSets }, 'parsed_optionSets.yml');
194
+ saveData({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml');
195
+ }
196
+
140
197
  async function parseTypesFromFiles(fileIds: string[]) {
141
198
  await authUser();
142
199
 
@@ -0,0 +1,13 @@
1
+
2
+ import { authUser } from '../auth/login';
3
+ import { WorkflowTemplateDefinitionDeployer } from './workflow-template-definition-deployer';
4
+
5
+ export async function cliInstallWorkflowTemplateDefinitions() {
6
+ await authUser();
7
+ await new WorkflowTemplateDefinitionDeployer().cliInstallWorkflowTemplateDefinitions();
8
+ }
9
+
10
+ export async function listWorkflowTemplateDefinitions() {
11
+ await authUser();
12
+ await new WorkflowTemplateDefinitionDeployer().listWorkflowTemplateDefinitions();
13
+ }