@arkyn/server 3.0.1-beta.159 → 3.0.1-beta.166

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 (47) hide show
  1. package/dist/index.js +1026 -1262
  2. package/dist/modules/http/api/_logRequest.js +55 -68
  3. package/dist/modules/http/api/_makeRequest.js +69 -68
  4. package/dist/modules/http/api/deleteRequest.js +12 -12
  5. package/dist/modules/http/api/getRequest.js +11 -11
  6. package/dist/modules/http/api/patchRequest.js +11 -11
  7. package/dist/modules/http/api/postRequest.js +11 -11
  8. package/dist/modules/http/api/putRequest.js +11 -11
  9. package/dist/modules/http/badResponses/_badResponse.js +62 -58
  10. package/dist/modules/http/badResponses/badGateway.js +22 -28
  11. package/dist/modules/http/badResponses/badRequest.js +22 -28
  12. package/dist/modules/http/badResponses/conflict.js +22 -28
  13. package/dist/modules/http/badResponses/forbidden.js +22 -28
  14. package/dist/modules/http/badResponses/notFound.js +22 -28
  15. package/dist/modules/http/badResponses/notImplemented.js +22 -28
  16. package/dist/modules/http/badResponses/serverError.js +22 -28
  17. package/dist/modules/http/badResponses/unauthorized.js +22 -28
  18. package/dist/modules/http/badResponses/unprocessableEntity.js +27 -35
  19. package/dist/modules/http/successResponses/_successResponse.js +61 -68
  20. package/dist/modules/http/successResponses/created.js +22 -28
  21. package/dist/modules/http/successResponses/found.js +22 -28
  22. package/dist/modules/http/successResponses/noContent.js +16 -20
  23. package/dist/modules/http/successResponses/success.js +22 -28
  24. package/dist/modules/http/successResponses/updated.js +22 -28
  25. package/dist/modules/index.js +33 -67
  26. package/dist/modules/services/apiService.js +108 -128
  27. package/dist/modules/services/debugService.js +35 -65
  28. package/dist/modules/services/logMapperService.js +28 -51
  29. package/dist/modules/services/logService.js +20 -30
  30. package/dist/modules/utilities/decodeRequestBody.js +19 -21
  31. package/dist/modules/utilities/decodeRequestErrorMessage.js +5 -6
  32. package/dist/modules/utilities/errorHandler.js +36 -51
  33. package/dist/modules/utilities/flushDebugLogs.js +15 -19
  34. package/dist/modules/utilities/formAsyncParse.js +13 -18
  35. package/dist/modules/utilities/formParse.js +13 -18
  36. package/dist/modules/utilities/getScopedParams.js +8 -10
  37. package/dist/modules/utilities/schemaValidator.js +53 -104
  38. package/dist/modules/validations/validateCep.js +8 -8
  39. package/dist/modules/validations/validateCnpj.js +49 -26
  40. package/dist/modules/validations/validateCpf.js +22 -23
  41. package/dist/modules/validations/validateDate.js +25 -26
  42. package/dist/modules/validations/validateEmail.js +54 -53
  43. package/dist/modules/validations/validatePassword.js +11 -15
  44. package/dist/modules/validations/validatePhone.js +8 -8
  45. package/dist/modules/validations/validateRg.js +7 -7
  46. package/generate-version.ts +74 -0
  47. package/package.json +17 -9
@@ -1,52 +1,29 @@
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
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
+ }
52
27
  };
28
+ //#endregion
29
+ export { e as LogMapperService };
@@ -1,31 +1,21 @@
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
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
+ }
31
19
  };
20
+ //#endregion
21
+ export { e as LogService };
@@ -1,22 +1,20 @@
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;
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;
19
18
  }
20
- export {
21
- d as decodeRequestBody
22
- };
19
+ //#endregion
20
+ export { t as decodeRequestBody };
@@ -1,7 +1,6 @@
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";
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
4
  }
5
- export {
6
- o as decodeRequestErrorMessage
7
- };
5
+ //#endregion
6
+ export { e as decodeRequestErrorMessage };
@@ -1,54 +1,39 @@
1
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";
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
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();
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();
51
37
  }
52
- export {
53
- z as errorHandler
54
- };
38
+ //#endregion
39
+ export { m as errorHandler };
@@ -1,20 +1,16 @@
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
- }
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}]`, 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
+ }
17
14
  }
18
- export {
19
- r as flushDebugLogs
20
- };
15
+ //#endregion
16
+ export { e as flushDebugLogs };
@@ -1,19 +1,14 @@
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
- };
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
+ };
16
12
  }
17
- export {
18
- a as formAsyncParse
19
- };
13
+ //#endregion
14
+ export { e as formAsyncParse };
@@ -1,19 +1,14 @@
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
- };
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
+ };
16
12
  }
17
- export {
18
- o as formParse
19
- };
13
+ //#endregion
14
+ export { e as formParse };
@@ -1,11 +1,9 @@
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);
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);
8
7
  }
9
- export {
10
- c as getScopedParams
11
- };
8
+ //#endregion
9
+ export { e as getScopedParams };
@@ -1,106 +1,55 @@
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
- `);
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");
11
8
  }
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
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
+ }
106
53
  };
54
+ //#endregion
55
+ export { a as SchemaValidator };
@@ -1,9 +1,9 @@
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;
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;
6
7
  }
7
- export {
8
- c as validateCep
9
- };
8
+ //#endregion
9
+ export { t as validateCep };