@contrail/cli 2.2.8 → 2.3.1

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 (83) hide show
  1. package/README.md +135 -367
  2. package/dist/api/apps.js +1 -2
  3. package/dist/auth/auth.js +1 -0
  4. package/dist/basecommand.js +16 -19
  5. package/dist/commands/app/create.js +5 -5
  6. package/dist/commands/app/delete.js +7 -7
  7. package/dist/commands/app/getApiKey.js +8 -8
  8. package/dist/commands/app/init.js +5 -5
  9. package/dist/commands/app/install.js +24 -24
  10. package/dist/commands/app/publish.js +24 -24
  11. package/dist/commands/app/uninstall.js +14 -14
  12. package/dist/commands/app/upgrade.js +19 -19
  13. package/dist/commands/app/version/major.js +6 -9
  14. package/dist/commands/app/version/minor.js +6 -9
  15. package/dist/commands/app/version/patch.js +6 -9
  16. package/dist/commands/colors/deleteAll.js +5 -5
  17. package/dist/commands/colors/load.js +5 -5
  18. package/dist/commands/config/environments/list.js +6 -9
  19. package/dist/commands/config/environments/remove.js +12 -15
  20. package/dist/commands/config/environments/set.js +11 -14
  21. package/dist/commands/config/list.js +6 -9
  22. package/dist/commands/config/remove.js +16 -19
  23. package/dist/commands/config/set.js +22 -25
  24. package/dist/commands/groups/export.js +21 -22
  25. package/dist/commands/groups/upload.js +10 -11
  26. package/dist/commands/instance/export.js +19 -19
  27. package/dist/commands/instance/import.js +13 -13
  28. package/dist/commands/loader-process/load.js +12 -12
  29. package/dist/commands/loader-process/upload-and-load.js +17 -17
  30. package/dist/commands/projects/export.js +9 -9
  31. package/dist/commands/projects/list.js +5 -5
  32. package/dist/commands/projects/load.js +16 -17
  33. package/dist/commands/types/exportOptionSetHierarchies.js +5 -5
  34. package/dist/commands/types/getAll.js +73 -72
  35. package/dist/commands/types/loadAll.js +13 -13
  36. package/dist/commands/types/mergeOptionSets.js +9 -10
  37. package/dist/commands/types/mergeTypeProperties.js +11 -11
  38. package/dist/commands/types/parseOptionSetsHierarchyLocalFile.js +9 -9
  39. package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.js +9 -9
  40. package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +21 -0
  41. package/dist/commands/types/parseOptionSetsLocalFiles.js +97 -17
  42. package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +0 -1
  43. package/dist/commands/types/parseOptionSetsToFolderStructure.js +5 -41
  44. package/dist/commands/types/parseTypesFromFiles.js +13 -13
  45. package/dist/commands/types/parseTypesFromLocalFiles.js +10 -10
  46. package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.js +10 -10
  47. package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.js +9 -9
  48. package/dist/commands/types/uploadOptionSetHierarchies.js +15 -16
  49. package/dist/commands/types/uploadOptionSets.js +15 -13
  50. package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.js +13 -13
  51. package/dist/commands/types/uploadRuleSets.js +13 -13
  52. package/dist/commands/types/uploadTypePolicies.js +16 -16
  53. package/dist/commands/types/uploadTypePropertyPolicies.js +16 -16
  54. package/dist/commands/types/uploadTypes.js +13 -13
  55. package/dist/commands/types/uploadUsageInfo.js +13 -13
  56. package/dist/commands/users/export.js +19 -20
  57. package/dist/commands/users/upload.js +8 -8
  58. package/dist/commands/webhooks/create.js +5 -5
  59. package/dist/commands/webhooks/delete.js +11 -11
  60. package/dist/commands/webhooks/getWebhookTrigger.js +5 -5
  61. package/dist/commands/webhooks/list.js +11 -11
  62. package/dist/commands/workflow-template-definitions/install.js +5 -5
  63. package/dist/commands/workflow-template-definitions/list.js +5 -5
  64. package/dist/commands/workflow-templates/delete.js +5 -5
  65. package/dist/commands/workflow-templates/export.js +19 -20
  66. package/dist/commands/workflow-templates/list.js +5 -5
  67. package/dist/commands/workflow-templates/load.js +11 -11
  68. package/dist/helpers/app/actions-deployer.js +4 -4
  69. package/dist/helpers/app/app-deployer.js +9 -9
  70. package/dist/helpers/app/app-template-parsers.js +1 -1
  71. package/dist/helpers/app/extensions-deployer.js +5 -6
  72. package/dist/helpers/app/load-app-config.js +1 -1
  73. package/dist/helpers/loader-process/helpers.js +3 -3
  74. package/dist/helpers/projects/helpers.js +5 -5
  75. package/dist/helpers/types/type-parser.js +8 -8
  76. package/dist/helpers/types/type-uploader.js +19 -20
  77. package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.js +3 -4
  78. package/dist/helpers/workflow-templates/helper.js +11 -16
  79. package/dist/interface-converters.js +1 -2
  80. package/dist/interfaces.js +79 -0
  81. package/dist/logger.js +7 -6
  82. package/oclif.manifest.json +60 -1422
  83. package/package.json +1 -1
@@ -15,25 +15,25 @@ const logger_1 = tslib_1.__importDefault(require("../../logger"));
15
15
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
16
16
  const _ = tslib_1.__importStar(require("lodash"));
17
17
  class UploadTypePropertyPolicies extends basecommand_1.BaseCommand {
18
+ static description = 'Upload type property policies';
19
+ static examples = [
20
+ `$ contrail types uploadTypePropertyPolicies
21
+ `,
22
+ ];
23
+ static flags = {
24
+ dir: core_1.Flags.string({
25
+ char: 'd',
26
+ description: 'The directory from which to export the type property policy data. Defaults to the current directory. The type property policy data will be loaded from $dir/type-property-policies/*.yml',
27
+ required: false,
28
+ default: '.',
29
+ }),
30
+ };
18
31
  async run() {
19
32
  const { flags } = await this.parse(UploadTypePropertyPolicies);
20
33
  return await uploadTypePropertyPolicies(flags.dir);
21
34
  }
22
35
  }
23
36
  exports.default = UploadTypePropertyPolicies;
24
- UploadTypePropertyPolicies.description = 'Upload type property policies';
25
- UploadTypePropertyPolicies.examples = [
26
- `$ contrail types uploadTypePropertyPolicies
27
- `,
28
- ];
29
- UploadTypePropertyPolicies.flags = {
30
- dir: core_1.Flags.string({
31
- char: 'd',
32
- description: 'The directory from which to export the type property policy data. Defaults to the current directory. The type property policy data will be loaded from $dir/type-property-policies/*.yml',
33
- required: false,
34
- default: '.',
35
- }),
36
- };
37
37
  async function uploadTypePropertyPolicies(dir) {
38
38
  try {
39
39
  await (0, login_1.authUser)();
@@ -72,14 +72,14 @@ async function uploadTPPolicyObjects(reducedTypePropertyPolicies) {
72
72
  const orgUsers = await (0, users_1.getUserOrgs)();
73
73
  const groups = await (0, users_1.getGroups)();
74
74
  function fillPrincipal(statement) {
75
- const principal = statement === null || statement === void 0 ? void 0 : statement.principal;
75
+ const principal = statement?.principal;
76
76
  if (!principal) {
77
- logger_1.default.warn(`skipping bad statement principal ${statement === null || statement === void 0 ? void 0 : statement.principal}`);
77
+ logger_1.default.warn(`skipping bad statement principal ${statement?.principal}`);
78
78
  return statement;
79
79
  }
80
80
  const [type, identifier] = principal.split(':');
81
81
  if (!type || !identifier) {
82
- logger_1.default.warn(`skipping bad statement principal ${statement === null || statement === void 0 ? void 0 : statement.principal}`);
82
+ logger_1.default.warn(`skipping bad statement principal ${statement?.principal}`);
83
83
  return statement;
84
84
  }
85
85
  if (type === 'group') {
@@ -5,25 +5,25 @@ const type_uploader_1 = require("../../helpers/types/type-uploader");
5
5
  const core_1 = require("@oclif/core");
6
6
  const basecommand_1 = require("../../basecommand");
7
7
  class UploadTypes extends basecommand_1.BaseCommand {
8
+ static description = 'Upload Types Org. OptionSets are loaded from .yml files in the types directory.';
9
+ static examples = [
10
+ `$ contrail types uploadTypes
11
+ `,
12
+ ];
13
+ static flags = {
14
+ dir: core_1.Flags.string({
15
+ char: 'd',
16
+ description: 'The directory from which to export the option set data. Defaults to the current directory. The option set data will be loaded from $dir/types',
17
+ required: false,
18
+ default: '.',
19
+ }),
20
+ };
8
21
  async run() {
9
22
  const { flags } = await this.parse(UploadTypes);
10
23
  return await uploadTypes(flags.dir);
11
24
  }
12
25
  }
13
26
  exports.default = UploadTypes;
14
- UploadTypes.description = 'Upload Types Org. OptionSets are loaded from .yml files in the types directory.';
15
- UploadTypes.examples = [
16
- `$ contrail types uploadTypes
17
- `,
18
- ];
19
- UploadTypes.flags = {
20
- dir: core_1.Flags.string({
21
- char: 'd',
22
- description: 'The directory from which to export the option set data. Defaults to the current directory. The option set data will be loaded from $dir/types',
23
- required: false,
24
- default: '.',
25
- }),
26
- };
27
27
  async function uploadTypes(dir) {
28
28
  await (0, type_uploader_1.uploadTypes)(dir);
29
29
  }
@@ -13,25 +13,25 @@ const basecommand_1 = require("../../basecommand");
13
13
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
14
14
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
15
15
  class UploadUsageInfo extends basecommand_1.BaseCommand {
16
+ static description = 'Upload extracted usage info';
17
+ static examples = [
18
+ `$ contrail types uploadUsageInfo
19
+ `,
20
+ ];
21
+ static flags = {
22
+ dir: core_1.Flags.string({
23
+ char: 'd',
24
+ description: 'The directory from which to export the usage info data. Defaults to the current directory. The usage info data will be loaded from $dir/usage-info.yml',
25
+ required: false,
26
+ default: '.',
27
+ }),
28
+ };
16
29
  async run() {
17
30
  const { flags } = await this.parse(UploadUsageInfo);
18
31
  await uploadUsageInfo(flags.dir);
19
32
  }
20
33
  }
21
34
  exports.default = UploadUsageInfo;
22
- UploadUsageInfo.description = 'Upload extracted usage info';
23
- UploadUsageInfo.examples = [
24
- `$ contrail types uploadUsageInfo
25
- `,
26
- ];
27
- UploadUsageInfo.flags = {
28
- dir: core_1.Flags.string({
29
- char: 'd',
30
- description: 'The directory from which to export the usage info data. Defaults to the current directory. The usage info data will be loaded from $dir/usage-info.yml',
31
- required: false,
32
- default: '.',
33
- }),
34
- };
35
35
  async function uploadUsageInfo(dir) {
36
36
  try {
37
37
  await (0, login_1.authUser)();
@@ -13,13 +13,30 @@ const users_1 = require("../../api/users");
13
13
  const basecommand_1 = require("../../basecommand");
14
14
  exports.DEFAULT_FILE_LOCATION = 'users.yml';
15
15
  class ExportUsers extends basecommand_1.BaseCommand {
16
+ static description = 'Export all users in the org.';
17
+ static examples = [
18
+ `$ contrail users export
19
+ `,
20
+ ];
21
+ static flags = {
22
+ outFile: core_1.Flags.string({
23
+ char: 'f',
24
+ description: 'The location for the file to be saved',
25
+ required: false,
26
+ default: exports.DEFAULT_FILE_LOCATION,
27
+ }),
28
+ overwrite: core_1.Flags.boolean({
29
+ description: 'Replaces existing files if they exist',
30
+ required: false,
31
+ default: false,
32
+ }),
33
+ };
16
34
  async run() {
17
- var _a;
18
35
  const { flags } = await this.parse(ExportUsers);
19
36
  try {
20
37
  await (0, login_1.authUser)();
21
38
  this.log('%s Getting Users.', chalk_1.default.blue.bold('START'));
22
- await exportUsers((_a = flags.outFile) !== null && _a !== void 0 ? _a : exports.DEFAULT_FILE_LOCATION, flags.overwrite);
39
+ await exportUsers(flags.outFile ?? exports.DEFAULT_FILE_LOCATION, flags.overwrite);
23
40
  this.log('%s Done', chalk_1.default.yellow.bold('USERS'));
24
41
  }
25
42
  catch (e) {
@@ -30,24 +47,6 @@ class ExportUsers extends basecommand_1.BaseCommand {
30
47
  }
31
48
  }
32
49
  exports.default = ExportUsers;
33
- ExportUsers.description = 'Export all users in the org.';
34
- ExportUsers.examples = [
35
- `$ contrail users export
36
- `,
37
- ];
38
- ExportUsers.flags = {
39
- outFile: core_1.Flags.string({
40
- char: 'f',
41
- description: 'The location for the file to be saved',
42
- required: false,
43
- default: exports.DEFAULT_FILE_LOCATION,
44
- }),
45
- overwrite: core_1.Flags.boolean({
46
- description: 'Replaces existing files if they exist',
47
- required: false,
48
- default: false,
49
- }),
50
- };
51
50
  async function exportUsers(fileLocation, overwrite) {
52
51
  const allUsersInOrg = await (0, users_1.getUserOrgs)();
53
52
  let users = [];
@@ -11,6 +11,14 @@ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
11
11
  const core_1 = require("@oclif/core");
12
12
  const basecommand_1 = require("../../basecommand");
13
13
  class ImportUsers extends basecommand_1.BaseCommand {
14
+ static description = 'Import all users in the users.yml file';
15
+ static examples = [
16
+ `$ contrail users import <USERS_FILE>
17
+ `,
18
+ ];
19
+ static args = {
20
+ usersFile: core_1.Args.string({ description: 'The .yml file containing the users', required: true }),
21
+ };
14
22
  async run() {
15
23
  const { args } = await this.parse(ImportUsers);
16
24
  try {
@@ -28,14 +36,6 @@ class ImportUsers extends basecommand_1.BaseCommand {
28
36
  }
29
37
  }
30
38
  exports.default = ImportUsers;
31
- ImportUsers.description = 'Import all users in the users.yml file';
32
- ImportUsers.examples = [
33
- `$ contrail users import <USERS_FILE>
34
- `,
35
- ];
36
- ImportUsers.args = {
37
- usersFile: core_1.Args.string({ description: 'The .yml file containing the users', required: true }),
38
- };
39
39
  function getUsersFile(fileLocation) {
40
40
  const CURRENT_DIR = process.cwd();
41
41
  try {
@@ -5,6 +5,11 @@ const login_1 = require("../../auth/login");
5
5
  const webhooks_1 = require("../../api/webhooks");
6
6
  const basecommand_1 = require("../../basecommand");
7
7
  class CreateWebhooks extends basecommand_1.BaseCommand {
8
+ static description = 'Create a new webhook';
9
+ static examples = ['contrail webhooks create'];
10
+ static flags = {
11
+ json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
12
+ };
8
13
  async run() {
9
14
  const { flags } = await this.parse(CreateWebhooks);
10
15
  await (0, login_1.authUser)();
@@ -18,8 +23,3 @@ class CreateWebhooks extends basecommand_1.BaseCommand {
18
23
  }
19
24
  }
20
25
  exports.default = CreateWebhooks;
21
- CreateWebhooks.description = 'Create a new webhook';
22
- CreateWebhooks.examples = ['contrail webhooks create'];
23
- CreateWebhooks.flags = {
24
- json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
25
- };
@@ -8,6 +8,17 @@ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
8
8
  const basecommand_1 = require("../../basecommand");
9
9
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
10
10
  class DeleteWebhooks extends basecommand_1.BaseCommand {
11
+ static description = 'Delete an existing webhook. To delete a single webhook, pass its ID. To delete multiple webhooks, do not pass a value for the ID, and select multiple using the interactive selector';
12
+ static examples = [
13
+ 'contrail webhooks delete',
14
+ 'contrail webhooks delete 12345abcd-1234-abcd-1234-12345abcde',
15
+ ];
16
+ static flags = {
17
+ json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
18
+ };
19
+ static args = {
20
+ webhookId: core_1.Args.string({ description: 'The id of the webhook to delete', required: false }),
21
+ };
11
22
  async run() {
12
23
  const { flags, args } = await this.parse(DeleteWebhooks);
13
24
  await (0, login_1.authUser)();
@@ -40,14 +51,3 @@ class DeleteWebhooks extends basecommand_1.BaseCommand {
40
51
  }
41
52
  }
42
53
  exports.default = DeleteWebhooks;
43
- DeleteWebhooks.description = 'Delete an existing webhook. To delete a single webhook, pass its ID. To delete multiple webhooks, do not pass a value for the ID, and select multiple using the interactive selector';
44
- DeleteWebhooks.examples = [
45
- 'contrail webhooks delete',
46
- 'contrail webhooks delete 12345abcd-1234-abcd-1234-12345abcde',
47
- ];
48
- DeleteWebhooks.flags = {
49
- json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
50
- };
51
- DeleteWebhooks.args = {
52
- webhookId: core_1.Args.string({ description: 'The id of the webhook to delete', required: false }),
53
- };
@@ -8,6 +8,11 @@ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
8
8
  const basecommand_1 = require("../../basecommand");
9
9
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
10
10
  class GetWebhookTrigger extends basecommand_1.BaseCommand {
11
+ static description = 'Crafts a webhook trigger that can be used for event workflows. This command does not alter the state of any webhook or event workflow. It is only a utility for generating a webhook trigger.';
12
+ static examples = ['contrail webhooks getWebhookTrigger 1234-abcd-1234-abcd-1234abcd'];
13
+ static args = {
14
+ webhookId: core_1.Args.string({ description: 'The id of the webhook to delete', required: false }),
15
+ };
11
16
  async run() {
12
17
  const { args } = await this.parse(GetWebhookTrigger);
13
18
  await (0, login_1.authUser)();
@@ -31,8 +36,3 @@ class GetWebhookTrigger extends basecommand_1.BaseCommand {
31
36
  }
32
37
  }
33
38
  exports.default = GetWebhookTrigger;
34
- GetWebhookTrigger.description = 'Crafts a webhook trigger that can be used for event workflows. This command does not alter the state of any webhook or event workflow. It is only a utility for generating a webhook trigger.';
35
- GetWebhookTrigger.examples = ['contrail webhooks getWebhookTrigger 1234-abcd-1234-abcd-1234abcd'];
36
- GetWebhookTrigger.args = {
37
- webhookId: core_1.Args.string({ description: 'The id of the webhook to delete', required: false }),
38
- };
@@ -5,6 +5,17 @@ const webhooks_1 = require("../../api/webhooks");
5
5
  const login_1 = require("../../auth/login");
6
6
  const basecommand_1 = require("../../basecommand");
7
7
  class ListWebhooks extends basecommand_1.BaseCommand {
8
+ static description = 'List current webhooks';
9
+ static examples = ['contrail webhooks list'];
10
+ static flags = {
11
+ // // flag with a value (-n, --name=VALUE)
12
+ // name: Flags.string({char: 'n', description: 'name to print'}),
13
+ // flag with no value (-f, --force)
14
+ json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
15
+ };
16
+ static args = {
17
+ // file: Args.string({description: 'file to read'}),
18
+ };
8
19
  async run() {
9
20
  const { flags } = await this.parse(ListWebhooks);
10
21
  await (0, login_1.authUser)();
@@ -18,14 +29,3 @@ class ListWebhooks extends basecommand_1.BaseCommand {
18
29
  }
19
30
  }
20
31
  exports.default = ListWebhooks;
21
- ListWebhooks.description = 'List current webhooks';
22
- ListWebhooks.examples = ['contrail webhooks list'];
23
- ListWebhooks.flags = {
24
- // // flag with a value (-n, --name=VALUE)
25
- // name: Flags.string({char: 'n', description: 'name to print'}),
26
- // flag with no value (-f, --force)
27
- json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
28
- };
29
- ListWebhooks.args = {
30
- // file: Args.string({description: 'file to read'}),
31
- };
@@ -4,14 +4,14 @@ const login_1 = require("../../auth/login");
4
4
  const workflow_template_definition_deployer_1 = require("../../helpers/workflow-template-definitions/workflow-template-definition-deployer");
5
5
  const basecommand_1 = require("../../basecommand");
6
6
  class InstallWorkflowTemplateDefinitions extends basecommand_1.BaseCommand {
7
+ static description = 'Install the template definitions of an app to your org';
8
+ static examples = [
9
+ `$ contrail workflow-template-definitions install
10
+ `,
11
+ ];
7
12
  async run() {
8
13
  await (0, login_1.authUser)();
9
14
  await new workflow_template_definition_deployer_1.WorkflowTemplateDefinitionDeployer().cliInstallWorkflowTemplateDefinitions();
10
15
  }
11
16
  }
12
17
  exports.default = InstallWorkflowTemplateDefinitions;
13
- InstallWorkflowTemplateDefinitions.description = 'Install the template definitions of an app to your org';
14
- InstallWorkflowTemplateDefinitions.examples = [
15
- `$ contrail workflow-template-definitions install
16
- `,
17
- ];
@@ -4,14 +4,14 @@ const login_1 = require("../../auth/login");
4
4
  const workflow_template_definition_deployer_1 = require("../../helpers/workflow-template-definitions/workflow-template-definition-deployer");
5
5
  const basecommand_1 = require("../../basecommand");
6
6
  class ListWorkflowTemplateDefinitions extends basecommand_1.BaseCommand {
7
+ static description = 'Lists the workflow templates in the org';
8
+ static examples = [
9
+ `$ contrail workflow-template-definitions list
10
+ `,
11
+ ];
7
12
  async run() {
8
13
  await (0, login_1.authUser)();
9
14
  await new workflow_template_definition_deployer_1.WorkflowTemplateDefinitionDeployer().listWorkflowTemplateDefinitions();
10
15
  }
11
16
  }
12
17
  exports.default = ListWorkflowTemplateDefinitions;
13
- ListWorkflowTemplateDefinitions.description = 'Lists the workflow templates in the org';
14
- ListWorkflowTemplateDefinitions.examples = [
15
- `$ contrail workflow-template-definitions list
16
- `,
17
- ];
@@ -4,14 +4,14 @@ const login_1 = require("../../auth/login");
4
4
  const helper_1 = require("../../helpers/workflow-templates/helper");
5
5
  const basecommand_1 = require("../../basecommand");
6
6
  class DeleteWorkflowTemplates extends basecommand_1.BaseCommand {
7
+ static description = 'Delete workflow templates from your org';
8
+ static examples = [
9
+ `$ contrail workflow-templates delete
10
+ `,
11
+ ];
7
12
  async run() {
8
13
  await (0, login_1.authUser)();
9
14
  await new helper_1.WorkflowTemplateDeployer().deleteWorkflowTemplates();
10
15
  }
11
16
  }
12
17
  exports.default = DeleteWorkflowTemplates;
13
- DeleteWorkflowTemplates.description = 'Delete workflow templates from your org';
14
- DeleteWorkflowTemplates.examples = [
15
- `$ contrail workflow-templates delete
16
- `,
17
- ];
@@ -15,13 +15,30 @@ const helper_1 = require("../../helpers/workflow-templates/helper");
15
15
  const basecommand_1 = require("../../basecommand");
16
16
  exports.DEFAULT_FILE_LOCATION = 'workflows.yml';
17
17
  class ExportWorkflows extends basecommand_1.BaseCommand {
18
+ static description = 'Export all workflows in the org.';
19
+ static examples = [
20
+ `$ contrail workflow-templates export
21
+ `,
22
+ ];
23
+ static flags = {
24
+ outFile: core_1.Flags.string({
25
+ char: 'f',
26
+ description: 'The location for the file to be saved',
27
+ required: false,
28
+ default: exports.DEFAULT_FILE_LOCATION,
29
+ }),
30
+ overwrite: core_1.Flags.boolean({
31
+ description: 'Replaces existing files if they exist',
32
+ required: false,
33
+ default: false,
34
+ }),
35
+ };
18
36
  async run() {
19
- var _a;
20
37
  const { flags } = await this.parse(ExportWorkflows);
21
38
  try {
22
39
  await (0, login_1.authUser)();
23
40
  this.log('%s Getting Workflows.', chalk_1.default.blue.bold('START'));
24
- await exportWorkflows((_a = flags.outFile) !== null && _a !== void 0 ? _a : exports.DEFAULT_FILE_LOCATION, flags.overwrite);
41
+ await exportWorkflows(flags.outFile ?? exports.DEFAULT_FILE_LOCATION, flags.overwrite);
25
42
  this.log('%s Done', chalk_1.default.yellow.bold('WORKFLOWS'));
26
43
  }
27
44
  catch (e) {
@@ -32,24 +49,6 @@ class ExportWorkflows extends basecommand_1.BaseCommand {
32
49
  }
33
50
  }
34
51
  exports.default = ExportWorkflows;
35
- ExportWorkflows.description = 'Export all workflows in the org.';
36
- ExportWorkflows.examples = [
37
- `$ contrail workflow-templates export
38
- `,
39
- ];
40
- ExportWorkflows.flags = {
41
- outFile: core_1.Flags.string({
42
- char: 'f',
43
- description: 'The location for the file to be saved',
44
- required: false,
45
- default: exports.DEFAULT_FILE_LOCATION,
46
- }),
47
- overwrite: core_1.Flags.boolean({
48
- description: 'Replaces existing files if they exist',
49
- required: false,
50
- default: false,
51
- }),
52
- };
53
52
  async function exportWorkflows(fileLocation, overwrite) {
54
53
  const allWorkflowsInOrg = await (0, event_workflow_templates_1.getExistingWorkflowTemplates)();
55
54
  const workflowsObj = { workflows: [] };
@@ -4,14 +4,14 @@ const login_1 = require("../../auth/login");
4
4
  const helper_1 = require("../../helpers/workflow-templates/helper");
5
5
  const basecommand_1 = require("../../basecommand");
6
6
  class ListWorkflowTemplates extends basecommand_1.BaseCommand {
7
+ static description = 'Lists the workflow templates in the org';
8
+ static examples = [
9
+ `$ contrail workflow-templates list
10
+ `,
11
+ ];
7
12
  async run() {
8
13
  await (0, login_1.authUser)();
9
14
  return await new helper_1.WorkflowTemplateDeployer().listExistingWorkflowTemplates();
10
15
  }
11
16
  }
12
17
  exports.default = ListWorkflowTemplates;
13
- ListWorkflowTemplates.description = 'Lists the workflow templates in the org';
14
- ListWorkflowTemplates.examples = [
15
- `$ contrail workflow-templates list
16
- `,
17
- ];
@@ -5,6 +5,17 @@ const login_1 = require("../../auth/login");
5
5
  const helper_1 = require("../../helpers/workflow-templates/helper");
6
6
  const basecommand_1 = require("../../basecommand");
7
7
  class LoadWorkflowTemplates extends basecommand_1.BaseCommand {
8
+ static description = 'Loads your workflow from a local file';
9
+ static examples = [
10
+ `$ contrail workflow-templates load <FILE_LOCATION>
11
+ `,
12
+ ];
13
+ static args = {
14
+ fileLocation: core_1.Args.string({
15
+ description: 'The workflow template file to load',
16
+ required: true,
17
+ }),
18
+ };
8
19
  async run() {
9
20
  const { args } = await this.parse(LoadWorkflowTemplates);
10
21
  await (0, login_1.authUser)();
@@ -12,14 +23,3 @@ class LoadWorkflowTemplates extends basecommand_1.BaseCommand {
12
23
  }
13
24
  }
14
25
  exports.default = LoadWorkflowTemplates;
15
- LoadWorkflowTemplates.description = 'Loads your workflow from a local file';
16
- LoadWorkflowTemplates.examples = [
17
- `$ contrail workflow-templates load <FILE_LOCATION>
18
- `,
19
- ];
20
- LoadWorkflowTemplates.args = {
21
- fileLocation: core_1.Args.string({
22
- description: 'The workflow template file to load',
23
- required: true,
24
- }),
25
- };
@@ -34,7 +34,7 @@ class ActionsDeployer {
34
34
  logger_1.default.info(`${chalk_1.default.yellow.bold('ACTION')} \tDeploying actions.`);
35
35
  if (appDeclaration.actions) {
36
36
  const localActionKeys = Object.keys(appDeclaration.actions);
37
- if ((localActionKeys === null || localActionKeys === void 0 ? void 0 : localActionKeys.length) > 0) {
37
+ if (localActionKeys?.length > 0) {
38
38
  for (const actionKey of localActionKeys) {
39
39
  await this.deployAction(actionKey, appDeclaration.actions[actionKey], app, existingActions);
40
40
  }
@@ -54,7 +54,7 @@ class ActionsDeployer {
54
54
  }
55
55
  async createNewActionDefinition(actionKey, actionDeclaration, app) {
56
56
  let configProperties;
57
- if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
57
+ if (actionDeclaration?.actionConfiguration) {
58
58
  configProperties = app_template_parsers_1.ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
59
59
  }
60
60
  const newObject = {
@@ -79,10 +79,10 @@ class ActionsDeployer {
79
79
  }
80
80
  async updateActionDefinition(existingActionDefinition, actionDeclaration, app) {
81
81
  let configProperties;
82
- if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
82
+ if (actionDeclaration?.actionConfiguration) {
83
83
  configProperties = app_template_parsers_1.ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
84
84
  }
85
- else if (!(actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) &&
85
+ else if (!actionDeclaration?.actionConfiguration &&
86
86
  existingActionDefinition.configProperties) {
87
87
  configProperties = null;
88
88
  }
@@ -16,6 +16,8 @@ const child_process_1 = tslib_1.__importDefault(require("child_process"));
16
16
  const fs_1 = tslib_1.__importDefault(require("fs"));
17
17
  const extensions_deployer_1 = require("./extensions-deployer");
18
18
  class AppDeployer {
19
+ debug;
20
+ dryRun;
19
21
  constructor(debug = false, dryRun = false) {
20
22
  this.debug = debug;
21
23
  this.dryRun = dryRun;
@@ -46,16 +48,15 @@ class AppDeployer {
46
48
  return apps.find((app) => app.identifier === appDeclaration.appIdentifier);
47
49
  }
48
50
  async createNewApp(appDeclaration) {
49
- var _a;
50
51
  let configProperties;
51
- if (appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.appConfiguration) {
52
+ if (appDeclaration?.appConfiguration) {
52
53
  configProperties = app_template_parsers_1.ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration);
53
54
  }
54
55
  const externalLinks = appDeclaration.externalLinks
55
56
  ? app_template_parsers_1.ExternalLinkParser.validateAndGetExternalLinks(appDeclaration.externalLinks)
56
57
  : [];
57
58
  let triggerKeyDefinitions;
58
- if (appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.triggers) {
59
+ if (appDeclaration?.triggers) {
59
60
  triggerKeyDefinitions = app_template_parsers_1.TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration);
60
61
  }
61
62
  const newApp = {
@@ -72,7 +73,7 @@ class AppDeployer {
72
73
  configProperties,
73
74
  externalLinks,
74
75
  triggerKeyDefinitions,
75
- dockerImageRef: (_a = appDeclaration.dockerImageRef) !== null && _a !== void 0 ? _a : null,
76
+ dockerImageRef: appDeclaration.dockerImageRef ?? null,
76
77
  frameworkVersion: 2,
77
78
  };
78
79
  if (this.dryRun) {
@@ -92,13 +93,12 @@ class AppDeployer {
92
93
  return app;
93
94
  }
94
95
  async updateExistingApp(appDeclaration, existingApp) {
95
- var _a;
96
96
  let configProperties = null;
97
- if (appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.appConfiguration) {
97
+ if (appDeclaration?.appConfiguration) {
98
98
  configProperties = app_template_parsers_1.ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration);
99
99
  }
100
100
  let triggerKeyDefinitions;
101
- if (appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.triggers) {
101
+ if (appDeclaration?.triggers) {
102
102
  triggerKeyDefinitions = app_template_parsers_1.TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration);
103
103
  }
104
104
  // does appDeclaration have dockerImageRef
@@ -125,8 +125,8 @@ class AppDeployer {
125
125
  configProperties,
126
126
  externalLinks,
127
127
  triggerKeyDefinitions,
128
- dockerImageRef: (_a = appDeclaration.dockerImageRef) !== null && _a !== void 0 ? _a : null,
129
- appCodePackageId: appCodePackageId !== null && appCodePackageId !== void 0 ? appCodePackageId : null,
128
+ dockerImageRef: appDeclaration.dockerImageRef ?? null,
129
+ appCodePackageId: appCodePackageId ?? null,
130
130
  frameworkVersion: 2,
131
131
  };
132
132
  logger_1.default.debug(`app update: ${JSON.stringify(updates, null, 2)}`);
@@ -32,7 +32,7 @@ class ConfigPropertiesParser {
32
32
  label: declaration.label,
33
33
  slug: configKey,
34
34
  propertyType: declaration.propertyType,
35
- dynamic: (declaration === null || declaration === void 0 ? void 0 : declaration.dynamic) || false,
35
+ dynamic: declaration?.dynamic || false,
36
36
  };
37
37
  if (declaration.options) {
38
38
  config.options = declaration.options;
@@ -15,7 +15,6 @@ async function getExtensionDefinitionsForAppVersion(app) {
15
15
  exports.getExtensionDefinitionsForAppVersion = getExtensionDefinitionsForAppVersion;
16
16
  class ExtensionsDeployer {
17
17
  async deployExtensions(appDeclaration, app) {
18
- var _a;
19
18
  // FETCH ALL EXTENSIONS FROM THE API.
20
19
  if (!appDeclaration.extensions) {
21
20
  logger_1.default.info(`${chalk_1.default.yellow.bold('EXTENSION')} \tNo extensions found...skipping.`);
@@ -26,13 +25,13 @@ class ExtensionsDeployer {
26
25
  const existingExtensions = await getExtensionDefinitionsForAppVersion(app);
27
26
  logger_1.default.debug(appDeclaration.extensions);
28
27
  if (appDeclaration.extensions) {
29
- for (const extension of (_a = appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.extensions) !== null && _a !== void 0 ? _a : []) {
28
+ for (const extension of appDeclaration?.extensions ?? []) {
30
29
  await this.deployExtension(extension, app, existingExtensions);
31
30
  }
32
31
  }
33
32
  }
34
33
  async deployExtension(extension, app, existingExtensions) {
35
- logger_1.default.info(`${chalk_1.default.yellow.bold('EXTENSION')} \tDeploying extension: ${extension === null || extension === void 0 ? void 0 : extension.identifier}`);
34
+ logger_1.default.info(`${chalk_1.default.yellow.bold('EXTENSION')} \tDeploying extension: ${extension?.identifier}`);
36
35
  const identifier = util_1.AppUtil.createExtensionIdentifier({
37
36
  appIdentifier: app.identifier,
38
37
  extensionIdentifier: extension.identifier,
@@ -48,7 +47,7 @@ class ExtensionsDeployer {
48
47
  async createNewExtensionDefinition(extension, app) {
49
48
  const newObject = {
50
49
  identifier: util_1.AppUtil.createExtensionIdentifier({
51
- extensionIdentifier: extension === null || extension === void 0 ? void 0 : extension.identifier,
50
+ extensionIdentifier: extension?.identifier,
52
51
  appIdentifier: app.identifier,
53
52
  }),
54
53
  name: extension.name,
@@ -63,13 +62,13 @@ class ExtensionsDeployer {
63
62
  entityName: 'app-extension-definition',
64
63
  object: newObject,
65
64
  });
66
- logger_1.default.info(`${chalk_1.default.yellow.bold('EXTENSION')} Created new extension definition: ${extension === null || extension === void 0 ? void 0 : extension.identifier}`);
65
+ logger_1.default.info(`${chalk_1.default.yellow.bold('EXTENSION')} Created new extension definition: ${extension?.identifier}`);
67
66
  return actionDefinition;
68
67
  }
69
68
  async updateActionDefinition(existingActionDefinition, extension, app) {
70
69
  const updates = {
71
70
  identifier: util_1.AppUtil.createExtensionIdentifier({
72
- extensionIdentifier: extension === null || extension === void 0 ? void 0 : extension.identifier,
71
+ extensionIdentifier: extension?.identifier,
73
72
  appIdentifier: app.identifier,
74
73
  }),
75
74
  name: extension.name,