@unmeshed/sdk 1.0.9 → 1.0.11

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 (52) hide show
  1. package/.idea/modules.xml +8 -0
  2. package/.idea/unmeshed-javascript-sdk.iml +12 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/p.json +25 -0
  5. package/package.json +11 -12
  6. package/src/apiClient.ts +142 -0
  7. package/src/index.ts +43 -0
  8. package/src/poller/pollerClientImpl.ts +150 -0
  9. package/src/process/processClientImpl.ts +267 -0
  10. package/src/registration/registrationClientImpl.ts +17 -0
  11. package/src/sampleTest.ts +86 -0
  12. package/src/types/index.ts +349 -0
  13. package/src/utils/unmeshedCommonUtils.ts +13 -0
  14. package/tsconfig.json +29 -0
  15. package/tsconfig.tsbuildinfo +1 -0
  16. package/dist/apiClient.d.ts +0 -14
  17. package/dist/apiClient.js +0 -89
  18. package/dist/index.d.ts +0 -21
  19. package/dist/index.js +0 -22
  20. package/dist/poller/pollerClientImpl.d.ts +0 -2
  21. package/dist/poller/pollerClientImpl.js +0 -122
  22. package/dist/process/processClientImpl.d.ts +0 -12
  23. package/dist/process/processClientImpl.js +0 -181
  24. package/dist/registration/registrationClientImpl.d.ts +0 -1
  25. package/dist/registration/registrationClientImpl.js +0 -17
  26. package/dist/sample/sampleAPI.d.ts +0 -2
  27. package/dist/sample/sampleAPI.js +0 -29
  28. package/dist/sample/server.d.ts +0 -1
  29. package/dist/sample/server.js +0 -9
  30. package/dist/src/apiClient.d.ts +0 -14
  31. package/dist/src/apiClient.js +0 -99
  32. package/dist/src/index.d.ts +0 -21
  33. package/dist/src/index.js +0 -22
  34. package/dist/src/poller/pollerClientImpl.d.ts +0 -2
  35. package/dist/src/poller/pollerClientImpl.js +0 -126
  36. package/dist/src/process/processClientImpl.d.ts +0 -12
  37. package/dist/src/process/processClientImpl.js +0 -187
  38. package/dist/src/registration/registrationClientImpl.d.ts +0 -1
  39. package/dist/src/registration/registrationClientImpl.js +0 -17
  40. package/dist/src/sample/server.d.ts +0 -1
  41. package/dist/src/sample/server.js +0 -9
  42. package/dist/src/types/index.d.ts +0 -313
  43. package/dist/src/types/index.js +0 -77
  44. package/dist/src/utils/unmeshedCommonUtils.d.ts +0 -3
  45. package/dist/src/utils/unmeshedCommonUtils.js +0 -13
  46. package/dist/tsconfig.tsbuildinfo +0 -1
  47. package/dist/types/index.d.ts +0 -313
  48. package/dist/types/index.js +0 -77
  49. package/dist/types/unmeshedCommonUtils.d.ts +0 -3
  50. package/dist/types/unmeshedCommonUtils.js +0 -17
  51. package/dist/utils/unmeshedCommonUtils.d.ts +0 -3
  52. package/dist/utils/unmeshedCommonUtils.js +0 -13
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/unmeshed-javascript-sdk.iml" filepath="$PROJECT_DIR$/.idea/unmeshed-javascript-sdk.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
package/p.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@unmeshed/sdk",
3
+ "version": "1.0.10",
4
+ "description": "Unmeshed SDK",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "dev": "tsc && node dist/sample/sampleServer.js",
11
+ "start": "tsc && node dist/sample/sampleServer.js",
12
+ "publishToNpm": "tsc && npm publish --access public"
13
+ },
14
+ "files": [
15
+ "/dist"
16
+ ],
17
+ "dependencies": {
18
+ "@types/axios": "^0.14.4",
19
+ "axios": "^1.7.9",
20
+ "dotenv": "^16.4.7"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^22.10.6"
24
+ }
25
+ }
package/package.json CHANGED
@@ -1,24 +1,23 @@
1
1
  {
2
2
  "name": "@unmeshed/sdk",
3
- "version": "1.0.9",
4
- "description": "Unmeshed SDK",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
3
+ "version": "1.0.11",
7
4
  "scripts": {
8
- "build": "tsc",
5
+ "build": "tsc --build --verbose",
9
6
  "dev": "tsc && node dist/sample/sampleServer.js",
10
7
  "start": "tsc && node dist/sample/sampleServer.js",
11
- "publishToNpm": "tsc && npm publish --access public"
8
+ "publishToNpm": "tsc && npm publish --access public",
9
+ "clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo"
10
+ },
11
+ "author": "",
12
+ "license": "ISC",
13
+ "description": "",
14
+ "devDependencies": {
15
+ "@types/node": "^22.10.6",
16
+ "@tsconfig/node18": "^18.2.4"
12
17
  },
13
- "files": [
14
- "/dist"
15
- ],
16
18
  "dependencies": {
17
19
  "@types/axios": "^0.14.4",
18
20
  "axios": "^1.7.9",
19
21
  "dotenv": "^16.4.7"
20
- },
21
- "devDependencies": {
22
- "@types/node": "^22.10.6"
23
22
  }
24
23
  }
@@ -0,0 +1,142 @@
1
+ import axios, { AxiosError, AxiosInstance, AxiosResponse } from "axios";
2
+ import {
3
+ ApiClientConfig,
4
+ ApiResponse,
5
+ ClientRequestConfig,
6
+ HandleRequestConfig,
7
+ QueryParams,
8
+ RequestConfig,
9
+ } from "./types";
10
+ import { UnmeshedCommonUtils } from "./utils/unmeshedCommonUtils";
11
+
12
+ export class ApiClient {
13
+ private axiosInstance: AxiosInstance | null = null;
14
+ private clientId: string | undefined = undefined;
15
+
16
+ public initialize(config: ApiClientConfig): void {
17
+ console.log("Initializing Unmeshed ApiClient");
18
+ const { clientId, authToken, baseUrl, port, timeout = 10000 } = config;
19
+
20
+ this.clientId = clientId;
21
+
22
+ if (!baseUrl) {
23
+ throw new Error("baseUrl is required");
24
+ }
25
+
26
+ const baseURL = port ? `${baseUrl}:${port}` : baseUrl;
27
+
28
+ this.axiosInstance = axios.create({
29
+ baseURL,
30
+ timeout,
31
+ headers: {
32
+ "Content-Type": "application/json",
33
+ Authorization: `Bearer client.sdk.${clientId}.${UnmeshedCommonUtils.createSecureHash(
34
+ authToken
35
+ )}`,
36
+ },
37
+ });
38
+ }
39
+
40
+ private validateInstance(): void {
41
+ if (!this.axiosInstance) {
42
+ throw new Error("ApiClient must be initialized before making requests");
43
+ }
44
+ }
45
+
46
+ private async handleRequest<T>({
47
+ method,
48
+ endpoint,
49
+ params,
50
+ data,
51
+ config,
52
+ }: HandleRequestConfig): Promise<ApiResponse<T>> {
53
+ this.validateInstance();
54
+
55
+ try {
56
+ // Assert that axiosInstance exists before using it
57
+ if (!this.axiosInstance) {
58
+ throw new Error("Axios instance is not initialized");
59
+ }
60
+
61
+ const response: AxiosResponse<T> = await this.axiosInstance.request<T>({
62
+ method,
63
+ url: endpoint,
64
+ params,
65
+ data,
66
+ ...config,
67
+ });
68
+
69
+ return {
70
+ data: response.data,
71
+ status: response.status,
72
+ headers: response.headers as Record<string, string>,
73
+ };
74
+ } catch (error) {
75
+ if (axios.isAxiosError(error)) {
76
+ console.error("Request failed:", error.message);
77
+ throw this.handleError(error);
78
+ } else {
79
+ console.error("Unexpected error:", (error as Error).message);
80
+ throw error;
81
+ }
82
+ }
83
+ }
84
+
85
+ private handleError(error: AxiosError) {
86
+ console.error("Error details:", {
87
+ message: error.message,
88
+ status: error.response?.status,
89
+ data: error.response?.data,
90
+ });
91
+ }
92
+
93
+ public async get<T = any>(
94
+ endpoint: string,
95
+ params?: QueryParams,
96
+ config?: RequestConfig
97
+ ): Promise<ApiResponse<T>> {
98
+ return this.handleRequest<T>({
99
+ method: "get",
100
+ endpoint: endpoint,
101
+ params: params,
102
+ config: config,
103
+ });
104
+ }
105
+
106
+ public async post<T = any>(
107
+ endpoint: string,
108
+ clientRequestConfig: ClientRequestConfig
109
+ ): Promise<ApiResponse<T>> {
110
+ return this.handleRequest<T>({
111
+ method: "post",
112
+ endpoint: endpoint,
113
+ ...clientRequestConfig,
114
+ });
115
+ }
116
+
117
+ public async put<T = any>(
118
+ endpoint: string,
119
+ clientRequestConfig: ClientRequestConfig
120
+ ): Promise<ApiResponse<T>> {
121
+ return this.handleRequest<T>({
122
+ method: "put",
123
+ endpoint: endpoint,
124
+ ...clientRequestConfig,
125
+ });
126
+ }
127
+
128
+ public async delete<T = any>(
129
+ endpoint: string,
130
+ clientRequestConfig: ClientRequestConfig
131
+ ): Promise<ApiResponse<T>> {
132
+ return this.handleRequest<T>({
133
+ method: "delete",
134
+ endpoint: endpoint,
135
+ ...clientRequestConfig,
136
+ });
137
+ }
138
+
139
+ public getClientId(): string | undefined {
140
+ return this.clientId;
141
+ }
142
+ }
package/src/index.ts ADDED
@@ -0,0 +1,43 @@
1
+ import { ApiClient } from "./apiClient";
2
+ import pollForWorkers from "./poller/pollerClientImpl";
3
+ import {
4
+ bulkResume,
5
+ bulkReviewed,
6
+ bulkTerminate,
7
+ getProcessData,
8
+ getStepData,
9
+ invokeApiMappingGet,
10
+ invokeApiMappingPost,
11
+ rerun,
12
+ runProcessAsync,
13
+ runProcessSync,
14
+ searchProcessExecutions,
15
+ } from "./process/processClientImpl";
16
+ import { renewRegistration } from "./registration/registrationClientImpl";
17
+ import {
18
+ ApiCallType,
19
+ ApiClientConfig,
20
+ ProcessRequestData,
21
+ ProcessSearchRequest,
22
+ } from "./types";
23
+
24
+ export const apiClient = new ApiClient();
25
+
26
+ const UnmeshedClient = {
27
+ initialize: (config: ApiClientConfig) => apiClient.initialize(config),
28
+ runProcessSync,
29
+ runProcessAsync,
30
+ getProcessData,
31
+ getStepData,
32
+ bulkTerminate,
33
+ bulkResume,
34
+ bulkReviewed,
35
+ rerun,
36
+ searchProcessExecutions,
37
+ invokeApiMappingGet,
38
+ invokeApiMappingPost,
39
+ renewRegistration,
40
+ pollForWorkers,
41
+ };
42
+
43
+ export default UnmeshedClient;
@@ -0,0 +1,150 @@
1
+ import { apiClient } from "..";
2
+ import {
3
+ PollRequestData,
4
+ StepQueueNameData,
5
+ StepStatus,
6
+ UnmeshedWorkerConfig,
7
+ WorkRequest,
8
+ WorkResponse,
9
+ } from "../types";
10
+
11
+ async function registerPolling(data: StepQueueNameData[]) {
12
+ const attempt = async (): Promise<any> => {
13
+ try {
14
+ const response = await apiClient.put("/api/clients/register", {
15
+ data: data,
16
+ });
17
+ console.log("Successfully executed polling registration...");
18
+ return response.data;
19
+ } catch {
20
+ console.error(
21
+ "An error occurred during polling registration. Retrying in 3 seconds..."
22
+ );
23
+ await new Promise((resolve) => setTimeout(resolve, 3000));
24
+ return attempt();
25
+ }
26
+ };
27
+
28
+ return attempt();
29
+ }
30
+
31
+ async function pollWorker(data: PollRequestData[]) {
32
+ try {
33
+ const response = await apiClient.post("/api/clients/poll", {
34
+ data: data,
35
+ });
36
+ console.log("Succesfully executed worker polling...");
37
+ return response.data;
38
+ } catch (error) {
39
+ console.error("Error occurred during worker polling", error);
40
+ }
41
+ }
42
+
43
+ async function pollWorkerResult(data: WorkResponse[]) {
44
+ try {
45
+ const response = await apiClient.post("/api/clients/bulkResults", {
46
+ data: data,
47
+ });
48
+ console.log("Worker Result returned successfully...");
49
+ return response.data;
50
+ } catch (error) {
51
+ console.log("Error:", error);
52
+ }
53
+ }
54
+
55
+ export default async function pollForWorkers(workers: UnmeshedWorkerConfig[]) {
56
+ const registerPollingData = workers.map((worker) => {
57
+ return {
58
+ orgId: 0,
59
+ namespace: worker.namespace,
60
+ stepType: "WORKER",
61
+ name: worker.name,
62
+ } as StepQueueNameData;
63
+ });
64
+ await registerPolling(registerPollingData);
65
+ const pollWorkerData = workers.map((worker) => {
66
+ return {
67
+ stepQueueNameData: {
68
+ orgId: 0,
69
+ namespace: worker.namespace,
70
+ stepType: "WORKER",
71
+ name: worker.name,
72
+ },
73
+ size: worker.maxInProgress,
74
+ } as PollRequestData;
75
+ });
76
+
77
+ const pollResponse = await pollWorker(pollWorkerData);
78
+
79
+ const workerResult: WorkResponse[] = await Promise.all(
80
+ pollResponse.map(async (polledWorker: WorkRequest) => {
81
+ const associatedWorker: UnmeshedWorkerConfig | undefined = workers.find(
82
+ (worker) =>
83
+ worker.name === polledWorker.stepName &&
84
+ worker.namespace === polledWorker.stepNamespace
85
+ );
86
+
87
+ if(!associatedWorker) {
88
+ throw Error(`No worker found for ${polledWorker.stepName} ${polledWorker.stepNamespace}`)
89
+ }
90
+
91
+ let workerResponse: WorkResponse = {
92
+ processId: polledWorker.processId,
93
+ stepId: polledWorker.stepId,
94
+ stepExecutionId: polledWorker.stepExecutionId,
95
+ runCount: polledWorker.runCount,
96
+ output: {},
97
+ status: StepStatus.RUNNING,
98
+ rescheduleAfterSeconds: null,
99
+ startedAt: new Date().getTime(),
100
+ };
101
+
102
+ const TIMEOUT = 1000;
103
+
104
+ const timeoutPromise = new Promise((_, reject) => {
105
+ setTimeout(() => reject(new Error("Timed out")), TIMEOUT);
106
+ });
107
+
108
+ try {
109
+ const result = await Promise.race([
110
+ associatedWorker.worker(polledWorker.inputParam),
111
+ timeoutPromise,
112
+ ]);
113
+
114
+ workerResponse = {
115
+ ...workerResponse,
116
+ output: {
117
+ ...result,
118
+ __workCompletedAt: new Date().getTime(),
119
+ },
120
+ status: StepStatus.COMPLETED,
121
+ };
122
+ } catch (error: unknown) {
123
+ const err = error as Error;
124
+ if (err.message === "Timed out") {
125
+ workerResponse = {
126
+ ...workerResponse,
127
+ output: {
128
+ error: err.message,
129
+ },
130
+ status: StepStatus.TIMED_OUT,
131
+ };
132
+ } else {
133
+ workerResponse = {
134
+ ...workerResponse,
135
+ output: {
136
+ error: err.message,
137
+ },
138
+ status: StepStatus.FAILED,
139
+ };
140
+ console.error("Error:", err.message);
141
+ }
142
+ }
143
+
144
+ return workerResponse;
145
+ })
146
+ );
147
+
148
+ const workerResultResponse = await pollWorkerResult(workerResult);
149
+ console.log("Worker result : ", workerResultResponse);
150
+ }
@@ -0,0 +1,267 @@
1
+ import {apiClient} from "..";
2
+ import {
3
+ ApiCallType,
4
+ ProcessActionResponseData,
5
+ ProcessData,
6
+ ProcessRequestData,
7
+ ProcessSearchRequest,
8
+ StepData,
9
+ } from "../types";
10
+ import {isAxiosError} from "axios";
11
+
12
+ const RUN_PROCESS_REQUEST_URL = "api/process/";
13
+
14
+ export const runProcessSync = async (
15
+ ProcessRequestData: ProcessRequestData
16
+ ): Promise<ProcessData> => {
17
+ try {
18
+ const response = await apiClient.post(RUN_PROCESS_REQUEST_URL + "runSync", {
19
+ data: ProcessRequestData,
20
+ params: {
21
+ clientId: apiClient.getClientId(),
22
+ },
23
+ });
24
+ console.log("Response:", response);
25
+ return response.data;
26
+ } catch (error) {
27
+ console.error("Some error occurred running process request : ", error);
28
+ throw error;
29
+ }
30
+ };
31
+
32
+ export const runProcessAsync = async (
33
+ ProcessRequestData: ProcessRequestData
34
+ ): Promise<ProcessData> => {
35
+ try {
36
+ const response = await apiClient.post(
37
+ RUN_PROCESS_REQUEST_URL + "runAsync",
38
+ {
39
+ data: ProcessRequestData,
40
+ params: {
41
+ clientId: apiClient.getClientId(),
42
+ },
43
+ }
44
+ );
45
+ console.log("Response:", response);
46
+ return response.data;
47
+ } catch (error) {
48
+ console.error("Some error occurred running process request : ", error);
49
+ throw error;
50
+ }
51
+ };
52
+
53
+ export const getProcessData = async (
54
+ processId: number
55
+ ): Promise<ProcessData> => {
56
+ if (processId == null) {
57
+ throw new Error("Process ID cannot be null");
58
+ }
59
+ try {
60
+ const response = await apiClient.get<ProcessData>(
61
+ RUN_PROCESS_REQUEST_URL + "context/" + processId
62
+ );
63
+ return response.data;
64
+ } catch (error) {
65
+ console.error("Error occurred while fetching process record: ", error);
66
+ throw error;
67
+ }
68
+ };
69
+
70
+ export const getStepData = async (stepId: number | null): Promise<StepData> => {
71
+ if (stepId === null || stepId === undefined) {
72
+ throw new Error("Step ID cannot be null or undefined");
73
+ }
74
+
75
+ try {
76
+ const response = await apiClient.get<StepData>(
77
+ RUN_PROCESS_REQUEST_URL + "stepContext/" + stepId
78
+ );
79
+ return response.data;
80
+ } catch (error) {
81
+ const err = error as Error;
82
+ throw new Error(
83
+ `Error occurred while fetching step record: ${err.message || error}`
84
+ );
85
+ }
86
+ };
87
+
88
+ export const bulkTerminate = async (
89
+ processIds: number[],
90
+ reason?: string
91
+ ): Promise<ProcessActionResponseData> => {
92
+ try {
93
+ const response = await apiClient.post(
94
+ RUN_PROCESS_REQUEST_URL + "bulkTerminate",
95
+ {
96
+ params: { reason },
97
+ data: processIds,
98
+ }
99
+ );
100
+ return response.data as ProcessActionResponseData;
101
+ } catch (error) {
102
+ const err = error as Error;
103
+ throw new Error(
104
+ `Error occurred while terminating processes: ${err.message || error}`
105
+ );
106
+ }
107
+ };
108
+
109
+ export const bulkResume = async (
110
+ processIds: number[]
111
+ ): Promise<ProcessActionResponseData> => {
112
+ try {
113
+ const response = await apiClient.post(
114
+ RUN_PROCESS_REQUEST_URL + "bulkResume",
115
+ {
116
+ data: processIds,
117
+ }
118
+ );
119
+ return response.data as ProcessActionResponseData;
120
+ } catch (error) {
121
+ const err = error as Error;
122
+ throw new Error(
123
+ `Error occurred while resuming processes: ${err.message || error}`
124
+ );
125
+ }
126
+ };
127
+
128
+ export const bulkReviewed = async (
129
+ processIds: number[],
130
+ reason?: string
131
+ ): Promise<ProcessActionResponseData> => {
132
+ try {
133
+ const response = await apiClient.post(
134
+ RUN_PROCESS_REQUEST_URL + "bulkReviewed",
135
+ {
136
+ data: processIds,
137
+ params: { reason },
138
+ }
139
+ );
140
+ return response.data as ProcessActionResponseData;
141
+ } catch (error) {
142
+ const err = error as Error;
143
+ throw new Error(
144
+ `Error occurred while marking processes as reviewed: ${err.message || error}`
145
+ );
146
+ }
147
+ };
148
+
149
+ export const rerun = async (
150
+ processId: number,
151
+ clientId: string,
152
+ version?: number
153
+ ): Promise<ProcessData> => {
154
+ const params: Record<string, any> = {
155
+ clientId,
156
+ processId,
157
+ };
158
+
159
+ if (version !== undefined) {
160
+ params["version"] = version;
161
+ }
162
+
163
+ try {
164
+ const response = await apiClient.post(RUN_PROCESS_REQUEST_URL + "rerun", {
165
+ params,
166
+ });
167
+
168
+ return response.data as ProcessData;
169
+ } catch (error) {
170
+ if (isAxiosError(error)) {
171
+ throw new Error(
172
+ `HTTP request error during rerun process: ${error.response?.status} - ${error.response?.data}`
173
+ );
174
+ } else {
175
+ const err = error as Error;
176
+ throw new Error(
177
+ `Unexpected error during rerun process: ${err.message || err}`
178
+ );
179
+ }
180
+ }
181
+ };
182
+
183
+ export const searchProcessExecutions = async (params: ProcessSearchRequest) => {
184
+ const queryParams = new URLSearchParams();
185
+
186
+ if (params.startTimeEpoch !== undefined && params.startTimeEpoch !== 0)
187
+ queryParams.set("startTimeEpoch", params.startTimeEpoch.toString());
188
+ if (params.endTimeEpoch !== undefined && params.endTimeEpoch !== 0)
189
+ queryParams.set("endTimeEpoch", (params.endTimeEpoch || 0).toString());
190
+ if (params.namespace) queryParams.set("namespace", params.namespace);
191
+ if (params.names && params.names.length)
192
+ queryParams.set("names", params.names.join(","));
193
+ if (params.processIds && params.processIds.length)
194
+ queryParams.set("processIds", params.processIds.join(","));
195
+ if (params.correlationIds && params.correlationIds.length)
196
+ queryParams.set("correlationIds", params.correlationIds.join(","));
197
+ if (params.requestIds && params.requestIds.length)
198
+ queryParams.set("requestIds", params.requestIds.join(","));
199
+ if (params.statuses && params.statuses.length)
200
+ queryParams.set("statuses", params.statuses.join(","));
201
+ if (params.triggerTypes && params.triggerTypes.length)
202
+ queryParams.set("triggerTypes", params.triggerTypes.join(","));
203
+
204
+ const updatedParams = Object.fromEntries(new URLSearchParams(queryParams));
205
+
206
+ try {
207
+ const response = await apiClient.get(
208
+ RUN_PROCESS_REQUEST_URL + "api/stats/process/search",
209
+ updatedParams
210
+ );
211
+ console.log("Response:", response);
212
+ return response.data;
213
+ } catch (error) {
214
+ console.error("Error occurred while searching process executions: ", error);
215
+ throw error;
216
+ }
217
+ };
218
+
219
+ export const invokeApiMappingGet = async (
220
+ endpoint: string,
221
+ id: string,
222
+ correlationId: string,
223
+ apiCallType: ApiCallType
224
+ ) => {
225
+ try {
226
+ const response = await apiClient.get(
227
+ RUN_PROCESS_REQUEST_URL + "api/call/" + endpoint,
228
+ {
229
+ id: id,
230
+ correlationId: correlationId,
231
+ apiCallType,
232
+ }
233
+ );
234
+ console.log("Response:", response);
235
+ return response.data;
236
+ } catch (error) {
237
+ console.error("Error occurred while invoking API Mapping GET: ", error);
238
+ throw error;
239
+ }
240
+ };
241
+
242
+ export const invokeApiMappingPost = async (
243
+ endpoint: string,
244
+ input: Record<string, any>,
245
+ id: string,
246
+ correlationId: string,
247
+ apiCallType: ApiCallType = ApiCallType.ASYNC
248
+ ): Promise<any> => {
249
+ try {
250
+ const response = await apiClient.post(
251
+ RUN_PROCESS_REQUEST_URL + "api/call/" + endpoint,
252
+ {
253
+ data: input,
254
+ params: {
255
+ id: id,
256
+ correlationId: correlationId,
257
+ apiCallType,
258
+ },
259
+ }
260
+ );
261
+
262
+ return response.data;
263
+ } catch (error) {
264
+ console.error("Error occurred while invoking API Mapping POST: ", error);
265
+ throw error;
266
+ }
267
+ };