@unmeshed/sdk 1.0.11 → 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.
@@ -1,23 +1,21 @@
1
-
2
- import "dotenv/config";
3
- import UnmeshedClient from './index.js'
4
-
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ require("dotenv/config");
7
+ const index_js_1 = __importDefault(require("./index.js"));
5
8
  const BASE_URL = process.env.UNMESHED_BASE_URL;
6
9
  const PORT = process.env.UNMESHED_PORT;
7
10
  const ClIENT_ID = process.env.UNMESHED_CLIENT_ID;
8
11
  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',
12
+ console.log("UC2", index_js_1.default);
13
+ index_js_1.default.initialize({
14
+ baseUrl: BASE_URL || 'abc',
15
+ port: PORT,
16
+ clientId: ClIENT_ID || 'abc',
17
+ authToken: AUTH_TOKEN || 'token',
17
18
  });
18
-
19
-
20
-
21
19
  //
22
20
  // const request = {
23
21
  // name: "sample-http",
@@ -60,7 +58,6 @@ UnmeshedClient.initialize({
60
58
  // limit: 10,
61
59
  // offset: 0,
62
60
  // };
63
-
64
61
  // UnmeshedClient.getStepData(stepId)
65
62
  // .then((stepData) => {
66
63
  // console.log("STEP_DATA", stepData);
@@ -68,7 +65,6 @@ UnmeshedClient.initialize({
68
65
  // .catch((error) => {
69
66
  // console.error("Error fetching step data:", error.message);
70
67
  // });
71
-
72
68
  // UnmeshedClient.rerun(processId, ClIENT_ID)
73
69
  // .then((data) => {
74
70
  // console.log("PROCESS_DATA", data);
@@ -76,7 +72,6 @@ UnmeshedClient.initialize({
76
72
  // .catch((error) => {
77
73
  // console.error("Error fetching step data:", error.message);
78
74
  // });
79
-
80
75
  // UnmeshedClient.bulkTerminate(processIds)
81
76
  // .then((data) => {
82
77
  // console.log("PROCESS_DATA", data);
@@ -84,3 +79,4 @@ UnmeshedClient.initialize({
84
79
  // .catch((error) => {
85
80
  // console.error("Error fetching step data:", error.message);
86
81
  // });
82
+ //# sourceMappingURL=sampleTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampleTest.js","sourceRoot":"","sources":["../src/sampleTest.ts"],"names":[],"mappings":";;;;;AACA,yBAAuB;AACvB,0DAAuC;AAEvC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AACvC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;AACjD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAEnD,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,kBAAc,CAAC,CAAA;AAElC,kBAAc,CAAC,UAAU,CAAC;IACxB,OAAO,EAAE,QAAQ,IAAI,KAAK;IAC1B,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,SAAS,IAAI,KAAK;IAC5B,SAAS,EAAE,UAAU,IAAI,OAAO;CACjC,CAAC,CAAC;AAIH,EAAE;AACF,oBAAoB;AACpB,yBAAyB;AACzB,0BAA0B;AAC1B,eAAe;AACf,uBAAuB;AACvB,mBAAmB;AACnB,gBAAgB;AAChB,KAAK;AACL,oBAAoB;AACpB,MAAM;AACN,qDAAqD;AACrD,4BAA4B;AAC5B,2CAA2C;AAC3C,yBAAyB;AACzB,OAAO;AACP,KAAK;AACL,0CAA0C;AAC1C,EAAE;AACF,8BAA8B;AAC9B,2BAA2B;AAC3B,gCAAgC;AAChC,6BAA6B;AAC7B,oCAAoC;AACpC,kCAAkC;AAClC,sBAAsB;AACtB,wCAAwC;AACxC,EAAE;AACF,mBAAmB;AACnB,mCAAmC;AACnC,iCAAiC;AACjC,0BAA0B;AAC1B,0CAA0C;AAC1C,+CAA+C;AAC/C,iDAAiD;AACjD,sCAAsC;AACtC,0DAA0D;AAC1D,8CAA8C;AAC9C,yCAAyC;AACzC,eAAe;AACf,eAAe;AACf,KAAK;AAEL,qCAAqC;AACrC,0BAA0B;AAC1B,0CAA0C;AAC1C,OAAO;AACP,wBAAwB;AACxB,iEAAiE;AACjE,QAAQ;AAER,6CAA6C;AAC7C,sBAAsB;AACtB,yCAAyC;AACzC,OAAO;AACP,wBAAwB;AACxB,iEAAiE;AACjE,QAAQ;AAER,2CAA2C;AAC3C,sBAAsB;AACtB,yCAAyC;AACzC,OAAO;AACP,wBAAwB;AACxB,iEAAiE;AACjE,QAAQ"}
@@ -0,0 +1,313 @@
1
+ import { AxiosRequestConfig } from "axios";
2
+ export declare enum ApiCallType {
3
+ SYNC = "SYNC",
4
+ ASYNC = "ASYNC",
5
+ STREAM = "STREAM"
6
+ }
7
+ export interface ApiMappingData {
8
+ endpoint: string;
9
+ processDefNamespace: string;
10
+ processDefName: string;
11
+ processDefVersion: number;
12
+ authType: string;
13
+ authClaims: string;
14
+ createdBy: string;
15
+ updatedBy: string;
16
+ created: Date;
17
+ updated: Date;
18
+ }
19
+ export type ApiMappingWebhookData = {
20
+ endpoint: string;
21
+ name: string;
22
+ uniqueId: string;
23
+ urlSecret: string;
24
+ description: string;
25
+ userIdentifier: string;
26
+ webhookSource: WebhookSource;
27
+ webhookSourceConfig: Record<string, string>;
28
+ expiryDate: Date;
29
+ userType: SQAuthUserType;
30
+ createdBy: string;
31
+ updatedBy: string;
32
+ created: Date;
33
+ updated: Date;
34
+ };
35
+ export declare enum WebhookSource {
36
+ MS_TEAMS = "MS_TEAMS",
37
+ NOT_DEFINED = "NOT_DEFINED"
38
+ }
39
+ export declare enum SQAuthUserType {
40
+ USER = "USER",
41
+ API = "API",
42
+ INTERNAL = "INTERNAL"
43
+ }
44
+ export declare enum StepType {
45
+ WORKER = "WORKER",
46
+ HTTP = "HTTP",
47
+ WAIT = "WAIT",
48
+ FAIL = "FAIL",
49
+ PYTHON = "PYTHON",
50
+ JAVASCRIPT = "JAVASCRIPT",
51
+ JQ = "JQ",
52
+ MANAGED = "MANAGED",
53
+ BUILTIN = "BUILTIN",
54
+ NOOP = "NOOP",
55
+ PERSISTED_STATE = "PERSISTED_STATE",
56
+ DEPENDSON = "DEPENDSON",
57
+ INTEGRATION = "INTEGRATION",
58
+ EXIT = "EXIT",
59
+ SUB_PROCESS = "SUB_PROCESS",
60
+ LIST = "LIST",
61
+ PARALLEL = "PARALLEL",
62
+ FOREACH = "FOREACH",
63
+ SWITCH = "SWITCH"
64
+ }
65
+ export declare enum StepStatus {
66
+ PENDING = "PENDING",
67
+ SCHEDULED = "SCHEDULED",
68
+ RUNNING = "RUNNING",
69
+ PAUSED = "PAUSED",
70
+ COMPLETED = "COMPLETED",
71
+ FAILED = "FAILED",
72
+ TIMED_OUT = "TIMED_OUT",
73
+ SKIPPED = "SKIPPED",
74
+ CANCELLED = "CANCELLED"
75
+ }
76
+ export declare enum ProcessStatus {
77
+ RUNNING = "RUNNING",
78
+ COMPLETED = "COMPLETED",
79
+ FAILED = "FAILED",
80
+ TIMED_OUT = "TIMED_OUT",
81
+ CANCELLED = "CANCELLED",
82
+ TERMINATED = "TERMINATED",
83
+ REVIEWED = "REVIEWED"
84
+ }
85
+ export declare enum ProcessTriggerType {
86
+ MANUAL = "MANUAL",
87
+ SCHEDULED = "SCHEDULED",
88
+ API_MAPPING = "API_MAPPING",
89
+ WEBHOOK = "WEBHOOK",
90
+ API = "API",
91
+ SUB_PROCESS = "SUB_PROCESS"
92
+ }
93
+ export declare enum ProcessType {
94
+ STANDARD = "STANDARD",
95
+ DYNAMIC = "DYNAMIC",
96
+ API_ORCHESTRATION = "API_ORCHESTRATION",
97
+ INTERNAL = "INTERNAL"
98
+ }
99
+ export type ClientProfileData = {
100
+ clientId: string;
101
+ ipAddress: string;
102
+ friendlyName: string;
103
+ userIdentifier: string;
104
+ stepQueueNames: StepQueueNameData[];
105
+ createdBy: string;
106
+ updatedBy: string;
107
+ created: Date;
108
+ updated: Date;
109
+ expiryDate: Date;
110
+ };
111
+ export type FullClientProfileData = {
112
+ clientId: string;
113
+ ipAddress: string;
114
+ friendlyName: string;
115
+ userIdentifier: string;
116
+ stepQueueNames: StepQueueNameData[];
117
+ createdBy: string;
118
+ updatedBy: string;
119
+ created: Date;
120
+ updated: Date;
121
+ expiryDate: Date;
122
+ tokenValue: string;
123
+ };
124
+ export type StepQueueNameData = {
125
+ orgId: number;
126
+ namespace: string;
127
+ stepType: StepType;
128
+ name: string;
129
+ };
130
+ export type ProcessActionResponseData = {
131
+ count: number;
132
+ details: ProcessActionResponseDetailData[];
133
+ };
134
+ export type ProcessActionResponseDetailData = {
135
+ id: string;
136
+ message: string;
137
+ error: string;
138
+ };
139
+ export type ProcessData = {
140
+ processId: number;
141
+ processType: ProcessType;
142
+ triggerType: ProcessTriggerType;
143
+ namespace: string;
144
+ name: string;
145
+ version: number | null;
146
+ processDefinitionHistoryId: number | null;
147
+ requestId: string;
148
+ correlationId: string;
149
+ status: ProcessStatus;
150
+ input: Record<string, unknown>;
151
+ output: Record<string, unknown>;
152
+ stepIdCount: number | null;
153
+ shardName: string;
154
+ shardInstanceId: number | null;
155
+ stepIds: StepId[];
156
+ stepDataById: Record<number, StepData>;
157
+ created: number;
158
+ updated: number;
159
+ createdBy: string;
160
+ };
161
+ export type StepData = {
162
+ id: number;
163
+ processId: number;
164
+ ref: string;
165
+ parentId: number | null;
166
+ parentRef: string | null;
167
+ namespace: string;
168
+ name: string;
169
+ type: StepType;
170
+ stepDefinitionHistoryId: number | null;
171
+ status: StepStatus;
172
+ input: Record<string, unknown>;
173
+ output: Record<string, unknown>;
174
+ workerId: string;
175
+ start: number;
176
+ schedule: number;
177
+ priority: number;
178
+ updated: number;
179
+ optional: boolean;
180
+ executionList: StepExecutionData[];
181
+ };
182
+ export type StepExecutionData = {
183
+ id: number;
184
+ scheduled: number;
185
+ polled: number;
186
+ start: number;
187
+ updated: number;
188
+ executor: string;
189
+ ref: string;
190
+ runs: number;
191
+ output: Record<string, unknown>;
192
+ };
193
+ export type StepId = {
194
+ id: number;
195
+ processId: number;
196
+ ref: string;
197
+ };
198
+ export type ProcessRequestData = {
199
+ name: string;
200
+ namespace: string;
201
+ version: number | null;
202
+ requestId: string;
203
+ correlationId: string;
204
+ input: Record<string, unknown>;
205
+ };
206
+ export type ProcessSearchRequest = {
207
+ startTimeEpoch: number;
208
+ endTimeEpoch?: number | null;
209
+ namespace: string;
210
+ processTypes: ProcessType[];
211
+ triggerTypes: ProcessTriggerType[];
212
+ names: string[];
213
+ processIds: number[];
214
+ correlationIds: string[];
215
+ requestIds: string[];
216
+ statuses: ProcessStatus[];
217
+ limit: number;
218
+ offset: number;
219
+ };
220
+ export type StepSize = {
221
+ stepQueueNameData: StepQueueNameData;
222
+ size: number | null;
223
+ };
224
+ export type ClientSubmitResult = {
225
+ processId: number;
226
+ stepId: number;
227
+ errorMessage: string | null;
228
+ httpStatusCode: number | null;
229
+ };
230
+ export type WorkRequest = {
231
+ processId: number;
232
+ stepId: number;
233
+ stepExecutionId: number;
234
+ runCount: number;
235
+ stepName: string;
236
+ stepNamespace: string;
237
+ stepRef: string;
238
+ inputParam: Record<string, unknown>;
239
+ isOptional: boolean;
240
+ polled: number;
241
+ scheduled: number;
242
+ updated: number;
243
+ priority: number;
244
+ };
245
+ export type WorkResponse = {
246
+ processId: number;
247
+ stepId: number;
248
+ stepExecutionId: number;
249
+ runCount: number;
250
+ output: Record<string, unknown>;
251
+ status: StepStatus;
252
+ rescheduleAfterSeconds: number | null;
253
+ startedAt: number;
254
+ };
255
+ export type WorkResult = {
256
+ output: unknown;
257
+ taskExecutionId: string;
258
+ startTime: number;
259
+ endTime: number;
260
+ workRequest: WorkRequest;
261
+ };
262
+ export interface ApiClientConfig {
263
+ baseUrl: string;
264
+ clientId: string;
265
+ authToken: string;
266
+ port?: string | number;
267
+ timeout?: number;
268
+ }
269
+ export interface ApiResponse<T = any> {
270
+ data: T;
271
+ status: number;
272
+ headers: Record<string, string>;
273
+ }
274
+ export interface ApiError extends Error {
275
+ status?: number;
276
+ response?: {
277
+ data?: any;
278
+ status: number;
279
+ headers: Record<string, string>;
280
+ };
281
+ }
282
+ export interface QueryParams {
283
+ [key: string]: string | number | boolean | undefined;
284
+ }
285
+ export interface RequestConfig extends Omit<AxiosRequestConfig, "baseURL" | "url" | "method"> {
286
+ headers?: Record<string, string>;
287
+ }
288
+ export interface HandleRequestConfig {
289
+ method: "get" | "post" | "put" | "delete";
290
+ endpoint: string;
291
+ params?: QueryParams;
292
+ data?: Record<string, unknown>;
293
+ config?: RequestConfig;
294
+ }
295
+ export interface ClientRequestConfig {
296
+ params?: QueryParams;
297
+ data?: any;
298
+ config?: RequestConfig;
299
+ }
300
+ interface UnmeshedWorker {
301
+ (input: Record<string, any>): Promise<any>;
302
+ }
303
+ export interface UnmeshedWorkerConfig {
304
+ worker: UnmeshedWorker;
305
+ namespace: string;
306
+ name: string;
307
+ maxInProgress: number;
308
+ }
309
+ export interface PollRequestData {
310
+ stepQueueNameData: StepQueueNameData;
311
+ size: number;
312
+ }
313
+ export {};
package/types/index.js ADDED
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProcessType = exports.ProcessTriggerType = exports.ProcessStatus = exports.StepStatus = exports.StepType = exports.SQAuthUserType = exports.WebhookSource = exports.ApiCallType = void 0;
4
+ var ApiCallType;
5
+ (function (ApiCallType) {
6
+ ApiCallType["SYNC"] = "SYNC";
7
+ ApiCallType["ASYNC"] = "ASYNC";
8
+ ApiCallType["STREAM"] = "STREAM";
9
+ })(ApiCallType || (exports.ApiCallType = ApiCallType = {}));
10
+ var WebhookSource;
11
+ (function (WebhookSource) {
12
+ WebhookSource["MS_TEAMS"] = "MS_TEAMS";
13
+ WebhookSource["NOT_DEFINED"] = "NOT_DEFINED";
14
+ })(WebhookSource || (exports.WebhookSource = WebhookSource = {}));
15
+ var SQAuthUserType;
16
+ (function (SQAuthUserType) {
17
+ SQAuthUserType["USER"] = "USER";
18
+ SQAuthUserType["API"] = "API";
19
+ SQAuthUserType["INTERNAL"] = "INTERNAL";
20
+ })(SQAuthUserType || (exports.SQAuthUserType = SQAuthUserType = {}));
21
+ var StepType;
22
+ (function (StepType) {
23
+ StepType["WORKER"] = "WORKER";
24
+ StepType["HTTP"] = "HTTP";
25
+ StepType["WAIT"] = "WAIT";
26
+ StepType["FAIL"] = "FAIL";
27
+ StepType["PYTHON"] = "PYTHON";
28
+ StepType["JAVASCRIPT"] = "JAVASCRIPT";
29
+ StepType["JQ"] = "JQ";
30
+ StepType["MANAGED"] = "MANAGED";
31
+ StepType["BUILTIN"] = "BUILTIN";
32
+ StepType["NOOP"] = "NOOP";
33
+ StepType["PERSISTED_STATE"] = "PERSISTED_STATE";
34
+ StepType["DEPENDSON"] = "DEPENDSON";
35
+ StepType["INTEGRATION"] = "INTEGRATION";
36
+ StepType["EXIT"] = "EXIT";
37
+ StepType["SUB_PROCESS"] = "SUB_PROCESS";
38
+ StepType["LIST"] = "LIST";
39
+ StepType["PARALLEL"] = "PARALLEL";
40
+ StepType["FOREACH"] = "FOREACH";
41
+ StepType["SWITCH"] = "SWITCH";
42
+ })(StepType || (exports.StepType = StepType = {}));
43
+ var StepStatus;
44
+ (function (StepStatus) {
45
+ StepStatus["PENDING"] = "PENDING";
46
+ StepStatus["SCHEDULED"] = "SCHEDULED";
47
+ StepStatus["RUNNING"] = "RUNNING";
48
+ StepStatus["PAUSED"] = "PAUSED";
49
+ StepStatus["COMPLETED"] = "COMPLETED";
50
+ StepStatus["FAILED"] = "FAILED";
51
+ StepStatus["TIMED_OUT"] = "TIMED_OUT";
52
+ StepStatus["SKIPPED"] = "SKIPPED";
53
+ StepStatus["CANCELLED"] = "CANCELLED";
54
+ })(StepStatus || (exports.StepStatus = StepStatus = {}));
55
+ var ProcessStatus;
56
+ (function (ProcessStatus) {
57
+ ProcessStatus["RUNNING"] = "RUNNING";
58
+ ProcessStatus["COMPLETED"] = "COMPLETED";
59
+ ProcessStatus["FAILED"] = "FAILED";
60
+ ProcessStatus["TIMED_OUT"] = "TIMED_OUT";
61
+ ProcessStatus["CANCELLED"] = "CANCELLED";
62
+ ProcessStatus["TERMINATED"] = "TERMINATED";
63
+ ProcessStatus["REVIEWED"] = "REVIEWED";
64
+ })(ProcessStatus || (exports.ProcessStatus = ProcessStatus = {}));
65
+ var ProcessTriggerType;
66
+ (function (ProcessTriggerType) {
67
+ ProcessTriggerType["MANUAL"] = "MANUAL";
68
+ ProcessTriggerType["SCHEDULED"] = "SCHEDULED";
69
+ ProcessTriggerType["API_MAPPING"] = "API_MAPPING";
70
+ ProcessTriggerType["WEBHOOK"] = "WEBHOOK";
71
+ ProcessTriggerType["API"] = "API";
72
+ ProcessTriggerType["SUB_PROCESS"] = "SUB_PROCESS";
73
+ })(ProcessTriggerType || (exports.ProcessTriggerType = ProcessTriggerType = {}));
74
+ var ProcessType;
75
+ (function (ProcessType) {
76
+ ProcessType["STANDARD"] = "STANDARD";
77
+ ProcessType["DYNAMIC"] = "DYNAMIC";
78
+ ProcessType["API_ORCHESTRATION"] = "API_ORCHESTRATION";
79
+ ProcessType["INTERNAL"] = "INTERNAL";
80
+ })(ProcessType || (exports.ProcessType = ProcessType = {}));
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAEA,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,gCAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAgCD,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,4CAA2B,CAAA;AAC7B,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,+BAAa,CAAA;IACb,6BAAW,CAAA;IACX,uCAAqB,CAAA;AACvB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAED,IAAY,QAoBX;AApBD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,6BAAiB,CAAA;IACjB,qCAAyB,CAAA;IACzB,qBAAS,CAAA;IACT,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,yBAAa,CAAA;IACb,+CAAmC,CAAA;IACnC,mCAAuB,CAAA;IACvB,uCAA2B,CAAA;IAC3B,yBAAa,CAAA;IACb,uCAA2B,CAAA;IAC3B,yBAAa,CAAA;IACb,iCAAqB,CAAA;IACrB,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;AACnB,CAAC,EApBW,QAAQ,wBAAR,QAAQ,QAoBnB;AAED,IAAY,UAUX;AAVD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,qCAAuB,CAAA;IACvB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,qCAAuB,CAAA;IACvB,+BAAiB,CAAA;IACjB,qCAAuB,CAAA;IACvB,iCAAmB,CAAA;IACnB,qCAAuB,CAAA;AACzB,CAAC,EAVW,UAAU,0BAAV,UAAU,QAUrB;AAED,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,kCAAiB,CAAA;IACjB,wCAAuB,CAAA;IACvB,wCAAuB,CAAA;IACvB,0CAAyB,CAAA;IACzB,sCAAqB,CAAA;AACvB,CAAC,EARW,aAAa,6BAAb,aAAa,QAQxB;AAED,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,6CAAuB,CAAA;IACvB,iDAA2B,CAAA;IAC3B,yCAAmB,CAAA;IACnB,iCAAW,CAAA;IACX,iDAA2B,CAAA;AAC7B,CAAC,EAPW,kBAAkB,kCAAlB,kBAAkB,QAO7B;AAED,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,kCAAmB,CAAA;IACnB,sDAAuC,CAAA;IACvC,oCAAqB,CAAA;AACvB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB"}
@@ -0,0 +1,3 @@
1
+ export declare class UnmeshedCommonUtils {
2
+ static createSecureHash(input: string): string;
3
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnmeshedCommonUtils = void 0;
4
+ const crypto_1 = require("crypto");
5
+ class UnmeshedCommonUtils {
6
+ static createSecureHash(input) {
7
+ try {
8
+ const hash = (0, crypto_1.createHash)("sha256");
9
+ hash.update(input, "utf8");
10
+ return hash.digest("hex");
11
+ }
12
+ catch (e) {
13
+ throw new Error("Error creating hash");
14
+ }
15
+ }
16
+ }
17
+ exports.UnmeshedCommonUtils = UnmeshedCommonUtils;
18
+ //# sourceMappingURL=unmeshedCommonUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unmeshedCommonUtils.js","sourceRoot":"","sources":["../../src/utils/unmeshedCommonUtils.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,MAAa,mBAAmB;IAC9B,MAAM,CAAC,gBAAgB,CAAC,KAAa;QACnC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF;AAVD,kDAUC"}
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
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>
@@ -1,12 +0,0 @@
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 DELETED
@@ -1,6 +0,0 @@
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 DELETED
@@ -1,25 +0,0 @@
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/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
- }