@arkyn/server 3.0.1-beta.201 → 3.0.1-beta.205
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/LICENSE.txt +184 -1
- package/README.md +1 -1
- package/dist/http/api/{deleteRequest.d.ts → _deleteRequest.d.ts} +1 -1
- package/dist/http/api/_deleteRequest.d.ts.map +1 -0
- package/dist/http/api/{getRequest.d.ts → _getRequest.d.ts} +1 -1
- package/dist/http/api/_getRequest.d.ts.map +1 -0
- package/dist/{services/logMapperService.d.ts → http/api/_logMapperService.d.ts} +1 -1
- package/dist/http/api/_logMapperService.d.ts.map +1 -0
- package/dist/http/api/{patchRequest.d.ts → _patchRequest.d.ts} +1 -1
- package/dist/http/api/_patchRequest.d.ts.map +1 -0
- package/dist/http/api/{postRequest.d.ts → _postRequest.d.ts} +1 -1
- package/dist/http/api/_postRequest.d.ts.map +1 -0
- package/dist/http/api/{putRequest.d.ts → _putRequest.d.ts} +1 -1
- package/dist/http/api/_putRequest.d.ts.map +1 -0
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -0
- package/dist/modules/http/api/{deleteRequest.js → _deleteRequest.js} +3 -1
- package/dist/modules/http/api/_deleteRequest.js.map +1 -0
- package/dist/modules/http/api/{getRequest.js → _getRequest.js} +3 -1
- package/dist/modules/http/api/_getRequest.js.map +1 -0
- package/dist/modules/{services/logMapperService.js → http/api/_logMapperService.js} +3 -1
- package/dist/modules/http/api/_logMapperService.js.map +1 -0
- package/dist/modules/http/api/_logRequest.js +2 -0
- package/dist/modules/http/api/_logRequest.js.map +1 -0
- package/dist/modules/http/api/_makeRequest.js +3 -1
- package/dist/modules/http/api/_makeRequest.js.map +1 -0
- package/dist/modules/http/api/{patchRequest.js → _patchRequest.js} +3 -1
- package/dist/modules/http/api/_patchRequest.js.map +1 -0
- package/dist/modules/http/api/{postRequest.js → _postRequest.js} +3 -1
- package/dist/modules/http/api/_postRequest.js.map +1 -0
- package/dist/modules/http/api/{putRequest.js → _putRequest.js} +3 -1
- package/dist/modules/http/api/_putRequest.js.map +1 -0
- package/dist/modules/http/badResponses/_badResponse.js +2 -0
- package/dist/modules/http/badResponses/_badResponse.js.map +1 -0
- package/dist/modules/http/badResponses/badGateway.js +2 -0
- package/dist/modules/http/badResponses/badGateway.js.map +1 -0
- package/dist/modules/http/badResponses/badRequest.js +2 -0
- package/dist/modules/http/badResponses/badRequest.js.map +1 -0
- package/dist/modules/http/badResponses/conflict.js +2 -0
- package/dist/modules/http/badResponses/conflict.js.map +1 -0
- package/dist/modules/http/badResponses/forbidden.js +2 -0
- package/dist/modules/http/badResponses/forbidden.js.map +1 -0
- package/dist/modules/http/badResponses/notFound.js +2 -0
- package/dist/modules/http/badResponses/notFound.js.map +1 -0
- package/dist/modules/http/badResponses/notImplemented.js +2 -0
- package/dist/modules/http/badResponses/notImplemented.js.map +1 -0
- package/dist/modules/http/badResponses/serverError.js +2 -0
- package/dist/modules/http/badResponses/serverError.js.map +1 -0
- package/dist/modules/http/badResponses/unauthorized.js +2 -0
- package/dist/modules/http/badResponses/unauthorized.js.map +1 -0
- package/dist/modules/http/badResponses/unprocessableEntity.js +2 -0
- package/dist/modules/http/badResponses/unprocessableEntity.js.map +1 -0
- package/dist/modules/http/successResponses/_successResponse.js +2 -0
- package/dist/modules/http/successResponses/_successResponse.js.map +1 -0
- package/dist/modules/http/successResponses/created.js +2 -0
- package/dist/modules/http/successResponses/created.js.map +1 -0
- package/dist/modules/http/successResponses/found.js +2 -0
- package/dist/modules/http/successResponses/found.js.map +1 -0
- package/dist/modules/http/successResponses/noContent.js +2 -0
- package/dist/modules/http/successResponses/noContent.js.map +1 -0
- package/dist/modules/http/successResponses/success.js +2 -0
- package/dist/modules/http/successResponses/success.js.map +1 -0
- package/dist/modules/http/successResponses/updated.js +2 -0
- package/dist/modules/http/successResponses/updated.js.map +1 -0
- package/dist/modules/services/apiService.js +7 -5
- package/dist/modules/services/apiService.js.map +1 -0
- package/dist/modules/services/debugService.js +2 -0
- package/dist/modules/services/debugService.js.map +1 -0
- package/dist/modules/services/logService.js +2 -0
- package/dist/modules/services/logService.js.map +1 -0
- package/dist/modules/utilities/decodeRequestBody.js +2 -0
- package/dist/modules/utilities/decodeRequestBody.js.map +1 -0
- package/dist/modules/utilities/decodeRequestErrorMessage.js +2 -0
- package/dist/modules/utilities/decodeRequestErrorMessage.js.map +1 -0
- package/dist/modules/utilities/errorHandler.js +2 -0
- package/dist/modules/utilities/errorHandler.js.map +1 -0
- package/dist/modules/utilities/flushDebugLogs.js +2 -0
- package/dist/modules/utilities/flushDebugLogs.js.map +1 -0
- package/dist/modules/utilities/formAsyncParse.js +2 -0
- package/dist/modules/utilities/formAsyncParse.js.map +1 -0
- package/dist/modules/utilities/formParse.js +2 -0
- package/dist/modules/utilities/formParse.js.map +1 -0
- package/dist/modules/utilities/getScopedParams.js +2 -0
- package/dist/modules/utilities/getScopedParams.js.map +1 -0
- package/dist/modules/utilities/schemaValidator.js +2 -0
- package/dist/modules/utilities/schemaValidator.js.map +1 -0
- package/dist/modules/validations/validateCep.js +2 -0
- package/dist/modules/validations/validateCep.js.map +1 -0
- package/dist/modules/validations/validateCnpj.js +2 -0
- package/dist/modules/validations/validateCnpj.js.map +1 -0
- package/dist/modules/validations/validateCpf.js +2 -0
- package/dist/modules/validations/validateCpf.js.map +1 -0
- package/dist/modules/validations/validateDate.js +2 -0
- package/dist/modules/validations/validateDate.js.map +1 -0
- package/dist/modules/validations/validateEmail.js +2 -0
- package/dist/modules/validations/validateEmail.js.map +1 -0
- package/dist/modules/validations/validatePassword.js +2 -0
- package/dist/modules/validations/validatePassword.js.map +1 -0
- package/dist/modules/validations/validatePhone.js +2 -0
- package/dist/modules/validations/validatePhone.js.map +1 -0
- package/dist/modules/validations/validateRg.js +2 -0
- package/dist/modules/validations/validateRg.js.map +1 -0
- package/package.json +116 -5
- package/dist/http/api/deleteRequest.d.ts.map +0 -1
- package/dist/http/api/getRequest.d.ts.map +0 -1
- package/dist/http/api/patchRequest.d.ts.map +0 -1
- package/dist/http/api/postRequest.d.ts.map +0 -1
- package/dist/http/api/putRequest.d.ts.map +0 -1
- package/dist/modules/index.js +0 -34
- package/dist/services/logMapperService.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formParse.js","names":[],"sources":["../../../src/utilities/formParse.ts"],"sourcesContent":["import type { ZodType } from \"zod\";\n\ntype SuccessResponse<T extends FormParseProps> = {\n\tsuccess: true;\n\tdata: T[1] extends ZodType<infer U> ? U : never;\n};\n\ntype ErrorResponse = {\n\tsuccess: false;\n\tfields: { [x: string]: string };\n\tfieldErrors: { [x: string]: string };\n};\n\n// biome-ignore lint/suspicious/noExplicitAny: intentional\ntype FormParseProps = [formData: { [k: string]: any }, schema: ZodType];\n\ntype FormParseReturnType<T extends FormParseProps> =\n\t| SuccessResponse<T>\n\t| ErrorResponse;\n\n/**\n * Validates form data against a Zod schema synchronously.\n * Returns `{ success: true, data }` on success or `{ success: false, fieldErrors, fields }` on failure.\n *\n * @param formData - The raw form data object to validate.\n * @param schema - The Zod schema to validate against.\n *\n * @example\n * ```typescript\n * const schema = z.object({ name: z.string().min(1, \"Required\"), age: z.number().min(18) });\n * const result = formParse([{ name: \"\", age: 15 }, schema]);\n *\n * if (!result.success) {\n * console.log(result.fieldErrors); // { name: \"Required\", age: \"...\" }\n * }\n * ```\n */\n\nfunction formParse<T extends FormParseProps>([\n\tformData,\n\tschema,\n]: T): FormParseReturnType<T> {\n\tconst zodResponse = schema.safeParse(formData);\n\n\tif (zodResponse.success === false) {\n\t\tconst errorsObject = Object.fromEntries(\n\t\t\tzodResponse.error.issues.map((item) => {\n\t\t\t\treturn [item.path.join(\".\"), item.message];\n\t\t\t}),\n\t\t);\n\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tfieldErrors: errorsObject,\n\t\t\tfields: formData,\n\t\t};\n\t} else {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: zodResponse.data as T[1] extends ZodType<infer U> ? U : never,\n\t\t};\n\t}\n}\n\nexport { formParse };\n"],"mappings":";AAsCA,SAAS,EAAoC,CAC5C,GACA,IAC6B;CAC7B,IAAM,IAAc,EAAO,UAAU,CAAQ;CAe5C,OAbG,EAAY,YAAY,KAOpB;EACN,SAAS;EACT,aARoB,OAAO,YAC3B,EAAY,MAAM,OAAO,KAAK,MACtB,CAAC,EAAK,KAAK,KAAK,GAAG,GAAG,EAAK,OAAO,CACzC,CAKY;EACb,QAAQ;CACT,IAEO;EACN,SAAS;EACT,MAAM,EAAY;CACnB;AAEF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getScopedParams.js","names":[],"sources":["../../../src/utilities/getScopedParams.ts"],"sourcesContent":["/**\n * Extracts URL search parameters from a request, optionally filtered by a namespace prefix\n * (e.g. `scope:key` → `key`). Without a scope, returns all search params as-is.\n *\n * @param request - The incoming request whose URL will be parsed.\n * @param scope - Namespace prefix to filter by (e.g. `\"table\"` matches `table:page`, `table:sort`).\n * @returns A `URLSearchParams` object with the matching params, stripped of the scope prefix.\n *\n * @example\n * ```typescript\n * // URL: /products?table:page=2&table:sort=asc&other=1\n * const params = getScopedParams(request, \"table\");\n * params.get(\"page\"); // \"2\"\n * params.get(\"sort\"); // \"asc\"\n * ```\n */\n\nfunction getScopedParams(request: Request, scope: string = \"\") {\n\tconst url = new URL(request.url);\n\tif (scope === \"\") return url.searchParams;\n\n\tconst scopedSearchParams: [string, string][] = Array.from(\n\t\turl.searchParams.entries(),\n\t)\n\t\t.filter(([key]) => key.startsWith(`${scope}:`))\n\t\t.map(([key, value]) => [key.replace(`${scope}:`, \"\"), value]);\n\n\treturn new URLSearchParams(scopedSearchParams);\n}\n\nexport { getScopedParams };\n"],"mappings":";AAiBA,SAAS,EAAgB,GAAkB,IAAgB,IAAI;CAC9D,IAAM,IAAM,IAAI,IAAI,EAAQ,GAAG;CAC/B,IAAI,MAAU,IAAI,OAAO,EAAI;CAE7B,IAAM,IAAyC,MAAM,KACpD,EAAI,aAAa,QAAQ,CAC1B,CAAC,CACC,QAAQ,CAAC,OAAS,EAAI,WAAW,GAAG,EAAM,EAAE,CAAC,CAAC,CAC9C,KAAK,CAAC,GAAK,OAAW,CAAC,EAAI,QAAQ,GAAG,EAAM,IAAI,EAAE,GAAG,CAAK,CAAC;CAE7D,OAAO,IAAI,gBAAgB,CAAkB;AAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaValidator.js","names":[],"sources":["../../../src/utilities/schemaValidator.ts"],"sourcesContent":["import type { ZodType, z } from \"zod\";\n\nimport { ServerError } from \"../http/badResponses/serverError\";\nimport { UnprocessableEntity } from \"../http/badResponses/unprocessableEntity\";\nimport { formAsyncParse } from \"./formAsyncParse\";\nimport { formParse } from \"./formParse\";\n\nfunction formatErrorMessage(error: z.ZodError) {\n\tconst title = \"Error validating:\";\n\tconst lines = error.issues.map(\n\t\t({ path, message }) => `-> ${path.join(\".\")}: ${message}`,\n\t);\n\n\treturn [title, ...lines].join(\"\\n\");\n}\n\n/**\n * Wraps a Zod schema with convenience validation methods suited for server-side use:\n * - `isValid` — boolean check, no throws\n * - `safeValidate` — raw Zod result, no throws\n * - `validate` — throws `ServerError` on failure (for trusted/internal data)\n * - `formValidate` / `formAsyncValidate` — throws `UnprocessableEntity` on failure (for user-submitted forms)\n *\n * @example\n * ```typescript\n * const validator = new SchemaValidator(z.object({ email: z.string().email() }));\n *\n * // Inside a Remix action:\n * const body = validator.formValidate(await decodeRequestBody(request));\n * ```\n */\nclass SchemaValidator<T extends ZodType> {\n\t/**\n\t * @param schema - The Zod schema used for all validation methods on this instance.\n\t */\n\tconstructor(readonly schema: T) {}\n\n\t/**\n\t * Returns `true` if the data satisfies the schema, `false` otherwise. Never throws.\n\t *\n\t * @param data - The value to check.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tisValid(data: any): boolean {\n\t\treturn this.schema.safeParse(data).success;\n\t}\n\n\t/**\n\t * Validates data and returns the raw Zod `safeParseResult` without throwing.\n\t * Useful when you need access to the full error details.\n\t *\n\t * @param data - The value to validate.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tsafeValidate(data: any): z.ZodSafeParseResult<z.infer<T>> {\n\t\treturn this.schema.safeParse(data);\n\t}\n\n\t/**\n\t * Validates data and returns the typed result, throwing `ServerError` on failure.\n\t * Use for validating internal/trusted data (e.g. env vars, config objects).\n\t *\n\t * @param data - The value to validate.\n\t * @throws `ServerError` with a formatted field-by-field error message.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tvalidate(data: any): z.infer<T> {\n\t\ttry {\n\t\t\treturn this.schema.parse(data);\n\t\t} catch (error) {\n\t\t\tthrow new ServerError(formatErrorMessage(error as z.ZodError));\n\t\t}\n\t}\n\n\t/**\n\t * Validates form data and returns the typed result, throwing `UnprocessableEntity` on failure.\n\t * The error includes `fieldErrors`, `fields`, and `data.scrollTo` (first failing field name).\n\t *\n\t * @param data - The raw form data to validate.\n\t * @param message - Optional human-readable error message for the 422 response.\n\t * @throws `UnprocessableEntity` with structured field errors for client-side form handling.\n\t *\n\t * @example\n\t * ```typescript\n\t * const validator = new SchemaValidator(registerSchema);\n\t * const body = validator.formValidate(await decodeRequestBody(request));\n\t * ```\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tformValidate(data: any, message?: string): z.infer<T> {\n\t\tconst formParsed = formParse([data, this.schema]);\n\n\t\tif (\"fieldErrors\" in formParsed) {\n\t\t\tconst firstErrorKey = Object.keys(formParsed.fieldErrors)[0];\n\n\t\t\tthrow new UnprocessableEntity({\n\t\t\t\tfields: formParsed.fields,\n\t\t\t\tfieldErrors: formParsed.fieldErrors,\n\t\t\t\tdata: { scrollTo: firstErrorKey },\n\t\t\t\tmessage,\n\t\t\t});\n\t\t}\n\n\t\treturn formParsed.data as z.infer<T>;\n\t}\n\n\t/**\n\t * Async version of `formValidate` for schemas with async refinements (e.g. uniqueness checks).\n\t *\n\t * @param data - The raw form data to validate.\n\t * @param message - Optional human-readable error message for the 422 response.\n\t * @throws `UnprocessableEntity` with structured field errors for client-side form handling.\n\t *\n\t * @example\n\t * ```typescript\n\t * const validator = new SchemaValidator(registerSchema);\n\t * const body = await validator.formAsyncValidate(await decodeRequestBody(request));\n\t * ```\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tasync formAsyncValidate(data: any, message?: string): Promise<z.infer<T>> {\n\t\tconst formParsed = await formAsyncParse([data, this.schema]);\n\n\t\tif (\"fieldErrors\" in formParsed) {\n\t\t\tconst firstErrorKey = Object.keys(formParsed.fieldErrors)[0];\n\n\t\t\tthrow new UnprocessableEntity({\n\t\t\t\tfields: formParsed.fields,\n\t\t\t\tfieldErrors: formParsed.fieldErrors,\n\t\t\t\tdata: { scrollTo: firstErrorKey },\n\t\t\t\tmessage,\n\t\t\t});\n\t\t}\n\n\t\treturn formParsed.data as z.infer<T>;\n\t}\n}\n\nexport { SchemaValidator };\n"],"mappings":";;;;;AAOA,SAAS,EAAmB,GAAmB;CAM9C,OAAO,CAAC,qBAAO,GAJD,EAAM,OAAO,KACzB,EAAE,SAAM,iBAAc,MAAM,EAAK,KAAK,GAAG,EAAE,IAAI,GAG/B,CAAK,CAAC,CAAC,KAAK,IAAI;AACnC;AAiBA,IAAM,IAAN,MAAyC;CAInB;CAArB,YAAY,GAAoB;EAAX,KAAA,SAAA;CAAY;CAQjC,QAAQ,GAAoB;EAC3B,OAAO,KAAK,OAAO,UAAU,CAAI,CAAC,CAAC;CACpC;CASA,aAAa,GAA6C;EACzD,OAAO,KAAK,OAAO,UAAU,CAAI;CAClC;CAUA,SAAS,GAAuB;EAC/B,IAAI;GACH,OAAO,KAAK,OAAO,MAAM,CAAI;EAC9B,SAAS,GAAO;GACf,MAAM,IAAI,EAAY,EAAmB,CAAmB,CAAC;EAC9D;CACD;CAiBA,aAAa,GAAW,GAA8B;EACrD,IAAM,IAAa,EAAU,CAAC,GAAM,KAAK,MAAM,CAAC;EAEhD,IAAI,iBAAiB,GAAY;GAChC,IAAM,IAAgB,OAAO,KAAK,EAAW,WAAW,CAAC,CAAC;GAE1D,MAAM,IAAI,EAAoB;IAC7B,QAAQ,EAAW;IACnB,aAAa,EAAW;IACxB,MAAM,EAAE,UAAU,EAAc;IAChC;GACD,CAAC;EACF;EAEA,OAAO,EAAW;CACnB;CAgBA,MAAM,kBAAkB,GAAW,GAAuC;EACzE,IAAM,IAAa,MAAM,EAAe,CAAC,GAAM,KAAK,MAAM,CAAC;EAE3D,IAAI,iBAAiB,GAAY;GAChC,IAAM,IAAgB,OAAO,KAAK,EAAW,WAAW,CAAC,CAAC;GAE1D,MAAM,IAAI,EAAoB;IAC7B,QAAQ,EAAW;IACnB,aAAa,EAAW;IACxB,MAAM,EAAE,UAAU,EAAc;IAChC;GACD,CAAC;EACF;EAEA,OAAO,EAAW;CACnB;AACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateCep.js","names":[],"sources":["../../../src/validations/validateCep.ts"],"sourcesContent":["import { removeNonNumeric } from \"@arkyn/shared\";\n\n/**\n * Validates a Brazilian CEP (postal code).\n *\n * A valid CEP must contain exactly 8 numeric digits,\n * optionally formatted as \"12345-678\".\n *\n * @param rawCep - CEP value, with or without formatting.\n * @returns `true` if the CEP is valid, otherwise `false`.\n *\n * @example\n * ```typescript\n * validateCep(\"12345-678\"); // true\n * validateCep(\"12345678\"); // true\n * validateCep(\"ABCDE-123\"); // false\n * ```\n */\n\nfunction validateCep(rawCep: string): boolean {\n\tconst validFormat = /^\\d{5}-\\d{3}$/.test(rawCep) || /^\\d{8}$/.test(rawCep);\n\tif (!validFormat) return false;\n\n\tconst cep = removeNonNumeric(rawCep);\n\n\tconst CEP_LENGTH = 8;\n\tconst isOnlyDigits = /^\\d{8}$/.test(cep);\n\n\treturn cep.length === CEP_LENGTH && isOnlyDigits;\n}\n\nexport { validateCep };\n"],"mappings":";;AAmBA,SAAS,EAAY,GAAyB;CAE7C,IAAI,EADgB,gBAAgB,KAAK,CAAM,KAAK,UAAU,KAAK,CAAM,IACvD,OAAO;CAEzB,IAAM,IAAM,EAAiB,CAAM,GAG7B,IAAe,UAAU,KAAK,CAAG;CAEvC,OAAO,EAAI,WAAW,KAAc;AACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateCnpj.js","names":[],"sources":["../../../src/validations/validateCnpj.ts"],"sourcesContent":["import { removeNonNumeric } from \"@arkyn/shared\";\n\nfunction isInvalidLength(cnpj: string) {\n\tconst CNPJ_LENGTH = 14;\n\treturn cnpj.length !== CNPJ_LENGTH;\n}\n\nfunction hasAllDigitsEqual(cnpj: string) {\n\tconst [firstDigit] = cnpj;\n\treturn [...cnpj].every((digit) => digit === firstDigit);\n}\n\nfunction calculateDigit(cnpj: string, multipliers: number[]) {\n\tlet total = 0;\n\tfor (let i = 0; i < multipliers.length; i++) {\n\t\ttotal += parseInt(cnpj[i], 10) * multipliers[i];\n\t}\n\tconst rest = total % 11;\n\treturn rest < 2 ? 0 : 11 - rest;\n}\n\nfunction extractDigit(cnpj: string) {\n\treturn cnpj.slice(12);\n}\n\n/**\n * Validates a Brazilian CNPJ (Cadastro Nacional da Pessoa Jurídica) number.\n *\n * This function performs:\n * - Sanitization (removes non-digit characters).\n * - Length check (must be 14 digits).\n * - Repeating digits check (invalid if all digits are the same).\n * - Verifies the two check digits with the proper weights.\n *\n * @param rawCnpj - CNPJ string, possibly formatted.\n * @returns `true` if valid, otherwise `false`.\n *\n * @example\n * ```typescript\n * validateCnpj(\"12.345.678/0001-95\"); // false\n * validateCnpj(\"11.444.777/0001-61\"); // true\n * ```\n */\n\nfunction validateCnpj(rawCnpj: string): boolean {\n\tif (!rawCnpj) return false;\n\tif (rawCnpj.length > 18) return false;\n\tif (rawCnpj.length < 14) return false;\n\n\tconst hasSpaces = /\\s/.test(rawCnpj);\n\tif (hasSpaces) return false;\n\n\tconst cnpj = removeNonNumeric(rawCnpj);\n\n\tif (isInvalidLength(cnpj)) return false;\n\tif (hasAllDigitsEqual(cnpj)) return false;\n\n\tconst base = cnpj.slice(0, 12);\n\tconst digit1 = calculateDigit(base, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]);\n\tconst digit2 = calculateDigit(\n\t\tbase + digit1,\n\t\t[6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2],\n\t);\n\n\treturn extractDigit(cnpj) === `${digit1}${digit2}`;\n}\n\nexport { validateCnpj };\n"],"mappings":";;AAEA,SAAS,EAAgB,GAAc;CAEtC,OAAO,EAAK,WAAW;AACxB;AAEA,SAAS,EAAkB,GAAc;CACxC,IAAM,CAAC,KAAc;CACrB,OAAO,CAAC,GAAG,CAAI,CAAC,CAAC,OAAO,MAAU,MAAU,CAAU;AACvD;AAEA,SAAS,EAAe,GAAc,GAAuB;CAC5D,IAAI,IAAQ;CACZ,KAAK,IAAI,IAAI,GAAG,IAAI,EAAY,QAAQ,KACvC,KAAS,SAAS,EAAK,IAAI,EAAE,IAAI,EAAY;CAE9C,IAAM,IAAO,IAAQ;CACrB,OAAO,IAAO,IAAI,IAAI,KAAK;AAC5B;AAEA,SAAS,EAAa,GAAc;CACnC,OAAO,EAAK,MAAM,EAAE;AACrB;AAqBA,SAAS,EAAa,GAA0B;CAM/C,IALI,CAAC,KACD,EAAQ,SAAS,MACjB,EAAQ,SAAS,MAEH,KAAK,KAAK,CACxB,GAAW,OAAO;CAEtB,IAAM,IAAO,EAAiB,CAAO;CAGrC,IADI,EAAgB,CAAI,KACpB,EAAkB,CAAI,GAAG,OAAO;CAEpC,IAAM,IAAO,EAAK,MAAM,GAAG,EAAE,GACvB,IAAS,EAAe,GAAM;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;CAAC,CAAC,GAClE,IAAS,EACd,IAAO,GACP;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;CAAC,CACvC;CAEA,OAAO,EAAa,CAAI,MAAM,GAAG,IAAS;AAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateCpf.js","names":[],"sources":["../../../src/validations/validateCpf.ts"],"sourcesContent":["import { removeNonNumeric } from \"@arkyn/shared\";\n\nfunction isInvalidLength(cpf: string) {\n\tconst CPF_LENGTH = 11;\n\treturn cpf.length !== CPF_LENGTH;\n}\n\nfunction hasAllDigitsEqual(cpf: string) {\n\tconst [firstCpfDigit] = cpf;\n\treturn [...cpf].every((digit) => digit === firstCpfDigit);\n}\n\nfunction calculateDigit(cpf: string, factor: number) {\n\tlet total = 0;\n\tfor (const digit of cpf) {\n\t\tif (factor > 1) total += parseInt(digit, 10) * factor--;\n\t}\n\tconst rest = total % 11;\n\treturn rest < 2 ? 0 : 11 - rest;\n}\n\nfunction extractDigit(cpf: string) {\n\treturn cpf.slice(9);\n}\n\n/**\n * Validates a Brazilian CPF number. Strips formatting, checks length, rejects\n * repeated-digit sequences, and verifies both check digits with the CPF algorithm.\n *\n * @param rawCpf - CPF string, with or without formatting (dots and dashes).\n * @returns `true` if the CPF is valid, otherwise `false`.\n *\n * @example\n * ```typescript\n * validateCpf(\"123.456.789-09\"); // false\n * validateCpf(\"111.444.777-35\"); // true\n * ```\n */\n\nfunction validateCpf(rawCpf: string): boolean {\n\tif (!rawCpf) return false;\n\tif (rawCpf.length > 14) return false;\n\tif (rawCpf.length < 11) return false;\n\n\tconst hasSpaces = /\\s/.test(rawCpf);\n\tif (hasSpaces) return false;\n\n\tconst cpf = removeNonNumeric(rawCpf);\n\n\tif (isInvalidLength(cpf)) return false;\n\tif (hasAllDigitsEqual(cpf)) return false;\n\n\tconst digit1 = calculateDigit(cpf, 10);\n\tconst digit2 = calculateDigit(cpf, 11);\n\n\treturn extractDigit(cpf) === `${digit1}${digit2}`;\n}\n\nexport { validateCpf };\n"],"mappings":";;AAEA,SAAS,EAAgB,GAAa;CAErC,OAAO,EAAI,WAAW;AACvB;AAEA,SAAS,EAAkB,GAAa;CACvC,IAAM,CAAC,KAAiB;CACxB,OAAO,CAAC,GAAG,CAAG,CAAC,CAAC,OAAO,MAAU,MAAU,CAAa;AACzD;AAEA,SAAS,EAAe,GAAa,GAAgB;CACpD,IAAI,IAAQ;CACZ,KAAK,IAAM,KAAS,GACnB,AAAI,IAAS,MAAG,KAAS,SAAS,GAAO,EAAE,IAAI;CAEhD,IAAM,IAAO,IAAQ;CACrB,OAAO,IAAO,IAAI,IAAI,KAAK;AAC5B;AAEA,SAAS,EAAa,GAAa;CAClC,OAAO,EAAI,MAAM,CAAC;AACnB;AAgBA,SAAS,EAAY,GAAyB;CAM7C,IALI,CAAC,KACD,EAAO,SAAS,MAChB,EAAO,SAAS,MAEF,KAAK,KAAK,CACxB,GAAW,OAAO;CAEtB,IAAM,IAAM,EAAiB,CAAM;CAGnC,IADI,EAAgB,CAAG,KACnB,EAAkB,CAAG,GAAG,OAAO;CAEnC,IAAM,IAAS,EAAe,GAAK,EAAE,GAC/B,IAAS,EAAe,GAAK,EAAE;CAErC,OAAO,EAAa,CAAG,MAAM,GAAG,IAAS;AAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateDate.js","names":[],"sources":["../../../src/validations/validateDate.ts"],"sourcesContent":["import { ValidateDateService } from \"@arkyn/shared\";\n\n/**\n * Validates a date string against a format and optional year bounds.\n *\n * @param date - The date string to validate.\n * @param config.inputFormat - Parsing format: `\"brazilianDate\"` (DD/MM/YYYY, default), `\"isoDate\"` (MM-DD-YYYY), or `\"timestamp\"` (YYYY-MM-DD).\n * @param config.minYear - Minimum allowed year. Defaults to 1900.\n * @param config.maxYear - Maximum allowed year. Defaults to 3000.\n * @returns `true` if the date is valid according to the format and bounds, otherwise `false`.\n *\n * @example\n * ```typescript\n * validateDate(\"31/12/2023\"); // true\n * validateDate(\"2023-12-31\", { inputFormat: \"timestamp\", minYear: 2000, maxYear: 2100 }); // true\n * validateDate(\"29/02/2023\"); // false (not a leap year)\n * ```\n */\n\nfunction validateDate(\n\tdate: string,\n\tconfig?: {\n\t\tinputFormat?: \"brazilianDate\" | \"isoDate\" | \"timestamp\";\n\t\tminYear?: number;\n\t\tmaxYear?: number;\n\t},\n): boolean {\n\tconst inputFormat = config?.inputFormat || \"brazilianDate\";\n\tconst minYear = config?.minYear || 1900;\n\tconst maxYear = config?.maxYear || 3000;\n\n\tconst validateDateService = new ValidateDateService();\n\tvalidateDateService.validateInputFormat(inputFormat);\n\n\tlet day: number, month: number, year: number;\n\tconst dateParts = date.split(/[-/]/).map(Number);\n\n\tif (dateParts.length !== 3) return false;\n\n\ttry {\n\t\tswitch (inputFormat) {\n\t\t\tcase \"brazilianDate\":\n\t\t\t\t[day, month, year] = dateParts;\n\t\t\t\tvalidateDateService.validateDateParts(year, month, day);\n\t\t\t\tbreak;\n\t\t\tcase \"isoDate\":\n\t\t\t\t[month, day, year] = dateParts;\n\t\t\t\tvalidateDateService.validateDateParts(year, month, day);\n\t\t\t\tbreak;\n\t\t\tcase \"timestamp\":\n\t\t\t\t[year, month, day] = dateParts;\n\t\t\t\tvalidateDateService.validateDateParts(year, month, day);\n\t\t\t\tbreak;\n\t\t}\n\t\tif (year < minYear || year > maxYear) return false;\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport { validateDate };\n"],"mappings":";;AAmBA,SAAS,EACR,GACA,GAKU;CACV,IAAM,IAAc,GAAQ,eAAe,iBACrC,IAAU,GAAQ,WAAW,MAC7B,IAAU,GAAQ,WAAW,KAE7B,IAAsB,IAAI,EAAoB;CACpD,EAAoB,oBAAoB,CAAW;CAEnD,IAAI,GAAa,GAAe,GAC1B,IAAY,EAAK,MAAM,MAAM,CAAC,CAAC,IAAI,MAAM;CAE/C,IAAI,EAAU,WAAW,GAAG,OAAO;CAEnC,IAAI;EACH,QAAQ,GAAR;GACC,KAAK;IAEJ,AADA,CAAC,GAAK,GAAO,KAAQ,GACrB,EAAoB,kBAAkB,GAAM,GAAO,CAAG;IACtD;GACD,KAAK;IAEJ,AADA,CAAC,GAAO,GAAK,KAAQ,GACrB,EAAoB,kBAAkB,GAAM,GAAO,CAAG;IACtD;GACD,KAAK;IAEJ,AADA,CAAC,GAAM,GAAO,KAAO,GACrB,EAAoB,kBAAkB,GAAM,GAAO,CAAG;IACtD;EACF;EAEA,OADA,EAAI,IAAO,KAAW,IAAO;CAE9B,QAAQ;EACP,OAAO;CACR;AACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateEmail.js","names":[],"sources":["../../../src/validations/validateEmail.ts"],"sourcesContent":["import dns from \"node:dns\";\n\nfunction isValidBasicFormat(email: string): boolean {\n\tconst emailRegex =\n\t\t/^[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])?)*$/;\n\n\treturn emailRegex.test(email);\n}\n\nfunction isValidLocalPart(localPart: string): boolean {\n\tif (localPart.length === 0 || localPart.length > 64) return false;\n\tif (localPart.startsWith(\".\") || localPart.endsWith(\".\")) return false;\n\tif (localPart.includes(\"..\")) return false;\n\n\tconst validLocalRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/;\n\tif (!validLocalRegex.test(localPart)) return false;\n\n\treturn true;\n}\n\nfunction isValidDomainLabel(label: string): boolean {\n\tif (label.length === 0 || label.length > 63) return false;\n\tif (label.startsWith(\"-\") || label.endsWith(\"-\")) return false;\n\tif (!/^[a-zA-Z0-9-]+$/.test(label)) return false;\n\treturn true;\n}\n\nfunction isValidDomainPart(domainPart: string): boolean {\n\tif (domainPart.length === 0 || domainPart.length > 253) return false;\n\n\tif (\n\t\tdomainPart.startsWith(\".\") ||\n\t\tdomainPart.endsWith(\".\") ||\n\t\tdomainPart.startsWith(\"-\") ||\n\t\tdomainPart.endsWith(\"-\")\n\t) {\n\t\treturn false;\n\t}\n\n\tconst labels = domainPart.split(\".\");\n\tif (labels.length < 2) return false;\n\n\tfor (const label of labels) if (!isValidDomainLabel(label)) return false;\n\n\tconst tld = labels[labels.length - 1];\n\tif (tld.length < 2 || !/^[a-zA-Z]+$/.test(tld)) return false;\n\n\treturn true;\n}\n\nfunction isValidAdvancedSyntax(email: string): boolean {\n\tconst parts = email.split(\"@\");\n\tif (parts.length !== 2) return false;\n\n\tconst [localPart, domainPart] = parts;\n\n\tif (!isValidLocalPart(localPart)) return false;\n\tif (!isValidDomainPart(domainPart)) return false;\n\treturn true;\n}\n\nfunction extractDomain(email: string): string | null {\n\tconst parts = email.split(\"@\");\n\treturn parts.length === 2 ? parts[1].toLowerCase() : null;\n}\n\nconst DNS_RECORD_TYPES = [\"MX\", \"A\", \"AAAA\"] as const;\n\nasync function tryResolveDnsRecord(\n\tdomain: string,\n\trecordType: string,\n): Promise<boolean> {\n\ttry {\n\t\tawait dns?.promises?.resolve(domain, recordType);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function isValidDns(domain: string): Promise<boolean> {\n\tfor (const recordType of DNS_RECORD_TYPES) {\n\t\tconst hasRecord = await tryResolveDnsRecord(domain, recordType);\n\t\tif (hasRecord) return true;\n\t}\n\treturn false;\n}\n\n/**\n * Validates if an email address is valid in all possible ways, including DNS validation.\n *\n * This function performs comprehensive email validation by:\n * - Checking basic email format and syntax\n * - Validating advanced RFC 5322 compliance rules\n * - Verifying that the domain has valid MX or A records in DNS\n *\n * @param rawEmail - The email address to validate.\n * @returns `true` if the email passes format checks and its domain resolves in DNS, otherwise `false`.\n *\n * @example\n * ```typescript\n * await validateEmail(\"user@gmail.com\"); // true\n * await validateEmail(\"user@gmil.com\"); // false (invalid domain)\n * await validateEmail(\"invalid-email\"); // false (invalid format)\n * ```\n */\n\nasync function validateEmail(rawEmail: string): Promise<boolean> {\n\tif (!rawEmail || typeof rawEmail !== \"string\") return false;\n\tconst email = rawEmail.trim();\n\n\tif (!isValidBasicFormat(email)) return false;\n\tif (!isValidAdvancedSyntax(email)) return false;\n\n\tconst domain = extractDomain(email);\n\tif (!domain) return false;\n\n\treturn await isValidDns(domain);\n}\n\nexport { validateEmail };\n"],"mappings":";;AAEA,SAAS,EAAmB,GAAwB;CAInD,OAAO,sIAAW,KAAK,CAAK;AAC7B;AAEA,SAAS,EAAiB,GAA4B;CAQrD,OAFA,EALI,EAAU,WAAW,KAAK,EAAU,SAAS,MAC7C,EAAU,WAAW,GAAG,KAAK,EAAU,SAAS,GAAG,KACnD,EAAU,SAAS,IAAI,KAGvB,CAAC,qCAAgB,KAAK,CAAS;AAGpC;AAEA,SAAS,EAAmB,GAAwB;CAInD,OADA,EAFI,EAAM,WAAW,KAAK,EAAM,SAAS,MACrC,EAAM,WAAW,GAAG,KAAK,EAAM,SAAS,GAAG,KAC3C,CAAC,kBAAkB,KAAK,CAAK;AAElC;AAEA,SAAS,EAAkB,GAA6B;CAGvD,IAFI,EAAW,WAAW,KAAK,EAAW,SAAS,OAGlD,EAAW,WAAW,GAAG,KACzB,EAAW,SAAS,GAAG,KACvB,EAAW,WAAW,GAAG,KACzB,EAAW,SAAS,GAAG,GAEvB,OAAO;CAGR,IAAM,IAAS,EAAW,MAAM,GAAG;CACnC,IAAI,EAAO,SAAS,GAAG,OAAO;CAE9B,KAAK,IAAM,KAAS,GAAQ,IAAI,CAAC,EAAmB,CAAK,GAAG,OAAO;CAEnE,IAAM,IAAM,EAAO,EAAO,SAAS;CAGnC,OAFA,EAAI,EAAI,SAAS,KAAK,CAAC,cAAc,KAAK,CAAG;AAG9C;AAEA,SAAS,EAAsB,GAAwB;CACtD,IAAM,IAAQ,EAAM,MAAM,GAAG;CAC7B,IAAI,EAAM,WAAW,GAAG,OAAO;CAE/B,IAAM,CAAC,GAAW,KAAc;CAIhC,OADA,EADI,CAAC,EAAiB,CAAS,KAC3B,CAAC,EAAkB,CAAU;AAElC;AAEA,SAAS,EAAc,GAA8B;CACpD,IAAM,IAAQ,EAAM,MAAM,GAAG;CAC7B,OAAO,EAAM,WAAW,IAAI,EAAM,EAAE,CAAC,YAAY,IAAI;AACtD;AAEA,IAAM,IAAmB;CAAC;CAAM;CAAK;AAAM;AAE3C,eAAe,EACd,GACA,GACmB;CACnB,IAAI;EAEH,OADA,MAAM,GAAK,UAAU,QAAQ,GAAQ,CAAU,GACxC;CACR,QAAQ;EACP,OAAO;CACR;AACD;AAEA,eAAe,EAAW,GAAkC;CAC3D,KAAK,IAAM,KAAc,GAExB,IAAI,MADoB,EAAoB,GAAQ,CAAU,GAC/C,OAAO;CAEvB,OAAO;AACR;AAqBA,eAAe,EAAc,GAAoC;CAChE,IAAI,CAAC,KAAY,OAAO,KAAa,UAAU,OAAO;CACtD,IAAM,IAAQ,EAAS,KAAK;CAG5B,IADI,CAAC,EAAmB,CAAK,KACzB,CAAC,EAAsB,CAAK,GAAG,OAAO;CAE1C,IAAM,IAAS,EAAc,CAAK;CAGlC,OAFK,IAEE,MAAM,EAAW,CAAM,IAFV;AAGrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validatePassword.js","names":[],"sources":["../../../src/validations/validatePassword.ts"],"sourcesContent":["/**\n * Validates a password based on the following rules:\n * - At least 8 characters\n * - At least 1 uppercase letter\n * - At least 1 letter (any case)\n * - At least 1 number\n * - At least 1 special character\n *\n * @param rawPassword - The password string to validate.\n * @returns `true` if the password meets all rules, otherwise `false`.\n *\n * @example\n * ```ts\n * validatePassword(\"Senha@123\"); // true\n * validatePassword(\"senha123\"); // false (no uppercase, no special char)\n * ```\n */\n\nfunction validatePassword(rawPassword: string): boolean {\n\tif (!rawPassword) return false;\n\n\tconst hasMinLength = rawPassword.length >= 8;\n\tconst hasUppercase = /[A-Z]/.test(rawPassword);\n\tconst hasLetter = /[a-z]/.test(rawPassword);\n\tconst hasNumber = /\\d/.test(rawPassword);\n\tconst hasSpecialChar = /[!@#$%^&*(),.?\":;{}|<>_\\-+=~`[\\]\\\\/]/.test(\n\t\trawPassword,\n\t);\n\n\treturn [\n\t\thasMinLength,\n\t\thasUppercase,\n\t\thasLetter,\n\t\thasNumber,\n\t\thasSpecialChar,\n\t].every((condition) => condition);\n}\n\nexport { validatePassword };\n"],"mappings":";AAkBA,SAAS,EAAiB,GAA8B;CAWvD,OAVK,IAUE;EARc,EAAY,UAAU;EACtB,QAAQ,KAAK,CASjC;EARiB,QAAQ,KAAK,CAS9B;EARiB,KAAK,KAAK,CAS3B;EARsB,uCAAuC,KAC7D,CAQA;CACD,CAAC,CAAC,OAAO,MAAc,CAAS,IAhBP;AAiB1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validatePhone.js","names":[],"sources":["../../../src/validations/validatePhone.ts"],"sourcesContent":["import { countries } from \"@arkyn/templates\";\nimport {\n\tisValidPhoneNumber,\n\tparsePhoneNumberWithError,\n} from \"libphonenumber-js\";\n\n/**\n * Validates an international phone number using `libphonenumber-js`, then confirms\n * the parsed country code is present in the supported countries list.\n *\n * @param rawPhone - Phone number in E.164 format (e.g. `\"+5532912345678\"`).\n * @returns `true` if the number is valid and the country is supported, otherwise `false`.\n *\n * @example\n * ```typescript\n * validatePhone(\"+5532912345678\"); // true (Brazil)\n * validatePhone(\"+55329123456178\"); // false (invalid)\n * ```\n */\n\nfunction validatePhone(rawPhone: string): boolean {\n\tif (!isValidPhoneNumber(rawPhone)) return false;\n\n\tconst parsedPhone = parsePhoneNumberWithError(rawPhone);\n\n\tconst countryCode = parsedPhone?.country;\n\tif (!countryCode) return false;\n\n\tconst country = countries.find((c) => c.iso === countryCode);\n\tif (!country) return false;\n\n\treturn true;\n}\n\nexport { validatePhone };\n"],"mappings":";;;AAoBA,SAAS,EAAc,GAA2B;CACjD,IAAI,CAAC,EAAmB,CAAQ,GAAG,OAAO;CAI1C,IAAM,IAFc,EAA0B,CAE1B,CAAA,EAAa;CAMjC,OAFA,EAHI,CAAC,KAGD,CADY,EAAU,MAAM,MAAM,EAAE,QAAQ,CAC3C;AAGN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateRg.js","names":[],"sources":["../../../src/validations/validateRg.ts"],"sourcesContent":["/**\n * Validates a Brazilian RG (Registro Geral) in a generic way.\n *\n * This function does a basic structure validation:\n * - Removes non-alphanumeric characters.\n * - Ensures length is reasonable (7–9 digits).\n * - Optionally allows for a final letter (verifier).\n *\n * @param rawRg - RG string, possibly formatted.\n * @returns `true` if format seems valid, otherwise `false`.\n *\n * @example\n * ```ts\n * validateRg(\"12.345.678-9\"); // true\n * validateRg(\"MG-12.345.678\"); // false (not supported)\n * validateRg(\"12345678X\"); // true\n * ```\n */\n\nfunction validateRg(rawRg: string): boolean {\n\tif (!rawRg) return false;\n\n\tconst validFormat = /^[0-9a-zA-Z.-]+$/.test(rawRg);\n\tif (!validFormat) return false;\n\n\tconst rg = rawRg.replace(/[^a-zA-Z0-9]/g, \"\");\n\n\tif (rg.length < 7 || rg.length > 9) return false;\n\n\tconst isValidFormat = /^[0-9]{7,8}[0-9Xx]?$/.test(rg);\n\n\treturn isValidFormat;\n}\n\nexport { validateRg };\n"],"mappings":";AAmBA,SAAS,EAAW,GAAwB;CAI3C,IAHI,CAAC,KAGD,CADgB,mBAAmB,KAAK,CACvC,GAAa,OAAO;CAEzB,IAAM,IAAK,EAAM,QAAQ,iBAAiB,EAAE;CAM5C,OAJI,EAAG,SAAS,KAAK,EAAG,SAAS,IAAU,KAErB,uBAAuB,KAAK,CAE3C;AACR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkyn/server",
|
|
3
|
-
"version": "3.0.1-beta.
|
|
3
|
+
"version": "3.0.1-beta.205",
|
|
4
4
|
"author": "Arkyn | Lucas Gonçalves",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -19,9 +19,12 @@
|
|
|
19
19
|
"typescript",
|
|
20
20
|
"zod"
|
|
21
21
|
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
22
25
|
"engines": {
|
|
23
|
-
"node": ">=
|
|
24
|
-
"bun": ">=1.
|
|
26
|
+
"node": ">=18.0.0",
|
|
27
|
+
"bun": ">=1.0.0"
|
|
25
28
|
},
|
|
26
29
|
"homepage": "https://docs.arkyn.dev/docs/server/introduction",
|
|
27
30
|
"repository": {
|
|
@@ -35,9 +38,13 @@
|
|
|
35
38
|
"LICENSE.txt"
|
|
36
39
|
],
|
|
37
40
|
"sideEffects": false,
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@arkyn/shared": ">=3.0.1-beta.205",
|
|
43
|
+
"@arkyn/templates": ">=3.0.1-beta.205"
|
|
44
|
+
},
|
|
38
45
|
"scripts": {
|
|
39
46
|
"audit": "bun audit --workspace packages/server",
|
|
40
|
-
"build": "bunx vite build && bunx tsc --project tsconfig.json --emitDeclarationOnly && bun ./generate-exports.ts",
|
|
47
|
+
"build": "bunx vite build && bunx tsc --project tsconfig.json --emitDeclarationOnly && bun ./generate-exports.ts && rm -f dist/modules/index.js dist/modules/style.css",
|
|
41
48
|
"prebuild": "rm -rf dist",
|
|
42
49
|
"publish:beta": "npm publish --tag beta",
|
|
43
50
|
"publish:latest": "npm publish --tag latest",
|
|
@@ -57,9 +64,10 @@
|
|
|
57
64
|
"@types/bun": "catalog:",
|
|
58
65
|
"@types/node": "catalog:",
|
|
59
66
|
"libphonenumber-js": "catalog:",
|
|
67
|
+
"typescript": "catalog:",
|
|
60
68
|
"vite": "catalog:",
|
|
61
69
|
"vitest": "catalog:",
|
|
62
|
-
"zod": "
|
|
70
|
+
"zod": "catalog:"
|
|
63
71
|
},
|
|
64
72
|
"exports": {
|
|
65
73
|
".": {
|
|
@@ -232,5 +240,108 @@
|
|
|
232
240
|
"types": "./dist/validations/validateRg.d.ts",
|
|
233
241
|
"default": "./dist/modules/validations/validateRg.js"
|
|
234
242
|
}
|
|
243
|
+
},
|
|
244
|
+
"typesVersions": {
|
|
245
|
+
"*": {
|
|
246
|
+
"apiService": [
|
|
247
|
+
"./dist/services/apiService.d.ts"
|
|
248
|
+
],
|
|
249
|
+
"badGateway": [
|
|
250
|
+
"./dist/http/badResponses/badGateway.d.ts"
|
|
251
|
+
],
|
|
252
|
+
"badRequest": [
|
|
253
|
+
"./dist/http/badResponses/badRequest.d.ts"
|
|
254
|
+
],
|
|
255
|
+
"conflict": [
|
|
256
|
+
"./dist/http/badResponses/conflict.d.ts"
|
|
257
|
+
],
|
|
258
|
+
"created": [
|
|
259
|
+
"./dist/http/successResponses/created.d.ts"
|
|
260
|
+
],
|
|
261
|
+
"debugService": [
|
|
262
|
+
"./dist/services/debugService.d.ts"
|
|
263
|
+
],
|
|
264
|
+
"decodeRequestBody": [
|
|
265
|
+
"./dist/utilities/decodeRequestBody.d.ts"
|
|
266
|
+
],
|
|
267
|
+
"decodeRequestErrorMessage": [
|
|
268
|
+
"./dist/utilities/decodeRequestErrorMessage.d.ts"
|
|
269
|
+
],
|
|
270
|
+
"errorHandler": [
|
|
271
|
+
"./dist/utilities/errorHandler.d.ts"
|
|
272
|
+
],
|
|
273
|
+
"flushDebugLogs": [
|
|
274
|
+
"./dist/utilities/flushDebugLogs.d.ts"
|
|
275
|
+
],
|
|
276
|
+
"forbidden": [
|
|
277
|
+
"./dist/http/badResponses/forbidden.d.ts"
|
|
278
|
+
],
|
|
279
|
+
"formAsyncParse": [
|
|
280
|
+
"./dist/utilities/formAsyncParse.d.ts"
|
|
281
|
+
],
|
|
282
|
+
"formParse": [
|
|
283
|
+
"./dist/utilities/formParse.d.ts"
|
|
284
|
+
],
|
|
285
|
+
"found": [
|
|
286
|
+
"./dist/http/successResponses/found.d.ts"
|
|
287
|
+
],
|
|
288
|
+
"getScopedParams": [
|
|
289
|
+
"./dist/utilities/getScopedParams.d.ts"
|
|
290
|
+
],
|
|
291
|
+
"logService": [
|
|
292
|
+
"./dist/services/logService.d.ts"
|
|
293
|
+
],
|
|
294
|
+
"noContent": [
|
|
295
|
+
"./dist/http/successResponses/noContent.d.ts"
|
|
296
|
+
],
|
|
297
|
+
"notFound": [
|
|
298
|
+
"./dist/http/badResponses/notFound.d.ts"
|
|
299
|
+
],
|
|
300
|
+
"notImplemented": [
|
|
301
|
+
"./dist/http/badResponses/notImplemented.d.ts"
|
|
302
|
+
],
|
|
303
|
+
"schemaValidator": [
|
|
304
|
+
"./dist/utilities/schemaValidator.d.ts"
|
|
305
|
+
],
|
|
306
|
+
"serverError": [
|
|
307
|
+
"./dist/http/badResponses/serverError.d.ts"
|
|
308
|
+
],
|
|
309
|
+
"success": [
|
|
310
|
+
"./dist/http/successResponses/success.d.ts"
|
|
311
|
+
],
|
|
312
|
+
"unauthorized": [
|
|
313
|
+
"./dist/http/badResponses/unauthorized.d.ts"
|
|
314
|
+
],
|
|
315
|
+
"unprocessableEntity": [
|
|
316
|
+
"./dist/http/badResponses/unprocessableEntity.d.ts"
|
|
317
|
+
],
|
|
318
|
+
"updated": [
|
|
319
|
+
"./dist/http/successResponses/updated.d.ts"
|
|
320
|
+
],
|
|
321
|
+
"validateCep": [
|
|
322
|
+
"./dist/validations/validateCep.d.ts"
|
|
323
|
+
],
|
|
324
|
+
"validateCnpj": [
|
|
325
|
+
"./dist/validations/validateCnpj.d.ts"
|
|
326
|
+
],
|
|
327
|
+
"validateCpf": [
|
|
328
|
+
"./dist/validations/validateCpf.d.ts"
|
|
329
|
+
],
|
|
330
|
+
"validateDate": [
|
|
331
|
+
"./dist/validations/validateDate.d.ts"
|
|
332
|
+
],
|
|
333
|
+
"validateEmail": [
|
|
334
|
+
"./dist/validations/validateEmail.d.ts"
|
|
335
|
+
],
|
|
336
|
+
"validatePassword": [
|
|
337
|
+
"./dist/validations/validatePassword.d.ts"
|
|
338
|
+
],
|
|
339
|
+
"validatePhone": [
|
|
340
|
+
"./dist/validations/validatePhone.d.ts"
|
|
341
|
+
],
|
|
342
|
+
"validateRg": [
|
|
343
|
+
"./dist/validations/validateRg.d.ts"
|
|
344
|
+
]
|
|
345
|
+
}
|
|
235
346
|
}
|
|
236
347
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deleteRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/deleteRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACX,CAAC;AAEF;;;;;;GAMG;AAGH,iBAAe,aAAa,CAAC,CAAC,GAAG,GAAG,EACnC,KAAK,EAAE,UAAU,GACf,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAQ5B;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/getRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF;;;;;;GAMG;AAGH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAChC,KAAK,EAAE,UAAU,GACf,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAO5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patchRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/patchRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACX,CAAC;AAEF;;;;;;GAMG;AAGH,iBAAe,YAAY,CAAC,CAAC,GAAG,GAAG,EAClC,KAAK,EAAE,UAAU,GACf,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAQ5B;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/postRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACX,CAAC;AAEF;;;;;;GAMG;AAGH,iBAAe,WAAW,CAAC,CAAC,GAAG,GAAG,EACjC,KAAK,EAAE,UAAU,GACf,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAQ5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"putRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/putRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACX,CAAC;AAEF;;;;;;GAMG;AAGH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAChC,KAAK,EAAE,UAAU,GACf,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAQ5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logMapperService.d.ts","sourceRoot":"","sources":["../../src/services/logMapperService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,GAAG;IACjB,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;IAE7B,WAAW,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IAEpB,YAAY,EAAE,GAAG,CAAC;IAClB,WAAW,EAAE,eAAe,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,KAAK,WAAW,GAAG;IAClB,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;IAExC,YAAY,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,cAAM,gBAAgB;IACrB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAiBzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAY7B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW;CAiB7C;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|