@contrail/cli 2.2.8 → 2.3.0

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 +95 -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
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseLabelsInColumn = exports.ParseOptionSetsToFolderStructure = void 0;
3
+ exports.parseNameAndLabelAndKey = exports.parseLabelsInColumn = exports.ParseOptionSetsToFolderStructure = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const path = tslib_1.__importStar(require("path"));
6
6
  const fs_1 = tslib_1.__importDefault(require("fs"));
7
- const types_1 = require("@contrail/types");
8
7
  const util_1 = require("@contrail/util");
9
8
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
9
  const csvtojson_1 = tslib_1.__importDefault(require("csvtojson"));
@@ -14,6 +13,40 @@ const basecommand_1 = require("../../basecommand");
14
13
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
15
14
  const common_1 = require("../../common");
16
15
  class ParseOptionSetsLocalFiles extends basecommand_1.BaseCommand {
16
+ static description = 'Parse CSV files into OptionSets. Style denotes the format the csv is in. If the csv file has a column for option set' +
17
+ 'name, option key, and option label, use "NameAndLabelAndKey". If the file has one column for each option set with ' +
18
+ `the rows being the label value use "LabelsInColumn". In the case of LabelsInColumn, the keys are autogenerated.
19
+
20
+ Example file for LabelsInColumn would be
21
+
22
+ Gender, Countries, Brands
23
+ men, spain, prada
24
+ women, france, converse
25
+ unisex, australia
26
+ , usa
27
+ , egypt
28
+
29
+ Example file for NameAndLabelAndKey would be
30
+
31
+ Gender, g_men, Men
32
+ Bender, g_women, Women
33
+ Gender g_uni, Unisex
34
+ Countries, co_spain, Spain
35
+ Countries, co_france, France
36
+ Countries, co_aus, Australia
37
+ Countries, co_usa, United States of America,
38
+ Countries, co_egypt, Egypt
39
+ `;
40
+ static examples = [
41
+ `$ contrail types parseOptionSetsLocalFiles <File Paths> <style>
42
+ `,
43
+ ];
44
+ static flags = {
45
+ csvStyle: core_1.Flags.string({ options: ['NameAndLabelAndKey', 'LabelsInColumn'], required: true }),
46
+ };
47
+ static args = {
48
+ file: core_1.Args.string({ description: 'File to parse', required: true }),
49
+ };
17
50
  async run() {
18
51
  const { args, flags } = await this.parse(ParseOptionSetsLocalFiles);
19
52
  try {
@@ -24,26 +57,16 @@ class ParseOptionSetsLocalFiles extends basecommand_1.BaseCommand {
24
57
  }
25
58
  catch (e) {
26
59
  this.log(`%s PARSE Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
60
+ console.error(e);
27
61
  return;
28
62
  }
29
63
  this.log('%s PARSE Complete.', chalk_1.default.green.bold('COMPLETE'));
30
64
  }
31
65
  }
32
66
  exports.default = ParseOptionSetsLocalFiles;
33
- ParseOptionSetsLocalFiles.description = 'Parse CSV files into OptionSets. Style denotes the format the csv is in. If the csv file has a column for name and label, use "NameAndLabel". If the file has one column for each option set with the rows being the label value use "LabelsInColumn"';
34
- ParseOptionSetsLocalFiles.examples = [
35
- `$ contrail types parseOptionSetsLocalFiles <File Paths> <style>
36
- `,
37
- ];
38
- ParseOptionSetsLocalFiles.flags = {
39
- csvStyle: core_1.Flags.string({ options: ['NameAndLabel', 'LabelsInColumn'], required: true }),
40
- };
41
- ParseOptionSetsLocalFiles.args = {
42
- file: core_1.Args.string({ description: 'File to parse', required: true }),
43
- };
44
67
  async function ParseOptionSetsToFolderStructure(args) {
45
68
  try {
46
- if ((args === null || args === void 0 ? void 0 : args.length) < 4) {
69
+ if (args?.length < 4) {
47
70
  throw new Error('File name must be included.');
48
71
  }
49
72
  logger_1.default.info('%s Importing local file', chalk_1.default.yellow.bold('OPTION SET PARSE'));
@@ -84,8 +107,8 @@ function loadOptionSets(fileLocation) {
84
107
  }
85
108
  async function parseOptionSetsLocalFiles(fileLocation, csvStyle) {
86
109
  const uploadedOptionData = await loadOptionSetCSV(fileLocation);
87
- if (csvStyle === 'NameAndLabel') {
88
- const parsedOptionSets = (0, types_1.parseOptionSets)(uploadedOptionData);
110
+ if (csvStyle === 'NameAndLabelAndKey') {
111
+ const parsedOptionSets = parseNameAndLabelAndKey(uploadedOptionData);
89
112
  saveData(parsedOptionSets);
90
113
  }
91
114
  if (csvStyle === 'LabelsInColumn') {
@@ -119,6 +142,11 @@ function saveDataInFolders(data) {
119
142
  fs_1.default.writeFileSync(path.join(subDir, `${(0, common_1.removeSlash)(fileLabel)}.yml`), yamlStr, 'utf8');
120
143
  }
121
144
  }
145
+ /**
146
+ * Expects
147
+ * @param uploadedOptionData
148
+ * @returns
149
+ */
122
150
  function parseLabelsInColumn(uploadedOptionData) {
123
151
  const optionSets = [];
124
152
  const optionSetNames = Object.keys(uploadedOptionData[0]);
@@ -131,7 +159,7 @@ function parseLabelsInColumn(uploadedOptionData) {
131
159
  const optionSet = [];
132
160
  if (uniqueOptionSetValues) {
133
161
  for (const entry of uniqueOptionSetValues.values()) {
134
- if (entry === '') {
162
+ if (!entry) {
135
163
  continue;
136
164
  }
137
165
  optionSet.push({
@@ -150,3 +178,53 @@ function parseLabelsInColumn(uploadedOptionData) {
150
178
  return optionSets;
151
179
  }
152
180
  exports.parseLabelsInColumn = parseLabelsInColumn;
181
+ /**
182
+ * Expects a CSV file with an ignored header file and 3 columns:
183
+ * The first column contains the option set name (e.g. Gender)
184
+ * The second column contains the option keys (e.g. ge_men)
185
+ * The second column contains the option display label (e.g. Men)
186
+ *
187
+ * Sample file
188
+ * ignored header 1, ignored header 2, ignored header 3
189
+ * Gender, ge_men, Men
190
+ * Gender, ge_women, Women
191
+ * Brand, b_prada, Prada
192
+ * Brand, b_coach, Coach
193
+ * @param uploadedOptionData
194
+ * @returns
195
+ */
196
+ function parseNameAndLabelAndKey(uploadedOptionData) {
197
+ const optionSets = {};
198
+ for (const csvRow of uploadedOptionData) {
199
+ const row = Object.values(csvRow);
200
+ if (row.length !== 3 || row.some((x) => !x)) {
201
+ console.log('skipping bad row', JSON.stringify(row, null, 2));
202
+ continue;
203
+ }
204
+ const optionSetName = row[0];
205
+ if (!optionSets[optionSetName]) {
206
+ optionSets[optionSetName] = {};
207
+ }
208
+ const key = row[1];
209
+ const label = row[2];
210
+ optionSets[optionSetName][key] = label;
211
+ }
212
+ const result = [];
213
+ for (const optionSetName of Object.keys(optionSets)) {
214
+ const optionSet = [];
215
+ for (const [key, value] of Object.entries(optionSets[optionSetName])) {
216
+ optionSet.push({
217
+ value: key,
218
+ display: value,
219
+ });
220
+ }
221
+ const reducedOptionSet = {
222
+ name: optionSetName,
223
+ isArchived: false,
224
+ optionSet,
225
+ };
226
+ result.push(reducedOptionSet);
227
+ }
228
+ return result;
229
+ }
230
+ exports.parseNameAndLabelAndKey = parseNameAndLabelAndKey;
@@ -7,4 +7,3 @@ export default class ParseOptionSetsToFolderStructure extends BaseCommand {
7
7
  };
8
8
  run(): Promise<void>;
9
9
  }
10
- export declare function parseLabelsInColumn(uploadedOptionData: any): any[];
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseLabelsInColumn = void 0;
4
3
  const tslib_1 = require("tslib");
5
4
  const path = tslib_1.__importStar(require("path"));
6
5
  const fs_1 = tslib_1.__importDefault(require("fs"));
7
- const util_1 = require("@contrail/util");
8
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
9
7
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
10
8
  const core_1 = require("@oclif/core");
@@ -12,6 +10,11 @@ const basecommand_1 = require("../../basecommand");
12
10
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
13
11
  const common_1 = require("../../common");
14
12
  class ParseOptionSetsToFolderStructure extends basecommand_1.BaseCommand {
13
+ static description = 'Parses a YAML file containing multiple option sets (like the output of `parseOptionSetLocalFiles`) and separates them into multiple files in a directory. The resulting files can be uploaded using `uploadOptionSets`';
14
+ static examples = ['$ contrail types parseOptionSetsLocalFiles <File Paths> <style>'];
15
+ static args = {
16
+ file: core_1.Args.string({ description: 'File to parse', required: true }),
17
+ };
15
18
  async run() {
16
19
  const { args } = await this.parse(ParseOptionSetsToFolderStructure);
17
20
  try {
@@ -28,14 +31,6 @@ class ParseOptionSetsToFolderStructure extends basecommand_1.BaseCommand {
28
31
  }
29
32
  }
30
33
  exports.default = ParseOptionSetsToFolderStructure;
31
- ParseOptionSetsToFolderStructure.description = 'Parse CSV files into OptionSets. Style denotes the format the csv is in. If the csv file has a column for name and label, use "NameAndLabel". If the file has one column for each option set with the rows being the label value use "LabelsInColumn"';
32
- ParseOptionSetsToFolderStructure.examples = [
33
- `$ contrail types parseOptionSetsLocalFiles <File Paths> <style>
34
- `,
35
- ];
36
- ParseOptionSetsToFolderStructure.args = {
37
- file: core_1.Args.string({ description: 'File to parse', required: true }),
38
- };
39
34
  function loadOptionSets(fileLocation) {
40
35
  const TARGET_DIR = process.cwd();
41
36
  try {
@@ -69,34 +64,3 @@ function saveDataInFolders(data) {
69
64
  fs_1.default.writeFileSync(path.join(subDir, `${(0, common_1.removeSlash)(fileLabel)}.yml`), yamlStr, 'utf8');
70
65
  }
71
66
  }
72
- function parseLabelsInColumn(uploadedOptionData) {
73
- const optionSets = [];
74
- const optionSetNames = Object.keys(uploadedOptionData[0]);
75
- for (const optionSetName of optionSetNames) {
76
- const uniqueOptionSetValues = new Set();
77
- for (const data of uploadedOptionData) {
78
- const label = data[optionSetName];
79
- uniqueOptionSetValues.add(label);
80
- }
81
- const optionSet = [];
82
- if (uniqueOptionSetValues) {
83
- for (const entry of uniqueOptionSetValues.values()) {
84
- if (entry === '') {
85
- continue;
86
- }
87
- optionSet.push({
88
- value: util_1.StringUtil.convertToCamelCase(entry),
89
- display: entry,
90
- });
91
- }
92
- }
93
- const reducedOptionSet = {
94
- name: optionSetName,
95
- isArchived: false,
96
- optionSet,
97
- };
98
- optionSets.push(reducedOptionSet);
99
- }
100
- return optionSets;
101
- }
102
- exports.parseLabelsInColumn = parseLabelsInColumn;
@@ -7,6 +7,19 @@ const type_parser_1 = require("../../helpers/types/type-parser");
7
7
  const basecommand_1 = require("../../basecommand");
8
8
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
9
9
  class ParseTypesFromFiles extends basecommand_1.BaseCommand {
10
+ static description = 'Parse CSV files into Types and OptionSets from VibeIQ Files.\n File must be .yml.';
11
+ static examples = [
12
+ `$ contrail types parseTypesFromFiles <fileIds>
13
+ `,
14
+ ];
15
+ // variable argument length
16
+ static strict = false;
17
+ static args = {
18
+ typePaths: core_1.Args.string({
19
+ description: 'A list of the VibeIQ file IDs to parse',
20
+ required: true,
21
+ }),
22
+ };
10
23
  async run() {
11
24
  const { argv } = await this.parse(ParseTypesFromFiles);
12
25
  try {
@@ -24,16 +37,3 @@ class ParseTypesFromFiles extends basecommand_1.BaseCommand {
24
37
  }
25
38
  }
26
39
  exports.default = ParseTypesFromFiles;
27
- ParseTypesFromFiles.description = 'Parse CSV files into Types and OptionSets from VibeIQ Files.\n File must be .yml.';
28
- ParseTypesFromFiles.examples = [
29
- `$ contrail types parseTypesFromFiles <fileIds>
30
- `,
31
- ];
32
- // variable argument length
33
- ParseTypesFromFiles.strict = false;
34
- ParseTypesFromFiles.args = {
35
- typePaths: core_1.Args.string({
36
- description: 'A list of the VibeIQ file IDs to parse',
37
- required: true,
38
- }),
39
- };
@@ -7,6 +7,16 @@ const type_parser_1 = require("../../helpers/types/type-parser");
7
7
  const basecommand_1 = require("../../basecommand");
8
8
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
9
9
  class ParseTypesFromLocalFiles extends basecommand_1.BaseCommand {
10
+ static description = 'Parse CSV files into Types and OptionSets from local files.';
11
+ static examples = [
12
+ `$ contrail types parseTypesFromLocalFiles <File Paths>
13
+ `,
14
+ ];
15
+ // variable argument length
16
+ static strict = false;
17
+ static args = {
18
+ typePaths: core_1.Args.string({ description: 'A list of the files to parse', required: true }),
19
+ };
10
20
  async run() {
11
21
  const { argv } = await this.parse(ParseTypesFromLocalFiles);
12
22
  try {
@@ -24,13 +34,3 @@ class ParseTypesFromLocalFiles extends basecommand_1.BaseCommand {
24
34
  }
25
35
  }
26
36
  exports.default = ParseTypesFromLocalFiles;
27
- ParseTypesFromLocalFiles.description = 'Parse CSV files into Types and OptionSets from local files.';
28
- ParseTypesFromLocalFiles.examples = [
29
- `$ contrail types parseTypesFromLocalFiles <File Paths>
30
- `,
31
- ];
32
- // variable argument length
33
- ParseTypesFromLocalFiles.strict = false;
34
- ParseTypesFromLocalFiles.args = {
35
- typePaths: core_1.Args.string({ description: 'A list of the files to parse', required: true }),
36
- };
@@ -7,6 +7,16 @@ const type_parser_1 = require("../../helpers/types/type-parser");
7
7
  const basecommand_1 = require("../../basecommand");
8
8
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
9
9
  class ParseTypesFromTemplateAndDataFromLocalFiles extends basecommand_1.BaseCommand {
10
+ static description = 'Parse CSV files into Types and OptionSets from local type template files.';
11
+ static examples = [
12
+ `$ contrail types parseTypesFromTemplateAndDataFromLocalFiles <Template Path> <File Paths>
13
+ `,
14
+ ];
15
+ static strict = false;
16
+ static args = {
17
+ templateFile: core_1.Args.string({ description: 'The template file to use', required: true }),
18
+ filePaths: core_1.Args.string({ description: 'A list of data file to use', required: true }),
19
+ };
10
20
  async run() {
11
21
  const { args, argv } = await this.parse(ParseTypesFromTemplateAndDataFromLocalFiles);
12
22
  try {
@@ -26,13 +36,3 @@ class ParseTypesFromTemplateAndDataFromLocalFiles extends basecommand_1.BaseComm
26
36
  }
27
37
  }
28
38
  exports.default = ParseTypesFromTemplateAndDataFromLocalFiles;
29
- ParseTypesFromTemplateAndDataFromLocalFiles.description = 'Parse CSV files into Types and OptionSets from local type template files.';
30
- ParseTypesFromTemplateAndDataFromLocalFiles.examples = [
31
- `$ contrail types parseTypesFromTemplateAndDataFromLocalFiles <Template Path> <File Paths>
32
- `,
33
- ];
34
- ParseTypesFromTemplateAndDataFromLocalFiles.strict = false;
35
- ParseTypesFromTemplateAndDataFromLocalFiles.args = {
36
- templateFile: core_1.Args.string({ description: 'The template file to use', required: true }),
37
- filePaths: core_1.Args.string({ description: 'A list of data file to use', required: true }),
38
- };
@@ -7,6 +7,15 @@ const type_parser_1 = require("../../helpers/types/type-parser");
7
7
  const basecommand_1 = require("../../basecommand");
8
8
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
9
9
  class ParseTypesFromTemplateFromLocalFiles extends basecommand_1.BaseCommand {
10
+ static description = 'Parse CSV files into Types and OptionSets from local type template files.';
11
+ static examples = [
12
+ `$ contrail types parseTypesFromTemplateFromLocalFiles <Template File> <Data File>
13
+ `,
14
+ ];
15
+ static args = {
16
+ templateFile: core_1.Args.string({ description: 'The template file to use', required: true }),
17
+ filePath: core_1.Args.string({ description: 'The data file to use', required: true }),
18
+ };
10
19
  async run() {
11
20
  const { args } = await this.parse(ParseTypesFromTemplateFromLocalFiles);
12
21
  try {
@@ -26,12 +35,3 @@ class ParseTypesFromTemplateFromLocalFiles extends basecommand_1.BaseCommand {
26
35
  }
27
36
  }
28
37
  exports.default = ParseTypesFromTemplateFromLocalFiles;
29
- ParseTypesFromTemplateFromLocalFiles.description = 'Parse CSV files into Types and OptionSets from local type template files.';
30
- ParseTypesFromTemplateFromLocalFiles.examples = [
31
- `$ contrail types parseTypesFromTemplateFromLocalFiles <Template File> <Data File>
32
- `,
33
- ];
34
- ParseTypesFromTemplateFromLocalFiles.args = {
35
- templateFile: core_1.Args.string({ description: 'The template file to use', required: true }),
36
- filePath: core_1.Args.string({ description: 'The data file to use', required: true }),
37
- };
@@ -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 UploadOptionSetHierarchies extends basecommand_1.BaseCommand {
16
+ static description = 'Upload Option Set Hierarchies for your Org. Option set hierarchies are loaded from .yml files in the option-set-hierarchies directory.';
17
+ static examples = [
18
+ `$ contrail types uploadOptionSetHierarchies
19
+ `,
20
+ ];
21
+ static flags = {
22
+ dir: core_1.Flags.string({
23
+ char: 'd',
24
+ description: 'The directory from which to export the option set hierarchies data. Defaults to the current directory. The option set data will be loaded from $dir/option-set-hierarchies',
25
+ required: false,
26
+ default: '.',
27
+ }),
28
+ };
16
29
  async run() {
17
30
  const { flags } = await this.parse(UploadOptionSetHierarchies);
18
31
  return await uploadOptionSetHierarchies(flags.dir);
19
32
  }
20
33
  }
21
34
  exports.default = UploadOptionSetHierarchies;
22
- UploadOptionSetHierarchies.description = 'Upload Option Set Hierarchies for your Org. Option set hierarchies are loaded from .yml files in the option-set-hierarchies directory.';
23
- UploadOptionSetHierarchies.examples = [
24
- `$ contrail types uploadOptionSetHierarchies
25
- `,
26
- ];
27
- UploadOptionSetHierarchies.flags = {
28
- dir: core_1.Flags.string({
29
- char: 'd',
30
- description: 'The directory from which to export the option set hierarchies data. Defaults to the current directory. The option set data will be loaded from $dir/option-set-hierarchies',
31
- required: false,
32
- default: '.',
33
- }),
34
- };
35
35
  async function uploadOptionSetHierarchies(dir) {
36
36
  try {
37
37
  await (0, login_1.authUser)();
@@ -173,7 +173,7 @@ async function uploadOSHLinks(reducedOSHLinks) {
173
173
  const foundType = typesWithProperties.find((x) => x.id === currentLink.typeId);
174
174
  const foundOSH = currentOSHs.find((osh) => osh.id === currentLink.optionSetHierarchyId);
175
175
  const foundTPSlugs = typeProperties
176
- .filter((x) => { var _a; return (_a = currentLink === null || currentLink === void 0 ? void 0 : currentLink.hierarchyTypePropertyIds) === null || _a === void 0 ? void 0 : _a.includes(x.id); })
176
+ .filter((x) => currentLink?.hierarchyTypePropertyIds?.includes(x.id))
177
177
  .map((x) => x.slug);
178
178
  if (!foundType ||
179
179
  !foundOSH ||
@@ -233,7 +233,6 @@ async function uploadOSHLinks(reducedOSHLinks) {
233
233
  }
234
234
  }
235
235
  function transformReducedLink(OSHLink, typesWithProperties, OSHs) {
236
- var _a, _b;
237
236
  logger_1.default.debug(`OSHLink before transform: ${JSON.stringify(OSHLink, null, 2)}`);
238
237
  const foundType = typesWithProperties.find((x) => x.slug === OSHLink.typeSlug);
239
238
  if (!foundType) {
@@ -241,7 +240,7 @@ function transformReducedLink(OSHLink, typesWithProperties, OSHs) {
241
240
  return false;
242
241
  }
243
242
  OSHLink.typeId = foundType.id;
244
- const foundTPs = (_b = (_a = foundType === null || foundType === void 0 ? void 0 : foundType.typeProperties) === null || _a === void 0 ? void 0 : _a.filter((x) => OSHLink.typePropertySlugs.includes(x.slug))) !== null && _b !== void 0 ? _b : [];
243
+ const foundTPs = foundType?.typeProperties?.filter((x) => OSHLink.typePropertySlugs.includes(x.slug)) ?? [];
245
244
  if (foundTPs.length !== OSHLink.typePropertySlugs.length) {
246
245
  logger_1.default.error(`OSH Links: Could not find all type properties with slugs ${OSHLink.typePropertySlugs}`);
247
246
  return false;
@@ -12,25 +12,25 @@ const basecommand_1 = require("../../basecommand");
12
12
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
13
13
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
14
14
  class UploadOptionSets extends basecommand_1.BaseCommand {
15
+ static description = 'Upload OptionSets for your Org. OptionSets are loaded from .yml files in the option-sets directory.';
16
+ static examples = [
17
+ `$ contrail types uploadOptionSets
18
+ `,
19
+ ];
20
+ static flags = {
21
+ dir: core_1.Flags.string({
22
+ char: 'd',
23
+ 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/option-sets',
24
+ required: false,
25
+ default: '.',
26
+ }),
27
+ };
15
28
  async run() {
16
29
  const { flags } = await this.parse(UploadOptionSets);
17
30
  return await uploadOptionSets(flags.dir);
18
31
  }
19
32
  }
20
33
  exports.default = UploadOptionSets;
21
- UploadOptionSets.description = 'Upload OptionSets for your Org. OptionSets are loaded from .yml files in the option-sets directory.';
22
- UploadOptionSets.examples = [
23
- `$ contrail types uploadOptionSets
24
- `,
25
- ];
26
- UploadOptionSets.flags = {
27
- dir: core_1.Flags.string({
28
- char: 'd',
29
- 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/option-sets',
30
- required: false,
31
- default: '.',
32
- }),
33
- };
34
34
  async function uploadOptionSets(dir) {
35
35
  try {
36
36
  const userConfig = await (0, login_1.authUser)();
@@ -73,6 +73,8 @@ async function uploadOS(dir) {
73
73
  for (const optionSet of optionSets) {
74
74
  newOptionSetsBySlug[optionSet.slug] = optionSet;
75
75
  }
76
+ logger_1.default.debug(`Current OptionSets: ${JSON.stringify(currentOptionSetsBySlug, null, 2)}`);
77
+ logger_1.default.debug(`New OptionSets: ${JSON.stringify(newOptionSetsBySlug, null, 2)}`);
76
78
  for (const optionSet of optionSets) {
77
79
  try {
78
80
  const found = currentOptionSetsBySlug[optionSet.slug];
@@ -12,24 +12,24 @@ 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 UploadOptionSetsHierarchyLocalFile extends basecommand_1.BaseCommand {
15
+ static description = 'upload CSV file into OptionSetHierarchy';
16
+ static examples = [
17
+ `$ contrail types uploadOptionSetsHierarchyLocalFile <File Path> <name>
18
+ `,
19
+ ];
20
+ static args = {
21
+ file: core_1.Args.string({ description: 'File to parse', required: true }),
22
+ name: core_1.Args.string({
23
+ description: 'The name to be give to the option set hierarchy',
24
+ required: true,
25
+ }),
26
+ };
15
27
  async run() {
16
28
  const { args } = await this.parse(UploadOptionSetsHierarchyLocalFile);
17
29
  await uploadOptionSetsHierarchyLocalFile(args.file, args.name);
18
30
  }
19
31
  }
20
32
  exports.default = UploadOptionSetsHierarchyLocalFile;
21
- UploadOptionSetsHierarchyLocalFile.description = 'upload CSV file into OptionSetHierarchy';
22
- UploadOptionSetsHierarchyLocalFile.examples = [
23
- `$ contrail types uploadOptionSetsHierarchyLocalFile <File Path> <name>
24
- `,
25
- ];
26
- UploadOptionSetsHierarchyLocalFile.args = {
27
- file: core_1.Args.string({ description: 'File to parse', required: true }),
28
- name: core_1.Args.string({
29
- description: 'The name to be give to the option set hierarchy',
30
- required: true,
31
- }),
32
- };
33
33
  async function uploadOptionSetsHierarchyLocalFile(fileLocation, name) {
34
34
  try {
35
35
  await (0, login_1.authUser)();
@@ -65,7 +65,7 @@ async function parseOptionSetHierarchiesLocalFile(fileLocation) {
65
65
  name: 'No Name',
66
66
  options: [],
67
67
  };
68
- if (!((uploadedOptionHierarchyData === null || uploadedOptionHierarchyData === void 0 ? void 0 : uploadedOptionHierarchyData.length) > 0)) {
68
+ if (!(uploadedOptionHierarchyData?.length > 0)) {
69
69
  return optionSetHierarchy;
70
70
  }
71
71
  const keysInOrder = Object.keys(uploadedOptionHierarchyData[0]);
@@ -12,25 +12,25 @@ const basecommand_1 = require("../../basecommand");
12
12
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
13
13
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
14
14
  class UploadRuleSets extends basecommand_1.BaseCommand {
15
+ static description = 'Upload an extracted rule set';
16
+ static examples = [
17
+ `$ contrail types uploadRuleSets
18
+ `,
19
+ ];
20
+ static flags = {
21
+ dir: core_1.Flags.string({
22
+ char: 'd',
23
+ description: 'The directory from which to export the rule set data. Defaults to the current directory. The rule set data will be loaded from $dir/rule-sets/*.yml',
24
+ required: false,
25
+ default: '.',
26
+ }),
27
+ };
15
28
  async run() {
16
29
  const { flags } = await this.parse(UploadRuleSets);
17
30
  await uploadRuleSets(flags.dir);
18
31
  }
19
32
  }
20
33
  exports.default = UploadRuleSets;
21
- UploadRuleSets.description = 'Upload an extracted rule set';
22
- UploadRuleSets.examples = [
23
- `$ contrail types uploadRuleSets
24
- `,
25
- ];
26
- UploadRuleSets.flags = {
27
- dir: core_1.Flags.string({
28
- char: 'd',
29
- description: 'The directory from which to export the rule set data. Defaults to the current directory. The rule set data will be loaded from $dir/rule-sets/*.yml',
30
- required: false,
31
- default: '.',
32
- }),
33
- };
34
34
  async function uploadRuleSets(dir) {
35
35
  try {
36
36
  await (0, login_1.authUser)();
@@ -14,25 +14,25 @@ const basecommand_1 = require("../../basecommand");
14
14
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
15
15
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
16
16
  class UploadTypePolicies extends basecommand_1.BaseCommand {
17
+ static description = 'Upload type policies';
18
+ static examples = [
19
+ `$ contrail types UploadTypePolicies
20
+ `,
21
+ ];
22
+ static flags = {
23
+ dir: core_1.Flags.string({
24
+ char: 'd',
25
+ description: 'The directory from which to export the type policy data. Defaults to the current directory. The type policy data will be loaded from $dir/type-policies/*.yml',
26
+ required: false,
27
+ default: '.',
28
+ }),
29
+ };
17
30
  async run() {
18
31
  const { flags } = await this.parse(UploadTypePolicies);
19
32
  return await uploadTypePolicies(flags.dir);
20
33
  }
21
34
  }
22
35
  exports.default = UploadTypePolicies;
23
- UploadTypePolicies.description = 'Upload type policies';
24
- UploadTypePolicies.examples = [
25
- `$ contrail types UploadTypePolicies
26
- `,
27
- ];
28
- UploadTypePolicies.flags = {
29
- dir: core_1.Flags.string({
30
- char: 'd',
31
- description: 'The directory from which to export the type policy data. Defaults to the current directory. The type policy data will be loaded from $dir/type-policies/*.yml',
32
- required: false,
33
- default: '.',
34
- }),
35
- };
36
36
  async function uploadTypePolicies(dir) {
37
37
  try {
38
38
  await (0, login_1.authUser)();
@@ -69,14 +69,14 @@ async function uploadTypePolicyObjects(reducedTypePolicies) {
69
69
  const orgUsers = await (0, users_1.getUserOrgs)();
70
70
  const groups = await (0, users_1.getGroups)();
71
71
  function fillPrincipal(statement) {
72
- const principal = statement === null || statement === void 0 ? void 0 : statement.principal;
72
+ const principal = statement?.principal;
73
73
  if (!principal) {
74
- logger_1.default.warn(`skipping bad statement principal ${statement === null || statement === void 0 ? void 0 : statement.principal}`);
74
+ logger_1.default.warn(`skipping bad statement principal ${statement?.principal}`);
75
75
  return statement;
76
76
  }
77
77
  const [type, identifier] = principal.split(':');
78
78
  if (!type || !identifier) {
79
- logger_1.default.warn(`skipping bad statement principal ${statement === null || statement === void 0 ? void 0 : statement.principal}`);
79
+ logger_1.default.warn(`skipping bad statement principal ${statement?.principal}`);
80
80
  return statement;
81
81
  }
82
82
  if (type === 'group') {