@unmeshed/sdk 1.0.12 → 1.0.13

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 (33) hide show
  1. package/package.json +1 -1
  2. package/src/apiClient.ts +0 -142
  3. package/src/index.ts +0 -43
  4. package/src/poller/pollerClientImpl.ts +0 -150
  5. package/src/process/processClientImpl.ts +0 -267
  6. package/src/registration/registrationClientImpl.ts +0 -17
  7. package/src/sampleTest.ts +0 -86
  8. package/src/types/index.ts +0 -349
  9. package/src/utils/unmeshedCommonUtils.ts +0 -13
  10. /package/{dist/apiClient.d.ts → apiClient.d.ts} +0 -0
  11. /package/{dist/apiClient.js → apiClient.js} +0 -0
  12. /package/{dist/apiClient.js.map → apiClient.js.map} +0 -0
  13. /package/{dist/index.d.ts → index.d.ts} +0 -0
  14. /package/{dist/index.js → index.js} +0 -0
  15. /package/{dist/index.js.map → index.js.map} +0 -0
  16. /package/{dist/poller → poller}/pollerClientImpl.d.ts +0 -0
  17. /package/{dist/poller → poller}/pollerClientImpl.js +0 -0
  18. /package/{dist/poller → poller}/pollerClientImpl.js.map +0 -0
  19. /package/{dist/process → process}/processClientImpl.d.ts +0 -0
  20. /package/{dist/process → process}/processClientImpl.js +0 -0
  21. /package/{dist/process → process}/processClientImpl.js.map +0 -0
  22. /package/{dist/registration → registration}/registrationClientImpl.d.ts +0 -0
  23. /package/{dist/registration → registration}/registrationClientImpl.js +0 -0
  24. /package/{dist/registration → registration}/registrationClientImpl.js.map +0 -0
  25. /package/{dist/sampleTest.d.ts → sampleTest.d.ts} +0 -0
  26. /package/{dist/sampleTest.js → sampleTest.js} +0 -0
  27. /package/{dist/sampleTest.js.map → sampleTest.js.map} +0 -0
  28. /package/{dist/types → types}/index.d.ts +0 -0
  29. /package/{dist/types → types}/index.js +0 -0
  30. /package/{dist/types → types}/index.js.map +0 -0
  31. /package/{dist/utils → utils}/unmeshedCommonUtils.d.ts +0 -0
  32. /package/{dist/utils → utils}/unmeshedCommonUtils.js +0 -0
  33. /package/{dist/utils → utils}/unmeshedCommonUtils.js.map +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unmeshed/sdk",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "scripts": {
5
5
  "build": "tsc --build --verbose",
6
6
  "dev": "tsc && node dist/sample/sampleServer.js",
package/src/apiClient.ts DELETED
@@ -1,142 +0,0 @@
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 DELETED
@@ -1,43 +0,0 @@
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;
@@ -1,150 +0,0 @@
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
- }
@@ -1,267 +0,0 @@
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
- };
@@ -1,17 +0,0 @@
1
- import { apiClient } from "..";
2
-
3
- export const renewRegistration = async (): Promise<string> => {
4
- try {
5
- const response = await apiClient.put("/api/clients/register", {
6
- params: {
7
- friendlyName: "Unmeshed",
8
- tokenExpiryDate: "",
9
- },
10
- });
11
- console.debug("Response from server:", response);
12
- return response.data;
13
- } catch (error) {
14
- console.error("Error occurred during registration renewal:", error);
15
- throw error;
16
- }
17
- };
package/src/sampleTest.ts DELETED
@@ -1,86 +0,0 @@
1
-
2
- import "dotenv/config";
3
- import UnmeshedClient from './index.js'
4
-
5
- const BASE_URL = process.env.UNMESHED_BASE_URL;
6
- const PORT = process.env.UNMESHED_PORT;
7
- const ClIENT_ID = process.env.UNMESHED_CLIENT_ID;
8
- const AUTH_TOKEN = process.env.UNMESHED_AUTH_TOKEN;
9
-
10
- console.log("UC2", UnmeshedClient)
11
-
12
- UnmeshedClient.initialize({
13
- baseUrl: BASE_URL || 'abc',
14
- port: PORT,
15
- clientId: ClIENT_ID || 'abc',
16
- authToken: AUTH_TOKEN || 'token',
17
- });
18
-
19
-
20
-
21
- //
22
- // const request = {
23
- // name: "sample-http",
24
- // namespace: "default",
25
- // input: {},
26
- // correlationId: "",
27
- // requestId: "",
28
- // version: 1,
29
- // };
30
- // const workers = [
31
- // {
32
- // worker: (input) => ArithmeticOperation(input),
33
- // namespace: "default",
34
- // name: "arithmetic_operation_worker",
35
- // maxInProgress: 10,
36
- // },
37
- // ];
38
- // UnmeshedClient.pollForWorkers(workers);
39
- //
40
- // const processId = 28878569;
41
- // const stepId = 28878571;
42
- // const processIds = [34, 344];
43
- // const clientId = "jdjfjf";
44
- // const endpoint = "your-endpoint";
45
- // const input = { key: "value" };
46
- // const id = "12345";
47
- // const apiCallType = ApiCallType.SYNC;
48
- //
49
- // const params = {
50
- // startTimeEpoch: 1673606400000,
51
- // endTimeEpoch: 1673692800000,
52
- // namespace: "default",
53
- // processTypes: [ProcessType.STANDARD],
54
- // triggerTypes: [ProcessTriggerType.MANUAL],
55
- // names: ["process1", "process2", "process3"],
56
- // processIds: [28883174, 28883162],
57
- // correlationIds: ["correlationId1", "correlationId2"],
58
- // requestIds: ["requestId1", "requestId2"],
59
- // statuses: [ProcessStatus.COMPLETED],
60
- // limit: 10,
61
- // offset: 0,
62
- // };
63
-
64
- // UnmeshedClient.getStepData(stepId)
65
- // .then((stepData) => {
66
- // console.log("STEP_DATA", stepData);
67
- // })
68
- // .catch((error) => {
69
- // console.error("Error fetching step data:", error.message);
70
- // });
71
-
72
- // UnmeshedClient.rerun(processId, ClIENT_ID)
73
- // .then((data) => {
74
- // console.log("PROCESS_DATA", data);
75
- // })
76
- // .catch((error) => {
77
- // console.error("Error fetching step data:", error.message);
78
- // });
79
-
80
- // UnmeshedClient.bulkTerminate(processIds)
81
- // .then((data) => {
82
- // console.log("PROCESS_DATA", data);
83
- // })
84
- // .catch((error) => {
85
- // console.error("Error fetching step data:", error.message);
86
- // });
@@ -1,349 +0,0 @@
1
- import { AxiosRequestConfig } from "axios";
2
-
3
- export enum ApiCallType {
4
- SYNC = "SYNC",
5
- ASYNC = "ASYNC",
6
- STREAM = "STREAM",
7
- }
8
-
9
- export interface ApiMappingData {
10
- endpoint: string;
11
- processDefNamespace: string;
12
- processDefName: string;
13
- processDefVersion: number;
14
- authType: string;
15
- authClaims: string;
16
- createdBy: string;
17
- updatedBy: string;
18
- created: Date;
19
- updated: Date;
20
- }
21
-
22
- export type ApiMappingWebhookData = {
23
- endpoint: string;
24
- name: string;
25
- uniqueId: string;
26
- urlSecret: string;
27
- description: string;
28
- userIdentifier: string;
29
- webhookSource: WebhookSource;
30
- webhookSourceConfig: Record<string, string>;
31
- expiryDate: Date;
32
- userType: SQAuthUserType;
33
- createdBy: string;
34
- updatedBy: string;
35
- created: Date;
36
- updated: Date;
37
- };
38
-
39
- export enum WebhookSource {
40
- MS_TEAMS = "MS_TEAMS",
41
- NOT_DEFINED = "NOT_DEFINED",
42
- }
43
-
44
- export enum SQAuthUserType {
45
- USER = "USER",
46
- API = "API",
47
- INTERNAL = "INTERNAL",
48
- }
49
-
50
- export enum StepType {
51
- WORKER = "WORKER",
52
- HTTP = "HTTP",
53
- WAIT = "WAIT",
54
- FAIL = "FAIL",
55
- PYTHON = "PYTHON",
56
- JAVASCRIPT = "JAVASCRIPT",
57
- JQ = "JQ",
58
- MANAGED = "MANAGED",
59
- BUILTIN = "BUILTIN",
60
- NOOP = "NOOP",
61
- PERSISTED_STATE = "PERSISTED_STATE",
62
- DEPENDSON = "DEPENDSON",
63
- INTEGRATION = "INTEGRATION",
64
- EXIT = "EXIT",
65
- SUB_PROCESS = "SUB_PROCESS",
66
- LIST = "LIST",
67
- PARALLEL = "PARALLEL",
68
- FOREACH = "FOREACH",
69
- SWITCH = "SWITCH",
70
- }
71
-
72
- export enum StepStatus {
73
- PENDING = "PENDING",
74
- SCHEDULED = "SCHEDULED",
75
- RUNNING = "RUNNING",
76
- PAUSED = "PAUSED",
77
- COMPLETED = "COMPLETED",
78
- FAILED = "FAILED",
79
- TIMED_OUT = "TIMED_OUT",
80
- SKIPPED = "SKIPPED",
81
- CANCELLED = "CANCELLED",
82
- }
83
-
84
- export enum ProcessStatus {
85
- RUNNING = "RUNNING",
86
- COMPLETED = "COMPLETED",
87
- FAILED = "FAILED",
88
- TIMED_OUT = "TIMED_OUT",
89
- CANCELLED = "CANCELLED",
90
- TERMINATED = "TERMINATED",
91
- REVIEWED = "REVIEWED",
92
- }
93
-
94
- export enum ProcessTriggerType {
95
- MANUAL = "MANUAL",
96
- SCHEDULED = "SCHEDULED",
97
- API_MAPPING = "API_MAPPING",
98
- WEBHOOK = "WEBHOOK",
99
- API = "API",
100
- SUB_PROCESS = "SUB_PROCESS",
101
- }
102
-
103
- export enum ProcessType {
104
- STANDARD = "STANDARD",
105
- DYNAMIC = "DYNAMIC",
106
- API_ORCHESTRATION = "API_ORCHESTRATION",
107
- INTERNAL = "INTERNAL",
108
- }
109
-
110
- export type ClientProfileData = {
111
- clientId: string;
112
- ipAddress: string;
113
- friendlyName: string;
114
- userIdentifier: string;
115
- stepQueueNames: StepQueueNameData[];
116
- createdBy: string;
117
- updatedBy: string;
118
- created: Date;
119
- updated: Date;
120
- expiryDate: Date;
121
- };
122
-
123
- export type FullClientProfileData = {
124
- clientId: string;
125
- ipAddress: string;
126
- friendlyName: string;
127
- userIdentifier: string;
128
- stepQueueNames: StepQueueNameData[];
129
- createdBy: string;
130
- updatedBy: string;
131
- created: Date;
132
- updated: Date;
133
- expiryDate: Date;
134
- tokenValue: string;
135
- };
136
-
137
- export type StepQueueNameData = {
138
- orgId: number;
139
- namespace: string;
140
- stepType: StepType;
141
- name: string;
142
- };
143
-
144
- export type ProcessActionResponseData = {
145
- count: number;
146
- details: ProcessActionResponseDetailData[];
147
- };
148
-
149
- export type ProcessActionResponseDetailData = {
150
- id: string;
151
- message: string;
152
- error: string;
153
- };
154
-
155
- export type ProcessData = {
156
- processId: number;
157
- processType: ProcessType;
158
- triggerType: ProcessTriggerType;
159
- namespace: string;
160
- name: string;
161
- version: number | null;
162
- processDefinitionHistoryId: number | null;
163
- requestId: string;
164
- correlationId: string;
165
- status: ProcessStatus;
166
- input: Record<string, unknown>;
167
- output: Record<string, unknown>;
168
- stepIdCount: number | null;
169
- shardName: string;
170
- shardInstanceId: number | null;
171
- stepIds: StepId[];
172
- stepDataById: Record<number, StepData>;
173
- created: number;
174
- updated: number;
175
- createdBy: string;
176
- };
177
-
178
- export type StepData = {
179
- id: number;
180
- processId: number;
181
- ref: string;
182
- parentId: number | null;
183
- parentRef: string | null;
184
- namespace: string;
185
- name: string;
186
- type: StepType;
187
- stepDefinitionHistoryId: number | null;
188
- status: StepStatus;
189
- input: Record<string, unknown>;
190
- output: Record<string, unknown>;
191
- workerId: string;
192
- start: number;
193
- schedule: number;
194
- priority: number;
195
- updated: number;
196
- optional: boolean;
197
- executionList: StepExecutionData[];
198
- };
199
-
200
- export type StepExecutionData = {
201
- id: number;
202
- scheduled: number;
203
- polled: number;
204
- start: number;
205
- updated: number;
206
- executor: string;
207
- ref: string;
208
- runs: number;
209
- output: Record<string, unknown>;
210
- };
211
-
212
- export type StepId = {
213
- id: number;
214
- processId: number;
215
- ref: string;
216
- };
217
-
218
- export type ProcessRequestData = {
219
- name: string;
220
- namespace: string;
221
- version: number | null;
222
- requestId: string;
223
- correlationId: string;
224
- input: Record<string, unknown>;
225
- };
226
-
227
- export type ProcessSearchRequest = {
228
- startTimeEpoch: number;
229
- endTimeEpoch?: number | null;
230
- namespace: string;
231
- processTypes: ProcessType[];
232
- triggerTypes: ProcessTriggerType[];
233
- names: string[];
234
- processIds: number[];
235
- correlationIds: string[];
236
- requestIds: string[];
237
- statuses: ProcessStatus[];
238
- limit: number;
239
- offset: number;
240
- };
241
-
242
- export type StepSize = {
243
- stepQueueNameData: StepQueueNameData;
244
- size: number | null;
245
- };
246
-
247
- export type ClientSubmitResult = {
248
- processId: number;
249
- stepId: number;
250
- errorMessage: string | null;
251
- httpStatusCode: number | null;
252
- };
253
-
254
- export type WorkRequest = {
255
- processId: number;
256
- stepId: number;
257
- stepExecutionId: number;
258
- runCount: number;
259
- stepName: string;
260
- stepNamespace: string;
261
- stepRef: string;
262
- inputParam: Record<string, unknown>;
263
- isOptional: boolean;
264
- polled: number;
265
- scheduled: number;
266
- updated: number;
267
- priority: number;
268
- };
269
-
270
- export type WorkResponse = {
271
- processId: number;
272
- stepId: number;
273
- stepExecutionId: number;
274
- runCount: number;
275
- output: Record<string, unknown>;
276
- status: StepStatus;
277
- rescheduleAfterSeconds: number | null;
278
- startedAt: number;
279
- };
280
-
281
- export type WorkResult = {
282
- output: unknown;
283
- taskExecutionId: string;
284
- startTime: number;
285
- endTime: number;
286
- workRequest: WorkRequest;
287
- };
288
-
289
- export interface ApiClientConfig {
290
- baseUrl: string;
291
- clientId: string;
292
- authToken: string;
293
- port?: string | number;
294
- timeout?: number;
295
- }
296
-
297
- export interface ApiResponse<T = any> {
298
- data: T;
299
- status: number;
300
- headers: Record<string, string>;
301
- }
302
-
303
- export interface ApiError extends Error {
304
- status?: number;
305
- response?: {
306
- data?: any;
307
- status: number;
308
- headers: Record<string, string>;
309
- };
310
- }
311
-
312
- export interface QueryParams {
313
- [key: string]: string | number | boolean | undefined;
314
- }
315
-
316
- export interface RequestConfig
317
- extends Omit<AxiosRequestConfig, "baseURL" | "url" | "method"> {
318
- headers?: Record<string, string>;
319
- }
320
-
321
- export interface HandleRequestConfig {
322
- method: "get" | "post" | "put" | "delete";
323
- endpoint: string;
324
- params?: QueryParams;
325
- data?: Record<string, unknown>;
326
- config?: RequestConfig;
327
- }
328
-
329
- export interface ClientRequestConfig {
330
- params?: QueryParams;
331
- data?: any;
332
- config?: RequestConfig;
333
- }
334
-
335
- interface UnmeshedWorker {
336
- (input: Record<string, any>): Promise<any>;
337
- }
338
-
339
- export interface UnmeshedWorkerConfig {
340
- worker: UnmeshedWorker;
341
- namespace: string;
342
- name: string;
343
- maxInProgress: number;
344
- }
345
-
346
- export interface PollRequestData {
347
- stepQueueNameData: StepQueueNameData;
348
- size: number;
349
- }
@@ -1,13 +0,0 @@
1
- import { createHash } from "crypto";
2
-
3
- export class UnmeshedCommonUtils {
4
- static createSecureHash(input: string): string {
5
- try {
6
- const hash = createHash("sha256");
7
- hash.update(input, "utf8");
8
- return hash.digest("hex");
9
- } catch (e) {
10
- throw new Error("Error creating hash");
11
- }
12
- }
13
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes