@arkyn/server 3.0.1-beta.72 → 3.0.1-beta.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +407 -240
- package/dist/bundle.umd.cjs +9 -9
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/validations/validateCep.d.ts +24 -0
- package/dist/validations/validateCep.d.ts.map +1 -0
- package/dist/validations/validateCep.js +33 -0
- package/dist/validations/validateCnpj.d.ts +22 -0
- package/dist/validations/validateCnpj.d.ts.map +1 -0
- package/dist/validations/validateCnpj.js +52 -0
- package/dist/validations/validateCpf.d.ts +24 -0
- package/dist/validations/validateCpf.d.ts.map +1 -0
- package/dist/validations/validateCpf.js +54 -0
- package/dist/validations/validateDate.d.ts +34 -0
- package/dist/validations/validateDate.d.ts.map +1 -0
- package/dist/validations/validateDate.js +73 -0
- package/dist/validations/validateEmail.d.ts +22 -0
- package/dist/validations/validateEmail.d.ts.map +1 -0
- package/dist/validations/validateEmail.js +121 -0
- package/dist/validations/validatePassword.d.ts +21 -0
- package/dist/validations/validatePassword.d.ts.map +1 -0
- package/dist/validations/validatePassword.js +34 -0
- package/dist/validations/validatePhone.d.ts +29 -0
- package/dist/validations/validatePhone.d.ts.map +1 -0
- package/dist/validations/validatePhone.js +44 -0
- package/dist/validations/validateRg.d.ts +22 -0
- package/dist/validations/validateRg.d.ts.map +1 -0
- package/dist/validations/validateRg.js +31 -0
- package/package.json +4 -3
package/dist/bundle.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (
|
|
4
|
-
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var k = (e, t, s) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var o = (e, t, s) => k(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
import "zod";
|
|
5
|
+
import { removeNonNumeric as R } from "@arkyn/shared";
|
|
6
|
+
import { countries as w } from "@arkyn/templates";
|
|
7
|
+
function g(e) {
|
|
5
8
|
var s;
|
|
6
9
|
if (process.env.NODE_ENV === "development" || ((s = process.env) == null ? void 0 : s.SHOW_ERRORS_IN_CONSOLE) === "true") {
|
|
7
|
-
const
|
|
10
|
+
const a = `${{
|
|
8
11
|
yellow: "\x1B[33m",
|
|
9
12
|
cyan: "\x1B[36m",
|
|
10
13
|
red: "\x1B[31m",
|
|
11
14
|
green: "\x1B[32m"
|
|
12
|
-
}[
|
|
15
|
+
}[e.scheme]}[${e.name}]\x1B[0m`;
|
|
13
16
|
let c = `
|
|
14
17
|
`;
|
|
15
|
-
|
|
16
|
-
c += `${
|
|
18
|
+
e.debugs.forEach((h) => {
|
|
19
|
+
c += `${a} ${h.trim()}
|
|
17
20
|
`;
|
|
18
21
|
}), console.log(c);
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
const
|
|
22
|
-
class
|
|
24
|
+
const $ = {};
|
|
25
|
+
class I {
|
|
23
26
|
/**
|
|
24
27
|
* Sets the file name to be ignored during stack trace analysis.
|
|
25
28
|
*
|
|
@@ -58,27 +61,27 @@ class S {
|
|
|
58
61
|
* The name of the file to ignore when analyzing the stack trace.
|
|
59
62
|
* When set, the `getCaller` function will skip stack frames containing this file name.
|
|
60
63
|
*/
|
|
61
|
-
o(
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
`).map((
|
|
65
|
-
let
|
|
66
|
-
for (;
|
|
67
|
-
|
|
64
|
+
o(I, "ignoreFiles", []);
|
|
65
|
+
function N() {
|
|
66
|
+
const e = process.cwd(), n = (new Error().stack || "").split(`
|
|
67
|
+
`).map((u) => u.trim()), r = I.ignoreFiles;
|
|
68
|
+
let a = 2;
|
|
69
|
+
for (; a < n.length && (n[a].includes("node:internal") || n[a].includes("/node_modules/")); )
|
|
70
|
+
a++;
|
|
68
71
|
if (r.length > 0)
|
|
69
|
-
for (;
|
|
70
|
-
(
|
|
72
|
+
for (; a < n.length && r.some(
|
|
73
|
+
(u) => n[a].includes(u)
|
|
71
74
|
); )
|
|
72
|
-
|
|
73
|
-
const c =
|
|
75
|
+
a++;
|
|
76
|
+
const c = n[a] || "";
|
|
74
77
|
let h = "Unknown function", i = "Unknown caller";
|
|
75
78
|
const l = c.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
|
|
76
79
|
if (l)
|
|
77
80
|
h = l[1], i = l[2];
|
|
78
81
|
else {
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
i =
|
|
82
|
+
const u = c.match(/at\s+(.+)/);
|
|
83
|
+
if (u) {
|
|
84
|
+
i = u[1];
|
|
82
85
|
const d = i.match(/at\s+([^(\s]+)\s+/);
|
|
83
86
|
d && d[1] !== "new" && (h = d[1]);
|
|
84
87
|
}
|
|
@@ -88,31 +91,31 @@ function x() {
|
|
|
88
91
|
i.lastIndexOf(")")
|
|
89
92
|
)), i = i.split(":").slice(0, -2).join(":");
|
|
90
93
|
try {
|
|
91
|
-
i =
|
|
94
|
+
i = $.relative(e, i);
|
|
92
95
|
} catch {
|
|
93
96
|
}
|
|
94
97
|
return { functionName: h, callerInfo: i };
|
|
95
98
|
}
|
|
96
99
|
class y {
|
|
97
100
|
onDebug(t) {
|
|
98
|
-
const { name: s, body:
|
|
99
|
-
c.push(`${s} initialized`), c.push(`Caller Function: ${i}`), c.push(`Caller Location: ${h}`),
|
|
101
|
+
const { name: s, body: n, cause: r, message: a } = t, c = [], { callerInfo: h, functionName: i } = N();
|
|
102
|
+
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 });
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
|
-
class
|
|
105
|
+
class J extends y {
|
|
103
106
|
/**
|
|
104
107
|
* Creates an instance of the `BadGateway` class.
|
|
105
108
|
*
|
|
106
109
|
* @param message - A descriptive message explaining the cause of the error.
|
|
107
110
|
* @param cause - Optional additional information about the cause of the error.
|
|
108
111
|
*/
|
|
109
|
-
constructor(s,
|
|
112
|
+
constructor(s, n) {
|
|
110
113
|
super();
|
|
111
114
|
o(this, "body");
|
|
112
115
|
o(this, "cause");
|
|
113
116
|
o(this, "status", 502);
|
|
114
117
|
o(this, "statusText");
|
|
115
|
-
this.body = { name: "BadGateway", message: s }, this.statusText = s, this.cause =
|
|
118
|
+
this.body = { name: "BadGateway", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
|
|
116
119
|
name: "BadGateway",
|
|
117
120
|
body: this.body,
|
|
118
121
|
cause: this.cause,
|
|
@@ -147,20 +150,20 @@ class j extends y {
|
|
|
147
150
|
return Response.json(this.body, s);
|
|
148
151
|
}
|
|
149
152
|
}
|
|
150
|
-
class
|
|
153
|
+
class x extends y {
|
|
151
154
|
/**
|
|
152
155
|
* Creates an instance of the `BadRequest` class.
|
|
153
156
|
*
|
|
154
157
|
* @param message - A descriptive message explaining the cause of the error.
|
|
155
158
|
* @param cause - Optional additional information about the cause of the error.
|
|
156
159
|
*/
|
|
157
|
-
constructor(s,
|
|
160
|
+
constructor(s, n) {
|
|
158
161
|
super();
|
|
159
162
|
o(this, "body");
|
|
160
163
|
o(this, "cause");
|
|
161
164
|
o(this, "status", 400);
|
|
162
165
|
o(this, "statusText");
|
|
163
|
-
this.body = { name: "BadRequest", message: s }, this.statusText = s, this.cause =
|
|
166
|
+
this.body = { name: "BadRequest", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
|
|
164
167
|
name: "BadRequest",
|
|
165
168
|
body: this.body,
|
|
166
169
|
cause: this.cause,
|
|
@@ -195,20 +198,20 @@ class b extends y {
|
|
|
195
198
|
return Response.json(this.body, s);
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
|
-
class
|
|
201
|
+
class j extends y {
|
|
199
202
|
/**
|
|
200
203
|
* Creates an instance of the `Conflict` class.
|
|
201
204
|
*
|
|
202
205
|
* @param message - A descriptive message explaining the cause of the conflict.
|
|
203
206
|
* @param cause - Optional additional information about the cause of the conflict.
|
|
204
207
|
*/
|
|
205
|
-
constructor(s,
|
|
208
|
+
constructor(s, n) {
|
|
206
209
|
super();
|
|
207
210
|
o(this, "body");
|
|
208
211
|
o(this, "cause");
|
|
209
212
|
o(this, "status", 409);
|
|
210
213
|
o(this, "statusText");
|
|
211
|
-
this.body = { name: "Conflict", message: s }, this.statusText = s, this.cause =
|
|
214
|
+
this.body = { name: "Conflict", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
|
|
212
215
|
name: "Conflict",
|
|
213
216
|
body: this.body,
|
|
214
217
|
cause: this.cause,
|
|
@@ -243,20 +246,20 @@ class J extends y {
|
|
|
243
246
|
return Response.json(this.body, s);
|
|
244
247
|
}
|
|
245
248
|
}
|
|
246
|
-
class
|
|
249
|
+
class L extends y {
|
|
247
250
|
/**
|
|
248
251
|
* Creates an instance of the `Forbidden` class.
|
|
249
252
|
*
|
|
250
253
|
* @param message - A descriptive message explaining why access is forbidden.
|
|
251
254
|
* @param cause - Optional additional information about the cause of the error.
|
|
252
255
|
*/
|
|
253
|
-
constructor(s,
|
|
256
|
+
constructor(s, n) {
|
|
254
257
|
super();
|
|
255
258
|
o(this, "body");
|
|
256
259
|
o(this, "cause");
|
|
257
260
|
o(this, "status", 403);
|
|
258
261
|
o(this, "statusText");
|
|
259
|
-
this.body = { name: "Forbidden", message: s }, this.statusText = s, this.cause =
|
|
262
|
+
this.body = { name: "Forbidden", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
|
|
260
263
|
name: "Forbidden",
|
|
261
264
|
body: this.body,
|
|
262
265
|
cause: this.cause,
|
|
@@ -291,20 +294,20 @@ class D extends y {
|
|
|
291
294
|
return Response.json(this.body, s);
|
|
292
295
|
}
|
|
293
296
|
}
|
|
294
|
-
class
|
|
297
|
+
class B extends y {
|
|
295
298
|
/**
|
|
296
299
|
* Creates an instance of the `NotFound` class.
|
|
297
300
|
*
|
|
298
301
|
* @param message - A descriptive message explaining the reason the resource was not found.
|
|
299
302
|
* @param cause - Optional additional information about the cause of the error.
|
|
300
303
|
*/
|
|
301
|
-
constructor(s,
|
|
304
|
+
constructor(s, n) {
|
|
302
305
|
super();
|
|
303
306
|
o(this, "body");
|
|
304
307
|
o(this, "cause");
|
|
305
308
|
o(this, "status", 404);
|
|
306
309
|
o(this, "statusText");
|
|
307
|
-
this.body = { name: "NotFound", message: s }, this.statusText = s, this.cause =
|
|
310
|
+
this.body = { name: "NotFound", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
|
|
308
311
|
name: "NotFound",
|
|
309
312
|
body: this.body,
|
|
310
313
|
cause: this.cause,
|
|
@@ -339,20 +342,20 @@ class C extends y {
|
|
|
339
342
|
return Response.json(this.body, s);
|
|
340
343
|
}
|
|
341
344
|
}
|
|
342
|
-
class
|
|
345
|
+
class H extends y {
|
|
343
346
|
/**
|
|
344
347
|
* Creates an instance of the `NotImplemented` class.
|
|
345
348
|
*
|
|
346
349
|
* @param message - A descriptive message explaining why the functionality is not implemented.
|
|
347
350
|
* @param cause - Optional additional information about the cause of the error.
|
|
348
351
|
*/
|
|
349
|
-
constructor(s,
|
|
352
|
+
constructor(s, n) {
|
|
350
353
|
super();
|
|
351
354
|
o(this, "body");
|
|
352
355
|
o(this, "cause");
|
|
353
356
|
o(this, "status", 501);
|
|
354
357
|
o(this, "statusText");
|
|
355
|
-
this.body = { name: "NotImplemented", message: s }, this.statusText = s, this.cause =
|
|
358
|
+
this.body = { name: "NotImplemented", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
|
|
356
359
|
name: "NotImplemented",
|
|
357
360
|
body: this.body,
|
|
358
361
|
cause: this.cause,
|
|
@@ -387,20 +390,20 @@ class B extends y {
|
|
|
387
390
|
return Response.json(this.body, s);
|
|
388
391
|
}
|
|
389
392
|
}
|
|
390
|
-
class
|
|
393
|
+
class b extends y {
|
|
391
394
|
/**
|
|
392
395
|
* Creates an instance of the `ServerError` class.
|
|
393
396
|
*
|
|
394
397
|
* @param message - A descriptive message explaining the cause of the server error.
|
|
395
398
|
* @param cause - Optional additional information about the cause of the error.
|
|
396
399
|
*/
|
|
397
|
-
constructor(s,
|
|
400
|
+
constructor(s, n) {
|
|
398
401
|
super();
|
|
399
402
|
o(this, "body");
|
|
400
403
|
o(this, "cause");
|
|
401
404
|
o(this, "status", 500);
|
|
402
405
|
o(this, "statusText");
|
|
403
|
-
this.body = { name: "ServerError", message: s }, this.statusText = s, this.cause =
|
|
406
|
+
this.body = { name: "ServerError", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
|
|
404
407
|
name: "ServerError",
|
|
405
408
|
body: this.body,
|
|
406
409
|
cause: this.cause,
|
|
@@ -442,13 +445,13 @@ class q extends y {
|
|
|
442
445
|
* @param message - A descriptive message explaining why the request is unauthorized.
|
|
443
446
|
* @param cause - Optional additional information about the cause of the error.
|
|
444
447
|
*/
|
|
445
|
-
constructor(s,
|
|
448
|
+
constructor(s, n) {
|
|
446
449
|
super();
|
|
447
450
|
o(this, "body");
|
|
448
451
|
o(this, "cause");
|
|
449
452
|
o(this, "status", 401);
|
|
450
453
|
o(this, "statusText");
|
|
451
|
-
this.body = { name: "Unauthorized", message: s }, this.statusText = s, this.cause =
|
|
454
|
+
this.body = { name: "Unauthorized", message: s }, this.statusText = s, this.cause = n ? JSON.stringify(n) : void 0, this.onDebug({
|
|
452
455
|
name: "Unauthorized",
|
|
453
456
|
body: this.body,
|
|
454
457
|
cause: this.cause,
|
|
@@ -483,7 +486,7 @@ class q extends y {
|
|
|
483
486
|
return Response.json(this.body, s);
|
|
484
487
|
}
|
|
485
488
|
}
|
|
486
|
-
class
|
|
489
|
+
class O extends y {
|
|
487
490
|
/**
|
|
488
491
|
* Creates an instance of the `UnprocessableEntity` class.
|
|
489
492
|
*
|
|
@@ -539,7 +542,7 @@ class N extends y {
|
|
|
539
542
|
return Response.json(this.body, s);
|
|
540
543
|
}
|
|
541
544
|
}
|
|
542
|
-
class
|
|
545
|
+
class m {
|
|
543
546
|
/**
|
|
544
547
|
* Logs debug information for success responses including caller context and response details.
|
|
545
548
|
*
|
|
@@ -553,34 +556,34 @@ class T {
|
|
|
553
556
|
* SuccessResponse.onDebug("ValidationError", { field: "email", message: "Invalid format" });
|
|
554
557
|
* ```
|
|
555
558
|
*/
|
|
556
|
-
onDebug(t, s,
|
|
557
|
-
const r = [], { callerInfo:
|
|
559
|
+
onDebug(t, s, n) {
|
|
560
|
+
const r = [], { callerInfo: a, functionName: c } = N();
|
|
558
561
|
r.push(`${t} initialized
|
|
559
562
|
`), r.push(`Caller Function: ${c}
|
|
560
|
-
`), r.push(`Caller Location: ${
|
|
563
|
+
`), r.push(`Caller Location: ${a}
|
|
561
564
|
`), r.push(`Body: ${JSON.stringify(s, null, 2)}
|
|
562
|
-
`),
|
|
563
|
-
`),
|
|
565
|
+
`), n && r.push(`Cause: ${JSON.stringify(n, null, 2)}
|
|
566
|
+
`), g({
|
|
564
567
|
scheme: "green",
|
|
565
568
|
name: "ARKYN-SUCCESS-RESPONSE-DEBUG",
|
|
566
569
|
debugs: r
|
|
567
570
|
});
|
|
568
571
|
}
|
|
569
572
|
}
|
|
570
|
-
class
|
|
573
|
+
class F extends m {
|
|
571
574
|
/**
|
|
572
575
|
* Creates an instance of the `Created` class.
|
|
573
576
|
*
|
|
574
577
|
* @param body - The response body to be included in the HTTP response.
|
|
575
578
|
* @param init - Optional initialization object for customizing headers, status, and status text.
|
|
576
579
|
*/
|
|
577
|
-
constructor(s,
|
|
580
|
+
constructor(s, n) {
|
|
578
581
|
super();
|
|
579
582
|
o(this, "body");
|
|
580
583
|
o(this, "headers");
|
|
581
584
|
o(this, "status");
|
|
582
585
|
o(this, "statusText");
|
|
583
|
-
this.body = s, this.headers = (
|
|
586
|
+
this.body = s, 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);
|
|
584
587
|
}
|
|
585
588
|
/**
|
|
586
589
|
* Converts the `Created` instance into a `Response` object with a JSON body.
|
|
@@ -611,7 +614,7 @@ class P extends T {
|
|
|
611
614
|
return Response.json(this.body, s);
|
|
612
615
|
}
|
|
613
616
|
}
|
|
614
|
-
class
|
|
617
|
+
class Y extends m {
|
|
615
618
|
/**
|
|
616
619
|
* Creates an instance of the `Found` class.
|
|
617
620
|
*
|
|
@@ -621,13 +624,13 @@ class $ extends T {
|
|
|
621
624
|
* - `status`: HTTP status code (default is 302).
|
|
622
625
|
* - `statusText`: HTTP status text (default is "Found").
|
|
623
626
|
*/
|
|
624
|
-
constructor(s,
|
|
627
|
+
constructor(s, n) {
|
|
625
628
|
super();
|
|
626
629
|
o(this, "body");
|
|
627
630
|
o(this, "headers");
|
|
628
631
|
o(this, "status");
|
|
629
632
|
o(this, "statusText");
|
|
630
|
-
this.body = s, this.headers = (
|
|
633
|
+
this.body = s, 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);
|
|
631
634
|
}
|
|
632
635
|
/**
|
|
633
636
|
* Converts the `Found` instance into a `Response` object.
|
|
@@ -658,7 +661,7 @@ class $ extends T {
|
|
|
658
661
|
return Response.json(this.body, s);
|
|
659
662
|
}
|
|
660
663
|
}
|
|
661
|
-
class
|
|
664
|
+
class P extends m {
|
|
662
665
|
/**
|
|
663
666
|
* Creates an instance of the `NoContent` class.
|
|
664
667
|
*
|
|
@@ -686,20 +689,20 @@ class H extends T {
|
|
|
686
689
|
return new Response(null, s);
|
|
687
690
|
}
|
|
688
691
|
}
|
|
689
|
-
class
|
|
692
|
+
class M extends m {
|
|
690
693
|
/**
|
|
691
694
|
* Creates an instance of the `Success` class.
|
|
692
695
|
*
|
|
693
696
|
* @param body - The response body to be included in the HTTP response.
|
|
694
697
|
* @param init - Optional initialization object for customizing headers, status, and status text.
|
|
695
698
|
*/
|
|
696
|
-
constructor(s,
|
|
699
|
+
constructor(s, n) {
|
|
697
700
|
super();
|
|
698
701
|
o(this, "body");
|
|
699
702
|
o(this, "headers");
|
|
700
703
|
o(this, "status");
|
|
701
704
|
o(this, "statusText");
|
|
702
|
-
this.body = s, this.headers = (
|
|
705
|
+
this.body = s, 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);
|
|
703
706
|
}
|
|
704
707
|
/**
|
|
705
708
|
* Converts the `Success` instance into a `Response` object with a JSON body.
|
|
@@ -730,20 +733,20 @@ class A extends T {
|
|
|
730
733
|
return Response.json(this.body, s);
|
|
731
734
|
}
|
|
732
735
|
}
|
|
733
|
-
class
|
|
736
|
+
class z extends m {
|
|
734
737
|
/**
|
|
735
738
|
* Creates an instance of the `Updated` class.
|
|
736
739
|
*
|
|
737
740
|
* @param body - The response body to be included in the HTTP response.
|
|
738
741
|
* @param init - Optional initialization object for customizing headers, status, and status text.
|
|
739
742
|
*/
|
|
740
|
-
constructor(s,
|
|
743
|
+
constructor(s, n) {
|
|
741
744
|
super();
|
|
742
745
|
o(this, "body");
|
|
743
746
|
o(this, "headers");
|
|
744
747
|
o(this, "status");
|
|
745
748
|
o(this, "statusText");
|
|
746
|
-
this.body = s, this.headers = (
|
|
749
|
+
this.body = s, 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);
|
|
747
750
|
}
|
|
748
751
|
/**
|
|
749
752
|
* Converts the `Updated` instance into a `Response` object with a JSON body.
|
|
@@ -774,14 +777,14 @@ class L extends T {
|
|
|
774
777
|
return Response.json(this.body, s);
|
|
775
778
|
}
|
|
776
779
|
}
|
|
777
|
-
class
|
|
780
|
+
class _ {
|
|
778
781
|
static mapHeaders(t) {
|
|
779
|
-
return t instanceof Headers ? Object.fromEntries(t.entries()) : typeof t == "object" ? Object.entries(t).reduce((s, [
|
|
782
|
+
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), {}) : {};
|
|
780
783
|
}
|
|
781
784
|
static mapQueryParams(t) {
|
|
782
785
|
const s = {};
|
|
783
|
-
return t.forEach((
|
|
784
|
-
s[r] =
|
|
786
|
+
return t.forEach((n, r) => {
|
|
787
|
+
s[r] = n;
|
|
785
788
|
}), s;
|
|
786
789
|
}
|
|
787
790
|
static handle(t) {
|
|
@@ -799,7 +802,7 @@ class v {
|
|
|
799
802
|
};
|
|
800
803
|
}
|
|
801
804
|
}
|
|
802
|
-
class
|
|
805
|
+
class U {
|
|
803
806
|
/**
|
|
804
807
|
* Sets the configuration for the arkyn. This method initializes the arkyn configuration
|
|
805
808
|
* with the provided `arkynConfig` values. If the configuration has already been set,
|
|
@@ -813,11 +816,11 @@ class w {
|
|
|
813
816
|
*/
|
|
814
817
|
static setArkynConfig(t) {
|
|
815
818
|
if (this.arkynConfig) return;
|
|
816
|
-
let
|
|
817
|
-
|
|
819
|
+
let n = t.arkynLogBaseApiUrl || "https://logs-arkyn-flow-logs.vw6wo7.easypanel.host";
|
|
820
|
+
n = n + "/http-traffic-records/:trafficSourceId", this.arkynConfig = {
|
|
818
821
|
arkynTrafficSourceId: t.arkynTrafficSourceId,
|
|
819
822
|
arkynUserToken: t.arkynUserToken,
|
|
820
|
-
arkynApiUrl:
|
|
823
|
+
arkynApiUrl: n
|
|
821
824
|
};
|
|
822
825
|
}
|
|
823
826
|
/**
|
|
@@ -837,64 +840,64 @@ class w {
|
|
|
837
840
|
this.arkynConfig = void 0;
|
|
838
841
|
}
|
|
839
842
|
}
|
|
840
|
-
o(
|
|
841
|
-
async function
|
|
842
|
-
const t =
|
|
843
|
+
o(U, "arkynConfig");
|
|
844
|
+
async function V(e) {
|
|
845
|
+
const t = U.getArkynConfig();
|
|
843
846
|
if (!t) return;
|
|
844
|
-
const { arkynUserToken: s, arkynApiUrl:
|
|
847
|
+
const { arkynUserToken: s, arkynApiUrl: n } = t, {
|
|
845
848
|
elapsedTime: r,
|
|
846
|
-
method:
|
|
849
|
+
method: a,
|
|
847
850
|
queryParams: c,
|
|
848
851
|
requestBody: h,
|
|
849
852
|
requestHeaders: i,
|
|
850
853
|
responseBody: l,
|
|
851
|
-
responseHeaders:
|
|
854
|
+
responseHeaders: u,
|
|
852
855
|
status: d,
|
|
853
|
-
token:
|
|
854
|
-
rawUrl:
|
|
855
|
-
} =
|
|
856
|
+
token: C,
|
|
857
|
+
rawUrl: f
|
|
858
|
+
} = e;
|
|
856
859
|
if (process.env.NODE_ENV !== "development")
|
|
857
860
|
try {
|
|
858
|
-
const
|
|
859
|
-
let
|
|
860
|
-
|
|
861
|
-
const
|
|
862
|
-
domainUrl:
|
|
863
|
-
pathnameUrl:
|
|
861
|
+
const p = new URL(f);
|
|
862
|
+
let S = "HTTPS";
|
|
863
|
+
p.protocol === "http:" && (S = "HTTP");
|
|
864
|
+
const v = JSON.stringify({
|
|
865
|
+
domainUrl: p.protocol + "//" + p.host,
|
|
866
|
+
pathnameUrl: p.pathname,
|
|
864
867
|
status: d,
|
|
865
|
-
protocol:
|
|
866
|
-
method:
|
|
868
|
+
protocol: S,
|
|
869
|
+
method: a,
|
|
867
870
|
trafficUserId: null,
|
|
868
871
|
elapsedTime: r,
|
|
869
872
|
requestHeaders: i,
|
|
870
873
|
requestBody: h,
|
|
871
874
|
queryParams: c,
|
|
872
|
-
responseHeaders:
|
|
875
|
+
responseHeaders: u,
|
|
873
876
|
responseBody: l
|
|
874
877
|
});
|
|
875
878
|
await fetch(
|
|
876
|
-
|
|
879
|
+
n.replace(
|
|
877
880
|
":trafficSourceId",
|
|
878
881
|
t.arkynTrafficSourceId
|
|
879
882
|
),
|
|
880
883
|
{
|
|
881
884
|
method: "POST",
|
|
882
|
-
body:
|
|
885
|
+
body: v,
|
|
883
886
|
headers: {
|
|
884
887
|
"Content-Type": "application/json",
|
|
885
888
|
Authorization: `Bearer ${s}`
|
|
886
889
|
}
|
|
887
890
|
}
|
|
888
891
|
);
|
|
889
|
-
} catch (
|
|
890
|
-
|
|
891
|
-
debugs: [`Error sending request: ${
|
|
892
|
+
} catch (p) {
|
|
893
|
+
g({
|
|
894
|
+
debugs: [`Error sending request: ${p}`],
|
|
892
895
|
name: "ARKYN_LOG_ERROR",
|
|
893
896
|
scheme: "red"
|
|
894
897
|
});
|
|
895
898
|
}
|
|
896
899
|
}
|
|
897
|
-
async function
|
|
900
|
+
async function T(e, t, s = {}, n) {
|
|
898
901
|
const r = {
|
|
899
902
|
POST: "Resource created successfully",
|
|
900
903
|
PUT: "Resource updated successfully",
|
|
@@ -903,44 +906,44 @@ async function g(n, t, s = {}, e) {
|
|
|
903
906
|
GET: "Request successful"
|
|
904
907
|
};
|
|
905
908
|
try {
|
|
906
|
-
const
|
|
907
|
-
method:
|
|
909
|
+
const a = performance.now(), c = { ...s, "Content-Type": "application/json" }, h = await fetch(t, {
|
|
910
|
+
method: e,
|
|
908
911
|
headers: c,
|
|
909
|
-
body:
|
|
910
|
-
}), i = performance.now() -
|
|
911
|
-
let
|
|
912
|
+
body: n ? JSON.stringify(n) : void 0
|
|
913
|
+
}), i = performance.now() - a, l = h.status;
|
|
914
|
+
let u = null;
|
|
912
915
|
try {
|
|
913
|
-
|
|
916
|
+
u = await h.json();
|
|
914
917
|
} catch {
|
|
915
|
-
|
|
918
|
+
u = null;
|
|
916
919
|
}
|
|
917
|
-
const d =
|
|
920
|
+
const d = _.handle({
|
|
918
921
|
elapsedTime: i,
|
|
919
|
-
method:
|
|
922
|
+
method: e,
|
|
920
923
|
queryParams: new URL(t).searchParams,
|
|
921
924
|
requestHeaders: c,
|
|
922
|
-
requestBody:
|
|
923
|
-
responseBody:
|
|
925
|
+
requestBody: n,
|
|
926
|
+
responseBody: u,
|
|
924
927
|
responseHeaders: h.headers,
|
|
925
928
|
status: l,
|
|
926
929
|
url: t
|
|
927
930
|
});
|
|
928
|
-
return
|
|
931
|
+
return V(d), h.ok ? {
|
|
929
932
|
success: !0,
|
|
930
933
|
status: l,
|
|
931
|
-
message: (
|
|
932
|
-
response:
|
|
934
|
+
message: (u == null ? void 0 : u.message) || r[e],
|
|
935
|
+
response: u,
|
|
933
936
|
cause: null
|
|
934
937
|
} : {
|
|
935
938
|
success: !1,
|
|
936
939
|
status: l,
|
|
937
|
-
message: (
|
|
938
|
-
response:
|
|
940
|
+
message: (u == null ? void 0 : u.message) || h.statusText || "Request failed",
|
|
941
|
+
response: u,
|
|
939
942
|
cause: null
|
|
940
943
|
};
|
|
941
|
-
} catch (
|
|
942
|
-
return
|
|
943
|
-
debugs: [`Network error or request failed: ${
|
|
944
|
+
} catch (a) {
|
|
945
|
+
return g({
|
|
946
|
+
debugs: [`Network error or request failed: ${a}`],
|
|
944
947
|
name: "ARKYN_MAKE_REQUEST_ERROR",
|
|
945
948
|
scheme: "red"
|
|
946
949
|
}), {
|
|
@@ -948,26 +951,26 @@ async function g(n, t, s = {}, e) {
|
|
|
948
951
|
status: 0,
|
|
949
952
|
message: "Network error or request failed",
|
|
950
953
|
response: null,
|
|
951
|
-
cause:
|
|
954
|
+
cause: a instanceof Error ? a.message : String(a)
|
|
952
955
|
};
|
|
953
956
|
}
|
|
954
957
|
}
|
|
955
|
-
async function
|
|
956
|
-
return
|
|
958
|
+
async function G(e, t = {}, s) {
|
|
959
|
+
return T("DELETE", e, t, s);
|
|
957
960
|
}
|
|
958
|
-
async function
|
|
959
|
-
return
|
|
961
|
+
async function Z(e, t = {}) {
|
|
962
|
+
return T("GET", e, t);
|
|
960
963
|
}
|
|
961
|
-
async function
|
|
962
|
-
return
|
|
964
|
+
async function W(e, t = {}, s) {
|
|
965
|
+
return T("PATCH", e, t, s);
|
|
963
966
|
}
|
|
964
|
-
async function
|
|
965
|
-
return
|
|
967
|
+
async function K(e, t = {}, s) {
|
|
968
|
+
return T("POST", e, t, s);
|
|
966
969
|
}
|
|
967
|
-
async function
|
|
968
|
-
return
|
|
970
|
+
async function Q(e, t = {}, s) {
|
|
971
|
+
return T("PUT", e, t, s);
|
|
969
972
|
}
|
|
970
|
-
class
|
|
973
|
+
class Rs {
|
|
971
974
|
/**
|
|
972
975
|
* Creates an instance of ApiService.
|
|
973
976
|
* @param props - The configuration properties for the API instance.
|
|
@@ -988,10 +991,10 @@ class X {
|
|
|
988
991
|
* @param route - The route to append to the base URL.
|
|
989
992
|
* @returns The full URL as a string.
|
|
990
993
|
*/
|
|
991
|
-
onDebug(t, s,
|
|
994
|
+
onDebug(t, s, n) {
|
|
992
995
|
if (this.enableDebug) {
|
|
993
996
|
const r = [];
|
|
994
|
-
r.push(`Base URL: ${this.baseUrl}`), r.push(`Endpoint: ${t}`), r.push(`Method: ${s}`),
|
|
997
|
+
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" });
|
|
995
998
|
}
|
|
996
999
|
}
|
|
997
1000
|
generateURL(t) {
|
|
@@ -1004,8 +1007,8 @@ class X {
|
|
|
1004
1007
|
* @returns The merged headers as a HeadersInit object.
|
|
1005
1008
|
*/
|
|
1006
1009
|
generateHeaders(t, s) {
|
|
1007
|
-
let
|
|
1008
|
-
return this.baseToken && (
|
|
1010
|
+
let n = {};
|
|
1011
|
+
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;
|
|
1009
1012
|
}
|
|
1010
1013
|
/**
|
|
1011
1014
|
* Sends a get request to the specified endpoint.
|
|
@@ -1014,8 +1017,8 @@ class X {
|
|
|
1014
1017
|
* @returns The API response data.
|
|
1015
1018
|
*/
|
|
1016
1019
|
async get(t, s) {
|
|
1017
|
-
const
|
|
1018
|
-
return this.onDebug(t, "get", [r]), await
|
|
1020
|
+
const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token);
|
|
1021
|
+
return this.onDebug(t, "get", [r]), await Z(n, r);
|
|
1019
1022
|
}
|
|
1020
1023
|
/**
|
|
1021
1024
|
* Sends a post request to the specified endpoint.
|
|
@@ -1024,8 +1027,8 @@ class X {
|
|
|
1024
1027
|
* @returns The API response data.
|
|
1025
1028
|
*/
|
|
1026
1029
|
async post(t, s) {
|
|
1027
|
-
const
|
|
1028
|
-
return this.onDebug(t, "post", [r,
|
|
1030
|
+
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;
|
|
1031
|
+
return this.onDebug(t, "post", [r, a]), await K(n, r, a);
|
|
1029
1032
|
}
|
|
1030
1033
|
/**
|
|
1031
1034
|
* Sends a put request to the specified endpoint.
|
|
@@ -1034,8 +1037,8 @@ class X {
|
|
|
1034
1037
|
* @returns The API response data.
|
|
1035
1038
|
*/
|
|
1036
1039
|
async put(t, s) {
|
|
1037
|
-
const
|
|
1038
|
-
return this.onDebug(t, "put", [r,
|
|
1040
|
+
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;
|
|
1041
|
+
return this.onDebug(t, "put", [r, a]), await Q(n, r, a);
|
|
1039
1042
|
}
|
|
1040
1043
|
/**
|
|
1041
1044
|
* Sends a patch request to the specified endpoint.
|
|
@@ -1044,8 +1047,8 @@ class X {
|
|
|
1044
1047
|
* @returns The API response data.
|
|
1045
1048
|
*/
|
|
1046
1049
|
async patch(t, s) {
|
|
1047
|
-
const
|
|
1048
|
-
return this.onDebug(t, "patch", [r,
|
|
1050
|
+
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;
|
|
1051
|
+
return this.onDebug(t, "patch", [r, a]), await W(n, r, a);
|
|
1049
1052
|
}
|
|
1050
1053
|
/**
|
|
1051
1054
|
* Sends a delete request to the specified endpoint.
|
|
@@ -1054,82 +1057,82 @@ class X {
|
|
|
1054
1057
|
* @returns The API response data.
|
|
1055
1058
|
*/
|
|
1056
1059
|
async delete(t, s) {
|
|
1057
|
-
const
|
|
1058
|
-
return this.onDebug(t, "delete", [r,
|
|
1060
|
+
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;
|
|
1061
|
+
return this.onDebug(t, "delete", [r, a]), await G(n, r, a);
|
|
1059
1062
|
}
|
|
1060
1063
|
}
|
|
1061
|
-
function
|
|
1062
|
-
var s,
|
|
1063
|
-
return
|
|
1064
|
+
function Ns(e, t) {
|
|
1065
|
+
var s, n, r;
|
|
1066
|
+
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";
|
|
1064
1067
|
}
|
|
1065
|
-
const
|
|
1068
|
+
const Ss = async (e) => {
|
|
1066
1069
|
let t;
|
|
1067
|
-
const s = await
|
|
1070
|
+
const s = await e.arrayBuffer(), n = new TextDecoder().decode(s);
|
|
1068
1071
|
try {
|
|
1069
|
-
t = JSON.parse(
|
|
1072
|
+
t = JSON.parse(n);
|
|
1070
1073
|
} catch {
|
|
1071
1074
|
try {
|
|
1072
|
-
if (
|
|
1073
|
-
const
|
|
1074
|
-
t = Object.fromEntries(
|
|
1075
|
+
if (n.includes("=")) {
|
|
1076
|
+
const a = new URLSearchParams(n);
|
|
1077
|
+
t = Object.fromEntries(a.entries());
|
|
1075
1078
|
} else
|
|
1076
|
-
throw new
|
|
1079
|
+
throw new x("Invalid URLSearchParams format");
|
|
1077
1080
|
} catch {
|
|
1078
|
-
throw new
|
|
1081
|
+
throw new x("Failed to extract data from request");
|
|
1079
1082
|
}
|
|
1080
1083
|
}
|
|
1081
1084
|
return t;
|
|
1082
1085
|
};
|
|
1083
|
-
function
|
|
1086
|
+
function Es(e) {
|
|
1084
1087
|
switch (!0) {
|
|
1085
|
-
case
|
|
1086
|
-
return
|
|
1087
|
-
case
|
|
1088
|
-
return
|
|
1089
|
-
case
|
|
1090
|
-
return
|
|
1091
|
-
case
|
|
1092
|
-
return
|
|
1093
|
-
case
|
|
1094
|
-
return
|
|
1095
|
-
case
|
|
1096
|
-
return
|
|
1088
|
+
case e instanceof Response:
|
|
1089
|
+
return e;
|
|
1090
|
+
case e instanceof Y:
|
|
1091
|
+
return e.toResponse();
|
|
1092
|
+
case e instanceof F:
|
|
1093
|
+
return e.toResponse();
|
|
1094
|
+
case e instanceof z:
|
|
1095
|
+
return e.toResponse();
|
|
1096
|
+
case e instanceof M:
|
|
1097
|
+
return e.toResponse();
|
|
1098
|
+
case e instanceof P:
|
|
1099
|
+
return e.toResponse();
|
|
1097
1100
|
}
|
|
1098
1101
|
switch (!0) {
|
|
1099
|
-
case
|
|
1100
|
-
return
|
|
1101
|
-
case
|
|
1102
|
-
return
|
|
1103
|
-
case
|
|
1104
|
-
return
|
|
1105
|
-
case
|
|
1106
|
-
return
|
|
1107
|
-
case
|
|
1108
|
-
return
|
|
1109
|
-
case
|
|
1110
|
-
return
|
|
1111
|
-
case
|
|
1112
|
-
return
|
|
1113
|
-
case
|
|
1114
|
-
return
|
|
1115
|
-
case
|
|
1116
|
-
return
|
|
1117
|
-
}
|
|
1118
|
-
return new
|
|
1102
|
+
case e instanceof J:
|
|
1103
|
+
return e.toResponse();
|
|
1104
|
+
case e instanceof x:
|
|
1105
|
+
return e.toResponse();
|
|
1106
|
+
case e instanceof j:
|
|
1107
|
+
return e.toResponse();
|
|
1108
|
+
case e instanceof L:
|
|
1109
|
+
return e.toResponse();
|
|
1110
|
+
case e instanceof B:
|
|
1111
|
+
return e.toResponse();
|
|
1112
|
+
case e instanceof H:
|
|
1113
|
+
return e.toResponse();
|
|
1114
|
+
case e instanceof b:
|
|
1115
|
+
return e.toResponse();
|
|
1116
|
+
case e instanceof q:
|
|
1117
|
+
return e.toResponse();
|
|
1118
|
+
case e instanceof O:
|
|
1119
|
+
return e.toResponse();
|
|
1120
|
+
}
|
|
1121
|
+
return new b("Server error", e).toResponse();
|
|
1119
1122
|
}
|
|
1120
|
-
function
|
|
1121
|
-
|
|
1123
|
+
function X([
|
|
1124
|
+
e,
|
|
1122
1125
|
t
|
|
1123
1126
|
]) {
|
|
1124
|
-
const s = t.safeParse(
|
|
1127
|
+
const s = t.safeParse(e);
|
|
1125
1128
|
if (s.success === !1) {
|
|
1126
|
-
const
|
|
1129
|
+
const n = Object.fromEntries(
|
|
1127
1130
|
s.error.issues.map((r) => [r.path.join("."), r.message])
|
|
1128
1131
|
);
|
|
1129
1132
|
return {
|
|
1130
1133
|
success: s.success,
|
|
1131
|
-
fieldErrors:
|
|
1132
|
-
fields:
|
|
1134
|
+
fieldErrors: n,
|
|
1135
|
+
fields: e
|
|
1133
1136
|
};
|
|
1134
1137
|
} else
|
|
1135
1138
|
return {
|
|
@@ -1137,28 +1140,28 @@ function V([
|
|
|
1137
1140
|
data: s.data
|
|
1138
1141
|
};
|
|
1139
1142
|
}
|
|
1140
|
-
const
|
|
1141
|
-
const s = new URL(
|
|
1143
|
+
const Ds = (e, t = "") => {
|
|
1144
|
+
const s = new URL(e.url);
|
|
1142
1145
|
if (t === "") return s.searchParams;
|
|
1143
|
-
const
|
|
1146
|
+
const n = Array.from(
|
|
1144
1147
|
s.searchParams.entries()
|
|
1145
|
-
).filter(([r]) => r.startsWith(`${t}:`)).map(([r,
|
|
1146
|
-
return new URLSearchParams(
|
|
1148
|
+
).filter(([r]) => r.startsWith(`${t}:`)).map(([r, a]) => [r.replace(`${t}:`, ""), a]);
|
|
1149
|
+
return new URLSearchParams(n);
|
|
1147
1150
|
};
|
|
1148
|
-
function
|
|
1149
|
-
const t = "Error validating:", s =
|
|
1150
|
-
({ path:
|
|
1151
|
+
function ss(e) {
|
|
1152
|
+
const t = "Error validating:", s = e.issues.map(
|
|
1153
|
+
({ path: n, message: r }) => `-> ${n.join(".")}: ${r}`
|
|
1151
1154
|
);
|
|
1152
1155
|
return [t, ...s].join(`
|
|
1153
1156
|
`);
|
|
1154
1157
|
}
|
|
1155
|
-
class
|
|
1158
|
+
class $s {
|
|
1156
1159
|
constructor(t) {
|
|
1157
1160
|
o(this, "functionName");
|
|
1158
1161
|
o(this, "callerInfo");
|
|
1159
1162
|
this.schema = t;
|
|
1160
|
-
const { callerInfo: s, functionName:
|
|
1161
|
-
this.callerInfo = s, this.functionName =
|
|
1163
|
+
const { callerInfo: s, functionName: n } = N();
|
|
1164
|
+
this.callerInfo = s, this.functionName = n;
|
|
1162
1165
|
}
|
|
1163
1166
|
isValid(t) {
|
|
1164
1167
|
return this.schema.safeParse(t).success;
|
|
@@ -1170,47 +1173,211 @@ class ns {
|
|
|
1170
1173
|
try {
|
|
1171
1174
|
return this.schema.parse(t);
|
|
1172
1175
|
} catch (s) {
|
|
1173
|
-
throw new
|
|
1176
|
+
throw new b(ss(s));
|
|
1174
1177
|
}
|
|
1175
1178
|
}
|
|
1176
1179
|
formValidate(t, s) {
|
|
1177
|
-
const
|
|
1178
|
-
if (!
|
|
1179
|
-
const r = Object.keys(
|
|
1180
|
-
throw new
|
|
1181
|
-
fields:
|
|
1182
|
-
fieldErrors:
|
|
1180
|
+
const n = X([t, this.schema]);
|
|
1181
|
+
if (!n.success) {
|
|
1182
|
+
const r = Object.keys(n.fieldErrors)[0];
|
|
1183
|
+
throw new O({
|
|
1184
|
+
fields: n.fields,
|
|
1185
|
+
fieldErrors: n.fieldErrors,
|
|
1183
1186
|
data: { scrollTo: r },
|
|
1184
1187
|
message: s
|
|
1185
1188
|
});
|
|
1186
1189
|
}
|
|
1187
|
-
return
|
|
1190
|
+
return n.data;
|
|
1188
1191
|
}
|
|
1189
1192
|
}
|
|
1193
|
+
const Is = (e) => {
|
|
1194
|
+
if (!e || !/^[0-9-]+$/.test(e)) return !1;
|
|
1195
|
+
const s = R(e), n = 8, r = /^\d{8}$/.test(s);
|
|
1196
|
+
return s.length === n && r;
|
|
1197
|
+
};
|
|
1198
|
+
function es(e) {
|
|
1199
|
+
return e.length !== 14;
|
|
1200
|
+
}
|
|
1201
|
+
function ts(e) {
|
|
1202
|
+
const [t] = e;
|
|
1203
|
+
return [...e].every((s) => s === t);
|
|
1204
|
+
}
|
|
1205
|
+
function E(e, t) {
|
|
1206
|
+
let s = 0;
|
|
1207
|
+
for (let r = 0; r < t.length; r++)
|
|
1208
|
+
s += parseInt(e[r]) * t[r];
|
|
1209
|
+
const n = s % 11;
|
|
1210
|
+
return n < 2 ? 0 : 11 - n;
|
|
1211
|
+
}
|
|
1212
|
+
function ns(e) {
|
|
1213
|
+
return e.slice(12);
|
|
1214
|
+
}
|
|
1215
|
+
const Os = (e) => {
|
|
1216
|
+
if (!e) return !1;
|
|
1217
|
+
const t = R(e);
|
|
1218
|
+
if (es(t) || ts(t)) return !1;
|
|
1219
|
+
const s = t.slice(0, 12), n = E(s, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), r = E(
|
|
1220
|
+
s + n,
|
|
1221
|
+
[6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
1222
|
+
);
|
|
1223
|
+
return ns(t) === `${n}${r}`;
|
|
1224
|
+
};
|
|
1225
|
+
function rs(e) {
|
|
1226
|
+
return e.length !== 11;
|
|
1227
|
+
}
|
|
1228
|
+
function os(e) {
|
|
1229
|
+
const [t] = e;
|
|
1230
|
+
return [...e].every((s) => s === t);
|
|
1231
|
+
}
|
|
1232
|
+
function D(e, t) {
|
|
1233
|
+
let s = 0;
|
|
1234
|
+
for (const r of e)
|
|
1235
|
+
t > 1 && (s += parseInt(r) * t--);
|
|
1236
|
+
const n = s % 11;
|
|
1237
|
+
return n < 2 ? 0 : 11 - n;
|
|
1238
|
+
}
|
|
1239
|
+
function as(e) {
|
|
1240
|
+
return e.slice(9);
|
|
1241
|
+
}
|
|
1242
|
+
const Us = (e) => {
|
|
1243
|
+
if (!e) return !1;
|
|
1244
|
+
const t = R(e);
|
|
1245
|
+
if (rs(t) || os(t)) return !1;
|
|
1246
|
+
const s = D(t, 10), n = D(t, 11);
|
|
1247
|
+
return as(t) === `${s}${n}`;
|
|
1248
|
+
}, Cs = (e, t) => {
|
|
1249
|
+
let s, n, r;
|
|
1250
|
+
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;
|
|
1251
|
+
if (a === "DD/MM/YYYY") {
|
|
1252
|
+
const f = /^(\d{2})\/(\d{2})\/(\d{4})$/;
|
|
1253
|
+
if (!f.test(e)) return !1;
|
|
1254
|
+
[, s, n, r] = e.match(f) || [];
|
|
1255
|
+
} else if (a === "MM-DD-YYYY") {
|
|
1256
|
+
const f = /^(\d{2})-(\d{2})-(\d{4})$/;
|
|
1257
|
+
if (!f.test(e)) return !1;
|
|
1258
|
+
[, n, s, r] = e.match(f) || [];
|
|
1259
|
+
} else if (a === "YYYY-MM-DD") {
|
|
1260
|
+
const f = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
1261
|
+
if (!f.test(e)) return !1;
|
|
1262
|
+
[, r, n, s] = e.match(f) || [];
|
|
1263
|
+
} else
|
|
1264
|
+
throw new Error("Invalid date format");
|
|
1265
|
+
const i = parseInt(s, 10), l = parseInt(n, 10), u = parseInt(r, 10);
|
|
1266
|
+
if (i < 1 || i > 31 || l < 1 || l > 12) return !1;
|
|
1267
|
+
const d = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
1268
|
+
if (l === 2) {
|
|
1269
|
+
const f = u % 4 === 0 && u % 100 !== 0 || u % 400 === 0;
|
|
1270
|
+
if (i > (f ? 29 : 28)) return !1;
|
|
1271
|
+
} else if (i > d[l - 1])
|
|
1272
|
+
return !1;
|
|
1273
|
+
return u < c || u > h ? !1 : new Date(u, l - 1, i).getDate() === i;
|
|
1274
|
+
}, us = $.promises.resolve;
|
|
1275
|
+
function is(e) {
|
|
1276
|
+
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);
|
|
1277
|
+
}
|
|
1278
|
+
function cs(e) {
|
|
1279
|
+
return !(e.length === 0 || e.length > 64 || e.startsWith(".") || e.endsWith(".") || e.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e));
|
|
1280
|
+
}
|
|
1281
|
+
function hs(e) {
|
|
1282
|
+
return !(e.length === 0 || e.length > 63 || e.startsWith("-") || e.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(e));
|
|
1283
|
+
}
|
|
1284
|
+
function ls(e) {
|
|
1285
|
+
if (e.length === 0 || e.length > 253 || e.startsWith(".") || e.endsWith(".") || e.startsWith("-") || e.endsWith("-"))
|
|
1286
|
+
return !1;
|
|
1287
|
+
const t = e.split(".");
|
|
1288
|
+
if (t.length < 2) return !1;
|
|
1289
|
+
for (const n of t) if (!hs(n)) return !1;
|
|
1290
|
+
const s = t[t.length - 1];
|
|
1291
|
+
return !(s.length < 2 || !/^[a-zA-Z]+$/.test(s));
|
|
1292
|
+
}
|
|
1293
|
+
function fs(e) {
|
|
1294
|
+
const t = e.split("@");
|
|
1295
|
+
if (t.length !== 2) return !1;
|
|
1296
|
+
const [s, n] = t;
|
|
1297
|
+
return !(!cs(s) || !ls(n));
|
|
1298
|
+
}
|
|
1299
|
+
function ds(e) {
|
|
1300
|
+
const t = e.split("@");
|
|
1301
|
+
return t.length === 2 ? t[1].toLowerCase() : null;
|
|
1302
|
+
}
|
|
1303
|
+
const ys = ["MX", "A", "AAAA"];
|
|
1304
|
+
async function ps(e, t) {
|
|
1305
|
+
try {
|
|
1306
|
+
return await us(e, t), !0;
|
|
1307
|
+
} catch {
|
|
1308
|
+
return !1;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
async function gs(e) {
|
|
1312
|
+
for (const t of ys)
|
|
1313
|
+
if (await ps(e, t)) return !0;
|
|
1314
|
+
return !1;
|
|
1315
|
+
}
|
|
1316
|
+
const vs = async (e) => {
|
|
1317
|
+
if (!e || typeof e != "string") return !1;
|
|
1318
|
+
const t = e.trim();
|
|
1319
|
+
if (!is(t) || !fs(t)) return !1;
|
|
1320
|
+
const s = ds(t);
|
|
1321
|
+
return s ? await gs(s) : !1;
|
|
1322
|
+
}, As = (e) => {
|
|
1323
|
+
if (!e) return !1;
|
|
1324
|
+
const t = e.length >= 8, s = /[A-Z]/.test(e), n = /[a-z]/.test(e), r = /\d/.test(e), a = /[!@#$%^&*(),.?":{}|<>_\-+=~`[\]\\\/]/.test(
|
|
1325
|
+
e
|
|
1326
|
+
);
|
|
1327
|
+
return [
|
|
1328
|
+
t,
|
|
1329
|
+
s,
|
|
1330
|
+
n,
|
|
1331
|
+
r,
|
|
1332
|
+
a
|
|
1333
|
+
].every((c) => c);
|
|
1334
|
+
}, ks = (e) => {
|
|
1335
|
+
for (const t of w) {
|
|
1336
|
+
const s = t.code, n = t.prefix ? `-${t.prefix}` : "", r = t.mask.replace(/[^_]/g, "").length;
|
|
1337
|
+
if (t.iso === "BR") {
|
|
1338
|
+
if (new RegExp(`^\\${s} \\d{2}9?\\d{8}$`).test(e)) return !0;
|
|
1339
|
+
continue;
|
|
1340
|
+
}
|
|
1341
|
+
if (new RegExp(`^\\${s}${n} \\d{${r}}$`).test(e)) return !0;
|
|
1342
|
+
}
|
|
1343
|
+
return !1;
|
|
1344
|
+
}, ws = (e) => {
|
|
1345
|
+
if (!e || !/^[0-9a-zA-Z.-]+$/.test(e)) return !1;
|
|
1346
|
+
const s = e.replace(/[^a-zA-Z0-9]/g, "");
|
|
1347
|
+
return s.length < 7 || s.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(s);
|
|
1348
|
+
};
|
|
1190
1349
|
export {
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1350
|
+
Rs as ApiService,
|
|
1351
|
+
U as ArkynLogService,
|
|
1352
|
+
J as BadGateway,
|
|
1353
|
+
x as BadRequest,
|
|
1354
|
+
j as Conflict,
|
|
1355
|
+
F as Created,
|
|
1356
|
+
I as DebugService,
|
|
1357
|
+
L as Forbidden,
|
|
1358
|
+
Y as Found,
|
|
1359
|
+
P as NoContent,
|
|
1360
|
+
B as NotFound,
|
|
1361
|
+
H as NotImplemented,
|
|
1362
|
+
$s as SchemaValidator,
|
|
1363
|
+
b as ServerError,
|
|
1364
|
+
M as Success,
|
|
1206
1365
|
q as Unauthorized,
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1366
|
+
O as UnprocessableEntity,
|
|
1367
|
+
z as Updated,
|
|
1368
|
+
Ns as decodeErrorMessageFromRequest,
|
|
1369
|
+
Ss as decodeRequestBody,
|
|
1370
|
+
Es as errorHandler,
|
|
1371
|
+
g as flushDebugLogs,
|
|
1372
|
+
X as formParse,
|
|
1373
|
+
N as getCaller,
|
|
1374
|
+
Ds as getScopedParams,
|
|
1375
|
+
Is as validateCep,
|
|
1376
|
+
Os as validateCnpj,
|
|
1377
|
+
Us as validateCpf,
|
|
1378
|
+
Cs as validateDate,
|
|
1379
|
+
vs as validateEmail,
|
|
1380
|
+
As as validatePassword,
|
|
1381
|
+
ks as validatePhone,
|
|
1382
|
+
ws as validateRg
|
|
1216
1383
|
};
|