@arkyn/server 3.0.1-beta.116 → 3.0.1-beta.118

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 (178) hide show
  1. package/dist/bundle.js +721 -734
  2. package/dist/bundle.umd.cjs +5 -10
  3. package/dist/{api/arkynLogRequest.d.ts → http/api/_logRequest.d.ts} +22 -19
  4. package/dist/{api/arkynLogRequest.d.ts.map → http/api/_logRequest.d.ts.map} +1 -1
  5. package/dist/{api/arkynLogRequest.js → http/api/_logRequest.js} +30 -30
  6. package/dist/http/api/_makeRequest.d.ts +61 -0
  7. package/dist/http/api/_makeRequest.d.ts.map +1 -0
  8. package/dist/{api/makeRequest.js → http/api/_makeRequest.js} +29 -20
  9. package/dist/http/api/deleteRequest.d.ts +17 -0
  10. package/dist/http/api/deleteRequest.d.ts.map +1 -0
  11. package/dist/http/api/deleteRequest.js +18 -0
  12. package/dist/http/api/getRequest.d.ts +16 -0
  13. package/dist/http/api/getRequest.d.ts.map +1 -0
  14. package/dist/http/api/getRequest.js +17 -0
  15. package/dist/http/api/patchRequest.d.ts +17 -0
  16. package/dist/http/api/patchRequest.d.ts.map +1 -0
  17. package/dist/http/api/patchRequest.js +18 -0
  18. package/dist/http/api/postRequest.d.ts +17 -0
  19. package/dist/http/api/postRequest.d.ts.map +1 -0
  20. package/dist/http/api/postRequest.js +18 -0
  21. package/dist/http/api/putRequest.d.ts +17 -0
  22. package/dist/http/api/putRequest.d.ts.map +1 -0
  23. package/dist/http/api/putRequest.js +18 -0
  24. package/dist/http/badResponses/_badResponse.d.ts +18 -7
  25. package/dist/http/badResponses/_badResponse.d.ts.map +1 -1
  26. package/dist/http/badResponses/_badResponse.js +44 -13
  27. package/dist/http/badResponses/badGateway.d.ts +4 -8
  28. package/dist/http/badResponses/badGateway.d.ts.map +1 -1
  29. package/dist/http/badResponses/badGateway.js +9 -17
  30. package/dist/http/badResponses/badRequest.d.ts +4 -8
  31. package/dist/http/badResponses/badRequest.d.ts.map +1 -1
  32. package/dist/http/badResponses/badRequest.js +9 -17
  33. package/dist/http/badResponses/conflict.d.ts +4 -8
  34. package/dist/http/badResponses/conflict.d.ts.map +1 -1
  35. package/dist/http/badResponses/conflict.js +9 -17
  36. package/dist/http/badResponses/forbidden.d.ts +4 -8
  37. package/dist/http/badResponses/forbidden.d.ts.map +1 -1
  38. package/dist/http/badResponses/forbidden.js +9 -17
  39. package/dist/http/badResponses/notFound.d.ts +4 -8
  40. package/dist/http/badResponses/notFound.d.ts.map +1 -1
  41. package/dist/http/badResponses/notFound.js +9 -17
  42. package/dist/http/badResponses/notImplemented.d.ts +4 -8
  43. package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
  44. package/dist/http/badResponses/notImplemented.js +9 -17
  45. package/dist/http/badResponses/serverError.d.ts +4 -8
  46. package/dist/http/badResponses/serverError.d.ts.map +1 -1
  47. package/dist/http/badResponses/serverError.js +9 -17
  48. package/dist/http/badResponses/unauthorized.d.ts +2 -6
  49. package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
  50. package/dist/http/badResponses/unauthorized.js +7 -15
  51. package/dist/http/badResponses/unprocessableEntity.d.ts +13 -18
  52. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
  53. package/dist/http/badResponses/unprocessableEntity.js +14 -22
  54. package/dist/http/successResponses/_successResponse.d.ts +18 -7
  55. package/dist/http/successResponses/_successResponse.d.ts.map +1 -1
  56. package/dist/http/successResponses/_successResponse.js +50 -21
  57. package/dist/http/successResponses/created.d.ts +8 -22
  58. package/dist/http/successResponses/created.d.ts.map +1 -1
  59. package/dist/http/successResponses/created.js +13 -25
  60. package/dist/http/successResponses/found.d.ts +9 -26
  61. package/dist/http/successResponses/found.d.ts.map +1 -1
  62. package/dist/http/successResponses/found.js +14 -29
  63. package/dist/http/successResponses/noContent.d.ts +4 -12
  64. package/dist/http/successResponses/noContent.d.ts.map +1 -1
  65. package/dist/http/successResponses/noContent.js +9 -17
  66. package/dist/http/successResponses/success.d.ts +8 -22
  67. package/dist/http/successResponses/success.d.ts.map +1 -1
  68. package/dist/http/successResponses/success.js +13 -25
  69. package/dist/http/successResponses/updated.d.ts +8 -22
  70. package/dist/http/successResponses/updated.d.ts.map +1 -1
  71. package/dist/http/successResponses/updated.js +13 -25
  72. package/dist/index.d.ts +9 -10
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +11 -12
  75. package/dist/services/apiService.d.ts +7 -28
  76. package/dist/services/apiService.d.ts.map +1 -1
  77. package/dist/services/apiService.js +35 -41
  78. package/dist/services/debugService.d.ts +16 -1
  79. package/dist/services/debugService.d.ts.map +1 -1
  80. package/dist/services/debugService.js +58 -1
  81. package/dist/services/logMapperService.d.ts +86 -0
  82. package/dist/services/logMapperService.d.ts.map +1 -0
  83. package/dist/services/logMapperService.js +68 -0
  84. package/dist/services/logService.d.ts +38 -0
  85. package/dist/services/logService.d.ts.map +1 -0
  86. package/dist/services/logService.js +40 -0
  87. package/dist/{services → utilities}/decodeRequestBody.d.ts +3 -4
  88. package/dist/utilities/decodeRequestBody.d.ts.map +1 -0
  89. package/dist/{services → utilities}/decodeRequestBody.js +5 -5
  90. package/dist/{services/decodeErrorMessageFromRequest.d.ts → utilities/decodeRequestErrorMessage.d.ts} +6 -6
  91. package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -0
  92. package/dist/{services/decodeErrorMessageFromRequest.js → utilities/decodeRequestErrorMessage.js} +5 -5
  93. package/dist/utilities/errorHandler.d.ts +50 -0
  94. package/dist/utilities/errorHandler.d.ts.map +1 -0
  95. package/dist/{services → utilities}/errorHandler.js +34 -28
  96. package/dist/utilities/flushDebugLogs.d.ts +46 -0
  97. package/dist/utilities/flushDebugLogs.d.ts.map +1 -0
  98. package/dist/utilities/flushDebugLogs.js +59 -0
  99. package/dist/{services → utilities}/formAsyncParse.d.ts +3 -3
  100. package/dist/utilities/formAsyncParse.d.ts.map +1 -0
  101. package/dist/{services → utilities}/formAsyncParse.js +3 -3
  102. package/dist/{services → utilities}/formParse.d.ts +3 -3
  103. package/dist/utilities/formParse.d.ts.map +1 -0
  104. package/dist/{services → utilities}/formParse.js +3 -3
  105. package/dist/{services → utilities}/getScopedParams.d.ts +3 -4
  106. package/dist/utilities/getScopedParams.d.ts.map +1 -0
  107. package/dist/{services → utilities}/getScopedParams.js +4 -4
  108. package/dist/{services → utilities}/schemaValidator.d.ts +3 -15
  109. package/dist/utilities/schemaValidator.d.ts.map +1 -0
  110. package/dist/{services → utilities}/schemaValidator.js +3 -19
  111. package/dist/validations/validateCep.d.ts +7 -12
  112. package/dist/validations/validateCep.d.ts.map +1 -1
  113. package/dist/validations/validateCep.js +9 -15
  114. package/dist/validations/validateCnpj.d.ts +4 -5
  115. package/dist/validations/validateCnpj.d.ts.map +1 -1
  116. package/dist/validations/validateCnpj.js +12 -5
  117. package/dist/validations/validateCpf.d.ts +3 -4
  118. package/dist/validations/validateCpf.d.ts.map +1 -1
  119. package/dist/validations/validateCpf.js +11 -4
  120. package/dist/validations/validateDate.d.ts +16 -23
  121. package/dist/validations/validateDate.d.ts.map +1 -1
  122. package/dist/validations/validateDate.js +38 -56
  123. package/dist/validations/validateEmail.d.ts +3 -4
  124. package/dist/validations/validateEmail.d.ts.map +1 -1
  125. package/dist/validations/validateEmail.js +23 -35
  126. package/dist/validations/validatePassword.d.ts +3 -4
  127. package/dist/validations/validatePassword.d.ts.map +1 -1
  128. package/dist/validations/validatePassword.js +5 -5
  129. package/dist/validations/validatePhone.d.ts +3 -4
  130. package/dist/validations/validatePhone.d.ts.map +1 -1
  131. package/dist/validations/validatePhone.js +4 -4
  132. package/dist/validations/validateRg.d.ts +3 -4
  133. package/dist/validations/validateRg.d.ts.map +1 -1
  134. package/dist/validations/validateRg.js +4 -4
  135. package/package.json +1 -1
  136. package/dist/api/deleteRequest.d.ts +0 -13
  137. package/dist/api/deleteRequest.d.ts.map +0 -1
  138. package/dist/api/deleteRequest.js +0 -14
  139. package/dist/api/getRequest.d.ts +0 -12
  140. package/dist/api/getRequest.d.ts.map +0 -1
  141. package/dist/api/getRequest.js +0 -13
  142. package/dist/api/makeRequest.d.ts +0 -38
  143. package/dist/api/makeRequest.d.ts.map +0 -1
  144. package/dist/api/patchRequest.d.ts +0 -13
  145. package/dist/api/patchRequest.d.ts.map +0 -1
  146. package/dist/api/patchRequest.js +0 -14
  147. package/dist/api/postRequest.d.ts +0 -13
  148. package/dist/api/postRequest.d.ts.map +0 -1
  149. package/dist/api/postRequest.js +0 -14
  150. package/dist/api/putRequest.d.ts +0 -13
  151. package/dist/api/putRequest.d.ts.map +0 -1
  152. package/dist/api/putRequest.js +0 -14
  153. package/dist/mapper/arkynLogRequestMapper.d.ts +0 -30
  154. package/dist/mapper/arkynLogRequestMapper.d.ts.map +0 -1
  155. package/dist/mapper/arkynLogRequestMapper.js +0 -44
  156. package/dist/services/arkynLogService.d.ts +0 -44
  157. package/dist/services/arkynLogService.d.ts.map +0 -1
  158. package/dist/services/arkynLogService.js +0 -46
  159. package/dist/services/decodeErrorMessageFromRequest.d.ts.map +0 -1
  160. package/dist/services/decodeRequestBody.d.ts.map +0 -1
  161. package/dist/services/errorHandler.d.ts +0 -44
  162. package/dist/services/errorHandler.d.ts.map +0 -1
  163. package/dist/services/flushDebugLogs.d.ts +0 -8
  164. package/dist/services/flushDebugLogs.d.ts.map +0 -1
  165. package/dist/services/flushDebugLogs.js +0 -20
  166. package/dist/services/formAsyncParse.d.ts.map +0 -1
  167. package/dist/services/formParse.d.ts.map +0 -1
  168. package/dist/services/getCaller.d.ts +0 -17
  169. package/dist/services/getCaller.d.ts.map +0 -1
  170. package/dist/services/getCaller.js +0 -60
  171. package/dist/services/getScopedParams.d.ts.map +0 -1
  172. package/dist/services/measureRouteExecution.d.ts +0 -3
  173. package/dist/services/measureRouteExecution.d.ts.map +0 -1
  174. package/dist/services/measureRouteExecution.js +0 -24
  175. package/dist/services/schemaValidator.d.ts.map +0 -1
  176. package/dist/types/ApiResponseDTO.d.ts +0 -17
  177. package/dist/types/ApiResponseDTO.d.ts.map +0 -1
  178. package/dist/types/ApiResponseDTO.js +0 -1
package/dist/bundle.js CHANGED
@@ -1,29 +1,12 @@
1
- var w = Object.defineProperty;
2
- var U = (e, t, s) => t in e ? w(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var o = (e, t, s) => U(e, typeof t != "symbol" ? t + "" : t, s);
1
+ var k = Object.defineProperty;
2
+ var w = (e, s, t) => s in e ? k(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
+ var c = (e, s, t) => w(e, typeof s != "symbol" ? s + "" : s, t);
4
4
  import "zod";
5
- import { removeNonNumeric as N } from "@arkyn/shared";
6
- import "node:dns";
7
- import { countries as v } from "@arkyn/templates";
8
- function g(e) {
9
- var s;
10
- if (process.env.NODE_ENV === "development" || ((s = process.env) == null ? void 0 : s.SHOW_ERRORS_IN_CONSOLE) === "true") {
11
- const a = `${{
12
- yellow: "\x1B[33m",
13
- cyan: "\x1B[36m",
14
- red: "\x1B[31m",
15
- green: "\x1B[32m"
16
- }[e.scheme]}[${e.name}]\x1B[0m`;
17
- let c = `
18
- `;
19
- e.debugs.forEach((h) => {
20
- c += `${a} ${h.trim()}
21
- `;
22
- }), console.log(c);
23
- }
24
- }
25
- const A = {};
26
- class I {
5
+ import { removeNonNumeric as R, ValidateDateService as J } from "@arkyn/shared";
6
+ import j from "node:dns";
7
+ import { countries as _ } from "@arkyn/templates";
8
+ const I = {};
9
+ class S {
27
10
  /**
28
11
  * Sets the file name to be ignored during stack trace analysis.
29
12
  *
@@ -31,7 +14,7 @@ class I {
31
14
  * determining the actual caller of a function. This is useful when you have
32
15
  * adapter or wrapper functions that you want to be transparent in the debug output.
33
16
  *
34
- * @param file - The name of the file to ignore in stack traces (e.g., "httpAdapter.ts")
17
+ * @param {string} file - The name of the file to ignore in stack traces (e.g., "httpAdapter.ts")
35
18
  *
36
19
  * @example
37
20
  * ```typescript
@@ -39,8 +22,8 @@ class I {
39
22
  * DebugService.setIgnoreFile("httpAdapter.ts");
40
23
  * ```
41
24
  */
42
- static setIgnoreFile(t) {
43
- this.ignoreFiles.push(t);
25
+ static setIgnoreFile(s) {
26
+ this.ignoreFiles.push(s);
44
27
  }
45
28
  /**
46
29
  * Clears all configured ignore files.
@@ -57,77 +40,132 @@ class I {
57
40
  static clearIgnoreFiles() {
58
41
  this.ignoreFiles = [];
59
42
  }
43
+ /**
44
+ * Retrieves information about the caller of the current function.
45
+ *
46
+ * This function analyzes the stack trace to determine the file path and function name
47
+ * of the caller. It excludes stack trace entries related to the `@arkyn/server` package
48
+ * and attempts to resolve the file path relative to the project root directory.
49
+ *
50
+ * @returns An object containing:
51
+ * - `functionName`: The name of the function that called the current function, or "Unknown function" if it cannot be determined.
52
+ * - `callerInfo`: The file path of the caller relative to the project root, or "Unknown caller" if it cannot be determined.
53
+ */
54
+ static getCaller() {
55
+ const s = process.cwd(), r = (new Error().stack || "").split(`
56
+ `).map((l) => l.trim());
57
+ let i = 2;
58
+ for (; i < r.length && (r[i].includes("node:internal") || r[i].includes("/node_modules/")); )
59
+ i++;
60
+ if (this.ignoreFiles.length > 0)
61
+ for (; i < r.length && this.ignoreFiles.some(
62
+ (l) => r[i].includes(l)
63
+ ); )
64
+ i++;
65
+ const a = r[i] || "";
66
+ let u = "Unknown function", o = "Unknown caller";
67
+ const h = a.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
68
+ if (h)
69
+ u = h[1], o = h[2];
70
+ else {
71
+ const l = a.match(/at\s+(.+)/);
72
+ if (l) {
73
+ o = l[1];
74
+ const d = o.match(/at\s+([^(\s]+)\s+/);
75
+ d && d[1] !== "new" && (u = d[1]);
76
+ }
77
+ }
78
+ o.includes("(") && (o = o.substring(
79
+ o.indexOf("(") + 1,
80
+ o.lastIndexOf(")")
81
+ )), o = o.split(":").slice(0, -2).join(":");
82
+ try {
83
+ o = I.relative(s, o);
84
+ } catch {
85
+ }
86
+ return { functionName: u, callerInfo: o };
87
+ }
60
88
  }
61
89
  /**
62
90
  * The name of the file to ignore when analyzing the stack trace.
63
91
  * When set, the `getCaller` function will skip stack frames containing this file name.
64
92
  */
65
- o(I, "ignoreFiles", []);
66
- function E() {
67
- const e = process.cwd(), n = (new Error().stack || "").split(`
68
- `).map((u) => u.trim()), r = I.ignoreFiles;
69
- let a = 2;
70
- for (; a < n.length && (n[a].includes("node:internal") || n[a].includes("/node_modules/")); )
71
- a++;
72
- if (r.length > 0)
73
- for (; a < n.length && r.some(
74
- (u) => n[a].includes(u)
75
- ); )
76
- a++;
77
- const c = n[a] || "";
78
- let h = "Unknown function", i = "Unknown caller";
79
- const l = c.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
80
- if (l)
81
- h = l[1], i = l[2];
82
- else {
83
- const u = c.match(/at\s+(.+)/);
84
- if (u) {
85
- i = u[1];
86
- const d = i.match(/at\s+([^(\s]+)\s+/);
87
- d && d[1] !== "new" && (h = d[1]);
88
- }
89
- }
90
- i.includes("(") && (i = i.substring(
91
- i.indexOf("(") + 1,
92
- i.lastIndexOf(")")
93
- )), i = i.split(":").slice(0, -2).join(":");
94
- try {
95
- i = A.relative(e, i);
96
- } catch {
93
+ c(S, "ignoreFiles", []);
94
+ function p(e) {
95
+ var t;
96
+ if (process.env.NODE_ENV === "development" || ((t = process.env) == null ? void 0 : t.DEBUG_MODE) === "true") {
97
+ const i = `${{
98
+ yellow: "\x1B[33m",
99
+ cyan: "\x1B[36m",
100
+ red: "\x1B[31m",
101
+ green: "\x1B[32m"
102
+ }[e.scheme]}[${e.name}]\x1B[0m`;
103
+ let a = `
104
+ `;
105
+ e.debugs.forEach((u) => {
106
+ a += `${i} ${u.trim()}
107
+ `;
108
+ }), console.log(a);
97
109
  }
98
- return { functionName: h, callerInfo: i };
99
110
  }
100
- class p {
101
- onDebug(t) {
102
- const { name: s, body: n, cause: r, message: a } = t, c = [], { callerInfo: h, functionName: i } = E();
103
- c.push(`${s} initialized`), c.push(`Caller Function: ${i}`), c.push(`Caller Location: ${h}`), a && c.push(`Message: ${a}`), n && c.push(`Body: ${JSON.stringify(n, null, 2)}`), r && c.push(`Cause: ${JSON.stringify(r, null, 2)}`), g({ scheme: "red", name: "ARKYN-BAD-RESPONSE-DEBUG", debugs: c });
111
+ class f {
112
+ constructor() {
113
+ c(this, "_cause");
114
+ c(this, "_name", "BadResponse");
115
+ c(this, "_status", 500);
116
+ c(this, "_statusText", "Unknown error");
117
+ }
118
+ get cause() {
119
+ return this._cause;
120
+ }
121
+ set cause(s) {
122
+ this._cause = s;
123
+ }
124
+ get name() {
125
+ return this._name;
126
+ }
127
+ set name(s) {
128
+ this._name = s;
129
+ }
130
+ get status() {
131
+ return this._status;
132
+ }
133
+ set status(s) {
134
+ this._status = s;
135
+ }
136
+ get statusText() {
137
+ return this._statusText;
138
+ }
139
+ set statusText(s) {
140
+ this._statusText = s;
141
+ }
142
+ onDebug() {
143
+ const s = [], { callerInfo: t, functionName: n } = S.getCaller();
144
+ s.push(`Caller Function: ${n}`), s.push(`Caller Location: ${t}`), this._statusText && s.push(`Message: ${this._statusText}`), this._cause && s.push(`Cause: ${JSON.stringify(this._cause)}`), p({ scheme: "red", name: this._name, debugs: s });
145
+ }
146
+ makeBody() {
147
+ return {
148
+ name: this._name,
149
+ message: this._statusText,
150
+ cause: this._cause
151
+ };
104
152
  }
105
153
  }
106
- class L extends p {
154
+ class U extends f {
107
155
  /**
108
156
  * Creates an instance of the `BadGateway` class.
109
157
  *
110
- * @param message - A descriptive message explaining the cause of the error.
111
- * @param cause - Optional additional information about the cause of the error.
158
+ * @param {string} message - A descriptive message explaining the cause of the error.
159
+ * @param {any} cause - Optional additional information about the cause of the error.
112
160
  */
113
- constructor(s, n) {
114
- super();
115
- o(this, "body");
116
- o(this, "cause");
117
- o(this, "status", 502);
118
- o(this, "statusText");
119
- this.body = { name: "BadGateway", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
120
- name: "BadGateway",
121
- body: this.body,
122
- cause: this.cause,
123
- message: this.statusText
124
- });
161
+ constructor(s, t) {
162
+ super(), this.name = "BadGateway", this.status = 502, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
125
163
  }
126
164
  /**
127
165
  * Converts the `BadGateway` instance into a `Response` object with a JSON body.
128
166
  * This method ensures the response has the appropriate headers, status, and status text.
129
167
  *
130
- * @returns A `Response` object with the serialized JSON body and response metadata.
168
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
131
169
  */
132
170
  toResponse() {
133
171
  const s = {
@@ -135,47 +173,37 @@ class L extends p {
135
173
  status: this.status,
136
174
  statusText: this.statusText
137
175
  };
138
- return new Response(JSON.stringify(this.body), s);
176
+ return new Response(JSON.stringify(this.makeBody()), s);
139
177
  }
140
178
  /**
141
179
  * Converts the `BadGateway` instance into a `Response` object using the `Response.json` method.
142
180
  * This method is an alternative to `toResponse` for generating JSON error responses.
143
181
  *
144
- * @returns A `Response` object with the JSON body and response metadata.
182
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
145
183
  */
146
184
  toJson() {
147
185
  const s = {
148
186
  status: this.status,
149
187
  statusText: this.statusText
150
188
  };
151
- return Response.json(this.body, s);
189
+ return Response.json(this.makeBody(), s);
152
190
  }
153
191
  }
154
- class x extends p {
192
+ class T extends f {
155
193
  /**
156
194
  * Creates an instance of the `BadRequest` class.
157
195
  *
158
- * @param message - A descriptive message explaining the cause of the error.
159
- * @param cause - Optional additional information about the cause of the error.
196
+ * @param {string} message - A descriptive message explaining the cause of the error.
197
+ * @param {any} cause - Optional additional information about the cause of the error.
160
198
  */
161
- constructor(s, n) {
162
- super();
163
- o(this, "body");
164
- o(this, "cause");
165
- o(this, "status", 400);
166
- o(this, "statusText");
167
- this.body = { name: "BadRequest", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
168
- name: "BadRequest",
169
- body: this.body,
170
- cause: this.cause,
171
- message: this.statusText
172
- });
199
+ constructor(s, t) {
200
+ super(), this.name = "BadRequest", this.status = 400, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
173
201
  }
174
202
  /**
175
203
  * Converts the `BadRequest` instance into a `Response` object with a JSON body.
176
204
  * This method ensures the response has the appropriate headers, status, and status text.
177
205
  *
178
- * @returns A `Response` object with the serialized JSON body and response metadata.
206
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
179
207
  */
180
208
  toResponse() {
181
209
  const s = {
@@ -183,47 +211,37 @@ class x extends p {
183
211
  status: this.status,
184
212
  statusText: this.statusText
185
213
  };
186
- return new Response(JSON.stringify(this.body), s);
214
+ return new Response(JSON.stringify(this.makeBody()), s);
187
215
  }
188
216
  /**
189
217
  * Converts the `BadRequest` instance into a `Response` object using the `Response.json` method.
190
218
  * This method is an alternative to `toResponse` for generating JSON error responses.
191
219
  *
192
- * @returns A `Response` object with the JSON body and response metadata.
220
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
193
221
  */
194
222
  toJson() {
195
223
  const s = {
196
224
  status: this.status,
197
225
  statusText: this.statusText
198
226
  };
199
- return Response.json(this.body, s);
227
+ return Response.json(this.makeBody(), s);
200
228
  }
201
229
  }
202
- class B extends p {
230
+ class C extends f {
203
231
  /**
204
232
  * Creates an instance of the `Conflict` class.
205
233
  *
206
- * @param message - A descriptive message explaining the cause of the conflict.
207
- * @param cause - Optional additional information about the cause of the conflict.
234
+ * @param {string} message - A descriptive message explaining the cause of the conflict.
235
+ * @param {any} cause - Optional additional information about the cause of the conflict.
208
236
  */
209
- constructor(s, n) {
210
- super();
211
- o(this, "body");
212
- o(this, "cause");
213
- o(this, "status", 409);
214
- o(this, "statusText");
215
- this.body = { name: "Conflict", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
216
- name: "Conflict",
217
- body: this.body,
218
- cause: this.cause,
219
- message: this.statusText
220
- });
237
+ constructor(s, t) {
238
+ super(), this.name = "Conflict", this.status = 409, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
221
239
  }
222
240
  /**
223
241
  * Converts the `Conflict` instance into a `Response` object with a JSON body.
224
242
  * This method ensures the response has the appropriate headers, status, and status text.
225
243
  *
226
- * @returns A `Response` object with the serialized JSON body and response metadata.
244
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
227
245
  */
228
246
  toResponse() {
229
247
  const s = {
@@ -231,47 +249,37 @@ class B extends p {
231
249
  status: this.status,
232
250
  statusText: this.statusText
233
251
  };
234
- return new Response(JSON.stringify(this.body), s);
252
+ return new Response(JSON.stringify(this.makeBody()), s);
235
253
  }
236
254
  /**
237
255
  * Converts the `Conflict` instance into a `Response` object using the `Response.json` method.
238
256
  * This method is an alternative to `toResponse` for generating JSON error responses.
239
257
  *
240
- * @returns A `Response` object with the JSON body and response metadata.
258
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
241
259
  */
242
260
  toJson() {
243
261
  const s = {
244
262
  status: this.status,
245
263
  statusText: this.statusText
246
264
  };
247
- return Response.json(this.body, s);
265
+ return Response.json(this.makeBody(), s);
248
266
  }
249
267
  }
250
- class k extends p {
268
+ class A extends f {
251
269
  /**
252
270
  * Creates an instance of the `Forbidden` class.
253
271
  *
254
- * @param message - A descriptive message explaining why access is forbidden.
255
- * @param cause - Optional additional information about the cause of the error.
272
+ * @param {string} message - A descriptive message explaining why access is forbidden.
273
+ * @param {any} cause - Optional additional information about the cause of the error.
256
274
  */
257
- constructor(s, n) {
258
- super();
259
- o(this, "body");
260
- o(this, "cause");
261
- o(this, "status", 403);
262
- o(this, "statusText");
263
- this.body = { name: "Forbidden", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
264
- name: "Forbidden",
265
- body: this.body,
266
- cause: this.cause,
267
- message: this.statusText
268
- });
275
+ constructor(s, t) {
276
+ super(), this.name = "Forbidden", this.status = 403, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
269
277
  }
270
278
  /**
271
279
  * Converts the `Forbidden` instance into a `Response` object with a JSON body.
272
280
  * This method ensures the response has the appropriate headers, status, and status text.
273
281
  *
274
- * @returns A `Response` object with the serialized JSON body and response metadata.
282
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
275
283
  */
276
284
  toResponse() {
277
285
  const s = {
@@ -279,47 +287,37 @@ class k extends p {
279
287
  status: this.status,
280
288
  statusText: this.statusText
281
289
  };
282
- return new Response(JSON.stringify(this.body), s);
290
+ return new Response(JSON.stringify(this.makeBody()), s);
283
291
  }
284
292
  /**
285
293
  * Converts the `Forbidden` instance into a `Response` object using the `Response.json` method.
286
294
  * This method is an alternative to `toResponse` for generating JSON error responses.
287
295
  *
288
- * @returns A `Response` object with the JSON body and response metadata.
296
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
289
297
  */
290
298
  toJson() {
291
299
  const s = {
292
300
  status: this.status,
293
301
  statusText: this.statusText
294
302
  };
295
- return Response.json(this.body, s);
303
+ return Response.json(this.makeBody(), s);
296
304
  }
297
305
  }
298
- class q extends p {
306
+ class q extends f {
299
307
  /**
300
308
  * Creates an instance of the `NotFound` class.
301
309
  *
302
- * @param message - A descriptive message explaining the reason the resource was not found.
303
- * @param cause - Optional additional information about the cause of the error.
310
+ * @param {string} message - A descriptive message explaining the reason the resource was not found.
311
+ * @param {any} cause - Optional additional information about the cause of the error.
304
312
  */
305
- constructor(s, n) {
306
- super();
307
- o(this, "body");
308
- o(this, "cause");
309
- o(this, "status", 404);
310
- o(this, "statusText");
311
- this.body = { name: "NotFound", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
312
- name: "NotFound",
313
- body: this.body,
314
- cause: this.cause,
315
- message: this.statusText
316
- });
313
+ constructor(s, t) {
314
+ super(), this.name = "NotFound", this.status = 404, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
317
315
  }
318
316
  /**
319
317
  * Converts the `NotFound` instance into a `Response` object with a JSON body.
320
318
  * This method ensures the response has the appropriate headers, status, and status text.
321
319
  *
322
- * @returns A `Response` object with the serialized JSON body and response metadata.
320
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
323
321
  */
324
322
  toResponse() {
325
323
  const s = {
@@ -327,47 +325,37 @@ class q extends p {
327
325
  status: this.status,
328
326
  statusText: this.statusText
329
327
  };
330
- return new Response(JSON.stringify(this.body), s);
328
+ return new Response(JSON.stringify(this.makeBody()), s);
331
329
  }
332
330
  /**
333
331
  * Converts the `NotFound` instance into a `Response` object using the `Response.json` method.
334
332
  * This method is an alternative to `toResponse` for generating JSON error responses.
335
333
  *
336
- * @returns A `Response` object with the JSON body and response metadata.
334
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
337
335
  */
338
336
  toJson() {
339
337
  const s = {
340
338
  status: this.status,
341
339
  statusText: this.statusText
342
340
  };
343
- return Response.json(this.body, s);
341
+ return Response.json(this.makeBody(), s);
344
342
  }
345
343
  }
346
- class F extends p {
344
+ class H extends f {
347
345
  /**
348
346
  * Creates an instance of the `NotImplemented` class.
349
347
  *
350
- * @param message - A descriptive message explaining why the functionality is not implemented.
351
- * @param cause - Optional additional information about the cause of the error.
348
+ * @param {string} message - A descriptive message explaining why the functionality is not implemented.
349
+ * @param {any} cause - Optional additional information about the cause of the error.
352
350
  */
353
- constructor(s, n) {
354
- super();
355
- o(this, "body");
356
- o(this, "cause");
357
- o(this, "status", 501);
358
- o(this, "statusText");
359
- this.body = { name: "NotImplemented", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
360
- name: "NotImplemented",
361
- body: this.body,
362
- cause: this.cause,
363
- message: this.statusText
364
- });
351
+ constructor(s, t) {
352
+ super(), this.name = "NotImplemented", this.status = 501, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
365
353
  }
366
354
  /**
367
355
  * Converts the `NotImplemented` instance into a `Response` object with a JSON body.
368
356
  * This method ensures the response has the appropriate headers, status, and status text.
369
357
  *
370
- * @returns A `Response` object with the serialized JSON body and response metadata.
358
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
371
359
  */
372
360
  toResponse() {
373
361
  const s = {
@@ -375,47 +363,37 @@ class F extends p {
375
363
  status: this.status,
376
364
  statusText: this.statusText
377
365
  };
378
- return new Response(JSON.stringify(this.body), s);
366
+ return new Response(JSON.stringify(this.makeBody()), s);
379
367
  }
380
368
  /**
381
369
  * Converts the `NotImplemented` instance into a `Response` object using the `Response.json` method.
382
370
  * This method is an alternative to `toResponse` for generating JSON error responses.
383
371
  *
384
- * @returns A `Response` object with the JSON body and response metadata.
372
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
385
373
  */
386
374
  toJson() {
387
375
  const s = {
388
376
  status: this.status,
389
377
  statusText: this.statusText
390
378
  };
391
- return Response.json(this.body, s);
379
+ return Response.json(this.makeBody(), s);
392
380
  }
393
381
  }
394
- class T extends p {
382
+ class x extends f {
395
383
  /**
396
384
  * Creates an instance of the `ServerError` class.
397
385
  *
398
- * @param message - A descriptive message explaining the cause of the server error.
399
- * @param cause - Optional additional information about the cause of the error.
386
+ * @param {string} message - A descriptive message explaining the cause of the server error.
387
+ * @param {any} cause - Optional additional information about the cause of the error.
400
388
  */
401
- constructor(s, n) {
402
- super();
403
- o(this, "body");
404
- o(this, "cause");
405
- o(this, "status", 500);
406
- o(this, "statusText");
407
- this.body = { name: "ServerError", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
408
- name: "ServerError",
409
- body: this.body,
410
- cause: this.cause,
411
- message: this.statusText
412
- });
389
+ constructor(s, t) {
390
+ super(), this.name = "ServerError", this.status = 500, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
413
391
  }
414
392
  /**
415
393
  * Converts the `ServerError` instance into a `Response` object with a JSON body.
416
394
  * This method ensures the response has the appropriate headers, status, and status text.
417
395
  *
418
- * @returns A `Response` object with the serialized JSON body and response metadata.
396
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
419
397
  */
420
398
  toResponse() {
421
399
  const s = {
@@ -423,47 +401,37 @@ class T extends p {
423
401
  status: this.status,
424
402
  statusText: this.statusText
425
403
  };
426
- return new Response(JSON.stringify(this.body), s);
404
+ return new Response(JSON.stringify(this.makeBody()), s);
427
405
  }
428
406
  /**
429
407
  * Converts the `ServerError` instance into a `Response` object using the `Response.json` method.
430
408
  * This method is an alternative to `toResponse` for generating JSON error responses.
431
409
  *
432
- * @returns A `Response` object with the JSON body and response metadata.
410
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
433
411
  */
434
412
  toJson() {
435
413
  const s = {
436
414
  status: this.status,
437
415
  statusText: this.statusText
438
416
  };
439
- return Response.json(this.body, s);
417
+ return Response.json(this.makeBody(), s);
440
418
  }
441
419
  }
442
- class H extends p {
420
+ class L extends f {
443
421
  /**
444
422
  * Creates an instance of the `Unauthorized` class.
445
423
  *
446
424
  * @param message - A descriptive message explaining why the request is unauthorized.
447
425
  * @param cause - Optional additional information about the cause of the error.
448
426
  */
449
- constructor(s, n) {
450
- super();
451
- o(this, "body");
452
- o(this, "cause");
453
- o(this, "status", 401);
454
- o(this, "statusText");
455
- this.body = { name: "Unauthorized", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
456
- name: "Unauthorized",
457
- body: this.body,
458
- cause: this.cause,
459
- message: this.statusText
460
- });
427
+ constructor(s, t) {
428
+ super(), this.name = "Unauthorized", this.status = 401, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
461
429
  }
462
430
  /**
463
431
  * Converts the `Unauthorized` instance into a `Response` object with a JSON body.
464
432
  * This method ensures the response has the appropriate headers, status, and status text.
465
433
  *
466
- * @returns A `Response` object with the serialized JSON body and response metadata.
434
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
467
435
  */
468
436
  toResponse() {
469
437
  const s = {
@@ -471,55 +439,44 @@ class H extends p {
471
439
  status: this.status,
472
440
  statusText: this.statusText
473
441
  };
474
- return new Response(JSON.stringify(this.body), s);
442
+ return new Response(JSON.stringify(this.makeBody()), s);
475
443
  }
476
444
  /**
477
445
  * Converts the `Unauthorized` instance into a `Response` object using the `Response.json` method.
478
446
  * This method is an alternative to `toResponse` for generating JSON error responses.
479
447
  *
480
- * @returns A `Response` object with the JSON body and response metadata.
448
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
481
449
  */
482
450
  toJson() {
483
451
  const s = {
484
452
  status: this.status,
485
453
  statusText: this.statusText
486
454
  };
487
- return Response.json(this.body, s);
455
+ return Response.json(this.makeBody(), s);
488
456
  }
489
457
  }
490
- class R extends p {
458
+ class b extends f {
491
459
  /**
492
460
  * Creates an instance of the `UnprocessableEntity` class.
493
461
  *
494
- * @param props - An object containing details about the error, such as:
495
- * - `data`: Additional data related to the error.
496
- * - `fieldErrors`: A record of field-specific error messages.
497
- * - `fields`: A record of field values that caused the error.
498
- * - `message`: A descriptive message explaining the error.
499
- * @param enableDebug - A boolean indicating whether to enable debug logging for this error.
462
+ * @param {object} props - An object containing details about the error, such as:
463
+ * @param {any} [props.data] - `data`: Additional data related to the error.
464
+ * @param {Record<string, string>} [props.fieldErrors] - `fieldErrors`: A record of field-specific error messages.
465
+ * @param {Record<string, string>} [props.fields] - `fields`: A record of field values that caused the error.
466
+ * @param {string} [props.message] - `message`: A descriptive message explaining the error.
500
467
  */
501
468
  constructor(s) {
502
- super();
503
- o(this, "body");
504
- o(this, "status", 422);
505
- o(this, "statusText");
506
- this.statusText = s.message || "Unprocessable Entity", this.body = {
507
- name: "UnprocessableEntity",
508
- message: s.message || null,
469
+ super(), this.name = "UnprocessableEntity", this.status = 422, this.statusText = s.message || "Unprocessable entity", this.cause = {
509
470
  data: s.data,
510
471
  fieldErrors: s.fieldErrors,
511
472
  fields: s.fields
512
- }, this.onDebug({
513
- name: "UnprocessableEntity",
514
- cause: s.fieldErrors,
515
- message: s.message
516
- });
473
+ }, this.onDebug();
517
474
  }
518
475
  /**
519
476
  * Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
520
477
  * This method ensures the response has the appropriate headers, status, and status text.
521
478
  *
522
- * @returns A `Response` object with the serialized JSON body and response metadata.
479
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
523
480
  */
524
481
  toResponse() {
525
482
  const s = {
@@ -527,74 +484,93 @@ class R extends p {
527
484
  status: this.status,
528
485
  statusText: this.statusText
529
486
  };
530
- return new Response(JSON.stringify(this.body), s);
487
+ return new Response(JSON.stringify(this.makeBody()), s);
531
488
  }
532
489
  /**
533
490
  * Converts the `UnprocessableEntity` instance into a `Response` object using the `Response.json` method.
534
491
  * This method is an alternative to `toResponse` for generating JSON error responses.
535
492
  *
536
- * @returns A `Response` object with the JSON body and response metadata.
493
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
537
494
  */
538
495
  toJson() {
539
496
  const s = {
540
497
  status: this.status,
541
498
  statusText: this.statusText
542
499
  };
543
- return Response.json(this.body, s);
500
+ return Response.json(this.makeBody(), s);
544
501
  }
545
502
  }
546
- class m {
503
+ class y {
504
+ constructor() {
505
+ c(this, "_body", null);
506
+ c(this, "_name", "SuccessResponse");
507
+ c(this, "_status", 200);
508
+ c(this, "_statusText", "OK");
509
+ }
510
+ get body() {
511
+ return this._body;
512
+ }
513
+ set body(s) {
514
+ this._body = s ?? null;
515
+ }
516
+ get name() {
517
+ return this._name;
518
+ }
519
+ set name(s) {
520
+ this._name = s;
521
+ }
522
+ get status() {
523
+ return this._status;
524
+ }
525
+ set status(s) {
526
+ this._status = s;
527
+ }
528
+ get statusText() {
529
+ return this._statusText;
530
+ }
531
+ set statusText(s) {
532
+ this._statusText = s;
533
+ }
547
534
  /**
548
535
  * Logs debug information for success responses including caller context and response details.
549
536
  *
550
- * @param name - The name/type of the success response being logged
551
- * @param body - The response body or success data to be logged
552
- * @param cause - Optional additional cause information for the error
537
+ * @param {any} body - The response body or success data to be logged
553
538
  *
554
539
  * @example
555
540
  * ```typescript
556
541
  * const SuccessResponse = new SuccessResponse();
557
- * SuccessResponse.onDebug("ValidationError", { field: "email", message: "Invalid format" });
542
+ * SuccessResponse.onDebug({ data: "Operation completed successfully" });
558
543
  * ```
559
544
  */
560
- onDebug(t, s, n) {
561
- const r = [], { callerInfo: a, functionName: c } = E();
562
- r.push(`${t} initialized
563
- `), r.push(`Caller Function: ${c}
564
- `), r.push(`Caller Location: ${a}
565
- `), r.push(`Body: ${JSON.stringify(s, null, 2)}
566
- `), n && r.push(`Cause: ${JSON.stringify(n, null, 2)}
567
- `), g({
568
- scheme: "green",
569
- name: "ARKYN-SUCCESS-RESPONSE-DEBUG",
570
- debugs: r
571
- });
545
+ onDebug(s) {
546
+ const t = [], { callerInfo: n, functionName: r } = S.getCaller();
547
+ t.push(`Caller Function: ${r}`), t.push(`Caller Location: ${n}`), this.statusText && t.push(`Message: ${this.statusText}`), s && t.push(`Body: ${JSON.stringify(s)}`), p({ scheme: "red", name: this.name, debugs: t });
548
+ }
549
+ makeBody() {
550
+ return {
551
+ name: this.name,
552
+ message: this.statusText,
553
+ body: this.body
554
+ };
572
555
  }
573
556
  }
574
- class P extends m {
557
+ class F extends y {
575
558
  /**
576
559
  * Creates an instance of the `Created` class.
577
560
  *
578
- * @param body - The response body to be included in the HTTP response.
579
- * @param init - Optional initialization object for customizing headers, status, and status text.
561
+ * @param {string} message - A message describing the creation status.
562
+ * @param {any} body - The response body to be included in the HTTP response.
580
563
  */
581
- constructor(s, n) {
582
- super();
583
- o(this, "body");
584
- o(this, "headers");
585
- o(this, "status");
586
- o(this, "statusText");
587
- this.body = { ...s, name: "Created", message: n == null ? void 0 : n.message }, this.headers = (n == null ? void 0 : n.headers) || {}, this.status = (n == null ? void 0 : n.status) || 201, this.statusText = (n == null ? void 0 : n.statusText) || "Resource created successfully", this.onDebug("Created", s);
564
+ constructor(s, t) {
565
+ super(), this.name = "Created", this.status = 201, this.statusText = s, this.body = t || void 0, this.onDebug();
588
566
  }
589
567
  /**
590
- * Converts the `Created` instance into a `Response` object with a JSON body.
591
- * This method ensures the response has the appropriate headers, status, and status text.
592
- *
593
- * @returns A `Response` object with the serialized JSON body and response metadata.
568
+ * Converts the `Created` instance into a `Response` object.
569
+ * @returns {Response} A `Response` object with the body and response metadata.
594
570
  */
595
571
  toResponse() {
596
572
  const s = {
597
- headers: { "Content-Type": "application/json", ...this.headers },
573
+ headers: { "Content-Type": "application/json" },
598
574
  status: this.status,
599
575
  statusText: this.statusText
600
576
  };
@@ -603,117 +579,89 @@ class P extends m {
603
579
  /**
604
580
  * Converts the `Created` instance into a `Response` object using the `Response.json` method.
605
581
  * This method is an alternative to `toResponse` for generating JSON responses.
606
- *
607
- * @returns A `Response` object with the JSON body and response metadata.
582
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
608
583
  */
609
584
  toJson() {
610
585
  const s = {
611
- headers: this.headers,
612
586
  status: this.status,
613
587
  statusText: this.statusText
614
588
  };
615
589
  return Response.json(this.body, s);
616
590
  }
617
591
  }
618
- class Y extends m {
592
+ class z extends y {
619
593
  /**
620
594
  * Creates an instance of the `Found` class.
621
595
  *
622
- * @param body - The body of the response.
623
- * @param init - Optional initialization object to set headers, status, and statusText.
624
- * - `headers`: Additional headers to include in the response.
625
- * - `status`: HTTP status code (default is 302).
626
- * - `statusText`: HTTP status text (default is "Found").
596
+ * @param {string} message - A message describing the creation status.
597
+ * @param {any} body - The response body to be included in the HTTP response.
627
598
  */
628
- constructor(s, n) {
629
- super();
630
- o(this, "body");
631
- o(this, "headers");
632
- o(this, "status");
633
- o(this, "statusText");
634
- this.body = { ...s, name: "Found", message: n == null ? void 0 : n.message }, this.headers = (n == null ? void 0 : n.headers) || {}, this.status = (n == null ? void 0 : n.status) || 302, this.statusText = (n == null ? void 0 : n.statusText) || "Found", this.onDebug("Found", s);
599
+ constructor(s, t) {
600
+ super(), this.name = "Found", this.status = 302, this.statusText = s, this.body = t || void 0, this.onDebug();
635
601
  }
636
602
  /**
637
603
  * Converts the `Found` instance into a `Response` object.
638
- * This method serializes the response body as JSON and includes the appropriate headers.
639
- *
640
- * @returns A `Response` object with the serialized JSON body and the specified headers, status, and statusText.
604
+ * @returns {Response} A `Response` object with the body and response metadata.
641
605
  */
642
606
  toResponse() {
643
607
  const s = {
644
- headers: { "Content-Type": "application/json", ...this.headers },
608
+ headers: { "Content-Type": "application/json" },
645
609
  status: this.status,
646
610
  statusText: this.statusText
647
611
  };
648
612
  return new Response(JSON.stringify(this.body), s);
649
613
  }
650
614
  /**
651
- * Converts the `Found` instance into a JSON response using `Response.json`.
652
- * This method is an alternative to `toResponse` for creating JSON responses.
653
- *
654
- * @returns A `Response` object with the JSON body and the specified headers, status, and statusText.
615
+ * Converts the `Found` instance into a `Response` object using the `Response.json` method.
616
+ * This method is an alternative to `toResponse` for generating JSON responses.
617
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
655
618
  */
656
619
  toJson() {
657
620
  const s = {
658
- headers: this.headers,
659
621
  status: this.status,
660
622
  statusText: this.statusText
661
623
  };
662
624
  return Response.json(this.body, s);
663
625
  }
664
626
  }
665
- class z extends m {
627
+ class M extends y {
666
628
  /**
667
629
  * Creates an instance of the `NoContent` class.
668
- *
669
- * @param init - Optional initialization object for customizing headers, status, and status text.
630
+ * @param {string} message - A message describing the creation status.
670
631
  */
671
632
  constructor(s) {
672
- super();
673
- o(this, "headers");
674
- o(this, "status");
675
- o(this, "statusText");
676
- 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);
633
+ super(), this.name = "NoContent", this.status = 204, this.statusText = s, this.onDebug();
677
634
  }
678
635
  /**
679
636
  * Converts the `NoContent` instance into a `Response` object.
680
- * This method ensures the response has the appropriate headers, status, and status text.
681
- *
682
- * @returns A `Response` object with no body and response metadata.
637
+ * @returns {Response} A `Response` object with the body and response metadata.
683
638
  */
684
639
  toResponse() {
685
640
  const s = {
686
- headers: this.headers,
641
+ headers: { "Content-Type": "application/json" },
687
642
  status: this.status,
688
643
  statusText: this.statusText
689
644
  };
690
645
  return new Response(null, s);
691
646
  }
692
647
  }
693
- class M extends m {
648
+ class V extends y {
694
649
  /**
695
650
  * Creates an instance of the `Success` class.
696
651
  *
697
- * @param body - The response body to be included in the HTTP response.
698
- * @param init - Optional initialization object for customizing headers, status, and status text.
652
+ * @param {string} message - A message describing the creation status.
653
+ * @param {any} body - The response body to be included in the HTTP response.
699
654
  */
700
- constructor(s, n) {
701
- super();
702
- o(this, "body");
703
- o(this, "headers");
704
- o(this, "status");
705
- o(this, "statusText");
706
- this.body = { ...s, name: "Success", message: n == null ? void 0 : n.message }, this.headers = (n == null ? void 0 : n.headers) || {}, this.status = (n == null ? void 0 : n.status) || 200, this.statusText = (n == null ? void 0 : n.statusText) ?? "OK", this.onDebug("Success", s);
655
+ constructor(s, t) {
656
+ super(), this.name = "Success", this.status = 200, this.statusText = s, this.body = t || void 0, this.onDebug();
707
657
  }
708
658
  /**
709
- * Converts the `Success` instance into a `Response` object with a JSON body.
710
- * This method ensures the response has the appropriate headers, status, and status text.
711
- *
712
- * @returns A `Response` object with the serialized JSON body and response metadata.
659
+ * Converts the `Success` instance into a `Response` object.
660
+ * @returns {Response} A `Response` object with the body and response metadata.
713
661
  */
714
662
  toResponse() {
715
663
  const s = {
716
- headers: { "Content-Type": "application/json", ...this.headers },
664
+ headers: { "Content-Type": "application/json" },
717
665
  status: this.status,
718
666
  statusText: this.statusText
719
667
  };
@@ -722,42 +670,33 @@ class M extends m {
722
670
  /**
723
671
  * Converts the `Success` instance into a `Response` object using the `Response.json` method.
724
672
  * This method is an alternative to `toResponse` for generating JSON responses.
725
- *
726
- * @returns A `Response` object with the JSON body and response metadata.
673
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
727
674
  */
728
675
  toJson() {
729
676
  const s = {
730
- headers: this.headers,
731
677
  status: this.status,
732
678
  statusText: this.statusText
733
679
  };
734
680
  return Response.json(this.body, s);
735
681
  }
736
682
  }
737
- class _ extends m {
683
+ class Z extends y {
738
684
  /**
739
685
  * Creates an instance of the `Updated` class.
740
686
  *
741
- * @param body - The response body to be included in the HTTP response.
742
- * @param init - Optional initialization object for customizing headers, status, and status text.
687
+ * @param {string} message - A message describing the creation status.
688
+ * @param {any} body - The response body to be included in the HTTP response.
743
689
  */
744
- constructor(s, n) {
745
- super();
746
- o(this, "body");
747
- o(this, "headers");
748
- o(this, "status");
749
- o(this, "statusText");
750
- this.body = { ...s, name: "Updated", message: n == null ? void 0 : n.message }, this.headers = (n == null ? void 0 : n.headers) || {}, this.status = (n == null ? void 0 : n.status) || 200, this.statusText = (n == null ? void 0 : n.statusText) || "Resource updated successfully", this.onDebug("Updated", s);
690
+ constructor(s, t) {
691
+ super(), this.name = "Updated", this.status = 200, this.statusText = s, this.body = t || void 0, this.onDebug();
751
692
  }
752
693
  /**
753
- * Converts the `Updated` instance into a `Response` object with a JSON body.
754
- * This method ensures the response has the appropriate headers, status, and status text.
755
- *
756
- * @returns A `Response` object with the serialized JSON body and response metadata.
694
+ * Converts the `Updated` instance into a `Response` object.
695
+ * @returns {Response} A `Response` object with the body and response metadata.
757
696
  */
758
697
  toResponse() {
759
698
  const s = {
760
- headers: { "Content-Type": "application/json", ...this.headers },
699
+ headers: { "Content-Type": "application/json" },
761
700
  status: this.status,
762
701
  statusText: this.statusText
763
702
  };
@@ -766,135 +705,148 @@ class _ extends m {
766
705
  /**
767
706
  * Converts the `Updated` instance into a `Response` object using the `Response.json` method.
768
707
  * This method is an alternative to `toResponse` for generating JSON responses.
769
- *
770
- * @returns A `Response` object with the JSON body and response metadata.
708
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
771
709
  */
772
710
  toJson() {
773
711
  const s = {
774
- headers: this.headers,
775
712
  status: this.status,
776
713
  statusText: this.statusText
777
714
  };
778
715
  return Response.json(this.body, s);
779
716
  }
780
717
  }
781
- class V {
782
- static mapHeaders(t) {
783
- return t instanceof Headers ? Object.fromEntries(t.entries()) : typeof t == "object" ? Object.entries(t).reduce((s, [n, r]) => (typeof r == "string" ? s[n] = r : Array.isArray(r) ? s[n] = r.join(", ") : s[n] = JSON.stringify(r), s), {}) : {};
718
+ class G {
719
+ /**
720
+ * Converts various header formats into a plain key-value object.
721
+ *
722
+ * @param {HeadersInit} headers - The headers to map.
723
+ * @returns {Record<string, string>} A plain object with header key-value pairs.
724
+ * @private
725
+ */
726
+ static mapHeaders(s) {
727
+ return s instanceof Headers ? Object.fromEntries(s.entries()) : typeof s == "object" ? Object.entries(s).reduce(
728
+ (t, [n, r]) => (typeof r == "string" ? t[n] = r : Array.isArray(r) ? t[n] = r.join(", ") : t[n] = JSON.stringify(r), t),
729
+ {}
730
+ ) : {};
784
731
  }
785
- static mapQueryParams(t) {
786
- const s = {};
787
- return t.forEach((n, r) => {
788
- s[r] = n;
789
- }), s;
732
+ /**
733
+ * Converts URLSearchParams into a plain key-value object.
734
+ *
735
+ * @param {URLSearchParams} queryParams - The query parameters to map.
736
+ * @returns {Record<string, string>} A plain object with query parameter key-value pairs.
737
+ * @private
738
+ */
739
+ static mapQueryParams(s) {
740
+ const t = {};
741
+ return s.forEach((n, r) => t[r] = n), t;
790
742
  }
791
- static handle(t) {
743
+ /**
744
+ * Transforms raw HTTP request/response data into a standardized log output format.
745
+ *
746
+ * @param {InputProps} props - The input properties containing request/response data.
747
+ * @returns {OutputProps} The mapped output object ready for logging.
748
+ */
749
+ static handle(s) {
792
750
  return {
793
- rawUrl: t.url,
794
- status: t.status,
795
- method: t.method,
751
+ rawUrl: s.rawUrl,
752
+ status: s.status,
753
+ method: s.method,
796
754
  token: null,
797
- elapsedTime: t.elapsedTime,
798
- requestHeaders: this.mapHeaders(t.requestHeaders),
799
- requestBody: t.requestBody || null,
800
- queryParams: this.mapQueryParams(t.queryParams),
801
- responseHeaders: this.mapHeaders(t.responseHeaders),
802
- responseBody: t.responseBody || null
755
+ elapsedTime: s.elapsedTime,
756
+ requestHeaders: this.mapHeaders(s.requestHeaders),
757
+ requestBody: s.requestBody || null,
758
+ queryParams: {
759
+ ...this.mapQueryParams(s.queryParams),
760
+ ...s.urlParams
761
+ },
762
+ responseHeaders: this.mapHeaders(s.responseHeaders),
763
+ responseBody: s.responseBody || null
803
764
  };
804
765
  }
805
766
  }
806
- class C {
767
+ class v {
807
768
  /**
808
- * Sets the configuration for the arkyn. This method initializes the arkyn configuration
809
- * with the provided `arkynConfig` values. If the configuration has already been set,
810
- * the method will return early without making any changes.
769
+ * Sets the log service configuration only once.
770
+ * If the configuration is already set, the call is ignored.
811
771
  *
812
- * @param arkynConfig - An object containing the arkyn configuration properties.
813
- * @param arkynConfig.arkynTrafficSourceId - The key used to identify the arkyn.
814
- * @param arkynConfig.arkynUserToken - The user token for authenticating with the arkyn.
815
- * @param arkynConfig.arkynLogBaseApiUrl - (Optional) The API URL for the arkyn. If not provided,
816
- * a default URL will be used.
772
+ * @param {object} config - Service configuration parameters.
773
+ * @param {string} config.trafficSourceId - Traffic source identifier.
774
+ * @param {string} config.userToken - User token for authentication.
775
+ * @param {string} [config.logBaseApiUrl] - Optional base URL for the log service.
817
776
  */
818
- static setArkynConfig(t) {
819
- if (this.arkynConfig) return;
820
- const { trafficSourceId: s, userToken: n, logBaseApiUrl: r } = t;
821
- this.arkynConfig = {
822
- trafficSourceId: s,
823
- userToken: n,
824
- apiUrl: r || "http://95.216.190.158:8081/ingest-log"
825
- };
777
+ static setConfig(s) {
778
+ if (this.config) return;
779
+ const { trafficSourceId: t, userToken: n, logBaseApiUrl: r } = s, a = `${r || "http://95.216.190.158:8081"}/ingest-log`;
780
+ this.config = { trafficSourceId: t, userToken: n, apiUrl: a };
826
781
  }
827
782
  /**
828
- * Retrieves the current arkyn configuration for the ArkynLogService.
829
- *
830
- * @returns {ArkynConfigProps | undefined} The current arkyn configuration if set,
831
- * or `undefined` if no configuration has been initialized.
783
+ * Returns the current service configuration, if it exists.
784
+ * @returns {{ trafficSourceId: string; userToken: string; apiUrl: string } | undefined} The stored configuration or `undefined` if not set.
832
785
  */
833
- static getArkynConfig() {
834
- return this.arkynConfig;
786
+ static getConfig() {
787
+ return this.config;
835
788
  }
836
789
  /**
837
- * Resets the arkyn configuration to `undefined`.
838
- * This method can be used to clear the current configuration.
790
+ * Resets the stored configuration, allowing a new initialization.
839
791
  */
840
- static resetArkynConfig() {
841
- this.arkynConfig = void 0;
792
+ static resetConfig() {
793
+ this.config = void 0;
842
794
  }
843
795
  }
844
- o(C, "arkynConfig");
845
- async function G(e) {
846
- const t = C.getArkynConfig();
847
- if (!t) return;
848
- const { userToken: s, apiUrl: n, trafficSourceId: r } = t, {
849
- elapsedTime: a,
850
- method: c,
851
- queryParams: h,
852
- requestBody: i,
853
- requestHeaders: l,
854
- responseBody: u,
796
+ c(v, "config");
797
+ async function W(e) {
798
+ const s = v.getConfig();
799
+ if (!s) return;
800
+ const { userToken: t, apiUrl: n, trafficSourceId: r } = s, {
801
+ elapsedTime: i,
802
+ method: a,
803
+ queryParams: u,
804
+ requestBody: o,
805
+ requestHeaders: h,
806
+ responseBody: l,
855
807
  responseHeaders: d,
856
- status: S,
857
- token: f,
858
- rawUrl: J
808
+ status: $,
809
+ token: xs,
810
+ rawUrl: B
859
811
  } = e;
860
812
  if (process.env.NODE_ENV !== "development")
861
813
  try {
862
- const y = new URL(J);
863
- let O = "https";
864
- y.protocol === "http:" && (O = "http");
865
- const j = JSON.stringify({
866
- domainUrl: y.protocol + "//" + y.host,
867
- pathnameUrl: y.pathname,
814
+ const m = new URL(B);
815
+ let D = "https";
816
+ m.protocol === "http:" && (D = "http");
817
+ const O = JSON.stringify({
818
+ domainUrl: m.protocol + "//" + m.host,
819
+ pathnameUrl: m.pathname,
868
820
  trafficSourceId: r,
869
- status: S,
870
- protocol: O,
871
- method: c.toLowerCase(),
821
+ status: $,
822
+ protocol: D,
823
+ method: a.toLowerCase(),
872
824
  trafficUserId: null,
873
- elapsedTime: a,
874
- requestHeaders: JSON.stringify(l),
875
- requestBody: JSON.stringify(i),
876
- queryParams: JSON.stringify(h),
825
+ elapsedTime: i,
826
+ requestHeaders: JSON.stringify(h),
827
+ requestBody: JSON.stringify(o),
828
+ queryParams: JSON.stringify(u),
877
829
  responseHeaders: JSON.stringify(d),
878
- responseBody: JSON.stringify(u)
879
- });
880
- await fetch(n, {
881
- method: "POST",
882
- body: j,
883
- headers: {
884
- "Content-Type": "application/json",
885
- Authorization: `Bearer ${s}`
886
- }
887
- });
888
- } catch (y) {
889
- g({
890
- debugs: [`Error sending request: ${y}`],
891
- name: "ARKYN_LOG_ERROR",
830
+ responseBody: JSON.stringify(l)
831
+ }), P = {
832
+ "Content-Type": "application/json",
833
+ Authorization: `Bearer ${t}`
834
+ };
835
+ await fetch(n, { method: "POST", body: O, headers: P });
836
+ } catch (m) {
837
+ p({
838
+ debugs: [`Error sending request: ${m}`],
839
+ name: "LogError",
892
840
  scheme: "red"
893
841
  });
894
842
  }
895
843
  }
896
- async function b(e, t, s = {}, n) {
897
- const r = {
844
+ async function g(e) {
845
+ let s = e.url;
846
+ e.urlParams && Object.entries(e.urlParams).forEach(([n, r]) => {
847
+ s = s.replaceAll(`:${n}`, r);
848
+ });
849
+ const t = {
898
850
  POST: "Resource created successfully",
899
851
  PUT: "Resource updated successfully",
900
852
  DELETE: "Resource deleted successfully",
@@ -902,109 +854,117 @@ async function b(e, t, s = {}, n) {
902
854
  GET: "Request successful"
903
855
  };
904
856
  try {
905
- const a = performance.now(), c = { ...s, "Content-Type": "application/json" }, h = await fetch(t, {
906
- method: e,
907
- headers: c,
908
- body: n ? JSON.stringify(n) : void 0
909
- }), i = performance.now() - a, l = h.status;
910
- let u = null;
857
+ const n = performance.now(), r = { ...e.headers, "Content-Type": "application/json" }, i = await fetch(s, {
858
+ headers: r,
859
+ method: e.method,
860
+ body: e.body ? JSON.stringify(e.body) : void 0
861
+ }), a = performance.now() - n, u = i.status;
862
+ let o = null;
911
863
  try {
912
- u = await h.json();
864
+ o = await i.json();
913
865
  } catch {
914
- u = null;
866
+ o = null;
915
867
  }
916
- const d = V.handle({
917
- elapsedTime: i,
918
- method: e,
919
- queryParams: new URL(t).searchParams,
920
- requestHeaders: c,
921
- requestBody: n,
922
- responseBody: u,
923
- responseHeaders: h.headers,
924
- status: l,
925
- url: t
868
+ const h = G.handle({
869
+ elapsedTime: a,
870
+ method: e.method,
871
+ queryParams: new URL(s).searchParams,
872
+ requestHeaders: r,
873
+ requestBody: e.body,
874
+ responseBody: o,
875
+ responseHeaders: i.headers,
876
+ status: u,
877
+ rawUrl: e.url,
878
+ urlParams: e.urlParams
926
879
  });
927
- return G(d), h.ok ? {
880
+ return W(h), i.ok ? {
928
881
  success: !0,
929
- status: l,
930
- message: (u == null ? void 0 : u.message) || r[e],
931
- response: u,
882
+ status: u,
883
+ message: (o == null ? void 0 : o.message) || t[e.method],
884
+ response: o,
932
885
  cause: null
933
886
  } : {
934
887
  success: !1,
935
- status: l,
936
- message: (u == null ? void 0 : u.message) || h.statusText || "Request failed",
937
- response: u,
888
+ status: u,
889
+ message: (o == null ? void 0 : o.message) || i.statusText || "Request failed",
890
+ response: o,
938
891
  cause: null
939
892
  };
940
- } catch (a) {
941
- return g({
942
- debugs: [`Network error or request failed: ${a}`],
943
- name: "ARKYN_MAKE_REQUEST_ERROR",
893
+ } catch (n) {
894
+ return p({
895
+ debugs: [`Network error or request failed: ${n}`],
896
+ name: "MakeRequestError",
944
897
  scheme: "red"
945
898
  }), {
946
899
  success: !1,
947
900
  status: 0,
948
901
  message: "Network error or request failed",
949
902
  response: null,
950
- cause: a instanceof Error ? a.message : String(a)
903
+ cause: n instanceof Error ? n.message : String(n)
951
904
  };
952
905
  }
953
906
  }
954
- async function Z(e, t = {}, s) {
955
- return b("DELETE", e, t, s);
907
+ async function Y(e) {
908
+ return g({
909
+ method: "DELETE",
910
+ url: e.url,
911
+ urlParams: e.urlParams,
912
+ headers: e.headers,
913
+ body: e.body
914
+ });
956
915
  }
957
- async function W(e, t = {}) {
958
- return b("GET", e, t);
916
+ async function K(e) {
917
+ return g({
918
+ method: "GET",
919
+ url: e.url,
920
+ urlParams: e.urlParams,
921
+ headers: e.headers
922
+ });
959
923
  }
960
- async function K(e, t = {}, s) {
961
- return b("PATCH", e, t, s);
924
+ async function Q(e) {
925
+ return g({
926
+ method: "PATCH",
927
+ url: e.url,
928
+ urlParams: e.urlParams,
929
+ headers: e.headers,
930
+ body: e.body
931
+ });
962
932
  }
963
- async function Q(e, t = {}, s) {
964
- return b("POST", e, t, s);
933
+ async function X(e) {
934
+ return g({
935
+ method: "POST",
936
+ url: e.url,
937
+ urlParams: e.urlParams,
938
+ headers: e.headers,
939
+ body: e.body
940
+ });
965
941
  }
966
- async function X(e, t = {}, s) {
967
- return b("PUT", e, t, s);
942
+ async function ss(e) {
943
+ return g({
944
+ method: "PUT",
945
+ url: e.url,
946
+ urlParams: e.urlParams,
947
+ headers: e.headers,
948
+ body: e.body
949
+ });
968
950
  }
969
- class Ts {
970
- /**
971
- * Creates an instance of ApiService.
972
- * @param props - The configuration properties for the API instance.
973
- * @param props.baseUrl - The base URL for the API.
974
- * @param props.baseHeaders - Optional base headers to include in all requests.
975
- * @param props.baseToken - Optional base token for authorization.
976
- * @param props.enableDebug - Optional flag to enable debug logging for requests.
977
- */
978
- constructor(t) {
979
- o(this, "baseUrl");
980
- o(this, "baseHeaders");
981
- o(this, "baseToken");
982
- o(this, "enableDebug");
983
- this.baseUrl = t.baseUrl, this.baseHeaders = t.baseHeaders || void 0, this.baseToken = t.baseToken || void 0, this.enableDebug = t.enableDebug || !1;
951
+ class Es {
952
+ constructor(s) {
953
+ c(this, "baseUrl");
954
+ c(this, "baseHeaders");
955
+ c(this, "baseToken");
956
+ c(this, "enableDebug");
957
+ this.baseUrl = s.baseUrl, this.baseHeaders = s.baseHeaders || void 0, this.baseToken = s.baseToken || void 0, this.enableDebug = s.enableDebug || !1;
984
958
  }
985
- /**
986
- * Generates the full URL by appending the route to the base URL.
987
- * @param route - The route to append to the base URL.
988
- * @returns The full URL as a string.
989
- */
990
- onDebug(t, s, n) {
959
+ onDebug(s, t, n) {
991
960
  if (this.enableDebug) {
992
961
  const r = [];
993
- r.push(`Base URL: ${this.baseUrl}`), r.push(`Endpoint: ${t}`), r.push(`Method: ${s}`), n[0] && r.push(`Headers: ${JSON.stringify(n[0])}`), n[1] && r.push(`Body: ${JSON.stringify(n[1])}`), g({ debugs: r, name: "ARKYN-API-DEBUG", scheme: "yellow" });
962
+ r.push(`Base URL: ${this.baseUrl}`), r.push(`Endpoint: ${s}`), r.push(`Method: ${t}`), n[0] && r.push(`Headers: ${JSON.stringify(n[0])}`), n[1] && r.push(`Body: ${JSON.stringify(n[1])}`), p({ debugs: r, name: "ARKYN-API-DEBUG", scheme: "yellow" });
994
963
  }
995
964
  }
996
- generateURL(t) {
997
- return this.baseUrl + t;
998
- }
999
- /**
1000
- * Generates the headers for a request by merging base headers, provided headers, and tokens.
1001
- * @param initHeaders - Initial headers to include in the request.
1002
- * @param token - Optional token to override the base token.
1003
- * @returns The merged headers as a HeadersInit object.
1004
- */
1005
- generateHeaders(t, s) {
965
+ generateHeaders(s, t) {
1006
966
  let n = {};
1007
- return this.baseToken && (n = { Authorization: `Bearer ${this.baseToken}` }), this.baseHeaders && (n = { ...n, ...this.baseHeaders }), t && (n = { ...n, ...t }), s && (n = { ...n, Authorization: `Bearer ${s}` }), n;
967
+ return this.baseToken && (n = { Authorization: `Bearer ${this.baseToken}` }), this.baseHeaders && (n = { ...n, ...this.baseHeaders }), s && (n = { ...n, ...s }), t && (n = { ...n, Authorization: `Bearer ${t}` }), n;
1008
968
  }
1009
969
  /**
1010
970
  * Sends a get request to the specified endpoint.
@@ -1012,9 +972,13 @@ class Ts {
1012
972
  * @param data - The request data, including optional headers and token.
1013
973
  * @returns The API response data.
1014
974
  */
1015
- async get(t, s) {
1016
- const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token);
1017
- return this.onDebug(t, "get", [r]), await W(n, r);
975
+ async get(s, t) {
976
+ const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token);
977
+ return this.onDebug(s, "get", [n]), await K({
978
+ url: this.baseUrl + s,
979
+ urlParams: (t == null ? void 0 : t.urlParams) || {},
980
+ headers: n
981
+ });
1018
982
  }
1019
983
  /**
1020
984
  * Sends a post request to the specified endpoint.
@@ -1022,9 +986,14 @@ class Ts {
1022
986
  * @param data - The request data, including body, optional headers, and token.
1023
987
  * @returns The API response data.
1024
988
  */
1025
- async post(t, s) {
1026
- const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
1027
- return this.onDebug(t, "post", [r, a]), await Q(n, r, a);
989
+ async post(s, t) {
990
+ const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token), r = t == null ? void 0 : t.body;
991
+ return this.onDebug(s, "post", [n, r]), await X({
992
+ url: this.baseUrl + s,
993
+ urlParams: (t == null ? void 0 : t.urlParams) || {},
994
+ headers: n,
995
+ body: r
996
+ });
1028
997
  }
1029
998
  /**
1030
999
  * Sends a put request to the specified endpoint.
@@ -1032,9 +1001,14 @@ class Ts {
1032
1001
  * @param data - The request data, including body, optional headers, and token.
1033
1002
  * @returns The API response data.
1034
1003
  */
1035
- async put(t, s) {
1036
- const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
1037
- return this.onDebug(t, "put", [r, a]), await X(n, r, a);
1004
+ async put(s, t) {
1005
+ const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token), r = t == null ? void 0 : t.body;
1006
+ return this.onDebug(s, "put", [n, r]), await ss({
1007
+ url: this.baseUrl + s,
1008
+ urlParams: (t == null ? void 0 : t.urlParams) || {},
1009
+ headers: n,
1010
+ body: r
1011
+ });
1038
1012
  }
1039
1013
  /**
1040
1014
  * Sends a patch request to the specified endpoint.
@@ -1042,9 +1016,14 @@ class Ts {
1042
1016
  * @param data - The request data, including body, optional headers, and token.
1043
1017
  * @returns The API response data.
1044
1018
  */
1045
- async patch(t, s) {
1046
- const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
1047
- return this.onDebug(t, "patch", [r, a]), await K(n, r, a);
1019
+ async patch(s, t) {
1020
+ const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token), r = t == null ? void 0 : t.body;
1021
+ return this.onDebug(s, "patch", [n, r]), await Q({
1022
+ url: this.baseUrl + s,
1023
+ urlParams: (t == null ? void 0 : t.urlParams) || {},
1024
+ headers: n,
1025
+ body: r
1026
+ });
1048
1027
  }
1049
1028
  /**
1050
1029
  * Sends a delete request to the specified endpoint.
@@ -1052,137 +1031,137 @@ class Ts {
1052
1031
  * @param data - The request data, including body, optional headers, and token.
1053
1032
  * @returns The API response data.
1054
1033
  */
1055
- async delete(t, s) {
1056
- const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
1057
- return this.onDebug(t, "delete", [r, a]), await Z(n, r, a);
1034
+ async delete(s, t) {
1035
+ const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token), r = t == null ? void 0 : t.body;
1036
+ return this.onDebug(s, "delete", [n, r]), await Y({
1037
+ url: this.baseUrl + s,
1038
+ urlParams: (t == null ? void 0 : t.urlParams) || {},
1039
+ headers: n,
1040
+ body: r
1041
+ });
1058
1042
  }
1059
1043
  }
1060
- function Rs(e, t) {
1061
- var s, n, r;
1062
- return e != null && e.message && typeof (e == null ? void 0 : e.message) == "string" ? e == null ? void 0 : e.message : e != null && e.error && typeof (e == null ? void 0 : e.error) == "string" ? e == null ? void 0 : e.error : (s = e == null ? void 0 : e.error) != null && s.message && typeof ((n = e == null ? void 0 : e.error) == null ? void 0 : n.message) == "string" ? (r = e == null ? void 0 : e.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";
1063
- }
1064
- const Ns = async (e) => {
1065
- let t;
1066
- const s = await e.arrayBuffer(), n = new TextDecoder().decode(s);
1044
+ async function vs(e) {
1045
+ let s;
1046
+ const t = await e.arrayBuffer(), n = new TextDecoder().decode(t);
1067
1047
  try {
1068
- t = JSON.parse(n);
1048
+ s = JSON.parse(n);
1069
1049
  } catch {
1070
1050
  try {
1071
1051
  if (n.includes("=")) {
1072
- const a = new URLSearchParams(n);
1073
- t = Object.fromEntries(a.entries());
1052
+ const i = new URLSearchParams(n);
1053
+ s = Object.fromEntries(i.entries());
1074
1054
  } else
1075
- throw new x("Invalid URLSearchParams format");
1055
+ throw new T("Invalid URLSearchParams format");
1076
1056
  } catch {
1077
- throw new x("Failed to extract data from request");
1057
+ throw new T("Failed to extract data from request");
1078
1058
  }
1079
1059
  }
1080
- return t;
1081
- };
1082
- function Es(e) {
1060
+ return s;
1061
+ }
1062
+ function $s(e, s) {
1063
+ var t, n, r;
1064
+ return e != null && e.message && typeof (e == null ? void 0 : e.message) == "string" ? e == null ? void 0 : e.message : e != null && e.error && typeof (e == null ? void 0 : e.error) == "string" ? e == null ? void 0 : e.error : (t = e == null ? void 0 : e.error) != null && t.message && typeof ((n = e == null ? void 0 : e.error) == null ? void 0 : n.message) == "string" ? (r = e == null ? void 0 : e.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";
1065
+ }
1066
+ function Bs(e) {
1083
1067
  switch (!0) {
1084
1068
  case e instanceof Response:
1085
1069
  return e;
1086
- case e instanceof Y:
1070
+ case e instanceof z:
1087
1071
  return e.toResponse();
1088
- case e instanceof P:
1072
+ case e instanceof F:
1089
1073
  return e.toResponse();
1090
- case e instanceof _:
1074
+ case e instanceof Z:
1091
1075
  return e.toResponse();
1092
- case e instanceof M:
1076
+ case e instanceof V:
1093
1077
  return e.toResponse();
1094
- case e instanceof z:
1078
+ case e instanceof M:
1095
1079
  return e.toResponse();
1096
1080
  }
1097
1081
  switch (!0) {
1098
- case e instanceof L:
1082
+ case e instanceof U:
1099
1083
  return e.toResponse();
1100
- case e instanceof x:
1084
+ case e instanceof T:
1101
1085
  return e.toResponse();
1102
- case e instanceof B:
1086
+ case e instanceof C:
1103
1087
  return e.toResponse();
1104
- case e instanceof k:
1088
+ case e instanceof A:
1105
1089
  return e.toResponse();
1106
1090
  case e instanceof q:
1107
1091
  return e.toResponse();
1108
- case e instanceof F:
1092
+ case e instanceof H:
1109
1093
  return e.toResponse();
1110
- case e instanceof T:
1094
+ case e instanceof x:
1111
1095
  return e.toResponse();
1112
- case e instanceof H:
1096
+ case e instanceof L:
1113
1097
  return e.toResponse();
1114
- case e instanceof R:
1098
+ case e instanceof b:
1115
1099
  return e.toResponse();
1116
1100
  }
1117
- return new T("Server error", e).toResponse();
1101
+ return new x("Server error", e).toResponse();
1118
1102
  }
1119
- async function ss([
1103
+ async function es([
1120
1104
  e,
1121
- t
1105
+ s
1122
1106
  ]) {
1123
- const s = await t.safeParseAsync(e);
1124
- if (s.success === !1) {
1107
+ const t = await s.safeParseAsync(e);
1108
+ if (t.success === !1) {
1125
1109
  const n = Object.fromEntries(
1126
- s.error.issues.map((r) => [r.path.join("."), r.message])
1110
+ t.error.issues.map((r) => [r.path.join("."), r.message])
1127
1111
  );
1128
1112
  return {
1129
- success: s.success,
1113
+ success: t.success,
1130
1114
  fieldErrors: n,
1131
1115
  fields: e
1132
1116
  };
1133
1117
  } else
1134
1118
  return {
1135
- success: s.success,
1136
- data: s.data
1119
+ success: t.success,
1120
+ data: t.data
1137
1121
  };
1138
1122
  }
1139
- function es([
1123
+ function ts([
1140
1124
  e,
1141
- t
1125
+ s
1142
1126
  ]) {
1143
- const s = t.safeParse(e);
1144
- if (s.success === !1) {
1127
+ const t = s.safeParse(e);
1128
+ if (t.success === !1) {
1145
1129
  const n = Object.fromEntries(
1146
- s.error.issues.map((r) => [r.path.join("."), r.message])
1130
+ t.error.issues.map((r) => [r.path.join("."), r.message])
1147
1131
  );
1148
1132
  return {
1149
- success: s.success,
1133
+ success: t.success,
1150
1134
  fieldErrors: n,
1151
1135
  fields: e
1152
1136
  };
1153
1137
  } else
1154
1138
  return {
1155
- success: s.success,
1156
- data: s.data
1139
+ success: t.success,
1140
+ data: t.data
1157
1141
  };
1158
1142
  }
1159
- const Ss = (e, t = "") => {
1160
- const s = new URL(e.url);
1161
- if (t === "") return s.searchParams;
1143
+ function Os(e, s = "") {
1144
+ const t = new URL(e.url);
1145
+ if (s === "") return t.searchParams;
1162
1146
  const n = Array.from(
1163
- s.searchParams.entries()
1164
- ).filter(([r]) => r.startsWith(`${t}:`)).map(([r, a]) => [r.replace(`${t}:`, ""), a]);
1147
+ t.searchParams.entries()
1148
+ ).filter(([r]) => r.startsWith(`${s}:`)).map(([r, i]) => [r.replace(`${s}:`, ""), i]);
1165
1149
  return new URLSearchParams(n);
1166
- };
1167
- function ts(e) {
1168
- const t = "Error validating:", s = e.issues.map(
1150
+ }
1151
+ function ns(e) {
1152
+ const s = "Error validating:", t = e.issues.map(
1169
1153
  ({ path: n, message: r }) => `-> ${n.join(".")}: ${r}`
1170
1154
  );
1171
- return [t, ...s].join(`
1155
+ return [s, ...t].join(`
1172
1156
  `);
1173
1157
  }
1174
- class Os {
1158
+ class Ps {
1175
1159
  /**
1176
1160
  * Creates a new SchemaValidator instance.
1177
- *
1178
1161
  * @param {T} schema - The Zod schema to use for validation.
1179
1162
  */
1180
- constructor(t) {
1181
- o(this, "functionName");
1182
- o(this, "callerInfo");
1183
- this.schema = t;
1184
- const { callerInfo: s, functionName: n } = E();
1185
- this.callerInfo = s, this.functionName = n;
1163
+ constructor(s) {
1164
+ this.schema = s;
1186
1165
  }
1187
1166
  /**
1188
1167
  * Checks if the provided data is valid according to the schema without throwing errors.
@@ -1198,14 +1177,13 @@ class Os {
1198
1177
  * console.log(isValid); // false
1199
1178
  * ```
1200
1179
  */
1201
- isValid(t) {
1202
- return this.schema.safeParse(t).success;
1180
+ isValid(s) {
1181
+ return this.schema.safeParse(s).success;
1203
1182
  }
1204
1183
  /**
1205
1184
  * Safely validates data and returns the complete parse result without throwing errors.
1206
1185
  *
1207
1186
  * @param {any} data - The data to validate.
1208
- *
1209
1187
  * @returns {z.ZodSafeParseResult<z.infer<T>>} The Zod safe parse result containing success status and data or error.
1210
1188
  *
1211
1189
  * @example
@@ -1220,17 +1198,15 @@ class Os {
1220
1198
  * }
1221
1199
  * ```
1222
1200
  */
1223
- safeValidate(t) {
1224
- return this.schema.safeParse(t);
1201
+ safeValidate(s) {
1202
+ return this.schema.safeParse(s);
1225
1203
  }
1226
1204
  /**
1227
1205
  * Validates data and returns the parsed result, throwing a ServerError on validation failure.
1228
1206
  *
1229
1207
  * @param {any} data - The data to validate.
1230
- *
1231
- * @returns {z.infer<T>} The validated and parsed data.
1232
- *
1233
1208
  * @throws {ServerError} When validation fails, with a formatted error message.
1209
+ * @returns {z.infer<T>} The validated and parsed data.
1234
1210
  *
1235
1211
  * @example
1236
1212
  * ```typescript
@@ -1244,11 +1220,11 @@ class Os {
1244
1220
  * }
1245
1221
  * ```
1246
1222
  */
1247
- validate(t) {
1223
+ validate(s) {
1248
1224
  try {
1249
- return this.schema.parse(t);
1250
- } catch (s) {
1251
- throw new T(ts(s));
1225
+ return this.schema.parse(s);
1226
+ } catch (t) {
1227
+ throw new x(ns(t));
1252
1228
  }
1253
1229
  }
1254
1230
  /**
@@ -1257,10 +1233,8 @@ class Os {
1257
1233
  *
1258
1234
  * @param {any} data - The form data to validate.
1259
1235
  * @param {string} [message] - Optional custom error message.
1260
- *
1261
- * @returns {z.infer<T>} The validated and parsed form data.
1262
- *
1263
1236
  * @throws {UnprocessableEntity} When validation fails, with structured field errors for form handling.
1237
+ * @returns {z.infer<T>} The validated and parsed form data.
1264
1238
  *
1265
1239
  * @example
1266
1240
  * ```typescript
@@ -1276,15 +1250,15 @@ class Os {
1276
1250
  * }
1277
1251
  * ```
1278
1252
  */
1279
- formValidate(t, s) {
1280
- const n = es([t, this.schema]);
1253
+ formValidate(s, t) {
1254
+ const n = ts([s, this.schema]);
1281
1255
  if (!n.success) {
1282
1256
  const r = Object.keys(n.fieldErrors)[0];
1283
- throw new R({
1257
+ throw new b({
1284
1258
  fields: n.fields,
1285
1259
  fieldErrors: n.fieldErrors,
1286
1260
  data: { scrollTo: r },
1287
- message: s
1261
+ message: t
1288
1262
  });
1289
1263
  }
1290
1264
  return n.data;
@@ -1295,10 +1269,8 @@ class Os {
1295
1269
  *
1296
1270
  * @param {any} data - The form data to validate.
1297
1271
  * @param {string} [message] - Optional custom error message.
1298
- *
1299
- * @returns {Promise<z.infer<T>>} A promise that resolves to the validated and parsed form data.
1300
- *
1301
1272
  * @throws {UnprocessableEntity} When validation fails, with structured field errors for form handling.
1273
+ * @returns {Promise<z.infer<T>>} A promise that resolves to the validated and parsed form data.
1302
1274
  *
1303
1275
  * @example
1304
1276
  * ```typescript
@@ -1314,194 +1286,209 @@ class Os {
1314
1286
  * }
1315
1287
  * ```
1316
1288
  */
1317
- async formAsyncValidate(t, s) {
1318
- const n = await ss([t, this.schema]);
1289
+ async formAsyncValidate(s, t) {
1290
+ const n = await es([s, this.schema]);
1319
1291
  if (!n.success) {
1320
1292
  const r = Object.keys(n.fieldErrors)[0];
1321
- throw new R({
1293
+ throw new b({
1322
1294
  fields: n.fields,
1323
1295
  fieldErrors: n.fieldErrors,
1324
1296
  data: { scrollTo: r },
1325
- message: s
1297
+ message: t
1326
1298
  });
1327
1299
  }
1328
1300
  return n.data;
1329
1301
  }
1330
1302
  }
1331
- const Ds = (e) => {
1332
- if (!e || !/^[0-9-]+$/.test(e)) return !1;
1333
- const s = N(e), n = 8, r = /^\d{8}$/.test(s);
1334
- return s.length === n && r;
1335
- };
1336
- function ns(e) {
1337
- return e.length !== 14;
1303
+ function ks(e) {
1304
+ if (!(/^\d{5}-\d{3}$/.test(e) || /^\d{8}$/.test(e))) return !1;
1305
+ const t = R(e), n = 8, r = /^\d{8}$/.test(t);
1306
+ return t.length === n && r;
1338
1307
  }
1339
1308
  function rs(e) {
1340
- const [t] = e;
1341
- return [...e].every((s) => s === t);
1309
+ return e.length !== 14;
1310
+ }
1311
+ function os(e) {
1312
+ const [s] = e;
1313
+ return [...e].every((t) => t === s);
1342
1314
  }
1343
- function D(e, t) {
1344
- let s = 0;
1345
- for (let r = 0; r < t.length; r++)
1346
- s += parseInt(e[r]) * t[r];
1347
- const n = s % 11;
1315
+ function N(e, s) {
1316
+ let t = 0;
1317
+ for (let r = 0; r < s.length; r++)
1318
+ t += parseInt(e[r]) * s[r];
1319
+ const n = t % 11;
1348
1320
  return n < 2 ? 0 : 11 - n;
1349
1321
  }
1350
- function os(e) {
1322
+ function is(e) {
1351
1323
  return e.slice(12);
1352
1324
  }
1353
- const $s = (e) => {
1354
- if (!e) return !1;
1355
- const t = N(e);
1356
- if (ns(t) || rs(t)) return !1;
1357
- const s = t.slice(0, 12), n = D(s, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), r = D(
1358
- s + n,
1325
+ function ws(e) {
1326
+ if (!e || e.length > 18 || e.length < 14 || /\s/.test(e)) return !1;
1327
+ const t = R(e);
1328
+ if (rs(t) || os(t)) return !1;
1329
+ const n = t.slice(0, 12), r = N(n, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), i = N(
1330
+ n + r,
1359
1331
  [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
1360
1332
  );
1361
- return os(t) === `${n}${r}`;
1362
- };
1333
+ return is(t) === `${r}${i}`;
1334
+ }
1363
1335
  function as(e) {
1364
1336
  return e.length !== 11;
1365
1337
  }
1366
1338
  function us(e) {
1367
- const [t] = e;
1368
- return [...e].every((s) => s === t);
1339
+ const [s] = e;
1340
+ return [...e].every((t) => t === s);
1369
1341
  }
1370
- function $(e, t) {
1371
- let s = 0;
1342
+ function E(e, s) {
1343
+ let t = 0;
1372
1344
  for (const r of e)
1373
- t > 1 && (s += parseInt(r) * t--);
1374
- const n = s % 11;
1345
+ s > 1 && (t += parseInt(r) * s--);
1346
+ const n = t % 11;
1375
1347
  return n < 2 ? 0 : 11 - n;
1376
1348
  }
1377
- function is(e) {
1349
+ function cs(e) {
1378
1350
  return e.slice(9);
1379
1351
  }
1380
- const Is = (e) => {
1381
- if (!e) return !1;
1382
- const t = N(e);
1352
+ function Js(e) {
1353
+ if (!e || e.length > 14 || e.length < 11 || /\s/.test(e)) return !1;
1354
+ const t = R(e);
1383
1355
  if (as(t) || us(t)) return !1;
1384
- const s = $(t, 10), n = $(t, 11);
1385
- return is(t) === `${s}${n}`;
1386
- }, Cs = (e, t) => {
1387
- let s, n, r;
1388
- const a = (t == null ? void 0 : t.inputFormat) || "DD/MM/YYYY", c = (t == null ? void 0 : t.minYear) || 1900, h = (t == null ? void 0 : t.maxYear) || 3e3;
1389
- if (a === "DD/MM/YYYY") {
1390
- const f = /^(\d{2})\/(\d{2})\/(\d{4})$/;
1391
- if (!f.test(e)) return !1;
1392
- [, s, n, r] = e.match(f) || [];
1393
- } else if (a === "MM-DD-YYYY") {
1394
- const f = /^(\d{2})-(\d{2})-(\d{4})$/;
1395
- if (!f.test(e)) return !1;
1396
- [, n, s, r] = e.match(f) || [];
1397
- } else if (a === "YYYY-MM-DD") {
1398
- const f = /^(\d{4})-(\d{2})-(\d{2})$/;
1399
- if (!f.test(e)) return !1;
1400
- [, r, n, s] = e.match(f) || [];
1401
- } else
1402
- throw new Error("Invalid date format");
1403
- const i = parseInt(s, 10), l = parseInt(n, 10), u = parseInt(r, 10);
1404
- if (i < 1 || i > 31 || l < 1 || l > 12) return !1;
1405
- const d = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
1406
- if (l === 2) {
1407
- const f = u % 4 === 0 && u % 100 !== 0 || u % 400 === 0;
1408
- if (i > (f ? 29 : 28)) return !1;
1409
- } else if (i > d[l - 1])
1356
+ const n = E(t, 10), r = E(t, 11);
1357
+ return cs(t) === `${n}${r}`;
1358
+ }
1359
+ function js(e, s) {
1360
+ const t = (s == null ? void 0 : s.inputFormat) || "brazilianDate", n = (s == null ? void 0 : s.minYear) || 1900, r = (s == null ? void 0 : s.maxYear) || 3e3, i = new J();
1361
+ i.validateInputFormat(t);
1362
+ let a, u, o;
1363
+ const h = e.split(/[-/]/).map(Number);
1364
+ if (h.length !== 3) return !1;
1365
+ try {
1366
+ switch (t) {
1367
+ case "brazilianDate":
1368
+ [a, u, o] = h, i.validateDateParts(o, u, a);
1369
+ break;
1370
+ case "isoDate":
1371
+ [u, a, o] = h, i.validateDateParts(o, u, a);
1372
+ break;
1373
+ case "timestamp":
1374
+ [o, u, a] = h, i.validateDateParts(o, u, a);
1375
+ break;
1376
+ }
1377
+ return !(o < n || o > r);
1378
+ } catch {
1410
1379
  return !1;
1411
- return u < c || u > h ? !1 : new Date(u, l - 1, i).getDate() === i;
1412
- };
1413
- function cs(e) {
1414
- return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(e);
1380
+ }
1415
1381
  }
1416
1382
  function hs(e) {
1417
- return !(e.length === 0 || e.length > 64 || e.startsWith(".") || e.endsWith(".") || e.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e));
1383
+ return /^[a-zA-Z0-9.!$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(e);
1418
1384
  }
1419
1385
  function ls(e) {
1420
- return !(e.length === 0 || e.length > 63 || e.startsWith("-") || e.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(e));
1386
+ return !(e.length === 0 || e.length > 64 || e.startsWith(".") || e.endsWith(".") || e.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e));
1421
1387
  }
1422
1388
  function fs(e) {
1389
+ return !(e.length === 0 || e.length > 63 || e.startsWith("-") || e.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(e));
1390
+ }
1391
+ function ms(e) {
1423
1392
  if (e.length === 0 || e.length > 253 || e.startsWith(".") || e.endsWith(".") || e.startsWith("-") || e.endsWith("-"))
1424
1393
  return !1;
1425
- const t = e.split(".");
1426
- if (t.length < 2) return !1;
1427
- for (const n of t) if (!ls(n)) return !1;
1428
- const s = t[t.length - 1];
1429
- return !(s.length < 2 || !/^[a-zA-Z]+$/.test(s));
1394
+ const s = e.split(".");
1395
+ if (s.length < 2) return !1;
1396
+ for (const n of s) if (!fs(n)) return !1;
1397
+ const t = s[s.length - 1];
1398
+ return !(t.length < 2 || !/^[a-zA-Z]+$/.test(t));
1430
1399
  }
1431
1400
  function ds(e) {
1432
- const t = e.split("@");
1433
- if (t.length !== 2) return !1;
1434
- const [s, n] = t;
1435
- return !(!hs(s) || !fs(n));
1401
+ const s = e.split("@");
1402
+ if (s.length !== 2) return !1;
1403
+ const [t, n] = s;
1404
+ return !(!ls(t) || !ms(n));
1436
1405
  }
1437
1406
  function ps(e) {
1438
- const t = e.split("@");
1439
- return t.length === 2 ? t[1].toLowerCase() : null;
1407
+ const s = e.split("@");
1408
+ return s.length === 2 ? s[1].toLowerCase() : null;
1409
+ }
1410
+ const ys = ["MX", "A", "AAAA"];
1411
+ async function gs(e, s) {
1412
+ var t, n;
1413
+ try {
1414
+ return await ((n = (t = j) == null ? void 0 : t.promises) == null ? void 0 : n.resolve(e, s)), !0;
1415
+ } catch {
1416
+ return !1;
1417
+ }
1440
1418
  }
1441
- const Js = async (e) => {
1419
+ async function Ts(e) {
1420
+ for (const s of ys)
1421
+ if (await gs(e, s)) return !0;
1422
+ return !1;
1423
+ }
1424
+ async function _s(e) {
1442
1425
  if (!e || typeof e != "string") return !1;
1443
- const t = e.trim();
1444
- return !(!cs(t) || !ds(t) || !ps(t));
1445
- }, js = (e) => {
1426
+ const s = e.trim();
1427
+ if (!hs(s) || !ds(s)) return !1;
1428
+ const t = ps(s);
1429
+ return t ? await Ts(t) : !1;
1430
+ }
1431
+ function Is(e) {
1446
1432
  if (!e) return !1;
1447
- const t = e.length >= 8, s = /[A-Z]/.test(e), n = /[a-z]/.test(e), r = /\d/.test(e), a = /[!@#$%^&*(),.?":{}|<>_\-+=~`[\]\\\/]/.test(
1433
+ const s = e.length >= 8, t = /[A-Z]/.test(e), n = /[a-z]/.test(e), r = /\d/.test(e), i = /[!@#$%^&*(),.?":;{}|<>_\-+=~`[\]\\\/]/.test(
1448
1434
  e
1449
1435
  );
1450
1436
  return [
1451
- t,
1452
1437
  s,
1438
+ t,
1453
1439
  n,
1454
1440
  r,
1455
- a
1456
- ].every((c) => c);
1457
- }, ws = (e) => {
1458
- for (const t of v) {
1459
- const s = t.code, n = t.prefix ? `-${t.prefix}` : "", r = t.mask.replace(/[^_]/g, "").length;
1460
- if (t.iso === "BR") {
1461
- if (new RegExp(`^\\${s} \\d{2}9?\\d{8}$`).test(e)) return !0;
1441
+ i
1442
+ ].every((a) => a);
1443
+ }
1444
+ function Us(e) {
1445
+ for (const s of _) {
1446
+ const t = s.code, n = s.prefix ? `-${s.prefix}` : "", r = s.mask.replace(/[^_]/g, "").length;
1447
+ if (s.iso === "BR") {
1448
+ if (new RegExp(`^\\${t} \\d{2}9?\\d{8}$`).test(e)) return !0;
1462
1449
  continue;
1463
1450
  }
1464
- if (new RegExp(`^\\${s}${n} \\d{${r}}$`).test(e)) return !0;
1451
+ if (new RegExp(`^\\${t}${n} \\d{${r}}$`).test(e)) return !0;
1465
1452
  }
1466
1453
  return !1;
1467
- }, Us = (e) => {
1454
+ }
1455
+ function Cs(e) {
1468
1456
  if (!e || !/^[0-9a-zA-Z.-]+$/.test(e)) return !1;
1469
- const s = e.replace(/[^a-zA-Z0-9]/g, "");
1470
- return s.length < 7 || s.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(s);
1471
- };
1457
+ const t = e.replace(/[^a-zA-Z0-9]/g, "");
1458
+ return t.length < 7 || t.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(t);
1459
+ }
1472
1460
  export {
1473
- Ts as ApiService,
1474
- C as ArkynLogService,
1475
- L as BadGateway,
1476
- x as BadRequest,
1477
- B as Conflict,
1478
- P as Created,
1479
- I as DebugService,
1480
- k as Forbidden,
1481
- Y as Found,
1482
- z as NoContent,
1461
+ Es as ApiService,
1462
+ U as BadGateway,
1463
+ T as BadRequest,
1464
+ C as Conflict,
1465
+ F as Created,
1466
+ S as DebugService,
1467
+ A as Forbidden,
1468
+ z as Found,
1469
+ v as LogService,
1470
+ M as NoContent,
1483
1471
  q as NotFound,
1484
- F as NotImplemented,
1485
- Os as SchemaValidator,
1486
- T as ServerError,
1487
- M as Success,
1488
- H as Unauthorized,
1489
- R as UnprocessableEntity,
1490
- _ as Updated,
1491
- Rs as decodeErrorMessageFromRequest,
1492
- Ns as decodeRequestBody,
1493
- Es as errorHandler,
1494
- g as flushDebugLogs,
1495
- ss as formAsyncParse,
1496
- es as formParse,
1497
- E as getCaller,
1498
- Ss as getScopedParams,
1499
- Ds as validateCep,
1500
- $s as validateCnpj,
1501
- Is as validateCpf,
1502
- Cs as validateDate,
1503
- Js as validateEmail,
1504
- js as validatePassword,
1505
- ws as validatePhone,
1506
- Us as validateRg
1472
+ H as NotImplemented,
1473
+ Ps as SchemaValidator,
1474
+ x as ServerError,
1475
+ V as Success,
1476
+ L as Unauthorized,
1477
+ b as UnprocessableEntity,
1478
+ Z as Updated,
1479
+ vs as decodeRequestBody,
1480
+ $s as decodeRequestErrorMessage,
1481
+ Bs as errorHandler,
1482
+ p as flushDebugLogs,
1483
+ es as formAsyncParse,
1484
+ ts as formParse,
1485
+ Os as getScopedParams,
1486
+ ks as validateCep,
1487
+ ws as validateCnpj,
1488
+ Js as validateCpf,
1489
+ js as validateDate,
1490
+ _s as validateEmail,
1491
+ Is as validatePassword,
1492
+ Us as validatePhone,
1493
+ Cs as validateRg
1507
1494
  };