@arkyn/server 3.0.1-beta.154 → 3.0.1-beta.156

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.
Files changed (91) hide show
  1. package/dist/index.js +1301 -37
  2. package/dist/modules/http/api/_logRequest.js +69 -0
  3. package/dist/modules/http/api/_makeRequest.js +69 -0
  4. package/dist/modules/http/api/deleteRequest.js +13 -0
  5. package/dist/modules/http/api/getRequest.js +12 -0
  6. package/dist/modules/http/api/patchRequest.js +13 -0
  7. package/dist/modules/http/api/postRequest.js +13 -0
  8. package/dist/modules/http/api/putRequest.js +13 -0
  9. package/dist/modules/http/badResponses/_badResponse.js +59 -0
  10. package/dist/modules/http/badResponses/badGateway.js +30 -0
  11. package/dist/modules/http/badResponses/badRequest.js +30 -0
  12. package/dist/modules/http/badResponses/conflict.js +30 -0
  13. package/dist/modules/http/badResponses/forbidden.js +30 -0
  14. package/dist/modules/http/badResponses/notFound.js +30 -0
  15. package/dist/modules/http/badResponses/notImplemented.js +30 -0
  16. package/dist/modules/http/badResponses/serverError.js +30 -0
  17. package/dist/modules/http/badResponses/unauthorized.js +30 -0
  18. package/dist/modules/http/badResponses/unprocessableEntity.js +36 -0
  19. package/dist/modules/http/successResponses/_successResponse.js +69 -0
  20. package/dist/modules/http/successResponses/created.js +30 -0
  21. package/dist/modules/http/successResponses/found.js +30 -0
  22. package/dist/modules/http/successResponses/noContent.js +21 -0
  23. package/dist/modules/http/successResponses/success.js +30 -0
  24. package/dist/modules/http/successResponses/updated.js +30 -0
  25. package/dist/modules/index.js +68 -0
  26. package/dist/modules/services/apiService.js +129 -0
  27. package/dist/modules/services/debugService.js +66 -0
  28. package/dist/modules/services/logMapperService.js +52 -0
  29. package/dist/modules/services/logService.js +31 -0
  30. package/dist/modules/utilities/decodeRequestBody.js +22 -0
  31. package/dist/modules/utilities/decodeRequestErrorMessage.js +7 -0
  32. package/dist/modules/utilities/errorHandler.js +54 -0
  33. package/dist/modules/utilities/flushDebugLogs.js +20 -0
  34. package/dist/modules/utilities/formAsyncParse.js +19 -0
  35. package/dist/modules/utilities/formParse.js +19 -0
  36. package/dist/modules/utilities/getScopedParams.js +11 -0
  37. package/dist/modules/utilities/schemaValidator.js +106 -0
  38. package/dist/modules/validations/validateCep.js +9 -0
  39. package/dist/modules/validations/validateCnpj.js +31 -0
  40. package/dist/modules/validations/validateCpf.js +28 -0
  41. package/dist/modules/validations/validateDate.js +27 -0
  42. package/dist/modules/validations/validateEmail.js +53 -0
  43. package/dist/modules/validations/validatePassword.js +16 -0
  44. package/dist/modules/validations/validatePhone.js +10 -0
  45. package/dist/modules/validations/validateRg.js +8 -0
  46. package/package.json +121 -87
  47. package/dist/bundle.js +0 -3014
  48. package/dist/bundle.umd.cjs +0 -9
  49. package/dist/http/api/_logRequest.js +0 -109
  50. package/dist/http/api/_makeRequest.js +0 -116
  51. package/dist/http/api/deleteRequest.js +0 -18
  52. package/dist/http/api/getRequest.js +0 -17
  53. package/dist/http/api/patchRequest.js +0 -18
  54. package/dist/http/api/postRequest.js +0 -18
  55. package/dist/http/api/putRequest.js +0 -18
  56. package/dist/http/badResponses/_badResponse.js +0 -62
  57. package/dist/http/badResponses/badGateway.js +0 -43
  58. package/dist/http/badResponses/badRequest.js +0 -41
  59. package/dist/http/badResponses/conflict.js +0 -42
  60. package/dist/http/badResponses/forbidden.js +0 -41
  61. package/dist/http/badResponses/notFound.js +0 -41
  62. package/dist/http/badResponses/notImplemented.js +0 -41
  63. package/dist/http/badResponses/serverError.js +0 -41
  64. package/dist/http/badResponses/unauthorized.js +0 -42
  65. package/dist/http/badResponses/unprocessableEntity.js +0 -53
  66. package/dist/http/successResponses/_successResponse.js +0 -75
  67. package/dist/http/successResponses/created.js +0 -41
  68. package/dist/http/successResponses/found.js +0 -41
  69. package/dist/http/successResponses/noContent.js +0 -32
  70. package/dist/http/successResponses/success.js +0 -41
  71. package/dist/http/successResponses/updated.js +0 -42
  72. package/dist/services/apiService.js +0 -174
  73. package/dist/services/debugService.js +0 -82
  74. package/dist/services/logMapperService.js +0 -68
  75. package/dist/services/logService.js +0 -35
  76. package/dist/utilities/decodeRequestBody.js +0 -40
  77. package/dist/utilities/decodeRequestErrorMessage.js +0 -36
  78. package/dist/utilities/errorHandler.js +0 -74
  79. package/dist/utilities/flushDebugLogs.js +0 -39
  80. package/dist/utilities/formAsyncParse.js +0 -37
  81. package/dist/utilities/formParse.js +0 -37
  82. package/dist/utilities/getScopedParams.js +0 -26
  83. package/dist/utilities/schemaValidator.js +0 -119
  84. package/dist/validations/validateCep.js +0 -27
  85. package/dist/validations/validateCnpj.js +0 -59
  86. package/dist/validations/validateCpf.js +0 -54
  87. package/dist/validations/validateDate.js +0 -51
  88. package/dist/validations/validateEmail.js +0 -111
  89. package/dist/validations/validatePassword.js +0 -34
  90. package/dist/validations/validatePhone.js +0 -28
  91. package/dist/validations/validateRg.js +0 -31
@@ -0,0 +1,21 @@
1
+ import { SuccessResponse as s } from "./_successResponse.js";
2
+ class o extends s {
3
+ /**
4
+ * @param message - Description included in the response status text.
5
+ */
6
+ constructor(t) {
7
+ super(), this.name = "NoContent", this.status = 204, this.statusText = t, this.onDebug();
8
+ }
9
+ /** Converts to a `Response` with `Content-Type: application/json` header and no body. */
10
+ toResponse() {
11
+ const t = {
12
+ headers: { "Content-Type": "application/json" },
13
+ status: this.status,
14
+ statusText: this.statusText
15
+ };
16
+ return new Response(null, t);
17
+ }
18
+ }
19
+ export {
20
+ o as NoContent
21
+ };
@@ -0,0 +1,30 @@
1
+ import { SuccessResponse as e } from "./_successResponse.js";
2
+ class i extends e {
3
+ /**
4
+ * @param message - Description included in the response status text.
5
+ * @param body - Data to include in the response body.
6
+ */
7
+ constructor(s, t) {
8
+ super(), this.name = "Success", this.status = 200, this.statusText = s, this.body = t || void 0, this.onDebug();
9
+ }
10
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
11
+ toResponse() {
12
+ const s = {
13
+ headers: { "Content-Type": "application/json" },
14
+ status: this.status,
15
+ statusText: this.statusText
16
+ };
17
+ return new Response(JSON.stringify(this.body), s);
18
+ }
19
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
20
+ toJson() {
21
+ const s = {
22
+ status: this.status,
23
+ statusText: this.statusText
24
+ };
25
+ return Response.json(this.body, s);
26
+ }
27
+ }
28
+ export {
29
+ i as Success
30
+ };
@@ -0,0 +1,30 @@
1
+ import { SuccessResponse as e } from "./_successResponse.js";
2
+ class i extends e {
3
+ /**
4
+ * @param message - Description included in the response status text.
5
+ * @param body - Data to include in the response body.
6
+ */
7
+ constructor(s, t) {
8
+ super(), this.name = "Updated", this.status = 200, this.statusText = s, this.body = t || void 0, this.onDebug();
9
+ }
10
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
11
+ toResponse() {
12
+ const s = {
13
+ headers: { "Content-Type": "application/json" },
14
+ status: this.status,
15
+ statusText: this.statusText
16
+ };
17
+ return new Response(JSON.stringify(this.body), s);
18
+ }
19
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
20
+ toJson() {
21
+ const s = {
22
+ status: this.status,
23
+ statusText: this.statusText
24
+ };
25
+ return Response.json(this.body, s);
26
+ }
27
+ }
28
+ export {
29
+ i as Updated
30
+ };
@@ -0,0 +1,68 @@
1
+ import { BadGateway as e } from "./http/badResponses/badGateway.js";
2
+ import { BadRequest as p } from "./http/badResponses/badRequest.js";
3
+ import { Conflict as f } from "./http/badResponses/conflict.js";
4
+ import { Forbidden as x } from "./http/badResponses/forbidden.js";
5
+ import { NotFound as i } from "./http/badResponses/notFound.js";
6
+ import { NotImplemented as l } from "./http/badResponses/notImplemented.js";
7
+ import { ServerError as c } from "./http/badResponses/serverError.js";
8
+ import { Unauthorized as u } from "./http/badResponses/unauthorized.js";
9
+ import { UnprocessableEntity as S } from "./http/badResponses/unprocessableEntity.js";
10
+ import { Created as P } from "./http/successResponses/created.js";
11
+ import { Found as h } from "./http/successResponses/found.js";
12
+ import { NoContent as E } from "./http/successResponses/noContent.js";
13
+ import { Success as q } from "./http/successResponses/success.js";
14
+ import { Updated as D } from "./http/successResponses/updated.js";
15
+ import { ApiService as N } from "./services/apiService.js";
16
+ import { DebugService as w } from "./services/debugService.js";
17
+ import { LogService as L } from "./services/logService.js";
18
+ import { decodeRequestBody as z } from "./utilities/decodeRequestBody.js";
19
+ import { decodeRequestErrorMessage as H } from "./utilities/decodeRequestErrorMessage.js";
20
+ import { errorHandler as M } from "./utilities/errorHandler.js";
21
+ import { flushDebugLogs as k } from "./utilities/flushDebugLogs.js";
22
+ import { formAsyncParse as K } from "./utilities/formAsyncParse.js";
23
+ import { formParse as Q } from "./utilities/formParse.js";
24
+ import { getScopedParams as W } from "./utilities/getScopedParams.js";
25
+ import { SchemaValidator as Y } from "./utilities/schemaValidator.js";
26
+ import { validateCep as _ } from "./validations/validateCep.js";
27
+ import { validateCnpj as rr } from "./validations/validateCnpj.js";
28
+ import { validateCpf as er } from "./validations/validateCpf.js";
29
+ import { validateDate as pr } from "./validations/validateDate.js";
30
+ import { validateEmail as fr } from "./validations/validateEmail.js";
31
+ import { validatePassword as xr } from "./validations/validatePassword.js";
32
+ import { validatePhone as ir } from "./validations/validatePhone.js";
33
+ import { validateRg as lr } from "./validations/validateRg.js";
34
+ export {
35
+ N as ApiService,
36
+ e as BadGateway,
37
+ p as BadRequest,
38
+ f as Conflict,
39
+ P as Created,
40
+ w as DebugService,
41
+ x as Forbidden,
42
+ h as Found,
43
+ L as LogService,
44
+ E as NoContent,
45
+ i as NotFound,
46
+ l as NotImplemented,
47
+ Y as SchemaValidator,
48
+ c as ServerError,
49
+ q as Success,
50
+ u as Unauthorized,
51
+ S as UnprocessableEntity,
52
+ D as Updated,
53
+ z as decodeRequestBody,
54
+ H as decodeRequestErrorMessage,
55
+ M as errorHandler,
56
+ k as flushDebugLogs,
57
+ K as formAsyncParse,
58
+ Q as formParse,
59
+ W as getScopedParams,
60
+ _ as validateCep,
61
+ rr as validateCnpj,
62
+ er as validateCpf,
63
+ pr as validateDate,
64
+ fr as validateEmail,
65
+ xr as validatePassword,
66
+ ir as validatePhone,
67
+ lr as validateRg
68
+ };
@@ -0,0 +1,129 @@
1
+ var b = Object.defineProperty;
2
+ var l = (n, s, e) => s in n ? b(n, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[s] = e;
3
+ var h = (n, s, e) => l(n, typeof s != "symbol" ? s + "" : s, e);
4
+ import { deleteRequest as g } from "../http/api/deleteRequest.js";
5
+ import { getRequest as m } from "../http/api/getRequest.js";
6
+ import { patchRequest as c } from "../http/api/patchRequest.js";
7
+ import { postRequest as t } from "../http/api/postRequest.js";
8
+ import { putRequest as p } from "../http/api/putRequest.js";
9
+ import { flushDebugLogs as y } from "../utilities/flushDebugLogs.js";
10
+ class w {
11
+ constructor(s) {
12
+ h(this, "baseUrl");
13
+ h(this, "baseHeaders");
14
+ h(this, "baseToken");
15
+ h(this, "enableDebug");
16
+ this.baseUrl = s.baseUrl, this.baseHeaders = s.baseHeaders || void 0, this.baseToken = s.baseToken || void 0, this.enableDebug = s.enableDebug || !1;
17
+ }
18
+ onDebug(s, e, r) {
19
+ if (this.enableDebug) {
20
+ const o = [], u = (i) => JSON.stringify(i, null, 2);
21
+ o.push(`Base URL: ${this.baseUrl}`), o.push(`Endpoint: ${s}`), o.push(`Status/Method: ${e} => ${r.status}`), o.push(`Message: ${r.message}`), r.headers && o.push(`Headers: ${u(r.headers)}`), r.body && o.push(`Body: ${u(r.body)}`), y({ debugs: o, name: "ApiDebug", scheme: "yellow" });
22
+ }
23
+ }
24
+ generateHeaders(s, e) {
25
+ let r = {};
26
+ return this.baseToken && (r = { Authorization: `Bearer ${this.baseToken}` }), this.baseHeaders && (r = { ...r, ...this.baseHeaders }), s && (r = { ...r, ...s }), e && (r = { ...r, Authorization: `Bearer ${e}` }), r;
27
+ }
28
+ /**
29
+ * Sends a get request to the specified endpoint.
30
+ * @param endpoint - The API endpoint to send the get request to.
31
+ * @param data - The request data, including optional headers and token.
32
+ * @returns The API response data.
33
+ */
34
+ async get(s, e) {
35
+ const r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), o = await m({
36
+ url: this.baseUrl + s,
37
+ urlParams: (e == null ? void 0 : e.urlParams) || {},
38
+ headers: r
39
+ });
40
+ return this.onDebug(s, "get", {
41
+ headers: r,
42
+ message: o.message,
43
+ status: o.status
44
+ }), o;
45
+ }
46
+ /**
47
+ * Sends a post request to the specified endpoint.
48
+ * @param endpoint - The API endpoint to send the post request to.
49
+ * @param data - The request data, including body, optional headers, and token.
50
+ * @returns The API response data.
51
+ */
52
+ async post(s, e) {
53
+ const r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), o = e == null ? void 0 : e.body, u = await t({
54
+ url: this.baseUrl + s,
55
+ urlParams: (e == null ? void 0 : e.urlParams) || {},
56
+ headers: r,
57
+ body: o
58
+ });
59
+ return this.onDebug(s, "post", {
60
+ headers: r,
61
+ body: o,
62
+ message: u.message,
63
+ status: u.status
64
+ }), u;
65
+ }
66
+ /**
67
+ * Sends a put request to the specified endpoint.
68
+ * @param endpoint - The API endpoint to send the put request to.
69
+ * @param data - The request data, including body, optional headers, and token.
70
+ * @returns The API response data.
71
+ */
72
+ async put(s, e) {
73
+ const r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), o = e == null ? void 0 : e.body, u = await p({
74
+ url: this.baseUrl + s,
75
+ urlParams: (e == null ? void 0 : e.urlParams) || {},
76
+ headers: r,
77
+ body: o
78
+ });
79
+ return this.onDebug(s, "put", {
80
+ headers: r,
81
+ body: o,
82
+ message: u.message,
83
+ status: u.status
84
+ }), u;
85
+ }
86
+ /**
87
+ * Sends a patch request to the specified endpoint.
88
+ * @param endpoint - The API endpoint to send the patch request to.
89
+ * @param data - The request data, including body, optional headers, and token.
90
+ * @returns The API response data.
91
+ */
92
+ async patch(s, e) {
93
+ const r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), o = e == null ? void 0 : e.body, u = await c({
94
+ url: this.baseUrl + s,
95
+ urlParams: (e == null ? void 0 : e.urlParams) || {},
96
+ headers: r,
97
+ body: o
98
+ });
99
+ return this.onDebug(s, "patch", {
100
+ headers: r,
101
+ body: o,
102
+ message: u.message,
103
+ status: u.status
104
+ }), u;
105
+ }
106
+ /**
107
+ * Sends a delete request to the specified endpoint.
108
+ * @param endpoint - The API endpoint to send the delete request to.
109
+ * @param data - The request data, including body, optional headers, and token.
110
+ * @returns The API response data.
111
+ */
112
+ async delete(s, e) {
113
+ const r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), o = e == null ? void 0 : e.body, u = await g({
114
+ url: this.baseUrl + s,
115
+ urlParams: (e == null ? void 0 : e.urlParams) || {},
116
+ headers: r,
117
+ body: o
118
+ });
119
+ return this.onDebug(s, "delete", {
120
+ headers: r,
121
+ body: o,
122
+ message: u.message,
123
+ status: u.status
124
+ }), u;
125
+ }
126
+ }
127
+ export {
128
+ w as ApiService
129
+ };
@@ -0,0 +1,66 @@
1
+ var u = Object.defineProperty;
2
+ var g = (i, t, l) => t in i ? u(i, t, { enumerable: !0, configurable: !0, writable: !0, value: l }) : i[t] = l;
3
+ var d = (i, t, l) => g(i, typeof t != "symbol" ? t + "" : t, l);
4
+ import m from "node:path";
5
+ class f {
6
+ /**
7
+ * Adds a file name to the ignore list so it is skipped when resolving the caller in stack traces.
8
+ *
9
+ * @param file - File name to ignore (e.g. `"httpAdapter.ts"`).
10
+ */
11
+ static setIgnoreFile(t) {
12
+ this.ignoreFiles.push(t);
13
+ }
14
+ /** Resets the ignore list, restoring full stack trace analysis. */
15
+ static clearIgnoreFiles() {
16
+ this.ignoreFiles = [];
17
+ }
18
+ /**
19
+ * Resolves the file path and function name of the code that triggered the current debug call,
20
+ * skipping internal node modules and any files registered with `setIgnoreFile`.
21
+ *
22
+ * @returns `{ functionName, callerInfo }` — caller function name and file path relative to `process.cwd()`.
23
+ */
24
+ static getCaller() {
25
+ const t = process.cwd(), c = (new Error().stack || "").split(`
26
+ `).map((s) => s.trim());
27
+ let n = 2;
28
+ for (; n < c.length && (c[n].includes("node:internal") || c[n].includes("/node_modules/")); )
29
+ n++;
30
+ if (this.ignoreFiles.length > 0)
31
+ for (; n < c.length && this.ignoreFiles.some(
32
+ (s) => c[n].includes(s)
33
+ ); )
34
+ n++;
35
+ const h = c[n] || "";
36
+ let o = "Unknown function", e = "Unknown caller";
37
+ const a = h.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
38
+ if (a)
39
+ o = a[1], e = a[2];
40
+ else {
41
+ const s = h.match(/at\s+(.+)/);
42
+ if (s) {
43
+ e = s[1];
44
+ const r = e.match(/at\s+([^(\s]+)\s+/);
45
+ r && r[1] !== "new" && (o = r[1]);
46
+ }
47
+ }
48
+ e.includes("(") && (e = e.substring(
49
+ e.indexOf("(") + 1,
50
+ e.lastIndexOf(")")
51
+ )), e = e.split(":").slice(0, -2).join(":");
52
+ try {
53
+ e = m.relative(t, e);
54
+ } catch {
55
+ }
56
+ return { functionName: o, callerInfo: e };
57
+ }
58
+ }
59
+ /**
60
+ * The name of the file to ignore when analyzing the stack trace.
61
+ * When set, the `getCaller` function will skip stack frames containing this file name.
62
+ */
63
+ d(f, "ignoreFiles", []);
64
+ export {
65
+ f as DebugService
66
+ };
@@ -0,0 +1,52 @@
1
+ class n {
2
+ /**
3
+ * Converts various header formats into a plain key-value object.
4
+ *
5
+ * @param {HeadersInit} headers - The headers to map.
6
+ * @returns {Record<string, string>} A plain object with header key-value pairs.
7
+ * @private
8
+ */
9
+ static mapHeaders(e) {
10
+ return e instanceof Headers ? Object.fromEntries(e.entries()) : typeof e == "object" ? Object.entries(e).reduce(
11
+ (r, [t, s]) => (typeof s == "string" ? r[t] = s : Array.isArray(s) ? r[t] = s.join(", ") : r[t] = JSON.stringify(s), r),
12
+ {}
13
+ ) : {};
14
+ }
15
+ /**
16
+ * Converts URLSearchParams into a plain key-value object.
17
+ *
18
+ * @param {URLSearchParams} queryParams - The query parameters to map.
19
+ * @returns {Record<string, string>} A plain object with query parameter key-value pairs.
20
+ * @private
21
+ */
22
+ static mapQueryParams(e) {
23
+ const r = {};
24
+ return e.forEach((t, s) => r[s] = t), r;
25
+ }
26
+ /**
27
+ * Transforms raw HTTP request/response data into a standardized log output format.
28
+ *
29
+ * @param {InputProps} props - The input properties containing request/response data.
30
+ * @returns {OutputProps} The mapped output object ready for logging.
31
+ */
32
+ static handle(e) {
33
+ return {
34
+ rawUrl: e.rawUrl,
35
+ status: e.status,
36
+ method: e.method,
37
+ token: null,
38
+ elapsedTime: e.elapsedTime,
39
+ requestHeaders: this.mapHeaders(e.requestHeaders),
40
+ requestBody: e.requestBody || null,
41
+ queryParams: {
42
+ ...this.mapQueryParams(e.queryParams),
43
+ ...e.urlParams
44
+ },
45
+ responseHeaders: this.mapHeaders(e.responseHeaders),
46
+ responseBody: e.responseBody || null
47
+ };
48
+ }
49
+ }
50
+ export {
51
+ n as LogMapperService
52
+ };
@@ -0,0 +1,31 @@
1
+ var r = Object.defineProperty;
2
+ var g = (i, t, s) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[t] = s;
3
+ var o = (i, t, s) => g(i, typeof t != "symbol" ? t + "" : t, s);
4
+ class f {
5
+ /**
6
+ * Sets the log service configuration once. Subsequent calls are ignored.
7
+ *
8
+ * @param config.trafficSourceId - Traffic source identifier.
9
+ * @param config.userToken - User token for authentication.
10
+ * @param config.logBaseApiUrl - Override the default log ingestion base URL.
11
+ */
12
+ static setConfig(t) {
13
+ if (this.config) return;
14
+ const { trafficSourceId: s, userToken: c, logBaseApiUrl: n } = t, e = `${n || "http://62.238.8.44:8081"}/ingest-log`;
15
+ this.config = { trafficSourceId: s, userToken: c, apiUrl: e };
16
+ }
17
+ /** Returns the stored configuration, or `undefined` if `setConfig` has not been called. */
18
+ static getConfig() {
19
+ return this.config;
20
+ }
21
+ /**
22
+ * Resets the stored configuration, allowing a new initialization.
23
+ */
24
+ static resetConfig() {
25
+ this.config = void 0;
26
+ }
27
+ }
28
+ o(f, "config");
29
+ export {
30
+ f as LogService
31
+ };
@@ -0,0 +1,22 @@
1
+ import { BadRequest as a } from "../http/badResponses/badRequest.js";
2
+ async function d(o) {
3
+ let r;
4
+ const c = await o.arrayBuffer(), e = new TextDecoder().decode(c);
5
+ try {
6
+ r = JSON.parse(e);
7
+ } catch {
8
+ try {
9
+ if (e.includes("=")) {
10
+ const t = new URLSearchParams(e);
11
+ r = Object.fromEntries(t.entries());
12
+ } else
13
+ throw new a("Invalid URLSearchParams format");
14
+ } catch {
15
+ throw new a("Failed to extract data from request");
16
+ }
17
+ }
18
+ return r;
19
+ }
20
+ export {
21
+ d as decodeRequestBody
22
+ };
@@ -0,0 +1,7 @@
1
+ function o(r, e) {
2
+ var g, i, f;
3
+ return r != null && r.message && typeof (r == null ? void 0 : r.message) == "string" ? r == null ? void 0 : r.message : r != null && r.operator_erro_message && typeof (r == null ? void 0 : r.operator_erro_message) == "string" ? r == null ? void 0 : r.operator_erro_message : r != null && r.error && typeof (r == null ? void 0 : r.error) == "string" ? r == null ? void 0 : r.error : (g = r == null ? void 0 : r.error) != null && g.message && typeof ((i = r == null ? void 0 : r.error) == null ? void 0 : i.message) == "string" ? (f = r == null ? void 0 : r.error) == null ? void 0 : f.message : e != null && e.statusText && typeof (e == null ? void 0 : e.statusText) == "string" ? e == null ? void 0 : e.statusText : "Missing error message";
4
+ }
5
+ export {
6
+ o as decodeRequestErrorMessage
7
+ };
@@ -0,0 +1,54 @@
1
+ import { BadGateway as e } from "../http/badResponses/badGateway.js";
2
+ import { BadRequest as s } from "../http/badResponses/badRequest.js";
3
+ import { Conflict as o } from "../http/badResponses/conflict.js";
4
+ import { Forbidden as a } from "../http/badResponses/forbidden.js";
5
+ import { NotFound as c } from "../http/badResponses/notFound.js";
6
+ import { NotImplemented as i } from "../http/badResponses/notImplemented.js";
7
+ import { ServerError as n } from "../http/badResponses/serverError.js";
8
+ import { Unauthorized as p } from "../http/badResponses/unauthorized.js";
9
+ import { UnprocessableEntity as f } from "../http/badResponses/unprocessableEntity.js";
10
+ import { Created as m } from "../http/successResponses/created.js";
11
+ import { Found as u } from "../http/successResponses/found.js";
12
+ import { NoContent as R } from "../http/successResponses/noContent.js";
13
+ import { Success as d } from "../http/successResponses/success.js";
14
+ import { Updated as l } from "../http/successResponses/updated.js";
15
+ function z(t) {
16
+ switch (!0) {
17
+ case t instanceof Response:
18
+ return t;
19
+ case t instanceof u:
20
+ return t.toResponse();
21
+ case t instanceof m:
22
+ return t.toResponse();
23
+ case t instanceof l:
24
+ return t.toResponse();
25
+ case t instanceof d:
26
+ return t.toResponse();
27
+ case t instanceof R:
28
+ return t.toResponse();
29
+ }
30
+ switch (!0) {
31
+ case t instanceof e:
32
+ return t.toResponse();
33
+ case t instanceof s:
34
+ return t.toResponse();
35
+ case t instanceof o:
36
+ return t.toResponse();
37
+ case t instanceof a:
38
+ return t.toResponse();
39
+ case t instanceof c:
40
+ return t.toResponse();
41
+ case t instanceof i:
42
+ return t.toResponse();
43
+ case t instanceof n:
44
+ return t.toResponse();
45
+ case t instanceof p:
46
+ return t.toResponse();
47
+ case t instanceof f:
48
+ return t.toResponse();
49
+ }
50
+ return new n("Server error", t).toResponse();
51
+ }
52
+ export {
53
+ z as errorHandler
54
+ };
@@ -0,0 +1,20 @@
1
+ function r(e) {
2
+ var s;
3
+ if (process.env.NODE_ENV === "development" || ((s = process.env) == null ? void 0 : s.DEBUG_MODE) === "true") {
4
+ const n = `${{
5
+ yellow: "\x1B[33m",
6
+ cyan: "\x1B[36m",
7
+ red: "\x1B[31m",
8
+ green: "\x1B[32m"
9
+ }[e.scheme]}[${e.name}]\x1B[0m`;
10
+ let o = `
11
+ `;
12
+ e.debugs.forEach((c, t) => {
13
+ o += `${n} ${c.trim()}`, t < e.debugs.length - 1 && (o += `
14
+ `);
15
+ }), console.log(o);
16
+ }
17
+ }
18
+ export {
19
+ r as flushDebugLogs
20
+ };
@@ -0,0 +1,19 @@
1
+ async function a([
2
+ e,
3
+ c
4
+ ]) {
5
+ const s = await c.safeParseAsync(e);
6
+ return s.success === !1 ? {
7
+ success: !1,
8
+ fieldErrors: Object.fromEntries(
9
+ s.error.issues.map((r) => [r.path.join("."), r.message])
10
+ ),
11
+ fields: e
12
+ } : {
13
+ success: !0,
14
+ data: s.data
15
+ };
16
+ }
17
+ export {
18
+ a as formAsyncParse
19
+ };
@@ -0,0 +1,19 @@
1
+ function o([
2
+ e,
3
+ t
4
+ ]) {
5
+ const s = t.safeParse(e);
6
+ return s.success === !1 ? {
7
+ success: !1,
8
+ fieldErrors: Object.fromEntries(
9
+ s.error.issues.map((r) => [r.path.join("."), r.message])
10
+ ),
11
+ fields: e
12
+ } : {
13
+ success: !0,
14
+ data: s.data
15
+ };
16
+ }
17
+ export {
18
+ o as formParse
19
+ };
@@ -0,0 +1,11 @@
1
+ function c(t, r = "") {
2
+ const e = new URL(t.url);
3
+ if (r === "") return e.searchParams;
4
+ const s = Array.from(
5
+ e.searchParams.entries()
6
+ ).filter(([a]) => a.startsWith(`${r}:`)).map(([a, n]) => [a.replace(`${r}:`, ""), n]);
7
+ return new URLSearchParams(s);
8
+ }
9
+ export {
10
+ c as getScopedParams
11
+ };