@arkyn/server 3.0.1-beta.61 → 3.0.1-beta.63
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.
- package/dist/api/arkynLogRequest.d.ts.map +1 -1
- package/dist/api/arkynLogRequest.js +8 -3
- package/dist/api/makeRequest.d.ts.map +1 -1
- package/dist/api/makeRequest.js +6 -2
- package/dist/bundle.js +484 -393
- package/dist/bundle.umd.cjs +14 -8
- package/dist/http/badResponses/_badResponse.d.ts +22 -0
- package/dist/http/badResponses/_badResponse.d.ts.map +1 -0
- package/dist/http/badResponses/_badResponse.js +33 -0
- package/dist/http/badResponses/badGateway.d.ts +2 -1
- package/dist/http/badResponses/badGateway.d.ts.map +1 -1
- package/dist/http/badResponses/badGateway.js +4 -3
- package/dist/http/badResponses/badRequest.d.ts +2 -1
- package/dist/http/badResponses/badRequest.d.ts.map +1 -1
- package/dist/http/badResponses/badRequest.js +4 -3
- package/dist/http/badResponses/conflict.d.ts +2 -1
- package/dist/http/badResponses/conflict.d.ts.map +1 -1
- package/dist/http/badResponses/conflict.js +4 -3
- package/dist/http/badResponses/forbidden.d.ts +2 -1
- package/dist/http/badResponses/forbidden.d.ts.map +1 -1
- package/dist/http/badResponses/forbidden.js +4 -3
- package/dist/http/badResponses/notFound.d.ts +2 -1
- package/dist/http/badResponses/notFound.d.ts.map +1 -1
- package/dist/http/badResponses/notFound.js +4 -3
- package/dist/http/badResponses/notImplemented.d.ts +2 -1
- package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
- package/dist/http/badResponses/notImplemented.js +4 -3
- package/dist/http/badResponses/serverError.d.ts +2 -1
- package/dist/http/badResponses/serverError.d.ts.map +1 -1
- package/dist/http/badResponses/serverError.js +4 -3
- package/dist/http/badResponses/unauthorized.d.ts +2 -1
- package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
- package/dist/http/badResponses/unauthorized.js +4 -3
- package/dist/http/badResponses/unprocessableEntity.d.ts +3 -2
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
- package/dist/http/badResponses/unprocessableEntity.js +5 -4
- package/dist/http/successResponses/_successResponse.d.ts +22 -0
- package/dist/http/successResponses/_successResponse.d.ts.map +1 -0
- package/dist/http/successResponses/_successResponse.js +37 -0
- package/dist/http/successResponses/created.d.ts +2 -1
- package/dist/http/successResponses/created.d.ts.map +1 -1
- package/dist/http/successResponses/created.js +4 -1
- package/dist/http/successResponses/found.d.ts +2 -1
- package/dist/http/successResponses/found.d.ts.map +1 -1
- package/dist/http/successResponses/found.js +4 -1
- package/dist/http/successResponses/noContent.d.ts +2 -1
- package/dist/http/successResponses/noContent.d.ts.map +1 -1
- package/dist/http/successResponses/noContent.js +4 -1
- package/dist/http/successResponses/success.d.ts +2 -1
- package/dist/http/successResponses/success.d.ts.map +1 -1
- package/dist/http/successResponses/success.js +4 -1
- package/dist/http/successResponses/updated.d.ts +2 -1
- package/dist/http/successResponses/updated.d.ts.map +1 -1
- package/dist/http/successResponses/updated.js +4 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/services/apiService.d.ts.map +1 -1
- package/dist/services/apiService.js +8 -8
- package/dist/services/debugService.d.ts +54 -0
- package/dist/services/debugService.d.ts.map +1 -0
- package/dist/services/debugService.js +57 -0
- package/dist/services/flushDebugLogs.d.ts +8 -0
- package/dist/services/flushDebugLogs.d.ts.map +1 -0
- package/dist/services/flushDebugLogs.js +21 -0
- package/dist/services/formParse.d.ts.map +1 -1
- package/dist/services/formParse.js +0 -1
- package/dist/services/getCaller.d.ts.map +1 -1
- package/dist/services/getCaller.js +4 -4
- package/dist/services/schemaValidator.d.ts.map +1 -1
- package/dist/services/schemaValidator.js +1 -3
- package/package.json +1 -1
- package/dist/services/httpDebug.d.ts +0 -74
- package/dist/services/httpDebug.d.ts.map +0 -1
- package/dist/services/httpDebug.js +0 -93
package/dist/bundle.js
CHANGED
|
@@ -1,40 +1,24 @@
|
|
|
1
1
|
var U = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
i = y[1], c = y[2];
|
|
19
|
-
else {
|
|
20
|
-
const u = h.match(/at\s+(.+)/);
|
|
21
|
-
if (u) {
|
|
22
|
-
c = u[1];
|
|
23
|
-
const f = c.match(/at\s+([^(\s]+)\s+/);
|
|
24
|
-
f && f[1] !== "new" && (i = f[1]);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
c.includes("(") && (c = c.substring(
|
|
28
|
-
c.indexOf("(") + 1,
|
|
29
|
-
c.lastIndexOf(")")
|
|
30
|
-
)), c = c.split(":").slice(0, -2).join(":");
|
|
31
|
-
try {
|
|
32
|
-
c = I.relative(t, c);
|
|
33
|
-
} catch {
|
|
2
|
+
var I = (n, t, s) => t in n ? U(n, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[t] = s;
|
|
3
|
+
var r = (n, t, s) => I(n, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
function f(n) {
|
|
5
|
+
var s;
|
|
6
|
+
if (process.env.NODE_ENV === "development" || ((s = process.env) == null ? void 0 : s.SHOW_ERRORS_IN_CONSOLE) === "true") {
|
|
7
|
+
const u = `${{
|
|
8
|
+
yellow: "\x1B[33m",
|
|
9
|
+
cyan: "\x1B[36m",
|
|
10
|
+
red: "\x1B[31m",
|
|
11
|
+
green: "\x1B[32m"
|
|
12
|
+
}[n.scheme]}[${n.name}]\x1B[0m`;
|
|
13
|
+
let c = "<------------------->";
|
|
14
|
+
n.debugs.forEach((h) => {
|
|
15
|
+
c += `${u} ${h}
|
|
16
|
+
`;
|
|
17
|
+
}), c += "<------------------->", console.log(c);
|
|
34
18
|
}
|
|
35
|
-
return { functionName: i, callerInfo: c };
|
|
36
19
|
}
|
|
37
|
-
|
|
20
|
+
const k = {};
|
|
21
|
+
class S {
|
|
38
22
|
/**
|
|
39
23
|
* Sets the file name to be ignored during stack trace analysis.
|
|
40
24
|
*
|
|
@@ -47,32 +31,92 @@ class R {
|
|
|
47
31
|
* @example
|
|
48
32
|
* ```typescript
|
|
49
33
|
* // Ignore the HTTP adapter file so debug shows the actual business logic caller
|
|
50
|
-
*
|
|
34
|
+
* DebugService.setIgnoreFile("httpAdapter.ts");
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
static setIgnoreFile(t) {
|
|
38
|
+
this.ignoreFiles.push(t);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Clears all configured ignore files.
|
|
42
|
+
*
|
|
43
|
+
* This method resets the ignore file configuration, allowing all files to be
|
|
44
|
+
* considered in stack trace analysis again.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Clear all ignore file configurations
|
|
49
|
+
* DebugService.clearIgnoreFiles();
|
|
51
50
|
* ```
|
|
52
51
|
*/
|
|
53
|
-
static
|
|
54
|
-
this.
|
|
52
|
+
static clearIgnoreFiles() {
|
|
53
|
+
this.ignoreFiles = [];
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
57
|
* The name of the file to ignore when analyzing the stack trace.
|
|
59
58
|
* When set, the `getCaller` function will skip stack frames containing this file name.
|
|
60
59
|
*/
|
|
61
|
-
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
r(S, "ignoreFiles", []);
|
|
61
|
+
function R() {
|
|
62
|
+
const n = process.cwd(), e = (new Error().stack || "").split(`
|
|
63
|
+
`).map((a) => a.trim()), o = S.ignoreFiles;
|
|
64
|
+
let u = 2;
|
|
65
|
+
for (; u < e.length && (e[u].includes("node:internal") || e[u].includes("/node_modules/")); )
|
|
66
|
+
u++;
|
|
67
|
+
if (o.length > 0)
|
|
68
|
+
for (; u < e.length && o.some(
|
|
69
|
+
(a) => e[u].includes(a)
|
|
70
|
+
); )
|
|
71
|
+
u++;
|
|
72
|
+
const c = e[u] || "";
|
|
73
|
+
let h = "Unknown function", i = "Unknown caller";
|
|
74
|
+
const l = c.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
|
|
75
|
+
if (l)
|
|
76
|
+
h = l[1], i = l[2];
|
|
77
|
+
else {
|
|
78
|
+
const a = c.match(/at\s+(.+)/);
|
|
79
|
+
if (a) {
|
|
80
|
+
i = a[1];
|
|
81
|
+
const p = i.match(/at\s+([^(\s]+)\s+/);
|
|
82
|
+
p && p[1] !== "new" && (h = p[1]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
i.includes("(") && (i = i.substring(
|
|
86
|
+
i.indexOf("(") + 1,
|
|
87
|
+
i.lastIndexOf(")")
|
|
88
|
+
)), i = i.split(":").slice(0, -2).join(":");
|
|
89
|
+
try {
|
|
90
|
+
i = k.relative(n, i);
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
return { functionName: h, callerInfo: i };
|
|
94
|
+
}
|
|
95
|
+
class d {
|
|
96
|
+
/**
|
|
97
|
+
* Logs debug information for bad responses including caller context and response details.
|
|
98
|
+
*
|
|
99
|
+
* @param name - The name/type of the bad response being logged
|
|
100
|
+
* @param body - The response body or error data to be logged
|
|
101
|
+
* @param cause - Optional additional cause information for the error
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const badResponse = new BadResponse();
|
|
106
|
+
* badResponse.onDebug("ValidationError", { field: "email", message: "Invalid format" });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
onDebug(t, s, e) {
|
|
110
|
+
const o = [], { callerInfo: u, functionName: c } = R();
|
|
111
|
+
o.push(`${t} initialized
|
|
112
|
+
`), o.push(`Caller Function: ${c}
|
|
113
|
+
`), o.push(`Caller Location: ${u}
|
|
114
|
+
`), o.push(`Body: ${JSON.stringify(s, null, 2)}
|
|
115
|
+
`), e && o.push(`Cause: ${JSON.stringify(e, null, 2)}
|
|
116
|
+
`), f({ scheme: "red", name: "ARKYN-BAD-RESPONSE-DEBUG", debugs: o });
|
|
73
117
|
}
|
|
74
118
|
}
|
|
75
|
-
class j {
|
|
119
|
+
class j extends d {
|
|
76
120
|
/**
|
|
77
121
|
* Creates an instance of the `BadGateway` class.
|
|
78
122
|
*
|
|
@@ -80,11 +124,12 @@ class j {
|
|
|
80
124
|
* @param cause - Optional additional information about the cause of the error.
|
|
81
125
|
*/
|
|
82
126
|
constructor(s, e) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this
|
|
127
|
+
super();
|
|
128
|
+
r(this, "body");
|
|
129
|
+
r(this, "cause");
|
|
130
|
+
r(this, "status", 502);
|
|
131
|
+
r(this, "statusText");
|
|
132
|
+
this.body = { name: "BadGateway", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("BadGateway", this.body, this.cause);
|
|
88
133
|
}
|
|
89
134
|
/**
|
|
90
135
|
* Converts the `BadGateway` instance into a `Response` object with a JSON body.
|
|
@@ -114,7 +159,7 @@ class j {
|
|
|
114
159
|
return Response.json(this.body, s);
|
|
115
160
|
}
|
|
116
161
|
}
|
|
117
|
-
class
|
|
162
|
+
class g extends d {
|
|
118
163
|
/**
|
|
119
164
|
* Creates an instance of the `BadRequest` class.
|
|
120
165
|
*
|
|
@@ -122,11 +167,12 @@ class T {
|
|
|
122
167
|
* @param cause - Optional additional information about the cause of the error.
|
|
123
168
|
*/
|
|
124
169
|
constructor(s, e) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this
|
|
170
|
+
super();
|
|
171
|
+
r(this, "body");
|
|
172
|
+
r(this, "cause");
|
|
173
|
+
r(this, "status", 400);
|
|
174
|
+
r(this, "statusText");
|
|
175
|
+
this.body = { name: "BadRequest", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("BadRequest", this.body, this.cause);
|
|
130
176
|
}
|
|
131
177
|
/**
|
|
132
178
|
* Converts the `BadRequest` instance into a `Response` object with a JSON body.
|
|
@@ -156,7 +202,7 @@ class T {
|
|
|
156
202
|
return Response.json(this.body, s);
|
|
157
203
|
}
|
|
158
204
|
}
|
|
159
|
-
class
|
|
205
|
+
class J extends d {
|
|
160
206
|
/**
|
|
161
207
|
* Creates an instance of the `Conflict` class.
|
|
162
208
|
*
|
|
@@ -164,11 +210,12 @@ class O {
|
|
|
164
210
|
* @param cause - Optional additional information about the cause of the conflict.
|
|
165
211
|
*/
|
|
166
212
|
constructor(s, e) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this
|
|
213
|
+
super();
|
|
214
|
+
r(this, "body");
|
|
215
|
+
r(this, "cause");
|
|
216
|
+
r(this, "status", 409);
|
|
217
|
+
r(this, "statusText");
|
|
218
|
+
this.body = { name: "Conflict", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("Conflict", this.body, this.cause);
|
|
172
219
|
}
|
|
173
220
|
/**
|
|
174
221
|
* Converts the `Conflict` instance into a `Response` object with a JSON body.
|
|
@@ -198,7 +245,7 @@ class O {
|
|
|
198
245
|
return Response.json(this.body, s);
|
|
199
246
|
}
|
|
200
247
|
}
|
|
201
|
-
class
|
|
248
|
+
class D extends d {
|
|
202
249
|
/**
|
|
203
250
|
* Creates an instance of the `Forbidden` class.
|
|
204
251
|
*
|
|
@@ -206,11 +253,12 @@ class E {
|
|
|
206
253
|
* @param cause - Optional additional information about the cause of the error.
|
|
207
254
|
*/
|
|
208
255
|
constructor(s, e) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
this
|
|
256
|
+
super();
|
|
257
|
+
r(this, "body");
|
|
258
|
+
r(this, "cause");
|
|
259
|
+
r(this, "status", 403);
|
|
260
|
+
r(this, "statusText");
|
|
261
|
+
this.body = { name: "Forbidden", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("Forbidden", this.body, this.cause);
|
|
214
262
|
}
|
|
215
263
|
/**
|
|
216
264
|
* Converts the `Forbidden` instance into a `Response` object with a JSON body.
|
|
@@ -240,7 +288,7 @@ class E {
|
|
|
240
288
|
return Response.json(this.body, s);
|
|
241
289
|
}
|
|
242
290
|
}
|
|
243
|
-
class
|
|
291
|
+
class C extends d {
|
|
244
292
|
/**
|
|
245
293
|
* Creates an instance of the `NotFound` class.
|
|
246
294
|
*
|
|
@@ -248,11 +296,12 @@ class J {
|
|
|
248
296
|
* @param cause - Optional additional information about the cause of the error.
|
|
249
297
|
*/
|
|
250
298
|
constructor(s, e) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
this
|
|
299
|
+
super();
|
|
300
|
+
r(this, "body");
|
|
301
|
+
r(this, "cause");
|
|
302
|
+
r(this, "status", 404);
|
|
303
|
+
r(this, "statusText");
|
|
304
|
+
this.body = { name: "NotFound", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("NotFound", this.body, this.cause);
|
|
256
305
|
}
|
|
257
306
|
/**
|
|
258
307
|
* Converts the `NotFound` instance into a `Response` object with a JSON body.
|
|
@@ -282,7 +331,7 @@ class J {
|
|
|
282
331
|
return Response.json(this.body, s);
|
|
283
332
|
}
|
|
284
333
|
}
|
|
285
|
-
class
|
|
334
|
+
class B extends d {
|
|
286
335
|
/**
|
|
287
336
|
* Creates an instance of the `NotImplemented` class.
|
|
288
337
|
*
|
|
@@ -290,11 +339,12 @@ class C {
|
|
|
290
339
|
* @param cause - Optional additional information about the cause of the error.
|
|
291
340
|
*/
|
|
292
341
|
constructor(s, e) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
this
|
|
342
|
+
super();
|
|
343
|
+
r(this, "body");
|
|
344
|
+
r(this, "cause");
|
|
345
|
+
r(this, "status", 501);
|
|
346
|
+
r(this, "statusText");
|
|
347
|
+
this.body = { name: "NotImplemented", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("NotImplemented", this.body, this.cause);
|
|
298
348
|
}
|
|
299
349
|
/**
|
|
300
350
|
* Converts the `NotImplemented` instance into a `Response` object with a JSON body.
|
|
@@ -324,7 +374,7 @@ class C {
|
|
|
324
374
|
return Response.json(this.body, s);
|
|
325
375
|
}
|
|
326
376
|
}
|
|
327
|
-
class
|
|
377
|
+
class x extends d {
|
|
328
378
|
/**
|
|
329
379
|
* Creates an instance of the `ServerError` class.
|
|
330
380
|
*
|
|
@@ -332,11 +382,12 @@ class b {
|
|
|
332
382
|
* @param cause - Optional additional information about the cause of the error.
|
|
333
383
|
*/
|
|
334
384
|
constructor(s, e) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
this
|
|
385
|
+
super();
|
|
386
|
+
r(this, "body");
|
|
387
|
+
r(this, "cause");
|
|
388
|
+
r(this, "status", 500);
|
|
389
|
+
r(this, "statusText");
|
|
390
|
+
this.body = { name: "ServerError", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("ServerError", this.body, this.cause);
|
|
340
391
|
}
|
|
341
392
|
/**
|
|
342
393
|
* Converts the `ServerError` instance into a `Response` object with a JSON body.
|
|
@@ -366,7 +417,7 @@ class b {
|
|
|
366
417
|
return Response.json(this.body, s);
|
|
367
418
|
}
|
|
368
419
|
}
|
|
369
|
-
class q {
|
|
420
|
+
class q extends d {
|
|
370
421
|
/**
|
|
371
422
|
* Creates an instance of the `Unauthorized` class.
|
|
372
423
|
*
|
|
@@ -374,11 +425,12 @@ class q {
|
|
|
374
425
|
* @param cause - Optional additional information about the cause of the error.
|
|
375
426
|
*/
|
|
376
427
|
constructor(s, e) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
this
|
|
428
|
+
super();
|
|
429
|
+
r(this, "body");
|
|
430
|
+
r(this, "cause");
|
|
431
|
+
r(this, "status", 401);
|
|
432
|
+
r(this, "statusText");
|
|
433
|
+
this.body = { name: "Unauthorized", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("Unauthorized", this.body, this.cause);
|
|
382
434
|
}
|
|
383
435
|
/**
|
|
384
436
|
* Converts the `Unauthorized` instance into a `Response` object with a JSON body.
|
|
@@ -408,7 +460,7 @@ class q {
|
|
|
408
460
|
return Response.json(this.body, s);
|
|
409
461
|
}
|
|
410
462
|
}
|
|
411
|
-
class
|
|
463
|
+
class N extends d {
|
|
412
464
|
/**
|
|
413
465
|
* Creates an instance of the `UnprocessableEntity` class.
|
|
414
466
|
*
|
|
@@ -419,17 +471,18 @@ class m {
|
|
|
419
471
|
* - `message`: A descriptive message explaining the error.
|
|
420
472
|
* @param enableDebug - A boolean indicating whether to enable debug logging for this error.
|
|
421
473
|
*/
|
|
422
|
-
constructor(s
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
474
|
+
constructor(s) {
|
|
475
|
+
super();
|
|
476
|
+
r(this, "body");
|
|
477
|
+
r(this, "status", 422);
|
|
478
|
+
r(this, "statusText");
|
|
426
479
|
this.statusText = s.message || "Unprocessable Entity", this.body = {
|
|
427
480
|
name: "UnprocessableEntity",
|
|
428
481
|
message: s.message || null,
|
|
429
482
|
data: s.data,
|
|
430
483
|
fieldErrors: s.fieldErrors,
|
|
431
484
|
fields: s.fields
|
|
432
|
-
},
|
|
485
|
+
}, this.onDebug("UnprocessableEntity", this.body, this.body);
|
|
433
486
|
}
|
|
434
487
|
/**
|
|
435
488
|
* Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
|
|
@@ -459,7 +512,35 @@ class m {
|
|
|
459
512
|
return Response.json(this.body, s);
|
|
460
513
|
}
|
|
461
514
|
}
|
|
462
|
-
class
|
|
515
|
+
class T {
|
|
516
|
+
/**
|
|
517
|
+
* Logs debug information for success responses including caller context and response details.
|
|
518
|
+
*
|
|
519
|
+
* @param name - The name/type of the success response being logged
|
|
520
|
+
* @param body - The response body or success data to be logged
|
|
521
|
+
* @param cause - Optional additional cause information for the error
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```typescript
|
|
525
|
+
* const SuccessResponse = new SuccessResponse();
|
|
526
|
+
* SuccessResponse.onDebug("ValidationError", { field: "email", message: "Invalid format" });
|
|
527
|
+
* ```
|
|
528
|
+
*/
|
|
529
|
+
onDebug(t, s, e) {
|
|
530
|
+
const o = [], { callerInfo: u, functionName: c } = R();
|
|
531
|
+
o.push(`${t} initialized
|
|
532
|
+
`), o.push(`Caller Function: ${c}
|
|
533
|
+
`), o.push(`Caller Location: ${u}
|
|
534
|
+
`), o.push(`Body: ${JSON.stringify(s, null, 2)}
|
|
535
|
+
`), e && o.push(`Cause: ${JSON.stringify(e, null, 2)}
|
|
536
|
+
`), f({
|
|
537
|
+
scheme: "green",
|
|
538
|
+
name: "ARKYN-SUCCESS-RESPONSE-DEBUG",
|
|
539
|
+
debugs: o
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
class P extends T {
|
|
463
544
|
/**
|
|
464
545
|
* Creates an instance of the `Created` class.
|
|
465
546
|
*
|
|
@@ -467,11 +548,12 @@ class B {
|
|
|
467
548
|
* @param init - Optional initialization object for customizing headers, status, and status text.
|
|
468
549
|
*/
|
|
469
550
|
constructor(s, e) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
551
|
+
super();
|
|
552
|
+
r(this, "body");
|
|
553
|
+
r(this, "headers");
|
|
554
|
+
r(this, "status");
|
|
555
|
+
r(this, "statusText");
|
|
556
|
+
this.body = s, this.headers = (e == null ? void 0 : e.headers) || {}, this.status = (e == null ? void 0 : e.status) || 201, this.statusText = (e == null ? void 0 : e.statusText) || "Resource created successfully", this.onDebug("Created", s);
|
|
475
557
|
}
|
|
476
558
|
/**
|
|
477
559
|
* Converts the `Created` instance into a `Response` object with a JSON body.
|
|
@@ -502,7 +584,7 @@ class B {
|
|
|
502
584
|
return Response.json(this.body, s);
|
|
503
585
|
}
|
|
504
586
|
}
|
|
505
|
-
class H {
|
|
587
|
+
class H extends T {
|
|
506
588
|
/**
|
|
507
589
|
* Creates an instance of the `Found` class.
|
|
508
590
|
*
|
|
@@ -513,11 +595,12 @@ class H {
|
|
|
513
595
|
* - `statusText`: HTTP status text (default is "Found").
|
|
514
596
|
*/
|
|
515
597
|
constructor(s, e) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
598
|
+
super();
|
|
599
|
+
r(this, "body");
|
|
600
|
+
r(this, "headers");
|
|
601
|
+
r(this, "status");
|
|
602
|
+
r(this, "statusText");
|
|
603
|
+
this.body = s, this.headers = (e == null ? void 0 : e.headers) || {}, this.status = (e == null ? void 0 : e.status) || 302, this.statusText = (e == null ? void 0 : e.statusText) || "Found", this.onDebug("Found", s);
|
|
521
604
|
}
|
|
522
605
|
/**
|
|
523
606
|
* Converts the `Found` instance into a `Response` object.
|
|
@@ -548,17 +631,18 @@ class H {
|
|
|
548
631
|
return Response.json(this.body, s);
|
|
549
632
|
}
|
|
550
633
|
}
|
|
551
|
-
class
|
|
634
|
+
class L extends T {
|
|
552
635
|
/**
|
|
553
636
|
* Creates an instance of the `NoContent` class.
|
|
554
637
|
*
|
|
555
638
|
* @param init - Optional initialization object for customizing headers, status, and status text.
|
|
556
639
|
*/
|
|
557
640
|
constructor(s) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
641
|
+
super();
|
|
642
|
+
r(this, "headers");
|
|
643
|
+
r(this, "status");
|
|
644
|
+
r(this, "statusText");
|
|
645
|
+
this.headers = (s == null ? void 0 : s.headers) || {}, this.status = (s == null ? void 0 : s.status) || 204, this.statusText = (s == null ? void 0 : s.statusText) ?? "No content", this.onDebug("No content", null);
|
|
562
646
|
}
|
|
563
647
|
/**
|
|
564
648
|
* Converts the `NoContent` instance into a `Response` object.
|
|
@@ -575,7 +659,7 @@ class P {
|
|
|
575
659
|
return new Response(null, s);
|
|
576
660
|
}
|
|
577
661
|
}
|
|
578
|
-
class $ {
|
|
662
|
+
class $ extends T {
|
|
579
663
|
/**
|
|
580
664
|
* Creates an instance of the `Success` class.
|
|
581
665
|
*
|
|
@@ -583,11 +667,12 @@ class $ {
|
|
|
583
667
|
* @param init - Optional initialization object for customizing headers, status, and status text.
|
|
584
668
|
*/
|
|
585
669
|
constructor(s, e) {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
670
|
+
super();
|
|
671
|
+
r(this, "body");
|
|
672
|
+
r(this, "headers");
|
|
673
|
+
r(this, "status");
|
|
674
|
+
r(this, "statusText");
|
|
675
|
+
this.body = s, this.headers = (e == null ? void 0 : e.headers) || {}, this.status = (e == null ? void 0 : e.status) || 200, this.statusText = (e == null ? void 0 : e.statusText) ?? "OK", this.onDebug("Success", s);
|
|
591
676
|
}
|
|
592
677
|
/**
|
|
593
678
|
* Converts the `Success` instance into a `Response` object with a JSON body.
|
|
@@ -618,7 +703,7 @@ class $ {
|
|
|
618
703
|
return Response.json(this.body, s);
|
|
619
704
|
}
|
|
620
705
|
}
|
|
621
|
-
class
|
|
706
|
+
class A extends T {
|
|
622
707
|
/**
|
|
623
708
|
* Creates an instance of the `Updated` class.
|
|
624
709
|
*
|
|
@@ -626,11 +711,12 @@ class L {
|
|
|
626
711
|
* @param init - Optional initialization object for customizing headers, status, and status text.
|
|
627
712
|
*/
|
|
628
713
|
constructor(s, e) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
714
|
+
super();
|
|
715
|
+
r(this, "body");
|
|
716
|
+
r(this, "headers");
|
|
717
|
+
r(this, "status");
|
|
718
|
+
r(this, "statusText");
|
|
719
|
+
this.body = s, this.headers = (e == null ? void 0 : e.headers) || {}, this.status = (e == null ? void 0 : e.status) || 200, this.statusText = (e == null ? void 0 : e.statusText) || "Resource updated successfully", this.onDebug("Updated", s);
|
|
634
720
|
}
|
|
635
721
|
/**
|
|
636
722
|
* Converts the `Updated` instance into a `Response` object with a JSON body.
|
|
@@ -661,28 +747,28 @@ class L {
|
|
|
661
747
|
return Response.json(this.body, s);
|
|
662
748
|
}
|
|
663
749
|
}
|
|
664
|
-
class
|
|
665
|
-
static mapHeaders(
|
|
666
|
-
return
|
|
750
|
+
class v {
|
|
751
|
+
static mapHeaders(t) {
|
|
752
|
+
return t instanceof Headers ? Object.fromEntries(t.entries()) : typeof t == "object" ? Object.entries(t).reduce((s, [e, o]) => (typeof o == "string" ? s[e] = o : Array.isArray(o) ? s[e] = o.join(", ") : s[e] = JSON.stringify(o), s), {}) : {};
|
|
667
753
|
}
|
|
668
|
-
static mapQueryParams(
|
|
669
|
-
const
|
|
670
|
-
return
|
|
671
|
-
|
|
672
|
-
}),
|
|
754
|
+
static mapQueryParams(t) {
|
|
755
|
+
const s = {};
|
|
756
|
+
return t.forEach((e, o) => {
|
|
757
|
+
s[o] = e;
|
|
758
|
+
}), s;
|
|
673
759
|
}
|
|
674
|
-
static handle(
|
|
760
|
+
static handle(t) {
|
|
675
761
|
return {
|
|
676
|
-
rawUrl:
|
|
677
|
-
status:
|
|
678
|
-
method:
|
|
762
|
+
rawUrl: t.url,
|
|
763
|
+
status: t.status,
|
|
764
|
+
method: t.method,
|
|
679
765
|
token: null,
|
|
680
|
-
elapsedTime:
|
|
681
|
-
requestHeaders: this.mapHeaders(
|
|
682
|
-
requestBody:
|
|
683
|
-
queryParams: this.mapQueryParams(
|
|
684
|
-
responseHeaders: this.mapHeaders(
|
|
685
|
-
responseBody:
|
|
766
|
+
elapsedTime: t.elapsedTime,
|
|
767
|
+
requestHeaders: this.mapHeaders(t.requestHeaders),
|
|
768
|
+
requestBody: t.requestBody || null,
|
|
769
|
+
queryParams: this.mapQueryParams(t.queryParams),
|
|
770
|
+
responseHeaders: this.mapHeaders(t.responseHeaders),
|
|
771
|
+
responseBody: t.responseBody || null
|
|
686
772
|
};
|
|
687
773
|
}
|
|
688
774
|
}
|
|
@@ -698,13 +784,13 @@ class w {
|
|
|
698
784
|
* @param arkynConfig.arkynLogBaseApiUrl - (Optional) The API URL for the arkyn. If not provided,
|
|
699
785
|
* a default URL will be used.
|
|
700
786
|
*/
|
|
701
|
-
static setArkynConfig(
|
|
787
|
+
static setArkynConfig(t) {
|
|
702
788
|
if (this.arkynConfig) return;
|
|
703
|
-
let
|
|
704
|
-
|
|
705
|
-
arkynTrafficSourceId:
|
|
706
|
-
arkynUserToken:
|
|
707
|
-
arkynApiUrl:
|
|
789
|
+
let e = t.arkynLogBaseApiUrl || "https://logs-arkyn-flow-logs.vw6wo7.easypanel.host";
|
|
790
|
+
e = e + "/http-traffic-records/:trafficSourceId", this.arkynConfig = {
|
|
791
|
+
arkynTrafficSourceId: t.arkynTrafficSourceId,
|
|
792
|
+
arkynUserToken: t.arkynUserToken,
|
|
793
|
+
arkynApiUrl: e
|
|
708
794
|
};
|
|
709
795
|
}
|
|
710
796
|
/**
|
|
@@ -724,60 +810,65 @@ class w {
|
|
|
724
810
|
this.arkynConfig = void 0;
|
|
725
811
|
}
|
|
726
812
|
}
|
|
727
|
-
|
|
728
|
-
async function
|
|
729
|
-
const
|
|
730
|
-
if (!
|
|
731
|
-
const { arkynUserToken:
|
|
732
|
-
elapsedTime:
|
|
733
|
-
method:
|
|
734
|
-
queryParams:
|
|
735
|
-
requestBody:
|
|
736
|
-
requestHeaders:
|
|
737
|
-
responseBody:
|
|
738
|
-
responseHeaders:
|
|
739
|
-
status:
|
|
740
|
-
token:
|
|
741
|
-
rawUrl:
|
|
742
|
-
} =
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
813
|
+
r(w, "arkynConfig");
|
|
814
|
+
async function F(n) {
|
|
815
|
+
const t = w.getArkynConfig();
|
|
816
|
+
if (!t) return;
|
|
817
|
+
const { arkynUserToken: s, arkynApiUrl: e } = t, {
|
|
818
|
+
elapsedTime: o,
|
|
819
|
+
method: u,
|
|
820
|
+
queryParams: c,
|
|
821
|
+
requestBody: h,
|
|
822
|
+
requestHeaders: i,
|
|
823
|
+
responseBody: l,
|
|
824
|
+
responseHeaders: a,
|
|
825
|
+
status: p,
|
|
826
|
+
token: Q,
|
|
827
|
+
rawUrl: E
|
|
828
|
+
} = n;
|
|
829
|
+
if (process.env.NODE_ENV !== "development")
|
|
830
|
+
try {
|
|
831
|
+
const y = new URL(E);
|
|
832
|
+
let m = "HTTPS";
|
|
833
|
+
y.protocol === "http:" && (m = "HTTP");
|
|
834
|
+
const O = JSON.stringify({
|
|
835
|
+
domainUrl: y.protocol + "//" + y.host,
|
|
836
|
+
pathnameUrl: y.pathname,
|
|
837
|
+
status: p,
|
|
838
|
+
protocol: m,
|
|
839
|
+
method: u,
|
|
840
|
+
trafficUserId: null,
|
|
841
|
+
elapsedTime: o,
|
|
842
|
+
requestHeaders: i,
|
|
843
|
+
requestBody: h,
|
|
844
|
+
queryParams: c,
|
|
845
|
+
responseHeaders: a,
|
|
846
|
+
responseBody: l
|
|
847
|
+
});
|
|
848
|
+
await fetch(
|
|
849
|
+
e.replace(
|
|
850
|
+
":trafficSourceId",
|
|
851
|
+
t.arkynTrafficSourceId
|
|
852
|
+
),
|
|
853
|
+
{
|
|
854
|
+
method: "POST",
|
|
855
|
+
body: O,
|
|
856
|
+
headers: {
|
|
857
|
+
"Content-Type": "application/json",
|
|
858
|
+
Authorization: `Bearer ${s}`
|
|
859
|
+
}
|
|
772
860
|
}
|
|
773
|
-
|
|
774
|
-
)
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
861
|
+
);
|
|
862
|
+
} catch (y) {
|
|
863
|
+
f({
|
|
864
|
+
debugs: [`Error sending request: ${y}`],
|
|
865
|
+
name: "ARKYN_LOG_ERROR",
|
|
866
|
+
scheme: "red"
|
|
867
|
+
});
|
|
868
|
+
}
|
|
778
869
|
}
|
|
779
|
-
async function
|
|
780
|
-
const
|
|
870
|
+
async function b(n, t, s = {}, e) {
|
|
871
|
+
const o = {
|
|
781
872
|
POST: "Resource created successfully",
|
|
782
873
|
PUT: "Resource updated successfully",
|
|
783
874
|
DELETE: "Resource deleted successfully",
|
|
@@ -785,67 +876,71 @@ async function p(t, s, e = {}, n) {
|
|
|
785
876
|
GET: "Request successful"
|
|
786
877
|
};
|
|
787
878
|
try {
|
|
788
|
-
const
|
|
789
|
-
method:
|
|
790
|
-
headers:
|
|
791
|
-
body:
|
|
792
|
-
}),
|
|
793
|
-
let
|
|
879
|
+
const u = performance.now(), c = { ...s, "Content-Type": "application/json" }, h = await fetch(t, {
|
|
880
|
+
method: n,
|
|
881
|
+
headers: c,
|
|
882
|
+
body: e ? JSON.stringify(e) : void 0
|
|
883
|
+
}), i = performance.now() - u, l = h.status;
|
|
884
|
+
let a = null;
|
|
794
885
|
try {
|
|
795
|
-
|
|
886
|
+
a = await h.json();
|
|
796
887
|
} catch {
|
|
797
|
-
|
|
888
|
+
a = null;
|
|
798
889
|
}
|
|
799
|
-
const
|
|
800
|
-
elapsedTime:
|
|
801
|
-
method:
|
|
802
|
-
queryParams: new URL(
|
|
803
|
-
requestHeaders:
|
|
804
|
-
requestBody:
|
|
805
|
-
responseBody:
|
|
806
|
-
responseHeaders:
|
|
807
|
-
status:
|
|
808
|
-
url:
|
|
890
|
+
const p = v.handle({
|
|
891
|
+
elapsedTime: i,
|
|
892
|
+
method: n,
|
|
893
|
+
queryParams: new URL(t).searchParams,
|
|
894
|
+
requestHeaders: c,
|
|
895
|
+
requestBody: e,
|
|
896
|
+
responseBody: a,
|
|
897
|
+
responseHeaders: h.headers,
|
|
898
|
+
status: l,
|
|
899
|
+
url: t
|
|
809
900
|
});
|
|
810
|
-
return
|
|
901
|
+
return F(p), h.ok ? {
|
|
811
902
|
success: !0,
|
|
812
|
-
status:
|
|
813
|
-
message: (
|
|
814
|
-
response:
|
|
903
|
+
status: l,
|
|
904
|
+
message: (a == null ? void 0 : a.message) || o[n],
|
|
905
|
+
response: a,
|
|
815
906
|
cause: null
|
|
816
907
|
} : {
|
|
817
908
|
success: !1,
|
|
818
|
-
status:
|
|
819
|
-
message: (
|
|
820
|
-
response:
|
|
909
|
+
status: l,
|
|
910
|
+
message: (a == null ? void 0 : a.message) || h.statusText || "Request failed",
|
|
911
|
+
response: a,
|
|
821
912
|
cause: null
|
|
822
913
|
};
|
|
823
|
-
} catch (
|
|
824
|
-
return
|
|
914
|
+
} catch (u) {
|
|
915
|
+
return f({
|
|
916
|
+
debugs: [`Network error or request failed: ${u}`],
|
|
917
|
+
name: "ARKYN_MAKE_REQUEST_ERROR",
|
|
918
|
+
scheme: "red"
|
|
919
|
+
}), {
|
|
825
920
|
success: !1,
|
|
826
921
|
status: 0,
|
|
827
922
|
message: "Network error or request failed",
|
|
828
923
|
response: null,
|
|
829
|
-
cause:
|
|
924
|
+
cause: u instanceof Error ? u.message : String(u)
|
|
830
925
|
};
|
|
831
926
|
}
|
|
832
927
|
}
|
|
833
|
-
async function
|
|
834
|
-
return
|
|
928
|
+
async function M(n, t = {}, s) {
|
|
929
|
+
return b("DELETE", n, t, s);
|
|
835
930
|
}
|
|
836
|
-
async function
|
|
837
|
-
return
|
|
931
|
+
async function _(n, t = {}) {
|
|
932
|
+
return b("GET", n, t);
|
|
838
933
|
}
|
|
839
|
-
async function
|
|
840
|
-
return
|
|
934
|
+
async function z(n, t = {}, s) {
|
|
935
|
+
return b("PATCH", n, t, s);
|
|
841
936
|
}
|
|
842
|
-
async function
|
|
843
|
-
return
|
|
937
|
+
async function G(n, t = {}, s) {
|
|
938
|
+
return b("POST", n, t, s);
|
|
844
939
|
}
|
|
845
|
-
async function
|
|
846
|
-
return
|
|
940
|
+
async function K(n, t = {}, s) {
|
|
941
|
+
return b("PUT", n, t, s);
|
|
847
942
|
}
|
|
848
|
-
class
|
|
943
|
+
class X {
|
|
849
944
|
/**
|
|
850
945
|
* Creates an instance of ApiService.
|
|
851
946
|
* @param props - The configuration properties for the API instance.
|
|
@@ -854,26 +949,26 @@ class W {
|
|
|
854
949
|
* @param props.baseToken - Optional base token for authorization.
|
|
855
950
|
* @param props.enableDebug - Optional flag to enable debug logging for requests.
|
|
856
951
|
*/
|
|
857
|
-
constructor(
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
this.baseUrl =
|
|
952
|
+
constructor(t) {
|
|
953
|
+
r(this, "baseUrl");
|
|
954
|
+
r(this, "baseHeaders");
|
|
955
|
+
r(this, "baseToken");
|
|
956
|
+
r(this, "enableDebug");
|
|
957
|
+
this.baseUrl = t.baseUrl, this.baseHeaders = t.baseHeaders || void 0, this.baseToken = t.baseToken || void 0, this.enableDebug = t.enableDebug || !1;
|
|
863
958
|
}
|
|
864
959
|
/**
|
|
865
960
|
* Generates the full URL by appending the route to the base URL.
|
|
866
961
|
* @param route - The route to append to the base URL.
|
|
867
962
|
* @returns The full URL as a string.
|
|
868
963
|
*/
|
|
869
|
-
onDebug(s, e
|
|
964
|
+
onDebug(t, s, e) {
|
|
870
965
|
if (this.enableDebug) {
|
|
871
|
-
const
|
|
872
|
-
|
|
966
|
+
const o = [];
|
|
967
|
+
o.push(`Base URL: ${this.baseUrl}`), o.push(`Full URL: ${t}`), o.push(`Method: ${s}`), e[0] && o.push(`Headers: ${JSON.stringify(e[0])}`), e[1] && o.push(`Body: ${JSON.stringify(e[1])}`), f({ debugs: o, name: "ARKYN-API-DEBUG", scheme: "yellow" });
|
|
873
968
|
}
|
|
874
969
|
}
|
|
875
|
-
generateURL(
|
|
876
|
-
return this.baseUrl +
|
|
970
|
+
generateURL(t) {
|
|
971
|
+
return this.baseUrl + t;
|
|
877
972
|
}
|
|
878
973
|
/**
|
|
879
974
|
* Generates the headers for a request by merging base headers, provided headers, and tokens.
|
|
@@ -881,9 +976,9 @@ class W {
|
|
|
881
976
|
* @param token - Optional token to override the base token.
|
|
882
977
|
* @returns The merged headers as a HeadersInit object.
|
|
883
978
|
*/
|
|
884
|
-
generateHeaders(
|
|
885
|
-
let
|
|
886
|
-
return this.baseToken && (
|
|
979
|
+
generateHeaders(t, s) {
|
|
980
|
+
let e = {};
|
|
981
|
+
return this.baseToken && (e = { Authorization: `Bearer ${this.baseToken}` }), this.baseHeaders && (e = { ...e, ...this.baseHeaders }), t && (e = { ...e, ...t }), s && (e = { ...e, Authorization: `Bearer ${s}` }), e;
|
|
887
982
|
}
|
|
888
983
|
/**
|
|
889
984
|
* Sends a get request to the specified route.
|
|
@@ -891,9 +986,9 @@ class W {
|
|
|
891
986
|
* @param data - The request data, including optional headers and token.
|
|
892
987
|
* @returns The API response data.
|
|
893
988
|
*/
|
|
894
|
-
async get(
|
|
895
|
-
const
|
|
896
|
-
return this.onDebug(
|
|
989
|
+
async get(t, s) {
|
|
990
|
+
const e = this.generateURL(t), o = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token);
|
|
991
|
+
return this.onDebug(e, "get", [o]), await _(e, o);
|
|
897
992
|
}
|
|
898
993
|
/**
|
|
899
994
|
* Sends a post request to the specified route.
|
|
@@ -901,9 +996,9 @@ class W {
|
|
|
901
996
|
* @param data - The request data, including body, optional headers, and token.
|
|
902
997
|
* @returns The API response data.
|
|
903
998
|
*/
|
|
904
|
-
async post(
|
|
905
|
-
const
|
|
906
|
-
return this.onDebug(
|
|
999
|
+
async post(t, s) {
|
|
1000
|
+
const e = this.generateURL(t), o = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), u = s == null ? void 0 : s.body;
|
|
1001
|
+
return this.onDebug(e, "post", [o, u]), await G(e, o, u);
|
|
907
1002
|
}
|
|
908
1003
|
/**
|
|
909
1004
|
* Sends a put request to the specified route.
|
|
@@ -911,9 +1006,9 @@ class W {
|
|
|
911
1006
|
* @param data - The request data, including body, optional headers, and token.
|
|
912
1007
|
* @returns The API response data.
|
|
913
1008
|
*/
|
|
914
|
-
async put(
|
|
915
|
-
const
|
|
916
|
-
return this.onDebug(
|
|
1009
|
+
async put(t, s) {
|
|
1010
|
+
const e = this.generateURL(t), o = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), u = s == null ? void 0 : s.body;
|
|
1011
|
+
return this.onDebug(e, "put", [o, u]), await K(e, o, u);
|
|
917
1012
|
}
|
|
918
1013
|
/**
|
|
919
1014
|
* Sends a patch request to the specified route.
|
|
@@ -921,9 +1016,9 @@ class W {
|
|
|
921
1016
|
* @param data - The request data, including body, optional headers, and token.
|
|
922
1017
|
* @returns The API response data.
|
|
923
1018
|
*/
|
|
924
|
-
async patch(
|
|
925
|
-
const
|
|
926
|
-
return this.onDebug(
|
|
1019
|
+
async patch(t, s) {
|
|
1020
|
+
const e = this.generateURL(t), o = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), u = s == null ? void 0 : s.body;
|
|
1021
|
+
return this.onDebug(e, "patch", [o, u]), await z(e, o, u);
|
|
927
1022
|
}
|
|
928
1023
|
/**
|
|
929
1024
|
* Sends a delete request to the specified route.
|
|
@@ -931,168 +1026,164 @@ class W {
|
|
|
931
1026
|
* @param data - The request data, including body, optional headers, and token.
|
|
932
1027
|
* @returns The API response data.
|
|
933
1028
|
*/
|
|
934
|
-
async delete(
|
|
935
|
-
const
|
|
936
|
-
return this.onDebug(
|
|
1029
|
+
async delete(t, s) {
|
|
1030
|
+
const e = this.generateURL(t), o = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), u = s == null ? void 0 : s.body;
|
|
1031
|
+
return this.onDebug(e, "delete", [o, u]), await M(e, o, u);
|
|
937
1032
|
}
|
|
938
1033
|
}
|
|
939
|
-
function
|
|
940
|
-
var
|
|
941
|
-
return
|
|
1034
|
+
function Z(n, t) {
|
|
1035
|
+
var s, e, o;
|
|
1036
|
+
return n != null && n.message && typeof (n == null ? void 0 : n.message) == "string" ? n == null ? void 0 : n.message : n != null && n.error && typeof (n == null ? void 0 : n.error) == "string" ? n == null ? void 0 : n.error : (s = n == null ? void 0 : n.error) != null && s.message && typeof ((e = n == null ? void 0 : n.error) == null ? void 0 : e.message) == "string" ? (o = n == null ? void 0 : n.error) == null ? void 0 : o.message : t != null && t.statusText && typeof (t == null ? void 0 : t.statusText) == "string" ? t == null ? void 0 : t.statusText : "Missing error message";
|
|
942
1037
|
}
|
|
943
|
-
const
|
|
944
|
-
let
|
|
945
|
-
const
|
|
1038
|
+
const ss = async (n) => {
|
|
1039
|
+
let t;
|
|
1040
|
+
const s = await n.arrayBuffer(), e = new TextDecoder().decode(s);
|
|
946
1041
|
try {
|
|
947
|
-
|
|
1042
|
+
t = JSON.parse(e);
|
|
948
1043
|
} catch {
|
|
949
1044
|
try {
|
|
950
|
-
if (
|
|
951
|
-
const
|
|
952
|
-
|
|
1045
|
+
if (e.includes("=")) {
|
|
1046
|
+
const u = new URLSearchParams(e);
|
|
1047
|
+
t = Object.fromEntries(u.entries());
|
|
953
1048
|
} else
|
|
954
|
-
throw new
|
|
1049
|
+
throw new g("Invalid URLSearchParams format");
|
|
955
1050
|
} catch {
|
|
956
|
-
throw new
|
|
1051
|
+
throw new g("Failed to extract data from request");
|
|
957
1052
|
}
|
|
958
1053
|
}
|
|
959
|
-
return
|
|
1054
|
+
return t;
|
|
960
1055
|
};
|
|
961
|
-
function
|
|
1056
|
+
function es(n) {
|
|
962
1057
|
switch (!0) {
|
|
963
|
-
case
|
|
964
|
-
return
|
|
965
|
-
case
|
|
966
|
-
return
|
|
967
|
-
case
|
|
968
|
-
return
|
|
969
|
-
case
|
|
970
|
-
return
|
|
971
|
-
case
|
|
972
|
-
return
|
|
973
|
-
case
|
|
974
|
-
return
|
|
1058
|
+
case n instanceof Response:
|
|
1059
|
+
return n;
|
|
1060
|
+
case n instanceof H:
|
|
1061
|
+
return n.toResponse();
|
|
1062
|
+
case n instanceof P:
|
|
1063
|
+
return n.toResponse();
|
|
1064
|
+
case n instanceof A:
|
|
1065
|
+
return n.toResponse();
|
|
1066
|
+
case n instanceof $:
|
|
1067
|
+
return n.toResponse();
|
|
1068
|
+
case n instanceof L:
|
|
1069
|
+
return n.toResponse();
|
|
975
1070
|
}
|
|
976
1071
|
switch (!0) {
|
|
977
|
-
case
|
|
978
|
-
return
|
|
979
|
-
case
|
|
980
|
-
return
|
|
981
|
-
case
|
|
982
|
-
return
|
|
983
|
-
case
|
|
984
|
-
return
|
|
985
|
-
case
|
|
986
|
-
return
|
|
987
|
-
case
|
|
988
|
-
return
|
|
989
|
-
case
|
|
990
|
-
return
|
|
991
|
-
case
|
|
992
|
-
return
|
|
993
|
-
case
|
|
994
|
-
return
|
|
995
|
-
}
|
|
996
|
-
return new
|
|
1072
|
+
case n instanceof j:
|
|
1073
|
+
return n.toResponse();
|
|
1074
|
+
case n instanceof g:
|
|
1075
|
+
return n.toResponse();
|
|
1076
|
+
case n instanceof J:
|
|
1077
|
+
return n.toResponse();
|
|
1078
|
+
case n instanceof D:
|
|
1079
|
+
return n.toResponse();
|
|
1080
|
+
case n instanceof C:
|
|
1081
|
+
return n.toResponse();
|
|
1082
|
+
case n instanceof B:
|
|
1083
|
+
return n.toResponse();
|
|
1084
|
+
case n instanceof x:
|
|
1085
|
+
return n.toResponse();
|
|
1086
|
+
case n instanceof q:
|
|
1087
|
+
return n.toResponse();
|
|
1088
|
+
case n instanceof N:
|
|
1089
|
+
return n.toResponse();
|
|
1090
|
+
}
|
|
1091
|
+
return new x("Server error", n).toResponse();
|
|
997
1092
|
}
|
|
998
1093
|
function V([
|
|
999
|
-
|
|
1000
|
-
|
|
1094
|
+
n,
|
|
1095
|
+
t
|
|
1001
1096
|
]) {
|
|
1002
|
-
const
|
|
1003
|
-
if (
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1097
|
+
const s = t.safeParse(n);
|
|
1098
|
+
if (s.success === !1) {
|
|
1099
|
+
const e = Object.fromEntries(
|
|
1100
|
+
s.error.issues.map((o) => [o.path.join("."), o.message])
|
|
1006
1101
|
);
|
|
1007
1102
|
return {
|
|
1008
|
-
success:
|
|
1009
|
-
fieldErrors:
|
|
1010
|
-
fields:
|
|
1103
|
+
success: s.success,
|
|
1104
|
+
fieldErrors: e,
|
|
1105
|
+
fields: n
|
|
1011
1106
|
};
|
|
1012
1107
|
} else
|
|
1013
1108
|
return {
|
|
1014
|
-
success:
|
|
1015
|
-
data:
|
|
1109
|
+
success: s.success,
|
|
1110
|
+
data: s.data
|
|
1016
1111
|
};
|
|
1017
1112
|
}
|
|
1018
|
-
const
|
|
1019
|
-
const
|
|
1020
|
-
if (
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1023
|
-
).filter(([
|
|
1024
|
-
return new URLSearchParams(
|
|
1113
|
+
const ts = (n, t = "") => {
|
|
1114
|
+
const s = new URL(n.url);
|
|
1115
|
+
if (t === "") return s.searchParams;
|
|
1116
|
+
const e = Array.from(
|
|
1117
|
+
s.searchParams.entries()
|
|
1118
|
+
).filter(([o]) => o.startsWith(`${t}:`)).map(([o, u]) => [o.replace(`${t}:`, ""), u]);
|
|
1119
|
+
return new URLSearchParams(e);
|
|
1025
1120
|
};
|
|
1026
|
-
function
|
|
1027
|
-
const
|
|
1028
|
-
({ path:
|
|
1121
|
+
function Y(n) {
|
|
1122
|
+
const t = "Error validating:", s = n.issues.map(
|
|
1123
|
+
({ path: e, message: o }) => `-> ${e.join(".")}: ${o}`
|
|
1029
1124
|
);
|
|
1030
|
-
return [
|
|
1125
|
+
return [t, ...s].join(`
|
|
1031
1126
|
`);
|
|
1032
1127
|
}
|
|
1033
|
-
class
|
|
1034
|
-
constructor(
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
this.schema =
|
|
1038
|
-
const { callerInfo:
|
|
1039
|
-
this.callerInfo =
|
|
1128
|
+
class ns {
|
|
1129
|
+
constructor(t) {
|
|
1130
|
+
r(this, "functionName");
|
|
1131
|
+
r(this, "callerInfo");
|
|
1132
|
+
this.schema = t;
|
|
1133
|
+
const { callerInfo: s, functionName: e } = R();
|
|
1134
|
+
this.callerInfo = s, this.functionName = e;
|
|
1040
1135
|
}
|
|
1041
|
-
isValid(
|
|
1042
|
-
return this.schema.safeParse(
|
|
1136
|
+
isValid(t) {
|
|
1137
|
+
return this.schema.safeParse(t).success;
|
|
1043
1138
|
}
|
|
1044
|
-
safeValidate(
|
|
1045
|
-
return this.schema.safeParse(
|
|
1139
|
+
safeValidate(t) {
|
|
1140
|
+
return this.schema.safeParse(t);
|
|
1046
1141
|
}
|
|
1047
|
-
validate(
|
|
1142
|
+
validate(t) {
|
|
1048
1143
|
try {
|
|
1049
|
-
return this.schema.parse(
|
|
1050
|
-
} catch (
|
|
1051
|
-
throw new
|
|
1144
|
+
return this.schema.parse(t);
|
|
1145
|
+
} catch (s) {
|
|
1146
|
+
throw new x(Y(s));
|
|
1052
1147
|
}
|
|
1053
1148
|
}
|
|
1054
|
-
formValidate(
|
|
1055
|
-
const
|
|
1056
|
-
if (!
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
message: e
|
|
1065
|
-
},
|
|
1066
|
-
!1
|
|
1067
|
-
);
|
|
1149
|
+
formValidate(t, s) {
|
|
1150
|
+
const e = V([t, this.schema]);
|
|
1151
|
+
if (!e.success) {
|
|
1152
|
+
const o = Object.keys(e.fieldErrors)[0];
|
|
1153
|
+
throw new N({
|
|
1154
|
+
fields: e.fields,
|
|
1155
|
+
fieldErrors: e.fieldErrors,
|
|
1156
|
+
data: { scrollTo: o },
|
|
1157
|
+
message: s
|
|
1158
|
+
});
|
|
1068
1159
|
}
|
|
1069
|
-
return
|
|
1160
|
+
return e.data;
|
|
1070
1161
|
}
|
|
1071
1162
|
}
|
|
1072
1163
|
export {
|
|
1073
|
-
|
|
1164
|
+
X as ApiService,
|
|
1074
1165
|
w as ArkynLogService,
|
|
1075
1166
|
j as BadGateway,
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1167
|
+
g as BadRequest,
|
|
1168
|
+
J as Conflict,
|
|
1169
|
+
P as Created,
|
|
1170
|
+
S as DebugService,
|
|
1171
|
+
D as Forbidden,
|
|
1080
1172
|
H as Found,
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
b as ServerError,
|
|
1173
|
+
L as NoContent,
|
|
1174
|
+
C as NotFound,
|
|
1175
|
+
B as NotImplemented,
|
|
1176
|
+
ns as SchemaValidator,
|
|
1177
|
+
x as ServerError,
|
|
1087
1178
|
$ as Success,
|
|
1088
1179
|
q as Unauthorized,
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1180
|
+
N as UnprocessableEntity,
|
|
1181
|
+
A as Updated,
|
|
1182
|
+
Z as decodeErrorMessageFromRequest,
|
|
1183
|
+
ss as decodeRequestBody,
|
|
1184
|
+
es as errorHandler,
|
|
1185
|
+
f as flushDebugLogs,
|
|
1094
1186
|
V as formParse,
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
l as httpDebug
|
|
1187
|
+
R as getCaller,
|
|
1188
|
+
ts as getScopedParams
|
|
1098
1189
|
};
|