@arkyn/server 3.0.1-beta.20 → 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 (244) hide show
  1. package/README.md +423 -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,34 @@
1
+ import { DebugService as e } from "./services/debugService.js";
2
+ import { flushDebugLogs as t } from "./utilities/flushDebugLogs.js";
3
+ import { BadGateway as n } from "./http/badResponses/badGateway.js";
4
+ import { BadRequest as r } from "./http/badResponses/badRequest.js";
5
+ import { Conflict as i } from "./http/badResponses/conflict.js";
6
+ import { Forbidden as a } from "./http/badResponses/forbidden.js";
7
+ import { NotFound as o } from "./http/badResponses/notFound.js";
8
+ import { NotImplemented as s } from "./http/badResponses/notImplemented.js";
9
+ import { ServerError as c } from "./http/badResponses/serverError.js";
10
+ import { Unauthorized as l } from "./http/badResponses/unauthorized.js";
11
+ import { UnprocessableEntity as u } from "./http/badResponses/unprocessableEntity.js";
12
+ import { Created as d } from "./http/successResponses/created.js";
13
+ import { Found as f } from "./http/successResponses/found.js";
14
+ import { NoContent as p } from "./http/successResponses/noContent.js";
15
+ import { Success as m } from "./http/successResponses/success.js";
16
+ import { Updated as h } from "./http/successResponses/updated.js";
17
+ import { LogService as g } from "./services/logService.js";
18
+ import { ApiService as _ } from "./services/apiService.js";
19
+ import { decodeRequestBody as v } from "./utilities/decodeRequestBody.js";
20
+ import { decodeRequestErrorMessage as y } from "./utilities/decodeRequestErrorMessage.js";
21
+ import { errorHandler as b } from "./utilities/errorHandler.js";
22
+ import { formAsyncParse as x } from "./utilities/formAsyncParse.js";
23
+ import { formParse as S } from "./utilities/formParse.js";
24
+ import { getScopedParams as C } from "./utilities/getScopedParams.js";
25
+ import { SchemaValidator as w } from "./utilities/schemaValidator.js";
26
+ import { validateCep as T } from "./validations/validateCep.js";
27
+ import { validateCnpj as E } from "./validations/validateCnpj.js";
28
+ import { validateCpf as D } from "./validations/validateCpf.js";
29
+ import { validateDate as O } from "./validations/validateDate.js";
30
+ import { validateEmail as k } from "./validations/validateEmail.js";
31
+ import { validatePassword as A } from "./validations/validatePassword.js";
32
+ import { validatePhone as j } from "./validations/validatePhone.js";
33
+ import { validateRg as M } from "./validations/validateRg.js";
34
+ export { _ as ApiService, n as BadGateway, r as BadRequest, i as Conflict, d as Created, e as DebugService, a as Forbidden, f as Found, g as LogService, p as NoContent, o as NotFound, s as NotImplemented, w as SchemaValidator, c as ServerError, m as Success, l as Unauthorized, u as UnprocessableEntity, h as Updated, v as decodeRequestBody, y as decodeRequestErrorMessage, b as errorHandler, t as flushDebugLogs, x as formAsyncParse, S as formParse, C as getScopedParams, T as validateCep, E as validateCnpj, D as validateCpf, O as validateDate, k as validateEmail, A as validatePassword, j as validatePhone, M as validateRg };
@@ -0,0 +1,109 @@
1
+ import { flushDebugLogs as e } from "../utilities/flushDebugLogs.js";
2
+ import { deleteRequest as t } from "../http/api/deleteRequest.js";
3
+ import { getRequest as n } from "../http/api/getRequest.js";
4
+ import { patchRequest as r } from "../http/api/patchRequest.js";
5
+ import { postRequest as i } from "../http/api/postRequest.js";
6
+ import { putRequest as a } from "../http/api/putRequest.js";
7
+ //#region src/services/apiService.ts
8
+ var o = class {
9
+ baseUrl;
10
+ baseHeaders;
11
+ baseToken;
12
+ enableDebug;
13
+ constructor(e) {
14
+ this.baseUrl = e.baseUrl, this.baseHeaders = e.baseHeaders || void 0, this.baseToken = e.baseToken || void 0, this.enableDebug = e.enableDebug || !1;
15
+ }
16
+ onDebug(t, n, r) {
17
+ if (this.enableDebug) {
18
+ let i = [], a = (e) => JSON.stringify(e, null, 2);
19
+ i.push(`Base URL: ${this.baseUrl}`), i.push(`Endpoint: ${t}`), i.push(`Status/Method: ${n} => ${r.status}`), i.push(`Message: ${r.message}`), r.headers && i.push(`Headers: ${a(r.headers)}`), r.body && i.push(`Body: ${a(r.body)}`), e({
20
+ debugs: i,
21
+ name: "ApiDebug",
22
+ scheme: "yellow"
23
+ });
24
+ }
25
+ }
26
+ generateHeaders(e, t) {
27
+ let n = {};
28
+ return this.baseToken && (n = { Authorization: `Bearer ${this.baseToken}` }), this.baseHeaders && (n = {
29
+ ...n,
30
+ ...this.baseHeaders
31
+ }), e && (n = {
32
+ ...n,
33
+ ...e
34
+ }), t && (n = {
35
+ ...n,
36
+ Authorization: `Bearer ${t}`
37
+ }), n;
38
+ }
39
+ async get(e, t) {
40
+ let r = this.generateHeaders(t?.headers || {}, t?.token), i = await n({
41
+ url: this.baseUrl + e,
42
+ urlParams: t?.urlParams || {},
43
+ headers: r
44
+ });
45
+ return this.onDebug(e, "get", {
46
+ headers: r,
47
+ message: i.message,
48
+ status: i.status
49
+ }), i;
50
+ }
51
+ async post(e, t) {
52
+ let n = this.generateHeaders(t?.headers || {}, t?.token), r = t?.body, a = await i({
53
+ url: this.baseUrl + e,
54
+ urlParams: t?.urlParams || {},
55
+ headers: n,
56
+ body: r
57
+ });
58
+ return this.onDebug(e, "post", {
59
+ headers: n,
60
+ body: r,
61
+ message: a.message,
62
+ status: a.status
63
+ }), a;
64
+ }
65
+ async put(e, t) {
66
+ let n = this.generateHeaders(t?.headers || {}, t?.token), r = t?.body, i = await a({
67
+ url: this.baseUrl + e,
68
+ urlParams: t?.urlParams || {},
69
+ headers: n,
70
+ body: r
71
+ });
72
+ return this.onDebug(e, "put", {
73
+ headers: n,
74
+ body: r,
75
+ message: i.message,
76
+ status: i.status
77
+ }), i;
78
+ }
79
+ async patch(e, t) {
80
+ let n = this.generateHeaders(t?.headers || {}, t?.token), i = t?.body, a = await r({
81
+ url: this.baseUrl + e,
82
+ urlParams: t?.urlParams || {},
83
+ headers: n,
84
+ body: i
85
+ });
86
+ return this.onDebug(e, "patch", {
87
+ headers: n,
88
+ body: i,
89
+ message: a.message,
90
+ status: a.status
91
+ }), a;
92
+ }
93
+ async delete(e, n) {
94
+ let r = this.generateHeaders(n?.headers || {}, n?.token), i = n?.body, a = await t({
95
+ url: this.baseUrl + e,
96
+ urlParams: n?.urlParams || {},
97
+ headers: r,
98
+ body: i
99
+ });
100
+ return this.onDebug(e, "delete", {
101
+ headers: r,
102
+ body: i,
103
+ message: a.message,
104
+ status: a.status
105
+ }), a;
106
+ }
107
+ };
108
+ //#endregion
109
+ export { o as ApiService };
@@ -0,0 +1,36 @@
1
+ import e from "node:path";
2
+ //#region src/services/debugService.ts
3
+ var t = class t {
4
+ static ignoreFiles = [];
5
+ static setIgnoreFile(e) {
6
+ t.ignoreFiles.push(e);
7
+ }
8
+ static clearIgnoreFiles() {
9
+ t.ignoreFiles = [];
10
+ }
11
+ static getCaller() {
12
+ let n = process.cwd(), r = ((/* @__PURE__ */ Error()).stack || "").split("\n").map((e) => e.trim()), i = 2;
13
+ for (; i < r.length && (r[i].includes("node:internal") || r[i].includes("/node_modules/"));) i++;
14
+ if (t.ignoreFiles.length > 0) for (; i < r.length && t.ignoreFiles.some((e) => r[i].includes(e));) i++;
15
+ let a = r[i] || "", o = "Unknown function", s = "Unknown caller", c = a.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
16
+ if (c) o = c[1], s = c[2];
17
+ else {
18
+ let e = a.match(/at\s+(.+)/);
19
+ if (e) {
20
+ s = e[1];
21
+ let t = s.match(/at\s+([^(\s]+)\s+/);
22
+ t && t[1] !== "new" && (o = t[1]);
23
+ }
24
+ }
25
+ s.includes("(") && (s = s.substring(s.indexOf("(") + 1, s.lastIndexOf(")"))), s = s.split(":").slice(0, -2).join(":");
26
+ try {
27
+ s = e.relative(n, s);
28
+ } catch {}
29
+ return {
30
+ functionName: o,
31
+ callerInfo: s
32
+ };
33
+ }
34
+ };
35
+ //#endregion
36
+ export { t as DebugService };
@@ -0,0 +1,31 @@
1
+ //#region src/services/logMapperService.ts
2
+ var e = class e {
3
+ static mapHeaders(e) {
4
+ return e instanceof Headers ? Object.fromEntries(e.entries()) : typeof e == "object" ? Object.entries(e).reduce((e, [t, n]) => (typeof n == "string" ? e[t] = n : Array.isArray(n) ? e[t] = n.join(", ") : e[t] = JSON.stringify(n), e), {}) : {};
5
+ }
6
+ static mapQueryParams(e) {
7
+ let t = {};
8
+ return e.forEach((e, n) => {
9
+ t[n] = e;
10
+ }), t;
11
+ }
12
+ static handle(t) {
13
+ return {
14
+ rawUrl: t.rawUrl,
15
+ status: t.status,
16
+ method: t.method,
17
+ token: null,
18
+ elapsedTime: t.elapsedTime,
19
+ requestHeaders: e.mapHeaders(t.requestHeaders),
20
+ requestBody: t.requestBody || null,
21
+ queryParams: {
22
+ ...e.mapQueryParams(t.queryParams),
23
+ ...t.urlParams
24
+ },
25
+ responseHeaders: e.mapHeaders(t.responseHeaders),
26
+ responseBody: t.responseBody || null
27
+ };
28
+ }
29
+ };
30
+ //#endregion
31
+ export { e as LogMapperService };
@@ -0,0 +1,21 @@
1
+ //#region src/services/logService.ts
2
+ var e = class e {
3
+ static config;
4
+ static setConfig(t) {
5
+ if (e.config) return;
6
+ let { trafficSourceId: n, userToken: r, logBaseApiUrl: i } = t;
7
+ e.config = {
8
+ trafficSourceId: n,
9
+ userToken: r,
10
+ apiUrl: `${i || "http://62.238.8.44:8081"}/ingest-log`
11
+ };
12
+ }
13
+ static getConfig() {
14
+ return e.config;
15
+ }
16
+ static resetConfig() {
17
+ e.config = void 0;
18
+ }
19
+ };
20
+ //#endregion
21
+ export { e as LogService };
@@ -0,0 +1,20 @@
1
+ import { BadRequest as e } from "../http/badResponses/badRequest.js";
2
+ //#region src/utilities/decodeRequestBody.ts
3
+ async function t(t) {
4
+ let n, r = await t.arrayBuffer(), i = new TextDecoder().decode(r);
5
+ try {
6
+ n = JSON.parse(i);
7
+ } catch {
8
+ try {
9
+ if (i.includes("=")) {
10
+ let e = new URLSearchParams(i);
11
+ n = Object.fromEntries(e.entries());
12
+ } else throw new e("Invalid URLSearchParams format");
13
+ } catch {
14
+ throw new e("Failed to extract data from request");
15
+ }
16
+ }
17
+ return n;
18
+ }
19
+ //#endregion
20
+ export { t as decodeRequestBody };
@@ -0,0 +1,6 @@
1
+ //#region src/utilities/decodeRequestErrorMessage.ts
2
+ function e(e, t) {
3
+ return e?.message && typeof e?.message == "string" ? e?.message : e?.operator_erro_message && typeof e?.operator_erro_message == "string" ? e?.operator_erro_message : e?.error && typeof e?.error == "string" ? e?.error : e?.error?.message && typeof e?.error?.message == "string" ? e?.error?.message : t?.statusText && typeof t?.statusText == "string" ? t?.statusText : "Missing error message";
4
+ }
5
+ //#endregion
6
+ export { e as decodeRequestErrorMessage };
@@ -0,0 +1,39 @@
1
+ import { BadGateway as e } from "../http/badResponses/badGateway.js";
2
+ import { BadRequest as t } from "../http/badResponses/badRequest.js";
3
+ import { Conflict as n } from "../http/badResponses/conflict.js";
4
+ import { Forbidden as r } from "../http/badResponses/forbidden.js";
5
+ import { NotFound as i } from "../http/badResponses/notFound.js";
6
+ import { NotImplemented as a } from "../http/badResponses/notImplemented.js";
7
+ import { ServerError as o } from "../http/badResponses/serverError.js";
8
+ import { Unauthorized as s } from "../http/badResponses/unauthorized.js";
9
+ import { UnprocessableEntity as c } from "../http/badResponses/unprocessableEntity.js";
10
+ import { Created as l } from "../http/successResponses/created.js";
11
+ import { Found as u } from "../http/successResponses/found.js";
12
+ import { NoContent as d } from "../http/successResponses/noContent.js";
13
+ import { Success as f } from "../http/successResponses/success.js";
14
+ import { Updated as p } from "../http/successResponses/updated.js";
15
+ //#region src/utilities/errorHandler.ts
16
+ function m(m) {
17
+ switch (!0) {
18
+ case m instanceof Response: return m;
19
+ case m instanceof u: return m.toResponse();
20
+ case m instanceof l: return m.toResponse();
21
+ case m instanceof p: return m.toResponse();
22
+ case m instanceof f: return m.toResponse();
23
+ case m instanceof d: return m.toResponse();
24
+ }
25
+ switch (!0) {
26
+ case m instanceof e: return m.toResponse();
27
+ case m instanceof t: return m.toResponse();
28
+ case m instanceof n: return m.toResponse();
29
+ case m instanceof r: return m.toResponse();
30
+ case m instanceof i: return m.toResponse();
31
+ case m instanceof a: return m.toResponse();
32
+ case m instanceof o: return m.toResponse();
33
+ case m instanceof s: return m.toResponse();
34
+ case m instanceof c: return m.toResponse();
35
+ }
36
+ return new o("Server error", m).toResponse();
37
+ }
38
+ //#endregion
39
+ export { m as errorHandler };
@@ -0,0 +1,16 @@
1
+ //#region src/utilities/flushDebugLogs.ts
2
+ function e(e) {
3
+ if (process.env.NODE_ENV === "development" || process.env?.DEBUG_MODE === "true") {
4
+ let t = `${{
5
+ yellow: "\x1B[33m",
6
+ cyan: "\x1B[36m",
7
+ red: "\x1B[31m",
8
+ green: "\x1B[32m"
9
+ }[e.scheme]}[${e.name}]`, n = "\n";
10
+ e.debugs.forEach((r, i) => {
11
+ n += `${t} ${r.trim()}`, i < e.debugs.length - 1 && (n += "\n");
12
+ }), console.log(n);
13
+ }
14
+ }
15
+ //#endregion
16
+ export { e as flushDebugLogs };
@@ -0,0 +1,14 @@
1
+ //#region src/utilities/formAsyncParse.ts
2
+ async function e([e, t]) {
3
+ let n = await t.safeParseAsync(e);
4
+ return n.success === !1 ? {
5
+ success: !1,
6
+ fieldErrors: Object.fromEntries(n.error.issues.map((e) => [e.path.join("."), e.message])),
7
+ fields: e
8
+ } : {
9
+ success: !0,
10
+ data: n.data
11
+ };
12
+ }
13
+ //#endregion
14
+ export { e as formAsyncParse };
@@ -0,0 +1,14 @@
1
+ //#region src/utilities/formParse.ts
2
+ function e([e, t]) {
3
+ let n = t.safeParse(e);
4
+ return n.success === !1 ? {
5
+ success: !1,
6
+ fieldErrors: Object.fromEntries(n.error.issues.map((e) => [e.path.join("."), e.message])),
7
+ fields: e
8
+ } : {
9
+ success: !0,
10
+ data: n.data
11
+ };
12
+ }
13
+ //#endregion
14
+ export { e as formParse };
@@ -0,0 +1,9 @@
1
+ //#region src/utilities/getScopedParams.ts
2
+ function e(e, t = "") {
3
+ let n = new URL(e.url);
4
+ if (t === "") return n.searchParams;
5
+ let r = Array.from(n.searchParams.entries()).filter(([e]) => e.startsWith(`${t}:`)).map(([e, n]) => [e.replace(`${t}:`, ""), n]);
6
+ return new URLSearchParams(r);
7
+ }
8
+ //#endregion
9
+ export { e as getScopedParams };
@@ -0,0 +1,55 @@
1
+ import { ServerError as e } from "../http/badResponses/serverError.js";
2
+ import { UnprocessableEntity as t } from "../http/badResponses/unprocessableEntity.js";
3
+ import { formAsyncParse as n } from "./formAsyncParse.js";
4
+ import { formParse as r } from "./formParse.js";
5
+ //#region src/utilities/schemaValidator.ts
6
+ function i(e) {
7
+ return ["Error validating:", ...e.issues.map(({ path: e, message: t }) => `-> ${e.join(".")}: ${t}`)].join("\n");
8
+ }
9
+ var a = class {
10
+ schema;
11
+ constructor(e) {
12
+ this.schema = e;
13
+ }
14
+ isValid(e) {
15
+ return this.schema.safeParse(e).success;
16
+ }
17
+ safeValidate(e) {
18
+ return this.schema.safeParse(e);
19
+ }
20
+ validate(t) {
21
+ try {
22
+ return this.schema.parse(t);
23
+ } catch (t) {
24
+ throw new e(i(t));
25
+ }
26
+ }
27
+ formValidate(e, n) {
28
+ let i = r([e, this.schema]);
29
+ if ("fieldErrors" in i) {
30
+ let e = Object.keys(i.fieldErrors)[0];
31
+ throw new t({
32
+ fields: i.fields,
33
+ fieldErrors: i.fieldErrors,
34
+ data: { scrollTo: e },
35
+ message: n
36
+ });
37
+ }
38
+ return i.data;
39
+ }
40
+ async formAsyncValidate(e, r) {
41
+ let i = await n([e, this.schema]);
42
+ if ("fieldErrors" in i) {
43
+ let e = Object.keys(i.fieldErrors)[0];
44
+ throw new t({
45
+ fields: i.fields,
46
+ fieldErrors: i.fieldErrors,
47
+ data: { scrollTo: e },
48
+ message: r
49
+ });
50
+ }
51
+ return i.data;
52
+ }
53
+ };
54
+ //#endregion
55
+ export { a as SchemaValidator };
@@ -0,0 +1,9 @@
1
+ import { removeNonNumeric as e } from "@arkyn/shared";
2
+ //#region src/validations/validateCep.ts
3
+ function t(t) {
4
+ if (!(/^\d{5}-\d{3}$/.test(t) || /^\d{8}$/.test(t))) return !1;
5
+ let n = e(t), r = /^\d{8}$/.test(n);
6
+ return n.length === 8 && r;
7
+ }
8
+ //#endregion
9
+ export { t as validateCep };
@@ -0,0 +1,54 @@
1
+ import { removeNonNumeric as e } from "@arkyn/shared";
2
+ //#region src/validations/validateCnpj.ts
3
+ function t(e) {
4
+ return e.length !== 14;
5
+ }
6
+ function n(e) {
7
+ let [t] = e;
8
+ return [...e].every((e) => e === t);
9
+ }
10
+ function r(e, t) {
11
+ let n = 0;
12
+ for (let r = 0; r < t.length; r++) n += parseInt(e[r], 10) * t[r];
13
+ let r = n % 11;
14
+ return r < 2 ? 0 : 11 - r;
15
+ }
16
+ function i(e) {
17
+ return e.slice(12);
18
+ }
19
+ function a(a) {
20
+ if (!a || a.length > 18 || a.length < 14 || /\s/.test(a)) return !1;
21
+ let o = e(a);
22
+ if (t(o) || n(o)) return !1;
23
+ let s = o.slice(0, 12), c = r(s, [
24
+ 5,
25
+ 4,
26
+ 3,
27
+ 2,
28
+ 9,
29
+ 8,
30
+ 7,
31
+ 6,
32
+ 5,
33
+ 4,
34
+ 3,
35
+ 2
36
+ ]), l = r(s + c, [
37
+ 6,
38
+ 5,
39
+ 4,
40
+ 3,
41
+ 2,
42
+ 9,
43
+ 8,
44
+ 7,
45
+ 6,
46
+ 5,
47
+ 4,
48
+ 3,
49
+ 2
50
+ ]);
51
+ return i(o) === `${c}${l}`;
52
+ }
53
+ //#endregion
54
+ export { a as validateCnpj };
@@ -0,0 +1,27 @@
1
+ import { removeNonNumeric as e } from "@arkyn/shared";
2
+ //#region src/validations/validateCpf.ts
3
+ function t(e) {
4
+ return e.length !== 11;
5
+ }
6
+ function n(e) {
7
+ let [t] = e;
8
+ return [...e].every((e) => e === t);
9
+ }
10
+ function r(e, t) {
11
+ let n = 0;
12
+ for (let r of e) t > 1 && (n += parseInt(r, 10) * t--);
13
+ let r = n % 11;
14
+ return r < 2 ? 0 : 11 - r;
15
+ }
16
+ function i(e) {
17
+ return e.slice(9);
18
+ }
19
+ function a(a) {
20
+ if (!a || a.length > 14 || a.length < 11 || /\s/.test(a)) return !1;
21
+ let o = e(a);
22
+ if (t(o) || n(o)) return !1;
23
+ let s = r(o, 10), c = r(o, 11);
24
+ return i(o) === `${s}${c}`;
25
+ }
26
+ //#endregion
27
+ export { a as validateCpf };
@@ -0,0 +1,26 @@
1
+ import { ValidateDateService as e } from "@arkyn/shared";
2
+ //#region src/validations/validateDate.ts
3
+ function t(t, n) {
4
+ let r = n?.inputFormat || "brazilianDate", i = n?.minYear || 1900, a = n?.maxYear || 3e3, o = new e();
5
+ o.validateInputFormat(r);
6
+ let s, c, l, u = t.split(/[-/]/).map(Number);
7
+ if (u.length !== 3) return !1;
8
+ try {
9
+ switch (r) {
10
+ case "brazilianDate":
11
+ [s, c, l] = u, o.validateDateParts(l, c, s);
12
+ break;
13
+ case "isoDate":
14
+ [c, s, l] = u, o.validateDateParts(l, c, s);
15
+ break;
16
+ case "timestamp":
17
+ [l, c, s] = u, o.validateDateParts(l, c, s);
18
+ break;
19
+ }
20
+ return !(l < i || l > a);
21
+ } catch {
22
+ return !1;
23
+ }
24
+ }
25
+ //#endregion
26
+ export { t as validateDate };
@@ -0,0 +1,54 @@
1
+ import e from "node:dns";
2
+ //#region src/validations/validateEmail.ts
3
+ function t(e) {
4
+ return /^[a-zA-Z0-9.!$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(e);
5
+ }
6
+ function n(e) {
7
+ return !(e.length === 0 || e.length > 64 || e.startsWith(".") || e.endsWith(".") || e.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e));
8
+ }
9
+ function r(e) {
10
+ return !(e.length === 0 || e.length > 63 || e.startsWith("-") || e.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(e));
11
+ }
12
+ function i(e) {
13
+ if (e.length === 0 || e.length > 253 || e.startsWith(".") || e.endsWith(".") || e.startsWith("-") || e.endsWith("-")) return !1;
14
+ let t = e.split(".");
15
+ if (t.length < 2) return !1;
16
+ for (let e of t) if (!r(e)) return !1;
17
+ let n = t[t.length - 1];
18
+ return !(n.length < 2 || !/^[a-zA-Z]+$/.test(n));
19
+ }
20
+ function a(e) {
21
+ let t = e.split("@");
22
+ if (t.length !== 2) return !1;
23
+ let [r, a] = t;
24
+ return !(!n(r) || !i(a));
25
+ }
26
+ function o(e) {
27
+ let t = e.split("@");
28
+ return t.length === 2 ? t[1].toLowerCase() : null;
29
+ }
30
+ var s = [
31
+ "MX",
32
+ "A",
33
+ "AAAA"
34
+ ];
35
+ async function c(t, n) {
36
+ try {
37
+ return await e?.promises?.resolve(t, n), !0;
38
+ } catch {
39
+ return !1;
40
+ }
41
+ }
42
+ async function l(e) {
43
+ for (let t of s) if (await c(e, t)) return !0;
44
+ return !1;
45
+ }
46
+ async function u(e) {
47
+ if (!e || typeof e != "string") return !1;
48
+ let n = e.trim();
49
+ if (!t(n) || !a(n)) return !1;
50
+ let r = o(n);
51
+ return r ? await l(r) : !1;
52
+ }
53
+ //#endregion
54
+ export { u as validateEmail };
@@ -0,0 +1,12 @@
1
+ //#region src/validations/validatePassword.ts
2
+ function e(e) {
3
+ return e ? [
4
+ e.length >= 8,
5
+ /[A-Z]/.test(e),
6
+ /[a-z]/.test(e),
7
+ /\d/.test(e),
8
+ /[!@#$%^&*(),.?":;{}|<>_\-+=~`[\]\\/]/.test(e)
9
+ ].every((e) => e) : !1;
10
+ }
11
+ //#endregion
12
+ export { e as validatePassword };
@@ -0,0 +1,10 @@
1
+ import { countries as e } from "@arkyn/templates";
2
+ import { isValidPhoneNumber as t, parsePhoneNumberWithError as n } from "libphonenumber-js";
3
+ //#region src/validations/validatePhone.ts
4
+ function r(r) {
5
+ if (!t(r)) return !1;
6
+ let i = n(r)?.country;
7
+ return !(!i || !e.find((e) => e.iso === i));
8
+ }
9
+ //#endregion
10
+ export { r as validatePhone };
@@ -0,0 +1,8 @@
1
+ //#region src/validations/validateRg.ts
2
+ function e(e) {
3
+ if (!e || !/^[0-9a-zA-Z.-]+$/.test(e)) return !1;
4
+ let t = e.replace(/[^a-zA-Z0-9]/g, "");
5
+ return t.length < 7 || t.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(t);
6
+ }
7
+ //#endregion
8
+ export { e as validateRg };