zcatalyst-cli 1.13.0 → 1.13.3
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/apig-utils.toml +5 -0
- package/lib/apig-utils.js +12 -0
- package/lib/client-utils.js +25 -4
- package/lib/command_needs/rc.js +8 -1
- package/lib/express_middlewares/authenticator.js +5 -6
- package/lib/internal/rc.js +1 -1
- package/lib/serve/server/index.js +9 -0
- 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-function-sdk-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
- package/lib/shell/dependencies/http-functions.js +2 -1
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +7 -0
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +6 -0
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +6 -0
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +6 -0
- package/lib/util_modules/constants/lib/scopes.js +1 -0
- package/package.json +1 -1
- 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
- package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
package/docs/apig-utils.toml
CHANGED
|
@@ -67,3 +67,8 @@ link = 'https://www.zoho.com/catalyst/help/api-gateway.html'
|
|
|
67
67
|
context = '''Unable to recognise the ${arg[0]}(${arg[1]}) provided for the APIG rule ${arg[2]}.'''
|
|
68
68
|
aid = '''Please provide a valid Catalyst URL as the ${arg[0]}.'''
|
|
69
69
|
link = 'https://www.zoho.com/catalyst/help/api-gateway.html#Routing'
|
|
70
|
+
|
|
71
|
+
[APIG-UTILS-15]
|
|
72
|
+
context = '''The Regular Expression provided for the rule ${arg[0]} is in an Invalid format.'''
|
|
73
|
+
aid = '''The Regular Expression must be in the format of ${arg[1]}. Where, ${arg[2]} is the name of dynamic value and ${arg[3]} is the Regular Expression.'''
|
|
74
|
+
link = 'https://www.zoho.com/catalyst/help/api-gateway.html#Routingl'
|
package/lib/apig-utils.js
CHANGED
|
@@ -194,6 +194,18 @@ exports.apigUtils = {
|
|
|
194
194
|
.map((part, currentIdx, allParts) => {
|
|
195
195
|
if (part.startsWith('{')) {
|
|
196
196
|
const regexParts = part.slice(1, -1).split(':');
|
|
197
|
+
if (regexParts.length !== 2) {
|
|
198
|
+
throw new error_1.default('Invalid regex format', {
|
|
199
|
+
errorId: 'APIG-UTILS-15',
|
|
200
|
+
exit: 1,
|
|
201
|
+
arg: [
|
|
202
|
+
(0, ansi_colors_1.red)(rule.name),
|
|
203
|
+
ansi_colors_1.italic.green(`"{var:regex}"`),
|
|
204
|
+
(0, ansi_colors_1.bold)('var'),
|
|
205
|
+
(0, ansi_colors_1.bold)('regex')
|
|
206
|
+
]
|
|
207
|
+
});
|
|
208
|
+
}
|
|
197
209
|
try {
|
|
198
210
|
rule.name, new RegExp(regexParts[1]);
|
|
199
211
|
}
|
package/lib/client-utils.js
CHANGED
|
@@ -27,6 +27,7 @@ const js_1 = require("./util_modules/js");
|
|
|
27
27
|
const logger_1 = require("./util_modules/logger");
|
|
28
28
|
const option_1 = require("./util_modules/option");
|
|
29
29
|
const project_1 = require("./util_modules/project");
|
|
30
|
+
const stream_1 = require("stream");
|
|
30
31
|
exports.clientUtils = {
|
|
31
32
|
validate: (source) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
33
|
const sourceDir = source || (0, project_1.resolveProjectPath)(config_1.clientConfig.source());
|
|
@@ -76,13 +77,19 @@ exports.clientUtils = {
|
|
|
76
77
|
runtime_store_1.default.set('context.client.valid', true);
|
|
77
78
|
return packageJson;
|
|
78
79
|
}
|
|
80
|
+
const logStreamPlugin = yield (0, plugin_loader_1.default)('client', 'logs').catch((err) => (0, logger_1.debug)(err));
|
|
81
|
+
let stream;
|
|
82
|
+
const streamLogFn = (chunk) => (0, logger_1.log)('info', chunk.toString(), true);
|
|
83
|
+
if (typeof logStreamPlugin === 'function') {
|
|
84
|
+
stream = yield logStreamPlugin();
|
|
85
|
+
stream instanceof stream_1.Stream && stream.on('data', streamLogFn);
|
|
86
|
+
}
|
|
79
87
|
try {
|
|
80
88
|
yield validatePlugin((0, option_1.getCurrentCommand)(), sourceDir, runtime_store_1.default, packageJson);
|
|
81
89
|
}
|
|
82
90
|
catch (e) {
|
|
83
91
|
const err = error_1.default.getErrorInstance(e, {
|
|
84
|
-
skipHelp: false
|
|
85
|
-
fileName: __filename
|
|
92
|
+
skipHelp: false
|
|
86
93
|
});
|
|
87
94
|
err.errorId = 'CLIENT-UTILS-5';
|
|
88
95
|
err.arg = [
|
|
@@ -92,6 +99,9 @@ exports.clientUtils = {
|
|
|
92
99
|
];
|
|
93
100
|
throw err;
|
|
94
101
|
}
|
|
102
|
+
finally {
|
|
103
|
+
stream instanceof stream_1.Stream && stream.removeListener('data', streamLogFn);
|
|
104
|
+
}
|
|
95
105
|
runtime_store_1.default.set('context.client.valid', true);
|
|
96
106
|
return packageJson;
|
|
97
107
|
}),
|
|
@@ -110,8 +120,16 @@ exports.clientUtils = {
|
|
|
110
120
|
let source = (0, project_1.resolveProjectPath)(config_1.clientConfig.source());
|
|
111
121
|
const buildPlugin = yield (0, plugin_loader_1.default)('client', 'build').catch((err) => (0, logger_1.debug)(err));
|
|
112
122
|
if (typeof buildPlugin === 'function') {
|
|
123
|
+
const logStreamPlugin = yield (0, plugin_loader_1.default)('client', 'logs').catch((err) => (0, logger_1.debug)(err));
|
|
124
|
+
let stream;
|
|
125
|
+
const streamLogFn = (chunk) => (0, logger_1.log)('info', chunk.toString(), true);
|
|
126
|
+
if (typeof logStreamPlugin === 'function') {
|
|
127
|
+
stream = yield logStreamPlugin();
|
|
128
|
+
stream instanceof stream_1.Stream && stream.on('data', streamLogFn);
|
|
129
|
+
}
|
|
113
130
|
try {
|
|
114
131
|
(0, logger_1.message)(`Plugin : "${runtime_store_1.default.get(`context.client.plugins.build`)}" is used for client deploy`);
|
|
132
|
+
(0, logger_1.message)('Building Application...');
|
|
115
133
|
const outputDir = yield buildPlugin(source, runtime_store_1.default);
|
|
116
134
|
if (typeof outputDir !== 'string') {
|
|
117
135
|
throw new Error('unexpected return value from build plugin, ' + source);
|
|
@@ -120,8 +138,7 @@ exports.clientUtils = {
|
|
|
120
138
|
}
|
|
121
139
|
catch (e) {
|
|
122
140
|
const err = error_1.default.getErrorInstance(e, {
|
|
123
|
-
skipHelp: false
|
|
124
|
-
fileName: __filename
|
|
141
|
+
skipHelp: false
|
|
125
142
|
});
|
|
126
143
|
err.errorId = 'CLIENT-UTILS-5';
|
|
127
144
|
err.arg = [
|
|
@@ -131,6 +148,10 @@ exports.clientUtils = {
|
|
|
131
148
|
];
|
|
132
149
|
throw err;
|
|
133
150
|
}
|
|
151
|
+
finally {
|
|
152
|
+
stream instanceof stream_1.Stream &&
|
|
153
|
+
stream.removeListener('data', streamLogFn);
|
|
154
|
+
}
|
|
134
155
|
}
|
|
135
156
|
const exclude = config_1.clientConfig.ignore(source);
|
|
136
157
|
const files = yield fs_1.ASYNC.walk(source, { exclude });
|
package/lib/command_needs/rc.js
CHANGED
|
@@ -145,7 +145,9 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
|
|
|
145
145
|
arg: [(0, ansi_colors_1.bold)(constants_1.FILENAME.rc), (0, ansi_colors_1.bold)('catalyst init project'), (0, ansi_colors_1.bold)('--option')]
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
const projectDetails = yield projectApi
|
|
149
|
+
.getProject(finalProjectObj.id + '')
|
|
150
|
+
.catch((err) => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
151
|
if (js_1.JS.hasIn(err, 'context.response.statusCode') &&
|
|
150
152
|
err.context.response.statusCode === 404) {
|
|
151
153
|
(0, logger_1.message)('cleaning up ' +
|
|
@@ -164,6 +166,11 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
|
|
|
164
166
|
}
|
|
165
167
|
throw err;
|
|
166
168
|
}));
|
|
169
|
+
if (projectDetails && projectDetails.project_name !== finalProjectObj.name) {
|
|
170
|
+
finalProjectObj.name = projectDetails.project_name;
|
|
171
|
+
finalProjectObj.domain.name = projectDetails.project_domain_details.project_domain_name;
|
|
172
|
+
rcInstance.upsertProject(finalProjectObj);
|
|
173
|
+
}
|
|
167
174
|
if (finalProjectObj === undefined) {
|
|
168
175
|
return;
|
|
169
176
|
}
|
|
@@ -49,6 +49,10 @@ exports.default = (req, _RES, next) => __awaiter(void 0, void 0, void 0, functio
|
|
|
49
49
|
req.headers['x-zc-user-type'] = 'project-user';
|
|
50
50
|
req.headers['x-zc-user-cred-type'] = 'token';
|
|
51
51
|
req.headers['x-zc-user-cred-token'] = (_a = req.headers.authorization) === null || _a === void 0 ? void 0 : _a.split(' ')[1];
|
|
52
|
+
if (req.headers['x-zc-user-cred-token'] === undefined) {
|
|
53
|
+
next(new Error('Provided "authorization" header is not valid'));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
else {
|
|
@@ -58,10 +62,5 @@ exports.default = (req, _RES, next) => __awaiter(void 0, void 0, void 0, functio
|
|
|
58
62
|
}
|
|
59
63
|
req.headers['x-zc-admin-cred-type'] = 'token';
|
|
60
64
|
req.headers['x-zc-admin-cred-token'] = accessToken;
|
|
61
|
-
|
|
62
|
-
next(new Error('Provided "authorization" header is not valid'));
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
next();
|
|
66
|
-
}
|
|
65
|
+
next();
|
|
67
66
|
});
|
package/lib/internal/rc.js
CHANGED
|
@@ -111,7 +111,7 @@ class RC {
|
|
|
111
111
|
projectObj.env = envArr;
|
|
112
112
|
return this.save();
|
|
113
113
|
}
|
|
114
|
-
upsertProject(project, { base = false, ignoreEnv = true, active = false }) {
|
|
114
|
+
upsertProject(project, { base = false, ignoreEnv = true, active = false } = {}) {
|
|
115
115
|
const projectArr = this.projects;
|
|
116
116
|
const existingProjArr = js_1.JS.remove(projectArr, (obj) => obj.id + '' === project.id + '');
|
|
117
117
|
let lastIdx = js_1.JS.size(projectArr);
|
|
@@ -59,6 +59,7 @@ const logger_1 = require("../../util_modules/logger");
|
|
|
59
59
|
const shell_1 = require("../../util_modules/shell");
|
|
60
60
|
const master_1 = __importDefault(require("./lib/master"));
|
|
61
61
|
const ansi_colors_1 = require("ansi-colors");
|
|
62
|
+
const stream_1 = require("stream");
|
|
62
63
|
class Server {
|
|
63
64
|
constructor() {
|
|
64
65
|
this.targetDetailsArr = [];
|
|
@@ -149,6 +150,14 @@ class Server {
|
|
|
149
150
|
const configType = details.type === 'server' ? 'functions' : details.type;
|
|
150
151
|
const servePlugin = yield (0, plugin_loader_1.default)(configType, 'start', targetSource).catch((err) => (0, logger_1.debug)(err));
|
|
151
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
|
+
}
|
|
152
161
|
const event = servePlugin(details, masterPort).catch((e) => {
|
|
153
162
|
var _a, _b;
|
|
154
163
|
const err = error_1.default.getErrorInstance(e, {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -198,7 +198,8 @@ class HttpFunctions {
|
|
|
198
198
|
'x-zc-user-cred-token': request.headers['x-zc-user-cred-token'],
|
|
199
199
|
'x-zc-admin-cred-type': request.headers['x-zc-admin-cred-type'],
|
|
200
200
|
'x-zc-admin-cred-token': request.headers['x-zc-admin-cred-token'],
|
|
201
|
-
'x-zc-cookie': request.headers['x-zc-cookie']
|
|
201
|
+
'x-zc-cookie': request.headers['x-zc-cookie'],
|
|
202
|
+
'x-zc-user-type': request.headers['x-zc-user-type']
|
|
202
203
|
}));
|
|
203
204
|
slave = this.q.push({
|
|
204
205
|
command: 'java',
|
|
@@ -169,13 +169,20 @@ public class JavabioInvoker {
|
|
|
169
169
|
String userType = auth.get("x-zc-user-type").toString(); // No I18N
|
|
170
170
|
clientAuth.put("user_type", userType); // No I18N
|
|
171
171
|
}
|
|
172
|
+
if (auth.containsKey("x-zc-cookie")) {
|
|
173
|
+
String cookie = auth.get("x-zc-cookie").toString();
|
|
174
|
+
clientAuth.put("cookie", cookie);
|
|
175
|
+
}
|
|
172
176
|
catalystAuth.put("client_cred", clientAuth);
|
|
177
|
+
|
|
173
178
|
ZCThreadLocal.putValue("CATALYST_AUTH", catalystAuth.toString()); // No I18N
|
|
174
179
|
|
|
180
|
+
// For backward compatibility, to be remove in future.
|
|
175
181
|
if(auth.containsKey("x-zc-cookie")) {
|
|
176
182
|
String cookie = auth.get("x-zc-cookie").toString();
|
|
177
183
|
ZCThreadLocal.putValue("client_cookie", cookie); // No I18N
|
|
178
184
|
}
|
|
185
|
+
// to be removed in future
|
|
179
186
|
}
|
|
180
187
|
|
|
181
188
|
public static void main(String[] args) {
|
|
@@ -144,13 +144,19 @@ public class JavacronInvoker {
|
|
|
144
144
|
String userType = auth.get("x-zc-user-type").toString(); // No I18N
|
|
145
145
|
clientAuth.put("user_type", userType); // No I18N
|
|
146
146
|
}
|
|
147
|
+
if (auth.containsKey("x-zc-cookie")) {
|
|
148
|
+
String cookie = auth.get("x-zc-cookie").toString();
|
|
149
|
+
clientAuth.put("cookie", cookie);
|
|
150
|
+
}
|
|
147
151
|
catalystAuth.put("client_cred", clientAuth);
|
|
148
152
|
ZCThreadLocal.putValue("CATALYST_AUTH", catalystAuth.toString()); // No I18N
|
|
149
153
|
|
|
154
|
+
// For backward compatibility, to be remove in future.
|
|
150
155
|
if(auth.containsKey("x-zc-cookie")) {
|
|
151
156
|
String cookie = auth.get("x-zc-cookie").toString();
|
|
152
157
|
ZCThreadLocal.putValue("client_cookie", cookie); // No I18N
|
|
153
158
|
}
|
|
159
|
+
// to be removed in future
|
|
154
160
|
}
|
|
155
161
|
|
|
156
162
|
public static void main(String[] args) {
|
|
@@ -144,13 +144,19 @@ public class JavaeventInvoker {
|
|
|
144
144
|
String userType = auth.get("x-zc-user-type").toString(); // No I18N
|
|
145
145
|
clientAuth.put("user_type", userType); // No I18N
|
|
146
146
|
}
|
|
147
|
+
if (auth.containsKey("x-zc-cookie")) {
|
|
148
|
+
String cookie = auth.get("x-zc-cookie").toString();
|
|
149
|
+
clientAuth.put("cookie", cookie);
|
|
150
|
+
}
|
|
147
151
|
catalystAuth.put("client_cred", clientAuth);
|
|
148
152
|
ZCThreadLocal.putValue("CATALYST_AUTH", catalystAuth.toString()); // No I18N
|
|
149
153
|
|
|
154
|
+
// For backward compatibility, to be remove in future.
|
|
150
155
|
if(auth.containsKey("x-zc-cookie")) {
|
|
151
156
|
String cookie = auth.get("x-zc-cookie").toString();
|
|
152
157
|
ZCThreadLocal.putValue("client_cookie", cookie); // No I18N
|
|
153
158
|
}
|
|
159
|
+
// to be removed in future
|
|
154
160
|
}
|
|
155
161
|
|
|
156
162
|
public static void main(String[] args) {
|
|
@@ -145,13 +145,19 @@ public class JavaintegInvoker {
|
|
|
145
145
|
String userType = auth.get("x-zc-user-type").toString(); // No I18N
|
|
146
146
|
clientAuth.put("user_type", userType); // No I18N
|
|
147
147
|
}
|
|
148
|
+
if (auth.containsKey("x-zc-cookie")) {
|
|
149
|
+
String cookie = auth.get("x-zc-cookie").toString();
|
|
150
|
+
clientAuth.put("cookie", cookie);
|
|
151
|
+
}
|
|
148
152
|
catalystAuth.put("client_cred", clientAuth);
|
|
149
153
|
ZCThreadLocal.putValue("CATALYST_AUTH", catalystAuth.toString()); // No I18N
|
|
150
154
|
|
|
155
|
+
// For backward compatibility, to be remove in future.
|
|
151
156
|
if (auth.containsKey("x-zc-cookie")) {
|
|
152
157
|
String cookie = auth.get("x-zc-cookie").toString();
|
|
153
158
|
ZCThreadLocal.putValue("client_cookie", cookie); // No I18N
|
|
154
159
|
}
|
|
160
|
+
// to be removed in future
|
|
155
161
|
}
|
|
156
162
|
|
|
157
163
|
public static void main(String[] args) {
|
|
@@ -35,6 +35,7 @@ exports.default = Object.freeze({
|
|
|
35
35
|
folders: 'ZohoCatalyst.folders.ALL',
|
|
36
36
|
file_create: 'ZohoCatalyst.files.CREATE',
|
|
37
37
|
file_read: 'ZohoCatalyst.files.READ',
|
|
38
|
+
file_delete: 'ZohoCatalyst.files.DELETE',
|
|
38
39
|
functions: 'ZohoCatalyst.functions.ALL',
|
|
39
40
|
functions_execution: 'ZohoCatalyst.functions.EXECUTE',
|
|
40
41
|
event_listeners: 'ZohoCatalyst.eventlistners.ALL',
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|