zcatalyst-cli 1.26.2 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +1 -0
  2. package/lib/authentication/credential.d.ts +2 -1
  3. package/lib/authentication/credential.js +20 -3
  4. package/lib/authentication/crypt.d.ts +7 -3
  5. package/lib/authentication/crypt.js +87 -16
  6. package/lib/authentication/index.js +1 -0
  7. package/lib/authentication/key-manager.d.ts +7 -0
  8. package/lib/authentication/key-manager.js +62 -0
  9. package/lib/authentication/login.js +20 -20
  10. package/lib/bin/catalyst.js +1 -15
  11. package/lib/client.d.ts +3 -1
  12. package/lib/client.js +16 -5
  13. package/lib/command_needs/rc.js +13 -3
  14. package/lib/commands/appsail/add.js +10 -0
  15. package/lib/commands/client/delete.js +18 -6
  16. package/lib/commands/client/setup.js +7 -0
  17. package/lib/commands/deploy/index.js +3 -3
  18. package/lib/commands/deploy/slate.js +65 -4
  19. package/lib/commands/functions/add.js +7 -0
  20. package/lib/commands/functions/delete.js +22 -4
  21. package/lib/commands/functions/execute.js +39 -71
  22. package/lib/commands/functions/setup.js +13 -0
  23. package/lib/commands/functions/shell.js +15 -1
  24. package/lib/commands/iac/import.js +2 -2
  25. package/lib/commands/init.js +34 -20
  26. package/lib/commands/login.js +1 -0
  27. package/lib/commands/pull.js +22 -1
  28. package/lib/commands/serve.js +2 -1
  29. package/lib/commands/slate/create.js +7 -4
  30. package/lib/commands/slate/link.js +11 -5
  31. package/lib/commands/slate/unlink.js +7 -0
  32. package/lib/commands/zest/generate/index.js +28 -35
  33. package/lib/deploy/features/slate.d.ts +3 -1
  34. package/lib/deploy/features/slate.js +204 -5
  35. package/lib/docs/client-utils.toml +0 -5
  36. package/lib/docs/command_needs/rc.toml +9 -1
  37. package/lib/docs/commands/client/delete.toml +4 -0
  38. package/lib/docs/commands/deploy/slate.toml +3 -0
  39. package/lib/docs/commands/functions/delete.toml +10 -0
  40. package/lib/docs/commands/functions/execute.toml +1 -16
  41. package/lib/docs/commands/functions/setup.toml +3 -0
  42. package/lib/docs/commands/functions/shell.toml +8 -0
  43. package/lib/docs/commands/init.toml +3 -0
  44. package/lib/docs/commands/pull.toml +6 -0
  45. package/lib/docs/commands/slate/unlink.toml +6 -0
  46. package/lib/docs/execute/command-utils.toml +14 -0
  47. package/lib/docs/execute/execute-input-resolver.toml +37 -0
  48. package/lib/docs/init/features/project.toml +20 -0
  49. package/lib/docs/init/util/client.toml +4 -0
  50. package/lib/docs/prompt/index.toml +15 -0
  51. package/lib/docs/pull/features/apig.toml +6 -0
  52. package/lib/docs/pull/features/client.toml +20 -0
  53. package/lib/docs/pull/features/functions/index.toml +24 -0
  54. package/lib/endpoints/lib/slate.d.ts +14 -1
  55. package/lib/endpoints/lib/slate.js +35 -0
  56. package/lib/error/context-help.js +1 -1
  57. package/lib/error/index.js +9 -13
  58. package/lib/execute/command-utils.d.ts +5 -0
  59. package/lib/execute/command-utils.js +86 -0
  60. package/lib/execute/execute-input-resolver.d.ts +29 -0
  61. package/lib/execute/execute-input-resolver.js +207 -0
  62. package/lib/execute/index.d.ts +4 -1
  63. package/lib/execute/index.js +3 -2
  64. package/lib/fn-utils/lib/integ.js +22 -17
  65. package/lib/index.js +1 -0
  66. package/lib/init/dependencies/package-json.js +11 -7
  67. package/lib/init/features/appsail/index.js +75 -26
  68. package/lib/init/features/appsail/prompt-fields.d.ts +43 -0
  69. package/lib/init/features/appsail/prompt-fields.js +55 -0
  70. package/lib/init/features/appsail/utils/custom-runtime.d.ts +3 -0
  71. package/lib/init/features/appsail/utils/custom-runtime.js +161 -0
  72. package/lib/init/features/appsail/{utils.d.ts → utils/index.d.ts} +2 -2
  73. package/lib/init/features/appsail/utils/index.js +170 -0
  74. package/lib/init/features/client/index.js +4 -3
  75. package/lib/init/features/client/initializers/angular.js +3 -2
  76. package/lib/init/features/client/initializers/react.js +4 -3
  77. package/lib/init/features/client/prompt-fields.d.ts +37 -0
  78. package/lib/init/features/client/prompt-fields.js +48 -0
  79. package/lib/init/features/functions/index.js +37 -8
  80. package/lib/init/features/functions/languages/java.js +42 -7
  81. package/lib/init/features/functions/languages/node.js +42 -10
  82. package/lib/init/features/functions/languages/python.js +42 -7
  83. package/lib/init/features/functions/prompt-fields.d.ts +25 -0
  84. package/lib/init/features/functions/prompt-fields.js +34 -0
  85. package/lib/init/features/project.js +41 -6
  86. package/lib/init/features/slate/index.js +2 -0
  87. package/lib/init/features/slate/prompt-fields.d.ts +31 -0
  88. package/lib/init/features/slate/prompt-fields.js +41 -0
  89. package/lib/init/index.js +2 -1
  90. package/lib/init/util/client.js +11 -8
  91. package/lib/init/util/common.d.ts +2 -0
  92. package/lib/init/util/common.js +33 -3
  93. package/lib/init/util/prompt-fields.d.ts +7 -0
  94. package/lib/init/util/prompt-fields.js +13 -0
  95. package/lib/internal/command.d.ts +3 -0
  96. package/lib/internal/command.js +26 -3
  97. package/lib/migration/global/1.27.0.d.ts +2 -0
  98. package/lib/migration/global/1.27.0.js +39 -0
  99. package/lib/prompt/choice.d.ts +2 -0
  100. package/lib/prompt/choice.js +24 -0
  101. package/lib/prompt/cli-option-key.d.ts +1 -0
  102. package/lib/prompt/cli-option-key.js +10 -0
  103. package/lib/prompt/index.d.ts +6 -22
  104. package/lib/prompt/index.js +264 -67
  105. package/lib/prompt/overwrite-prompt.d.ts +11 -0
  106. package/lib/prompt/overwrite-prompt.js +16 -0
  107. package/lib/prompt/question-factory.d.ts +34 -0
  108. package/lib/prompt/question-factory.js +41 -0
  109. package/lib/prompt/register-fields.d.ts +24 -0
  110. package/lib/prompt/register-fields.js +37 -0
  111. package/lib/pull/features/apig.js +57 -6
  112. package/lib/pull/features/client.js +107 -24
  113. package/lib/pull/features/functions/index.js +100 -4
  114. package/lib/pull/index.js +1 -1
  115. package/lib/pull/utils.d.ts +13 -0
  116. package/lib/pull/utils.js +20 -0
  117. package/lib/repl-server.d.ts +4 -0
  118. package/lib/repl-server.js +9 -0
  119. package/lib/serve/server/lib/master/index.js +3 -3
  120. package/lib/serve/server/lib/slate/static-server.js +2 -2
  121. package/lib/serve/server/lib/web_client/server.js +2 -2
  122. package/lib/shell/format-functions.d.ts +4 -0
  123. package/lib/shell/format-functions.js +59 -0
  124. package/lib/shell/index.js +18 -0
  125. package/lib/util_modules/config/lib/appsail.d.ts +3 -2
  126. package/lib/util_modules/config/lib/appsail.js +6 -3
  127. package/lib/util_modules/config/lib/slate.d.ts +19 -0
  128. package/lib/util_modules/config-store.d.ts +1 -0
  129. package/lib/util_modules/config-store.js +29 -10
  130. package/lib/util_modules/constants/index.d.ts +0 -1
  131. package/lib/util_modules/constants/index.js +1 -3
  132. package/lib/util_modules/constants/lib/urls.d.ts +2 -0
  133. package/lib/util_modules/constants/lib/urls.js +4 -0
  134. package/lib/util_modules/dc.d.ts +6 -1
  135. package/lib/util_modules/dc.js +21 -8
  136. package/lib/util_modules/env.d.ts +3 -0
  137. package/lib/util_modules/env.js +41 -0
  138. package/lib/util_modules/fs/lib/sync.d.ts +1 -0
  139. package/lib/util_modules/fs/lib/sync.js +19 -0
  140. package/lib/util_modules/logger/utils.d.ts +1 -0
  141. package/lib/util_modules/logger/utils.js +5 -1
  142. package/lib/util_modules/option.d.ts +1 -0
  143. package/lib/util_modules/option.js +8 -0
  144. package/lib/util_modules/{server.js → server/index.js} +3 -3
  145. package/lib/util_modules/server/needed-scopes.d.ts +1 -0
  146. package/lib/util_modules/{constants/lib → server}/needed-scopes.js +7 -7
  147. package/package.json +3 -2
  148. package/lib/init/features/appsail/utils.js +0 -273
  149. package/lib/util_modules/constants/lib/needed-scopes.d.ts +0 -4
  150. /package/lib/docs/{dc.toml → util_modules/dc.toml} +0 -0
  151. /package/lib/util_modules/{server.d.ts → server/index.d.ts} +0 -0
@@ -1,273 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.getAppSailZip = getAppSailZip;
49
- exports.getAppSailName = getAppSailName;
50
- exports.getContainerImageTag = getContainerImageTag;
51
- exports.getCustomAppSailSource = getCustomAppSailSource;
52
- const image_1 = require("@zcatalyst/container-plugin/out/endpoints/image");
53
- const ansi_colors_1 = require("ansi-colors");
54
- const inquirer = __importStar(require("inquirer"));
55
- const path_1 = require("path");
56
- const archiver_1 = __importDefault(require("../../../archiver"));
57
- const endpoints_1 = require("../../../endpoints");
58
- const error_1 = __importDefault(require("../../../error"));
59
- const prompt_1 = __importDefault(require("../../../prompt"));
60
- const config_1 = require("../../../util_modules/config");
61
- const constants_1 = require("../../../util_modules/constants");
62
- const container_1 = require("../../../util_modules/container");
63
- const fs_1 = require("../../../util_modules/fs");
64
- const js_1 = require("../../../util_modules/js");
65
- const logger_1 = require("../../../util_modules/logger");
66
- const project_1 = require("../../../util_modules/project");
67
- function getAppSailZip() {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- const _gitHubAPI = yield (0, endpoints_1.gitHubAPI)();
70
- const gitRepo = yield prompt_1.default.ask(prompt_1.default.question('repo', 'Please choose from the list of recommended projects to get started', {
71
- type: 'list',
72
- choices: [
73
- prompt_1.default.choice(`appsail-nodejs - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-nodejs')}`, {
74
- value: {
75
- api: _gitHubAPI.appsailNodejs.bind(_gitHubAPI),
76
- command: 'node index.js',
77
- source: (0, project_1.resolveProjectPath)('appsail-nodejs'),
78
- build: './',
79
- stack: {
80
- runtime: 'node16',
81
- lang: 'node'
82
- },
83
- scripts: {
84
- preserve: 'npm install',
85
- predeploy: 'npm install'
86
- },
87
- memory: 256
88
- },
89
- short: 'appsail-nodejs'
90
- }),
91
- prompt_1.default.choice(`appsail-java - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-java')}`, {
92
- value: {
93
- api: _gitHubAPI.appsailJava.bind(_gitHubAPI),
94
- command: 'java -jar demo-0.0.1-SNAPSHOT.jar',
95
- source: (0, project_1.resolveProjectPath)('appsail-java'),
96
- build: (0, path_1.join)('target', 'demo-0.0.1-SNAPSHOT.jar'),
97
- stack: {
98
- runtime: 'java8',
99
- lang: 'java'
100
- },
101
- scripts: {
102
- preserve: './mvnw clean install',
103
- predeploy: './mvnw clean install'
104
- },
105
- memory: 512,
106
- platform: 'javase'
107
- },
108
- short: 'appsail-java'
109
- }),
110
- prompt_1.default.choice(`appsail-python - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-python')}`, {
111
- value: {
112
- api: _gitHubAPI.appsailPython.bind(_gitHubAPI),
113
- command: 'python3 app.py',
114
- source: (0, project_1.resolveProjectPath)('appsail-python'),
115
- build: './',
116
- stack: {
117
- runtime: 'python_3_9',
118
- lang: 'python'
119
- },
120
- scripts: {
121
- preserve: 'python3 -m pip install -r ./requirements.txt -t ./ --upgrade',
122
- predeploy: 'python3 -m pip install -r ./requirements.txt -t ./ --upgrade'
123
- },
124
- memory: 256
125
- },
126
- short: 'appsail-python'
127
- })
128
- ]
129
- }));
130
- (0, logger_1.info)();
131
- (0, logger_1.info)((0, ansi_colors_1.white)('=>') + ' Downloading code');
132
- const code = (yield gitRepo.repo.api());
133
- const repoDir = gitRepo.repo.source;
134
- yield fs_1.ASYNC.ensureDir(repoDir);
135
- const zip = new archiver_1.default();
136
- zip.load(code);
137
- zip.extract(repoDir, '/', {
138
- isFolder: true,
139
- ignoreLevel: 1
140
- });
141
- yield zip.finalize();
142
- (0, logger_1.success)(`Successfully downloaded the code to ${ansi_colors_1.bold.green(gitRepo.repo.source)}`);
143
- return {
144
- source: gitRepo.repo.source,
145
- build: gitRepo.repo.build,
146
- stack: gitRepo.repo.stack,
147
- command: gitRepo.repo.command,
148
- scripts: gitRepo.repo.scripts,
149
- memory: gitRepo.repo.memory,
150
- platform: gitRepo.repo.platform
151
- };
152
- });
153
- }
154
- function getAppSailName() {
155
- return __awaiter(this, void 0, void 0, function* () {
156
- const existingSails = config_1.appSailConfig.raw() || [];
157
- const appName = yield prompt_1.default.ask(prompt_1.default.question('name', 'Please provide the name for your AppSail: ', {
158
- type: 'input',
159
- default: 'AppSail',
160
- validate: (name) => {
161
- const exists = existingSails.findIndex((appSail) => appSail.name === name) !== -1
162
- ? 'AppSail already exists'
163
- : true;
164
- const match = name.match(constants_1.REGEX.appsail.name)
165
- ? true
166
- : 'Invalid AppSail name: Name must contain only alphanumeric and hyphen';
167
- return typeof exists === 'string'
168
- ? exists
169
- : typeof match === 'string'
170
- ? match
171
- : true;
172
- }
173
- }));
174
- return appName.name;
175
- });
176
- }
177
- function getContainerImageTag() {
178
- return __awaiter(this, void 0, void 0, function* () {
179
- yield (0, container_1.isSocketAccessible)();
180
- const images = (yield (0, image_1.getAllLocalImages)()).reduce((_images, img) => {
181
- var _a;
182
- (_a = img.RepoTags) === null || _a === void 0 ? void 0 : _a.forEach((tag) => _images.push({ imgName: tag, id: img.Id }));
183
- return _images;
184
- }, []);
185
- const searchImages = (filter) => {
186
- const filteredImages = [];
187
- images.forEach((img) => {
188
- var _a;
189
- if (filter === '' ||
190
- img.id.includes(filter) ||
191
- ((_a = img.imgName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(filter.toLowerCase()))) {
192
- filteredImages.push({
193
- name: `${img.imgName} ${(0, ansi_colors_1.dim)(img.id.substring(7, 17))}`,
194
- value: img.imgName || img.id
195
- });
196
- return;
197
- }
198
- });
199
- return filteredImages;
200
- };
201
- yield prompt_1.default.register('search-box');
202
- const image = yield inquirer.prompt([
203
- {
204
- type: 'search-box',
205
- boxType: 'list',
206
- name: 'name',
207
- searchable: true,
208
- pageSize: 10,
209
- highlight: true,
210
- notFoundMsg: 'No Images found!',
211
- searchMsg: 'Searching images...',
212
- message: 'Please search and select the image to link:',
213
- source(_answersSoFar, input) {
214
- input || (input = '');
215
- return Promise.resolve(searchImages(input));
216
- },
217
- validate: (ansArr) => {
218
- if (js_1.JS.isEmpty(ansArr)) {
219
- return 'Must select an Image';
220
- }
221
- return true;
222
- }
223
- }
224
- ]);
225
- return `docker://${image.name}`;
226
- });
227
- }
228
- function getCustomAppSailSource() {
229
- return __awaiter(this, void 0, void 0, function* () {
230
- const dockerProtocol = yield prompt_1.default.ask(prompt_1.default.question('type', 'Please choose one of the supported protocols:', {
231
- type: 'list',
232
- choices: [
233
- prompt_1.default.choice(`Docker image ${(0, ansi_colors_1.italic)('(docker://)')}`, {
234
- value: 'image',
235
- short: 'Docker image'
236
- }),
237
- prompt_1.default.choice(`Docker archive ${(0, ansi_colors_1.italic)('(docker-archive://)')}`, {
238
- value: 'docker-archive',
239
- short: 'Docker archive'
240
- })
241
- ]
242
- }));
243
- switch (dockerProtocol.type) {
244
- case 'image': {
245
- return getContainerImageTag();
246
- }
247
- case 'docker-archive': {
248
- const archivePath = yield prompt_1.default.ask(prompt_1.default.question('archive', 'Please provide the path to the docker archive file: ', {
249
- type: 'input',
250
- validate: (pth) => __awaiter(this, void 0, void 0, function* () {
251
- if (!(0, path_1.isAbsolute)(pth)) {
252
- return 'Please provide an absolute path';
253
- }
254
- if (!(yield fs_1.ASYNC.fileExists(pth))) {
255
- return 'Provided path does not exists';
256
- }
257
- if (!pth.endsWith('.tar')) {
258
- return 'Provided file is not a valid docker archive. Please provide a .tar file';
259
- }
260
- return true;
261
- })
262
- }));
263
- const path = (0, path_1.relative)((0, project_1.getProjectRoot)(), archivePath.archive);
264
- return `docker-archive://${path}`;
265
- }
266
- default: {
267
- throw new error_1.default('Unsupported protocol selected for AppSail source', {
268
- exit: 2
269
- });
270
- }
271
- }
272
- });
273
- }
@@ -1,4 +0,0 @@
1
- declare const _default: Readonly<{
2
- SERVE: ("ZohoCatalyst.apigateway.apis.READ" | "ZohoCatalyst.apigateway.READ" | "ZohoCatalyst.segments.ALL" | "ZohoCatalyst.cache.READ" | "ZohoCatalyst.cache.CREATE" | "ZohoCatalyst.cache.DELETE" | "ZohoCatalyst.projects.ALL" | "ZohoCatalyst.cron.ALL" | "ZohoCatalyst.zcql.CREATE" | "ZohoCatalyst.projects.users.READ" | "ZohoCatalyst.projects.users.CREATE" | "ZohoCatalyst.projects.users.DELETE" | "ZohoCatalyst.projects.users.UPDATE" | "ZohoCatalyst.authentication.CREATE" | "ZohoCatalyst.email.CREATE" | "ZohoCatalyst.tables.ALL" | "ZohoCatalyst.tables.rows.ALL" | "ZohoCatalyst.tables.columns.ALL" | "ZohoCatalyst.tables.bulk.READ" | "ZohoCatalyst.tables.bulk.CREATE" | "ZohoCatalyst.nosql.READ" | "ZohoCatalyst.nosql.rows.ALL" | "ZohoCatalyst.folders.ALL" | "ZohoCatalyst.files.CREATE" | "ZohoCatalyst.files.READ" | "ZohoCatalyst.files.DELETE" | "ZohoCatalyst.functions.ALL" | "ZohoCatalyst.functions.EXECUTE" | "ZohoCatalyst.eventlistners.ALL" | "ZohoCatalyst.eventlisteners.produce" | "ZohoCatalyst.security.rules.Read" | "ZohoCatalyst.security.rules.Update" | "ZohoCatalyst.notifications.mobile" | "ZohoCatalyst.notifications.web" | "ZohoCatalyst.search.READ" | "ZohoCatalyst.mlkit.READ" | "QuickML.deployment.READ" | "ZohoCatalyst.pdfshot.execute" | "ZohoCatalyst.dataverse.execute" | "ZohoCatalyst.grid.READ" | "ZohoCatalyst.grid.terminate" | "ZohoCatalyst.circuits.execute" | "ZohoCatalyst.circuits.execution.READ" | "ZohoCatalyst.circuits.execution.DELETE" | "ZohoCatalyst.appsail.Read" | "ZohoCatalyst.jobpool.READ" | "ZohoCatalyst.job.ALL")[];
3
- }>;
4
- export default _default;
File without changes