zcatalyst-cli 1.26.1 → 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 (155) hide show
  1. package/README.md +1 -0
  2. package/lib/appsail-utils.d.ts +1 -1
  3. package/lib/appsail-utils.js +170 -129
  4. package/lib/authentication/credential.d.ts +2 -1
  5. package/lib/authentication/credential.js +20 -3
  6. package/lib/authentication/crypt.d.ts +7 -3
  7. package/lib/authentication/crypt.js +87 -16
  8. package/lib/authentication/index.js +1 -0
  9. package/lib/authentication/key-manager.d.ts +7 -0
  10. package/lib/authentication/key-manager.js +62 -0
  11. package/lib/authentication/login.js +20 -20
  12. package/lib/bin/catalyst.js +1 -15
  13. package/lib/client.d.ts +3 -1
  14. package/lib/client.js +16 -5
  15. package/lib/command_needs/rc.js +13 -3
  16. package/lib/commands/appsail/add.js +10 -0
  17. package/lib/commands/client/delete.js +18 -6
  18. package/lib/commands/client/setup.js +7 -0
  19. package/lib/commands/deploy/index.js +3 -3
  20. package/lib/commands/deploy/slate.js +65 -4
  21. package/lib/commands/functions/add.js +7 -0
  22. package/lib/commands/functions/delete.js +22 -4
  23. package/lib/commands/functions/execute.js +39 -71
  24. package/lib/commands/functions/setup.js +13 -0
  25. package/lib/commands/functions/shell.js +15 -1
  26. package/lib/commands/iac/import.js +2 -2
  27. package/lib/commands/init.js +34 -20
  28. package/lib/commands/login.js +1 -0
  29. package/lib/commands/pull.js +22 -1
  30. package/lib/commands/serve.js +2 -1
  31. package/lib/commands/slate/create.js +7 -4
  32. package/lib/commands/slate/link.js +11 -5
  33. package/lib/commands/slate/unlink.js +7 -0
  34. package/lib/commands/zest/generate/index.js +28 -35
  35. package/lib/deploy/features/appsail/index.js +2 -1
  36. package/lib/deploy/features/slate.d.ts +3 -1
  37. package/lib/deploy/features/slate.js +204 -5
  38. package/lib/docs/client-utils.toml +0 -5
  39. package/lib/docs/command_needs/rc.toml +9 -1
  40. package/lib/docs/commands/client/delete.toml +4 -0
  41. package/lib/docs/commands/deploy/slate.toml +3 -0
  42. package/lib/docs/commands/functions/delete.toml +10 -0
  43. package/lib/docs/commands/functions/execute.toml +1 -16
  44. package/lib/docs/commands/functions/setup.toml +3 -0
  45. package/lib/docs/commands/functions/shell.toml +8 -0
  46. package/lib/docs/commands/init.toml +3 -0
  47. package/lib/docs/commands/pull.toml +6 -0
  48. package/lib/docs/commands/slate/unlink.toml +6 -0
  49. package/lib/docs/execute/command-utils.toml +14 -0
  50. package/lib/docs/execute/execute-input-resolver.toml +37 -0
  51. package/lib/docs/init/features/project.toml +20 -0
  52. package/lib/docs/init/util/client.toml +4 -0
  53. package/lib/docs/prompt/index.toml +15 -0
  54. package/lib/docs/pull/features/apig.toml +6 -0
  55. package/lib/docs/pull/features/client.toml +20 -0
  56. package/lib/docs/pull/features/functions/index.toml +24 -0
  57. package/lib/endpoints/lib/slate.d.ts +14 -1
  58. package/lib/endpoints/lib/slate.js +35 -0
  59. package/lib/error/context-help.js +1 -1
  60. package/lib/error/index.js +9 -13
  61. package/lib/execute/command-utils.d.ts +5 -0
  62. package/lib/execute/command-utils.js +86 -0
  63. package/lib/execute/execute-input-resolver.d.ts +29 -0
  64. package/lib/execute/execute-input-resolver.js +207 -0
  65. package/lib/execute/index.d.ts +4 -1
  66. package/lib/execute/index.js +3 -2
  67. package/lib/fn-utils/lib/integ.js +22 -17
  68. package/lib/index.js +1 -0
  69. package/lib/init/dependencies/package-json.js +11 -7
  70. package/lib/init/features/appsail/index.js +75 -26
  71. package/lib/init/features/appsail/prompt-fields.d.ts +43 -0
  72. package/lib/init/features/appsail/prompt-fields.js +55 -0
  73. package/lib/init/features/appsail/utils/custom-runtime.d.ts +3 -0
  74. package/lib/init/features/appsail/utils/custom-runtime.js +161 -0
  75. package/lib/init/features/appsail/{utils.d.ts → utils/index.d.ts} +2 -2
  76. package/lib/init/features/appsail/utils/index.js +170 -0
  77. package/lib/init/features/client/index.js +4 -3
  78. package/lib/init/features/client/initializers/angular.js +3 -2
  79. package/lib/init/features/client/initializers/react.js +4 -3
  80. package/lib/init/features/client/prompt-fields.d.ts +37 -0
  81. package/lib/init/features/client/prompt-fields.js +48 -0
  82. package/lib/init/features/functions/index.js +37 -8
  83. package/lib/init/features/functions/languages/java.js +42 -7
  84. package/lib/init/features/functions/languages/node.js +42 -10
  85. package/lib/init/features/functions/languages/python.js +42 -7
  86. package/lib/init/features/functions/prompt-fields.d.ts +25 -0
  87. package/lib/init/features/functions/prompt-fields.js +34 -0
  88. package/lib/init/features/project.js +41 -6
  89. package/lib/init/features/slate/index.js +2 -0
  90. package/lib/init/features/slate/prompt-fields.d.ts +31 -0
  91. package/lib/init/features/slate/prompt-fields.js +41 -0
  92. package/lib/init/index.js +2 -1
  93. package/lib/init/util/client.js +11 -8
  94. package/lib/init/util/common.d.ts +2 -0
  95. package/lib/init/util/common.js +33 -3
  96. package/lib/init/util/prompt-fields.d.ts +7 -0
  97. package/lib/init/util/prompt-fields.js +13 -0
  98. package/lib/internal/command.d.ts +3 -0
  99. package/lib/internal/command.js +26 -3
  100. package/lib/migration/global/1.27.0.d.ts +2 -0
  101. package/lib/migration/global/1.27.0.js +39 -0
  102. package/lib/prompt/choice.d.ts +2 -0
  103. package/lib/prompt/choice.js +24 -0
  104. package/lib/prompt/cli-option-key.d.ts +1 -0
  105. package/lib/prompt/cli-option-key.js +10 -0
  106. package/lib/prompt/index.d.ts +6 -22
  107. package/lib/prompt/index.js +264 -67
  108. package/lib/prompt/overwrite-prompt.d.ts +11 -0
  109. package/lib/prompt/overwrite-prompt.js +16 -0
  110. package/lib/prompt/question-factory.d.ts +34 -0
  111. package/lib/prompt/question-factory.js +41 -0
  112. package/lib/prompt/register-fields.d.ts +24 -0
  113. package/lib/prompt/register-fields.js +37 -0
  114. package/lib/pull/features/apig.js +57 -6
  115. package/lib/pull/features/client.js +107 -24
  116. package/lib/pull/features/functions/index.js +100 -4
  117. package/lib/pull/index.js +1 -1
  118. package/lib/pull/utils.d.ts +13 -0
  119. package/lib/pull/utils.js +20 -0
  120. package/lib/repl-server.d.ts +4 -0
  121. package/lib/repl-server.js +9 -0
  122. package/lib/serve/features/appsail.js +2 -45
  123. package/lib/serve/server/lib/master/index.js +3 -3
  124. package/lib/serve/server/lib/slate/static-server.js +2 -2
  125. package/lib/serve/server/lib/web_client/server.js +2 -2
  126. package/lib/shell/format-functions.d.ts +4 -0
  127. package/lib/shell/format-functions.js +59 -0
  128. package/lib/shell/index.js +18 -0
  129. package/lib/util_modules/config/lib/appsail.d.ts +3 -2
  130. package/lib/util_modules/config/lib/appsail.js +21 -5
  131. package/lib/util_modules/config/lib/slate.d.ts +19 -0
  132. package/lib/util_modules/config-store.d.ts +1 -0
  133. package/lib/util_modules/config-store.js +29 -10
  134. package/lib/util_modules/constants/index.d.ts +0 -1
  135. package/lib/util_modules/constants/index.js +1 -3
  136. package/lib/util_modules/constants/lib/urls.d.ts +2 -0
  137. package/lib/util_modules/constants/lib/urls.js +4 -0
  138. package/lib/util_modules/dc.d.ts +6 -1
  139. package/lib/util_modules/dc.js +21 -8
  140. package/lib/util_modules/env.d.ts +3 -0
  141. package/lib/util_modules/env.js +41 -0
  142. package/lib/util_modules/fs/lib/sync.d.ts +1 -0
  143. package/lib/util_modules/fs/lib/sync.js +19 -0
  144. package/lib/util_modules/logger/utils.d.ts +1 -0
  145. package/lib/util_modules/logger/utils.js +5 -1
  146. package/lib/util_modules/option.d.ts +1 -0
  147. package/lib/util_modules/option.js +8 -0
  148. package/lib/util_modules/{server.js → server/index.js} +3 -3
  149. package/lib/util_modules/server/needed-scopes.d.ts +1 -0
  150. package/lib/util_modules/{constants/lib → server}/needed-scopes.js +7 -7
  151. package/package.json +3 -2
  152. package/lib/init/features/appsail/utils.js +0 -273
  153. package/lib/util_modules/constants/lib/needed-scopes.d.ts +0 -4
  154. /package/lib/docs/{dc.toml → util_modules/dc.toml} +0 -0
  155. /package/lib/util_modules/{server.d.ts → server/index.d.ts} +0 -0
@@ -105,12 +105,211 @@ function getEnvironmentType() {
105
105
  return isProduction ? 'Production' : 'Development';
106
106
  }
107
107
  function slateLogger() {
108
- const deployTargets = runtime_store_1.default.get('context.payload.slate.targets', []);
109
- deployTargets.forEach((slate) => {
108
+ return __awaiter(this, arguments, void 0, function* (opts = {}) {
110
109
  var _a, _b;
111
- (0, logger_1.labeled)(`Slate(${slate.name})`, 'Deploy is live!').SUCCESS();
112
- (0, logger_1.labeled)((0, ansi_colors_1.cyan)(`Build Url(${slate.name})`), `${urls_1.default.console}/baas/${(0, project_1.getEnvId)()}/project/${(0, project_1.getProjectId)()}/${getEnvironmentType()}#/slate/app/${(_a = slate.details) === null || _a === void 0 ? void 0 : _a.id}/deployment/${(_b = slate.details) === null || _b === void 0 ? void 0 : _b.deployment_type_config.upcoming_build.deployment_id}/overview`).MESSAGE();
110
+ const { wait = true } = opts;
111
+ const deployTargets = runtime_store_1.default.get('context.payload.slate.targets', []);
112
+ const env = getEnvironmentType();
113
+ const failedBuilds = [];
114
+ for (const slate of deployTargets) {
115
+ (0, logger_1.labeled)(`Slate(${slate.name})`, 'Deploy initiated!').SUCCESS();
116
+ (0, logger_1.labeled)((0, ansi_colors_1.cyan)(`Build Url(${slate.name})`), `${urls_1.default.console}/baas/${(0, project_1.getEnvId)()}/project/${(0, project_1.getProjectId)()}/${env}#/slate/app/${(_a = slate.details) === null || _a === void 0 ? void 0 : _a.id}/deployment/${(_b = slate.details) === null || _b === void 0 ? void 0 : _b.deployment_type_config.upcoming_build.deployment_id}/overview`).MESSAGE();
117
+ (0, logger_1.info)();
118
+ if (wait) {
119
+ const buildSucceeded = yield pollSlateDeployStatus(slate, env);
120
+ if (!buildSucceeded) {
121
+ failedBuilds.push(slate.name);
122
+ }
123
+ }
124
+ }
125
+ return deployTargets.filter((t) => !failedBuilds.includes(t.name));
126
+ });
127
+ }
128
+ const TERMINAL_BUILD_STATES = new Set(['success', 'failure', 'failed', 'cancelled', 'canceled']);
129
+ const POLL_INTERVAL_MS = 3000;
130
+ const MAX_POLLS = 200;
131
+ const MAX_CONSECUTIVE_STATUS_ERRORS = 5;
132
+ function pollSlateDeployStatus(slate, env) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ var _a, _b;
135
+ const details = slate.details;
136
+ const upcomingBuild = (_a = details === null || details === void 0 ? void 0 : details.deployment_type_config) === null || _a === void 0 ? void 0 : _a.upcoming_build;
137
+ if (!(upcomingBuild === null || upcomingBuild === void 0 ? void 0 : upcomingBuild.id)) {
138
+ (0, logger_1.debug)('No upcoming build info found, skipping poll for ' + slate.name);
139
+ return false;
140
+ }
141
+ const appId = details.id;
142
+ const buildId = upcomingBuild.id;
143
+ const deploymentId = upcomingBuild.deployment_id;
144
+ const api = yield (0, endpoints_1.slateAPI)({ env });
145
+ const throbber = throbber_1.default.getInstance();
146
+ const spinnerName = `slate_poll_${slate.name}`;
147
+ let nextToken;
148
+ let pollCount = 0;
149
+ let consecutiveStatusErrors = 0;
150
+ let logHeaderPrinted = false;
151
+ let quitRequested = false;
152
+ let wakeUp;
153
+ const hintSuffix = ' ' + (0, ansi_colors_1.gray)('(Press Ctrl+C to stop watching logs)');
154
+ const onSigint = () => {
155
+ quitRequested = true;
156
+ throbber.remove(spinnerName);
157
+ if (logHeaderPrinted) {
158
+ printLogSectionFooter();
159
+ }
160
+ (0, logger_1.info)((0, ansi_colors_1.gray)(' Stopped watching. The build is still running in the background.'));
161
+ (0, logger_1.info)((0, ansi_colors_1.gray)(' Check the Build URL above to monitor progress.'));
162
+ (0, logger_1.info)();
163
+ if (wakeUp)
164
+ wakeUp();
165
+ };
166
+ process.once('SIGINT', onSigint);
167
+ const interruptibleSleep = (ms) => new Promise((resolve) => {
168
+ const timer = setTimeout(resolve, ms);
169
+ wakeUp = () => {
170
+ clearTimeout(timer);
171
+ resolve();
172
+ };
173
+ });
174
+ throbber.add(spinnerName, { text: `Building Slate[${slate.name}]...${hintSuffix}` });
175
+ while (pollCount < MAX_POLLS) {
176
+ yield interruptibleSleep(POLL_INTERVAL_MS);
177
+ if (quitRequested)
178
+ break;
179
+ pollCount++;
180
+ try {
181
+ const logsData = yield api.getBuildLogs(appId, deploymentId, buildId, nextToken);
182
+ if (((_b = logsData.records) === null || _b === void 0 ? void 0 : _b.length) > 0) {
183
+ throbber.remove(spinnerName);
184
+ if (!logHeaderPrinted) {
185
+ printLogSectionHeader(slate.name);
186
+ logHeaderPrinted = true;
187
+ }
188
+ for (const record of logsData.records) {
189
+ try {
190
+ const { message } = JSON.parse(record);
191
+ const clean = sanitizeLogMessage(message);
192
+ if (clean) {
193
+ (0, logger_1.info)((0, ansi_colors_1.dim)(` ${clean}`));
194
+ }
195
+ }
196
+ catch (_c) {
197
+ }
198
+ }
199
+ nextToken = logsData.next_token || nextToken;
200
+ throbber.add(spinnerName, {
201
+ text: `Building Slate[${slate.name}]...${hintSuffix}`
202
+ });
203
+ }
204
+ else {
205
+ nextToken = logsData.next_token || nextToken;
206
+ }
207
+ }
208
+ catch (logErr) {
209
+ (0, logger_1.debug)(`Build log fetch error (poll ${pollCount}): ` +
210
+ error_1.default.getErrorInstance(logErr).message);
211
+ }
212
+ let buildInfo;
213
+ try {
214
+ buildInfo = yield api.getBuildStatus(appId, deploymentId, buildId);
215
+ consecutiveStatusErrors = 0;
216
+ }
217
+ catch (statusErr) {
218
+ const err = error_1.default.getErrorInstance(statusErr);
219
+ consecutiveStatusErrors++;
220
+ if (err.status === 401 || err.status === 403) {
221
+ process.removeListener('SIGINT', onSigint);
222
+ throbber.remove(spinnerName);
223
+ (0, logger_1.error)(`Authentication error while polling Slate[${slate.name}] build status: ${err.message}`);
224
+ (0, logger_1.info)();
225
+ return false;
226
+ }
227
+ if (consecutiveStatusErrors >= MAX_CONSECUTIVE_STATUS_ERRORS) {
228
+ process.removeListener('SIGINT', onSigint);
229
+ throbber.remove(spinnerName);
230
+ (0, logger_1.warning)(`Build status polling for Slate[${slate.name}] failed after ` +
231
+ `${consecutiveStatusErrors} consecutive errors. Last error: ${err.message}. ` +
232
+ `Check the console for the current build status.`);
233
+ (0, logger_1.info)();
234
+ return false;
235
+ }
236
+ (0, logger_1.debug)(`Build status error (poll ${pollCount}, consecutive: ${consecutiveStatusErrors}): ` +
237
+ err.message);
238
+ throbber.add(spinnerName, {
239
+ text: `Building Slate[${slate.name}]... [retrying status check]${hintSuffix}`
240
+ });
241
+ }
242
+ if (buildInfo) {
243
+ const statusLower = (buildInfo.status || '').toLowerCase();
244
+ if (TERMINAL_BUILD_STATES.has(statusLower)) {
245
+ process.removeListener('SIGINT', onSigint);
246
+ throbber.remove(spinnerName);
247
+ if (logHeaderPrinted) {
248
+ printLogSectionFooter();
249
+ }
250
+ if (statusLower === 'success') {
251
+ (0, logger_1.labeled)(`Slate(${slate.name})`, 'Build completed successfully!').SUCCESS();
252
+ yield printDeploymentUrl(api, slate.name, appId, deploymentId);
253
+ (0, logger_1.info)();
254
+ return true;
255
+ }
256
+ (0, logger_1.labeled)(`Slate(${slate.name})`, `Build ended with status: ${buildInfo.status}`).ERROR();
257
+ (0, logger_1.info)();
258
+ return false;
259
+ }
260
+ throbber.add(spinnerName, {
261
+ text: `Building Slate[${slate.name}]... [${buildInfo.status}]`
262
+ });
263
+ }
264
+ }
265
+ process.removeListener('SIGINT', onSigint);
266
+ if (quitRequested) {
267
+ process.exit(0);
268
+ }
269
+ throbber.remove(spinnerName);
270
+ if (logHeaderPrinted) {
271
+ printLogSectionFooter();
272
+ }
273
+ (0, logger_1.warning)(`Build polling timed out for Slate[${slate.name}]. Check console for build status.`);
113
274
  (0, logger_1.info)();
275
+ return false;
276
+ });
277
+ }
278
+ function sanitizeLogMessage(msg) {
279
+ if (!msg)
280
+ return '';
281
+ let out = msg.replace(/<[^>]+>/g, ' ');
282
+ out = out.replace(/\b\d{1,2}:\d{2}:\d{2}(?::\d{1,3})?\b/g, ' ');
283
+ out = out.replace(/:\d{3}\b/g, ' ');
284
+ out = out.replace(/\[.*?\]/g, ' ');
285
+ return out.replace(/\s+/g, ' ').trim();
286
+ }
287
+ function printLogSectionHeader(slateName) {
288
+ const cols = process.stdout.columns || 80;
289
+ const label = ` Build Output (${slateName}) `;
290
+ const lineLen = Math.max(0, cols - label.length - 4);
291
+ const line = '─'.repeat(Math.floor(lineLen / 2));
292
+ (0, logger_1.info)((0, ansi_colors_1.gray)(` ${line}${label}${line}`));
293
+ (0, logger_1.info)();
294
+ }
295
+ function printLogSectionFooter() {
296
+ const cols = process.stdout.columns || 80;
297
+ (0, logger_1.info)();
298
+ (0, logger_1.info)((0, ansi_colors_1.gray)(` ${'─'.repeat(Math.max(0, cols - 4))}`));
299
+ (0, logger_1.info)();
300
+ }
301
+ function printDeploymentUrl(api, slateName, appId, deploymentId) {
302
+ return __awaiter(this, void 0, void 0, function* () {
303
+ try {
304
+ const deployment = yield api.getDeployment(appId, deploymentId);
305
+ const appUrl = deployment.domain || deployment.origin_domain;
306
+ if (appUrl) {
307
+ (0, logger_1.labeled)((0, ansi_colors_1.cyan)(`App Url(${slateName})`), appUrl).MESSAGE();
308
+ }
309
+ }
310
+ catch (err) {
311
+ (0, logger_1.debug)(`Could not fetch deployment URL for Slate[${slateName}]: ` +
312
+ error_1.default.getErrorInstance(err).message);
313
+ }
114
314
  });
115
- return deployTargets;
116
315
  }
@@ -23,11 +23,6 @@ context = '''Error when ${arg[0]} the Client with the ${arg[1]} plugin.'''
23
23
  aid = '''Please rectify the below error to continue. \n${arg[2]}'''
24
24
  link = ''
25
25
 
26
- [CLIENT-UTILS-6]
27
- context = '''Client Setup Skipped: Since the consent to overwrite the existing directory was not given.'''
28
- aid = '''Existing directory: ${arg[0]}'''
29
- link = ''
30
-
31
26
  [CLIENT-UTILS-7]
32
27
  context = '''${arg[0]} cannot be same as the ${arg[1]} page: ${arg[2]}'''
33
28
  aid = '''Please configure a differnet value for ${arg[0]} page.'''
@@ -1,5 +1,5 @@
1
1
  [RC-1]
2
- context = '''The project(${arg[0]}) provided with the ${arg[1]} option is not available is not available in the ${arg[3]} org.'''
2
+ context = '''The project(${arg[0]}) provided with the ${arg[1]} option 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
4
  link = 'https://docs.catalyst.zoho.com/en/cli/v1/initialize-resources/initialize-new-project/'
5
5
 
@@ -29,3 +29,11 @@ ${arg[0]} ${arg[1]}
29
29
  ${arg[2]} ${arg[3]}'''
30
30
  aid = '''Please ensure you've logged-in with the correct user credentials.'''
31
31
  link = ''
32
+
33
+ [RC-7]
34
+ context = '''The provided value(${arg[0]}) for option ${arg[1]} is not valid.'''
35
+ aid = '''Please use one of the available orgs with the ${arg[1]} option or specify the correct org.
36
+
37
+ The available orgs are:
38
+ ${arg[2]}
39
+ '''
@@ -32,3 +32,7 @@ link = 'https://www.zoho.com/catalyst/help/web-client-hosting.html#Older_Version
32
32
  context = '''Only the live version(${arg[0]}) of the web client is available in the Catalyst Remote Console, and a live web client cannot be deleted.'''
33
33
  aid = '''You can deploy a new version of the web client that will make the ${arg[0]} version eligible for deletion.'''
34
34
  link = 'https://www.zoho.com/catalyst/help/web-client-hosting.html#Older_Version'
35
+
36
+ [CDEL-8]
37
+ context = '''Remote deletion of the web client is not possible in non-interactive mode.'''
38
+ aid = '''Please disable the non-interactive mode and try again.'''
@@ -0,0 +1,3 @@
1
+ [E_NON_INTERACTIVE_MODE_SLATE_NAME_REQUIRED]
2
+ context = '''Slate app name is required in non-interactive mode. Please provide the name of the Slate app to deploy.'''
3
+ aid = '''Example: ${arg[0]}'''
@@ -27,3 +27,13 @@ link = 'https://www.zoho.com/catalyst/help/cli-deploy.html'
27
27
  context = '''The function ${arg[0]} is not available in the Catalyst remote console.'''
28
28
  aid = '''The available functions are: \n${arg[1]}'''
29
29
  link = 'https://www.zoho.com/catalyst/help/cli-functions.html#Delete'
30
+
31
+ [FDEL-7]
32
+ context = '''Remote deletion of the function is not possible in non-interactive mode.'''
33
+ aid = '''Please run the command in interactive mode to use the remote option.'''
34
+
35
+ [FDEL-8]
36
+ context = '''Function name input is missing in non-interactive mode.'''
37
+ aid = '''Please provide the function name as an argument when running the command in non-interactive mode.
38
+ Example: ${arg[0]}
39
+ '''
@@ -3,21 +3,6 @@ context = '''${arg[0]} command does not support the execution of ${arg[1]} type
3
3
  aid = '''The supported function types are: \n${arg[3]}'''
4
4
  link = ''
5
5
 
6
- [FEXE-2]
7
- context = '''Unable to read the ${arg[0]} inputs file.'''
8
- aid = '''Please rectify the below error to continue: \n${arg[1]}'''
9
- link = ''
10
-
11
- [FEXE-3]
12
- context = '''Unable to find any inputs to execute the function.'''
13
- aid = '''Please provide the inputs to execute the function in a ${arg[0]} file inside the functions source directory or specify the path to inputs file in the ${arg[1]} file of the function, under the ${arg[2]} key.'''
14
- link = ''
15
-
16
- [FEXE-4]
17
- context = '''The input provided with the ${arg[0]} option is not present among the available input keys.'''
18
- aid = '''The available input keys are: \n${arg[1]}'''
19
- link = ''
20
-
21
6
  [FEXE-5]
22
7
  context = '''The input ${arg[0]} is an Invalid input.'''
23
8
  aid = '''Please provide a valid input. The input should be a valid json object string.'''
@@ -25,5 +10,5 @@ link = ''
25
10
 
26
11
  [FEXE-6]
27
12
  context = '''Invalid JSON input. Error when parsing the provided JSON. \n ${arg[0]}'''
28
- aid = '''Please provide a valid JSON object string'''
13
+ aid = '''Please provide a valid JSON string using --input <value>. For piped stdin, use --input -.'''
29
14
  link = ''
@@ -0,0 +1,3 @@
1
+ [E_NON_INTERACTIVE_MODE_FUNCTIONS_SETUP]
2
+ context = '''The ${arg[0]} command is disabled in ${arg[1]} mode.'''
3
+ aid = '''Please use the ${arg[2]} command to add functions in ${arg[1]} mode.'''
@@ -2,3 +2,11 @@
2
2
  context = '''Tunneling has not yet been configured for your project ${arg[0]}.'''
3
3
  aid = '''Please visit this link to get started: ${arg[1]}'''
4
4
  link = ''
5
+
6
+ [FSHELL-2]
7
+ context = '''The ${arg[0]} command cannot be run in ${arg[1]} mode. Please run the command in interactive mode.'''
8
+ aid = '''Alternatively, you can use the ${arg[2]} command to execute non-http functions such as Event, Cron, Job and Integration functions in non-interactive mode.
9
+
10
+ For command usage details, run:
11
+ ${arg[3]}
12
+ '''
@@ -0,0 +1,3 @@
1
+ [E_NON_INTERACTIVE_FEATURE_INIT]
2
+ context = '''Non-interactive mode is only supported for project initialization.'''
3
+ aid = '''Please run the command without --ni or --non-interactive flag to initialize other features.'''
@@ -0,0 +1,6 @@
1
+ [E_NON_INTERACTIVE_PULL_NO_FEATURE]
2
+ context = '''Missing ${arg[0]} argument. In Non-Interactive mode the feature to pull must be specified using an argument.'''
3
+ aid = '''Use the ${arg[0]} argument to specify the feature to pull in non-interactive mode.
4
+
5
+ Example: ${arg[1]}
6
+ '''
@@ -7,3 +7,9 @@ link = ''
7
7
  context = '''No slate app linked with the given name.'''
8
8
  aid = '''Please check the available slate apps by running the command ${arg[0]} without any options.'''
9
9
  link = ''
10
+
11
+ [SLULK-3]
12
+ context = '''No slate app linked with the given name. Please specify the name of an existing slate app.'''
13
+ aid = '''List of available slate apps:
14
+ ${arg[0]}
15
+ '''
@@ -0,0 +1,14 @@
1
+ [FEXE-2]
2
+ context = '''Unable to read the ${arg[0]} inputs file.'''
3
+ aid = '''Please rectify the below error to continue: \n${arg[1]}'''
4
+ link = ''
5
+
6
+ [FEXE-3]
7
+ context = '''Unable to find any inputs to execute the function.'''
8
+ aid = '''Please provide the inputs to execute the function in a ${arg[0]} file inside the functions source directory or specify the path to inputs file in the ${arg[1]} file of the function, under the ${arg[2]} key.'''
9
+ link = ''
10
+
11
+ [FEXE-4]
12
+ context = '''The input provided with the ${arg[0]} option is not present among the available input keys.'''
13
+ aid = '''The available input keys are: \n${arg[1]}'''
14
+ link = ''
@@ -0,0 +1,37 @@
1
+ [FEXE-6]
2
+ # FEXE-6 exists in both src/docs/commands/functions/execute.toml and src/docs/execute/execute-input-resolver.toml.
3
+ # The context and aid are identical in both files, indicating that this error message is relevant to both the command execution
4
+ # and input resolution processes.
5
+ context = '''Invalid JSON input. Error when parsing the provided JSON. \n ${arg[0]}'''
6
+ aid = '''Please provide a valid JSON string using --input <value>. For piped stdin, use --input -.'''
7
+ link = ''
8
+
9
+ [FEXE-7]
10
+ context = '''No usable input found for ${arg[0]}.'''
11
+ aid = '''Provide one of: inline JSON (--input '{"k":{}}'), a JSON file path (--input ./input.json), or piped stdin (--input -).'''
12
+ link = ''
13
+
14
+ [FEXE-8]
15
+ context = '''Timed out while waiting for input from stdin via ${arg[0]}.'''
16
+ aid = '''Ensure data is being piped and the stream completes. Example: echo '{"k":{}}' | catalyst functions:execute <fn> --input -'''
17
+ link = ''
18
+
19
+ [FEXE-9]
20
+ context = '''Cannot read stdin because ${arg[0]} requires piped or redirected input.'''
21
+ aid = '''Run the command with piped stdin or use a file/inline value with --input.'''
22
+ link = ''
23
+
24
+ [FEXE-10]
25
+ context = '''Empty stdin received for ${arg[0]}.'''
26
+ aid = '''Pipe non-empty JSON content and use --input -.'''
27
+ link = ''
28
+
29
+ [FEXE-11]
30
+ context = '''Input file not found: ${arg[0]}'''
31
+ aid = '''Provide a valid JSON file path with --input, or use inline JSON / --input -.'''
32
+ link = ''
33
+
34
+ [FEXE-12]
35
+ context = '''Unable to read input source: ${arg[0]}'''
36
+ aid = '''Ensure the input source is inside the project directory and readable, then retry with --input.'''
37
+ link = ''
@@ -0,0 +1,20 @@
1
+ [E_NON_INTERACTIVE_MISSING_INPUTS_ORG_OPT]
2
+ context = '''Catalyst init in Non-Interactive mode requires the OrgId to be passed as an option with the command.'''
3
+ aid = '''Please use the ${arg[0]} option to specify the org.
4
+
5
+ Example: ${arg[1]}
6
+
7
+ The following orgs are available:
8
+ ${arg[2]}
9
+ '''
10
+
11
+ [E_NON_INTERACTIVE_MISSING_INPUTS_PROJECT_OPT]
12
+ context = '''Catalyst init in Non-Interactive mode requires the ProjectId to be passed as an option with the command.'''
13
+ aid = '''Please use the ${arg[0]} option to specify the org.
14
+
15
+ Example: ${arg[1]}
16
+
17
+ The following orgs are available:
18
+ ${arg[2]}
19
+ '''
20
+
@@ -0,0 +1,4 @@
1
+ [CLIENT-UTILS-6]
2
+ context = '''Client Setup Skipped: Since the consent to overwrite the existing directory was not given.'''
3
+ aid = '''Existing directory: ${arg[0]}'''
4
+ link = ''
@@ -0,0 +1,15 @@
1
+ [E_NON_INTERACTIVE_MISSING_INPUTS]
2
+ context = '''Non-interactive mode requires prepared inputs for: ${arg[0]}.'''
3
+ aid = '''${arg[1]} \n\nCheckout the below command to get the list of supported inputs.\n ${arg[2]}\n'''
4
+
5
+ [E_RUNTIME_PROMPT_NO_MATCH]
6
+ context = '''No list choice matches "${arg[0]}" for prompt "${arg[1]}".'''
7
+ aid = '''Please provide a valid choice for the prompt.
8
+
9
+ Available choices are:
10
+ ${arg[2]}.
11
+ '''
12
+
13
+ [E_NON_INTERACTIVE_MISSING_INPUTS_ANY]
14
+ context = '''${arg[0]}'''
15
+ aid = '''${arg[1]}'''
@@ -0,0 +1,6 @@
1
+ [E_NON_INTERACTIVE_APIG_PULL_OVERWRITE]
2
+ context = '''APIG pull failed. Since the APIG rules file already exists in the location ${arg[0]}'''
3
+ aid = '''Use the ${arg[1]} option to overwrite the file in local.
4
+
5
+ Example: ${arg[2]}
6
+ '''
@@ -0,0 +1,20 @@
1
+ [E_NON_INTERACTIVE_CLIENT_PULL_NO_RESOURCE]
2
+ context = '''Missing ${arg[0]} option In Non-Interactive mode the web client version to pull must be specified using the ${arg[0]} option.'''
3
+ aid = '''Use the ${arg[0]} option to specify the functions to pull in non-interactive mode.
4
+
5
+ For example: ${arg[1]}
6
+
7
+ Available functions to pull:
8
+ ${arg[2]}
9
+ '''
10
+
11
+ [E_NON_INTERACTIVE_CLIENT_PULL_NO_OVERWRITE]
12
+ context = '''Web Client pull failed. Since the Web Client directory already exists in the location ${arg[0]}'''
13
+ aid = '''Use the ${arg[1]} option to overwrite the folder in local.
14
+
15
+ Example: ${arg[2]}
16
+ '''
17
+
18
+ [E_NON_INTERACTIVE_CLIENT_PULL_MULTIPLE_RESOURCES]
19
+ context = '''Multiple web client versions are specified in the ${arg[0]} option. In Non-Interactive mode only one web client version can be specified using the ${arg[0]} option.'''
20
+ aid = '''Use the ${arg[0]} option to specify only one web client version to pull in non-interactive mode.'''
@@ -0,0 +1,24 @@
1
+ [E_NON_INTERACTIVE_FNS_PULL-1]
2
+ context = '''In Non-Interactive mode the functions to pull must be specified using the ${arg[0]} option.'''
3
+ aid = '''Use the ${arg[0]} option to specify the functions to pull in non-interactive mode.
4
+
5
+ For example: ${arg[1]}
6
+
7
+ Available functions to pull:
8
+ ${arg[2]}
9
+ '''
10
+
11
+ [E_NON_INTERACTIVE_FNS_PULL-2]
12
+ context = '''The functions specified in the ${arg[0]} option is not valid.'''
13
+ aid = '''Use the ${arg[1]} option to specify only the valid functions to pull in non-interactive mode.
14
+
15
+ Valid functions to pull:
16
+ ${arg[2]}
17
+ '''
18
+
19
+ [E_NON_INTERACTIVE_FNS_PULL-3]
20
+ context = '''Unable to pull as the function with the same name${arg[0]} already exists in the local environment.'''
21
+ aid = '''Use the ${arg[1]} command with the ${arg[2]} option to overwrite the existing function in the local environment.
22
+
23
+ Example: ${arg[3]}
24
+ '''
@@ -1,6 +1,16 @@
1
1
  import { ReadStream } from 'fs-extra';
2
2
  import { IAPIOptions } from '../../internal/api';
3
- import { FrameworkType, ISlateAppInfo } from '../../util_modules/config/lib/slate';
3
+ import { FrameworkType, ISlateAppInfo, ISlateDeploymentInfo, SlateBuildInfo } from '../../util_modules/config/lib/slate';
4
+ export interface ISlateBuildLogRecord {
5
+ _zl_timestamp: number;
6
+ job_id: string;
7
+ message: string;
8
+ }
9
+ export interface ISlateBuildLogsResponse {
10
+ identifier: number;
11
+ records: Array<string>;
12
+ next_token: string;
13
+ }
4
14
  declare class Slate {
5
15
  opts: IAPIOptions;
6
16
  projectId: string;
@@ -11,5 +21,8 @@ declare class Slate {
11
21
  getAllApps(): Promise<Array<ISlateAppInfo>>;
12
22
  downloadTemplate(): Promise<unknown>;
13
23
  deploy(sourceStream: ReadStream, contentLength: number, appName: string, deploymentName?: string, appId?: string, config?: string, msg?: string): Promise<unknown>;
24
+ getBuildStatus(appId: string, deploymentId: string, buildId: string): Promise<SlateBuildInfo>;
25
+ getBuildLogs(appId: string, deploymentId: string, buildId: string, nextToken?: string, limit?: number): Promise<ISlateBuildLogsResponse>;
26
+ getDeployment(appId: string, deploymentId: string): Promise<ISlateDeploymentInfo>;
14
27
  }
15
28
  export default Slate;
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const error_1 = __importDefault(require("../../error"));
16
16
  const api_1 = __importDefault(require("../../internal/api"));
17
17
  const logger_1 = require("../../util_modules/logger");
18
+ const constants_1 = require("../../util_modules/constants");
18
19
  class Slate {
19
20
  constructor(projectId, opts) {
20
21
  this.opts = opts;
@@ -87,5 +88,39 @@ class Slate {
87
88
  });
88
89
  });
89
90
  }
91
+ getBuildStatus(appId, deploymentId, buildId) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ const response = yield new api_1.default(Object.assign({ origin: constants_1.ORIGIN.zgraphql }, this.opts)).get(`/slate/v1/project/${this.projectId}/app/${appId}/deployment/${deploymentId}/build/${buildId}`);
94
+ if (response.body && response.body.data) {
95
+ return response.body.data;
96
+ }
97
+ (0, logger_1.debug)('get build status response from server : ' + response.body);
98
+ throw new error_1.default('Error while fetching build status', { exit: 2 });
99
+ });
100
+ }
101
+ getBuildLogs(appId_1, deploymentId_1, buildId_1, nextToken_1) {
102
+ return __awaiter(this, arguments, void 0, function* (appId, deploymentId, buildId, nextToken, limit = 50) {
103
+ const qs = { limit };
104
+ if (nextToken) {
105
+ qs.next_token = nextToken;
106
+ }
107
+ const response = yield new api_1.default(Object.assign({ origin: constants_1.ORIGIN.zgraphql }, this.opts)).get(`/slate/v1/project/${this.projectId}/app/${appId}/deployment/${deploymentId}/build/${buildId}/logs`, { qs });
108
+ if (response.body && response.body.data) {
109
+ return response.body.data;
110
+ }
111
+ (0, logger_1.debug)('get build logs response from server : ' + response.body);
112
+ throw new error_1.default('Error while fetching build logs', { exit: 2 });
113
+ });
114
+ }
115
+ getDeployment(appId, deploymentId) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ const response = yield new api_1.default(Object.assign({ origin: constants_1.ORIGIN.zgraphql }, this.opts)).get(`/slate/v1/project/${this.projectId}/app/${appId}/deployment/${deploymentId}`);
118
+ if (response.body && response.body.data) {
119
+ return response.body.data;
120
+ }
121
+ (0, logger_1.debug)('get deployment response from server : ' + response.body);
122
+ throw new error_1.default('Error while fetching deployment details', { exit: 2 });
123
+ });
124
+ }
90
125
  }
91
126
  exports.default = Slate;
@@ -24,7 +24,7 @@ function help() {
24
24
  };
25
25
  };
26
26
  logKeys.forEach((key) => {
27
- const errQueue = logs[key];
27
+ const errQueue = logs[key].filter((err) => !err.skipHelp);
28
28
  if (!Array.isArray(errQueue) || errQueue.length === 0) {
29
29
  return;
30
30
  }
@@ -17,20 +17,16 @@ class CatalystError extends Error {
17
17
  this.arg = options.arg;
18
18
  this.skipHelp = options.skipHelp || false;
19
19
  try {
20
- if (!this.skipHelp) {
21
- const stackArr = ((_a = this.stack) === null || _a === void 0 ? void 0 : _a.split(/\n {4}at /)) || [];
22
- const errorPath = options.filePath === undefined && stackArr[1] !== undefined
23
- ? stackArr[1].replace(/\.[^.]+$/, '').replace(/^[^(]+\(/, '')
24
- : (_b = options.filePath) === null || _b === void 0 ? void 0 : _b.replace(/\.[^.]+$/, '');
25
- if (!errorPath) {
26
- throw new CatalystError('Invalid error path', { skipHelp: true });
27
- }
28
- options.docPath = options.docPath || DEFAULT_DOC;
29
- this.filePath = errorPath.replace((0, path_1.dirname)(options.docPath), options.docPath);
30
- utils_js_1.runtime.set(['context.log', this.filePath], utils_js_1.runtime
31
- .get(['context.log', this.filePath], [])
32
- .concat(this));
20
+ const stackArr = ((_a = this.stack) === null || _a === void 0 ? void 0 : _a.split(/\n {4}at /)) || [];
21
+ const errorPath = options.filePath === undefined && stackArr[1] !== undefined
22
+ ? stackArr[1].replace(/\.[^.]+$/, '').replace(/^[^(]+\(/, '')
23
+ : (_b = options.filePath) === null || _b === void 0 ? void 0 : _b.replace(/\.[^.]+$/, '');
24
+ if (!errorPath) {
25
+ throw new CatalystError('Invalid error path', { skipHelp: true });
33
26
  }
27
+ options.docPath = options.docPath || DEFAULT_DOC;
28
+ this.filePath = errorPath.replace((0, path_1.dirname)(options.docPath), options.docPath);
29
+ utils_js_1.runtime.set(['context.log', this.filePath], utils_js_1.runtime.get(['context.log', this.filePath], []).concat(this));
34
30
  }
35
31
  catch (e) {
36
32
  utils_js_1.runtime.set('context.log.faultyError', utils_js_1.runtime.get('context.log.faultyError', []).concat(this));
@@ -0,0 +1,5 @@
1
+ import { IFnTarget } from '../fn-utils/lib/common';
2
+ export declare function getInputs(exeTarget: IFnTarget, inputData?: Record<string, Record<string, unknown>>): Promise<{
3
+ key: string;
4
+ ip?: Record<string, unknown>;
5
+ }>;