@arkyn/server 3.0.1-beta.160 → 3.0.1-beta.168
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +18 -9
- package/dist/http/api/_logRequest.d.ts +0 -58
- package/dist/http/api/_logRequest.d.ts.map +0 -1
- package/dist/http/api/_makeRequest.d.ts +0 -61
- package/dist/http/api/_makeRequest.d.ts.map +0 -1
- package/dist/http/api/deleteRequest.d.ts +0 -17
- package/dist/http/api/deleteRequest.d.ts.map +0 -1
- package/dist/http/api/getRequest.d.ts +0 -16
- package/dist/http/api/getRequest.d.ts.map +0 -1
- package/dist/http/api/patchRequest.d.ts +0 -17
- package/dist/http/api/patchRequest.d.ts.map +0 -1
- package/dist/http/api/postRequest.d.ts +0 -17
- package/dist/http/api/postRequest.d.ts.map +0 -1
- package/dist/http/api/putRequest.d.ts +0 -17
- package/dist/http/api/putRequest.d.ts.map +0 -1
- package/dist/http/badResponses/_badResponse.d.ts +0 -25
- package/dist/http/badResponses/_badResponse.d.ts.map +0 -1
- package/dist/http/badResponses/badGateway.d.ts +0 -24
- package/dist/http/badResponses/badGateway.d.ts.map +0 -1
- package/dist/http/badResponses/badRequest.d.ts +0 -22
- package/dist/http/badResponses/badRequest.d.ts.map +0 -1
- package/dist/http/badResponses/conflict.d.ts +0 -22
- package/dist/http/badResponses/conflict.d.ts.map +0 -1
- package/dist/http/badResponses/forbidden.d.ts +0 -22
- package/dist/http/badResponses/forbidden.d.ts.map +0 -1
- package/dist/http/badResponses/notFound.d.ts +0 -22
- package/dist/http/badResponses/notFound.d.ts.map +0 -1
- package/dist/http/badResponses/notImplemented.d.ts +0 -22
- package/dist/http/badResponses/notImplemented.d.ts.map +0 -1
- package/dist/http/badResponses/serverError.d.ts +0 -22
- package/dist/http/badResponses/serverError.d.ts.map +0 -1
- package/dist/http/badResponses/unauthorized.d.ts +0 -22
- package/dist/http/badResponses/unauthorized.d.ts.map +0 -1
- package/dist/http/badResponses/unprocessableEntity.d.ts +0 -34
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +0 -1
- package/dist/http/successResponses/_successResponse.d.ts +0 -36
- package/dist/http/successResponses/_successResponse.d.ts.map +0 -1
- package/dist/http/successResponses/created.d.ts +0 -22
- package/dist/http/successResponses/created.d.ts.map +0 -1
- package/dist/http/successResponses/found.d.ts +0 -22
- package/dist/http/successResponses/found.d.ts.map +0 -1
- package/dist/http/successResponses/noContent.d.ts +0 -20
- package/dist/http/successResponses/noContent.d.ts.map +0 -1
- package/dist/http/successResponses/success.d.ts +0 -22
- package/dist/http/successResponses/success.d.ts.map +0 -1
- package/dist/http/successResponses/updated.d.ts +0 -23
- package/dist/http/successResponses/updated.d.ts.map +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1301
- package/dist/modules/http/api/_logRequest.js +0 -69
- package/dist/modules/http/api/_makeRequest.js +0 -69
- package/dist/modules/http/api/deleteRequest.js +0 -13
- package/dist/modules/http/api/getRequest.js +0 -12
- package/dist/modules/http/api/patchRequest.js +0 -13
- package/dist/modules/http/api/postRequest.js +0 -13
- package/dist/modules/http/api/putRequest.js +0 -13
- package/dist/modules/http/badResponses/_badResponse.js +0 -59
- package/dist/modules/http/badResponses/badGateway.js +0 -30
- package/dist/modules/http/badResponses/badRequest.js +0 -30
- package/dist/modules/http/badResponses/conflict.js +0 -30
- package/dist/modules/http/badResponses/forbidden.js +0 -30
- package/dist/modules/http/badResponses/notFound.js +0 -30
- package/dist/modules/http/badResponses/notImplemented.js +0 -30
- package/dist/modules/http/badResponses/serverError.js +0 -30
- package/dist/modules/http/badResponses/unauthorized.js +0 -30
- package/dist/modules/http/badResponses/unprocessableEntity.js +0 -36
- package/dist/modules/http/successResponses/_successResponse.js +0 -69
- package/dist/modules/http/successResponses/created.js +0 -30
- package/dist/modules/http/successResponses/found.js +0 -30
- package/dist/modules/http/successResponses/noContent.js +0 -21
- package/dist/modules/http/successResponses/success.js +0 -30
- package/dist/modules/http/successResponses/updated.js +0 -30
- package/dist/modules/index.js +0 -68
- package/dist/modules/services/apiService.js +0 -129
- package/dist/modules/services/debugService.js +0 -66
- package/dist/modules/services/logMapperService.js +0 -52
- package/dist/modules/services/logService.js +0 -31
- package/dist/modules/utilities/decodeRequestBody.js +0 -22
- package/dist/modules/utilities/decodeRequestErrorMessage.js +0 -7
- package/dist/modules/utilities/errorHandler.js +0 -54
- package/dist/modules/utilities/flushDebugLogs.js +0 -20
- package/dist/modules/utilities/formAsyncParse.js +0 -19
- package/dist/modules/utilities/formParse.js +0 -19
- package/dist/modules/utilities/getScopedParams.js +0 -11
- package/dist/modules/utilities/schemaValidator.js +0 -106
- package/dist/modules/validations/validateCep.js +0 -9
- package/dist/modules/validations/validateCnpj.js +0 -31
- package/dist/modules/validations/validateCpf.js +0 -28
- package/dist/modules/validations/validateDate.js +0 -27
- package/dist/modules/validations/validateEmail.js +0 -53
- package/dist/modules/validations/validatePassword.js +0 -16
- package/dist/modules/validations/validatePhone.js +0 -10
- package/dist/modules/validations/validateRg.js +0 -8
- package/dist/services/apiService.d.ts +0 -83
- package/dist/services/apiService.d.ts.map +0 -1
- package/dist/services/debugService.d.ts +0 -37
- package/dist/services/debugService.d.ts.map +0 -1
- package/dist/services/logMapperService.d.ts +0 -86
- package/dist/services/logMapperService.d.ts.map +0 -1
- package/dist/services/logService.d.ts +0 -33
- package/dist/services/logService.d.ts.map +0 -1
- package/dist/utilities/decodeRequestBody.d.ts +0 -18
- package/dist/utilities/decodeRequestBody.d.ts.map +0 -1
- package/dist/utilities/decodeRequestErrorMessage.d.ts +0 -19
- package/dist/utilities/decodeRequestErrorMessage.d.ts.map +0 -1
- package/dist/utilities/errorHandler.d.ts +0 -25
- package/dist/utilities/errorHandler.d.ts.map +0 -1
- package/dist/utilities/flushDebugLogs.d.ts +0 -24
- package/dist/utilities/flushDebugLogs.d.ts.map +0 -1
- package/dist/utilities/formAsyncParse.d.ts +0 -38
- package/dist/utilities/formAsyncParse.d.ts.map +0 -1
- package/dist/utilities/formParse.d.ts +0 -38
- package/dist/utilities/formParse.d.ts.map +0 -1
- package/dist/utilities/getScopedParams.d.ts +0 -19
- package/dist/utilities/getScopedParams.d.ts.map +0 -1
- package/dist/utilities/schemaValidator.d.ts +0 -75
- package/dist/utilities/schemaValidator.d.ts.map +0 -1
- package/dist/validations/validateCep.d.ts +0 -19
- package/dist/validations/validateCep.d.ts.map +0 -1
- package/dist/validations/validateCnpj.d.ts +0 -21
- package/dist/validations/validateCnpj.d.ts.map +0 -1
- package/dist/validations/validateCpf.d.ts +0 -16
- package/dist/validations/validateCpf.d.ts.map +0 -1
- package/dist/validations/validateDate.d.ts +0 -23
- package/dist/validations/validateDate.d.ts.map +0 -1
- package/dist/validations/validateEmail.d.ts +0 -21
- package/dist/validations/validateEmail.d.ts.map +0 -1
- package/dist/validations/validatePassword.d.ts +0 -20
- package/dist/validations/validatePassword.d.ts.map +0 -1
- package/dist/validations/validatePhone.d.ts +0 -16
- package/dist/validations/validatePhone.d.ts.map +0 -1
- package/dist/validations/validateRg.d.ts +0 -21
- package/dist/validations/validateRg.d.ts.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,1301 +0,0 @@
|
|
|
1
|
-
var k = Object.defineProperty;
|
|
2
|
-
var I = (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) => I(e, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
-
import { formatJsonString as U, formatJsonObject as q, removeNonNumeric as S, ValidateDateService as A } from "@arkyn/shared";
|
|
5
|
-
import H from "node:path";
|
|
6
|
-
import L from "node:dns";
|
|
7
|
-
import { countries as F } from "@arkyn/templates";
|
|
8
|
-
import { isValidPhoneNumber as z, parsePhoneNumberWithError as M } from "libphonenumber-js";
|
|
9
|
-
class N {
|
|
10
|
-
/**
|
|
11
|
-
* Adds a file name to the ignore list so it is skipped when resolving the caller in stack traces.
|
|
12
|
-
*
|
|
13
|
-
* @param file - File name to ignore (e.g. `"httpAdapter.ts"`).
|
|
14
|
-
*/
|
|
15
|
-
static setIgnoreFile(s) {
|
|
16
|
-
this.ignoreFiles.push(s);
|
|
17
|
-
}
|
|
18
|
-
/** Resets the ignore list, restoring full stack trace analysis. */
|
|
19
|
-
static clearIgnoreFiles() {
|
|
20
|
-
this.ignoreFiles = [];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Resolves the file path and function name of the code that triggered the current debug call,
|
|
24
|
-
* skipping internal node modules and any files registered with `setIgnoreFile`.
|
|
25
|
-
*
|
|
26
|
-
* @returns `{ functionName, callerInfo }` — caller function name and file path relative to `process.cwd()`.
|
|
27
|
-
*/
|
|
28
|
-
static getCaller() {
|
|
29
|
-
const s = process.cwd(), r = (new Error().stack || "").split(`
|
|
30
|
-
`).map((h) => h.trim());
|
|
31
|
-
let o = 2;
|
|
32
|
-
for (; o < r.length && (r[o].includes("node:internal") || r[o].includes("/node_modules/")); )
|
|
33
|
-
o++;
|
|
34
|
-
if (this.ignoreFiles.length > 0)
|
|
35
|
-
for (; o < r.length && this.ignoreFiles.some(
|
|
36
|
-
(h) => r[o].includes(h)
|
|
37
|
-
); )
|
|
38
|
-
o++;
|
|
39
|
-
const a = r[o] || "";
|
|
40
|
-
let u = "Unknown function", i = "Unknown caller";
|
|
41
|
-
const l = a.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
|
|
42
|
-
if (l)
|
|
43
|
-
u = l[1], i = l[2];
|
|
44
|
-
else {
|
|
45
|
-
const h = a.match(/at\s+(.+)/);
|
|
46
|
-
if (h) {
|
|
47
|
-
i = h[1];
|
|
48
|
-
const d = i.match(/at\s+([^(\s]+)\s+/);
|
|
49
|
-
d && d[1] !== "new" && (u = d[1]);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
i.includes("(") && (i = i.substring(
|
|
53
|
-
i.indexOf("(") + 1,
|
|
54
|
-
i.lastIndexOf(")")
|
|
55
|
-
)), i = i.split(":").slice(0, -2).join(":");
|
|
56
|
-
try {
|
|
57
|
-
i = H.relative(s, i);
|
|
58
|
-
} catch {
|
|
59
|
-
}
|
|
60
|
-
return { functionName: u, callerInfo: i };
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The name of the file to ignore when analyzing the stack trace.
|
|
65
|
-
* When set, the `getCaller` function will skip stack frames containing this file name.
|
|
66
|
-
*/
|
|
67
|
-
c(N, "ignoreFiles", []);
|
|
68
|
-
function g(e) {
|
|
69
|
-
var t;
|
|
70
|
-
if (process.env.NODE_ENV === "development" || ((t = process.env) == null ? void 0 : t.DEBUG_MODE) === "true") {
|
|
71
|
-
const o = `${{
|
|
72
|
-
yellow: "\x1B[33m",
|
|
73
|
-
cyan: "\x1B[36m",
|
|
74
|
-
red: "\x1B[31m",
|
|
75
|
-
green: "\x1B[32m"
|
|
76
|
-
}[e.scheme]}[${e.name}]\x1B[0m`;
|
|
77
|
-
let a = `
|
|
78
|
-
`;
|
|
79
|
-
e.debugs.forEach((u, i) => {
|
|
80
|
-
a += `${o} ${u.trim()}`, i < e.debugs.length - 1 && (a += `
|
|
81
|
-
`);
|
|
82
|
-
}), console.log(a);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
class f {
|
|
86
|
-
constructor() {
|
|
87
|
-
c(this, "_cause");
|
|
88
|
-
c(this, "_name", "BadResponse");
|
|
89
|
-
c(this, "_status", 500);
|
|
90
|
-
c(this, "_statusText", "Unknown error");
|
|
91
|
-
c(this, "_debugColor", "red");
|
|
92
|
-
}
|
|
93
|
-
get cause() {
|
|
94
|
-
return this._cause;
|
|
95
|
-
}
|
|
96
|
-
set cause(s) {
|
|
97
|
-
this._cause = s;
|
|
98
|
-
}
|
|
99
|
-
get name() {
|
|
100
|
-
return this._name;
|
|
101
|
-
}
|
|
102
|
-
set name(s) {
|
|
103
|
-
this._name = s;
|
|
104
|
-
}
|
|
105
|
-
get status() {
|
|
106
|
-
return this._status;
|
|
107
|
-
}
|
|
108
|
-
set status(s) {
|
|
109
|
-
this._status = s;
|
|
110
|
-
}
|
|
111
|
-
get statusText() {
|
|
112
|
-
return this._statusText;
|
|
113
|
-
}
|
|
114
|
-
set statusText(s) {
|
|
115
|
-
this._statusText = s;
|
|
116
|
-
}
|
|
117
|
-
get debugColor() {
|
|
118
|
-
return this._debugColor;
|
|
119
|
-
}
|
|
120
|
-
set debugColor(s) {
|
|
121
|
-
["green", "yellow", "cyan", "red"].includes(s) && (this._debugColor = s);
|
|
122
|
-
}
|
|
123
|
-
onDebug() {
|
|
124
|
-
const s = [], { callerInfo: t, functionName: n } = N.getCaller();
|
|
125
|
-
s.push(`Caller Function: ${n}`), s.push(`Caller Location: ${t}`), this._statusText && s.push(`Message: ${this._statusText}`), this._cause && s.push(`Cause: ${U(JSON.stringify(this._cause))}`), g({ scheme: "red", name: this._name, debugs: s });
|
|
126
|
-
}
|
|
127
|
-
makeBody() {
|
|
128
|
-
return {
|
|
129
|
-
name: this._name,
|
|
130
|
-
message: this._statusText,
|
|
131
|
-
cause: this._cause
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
class V extends f {
|
|
136
|
-
/**
|
|
137
|
-
* @param message - Error description sent in the response body and logged for debugging.
|
|
138
|
-
* @param cause - Optional extra context (serialized to JSON in the response).
|
|
139
|
-
*/
|
|
140
|
-
constructor(s, t) {
|
|
141
|
-
super(), this.name = "BadGateway", this.status = 502, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
142
|
-
}
|
|
143
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
144
|
-
toResponse() {
|
|
145
|
-
const s = {
|
|
146
|
-
headers: { "Content-Type": "application/json" },
|
|
147
|
-
status: this.status,
|
|
148
|
-
statusText: this.statusText
|
|
149
|
-
};
|
|
150
|
-
return new Response(JSON.stringify(this.makeBody()), s);
|
|
151
|
-
}
|
|
152
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
153
|
-
toJson() {
|
|
154
|
-
const s = {
|
|
155
|
-
status: this.status,
|
|
156
|
-
statusText: this.statusText
|
|
157
|
-
};
|
|
158
|
-
return Response.json(this.makeBody(), s);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
class T extends f {
|
|
162
|
-
/**
|
|
163
|
-
* @param message - Error description.
|
|
164
|
-
* @param cause - Optional extra context (serialized to JSON).
|
|
165
|
-
*/
|
|
166
|
-
constructor(s, t) {
|
|
167
|
-
super(), this.name = "BadRequest", this.status = 400, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
168
|
-
}
|
|
169
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
170
|
-
toResponse() {
|
|
171
|
-
const s = {
|
|
172
|
-
headers: { "Content-Type": "application/json" },
|
|
173
|
-
status: this.status,
|
|
174
|
-
statusText: this.statusText
|
|
175
|
-
};
|
|
176
|
-
return new Response(JSON.stringify(this.makeBody()), s);
|
|
177
|
-
}
|
|
178
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
179
|
-
toJson() {
|
|
180
|
-
const s = {
|
|
181
|
-
status: this.status,
|
|
182
|
-
statusText: this.statusText
|
|
183
|
-
};
|
|
184
|
-
return Response.json(this.makeBody(), s);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
class Z extends f {
|
|
188
|
-
/**
|
|
189
|
-
* @param message - Error description.
|
|
190
|
-
* @param cause - Optional extra context (serialized to JSON).
|
|
191
|
-
*/
|
|
192
|
-
constructor(s, t) {
|
|
193
|
-
super(), this.name = "Conflict", this.status = 409, this.statusText = s, this.debugColor = "yellow", this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
194
|
-
}
|
|
195
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
196
|
-
toResponse() {
|
|
197
|
-
const s = {
|
|
198
|
-
headers: { "Content-Type": "application/json" },
|
|
199
|
-
status: this.status,
|
|
200
|
-
statusText: this.statusText
|
|
201
|
-
};
|
|
202
|
-
return new Response(JSON.stringify(this.makeBody()), s);
|
|
203
|
-
}
|
|
204
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
205
|
-
toJson() {
|
|
206
|
-
const s = {
|
|
207
|
-
status: this.status,
|
|
208
|
-
statusText: this.statusText
|
|
209
|
-
};
|
|
210
|
-
return Response.json(this.makeBody(), s);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
class G extends f {
|
|
214
|
-
/**
|
|
215
|
-
* @param message - Error description.
|
|
216
|
-
* @param cause - Optional extra context (serialized to JSON).
|
|
217
|
-
*/
|
|
218
|
-
constructor(s, t) {
|
|
219
|
-
super(), this.name = "Forbidden", this.status = 403, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
220
|
-
}
|
|
221
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
222
|
-
toResponse() {
|
|
223
|
-
const s = {
|
|
224
|
-
headers: { "Content-Type": "application/json" },
|
|
225
|
-
status: this.status,
|
|
226
|
-
statusText: this.statusText
|
|
227
|
-
};
|
|
228
|
-
return new Response(JSON.stringify(this.makeBody()), s);
|
|
229
|
-
}
|
|
230
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
231
|
-
toJson() {
|
|
232
|
-
const s = {
|
|
233
|
-
status: this.status,
|
|
234
|
-
statusText: this.statusText
|
|
235
|
-
};
|
|
236
|
-
return Response.json(this.makeBody(), s);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
class W extends f {
|
|
240
|
-
/**
|
|
241
|
-
* @param message - Error description.
|
|
242
|
-
* @param cause - Optional extra context (serialized to JSON).
|
|
243
|
-
*/
|
|
244
|
-
constructor(s, t) {
|
|
245
|
-
super(), this.name = "NotFound", this.status = 404, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
246
|
-
}
|
|
247
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
248
|
-
toResponse() {
|
|
249
|
-
const s = {
|
|
250
|
-
headers: { "Content-Type": "application/json" },
|
|
251
|
-
status: this.status,
|
|
252
|
-
statusText: this.statusText
|
|
253
|
-
};
|
|
254
|
-
return new Response(JSON.stringify(this.makeBody()), s);
|
|
255
|
-
}
|
|
256
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
257
|
-
toJson() {
|
|
258
|
-
const s = {
|
|
259
|
-
status: this.status,
|
|
260
|
-
statusText: this.statusText
|
|
261
|
-
};
|
|
262
|
-
return Response.json(this.makeBody(), s);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
class Y extends f {
|
|
266
|
-
/**
|
|
267
|
-
* @param message - Error description.
|
|
268
|
-
* @param cause - Optional extra context (serialized to JSON).
|
|
269
|
-
*/
|
|
270
|
-
constructor(s, t) {
|
|
271
|
-
super(), this.name = "NotImplemented", this.status = 501, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
272
|
-
}
|
|
273
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
274
|
-
toResponse() {
|
|
275
|
-
const s = {
|
|
276
|
-
headers: { "Content-Type": "application/json" },
|
|
277
|
-
status: this.status,
|
|
278
|
-
statusText: this.statusText
|
|
279
|
-
};
|
|
280
|
-
return new Response(JSON.stringify(this.makeBody()), s);
|
|
281
|
-
}
|
|
282
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
283
|
-
toJson() {
|
|
284
|
-
const s = {
|
|
285
|
-
status: this.status,
|
|
286
|
-
statusText: this.statusText
|
|
287
|
-
};
|
|
288
|
-
return Response.json(this.makeBody(), s);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
class x extends f {
|
|
292
|
-
/**
|
|
293
|
-
* @param message - Error description.
|
|
294
|
-
* @param cause - Optional extra context (serialized to JSON).
|
|
295
|
-
*/
|
|
296
|
-
constructor(s, t) {
|
|
297
|
-
super(), this.name = "ServerError", this.status = 500, this.statusText = s, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
298
|
-
}
|
|
299
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
300
|
-
toResponse() {
|
|
301
|
-
const s = {
|
|
302
|
-
headers: { "Content-Type": "application/json" },
|
|
303
|
-
status: this.status,
|
|
304
|
-
statusText: this.statusText
|
|
305
|
-
};
|
|
306
|
-
return new Response(JSON.stringify(this.makeBody()), s);
|
|
307
|
-
}
|
|
308
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
309
|
-
toJson() {
|
|
310
|
-
const s = {
|
|
311
|
-
status: this.status,
|
|
312
|
-
statusText: this.statusText
|
|
313
|
-
};
|
|
314
|
-
return Response.json(this.makeBody(), s);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
class K extends f {
|
|
318
|
-
/**
|
|
319
|
-
* @param message - Error description.
|
|
320
|
-
* @param cause - Optional extra context (serialized to JSON).
|
|
321
|
-
*/
|
|
322
|
-
constructor(s, t) {
|
|
323
|
-
super(), this.name = "Unauthorized", this.status = 401, this.statusText = s, this.debugColor = "yellow", this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
324
|
-
}
|
|
325
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
326
|
-
toResponse() {
|
|
327
|
-
const s = {
|
|
328
|
-
headers: { "Content-Type": "application/json" },
|
|
329
|
-
status: this.status,
|
|
330
|
-
statusText: this.statusText
|
|
331
|
-
};
|
|
332
|
-
return new Response(JSON.stringify(this.makeBody()), s);
|
|
333
|
-
}
|
|
334
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
335
|
-
toJson() {
|
|
336
|
-
const s = {
|
|
337
|
-
status: this.status,
|
|
338
|
-
statusText: this.statusText
|
|
339
|
-
};
|
|
340
|
-
return Response.json(this.makeBody(), s);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
class R extends f {
|
|
344
|
-
/**
|
|
345
|
-
* @param props.message - Human-readable description of the error.
|
|
346
|
-
* @param props.fieldErrors - Per-field validation messages keyed by field name.
|
|
347
|
-
* @param props.fields - Original submitted field values (useful for repopulating forms).
|
|
348
|
-
* @param props.data - Any extra data to include in the response body.
|
|
349
|
-
*/
|
|
350
|
-
constructor(s) {
|
|
351
|
-
super(), this.name = "UnprocessableEntity", this.status = 422, this.statusText = s.message || "Unprocessable entity", this.debugColor = "yellow", this.cause = {
|
|
352
|
-
data: s.data,
|
|
353
|
-
fieldErrors: s.fieldErrors,
|
|
354
|
-
fields: s.fields
|
|
355
|
-
}, this.onDebug();
|
|
356
|
-
}
|
|
357
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
358
|
-
toResponse() {
|
|
359
|
-
const s = {
|
|
360
|
-
headers: { "Content-Type": "application/json" },
|
|
361
|
-
status: this.status,
|
|
362
|
-
statusText: this.statusText
|
|
363
|
-
};
|
|
364
|
-
return new Response(JSON.stringify(this.makeBody()), s);
|
|
365
|
-
}
|
|
366
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
367
|
-
toJson() {
|
|
368
|
-
const s = {
|
|
369
|
-
status: this.status,
|
|
370
|
-
statusText: this.statusText
|
|
371
|
-
};
|
|
372
|
-
return Response.json(this.makeBody(), s);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
class y {
|
|
376
|
-
constructor() {
|
|
377
|
-
c(this, "_body", null);
|
|
378
|
-
c(this, "_name", "SuccessResponse");
|
|
379
|
-
c(this, "_status", 200);
|
|
380
|
-
c(this, "_statusText", "OK");
|
|
381
|
-
c(this, "_debugColor", "green");
|
|
382
|
-
}
|
|
383
|
-
get body() {
|
|
384
|
-
return this._body;
|
|
385
|
-
}
|
|
386
|
-
set body(s) {
|
|
387
|
-
this._body = s ?? null;
|
|
388
|
-
}
|
|
389
|
-
get name() {
|
|
390
|
-
return this._name;
|
|
391
|
-
}
|
|
392
|
-
set name(s) {
|
|
393
|
-
this._name = s;
|
|
394
|
-
}
|
|
395
|
-
get status() {
|
|
396
|
-
return this._status;
|
|
397
|
-
}
|
|
398
|
-
set status(s) {
|
|
399
|
-
this._status = s;
|
|
400
|
-
}
|
|
401
|
-
get statusText() {
|
|
402
|
-
return this._statusText;
|
|
403
|
-
}
|
|
404
|
-
set statusText(s) {
|
|
405
|
-
this._statusText = s;
|
|
406
|
-
}
|
|
407
|
-
get debugColor() {
|
|
408
|
-
return this._debugColor;
|
|
409
|
-
}
|
|
410
|
-
set debugColor(s) {
|
|
411
|
-
["green", "yellow", "cyan", "red"].includes(s) && (this._debugColor = s);
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Logs debug information for success responses including caller context and response details.
|
|
415
|
-
*
|
|
416
|
-
* @param {any} body - The response body or success data to be logged
|
|
417
|
-
*
|
|
418
|
-
* @example
|
|
419
|
-
* ```typescript
|
|
420
|
-
* const SuccessResponse = new SuccessResponse();
|
|
421
|
-
* SuccessResponse.onDebug({ data: "Operation completed successfully" });
|
|
422
|
-
* ```
|
|
423
|
-
*/
|
|
424
|
-
onDebug(s) {
|
|
425
|
-
const t = [], { callerInfo: n, functionName: r } = N.getCaller();
|
|
426
|
-
t.push(`Caller Function: ${r}`), t.push(`Caller Location: ${n}`), this.statusText && t.push(`Message: ${this.statusText}`), s && t.push(`Body: ${JSON.stringify(s)}`), g({ scheme: this._debugColor, name: this.name, debugs: t });
|
|
427
|
-
}
|
|
428
|
-
makeBody() {
|
|
429
|
-
return {
|
|
430
|
-
name: this.name,
|
|
431
|
-
message: this.statusText,
|
|
432
|
-
body: this.body
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
class Q extends y {
|
|
437
|
-
/**
|
|
438
|
-
* @param message - Description included in the response status text.
|
|
439
|
-
* @param body - Data to include in the response body.
|
|
440
|
-
*/
|
|
441
|
-
constructor(s, t) {
|
|
442
|
-
super(), this.name = "Created", this.status = 201, this.statusText = s, this.body = t || void 0, this.onDebug();
|
|
443
|
-
}
|
|
444
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
445
|
-
toResponse() {
|
|
446
|
-
const s = {
|
|
447
|
-
headers: { "Content-Type": "application/json" },
|
|
448
|
-
status: this.status,
|
|
449
|
-
statusText: this.statusText
|
|
450
|
-
};
|
|
451
|
-
return new Response(JSON.stringify(this.body), s);
|
|
452
|
-
}
|
|
453
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
454
|
-
toJson() {
|
|
455
|
-
const s = {
|
|
456
|
-
status: this.status,
|
|
457
|
-
statusText: this.statusText
|
|
458
|
-
};
|
|
459
|
-
return Response.json(this.body, s);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
class X extends y {
|
|
463
|
-
/**
|
|
464
|
-
* @param message - Description included in the response status text.
|
|
465
|
-
* @param body - Data to include in the response body.
|
|
466
|
-
*/
|
|
467
|
-
constructor(s, t) {
|
|
468
|
-
super(), this.name = "Found", this.status = 302, this.statusText = s, this.body = t || void 0, this.onDebug();
|
|
469
|
-
}
|
|
470
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
471
|
-
toResponse() {
|
|
472
|
-
const s = {
|
|
473
|
-
headers: { "Content-Type": "application/json" },
|
|
474
|
-
status: this.status,
|
|
475
|
-
statusText: this.statusText
|
|
476
|
-
};
|
|
477
|
-
return new Response(JSON.stringify(this.body), s);
|
|
478
|
-
}
|
|
479
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
480
|
-
toJson() {
|
|
481
|
-
const s = {
|
|
482
|
-
status: this.status,
|
|
483
|
-
statusText: this.statusText
|
|
484
|
-
};
|
|
485
|
-
return Response.json(this.body, s);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
class ss extends y {
|
|
489
|
-
/**
|
|
490
|
-
* @param message - Description included in the response status text.
|
|
491
|
-
*/
|
|
492
|
-
constructor(s) {
|
|
493
|
-
super(), this.name = "NoContent", this.status = 204, this.statusText = s, this.onDebug();
|
|
494
|
-
}
|
|
495
|
-
/** Converts to a `Response` with `Content-Type: application/json` header and no body. */
|
|
496
|
-
toResponse() {
|
|
497
|
-
const s = {
|
|
498
|
-
headers: { "Content-Type": "application/json" },
|
|
499
|
-
status: this.status,
|
|
500
|
-
statusText: this.statusText
|
|
501
|
-
};
|
|
502
|
-
return new Response(null, s);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
class es extends y {
|
|
506
|
-
/**
|
|
507
|
-
* @param message - Description included in the response status text.
|
|
508
|
-
* @param body - Data to include in the response body.
|
|
509
|
-
*/
|
|
510
|
-
constructor(s, t) {
|
|
511
|
-
super(), this.name = "Success", this.status = 200, this.statusText = s, this.body = t || void 0, this.onDebug();
|
|
512
|
-
}
|
|
513
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
514
|
-
toResponse() {
|
|
515
|
-
const s = {
|
|
516
|
-
headers: { "Content-Type": "application/json" },
|
|
517
|
-
status: this.status,
|
|
518
|
-
statusText: this.statusText
|
|
519
|
-
};
|
|
520
|
-
return new Response(JSON.stringify(this.body), s);
|
|
521
|
-
}
|
|
522
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
523
|
-
toJson() {
|
|
524
|
-
const s = {
|
|
525
|
-
status: this.status,
|
|
526
|
-
statusText: this.statusText
|
|
527
|
-
};
|
|
528
|
-
return Response.json(this.body, s);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
class ts extends y {
|
|
532
|
-
/**
|
|
533
|
-
* @param message - Description included in the response status text.
|
|
534
|
-
* @param body - Data to include in the response body.
|
|
535
|
-
*/
|
|
536
|
-
constructor(s, t) {
|
|
537
|
-
super(), this.name = "Updated", this.status = 200, this.statusText = s, this.body = t || void 0, this.onDebug();
|
|
538
|
-
}
|
|
539
|
-
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
540
|
-
toResponse() {
|
|
541
|
-
const s = {
|
|
542
|
-
headers: { "Content-Type": "application/json" },
|
|
543
|
-
status: this.status,
|
|
544
|
-
statusText: this.statusText
|
|
545
|
-
};
|
|
546
|
-
return new Response(JSON.stringify(this.body), s);
|
|
547
|
-
}
|
|
548
|
-
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
549
|
-
toJson() {
|
|
550
|
-
const s = {
|
|
551
|
-
status: this.status,
|
|
552
|
-
statusText: this.statusText
|
|
553
|
-
};
|
|
554
|
-
return Response.json(this.body, s);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
class ns {
|
|
558
|
-
/**
|
|
559
|
-
* Converts various header formats into a plain key-value object.
|
|
560
|
-
*
|
|
561
|
-
* @param {HeadersInit} headers - The headers to map.
|
|
562
|
-
* @returns {Record<string, string>} A plain object with header key-value pairs.
|
|
563
|
-
* @private
|
|
564
|
-
*/
|
|
565
|
-
static mapHeaders(s) {
|
|
566
|
-
return s instanceof Headers ? Object.fromEntries(s.entries()) : typeof s == "object" ? Object.entries(s).reduce(
|
|
567
|
-
(t, [n, r]) => (typeof r == "string" ? t[n] = r : Array.isArray(r) ? t[n] = r.join(", ") : t[n] = JSON.stringify(r), t),
|
|
568
|
-
{}
|
|
569
|
-
) : {};
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* Converts URLSearchParams into a plain key-value object.
|
|
573
|
-
*
|
|
574
|
-
* @param {URLSearchParams} queryParams - The query parameters to map.
|
|
575
|
-
* @returns {Record<string, string>} A plain object with query parameter key-value pairs.
|
|
576
|
-
* @private
|
|
577
|
-
*/
|
|
578
|
-
static mapQueryParams(s) {
|
|
579
|
-
const t = {};
|
|
580
|
-
return s.forEach((n, r) => t[r] = n), t;
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Transforms raw HTTP request/response data into a standardized log output format.
|
|
584
|
-
*
|
|
585
|
-
* @param {InputProps} props - The input properties containing request/response data.
|
|
586
|
-
* @returns {OutputProps} The mapped output object ready for logging.
|
|
587
|
-
*/
|
|
588
|
-
static handle(s) {
|
|
589
|
-
return {
|
|
590
|
-
rawUrl: s.rawUrl,
|
|
591
|
-
status: s.status,
|
|
592
|
-
method: s.method,
|
|
593
|
-
token: null,
|
|
594
|
-
elapsedTime: s.elapsedTime,
|
|
595
|
-
requestHeaders: this.mapHeaders(s.requestHeaders),
|
|
596
|
-
requestBody: s.requestBody || null,
|
|
597
|
-
queryParams: {
|
|
598
|
-
...this.mapQueryParams(s.queryParams),
|
|
599
|
-
...s.urlParams
|
|
600
|
-
},
|
|
601
|
-
responseHeaders: this.mapHeaders(s.responseHeaders),
|
|
602
|
-
responseBody: s.responseBody || null
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
class v {
|
|
607
|
-
/**
|
|
608
|
-
* Sets the log service configuration once. Subsequent calls are ignored.
|
|
609
|
-
*
|
|
610
|
-
* @param config.trafficSourceId - Traffic source identifier.
|
|
611
|
-
* @param config.userToken - User token for authentication.
|
|
612
|
-
* @param config.logBaseApiUrl - Override the default log ingestion base URL.
|
|
613
|
-
*/
|
|
614
|
-
static setConfig(s) {
|
|
615
|
-
if (this.config) return;
|
|
616
|
-
const { trafficSourceId: t, userToken: n, logBaseApiUrl: r } = s, a = `${r || "http://62.238.8.44:8081"}/ingest-log`;
|
|
617
|
-
this.config = { trafficSourceId: t, userToken: n, apiUrl: a };
|
|
618
|
-
}
|
|
619
|
-
/** Returns the stored configuration, or `undefined` if `setConfig` has not been called. */
|
|
620
|
-
static getConfig() {
|
|
621
|
-
return this.config;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Resets the stored configuration, allowing a new initialization.
|
|
625
|
-
*/
|
|
626
|
-
static resetConfig() {
|
|
627
|
-
this.config = void 0;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
c(v, "config");
|
|
631
|
-
async function rs(e) {
|
|
632
|
-
const s = v.getConfig();
|
|
633
|
-
if (!s) return;
|
|
634
|
-
const { userToken: t, apiUrl: n, trafficSourceId: r } = s, {
|
|
635
|
-
elapsedTime: o,
|
|
636
|
-
method: a,
|
|
637
|
-
queryParams: u,
|
|
638
|
-
requestBody: i,
|
|
639
|
-
requestHeaders: l,
|
|
640
|
-
responseBody: h,
|
|
641
|
-
responseHeaders: d,
|
|
642
|
-
status: P,
|
|
643
|
-
token: vs,
|
|
644
|
-
rawUrl: $
|
|
645
|
-
} = e;
|
|
646
|
-
if (process.env.NODE_ENV !== "development")
|
|
647
|
-
try {
|
|
648
|
-
const m = new URL($);
|
|
649
|
-
let D = "https";
|
|
650
|
-
m.protocol === "http:" && (D = "http");
|
|
651
|
-
const w = JSON.stringify({
|
|
652
|
-
domainUrl: m.protocol + "//" + m.host,
|
|
653
|
-
pathnameUrl: m.pathname,
|
|
654
|
-
trafficSourceId: r,
|
|
655
|
-
status: P,
|
|
656
|
-
protocol: D,
|
|
657
|
-
method: a.toLowerCase(),
|
|
658
|
-
trafficUserId: null,
|
|
659
|
-
elapsedTime: o,
|
|
660
|
-
requestHeaders: JSON.stringify(l),
|
|
661
|
-
requestBody: JSON.stringify(i),
|
|
662
|
-
queryParams: JSON.stringify(u),
|
|
663
|
-
responseHeaders: JSON.stringify(d),
|
|
664
|
-
responseBody: JSON.stringify(h)
|
|
665
|
-
}), C = {
|
|
666
|
-
"Content-Type": "application/json",
|
|
667
|
-
Authorization: `Bearer ${t}`
|
|
668
|
-
}, p = await fetch(n, {
|
|
669
|
-
method: "POST",
|
|
670
|
-
body: w,
|
|
671
|
-
headers: C
|
|
672
|
-
});
|
|
673
|
-
if (!p.ok) {
|
|
674
|
-
const j = await p.text(), B = p.status, J = p.statusText, E = await p.json().catch(() => null);
|
|
675
|
-
g({
|
|
676
|
-
name: "LogError",
|
|
677
|
-
scheme: "red",
|
|
678
|
-
debugs: [
|
|
679
|
-
"Failed to log request.",
|
|
680
|
-
`Status: ${B} ${J}.`,
|
|
681
|
-
`Status text: ${j}.`,
|
|
682
|
-
`JSON Response: ${E ? q(E, 0) : "No JSON response"}`
|
|
683
|
-
]
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
} catch (m) {
|
|
687
|
-
g({
|
|
688
|
-
debugs: [`Error sending request: ${m}`],
|
|
689
|
-
name: "LogError",
|
|
690
|
-
scheme: "red"
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
async function b(e) {
|
|
695
|
-
let s = e.url;
|
|
696
|
-
e.urlParams && Object.entries(e.urlParams).forEach(([n, r]) => {
|
|
697
|
-
s = s.replaceAll(`:${n}`, r);
|
|
698
|
-
});
|
|
699
|
-
const t = {
|
|
700
|
-
POST: "Resource created successfully",
|
|
701
|
-
PUT: "Resource updated successfully",
|
|
702
|
-
DELETE: "Resource deleted successfully",
|
|
703
|
-
PATCH: "Resource patched successfully",
|
|
704
|
-
GET: "Request successful"
|
|
705
|
-
};
|
|
706
|
-
try {
|
|
707
|
-
const n = performance.now(), r = { ...e.headers, "Content-Type": "application/json" }, o = await fetch(s, {
|
|
708
|
-
headers: r,
|
|
709
|
-
method: e.method,
|
|
710
|
-
body: e.body ? JSON.stringify(e.body) : void 0
|
|
711
|
-
}), a = performance.now() - n, u = o.status;
|
|
712
|
-
let i = null;
|
|
713
|
-
try {
|
|
714
|
-
i = await o.json();
|
|
715
|
-
} catch {
|
|
716
|
-
i = null;
|
|
717
|
-
}
|
|
718
|
-
const l = ns.handle({
|
|
719
|
-
elapsedTime: a,
|
|
720
|
-
method: e.method,
|
|
721
|
-
queryParams: new URL(s).searchParams,
|
|
722
|
-
requestHeaders: r,
|
|
723
|
-
requestBody: e.body,
|
|
724
|
-
responseBody: i,
|
|
725
|
-
responseHeaders: o.headers,
|
|
726
|
-
status: u,
|
|
727
|
-
rawUrl: e.url,
|
|
728
|
-
urlParams: e.urlParams
|
|
729
|
-
});
|
|
730
|
-
return rs(l), o.ok ? {
|
|
731
|
-
success: !0,
|
|
732
|
-
status: u,
|
|
733
|
-
message: (i == null ? void 0 : i.message) || t[e.method],
|
|
734
|
-
response: i,
|
|
735
|
-
cause: null
|
|
736
|
-
} : {
|
|
737
|
-
success: !1,
|
|
738
|
-
status: u,
|
|
739
|
-
message: (i == null ? void 0 : i.message) || o.statusText || "Request failed",
|
|
740
|
-
response: i,
|
|
741
|
-
cause: null
|
|
742
|
-
};
|
|
743
|
-
} catch (n) {
|
|
744
|
-
return g({
|
|
745
|
-
debugs: [`Network error or request failed: ${n}`],
|
|
746
|
-
name: "MakeRequestError",
|
|
747
|
-
scheme: "red"
|
|
748
|
-
}), {
|
|
749
|
-
success: !1,
|
|
750
|
-
status: 0,
|
|
751
|
-
message: "Network error or request failed",
|
|
752
|
-
response: null,
|
|
753
|
-
cause: n instanceof Error ? n.message : String(n)
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
async function os(e) {
|
|
758
|
-
return b({
|
|
759
|
-
method: "DELETE",
|
|
760
|
-
url: e.url,
|
|
761
|
-
urlParams: e.urlParams,
|
|
762
|
-
headers: e.headers,
|
|
763
|
-
body: e.body
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
async function is(e) {
|
|
767
|
-
return b({
|
|
768
|
-
method: "GET",
|
|
769
|
-
url: e.url,
|
|
770
|
-
urlParams: e.urlParams,
|
|
771
|
-
headers: e.headers
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
async function as(e) {
|
|
775
|
-
return b({
|
|
776
|
-
method: "PATCH",
|
|
777
|
-
url: e.url,
|
|
778
|
-
urlParams: e.urlParams,
|
|
779
|
-
headers: e.headers,
|
|
780
|
-
body: e.body
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
async function us(e) {
|
|
784
|
-
return b({
|
|
785
|
-
method: "POST",
|
|
786
|
-
url: e.url,
|
|
787
|
-
urlParams: e.urlParams,
|
|
788
|
-
headers: e.headers,
|
|
789
|
-
body: e.body
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
async function cs(e) {
|
|
793
|
-
return b({
|
|
794
|
-
method: "PUT",
|
|
795
|
-
url: e.url,
|
|
796
|
-
urlParams: e.urlParams,
|
|
797
|
-
headers: e.headers,
|
|
798
|
-
body: e.body
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
class Js {
|
|
802
|
-
constructor(s) {
|
|
803
|
-
c(this, "baseUrl");
|
|
804
|
-
c(this, "baseHeaders");
|
|
805
|
-
c(this, "baseToken");
|
|
806
|
-
c(this, "enableDebug");
|
|
807
|
-
this.baseUrl = s.baseUrl, this.baseHeaders = s.baseHeaders || void 0, this.baseToken = s.baseToken || void 0, this.enableDebug = s.enableDebug || !1;
|
|
808
|
-
}
|
|
809
|
-
onDebug(s, t, n) {
|
|
810
|
-
if (this.enableDebug) {
|
|
811
|
-
const r = [], o = (a) => JSON.stringify(a, null, 2);
|
|
812
|
-
r.push(`Base URL: ${this.baseUrl}`), r.push(`Endpoint: ${s}`), r.push(`Status/Method: ${t} => ${n.status}`), r.push(`Message: ${n.message}`), n.headers && r.push(`Headers: ${o(n.headers)}`), n.body && r.push(`Body: ${o(n.body)}`), g({ debugs: r, name: "ApiDebug", scheme: "yellow" });
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
generateHeaders(s, t) {
|
|
816
|
-
let n = {};
|
|
817
|
-
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;
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* Sends a get request to the specified endpoint.
|
|
821
|
-
* @param endpoint - The API endpoint to send the get request to.
|
|
822
|
-
* @param data - The request data, including optional headers and token.
|
|
823
|
-
* @returns The API response data.
|
|
824
|
-
*/
|
|
825
|
-
async get(s, t) {
|
|
826
|
-
const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token), r = await is({
|
|
827
|
-
url: this.baseUrl + s,
|
|
828
|
-
urlParams: (t == null ? void 0 : t.urlParams) || {},
|
|
829
|
-
headers: n
|
|
830
|
-
});
|
|
831
|
-
return this.onDebug(s, "get", {
|
|
832
|
-
headers: n,
|
|
833
|
-
message: r.message,
|
|
834
|
-
status: r.status
|
|
835
|
-
}), r;
|
|
836
|
-
}
|
|
837
|
-
/**
|
|
838
|
-
* Sends a post request to the specified endpoint.
|
|
839
|
-
* @param endpoint - The API endpoint to send the post request to.
|
|
840
|
-
* @param data - The request data, including body, optional headers, and token.
|
|
841
|
-
* @returns The API response data.
|
|
842
|
-
*/
|
|
843
|
-
async post(s, t) {
|
|
844
|
-
const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token), r = t == null ? void 0 : t.body, o = await us({
|
|
845
|
-
url: this.baseUrl + s,
|
|
846
|
-
urlParams: (t == null ? void 0 : t.urlParams) || {},
|
|
847
|
-
headers: n,
|
|
848
|
-
body: r
|
|
849
|
-
});
|
|
850
|
-
return this.onDebug(s, "post", {
|
|
851
|
-
headers: n,
|
|
852
|
-
body: r,
|
|
853
|
-
message: o.message,
|
|
854
|
-
status: o.status
|
|
855
|
-
}), o;
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* Sends a put request to the specified endpoint.
|
|
859
|
-
* @param endpoint - The API endpoint to send the put request to.
|
|
860
|
-
* @param data - The request data, including body, optional headers, and token.
|
|
861
|
-
* @returns The API response data.
|
|
862
|
-
*/
|
|
863
|
-
async put(s, t) {
|
|
864
|
-
const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token), r = t == null ? void 0 : t.body, o = await cs({
|
|
865
|
-
url: this.baseUrl + s,
|
|
866
|
-
urlParams: (t == null ? void 0 : t.urlParams) || {},
|
|
867
|
-
headers: n,
|
|
868
|
-
body: r
|
|
869
|
-
});
|
|
870
|
-
return this.onDebug(s, "put", {
|
|
871
|
-
headers: n,
|
|
872
|
-
body: r,
|
|
873
|
-
message: o.message,
|
|
874
|
-
status: o.status
|
|
875
|
-
}), o;
|
|
876
|
-
}
|
|
877
|
-
/**
|
|
878
|
-
* Sends a patch request to the specified endpoint.
|
|
879
|
-
* @param endpoint - The API endpoint to send the patch request to.
|
|
880
|
-
* @param data - The request data, including body, optional headers, and token.
|
|
881
|
-
* @returns The API response data.
|
|
882
|
-
*/
|
|
883
|
-
async patch(s, t) {
|
|
884
|
-
const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token), r = t == null ? void 0 : t.body, o = await as({
|
|
885
|
-
url: this.baseUrl + s,
|
|
886
|
-
urlParams: (t == null ? void 0 : t.urlParams) || {},
|
|
887
|
-
headers: n,
|
|
888
|
-
body: r
|
|
889
|
-
});
|
|
890
|
-
return this.onDebug(s, "patch", {
|
|
891
|
-
headers: n,
|
|
892
|
-
body: r,
|
|
893
|
-
message: o.message,
|
|
894
|
-
status: o.status
|
|
895
|
-
}), o;
|
|
896
|
-
}
|
|
897
|
-
/**
|
|
898
|
-
* Sends a delete request to the specified endpoint.
|
|
899
|
-
* @param endpoint - The API endpoint to send the delete request to.
|
|
900
|
-
* @param data - The request data, including body, optional headers, and token.
|
|
901
|
-
* @returns The API response data.
|
|
902
|
-
*/
|
|
903
|
-
async delete(s, t) {
|
|
904
|
-
const n = this.generateHeaders((t == null ? void 0 : t.headers) || {}, t == null ? void 0 : t.token), r = t == null ? void 0 : t.body, o = await os({
|
|
905
|
-
url: this.baseUrl + s,
|
|
906
|
-
urlParams: (t == null ? void 0 : t.urlParams) || {},
|
|
907
|
-
headers: n,
|
|
908
|
-
body: r
|
|
909
|
-
});
|
|
910
|
-
return this.onDebug(s, "delete", {
|
|
911
|
-
headers: n,
|
|
912
|
-
body: r,
|
|
913
|
-
message: o.message,
|
|
914
|
-
status: o.status
|
|
915
|
-
}), o;
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
async function ks(e) {
|
|
919
|
-
let s;
|
|
920
|
-
const t = await e.arrayBuffer(), n = new TextDecoder().decode(t);
|
|
921
|
-
try {
|
|
922
|
-
s = JSON.parse(n);
|
|
923
|
-
} catch {
|
|
924
|
-
try {
|
|
925
|
-
if (n.includes("=")) {
|
|
926
|
-
const o = new URLSearchParams(n);
|
|
927
|
-
s = Object.fromEntries(o.entries());
|
|
928
|
-
} else
|
|
929
|
-
throw new T("Invalid URLSearchParams format");
|
|
930
|
-
} catch {
|
|
931
|
-
throw new T("Failed to extract data from request");
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
return s;
|
|
935
|
-
}
|
|
936
|
-
function Is(e, s) {
|
|
937
|
-
var t, n, r;
|
|
938
|
-
return e != null && e.message && typeof (e == null ? void 0 : e.message) == "string" ? e == null ? void 0 : e.message : e != null && e.operator_erro_message && typeof (e == null ? void 0 : e.operator_erro_message) == "string" ? e == null ? void 0 : e.operator_erro_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";
|
|
939
|
-
}
|
|
940
|
-
function Us(e) {
|
|
941
|
-
switch (!0) {
|
|
942
|
-
case e instanceof Response:
|
|
943
|
-
return e;
|
|
944
|
-
case e instanceof X:
|
|
945
|
-
return e.toResponse();
|
|
946
|
-
case e instanceof Q:
|
|
947
|
-
return e.toResponse();
|
|
948
|
-
case e instanceof ts:
|
|
949
|
-
return e.toResponse();
|
|
950
|
-
case e instanceof es:
|
|
951
|
-
return e.toResponse();
|
|
952
|
-
case e instanceof ss:
|
|
953
|
-
return e.toResponse();
|
|
954
|
-
}
|
|
955
|
-
switch (!0) {
|
|
956
|
-
case e instanceof V:
|
|
957
|
-
return e.toResponse();
|
|
958
|
-
case e instanceof T:
|
|
959
|
-
return e.toResponse();
|
|
960
|
-
case e instanceof Z:
|
|
961
|
-
return e.toResponse();
|
|
962
|
-
case e instanceof G:
|
|
963
|
-
return e.toResponse();
|
|
964
|
-
case e instanceof W:
|
|
965
|
-
return e.toResponse();
|
|
966
|
-
case e instanceof Y:
|
|
967
|
-
return e.toResponse();
|
|
968
|
-
case e instanceof x:
|
|
969
|
-
return e.toResponse();
|
|
970
|
-
case e instanceof K:
|
|
971
|
-
return e.toResponse();
|
|
972
|
-
case e instanceof R:
|
|
973
|
-
return e.toResponse();
|
|
974
|
-
}
|
|
975
|
-
return new x("Server error", e).toResponse();
|
|
976
|
-
}
|
|
977
|
-
async function ls([
|
|
978
|
-
e,
|
|
979
|
-
s
|
|
980
|
-
]) {
|
|
981
|
-
const t = await s.safeParseAsync(e);
|
|
982
|
-
return t.success === !1 ? {
|
|
983
|
-
success: !1,
|
|
984
|
-
fieldErrors: Object.fromEntries(
|
|
985
|
-
t.error.issues.map((r) => [r.path.join("."), r.message])
|
|
986
|
-
),
|
|
987
|
-
fields: e
|
|
988
|
-
} : {
|
|
989
|
-
success: !0,
|
|
990
|
-
data: t.data
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
function hs([
|
|
994
|
-
e,
|
|
995
|
-
s
|
|
996
|
-
]) {
|
|
997
|
-
const t = s.safeParse(e);
|
|
998
|
-
return t.success === !1 ? {
|
|
999
|
-
success: !1,
|
|
1000
|
-
fieldErrors: Object.fromEntries(
|
|
1001
|
-
t.error.issues.map((r) => [r.path.join("."), r.message])
|
|
1002
|
-
),
|
|
1003
|
-
fields: e
|
|
1004
|
-
} : {
|
|
1005
|
-
success: !0,
|
|
1006
|
-
data: t.data
|
|
1007
|
-
};
|
|
1008
|
-
}
|
|
1009
|
-
function qs(e, s = "") {
|
|
1010
|
-
const t = new URL(e.url);
|
|
1011
|
-
if (s === "") return t.searchParams;
|
|
1012
|
-
const n = Array.from(
|
|
1013
|
-
t.searchParams.entries()
|
|
1014
|
-
).filter(([r]) => r.startsWith(`${s}:`)).map(([r, o]) => [r.replace(`${s}:`, ""), o]);
|
|
1015
|
-
return new URLSearchParams(n);
|
|
1016
|
-
}
|
|
1017
|
-
function fs(e) {
|
|
1018
|
-
const s = "Error validating:", t = e.issues.map(
|
|
1019
|
-
({ path: n, message: r }) => `-> ${n.join(".")}: ${r}`
|
|
1020
|
-
);
|
|
1021
|
-
return [s, ...t].join(`
|
|
1022
|
-
`);
|
|
1023
|
-
}
|
|
1024
|
-
class As {
|
|
1025
|
-
/**
|
|
1026
|
-
* @param schema - The Zod schema used for all validation methods on this instance.
|
|
1027
|
-
*/
|
|
1028
|
-
constructor(s) {
|
|
1029
|
-
this.schema = s;
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* Returns `true` if the data satisfies the schema, `false` otherwise. Never throws.
|
|
1033
|
-
*
|
|
1034
|
-
* @param data - The value to check.
|
|
1035
|
-
*/
|
|
1036
|
-
isValid(s) {
|
|
1037
|
-
return this.schema.safeParse(s).success;
|
|
1038
|
-
}
|
|
1039
|
-
/**
|
|
1040
|
-
* Validates data and returns the raw Zod `safeParseResult` without throwing.
|
|
1041
|
-
* Useful when you need access to the full error details.
|
|
1042
|
-
*
|
|
1043
|
-
* @param data - The value to validate.
|
|
1044
|
-
*/
|
|
1045
|
-
safeValidate(s) {
|
|
1046
|
-
return this.schema.safeParse(s);
|
|
1047
|
-
}
|
|
1048
|
-
/**
|
|
1049
|
-
* Validates data and returns the typed result, throwing `ServerError` on failure.
|
|
1050
|
-
* Use for validating internal/trusted data (e.g. env vars, config objects).
|
|
1051
|
-
*
|
|
1052
|
-
* @param data - The value to validate.
|
|
1053
|
-
* @throws `ServerError` with a formatted field-by-field error message.
|
|
1054
|
-
*/
|
|
1055
|
-
validate(s) {
|
|
1056
|
-
try {
|
|
1057
|
-
return this.schema.parse(s);
|
|
1058
|
-
} catch (t) {
|
|
1059
|
-
throw new x(fs(t));
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
/**
|
|
1063
|
-
* Validates form data and returns the typed result, throwing `UnprocessableEntity` on failure.
|
|
1064
|
-
* The error includes `fieldErrors`, `fields`, and `data.scrollTo` (first failing field name).
|
|
1065
|
-
*
|
|
1066
|
-
* @param data - The raw form data to validate.
|
|
1067
|
-
* @param message - Optional human-readable error message for the 422 response.
|
|
1068
|
-
* @throws `UnprocessableEntity` with structured field errors for client-side form handling.
|
|
1069
|
-
*
|
|
1070
|
-
* @example
|
|
1071
|
-
* ```typescript
|
|
1072
|
-
* const validator = new SchemaValidator(registerSchema);
|
|
1073
|
-
* const body = validator.formValidate(await decodeRequestBody(request));
|
|
1074
|
-
* ```
|
|
1075
|
-
*/
|
|
1076
|
-
formValidate(s, t) {
|
|
1077
|
-
const n = hs([s, this.schema]);
|
|
1078
|
-
if ("fieldErrors" in n) {
|
|
1079
|
-
const r = Object.keys(n.fieldErrors)[0];
|
|
1080
|
-
throw new R({
|
|
1081
|
-
fields: n.fields,
|
|
1082
|
-
fieldErrors: n.fieldErrors,
|
|
1083
|
-
data: { scrollTo: r },
|
|
1084
|
-
message: t
|
|
1085
|
-
});
|
|
1086
|
-
}
|
|
1087
|
-
return n.data;
|
|
1088
|
-
}
|
|
1089
|
-
/**
|
|
1090
|
-
* Async version of `formValidate` for schemas with async refinements (e.g. uniqueness checks).
|
|
1091
|
-
*
|
|
1092
|
-
* @param data - The raw form data to validate.
|
|
1093
|
-
* @param message - Optional human-readable error message for the 422 response.
|
|
1094
|
-
* @throws `UnprocessableEntity` with structured field errors for client-side form handling.
|
|
1095
|
-
*
|
|
1096
|
-
* @example
|
|
1097
|
-
* ```typescript
|
|
1098
|
-
* const validator = new SchemaValidator(registerSchema);
|
|
1099
|
-
* const body = await validator.formAsyncValidate(await decodeRequestBody(request));
|
|
1100
|
-
* ```
|
|
1101
|
-
*/
|
|
1102
|
-
async formAsyncValidate(s, t) {
|
|
1103
|
-
const n = await ls([s, this.schema]);
|
|
1104
|
-
if ("fieldErrors" in n) {
|
|
1105
|
-
const r = Object.keys(n.fieldErrors)[0];
|
|
1106
|
-
throw new R({
|
|
1107
|
-
fields: n.fields,
|
|
1108
|
-
fieldErrors: n.fieldErrors,
|
|
1109
|
-
data: { scrollTo: r },
|
|
1110
|
-
message: t
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
return n.data;
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
function Hs(e) {
|
|
1117
|
-
if (!(/^\d{5}-\d{3}$/.test(e) || /^\d{8}$/.test(e))) return !1;
|
|
1118
|
-
const t = S(e), n = 8, r = /^\d{8}$/.test(t);
|
|
1119
|
-
return t.length === n && r;
|
|
1120
|
-
}
|
|
1121
|
-
function ms(e) {
|
|
1122
|
-
return e.length !== 14;
|
|
1123
|
-
}
|
|
1124
|
-
function gs(e) {
|
|
1125
|
-
const [s] = e;
|
|
1126
|
-
return [...e].every((t) => t === s);
|
|
1127
|
-
}
|
|
1128
|
-
function O(e, s) {
|
|
1129
|
-
let t = 0;
|
|
1130
|
-
for (let r = 0; r < s.length; r++)
|
|
1131
|
-
t += parseInt(e[r]) * s[r];
|
|
1132
|
-
const n = t % 11;
|
|
1133
|
-
return n < 2 ? 0 : 11 - n;
|
|
1134
|
-
}
|
|
1135
|
-
function ds(e) {
|
|
1136
|
-
return e.slice(12);
|
|
1137
|
-
}
|
|
1138
|
-
function Ls(e) {
|
|
1139
|
-
if (!e || e.length > 18 || e.length < 14 || /\s/.test(e)) return !1;
|
|
1140
|
-
const t = S(e);
|
|
1141
|
-
if (ms(t) || gs(t)) return !1;
|
|
1142
|
-
const n = t.slice(0, 12), r = O(n, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), o = O(
|
|
1143
|
-
n + r,
|
|
1144
|
-
[6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
1145
|
-
);
|
|
1146
|
-
return ds(t) === `${r}${o}`;
|
|
1147
|
-
}
|
|
1148
|
-
function ps(e) {
|
|
1149
|
-
return e.length !== 11;
|
|
1150
|
-
}
|
|
1151
|
-
function ys(e) {
|
|
1152
|
-
const [s] = e;
|
|
1153
|
-
return [...e].every((t) => t === s);
|
|
1154
|
-
}
|
|
1155
|
-
function _(e, s) {
|
|
1156
|
-
let t = 0;
|
|
1157
|
-
for (const r of e)
|
|
1158
|
-
s > 1 && (t += parseInt(r) * s--);
|
|
1159
|
-
const n = t % 11;
|
|
1160
|
-
return n < 2 ? 0 : 11 - n;
|
|
1161
|
-
}
|
|
1162
|
-
function bs(e) {
|
|
1163
|
-
return e.slice(9);
|
|
1164
|
-
}
|
|
1165
|
-
function Fs(e) {
|
|
1166
|
-
if (!e || e.length > 14 || e.length < 11 || /\s/.test(e)) return !1;
|
|
1167
|
-
const t = S(e);
|
|
1168
|
-
if (ps(t) || ys(t)) return !1;
|
|
1169
|
-
const n = _(t, 10), r = _(t, 11);
|
|
1170
|
-
return bs(t) === `${n}${r}`;
|
|
1171
|
-
}
|
|
1172
|
-
function zs(e, s) {
|
|
1173
|
-
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, o = new A();
|
|
1174
|
-
o.validateInputFormat(t);
|
|
1175
|
-
let a, u, i;
|
|
1176
|
-
const l = e.split(/[-/]/).map(Number);
|
|
1177
|
-
if (l.length !== 3) return !1;
|
|
1178
|
-
try {
|
|
1179
|
-
switch (t) {
|
|
1180
|
-
case "brazilianDate":
|
|
1181
|
-
[a, u, i] = l, o.validateDateParts(i, u, a);
|
|
1182
|
-
break;
|
|
1183
|
-
case "isoDate":
|
|
1184
|
-
[u, a, i] = l, o.validateDateParts(i, u, a);
|
|
1185
|
-
break;
|
|
1186
|
-
case "timestamp":
|
|
1187
|
-
[i, u, a] = l, o.validateDateParts(i, u, a);
|
|
1188
|
-
break;
|
|
1189
|
-
}
|
|
1190
|
-
return !(i < n || i > r);
|
|
1191
|
-
} catch {
|
|
1192
|
-
return !1;
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
function Ts(e) {
|
|
1196
|
-
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);
|
|
1197
|
-
}
|
|
1198
|
-
function xs(e) {
|
|
1199
|
-
return !(e.length === 0 || e.length > 64 || e.startsWith(".") || e.endsWith(".") || e.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e));
|
|
1200
|
-
}
|
|
1201
|
-
function Rs(e) {
|
|
1202
|
-
return !(e.length === 0 || e.length > 63 || e.startsWith("-") || e.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(e));
|
|
1203
|
-
}
|
|
1204
|
-
function Ss(e) {
|
|
1205
|
-
if (e.length === 0 || e.length > 253 || e.startsWith(".") || e.endsWith(".") || e.startsWith("-") || e.endsWith("-"))
|
|
1206
|
-
return !1;
|
|
1207
|
-
const s = e.split(".");
|
|
1208
|
-
if (s.length < 2) return !1;
|
|
1209
|
-
for (const n of s) if (!Rs(n)) return !1;
|
|
1210
|
-
const t = s[s.length - 1];
|
|
1211
|
-
return !(t.length < 2 || !/^[a-zA-Z]+$/.test(t));
|
|
1212
|
-
}
|
|
1213
|
-
function Ns(e) {
|
|
1214
|
-
const s = e.split("@");
|
|
1215
|
-
if (s.length !== 2) return !1;
|
|
1216
|
-
const [t, n] = s;
|
|
1217
|
-
return !(!xs(t) || !Ss(n));
|
|
1218
|
-
}
|
|
1219
|
-
function Ds(e) {
|
|
1220
|
-
const s = e.split("@");
|
|
1221
|
-
return s.length === 2 ? s[1].toLowerCase() : null;
|
|
1222
|
-
}
|
|
1223
|
-
const Es = ["MX", "A", "AAAA"];
|
|
1224
|
-
async function Os(e, s) {
|
|
1225
|
-
var t, n;
|
|
1226
|
-
try {
|
|
1227
|
-
return await ((n = (t = L) == null ? void 0 : t.promises) == null ? void 0 : n.resolve(e, s)), !0;
|
|
1228
|
-
} catch {
|
|
1229
|
-
return !1;
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
async function _s(e) {
|
|
1233
|
-
for (const s of Es)
|
|
1234
|
-
if (await Os(e, s)) return !0;
|
|
1235
|
-
return !1;
|
|
1236
|
-
}
|
|
1237
|
-
async function Ms(e) {
|
|
1238
|
-
if (!e || typeof e != "string") return !1;
|
|
1239
|
-
const s = e.trim();
|
|
1240
|
-
if (!Ts(s) || !Ns(s)) return !1;
|
|
1241
|
-
const t = Ds(s);
|
|
1242
|
-
return t ? await _s(t) : !1;
|
|
1243
|
-
}
|
|
1244
|
-
function Vs(e) {
|
|
1245
|
-
if (!e) return !1;
|
|
1246
|
-
const s = e.length >= 8, t = /[A-Z]/.test(e), n = /[a-z]/.test(e), r = /\d/.test(e), o = /[!@#$%^&*(),.?":;{}|<>_\-+=~`[\]\\\/]/.test(
|
|
1247
|
-
e
|
|
1248
|
-
);
|
|
1249
|
-
return [
|
|
1250
|
-
s,
|
|
1251
|
-
t,
|
|
1252
|
-
n,
|
|
1253
|
-
r,
|
|
1254
|
-
o
|
|
1255
|
-
].every((a) => a);
|
|
1256
|
-
}
|
|
1257
|
-
function Zs(e) {
|
|
1258
|
-
if (!z(e)) return !1;
|
|
1259
|
-
const s = M(e), t = s == null ? void 0 : s.country;
|
|
1260
|
-
return !(!t || !F.find((r) => r.iso === t));
|
|
1261
|
-
}
|
|
1262
|
-
function Gs(e) {
|
|
1263
|
-
if (!e || !/^[0-9a-zA-Z.-]+$/.test(e)) return !1;
|
|
1264
|
-
const t = e.replace(/[^a-zA-Z0-9]/g, "");
|
|
1265
|
-
return t.length < 7 || t.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(t);
|
|
1266
|
-
}
|
|
1267
|
-
export {
|
|
1268
|
-
Js as ApiService,
|
|
1269
|
-
V as BadGateway,
|
|
1270
|
-
T as BadRequest,
|
|
1271
|
-
Z as Conflict,
|
|
1272
|
-
Q as Created,
|
|
1273
|
-
N as DebugService,
|
|
1274
|
-
G as Forbidden,
|
|
1275
|
-
X as Found,
|
|
1276
|
-
v as LogService,
|
|
1277
|
-
ss as NoContent,
|
|
1278
|
-
W as NotFound,
|
|
1279
|
-
Y as NotImplemented,
|
|
1280
|
-
As as SchemaValidator,
|
|
1281
|
-
x as ServerError,
|
|
1282
|
-
es as Success,
|
|
1283
|
-
K as Unauthorized,
|
|
1284
|
-
R as UnprocessableEntity,
|
|
1285
|
-
ts as Updated,
|
|
1286
|
-
ks as decodeRequestBody,
|
|
1287
|
-
Is as decodeRequestErrorMessage,
|
|
1288
|
-
Us as errorHandler,
|
|
1289
|
-
g as flushDebugLogs,
|
|
1290
|
-
ls as formAsyncParse,
|
|
1291
|
-
hs as formParse,
|
|
1292
|
-
qs as getScopedParams,
|
|
1293
|
-
Hs as validateCep,
|
|
1294
|
-
Ls as validateCnpj,
|
|
1295
|
-
Fs as validateCpf,
|
|
1296
|
-
zs as validateDate,
|
|
1297
|
-
Ms as validateEmail,
|
|
1298
|
-
Vs as validatePassword,
|
|
1299
|
-
Zs as validatePhone,
|
|
1300
|
-
Gs as validateRg
|
|
1301
|
-
};
|