zcatalyst-cli 1.18.0-beta.0 → 1.18.0-beta.2

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 (129) hide show
  1. package/docs/command_needs/rc.toml +8 -8
  2. package/docs/commands/event/generate/job.toml +7 -0
  3. package/docs/endpoints/lib/job-scheduling.toml +3 -0
  4. package/docs/internal/command.toml +5 -0
  5. package/lib/appsail-utils.js +4 -10
  6. package/lib/authentication/index.js +1 -0
  7. package/lib/bin/catalyst.js +1 -1
  8. package/lib/command_needs/rc.js +8 -8
  9. package/lib/commands/appsail/add.js +2 -1
  10. package/lib/commands/client/setup.js +2 -1
  11. package/lib/commands/codelib/install.js +5 -2
  12. package/lib/commands/event/generate/index.js +2 -1
  13. package/lib/commands/event/generate/integ.js +2 -1
  14. package/lib/commands/event/generate/job.js +82 -0
  15. package/lib/commands/functions/add.js +2 -1
  16. package/lib/commands/functions/delete.js +2 -4
  17. package/lib/commands/functions/setup.js +2 -1
  18. package/lib/commands/functions/shell.js +1 -0
  19. package/lib/commands/index.js +3 -1
  20. package/lib/commands/init.js +10 -7
  21. package/lib/commands/login.js +1 -0
  22. package/lib/commands/logout.js +1 -0
  23. package/lib/commands/pull.js +1 -0
  24. package/lib/commands/serve.js +1 -1
  25. package/lib/commands/whoami.js +1 -0
  26. package/lib/deploy/features/appsail/index.js +42 -25
  27. package/lib/deploy/features/appsail/utils.js +4 -5
  28. package/lib/endpoints/index.js +10 -3
  29. package/lib/endpoints/lib/appsail.js +7 -1
  30. package/lib/endpoints/lib/job-scheduling.js +61 -0
  31. package/lib/express_middlewares/logger.js +2 -4
  32. package/lib/fn-utils/lib/common.js +2 -3
  33. package/lib/fn-utils/lib/java.js +1 -1
  34. package/lib/fn-utils/lib/python.js +2 -2
  35. package/lib/fn-watcher.js +1 -1
  36. package/lib/init/dependencies/python/ensure-python.js +6 -8
  37. package/lib/init/features/appsail/index.js +36 -26
  38. package/lib/init/features/client/index.js +2 -1
  39. package/lib/init/features/functions/index.js +4 -0
  40. package/lib/init/features/functions/languages/python.js +21 -5
  41. package/lib/init/features/project.js +5 -15
  42. package/lib/internal/api.js +25 -6
  43. package/lib/internal/command.js +30 -6
  44. package/lib/migration/index.js +4 -2
  45. package/lib/optional-import.js +3 -2
  46. package/lib/prompt/types/file-path.js +1 -1
  47. package/lib/prompt/types/tree.js +3 -3
  48. package/lib/serve/features/appsail.js +2 -3
  49. package/lib/serve/index.js +1 -2
  50. package/lib/serve/server/index.js +8 -9
  51. package/lib/serve/server/lib/appsail/index.js +29 -35
  52. package/lib/serve/server/lib/java/aio_server/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  53. package/lib/serve/server/lib/java/aio_server/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  54. package/lib/serve/server/lib/java/aio_server/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  55. package/lib/serve/server/lib/java/index.js +2 -2
  56. package/lib/serve/server/lib/master/appsail.js +53 -0
  57. package/lib/serve/server/lib/master/functions.js +34 -0
  58. package/lib/serve/server/lib/master/index.js +155 -0
  59. package/lib/{express_middlewares/unknownReqProxy.js → serve/server/lib/master/unknown-req-proxy.js} +4 -7
  60. package/lib/serve/server/lib/master/utils.js +130 -0
  61. package/lib/serve/server/lib/master/web-client.js +39 -0
  62. package/lib/serve/server/lib/node/index.js +3 -3
  63. package/lib/serve/server/lib/python/index.js +3 -3
  64. package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  65. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
  66. package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  67. package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +2 -1
  68. package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  69. package/lib/shell/dependencies/invoker/event/node.mjs +1 -0
  70. package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +14 -0
  71. package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  72. package/lib/shell/dependencies/invoker/integ/node.mjs +13 -0
  73. package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +268 -0
  74. package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  75. package/lib/shell/dependencies/invoker/job/java/lib/org.json.jar +0 -0
  76. package/lib/shell/dependencies/invoker/job/node.mjs +93 -0
  77. package/lib/shell/dependencies/local-function.js +121 -13
  78. package/lib/shell/index.js +7 -1
  79. package/lib/shell/prepare/languages/index.js +4 -4
  80. package/lib/shell/prepare/languages/java.js +1 -2
  81. package/lib/shell/prepare/languages/python.js +10 -16
  82. package/lib/throbber/index.js +6 -1
  83. package/lib/userConfig.js +7 -1
  84. package/lib/util_modules/config/index.js +1 -1
  85. package/lib/util_modules/config/lib/{appSail.js → appsail.js} +60 -10
  86. package/lib/util_modules/config/lib/client.js +6 -8
  87. package/lib/util_modules/config/lib/functions.js +6 -8
  88. package/lib/util_modules/constants/lib/default.js +9 -9
  89. package/lib/util_modules/constants/lib/fn-type.js +2 -1
  90. package/lib/util_modules/constants/lib/needed-scopes.js +53 -44
  91. package/lib/util_modules/constants/lib/placeholders.js +6 -0
  92. package/lib/util_modules/constants/lib/ref-mapping.js +2 -1
  93. package/lib/util_modules/constants/lib/remote-mapping.js +2 -1
  94. package/lib/util_modules/constants/lib/scopes.js +5 -1
  95. package/lib/util_modules/constants/lib/template.js +9 -4
  96. package/lib/util_modules/constants/lib/urls.js +8 -0
  97. package/lib/util_modules/fs/lib/async.js +14 -4
  98. package/lib/util_modules/fs/lib/sync.js +12 -1
  99. package/lib/util_modules/server.js +2 -4
  100. package/lib/winston.js +17 -11
  101. package/package.json +1 -1
  102. package/templates/event/job.json +30 -0
  103. package/templates/init/functions/java/job/.classpath +6 -0
  104. package/templates/init/functions/java/job/.project +17 -0
  105. package/templates/init/functions/java/job/catalyst-config.json +11 -0
  106. package/templates/init/functions/java/job/sample.java +34 -0
  107. package/templates/init/functions/node/aio/package.json +1 -1
  108. package/templates/init/functions/node/aio/sample.js +7 -0
  109. package/templates/init/functions/node/bio/package.json +1 -1
  110. package/templates/init/functions/node/bio/sample.js +5 -0
  111. package/templates/init/functions/node/bio/types/basicio.d.ts +57 -0
  112. package/templates/init/functions/node/cron/package.json +1 -1
  113. package/templates/init/functions/node/cron/sample.js +5 -0
  114. package/templates/init/functions/node/cron/types/cron.d.ts +64 -0
  115. package/templates/init/functions/node/event/package.json +1 -1
  116. package/templates/init/functions/node/event/sample.js +11 -8
  117. package/templates/init/functions/node/event/types/event.d.ts +82 -0
  118. package/templates/init/functions/node/integ/cliq/package.json +1 -1
  119. package/templates/init/functions/node/integ/convokraft/package.json +1 -1
  120. package/templates/init/functions/node/{stream → job}/catalyst-config.json +3 -2
  121. package/templates/init/functions/node/{stream → job}/package.json +1 -1
  122. package/templates/init/functions/node/job/sample.js +27 -0
  123. package/templates/init/functions/node/job/types/job.d.ts +62 -0
  124. package/templates/init/functions/python/job/catalyst-config.json +11 -0
  125. package/templates/init/functions/python/job/requirements.txt +1 -0
  126. package/templates/init/functions/python/job/sample.py +22 -0
  127. package/templates/init.txt +13 -0
  128. package/lib/serve/server/lib/master.js +0 -326
  129. package/templates/init/functions/node/stream/sample.js +0 -15
@@ -1,7 +1,7 @@
1
1
  [RC-1]
2
2
  context = '''The project(${arg[0]}) provided with the ${arg[1]} option is not available is not available in the ${arg[3]} org.'''
3
3
  aid = '''Please use one of the available projects with the ${arg[1]} option or specify the correct org \nThe available projects in the ${arg[3]} org are: \n${arg[2]}'''
4
- link = 'https://www.zoho.com/catalyst/help/cli-options.html#Project'
4
+ link = 'https://docs.catalyst.zoho.com/en/cli/v1/initialize-resources/initialize-new-project/'
5
5
 
6
6
  [RC-2]
7
7
  context = '''Unable to load the ${arg[0]} file.'''
@@ -10,18 +10,18 @@ link = ''
10
10
 
11
11
  [RC-3]
12
12
  context = '''Oops!!! It looks like you're not inside a Catalyst app directory because we are unable to locate the ${arg[0]} file.'''
13
- aid = '''Please run the ${arg[1]} command to initialise or specify a valid project with the ${arg[2]} option.'''
14
- link = 'https://www.zoho.com/catalyst/help/cli-init.html#Initialize_All'
13
+ aid = '''Please run the ${arg[1]} command to initialize or specify a valid project with the ${arg[2]} option.'''
14
+ link = 'https://docs.catalyst.zoho.com/en/cli/v1/initialize-resources/introduction/#Initialize_Alll'
15
15
 
16
16
  [RC-4]
17
17
  context = '''The ${arg[0]} file is corrupted.'''
18
- aid = '''Please delete the ${arg[0]} file in the Catalyst app directory and initialise the project with the ${arg[1]} command or \nSpecify a valid project with the ${arg[2]} option.'''
19
- link = 'https://www.zoho.com/catalyst/help/cli-init.html#Options'
18
+ aid = '''Please delete the ${arg[0]} file in the Catalyst app directory and initialize the project with the ${arg[1]} command or \nSpecify a valid project with the ${arg[2]} option.'''
19
+ link = 'https://docs.catalyst.zoho.com/en/cli/v1/initialize-resources/initialize-options/#--force'
20
20
 
21
21
  [RC-5]
22
- context = '''The project which is currently active doesn't seems to be present in Catalyst remote console.'''
23
- aid = '''Use the ${arg[0]} command in order to change the existing active project.'''
24
- link = 'https://www.zoho.com/catalyst/help/cli-projects.html#Use'
22
+ context = '''Oops!!! It looks like you don't have access to the currently initialized project ${arg[0]}.'''
23
+ aid = '''Please contact the owner or an administrator of the project.\nIf you would like to initialize a new project for this directory, please use the below command\n${arg[1]}'''
24
+ link = 'https://docs.catalyst.zoho.com/en/cli/v1/initialize-resources/initialize-options/#--force'
25
25
 
26
26
  [RC-6]
27
27
  context = '''The Catalyst portal initialized in the current project directory is not accessible with the currently logged in user.\n
@@ -0,0 +1,7 @@
1
+ [JOB-1]
2
+ context = '''No Jobpools were present in the development environment for project ${arg[0]}'''
3
+ aid = '''Please visit the below link to create your first jobpool\n${arg[1]}'''
4
+
5
+ [JOB-2]
6
+ context = '''No function Jobpools were present in the development environment for project ${arg[0]}'''
7
+ aid = '''Please visit the below link to create a functions jobpool\n${arg[1]}'''
@@ -0,0 +1,3 @@
1
+ [JOB-SCHEDULING-1]
2
+ context = '''The Jobpool ${arg[0]} is not available in the Catalyst Development environment'''
3
+ aid = '''Please select from one of the Jobpools listed below:\n${arg[1]}'''
@@ -2,3 +2,8 @@
2
2
  context = '''Too many arguments specified with the command: ${arg[0]}.'''
3
3
  aid = '''Use ${arg[1]} command to get the usage instructions.'''
4
4
  link = 'https://www.zoho.com/catalyst/help/cli-help.html'
5
+
6
+ [CMD-2]
7
+ context = '''The command ${arg[0]} provided is not supported in CI enviroment.'''
8
+ aid = '''Use '${arg[1]}' to know the commands supported in CI.'''
9
+ link = ''
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getDomainPrefix = exports.validateAppSail = exports.filterTargets = void 0;
6
+ exports.validateAppSail = exports.filterTargets = void 0;
7
7
  const ansi_colors_1 = require("ansi-colors");
8
8
  const error_1 = __importDefault(require("./error"));
9
9
  const constants_1 = require("./util_modules/constants");
10
10
  const logger_1 = require("./util_modules/logger");
11
11
  const option_1 = require("./util_modules/option");
12
- const project_1 = require("./util_modules/project");
13
12
  function getAppSailFilters(targetStr) {
14
13
  return targetStr.split(',').reduce((filterArr, target) => {
15
14
  const opts = target.split(':');
@@ -28,7 +27,7 @@ function filterTargets(allTargets) {
28
27
  return allTargets;
29
28
  }
30
29
  const refined = onlyTargs.reduce((filtered, filter) => {
31
- const targDetailsIdx = allTargets.findIndex((targ) => { var _a; return ((_a = targ.appSail) === null || _a === void 0 ? void 0 : _a.name) === filter; });
30
+ const targDetailsIdx = allTargets.findIndex((targ) => targ.name === filter);
32
31
  if (targDetailsIdx === -1) {
33
32
  filtered.unmatched.push(filter);
34
33
  }
@@ -50,7 +49,7 @@ function filterTargets(allTargets) {
50
49
  if (except !== undefined) {
51
50
  const exceptTargs = getAppSailFilters(except);
52
51
  const refined = exceptTargs.reduce((filtered, filter) => {
53
- const targDetailsIdx = allTargets.findIndex((targ) => { var _a; return ((_a = targ.appSail) === null || _a === void 0 ? void 0 : _a.name) === filter; });
52
+ const targDetailsIdx = allTargets.findIndex((targ) => targ.name === filter);
54
53
  if (targDetailsIdx === -1) {
55
54
  filtered.unmatched.push(filter);
56
55
  }
@@ -73,7 +72,7 @@ exports.filterTargets = filterTargets;
73
72
  function validateAppSail(targDetails) {
74
73
  targDetails.forEach((targ) => {
75
74
  var _a, _b;
76
- if (targ.validity.valid && ((_a = targ.appSail) === null || _a === void 0 ? void 0 : _a.platform) !== 'war' && !((_b = targ.appSail) === null || _b === void 0 ? void 0 : _b.command)) {
75
+ if (targ.validity.valid && ((_a = targ.config) === null || _a === void 0 ? void 0 : _a.platform) !== 'war' && !((_b = targ.config) === null || _b === void 0 ? void 0 : _b.command)) {
77
76
  targ.validity = {
78
77
  valid: false,
79
78
  reason: 'Start-up command missing'
@@ -83,8 +82,3 @@ function validateAppSail(targDetails) {
83
82
  return targDetails;
84
83
  }
85
84
  exports.validateAppSail = validateAppSail;
86
- function getDomainPrefix(targetDetail) {
87
- var _a;
88
- return `${(_a = targetDetail.appSail) === null || _a === void 0 ? void 0 : _a.name}-${(0, project_1.getDomainKey)()}.development`;
89
- }
90
- exports.getDomainPrefix = getDomainPrefix;
@@ -113,6 +113,7 @@ function login() {
113
113
  const token = config_store_1.default.get(`${activeDC}.credential`);
114
114
  if (user && token && !(0, option_1.getOptionValue)('force', false)) {
115
115
  (0, logger_1.message)('No need to login. Already logged as: ' + ansi_colors_1.default.cyan.bold(user.Email));
116
+ (0, dc_1.updateActiveDC)(activeDC);
116
117
  return;
117
118
  }
118
119
  const ans = yield prompt_1.default.ask(prompt_1.default.question('collectUsage', 'Allow Catalyst to collect CLI error reporting information?', {
@@ -44,7 +44,7 @@ const errorOut_1 = __importDefault(require("../errorOut"));
44
44
  (0, logger_1.debug)(js_1.JS.repeat('-', 70));
45
45
  (0, logger_1.debug)();
46
46
  process.on('beforeExit', (code) => __awaiter(void 0, void 0, void 0, function* () {
47
- code = process.exitCode || code;
47
+ code = Number(process.exitCode) || code;
48
48
  if (code > 0 && process.stdout.isTTY) {
49
49
  const lastError = config_store_1.default.get('lastError', 0);
50
50
  const timestamp = Date.now();
@@ -33,7 +33,7 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
33
33
  const globProjectOpt = (0, option_1.getGlobalOptionValue)('project', null);
34
34
  const projectOpt = globProjectOpt
35
35
  ? globProjectOpt
36
- : (0, env_1.getEnvVariable)('CATALYST_PROJECT', null);
36
+ : (0, env_1.getEnvVariable)('CATALYST_PROJECT_ID', (0, env_1.getEnvVariable)('CATALYST_PROJECT', null));
37
37
  const orgApi = yield (0, endpoints_1.orgAPI)();
38
38
  if (orgOpt !== null) {
39
39
  const orgList = yield orgApi.getAllOrgs();
@@ -192,7 +192,7 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
192
192
  });
193
193
  }
194
194
  if (typeof finalEnvObj !== 'undefined') {
195
- projectApi = yield (0, endpoints_1.projectAPI)({ auth: true, org: finalEnvObj.id });
195
+ projectApi = yield (0, endpoints_1.projectAPI)({ auth: true, org: finalEnvObj.id, printError: false });
196
196
  envApi = yield (0, endpoints_1.envAPI)({ auth: true, org: finalEnvObj.id });
197
197
  }
198
198
  const projectDetails = yield projectApi
@@ -200,19 +200,19 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
200
200
  .catch((err) => __awaiter(void 0, void 0, void 0, function* () {
201
201
  if (js_1.JS.hasIn(err, 'context.response.statusCode')) {
202
202
  switch (err.context.response.statusCode) {
203
+ case 401:
203
204
  case 404: {
204
- (0, logger_1.message)('cleaning up ' +
205
- constants_1.FILENAME.rc +
206
- ' since the current active project for this folder is not found in remote');
207
- yield (0, project_2.removeProject)(finalProjectObj.id + '');
208
205
  if (resolveOnNotFound) {
209
206
  finalProjectObj = undefined;
210
207
  return;
211
208
  }
212
- throw new error_1.default('active project not found in remote', {
209
+ throw new error_1.default('no access to project: ' + (finalProjectObj === null || finalProjectObj === void 0 ? void 0 : finalProjectObj.id), {
213
210
  exit: 1,
214
211
  errorId: 'RC-5',
215
- arg: [(0, ansi_colors_1.bold)('catalyst project:use')]
212
+ arg: [
213
+ (0, ansi_colors_1.bold)(`${finalProjectObj === null || finalProjectObj === void 0 ? void 0 : finalProjectObj.name}(${finalProjectObj === null || finalProjectObj === void 0 ? void 0 : finalProjectObj.id})`),
214
+ (0, ansi_colors_1.bold)((0, ansi_colors_1.cyan)('command: ') + 'catalyst init --force')
215
+ ]
216
216
  });
217
217
  }
218
218
  case 403: {
@@ -43,8 +43,9 @@ const logger_1 = require("../../util_modules/logger");
43
43
  exports.default = new command_1.default('appsail:add')
44
44
  .description('Link an already existing AppSail service to Catalyst Project')
45
45
  .needs('auth', [constants_1.SCOPE.functions])
46
- .needs('config')
46
+ .needs('config', { optional: true })
47
47
  .needs('rc')
48
+ .ci(false)
48
49
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
49
50
  const config = runtime_store_1.default.get('config');
50
51
  yield (yield Promise.resolve().then(() => __importStar(require('../../init/features')))).appsail();
@@ -43,8 +43,9 @@ const logger_1 = require("../../util_modules/logger");
43
43
  exports.default = new command_1.default('client:setup')
44
44
  .description('Set up and configure the client directory in your project directory')
45
45
  .needs('auth', [constants_1.SCOPE.webapp])
46
- .needs('config')
46
+ .needs('config', { optional: true })
47
47
  .needs('rc')
48
+ .ci(false)
48
49
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
49
50
  const config = runtime_store_1.default.get('config');
50
51
  yield (yield Promise.resolve().then(() => __importStar(require('../../init/features')))).client();
@@ -32,7 +32,7 @@ exports.default = new command_1.default('codelib:install [git-url]')
32
32
  .description('Install the code library functionalities into your project')
33
33
  .option('-c, --continue <install-id>', 'Continue CodeLib install')
34
34
  .needs('auth', [constants_1.SCOPE.project_import_create])
35
- .needs('config')
35
+ .needs('config', { optional: true })
36
36
  .needs('rc')
37
37
  .action((gitUrl) => __awaiter(void 0, void 0, void 0, function* () {
38
38
  var _a;
@@ -72,7 +72,10 @@ exports.default = new command_1.default('codelib:install [git-url]')
72
72
  if (!gitUrl) {
73
73
  throw new error_1.default('Invalid code lib', { exit: 2 });
74
74
  }
75
- return;
75
+ throw new error_1.default(`Error while downloading codelib.`, {
76
+ exit: 2,
77
+ original: `Occurred while processing ${gitUrl}`
78
+ });
76
79
  }
77
80
  const templateFile = yield (0, code_deck_1.getTemplateFile)(deckZip);
78
81
  const templateJson = JSON.parse(templateFile || '');
@@ -54,6 +54,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
54
54
  .needs('auth')
55
55
  .action(function generate(source, action) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
+ var _a;
57
58
  const unknownArgs = (0, option_1.getUnknownOpts)([]);
58
59
  if (unknownArgs.length % 2 !== 0) {
59
60
  throw new error_1.default('Unknown options are not provided as key value pairs', {
@@ -175,7 +176,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
175
176
  break;
176
177
  }
177
178
  });
178
- const sourceModule = (yield Promise.resolve().then(() => __importStar(require('../../../event_generate/' + source)))).default;
179
+ const sourceModule = (yield (_a = '../../../event_generate/' + source, Promise.resolve().then(() => __importStar(require(_a))))).default;
179
180
  eventJsonContent = yield sourceModule(eventJsonContent, optionMap, action);
180
181
  const jsonContent = JSON.parse(eventJsonContent);
181
182
  Object.keys(jsonContent).forEach((key) => {
@@ -46,6 +46,7 @@ exports.default = new command_1.default('event:generate:integ <service>')
46
46
  .needs('rc')
47
47
  .needs('auth')
48
48
  .action((service) => __awaiter(void 0, void 0, void 0, function* () {
49
+ var _a;
49
50
  const availableServices = Object.keys(constants_1.INTEG.service_map);
50
51
  if (!availableServices.includes(service)) {
51
52
  throw new error_1.default('Unknown service requested', {
@@ -56,7 +57,7 @@ exports.default = new command_1.default('event:generate:integ <service>')
56
57
  }
57
58
  const inputs = (0, option_1.getOptionValue)('inputs', '');
58
59
  const serviceValue = constants_1.INTEG.service_map[service];
59
- const serviceModule = (yield Promise.resolve().then(() => __importStar(require(`../../../event_generate/integration/${serviceValue}`))))
60
+ const serviceModule = (yield (_a = `../../../event_generate/integration/${serviceValue}`, Promise.resolve().then(() => __importStar(require(_a)))))
60
61
  .default;
61
62
  const payload = yield serviceModule(inputs);
62
63
  process.stdout.write(payload + '\n');
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const ansi_colors_1 = require("ansi-colors");
16
+ const endpoints_1 = require("../../../endpoints");
17
+ const error_1 = __importDefault(require("../../../error"));
18
+ const command_1 = __importDefault(require("../../../internal/command"));
19
+ const prompt_1 = __importDefault(require("../../../prompt"));
20
+ const constants_1 = require("../../../util_modules/constants");
21
+ const fs_1 = require("../../../util_modules/fs");
22
+ const project_1 = require("../../../util_modules/project");
23
+ exports.default = new command_1.default('event:generate:job [jobpool_id]')
24
+ .description('Generate sample payloads for job functions')
25
+ .needs('rc')
26
+ .needs('auth')
27
+ .action((jobpoolId) => __awaiter(void 0, void 0, void 0, function* () {
28
+ if (!fs_1.ASYNC.fileExists(constants_1.TEMPLATE.job_data)) {
29
+ throw new error_1.default('Could not read request template', { exit: 2 });
30
+ }
31
+ const jobData = yield fs_1.ASYNC.readFile(constants_1.TEMPLATE.job_data);
32
+ const jobDataJson = JSON.parse(jobData || '');
33
+ const jobpoolAPI = yield (0, endpoints_1.jobScheduling)();
34
+ const jobpoolDetails = jobpoolId
35
+ ? yield jobpoolAPI.getJobpoolDetails(jobpoolId)
36
+ : yield (() => __awaiter(void 0, void 0, void 0, function* () {
37
+ const allJobpoolDetails = yield jobpoolAPI.getJobpoolDetails();
38
+ if (allJobpoolDetails.length === 0) {
39
+ throw new error_1.default('No jobpool present in development environment', {
40
+ exit: 1,
41
+ errorId: 'JOB-1',
42
+ arg: [
43
+ (0, ansi_colors_1.bold)(`${(0, project_1.getProjectName)()} (${(0, project_1.getProjectId)()})`),
44
+ ansi_colors_1.italic.underline(`${constants_1.ORIGIN.console}/baas/${(0, project_1.getEnvId)()}/project/${(0, project_1.getProjectId)()}/Development#/jobscheduling/jobpool`)
45
+ ]
46
+ });
47
+ }
48
+ const jobpoolChoices = allJobpoolDetails.reduce((poolChoices, _pool) => {
49
+ if (_pool.type !== 'Function') {
50
+ return poolChoices;
51
+ }
52
+ poolChoices.push(prompt_1.default.choice(`${_pool.name} [${_pool.id}]`, {
53
+ value: _pool,
54
+ short: _pool.name
55
+ }));
56
+ return poolChoices;
57
+ }, []);
58
+ if (jobpoolChoices.length === 0) {
59
+ throw new error_1.default('No valid function jobpool available in the development environment', {
60
+ exit: 1,
61
+ errorId: 'JOB-2',
62
+ arg: [
63
+ (0, ansi_colors_1.bold)(`${(0, project_1.getProjectName)()} (${(0, project_1.getProjectId)()})`),
64
+ ansi_colors_1.italic.underline(`${constants_1.ORIGIN.console}/baas/${(0, project_1.getEnvId)()}/project/${(0, project_1.getProjectId)()}/Development#/jobscheduling/jobpool`)
65
+ ]
66
+ });
67
+ }
68
+ const jobpoolQuestion = yield prompt_1.default.ask(prompt_1.default.question('details', "Please choose one of the function jobpool's to generate the data", {
69
+ type: 'list',
70
+ choices: jobpoolChoices
71
+ }));
72
+ return jobpoolQuestion.details;
73
+ }))();
74
+ if (jobpoolDetails.type !== 'Function') {
75
+ throw new error_1.default(`The jobpool ${jobpoolId || jobpoolDetails.name || jobpoolDetails.id} is not a function jobpool`, {
76
+ exit: 1
77
+ });
78
+ }
79
+ jobDataJson.job_details.job_meta_details.jobpool_id = jobpoolDetails.id;
80
+ jobDataJson.job_details.job_meta_details.jobpool_details = jobpoolDetails;
81
+ process.stdout.write(JSON.stringify(jobDataJson, null, ' ') + '\n');
82
+ }));
@@ -43,8 +43,9 @@ const logger_1 = require("../../util_modules/logger");
43
43
  exports.default = new command_1.default('functions:add')
44
44
  .description('Add a function of the required stack to the function directory')
45
45
  .needs('auth', [constants_1.SCOPE.functions])
46
- .needs('config')
46
+ .needs('config', { optional: true })
47
47
  .needs('rc')
48
+ .ci(false)
48
49
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
49
50
  const config = runtime_store_1.default.get('config');
50
51
  yield (yield Promise.resolve().then(() => __importStar(require('../../init/features')))).functions(true);
@@ -199,10 +199,8 @@ exports.default = new command_1.default('functions:delete [function_name_or_id]'
199
199
  if (fn.location === remote && fn.id !== undefined) {
200
200
  return fnApi.delete(fn.id + '');
201
201
  }
202
- else {
203
- if (fn.source) {
204
- return (0, common_1.deleteFunctionLocal)(fn.source);
205
- }
202
+ if (fn.source) {
203
+ return (0, common_1.deleteFunctionLocal)(fn.source);
206
204
  }
207
205
  return;
208
206
  }));
@@ -43,8 +43,9 @@ const logger_1 = require("../../util_modules/logger");
43
43
  exports.default = new command_1.default('functions:setup')
44
44
  .description('Set up and configure the function directory in your project directory')
45
45
  .needs('auth', [constants_1.SCOPE.functions])
46
- .needs('config')
46
+ .needs('config', { optional: true })
47
47
  .needs('rc')
48
+ .ci(false)
48
49
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
49
50
  const config = runtime_store_1.default.get('config');
50
51
  yield (yield Promise.resolve().then(() => __importStar(require('../../init/features')))).functions();
@@ -61,6 +61,7 @@ exports.default = new command_1.default('functions:shell')
61
61
  .needs('auth', constants_1.NEEDED_SCOPES.SERVE)
62
62
  .needs('config')
63
63
  .needs('rc')
64
+ .ci(false)
64
65
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
65
66
  const httpOpt = (0, option_1.getOptionValue)('http', false);
66
67
  if (httpOpt && typeof httpOpt !== 'boolean') {
@@ -36,7 +36,8 @@ exports.default = (client) => {
36
36
  function loadCommand(name) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
38
  return new Promise((resolve, reject) => setTimeout(() => __awaiter(this, void 0, void 0, function* () {
39
- const cmd = (yield Promise.resolve().then(() => __importStar(require('./' + name.split(':').join('/'))))).default;
39
+ var _a;
40
+ const cmd = (yield (_a = './' + name.split(':').join('/'), Promise.resolve().then(() => __importStar(require(_a))))).default;
40
41
  try {
41
42
  cmd.register(client);
42
43
  resolve();
@@ -79,6 +80,7 @@ exports.default = (client) => {
79
80
  loadCommand('codelib:install'),
80
81
  loadCommand('event:generate'),
81
82
  loadCommand('event:generate:integ'),
83
+ loadCommand('event:generate:job'),
82
84
  loadCommand('serve'),
83
85
  loadCommand('deploy'),
84
86
  loadCommand('help'),
@@ -56,14 +56,10 @@ exports.default = new command_1.default('init [feature]')
56
56
  .description('Initialize a Catalyst project, function, and client resources in the local directory')
57
57
  .option('--force', 'force initialise a project for this directory')
58
58
  .ignore(['project'])
59
- .needs('auth', [
60
- constants_1.SCOPE.projects,
61
- constants_1.SCOPE.stratus_create,
62
- constants_1.SCOPE.stratus_read,
63
- constants_1.SCOPE.project_import_create
64
- ])
59
+ .needs('auth', [constants_1.SCOPE.projects, constants_1.SCOPE.project_import_create])
65
60
  .needs('config', { optional: true })
66
61
  .needs('rc', { optional: true, resolveOnNotFound: true })
62
+ .ci(false)
67
63
  .action((feature) => __awaiter(void 0, void 0, void 0, function* () {
68
64
  var _a;
69
65
  const config = runtime_store_1.default.get('config');
@@ -104,8 +100,15 @@ exports.default = new command_1.default('init [feature]')
104
100
  return;
105
101
  }
106
102
  if (feature !== 'project') {
107
- yield (0, features_1.project)();
103
+ try {
104
+ yield (0, features_1.project)();
105
+ }
106
+ catch (er) {
107
+ (0, logger_1.debug)(er);
108
+ return;
109
+ }
108
110
  }
111
+ (0, logger_1.info)();
109
112
  const featureAns = yield prompt_1.default.ask(prompt_1.default.question('features', 'Which are the features you want to setup for this folder?\n This step is optional! Press ' +
110
113
  (0, ansi_colors_1.cyan)('<return> ') +
111
114
  'to proceed.\n', {
@@ -40,6 +40,7 @@ exports.default = new command_1.default('login')
40
40
  .description('Log the CLI in to your Catalyst account')
41
41
  .option('--no-localhost', 'login without browser')
42
42
  .option('--force', 'force reauthentication')
43
+ .ci(false)
43
44
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
44
45
  const auth = yield Promise.resolve().then(() => __importStar(require('../authentication')));
45
46
  return auth.login();
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  const command_1 = __importDefault(require("../internal/command"));
39
39
  exports.default = new command_1.default('logout')
40
40
  .description('Log the CLI out of your Catalyst account')
41
+ .ci(false)
41
42
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
42
43
  const auth = yield Promise.resolve().then(() => __importStar(require('../authentication')));
43
44
  return auth.logout();
@@ -50,6 +50,7 @@ exports.default = new command_1.default('pull [feature]')
50
50
  .needs('auth', [constants_1.SCOPE.functions, constants_1.SCOPE.webapp])
51
51
  .needs('config', { optional: true })
52
52
  .needs('rc')
53
+ .ci(false)
53
54
  .action((feature) => __awaiter(void 0, void 0, void 0, function* () {
54
55
  const config = runtime_store_1.default.get('config');
55
56
  const homeDir = (yield Promise.resolve().then(() => __importStar(require('os')))).homedir();
@@ -47,7 +47,7 @@ exports.default = new command_1.default('serve')
47
47
  .option('--only <targets>', 'only serve specified, comma-separated targets (e.g. "client,functions:f1")')
48
48
  .option('--no-watch', 'disable watching the files for changes')
49
49
  .option('--except <targets>', 'serve all targets except specified (e.g. "client")')
50
- .option('--ignore-scripts', 'ignore the pre and post lifescycle scripts')
50
+ .option('--ignore-scripts', 'ignore the pre and post lifecycle scripts')
51
51
  .option('--no-open', 'disable opening the client automatically when served')
52
52
  .needs('auth', constants_1.NEEDED_SCOPES.SERVE)
53
53
  .needs('config')
@@ -19,6 +19,7 @@ const command_1 = __importDefault(require("../internal/command"));
19
19
  const logger_1 = require("../util_modules/logger");
20
20
  exports.default = new command_1.default('whoami')
21
21
  .description('Print the email address of the user currently logged in')
22
+ .ci(false)
22
23
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
23
24
  const activeDC = (0, dc_1.getActiveDC)();
24
25
  const user = config_store_1.default.get(`${activeDC}.user`);