@arkyn/server 3.0.1-beta.78 → 3.0.1-beta.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -1,9 +1,9 @@
1
- var w = Object.defineProperty;
2
- var A = (e, t, s) => t in e ? w(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var o = (e, t, s) => A(e, typeof t != "symbol" ? t + "" : t, s);
1
+ var v = Object.defineProperty;
2
+ var w = (e, t, s) => t in e ? v(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var o = (e, t, s) => w(e, typeof t != "symbol" ? t + "" : t, s);
4
4
  import "zod";
5
5
  import { removeNonNumeric as N } from "@arkyn/shared";
6
- import J from "node:dns";
6
+ import "node:dns";
7
7
  import { countries as U } from "@arkyn/templates";
8
8
  function g(e) {
9
9
  var s;
@@ -22,7 +22,7 @@ function g(e) {
22
22
  }), console.log(c);
23
23
  }
24
24
  }
25
- const L = {};
25
+ const A = {};
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 = L.relative(e, i);
95
+ i = A.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 B extends p {
106
+ class L extends p {
107
107
  /**
108
108
  * Creates an instance of the `BadGateway` class.
109
109
  *
@@ -151,7 +151,7 @@ class B extends p {
151
151
  return Response.json(this.body, s);
152
152
  }
153
153
  }
154
- class b extends p {
154
+ class T extends p {
155
155
  /**
156
156
  * Creates an instance of the `BadRequest` class.
157
157
  *
@@ -199,7 +199,7 @@ class b extends p {
199
199
  return Response.json(this.body, s);
200
200
  }
201
201
  }
202
- class k extends p {
202
+ class B extends p {
203
203
  /**
204
204
  * Creates an instance of the `Conflict` class.
205
205
  *
@@ -247,7 +247,7 @@ class k extends p {
247
247
  return Response.json(this.body, s);
248
248
  }
249
249
  }
250
- class H extends p {
250
+ class k extends p {
251
251
  /**
252
252
  * Creates an instance of the `Forbidden` class.
253
253
  *
@@ -295,7 +295,7 @@ class H extends p {
295
295
  return Response.json(this.body, s);
296
296
  }
297
297
  }
298
- class q extends p {
298
+ class H extends p {
299
299
  /**
300
300
  * Creates an instance of the `NotFound` class.
301
301
  *
@@ -343,7 +343,7 @@ class q extends p {
343
343
  return Response.json(this.body, s);
344
344
  }
345
345
  }
346
- class F extends p {
346
+ class q 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 P extends p {
442
+ class F 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 Y extends m {
574
+ class P extends m {
575
575
  /**
576
576
  * Creates an instance of the `Created` class.
577
577
  *
@@ -615,7 +615,7 @@ class Y extends m {
615
615
  return Response.json(this.body, s);
616
616
  }
617
617
  }
618
- class z extends m {
618
+ class Y extends m {
619
619
  /**
620
620
  * Creates an instance of the `Found` class.
621
621
  *
@@ -662,7 +662,7 @@ class z extends m {
662
662
  return Response.json(this.body, s);
663
663
  }
664
664
  }
665
- class M extends m {
665
+ class z extends m {
666
666
  /**
667
667
  * Creates an instance of the `NoContent` class.
668
668
  *
@@ -690,7 +690,7 @@ class M extends m {
690
690
  return new Response(null, s);
691
691
  }
692
692
  }
693
- class _ extends m {
693
+ class M extends m {
694
694
  /**
695
695
  * Creates an instance of the `Success` class.
696
696
  *
@@ -734,7 +734,7 @@ class _ extends m {
734
734
  return Response.json(this.body, s);
735
735
  }
736
736
  }
737
- class V extends m {
737
+ class _ extends m {
738
738
  /**
739
739
  * Creates an instance of the `Updated` class.
740
740
  *
@@ -778,7 +778,7 @@ class V extends m {
778
778
  return Response.json(this.body, s);
779
779
  }
780
780
  }
781
- class G {
781
+ class V {
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 Z(e) {
845
+ async function G(e) {
846
846
  const t = C.getArkynConfig();
847
847
  if (!t) return;
848
848
  const { userToken: s, apiUrl: n, trafficSourceId: r } = t, {
@@ -862,7 +862,7 @@ async function Z(e) {
862
862
  const y = new URL(j);
863
863
  let D = "HTTPS";
864
864
  y.protocol === "http:" && (D = "HTTP");
865
- const v = JSON.stringify({
865
+ const J = JSON.stringify({
866
866
  domainUrl: y.protocol + "//" + y.host,
867
867
  pathnameUrl: y.pathname,
868
868
  trafficSourceId: r,
@@ -879,7 +879,7 @@ async function Z(e) {
879
879
  });
880
880
  await fetch(n, {
881
881
  method: "POST",
882
- body: v,
882
+ body: J,
883
883
  headers: {
884
884
  "Content-Type": "application/json",
885
885
  Authorization: `Bearer ${s}`
@@ -893,7 +893,7 @@ async function Z(e) {
893
893
  });
894
894
  }
895
895
  }
896
- async function T(e, t, s = {}, n) {
896
+ async function b(e, t, s = {}, n) {
897
897
  const r = {
898
898
  POST: "Resource created successfully",
899
899
  PUT: "Resource updated successfully",
@@ -913,7 +913,7 @@ async function T(e, t, s = {}, n) {
913
913
  } catch {
914
914
  u = null;
915
915
  }
916
- const d = G.handle({
916
+ const d = V.handle({
917
917
  elapsedTime: i,
918
918
  method: e,
919
919
  queryParams: new URL(t).searchParams,
@@ -924,7 +924,7 @@ async function T(e, t, s = {}, n) {
924
924
  status: l,
925
925
  url: t
926
926
  });
927
- return Z(d), h.ok ? {
927
+ return G(d), h.ok ? {
928
928
  success: !0,
929
929
  status: l,
930
930
  message: (u == null ? void 0 : u.message) || r[e],
@@ -951,22 +951,22 @@ async function T(e, t, s = {}, n) {
951
951
  };
952
952
  }
953
953
  }
954
- async function W(e, t = {}, s) {
955
- return T("DELETE", e, t, s);
954
+ async function Z(e, t = {}, s) {
955
+ return b("DELETE", e, t, s);
956
+ }
957
+ async function W(e, t = {}) {
958
+ return b("GET", e, t);
956
959
  }
957
- async function K(e, t = {}) {
958
- return T("GET", e, t);
960
+ async function K(e, t = {}, s) {
961
+ return b("PATCH", e, t, s);
959
962
  }
960
963
  async function Q(e, t = {}, s) {
961
- return T("PATCH", e, t, s);
964
+ return b("POST", e, t, s);
962
965
  }
963
966
  async function X(e, t = {}, s) {
964
- return T("POST", e, t, s);
965
- }
966
- async function ss(e, t = {}, s) {
967
- return T("PUT", e, t, s);
967
+ return b("PUT", e, t, s);
968
968
  }
969
- class Ds {
969
+ class xs {
970
970
  /**
971
971
  * Creates an instance of ApiService.
972
972
  * @param props - The configuration properties for the API instance.
@@ -1014,7 +1014,7 @@ class Ds {
1014
1014
  */
1015
1015
  async get(t, s) {
1016
1016
  const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token);
1017
- return this.onDebug(t, "get", [r]), await K(n, r);
1017
+ return this.onDebug(t, "get", [r]), await W(n, r);
1018
1018
  }
1019
1019
  /**
1020
1020
  * Sends a post request to the specified endpoint.
@@ -1024,7 +1024,7 @@ class Ds {
1024
1024
  */
1025
1025
  async post(t, s) {
1026
1026
  const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
1027
- return this.onDebug(t, "post", [r, a]), await X(n, r, a);
1027
+ return this.onDebug(t, "post", [r, a]), await Q(n, r, a);
1028
1028
  }
1029
1029
  /**
1030
1030
  * Sends a put request to the specified endpoint.
@@ -1034,7 +1034,7 @@ class Ds {
1034
1034
  */
1035
1035
  async put(t, s) {
1036
1036
  const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
1037
- return this.onDebug(t, "put", [r, a]), await ss(n, r, a);
1037
+ return this.onDebug(t, "put", [r, a]), await X(n, r, a);
1038
1038
  }
1039
1039
  /**
1040
1040
  * Sends a patch request to the specified endpoint.
@@ -1044,7 +1044,7 @@ class Ds {
1044
1044
  */
1045
1045
  async patch(t, s) {
1046
1046
  const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
1047
- return this.onDebug(t, "patch", [r, a]), await Q(n, r, a);
1047
+ return this.onDebug(t, "patch", [r, a]), await K(n, r, a);
1048
1048
  }
1049
1049
  /**
1050
1050
  * Sends a delete request to the specified endpoint.
@@ -1054,14 +1054,14 @@ class Ds {
1054
1054
  */
1055
1055
  async delete(t, s) {
1056
1056
  const n = this.generateURL(t), r = this.generateHeaders((s == null ? void 0 : s.headers) || {}, s == null ? void 0 : s.token), a = s == null ? void 0 : s.body;
1057
- return this.onDebug(t, "delete", [r, a]), await W(n, r, a);
1057
+ return this.onDebug(t, "delete", [r, a]), await Z(n, r, a);
1058
1058
  }
1059
1059
  }
1060
- function Os(e, t) {
1060
+ function Rs(e, t) {
1061
1061
  var s, n, r;
1062
1062
  return e != null && e.message && typeof (e == null ? void 0 : e.message) == "string" ? e == null ? void 0 : e.message : e != null && e.error && typeof (e == null ? void 0 : e.error) == "string" ? e == null ? void 0 : e.error : (s = e == null ? void 0 : e.error) != null && s.message && typeof ((n = e == null ? void 0 : e.error) == null ? void 0 : n.message) == "string" ? (r = e == null ? void 0 : e.error) == null ? void 0 : r.message : t != null && t.statusText && typeof (t == null ? void 0 : t.statusText) == "string" ? t == null ? void 0 : t.statusText : "Missing error message";
1063
1063
  }
1064
- const $s = async (e) => {
1064
+ const Ns = async (e) => {
1065
1065
  let t;
1066
1066
  const s = await e.arrayBuffer(), n = new TextDecoder().decode(s);
1067
1067
  try {
@@ -1072,32 +1072,34 @@ const $s = async (e) => {
1072
1072
  const a = new URLSearchParams(n);
1073
1073
  t = Object.fromEntries(a.entries());
1074
1074
  } else
1075
- throw new b("Invalid URLSearchParams format");
1075
+ throw new T("Invalid URLSearchParams format");
1076
1076
  } catch {
1077
- throw new b("Failed to extract data from request");
1077
+ throw new T("Failed to extract data from request");
1078
1078
  }
1079
1079
  }
1080
1080
  return t;
1081
1081
  };
1082
- function Is(e) {
1082
+ function Es(e) {
1083
1083
  switch (!0) {
1084
1084
  case e instanceof Response:
1085
1085
  return e;
1086
- case e instanceof z:
1087
- return e.toResponse();
1088
1086
  case e instanceof Y:
1089
1087
  return e.toResponse();
1090
- case e instanceof V:
1088
+ case e instanceof P:
1091
1089
  return e.toResponse();
1092
1090
  case e instanceof _:
1093
1091
  return e.toResponse();
1094
1092
  case e instanceof M:
1095
1093
  return e.toResponse();
1094
+ case e instanceof z:
1095
+ return e.toResponse();
1096
1096
  }
1097
1097
  switch (!0) {
1098
- case e instanceof B:
1098
+ case e instanceof L:
1099
+ return e.toResponse();
1100
+ case e instanceof T:
1099
1101
  return e.toResponse();
1100
- case e instanceof b:
1102
+ case e instanceof B:
1101
1103
  return e.toResponse();
1102
1104
  case e instanceof k:
1103
1105
  return e.toResponse();
@@ -1105,18 +1107,16 @@ function Is(e) {
1105
1107
  return e.toResponse();
1106
1108
  case e instanceof q:
1107
1109
  return e.toResponse();
1108
- case e instanceof F:
1109
- return e.toResponse();
1110
1110
  case e instanceof x:
1111
1111
  return e.toResponse();
1112
- case e instanceof P:
1112
+ case e instanceof F:
1113
1113
  return e.toResponse();
1114
1114
  case e instanceof R:
1115
1115
  return e.toResponse();
1116
1116
  }
1117
1117
  return new x("Server error", e).toResponse();
1118
1118
  }
1119
- async function es([
1119
+ async function ss([
1120
1120
  e,
1121
1121
  t
1122
1122
  ]) {
@@ -1136,7 +1136,7 @@ async function es([
1136
1136
  data: s.data
1137
1137
  };
1138
1138
  }
1139
- function ts([
1139
+ function es([
1140
1140
  e,
1141
1141
  t
1142
1142
  ]) {
@@ -1156,7 +1156,7 @@ function ts([
1156
1156
  data: s.data
1157
1157
  };
1158
1158
  }
1159
- const Cs = (e, t = "") => {
1159
+ const Ss = (e, t = "") => {
1160
1160
  const s = new URL(e.url);
1161
1161
  if (t === "") return s.searchParams;
1162
1162
  const n = Array.from(
@@ -1164,14 +1164,14 @@ const Cs = (e, t = "") => {
1164
1164
  ).filter(([r]) => r.startsWith(`${t}:`)).map(([r, a]) => [r.replace(`${t}:`, ""), a]);
1165
1165
  return new URLSearchParams(n);
1166
1166
  };
1167
- function ns(e) {
1167
+ function ts(e) {
1168
1168
  const t = "Error validating:", s = e.issues.map(
1169
1169
  ({ path: n, message: r }) => `-> ${n.join(".")}: ${r}`
1170
1170
  );
1171
1171
  return [t, ...s].join(`
1172
1172
  `);
1173
1173
  }
1174
- class js {
1174
+ class Ds {
1175
1175
  /**
1176
1176
  * Creates a new SchemaValidator instance.
1177
1177
  *
@@ -1248,7 +1248,7 @@ class js {
1248
1248
  try {
1249
1249
  return this.schema.parse(t);
1250
1250
  } catch (s) {
1251
- throw new x(ns(s));
1251
+ throw new x(ts(s));
1252
1252
  }
1253
1253
  }
1254
1254
  /**
@@ -1277,7 +1277,7 @@ class js {
1277
1277
  * ```
1278
1278
  */
1279
1279
  formValidate(t, s) {
1280
- const n = ts([t, this.schema]);
1280
+ const n = es([t, this.schema]);
1281
1281
  if (!n.success) {
1282
1282
  const r = Object.keys(n.fieldErrors)[0];
1283
1283
  throw new R({
@@ -1315,7 +1315,7 @@ class js {
1315
1315
  * ```
1316
1316
  */
1317
1317
  async formAsyncValidate(t, s) {
1318
- const n = await es([t, this.schema]);
1318
+ const n = await ss([t, this.schema]);
1319
1319
  if (!n.success) {
1320
1320
  const r = Object.keys(n.fieldErrors)[0];
1321
1321
  throw new R({
@@ -1328,62 +1328,62 @@ class js {
1328
1328
  return n.data;
1329
1329
  }
1330
1330
  }
1331
- const vs = (e) => {
1331
+ const $s = (e) => {
1332
1332
  if (!e || !/^[0-9-]+$/.test(e)) return !1;
1333
1333
  const s = N(e), n = 8, r = /^\d{8}$/.test(s);
1334
1334
  return s.length === n && r;
1335
1335
  };
1336
- function rs(e) {
1336
+ function ns(e) {
1337
1337
  return e.length !== 14;
1338
1338
  }
1339
- function os(e) {
1339
+ function rs(e) {
1340
1340
  const [t] = e;
1341
1341
  return [...e].every((s) => s === t);
1342
1342
  }
1343
- function O(e, t) {
1343
+ function $(e, t) {
1344
1344
  let s = 0;
1345
1345
  for (let r = 0; r < t.length; r++)
1346
1346
  s += parseInt(e[r]) * t[r];
1347
1347
  const n = s % 11;
1348
1348
  return n < 2 ? 0 : 11 - n;
1349
1349
  }
1350
- function as(e) {
1350
+ function os(e) {
1351
1351
  return e.slice(12);
1352
1352
  }
1353
- const ws = (e) => {
1353
+ const Os = (e) => {
1354
1354
  if (!e) return !1;
1355
1355
  const t = N(e);
1356
- if (rs(t) || os(t)) return !1;
1357
- const s = t.slice(0, 12), n = O(s, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), r = O(
1356
+ if (ns(t) || rs(t)) return !1;
1357
+ const s = t.slice(0, 12), n = $(s, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), r = $(
1358
1358
  s + n,
1359
1359
  [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
1360
1360
  );
1361
- return as(t) === `${n}${r}`;
1361
+ return os(t) === `${n}${r}`;
1362
1362
  };
1363
- function us(e) {
1363
+ function as(e) {
1364
1364
  return e.length !== 11;
1365
1365
  }
1366
- function is(e) {
1366
+ function us(e) {
1367
1367
  const [t] = e;
1368
1368
  return [...e].every((s) => s === t);
1369
1369
  }
1370
- function $(e, t) {
1370
+ function O(e, t) {
1371
1371
  let s = 0;
1372
1372
  for (const r of e)
1373
1373
  t > 1 && (s += parseInt(r) * t--);
1374
1374
  const n = s % 11;
1375
1375
  return n < 2 ? 0 : 11 - n;
1376
1376
  }
1377
- function cs(e) {
1377
+ function is(e) {
1378
1378
  return e.slice(9);
1379
1379
  }
1380
- const As = (e) => {
1380
+ const Is = (e) => {
1381
1381
  if (!e) return !1;
1382
1382
  const t = N(e);
1383
- if (us(t) || is(t)) return !1;
1384
- const s = $(t, 10), n = $(t, 11);
1385
- return cs(t) === `${s}${n}`;
1386
- }, Js = (e, t) => {
1383
+ if (as(t) || us(t)) return !1;
1384
+ const s = O(t, 10), n = O(t, 11);
1385
+ return is(t) === `${s}${n}`;
1386
+ }, Cs = (e, t) => {
1387
1387
  let s, n, r;
1388
1388
  const a = (t == null ? void 0 : t.inputFormat) || "DD/MM/YYYY", c = (t == null ? void 0 : t.minYear) || 1900, h = (t == null ? void 0 : t.maxYear) || 3e3;
1389
1389
  if (a === "DD/MM/YYYY") {
@@ -1409,55 +1409,40 @@ const As = (e) => {
1409
1409
  } else if (i > d[l - 1])
1410
1410
  return !1;
1411
1411
  return u < c || u > h ? !1 : new Date(u, l - 1, i).getDate() === i;
1412
- }, hs = J.promises.resolve;
1413
- function ls(e) {
1412
+ };
1413
+ function cs(e) {
1414
1414
  return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(e);
1415
1415
  }
1416
- function fs(e) {
1416
+ function hs(e) {
1417
1417
  return !(e.length === 0 || e.length > 64 || e.startsWith(".") || e.endsWith(".") || e.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e));
1418
1418
  }
1419
- function ds(e) {
1419
+ function ls(e) {
1420
1420
  return !(e.length === 0 || e.length > 63 || e.startsWith("-") || e.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(e));
1421
1421
  }
1422
- function ps(e) {
1422
+ function fs(e) {
1423
1423
  if (e.length === 0 || e.length > 253 || e.startsWith(".") || e.endsWith(".") || e.startsWith("-") || e.endsWith("-"))
1424
1424
  return !1;
1425
1425
  const t = e.split(".");
1426
1426
  if (t.length < 2) return !1;
1427
- for (const n of t) if (!ds(n)) return !1;
1427
+ for (const n of t) if (!ls(n)) return !1;
1428
1428
  const s = t[t.length - 1];
1429
1429
  return !(s.length < 2 || !/^[a-zA-Z]+$/.test(s));
1430
1430
  }
1431
- function ys(e) {
1431
+ function ds(e) {
1432
1432
  const t = e.split("@");
1433
1433
  if (t.length !== 2) return !1;
1434
1434
  const [s, n] = t;
1435
- return !(!fs(s) || !ps(n));
1435
+ return !(!hs(s) || !fs(n));
1436
1436
  }
1437
- function gs(e) {
1437
+ function ps(e) {
1438
1438
  const t = e.split("@");
1439
1439
  return t.length === 2 ? t[1].toLowerCase() : null;
1440
1440
  }
1441
- const ms = ["MX", "A", "AAAA"];
1442
- async function Ts(e, t) {
1443
- try {
1444
- return await hs(e, t), !0;
1445
- } catch {
1446
- return !1;
1447
- }
1448
- }
1449
- async function bs(e) {
1450
- for (const t of ms)
1451
- if (await Ts(e, t)) return !0;
1452
- return !1;
1453
- }
1454
- const Us = async (e) => {
1441
+ const js = async (e) => {
1455
1442
  if (!e || typeof e != "string") return !1;
1456
1443
  const t = e.trim();
1457
- if (!ls(t) || !ys(t)) return !1;
1458
- const s = gs(t);
1459
- return s ? await bs(s) : !1;
1460
- }, Ls = (e) => {
1444
+ return !(!cs(t) || !ds(t) || !ps(t));
1445
+ }, Js = (e) => {
1461
1446
  if (!e) return !1;
1462
1447
  const t = e.length >= 8, s = /[A-Z]/.test(e), n = /[a-z]/.test(e), r = /\d/.test(e), a = /[!@#$%^&*(),.?":{}|<>_\-+=~`[\]\\\/]/.test(
1463
1448
  e
@@ -1469,7 +1454,7 @@ const Us = async (e) => {
1469
1454
  r,
1470
1455
  a
1471
1456
  ].every((c) => c);
1472
- }, Bs = (e) => {
1457
+ }, vs = (e) => {
1473
1458
  for (const t of U) {
1474
1459
  const s = t.code, n = t.prefix ? `-${t.prefix}` : "", r = t.mask.replace(/[^_]/g, "").length;
1475
1460
  if (t.iso === "BR") {
@@ -1479,44 +1464,44 @@ const Us = async (e) => {
1479
1464
  if (new RegExp(`^\\${s}${n} \\d{${r}}$`).test(e)) return !0;
1480
1465
  }
1481
1466
  return !1;
1482
- }, ks = (e) => {
1467
+ }, ws = (e) => {
1483
1468
  if (!e || !/^[0-9a-zA-Z.-]+$/.test(e)) return !1;
1484
1469
  const s = e.replace(/[^a-zA-Z0-9]/g, "");
1485
1470
  return s.length < 7 || s.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(s);
1486
1471
  };
1487
1472
  export {
1488
- Ds as ApiService,
1473
+ xs as ApiService,
1489
1474
  C as ArkynLogService,
1490
- B as BadGateway,
1491
- b as BadRequest,
1492
- k as Conflict,
1493
- Y as Created,
1475
+ L as BadGateway,
1476
+ T as BadRequest,
1477
+ B as Conflict,
1478
+ P as Created,
1494
1479
  I as DebugService,
1495
- H as Forbidden,
1496
- z as Found,
1497
- M as NoContent,
1498
- q as NotFound,
1499
- F as NotImplemented,
1500
- js as SchemaValidator,
1480
+ k as Forbidden,
1481
+ Y as Found,
1482
+ z as NoContent,
1483
+ H as NotFound,
1484
+ q as NotImplemented,
1485
+ Ds as SchemaValidator,
1501
1486
  x as ServerError,
1502
- _ as Success,
1503
- P as Unauthorized,
1487
+ M as Success,
1488
+ F as Unauthorized,
1504
1489
  R as UnprocessableEntity,
1505
- V as Updated,
1506
- Os as decodeErrorMessageFromRequest,
1507
- $s as decodeRequestBody,
1508
- Is as errorHandler,
1490
+ _ as Updated,
1491
+ Rs as decodeErrorMessageFromRequest,
1492
+ Ns as decodeRequestBody,
1493
+ Es as errorHandler,
1509
1494
  g as flushDebugLogs,
1510
- es as formAsyncParse,
1511
- ts as formParse,
1495
+ ss as formAsyncParse,
1496
+ es as formParse,
1512
1497
  E as getCaller,
1513
- Cs as getScopedParams,
1514
- vs as validateCep,
1515
- ws as validateCnpj,
1516
- As as validateCpf,
1517
- Js as validateDate,
1518
- Us as validateEmail,
1519
- Ls as validatePassword,
1520
- Bs as validatePhone,
1521
- ks as validateRg
1498
+ Ss as getScopedParams,
1499
+ $s as validateCep,
1500
+ Os as validateCnpj,
1501
+ Is as validateCpf,
1502
+ Cs as validateDate,
1503
+ js as validateEmail,
1504
+ Js as validatePassword,
1505
+ vs as validatePhone,
1506
+ ws as validateRg
1522
1507
  };
@@ -1,10 +1,10 @@
1
- (function(a,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):(a=typeof globalThis<"u"?globalThis:a||self,d(a["@arkyn/server"]={},null,a.shared,a.dns,a.templates))})(this,function(a,d,m,Y,_){"use strict";var Us=Object.defineProperty;var Js=(a,d,m)=>d in a?Us(a,d,{enumerable:!0,configurable:!0,writable:!0,value:m}):a[d]=m;var o=(a,d,m)=>Js(a,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 u=`${{yellow:"\x1B[33m",cyan:"\x1B[36m",red:"\x1B[31m",green:"\x1B[32m"}[e.scheme]}[${e.name}]\x1B[0m`;let h=`
2
- `;e.debugs.forEach(l=>{h+=`${u} ${l.trim()}
3
- `}),console.log(h)}}const V={};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 u=2;for(;u<n.length&&(n[u].includes("node:internal")||n[u].includes("/node_modules/"));)u++;if(r.length>0)for(;u<n.length&&r.some(i=>n[u].includes(i));)u++;const h=n[u]||"";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 g=c.match(/at\s+([^(\s]+)\s+/);g&&g[1]!=="new"&&(l=g[1])}}c.includes("(")&&(c=c.substring(c.indexOf("(")+1,c.lastIndexOf(")"))),c=c.split(":").slice(0,-2).join(":");try{c=V.relative(e,c)}catch{}return{functionName:l,callerInfo:c}}class p{onDebug(t){const{name:s,body:n,cause:r,message:u}=t,h=[],{callerInfo:l,functionName:c}=N();h.push(`${s} initialized`),h.push(`Caller Function: ${c}`),h.push(`Caller Location: ${l}`),u&&h.push(`Message: ${u}`),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 p{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 E extends p{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 $ extends p{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 p{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 p{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 w extends p{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 S extends p{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 A extends p{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 p{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:u,functionName:h}=N();r.push(`${t} initialized
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,js,Y){"use strict";var Cs=Object.defineProperty;var Is=(u,d,m)=>d in u?Cs(u,d,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[d]=m;var o=(u,d,m)=>Is(u,typeof d!="symbol"?d+"":d,m);function b(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
+ `;e.debugs.forEach(l=>{h+=`${a} ${l.trim()}
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 g=c.match(/at\s+([^(\s]+)\s+/);g&&g[1]!=="new"&&(l=g[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 p{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)}`),b({scheme:"red",name:"ARKYN-BAD-RESPONSE-DEBUG",debugs:h})}}class $ extends p{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 E extends p{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 C extends p{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 p{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 p{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 p{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 S extends p{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 p{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 p{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
- `),r.push(`Caller Location: ${u}
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
- `),T({scheme:"green",name:"ARKYN-SUCCESS-RESPONSE-DEBUG",debugs:r})}}class U 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 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)||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 G{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:8080/ingest-log"}}static getArkynConfig(){return this.arkynConfig}static resetArkynConfig(){this.arkynConfig=void 0}}o(O,"arkynConfig");async function Z(e){const t=O.getArkynConfig();if(!t)return;const{userToken:s,apiUrl:n,trafficSourceId:r}=t,{elapsedTime:u,method:h,queryParams:l,requestBody:c,requestHeaders:f,responseBody:i,responseHeaders:g,status:z,token:y,rawUrl:ws}=e;if(process.env.NODE_ENV!=="development")try{const b=new URL(ws);let M="HTTPS";b.protocol==="http:"&&(M="HTTP");const As=JSON.stringify({domainUrl:b.protocol+"//"+b.host,pathnameUrl:b.pathname,trafficSourceId:r,status:z,protocol:M,method:h,trafficUserId:null,elapsedTime:u,requestHeaders:f,requestBody:c,queryParams:l,responseHeaders:g,responseBody:i});await fetch(n,{method:"POST",body:As,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(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 u=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()-u,f=l.status;let i=null;try{i=await l.json()}catch{i=null}const g=G.handle({elapsedTime:c,method:e,queryParams:new URL(t).searchParams,requestHeaders:h,requestBody:n,responseBody:i,responseHeaders:l.headers,status:f,url:t});return Z(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(u){return T({debugs:[`Network error or request failed: ${u}`],name:"ARKYN_MAKE_REQUEST_ERROR",scheme:"red"}),{success:!1,status:0,message:"Network error or request failed",response:null,cause:u instanceof Error?u.message:String(u)}}}async function W(e,t={},s){return x("DELETE",e,t,s)}async function K(e,t={}){return x("GET",e,t)}async function Q(e,t={},s){return x("PATCH",e,t,s)}async function X(e,t={},s){return x("POST",e,t,s)}async function ss(e,t={},s){return x("PUT",e,t,s)}class es{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 K(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),u=s==null?void 0:s.body;return this.onDebug(t,"post",[r,u]),await X(n,r,u)}async put(t,s){const n=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token),u=s==null?void 0:s.body;return this.onDebug(t,"put",[r,u]),await ss(n,r,u)}async patch(t,s){const n=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token),u=s==null?void 0:s.body;return this.onDebug(t,"patch",[r,u]),await Q(n,r,u)}async delete(t,s){const n=this.generateURL(t),r=this.generateHeaders((s==null?void 0:s.headers)||{},s==null?void 0:s.token),u=s==null?void 0:s.body;return this.onDebug(t,"delete",[r,u]),await W(n,r,u)}}function ts(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 ns=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 u=new URLSearchParams(n);t=Object.fromEntries(u.entries())}else throw new E("Invalid URLSearchParams format")}catch{throw new E("Failed to extract data from request")}}return t};function rs(e){switch(!0){case e instanceof Response:return e;case e instanceof J:return e.toResponse();case e instanceof U: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 E:return e.toResponse();case e instanceof $:return e.toResponse();case e instanceof I:return e.toResponse();case e instanceof j:return e.toResponse();case e instanceof w:return e.toResponse();case e instanceof S:return e.toResponse();case e instanceof A: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 os=(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,u])=>[r.replace(`${t}:`,""),u]);return new URLSearchParams(n)};function as(e){const t="Error validating:",s=e.issues.map(({path:n,message:r})=>`-> ${n.join(".")}: ${r}`);return[t,...s].join(`
10
- `)}class us{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 S(as(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 is=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 cs(e){return e.length!==14}function hs(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 ls(e){return e.slice(12)}const fs=e=>{if(!e)return!1;const t=m.removeNonNumeric(e);if(cs(t)||hs(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 ls(t)===`${n}${r}`};function ds(e){return e.length!==11}function ys(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 ps(e){return e.slice(9)}const gs=e=>{if(!e)return!1;const t=m.removeNonNumeric(e);if(ds(t)||ys(t))return!1;const s=P(t,10),n=P(t,11);return ps(t)===`${s}${n}`},ms=(e,t)=>{let s,n,r;const u=(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(u==="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(u==="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(u==="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 g=[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>g[f-1])return!1;return i<h||i>l?!1:new Date(i,f-1,c).getDate()===c},Ts=Y.promises.resolve;function bs(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 Rs(e){return!(e.length===0||e.length>64||e.startsWith(".")||e.endsWith(".")||e.includes("..")||!/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e))}function xs(e){return!(e.length===0||e.length>63||e.startsWith("-")||e.endsWith("-")||!/^[a-zA-Z0-9-]+$/.test(e))}function Ns(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(!xs(n))return!1;const s=t[t.length-1];return!(s.length<2||!/^[a-zA-Z]+$/.test(s))}function Es(e){const t=e.split("@");if(t.length!==2)return!1;const[s,n]=t;return!(!Rs(s)||!Ns(n))}function Ss(e){const t=e.split("@");return t.length===2?t[1].toLowerCase():null}const Ds=["MX","A","AAAA"];async function vs(e,t){try{return await Ts(e,t),!0}catch{return!1}}async function Os(e){for(const t of Ds)if(await vs(e,t))return!0;return!1}const Cs=async e=>{if(!e||typeof e!="string")return!1;const t=e.trim();if(!bs(t)||!Es(t))return!1;const s=Ss(t);return s?await Os(s):!1},$s=e=>{if(!e)return!1;const t=e.length>=8,s=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/\d/.test(e),u=/[!@#$%^&*(),.?":{}|<>_\-+=~`[\]\\\/]/.test(e);return[t,s,n,r,u].every(h=>h)},Is=e=>{for(const t of _.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},js=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)};a.ApiService=es,a.ArkynLogService=O,a.BadGateway=C,a.BadRequest=E,a.Conflict=$,a.Created=U,a.DebugService=v,a.Forbidden=I,a.Found=J,a.NoContent=k,a.NotFound=j,a.NotImplemented=w,a.SchemaValidator=us,a.ServerError=S,a.Success=L,a.Unauthorized=A,a.UnprocessableEntity=D,a.Updated=q,a.decodeErrorMessageFromRequest=ts,a.decodeRequestBody=ns,a.errorHandler=rs,a.flushDebugLogs=T,a.formAsyncParse=B,a.formParse=F,a.getCaller=N,a.getScopedParams=os,a.validateCep=is,a.validateCnpj=fs,a.validateCpf=gs,a.validateDate=ms,a.validateEmail=Cs,a.validatePassword=$s,a.validatePhone=Is,a.validateRg=js,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
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:8080/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 S(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 ps=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}`},gs=(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 g=[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>g[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 Es=async e=>{if(!e||typeof e!="string")return!1;const t=e.trim();return!(!ms(t)||!xs(t)||!Ns(t))},Ss=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=O,u.BadGateway=$,u.BadRequest=E,u.Conflict=C,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=S,u.Success=L,u.Unauthorized=w,u.UnprocessableEntity=D,u.Updated=q,u.decodeErrorMessageFromRequest=es,u.decodeRequestBody=ts,u.errorHandler=ns,u.flushDebugLogs=b,u.formAsyncParse=B,u.formParse=F,u.getCaller=N,u.getScopedParams=rs,u.validateCep=us,u.validateCnpj=ls,u.validateCpf=ps,u.validateDate=gs,u.validateEmail=Es,u.validatePassword=Ss,u.validatePhone=Ds,u.validateRg=vs,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
@@ -1 +1 @@
1
- {"version":3,"file":"validateEmail.d.ts","sourceRoot":"","sources":["../../src/validations/validateEmail.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAmGpE;;;;;;;;;;;;;;;;;GAiBG;AAEH,QAAA,MAAM,aAAa,EAAE,qBAWpB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"validateEmail.d.ts","sourceRoot":"","sources":["../../src/validations/validateEmail.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAmGpE;;;;;;;;;;;;;;;;;GAiBG;AAEH,QAAA,MAAM,aAAa,EAAE,qBAYpB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import dns from "node:dns";
2
- const resolveDns = dns.promises.resolve;
2
+ // const resolveDns = dns.promises.resolve;
3
3
  // Validates basic email format using a comprehensive regex pattern
4
4
  function isValidBasicFormat(email) {
5
5
  const emailRegex = /^[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])?)*$/;
@@ -69,24 +69,25 @@ function extractDomain(email) {
69
69
  // DNS record types to check for domain validation
70
70
  const DNS_RECORD_TYPES = ["MX", "A", "AAAA"];
71
71
  // Attempts to resolve a specific DNS record type for a domain
72
- async function tryResolveDnsRecord(domain, recordType) {
73
- try {
74
- await resolveDns(domain, recordType);
75
- return true;
76
- }
77
- catch {
78
- return false;
79
- }
80
- }
72
+ // async function tryResolveDnsRecord(
73
+ // domain: string,
74
+ // recordType: string
75
+ // ): Promise<boolean> {
76
+ // try {
77
+ // await resolveDns(domain, recordType);
78
+ // return true;
79
+ // } catch {
80
+ // return false;
81
+ // }
82
+ // }
81
83
  // Validates if domain has valid DNS records (MX, A, or AAAA records)
82
- async function isValidDns(domain) {
83
- for (const recordType of DNS_RECORD_TYPES) {
84
- const hasRecord = await tryResolveDnsRecord(domain, recordType);
85
- if (hasRecord)
86
- return true;
87
- }
88
- return false;
89
- }
84
+ // async function isValidDns(domain: string): Promise<boolean> {
85
+ // for (const recordType of DNS_RECORD_TYPES) {
86
+ // const hasRecord = await tryResolveDnsRecord(domain, recordType);
87
+ // if (hasRecord) return true;
88
+ // }
89
+ // return false;
90
+ // }
90
91
  /**
91
92
  * Validates if an email address is valid in all possible ways, including DNS validation.
92
93
  *
@@ -116,6 +117,7 @@ const validateEmail = async (rawEmail) => {
116
117
  const domain = extractDomain(email);
117
118
  if (!domain)
118
119
  return false;
119
- return await isValidDns(domain);
120
+ // return await isValidDns(domain);
121
+ return true;
120
122
  };
121
123
  export { validateEmail };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "3.0.1-beta.78",
3
+ "version": "3.0.1-beta.79",
4
4
  "author": "Arkyn | Lucas Gonçalves",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/bundle.js",