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.
Files changed (160) hide show
  1. package/docs/command_needs/rc.toml +8 -8
  2. package/docs/commands/ds/import.toml +5 -5
  3. package/docs/commands/event/generate/job.toml +7 -0
  4. package/docs/commands/zest/generate/index.toml +4 -0
  5. package/docs/endpoints/lib/job-scheduling.toml +3 -0
  6. package/docs/internal/command.toml +5 -0
  7. package/docs/serve/server/lib/appsail/index.toml +22 -1
  8. package/lib/appsail-utils.js +4 -10
  9. package/lib/authentication/index.js +1 -0
  10. package/lib/authentication/login.js +8 -4
  11. package/lib/bin/catalyst.js +1 -1
  12. package/lib/code-deck.js +7 -7
  13. package/lib/command_needs/rc.js +8 -8
  14. package/lib/commands/appsail/add.js +3 -2
  15. package/lib/commands/client/setup.js +2 -1
  16. package/lib/commands/codelib/install.js +6 -2
  17. package/lib/commands/ds/import.js +37 -21
  18. package/lib/commands/event/generate/index.js +16 -3
  19. package/lib/commands/event/generate/integ.js +2 -1
  20. package/lib/commands/event/generate/job.js +82 -0
  21. package/lib/commands/functions/add.js +2 -1
  22. package/lib/commands/functions/delete.js +2 -4
  23. package/lib/commands/functions/setup.js +2 -1
  24. package/lib/commands/functions/shell.js +1 -0
  25. package/lib/commands/iac/export.js +5 -1
  26. package/lib/commands/iac/import.js +4 -1
  27. package/lib/commands/index.js +4 -1
  28. package/lib/commands/init.js +10 -7
  29. package/lib/commands/login.js +1 -0
  30. package/lib/commands/logout.js +1 -0
  31. package/lib/commands/pull.js +1 -0
  32. package/lib/commands/serve.js +1 -1
  33. package/lib/commands/whoami.js +1 -0
  34. package/lib/commands/zest/generate/index.js +304 -0
  35. package/lib/deploy/features/appsail/index.js +42 -25
  36. package/lib/deploy/features/appsail/utils.js +4 -5
  37. package/lib/endpoints/index.js +24 -3
  38. package/lib/endpoints/lib/appsail.js +7 -1
  39. package/lib/endpoints/lib/ds-bulk.js +1 -0
  40. package/lib/endpoints/lib/job-scheduling.js +61 -0
  41. package/lib/endpoints/lib/stratus.js +63 -0
  42. package/lib/endpoints/lib/tunnel.js +18 -0
  43. package/lib/endpoints/lib/zest.js +124 -0
  44. package/lib/event_generate/stratus.js +52 -0
  45. package/lib/express_middlewares/logger.js +2 -4
  46. package/lib/fn-utils/lib/common.js +8 -4
  47. package/lib/fn-utils/lib/java.js +1 -1
  48. package/lib/fn-utils/lib/python.js +2 -2
  49. package/lib/fn-watcher.js +1 -1
  50. package/lib/iac/status/deploy.js +1 -5
  51. package/lib/init/dependencies/python/ensure-python.js +6 -8
  52. package/lib/init/features/appsail/index.js +38 -27
  53. package/lib/init/features/client/index.js +2 -1
  54. package/lib/init/features/functions/index.js +4 -0
  55. package/lib/init/features/functions/languages/python.js +21 -5
  56. package/lib/init/features/project.js +6 -15
  57. package/lib/internal/api.js +26 -7
  58. package/lib/internal/command.js +31 -7
  59. package/lib/migration/index.js +4 -2
  60. package/lib/optional-import.js +3 -2
  61. package/lib/prompt/index.js +5 -2
  62. package/lib/prompt/types/file-path.js +1 -1
  63. package/lib/prompt/types/search-box.js +281 -0
  64. package/lib/prompt/types/tree.js +3 -3
  65. package/lib/serve/features/appsail.js +3 -4
  66. package/lib/serve/index.js +1 -2
  67. package/lib/serve/server/index.js +52 -23
  68. package/lib/serve/server/lib/appsail/index.js +89 -39
  69. package/lib/serve/server/lib/appsail/start.js +9 -1
  70. package/lib/serve/server/lib/java/aio_server/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  71. 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
  72. package/lib/serve/server/lib/java/aio_server/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  73. package/lib/serve/server/lib/java/index.js +2 -2
  74. package/lib/serve/server/lib/master/appsail.js +53 -0
  75. package/lib/serve/server/lib/master/functions.js +34 -0
  76. package/lib/serve/server/lib/master/index.js +155 -0
  77. package/lib/{express_middlewares/unknownReqProxy.js → serve/server/lib/master/unknown-req-proxy.js} +9 -9
  78. package/lib/serve/server/lib/master/utils.js +142 -0
  79. package/lib/serve/server/lib/master/web-client.js +39 -0
  80. package/lib/serve/server/lib/node/index.js +3 -3
  81. package/lib/serve/server/lib/node/server/package-lock.json +12 -0
  82. package/lib/serve/server/lib/python/index.js +3 -3
  83. package/lib/shell/dependencies/http-functions.js +1 -1
  84. package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
  85. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
  86. package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
  87. package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +2 -1
  88. package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
  89. package/lib/shell/dependencies/invoker/event/node.mjs +1 -0
  90. package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +15 -0
  91. package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
  92. package/lib/shell/dependencies/invoker/integ/node.mjs +13 -0
  93. package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +268 -0
  94. package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
  95. package/lib/shell/dependencies/invoker/job/java/lib/org.json.jar +0 -0
  96. package/lib/shell/dependencies/invoker/job/node.mjs +93 -0
  97. package/lib/shell/dependencies/local-function.js +122 -13
  98. package/lib/shell/dependencies/tunnel-server.js +52 -23
  99. package/lib/shell/index.js +22 -22
  100. package/lib/shell/prepare/languages/index.js +4 -4
  101. package/lib/shell/prepare/languages/java.js +1 -2
  102. package/lib/shell/prepare/languages/python.js +10 -16
  103. package/lib/throbber/index.js +6 -1
  104. package/lib/userConfig.js +7 -1
  105. package/lib/util_modules/config/index.js +1 -1
  106. package/lib/util_modules/config/lib/{appSail.js → appsail.js} +64 -10
  107. package/lib/util_modules/config/lib/client.js +6 -8
  108. package/lib/util_modules/config/lib/functions.js +6 -8
  109. package/lib/util_modules/constants/lib/dc-type.js +8 -0
  110. package/lib/util_modules/constants/lib/default.js +9 -9
  111. package/lib/util_modules/constants/lib/event-action.js +1 -0
  112. package/lib/util_modules/constants/lib/event-source.js +1 -0
  113. package/lib/util_modules/constants/lib/fn-type.js +2 -1
  114. package/lib/util_modules/constants/lib/needed-scopes.js +53 -44
  115. package/lib/util_modules/constants/lib/placeholders.js +7 -0
  116. package/lib/util_modules/constants/lib/ref-mapping.js +2 -1
  117. package/lib/util_modules/constants/lib/remote-mapping.js +2 -1
  118. package/lib/util_modules/constants/lib/scopes.js +17 -2
  119. package/lib/util_modules/constants/lib/template.js +9 -4
  120. package/lib/util_modules/constants/lib/urls.js +16 -0
  121. package/lib/util_modules/fs/lib/async.js +14 -4
  122. package/lib/util_modules/fs/lib/sync.js +12 -1
  123. package/lib/util_modules/server.js +2 -4
  124. package/lib/winston.js +17 -11
  125. package/package.json +4 -2
  126. package/templates/event/job.json +30 -0
  127. package/templates/init/client/react/react_js/template/src/index.js +3 -3
  128. package/templates/init/client/react/react_ts/template/src/index.tsx +3 -3
  129. package/templates/init/client/react/react_ts/template.json +3 -3
  130. package/templates/init/functions/java/job/.classpath +6 -0
  131. package/templates/init/functions/java/job/.project +17 -0
  132. package/templates/init/functions/java/job/catalyst-config.json +11 -0
  133. package/templates/init/functions/java/job/sample.java +34 -0
  134. package/templates/init/functions/node/aio/package.json +1 -1
  135. package/templates/init/functions/node/aio/sample.js +7 -0
  136. package/templates/init/functions/node/bio/package.json +1 -1
  137. package/templates/init/functions/node/bio/sample.js +5 -0
  138. package/templates/init/functions/node/bio/types/basicio.d.ts +57 -0
  139. package/templates/init/functions/node/cron/package.json +1 -1
  140. package/templates/init/functions/node/cron/sample.js +5 -0
  141. package/templates/init/functions/node/cron/types/cron.d.ts +64 -0
  142. package/templates/init/functions/node/event/package.json +1 -1
  143. package/templates/init/functions/node/event/sample.js +11 -8
  144. package/templates/init/functions/node/event/types/event.d.ts +82 -0
  145. package/templates/init/functions/node/integ/cliq/package.json +1 -1
  146. package/templates/init/functions/node/integ/convokraft/package.json +1 -1
  147. package/templates/init/functions/node/{stream → job}/catalyst-config.json +3 -2
  148. package/templates/init/functions/node/{stream → job}/package.json +1 -1
  149. package/templates/init/functions/node/job/sample.js +27 -0
  150. package/templates/init/functions/node/job/types/job.d.ts +62 -0
  151. package/templates/init/functions/python/job/catalyst-config.json +11 -0
  152. package/templates/init/functions/python/job/requirements.txt +1 -0
  153. package/templates/init/functions/python/job/sample.py +22 -0
  154. package/templates/init.txt +14 -0
  155. package/lib/serve/server/lib/master.js +0 -326
  156. package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  157. package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  158. package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  159. package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  160. package/templates/init/functions/node/stream/sample.js +0 -15
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
- import ReactDOM from 'react-dom';
2
+ import ReactDOM from 'react-dom/client';
3
3
  import './index.css';
4
4
  import App from './App';
5
5
  import reportWebVitals from './reportWebVitals';
6
6
 
7
- ReactDOM.render(
7
+ const root = ReactDOM.createRoot(document.getElementById('root'));
8
+ root.render(
8
9
  <React.StrictMode>
9
10
  <App />
10
11
  </React.StrictMode>,
11
- document.getElementById('root')
12
12
  );
13
13
 
14
14
  // If you want to start measuring performance in your app, pass a function
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
- import ReactDOM from 'react-dom';
2
+ import ReactDOM, { Container } from 'react-dom/client';
3
3
  import './index.css';
4
4
  import App from './App';
5
5
  import reportWebVitals from './reportWebVitals';
6
6
 
7
- ReactDOM.render(
7
+ const root = ReactDOM.createRoot(document.getElementById('root') as Container);
8
+ root.render(
8
9
  <React.StrictMode>
9
10
  <App />
10
11
  </React.StrictMode>,
11
- document.getElementById('root')
12
12
  );
13
13
 
14
14
  // If you want to start measuring performance in your app, pass a function
@@ -4,9 +4,9 @@
4
4
  "@testing-library/jest-dom": "^5.11.4",
5
5
  "@testing-library/react": "^11.1.0",
6
6
  "@testing-library/user-event": "^12.1.10",
7
- "@types/node": "^12.0.0",
8
- "@types/react": "^17.0.0",
9
- "@types/react-dom": "^17.0.0",
7
+ "@types/node": "latest",
8
+ "@types/react": "latest",
9
+ "@types/react-dom": "latest",
10
10
  "@types/jest": "^26.0.15",
11
11
  "typescript": "^4.1.2",
12
12
  "web-vitals": "^1.0.1"
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <classpath>
3
+ <classpathentry including="**/*.java" kind="src" path="."/>
4
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
+ <classpathentry kind="output" path=".output"/>
6
+ </classpath>
@@ -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,11 @@
1
+ {
2
+ "deployment": {
3
+ "name": "{{_NAME_}}",
4
+ "stack": "{{_STACK_}}",
5
+ "type": "{{_TYPE_}}",
6
+ "env_variables": {}
7
+ },
8
+ "execution": {
9
+ "main": "{{_CLASS_}}"
10
+ }
11
+ }
@@ -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
+ }
@@ -4,6 +4,6 @@
4
4
  "main": "{{_MAIN_}}",
5
5
  "author": "{{_AUTHOR_}}",
6
6
  "dependencies": {
7
- "zcatalyst-sdk-node": "latest"
7
+ "zcatalyst-sdk-node": "beta"
8
8
  }
9
9
  }
@@ -1,5 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ const { IncomingMessage, ServerResponse } = require("http");
4
+
5
+ /**
6
+ *
7
+ * @param {IncomingMessage} req
8
+ * @param {ServerResponse} res
9
+ */
3
10
  module.exports = (req, res) => {
4
11
  var url = req.url;
5
12
 
@@ -4,6 +4,6 @@
4
4
  "main": "{{_MAIN_}}",
5
5
  "author": "{{_AUTHOR_}}",
6
6
  "dependencies": {
7
- "zcatalyst-sdk-node": "latest"
7
+ "zcatalyst-sdk-node": "beta"
8
8
  }
9
9
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {import('./types/basicio').Context} context
4
+ * @param {import('./types/basicio').BasicIO} basicIO
5
+ */
1
6
  module.exports = (context, basicIO) => {
2
7
  /*
3
8
  BASICIO FUNCTIONALITIES
@@ -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
+ }
@@ -4,6 +4,6 @@
4
4
  "main": "{{_MAIN_}}",
5
5
  "author": "{{_AUTHOR_}}",
6
6
  "dependencies": {
7
- "zcatalyst-sdk-node": "latest"
7
+ "zcatalyst-sdk-node": "beta"
8
8
  }
9
9
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {import('./types/cron').CronDetails} cronDetails
4
+ * @param {import('./types/cron').Context} context
5
+ */
1
6
  module.exports = (cronDetails, context) => {
2
7
  console.log('Hello from {{_MAIN_}}');
3
8
 
@@ -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
+ }
@@ -4,6 +4,6 @@
4
4
  "main": "{{_MAIN_}}",
5
5
  "author": "{{_AUTHOR_}}",
6
6
  "dependencies": {
7
- "zcatalyst-sdk-node": "latest"
7
+ "zcatalyst-sdk-node": "beta"
8
8
  }
9
9
  }
@@ -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.data; //event data
6
- // const TIME = event.time; //event occured time
10
+ // const DATA = event.getData(); //event data
11
+ // const TIME = event.getTime(); //event occurred time
7
12
 
8
- // const SOURCE_DETAILS = event.getSourceDetails(); //event source details
9
- // const SOURCE_ACTION = SOURCE_DETAILS.action; //(insert | fetch | invoke ...)
10
- // const SOURCE_TYPE = SOURCE_DETAILS.type; //(datastore | cache | queue ...)
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 = SOURCE_DETAILS.getBusDetails(); //event 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
+ }
@@ -6,6 +6,6 @@
6
6
  "type": "module",
7
7
  "dependencies": {
8
8
  "zcatalyst-integ-cliq": "latest",
9
- "zcatalyst-sdk-node": "^2.1.0"
9
+ "zcatalyst-sdk-node": "beta"
10
10
  }
11
11
  }
@@ -5,6 +5,6 @@
5
5
  "author": "{{_AUTHOR_}}",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "zcatalyst-sdk-node": "^2.1.0"
8
+ "zcatalyst-sdk-node": "beta"
9
9
  }
10
10
  }
@@ -2,9 +2,10 @@
2
2
  "deployment": {
3
3
  "name": "{{_NAME_}}",
4
4
  "stack": "{{_STACK_}}",
5
- "type": "{{_TYPE_}}"
5
+ "type": "{{_TYPE_}}",
6
+ "env_variables": {}
6
7
  },
7
8
  "execution": {
8
9
  "main": "{{_MAIN_}}"
9
10
  }
10
- }
11
+ }
@@ -4,6 +4,6 @@
4
4
  "main": "{{_MAIN_}}",
5
5
  "author": "{{_AUTHOR_}}",
6
6
  "dependencies": {
7
- "zcatalyst-sdk-node": "latest"
7
+ "zcatalyst-sdk-node": "beta"
8
8
  }
9
9
  }
@@ -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,11 @@
1
+ {
2
+ "deployment": {
3
+ "name": "{{_NAME_}}",
4
+ "stack": "{{_STACK_}}",
5
+ "type": "{{_TYPE_}}",
6
+ "env_variables": {}
7
+ },
8
+ "execution": {
9
+ "main": "{{_MAIN_}}"
10
+ }
11
+ }
@@ -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,14 @@
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
+ stratus_domain: "{{_STRATUS_DOMAIN__}}"
12
+ },{
13
+ org_id: "{{__ORG_ID__}}" //No I18N
14
+ });