zcatalyst-cli 1.18.0-beta.1 → 1.18.0-beta.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/command_needs/rc.toml +8 -8
- package/docs/serve/server/lib/appsail/index.toml +22 -1
- package/lib/command_needs/rc.js +7 -7
- package/lib/commands/appsail/add.js +1 -1
- package/lib/commands/client/setup.js +1 -1
- package/lib/commands/codelib/install.js +5 -2
- package/lib/commands/event/generate/index.js +1 -2
- package/lib/commands/event/generate/integ.js +1 -2
- package/lib/commands/functions/add.js +1 -1
- package/lib/commands/functions/setup.js +1 -1
- package/lib/commands/index.js +1 -2
- package/lib/commands/init.js +8 -1
- package/lib/deploy/features/appsail/index.js +25 -10
- package/lib/endpoints/index.js +2 -2
- package/lib/endpoints/lib/tunnel.js +18 -0
- package/lib/init/features/appsail/index.js +34 -27
- package/lib/init/features/client/index.js +1 -2
- package/lib/init/features/project.js +5 -15
- package/lib/internal/api.js +13 -5
- package/lib/internal/command.js +1 -2
- package/lib/migration/index.js +2 -4
- package/lib/optional-import.js +2 -3
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/prompt/types/tree.js +3 -3
- package/lib/serve/features/appsail.js +1 -1
- package/lib/serve/server/index.js +44 -14
- package/lib/serve/server/lib/appsail/index.js +73 -13
- package/lib/serve/server/lib/appsail/start.js +9 -1
- package/lib/serve/server/lib/master/unknown-req-proxy.js +3 -0
- package/lib/serve/server/lib/master/utils.js +6 -6
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +14 -0
- package/lib/shell/dependencies/invoker/integ/node.mjs +13 -0
- package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +15 -1
- package/lib/shell/dependencies/local-function.js +24 -23
- package/lib/shell/dependencies/tunnel-server.js +52 -23
- package/lib/shell/index.js +22 -28
- package/lib/util_modules/config/lib/appsail.js +10 -8
- package/lib/util_modules/fs/lib/async.js +7 -2
- package/package.json +1 -1
- package/templates/init/functions/java/job/sample.java +1 -1
- package/templates/init/functions/node/aio/sample.js +7 -0
- 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/sample.js +5 -0
- package/templates/init/functions/node/cron/types/cron.d.ts +64 -0
- 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/job/sample.js +0 -1
- package/templates/init/functions/node/job/types/job.d.ts +0 -4
- package/templates/init/functions/python/job/sample.py +0 -1
|
@@ -33,6 +33,7 @@ const server_1 = require("../../util_modules/server");
|
|
|
33
33
|
const ansi_colors_1 = require("ansi-colors");
|
|
34
34
|
const util_1 = require("util");
|
|
35
35
|
const project_1 = require("../../util_modules/project");
|
|
36
|
+
const endpoints_1 = require("../../endpoints");
|
|
36
37
|
class TunnelServer {
|
|
37
38
|
constructor(repel) {
|
|
38
39
|
_TunnelServer_contextMap.set(this, {});
|
|
@@ -42,6 +43,29 @@ class TunnelServer {
|
|
|
42
43
|
_TunnelServer_projectId.set(this, (0, project_1.getProjectId)());
|
|
43
44
|
__classPrivateFieldSet(this, _TunnelServer_repel, repel, "f");
|
|
44
45
|
}
|
|
46
|
+
isAsyncFn(fnType) {
|
|
47
|
+
switch (fnType) {
|
|
48
|
+
case 'cron':
|
|
49
|
+
case 'event':
|
|
50
|
+
case 'job': {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
send(req, res, status = 200, data, contentType) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const body = req.body;
|
|
59
|
+
if (this.isAsyncFn(body.function_details.function_type)) {
|
|
60
|
+
const tunnelAPI = yield (0, endpoints_1.tunnelAPI)();
|
|
61
|
+
yield tunnelAPI.tunnelCallback(status, body.default, data);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
contentType && res.contentType(contentType);
|
|
65
|
+
res.status(status);
|
|
66
|
+
res.send(data);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
45
69
|
startServer() {
|
|
46
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
71
|
const tunnelPortOpt = Number.parseInt(runtime_store_1.default.get('context.port.tunnel'));
|
|
@@ -59,23 +83,33 @@ class TunnelServer {
|
|
|
59
83
|
const app = (0, express_1.default)();
|
|
60
84
|
app.use(express_1.default.json());
|
|
61
85
|
app.all('/', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
if (req.method !== 'POST') {
|
|
87
|
+
res.status(200);
|
|
88
|
+
res.send();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const body = req.body;
|
|
92
|
+
if (!body.function_details ||
|
|
93
|
+
!body.function_data ||
|
|
94
|
+
(body.function_details.function_type !== 'integration' && !body.default)) {
|
|
95
|
+
res.status(400);
|
|
96
|
+
res.send();
|
|
97
|
+
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
98
|
+
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('Invalid tunnel request: ' + (0, util_1.inspect)(body));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (this.isAsyncFn(body.function_details.function_type)) {
|
|
102
|
+
res.status(200);
|
|
103
|
+
res.send();
|
|
104
|
+
}
|
|
62
105
|
try {
|
|
63
|
-
const body = req.body;
|
|
64
|
-
if (!body.function_details || !body.function_data) {
|
|
65
|
-
res.status(400);
|
|
66
|
-
res.send();
|
|
67
|
-
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
68
|
-
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('Invalid tunnel request: ' + (0, util_1.inspect)(body));
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
106
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
72
107
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write((0, ansi_colors_1.bold)(`Received tunnel request from ${body.function_details.function_name}(${body.function_details.function_id})`));
|
|
73
108
|
const target = body.function_details.function_id in __classPrivateFieldGet(this, _TunnelServer_contextMap, "f")
|
|
74
109
|
? __classPrivateFieldGet(this, _TunnelServer_contextMap, "f")[body.function_details.function_id]
|
|
75
|
-
: (() => {
|
|
110
|
+
: yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
76
111
|
if (__classPrivateFieldGet(this, _TunnelServer_projectId, "f") !== body.function_details.project_id) {
|
|
77
|
-
|
|
78
|
-
res.send();
|
|
112
|
+
yield this.send(req, res, 403);
|
|
79
113
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
80
114
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('Invalid access: the tunnel is trying to access the functions from a different project');
|
|
81
115
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
@@ -87,15 +121,14 @@ class TunnelServer {
|
|
|
87
121
|
if (namedFn) {
|
|
88
122
|
return namedFn;
|
|
89
123
|
}
|
|
90
|
-
|
|
91
|
-
res.send();
|
|
124
|
+
yield this.send(req, res, 404);
|
|
92
125
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
93
126
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write(`The tunneled function ${(0, ansi_colors_1.bold)(body.function_details.function_name)} is not present in local project directory`);
|
|
94
127
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
95
128
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('[STATUS]');
|
|
96
129
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('NOT_FOUND');
|
|
97
130
|
return;
|
|
98
|
-
}).bind(this)();
|
|
131
|
+
})).bind(this)();
|
|
99
132
|
if (!target) {
|
|
100
133
|
return;
|
|
101
134
|
}
|
|
@@ -103,11 +136,10 @@ class TunnelServer {
|
|
|
103
136
|
? JSON.parse(body.function_data)
|
|
104
137
|
: body.function_data;
|
|
105
138
|
target.call(false)(fnData);
|
|
106
|
-
const errorHandler = (e) => {
|
|
107
|
-
|
|
108
|
-
res.send();
|
|
139
|
+
const errorHandler = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
yield this.send(req, res, 500);
|
|
109
141
|
(0, logger_1.debug)('Target error: ' + e);
|
|
110
|
-
};
|
|
142
|
+
});
|
|
111
143
|
target.once('error', errorHandler);
|
|
112
144
|
const response = yield new Promise((resolve, reject) => {
|
|
113
145
|
target.once('response', (response) => {
|
|
@@ -118,13 +150,10 @@ class TunnelServer {
|
|
|
118
150
|
resolve(response);
|
|
119
151
|
});
|
|
120
152
|
});
|
|
121
|
-
|
|
122
|
-
res.status(response.status || 200);
|
|
123
|
-
res.send(response.responseBody);
|
|
153
|
+
yield this.send(req, res, response.status, response.responseBody, response.ContentType);
|
|
124
154
|
}
|
|
125
155
|
catch (e) {
|
|
126
|
-
|
|
127
|
-
res.send();
|
|
156
|
+
yield this.send(req, res, 500);
|
|
128
157
|
(0, logger_1.debug)(e);
|
|
129
158
|
}
|
|
130
159
|
}));
|
package/lib/shell/index.js
CHANGED
|
@@ -49,35 +49,29 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
49
49
|
const httpServer = new http_functions_1.default({ repl: replServer });
|
|
50
50
|
const tunnelServer = new tunnel_server_1.default(replServer);
|
|
51
51
|
const projectRoot = runtime_store_1.default.get('project.root');
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(0, logger_js_1.warning)(
|
|
65
|
-
target.name +
|
|
66
|
-
'] is not a valid one reason : ' +
|
|
67
|
-
target.failure_reason);
|
|
68
|
-
Array.isArray(target.compilationError) &&
|
|
69
|
-
target.compilationError.forEach((er) => (0, logger_js_1.error)(er));
|
|
70
|
-
Array.isArray(target.compilationWarning) &&
|
|
71
|
-
target.compilationWarning.forEach((warn) => (0, logger_js_1.warning)(warn));
|
|
72
|
-
}
|
|
73
|
-
return target.valid;
|
|
74
|
-
});
|
|
75
|
-
if (targets.length === 0) {
|
|
76
|
-
throw new error_1.default('No functions are ready for serving', {
|
|
77
|
-
exit: 0,
|
|
78
|
-
errorId: 'SHELL-IDX-1'
|
|
79
|
-
});
|
|
52
|
+
yield (0, prepare_1.default)([constants_1.FN_TYPE.basic, constants_1.FN_TYPE.cron, constants_1.FN_TYPE.event, constants_1.FN_TYPE.integration, constants_1.FN_TYPE.job]);
|
|
53
|
+
const targets = runtime_store_1.default
|
|
54
|
+
.get('context.functions.targets', [])
|
|
55
|
+
.filter((target) => {
|
|
56
|
+
if (!target.valid) {
|
|
57
|
+
(0, logger_js_1.warning)('target [' +
|
|
58
|
+
target.name +
|
|
59
|
+
'] is not a valid one reason : ' +
|
|
60
|
+
target.failure_reason);
|
|
61
|
+
Array.isArray(target.compilationError) &&
|
|
62
|
+
target.compilationError.forEach((er) => (0, logger_js_1.error)(er));
|
|
63
|
+
Array.isArray(target.compilationWarning) &&
|
|
64
|
+
target.compilationWarning.forEach((warn) => (0, logger_js_1.warning)(warn));
|
|
80
65
|
}
|
|
66
|
+
return target.valid;
|
|
67
|
+
});
|
|
68
|
+
if (targets.length === 0) {
|
|
69
|
+
throw new error_1.default('No functions are ready for serving', {
|
|
70
|
+
exit: 0,
|
|
71
|
+
errorId: 'SHELL-IDX-1'
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
81
75
|
replServer.start();
|
|
82
76
|
yield tunnelServer.startServer();
|
|
83
77
|
const tunnelUrl = runtime_store_1.default.get('context.fn_shell.enable_tunnel', undefined);
|
|
@@ -26,6 +26,8 @@ function validateConfig(source, configJson) {
|
|
|
26
26
|
reason: 'Config file is empty'
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
const sourcePath = (0, path_1.join)((0, project_1.getProjectRoot)(), source);
|
|
30
|
+
configJson.raw.source_path = sourcePath;
|
|
29
31
|
if (configJson.buildPath || configJson.build_path) {
|
|
30
32
|
const buildPath = configJson.build_path || configJson.buildPath;
|
|
31
33
|
if (!buildPath) {
|
|
@@ -34,14 +36,9 @@ function validateConfig(source, configJson) {
|
|
|
34
36
|
reason: 'Build Path not present'
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
|
-
const absolutePath = (0, path_1.isAbsolute)(buildPath) ? buildPath : (0, path_1.resolve)(
|
|
38
|
-
if (!fs_1.SYNC.pathExists(absolutePath)) {
|
|
39
|
-
return {
|
|
40
|
-
valid: false,
|
|
41
|
-
reason: 'Build Path does not exists'
|
|
42
|
-
};
|
|
43
|
-
}
|
|
39
|
+
const absolutePath = (0, path_1.isAbsolute)(buildPath) ? buildPath : (0, path_1.resolve)(sourcePath, buildPath);
|
|
44
40
|
configJson.build_path = absolutePath;
|
|
41
|
+
configJson.raw.build_path = buildPath;
|
|
45
42
|
}
|
|
46
43
|
if (configJson.catalyst_auth === true) {
|
|
47
44
|
if (configJson.login_redirect === undefined) {
|
|
@@ -78,7 +75,11 @@ function raw(throwError = false) {
|
|
|
78
75
|
}
|
|
79
76
|
return;
|
|
80
77
|
}
|
|
81
|
-
|
|
78
|
+
const appsailConfig = config.get('appsail');
|
|
79
|
+
return appsailConfig === null || appsailConfig === void 0 ? void 0 : appsailConfig.map((_conf) => {
|
|
80
|
+
_conf.source = (0, path_1.isAbsolute)(_conf.source) ? _conf.source : (0, path_1.normalize)(_conf.source);
|
|
81
|
+
return _conf;
|
|
82
|
+
});
|
|
82
83
|
}
|
|
83
84
|
exports.raw = raw;
|
|
84
85
|
function getTargetDetails(name) {
|
|
@@ -123,6 +124,7 @@ function getAllTargetDetails(throwErr = true) {
|
|
|
123
124
|
resArr.push(new Promise((res) => __awaiter(this, void 0, void 0, function* () {
|
|
124
125
|
try {
|
|
125
126
|
const configJson = yield fs_1.ASYNC.readJSONFile(catalystConfigPth);
|
|
127
|
+
configJson && (configJson.raw = {});
|
|
126
128
|
const validity = validateConfig(target.source, configJson);
|
|
127
129
|
return res(Object.assign({ config: configJson, validity }, target));
|
|
128
130
|
}
|
|
@@ -99,8 +99,13 @@ function walk(dir, { filter = {
|
|
|
99
99
|
const isEntryPthDir = entryPathStats.isDirectory() && !entryPathStats.isSymbolicLink();
|
|
100
100
|
let excludeMatch = false;
|
|
101
101
|
if (!(isEntryPthDir && !filter.excludeDir)) {
|
|
102
|
-
|
|
103
|
-
excludeMatch = excludeMatch || (
|
|
102
|
+
if (typeof filter.exclude === 'function') {
|
|
103
|
+
excludeMatch = excludeMatch || (yield filter.exclude(entryPath));
|
|
104
|
+
}
|
|
105
|
+
else if (Array.isArray(filter.exclude)) {
|
|
106
|
+
for (const glob of filter.exclude || []) {
|
|
107
|
+
excludeMatch = excludeMatch || (0, minimatch_1.default)(entryPath, glob);
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
if (excludeMatch) {
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ public class {{_CLASS_}} implements CatalystJobHandler {
|
|
|
23
23
|
}
|
|
24
24
|
LOGGER.log(Level.SEVERE, "Project Details " + request.getProjectDetails().toString());
|
|
25
25
|
ZCCache.getInstance().putCacheValue("JobSample", "Working", 1l);
|
|
26
|
-
LOGGER.log(Level.SEVERE, "Inserted
|
|
26
|
+
LOGGER.log(Level.SEVERE, "Inserted SuccessFully:)");
|
|
27
27
|
} catch (Exception e) {
|
|
28
28
|
LOGGER.log(Level.SEVERE, "Exception in Job Function", e);
|
|
29
29
|
return JOB_STATUS.FAILURE;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a utility file with the type declaration of the BasicIO function parameters
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type of the BasicIO object. Contains the functional APIs of BasicIO
|
|
7
|
+
*/
|
|
8
|
+
export interface BasicIO {
|
|
9
|
+
/**
|
|
10
|
+
* Write to the BasicIO output
|
|
11
|
+
* @param value input string
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
write: (value: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Set the BasicIO status code
|
|
17
|
+
* @param statusCode status code of BasicIO
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
setStatus: (statusCode: number) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Get the input argument values of the BasicIO
|
|
23
|
+
* @param key argument name(key)
|
|
24
|
+
* @returns argument value as string
|
|
25
|
+
*/
|
|
26
|
+
getArgument: (key: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Get all input arguments
|
|
29
|
+
* @returns all arguments as key value pair
|
|
30
|
+
*/
|
|
31
|
+
getAllArguments: () => Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Type of the context object of the function
|
|
36
|
+
*/
|
|
37
|
+
export interface Context {
|
|
38
|
+
/**
|
|
39
|
+
* Contains catalyst auth headers (for internal use)
|
|
40
|
+
*/
|
|
41
|
+
catalystHeaders: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* To indicate the end of a function execution
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
close: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Fetch the remaining execution time of the function
|
|
49
|
+
* @returns remaining execution time in milliseconds
|
|
50
|
+
*/
|
|
51
|
+
getRemainingExecutionTimeMs: () => number;
|
|
52
|
+
/**
|
|
53
|
+
* Fetch the maximum execution time of the function
|
|
54
|
+
* @returns maximum execution time in milliseconds
|
|
55
|
+
*/
|
|
56
|
+
getMaxExecutionTimeMs: () => number;
|
|
57
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a utility file with the type declaration of the Cron function parameters
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type of Cron Details object. Contains the details of the scheduled cron
|
|
7
|
+
*/
|
|
8
|
+
export interface CronDetails {
|
|
9
|
+
/**
|
|
10
|
+
* Get the input param value of the Cron function
|
|
11
|
+
* @returns input param value
|
|
12
|
+
*/
|
|
13
|
+
getCronParam: () => string;
|
|
14
|
+
/**
|
|
15
|
+
* Get all input params of the Cron function
|
|
16
|
+
* @returns all input params as key value pairs
|
|
17
|
+
*/
|
|
18
|
+
getAllCronParam: () => Record<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Get the remaining execution count of the cron job
|
|
21
|
+
* @returns remaining execution count
|
|
22
|
+
*/
|
|
23
|
+
getRemainingExecutionCount: () => number;
|
|
24
|
+
/**
|
|
25
|
+
* Get the details of the cron which executed the function
|
|
26
|
+
* @returns cron details
|
|
27
|
+
*/
|
|
28
|
+
getCronDetails: () => Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Get the current project details
|
|
31
|
+
* @returns project details
|
|
32
|
+
*/
|
|
33
|
+
getProjectDetails: () => Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Type of the Context object of the Cron function
|
|
38
|
+
*/
|
|
39
|
+
export interface Context {
|
|
40
|
+
/**
|
|
41
|
+
* Contains catalyst auth headers (for internal use)
|
|
42
|
+
*/
|
|
43
|
+
catalystHeaders: Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Close the Cron function with success response
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
closeWithSuccess: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Close the Cron function failure response
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
closeWithFailure: () => void;
|
|
54
|
+
/**
|
|
55
|
+
* Get the remaining execution time of the Cron function
|
|
56
|
+
* @returns remaining execution time in milliseconds
|
|
57
|
+
*/
|
|
58
|
+
getRemainingExecutionTimeMs: () => number;
|
|
59
|
+
/**
|
|
60
|
+
* Get the maximum possible execution time of the Cron function
|
|
61
|
+
* @returns maximum possible execution time in milliseconds
|
|
62
|
+
*/
|
|
63
|
+
getMaxExecutionTimeMs: () => number;
|
|
64
|
+
}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {import('./types/event').EventDetails} event
|
|
4
|
+
* @param {import('./types/event').Context} context
|
|
5
|
+
*/
|
|
1
6
|
module.exports = (event, context) => {
|
|
2
7
|
/*
|
|
3
8
|
EVENT FUNCTIONALITIES
|
|
4
9
|
*/
|
|
5
|
-
// const DATA = event.
|
|
6
|
-
// const TIME = event.
|
|
10
|
+
// const DATA = event.getData(); //event data
|
|
11
|
+
// const TIME = event.getTime(); //event occurred time
|
|
7
12
|
|
|
8
|
-
// const
|
|
9
|
-
// const
|
|
10
|
-
// const
|
|
11
|
-
// const SOURCE_ENTITY_ID = SOURCE_DETAILS.entityId; //if type is datastore then entity id is tableid
|
|
13
|
+
// const ACTION = event.getAction(); //(insert | fetch | invoke ...)
|
|
14
|
+
// const SOURCE = event.getSource(); //(datastore | cache | queue ...)
|
|
15
|
+
// const SOURCE_ENTITY_ID = event.getSourceEntityId(); //if type is datastore then entity id is tableid
|
|
12
16
|
|
|
13
|
-
// const SOURCE_BUS_DETAILS =
|
|
17
|
+
// const SOURCE_BUS_DETAILS = event.getBusDetails(); //event bus details
|
|
14
18
|
// const SOURCE_BUS_ID = SOURCE_BUS_DETAILS.id; //event bus id
|
|
15
19
|
|
|
16
20
|
// const PROJECT_DETAILS = event.getProjectDetails(); //event project details
|
|
17
|
-
// const FUNCTION_DETAILS = event.getFunctionDetails(); //event function details
|
|
18
21
|
|
|
19
22
|
console.log('Hello from {{_MAIN_}}');
|
|
20
23
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a utility file with the type declaration of the Event function parameters
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type of Event Details object. Contains the details of the triggered Event
|
|
7
|
+
*/
|
|
8
|
+
export interface EventDetails {
|
|
9
|
+
/**
|
|
10
|
+
* Event data
|
|
11
|
+
*/
|
|
12
|
+
data: Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Time of the event
|
|
15
|
+
*/
|
|
16
|
+
time: number;
|
|
17
|
+
/**
|
|
18
|
+
* Get the project details of the event function
|
|
19
|
+
* @returns project details
|
|
20
|
+
*/
|
|
21
|
+
getProjectDetails: () => Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Functional API to get the data of the event
|
|
24
|
+
* @returns event data
|
|
25
|
+
*/
|
|
26
|
+
getData: () => Record<string, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Functional API to get the time of the event
|
|
29
|
+
* @returns event time
|
|
30
|
+
*/
|
|
31
|
+
getTime: () => number;
|
|
32
|
+
/**
|
|
33
|
+
* Get the action that triggered the event
|
|
34
|
+
* @returns action
|
|
35
|
+
*/
|
|
36
|
+
getAction: () => string;
|
|
37
|
+
/**
|
|
38
|
+
* Get the source of the event
|
|
39
|
+
* @returns event source
|
|
40
|
+
*/
|
|
41
|
+
getSource: () => string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the Id of the entity that triggered the event
|
|
44
|
+
* @returns source entity's Id
|
|
45
|
+
*/
|
|
46
|
+
getSourceEntityId: () => string;
|
|
47
|
+
/**
|
|
48
|
+
* Get the details of the event bus
|
|
49
|
+
* @returns event bus details
|
|
50
|
+
*/
|
|
51
|
+
getEventBusDetails: () => Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Type of the Context object of the Event function
|
|
56
|
+
*/
|
|
57
|
+
export interface Context {
|
|
58
|
+
/**
|
|
59
|
+
* Contains catalyst auth headers (for internal use)
|
|
60
|
+
*/
|
|
61
|
+
catalystHeaders: Record<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* Close the Event function with success response
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
closeWithSuccess: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Close the Event function failure response
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
closeWithFailure: () => void;
|
|
72
|
+
/**
|
|
73
|
+
* Get the remaining execution time of the Event function
|
|
74
|
+
* @returns remaining execution time in milliseconds
|
|
75
|
+
*/
|
|
76
|
+
getRemainingExecutionTimeMs: () => number;
|
|
77
|
+
/**
|
|
78
|
+
* Get the maximum possible execution time of the Event function
|
|
79
|
+
* @returns maximum possible execution time in milliseconds
|
|
80
|
+
*/
|
|
81
|
+
getMaxExecutionTimeMs: () => number;
|
|
82
|
+
}
|
|
@@ -15,7 +15,6 @@ module.exports = (jobRequest, context) => {
|
|
|
15
15
|
const projectDetails = jobRequest.getProjectDetails(); // to get the current project details
|
|
16
16
|
const jobDetails = jobRequest.getJobDetails(); // to get the current job details
|
|
17
17
|
const jobMetaDetails = jobRequest.getJobMetaDetails(); // to get the current job's meta details
|
|
18
|
-
const jobpoolDetails = jobRequest.getJobpoolDetails(); // to get the current function job pool's details
|
|
19
18
|
const getJobCapacityAttributes = jobRequest.getJobCapacityAttributes(); // to get the current jobs capacity
|
|
20
19
|
const allJobParams = jobRequest.getAllJobParams(); // to get all the parameters supplied to the job function
|
|
21
20
|
const jobParam = jobRequest.getJobParam('key'); // to get the value of a particular parameter supplied to the job function
|
|
@@ -18,10 +18,6 @@ export interface JobRequest {
|
|
|
18
18
|
* @returns Meta details of the current job
|
|
19
19
|
*/
|
|
20
20
|
getJobMetaDetails: () => Record<string, unknown>;
|
|
21
|
-
/**
|
|
22
|
-
* @returns Job pool details of the current job
|
|
23
|
-
*/
|
|
24
|
-
getJobpoolDetails: () => Record<string, unknown>;
|
|
25
21
|
/**
|
|
26
22
|
* @returns Capacity attributes of the current job
|
|
27
23
|
*/
|
|
@@ -11,7 +11,6 @@ def handler(job_request, context):
|
|
|
11
11
|
job_details = job_request.get_job_details() # get the details of the current job
|
|
12
12
|
project_details = job_request.get_project_details() # get the details of the current project
|
|
13
13
|
job_meta_details = job_request.get_job_meta_details() # get the job meta of the current job
|
|
14
|
-
job_pool_details = job_request.get_job_pool_details() # get the current functions job pool details
|
|
15
14
|
job_capacity_attributes = job_request.get_job_capacity_attributes() # get the current jobs capacity
|
|
16
15
|
all_job_params = job_request.get_all_job_params() # get all the parameters supplied to the job function
|
|
17
16
|
job_param = job_request.get_job_param('key') # get the value of a particular parameter supplied to the job function
|