zcatalyst-cli 1.12.1 → 1.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/docs/apig-utils.toml +5 -0
  2. package/lib/apig-utils.js +51 -39
  3. package/lib/archiver.js +13 -9
  4. package/lib/authentication/index.js +22 -18
  5. package/lib/authentication/login.js +32 -32
  6. package/lib/bin/catalyst.js +15 -15
  7. package/lib/cli_table/src/cell.js +26 -26
  8. package/lib/cli_table/src/layout-manager.js +44 -45
  9. package/lib/cli_table/src/table.js +9 -9
  10. package/lib/cli_table/src/utils.js +35 -36
  11. package/lib/client-utils.js +43 -22
  12. package/lib/client.js +1 -1
  13. package/lib/command_needs/auth.js +7 -7
  14. package/lib/command_needs/rc.js +32 -25
  15. package/lib/commands/apig/disable.js +5 -5
  16. package/lib/commands/apig/enable.js +5 -5
  17. package/lib/commands/apig/status.js +9 -9
  18. package/lib/commands/client/delete.js +18 -18
  19. package/lib/commands/client/setup.js +8 -4
  20. package/lib/commands/deploy.js +18 -14
  21. package/lib/commands/ds/export.js +11 -11
  22. package/lib/commands/ds/import.js +12 -12
  23. package/lib/commands/ds/status.js +10 -10
  24. package/lib/commands/event/generate/index.js +21 -17
  25. package/lib/commands/event/generate/integ.js +7 -3
  26. package/lib/commands/functions/add.js +8 -4
  27. package/lib/commands/functions/config.js +5 -5
  28. package/lib/commands/functions/delete.js +20 -20
  29. package/lib/commands/functions/setup.js +8 -4
  30. package/lib/commands/functions/shell.js +7 -3
  31. package/lib/commands/help.js +4 -4
  32. package/lib/commands/iac/export.js +8 -8
  33. package/lib/commands/iac/import.js +23 -19
  34. package/lib/commands/iac/pack.js +15 -11
  35. package/lib/commands/iac/status.js +6 -2
  36. package/lib/commands/index.js +5 -1
  37. package/lib/commands/init.js +14 -10
  38. package/lib/commands/login.js +5 -1
  39. package/lib/commands/logout.js +5 -1
  40. package/lib/commands/project/list.js +14 -10
  41. package/lib/commands/project/reset.js +5 -5
  42. package/lib/commands/project/use.js +9 -9
  43. package/lib/commands/pull.js +18 -14
  44. package/lib/commands/run.js +13 -9
  45. package/lib/commands/serve.js +5 -1
  46. package/lib/commands/token/generate.js +6 -2
  47. package/lib/commands/token/list.js +7 -3
  48. package/lib/commands/token/revoke.js +6 -2
  49. package/lib/commands/whoami.js +3 -3
  50. package/lib/dc.js +2 -2
  51. package/lib/deploy/features/apig.js +6 -6
  52. package/lib/deploy/features/client.js +1 -1
  53. package/lib/deploy/features/functions/index.js +9 -9
  54. package/lib/deploy/features/index.js +5 -1
  55. package/lib/deploy/index.js +2 -2
  56. package/lib/endpoints/index.js +17 -13
  57. package/lib/endpoints/lib/apig.js +5 -5
  58. package/lib/endpoints/lib/applogic.js +4 -4
  59. package/lib/endpoints/lib/cache.js +3 -3
  60. package/lib/endpoints/lib/catalyst-details.js +1 -1
  61. package/lib/endpoints/lib/client.js +5 -5
  62. package/lib/endpoints/lib/datastore.js +2 -2
  63. package/lib/endpoints/lib/ds-bulk.js +5 -5
  64. package/lib/endpoints/lib/env.js +1 -1
  65. package/lib/endpoints/lib/event-bus.js +1 -1
  66. package/lib/endpoints/lib/filestore.js +2 -2
  67. package/lib/endpoints/lib/functions.js +4 -4
  68. package/lib/endpoints/lib/iac.js +10 -10
  69. package/lib/endpoints/lib/project.js +20 -5
  70. package/lib/endpoints/lib/queue.js +3 -3
  71. package/lib/endpoints/lib/sdk.js +1 -1
  72. package/lib/endpoints/lib/zcql.js +1 -1
  73. package/lib/error.js +1 -1
  74. package/lib/errorOut.js +2 -2
  75. package/lib/event_generate/cache.js +5 -5
  76. package/lib/event_generate/custom.js +2 -2
  77. package/lib/event_generate/datastore.js +5 -5
  78. package/lib/event_generate/filestore.js +5 -5
  79. package/lib/event_generate/integration/cliq.js +3 -3
  80. package/lib/event_generate/user.js +1 -1
  81. package/lib/event_generate/webapp.js +5 -5
  82. package/lib/execute-script.js +19 -15
  83. package/lib/express_middlewares/authenticator.js +30 -4
  84. package/lib/express_middlewares/logger.js +2 -2
  85. package/lib/express_middlewares/unknownReqProxy.js +1 -1
  86. package/lib/fn-utils/index.js +5 -1
  87. package/lib/fn-utils/lib/common.js +44 -44
  88. package/lib/fn-utils/lib/integ.js +9 -9
  89. package/lib/fn-utils/lib/java.js +46 -46
  90. package/lib/fn-utils/lib/node.js +7 -7
  91. package/lib/fn-watcher.js +9 -11
  92. package/lib/iac/status/bundle.js +5 -5
  93. package/lib/iac/status/deploy.js +4 -4
  94. package/lib/index.js +2 -2
  95. package/lib/init/dependencies/npm-install.js +1 -1
  96. package/lib/init/dependencies/package-json.js +6 -6
  97. package/lib/init/features/client/index.js +5 -1
  98. package/lib/init/features/client/initializers/angular.js +16 -12
  99. package/lib/init/features/client/initializers/basic.js +10 -6
  100. package/lib/init/features/client/initializers/lyte.js +11 -7
  101. package/lib/init/features/client/initializers/react.js +13 -9
  102. package/lib/init/features/functions/index.js +9 -9
  103. package/lib/init/features/functions/languages/java.js +10 -10
  104. package/lib/init/features/functions/languages/node.js +9 -9
  105. package/lib/init/features/index.js +12 -8
  106. package/lib/init/features/project.js +20 -20
  107. package/lib/init/index.js +2 -2
  108. package/lib/init/util/client.js +7 -3
  109. package/lib/init/util/functions.js +1 -1
  110. package/lib/init/util/project.js +4 -4
  111. package/lib/internal/api.js +19 -19
  112. package/lib/internal/command.js +20 -16
  113. package/lib/internal/config.js +5 -5
  114. package/lib/internal/credential.js +10 -10
  115. package/lib/internal/crypt.js +5 -5
  116. package/lib/internal/rc.js +6 -6
  117. package/lib/migration/global/1.6.2.js +3 -3
  118. package/lib/migration/index.js +22 -18
  119. package/lib/option-filter.js +34 -30
  120. package/lib/optional-import.js +12 -8
  121. package/lib/plugin-loader.js +7 -3
  122. package/lib/port-resolver.js +4 -4
  123. package/lib/progress.js +2 -2
  124. package/lib/prompt/index.js +5 -1
  125. package/lib/prompt/types/file-path.js +1 -1
  126. package/lib/pull/features/apig.js +9 -9
  127. package/lib/pull/features/client.js +7 -7
  128. package/lib/pull/features/functions/index.js +14 -14
  129. package/lib/pull/features/index.js +5 -1
  130. package/lib/pull/index.js +4 -4
  131. package/lib/repl-server.js +2 -2
  132. package/lib/serve/features/apig.js +1 -1
  133. package/lib/serve/features/index.js +8 -4
  134. package/lib/serve/index.js +15 -11
  135. package/lib/serve/server/index.js +43 -27
  136. package/lib/serve/server/lib/java/JavaaioServer.java +2 -1
  137. package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  138. package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  139. package/lib/serve/server/lib/java/lib/zip4j-2.5.0.jar +0 -0
  140. package/lib/serve/server/lib/master.js +26 -15
  141. package/lib/serve/server/lib/node.js +7 -3
  142. package/lib/serve/server/lib/web_client/index.js +3 -3
  143. package/lib/serve/server/lib/web_client/server.js +17 -17
  144. package/lib/shell/dependencies/http-functions.js +40 -34
  145. package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +13 -1
  146. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +13 -2
  147. package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +13 -2
  148. package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +13 -2
  149. package/lib/shell/dependencies/invoker/integ/node.js +8 -4
  150. package/lib/shell/dependencies/local-function.js +44 -40
  151. package/lib/shell/index.js +12 -12
  152. package/lib/shell/prepare/index.js +2 -2
  153. package/lib/shell/prepare/languages/index.js +5 -1
  154. package/lib/shell/prepare/languages/java.js +1 -1
  155. package/lib/throbber/index.js +17 -17
  156. package/lib/throbber/utils.js +9 -9
  157. package/lib/track.js +7 -7
  158. package/lib/util_modules/config/index.js +5 -1
  159. package/lib/util_modules/constants/lib/auth.js +6 -6
  160. package/lib/util_modules/constants/lib/cliq-handlers.js +2 -2
  161. package/lib/util_modules/constants/lib/scopes.js +1 -0
  162. package/lib/util_modules/constants/lib/template.js +21 -21
  163. package/lib/util_modules/constants/lib/urls.js +11 -11
  164. package/lib/util_modules/context-help.js +15 -15
  165. package/lib/util_modules/fs/index.js +5 -1
  166. package/lib/util_modules/fs/lib/async.js +4 -4
  167. package/lib/util_modules/fs/utils.js +1 -1
  168. package/lib/util_modules/logger.js +2 -2
  169. package/lib/util_modules/parser/toml.js +1 -1
  170. package/lib/util_modules/project.js +6 -6
  171. package/lib/util_modules/shell.js +4 -4
  172. package/lib/winston.js +5 -5
  173. package/package.json +39 -39
  174. package/scripts/postInstall.js +7 -6
  175. package/docs/.DS_Store +0 -0
  176. package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
package/lib/pull/index.js CHANGED
@@ -31,17 +31,17 @@ function pull() {
31
31
  errorId: 'PULL-1',
32
32
  arg: [
33
33
  ansi_colors_1.bold.red(feature),
34
- ansi_colors_1.bold(Object.keys(features_1.default)
34
+ (0, ansi_colors_1.bold)(Object.keys(features_1.default)
35
35
  .map((feat) => '* ' + feat)
36
36
  .join('\n'))
37
37
  ]
38
38
  });
39
39
  }
40
40
  const MODULE = features_1.default[feature];
41
- logger_1.info(ansi_colors_1.bold('\n' + ansi_colors_1.white('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
41
+ (0, logger_1.info)((0, ansi_colors_1.bold)('\n' + (0, ansi_colors_1.white)('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
42
42
  yield MODULE().catch((err) => {
43
- logger_1.info();
44
- logger_1.warning(`Skipping pull of ${feature}. Since ${err.message}.\nContact Catalyst Support with catalyst-debug.log file.`);
43
+ (0, logger_1.info)();
44
+ (0, logger_1.warning)(`Skipping pull of ${feature}. Since ${err.message}.\nContact Catalyst Support with catalyst-debug.log file.`);
45
45
  });
46
46
  if (runtime_store_1.default.get('payload.' + feature, false)) {
47
47
  runtime_store_1.default.set('payload.features', runtime_store_1.default.get('payload.features', []).concat(feature));
@@ -9,7 +9,7 @@ const error_1 = __importDefault(require("./error"));
9
9
  const stdin = process.stdin;
10
10
  const ASCII_ETX_CODE = 0x03;
11
11
  class Repl {
12
- constructor({ prompt = '>', writer = (output) => util_1.inspect(output), useColors = true, ignoreUndefined = false } = {}) {
12
+ constructor({ prompt = '>', writer = (output) => (0, util_1.inspect)(output), useColors = true, ignoreUndefined = false } = {}) {
13
13
  this.prompt = prompt;
14
14
  this.writer = writer;
15
15
  this.useColors = useColors;
@@ -21,7 +21,7 @@ class Repl {
21
21
  this.pureEmit = stdin.emit;
22
22
  }
23
23
  start() {
24
- this.server = repl_1.start({
24
+ this.server = (0, repl_1.start)({
25
25
  prompt: this.prompt,
26
26
  writer: this.writer,
27
27
  useColors: this.useColors,
@@ -14,7 +14,7 @@ const config_1 = require("../../util_modules/config");
14
14
  const logger_1 = require("../../util_modules/logger");
15
15
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
16
16
  if (!config_1.apigConfig.enabled()) {
17
- logger_1.info('Skipping API Gateway rules');
17
+ (0, logger_1.info)('Skipping API Gateway rules');
18
18
  return;
19
19
  }
20
20
  apig_utils_1.apigUtils.executeHook({ prefix: 'pre', command: 'serve' });
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -45,9 +49,9 @@ function client() {
45
49
  }
46
50
  catch (e) {
47
51
  const err = error_1.default.getErrorInstance(e);
48
- logger_1.info();
49
- logger_1.warning('Skipping the serve of Client because of the error: ' + err.message);
50
- logger_1.info();
52
+ (0, logger_1.info)();
53
+ (0, logger_1.warning)('Skipping the serve of Client because of the error: ' + err.message);
54
+ (0, logger_1.info)();
51
55
  return;
52
56
  }
53
57
  const clientName = runtime_store_1.default.get('context.client.name');
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -48,19 +52,19 @@ const server_1 = __importDefault(require("./server"));
48
52
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
49
53
  const serveTargets = runtime_store_1.default.get('context.targets', []);
50
54
  const advancedServer = new server_1.default();
51
- const basicFnServer = new http_functions_1.default();
55
+ const basicFnServer = new http_functions_1.default({ primary: false });
52
56
  try {
53
57
  const masterPort = yield port_resolver_1.default.getPort('master', 'http', 'master', false);
54
58
  runtime_store_1.default.set('context.port.http.master', masterPort);
55
59
  yield Promise.all(serveTargets.map((target) => features[target]()));
56
60
  const rawTargets = runtime_store_1.default.get('context.functions.targets', []);
57
- const watchOpt = option_1.getOptionValue('watch', false);
61
+ const watchOpt = (0, option_1.getOptionValue)('watch', false);
58
62
  if (watchOpt) {
59
- yield Promise.all(rawTargets.map((target) => __awaiter(void 0, void 0, void 0, function* () { return (target.valid ? fn_watcher_1.default(target) : undefined); })));
63
+ yield Promise.all(rawTargets.map((target) => __awaiter(void 0, void 0, void 0, function* () { return (target.valid ? (0, fn_watcher_1.default)(target) : undefined); })));
60
64
  }
61
65
  const funtionTargets = rawTargets.filter((target) => {
62
66
  if (!target.valid) {
63
- logger_1.warning('skipping serve of function [' +
67
+ (0, logger_1.warning)('skipping serve of function [' +
64
68
  target.name +
65
69
  '] since ' +
66
70
  target.failure_reason);
@@ -75,7 +79,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
75
79
  const client = runtime_store_1.default.get('context.client', false);
76
80
  if (client && client.valid) {
77
81
  client.opts = {
78
- open: option_1.getOptionValue('open', false),
82
+ open: (0, option_1.getOptionValue)('open', false),
79
83
  watch: watchOpt
80
84
  };
81
85
  advancedServer.add('client', client);
@@ -85,7 +89,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
85
89
  }
86
90
  }
87
91
  if (serveTargets.includes('functions') && funtionTargets.length === 0) {
88
- logger_1.labeled('functions', 'No targets are ready to be served in local').WARN();
92
+ (0, logger_1.labeled)('functions', 'No targets are ready to be served in local').WARN();
89
93
  serveTargets.splice(serveTargets.indexOf('functions'), 1);
90
94
  runtime_store_1.default.set('context.targets', serveTargets);
91
95
  }
@@ -105,7 +109,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
105
109
  yield advancedServer.start();
106
110
  yield advancedServer.wait();
107
111
  yield Promise.all([
108
- fs_1.ASYNC.deleteDir(path_1.join(runtime_store_1.default.get('cwd'), '.build')).catch(),
112
+ fs_1.ASYNC.deleteDir((0, path_1.join)(runtime_store_1.default.get('cwd'), '.build')).catch(),
109
113
  advancedServer ? advancedServer.stop() : undefined,
110
114
  basicFnServer ? basicFnServer.stop() : undefined
111
115
  ]);
@@ -121,12 +125,12 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
121
125
  command: 'serve'
122
126
  });
123
127
  }
124
- logger_1.info();
125
- logger_1.success('Shutdown complete');
128
+ (0, logger_1.info)();
129
+ (0, logger_1.success)('Shutdown complete');
126
130
  }
127
131
  catch (e) {
128
132
  yield Promise.all([
129
- fs_1.ASYNC.deleteDir(path_1.join(runtime_store_1.default.get('cwd'), '.build')).catch(),
133
+ fs_1.ASYNC.deleteDir((0, path_1.join)(runtime_store_1.default.get('cwd'), '.build')).catch(),
130
134
  advancedServer ? advancedServer.stop() : undefined,
131
135
  basicFnServer ? basicFnServer.stop() : undefined
132
136
  ]);
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -55,6 +59,7 @@ const logger_1 = require("../../util_modules/logger");
55
59
  const shell_1 = require("../../util_modules/shell");
56
60
  const master_1 = __importDefault(require("./lib/master"));
57
61
  const ansi_colors_1 = require("ansi-colors");
62
+ const stream_1 = require("stream");
58
63
  class Server {
59
64
  constructor() {
60
65
  this.targetDetailsArr = [];
@@ -62,7 +67,7 @@ class Server {
62
67
  _addBasicFnDetails() {
63
68
  const fnTargets = runtime_store_1.default.get('context.functions.targets', []);
64
69
  if (fnTargets.length === 0) {
65
- logger_1.debug('No basic functions to add');
70
+ (0, logger_1.debug)('No basic functions to add');
66
71
  }
67
72
  const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic]), 10);
68
73
  const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], '-1'), 10);
@@ -83,45 +88,47 @@ class Server {
83
88
  _spinUpJavaServer(details, masterPort) {
84
89
  var _a, _b, _c, _d;
85
90
  return __awaiter(this, void 0, void 0, function* () {
86
- const javaServer = path_1.join(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'aioserver', 'JavaaioServer');
87
- const targetDir = path_1.join(runtime_store_1.default.get('cwd'), '.build', (_a = details.target) === null || _a === void 0 ? void 0 : _a.name);
91
+ const javaServer = (0, path_1.join)(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'aioserver', 'JavaaioServer');
92
+ const targetDir = (0, path_1.join)(runtime_store_1.default.get('cwd'), '.build', (_a = details.target) === null || _a === void 0 ? void 0 : _a.name);
88
93
  const label = `${details.type}[${(_b = details.target) === null || _b === void 0 ? void 0 : _b.name}]`;
89
- fn_utils_1.fnUtils.java.ensureJavaInvoker(javaServer, path_1.normalize(path_1.join(__dirname, './lib', 'java', 'JavaaioServer.java')));
90
- const serverFiles = yield fs_1.ASYNC.walk(path_1.dirname(javaServer));
94
+ fn_utils_1.fnUtils.java.ensureJavaInvoker(javaServer, (0, path_1.normalize)((0, path_1.join)(__dirname, './lib', 'java', 'JavaaioServer.java')));
95
+ const serverFiles = yield fs_1.ASYNC.walk((0, path_1.dirname)(javaServer));
91
96
  yield Promise.all(serverFiles.map((file) => __awaiter(this, void 0, void 0, function* () {
92
- return fs_1.ASYNC.copyFile(file, path_1.join(targetDir, path_1.relative(path_1.dirname(javaServer), file.replace('lib' + path_1.sep, ''))));
97
+ return fs_1.ASYNC.copyFile(file, (0, path_1.join)(targetDir, (0, path_1.relative)((0, path_1.dirname)(javaServer), file.replace('lib' + path_1.sep, ''))));
93
98
  })));
94
99
  const opts = [
95
100
  '-cp',
96
- path_1.join(targetDir, '*') + fn_utils_1.fnUtils.java.classPathSep + targetDir + path_1.sep,
101
+ (0, path_1.join)(targetDir, '*') + fn_utils_1.fnUtils.java.classPathSep + targetDir + path_1.sep,
97
102
  '-DCATALYST_FUNCTION_TYPE=applogic'
98
103
  ];
99
104
  if (details.debugPort !== -1) {
100
- logger_1.labeled(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
105
+ (0, logger_1.labeled)(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
101
106
  opts.push('-Xdebug');
102
107
  opts.push('-Xrunjdwp:transport=dt_socket,address=' + details.debugPort + ',server=y,suspend=y');
103
108
  }
104
- opts.push(path_1.basename(javaServer));
109
+ opts.push((0, path_1.basename)(javaServer));
105
110
  opts.push(details.httpPort + '');
106
111
  const targetSource = (_c = details.target) === null || _c === void 0 ? void 0 : _c.source;
107
112
  const configType = details.type === 'server' ? 'functions' : details.type;
108
- const servePlugin = yield plugin_loader_1.default(configType, 'start', targetSource).catch((err) => logger_1.debug(err));
113
+ const servePlugin = yield (0, plugin_loader_1.default)(configType, 'start', targetSource).catch((err) => (0, logger_1.debug)(err));
109
114
  if (typeof servePlugin === 'function') {
110
115
  const event = servePlugin(details, masterPort);
111
- logger_1.labeled(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
116
+ (0, logger_1.labeled)(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
112
117
  return event;
113
118
  }
114
- const child = shell_1.spawn('java', opts, {
119
+ const child = (0, shell_1.spawn)('java', opts, {
115
120
  cwd: targetSource,
116
121
  stdio: 'pipe',
117
122
  env: {
118
123
  X_ZOHO_CATALYST_IS_LOCAL: 'true',
124
+ X_ZOHO_CATALYST_FUNCTION_LOADED: 'true',
125
+ X_ZOHO_CATALYST_CODE_LOCATION: targetDir + path_1.sep,
119
126
  X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth,
120
127
  X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin
121
128
  }
122
129
  }).RAW();
123
- logger_1.labeled(label, `URL : http://localhost:${masterPort}/server/${(_d = details.target) === null || _d === void 0 ? void 0 : _d.name}/`).MESSAGE();
124
- logger_1.info();
130
+ (0, logger_1.labeled)(label, `URL : http://localhost:${masterPort}/server/${(_d = details.target) === null || _d === void 0 ? void 0 : _d.name}/`).MESSAGE();
131
+ (0, logger_1.info)();
125
132
  return child;
126
133
  });
127
134
  }
@@ -131,18 +138,26 @@ class Server {
131
138
  const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
132
139
  const _d = details.target, { ['watcher']: _ } = _d, serialisableTarget = __rest(_d, ['watcher']);
133
140
  const opts = [
134
- path_1.join(__dirname, 'lib', 'node.js'),
141
+ (0, path_1.join)(__dirname, 'lib', 'node.js'),
135
142
  details.httpPort + '',
136
143
  JSON.stringify(serialisableTarget)
137
144
  ];
138
145
  if (details.debugPort !== -1) {
139
- logger_1.labeled(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
146
+ (0, logger_1.labeled)(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
140
147
  opts.unshift('--inspect=' + details.debugPort);
141
148
  }
142
149
  const targetSource = (_b = details.target) === null || _b === void 0 ? void 0 : _b.source;
143
150
  const configType = details.type === 'server' ? 'functions' : details.type;
144
- const servePlugin = yield plugin_loader_1.default(configType, 'start', targetSource).catch((err) => logger_1.debug(err));
151
+ const servePlugin = yield (0, plugin_loader_1.default)(configType, 'start', targetSource).catch((err) => (0, logger_1.debug)(err));
145
152
  if (typeof servePlugin === 'function') {
153
+ const logStreamPlugin = yield (0, plugin_loader_1.default)(configType, 'logs', targetSource).catch((err) => (0, logger_1.debug)(err));
154
+ if (typeof logStreamPlugin === 'function') {
155
+ const stream = yield logStreamPlugin();
156
+ if (stream instanceof stream_1.Stream) {
157
+ const streamLogFn = (chunk) => (0, logger_1.log)('info', chunk.toString(), true);
158
+ stream.on('data', streamLogFn);
159
+ }
160
+ }
146
161
  const event = servePlugin(details, masterPort).catch((e) => {
147
162
  var _a, _b;
148
163
  const err = error_1.default.getErrorInstance(e, {
@@ -152,28 +167,29 @@ class Server {
152
167
  err.errorId = 'SERVE-IDX-1';
153
168
  err.arg = [
154
169
  configType,
155
- ansi_colors_1.bold(((_b = (_a = details.target) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b.start)[targetSource] || 'start'),
156
- ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(err.message)
170
+ (0, ansi_colors_1.bold)(((_b = (_a = details.target) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b.start)[targetSource] || 'start'),
171
+ (0, ansi_colors_1.bold)('Error: ') + ansi_colors_1.italic.red(err.message)
157
172
  ];
158
173
  throw err;
159
174
  });
160
- logger_1.labeled(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
175
+ (0, logger_1.labeled)(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
161
176
  return event;
162
177
  }
163
178
  if (details.type === 'client') {
164
179
  return yield (yield Promise.resolve().then(() => __importStar(require('./lib/web_client/index.js')))).default(details, masterPort);
165
180
  }
166
- const child = shell_1.spawn('node', opts, {
181
+ const child = (0, shell_1.spawn)('node', opts, {
167
182
  cwd: targetSource,
168
183
  stdio: 'pipe',
169
184
  env: {
170
185
  X_ZOHO_CATALYST_IS_LOCAL: 'true',
186
+ X_ZOHO_CATALYST_FUNCTION_LOADED: 'true',
171
187
  X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth,
172
188
  X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin
173
189
  }
174
190
  }).RAW();
175
- logger_1.labeled(label, `URL : http://localhost:${masterPort}/server/${(_c = details.target) === null || _c === void 0 ? void 0 : _c.name}/`).MESSAGE();
176
- logger_1.info();
191
+ (0, logger_1.labeled)(label, `URL : http://localhost:${masterPort}/server/${(_c = details.target) === null || _c === void 0 ? void 0 : _c.name}/`).MESSAGE();
192
+ (0, logger_1.info)();
177
193
  return child;
178
194
  });
179
195
  }
@@ -228,7 +244,7 @@ class Server {
228
244
  exit: 2
229
245
  });
230
246
  }
231
- const server = yield master_1.default(masterPort, this.targetDetailsArr);
247
+ const server = yield (0, master_1.default)(masterPort, this.targetDetailsArr);
232
248
  this.masterServer = server;
233
249
  return new Promise((res) => {
234
250
  server.on('listening', () => {
@@ -249,7 +265,7 @@ class Server {
249
265
  wait() {
250
266
  return __awaiter(this, void 0, void 0, function* () {
251
267
  if (!this.masterServer) {
252
- logger_1.debug('Master server is not started yet.');
268
+ (0, logger_1.debug)('Master server is not started yet.');
253
269
  throw new error_1.default('Server cannot be put to wait state.', { exit: 2 });
254
270
  }
255
271
  this.targetDetailsArr.forEach((targetdetails) => {
@@ -263,7 +279,7 @@ class Server {
263
279
  }));
264
280
  (_b = target.watcher) === null || _b === void 0 ? void 0 : _b.on('compiled', () => __awaiter(this, void 0, void 0, function* () {
265
281
  yield this.restart(target);
266
- logger_1.labeled(`server[${target.name}]`, 'ready!').MESSAGE();
282
+ (0, logger_1.labeled)(`server[${target.name}]`, 'ready!').MESSAGE();
267
283
  setTimeout(() => {
268
284
  var _a;
269
285
  (_a = target.watcher) === null || _a === void 0 ? void 0 : _a.emit('next');
@@ -4,6 +4,7 @@ import java.util.logging.Handler;
4
4
  import java.util.logging.LogManager;
5
5
  import java.util.logging.LogRecord;
6
6
  import java.util.logging.Logger;
7
+ import java.util.logging.SimpleFormatter;
7
8
 
8
9
  import com.cop.main.server.DefaultCoreServer;
9
10
 
@@ -21,7 +22,7 @@ public class JavaaioServer extends DefaultCoreServer {
21
22
  if (record.getThrown() != null) {
22
23
  exceptionMessage = getStackTraceAsString(record.getThrown());
23
24
  }
24
- String message = record.getMessage() + " " + exceptionMessage;
25
+ String message = new SimpleFormatter().format(record) + " " + exceptionMessage;
25
26
  if (message.length() > MESSAGE_LENGTH) {
26
27
  message = message.substring(0, MESSAGE_LENGTH);
27
28
  }
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const express_1 = __importDefault(require("express"));
16
+ const http_1 = require("http");
16
17
  const error_1 = __importDefault(require("../../../error"));
17
18
  const apig_matcher_1 = __importDefault(require("../../../express_middlewares/apig-matcher"));
18
19
  const auth_checker_1 = __importDefault(require("../../../express_middlewares/auth-checker"));
@@ -86,20 +87,20 @@ const proxyResponseHandler = (systemRoutes) => (proxyRes, req, res) => {
86
87
  function spinUpMaster(listenPort, otherServerDetails) {
87
88
  return __awaiter(this, void 0, void 0, function* () {
88
89
  const projectDetails = {
89
- id: project_2.getProjectId(),
90
- domain_prefix: project_2.getDomainPrefix(),
90
+ id: (0, project_2.getProjectId)(),
91
+ domain_prefix: (0, project_2.getDomainPrefix)(),
91
92
  domain: constants_1.ORIGIN.app.replace('https://', ''),
92
- key: project_2.getDomainKey(),
93
- env_name: project_2.getEnvName()
93
+ key: (0, project_2.getDomainKey)(),
94
+ env_name: (0, project_2.getEnvName)()
94
95
  };
95
96
  const rules = runtime_store_1.default.get('context.apig.local.config', -1);
96
- const customProxyUrl = option_1.getOptionValue('proxy');
97
- const app = express_1.default();
97
+ const customProxyUrl = (0, option_1.getOptionValue)('proxy');
98
+ const app = (0, express_1.default)();
98
99
  let systemRoutes;
99
100
  app.use(logger_1.default);
100
101
  app.use(cookie_parser_1.default);
102
+ app.use((0, project_1.default)(projectDetails));
101
103
  app.use(authenticator_1.default);
102
- app.use(project_1.default(projectDetails));
103
104
  if (rules !== -1) {
104
105
  for (const [sourceURL, methodByConfig] of Object.entries(rules)) {
105
106
  const router = app.route(sourceURL);
@@ -121,16 +122,26 @@ function spinUpMaster(listenPort, otherServerDetails) {
121
122
  }
122
123
  app.use('/', apig_matcher_1.default, auth_checker_1.default, url_rewriter_1.default);
123
124
  }
124
- const proxy = http_proxy_1.createProxyServer()
125
+ const proxy = (0, http_proxy_1.createProxyServer)()
125
126
  .on('error', (err, req, res) => {
126
- res.writeHead(503, { 'Content-Type': 'json' });
127
- res.write(JSON.stringify({ error: 'unable to proxy request' }));
128
- res.end();
127
+ if (res instanceof http_1.ServerResponse) {
128
+ res.writeHead(502, { 'Content-Type': 'json' });
129
+ }
130
+ res.end(JSON.stringify({ error: 'unable to proxy request' }));
129
131
  console.log('unable to proxy request ', req.url);
130
132
  console.error(err);
133
+ })
134
+ .on('econnreset', (err, req, res, targetUrl) => {
135
+ if (res instanceof http_1.ServerResponse) {
136
+ res.writeHead(502, { 'Content-Type': 'json' });
137
+ }
138
+ res.end(JSON.stringify({ error: 'unable to proxy request. ECONNRESET.' }));
139
+ console.log('Connection reset while trying to proxy ', req.url);
140
+ (0, logger_2.debug)('Connection reset from target URL : ', targetUrl);
141
+ console.error(err);
131
142
  })
132
143
  .on('proxyRes', proxyResponseHandler(systemRoutes))
133
- .on('close', () => logger_2.debug('proxy closed'));
144
+ .on('close', () => (0, logger_2.debug)('proxy closed'));
134
145
  const proxyDestroyer = new server_js_1.ConnectionDestroyer(proxy);
135
146
  otherServerDetails.forEach((serverDetail) => {
136
147
  var _a, _b, _c, _d, _e, _f;
@@ -212,7 +223,7 @@ function spinUpMaster(listenPort, otherServerDetails) {
212
223
  });
213
224
  }
214
225
  });
215
- app.use('/', unknownReqProxy_1.default(proxy, customProxyUrl));
226
+ app.use('/', (0, unknownReqProxy_1.default)(proxy, customProxyUrl));
216
227
  app.use(error_handler_1.default);
217
228
  const expressServer = app.listen(listenPort).on('error', (err) => {
218
229
  if (proxy) {
@@ -224,8 +235,8 @@ function spinUpMaster(listenPort, otherServerDetails) {
224
235
  expressServer.maxConnections = 100;
225
236
  process.on('SIGINT', () => expressDestroyer.destroy(false));
226
237
  expressServer.on('close', () => __awaiter(this, void 0, void 0, function* () {
227
- logger_2.info('Shutting down server');
228
- yield proxyDestroyer.destroy().catch((err) => logger_2.debug(err));
238
+ (0, logger_2.info)('Shutting down server');
239
+ yield proxyDestroyer.destroy().catch((err) => (0, logger_2.debug)(err));
229
240
  }));
230
241
  expressServer.on('upgrade', (...upgradeParam) => {
231
242
  app.emit('upgrade', ...upgradeParam);
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -36,7 +40,7 @@ const util_1 = require("util");
36
40
  const args = process.argv.slice(2);
37
41
  const listenPort = parseInt(args[0], 10);
38
42
  const fnDetails = JSON.parse(args[1]);
39
- const app = express_1.default();
43
+ const app = (0, express_1.default)();
40
44
  const targetName = fnDetails.name;
41
45
  const index = fnDetails.index;
42
46
  app.use('/', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
@@ -47,7 +51,7 @@ app.use('/', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
47
51
  (yield Promise.resolve().then(() => __importStar(require(index)))).default(req, res);
48
52
  }
49
53
  catch (e) {
50
- const errorString = util_1.inspect(e);
54
+ const errorString = (0, util_1.inspect)(e);
51
55
  console.error('[' + targetName + '] ' + errorString);
52
56
  res.writeHead(500);
53
57
  res.end(errorString);
@@ -18,13 +18,13 @@ const server_js_1 = __importDefault(require("./server.js"));
18
18
  exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, function* () {
19
19
  var _a;
20
20
  const target = details.target;
21
- const clientListner = yield server_js_1.default(details.httpPort, target.source, target.homepage, ((_a = target.opts) === null || _a === void 0 ? void 0 : _a.watch) || false);
21
+ const clientListner = yield (0, server_js_1.default)(details.httpPort, target.source, target.homepage, ((_a = target.opts) === null || _a === void 0 ? void 0 : _a.watch) || false);
22
22
  clientListner.addListener('start', () => {
23
23
  var _a, _b;
24
24
  const appUrl = 'http://localhost:' + masterPort;
25
25
  const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
26
- logger_1.labeled(label, `URL : ${appUrl}/app/`).MESSAGE();
27
- ((_b = details.target.opts) === null || _b === void 0 ? void 0 : _b.open) && open_1.default(appUrl).catch();
26
+ (0, logger_1.labeled)(label, `URL : ${appUrl}/app/`).MESSAGE();
27
+ ((_b = details.target.opts) === null || _b === void 0 ? void 0 : _b.open) && (0, open_1.default)(appUrl).catch();
28
28
  });
29
29
  return clientListner;
30
30
  });
@@ -32,7 +32,7 @@ function prepareScriptFile(dir, port) {
32
32
  }
33
33
  const scriptReady = scriptFile.replace(new RegExp(index_js_1.PLACEHOLDER.client.port, 'g'), port + '');
34
34
  yield index_js_2.ASYNC.ensureDir(dir);
35
- const scriptFilePath = path_1.join(dir, 'reload-script.js');
35
+ const scriptFilePath = (0, path_1.join)(dir, 'reload-script.js');
36
36
  yield index_js_2.ASYNC.writeFile(scriptFilePath, scriptReady);
37
37
  return scriptFilePath;
38
38
  });
@@ -56,19 +56,19 @@ function injectScript(scriptLocale, indexHtml) {
56
56
  });
57
57
  }
58
58
  function reloadApp(event, path, liveSockets) {
59
- logger_js_1.info(ansi_colors_1.cyan(`${event} detected in ${path} of the Web-Client.`));
59
+ (0, logger_js_1.info)((0, ansi_colors_1.cyan)(`${event} detected in ${path} of the Web-Client.`));
60
60
  liveSockets.forEach((socket) => socket.send('reload'));
61
61
  }
62
62
  function webClientServer(httpPort, source, homepage, enableWatch) {
63
63
  return __awaiter(this, void 0, void 0, function* () {
64
64
  const eventListener = new events_1.EventEmitter();
65
- const catalystTempDir = path_1.join(source, '.catalyst');
65
+ const catalystTempDir = (0, path_1.join)(source, '.catalyst');
66
66
  const socketServerPort = yield port_resolver_js_1.default.getFreePort(httpPort, 20, true);
67
67
  const reloadScriptSrc = enableWatch
68
- ? path_1.relative(source, yield prepareScriptFile(catalystTempDir, socketServerPort))
68
+ ? (0, path_1.relative)(source, yield prepareScriptFile(catalystTempDir, socketServerPort))
69
69
  : undefined;
70
70
  if (reloadScriptSrc) {
71
- const clientWatcher = chokidar_1.watch(source, {
71
+ const clientWatcher = (0, chokidar_1.watch)(source, {
72
72
  ignoreInitial: true,
73
73
  ignored: ['node_modules/**/*']
74
74
  });
@@ -101,16 +101,16 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
101
101
  liveSockets.push(clientSocket);
102
102
  clientSocket.send('connected');
103
103
  })
104
- .on('error', (err) => logger_js_1.debug(err));
104
+ .on('error', (err) => (0, logger_js_1.debug)(err));
105
105
  setTimeout(() => {
106
106
  clientWatcher.on('change', (path) => {
107
- reloadApp('Change(s) is', path_1.relative(source, path), liveSockets);
107
+ reloadApp('Change(s) is', (0, path_1.relative)(source, path), liveSockets);
108
108
  });
109
109
  clientWatcher.on('add', (path) => {
110
- reloadApp('Addition of file(s) is', path_1.relative(source, path), liveSockets);
110
+ reloadApp('Addition of file(s) is', (0, path_1.relative)(source, path), liveSockets);
111
111
  });
112
112
  clientWatcher.on('unlink', (path) => {
113
- reloadApp('Deletion of file(s) is', path_1.relative(source, path), liveSockets);
113
+ reloadApp('Deletion of file(s) is', (0, path_1.relative)(source, path), liveSockets);
114
114
  });
115
115
  }, 1000);
116
116
  eventListener.addListener('close', () => socketServer === null || socketServer === void 0 ? void 0 : socketServer.close());
@@ -123,13 +123,13 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
123
123
  index_js_2.SYNC.deleteDir(catalystTempDir);
124
124
  });
125
125
  }
126
- const app = express_1.default();
126
+ const app = (0, express_1.default)();
127
127
  app.use('/app', (req, res) => __awaiter(this, void 0, void 0, function* () {
128
128
  const requestedFile = req.url === '/' ? homepage : decodeURIComponent(req.path);
129
129
  if (enableWatch &&
130
130
  requestedFile === homepage &&
131
131
  (requestedFile.includes('.html') || requestedFile.includes('.htm'))) {
132
- const homepageFile = yield index_js_2.ASYNC.readFile(path_1.join(source, homepage));
132
+ const homepageFile = yield index_js_2.ASYNC.readFile((0, path_1.join)(source, homepage));
133
133
  if (!homepageFile) {
134
134
  eventListener.emit('error', new error_js_1.default('Unable to read the homepage file', {
135
135
  exit: 1,
@@ -146,10 +146,10 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
146
146
  res.send(injectedHomePage || homepageFile);
147
147
  return;
148
148
  }
149
- res.sendFile(path_1.join(source, requestedFile), (err) => {
149
+ res.sendFile((0, path_1.join)(source, requestedFile), (err) => {
150
150
  if (err) {
151
- logger_js_1.error('Unable to serve the requested file: ' + path_1.join(source, requestedFile));
152
- logger_js_1.debug(err.stack || err.message);
151
+ (0, logger_js_1.error)('Unable to serve the requested file: ' + (0, path_1.join)(source, requestedFile));
152
+ (0, logger_js_1.debug)(err.stack || err.message);
153
153
  res.status(404);
154
154
  res.send('Resource not found');
155
155
  }
@@ -160,13 +160,13 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
160
160
  });
161
161
  const expressDestroyer = new server_js_1.ConnectionDestroyer(server);
162
162
  eventListener.on('error', (err) => {
163
- logger_js_1.error('Error when serving the web-client: ' + err.message);
164
- logger_js_1.info('Please exit the command to get more info');
163
+ (0, logger_js_1.error)('Error when serving the web-client: ' + err.message);
164
+ (0, logger_js_1.info)('Please exit the command to get more info');
165
165
  eventListener.emit('close');
166
166
  });
167
167
  eventListener.on('close', () => __awaiter(this, void 0, void 0, function* () {
168
168
  yield expressDestroyer.destroy();
169
- logger_js_1.debug('client server closed');
169
+ (0, logger_js_1.debug)('client server closed');
170
170
  }));
171
171
  return new Promise((res) => server.on('listening', () => res(eventListener)));
172
172
  });