zcatalyst-cli 1.15.0-beta.7 → 1.15.1
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/command_needs/rc.toml +7 -0
- package/docs/option-filter.toml +2 -2
- package/lib/authentication/login.js +22 -5
- package/lib/command_needs/rc.js +37 -14
- package/lib/commands/functions/shell.js +2 -2
- package/lib/endpoints/lib/sdk.js +1 -4
- package/lib/express_middlewares/unknownReqProxy.js +2 -0
- package/lib/fn-utils/lib/common.js +29 -13
- package/lib/fn-utils/lib/java.js +6 -2
- package/lib/option-filter.js +28 -11
- package/lib/port-resolver.js +9 -1
- package/lib/serve/server/index.js +2 -2
- package/lib/serve/server/lib/node/server/index.js +3 -5
- package/lib/shell/dependencies/http-functions.js +12 -4
- package/lib/shell/dependencies/local-function.js +1 -1
- package/lib/shell/index.js +1 -1
- package/lib/util_modules/constants/lib/browserLogic.js +3 -3
- package/lib/util_modules/constants/lib/template.js +5 -5
- package/lib/util_modules/server.js +1 -1
- package/package.json +2 -2
|
@@ -22,3 +22,10 @@ link = 'https://www.zoho.com/catalyst/help/cli-init.html#Options'
|
|
|
22
22
|
context = '''The project which is currently active doesn't seems to be present in Catalyst remote console.'''
|
|
23
23
|
aid = '''Use the ${arg[0]} command in order to change the existing active project.'''
|
|
24
24
|
link = 'https://www.zoho.com/catalyst/help/cli-projects.html#Use'
|
|
25
|
+
|
|
26
|
+
[RC-6]
|
|
27
|
+
context = '''The Catalyst portal initialized in the current project directory is not accessible with the currently logged in user.\n
|
|
28
|
+
${arg[0]} ${arg[1]}
|
|
29
|
+
${arg[2]} ${arg[3]}'''
|
|
30
|
+
aid = '''Please ensure you've logged-in with the correct user credentials.'''
|
|
31
|
+
link = ''
|
package/docs/option-filter.toml
CHANGED
|
@@ -25,13 +25,13 @@ link = ''
|
|
|
25
25
|
|
|
26
26
|
[OPT-FILTER-6]
|
|
27
27
|
context = '''The input for the ${arg[0]} option is in an invalid format: ${arg[1]}'''
|
|
28
|
-
aid = '''Please use only these valid formats to specify the targets: \n${arg[2]}\n${arg[3]}'''
|
|
28
|
+
aid = '''Please use only these valid formats to specify the targets: \n${arg[2]}\n${arg[3]}\n${arg[4]}'''
|
|
29
29
|
link = ''
|
|
30
30
|
|
|
31
31
|
[OPT-FILTER-7]
|
|
32
32
|
context = '''The input of the ${arg[0]} option for target ${arg[1]} is in an invalid format: ${arg[2]}'''
|
|
33
33
|
aid = '''Please use only the ${arg[3]} format, to specify your ${arg[1]} targets with the ${arg[0]} option.
|
|
34
|
-
example: --debug
|
|
34
|
+
example: --debug ${arg[4]}:fn_name:8001'''
|
|
35
35
|
link = ''
|
|
36
36
|
|
|
37
37
|
[OPT-FILTER-8]
|
|
@@ -12,6 +12,7 @@ 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
|
+
exports.missingScopes = void 0;
|
|
15
16
|
const ansi_colors_1 = require("ansi-colors");
|
|
16
17
|
const http_1 = require("http");
|
|
17
18
|
const server_js_1 = require("../util_modules/server.js");
|
|
@@ -30,6 +31,10 @@ const fs_1 = require("../util_modules/fs");
|
|
|
30
31
|
const js_1 = require("../util_modules/js");
|
|
31
32
|
const logger_1 = require("../util_modules/logger");
|
|
32
33
|
const option_1 = require("../util_modules/option");
|
|
34
|
+
exports.missingScopes = {
|
|
35
|
+
[constants_1.DC_TYPE.au.value]: ['zia_hub'],
|
|
36
|
+
[constants_1.DC_TYPE.eu.value]: ['zia_hub']
|
|
37
|
+
};
|
|
33
38
|
class Login {
|
|
34
39
|
constructor(localhost = true, user = true) {
|
|
35
40
|
this.localhost = localhost;
|
|
@@ -58,7 +63,7 @@ class Login {
|
|
|
58
63
|
'/oauth/v2/auth?' +
|
|
59
64
|
js_1.JS.map({
|
|
60
65
|
client_id: constants_1.AUTH.web.id,
|
|
61
|
-
scope: js_1.JS.values(
|
|
66
|
+
scope: js_1.JS.values(this._getScopes()).join(' '),
|
|
62
67
|
response_type: 'code',
|
|
63
68
|
access_type: 'offline',
|
|
64
69
|
prompt: 'consent',
|
|
@@ -115,7 +120,7 @@ class Login {
|
|
|
115
120
|
qs: {
|
|
116
121
|
client_id: constants_1.AUTH.mobile.id,
|
|
117
122
|
client_secret: constants_1.AUTH.mobile.secret,
|
|
118
|
-
scope: js_1.JS.values(
|
|
123
|
+
scope: js_1.JS.values(this._getScopes()).join(' '),
|
|
119
124
|
grant_type: 'device_token',
|
|
120
125
|
code
|
|
121
126
|
},
|
|
@@ -215,7 +220,7 @@ class Login {
|
|
|
215
220
|
origin: constants_1.ORIGIN.auth,
|
|
216
221
|
qs: {
|
|
217
222
|
client_id: constants_1.AUTH.mobile.id,
|
|
218
|
-
scope: js_1.JS.values(
|
|
223
|
+
scope: js_1.JS.values(this._getScopes()).join(' '),
|
|
219
224
|
grant_type: 'device_request',
|
|
220
225
|
access_type: 'offline',
|
|
221
226
|
prompt: 'consent'
|
|
@@ -260,7 +265,7 @@ class Login {
|
|
|
260
265
|
return {
|
|
261
266
|
user: userDetails,
|
|
262
267
|
token: result,
|
|
263
|
-
scopes: js_1.JS.values(
|
|
268
|
+
scopes: js_1.JS.values(this._getScopes()),
|
|
264
269
|
dc: (0, dc_1.getActiveDC)()
|
|
265
270
|
};
|
|
266
271
|
}
|
|
@@ -322,7 +327,7 @@ class Login {
|
|
|
322
327
|
resolve({
|
|
323
328
|
user: userDetails,
|
|
324
329
|
token: result,
|
|
325
|
-
scopes: js_1.JS.values(
|
|
330
|
+
scopes: js_1.JS.values(this._getScopes()),
|
|
326
331
|
dc: (0, dc_1.getActiveDC)()
|
|
327
332
|
});
|
|
328
333
|
}
|
|
@@ -356,5 +361,17 @@ class Login {
|
|
|
356
361
|
});
|
|
357
362
|
});
|
|
358
363
|
}
|
|
364
|
+
_getScopes() {
|
|
365
|
+
const dc = (0, dc_1.getActiveDC)();
|
|
366
|
+
if (dc in exports.missingScopes) {
|
|
367
|
+
const devoidScopes = exports.missingScopes[dc];
|
|
368
|
+
const _scopes = Object.assign({}, constants_1.SCOPE);
|
|
369
|
+
devoidScopes.forEach((scope) => {
|
|
370
|
+
delete _scopes[scope];
|
|
371
|
+
});
|
|
372
|
+
return _scopes;
|
|
373
|
+
}
|
|
374
|
+
return constants_1.SCOPE;
|
|
375
|
+
}
|
|
359
376
|
}
|
|
360
377
|
exports.default = Login;
|
package/lib/command_needs/rc.js
CHANGED
|
@@ -24,6 +24,8 @@ const js_1 = require("../util_modules/js");
|
|
|
24
24
|
const logger_1 = require("../util_modules/logger");
|
|
25
25
|
const option_1 = require("../util_modules/option");
|
|
26
26
|
const project_2 = require("../util_modules/project");
|
|
27
|
+
const config_store_1 = __importDefault(require("../config-store"));
|
|
28
|
+
const dc_1 = require("../dc");
|
|
27
29
|
exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck = true } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
30
|
const orgOpt = (0, option_1.getGlobalOptionValue)('org', null);
|
|
29
31
|
const projectOpt = (0, option_1.getGlobalOptionValue)('project', null);
|
|
@@ -191,21 +193,42 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
|
|
|
191
193
|
const projectDetails = yield projectApi
|
|
192
194
|
.getProject(finalProjectObj.id + '')
|
|
193
195
|
.catch((err) => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
|
-
if (js_1.JS.hasIn(err, 'context.response.statusCode')
|
|
195
|
-
err.context.response.statusCode
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
if (js_1.JS.hasIn(err, 'context.response.statusCode')) {
|
|
197
|
+
switch (err.context.response.statusCode) {
|
|
198
|
+
case 404: {
|
|
199
|
+
(0, logger_1.message)('cleaning up ' +
|
|
200
|
+
constants_1.FILENAME.rc +
|
|
201
|
+
' since the current active project for this folder is not found in remote');
|
|
202
|
+
yield (0, project_2.removeProject)(finalProjectObj.id + '');
|
|
203
|
+
if (resolveOnNotFound) {
|
|
204
|
+
finalProjectObj = undefined;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
throw new error_1.default('active project not found in remote', {
|
|
208
|
+
exit: 1,
|
|
209
|
+
errorId: 'RC-5',
|
|
210
|
+
arg: [(0, ansi_colors_1.bold)('catalyst project:use')]
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
case 403: {
|
|
214
|
+
const activeDC = (0, dc_1.getActiveDC)();
|
|
215
|
+
const user = config_store_1.default.get(`${activeDC}.user`);
|
|
216
|
+
throw new error_1.default('Invalid org identifier: ' + (finalEnvObj === null || finalEnvObj === void 0 ? void 0 : finalEnvObj.id), {
|
|
217
|
+
original: err,
|
|
218
|
+
errorId: 'RC-6',
|
|
219
|
+
arg: [
|
|
220
|
+
(0, ansi_colors_1.bold)('Current logged in user:'),
|
|
221
|
+
ansi_colors_1.cyan.italic.underline(user
|
|
222
|
+
? user.Email
|
|
223
|
+
? user.Email
|
|
224
|
+
: `${user.First_Name} ${user.Last_Name}`
|
|
225
|
+
: 'unknown user'),
|
|
226
|
+
(0, ansi_colors_1.bold)('Current Org-id:'),
|
|
227
|
+
(0, ansi_colors_1.red)((finalEnvObj === null || finalEnvObj === void 0 ? void 0 : finalEnvObj.id) || '')
|
|
228
|
+
]
|
|
229
|
+
});
|
|
230
|
+
}
|
|
203
231
|
}
|
|
204
|
-
throw new error_1.default('active project not found in remote', {
|
|
205
|
-
exit: 1,
|
|
206
|
-
errorId: 'RC-5',
|
|
207
|
-
arg: [(0, ansi_colors_1.bold)('catalyst project:use')]
|
|
208
|
-
});
|
|
209
232
|
}
|
|
210
233
|
throw err;
|
|
211
234
|
}));
|
|
@@ -56,11 +56,11 @@ exports.default = new command_1.default('functions:shell')
|
|
|
56
56
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
57
|
const httpOpt = (0, option_1.getOptionValue)('http', false);
|
|
58
58
|
if (httpOpt && typeof httpOpt !== 'boolean') {
|
|
59
|
-
runtime_store_1.default.set('context.port.http.
|
|
59
|
+
runtime_store_1.default.set('context.port.http.bio', httpOpt);
|
|
60
60
|
}
|
|
61
61
|
const debugOpt = (0, option_1.getOptionValue)('debug', false);
|
|
62
62
|
if (debugOpt && typeof debugOpt !== 'boolean') {
|
|
63
|
-
runtime_store_1.default.set('context.port.debug.
|
|
63
|
+
runtime_store_1.default.set('context.port.debug.bio', debugOpt);
|
|
64
64
|
}
|
|
65
65
|
return (yield Promise.resolve().then(() => __importStar(require('../../shell')))).default();
|
|
66
66
|
}));
|
package/lib/endpoints/lib/sdk.js
CHANGED
|
@@ -22,9 +22,6 @@ class SDK {
|
|
|
22
22
|
}
|
|
23
23
|
getSdkUrl(fnType, service) {
|
|
24
24
|
switch (fnType) {
|
|
25
|
-
case constants_1.FN_TYPE.browserLogic: {
|
|
26
|
-
return `/downloads/sdk/java/catalyst_java_sdk_beta.zip`;
|
|
27
|
-
}
|
|
28
25
|
case constants_1.FN_TYPE.integration: {
|
|
29
26
|
if (!service) {
|
|
30
27
|
throw new error_1.default('Invalid integration service');
|
|
@@ -32,7 +29,7 @@ class SDK {
|
|
|
32
29
|
if (service === constants_1.INTEG.services.cliq) {
|
|
33
30
|
return `/downloads/sdk/java/${constants_1.INTEG.service_map[service]}/${constants_1.INTEG.java_dependencies[service]}_latest.zip`;
|
|
34
31
|
}
|
|
35
|
-
return '/downloads/sdk/java/
|
|
32
|
+
return '/downloads/sdk/java/catalyst_java_sdk_latest.zip';
|
|
36
33
|
}
|
|
37
34
|
default: {
|
|
38
35
|
return '/downloads/sdk/java/catalyst_java_sdk_latest.zip';
|
|
@@ -380,6 +380,7 @@ exports.findAndReplaceConfigProps = findAndReplaceConfigProps;
|
|
|
380
380
|
function resolveAllFnServePort(targets) {
|
|
381
381
|
return __awaiter(this, void 0, void 0, function* () {
|
|
382
382
|
let isBioHttp = false;
|
|
383
|
+
let isBioDebug = false;
|
|
383
384
|
const debugOpts = runtime_store_1.default.get('context.port.debug', false);
|
|
384
385
|
yield Promise.all(targets.map((target) => __awaiter(this, void 0, void 0, function* () {
|
|
385
386
|
var _a;
|
|
@@ -391,23 +392,35 @@ function resolveAllFnServePort(targets) {
|
|
|
391
392
|
((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value))) {
|
|
392
393
|
curTargetType = constants_1.FN_TYPE.advanced;
|
|
393
394
|
}
|
|
394
|
-
if (debugOpts
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
395
|
+
if (debugOpts) {
|
|
396
|
+
if (!isBioDebug && curTargetType === constants_1.FN_TYPE.basic) {
|
|
397
|
+
isBioDebug = true;
|
|
398
|
+
const debugPort = yield port_resolver_1.default.getPort(curTargetType, 'debug', {
|
|
399
|
+
name: target.name,
|
|
400
|
+
duplicateCheck: true,
|
|
401
|
+
searchSpan: 0
|
|
402
|
+
});
|
|
403
|
+
runtime_store_1.default.set('context.port.debug.' + curTargetType, debugPort);
|
|
404
|
+
}
|
|
405
|
+
else if (typeof debugOpts[curTargetType] === 'object' &&
|
|
406
|
+
target.name in debugOpts[curTargetType]) {
|
|
407
|
+
const debugPort = yield port_resolver_1.default.getPort(curTargetType, 'debug', {
|
|
408
|
+
name: target.name,
|
|
409
|
+
duplicateCheck: false,
|
|
410
|
+
searchSpan: 0
|
|
411
|
+
});
|
|
412
|
+
runtime_store_1.default.set('context.port.debug.functions.' + target.name, debugPort);
|
|
413
|
+
}
|
|
401
414
|
}
|
|
402
415
|
if (curTargetType === constants_1.FN_TYPE.basic && isBioHttp) {
|
|
403
416
|
return;
|
|
404
417
|
}
|
|
405
|
-
const httpPort = yield port_resolver_1.default.getPort(
|
|
418
|
+
const httpPort = yield port_resolver_1.default.getPort(curTargetType, 'http', {
|
|
406
419
|
name: target.name,
|
|
407
420
|
duplicateCheck: curTargetType === constants_1.FN_TYPE.advanced || curTargetType === constants_1.FN_TYPE.browserLogic
|
|
408
421
|
});
|
|
409
422
|
if (curTargetType === constants_1.FN_TYPE.basic) {
|
|
410
|
-
runtime_store_1.default.set('context.port.http.' + constants_1.
|
|
423
|
+
runtime_store_1.default.set('context.port.http.' + constants_1.FN_TYPE.basic, httpPort);
|
|
411
424
|
isBioHttp = true;
|
|
412
425
|
}
|
|
413
426
|
else {
|
|
@@ -415,7 +428,10 @@ function resolveAllFnServePort(targets) {
|
|
|
415
428
|
}
|
|
416
429
|
})));
|
|
417
430
|
if (debugOpts && 'basicio' in debugOpts) {
|
|
418
|
-
const bioDebugPort = yield port_resolver_1.default.getPort(
|
|
431
|
+
const bioDebugPort = yield port_resolver_1.default.getPort('bio', 'debug', {
|
|
432
|
+
duplicateCheck: false,
|
|
433
|
+
searchSpan: 0
|
|
434
|
+
});
|
|
419
435
|
runtime_store_1.default.set('context.port.debug.basicio', bioDebugPort);
|
|
420
436
|
}
|
|
421
437
|
});
|
|
@@ -430,11 +446,11 @@ function resolveAllFnPorts(targets) {
|
|
|
430
446
|
return resolveAllFnServePort(targets);
|
|
431
447
|
}
|
|
432
448
|
case 'functions:shell': {
|
|
433
|
-
if (runtime_store_1.default.get('context.port.http.
|
|
434
|
-
const bioHttpPort = yield port_resolver_1.default.getPort('
|
|
449
|
+
if (runtime_store_1.default.get('context.port.http.' + constants_1.FN_TYPE.basic, false)) {
|
|
450
|
+
const bioHttpPort = yield port_resolver_1.default.getPort('bio', 'http', {
|
|
435
451
|
duplicateCheck: false
|
|
436
452
|
});
|
|
437
|
-
runtime_store_1.default.set('context.port.http.' + constants_1.
|
|
453
|
+
runtime_store_1.default.set('context.port.http.' + constants_1.FN_TYPE.basic, bioHttpPort);
|
|
438
454
|
}
|
|
439
455
|
break;
|
|
440
456
|
}
|
package/lib/fn-utils/lib/java.js
CHANGED
|
@@ -433,8 +433,12 @@ function cleanUp(files) {
|
|
|
433
433
|
}
|
|
434
434
|
function getTemplatePath(fnType, add) {
|
|
435
435
|
switch (fnType) {
|
|
436
|
-
case constants_1.FN_TYPE.browserLogic:
|
|
437
|
-
|
|
436
|
+
case constants_1.FN_TYPE.browserLogic: {
|
|
437
|
+
if (Object.keys(constants_1.TEMPLATE.functions.java.browserlogic).includes('Selenium')) {
|
|
438
|
+
return constants_1.TEMPLATE.functions.java.browserlogic.Selenium;
|
|
439
|
+
}
|
|
440
|
+
throw new error_1.default('Invalid browserlogic type', { exit: 2 });
|
|
441
|
+
}
|
|
438
442
|
case constants_1.FN_TYPE.integration: {
|
|
439
443
|
if (!add) {
|
|
440
444
|
throw new error_1.default('Invalid additional parameter', { exit: 2 });
|
package/lib/option-filter.js
CHANGED
|
@@ -44,9 +44,10 @@ const onlyExceptTargets = [
|
|
|
44
44
|
];
|
|
45
45
|
const portTargets = [
|
|
46
46
|
{ filterName: ['appsail'], target: 'appsail' },
|
|
47
|
-
{ filterName: ['advancedio', 'aio'], target: '
|
|
48
|
-
{ filterName: ['basicio', 'bio'], target: '
|
|
49
|
-
{ filterName: ['client'], target: 'client' }
|
|
47
|
+
{ filterName: ['advancedio', 'aio'], target: 'aio' },
|
|
48
|
+
{ filterName: ['basicio', 'bio'], target: 'bio' },
|
|
49
|
+
{ filterName: ['client'], target: 'client' },
|
|
50
|
+
{ filterName: ['browser_logic', 'browserlogic'], target: 'browserlogic' }
|
|
50
51
|
];
|
|
51
52
|
function enrichOptsData(opt, optValue, validTargets, multiTargetSupport = true) {
|
|
52
53
|
if (optValue === undefined || typeof optValue === 'boolean') {
|
|
@@ -160,7 +161,9 @@ function validatePorts() {
|
|
|
160
161
|
(0, ansi_colors_1.bold)('--debug'),
|
|
161
162
|
ansi_colors_1.italic.red('--debug <target>'),
|
|
162
163
|
(0, ansi_colors_1.bold)('* basicio: ') + ansi_colors_1.italic.green('--debug <basicio|bio>:<port>'),
|
|
163
|
-
(0, ansi_colors_1.bold)('* advancedio: ') + ansi_colors_1.italic.green('--debug <advancedio|aio>:<name>:<port>')
|
|
164
|
+
(0, ansi_colors_1.bold)('* advancedio: ') + ansi_colors_1.italic.green('--debug <advancedio|aio>:<name>:<port>'),
|
|
165
|
+
(0, ansi_colors_1.bold)('* browserlogic: ') +
|
|
166
|
+
ansi_colors_1.italic.green('--debug <browserlogic|browser_logic>:<name>:<port>')
|
|
164
167
|
]
|
|
165
168
|
});
|
|
166
169
|
}
|
|
@@ -173,20 +176,34 @@ function filterPorts() {
|
|
|
173
176
|
const validOptResultants = validatePorts();
|
|
174
177
|
runtime_store_1.default.set(`context.port.http.master`, validOptResultants.port);
|
|
175
178
|
validOptResultants.debug.forEach((res) => {
|
|
176
|
-
if (res.target.target === constants_1.
|
|
177
|
-
|
|
179
|
+
if ((res.target.target === constants_1.FN_TYPE.advanced ||
|
|
180
|
+
res.target.target === constants_1.FN_TYPE.browserLogic) &&
|
|
181
|
+
!res.specific) {
|
|
182
|
+
const targMap = {
|
|
183
|
+
aio: {
|
|
184
|
+
filter: 'advancedio|aio',
|
|
185
|
+
targName: constants_1.REMOTE_REF.functions.type[res.target.target]
|
|
186
|
+
},
|
|
187
|
+
browserlogic: {
|
|
188
|
+
filter: 'browser_logic|browserlogic',
|
|
189
|
+
targName: constants_1.REMOTE_REF.functions.type[res.target.target]
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const targ = targMap[res.target.target];
|
|
193
|
+
throw new error_1.default(`Invalid input format for ${targ} target`, {
|
|
178
194
|
exit: 1,
|
|
179
195
|
errorId: 'OPT-FILTER-7',
|
|
180
196
|
arg: [
|
|
181
197
|
(0, ansi_colors_1.bold)('--debug'),
|
|
182
|
-
(0, ansi_colors_1.bold)(
|
|
183
|
-
ansi_colors_1.italic.red(
|
|
184
|
-
ansi_colors_1.italic.green(
|
|
198
|
+
(0, ansi_colors_1.bold)(targ.targName),
|
|
199
|
+
ansi_colors_1.italic.red(`--debug <${targ.filter}>:<name|port>`),
|
|
200
|
+
ansi_colors_1.italic.green(`--debug <${targ.filter}>:<name>:<port>`),
|
|
201
|
+
targ.targName
|
|
185
202
|
]
|
|
186
203
|
});
|
|
187
204
|
}
|
|
188
|
-
else if (res.target.target === constants_1.
|
|
189
|
-
runtime_store_1.default.set(`context.port.debug.${constants_1.
|
|
205
|
+
else if (res.target.target === constants_1.FN_TYPE.basic) {
|
|
206
|
+
runtime_store_1.default.set(`context.port.debug.${constants_1.FN_TYPE.basic}`, res.filter);
|
|
190
207
|
}
|
|
191
208
|
else {
|
|
192
209
|
runtime_store_1.default.set(`context.port.debug.${res.target.target}.${res.filter}`, res.specific);
|
package/lib/port-resolver.js
CHANGED
|
@@ -24,6 +24,14 @@ const error_1 = __importDefault(require("./error"));
|
|
|
24
24
|
const runtime_store_1 = __importDefault(require("./runtime-store"));
|
|
25
25
|
const constants_1 = require("./util_modules/constants");
|
|
26
26
|
const logger_1 = require("./util_modules/logger");
|
|
27
|
+
const featureRef = {
|
|
28
|
+
client: 'client',
|
|
29
|
+
aio: 'advancedio',
|
|
30
|
+
bio: 'basicio',
|
|
31
|
+
master: 'master',
|
|
32
|
+
appsail: 'appsail',
|
|
33
|
+
browserlogic: 'browser_logic'
|
|
34
|
+
};
|
|
27
35
|
class PortResolver {
|
|
28
36
|
static getFreePort(startPort, searchSpan, dupCheck) {
|
|
29
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -62,7 +70,7 @@ class PortResolver {
|
|
|
62
70
|
port = constants_1.DEFAULT.serve_port['http']['appsail'][server];
|
|
63
71
|
}
|
|
64
72
|
else {
|
|
65
|
-
port = constants_1.DEFAULT.serve_port[type][feature];
|
|
73
|
+
port = constants_1.DEFAULT.serve_port[type][featureRef[feature]];
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
else {
|
|
@@ -58,8 +58,8 @@ class Server {
|
|
|
58
58
|
if (fnTargets.length === 0) {
|
|
59
59
|
(0, logger_1.debug)('No basic functions to add');
|
|
60
60
|
}
|
|
61
|
-
const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.
|
|
62
|
-
const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.
|
|
61
|
+
const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.FN_TYPE.basic), 10);
|
|
62
|
+
const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.FN_TYPE.basic, '-1'), 10);
|
|
63
63
|
if (!isNaN(httpPort)) {
|
|
64
64
|
fnTargets
|
|
65
65
|
.filter((t) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { createServer } from 'http';
|
|
4
4
|
import { inspect } from 'util';
|
|
5
5
|
import { pathToFileURL } from 'url';
|
|
6
6
|
|
|
@@ -8,8 +8,6 @@ const args = process.argv.slice(2);
|
|
|
8
8
|
const listenPort = parseInt(args[0], 10);
|
|
9
9
|
const fnDetails = JSON.parse(args[1]);
|
|
10
10
|
|
|
11
|
-
const app = express();
|
|
12
|
-
|
|
13
11
|
const targetName = fnDetails.name;
|
|
14
12
|
const index = pathToFileURL(fnDetails.index);
|
|
15
13
|
const type = fnDetails.type;
|
|
@@ -69,9 +67,9 @@ const browserLogicHandler = async (req, res) => {
|
|
|
69
67
|
}
|
|
70
68
|
};
|
|
71
69
|
|
|
72
|
-
|
|
70
|
+
const server = createServer(type === 'browserlogic' ? browserLogicHandler : aioHandler);
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
server.listen(listenPort).on('error', (err) => {
|
|
75
73
|
// eslint-disable-next-line no-console
|
|
76
74
|
console.error(err);
|
|
77
75
|
});
|
|
@@ -117,6 +117,11 @@ class HttpFunctions {
|
|
|
117
117
|
cb(errorString, null);
|
|
118
118
|
});
|
|
119
119
|
slave.on('exit', (code) => {
|
|
120
|
+
if (!fs_1.SYNC.fileExists(this.responseFile)) {
|
|
121
|
+
(0, logger_2.debug)(`${this.responseFile} not present`);
|
|
122
|
+
cb(new Error('File does not exists: ' + this.responseFile));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
120
125
|
const response = fs_1.SYNC.getReadStream(this.responseFile);
|
|
121
126
|
const metaFileString = fs_1.SYNC.readFile(this.metaFile);
|
|
122
127
|
let meta = {};
|
|
@@ -138,12 +143,15 @@ class HttpFunctions {
|
|
|
138
143
|
}
|
|
139
144
|
});
|
|
140
145
|
this.runningSlaves.push(slave);
|
|
141
|
-
}, { batchSize: 1, concurrent: 1, maxTimeout: Infinity })
|
|
146
|
+
}, { batchSize: 1, concurrent: 1, maxTimeout: Infinity }).on('task_failed', (targetName, err) => {
|
|
147
|
+
(0, logger_2.debug)('Unable to serve the function: ' + targetName);
|
|
148
|
+
(0, logger_2.debug)(err);
|
|
149
|
+
});
|
|
142
150
|
}
|
|
143
151
|
_spinUpServer() {
|
|
144
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.
|
|
146
|
-
const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.
|
|
153
|
+
const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.FN_TYPE.basic, '-1'), 10);
|
|
154
|
+
const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.FN_TYPE.basic), 10);
|
|
147
155
|
if (this.repl !== undefined) {
|
|
148
156
|
this.app.use((_req, _res, next) => {
|
|
149
157
|
(0, shell_1.clearLine)(process.stdout);
|
|
@@ -151,7 +159,7 @@ class HttpFunctions {
|
|
|
151
159
|
});
|
|
152
160
|
}
|
|
153
161
|
if (this.app.locals.primary) {
|
|
154
|
-
this.app.use(logger_1.default);
|
|
162
|
+
this.app.use((0, logger_1.default)());
|
|
155
163
|
this.app.use(cookie_parser_1.default);
|
|
156
164
|
this.app.use((0, project_1.default)({
|
|
157
165
|
id: (0, project_2.getProjectId)(),
|
|
@@ -91,7 +91,7 @@ class LocalFunction {
|
|
|
91
91
|
const projectRoot = runtime_store_1.default.get('project.root');
|
|
92
92
|
const accessToken = yield credential_1.default.getAccessToken();
|
|
93
93
|
const slaveOptions = [];
|
|
94
|
-
const debugPort = runtime_store_1.default.get('context.port.debug.' + constants_1.
|
|
94
|
+
const debugPort = runtime_store_1.default.get('context.port.debug.' + constants_1.FN_TYPE.basic, null);
|
|
95
95
|
yield fs_1.ASYNC.ensureFile(this.responseFile, true);
|
|
96
96
|
yield fs_1.ASYNC.ensureFile(this.metaFile, true);
|
|
97
97
|
if ((_a = this.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) {
|
package/lib/shell/index.js
CHANGED
|
@@ -78,7 +78,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
78
78
|
replServer.setContext(target.name, localFn.call);
|
|
79
79
|
target.localFn = localFn;
|
|
80
80
|
})));
|
|
81
|
-
if (runtime_store_1.default.get('context.port.http.' + constants_1.
|
|
81
|
+
if (runtime_store_1.default.get('context.port.http.' + constants_1.FN_TYPE.basic, false)) {
|
|
82
82
|
yield httpServer.start();
|
|
83
83
|
}
|
|
84
84
|
yield replServer.wait();
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = Object.freeze({
|
|
4
4
|
nodejs: {
|
|
5
|
-
Puppeteer: { 'puppeteer-core': 'latest', 'zcatalyst-sdk-node': '
|
|
6
|
-
Playwright: { 'playwright-core': 'latest', 'zcatalyst-sdk-node': '
|
|
7
|
-
Selenium: { 'selenium-webdriver': 'latest', 'zcatalyst-sdk-node': '
|
|
5
|
+
Puppeteer: { 'puppeteer-core': 'latest', 'zcatalyst-sdk-node': 'latest' },
|
|
6
|
+
Playwright: { 'playwright-core': 'latest', 'zcatalyst-sdk-node': 'latest' },
|
|
7
|
+
Selenium: { 'selenium-webdriver': 'latest', 'zcatalyst-sdk-node': 'latest' }
|
|
8
8
|
},
|
|
9
9
|
java: {
|
|
10
10
|
Selenium: [
|
|
@@ -35,9 +35,9 @@ exports.default = Object.freeze({
|
|
|
35
35
|
[constants_1.INTEG.services.convokraft]: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'integ', 'convokraft')
|
|
36
36
|
},
|
|
37
37
|
[constants_1.FN_TYPE.browserLogic]: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
Playwright: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'browserlogic', 'playwright'),
|
|
39
|
+
Puppeteer: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'browserlogic', 'puppeteer'),
|
|
40
|
+
Selenium: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'browserlogic', 'selenium')
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
java: {
|
|
@@ -50,8 +50,8 @@ exports.default = Object.freeze({
|
|
|
50
50
|
[constants_1.INTEG.services.convokraft]: (0, path_1.join)(FUNCTIONS_JAVA_ROOT, 'integ', 'convokraft')
|
|
51
51
|
},
|
|
52
52
|
[constants_1.FN_TYPE.browserLogic]: {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
Selenium: (0, path_1.join)(FUNCTIONS_JAVA_ROOT, 'browserlogic', 'selenium'),
|
|
54
|
+
Playwright: (0, path_1.join)(FUNCTIONS_JAVA_ROOT, 'browserlogic', 'playwright')
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
python: {
|
|
@@ -20,7 +20,7 @@ class ConnectionDestroyer {
|
|
|
20
20
|
this.connections = new Set();
|
|
21
21
|
if (this.server instanceof http_proxy_1.default) {
|
|
22
22
|
this.server.on('proxyReq', (req) => {
|
|
23
|
-
req.on('
|
|
23
|
+
req.on('close', () => this.connections.delete(req));
|
|
24
24
|
this.connections.add(req);
|
|
25
25
|
});
|
|
26
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcatalyst-cli",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "Command Line Tool for CATALYST",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/inquirer-autocomplete-prompt": "^1.3.4",
|
|
71
71
|
"@types/jest": "^27.4.1",
|
|
72
72
|
"@types/lodash": "^4.14.182",
|
|
73
|
-
"@types/minimatch": "^
|
|
73
|
+
"@types/minimatch": "^5.1.2",
|
|
74
74
|
"@types/node": "^17.0.25",
|
|
75
75
|
"@types/request": "^2.48.8",
|
|
76
76
|
"@types/semver": "^7.3.9",
|