@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.
Files changed (75) hide show
  1. package/dist/api/arkynLogRequest.d.ts.map +1 -1
  2. package/dist/api/arkynLogRequest.js +8 -3
  3. package/dist/api/makeRequest.d.ts.map +1 -1
  4. package/dist/api/makeRequest.js +6 -2
  5. package/dist/bundle.js +484 -393
  6. package/dist/bundle.umd.cjs +14 -8
  7. package/dist/http/badResponses/_badResponse.d.ts +22 -0
  8. package/dist/http/badResponses/_badResponse.d.ts.map +1 -0
  9. package/dist/http/badResponses/_badResponse.js +33 -0
  10. package/dist/http/badResponses/badGateway.d.ts +2 -1
  11. package/dist/http/badResponses/badGateway.d.ts.map +1 -1
  12. package/dist/http/badResponses/badGateway.js +4 -3
  13. package/dist/http/badResponses/badRequest.d.ts +2 -1
  14. package/dist/http/badResponses/badRequest.d.ts.map +1 -1
  15. package/dist/http/badResponses/badRequest.js +4 -3
  16. package/dist/http/badResponses/conflict.d.ts +2 -1
  17. package/dist/http/badResponses/conflict.d.ts.map +1 -1
  18. package/dist/http/badResponses/conflict.js +4 -3
  19. package/dist/http/badResponses/forbidden.d.ts +2 -1
  20. package/dist/http/badResponses/forbidden.d.ts.map +1 -1
  21. package/dist/http/badResponses/forbidden.js +4 -3
  22. package/dist/http/badResponses/notFound.d.ts +2 -1
  23. package/dist/http/badResponses/notFound.d.ts.map +1 -1
  24. package/dist/http/badResponses/notFound.js +4 -3
  25. package/dist/http/badResponses/notImplemented.d.ts +2 -1
  26. package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
  27. package/dist/http/badResponses/notImplemented.js +4 -3
  28. package/dist/http/badResponses/serverError.d.ts +2 -1
  29. package/dist/http/badResponses/serverError.d.ts.map +1 -1
  30. package/dist/http/badResponses/serverError.js +4 -3
  31. package/dist/http/badResponses/unauthorized.d.ts +2 -1
  32. package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
  33. package/dist/http/badResponses/unauthorized.js +4 -3
  34. package/dist/http/badResponses/unprocessableEntity.d.ts +3 -2
  35. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
  36. package/dist/http/badResponses/unprocessableEntity.js +5 -4
  37. package/dist/http/successResponses/_successResponse.d.ts +22 -0
  38. package/dist/http/successResponses/_successResponse.d.ts.map +1 -0
  39. package/dist/http/successResponses/_successResponse.js +37 -0
  40. package/dist/http/successResponses/created.d.ts +2 -1
  41. package/dist/http/successResponses/created.d.ts.map +1 -1
  42. package/dist/http/successResponses/created.js +4 -1
  43. package/dist/http/successResponses/found.d.ts +2 -1
  44. package/dist/http/successResponses/found.d.ts.map +1 -1
  45. package/dist/http/successResponses/found.js +4 -1
  46. package/dist/http/successResponses/noContent.d.ts +2 -1
  47. package/dist/http/successResponses/noContent.d.ts.map +1 -1
  48. package/dist/http/successResponses/noContent.js +4 -1
  49. package/dist/http/successResponses/success.d.ts +2 -1
  50. package/dist/http/successResponses/success.d.ts.map +1 -1
  51. package/dist/http/successResponses/success.js +4 -1
  52. package/dist/http/successResponses/updated.d.ts +2 -1
  53. package/dist/http/successResponses/updated.d.ts.map +1 -1
  54. package/dist/http/successResponses/updated.js +4 -1
  55. package/dist/index.d.ts +2 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +2 -1
  58. package/dist/services/apiService.d.ts.map +1 -1
  59. package/dist/services/apiService.js +8 -8
  60. package/dist/services/debugService.d.ts +54 -0
  61. package/dist/services/debugService.d.ts.map +1 -0
  62. package/dist/services/debugService.js +57 -0
  63. package/dist/services/flushDebugLogs.d.ts +8 -0
  64. package/dist/services/flushDebugLogs.d.ts.map +1 -0
  65. package/dist/services/flushDebugLogs.js +21 -0
  66. package/dist/services/formParse.d.ts.map +1 -1
  67. package/dist/services/formParse.js +0 -1
  68. package/dist/services/getCaller.d.ts.map +1 -1
  69. package/dist/services/getCaller.js +4 -4
  70. package/dist/services/schemaValidator.d.ts.map +1 -1
  71. package/dist/services/schemaValidator.js +1 -3
  72. package/package.json +1 -1
  73. package/dist/services/httpDebug.d.ts +0 -74
  74. package/dist/services/httpDebug.d.ts.map +0 -1
  75. package/dist/services/httpDebug.js +0 -93
package/dist/bundle.js CHANGED
@@ -1,40 +1,24 @@
1
1
  var U = Object.defineProperty;
2
- var k = (t, s, e) => s in t ? U(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
3
- var o = (t, s, e) => k(t, typeof s != "symbol" ? s + "" : s, e);
4
- const I = {};
5
- function x() {
6
- const t = process.cwd(), n = (new Error().stack || "").split(`
7
- `).map((u) => u.trim()), r = R.ignoreFile;
8
- let a = 2;
9
- for (; a < n.length && (n[a].includes("node:internal") || n[a].includes("/node_modules/")); )
10
- a++;
11
- if (r)
12
- for (; a < n.length && n[a].includes(r); )
13
- a++;
14
- const h = n[a] || "";
15
- let i = "Unknown function", c = "Unknown caller";
16
- const y = h.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
17
- if (y)
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
- class R {
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
- * HttpDebugService.setIgnoreFile("httpAdapter.ts");
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 setIgnoreFile(s) {
54
- this.ignoreFile = s;
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
- o(R, "ignoreFile");
62
- function l(t, s, e) {
63
- var r;
64
- if (process.env.NODE_ENV === "development" || ((r = process.env) == null ? void 0 : r.SHOW_ERRORS_IN_CONSOLE) === "true") {
65
- const i = "\x1B[36m[ARKYN-DEBUG]\x1B[0m", { callerInfo: c, functionName: y } = x();
66
- let u = `${i} ${t} initialized
67
- `;
68
- u += `${i} Caller Function: ${y}
69
- `, u += `${i} Caller Location: ${c}
70
- `, u += `${i} Body: ${JSON.stringify(s, null, 2)}
71
- `, e && (u += `${i} Cause: ${JSON.stringify(e, null, 2)}
72
- `), console.log(u);
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
- o(this, "body");
84
- o(this, "cause");
85
- o(this, "status", 502);
86
- o(this, "statusText");
87
- this.body = { name: "BadGateway", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, l("BadGateway", this.body, this.cause);
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 T {
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
- o(this, "body");
126
- o(this, "cause");
127
- o(this, "status", 400);
128
- o(this, "statusText");
129
- this.body = { name: "BadRequest", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, l("BadRequest", this.body, this.cause);
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 O {
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
- o(this, "body");
168
- o(this, "cause");
169
- o(this, "status", 409);
170
- o(this, "statusText");
171
- this.body = { name: "Conflict", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, l("Conflict", this.body, this.cause);
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 E {
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
- o(this, "body");
210
- o(this, "cause");
211
- o(this, "status", 403);
212
- o(this, "statusText");
213
- this.body = { name: "Forbidden", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, l("Forbidden", this.body, this.cause);
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 J {
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
- o(this, "body");
252
- o(this, "cause");
253
- o(this, "status", 404);
254
- o(this, "statusText");
255
- this.body = { name: "NotFound", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, l("NotFound", this.body, this.cause);
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 C {
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
- o(this, "body");
294
- o(this, "cause");
295
- o(this, "status", 501);
296
- o(this, "statusText");
297
- this.body = { name: "NotImplemented", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, l("NotImplemented", this.body, this.cause);
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 b {
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
- o(this, "body");
336
- o(this, "cause");
337
- o(this, "status", 500);
338
- o(this, "statusText");
339
- this.body = { name: "ServerError", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, l("ServerError", this.body, this.cause);
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
- o(this, "body");
378
- o(this, "cause");
379
- o(this, "status", 401);
380
- o(this, "statusText");
381
- this.body = { name: "Unauthorized", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, l("Unauthorized", this.body, this.cause);
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 m {
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, e = !1) {
423
- o(this, "body");
424
- o(this, "status", 422);
425
- o(this, "statusText");
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
- }, e && l("UnprocessableEntity", this.body);
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 B {
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
- o(this, "body");
471
- o(this, "headers");
472
- o(this, "status");
473
- o(this, "statusText");
474
- 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";
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
- o(this, "body");
517
- o(this, "headers");
518
- o(this, "status");
519
- o(this, "statusText");
520
- 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";
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 P {
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
- o(this, "headers");
559
- o(this, "status");
560
- o(this, "statusText");
561
- 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";
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
- o(this, "body");
587
- o(this, "headers");
588
- o(this, "status");
589
- o(this, "statusText");
590
- 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";
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 L {
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
- o(this, "body");
630
- o(this, "headers");
631
- o(this, "status");
632
- o(this, "statusText");
633
- 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";
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 A {
665
- static mapHeaders(s) {
666
- return s instanceof Headers ? Object.fromEntries(s.entries()) : typeof s == "object" ? Object.entries(s).reduce((e, [n, r]) => (typeof r == "string" ? e[n] = r : Array.isArray(r) ? e[n] = r.join(", ") : e[n] = JSON.stringify(r), e), {}) : {};
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(s) {
669
- const e = {};
670
- return s.forEach((n, r) => {
671
- e[r] = n;
672
- }), e;
754
+ static mapQueryParams(t) {
755
+ const s = {};
756
+ return t.forEach((e, o) => {
757
+ s[o] = e;
758
+ }), s;
673
759
  }
674
- static handle(s) {
760
+ static handle(t) {
675
761
  return {
676
- rawUrl: s.url,
677
- status: s.status,
678
- method: s.method,
762
+ rawUrl: t.url,
763
+ status: t.status,
764
+ method: t.method,
679
765
  token: null,
680
- elapsedTime: s.elapsedTime,
681
- requestHeaders: this.mapHeaders(s.requestHeaders),
682
- requestBody: s.requestBody || null,
683
- queryParams: this.mapQueryParams(s.queryParams),
684
- responseHeaders: this.mapHeaders(s.responseHeaders),
685
- responseBody: s.responseBody || null
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(s) {
787
+ static setArkynConfig(t) {
702
788
  if (this.arkynConfig) return;
703
- let n = s.arkynLogBaseApiUrl || "https://logs-arkyn-flow-logs.vw6wo7.easypanel.host";
704
- n = n + "/http-traffic-records/:trafficSourceId", this.arkynConfig = {
705
- arkynTrafficSourceId: s.arkynTrafficSourceId,
706
- arkynUserToken: s.arkynUserToken,
707
- arkynApiUrl: n
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
- o(w, "arkynConfig");
728
- async function v(t) {
729
- const s = w.getArkynConfig();
730
- if (!s) return;
731
- const { arkynUserToken: e, arkynApiUrl: n } = s, {
732
- elapsedTime: r,
733
- method: a,
734
- queryParams: h,
735
- requestBody: i,
736
- requestHeaders: c,
737
- responseBody: y,
738
- responseHeaders: u,
739
- status: f,
740
- token: K,
741
- rawUrl: S
742
- } = t;
743
- try {
744
- const d = new URL(S);
745
- let g = "HTTPS";
746
- d.protocol === "http:" && (g = "HTTP");
747
- const N = JSON.stringify({
748
- domainUrl: d.protocol + "//" + d.host,
749
- pathnameUrl: d.pathname,
750
- status: f,
751
- protocol: g,
752
- method: a,
753
- trafficUserId: null,
754
- elapsedTime: r,
755
- requestHeaders: c,
756
- requestBody: i,
757
- queryParams: h,
758
- responseHeaders: u,
759
- responseBody: y
760
- });
761
- await fetch(
762
- n.replace(
763
- ":trafficSourceId",
764
- s.arkynTrafficSourceId
765
- ),
766
- {
767
- method: "POST",
768
- body: N,
769
- headers: {
770
- "Content-Type": "application/json",
771
- Authorization: `Bearer ${e}`
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
- } catch (d) {
776
- l("arkyn log error", "Error sending request", d);
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 p(t, s, e = {}, n) {
780
- const r = {
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 a = performance.now(), h = { ...e, "Content-Type": "application/json" }, i = await fetch(s, {
789
- method: t,
790
- headers: h,
791
- body: n ? JSON.stringify(n) : void 0
792
- }), c = performance.now() - a, y = i.status;
793
- let u = null;
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
- u = await i.json();
886
+ a = await h.json();
796
887
  } catch {
797
- u = null;
888
+ a = null;
798
889
  }
799
- const f = A.handle({
800
- elapsedTime: c,
801
- method: t,
802
- queryParams: new URL(s).searchParams,
803
- requestHeaders: h,
804
- requestBody: n,
805
- responseBody: u,
806
- responseHeaders: i.headers,
807
- status: y,
808
- url: s
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 v(f), i.ok ? {
901
+ return F(p), h.ok ? {
811
902
  success: !0,
812
- status: y,
813
- message: (u == null ? void 0 : u.message) || r[t],
814
- response: u,
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: y,
819
- message: (u == null ? void 0 : u.message) || i.statusText || "Request failed",
820
- response: u,
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 (a) {
824
- return l("Network error or request failed", null, a), {
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: a instanceof Error ? a.message : String(a)
924
+ cause: u instanceof Error ? u.message : String(u)
830
925
  };
831
926
  }
832
927
  }
833
- async function D(t, s = {}, e) {
834
- return p("DELETE", t, s, e);
928
+ async function M(n, t = {}, s) {
929
+ return b("DELETE", n, t, s);
835
930
  }
836
- async function F(t, s = {}) {
837
- return p("GET", t, s);
931
+ async function _(n, t = {}) {
932
+ return b("GET", n, t);
838
933
  }
839
- async function M(t, s = {}, e) {
840
- return p("PATCH", t, s, e);
934
+ async function z(n, t = {}, s) {
935
+ return b("PATCH", n, t, s);
841
936
  }
842
- async function z(t, s = {}, e) {
843
- return p("POST", t, s, e);
937
+ async function G(n, t = {}, s) {
938
+ return b("POST", n, t, s);
844
939
  }
845
- async function G(t, s = {}, e) {
846
- return p("PUT", t, s, e);
940
+ async function K(n, t = {}, s) {
941
+ return b("PUT", n, t, s);
847
942
  }
848
- class W {
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(s) {
858
- o(this, "baseUrl");
859
- o(this, "baseHeaders");
860
- o(this, "baseToken");
861
- o(this, "enableDebug");
862
- this.baseUrl = s.baseUrl, this.baseHeaders = s.baseHeaders || void 0, this.baseToken = s.baseToken || void 0, this.enableDebug = s.enableDebug || !1;
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, n) {
964
+ onDebug(t, s, e) {
870
965
  if (this.enableDebug) {
871
- const h = "\x1B[33m[ARKYN-API-DEBUG]\x1B[0m";
872
- console.log(`${h} Base URL: ${this.baseUrl}`), console.log(`${h} Full URL: ${s}`), console.log(`${h} Method: ${e}`), n[0] && console.log(`${h} Headers: `, n[0]), n[1] && console.log(`${h} Body: `, n[1]);
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(s) {
876
- return this.baseUrl + s;
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(s, e) {
885
- let n = {};
886
- return this.baseToken && (n = { Authorization: `Bearer ${this.baseToken}` }), this.baseHeaders && (n = { ...n, ...this.baseHeaders }), s && (n = { ...n, ...s }), e && (n = { ...n, Authorization: `Bearer ${e}` }), n;
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(s, e) {
895
- const n = this.generateURL(s), r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token);
896
- return this.onDebug(n, "get", [r]), await F(n, r);
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(s, e) {
905
- const n = this.generateURL(s), r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), a = e == null ? void 0 : e.body;
906
- return this.onDebug(n, "post", [r, a]), await z(n, r, a);
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(s, e) {
915
- const n = this.generateURL(s), r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), a = e == null ? void 0 : e.body;
916
- return this.onDebug(n, "put", [r, a]), await G(n, r, a);
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(s, e) {
925
- const n = this.generateURL(s), r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), a = e == null ? void 0 : e.body;
926
- return this.onDebug(n, "patch", [r, a]), await M(n, r, a);
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(s, e) {
935
- const n = this.generateURL(s), r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), a = e == null ? void 0 : e.body;
936
- return this.onDebug(n, "delete", [r, a]), await D(n, r, a);
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 Y(t, s) {
940
- var e, n, r;
941
- return t != null && t.message && typeof (t == null ? void 0 : t.message) == "string" ? t == null ? void 0 : t.message : t != null && t.error && typeof (t == null ? void 0 : t.error) == "string" ? t == null ? void 0 : t.error : (e = t == null ? void 0 : t.error) != null && e.message && typeof ((n = t == null ? void 0 : t.error) == null ? void 0 : n.message) == "string" ? (r = t == null ? void 0 : t.error) == null ? void 0 : r.message : s != null && s.statusText && typeof (s == null ? void 0 : s.statusText) == "string" ? s == null ? void 0 : s.statusText : "Missing error message";
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 X = async (t) => {
944
- let s;
945
- const e = await t.arrayBuffer(), n = new TextDecoder().decode(e);
1038
+ const ss = async (n) => {
1039
+ let t;
1040
+ const s = await n.arrayBuffer(), e = new TextDecoder().decode(s);
946
1041
  try {
947
- s = JSON.parse(n);
1042
+ t = JSON.parse(e);
948
1043
  } catch {
949
1044
  try {
950
- if (n.includes("=")) {
951
- const a = new URLSearchParams(n);
952
- s = Object.fromEntries(a.entries());
1045
+ if (e.includes("=")) {
1046
+ const u = new URLSearchParams(e);
1047
+ t = Object.fromEntries(u.entries());
953
1048
  } else
954
- throw new T("Invalid URLSearchParams format");
1049
+ throw new g("Invalid URLSearchParams format");
955
1050
  } catch {
956
- throw new T("Failed to extract data from request");
1051
+ throw new g("Failed to extract data from request");
957
1052
  }
958
1053
  }
959
- return s;
1054
+ return t;
960
1055
  };
961
- function Z(t) {
1056
+ function es(n) {
962
1057
  switch (!0) {
963
- case t instanceof Response:
964
- return t;
965
- case t instanceof H:
966
- return t.toResponse();
967
- case t instanceof B:
968
- return t.toResponse();
969
- case t instanceof L:
970
- return t.toResponse();
971
- case t instanceof $:
972
- return t.toResponse();
973
- case t instanceof P:
974
- return t.toResponse();
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 t instanceof j:
978
- return t.toResponse();
979
- case t instanceof T:
980
- return t.toResponse();
981
- case t instanceof O:
982
- return t.toResponse();
983
- case t instanceof E:
984
- return t.toResponse();
985
- case t instanceof J:
986
- return t.toResponse();
987
- case t instanceof C:
988
- return t.toResponse();
989
- case t instanceof b:
990
- return t.toResponse();
991
- case t instanceof q:
992
- return t.toResponse();
993
- case t instanceof m:
994
- return t.toResponse();
995
- }
996
- return new b("Server error", t).toResponse();
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
- t,
1000
- s
1094
+ n,
1095
+ t
1001
1096
  ]) {
1002
- const e = s.safeParse(t);
1003
- if (e.success === !1) {
1004
- const n = Object.fromEntries(
1005
- e.error.issues.map((r) => (console.log(r), [r.path.join("."), r.message]))
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: e.success,
1009
- fieldErrors: n,
1010
- fields: t
1103
+ success: s.success,
1104
+ fieldErrors: e,
1105
+ fields: n
1011
1106
  };
1012
1107
  } else
1013
1108
  return {
1014
- success: e.success,
1015
- data: e.data
1109
+ success: s.success,
1110
+ data: s.data
1016
1111
  };
1017
1112
  }
1018
- const ss = (t, s = "") => {
1019
- const e = new URL(t.url);
1020
- if (s === "") return e.searchParams;
1021
- const n = Array.from(
1022
- e.searchParams.entries()
1023
- ).filter(([r]) => r.startsWith(`${s}:`)).map(([r, a]) => [r.replace(`${s}:`, ""), a]);
1024
- return new URLSearchParams(n);
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 _(t) {
1027
- const s = "Error validating:", e = t.issues.map(
1028
- ({ path: n, message: r }) => `-> ${n.join(".")}: ${r}`
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 [s, ...e].join(`
1125
+ return [t, ...s].join(`
1031
1126
  `);
1032
1127
  }
1033
- class es {
1034
- constructor(s) {
1035
- o(this, "functionName");
1036
- o(this, "callerInfo");
1037
- this.schema = s;
1038
- const { callerInfo: e, functionName: n } = x();
1039
- this.callerInfo = e, this.functionName = n;
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(s) {
1042
- return this.schema.safeParse(s).success;
1136
+ isValid(t) {
1137
+ return this.schema.safeParse(t).success;
1043
1138
  }
1044
- safeValidate(s) {
1045
- return this.schema.safeParse(s);
1139
+ safeValidate(t) {
1140
+ return this.schema.safeParse(t);
1046
1141
  }
1047
- validate(s) {
1142
+ validate(t) {
1048
1143
  try {
1049
- return this.schema.parse(s);
1050
- } catch (e) {
1051
- throw new b(_(e));
1144
+ return this.schema.parse(t);
1145
+ } catch (s) {
1146
+ throw new x(Y(s));
1052
1147
  }
1053
1148
  }
1054
- formValidate(s, e) {
1055
- const n = V([s, this.schema]);
1056
- if (!n.success) {
1057
- l("UnprocessableEntity", n);
1058
- const r = Object.keys(n.fieldErrors)[0];
1059
- throw new m(
1060
- {
1061
- fields: n.fields,
1062
- fieldErrors: n.fieldErrors,
1063
- data: { scrollTo: r },
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 n.data;
1160
+ return e.data;
1070
1161
  }
1071
1162
  }
1072
1163
  export {
1073
- W as ApiService,
1164
+ X as ApiService,
1074
1165
  w as ArkynLogService,
1075
1166
  j as BadGateway,
1076
- T as BadRequest,
1077
- O as Conflict,
1078
- B as Created,
1079
- E as Forbidden,
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
- R as HttpDebugService,
1082
- P as NoContent,
1083
- J as NotFound,
1084
- C as NotImplemented,
1085
- es as SchemaValidator,
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
- m as UnprocessableEntity,
1090
- L as Updated,
1091
- Y as decodeErrorMessageFromRequest,
1092
- X as decodeRequestBody,
1093
- Z as errorHandler,
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
- x as getCaller,
1096
- ss as getScopedParams,
1097
- l as httpDebug
1187
+ R as getCaller,
1188
+ ts as getScopedParams
1098
1189
  };