@arkyn/server 3.0.1-beta.99 → 3.0.3

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 (265) hide show
  1. package/LICENSE.txt +184 -1
  2. package/README.md +277 -224
  3. package/dist/http/api/_deleteRequest.d.ts +17 -0
  4. package/dist/http/api/_deleteRequest.d.ts.map +1 -0
  5. package/dist/http/api/_getRequest.d.ts +16 -0
  6. package/dist/http/api/_getRequest.d.ts.map +1 -0
  7. package/dist/http/api/_logMapperService.d.ts +86 -0
  8. package/dist/http/api/_logMapperService.d.ts.map +1 -0
  9. package/dist/{api/arkynLogRequest.d.ts → http/api/_logRequest.d.ts} +22 -19
  10. package/dist/{api/arkynLogRequest.d.ts.map → http/api/_logRequest.d.ts.map} +1 -1
  11. package/dist/http/api/_makeRequest.d.ts +61 -0
  12. package/dist/http/api/_makeRequest.d.ts.map +1 -0
  13. package/dist/http/api/_patchRequest.d.ts +17 -0
  14. package/dist/http/api/_patchRequest.d.ts.map +1 -0
  15. package/dist/http/api/_postRequest.d.ts +17 -0
  16. package/dist/http/api/_postRequest.d.ts.map +1 -0
  17. package/dist/http/api/_putRequest.d.ts +17 -0
  18. package/dist/http/api/_putRequest.d.ts.map +1 -0
  19. package/dist/http/badResponses/_badResponse.d.ts +21 -7
  20. package/dist/http/badResponses/_badResponse.d.ts.map +1 -1
  21. package/dist/http/badResponses/badGateway.d.ts +12 -23
  22. package/dist/http/badResponses/badGateway.d.ts.map +1 -1
  23. package/dist/http/badResponses/badRequest.d.ts +10 -23
  24. package/dist/http/badResponses/badRequest.d.ts.map +1 -1
  25. package/dist/http/badResponses/conflict.d.ts +10 -23
  26. package/dist/http/badResponses/conflict.d.ts.map +1 -1
  27. package/dist/http/badResponses/forbidden.d.ts +10 -23
  28. package/dist/http/badResponses/forbidden.d.ts.map +1 -1
  29. package/dist/http/badResponses/notFound.d.ts +10 -23
  30. package/dist/http/badResponses/notFound.d.ts.map +1 -1
  31. package/dist/http/badResponses/notImplemented.d.ts +10 -23
  32. package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
  33. package/dist/http/badResponses/serverError.d.ts +10 -23
  34. package/dist/http/badResponses/serverError.d.ts.map +1 -1
  35. package/dist/http/badResponses/unauthorized.d.ts +10 -23
  36. package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
  37. package/dist/http/badResponses/unprocessableEntity.d.ts +23 -33
  38. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
  39. package/dist/http/successResponses/_successResponse.d.ts +21 -7
  40. package/dist/http/successResponses/_successResponse.d.ts.map +1 -1
  41. package/dist/http/successResponses/created.d.ts +11 -29
  42. package/dist/http/successResponses/created.d.ts.map +1 -1
  43. package/dist/http/successResponses/found.d.ts +11 -32
  44. package/dist/http/successResponses/found.d.ts.map +1 -1
  45. package/dist/http/successResponses/noContent.d.ts +10 -16
  46. package/dist/http/successResponses/noContent.d.ts.map +1 -1
  47. package/dist/http/successResponses/success.d.ts +11 -29
  48. package/dist/http/successResponses/success.d.ts.map +1 -1
  49. package/dist/http/successResponses/updated.d.ts +12 -29
  50. package/dist/http/successResponses/updated.d.ts.map +1 -1
  51. package/dist/index.d.ts +9 -10
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +1069 -38
  54. package/dist/index.js.map +1 -0
  55. package/dist/modules/http/api/_deleteRequest.js +15 -0
  56. package/dist/modules/http/api/_deleteRequest.js.map +1 -0
  57. package/dist/modules/http/api/_getRequest.js +14 -0
  58. package/dist/modules/http/api/_getRequest.js.map +1 -0
  59. package/dist/modules/http/api/_logMapperService.js +33 -0
  60. package/dist/modules/http/api/_logMapperService.js.map +1 -0
  61. package/dist/modules/http/api/_logRequest.js +58 -0
  62. package/dist/modules/http/api/_logRequest.js.map +1 -0
  63. package/dist/modules/http/api/_makeRequest.js +72 -0
  64. package/dist/modules/http/api/_makeRequest.js.map +1 -0
  65. package/dist/modules/http/api/_patchRequest.js +15 -0
  66. package/dist/modules/http/api/_patchRequest.js.map +1 -0
  67. package/dist/modules/http/api/_postRequest.js +15 -0
  68. package/dist/modules/http/api/_postRequest.js.map +1 -0
  69. package/dist/modules/http/api/_putRequest.js +15 -0
  70. package/dist/modules/http/api/_putRequest.js.map +1 -0
  71. package/dist/modules/http/badResponses/_badResponse.js +65 -0
  72. package/dist/modules/http/badResponses/_badResponse.js.map +1 -0
  73. package/dist/modules/http/badResponses/badGateway.js +26 -0
  74. package/dist/modules/http/badResponses/badGateway.js.map +1 -0
  75. package/dist/modules/http/badResponses/badRequest.js +26 -0
  76. package/dist/modules/http/badResponses/badRequest.js.map +1 -0
  77. package/dist/modules/http/badResponses/conflict.js +26 -0
  78. package/dist/modules/http/badResponses/conflict.js.map +1 -0
  79. package/dist/modules/http/badResponses/forbidden.js +26 -0
  80. package/dist/modules/http/badResponses/forbidden.js.map +1 -0
  81. package/dist/modules/http/badResponses/notFound.js +26 -0
  82. package/dist/modules/http/badResponses/notFound.js.map +1 -0
  83. package/dist/modules/http/badResponses/notImplemented.js +26 -0
  84. package/dist/modules/http/badResponses/notImplemented.js.map +1 -0
  85. package/dist/modules/http/badResponses/serverError.js +26 -0
  86. package/dist/modules/http/badResponses/serverError.js.map +1 -0
  87. package/dist/modules/http/badResponses/unauthorized.js +26 -0
  88. package/dist/modules/http/badResponses/unauthorized.js.map +1 -0
  89. package/dist/modules/http/badResponses/unprocessableEntity.js +30 -0
  90. package/dist/modules/http/badResponses/unprocessableEntity.js.map +1 -0
  91. package/dist/modules/http/successResponses/_successResponse.js +64 -0
  92. package/dist/modules/http/successResponses/_successResponse.js.map +1 -0
  93. package/dist/modules/http/successResponses/created.js +26 -0
  94. package/dist/modules/http/successResponses/created.js.map +1 -0
  95. package/dist/modules/http/successResponses/found.js +26 -0
  96. package/dist/modules/http/successResponses/found.js.map +1 -0
  97. package/dist/modules/http/successResponses/noContent.js +19 -0
  98. package/dist/modules/http/successResponses/noContent.js.map +1 -0
  99. package/dist/modules/http/successResponses/success.js +26 -0
  100. package/dist/modules/http/successResponses/success.js.map +1 -0
  101. package/dist/modules/http/successResponses/updated.js +26 -0
  102. package/dist/modules/http/successResponses/updated.js.map +1 -0
  103. package/dist/modules/services/apiService.js +111 -0
  104. package/dist/modules/services/apiService.js.map +1 -0
  105. package/dist/modules/services/debugService.js +38 -0
  106. package/dist/modules/services/debugService.js.map +1 -0
  107. package/dist/modules/services/logService.js +23 -0
  108. package/dist/modules/services/logService.js.map +1 -0
  109. package/dist/modules/utilities/decodeRequestBody.js +22 -0
  110. package/dist/modules/utilities/decodeRequestBody.js.map +1 -0
  111. package/dist/modules/utilities/decodeRequestErrorMessage.js +8 -0
  112. package/dist/modules/utilities/decodeRequestErrorMessage.js.map +1 -0
  113. package/dist/modules/utilities/errorHandler.js +41 -0
  114. package/dist/modules/utilities/errorHandler.js.map +1 -0
  115. package/dist/modules/utilities/flushDebugLogs.js +18 -0
  116. package/dist/modules/utilities/flushDebugLogs.js.map +1 -0
  117. package/dist/modules/utilities/formAsyncParse.js +16 -0
  118. package/dist/modules/utilities/formAsyncParse.js.map +1 -0
  119. package/dist/modules/utilities/formParse.js +16 -0
  120. package/dist/modules/utilities/formParse.js.map +1 -0
  121. package/dist/modules/utilities/getScopedParams.js +11 -0
  122. package/dist/modules/utilities/getScopedParams.js.map +1 -0
  123. package/dist/modules/utilities/schemaValidator.js +57 -0
  124. package/dist/modules/utilities/schemaValidator.js.map +1 -0
  125. package/dist/modules/validations/validateCep.js +11 -0
  126. package/dist/modules/validations/validateCep.js.map +1 -0
  127. package/dist/modules/validations/validateCnpj.js +56 -0
  128. package/dist/modules/validations/validateCnpj.js.map +1 -0
  129. package/dist/modules/validations/validateCpf.js +29 -0
  130. package/dist/modules/validations/validateCpf.js.map +1 -0
  131. package/dist/modules/validations/validateDate.js +28 -0
  132. package/dist/modules/validations/validateDate.js.map +1 -0
  133. package/dist/modules/validations/validateEmail.js +56 -0
  134. package/dist/modules/validations/validateEmail.js.map +1 -0
  135. package/dist/modules/validations/validatePassword.js +14 -0
  136. package/dist/modules/validations/validatePassword.js.map +1 -0
  137. package/dist/modules/validations/validatePhone.js +12 -0
  138. package/dist/modules/validations/validatePhone.js.map +1 -0
  139. package/dist/modules/validations/validateRg.js +10 -0
  140. package/dist/modules/validations/validateRg.js.map +1 -0
  141. package/dist/services/apiService.d.ts +25 -26
  142. package/dist/services/apiService.d.ts.map +1 -1
  143. package/dist/services/debugService.d.ts +15 -32
  144. package/dist/services/debugService.d.ts.map +1 -1
  145. package/dist/services/logService.d.ts +33 -0
  146. package/dist/services/logService.d.ts.map +1 -0
  147. package/dist/utilities/decodeRequestBody.d.ts +18 -0
  148. package/dist/utilities/decodeRequestBody.d.ts.map +1 -0
  149. package/dist/utilities/decodeRequestErrorMessage.d.ts +19 -0
  150. package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -0
  151. package/dist/utilities/errorHandler.d.ts +25 -0
  152. package/dist/utilities/errorHandler.d.ts.map +1 -0
  153. package/dist/utilities/flushDebugLogs.d.ts +24 -0
  154. package/dist/utilities/flushDebugLogs.d.ts.map +1 -0
  155. package/dist/utilities/formAsyncParse.d.ts +38 -0
  156. package/dist/utilities/formAsyncParse.d.ts.map +1 -0
  157. package/dist/utilities/formParse.d.ts +38 -0
  158. package/dist/utilities/formParse.d.ts.map +1 -0
  159. package/dist/utilities/getScopedParams.d.ts +19 -0
  160. package/dist/utilities/getScopedParams.d.ts.map +1 -0
  161. package/dist/utilities/schemaValidator.d.ts +75 -0
  162. package/dist/utilities/schemaValidator.d.ts.map +1 -0
  163. package/dist/validations/validateCep.d.ts +6 -11
  164. package/dist/validations/validateCep.d.ts.map +1 -1
  165. package/dist/validations/validateCnpj.d.ts +2 -3
  166. package/dist/validations/validateCnpj.d.ts.map +1 -1
  167. package/dist/validations/validateCpf.d.ts +4 -12
  168. package/dist/validations/validateCpf.d.ts.map +1 -1
  169. package/dist/validations/validateDate.d.ts +13 -24
  170. package/dist/validations/validateDate.d.ts.map +1 -1
  171. package/dist/validations/validateEmail.d.ts +3 -4
  172. package/dist/validations/validateEmail.d.ts.map +1 -1
  173. package/dist/validations/validatePassword.d.ts +3 -4
  174. package/dist/validations/validatePassword.d.ts.map +1 -1
  175. package/dist/validations/validatePhone.d.ts +7 -20
  176. package/dist/validations/validatePhone.d.ts.map +1 -1
  177. package/dist/validations/validateRg.d.ts +1 -2
  178. package/dist/validations/validateRg.d.ts.map +1 -1
  179. package/package.json +317 -15
  180. package/dist/api/arkynLogRequest.js +0 -88
  181. package/dist/api/deleteRequest.d.ts +0 -13
  182. package/dist/api/deleteRequest.d.ts.map +0 -1
  183. package/dist/api/deleteRequest.js +0 -14
  184. package/dist/api/getRequest.d.ts +0 -12
  185. package/dist/api/getRequest.d.ts.map +0 -1
  186. package/dist/api/getRequest.js +0 -13
  187. package/dist/api/makeRequest.d.ts +0 -38
  188. package/dist/api/makeRequest.d.ts.map +0 -1
  189. package/dist/api/makeRequest.js +0 -107
  190. package/dist/api/patchRequest.d.ts +0 -13
  191. package/dist/api/patchRequest.d.ts.map +0 -1
  192. package/dist/api/patchRequest.js +0 -14
  193. package/dist/api/postRequest.d.ts +0 -13
  194. package/dist/api/postRequest.d.ts.map +0 -1
  195. package/dist/api/postRequest.js +0 -14
  196. package/dist/api/putRequest.d.ts +0 -13
  197. package/dist/api/putRequest.d.ts.map +0 -1
  198. package/dist/api/putRequest.js +0 -14
  199. package/dist/bundle.js +0 -1507
  200. package/dist/bundle.umd.cjs +0 -10
  201. package/dist/http/badResponses/_badResponse.js +0 -20
  202. package/dist/http/badResponses/badGateway.js +0 -58
  203. package/dist/http/badResponses/badRequest.js +0 -58
  204. package/dist/http/badResponses/conflict.js +0 -58
  205. package/dist/http/badResponses/forbidden.js +0 -58
  206. package/dist/http/badResponses/notFound.js +0 -58
  207. package/dist/http/badResponses/notImplemented.js +0 -58
  208. package/dist/http/badResponses/serverError.js +0 -58
  209. package/dist/http/badResponses/unauthorized.js +0 -58
  210. package/dist/http/badResponses/unprocessableEntity.js +0 -65
  211. package/dist/http/successResponses/_successResponse.js +0 -37
  212. package/dist/http/successResponses/created.js +0 -57
  213. package/dist/http/successResponses/found.js +0 -60
  214. package/dist/http/successResponses/noContent.js +0 -38
  215. package/dist/http/successResponses/success.js +0 -57
  216. package/dist/http/successResponses/updated.js +0 -57
  217. package/dist/mapper/arkynLogRequestMapper.d.ts +0 -30
  218. package/dist/mapper/arkynLogRequestMapper.d.ts.map +0 -1
  219. package/dist/mapper/arkynLogRequestMapper.js +0 -44
  220. package/dist/services/apiService.js +0 -133
  221. package/dist/services/arkynLogService.d.ts +0 -44
  222. package/dist/services/arkynLogService.d.ts.map +0 -1
  223. package/dist/services/arkynLogService.js +0 -46
  224. package/dist/services/debugService.js +0 -57
  225. package/dist/services/decodeErrorMessageFromRequest.d.ts +0 -17
  226. package/dist/services/decodeErrorMessageFromRequest.d.ts.map +0 -1
  227. package/dist/services/decodeErrorMessageFromRequest.js +0 -30
  228. package/dist/services/decodeRequestBody.d.ts +0 -17
  229. package/dist/services/decodeRequestBody.d.ts.map +0 -1
  230. package/dist/services/decodeRequestBody.js +0 -38
  231. package/dist/services/errorHandler.d.ts +0 -44
  232. package/dist/services/errorHandler.d.ts.map +0 -1
  233. package/dist/services/errorHandler.js +0 -93
  234. package/dist/services/flushDebugLogs.d.ts +0 -8
  235. package/dist/services/flushDebugLogs.d.ts.map +0 -1
  236. package/dist/services/flushDebugLogs.js +0 -20
  237. package/dist/services/formAsyncParse.d.ts +0 -59
  238. package/dist/services/formAsyncParse.d.ts.map +0 -1
  239. package/dist/services/formAsyncParse.js +0 -58
  240. package/dist/services/formParse.d.ts +0 -59
  241. package/dist/services/formParse.d.ts.map +0 -1
  242. package/dist/services/formParse.js +0 -58
  243. package/dist/services/getCaller.d.ts +0 -17
  244. package/dist/services/getCaller.d.ts.map +0 -1
  245. package/dist/services/getCaller.js +0 -60
  246. package/dist/services/getScopedParams.d.ts +0 -28
  247. package/dist/services/getScopedParams.d.ts.map +0 -1
  248. package/dist/services/getScopedParams.js +0 -34
  249. package/dist/services/measureRouteExecution.d.ts +0 -3
  250. package/dist/services/measureRouteExecution.d.ts.map +0 -1
  251. package/dist/services/measureRouteExecution.js +0 -24
  252. package/dist/services/schemaValidator.d.ts +0 -158
  253. package/dist/services/schemaValidator.d.ts.map +0 -1
  254. package/dist/services/schemaValidator.js +0 -207
  255. package/dist/types/ApiResponseDTO.d.ts +0 -17
  256. package/dist/types/ApiResponseDTO.d.ts.map +0 -1
  257. package/dist/types/ApiResponseDTO.js +0 -1
  258. package/dist/validations/validateCep.js +0 -33
  259. package/dist/validations/validateCnpj.js +0 -52
  260. package/dist/validations/validateCpf.js +0 -54
  261. package/dist/validations/validateDate.js +0 -73
  262. package/dist/validations/validateEmail.js +0 -123
  263. package/dist/validations/validatePassword.js +0 -34
  264. package/dist/validations/validatePhone.js +0 -44
  265. package/dist/validations/validateRg.js +0 -31
@@ -1,57 +0,0 @@
1
- import { SuccessResponse } from "./_successResponse";
2
- /**
3
- * Represents a successful HTTP response with a status code of 201 (Created).
4
- * This class is used to standardize the structure of a "Created" response,
5
- * including the response body, headers, status, and status text.
6
- *
7
- * @template T - The type of the response body.
8
- */
9
- class Created extends SuccessResponse {
10
- body;
11
- headers;
12
- status;
13
- statusText;
14
- /**
15
- * Creates an instance of the `Created` class.
16
- *
17
- * @param body - The response body to be included in the HTTP response.
18
- * @param init - Optional initialization object for customizing headers, status, and status text.
19
- */
20
- constructor(body, init) {
21
- super();
22
- this.body = { ...body, name: "Created", message: init?.message };
23
- this.headers = init?.headers || {};
24
- this.status = init?.status || 201;
25
- this.statusText = init?.statusText || "Resource created successfully";
26
- this.onDebug("Created", body);
27
- }
28
- /**
29
- * Converts the `Created` instance into a `Response` object with a JSON body.
30
- * This method ensures the response has the appropriate headers, status, and status text.
31
- *
32
- * @returns A `Response` object with the serialized JSON body and response metadata.
33
- */
34
- toResponse() {
35
- const responseInit = {
36
- headers: { "Content-Type": "application/json", ...this.headers },
37
- status: this.status,
38
- statusText: this.statusText,
39
- };
40
- return new Response(JSON.stringify(this.body), responseInit);
41
- }
42
- /**
43
- * Converts the `Created` instance into a `Response` object using the `Response.json` method.
44
- * This method is an alternative to `toResponse` for generating JSON responses.
45
- *
46
- * @returns A `Response` object with the JSON body and response metadata.
47
- */
48
- toJson() {
49
- const responseInit = {
50
- headers: this.headers,
51
- status: this.status,
52
- statusText: this.statusText,
53
- };
54
- return Response.json(this.body, responseInit);
55
- }
56
- }
57
- export { Created };
@@ -1,60 +0,0 @@
1
- import { SuccessResponse } from "./_successResponse";
2
- /**
3
- * Represents an HTTP 302 Found response.
4
- * This class is used to create a standardized HTTP response with a status of 302 (Found),
5
- * including optional headers and a response body.
6
- *
7
- * @template T - The type of the response body.
8
- */
9
- class Found extends SuccessResponse {
10
- body;
11
- headers;
12
- status;
13
- statusText;
14
- /**
15
- * Creates an instance of the `Found` class.
16
- *
17
- * @param body - The body of the response.
18
- * @param init - Optional initialization object to set headers, status, and statusText.
19
- * - `headers`: Additional headers to include in the response.
20
- * - `status`: HTTP status code (default is 302).
21
- * - `statusText`: HTTP status text (default is "Found").
22
- */
23
- constructor(body, init) {
24
- super();
25
- this.body = { ...body, name: "Found", message: init?.message };
26
- this.headers = init?.headers || {};
27
- this.status = init?.status || 302;
28
- this.statusText = init?.statusText || "Found";
29
- this.onDebug("Found", body);
30
- }
31
- /**
32
- * Converts the `Found` instance into a `Response` object.
33
- * This method serializes the response body as JSON and includes the appropriate headers.
34
- *
35
- * @returns A `Response` object with the serialized JSON body and the specified headers, status, and statusText.
36
- */
37
- toResponse() {
38
- const responseInit = {
39
- headers: { "Content-Type": "application/json", ...this.headers },
40
- status: this.status,
41
- statusText: this.statusText,
42
- };
43
- return new Response(JSON.stringify(this.body), responseInit);
44
- }
45
- /**
46
- * Converts the `Found` instance into a JSON response using `Response.json`.
47
- * This method is an alternative to `toResponse` for creating JSON responses.
48
- *
49
- * @returns A `Response` object with the JSON body and the specified headers, status, and statusText.
50
- */
51
- toJson() {
52
- const responseInit = {
53
- headers: this.headers,
54
- status: this.status,
55
- statusText: this.statusText,
56
- };
57
- return Response.json(this.body, responseInit);
58
- }
59
- }
60
- export { Found };
@@ -1,38 +0,0 @@
1
- import { SuccessResponse } from "./_successResponse";
2
- /**
3
- * Represents a successful HTTP response with a status code of 204 (No Content).
4
- * This class is used to standardize the structure of a "No Content" response,
5
- * including headers, status, and status text.
6
- */
7
- class NoContent extends SuccessResponse {
8
- headers;
9
- status;
10
- statusText;
11
- /**
12
- * Creates an instance of the `NoContent` class.
13
- *
14
- * @param init - Optional initialization object for customizing headers, status, and status text.
15
- */
16
- constructor(init) {
17
- super();
18
- this.headers = init?.headers || {};
19
- this.status = init?.status || 204;
20
- this.statusText = init?.statusText ?? "No content";
21
- this.onDebug("No content", null);
22
- }
23
- /**
24
- * Converts the `NoContent` instance into a `Response` object.
25
- * This method ensures the response has the appropriate headers, status, and status text.
26
- *
27
- * @returns A `Response` object with no body and response metadata.
28
- */
29
- toResponse() {
30
- const responseInit = {
31
- headers: this.headers,
32
- status: this.status,
33
- statusText: this.statusText,
34
- };
35
- return new Response(null, responseInit);
36
- }
37
- }
38
- export { NoContent };
@@ -1,57 +0,0 @@
1
- import { SuccessResponse } from "./_successResponse";
2
- /**
3
- * Represents a successful HTTP response with a status code of 200 (OK).
4
- * This class is used to standardize the structure of a "Success" response,
5
- * including the response body, headers, status, and status text.
6
- *
7
- * @template T - The type of the response body.
8
- */
9
- class Success extends SuccessResponse {
10
- body;
11
- headers;
12
- status;
13
- statusText;
14
- /**
15
- * Creates an instance of the `Success` class.
16
- *
17
- * @param body - The response body to be included in the HTTP response.
18
- * @param init - Optional initialization object for customizing headers, status, and status text.
19
- */
20
- constructor(body, init) {
21
- super();
22
- this.body = { ...body, name: "Success", message: init?.message };
23
- this.headers = init?.headers || {};
24
- this.status = init?.status || 200;
25
- this.statusText = init?.statusText ?? "OK";
26
- this.onDebug("Success", body);
27
- }
28
- /**
29
- * Converts the `Success` instance into a `Response` object with a JSON body.
30
- * This method ensures the response has the appropriate headers, status, and status text.
31
- *
32
- * @returns A `Response` object with the serialized JSON body and response metadata.
33
- */
34
- toResponse() {
35
- const responseInit = {
36
- headers: { "Content-Type": "application/json", ...this.headers },
37
- status: this.status,
38
- statusText: this.statusText,
39
- };
40
- return new Response(JSON.stringify(this.body), responseInit);
41
- }
42
- /**
43
- * Converts the `Success` instance into a `Response` object using the `Response.json` method.
44
- * This method is an alternative to `toResponse` for generating JSON responses.
45
- *
46
- * @returns A `Response` object with the JSON body and response metadata.
47
- */
48
- toJson() {
49
- const responseInit = {
50
- headers: this.headers,
51
- status: this.status,
52
- statusText: this.statusText,
53
- };
54
- return Response.json(this.body, responseInit);
55
- }
56
- }
57
- export { Success };
@@ -1,57 +0,0 @@
1
- import { SuccessResponse } from "./_successResponse";
2
- /**
3
- * Represents a successful HTTP response with a status code of 200 (OK) or other custom status codes.
4
- * This class is used to standardize the structure of an "Updated" response,
5
- * including the response body, headers, status, and status text.
6
- *
7
- * @template T - The type of the response body.
8
- */
9
- class Updated extends SuccessResponse {
10
- body;
11
- headers;
12
- status;
13
- statusText;
14
- /**
15
- * Creates an instance of the `Updated` class.
16
- *
17
- * @param body - The response body to be included in the HTTP response.
18
- * @param init - Optional initialization object for customizing headers, status, and status text.
19
- */
20
- constructor(body, init) {
21
- super();
22
- this.body = { ...body, name: "Updated", message: init?.message };
23
- this.headers = init?.headers || {};
24
- this.status = init?.status || 200;
25
- this.statusText = init?.statusText || "Resource updated successfully";
26
- this.onDebug("Updated", body);
27
- }
28
- /**
29
- * Converts the `Updated` instance into a `Response` object with a JSON body.
30
- * This method ensures the response has the appropriate headers, status, and status text.
31
- *
32
- * @returns A `Response` object with the serialized JSON body and response metadata.
33
- */
34
- toResponse() {
35
- const responseInit = {
36
- headers: { "Content-Type": "application/json", ...this.headers },
37
- status: this.status,
38
- statusText: this.statusText,
39
- };
40
- return new Response(JSON.stringify(this.body), responseInit);
41
- }
42
- /**
43
- * Converts the `Updated` instance into a `Response` object using the `Response.json` method.
44
- * This method is an alternative to `toResponse` for generating JSON responses.
45
- *
46
- * @returns A `Response` object with the JSON body and response metadata.
47
- */
48
- toJson() {
49
- const responseInit = {
50
- headers: this.headers,
51
- status: this.status,
52
- statusText: this.statusText,
53
- };
54
- return Response.json(this.body, responseInit);
55
- }
56
- }
57
- export { Updated };
@@ -1,30 +0,0 @@
1
- type InputProps = {
2
- status: number;
3
- url: string;
4
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
5
- requestHeaders: HeadersInit;
6
- responseHeaders: HeadersInit;
7
- requestBody: any;
8
- elapsedTime: number;
9
- responseBody: any;
10
- queryParams: URLSearchParams;
11
- };
12
- type OutputProps = {
13
- rawUrl: string;
14
- status: number;
15
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
16
- token: string | null;
17
- elapsedTime: number;
18
- requestHeaders: Record<string, string>;
19
- requestBody: Record<string, string>;
20
- queryParams: Record<string, string>;
21
- responseHeaders: Record<string, string>;
22
- responseBody: any;
23
- };
24
- declare class ArkynLogRequestMapper {
25
- private static mapHeaders;
26
- private static mapQueryParams;
27
- static handle(props: InputProps): OutputProps;
28
- }
29
- export { ArkynLogRequestMapper };
30
- //# sourceMappingURL=arkynLogRequestMapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arkynLogRequestMapper.d.ts","sourceRoot":"","sources":["../../src/mapper/arkynLogRequestMapper.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,cAAc,EAAE,WAAW,CAAC;IAC5B,eAAe,EAAE,WAAW,CAAC;IAC7B,WAAW,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC;IAClB,WAAW,EAAE,eAAe,CAAC;CAC9B,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,YAAY,EAAE,GAAG,CAAC;CACnB,CAAC;AAEF,cAAM,qBAAqB;IACzB,OAAO,CAAC,MAAM,CAAC,UAAU;IAkBzB,OAAO,CAAC,MAAM,CAAC,cAAc;IAY7B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW;CAc9C;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -1,44 +0,0 @@
1
- class ArkynLogRequestMapper {
2
- static mapHeaders(headers) {
3
- if (headers instanceof Headers) {
4
- return Object.fromEntries(headers.entries());
5
- }
6
- else if (typeof headers === "object") {
7
- return Object.entries(headers).reduce((acc, [key, value]) => {
8
- if (typeof value === "string") {
9
- acc[key] = value;
10
- }
11
- else if (Array.isArray(value)) {
12
- acc[key] = value.join(", ");
13
- }
14
- else {
15
- acc[key] = JSON.stringify(value);
16
- }
17
- return acc;
18
- }, {});
19
- }
20
- return {};
21
- }
22
- static mapQueryParams(queryParams) {
23
- const params = {};
24
- queryParams.forEach((value, key) => {
25
- params[key] = value;
26
- });
27
- return params;
28
- }
29
- static handle(props) {
30
- return {
31
- rawUrl: props.url,
32
- status: props.status,
33
- method: props.method,
34
- token: null,
35
- elapsedTime: props.elapsedTime,
36
- requestHeaders: this.mapHeaders(props.requestHeaders),
37
- requestBody: props.requestBody || null,
38
- queryParams: this.mapQueryParams(props.queryParams),
39
- responseHeaders: this.mapHeaders(props.responseHeaders),
40
- responseBody: props.responseBody || null,
41
- };
42
- }
43
- }
44
- export { ArkynLogRequestMapper };
@@ -1,133 +0,0 @@
1
- import { deleteRequest } from "../api/deleteRequest";
2
- import { getRequest } from "../api/getRequest";
3
- import { patchRequest } from "../api/patchRequest";
4
- import { postRequest } from "../api/postRequest";
5
- import { putRequest } from "../api/putRequest";
6
- import { flushDebugLogs } from "./flushDebugLogs";
7
- /**
8
- * Class representing an API instance to handle HTTP requests with base configurations.
9
- */
10
- class ApiService {
11
- baseUrl;
12
- baseHeaders;
13
- baseToken;
14
- enableDebug;
15
- /**
16
- * Creates an instance of ApiService.
17
- * @param props - The configuration properties for the API instance.
18
- * @param props.baseUrl - The base URL for the API.
19
- * @param props.baseHeaders - Optional base headers to include in all requests.
20
- * @param props.baseToken - Optional base token for authorization.
21
- * @param props.enableDebug - Optional flag to enable debug logging for requests.
22
- */
23
- constructor(props) {
24
- this.baseUrl = props.baseUrl;
25
- this.baseHeaders = props.baseHeaders || undefined;
26
- this.baseToken = props.baseToken || undefined;
27
- this.enableDebug = props.enableDebug || false;
28
- }
29
- /**
30
- * Generates the full URL by appending the route to the base URL.
31
- * @param route - The route to append to the base URL.
32
- * @returns The full URL as a string.
33
- */
34
- onDebug(endpoint, method, data) {
35
- if (this.enableDebug) {
36
- const debugs = [];
37
- debugs.push(`Base URL: ${this.baseUrl}`);
38
- debugs.push(`Endpoint: ${endpoint}`);
39
- debugs.push(`Method: ${method}`);
40
- if (data[0])
41
- debugs.push(`Headers: ${JSON.stringify(data[0])}`);
42
- if (data[1])
43
- debugs.push(`Body: ${JSON.stringify(data[1])}`);
44
- flushDebugLogs({ debugs, name: "ARKYN-API-DEBUG", scheme: "yellow" });
45
- }
46
- }
47
- generateURL(route) {
48
- return this.baseUrl + route;
49
- }
50
- /**
51
- * Generates the headers for a request by merging base headers, provided headers, and tokens.
52
- * @param initHeaders - Initial headers to include in the request.
53
- * @param token - Optional token to override the base token.
54
- * @returns The merged headers as a HeadersInit object.
55
- */
56
- generateHeaders(initHeaders, token) {
57
- let headers = {};
58
- if (this.baseToken)
59
- headers = { Authorization: `Bearer ${this.baseToken}` };
60
- if (this.baseHeaders)
61
- headers = { ...headers, ...this.baseHeaders };
62
- if (initHeaders)
63
- headers = { ...headers, ...initHeaders };
64
- if (token)
65
- headers = { ...headers, Authorization: `Bearer ${token}` };
66
- return headers;
67
- }
68
- /**
69
- * Sends a get request to the specified endpoint.
70
- * @param endpoint - The API endpoint to send the get request to.
71
- * @param data - The request data, including optional headers and token.
72
- * @returns The API response data.
73
- */
74
- async get(endpoint, data) {
75
- const url = this.generateURL(endpoint);
76
- const headers = this.generateHeaders(data?.headers || {}, data?.token);
77
- this.onDebug(endpoint, "get", [headers]);
78
- return await getRequest(url, headers);
79
- }
80
- /**
81
- * Sends a post request to the specified endpoint.
82
- * @param endpoint - The API endpoint to send the post request to.
83
- * @param data - The request data, including body, optional headers, and token.
84
- * @returns The API response data.
85
- */
86
- async post(endpoint, data) {
87
- const url = this.generateURL(endpoint);
88
- const headers = this.generateHeaders(data?.headers || {}, data?.token);
89
- const body = data?.body;
90
- this.onDebug(endpoint, "post", [headers, body]);
91
- return await postRequest(url, headers, body);
92
- }
93
- /**
94
- * Sends a put request to the specified endpoint.
95
- * @param endpoint - The API endpoint to send the put request to.
96
- * @param data - The request data, including body, optional headers, and token.
97
- * @returns The API response data.
98
- */
99
- async put(endpoint, data) {
100
- const url = this.generateURL(endpoint);
101
- const headers = this.generateHeaders(data?.headers || {}, data?.token);
102
- const body = data?.body;
103
- this.onDebug(endpoint, "put", [headers, body]);
104
- return await putRequest(url, headers, body);
105
- }
106
- /**
107
- * Sends a patch request to the specified endpoint.
108
- * @param endpoint - The API endpoint to send the patch request to.
109
- * @param data - The request data, including body, optional headers, and token.
110
- * @returns The API response data.
111
- */
112
- async patch(endpoint, data) {
113
- const url = this.generateURL(endpoint);
114
- const headers = this.generateHeaders(data?.headers || {}, data?.token);
115
- const body = data?.body;
116
- this.onDebug(endpoint, "patch", [headers, body]);
117
- return await patchRequest(url, headers, body);
118
- }
119
- /**
120
- * Sends a delete request to the specified endpoint.
121
- * @param endpoint - The API endpoint to send the delete request to.
122
- * @param data - The request data, including body, optional headers, and token.
123
- * @returns The API response data.
124
- */
125
- async delete(endpoint, data) {
126
- const url = this.generateURL(endpoint);
127
- const headers = this.generateHeaders(data?.headers || {}, data?.token);
128
- const body = data?.body;
129
- this.onDebug(endpoint, "delete", [headers, body]);
130
- return await deleteRequest(url, headers, body);
131
- }
132
- }
133
- export { ApiService };
@@ -1,44 +0,0 @@
1
- type ArkynConfigProps = {
2
- trafficSourceId: string;
3
- userToken: string;
4
- apiUrl: string;
5
- };
6
- type SetArkynConfigProps = {
7
- trafficSourceId: string;
8
- userToken: string;
9
- logBaseApiUrl?: string;
10
- };
11
- /**
12
- * The `ArkynLogService` class manages the configuration for the arkyn flow.
13
- * It allows you to set and retrieve the arkyn configuration, including the traffic source ID,
14
- * user token, and API URL.
15
- */
16
- declare class ArkynLogService {
17
- private static arkynConfig?;
18
- /**
19
- * Sets the configuration for the arkyn. This method initializes the arkyn configuration
20
- * with the provided `arkynConfig` values. If the configuration has already been set,
21
- * the method will return early without making any changes.
22
- *
23
- * @param arkynConfig - An object containing the arkyn configuration properties.
24
- * @param arkynConfig.arkynTrafficSourceId - The key used to identify the arkyn.
25
- * @param arkynConfig.arkynUserToken - The user token for authenticating with the arkyn.
26
- * @param arkynConfig.arkynLogBaseApiUrl - (Optional) The API URL for the arkyn. If not provided,
27
- * a default URL will be used.
28
- */
29
- static setArkynConfig(arkynConfig: SetArkynConfigProps): void;
30
- /**
31
- * Retrieves the current arkyn configuration for the ArkynLogService.
32
- *
33
- * @returns {ArkynConfigProps | undefined} The current arkyn configuration if set,
34
- * or `undefined` if no configuration has been initialized.
35
- */
36
- static getArkynConfig(): ArkynConfigProps | undefined;
37
- /**
38
- * Resets the arkyn configuration to `undefined`.
39
- * This method can be used to clear the current configuration.
40
- */
41
- static resetArkynConfig(): void;
42
- }
43
- export { ArkynLogService };
44
- //# sourceMappingURL=arkynLogService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arkynLogService.d.ts","sourceRoot":"","sources":["../../src/services/arkynLogService.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AAEH,cAAM,eAAe;IACnB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAmB;IAE9C;;;;;;;;;;OAUG;IAEH,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,mBAAmB;IAYtD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,IAAI,gBAAgB,GAAG,SAAS;IAIrD;;;OAGG;IAEH,MAAM,CAAC,gBAAgB;CAGxB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -1,46 +0,0 @@
1
- /**
2
- * The `ArkynLogService` class manages the configuration for the arkyn flow.
3
- * It allows you to set and retrieve the arkyn configuration, including the traffic source ID,
4
- * user token, and API URL.
5
- */
6
- class ArkynLogService {
7
- static arkynConfig;
8
- /**
9
- * Sets the configuration for the arkyn. This method initializes the arkyn configuration
10
- * with the provided `arkynConfig` values. If the configuration has already been set,
11
- * the method will return early without making any changes.
12
- *
13
- * @param arkynConfig - An object containing the arkyn configuration properties.
14
- * @param arkynConfig.arkynTrafficSourceId - The key used to identify the arkyn.
15
- * @param arkynConfig.arkynUserToken - The user token for authenticating with the arkyn.
16
- * @param arkynConfig.arkynLogBaseApiUrl - (Optional) The API URL for the arkyn. If not provided,
17
- * a default URL will be used.
18
- */
19
- static setArkynConfig(arkynConfig) {
20
- if (!!this.arkynConfig)
21
- return;
22
- const { trafficSourceId, userToken, logBaseApiUrl } = arkynConfig;
23
- this.arkynConfig = {
24
- trafficSourceId,
25
- userToken,
26
- apiUrl: logBaseApiUrl || `http://95.216.190.158:8081/ingest-log`,
27
- };
28
- }
29
- /**
30
- * Retrieves the current arkyn configuration for the ArkynLogService.
31
- *
32
- * @returns {ArkynConfigProps | undefined} The current arkyn configuration if set,
33
- * or `undefined` if no configuration has been initialized.
34
- */
35
- static getArkynConfig() {
36
- return this.arkynConfig;
37
- }
38
- /**
39
- * Resets the arkyn configuration to `undefined`.
40
- * This method can be used to clear the current configuration.
41
- */
42
- static resetArkynConfig() {
43
- this.arkynConfig = undefined;
44
- }
45
- }
46
- export { ArkynLogService };
@@ -1,57 +0,0 @@
1
- /**
2
- * Service for managing HTTP debug configuration and behavior.
3
- *
4
- * This service provides functionality to configure how the `getCaller` function
5
- * identifies the actual caller in the stack trace by allowing specific files
6
- * to be ignored during stack trace analysis.
7
- *
8
- * @example
9
- * ```typescript
10
- * // Configure to ignore httpAdapter.ts in stack traces
11
- * HttpDebugService.setIgnoreFile("httpAdapter.ts");
12
- *
13
- * // Now when httpDebug is called from within httpAdapter.ts,
14
- * // it will show the actual caller (e.g., cart.ts) instead
15
- * ```
16
- */
17
- class DebugService {
18
- /**
19
- * The name of the file to ignore when analyzing the stack trace.
20
- * When set, the `getCaller` function will skip stack frames containing this file name.
21
- */
22
- static ignoreFiles = [];
23
- /**
24
- * Sets the file name to be ignored during stack trace analysis.
25
- *
26
- * This method configures the debug service to skip specific files when
27
- * determining the actual caller of a function. This is useful when you have
28
- * adapter or wrapper functions that you want to be transparent in the debug output.
29
- *
30
- * @param file - The name of the file to ignore in stack traces (e.g., "httpAdapter.ts")
31
- *
32
- * @example
33
- * ```typescript
34
- * // Ignore the HTTP adapter file so debug shows the actual business logic caller
35
- * DebugService.setIgnoreFile("httpAdapter.ts");
36
- * ```
37
- */
38
- static setIgnoreFile(file) {
39
- this.ignoreFiles.push(file);
40
- }
41
- /**
42
- * Clears all configured ignore files.
43
- *
44
- * This method resets the ignore file configuration, allowing all files to be
45
- * considered in stack trace analysis again.
46
- *
47
- * @example
48
- * ```typescript
49
- * // Clear all ignore file configurations
50
- * DebugService.clearIgnoreFiles();
51
- * ```
52
- */
53
- static clearIgnoreFiles() {
54
- this.ignoreFiles = [];
55
- }
56
- }
57
- export { DebugService };
@@ -1,17 +0,0 @@
1
- /**
2
- * Decodes an error message from a given request data object or response object.
3
- *
4
- * This function attempts to extract a meaningful error message from the provided
5
- * `data` or `response` objects by checking various properties in a specific order.
6
- * If no valid error message is found, it returns a default message: "Missing error message".
7
- *
8
- * @param data - The data object that may contain error information. It can have properties
9
- * such as `message`, `error`, or `error.message` that are checked for a string value.
10
- * @param response - The response object that may contain a `statusText` property
11
- * representing the HTTP status text.
12
- * @returns A string representing the decoded error message, or a default message
13
- * if no error message is found.
14
- */
15
- declare function decodeErrorMessageFromRequest(data: any, response: Response): string;
16
- export { decodeErrorMessageFromRequest };
17
- //# sourceMappingURL=decodeErrorMessageFromRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decodeErrorMessageFromRequest.d.ts","sourceRoot":"","sources":["../../src/services/decodeErrorMessageFromRequest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iBAAS,6BAA6B,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAkB5E;AAED,OAAO,EAAE,6BAA6B,EAAE,CAAC"}