@arkyn/server 3.0.1-beta.155 → 3.0.1-beta.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/index.js +1301 -37
  2. package/dist/modules/http/api/_logRequest.js +69 -0
  3. package/dist/modules/http/api/_makeRequest.js +69 -0
  4. package/dist/modules/http/api/deleteRequest.js +13 -0
  5. package/dist/modules/http/api/getRequest.js +12 -0
  6. package/dist/modules/http/api/patchRequest.js +13 -0
  7. package/dist/modules/http/api/postRequest.js +13 -0
  8. package/dist/modules/http/api/putRequest.js +13 -0
  9. package/dist/modules/http/badResponses/_badResponse.js +59 -0
  10. package/dist/modules/http/badResponses/badGateway.js +30 -0
  11. package/dist/modules/http/badResponses/badRequest.js +30 -0
  12. package/dist/modules/http/badResponses/conflict.js +30 -0
  13. package/dist/modules/http/badResponses/forbidden.js +30 -0
  14. package/dist/modules/http/badResponses/notFound.js +30 -0
  15. package/dist/modules/http/badResponses/notImplemented.js +30 -0
  16. package/dist/modules/http/badResponses/serverError.js +30 -0
  17. package/dist/modules/http/badResponses/unauthorized.js +30 -0
  18. package/dist/modules/http/badResponses/unprocessableEntity.js +36 -0
  19. package/dist/modules/http/successResponses/_successResponse.js +69 -0
  20. package/dist/modules/http/successResponses/created.js +30 -0
  21. package/dist/modules/http/successResponses/found.js +30 -0
  22. package/dist/modules/http/successResponses/noContent.js +21 -0
  23. package/dist/modules/http/successResponses/success.js +30 -0
  24. package/dist/modules/http/successResponses/updated.js +30 -0
  25. package/dist/modules/index.js +68 -0
  26. package/dist/modules/services/apiService.js +129 -0
  27. package/dist/modules/services/debugService.js +66 -0
  28. package/dist/modules/services/logMapperService.js +52 -0
  29. package/dist/modules/services/logService.js +31 -0
  30. package/dist/modules/utilities/decodeRequestBody.js +22 -0
  31. package/dist/modules/utilities/decodeRequestErrorMessage.js +7 -0
  32. package/dist/modules/utilities/errorHandler.js +54 -0
  33. package/dist/modules/utilities/flushDebugLogs.js +20 -0
  34. package/dist/modules/utilities/formAsyncParse.js +19 -0
  35. package/dist/modules/utilities/formParse.js +19 -0
  36. package/dist/modules/utilities/getScopedParams.js +11 -0
  37. package/dist/modules/utilities/schemaValidator.js +106 -0
  38. package/dist/modules/validations/validateCep.js +9 -0
  39. package/dist/modules/validations/validateCnpj.js +31 -0
  40. package/dist/modules/validations/validateCpf.js +28 -0
  41. package/dist/modules/validations/validateDate.js +27 -0
  42. package/dist/modules/validations/validateEmail.js +53 -0
  43. package/dist/modules/validations/validatePassword.js +16 -0
  44. package/dist/modules/validations/validatePhone.js +10 -0
  45. package/dist/modules/validations/validateRg.js +8 -0
  46. package/package.json +121 -87
  47. package/dist/bundle.js +0 -3014
  48. package/dist/bundle.umd.cjs +0 -9
  49. package/dist/http/api/_logRequest.js +0 -109
  50. package/dist/http/api/_makeRequest.js +0 -116
  51. package/dist/http/api/deleteRequest.js +0 -18
  52. package/dist/http/api/getRequest.js +0 -17
  53. package/dist/http/api/patchRequest.js +0 -18
  54. package/dist/http/api/postRequest.js +0 -18
  55. package/dist/http/api/putRequest.js +0 -18
  56. package/dist/http/badResponses/_badResponse.js +0 -62
  57. package/dist/http/badResponses/badGateway.js +0 -43
  58. package/dist/http/badResponses/badRequest.js +0 -41
  59. package/dist/http/badResponses/conflict.js +0 -42
  60. package/dist/http/badResponses/forbidden.js +0 -41
  61. package/dist/http/badResponses/notFound.js +0 -41
  62. package/dist/http/badResponses/notImplemented.js +0 -41
  63. package/dist/http/badResponses/serverError.js +0 -41
  64. package/dist/http/badResponses/unauthorized.js +0 -42
  65. package/dist/http/badResponses/unprocessableEntity.js +0 -53
  66. package/dist/http/successResponses/_successResponse.js +0 -75
  67. package/dist/http/successResponses/created.js +0 -41
  68. package/dist/http/successResponses/found.js +0 -41
  69. package/dist/http/successResponses/noContent.js +0 -32
  70. package/dist/http/successResponses/success.js +0 -41
  71. package/dist/http/successResponses/updated.js +0 -42
  72. package/dist/services/apiService.js +0 -174
  73. package/dist/services/debugService.js +0 -82
  74. package/dist/services/logMapperService.js +0 -68
  75. package/dist/services/logService.js +0 -35
  76. package/dist/utilities/decodeRequestBody.js +0 -40
  77. package/dist/utilities/decodeRequestErrorMessage.js +0 -36
  78. package/dist/utilities/errorHandler.js +0 -74
  79. package/dist/utilities/flushDebugLogs.js +0 -39
  80. package/dist/utilities/formAsyncParse.js +0 -37
  81. package/dist/utilities/formParse.js +0 -37
  82. package/dist/utilities/getScopedParams.js +0 -26
  83. package/dist/utilities/schemaValidator.js +0 -119
  84. package/dist/validations/validateCep.js +0 -27
  85. package/dist/validations/validateCnpj.js +0 -59
  86. package/dist/validations/validateCpf.js +0 -54
  87. package/dist/validations/validateDate.js +0 -51
  88. package/dist/validations/validateEmail.js +0 -111
  89. package/dist/validations/validatePassword.js +0 -34
  90. package/dist/validations/validatePhone.js +0 -28
  91. package/dist/validations/validateRg.js +0 -31
@@ -1,34 +0,0 @@
1
- /**
2
- * Validates a password based on the following rules:
3
- * - At least 8 characters
4
- * - At least 1 uppercase letter
5
- * - At least 1 letter (any case)
6
- * - At least 1 number
7
- * - At least 1 special character
8
- *
9
- * @param rawPassword - The password string to validate.
10
- * @returns `true` if the password meets all rules, otherwise `false`.
11
- *
12
- * @example
13
- * ```ts
14
- * validatePassword("Senha@123"); // true
15
- * validatePassword("senha123"); // false (no uppercase, no special char)
16
- * ```
17
- */
18
- function validatePassword(rawPassword) {
19
- if (!rawPassword)
20
- return false;
21
- const hasMinLength = rawPassword.length >= 8;
22
- const hasUppercase = /[A-Z]/.test(rawPassword);
23
- const hasLetter = /[a-z]/.test(rawPassword);
24
- const hasNumber = /\d/.test(rawPassword);
25
- const hasSpecialChar = /[!@#$%^&*(),.?":;{}|<>_\-+=~`[\]\\\/]/.test(rawPassword);
26
- return [
27
- hasMinLength,
28
- hasUppercase,
29
- hasLetter,
30
- hasNumber,
31
- hasSpecialChar,
32
- ].every((condition) => condition);
33
- }
34
- export { validatePassword };
@@ -1,28 +0,0 @@
1
- import { countries } from "@arkyn/templates";
2
- import { isValidPhoneNumber, parsePhoneNumberWithError, } from "libphonenumber-js";
3
- /**
4
- * Validates an international phone number using `libphonenumber-js`, then confirms
5
- * the parsed country code is present in the supported countries list.
6
- *
7
- * @param rawPhone - Phone number in E.164 format (e.g. `"+5532912345678"`).
8
- * @returns `true` if the number is valid and the country is supported, otherwise `false`.
9
- *
10
- * @example
11
- * ```typescript
12
- * validatePhone("+5532912345678"); // true (Brazil)
13
- * validatePhone("+55329123456178"); // false (invalid)
14
- * ```
15
- */
16
- function validatePhone(rawPhone) {
17
- if (!isValidPhoneNumber(rawPhone))
18
- return false;
19
- const parsedPhone = parsePhoneNumberWithError(rawPhone);
20
- const countryCode = parsedPhone?.country;
21
- if (!countryCode)
22
- return false;
23
- const country = countries.find((c) => c.iso === countryCode);
24
- if (!country)
25
- return false;
26
- return true;
27
- }
28
- export { validatePhone };
@@ -1,31 +0,0 @@
1
- /**
2
- * Validates a Brazilian RG (Registro Geral) in a generic way.
3
- *
4
- * This function does a basic structure validation:
5
- * - Removes non-alphanumeric characters.
6
- * - Ensures length is reasonable (7–9 digits).
7
- * - Optionally allows for a final letter (verifier).
8
- *
9
- * @param rawRg - RG string, possibly formatted.
10
- * @returns `true` if format seems valid, otherwise `false`.
11
- *
12
- * @example
13
- * ```ts
14
- * validateRg("12.345.678-9"); // true
15
- * validateRg("MG-12.345.678"); // false (not supported)
16
- * validateRg("12345678X"); // true
17
- * ```
18
- */
19
- function validateRg(rawRg) {
20
- if (!rawRg)
21
- return false;
22
- const validFormat = /^[0-9a-zA-Z.-]+$/.test(rawRg);
23
- if (!validFormat)
24
- return false;
25
- const rg = rawRg.replace(/[^a-zA-Z0-9]/g, "");
26
- if (rg.length < 7 || rg.length > 9)
27
- return false;
28
- const isValidFormat = /^[0-9]{7,8}[0-9Xx]?$/.test(rg);
29
- return isValidFormat;
30
- }
31
- export { validateRg };