zcatalyst-cli 1.11.1 → 1.13.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.
- package/docs/optional-import.toml +10 -0
- package/lib/apig-utils.js +39 -39
- package/lib/archiver.js +13 -9
- package/lib/authentication/index.js +22 -18
- package/lib/authentication/login.js +37 -39
- package/lib/bin/catalyst.js +15 -15
- package/lib/cli_table/src/cell.js +26 -26
- package/lib/cli_table/src/layout-manager.js +44 -45
- package/lib/cli_table/src/table.js +9 -9
- package/lib/cli_table/src/utils.js +35 -36
- package/lib/client-utils.js +18 -18
- package/lib/client.js +1 -1
- package/lib/command_needs/auth.js +7 -7
- package/lib/command_needs/rc.js +24 -24
- package/lib/commands/apig/disable.js +5 -5
- package/lib/commands/apig/enable.js +5 -5
- package/lib/commands/apig/status.js +9 -9
- package/lib/commands/client/delete.js +19 -19
- package/lib/commands/client/setup.js +8 -4
- package/lib/commands/deploy.js +18 -14
- package/lib/commands/ds/export.js +11 -11
- package/lib/commands/ds/import.js +12 -12
- package/lib/commands/ds/status.js +15 -15
- package/lib/commands/event/generate/index.js +21 -17
- package/lib/commands/event/generate/integ.js +7 -3
- package/lib/commands/functions/add.js +8 -4
- package/lib/commands/functions/config.js +5 -5
- package/lib/commands/functions/delete.js +22 -22
- package/lib/commands/functions/setup.js +8 -4
- package/lib/commands/functions/shell.js +12 -5
- package/lib/commands/help.js +4 -4
- package/lib/commands/iac/export.js +8 -8
- package/lib/commands/iac/import.js +29 -21
- package/lib/commands/iac/pack.js +15 -11
- package/lib/commands/iac/status.js +6 -2
- package/lib/commands/index.js +5 -1
- package/lib/commands/init.js +14 -10
- package/lib/commands/login.js +5 -1
- package/lib/commands/logout.js +5 -1
- package/lib/commands/project/list.js +14 -10
- package/lib/commands/project/reset.js +5 -5
- package/lib/commands/project/use.js +9 -9
- package/lib/commands/pull.js +18 -14
- package/lib/commands/run.js +13 -9
- package/lib/commands/serve.js +5 -1
- package/lib/commands/token/generate.js +6 -2
- package/lib/commands/token/list.js +7 -3
- package/lib/commands/token/revoke.js +6 -2
- package/lib/commands/whoami.js +3 -3
- package/lib/dc.js +2 -2
- package/lib/deploy/features/apig.js +6 -6
- package/lib/deploy/features/client.js +1 -1
- package/lib/deploy/features/functions/index.js +9 -9
- package/lib/deploy/features/index.js +5 -1
- package/lib/deploy/index.js +2 -2
- package/lib/endpoints/index.js +17 -13
- package/lib/endpoints/lib/apig.js +5 -5
- package/lib/endpoints/lib/applogic.js +4 -4
- package/lib/endpoints/lib/cache.js +3 -3
- package/lib/endpoints/lib/catalyst-details.js +1 -1
- package/lib/endpoints/lib/client.js +5 -5
- package/lib/endpoints/lib/datastore.js +2 -2
- package/lib/endpoints/lib/ds-bulk.js +5 -5
- package/lib/endpoints/lib/env.js +1 -1
- package/lib/endpoints/lib/event-bus.js +1 -1
- package/lib/endpoints/lib/filestore.js +2 -2
- package/lib/endpoints/lib/functions.js +4 -4
- package/lib/endpoints/lib/iac.js +10 -10
- package/lib/endpoints/lib/project.js +20 -5
- package/lib/endpoints/lib/queue.js +3 -3
- package/lib/endpoints/lib/sdk.js +1 -1
- package/lib/endpoints/lib/zcql.js +1 -1
- package/lib/error.js +11 -9
- package/lib/errorOut.js +2 -2
- package/lib/event_generate/cache.js +5 -5
- package/lib/event_generate/custom.js +2 -2
- package/lib/event_generate/datastore.js +5 -5
- package/lib/event_generate/filestore.js +5 -5
- package/lib/event_generate/integration/cliq.js +3 -3
- package/lib/event_generate/user.js +1 -1
- package/lib/event_generate/webapp.js +5 -5
- package/lib/execute-script.js +19 -15
- package/lib/express_middlewares/authenticator.js +32 -5
- package/lib/express_middlewares/logger.js +2 -2
- package/lib/express_middlewares/unknownReqProxy.js +1 -1
- package/lib/fn-utils/index.js +5 -1
- package/lib/fn-utils/lib/common.js +44 -44
- package/lib/fn-utils/lib/integ.js +9 -9
- package/lib/fn-utils/lib/java.js +48 -46
- package/lib/fn-utils/lib/node.js +8 -8
- package/lib/fn-watcher.js +9 -11
- package/lib/iac/status/bundle.js +5 -5
- package/lib/iac/status/deploy.js +4 -4
- package/lib/index.js +2 -2
- package/lib/init/dependencies/npm-install.js +8 -1
- package/lib/init/dependencies/package-json.js +6 -6
- package/lib/init/features/client/index.js +5 -1
- package/lib/init/features/client/initializers/angular.js +29 -27
- package/lib/init/features/client/initializers/basic.js +10 -6
- package/lib/init/features/client/initializers/lyte.js +12 -13
- package/lib/init/features/client/initializers/react.js +23 -18
- package/lib/init/features/functions/index.js +23 -14
- package/lib/init/features/functions/languages/java.js +10 -10
- package/lib/init/features/functions/languages/node.js +9 -9
- package/lib/init/features/index.js +12 -8
- package/lib/init/features/project.js +20 -20
- package/lib/init/index.js +2 -2
- package/lib/init/util/client.js +12 -7
- package/lib/init/util/functions.js +1 -1
- package/lib/init/util/project.js +4 -4
- package/lib/internal/api.js +19 -19
- package/lib/internal/command.js +20 -16
- package/lib/internal/config.js +5 -5
- package/lib/internal/credential.js +10 -10
- package/lib/internal/crypt.js +5 -5
- package/lib/internal/rc.js +5 -5
- package/lib/migration/global/1.6.2.js +3 -3
- package/lib/migration/index.js +22 -18
- package/lib/option-filter.js +34 -30
- package/lib/optional-import.js +30 -11
- package/lib/plugin-loader.js +28 -13
- package/lib/port-resolver.js +4 -4
- package/lib/progress.js +2 -2
- package/lib/prompt/index.js +6 -2
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/pull/features/apig.js +9 -9
- package/lib/pull/features/client.js +7 -7
- package/lib/pull/features/functions/index.js +15 -15
- package/lib/pull/features/index.js +5 -1
- package/lib/pull/index.js +4 -4
- package/lib/repl-server.js +2 -2
- package/lib/serve/features/apig.js +1 -1
- package/lib/serve/features/index.js +8 -4
- package/lib/serve/index.js +15 -11
- package/lib/serve/server/index.js +34 -27
- package/lib/serve/server/lib/java/JavaaioServer.java +5 -3
- package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/zip4j-2.5.0.jar +0 -0
- package/lib/serve/server/lib/master.js +33 -36
- package/lib/serve/server/lib/node.js +7 -3
- package/lib/serve/server/lib/web_client/index.js +3 -3
- package/lib/serve/server/lib/web_client/server.js +33 -30
- package/lib/shell/dependencies/http-functions.js +38 -33
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +14 -3
- package/lib/shell/dependencies/invoker/bio/node.js +5 -2
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/integ/node.js +8 -4
- package/lib/shell/dependencies/local-function.js +44 -40
- package/lib/shell/index.js +16 -12
- package/lib/shell/prepare/index.js +2 -2
- package/lib/shell/prepare/languages/index.js +5 -1
- package/lib/shell/prepare/languages/java.js +1 -1
- package/lib/throbber/index.js +17 -17
- package/lib/throbber/utils.js +9 -9
- package/lib/track.js +7 -7
- package/lib/util_modules/config/index.js +5 -1
- package/lib/util_modules/config/lib/client.js +18 -21
- package/lib/util_modules/constants/lib/auth.js +6 -6
- package/lib/util_modules/constants/lib/cliq-handlers.js +2 -2
- package/lib/util_modules/constants/lib/template.js +21 -21
- package/lib/util_modules/constants/lib/urls.js +20 -12
- package/lib/util_modules/context-help.js +15 -15
- package/lib/util_modules/fs/index.js +5 -1
- package/lib/util_modules/fs/lib/async.js +4 -4
- package/lib/util_modules/fs/utils.js +1 -1
- package/lib/util_modules/global-space.js +0 -97
- package/lib/util_modules/logger.js +2 -2
- package/lib/util_modules/parser/toml.js +1 -1
- package/lib/util_modules/project.js +6 -6
- package/lib/util_modules/server.js +53 -0
- package/lib/util_modules/shell.js +4 -4
- package/lib/winston.js +5 -5
- package/package.json +40 -40
- package/scripts/postInstall.js +7 -6
- package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +23 -5
- package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +23 -8
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -3
- package/templates/init/functions/node/integ/cliq/package.json +2 -1
- package/templates/init/functions/node/integ/cliq/sample.js +3 -1
- package/docs/.DS_Store +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/templates/.DS_Store +0 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/react/.DS_Store +0 -0
|
@@ -13,7 +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
|
|
16
|
+
const http_1 = require("http");
|
|
17
17
|
const error_1 = __importDefault(require("../../../error"));
|
|
18
18
|
const apig_matcher_1 = __importDefault(require("../../../express_middlewares/apig-matcher"));
|
|
19
19
|
const auth_checker_1 = __importDefault(require("../../../express_middlewares/auth-checker"));
|
|
@@ -30,6 +30,8 @@ const js_1 = require("../../../util_modules/js");
|
|
|
30
30
|
const logger_2 = require("../../../util_modules/logger");
|
|
31
31
|
const project_2 = require("../../../util_modules/project");
|
|
32
32
|
const option_1 = require("../../../util_modules/option");
|
|
33
|
+
const server_js_1 = require("../../../util_modules/server.js");
|
|
34
|
+
const http_proxy_1 = require("http-proxy");
|
|
33
35
|
const removeSecure = (str) => str.replace(/;\s?Secure/i, '').replace(/;\s?SameSite=None/i, '');
|
|
34
36
|
const redirectByAuth = (req, res, redirectUrl) => {
|
|
35
37
|
if (req.headers['x-zc-user-cred-token'] === undefined) {
|
|
@@ -85,21 +87,20 @@ const proxyResponseHandler = (systemRoutes) => (proxyRes, req, res) => {
|
|
|
85
87
|
function spinUpMaster(listenPort, otherServerDetails) {
|
|
86
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
89
|
const projectDetails = {
|
|
88
|
-
id: project_2.getProjectId(),
|
|
89
|
-
domain_prefix: project_2.getDomainPrefix(),
|
|
90
|
+
id: (0, project_2.getProjectId)(),
|
|
91
|
+
domain_prefix: (0, project_2.getDomainPrefix)(),
|
|
90
92
|
domain: constants_1.ORIGIN.app.replace('https://', ''),
|
|
91
|
-
key: project_2.getDomainKey(),
|
|
92
|
-
env_name: project_2.getEnvName()
|
|
93
|
+
key: (0, project_2.getDomainKey)(),
|
|
94
|
+
env_name: (0, project_2.getEnvName)()
|
|
93
95
|
};
|
|
94
96
|
const rules = runtime_store_1.default.get('context.apig.local.config', -1);
|
|
95
|
-
const customProxyUrl = option_1.getOptionValue('proxy');
|
|
96
|
-
const app = express_1.default();
|
|
97
|
-
const connections = {};
|
|
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,23 +122,27 @@ 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.
|
|
127
|
-
|
|
128
|
-
|
|
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);
|
|
131
133
|
})
|
|
132
|
-
.on('
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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);
|
|
139
142
|
})
|
|
140
|
-
.on('
|
|
143
|
+
.on('proxyRes', proxyResponseHandler(systemRoutes))
|
|
144
|
+
.on('close', () => (0, logger_2.debug)('proxy closed'));
|
|
145
|
+
const proxyDestroyer = new server_js_1.ConnectionDestroyer(proxy);
|
|
141
146
|
otherServerDetails.forEach((serverDetail) => {
|
|
142
147
|
var _a, _b, _c, _d, _e, _f;
|
|
143
148
|
switch (serverDetail.type) {
|
|
@@ -218,29 +223,21 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
218
223
|
});
|
|
219
224
|
}
|
|
220
225
|
});
|
|
221
|
-
app.use('/', unknownReqProxy_1.default(proxy, customProxyUrl));
|
|
226
|
+
app.use('/', (0, unknownReqProxy_1.default)(proxy, customProxyUrl));
|
|
222
227
|
app.use(error_handler_1.default);
|
|
223
228
|
const expressServer = app.listen(listenPort).on('error', (err) => {
|
|
224
229
|
if (proxy) {
|
|
225
|
-
|
|
230
|
+
proxyDestroyer.destroy();
|
|
226
231
|
}
|
|
227
232
|
console.error(err);
|
|
228
233
|
});
|
|
234
|
+
const expressDestroyer = new server_js_1.ConnectionDestroyer(expressServer);
|
|
229
235
|
expressServer.maxConnections = 100;
|
|
230
|
-
process.on('SIGINT', () =>
|
|
231
|
-
|
|
236
|
+
process.on('SIGINT', () => expressDestroyer.destroy(false));
|
|
237
|
+
expressServer.on('close', () => __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
(0, logger_2.info)('Shutting down server');
|
|
239
|
+
yield proxyDestroyer.destroy().catch((err) => (0, logger_2.debug)(err));
|
|
232
240
|
}));
|
|
233
|
-
expressServer.on('connection', (socket) => {
|
|
234
|
-
const id = js_1.JS.randomNumber(4) + '';
|
|
235
|
-
connections[id] = socket;
|
|
236
|
-
socket.on('close', () => {
|
|
237
|
-
delete connections[id];
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
expressServer.on('close', () => {
|
|
241
|
-
logger_2.info('Shutting down server');
|
|
242
|
-
proxy.close();
|
|
243
|
-
});
|
|
244
241
|
expressServer.on('upgrade', (...upgradeParam) => {
|
|
245
242
|
app.emit('upgrade', ...upgradeParam);
|
|
246
243
|
});
|
|
@@ -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.
|
|
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
|
});
|
|
@@ -23,6 +23,7 @@ const path_1 = require("path");
|
|
|
23
23
|
const ws_1 = require("ws");
|
|
24
24
|
const port_resolver_js_1 = __importDefault(require("../../../../port-resolver.js"));
|
|
25
25
|
const ansi_colors_1 = require("ansi-colors");
|
|
26
|
+
const server_js_1 = require("../../../../util_modules/server.js");
|
|
26
27
|
function prepareScriptFile(dir, port) {
|
|
27
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
29
|
const scriptFile = yield index_js_2.ASYNC.readFile(index_js_1.TEMPLATE.client.basic.socket);
|
|
@@ -31,7 +32,7 @@ function prepareScriptFile(dir, port) {
|
|
|
31
32
|
}
|
|
32
33
|
const scriptReady = scriptFile.replace(new RegExp(index_js_1.PLACEHOLDER.client.port, 'g'), port + '');
|
|
33
34
|
yield index_js_2.ASYNC.ensureDir(dir);
|
|
34
|
-
const scriptFilePath = path_1.join(dir, 'reload-script.js');
|
|
35
|
+
const scriptFilePath = (0, path_1.join)(dir, 'reload-script.js');
|
|
35
36
|
yield index_js_2.ASYNC.writeFile(scriptFilePath, scriptReady);
|
|
36
37
|
return scriptFilePath;
|
|
37
38
|
});
|
|
@@ -39,8 +40,8 @@ function prepareScriptFile(dir, port) {
|
|
|
39
40
|
function stringInjector(source, anchorIdx, marker, inject) {
|
|
40
41
|
const headLastIdx = anchorIdx + marker.length;
|
|
41
42
|
const scriptPrefix = source.slice(0, headLastIdx);
|
|
42
|
-
const
|
|
43
|
-
return scriptPrefix + inject +
|
|
43
|
+
const scriptSuffix = source.slice(headLastIdx);
|
|
44
|
+
return scriptPrefix + inject + scriptSuffix;
|
|
44
45
|
}
|
|
45
46
|
function injectScript(scriptLocale, indexHtml) {
|
|
46
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -55,19 +56,19 @@ function injectScript(scriptLocale, indexHtml) {
|
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
function reloadApp(event, path, liveSockets) {
|
|
58
|
-
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.`));
|
|
59
60
|
liveSockets.forEach((socket) => socket.send('reload'));
|
|
60
61
|
}
|
|
61
62
|
function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
62
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const
|
|
64
|
-
const catalystTempDir = path_1.join(source, '.catalyst');
|
|
64
|
+
const eventListener = new events_1.EventEmitter();
|
|
65
|
+
const catalystTempDir = (0, path_1.join)(source, '.catalyst');
|
|
65
66
|
const socketServerPort = yield port_resolver_js_1.default.getFreePort(httpPort, 20, true);
|
|
66
67
|
const reloadScriptSrc = enableWatch
|
|
67
|
-
? path_1.relative(source, yield prepareScriptFile(catalystTempDir, socketServerPort))
|
|
68
|
+
? (0, path_1.relative)(source, yield prepareScriptFile(catalystTempDir, socketServerPort))
|
|
68
69
|
: undefined;
|
|
69
70
|
if (reloadScriptSrc) {
|
|
70
|
-
const clientWatcher = chokidar_1.watch(source, {
|
|
71
|
+
const clientWatcher = (0, chokidar_1.watch)(source, {
|
|
71
72
|
ignoreInitial: true,
|
|
72
73
|
ignored: ['node_modules/**/*']
|
|
73
74
|
});
|
|
@@ -75,7 +76,7 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
|
75
76
|
let watcherReady = false;
|
|
76
77
|
clientWatcher.on('error', (err) => {
|
|
77
78
|
watcherReady = false;
|
|
78
|
-
|
|
79
|
+
eventListener.emit('error', new error_js_1.default('client watcher error', {
|
|
79
80
|
original: err,
|
|
80
81
|
exit: 1,
|
|
81
82
|
skipHelp: true
|
|
@@ -100,21 +101,21 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
|
100
101
|
liveSockets.push(clientSocket);
|
|
101
102
|
clientSocket.send('connected');
|
|
102
103
|
})
|
|
103
|
-
.on('error', (err) => logger_js_1.debug(err));
|
|
104
|
+
.on('error', (err) => (0, logger_js_1.debug)(err));
|
|
104
105
|
setTimeout(() => {
|
|
105
106
|
clientWatcher.on('change', (path) => {
|
|
106
|
-
reloadApp('Change(s) is', path_1.relative(source, path), liveSockets);
|
|
107
|
+
reloadApp('Change(s) is', (0, path_1.relative)(source, path), liveSockets);
|
|
107
108
|
});
|
|
108
109
|
clientWatcher.on('add', (path) => {
|
|
109
|
-
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);
|
|
110
111
|
});
|
|
111
112
|
clientWatcher.on('unlink', (path) => {
|
|
112
|
-
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);
|
|
113
114
|
});
|
|
114
115
|
}, 1000);
|
|
115
|
-
|
|
116
|
+
eventListener.addListener('close', () => socketServer === null || socketServer === void 0 ? void 0 : socketServer.close());
|
|
116
117
|
});
|
|
117
|
-
|
|
118
|
+
eventListener.addListener('close', () => {
|
|
118
119
|
if (clientWatcher) {
|
|
119
120
|
clientWatcher.close();
|
|
120
121
|
}
|
|
@@ -122,15 +123,15 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
|
122
123
|
index_js_2.SYNC.deleteDir(catalystTempDir);
|
|
123
124
|
});
|
|
124
125
|
}
|
|
125
|
-
const app = express_1.default();
|
|
126
|
+
const app = (0, express_1.default)();
|
|
126
127
|
app.use('/app', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
127
128
|
const requestedFile = req.url === '/' ? homepage : decodeURIComponent(req.path);
|
|
128
129
|
if (enableWatch &&
|
|
129
130
|
requestedFile === homepage &&
|
|
130
131
|
(requestedFile.includes('.html') || requestedFile.includes('.htm'))) {
|
|
131
|
-
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));
|
|
132
133
|
if (!homepageFile) {
|
|
133
|
-
|
|
134
|
+
eventListener.emit('error', new error_js_1.default('Unable to read the homepage file', {
|
|
134
135
|
exit: 1,
|
|
135
136
|
errorId: 'WEB-CLIENT-SERVER-1',
|
|
136
137
|
arg: [ansi_colors_1.red.italic(homepage)]
|
|
@@ -145,27 +146,29 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
|
145
146
|
res.send(injectedHomePage || homepageFile);
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
|
-
res.sendFile(path_1.join(source, requestedFile), (err) => {
|
|
149
|
+
res.sendFile((0, path_1.join)(source, requestedFile), (err) => {
|
|
149
150
|
if (err) {
|
|
150
|
-
logger_js_1.error('Unable to serve the requested file: ' + path_1.join(source, requestedFile));
|
|
151
|
-
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);
|
|
152
153
|
res.status(404);
|
|
153
154
|
res.send('Resource not found');
|
|
154
155
|
}
|
|
155
156
|
});
|
|
156
157
|
}));
|
|
157
158
|
const server = app.listen(httpPort).on('error', (err) => {
|
|
158
|
-
|
|
159
|
+
eventListener.emit('error', err);
|
|
159
160
|
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
logger_js_1.
|
|
163
|
-
|
|
161
|
+
const expressDestroyer = new server_js_1.ConnectionDestroyer(server);
|
|
162
|
+
eventListener.on('error', (err) => {
|
|
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
|
+
eventListener.emit('close');
|
|
164
166
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
eventListener.on('close', () => __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
yield expressDestroyer.destroy();
|
|
169
|
+
(0, logger_js_1.debug)('client server closed');
|
|
170
|
+
}));
|
|
171
|
+
return new Promise((res) => server.on('listening', () => res(eventListener)));
|
|
169
172
|
});
|
|
170
173
|
}
|
|
171
174
|
exports.default = webClientServer;
|
|
@@ -31,21 +31,22 @@ const logger_2 = require("../../util_modules/logger");
|
|
|
31
31
|
const project_2 = require("../../util_modules/project");
|
|
32
32
|
const shell_1 = require("../../util_modules/shell");
|
|
33
33
|
const logUrl = (name, pthName, httpPort, masterPort) => {
|
|
34
|
-
logger_2.labeled(`functions(${name})`, 'URL => http://localhost:' + (masterPort === -1 ? httpPort : masterPort) + pthName).MESSAGE();
|
|
34
|
+
(0, logger_2.labeled)(`functions(${name})`, 'URL => http://localhost:' + (masterPort === -1 ? httpPort : masterPort) + pthName).MESSAGE();
|
|
35
35
|
};
|
|
36
36
|
class HttpFunctions {
|
|
37
|
-
constructor(repl) {
|
|
37
|
+
constructor({ repl, primary = true } = {}) {
|
|
38
38
|
this.repl = repl;
|
|
39
|
-
this.app = express_1.default();
|
|
39
|
+
this.app = (0, express_1.default)();
|
|
40
|
+
this.app.locals.primary = primary;
|
|
40
41
|
this.nodeInvoker = {
|
|
41
|
-
[constants_1.FN_TYPE.basic]: path_1.normalize(path_1.join(__dirname, './invoker', constants_1.FN_TYPE.basic, 'node.js'))
|
|
42
|
+
[constants_1.FN_TYPE.basic]: (0, path_1.normalize)((0, path_1.join)(__dirname, './invoker', constants_1.FN_TYPE.basic, 'node.js'))
|
|
42
43
|
};
|
|
43
44
|
this.javaInvoker = {
|
|
44
|
-
[constants_1.FN_TYPE.basic]: path_1.join(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'Java' + constants_1.FN_TYPE.basic + 'Invoker')
|
|
45
|
+
[constants_1.FN_TYPE.basic]: (0, path_1.join)(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'Java' + constants_1.FN_TYPE.basic + 'Invoker')
|
|
45
46
|
};
|
|
46
|
-
this.requestFile = path_1.join(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'user_req_body');
|
|
47
|
-
this.responseFile = path_1.join(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'user_res_body');
|
|
48
|
-
this.metaFile = path_1.join(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'user_meta.json');
|
|
47
|
+
this.requestFile = (0, path_1.join)(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'user_req_body');
|
|
48
|
+
this.responseFile = (0, path_1.join)(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'user_res_body');
|
|
49
|
+
this.metaFile = (0, path_1.join)(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'user_meta.json');
|
|
49
50
|
this.runningSlaves = [];
|
|
50
51
|
this.targets = [];
|
|
51
52
|
this.q = new better_queue_1.default((opts, cb) => {
|
|
@@ -61,25 +62,26 @@ class HttpFunctions {
|
|
|
61
62
|
'content-length': opts.req.headers['content-length']
|
|
62
63
|
}
|
|
63
64
|
}));
|
|
64
|
-
const slave = shell_1.spawn(opts.command, opts.options, {
|
|
65
|
+
const slave = (0, shell_1.spawn)(opts.command, opts.options, {
|
|
65
66
|
cwd: opts.pth,
|
|
66
67
|
stdio: 'pipe',
|
|
67
68
|
env: {
|
|
68
69
|
X_ZOHO_CATALYST_IS_LOCAL: 'true',
|
|
70
|
+
X_ZOHO_CATALYST_FUNCTION_LOADED: 'true',
|
|
69
71
|
X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth,
|
|
70
72
|
X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin
|
|
71
73
|
}
|
|
72
74
|
}).RAW();
|
|
73
75
|
(_a = slave.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
|
|
74
|
-
logger_2.info(Buffer.isBuffer(data) ? data.toString() : data);
|
|
76
|
+
(0, logger_2.info)(Buffer.isBuffer(data) ? data.toString() : data);
|
|
75
77
|
});
|
|
76
78
|
(_b = slave.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
|
|
77
79
|
const errorStr = data.toString().trim();
|
|
78
|
-
logger_2.info(errorStr);
|
|
80
|
+
(0, logger_2.info)(errorStr);
|
|
79
81
|
});
|
|
80
82
|
slave.on('uncaughtException', (err, origin) => {
|
|
81
83
|
const errorString = `Caught exception: ${err}\n` + `Exception origin: ${origin}`;
|
|
82
|
-
logger_2.error(errorString);
|
|
84
|
+
(0, logger_2.error)(errorString);
|
|
83
85
|
cb(errorString, null);
|
|
84
86
|
});
|
|
85
87
|
slave.on('exit', (code) => {
|
|
@@ -112,20 +114,22 @@ class HttpFunctions {
|
|
|
112
114
|
const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic]), 10);
|
|
113
115
|
if (this.repl !== undefined) {
|
|
114
116
|
this.app.use((_req, _res, next) => {
|
|
115
|
-
shell_1.clearLine(process.stdout);
|
|
117
|
+
(0, shell_1.clearLine)(process.stdout);
|
|
116
118
|
next();
|
|
117
119
|
});
|
|
118
120
|
}
|
|
119
|
-
this.app.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
121
|
+
if (this.app.locals.primary) {
|
|
122
|
+
this.app.use(logger_1.default);
|
|
123
|
+
this.app.use(cookie_parser_1.default);
|
|
124
|
+
this.app.use((0, project_1.default)({
|
|
125
|
+
id: (0, project_2.getProjectId)(),
|
|
126
|
+
domain_prefix: (0, project_2.getDomainPrefix)(),
|
|
127
|
+
domain: constants_1.ORIGIN.app.replace('https://', ''),
|
|
128
|
+
key: (0, project_2.getDomainKey)(),
|
|
129
|
+
env_name: (0, project_2.getEnvName)()
|
|
130
|
+
}));
|
|
131
|
+
this.app.use(authenticator_1.default);
|
|
132
|
+
}
|
|
129
133
|
const reqHandler = (fnTarget) => (request, response, next) => {
|
|
130
134
|
var _a, _b;
|
|
131
135
|
const urlParts = new url_1.URL(request.originalUrl, request.protocol + '://' + request.get('host')).searchParams;
|
|
@@ -155,9 +159,10 @@ class HttpFunctions {
|
|
|
155
159
|
'x-zc-user-cred-token': request.headers['x-zc-user-cred-token'],
|
|
156
160
|
'x-zc-admin-cred-type': request.headers['x-zc-admin-cred-type'],
|
|
157
161
|
'x-zc-admin-cred-token': request.headers['x-zc-admin-cred-token'],
|
|
158
|
-
'x-zc-cookie': request.headers['x-zc-cookie']
|
|
162
|
+
'x-zc-cookie': request.headers['x-zc-cookie'],
|
|
163
|
+
'x-zc-user-type': request.headers['x-zc-user-type']
|
|
159
164
|
}));
|
|
160
|
-
slaveOptions.push(JSON.stringify(path_1.join(runtime_store_1.default.get('cwd'), '.build')));
|
|
165
|
+
slaveOptions.push(JSON.stringify((0, path_1.join)(runtime_store_1.default.get('cwd'), '.build')));
|
|
161
166
|
slave = this.q.push({
|
|
162
167
|
command: 'node',
|
|
163
168
|
options: slaveOptions,
|
|
@@ -167,18 +172,18 @@ class HttpFunctions {
|
|
|
167
172
|
});
|
|
168
173
|
}
|
|
169
174
|
else if ((_b = fnTarget.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java)) {
|
|
170
|
-
const javaInvokerDir = path_1.parse(this.javaInvoker[fnTarget.type]).dir;
|
|
175
|
+
const javaInvokerDir = (0, path_1.parse)(this.javaInvoker[fnTarget.type]).dir;
|
|
171
176
|
slaveOptions.push('-cp');
|
|
172
177
|
slaveOptions.push(javaInvokerDir +
|
|
173
178
|
fn_utils_1.fnUtils.java.classPathSep +
|
|
174
|
-
path_1.join(javaInvokerDir, 'lib', '*'));
|
|
179
|
+
(0, path_1.join)(javaInvokerDir, 'lib', '*'));
|
|
175
180
|
if (debugPort !== -1) {
|
|
176
181
|
slaveOptions.push('-Xdebug');
|
|
177
182
|
slaveOptions.push('-Xrunjdwp:transport=dt_socket,address=' +
|
|
178
183
|
debugPort +
|
|
179
184
|
',server=y,suspend=y');
|
|
180
185
|
}
|
|
181
|
-
slaveOptions.push(path_1.basename(this.javaInvoker[fnTarget.type]));
|
|
186
|
+
slaveOptions.push((0, path_1.basename)(this.javaInvoker[fnTarget.type]));
|
|
182
187
|
slaveOptions.push(javaInvokerDir);
|
|
183
188
|
slaveOptions.push(JSON.stringify(fnTarget));
|
|
184
189
|
slaveOptions.push(query);
|
|
@@ -233,7 +238,7 @@ class HttpFunctions {
|
|
|
233
238
|
}
|
|
234
239
|
});
|
|
235
240
|
};
|
|
236
|
-
shell_1.clearLine(process.stdout);
|
|
241
|
+
(0, shell_1.clearLine)(process.stdout);
|
|
237
242
|
const masterPort = runtime_store_1.default.get(`context.port.http.master`, -1);
|
|
238
243
|
const fnTargets = runtime_store_1.default.get('context.functions.targets', []);
|
|
239
244
|
fnTargets
|
|
@@ -245,7 +250,7 @@ class HttpFunctions {
|
|
|
245
250
|
.forEach((t) => {
|
|
246
251
|
var _a;
|
|
247
252
|
if ((_a = t.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java)) {
|
|
248
|
-
fn_utils_1.fnUtils.java.ensureJavaInvoker(this.javaInvoker[t.type], path_1.normalize(path_1.join(__dirname, './invoker', t.type, 'java', 'Java' + t.type + 'Invoker.java')));
|
|
253
|
+
fn_utils_1.fnUtils.java.ensureJavaInvoker(this.javaInvoker[t.type], (0, path_1.normalize)((0, path_1.join)(__dirname, './invoker', t.type, 'java', 'Java' + t.type + 'Invoker.java')));
|
|
249
254
|
}
|
|
250
255
|
const pthName = new url_1.URL(t.url).pathname;
|
|
251
256
|
if (pthName !== null) {
|
|
@@ -269,7 +274,7 @@ class HttpFunctions {
|
|
|
269
274
|
}
|
|
270
275
|
});
|
|
271
276
|
(_b = target.watcher) === null || _b === void 0 ? void 0 : _b.on('compiled', () => {
|
|
272
|
-
logger_2.labeled(`functions(${target.name})`, 'ready!').MESSAGE();
|
|
277
|
+
(0, logger_2.labeled)(`functions(${target.name})`, 'ready!').MESSAGE();
|
|
273
278
|
logUrl(target.name, new url_1.URL(target.url).pathname, httpPort, masterPort);
|
|
274
279
|
if (this.repl && this.repl.paused) {
|
|
275
280
|
this.repl.resume();
|
|
@@ -292,7 +297,7 @@ class HttpFunctions {
|
|
|
292
297
|
start() {
|
|
293
298
|
return __awaiter(this, void 0, void 0, function* () {
|
|
294
299
|
const server = yield this._spinUpServer();
|
|
295
|
-
logger_2.info();
|
|
300
|
+
(0, logger_2.info)();
|
|
296
301
|
server.on('connection', (socket) => {
|
|
297
302
|
socket.unref();
|
|
298
303
|
});
|
|
@@ -310,7 +315,7 @@ class HttpFunctions {
|
|
|
310
315
|
yield Promise.all(this.targets.map((target) => __awaiter(this, void 0, void 0, function* () { var _a; return (_a = target.watcher) === null || _a === void 0 ? void 0 : _a.close(); })));
|
|
311
316
|
if (HttpFunctions.server !== null) {
|
|
312
317
|
HttpFunctions.server.close((err) => {
|
|
313
|
-
logger_2.debug(err);
|
|
318
|
+
(0, logger_2.debug)(err);
|
|
314
319
|
res();
|
|
315
320
|
});
|
|
316
321
|
}
|
|
@@ -18,6 +18,7 @@ import java.util.logging.Handler;
|
|
|
18
18
|
import java.util.logging.LogManager;
|
|
19
19
|
import java.util.logging.LogRecord;
|
|
20
20
|
import java.util.logging.Logger;
|
|
21
|
+
import java.util.logging.SimpleFormatter;
|
|
21
22
|
|
|
22
23
|
import org.json.JSONException;
|
|
23
24
|
import org.json.JSONObject;
|
|
@@ -41,7 +42,7 @@ public class JavabioInvoker {
|
|
|
41
42
|
if (record.getThrown() != null) {
|
|
42
43
|
exceptionMessage = getStackTraceAsString(record.getThrown());
|
|
43
44
|
}
|
|
44
|
-
String message =
|
|
45
|
+
String message = new SimpleFormatter().format(record) + " " + exceptionMessage;
|
|
45
46
|
if (message.length() > MESSAGE_LENGTH) {
|
|
46
47
|
message = message.substring(0, MESSAGE_LENGTH);
|
|
47
48
|
}
|
|
@@ -94,10 +95,16 @@ public class JavabioInvoker {
|
|
|
94
95
|
String responseMeta = Paths.get(invokerDir, "user_meta.json").toString();
|
|
95
96
|
|
|
96
97
|
BufferedWriter responseWriter = new BufferedWriter(new FileWriter(responseFilePath));
|
|
97
|
-
|
|
98
|
+
String responseStr = responseJson.toString();
|
|
99
|
+
responseWriter.write(responseStr);
|
|
98
100
|
responseWriter.close();
|
|
99
101
|
|
|
100
102
|
BufferedWriter metaWriter = new BufferedWriter(new FileWriter(responseMeta));
|
|
103
|
+
|
|
104
|
+
JSONObject metaResp = ((JSONObject) metaJson.get("response"));
|
|
105
|
+
metaResp.put("Content-Type", "application/json");
|
|
106
|
+
metaResp.put("Content-Length", responseStr.length());
|
|
107
|
+
|
|
101
108
|
metaWriter.write(metaJson.toString());
|
|
102
109
|
metaWriter.close();
|
|
103
110
|
}
|
|
@@ -158,9 +165,13 @@ public class JavabioInvoker {
|
|
|
158
165
|
|
|
159
166
|
clientAuth.put((userAuthHeaderType.equals("token")) ? "access_token" : "ticket", userAuthToken); // No I18N
|
|
160
167
|
}
|
|
168
|
+
if(auth.containsKey("x-zc-user-type")) { // No I18N
|
|
169
|
+
String userType = auth.get("x-zc-user-type").toString(); // No I18N
|
|
170
|
+
clientAuth.put("user_type", userType); // No I18N
|
|
171
|
+
}
|
|
161
172
|
catalystAuth.put("client_cred", clientAuth);
|
|
162
|
-
|
|
163
173
|
ZCThreadLocal.putValue("CATALYST_AUTH", catalystAuth.toString()); // No I18N
|
|
174
|
+
|
|
164
175
|
if(auth.containsKey("x-zc-cookie")) {
|
|
165
176
|
String cookie = auth.get("x-zc-cookie").toString();
|
|
166
177
|
ZCThreadLocal.putValue("client_cookie", cookie); // No I18N
|
|
@@ -11,8 +11,11 @@ const buildDir = JSON.parse(args[4]);
|
|
|
11
11
|
const requestFile = path.join(buildDir, '.catalyst', 'user_req_body');
|
|
12
12
|
const responseFile = path.join(buildDir, '.catalyst', 'user_res_body');
|
|
13
13
|
const metaFile = path.join(buildDir, '.catalyst', 'user_meta.json');
|
|
14
|
-
const writeToFile = (
|
|
15
|
-
|
|
14
|
+
const writeToFile = (respJson, metaJson) => {
|
|
15
|
+
const respStr = JSON.stringify(respJson);
|
|
16
|
+
fs.writeFileSync(responseFile, respStr);
|
|
17
|
+
metaJson.response['Content-Type'] = 'application/json';
|
|
18
|
+
metaJson.response['Content-Length'] = respStr.length;
|
|
16
19
|
fs.writeFileSync(metaFile, JSON.stringify(metaJson));
|
|
17
20
|
};
|
|
18
21
|
let body = {};
|
|
@@ -18,6 +18,7 @@ import java.util.logging.Handler;
|
|
|
18
18
|
import java.util.logging.LogManager;
|
|
19
19
|
import java.util.logging.LogRecord;
|
|
20
20
|
import java.util.logging.Logger;
|
|
21
|
+
import java.util.logging.SimpleFormatter;
|
|
21
22
|
|
|
22
23
|
import org.json.JSONException;
|
|
23
24
|
import org.json.JSONObject;
|
|
@@ -42,7 +43,7 @@ public class JavacronInvoker {
|
|
|
42
43
|
if (record.getThrown() != null) {
|
|
43
44
|
exceptionMessage = getStackTraceAsString(record.getThrown());
|
|
44
45
|
}
|
|
45
|
-
String message =
|
|
46
|
+
String message = new SimpleFormatter().format(record) + " " + exceptionMessage;
|
|
46
47
|
if (message.length() > MESSAGE_LENGTH) {
|
|
47
48
|
message = message.substring(0, MESSAGE_LENGTH);
|
|
48
49
|
}
|
|
@@ -139,9 +140,13 @@ public class JavacronInvoker {
|
|
|
139
140
|
|
|
140
141
|
clientAuth.put((userAuthHeaderType.equals("token")) ? "access_token" : "ticket", userAuthToken); // No I18N
|
|
141
142
|
}
|
|
143
|
+
if(auth.containsKey("x-zc-user-type")) { // No I18N
|
|
144
|
+
String userType = auth.get("x-zc-user-type").toString(); // No I18N
|
|
145
|
+
clientAuth.put("user_type", userType); // No I18N
|
|
146
|
+
}
|
|
142
147
|
catalystAuth.put("client_cred", clientAuth);
|
|
143
|
-
|
|
144
148
|
ZCThreadLocal.putValue("CATALYST_AUTH", catalystAuth.toString()); // No I18N
|
|
149
|
+
|
|
145
150
|
if(auth.containsKey("x-zc-cookie")) {
|
|
146
151
|
String cookie = auth.get("x-zc-cookie").toString();
|
|
147
152
|
ZCThreadLocal.putValue("client_cookie", cookie); // No I18N
|
|
@@ -18,6 +18,7 @@ import java.util.logging.Handler;
|
|
|
18
18
|
import java.util.logging.LogManager;
|
|
19
19
|
import java.util.logging.LogRecord;
|
|
20
20
|
import java.util.logging.Logger;
|
|
21
|
+
import java.util.logging.SimpleFormatter;
|
|
21
22
|
|
|
22
23
|
import org.json.JSONException;
|
|
23
24
|
import org.json.JSONObject;
|
|
@@ -42,7 +43,7 @@ public class JavaeventInvoker {
|
|
|
42
43
|
if (record.getThrown() != null) {
|
|
43
44
|
exceptionMessage = getStackTraceAsString(record.getThrown());
|
|
44
45
|
}
|
|
45
|
-
String message =
|
|
46
|
+
String message = new SimpleFormatter().format(record) + " " + exceptionMessage;
|
|
46
47
|
if (message.length() > MESSAGE_LENGTH) {
|
|
47
48
|
message = message.substring(0, MESSAGE_LENGTH);
|
|
48
49
|
}
|
|
@@ -139,9 +140,13 @@ public class JavaeventInvoker {
|
|
|
139
140
|
|
|
140
141
|
clientAuth.put((userAuthHeaderType.equals("token")) ? "access_token" : "ticket", userAuthToken); // No I18N
|
|
141
142
|
}
|
|
143
|
+
if(auth.containsKey("x-zc-user-type")) { // No I18N
|
|
144
|
+
String userType = auth.get("x-zc-user-type").toString(); // No I18N
|
|
145
|
+
clientAuth.put("user_type", userType); // No I18N
|
|
146
|
+
}
|
|
142
147
|
catalystAuth.put("client_cred", clientAuth);
|
|
143
|
-
|
|
144
148
|
ZCThreadLocal.putValue("CATALYST_AUTH", catalystAuth.toString()); // No I18N
|
|
149
|
+
|
|
145
150
|
if(auth.containsKey("x-zc-cookie")) {
|
|
146
151
|
String cookie = auth.get("x-zc-cookie").toString();
|
|
147
152
|
ZCThreadLocal.putValue("client_cookie", cookie); // No I18N
|