@arkyn/server 3.0.1-beta.2 → 3.0.1-beta.200

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 (238) hide show
  1. package/README.md +423 -69
  2. package/dist/http/api/_logRequest.d.ts +58 -0
  3. package/dist/http/api/_logRequest.d.ts.map +1 -0
  4. package/dist/http/api/_makeRequest.d.ts +61 -0
  5. package/dist/http/api/_makeRequest.d.ts.map +1 -0
  6. package/dist/http/api/deleteRequest.d.ts +17 -0
  7. package/dist/http/api/deleteRequest.d.ts.map +1 -0
  8. package/dist/http/api/getRequest.d.ts +16 -0
  9. package/dist/http/api/getRequest.d.ts.map +1 -0
  10. package/dist/http/api/patchRequest.d.ts +17 -0
  11. package/dist/http/api/patchRequest.d.ts.map +1 -0
  12. package/dist/http/api/postRequest.d.ts +17 -0
  13. package/dist/http/api/postRequest.d.ts.map +1 -0
  14. package/dist/http/api/putRequest.d.ts +17 -0
  15. package/dist/http/api/putRequest.d.ts.map +1 -0
  16. package/dist/http/badResponses/_badResponse.d.ts +25 -0
  17. package/dist/http/badResponses/_badResponse.d.ts.map +1 -0
  18. package/dist/http/badResponses/badGateway.d.ts +14 -24
  19. package/dist/http/badResponses/badGateway.d.ts.map +1 -1
  20. package/dist/http/badResponses/badRequest.d.ts +12 -24
  21. package/dist/http/badResponses/badRequest.d.ts.map +1 -1
  22. package/dist/http/badResponses/conflict.d.ts +12 -24
  23. package/dist/http/badResponses/conflict.d.ts.map +1 -1
  24. package/dist/http/badResponses/forbidden.d.ts +12 -24
  25. package/dist/http/badResponses/forbidden.d.ts.map +1 -1
  26. package/dist/http/badResponses/notFound.d.ts +12 -24
  27. package/dist/http/badResponses/notFound.d.ts.map +1 -1
  28. package/dist/http/badResponses/notImplemented.d.ts +12 -24
  29. package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
  30. package/dist/http/badResponses/serverError.d.ts +12 -24
  31. package/dist/http/badResponses/serverError.d.ts.map +1 -1
  32. package/dist/http/badResponses/unauthorized.d.ts +12 -24
  33. package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
  34. package/dist/http/badResponses/unprocessableEntity.d.ts +25 -34
  35. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
  36. package/dist/http/successResponses/_successResponse.d.ts +36 -0
  37. package/dist/http/successResponses/_successResponse.d.ts.map +1 -0
  38. package/dist/http/successResponses/created.d.ts +12 -26
  39. package/dist/http/successResponses/created.d.ts.map +1 -1
  40. package/dist/http/successResponses/found.d.ts +12 -29
  41. package/dist/http/successResponses/found.d.ts.map +1 -1
  42. package/dist/http/successResponses/noContent.d.ts +12 -17
  43. package/dist/http/successResponses/noContent.d.ts.map +1 -1
  44. package/dist/http/successResponses/success.d.ts +12 -26
  45. package/dist/http/successResponses/success.d.ts.map +1 -1
  46. package/dist/http/successResponses/updated.d.ts +13 -26
  47. package/dist/http/successResponses/updated.d.ts.map +1 -1
  48. package/dist/index.d.ts +19 -10
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1067 -28
  51. package/dist/modules/http/api/_logRequest.js +56 -0
  52. package/dist/modules/http/api/_makeRequest.js +70 -0
  53. package/dist/modules/http/api/deleteRequest.js +13 -0
  54. package/dist/modules/http/api/getRequest.js +12 -0
  55. package/dist/modules/http/api/patchRequest.js +13 -0
  56. package/dist/modules/http/api/postRequest.js +13 -0
  57. package/dist/modules/http/api/putRequest.js +13 -0
  58. package/dist/modules/http/badResponses/_badResponse.js +63 -0
  59. package/dist/modules/http/badResponses/badGateway.js +24 -0
  60. package/dist/modules/http/badResponses/badRequest.js +24 -0
  61. package/dist/modules/http/badResponses/conflict.js +24 -0
  62. package/dist/modules/http/badResponses/forbidden.js +24 -0
  63. package/dist/modules/http/badResponses/notFound.js +24 -0
  64. package/dist/modules/http/badResponses/notImplemented.js +24 -0
  65. package/dist/modules/http/badResponses/serverError.js +24 -0
  66. package/dist/modules/http/badResponses/unauthorized.js +24 -0
  67. package/dist/modules/http/badResponses/unprocessableEntity.js +28 -0
  68. package/dist/modules/http/successResponses/_successResponse.js +62 -0
  69. package/dist/modules/http/successResponses/created.js +24 -0
  70. package/dist/modules/http/successResponses/found.js +24 -0
  71. package/dist/modules/http/successResponses/noContent.js +17 -0
  72. package/dist/modules/http/successResponses/success.js +24 -0
  73. package/dist/modules/http/successResponses/updated.js +24 -0
  74. package/dist/modules/index.js +34 -0
  75. package/dist/modules/services/apiService.js +109 -0
  76. package/dist/modules/services/debugService.js +36 -0
  77. package/dist/modules/services/logMapperService.js +31 -0
  78. package/dist/modules/services/logService.js +21 -0
  79. package/dist/modules/utilities/decodeRequestBody.js +20 -0
  80. package/dist/modules/utilities/decodeRequestErrorMessage.js +6 -0
  81. package/dist/modules/utilities/errorHandler.js +39 -0
  82. package/dist/modules/utilities/flushDebugLogs.js +16 -0
  83. package/dist/modules/utilities/formAsyncParse.js +14 -0
  84. package/dist/modules/utilities/formParse.js +14 -0
  85. package/dist/modules/utilities/getScopedParams.js +9 -0
  86. package/dist/modules/utilities/schemaValidator.js +55 -0
  87. package/dist/modules/validations/validateCep.js +9 -0
  88. package/dist/modules/validations/validateCnpj.js +54 -0
  89. package/dist/modules/validations/validateCpf.js +27 -0
  90. package/dist/modules/validations/validateDate.js +26 -0
  91. package/dist/modules/validations/validateEmail.js +54 -0
  92. package/dist/modules/validations/validatePassword.js +12 -0
  93. package/dist/modules/validations/validatePhone.js +10 -0
  94. package/dist/modules/validations/validateRg.js +8 -0
  95. package/dist/services/apiService.d.ts +83 -0
  96. package/dist/services/apiService.d.ts.map +1 -0
  97. package/dist/services/debugService.d.ts +37 -0
  98. package/dist/services/debugService.d.ts.map +1 -0
  99. package/dist/services/logMapperService.d.ts +86 -0
  100. package/dist/services/logMapperService.d.ts.map +1 -0
  101. package/dist/services/logService.d.ts +33 -0
  102. package/dist/services/logService.d.ts.map +1 -0
  103. package/dist/utilities/decodeRequestBody.d.ts +18 -0
  104. package/dist/utilities/decodeRequestBody.d.ts.map +1 -0
  105. package/dist/utilities/decodeRequestErrorMessage.d.ts +19 -0
  106. package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -0
  107. package/dist/utilities/errorHandler.d.ts +25 -0
  108. package/dist/utilities/errorHandler.d.ts.map +1 -0
  109. package/dist/utilities/flushDebugLogs.d.ts +24 -0
  110. package/dist/utilities/flushDebugLogs.d.ts.map +1 -0
  111. package/dist/utilities/formAsyncParse.d.ts +38 -0
  112. package/dist/utilities/formAsyncParse.d.ts.map +1 -0
  113. package/dist/utilities/formParse.d.ts +38 -0
  114. package/dist/utilities/formParse.d.ts.map +1 -0
  115. package/dist/utilities/getScopedParams.d.ts +19 -0
  116. package/dist/utilities/getScopedParams.d.ts.map +1 -0
  117. package/dist/utilities/schemaValidator.d.ts +75 -0
  118. package/dist/utilities/schemaValidator.d.ts.map +1 -0
  119. package/dist/validations/validateCep.d.ts +19 -0
  120. package/dist/validations/validateCep.d.ts.map +1 -0
  121. package/dist/validations/validateCnpj.d.ts +21 -0
  122. package/dist/validations/validateCnpj.d.ts.map +1 -0
  123. package/dist/validations/validateCpf.d.ts +16 -0
  124. package/dist/validations/validateCpf.d.ts.map +1 -0
  125. package/dist/validations/validateDate.d.ts +23 -0
  126. package/dist/validations/validateDate.d.ts.map +1 -0
  127. package/dist/validations/validateEmail.d.ts +21 -0
  128. package/dist/validations/validateEmail.d.ts.map +1 -0
  129. package/dist/validations/validatePassword.d.ts +20 -0
  130. package/dist/validations/validatePassword.d.ts.map +1 -0
  131. package/dist/validations/validatePhone.d.ts +16 -0
  132. package/dist/validations/validatePhone.d.ts.map +1 -0
  133. package/dist/validations/validateRg.d.ts +21 -0
  134. package/dist/validations/validateRg.d.ts.map +1 -0
  135. package/package.json +227 -23
  136. package/dist/api/deleteRequest.d.ts +0 -13
  137. package/dist/api/deleteRequest.d.ts.map +0 -1
  138. package/dist/api/deleteRequest.js +0 -14
  139. package/dist/api/getRequest.d.ts +0 -12
  140. package/dist/api/getRequest.d.ts.map +0 -1
  141. package/dist/api/getRequest.js +0 -13
  142. package/dist/api/inboxFlowRequest.d.ts +0 -40
  143. package/dist/api/inboxFlowRequest.d.ts.map +0 -1
  144. package/dist/api/inboxFlowRequest.js +0 -63
  145. package/dist/api/makeRequest.d.ts +0 -38
  146. package/dist/api/makeRequest.d.ts.map +0 -1
  147. package/dist/api/makeRequest.js +0 -102
  148. package/dist/api/patchRequest.d.ts +0 -13
  149. package/dist/api/patchRequest.d.ts.map +0 -1
  150. package/dist/api/patchRequest.js +0 -14
  151. package/dist/api/postRequest.d.ts +0 -13
  152. package/dist/api/postRequest.d.ts.map +0 -1
  153. package/dist/api/postRequest.js +0 -14
  154. package/dist/api/putRequest.d.ts +0 -13
  155. package/dist/api/putRequest.d.ts.map +0 -1
  156. package/dist/api/putRequest.js +0 -14
  157. package/dist/config/apiInstance.d.ts +0 -80
  158. package/dist/config/apiInstance.d.ts.map +0 -1
  159. package/dist/config/apiInstance.js +0 -111
  160. package/dist/config/inboxFlowInstance.d.ts +0 -44
  161. package/dist/config/inboxFlowInstance.d.ts.map +0 -1
  162. package/dist/config/inboxFlowInstance.js +0 -46
  163. package/dist/http/badResponses/badGateway.js +0 -52
  164. package/dist/http/badResponses/badRequest.js +0 -52
  165. package/dist/http/badResponses/conflict.js +0 -52
  166. package/dist/http/badResponses/forbidden.js +0 -52
  167. package/dist/http/badResponses/notFound.js +0 -52
  168. package/dist/http/badResponses/notImplemented.js +0 -52
  169. package/dist/http/badResponses/serverError.js +0 -52
  170. package/dist/http/badResponses/unauthorized.js +0 -52
  171. package/dist/http/badResponses/unprocessableEntity.js +0 -60
  172. package/dist/http/successResponses/created.js +0 -54
  173. package/dist/http/successResponses/found.js +0 -57
  174. package/dist/http/successResponses/noContent.js +0 -35
  175. package/dist/http/successResponses/success.js +0 -54
  176. package/dist/http/successResponses/updated.js +0 -54
  177. package/dist/services/decodeErrorMessageFromRequest.d.ts +0 -17
  178. package/dist/services/decodeErrorMessageFromRequest.d.ts.map +0 -1
  179. package/dist/services/decodeErrorMessageFromRequest.js +0 -30
  180. package/dist/services/decodeRequestBody.d.ts +0 -17
  181. package/dist/services/decodeRequestBody.d.ts.map +0 -1
  182. package/dist/services/decodeRequestBody.js +0 -38
  183. package/dist/services/errorHandler.d.ts +0 -44
  184. package/dist/services/errorHandler.d.ts.map +0 -1
  185. package/dist/services/errorHandler.js +0 -93
  186. package/dist/services/formParse.d.ts +0 -59
  187. package/dist/services/formParse.d.ts.map +0 -1
  188. package/dist/services/formParse.js +0 -56
  189. package/dist/services/getCaller.d.ts +0 -17
  190. package/dist/services/getCaller.d.ts.map +0 -1
  191. package/dist/services/getCaller.js +0 -39
  192. package/dist/services/getScopedParams.d.ts +0 -28
  193. package/dist/services/getScopedParams.d.ts.map +0 -1
  194. package/dist/services/getScopedParams.js +0 -34
  195. package/dist/services/httpDebug.d.ts +0 -35
  196. package/dist/services/httpDebug.d.ts.map +0 -1
  197. package/dist/services/httpDebug.js +0 -53
  198. package/dist/services/schemaValidator.d.ts +0 -13
  199. package/dist/services/schemaValidator.d.ts.map +0 -1
  200. package/dist/services/schemaValidator.js +0 -51
  201. package/dist/types/ApiResponseDTO.d.ts +0 -17
  202. package/dist/types/ApiResponseDTO.d.ts.map +0 -1
  203. package/dist/types/ApiResponseDTO.js +0 -1
  204. package/src/api/deleteRequest.ts +0 -22
  205. package/src/api/getRequest.ts +0 -20
  206. package/src/api/inboxFlowRequest.ts +0 -76
  207. package/src/api/makeRequest.ts +0 -116
  208. package/src/api/patchRequest.ts +0 -22
  209. package/src/api/postRequest.ts +0 -22
  210. package/src/api/putRequest.ts +0 -22
  211. package/src/config/apiInstance.ts +0 -148
  212. package/src/config/inboxFlowInstance.ts +0 -65
  213. package/src/http/badResponses/badGateway.ts +0 -63
  214. package/src/http/badResponses/badRequest.ts +0 -63
  215. package/src/http/badResponses/conflict.ts +0 -63
  216. package/src/http/badResponses/forbidden.ts +0 -63
  217. package/src/http/badResponses/notFound.ts +0 -63
  218. package/src/http/badResponses/notImplemented.ts +0 -63
  219. package/src/http/badResponses/serverError.ts +0 -63
  220. package/src/http/badResponses/unauthorized.ts +0 -63
  221. package/src/http/badResponses/unprocessableEntity.ts +0 -79
  222. package/src/http/successResponses/created.ts +0 -64
  223. package/src/http/successResponses/found.ts +0 -67
  224. package/src/http/successResponses/noContent.ts +0 -42
  225. package/src/http/successResponses/success.ts +0 -64
  226. package/src/http/successResponses/updated.ts +0 -64
  227. package/src/index.ts +0 -31
  228. package/src/services/decodeErrorMessageFromRequest.ts +0 -36
  229. package/src/services/decodeRequestBody.ts +0 -43
  230. package/src/services/errorHandler.ts +0 -99
  231. package/src/services/formParse.ts +0 -83
  232. package/src/services/getCaller.ts +0 -48
  233. package/src/services/getScopedParams.ts +0 -43
  234. package/src/services/httpDebug.ts +0 -62
  235. package/src/services/schemaValidator.ts +0 -66
  236. package/src/types/ApiResponseDTO.ts +0 -19
  237. package/tsconfig.json +0 -21
  238. package/vitest.config.ts +0 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateDate.d.ts","sourceRoot":"","sources":["../../src/validations/validateDate.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,iBAAS,YAAY,CACpB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,eAAe,GAAG,SAAS,GAAG,WAAW,CAAC;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,GACC,OAAO,CAiCT;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Validates if an email address is valid in all possible ways, including DNS validation.
3
+ *
4
+ * This function performs comprehensive email validation by:
5
+ * - Checking basic email format and syntax
6
+ * - Validating advanced RFC 5322 compliance rules
7
+ * - Verifying that the domain has valid MX or A records in DNS
8
+ *
9
+ * @param rawEmail - The email address to validate.
10
+ * @returns `true` if the email passes format checks and its domain resolves in DNS, otherwise `false`.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * await validateEmail("user@gmail.com"); // true
15
+ * await validateEmail("user@gmil.com"); // false (invalid domain)
16
+ * await validateEmail("invalid-email"); // false (invalid format)
17
+ * ```
18
+ */
19
+ declare function validateEmail(rawEmail: string): Promise<boolean>;
20
+ export { validateEmail };
21
+ //# sourceMappingURL=validateEmail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateEmail.d.ts","sourceRoot":"","sources":["../../src/validations/validateEmail.ts"],"names":[],"mappings":"AAwFA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAe,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAW/D;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,20 @@
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
+ declare function validatePassword(rawPassword: string): boolean;
19
+ export { validatePassword };
20
+ //# sourceMappingURL=validatePassword.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatePassword.d.ts","sourceRoot":"","sources":["../../src/validations/validatePassword.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,iBAAS,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAkBtD;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Validates an international phone number using `libphonenumber-js`, then confirms
3
+ * the parsed country code is present in the supported countries list.
4
+ *
5
+ * @param rawPhone - Phone number in E.164 format (e.g. `"+5532912345678"`).
6
+ * @returns `true` if the number is valid and the country is supported, otherwise `false`.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * validatePhone("+5532912345678"); // true (Brazil)
11
+ * validatePhone("+55329123456178"); // false (invalid)
12
+ * ```
13
+ */
14
+ declare function validatePhone(rawPhone: string): boolean;
15
+ export { validatePhone };
16
+ //# sourceMappingURL=validatePhone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatePhone.d.ts","sourceRoot":"","sources":["../../src/validations/validatePhone.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AAEH,iBAAS,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAYhD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,21 @@
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
+ declare function validateRg(rawRg: string): boolean;
20
+ export { validateRg };
21
+ //# sourceMappingURL=validateRg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateRg.d.ts","sourceRoot":"","sources":["../../src/validations/validateRg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAa1C;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,32 +1,236 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "3.0.1-beta.2",
3
+ "version": "3.0.1-beta.200",
4
4
  "author": "Arkyn | Lucas Gonçalves",
5
- "main": "./dist/bundle.js",
6
- "module": "./src/index.ts",
7
- "dependencies": {
8
- "@arkyn/shared": "*",
9
- "@aws-sdk/client-s3": "^3.782.0",
10
- "@mjackson/multipart-parser": "^0.8.2",
11
- "sharp": "^0.33.5",
12
- "zod": "^3.24.2"
13
- },
14
- "devDependencies": {
15
- "bun-types": "latest",
16
- "vitest": "^3.1.1",
17
- "typescript": "^5.8.3"
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "type": "module",
8
+ "types": "./dist/index.d.ts",
9
+ "license": "Apache-2.0",
10
+ "description": "Comprehensive server-side utilities for building robust backend applications, featuring HTTP response helpers, error handlers, request utilities, and API configurations.",
11
+ "keywords": [
12
+ "server",
13
+ "http",
14
+ "api",
15
+ "utilities",
16
+ "error-handling",
17
+ "validation",
18
+ "remix",
19
+ "typescript",
20
+ "zod"
21
+ ],
22
+ "engines": {
23
+ "node": ">=24.16.0",
24
+ "bun": ">=1.3.14"
18
25
  },
19
- "peerDependencies": {
20
- "@react-router/node": ">=7.6.0"
26
+ "homepage": "https://docs.arkyn.dev/docs/server/introduction",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/Lucas-Eduardo-Goncalves/arkyn-library.git",
30
+ "directory": "packages/server"
21
31
  },
22
- "description": "Server-side utilities for projects.",
23
- "license": "Apache-2.0",
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE.txt"
36
+ ],
37
+ "sideEffects": false,
24
38
  "scripts": {
25
- "clean": "rm -rf dist",
26
- "build": "bun run clean && bunx tsc --project tsconfig.json",
27
- "test": "vitest --config vitest.config.ts",
39
+ "audit": "bun audit --workspace packages/server",
40
+ "build": "bunx vite build && bunx tsc --project tsconfig.json --emitDeclarationOnly && bun ./generate-exports.ts",
41
+ "prebuild": "rm -rf dist",
42
+ "publish:beta": "npm publish --tag beta",
43
+ "publish:latest": "npm publish --tag latest",
44
+ "release:beta": "bun ./generate-version.ts beta",
45
+ "release:patch": "bun ./generate-version.ts patch",
46
+ "release:minor": "bun ./generate-version.ts minor",
47
+ "release:major": "bun ./generate-version.ts major",
48
+ "test": "bunx vitest --config vitest.config.ts --run",
49
+ "test:watch": "bunx vitest --config vitest.config.ts --watch",
28
50
  "typecheck": "bunx tsc --project tsconfig.json --noEmit"
29
51
  },
30
- "type": "module",
31
- "types": "./dist/index.d.ts"
52
+ "peerDependencies": {
53
+ "libphonenumber-js": ">=1.13.7",
54
+ "zod": ">=4.4.3"
55
+ },
56
+ "devDependencies": {
57
+ "@types/bun": "catalog:",
58
+ "@types/node": "catalog:",
59
+ "libphonenumber-js": "catalog:",
60
+ "vite": "catalog:",
61
+ "vitest": "catalog:",
62
+ "zod": "^4.4.3"
63
+ },
64
+ "exports": {
65
+ ".": {
66
+ "import": "./dist/index.js",
67
+ "types": "./dist/index.d.ts",
68
+ "default": "./dist/index.js"
69
+ },
70
+ "./apiService": {
71
+ "import": "./dist/modules/services/apiService.js",
72
+ "types": "./dist/services/apiService.d.ts",
73
+ "default": "./dist/modules/services/apiService.js"
74
+ },
75
+ "./badGateway": {
76
+ "import": "./dist/modules/http/badResponses/badGateway.js",
77
+ "types": "./dist/http/badResponses/badGateway.d.ts",
78
+ "default": "./dist/modules/http/badResponses/badGateway.js"
79
+ },
80
+ "./badRequest": {
81
+ "import": "./dist/modules/http/badResponses/badRequest.js",
82
+ "types": "./dist/http/badResponses/badRequest.d.ts",
83
+ "default": "./dist/modules/http/badResponses/badRequest.js"
84
+ },
85
+ "./conflict": {
86
+ "import": "./dist/modules/http/badResponses/conflict.js",
87
+ "types": "./dist/http/badResponses/conflict.d.ts",
88
+ "default": "./dist/modules/http/badResponses/conflict.js"
89
+ },
90
+ "./created": {
91
+ "import": "./dist/modules/http/successResponses/created.js",
92
+ "types": "./dist/http/successResponses/created.d.ts",
93
+ "default": "./dist/modules/http/successResponses/created.js"
94
+ },
95
+ "./debugService": {
96
+ "import": "./dist/modules/services/debugService.js",
97
+ "types": "./dist/services/debugService.d.ts",
98
+ "default": "./dist/modules/services/debugService.js"
99
+ },
100
+ "./decodeRequestBody": {
101
+ "import": "./dist/modules/utilities/decodeRequestBody.js",
102
+ "types": "./dist/utilities/decodeRequestBody.d.ts",
103
+ "default": "./dist/modules/utilities/decodeRequestBody.js"
104
+ },
105
+ "./decodeRequestErrorMessage": {
106
+ "import": "./dist/modules/utilities/decodeRequestErrorMessage.js",
107
+ "types": "./dist/utilities/decodeRequestErrorMessage.d.ts",
108
+ "default": "./dist/modules/utilities/decodeRequestErrorMessage.js"
109
+ },
110
+ "./errorHandler": {
111
+ "import": "./dist/modules/utilities/errorHandler.js",
112
+ "types": "./dist/utilities/errorHandler.d.ts",
113
+ "default": "./dist/modules/utilities/errorHandler.js"
114
+ },
115
+ "./flushDebugLogs": {
116
+ "import": "./dist/modules/utilities/flushDebugLogs.js",
117
+ "types": "./dist/utilities/flushDebugLogs.d.ts",
118
+ "default": "./dist/modules/utilities/flushDebugLogs.js"
119
+ },
120
+ "./forbidden": {
121
+ "import": "./dist/modules/http/badResponses/forbidden.js",
122
+ "types": "./dist/http/badResponses/forbidden.d.ts",
123
+ "default": "./dist/modules/http/badResponses/forbidden.js"
124
+ },
125
+ "./formAsyncParse": {
126
+ "import": "./dist/modules/utilities/formAsyncParse.js",
127
+ "types": "./dist/utilities/formAsyncParse.d.ts",
128
+ "default": "./dist/modules/utilities/formAsyncParse.js"
129
+ },
130
+ "./formParse": {
131
+ "import": "./dist/modules/utilities/formParse.js",
132
+ "types": "./dist/utilities/formParse.d.ts",
133
+ "default": "./dist/modules/utilities/formParse.js"
134
+ },
135
+ "./found": {
136
+ "import": "./dist/modules/http/successResponses/found.js",
137
+ "types": "./dist/http/successResponses/found.d.ts",
138
+ "default": "./dist/modules/http/successResponses/found.js"
139
+ },
140
+ "./getScopedParams": {
141
+ "import": "./dist/modules/utilities/getScopedParams.js",
142
+ "types": "./dist/utilities/getScopedParams.d.ts",
143
+ "default": "./dist/modules/utilities/getScopedParams.js"
144
+ },
145
+ "./logService": {
146
+ "import": "./dist/modules/services/logService.js",
147
+ "types": "./dist/services/logService.d.ts",
148
+ "default": "./dist/modules/services/logService.js"
149
+ },
150
+ "./noContent": {
151
+ "import": "./dist/modules/http/successResponses/noContent.js",
152
+ "types": "./dist/http/successResponses/noContent.d.ts",
153
+ "default": "./dist/modules/http/successResponses/noContent.js"
154
+ },
155
+ "./notFound": {
156
+ "import": "./dist/modules/http/badResponses/notFound.js",
157
+ "types": "./dist/http/badResponses/notFound.d.ts",
158
+ "default": "./dist/modules/http/badResponses/notFound.js"
159
+ },
160
+ "./notImplemented": {
161
+ "import": "./dist/modules/http/badResponses/notImplemented.js",
162
+ "types": "./dist/http/badResponses/notImplemented.d.ts",
163
+ "default": "./dist/modules/http/badResponses/notImplemented.js"
164
+ },
165
+ "./schemaValidator": {
166
+ "import": "./dist/modules/utilities/schemaValidator.js",
167
+ "types": "./dist/utilities/schemaValidator.d.ts",
168
+ "default": "./dist/modules/utilities/schemaValidator.js"
169
+ },
170
+ "./serverError": {
171
+ "import": "./dist/modules/http/badResponses/serverError.js",
172
+ "types": "./dist/http/badResponses/serverError.d.ts",
173
+ "default": "./dist/modules/http/badResponses/serverError.js"
174
+ },
175
+ "./success": {
176
+ "import": "./dist/modules/http/successResponses/success.js",
177
+ "types": "./dist/http/successResponses/success.d.ts",
178
+ "default": "./dist/modules/http/successResponses/success.js"
179
+ },
180
+ "./unauthorized": {
181
+ "import": "./dist/modules/http/badResponses/unauthorized.js",
182
+ "types": "./dist/http/badResponses/unauthorized.d.ts",
183
+ "default": "./dist/modules/http/badResponses/unauthorized.js"
184
+ },
185
+ "./unprocessableEntity": {
186
+ "import": "./dist/modules/http/badResponses/unprocessableEntity.js",
187
+ "types": "./dist/http/badResponses/unprocessableEntity.d.ts",
188
+ "default": "./dist/modules/http/badResponses/unprocessableEntity.js"
189
+ },
190
+ "./updated": {
191
+ "import": "./dist/modules/http/successResponses/updated.js",
192
+ "types": "./dist/http/successResponses/updated.d.ts",
193
+ "default": "./dist/modules/http/successResponses/updated.js"
194
+ },
195
+ "./validateCep": {
196
+ "import": "./dist/modules/validations/validateCep.js",
197
+ "types": "./dist/validations/validateCep.d.ts",
198
+ "default": "./dist/modules/validations/validateCep.js"
199
+ },
200
+ "./validateCnpj": {
201
+ "import": "./dist/modules/validations/validateCnpj.js",
202
+ "types": "./dist/validations/validateCnpj.d.ts",
203
+ "default": "./dist/modules/validations/validateCnpj.js"
204
+ },
205
+ "./validateCpf": {
206
+ "import": "./dist/modules/validations/validateCpf.js",
207
+ "types": "./dist/validations/validateCpf.d.ts",
208
+ "default": "./dist/modules/validations/validateCpf.js"
209
+ },
210
+ "./validateDate": {
211
+ "import": "./dist/modules/validations/validateDate.js",
212
+ "types": "./dist/validations/validateDate.d.ts",
213
+ "default": "./dist/modules/validations/validateDate.js"
214
+ },
215
+ "./validateEmail": {
216
+ "import": "./dist/modules/validations/validateEmail.js",
217
+ "types": "./dist/validations/validateEmail.d.ts",
218
+ "default": "./dist/modules/validations/validateEmail.js"
219
+ },
220
+ "./validatePassword": {
221
+ "import": "./dist/modules/validations/validatePassword.js",
222
+ "types": "./dist/validations/validatePassword.d.ts",
223
+ "default": "./dist/modules/validations/validatePassword.js"
224
+ },
225
+ "./validatePhone": {
226
+ "import": "./dist/modules/validations/validatePhone.js",
227
+ "types": "./dist/validations/validatePhone.d.ts",
228
+ "default": "./dist/modules/validations/validatePhone.js"
229
+ },
230
+ "./validateRg": {
231
+ "import": "./dist/modules/validations/validateRg.js",
232
+ "types": "./dist/validations/validateRg.d.ts",
233
+ "default": "./dist/modules/validations/validateRg.js"
234
+ }
235
+ }
32
236
  }
@@ -1,13 +0,0 @@
1
- import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
- /**
3
- * Sends a DELETE request to the specified URL with optional headers and body.
4
- *
5
- * @template T - The expected type of the response data.
6
- * @param {string} url - The URL to send the DELETE request to.
7
- * @param {HeadersInit} [headers={}] - Optional headers to include in the request.
8
- * @param {any} [body] - Optional body to include in the request.
9
- * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
10
- */
11
- declare function deleteRequest<T = any>(url: string, headers?: HeadersInit, body?: any): Promise<ApiResponseDTO<T>>;
12
- export { deleteRequest };
13
- //# sourceMappingURL=deleteRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deleteRequest.d.ts","sourceRoot":"","sources":["../../src/api/deleteRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;;GAQG;AAEH,iBAAe,aAAa,CAAC,CAAC,GAAG,GAAG,EAClC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,14 +0,0 @@
1
- import { makeRequest } from "./makeRequest";
2
- /**
3
- * Sends a DELETE request to the specified URL with optional headers and body.
4
- *
5
- * @template T - The expected type of the response data.
6
- * @param {string} url - The URL to send the DELETE request to.
7
- * @param {HeadersInit} [headers={}] - Optional headers to include in the request.
8
- * @param {any} [body] - Optional body to include in the request.
9
- * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
10
- */
11
- async function deleteRequest(url, headers = {}, body) {
12
- return makeRequest("DELETE", url, headers, body);
13
- }
14
- export { deleteRequest };
@@ -1,12 +0,0 @@
1
- import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
- /**
3
- * Sends a GET request to the specified URL with optional headers.
4
- *
5
- * @template T - The expected type of the response data.
6
- * @param {string} url - The URL to send the GET request to.
7
- * @param {HeadersInit} [headers={}] - Optional headers to include in the request.
8
- * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
9
- */
10
- declare function getRequest<T = any>(url: string, headers?: HeadersInit): Promise<ApiResponseDTO<T>>;
11
- export { getRequest };
12
- //# sourceMappingURL=getRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getRequest.d.ts","sourceRoot":"","sources":["../../src/api/getRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;GAOG;AAEH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAC/B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,13 +0,0 @@
1
- import { makeRequest } from "./makeRequest";
2
- /**
3
- * Sends a GET request to the specified URL with optional headers.
4
- *
5
- * @template T - The expected type of the response data.
6
- * @param {string} url - The URL to send the GET request to.
7
- * @param {HeadersInit} [headers={}] - Optional headers to include in the request.
8
- * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
9
- */
10
- async function getRequest(url, headers = {}) {
11
- return makeRequest("GET", url, headers);
12
- }
13
- export { getRequest };
@@ -1,40 +0,0 @@
1
- type ConfigProps = {
2
- status: number;
3
- method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "ERROR";
4
- request: string;
5
- response: string;
6
- token: string;
7
- };
8
- /**
9
- * Sends a request to the inbox flow API with the provided configuration.
10
- *
11
- * @param config - The configuration object for the request.
12
- * @param config.status - The HTTP status code associated with the request.
13
- * @param config.method - The HTTP method used for the request. Can be "POST", "GET", "PUT", "DELETE", "PATCH", or "ERROR".
14
- * @param config.request - The request payload or details as a string.
15
- * @param config.response - The response payload or details as a string.
16
- * @param config.token - The token associated with the request for authentication or identification.
17
- *
18
- * @remarks
19
- * - This function retrieves the inbox flow configuration using `InboxFlowInstance.getInboxConfig()`.
20
- * - If the configuration is not available, the function will return early without performing any action.
21
- * - In a development environment (`NODE_ENV === "development"`), the function will also return early.
22
- * - The request is sent as a POST request to the inbox API URL with the provided configuration details.
23
- * - If an error occurs during the request, it will be logged using the `httpDebug` service.
24
- *
25
- * @example
26
- * ```typescript
27
- * const config = {
28
- * status: 200,
29
- * method: "POST",
30
- * request: JSON.stringify({ key: "value" }),
31
- * response: JSON.stringify({ success: true }),
32
- * token: "example-token",
33
- * };
34
- *
35
- * await inboxFlowRequest(config);
36
- * ```
37
- */
38
- declare function inboxFlowRequest(config: ConfigProps): Promise<void>;
39
- export { inboxFlowRequest };
40
- //# sourceMappingURL=inboxFlowRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inboxFlowRequest.d.ts","sourceRoot":"","sources":["../../src/api/inboxFlowRequest.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,iBAAe,gBAAgB,CAAC,MAAM,EAAE,WAAW,iBA+BlD;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,63 +0,0 @@
1
- import { InboxFlowInstance } from "../config/inboxFlowInstance";
2
- import { httpDebug } from "../services/httpDebug";
3
- /**
4
- * Sends a request to the inbox flow API with the provided configuration.
5
- *
6
- * @param config - The configuration object for the request.
7
- * @param config.status - The HTTP status code associated with the request.
8
- * @param config.method - The HTTP method used for the request. Can be "POST", "GET", "PUT", "DELETE", "PATCH", or "ERROR".
9
- * @param config.request - The request payload or details as a string.
10
- * @param config.response - The response payload or details as a string.
11
- * @param config.token - The token associated with the request for authentication or identification.
12
- *
13
- * @remarks
14
- * - This function retrieves the inbox flow configuration using `InboxFlowInstance.getInboxConfig()`.
15
- * - If the configuration is not available, the function will return early without performing any action.
16
- * - In a development environment (`NODE_ENV === "development"`), the function will also return early.
17
- * - The request is sent as a POST request to the inbox API URL with the provided configuration details.
18
- * - If an error occurs during the request, it will be logged using the `httpDebug` service.
19
- *
20
- * @example
21
- * ```typescript
22
- * const config = {
23
- * status: 200,
24
- * method: "POST",
25
- * request: JSON.stringify({ key: "value" }),
26
- * response: JSON.stringify({ success: true }),
27
- * token: "example-token",
28
- * };
29
- *
30
- * await inboxFlowRequest(config);
31
- * ```
32
- */
33
- async function inboxFlowRequest(config) {
34
- const inboxFlowInstance = InboxFlowInstance.getInboxConfig();
35
- if (!inboxFlowInstance)
36
- return;
37
- const { inboxChannelId, inboxUserToken, inboxApiUrl } = inboxFlowInstance;
38
- const { status, method, request, response, token } = config;
39
- if (process.env.NODE_ENV === "development")
40
- return;
41
- try {
42
- const body = JSON.stringify({
43
- status,
44
- channelId: inboxChannelId,
45
- method,
46
- token,
47
- request,
48
- response,
49
- });
50
- await fetch(inboxApiUrl, {
51
- method: "POST",
52
- body,
53
- headers: {
54
- "Content-Type": "application/json",
55
- Authorization: `Bearer ${inboxUserToken}`,
56
- },
57
- });
58
- }
59
- catch (err) {
60
- httpDebug("inboxFlowRequest", "Error sending inbox flow request", err);
61
- }
62
- }
63
- export { inboxFlowRequest };
@@ -1,38 +0,0 @@
1
- import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
- /**
3
- * Makes an HTTP request using the Fetch API and returns a standardized response.
4
- *
5
- * @template T - The expected type of the response data.
6
- * @param method - The HTTP method to use for the request. Supported methods are:
7
- * - "POST": Create a new resource.
8
- * - "PUT": Update an existing resource.
9
- * - "DELETE": Remove a resource.
10
- * - "PATCH": Partially update a resource.
11
- * - "GET": Retrieve a resource.
12
- * @param url - The URL to which the request is sent.
13
- * @param headers - Optional headers to include in the request. Defaults to an empty object.
14
- * @param body - Optional body to include in the request. Should be serializable to JSON.
15
- * @returns A promise that resolves to an `ApiResponseDTO<T>` object containing:
16
- * - `success`: A boolean indicating whether the request was successful.
17
- * - `status`: The HTTP status code of the response.
18
- * - `message`: A message describing the result of the request.
19
- * - `response`: The parsed JSON response data, or `null` if parsing fails.
20
- * - `cause`: Additional error information, if applicable.
21
- *
22
- * @example
23
- * ```typescript
24
- * import { makeRequest } from "./makeRequest";
25
- *
26
- * async function fetchData() {
27
- * const response = await makeRequest("GET", "https://api.example.com/data");
28
- * if (response.success) {
29
- * console.log("Data:", response.response);
30
- * } else {
31
- * console.error("Error:", response.message);
32
- * }
33
- * }
34
- * ```
35
- */
36
- declare function makeRequest<T = any>(method: "POST" | "PUT" | "DELETE" | "PATCH" | "GET", url: string, headers?: HeadersInit, body?: any): Promise<ApiResponseDTO<T>>;
37
- export { makeRequest };
38
- //# sourceMappingURL=makeRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"makeRequest.d.ts","sourceRoot":"","sources":["../../src/api/makeRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,iBAAe,WAAW,CAAC,CAAC,GAAG,GAAG,EAChC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,EACnD,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAsE5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}