zcatalyst-cli 1.7.1 → 1.9.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 (179) hide show
  1. package/README.md +31 -10
  2. package/docs/apig-utils.toml +69 -0
  3. package/docs/authentication/index.toml +15 -0
  4. package/docs/authentication/login.toml +14 -0
  5. package/docs/client-utils.toml +24 -0
  6. package/docs/command_needs/auth.toml +4 -0
  7. package/docs/command_needs/rc.toml +24 -0
  8. package/docs/commands/apig/disable.toml +4 -0
  9. package/docs/commands/apig/enable.toml +4 -0
  10. package/docs/commands/apig/status.toml +4 -0
  11. package/docs/commands/client/delete.toml +34 -0
  12. package/docs/commands/ds/export.toml +4 -0
  13. package/docs/commands/ds/import.toml +15 -0
  14. package/docs/commands/ds/status.toml +9 -0
  15. package/docs/commands/event/generate/index.toml +29 -0
  16. package/docs/commands/event/generate/integ.toml +4 -0
  17. package/docs/commands/functions/config.toml +11 -0
  18. package/docs/commands/functions/delete.toml +29 -0
  19. package/docs/commands/project/use.toml +9 -0
  20. package/docs/dc.toml +4 -0
  21. package/docs/deploy/features/apig.toml +4 -0
  22. package/docs/deploy/features/functions/index.toml +4 -0
  23. package/docs/event_generate/cache.toml +4 -0
  24. package/docs/event_generate/custom.toml +4 -0
  25. package/docs/event_generate/datastore.toml +4 -0
  26. package/docs/event_generate/filestore.toml +4 -0
  27. package/docs/event_generate/integration/cliq.toml +9 -0
  28. package/docs/execute-script.toml +19 -0
  29. package/docs/fn-utils/lib/common.toml +25 -0
  30. package/docs/fn-utils/lib/java.toml +34 -0
  31. package/docs/fn-utils/lib/node.toml +4 -0
  32. package/docs/init/index.toml +4 -0
  33. package/docs/internal/command.toml +4 -0
  34. package/docs/internal/config.toml +9 -0
  35. package/docs/internal/credential.toml +14 -0
  36. package/docs/option-filter.toml +45 -0
  37. package/docs/port-resolver.toml +9 -0
  38. package/docs/pull/index.toml +4 -0
  39. package/docs/serve/index.toml +4 -0
  40. package/docs/shell/index.toml +4 -0
  41. package/docs/util_modules/project.toml +9 -0
  42. package/lib/apig-utils.js +133 -43
  43. package/lib/archiver.js +4 -2
  44. package/lib/authentication/index.js +44 -9
  45. package/lib/authentication/login.js +51 -8
  46. package/lib/bin/catalyst.js +14 -7
  47. package/lib/client-utils.js +47 -14
  48. package/lib/client.js +1 -1
  49. package/lib/command_needs/auth.js +5 -3
  50. package/lib/command_needs/rc.js +35 -13
  51. package/lib/commands/apig/disable.js +8 -3
  52. package/lib/commands/apig/enable.js +8 -3
  53. package/lib/commands/apig/status.js +29 -9
  54. package/lib/commands/client/delete.js +65 -26
  55. package/lib/commands/client/setup.js +2 -2
  56. package/lib/commands/deploy.js +2 -2
  57. package/lib/commands/ds/export.js +16 -8
  58. package/lib/commands/ds/import.js +20 -14
  59. package/lib/commands/ds/status.js +22 -11
  60. package/lib/commands/event/generate/index.js +62 -12
  61. package/lib/commands/event/generate/integ.js +7 -3
  62. package/lib/commands/functions/add.js +2 -2
  63. package/lib/commands/functions/config.js +11 -3
  64. package/lib/commands/functions/delete.js +36 -13
  65. package/lib/commands/functions/setup.js +2 -2
  66. package/lib/commands/functions/shell.js +2 -2
  67. package/lib/commands/help.js +1 -1
  68. package/lib/commands/index.js +2 -3
  69. package/lib/commands/init.js +4 -4
  70. package/lib/commands/login.js +2 -2
  71. package/lib/commands/logout.js +2 -2
  72. package/lib/commands/project/list.js +2 -2
  73. package/lib/commands/project/reset.js +1 -1
  74. package/lib/commands/project/use.js +18 -2
  75. package/lib/commands/pull.js +5 -5
  76. package/lib/commands/run.js +2 -2
  77. package/lib/commands/serve.js +7 -6
  78. package/lib/commands/token/generate.js +2 -2
  79. package/lib/commands/token/list.js +2 -2
  80. package/lib/commands/token/revoke.js +2 -2
  81. package/lib/commands/whoami.js +1 -1
  82. package/lib/dc.js +11 -1
  83. package/lib/deploy/features/apig.js +33 -33
  84. package/lib/deploy/features/client.js +12 -19
  85. package/lib/deploy/features/functions/index.js +14 -4
  86. package/lib/deploy/features/index.js +1 -1
  87. package/lib/deploy/index.js +2 -9
  88. package/lib/endpoints/index.js +5 -2
  89. package/lib/endpoints/lib/apig.js +15 -5
  90. package/lib/endpoints/lib/applogic.js +12 -4
  91. package/lib/endpoints/lib/cache.js +9 -3
  92. package/lib/endpoints/lib/catalyst-details.js +37 -0
  93. package/lib/endpoints/lib/client.js +15 -5
  94. package/lib/endpoints/lib/datastore.js +6 -2
  95. package/lib/endpoints/lib/ds-bulk.js +15 -5
  96. package/lib/endpoints/lib/env.js +3 -1
  97. package/lib/endpoints/lib/event-bus.js +3 -1
  98. package/lib/endpoints/lib/filestore.js +6 -2
  99. package/lib/endpoints/lib/functions.js +12 -4
  100. package/lib/endpoints/lib/project.js +9 -3
  101. package/lib/endpoints/lib/queue.js +9 -3
  102. package/lib/endpoints/lib/sdk.js +3 -1
  103. package/lib/endpoints/lib/zcql.js +3 -1
  104. package/lib/error.js +18 -0
  105. package/lib/errorOut.js +10 -7
  106. package/lib/event_generate/cache.js +9 -1
  107. package/lib/event_generate/custom.js +6 -1
  108. package/lib/event_generate/datastore.js +12 -2
  109. package/lib/event_generate/filestore.js +9 -1
  110. package/lib/event_generate/integration/cliq.js +10 -2
  111. package/lib/execute-script.js +35 -6
  112. package/lib/express_middlewares/unknownReqProxy.js +18 -7
  113. package/lib/fn-utils/index.js +1 -1
  114. package/lib/fn-utils/lib/common.js +95 -17
  115. package/lib/fn-utils/lib/integ.js +4 -3
  116. package/lib/fn-utils/lib/java.js +49 -13
  117. package/lib/fn-utils/lib/node.js +15 -6
  118. package/lib/fn-watcher.js +67 -0
  119. package/lib/index.js +13 -12
  120. package/lib/init/dependencies/package-json.js +3 -1
  121. package/lib/init/features/functions/index.js +41 -29
  122. package/lib/init/features/functions/languages/java.js +5 -4
  123. package/lib/init/features/functions/languages/node.js +6 -5
  124. package/lib/init/features/index.js +8 -4
  125. package/lib/init/index.js +10 -3
  126. package/lib/internal/api.js +9 -9
  127. package/lib/internal/command.js +19 -14
  128. package/lib/internal/config.js +15 -15
  129. package/lib/internal/credential.js +33 -7
  130. package/lib/internal/rc.js +18 -10
  131. package/lib/migration/global/1.4.0.js +4 -2
  132. package/lib/migration/global/1.6.2.js +4 -2
  133. package/lib/migration/index.js +1 -1
  134. package/lib/option-filter.js +79 -22
  135. package/lib/optional-import.js +1 -1
  136. package/lib/plugin-loader.js +1 -1
  137. package/lib/port-resolver.js +23 -3
  138. package/lib/prompt.js +1 -1
  139. package/lib/pull/features/functions/index.js +7 -7
  140. package/lib/pull/features/index.js +1 -1
  141. package/lib/pull/index.js +10 -3
  142. package/lib/repl-server.js +9 -5
  143. package/lib/serve/features/index.js +11 -2
  144. package/lib/serve/index.js +19 -9
  145. package/lib/serve/server/index.js +137 -60
  146. package/lib/serve/server/lib/client.js +1 -1
  147. package/lib/serve/server/lib/master.js +16 -3
  148. package/lib/serve/server/lib/node.js +1 -1
  149. package/lib/shell/dependencies/http-functions.js +120 -90
  150. package/lib/shell/dependencies/invoker/integ/node.js +1 -1
  151. package/lib/shell/dependencies/local-function.js +86 -119
  152. package/lib/shell/index.js +10 -10
  153. package/lib/shell/prepare/index.js +1 -4
  154. package/lib/shell/prepare/languages/index.js +15 -4
  155. package/lib/track.js +4 -1
  156. package/lib/util_modules/config/index.js +1 -1
  157. package/lib/util_modules/config/lib/apig.js +3 -3
  158. package/lib/util_modules/config/lib/client.js +3 -3
  159. package/lib/util_modules/config/lib/functions.js +5 -5
  160. package/lib/util_modules/constants/index.js +22 -20
  161. package/lib/util_modules/constants/lib/regex.js +3 -2
  162. package/lib/util_modules/constants/lib/runtime.js +9 -0
  163. package/lib/util_modules/contextHelp.js +63 -123
  164. package/lib/util_modules/fs/index.js +1 -1
  165. package/lib/util_modules/fs/lib/async.js +19 -2
  166. package/lib/util_modules/fs/lib/sync.js +13 -1
  167. package/lib/util_modules/logger.js +12 -20
  168. package/lib/util_modules/option.js +1 -13
  169. package/lib/util_modules/project.js +75 -26
  170. package/lib/util_modules/shell.js +8 -2
  171. package/package.json +45 -45
  172. package/scripts/postInstall.js +31 -0
  173. package/lib/cjson.js +0 -20
  174. package/lib/log-error.js +0 -18
  175. package/lib/util_modules/big-json.js +0 -16
  176. package/lib/util_modules/constants/lib/stack.js +0 -6
  177. package/templates/init/functions/.DS_Store +0 -0
  178. package/templates/init/functions/node/.DS_Store +0 -0
  179. package/templates/init/functions/node/integ/.DS_Store +0 -0
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const path_1 = require("path");
16
- const cjson_1 = __importDefault(require("../../cjson"));
17
16
  const endpoints_1 = require("../../endpoints");
17
+ const error_1 = __importDefault(require("../../error"));
18
18
  const command_1 = __importDefault(require("../../internal/command"));
19
19
  const runtime_store_1 = __importDefault(require("../../runtime-store"));
20
20
  const constants_1 = require("../../util_modules/constants");
@@ -22,8 +22,20 @@ const env_1 = require("../../util_modules/env");
22
22
  const logger_1 = require("../../util_modules/logger");
23
23
  const option_1 = require("../../util_modules/option");
24
24
  const shell_1 = require("../../util_modules/shell");
25
+ const fs_1 = require("../../util_modules/fs");
26
+ const getReadConfigFromPath = (pth) => __awaiter(void 0, void 0, void 0, function* () {
27
+ const configJSON = yield fs_1.ASYNC.readJSONFile(path_1.resolve(pth), {
28
+ checkpath: true,
29
+ throws: false
30
+ });
31
+ if (!configJSON || Object.keys(configJSON).length === 0) {
32
+ logger_1.debug('No parsable export config given');
33
+ return {};
34
+ }
35
+ return configJSON;
36
+ });
25
37
  exports.default = new command_1.default('ds:export [table]')
26
- .description('Read bulk data from table in catalyst datastore')
38
+ .description('Bulk read records from a table in the Catalyst Data Store')
27
39
  .option('--table <name|id>', 'Name or ID of the table from which data is to be read (eg. "UserDetails")')
28
40
  .option('--config <path>', 'Path of the configuration json file to be used for export.')
29
41
  .option('--page <page>', 'Number which denotes the range of rows to be fetched (eg. "1")')
@@ -34,15 +46,11 @@ exports.default = new command_1.default('ds:export [table]')
34
46
  .action((optTable) => __awaiter(void 0, void 0, void 0, function* () {
35
47
  const env = option_1.getOptionValue('production', false) ? 'Production' : 'Development';
36
48
  const configPath = option_1.getOptionValue('config', false);
37
- let exportConfig = {};
38
- if (configPath) {
39
- exportConfig = cjson_1.default(path_1.resolve(configPath));
40
- }
49
+ const exportConfig = configPath ? yield getReadConfigFromPath(configPath) : {};
41
50
  const tableOptId = option_1.getOptionValue('table', exportConfig.table_identifier + '');
42
51
  const tableId = optTable ? optTable : tableOptId;
43
52
  if (!tableId) {
44
- logger_1.error('Kindly provide table identifier in command or config file!');
45
- return;
53
+ throw new error_1.default('table identifier missing', { exit: 0, errorId: 'EXP-1' });
46
54
  }
47
55
  const page = option_1.getOptionValue('page', undefined);
48
56
  if (page !== undefined) {
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const path_1 = require("path");
16
- const cjson_1 = __importDefault(require("../../cjson"));
17
16
  const endpoints_1 = require("../../endpoints");
17
+ const error_1 = __importDefault(require("../../error"));
18
18
  const command_1 = __importDefault(require("../../internal/command"));
19
19
  const prompt_1 = __importDefault(require("../../prompt"));
20
20
  const runtime_store_1 = __importDefault(require("../../runtime-store"));
@@ -24,8 +24,19 @@ const fs_1 = require("../../util_modules/fs");
24
24
  const logger_1 = require("../../util_modules/logger");
25
25
  const option_1 = require("../../util_modules/option");
26
26
  const shell_1 = require("../../util_modules/shell");
27
+ const getWriteConfigFromPath = (pth) => __awaiter(void 0, void 0, void 0, function* () {
28
+ const configJSON = yield fs_1.ASYNC.readJSONFile(path_1.resolve(pth), {
29
+ checkpath: true,
30
+ throws: false
31
+ });
32
+ if (!configJSON || Object.keys(configJSON).length === 0) {
33
+ logger_1.debug('No parsable import config given');
34
+ return {};
35
+ }
36
+ return configJSON;
37
+ });
27
38
  exports.default = new command_1.default('ds:import [file]')
28
- .description('Write bulk data to table in catalyst datastore')
39
+ .description('Bulk write records to a table in the Catalyst Data Store')
29
40
  .option('--table <name|id>', 'Name or ID of the table to which data to be written (e.g. "UserDetails")')
30
41
  .option('--config <path>', 'Path of the configuration json file to be used for import.')
31
42
  .option('--production', 'flag for pointing to production environment')
@@ -35,25 +46,21 @@ exports.default = new command_1.default('ds:import [file]')
35
46
  .action((uploadFile) => __awaiter(void 0, void 0, void 0, function* () {
36
47
  const env = option_1.getOptionValue('production', false) ? 'Production' : 'Development';
37
48
  const configPath = option_1.getOptionValue('config', false);
38
- let importConfig = {};
39
- if (configPath) {
40
- importConfig = cjson_1.default(path_1.resolve(configPath));
41
- }
49
+ const importConfig = configPath ? yield getWriteConfigFromPath(configPath) : {};
42
50
  const tableId = option_1.getOptionValue('table', importConfig.table_identifier + '');
43
51
  if (!tableId) {
44
- logger_1.error('Kindly provide table identifier in command options or config file!');
45
- return;
52
+ throw new error_1.default('Table identifier missing', { exit: 0, errorId: 'IMP-1' });
46
53
  }
47
54
  if (!importConfig.file_id) {
48
55
  if (!uploadFile) {
49
- logger_1.error('Kindly provide a csv file path to proceed!\n' +
50
- 'Alternatively you can provide file_id from filestore in config json.');
51
- return;
56
+ throw new error_1.default('No CSV file provided', { exit: 0, errorId: 'IMP-2' });
52
57
  }
53
58
  const fileAPI = yield endpoints_1.filestoreAPI({ env });
54
59
  const allFolders = (yield fileAPI.getAllFolders());
55
60
  if (allFolders.length > 0) {
56
- const choices = allFolders.map((folderDetail) => prompt_1.default.choice(folderDetail.folder_name, { value: folderDetail.id }));
61
+ const choices = allFolders.map((folderDetail) => prompt_1.default.choice(folderDetail.folder_name, {
62
+ value: folderDetail.id
63
+ }));
57
64
  const folderAns = yield prompt_1.default.ask(prompt_1.default.question('folder', 'Select a folder to which you want to upload the file to : ', {
58
65
  type: 'list',
59
66
  choices
@@ -62,8 +69,7 @@ exports.default = new command_1.default('ds:import [file]')
62
69
  importConfig.file_id = fileDetails.id;
63
70
  }
64
71
  else {
65
- logger_1.error('You need atleast one folder in filestore to proceed!');
66
- return;
72
+ throw new error_1.default('folder needed', { exit: 0, errorId: 'IMP-3' });
67
73
  }
68
74
  }
69
75
  const bulkAPI = yield endpoints_1.bulkDSAPI({ env });
@@ -25,7 +25,7 @@ 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
27
  exports.default = new command_1.default('ds:status <operation> [jobid]')
28
- .description('Displays the status of catalyst datastore bulk schedule progress')
28
+ .description('Display the job status of a Data Store import or export operation')
29
29
  .option('--production', 'flag for pointing to production environment.')
30
30
  .needs('auth', [constants_1.SCOPE.projects, constants_1.SCOPE.datastore, constants_1.SCOPE.row])
31
31
  .needs('config')
@@ -38,8 +38,11 @@ exports.default = new command_1.default('ds:status <operation> [jobid]')
38
38
  if (jobId === undefined) {
39
39
  const jobsList = (yield bulkApi.getAllJobs(action));
40
40
  if (jobsList === undefined || jobsList.length === 0) {
41
- logger_1.error(`No Jobs are available! In order to create one use ${ansi_colors_1.bold('ds:import or ds:export')} command.`);
42
- return;
41
+ throw new error_1.default('No jobs available', {
42
+ exit: 0,
43
+ errorId: 'STAT-1',
44
+ arg: [ansi_colors_1.bold('ds:import or ds:export')]
45
+ });
43
46
  }
44
47
  const listTable = new cli_table_1.default();
45
48
  listTable.push(['Job ID', 'Table Name', 'Created Time', 'Created By', 'Status']);
@@ -65,14 +68,18 @@ exports.default = new command_1.default('ds:status <operation> [jobid]')
65
68
  jobId = jobAns.job;
66
69
  }
67
70
  if (jobId === undefined) {
68
- logger_1.error('Job ID cannot be empty!');
69
- return;
70
- }
71
- let dsReport = (yield bulkApi.getReport(action, jobId));
72
- if (!dsReport.status) {
73
- logger_1.error('There is no job running with this jobid ' + jobId);
74
- return;
71
+ throw new error_1.default('Job ID is empty!', { exit: 2 });
75
72
  }
73
+ let dsReport = (yield bulkApi.getReport(action, jobId).catch((err) => {
74
+ if (err.status === 404) {
75
+ throw new error_1.default('No jobs found for the given id', {
76
+ exit: 1,
77
+ errorId: 'STAT-2',
78
+ arg: [ansi_colors_1.bold(jobId), ansi_colors_1.bold('catalyst ds:status ' + operation)]
79
+ });
80
+ }
81
+ throw err;
82
+ }));
76
83
  let cumulativeStatus;
77
84
  cumulativeStatus = (yield bulkApi.getStatus(action, jobId));
78
85
  if (Object.keys(cumulativeStatus).length === 0) {
@@ -162,7 +169,11 @@ exports.default = new command_1.default('ds:status <operation> [jobid]')
162
169
  }
163
170
  else {
164
171
  reportTable.unshift([
165
- { hAlign: 'center', colSpan: 4, content: ansi_colors_1.cyan.bold('In-Progress') }
172
+ {
173
+ hAlign: 'center',
174
+ colSpan: 4,
175
+ content: ansi_colors_1.cyan.bold('In-Progress')
176
+ }
166
177
  ]);
167
178
  }
168
179
  break;
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -31,6 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
31
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
32
32
  };
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
+ const ansi_colors_1 = require("ansi-colors");
34
35
  const endpoints_1 = require("../../../endpoints");
35
36
  const error_1 = __importDefault(require("../../../error"));
36
37
  const command_1 = __importDefault(require("../../../internal/command"));
@@ -41,7 +42,7 @@ const option_1 = require("../../../util_modules/option");
41
42
  const project_1 = require("../../../util_modules/project");
42
43
  exports.default = new command_1.default('event:generate <source> <action>')
43
44
  .alias('generate:event')
44
- .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')
45
46
  .option('-rid, --rule-id <rule_identifier>', 'rule_identifier that will be used if the source is custom')
46
47
  .option('-e, --event-bus <event_bus_name>', 'event bus name that should be used')
47
48
  .allowUnknownOpts()
@@ -50,17 +51,30 @@ exports.default = new command_1.default('event:generate <source> <action>')
50
51
  .action(function generate(source, action) {
51
52
  var _a;
52
53
  return __awaiter(this, void 0, void 0, function* () {
53
- let unknownArgs = (_a = this.client) === null || _a === void 0 ? void 0 : _a.cli.parseOptions(process.argv).unknown;
54
+ const args = (_a = this.client) === null || _a === void 0 ? void 0 : _a.cli.parseOptions(process.argv);
55
+ let unknownArgs = args.unknown;
54
56
  if (unknownArgs === undefined) {
55
57
  logger_1.debug('No unknownArgs supplied');
56
58
  unknownArgs = [];
57
59
  }
58
60
  if (unknownArgs.length % 2 !== 0) {
59
- throw new error_1.default(`The options provided for ${source} ${action} is not in pairs. All options should contain key and value.`, { exit: 1 });
61
+ throw new error_1.default('Unknown options are not provided as key value pairs', {
62
+ exit: 1,
63
+ errorId: 'IDX-1',
64
+ arg: [ansi_colors_1.bold(source), ansi_colors_1.bold(action), ansi_colors_1.bold('--key value')]
65
+ });
60
66
  }
61
67
  const remoteSourceName = constants_1.EVENT_SOURCE[source];
62
68
  if (remoteSourceName === undefined) {
63
- throw new error_1.default('source must be one of ' + Object.keys(constants_1.EVENT_SOURCE).join(','), { exit: 1 });
69
+ throw new error_1.default('Invalid source', {
70
+ exit: 1,
71
+ errorId: 'IDX-2',
72
+ arg: [
73
+ ansi_colors_1.bold(Object.keys(constants_1.EVENT_SOURCE)
74
+ .map((src) => '* ' + src)
75
+ .join('\n'))
76
+ ]
77
+ });
64
78
  }
65
79
  if (constants_1.EVENT_REF[remoteSourceName] === undefined) {
66
80
  throw new error_1.default('Event reference is not found for the source provided', {
@@ -73,8 +87,24 @@ exports.default = new command_1.default('event:generate <source> <action>')
73
87
  }
74
88
  const optionMap = unknownArgs.reduce((previousValue, currentValue, currentIndex, optionArr) => {
75
89
  if (currentIndex % 2 === 0) {
76
- if (!currentValue.startsWith('--')) {
77
- throw new error_1.default('The options should be given in --<option> <value> format', { exit: 1 });
90
+ if (!currentValue.startsWith('--') &&
91
+ currentValue !== '-e' &&
92
+ currentValue !== '-rid') {
93
+ const knownArgs = args.operands.slice(2).join(' ');
94
+ const fault = unknownArgs === null || unknownArgs === void 0 ? void 0 : unknownArgs.map((arg) => {
95
+ if (arg === currentValue) {
96
+ return ansi_colors_1.red(arg);
97
+ }
98
+ return arg;
99
+ }).join(' ');
100
+ throw new error_1.default('Invalid option format detected', {
101
+ exit: 1,
102
+ errorId: 'IDX-3',
103
+ arg: [
104
+ ansi_colors_1.bold('[catalyst ' + knownArgs + ' ' + fault + ']'),
105
+ ansi_colors_1.bold('--<option> <value>')
106
+ ]
107
+ });
78
108
  }
79
109
  previousValue[currentValue.slice(2)] = optionArr[currentIndex + 1];
80
110
  }
@@ -85,12 +115,25 @@ exports.default = new command_1.default('event:generate <source> <action>')
85
115
  eventBusName = constants_1.DEFAULT.event_bus.name;
86
116
  }
87
117
  if (remoteSourceName === constants_1.EVENT_SOURCE.custom && eventBusName === constants_1.DEFAULT.event_bus.name) {
88
- throw new error_1.default('Event Bus Name is mandatory for custom source. Kindly use option -e or --event-bus to provide a bus name.', { exit: 1 });
118
+ throw new error_1.default('Event bus details not provided', {
119
+ exit: 0,
120
+ errorId: 'IDX-4',
121
+ arg: [ansi_colors_1.bold('-e or --event-bus')]
122
+ });
89
123
  }
90
124
  const remoteEventBusDetails = (yield (yield endpoints_1.eventBusAPI()).getAllEventBusDetails());
91
125
  const currentEventBusDetails = remoteEventBusDetails.filter((eventBus) => eventBus.name === eventBusName)[0];
92
126
  if (currentEventBusDetails === undefined) {
93
- throw new error_1.default(`no matching event bus details found for event bus name : ${eventBusName} found`, { exit: 1 });
127
+ const availableBuses = remoteEventBusDetails
128
+ .map((bus) => {
129
+ return '* ' + bus.name;
130
+ })
131
+ .join('\n');
132
+ throw new error_1.default('No matching event bus details found', {
133
+ exit: 1,
134
+ errorId: 'IDX-5',
135
+ arg: [ansi_colors_1.bold(eventBusName), ansi_colors_1.bold(availableBuses)]
136
+ });
94
137
  }
95
138
  const eventDataPlaceHolder = constants_1.PLACEHOLDER.event_data;
96
139
  Object.keys(eventDataPlaceHolder).forEach((placeholderKey) => {
@@ -114,9 +157,16 @@ exports.default = new command_1.default('event:generate <source> <action>')
114
157
  logger_1.debug(`action provided is : ${remoteRefAction}`);
115
158
  const indexOfAction = eventRefArr.indexOf(remoteRefAction);
116
159
  if (indexOfAction < 0) {
117
- throw new error_1.default(`The event action ${action} provided is not compatible with the source ${source}.` +
118
- ' The proper actions are ' +
119
- eventRefArr, { exit: 1 });
160
+ throw new error_1.default('Action incompatible with the source ' + eventRefArr, {
161
+ exit: 1,
162
+ errorId: 'IDX-6',
163
+ arg: [
164
+ ansi_colors_1.bold(action),
165
+ ansi_colors_1.bold.red('X'),
166
+ ansi_colors_1.bold(source),
167
+ ansi_colors_1.bold(eventRefArr.map((act) => '* ' + act).join('\n'))
168
+ ]
169
+ });
120
170
  }
121
171
  eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), eventRefArr[indexOfAction]);
122
172
  break;
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -37,14 +37,18 @@ 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('Genereate 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')
44
44
  .action((service) => __awaiter(void 0, void 0, void 0, function* () {
45
45
  const availableServices = Object.keys(constants_1.INTEG.service_map);
46
46
  if (!availableServices.includes(service)) {
47
- throw new error_1.default(`Unknown service requested, the services available are ${ansi_colors_1.bold(availableServices.join(','))}`);
47
+ throw new error_1.default('Unknown service requested', {
48
+ exit: 1,
49
+ errorId: 'INTEG-1',
50
+ arg: [ansi_colors_1.bold(availableServices.map((service) => '* ' + service).join('\n'))]
51
+ });
48
52
  }
49
53
  const inputs = option_1.getOptionValue('inputs', '');
50
54
  const serviceValue = constants_1.INTEG.service_map[service];
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -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('Configure the memory allocation of 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')
@@ -30,7 +30,8 @@ exports.default = new command_1.default('functions:config [function_name_or_id]'
30
30
  const allRemoteFn = (yield fnApi.getAllFunctions());
31
31
  if (allRemoteFn.length === 0) {
32
32
  throw new error_1.default('No Functions present in the Catalyst remote console', {
33
- exit: 1
33
+ exit: 0,
34
+ errorId: 'CONF-1'
34
35
  });
35
36
  }
36
37
  let remoteTarget = undefined;
@@ -50,7 +51,14 @@ exports.default = new command_1.default('functions:config [function_name_or_id]'
50
51
  ? allRemoteFn.find((fn) => fn.id + '' === targetFn)
51
52
  : allRemoteFn.find((fn) => fn.name === targetFn);
52
53
  if (remoteTarget === undefined) {
53
- throw new error_1.default(`The function ${ansi_colors_1.bold(targetFn + '')} is not found in the Catalyst remote console`, { exit: 1 });
54
+ throw new error_1.default('function not present in remote console', {
55
+ exit: 1,
56
+ errorId: 'CONF-2',
57
+ arg: [
58
+ ansi_colors_1.bold(targetFn),
59
+ ansi_colors_1.bold(allRemoteFn.map((fn) => `* ${fn.name} (${fn.id})`).join('\n'))
60
+ ]
61
+ });
54
62
  }
55
63
  }
56
64
  return common_1.updateFnConfig(remoteTarget);
@@ -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('This command lets you to delete the functions from local machine and remote console.')
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])
@@ -40,7 +40,11 @@ exports.default = new command_1.default('functions:delete [function_name_or_id]'
40
40
  let remoteOpt = option_1.getOptionValue('remote', false);
41
41
  const choiceArr = [];
42
42
  if (localOpt && remoteOpt) {
43
- throw new error_1.default('Cannot specify both --local and --remote options in the same command');
43
+ throw new error_1.default('local and remote opts specified in the same command', {
44
+ exit: 1,
45
+ errorId: 'FDEL-1',
46
+ arg: [ansi_colors_1.bold('--local'), ansi_colors_1.bold('--remote')]
47
+ });
44
48
  }
45
49
  if (!localOpt && !remoteOpt) {
46
50
  const locationAns = yield prompt_1.default.ask(prompt_1.default.question('location', 'Choose a location to get more information', {
@@ -66,17 +70,25 @@ exports.default = new command_1.default('functions:delete [function_name_or_id]'
66
70
  if (localOpt) {
67
71
  let target = config_1.functionsConfig.targets([]);
68
72
  if (target.length === 0) {
69
- logger_1.error('No targets found for function in Local machine');
70
- return;
73
+ throw new error_1.default('No targets found in local', {
74
+ exit: 0,
75
+ errorId: 'FDEL-2',
76
+ arg: [ansi_colors_1.bold('catalyst functions:add')]
77
+ });
71
78
  }
72
79
  if (fnTarget !== undefined) {
73
80
  if (!isNaN(parseInt(fnTarget, 10))) {
74
- logger_1.error('Cannot use the Function ID with the functions in local');
75
- return;
81
+ throw new error_1.default('cannot use function Id in local', {
82
+ exit: 1,
83
+ errorId: 'FDEL-3'
84
+ });
76
85
  }
77
86
  if (!target.includes(fnTarget)) {
78
- logger_1.error(`${ansi_colors_1.bold(fnTarget)} is not available in the local machine, check the ${constants_1.FILENAME.config} file.`);
79
- return;
87
+ throw new error_1.default('function not available in local', {
88
+ exit: 1,
89
+ errorId: 'FDEL-4',
90
+ arg: [ansi_colors_1.bold(fnTarget), ansi_colors_1.bold(target.map((tar) => '* ' + tar).join('\n'))]
91
+ });
80
92
  }
81
93
  target = [fnTarget];
82
94
  }
@@ -111,16 +123,27 @@ exports.default = new command_1.default('functions:delete [function_name_or_id]'
111
123
  if (remoteOpt) {
112
124
  let remoteTargets = (yield fnApi.getAllFunctions());
113
125
  if (js_1.JS.isEmpty(remoteTargets)) {
114
- logger_1.error('No targets found for function in Catalyst Remote console');
115
- return;
126
+ throw new error_1.default('No targets found in remote', {
127
+ exit: 0,
128
+ errorId: 'FDEL-5',
129
+ arg: [ansi_colors_1.bold('catalyst deploy')]
130
+ });
116
131
  }
117
132
  if (fnTarget !== undefined) {
118
133
  const target = parseInt(fnTarget, 10)
119
134
  ? remoteTargets.find((fn) => fn.id + '' === fnTarget)
120
135
  : remoteTargets.find((fn) => fn.name === fnTarget);
121
136
  if (target === undefined) {
122
- logger_1.error(`${ansi_colors_1.bold(fnTarget)} is not found in the Catalyst remote console.`);
123
- return;
137
+ throw new error_1.default('Target not found in remote', {
138
+ exit: 1,
139
+ errorId: 'FDEL-6',
140
+ arg: [
141
+ ansi_colors_1.bold(fnTarget),
142
+ ansi_colors_1.bold(remoteTargets
143
+ .map((rTarget) => '* ' + rTarget.name + ' -- ' + rTarget.id)
144
+ .join('\n'))
145
+ ]
146
+ });
124
147
  }
125
148
  remoteTargets = [target];
126
149
  }
@@ -147,7 +170,7 @@ exports.default = new command_1.default('functions:delete [function_name_or_id]'
147
170
  choiceArr.push(...remoteChoices);
148
171
  }
149
172
  if (js_1.JS.isEmpty(choiceArr)) {
150
- throw new error_1.default('No functions available to delete', { exit: 1 });
173
+ throw new error_1.default('No functions available to delete', { exit: 2 });
151
174
  }
152
175
  const fnAns = yield prompt_1.default.ask(prompt_1.default.question('functions', 'Select all the functions needed to be deleted:', {
153
176
  type: 'checkbox',
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -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:setup')
40
- .description('Setup, Configure and deploy function files for catalyst functions')
40
+ .description('Set up the function directory in your project directory')
41
41
  .needs('auth', [constants_1.SCOPE.functions])
42
42
  .needs('config')
43
43
  .needs('rc')
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -36,7 +36,7 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
36
36
  const constants_1 = require("../../util_modules/constants");
37
37
  const option_1 = require("../../util_modules/option");
38
38
  exports.default = new command_1.default('functions:shell')
39
- .description('Launch a node shell with emulated functions for any stack pointing to production or local')
39
+ .description('Launch a node shell to test emulated functions of any stack or type, other than Advanced I/O functions')
40
40
  .option('--http [port]', 'enables http mode for the basicIO functions and start server at specified port' +
41
41
  `(default: ${constants_1.DEFAULT.serve_port.http.basicio})`)
42
42
  .option('--debug [port]', 'the functions are invoked from local environment enabling debugging options on provided port.' +
@@ -11,7 +11,7 @@ const logger_1 = require("../util_modules/logger");
11
11
  const option_1 = require("../util_modules/option");
12
12
  const project_1 = require("../util_modules/project");
13
13
  exports.default = new command_1.default('help [command]')
14
- .description('Display help information')
14
+ .description('Display the command reference or help for a specific command')
15
15
  .action(function help(commandName) {
16
16
  var _a, _b, _c;
17
17
  if (option_1.getOptionValue('info', false)) {
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -34,8 +34,7 @@ exports.default = (client) => {
34
34
  return new Promise((resolve, reject) => setTimeout(() => __awaiter(this, void 0, void 0, function* () {
35
35
  const cmd = (yield Promise.resolve().then(() => __importStar(require('./' + name.split(':').join('/'))))).default;
36
36
  try {
37
- const currentCmd = cmd.register(client);
38
- client.commands[currentCmd._name] = currentCmd.options.map((o) => o.long);
37
+ cmd.register(client);
39
38
  resolve();
40
39
  }
41
40
  catch (e) {
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -32,7 +32,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
32
32
  };
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  const ansi_colors_1 = require("ansi-colors");
35
- const error_1 = __importDefault(require("../error"));
36
35
  const command_1 = __importDefault(require("../internal/command"));
37
36
  const prompt_1 = __importDefault(require("../prompt"));
38
37
  const runtime_store_1 = __importDefault(require("../runtime-store"));
@@ -43,7 +42,7 @@ const js_1 = require("../util_modules/js");
43
42
  const logger_1 = require("../util_modules/logger");
44
43
  const shell_1 = require("../util_modules/shell");
45
44
  exports.default = new command_1.default('init [feature]')
46
- .description('Initialize a Catalyst sample project in the current directory')
45
+ .description('Initialize a Catalyst project, function, and client resources in the local directory')
47
46
  .option('--force', 'force initialise a project for this directory')
48
47
  .ignore(['project'])
49
48
  .needs('auth', [constants_1.SCOPE.projects, constants_1.SCOPE.stratus_create, constants_1.SCOPE.stratus_read])
@@ -84,7 +83,8 @@ exports.default = new command_1.default('init [feature]')
84
83
  }))
85
84
  : { confirmation: true };
86
85
  if (!windownConfirmation.confirmation) {
87
- throw new error_1.default('Aborted by user.', { exit: 1 });
86
+ logger_1.message('Aborted by user.');
87
+ return;
88
88
  }
89
89
  let featureAns;
90
90
  if (typeof feature === 'string') {
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -33,7 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  const command_1 = __importDefault(require("../internal/command"));
35
35
  exports.default = new command_1.default('login')
36
- .description('Log the CLI in to your Zoho Catalyst account')
36
+ .description('Log the CLI in to your Catalyst account')
37
37
  .option('--no-localhost', 'login without browser')
38
38
  .option('--force', 'force reauthentication')
39
39
  .action(() => __awaiter(void 0, void 0, void 0, function* () {