@arkyn/server 3.0.1-beta.80 → 3.0.1-beta.81
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/api/arkynLogRequest.d.ts.map +1 -1
- package/dist/api/arkynLogRequest.js +4 -3
- package/dist/bundle.js +139 -140
- package/dist/bundle.umd.cjs +4 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arkynLogRequest.d.ts","sourceRoot":"","sources":["../../src/api/arkynLogRequest.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,iBAAe,eAAe,CAAC,MAAM,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"arkynLogRequest.d.ts","sourceRoot":"","sources":["../../src/api/arkynLogRequest.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,iBAAe,eAAe,CAAC,MAAM,EAAE,WAAW,iBA4DjD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -46,8 +46,7 @@ async function arkynLogRequest(config) {
|
|
|
46
46
|
return;
|
|
47
47
|
const { userToken, apiUrl, trafficSourceId } = arkynService;
|
|
48
48
|
const { elapsedTime, method, queryParams, requestBody, requestHeaders, responseBody, responseHeaders, status, token, rawUrl, } = config;
|
|
49
|
-
if (process.env.NODE_ENV === "development")
|
|
50
|
-
return;
|
|
49
|
+
// if (process.env.NODE_ENV === "development") return;
|
|
51
50
|
try {
|
|
52
51
|
const url = new URL(rawUrl);
|
|
53
52
|
let protocol = "HTTPS";
|
|
@@ -68,7 +67,7 @@ async function arkynLogRequest(config) {
|
|
|
68
67
|
responseHeaders,
|
|
69
68
|
responseBody,
|
|
70
69
|
});
|
|
71
|
-
await fetch(apiUrl, {
|
|
70
|
+
const data = await fetch(apiUrl, {
|
|
72
71
|
method: "POST",
|
|
73
72
|
body,
|
|
74
73
|
headers: {
|
|
@@ -76,8 +75,10 @@ async function arkynLogRequest(config) {
|
|
|
76
75
|
Authorization: `Bearer ${userToken}`,
|
|
77
76
|
},
|
|
78
77
|
});
|
|
78
|
+
console.log(data);
|
|
79
79
|
}
|
|
80
80
|
catch (err) {
|
|
81
|
+
console.log(err);
|
|
81
82
|
flushDebugLogs({
|
|
82
83
|
debugs: [`Error sending request: ${err}`],
|
|
83
84
|
name: "ARKYN_LOG_ERROR",
|
package/dist/bundle.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (e, t, s) =>
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var v = (e, t, s) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var o = (e, t, s) => v(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
4
|
import "zod";
|
|
5
5
|
import { removeNonNumeric as N } from "@arkyn/shared";
|
|
6
6
|
import "node:dns";
|
|
7
|
-
import { countries as
|
|
7
|
+
import { countries as A } from "@arkyn/templates";
|
|
8
8
|
function g(e) {
|
|
9
9
|
var s;
|
|
10
10
|
if (process.env.NODE_ENV === "development" || ((s = process.env) == null ? void 0 : s.SHOW_ERRORS_IN_CONSOLE) === "true") {
|
|
@@ -22,7 +22,7 @@ function g(e) {
|
|
|
22
22
|
}), console.log(c);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const L = {};
|
|
26
26
|
class I {
|
|
27
27
|
/**
|
|
28
28
|
* Sets the file name to be ignored during stack trace analysis.
|
|
@@ -92,7 +92,7 @@ function E() {
|
|
|
92
92
|
i.lastIndexOf(")")
|
|
93
93
|
)), i = i.split(":").slice(0, -2).join(":");
|
|
94
94
|
try {
|
|
95
|
-
i =
|
|
95
|
+
i = L.relative(e, i);
|
|
96
96
|
} catch {
|
|
97
97
|
}
|
|
98
98
|
return { functionName: h, callerInfo: i };
|
|
@@ -103,7 +103,7 @@ class p {
|
|
|
103
103
|
c.push(`${s} initialized`), c.push(`Caller Function: ${i}`), c.push(`Caller Location: ${h}`), a && c.push(`Message: ${a}`), n && c.push(`Body: ${JSON.stringify(n, null, 2)}`), r && c.push(`Cause: ${JSON.stringify(r, null, 2)}`), g({ scheme: "red", name: "ARKYN-BAD-RESPONSE-DEBUG", debugs: c });
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
class
|
|
106
|
+
class B extends p {
|
|
107
107
|
/**
|
|
108
108
|
* Creates an instance of the `BadGateway` class.
|
|
109
109
|
*
|
|
@@ -199,7 +199,7 @@ class T extends p {
|
|
|
199
199
|
return Response.json(this.body, s);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
class
|
|
202
|
+
class k extends p {
|
|
203
203
|
/**
|
|
204
204
|
* Creates an instance of the `Conflict` class.
|
|
205
205
|
*
|
|
@@ -247,7 +247,7 @@ class B extends p {
|
|
|
247
247
|
return Response.json(this.body, s);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
class
|
|
250
|
+
class H extends p {
|
|
251
251
|
/**
|
|
252
252
|
* Creates an instance of the `Forbidden` class.
|
|
253
253
|
*
|
|
@@ -295,7 +295,7 @@ class k extends p {
|
|
|
295
295
|
return Response.json(this.body, s);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
class
|
|
298
|
+
class q extends p {
|
|
299
299
|
/**
|
|
300
300
|
* Creates an instance of the `NotFound` class.
|
|
301
301
|
*
|
|
@@ -343,7 +343,7 @@ class H extends p {
|
|
|
343
343
|
return Response.json(this.body, s);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
|
-
class
|
|
346
|
+
class F extends p {
|
|
347
347
|
/**
|
|
348
348
|
* Creates an instance of the `NotImplemented` class.
|
|
349
349
|
*
|
|
@@ -439,7 +439,7 @@ class x extends p {
|
|
|
439
439
|
return Response.json(this.body, s);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
class
|
|
442
|
+
class P extends p {
|
|
443
443
|
/**
|
|
444
444
|
* Creates an instance of the `Unauthorized` class.
|
|
445
445
|
*
|
|
@@ -571,7 +571,7 @@ class m {
|
|
|
571
571
|
});
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
class
|
|
574
|
+
class Y extends m {
|
|
575
575
|
/**
|
|
576
576
|
* Creates an instance of the `Created` class.
|
|
577
577
|
*
|
|
@@ -615,7 +615,7 @@ class P extends m {
|
|
|
615
615
|
return Response.json(this.body, s);
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
class
|
|
618
|
+
class z extends m {
|
|
619
619
|
/**
|
|
620
620
|
* Creates an instance of the `Found` class.
|
|
621
621
|
*
|
|
@@ -662,7 +662,7 @@ class Y extends m {
|
|
|
662
662
|
return Response.json(this.body, s);
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
|
-
class
|
|
665
|
+
class M extends m {
|
|
666
666
|
/**
|
|
667
667
|
* Creates an instance of the `NoContent` class.
|
|
668
668
|
*
|
|
@@ -690,7 +690,7 @@ class z extends m {
|
|
|
690
690
|
return new Response(null, s);
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
|
-
class
|
|
693
|
+
class _ extends m {
|
|
694
694
|
/**
|
|
695
695
|
* Creates an instance of the `Success` class.
|
|
696
696
|
*
|
|
@@ -734,7 +734,7 @@ class M extends m {
|
|
|
734
734
|
return Response.json(this.body, s);
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
|
-
class
|
|
737
|
+
class V extends m {
|
|
738
738
|
/**
|
|
739
739
|
* Creates an instance of the `Updated` class.
|
|
740
740
|
*
|
|
@@ -778,7 +778,7 @@ class _ extends m {
|
|
|
778
778
|
return Response.json(this.body, s);
|
|
779
779
|
}
|
|
780
780
|
}
|
|
781
|
-
class
|
|
781
|
+
class G {
|
|
782
782
|
static mapHeaders(t) {
|
|
783
783
|
return t instanceof Headers ? Object.fromEntries(t.entries()) : typeof t == "object" ? Object.entries(t).reduce((s, [n, r]) => (typeof r == "string" ? s[n] = r : Array.isArray(r) ? s[n] = r.join(", ") : s[n] = JSON.stringify(r), s), {}) : {};
|
|
784
784
|
}
|
|
@@ -842,7 +842,7 @@ class C {
|
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
844
|
o(C, "arkynConfig");
|
|
845
|
-
async function
|
|
845
|
+
async function Z(e) {
|
|
846
846
|
const t = C.getArkynConfig();
|
|
847
847
|
if (!t) return;
|
|
848
848
|
const { userToken: s, apiUrl: n, trafficSourceId: r } = t, {
|
|
@@ -857,41 +857,40 @@ async function G(e) {
|
|
|
857
857
|
token: f,
|
|
858
858
|
rawUrl: j
|
|
859
859
|
} = e;
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
}
|
|
860
|
+
try {
|
|
861
|
+
const y = new URL(j);
|
|
862
|
+
let D = "HTTPS";
|
|
863
|
+
y.protocol === "http:" && (D = "HTTP");
|
|
864
|
+
const J = JSON.stringify({
|
|
865
|
+
domainUrl: y.protocol + "//" + y.host,
|
|
866
|
+
pathnameUrl: y.pathname,
|
|
867
|
+
trafficSourceId: r,
|
|
868
|
+
status: S,
|
|
869
|
+
protocol: D,
|
|
870
|
+
method: c,
|
|
871
|
+
trafficUserId: null,
|
|
872
|
+
elapsedTime: a,
|
|
873
|
+
requestHeaders: l,
|
|
874
|
+
requestBody: i,
|
|
875
|
+
queryParams: h,
|
|
876
|
+
responseHeaders: d,
|
|
877
|
+
responseBody: u
|
|
878
|
+
}), w = await fetch(n, {
|
|
879
|
+
method: "POST",
|
|
880
|
+
body: J,
|
|
881
|
+
headers: {
|
|
882
|
+
"Content-Type": "application/json",
|
|
883
|
+
Authorization: `Bearer ${s}`
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
console.log(w);
|
|
887
|
+
} catch (y) {
|
|
888
|
+
console.log(y), g({
|
|
889
|
+
debugs: [`Error sending request: ${y}`],
|
|
890
|
+
name: "ARKYN_LOG_ERROR",
|
|
891
|
+
scheme: "red"
|
|
892
|
+
});
|
|
893
|
+
}
|
|
895
894
|
}
|
|
896
895
|
async function b(e, t, s = {}, n) {
|
|
897
896
|
const r = {
|
|
@@ -913,7 +912,7 @@ async function b(e, t, s = {}, n) {
|
|
|
913
912
|
} catch {
|
|
914
913
|
u = null;
|
|
915
914
|
}
|
|
916
|
-
const d =
|
|
915
|
+
const d = G.handle({
|
|
917
916
|
elapsedTime: i,
|
|
918
917
|
method: e,
|
|
919
918
|
queryParams: new URL(t).searchParams,
|
|
@@ -924,7 +923,7 @@ async function b(e, t, s = {}, n) {
|
|
|
924
923
|
status: l,
|
|
925
924
|
url: t
|
|
926
925
|
});
|
|
927
|
-
return
|
|
926
|
+
return Z(d), h.ok ? {
|
|
928
927
|
success: !0,
|
|
929
928
|
status: l,
|
|
930
929
|
message: (u == null ? void 0 : u.message) || r[e],
|
|
@@ -951,22 +950,22 @@ async function b(e, t, s = {}, n) {
|
|
|
951
950
|
};
|
|
952
951
|
}
|
|
953
952
|
}
|
|
954
|
-
async function
|
|
953
|
+
async function W(e, t = {}, s) {
|
|
955
954
|
return b("DELETE", e, t, s);
|
|
956
955
|
}
|
|
957
|
-
async function
|
|
956
|
+
async function K(e, t = {}) {
|
|
958
957
|
return b("GET", e, t);
|
|
959
958
|
}
|
|
960
|
-
async function
|
|
959
|
+
async function Q(e, t = {}, s) {
|
|
961
960
|
return b("PATCH", e, t, s);
|
|
962
961
|
}
|
|
963
|
-
async function
|
|
962
|
+
async function X(e, t = {}, s) {
|
|
964
963
|
return b("POST", e, t, s);
|
|
965
964
|
}
|
|
966
|
-
async function
|
|
965
|
+
async function ss(e, t = {}, s) {
|
|
967
966
|
return b("PUT", e, t, s);
|
|
968
967
|
}
|
|
969
|
-
class
|
|
968
|
+
class Rs {
|
|
970
969
|
/**
|
|
971
970
|
* Creates an instance of ApiService.
|
|
972
971
|
* @param props - The configuration properties for the API instance.
|
|
@@ -1014,7 +1013,7 @@ class xs {
|
|
|
1014
1013
|
*/
|
|
1015
1014
|
async get(t, s) {
|
|
1016
1015
|
const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token);
|
|
1017
|
-
return this.onDebug(t, "get", [r]), await
|
|
1016
|
+
return this.onDebug(t, "get", [r]), await K(n, r);
|
|
1018
1017
|
}
|
|
1019
1018
|
/**
|
|
1020
1019
|
* Sends a post request to the specified endpoint.
|
|
@@ -1024,7 +1023,7 @@ class xs {
|
|
|
1024
1023
|
*/
|
|
1025
1024
|
async post(t, s) {
|
|
1026
1025
|
const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
|
|
1027
|
-
return this.onDebug(t, "post", [r, a]), await
|
|
1026
|
+
return this.onDebug(t, "post", [r, a]), await X(n, r, a);
|
|
1028
1027
|
}
|
|
1029
1028
|
/**
|
|
1030
1029
|
* Sends a put request to the specified endpoint.
|
|
@@ -1034,7 +1033,7 @@ class xs {
|
|
|
1034
1033
|
*/
|
|
1035
1034
|
async put(t, s) {
|
|
1036
1035
|
const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
|
|
1037
|
-
return this.onDebug(t, "put", [r, a]), await
|
|
1036
|
+
return this.onDebug(t, "put", [r, a]), await ss(n, r, a);
|
|
1038
1037
|
}
|
|
1039
1038
|
/**
|
|
1040
1039
|
* Sends a patch request to the specified endpoint.
|
|
@@ -1044,7 +1043,7 @@ class xs {
|
|
|
1044
1043
|
*/
|
|
1045
1044
|
async patch(t, s) {
|
|
1046
1045
|
const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
|
|
1047
|
-
return this.onDebug(t, "patch", [r, a]), await
|
|
1046
|
+
return this.onDebug(t, "patch", [r, a]), await Q(n, r, a);
|
|
1048
1047
|
}
|
|
1049
1048
|
/**
|
|
1050
1049
|
* Sends a delete request to the specified endpoint.
|
|
@@ -1054,14 +1053,14 @@ class xs {
|
|
|
1054
1053
|
*/
|
|
1055
1054
|
async delete(t, s) {
|
|
1056
1055
|
const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
|
|
1057
|
-
return this.onDebug(t, "delete", [r, a]), await
|
|
1056
|
+
return this.onDebug(t, "delete", [r, a]), await W(n, r, a);
|
|
1058
1057
|
}
|
|
1059
1058
|
}
|
|
1060
|
-
function
|
|
1059
|
+
function Ns(e, t) {
|
|
1061
1060
|
var s, n, r;
|
|
1062
1061
|
return e != null && e.message && typeof (e == null ? void 0 : e.message) == "string" ? e == null ? void 0 : e.message : e != null && e.error && typeof (e == null ? void 0 : e.error) == "string" ? e == null ? void 0 : e.error : (s = e == null ? void 0 : e.error) != null && s.message && typeof ((n = e == null ? void 0 : e.error) == null ? void 0 : n.message) == "string" ? (r = e == null ? void 0 : e.error) == null ? void 0 : r.message : t != null && t.statusText && typeof (t == null ? void 0 : t.statusText) == "string" ? t == null ? void 0 : t.statusText : "Missing error message";
|
|
1063
1062
|
}
|
|
1064
|
-
const
|
|
1063
|
+
const Es = async (e) => {
|
|
1065
1064
|
let t;
|
|
1066
1065
|
const s = await e.arrayBuffer(), n = new TextDecoder().decode(s);
|
|
1067
1066
|
try {
|
|
@@ -1079,44 +1078,44 @@ const Ns = async (e) => {
|
|
|
1079
1078
|
}
|
|
1080
1079
|
return t;
|
|
1081
1080
|
};
|
|
1082
|
-
function
|
|
1081
|
+
function Ss(e) {
|
|
1083
1082
|
switch (!0) {
|
|
1084
1083
|
case e instanceof Response:
|
|
1085
1084
|
return e;
|
|
1085
|
+
case e instanceof z:
|
|
1086
|
+
return e.toResponse();
|
|
1086
1087
|
case e instanceof Y:
|
|
1087
1088
|
return e.toResponse();
|
|
1088
|
-
case e instanceof
|
|
1089
|
+
case e instanceof V:
|
|
1089
1090
|
return e.toResponse();
|
|
1090
1091
|
case e instanceof _:
|
|
1091
1092
|
return e.toResponse();
|
|
1092
1093
|
case e instanceof M:
|
|
1093
1094
|
return e.toResponse();
|
|
1094
|
-
case e instanceof z:
|
|
1095
|
-
return e.toResponse();
|
|
1096
1095
|
}
|
|
1097
1096
|
switch (!0) {
|
|
1098
|
-
case e instanceof
|
|
1097
|
+
case e instanceof B:
|
|
1099
1098
|
return e.toResponse();
|
|
1100
1099
|
case e instanceof T:
|
|
1101
1100
|
return e.toResponse();
|
|
1102
|
-
case e instanceof B:
|
|
1103
|
-
return e.toResponse();
|
|
1104
1101
|
case e instanceof k:
|
|
1105
1102
|
return e.toResponse();
|
|
1106
1103
|
case e instanceof H:
|
|
1107
1104
|
return e.toResponse();
|
|
1108
1105
|
case e instanceof q:
|
|
1109
1106
|
return e.toResponse();
|
|
1107
|
+
case e instanceof F:
|
|
1108
|
+
return e.toResponse();
|
|
1110
1109
|
case e instanceof x:
|
|
1111
1110
|
return e.toResponse();
|
|
1112
|
-
case e instanceof
|
|
1111
|
+
case e instanceof P:
|
|
1113
1112
|
return e.toResponse();
|
|
1114
1113
|
case e instanceof R:
|
|
1115
1114
|
return e.toResponse();
|
|
1116
1115
|
}
|
|
1117
1116
|
return new x("Server error", e).toResponse();
|
|
1118
1117
|
}
|
|
1119
|
-
async function
|
|
1118
|
+
async function es([
|
|
1120
1119
|
e,
|
|
1121
1120
|
t
|
|
1122
1121
|
]) {
|
|
@@ -1136,7 +1135,7 @@ async function ss([
|
|
|
1136
1135
|
data: s.data
|
|
1137
1136
|
};
|
|
1138
1137
|
}
|
|
1139
|
-
function
|
|
1138
|
+
function ts([
|
|
1140
1139
|
e,
|
|
1141
1140
|
t
|
|
1142
1141
|
]) {
|
|
@@ -1156,7 +1155,7 @@ function es([
|
|
|
1156
1155
|
data: s.data
|
|
1157
1156
|
};
|
|
1158
1157
|
}
|
|
1159
|
-
const
|
|
1158
|
+
const Ds = (e, t = "") => {
|
|
1160
1159
|
const s = new URL(e.url);
|
|
1161
1160
|
if (t === "") return s.searchParams;
|
|
1162
1161
|
const n = Array.from(
|
|
@@ -1164,14 +1163,14 @@ const Ss = (e, t = "") => {
|
|
|
1164
1163
|
).filter(([r]) => r.startsWith(`${t}:`)).map(([r, a]) => [r.replace(`${t}:`, ""), a]);
|
|
1165
1164
|
return new URLSearchParams(n);
|
|
1166
1165
|
};
|
|
1167
|
-
function
|
|
1166
|
+
function ns(e) {
|
|
1168
1167
|
const t = "Error validating:", s = e.issues.map(
|
|
1169
1168
|
({ path: n, message: r }) => `-> ${n.join(".")}: ${r}`
|
|
1170
1169
|
);
|
|
1171
1170
|
return [t, ...s].join(`
|
|
1172
1171
|
`);
|
|
1173
1172
|
}
|
|
1174
|
-
class
|
|
1173
|
+
class $s {
|
|
1175
1174
|
/**
|
|
1176
1175
|
* Creates a new SchemaValidator instance.
|
|
1177
1176
|
*
|
|
@@ -1248,7 +1247,7 @@ class Ds {
|
|
|
1248
1247
|
try {
|
|
1249
1248
|
return this.schema.parse(t);
|
|
1250
1249
|
} catch (s) {
|
|
1251
|
-
throw new x(
|
|
1250
|
+
throw new x(ns(s));
|
|
1252
1251
|
}
|
|
1253
1252
|
}
|
|
1254
1253
|
/**
|
|
@@ -1277,7 +1276,7 @@ class Ds {
|
|
|
1277
1276
|
* ```
|
|
1278
1277
|
*/
|
|
1279
1278
|
formValidate(t, s) {
|
|
1280
|
-
const n =
|
|
1279
|
+
const n = ts([t, this.schema]);
|
|
1281
1280
|
if (!n.success) {
|
|
1282
1281
|
const r = Object.keys(n.fieldErrors)[0];
|
|
1283
1282
|
throw new R({
|
|
@@ -1315,7 +1314,7 @@ class Ds {
|
|
|
1315
1314
|
* ```
|
|
1316
1315
|
*/
|
|
1317
1316
|
async formAsyncValidate(t, s) {
|
|
1318
|
-
const n = await
|
|
1317
|
+
const n = await es([t, this.schema]);
|
|
1319
1318
|
if (!n.success) {
|
|
1320
1319
|
const r = Object.keys(n.fieldErrors)[0];
|
|
1321
1320
|
throw new R({
|
|
@@ -1328,15 +1327,15 @@ class Ds {
|
|
|
1328
1327
|
return n.data;
|
|
1329
1328
|
}
|
|
1330
1329
|
}
|
|
1331
|
-
const
|
|
1330
|
+
const Os = (e) => {
|
|
1332
1331
|
if (!e || !/^[0-9-]+$/.test(e)) return !1;
|
|
1333
1332
|
const s = N(e), n = 8, r = /^\d{8}$/.test(s);
|
|
1334
1333
|
return s.length === n && r;
|
|
1335
1334
|
};
|
|
1336
|
-
function
|
|
1335
|
+
function rs(e) {
|
|
1337
1336
|
return e.length !== 14;
|
|
1338
1337
|
}
|
|
1339
|
-
function
|
|
1338
|
+
function os(e) {
|
|
1340
1339
|
const [t] = e;
|
|
1341
1340
|
return [...e].every((s) => s === t);
|
|
1342
1341
|
}
|
|
@@ -1347,23 +1346,23 @@ function $(e, t) {
|
|
|
1347
1346
|
const n = s % 11;
|
|
1348
1347
|
return n < 2 ? 0 : 11 - n;
|
|
1349
1348
|
}
|
|
1350
|
-
function
|
|
1349
|
+
function as(e) {
|
|
1351
1350
|
return e.slice(12);
|
|
1352
1351
|
}
|
|
1353
|
-
const
|
|
1352
|
+
const Is = (e) => {
|
|
1354
1353
|
if (!e) return !1;
|
|
1355
1354
|
const t = N(e);
|
|
1356
|
-
if (
|
|
1355
|
+
if (rs(t) || os(t)) return !1;
|
|
1357
1356
|
const s = t.slice(0, 12), n = $(s, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), r = $(
|
|
1358
1357
|
s + n,
|
|
1359
1358
|
[6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
1360
1359
|
);
|
|
1361
|
-
return
|
|
1360
|
+
return as(t) === `${n}${r}`;
|
|
1362
1361
|
};
|
|
1363
|
-
function
|
|
1362
|
+
function us(e) {
|
|
1364
1363
|
return e.length !== 11;
|
|
1365
1364
|
}
|
|
1366
|
-
function
|
|
1365
|
+
function is(e) {
|
|
1367
1366
|
const [t] = e;
|
|
1368
1367
|
return [...e].every((s) => s === t);
|
|
1369
1368
|
}
|
|
@@ -1374,16 +1373,16 @@ function O(e, t) {
|
|
|
1374
1373
|
const n = s % 11;
|
|
1375
1374
|
return n < 2 ? 0 : 11 - n;
|
|
1376
1375
|
}
|
|
1377
|
-
function
|
|
1376
|
+
function cs(e) {
|
|
1378
1377
|
return e.slice(9);
|
|
1379
1378
|
}
|
|
1380
|
-
const
|
|
1379
|
+
const Cs = (e) => {
|
|
1381
1380
|
if (!e) return !1;
|
|
1382
1381
|
const t = N(e);
|
|
1383
|
-
if (
|
|
1382
|
+
if (us(t) || is(t)) return !1;
|
|
1384
1383
|
const s = O(t, 10), n = O(t, 11);
|
|
1385
|
-
return
|
|
1386
|
-
},
|
|
1384
|
+
return cs(t) === `${s}${n}`;
|
|
1385
|
+
}, js = (e, t) => {
|
|
1387
1386
|
let s, n, r;
|
|
1388
1387
|
const a = (t == null ? void 0 : t.inputFormat) || "DD/MM/YYYY", c = (t == null ? void 0 : t.minYear) || 1900, h = (t == null ? void 0 : t.maxYear) || 3e3;
|
|
1389
1388
|
if (a === "DD/MM/YYYY") {
|
|
@@ -1410,39 +1409,39 @@ const Is = (e) => {
|
|
|
1410
1409
|
return !1;
|
|
1411
1410
|
return u < c || u > h ? !1 : new Date(u, l - 1, i).getDate() === i;
|
|
1412
1411
|
};
|
|
1413
|
-
function
|
|
1412
|
+
function hs(e) {
|
|
1414
1413
|
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);
|
|
1415
1414
|
}
|
|
1416
|
-
function
|
|
1415
|
+
function ls(e) {
|
|
1417
1416
|
return !(e.length === 0 || e.length > 64 || e.startsWith(".") || e.endsWith(".") || e.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e));
|
|
1418
1417
|
}
|
|
1419
|
-
function
|
|
1418
|
+
function fs(e) {
|
|
1420
1419
|
return !(e.length === 0 || e.length > 63 || e.startsWith("-") || e.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(e));
|
|
1421
1420
|
}
|
|
1422
|
-
function
|
|
1421
|
+
function ds(e) {
|
|
1423
1422
|
if (e.length === 0 || e.length > 253 || e.startsWith(".") || e.endsWith(".") || e.startsWith("-") || e.endsWith("-"))
|
|
1424
1423
|
return !1;
|
|
1425
1424
|
const t = e.split(".");
|
|
1426
1425
|
if (t.length < 2) return !1;
|
|
1427
|
-
for (const n of t) if (!
|
|
1426
|
+
for (const n of t) if (!fs(n)) return !1;
|
|
1428
1427
|
const s = t[t.length - 1];
|
|
1429
1428
|
return !(s.length < 2 || !/^[a-zA-Z]+$/.test(s));
|
|
1430
1429
|
}
|
|
1431
|
-
function
|
|
1430
|
+
function ps(e) {
|
|
1432
1431
|
const t = e.split("@");
|
|
1433
1432
|
if (t.length !== 2) return !1;
|
|
1434
1433
|
const [s, n] = t;
|
|
1435
|
-
return !(!
|
|
1434
|
+
return !(!ls(s) || !ds(n));
|
|
1436
1435
|
}
|
|
1437
|
-
function
|
|
1436
|
+
function ys(e) {
|
|
1438
1437
|
const t = e.split("@");
|
|
1439
1438
|
return t.length === 2 ? t[1].toLowerCase() : null;
|
|
1440
1439
|
}
|
|
1441
|
-
const
|
|
1440
|
+
const Js = async (e) => {
|
|
1442
1441
|
if (!e || typeof e != "string") return !1;
|
|
1443
1442
|
const t = e.trim();
|
|
1444
|
-
return !(!
|
|
1445
|
-
},
|
|
1443
|
+
return !(!hs(t) || !ps(t) || !ys(t));
|
|
1444
|
+
}, ws = (e) => {
|
|
1446
1445
|
if (!e) return !1;
|
|
1447
1446
|
const t = e.length >= 8, s = /[A-Z]/.test(e), n = /[a-z]/.test(e), r = /\d/.test(e), a = /[!@#$%^&*(),.?":{}|<>_\-+=~`[\]\\\/]/.test(
|
|
1448
1447
|
e
|
|
@@ -1454,8 +1453,8 @@ const js = async (e) => {
|
|
|
1454
1453
|
r,
|
|
1455
1454
|
a
|
|
1456
1455
|
].every((c) => c);
|
|
1457
|
-
},
|
|
1458
|
-
for (const t of
|
|
1456
|
+
}, Us = (e) => {
|
|
1457
|
+
for (const t of A) {
|
|
1459
1458
|
const s = t.code, n = t.prefix ? `-${t.prefix}` : "", r = t.mask.replace(/[^_]/g, "").length;
|
|
1460
1459
|
if (t.iso === "BR") {
|
|
1461
1460
|
if (new RegExp(`^\\${s} \\d{2}9?\\d{8}$`).test(e)) return !0;
|
|
@@ -1464,44 +1463,44 @@ const js = async (e) => {
|
|
|
1464
1463
|
if (new RegExp(`^\\${s}${n} \\d{${r}}$`).test(e)) return !0;
|
|
1465
1464
|
}
|
|
1466
1465
|
return !1;
|
|
1467
|
-
},
|
|
1466
|
+
}, vs = (e) => {
|
|
1468
1467
|
if (!e || !/^[0-9a-zA-Z.-]+$/.test(e)) return !1;
|
|
1469
1468
|
const s = e.replace(/[^a-zA-Z0-9]/g, "");
|
|
1470
1469
|
return s.length < 7 || s.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(s);
|
|
1471
1470
|
};
|
|
1472
1471
|
export {
|
|
1473
|
-
|
|
1472
|
+
Rs as ApiService,
|
|
1474
1473
|
C as ArkynLogService,
|
|
1475
|
-
|
|
1474
|
+
B as BadGateway,
|
|
1476
1475
|
T as BadRequest,
|
|
1477
|
-
|
|
1478
|
-
|
|
1476
|
+
k as Conflict,
|
|
1477
|
+
Y as Created,
|
|
1479
1478
|
I as DebugService,
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1479
|
+
H as Forbidden,
|
|
1480
|
+
z as Found,
|
|
1481
|
+
M as NoContent,
|
|
1482
|
+
q as NotFound,
|
|
1483
|
+
F as NotImplemented,
|
|
1484
|
+
$s as SchemaValidator,
|
|
1486
1485
|
x as ServerError,
|
|
1487
|
-
|
|
1488
|
-
|
|
1486
|
+
_ as Success,
|
|
1487
|
+
P as Unauthorized,
|
|
1489
1488
|
R as UnprocessableEntity,
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1489
|
+
V as Updated,
|
|
1490
|
+
Ns as decodeErrorMessageFromRequest,
|
|
1491
|
+
Es as decodeRequestBody,
|
|
1492
|
+
Ss as errorHandler,
|
|
1494
1493
|
g as flushDebugLogs,
|
|
1495
|
-
|
|
1496
|
-
|
|
1494
|
+
es as formAsyncParse,
|
|
1495
|
+
ts as formParse,
|
|
1497
1496
|
E as getCaller,
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1497
|
+
Ds as getScopedParams,
|
|
1498
|
+
Os as validateCep,
|
|
1499
|
+
Is as validateCnpj,
|
|
1500
|
+
Cs as validateCpf,
|
|
1501
|
+
js as validateDate,
|
|
1502
|
+
Js as validateEmail,
|
|
1503
|
+
ws as validatePassword,
|
|
1504
|
+
Us as validatePhone,
|
|
1505
|
+
vs as validateRg
|
|
1507
1506
|
};
|
package/dist/bundle.umd.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(u,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("zod"),require("@arkyn/shared"),require("node:dns"),require("@arkyn/templates")):typeof define=="function"&&define.amd?define(["exports","zod","@arkyn/shared","node:dns","@arkyn/templates"],d):(u=typeof globalThis<"u"?globalThis:u||self,d(u["@arkyn/server"]={},null,u.shared,null,u.templates))})(this,function(u,d,m,
|
|
1
|
+
(function(u,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("zod"),require("@arkyn/shared"),require("node:dns"),require("@arkyn/templates")):typeof define=="function"&&define.amd?define(["exports","zod","@arkyn/shared","node:dns","@arkyn/templates"],d):(u=typeof globalThis<"u"?globalThis:u||self,d(u["@arkyn/server"]={},null,u.shared,null,u.templates))})(this,function(u,d,m,Us,Y){"use strict";var Is=Object.defineProperty;var js=(u,d,m)=>d in u?Is(u,d,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[d]=m;var o=(u,d,m)=>js(u,typeof d!="symbol"?d+"":d,m);function T(e){var s;if(process.env.NODE_ENV==="development"||((s=process.env)==null?void 0:s.SHOW_ERRORS_IN_CONSOLE)==="true"){const a=`${{yellow:"\x1B[33m",cyan:"\x1B[36m",red:"\x1B[31m",green:"\x1B[32m"}[e.scheme]}[${e.name}]\x1B[0m`;let h=`
|
|
2
2
|
`;e.debugs.forEach(l=>{h+=`${a} ${l.trim()}
|
|
3
3
|
`}),console.log(h)}}const _={};class v{static setIgnoreFile(t){this.ignoreFiles.push(t)}static clearIgnoreFiles(){this.ignoreFiles=[]}}o(v,"ignoreFiles",[]);function N(){const e=process.cwd(),n=(new Error().stack||"").split(`
|
|
4
|
-
`).map(i=>i.trim()),r=v.ignoreFiles;let a=2;for(;a<n.length&&(n[a].includes("node:internal")||n[a].includes("/node_modules/"));)a++;if(r.length>0)for(;a<n.length&&r.some(i=>n[a].includes(i));)a++;const h=n[a]||"";let l="Unknown function",c="Unknown caller";const f=h.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);if(f)l=f[1],c=f[2];else{const i=h.match(/at\s+(.+)/);if(i){c=i[1];const
|
|
4
|
+
`).map(i=>i.trim()),r=v.ignoreFiles;let a=2;for(;a<n.length&&(n[a].includes("node:internal")||n[a].includes("/node_modules/"));)a++;if(r.length>0)for(;a<n.length&&r.some(i=>n[a].includes(i));)a++;const h=n[a]||"";let l="Unknown function",c="Unknown caller";const f=h.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);if(f)l=f[1],c=f[2];else{const i=h.match(/at\s+(.+)/);if(i){c=i[1];const p=c.match(/at\s+([^(\s]+)\s+/);p&&p[1]!=="new"&&(l=p[1])}}c.includes("(")&&(c=c.substring(c.indexOf("(")+1,c.lastIndexOf(")"))),c=c.split(":").slice(0,-2).join(":");try{c=_.relative(e,c)}catch{}return{functionName:l,callerInfo:c}}class g{onDebug(t){const{name:s,body:n,cause:r,message:a}=t,h=[],{callerInfo:l,functionName:c}=N();h.push(`${s} initialized`),h.push(`Caller Function: ${c}`),h.push(`Caller Location: ${l}`),a&&h.push(`Message: ${a}`),n&&h.push(`Body: ${JSON.stringify(n,null,2)}`),r&&h.push(`Cause: ${JSON.stringify(r,null,2)}`),T({scheme:"red",name:"ARKYN-BAD-RESPONSE-DEBUG",debugs:h})}}class C extends g{constructor(s,n){super();o(this,"body");o(this,"cause");o(this,"status",502);o(this,"statusText");this.body={name:"BadGateway",message:s},this.statusText=s,this.cause=n?JSON.stringify(n):void 0,this.onDebug({name:"BadGateway",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class S extends g{constructor(s,n){super();o(this,"body");o(this,"cause");o(this,"status",400);o(this,"statusText");this.body={name:"BadRequest",message:s},this.statusText=s,this.cause=n?JSON.stringify(n):void 0,this.onDebug({name:"BadRequest",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class O extends g{constructor(s,n){super();o(this,"body");o(this,"cause");o(this,"status",409);o(this,"statusText");this.body={name:"Conflict",message:s},this.statusText=s,this.cause=n?JSON.stringify(n):void 0,this.onDebug({name:"Conflict",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class I extends g{constructor(s,n){super();o(this,"body");o(this,"cause");o(this,"status",403);o(this,"statusText");this.body={name:"Forbidden",message:s},this.statusText=s,this.cause=n?JSON.stringify(n):void 0,this.onDebug({name:"Forbidden",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class j extends g{constructor(s,n){super();o(this,"body");o(this,"cause");o(this,"status",404);o(this,"statusText");this.body={name:"NotFound",message:s},this.statusText=s,this.cause=n?JSON.stringify(n):void 0,this.onDebug({name:"NotFound",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class U extends g{constructor(s,n){super();o(this,"body");o(this,"cause");o(this,"status",501);o(this,"statusText");this.body={name:"NotImplemented",message:s},this.statusText=s,this.cause=n?JSON.stringify(n):void 0,this.onDebug({name:"NotImplemented",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class E extends g{constructor(s,n){super();o(this,"body");o(this,"cause");o(this,"status",500);o(this,"statusText");this.body={name:"ServerError",message:s},this.statusText=s,this.cause=n?JSON.stringify(n):void 0,this.onDebug({name:"ServerError",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class w extends g{constructor(s,n){super();o(this,"body");o(this,"cause");o(this,"status",401);o(this,"statusText");this.body={name:"Unauthorized",message:s},this.statusText=s,this.cause=n?JSON.stringify(n):void 0,this.onDebug({name:"Unauthorized",body:this.body,cause:this.cause,message:this.statusText})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class D extends g{constructor(s){super();o(this,"body");o(this,"status",422);o(this,"statusText");this.statusText=s.message||"Unprocessable Entity",this.body={name:"UnprocessableEntity",message:s.message||null,data:s.data,fieldErrors:s.fieldErrors,fields:s.fields},this.onDebug({name:"UnprocessableEntity",cause:s.fieldErrors,message:s.message})}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class R{onDebug(t,s,n){const r=[],{callerInfo:a,functionName:h}=N();r.push(`${t} initialized
|
|
5
5
|
`),r.push(`Caller Function: ${h}
|
|
6
6
|
`),r.push(`Caller Location: ${a}
|
|
7
7
|
`),r.push(`Body: ${JSON.stringify(s,null,2)}
|
|
8
8
|
`),n&&r.push(`Cause: ${JSON.stringify(n,null,2)}
|
|
9
|
-
`),b({scheme:"green",name:"ARKYN-SUCCESS-RESPONSE-DEBUG",debugs:r})}}class J extends R{constructor(s,n){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class A extends R{constructor(s,n){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class k extends R{constructor(s){super();o(this,"headers");o(this,"status");o(this,"statusText");this.headers=(s==null?void 0:s.headers)||{},this.status=(s==null?void 0:s.status)||204,this.statusText=(s==null?void 0:s.statusText)??"No content",this.onDebug("No content",null)}toResponse(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return new Response(null,s)}}class L extends R{constructor(s,n){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class q extends R{constructor(s,n){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class V{static mapHeaders(t){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),{}):{}}static mapQueryParams(t){const s={};return t.forEach((n,r)=>{s[r]=n}),s}static handle(t){return{rawUrl:t.url,status:t.status,method:t.method,token:null,elapsedTime:t.elapsedTime,requestHeaders:this.mapHeaders(t.requestHeaders),requestBody:t.requestBody||null,queryParams:this.mapQueryParams(t.queryParams),responseHeaders:this.mapHeaders(t.responseHeaders),responseBody:t.responseBody||null}}}class O{static setArkynConfig(t){if(this.arkynConfig)return;const{trafficSourceId:s,userToken:n,logBaseApiUrl:r}=t;this.arkynConfig={trafficSourceId:s,userToken:n,apiUrl:r||"http://95.216.190.158:8081/ingest-log"}}static getArkynConfig(){return this.arkynConfig}static resetArkynConfig(){this.arkynConfig=void 0}}o(O,"arkynConfig");async function G(e){const t=O.getArkynConfig();if(!t)return;const{userToken:s,apiUrl:n,trafficSourceId:r}=t,{elapsedTime:a,method:h,queryParams:l,requestBody:c,requestHeaders:f,responseBody:i,responseHeaders:g,status:z,token:y,rawUrl:Os}=e;if(process.env.NODE_ENV!=="development")try{const T=new URL(Os);let M="HTTPS";T.protocol==="http:"&&(M="HTTP");const $s=JSON.stringify({domainUrl:T.protocol+"//"+T.host,pathnameUrl:T.pathname,trafficSourceId:r,status:z,protocol:M,method:h,trafficUserId:null,elapsedTime:a,requestHeaders:f,requestBody:c,queryParams:l,responseHeaders:g,responseBody:i});await fetch(n,{method:"POST",body:$s,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(T){b({debugs:[`Error sending request: ${T}`],name:"ARKYN_LOG_ERROR",scheme:"red"})}}async function x(e,t,s={},n){const r={POST:"Resource created successfully",PUT:"Resource updated successfully",DELETE:"Resource deleted successfully",PATCH:"Resource patched successfully",GET:"Request successful"};try{const a=performance.now(),h={...s,"Content-Type":"application/json"},l=await fetch(t,{method:e,headers:h,body:n?JSON.stringify(n):void 0}),c=performance.now()-a,f=l.status;let i=null;try{i=await l.json()}catch{i=null}const g=V.handle({elapsedTime:c,method:e,queryParams:new URL(t).searchParams,requestHeaders:h,requestBody:n,responseBody:i,responseHeaders:l.headers,status:f,url:t});return G(g),l.ok?{success:!0,status:f,message:(i==null?void 0:i.message)||r[e],response:i,cause:null}:{success:!1,status:f,message:(i==null?void 0:i.message)||l.statusText||"Request failed",response:i,cause:null}}catch(a){return b({debugs:[`Network error or request failed: ${a}`],name:"ARKYN_MAKE_REQUEST_ERROR",scheme:"red"}),{success:!1,status:0,message:"Network error or request failed",response:null,cause:a instanceof Error?a.message:String(a)}}}async function Z(e,t={},s){return x("DELETE",e,t,s)}async function W(e,t={}){return x("GET",e,t)}async function K(e,t={},s){return x("PATCH",e,t,s)}async function Q(e,t={},s){return x("POST",e,t,s)}async function X(e,t={},s){return x("PUT",e,t,s)}class ss{constructor(t){o(this,"baseUrl");o(this,"baseHeaders");o(this,"baseToken");o(this,"enableDebug");this.baseUrl=t.baseUrl,this.baseHeaders=t.baseHeaders||void 0,this.baseToken=t.baseToken||void 0,this.enableDebug=t.enableDebug||!1}onDebug(t,s,n){if(this.enableDebug){const r=[];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])}`),b({debugs:r,name:"ARKYN-API-DEBUG",scheme:"yellow"})}}generateURL(t){return this.baseUrl+t}generateHeaders(t,s){let n={};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}async get(t,s){const n=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token);return this.onDebug(t,"get",[r]),await W(n,r)}async post(t,s){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;return this.onDebug(t,"post",[r,a]),await Q(n,r,a)}async put(t,s){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;return this.onDebug(t,"put",[r,a]),await X(n,r,a)}async patch(t,s){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;return this.onDebug(t,"patch",[r,a]),await K(n,r,a)}async delete(t,s){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;return this.onDebug(t,"delete",[r,a]),await Z(n,r,a)}}function es(e,t){var s,n,r;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"}const ts=async e=>{let t;const s=await e.arrayBuffer(),n=new TextDecoder().decode(s);try{t=JSON.parse(n)}catch{try{if(n.includes("=")){const a=new URLSearchParams(n);t=Object.fromEntries(a.entries())}else throw new E("Invalid URLSearchParams format")}catch{throw new E("Failed to extract data from request")}}return t};function ns(e){switch(!0){case e instanceof Response:return e;case e instanceof A:return e.toResponse();case e instanceof J:return e.toResponse();case e instanceof q:return e.toResponse();case e instanceof L:return e.toResponse();case e instanceof k:return e.toResponse()}switch(!0){case e instanceof $:return e.toResponse();case e instanceof E:return e.toResponse();case e instanceof C:return e.toResponse();case e instanceof I:return e.toResponse();case e instanceof j:return e.toResponse();case e instanceof U:return e.toResponse();case e instanceof S:return e.toResponse();case e instanceof w:return e.toResponse();case e instanceof D:return e.toResponse()}return new S("Server error",e).toResponse()}async function B([e,t]){const s=await t.safeParseAsync(e);if(s.success===!1){const n=Object.fromEntries(s.error.issues.map(r=>[r.path.join("."),r.message]));return{success:s.success,fieldErrors:n,fields:e}}else return{success:s.success,data:s.data}}function F([e,t]){const s=t.safeParse(e);if(s.success===!1){const n=Object.fromEntries(s.error.issues.map(r=>[r.path.join("."),r.message]));return{success:s.success,fieldErrors:n,fields:e}}else return{success:s.success,data:s.data}}const rs=(e,t="")=>{const s=new URL(e.url);if(t==="")return s.searchParams;const n=Array.from(s.searchParams.entries()).filter(([r])=>r.startsWith(`${t}:`)).map(([r,a])=>[r.replace(`${t}:`,""),a]);return new URLSearchParams(n)};function os(e){const t="Error validating:",s=e.issues.map(({path:n,message:r})=>`-> ${n.join(".")}: ${r}`);return[t,...s].join(`
|
|
10
|
-
`)}class as{constructor(t){o(this,"functionName");o(this,"callerInfo");this.schema=t;const{callerInfo:s,functionName:n}=N();this.callerInfo=s,this.functionName=n}isValid(t){return this.schema.safeParse(t).success}safeValidate(t){return this.schema.safeParse(t)}validate(t){try{return this.schema.parse(t)}catch(s){throw new
|
|
9
|
+
`),T({scheme:"green",name:"ARKYN-SUCCESS-RESPONSE-DEBUG",debugs:r})}}class J extends R{constructor(s,n){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class A extends R{constructor(s,n){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class k extends R{constructor(s){super();o(this,"headers");o(this,"status");o(this,"statusText");this.headers=(s==null?void 0:s.headers)||{},this.status=(s==null?void 0:s.status)||204,this.statusText=(s==null?void 0:s.statusText)??"No content",this.onDebug("No content",null)}toResponse(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return new Response(null,s)}}class L extends R{constructor(s,n){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class q extends R{constructor(s,n){super();o(this,"body");o(this,"headers");o(this,"status");o(this,"statusText");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)}toResponse(){const s={headers:{"Content-Type":"application/json",...this.headers},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={headers:this.headers,status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class V{static mapHeaders(t){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),{}):{}}static mapQueryParams(t){const s={};return t.forEach((n,r)=>{s[r]=n}),s}static handle(t){return{rawUrl:t.url,status:t.status,method:t.method,token:null,elapsedTime:t.elapsedTime,requestHeaders:this.mapHeaders(t.requestHeaders),requestBody:t.requestBody||null,queryParams:this.mapQueryParams(t.queryParams),responseHeaders:this.mapHeaders(t.responseHeaders),responseBody:t.responseBody||null}}}class ${static setArkynConfig(t){if(this.arkynConfig)return;const{trafficSourceId:s,userToken:n,logBaseApiUrl:r}=t;this.arkynConfig={trafficSourceId:s,userToken:n,apiUrl:r||"http://95.216.190.158:8081/ingest-log"}}static getArkynConfig(){return this.arkynConfig}static resetArkynConfig(){this.arkynConfig=void 0}}o($,"arkynConfig");async function G(e){const t=$.getArkynConfig();if(!t)return;const{userToken:s,apiUrl:n,trafficSourceId:r}=t,{elapsedTime:a,method:h,queryParams:l,requestBody:c,requestHeaders:f,responseBody:i,responseHeaders:p,status:z,token:y,rawUrl:$s}=e;try{const b=new URL($s);let M="HTTPS";b.protocol==="http:"&&(M="HTTP");const Cs=JSON.stringify({domainUrl:b.protocol+"//"+b.host,pathnameUrl:b.pathname,trafficSourceId:r,status:z,protocol:M,method:h,trafficUserId:null,elapsedTime:a,requestHeaders:f,requestBody:c,queryParams:l,responseHeaders:p,responseBody:i}),Os=await fetch(n,{method:"POST",body:Cs,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}});console.log(Os)}catch(b){console.log(b),T({debugs:[`Error sending request: ${b}`],name:"ARKYN_LOG_ERROR",scheme:"red"})}}async function x(e,t,s={},n){const r={POST:"Resource created successfully",PUT:"Resource updated successfully",DELETE:"Resource deleted successfully",PATCH:"Resource patched successfully",GET:"Request successful"};try{const a=performance.now(),h={...s,"Content-Type":"application/json"},l=await fetch(t,{method:e,headers:h,body:n?JSON.stringify(n):void 0}),c=performance.now()-a,f=l.status;let i=null;try{i=await l.json()}catch{i=null}const p=V.handle({elapsedTime:c,method:e,queryParams:new URL(t).searchParams,requestHeaders:h,requestBody:n,responseBody:i,responseHeaders:l.headers,status:f,url:t});return G(p),l.ok?{success:!0,status:f,message:(i==null?void 0:i.message)||r[e],response:i,cause:null}:{success:!1,status:f,message:(i==null?void 0:i.message)||l.statusText||"Request failed",response:i,cause:null}}catch(a){return T({debugs:[`Network error or request failed: ${a}`],name:"ARKYN_MAKE_REQUEST_ERROR",scheme:"red"}),{success:!1,status:0,message:"Network error or request failed",response:null,cause:a instanceof Error?a.message:String(a)}}}async function Z(e,t={},s){return x("DELETE",e,t,s)}async function W(e,t={}){return x("GET",e,t)}async function K(e,t={},s){return x("PATCH",e,t,s)}async function Q(e,t={},s){return x("POST",e,t,s)}async function X(e,t={},s){return x("PUT",e,t,s)}class ss{constructor(t){o(this,"baseUrl");o(this,"baseHeaders");o(this,"baseToken");o(this,"enableDebug");this.baseUrl=t.baseUrl,this.baseHeaders=t.baseHeaders||void 0,this.baseToken=t.baseToken||void 0,this.enableDebug=t.enableDebug||!1}onDebug(t,s,n){if(this.enableDebug){const r=[];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])}`),T({debugs:r,name:"ARKYN-API-DEBUG",scheme:"yellow"})}}generateURL(t){return this.baseUrl+t}generateHeaders(t,s){let n={};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}async get(t,s){const n=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token);return this.onDebug(t,"get",[r]),await W(n,r)}async post(t,s){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;return this.onDebug(t,"post",[r,a]),await Q(n,r,a)}async put(t,s){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;return this.onDebug(t,"put",[r,a]),await X(n,r,a)}async patch(t,s){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;return this.onDebug(t,"patch",[r,a]),await K(n,r,a)}async delete(t,s){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;return this.onDebug(t,"delete",[r,a]),await Z(n,r,a)}}function es(e,t){var s,n,r;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"}const ts=async e=>{let t;const s=await e.arrayBuffer(),n=new TextDecoder().decode(s);try{t=JSON.parse(n)}catch{try{if(n.includes("=")){const a=new URLSearchParams(n);t=Object.fromEntries(a.entries())}else throw new S("Invalid URLSearchParams format")}catch{throw new S("Failed to extract data from request")}}return t};function ns(e){switch(!0){case e instanceof Response:return e;case e instanceof A:return e.toResponse();case e instanceof J:return e.toResponse();case e instanceof q:return e.toResponse();case e instanceof L:return e.toResponse();case e instanceof k:return e.toResponse()}switch(!0){case e instanceof C:return e.toResponse();case e instanceof S:return e.toResponse();case e instanceof O:return e.toResponse();case e instanceof I:return e.toResponse();case e instanceof j:return e.toResponse();case e instanceof U:return e.toResponse();case e instanceof E:return e.toResponse();case e instanceof w:return e.toResponse();case e instanceof D:return e.toResponse()}return new E("Server error",e).toResponse()}async function B([e,t]){const s=await t.safeParseAsync(e);if(s.success===!1){const n=Object.fromEntries(s.error.issues.map(r=>[r.path.join("."),r.message]));return{success:s.success,fieldErrors:n,fields:e}}else return{success:s.success,data:s.data}}function F([e,t]){const s=t.safeParse(e);if(s.success===!1){const n=Object.fromEntries(s.error.issues.map(r=>[r.path.join("."),r.message]));return{success:s.success,fieldErrors:n,fields:e}}else return{success:s.success,data:s.data}}const rs=(e,t="")=>{const s=new URL(e.url);if(t==="")return s.searchParams;const n=Array.from(s.searchParams.entries()).filter(([r])=>r.startsWith(`${t}:`)).map(([r,a])=>[r.replace(`${t}:`,""),a]);return new URLSearchParams(n)};function os(e){const t="Error validating:",s=e.issues.map(({path:n,message:r})=>`-> ${n.join(".")}: ${r}`);return[t,...s].join(`
|
|
10
|
+
`)}class as{constructor(t){o(this,"functionName");o(this,"callerInfo");this.schema=t;const{callerInfo:s,functionName:n}=N();this.callerInfo=s,this.functionName=n}isValid(t){return this.schema.safeParse(t).success}safeValidate(t){return this.schema.safeParse(t)}validate(t){try{return this.schema.parse(t)}catch(s){throw new E(os(s))}}formValidate(t,s){const n=F([t,this.schema]);if(!n.success){const r=Object.keys(n.fieldErrors)[0];throw new D({fields:n.fields,fieldErrors:n.fieldErrors,data:{scrollTo:r},message:s})}return n.data}async formAsyncValidate(t,s){const n=await B([t,this.schema]);if(!n.success){const r=Object.keys(n.fieldErrors)[0];throw new D({fields:n.fields,fieldErrors:n.fieldErrors,data:{scrollTo:r},message:s})}return n.data}}const us=e=>{if(!e||!/^[0-9-]+$/.test(e))return!1;const s=m.removeNonNumeric(e),n=8,r=/^\d{8}$/.test(s);return s.length===n&&r};function is(e){return e.length!==14}function cs(e){const[t]=e;return[...e].every(s=>s===t)}function H(e,t){let s=0;for(let r=0;r<t.length;r++)s+=parseInt(e[r])*t[r];const n=s%11;return n<2?0:11-n}function hs(e){return e.slice(12)}const ls=e=>{if(!e)return!1;const t=m.removeNonNumeric(e);if(is(t)||cs(t))return!1;const s=t.slice(0,12),n=H(s,[5,4,3,2,9,8,7,6,5,4,3,2]),r=H(s+n,[6,5,4,3,2,9,8,7,6,5,4,3,2]);return hs(t)===`${n}${r}`};function fs(e){return e.length!==11}function ds(e){const[t]=e;return[...e].every(s=>s===t)}function P(e,t){let s=0;for(const r of e)t>1&&(s+=parseInt(r)*t--);const n=s%11;return n<2?0:11-n}function ys(e){return e.slice(9)}const gs=e=>{if(!e)return!1;const t=m.removeNonNumeric(e);if(fs(t)||ds(t))return!1;const s=P(t,10),n=P(t,11);return ys(t)===`${s}${n}`},ps=(e,t)=>{let s,n,r;const a=(t==null?void 0:t.inputFormat)||"DD/MM/YYYY",h=(t==null?void 0:t.minYear)||1900,l=(t==null?void 0:t.maxYear)||3e3;if(a==="DD/MM/YYYY"){const y=/^(\d{2})\/(\d{2})\/(\d{4})$/;if(!y.test(e))return!1;[,s,n,r]=e.match(y)||[]}else if(a==="MM-DD-YYYY"){const y=/^(\d{2})-(\d{2})-(\d{4})$/;if(!y.test(e))return!1;[,n,s,r]=e.match(y)||[]}else if(a==="YYYY-MM-DD"){const y=/^(\d{4})-(\d{2})-(\d{2})$/;if(!y.test(e))return!1;[,r,n,s]=e.match(y)||[]}else throw new Error("Invalid date format");const c=parseInt(s,10),f=parseInt(n,10),i=parseInt(r,10);if(c<1||c>31||f<1||f>12)return!1;const p=[31,28,31,30,31,30,31,31,30,31,30,31];if(f===2){const y=i%4===0&&i%100!==0||i%400===0;if(c>(y?29:28))return!1}else if(c>p[f-1])return!1;return i<h||i>l?!1:new Date(i,f-1,c).getDate()===c};function ms(e){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)}function bs(e){return!(e.length===0||e.length>64||e.startsWith(".")||e.endsWith(".")||e.includes("..")||!/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e))}function Ts(e){return!(e.length===0||e.length>63||e.startsWith("-")||e.endsWith("-")||!/^[a-zA-Z0-9-]+$/.test(e))}function Rs(e){if(e.length===0||e.length>253||e.startsWith(".")||e.endsWith(".")||e.startsWith("-")||e.endsWith("-"))return!1;const t=e.split(".");if(t.length<2)return!1;for(const n of t)if(!Ts(n))return!1;const s=t[t.length-1];return!(s.length<2||!/^[a-zA-Z]+$/.test(s))}function xs(e){const t=e.split("@");if(t.length!==2)return!1;const[s,n]=t;return!(!bs(s)||!Rs(n))}function Ns(e){const t=e.split("@");return t.length===2?t[1].toLowerCase():null}const Ss=async e=>{if(!e||typeof e!="string")return!1;const t=e.trim();return!(!ms(t)||!xs(t)||!Ns(t))},Es=e=>{if(!e)return!1;const t=e.length>=8,s=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/\d/.test(e),a=/[!@#$%^&*(),.?":{}|<>_\-+=~`[\]\\\/]/.test(e);return[t,s,n,r,a].every(h=>h)},Ds=e=>{for(const t of Y.countries){const s=t.code,n=t.prefix?`-${t.prefix}`:"",r=t.mask.replace(/[^_]/g,"").length;if(t.iso==="BR"){if(new RegExp(`^\\${s} \\d{2}9?\\d{8}$`).test(e))return!0;continue}if(new RegExp(`^\\${s}${n} \\d{${r}}$`).test(e))return!0}return!1},vs=e=>{if(!e||!/^[0-9a-zA-Z.-]+$/.test(e))return!1;const s=e.replace(/[^a-zA-Z0-9]/g,"");return s.length<7||s.length>9?!1:/^[0-9]{7,8}[0-9Xx]?$/.test(s)};u.ApiService=ss,u.ArkynLogService=$,u.BadGateway=C,u.BadRequest=S,u.Conflict=O,u.Created=J,u.DebugService=v,u.Forbidden=I,u.Found=A,u.NoContent=k,u.NotFound=j,u.NotImplemented=U,u.SchemaValidator=as,u.ServerError=E,u.Success=L,u.Unauthorized=w,u.UnprocessableEntity=D,u.Updated=q,u.decodeErrorMessageFromRequest=es,u.decodeRequestBody=ts,u.errorHandler=ns,u.flushDebugLogs=T,u.formAsyncParse=B,u.formParse=F,u.getCaller=N,u.getScopedParams=rs,u.validateCep=us,u.validateCnpj=ls,u.validateCpf=gs,u.validateDate=ps,u.validateEmail=Ss,u.validatePassword=Es,u.validatePhone=Ds,u.validateRg=vs,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|