zcatalyst-cli 1.18.0-beta.0 → 1.18.0-beta.10
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 +8 -8
- package/docs/commands/ds/import.toml +5 -5
- package/docs/commands/event/generate/job.toml +7 -0
- package/docs/commands/zest/generate/index.toml +4 -0
- package/docs/endpoints/lib/job-scheduling.toml +3 -0
- package/docs/internal/command.toml +5 -0
- package/docs/serve/server/lib/appsail/index.toml +22 -1
- package/lib/appsail-utils.js +4 -10
- package/lib/authentication/index.js +1 -0
- package/lib/authentication/login.js +8 -4
- package/lib/bin/catalyst.js +1 -1
- package/lib/code-deck.js +7 -7
- package/lib/command_needs/rc.js +8 -8
- package/lib/commands/appsail/add.js +3 -2
- package/lib/commands/client/setup.js +2 -1
- package/lib/commands/codelib/install.js +6 -2
- 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/event/generate/job.js +82 -0
- package/lib/commands/functions/add.js +2 -1
- package/lib/commands/functions/delete.js +2 -4
- package/lib/commands/functions/setup.js +2 -1
- package/lib/commands/functions/shell.js +1 -0
- package/lib/commands/iac/export.js +5 -1
- package/lib/commands/iac/import.js +4 -1
- package/lib/commands/index.js +4 -1
- package/lib/commands/init.js +10 -7
- package/lib/commands/login.js +1 -0
- package/lib/commands/logout.js +1 -0
- package/lib/commands/pull.js +1 -0
- package/lib/commands/serve.js +1 -1
- package/lib/commands/whoami.js +1 -0
- package/lib/commands/zest/generate/index.js +304 -0
- package/lib/deploy/features/appsail/index.js +42 -25
- package/lib/deploy/features/appsail/utils.js +4 -5
- package/lib/endpoints/index.js +24 -3
- package/lib/endpoints/lib/appsail.js +7 -1
- package/lib/endpoints/lib/ds-bulk.js +1 -0
- package/lib/endpoints/lib/job-scheduling.js +61 -0
- package/lib/endpoints/lib/stratus.js +63 -0
- package/lib/endpoints/lib/tunnel.js +18 -0
- package/lib/endpoints/lib/zest.js +124 -0
- package/lib/event_generate/stratus.js +52 -0
- package/lib/express_middlewares/logger.js +2 -4
- package/lib/fn-utils/lib/common.js +8 -4
- package/lib/fn-utils/lib/java.js +1 -1
- package/lib/fn-utils/lib/python.js +2 -2
- package/lib/fn-watcher.js +1 -1
- package/lib/iac/status/deploy.js +1 -5
- package/lib/init/dependencies/python/ensure-python.js +6 -8
- package/lib/init/features/appsail/index.js +38 -27
- package/lib/init/features/client/index.js +2 -1
- package/lib/init/features/functions/index.js +4 -0
- package/lib/init/features/functions/languages/python.js +21 -5
- package/lib/init/features/project.js +6 -15
- package/lib/internal/api.js +26 -7
- package/lib/internal/command.js +31 -7
- package/lib/migration/index.js +4 -2
- package/lib/optional-import.js +3 -2
- package/lib/prompt/index.js +5 -2
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/prompt/types/search-box.js +281 -0
- package/lib/prompt/types/tree.js +3 -3
- package/lib/serve/features/appsail.js +3 -4
- package/lib/serve/index.js +1 -2
- package/lib/serve/server/index.js +52 -23
- package/lib/serve/server/lib/appsail/index.js +89 -39
- package/lib/serve/server/lib/appsail/start.js +9 -1
- package/lib/serve/server/lib/java/aio_server/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/aio_server/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
- package/lib/serve/server/lib/java/aio_server/lib/catalyst-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/index.js +2 -2
- package/lib/serve/server/lib/master/appsail.js +53 -0
- package/lib/serve/server/lib/master/functions.js +34 -0
- package/lib/serve/server/lib/master/index.js +155 -0
- package/lib/{express_middlewares/unknownReqProxy.js → serve/server/lib/master/unknown-req-proxy.js} +9 -9
- package/lib/serve/server/lib/master/utils.js +142 -0
- package/lib/serve/server/lib/master/web-client.js +39 -0
- package/lib/serve/server/lib/node/index.js +3 -3
- package/lib/serve/server/lib/node/server/package-lock.json +12 -0
- package/lib/serve/server/lib/python/index.js +3 -3
- package/lib/shell/dependencies/http-functions.js +1 -1
- package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
- package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +2 -1
- package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/node.mjs +1 -0
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +15 -0
- package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/integ/node.mjs +13 -0
- package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +268 -0
- package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/job/java/lib/org.json.jar +0 -0
- package/lib/shell/dependencies/invoker/job/node.mjs +93 -0
- package/lib/shell/dependencies/local-function.js +122 -13
- package/lib/shell/dependencies/tunnel-server.js +52 -23
- package/lib/shell/index.js +22 -22
- package/lib/shell/prepare/languages/index.js +4 -4
- package/lib/shell/prepare/languages/java.js +1 -2
- package/lib/shell/prepare/languages/python.js +10 -16
- package/lib/throbber/index.js +6 -1
- package/lib/userConfig.js +7 -1
- package/lib/util_modules/config/index.js +1 -1
- package/lib/util_modules/config/lib/{appSail.js → appsail.js} +64 -10
- package/lib/util_modules/config/lib/client.js +6 -8
- package/lib/util_modules/config/lib/functions.js +6 -8
- package/lib/util_modules/constants/lib/dc-type.js +8 -0
- package/lib/util_modules/constants/lib/default.js +9 -9
- 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/fn-type.js +2 -1
- package/lib/util_modules/constants/lib/needed-scopes.js +53 -44
- package/lib/util_modules/constants/lib/placeholders.js +7 -0
- package/lib/util_modules/constants/lib/ref-mapping.js +2 -1
- package/lib/util_modules/constants/lib/remote-mapping.js +2 -1
- package/lib/util_modules/constants/lib/scopes.js +17 -2
- package/lib/util_modules/constants/lib/template.js +9 -4
- package/lib/util_modules/constants/lib/urls.js +16 -0
- package/lib/util_modules/fs/lib/async.js +14 -4
- package/lib/util_modules/fs/lib/sync.js +12 -1
- package/lib/util_modules/server.js +2 -4
- package/lib/winston.js +17 -11
- package/package.json +4 -2
- package/templates/event/job.json +30 -0
- package/templates/init/client/react/react_js/template/src/index.js +3 -3
- package/templates/init/client/react/react_ts/template/src/index.tsx +3 -3
- package/templates/init/client/react/react_ts/template.json +3 -3
- package/templates/init/functions/java/job/.classpath +6 -0
- package/templates/init/functions/java/job/.project +17 -0
- package/templates/init/functions/java/job/catalyst-config.json +11 -0
- package/templates/init/functions/java/job/sample.java +34 -0
- package/templates/init/functions/node/aio/package.json +1 -1
- package/templates/init/functions/node/aio/sample.js +7 -0
- package/templates/init/functions/node/bio/package.json +1 -1
- package/templates/init/functions/node/bio/sample.js +5 -0
- package/templates/init/functions/node/bio/types/basicio.d.ts +57 -0
- package/templates/init/functions/node/cron/package.json +1 -1
- package/templates/init/functions/node/cron/sample.js +5 -0
- package/templates/init/functions/node/cron/types/cron.d.ts +64 -0
- package/templates/init/functions/node/event/package.json +1 -1
- package/templates/init/functions/node/event/sample.js +11 -8
- package/templates/init/functions/node/event/types/event.d.ts +82 -0
- package/templates/init/functions/node/integ/cliq/package.json +1 -1
- package/templates/init/functions/node/integ/convokraft/package.json +1 -1
- package/templates/init/functions/node/{stream → job}/catalyst-config.json +3 -2
- package/templates/init/functions/node/{stream → job}/package.json +1 -1
- package/templates/init/functions/node/job/sample.js +27 -0
- package/templates/init/functions/node/job/types/job.d.ts +62 -0
- package/templates/init/functions/python/job/catalyst-config.json +11 -0
- package/templates/init/functions/python/job/requirements.txt +1 -0
- package/templates/init/functions/python/job/sample.py +22 -0
- package/templates/init.txt +14 -0
- package/lib/serve/server/lib/master.js +0 -326
- package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/templates/init/functions/node/stream/sample.js +0 -15
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.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.tunnelAPI = exports.commonAPI = exports.jobScheduling = exports.codeDeck = exports.gitHubAPI = exports.stratusAPI = exports.zestAPI = 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* () {
|
|
@@ -41,10 +41,10 @@ function orgAPI({ auth = true } = {}) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
exports.orgAPI = orgAPI;
|
|
44
|
-
function projectAPI({ auth = true, org = (0, project_1.getEnvId)() } = {}) {
|
|
44
|
+
function projectAPI({ auth = true, org = (0, project_1.getEnvId)(), printError = true } = {}) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
const project = (yield Promise.resolve().then(() => __importStar(require('./lib/project')))).default;
|
|
47
|
-
return new project({ authNeeded: auth }, org);
|
|
47
|
+
return new project({ authNeeded: auth, printError }, org);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
exports.projectAPI = projectAPI;
|
|
@@ -156,6 +156,20 @@ function appSailAPI({ auth = true, projectId = (0, project_1.getProjectId)(), en
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
exports.appSailAPI = appSailAPI;
|
|
159
|
+
function zestAPI({ auth = true, projectId = (0, project_1.getProjectId)(), env = (0, project_1.getEnvName)() } = {}) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const zest = (yield Promise.resolve().then(() => __importStar(require('./lib/zest.js')))).default;
|
|
162
|
+
return new zest(projectId, { authNeeded: auth, env, isExternal: true });
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
exports.zestAPI = zestAPI;
|
|
166
|
+
function stratusAPI({ auth = true, projectId = (0, project_1.getProjectId)(), env = (0, project_1.getEnvName)() } = {}) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const stratus = (yield Promise.resolve().then(() => __importStar(require('./lib/stratus')))).default;
|
|
169
|
+
return new stratus(projectId, { authNeeded: auth, env });
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
exports.stratusAPI = stratusAPI;
|
|
159
173
|
function gitHubAPI() {
|
|
160
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
175
|
const gitHub = (yield Promise.resolve().then(() => __importStar(require('./lib/git-hub')))).default;
|
|
@@ -170,6 +184,13 @@ function codeDeck() {
|
|
|
170
184
|
});
|
|
171
185
|
}
|
|
172
186
|
exports.codeDeck = codeDeck;
|
|
187
|
+
function jobScheduling({ auth = true, projectId = (0, project_1.getProjectId)() } = {}) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
const jobScheduling = (yield Promise.resolve().then(() => __importStar(require('./lib/job-scheduling')))).default;
|
|
190
|
+
return new jobScheduling(projectId, { authNeeded: auth });
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
exports.jobScheduling = jobScheduling;
|
|
173
194
|
function commonAPI() {
|
|
174
195
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
196
|
const common = (yield Promise.resolve().then(() => __importStar(require('./lib/common')))).default;
|
|
@@ -21,7 +21,7 @@ class AppSail {
|
|
|
21
21
|
this.opts = opts;
|
|
22
22
|
this.projectId = projectId;
|
|
23
23
|
}
|
|
24
|
-
deploy(sourceFsStream, { stack, name, contentLength, command, memory, platform, envVariables = {} }) {
|
|
24
|
+
deploy(sourceFsStream, { stack, name, contentLength, command, memory, platform, envVariables = {}, catalystAuth, loginRedirect }) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
const formData = {
|
|
27
27
|
stack,
|
|
@@ -43,6 +43,12 @@ class AppSail {
|
|
|
43
43
|
variables: envVariables
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
+
if (typeof catalystAuth === 'boolean') {
|
|
47
|
+
configuration.catalyst_auth = catalystAuth;
|
|
48
|
+
if (typeof loginRedirect === 'string') {
|
|
49
|
+
configuration.login_redirect = loginRedirect;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
46
52
|
if (Object.keys(configuration).length > 0) {
|
|
47
53
|
formData.configuration = JSON.stringify(configuration);
|
|
48
54
|
}
|
|
@@ -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,61 @@
|
|
|
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 ansi_colors_1 = require("ansi-colors");
|
|
16
|
+
const error_1 = __importDefault(require("../../error"));
|
|
17
|
+
const api_1 = __importDefault(require("../../internal/api"));
|
|
18
|
+
const logger_1 = require("../../util_modules/logger");
|
|
19
|
+
class JobScheduling {
|
|
20
|
+
constructor(projectId, opts) {
|
|
21
|
+
this.opts = opts;
|
|
22
|
+
this.projectId = projectId;
|
|
23
|
+
}
|
|
24
|
+
getJobpoolDetails(id) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const res = yield new api_1.default(this.opts).get(`/baas/v1/project/${this.projectId}/job_scheduling/jobpool${id ? '/' + id : ''}`, {
|
|
27
|
+
resolveOnError: true
|
|
28
|
+
});
|
|
29
|
+
if (res.status === 200) {
|
|
30
|
+
if (res.body && res.body.data) {
|
|
31
|
+
return res.body.data;
|
|
32
|
+
}
|
|
33
|
+
(0, logger_1.debug)(`get jobpool details response from server for (${id}): ${res.body}`);
|
|
34
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
35
|
+
exit: 2
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (res.status === 404 && id) {
|
|
39
|
+
const allJobpools = yield this.getJobpoolDetails();
|
|
40
|
+
throw new error_1.default(`The provided jobpool identifier (${id}) is invalid`, {
|
|
41
|
+
exit: 1,
|
|
42
|
+
context: res.body,
|
|
43
|
+
status: res.status,
|
|
44
|
+
errorId: 'JOB-SCHEDULING-1',
|
|
45
|
+
arg: [
|
|
46
|
+
(0, ansi_colors_1.bold)(id),
|
|
47
|
+
(0, ansi_colors_1.bold)(allJobpools
|
|
48
|
+
.map((pool) => `${(0, ansi_colors_1.green)('*')} ${pool.name} [${pool.id}]`)
|
|
49
|
+
.join('\n'))
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
throw new error_1.default('Error when feting details of the jobpool: ' + id, {
|
|
54
|
+
exit: 2,
|
|
55
|
+
context: res.body,
|
|
56
|
+
status: res.status
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = JobScheduling;
|
|
@@ -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;
|
|
@@ -62,5 +62,23 @@ class TunnelAPI {
|
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
+
tunnelCallback(status, details, data) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const res = yield new api_1.default(this.opts).post(`/baas/v1/project/${this.projectId}/tunneling/callback`, {
|
|
68
|
+
body: {
|
|
69
|
+
status,
|
|
70
|
+
content: Object.assign({}, details),
|
|
71
|
+
data
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (res.status >= 200 && res.status <= 299) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
(0, logger_1.debug)(`tunnel callback response from server ::: status=${res.status} ::: body=${res.body}`);
|
|
78
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
79
|
+
exit: 2
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
65
83
|
}
|
|
66
84
|
exports.default = TunnelAPI;
|
|
@@ -0,0 +1,124 @@
|
|
|
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 js_1 = require("../../util_modules/js");
|
|
18
|
+
const logger_1 = require("../../util_modules/logger");
|
|
19
|
+
const project_1 = require("../../util_modules/project");
|
|
20
|
+
class Zest {
|
|
21
|
+
constructor(projectId, opts) {
|
|
22
|
+
this.opts = Object.assign(Object.assign({}, opts), { headers: {
|
|
23
|
+
'CATALYST-ORG': (0, project_1.getEnvId)()
|
|
24
|
+
} });
|
|
25
|
+
this.projectId = projectId;
|
|
26
|
+
}
|
|
27
|
+
getSpecifications(query) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
try {
|
|
30
|
+
const res = yield new api_1.default(this.opts).get(`/zest/v1/project/${this.projectId}/specifications`, {
|
|
31
|
+
qs: query,
|
|
32
|
+
log: {
|
|
33
|
+
awaitingSpinner: 'Getting Zest Specifications'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (res.body || res.status === 204) {
|
|
37
|
+
return res.body;
|
|
38
|
+
}
|
|
39
|
+
(0, logger_1.debug)('get specifications response from server : ' + res.body);
|
|
40
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
41
|
+
exit: 2
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
if (err.status === 429) {
|
|
46
|
+
const responseData = err.context;
|
|
47
|
+
const retryAfter = responseData.response.headers['Retry-After'];
|
|
48
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () { return yield this.getSpecifications(query); }), (retryAfter ? parseInt(retryAfter, 10) : 1) * 1000);
|
|
49
|
+
}
|
|
50
|
+
throw err;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
generateFunction(resources, specEnv, name) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const res = yield new api_1.default(this.opts).post(`/zest/v1/project/${this.projectId}/specifications/actions/generate_function`, {
|
|
57
|
+
body: {
|
|
58
|
+
name,
|
|
59
|
+
stack: specEnv,
|
|
60
|
+
resources: resources
|
|
61
|
+
},
|
|
62
|
+
log: {
|
|
63
|
+
awaitingSpinner: `Scheduling Function Generation ${name}`
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
if (res.body && res.body.details && res.body.code === 'SCHEDULED') {
|
|
67
|
+
return res.body.details;
|
|
68
|
+
}
|
|
69
|
+
(0, logger_1.debug)('generate function response from server : ' + res.body);
|
|
70
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
71
|
+
exit: 2
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
generateAppsail(requestJson) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const res = yield new api_1.default(this.opts).post(`/zest/v1/project/${this.projectId}/specifications/actions/generate_appsail`, {
|
|
78
|
+
body: requestJson,
|
|
79
|
+
log: {
|
|
80
|
+
awaitingSpinner: `Scheduling Appsail Generation${requestJson.name}`
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (res.body && res.body.details && res.body.code === 'SCHEDULED') {
|
|
84
|
+
return res.body.details;
|
|
85
|
+
}
|
|
86
|
+
(0, logger_1.debug)('generate appsail response from server : ' + res.body);
|
|
87
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
88
|
+
exit: 2
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
getScheduledJob(job_id) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const res = yield new api_1.default(this.opts).get(`/zest/v1/scheduled_jobs/${job_id}`);
|
|
95
|
+
if (res.body) {
|
|
96
|
+
return res.body;
|
|
97
|
+
}
|
|
98
|
+
(0, logger_1.debug)('get scheduled job response from server : ' + res.body);
|
|
99
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
100
|
+
exit: 2
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
getFile(file_id, source, name) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const res = yield new api_1.default(Object.assign(Object.assign({}, this.opts), { json: false })).get(`/zest/v1/files/${file_id}`, {
|
|
107
|
+
encoding: null,
|
|
108
|
+
log: {
|
|
109
|
+
progress: {
|
|
110
|
+
title: `${js_1.JS.capitalize(source)} (${name})`
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
if (res.body) {
|
|
115
|
+
return res.body;
|
|
116
|
+
}
|
|
117
|
+
(0, logger_1.debug)('get file response from server : ' + res);
|
|
118
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
119
|
+
exit: 2
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.default = Zest;
|
|
@@ -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
|
+
}
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ansi_colors_1 = require("ansi-colors");
|
|
4
4
|
exports.default = (appSailDetails) => (req, _RES, next) => {
|
|
5
|
-
var _a
|
|
5
|
+
var _a;
|
|
6
6
|
console.log('[' +
|
|
7
7
|
new Date().getTime() +
|
|
8
8
|
'] ' +
|
|
9
|
-
(appSailDetails
|
|
10
|
-
? (0, ansi_colors_1.cyan)(` Appsail[${(_b = (_a = appSailDetails === null || appSailDetails === void 0 ? void 0 : appSailDetails.target) === null || _a === void 0 ? void 0 : _a.appSail) === null || _b === void 0 ? void 0 : _b.name}] `)
|
|
11
|
-
: '') +
|
|
9
|
+
(appSailDetails ? (0, ansi_colors_1.cyan)(` Appsail[${(_a = appSailDetails === null || appSailDetails === void 0 ? void 0 : appSailDetails.target) === null || _a === void 0 ? void 0 : _a.name}] `) : '') +
|
|
12
10
|
' "' +
|
|
13
11
|
(0, ansi_colors_1.cyan)(req.method) +
|
|
14
12
|
'" ' +
|
|
@@ -32,7 +32,6 @@ const js_1 = require("../../util_modules/js");
|
|
|
32
32
|
const logger_1 = require("../../util_modules/logger");
|
|
33
33
|
const option_1 = require("../../util_modules/option");
|
|
34
34
|
const project_1 = require("../../util_modules/project");
|
|
35
|
-
const fs_2 = require("fs");
|
|
36
35
|
const os_1 = require("os");
|
|
37
36
|
const pip_install_1 = require("../../init/dependencies/python/pip-install");
|
|
38
37
|
function validate() {
|
|
@@ -318,7 +317,7 @@ function pack(target) {
|
|
|
318
317
|
const tmpDir = (0, path_1.join)((0, os_1.tmpdir)(), '.catalyst', 'python', target.name + Date.now().toString());
|
|
319
318
|
yield fs_1.ASYNC.ensureDir(tmpDir);
|
|
320
319
|
yield fs_1.ASYNC.emptyDir(tmpDir);
|
|
321
|
-
yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, target.stack.replace('python_', ''),
|
|
320
|
+
yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, target.stack.replace('python_', ''), (0, os_1.platform)() === 'linux');
|
|
322
321
|
const files = yield fs_1.ASYNC.walk(tmpDir);
|
|
323
322
|
files.forEach((file) => {
|
|
324
323
|
zip.add(file.path.replace(tmpDir + path_1.sep, ''), file.stats.isSymbolicLink()
|
|
@@ -342,7 +341,12 @@ function pack(target) {
|
|
|
342
341
|
}
|
|
343
342
|
exports.pack = pack;
|
|
344
343
|
function generateUrlForTarget(target) {
|
|
345
|
-
const
|
|
344
|
+
const domainPrefix = (0, project_1.getDomainPrefix)(false);
|
|
345
|
+
if (!domainPrefix) {
|
|
346
|
+
(0, logger_1.warning)('Failed to retrieve the domain name, so the function URL generation was skipped.');
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const urlDefault = 'https://' + domainPrefix + '.' + constants_1.ORIGIN.app.replace('https://', '');
|
|
346
350
|
switch (target.type) {
|
|
347
351
|
case constants_1.FN_TYPE.basic:
|
|
348
352
|
case constants_1.FN_TYPE.browserLogic:
|
|
@@ -578,7 +582,7 @@ function copyModDirPerm(src, dest, perm, { replace = true } = {}) {
|
|
|
578
582
|
return res();
|
|
579
583
|
}
|
|
580
584
|
const destFile = (0, path_1.join)(dest, (0, path_1.basename)(content.path));
|
|
581
|
-
yield fs_1.ASYNC.copyFile(content.path, destFile, replace
|
|
585
|
+
yield fs_1.ASYNC.copyFile(content.path, destFile, replace).catch((err) => {
|
|
582
586
|
if (!replace && err.code === 'EEXIST') {
|
|
583
587
|
return;
|
|
584
588
|
}
|
package/lib/fn-utils/lib/java.js
CHANGED
|
@@ -287,7 +287,7 @@ function compileJavaFiles(file, spawnCommand, targetVersion, targetSource, outpu
|
|
|
287
287
|
'*' + module.exports.classPathSep + '.',
|
|
288
288
|
'-g',
|
|
289
289
|
'-Xprefer:source',
|
|
290
|
-
'-Xlint',
|
|
290
|
+
userConfig_1.default.get('javac.disable_warnings') === 'true' ? '-Xlint:none' : '-Xlint',
|
|
291
291
|
file.replace(targetSource, outputFolder)
|
|
292
292
|
], {
|
|
293
293
|
cwd: outputFolder,
|
|
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.removeRequirements = exports.validate = void 0;
|
|
39
39
|
const ansi_colors_1 = require("ansi-colors");
|
|
40
|
-
const os_1 = require("os");
|
|
40
|
+
const os_1 = __importStar(require("os"));
|
|
41
41
|
const path_1 = __importStar(require("path"));
|
|
42
42
|
const error_1 = __importDefault(require("../../error"));
|
|
43
43
|
const ensure_python_1 = require("../../init/dependencies/python/ensure-python");
|
|
@@ -111,7 +111,7 @@ function removeRequirements(reqFile, target) {
|
|
|
111
111
|
const tmpDir = (0, path_1.join)((0, os_1.tmpdir)(), '.catalyst', 'python', Date.now().toString());
|
|
112
112
|
yield fs_1.ASYNC.ensureDir(tmpDir);
|
|
113
113
|
yield fs_1.ASYNC.emptyDir(tmpDir);
|
|
114
|
-
yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, (_a = target.stack) === null || _a === void 0 ? void 0 : _a.replace('python_', ''),
|
|
114
|
+
yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, (_a = target.stack) === null || _a === void 0 ? void 0 : _a.replace('python_', ''), os_1.default.platform() === 'linux');
|
|
115
115
|
const files = yield fs_1.ASYNC.walk(tmpDir, { depth: 1, includeDirPaths: true });
|
|
116
116
|
yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
117
117
|
yield fs_1.ASYNC.deleteFile((0, path_1.join)(target.source, path_1.default.basename(file.path)));
|
package/lib/fn-watcher.js
CHANGED
|
@@ -35,7 +35,7 @@ exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
35
35
|
target.valid = true;
|
|
36
36
|
target.compilationError = undefined;
|
|
37
37
|
target.compilationWarning = undefined;
|
|
38
|
-
yield (0, languages_1.prepareFunctions)([target]
|
|
38
|
+
yield (0, languages_1.prepareFunctions)([target]);
|
|
39
39
|
if (currentLatestEvent.at === latestEvent.at) {
|
|
40
40
|
latestEvent = undefined;
|
|
41
41
|
}
|
package/lib/iac/status/deploy.js
CHANGED
|
@@ -19,7 +19,6 @@ const error_1 = __importDefault(require("../../error"));
|
|
|
19
19
|
const throbber_1 = __importDefault(require("../../throbber"));
|
|
20
20
|
const logger_1 = require("../../util_modules/logger");
|
|
21
21
|
const util_1 = require("./util");
|
|
22
|
-
const env_1 = require("../../util_modules/env");
|
|
23
22
|
const ansi_colors_1 = require("ansi-colors");
|
|
24
23
|
const code_deck_1 = require("../../code-deck");
|
|
25
24
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -76,10 +75,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
76
75
|
timerAPI.on('error', (e) => {
|
|
77
76
|
(0, logger_1.debug)('Error encountered : ', e);
|
|
78
77
|
});
|
|
79
|
-
timerAPI.on('end', (
|
|
80
|
-
if (data === true && !(0, env_1.isPrimaryShell)() && process.send) {
|
|
81
|
-
process.send('success');
|
|
82
|
-
}
|
|
78
|
+
timerAPI.on('end', () => {
|
|
83
79
|
throbber.stopAll();
|
|
84
80
|
});
|
|
85
81
|
process.env.PARENT_COMMAND === 'codedeck' &&
|
|
@@ -99,14 +99,12 @@ function validateCommand(version, spawnCommand, skipHelp) {
|
|
|
99
99
|
const data = Buffer.concat(dataBuf).toString();
|
|
100
100
|
return resolve(data);
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
102
|
+
reject(new error_1.default(`unable to locate python${version} with the given binary path`, {
|
|
103
|
+
exit: 1,
|
|
104
|
+
errorId: 'PY-1',
|
|
105
|
+
arg: [version, (0, ansi_colors_1.bold)(spawnCommand)],
|
|
106
|
+
skipHelp
|
|
107
|
+
}));
|
|
110
108
|
});
|
|
111
109
|
child.on('error', (err) => {
|
|
112
110
|
reject(new error_1.default(`unable to locate python${version} with the given binary path`, {
|