@arkyn/server 3.0.1-beta.160 → 3.0.1-beta.168

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 (134) hide show
  1. package/package.json +18 -9
  2. package/dist/http/api/_logRequest.d.ts +0 -58
  3. package/dist/http/api/_logRequest.d.ts.map +0 -1
  4. package/dist/http/api/_makeRequest.d.ts +0 -61
  5. package/dist/http/api/_makeRequest.d.ts.map +0 -1
  6. package/dist/http/api/deleteRequest.d.ts +0 -17
  7. package/dist/http/api/deleteRequest.d.ts.map +0 -1
  8. package/dist/http/api/getRequest.d.ts +0 -16
  9. package/dist/http/api/getRequest.d.ts.map +0 -1
  10. package/dist/http/api/patchRequest.d.ts +0 -17
  11. package/dist/http/api/patchRequest.d.ts.map +0 -1
  12. package/dist/http/api/postRequest.d.ts +0 -17
  13. package/dist/http/api/postRequest.d.ts.map +0 -1
  14. package/dist/http/api/putRequest.d.ts +0 -17
  15. package/dist/http/api/putRequest.d.ts.map +0 -1
  16. package/dist/http/badResponses/_badResponse.d.ts +0 -25
  17. package/dist/http/badResponses/_badResponse.d.ts.map +0 -1
  18. package/dist/http/badResponses/badGateway.d.ts +0 -24
  19. package/dist/http/badResponses/badGateway.d.ts.map +0 -1
  20. package/dist/http/badResponses/badRequest.d.ts +0 -22
  21. package/dist/http/badResponses/badRequest.d.ts.map +0 -1
  22. package/dist/http/badResponses/conflict.d.ts +0 -22
  23. package/dist/http/badResponses/conflict.d.ts.map +0 -1
  24. package/dist/http/badResponses/forbidden.d.ts +0 -22
  25. package/dist/http/badResponses/forbidden.d.ts.map +0 -1
  26. package/dist/http/badResponses/notFound.d.ts +0 -22
  27. package/dist/http/badResponses/notFound.d.ts.map +0 -1
  28. package/dist/http/badResponses/notImplemented.d.ts +0 -22
  29. package/dist/http/badResponses/notImplemented.d.ts.map +0 -1
  30. package/dist/http/badResponses/serverError.d.ts +0 -22
  31. package/dist/http/badResponses/serverError.d.ts.map +0 -1
  32. package/dist/http/badResponses/unauthorized.d.ts +0 -22
  33. package/dist/http/badResponses/unauthorized.d.ts.map +0 -1
  34. package/dist/http/badResponses/unprocessableEntity.d.ts +0 -34
  35. package/dist/http/badResponses/unprocessableEntity.d.ts.map +0 -1
  36. package/dist/http/successResponses/_successResponse.d.ts +0 -36
  37. package/dist/http/successResponses/_successResponse.d.ts.map +0 -1
  38. package/dist/http/successResponses/created.d.ts +0 -22
  39. package/dist/http/successResponses/created.d.ts.map +0 -1
  40. package/dist/http/successResponses/found.d.ts +0 -22
  41. package/dist/http/successResponses/found.d.ts.map +0 -1
  42. package/dist/http/successResponses/noContent.d.ts +0 -20
  43. package/dist/http/successResponses/noContent.d.ts.map +0 -1
  44. package/dist/http/successResponses/success.d.ts +0 -22
  45. package/dist/http/successResponses/success.d.ts.map +0 -1
  46. package/dist/http/successResponses/updated.d.ts +0 -23
  47. package/dist/http/successResponses/updated.d.ts.map +0 -1
  48. package/dist/index.d.ts +0 -34
  49. package/dist/index.d.ts.map +0 -1
  50. package/dist/index.js +0 -1301
  51. package/dist/modules/http/api/_logRequest.js +0 -69
  52. package/dist/modules/http/api/_makeRequest.js +0 -69
  53. package/dist/modules/http/api/deleteRequest.js +0 -13
  54. package/dist/modules/http/api/getRequest.js +0 -12
  55. package/dist/modules/http/api/patchRequest.js +0 -13
  56. package/dist/modules/http/api/postRequest.js +0 -13
  57. package/dist/modules/http/api/putRequest.js +0 -13
  58. package/dist/modules/http/badResponses/_badResponse.js +0 -59
  59. package/dist/modules/http/badResponses/badGateway.js +0 -30
  60. package/dist/modules/http/badResponses/badRequest.js +0 -30
  61. package/dist/modules/http/badResponses/conflict.js +0 -30
  62. package/dist/modules/http/badResponses/forbidden.js +0 -30
  63. package/dist/modules/http/badResponses/notFound.js +0 -30
  64. package/dist/modules/http/badResponses/notImplemented.js +0 -30
  65. package/dist/modules/http/badResponses/serverError.js +0 -30
  66. package/dist/modules/http/badResponses/unauthorized.js +0 -30
  67. package/dist/modules/http/badResponses/unprocessableEntity.js +0 -36
  68. package/dist/modules/http/successResponses/_successResponse.js +0 -69
  69. package/dist/modules/http/successResponses/created.js +0 -30
  70. package/dist/modules/http/successResponses/found.js +0 -30
  71. package/dist/modules/http/successResponses/noContent.js +0 -21
  72. package/dist/modules/http/successResponses/success.js +0 -30
  73. package/dist/modules/http/successResponses/updated.js +0 -30
  74. package/dist/modules/index.js +0 -68
  75. package/dist/modules/services/apiService.js +0 -129
  76. package/dist/modules/services/debugService.js +0 -66
  77. package/dist/modules/services/logMapperService.js +0 -52
  78. package/dist/modules/services/logService.js +0 -31
  79. package/dist/modules/utilities/decodeRequestBody.js +0 -22
  80. package/dist/modules/utilities/decodeRequestErrorMessage.js +0 -7
  81. package/dist/modules/utilities/errorHandler.js +0 -54
  82. package/dist/modules/utilities/flushDebugLogs.js +0 -20
  83. package/dist/modules/utilities/formAsyncParse.js +0 -19
  84. package/dist/modules/utilities/formParse.js +0 -19
  85. package/dist/modules/utilities/getScopedParams.js +0 -11
  86. package/dist/modules/utilities/schemaValidator.js +0 -106
  87. package/dist/modules/validations/validateCep.js +0 -9
  88. package/dist/modules/validations/validateCnpj.js +0 -31
  89. package/dist/modules/validations/validateCpf.js +0 -28
  90. package/dist/modules/validations/validateDate.js +0 -27
  91. package/dist/modules/validations/validateEmail.js +0 -53
  92. package/dist/modules/validations/validatePassword.js +0 -16
  93. package/dist/modules/validations/validatePhone.js +0 -10
  94. package/dist/modules/validations/validateRg.js +0 -8
  95. package/dist/services/apiService.d.ts +0 -83
  96. package/dist/services/apiService.d.ts.map +0 -1
  97. package/dist/services/debugService.d.ts +0 -37
  98. package/dist/services/debugService.d.ts.map +0 -1
  99. package/dist/services/logMapperService.d.ts +0 -86
  100. package/dist/services/logMapperService.d.ts.map +0 -1
  101. package/dist/services/logService.d.ts +0 -33
  102. package/dist/services/logService.d.ts.map +0 -1
  103. package/dist/utilities/decodeRequestBody.d.ts +0 -18
  104. package/dist/utilities/decodeRequestBody.d.ts.map +0 -1
  105. package/dist/utilities/decodeRequestErrorMessage.d.ts +0 -19
  106. package/dist/utilities/decodeRequestErrorMessage.d.ts.map +0 -1
  107. package/dist/utilities/errorHandler.d.ts +0 -25
  108. package/dist/utilities/errorHandler.d.ts.map +0 -1
  109. package/dist/utilities/flushDebugLogs.d.ts +0 -24
  110. package/dist/utilities/flushDebugLogs.d.ts.map +0 -1
  111. package/dist/utilities/formAsyncParse.d.ts +0 -38
  112. package/dist/utilities/formAsyncParse.d.ts.map +0 -1
  113. package/dist/utilities/formParse.d.ts +0 -38
  114. package/dist/utilities/formParse.d.ts.map +0 -1
  115. package/dist/utilities/getScopedParams.d.ts +0 -19
  116. package/dist/utilities/getScopedParams.d.ts.map +0 -1
  117. package/dist/utilities/schemaValidator.d.ts +0 -75
  118. package/dist/utilities/schemaValidator.d.ts.map +0 -1
  119. package/dist/validations/validateCep.d.ts +0 -19
  120. package/dist/validations/validateCep.d.ts.map +0 -1
  121. package/dist/validations/validateCnpj.d.ts +0 -21
  122. package/dist/validations/validateCnpj.d.ts.map +0 -1
  123. package/dist/validations/validateCpf.d.ts +0 -16
  124. package/dist/validations/validateCpf.d.ts.map +0 -1
  125. package/dist/validations/validateDate.d.ts +0 -23
  126. package/dist/validations/validateDate.d.ts.map +0 -1
  127. package/dist/validations/validateEmail.d.ts +0 -21
  128. package/dist/validations/validateEmail.d.ts.map +0 -1
  129. package/dist/validations/validatePassword.d.ts +0 -20
  130. package/dist/validations/validatePassword.d.ts.map +0 -1
  131. package/dist/validations/validatePhone.d.ts +0 -16
  132. package/dist/validations/validatePhone.d.ts.map +0 -1
  133. package/dist/validations/validateRg.d.ts +0 -21
  134. package/dist/validations/validateRg.d.ts.map +0 -1
@@ -1,106 +0,0 @@
1
- import { ServerError as i } from "../http/badResponses/serverError.js";
2
- import { UnprocessableEntity as a } from "../http/badResponses/unprocessableEntity.js";
3
- import { formAsyncParse as f } from "./formAsyncParse.js";
4
- import { formParse as n } from "./formParse.js";
5
- function c(o) {
6
- const r = "Error validating:", e = o.issues.map(
7
- ({ path: s, message: t }) => `-> ${s.join(".")}: ${t}`
8
- );
9
- return [r, ...e].join(`
10
- `);
11
- }
12
- class E {
13
- /**
14
- * @param schema - The Zod schema used for all validation methods on this instance.
15
- */
16
- constructor(r) {
17
- this.schema = r;
18
- }
19
- /**
20
- * Returns `true` if the data satisfies the schema, `false` otherwise. Never throws.
21
- *
22
- * @param data - The value to check.
23
- */
24
- isValid(r) {
25
- return this.schema.safeParse(r).success;
26
- }
27
- /**
28
- * Validates data and returns the raw Zod `safeParseResult` without throwing.
29
- * Useful when you need access to the full error details.
30
- *
31
- * @param data - The value to validate.
32
- */
33
- safeValidate(r) {
34
- return this.schema.safeParse(r);
35
- }
36
- /**
37
- * Validates data and returns the typed result, throwing `ServerError` on failure.
38
- * Use for validating internal/trusted data (e.g. env vars, config objects).
39
- *
40
- * @param data - The value to validate.
41
- * @throws `ServerError` with a formatted field-by-field error message.
42
- */
43
- validate(r) {
44
- try {
45
- return this.schema.parse(r);
46
- } catch (e) {
47
- throw new i(c(e));
48
- }
49
- }
50
- /**
51
- * Validates form data and returns the typed result, throwing `UnprocessableEntity` on failure.
52
- * The error includes `fieldErrors`, `fields`, and `data.scrollTo` (first failing field name).
53
- *
54
- * @param data - The raw form data to validate.
55
- * @param message - Optional human-readable error message for the 422 response.
56
- * @throws `UnprocessableEntity` with structured field errors for client-side form handling.
57
- *
58
- * @example
59
- * ```typescript
60
- * const validator = new SchemaValidator(registerSchema);
61
- * const body = validator.formValidate(await decodeRequestBody(request));
62
- * ```
63
- */
64
- formValidate(r, e) {
65
- const s = n([r, this.schema]);
66
- if ("fieldErrors" in s) {
67
- const t = Object.keys(s.fieldErrors)[0];
68
- throw new a({
69
- fields: s.fields,
70
- fieldErrors: s.fieldErrors,
71
- data: { scrollTo: t },
72
- message: e
73
- });
74
- }
75
- return s.data;
76
- }
77
- /**
78
- * Async version of `formValidate` for schemas with async refinements (e.g. uniqueness checks).
79
- *
80
- * @param data - The raw form data to validate.
81
- * @param message - Optional human-readable error message for the 422 response.
82
- * @throws `UnprocessableEntity` with structured field errors for client-side form handling.
83
- *
84
- * @example
85
- * ```typescript
86
- * const validator = new SchemaValidator(registerSchema);
87
- * const body = await validator.formAsyncValidate(await decodeRequestBody(request));
88
- * ```
89
- */
90
- async formAsyncValidate(r, e) {
91
- const s = await f([r, this.schema]);
92
- if ("fieldErrors" in s) {
93
- const t = Object.keys(s.fieldErrors)[0];
94
- throw new a({
95
- fields: s.fields,
96
- fieldErrors: s.fieldErrors,
97
- data: { scrollTo: t },
98
- message: e
99
- });
100
- }
101
- return s.data;
102
- }
103
- }
104
- export {
105
- E as SchemaValidator
106
- };
@@ -1,9 +0,0 @@
1
- import { removeNonNumeric as i } from "@arkyn/shared";
2
- function c(t) {
3
- if (!(/^\d{5}-\d{3}$/.test(t) || /^\d{8}$/.test(t))) return !1;
4
- const e = i(t), o = 8, n = /^\d{8}$/.test(e);
5
- return e.length === o && n;
6
- }
7
- export {
8
- c as validateCep
9
- };
@@ -1,31 +0,0 @@
1
- import { removeNonNumeric as f } from "@arkyn/shared";
2
- function l(t) {
3
- return t.length !== 14;
4
- }
5
- function o(t) {
6
- const [i] = t;
7
- return [...t].every((e) => e === i);
8
- }
9
- function s(t, i) {
10
- let e = 0;
11
- for (let n = 0; n < i.length; n++)
12
- e += parseInt(t[n]) * i[n];
13
- const r = e % 11;
14
- return r < 2 ? 0 : 11 - r;
15
- }
16
- function u(t) {
17
- return t.slice(12);
18
- }
19
- function g(t) {
20
- if (!t || t.length > 18 || t.length < 14 || /\s/.test(t)) return !1;
21
- const e = f(t);
22
- if (l(e) || o(e)) return !1;
23
- const r = e.slice(0, 12), n = s(r, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), c = s(
24
- r + n,
25
- [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
26
- );
27
- return u(e) === `${n}${c}`;
28
- }
29
- export {
30
- g as validateCnpj
31
- };
@@ -1,28 +0,0 @@
1
- import { removeNonNumeric as o } from "@arkyn/shared";
2
- function c(t) {
3
- return t.length !== 11;
4
- }
5
- function f(t) {
6
- const [n] = t;
7
- return [...t].every((e) => e === n);
8
- }
9
- function s(t, n) {
10
- let e = 0;
11
- for (const r of t)
12
- n > 1 && (e += parseInt(r) * n--);
13
- const i = e % 11;
14
- return i < 2 ? 0 : 11 - i;
15
- }
16
- function l(t) {
17
- return t.slice(9);
18
- }
19
- function a(t) {
20
- if (!t || t.length > 14 || t.length < 11 || /\s/.test(t)) return !1;
21
- const e = o(t);
22
- if (c(e) || f(e)) return !1;
23
- const i = s(e, 10), r = s(e, 11);
24
- return l(e) === `${i}${r}`;
25
- }
26
- export {
27
- a as validateCpf
28
- };
@@ -1,27 +0,0 @@
1
- import { ValidateDateService as D } from "@arkyn/shared";
2
- function v(i, a) {
3
- const m = (a == null ? void 0 : a.inputFormat) || "brazilianDate", u = (a == null ? void 0 : a.minYear) || 1900, d = (a == null ? void 0 : a.maxYear) || 3e3, s = new D();
4
- s.validateInputFormat(m);
5
- let e, r, t;
6
- const l = i.split(/[-/]/).map(Number);
7
- if (l.length !== 3) return !1;
8
- try {
9
- switch (m) {
10
- case "brazilianDate":
11
- [e, r, t] = l, s.validateDateParts(t, r, e);
12
- break;
13
- case "isoDate":
14
- [r, e, t] = l, s.validateDateParts(t, r, e);
15
- break;
16
- case "timestamp":
17
- [t, r, e] = l, s.validateDateParts(t, r, e);
18
- break;
19
- }
20
- return !(t < u || t > d);
21
- } catch {
22
- return !1;
23
- }
24
- }
25
- export {
26
- v as validateDate
27
- };
@@ -1,53 +0,0 @@
1
- import s from "node:dns";
2
- function i(t) {
3
- 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(t);
4
- }
5
- function f(t) {
6
- return !(t.length === 0 || t.length > 64 || t.startsWith(".") || t.endsWith(".") || t.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(t));
7
- }
8
- function a(t) {
9
- return !(t.length === 0 || t.length > 63 || t.startsWith("-") || t.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(t));
10
- }
11
- function u(t) {
12
- if (t.length === 0 || t.length > 253 || t.startsWith(".") || t.endsWith(".") || t.startsWith("-") || t.endsWith("-"))
13
- return !1;
14
- const e = t.split(".");
15
- if (e.length < 2) return !1;
16
- for (const r of e) if (!a(r)) return !1;
17
- const n = e[e.length - 1];
18
- return !(n.length < 2 || !/^[a-zA-Z]+$/.test(n));
19
- }
20
- function l(t) {
21
- const e = t.split("@");
22
- if (e.length !== 2) return !1;
23
- const [n, r] = e;
24
- return !(!f(n) || !u(r));
25
- }
26
- function o(t) {
27
- const e = t.split("@");
28
- return e.length === 2 ? e[1].toLowerCase() : null;
29
- }
30
- const c = ["MX", "A", "AAAA"];
31
- async function h(t, e) {
32
- var n, r;
33
- try {
34
- return await ((r = (n = s) == null ? void 0 : n.promises) == null ? void 0 : r.resolve(t, e)), !0;
35
- } catch {
36
- return !1;
37
- }
38
- }
39
- async function d(t) {
40
- for (const e of c)
41
- if (await h(t, e)) return !0;
42
- return !1;
43
- }
44
- async function A(t) {
45
- if (!t || typeof t != "string") return !1;
46
- const e = t.trim();
47
- if (!i(e) || !l(e)) return !1;
48
- const n = o(e);
49
- return n ? await d(n) : !1;
50
- }
51
- export {
52
- A as validateEmail
53
- };
@@ -1,16 +0,0 @@
1
- function l(t) {
2
- if (!t) return !1;
3
- const e = t.length >= 8, n = /[A-Z]/.test(t), c = /[a-z]/.test(t), h = /\d/.test(t), s = /[!@#$%^&*(),.?":;{}|<>_\-+=~`[\]\\\/]/.test(
4
- t
5
- );
6
- return [
7
- e,
8
- n,
9
- c,
10
- h,
11
- s
12
- ].every((i) => i);
13
- }
14
- export {
15
- l as validatePassword
16
- };
@@ -1,10 +0,0 @@
1
- import { countries as e } from "@arkyn/templates";
2
- import { isValidPhoneNumber as i, parsePhoneNumberWithError as u } from "libphonenumber-js";
3
- function m(t) {
4
- if (!i(t)) return !1;
5
- const r = u(t), o = r == null ? void 0 : r.country;
6
- return !(!o || !e.find((n) => n.iso === o));
7
- }
8
- export {
9
- m as validatePhone
10
- };
@@ -1,8 +0,0 @@
1
- function i(t) {
2
- if (!t || !/^[0-9a-zA-Z.-]+$/.test(t)) return !1;
3
- const e = t.replace(/[^a-zA-Z0-9]/g, "");
4
- return e.length < 7 || e.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(e);
5
- }
6
- export {
7
- i as validateRg
8
- };
@@ -1,83 +0,0 @@
1
- type ApiServiceConstructorProps = {
2
- /** Base URL prepended to every request path (e.g. `"https://api.example.com"`). */
3
- baseUrl: string;
4
- /** Default headers merged into every request. */
5
- baseHeaders?: HeadersInit;
6
- /** Default Bearer token; can be overridden per request via `data.token`. */
7
- baseToken?: string | null;
8
- /** When `true`, logs each request and response to the console in development. */
9
- enableDebug?: boolean;
10
- };
11
- type ApiRequestDataWithoutBodyProps = {
12
- headers?: HeadersInit;
13
- token?: string;
14
- urlParams?: Record<string, string>;
15
- };
16
- type ApiRequestDataWithBodyProps = {
17
- body?: any;
18
- headers?: HeadersInit;
19
- token?: string;
20
- urlParams?: Record<string, string>;
21
- };
22
- /**
23
- * HTTP client for external API calls. Wraps fetch with base URL, default headers, optional auth token,
24
- * and per-request overrides for all standard HTTP methods.
25
- *
26
- * @example
27
- * ```typescript
28
- * const api = new ApiService({
29
- * baseUrl: "https://api.example.com",
30
- * baseToken: session.token,
31
- * enableDebug: true,
32
- * });
33
- *
34
- * const { data } = await api.get("/users/me");
35
- * const { data: created } = await api.post("/orders", { body: { productId: 1 } });
36
- * ```
37
- */
38
- declare class ApiService {
39
- private baseUrl;
40
- private baseHeaders?;
41
- private baseToken?;
42
- private enableDebug?;
43
- constructor(props: ApiServiceConstructorProps);
44
- private onDebug;
45
- private generateHeaders;
46
- /**
47
- * Sends a get request to the specified endpoint.
48
- * @param endpoint - The API endpoint to send the get request to.
49
- * @param data - The request data, including optional headers and token.
50
- * @returns The API response data.
51
- */
52
- get(endpoint: string, data?: ApiRequestDataWithoutBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
53
- /**
54
- * Sends a post request to the specified endpoint.
55
- * @param endpoint - The API endpoint to send the post request to.
56
- * @param data - The request data, including body, optional headers, and token.
57
- * @returns The API response data.
58
- */
59
- post(endpoint: string, data?: ApiRequestDataWithBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
60
- /**
61
- * Sends a put request to the specified endpoint.
62
- * @param endpoint - The API endpoint to send the put request to.
63
- * @param data - The request data, including body, optional headers, and token.
64
- * @returns The API response data.
65
- */
66
- put(endpoint: string, data?: ApiRequestDataWithBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
67
- /**
68
- * Sends a patch request to the specified endpoint.
69
- * @param endpoint - The API endpoint to send the patch request to.
70
- * @param data - The request data, including body, optional headers, and token.
71
- * @returns The API response data.
72
- */
73
- patch(endpoint: string, data?: ApiRequestDataWithBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
74
- /**
75
- * Sends a delete request to the specified endpoint.
76
- * @param endpoint - The API endpoint to send the delete request to.
77
- * @param data - The request data, including body, optional headers, and token.
78
- * @returns The API response data.
79
- */
80
- delete(endpoint: string, data?: ApiRequestDataWithBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
81
- }
82
- export { ApiService };
83
- //# sourceMappingURL=apiService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apiService.d.ts","sourceRoot":"","sources":["../../src/services/apiService.ts"],"names":[],"mappings":"AAOA,KAAK,0BAA0B,GAAG;IAChC,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,iFAAiF;IACjF,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;;;;;;;;;;;;;;;GAeG;AACH,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"}
@@ -1,37 +0,0 @@
1
- /**
2
- * Manages stack-trace configuration for debug output, allowing specific adapter/wrapper files
3
- * to be skipped so logs show the actual business-logic caller.
4
- *
5
- * @example
6
- * ```typescript
7
- * // Skip httpAdapter.ts so debug output shows the calling route instead
8
- * DebugService.setIgnoreFile("httpAdapter.ts");
9
- * ```
10
- */
11
- declare class DebugService {
12
- /**
13
- * The name of the file to ignore when analyzing the stack trace.
14
- * When set, the `getCaller` function will skip stack frames containing this file name.
15
- */
16
- static ignoreFiles: string[];
17
- /**
18
- * Adds a file name to the ignore list so it is skipped when resolving the caller in stack traces.
19
- *
20
- * @param file - File name to ignore (e.g. `"httpAdapter.ts"`).
21
- */
22
- static setIgnoreFile(file: string): void;
23
- /** Resets the ignore list, restoring full stack trace analysis. */
24
- static clearIgnoreFiles(): void;
25
- /**
26
- * Resolves the file path and function name of the code that triggered the current debug call,
27
- * skipping internal node modules and any files registered with `setIgnoreFile`.
28
- *
29
- * @returns `{ functionName, callerInfo }` — caller function name and file path relative to `process.cwd()`.
30
- */
31
- static getCaller(): {
32
- functionName: string;
33
- callerInfo: string;
34
- };
35
- }
36
- export { DebugService };
37
- //# sourceMappingURL=debugService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debugService.d.ts","sourceRoot":"","sources":["../../src/services/debugService.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,cAAM,YAAY;IAChB;;;OAGG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CAAM;IAElC;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxC,mEAAmE;IACnE,MAAM,CAAC,gBAAgB,IAAI,IAAI;IAI/B;;;;;OAKG;IACH,MAAM,CAAC,SAAS;;;;CAgEjB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1,86 +0,0 @@
1
- /**
2
- * Input properties for log mapping.
3
- *
4
- * @typedef {object} InputProps
5
- * @property {number} status - HTTP response status code.
6
- * @property {string} url - The request URL.
7
- * @property {"GET" | "POST" | "PUT" | "DELETE" | "PATCH"} method - HTTP method used.
8
- * @property {HeadersInit} requestHeaders - Headers sent with the request.
9
- * @property {HeadersInit} responseHeaders - Headers received in the response.
10
- * @property {any} requestBody - Body of the request.
11
- * @property {number} elapsedTime - Time elapsed for the request in milliseconds.
12
- * @property {any} responseBody - Body of the response.
13
- * @property {URLSearchParams} queryParams - Query parameters from the URL.
14
- */
15
- type InputProps = {
16
- status: number;
17
- rawUrl: string;
18
- urlParams?: Record<string, string>;
19
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
20
- requestHeaders: HeadersInit;
21
- responseHeaders: HeadersInit;
22
- requestBody: any;
23
- elapsedTime: number;
24
- responseBody: any;
25
- queryParams: URLSearchParams;
26
- };
27
- /**
28
- * Output properties after log mapping transformation.
29
- *
30
- * @typedef {object} OutputProps
31
- * @property {string} rawUrl - The original request URL.
32
- * @property {number} status - HTTP response status code.
33
- * @property {"GET" | "POST" | "PUT" | "DELETE" | "PATCH"} method - HTTP method used.
34
- * @property {string | null} token - Authentication token (if present).
35
- * @property {number} elapsedTime - Time elapsed for the request in milliseconds.
36
- * @property {Record<string, string>} requestHeaders - Mapped request headers.
37
- * @property {Record<string, string>} requestBody - Mapped request body.
38
- * @property {Record<string, string>} queryParams - Mapped query parameters.
39
- * @property {Record<string, string>} responseHeaders - Mapped response headers.
40
- * @property {any} responseBody - The response body.
41
- */
42
- type OutputProps = {
43
- rawUrl: string;
44
- status: number;
45
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
46
- token: string | null;
47
- elapsedTime: number;
48
- requestHeaders: Record<string, string>;
49
- requestBody: Record<string, string>;
50
- queryParams: Record<string, string>;
51
- responseHeaders: Record<string, string>;
52
- responseBody: any;
53
- };
54
- /**
55
- * Static service for mapping HTTP request/response data into a standardized log format.
56
- *
57
- * Provides utilities to transform headers and query parameters into plain objects,
58
- * and produces a unified output structure for logging purposes.
59
- */
60
- declare class LogMapperService {
61
- /**
62
- * Converts various header formats into a plain key-value object.
63
- *
64
- * @param {HeadersInit} headers - The headers to map.
65
- * @returns {Record<string, string>} A plain object with header key-value pairs.
66
- * @private
67
- */
68
- private static mapHeaders;
69
- /**
70
- * Converts URLSearchParams into a plain key-value object.
71
- *
72
- * @param {URLSearchParams} queryParams - The query parameters to map.
73
- * @returns {Record<string, string>} A plain object with query parameter key-value pairs.
74
- * @private
75
- */
76
- private static mapQueryParams;
77
- /**
78
- * Transforms raw HTTP request/response data into a standardized log output format.
79
- *
80
- * @param {InputProps} props - The input properties containing request/response data.
81
- * @returns {OutputProps} The mapped output object ready for logging.
82
- */
83
- static handle(props: InputProps): OutputProps;
84
- }
85
- export { LogMapperService };
86
- //# sourceMappingURL=logMapperService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logMapperService.d.ts","sourceRoot":"","sources":["../../src/services/logMapperService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,cAAc,EAAE,WAAW,CAAC;IAC5B,eAAe,EAAE,WAAW,CAAC;IAC7B,WAAW,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC;IAClB,WAAW,EAAE,eAAe,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,YAAY,EAAE,GAAG,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,cAAM,gBAAgB;IACpB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAiBzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAQ7B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW;CAiB9C;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Static service for log endpoint configuration and access.
3
- *
4
- * Stores a singleton configuration containing the traffic source identifier,
5
- * user token, and log ingestion URL.
6
- */
7
- declare class LogService {
8
- private static config?;
9
- /**
10
- * Sets the log service configuration once. Subsequent calls are ignored.
11
- *
12
- * @param config.trafficSourceId - Traffic source identifier.
13
- * @param config.userToken - User token for authentication.
14
- * @param config.logBaseApiUrl - Override the default log ingestion base URL.
15
- */
16
- static setConfig(config: {
17
- trafficSourceId: string;
18
- userToken: string;
19
- logBaseApiUrl?: string;
20
- }): void;
21
- /** Returns the stored configuration, or `undefined` if `setConfig` has not been called. */
22
- static getConfig(): {
23
- trafficSourceId: string;
24
- userToken: string;
25
- apiUrl: string;
26
- } | undefined;
27
- /**
28
- * Resets the stored configuration, allowing a new initialization.
29
- */
30
- static resetConfig(): void;
31
- }
32
- export { LogService };
33
- //# sourceMappingURL=logService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logService.d.ts","sourceRoot":"","sources":["../../src/services/logService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAM,UAAU;IACd,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAIpB;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE;QACvB,eAAe,EAAE,MAAM,CAAC;QACxB,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,IAAI;IAUR,2FAA2F;IAC3F,MAAM,CAAC,SAAS,IACZ;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAC9D,SAAS;IAIb;;OAEG;IACH,MAAM,CAAC,WAAW;CAGnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Decodes a request body into a plain object, trying JSON first then URL-encoded form data.
3
- * Throws `BadRequest` if neither format can be parsed.
4
- *
5
- * @param request - The incoming request whose body will be decoded.
6
- * @returns The decoded body as a plain object.
7
- *
8
- * @example
9
- * ```typescript
10
- * export async function action({ request }: ActionFunctionArgs) {
11
- * const body = await decodeRequestBody(request);
12
- * // body is now a plain JS object
13
- * }
14
- * ```
15
- */
16
- declare function decodeRequestBody(request: Request): Promise<any>;
17
- export { decodeRequestBody };
18
- //# sourceMappingURL=decodeRequestBody.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decodeRequestBody.d.ts","sourceRoot":"","sources":["../../src/utilities/decodeRequestBody.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH,iBAAe,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAsB/D;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Extracts a human-readable error message from an API response body or a `Response` object.
3
- * Checks `data.message`, `data.operator_erro_message`, `data.error`, `data.error.message`,
4
- * and `response.statusText` in that order. Falls back to `"Missing error message"`.
5
- *
6
- * @param data - Parsed response body that may contain error info.
7
- * @param response - The raw `Response` object, used as a fallback for `statusText`.
8
- * @returns The first non-empty string error message found.
9
- *
10
- * @example
11
- * ```typescript
12
- * const res = await fetch("/api/orders");
13
- * const data = await res.json().catch(() => null);
14
- * const message = decodeRequestErrorMessage(data, res);
15
- * ```
16
- */
17
- declare function decodeRequestErrorMessage(data: any, response: Response): string;
18
- export { decodeRequestErrorMessage };
19
- //# sourceMappingURL=decodeRequestErrorMessage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decodeRequestErrorMessage.d.ts","sourceRoot":"","sources":["../../src/utilities/decodeRequestErrorMessage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,iBAAS,yBAAyB,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAyBxE;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
@@ -1,25 +0,0 @@
1
- /**
2
- * Converts any thrown value into a `Response`. Recognizes all `@arkyn/server` success and error
3
- * response classes, native `Response` objects, and falls back to a 500 `ServerError` for anything else.
4
- *
5
- * Intended to be used as the catch handler of a route action or loader:
6
- *
7
- * @param error - The thrown value to convert.
8
- * @returns A `Response` with the appropriate HTTP status, headers, and JSON body.
9
- *
10
- * @example
11
- * ```typescript
12
- * export async function action({ request }: ActionFunctionArgs) {
13
- * try {
14
- * const user = await findUser(id);
15
- * if (!user) throw new NotFound("User not found");
16
- * return new Success("User retrieved", { user }).toJson();
17
- * } catch (error) {
18
- * return errorHandler(error);
19
- * }
20
- * }
21
- * ```
22
- */
23
- declare function errorHandler(error: any): Response;
24
- export { errorHandler };
25
- //# sourceMappingURL=errorHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/utilities/errorHandler.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,QAAQ,CAsC1C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Writes colored `[name] message` lines to the console, but only when
3
- * `NODE_ENV === "development"` or `DEBUG_MODE === "true"`. No-op in production.
4
- *
5
- * @param props.name - Label shown before each line (e.g. `"API"`, `"Auth"`).
6
- * @param props.scheme - Color of the label tag: `"cyan"` info, `"green"` success, `"yellow"` warning, `"red"` error.
7
- * @param props.debugs - Lines of text to print, one per console entry.
8
- *
9
- * @example
10
- * ```typescript
11
- * flushDebugLogs({
12
- * name: "API",
13
- * scheme: "cyan",
14
- * debugs: ["POST /api/users", "Status: 201"],
15
- * });
16
- * ```
17
- */
18
- declare function flushDebugLogs(props: {
19
- scheme: "yellow" | "cyan" | "red" | "green";
20
- name: string;
21
- debugs: string[];
22
- }): void;
23
- export { flushDebugLogs };
24
- //# sourceMappingURL=flushDebugLogs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flushDebugLogs.d.ts","sourceRoot":"","sources":["../../src/utilities/flushDebugLogs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,iBAAS,cAAc,CAAC,KAAK,EAAE;IAC7B,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,GAAG,IAAI,CAyBP;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}