@arkyn/server 3.0.1-beta.20 → 3.0.1-beta.201

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 (244) hide show
  1. package/README.md +425 -69
  2. package/dist/{api/arkynLogRequest.d.ts → http/api/_logRequest.d.ts} +22 -19
  3. package/dist/{api/arkynLogRequest.d.ts.map → http/api/_logRequest.d.ts.map} +1 -1
  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 +222 -15
  136. package/dist/api/arkynLogRequest.js +0 -82
  137. package/dist/api/deleteRequest.d.ts +0 -13
  138. package/dist/api/deleteRequest.d.ts.map +0 -1
  139. package/dist/api/deleteRequest.js +0 -14
  140. package/dist/api/getRequest.d.ts +0 -12
  141. package/dist/api/getRequest.d.ts.map +0 -1
  142. package/dist/api/getRequest.js +0 -13
  143. package/dist/api/makeRequest.d.ts +0 -38
  144. package/dist/api/makeRequest.d.ts.map +0 -1
  145. package/dist/api/makeRequest.js +0 -103
  146. package/dist/api/patchRequest.d.ts +0 -13
  147. package/dist/api/patchRequest.d.ts.map +0 -1
  148. package/dist/api/patchRequest.js +0 -14
  149. package/dist/api/postRequest.d.ts +0 -13
  150. package/dist/api/postRequest.d.ts.map +0 -1
  151. package/dist/api/postRequest.js +0 -14
  152. package/dist/api/putRequest.d.ts +0 -13
  153. package/dist/api/putRequest.d.ts.map +0 -1
  154. package/dist/api/putRequest.js +0 -14
  155. package/dist/config/apiInstance.d.ts +0 -80
  156. package/dist/config/apiInstance.d.ts.map +0 -1
  157. package/dist/config/apiInstance.js +0 -111
  158. package/dist/config/arkynLogInstance.d.ts +0 -44
  159. package/dist/config/arkynLogInstance.d.ts.map +0 -1
  160. package/dist/config/arkynLogInstance.js +0 -49
  161. package/dist/http/badResponses/badGateway.js +0 -52
  162. package/dist/http/badResponses/badRequest.js +0 -52
  163. package/dist/http/badResponses/conflict.js +0 -52
  164. package/dist/http/badResponses/forbidden.js +0 -52
  165. package/dist/http/badResponses/notFound.js +0 -52
  166. package/dist/http/badResponses/notImplemented.js +0 -52
  167. package/dist/http/badResponses/serverError.js +0 -52
  168. package/dist/http/badResponses/unauthorized.js +0 -52
  169. package/dist/http/badResponses/unprocessableEntity.js +0 -60
  170. package/dist/http/successResponses/created.js +0 -54
  171. package/dist/http/successResponses/found.js +0 -57
  172. package/dist/http/successResponses/noContent.js +0 -35
  173. package/dist/http/successResponses/success.js +0 -54
  174. package/dist/http/successResponses/updated.js +0 -54
  175. package/dist/mapper/arkynLogRequestMapper.d.ts +0 -30
  176. package/dist/mapper/arkynLogRequestMapper.d.ts.map +0 -1
  177. package/dist/mapper/arkynLogRequestMapper.js +0 -44
  178. package/dist/services/decodeErrorMessageFromRequest.d.ts +0 -17
  179. package/dist/services/decodeErrorMessageFromRequest.d.ts.map +0 -1
  180. package/dist/services/decodeErrorMessageFromRequest.js +0 -30
  181. package/dist/services/decodeRequestBody.d.ts +0 -17
  182. package/dist/services/decodeRequestBody.d.ts.map +0 -1
  183. package/dist/services/decodeRequestBody.js +0 -38
  184. package/dist/services/errorHandler.d.ts +0 -44
  185. package/dist/services/errorHandler.d.ts.map +0 -1
  186. package/dist/services/errorHandler.js +0 -93
  187. package/dist/services/formParse.d.ts +0 -59
  188. package/dist/services/formParse.d.ts.map +0 -1
  189. package/dist/services/formParse.js +0 -59
  190. package/dist/services/getCaller.d.ts +0 -17
  191. package/dist/services/getCaller.d.ts.map +0 -1
  192. package/dist/services/getCaller.js +0 -65
  193. package/dist/services/getScopedParams.d.ts +0 -28
  194. package/dist/services/getScopedParams.d.ts.map +0 -1
  195. package/dist/services/getScopedParams.js +0 -34
  196. package/dist/services/httpDebug.d.ts +0 -35
  197. package/dist/services/httpDebug.d.ts.map +0 -1
  198. package/dist/services/httpDebug.js +0 -52
  199. package/dist/services/measureRouteExecution.d.ts +0 -3
  200. package/dist/services/measureRouteExecution.d.ts.map +0 -1
  201. package/dist/services/measureRouteExecution.js +0 -24
  202. package/dist/services/schemaValidator.d.ts +0 -13
  203. package/dist/services/schemaValidator.d.ts.map +0 -1
  204. package/dist/services/schemaValidator.js +0 -51
  205. package/dist/types/ApiResponseDTO.d.ts +0 -17
  206. package/dist/types/ApiResponseDTO.d.ts.map +0 -1
  207. package/dist/types/ApiResponseDTO.js +0 -1
  208. package/src/api/arkynLogRequest.ts +0 -118
  209. package/src/api/deleteRequest.ts +0 -22
  210. package/src/api/getRequest.ts +0 -20
  211. package/src/api/makeRequest.ts +0 -118
  212. package/src/api/patchRequest.ts +0 -22
  213. package/src/api/postRequest.ts +0 -22
  214. package/src/api/putRequest.ts +0 -22
  215. package/src/config/apiInstance.ts +0 -148
  216. package/src/config/arkynLogInstance.ts +0 -70
  217. package/src/http/badResponses/badGateway.ts +0 -63
  218. package/src/http/badResponses/badRequest.ts +0 -63
  219. package/src/http/badResponses/conflict.ts +0 -63
  220. package/src/http/badResponses/forbidden.ts +0 -63
  221. package/src/http/badResponses/notFound.ts +0 -63
  222. package/src/http/badResponses/notImplemented.ts +0 -63
  223. package/src/http/badResponses/serverError.ts +0 -63
  224. package/src/http/badResponses/unauthorized.ts +0 -63
  225. package/src/http/badResponses/unprocessableEntity.ts +0 -79
  226. package/src/http/successResponses/created.ts +0 -64
  227. package/src/http/successResponses/found.ts +0 -67
  228. package/src/http/successResponses/noContent.ts +0 -42
  229. package/src/http/successResponses/success.ts +0 -64
  230. package/src/http/successResponses/updated.ts +0 -64
  231. package/src/index.ts +0 -31
  232. package/src/mapper/arkynLogRequestMapper.ts +0 -73
  233. package/src/services/decodeErrorMessageFromRequest.ts +0 -36
  234. package/src/services/decodeRequestBody.ts +0 -43
  235. package/src/services/errorHandler.ts +0 -99
  236. package/src/services/formParse.ts +0 -86
  237. package/src/services/getCaller.ts +0 -82
  238. package/src/services/getScopedParams.ts +0 -43
  239. package/src/services/httpDebug.ts +0 -61
  240. package/src/services/measureRouteExecution.ts +0 -31
  241. package/src/services/schemaValidator.ts +0 -66
  242. package/src/types/ApiResponseDTO.ts +0 -19
  243. package/tsconfig.json +0 -21
  244. 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,29 +1,236 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "3.0.1-beta.20",
3
+ "version": "3.0.1-beta.201",
4
4
  "author": "Arkyn | Lucas Gonçalves",
5
- "main": "./dist/bundle.js",
6
- "module": "./src/index.ts",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
7
  "type": "module",
8
8
  "types": "./dist/index.d.ts",
9
9
  "license": "Apache-2.0",
10
- "description": "Server-side utilities for projects.",
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"
25
+ },
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"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE.txt"
36
+ ],
37
+ "sideEffects": false,
11
38
  "scripts": {
12
- "clean": "rm -rf dist",
13
- "build": "bun run clean && bunx tsc --project tsconfig.json",
14
- "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",
15
50
  "typecheck": "bunx tsc --project tsconfig.json --noEmit"
16
51
  },
17
- "dependencies": {
18
- "@arkyn/shared": "*",
19
- "zod": "^4.0.17"
52
+ "peerDependencies": {
53
+ "libphonenumber-js": ">=1.13.7",
54
+ "zod": ">=4.4.3"
20
55
  },
21
56
  "devDependencies": {
22
- "bun-types": "latest",
23
- "vitest": "^3.2.4",
24
- "typescript": "^5.9.2"
57
+ "@types/bun": "catalog:",
58
+ "@types/node": "catalog:",
59
+ "libphonenumber-js": "catalog:",
60
+ "vite": "catalog:",
61
+ "vitest": "catalog:",
62
+ "zod": "^4.4.3"
25
63
  },
26
- "peerDependencies": {
27
- "@react-router/node": "^7.6.2"
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
+ }
28
235
  }
29
236
  }
@@ -1,82 +0,0 @@
1
- import { ArkynLogInstance } from "../config/arkynLogInstance";
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.rawUrl - The raw URL of the request.
8
- * @param config.status - The HTTP status code associated with the request.
9
- * @param config.method - The HTTP method used for the request. Can be "POST", "GET", "PUT", "DELETE", or "PATCH".
10
- * @param config.token - The authentication token for the request.
11
- * @param config.elapsedTime - The elapsed time for the request in milliseconds.
12
- * @param config.requestHeaders - The headers sent with the request.
13
- * @param config.requestBody - The body of the request, if applicable.
14
- * @param config.queryParams - The query parameters for the request.
15
- * @param config.responseHeaders - The headers received in the response.
16
- * @param config.responseBody - The body of the response received.
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
- * rawUrl: "https://example.com/api/data",
29
- * status: 200,
30
- * method: "GET",
31
- * token: "auth-token-123",
32
- * elapsedTime: "150ms",
33
- * requestHeaders: { "Accept": "application/json", "Authorization": "Bearer token123" },
34
- * requestBody: {},
35
- * queryParams: { "page": "1", "limit": "10" },
36
- * responseHeaders: { "Content-Type": "application/json" },
37
- * responseBody: { "data": "example response" }
38
- * };
39
- *
40
- * await arkynLogRequest(config);
41
- * ```
42
- */
43
- async function arkynLogRequest(config) {
44
- const arkynInstance = ArkynLogInstance.getArkynConfig();
45
- if (!arkynInstance)
46
- return;
47
- const { arkynUserToken, arkynApiUrl } = arkynInstance;
48
- const { elapsedTime, method, queryParams, requestBody, requestHeaders, responseBody, responseHeaders, status, token, rawUrl, } = config;
49
- // if (process.env.NODE_ENV === "development") return;
50
- try {
51
- const url = new URL(rawUrl);
52
- let protocol = "HTTPS";
53
- if (url.protocol === "http:")
54
- protocol = "HTTP";
55
- const body = JSON.stringify({
56
- domainUrl: url.protocol + "//" + url.host,
57
- pathnameUrl: url.pathname,
58
- status,
59
- protocol,
60
- method,
61
- trafficUserId: null,
62
- elapsedTime,
63
- requestHeaders,
64
- requestBody,
65
- queryParams,
66
- responseHeaders,
67
- responseBody,
68
- });
69
- await fetch(arkynApiUrl.replace(":trafficSourceId", arkynInstance.arkynTrafficSourceId), {
70
- method: "POST",
71
- body,
72
- headers: {
73
- "Content-Type": "application/json",
74
- Authorization: `Bearer ${arkynUserToken}`,
75
- },
76
- });
77
- }
78
- catch (err) {
79
- httpDebug("arkyn log error", "Error sending request", err);
80
- }
81
- }
82
- export { arkynLogRequest };
@@ -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,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, rawHeaders?: 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":"AAEA,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,UAAU,GAAE,WAAgB,EAC5B,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAsE5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,103 +0,0 @@
1
- import { ArkynLogRequestMapper } from "../mapper/arkynLogRequestMapper";
2
- import { httpDebug } from "../services/httpDebug";
3
- import { arkynLogRequest } from "./arkynLogRequest";
4
- /**
5
- * Makes an HTTP request using the Fetch API and returns a standardized response.
6
- *
7
- * @template T - The expected type of the response data.
8
- * @param method - The HTTP method to use for the request. Supported methods are:
9
- * - "POST": Create a new resource.
10
- * - "PUT": Update an existing resource.
11
- * - "DELETE": Remove a resource.
12
- * - "PATCH": Partially update a resource.
13
- * - "GET": Retrieve a resource.
14
- * @param url - The URL to which the request is sent.
15
- * @param headers - Optional headers to include in the request. Defaults to an empty object.
16
- * @param body - Optional body to include in the request. Should be serializable to JSON.
17
- * @returns A promise that resolves to an `ApiResponseDTO<T>` object containing:
18
- * - `success`: A boolean indicating whether the request was successful.
19
- * - `status`: The HTTP status code of the response.
20
- * - `message`: A message describing the result of the request.
21
- * - `response`: The parsed JSON response data, or `null` if parsing fails.
22
- * - `cause`: Additional error information, if applicable.
23
- *
24
- * @example
25
- * ```typescript
26
- * import { makeRequest } from "./makeRequest";
27
- *
28
- * async function fetchData() {
29
- * const response = await makeRequest("GET", "https://api.example.com/data");
30
- * if (response.success) {
31
- * console.log("Data:", response.response);
32
- * } else {
33
- * console.error("Error:", response.message);
34
- * }
35
- * }
36
- * ```
37
- */
38
- async function makeRequest(method, url, rawHeaders = {}, body) {
39
- const successMessage = {
40
- POST: "Resource created successfully",
41
- PUT: "Resource updated successfully",
42
- DELETE: "Resource deleted successfully",
43
- PATCH: "Resource patched successfully",
44
- GET: "Request successful",
45
- };
46
- try {
47
- const startTime = performance.now();
48
- const headers = { ...rawHeaders, "Content-Type": "application/json" };
49
- const response = await fetch(url, {
50
- method,
51
- headers,
52
- body: body ? JSON.stringify(body) : undefined,
53
- });
54
- const elapsedTime = performance.now() - startTime;
55
- const status = response.status;
56
- let data = null;
57
- try {
58
- data = await response.json();
59
- }
60
- catch {
61
- data = null;
62
- }
63
- const logData = ArkynLogRequestMapper.handle({
64
- elapsedTime,
65
- method,
66
- queryParams: new URL(url).searchParams,
67
- requestHeaders: headers,
68
- requestBody: body,
69
- responseBody: data,
70
- responseHeaders: response.headers,
71
- status,
72
- url,
73
- });
74
- arkynLogRequest(logData);
75
- if (!response.ok) {
76
- return {
77
- success: false,
78
- status,
79
- message: data?.message || response.statusText || "Request failed",
80
- response: data,
81
- cause: null,
82
- };
83
- }
84
- return {
85
- success: true,
86
- status,
87
- message: data?.message || successMessage[method],
88
- response: data,
89
- cause: null,
90
- };
91
- }
92
- catch (err) {
93
- httpDebug("Network error or request failed", null, err);
94
- return {
95
- success: false,
96
- status: 0,
97
- message: "Network error or request failed",
98
- response: null,
99
- cause: err instanceof Error ? err.message : String(err),
100
- };
101
- }
102
- }
103
- export { makeRequest };