zcatalyst-cli 1.18.0-beta.3 → 1.18.0-beta.5
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/commands/ds/import.toml +5 -5
- package/lib/commands/ds/import.js +37 -21
- package/lib/commands/event/generate/index.js +16 -3
- package/lib/commands/event/generate/integ.js +2 -1
- package/lib/commands/index.js +2 -1
- package/lib/endpoints/index.js +15 -1
- package/lib/endpoints/lib/credentials.js +59 -0
- package/lib/endpoints/lib/ds-bulk.js +1 -0
- package/lib/endpoints/lib/stratus.js +63 -0
- package/lib/event_generate/stratus.js +52 -0
- package/lib/express_middlewares/authenticator.js +11 -1
- package/lib/init/features/client/index.js +2 -1
- package/lib/internal/command.js +2 -1
- package/lib/migration/index.js +4 -2
- package/lib/optional-import.js +3 -2
- package/lib/prompt/types/tree.js +3 -3
- package/lib/serve/server/lib/appsail/index.js +1 -1
- package/lib/serve/server/lib/java/index.js +1 -1
- package/lib/serve/server/lib/master/appsail.js +3 -3
- package/lib/serve/server/lib/master/utils.js +21 -15
- package/lib/serve/server/lib/node/index.js +1 -1
- package/lib/serve/server/lib/node/server/package-lock.json +12 -0
- package/lib/serve/server/lib/python/index.js +1 -1
- package/lib/shell/dependencies/http-functions.js +1 -1
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +1 -0
- package/lib/shell/dependencies/local-function.js +3 -3
- package/lib/util_modules/constants/lib/event-action.js +1 -0
- package/lib/util_modules/constants/lib/event-source.js +1 -0
- package/lib/util_modules/constants/lib/scopes.js +8 -2
- package/lib/util_modules/constants/lib/urls.js +8 -0
- package/package.json +3 -1
|
@@ -6,15 +6,15 @@ link = 'https://www.zoho.com/catalyst/help/cli-import-export.html#Import'
|
|
|
6
6
|
[IMP-2]
|
|
7
7
|
context = '''File needed for import! A CSV file is mandatory for executing this command.'''
|
|
8
8
|
aid = '''Please provide the path of the CSV file present in the local machine with the command, or
|
|
9
|
-
provide the
|
|
9
|
+
provide the object_details of the file that is already uploaded to the Stratus in the config json.'''
|
|
10
10
|
link = 'https://www.zoho.com/catalyst/help/cli-import-export.html#CSV'
|
|
11
11
|
|
|
12
12
|
[IMP-3]
|
|
13
|
-
context = '''No
|
|
14
|
-
aid = '''Please create atleast one
|
|
13
|
+
context = '''No Buckets present in the Stratus! You must have atleast one bucket in the Stratus to upload the CSV file.'''
|
|
14
|
+
aid = '''Please create atleast one bucket in the Catalyst Stratus to proceed.'''
|
|
15
15
|
link = 'https://www.zoho.com/catalyst/help/file-store.html#Creating'
|
|
16
16
|
|
|
17
17
|
[IMP-4]
|
|
18
|
-
context = '''The
|
|
19
|
-
aid = '''Please specify the name of a
|
|
18
|
+
context = '''The bucket ${arg[0]} specified in the ${arg[1]} config file does not exists in the Catalyst Stratus.'''
|
|
19
|
+
aid = '''Please specify the name of a bucket that's already present in Catalyst Stratus. Alternatively, you can try uploading the ${arg[2]} file to a bucket in the Catalyst Stratus and specify it's ${arg[3]} as ${arg[4]} in the ${arg[1]} config file.'''
|
|
20
20
|
link = 'https://catalyst.zoho.com/help/cli-import-export.html#Import_File_Format'
|
|
@@ -45,6 +45,7 @@ exports.default = new command_1.default('ds:import [file]')
|
|
|
45
45
|
.needs('config', { optional: true })
|
|
46
46
|
.needs('rc', { optional: true })
|
|
47
47
|
.action((uploadFile) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
var _a, _b, _c;
|
|
48
49
|
const env = (0, option_1.getOptionValue)('production', false) ? 'Production' : 'Development';
|
|
49
50
|
const configPath = (0, option_1.getOptionValue)('config', false);
|
|
50
51
|
const importConfig = configPath ? yield getWriteConfigFromPath(configPath) : {};
|
|
@@ -52,44 +53,59 @@ exports.default = new command_1.default('ds:import [file]')
|
|
|
52
53
|
if (!tableId) {
|
|
53
54
|
throw new error_1.default('Table identifier missing', { exit: 0, errorId: 'IMP-1' });
|
|
54
55
|
}
|
|
55
|
-
if (!importConfig.file_id) {
|
|
56
|
+
if (!importConfig.file_id && !((_a = importConfig.object_details) === null || _a === void 0 ? void 0 : _a.object_key)) {
|
|
56
57
|
if (!uploadFile) {
|
|
57
58
|
throw new error_1.default('No CSV file provided', { exit: 0, errorId: 'IMP-2' });
|
|
58
59
|
}
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
const choices =
|
|
63
|
-
value:
|
|
60
|
+
const bucketAPI = yield (0, endpoints_1.stratusAPI)({ env });
|
|
61
|
+
const allBuckets = (yield bucketAPI.getAllBuckets());
|
|
62
|
+
if (allBuckets.length > 0) {
|
|
63
|
+
const choices = allBuckets.map((bucketDetail) => prompt_1.default.choice(bucketDetail.bucket_name, {
|
|
64
|
+
value: bucketDetail
|
|
64
65
|
}));
|
|
65
|
-
const
|
|
66
|
+
const bucketAns = yield prompt_1.default.ask(prompt_1.default.question('bucket', 'Select a bucket to which you want to upload the object to : ', {
|
|
66
67
|
type: 'list',
|
|
67
68
|
choices,
|
|
68
|
-
when: !importConfig.
|
|
69
|
+
when: !((_b = importConfig.object_details) === null || _b === void 0 ? void 0 : _b.bucket_name)
|
|
69
70
|
}));
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
const bucket = bucketAns.bucket;
|
|
72
|
+
const bucketName = bucket.bucket_name === undefined
|
|
73
|
+
? allBuckets.find((bucketDetails) => {
|
|
74
|
+
var _a;
|
|
75
|
+
return bucketDetails.bucket_name ===
|
|
76
|
+
((_a = importConfig.object_details) === null || _a === void 0 ? void 0 : _a.bucket_name);
|
|
77
|
+
})
|
|
78
|
+
: bucket.bucket_name;
|
|
79
|
+
if (!bucketName) {
|
|
80
|
+
throw new error_1.default('Bucket not present', {
|
|
77
81
|
exit: 1,
|
|
78
82
|
errorId: 'IMP-4',
|
|
79
83
|
arg: [
|
|
80
|
-
ansi_colors_1.bold.red(importConfig.
|
|
84
|
+
ansi_colors_1.bold.red(((_c = importConfig.object_details) === null || _c === void 0 ? void 0 : _c.bucket_name) || ''),
|
|
81
85
|
(0, ansi_colors_1.italic)(configPath || ''),
|
|
82
86
|
(0, ansi_colors_1.bold)(uploadFile),
|
|
83
|
-
(0, ansi_colors_1.bold)('
|
|
84
|
-
(0, ansi_colors_1.italic)('
|
|
87
|
+
(0, ansi_colors_1.bold)('Details(bucket_name and object_key)'),
|
|
88
|
+
(0, ansi_colors_1.italic)('object_details')
|
|
85
89
|
]
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
try {
|
|
93
|
+
yield bucketAPI.uploadObject(bucketName, uploadFile, fs_1.SYNC.getReadStream((0, path_1.resolve)(uploadFile)));
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
throw new error_1.default('Error while uploading the object to the stratus. Use --verbose for error details', {
|
|
97
|
+
exit: 1,
|
|
98
|
+
original: err
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const objDetail = {
|
|
102
|
+
bucket_name: bucketName,
|
|
103
|
+
object_key: uploadFile
|
|
104
|
+
};
|
|
105
|
+
importConfig.object_details = objDetail;
|
|
90
106
|
}
|
|
91
107
|
else {
|
|
92
|
-
throw new error_1.default('
|
|
108
|
+
throw new error_1.default('bucket needed', { exit: 0, errorId: 'IMP-3' });
|
|
93
109
|
}
|
|
94
110
|
}
|
|
95
111
|
const bulkAPI = yield (0, endpoints_1.bulkDSAPI)({ env });
|
|
@@ -54,6 +54,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
|
|
|
54
54
|
.needs('auth')
|
|
55
55
|
.action(function generate(source, action) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a;
|
|
57
58
|
const unknownArgs = (0, option_1.getUnknownOpts)([]);
|
|
58
59
|
if (unknownArgs.length % 2 !== 0) {
|
|
59
60
|
throw new error_1.default('Unknown options are not provided as key value pairs', {
|
|
@@ -148,10 +149,22 @@ exports.default = new command_1.default('event:generate <source> <action>')
|
|
|
148
149
|
break;
|
|
149
150
|
case 'action':
|
|
150
151
|
const eventRefArr = constants_1.EVENT_REF[remoteSourceName];
|
|
151
|
-
const remoteRefAction = action
|
|
152
|
+
const remoteRefAction = action
|
|
153
|
+
.split('_')
|
|
154
|
+
.map((act) => act.charAt(0).toUpperCase() + act.slice(1))
|
|
155
|
+
.join(' ');
|
|
152
156
|
(0, logger_1.debug)(`action provided is : ${remoteRefAction}`);
|
|
153
157
|
const indexOfAction = eventRefArr.indexOf(remoteRefAction);
|
|
154
158
|
if (indexOfAction < 0) {
|
|
159
|
+
const availableActions = eventRefArr
|
|
160
|
+
.map((act) => {
|
|
161
|
+
act = act
|
|
162
|
+
.split(' ')
|
|
163
|
+
.map((act) => act.charAt(0).toUpperCase() + act.slice(1))
|
|
164
|
+
.join('_');
|
|
165
|
+
return '* ' + act;
|
|
166
|
+
})
|
|
167
|
+
.join('\n');
|
|
155
168
|
throw new error_1.default('Action incompatible with the source ' + eventRefArr, {
|
|
156
169
|
exit: 1,
|
|
157
170
|
errorId: 'IDX-6',
|
|
@@ -159,7 +172,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
|
|
|
159
172
|
(0, ansi_colors_1.bold)(action),
|
|
160
173
|
ansi_colors_1.bold.red('X'),
|
|
161
174
|
(0, ansi_colors_1.bold)(source),
|
|
162
|
-
(0, ansi_colors_1.bold)(
|
|
175
|
+
(0, ansi_colors_1.bold)(availableActions)
|
|
163
176
|
]
|
|
164
177
|
});
|
|
165
178
|
}
|
|
@@ -175,7 +188,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
|
|
|
175
188
|
break;
|
|
176
189
|
}
|
|
177
190
|
});
|
|
178
|
-
const sourceModule = (yield Promise.resolve().then(() => __importStar(require(
|
|
191
|
+
const sourceModule = (yield (_a = '../../../event_generate/' + source, Promise.resolve().then(() => __importStar(require(_a))))).default;
|
|
179
192
|
eventJsonContent = yield sourceModule(eventJsonContent, optionMap, action);
|
|
180
193
|
const jsonContent = JSON.parse(eventJsonContent);
|
|
181
194
|
Object.keys(jsonContent).forEach((key) => {
|
|
@@ -46,6 +46,7 @@ exports.default = new command_1.default('event:generate:integ <service>')
|
|
|
46
46
|
.needs('rc')
|
|
47
47
|
.needs('auth')
|
|
48
48
|
.action((service) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
var _a;
|
|
49
50
|
const availableServices = Object.keys(constants_1.INTEG.service_map);
|
|
50
51
|
if (!availableServices.includes(service)) {
|
|
51
52
|
throw new error_1.default('Unknown service requested', {
|
|
@@ -56,7 +57,7 @@ exports.default = new command_1.default('event:generate:integ <service>')
|
|
|
56
57
|
}
|
|
57
58
|
const inputs = (0, option_1.getOptionValue)('inputs', '');
|
|
58
59
|
const serviceValue = constants_1.INTEG.service_map[service];
|
|
59
|
-
const serviceModule = (yield Promise.resolve().then(() => __importStar(require(
|
|
60
|
+
const serviceModule = (yield (_a = `../../../event_generate/integration/${serviceValue}`, Promise.resolve().then(() => __importStar(require(_a)))))
|
|
60
61
|
.default;
|
|
61
62
|
const payload = yield serviceModule(inputs);
|
|
62
63
|
process.stdout.write(payload + '\n');
|
package/lib/commands/index.js
CHANGED
|
@@ -36,7 +36,8 @@ exports.default = (client) => {
|
|
|
36
36
|
function loadCommand(name) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
return new Promise((resolve, reject) => setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
|
|
39
|
+
var _a;
|
|
40
|
+
const cmd = (yield (_a = './' + name.split(':').join('/'), Promise.resolve().then(() => __importStar(require(_a))))).default;
|
|
40
41
|
try {
|
|
41
42
|
cmd.register(client);
|
|
42
43
|
resolve();
|
package/lib/endpoints/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.tunnelAPI = exports.commonAPI = exports.jobScheduling = exports.codeDeck = exports.gitHubAPI = exports.appSailAPI = exports.logAPI = exports.eventBusAPI = exports.functionsAPI = exports.applogicAPI = exports.bulkDSAPI = exports.apigAPI = exports.clientAPI = exports.datastoreAPI = exports.zcqlAPI = exports.queueAPI = exports.filestoreAPI = exports.cacheAPI = exports.sdkAPI = exports.envAPI = exports.projectAPI = exports.orgAPI = void 0;
|
|
35
|
+
exports.credentialsAPI = exports.tunnelAPI = exports.commonAPI = exports.jobScheduling = exports.codeDeck = exports.gitHubAPI = exports.stratusAPI = exports.appSailAPI = exports.logAPI = exports.eventBusAPI = exports.functionsAPI = exports.applogicAPI = exports.bulkDSAPI = exports.apigAPI = exports.clientAPI = exports.datastoreAPI = exports.zcqlAPI = exports.queueAPI = exports.filestoreAPI = exports.cacheAPI = exports.sdkAPI = exports.envAPI = exports.projectAPI = exports.orgAPI = void 0;
|
|
36
36
|
const project_1 = require("../util_modules/project");
|
|
37
37
|
function orgAPI({ auth = true } = {}) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -156,6 +156,13 @@ function appSailAPI({ auth = true, projectId = (0, project_1.getProjectId)(), en
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
exports.appSailAPI = appSailAPI;
|
|
159
|
+
function stratusAPI({ auth = true, projectId = (0, project_1.getProjectId)(), env = (0, project_1.getEnvName)() } = {}) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const stratus = (yield Promise.resolve().then(() => __importStar(require('./lib/stratus')))).default;
|
|
162
|
+
return new stratus(projectId, { authNeeded: auth, env });
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
exports.stratusAPI = stratusAPI;
|
|
159
166
|
function gitHubAPI() {
|
|
160
167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
168
|
const gitHub = (yield Promise.resolve().then(() => __importStar(require('./lib/git-hub')))).default;
|
|
@@ -191,3 +198,10 @@ function tunnelAPI({ auth = true, projectId = (0, project_1.getProjectId)() } =
|
|
|
191
198
|
});
|
|
192
199
|
}
|
|
193
200
|
exports.tunnelAPI = tunnelAPI;
|
|
201
|
+
function credentialsAPI({ auth = false, projectId = (0, project_1.getProjectId)() } = {}) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
const credentials = (yield Promise.resolve().then(() => __importStar(require('./lib/credentials')))).default;
|
|
204
|
+
return new credentials(projectId, { authNeeded: auth });
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
exports.credentialsAPI = credentialsAPI;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const api_1 = __importDefault(require("../../internal/api"));
|
|
16
|
+
const logger_1 = require("../../util_modules/logger");
|
|
17
|
+
const error_1 = __importDefault(require("../../error"));
|
|
18
|
+
const project_1 = require("../../util_modules/project");
|
|
19
|
+
const constants_1 = require("../../util_modules/constants");
|
|
20
|
+
const js_1 = require("../../util_modules/js");
|
|
21
|
+
class Credentials {
|
|
22
|
+
constructor(projectId, opts) {
|
|
23
|
+
this.opts = opts;
|
|
24
|
+
this.projectId = projectId;
|
|
25
|
+
this.projectDomain = `https://${(0, project_1.getDomainPrefix)()}.${constants_1.ORIGIN.app.replace('https://', '')}`;
|
|
26
|
+
}
|
|
27
|
+
generateJWTToken(cookie) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const res = yield new api_1.default(Object.assign(Object.assign({}, this.opts), { headers: { Cookie: cookie }, origin: this.projectDomain })).get(`/baas/v1/project/${this.projectId}/authentication/custom-token`);
|
|
30
|
+
if (res.body && res.body.data) {
|
|
31
|
+
return res.body.data;
|
|
32
|
+
}
|
|
33
|
+
(0, logger_1.debug)('Download response from server : ' + res.body);
|
|
34
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
35
|
+
exit: 2
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
convertJwtToAuthToken(reqOpts) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const res = yield new api_1.default(Object.assign(Object.assign({}, this.opts), { origin: constants_1.ORIGIN.iamPortal, headers: { Origin: this.projectDomain } })).post(`/clientoauth/v2/${(0, project_1.getDomainKey)()}/remote/auth`, {
|
|
42
|
+
qs: {
|
|
43
|
+
response_type: 'remote_token',
|
|
44
|
+
jwt_token: reqOpts.jwt_token,
|
|
45
|
+
client_id: reqOpts.client_id,
|
|
46
|
+
scope: js_1.JS.values(reqOpts.scopes).join(' ')
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (res.body) {
|
|
50
|
+
return res.body;
|
|
51
|
+
}
|
|
52
|
+
(0, logger_1.debug)('Download response from server : ' + res.body);
|
|
53
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
54
|
+
exit: 2
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.default = Credentials;
|
|
@@ -50,6 +50,7 @@ class BulkDS {
|
|
|
50
50
|
body: {
|
|
51
51
|
table_identifier: table,
|
|
52
52
|
operation: config === null || config === void 0 ? void 0 : config.operation,
|
|
53
|
+
object_details: config === null || config === void 0 ? void 0 : config.object_details,
|
|
53
54
|
file_id: config === null || config === void 0 ? void 0 : config.file_id,
|
|
54
55
|
callback: config === null || config === void 0 ? void 0 : config.callback,
|
|
55
56
|
find_by: config === null || config === void 0 ? void 0 : config.find_by,
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const error_1 = __importDefault(require("../../error"));
|
|
16
|
+
const api_1 = __importDefault(require("../../internal/api"));
|
|
17
|
+
const logger_1 = require("../../util_modules/logger");
|
|
18
|
+
const mime_types_1 = __importDefault(require("mime-types"));
|
|
19
|
+
const constants_1 = require("../../util_modules/constants");
|
|
20
|
+
class Stratus {
|
|
21
|
+
constructor(projectId, opts) {
|
|
22
|
+
this.opts = opts;
|
|
23
|
+
this.projectId = projectId;
|
|
24
|
+
}
|
|
25
|
+
getAllBuckets() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const res = yield new api_1.default(this.opts).get(`/baas/v1/project/${this.projectId}/bucket`);
|
|
28
|
+
if (res.body && res.body.data) {
|
|
29
|
+
return res.body.data;
|
|
30
|
+
}
|
|
31
|
+
(0, logger_1.debug)('get all buckets response from server : ' + res.body);
|
|
32
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
33
|
+
exit: 2
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
uploadObject(bucketName, objectName, fileStream) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const extension = objectName.substring(objectName.lastIndexOf('.') + 1).toLowerCase();
|
|
40
|
+
const contentType = mime_types_1.default.lookup(extension + '');
|
|
41
|
+
const res = yield new api_1.default(Object.assign({ origin: `https://${bucketName}` +
|
|
42
|
+
(this.opts.env === 'Development'
|
|
43
|
+
? '-' + this.opts.env.toLowerCase()
|
|
44
|
+
: '') +
|
|
45
|
+
constants_1.ORIGIN.stratusSuffix, isExternal: true }, this.opts)).put(`/${objectName}`, {
|
|
46
|
+
body: fileStream,
|
|
47
|
+
headers: {
|
|
48
|
+
compress: 'false',
|
|
49
|
+
'Content-Type': contentType || 'application/octet-stream'
|
|
50
|
+
},
|
|
51
|
+
json: false
|
|
52
|
+
});
|
|
53
|
+
if (res.status === 200) {
|
|
54
|
+
return res.status;
|
|
55
|
+
}
|
|
56
|
+
(0, logger_1.debug)('upload object response from server : ' + res);
|
|
57
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
58
|
+
exit: 2
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.default = Stratus;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const moment_1 = __importDefault(require("moment"));
|
|
7
|
+
const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
8
|
+
const constants_1 = require("../util_modules/constants");
|
|
9
|
+
const js_1 = require("../util_modules/js");
|
|
10
|
+
const project_1 = require("../util_modules/project");
|
|
11
|
+
function generateStratusEventJson(eventJson) {
|
|
12
|
+
const userDetails = {
|
|
13
|
+
email_id: runtime_store_1.default.get('user.Email'),
|
|
14
|
+
user_id: js_1.JS.randomNumber(15),
|
|
15
|
+
is_confirmed: getRandomBoolean(),
|
|
16
|
+
last_name: js_1.JS.randomString(5),
|
|
17
|
+
first_name: js_1.JS.randomString(10),
|
|
18
|
+
zuid: js_1.JS.randomNumber(10)
|
|
19
|
+
};
|
|
20
|
+
const time = (0, moment_1.default)().format('MMM DD, YYYY hh:mm A');
|
|
21
|
+
const data = {
|
|
22
|
+
bucket_details: {
|
|
23
|
+
bucket_name: 'sample-bucket',
|
|
24
|
+
project_details: {
|
|
25
|
+
id: (0, project_1.getProjectId)(),
|
|
26
|
+
project_name: (0, project_1.getProjectName)(),
|
|
27
|
+
project_type: 'Live'
|
|
28
|
+
},
|
|
29
|
+
created_by: userDetails,
|
|
30
|
+
created_time: time,
|
|
31
|
+
modified_by: userDetails,
|
|
32
|
+
modified_time: time,
|
|
33
|
+
bucket_meta: {
|
|
34
|
+
versioning: getRandomBoolean(),
|
|
35
|
+
caching: {
|
|
36
|
+
status: getRandomBoolean() ? 'Enabled' : 'Disabled'
|
|
37
|
+
},
|
|
38
|
+
encryption: getRandomBoolean(),
|
|
39
|
+
audit_consent: getRandomBoolean()
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
object_key: 'path1/path2/myfile.png'
|
|
43
|
+
};
|
|
44
|
+
eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.rule_id, 'g'), 'NULL');
|
|
45
|
+
eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.source_id, 'g'), 'NULL');
|
|
46
|
+
eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.data, 'g'), JSON.stringify(data));
|
|
47
|
+
return eventJson;
|
|
48
|
+
}
|
|
49
|
+
exports.default = generateStratusEventJson;
|
|
50
|
+
function getRandomBoolean() {
|
|
51
|
+
return js_1.JS.random(0, 1) === 1;
|
|
52
|
+
}
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const project_1 = __importDefault(require("../endpoints/lib/project"));
|
|
16
16
|
const credential_1 = __importDefault(require("../internal/credential"));
|
|
17
|
+
const endpoints_1 = require("../endpoints");
|
|
17
18
|
exports.default = (req, _RES, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
19
|
var _a;
|
|
19
20
|
const projectId = req.headers['x-zc-projectid'];
|
|
@@ -34,7 +35,16 @@ exports.default = (req, _RES, next) => __awaiter(void 0, void 0, void 0, functio
|
|
|
34
35
|
}, [false, false, false]);
|
|
35
36
|
if (hasCSRF && hasADT && hasBDT) {
|
|
36
37
|
req.headers['x-zc-user-type'] = 'project-user';
|
|
37
|
-
|
|
38
|
+
try {
|
|
39
|
+
const jwtResponse = yield (yield (0, endpoints_1.credentialsAPI)()).generateJWTToken(cookie);
|
|
40
|
+
const tokenRes = yield (yield (0, endpoints_1.credentialsAPI)()).convertJwtToAuthToken(jwtResponse);
|
|
41
|
+
req.headers['x-zc-user-cred-type'] = 'token';
|
|
42
|
+
req.headers['x-zc-user-cred-token'] = tokenRes
|
|
43
|
+
.access_token;
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
req.headers['x-zc-cookie'] = cookie;
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
else if (typeof authorization !== 'undefined') {
|
|
40
50
|
const currentUser = yield new project_1.default({
|
|
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
const index_js_1 = __importDefault(require("../../../prompt/index.js"));
|
|
39
39
|
const index_js_2 = require("../../../util_modules/constants/index.js");
|
|
40
40
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
var _a;
|
|
41
42
|
const clientInitAnswer = yield index_js_1.default.ask(index_js_1.default.question('clientFlavour', 'Choose the type of client to initialise: ', {
|
|
42
43
|
type: 'list',
|
|
43
44
|
choices: index_js_2.PLUGIN.client.map((plugin) => {
|
|
@@ -47,5 +48,5 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
47
48
|
});
|
|
48
49
|
})
|
|
49
50
|
}));
|
|
50
|
-
return (yield Promise.resolve().then(() => __importStar(require(
|
|
51
|
+
return (yield (_a = './initializers/' + clientInitAnswer.clientFlavour, Promise.resolve().then(() => __importStar(require(_a))))).default();
|
|
51
52
|
});
|
package/lib/internal/command.js
CHANGED
|
@@ -229,7 +229,8 @@ class Command {
|
|
|
229
229
|
(0, logger_1.debug)(e);
|
|
230
230
|
}
|
|
231
231
|
yield Promise.all(js_1.JS.map(this.beforeRunners, (before) => __awaiter(this, void 0, void 0, function* () {
|
|
232
|
-
|
|
232
|
+
var _a;
|
|
233
|
+
const beforeModule = (yield (_a = '../command_needs/' + before.fn, Promise.resolve().then(() => __importStar(require(_a))))).default;
|
|
233
234
|
return beforeModule.call(this, before.args);
|
|
234
235
|
})));
|
|
235
236
|
return this.cmdAction.call(this, ...args);
|
package/lib/migration/index.js
CHANGED
|
@@ -44,6 +44,7 @@ const rc_1 = __importDefault(require("../internal/rc"));
|
|
|
44
44
|
const fs_1 = require("../util_modules/fs");
|
|
45
45
|
const logger_1 = require("../util_modules/logger");
|
|
46
46
|
const runMigration = (rc, migFiles, idx = 0) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
var _a;
|
|
47
48
|
if (migFiles.length <= idx) {
|
|
48
49
|
return Promise.resolve();
|
|
49
50
|
}
|
|
@@ -54,7 +55,7 @@ const runMigration = (rc, migFiles, idx = 0) => __awaiter(void 0, void 0, void 0
|
|
|
54
55
|
return runMigration(rc, migFiles, ++idx);
|
|
55
56
|
}
|
|
56
57
|
try {
|
|
57
|
-
const migModule = yield Promise.resolve().then(() => __importStar(require(
|
|
58
|
+
const migModule = yield (_a = migFile, Promise.resolve().then(() => __importStar(require(_a))));
|
|
58
59
|
if (migModule.isRequire()) {
|
|
59
60
|
(0, logger_1.debug)('migration started for v' + currentMigFileVersion);
|
|
60
61
|
migModule.migrate();
|
|
@@ -83,6 +84,7 @@ const runMigration = (rc, migFiles, idx = 0) => __awaiter(void 0, void 0, void 0
|
|
|
83
84
|
return runMigration(rc, migFiles, ++idx);
|
|
84
85
|
});
|
|
85
86
|
const runGlobalMigration = (migFiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
+
var _b;
|
|
86
88
|
if (migFiles.length === 0) {
|
|
87
89
|
return;
|
|
88
90
|
}
|
|
@@ -96,7 +98,7 @@ const runGlobalMigration = (migFiles) => __awaiter(void 0, void 0, void 0, funct
|
|
|
96
98
|
return runGlobalMigration(migFiles);
|
|
97
99
|
}
|
|
98
100
|
try {
|
|
99
|
-
const migModule = yield Promise.resolve().then(() => __importStar(require(
|
|
101
|
+
const migModule = yield (_b = migFile, Promise.resolve().then(() => __importStar(require(_b))));
|
|
100
102
|
if (migModule.isRequire()) {
|
|
101
103
|
(0, logger_1.debug)('migration started for v' + currentMigFileVersion);
|
|
102
104
|
migModule.migrate();
|
package/lib/optional-import.js
CHANGED
|
@@ -42,6 +42,7 @@ const async_js_1 = require("./util_modules/fs/lib/async.js");
|
|
|
42
42
|
const error_js_1 = __importDefault(require("./error.js"));
|
|
43
43
|
const ansi_colors_1 = require("ansi-colors");
|
|
44
44
|
exports.default = (name, source) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
var _a, _b;
|
|
45
46
|
if (name === (0, path_1.basename)(name)) {
|
|
46
47
|
const projectModulePath = (0, project_js_1.resolveProjectPath)((0, path_1.join)(source, 'node_modules', name));
|
|
47
48
|
const projectModulePathExists = yield (0, async_js_1.dirExists)(projectModulePath);
|
|
@@ -53,7 +54,7 @@ exports.default = (name, source) => __awaiter(void 0, void 0, void 0, function*
|
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
app_module_path_1.default.addPath(projectModulePath);
|
|
56
|
-
return Promise.resolve().then(() => __importStar(require(
|
|
57
|
+
return _a = projectModulePath, Promise.resolve().then(() => __importStar(require(_a)));
|
|
57
58
|
}
|
|
58
59
|
const projectModulePath = (0, project_js_1.resolveProjectPath)(name);
|
|
59
60
|
const projectModulePathExists = yield (0, async_js_1.dirExists)(projectModulePath);
|
|
@@ -65,5 +66,5 @@ exports.default = (name, source) => __awaiter(void 0, void 0, void 0, function*
|
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
app_module_path_1.default.addPath(projectModulePath);
|
|
68
|
-
return Promise.resolve().then(() => __importStar(require(
|
|
69
|
+
return _b = projectModulePath, Promise.resolve().then(() => __importStar(require(_b)));
|
|
69
70
|
});
|
package/lib/prompt/types/tree.js
CHANGED
|
@@ -26,6 +26,9 @@ var ETreeState;
|
|
|
26
26
|
ETreeState[ETreeState["EXPANDED"] = 3] = "EXPANDED";
|
|
27
27
|
})(ETreeState || (ETreeState = {}));
|
|
28
28
|
class TreeNode {
|
|
29
|
+
get indent() {
|
|
30
|
+
return this.level * 2;
|
|
31
|
+
}
|
|
29
32
|
constructor(root) {
|
|
30
33
|
_TreeNode_instances.add(this);
|
|
31
34
|
this.open = false;
|
|
@@ -36,9 +39,6 @@ class TreeNode {
|
|
|
36
39
|
this.level = 1;
|
|
37
40
|
this.root = root;
|
|
38
41
|
}
|
|
39
|
-
get indent() {
|
|
40
|
-
return this.level * 2;
|
|
41
|
-
}
|
|
42
42
|
addNode(node) {
|
|
43
43
|
if (node instanceof TreeNode) {
|
|
44
44
|
this.leaves.push(node);
|
|
@@ -42,7 +42,7 @@ const startAppSail = (port, opts) => {
|
|
|
42
42
|
const child = (0, shell_1.spawn)('node', _opts, {
|
|
43
43
|
cwd: opts.target,
|
|
44
44
|
stdio: 'pipe',
|
|
45
|
-
env: Object.assign({ X_ZOHO_CATALYST_LISTEN_PORT: port + '', X_ZOHO_CATALYST_RUNTIME_MEMORY: opts.memory + '', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZC_RESOURCE_NAME: opts.name + '', CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, (opts.env || {}))
|
|
45
|
+
env: Object.assign({ X_ZOHO_CATALYST_LISTEN_PORT: port + '', X_ZOHO_CATALYST_RUNTIME_MEMORY: opts.memory + '', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZC_RESOURCE_NAME: opts.name + '', CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, (opts.env || {}))
|
|
46
46
|
}).RAW();
|
|
47
47
|
return new Promise((_res, _rej) => {
|
|
48
48
|
child.on('spawn', () => _res(child));
|
|
@@ -54,6 +54,6 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
|
|
|
54
54
|
return (0, shell_1.spawn)(spawnCommand, opts, {
|
|
55
55
|
cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)),
|
|
56
56
|
stdio: 'pipe',
|
|
57
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_CODE_LOCATION: targetDir + path_1.sep, X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_f = details.target) === null || _f === void 0 ? void 0 : _f.id, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
|
|
57
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_CODE_LOCATION: targetDir + path_1.sep, X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_f = details.target) === null || _f === void 0 ? void 0 : _f.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
|
|
58
58
|
}).RAW();
|
|
59
59
|
});
|
|
@@ -23,12 +23,12 @@ function addAppSailRoutes(app, details, proxy, unknownProxy) {
|
|
|
23
23
|
req.url = req.originalUrl;
|
|
24
24
|
unknownProxy(req, res);
|
|
25
25
|
}));
|
|
26
|
-
app.use('/
|
|
26
|
+
app.use('/__catalyst', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
req.url = req.originalUrl;
|
|
28
28
|
unknownProxy(req, res);
|
|
29
|
-
});
|
|
29
|
+
}));
|
|
30
30
|
((_b = (_a = details.target) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.catalyst_auth) === true &&
|
|
31
|
-
app.use(['/
|
|
31
|
+
app.use(['/accounts', '/oauthorize'], (req, res) => {
|
|
32
32
|
if (req.url.includes('/appsail/logout_redirect')) {
|
|
33
33
|
res.redirect(typeof req.query.service_url === 'string' ? req.query.service_url : '/');
|
|
34
34
|
return;
|
|
@@ -20,10 +20,21 @@ const error_1 = __importDefault(require("../../../../error"));
|
|
|
20
20
|
const project_1 = require("../../../../util_modules/project");
|
|
21
21
|
const http_proxy_1 = require("http-proxy");
|
|
22
22
|
const logger_1 = require("../../../../util_modules/logger");
|
|
23
|
+
const iam_cookies = [
|
|
24
|
+
'ZD_CSRF_TOKEN',
|
|
25
|
+
'_iamadt_client',
|
|
26
|
+
'_iambdt_client',
|
|
27
|
+
'_zcsr_tmp',
|
|
28
|
+
'iamcsr',
|
|
29
|
+
'zalb',
|
|
30
|
+
'stk',
|
|
31
|
+
'JSESSIONID'
|
|
32
|
+
];
|
|
33
|
+
const isIamCookie = (cookieStr) => iam_cookies.some((val) => cookieStr.startsWith(val));
|
|
23
34
|
const removeSecure = (str) => str.replace(/;\s?Secure/i, '').replace(/;\s?SameSite=None/i, '');
|
|
24
35
|
exports.removeSecure = removeSecure;
|
|
25
36
|
const redirectByAuth = (req, res, redirectUrl) => {
|
|
26
|
-
if (req.headers['
|
|
37
|
+
if (req.headers['cookie'] !== undefined) {
|
|
27
38
|
res.writeHead(302, { Location: redirectUrl });
|
|
28
39
|
res.end();
|
|
29
40
|
}
|
|
@@ -68,17 +79,16 @@ const createProxyServer = (port) => {
|
|
|
68
79
|
};
|
|
69
80
|
exports.createProxyServer = createProxyServer;
|
|
70
81
|
const proxyResponseHandler = ({ systemRoutes, signInRedirect = '/app/local-redirect' }) => (proxyRes, req, res) => {
|
|
82
|
+
var _a, _b;
|
|
71
83
|
if (!req.url) {
|
|
72
84
|
return;
|
|
73
85
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
else if (req.url.startsWith('/baas') || req.url.startsWith('/__catalyst')) {
|
|
86
|
+
proxyRes.headers['set-cookie'] = (_a = proxyRes.headers['set-cookie']) === null || _a === void 0 ? void 0 : _a.map((cookie) => {
|
|
87
|
+
if (isIamCookie(cookie))
|
|
88
|
+
return (0, exports.removeSecure)(cookie);
|
|
89
|
+
return cookie;
|
|
90
|
+
});
|
|
91
|
+
if (req.url.startsWith('/baas') || req.url.startsWith('/__catalyst')) {
|
|
82
92
|
if (req.url.includes('/signin-redirect')) {
|
|
83
93
|
if (systemRoutes === undefined) {
|
|
84
94
|
(0, exports.redirectByAuth)(req, res, signInRedirect);
|
|
@@ -107,12 +117,8 @@ const proxyResponseHandler = ({ systemRoutes, signInRedirect = '/app/local-redir
|
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
|
-
else if (req.url.startsWith('/accounts')) {
|
|
111
|
-
|
|
112
|
-
if (req.url.includes('/signin')) {
|
|
113
|
-
set.push('IAM_TEST_COOKIE=IAM_TEST_COOKIE; Domain=localhost; Path=/');
|
|
114
|
-
}
|
|
115
|
-
proxyRes.headers['set-cookie'] = set.map(exports.removeSecure);
|
|
120
|
+
else if (req.url.startsWith('/accounts') && req.url.includes('/signin')) {
|
|
121
|
+
(_b = proxyRes.headers['set-cookie']) === null || _b === void 0 ? void 0 : _b.push('IAM_TEST_COOKIE=IAM_TEST_COOKIE; Domain=localhost; Path=/');
|
|
116
122
|
}
|
|
117
123
|
};
|
|
118
124
|
exports.proxyResponseHandler = proxyResponseHandler;
|
|
@@ -88,6 +88,6 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
|
|
|
88
88
|
return (0, shell_1.spawn)('node', opts, {
|
|
89
89
|
cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)),
|
|
90
90
|
stdio: 'pipe',
|
|
91
|
-
env: Object.assign({ NODE_PATH: targetSource + path_1.sep + 'node_modules', X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_g = details.target) === null || _g === void 0 ? void 0 : _g.id, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
|
|
91
|
+
env: Object.assign({ NODE_PATH: targetSource + path_1.sep + 'node_modules', X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_g = details.target) === null || _g === void 0 ? void 0 : _g.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
|
|
92
92
|
}).RAW();
|
|
93
93
|
});
|
|
@@ -36,7 +36,7 @@ exports.default = (details) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
36
36
|
const child = (0, shell_1.spawn)(userConfig_1.default.get(`python${stackVersion}.bin`), opts, {
|
|
37
37
|
cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)),
|
|
38
38
|
stdio: 'pipe',
|
|
39
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_a = details.target) === null || _a === void 0 ? void 0 : _a.id, X_ZOHO_CATALYST_CODE_LOCATION: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)), X_ZOHO_CATALYST_SERVER_LISTEN_PORT: details.httpPort.toString(), CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
|
|
39
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_a = details.target) === null || _a === void 0 ? void 0 : _a.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, X_ZOHO_CATALYST_CODE_LOCATION: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)), X_ZOHO_CATALYST_SERVER_LISTEN_PORT: details.httpPort.toString(), CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
|
|
40
40
|
}).RAW();
|
|
41
41
|
child.on('spawn', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
42
|
yield (0, http_functions_1.checkIfRuntimeServerRunning)(details.httpPort.toString());
|
|
@@ -117,7 +117,7 @@ class HttpFunctions {
|
|
|
117
117
|
const slave = (0, shell_1.spawn)(opts.command, opts.options, {
|
|
118
118
|
cwd: opts.pth,
|
|
119
119
|
stdio: 'pipe',
|
|
120
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, CATALYST_PROJECT_TIMEZONE: (0, project_2.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, opts.envVars)
|
|
120
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PROJECT_TIMEZONE: (0, project_2.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, opts.envVars)
|
|
121
121
|
}).RAW();
|
|
122
122
|
(_a = slave.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
|
|
123
123
|
(0, logger_2.info)(Buffer.isBuffer(data) ? data.toString() : data);
|
|
@@ -123,6 +123,7 @@ public class JavaintegInvoker {
|
|
|
123
123
|
catalystConfig.put("project_key", project.get("x-zc-project-key").toString());
|
|
124
124
|
catalystConfig.put("project_domain", project.get("x-zc-project-domain").toString());
|
|
125
125
|
catalystConfig.put("environment", project.get("x-zc-environment").toString());
|
|
126
|
+
|
|
126
127
|
|
|
127
128
|
ZCThreadLocal.putValue("CATALYST_CONFIG", catalystConfig.toString());
|
|
128
129
|
}
|
|
@@ -158,7 +158,7 @@ class LocalFunction {
|
|
|
158
158
|
this.slave = (0, shell_1.spawn)('node', slaveOptions, {
|
|
159
159
|
cwd: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name),
|
|
160
160
|
stdio: 'pipe',
|
|
161
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_h = this.target) === null || _h === void 0 ? void 0 : _h.id, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, this.target.env_var)
|
|
161
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_h = this.target) === null || _h === void 0 ? void 0 : _h.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, this.target.env_var)
|
|
162
162
|
}).RAW();
|
|
163
163
|
}
|
|
164
164
|
else if ((_j = this.target.stack) === null || _j === void 0 ? void 0 : _j.startsWith(runtime_1.default.language.java.value)) {
|
|
@@ -196,7 +196,7 @@ class LocalFunction {
|
|
|
196
196
|
this.slave = (0, shell_1.spawn)(spawnCommand, slaveOptions, {
|
|
197
197
|
cwd: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name),
|
|
198
198
|
stdio: 'pipe',
|
|
199
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_k = this.target) === null || _k === void 0 ? void 0 : _k.id, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, this.target.env_var)
|
|
199
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_k = this.target) === null || _k === void 0 ? void 0 : _k.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, this.target.env_var)
|
|
200
200
|
}).RAW();
|
|
201
201
|
}
|
|
202
202
|
else if ((_l = this.target.stack) === null || _l === void 0 ? void 0 : _l.startsWith(runtime_1.default.language.python.value)) {
|
|
@@ -211,7 +211,7 @@ class LocalFunction {
|
|
|
211
211
|
this.slave = (0, shell_1.spawn)(userConfig_1.default.get(`python${stackVersion}.bin`), slaveOptions, {
|
|
212
212
|
cwd: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name),
|
|
213
213
|
stdio: 'pipe',
|
|
214
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_o = this.target) === null || _o === void 0 ? void 0 : _o.id, X_ZOHO_CATALYST_CODE_LOCATION: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name), X_ZOHO_CATALYST_SERVER_LISTEN_PORT: runTimePort.toString(), X_ZOHO_DATA_URL: `http://localhost:${runTimePort}/data`, X_ZOHO_CALLBACK_URL: `http://localhost:${runTimePort}/callback`, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone), X_ZOHO_ADMIN_CRED_TOKEN: 'dummy', X_ZOHO_PROJECT_SECRET_KEY: 'dummy', X_ZOHO_CATALYST_ORG: (0, project_1.getEnvId)(), X_ZOHO_CATALYST_ENVIRONMENT: 'Local', X_ZOHO_JOBMETA_JOBID: 'dummy', CATALYST_FUNCTION_TYPE: constants_1.REMOTE_REF.functions.type[this.target.type] }, this.target.env_var)
|
|
214
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_o = this.target) === null || _o === void 0 ? void 0 : _o.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, X_ZOHO_CATALYST_CODE_LOCATION: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name), X_ZOHO_CATALYST_SERVER_LISTEN_PORT: runTimePort.toString(), X_ZOHO_DATA_URL: `http://localhost:${runTimePort}/data`, X_ZOHO_CALLBACK_URL: `http://localhost:${runTimePort}/callback`, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone), X_ZOHO_ADMIN_CRED_TOKEN: 'dummy', X_ZOHO_PROJECT_SECRET_KEY: 'dummy', X_ZOHO_CATALYST_ORG: (0, project_1.getEnvId)(), X_ZOHO_CATALYST_ENVIRONMENT: 'Local', X_ZOHO_JOBMETA_JOBID: 'dummy', CATALYST_FUNCTION_TYPE: constants_1.REMOTE_REF.functions.type[this.target.type] }, this.target.env_var)
|
|
215
215
|
}).RAW();
|
|
216
216
|
this.slave.once('spawn', () => __awaiter(this, void 0, void 0, function* () {
|
|
217
217
|
var _r;
|
|
@@ -9,6 +9,7 @@ exports.default = Object.freeze({
|
|
|
9
9
|
[event_source_1.default.cache]: ['Put'],
|
|
10
10
|
[event_source_1.default.user]: ['SignUp', 'Delete'],
|
|
11
11
|
[event_source_1.default.filestore]: ['Upload', 'Download'],
|
|
12
|
+
[event_source_1.default.stratus]: ['Object Upload', 'Object Download', 'Object Update', 'Object Delete'],
|
|
12
13
|
[event_source_1.default.webapp]: ['Success'],
|
|
13
14
|
[event_source_1.default.github]: ['Success', 'Failure'],
|
|
14
15
|
[event_source_1.default.custom]: ['Produce']
|
|
@@ -66,8 +66,14 @@ exports.default = Object.freeze({
|
|
|
66
66
|
tunneling_read: 'ZohoCatalyst.tunneling.READ',
|
|
67
67
|
tunneling_update: 'ZohoCatalyst.tunneling.UPDATE',
|
|
68
68
|
iam_profile: 'AaaServer.profile.READ',
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
object_creation: 'Stratus.fileop.CREATE',
|
|
70
|
+
object_operation: 'Stratus.fileop.ALL',
|
|
71
|
+
stratus_bucket_operation: 'Stratus.bucketop.ALL',
|
|
72
|
+
object_update: 'ZohoCatalyst.buckets.objects.UPDATE',
|
|
73
|
+
object_read: 'ZohoCatalyst.buckets.objects.READ',
|
|
74
|
+
object_delete: 'ZohoCatalyst.buckets.objects.DELETE',
|
|
75
|
+
bucket_read: 'ZohoCatalyst.buckets.READ',
|
|
76
|
+
object_create: 'ZohoCatalyst.buckets.objects.CREATE',
|
|
71
77
|
pipline_read: 'ZohoCatalyst.pipeline.READ',
|
|
72
78
|
pipeline_exec_create: 'ZohoCatalyst.pipeline.execution.CREATE'
|
|
73
79
|
});
|
|
@@ -68,6 +68,13 @@ class URL {
|
|
|
68
68
|
}
|
|
69
69
|
return URL._console.replace('.com', dc.ext);
|
|
70
70
|
}
|
|
71
|
+
static get stratusSuffix() {
|
|
72
|
+
const dc = (0, dc_js_1.getActiveDCType)();
|
|
73
|
+
if (dc === undefined) {
|
|
74
|
+
return URL._stratusSuffix;
|
|
75
|
+
}
|
|
76
|
+
return URL._stratusSuffix.replace('.com', dc.ext);
|
|
77
|
+
}
|
|
71
78
|
}
|
|
72
79
|
exports.default = URL;
|
|
73
80
|
URL._auth = (0, env_js_1.envOverride)('CATALYST_AUTH_URL', 'https://accounts.zoho.com');
|
|
@@ -77,6 +84,7 @@ URL._app = (0, env_js_1.envOverride)('CATALYST_APP_URL', 'https://catalystserver
|
|
|
77
84
|
URL._appSailDomain = (0, env_js_1.envOverride)('CATALYST_APPSAIL_URL', 'https://catalystappsail.com');
|
|
78
85
|
URL._zohoStatic = (0, env_js_1.envOverride)('ZOHO_STATIC', 'https://www.zoho.com/catalyst');
|
|
79
86
|
URL._console = (0, env_js_1.envOverride)('CATALYST_CONSOLE_URL', 'https://console.catalyst.zoho.com');
|
|
87
|
+
URL._stratusSuffix = (0, env_js_1.envOverride)('CATALYST_STRATUS_RESOURCE_SUFFIX', '.zohostratus.com');
|
|
80
88
|
URL.zohoCDN = (0, env_js_1.envOverride)('ZOHO_CDN', 'https://static.zohocdn.com');
|
|
81
89
|
URL.external = Object.freeze({
|
|
82
90
|
gitHubAPI: 'https://api.github.com',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcatalyst-cli",
|
|
3
|
-
"version": "1.18.0-beta.
|
|
3
|
+
"version": "1.18.0-beta.5",
|
|
4
4
|
"description": "Command Line Tool for CATALYST",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -70,6 +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/mime-types": "^2.1.4",
|
|
73
74
|
"@types/minimatch": "^5.1.2",
|
|
74
75
|
"@types/node": "^20.12.7",
|
|
75
76
|
"@types/request": "^2.48.8",
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
"build:watch": "gulp watch",
|
|
95
96
|
"clean": "gulp cleanup",
|
|
96
97
|
"test:unit": "jest --config jest.config.js",
|
|
98
|
+
"lint:nofix": "eslint --ext .ts src/ --color",
|
|
97
99
|
"lint:src": "eslint --ext .ts src/ --fix --color",
|
|
98
100
|
"lint:unit": "eslint --ext .js,.ts test/ --fix --color",
|
|
99
101
|
"lint": "run-p lint:src lint:unit",
|