@arkyn/server 3.0.1-beta.68 → 3.0.1-beta.69

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/bundle.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var U = Object.defineProperty;
2
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);
3
+ var o = (n, t, s) => I(n, typeof t != "symbol" ? t + "" : t, s);
4
4
  function p(n) {
5
5
  var s;
6
6
  if (process.env.NODE_ENV === "development" || ((s = process.env) == null ? void 0 : s.SHOW_ERRORS_IN_CONSOLE) === "true") {
@@ -58,15 +58,15 @@ class S {
58
58
  * The name of the file to ignore when analyzing the stack trace.
59
59
  * When set, the `getCaller` function will skip stack frames containing this file name.
60
60
  */
61
- r(S, "ignoreFiles", []);
62
- function m() {
61
+ o(S, "ignoreFiles", []);
62
+ function x() {
63
63
  const n = process.cwd(), e = (new Error().stack || "").split(`
64
- `).map((a) => a.trim()), o = S.ignoreFiles;
64
+ `).map((a) => a.trim()), r = S.ignoreFiles;
65
65
  let u = 2;
66
66
  for (; u < e.length && (e[u].includes("node:internal") || e[u].includes("/node_modules/")); )
67
67
  u++;
68
- if (o.length > 0)
69
- for (; u < e.length && o.some(
68
+ if (r.length > 0)
69
+ for (; u < e.length && r.some(
70
70
  (a) => e[u].includes(a)
71
71
  ); )
72
72
  u++;
@@ -94,27 +94,9 @@ function m() {
94
94
  return { functionName: h, callerInfo: i };
95
95
  }
96
96
  class y {
97
- /**
98
- * Logs debug information for bad responses including caller context and response details.
99
- *
100
- * @param name - The name/type of the bad response being logged
101
- * @param body - The response body or error data to be logged
102
- * @param cause - Optional additional cause information for the error
103
- *
104
- * @example
105
- * ```typescript
106
- * const badResponse = new BadResponse();
107
- * badResponse.onDebug("ValidationError", { field: "email", message: "Invalid format" });
108
- * ```
109
- */
110
- onDebug(t, s, e) {
111
- const o = [], { callerInfo: u, functionName: c } = m();
112
- o.push(`${t} initialized
113
- `), o.push(`Caller Function: ${c}
114
- `), o.push(`Caller Location: ${u}
115
- `), o.push(`Body: ${JSON.stringify(s, null, 2)}
116
- `), e && o.push(`Cause: ${JSON.stringify(e, null, 2)}
117
- `), p({ scheme: "red", name: "ARKYN-BAD-RESPONSE-DEBUG", debugs: o });
97
+ onDebug(t) {
98
+ const { name: s, body: e, cause: r, message: u } = t, c = [], { callerInfo: h, functionName: i } = x();
99
+ c.push(`${s} initialized`), c.push(`Caller Function: ${i}`), c.push(`Caller Location: ${h}`), u && c.push(`Message: ${u}`), e && c.push(`Body: ${JSON.stringify(e, null, 2)}`), r && c.push(`Cause: ${JSON.stringify(r, null, 2)}`), p({ scheme: "red", name: "ARKYN-BAD-RESPONSE-DEBUG", debugs: c });
118
100
  }
119
101
  }
120
102
  class j extends y {
@@ -126,11 +108,16 @@ class j extends y {
126
108
  */
127
109
  constructor(s, e) {
128
110
  super();
129
- r(this, "body");
130
- r(this, "cause");
131
- r(this, "status", 502);
132
- r(this, "statusText");
133
- this.body = { name: "BadGateway", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("BadGateway", this.body, this.cause);
111
+ o(this, "body");
112
+ o(this, "cause");
113
+ o(this, "status", 502);
114
+ o(this, "statusText");
115
+ this.body = { name: "BadGateway", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug({
116
+ name: "BadGateway",
117
+ body: this.body,
118
+ cause: this.cause,
119
+ message: this.statusText
120
+ });
134
121
  }
135
122
  /**
136
123
  * Converts the `BadGateway` instance into a `Response` object with a JSON body.
@@ -169,11 +156,16 @@ class b extends y {
169
156
  */
170
157
  constructor(s, e) {
171
158
  super();
172
- r(this, "body");
173
- r(this, "cause");
174
- r(this, "status", 400);
175
- r(this, "statusText");
176
- this.body = { name: "BadRequest", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("BadRequest", this.body, this.cause);
159
+ o(this, "body");
160
+ o(this, "cause");
161
+ o(this, "status", 400);
162
+ o(this, "statusText");
163
+ this.body = { name: "BadRequest", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug({
164
+ name: "BadRequest",
165
+ body: this.body,
166
+ cause: this.cause,
167
+ message: this.statusText
168
+ });
177
169
  }
178
170
  /**
179
171
  * Converts the `BadRequest` instance into a `Response` object with a JSON body.
@@ -212,11 +204,16 @@ class J extends y {
212
204
  */
213
205
  constructor(s, e) {
214
206
  super();
215
- r(this, "body");
216
- r(this, "cause");
217
- r(this, "status", 409);
218
- r(this, "statusText");
219
- this.body = { name: "Conflict", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("Conflict", this.body, this.cause);
207
+ o(this, "body");
208
+ o(this, "cause");
209
+ o(this, "status", 409);
210
+ o(this, "statusText");
211
+ this.body = { name: "Conflict", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug({
212
+ name: "Conflict",
213
+ body: this.body,
214
+ cause: this.cause,
215
+ message: this.statusText
216
+ });
220
217
  }
221
218
  /**
222
219
  * Converts the `Conflict` instance into a `Response` object with a JSON body.
@@ -255,11 +252,16 @@ class D extends y {
255
252
  */
256
253
  constructor(s, e) {
257
254
  super();
258
- r(this, "body");
259
- r(this, "cause");
260
- r(this, "status", 403);
261
- r(this, "statusText");
262
- this.body = { name: "Forbidden", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("Forbidden", this.body, this.cause);
255
+ o(this, "body");
256
+ o(this, "cause");
257
+ o(this, "status", 403);
258
+ o(this, "statusText");
259
+ this.body = { name: "Forbidden", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug({
260
+ name: "Forbidden",
261
+ body: this.body,
262
+ cause: this.cause,
263
+ message: this.statusText
264
+ });
263
265
  }
264
266
  /**
265
267
  * Converts the `Forbidden` instance into a `Response` object with a JSON body.
@@ -298,11 +300,16 @@ class C extends y {
298
300
  */
299
301
  constructor(s, e) {
300
302
  super();
301
- r(this, "body");
302
- r(this, "cause");
303
- r(this, "status", 404);
304
- r(this, "statusText");
305
- this.body = { name: "NotFound", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("NotFound", this.body, this.cause);
303
+ o(this, "body");
304
+ o(this, "cause");
305
+ o(this, "status", 404);
306
+ o(this, "statusText");
307
+ this.body = { name: "NotFound", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug({
308
+ name: "NotFound",
309
+ body: this.body,
310
+ cause: this.cause,
311
+ message: this.statusText
312
+ });
306
313
  }
307
314
  /**
308
315
  * Converts the `NotFound` instance into a `Response` object with a JSON body.
@@ -341,11 +348,16 @@ class B extends y {
341
348
  */
342
349
  constructor(s, e) {
343
350
  super();
344
- r(this, "body");
345
- r(this, "cause");
346
- r(this, "status", 501);
347
- r(this, "statusText");
348
- this.body = { name: "NotImplemented", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("NotImplemented", this.body, this.cause);
351
+ o(this, "body");
352
+ o(this, "cause");
353
+ o(this, "status", 501);
354
+ o(this, "statusText");
355
+ this.body = { name: "NotImplemented", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug({
356
+ name: "NotImplemented",
357
+ body: this.body,
358
+ cause: this.cause,
359
+ message: this.statusText
360
+ });
349
361
  }
350
362
  /**
351
363
  * Converts the `NotImplemented` instance into a `Response` object with a JSON body.
@@ -375,7 +387,7 @@ class B extends y {
375
387
  return Response.json(this.body, s);
376
388
  }
377
389
  }
378
- class x extends y {
390
+ class m extends y {
379
391
  /**
380
392
  * Creates an instance of the `ServerError` class.
381
393
  *
@@ -384,11 +396,16 @@ class x extends y {
384
396
  */
385
397
  constructor(s, e) {
386
398
  super();
387
- r(this, "body");
388
- r(this, "cause");
389
- r(this, "status", 500);
390
- r(this, "statusText");
391
- this.body = { name: "ServerError", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("ServerError", this.body, this.cause);
399
+ o(this, "body");
400
+ o(this, "cause");
401
+ o(this, "status", 500);
402
+ o(this, "statusText");
403
+ this.body = { name: "ServerError", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug({
404
+ name: "ServerError",
405
+ body: this.body,
406
+ cause: this.cause,
407
+ message: this.statusText
408
+ });
392
409
  }
393
410
  /**
394
411
  * Converts the `ServerError` instance into a `Response` object with a JSON body.
@@ -427,11 +444,16 @@ class q extends y {
427
444
  */
428
445
  constructor(s, e) {
429
446
  super();
430
- r(this, "body");
431
- r(this, "cause");
432
- r(this, "status", 401);
433
- r(this, "statusText");
434
- this.body = { name: "Unauthorized", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug("Unauthorized", this.body, this.cause);
447
+ o(this, "body");
448
+ o(this, "cause");
449
+ o(this, "status", 401);
450
+ o(this, "statusText");
451
+ this.body = { name: "Unauthorized", message: s }, this.statusText = s, this.cause = e ? JSON.stringify(e) : void 0, this.onDebug({
452
+ name: "Unauthorized",
453
+ body: this.body,
454
+ cause: this.cause,
455
+ message: this.statusText
456
+ });
435
457
  }
436
458
  /**
437
459
  * Converts the `Unauthorized` instance into a `Response` object with a JSON body.
@@ -474,20 +496,20 @@ class N extends y {
474
496
  */
475
497
  constructor(s) {
476
498
  super();
477
- r(this, "body");
478
- r(this, "status", 422);
479
- r(this, "statusText");
499
+ o(this, "body");
500
+ o(this, "status", 422);
501
+ o(this, "statusText");
480
502
  this.statusText = s.message || "Unprocessable Entity", this.body = {
481
503
  name: "UnprocessableEntity",
482
504
  message: s.message || null,
483
505
  data: s.data,
484
506
  fieldErrors: s.fieldErrors,
485
507
  fields: s.fields
486
- }, this.onDebug(
487
- "UnprocessableEntity",
488
- s.message || null,
489
- s.fieldErrors || null
490
- );
508
+ }, this.onDebug({
509
+ name: "UnprocessableEntity",
510
+ cause: s.fieldErrors,
511
+ message: s.message
512
+ });
491
513
  }
492
514
  /**
493
515
  * Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
@@ -532,16 +554,16 @@ class T {
532
554
  * ```
533
555
  */
534
556
  onDebug(t, s, e) {
535
- const o = [], { callerInfo: u, functionName: c } = m();
536
- o.push(`${t} initialized
537
- `), o.push(`Caller Function: ${c}
538
- `), o.push(`Caller Location: ${u}
539
- `), o.push(`Body: ${JSON.stringify(s, null, 2)}
540
- `), e && o.push(`Cause: ${JSON.stringify(e, null, 2)}
557
+ const r = [], { callerInfo: u, functionName: c } = x();
558
+ r.push(`${t} initialized
559
+ `), r.push(`Caller Function: ${c}
560
+ `), r.push(`Caller Location: ${u}
561
+ `), r.push(`Body: ${JSON.stringify(s, null, 2)}
562
+ `), e && r.push(`Cause: ${JSON.stringify(e, null, 2)}
541
563
  `), p({
542
564
  scheme: "green",
543
565
  name: "ARKYN-SUCCESS-RESPONSE-DEBUG",
544
- debugs: o
566
+ debugs: r
545
567
  });
546
568
  }
547
569
  }
@@ -554,10 +576,10 @@ class P extends T {
554
576
  */
555
577
  constructor(s, e) {
556
578
  super();
557
- r(this, "body");
558
- r(this, "headers");
559
- r(this, "status");
560
- r(this, "statusText");
579
+ o(this, "body");
580
+ o(this, "headers");
581
+ o(this, "status");
582
+ o(this, "statusText");
561
583
  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);
562
584
  }
563
585
  /**
@@ -589,7 +611,7 @@ class P extends T {
589
611
  return Response.json(this.body, s);
590
612
  }
591
613
  }
592
- class H extends T {
614
+ class $ extends T {
593
615
  /**
594
616
  * Creates an instance of the `Found` class.
595
617
  *
@@ -601,10 +623,10 @@ class H extends T {
601
623
  */
602
624
  constructor(s, e) {
603
625
  super();
604
- r(this, "body");
605
- r(this, "headers");
606
- r(this, "status");
607
- r(this, "statusText");
626
+ o(this, "body");
627
+ o(this, "headers");
628
+ o(this, "status");
629
+ o(this, "statusText");
608
630
  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);
609
631
  }
610
632
  /**
@@ -636,7 +658,7 @@ class H extends T {
636
658
  return Response.json(this.body, s);
637
659
  }
638
660
  }
639
- class $ extends T {
661
+ class H extends T {
640
662
  /**
641
663
  * Creates an instance of the `NoContent` class.
642
664
  *
@@ -644,9 +666,9 @@ class $ extends T {
644
666
  */
645
667
  constructor(s) {
646
668
  super();
647
- r(this, "headers");
648
- r(this, "status");
649
- r(this, "statusText");
669
+ o(this, "headers");
670
+ o(this, "status");
671
+ o(this, "statusText");
650
672
  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);
651
673
  }
652
674
  /**
@@ -673,10 +695,10 @@ class A extends T {
673
695
  */
674
696
  constructor(s, e) {
675
697
  super();
676
- r(this, "body");
677
- r(this, "headers");
678
- r(this, "status");
679
- r(this, "statusText");
698
+ o(this, "body");
699
+ o(this, "headers");
700
+ o(this, "status");
701
+ o(this, "statusText");
680
702
  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);
681
703
  }
682
704
  /**
@@ -717,10 +739,10 @@ class L extends T {
717
739
  */
718
740
  constructor(s, e) {
719
741
  super();
720
- r(this, "body");
721
- r(this, "headers");
722
- r(this, "status");
723
- r(this, "statusText");
742
+ o(this, "body");
743
+ o(this, "headers");
744
+ o(this, "status");
745
+ o(this, "statusText");
724
746
  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);
725
747
  }
726
748
  /**
@@ -754,12 +776,12 @@ class L extends T {
754
776
  }
755
777
  class v {
756
778
  static mapHeaders(t) {
757
- 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), {}) : {};
779
+ return t instanceof Headers ? Object.fromEntries(t.entries()) : typeof t == "object" ? Object.entries(t).reduce((s, [e, r]) => (typeof r == "string" ? s[e] = r : Array.isArray(r) ? s[e] = r.join(", ") : s[e] = JSON.stringify(r), s), {}) : {};
758
780
  }
759
781
  static mapQueryParams(t) {
760
782
  const s = {};
761
- return t.forEach((e, o) => {
762
- s[o] = e;
783
+ return t.forEach((e, r) => {
784
+ s[r] = e;
763
785
  }), s;
764
786
  }
765
787
  static handle(t) {
@@ -815,12 +837,12 @@ class w {
815
837
  this.arkynConfig = void 0;
816
838
  }
817
839
  }
818
- r(w, "arkynConfig");
840
+ o(w, "arkynConfig");
819
841
  async function F(n) {
820
842
  const t = w.getArkynConfig();
821
843
  if (!t) return;
822
844
  const { arkynUserToken: s, arkynApiUrl: e } = t, {
823
- elapsedTime: o,
845
+ elapsedTime: r,
824
846
  method: u,
825
847
  queryParams: c,
826
848
  requestBody: h,
@@ -843,7 +865,7 @@ async function F(n) {
843
865
  protocol: R,
844
866
  method: u,
845
867
  trafficUserId: null,
846
- elapsedTime: o,
868
+ elapsedTime: r,
847
869
  requestHeaders: i,
848
870
  requestBody: h,
849
871
  queryParams: c,
@@ -873,7 +895,7 @@ async function F(n) {
873
895
  }
874
896
  }
875
897
  async function g(n, t, s = {}, e) {
876
- const o = {
898
+ const r = {
877
899
  POST: "Resource created successfully",
878
900
  PUT: "Resource updated successfully",
879
901
  DELETE: "Resource deleted successfully",
@@ -906,7 +928,7 @@ async function g(n, t, s = {}, e) {
906
928
  return F(d), h.ok ? {
907
929
  success: !0,
908
930
  status: l,
909
- message: (a == null ? void 0 : a.message) || o[n],
931
+ message: (a == null ? void 0 : a.message) || r[n],
910
932
  response: a,
911
933
  cause: null
912
934
  } : {
@@ -955,10 +977,10 @@ class X {
955
977
  * @param props.enableDebug - Optional flag to enable debug logging for requests.
956
978
  */
957
979
  constructor(t) {
958
- r(this, "baseUrl");
959
- r(this, "baseHeaders");
960
- r(this, "baseToken");
961
- r(this, "enableDebug");
980
+ o(this, "baseUrl");
981
+ o(this, "baseHeaders");
982
+ o(this, "baseToken");
983
+ o(this, "enableDebug");
962
984
  this.baseUrl = t.baseUrl, this.baseHeaders = t.baseHeaders || void 0, this.baseToken = t.baseToken || void 0, this.enableDebug = t.enableDebug || !1;
963
985
  }
964
986
  /**
@@ -968,8 +990,8 @@ class X {
968
990
  */
969
991
  onDebug(t, s, e) {
970
992
  if (this.enableDebug) {
971
- const o = [];
972
- o.push(`Base URL: ${this.baseUrl}`), o.push(`Endpoint: ${t}`), o.push(`Method: ${s}`), e[0] && o.push(`Headers: ${JSON.stringify(e[0])}`), e[1] && o.push(`Body: ${JSON.stringify(e[1])}`), p({ debugs: o, name: "ARKYN-API-DEBUG", scheme: "yellow" });
993
+ const r = [];
994
+ r.push(`Base URL: ${this.baseUrl}`), r.push(`Endpoint: ${t}`), r.push(`Method: ${s}`), e[0] && r.push(`Headers: ${JSON.stringify(e[0])}`), e[1] && r.push(`Body: ${JSON.stringify(e[1])}`), p({ debugs: r, name: "ARKYN-API-DEBUG", scheme: "yellow" });
973
995
  }
974
996
  }
975
997
  generateURL(t) {
@@ -992,8 +1014,8 @@ class X {
992
1014
  * @returns The API response data.
993
1015
  */
994
1016
  async get(t, s) {
995
- const e = this.generateURL(t), o = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token);
996
- return this.onDebug(t, "get", [o]), await _(e, o);
1017
+ const e = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token);
1018
+ return this.onDebug(t, "get", [r]), await _(e, r);
997
1019
  }
998
1020
  /**
999
1021
  * Sends a post request to the specified endpoint.
@@ -1002,8 +1024,8 @@ class X {
1002
1024
  * @returns The API response data.
1003
1025
  */
1004
1026
  async post(t, s) {
1005
- 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;
1006
- return this.onDebug(t, "post", [o, u]), await G(e, o, u);
1027
+ const e = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), u = s == null ? void 0 : s.body;
1028
+ return this.onDebug(t, "post", [r, u]), await G(e, r, u);
1007
1029
  }
1008
1030
  /**
1009
1031
  * Sends a put request to the specified endpoint.
@@ -1012,8 +1034,8 @@ class X {
1012
1034
  * @returns The API response data.
1013
1035
  */
1014
1036
  async put(t, s) {
1015
- 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;
1016
- return this.onDebug(t, "put", [o, u]), await K(e, o, u);
1037
+ const e = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), u = s == null ? void 0 : s.body;
1038
+ return this.onDebug(t, "put", [r, u]), await K(e, r, u);
1017
1039
  }
1018
1040
  /**
1019
1041
  * Sends a patch request to the specified endpoint.
@@ -1022,8 +1044,8 @@ class X {
1022
1044
  * @returns The API response data.
1023
1045
  */
1024
1046
  async patch(t, s) {
1025
- 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;
1026
- return this.onDebug(t, "patch", [o, u]), await z(e, o, u);
1047
+ const e = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), u = s == null ? void 0 : s.body;
1048
+ return this.onDebug(t, "patch", [r, u]), await z(e, r, u);
1027
1049
  }
1028
1050
  /**
1029
1051
  * Sends a delete request to the specified endpoint.
@@ -1032,13 +1054,13 @@ class X {
1032
1054
  * @returns The API response data.
1033
1055
  */
1034
1056
  async delete(t, s) {
1035
- 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;
1036
- return this.onDebug(t, "delete", [o, u]), await M(e, o, u);
1057
+ const e = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), u = s == null ? void 0 : s.body;
1058
+ return this.onDebug(t, "delete", [r, u]), await M(e, r, u);
1037
1059
  }
1038
1060
  }
1039
1061
  function Z(n, t) {
1040
- var s, e, o;
1041
- 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";
1062
+ var s, e, r;
1063
+ 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" ? (r = n == null ? void 0 : n.error) == null ? void 0 : r.message : t != null && t.statusText && typeof (t == null ? void 0 : t.statusText) == "string" ? t == null ? void 0 : t.statusText : "Missing error message";
1042
1064
  }
1043
1065
  const ss = async (n) => {
1044
1066
  let t;
@@ -1062,7 +1084,7 @@ function es(n) {
1062
1084
  switch (!0) {
1063
1085
  case n instanceof Response:
1064
1086
  return n;
1065
- case n instanceof H:
1087
+ case n instanceof $:
1066
1088
  return n.toResponse();
1067
1089
  case n instanceof P:
1068
1090
  return n.toResponse();
@@ -1070,7 +1092,7 @@ function es(n) {
1070
1092
  return n.toResponse();
1071
1093
  case n instanceof A:
1072
1094
  return n.toResponse();
1073
- case n instanceof $:
1095
+ case n instanceof H:
1074
1096
  return n.toResponse();
1075
1097
  }
1076
1098
  switch (!0) {
@@ -1086,14 +1108,14 @@ function es(n) {
1086
1108
  return n.toResponse();
1087
1109
  case n instanceof B:
1088
1110
  return n.toResponse();
1089
- case n instanceof x:
1111
+ case n instanceof m:
1090
1112
  return n.toResponse();
1091
1113
  case n instanceof q:
1092
1114
  return n.toResponse();
1093
1115
  case n instanceof N:
1094
1116
  return n.toResponse();
1095
1117
  }
1096
- return new x("Server error", n).toResponse();
1118
+ return new m("Server error", n).toResponse();
1097
1119
  }
1098
1120
  function V([
1099
1121
  n,
@@ -1102,7 +1124,7 @@ function V([
1102
1124
  const s = t.safeParse(n);
1103
1125
  if (s.success === !1) {
1104
1126
  const e = Object.fromEntries(
1105
- s.error.issues.map((o) => [o.path.join("."), o.message])
1127
+ s.error.issues.map((r) => [r.path.join("."), r.message])
1106
1128
  );
1107
1129
  return {
1108
1130
  success: s.success,
@@ -1120,22 +1142,22 @@ const ts = (n, t = "") => {
1120
1142
  if (t === "") return s.searchParams;
1121
1143
  const e = Array.from(
1122
1144
  s.searchParams.entries()
1123
- ).filter(([o]) => o.startsWith(`${t}:`)).map(([o, u]) => [o.replace(`${t}:`, ""), u]);
1145
+ ).filter(([r]) => r.startsWith(`${t}:`)).map(([r, u]) => [r.replace(`${t}:`, ""), u]);
1124
1146
  return new URLSearchParams(e);
1125
1147
  };
1126
1148
  function Y(n) {
1127
1149
  const t = "Error validating:", s = n.issues.map(
1128
- ({ path: e, message: o }) => `-> ${e.join(".")}: ${o}`
1150
+ ({ path: e, message: r }) => `-> ${e.join(".")}: ${r}`
1129
1151
  );
1130
1152
  return [t, ...s].join(`
1131
1153
  `);
1132
1154
  }
1133
1155
  class ns {
1134
1156
  constructor(t) {
1135
- r(this, "functionName");
1136
- r(this, "callerInfo");
1157
+ o(this, "functionName");
1158
+ o(this, "callerInfo");
1137
1159
  this.schema = t;
1138
- const { callerInfo: s, functionName: e } = m();
1160
+ const { callerInfo: s, functionName: e } = x();
1139
1161
  this.callerInfo = s, this.functionName = e;
1140
1162
  }
1141
1163
  isValid(t) {
@@ -1148,17 +1170,17 @@ class ns {
1148
1170
  try {
1149
1171
  return this.schema.parse(t);
1150
1172
  } catch (s) {
1151
- throw new x(Y(s));
1173
+ throw new m(Y(s));
1152
1174
  }
1153
1175
  }
1154
1176
  formValidate(t, s) {
1155
1177
  const e = V([t, this.schema]);
1156
1178
  if (!e.success) {
1157
- const o = Object.keys(e.fieldErrors)[0];
1179
+ const r = Object.keys(e.fieldErrors)[0];
1158
1180
  throw new N({
1159
1181
  fields: e.fields,
1160
1182
  fieldErrors: e.fieldErrors,
1161
- data: { scrollTo: o },
1183
+ data: { scrollTo: r },
1162
1184
  message: s
1163
1185
  });
1164
1186
  }
@@ -1174,12 +1196,12 @@ export {
1174
1196
  P as Created,
1175
1197
  S as DebugService,
1176
1198
  D as Forbidden,
1177
- H as Found,
1178
- $ as NoContent,
1199
+ $ as Found,
1200
+ H as NoContent,
1179
1201
  C as NotFound,
1180
1202
  B as NotImplemented,
1181
1203
  ns as SchemaValidator,
1182
- x as ServerError,
1204
+ m as ServerError,
1183
1205
  A as Success,
1184
1206
  q as Unauthorized,
1185
1207
  N as UnprocessableEntity,
@@ -1189,6 +1211,6 @@ export {
1189
1211
  es as errorHandler,
1190
1212
  p as flushDebugLogs,
1191
1213
  V as formParse,
1192
- m as getCaller,
1214
+ x as getCaller,
1193
1215
  ts as getScopedParams
1194
1216
  };
@@ -1,15 +1,10 @@
1
- (function(a,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a["@arkyn/server"]={}))})(this,function(a){"use strict";var es=Object.defineProperty;var ts=(a,c,g)=>c in a?es(a,c,{enumerable:!0,configurable:!0,writable:!0,value:g}):a[c]=g;var r=(a,c,g)=>ts(a,typeof c!="symbol"?c+"":c,g);function c(n){var s;if(process.env.NODE_ENV==="development"||((s=process.env)==null?void 0:s.SHOW_ERRORS_IN_CONSOLE)==="true"){const u=`${{yellow:"\x1B[33m",cyan:"\x1B[36m",red:"\x1B[31m",green:"\x1B[32m"}[n.scheme]}[${n.name}]\x1B[0m`;let l=`
2
- `;n.debugs.forEach(d=>{l+=`${u} ${d.trim()}
3
- `}),console.log(l)}}const g={};class N{static setIgnoreFile(t){this.ignoreFiles.push(t)}static clearIgnoreFiles(){this.ignoreFiles=[]}}r(N,"ignoreFiles",[]);function R(){const n=process.cwd(),e=(new Error().stack||"").split(`
4
- `).map(i=>i.trim()),o=N.ignoreFiles;let u=2;for(;u<e.length&&(e[u].includes("node:internal")||e[u].includes("/node_modules/"));)u++;if(o.length>0)for(;u<e.length&&o.some(i=>e[u].includes(i));)u++;const l=e[u]||"";let d="Unknown function",h="Unknown caller";const y=l.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);if(y)d=y[1],h=y[2];else{const i=l.match(/at\s+(.+)/);if(i){h=i[1];const p=h.match(/at\s+([^(\s]+)\s+/);p&&p[1]!=="new"&&(d=p[1])}}h.includes("(")&&(h=h.substring(h.indexOf("(")+1,h.lastIndexOf(")"))),h=h.split(":").slice(0,-2).join(":");try{h=g.relative(n,h)}catch{}return{functionName:d,callerInfo:h}}class f{onDebug(t,s,e){const o=[],{callerInfo:u,functionName:l}=R();o.push(`${t} initialized
5
- `),o.push(`Caller Function: ${l}
6
- `),o.push(`Caller Location: ${u}
7
- `),o.push(`Body: ${JSON.stringify(s,null,2)}
8
- `),e&&o.push(`Cause: ${JSON.stringify(e,null,2)}
9
- `),c({scheme:"red",name:"ARKYN-BAD-RESPONSE-DEBUG",debugs:o})}}class O extends f{constructor(s,e){super();r(this,"body");r(this,"cause");r(this,"status",502);r(this,"statusText");this.body={name:"BadGateway",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug("BadGateway",this.body,this.cause)}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class x extends f{constructor(s,e){super();r(this,"body");r(this,"cause");r(this,"status",400);r(this,"statusText");this.body={name:"BadRequest",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug("BadRequest",this.body,this.cause)}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class U extends f{constructor(s,e){super();r(this,"body");r(this,"cause");r(this,"status",409);r(this,"statusText");this.body={name:"Conflict",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug("Conflict",this.body,this.cause)}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class I extends f{constructor(s,e){super();r(this,"body");r(this,"cause");r(this,"status",403);r(this,"statusText");this.body={name:"Forbidden",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug("Forbidden",this.body,this.cause)}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class k extends f{constructor(s,e){super();r(this,"body");r(this,"cause");r(this,"status",404);r(this,"statusText");this.body={name:"NotFound",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug("NotFound",this.body,this.cause)}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class j extends f{constructor(s,e){super();r(this,"body");r(this,"cause");r(this,"status",501);r(this,"statusText");this.body={name:"NotImplemented",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug("NotImplemented",this.body,this.cause)}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class S extends f{constructor(s,e){super();r(this,"body");r(this,"cause");r(this,"status",500);r(this,"statusText");this.body={name:"ServerError",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug("ServerError",this.body,this.cause)}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class C extends f{constructor(s,e){super();r(this,"body");r(this,"cause");r(this,"status",401);r(this,"statusText");this.body={name:"Unauthorized",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug("Unauthorized",this.body,this.cause)}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class w extends f{constructor(s){super();r(this,"body");r(this,"status",422);r(this,"statusText");this.statusText=s.message||"Unprocessable Entity",this.body={name:"UnprocessableEntity",message:s.message||null,data:s.data,fieldErrors:s.fieldErrors,fields:s.fields},this.onDebug("UnprocessableEntity",s.message||null,s.fieldErrors||null)}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class b{onDebug(t,s,e){const o=[],{callerInfo:u,functionName:l}=R();o.push(`${t} initialized
10
- `),o.push(`Caller Function: ${l}
11
- `),o.push(`Caller Location: ${u}
12
- `),o.push(`Body: ${JSON.stringify(s,null,2)}
13
- `),e&&o.push(`Cause: ${JSON.stringify(e,null,2)}
14
- `),c({scheme:"green",name:"ARKYN-SUCCESS-RESPONSE-DEBUG",debugs:o})}}class J extends b{constructor(s,e){super();r(this,"body");r(this,"headers");r(this,"status");r(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class D extends b{constructor(s,e){super();r(this,"body");r(this,"headers");r(this,"status");r(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class B extends b{constructor(s){super();r(this,"headers");r(this,"status");r(this,"statusText");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)}toResponse(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return new Response(null,s)}}class q extends b{constructor(s,e){super();r(this,"body");r(this,"headers");r(this,"status");r(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class P extends b{constructor(s,e){super();r(this,"body");r(this,"headers");r(this,"status");r(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class H{static mapHeaders(t){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),{}):{}}static mapQueryParams(t){const s={};return t.forEach((e,o)=>{s[o]=e}),s}static handle(t){return{rawUrl:t.url,status:t.status,method:t.method,token:null,elapsedTime:t.elapsedTime,requestHeaders:this.mapHeaders(t.requestHeaders),requestBody:t.requestBody||null,queryParams:this.mapQueryParams(t.queryParams),responseHeaders:this.mapHeaders(t.responseHeaders),responseBody:t.responseBody||null}}}class E{static setArkynConfig(t){if(this.arkynConfig)return;let e=t.arkynLogBaseApiUrl||"https://logs-arkyn-flow-logs.vw6wo7.easypanel.host";e=e+"/http-traffic-records/:trafficSourceId",this.arkynConfig={arkynTrafficSourceId:t.arkynTrafficSourceId,arkynUserToken:t.arkynUserToken,arkynApiUrl:e}}static getArkynConfig(){return this.arkynConfig}static resetArkynConfig(){this.arkynConfig=void 0}}r(E,"arkynConfig");async function L(n){const t=E.getArkynConfig();if(!t)return;const{arkynUserToken:s,arkynApiUrl:e}=t,{elapsedTime:o,method:u,queryParams:l,requestBody:d,requestHeaders:h,responseBody:y,responseHeaders:i,status:p,token:ns,rawUrl:Z}=n;if(process.env.NODE_ENV!=="development")try{const T=new URL(Z);let A="HTTPS";T.protocol==="http:"&&(A="HTTP");const ss=JSON.stringify({domainUrl:T.protocol+"//"+T.host,pathnameUrl:T.pathname,status:p,protocol:A,method:u,trafficUserId:null,elapsedTime:o,requestHeaders:h,requestBody:d,queryParams:l,responseHeaders:i,responseBody:y});await fetch(e.replace(":trafficSourceId",t.arkynTrafficSourceId),{method:"POST",body:ss,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(T){c({debugs:[`Error sending request: ${T}`],name:"ARKYN_LOG_ERROR",scheme:"red"})}}async function m(n,t,s={},e){const o={POST:"Resource created successfully",PUT:"Resource updated successfully",DELETE:"Resource deleted successfully",PATCH:"Resource patched successfully",GET:"Request successful"};try{const u=performance.now(),l={...s,"Content-Type":"application/json"},d=await fetch(t,{method:n,headers:l,body:e?JSON.stringify(e):void 0}),h=performance.now()-u,y=d.status;let i=null;try{i=await d.json()}catch{i=null}const p=H.handle({elapsedTime:h,method:n,queryParams:new URL(t).searchParams,requestHeaders:l,requestBody:e,responseBody:i,responseHeaders:d.headers,status:y,url:t});return L(p),d.ok?{success:!0,status:y,message:(i==null?void 0:i.message)||o[n],response:i,cause:null}:{success:!1,status:y,message:(i==null?void 0:i.message)||d.statusText||"Request failed",response:i,cause:null}}catch(u){return c({debugs:[`Network error or request failed: ${u}`],name:"ARKYN_MAKE_REQUEST_ERROR",scheme:"red"}),{success:!1,status:0,message:"Network error or request failed",response:null,cause:u instanceof Error?u.message:String(u)}}}async function $(n,t={},s){return m("DELETE",n,t,s)}async function F(n,t={}){return m("GET",n,t)}async function M(n,t={},s){return m("PATCH",n,t,s)}async function _(n,t={},s){return m("POST",n,t,s)}async function z(n,t={},s){return m("PUT",n,t,s)}class G{constructor(t){r(this,"baseUrl");r(this,"baseHeaders");r(this,"baseToken");r(this,"enableDebug");this.baseUrl=t.baseUrl,this.baseHeaders=t.baseHeaders||void 0,this.baseToken=t.baseToken||void 0,this.enableDebug=t.enableDebug||!1}onDebug(t,s,e){if(this.enableDebug){const o=[];o.push(`Base URL: ${this.baseUrl}`),o.push(`Endpoint: ${t}`),o.push(`Method: ${s}`),e[0]&&o.push(`Headers: ${JSON.stringify(e[0])}`),e[1]&&o.push(`Body: ${JSON.stringify(e[1])}`),c({debugs:o,name:"ARKYN-API-DEBUG",scheme:"yellow"})}}generateURL(t){return this.baseUrl+t}generateHeaders(t,s){let e={};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}async get(t,s){const e=this.generateURL(t),o=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token);return this.onDebug(t,"get",[o]),await F(e,o)}async post(t,s){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;return this.onDebug(t,"post",[o,u]),await _(e,o,u)}async put(t,s){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;return this.onDebug(t,"put",[o,u]),await z(e,o,u)}async patch(t,s){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;return this.onDebug(t,"patch",[o,u]),await M(e,o,u)}async delete(t,s){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;return this.onDebug(t,"delete",[o,u]),await $(e,o,u)}}function K(n,t){var s,e,o;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"}const V=async n=>{let t;const s=await n.arrayBuffer(),e=new TextDecoder().decode(s);try{t=JSON.parse(e)}catch{try{if(e.includes("=")){const u=new URLSearchParams(e);t=Object.fromEntries(u.entries())}else throw new x("Invalid URLSearchParams format")}catch{throw new x("Failed to extract data from request")}}return t};function Y(n){switch(!0){case n instanceof Response:return n;case n instanceof D:return n.toResponse();case n instanceof J:return n.toResponse();case n instanceof P:return n.toResponse();case n instanceof q:return n.toResponse();case n instanceof B:return n.toResponse()}switch(!0){case n instanceof O:return n.toResponse();case n instanceof x:return n.toResponse();case n instanceof U:return n.toResponse();case n instanceof I:return n.toResponse();case n instanceof k:return n.toResponse();case n instanceof j:return n.toResponse();case n instanceof S:return n.toResponse();case n instanceof C:return n.toResponse();case n instanceof w:return n.toResponse()}return new S("Server error",n).toResponse()}function v([n,t]){const s=t.safeParse(n);if(s.success===!1){const e=Object.fromEntries(s.error.issues.map(o=>[o.path.join("."),o.message]));return{success:s.success,fieldErrors:e,fields:n}}else return{success:s.success,data:s.data}}const Q=(n,t="")=>{const s=new URL(n.url);if(t==="")return s.searchParams;const e=Array.from(s.searchParams.entries()).filter(([o])=>o.startsWith(`${t}:`)).map(([o,u])=>[o.replace(`${t}:`,""),u]);return new URLSearchParams(e)};function W(n){const t="Error validating:",s=n.issues.map(({path:e,message:o})=>`-> ${e.join(".")}: ${o}`);return[t,...s].join(`
15
- `)}class X{constructor(t){r(this,"functionName");r(this,"callerInfo");this.schema=t;const{callerInfo:s,functionName:e}=R();this.callerInfo=s,this.functionName=e}isValid(t){return this.schema.safeParse(t).success}safeValidate(t){return this.schema.safeParse(t)}validate(t){try{return this.schema.parse(t)}catch(s){throw new S(W(s))}}formValidate(t,s){const e=v([t,this.schema]);if(!e.success){const o=Object.keys(e.fieldErrors)[0];throw new w({fields:e.fields,fieldErrors:e.fieldErrors,data:{scrollTo:o},message:s})}return e.data}}a.ApiService=G,a.ArkynLogService=E,a.BadGateway=O,a.BadRequest=x,a.Conflict=U,a.Created=J,a.DebugService=N,a.Forbidden=I,a.Found=D,a.NoContent=B,a.NotFound=k,a.NotImplemented=j,a.SchemaValidator=X,a.ServerError=S,a.Success=q,a.Unauthorized=C,a.UnprocessableEntity=w,a.Updated=P,a.decodeErrorMessageFromRequest=K,a.decodeRequestBody=V,a.errorHandler=Y,a.flushDebugLogs=c,a.formParse=v,a.getCaller=R,a.getScopedParams=Q,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
1
+ (function(a,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(a=typeof globalThis<"u"?globalThis:a||self,l(a["@arkyn/server"]={}))})(this,function(a){"use strict";var es=Object.defineProperty;var ts=(a,l,g)=>l in a?es(a,l,{enumerable:!0,configurable:!0,writable:!0,value:g}):a[l]=g;var o=(a,l,g)=>ts(a,typeof l!="symbol"?l+"":l,g);function l(n){var s;if(process.env.NODE_ENV==="development"||((s=process.env)==null?void 0:s.SHOW_ERRORS_IN_CONSOLE)==="true"){const u=`${{yellow:"\x1B[33m",cyan:"\x1B[36m",red:"\x1B[31m",green:"\x1B[32m"}[n.scheme]}[${n.name}]\x1B[0m`;let c=`
2
+ `;n.debugs.forEach(d=>{c+=`${u} ${d.trim()}
3
+ `}),console.log(c)}}const g={};class N{static setIgnoreFile(t){this.ignoreFiles.push(t)}static clearIgnoreFiles(){this.ignoreFiles=[]}}o(N,"ignoreFiles",[]);function R(){const n=process.cwd(),e=(new Error().stack||"").split(`
4
+ `).map(i=>i.trim()),r=N.ignoreFiles;let u=2;for(;u<e.length&&(e[u].includes("node:internal")||e[u].includes("/node_modules/"));)u++;if(r.length>0)for(;u<e.length&&r.some(i=>e[u].includes(i));)u++;const c=e[u]||"";let d="Unknown function",h="Unknown caller";const f=c.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);if(f)d=f[1],h=f[2];else{const i=c.match(/at\s+(.+)/);if(i){h=i[1];const p=h.match(/at\s+([^(\s]+)\s+/);p&&p[1]!=="new"&&(d=p[1])}}h.includes("(")&&(h=h.substring(h.indexOf("(")+1,h.lastIndexOf(")"))),h=h.split(":").slice(0,-2).join(":");try{h=g.relative(n,h)}catch{}return{functionName:d,callerInfo:h}}class y{onDebug(t){const{name:s,body:e,cause:r,message:u}=t,c=[],{callerInfo:d,functionName:h}=R();c.push(`${s} initialized`),c.push(`Caller Function: ${h}`),c.push(`Caller Location: ${d}`),u&&c.push(`Message: ${u}`),e&&c.push(`Body: ${JSON.stringify(e,null,2)}`),r&&c.push(`Cause: ${JSON.stringify(r,null,2)}`),l({scheme:"red",name:"ARKYN-BAD-RESPONSE-DEBUG",debugs:c})}}class O extends y{constructor(s,e){super();o(this,"body");o(this,"cause");o(this,"status",502);o(this,"statusText");this.body={name:"BadGateway",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug({name:"BadGateway",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class x extends y{constructor(s,e){super();o(this,"body");o(this,"cause");o(this,"status",400);o(this,"statusText");this.body={name:"BadRequest",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug({name:"BadRequest",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class U extends y{constructor(s,e){super();o(this,"body");o(this,"cause");o(this,"status",409);o(this,"statusText");this.body={name:"Conflict",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug({name:"Conflict",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class I extends y{constructor(s,e){super();o(this,"body");o(this,"cause");o(this,"status",403);o(this,"statusText");this.body={name:"Forbidden",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug({name:"Forbidden",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class k extends y{constructor(s,e){super();o(this,"body");o(this,"cause");o(this,"status",404);o(this,"statusText");this.body={name:"NotFound",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug({name:"NotFound",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class j extends y{constructor(s,e){super();o(this,"body");o(this,"cause");o(this,"status",501);o(this,"statusText");this.body={name:"NotImplemented",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug({name:"NotImplemented",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class S extends y{constructor(s,e){super();o(this,"body");o(this,"cause");o(this,"status",500);o(this,"statusText");this.body={name:"ServerError",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug({name:"ServerError",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class C extends y{constructor(s,e){super();o(this,"body");o(this,"cause");o(this,"status",401);o(this,"statusText");this.body={name:"Unauthorized",message:s},this.statusText=s,this.cause=e?JSON.stringify(e):void 0,this.onDebug({name:"Unauthorized",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class w extends y{constructor(s){super();o(this,"body");o(this,"status",422);o(this,"statusText");this.statusText=s.message||"Unprocessable Entity",this.body={name:"UnprocessableEntity",message:s.message||null,data:s.data,fieldErrors:s.fieldErrors,fields:s.fields},this.onDebug({name:"UnprocessableEntity",cause:s.fieldErrors,message:s.message})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class T{onDebug(t,s,e){const r=[],{callerInfo:u,functionName:c}=R();r.push(`${t} initialized
5
+ `),r.push(`Caller Function: ${c}
6
+ `),r.push(`Caller Location: ${u}
7
+ `),r.push(`Body: ${JSON.stringify(s,null,2)}
8
+ `),e&&r.push(`Cause: ${JSON.stringify(e,null,2)}
9
+ `),l({scheme:"green",name:"ARKYN-SUCCESS-RESPONSE-DEBUG",debugs:r})}}class J extends T{constructor(s,e){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class D extends T{constructor(s,e){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class B extends T{constructor(s){super();o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return new Response(null,s)}}class q extends T{constructor(s,e){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class P extends T{constructor(s,e){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class H{static mapHeaders(t){return t instanceof Headers?Object.fromEntries(t.entries()):typeof t=="object"?Object.entries(t).reduce((s,[e,r])=>(typeof r=="string"?s[e]=r:Array.isArray(r)?s[e]=r.join(", "):s[e]=JSON.stringify(r),s),{}):{}}static mapQueryParams(t){const s={};return t.forEach((e,r)=>{s[r]=e}),s}static handle(t){return{rawUrl:t.url,status:t.status,method:t.method,token:null,elapsedTime:t.elapsedTime,requestHeaders:this.mapHeaders(t.requestHeaders),requestBody:t.requestBody||null,queryParams:this.mapQueryParams(t.queryParams),responseHeaders:this.mapHeaders(t.responseHeaders),responseBody:t.responseBody||null}}}class E{static setArkynConfig(t){if(this.arkynConfig)return;let e=t.arkynLogBaseApiUrl||"https://logs-arkyn-flow-logs.vw6wo7.easypanel.host";e=e+"/http-traffic-records/:trafficSourceId",this.arkynConfig={arkynTrafficSourceId:t.arkynTrafficSourceId,arkynUserToken:t.arkynUserToken,arkynApiUrl:e}}static getArkynConfig(){return this.arkynConfig}static resetArkynConfig(){this.arkynConfig=void 0}}o(E,"arkynConfig");async function L(n){const t=E.getArkynConfig();if(!t)return;const{arkynUserToken:s,arkynApiUrl:e}=t,{elapsedTime:r,method:u,queryParams:c,requestBody:d,requestHeaders:h,responseBody:f,responseHeaders:i,status:p,token:ns,rawUrl:Z}=n;if(process.env.NODE_ENV!=="development")try{const b=new URL(Z);let A="HTTPS";b.protocol==="http:"&&(A="HTTP");const ss=JSON.stringify({domainUrl:b.protocol+"//"+b.host,pathnameUrl:b.pathname,status:p,protocol:A,method:u,trafficUserId:null,elapsedTime:r,requestHeaders:h,requestBody:d,queryParams:c,responseHeaders:i,responseBody:f});await fetch(e.replace(":trafficSourceId",t.arkynTrafficSourceId),{method:"POST",body:ss,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(b){l({debugs:[`Error sending request: ${b}`],name:"ARKYN_LOG_ERROR",scheme:"red"})}}async function m(n,t,s={},e){const r={POST:"Resource created successfully",PUT:"Resource updated successfully",DELETE:"Resource deleted successfully",PATCH:"Resource patched successfully",GET:"Request successful"};try{const u=performance.now(),c={...s,"Content-Type":"application/json"},d=await fetch(t,{method:n,headers:c,body:e?JSON.stringify(e):void 0}),h=performance.now()-u,f=d.status;let i=null;try{i=await d.json()}catch{i=null}const p=H.handle({elapsedTime:h,method:n,queryParams:new URL(t).searchParams,requestHeaders:c,requestBody:e,responseBody:i,responseHeaders:d.headers,status:f,url:t});return L(p),d.ok?{success:!0,status:f,message:(i==null?void 0:i.message)||r[n],response:i,cause:null}:{success:!1,status:f,message:(i==null?void 0:i.message)||d.statusText||"Request failed",response:i,cause:null}}catch(u){return l({debugs:[`Network error or request failed: ${u}`],name:"ARKYN_MAKE_REQUEST_ERROR",scheme:"red"}),{success:!1,status:0,message:"Network error or request failed",response:null,cause:u instanceof Error?u.message:String(u)}}}async function $(n,t={},s){return m("DELETE",n,t,s)}async function F(n,t={}){return m("GET",n,t)}async function M(n,t={},s){return m("PATCH",n,t,s)}async function _(n,t={},s){return m("POST",n,t,s)}async function z(n,t={},s){return m("PUT",n,t,s)}class G{constructor(t){o(this,"baseUrl");o(this,"baseHeaders");o(this,"baseToken");o(this,"enableDebug");this.baseUrl=t.baseUrl,this.baseHeaders=t.baseHeaders||void 0,this.baseToken=t.baseToken||void 0,this.enableDebug=t.enableDebug||!1}onDebug(t,s,e){if(this.enableDebug){const r=[];r.push(`Base URL: ${this.baseUrl}`),r.push(`Endpoint: ${t}`),r.push(`Method: ${s}`),e[0]&&r.push(`Headers: ${JSON.stringify(e[0])}`),e[1]&&r.push(`Body: ${JSON.stringify(e[1])}`),l({debugs:r,name:"ARKYN-API-DEBUG",scheme:"yellow"})}}generateURL(t){return this.baseUrl+t}generateHeaders(t,s){let e={};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}async get(t,s){const e=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token);return this.onDebug(t,"get",[r]),await F(e,r)}async post(t,s){const e=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token),u=s==null?void 0:s.body;return this.onDebug(t,"post",[r,u]),await _(e,r,u)}async put(t,s){const e=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token),u=s==null?void 0:s.body;return this.onDebug(t,"put",[r,u]),await z(e,r,u)}async patch(t,s){const e=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token),u=s==null?void 0:s.body;return this.onDebug(t,"patch",[r,u]),await M(e,r,u)}async delete(t,s){const e=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token),u=s==null?void 0:s.body;return this.onDebug(t,"delete",[r,u]),await $(e,r,u)}}function K(n,t){var s,e,r;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"?(r=n==null?void 0:n.error)==null?void 0:r.message:t!=null&&t.statusText&&typeof(t==null?void 0:t.statusText)=="string"?t==null?void 0:t.statusText:"Missing error message"}const V=async n=>{let t;const s=await n.arrayBuffer(),e=new TextDecoder().decode(s);try{t=JSON.parse(e)}catch{try{if(e.includes("=")){const u=new URLSearchParams(e);t=Object.fromEntries(u.entries())}else throw new x("Invalid URLSearchParams format")}catch{throw new x("Failed to extract data from request")}}return t};function Y(n){switch(!0){case n instanceof Response:return n;case n instanceof D:return n.toResponse();case n instanceof J:return n.toResponse();case n instanceof P:return n.toResponse();case n instanceof q:return n.toResponse();case n instanceof B:return n.toResponse()}switch(!0){case n instanceof O:return n.toResponse();case n instanceof x:return n.toResponse();case n instanceof U:return n.toResponse();case n instanceof I:return n.toResponse();case n instanceof k:return n.toResponse();case n instanceof j:return n.toResponse();case n instanceof S:return n.toResponse();case n instanceof C:return n.toResponse();case n instanceof w:return n.toResponse()}return new S("Server error",n).toResponse()}function v([n,t]){const s=t.safeParse(n);if(s.success===!1){const e=Object.fromEntries(s.error.issues.map(r=>[r.path.join("."),r.message]));return{success:s.success,fieldErrors:e,fields:n}}else return{success:s.success,data:s.data}}const Q=(n,t="")=>{const s=new URL(n.url);if(t==="")return s.searchParams;const e=Array.from(s.searchParams.entries()).filter(([r])=>r.startsWith(`${t}:`)).map(([r,u])=>[r.replace(`${t}:`,""),u]);return new URLSearchParams(e)};function W(n){const t="Error validating:",s=n.issues.map(({path:e,message:r})=>`-> ${e.join(".")}: ${r}`);return[t,...s].join(`
10
+ `)}class X{constructor(t){o(this,"functionName");o(this,"callerInfo");this.schema=t;const{callerInfo:s,functionName:e}=R();this.callerInfo=s,this.functionName=e}isValid(t){return this.schema.safeParse(t).success}safeValidate(t){return this.schema.safeParse(t)}validate(t){try{return this.schema.parse(t)}catch(s){throw new S(W(s))}}formValidate(t,s){const e=v([t,this.schema]);if(!e.success){const r=Object.keys(e.fieldErrors)[0];throw new w({fields:e.fields,fieldErrors:e.fieldErrors,data:{scrollTo:r},message:s})}return e.data}}a.ApiService=G,a.ArkynLogService=E,a.BadGateway=O,a.BadRequest=x,a.Conflict=U,a.Created=J,a.DebugService=N,a.Forbidden=I,a.Found=D,a.NoContent=B,a.NotFound=k,a.NotImplemented=j,a.SchemaValidator=X,a.ServerError=S,a.Success=q,a.Unauthorized=C,a.UnprocessableEntity=w,a.Updated=P,a.decodeErrorMessageFromRequest=K,a.decodeRequestBody=V,a.errorHandler=Y,a.flushDebugLogs=l,a.formParse=v,a.getCaller=R,a.getScopedParams=Q,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
@@ -1,22 +1,11 @@
1
- /**
2
- * Base class for handling bad HTTP responses with debugging capabilities.
3
- * Provides logging functionality to track response errors and their context.
4
- */
1
+ type Input = {
2
+ name: string;
3
+ body?: any;
4
+ cause?: any;
5
+ message?: string;
6
+ };
5
7
  declare class BadResponse {
6
- /**
7
- * Logs debug information for bad responses including caller context and response details.
8
- *
9
- * @param name - The name/type of the bad response being logged
10
- * @param body - The response body or error data to be logged
11
- * @param cause - Optional additional cause information for the error
12
- *
13
- * @example
14
- * ```typescript
15
- * const badResponse = new BadResponse();
16
- * badResponse.onDebug("ValidationError", { field: "email", message: "Invalid format" });
17
- * ```
18
- */
19
- onDebug(name: string, body: any, cause?: any): void;
8
+ onDebug(input: Input): void;
20
9
  }
21
10
  export { BadResponse };
22
11
  //# sourceMappingURL=_badResponse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_badResponse.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/_badResponse.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,cAAM,WAAW;IACf;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG;CAY7C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"_badResponse.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/_badResponse.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,cAAM,WAAW;IACf,OAAO,CAAC,KAAK,EAAE,KAAK;CAgBrB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,32 +1,19 @@
1
1
  import { flushDebugLogs } from "../../services/flushDebugLogs";
2
2
  import { getCaller } from "../../services/getCaller";
3
- /**
4
- * Base class for handling bad HTTP responses with debugging capabilities.
5
- * Provides logging functionality to track response errors and their context.
6
- */
7
3
  class BadResponse {
8
- /**
9
- * Logs debug information for bad responses including caller context and response details.
10
- *
11
- * @param name - The name/type of the bad response being logged
12
- * @param body - The response body or error data to be logged
13
- * @param cause - Optional additional cause information for the error
14
- *
15
- * @example
16
- * ```typescript
17
- * const badResponse = new BadResponse();
18
- * badResponse.onDebug("ValidationError", { field: "email", message: "Invalid format" });
19
- * ```
20
- */
21
- onDebug(name, body, cause) {
4
+ onDebug(input) {
5
+ const { name, body, cause, message } = input;
22
6
  const debugs = [];
23
7
  const { callerInfo, functionName } = getCaller();
24
- debugs.push(`${name} initialized\n`);
25
- debugs.push(`Caller Function: ${functionName}\n`);
26
- debugs.push(`Caller Location: ${callerInfo}\n`);
27
- debugs.push(`Body: ${JSON.stringify(body, null, 2)}\n`);
8
+ debugs.push(`${name} initialized`);
9
+ debugs.push(`Caller Function: ${functionName}`);
10
+ debugs.push(`Caller Location: ${callerInfo}`);
11
+ if (message)
12
+ debugs.push(`Message: ${message}`);
13
+ if (body)
14
+ debugs.push(`Body: ${JSON.stringify(body, null, 2)}`);
28
15
  if (cause)
29
- debugs.push(`Cause: ${JSON.stringify(cause, null, 2)}\n`);
16
+ debugs.push(`Cause: ${JSON.stringify(cause, null, 2)}`);
30
17
  flushDebugLogs({ scheme: "red", name: "ARKYN-BAD-RESPONSE-DEBUG", debugs });
31
18
  }
32
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"badGateway.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badGateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,UAAW,SAAQ,WAAW;IAClC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAUxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"badGateway.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badGateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,UAAW,SAAQ,WAAW;IAClC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -20,7 +20,12 @@ class BadGateway extends BadResponse {
20
20
  this.body = { name: "BadGateway", message: message };
21
21
  this.statusText = message;
22
22
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug("BadGateway", this.body, this.cause);
23
+ this.onDebug({
24
+ name: "BadGateway",
25
+ body: this.body,
26
+ cause: this.cause,
27
+ message: this.statusText,
28
+ });
24
29
  }
25
30
  /**
26
31
  * Converts the `BadGateway` instance into a `Response` object with a JSON body.
@@ -1 +1 @@
1
- {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,UAAW,SAAQ,WAAW;IAClC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAUxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,UAAW,SAAQ,WAAW;IAClC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -20,7 +20,12 @@ class BadRequest extends BadResponse {
20
20
  this.body = { name: "BadRequest", message: message };
21
21
  this.statusText = message;
22
22
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug("BadRequest", this.body, this.cause);
23
+ this.onDebug({
24
+ name: "BadRequest",
25
+ body: this.body,
26
+ cause: this.cause,
27
+ message: this.statusText,
28
+ });
24
29
  }
25
30
  /**
26
31
  * Converts the `BadRequest` instance into a `Response` object with a JSON body.
@@ -1 +1 @@
1
- {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/conflict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,QAAS,SAAQ,WAAW;IAChC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAUxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/conflict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,QAAS,SAAQ,WAAW;IAChC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -20,7 +20,12 @@ class Conflict extends BadResponse {
20
20
  this.body = { name: "Conflict", message: message };
21
21
  this.statusText = message;
22
22
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug("Conflict", this.body, this.cause);
23
+ this.onDebug({
24
+ name: "Conflict",
25
+ body: this.body,
26
+ cause: this.cause,
27
+ message: this.statusText,
28
+ });
24
29
  }
25
30
  /**
26
31
  * Converts the `Conflict` instance into a `Response` object with a JSON body.
@@ -1 +1 @@
1
- {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/forbidden.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,SAAU,SAAQ,WAAW;IACjC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAUxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/forbidden.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,SAAU,SAAQ,WAAW;IACjC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -20,7 +20,12 @@ class Forbidden extends BadResponse {
20
20
  this.body = { name: "Forbidden", message: message };
21
21
  this.statusText = message;
22
22
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug("Forbidden", this.body, this.cause);
23
+ this.onDebug({
24
+ name: "Forbidden",
25
+ body: this.body,
26
+ cause: this.cause,
27
+ message: this.statusText,
28
+ });
24
29
  }
25
30
  /**
26
31
  * Converts the `Forbidden` instance into a `Response` object with a JSON body.
@@ -1 +1 @@
1
- {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notFound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,QAAS,SAAQ,WAAW;IAChC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAUxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notFound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,QAAS,SAAQ,WAAW;IAChC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -20,7 +20,12 @@ class NotFound extends BadResponse {
20
20
  this.body = { name: "NotFound", message: message };
21
21
  this.statusText = message;
22
22
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug("NotFound", this.body, this.cause);
23
+ this.onDebug({
24
+ name: "NotFound",
25
+ body: this.body,
26
+ cause: this.cause,
27
+ message: this.statusText,
28
+ });
24
29
  }
25
30
  /**
26
31
  * Converts the `NotFound` instance into a `Response` object with a JSON body.
@@ -1 +1 @@
1
- {"version":3,"file":"notImplemented.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notImplemented.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,cAAe,SAAQ,WAAW;IACtC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAUxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"notImplemented.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notImplemented.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,cAAe,SAAQ,WAAW;IACtC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -20,7 +20,12 @@ class NotImplemented extends BadResponse {
20
20
  this.body = { name: "NotImplemented", message: message };
21
21
  this.statusText = message;
22
22
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug("NotImplemented", this.body, this.cause);
23
+ this.onDebug({
24
+ name: "NotImplemented",
25
+ body: this.body,
26
+ cause: this.cause,
27
+ message: this.statusText,
28
+ });
24
29
  }
25
30
  /**
26
31
  * Converts the `NotImplemented` instance into a `Response` object with a JSON body.
@@ -1 +1 @@
1
- {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,WAAY,SAAQ,WAAW;IACnC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAUxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,WAAY,SAAQ,WAAW;IACnC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -20,7 +20,12 @@ class ServerError extends BadResponse {
20
20
  this.body = { name: "ServerError", message: message };
21
21
  this.statusText = message;
22
22
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug("ServerError", this.body, this.cause);
23
+ this.onDebug({
24
+ name: "ServerError",
25
+ body: this.body,
26
+ cause: this.cause,
27
+ message: this.statusText,
28
+ });
24
29
  }
25
30
  /**
26
31
  * Converts the `ServerError` instance into a `Response` object with a JSON body.
@@ -1 +1 @@
1
- {"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,YAAa,SAAQ,WAAW;IACpC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAUxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,YAAa,SAAQ,WAAW;IACpC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -20,7 +20,12 @@ class Unauthorized extends BadResponse {
20
20
  this.body = { name: "Unauthorized", message: message };
21
21
  this.statusText = message;
22
22
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug("Unauthorized", this.body, this.cause);
23
+ this.onDebug({
24
+ name: "Unauthorized",
25
+ body: this.body,
26
+ cause: this.cause,
27
+ message: this.statusText,
28
+ });
24
29
  }
25
30
  /**
26
31
  * Converts the `Unauthorized` instance into a `Response` object with a JSON body.
@@ -28,7 +28,11 @@ class UnprocessableEntity extends BadResponse {
28
28
  fieldErrors: props.fieldErrors,
29
29
  fields: props.fields,
30
30
  };
31
- this.onDebug("UnprocessableEntity", props.message || null, props.fieldErrors || null);
31
+ this.onDebug({
32
+ name: "UnprocessableEntity",
33
+ cause: props.fieldErrors,
34
+ message: props.message,
35
+ });
32
36
  }
33
37
  /**
34
38
  * Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "3.0.1-beta.68",
3
+ "version": "3.0.1-beta.69",
4
4
  "author": "Arkyn | Lucas Gonçalves",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/bundle.js",