@arkyn/server 3.0.1-beta.120 → 3.0.1-beta.121

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
@@ -71,8 +71,8 @@ class S {
71
71
  const l = a.match(/at\s+(.+)/);
72
72
  if (l) {
73
73
  i = l[1];
74
- const p = i.match(/at\s+([^(\s]+)\s+/);
75
- p && p[1] !== "new" && (u = p[1]);
74
+ const d = i.match(/at\s+([^(\s]+)\s+/);
75
+ d && d[1] !== "new" && (u = d[1]);
76
76
  }
77
77
  }
78
78
  i.includes("(") && (i = i.substring(
@@ -91,7 +91,7 @@ class S {
91
91
  * When set, the `getCaller` function will skip stack frames containing this file name.
92
92
  */
93
93
  c(S, "ignoreFiles", []);
94
- function d(e) {
94
+ function p(e) {
95
95
  var t;
96
96
  if (process.env.NODE_ENV === "development" || ((t = process.env) == null ? void 0 : t.DEBUG_MODE) === "true") {
97
97
  const o = `${{
@@ -141,7 +141,7 @@ class f {
141
141
  }
142
142
  onDebug() {
143
143
  const s = [], { callerInfo: t, functionName: n } = S.getCaller();
144
- s.push(`Caller Function: ${n}`), s.push(`Caller Location: ${t}`), this._statusText && s.push(`Message: ${this._statusText}`), this._cause && s.push(`Cause: ${JSON.stringify(this._cause)}`), d({ scheme: "red", name: this._name, debugs: s });
144
+ s.push(`Caller Function: ${n}`), s.push(`Caller Location: ${t}`), this._statusText && s.push(`Message: ${this._statusText}`), this._cause && s.push(`Cause: ${JSON.stringify(this._cause)}`), p({ scheme: "red", name: this._name, debugs: s });
145
145
  }
146
146
  makeBody() {
147
147
  return {
@@ -544,7 +544,7 @@ class g {
544
544
  */
545
545
  onDebug(s) {
546
546
  const t = [], { callerInfo: n, functionName: r } = S.getCaller();
547
- t.push(`Caller Function: ${r}`), t.push(`Caller Location: ${n}`), this.statusText && t.push(`Message: ${this.statusText}`), s && t.push(`Body: ${JSON.stringify(s)}`), d({ scheme: "red", name: this.name, debugs: t });
547
+ t.push(`Caller Function: ${r}`), t.push(`Caller Location: ${n}`), this.statusText && t.push(`Message: ${this.statusText}`), s && t.push(`Body: ${JSON.stringify(s)}`), p({ scheme: "red", name: this.name, debugs: t });
548
548
  }
549
549
  makeBody() {
550
550
  return {
@@ -804,7 +804,7 @@ async function W(e) {
804
804
  requestBody: i,
805
805
  requestHeaders: h,
806
806
  responseBody: l,
807
- responseHeaders: p,
807
+ responseHeaders: d,
808
808
  status: v,
809
809
  token: xs,
810
810
  rawUrl: B
@@ -826,7 +826,7 @@ async function W(e) {
826
826
  requestHeaders: JSON.stringify(h),
827
827
  requestBody: JSON.stringify(i),
828
828
  queryParams: JSON.stringify(u),
829
- responseHeaders: JSON.stringify(p),
829
+ responseHeaders: JSON.stringify(d),
830
830
  responseBody: JSON.stringify(l)
831
831
  }), P = {
832
832
  "Content-Type": "application/json",
@@ -834,7 +834,7 @@ async function W(e) {
834
834
  };
835
835
  await fetch(n, { method: "POST", body: O, headers: P });
836
836
  } catch (m) {
837
- d({
837
+ p({
838
838
  debugs: [`Error sending request: ${m}`],
839
839
  name: "LogError",
840
840
  scheme: "red"
@@ -891,7 +891,7 @@ async function y(e) {
891
891
  cause: null
892
892
  };
893
893
  } catch (n) {
894
- return d({
894
+ return p({
895
895
  debugs: [`Network error or request failed: ${n}`],
896
896
  name: "MakeRequestError",
897
897
  scheme: "red"
@@ -958,8 +958,8 @@ class Es {
958
958
  }
959
959
  onDebug(s, t, n) {
960
960
  if (this.enableDebug) {
961
- const r = [], o = (a) => a ? JSON.stringify(a, null, 2) : null;
962
- r.push(`Base URL: ${this.baseUrl}`), r.push(`Endpoint: ${s}`), r.push(`Method: ${t}`), r.push(`Status: ${n.status}`), r.push(`Message: ${n.message}`), r.push(`Headers: ${o(n.headers)}`), r.push(`Body: ${o(n.body)}`), r.push(`Response: ${o(n.response)}`), d({ debugs: r, name: "ApiDebug", scheme: "yellow" });
961
+ const r = [], o = (a) => JSON.stringify(a, null, 2);
962
+ r.push(`Base URL: ${this.baseUrl}`), r.push(`Endpoint: ${s}`), r.push(`Status/Method: ${t} => ${n.status}`), r.push(`Message: ${n.message}`), n.headers && r.push(`Headers: ${o(n.headers)}`), n.body && r.push(`Body: ${o(n.body)}`), p({ debugs: r, name: "ApiDebug", scheme: "yellow" });
963
963
  }
964
964
  }
965
965
  generateHeaders(s, t) {
@@ -981,8 +981,7 @@ class Es {
981
981
  return this.onDebug(s, "get", {
982
982
  headers: n,
983
983
  message: r.message,
984
- status: r.status,
985
- response: r.response
984
+ status: r.status
986
985
  }), r;
987
986
  }
988
987
  /**
@@ -1002,8 +1001,7 @@ class Es {
1002
1001
  headers: n,
1003
1002
  body: r,
1004
1003
  message: o.message,
1005
- status: o.status,
1006
- response: o.response
1004
+ status: o.status
1007
1005
  }), o;
1008
1006
  }
1009
1007
  /**
@@ -1023,8 +1021,7 @@ class Es {
1023
1021
  headers: n,
1024
1022
  body: r,
1025
1023
  message: o.message,
1026
- status: o.status,
1027
- response: o.response
1024
+ status: o.status
1028
1025
  }), o;
1029
1026
  }
1030
1027
  /**
@@ -1044,8 +1041,7 @@ class Es {
1044
1041
  headers: n,
1045
1042
  body: r,
1046
1043
  message: o.message,
1047
- status: o.status,
1048
- response: o.response
1044
+ status: o.status
1049
1045
  }), o;
1050
1046
  }
1051
1047
  /**
@@ -1065,8 +1061,7 @@ class Es {
1065
1061
  headers: n,
1066
1062
  body: r,
1067
1063
  message: o.message,
1068
- status: o.status,
1069
- response: o.response
1064
+ status: o.status
1070
1065
  }), o;
1071
1066
  }
1072
1067
  }
@@ -1426,13 +1421,13 @@ function ms(e) {
1426
1421
  const t = s[s.length - 1];
1427
1422
  return !(t.length < 2 || !/^[a-zA-Z]+$/.test(t));
1428
1423
  }
1429
- function ps(e) {
1424
+ function ds(e) {
1430
1425
  const s = e.split("@");
1431
1426
  if (s.length !== 2) return !1;
1432
1427
  const [t, n] = s;
1433
1428
  return !(!ls(t) || !ms(n));
1434
1429
  }
1435
- function ds(e) {
1430
+ function ps(e) {
1436
1431
  const s = e.split("@");
1437
1432
  return s.length === 2 ? s[1].toLowerCase() : null;
1438
1433
  }
@@ -1453,8 +1448,8 @@ async function Ts(e) {
1453
1448
  async function _s(e) {
1454
1449
  if (!e || typeof e != "string") return !1;
1455
1450
  const s = e.trim();
1456
- if (!hs(s) || !ps(s)) return !1;
1457
- const t = ds(s);
1451
+ if (!hs(s) || !ds(s)) return !1;
1452
+ const t = ps(s);
1458
1453
  return t ? await Ts(t) : !1;
1459
1454
  }
1460
1455
  function Is(e) {
@@ -1508,7 +1503,7 @@ export {
1508
1503
  $s as decodeRequestBody,
1509
1504
  vs as decodeRequestErrorMessage,
1510
1505
  Bs as errorHandler,
1511
- d as flushDebugLogs,
1506
+ p as flushDebugLogs,
1512
1507
  es as formAsyncParse,
1513
1508
  ts as formParse,
1514
1509
  Os as getScopedParams,
@@ -1,5 +1,5 @@
1
1
  (function(i,h){typeof exports=="object"&&typeof module<"u"?h(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"],h):(i=typeof globalThis<"u"?globalThis:i||self,h(i["@arkyn/server"]={},null,i.shared,i.dns,i.templates))})(this,function(i,h,d,D,L){"use strict";var js=Object.defineProperty;var ws=(i,h,d)=>h in i?js(i,h,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[h]=d;var l=(i,h,d)=>ws(i,typeof h!="symbol"?h+"":h,d);const z={};class x{static setIgnoreFile(s){this.ignoreFiles.push(s)}static clearIgnoreFiles(){this.ignoreFiles=[]}static getCaller(){const s=process.cwd(),r=(new Error().stack||"").split(`
2
2
  `).map(g=>g.trim());let o=2;for(;o<r.length&&(r[o].includes("node:internal")||r[o].includes("/node_modules/"));)o++;if(this.ignoreFiles.length>0)for(;o<r.length&&this.ignoreFiles.some(g=>r[o].includes(g));)o++;const u=r[o]||"";let c="Unknown function",a="Unknown caller";const f=u.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);if(f)c=f[1],a=f[2];else{const g=u.match(/at\s+(.+)/);if(g){a=g[1];const R=a.match(/at\s+([^(\s]+)\s+/);R&&R[1]!=="new"&&(c=R[1])}}a.includes("(")&&(a=a.substring(a.indexOf("(")+1,a.lastIndexOf(")"))),a=a.split(":").slice(0,-2).join(":");try{a=z.relative(s,a)}catch{}return{functionName:c,callerInfo:a}}}l(x,"ignoreFiles",[]);function y(e){var t;if(process.env.NODE_ENV==="development"||((t=process.env)==null?void 0:t.DEBUG_MODE)==="true"){const o=`${{yellow:"\x1B[33m",cyan:"\x1B[36m",red:"\x1B[31m",green:"\x1B[32m"}[e.scheme]}[${e.name}]\x1B[0m`;let u=`
3
3
  `;e.debugs.forEach(c=>{u+=`${o} ${c.trim()}
4
- `}),console.log(u)}}class m{constructor(){l(this,"_cause");l(this,"_name","BadResponse");l(this,"_status",500);l(this,"_statusText","Unknown error")}get cause(){return this._cause}set cause(s){this._cause=s}get name(){return this._name}set name(s){this._name=s}get status(){return this._status}set status(s){this._status=s}get statusText(){return this._statusText}set statusText(s){this._statusText=s}onDebug(){const s=[],{callerInfo:t,functionName:n}=x.getCaller();s.push(`Caller Function: ${n}`),s.push(`Caller Location: ${t}`),this._statusText&&s.push(`Message: ${this._statusText}`),this._cause&&s.push(`Cause: ${JSON.stringify(this._cause)}`),y({scheme:"red",name:this._name,debugs:s})}makeBody(){return{name:this._name,message:this._statusText,cause:this._cause}}}class P extends m{constructor(s,t){super(),this.name="BadGateway",this.status=502,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class S extends m{constructor(s,t){super(),this.name="BadRequest",this.status=400,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class $ extends m{constructor(s,t){super(),this.name="Conflict",this.status=409,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class B extends m{constructor(s,t){super(),this.name="Forbidden",this.status=403,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class k extends m{constructor(s,t){super(),this.name="NotFound",this.status=404,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class O extends m{constructor(s,t){super(),this.name="NotImplemented",this.status=501,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class v extends m{constructor(s,t){super(),this.name="ServerError",this.status=500,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class j extends m{constructor(s,t){super(),this.name="Unauthorized",this.status=401,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class N extends m{constructor(s){super(),this.name="UnprocessableEntity",this.status=422,this.statusText=s.message||"Unprocessable entity",this.cause={data:s.data,fieldErrors:s.fieldErrors,fields:s.fields},this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class T{constructor(){l(this,"_body",null);l(this,"_name","SuccessResponse");l(this,"_status",200);l(this,"_statusText","OK")}get body(){return this._body}set body(s){this._body=s??null}get name(){return this._name}set name(s){this._name=s}get status(){return this._status}set status(s){this._status=s}get statusText(){return this._statusText}set statusText(s){this._statusText=s}onDebug(s){const t=[],{callerInfo:n,functionName:r}=x.getCaller();t.push(`Caller Function: ${r}`),t.push(`Caller Location: ${n}`),this.statusText&&t.push(`Message: ${this.statusText}`),s&&t.push(`Body: ${JSON.stringify(s)}`),y({scheme:"red",name:this.name,debugs:t})}makeBody(){return{name:this.name,message:this.statusText,body:this.body}}}class w extends T{constructor(s,t){super(),this.name="Created",this.status=201,this.statusText=s,this.body=t||void 0,this.onDebug()}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 T{constructor(s,t){super(),this.name="Found",this.status=302,this.statusText=s,this.body=t||void 0,this.onDebug()}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 T{constructor(s){super(),this.name="NoContent",this.status=204,this.statusText=s,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(null,s)}}class _ extends T{constructor(s,t){super(),this.name="Success",this.status=200,this.statusText=s,this.body=t||void 0,this.onDebug()}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 T{constructor(s,t){super(),this.name="Updated",this.status=200,this.statusText=s,this.body=t||void 0,this.onDebug()}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 M{static mapHeaders(s){return s instanceof Headers?Object.fromEntries(s.entries()):typeof s=="object"?Object.entries(s).reduce((t,[n,r])=>(typeof r=="string"?t[n]=r:Array.isArray(r)?t[n]=r.join(", "):t[n]=JSON.stringify(r),t),{}):{}}static mapQueryParams(s){const t={};return s.forEach((n,r)=>t[r]=n),t}static handle(s){return{rawUrl:s.rawUrl,status:s.status,method:s.method,token:null,elapsedTime:s.elapsedTime,requestHeaders:this.mapHeaders(s.requestHeaders),requestBody:s.requestBody||null,queryParams:{...this.mapQueryParams(s.queryParams),...s.urlParams},responseHeaders:this.mapHeaders(s.responseHeaders),responseBody:s.responseBody||null}}}class E{static setConfig(s){if(this.config)return;const{trafficSourceId:t,userToken:n,logBaseApiUrl:r}=s,u=`${r||"http://95.216.190.158:8081"}/ingest-log`;this.config={trafficSourceId:t,userToken:n,apiUrl:u}}static getConfig(){return this.config}static resetConfig(){this.config=void 0}}l(E,"config");async function V(e){const s=E.getConfig();if(!s)return;const{userToken:t,apiUrl:n,trafficSourceId:r}=s,{elapsedTime:o,method:u,queryParams:c,requestBody:a,requestHeaders:f,responseBody:g,responseHeaders:R,status:$s,token:Js,rawUrl:Bs}=e;if(process.env.NODE_ENV!=="development")try{const p=new URL(Bs);let F="https";p.protocol==="http:"&&(F="http");const ks=JSON.stringify({domainUrl:p.protocol+"//"+p.host,pathnameUrl:p.pathname,trafficSourceId:r,status:$s,protocol:F,method:u.toLowerCase(),trafficUserId:null,elapsedTime:o,requestHeaders:JSON.stringify(f),requestBody:JSON.stringify(a),queryParams:JSON.stringify(c),responseHeaders:JSON.stringify(R),responseBody:JSON.stringify(g)}),Os={"Content-Type":"application/json",Authorization:`Bearer ${t}`};await fetch(n,{method:"POST",body:ks,headers:Os})}catch(p){y({debugs:[`Error sending request: ${p}`],name:"LogError",scheme:"red"})}}async function b(e){let s=e.url;e.urlParams&&Object.entries(e.urlParams).forEach(([n,r])=>{s=s.replaceAll(`:${n}`,r)});const t={POST:"Resource created successfully",PUT:"Resource updated successfully",DELETE:"Resource deleted successfully",PATCH:"Resource patched successfully",GET:"Request successful"};try{const n=performance.now(),r={...e.headers,"Content-Type":"application/json"},o=await fetch(s,{headers:r,method:e.method,body:e.body?JSON.stringify(e.body):void 0}),u=performance.now()-n,c=o.status;let a=null;try{a=await o.json()}catch{a=null}const f=M.handle({elapsedTime:u,method:e.method,queryParams:new URL(s).searchParams,requestHeaders:r,requestBody:e.body,responseBody:a,responseHeaders:o.headers,status:c,rawUrl:e.url,urlParams:e.urlParams});return V(f),o.ok?{success:!0,status:c,message:(a==null?void 0:a.message)||t[e.method],response:a,cause:null}:{success:!1,status:c,message:(a==null?void 0:a.message)||o.statusText||"Request failed",response:a,cause:null}}catch(n){return y({debugs:[`Network error or request failed: ${n}`],name:"MakeRequestError",scheme:"red"}),{success:!1,status:0,message:"Network error or request failed",response:null,cause:n instanceof Error?n.message:String(n)}}}async function Z(e){return b({method:"DELETE",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}async function G(e){return b({method:"GET",url:e.url,urlParams:e.urlParams,headers:e.headers})}async function W(e){return b({method:"PATCH",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}async function Y(e){return b({method:"POST",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}async function K(e){return b({method:"PUT",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}class Q{constructor(s){l(this,"baseUrl");l(this,"baseHeaders");l(this,"baseToken");l(this,"enableDebug");this.baseUrl=s.baseUrl,this.baseHeaders=s.baseHeaders||void 0,this.baseToken=s.baseToken||void 0,this.enableDebug=s.enableDebug||!1}onDebug(s,t,n){if(this.enableDebug){const r=[],o=u=>u?JSON.stringify(u,null,2):null;r.push(`Base URL: ${this.baseUrl}`),r.push(`Endpoint: ${s}`),r.push(`Method: ${t}`),r.push(`Status: ${n.status}`),r.push(`Message: ${n.message}`),r.push(`Headers: ${o(n.headers)}`),r.push(`Body: ${o(n.body)}`),r.push(`Response: ${o(n.response)}`),y({debugs:r,name:"ApiDebug",scheme:"yellow"})}}generateHeaders(s,t){let n={};return this.baseToken&&(n={Authorization:`Bearer ${this.baseToken}`}),this.baseHeaders&&(n={...n,...this.baseHeaders}),s&&(n={...n,...s}),t&&(n={...n,Authorization:`Bearer ${t}`}),n}async get(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=await G({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n});return this.onDebug(s,"get",{headers:n,message:r.message,status:r.status,response:r.response}),r}async post(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await Y({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"post",{headers:n,body:r,message:o.message,status:o.status,response:o.response}),o}async put(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await K({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"put",{headers:n,body:r,message:o.message,status:o.status,response:o.response}),o}async patch(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await W({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"patch",{headers:n,body:r,message:o.message,status:o.status,response:o.response}),o}async delete(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await Z({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"delete",{headers:n,body:r,message:o.message,status:o.status,response:o.response}),o}}async function X(e){let s;const t=await e.arrayBuffer(),n=new TextDecoder().decode(t);try{s=JSON.parse(n)}catch{try{if(n.includes("=")){const o=new URLSearchParams(n);s=Object.fromEntries(o.entries())}else throw new S("Invalid URLSearchParams format")}catch{throw new S("Failed to extract data from request")}}return s}function ss(e,s){var t,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:(t=e==null?void 0:e.error)!=null&&t.message&&typeof((n=e==null?void 0:e.error)==null?void 0:n.message)=="string"?(r=e==null?void 0:e.error)==null?void 0:r.message:s!=null&&s.statusText&&typeof(s==null?void 0:s.statusText)=="string"?s==null?void 0:s.statusText:"Missing error message"}function es(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 I:return e.toResponse();case e instanceof _:return e.toResponse();case e instanceof C:return e.toResponse()}switch(!0){case e instanceof P:return e.toResponse();case e instanceof S:return e.toResponse();case e instanceof $:return e.toResponse();case e instanceof B:return e.toResponse();case e instanceof k:return e.toResponse();case e instanceof O:return e.toResponse();case e instanceof v:return e.toResponse();case e instanceof j:return e.toResponse();case e instanceof N:return e.toResponse()}return new v("Server error",e).toResponse()}async function U([e,s]){const t=await s.safeParseAsync(e);if(t.success===!1){const n=Object.fromEntries(t.error.issues.map(r=>[r.path.join("."),r.message]));return{success:t.success,fieldErrors:n,fields:e}}else return{success:t.success,data:t.data}}function q([e,s]){const t=s.safeParse(e);if(t.success===!1){const n=Object.fromEntries(t.error.issues.map(r=>[r.path.join("."),r.message]));return{success:t.success,fieldErrors:n,fields:e}}else return{success:t.success,data:t.data}}function ts(e,s=""){const t=new URL(e.url);if(s==="")return t.searchParams;const n=Array.from(t.searchParams.entries()).filter(([r])=>r.startsWith(`${s}:`)).map(([r,o])=>[r.replace(`${s}:`,""),o]);return new URLSearchParams(n)}function ns(e){const s="Error validating:",t=e.issues.map(({path:n,message:r})=>`-> ${n.join(".")}: ${r}`);return[s,...t].join(`
4
+ `}),console.log(u)}}class m{constructor(){l(this,"_cause");l(this,"_name","BadResponse");l(this,"_status",500);l(this,"_statusText","Unknown error")}get cause(){return this._cause}set cause(s){this._cause=s}get name(){return this._name}set name(s){this._name=s}get status(){return this._status}set status(s){this._status=s}get statusText(){return this._statusText}set statusText(s){this._statusText=s}onDebug(){const s=[],{callerInfo:t,functionName:n}=x.getCaller();s.push(`Caller Function: ${n}`),s.push(`Caller Location: ${t}`),this._statusText&&s.push(`Message: ${this._statusText}`),this._cause&&s.push(`Cause: ${JSON.stringify(this._cause)}`),y({scheme:"red",name:this._name,debugs:s})}makeBody(){return{name:this._name,message:this._statusText,cause:this._cause}}}class P extends m{constructor(s,t){super(),this.name="BadGateway",this.status=502,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class S extends m{constructor(s,t){super(),this.name="BadRequest",this.status=400,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class $ extends m{constructor(s,t){super(),this.name="Conflict",this.status=409,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class B extends m{constructor(s,t){super(),this.name="Forbidden",this.status=403,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class k extends m{constructor(s,t){super(),this.name="NotFound",this.status=404,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class O extends m{constructor(s,t){super(),this.name="NotImplemented",this.status=501,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class v extends m{constructor(s,t){super(),this.name="ServerError",this.status=500,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class j extends m{constructor(s,t){super(),this.name="Unauthorized",this.status=401,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class N extends m{constructor(s){super(),this.name="UnprocessableEntity",this.status=422,this.statusText=s.message||"Unprocessable entity",this.cause={data:s.data,fieldErrors:s.fieldErrors,fields:s.fields},this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class T{constructor(){l(this,"_body",null);l(this,"_name","SuccessResponse");l(this,"_status",200);l(this,"_statusText","OK")}get body(){return this._body}set body(s){this._body=s??null}get name(){return this._name}set name(s){this._name=s}get status(){return this._status}set status(s){this._status=s}get statusText(){return this._statusText}set statusText(s){this._statusText=s}onDebug(s){const t=[],{callerInfo:n,functionName:r}=x.getCaller();t.push(`Caller Function: ${r}`),t.push(`Caller Location: ${n}`),this.statusText&&t.push(`Message: ${this.statusText}`),s&&t.push(`Body: ${JSON.stringify(s)}`),y({scheme:"red",name:this.name,debugs:t})}makeBody(){return{name:this.name,message:this.statusText,body:this.body}}}class w extends T{constructor(s,t){super(),this.name="Created",this.status=201,this.statusText=s,this.body=t||void 0,this.onDebug()}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 T{constructor(s,t){super(),this.name="Found",this.status=302,this.statusText=s,this.body=t||void 0,this.onDebug()}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 T{constructor(s){super(),this.name="NoContent",this.status=204,this.statusText=s,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(null,s)}}class _ extends T{constructor(s,t){super(),this.name="Success",this.status=200,this.statusText=s,this.body=t||void 0,this.onDebug()}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 T{constructor(s,t){super(),this.name="Updated",this.status=200,this.statusText=s,this.body=t||void 0,this.onDebug()}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 M{static mapHeaders(s){return s instanceof Headers?Object.fromEntries(s.entries()):typeof s=="object"?Object.entries(s).reduce((t,[n,r])=>(typeof r=="string"?t[n]=r:Array.isArray(r)?t[n]=r.join(", "):t[n]=JSON.stringify(r),t),{}):{}}static mapQueryParams(s){const t={};return s.forEach((n,r)=>t[r]=n),t}static handle(s){return{rawUrl:s.rawUrl,status:s.status,method:s.method,token:null,elapsedTime:s.elapsedTime,requestHeaders:this.mapHeaders(s.requestHeaders),requestBody:s.requestBody||null,queryParams:{...this.mapQueryParams(s.queryParams),...s.urlParams},responseHeaders:this.mapHeaders(s.responseHeaders),responseBody:s.responseBody||null}}}class E{static setConfig(s){if(this.config)return;const{trafficSourceId:t,userToken:n,logBaseApiUrl:r}=s,u=`${r||"http://95.216.190.158:8081"}/ingest-log`;this.config={trafficSourceId:t,userToken:n,apiUrl:u}}static getConfig(){return this.config}static resetConfig(){this.config=void 0}}l(E,"config");async function V(e){const s=E.getConfig();if(!s)return;const{userToken:t,apiUrl:n,trafficSourceId:r}=s,{elapsedTime:o,method:u,queryParams:c,requestBody:a,requestHeaders:f,responseBody:g,responseHeaders:R,status:$s,token:Js,rawUrl:Bs}=e;if(process.env.NODE_ENV!=="development")try{const p=new URL(Bs);let F="https";p.protocol==="http:"&&(F="http");const ks=JSON.stringify({domainUrl:p.protocol+"//"+p.host,pathnameUrl:p.pathname,trafficSourceId:r,status:$s,protocol:F,method:u.toLowerCase(),trafficUserId:null,elapsedTime:o,requestHeaders:JSON.stringify(f),requestBody:JSON.stringify(a),queryParams:JSON.stringify(c),responseHeaders:JSON.stringify(R),responseBody:JSON.stringify(g)}),Os={"Content-Type":"application/json",Authorization:`Bearer ${t}`};await fetch(n,{method:"POST",body:ks,headers:Os})}catch(p){y({debugs:[`Error sending request: ${p}`],name:"LogError",scheme:"red"})}}async function b(e){let s=e.url;e.urlParams&&Object.entries(e.urlParams).forEach(([n,r])=>{s=s.replaceAll(`:${n}`,r)});const t={POST:"Resource created successfully",PUT:"Resource updated successfully",DELETE:"Resource deleted successfully",PATCH:"Resource patched successfully",GET:"Request successful"};try{const n=performance.now(),r={...e.headers,"Content-Type":"application/json"},o=await fetch(s,{headers:r,method:e.method,body:e.body?JSON.stringify(e.body):void 0}),u=performance.now()-n,c=o.status;let a=null;try{a=await o.json()}catch{a=null}const f=M.handle({elapsedTime:u,method:e.method,queryParams:new URL(s).searchParams,requestHeaders:r,requestBody:e.body,responseBody:a,responseHeaders:o.headers,status:c,rawUrl:e.url,urlParams:e.urlParams});return V(f),o.ok?{success:!0,status:c,message:(a==null?void 0:a.message)||t[e.method],response:a,cause:null}:{success:!1,status:c,message:(a==null?void 0:a.message)||o.statusText||"Request failed",response:a,cause:null}}catch(n){return y({debugs:[`Network error or request failed: ${n}`],name:"MakeRequestError",scheme:"red"}),{success:!1,status:0,message:"Network error or request failed",response:null,cause:n instanceof Error?n.message:String(n)}}}async function Z(e){return b({method:"DELETE",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}async function G(e){return b({method:"GET",url:e.url,urlParams:e.urlParams,headers:e.headers})}async function W(e){return b({method:"PATCH",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}async function Y(e){return b({method:"POST",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}async function K(e){return b({method:"PUT",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}class Q{constructor(s){l(this,"baseUrl");l(this,"baseHeaders");l(this,"baseToken");l(this,"enableDebug");this.baseUrl=s.baseUrl,this.baseHeaders=s.baseHeaders||void 0,this.baseToken=s.baseToken||void 0,this.enableDebug=s.enableDebug||!1}onDebug(s,t,n){if(this.enableDebug){const r=[],o=u=>JSON.stringify(u,null,2);r.push(`Base URL: ${this.baseUrl}`),r.push(`Endpoint: ${s}`),r.push(`Status/Method: ${t} => ${n.status}`),r.push(`Message: ${n.message}`),n.headers&&r.push(`Headers: ${o(n.headers)}`),n.body&&r.push(`Body: ${o(n.body)}`),y({debugs:r,name:"ApiDebug",scheme:"yellow"})}}generateHeaders(s,t){let n={};return this.baseToken&&(n={Authorization:`Bearer ${this.baseToken}`}),this.baseHeaders&&(n={...n,...this.baseHeaders}),s&&(n={...n,...s}),t&&(n={...n,Authorization:`Bearer ${t}`}),n}async get(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=await G({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n});return this.onDebug(s,"get",{headers:n,message:r.message,status:r.status}),r}async post(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await Y({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"post",{headers:n,body:r,message:o.message,status:o.status}),o}async put(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await K({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"put",{headers:n,body:r,message:o.message,status:o.status}),o}async patch(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await W({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"patch",{headers:n,body:r,message:o.message,status:o.status}),o}async delete(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await Z({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"delete",{headers:n,body:r,message:o.message,status:o.status}),o}}async function X(e){let s;const t=await e.arrayBuffer(),n=new TextDecoder().decode(t);try{s=JSON.parse(n)}catch{try{if(n.includes("=")){const o=new URLSearchParams(n);s=Object.fromEntries(o.entries())}else throw new S("Invalid URLSearchParams format")}catch{throw new S("Failed to extract data from request")}}return s}function ss(e,s){var t,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:(t=e==null?void 0:e.error)!=null&&t.message&&typeof((n=e==null?void 0:e.error)==null?void 0:n.message)=="string"?(r=e==null?void 0:e.error)==null?void 0:r.message:s!=null&&s.statusText&&typeof(s==null?void 0:s.statusText)=="string"?s==null?void 0:s.statusText:"Missing error message"}function es(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 I:return e.toResponse();case e instanceof _:return e.toResponse();case e instanceof C:return e.toResponse()}switch(!0){case e instanceof P:return e.toResponse();case e instanceof S:return e.toResponse();case e instanceof $:return e.toResponse();case e instanceof B:return e.toResponse();case e instanceof k:return e.toResponse();case e instanceof O:return e.toResponse();case e instanceof v:return e.toResponse();case e instanceof j:return e.toResponse();case e instanceof N:return e.toResponse()}return new v("Server error",e).toResponse()}async function U([e,s]){const t=await s.safeParseAsync(e);if(t.success===!1){const n=Object.fromEntries(t.error.issues.map(r=>[r.path.join("."),r.message]));return{success:t.success,fieldErrors:n,fields:e}}else return{success:t.success,data:t.data}}function q([e,s]){const t=s.safeParse(e);if(t.success===!1){const n=Object.fromEntries(t.error.issues.map(r=>[r.path.join("."),r.message]));return{success:t.success,fieldErrors:n,fields:e}}else return{success:t.success,data:t.data}}function ts(e,s=""){const t=new URL(e.url);if(s==="")return t.searchParams;const n=Array.from(t.searchParams.entries()).filter(([r])=>r.startsWith(`${s}:`)).map(([r,o])=>[r.replace(`${s}:`,""),o]);return new URLSearchParams(n)}function ns(e){const s="Error validating:",t=e.issues.map(({path:n,message:r})=>`-> ${n.join(".")}: ${r}`);return[s,...t].join(`
5
5
  `)}class rs{constructor(s){this.schema=s}isValid(s){return this.schema.safeParse(s).success}safeValidate(s){return this.schema.safeParse(s)}validate(s){try{return this.schema.parse(s)}catch(t){throw new v(ns(t))}}formValidate(s,t){const n=q([s,this.schema]);if(!n.success){const r=Object.keys(n.fieldErrors)[0];throw new N({fields:n.fields,fieldErrors:n.fieldErrors,data:{scrollTo:r},message:t})}return n.data}async formAsyncValidate(s,t){const n=await U([s,this.schema]);if(!n.success){const r=Object.keys(n.fieldErrors)[0];throw new N({fields:n.fields,fieldErrors:n.fieldErrors,data:{scrollTo:r},message:t})}return n.data}}function os(e){if(!(/^\d{5}-\d{3}$/.test(e)||/^\d{8}$/.test(e)))return!1;const t=d.removeNonNumeric(e),n=8,r=/^\d{8}$/.test(t);return t.length===n&&r}function is(e){return e.length!==14}function as(e){const[s]=e;return[...e].every(t=>t===s)}function A(e,s){let t=0;for(let r=0;r<s.length;r++)t+=parseInt(e[r])*s[r];const n=t%11;return n<2?0:11-n}function us(e){return e.slice(12)}function cs(e){if(!e||e.length>18||e.length<14||/\s/.test(e))return!1;const t=d.removeNonNumeric(e);if(is(t)||as(t))return!1;const n=t.slice(0,12),r=A(n,[5,4,3,2,9,8,7,6,5,4,3,2]),o=A(n+r,[6,5,4,3,2,9,8,7,6,5,4,3,2]);return us(t)===`${r}${o}`}function ls(e){return e.length!==11}function hs(e){const[s]=e;return[...e].every(t=>t===s)}function H(e,s){let t=0;for(const r of e)s>1&&(t+=parseInt(r)*s--);const n=t%11;return n<2?0:11-n}function fs(e){return e.slice(9)}function ds(e){if(!e||e.length>14||e.length<11||/\s/.test(e))return!1;const t=d.removeNonNumeric(e);if(ls(t)||hs(t))return!1;const n=H(t,10),r=H(t,11);return fs(t)===`${n}${r}`}function ms(e,s){const t=(s==null?void 0:s.inputFormat)||"brazilianDate",n=(s==null?void 0:s.minYear)||1900,r=(s==null?void 0:s.maxYear)||3e3,o=new d.ValidateDateService;o.validateInputFormat(t);let u,c,a;const f=e.split(/[-/]/).map(Number);if(f.length!==3)return!1;try{switch(t){case"brazilianDate":[u,c,a]=f,o.validateDateParts(a,c,u);break;case"isoDate":[c,u,a]=f,o.validateDateParts(a,c,u);break;case"timestamp":[a,c,u]=f,o.validateDateParts(a,c,u);break}return!(a<n||a>r)}catch{return!1}}function gs(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 ys(e){return!(e.length===0||e.length>64||e.startsWith(".")||e.endsWith(".")||e.includes("..")||!/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e))}function ps(e){return!(e.length===0||e.length>63||e.startsWith("-")||e.endsWith("-")||!/^[a-zA-Z0-9-]+$/.test(e))}function Ts(e){if(e.length===0||e.length>253||e.startsWith(".")||e.endsWith(".")||e.startsWith("-")||e.endsWith("-"))return!1;const s=e.split(".");if(s.length<2)return!1;for(const n of s)if(!ps(n))return!1;const t=s[s.length-1];return!(t.length<2||!/^[a-zA-Z]+$/.test(t))}function bs(e){const s=e.split("@");if(s.length!==2)return!1;const[t,n]=s;return!(!ys(t)||!Ts(n))}function Rs(e){const s=e.split("@");return s.length===2?s[1].toLowerCase():null}const xs=["MX","A","AAAA"];async function Ss(e,s){var t;try{return await((t=D==null?void 0:D.promises)==null?void 0:t.resolve(e,s)),!0}catch{return!1}}async function vs(e){for(const s of xs)if(await Ss(e,s))return!0;return!1}async function Ns(e){if(!e||typeof e!="string")return!1;const s=e.trim();if(!gs(s)||!bs(s))return!1;const t=Rs(s);return t?await vs(t):!1}function Ds(e){if(!e)return!1;const s=e.length>=8,t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/\d/.test(e),o=/[!@#$%^&*(),.?":;{}|<>_\-+=~`[\]\\\/]/.test(e);return[s,t,n,r,o].every(u=>u)}function Es(e){for(const s of L.countries){const t=s.code,n=s.prefix?`-${s.prefix}`:"",r=s.mask.replace(/[^_]/g,"").length;if(s.iso==="BR"){if(new RegExp(`^\\${t} \\d{2}9?\\d{8}$`).test(e))return!0;continue}if(new RegExp(`^\\${t}${n} \\d{${r}}$`).test(e))return!0}return!1}function Ps(e){if(!e||!/^[0-9a-zA-Z.-]+$/.test(e))return!1;const t=e.replace(/[^a-zA-Z0-9]/g,"");return t.length<7||t.length>9?!1:/^[0-9]{7,8}[0-9Xx]?$/.test(t)}i.ApiService=Q,i.BadGateway=P,i.BadRequest=S,i.Conflict=$,i.Created=w,i.DebugService=x,i.Forbidden=B,i.Found=J,i.LogService=E,i.NoContent=C,i.NotFound=k,i.NotImplemented=O,i.SchemaValidator=rs,i.ServerError=v,i.Success=_,i.Unauthorized=j,i.UnprocessableEntity=N,i.Updated=I,i.decodeRequestBody=X,i.decodeRequestErrorMessage=ss,i.errorHandler=es,i.flushDebugLogs=y,i.formAsyncParse=U,i.formParse=q,i.getScopedParams=ts,i.validateCep=os,i.validateCnpj=cs,i.validateCpf=ds,i.validateDate=ms,i.validateEmail=Ns,i.validatePassword=Ds,i.validatePhone=Es,i.validateRg=Ps,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
@@ -1 +1 @@
1
- {"version":3,"file":"apiService.d.ts","sourceRoot":"","sources":["../../src/services/apiService.ts"],"names":[],"mappings":"AAOA,KAAK,0BAA0B,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAUF,cAAM,UAAU;IACd,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAC,CAAU;gBAElB,KAAK,EAAE,0BAA0B;IAO7C,OAAO,CAAC,OAAO;IAkBf,OAAO,CAAC,eAAe;IAcvB;;;;;OAKG;IAEG,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,8BAA8B;IAmBjE;;;;;OAKG;IAEG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAsB/D;;;;;OAKG;IAEG,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAsB9D;;;;;OAKG;IAEG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAsBhE;;;;;OAKG;IAEG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;CAqBlE;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"apiService.d.ts","sourceRoot":"","sources":["../../src/services/apiService.ts"],"names":[],"mappings":"AAOA,KAAK,0BAA0B,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AASF,cAAM,UAAU;IACd,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAC,CAAU;gBAElB,KAAK,EAAE,0BAA0B;IAO7C,OAAO,CAAC,OAAO;IAiBf,OAAO,CAAC,eAAe;IAcvB;;;;;OAKG;IAEG,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,8BAA8B;IAkBjE;;;;;OAKG;IAEG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAqB/D;;;;;OAKG;IAEG,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAqB9D;;;;;OAKG;IAEG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAqBhE;;;;;OAKG;IAEG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;CAoBlE;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -18,15 +18,15 @@ class ApiService {
18
18
  onDebug(endpoint, method, data) {
19
19
  if (this.enableDebug) {
20
20
  const debugs = [];
21
- const json = (data) => (data ? JSON.stringify(data, null, 2) : null);
21
+ const json = (data) => JSON.stringify(data, null, 2);
22
22
  debugs.push(`Base URL: ${this.baseUrl}`);
23
23
  debugs.push(`Endpoint: ${endpoint}`);
24
- debugs.push(`Method: ${method}`);
25
- debugs.push(`Status: ${data.status}`);
24
+ debugs.push(`Status/Method: ${method} => ${data.status}`);
26
25
  debugs.push(`Message: ${data.message}`);
27
- debugs.push(`Headers: ${json(data.headers)}`);
28
- debugs.push(`Body: ${json(data.body)}`);
29
- debugs.push(`Response: ${json(data.response)}`);
26
+ if (data.headers)
27
+ debugs.push(`Headers: ${json(data.headers)}`);
28
+ if (data.body)
29
+ debugs.push(`Body: ${json(data.body)}`);
30
30
  flushDebugLogs({ debugs, name: "ApiDebug", scheme: "yellow" });
31
31
  }
32
32
  }
@@ -59,7 +59,6 @@ class ApiService {
59
59
  headers,
60
60
  message: response.message,
61
61
  status: response.status,
62
- response: response.response,
63
62
  });
64
63
  return response;
65
64
  }
@@ -83,7 +82,6 @@ class ApiService {
83
82
  body,
84
83
  message: response.message,
85
84
  status: response.status,
86
- response: response.response,
87
85
  });
88
86
  return response;
89
87
  }
@@ -107,7 +105,6 @@ class ApiService {
107
105
  body,
108
106
  message: response.message,
109
107
  status: response.status,
110
- response: response.response,
111
108
  });
112
109
  return response;
113
110
  }
@@ -131,7 +128,6 @@ class ApiService {
131
128
  body,
132
129
  message: response.message,
133
130
  status: response.status,
134
- response: response.response,
135
131
  });
136
132
  return response;
137
133
  }
@@ -155,7 +151,6 @@ class ApiService {
155
151
  body,
156
152
  message: response.message,
157
153
  status: response.status,
158
- response: response.response,
159
154
  });
160
155
  return response;
161
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "3.0.1-beta.120",
3
+ "version": "3.0.1-beta.121",
4
4
  "author": "Arkyn | Lucas Gonçalves",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/bundle.js",