@arkyn/server 3.0.1-beta.77 → 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.
@@ -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,iBA8DjD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
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,iBAyDjD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -44,7 +44,7 @@ async function arkynLogRequest(config) {
44
44
  const arkynService = ArkynLogService.getArkynConfig();
45
45
  if (!arkynService)
46
46
  return;
47
- const { arkynUserToken, arkynApiUrl } = arkynService;
47
+ const { userToken, apiUrl, trafficSourceId } = arkynService;
48
48
  const { elapsedTime, method, queryParams, requestBody, requestHeaders, responseBody, responseHeaders, status, token, rawUrl, } = config;
49
49
  if (process.env.NODE_ENV === "development")
50
50
  return;
@@ -56,6 +56,7 @@ async function arkynLogRequest(config) {
56
56
  const body = JSON.stringify({
57
57
  domainUrl: url.protocol + "//" + url.host,
58
58
  pathnameUrl: url.pathname,
59
+ trafficSourceId: trafficSourceId,
59
60
  status,
60
61
  protocol,
61
62
  method,
@@ -67,12 +68,12 @@ async function arkynLogRequest(config) {
67
68
  responseHeaders,
68
69
  responseBody,
69
70
  });
70
- await fetch(arkynApiUrl.replace(":trafficSourceId", arkynService.arkynTrafficSourceId), {
71
+ await fetch(apiUrl, {
71
72
  method: "POST",
72
73
  body,
73
74
  headers: {
74
75
  "Content-Type": "application/json",
75
- Authorization: `Bearer ${arkynUserToken}`,
76
+ Authorization: `Bearer ${userToken}`,
76
77
  },
77
78
  });
78
79
  }
package/dist/bundle.js CHANGED
@@ -1,10 +1,10 @@
1
- var U = Object.defineProperty;
2
- var C = (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) => C(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 v from "node:dns";
7
- import { countries as j } from "@arkyn/templates";
6
+ import "node:dns";
7
+ import { countries as U } 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,8 +22,8 @@ function g(e) {
22
22
  }), console.log(c);
23
23
  }
24
24
  }
25
- const k = {};
26
- class $ {
25
+ const A = {};
26
+ class I {
27
27
  /**
28
28
  * Sets the file name to be ignored during stack trace analysis.
29
29
  *
@@ -62,10 +62,10 @@ class $ {
62
62
  * The name of the file to ignore when analyzing the stack trace.
63
63
  * When set, the `getCaller` function will skip stack frames containing this file name.
64
64
  */
65
- o($, "ignoreFiles", []);
65
+ o(I, "ignoreFiles", []);
66
66
  function E() {
67
67
  const e = process.cwd(), n = (new Error().stack || "").split(`
68
- `).map((u) => u.trim()), r = $.ignoreFiles;
68
+ `).map((u) => u.trim()), r = I.ignoreFiles;
69
69
  let a = 2;
70
70
  for (; a < n.length && (n[a].includes("node:internal") || n[a].includes("/node_modules/")); )
71
71
  a++;
@@ -92,18 +92,18 @@ function E() {
92
92
  i.lastIndexOf(")")
93
93
  )), i = i.split(":").slice(0, -2).join(":");
94
94
  try {
95
- i = k.relative(e, i);
95
+ i = A.relative(e, i);
96
96
  } catch {
97
97
  }
98
98
  return { functionName: h, callerInfo: i };
99
99
  }
100
- class y {
100
+ class p {
101
101
  onDebug(t) {
102
102
  const { name: s, body: n, cause: r, message: a } = t, c = [], { callerInfo: h, functionName: i } = E();
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 J extends y {
106
+ class L extends p {
107
107
  /**
108
108
  * Creates an instance of the `BadGateway` class.
109
109
  *
@@ -151,7 +151,7 @@ class J extends y {
151
151
  return Response.json(this.body, s);
152
152
  }
153
153
  }
154
- class b extends y {
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 y {
199
199
  return Response.json(this.body, s);
200
200
  }
201
201
  }
202
- class L extends y {
202
+ class B extends p {
203
203
  /**
204
204
  * Creates an instance of the `Conflict` class.
205
205
  *
@@ -247,7 +247,7 @@ class L extends y {
247
247
  return Response.json(this.body, s);
248
248
  }
249
249
  }
250
- class B extends y {
250
+ class k extends p {
251
251
  /**
252
252
  * Creates an instance of the `Forbidden` class.
253
253
  *
@@ -295,7 +295,7 @@ class B extends y {
295
295
  return Response.json(this.body, s);
296
296
  }
297
297
  }
298
- class H extends y {
298
+ class H extends p {
299
299
  /**
300
300
  * Creates an instance of the `NotFound` class.
301
301
  *
@@ -343,7 +343,7 @@ class H extends y {
343
343
  return Response.json(this.body, s);
344
344
  }
345
345
  }
346
- class q extends y {
346
+ class q extends p {
347
347
  /**
348
348
  * Creates an instance of the `NotImplemented` class.
349
349
  *
@@ -391,7 +391,7 @@ class q extends y {
391
391
  return Response.json(this.body, s);
392
392
  }
393
393
  }
394
- class x extends y {
394
+ class x extends p {
395
395
  /**
396
396
  * Creates an instance of the `ServerError` class.
397
397
  *
@@ -439,7 +439,7 @@ class x extends y {
439
439
  return Response.json(this.body, s);
440
440
  }
441
441
  }
442
- class F extends y {
442
+ class F extends p {
443
443
  /**
444
444
  * Creates an instance of the `Unauthorized` class.
445
445
  *
@@ -487,7 +487,7 @@ class F extends y {
487
487
  return Response.json(this.body, s);
488
488
  }
489
489
  }
490
- class R extends y {
490
+ class R extends p {
491
491
  /**
492
492
  * Creates an instance of the `UnprocessableEntity` class.
493
493
  *
@@ -803,7 +803,7 @@ class V {
803
803
  };
804
804
  }
805
805
  }
806
- class I {
806
+ class C {
807
807
  /**
808
808
  * Sets the configuration for the arkyn. This method initializes the arkyn configuration
809
809
  * with the provided `arkynConfig` values. If the configuration has already been set,
@@ -817,11 +817,11 @@ class I {
817
817
  */
818
818
  static setArkynConfig(t) {
819
819
  if (this.arkynConfig) return;
820
- let n = t.arkynLogBaseApiUrl || "https://logs-arkyn-flow-logs.vw6wo7.easypanel.host";
821
- n = n + "/http-traffic-records/:trafficSourceId", this.arkynConfig = {
822
- arkynTrafficSourceId: t.arkynTrafficSourceId,
823
- arkynUserToken: t.arkynUserToken,
824
- arkynApiUrl: n
820
+ const { trafficSourceId: s, userToken: n, logBaseApiUrl: r } = t;
821
+ this.arkynConfig = {
822
+ trafficSourceId: s,
823
+ userToken: n,
824
+ apiUrl: r || "http://95.216.190.158:8080/ingest-log"
825
825
  };
826
826
  }
827
827
  /**
@@ -841,64 +841,59 @@ class I {
841
841
  this.arkynConfig = void 0;
842
842
  }
843
843
  }
844
- o(I, "arkynConfig");
844
+ o(C, "arkynConfig");
845
845
  async function G(e) {
846
- const t = I.getArkynConfig();
846
+ const t = C.getArkynConfig();
847
847
  if (!t) return;
848
- const { arkynUserToken: s, arkynApiUrl: n } = t, {
849
- elapsedTime: r,
850
- method: a,
851
- queryParams: c,
852
- requestBody: h,
853
- requestHeaders: i,
854
- responseBody: l,
855
- responseHeaders: u,
856
- status: d,
857
- token: A,
858
- rawUrl: f
848
+ const { userToken: s, apiUrl: n, trafficSourceId: r } = t, {
849
+ elapsedTime: a,
850
+ method: c,
851
+ queryParams: h,
852
+ requestBody: i,
853
+ requestHeaders: l,
854
+ responseBody: u,
855
+ responseHeaders: d,
856
+ status: S,
857
+ token: f,
858
+ rawUrl: j
859
859
  } = e;
860
860
  if (process.env.NODE_ENV !== "development")
861
861
  try {
862
- const p = new URL(f);
863
- let S = "HTTPS";
864
- p.protocol === "http:" && (S = "HTTP");
865
- const w = JSON.stringify({
866
- domainUrl: p.protocol + "//" + p.host,
867
- pathnameUrl: p.pathname,
868
- status: d,
869
- protocol: S,
870
- method: a,
862
+ const y = new URL(j);
863
+ let D = "HTTPS";
864
+ y.protocol === "http:" && (D = "HTTP");
865
+ const J = JSON.stringify({
866
+ domainUrl: y.protocol + "//" + y.host,
867
+ pathnameUrl: y.pathname,
868
+ trafficSourceId: r,
869
+ status: S,
870
+ protocol: D,
871
+ method: c,
871
872
  trafficUserId: null,
872
- elapsedTime: r,
873
- requestHeaders: i,
874
- requestBody: h,
875
- queryParams: c,
876
- responseHeaders: u,
877
- responseBody: l
873
+ elapsedTime: a,
874
+ requestHeaders: l,
875
+ requestBody: i,
876
+ queryParams: h,
877
+ responseHeaders: d,
878
+ responseBody: u
878
879
  });
879
- await fetch(
880
- n.replace(
881
- ":trafficSourceId",
882
- t.arkynTrafficSourceId
883
- ),
884
- {
885
- method: "POST",
886
- body: w,
887
- headers: {
888
- "Content-Type": "application/json",
889
- Authorization: `Bearer ${s}`
890
- }
880
+ await fetch(n, {
881
+ method: "POST",
882
+ body: J,
883
+ headers: {
884
+ "Content-Type": "application/json",
885
+ Authorization: `Bearer ${s}`
891
886
  }
892
- );
893
- } catch (p) {
887
+ });
888
+ } catch (y) {
894
889
  g({
895
- debugs: [`Error sending request: ${p}`],
890
+ debugs: [`Error sending request: ${y}`],
896
891
  name: "ARKYN_LOG_ERROR",
897
892
  scheme: "red"
898
893
  });
899
894
  }
900
895
  }
901
- async function T(e, t, s = {}, n) {
896
+ async function b(e, t, s = {}, n) {
902
897
  const r = {
903
898
  POST: "Resource created successfully",
904
899
  PUT: "Resource updated successfully",
@@ -957,21 +952,21 @@ async function T(e, t, s = {}, n) {
957
952
  }
958
953
  }
959
954
  async function Z(e, t = {}, s) {
960
- return T("DELETE", e, t, s);
955
+ return b("DELETE", e, t, s);
961
956
  }
962
957
  async function W(e, t = {}) {
963
- return T("GET", e, t);
958
+ return b("GET", e, t);
964
959
  }
965
960
  async function K(e, t = {}, s) {
966
- return T("PATCH", e, t, s);
961
+ return b("PATCH", e, t, s);
967
962
  }
968
963
  async function Q(e, t = {}, s) {
969
- return T("POST", e, t, s);
964
+ return b("POST", e, t, s);
970
965
  }
971
966
  async function X(e, t = {}, s) {
972
- return T("PUT", e, t, s);
967
+ return b("PUT", e, t, s);
973
968
  }
974
- class Ss {
969
+ class xs {
975
970
  /**
976
971
  * Creates an instance of ApiService.
977
972
  * @param props - The configuration properties for the API instance.
@@ -1062,11 +1057,11 @@ class Ss {
1062
1057
  return this.onDebug(t, "delete", [r, a]), await Z(n, r, a);
1063
1058
  }
1064
1059
  }
1065
- function Ds(e, t) {
1060
+ function Rs(e, t) {
1066
1061
  var s, n, r;
1067
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";
1068
1063
  }
1069
- const Os = async (e) => {
1064
+ const Ns = async (e) => {
1070
1065
  let t;
1071
1066
  const s = await e.arrayBuffer(), n = new TextDecoder().decode(s);
1072
1067
  try {
@@ -1077,14 +1072,14 @@ const Os = async (e) => {
1077
1072
  const a = new URLSearchParams(n);
1078
1073
  t = Object.fromEntries(a.entries());
1079
1074
  } else
1080
- throw new b("Invalid URLSearchParams format");
1075
+ throw new T("Invalid URLSearchParams format");
1081
1076
  } catch {
1082
- throw new b("Failed to extract data from request");
1077
+ throw new T("Failed to extract data from request");
1083
1078
  }
1084
1079
  }
1085
1080
  return t;
1086
1081
  };
1087
- function $s(e) {
1082
+ function Es(e) {
1088
1083
  switch (!0) {
1089
1084
  case e instanceof Response:
1090
1085
  return e;
@@ -1100,14 +1095,14 @@ function $s(e) {
1100
1095
  return e.toResponse();
1101
1096
  }
1102
1097
  switch (!0) {
1103
- case e instanceof J:
1104
- return e.toResponse();
1105
- case e instanceof b:
1106
- return e.toResponse();
1107
1098
  case e instanceof L:
1108
1099
  return e.toResponse();
1100
+ case e instanceof T:
1101
+ return e.toResponse();
1109
1102
  case e instanceof B:
1110
1103
  return e.toResponse();
1104
+ case e instanceof k:
1105
+ return e.toResponse();
1111
1106
  case e instanceof H:
1112
1107
  return e.toResponse();
1113
1108
  case e instanceof q:
@@ -1161,7 +1156,7 @@ function es([
1161
1156
  data: s.data
1162
1157
  };
1163
1158
  }
1164
- const Is = (e, t = "") => {
1159
+ const Ss = (e, t = "") => {
1165
1160
  const s = new URL(e.url);
1166
1161
  if (t === "") return s.searchParams;
1167
1162
  const n = Array.from(
@@ -1176,7 +1171,7 @@ function ts(e) {
1176
1171
  return [t, ...s].join(`
1177
1172
  `);
1178
1173
  }
1179
- class As {
1174
+ class Ds {
1180
1175
  /**
1181
1176
  * Creates a new SchemaValidator instance.
1182
1177
  *
@@ -1333,7 +1328,7 @@ class As {
1333
1328
  return n.data;
1334
1329
  }
1335
1330
  }
1336
- const ws = (e) => {
1331
+ const $s = (e) => {
1337
1332
  if (!e || !/^[0-9-]+$/.test(e)) return !1;
1338
1333
  const s = N(e), n = 8, r = /^\d{8}$/.test(s);
1339
1334
  return s.length === n && r;
@@ -1345,7 +1340,7 @@ function rs(e) {
1345
1340
  const [t] = e;
1346
1341
  return [...e].every((s) => s === t);
1347
1342
  }
1348
- function D(e, t) {
1343
+ function $(e, t) {
1349
1344
  let s = 0;
1350
1345
  for (let r = 0; r < t.length; r++)
1351
1346
  s += parseInt(e[r]) * t[r];
@@ -1355,11 +1350,11 @@ function D(e, t) {
1355
1350
  function os(e) {
1356
1351
  return e.slice(12);
1357
1352
  }
1358
- const Us = (e) => {
1353
+ const Os = (e) => {
1359
1354
  if (!e) return !1;
1360
1355
  const t = N(e);
1361
1356
  if (ns(t) || rs(t)) return !1;
1362
- const s = t.slice(0, 12), n = D(s, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), r = D(
1357
+ const s = t.slice(0, 12), n = $(s, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), r = $(
1363
1358
  s + n,
1364
1359
  [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
1365
1360
  );
@@ -1382,13 +1377,13 @@ function O(e, t) {
1382
1377
  function is(e) {
1383
1378
  return e.slice(9);
1384
1379
  }
1385
- const Cs = (e) => {
1380
+ const Is = (e) => {
1386
1381
  if (!e) return !1;
1387
1382
  const t = N(e);
1388
1383
  if (as(t) || us(t)) return !1;
1389
1384
  const s = O(t, 10), n = O(t, 11);
1390
1385
  return is(t) === `${s}${n}`;
1391
- }, vs = (e, t) => {
1386
+ }, Cs = (e, t) => {
1392
1387
  let s, n, r;
1393
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;
1394
1389
  if (a === "DD/MM/YYYY") {
@@ -1414,55 +1409,40 @@ const Cs = (e) => {
1414
1409
  } else if (i > d[l - 1])
1415
1410
  return !1;
1416
1411
  return u < c || u > h ? !1 : new Date(u, l - 1, i).getDate() === i;
1417
- }, cs = v.promises.resolve;
1418
- function hs(e) {
1412
+ };
1413
+ function cs(e) {
1419
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);
1420
1415
  }
1421
- function ls(e) {
1416
+ function hs(e) {
1422
1417
  return !(e.length === 0 || e.length > 64 || e.startsWith(".") || e.endsWith(".") || e.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e));
1423
1418
  }
1424
- function fs(e) {
1419
+ function ls(e) {
1425
1420
  return !(e.length === 0 || e.length > 63 || e.startsWith("-") || e.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(e));
1426
1421
  }
1427
- function ds(e) {
1422
+ function fs(e) {
1428
1423
  if (e.length === 0 || e.length > 253 || e.startsWith(".") || e.endsWith(".") || e.startsWith("-") || e.endsWith("-"))
1429
1424
  return !1;
1430
1425
  const t = e.split(".");
1431
1426
  if (t.length < 2) return !1;
1432
- for (const n of t) if (!fs(n)) return !1;
1427
+ for (const n of t) if (!ls(n)) return !1;
1433
1428
  const s = t[t.length - 1];
1434
1429
  return !(s.length < 2 || !/^[a-zA-Z]+$/.test(s));
1435
1430
  }
1436
- function ys(e) {
1431
+ function ds(e) {
1437
1432
  const t = e.split("@");
1438
1433
  if (t.length !== 2) return !1;
1439
1434
  const [s, n] = t;
1440
- return !(!ls(s) || !ds(n));
1435
+ return !(!hs(s) || !fs(n));
1441
1436
  }
1442
1437
  function ps(e) {
1443
1438
  const t = e.split("@");
1444
1439
  return t.length === 2 ? t[1].toLowerCase() : null;
1445
1440
  }
1446
- const gs = ["MX", "A", "AAAA"];
1447
- async function ms(e, t) {
1448
- try {
1449
- return await cs(e, t), !0;
1450
- } catch {
1451
- return !1;
1452
- }
1453
- }
1454
- async function Ts(e) {
1455
- for (const t of gs)
1456
- if (await ms(e, t)) return !0;
1457
- return !1;
1458
- }
1459
1441
  const js = async (e) => {
1460
1442
  if (!e || typeof e != "string") return !1;
1461
1443
  const t = e.trim();
1462
- if (!hs(t) || !ys(t)) return !1;
1463
- const s = ps(t);
1464
- return s ? await Ts(s) : !1;
1465
- }, ks = (e) => {
1444
+ return !(!cs(t) || !ds(t) || !ps(t));
1445
+ }, Js = (e) => {
1466
1446
  if (!e) return !1;
1467
1447
  const t = e.length >= 8, s = /[A-Z]/.test(e), n = /[a-z]/.test(e), r = /\d/.test(e), a = /[!@#$%^&*(),.?":{}|<>_\-+=~`[\]\\\/]/.test(
1468
1448
  e
@@ -1474,8 +1454,8 @@ const js = async (e) => {
1474
1454
  r,
1475
1455
  a
1476
1456
  ].every((c) => c);
1477
- }, Js = (e) => {
1478
- for (const t of j) {
1457
+ }, vs = (e) => {
1458
+ for (const t of U) {
1479
1459
  const s = t.code, n = t.prefix ? `-${t.prefix}` : "", r = t.mask.replace(/[^_]/g, "").length;
1480
1460
  if (t.iso === "BR") {
1481
1461
  if (new RegExp(`^\\${s} \\d{2}9?\\d{8}$`).test(e)) return !0;
@@ -1484,44 +1464,44 @@ const js = async (e) => {
1484
1464
  if (new RegExp(`^\\${s}${n} \\d{${r}}$`).test(e)) return !0;
1485
1465
  }
1486
1466
  return !1;
1487
- }, Ls = (e) => {
1467
+ }, ws = (e) => {
1488
1468
  if (!e || !/^[0-9a-zA-Z.-]+$/.test(e)) return !1;
1489
1469
  const s = e.replace(/[^a-zA-Z0-9]/g, "");
1490
1470
  return s.length < 7 || s.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(s);
1491
1471
  };
1492
1472
  export {
1493
- Ss as ApiService,
1494
- I as ArkynLogService,
1495
- J as BadGateway,
1496
- b as BadRequest,
1497
- L as Conflict,
1473
+ xs as ApiService,
1474
+ C as ArkynLogService,
1475
+ L as BadGateway,
1476
+ T as BadRequest,
1477
+ B as Conflict,
1498
1478
  P as Created,
1499
- $ as DebugService,
1500
- B as Forbidden,
1479
+ I as DebugService,
1480
+ k as Forbidden,
1501
1481
  Y as Found,
1502
1482
  z as NoContent,
1503
1483
  H as NotFound,
1504
1484
  q as NotImplemented,
1505
- As as SchemaValidator,
1485
+ Ds as SchemaValidator,
1506
1486
  x as ServerError,
1507
1487
  M as Success,
1508
1488
  F as Unauthorized,
1509
1489
  R as UnprocessableEntity,
1510
1490
  _ as Updated,
1511
- Ds as decodeErrorMessageFromRequest,
1512
- Os as decodeRequestBody,
1513
- $s as errorHandler,
1491
+ Rs as decodeErrorMessageFromRequest,
1492
+ Ns as decodeRequestBody,
1493
+ Es as errorHandler,
1514
1494
  g as flushDebugLogs,
1515
1495
  ss as formAsyncParse,
1516
1496
  es as formParse,
1517
1497
  E as getCaller,
1518
- Is as getScopedParams,
1519
- ws as validateCep,
1520
- Us as validateCnpj,
1521
- Cs as validateCpf,
1522
- vs as validateDate,
1498
+ Ss as getScopedParams,
1499
+ $s as validateCep,
1500
+ Os as validateCnpj,
1501
+ Is as validateCpf,
1502
+ Cs as validateDate,
1523
1503
  js as validateEmail,
1524
- ks as validatePassword,
1525
- Js as validatePhone,
1526
- Ls as validateRg
1504
+ Js as validatePassword,
1505
+ vs as validatePhone,
1506
+ ws as validateRg
1527
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,M,Y){"use strict";var Us=Object.defineProperty;var ws=(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)=>ws(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()}
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
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 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=_.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 I 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 S 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 C 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 A 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 k 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 E 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 U 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
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 w 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 J 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 B 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;let n=t.arkynLogBaseApiUrl||"https://logs-arkyn-flow-logs.vw6wo7.easypanel.host";n=n+"/http-traffic-records/:trafficSourceId",this.arkynConfig={arkynTrafficSourceId:t.arkynTrafficSourceId,arkynUserToken:t.arkynUserToken,arkynApiUrl:n}}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{arkynUserToken:s,arkynApiUrl:n}=t,{elapsedTime:r,method:u,queryParams:h,requestBody:l,requestHeaders:c,responseBody:f,responseHeaders:i,status:g,token:As,rawUrl:y}=e;if(process.env.NODE_ENV!=="development")try{const b=new URL(y);let z="HTTPS";b.protocol==="http:"&&(z="HTTP");const ks=JSON.stringify({domainUrl:b.protocol+"//"+b.host,pathnameUrl:b.pathname,status:g,protocol:z,method:u,trafficUserId:null,elapsedTime:r,requestHeaders:c,requestBody:l,queryParams:h,responseHeaders:i,responseBody:f});await fetch(n.replace(":trafficSourceId",t.arkynTrafficSourceId),{method:"POST",body:ks,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=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(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 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),u=s==null?void 0:s.body;return this.onDebug(t,"post",[r,u]),await Q(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 X(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 K(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 Z(n,r,u)}}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 u=new URLSearchParams(n);t=Object.fromEntries(u.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 j:return e.toResponse();case e instanceof w:return e.toResponse();case e instanceof B:return e.toResponse();case e instanceof L:return e.toResponse();case e instanceof J:return e.toResponse()}switch(!0){case e instanceof I:return e.toResponse();case e instanceof S:return e.toResponse();case e instanceof $:return e.toResponse();case e instanceof C:return e.toResponse();case e instanceof A:return e.toResponse();case e instanceof k:return e.toResponse();case e instanceof E:return e.toResponse();case e instanceof U:return e.toResponse();case e instanceof D:return e.toResponse()}return new E("Server error",e).toResponse()}async function q([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,u])=>[r.replace(`${t}:`,""),u]);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 q([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 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},ms=M.promises.resolve;function Ts(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 Rs(e){return!(e.length===0||e.length>63||e.startsWith("-")||e.endsWith("-")||!/^[a-zA-Z0-9-]+$/.test(e))}function xs(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(!Rs(n))return!1;const s=t[t.length-1];return!(s.length<2||!/^[a-zA-Z]+$/.test(s))}function Ns(e){const t=e.split("@");if(t.length!==2)return!1;const[s,n]=t;return!(!bs(s)||!xs(n))}function Ss(e){const t=e.split("@");return t.length===2?t[1].toLowerCase():null}const Es=["MX","A","AAAA"];async function Ds(e,t){try{return await ms(e,t),!0}catch{return!1}}async function vs(e){for(const t of Es)if(await Ds(e,t))return!0;return!1}const Os=async e=>{if(!e||typeof e!="string")return!1;const t=e.trim();if(!Ts(t)||!Ns(t))return!1;const s=Ss(t);return s?await vs(s):!1},Is=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)},$s=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},Cs=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=ss,a.ArkynLogService=O,a.BadGateway=I,a.BadRequest=S,a.Conflict=$,a.Created=w,a.DebugService=v,a.Forbidden=C,a.Found=j,a.NoContent=J,a.NotFound=A,a.NotImplemented=k,a.SchemaValidator=as,a.ServerError=E,a.Success=L,a.Unauthorized=U,a.UnprocessableEntity=D,a.Updated=B,a.decodeErrorMessageFromRequest=es,a.decodeRequestBody=ts,a.errorHandler=ns,a.flushDebugLogs=T,a.formAsyncParse=q,a.formParse=F,a.getCaller=N,a.getScopedParams=rs,a.validateCep=us,a.validateCnpj=ls,a.validateCpf=ps,a.validateDate=gs,a.validateEmail=Os,a.validatePassword=Is,a.validatePhone=$s,a.validateRg=Cs,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,12 +1,12 @@
1
1
  type ArkynConfigProps = {
2
- arkynTrafficSourceId: string;
3
- arkynUserToken: string;
4
- arkynApiUrl: string;
2
+ trafficSourceId: string;
3
+ userToken: string;
4
+ apiUrl: string;
5
5
  };
6
6
  type SetArkynConfigProps = {
7
- arkynTrafficSourceId: string;
8
- arkynUserToken: string;
9
- arkynLogBaseApiUrl?: string;
7
+ trafficSourceId: string;
8
+ userToken: string;
9
+ logBaseApiUrl?: string;
10
10
  };
11
11
  /**
12
12
  * The `ArkynLogService` class manages the configuration for the arkyn flow.
@@ -1 +1 @@
1
- {"version":3,"file":"arkynLogService.d.ts","sourceRoot":"","sources":["../../src/services/arkynLogService.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AAEH,cAAM,eAAe;IACnB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAmB;IAE9C;;;;;;;;;;OAUG;IAEH,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,mBAAmB;IAgBtD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,IAAI,gBAAgB,GAAG,SAAS;IAIrD;;;OAGG;IAEH,MAAM,CAAC,gBAAgB;CAGxB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"arkynLogService.d.ts","sourceRoot":"","sources":["../../src/services/arkynLogService.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AAEH,cAAM,eAAe;IACnB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAmB;IAE9C;;;;;;;;;;OAUG;IAEH,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,mBAAmB;IAYtD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,IAAI,gBAAgB,GAAG,SAAS;IAIrD;;;OAGG;IAEH,MAAM,CAAC,gBAAgB;CAGxB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -19,14 +19,11 @@ class ArkynLogService {
19
19
  static setArkynConfig(arkynConfig) {
20
20
  if (!!this.arkynConfig)
21
21
  return;
22
- let defaultArkynURL = `https://logs-arkyn-flow-logs.vw6wo7.easypanel.host`;
23
- let arkynLogBaseApiUrl = arkynConfig.arkynLogBaseApiUrl || defaultArkynURL;
24
- arkynLogBaseApiUrl =
25
- arkynLogBaseApiUrl + "/http-traffic-records/:trafficSourceId";
22
+ const { trafficSourceId, userToken, logBaseApiUrl } = arkynConfig;
26
23
  this.arkynConfig = {
27
- arkynTrafficSourceId: arkynConfig.arkynTrafficSourceId,
28
- arkynUserToken: arkynConfig.arkynUserToken,
29
- arkynApiUrl: arkynLogBaseApiUrl,
24
+ trafficSourceId,
25
+ userToken,
26
+ apiUrl: logBaseApiUrl || `http://95.216.190.158:8080/ingest-log`,
30
27
  };
31
28
  }
32
29
  /**
@@ -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.77",
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",