zcatalyst-cli 1.18.0-beta.0 → 1.18.0-beta.2
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/event/generate/job.toml +7 -0
- package/docs/endpoints/lib/job-scheduling.toml +3 -0
- package/docs/internal/command.toml +5 -0
- package/lib/appsail-utils.js +4 -10
- package/lib/authentication/index.js +1 -0
- package/lib/bin/catalyst.js +1 -1
- package/lib/command_needs/rc.js +8 -8
- package/lib/commands/appsail/add.js +2 -1
- package/lib/commands/client/setup.js +2 -1
- package/lib/commands/codelib/install.js +5 -2
- package/lib/commands/event/generate/index.js +2 -1
- 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/index.js +3 -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/deploy/features/appsail/index.js +42 -25
- package/lib/deploy/features/appsail/utils.js +4 -5
- package/lib/endpoints/index.js +10 -3
- package/lib/endpoints/lib/appsail.js +7 -1
- package/lib/endpoints/lib/job-scheduling.js +61 -0
- package/lib/express_middlewares/logger.js +2 -4
- package/lib/fn-utils/lib/common.js +2 -3
- 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/init/dependencies/python/ensure-python.js +6 -8
- package/lib/init/features/appsail/index.js +36 -26
- 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 +5 -15
- package/lib/internal/api.js +25 -6
- package/lib/internal/command.js +30 -6
- package/lib/migration/index.js +4 -2
- package/lib/optional-import.js +3 -2
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/prompt/types/tree.js +3 -3
- package/lib/serve/features/appsail.js +2 -3
- package/lib/serve/index.js +1 -2
- package/lib/serve/server/index.js +8 -9
- package/lib/serve/server/lib/appsail/index.js +29 -35
- 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 +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} +4 -7
- package/lib/serve/server/lib/master/utils.js +130 -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/python/index.js +3 -3
- package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.0.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.0.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.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/node.mjs +1 -0
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +14 -0
- package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.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.0.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 +121 -13
- package/lib/shell/index.js +7 -1
- 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} +60 -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/default.js +9 -9
- 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 +6 -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 +5 -1
- package/lib/util_modules/constants/lib/template.js +9 -4
- package/lib/util_modules/constants/lib/urls.js +8 -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 +1 -1
- package/templates/event/job.json +30 -0
- 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 +13 -0
- package/lib/serve/server/lib/master.js +0 -326
- package/templates/init/functions/node/stream/sample.js +0 -15
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<projectDescription>
|
|
3
|
+
<name>{{_NAME_}}</name>
|
|
4
|
+
<comment></comment>
|
|
5
|
+
<projects>
|
|
6
|
+
</projects>
|
|
7
|
+
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
13
|
+
</buildSpec>
|
|
14
|
+
<natures>
|
|
15
|
+
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
16
|
+
</natures>
|
|
17
|
+
</projectDescription>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import java.util.logging.Level;
|
|
2
|
+
import java.util.logging.Logger;
|
|
3
|
+
|
|
4
|
+
import com.catalyst.Context;
|
|
5
|
+
import com.catalyst.job.JOB_STATUS;
|
|
6
|
+
import com.catalyst.job.JobRequest;
|
|
7
|
+
import com.catalyst.job.CatalystJobHandler;
|
|
8
|
+
|
|
9
|
+
import com.zc.common.ZCProject;
|
|
10
|
+
import com.zc.component.cache.ZCCache;
|
|
11
|
+
|
|
12
|
+
public class {{_CLASS_}} implements CatalystJobHandler {
|
|
13
|
+
|
|
14
|
+
private static final Logger LOGGER = Logger.getLogger({{_CLASS_}}.class.getName());
|
|
15
|
+
|
|
16
|
+
@Override
|
|
17
|
+
public JOB_STATUS handleJobExecute(JobRequest request, Context arg1) throws Exception {
|
|
18
|
+
try {
|
|
19
|
+
ZCProject.initProject();
|
|
20
|
+
Object eventData = request.getAllJobParams();
|
|
21
|
+
if(eventData != null) {
|
|
22
|
+
LOGGER.log(Level.SEVERE, "Data is" + eventData.toString());
|
|
23
|
+
}
|
|
24
|
+
LOGGER.log(Level.SEVERE, "Project Details " + request.getProjectDetails().toString());
|
|
25
|
+
ZCCache.getInstance().putCacheValue("JobSample", "Working", 1l);
|
|
26
|
+
LOGGER.log(Level.SEVERE, "Inserted SuccessFully:)");
|
|
27
|
+
} catch (Exception e) {
|
|
28
|
+
LOGGER.log(Level.SEVERE, "Exception in Job Function", e);
|
|
29
|
+
return JOB_STATUS.FAILURE;
|
|
30
|
+
}
|
|
31
|
+
return JOB_STATUS.SUCCESS;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {import("./types/job").JobRequest} jobRequest
|
|
4
|
+
* @param {import("./types/job").Context} context
|
|
5
|
+
*/
|
|
6
|
+
module.exports = (jobRequest, context) => {
|
|
7
|
+
console.log('Hello from {{_MAIN_}}');
|
|
8
|
+
|
|
9
|
+
// function input: { job_details: { job_meta_details: { params: { key: 'value' } } } }
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* JOB REQUEST FUNCTIONALITIES
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const projectDetails = jobRequest.getProjectDetails(); // to get the current project details
|
|
16
|
+
const jobDetails = jobRequest.getJobDetails(); // to get the current job details
|
|
17
|
+
const jobMetaDetails = jobRequest.getJobMetaDetails(); // to get the current job's meta details
|
|
18
|
+
const getJobCapacityAttributes = jobRequest.getJobCapacityAttributes(); // to get the current jobs capacity
|
|
19
|
+
const allJobParams = jobRequest.getAllJobParams(); // to get all the parameters supplied to the job function
|
|
20
|
+
const jobParam = jobRequest.getJobParam('key'); // to get the value of a particular parameter supplied to the job function
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* CONTEXT FUNCTIONALITIES
|
|
24
|
+
*/
|
|
25
|
+
context.closeWithSuccess(); //end of application with success
|
|
26
|
+
// context.closeWithFailure(); //end of application with failure
|
|
27
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a utility file with the type declaration of the job function parameters
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type of the Job Request object. Contains the required details of the current job.
|
|
7
|
+
*/
|
|
8
|
+
export interface JobRequest {
|
|
9
|
+
/**
|
|
10
|
+
* @returns Current project details
|
|
11
|
+
*/
|
|
12
|
+
getProjectDetails: () => Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* @returns Details of the current job
|
|
15
|
+
*/
|
|
16
|
+
getJobDetails: () => Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* @returns Meta details of the current job
|
|
19
|
+
*/
|
|
20
|
+
getJobMetaDetails: () => Record<string, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* @returns Capacity attributes of the current job
|
|
23
|
+
*/
|
|
24
|
+
getJobCapacityAttributes: () => Record<string, string | number>;
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @returns All parameters passed to the job function
|
|
28
|
+
*/
|
|
29
|
+
getAllJobParams: () => Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* @param key Name of the job param
|
|
32
|
+
* @returns Value of the job param
|
|
33
|
+
*/
|
|
34
|
+
getJobParam: (key: string) => string | undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Type of the context object. This object is used to initialize the Catalyst sdk
|
|
39
|
+
*/
|
|
40
|
+
export interface Context extends Record<string, unknown> {
|
|
41
|
+
/**
|
|
42
|
+
* Contains the necessary headers to initialize the sdk
|
|
43
|
+
*/
|
|
44
|
+
catalystHeaders: Record<string, string | number>;
|
|
45
|
+
/**
|
|
46
|
+
* @returns Maximum allowed execution time of the function
|
|
47
|
+
*/
|
|
48
|
+
getMaxExecutionTimeMs: () => number;
|
|
49
|
+
/**
|
|
50
|
+
* This values is the difference between time Maximum execution time and the current time
|
|
51
|
+
* @returns Remaining execution time of the function
|
|
52
|
+
*/
|
|
53
|
+
getRemainingExecutionTimeMs: () => number;
|
|
54
|
+
/**
|
|
55
|
+
* Conclude the function execution with a success response
|
|
56
|
+
*/
|
|
57
|
+
closeWithSuccess: () => void;
|
|
58
|
+
/**
|
|
59
|
+
* Conclude the function execution with a failure response
|
|
60
|
+
*/
|
|
61
|
+
closeWithFailure: () => void;
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
zcatalyst-sdk=={{_VERSION_}}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def handler(job_request, context):
|
|
5
|
+
logger = logging.getLogger()
|
|
6
|
+
logger.info('Hello from {{_MAIN_}}')
|
|
7
|
+
|
|
8
|
+
# function input: { job_details: { job_meta_details: { params: { key: 'value' } } } }
|
|
9
|
+
|
|
10
|
+
'''JobRequest Functionalities'''
|
|
11
|
+
job_details = job_request.get_job_details() # get the details of the current job
|
|
12
|
+
project_details = job_request.get_project_details() # get the details of the current project
|
|
13
|
+
job_meta_details = job_request.get_job_meta_details() # get the job meta of the current job
|
|
14
|
+
job_capacity_attributes = job_request.get_job_capacity_attributes() # get the current jobs capacity
|
|
15
|
+
all_job_params = job_request.get_all_job_params() # get all the parameters supplied to the job function
|
|
16
|
+
job_param = job_request.get_job_param('key') # get the value of a particular parameter supplied to the job function
|
|
17
|
+
|
|
18
|
+
'''Context Functionalities'''
|
|
19
|
+
remaining_execution_time_ms = context.get_remaining_execution_time_ms() # get the maximum allowed execution time for the job functions
|
|
20
|
+
max_execution_time_ms = context.get_max_execution_time_ms() # get the remaining execution time for this job function
|
|
21
|
+
# context.close_with_failure() # conclude the function execution with a failure response
|
|
22
|
+
context.close_with_success() # conclude the function execution with a success response
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
if (typeof catalyst === 'undefined'){
|
|
2
|
+
throw new Error('Catalyst Web SDK not included. You must include it before /__catalyst/sdk/init.js');
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
catalyst.initApp({
|
|
6
|
+
project_Id : "{{__PROJECT_ID__}}", //No I18N
|
|
7
|
+
zaid : "{{__ZAID__}}", //No I18N
|
|
8
|
+
auth_domain : "{{__AUTH_DOMAIN__}}",
|
|
9
|
+
is_appsail : "true",
|
|
10
|
+
api_domain : ""
|
|
11
|
+
},{
|
|
12
|
+
org_id: "{{__ORG_ID__}}" //No I18N
|
|
13
|
+
});
|