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
@@ -12,12 +12,8 @@ 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 path_1 = require("path");
16
15
  const appsail_utils_1 = require("../../appsail-utils");
17
16
  const error_1 = __importDefault(require("../../error"));
18
- const java_1 = require("../../fn-utils/lib/java");
19
- const node_1 = require("../../fn-utils/lib/node");
20
- const ensure_python_1 = require("../../init/dependencies/python/ensure-python");
21
17
  const port_resolver_1 = __importDefault(require("../../port-resolver"));
22
18
  const runtime_store_1 = __importDefault(require("../../runtime-store"));
23
19
  const config_1 = require("../../util_modules/config");
@@ -30,47 +26,8 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
30
26
  (0, index_1.debug)('AppSail targets are empty');
31
27
  return [];
32
28
  }
33
- const validated = yield (0, appsail_utils_1.validateAppSail)(optionTargets);
34
- const binPathMap = {};
35
- yield Promise.all(validated.map((target) => __awaiter(void 0, void 0, void 0, function* () {
36
- var _a;
37
- try {
38
- const stack = (_a = target.config) === null || _a === void 0 ? void 0 : _a.stack;
39
- if (!stack) {
40
- throw new error_1.default(`Stack is not defined for AppSail target ${target.name}`, {
41
- exit: 2
42
- });
43
- }
44
- if (binPathMap[stack]) {
45
- return;
46
- }
47
- switch (true) {
48
- case stack.startsWith('node'): {
49
- binPathMap[stack] = yield (0, node_1.ensureNodeVersion)(stack, true);
50
- break;
51
- }
52
- case stack.startsWith('java'): {
53
- const javaBinPath = yield (0, java_1.ensureJava)(stack);
54
- if (!javaBinPath) {
55
- throw new error_1.default(`Invalid bin path for ${stack}`, { exit: 1 });
56
- }
57
- binPathMap[stack] = javaBinPath;
58
- break;
59
- }
60
- case stack.startsWith('python'): {
61
- const stackVersion = stack.replace('python_', '');
62
- const pyExe = yield (0, ensure_python_1.ensurePython)(stackVersion.replace('_', '.'), false, true);
63
- binPathMap[stack] = (0, path_1.dirname)(pyExe);
64
- break;
65
- }
66
- }
67
- }
68
- catch (err) {
69
- const error = error_1.default.getErrorInstance(err);
70
- target.validity.valid = false;
71
- target.validity.reason = error.message;
72
- }
73
- })));
29
+ const [_validatePromise, binPathMap] = (0, appsail_utils_1.validateAppSail)(optionTargets);
30
+ const validated = yield _validatePromise;
74
31
  const filledTargets = yield Promise.all(validated.map((targ) => __awaiter(void 0, void 0, void 0, function* () {
75
32
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
76
33
  if (!targ.validity.valid) {
@@ -29,7 +29,7 @@ const js_1 = require("../../../../util_modules/js");
29
29
  const index_1 = require("../../../../util_modules/logger/index");
30
30
  const project_2 = require("../../../../util_modules/project");
31
31
  const option_1 = require("../../../../util_modules/option");
32
- const server_js_1 = require("../../../../util_modules/server.js");
32
+ const index_js_1 = require("../../../../util_modules/server/index.js");
33
33
  const utils_1 = require("./utils");
34
34
  const appsail_1 = require("./appsail");
35
35
  const web_client_1 = require("./web-client");
@@ -104,7 +104,7 @@ function spinUpMaster(listenPort_1, _a) {
104
104
  signInRedirect: appSailDetails.target.config.login_redirect || '/'
105
105
  }))
106
106
  : proxy.on('proxyRes', (0, utils_1.proxyResponseHandler)({ systemRoutes, signInRedirect: signRedirectUrl }));
107
- const proxyDestroyer = new server_js_1.ConnectionDestroyer(proxy);
107
+ const proxyDestroyer = new index_js_1.ConnectionDestroyer(proxy);
108
108
  const unknownProxy = (0, unknown_req_proxy_1.default)(proxy, listenPort, customProxyUrl);
109
109
  otherServerDetails &&
110
110
  Object.keys(otherServerDetails).forEach((targ) => {
@@ -148,7 +148,7 @@ function spinUpMaster(listenPort_1, _a) {
148
148
  }
149
149
  console.error(err);
150
150
  });
151
- const expressDestroyer = new server_js_1.ConnectionDestroyer(expressServer);
151
+ const expressDestroyer = new index_js_1.ConnectionDestroyer(expressServer);
152
152
  expressServer.maxConnections = 100;
153
153
  const stopServer = () => expressDestroyer.destroy(!!appSailDetails);
154
154
  utils_1.serverEvent.once('stop', () => {
@@ -24,7 +24,7 @@ const path_1 = require("path");
24
24
  const ws_1 = require("ws");
25
25
  const port_resolver_js_1 = __importDefault(require("../../../../port-resolver.js"));
26
26
  const ansi_colors_1 = require("ansi-colors");
27
- const server_js_1 = require("../../../../util_modules/server.js");
27
+ const index_js_2 = require("../../../../util_modules/server/index.js");
28
28
  const env_1 = require("../../../../util_modules/env");
29
29
  function prepareScriptFile(dir, port) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
@@ -180,7 +180,7 @@ function slateServer(httpPort_1, source_1) {
180
180
  const server = app.listen(httpPort, '127.0.0.1').on('error', (err) => {
181
181
  eventListener.emit('error', err);
182
182
  });
183
- const expressDestroyer = new server_js_1.ConnectionDestroyer(server);
183
+ const expressDestroyer = new index_js_2.ConnectionDestroyer(server);
184
184
  eventListener.on('error', (err) => {
185
185
  (0, logger_1.error)('Error when serving the web-client: ' + err.message);
186
186
  (0, logger_1.info)('Please exit the command to get more info');
@@ -24,7 +24,7 @@ const path_1 = require("path");
24
24
  const ws_1 = require("ws");
25
25
  const port_resolver_js_1 = __importDefault(require("../../../../port-resolver.js"));
26
26
  const ansi_colors_1 = require("ansi-colors");
27
- const server_js_1 = require("../../../../util_modules/server.js");
27
+ const index_js_4 = require("../../../../util_modules/server/index.js");
28
28
  const env_1 = require("../../../../util_modules/env");
29
29
  function prepareScriptFile(dir, port) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
@@ -180,7 +180,7 @@ function webClientServer(httpPort_1, source_1) {
180
180
  const server = app.listen(httpPort, '127.0.0.1').on('error', (err) => {
181
181
  eventListener.emit('error', err);
182
182
  });
183
- const expressDestroyer = new server_js_1.ConnectionDestroyer(server);
183
+ const expressDestroyer = new index_js_4.ConnectionDestroyer(server);
184
184
  eventListener.on('error', (err) => {
185
185
  (0, index_1.error)('Error when serving the web-client: ' + err.message);
186
186
  (0, index_1.info)('Please exit the command to get more info');
@@ -0,0 +1,4 @@
1
+ import { IFnTarget } from '../fn-utils/lib/common';
2
+ export declare function resolveTypeLabel(type?: string): string;
3
+ export declare function resolveLanguage(stack?: string): string | undefined;
4
+ export declare function formatFunctionList(targets: Array<IFnTarget>): string;
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveTypeLabel = resolveTypeLabel;
4
+ exports.resolveLanguage = resolveLanguage;
5
+ exports.formatFunctionList = formatFunctionList;
6
+ const ansi_colors_1 = require("ansi-colors");
7
+ const constants_1 = require("../util_modules/constants");
8
+ const UNGROUPED_TYPE = 'other';
9
+ const TYPE_LABEL_BY_CODE = Object.fromEntries(Object.entries(constants_1.FN_TYPE).map(([label, code]) => [code, label]));
10
+ function resolveTypeLabel(type) {
11
+ if (!type) {
12
+ return UNGROUPED_TYPE;
13
+ }
14
+ return TYPE_LABEL_BY_CODE[type] || type;
15
+ }
16
+ function resolveLanguage(stack) {
17
+ if (!stack) {
18
+ return undefined;
19
+ }
20
+ const { node, java, python } = constants_1.RUNTIME.language;
21
+ if (stack.startsWith(node.value)) {
22
+ return node.label;
23
+ }
24
+ if (stack.startsWith(java.value)) {
25
+ return java.label;
26
+ }
27
+ if (stack.startsWith(python.value)) {
28
+ return python.label;
29
+ }
30
+ return undefined;
31
+ }
32
+ function formatFunctionList(targets) {
33
+ if (!targets || targets.length === 0) {
34
+ return 'No functions are attached to this shell.';
35
+ }
36
+ const groups = new Map();
37
+ for (const target of targets) {
38
+ const type = resolveTypeLabel(target.type);
39
+ const bucket = groups.get(type) || [];
40
+ bucket.push(target);
41
+ groups.set(type, bucket);
42
+ }
43
+ const longestName = targets.reduce((max, target) => Math.max(max, target.name.length), 0);
44
+ const lines = [];
45
+ lines.push((0, ansi_colors_1.bold)(`Available functions (${targets.length}):`));
46
+ lines.push('');
47
+ for (const [type, bucket] of groups) {
48
+ lines.push(' ' + (0, ansi_colors_1.cyan)(type));
49
+ for (const target of bucket) {
50
+ const language = resolveLanguage(target.stack);
51
+ const name = (0, ansi_colors_1.green)(target.name.padEnd(longestName));
52
+ const suffix = language ? ' ' + (0, ansi_colors_1.dim)(`(${language})`) : '';
53
+ lines.push(' • ' + name + suffix);
54
+ }
55
+ }
56
+ lines.push('');
57
+ lines.push((0, ansi_colors_1.dim)('Invoke a function by calling it, e.g. ') + (0, ansi_colors_1.bold)(targets[0].name + '({ ... })'));
58
+ return lines.join('\n');
59
+ }
@@ -59,6 +59,7 @@ const option_1 = require("../util_modules/option");
59
59
  const http_functions_1 = __importDefault(require("./dependencies/http-functions"));
60
60
  const non_http_function_1 = __importDefault(require("./dependencies/non-http-function"));
61
61
  const prepare_1 = __importDefault(require("./prepare"));
62
+ const format_functions_1 = require("./format-functions");
62
63
  const fn_watcher_1 = __importDefault(require("../fn-watcher"));
63
64
  const tunnel_server_1 = __importDefault(require("./dependencies/tunnel-server"));
64
65
  const endpoints_1 = require("../endpoints");
@@ -125,6 +126,9 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
125
126
  });
126
127
  }
127
128
  try {
129
+ (0, index_2.info)();
130
+ (0, index_2.info)((0, format_functions_1.formatFunctionList)(targets));
131
+ (0, index_2.info)();
128
132
  replServer.start();
129
133
  yield tunnelServer.startServer();
130
134
  const tunnelUrl = runtime_store_1.default.get('context.fn_shell.enable_tunnel', undefined);
@@ -167,6 +171,20 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
167
171
  tunnelServer.addContext(target.id || target.name, localFn);
168
172
  target.localFn = localFn;
169
173
  })));
174
+ const listFunctions = () => {
175
+ var _a, _b;
176
+ (_a = replServer.server) === null || _a === void 0 ? void 0 : _a.clearBufferedCommand();
177
+ (0, index_2.info)((0, format_functions_1.formatFunctionList)(targets));
178
+ (_b = replServer.server) === null || _b === void 0 ? void 0 : _b.displayPrompt();
179
+ };
180
+ replServer.defineCommand('functions', {
181
+ help: 'List the Catalyst functions available in this shell',
182
+ action: listFunctions
183
+ });
184
+ replServer.defineCommand('list', {
185
+ help: 'Alias for .functions — list the Catalyst functions available in this shell',
186
+ action: listFunctions
187
+ });
170
188
  if (runtime_store_1.default.get('context.port.http.' + constants_1.FN_TYPE.basic, false)) {
171
189
  yield httpServer.start();
172
190
  }
@@ -4,8 +4,8 @@ export interface IAppSailConfig {
4
4
  command?: string;
5
5
  memory?: number;
6
6
  port?: {
7
- http: number;
8
- debug: number;
7
+ http?: number;
8
+ debug?: number;
9
9
  };
10
10
  }
11
11
  export interface IAppSailServerConfig extends Record<string, unknown> {
@@ -44,6 +44,7 @@ export declare const CONTAINER_IMAGE_PROTOCOLS: {
44
44
  docker: string;
45
45
  dockerArchive: string;
46
46
  };
47
+ export declare function isCustomAppSailSource(source: string): boolean;
47
48
  export declare function raw(throwError?: boolean): Array<TAppSailDetails> | undefined;
48
49
  export declare function getTargetDetails(name: string): Promise<TAppSailDetails | undefined>;
49
50
  export declare function getAllTargetDetails(throwErr?: boolean): Promise<Array<TAppSailDetails> | undefined>;
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CONTAINER_IMAGE_PROTOCOLS = void 0;
16
+ exports.isCustomAppSailSource = isCustomAppSailSource;
16
17
  exports.raw = raw;
17
18
  exports.getTargetDetails = getTargetDetails;
18
19
  exports.getAllTargetDetails = getAllTargetDetails;
@@ -27,7 +28,11 @@ exports.CONTAINER_IMAGE_PROTOCOLS = {
27
28
  docker: 'docker://',
28
29
  dockerArchive: 'docker-archive://'
29
30
  };
30
- function validateConfig(source, configJson) {
31
+ function isCustomAppSailSource(source) {
32
+ return (source.startsWith(exports.CONTAINER_IMAGE_PROTOCOLS.docker) ||
33
+ source.startsWith(exports.CONTAINER_IMAGE_PROTOCOLS.dockerArchive));
34
+ }
35
+ function validateManagedAppConfig(source, configJson) {
31
36
  if (!configJson) {
32
37
  return {
33
38
  valid: false,
@@ -73,6 +78,19 @@ function validateConfig(source, configJson) {
73
78
  };
74
79
  }
75
80
  }
81
+ if (!configJson.stack || configJson.stack.length === 0) {
82
+ return {
83
+ valid: false,
84
+ reason: 'Stack is not defined'
85
+ };
86
+ }
87
+ if (!configJson.command &&
88
+ !(configJson.stack.startsWith('java') && configJson.platform === 'war')) {
89
+ return {
90
+ valid: false,
91
+ reason: 'Start-up command is missing'
92
+ };
93
+ }
76
94
  return {
77
95
  valid: true
78
96
  };
@@ -92,9 +110,7 @@ function raw(throwError = false) {
92
110
  return `${exports.CONTAINER_IMAGE_PROTOCOLS.dockerArchive}${normalized}`;
93
111
  };
94
112
  return appsailConfig === null || appsailConfig === void 0 ? void 0 : appsailConfig.map((_conf) => {
95
- if (Object.values(exports.CONTAINER_IMAGE_PROTOCOLS)
96
- .flat()
97
- .find((proto) => _conf.source.startsWith(proto))) {
113
+ if (isCustomAppSailSource(_conf.source)) {
98
114
  return {
99
115
  name: _conf.name,
100
116
  source: _conf.source.startsWith(exports.CONTAINER_IMAGE_PROTOCOLS.dockerArchive)
@@ -177,7 +193,7 @@ function getAllTargetDetails() {
177
193
  try {
178
194
  const configJson = yield fs_1.ASYNC.readJSONFile(catalystConfigPth);
179
195
  configJson && (configJson.raw = {});
180
- target.validity = validateConfig(target.source, configJson);
196
+ target.validity = validateManagedAppConfig(target.source, configJson);
181
197
  target.config = configJson;
182
198
  return res(target);
183
199
  }
@@ -32,6 +32,25 @@ export interface SlateBuildInfo {
32
32
  deployment_id: string;
33
33
  build_meta: Record<string, unknown>;
34
34
  }
35
+ export interface ISlateDeploymentInfo {
36
+ id: string;
37
+ app_id: string;
38
+ name: string;
39
+ auto_deploy: boolean;
40
+ created_time: string;
41
+ modified_time: string;
42
+ created_by: IAppUpdatedByDetails;
43
+ modified_by: IAppUpdatedByDetails;
44
+ status: string;
45
+ is_function_mapped: boolean;
46
+ org_restriction_enabled: boolean;
47
+ type: string;
48
+ value: string;
49
+ current_build: SlateBuildInfo | null;
50
+ upcoming_build: SlateBuildInfo | null;
51
+ origin_domain: string;
52
+ domain: string;
53
+ }
35
54
  export interface IAppUpdatedByDetails {
36
55
  zuid: string;
37
56
  is_confirmed: boolean;
@@ -1,6 +1,7 @@
1
1
  export default class Store {
2
2
  private static _store;
3
3
  static changeStore(store: 'cli' | 'vscode' | 'zcode', path?: string): void;
4
+ static _lockDownPermissions(): void;
4
5
  private static get istore();
5
6
  static get path(): string | undefined;
6
7
  static get store(): Record<string, unknown>;
@@ -4,46 +4,63 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const conf_1 = __importDefault(require("conf"));
7
+ const fs_1 = require("fs");
7
8
  const path_1 = require("path");
8
9
  const error_1 = __importDefault(require("../error"));
9
10
  const path = process.env['X_ZC_CREDENTIAL_PATH'];
11
+ const CONFIG_FILE_MODE = 0o600;
12
+ const CLI_CONFIG_NAME = 'zcatalyst-cli-v1';
10
13
  class Store {
11
14
  static changeStore(store, path) {
12
15
  switch (store) {
13
16
  case 'cli': {
14
17
  Store._store = new conf_1.default({
15
- configName: 'zcatalyst-cli',
18
+ configName: CLI_CONFIG_NAME,
16
19
  projectName: 'zcatalyst-cli',
17
- cwd: path
20
+ cwd: path,
21
+ configFileMode: CONFIG_FILE_MODE
18
22
  });
19
- return;
23
+ break;
20
24
  }
21
25
  case 'vscode': {
22
26
  Store._store = new conf_1.default({
23
27
  configName: 'auth',
24
28
  projectName: 'zcatalyst-vscode',
25
- cwd: path ? (0, path_1.join)(path, 'zcatalyst-vscode') : undefined
29
+ cwd: path ? (0, path_1.join)(path, 'zcatalyst-vscode') : undefined,
30
+ configFileMode: CONFIG_FILE_MODE
26
31
  });
27
- return;
32
+ break;
28
33
  }
29
34
  case 'zcode': {
30
35
  Store._store = new conf_1.default({
31
36
  configName: 'auth',
32
37
  projectName: 'zcatalyst-zcode',
33
- cwd: path ? (0, path_1.join)(path, 'zcatalyst-code') : undefined
38
+ cwd: path ? (0, path_1.join)(path, 'zcatalyst-code') : undefined,
39
+ configFileMode: CONFIG_FILE_MODE
34
40
  });
35
- return;
41
+ break;
36
42
  }
37
43
  default: {
38
44
  throw new error_1.default('Invalid Store type: ' + store, { exit: 2 });
39
45
  }
40
46
  }
47
+ Store._lockDownPermissions();
48
+ }
49
+ static _lockDownPermissions() {
50
+ try {
51
+ const filePath = Store._store.path;
52
+ if ((0, fs_1.existsSync)(filePath)) {
53
+ (0, fs_1.chmodSync)(filePath, CONFIG_FILE_MODE);
54
+ }
55
+ }
56
+ catch (err) {
57
+ }
41
58
  }
42
59
  static get istore() {
43
60
  return Store._store;
44
61
  }
45
62
  static get path() {
46
- return (0, path_1.join)(this._store.path, '../../');
63
+ return (0, path_1.dirname)(this._store.path);
47
64
  }
48
65
  static get store() {
49
66
  return Store.istore.store;
@@ -65,8 +82,10 @@ class Store {
65
82
  }
66
83
  }
67
84
  Store._store = new conf_1.default({
68
- configName: 'zcatalyst-cli',
85
+ configName: CLI_CONFIG_NAME,
69
86
  projectName: 'zcatalyst-cli',
70
- cwd: path
87
+ cwd: path,
88
+ configFileMode: CONFIG_FILE_MODE
71
89
  });
72
90
  exports.default = Store;
91
+ Store._lockDownPermissions();
@@ -18,7 +18,6 @@ export { default as PLUGIN } from './lib/plugin';
18
18
  export { default as IAC } from './lib/iac';
19
19
  export { default as RUNTIME } from './lib/runtime';
20
20
  export { default as ENVPATH } from './lib/env-path';
21
- export { default as NEEDED_SCOPES } from './lib/needed-scopes';
22
21
  export { default as SIGNALS_PUBLISHERS_TYPE } from './lib/signals-publishers-type';
23
22
  export { default as SIGNALS_PUBLISHERS } from './lib/signals-publishers';
24
23
  export { default as SIGNALS_API_NAMES } from './lib/signals-api-names';
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SIGNALS_API_NAMES = exports.SIGNALS_PUBLISHERS = exports.SIGNALS_PUBLISHERS_TYPE = exports.NEEDED_SCOPES = exports.ENVPATH = exports.RUNTIME = exports.IAC = exports.PLUGIN = exports.ORIGIN = exports.TEMPLATE = exports.REMOTE_REF = exports.REGEX = exports.REFERENCE = exports.PLACEHOLDER = exports.INTEG = exports.FOLDERNAME = exports.FN_TYPE = exports.DC_TYPE = exports.FILENAME = exports.EVENT_SOURCE = exports.EVENT_REF = exports.DEFAULT = exports.CLIQ = exports.APIG_RULES = void 0;
6
+ exports.SIGNALS_API_NAMES = exports.SIGNALS_PUBLISHERS = exports.SIGNALS_PUBLISHERS_TYPE = exports.ENVPATH = exports.RUNTIME = exports.IAC = exports.PLUGIN = exports.ORIGIN = exports.TEMPLATE = exports.REMOTE_REF = exports.REGEX = exports.REFERENCE = exports.PLACEHOLDER = exports.INTEG = exports.FOLDERNAME = exports.FN_TYPE = exports.DC_TYPE = exports.FILENAME = exports.EVENT_SOURCE = exports.EVENT_REF = exports.DEFAULT = exports.CLIQ = exports.APIG_RULES = void 0;
7
7
  var apig_rules_1 = require("./lib/apig-rules");
8
8
  Object.defineProperty(exports, "APIG_RULES", { enumerable: true, get: function () { return __importDefault(apig_rules_1).default; } });
9
9
  var cliq_handlers_1 = require("./lib/cliq-handlers");
@@ -44,8 +44,6 @@ var runtime_1 = require("./lib/runtime");
44
44
  Object.defineProperty(exports, "RUNTIME", { enumerable: true, get: function () { return __importDefault(runtime_1).default; } });
45
45
  var env_path_1 = require("./lib/env-path");
46
46
  Object.defineProperty(exports, "ENVPATH", { enumerable: true, get: function () { return __importDefault(env_path_1).default; } });
47
- var needed_scopes_1 = require("./lib/needed-scopes");
48
- Object.defineProperty(exports, "NEEDED_SCOPES", { enumerable: true, get: function () { return __importDefault(needed_scopes_1).default; } });
49
47
  var signals_publishers_type_1 = require("./lib/signals-publishers-type");
50
48
  Object.defineProperty(exports, "SIGNALS_PUBLISHERS_TYPE", { enumerable: true, get: function () { return __importDefault(signals_publishers_type_1).default; } });
51
49
  var signals_publishers_1 = require("./lib/signals-publishers");
@@ -9,6 +9,7 @@ export default class URL {
9
9
  private static readonly _stratusSuffixBase;
10
10
  private static readonly _zohoCDNBase;
11
11
  private static readonly _contacts;
12
+ private static readonly _zgraphql;
12
13
  static get zohoCDNUS(): string;
13
14
  static get zohoCDN(): string;
14
15
  static get auth(): string;
@@ -18,6 +19,7 @@ export default class URL {
18
19
  static get appSailDomain(): string;
19
20
  static get catalystStatic(): string;
20
21
  static get console(): string;
22
+ static get zgraphql(): string;
21
23
  static get contacts(): string;
22
24
  static get stratusSuffix(): string;
23
25
  static external: Readonly<{
@@ -34,6 +34,9 @@ class URL {
34
34
  static get console() {
35
35
  return (0, env_js_1.envOverride)('CATALYST_CONSOLE_URL', mapDataCenterUrl(URL._consoleBase));
36
36
  }
37
+ static get zgraphql() {
38
+ return (0, env_js_1.envOverride)('CATALYST_ZGRAPHQL_URL', mapDataCenterUrl(URL._zgraphql));
39
+ }
37
40
  static get contacts() {
38
41
  return (0, env_js_1.envOverride)('ZOHO_CONTACTS', mapDataCenterUrl(URL._contacts));
39
42
  }
@@ -51,6 +54,7 @@ URL._consoleBase = 'https://console.catalyst.zoho.com';
51
54
  URL._stratusSuffixBase = '.zohostratus.com';
52
55
  URL._zohoCDNBase = 'https://static.zohocdn.com';
53
56
  URL._contacts = 'https://profile.zoho.com';
57
+ URL._zgraphql = 'https://zgraphql.zoho.com';
54
58
  URL.external = Object.freeze({
55
59
  gitHubAPI: 'https://api.github.com',
56
60
  gitHubWeb: 'https://github.com'
@@ -1,4 +1,9 @@
1
- export declare function getActiveDC(dcOption?: string): string;
1
+ export declare function getActiveDC(): string;
2
+ export declare function getActiveDC(dcOption: string): string;
3
+ export declare function getActiveDC(opts?: {
4
+ dcOption?: string;
5
+ throwError?: boolean;
6
+ }): string | undefined;
2
7
  export declare function getActiveDCType(): {
3
8
  loc: string;
4
9
  value: string;
@@ -7,11 +7,20 @@ exports.getActiveDC = getActiveDC;
7
7
  exports.getActiveDCType = getActiveDCType;
8
8
  exports.updateActiveDC = updateActiveDC;
9
9
  const ansi_colors_1 = require("ansi-colors");
10
- const path_1 = require("path");
11
10
  const config_store_js_1 = __importDefault(require("./config-store.js"));
12
11
  const index_js_1 = __importDefault(require("../error/index.js"));
13
12
  const dc_type_js_1 = __importDefault(require("./constants/lib/dc-type.js"));
14
- function getActiveDC(dcOption) {
13
+ function getActiveDC(opts) {
14
+ switch (typeof opts) {
15
+ case 'string':
16
+ return _getActiveDC({ dcOption: opts, throwError: true });
17
+ case 'object':
18
+ return _getActiveDC(opts);
19
+ default:
20
+ return _getActiveDC();
21
+ }
22
+ }
23
+ function _getActiveDC({ dcOption, throwError = true } = {}) {
15
24
  const envname = 'CATALYST_ACTIVE_DC';
16
25
  if (process.env[envname] !== undefined) {
17
26
  return process.env[envname];
@@ -26,12 +35,16 @@ function getActiveDC(dcOption) {
26
35
  if (typeof dcOption === 'string') {
27
36
  const availableDcs = Object.keys(dc_type_js_1.default);
28
37
  if (!availableDcs.includes(dcOption)) {
29
- throw new index_js_1.default('Provide DC in global option is not valid: ' + dcOption, {
30
- exit: 1,
31
- errorId: 'DC-1',
32
- arg: [ansi_colors_1.bold.red(dcOption), (0, ansi_colors_1.bold)(availableDcs.map((dc) => '* ' + dc).join('\n'))],
33
- docPath: (0, path_1.join)(__dirname, './docs/dc.toml')
34
- });
38
+ if (throwError) {
39
+ throw new index_js_1.default('Provide DC in global option is not valid: ' + dcOption, {
40
+ exit: 1,
41
+ errorId: 'DC-1',
42
+ arg: [ansi_colors_1.bold.red(dcOption), (0, ansi_colors_1.bold)(availableDcs.map((dc) => '* ' + dc).join('\n'))]
43
+ });
44
+ }
45
+ else {
46
+ return;
47
+ }
35
48
  }
36
49
  return dc_type_js_1.default[dcOption].value;
37
50
  }
@@ -4,7 +4,10 @@ export declare const isWindows: boolean;
4
4
  export declare const isVsCode: boolean;
5
5
  export declare const isZCode: boolean;
6
6
  export declare const isExtension: boolean;
7
+ export declare function isCLIBin(): boolean;
7
8
  export declare function isPrimaryShell(): boolean;
8
9
  export declare function envOverride(envname: string, value: string): string;
9
10
  export declare function getEnvVariable(variable: string, fallback?: unknown): unknown;
10
11
  export declare const getLocalAccessDomain: (port: number, protocol?: "http" | "ws") => string;
12
+ export declare function isNonInteractiveMode(): boolean;
13
+ export declare function getNonInteractiveModeSource(): 'env' | 'option' | undefined;
@@ -34,9 +34,15 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.getLocalAccessDomain = exports.isExtension = exports.isZCode = exports.isVsCode = exports.isWindows = exports.isMac = exports.isCI = void 0;
37
+ exports.isCLIBin = isCLIBin;
37
38
  exports.isPrimaryShell = isPrimaryShell;
38
39
  exports.envOverride = envOverride;
39
40
  exports.getEnvVariable = getEnvVariable;
41
+ exports.isNonInteractiveMode = isNonInteractiveMode;
42
+ exports.getNonInteractiveModeSource = getNonInteractiveModeSource;
43
+ const fs_1 = require("fs");
44
+ const path_1 = require("path");
45
+ const option_1 = require("./option");
40
46
  exports.isCI = process &&
41
47
  !!(process.env.CI ||
42
48
  process.env.CONTINUOUS_INTEGRATION ||
@@ -51,6 +57,23 @@ exports.isWindows = process &&
51
57
  exports.isVsCode = process.env.ZCATALYST_VSCODE === 'true';
52
58
  exports.isZCode = process.env.ZCODE === 'true';
53
59
  exports.isExtension = exports.isVsCode || exports.isZCode;
60
+ function isCLIBin() {
61
+ var _a;
62
+ if (!((_a = require.main) === null || _a === void 0 ? void 0 : _a.filename)) {
63
+ return false;
64
+ }
65
+ const resolveComparablePath = (filePath) => {
66
+ try {
67
+ return (0, fs_1.realpathSync)(filePath);
68
+ }
69
+ catch (_a) {
70
+ return (0, path_1.resolve)(filePath);
71
+ }
72
+ };
73
+ const mainPath = resolveComparablePath(require.main.filename);
74
+ const cliBinPath = resolveComparablePath((0, path_1.resolve)(__dirname, '../bin/catalyst.js'));
75
+ return mainPath === cliBinPath;
76
+ }
54
77
  function isPrimaryShell() {
55
78
  if (!process || process.env.CATALYST_SUB_PROCESS) {
56
79
  return false;
@@ -95,3 +118,21 @@ const getLocalAccessDomain = (port, protocol = 'http') => {
95
118
  return protocol === 'http' ? `http://localhost:${port}` : `ws://localhost:${port}`;
96
119
  };
97
120
  exports.getLocalAccessDomain = getLocalAccessDomain;
121
+ function isNonInteractiveMode() {
122
+ return getNonInteractiveModeSource() !== undefined;
123
+ }
124
+ function getNonInteractiveModeSource() {
125
+ const env = process.env.ZCATALYST_NON_INTERACTIVE;
126
+ if (env === '1' || env === 'true' || env === 'yes') {
127
+ return 'env';
128
+ }
129
+ const flag = (0, option_1.getGlobalOptionValue)('nonInteractive', false);
130
+ if (flag === true || flag === 'true') {
131
+ return 'option';
132
+ }
133
+ const _globalFlag = process.argv.includes('--non-interactive') || process.argv.includes('-ni');
134
+ if (_globalFlag) {
135
+ return 'option';
136
+ }
137
+ return undefined;
138
+ }
@@ -34,4 +34,5 @@ export declare function readJSONFile(pth: string, opts?: fs.ReadOptions & {
34
34
  }): Record<string, any> | undefined;
35
35
  export declare function writeJSONFile(pth: string, object: Record<string, unknown>, opts?: fs.WriteOptions): void;
36
36
  export declare function readPackageJson(): Record<string, unknown> | undefined;
37
+ export declare function getStdinType(): 'tty' | 'pipe' | 'file' | 'other';
37
38
  export declare function isDirEmpty(pth: string): boolean;