@contrail/cli 1.0.71 → 2.0.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 (270) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1034 -5
  3. package/bin/dev +17 -0
  4. package/bin/dev.cmd +3 -0
  5. package/bin/run +5 -0
  6. package/bin/run.cmd +3 -0
  7. package/{lib → dist}/api/apps.d.ts +13 -13
  8. package/dist/api/apps.js +96 -0
  9. package/{lib → dist}/api/event-workflow-action-definition.d.ts +1 -1
  10. package/dist/api/event-workflow-action-definition.js +11 -0
  11. package/{lib → dist}/api/event-workflow-template-definition.d.ts +6 -6
  12. package/dist/api/event-workflow-template-definition.js +26 -0
  13. package/{lib → dist}/api/event-workflow-templates.d.ts +7 -7
  14. package/dist/api/event-workflow-templates.js +32 -0
  15. package/dist/api/types.d.ts +7 -0
  16. package/dist/api/types.js +52 -0
  17. package/{lib → dist}/auth/auth.d.ts +9 -9
  18. package/dist/auth/auth.js +6 -0
  19. package/{lib → dist}/auth/login.d.ts +2 -2
  20. package/{lib → dist}/auth/login.js +146 -141
  21. package/dist/commands/app/create.d.ts +6 -0
  22. package/dist/commands/app/create.js +15 -0
  23. package/dist/commands/app/delete.d.ts +7 -0
  24. package/dist/commands/app/delete.js +38 -0
  25. package/dist/commands/app/install.d.ts +11 -0
  26. package/dist/commands/app/install.js +117 -0
  27. package/dist/commands/app/publish.d.ts +7 -0
  28. package/dist/commands/app/publish.js +45 -0
  29. package/dist/commands/app/uninstall.d.ts +10 -0
  30. package/dist/commands/app/uninstall.js +58 -0
  31. package/dist/commands/app/upgrade.d.ts +11 -0
  32. package/dist/commands/app/upgrade.js +79 -0
  33. package/dist/commands/colors/deleteAll.d.ts +6 -0
  34. package/dist/commands/colors/deleteAll.js +30 -0
  35. package/dist/commands/colors/load.d.ts +6 -0
  36. package/dist/commands/colors/load.js +29 -0
  37. package/dist/commands/config/list.d.ts +6 -0
  38. package/dist/commands/config/list.js +15 -0
  39. package/dist/commands/config/remove.d.ts +14 -0
  40. package/dist/commands/config/remove.js +26 -0
  41. package/dist/commands/config/set.d.ts +13 -0
  42. package/dist/commands/config/set.js +29 -0
  43. package/dist/commands/loader-process/load.d.ts +9 -0
  44. package/dist/commands/loader-process/load.js +33 -0
  45. package/dist/commands/loader-process/upload-and-load.d.ts +10 -0
  46. package/dist/commands/loader-process/upload-and-load.js +35 -0
  47. package/dist/commands/projects/export.d.ts +10 -0
  48. package/dist/commands/projects/export.js +34 -0
  49. package/dist/commands/projects/list.d.ts +6 -0
  50. package/dist/commands/projects/list.js +34 -0
  51. package/dist/commands/projects/load.d.ts +9 -0
  52. package/{lib/projects/project-uploader.js → dist/commands/projects/load.js} +106 -105
  53. package/dist/commands/types/exportOptionSetHierarchies.d.ts +7 -0
  54. package/{lib/types/option-set-hierarchy-exporter.js → dist/commands/types/exportOptionSetHierarchies.js} +130 -113
  55. package/{lib/types/types-extractor.d.ts → dist/commands/types/getAll.d.ts} +29 -27
  56. package/{lib/types/types-extractor.js → dist/commands/types/getAll.js} +267 -318
  57. package/dist/commands/types/loadAll.d.ts +7 -0
  58. package/dist/commands/types/loadAll.js +41 -0
  59. package/dist/commands/types/mergeOptionSets.d.ts +9 -0
  60. package/{lib/types/option-set-merger.js → dist/commands/types/mergeOptionSets.js} +114 -105
  61. package/dist/commands/types/mergeTypeProperties.d.ts +11 -0
  62. package/dist/commands/types/mergeTypeProperties.js +89 -0
  63. package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +10 -0
  64. package/dist/commands/types/parseOptionSetsHierarchyLocalFile.js +112 -0
  65. package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +14 -0
  66. package/dist/commands/types/parseOptionSetsLocalFiles.js +153 -0
  67. package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +10 -0
  68. package/dist/commands/types/parseOptionSetsToFolderStructure.js +104 -0
  69. package/dist/commands/types/parseTypesFromFiles.d.ts +10 -0
  70. package/dist/commands/types/parseTypesFromFiles.js +34 -0
  71. package/dist/commands/types/parseTypesFromLocalFiles.d.ts +10 -0
  72. package/dist/commands/types/parseTypesFromLocalFiles.js +34 -0
  73. package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +11 -0
  74. package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.js +36 -0
  75. package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +10 -0
  76. package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.js +35 -0
  77. package/dist/commands/types/uploadOptionSetHierarchies.d.ts +7 -0
  78. package/{lib/types/option-set-hierarchy-uploader.js → dist/commands/types/uploadOptionSetHierarchies.js} +130 -113
  79. package/dist/commands/types/uploadOptionSets.d.ts +7 -0
  80. package/{lib/types/option-set-uploader.js → dist/commands/types/uploadOptionSets.js} +115 -98
  81. package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +11 -0
  82. package/{lib/types/option-set-hierarchy-parser.js → dist/commands/types/uploadOptionSetsHierarchyLocalFile.js} +128 -140
  83. package/dist/commands/types/uploadRuleSets.d.ts +7 -0
  84. package/{lib/types/rule-set-uploader.js → dist/commands/types/uploadRuleSets.js} +189 -172
  85. package/dist/commands/types/uploadTypePropertyPolicies.d.ts +7 -0
  86. package/{lib/types/type-property-policy-uploader.js → dist/commands/types/uploadTypePropertyPolicies.js} +195 -178
  87. package/dist/commands/types/uploadUsageInfo.d.ts +7 -0
  88. package/{lib/types/usage-info-uploader.js → dist/commands/types/uploadUsageInfo.js} +149 -132
  89. package/dist/commands/users/export.d.ts +9 -0
  90. package/dist/commands/users/export.js +60 -0
  91. package/dist/commands/users/upload.d.ts +9 -0
  92. package/dist/commands/users/upload.js +65 -0
  93. package/dist/commands/workflow-template-definitions/install.d.ts +6 -0
  94. package/dist/commands/workflow-template-definitions/install.js +17 -0
  95. package/dist/commands/workflow-template-definitions/list.d.ts +6 -0
  96. package/dist/commands/workflow-template-definitions/list.js +17 -0
  97. package/dist/commands/workflow-templates/delete.d.ts +6 -0
  98. package/dist/commands/workflow-templates/delete.js +17 -0
  99. package/dist/commands/workflow-templates/list.d.ts +6 -0
  100. package/dist/commands/workflow-templates/list.js +17 -0
  101. package/dist/commands/workflow-templates/load.d.ts +9 -0
  102. package/dist/commands/workflow-templates/load.js +21 -0
  103. package/{lib → dist}/common.d.ts +1 -1
  104. package/dist/common.js +9 -0
  105. package/{lib/apps/deploy-app → dist/helpers/app}/actions-deployer.d.ts +11 -11
  106. package/{lib/apps/deploy-app → dist/helpers/app}/actions-deployer.js +122 -114
  107. package/{lib/apps/deploy-app → dist/helpers/app}/app-deployer.d.ts +8 -8
  108. package/{lib/apps/deploy-app → dist/helpers/app}/app-deployer.js +98 -93
  109. package/{lib/apps/deploy-app → dist/helpers/app}/app-template-parsers.d.ts +7 -7
  110. package/{lib/apps/deploy-app → dist/helpers/app}/app-template-parsers.js +43 -38
  111. package/dist/helpers/app/load-app-config.d.ts +1 -0
  112. package/dist/helpers/app/load-app-config.js +18 -0
  113. package/dist/helpers/app/setup-template.d.ts +1 -0
  114. package/dist/helpers/app/setup-template.js +38 -0
  115. package/dist/helpers/colors/helpers.d.ts +4 -0
  116. package/dist/helpers/colors/helpers.js +74 -0
  117. package/{lib → dist/helpers}/config/config.d.ts +6 -6
  118. package/dist/helpers/config/config.js +76 -0
  119. package/dist/helpers/loader-process/helpers.d.ts +2 -0
  120. package/{lib/loader-process/loader-process.js → dist/helpers/loader-process/helpers.js} +98 -120
  121. package/dist/helpers/projects/helpers.d.ts +2 -0
  122. package/{lib/projects/project-exporter.js → dist/helpers/projects/helpers.js} +165 -187
  123. package/{lib → dist/helpers}/types/csv-parser.d.ts +1 -1
  124. package/{lib → dist/helpers}/types/csv-parser.js +56 -51
  125. package/dist/helpers/types/type-extractor.d.ts +1 -0
  126. package/dist/helpers/types/type-extractor.js +32 -0
  127. package/dist/helpers/types/type-parser.d.ts +4 -0
  128. package/dist/helpers/types/type-parser.js +118 -0
  129. package/{lib/types/types-uploader.d.ts → dist/helpers/types/type-uploader.d.ts} +1 -1
  130. package/{lib/types/types-uploader.js → dist/helpers/types/type-uploader.js} +244 -239
  131. package/{lib → dist/helpers}/workflow-template-definitions/workflow-template-definition-deployer.d.ts +12 -12
  132. package/{lib → dist/helpers}/workflow-template-definitions/workflow-template-definition-deployer.js +156 -151
  133. package/{lib/workflow-templates/local-workflow-template-deployer.d.ts → dist/helpers/workflow-templates/helper.d.ts} +17 -11
  134. package/dist/helpers/workflow-templates/helper.js +166 -0
  135. package/dist/index.d.ts +1 -0
  136. package/dist/index.js +5 -0
  137. package/{lib → dist}/interfaces.d.ts +323 -191
  138. package/dist/interfaces.js +63 -0
  139. package/{templates → dist/templates}/typescript/Dockerfile +15 -15
  140. package/{templates → dist/templates}/typescript/README.md +10 -10
  141. package/{templates → dist/templates}/typescript/app.yml +49 -49
  142. package/{templates → dist/templates}/typescript/docker_deploy.bat +1 -1
  143. package/{templates → dist/templates}/typescript/package.json +54 -54
  144. package/{templates → dist/templates}/typescript/src/actions/logItem.ts +25 -25
  145. package/{templates → dist/templates}/typescript/src/framework/action-dispatcher.ts +89 -89
  146. package/{templates → dist/templates}/typescript/src/framework/app-config.ts +26 -26
  147. package/{templates → dist/templates}/typescript/src/framework/handler.ts +11 -11
  148. package/{templates → dist/templates}/typescript/src/framework/index.ts +2 -2
  149. package/{templates → dist/templates}/typescript/src/framework/interfaces.ts +32 -32
  150. package/{templates → dist/templates}/typescript/src/framework/logger.ts +21 -21
  151. package/{templates → dist/templates}/typescript/src/framework/mock-server.ts +31 -31
  152. package/{templates → dist/templates}/typescript/tsconfig.json +28 -28
  153. package/oclif.manifest.json +821 -0
  154. package/package.json +116 -72
  155. package/.eslintrc.js +0 -53
  156. package/.vscode/settings.json +0 -6
  157. package/bin/init +0 -4
  158. package/lib/api/apps.js +0 -85
  159. package/lib/api/event-workflow-action-definition.js +0 -7
  160. package/lib/api/event-workflow-template-definition.js +0 -20
  161. package/lib/api/event-workflow-templates.js +0 -25
  162. package/lib/apps/create-app/create.d.ts +0 -1
  163. package/lib/apps/create-app/create.js +0 -60
  164. package/lib/apps/create-app/setup-template.d.ts +0 -1
  165. package/lib/apps/create-app/setup-template.js +0 -34
  166. package/lib/apps/deploy-app/deploy.d.ts +0 -2
  167. package/lib/apps/deploy-app/deploy.js +0 -58
  168. package/lib/apps/install-app/app-installer.d.ts +0 -2
  169. package/lib/apps/install-app/app-installer.js +0 -120
  170. package/lib/apps/upgrade-app/app-upgrader.d.ts +0 -3
  171. package/lib/apps/upgrade-app/app-upgrader.js +0 -126
  172. package/lib/auth/auth.js +0 -2
  173. package/lib/cli.d.ts +0 -5
  174. package/lib/cli.js +0 -524
  175. package/lib/colors/color-loader.d.ts +0 -2
  176. package/lib/colors/color-loader.js +0 -96
  177. package/lib/common.js +0 -5
  178. package/lib/config/config.js +0 -70
  179. package/lib/config/configCommands.d.ts +0 -3
  180. package/lib/config/configCommands.js +0 -34
  181. package/lib/interfaces.js +0 -25
  182. package/lib/loader-process/loader-process.d.ts +0 -2
  183. package/lib/projects/interfaces.d.ts +0 -77
  184. package/lib/projects/interfaces.js +0 -23
  185. package/lib/projects/project-exporter.d.ts +0 -2
  186. package/lib/projects/project-uploader.d.ts +0 -1
  187. package/lib/types/allUploader.d.ts +0 -1
  188. package/lib/types/allUploader.js +0 -24
  189. package/lib/types/interfaces.d.ts +0 -55
  190. package/lib/types/interfaces.js +0 -1
  191. package/lib/types/option-set-hierarchy-exporter.d.ts +0 -1
  192. package/lib/types/option-set-hierarchy-parser.d.ts +0 -2
  193. package/lib/types/option-set-hierarchy-uploader.d.ts +0 -1
  194. package/lib/types/option-set-merger.d.ts +0 -1
  195. package/lib/types/option-set-parser.d.ts +0 -3
  196. package/lib/types/option-set-parser.js +0 -140
  197. package/lib/types/option-set-uploader.d.ts +0 -1
  198. package/lib/types/parse-types.d.ts +0 -4
  199. package/lib/types/parse-types.js +0 -189
  200. package/lib/types/rule-set-uploader.d.ts +0 -1
  201. package/lib/types/type-property-policy-uploader.d.ts +0 -1
  202. package/lib/types/types-properties-merger.d.ts +0 -1
  203. package/lib/types/types-properties-merger.js +0 -75
  204. package/lib/types/usage-info-uploader.d.ts +0 -1
  205. package/lib/users/user-exporter.d.ts +0 -1
  206. package/lib/users/user-exporter.js +0 -41
  207. package/lib/users/user-uploader.d.ts +0 -1
  208. package/lib/users/user-uploader.js +0 -45
  209. package/lib/workflow-template-definitions/workflow-template-definition-commands.d.ts +0 -2
  210. package/lib/workflow-template-definitions/workflow-template-definition-commands.js +0 -10
  211. package/lib/workflow-templates/local-workflow-template-deployer.js +0 -102
  212. package/lib/workflow-templates/workflow-template-commands.d.ts +0 -4
  213. package/lib/workflow-templates/workflow-template-commands.js +0 -51
  214. package/lib/workflow-templates/workflow-template-deployer.d.ts +0 -4
  215. package/lib/workflow-templates/workflow-template-deployer.js +0 -26
  216. package/publish.bat +0 -5
  217. package/publish.sh +0 -5
  218. package/src/api/apps.ts +0 -97
  219. package/src/api/event-workflow-action-definition.ts +0 -8
  220. package/src/api/event-workflow-template-definition.ts +0 -23
  221. package/src/api/event-workflow-templates.ts +0 -29
  222. package/src/apps/create-app/create.ts +0 -74
  223. package/src/apps/create-app/setup-template.ts +0 -38
  224. package/src/apps/deploy-app/actions-deployer.ts +0 -140
  225. package/src/apps/deploy-app/app-deployer.ts +0 -105
  226. package/src/apps/deploy-app/app-template-parsers.ts +0 -44
  227. package/src/apps/deploy-app/deploy.ts +0 -66
  228. package/src/apps/install-app/app-installer.ts +0 -126
  229. package/src/apps/upgrade-app/app-upgrader.ts +0 -132
  230. package/src/auth/auth.ts +0 -10
  231. package/src/auth/login.ts +0 -155
  232. package/src/cli.ts +0 -540
  233. package/src/colors/color-loader.ts +0 -112
  234. package/src/colors/colors.csv +0 -866
  235. package/src/common.ts +0 -5
  236. package/src/config/config.ts +0 -74
  237. package/src/config/configCommands.ts +0 -38
  238. package/src/interfaces.ts +0 -200
  239. package/src/loader-process/loader-process.ts +0 -152
  240. package/src/projects/interfaces.ts +0 -73
  241. package/src/projects/project-exporter.ts +0 -225
  242. package/src/projects/project-uploader.ts +0 -131
  243. package/src/types/allUploader.ts +0 -28
  244. package/src/types/csv-parser.ts +0 -59
  245. package/src/types/interfaces.ts +0 -58
  246. package/src/types/option-set-hierarchy-exporter.ts +0 -125
  247. package/src/types/option-set-hierarchy-parser.ts +0 -169
  248. package/src/types/option-set-hierarchy-uploader.ts +0 -122
  249. package/src/types/option-set-merger.ts +0 -124
  250. package/src/types/option-set-parser.ts +0 -166
  251. package/src/types/option-set-uploader.ts +0 -108
  252. package/src/types/parse-types.ts +0 -227
  253. package/src/types/rule-set-uploader.ts +0 -187
  254. package/src/types/type-property-policy-uploader.ts +0 -192
  255. package/src/types/types-extractor.ts +0 -369
  256. package/src/types/types-properties-merger.ts +0 -90
  257. package/src/types/types-uploader.ts +0 -271
  258. package/src/types/usage-info-uploader.ts +0 -139
  259. package/src/users/user-exporter.ts +0 -52
  260. package/src/users/user-uploader.ts +0 -58
  261. package/src/workflow-template-definitions/workflow-template-definition-commands.ts +0 -13
  262. package/src/workflow-template-definitions/workflow-template-definition-deployer.ts +0 -184
  263. package/src/workflow-templates/local-workflow-template-deployer.ts +0 -126
  264. package/src/workflow-templates/workflow-template-commands.ts +0 -59
  265. package/src/workflow-templates/workflow-template-deployer.ts +0 -30
  266. package/templates/javascript/actions/example/action.js +0 -38
  267. package/templates/javascript/app.yml +0 -53
  268. package/templates/javascript/package.json +0 -23
  269. package/templates/typescript/package-lock.json +0 -14
  270. package/tsconfig.json +0 -32
package/src/common.ts DELETED
@@ -1,5 +0,0 @@
1
- export function getSeparatorByPlatform() {
2
- const isWin = process.platform === 'win32';
3
- const separator = isWin ? '\\' : '/';
4
- return separator;
5
- }
@@ -1,74 +0,0 @@
1
- import { promises as fsPromises } from 'fs';
2
- import { join } from 'path';
3
- import {homedir} from 'os';
4
- const userHomeDir = homedir();
5
- const configDirectoryLocation = join(userHomeDir, '.vibeiq');
6
- const configFileLocation = join(configDirectoryLocation, 'config.json');
7
-
8
- export async function initializeVibeIQConfig() {
9
- try{
10
- await fsPromises.mkdir(configDirectoryLocation, {recursive: true});
11
- } catch (e) {
12
- console.error('could not initialize vibeiq directory');
13
- throw e;
14
- }
15
-
16
- try {
17
- await fsPromises.writeFile(configFileLocation, '{}');
18
- } catch (e) {
19
- console.error(`could not initialize config file (${configFileLocation}).`);
20
- throw e;
21
- }
22
- }
23
- export async function readVibeIQConfig() {
24
- let fileContent;
25
- try {
26
- fileContent = await fsPromises.readFile(configFileLocation);
27
- } catch (e) {
28
- console.debug(`failed to open config file (${configFileLocation}) for reading.`);
29
- console.debug('trying to initialize config file');
30
- await initializeVibeIQConfig();
31
- fileContent = await fsPromises.readFile(configFileLocation);
32
- }
33
-
34
- try {
35
- return JSON.parse(fileContent);
36
- } catch (e) {
37
- console.error(`Could not parse local vibeiq config. The file (${configFileLocation}) might be malformed`);
38
- }
39
- }
40
-
41
- export async function writeVibeIQConfig(config: any) {
42
- try {
43
- await fsPromises.writeFile(configFileLocation, JSON.stringify(config, null, 2));
44
- } catch (e) {
45
- console.error(`Could not open config file (${configFileLocation}) for writing.`);
46
- throw e;
47
- }
48
- }
49
-
50
- export async function getConfig() {
51
- console.debug('getting config from file system');
52
- return await readVibeIQConfig();
53
- }
54
-
55
- export async function deleteConfigs(configNames: string[]) {
56
- const currentConfig = await readVibeIQConfig();
57
- for(const configName of configNames) {
58
- delete currentConfig[configName];
59
- }
60
- await storeConfig(currentConfig, false);
61
- }
62
-
63
- export async function storeConfig(incomingConfig: any, merge=true) {
64
- let config;
65
- if (merge) {
66
- config = {
67
- ... await readVibeIQConfig(),
68
- ... incomingConfig
69
- };
70
- } else {
71
- config = incomingConfig;
72
- }
73
- await writeVibeIQConfig(config);
74
- }
@@ -1,38 +0,0 @@
1
- import {deleteConfigs, readVibeIQConfig, storeConfig} from './config';
2
- export async function listConfig() {
3
- console.log(await readVibeIQConfig());
4
- }
5
-
6
- export async function setConfig(args) {
7
- const helpConfigLine = `
8
- Usage:
9
- contrail config.set key1=value1 key2=value2
10
- `;
11
- if (args?.length < 4) {
12
- console.log(helpConfigLine);
13
- throw new Error('You need to pass at least one config to set');
14
- }
15
- const configsToSet = args.slice(3);
16
- const config = {};
17
- for(const conf of configsToSet) {
18
- if(conf.length < 3 || conf.indexOf('=') <= 0) {
19
- console.log(helpConfigLine);
20
- throw new Error(`value ${conf} does not adhere to key1=value1 standard`);
21
- }
22
- const [key, value] = conf.split('=');
23
- console.log('key and value:', key, value);
24
- console.log(conf.split('='));
25
- config[key] = value;
26
- }
27
- console.log('config is:', config);
28
- await storeConfig(config);
29
- }
30
-
31
- export async function removeConfig(args) {
32
- if (args?.length < 4) {
33
- throw new Error('At least one configuration must be included to be removed.');
34
- }
35
-
36
- await deleteConfigs(args.slice(3));
37
-
38
- }
package/src/interfaces.ts DELETED
@@ -1,200 +0,0 @@
1
- /** Describes the derivative JSON / object represented
2
- * in app.yml file.
3
- */
4
- export interface AppDeclaration {
5
- appIdentifier: string;
6
- appName: string;
7
- appDescription?: string;
8
- visibility: 'private' | 'public';
9
- publisher: string;
10
- version: string;
11
- eventWorkflowTriggerKeyMapping: string;
12
- thumbnail?: string;
13
- keywords?: Array<string>;
14
- actions?: { [key: string]: AppActionDeclaration };
15
- appConfiguration: ConfigPropertyElements;
16
- triggers: { [key: string]: AppTriggerDeclaration };
17
- workflows?: { [key: string]: WorkflowDefinition | WorkflowTemplateDeclaration };
18
- dockerImageRef?: string;
19
- }
20
-
21
- export interface ConfigPropertyElements {
22
- [key: string]: ConfigPropertyElement;
23
- }
24
-
25
- export interface ConfigPropertyElement {
26
- propertyType: string;
27
- options?: any[];
28
- label: string;
29
- dynamic?: boolean;
30
- }
31
-
32
- export interface AppActionDeclaration {
33
- handler: string;
34
- public?: boolean;
35
- name: string;
36
- description?: string;
37
- actionConfiguration?: ConfigPropertyElements;
38
- async?: boolean; // defaults to false
39
- }
40
-
41
- export interface AppTriggerDeclaration {
42
- key: string;
43
- name: string;
44
- external?: boolean;
45
- description?: string;
46
- }
47
-
48
- // workflow-template and workflow-template-definition share the same interface
49
- export interface WorkflowDefinition {
50
- id?: string;
51
- identifier: string;
52
- name: string;
53
- triggerKey: string;
54
- workflowDefinition: WorkflowDefinitionPaths;
55
- ownerKey: string;
56
- isActive: boolean;
57
- public: boolean;
58
- supportingAppId?: string;
59
- messageGroupId?: string;
60
- parallelWorkerCount?: number;
61
- }
62
-
63
- export interface WorkflowTemplateDeclaration {
64
- workflows?: { [key: string]: WorkflowTemplate }
65
- }
66
-
67
- export interface WorkflowTemplate {
68
- id?: string;
69
- identifier?: string;
70
- name: string;
71
- triggerKey: string;
72
- workflowDefinition: WorkflowDefinitionPaths;
73
- isActive: boolean;
74
- ownerKey?: string;
75
- supportingAppId?: string;
76
- messageGroupId?: string;
77
- parallelWorkerCount?: number;
78
- }
79
-
80
- export interface WorkflowDefinitionPaths {
81
- paths: WorkflowConditional[]
82
- }
83
-
84
- export interface WorkflowConditional {
85
- conditional: string;
86
- actionDefinitionConfigs: ActionDefinitionConfig[]
87
- }
88
- export interface ActionDefinitionConfig {
89
- name: string;
90
- action: string;
91
- config?: { [key: string]: any };
92
- id?: string;
93
- }
94
-
95
- export interface App {
96
- id: string;
97
- identifier: string;
98
- name: string;
99
- public: boolean;
100
- description?: string;
101
- publisher: string;
102
- thumbnail: string; // should be a public link
103
- eventWorkflowTriggerKeyMapping: string;
104
- configProperties?: ConfigProperty[];
105
- triggerKeyDefinitions?: TriggerKeyDefinition[];
106
- }
107
-
108
- export interface AppOrg {
109
- id: string;
110
- createdOn?: Date;
111
- updatedOn?: Date;
112
- createdById?: string;
113
- updatedById?: string;
114
- createdBy?: any;
115
- updatedBy?: any;
116
- orgId?: string;
117
- status: AppOrgStatus;
118
- appId?: string;
119
- app?: App;
120
- appVersionId?: string;
121
- appVersion?: AppVersion;
122
- apiKey?: AppApiKey;
123
- appConfig?: any;
124
- }
125
-
126
- export enum AppOrgStatus {
127
- INSTALLING = 'INSTALLING',
128
- FAILED_INSTALLING = 'FAILED_INSTALLING',
129
- READY = 'READY',
130
- DELETING = 'DELETING',
131
- FAILED_DELETING = 'FAILED_DELETING',
132
- }
133
-
134
- export enum AppVersionStatus {
135
- PUBLISHING = 'PUBLISHING',
136
- FAILED_PUBLISHING = 'FAILED_PUBLISHING',
137
- PUBLISHED = 'PUBLISHED',
138
- ARCHIVING = 'ARCHIVING',
139
- FAILED_ARCHIVING = 'FAILED_ARCHIVING',
140
- ARCHIVED = 'ARCHIVED',
141
- }
142
-
143
- export class AppVersion {
144
- id: string;
145
- createdOn?: Date;
146
- updatedOn?: Date;
147
- createdById?: string;
148
- updatedById?: string;
149
- createdBy?: any;
150
- updatedBy?: any;
151
- orgId?: string;
152
- appId?: string;
153
- app?: App;
154
- appOrgs?: AppOrg[];
155
- versionNumber: number;
156
- status: AppVersionStatus;
157
- eventWorkflowTriggerKeyMapping: string;
158
- configProperties?: ConfigProperty[];
159
- triggerKeyDefinitions?: TriggerKeyDefinition[];
160
- dockerImageRef?: string;
161
- }
162
-
163
- export class AppApiKey {
164
- id: string;
165
- createdOn?: Date;
166
- updatedOn?: Date;
167
- createdById?: string;
168
- updatedById?: string;
169
- createdBy?: any;
170
- updatedBy?: any;
171
- orgId?: string;
172
- appOrgId?: string;
173
- appOrg?: AppOrg;
174
- apiKey?: string;
175
- }
176
-
177
- export class ConfigProperty {
178
- slug: string;
179
- propertyType: string;
180
- options?: any[];
181
- label: string;
182
- }
183
-
184
- export interface EventWorkflowActionDefinition {
185
- id?: string;
186
- identifier?: string;
187
- name?: string;
188
- executeFunctionString?: string;
189
- ownerKey?: string;
190
- public?: boolean;
191
- configProperties?: ConfigProperty[];
192
- async?: boolean;
193
- }
194
-
195
- export class TriggerKeyDefinition {
196
- name: string;
197
- description?: string;
198
- triggerKey: string;
199
- external?: boolean;
200
- }
@@ -1,152 +0,0 @@
1
- import { Entities, Files } from '@contrail/sdk';
2
- import { authUser } from '../auth/login';
3
- import chalk from 'chalk';
4
- import * as fs from 'fs';
5
- import { getSeparatorByPlatform } from '../common';
6
- import yaml from 'js-yaml';
7
-
8
- export async function UploadAndLoad(args) {
9
- try {
10
- await authUser();
11
- console.log('%s Uploading file', chalk.yellow.bold('LOADER'));
12
- const incomingFileName = args[3];
13
- const configFileName = args[4];
14
-
15
- await uploadAndLoadLocalFile(incomingFileName, configFileName);
16
- console.log('%s Uploaded', chalk.yellow.bold('LOADER'));
17
-
18
- }
19
- catch (e) {
20
- console.log(`%s Starting Load Failed. ${e}`, chalk.red.bold('FAIL'));
21
- return;
22
- }
23
-
24
- console.log('%s Starting Load Complete.', chalk.green.bold('COMPLETE'));
25
- }
26
-
27
- export async function Load(args) {
28
- try {
29
- await authUser();
30
- console.log('%s Uploading file', chalk.yellow.bold('LOADER'));
31
- const configFileName = args[3];
32
-
33
- await loadLocalFile(configFileName);
34
- console.log('%s Uploaded', chalk.yellow.bold('LOADER'));
35
-
36
- }
37
- catch (e) {
38
- console.log(`%s Starting Load Failed. ${e}`, chalk.red.bold('FAIL'));
39
- return;
40
- }
41
-
42
- console.log('%s Starting Load Complete.', chalk.green.bold('COMPLETE'));
43
- }
44
-
45
- async function getLocalFile(incomingFileName) {
46
-
47
- const ext = getFileExtension(incomingFileName);
48
- if (ext !== '.csv') {
49
- throw new Error('Upload file must be a .csv');
50
- }
51
-
52
- const TARGET_DIR = process.cwd();
53
- try {
54
- const separator = getSeparatorByPlatform();
55
- return fs.readFileSync(TARGET_DIR + separator + incomingFileName);
56
- } catch (e) {
57
- throw new Error(`ERROR LOADING CSV: ${e}`);
58
- }
59
- }
60
-
61
- async function getLocalUploadConfig(configFileName) {
62
-
63
- const ext = getFileExtension(configFileName);
64
- if (ext !== '.json' && ext !== '.yml') {
65
- throw new Error('Upload file must be a .json or .yml');
66
- }
67
-
68
- const CURRENT_DIR = process.cwd();
69
- const separator = getSeparatorByPlatform();
70
- const fullPath = CURRENT_DIR + separator + configFileName;
71
- console.log('Getting config from path: ', fullPath);
72
-
73
- if (ext === '.yml') {
74
- try {
75
- const doc = yaml.load(fs.readFileSync(fullPath, 'utf8'));
76
- return doc;
77
- } catch (e) {
78
- throw new Error(`ERROR LOADING UPLOAD CONFIGURATION FILE: ${e}`);
79
- }
80
- }
81
-
82
- try {
83
- const doc = JSON.parse(fs.readFileSync(fullPath, 'utf8'));
84
- return doc;
85
- } catch (e) {
86
- throw new Error(`ERROR LOADING UPLOAD CONFIGURATION FILE: ${e}`);
87
- }
88
-
89
- }
90
-
91
- async function uploadFile(incomingFileName) {
92
- const csvContent = await getLocalFile(incomingFileName);
93
-
94
- const entities = new Entities();
95
- const fileName = `${incomingFileName.slice(0, incomingFileName.length - 4)}-Upload-${new Date().getTime()}.csv`;
96
- const file = await entities.create({
97
- entityName: 'file',
98
- object: { contentType: 'text/csv', fileName: fileName, ttl: 24 * 60 * 60 * 1000 }
99
- });
100
- console.log('VibeIQ file ID:', file.id);
101
-
102
- // Upload the CSV data to the newly created VibeIQ file
103
- const fileDetails = {
104
- contentType: 'text/csv',
105
- };
106
- await new Files().uploadFileAsStream(file.uploadPost, csvContent as any, fileDetails);
107
- console.log('File uploaded.');
108
-
109
- return file;
110
- }
111
-
112
- async function loadFile(config) {
113
-
114
- const entities = new Entities();
115
- // start a load job referencing the newly created file
116
- console.log('Loading with config: ', config);
117
- const loadJob = await entities.create(
118
- {
119
- entityName: 'loader-process',
120
- object: {
121
- ...config
122
- }
123
- });
124
-
125
- console.log('Load has been kicked off. loader-process ID: ', loadJob.id);
126
- }
127
-
128
- async function uploadAndLoadLocalFile(incomingFileName, configFileName) {
129
- const file = await uploadFile(incomingFileName);
130
- const config = await getLocalUploadConfig(configFileName);
131
- const fullConfig = {
132
- fileLocation: file.id,
133
- ...config
134
- };
135
- await loadFile(fullConfig);
136
- }
137
-
138
- async function loadLocalFile(configFileName) {
139
- const config = await getLocalUploadConfig(configFileName);
140
- await loadFile(config);
141
- }
142
-
143
- function getFileExtension(fileName) {
144
- let ext = '';
145
-
146
- const parts = fileName?.split('.');
147
- if (parts?.length > 1) {
148
- ext = '.' + parts[parts?.length - 1];
149
- }
150
-
151
- return ext;
152
- }
@@ -1,73 +0,0 @@
1
- export class CommonConfiguration {
2
- [key: string]: any;
3
- }
4
-
5
- export enum AssortmentType {
6
- ASSORTMENT = 'ASSORTMENT',
7
- BOARD = 'BOARD',
8
- PLAN = 'PLAN',
9
- SHOWCASE = 'SHOWCASE',
10
- }
11
-
12
- export class AssortmentConfiguration {
13
- identifier: string;
14
- name: string;
15
- type: AssortmentType;
16
- sourceAssortmentIdentifier?: string;
17
- composedFromAssortmentIdentifiers?: string[];
18
- ownerAtts?: {[key: string]: any};
19
- assortmentAtts?: {[key: string]: any};
20
- }
21
-
22
- export class Folder {
23
- identifier: string;
24
- name: string;
25
- principals: string[];
26
- assortments: AssortmentConfiguration[];
27
- subFolders: Folder[];
28
- }
29
-
30
- export class ProjectConfiguration {
31
- projectName: string;
32
- identifier: string;
33
- commonConfig: CommonConfiguration;
34
- principals: string[];
35
- assortments: AssortmentConfiguration[];
36
- subFolders: Folder[];
37
- }
38
-
39
- export class ProjectConfigurationTemplate {
40
- projectName: string;
41
- identifier: string;
42
- commonConfig: CommonConfiguration;
43
- principals: string[];
44
- allFolders: FolderSlim[];
45
- allAssortments: AssortmentConfigurationSlim[];
46
- allAssortmentRelationships: AssortmentConfigurationRelationships[];
47
- }
48
-
49
- export class FolderSlim {
50
- identifier: string;
51
- name: string;
52
- principals: string[];
53
- folderIdentifier: string;
54
- }
55
-
56
- export class AssortmentConfigurationSlim {
57
- identifier: string;
58
- name: string;
59
- type: AssortmentType;
60
- folderIdentifier: string;
61
- sourceAssortmentIdentifier?: string;
62
- composedFromAssortmentIdentifiers?: string[];
63
- ownerAtts?: {[key: string]: any};
64
- assortmentAtts?: {[key: string]: any};
65
- }
66
-
67
- export class AssortmentConfigurationRelationships {
68
- identifier: string;
69
- sourceAssortmentIdentifier?: string;
70
- composedFromAssortmentIdentifiers?: string[];
71
- ownerAtts?: {[key: string]: any};
72
- assortmentAtts?: {[key: string]: any};
73
- }