@arkyn/server 3.0.1-beta.154 → 3.0.1-beta.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1301 -37
- package/dist/modules/http/api/_logRequest.js +69 -0
- package/dist/modules/http/api/_makeRequest.js +69 -0
- package/dist/modules/http/api/deleteRequest.js +13 -0
- package/dist/modules/http/api/getRequest.js +12 -0
- package/dist/modules/http/api/patchRequest.js +13 -0
- package/dist/modules/http/api/postRequest.js +13 -0
- package/dist/modules/http/api/putRequest.js +13 -0
- package/dist/modules/http/badResponses/_badResponse.js +59 -0
- package/dist/modules/http/badResponses/badGateway.js +30 -0
- package/dist/modules/http/badResponses/badRequest.js +30 -0
- package/dist/modules/http/badResponses/conflict.js +30 -0
- package/dist/modules/http/badResponses/forbidden.js +30 -0
- package/dist/modules/http/badResponses/notFound.js +30 -0
- package/dist/modules/http/badResponses/notImplemented.js +30 -0
- package/dist/modules/http/badResponses/serverError.js +30 -0
- package/dist/modules/http/badResponses/unauthorized.js +30 -0
- package/dist/modules/http/badResponses/unprocessableEntity.js +36 -0
- package/dist/modules/http/successResponses/_successResponse.js +69 -0
- package/dist/modules/http/successResponses/created.js +30 -0
- package/dist/modules/http/successResponses/found.js +30 -0
- package/dist/modules/http/successResponses/noContent.js +21 -0
- package/dist/modules/http/successResponses/success.js +30 -0
- package/dist/modules/http/successResponses/updated.js +30 -0
- package/dist/modules/index.js +68 -0
- package/dist/modules/services/apiService.js +129 -0
- package/dist/modules/services/debugService.js +66 -0
- package/dist/modules/services/logMapperService.js +52 -0
- package/dist/modules/services/logService.js +31 -0
- package/dist/modules/utilities/decodeRequestBody.js +22 -0
- package/dist/modules/utilities/decodeRequestErrorMessage.js +7 -0
- package/dist/modules/utilities/errorHandler.js +54 -0
- package/dist/modules/utilities/flushDebugLogs.js +20 -0
- package/dist/modules/utilities/formAsyncParse.js +19 -0
- package/dist/modules/utilities/formParse.js +19 -0
- package/dist/modules/utilities/getScopedParams.js +11 -0
- package/dist/modules/utilities/schemaValidator.js +106 -0
- package/dist/modules/validations/validateCep.js +9 -0
- package/dist/modules/validations/validateCnpj.js +31 -0
- package/dist/modules/validations/validateCpf.js +28 -0
- package/dist/modules/validations/validateDate.js +27 -0
- package/dist/modules/validations/validateEmail.js +53 -0
- package/dist/modules/validations/validatePassword.js +16 -0
- package/dist/modules/validations/validatePhone.js +10 -0
- package/dist/modules/validations/validateRg.js +8 -0
- package/package.json +121 -87
- package/dist/bundle.js +0 -3014
- package/dist/bundle.umd.cjs +0 -9
- package/dist/http/api/_logRequest.js +0 -109
- package/dist/http/api/_makeRequest.js +0 -116
- package/dist/http/api/deleteRequest.js +0 -18
- package/dist/http/api/getRequest.js +0 -17
- package/dist/http/api/patchRequest.js +0 -18
- package/dist/http/api/postRequest.js +0 -18
- package/dist/http/api/putRequest.js +0 -18
- package/dist/http/badResponses/_badResponse.js +0 -62
- package/dist/http/badResponses/badGateway.js +0 -43
- package/dist/http/badResponses/badRequest.js +0 -41
- package/dist/http/badResponses/conflict.js +0 -42
- package/dist/http/badResponses/forbidden.js +0 -41
- package/dist/http/badResponses/notFound.js +0 -41
- package/dist/http/badResponses/notImplemented.js +0 -41
- package/dist/http/badResponses/serverError.js +0 -41
- package/dist/http/badResponses/unauthorized.js +0 -42
- package/dist/http/badResponses/unprocessableEntity.js +0 -53
- package/dist/http/successResponses/_successResponse.js +0 -75
- package/dist/http/successResponses/created.js +0 -41
- package/dist/http/successResponses/found.js +0 -41
- package/dist/http/successResponses/noContent.js +0 -32
- package/dist/http/successResponses/success.js +0 -41
- package/dist/http/successResponses/updated.js +0 -42
- package/dist/services/apiService.js +0 -174
- package/dist/services/debugService.js +0 -82
- package/dist/services/logMapperService.js +0 -68
- package/dist/services/logService.js +0 -35
- package/dist/utilities/decodeRequestBody.js +0 -40
- package/dist/utilities/decodeRequestErrorMessage.js +0 -36
- package/dist/utilities/errorHandler.js +0 -74
- package/dist/utilities/flushDebugLogs.js +0 -39
- package/dist/utilities/formAsyncParse.js +0 -37
- package/dist/utilities/formParse.js +0 -37
- package/dist/utilities/getScopedParams.js +0 -26
- package/dist/utilities/schemaValidator.js +0 -119
- package/dist/validations/validateCep.js +0 -27
- package/dist/validations/validateCnpj.js +0 -59
- package/dist/validations/validateCpf.js +0 -54
- package/dist/validations/validateDate.js +0 -51
- package/dist/validations/validateEmail.js +0 -111
- package/dist/validations/validatePassword.js +0 -34
- package/dist/validations/validatePhone.js +0 -28
- 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 };
|