@arkyn/server 3.0.1-beta.166 → 3.0.1-beta.170
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/package.json +4 -3
- package/dist/http/api/_logRequest.d.ts +0 -58
- package/dist/http/api/_logRequest.d.ts.map +0 -1
- package/dist/http/api/_makeRequest.d.ts +0 -61
- package/dist/http/api/_makeRequest.d.ts.map +0 -1
- package/dist/http/api/deleteRequest.d.ts +0 -17
- package/dist/http/api/deleteRequest.d.ts.map +0 -1
- package/dist/http/api/getRequest.d.ts +0 -16
- package/dist/http/api/getRequest.d.ts.map +0 -1
- package/dist/http/api/patchRequest.d.ts +0 -17
- package/dist/http/api/patchRequest.d.ts.map +0 -1
- package/dist/http/api/postRequest.d.ts +0 -17
- package/dist/http/api/postRequest.d.ts.map +0 -1
- package/dist/http/api/putRequest.d.ts +0 -17
- package/dist/http/api/putRequest.d.ts.map +0 -1
- package/dist/http/badResponses/_badResponse.d.ts +0 -25
- package/dist/http/badResponses/_badResponse.d.ts.map +0 -1
- package/dist/http/badResponses/badGateway.d.ts +0 -24
- package/dist/http/badResponses/badGateway.d.ts.map +0 -1
- package/dist/http/badResponses/badRequest.d.ts +0 -22
- package/dist/http/badResponses/badRequest.d.ts.map +0 -1
- package/dist/http/badResponses/conflict.d.ts +0 -22
- package/dist/http/badResponses/conflict.d.ts.map +0 -1
- package/dist/http/badResponses/forbidden.d.ts +0 -22
- package/dist/http/badResponses/forbidden.d.ts.map +0 -1
- package/dist/http/badResponses/notFound.d.ts +0 -22
- package/dist/http/badResponses/notFound.d.ts.map +0 -1
- package/dist/http/badResponses/notImplemented.d.ts +0 -22
- package/dist/http/badResponses/notImplemented.d.ts.map +0 -1
- package/dist/http/badResponses/serverError.d.ts +0 -22
- package/dist/http/badResponses/serverError.d.ts.map +0 -1
- package/dist/http/badResponses/unauthorized.d.ts +0 -22
- package/dist/http/badResponses/unauthorized.d.ts.map +0 -1
- package/dist/http/badResponses/unprocessableEntity.d.ts +0 -34
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +0 -1
- package/dist/http/successResponses/_successResponse.d.ts +0 -36
- package/dist/http/successResponses/_successResponse.d.ts.map +0 -1
- package/dist/http/successResponses/created.d.ts +0 -22
- package/dist/http/successResponses/created.d.ts.map +0 -1
- package/dist/http/successResponses/found.d.ts +0 -22
- package/dist/http/successResponses/found.d.ts.map +0 -1
- package/dist/http/successResponses/noContent.d.ts +0 -20
- package/dist/http/successResponses/noContent.d.ts.map +0 -1
- package/dist/http/successResponses/success.d.ts +0 -22
- package/dist/http/successResponses/success.d.ts.map +0 -1
- package/dist/http/successResponses/updated.d.ts +0 -23
- package/dist/http/successResponses/updated.d.ts.map +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1065
- package/dist/modules/http/api/_logRequest.js +0 -56
- package/dist/modules/http/api/_makeRequest.js +0 -70
- package/dist/modules/http/api/deleteRequest.js +0 -13
- package/dist/modules/http/api/getRequest.js +0 -12
- package/dist/modules/http/api/patchRequest.js +0 -13
- package/dist/modules/http/api/postRequest.js +0 -13
- package/dist/modules/http/api/putRequest.js +0 -13
- package/dist/modules/http/badResponses/_badResponse.js +0 -63
- package/dist/modules/http/badResponses/badGateway.js +0 -24
- package/dist/modules/http/badResponses/badRequest.js +0 -24
- package/dist/modules/http/badResponses/conflict.js +0 -24
- package/dist/modules/http/badResponses/forbidden.js +0 -24
- package/dist/modules/http/badResponses/notFound.js +0 -24
- package/dist/modules/http/badResponses/notImplemented.js +0 -24
- package/dist/modules/http/badResponses/serverError.js +0 -24
- package/dist/modules/http/badResponses/unauthorized.js +0 -24
- package/dist/modules/http/badResponses/unprocessableEntity.js +0 -28
- package/dist/modules/http/successResponses/_successResponse.js +0 -62
- package/dist/modules/http/successResponses/created.js +0 -24
- package/dist/modules/http/successResponses/found.js +0 -24
- package/dist/modules/http/successResponses/noContent.js +0 -17
- package/dist/modules/http/successResponses/success.js +0 -24
- package/dist/modules/http/successResponses/updated.js +0 -24
- package/dist/modules/index.js +0 -34
- package/dist/modules/services/apiService.js +0 -109
- package/dist/modules/services/debugService.js +0 -36
- package/dist/modules/services/logMapperService.js +0 -29
- package/dist/modules/services/logService.js +0 -21
- package/dist/modules/utilities/decodeRequestBody.js +0 -20
- package/dist/modules/utilities/decodeRequestErrorMessage.js +0 -6
- package/dist/modules/utilities/errorHandler.js +0 -39
- package/dist/modules/utilities/flushDebugLogs.js +0 -16
- package/dist/modules/utilities/formAsyncParse.js +0 -14
- package/dist/modules/utilities/formParse.js +0 -14
- package/dist/modules/utilities/getScopedParams.js +0 -9
- package/dist/modules/utilities/schemaValidator.js +0 -55
- package/dist/modules/validations/validateCep.js +0 -9
- package/dist/modules/validations/validateCnpj.js +0 -54
- package/dist/modules/validations/validateCpf.js +0 -27
- package/dist/modules/validations/validateDate.js +0 -26
- package/dist/modules/validations/validateEmail.js +0 -54
- package/dist/modules/validations/validatePassword.js +0 -12
- package/dist/modules/validations/validatePhone.js +0 -10
- package/dist/modules/validations/validateRg.js +0 -8
- package/dist/services/apiService.d.ts +0 -83
- package/dist/services/apiService.d.ts.map +0 -1
- package/dist/services/debugService.d.ts +0 -37
- package/dist/services/debugService.d.ts.map +0 -1
- package/dist/services/logMapperService.d.ts +0 -86
- package/dist/services/logMapperService.d.ts.map +0 -1
- package/dist/services/logService.d.ts +0 -33
- package/dist/services/logService.d.ts.map +0 -1
- package/dist/utilities/decodeRequestBody.d.ts +0 -18
- package/dist/utilities/decodeRequestBody.d.ts.map +0 -1
- package/dist/utilities/decodeRequestErrorMessage.d.ts +0 -19
- package/dist/utilities/decodeRequestErrorMessage.d.ts.map +0 -1
- package/dist/utilities/errorHandler.d.ts +0 -25
- package/dist/utilities/errorHandler.d.ts.map +0 -1
- package/dist/utilities/flushDebugLogs.d.ts +0 -24
- package/dist/utilities/flushDebugLogs.d.ts.map +0 -1
- package/dist/utilities/formAsyncParse.d.ts +0 -38
- package/dist/utilities/formAsyncParse.d.ts.map +0 -1
- package/dist/utilities/formParse.d.ts +0 -38
- package/dist/utilities/formParse.d.ts.map +0 -1
- package/dist/utilities/getScopedParams.d.ts +0 -19
- package/dist/utilities/getScopedParams.d.ts.map +0 -1
- package/dist/utilities/schemaValidator.d.ts +0 -75
- package/dist/utilities/schemaValidator.d.ts.map +0 -1
- package/dist/validations/validateCep.d.ts +0 -19
- package/dist/validations/validateCep.d.ts.map +0 -1
- package/dist/validations/validateCnpj.d.ts +0 -21
- package/dist/validations/validateCnpj.d.ts.map +0 -1
- package/dist/validations/validateCpf.d.ts +0 -16
- package/dist/validations/validateCpf.d.ts.map +0 -1
- package/dist/validations/validateDate.d.ts +0 -23
- package/dist/validations/validateDate.d.ts.map +0 -1
- package/dist/validations/validateEmail.d.ts +0 -21
- package/dist/validations/validateEmail.d.ts.map +0 -1
- package/dist/validations/validatePassword.d.ts +0 -20
- package/dist/validations/validatePassword.d.ts.map +0 -1
- package/dist/validations/validatePhone.d.ts +0 -16
- package/dist/validations/validatePhone.d.ts.map +0 -1
- package/dist/validations/validateRg.d.ts +0 -21
- package/dist/validations/validateRg.d.ts.map +0 -1
- package/generate-version.ts +0 -74
package/dist/modules/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { DebugService as e } from "./services/debugService.js";
|
|
2
|
-
import { flushDebugLogs as t } from "./utilities/flushDebugLogs.js";
|
|
3
|
-
import { BadGateway as n } from "./http/badResponses/badGateway.js";
|
|
4
|
-
import { BadRequest as r } from "./http/badResponses/badRequest.js";
|
|
5
|
-
import { Conflict as i } from "./http/badResponses/conflict.js";
|
|
6
|
-
import { Forbidden as a } from "./http/badResponses/forbidden.js";
|
|
7
|
-
import { NotFound as o } from "./http/badResponses/notFound.js";
|
|
8
|
-
import { NotImplemented as s } from "./http/badResponses/notImplemented.js";
|
|
9
|
-
import { ServerError as c } from "./http/badResponses/serverError.js";
|
|
10
|
-
import { Unauthorized as l } from "./http/badResponses/unauthorized.js";
|
|
11
|
-
import { UnprocessableEntity as u } from "./http/badResponses/unprocessableEntity.js";
|
|
12
|
-
import { Created as d } from "./http/successResponses/created.js";
|
|
13
|
-
import { Found as f } from "./http/successResponses/found.js";
|
|
14
|
-
import { NoContent as p } from "./http/successResponses/noContent.js";
|
|
15
|
-
import { Success as m } from "./http/successResponses/success.js";
|
|
16
|
-
import { Updated as h } from "./http/successResponses/updated.js";
|
|
17
|
-
import { LogService as g } from "./services/logService.js";
|
|
18
|
-
import { ApiService as _ } from "./services/apiService.js";
|
|
19
|
-
import { decodeRequestBody as v } from "./utilities/decodeRequestBody.js";
|
|
20
|
-
import { decodeRequestErrorMessage as y } from "./utilities/decodeRequestErrorMessage.js";
|
|
21
|
-
import { errorHandler as b } from "./utilities/errorHandler.js";
|
|
22
|
-
import { formAsyncParse as x } from "./utilities/formAsyncParse.js";
|
|
23
|
-
import { formParse as S } from "./utilities/formParse.js";
|
|
24
|
-
import { getScopedParams as C } from "./utilities/getScopedParams.js";
|
|
25
|
-
import { SchemaValidator as w } from "./utilities/schemaValidator.js";
|
|
26
|
-
import { validateCep as T } from "./validations/validateCep.js";
|
|
27
|
-
import { validateCnpj as E } from "./validations/validateCnpj.js";
|
|
28
|
-
import { validateCpf as D } from "./validations/validateCpf.js";
|
|
29
|
-
import { validateDate as O } from "./validations/validateDate.js";
|
|
30
|
-
import { validateEmail as k } from "./validations/validateEmail.js";
|
|
31
|
-
import { validatePassword as A } from "./validations/validatePassword.js";
|
|
32
|
-
import { validatePhone as j } from "./validations/validatePhone.js";
|
|
33
|
-
import { validateRg as M } from "./validations/validateRg.js";
|
|
34
|
-
export { _ as ApiService, n as BadGateway, r as BadRequest, i as Conflict, d as Created, e as DebugService, a as Forbidden, f as Found, g as LogService, p as NoContent, o as NotFound, s as NotImplemented, w as SchemaValidator, c as ServerError, m as Success, l as Unauthorized, u as UnprocessableEntity, h as Updated, v as decodeRequestBody, y as decodeRequestErrorMessage, b as errorHandler, t as flushDebugLogs, x as formAsyncParse, S as formParse, C as getScopedParams, T as validateCep, E as validateCnpj, D as validateCpf, O as validateDate, k as validateEmail, A as validatePassword, j as validatePhone, M as validateRg };
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { flushDebugLogs as e } from "../utilities/flushDebugLogs.js";
|
|
2
|
-
import { deleteRequest as t } from "../http/api/deleteRequest.js";
|
|
3
|
-
import { getRequest as n } from "../http/api/getRequest.js";
|
|
4
|
-
import { patchRequest as r } from "../http/api/patchRequest.js";
|
|
5
|
-
import { postRequest as i } from "../http/api/postRequest.js";
|
|
6
|
-
import { putRequest as a } from "../http/api/putRequest.js";
|
|
7
|
-
//#region src/services/apiService.ts
|
|
8
|
-
var o = class {
|
|
9
|
-
baseUrl;
|
|
10
|
-
baseHeaders;
|
|
11
|
-
baseToken;
|
|
12
|
-
enableDebug;
|
|
13
|
-
constructor(e) {
|
|
14
|
-
this.baseUrl = e.baseUrl, this.baseHeaders = e.baseHeaders || void 0, this.baseToken = e.baseToken || void 0, this.enableDebug = e.enableDebug || !1;
|
|
15
|
-
}
|
|
16
|
-
onDebug(t, n, r) {
|
|
17
|
-
if (this.enableDebug) {
|
|
18
|
-
let i = [], a = (e) => JSON.stringify(e, null, 2);
|
|
19
|
-
i.push(`Base URL: ${this.baseUrl}`), i.push(`Endpoint: ${t}`), i.push(`Status/Method: ${n} => ${r.status}`), i.push(`Message: ${r.message}`), r.headers && i.push(`Headers: ${a(r.headers)}`), r.body && i.push(`Body: ${a(r.body)}`), e({
|
|
20
|
-
debugs: i,
|
|
21
|
-
name: "ApiDebug",
|
|
22
|
-
scheme: "yellow"
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
generateHeaders(e, t) {
|
|
27
|
-
let n = {};
|
|
28
|
-
return this.baseToken && (n = { Authorization: `Bearer ${this.baseToken}` }), this.baseHeaders && (n = {
|
|
29
|
-
...n,
|
|
30
|
-
...this.baseHeaders
|
|
31
|
-
}), e && (n = {
|
|
32
|
-
...n,
|
|
33
|
-
...e
|
|
34
|
-
}), t && (n = {
|
|
35
|
-
...n,
|
|
36
|
-
Authorization: `Bearer ${t}`
|
|
37
|
-
}), n;
|
|
38
|
-
}
|
|
39
|
-
async get(e, t) {
|
|
40
|
-
let r = this.generateHeaders(t?.headers || {}, t?.token), i = await n({
|
|
41
|
-
url: this.baseUrl + e,
|
|
42
|
-
urlParams: t?.urlParams || {},
|
|
43
|
-
headers: r
|
|
44
|
-
});
|
|
45
|
-
return this.onDebug(e, "get", {
|
|
46
|
-
headers: r,
|
|
47
|
-
message: i.message,
|
|
48
|
-
status: i.status
|
|
49
|
-
}), i;
|
|
50
|
-
}
|
|
51
|
-
async post(e, t) {
|
|
52
|
-
let n = this.generateHeaders(t?.headers || {}, t?.token), r = t?.body, a = await i({
|
|
53
|
-
url: this.baseUrl + e,
|
|
54
|
-
urlParams: t?.urlParams || {},
|
|
55
|
-
headers: n,
|
|
56
|
-
body: r
|
|
57
|
-
});
|
|
58
|
-
return this.onDebug(e, "post", {
|
|
59
|
-
headers: n,
|
|
60
|
-
body: r,
|
|
61
|
-
message: a.message,
|
|
62
|
-
status: a.status
|
|
63
|
-
}), a;
|
|
64
|
-
}
|
|
65
|
-
async put(e, t) {
|
|
66
|
-
let n = this.generateHeaders(t?.headers || {}, t?.token), r = t?.body, i = await a({
|
|
67
|
-
url: this.baseUrl + e,
|
|
68
|
-
urlParams: t?.urlParams || {},
|
|
69
|
-
headers: n,
|
|
70
|
-
body: r
|
|
71
|
-
});
|
|
72
|
-
return this.onDebug(e, "put", {
|
|
73
|
-
headers: n,
|
|
74
|
-
body: r,
|
|
75
|
-
message: i.message,
|
|
76
|
-
status: i.status
|
|
77
|
-
}), i;
|
|
78
|
-
}
|
|
79
|
-
async patch(e, t) {
|
|
80
|
-
let n = this.generateHeaders(t?.headers || {}, t?.token), i = t?.body, a = await r({
|
|
81
|
-
url: this.baseUrl + e,
|
|
82
|
-
urlParams: t?.urlParams || {},
|
|
83
|
-
headers: n,
|
|
84
|
-
body: i
|
|
85
|
-
});
|
|
86
|
-
return this.onDebug(e, "patch", {
|
|
87
|
-
headers: n,
|
|
88
|
-
body: i,
|
|
89
|
-
message: a.message,
|
|
90
|
-
status: a.status
|
|
91
|
-
}), a;
|
|
92
|
-
}
|
|
93
|
-
async delete(e, n) {
|
|
94
|
-
let r = this.generateHeaders(n?.headers || {}, n?.token), i = n?.body, a = await t({
|
|
95
|
-
url: this.baseUrl + e,
|
|
96
|
-
urlParams: n?.urlParams || {},
|
|
97
|
-
headers: r,
|
|
98
|
-
body: i
|
|
99
|
-
});
|
|
100
|
-
return this.onDebug(e, "delete", {
|
|
101
|
-
headers: r,
|
|
102
|
-
body: i,
|
|
103
|
-
message: a.message,
|
|
104
|
-
status: a.status
|
|
105
|
-
}), a;
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
//#endregion
|
|
109
|
-
export { o as ApiService };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import e from "node:path";
|
|
2
|
-
//#region src/services/debugService.ts
|
|
3
|
-
var t = class {
|
|
4
|
-
static ignoreFiles = [];
|
|
5
|
-
static setIgnoreFile(e) {
|
|
6
|
-
this.ignoreFiles.push(e);
|
|
7
|
-
}
|
|
8
|
-
static clearIgnoreFiles() {
|
|
9
|
-
this.ignoreFiles = [];
|
|
10
|
-
}
|
|
11
|
-
static getCaller() {
|
|
12
|
-
let t = process.cwd(), n = ((/* @__PURE__ */ Error()).stack || "").split("\n").map((e) => e.trim()), r = 2;
|
|
13
|
-
for (; r < n.length && (n[r].includes("node:internal") || n[r].includes("/node_modules/"));) r++;
|
|
14
|
-
if (this.ignoreFiles.length > 0) for (; r < n.length && this.ignoreFiles.some((e) => n[r].includes(e));) r++;
|
|
15
|
-
let i = n[r] || "", a = "Unknown function", o = "Unknown caller", s = i.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
|
|
16
|
-
if (s) a = s[1], o = s[2];
|
|
17
|
-
else {
|
|
18
|
-
let e = i.match(/at\s+(.+)/);
|
|
19
|
-
if (e) {
|
|
20
|
-
o = e[1];
|
|
21
|
-
let t = o.match(/at\s+([^(\s]+)\s+/);
|
|
22
|
-
t && t[1] !== "new" && (a = t[1]);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
o.includes("(") && (o = o.substring(o.indexOf("(") + 1, o.lastIndexOf(")"))), o = o.split(":").slice(0, -2).join(":");
|
|
26
|
-
try {
|
|
27
|
-
o = e.relative(t, o);
|
|
28
|
-
} catch {}
|
|
29
|
-
return {
|
|
30
|
-
functionName: a,
|
|
31
|
-
callerInfo: o
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
//#endregion
|
|
36
|
-
export { t as DebugService };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region src/services/logMapperService.ts
|
|
2
|
-
var e = class {
|
|
3
|
-
static mapHeaders(e) {
|
|
4
|
-
return e instanceof Headers ? Object.fromEntries(e.entries()) : typeof e == "object" ? Object.entries(e).reduce((e, [t, n]) => (typeof n == "string" ? e[t] = n : Array.isArray(n) ? e[t] = n.join(", ") : e[t] = JSON.stringify(n), e), {}) : {};
|
|
5
|
-
}
|
|
6
|
-
static mapQueryParams(e) {
|
|
7
|
-
let t = {};
|
|
8
|
-
return e.forEach((e, n) => t[n] = e), t;
|
|
9
|
-
}
|
|
10
|
-
static handle(e) {
|
|
11
|
-
return {
|
|
12
|
-
rawUrl: e.rawUrl,
|
|
13
|
-
status: e.status,
|
|
14
|
-
method: e.method,
|
|
15
|
-
token: null,
|
|
16
|
-
elapsedTime: e.elapsedTime,
|
|
17
|
-
requestHeaders: this.mapHeaders(e.requestHeaders),
|
|
18
|
-
requestBody: e.requestBody || null,
|
|
19
|
-
queryParams: {
|
|
20
|
-
...this.mapQueryParams(e.queryParams),
|
|
21
|
-
...e.urlParams
|
|
22
|
-
},
|
|
23
|
-
responseHeaders: this.mapHeaders(e.responseHeaders),
|
|
24
|
-
responseBody: e.responseBody || null
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
export { e as LogMapperService };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region src/services/logService.ts
|
|
2
|
-
var e = class {
|
|
3
|
-
static config;
|
|
4
|
-
static setConfig(e) {
|
|
5
|
-
if (this.config) return;
|
|
6
|
-
let { trafficSourceId: t, userToken: n, logBaseApiUrl: r } = e, i = `${r || "http://62.238.8.44:8081"}/ingest-log`;
|
|
7
|
-
this.config = {
|
|
8
|
-
trafficSourceId: t,
|
|
9
|
-
userToken: n,
|
|
10
|
-
apiUrl: i
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
static getConfig() {
|
|
14
|
-
return this.config;
|
|
15
|
-
}
|
|
16
|
-
static resetConfig() {
|
|
17
|
-
this.config = void 0;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { e as LogService };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { BadRequest as e } from "../http/badResponses/badRequest.js";
|
|
2
|
-
//#region src/utilities/decodeRequestBody.ts
|
|
3
|
-
async function t(t) {
|
|
4
|
-
let n, r = await t.arrayBuffer(), i = new TextDecoder().decode(r);
|
|
5
|
-
try {
|
|
6
|
-
n = JSON.parse(i);
|
|
7
|
-
} catch {
|
|
8
|
-
try {
|
|
9
|
-
if (i.includes("=")) {
|
|
10
|
-
let e = new URLSearchParams(i);
|
|
11
|
-
n = Object.fromEntries(e.entries());
|
|
12
|
-
} else throw new e("Invalid URLSearchParams format");
|
|
13
|
-
} catch {
|
|
14
|
-
throw new e("Failed to extract data from request");
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return n;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { t as decodeRequestBody };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
//#region src/utilities/decodeRequestErrorMessage.ts
|
|
2
|
-
function e(e, t) {
|
|
3
|
-
return e?.message && typeof e?.message == "string" ? e?.message : e?.operator_erro_message && typeof e?.operator_erro_message == "string" ? e?.operator_erro_message : e?.error && typeof e?.error == "string" ? e?.error : e?.error?.message && typeof e?.error?.message == "string" ? e?.error?.message : t?.statusText && typeof t?.statusText == "string" ? t?.statusText : "Missing error message";
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
export { e as decodeRequestErrorMessage };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { BadGateway as e } from "../http/badResponses/badGateway.js";
|
|
2
|
-
import { BadRequest as t } from "../http/badResponses/badRequest.js";
|
|
3
|
-
import { Conflict as n } from "../http/badResponses/conflict.js";
|
|
4
|
-
import { Forbidden as r } from "../http/badResponses/forbidden.js";
|
|
5
|
-
import { NotFound as i } from "../http/badResponses/notFound.js";
|
|
6
|
-
import { NotImplemented as a } from "../http/badResponses/notImplemented.js";
|
|
7
|
-
import { ServerError as o } from "../http/badResponses/serverError.js";
|
|
8
|
-
import { Unauthorized as s } from "../http/badResponses/unauthorized.js";
|
|
9
|
-
import { UnprocessableEntity as c } from "../http/badResponses/unprocessableEntity.js";
|
|
10
|
-
import { Created as l } from "../http/successResponses/created.js";
|
|
11
|
-
import { Found as u } from "../http/successResponses/found.js";
|
|
12
|
-
import { NoContent as d } from "../http/successResponses/noContent.js";
|
|
13
|
-
import { Success as f } from "../http/successResponses/success.js";
|
|
14
|
-
import { Updated as p } from "../http/successResponses/updated.js";
|
|
15
|
-
//#region src/utilities/errorHandler.ts
|
|
16
|
-
function m(m) {
|
|
17
|
-
switch (!0) {
|
|
18
|
-
case m instanceof Response: return m;
|
|
19
|
-
case m instanceof u: return m.toResponse();
|
|
20
|
-
case m instanceof l: return m.toResponse();
|
|
21
|
-
case m instanceof p: return m.toResponse();
|
|
22
|
-
case m instanceof f: return m.toResponse();
|
|
23
|
-
case m instanceof d: return m.toResponse();
|
|
24
|
-
}
|
|
25
|
-
switch (!0) {
|
|
26
|
-
case m instanceof e: return m.toResponse();
|
|
27
|
-
case m instanceof t: return m.toResponse();
|
|
28
|
-
case m instanceof n: return m.toResponse();
|
|
29
|
-
case m instanceof r: return m.toResponse();
|
|
30
|
-
case m instanceof i: return m.toResponse();
|
|
31
|
-
case m instanceof a: return m.toResponse();
|
|
32
|
-
case m instanceof o: return m.toResponse();
|
|
33
|
-
case m instanceof s: return m.toResponse();
|
|
34
|
-
case m instanceof c: return m.toResponse();
|
|
35
|
-
}
|
|
36
|
-
return new o("Server error", m).toResponse();
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
export { m as errorHandler };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/utilities/flushDebugLogs.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
if (process.env.NODE_ENV === "development" || process.env?.DEBUG_MODE === "true") {
|
|
4
|
-
let t = `${{
|
|
5
|
-
yellow: "\x1B[33m",
|
|
6
|
-
cyan: "\x1B[36m",
|
|
7
|
-
red: "\x1B[31m",
|
|
8
|
-
green: "\x1B[32m"
|
|
9
|
-
}[e.scheme]}[${e.name}][0m`, n = "\n";
|
|
10
|
-
e.debugs.forEach((r, i) => {
|
|
11
|
-
n += `${t} ${r.trim()}`, i < e.debugs.length - 1 && (n += "\n");
|
|
12
|
-
}), console.log(n);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { e as flushDebugLogs };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/utilities/formAsyncParse.ts
|
|
2
|
-
async function e([e, t]) {
|
|
3
|
-
let n = await t.safeParseAsync(e);
|
|
4
|
-
return n.success === !1 ? {
|
|
5
|
-
success: !1,
|
|
6
|
-
fieldErrors: Object.fromEntries(n.error.issues.map((e) => [e.path.join("."), e.message])),
|
|
7
|
-
fields: e
|
|
8
|
-
} : {
|
|
9
|
-
success: !0,
|
|
10
|
-
data: n.data
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { e as formAsyncParse };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/utilities/formParse.ts
|
|
2
|
-
function e([e, t]) {
|
|
3
|
-
let n = t.safeParse(e);
|
|
4
|
-
return n.success === !1 ? {
|
|
5
|
-
success: !1,
|
|
6
|
-
fieldErrors: Object.fromEntries(n.error.issues.map((e) => [e.path.join("."), e.message])),
|
|
7
|
-
fields: e
|
|
8
|
-
} : {
|
|
9
|
-
success: !0,
|
|
10
|
-
data: n.data
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { e as formParse };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region src/utilities/getScopedParams.ts
|
|
2
|
-
function e(e, t = "") {
|
|
3
|
-
let n = new URL(e.url);
|
|
4
|
-
if (t === "") return n.searchParams;
|
|
5
|
-
let r = Array.from(n.searchParams.entries()).filter(([e]) => e.startsWith(`${t}:`)).map(([e, n]) => [e.replace(`${t}:`, ""), n]);
|
|
6
|
-
return new URLSearchParams(r);
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { e as getScopedParams };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ServerError as e } from "../http/badResponses/serverError.js";
|
|
2
|
-
import { UnprocessableEntity as t } from "../http/badResponses/unprocessableEntity.js";
|
|
3
|
-
import { formAsyncParse as n } from "./formAsyncParse.js";
|
|
4
|
-
import { formParse as r } from "./formParse.js";
|
|
5
|
-
//#region src/utilities/schemaValidator.ts
|
|
6
|
-
function i(e) {
|
|
7
|
-
return ["Error validating:", ...e.issues.map(({ path: e, message: t }) => `-> ${e.join(".")}: ${t}`)].join("\n");
|
|
8
|
-
}
|
|
9
|
-
var a = class {
|
|
10
|
-
schema;
|
|
11
|
-
constructor(e) {
|
|
12
|
-
this.schema = e;
|
|
13
|
-
}
|
|
14
|
-
isValid(e) {
|
|
15
|
-
return this.schema.safeParse(e).success;
|
|
16
|
-
}
|
|
17
|
-
safeValidate(e) {
|
|
18
|
-
return this.schema.safeParse(e);
|
|
19
|
-
}
|
|
20
|
-
validate(t) {
|
|
21
|
-
try {
|
|
22
|
-
return this.schema.parse(t);
|
|
23
|
-
} catch (t) {
|
|
24
|
-
throw new e(i(t));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
formValidate(e, n) {
|
|
28
|
-
let i = r([e, this.schema]);
|
|
29
|
-
if ("fieldErrors" in i) {
|
|
30
|
-
let e = Object.keys(i.fieldErrors)[0];
|
|
31
|
-
throw new t({
|
|
32
|
-
fields: i.fields,
|
|
33
|
-
fieldErrors: i.fieldErrors,
|
|
34
|
-
data: { scrollTo: e },
|
|
35
|
-
message: n
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return i.data;
|
|
39
|
-
}
|
|
40
|
-
async formAsyncValidate(e, r) {
|
|
41
|
-
let i = await n([e, this.schema]);
|
|
42
|
-
if ("fieldErrors" in i) {
|
|
43
|
-
let e = Object.keys(i.fieldErrors)[0];
|
|
44
|
-
throw new t({
|
|
45
|
-
fields: i.fields,
|
|
46
|
-
fieldErrors: i.fieldErrors,
|
|
47
|
-
data: { scrollTo: e },
|
|
48
|
-
message: r
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return i.data;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
//#endregion
|
|
55
|
-
export { a as SchemaValidator };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { removeNonNumeric as e } from "@arkyn/shared";
|
|
2
|
-
//#region src/validations/validateCep.ts
|
|
3
|
-
function t(t) {
|
|
4
|
-
if (!(/^\d{5}-\d{3}$/.test(t) || /^\d{8}$/.test(t))) return !1;
|
|
5
|
-
let n = e(t), r = /^\d{8}$/.test(n);
|
|
6
|
-
return n.length === 8 && r;
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { t as validateCep };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { removeNonNumeric as e } from "@arkyn/shared";
|
|
2
|
-
//#region src/validations/validateCnpj.ts
|
|
3
|
-
function t(e) {
|
|
4
|
-
return e.length !== 14;
|
|
5
|
-
}
|
|
6
|
-
function n(e) {
|
|
7
|
-
let [t] = e;
|
|
8
|
-
return [...e].every((e) => e === t);
|
|
9
|
-
}
|
|
10
|
-
function r(e, t) {
|
|
11
|
-
let n = 0;
|
|
12
|
-
for (let r = 0; r < t.length; r++) n += parseInt(e[r]) * t[r];
|
|
13
|
-
let r = n % 11;
|
|
14
|
-
return r < 2 ? 0 : 11 - r;
|
|
15
|
-
}
|
|
16
|
-
function i(e) {
|
|
17
|
-
return e.slice(12);
|
|
18
|
-
}
|
|
19
|
-
function a(a) {
|
|
20
|
-
if (!a || a.length > 18 || a.length < 14 || /\s/.test(a)) return !1;
|
|
21
|
-
let o = e(a);
|
|
22
|
-
if (t(o) || n(o)) return !1;
|
|
23
|
-
let s = o.slice(0, 12), c = r(s, [
|
|
24
|
-
5,
|
|
25
|
-
4,
|
|
26
|
-
3,
|
|
27
|
-
2,
|
|
28
|
-
9,
|
|
29
|
-
8,
|
|
30
|
-
7,
|
|
31
|
-
6,
|
|
32
|
-
5,
|
|
33
|
-
4,
|
|
34
|
-
3,
|
|
35
|
-
2
|
|
36
|
-
]), l = r(s + c, [
|
|
37
|
-
6,
|
|
38
|
-
5,
|
|
39
|
-
4,
|
|
40
|
-
3,
|
|
41
|
-
2,
|
|
42
|
-
9,
|
|
43
|
-
8,
|
|
44
|
-
7,
|
|
45
|
-
6,
|
|
46
|
-
5,
|
|
47
|
-
4,
|
|
48
|
-
3,
|
|
49
|
-
2
|
|
50
|
-
]);
|
|
51
|
-
return i(o) === `${c}${l}`;
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { a as validateCnpj };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { removeNonNumeric as e } from "@arkyn/shared";
|
|
2
|
-
//#region src/validations/validateCpf.ts
|
|
3
|
-
function t(e) {
|
|
4
|
-
return e.length !== 11;
|
|
5
|
-
}
|
|
6
|
-
function n(e) {
|
|
7
|
-
let [t] = e;
|
|
8
|
-
return [...e].every((e) => e === t);
|
|
9
|
-
}
|
|
10
|
-
function r(e, t) {
|
|
11
|
-
let n = 0;
|
|
12
|
-
for (let r of e) t > 1 && (n += parseInt(r) * t--);
|
|
13
|
-
let r = n % 11;
|
|
14
|
-
return r < 2 ? 0 : 11 - r;
|
|
15
|
-
}
|
|
16
|
-
function i(e) {
|
|
17
|
-
return e.slice(9);
|
|
18
|
-
}
|
|
19
|
-
function a(a) {
|
|
20
|
-
if (!a || a.length > 14 || a.length < 11 || /\s/.test(a)) return !1;
|
|
21
|
-
let o = e(a);
|
|
22
|
-
if (t(o) || n(o)) return !1;
|
|
23
|
-
let s = r(o, 10), c = r(o, 11);
|
|
24
|
-
return i(o) === `${s}${c}`;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { a as validateCpf };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ValidateDateService as e } from "@arkyn/shared";
|
|
2
|
-
//#region src/validations/validateDate.ts
|
|
3
|
-
function t(t, n) {
|
|
4
|
-
let r = n?.inputFormat || "brazilianDate", i = n?.minYear || 1900, a = n?.maxYear || 3e3, o = new e();
|
|
5
|
-
o.validateInputFormat(r);
|
|
6
|
-
let s, c, l, u = t.split(/[-/]/).map(Number);
|
|
7
|
-
if (u.length !== 3) return !1;
|
|
8
|
-
try {
|
|
9
|
-
switch (r) {
|
|
10
|
-
case "brazilianDate":
|
|
11
|
-
[s, c, l] = u, o.validateDateParts(l, c, s);
|
|
12
|
-
break;
|
|
13
|
-
case "isoDate":
|
|
14
|
-
[c, s, l] = u, o.validateDateParts(l, c, s);
|
|
15
|
-
break;
|
|
16
|
-
case "timestamp":
|
|
17
|
-
[l, c, s] = u, o.validateDateParts(l, c, s);
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
return !(l < i || l > a);
|
|
21
|
-
} catch {
|
|
22
|
-
return !1;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
export { t as validateDate };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import e from "node:dns";
|
|
2
|
-
//#region src/validations/validateEmail.ts
|
|
3
|
-
function t(e) {
|
|
4
|
-
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);
|
|
5
|
-
}
|
|
6
|
-
function n(e) {
|
|
7
|
-
return !(e.length === 0 || e.length > 64 || e.startsWith(".") || e.endsWith(".") || e.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e));
|
|
8
|
-
}
|
|
9
|
-
function r(e) {
|
|
10
|
-
return !(e.length === 0 || e.length > 63 || e.startsWith("-") || e.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(e));
|
|
11
|
-
}
|
|
12
|
-
function i(e) {
|
|
13
|
-
if (e.length === 0 || e.length > 253 || e.startsWith(".") || e.endsWith(".") || e.startsWith("-") || e.endsWith("-")) return !1;
|
|
14
|
-
let t = e.split(".");
|
|
15
|
-
if (t.length < 2) return !1;
|
|
16
|
-
for (let e of t) if (!r(e)) return !1;
|
|
17
|
-
let n = t[t.length - 1];
|
|
18
|
-
return !(n.length < 2 || !/^[a-zA-Z]+$/.test(n));
|
|
19
|
-
}
|
|
20
|
-
function a(e) {
|
|
21
|
-
let t = e.split("@");
|
|
22
|
-
if (t.length !== 2) return !1;
|
|
23
|
-
let [r, a] = t;
|
|
24
|
-
return !(!n(r) || !i(a));
|
|
25
|
-
}
|
|
26
|
-
function o(e) {
|
|
27
|
-
let t = e.split("@");
|
|
28
|
-
return t.length === 2 ? t[1].toLowerCase() : null;
|
|
29
|
-
}
|
|
30
|
-
var s = [
|
|
31
|
-
"MX",
|
|
32
|
-
"A",
|
|
33
|
-
"AAAA"
|
|
34
|
-
];
|
|
35
|
-
async function c(t, n) {
|
|
36
|
-
try {
|
|
37
|
-
return await e?.promises?.resolve(t, n), !0;
|
|
38
|
-
} catch {
|
|
39
|
-
return !1;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async function l(e) {
|
|
43
|
-
for (let t of s) if (await c(e, t)) return !0;
|
|
44
|
-
return !1;
|
|
45
|
-
}
|
|
46
|
-
async function u(e) {
|
|
47
|
-
if (!e || typeof e != "string") return !1;
|
|
48
|
-
let n = e.trim();
|
|
49
|
-
if (!t(n) || !a(n)) return !1;
|
|
50
|
-
let r = o(n);
|
|
51
|
-
return r ? await l(r) : !1;
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { u as validateEmail };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region src/validations/validatePassword.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
return e ? [
|
|
4
|
-
e.length >= 8,
|
|
5
|
-
/[A-Z]/.test(e),
|
|
6
|
-
/[a-z]/.test(e),
|
|
7
|
-
/\d/.test(e),
|
|
8
|
-
/[!@#$%^&*(),.?":;{}|<>_\-+=~`[\]\\\/]/.test(e)
|
|
9
|
-
].every((e) => e) : !1;
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { e as validatePassword };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { countries as e } from "@arkyn/templates";
|
|
2
|
-
import { isValidPhoneNumber as t, parsePhoneNumberWithError as n } from "libphonenumber-js";
|
|
3
|
-
//#region src/validations/validatePhone.ts
|
|
4
|
-
function r(r) {
|
|
5
|
-
if (!t(r)) return !1;
|
|
6
|
-
let i = n(r)?.country;
|
|
7
|
-
return !(!i || !e.find((e) => e.iso === i));
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
export { r as validatePhone };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region src/validations/validateRg.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
if (!e || !/^[0-9a-zA-Z.-]+$/.test(e)) return !1;
|
|
4
|
-
let t = e.replace(/[^a-zA-Z0-9]/g, "");
|
|
5
|
-
return t.length < 7 || t.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(t);
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { e as validateRg };
|