@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
@@ -6,10 +6,28 @@ const config_1 = require("../../helpers/config/config");
6
6
  const basecommand_1 = require("../../basecommand");
7
7
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
8
8
  class SetConfig extends basecommand_1.BaseCommand {
9
- constructor() {
10
- super(...arguments);
11
- this.skipConfirmEnv = true;
12
- }
9
+ skipConfirmEnv = true;
10
+ static description = 'Set a variable in the configuration';
11
+ static examples = ['$ contrail config set --orgId 1234'];
12
+ static flags = {
13
+ orgSlug: core_1.Flags.string({ description: 'The org slug', required: false }),
14
+ apiGateway: core_1.Flags.string({
15
+ description: 'The API Gateway',
16
+ required: false,
17
+ }),
18
+ orgId: core_1.Flags.string({ description: 'The org Id', required: false }),
19
+ apiUserToken: core_1.Flags.string({
20
+ description: 'The API User Token',
21
+ required: false,
22
+ }),
23
+ logLevel: core_1.Flags.string({
24
+ description: 'The Log Level',
25
+ required: false,
26
+ char: 'l',
27
+ options: ['error', 'warn', 'info', 'debug'],
28
+ }),
29
+ };
30
+ static args = {};
13
31
  async run() {
14
32
  const { flags } = await this.parse(SetConfig);
15
33
  const config = {};
@@ -22,24 +40,3 @@ class SetConfig extends basecommand_1.BaseCommand {
22
40
  }
23
41
  }
24
42
  exports.default = SetConfig;
25
- SetConfig.description = 'Set a variable in the configuration';
26
- SetConfig.examples = ['$ contrail config set --orgId 1234'];
27
- SetConfig.flags = {
28
- orgSlug: core_1.Flags.string({ description: 'The org slug', required: false }),
29
- apiGateway: core_1.Flags.string({
30
- description: 'The API Gateway',
31
- required: false,
32
- }),
33
- orgId: core_1.Flags.string({ description: 'The org Id', required: false }),
34
- apiUserToken: core_1.Flags.string({
35
- description: 'The API User Token',
36
- required: false,
37
- }),
38
- logLevel: core_1.Flags.string({
39
- description: 'The Log Level',
40
- required: false,
41
- char: 'l',
42
- options: ['error', 'warn', 'info', 'debug'],
43
- }),
44
- };
45
- SetConfig.args = {};
@@ -14,13 +14,30 @@ const basecommand_1 = require("../../basecommand");
14
14
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
15
15
  exports.DEFAULT_FILE_LOCATION = 'groups.yml';
16
16
  class ExportGroups extends basecommand_1.BaseCommand {
17
+ static description = 'Export all groups in the org.';
18
+ static examples = [
19
+ `$ contrail groups export
20
+ `,
21
+ ];
22
+ static flags = {
23
+ outFile: core_1.Flags.string({
24
+ char: 'f',
25
+ description: 'The location for the file to be saved',
26
+ required: false,
27
+ default: exports.DEFAULT_FILE_LOCATION,
28
+ }),
29
+ overwrite: core_1.Flags.boolean({
30
+ description: 'Replaces existing files if they exist',
31
+ required: false,
32
+ default: false,
33
+ }),
34
+ };
17
35
  async run() {
18
- var _a;
19
36
  const { flags } = await this.parse(ExportGroups);
20
37
  try {
21
38
  await (0, login_1.authUser)();
22
39
  this.log('%s Getting Groups.', chalk_1.default.blue.bold('START'));
23
- await exportGroups((_a = flags.outFile) !== null && _a !== void 0 ? _a : exports.DEFAULT_FILE_LOCATION, flags.overwrite);
40
+ await exportGroups(flags.outFile ?? exports.DEFAULT_FILE_LOCATION, flags.overwrite);
24
41
  this.log('%s Done', chalk_1.default.yellow.bold('GROUPS'));
25
42
  }
26
43
  catch (e) {
@@ -31,24 +48,6 @@ class ExportGroups extends basecommand_1.BaseCommand {
31
48
  }
32
49
  }
33
50
  exports.default = ExportGroups;
34
- ExportGroups.description = 'Export all groups in the org.';
35
- ExportGroups.examples = [
36
- `$ contrail groups export
37
- `,
38
- ];
39
- ExportGroups.flags = {
40
- outFile: core_1.Flags.string({
41
- char: 'f',
42
- description: 'The location for the file to be saved',
43
- required: false,
44
- default: exports.DEFAULT_FILE_LOCATION,
45
- }),
46
- overwrite: core_1.Flags.boolean({
47
- description: 'Replaces existing files if they exist',
48
- required: false,
49
- default: false,
50
- }),
51
- };
52
51
  async function exportGroups(fileLocation, overwrite) {
53
52
  const allGroups = await (0, users_1.getGroups)({ relations: ['groupPrincipals'] });
54
53
  const allUsersInOrg = await (0, users_1.getUserOrgs)();
@@ -74,7 +73,7 @@ async function saveData(data, fileLocation, overwrite) {
74
73
  fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
75
74
  }
76
75
  function getGroupPrincipals(group, allGroups, orgUsers) {
77
- if (!(group === null || group === void 0 ? void 0 : group.groupPrincipals)) {
76
+ if (!group?.groupPrincipals) {
78
77
  return [];
79
78
  }
80
79
  const principals = [];
@@ -100,5 +99,5 @@ function getGroupPrincipals(group, allGroups, orgUsers) {
100
99
  });
101
100
  }
102
101
  }
103
- return principals.sort((one, two) => { var _a, _b; return (((_b = (_a = one.email) !== null && _a !== void 0 ? _a : one.name < two.email) !== null && _b !== void 0 ? _b : two.name) ? -1 : 1); });
102
+ return principals.sort((one, two) => (one.email ?? one.name < two.email ?? two.name ? -1 : 1));
104
103
  }
@@ -12,6 +12,14 @@ const core_1 = require("@oclif/core");
12
12
  const basecommand_1 = require("../../basecommand");
13
13
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
14
14
  class ImportGroups extends basecommand_1.BaseCommand {
15
+ static description = 'Import all groups in the groups.yml file';
16
+ static examples = [
17
+ `$ contrail groups import <GROUPS_FILE>
18
+ `,
19
+ ];
20
+ static args = {
21
+ groupsFile: core_1.Args.string({ description: 'The .yml file containing the groups', required: true }),
22
+ };
15
23
  async run() {
16
24
  const { args } = await this.parse(ImportGroups);
17
25
  try {
@@ -29,14 +37,6 @@ class ImportGroups extends basecommand_1.BaseCommand {
29
37
  }
30
38
  }
31
39
  exports.default = ImportGroups;
32
- ImportGroups.description = 'Import all groups in the groups.yml file';
33
- ImportGroups.examples = [
34
- `$ contrail groups import <GROUPS_FILE>
35
- `,
36
- ];
37
- ImportGroups.args = {
38
- groupsFile: core_1.Args.string({ description: 'The .yml file containing the groups', required: true }),
39
- };
40
40
  function getGroupsFile(fileLocation) {
41
41
  const CURRENT_DIR = process.cwd();
42
42
  try {
@@ -95,7 +95,6 @@ async function uploadGroups(fileLocation) {
95
95
  }
96
96
  exports.uploadGroups = uploadGroups;
97
97
  async function updateGroup(principals, orgUsers, existingGroup, allGroupsAfterCreate) {
98
- var _a;
99
98
  const principalsToUpdate = principals
100
99
  .map((x) => groupPrincipalNameToId(x, allGroupsAfterCreate, orgUsers))
101
100
  .filter((x) => !!x)
@@ -111,7 +110,7 @@ async function updateGroup(principals, orgUsers, existingGroup, allGroupsAfterCr
111
110
  });
112
111
  // remove principals
113
112
  const principalsToKeep = principalsToUpdate.map((principal) => `${principal.type}:${principal.identifier}`);
114
- const principalsToDelete = ((_a = existingGroup === null || existingGroup === void 0 ? void 0 : existingGroup.groupPrincipals) !== null && _a !== void 0 ? _a : [])
113
+ const principalsToDelete = (existingGroup?.groupPrincipals ?? [])
115
114
  .map((x) => groupPrincipalNameToId(x, allGroupsAfterCreate, orgUsers))
116
115
  .filter((x) => !!x)
117
116
  .filter((x) => !principalsToKeep.includes(`${x.type}:${x.identifier}`));
@@ -136,7 +135,7 @@ async function createGroupPrincipals(group, principals, orgUsers, allGroupsAfter
136
135
  }
137
136
  function groupPrincipalNameToId(principal, groups, orgUsers) {
138
137
  if (principal.type === 'user') {
139
- const user = orgUsers.map((x) => x.user).find((x) => x.email === (principal === null || principal === void 0 ? void 0 : principal.email));
138
+ const user = orgUsers.map((x) => x.user).find((x) => x.email === principal?.email);
140
139
  if (!user) {
141
140
  logger_1.default.info(`user ${principal.email} is not in this org's user list`);
142
141
  return undefined;
@@ -8,6 +8,25 @@ const export_1 = require("../users/export");
8
8
  const export_2 = require("../groups/export");
9
9
  const basecommand_1 = require("../../basecommand");
10
10
  class ExportInstance extends basecommand_1.BaseCommand {
11
+ static description = 'Exports an data of an instance including types and users';
12
+ static examples = [
13
+ `$ contrail instance export
14
+ `,
15
+ ];
16
+ static flags = {
17
+ outDir: core_1.Flags.string({
18
+ char: 'd',
19
+ description: 'The directory to which to export the instance data. Defaults to the current directory',
20
+ required: false,
21
+ default: '.',
22
+ }),
23
+ overwrite: core_1.Flags.boolean({
24
+ char: 'f',
25
+ description: 'Replaces any existing export files in outDir',
26
+ required: false,
27
+ default: false,
28
+ }),
29
+ };
11
30
  async run() {
12
31
  const { flags } = await this.parse(ExportInstance);
13
32
  await (0, getAll_1.getAll)(flags.outDir, flags.overwrite);
@@ -16,22 +35,3 @@ class ExportInstance extends basecommand_1.BaseCommand {
16
35
  }
17
36
  }
18
37
  exports.default = ExportInstance;
19
- ExportInstance.description = 'Exports an data of an instance including types and users';
20
- ExportInstance.examples = [
21
- `$ contrail instance export
22
- `,
23
- ];
24
- ExportInstance.flags = {
25
- outDir: core_1.Flags.string({
26
- char: 'd',
27
- description: 'The directory to which to export the instance data. Defaults to the current directory',
28
- required: false,
29
- default: '.',
30
- }),
31
- overwrite: core_1.Flags.boolean({
32
- char: 'f',
33
- description: 'Replaces any existing export files in outDir',
34
- required: false,
35
- default: false,
36
- }),
37
- };
@@ -10,6 +10,19 @@ const uploadTypePropertyPolicies_1 = require("../types/uploadTypePropertyPolicie
10
10
  const uploadTypePolicies_1 = require("../types/uploadTypePolicies");
11
11
  const basecommand_1 = require("../../basecommand");
12
12
  class ImportInstance extends basecommand_1.BaseCommand {
13
+ static description = 'Import the data to an instance, including types and users';
14
+ static examples = [
15
+ `$ contrail instance import
16
+ `,
17
+ ];
18
+ static flags = {
19
+ dir: core_1.Flags.string({
20
+ char: 'd',
21
+ description: 'The directory from which to export the instance data. Defaults to the current directory',
22
+ required: false,
23
+ default: '.',
24
+ }),
25
+ };
13
26
  async run() {
14
27
  const { flags } = await this.parse(ImportInstance);
15
28
  await (0, loadAll_1.loadAll)(flags.dir, true);
@@ -20,16 +33,3 @@ class ImportInstance extends basecommand_1.BaseCommand {
20
33
  }
21
34
  }
22
35
  exports.default = ImportInstance;
23
- ImportInstance.description = 'Import the data to an instance, including types and users';
24
- ImportInstance.examples = [
25
- `$ contrail instance import
26
- `,
27
- ];
28
- ImportInstance.flags = {
29
- dir: core_1.Flags.string({
30
- char: 'd',
31
- description: 'The directory from which to export the instance data. Defaults to the current directory',
32
- required: false,
33
- default: '.',
34
- }),
35
- };
@@ -8,6 +8,18 @@ const helpers_1 = require("../../helpers/loader-process/helpers");
8
8
  const basecommand_1 = require("../../basecommand");
9
9
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
10
10
  class LoadPS extends basecommand_1.BaseCommand {
11
+ static description = 'Upload a csv file and kick off a load job for the uploaded file. The config path must be a reference to a .json or a .yml file.';
12
+ static examples = [
13
+ `$ contrail load-processor load
14
+ `,
15
+ ];
16
+ static args = {
17
+ configFileName: core_1.Args.string({
18
+ char: 'c',
19
+ description: 'The configuration file location',
20
+ required: true,
21
+ }),
22
+ };
11
23
  async run() {
12
24
  const { args } = await this.parse(LoadPS);
13
25
  try {
@@ -25,15 +37,3 @@ class LoadPS extends basecommand_1.BaseCommand {
25
37
  }
26
38
  }
27
39
  exports.default = LoadPS;
28
- LoadPS.description = 'Upload a csv file and kick off a load job for the uploaded file. The config path must be a reference to a .json or a .yml file.';
29
- LoadPS.examples = [
30
- `$ contrail load-processor load
31
- `,
32
- ];
33
- LoadPS.args = {
34
- configFileName: core_1.Args.string({
35
- char: 'c',
36
- description: 'The configuration file location',
37
- required: true,
38
- }),
39
- };
@@ -8,6 +8,23 @@ const helpers_1 = require("../../helpers/loader-process/helpers");
8
8
  const basecommand_1 = require("../../basecommand");
9
9
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
10
10
  class UploadAndLoadPS extends basecommand_1.BaseCommand {
11
+ static description = 'Upload a csv file and kick off a load job for the uploaded file. The file path must be a reference to a .csv file and the config path must be a reference to a .json or a .yml file';
12
+ static examples = [
13
+ `$ contrail load-processor upload-and-load <File Path> <Config Path>
14
+ `,
15
+ ];
16
+ static args = {
17
+ incomingFile: core_1.Args.string({
18
+ char: 'f',
19
+ description: 'The incoming file location',
20
+ required: true,
21
+ }),
22
+ configFileName: core_1.Args.string({
23
+ char: 'c',
24
+ description: 'The configuration file location',
25
+ required: true,
26
+ }),
27
+ };
11
28
  async run() {
12
29
  const { args } = await this.parse(UploadAndLoadPS);
13
30
  try {
@@ -26,20 +43,3 @@ class UploadAndLoadPS extends basecommand_1.BaseCommand {
26
43
  }
27
44
  }
28
45
  exports.default = UploadAndLoadPS;
29
- UploadAndLoadPS.description = 'Upload a csv file and kick off a load job for the uploaded file. The file path must be a reference to a .csv file and the config path must be a reference to a .json or a .yml file';
30
- UploadAndLoadPS.examples = [
31
- `$ contrail load-processor upload-and-load <File Path> <Config Path>
32
- `,
33
- ];
34
- UploadAndLoadPS.args = {
35
- incomingFile: core_1.Args.string({
36
- char: 'f',
37
- description: 'The incoming file location',
38
- required: true,
39
- }),
40
- configFileName: core_1.Args.string({
41
- char: 'c',
42
- description: 'The configuration file location',
43
- required: true,
44
- }),
45
- };
@@ -7,6 +7,15 @@ const login_1 = require("../../auth/login");
7
7
  const helpers_1 = require("../../helpers/projects/helpers");
8
8
  const basecommand_1 = require("../../basecommand");
9
9
  class ExportProjects extends basecommand_1.BaseCommand {
10
+ static description = 'Export a project.';
11
+ static examples = [
12
+ `$ contrail project export <PROJECT_NAME>
13
+ `,
14
+ ];
15
+ static flags = {};
16
+ static args = {
17
+ projectName: core_1.Args.string({ description: '', required: true }),
18
+ };
10
19
  async run() {
11
20
  const { args } = await this.parse(ExportProjects);
12
21
  try {
@@ -24,12 +33,3 @@ class ExportProjects extends basecommand_1.BaseCommand {
24
33
  }
25
34
  }
26
35
  exports.default = ExportProjects;
27
- ExportProjects.description = 'Export a project.';
28
- ExportProjects.examples = [
29
- `$ contrail project export <PROJECT_NAME>
30
- `,
31
- ];
32
- ExportProjects.flags = {};
33
- ExportProjects.args = {
34
- projectName: core_1.Args.string({ description: '', required: true }),
35
- };
@@ -6,6 +6,11 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
6
  const login_1 = require("../../auth/login");
7
7
  const basecommand_1 = require("../../basecommand");
8
8
  class ListProjects extends basecommand_1.BaseCommand {
9
+ static description = 'Get a list of all projects.';
10
+ static examples = [
11
+ `$ contrail project list
12
+ `,
13
+ ];
9
14
  async run() {
10
15
  try {
11
16
  await (0, login_1.authUser)();
@@ -27,8 +32,3 @@ class ListProjects extends basecommand_1.BaseCommand {
27
32
  }
28
33
  }
29
34
  exports.default = ListProjects;
30
- ListProjects.description = 'Get a list of all projects.';
31
- ListProjects.examples = [
32
- `$ contrail project list
33
- `,
34
- ];
@@ -10,6 +10,17 @@ const basecommand_1 = require("../../basecommand");
10
10
  const helpers_1 = require("../../helpers/projects/helpers");
11
11
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
12
12
  class LoadProject extends basecommand_1.BaseCommand {
13
+ static description = 'Configure a project from a yml file.';
14
+ static examples = [
15
+ `$ contrail project load <TEMPLATE_FILE_LOCATION>
16
+ `,
17
+ ];
18
+ static args = {
19
+ templateFileLocation: core_1.Args.string({
20
+ description: 'The location to the template file',
21
+ required: true,
22
+ }),
23
+ };
13
24
  async run() {
14
25
  const { args } = await this.parse(LoadProject);
15
26
  try {
@@ -29,17 +40,6 @@ class LoadProject extends basecommand_1.BaseCommand {
29
40
  }
30
41
  }
31
42
  exports.default = LoadProject;
32
- LoadProject.description = 'Configure a project from a yml file.';
33
- LoadProject.examples = [
34
- `$ contrail project load <TEMPLATE_FILE_LOCATION>
35
- `,
36
- ];
37
- LoadProject.args = {
38
- templateFileLocation: core_1.Args.string({
39
- description: 'The location to the template file',
40
- required: true,
41
- }),
42
- };
43
43
  async function uploadProject(templateFileLocation) {
44
44
  const projectConfigurationFromFile = (0, helpers_1.getProjectFile)(templateFileLocation);
45
45
  const projectConfiguration = getProjectConfiguration(projectConfigurationFromFile);
@@ -149,16 +149,15 @@ async function transformProject(projectConfiguration) {
149
149
  * @param assortments The expected node value passed ot this function is a list of assortments
150
150
  */
151
151
  async function transformAssortmentObjectReferences(_, assortments) {
152
- var _a, _b, _c, _d, _e;
153
152
  const typesClient = new sdk_1.Types();
154
153
  const assortmentType = await typesClient.getType({
155
154
  path: 'assortment',
156
155
  relations: ['typeProperties'],
157
156
  });
158
157
  const assortmentProperties = assortmentType.typeProperties;
159
- for (const assortment of assortments !== null && assortments !== void 0 ? assortments : []) {
160
- const attributes = JSON.parse(JSON.stringify((_a = assortment === null || assortment === void 0 ? void 0 : assortment.assortmentAtts) !== null && _a !== void 0 ? _a : {}));
161
- if (!((_b = Object.keys(attributes)) === null || _b === void 0 ? void 0 : _b.length)) {
158
+ for (const assortment of assortments ?? []) {
159
+ const attributes = JSON.parse(JSON.stringify(assortment?.assortmentAtts ?? {}));
160
+ if (!Object.keys(attributes)?.length) {
162
161
  continue;
163
162
  }
164
163
  for (const [attributeKey, attributeValue] of Object.entries(attributes)) {
@@ -170,7 +169,7 @@ async function transformAssortmentObjectReferences(_, assortments) {
170
169
  if (property.propertyType === types_1.PropertyType.TypeReference) {
171
170
  logger_1.default.debug(`found type reference!${attributeKey}${attributeValue}`);
172
171
  // special case: handle type references
173
- const type = (_c = (await new sdk_1.Types().getType({ path: attributeValue }))) === null || _c === void 0 ? void 0 : _c.id;
172
+ const type = (await new sdk_1.Types().getType({ path: attributeValue }))?.id;
174
173
  logger_1.default.debug(`found type ${type}`);
175
174
  logger_1.default.info(`replacing ${attributeKey}:${attributeValue} with ${attributeKey}Id:${type}`);
176
175
  assortment.assortmentAtts[`${attributeKey}Id`] = type;
@@ -188,7 +187,7 @@ async function transformAssortmentObjectReferences(_, assortments) {
188
187
  allEntities = await new sdk_1.Entities().get({ entityName: property.referencedTypePath });
189
188
  }
190
189
  // special case: handle type references
191
- const foundAttribute = (_e = (_d = allEntities.find((x) => x.name === attributeValue)) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : attributeKey;
190
+ const foundAttribute = allEntities.find((x) => x.name === attributeValue)?.id ?? attributeKey;
192
191
  logger_1.default.debug(`found attribute ${foundAttribute}`);
193
192
  logger_1.default.info(`replacing ${attributeKey}:${attributeValue} with ${attributeKey}Id:${foundAttribute}`);
194
193
  assortment.assortmentAtts[`${attributeKey}Id`] = foundAttribute;
@@ -12,16 +12,16 @@ const basecommand_1 = require("../../basecommand");
12
12
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
13
13
  const json2csv_1 = require("json2csv");
14
14
  class ExportOptionSetsHierarchies extends basecommand_1.BaseCommand {
15
+ static description = 'export OptionSetHierarchies into CSVs.';
16
+ static examples = [
17
+ `$ contrail types exportOptionSetsHierarchies
18
+ `,
19
+ ];
15
20
  async run() {
16
21
  await exportOptionSetsHierarchies();
17
22
  }
18
23
  }
19
24
  exports.default = ExportOptionSetsHierarchies;
20
- ExportOptionSetsHierarchies.description = 'export OptionSetHierarchies into CSVs.';
21
- ExportOptionSetsHierarchies.examples = [
22
- `$ contrail types exportOptionSetsHierarchies
23
- `,
24
- ];
25
25
  async function exportOptionSetsHierarchies() {
26
26
  try {
27
27
  await (0, login_1.authUser)();