zcatalyst-cli 1.9.0 → 1.11.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 (190) hide show
  1. package/README.md +29 -29
  2. package/docs/client-utils.toml +5 -0
  3. package/docs/command_needs/auth.toml +5 -0
  4. package/docs/commands/iac/export.toml +4 -0
  5. package/docs/commands/iac/import.toml +4 -0
  6. package/docs/commands/iac/status.toml +4 -0
  7. package/docs/commands/project/use.toml +6 -0
  8. package/docs/iac/status/bundle.toml +4 -0
  9. package/docs/plugin-loader.toml +4 -0
  10. package/docs/serve/server/index.toml +4 -0
  11. package/docs/serve/server/lib/web_client/server.toml +4 -0
  12. package/lib/api-timer.js +81 -0
  13. package/lib/apig-utils.js +17 -14
  14. package/lib/archiver.js +83 -45
  15. package/lib/authentication/login.js +4 -2
  16. package/lib/bin/catalyst.js +0 -1
  17. package/lib/client-utils.js +55 -26
  18. package/lib/client.js +0 -3
  19. package/lib/command_needs/auth.js +12 -3
  20. package/lib/command_needs/rc.js +12 -7
  21. package/lib/commands/apig/disable.js +1 -1
  22. package/lib/commands/apig/enable.js +1 -1
  23. package/lib/commands/apig/status.js +7 -5
  24. package/lib/commands/client/delete.js +4 -5
  25. package/lib/commands/client/setup.js +1 -1
  26. package/lib/commands/deploy.js +4 -2
  27. package/lib/commands/ds/export.js +4 -2
  28. package/lib/commands/ds/import.js +4 -2
  29. package/lib/commands/ds/status.js +146 -150
  30. package/lib/commands/event/generate/index.js +5 -14
  31. package/lib/commands/event/generate/integ.js +1 -1
  32. package/lib/commands/functions/add.js +1 -1
  33. package/lib/commands/functions/config.js +1 -1
  34. package/lib/commands/functions/delete.js +1 -1
  35. package/lib/commands/functions/setup.js +1 -1
  36. package/lib/commands/functions/shell.js +1 -1
  37. package/lib/commands/help.js +0 -22
  38. package/lib/commands/iac/export.js +85 -0
  39. package/lib/commands/iac/import.js +189 -0
  40. package/lib/commands/iac/pack.js +129 -0
  41. package/lib/commands/iac/status.js +63 -0
  42. package/lib/commands/index.js +4 -0
  43. package/lib/commands/init.js +35 -28
  44. package/lib/commands/login.js +1 -1
  45. package/lib/commands/logout.js +1 -1
  46. package/lib/commands/project/list.js +11 -7
  47. package/lib/commands/project/reset.js +1 -1
  48. package/lib/commands/project/use.js +42 -25
  49. package/lib/commands/pull.js +2 -2
  50. package/lib/commands/run.js +1 -1
  51. package/lib/commands/serve.js +3 -2
  52. package/lib/commands/token/generate.js +1 -1
  53. package/lib/commands/token/list.js +1 -1
  54. package/lib/commands/token/revoke.js +1 -1
  55. package/lib/commands/whoami.js +1 -1
  56. package/lib/deploy/features/functions/index.js +2 -1
  57. package/lib/deploy/index.js +3 -1
  58. package/lib/endpoints/lib/iac.js +134 -0
  59. package/lib/error.js +33 -3
  60. package/lib/errorOut.js +4 -3
  61. package/lib/fn-utils/lib/common.js +37 -16
  62. package/lib/fn-utils/lib/java.js +7 -9
  63. package/lib/fn-utils/lib/node.js +7 -1
  64. package/lib/iac/status/bundle.js +82 -0
  65. package/lib/iac/status/deploy.js +74 -0
  66. package/lib/iac/status/util/index.js +26 -0
  67. package/lib/index.js +13 -19
  68. package/lib/init/dependencies/npm-install.js +2 -9
  69. package/lib/init/features/client/index.js +47 -0
  70. package/lib/init/features/client/initializers/angular.js +88 -0
  71. package/lib/init/features/client/initializers/basic.js +27 -0
  72. package/lib/init/features/client/initializers/lyte.js +44 -0
  73. package/lib/init/features/client/initializers/react.js +53 -0
  74. package/lib/init/features/functions/languages/java.js +2 -5
  75. package/lib/init/features/functions/languages/node.js +5 -6
  76. package/lib/init/features/index.js +18 -6
  77. package/lib/init/features/project.js +72 -34
  78. package/lib/init/util/client.js +12 -0
  79. package/lib/init/util/functions.js +20 -0
  80. package/lib/init/util/project.js +35 -0
  81. package/lib/internal/api.js +6 -9
  82. package/lib/internal/command.js +6 -3
  83. package/lib/internal/config.js +7 -4
  84. package/lib/migration/index.js +10 -6
  85. package/lib/option-filter.js +4 -1
  86. package/lib/optional-import.js +11 -25
  87. package/lib/plugin-loader.js +8 -2
  88. package/lib/port-resolver.js +20 -16
  89. package/lib/prompt/index.js +92 -0
  90. package/lib/prompt/types/file-path.js +95 -0
  91. package/lib/pull/features/client.js +1 -1
  92. package/lib/pull/features/functions/index.js +5 -7
  93. package/lib/pull/index.js +4 -1
  94. package/lib/serve/features/index.js +3 -1
  95. package/lib/serve/index.js +6 -1
  96. package/lib/serve/server/index.js +74 -29
  97. package/lib/serve/server/lib/master.js +28 -12
  98. package/lib/serve/server/lib/web_client/index.js +30 -0
  99. package/lib/serve/server/lib/web_client/server.js +171 -0
  100. package/lib/serve/server/lib/web_client/utils.js +10 -0
  101. package/lib/shell/dependencies/http-functions.js +1 -1
  102. package/lib/shell/index.js +3 -1
  103. package/lib/track.js +3 -1
  104. package/lib/util_modules/char.js +1 -1
  105. package/lib/util_modules/config/lib/apig.js +2 -1
  106. package/lib/util_modules/constants/index.js +5 -1
  107. package/lib/util_modules/constants/lib/file-names.js +2 -1
  108. package/lib/util_modules/constants/lib/iac.js +8 -0
  109. package/lib/util_modules/constants/lib/placeholders.js +3 -1
  110. package/lib/util_modules/constants/lib/plugin.js +28 -0
  111. package/lib/util_modules/constants/lib/regex.js +2 -1
  112. package/lib/util_modules/constants/lib/scopes.js +5 -0
  113. package/lib/util_modules/constants/lib/template.js +11 -1
  114. package/lib/util_modules/constants/lib/urls.js +8 -0
  115. package/lib/util_modules/constants/project.js +6 -0
  116. package/lib/util_modules/{contextHelp.js → context-help.js} +5 -1
  117. package/lib/util_modules/env.js +14 -16
  118. package/lib/util_modules/fs/index.js +9 -1
  119. package/lib/util_modules/fs/lib/async.js +29 -22
  120. package/lib/util_modules/global-space.js +99 -0
  121. package/lib/util_modules/js.js +6 -0
  122. package/lib/util_modules/option.js +5 -1
  123. package/lib/util_modules/parser/toml.js +5 -1
  124. package/lib/util_modules/project.js +3 -0
  125. package/lib/util_modules/shell.js +9 -8
  126. package/lib/winston.js +1 -1
  127. package/package.json +11 -5
  128. package/templates/iacSuccess.html +391 -0
  129. package/templates/init/.DS_Store +0 -0
  130. package/templates/init/client/.DS_Store +0 -0
  131. package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
  132. package/templates/init/client/{index.html → basic/index.html} +0 -0
  133. package/templates/init/client/{main.css → basic/main.css} +0 -0
  134. package/templates/init/client/{main.js → basic/main.js} +0 -0
  135. package/templates/init/client/lyte/build/build.js +301 -0
  136. package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
  137. package/templates/init/client/lyte/client-package.json +5 -0
  138. package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
  139. package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
  140. package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
  141. package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
  142. package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
  143. package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
  144. package/templates/init/client/lyte/index.html +17 -0
  145. package/templates/init/client/lyte/package.json +12 -0
  146. package/templates/init/client/lyte/router.js +14 -0
  147. package/templates/init/client/lyte/routes/index.js +54 -0
  148. package/templates/init/client/react/.DS_Store +0 -0
  149. package/templates/init/client/react/react_js/package.json +11 -0
  150. package/templates/init/client/react/react_js/template/README.md +70 -0
  151. package/templates/init/client/react/react_js/template/client-package.json +5 -0
  152. package/templates/init/client/react/react_js/template/gitignore +23 -0
  153. package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
  154. package/templates/init/client/react/react_js/template/public/index.html +43 -0
  155. package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
  156. package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
  157. package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
  158. package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
  159. package/templates/init/client/react/react_js/template/src/App.css +38 -0
  160. package/templates/init/client/react/react_js/template/src/App.js +25 -0
  161. package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
  162. package/templates/init/client/react/react_js/template/src/index.css +13 -0
  163. package/templates/init/client/react/react_js/template/src/index.js +17 -0
  164. package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
  165. package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
  166. package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
  167. package/templates/init/client/react/react_js/template.json +13 -0
  168. package/templates/init/client/react/react_ts/package.json +11 -0
  169. package/templates/init/client/react/react_ts/template/README.md +46 -0
  170. package/templates/init/client/react/react_ts/template/client-package.json +5 -0
  171. package/templates/init/client/react/react_ts/template/gitignore +23 -0
  172. package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
  173. package/templates/init/client/react/react_ts/template/public/index.html +43 -0
  174. package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
  175. package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
  176. package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
  177. package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
  178. package/templates/init/client/react/react_ts/template/src/App.css +38 -0
  179. package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
  180. package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
  181. package/templates/init/client/react/react_ts/template/src/index.css +13 -0
  182. package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
  183. package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
  184. package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
  185. package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
  186. package/templates/init/client/react/react_ts/template.json +18 -0
  187. package/templates/web-socket.txt +21 -0
  188. package/lib/init/features/client.js +0 -51
  189. package/lib/prompt.js +0 -49
  190. package/lib/serve/server/lib/client.js +0 -30
@@ -41,9 +41,18 @@ exports.default = (inScopes = []) => {
41
41
  });
42
42
  }
43
43
  logger_1.debug(`> authorizing via ${tokenObj.option} option`);
44
- const commandScopes = [constants_1.SCOPE.projects, ...inScopes].filter((value, index, self) => self.indexOf(value) === index);
45
- logger_1.debug('> command requires scopes: ' + JSON.stringify([constants_1.SCOPE.projects].concat(inScopes || [])));
46
- runtime_store_1.default.set('auth_scopes', commandScopes);
44
+ const existingScopes = config_store_1.default.get(`${activeDC}.scopes`, []);
45
+ const requiredScopes = [constants_1.SCOPE.projects, ...inScopes];
46
+ logger_1.debug('> command requires scopes: ' + JSON.stringify(requiredScopes));
47
+ const hasAllScope = requiredScopes.every((scope) => existingScopes.includes(scope));
48
+ if (!tokenObj.temp && !env_1.isCI && !hasAllScope) {
49
+ throw new error_1.default('Re-login required due to missing scopes!!', {
50
+ exit: 0,
51
+ errorId: 'AUTH-2',
52
+ arg: [ansi_colors_1.bold('catalyst login --force')]
53
+ });
54
+ }
55
+ runtime_store_1.default.set('auth_scopes', requiredScopes);
47
56
  runtime_store_1.default.set('user', config_store_1.default.get(`${activeDC}.user`, null));
48
57
  runtime_store_1.default.set('credential', credential_1.default.init(tokenObj.token, tokenObj.temp));
49
58
  };
@@ -18,16 +18,17 @@ const error_1 = __importDefault(require("../error"));
18
18
  const rc_1 = __importDefault(require("../internal/rc"));
19
19
  const runtime_store_1 = __importDefault(require("../runtime-store"));
20
20
  const constants_1 = require("../util_modules/constants");
21
+ const project_1 = __importDefault(require("../util_modules/constants/project"));
21
22
  const js_1 = require("../util_modules/js");
22
23
  const logger_1 = require("../util_modules/logger");
23
24
  const option_1 = require("../util_modules/option");
24
- const project_1 = require("../util_modules/project");
25
+ const project_2 = require("../util_modules/project");
25
26
  exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __awaiter(void 0, void 0, void 0, function* () {
26
27
  const projectOpt = option_1.getGlobalOptionValue('project', null);
27
28
  const projectApi = yield endpoints_1.projectAPI();
28
29
  const envApi = yield endpoints_1.envAPI();
29
30
  const convertProjectToProperties = (project) => {
30
- project = project_1.transformProject(project);
31
+ project = project_2.transformProject(project);
31
32
  runtime_store_1.default.set('project.name', project.name);
32
33
  runtime_store_1.default.set('project.id', project.id + '');
33
34
  runtime_store_1.default.set('project.domain', project.domain);
@@ -39,7 +40,7 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
39
40
  exit: 2
40
41
  });
41
42
  }
42
- runtime_store_1.default.set('project.env', project_1.transformEnv(envObj));
43
+ runtime_store_1.default.set('project.env', project_2.transformEnv(envObj));
43
44
  };
44
45
  let ignoreRC = false;
45
46
  if (projectOpt !== null) {
@@ -60,7 +61,11 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
60
61
  arg: [
61
62
  ansi_colors_1.bold(projectOpt),
62
63
  ansi_colors_1.bold('--project'),
63
- ansi_colors_1.bold(projectArr.map((project) => '* ' + project.project_name).join('\n'))
64
+ ansi_colors_1.bold(projectArr
65
+ .filter((proj) => proj.project_type &&
66
+ project_1.default.accepted_types.includes(proj.project_type))
67
+ .map((project) => '* ' + project.project_name)
68
+ .join('\n'))
64
69
  ]
65
70
  });
66
71
  }
@@ -146,7 +151,7 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
146
151
  logger_1.message('cleaning up ' +
147
152
  constants_1.FILENAME.rc +
148
153
  ' since the current active project for this folder is not found in remote');
149
- yield project_1.removeProject(finalProjectObj.id + '');
154
+ yield project_2.removeProject(finalProjectObj.id + '');
150
155
  if (resolveOnNotFound) {
151
156
  finalProjectObj = undefined;
152
157
  return;
@@ -170,8 +175,8 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
170
175
  exit: 2
171
176
  });
172
177
  }
173
- finalEnvObj = project_1.transformEnv(envObj);
174
- yield project_1.upsertEnv(finalProjectObj.id + '', envObj, {
178
+ finalEnvObj = project_2.transformEnv(envObj);
179
+ yield project_2.upsertEnv(finalProjectObj.id + '', envObj, {
175
180
  active: true,
176
181
  base: js_1.JS.isEmpty(defaultRCEnv)
177
182
  });
@@ -20,7 +20,7 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
20
20
  const constants_1 = require("../../util_modules/constants");
21
21
  const logger_1 = require("../../util_modules/logger");
22
22
  exports.default = new command_1.default('apig:disable')
23
- .description('disable api gateway if not already disabled')
23
+ .description('Disable API Gateway for your project')
24
24
  .needs('auth', [constants_1.SCOPE.projects])
25
25
  .needs('config')
26
26
  .needs('rc')
@@ -20,7 +20,7 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
20
20
  const constants_1 = require("../../util_modules/constants");
21
21
  const logger_1 = require("../../util_modules/logger");
22
22
  exports.default = new command_1.default('apig:enable')
23
- .description('enables api gateway if not already enabled')
23
+ .description('Enable API Gateway for your project')
24
24
  .needs('auth', [constants_1.SCOPE.projects])
25
25
  .needs('config')
26
26
  .needs('rc')
@@ -22,7 +22,7 @@ const constants_1 = require("../../util_modules/constants");
22
22
  const logger_1 = require("../../util_modules/logger");
23
23
  const option_1 = require("../../util_modules/option");
24
24
  exports.default = new command_1.default('apig:status')
25
- .description('Displays the status of catalyst api gateway and schedule progress')
25
+ .description('Obtain the current status of API Gateway for your project and the schedule progress')
26
26
  .option('--previous', 'show previous schedule status instead of current one')
27
27
  .needs('auth', [constants_1.SCOPE.projects])
28
28
  .needs('config')
@@ -46,13 +46,14 @@ exports.default = new command_1.default('apig:status')
46
46
  report = (yield api.getScheduleReport(previousOpt));
47
47
  }
48
48
  catch (e) {
49
- if (e.status && e.status === 404) {
49
+ const err = error_1.default.getErrorInstance(e);
50
+ if (err.status && err.status === 404) {
50
51
  throw new error_1.default('There is no report available.', {
51
52
  exit: 0,
52
53
  errorId: 'STAT-1'
53
54
  });
54
55
  }
55
- throw e;
56
+ throw err;
56
57
  }
57
58
  const spinner = 'API Gateway Upsert';
58
59
  const throbber = throbber_1.default.getInstance();
@@ -192,13 +193,14 @@ exports.default = new command_1.default('apig:status')
192
193
  report = (yield api.getScheduleReport(false));
193
194
  }
194
195
  catch (ex) {
195
- if (ex.status && ex.status === 404) {
196
+ const err = error_1.default.getErrorInstance(ex);
197
+ if (err.status && err.status === 404) {
196
198
  report = (yield api.getScheduleReport(true));
197
199
  }
198
200
  else {
199
201
  throbber.stopAll();
200
202
  needIteration = false;
201
- reject(ex);
203
+ reject(err);
202
204
  }
203
205
  }
204
206
  }
@@ -28,7 +28,7 @@ const logger_1 = require("../../util_modules/logger");
28
28
  const option_1 = require("../../util_modules/option");
29
29
  const project_1 = require("../../util_modules/project");
30
30
  exports.default = new command_1.default('client:delete [client_version]')
31
- .description('Removes the selected version of client')
31
+ .description('Delete a version of the client from the remote console or the local directory')
32
32
  .option('--local', 'removes the client from local machine')
33
33
  .option('--remote', 'removes the selected client from remote console')
34
34
  .needs('auth', [constants_1.SCOPE.webapp])
@@ -87,10 +87,9 @@ exports.default = new command_1.default('client:delete [client_version]')
87
87
  localDel.version = version;
88
88
  }
89
89
  catch (error) {
90
- logger_1.debug('Failed to read ' +
91
- constants_1.FILENAME.client.package_json +
92
- ' Reason: ' +
93
- error.message);
90
+ const err = error_1.default.getErrorInstance(error);
91
+ err.exit = 2;
92
+ logger_1.debug('Failed to read ' + constants_1.FILENAME.client.package_json + ' Reason: ' + err.message);
94
93
  }
95
94
  if (clientVersion !== undefined && clientVersion !== localDel.version) {
96
95
  throw new error_1.default('version unavailable in local', {
@@ -37,7 +37,7 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
37
37
  const constants_1 = require("../../util_modules/constants");
38
38
  const logger_1 = require("../../util_modules/logger");
39
39
  exports.default = new command_1.default('client:setup')
40
- .description('Setup and configure Client files')
40
+ .description('Set up and configure the client directory in your project directory')
41
41
  .needs('auth', [constants_1.SCOPE.webapp])
42
42
  .needs('config')
43
43
  .needs('rc')
@@ -36,7 +36,7 @@ const runtime_store_1 = __importDefault(require("../runtime-store"));
36
36
  const constants_1 = require("../util_modules/constants");
37
37
  const logger_1 = require("../util_modules/logger");
38
38
  exports.default = new command_1.default('deploy')
39
- .description('Deploy your code from working directory to your Catalyst Project')
39
+ .description('Deploy the Catalyst project and project resources to the remote console from the local directory')
40
40
  .option('--only <targets>', 'only deploy specified, comma-separated targets (e.g. "functions,client").' +
41
41
  ' For Functions you can specify which functions to deploy with colon notation' +
42
42
  ' (e.g. "--only functions:<function_name>,functions:<function_name>"). ')
@@ -49,7 +49,9 @@ exports.default = new command_1.default('deploy')
49
49
  const optionFilter = yield Promise.resolve().then(() => __importStar(require('../option-filter')));
50
50
  optionFilter.filterTargets();
51
51
  yield (yield Promise.resolve().then(() => __importStar(require('../deploy')))).default();
52
- const deployTargets = runtime_store_1.default.get('payload.targets', []).filter((deploytarget) => {
52
+ const deployTargets = runtime_store_1.default
53
+ .get('payload.targets', [])
54
+ .filter((deploytarget) => {
53
55
  if (!runtime_store_1.default.get('payload.' + deploytarget + '.deploy', false)) {
54
56
  logger_1.info();
55
57
  logger_1.labeled(deploytarget, 'deploy skipped').ERROR();
@@ -35,7 +35,7 @@ const getReadConfigFromPath = (pth) => __awaiter(void 0, void 0, void 0, functio
35
35
  return configJSON;
36
36
  });
37
37
  exports.default = new command_1.default('ds:export [table]')
38
- .description('Read bulk data from table in catalyst datastore')
38
+ .description('Bulk read records from a table in the Catalyst Data Store')
39
39
  .option('--table <name|id>', 'Name or ID of the table from which data is to be read (eg. "UserDetails")')
40
40
  .option('--config <path>', 'Path of the configuration json file to be used for export.')
41
41
  .option('--page <page>', 'Number which denotes the range of rows to be fetched (eg. "1")')
@@ -69,7 +69,9 @@ exports.default = new command_1.default('ds:export [table]')
69
69
  const allGlobalOpts = runtime_store_1.default.get('opts.globalOpts', {});
70
70
  const optsArr = Object.keys(allGlobalOpts).reduce((arr, key) => {
71
71
  arr.push('--' + key);
72
- arr.push(allGlobalOpts[key]);
72
+ if (allGlobalOpts[key]) {
73
+ arr.push(allGlobalOpts[key]);
74
+ }
73
75
  return arr;
74
76
  }, (env === 'Production' ? ['--production'] : []));
75
77
  shell_1.spawn('catalyst', ['ds:status', 'export', readResponse.job_id + '', ...optsArr], {
@@ -36,7 +36,7 @@ const getWriteConfigFromPath = (pth) => __awaiter(void 0, void 0, void 0, functi
36
36
  return configJSON;
37
37
  });
38
38
  exports.default = new command_1.default('ds:import [file]')
39
- .description('Write bulk data to table in catalyst datastore')
39
+ .description('Bulk write records to a table in the Catalyst Data Store')
40
40
  .option('--table <name|id>', 'Name or ID of the table to which data to be written (e.g. "UserDetails")')
41
41
  .option('--config <path>', 'Path of the configuration json file to be used for import.')
42
42
  .option('--production', 'flag for pointing to production environment')
@@ -82,7 +82,9 @@ exports.default = new command_1.default('ds:import [file]')
82
82
  const allGlobalOpts = runtime_store_1.default.get('opts.globalOpts', {});
83
83
  const optsArr = Object.keys(allGlobalOpts).reduce((arr, key) => {
84
84
  arr.push('--' + key);
85
- arr.push(allGlobalOpts[key]);
85
+ if (allGlobalOpts[key]) {
86
+ arr.push(allGlobalOpts[key]);
87
+ }
86
88
  return arr;
87
89
  }, (env === 'Production' ? ['--production'] : []));
88
90
  shell_1.spawn('catalyst', ['ds:status', 'import', writeResponse.job_id + '', ...optsArr], {
@@ -24,8 +24,151 @@ const constants_1 = require("../../util_modules/constants");
24
24
  const fs_1 = require("../../util_modules/fs");
25
25
  const logger_1 = require("../../util_modules/logger");
26
26
  const option_1 = require("../../util_modules/option");
27
+ const getSpinnerTxt = (mainTable, finalReport) => {
28
+ var _a, _b, _c, _d;
29
+ const spaceRpt = ' '.repeat(35);
30
+ let spinnerTxt = '\n' + spaceRpt;
31
+ spinnerTxt += mainTable
32
+ .toString()
33
+ .split('\n')
34
+ .join('\n' + spaceRpt);
35
+ spinnerTxt += '\n';
36
+ if (finalReport === undefined) {
37
+ return spinnerTxt;
38
+ }
39
+ if (finalReport.status === 'Completed') {
40
+ spinnerTxt += ansi_colors_1.green(((_a = finalReport.results) === null || _a === void 0 ? void 0 : _a.description) + '');
41
+ if (((_b = finalReport.results) === null || _b === void 0 ? void 0 : _b.download_url) !== undefined) {
42
+ spinnerTxt += '\n';
43
+ spinnerTxt += ansi_colors_1.bold(`Download URL : ${(_c = finalReport.results) === null || _c === void 0 ? void 0 : _c.download_url}`);
44
+ }
45
+ }
46
+ else {
47
+ spinnerTxt += ansi_colors_1.red(ansi_colors_1.bold('Reason : ') + ((_d = finalReport.results) === null || _d === void 0 ? void 0 : _d.description));
48
+ }
49
+ return spinnerTxt;
50
+ };
51
+ const spinnerFn = (jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi, displayOpr, action) => (resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
52
+ if (jobId === undefined) {
53
+ reject('Job Id cannot be empty!');
54
+ return;
55
+ }
56
+ let needIteration = true;
57
+ const reportTable = new cli_table_1.default();
58
+ Object.keys(cumulativeStatus).forEach((table) => {
59
+ const initialCount = reportTable.length;
60
+ let tableRowCount = reportTable.length;
61
+ ['insert', 'update', 'upsert', 'read'].forEach((statusAct) => {
62
+ const operationObj = cumulativeStatus[table][statusAct];
63
+ if (operationObj !== null && operationObj !== undefined) {
64
+ let operationRowCount = 0;
65
+ if (operationObj.rows_processed !== undefined &&
66
+ operationObj.rows_processed >= 0) {
67
+ reportTable[tableRowCount++] = [
68
+ 'Processed',
69
+ operationObj.rows_processed + ''
70
+ ];
71
+ operationRowCount++;
72
+ }
73
+ if (operationObj.fail_count !== undefined && operationObj.fail_count >= 0) {
74
+ reportTable[tableRowCount++] = ['Failure', operationObj.fail_count + ''];
75
+ operationRowCount++;
76
+ }
77
+ if (operationRowCount > 0) {
78
+ reportTable[tableRowCount - operationRowCount].unshift({
79
+ hAlign: 'center',
80
+ vAlign: 'center',
81
+ rowSpan: operationRowCount,
82
+ content: statusAct.toUpperCase()
83
+ });
84
+ }
85
+ }
86
+ });
87
+ if (tableRowCount > 0) {
88
+ reportTable[initialCount].unshift({
89
+ hAlign: 'center',
90
+ vAlign: 'center',
91
+ rowSpan: tableRowCount,
92
+ content: ansi_colors_1.cyan.bold(table)
93
+ });
94
+ }
95
+ });
96
+ switch (dsReport.status) {
97
+ case 'In-Progress':
98
+ if (reportTable.length === 0) {
99
+ reportTable.unshift([
100
+ { hAlign: 'center', content: ansi_colors_1.yellow.bold('Yet to start') }
101
+ ]);
102
+ }
103
+ else {
104
+ reportTable.unshift([
105
+ {
106
+ hAlign: 'center',
107
+ colSpan: 4,
108
+ content: ansi_colors_1.cyan.bold('In-Progress')
109
+ }
110
+ ]);
111
+ }
112
+ break;
113
+ case 'Completed':
114
+ reportTable.unshift([
115
+ {
116
+ hAlign: 'center',
117
+ colSpan: 4,
118
+ content: ansi_colors_1.green.bold(displayOpr + ' Job Completed')
119
+ }
120
+ ]);
121
+ dsReport = (yield bulkApi.getReport(action, jobId));
122
+ throbber.succeed(spinner, {
123
+ text: getSpinnerTxt(reportTable, dsReport)
124
+ });
125
+ needIteration = false;
126
+ resolve();
127
+ break;
128
+ case 'Failed':
129
+ reportTable.unshift([
130
+ {
131
+ hAlign: 'center',
132
+ content: ansi_colors_1.red.bold(displayOpr + ' Job Failed!')
133
+ }
134
+ ]);
135
+ dsReport = (yield bulkApi.getReport(action, jobId));
136
+ throbber.fail(spinner, {
137
+ text: getSpinnerTxt(reportTable, dsReport)
138
+ });
139
+ needIteration = false;
140
+ resolve();
141
+ break;
142
+ default:
143
+ needIteration = false;
144
+ reject(new error_1.default('unknown state received', { exit: 2 }));
145
+ break;
146
+ }
147
+ if (dsReport.status === 'In-Progress') {
148
+ throbber.update(spinner, {
149
+ text: getSpinnerTxt(reportTable) + 'Press CTRL + C to exit listening to the status'
150
+ });
151
+ try {
152
+ cumulativeStatus = (yield bulkApi.getStatus(action, jobId));
153
+ if (Object.keys(cumulativeStatus).length === 0) {
154
+ dsReport = (yield bulkApi.getReport(action, jobId));
155
+ if (dsReport.status === 'Completed') {
156
+ cumulativeStatus = (yield bulkApi.getStatus(action, jobId, true));
157
+ }
158
+ }
159
+ }
160
+ catch (ex) {
161
+ throbber.stopAll();
162
+ needIteration = false;
163
+ reject(ex);
164
+ }
165
+ }
166
+ if (needIteration) {
167
+ setTimeout(() => spinnerFn(jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi, displayOpr, action)(resolve, reject), 2000);
168
+ }
169
+ });
27
170
  exports.default = new command_1.default('ds:status <operation> [jobid]')
28
- .description('Displays the status of catalyst datastore bulk schedule progress')
171
+ .description('Display the job status of a Data Store import or export operation')
29
172
  .option('--production', 'flag for pointing to production environment.')
30
173
  .needs('auth', [constants_1.SCOPE.projects, constants_1.SCOPE.datastore, constants_1.SCOPE.row])
31
174
  .needs('config')
@@ -70,7 +213,7 @@ exports.default = new command_1.default('ds:status <operation> [jobid]')
70
213
  if (jobId === undefined) {
71
214
  throw new error_1.default('Job ID is empty!', { exit: 2 });
72
215
  }
73
- let dsReport = (yield bulkApi.getReport(action, jobId).catch((err) => {
216
+ const dsReport = (yield bulkApi.getReport(action, jobId).catch((err) => {
74
217
  if (err.status === 404) {
75
218
  throw new error_1.default('No jobs found for the given id', {
76
219
  exit: 1,
@@ -88,154 +231,7 @@ exports.default = new command_1.default('ds:status <operation> [jobid]')
88
231
  const spinner = 'DS bulk ' + operation;
89
232
  const throbber = throbber_1.default.getInstance();
90
233
  throbber.add(spinner);
91
- const getSpinnerTxt = (mainTable, finalReport) => {
92
- var _a, _b, _c, _d;
93
- const spaceRpt = ' '.repeat(35);
94
- let spinnerTxt = '\n' + spaceRpt;
95
- spinnerTxt += mainTable
96
- .toString()
97
- .split('\n')
98
- .join('\n' + spaceRpt);
99
- spinnerTxt += '\n';
100
- if (finalReport === undefined) {
101
- return spinnerTxt;
102
- }
103
- if (finalReport.status === 'Completed') {
104
- spinnerTxt += ansi_colors_1.green(((_a = finalReport.results) === null || _a === void 0 ? void 0 : _a.description) + '');
105
- if (((_b = finalReport.results) === null || _b === void 0 ? void 0 : _b.download_url) !== undefined) {
106
- spinnerTxt += '\n';
107
- spinnerTxt += ansi_colors_1.bold(`Download URL : ${(_c = finalReport.results) === null || _c === void 0 ? void 0 : _c.download_url}`);
108
- }
109
- }
110
- else {
111
- spinnerTxt += ansi_colors_1.red(ansi_colors_1.bold('Reason : ') + ((_d = finalReport.results) === null || _d === void 0 ? void 0 : _d.description));
112
- }
113
- return spinnerTxt;
114
- };
115
- const spinnerFn = (resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
116
- if (jobId === undefined) {
117
- reject('Job Id cannot be empty!');
118
- return;
119
- }
120
- let needIteration = true;
121
- const reportTable = new cli_table_1.default();
122
- Object.keys(cumulativeStatus).forEach((table) => {
123
- const initialCount = reportTable.length;
124
- let tableRowCount = reportTable.length;
125
- ['insert', 'update', 'upsert', 'read'].forEach((statusAct) => {
126
- const operationObj = cumulativeStatus[table][statusAct];
127
- if (operationObj !== null && operationObj !== undefined) {
128
- let operationRowCount = 0;
129
- if (operationObj.rows_processed !== undefined &&
130
- operationObj.rows_processed >= 0) {
131
- reportTable[tableRowCount++] = [
132
- 'Processed',
133
- operationObj.rows_processed + ''
134
- ];
135
- operationRowCount++;
136
- }
137
- if (operationObj.fail_count !== undefined && operationObj.fail_count >= 0) {
138
- reportTable[tableRowCount++] = [
139
- 'Failure',
140
- operationObj.fail_count + ''
141
- ];
142
- operationRowCount++;
143
- }
144
- if (operationRowCount > 0) {
145
- reportTable[tableRowCount - operationRowCount].unshift({
146
- hAlign: 'center',
147
- vAlign: 'center',
148
- rowSpan: operationRowCount,
149
- content: statusAct.toUpperCase()
150
- });
151
- }
152
- }
153
- });
154
- if (tableRowCount > 0) {
155
- reportTable[initialCount].unshift({
156
- hAlign: 'center',
157
- vAlign: 'center',
158
- rowSpan: tableRowCount,
159
- content: ansi_colors_1.cyan.bold(table)
160
- });
161
- }
162
- });
163
- switch (dsReport.status) {
164
- case 'In-Progress':
165
- if (reportTable.length === 0) {
166
- reportTable.unshift([
167
- { hAlign: 'center', content: ansi_colors_1.yellow.bold('Yet to start') }
168
- ]);
169
- }
170
- else {
171
- reportTable.unshift([
172
- {
173
- hAlign: 'center',
174
- colSpan: 4,
175
- content: ansi_colors_1.cyan.bold('In-Progress')
176
- }
177
- ]);
178
- }
179
- break;
180
- case 'Completed':
181
- reportTable.unshift([
182
- {
183
- hAlign: 'center',
184
- colSpan: 4,
185
- content: ansi_colors_1.green.bold(displayOpr + ' Job Completed')
186
- }
187
- ]);
188
- dsReport = (yield bulkApi.getReport(action, jobId));
189
- throbber.succeed(spinner, {
190
- text: getSpinnerTxt(reportTable, dsReport)
191
- });
192
- needIteration = false;
193
- resolve();
194
- break;
195
- case 'Failed':
196
- reportTable.unshift([
197
- {
198
- hAlign: 'center',
199
- content: ansi_colors_1.red.bold(displayOpr + ' Job Failed!')
200
- }
201
- ]);
202
- dsReport = (yield bulkApi.getReport(action, jobId));
203
- throbber.fail(spinner, {
204
- text: getSpinnerTxt(reportTable, dsReport)
205
- });
206
- needIteration = false;
207
- resolve();
208
- break;
209
- default:
210
- needIteration = false;
211
- reject(new error_1.default('unknown state received', { exit: 2 }));
212
- break;
213
- }
214
- if (dsReport.status === 'In-Progress') {
215
- throbber.update(spinner, {
216
- text: getSpinnerTxt(reportTable) +
217
- 'Press CTRL + C to exit listening to the status'
218
- });
219
- try {
220
- cumulativeStatus = (yield bulkApi.getStatus(action, jobId));
221
- if (Object.keys(cumulativeStatus).length === 0) {
222
- dsReport = (yield bulkApi.getReport(action, jobId));
223
- if (dsReport.status === 'Completed') {
224
- cumulativeStatus = (yield bulkApi.getStatus(action, jobId, true));
225
- }
226
- }
227
- }
228
- catch (ex) {
229
- throbber.stopAll();
230
- needIteration = false;
231
- reject(ex);
232
- }
233
- }
234
- if (needIteration) {
235
- setTimeout(() => spinnerFn(resolve, reject), 2000);
236
- }
237
- });
238
- yield new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () { return spinnerFn(resolve, reject); }));
234
+ yield new Promise(spinnerFn(jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi, displayOpr, action));
239
235
  if (dsReport.results && dsReport.results.download_url) {
240
236
  const ans = yield prompt_1.default.ask(prompt_1.default.question('download', 'Do you like to download the report of this job to your cmd execution directory?', { type: 'confirm', defaultAns: false }));
241
237
  if (ans.download) {
@@ -42,21 +42,15 @@ const option_1 = require("../../../util_modules/option");
42
42
  const project_1 = require("../../../util_modules/project");
43
43
  exports.default = new command_1.default('event:generate <source> <action>')
44
44
  .alias('generate:event')
45
- .description('Generate sample payloads from different event sources of catalyst')
45
+ .description('Generate sample payloads from different components or custom event sources to test Event functions')
46
46
  .option('-rid, --rule-id <rule_identifier>', 'rule_identifier that will be used if the source is custom')
47
47
  .option('-e, --event-bus <event_bus_name>', 'event bus name that should be used')
48
48
  .allowUnknownOpts()
49
49
  .needs('rc')
50
50
  .needs('auth')
51
51
  .action(function generate(source, action) {
52
- var _a;
53
52
  return __awaiter(this, void 0, void 0, function* () {
54
- const args = (_a = this.client) === null || _a === void 0 ? void 0 : _a.cli.parseOptions(process.argv);
55
- let unknownArgs = args.unknown;
56
- if (unknownArgs === undefined) {
57
- logger_1.debug('No unknownArgs supplied');
58
- unknownArgs = [];
59
- }
53
+ const unknownArgs = option_1.getUnknownOpts([]);
60
54
  if (unknownArgs.length % 2 !== 0) {
61
55
  throw new error_1.default('Unknown options are not provided as key value pairs', {
62
56
  exit: 1,
@@ -89,8 +83,8 @@ exports.default = new command_1.default('event:generate <source> <action>')
89
83
  if (currentIndex % 2 === 0) {
90
84
  if (!currentValue.startsWith('--') &&
91
85
  currentValue !== '-e' &&
92
- currentValue !== '-rid') {
93
- const knownArgs = args.operands.slice(2).join(' ');
86
+ currentValue !== '-rid' &&
87
+ currentValue !== '--verbose') {
94
88
  const fault = unknownArgs === null || unknownArgs === void 0 ? void 0 : unknownArgs.map((arg) => {
95
89
  if (arg === currentValue) {
96
90
  return ansi_colors_1.red(arg);
@@ -100,10 +94,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
100
94
  throw new error_1.default('Invalid option format detected', {
101
95
  exit: 1,
102
96
  errorId: 'IDX-3',
103
- arg: [
104
- ansi_colors_1.bold('[catalyst ' + knownArgs + ' ' + fault + ']'),
105
- ansi_colors_1.bold('--<option> <value>')
106
- ]
97
+ arg: [ansi_colors_1.italic(fault), ansi_colors_1.bold('--<option> <value>')]
107
98
  });
108
99
  }
109
100
  previousValue[currentValue.slice(2)] = optionArr[currentIndex + 1];
@@ -37,7 +37,7 @@ const command_1 = __importDefault(require("../../../internal/command"));
37
37
  const constants_1 = require("../../../util_modules/constants");
38
38
  const option_1 = require("../../../util_modules/option");
39
39
  exports.default = new command_1.default('event:generate:integ <service>')
40
- .description('Generate sample payload for testing your integration functions in local')
40
+ .description('Generate sample payloads for the required integration service to test Integration functions')
41
41
  .option('--inputs <inputs>', 'inputs to generate the integ event provided as comma seperated values')
42
42
  .needs('rc')
43
43
  .needs('auth')
@@ -37,7 +37,7 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
37
37
  const constants_1 = require("../../util_modules/constants");
38
38
  const logger_1 = require("../../util_modules/logger");
39
39
  exports.default = new command_1.default('functions:add')
40
- .description('Add single function of desirable stack to catalyst functions')
40
+ .description('Add a function of the required stack to the function directory')
41
41
  .needs('auth', [constants_1.SCOPE.functions])
42
42
  .needs('config')
43
43
  .needs('rc')
@@ -20,7 +20,7 @@ const ansi_colors_1 = require("ansi-colors");
20
20
  const prompt_1 = __importDefault(require("../../prompt"));
21
21
  const common_1 = require("../../fn-utils/lib/common");
22
22
  exports.default = new command_1.default('functions:config [function_name_or_id]')
23
- .description('Configure the resources for the functions deployed to the Catalyst remote console')
23
+ .description('Perform advanced configurations such as memory allocation on a function in your project')
24
24
  .option('--memory <value>', 'use this option to configure the memory for the function. ex: --memory 128')
25
25
  .needs('auth', [constants_1.SCOPE.functions])
26
26
  .needs('config')
@@ -26,7 +26,7 @@ const logger_1 = require("../../util_modules/logger");
26
26
  const option_1 = require("../../util_modules/option");
27
27
  const project_1 = require("../../util_modules/project");
28
28
  exports.default = new command_1.default('functions:delete [function_name_or_id]')
29
- .description('Removes the selected functions')
29
+ .description('Delete a function from the remote console or the local directory')
30
30
  .option('--local', 'delete the functions in local machine.')
31
31
  .option('--remote', 'delete the functions in remote console.')
32
32
  .needs('auth', [constants_1.SCOPE.projects])