@unmeshed/sdk 1.0.6 → 1.0.7

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.
@@ -1,3 +1,14 @@
1
- import { AxiosInstance } from "axios";
2
- declare const _default: AxiosInstance;
3
- export default _default;
1
+ import { ApiClientConfig, ApiResponse, ClientRequestConfig, QueryParams, RequestConfig } from "./types/index";
2
+ export declare class ApiClient {
3
+ private axiosInstance;
4
+ private clientId;
5
+ initialize(config: ApiClientConfig): void;
6
+ private validateInstance;
7
+ private handleRequest;
8
+ private handleError;
9
+ get<T = any>(endpoint: string, params?: QueryParams, config?: RequestConfig): Promise<ApiResponse<T>>;
10
+ post<T = any>(endpoint: string, clientRequestConfig: ClientRequestConfig): Promise<ApiResponse<T>>;
11
+ put<T = any>(endpoint: string, clientRequestConfig: ClientRequestConfig): Promise<ApiResponse<T>>;
12
+ delete<T = any>(endpoint: string, clientRequestConfig: ClientRequestConfig): Promise<ApiResponse<T>>;
13
+ getClientId(): string | null;
14
+ }
package/dist/apiClient.js CHANGED
@@ -1,31 +1,94 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiClient = void 0;
3
4
  const axios_1 = require("axios");
4
- const config_1 = require("./config");
5
+ const unmeshedCommonUtils_1 = require("./utils/unmeshedCommonUtils");
5
6
  class ApiClient {
6
7
  constructor() {
7
- const { hostname, port, bearerToken, basePath } = config_1.default.getConfig();
8
- this.client = axios_1.default.create({
9
- baseURL: `https://${hostname}:${port}${basePath || ""}`,
8
+ this.axiosInstance = null;
9
+ this.clientId = null;
10
+ }
11
+ initialize(config) {
12
+ const { clientId, authToken, baseUrl, port, timeout = 10000 } = config;
13
+ this.clientId = clientId;
14
+ if (!baseUrl) {
15
+ throw new Error("baseUrl is required");
16
+ }
17
+ const baseURL = port ? `${baseUrl}:${port}` : baseUrl;
18
+ this.axiosInstance = axios_1.default.create({
19
+ baseURL,
20
+ timeout,
10
21
  headers: {
11
- Authorization: `Bearer ${bearerToken}`,
12
22
  "Content-Type": "application/json",
23
+ Authorization: `Bearer client.sdk.${clientId}.${unmeshedCommonUtils_1.UnmeshedCommonUtils.createSecureHash(authToken)}`,
13
24
  },
14
25
  });
15
- // Optional: Add interceptors for request/response
16
- this.client.interceptors.request.use((req) => {
17
- // Modify request if needed
18
- return req;
19
- }, (error) => {
20
- return Promise.reject(error);
26
+ }
27
+ validateInstance() {
28
+ if (!this.axiosInstance) {
29
+ throw new Error("ApiClient must be initialized before making requests");
30
+ }
31
+ }
32
+ async handleRequest({ method, endpoint, params, data, config, }) {
33
+ this.validateInstance();
34
+ try {
35
+ const response = await this.axiosInstance.request({
36
+ method,
37
+ url: endpoint,
38
+ params,
39
+ data,
40
+ ...config,
41
+ });
42
+ return {
43
+ data: response.data,
44
+ status: response.status,
45
+ headers: response.headers,
46
+ };
47
+ }
48
+ catch (error) {
49
+ console.error("Request failed:", error.message);
50
+ throw this.handleError(error);
51
+ }
52
+ }
53
+ handleError(error) {
54
+ var _a, _b;
55
+ console.error("Error details:", {
56
+ message: error.message,
57
+ status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
58
+ data: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
59
+ });
60
+ }
61
+ async get(endpoint, params, config) {
62
+ return this.handleRequest({
63
+ method: "get",
64
+ endpoint: endpoint,
65
+ params: params,
66
+ config: config,
21
67
  });
22
- this.client.interceptors.response.use((response) => response, (error) => {
23
- // Handle errors globally
24
- return Promise.reject(error);
68
+ }
69
+ async post(endpoint, clientRequestConfig) {
70
+ return this.handleRequest({
71
+ method: "post",
72
+ endpoint: endpoint,
73
+ ...clientRequestConfig,
74
+ });
75
+ }
76
+ async put(endpoint, clientRequestConfig) {
77
+ return this.handleRequest({
78
+ method: "put",
79
+ endpoint: endpoint,
80
+ ...clientRequestConfig,
81
+ });
82
+ }
83
+ async delete(endpoint, clientRequestConfig) {
84
+ return this.handleRequest({
85
+ method: "delete",
86
+ endpoint: endpoint,
87
+ ...clientRequestConfig,
25
88
  });
26
89
  }
27
- getInstance() {
28
- return this.client;
90
+ getClientId() {
91
+ return this.clientId;
29
92
  }
30
93
  }
31
- exports.default = new ApiClient().getInstance();
94
+ exports.ApiClient = ApiClient;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,21 @@
1
- import { ApiConfig } from "./config";
2
- import * as TestApi from "./testApi";
3
- export declare const configure: (apiConfig: ApiConfig) => void;
4
- export declare const TestAPI: typeof TestApi;
1
+ import { ApiClient } from "./apiClient";
2
+ import pollForWorkers from "./poller/pollerClientImpl";
3
+ import { ApiCallType, ApiClientConfig, ProcessRequestData, ProcessSearchRequest } from "./types";
4
+ export declare const apiClient: ApiClient;
5
+ declare const UnmeshedClient: {
6
+ initialize: (config: ApiClientConfig) => void;
7
+ runProcessSync: (ProcessRequestData: ProcessRequestData) => Promise<import("./types").ProcessData>;
8
+ runProcessAsync: (ProcessRequestData: ProcessRequestData) => Promise<import("./types").ProcessData>;
9
+ getProcessData: (processId: number) => Promise<import("./types").ProcessData>;
10
+ getStepData: (stepId: number | null) => Promise<import("./types").StepData>;
11
+ bulkTerminate: (processIds: number[], reason?: string) => Promise<import("./types").ProcessActionResponseData>;
12
+ bulkResume: (processIds: number[]) => Promise<import("./types").ProcessActionResponseData>;
13
+ bulkReviewed: (processIds: number[], reason?: string) => Promise<import("./types").ProcessActionResponseData>;
14
+ rerun: (processId: number, clientId: string, version?: number) => Promise<import("./types").ProcessData>;
15
+ searchProcessExecutions: (params: ProcessSearchRequest) => Promise<any>;
16
+ invokeApiMappingGet: (endpoint: string, id: string, correlationId: string, apiCallType: ApiCallType) => Promise<any>;
17
+ invokeApiMappingPost: (endpoint: string, input: Record<string, any>, id: string, correlationId: string, apiCallType?: ApiCallType) => Promise<any>;
18
+ renewRegistration: () => Promise<string>;
19
+ pollForWorkers: typeof pollForWorkers;
20
+ };
21
+ export default UnmeshedClient;
package/dist/index.js CHANGED
@@ -1,10 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestAPI = exports.configure = void 0;
4
- const config_1 = require("./config");
5
- const TestApi = require("./testApi");
6
- const configure = (apiConfig) => {
7
- config_1.default.setConfig(apiConfig);
3
+ exports.apiClient = void 0;
4
+ const apiClient_1 = require("./apiClient");
5
+ const pollerClientImpl_1 = require("./poller/pollerClientImpl");
6
+ const processClientImpl_1 = require("./process/processClientImpl");
7
+ const registrationClientImpl_1 = require("./registration/registrationClientImpl");
8
+ exports.apiClient = new apiClient_1.ApiClient();
9
+ const UnmeshedClient = {
10
+ initialize: (config) => exports.apiClient.initialize(config),
11
+ runProcessSync: processClientImpl_1.runProcessSync,
12
+ runProcessAsync: processClientImpl_1.runProcessAsync,
13
+ getProcessData: processClientImpl_1.getProcessData,
14
+ getStepData: processClientImpl_1.getStepData,
15
+ bulkTerminate: processClientImpl_1.bulkTerminate,
16
+ bulkResume: processClientImpl_1.bulkResume,
17
+ bulkReviewed: processClientImpl_1.bulkReviewed,
18
+ rerun: processClientImpl_1.rerun,
19
+ searchProcessExecutions: processClientImpl_1.searchProcessExecutions,
20
+ invokeApiMappingGet: processClientImpl_1.invokeApiMappingGet,
21
+ invokeApiMappingPost: processClientImpl_1.invokeApiMappingPost,
22
+ renewRegistration: registrationClientImpl_1.renewRegistration,
23
+ pollForWorkers: pollerClientImpl_1.default,
8
24
  };
9
- exports.configure = configure;
10
- exports.TestAPI = TestApi;
25
+ exports.default = UnmeshedClient;
@@ -0,0 +1,2 @@
1
+ import { UnmeshedWorkerConfig } from "../types";
2
+ export default function pollForWorkers(workers: UnmeshedWorkerConfig[]): Promise<void>;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = pollForWorkers;
4
+ const __1 = require("..");
5
+ const types_1 = require("../types");
6
+ async function registerPolling(data) {
7
+ const attempt = async () => {
8
+ try {
9
+ const response = await __1.apiClient.put("/api/clients/register", {
10
+ data: data,
11
+ });
12
+ console.log("Successfully executed polling registration...");
13
+ return response.data;
14
+ }
15
+ catch {
16
+ console.error("An error occurred during polling registration. Retrying in 3 seconds...");
17
+ await new Promise((resolve) => setTimeout(resolve, 3000));
18
+ return attempt();
19
+ }
20
+ };
21
+ return attempt();
22
+ }
23
+ async function pollWorker(data) {
24
+ try {
25
+ const response = await __1.apiClient.post("/api/clients/poll", {
26
+ data: data,
27
+ });
28
+ console.log("Succesfully executed worker polling...");
29
+ return response.data;
30
+ }
31
+ catch (error) {
32
+ console.error("Error occurred during worker polling", error);
33
+ }
34
+ }
35
+ async function pollWorkerResult(data) {
36
+ try {
37
+ const response = await __1.apiClient.post("/api/clients/bulkResults", {
38
+ data: data,
39
+ });
40
+ console.log("Worker Result returned successfully...");
41
+ return response.data;
42
+ }
43
+ catch (error) {
44
+ console.log("Error:", error);
45
+ }
46
+ }
47
+ async function pollForWorkers(workers) {
48
+ const registerPollingData = workers.map((worker) => {
49
+ return {
50
+ orgId: 0,
51
+ namespace: worker.namespace,
52
+ stepType: "WORKER",
53
+ name: worker.name,
54
+ };
55
+ });
56
+ await registerPolling(registerPollingData);
57
+ const pollWorkerData = workers.map((worker) => {
58
+ return {
59
+ stepQueueNameData: {
60
+ orgId: 0,
61
+ namespace: worker.namespace,
62
+ stepType: "WORKER",
63
+ name: worker.name,
64
+ },
65
+ size: worker.maxInProgress,
66
+ };
67
+ });
68
+ const pollResponse = await pollWorker(pollWorkerData);
69
+ const workerResult = await Promise.all(pollResponse.map(async (polledWorker) => {
70
+ const associatedWorker = workers.find((worker) => worker.name === polledWorker.stepName &&
71
+ worker.namespace === polledWorker.stepNamespace);
72
+ let workerResponse = {
73
+ processId: polledWorker.processId,
74
+ stepId: polledWorker.stepId,
75
+ stepExecutionId: polledWorker.stepExecutionId,
76
+ runCount: polledWorker.runCount,
77
+ output: {},
78
+ status: types_1.StepStatus.RUNNING,
79
+ rescheduleAfterSeconds: null,
80
+ startedAt: new Date().getTime(),
81
+ };
82
+ const TIMEOUT = 1000;
83
+ const timeoutPromise = new Promise((_, reject) => {
84
+ setTimeout(() => reject(new Error("Timed out")), TIMEOUT);
85
+ });
86
+ try {
87
+ const result = await Promise.race([
88
+ associatedWorker.worker(polledWorker.inputParam),
89
+ timeoutPromise,
90
+ ]);
91
+ workerResponse = {
92
+ ...workerResponse,
93
+ output: {
94
+ ...result,
95
+ __workCompletedAt: new Date().getTime(),
96
+ },
97
+ status: types_1.StepStatus.COMPLETED,
98
+ };
99
+ }
100
+ catch (error) {
101
+ if (error.message === "Timed out") {
102
+ workerResponse = {
103
+ ...workerResponse,
104
+ output: {
105
+ error: error.message,
106
+ },
107
+ status: types_1.StepStatus.TIMED_OUT,
108
+ };
109
+ }
110
+ else {
111
+ workerResponse = {
112
+ ...workerResponse,
113
+ output: {
114
+ error: error.message,
115
+ },
116
+ status: types_1.StepStatus.FAILED,
117
+ };
118
+ console.error("Error:", error.message);
119
+ }
120
+ }
121
+ return workerResponse;
122
+ }));
123
+ const workerResultResponse = await pollWorkerResult(workerResult);
124
+ console.log("Worker result : ", workerResultResponse);
125
+ }
@@ -0,0 +1,12 @@
1
+ import { ApiCallType, ProcessSearchRequest, ProcessActionResponseData, ProcessData, ProcessRequestData, StepData } from "../types";
2
+ export declare const runProcessSync: (ProcessRequestData: ProcessRequestData) => Promise<ProcessData>;
3
+ export declare const runProcessAsync: (ProcessRequestData: ProcessRequestData) => Promise<ProcessData>;
4
+ export declare const getProcessData: (processId: number) => Promise<ProcessData>;
5
+ export declare const getStepData: (stepId: number | null) => Promise<StepData>;
6
+ export declare const bulkTerminate: (processIds: number[], reason?: string) => Promise<ProcessActionResponseData>;
7
+ export declare const bulkResume: (processIds: number[]) => Promise<ProcessActionResponseData>;
8
+ export declare const bulkReviewed: (processIds: number[], reason?: string) => Promise<ProcessActionResponseData>;
9
+ export declare const rerun: (processId: number, clientId: string, version?: number) => Promise<ProcessData>;
10
+ export declare const searchProcessExecutions: (params: ProcessSearchRequest) => Promise<any>;
11
+ export declare const invokeApiMappingGet: (endpoint: string, id: string, correlationId: string, apiCallType: ApiCallType) => Promise<any>;
12
+ export declare const invokeApiMappingPost: (endpoint: string, input: Record<string, any>, id: string, correlationId: string, apiCallType?: ApiCallType) => Promise<any>;
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.invokeApiMappingPost = exports.invokeApiMappingGet = exports.searchProcessExecutions = exports.rerun = exports.bulkReviewed = exports.bulkResume = exports.bulkTerminate = exports.getStepData = exports.getProcessData = exports.runProcessAsync = exports.runProcessSync = void 0;
4
+ const __1 = require("..");
5
+ const types_1 = require("../types");
6
+ const RUN_PROCESS_REQUEST_URL = "api/process/";
7
+ const runProcessSync = async (ProcessRequestData) => {
8
+ try {
9
+ const response = await __1.apiClient.post(RUN_PROCESS_REQUEST_URL + "runSync", {
10
+ data: ProcessRequestData,
11
+ params: {
12
+ clientId: __1.apiClient.getClientId(),
13
+ },
14
+ });
15
+ console.log("Response:", response);
16
+ return response.data;
17
+ }
18
+ catch (error) {
19
+ console.error("Some error occurred running process request : ", error);
20
+ throw error;
21
+ }
22
+ };
23
+ exports.runProcessSync = runProcessSync;
24
+ const runProcessAsync = async (ProcessRequestData) => {
25
+ try {
26
+ const response = await __1.apiClient.post(RUN_PROCESS_REQUEST_URL + "runAsync", {
27
+ data: ProcessRequestData,
28
+ params: {
29
+ clientId: __1.apiClient.getClientId(),
30
+ },
31
+ });
32
+ console.log("Response:", response);
33
+ return response.data;
34
+ }
35
+ catch (error) {
36
+ console.error("Some error occurred running process request : ", error);
37
+ throw error;
38
+ }
39
+ };
40
+ exports.runProcessAsync = runProcessAsync;
41
+ const getProcessData = async (processId) => {
42
+ if (processId == null) {
43
+ throw new Error("Process ID cannot be null");
44
+ }
45
+ try {
46
+ const response = await __1.apiClient.get(RUN_PROCESS_REQUEST_URL + "context/" + processId);
47
+ return response.data;
48
+ }
49
+ catch (error) {
50
+ console.error("Error occurred while fetching process record: ", error);
51
+ throw error;
52
+ }
53
+ };
54
+ exports.getProcessData = getProcessData;
55
+ const getStepData = async (stepId) => {
56
+ if (stepId === null || stepId === undefined) {
57
+ throw new Error("Step ID cannot be null or undefined");
58
+ }
59
+ try {
60
+ const response = await __1.apiClient.get(RUN_PROCESS_REQUEST_URL + "stepContext/" + stepId);
61
+ return response.data;
62
+ }
63
+ catch (error) {
64
+ throw new Error(`Error occurred while fetching step record: ${error.message || error}`);
65
+ }
66
+ };
67
+ exports.getStepData = getStepData;
68
+ const bulkTerminate = async (processIds, reason) => {
69
+ try {
70
+ const response = await __1.apiClient.post(RUN_PROCESS_REQUEST_URL + "bulkTerminate", {
71
+ params: { reason },
72
+ data: processIds,
73
+ });
74
+ return response.data;
75
+ }
76
+ catch (error) {
77
+ throw new Error(`Error occurred while terminating processes: ${error.message || error}`);
78
+ }
79
+ };
80
+ exports.bulkTerminate = bulkTerminate;
81
+ const bulkResume = async (processIds) => {
82
+ try {
83
+ const response = await __1.apiClient.post(RUN_PROCESS_REQUEST_URL + "bulkResume", {
84
+ data: processIds,
85
+ });
86
+ return response.data;
87
+ }
88
+ catch (error) {
89
+ throw new Error(`Error occurred while resuming processes: ${error.message || error}`);
90
+ }
91
+ };
92
+ exports.bulkResume = bulkResume;
93
+ const bulkReviewed = async (processIds, reason) => {
94
+ try {
95
+ const response = await __1.apiClient.post(RUN_PROCESS_REQUEST_URL + "bulkReviewed", {
96
+ data: processIds,
97
+ params: { reason },
98
+ });
99
+ return response.data;
100
+ }
101
+ catch (error) {
102
+ throw new Error(`Error occurred while marking processes as reviewed: ${error.message || error}`);
103
+ }
104
+ };
105
+ exports.bulkReviewed = bulkReviewed;
106
+ const rerun = async (processId, clientId, version) => {
107
+ var _a, _b;
108
+ const params = {
109
+ clientId,
110
+ processId,
111
+ };
112
+ if (version !== undefined) {
113
+ params["version"] = version;
114
+ }
115
+ try {
116
+ const response = await __1.apiClient.post(RUN_PROCESS_REQUEST_URL + "rerun", {
117
+ params,
118
+ });
119
+ return response.data;
120
+ }
121
+ catch (error) {
122
+ if (error.isAxiosError) {
123
+ throw new Error(`HTTP request error during rerun process: ${(_a = error.response) === null || _a === void 0 ? void 0 : _a.status} - ${(_b = error.response) === null || _b === void 0 ? void 0 : _b.data}`);
124
+ }
125
+ else {
126
+ throw new Error(`Unexpected error during rerun process: ${error.message}`);
127
+ }
128
+ }
129
+ };
130
+ exports.rerun = rerun;
131
+ const searchProcessExecutions = async (params) => {
132
+ const queryParams = new URLSearchParams();
133
+ if (params.startTimeEpoch !== undefined && params.startTimeEpoch !== 0)
134
+ queryParams.set("startTimeEpoch", params.startTimeEpoch.toString());
135
+ if (params.endTimeEpoch !== undefined && params.endTimeEpoch !== 0)
136
+ queryParams.set("endTimeEpoch", params.endTimeEpoch.toString());
137
+ if (params.namespace)
138
+ queryParams.set("namespace", params.namespace);
139
+ if (params.names && params.names.length)
140
+ queryParams.set("names", params.names.join(","));
141
+ if (params.processIds && params.processIds.length)
142
+ queryParams.set("processIds", params.processIds.join(","));
143
+ if (params.correlationIds && params.correlationIds.length)
144
+ queryParams.set("correlationIds", params.correlationIds.join(","));
145
+ if (params.requestIds && params.requestIds.length)
146
+ queryParams.set("requestIds", params.requestIds.join(","));
147
+ if (params.statuses && params.statuses.length)
148
+ queryParams.set("statuses", params.statuses.join(","));
149
+ if (params.triggerTypes && params.triggerTypes.length)
150
+ queryParams.set("triggerTypes", params.triggerTypes.join(","));
151
+ const updatedParams = Object.fromEntries(new URLSearchParams(queryParams));
152
+ try {
153
+ const response = await __1.apiClient.get(RUN_PROCESS_REQUEST_URL + "api/stats/process/search", updatedParams);
154
+ console.log("Response:", response);
155
+ return response.data;
156
+ }
157
+ catch (error) {
158
+ console.error("Error occurred while searching process executions: ", error);
159
+ throw error;
160
+ }
161
+ };
162
+ exports.searchProcessExecutions = searchProcessExecutions;
163
+ const invokeApiMappingGet = async (endpoint, id, correlationId, apiCallType) => {
164
+ try {
165
+ const response = await __1.apiClient.get(RUN_PROCESS_REQUEST_URL + "api/call/" + endpoint, {
166
+ id: id,
167
+ correlationId: correlationId,
168
+ apiCallType,
169
+ });
170
+ console.log("Response:", response);
171
+ return response.data;
172
+ }
173
+ catch (error) {
174
+ console.error("Error occurred while invoking API Mapping GET: ", error);
175
+ throw error;
176
+ }
177
+ };
178
+ exports.invokeApiMappingGet = invokeApiMappingGet;
179
+ const invokeApiMappingPost = async (endpoint, input, id, correlationId, apiCallType = types_1.ApiCallType.ASYNC) => {
180
+ try {
181
+ const response = await __1.apiClient.post(RUN_PROCESS_REQUEST_URL + "api/call/" + endpoint, {
182
+ data: input,
183
+ params: {
184
+ id: id,
185
+ correlationId: correlationId,
186
+ apiCallType,
187
+ },
188
+ });
189
+ return response.data;
190
+ }
191
+ catch (error) {
192
+ console.error("Error occurred while invoking API Mapping POST: ", error);
193
+ throw error;
194
+ }
195
+ };
196
+ exports.invokeApiMappingPost = invokeApiMappingPost;
@@ -0,0 +1 @@
1
+ export declare const renewRegistration: () => Promise<string>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renewRegistration = void 0;
4
+ const __1 = require("..");
5
+ const renewRegistration = async () => {
6
+ try {
7
+ const response = await __1.apiClient.put("/api/clients/register", {
8
+ params: {
9
+ friendlyName: "Unmeshed",
10
+ tokenExpiryDate: "",
11
+ },
12
+ });
13
+ console.debug("Response from server:", response);
14
+ return response.data;
15
+ }
16
+ catch (error) {
17
+ console.error("Error occurred during registration renewal:", error);
18
+ throw error;
19
+ }
20
+ };
21
+ exports.renewRegistration = renewRegistration;
@@ -0,0 +1,2 @@
1
+ export declare const getApi: () => Promise<void>;
2
+ export declare const postApi: () => Promise<import("../types").ApiResponse<any>>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.postApi = exports.getApi = void 0;
4
+ const __1 = require("..");
5
+ const getApi = async () => {
6
+ try {
7
+ const response = await __1.apiClient.get("/api/schedules", {
8
+ name: "test_name",
9
+ });
10
+ console.log("Response:", response);
11
+ }
12
+ catch (error) {
13
+ console.error("Error occurred:", error);
14
+ }
15
+ };
16
+ exports.getApi = getApi;
17
+ const postApi = async () => {
18
+ try {
19
+ const response = await __1.apiClient.post("/api/test/post", {
20
+ data: { name: "test_name" },
21
+ });
22
+ console.log("Response:", response);
23
+ return response;
24
+ }
25
+ catch (error) {
26
+ console.error("Error occurred:", error);
27
+ }
28
+ };
29
+ exports.postApi = postApi;
@@ -0,0 +1 @@
1
+ import "dotenv/config";
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const __1 = require("..");
4
+ const types_1 = require("../types");
5
+ require("dotenv/config");
6
+ const ArithmeticWorker_1 = require("./workers/ArithmeticWorker");
7
+ const BASE_URL = process.env.UNMESHED_BASE_URL;
8
+ const PORT = process.env.UNMESHED_PORT;
9
+ const ClIENT_ID = process.env.UNMESHED_CLIENT_ID;
10
+ const AUTH_TOKEN = process.env.UNMESHED_AUTH_TOKEN;
11
+ __1.default.initialize({
12
+ baseUrl: BASE_URL,
13
+ port: PORT,
14
+ clientId: ClIENT_ID,
15
+ authToken: AUTH_TOKEN,
16
+ });
17
+ const request = {
18
+ name: "sample-http",
19
+ namespace: "default",
20
+ input: {},
21
+ correlationId: "",
22
+ requestId: "",
23
+ version: 1,
24
+ };
25
+ const workers = [
26
+ {
27
+ worker: (input) => (0, ArithmeticWorker_1.ArithmeticOperation)(input),
28
+ namespace: "default",
29
+ name: "arithmetic_operation_worker",
30
+ maxInProgress: 10,
31
+ },
32
+ ];
33
+ // UnmeshedClient.pollForWorkers(workers);
34
+ const processId = 28878569;
35
+ const stepId = 28878571;
36
+ const processIds = [34, 344];
37
+ const clientId = "jdjfjf";
38
+ const endpoint = "your-endpoint";
39
+ const input = { key: "value" };
40
+ const id = "12345";
41
+ const apiCallType = types_1.ApiCallType.SYNC;
42
+ const params = {
43
+ startTimeEpoch: 1673606400000,
44
+ endTimeEpoch: 1673692800000,
45
+ namespace: "default",
46
+ processTypes: [types_1.ProcessType.STANDARD],
47
+ triggerTypes: [types_1.ProcessTriggerType.MANUAL],
48
+ names: ["process1", "process2", "process3"],
49
+ processIds: [28883174, 28883162],
50
+ correlationIds: ["correlationId1", "correlationId2"],
51
+ requestIds: ["requestId1", "requestId2"],
52
+ statuses: [types_1.ProcessStatus.COMPLETED],
53
+ limit: 10,
54
+ offset: 0,
55
+ };
56
+ // UnmeshedClient.getStepData(stepId)
57
+ // .then((stepData) => {
58
+ // console.log("STEP_DATA", stepData);
59
+ // })
60
+ // .catch((error) => {
61
+ // console.error("Error fetching step data:", error.message);
62
+ // });
63
+ // UnmeshedClient.rerun(processId, ClIENT_ID)
64
+ // .then((data) => {
65
+ // console.log("PROCESS_DATA", data);
66
+ // })
67
+ // .catch((error) => {
68
+ // console.error("Error fetching step data:", error.message);
69
+ // });
70
+ __1.default.bulkTerminate(processIds)
71
+ .then((data) => {
72
+ console.log("PROCESS_DATA", data);
73
+ })
74
+ .catch((error) => {
75
+ console.error("Error fetching step data:", error.message);
76
+ });
@@ -0,0 +1,5 @@
1
+ type ArithmeticOutput = {
2
+ result: number | string;
3
+ };
4
+ export declare const ArithmeticOperation: (input: Record<string, any>) => Promise<ArithmeticOutput>;
5
+ export {};