zcatalyst-cli 1.13.3 → 1.14.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 (162) hide show
  1. package/docs/client-utils.toml +6 -1
  2. package/docs/commands/ds/import.toml +5 -0
  3. package/docs/fn-utils/lib/python.toml +4 -0
  4. package/docs/init/dependencies/python/ensure-python.toml +12 -0
  5. package/docs/init/dependencies/python/pip-install.toml +4 -0
  6. package/docs/serve/index.toml +5 -0
  7. package/lib/authentication/login.js +2 -1
  8. package/lib/cli_table/index.js +26 -2
  9. package/lib/cli_table/src/cell.js +359 -267
  10. package/lib/cli_table/src/layout-manager.js +231 -209
  11. package/lib/cli_table/src/table.js +76 -60
  12. package/lib/cli_table/src/utils.js +259 -224
  13. package/lib/client-utils.js +18 -4
  14. package/lib/command_needs/rc.js +57 -8
  15. package/lib/commands/config/delete.js +23 -0
  16. package/lib/commands/config/get.js +23 -0
  17. package/lib/commands/config/list.js +23 -0
  18. package/lib/commands/config/set.js +29 -0
  19. package/lib/commands/console/cache.js +31 -1
  20. package/lib/commands/console/queue.js +31 -1
  21. package/lib/commands/console/zcql.js +27 -1
  22. package/lib/commands/ds/export.js +2 -2
  23. package/lib/commands/ds/import.js +25 -5
  24. package/lib/commands/ds/status.js +2 -2
  25. package/lib/commands/iac/export.js +1 -1
  26. package/lib/commands/iac/import.js +1 -1
  27. package/lib/commands/iac/pack.js +16 -5
  28. package/lib/commands/iac/status.js +1 -1
  29. package/lib/commands/index.js +4 -0
  30. package/lib/commands/project/list.js +1 -1
  31. package/lib/commands/project/use.js +1 -1
  32. package/lib/deploy/features/client.js +2 -2
  33. package/lib/deploy/features/functions/index.js +13 -3
  34. package/lib/deploy/features/functions/languages/index.js +19 -2
  35. package/lib/endpoints/index.js +12 -5
  36. package/lib/endpoints/lib/env.js +5 -2
  37. package/lib/endpoints/lib/functions.js +30 -0
  38. package/lib/endpoints/lib/org.js +35 -0
  39. package/lib/endpoints/lib/project.js +7 -3
  40. package/lib/express_middlewares/unknownReqProxy.js +4 -1
  41. package/lib/fn-utils/index.js +2 -0
  42. package/lib/fn-utils/lib/common.js +68 -7
  43. package/lib/fn-utils/lib/integ.js +15 -11
  44. package/lib/fn-utils/lib/java.js +7 -3
  45. package/lib/fn-utils/lib/python.js +121 -0
  46. package/lib/fn-watcher.js +10 -2
  47. package/lib/index.js +2 -1
  48. package/lib/init/dependencies/python/ensure-python.js +151 -0
  49. package/lib/init/dependencies/python/pip-install.js +189 -0
  50. package/lib/init/features/functions/index.js +50 -29
  51. package/lib/init/features/functions/languages/index.js +3 -1
  52. package/lib/init/features/functions/languages/python.js +115 -0
  53. package/lib/init/features/index.js +2 -2
  54. package/lib/init/features/project.js +26 -6
  55. package/lib/init/util/project.js +2 -2
  56. package/lib/internal/api.js +2 -0
  57. package/lib/internal/command.js +1 -1
  58. package/lib/internal/rc.js +2 -0
  59. package/lib/port-resolver.js +4 -3
  60. package/lib/prompt/types/file-path.js +1 -1
  61. package/lib/pull/features/functions/index.js +35 -2
  62. package/lib/pull/features/functions/languages.js +8 -1
  63. package/lib/readLineUtils.js +37 -1
  64. package/lib/readline/features/cache.js +175 -1
  65. package/lib/readline/features/index.js +7 -1
  66. package/lib/readline/features/queue.js +209 -1
  67. package/lib/readline/features/zcql.js +237 -1
  68. package/lib/readline/index.js +30 -1
  69. package/lib/serve/index.js +48 -7
  70. package/lib/serve/server/index.js +118 -44
  71. package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  72. package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  73. package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  74. package/lib/serve/server/lib/master.js +18 -5
  75. package/lib/serve/server/lib/node.mjs +41 -0
  76. package/lib/serve/server/lib/web_client/index.js +7 -3
  77. package/lib/serve/server/lib/web_client/server.js +31 -15
  78. package/lib/shell/dependencies/http-functions.js +57 -21
  79. package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +1 -2
  80. package/lib/shell/dependencies/invoker/bio/node.mjs +127 -0
  81. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
  82. package/lib/shell/dependencies/invoker/cron/node.mjs +87 -0
  83. package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +3 -3
  84. package/lib/shell/dependencies/invoker/event/node.mjs +84 -0
  85. package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +1 -1
  86. package/lib/shell/dependencies/invoker/integ/node.mjs +88 -0
  87. package/lib/shell/dependencies/local-function.js +74 -22
  88. package/lib/shell/index.js +11 -2
  89. package/lib/shell/prepare/index.js +21 -0
  90. package/lib/shell/prepare/languages/index.js +8 -2
  91. package/lib/shell/prepare/languages/java.js +39 -2
  92. package/lib/shell/prepare/languages/node.js +21 -2
  93. package/lib/shell/prepare/languages/python.js +65 -0
  94. package/lib/throbber/index.js +3 -1
  95. package/lib/userConfig.js +48 -0
  96. package/lib/util_modules/constants/index.js +3 -1
  97. package/lib/util_modules/constants/lib/apig-rules.js +8 -0
  98. package/lib/util_modules/constants/lib/cliq-handlers.js +17 -1
  99. package/lib/util_modules/constants/lib/dc-type.js +8 -0
  100. package/lib/util_modules/constants/lib/default.js +2 -2
  101. package/lib/util_modules/constants/lib/env-path.js +12 -0
  102. package/lib/util_modules/constants/lib/file-names.js +4 -1
  103. package/lib/util_modules/constants/lib/folder-names.js +3 -1
  104. package/lib/util_modules/constants/lib/placeholders.js +6 -1
  105. package/lib/util_modules/constants/lib/runtime.js +2 -1
  106. package/lib/util_modules/constants/lib/scopes.js +1 -0
  107. package/lib/util_modules/constants/lib/template.js +9 -0
  108. package/lib/util_modules/constants/lib/urls.js +2 -6
  109. package/lib/util_modules/context-help.js +2 -0
  110. package/lib/util_modules/fs/lib/async.js +35 -11
  111. package/lib/util_modules/project.js +20 -1
  112. package/package.json +2 -1
  113. package/templates/init/functions/java/aio/catalyst-config.json +3 -2
  114. package/templates/init/functions/java/bio/catalyst-config.json +3 -2
  115. package/templates/init/functions/java/cron/catalyst-config.json +3 -2
  116. package/templates/init/functions/java/event/catalyst-config.json +3 -2
  117. package/templates/init/functions/java/integ/cliq/catalyst-config.json +1 -0
  118. package/templates/init/functions/node/aio/catalyst-config.json +3 -2
  119. package/templates/init/functions/node/bio/catalyst-config.json +3 -2
  120. package/templates/init/functions/node/cron/catalyst-config.json +3 -2
  121. package/templates/init/functions/node/event/catalyst-config.json +3 -2
  122. package/templates/init/functions/node/integ/cliq/catalyst-config.json +1 -0
  123. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +2 -2
  124. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +1 -2
  125. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +1 -1
  126. package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +1 -1
  127. package/templates/init/functions/node/integ/cliq/handlers/installation-validator.js +1 -1
  128. package/templates/init/functions/node/integ/cliq/handlers/message-action-handler.js +1 -1
  129. package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +1 -1
  130. package/templates/init/functions/node/integ/cliq/sample.js +4 -4
  131. package/templates/init/functions/python/aio/catalyst-config.json +11 -0
  132. package/templates/init/functions/python/aio/requirements.txt +1 -0
  133. package/templates/init/functions/python/aio/sample.py +26 -0
  134. package/templates/init/functions/python/bio/catalyst-config.json +11 -0
  135. package/templates/init/functions/python/bio/requirements.txt +1 -0
  136. package/templates/init/functions/python/bio/sample.py +6 -0
  137. package/templates/init/functions/python/cron/catalyst-config.json +11 -0
  138. package/templates/init/functions/python/cron/requirements.txt +1 -0
  139. package/templates/init/functions/python/cron/sample.py +18 -0
  140. package/templates/init/functions/python/event/catalyst-config.json +11 -0
  141. package/templates/init/functions/python/event/requirements.txt +1 -0
  142. package/templates/init/functions/python/event/sample.py +21 -0
  143. package/templates/init/functions/python/integ/cliq/catalyst-config.json +11 -0
  144. package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +174 -0
  145. package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +102 -0
  146. package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +409 -0
  147. package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +12 -0
  148. package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +16 -0
  149. package/templates/init/functions/python/integ/cliq/handlers/message_action_handler.py +18 -0
  150. package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +269 -0
  151. package/templates/init/functions/python/integ/cliq/requirements.txt +1 -0
  152. package/templates/init/functions/python/integ/cliq/sample.py +21 -0
  153. package/lib/serve/server/lib/node.js +0 -62
  154. package/lib/shell/dependencies/invoker/bio/node.js +0 -80
  155. package/lib/shell/dependencies/invoker/cron/node.js +0 -54
  156. package/lib/shell/dependencies/invoker/event/node.js +0 -56
  157. package/lib/shell/dependencies/invoker/integ/node.js +0 -79
  158. package/templates/.DS_Store +0 -0
  159. package/templates/init/.DS_Store +0 -0
  160. package/templates/init/client/.DS_Store +0 -0
  161. package/templates/init/client/react/.DS_Store +0 -0
  162. package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
@@ -16,6 +16,7 @@ const ansi_colors_1 = require("ansi-colors");
16
16
  const endpoints_1 = require("../endpoints");
17
17
  const error_1 = __importDefault(require("../error"));
18
18
  const rc_1 = __importDefault(require("../internal/rc"));
19
+ const prompt_1 = __importDefault(require("../prompt"));
19
20
  const runtime_store_1 = __importDefault(require("../runtime-store"));
20
21
  const constants_1 = require("../util_modules/constants");
21
22
  const project_1 = __importDefault(require("../util_modules/constants/project"));
@@ -23,15 +24,33 @@ const js_1 = require("../util_modules/js");
23
24
  const logger_1 = require("../util_modules/logger");
24
25
  const option_1 = require("../util_modules/option");
25
26
  const project_2 = require("../util_modules/project");
26
- exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __awaiter(void 0, void 0, void 0, function* () {
27
+ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck = true } = {}) => __awaiter(void 0, void 0, void 0, function* () {
28
+ const orgOpt = (0, option_1.getGlobalOptionValue)('org', null);
27
29
  const projectOpt = (0, option_1.getGlobalOptionValue)('project', null);
28
- const projectApi = yield (0, endpoints_1.projectAPI)();
29
- const envApi = yield (0, endpoints_1.envAPI)();
30
+ if (projectOpt != null && orgOpt == null) {
31
+ throw new error_1.default('Org option is needed when project option is supplied', {
32
+ exit: 2
33
+ });
34
+ }
35
+ const orgApi = yield (0, endpoints_1.orgAPI)();
36
+ if (orgOpt != null) {
37
+ const orgList = yield orgApi.getAllOrgs();
38
+ const found = orgList.find((org) => org.id + '' === orgOpt);
39
+ if (!found) {
40
+ throw new error_1.default('Invalid "org" option supplied', {
41
+ exit: 2
42
+ });
43
+ }
44
+ runtime_store_1.default.set('project.env.id', orgOpt + '');
45
+ }
46
+ let projectApi = orgOpt != null ? yield (0, endpoints_1.projectAPI)({ auth: true, org: orgOpt }) : yield (0, endpoints_1.projectAPI)();
47
+ let envApi = orgOpt != null ? yield (0, endpoints_1.envAPI)({ auth: true, org: orgOpt }) : yield (0, endpoints_1.envAPI)();
30
48
  const convertProjectToProperties = (project) => {
31
49
  project = (0, project_2.transformProject)(project);
32
50
  runtime_store_1.default.set('project.name', project.name);
33
51
  runtime_store_1.default.set('project.id', project.id + '');
34
52
  runtime_store_1.default.set('project.domain', project.domain);
53
+ runtime_store_1.default.set('project.timezone', project.timezone);
35
54
  };
36
55
  const convertEnvToProperties = (envArr) => {
37
56
  const envObj = js_1.JS.find(envArr, { env_name: constants_1.DEFAULT.env_name });
@@ -93,6 +112,26 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
93
112
  });
94
113
  runtime_store_1.default.set('rc', rcInstance);
95
114
  if (!rcInstance.loaded) {
115
+ if (!ignoreRC && orgOpt == null && !skipOrgCheck) {
116
+ (0, logger_1.warning)('Not in Catalyst app directory!!!');
117
+ const orgList = yield orgApi.getAllOrgs();
118
+ if (orgList.length === 0) {
119
+ throw new error_1.default('Visit ' +
120
+ (0, ansi_colors_1.underline)(constants_1.ORIGIN.console) +
121
+ ' for creation of your first project before you continue.', { exit: 1 });
122
+ }
123
+ const orgChoice = orgList.map((org) => prompt_1.default.choice(org.name + ' (' + org.id + ')', {
124
+ value: org,
125
+ short: org.name
126
+ }));
127
+ const orgAns = yield prompt_1.default.ask(prompt_1.default.question('org', 'Select a Catalyst org to continue: ', {
128
+ type: 'list',
129
+ choices: js_1.JS.reverse(orgChoice),
130
+ when: orgChoice.length > 0
131
+ }));
132
+ const selectedOrg = orgAns.org || orgList[0];
133
+ runtime_store_1.default.set('project.env.id', selectedOrg.id);
134
+ }
96
135
  if (optional || ignoreRC) {
97
136
  return;
98
137
  }
@@ -145,6 +184,10 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
145
184
  arg: [(0, ansi_colors_1.bold)(constants_1.FILENAME.rc), (0, ansi_colors_1.bold)('catalyst init project'), (0, ansi_colors_1.bold)('--option')]
146
185
  });
147
186
  }
187
+ if (typeof finalEnvObj !== 'undefined') {
188
+ projectApi = yield (0, endpoints_1.projectAPI)({ auth: true, org: finalEnvObj.id });
189
+ envApi = yield (0, endpoints_1.envAPI)({ auth: true, org: finalEnvObj.id });
190
+ }
148
191
  const projectDetails = yield projectApi
149
192
  .getProject(finalProjectObj.id + '')
150
193
  .catch((err) => __awaiter(void 0, void 0, void 0, function* () {
@@ -166,10 +209,16 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
166
209
  }
167
210
  throw err;
168
211
  }));
169
- if (projectDetails && projectDetails.project_name !== finalProjectObj.name) {
170
- finalProjectObj.name = projectDetails.project_name;
171
- finalProjectObj.domain.name = projectDetails.project_domain_details.project_domain_name;
172
- rcInstance.upsertProject(finalProjectObj);
212
+ if (projectDetails) {
213
+ if (projectDetails.project_name !== finalProjectObj.name) {
214
+ finalProjectObj.name = projectDetails.project_name;
215
+ finalProjectObj.domain.name = projectDetails.project_domain_details.project_domain_name;
216
+ rcInstance.upsertProject(finalProjectObj);
217
+ }
218
+ if (projectDetails.timezone !== finalProjectObj.timezone) {
219
+ finalProjectObj.timezone = projectDetails.timezone;
220
+ rcInstance.upsertProject(finalProjectObj);
221
+ }
173
222
  }
174
223
  if (finalProjectObj === undefined) {
175
224
  return;
@@ -195,5 +244,5 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
195
244
  ' in order to reset.');
196
245
  }
197
246
  convertProjectToProperties(finalProjectObj);
198
- runtime_store_1.default.set('project.env', finalEnvObj);
247
+ runtime_store_1.default.set('project.env', runtime_store_1.default.get('project.env', finalEnvObj));
199
248
  });
@@ -0,0 +1,23 @@
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 command_1 = __importDefault(require("../../internal/command"));
16
+ const userConfig_1 = __importDefault(require("../../userConfig"));
17
+ const logger_1 = require("../../util_modules/logger");
18
+ exports.default = new command_1.default('config:delete <key>')
19
+ .description('Delete a key from catalyst config')
20
+ .action((key) => __awaiter(void 0, void 0, void 0, function* () {
21
+ const value = userConfig_1.default.delete(key);
22
+ value ? (0, logger_1.success)('key deleted successfully') : (0, logger_1.error)('key not found');
23
+ }));
@@ -0,0 +1,23 @@
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 command_1 = __importDefault(require("../../internal/command"));
16
+ const userConfig_1 = __importDefault(require("../../userConfig"));
17
+ const logger_1 = require("../../util_modules/logger");
18
+ exports.default = new command_1.default('config:get <key>')
19
+ .description('Get catalyst config value for the specified key')
20
+ .action((key) => __awaiter(void 0, void 0, void 0, function* () {
21
+ const value = userConfig_1.default.get(key);
22
+ value ? (0, logger_1.info)(value) : (0, logger_1.error)('key not found');
23
+ }));
@@ -0,0 +1,23 @@
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 command_1 = __importDefault(require("../../internal/command"));
16
+ const userConfig_1 = __importDefault(require("../../userConfig"));
17
+ const logger_1 = require("../../util_modules/logger");
18
+ exports.default = new command_1.default('config:list')
19
+ .description('List all your catalyst configurations')
20
+ .action(() => __awaiter(void 0, void 0, void 0, function* () {
21
+ const list = userConfig_1.default.list();
22
+ (0, logger_1.info)(list);
23
+ }));
@@ -0,0 +1,29 @@
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 error_1 = __importDefault(require("../../error"));
16
+ const command_1 = __importDefault(require("../../internal/command"));
17
+ const userConfig_1 = __importDefault(require("../../userConfig"));
18
+ const logger_1 = require("../../util_modules/logger");
19
+ exports.default = new command_1.default('config:set <key=value>')
20
+ .description('Set catalyst configuration as a key value pair')
21
+ .action((details) => __awaiter(void 0, void 0, void 0, function* () {
22
+ const args = details.split('=');
23
+ if (args.length != 2) {
24
+ throw new error_1.default('Invalid parameter passed' +
25
+ `\nplease give the key value pairs splitted by '=' (eg. orgname=zoho) `);
26
+ }
27
+ userConfig_1.default.set(args[0], args[1]);
28
+ (0, logger_1.success)('config updated successfully');
29
+ }));
@@ -1 +1,31 @@
1
- "use strict";
1
+ // 'use strict';
2
+
3
+ // const font = require('ansi-colors');
4
+
5
+ // const _ = require('../../lib/util_modules');
6
+ // const Command = require('../../lib/internal/command');
7
+
8
+ // module.exports = new Command('console:cache')
9
+ // .description('Launch a shell with Catalyst Cache functionalities')
10
+ // .needs('auth', [
11
+ // _.CONSTANTS.SCOPE.cache_create,
12
+ // _.CONSTANTS.SCOPE.cache_read,
13
+ // _.CONSTANTS.SCOPE.cache_delete
14
+ // ])
15
+ // .action(function(options) {
16
+ // if (!options.project) {
17
+ // return _.PROMISE.reject(
18
+ // 'Must have an active project to use this feature. Try ' + font.bold('catalyst use')
19
+ // );
20
+ // }
21
+ // let setup = _.JS.set({}, 'repl.feature', 'cache');
22
+ // return require('../lib/replserver')(setup, options).then(() => {
23
+ // _.LOGGER.info();
24
+ // _.LOGGER.info(
25
+ // 'Instructions for the Cache Shell can be found at: ' +
26
+ // font.underline.bold(
27
+ // 'https://zoho.com/catalyst/help/cli-functionalities.html#Console_Cache'
28
+ // )
29
+ // );
30
+ // });
31
+ // });
@@ -1 +1,31 @@
1
- "use strict";
1
+ // 'use strict';
2
+
3
+ // const font = require('ansi-colors');
4
+
5
+ // const _ = require('../../lib/util_modules');
6
+ // const Command = require('../../lib/internal/command');
7
+
8
+ // module.exports = new Command('console:queue')
9
+ // .description('Launch a shell with Catalyst Queue functionalities')
10
+ // .needs('auth', [
11
+ // _.CONSTANTS.SCOPE.queue,
12
+ // _.CONSTANTS.SCOPE.queue_data_create,
13
+ // _.CONSTANTS.SCOPE.queue_data_read
14
+ // ])
15
+ // .action(function(options) {
16
+ // if (!options.project) {
17
+ // return _.PROMISE.reject(
18
+ // 'Must have an active project to use this feature. Try ' + font.bold('catalyst use')
19
+ // );
20
+ // }
21
+ // let setup = _.JS.set({}, 'repl.feature', 'queue');
22
+ // return require('../lib/replserver')(setup, options).then(() => {
23
+ // _.LOGGER.info();
24
+ // _.LOGGER.info(
25
+ // 'Instructions for the queue Shell can be found at: ' +
26
+ // font.underline.bold(
27
+ // 'https://zoho.com/catalyst/help/cli-functionalities.html#Console_Queue'
28
+ // )
29
+ // );
30
+ // });
31
+ // });
@@ -1 +1,27 @@
1
- "use strict";
1
+ // 'use strict';
2
+
3
+ // const font = require('ansi-colors');
4
+
5
+ // const _ = require('../../lib/util_modules');
6
+ // const Command = require('../../lib/internal/command');
7
+
8
+ // module.exports = new Command('console:zcql')
9
+ // .description('Launch a shell with CatalystQL functionalities for Data Store')
10
+ // .needs('auth', [_.CONSTANTS.SCOPE.zcql])
11
+ // .action(function(options) {
12
+ // if (!options.project) {
13
+ // return _.PROMISE.reject(
14
+ // 'Must have an active project to use this feature. Try ' + font.bold('catalyst use')
15
+ // );
16
+ // }
17
+ // let setup = _.JS.set({}, 'repl.feature', 'zcql');
18
+ // return require('../lib/replserver')(setup, options).then(() => {
19
+ // _.LOGGER.info();
20
+ // _.LOGGER.info(
21
+ // 'Instructions for the Cache Shell can be found at: ' +
22
+ // font.underline.bold(
23
+ // 'https://zoho.com/catalyst/help/cli-functionalities.html#Console_zcql'
24
+ // )
25
+ // );
26
+ // });
27
+ // });
@@ -41,8 +41,8 @@ exports.default = new command_1.default('ds:export [table]')
41
41
  .option('--page <page>', 'Number which denotes the range of rows to be fetched (eg. "1")')
42
42
  .option('--production', 'flag for pointing to production environment')
43
43
  .needs('auth', [constants_1.SCOPE.projects, constants_1.SCOPE.datastore, constants_1.SCOPE.row])
44
- .needs('config')
45
- .needs('rc')
44
+ .needs('config', { optional: true })
45
+ .needs('rc', { optional: true })
46
46
  .action((optTable) => __awaiter(void 0, void 0, void 0, function* () {
47
47
  const env = (0, option_1.getOptionValue)('production', false) ? 'Production' : 'Development';
48
48
  const configPath = (0, option_1.getOptionValue)('config', false);
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const ansi_colors_1 = require("ansi-colors");
15
16
  const path_1 = require("path");
16
17
  const endpoints_1 = require("../../endpoints");
17
18
  const error_1 = __importDefault(require("../../error"));
@@ -41,8 +42,8 @@ exports.default = new command_1.default('ds:import [file]')
41
42
  .option('--config <path>', 'Path of the configuration json file to be used for import.')
42
43
  .option('--production', 'flag for pointing to production environment')
43
44
  .needs('auth', [constants_1.SCOPE.projects, constants_1.SCOPE.datastore, constants_1.SCOPE.row])
44
- .needs('config')
45
- .needs('rc')
45
+ .needs('config', { optional: true })
46
+ .needs('rc', { optional: true })
46
47
  .action((uploadFile) => __awaiter(void 0, void 0, void 0, function* () {
47
48
  const env = (0, option_1.getOptionValue)('production', false) ? 'Production' : 'Development';
48
49
  const configPath = (0, option_1.getOptionValue)('config', false);
@@ -59,13 +60,32 @@ exports.default = new command_1.default('ds:import [file]')
59
60
  const allFolders = (yield fileAPI.getAllFolders());
60
61
  if (allFolders.length > 0) {
61
62
  const choices = allFolders.map((folderDetail) => prompt_1.default.choice(folderDetail.folder_name, {
62
- value: folderDetail.id
63
+ value: folderDetail
63
64
  }));
64
65
  const folderAns = yield prompt_1.default.ask(prompt_1.default.question('folder', 'Select a folder to which you want to upload the file to : ', {
65
66
  type: 'list',
66
- choices
67
+ choices,
68
+ when: !importConfig.folder_id
67
69
  }));
68
- const fileDetails = (yield fileAPI.uploadFile(folderAns.folder, fs_1.SYNC.getReadStream((0, path_1.resolve)(uploadFile))));
70
+ folderAns.folder =
71
+ folderAns.folder === undefined
72
+ ? allFolders.find((folderDetails) => folderDetails.folder_name === importConfig.folder_id ||
73
+ folderDetails.id === importConfig.folder_id)
74
+ : folderAns.folder;
75
+ if (!folderAns.folder) {
76
+ throw new error_1.default('Folder not present', {
77
+ exit: 1,
78
+ errorId: 'IMP-4',
79
+ arg: [
80
+ ansi_colors_1.bold.red(importConfig.folder_id || ''),
81
+ (0, ansi_colors_1.italic)(configPath || ''),
82
+ (0, ansi_colors_1.bold)(uploadFile),
83
+ (0, ansi_colors_1.bold)('Unique ID'),
84
+ (0, ansi_colors_1.italic)('file_id')
85
+ ]
86
+ });
87
+ }
88
+ const fileDetails = (yield fileAPI.uploadFile(folderAns.folder.id, fs_1.SYNC.getReadStream((0, path_1.resolve)(uploadFile))));
69
89
  importConfig.file_id = fileDetails.id;
70
90
  }
71
91
  else {
@@ -171,8 +171,8 @@ exports.default = new command_1.default('ds:status <operation> [jobid]')
171
171
  .description('Display the job status of a Data Store import or export operation')
172
172
  .option('--production', 'flag for pointing to production environment.')
173
173
  .needs('auth', [constants_1.SCOPE.projects, constants_1.SCOPE.datastore, constants_1.SCOPE.row])
174
- .needs('config')
175
- .needs('rc')
174
+ .needs('config', { optional: true })
175
+ .needs('rc', { optional: true })
176
176
  .action((operation, jobId) => __awaiter(void 0, void 0, void 0, function* () {
177
177
  const env = (0, option_1.getOptionValue)('production', false) ? 'Production' : 'Development';
178
178
  const action = operation === 'import' ? 'write' : 'read';
@@ -56,7 +56,7 @@ exports.default = new command_1.default('iac:export')
56
56
  .option('--production', 'flag for pointing to production environment')
57
57
  .needs('auth', [constants_1.SCOPE.project_export_read, constants_1.SCOPE.project_export_create])
58
58
  .needs('config', { optional: true })
59
- .needs('rc', { optional: true })
59
+ .needs('rc', { optional: true, skipOrgCheck: false })
60
60
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
61
61
  const env = (0, option_1.getOptionValue)('production', false) ? 'Production' : 'Development';
62
62
  const projectId = yield getExportProjectId();
@@ -208,7 +208,7 @@ exports.default = new command_1.default('iac:import [file_path]')
208
208
  constants_1.SCOPE.project_import_delete
209
209
  ])
210
210
  .needs('config', { optional: true })
211
- .needs('rc', { optional: true })
211
+ .needs('rc', { optional: true, skipOrgCheck: false })
212
212
  .action((filePath) => __awaiter(void 0, void 0, void 0, function* () {
213
213
  const nameOptValue = (0, option_1.getOptionValue)('name');
214
214
  if (nameOptValue && !nameOptValue.match(constants_1.REGEX.project.name)) {
@@ -58,7 +58,10 @@ exports.default = new command_1.default('iac:pack [zip_name]')
58
58
  var _a, _b;
59
59
  const config = runtime_store_1.default.get('config');
60
60
  const rootDir = (0, path_1.dirname)(config.configPath);
61
- const filesAtRoot = yield fs_1.ASYNC.walk(rootDir, { excludeDir: true, depth: 1 });
61
+ const filesAtRoot = yield fs_1.ASYNC.walk(rootDir, {
62
+ filter: { excludeDir: true, exclude: [] },
63
+ depth: 1
64
+ });
62
65
  const templateFilePth = filesAtRoot.find((fileName) => fileName.match(constants_1.REGEX.project.template));
63
66
  if (templateFilePth === undefined) {
64
67
  throw new error_1.default('No template file found', { exit: 1 });
@@ -81,8 +84,8 @@ exports.default = new command_1.default('iac:pack [zip_name]')
81
84
  const fnTargets = yield fn_utils_1.fnUtils.common.validate();
82
85
  const refinedFns = yield fn_utils_1.fnUtils.common.refineTargets(fnTargets, false);
83
86
  const fnNameByCodePath = {};
84
- const [nodeFns, javaFns] = refinedFns.reduce((acc, fn) => {
85
- var _a, _b;
87
+ const [nodeFns, javaFns, pythonFns] = refinedFns.reduce((acc, fn) => {
88
+ var _a, _b, _c;
86
89
  if (!fn.valid) {
87
90
  throw new error_1.default(`Unable to pack since "${fn.name}" is not valid. Reason: ${fn.failure_reason}`);
88
91
  }
@@ -97,11 +100,19 @@ exports.default = new command_1.default('iac:pack [zip_name]')
97
100
  if ((_b = fn.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java)) {
98
101
  acc[1].push(fn);
99
102
  }
103
+ if ((_c = fn.stack) === null || _c === void 0 ? void 0 : _c.startsWith(runtime_1.default.language.python)) {
104
+ acc[2].push(fn);
105
+ }
100
106
  return acc;
101
- }, [[], []]);
107
+ }, [[], [], []]);
102
108
  const packedNodeFns = yield (0, languages_1.node)(nodeFns);
103
109
  const packedJavaFns = yield (0, languages_1.java)(javaFns);
104
- const packedFns = [...(packedNodeFns || []), ...(packedJavaFns || [])];
110
+ const packedPythonFns = yield (0, languages_1.python)(pythonFns);
111
+ const packedFns = [
112
+ ...(packedNodeFns || []),
113
+ ...(packedJavaFns || []),
114
+ ...(packedPythonFns || [])
115
+ ];
105
116
  packedFns.forEach((fn) => {
106
117
  if (!fn.valid) {
107
118
  throw new error_1.default(`Unable to pack since "${fn.name}" is not valid. Reason: ${fn.failure_reason}`);
@@ -45,7 +45,7 @@ exports.default = new command_1.default('iac:status <operation>')
45
45
  .option('--production', 'flag for pointing to production environment (only for export)')
46
46
  .needs('auth', [constants_1.SCOPE.project_import_read, constants_1.SCOPE.project_export_read])
47
47
  .needs('config', { optional: true })
48
- .needs('rc', { optional: true })
48
+ .needs('rc', { optional: true, skipOrgCheck: false })
49
49
  .action((operation) => __awaiter(void 0, void 0, void 0, function* () {
50
50
  switch (operation) {
51
51
  case 'import':
@@ -81,6 +81,10 @@ exports.default = (client) => {
81
81
  loadCommand('deploy'),
82
82
  loadCommand('help'),
83
83
  loadCommand('run'),
84
+ loadCommand('config:set'),
85
+ loadCommand('config:get'),
86
+ loadCommand('config:delete'),
87
+ loadCommand('config:list'),
84
88
  loadCommand('logout')
85
89
  ]);
86
90
  };
@@ -46,7 +46,7 @@ exports.default = new command_1.default('project:list')
46
46
  .description('List all the Catalyst projects you have access to')
47
47
  .needs('auth', [constants_1.SCOPE.projects])
48
48
  .needs('config', { optional: true, resolveOnNotFound: true })
49
- .needs('rc', { optional: true })
49
+ .needs('rc', { optional: true, skipOrgCheck: false })
50
50
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
51
51
  const cliTable3 = (yield Promise.resolve().then(() => __importStar(require('../../cli_table')))).default;
52
52
  const projects = (yield (yield (0, endpoints_1.projectAPI)()).getAllProjects());
@@ -33,7 +33,7 @@ exports.default = new command_1.default('project:use [name_or_project_id]')
33
33
  .description('Set an active Catalyst project for your working directory')
34
34
  .needs('auth', [constants_1.SCOPE.projects])
35
35
  .needs('config', { optional: true, resolveOnNotFound: true })
36
- .needs('rc', { optional: true, resolveOnNotFound: true })
36
+ .needs('rc', { optional: true, resolveOnNotFound: true, skipOrgCheck: false })
37
37
  .action((newActive) => __awaiter(void 0, void 0, void 0, function* () {
38
38
  const currentProjectId = (0, project_2.getProjectId)(null);
39
39
  const allProjects = (yield (yield (0, endpoints_1.projectAPI)()).getAllProjects().catch(() => {
@@ -21,12 +21,12 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
21
21
  yield client_utils_1.clientUtils.validate();
22
22
  const readStream = yield client_utils_1.clientUtils.pack();
23
23
  const resp = (yield (yield (0, endpoints_1.clientAPI)()).deploy(readStream));
24
+ const homepage = runtime_store_1.default.get('context.client.homepage', '');
24
25
  runtime_store_1.default.set('payload.client.url', 'https://' +
25
26
  resp.url_prefix +
26
27
  '.' +
27
28
  constants_1.ORIGIN.app.replace('https://', '') +
28
- '/app/' +
29
- runtime_store_1.default.get('context.client.homepage'));
29
+ (homepage.startsWith('/__catalyst') ? homepage : '/app/' + homepage));
30
30
  runtime_store_1.default.set('payload.client.deploy', true);
31
31
  client_utils_1.clientUtils.executeHook({ prefix: 'post', command: 'deploy' });
32
32
  });
@@ -17,6 +17,7 @@ const endpoints_1 = require("../../../endpoints");
17
17
  const error_1 = __importDefault(require("../../../error"));
18
18
  const fn_utils_1 = require("../../../fn-utils");
19
19
  const runtime_store_1 = __importDefault(require("../../../runtime-store"));
20
+ const throbber_1 = __importDefault(require("../../../throbber"));
20
21
  const constants_1 = require("../../../util_modules/constants");
21
22
  const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/runtime"));
22
23
  const logger_1 = require("../../../util_modules/logger");
@@ -37,11 +38,17 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
37
38
  }
38
39
  const refinedTargets = yield fn_utils_1.fnUtils.common.refineTargets(targets);
39
40
  runtime_store_1.default.set('context.functions.targets', refinedTargets);
40
- const packedTargets = yield Promise.all([
41
+ refinedTargets
42
+ .filter((target) => target.valid)
43
+ .forEach((target) => throbber_1.default.getInstance().add('function_deploy_' + target.name, {
44
+ text: `packaging function [${target.name}]`
45
+ }));
46
+ const [nodeTarget, javaTarget, pythonTarget] = yield Promise.all([
41
47
  (0, languages_1.node)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.nodejs)) && target.valid; })),
42
- (0, languages_1.java)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java)) && target.valid; }))
48
+ (0, languages_1.java)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java)) && target.valid; })),
49
+ (0, languages_1.python)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python)) && target.valid; }))
43
50
  ]);
44
- const combinedTarget = [...(packedTargets[0] || []), ...(packedTargets[1] || [])];
51
+ const combinedTarget = [...(nodeTarget || []), ...(javaTarget || []), ...(pythonTarget || [])];
45
52
  const batchSize = 1;
46
53
  const fnAPI = yield (0, endpoints_1.functionsAPI)();
47
54
  const appAPI = yield (0, endpoints_1.applogicAPI)();
@@ -68,6 +75,9 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
68
75
  }));
69
76
  }
70
77
  target.id = resp.id + '';
78
+ if (target.id && target.env_var && Object.keys(target.env_var).length > 0) {
79
+ yield fnAPI.updateConfig(target.id, target.env_var);
80
+ }
71
81
  fn_utils_1.fnUtils.common.generateUrlForTarget(target);
72
82
  }
73
83
  catch (e) {
@@ -8,19 +8,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.java = exports.node = void 0;
15
+ exports.python = exports.java = exports.node = void 0;
13
16
  const fn_utils_1 = require("../../../../fn-utils");
17
+ const throbber_1 = __importDefault(require("../../../../throbber"));
14
18
  function deploy(targets, lang) {
15
19
  return __awaiter(this, void 0, void 0, function* () {
16
20
  if (targets === undefined || targets.length === 0) {
17
21
  return;
18
22
  }
23
+ const throbber = throbber_1.default.getInstance();
19
24
  yield fn_utils_1.fnUtils[lang].validate(targets, 0);
20
25
  return Promise.all(targets
21
- .filter((target) => target.valid)
26
+ .filter((target) => {
27
+ if (!target.valid) {
28
+ throbber.remove('function_deploy_' + target.name);
29
+ }
30
+ return target.valid;
31
+ })
22
32
  .map((target) => __awaiter(this, void 0, void 0, function* () {
23
33
  yield fn_utils_1.fnUtils.common.pack(target);
34
+ throbber.remove('function_deploy_' + target.name);
24
35
  return target;
25
36
  })));
26
37
  });
@@ -37,3 +48,9 @@ function java(targets) {
37
48
  });
38
49
  }
39
50
  exports.java = java;
51
+ function python(targets) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ return deploy(targets, 'python');
54
+ });
55
+ }
56
+ exports.python = python;
@@ -32,19 +32,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.logAPI = exports.eventBusAPI = exports.functionsAPI = exports.applogicAPI = exports.bulkDSAPI = exports.apigAPI = exports.clientAPI = exports.datastoreAPI = exports.zcqlAPI = exports.queueAPI = exports.filestoreAPI = exports.cacheAPI = exports.sdkAPI = exports.envAPI = exports.projectAPI = void 0;
35
+ exports.logAPI = exports.eventBusAPI = exports.functionsAPI = exports.applogicAPI = exports.bulkDSAPI = exports.apigAPI = exports.clientAPI = exports.datastoreAPI = exports.zcqlAPI = exports.queueAPI = exports.filestoreAPI = exports.cacheAPI = exports.sdkAPI = exports.envAPI = exports.projectAPI = exports.orgAPI = void 0;
36
36
  const project_1 = require("../util_modules/project");
37
- function projectAPI({ auth = true } = {}) {
37
+ function orgAPI({ auth = true } = {}) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const org = (yield Promise.resolve().then(() => __importStar(require('./lib/org')))).default;
40
+ return new org({ authNeeded: auth });
41
+ });
42
+ }
43
+ exports.orgAPI = orgAPI;
44
+ function projectAPI({ auth = true, org = (0, project_1.getEnvId)() } = {}) {
38
45
  return __awaiter(this, void 0, void 0, function* () {
39
46
  const project = (yield Promise.resolve().then(() => __importStar(require('./lib/project')))).default;
40
- return new project({ authNeeded: auth });
47
+ return new project({ authNeeded: auth }, org);
41
48
  });
42
49
  }
43
50
  exports.projectAPI = projectAPI;
44
- function envAPI({ auth = true } = {}) {
51
+ function envAPI({ auth = true, org = (0, project_1.getEnvId)() } = {}) {
45
52
  return __awaiter(this, void 0, void 0, function* () {
46
53
  const env = (yield Promise.resolve().then(() => __importStar(require('./lib/env')))).default;
47
- return new env({ authNeeded: auth });
54
+ return new env({ authNeeded: auth }, org);
48
55
  });
49
56
  }
50
57
  exports.envAPI = envAPI;