@contrail/cli 2.1.20 → 2.1.22

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 (154) hide show
  1. package/README.md +311 -105
  2. package/dist/api/apps.js +15 -15
  3. package/dist/api/event-workflow-action-definition.d.ts +1 -1
  4. package/dist/api/event-workflow-action-definition.js +1 -1
  5. package/dist/api/event-workflow-template-definition.d.ts +4 -3
  6. package/dist/api/event-workflow-templates.d.ts +5 -4
  7. package/dist/api/event-workflow-templates.js +2 -2
  8. package/dist/api/types.d.ts +10 -10
  9. package/dist/api/users.js +4 -2
  10. package/dist/auth/login.js +12 -14
  11. package/dist/commands/app/create.d.ts +2 -2
  12. package/dist/commands/app/create.js +15 -10
  13. package/dist/commands/app/delete.d.ts +2 -2
  14. package/dist/commands/app/delete.js +4 -2
  15. package/dist/commands/app/getApiKey.d.ts +2 -2
  16. package/dist/commands/app/getApiKey.js +17 -11
  17. package/dist/commands/app/install.d.ts +2 -2
  18. package/dist/commands/app/install.js +42 -25
  19. package/dist/commands/app/publish.d.ts +2 -2
  20. package/dist/commands/app/publish.js +26 -11
  21. package/dist/commands/app/uninstall.d.ts +2 -2
  22. package/dist/commands/app/uninstall.js +20 -11
  23. package/dist/commands/app/upgrade.d.ts +2 -2
  24. package/dist/commands/app/upgrade.js +46 -23
  25. package/dist/commands/basecommand.d.ts +7 -0
  26. package/dist/commands/basecommand.js +29 -0
  27. package/dist/commands/colors/deleteAll.d.ts +2 -2
  28. package/dist/commands/colors/deleteAll.js +8 -5
  29. package/dist/commands/colors/load.d.ts +2 -2
  30. package/dist/commands/colors/load.js +10 -7
  31. package/dist/commands/config/list.d.ts +2 -2
  32. package/dist/commands/config/list.js +4 -2
  33. package/dist/commands/config/remove.d.ts +2 -2
  34. package/dist/commands/config/remove.js +4 -2
  35. package/dist/commands/config/set.d.ts +3 -2
  36. package/dist/commands/config/set.js +21 -7
  37. package/dist/commands/groups/export.d.ts +2 -2
  38. package/dist/commands/groups/export.js +20 -8
  39. package/dist/commands/groups/upload.d.ts +3 -3
  40. package/dist/commands/groups/upload.js +44 -32
  41. package/dist/commands/instance/export.d.ts +2 -2
  42. package/dist/commands/instance/export.js +15 -3
  43. package/dist/commands/instance/import.d.ts +2 -2
  44. package/dist/commands/instance/import.js +9 -2
  45. package/dist/commands/loader-process/load.d.ts +2 -2
  46. package/dist/commands/loader-process/load.js +13 -6
  47. package/dist/commands/loader-process/upload-and-load.d.ts +2 -2
  48. package/dist/commands/loader-process/upload-and-load.js +18 -7
  49. package/dist/commands/projects/export.d.ts +2 -2
  50. package/dist/commands/projects/export.js +4 -2
  51. package/dist/commands/projects/list.d.ts +2 -2
  52. package/dist/commands/projects/list.js +6 -4
  53. package/dist/commands/projects/load.d.ts +2 -2
  54. package/dist/commands/projects/load.js +16 -8
  55. package/dist/commands/types/exportOptionSetHierarchies.d.ts +2 -2
  56. package/dist/commands/types/exportOptionSetHierarchies.js +15 -12
  57. package/dist/commands/types/getAll.d.ts +2 -2
  58. package/dist/commands/types/getAll.js +107 -76
  59. package/dist/commands/types/loadAll.d.ts +2 -2
  60. package/dist/commands/types/loadAll.js +12 -4
  61. package/dist/commands/types/mergeOptionSets.d.ts +2 -2
  62. package/dist/commands/types/mergeOptionSets.js +13 -10
  63. package/dist/commands/types/mergeTypeProperties.d.ts +2 -2
  64. package/dist/commands/types/mergeTypeProperties.js +12 -9
  65. package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +2 -2
  66. package/dist/commands/types/parseOptionSetsHierarchyLocalFile.js +19 -15
  67. package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +10 -0
  68. package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.js +102 -0
  69. package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +2 -2
  70. package/dist/commands/types/parseOptionSetsLocalFiles.js +21 -21
  71. package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +2 -2
  72. package/dist/commands/types/parseOptionSetsToFolderStructure.js +17 -18
  73. package/dist/commands/types/parseTypesFromFiles.d.ts +2 -2
  74. package/dist/commands/types/parseTypesFromFiles.js +14 -8
  75. package/dist/commands/types/parseTypesFromLocalFiles.d.ts +2 -2
  76. package/dist/commands/types/parseTypesFromLocalFiles.js +10 -7
  77. package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +2 -2
  78. package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.js +11 -8
  79. package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +2 -2
  80. package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.js +11 -8
  81. package/dist/commands/types/uploadOptionSetHierarchies.d.ts +2 -2
  82. package/dist/commands/types/uploadOptionSetHierarchies.js +44 -32
  83. package/dist/commands/types/uploadOptionSets.d.ts +2 -2
  84. package/dist/commands/types/uploadOptionSets.js +21 -13
  85. package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +2 -2
  86. package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.js +26 -19
  87. package/dist/commands/types/uploadRuleSets.d.ts +2 -2
  88. package/dist/commands/types/uploadRuleSets.js +34 -26
  89. package/dist/commands/types/uploadTypePolicies.d.ts +2 -2
  90. package/dist/commands/types/uploadTypePolicies.js +37 -29
  91. package/dist/commands/types/uploadTypePropertyPolicies.d.ts +2 -2
  92. package/dist/commands/types/uploadTypePropertyPolicies.js +38 -30
  93. package/dist/commands/types/uploadTypes.d.ts +2 -2
  94. package/dist/commands/types/uploadTypes.js +10 -4
  95. package/dist/commands/types/uploadUsageInfo.d.ts +2 -2
  96. package/dist/commands/types/uploadUsageInfo.js +32 -24
  97. package/dist/commands/users/export.d.ts +2 -2
  98. package/dist/commands/users/export.js +15 -4
  99. package/dist/commands/users/upload.d.ts +2 -2
  100. package/dist/commands/users/upload.js +6 -4
  101. package/dist/commands/webhooks/create.d.ts +2 -2
  102. package/dist/commands/webhooks/create.js +8 -6
  103. package/dist/commands/webhooks/delete.d.ts +2 -2
  104. package/dist/commands/webhooks/delete.js +8 -5
  105. package/dist/commands/webhooks/getWebhookTrigger.d.ts +2 -2
  106. package/dist/commands/webhooks/getWebhookTrigger.js +10 -9
  107. package/dist/commands/webhooks/list.d.ts +2 -2
  108. package/dist/commands/webhooks/list.js +8 -6
  109. package/dist/commands/workflow-template-definitions/install.d.ts +2 -2
  110. package/dist/commands/workflow-template-definitions/install.js +4 -2
  111. package/dist/commands/workflow-template-definitions/list.d.ts +2 -2
  112. package/dist/commands/workflow-template-definitions/list.js +4 -2
  113. package/dist/commands/workflow-templates/delete.d.ts +2 -2
  114. package/dist/commands/workflow-templates/delete.js +4 -2
  115. package/dist/commands/workflow-templates/export.d.ts +2 -2
  116. package/dist/commands/workflow-templates/export.js +19 -17
  117. package/dist/commands/workflow-templates/list.d.ts +2 -2
  118. package/dist/commands/workflow-templates/list.js +4 -2
  119. package/dist/commands/workflow-templates/load.d.ts +2 -2
  120. package/dist/commands/workflow-templates/load.js +8 -3
  121. package/dist/common.d.ts +4 -1
  122. package/dist/common.js +10 -1
  123. package/dist/helpers/app/actions-deployer.d.ts +2 -2
  124. package/dist/helpers/app/actions-deployer.js +12 -7
  125. package/dist/helpers/app/app-deployer.d.ts +1 -1
  126. package/dist/helpers/app/app-deployer.js +70 -52
  127. package/dist/helpers/app/app-template-parsers.js +3 -1
  128. package/dist/helpers/app/load-app-config.d.ts +2 -1
  129. package/dist/helpers/app/load-app-config.js +2 -2
  130. package/dist/helpers/app/setup-template.js +4 -3
  131. package/dist/helpers/colors/helpers.d.ts +10 -2
  132. package/dist/helpers/colors/helpers.js +11 -10
  133. package/dist/helpers/config/config.js +15 -10
  134. package/dist/helpers/file-helpers.js +7 -4
  135. package/dist/helpers/loader-process/helpers.js +14 -13
  136. package/dist/helpers/projects/helpers.d.ts +2 -1
  137. package/dist/helpers/projects/helpers.js +16 -15
  138. package/dist/helpers/types/csv-parser.js +17 -14
  139. package/dist/helpers/types/type-extractor.d.ts +1 -1
  140. package/dist/helpers/types/type-extractor.js +3 -2
  141. package/dist/helpers/types/type-parser.js +22 -21
  142. package/dist/helpers/types/type-uploader.js +19 -15
  143. package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.d.ts +1 -1
  144. package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.js +47 -28
  145. package/dist/helpers/workflow-templates/helper.d.ts +3 -3
  146. package/dist/helpers/workflow-templates/helper.js +33 -23
  147. package/dist/interface-converters.spec.js +15 -15
  148. package/dist/interfaces.d.ts +6 -0
  149. package/dist/logger.d.ts +3 -0
  150. package/dist/logger.js +32 -0
  151. package/dist/templates/typescript/src/actions/logItem.ts +9 -4
  152. package/dist/templates/typescript/src/main.ts +13 -8
  153. package/oclif.manifest.json +861 -31
  154. package/package.json +10 -7
@@ -11,10 +11,14 @@ const type_extractor_1 = require("../../helpers/types/type-extractor");
11
11
  const types_1 = require("../../api/types");
12
12
  const file_helpers_1 = require("../../helpers/file-helpers");
13
13
  const users_1 = require("../../api/users");
14
- const yaml = require('js-yaml');
15
- class GetAllTypes extends core_1.Command {
14
+ const basecommand_1 = require("../basecommand");
15
+ const logger_1 = tslib_1.__importDefault(require("../../logger"));
16
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
17
+ const common_1 = require("../../common");
18
+ class GetAllTypes extends basecommand_1.BaseCommand {
16
19
  async run() {
17
20
  const { flags } = await this.parse(GetAllTypes);
21
+ await super.setLogLevel(flags.logLevel);
18
22
  await getAll(flags.outDir, flags.overwrite);
19
23
  }
20
24
  }
@@ -25,13 +29,23 @@ GetAllTypes.examples = [
25
29
  `,
26
30
  ];
27
31
  GetAllTypes.flags = {
28
- outDir: core_1.Flags.string({ char: 'd', description: 'The directory to which to export the type data. Defaults to the current directory', required: false, default: '.' }),
29
- overwrite: core_1.Flags.boolean({ char: 'f', description: 'Replaces any existing export files in outDir', required: false, default: false })
32
+ outDir: core_1.Flags.string({
33
+ char: 'd',
34
+ description: 'The directory to which to export the type data. Defaults to the current directory',
35
+ required: false,
36
+ default: '.',
37
+ }),
38
+ overwrite: core_1.Flags.boolean({
39
+ char: 'f',
40
+ description: 'Replaces any existing export files in outDir',
41
+ required: false,
42
+ default: false,
43
+ }),
30
44
  };
31
45
  async function getAll(outDir, overwrite) {
32
46
  try {
33
47
  const userConfig = await (0, login_1.authUser)();
34
- console.log(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk_1.default.blue.bold('START'));
48
+ logger_1.default.info(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk_1.default.blue.bold('START'));
35
49
  // make directory to house exports
36
50
  if (!fs_1.default.existsSync(path.resolve(outDir))) {
37
51
  fs_1.default.mkdirSync(path.resolve(outDir));
@@ -51,13 +65,13 @@ async function getAll(outDir, overwrite) {
51
65
  };
52
66
  const reducedData = await reduceData(data);
53
67
  await saveData(reducedData, outDir, overwrite);
54
- console.log('%s Retrieved', chalk_1.default.yellow.bold('TYPES'));
68
+ logger_1.default.info('%s Retrieved', chalk_1.default.yellow.bold('TYPES'));
55
69
  }
56
70
  catch (e) {
57
- console.log(`%s Types Retrieval Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
71
+ logger_1.default.info(`%s Types Retrieval Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
58
72
  return;
59
73
  }
60
- console.log('%s Types Retrieval Complete.', chalk_1.default.green.bold('COMPLETE'));
74
+ logger_1.default.info('%s Types Retrieval Complete.', chalk_1.default.green.bold('COMPLETE'));
61
75
  }
62
76
  exports.getAll = getAll;
63
77
  async function reduceTypePropertyPolicies(data) {
@@ -74,36 +88,36 @@ async function reduceTypePropertyPolicies(data) {
74
88
  return statement;
75
89
  }
76
90
  if (type === 'group') {
77
- const groupName = (_a = groups.find(x => x.id === id)) === null || _a === void 0 ? void 0 : _a.name;
91
+ const groupName = (_a = groups.find((x) => x.id === id)) === null || _a === void 0 ? void 0 : _a.name;
78
92
  if (!groupName) {
79
- console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
93
+ logger_1.default.info(`Could not find group for statement. skipping invalid policy conversion ${id}`);
80
94
  return statement;
81
95
  }
82
96
  statement.principal = `group:${groupName}`;
83
97
  }
84
98
  else if (type === 'user') {
85
- const userEmail = (_b = orgUsers.find(x => x.user.id === id)) === null || _b === void 0 ? void 0 : _b.email;
99
+ const userEmail = (_b = orgUsers.find((x) => x.user.id === id)) === null || _b === void 0 ? void 0 : _b.email;
86
100
  if (!userEmail) {
87
- console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
101
+ logger_1.default.info(`Could not find group for statement. skipping invalid policy conversion ${id}`);
88
102
  return statement;
89
103
  }
90
104
  statement.principal = `user:${userEmail}`;
91
105
  }
92
106
  return statement;
93
107
  }
94
- return (_a = data === null || data === void 0 ? void 0 : data.typePropertyPolicies) === null || _a === void 0 ? void 0 : _a.map(x => {
108
+ return (_a = data === null || data === void 0 ? void 0 : data.typePropertyPolicies) === null || _a === void 0 ? void 0 : _a.map((x) => {
95
109
  return {
96
110
  label: x.label,
97
111
  policy: {
98
112
  version: x.policy.version,
99
- statements: x.policy.statements.map(x => reducePrincipal(x)),
100
- }
113
+ statements: x.policy.statements.map((x) => reducePrincipal(x)),
114
+ },
101
115
  };
102
116
  }).sort((one, two) => (one.label < two.label ? -1 : 1));
103
117
  }
104
118
  function reduceTypePropertyPolicyLinks(data) {
105
119
  var _a, _b;
106
- const typeProperties = (_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.map(x => x.typeProperties).reduce((x, y) => x.concat(y));
120
+ const typeProperties = (_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.map((x) => x.typeProperties).reduce((x, y) => x.concat(y));
107
121
  // make a map of all type properties to their type ids
108
122
  const typePropertyIdToTypeSlugMap = data.types.reduce((map, obj) => {
109
123
  for (const tp of obj.typeProperties) {
@@ -111,15 +125,13 @@ function reduceTypePropertyPolicyLinks(data) {
111
125
  }
112
126
  return map;
113
127
  }, {});
114
- return (_b = data === null || data === void 0 ? void 0 : data.typePropertyPolicyLinks) === null || _b === void 0 ? void 0 : _b.map(x => {
128
+ return (_b = data === null || data === void 0 ? void 0 : data.typePropertyPolicyLinks) === null || _b === void 0 ? void 0 : _b.map((x) => {
115
129
  var _a, _b;
116
130
  const typeSlug = typePropertyIdToTypeSlugMap[x.typePropertyId];
117
- const typePropertySlug = (_a = typeProperties.find(y => y.id === x.typePropertyId)) === null || _a === void 0 ? void 0 : _a.slug;
118
- const typePropertyPolicyLabel = (_b = data.typePropertyPolicies.find(y => y.id === x.typePropertyPolicyId)) === null || _b === void 0 ? void 0 : _b.label;
119
- if (!typeSlug ||
120
- !typePropertySlug ||
121
- !typePropertyPolicyLabel) {
122
- console.warn('Could not reduce bad type property policy link... skipping', x);
131
+ const typePropertySlug = (_a = typeProperties.find((y) => y.id === x.typePropertyId)) === null || _a === void 0 ? void 0 : _a.slug;
132
+ const typePropertyPolicyLabel = (_b = data.typePropertyPolicies.find((y) => y.id === x.typePropertyPolicyId)) === null || _b === void 0 ? void 0 : _b.label;
133
+ if (!typeSlug || !typePropertySlug || !typePropertyPolicyLabel) {
134
+ logger_1.default.warn('Could not reduce bad type property policy link... skipping', x);
123
135
  return null;
124
136
  }
125
137
  return {
@@ -127,7 +139,7 @@ function reduceTypePropertyPolicyLinks(data) {
127
139
  typePropertySlug,
128
140
  typePropertyPolicyLabel,
129
141
  };
130
- }).filter(x => !!x);
142
+ }).filter((x) => !!x);
131
143
  }
132
144
  async function reduceTypePolicies(data) {
133
145
  var _a;
@@ -143,48 +155,48 @@ async function reduceTypePolicies(data) {
143
155
  return statement;
144
156
  }
145
157
  if (type === 'group') {
146
- const groupName = (_a = groups.find(x => x.id === id)) === null || _a === void 0 ? void 0 : _a.name;
158
+ const groupName = (_a = groups.find((x) => x.id === id)) === null || _a === void 0 ? void 0 : _a.name;
147
159
  if (!groupName) {
148
- console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
160
+ logger_1.default.info(`Could not find group for statement. skipping invalid policy conversion ${id}`);
149
161
  return statement;
150
162
  }
151
163
  statement.principal = `group:${groupName}`;
152
164
  }
153
165
  else if (type === 'user') {
154
- const userEmail = (_b = orgUsers.find(x => x.user.id === id)) === null || _b === void 0 ? void 0 : _b.email;
166
+ const userEmail = (_b = orgUsers.find((x) => x.user.id === id)) === null || _b === void 0 ? void 0 : _b.email;
155
167
  if (!userEmail) {
156
- console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
168
+ logger_1.default.info(`Could not find group for statement. skipping invalid policy conversion ${id}`);
157
169
  return statement;
158
170
  }
159
171
  statement.principal = `user:${userEmail}`;
160
172
  }
161
173
  return statement;
162
174
  }
163
- return (_a = data === null || data === void 0 ? void 0 : data.typePolicies) === null || _a === void 0 ? void 0 : _a.map(x => {
175
+ return (_a = data === null || data === void 0 ? void 0 : data.typePolicies) === null || _a === void 0 ? void 0 : _a.map((x) => {
164
176
  return {
165
177
  label: x.label,
166
178
  policy: {
167
179
  version: x.policy.version,
168
- statements: x.policy.statements.map(x => reducePrincipal(x)),
169
- }
180
+ statements: x.policy.statements.map((x) => reducePrincipal(x)),
181
+ },
170
182
  };
171
183
  }).sort((one, two) => (one.label < two.label ? -1 : 1));
172
184
  }
173
185
  function reduceTypePolicyLinks(data) {
174
186
  var _a;
175
187
  const types = data === null || data === void 0 ? void 0 : data.types;
176
- return (_a = data === null || data === void 0 ? void 0 : data.typePolicyLinks) === null || _a === void 0 ? void 0 : _a.map(x => {
188
+ return (_a = data === null || data === void 0 ? void 0 : data.typePolicyLinks) === null || _a === void 0 ? void 0 : _a.map((x) => {
177
189
  var _a, _b;
178
190
  return {
179
- typeSlug: (_a = types.find(y => y.id === x.typeId)) === null || _a === void 0 ? void 0 : _a.slug,
180
- typePolicyLabel: (_b = data.typePolicies.find(y => y.id === x.typePolicyId)) === null || _b === void 0 ? void 0 : _b.label,
191
+ typeSlug: (_a = types.find((y) => y.id === x.typeId)) === null || _a === void 0 ? void 0 : _a.slug,
192
+ typePolicyLabel: (_b = data.typePolicies.find((y) => y.id === x.typePolicyId)) === null || _b === void 0 ? void 0 : _b.label,
181
193
  };
182
194
  });
183
195
  }
184
196
  function reduceUsageInfo(data) {
185
197
  var _a, _b;
186
- const typeProperties = (_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.map(x => x.typeProperties).reduce((x, y) => x.concat(y));
187
- return (_b = data === null || data === void 0 ? void 0 : data.usageInfo) === null || _b === void 0 ? void 0 : _b.map(x => {
198
+ const typeProperties = (_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.map((x) => x.typeProperties).reduce((x, y) => x.concat(y));
199
+ return (_b = data === null || data === void 0 ? void 0 : data.usageInfo) === null || _b === void 0 ? void 0 : _b.map((x) => {
188
200
  var _a, _b;
189
201
  return {
190
202
  used: x.used,
@@ -194,8 +206,8 @@ function reduceUsageInfo(data) {
194
206
  numberFormat: x.numberFormat,
195
207
  defaultValue: x.defaultValue,
196
208
  label: x.label,
197
- typeSlug: (_a = data.types.find(y => y.id === x.typeId)) === null || _a === void 0 ? void 0 : _a.slug,
198
- typePropertySlug: (_b = typeProperties.find(y => y.id === x.typePropertyId)) === null || _b === void 0 ? void 0 : _b.slug,
209
+ typeSlug: (_a = data.types.find((y) => y.id === x.typeId)) === null || _a === void 0 ? void 0 : _a.slug,
210
+ typePropertySlug: (_b = typeProperties.find((y) => y.id === x.typePropertyId)) === null || _b === void 0 ? void 0 : _b.slug,
199
211
  };
200
212
  }).sort((one, two) => (one.label < two.label ? -1 : 1));
201
213
  }
@@ -206,14 +218,14 @@ function reduceRuleSetLinks(data) {
206
218
  return [];
207
219
  }
208
220
  for (const ruleSetLink of data.ruleSetLinks) {
209
- const ruleSet = (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.find(x => x.id === ruleSetLink.typeRuleSetId);
210
- const type = (_b = data === null || data === void 0 ? void 0 : data.types) === null || _b === void 0 ? void 0 : _b.find(x => x.id === ruleSetLink.typeId);
221
+ const ruleSet = (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === ruleSetLink.typeRuleSetId);
222
+ const type = (_b = data === null || data === void 0 ? void 0 : data.types) === null || _b === void 0 ? void 0 : _b.find((x) => x.id === ruleSetLink.typeId);
211
223
  if (!ruleSet || !type) {
212
- console.log('%s Skipping bad rule set link', ruleSetLink.id, chalk_1.default.red.bold('TYPES'));
224
+ logger_1.default.info('%s Skipping bad rule set link', ruleSetLink.id, chalk_1.default.red.bold('TYPES'));
213
225
  }
214
226
  reducedRuleSetLinks.push({
215
227
  ruleSet: ruleSet.name,
216
- type: type.slug
228
+ type: type.slug,
217
229
  });
218
230
  }
219
231
  return reducedRuleSetLinks.sort((one, two) => {
@@ -225,7 +237,7 @@ function reduceRuleSetLinks(data) {
225
237
  }
226
238
  function reduceRuleSets(data) {
227
239
  var _a;
228
- return (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.map(x => {
240
+ return (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.map((x) => {
229
241
  return {
230
242
  ruleSet: x.ruleSet,
231
243
  name: x.name,
@@ -234,7 +246,7 @@ function reduceRuleSets(data) {
234
246
  }
235
247
  function reduceOptionSets(data) {
236
248
  var _a;
237
- return (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.map(optionSet => {
249
+ return (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.map((optionSet) => {
238
250
  return {
239
251
  name: optionSet.name,
240
252
  isArchived: optionSet.isArchived,
@@ -244,34 +256,34 @@ function reduceOptionSets(data) {
244
256
  }
245
257
  function reduceOptionSetHierarchies(data) {
246
258
  var _a;
247
- return (_a = data.optionSetHierarchies) === null || _a === void 0 ? void 0 : _a.map(x => {
248
- const hierarchyByName = x.hierarchy.map(optionSetId => { var _a, _b; return (_b = (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.find(x => x.id === optionSetId)) === null || _b === void 0 ? void 0 : _b.name; });
259
+ return (_a = data.optionSetHierarchies) === null || _a === void 0 ? void 0 : _a.map((x) => {
260
+ const hierarchyByName = x.hierarchy.map((optionSetId) => { var _a, _b; return (_b = (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === optionSetId)) === null || _b === void 0 ? void 0 : _b.name; });
249
261
  return {
250
262
  hierarchy: hierarchyByName,
251
263
  options: x.options,
252
- name: x.name
264
+ name: x.name,
253
265
  };
254
266
  }).sort((one, two) => (one.name < two.name ? -1 : 1));
255
267
  }
256
268
  function reduceOptionSetHierarchyLinks(data) {
257
269
  var _a;
258
- return (_a = data.optionSetHierarchyLinks) === null || _a === void 0 ? void 0 : _a.map(x => {
270
+ return (_a = data.optionSetHierarchyLinks) === null || _a === void 0 ? void 0 : _a.map((x) => {
259
271
  var _a;
260
- const osh = data.optionSetHierarchies.find(y => y.id === x.optionSetHierarchyId);
272
+ const osh = data.optionSetHierarchies.find((y) => y.id === x.optionSetHierarchyId);
261
273
  if (!osh) {
262
- console.log('OSH Link: could not find option set hierarchy', x.optionSetHierarchyId, 'skipping...');
274
+ logger_1.default.info('OSH Link: could not find option set hierarchy', x.optionSetHierarchyId, 'skipping...');
263
275
  return null;
264
276
  }
265
- const type = data.types.find(y => y.id === x.typeId);
277
+ const type = data.types.find((y) => y.id === x.typeId);
266
278
  if (!type) {
267
- console.log('OSH Link: could not find type', x.typeId, 'skipping...');
279
+ logger_1.default.info('OSH Link: could not find type', x.typeId, 'skipping...');
268
280
  return null;
269
281
  }
270
282
  const typePropertySlugs = [];
271
283
  for (const tpId of x.hierarchyTypePropertyIds) {
272
- const typePropertySlug = (_a = type.typeProperties.find(y => y.id === tpId)) === null || _a === void 0 ? void 0 : _a.slug;
284
+ const typePropertySlug = (_a = type.typeProperties.find((y) => y.id === tpId)) === null || _a === void 0 ? void 0 : _a.slug;
273
285
  if (!typePropertySlug) {
274
- console.log('OSH Link: could not find type property', tpId, 'skipping...');
286
+ logger_1.default.info('OSH Link: could not find type property', tpId, 'skipping...');
275
287
  return null;
276
288
  }
277
289
  typePropertySlugs.push(typePropertySlug);
@@ -281,10 +293,10 @@ function reduceOptionSetHierarchyLinks(data) {
281
293
  typeSlug: type.slug,
282
294
  typePropertySlugs,
283
295
  };
284
- }).filter(x => !!x).sort((one, two) => (one.typeSlug < two.typeSlug ? -1 : 1));
296
+ }).filter((x) => !!x).sort((one, two) => (one.typeSlug < two.typeSlug ? -1 : 1));
285
297
  }
286
298
  function reduceTypes(dataHolder) {
287
- console.log('Found types: ', dataHolder.types.length);
299
+ logger_1.default.info('Found types: ', dataHolder.types.length);
288
300
  let reducedTypes = [];
289
301
  const optionSetNameById = {};
290
302
  for (const optionSet of dataHolder.optionSets) {
@@ -321,12 +333,14 @@ function reduceTypes(dataHolder) {
321
333
  slug: type.slug,
322
334
  label: type.label,
323
335
  isArchived: type.isArchived,
324
- typeProperties: reducedTypeProperties.map(x => {
336
+ typeProperties: reducedTypeProperties
337
+ .map((x) => {
325
338
  delete x['id'];
326
339
  return {
327
- ...x
340
+ ...x,
328
341
  };
329
- }).sort((one, two) => (one.slug < two.slug ? -1 : 1)),
342
+ })
343
+ .sort((one, two) => (one.slug < two.slug ? -1 : 1)),
330
344
  };
331
345
  reducedTypes.push(reducedType);
332
346
  }
@@ -355,7 +369,7 @@ const saveTypesFunction = async (data, dir, overwrite) => {
355
369
  for (const type of data.reducedTypes) {
356
370
  const typePathParts = type.typePath.split(':');
357
371
  if (!typePathParts) {
358
- console.warn('skipping bad type with no path', type);
372
+ logger_1.default.warn('skipping bad type with no path', type);
359
373
  }
360
374
  const root = typePathParts[0];
361
375
  if (roots[root]) {
@@ -371,12 +385,12 @@ const saveTypesFunction = async (data, dir, overwrite) => {
371
385
  if (!fs_1.default.existsSync(subDir)) {
372
386
  fs_1.default.mkdirSync(subDir);
373
387
  }
374
- const yamlStr = yaml.dump(types);
388
+ const yamlStr = js_yaml_1.default.dump(types);
375
389
  const fileLabel = root;
376
390
  if (!fileLabel) {
377
- console.warn('skipping bad type root:', root);
391
+ logger_1.default.warn('skipping bad type root:', root);
378
392
  }
379
- const pathToWrite = path.join(subDir, `${removeSlash(fileLabel)}.yml`);
393
+ const pathToWrite = path.join(subDir, `${(0, common_1.removeSlash)(fileLabel)}.yml`);
380
394
  if (fs_1.default.existsSync(pathToWrite)) {
381
395
  await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
382
396
  }
@@ -385,15 +399,36 @@ const saveTypesFunction = async (data, dir, overwrite) => {
385
399
  };
386
400
  async function saveData(reducedData, dir, overwrite) {
387
401
  const propertyToFolderMap = {
388
- reducedTypes: { filename: 'types', split: false, fileLabel: 'slug', saveFunction: saveTypesFunction },
402
+ reducedTypes: {
403
+ filename: 'types',
404
+ split: false,
405
+ fileLabel: 'slug',
406
+ saveFunction: saveTypesFunction,
407
+ },
389
408
  reducedOptionSets: { filename: 'option-sets', split: true, fileLabel: 'name' },
390
- reducedOptionSetHierarchies: { filename: 'option-set-hierarchies', split: true, fileLabel: 'name' },
391
- reducedOptionSetHierarchyLinks: { filename: 'type-option-set-hierarchy-links', split: false, fileLabel: '' },
409
+ reducedOptionSetHierarchies: {
410
+ filename: 'option-set-hierarchies',
411
+ split: true,
412
+ fileLabel: 'name',
413
+ },
414
+ reducedOptionSetHierarchyLinks: {
415
+ filename: 'type-option-set-hierarchy-links',
416
+ split: false,
417
+ fileLabel: '',
418
+ },
392
419
  reducedRuleSets: { filename: 'rule-sets', split: true, fileLabel: 'name' },
393
420
  reducedRuleSetLinks: { filename: 'rule-set-links', split: false, fileLabel: '' },
394
421
  reducedUsageInfo: { filename: 'usage-info', split: false, fileLabel: '' },
395
- reducedTypePropertyPolicies: { filename: 'type-property-policies', split: true, fileLabel: 'label' },
396
- reducedTypePropertyPolicyLinks: { filename: 'type-property-policy-links', split: false, fileLabel: '' },
422
+ reducedTypePropertyPolicies: {
423
+ filename: 'type-property-policies',
424
+ split: true,
425
+ fileLabel: 'label',
426
+ },
427
+ reducedTypePropertyPolicyLinks: {
428
+ filename: 'type-property-policy-links',
429
+ split: false,
430
+ fileLabel: '',
431
+ },
397
432
  reducedTypePolicies: { filename: 'type-policies', split: true, fileLabel: 'label' },
398
433
  reducedTypePolicyLinks: { filename: 'type-policy-links', split: false, fileLabel: '' },
399
434
  };
@@ -408,13 +443,13 @@ async function saveData(reducedData, dir, overwrite) {
408
443
  fs_1.default.mkdirSync(subDir);
409
444
  }
410
445
  for (const item of reducedData[key]) {
411
- const yamlStr = yaml.dump(item);
446
+ const yamlStr = js_yaml_1.default.dump(item);
412
447
  const fileLabel = item[folder.fileLabel];
413
448
  if (!fileLabel) {
414
- console.warn('skipping bad data:', item);
449
+ logger_1.default.warn('skipping bad data:', item);
415
450
  continue;
416
451
  }
417
- const pathToWrite = path.join(subDir, `${removeSlash(fileLabel)}.yml`);
452
+ const pathToWrite = path.join(subDir, `${(0, common_1.removeSlash)(fileLabel)}.yml`);
418
453
  if (fs_1.default.existsSync(pathToWrite)) {
419
454
  await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
420
455
  }
@@ -422,7 +457,7 @@ async function saveData(reducedData, dir, overwrite) {
422
457
  }
423
458
  }
424
459
  else {
425
- const yamlStr = yaml.dump(reducedData[key]);
460
+ const yamlStr = js_yaml_1.default.dump(reducedData[key]);
426
461
  const pathToWrite = path.join(CURRENT_DIR, dir, `${folder.filename}.yml`);
427
462
  if (fs_1.default.existsSync(pathToWrite)) {
428
463
  await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
@@ -431,7 +466,3 @@ async function saveData(reducedData, dir, overwrite) {
431
466
  }
432
467
  }
433
468
  }
434
- function removeSlash(string) {
435
- const re = /\//gi;
436
- return string.replace(re, '-');
437
- }
@@ -1,5 +1,5 @@
1
- import { Command } from '@oclif/core';
2
- export default class LoadAllTypes extends Command {
1
+ import { BaseCommand } from '../basecommand';
2
+ export default class LoadAllTypes extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
@@ -12,9 +12,12 @@ const uploadRuleSets_1 = require("./uploadRuleSets");
12
12
  const uploadTypePropertyPolicies_1 = require("./uploadTypePropertyPolicies");
13
13
  const type_uploader_1 = require("../../helpers/types/type-uploader");
14
14
  const uploadTypePolicies_1 = require("./uploadTypePolicies");
15
- class LoadAllTypes extends core_1.Command {
15
+ const basecommand_1 = require("../basecommand");
16
+ const logger_1 = tslib_1.__importDefault(require("../../logger"));
17
+ class LoadAllTypes extends basecommand_1.BaseCommand {
16
18
  async run() {
17
19
  const { flags } = await this.parse(LoadAllTypes);
20
+ await super.setLogLevel(flags.logLevel);
18
21
  await loadAll(flags.dir);
19
22
  }
20
23
  }
@@ -25,7 +28,12 @@ LoadAllTypes.examples = [
25
28
  `,
26
29
  ];
27
30
  LoadAllTypes.flags = {
28
- dir: core_1.Flags.string({ char: 'd', description: 'The directory from which to load the types data. Defaults to the current directory.', required: false, default: '.' }),
31
+ dir: core_1.Flags.string({
32
+ char: 'd',
33
+ description: 'The directory from which to load the types data. Defaults to the current directory.',
34
+ required: false,
35
+ default: '.',
36
+ }),
29
37
  };
30
38
  async function loadAll(dir, skipPolicies = false) {
31
39
  try {
@@ -41,9 +49,9 @@ async function loadAll(dir, skipPolicies = false) {
41
49
  }
42
50
  }
43
51
  catch (e) {
44
- console.log(`%s Types Upload Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
52
+ logger_1.default.info(`%s Types Upload Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
45
53
  return;
46
54
  }
47
- console.log('%s Types Upload Complete.', chalk_1.default.green.bold('COMPLETE'));
55
+ logger_1.default.info('%s Types Upload Complete.', chalk_1.default.green.bold('COMPLETE'));
48
56
  }
49
57
  exports.loadAll = loadAll;
@@ -1,5 +1,5 @@
1
- import { Command } from '@oclif/core';
2
- export default class MergeOptionSets extends Command {
1
+ import { BaseCommand } from '../basecommand';
2
+ export default class MergeOptionSets extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static args: {
@@ -7,10 +7,13 @@ const fs_1 = tslib_1.__importDefault(require("fs"));
7
7
  const login_1 = require("../../auth/login");
8
8
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
9
9
  const core_1 = require("@oclif/core");
10
- const yaml = require('js-yaml');
11
- class MergeOptionSets extends core_1.Command {
10
+ const basecommand_1 = require("../basecommand");
11
+ const logger_1 = tslib_1.__importDefault(require("../../logger"));
12
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
13
+ class MergeOptionSets extends basecommand_1.BaseCommand {
12
14
  async run() {
13
15
  const { args, flags } = await this.parse(MergeOptionSets);
16
+ await super.setLogLevel(flags.logLevel);
14
17
  try {
15
18
  this.log('%s Importing local file', chalk_1.default.yellow.bold('OPTION SET MERGE'));
16
19
  this.log('Using File: ', args.file);
@@ -37,7 +40,7 @@ function loadOptionSets(fileLocation) {
37
40
  const TARGET_DIR = process.cwd();
38
41
  try {
39
42
  const fullPath = path.resolve(path.join(TARGET_DIR, fileLocation));
40
- const doc = yaml.load(fs_1.default.readFileSync(fullPath, 'utf8'));
43
+ const doc = js_yaml_1.default.load(fs_1.default.readFileSync(fullPath, 'utf8'));
41
44
  return doc;
42
45
  }
43
46
  catch (e) {
@@ -50,7 +53,7 @@ async function mergeOptionSets(fileLocation) {
50
53
  const currentOptionSetsFull = await new sdk_1.Entities().get({
51
54
  entityName: 'type-property-option-set',
52
55
  });
53
- const currentOptionSets = currentOptionSetsFull.map(os => Object.assign({}, {
56
+ const currentOptionSets = currentOptionSetsFull.map((os) => Object.assign({}, {
54
57
  name: os.name,
55
58
  isArchived: os.isArchived,
56
59
  optionSet: os.optionSet,
@@ -68,21 +71,21 @@ async function mergeOptionSets(fileLocation) {
68
71
  const existing = currentOptionSetsByName[uploadedOptionSet.name];
69
72
  if (!existing) {
70
73
  if (!uploadedOptionSet.optionSet) {
71
- console.log('No OptionSet for: ', uploadedOptionSet.name);
74
+ logger_1.default.info('No OptionSet for: ', uploadedOptionSet.name);
72
75
  continue;
73
76
  }
74
- console.log('Adding New: ', uploadedOptionSet.name);
77
+ logger_1.default.info('Adding New: ', uploadedOptionSet.name);
75
78
  mergedOptionSets.push(uploadedOptionSet);
76
79
  }
77
80
  else {
78
- console.log('Merging: ', uploadedOptionSet.name);
81
+ logger_1.default.info('Merging: ', uploadedOptionSet.name);
79
82
  mergedOptionSets.push(mergeOptionSet(existing, uploadedOptionSet));
80
83
  }
81
84
  }
82
85
  for (const currentOptionSet of currentOptionSets) {
83
86
  const found = uploadedOptionSetsByName[currentOptionSet.name];
84
87
  if (!found) {
85
- console.log('Adding Existing: ', currentOptionSet.name);
88
+ logger_1.default.info('Adding Existing: ', currentOptionSet.name);
86
89
  mergedOptionSets.push(currentOptionSet);
87
90
  }
88
91
  }
@@ -99,7 +102,7 @@ function mergeOptionSet(existingOptionSet, uploadedOptionSet) {
99
102
  for (const keyVal of existingOptionSet.optionSet) {
100
103
  const value = keyVal.value;
101
104
  const display = keyVal.display;
102
- const found = merged.optionSet.find(keyVal => keyVal.value === value);
105
+ const found = merged.optionSet.find((keyVal) => keyVal.value === value);
103
106
  if (!found) {
104
107
  merged.optionSet.push({ value, display });
105
108
  }
@@ -108,7 +111,7 @@ function mergeOptionSet(existingOptionSet, uploadedOptionSet) {
108
111
  return merged;
109
112
  }
110
113
  function saveData(data) {
111
- const yamlStr = yaml.dump(data);
114
+ const yamlStr = js_yaml_1.default.dump(data);
112
115
  const CURRENT_DIR = process.cwd();
113
116
  fs_1.default.writeFileSync(path.resolve(path.join(CURRENT_DIR, 'merged_optionSets.yml')), yamlStr, 'utf8');
114
117
  }
@@ -1,5 +1,5 @@
1
- import { Command } from '@oclif/core';
2
- export default class MergeTypeProperties extends Command {
1
+ import { BaseCommand } from '../basecommand';
2
+ export default class MergeTypeProperties extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static strict: boolean;
@@ -9,14 +9,17 @@ const core_1 = require("@oclif/core");
9
9
  const type_extractor_1 = require("../../helpers/types/type-extractor");
10
10
  const getAll_1 = require("./getAll");
11
11
  const types_1 = require("../../api/types");
12
- const yaml = require('js-yaml');
13
- class MergeTypeProperties extends core_1.Command {
12
+ const basecommand_1 = require("../basecommand");
13
+ const logger_1 = tslib_1.__importDefault(require("../../logger"));
14
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
15
+ class MergeTypeProperties extends basecommand_1.BaseCommand {
14
16
  async run() {
15
- const { args, argv } = await this.parse(MergeTypeProperties);
17
+ const { args, argv, flags } = await this.parse(MergeTypeProperties);
18
+ await super.setLogLevel(flags.logLevel);
16
19
  try {
17
20
  this.log('%s Importing local file', chalk_1.default.yellow.bold('TYPE PROPERTIES MERGE'));
18
21
  this.log('Using File: ', args.file);
19
- console.log('argv:', JSON.stringify(argv));
22
+ logger_1.default.info('argv:', JSON.stringify(argv));
20
23
  const typePaths = argv.slice(1);
21
24
  this.log('Using TypePaths: ', typePaths);
22
25
  await mergeTypeProperties(args.file, typePaths);
@@ -45,7 +48,7 @@ function loadTypeProperties(fileLocation) {
45
48
  const TARGET_DIR = process.cwd();
46
49
  try {
47
50
  const fullPath = path.join(TARGET_DIR, fileLocation);
48
- return yaml.load(fs_1.default.readFileSync(fullPath, 'utf8'));
51
+ return js_yaml_1.default.load(fs_1.default.readFileSync(fullPath, 'utf8'));
49
52
  }
50
53
  catch (e) {
51
54
  throw new Error(`ERROR PARSING YAML: ${e}`);
@@ -69,9 +72,9 @@ async function mergeTypeProperties(fileLocation, typePaths) {
69
72
  };
70
73
  const reducedData = await (0, getAll_1.reduceData)(data);
71
74
  for (const typePath of typePaths) {
72
- const foundType = reducedData.reducedTypes.find(reducedTypes => reducedTypes.typePath === typePath);
75
+ const foundType = reducedData.reducedTypes.find((reducedTypes) => reducedTypes.typePath === typePath);
73
76
  if (!foundType) {
74
- console.warn(`%s No Type found for: ${typePath}`, chalk_1.default.red.bold('WARNING'));
77
+ logger_1.default.warn(`%s No Type found for: ${typePath}`, chalk_1.default.red.bold('WARNING'));
75
78
  }
76
79
  mergeType(foundType, uploadedTypeProperties);
77
80
  }
@@ -79,14 +82,14 @@ async function mergeTypeProperties(fileLocation, typePaths) {
79
82
  }
80
83
  function mergeType(reducedType, typePropertiesToAdd) {
81
84
  for (const typeProperty of typePropertiesToAdd) {
82
- const found = reducedType.typeProperties.find(tp => tp.slug === typeProperty.slug);
85
+ const found = reducedType.typeProperties.find((tp) => tp.slug === typeProperty.slug);
83
86
  if (!found) {
84
87
  reducedType.typeProperties.push(typeProperty);
85
88
  }
86
89
  }
87
90
  }
88
91
  function saveData(data) {
89
- const yamlStr = yaml.dump(data);
92
+ const yamlStr = js_yaml_1.default.dump(data);
90
93
  const CURRENT_DIR = process.cwd();
91
94
  fs_1.default.writeFileSync(path.resolve(path.join(CURRENT_DIR, 'merged_types.yml')), yamlStr, 'utf8');
92
95
  }
@@ -1,5 +1,5 @@
1
- import { Command } from '@oclif/core';
2
- export default class ParseOptionSetsHierarchyLocalFile extends Command {
1
+ import { BaseCommand } from '../basecommand';
2
+ export default class ParseOptionSetsHierarchyLocalFile extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static args: {