@arkyn/server 3.0.1-beta.12 → 3.0.1-beta.121

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 (221) hide show
  1. package/README.md +368 -65
  2. package/dist/bundle.js +1518 -0
  3. package/dist/bundle.umd.cjs +5 -0
  4. package/dist/{api/arkynLogRequest.d.ts → http/api/_logRequest.d.ts} +22 -19
  5. package/dist/{api/arkynLogRequest.d.ts.map → http/api/_logRequest.d.ts.map} +1 -1
  6. package/dist/http/api/_logRequest.js +88 -0
  7. package/dist/http/api/_makeRequest.d.ts +61 -0
  8. package/dist/http/api/_makeRequest.d.ts.map +1 -0
  9. package/dist/{api/makeRequest.js → http/api/_makeRequest.js} +33 -20
  10. package/dist/http/api/deleteRequest.d.ts +17 -0
  11. package/dist/http/api/deleteRequest.d.ts.map +1 -0
  12. package/dist/http/api/deleteRequest.js +18 -0
  13. package/dist/http/api/getRequest.d.ts +16 -0
  14. package/dist/http/api/getRequest.d.ts.map +1 -0
  15. package/dist/http/api/getRequest.js +17 -0
  16. package/dist/http/api/patchRequest.d.ts +17 -0
  17. package/dist/http/api/patchRequest.d.ts.map +1 -0
  18. package/dist/http/api/patchRequest.js +18 -0
  19. package/dist/http/api/postRequest.d.ts +17 -0
  20. package/dist/http/api/postRequest.d.ts.map +1 -0
  21. package/dist/http/api/postRequest.js +18 -0
  22. package/dist/http/api/putRequest.d.ts +17 -0
  23. package/dist/http/api/putRequest.d.ts.map +1 -0
  24. package/dist/http/api/putRequest.js +18 -0
  25. package/dist/http/badResponses/_badResponse.d.ts +22 -0
  26. package/dist/http/badResponses/_badResponse.d.ts.map +1 -0
  27. package/dist/http/badResponses/_badResponse.js +51 -0
  28. package/dist/http/badResponses/badGateway.d.ts +6 -9
  29. package/dist/http/badResponses/badGateway.d.ts.map +1 -1
  30. package/dist/http/badResponses/badGateway.js +12 -14
  31. package/dist/http/badResponses/badRequest.d.ts +6 -9
  32. package/dist/http/badResponses/badRequest.d.ts.map +1 -1
  33. package/dist/http/badResponses/badRequest.js +12 -14
  34. package/dist/http/badResponses/conflict.d.ts +6 -9
  35. package/dist/http/badResponses/conflict.d.ts.map +1 -1
  36. package/dist/http/badResponses/conflict.js +12 -14
  37. package/dist/http/badResponses/forbidden.d.ts +6 -9
  38. package/dist/http/badResponses/forbidden.d.ts.map +1 -1
  39. package/dist/http/badResponses/forbidden.js +12 -14
  40. package/dist/http/badResponses/notFound.d.ts +6 -9
  41. package/dist/http/badResponses/notFound.d.ts.map +1 -1
  42. package/dist/http/badResponses/notFound.js +12 -14
  43. package/dist/http/badResponses/notImplemented.d.ts +6 -9
  44. package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
  45. package/dist/http/badResponses/notImplemented.js +12 -14
  46. package/dist/http/badResponses/serverError.d.ts +6 -9
  47. package/dist/http/badResponses/serverError.d.ts.map +1 -1
  48. package/dist/http/badResponses/serverError.js +12 -14
  49. package/dist/http/badResponses/unauthorized.d.ts +4 -7
  50. package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
  51. package/dist/http/badResponses/unauthorized.js +10 -12
  52. package/dist/http/badResponses/unprocessableEntity.d.ts +15 -19
  53. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
  54. package/dist/http/badResponses/unprocessableEntity.js +18 -21
  55. package/dist/http/successResponses/_successResponse.d.ts +33 -0
  56. package/dist/http/successResponses/_successResponse.d.ts.map +1 -0
  57. package/dist/http/successResponses/_successResponse.js +66 -0
  58. package/dist/http/successResponses/created.d.ts +9 -19
  59. package/dist/http/successResponses/created.d.ts.map +1 -1
  60. package/dist/http/successResponses/created.js +16 -25
  61. package/dist/http/successResponses/found.d.ts +10 -23
  62. package/dist/http/successResponses/found.d.ts.map +1 -1
  63. package/dist/http/successResponses/found.js +17 -29
  64. package/dist/http/successResponses/noContent.d.ts +6 -13
  65. package/dist/http/successResponses/noContent.d.ts.map +1 -1
  66. package/dist/http/successResponses/noContent.js +12 -17
  67. package/dist/http/successResponses/success.d.ts +9 -19
  68. package/dist/http/successResponses/success.d.ts.map +1 -1
  69. package/dist/http/successResponses/success.js +16 -25
  70. package/dist/http/successResponses/updated.d.ts +9 -19
  71. package/dist/http/successResponses/updated.d.ts.map +1 -1
  72. package/dist/http/successResponses/updated.js +16 -25
  73. package/dist/index.d.ts +19 -10
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +22 -13
  76. package/dist/services/apiService.d.ts +63 -0
  77. package/dist/services/apiService.d.ts.map +1 -0
  78. package/dist/services/apiService.js +158 -0
  79. package/dist/services/debugService.d.ts +69 -0
  80. package/dist/services/debugService.d.ts.map +1 -0
  81. package/dist/services/debugService.js +114 -0
  82. package/dist/services/logMapperService.d.ts +86 -0
  83. package/dist/services/logMapperService.d.ts.map +1 -0
  84. package/dist/services/logMapperService.js +68 -0
  85. package/dist/services/logService.d.ts +38 -0
  86. package/dist/services/logService.d.ts.map +1 -0
  87. package/dist/services/logService.js +40 -0
  88. package/dist/{services → utilities}/decodeRequestBody.d.ts +3 -4
  89. package/dist/utilities/decodeRequestBody.d.ts.map +1 -0
  90. package/dist/{services → utilities}/decodeRequestBody.js +5 -5
  91. package/dist/{services/decodeErrorMessageFromRequest.d.ts → utilities/decodeRequestErrorMessage.d.ts} +6 -6
  92. package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -0
  93. package/dist/{services/decodeErrorMessageFromRequest.js → utilities/decodeRequestErrorMessage.js} +5 -5
  94. package/dist/utilities/errorHandler.d.ts +50 -0
  95. package/dist/utilities/errorHandler.d.ts.map +1 -0
  96. package/dist/{services → utilities}/errorHandler.js +34 -28
  97. package/dist/utilities/flushDebugLogs.d.ts +46 -0
  98. package/dist/utilities/flushDebugLogs.d.ts.map +1 -0
  99. package/dist/utilities/flushDebugLogs.js +59 -0
  100. package/dist/utilities/formAsyncParse.d.ts +59 -0
  101. package/dist/utilities/formAsyncParse.d.ts.map +1 -0
  102. package/dist/utilities/formAsyncParse.js +58 -0
  103. package/dist/{services → utilities}/formParse.d.ts +6 -6
  104. package/dist/utilities/formParse.d.ts.map +1 -0
  105. package/dist/{services → utilities}/formParse.js +10 -8
  106. package/dist/{services → utilities}/getScopedParams.d.ts +3 -4
  107. package/dist/utilities/getScopedParams.d.ts.map +1 -0
  108. package/dist/{services → utilities}/getScopedParams.js +4 -4
  109. package/dist/utilities/schemaValidator.d.ts +146 -0
  110. package/dist/utilities/schemaValidator.d.ts.map +1 -0
  111. package/dist/utilities/schemaValidator.js +191 -0
  112. package/dist/validations/validateCep.d.ts +19 -0
  113. package/dist/validations/validateCep.d.ts.map +1 -0
  114. package/dist/validations/validateCep.js +27 -0
  115. package/dist/validations/validateCnpj.d.ts +21 -0
  116. package/dist/validations/validateCnpj.d.ts.map +1 -0
  117. package/dist/validations/validateCnpj.js +59 -0
  118. package/dist/validations/validateCpf.d.ts +23 -0
  119. package/dist/validations/validateCpf.d.ts.map +1 -0
  120. package/dist/validations/validateCpf.js +61 -0
  121. package/dist/validations/validateDate.d.ts +27 -0
  122. package/dist/validations/validateDate.d.ts.map +1 -0
  123. package/dist/validations/validateDate.js +55 -0
  124. package/dist/validations/validateEmail.d.ts +21 -0
  125. package/dist/validations/validateEmail.d.ts.map +1 -0
  126. package/dist/validations/validateEmail.js +111 -0
  127. package/dist/validations/validatePassword.d.ts +20 -0
  128. package/dist/validations/validatePassword.d.ts.map +1 -0
  129. package/dist/validations/validatePassword.js +34 -0
  130. package/dist/validations/validatePhone.d.ts +28 -0
  131. package/dist/validations/validatePhone.d.ts.map +1 -0
  132. package/dist/validations/validatePhone.js +44 -0
  133. package/dist/validations/validateRg.d.ts +21 -0
  134. package/dist/validations/validateRg.d.ts.map +1 -0
  135. package/dist/validations/validateRg.js +31 -0
  136. package/package.json +34 -18
  137. package/dist/api/arkynLogRequest.js +0 -82
  138. package/dist/api/deleteRequest.d.ts +0 -13
  139. package/dist/api/deleteRequest.d.ts.map +0 -1
  140. package/dist/api/deleteRequest.js +0 -14
  141. package/dist/api/getRequest.d.ts +0 -12
  142. package/dist/api/getRequest.d.ts.map +0 -1
  143. package/dist/api/getRequest.js +0 -13
  144. package/dist/api/makeRequest.d.ts +0 -38
  145. package/dist/api/makeRequest.d.ts.map +0 -1
  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/mapper/arkynLogRequestMapper.d.ts +0 -30
  162. package/dist/mapper/arkynLogRequestMapper.d.ts.map +0 -1
  163. package/dist/mapper/arkynLogRequestMapper.js +0 -44
  164. package/dist/services/decodeErrorMessageFromRequest.d.ts.map +0 -1
  165. package/dist/services/decodeRequestBody.d.ts.map +0 -1
  166. package/dist/services/errorHandler.d.ts +0 -44
  167. package/dist/services/errorHandler.d.ts.map +0 -1
  168. package/dist/services/formParse.d.ts.map +0 -1
  169. package/dist/services/getCaller.d.ts +0 -17
  170. package/dist/services/getCaller.d.ts.map +0 -1
  171. package/dist/services/getCaller.js +0 -65
  172. package/dist/services/getScopedParams.d.ts.map +0 -1
  173. package/dist/services/httpDebug.d.ts +0 -35
  174. package/dist/services/httpDebug.d.ts.map +0 -1
  175. package/dist/services/httpDebug.js +0 -52
  176. package/dist/services/measureRouteExecution.d.ts +0 -3
  177. package/dist/services/measureRouteExecution.d.ts.map +0 -1
  178. package/dist/services/measureRouteExecution.js +0 -24
  179. package/dist/services/schemaValidator.d.ts +0 -13
  180. package/dist/services/schemaValidator.d.ts.map +0 -1
  181. package/dist/services/schemaValidator.js +0 -51
  182. package/dist/types/ApiResponseDTO.d.ts +0 -17
  183. package/dist/types/ApiResponseDTO.d.ts.map +0 -1
  184. package/dist/types/ApiResponseDTO.js +0 -1
  185. package/src/api/arkynLogRequest.ts +0 -118
  186. package/src/api/deleteRequest.ts +0 -22
  187. package/src/api/getRequest.ts +0 -20
  188. package/src/api/makeRequest.ts +0 -118
  189. package/src/api/patchRequest.ts +0 -22
  190. package/src/api/postRequest.ts +0 -22
  191. package/src/api/putRequest.ts +0 -22
  192. package/src/config/apiInstance.ts +0 -148
  193. package/src/config/arkynLogInstance.ts +0 -70
  194. package/src/http/badResponses/badGateway.ts +0 -63
  195. package/src/http/badResponses/badRequest.ts +0 -63
  196. package/src/http/badResponses/conflict.ts +0 -63
  197. package/src/http/badResponses/forbidden.ts +0 -63
  198. package/src/http/badResponses/notFound.ts +0 -63
  199. package/src/http/badResponses/notImplemented.ts +0 -63
  200. package/src/http/badResponses/serverError.ts +0 -63
  201. package/src/http/badResponses/unauthorized.ts +0 -63
  202. package/src/http/badResponses/unprocessableEntity.ts +0 -79
  203. package/src/http/successResponses/created.ts +0 -64
  204. package/src/http/successResponses/found.ts +0 -67
  205. package/src/http/successResponses/noContent.ts +0 -42
  206. package/src/http/successResponses/success.ts +0 -64
  207. package/src/http/successResponses/updated.ts +0 -64
  208. package/src/index.ts +0 -31
  209. package/src/mapper/arkynLogRequestMapper.ts +0 -73
  210. package/src/services/decodeErrorMessageFromRequest.ts +0 -36
  211. package/src/services/decodeRequestBody.ts +0 -43
  212. package/src/services/errorHandler.ts +0 -99
  213. package/src/services/formParse.ts +0 -83
  214. package/src/services/getCaller.ts +0 -82
  215. package/src/services/getScopedParams.ts +0 -43
  216. package/src/services/httpDebug.ts +0 -61
  217. package/src/services/measureRouteExecution.ts +0 -31
  218. package/src/services/schemaValidator.ts +0 -66
  219. package/src/types/ApiResponseDTO.ts +0 -19
  220. package/tsconfig.json +0 -21
  221. package/vitest.config.ts +0 -5
@@ -0,0 +1,5 @@
1
+ (function(i,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("zod"),require("@arkyn/shared"),require("node:dns"),require("@arkyn/templates")):typeof define=="function"&&define.amd?define(["exports","zod","@arkyn/shared","node:dns","@arkyn/templates"],h):(i=typeof globalThis<"u"?globalThis:i||self,h(i["@arkyn/server"]={},null,i.shared,i.dns,i.templates))})(this,function(i,h,d,D,L){"use strict";var js=Object.defineProperty;var ws=(i,h,d)=>h in i?js(i,h,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[h]=d;var l=(i,h,d)=>ws(i,typeof h!="symbol"?h+"":h,d);const z={};class x{static setIgnoreFile(s){this.ignoreFiles.push(s)}static clearIgnoreFiles(){this.ignoreFiles=[]}static getCaller(){const s=process.cwd(),r=(new Error().stack||"").split(`
2
+ `).map(g=>g.trim());let o=2;for(;o<r.length&&(r[o].includes("node:internal")||r[o].includes("/node_modules/"));)o++;if(this.ignoreFiles.length>0)for(;o<r.length&&this.ignoreFiles.some(g=>r[o].includes(g));)o++;const u=r[o]||"";let c="Unknown function",a="Unknown caller";const f=u.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);if(f)c=f[1],a=f[2];else{const g=u.match(/at\s+(.+)/);if(g){a=g[1];const R=a.match(/at\s+([^(\s]+)\s+/);R&&R[1]!=="new"&&(c=R[1])}}a.includes("(")&&(a=a.substring(a.indexOf("(")+1,a.lastIndexOf(")"))),a=a.split(":").slice(0,-2).join(":");try{a=z.relative(s,a)}catch{}return{functionName:c,callerInfo:a}}}l(x,"ignoreFiles",[]);function y(e){var t;if(process.env.NODE_ENV==="development"||((t=process.env)==null?void 0:t.DEBUG_MODE)==="true"){const o=`${{yellow:"\x1B[33m",cyan:"\x1B[36m",red:"\x1B[31m",green:"\x1B[32m"}[e.scheme]}[${e.name}]\x1B[0m`;let u=`
3
+ `;e.debugs.forEach(c=>{u+=`${o} ${c.trim()}
4
+ `}),console.log(u)}}class m{constructor(){l(this,"_cause");l(this,"_name","BadResponse");l(this,"_status",500);l(this,"_statusText","Unknown error")}get cause(){return this._cause}set cause(s){this._cause=s}get name(){return this._name}set name(s){this._name=s}get status(){return this._status}set status(s){this._status=s}get statusText(){return this._statusText}set statusText(s){this._statusText=s}onDebug(){const s=[],{callerInfo:t,functionName:n}=x.getCaller();s.push(`Caller Function: ${n}`),s.push(`Caller Location: ${t}`),this._statusText&&s.push(`Message: ${this._statusText}`),this._cause&&s.push(`Cause: ${JSON.stringify(this._cause)}`),y({scheme:"red",name:this._name,debugs:s})}makeBody(){return{name:this._name,message:this._statusText,cause:this._cause}}}class P extends m{constructor(s,t){super(),this.name="BadGateway",this.status=502,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class S extends m{constructor(s,t){super(),this.name="BadRequest",this.status=400,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class $ extends m{constructor(s,t){super(),this.name="Conflict",this.status=409,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class B extends m{constructor(s,t){super(),this.name="Forbidden",this.status=403,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class k extends m{constructor(s,t){super(),this.name="NotFound",this.status=404,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class O extends m{constructor(s,t){super(),this.name="NotImplemented",this.status=501,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class v extends m{constructor(s,t){super(),this.name="ServerError",this.status=500,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class j extends m{constructor(s,t){super(),this.name="Unauthorized",this.status=401,this.statusText=s,this.cause=t?JSON.stringify(t):void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class N extends m{constructor(s){super(),this.name="UnprocessableEntity",this.status=422,this.statusText=s.message||"Unprocessable entity",this.cause={data:s.data,fieldErrors:s.fieldErrors,fields:s.fields},this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.makeBody()),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.makeBody(),s)}}class T{constructor(){l(this,"_body",null);l(this,"_name","SuccessResponse");l(this,"_status",200);l(this,"_statusText","OK")}get body(){return this._body}set body(s){this._body=s??null}get name(){return this._name}set name(s){this._name=s}get status(){return this._status}set status(s){this._status=s}get statusText(){return this._statusText}set statusText(s){this._statusText=s}onDebug(s){const t=[],{callerInfo:n,functionName:r}=x.getCaller();t.push(`Caller Function: ${r}`),t.push(`Caller Location: ${n}`),this.statusText&&t.push(`Message: ${this.statusText}`),s&&t.push(`Body: ${JSON.stringify(s)}`),y({scheme:"red",name:this.name,debugs:t})}makeBody(){return{name:this.name,message:this.statusText,body:this.body}}}class w extends T{constructor(s,t){super(),this.name="Created",this.status=201,this.statusText=s,this.body=t||void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class J extends T{constructor(s,t){super(),this.name="Found",this.status=302,this.statusText=s,this.body=t||void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class C extends T{constructor(s){super(),this.name="NoContent",this.status=204,this.statusText=s,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(null,s)}}class _ extends T{constructor(s,t){super(),this.name="Success",this.status=200,this.statusText=s,this.body=t||void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class I extends T{constructor(s,t){super(),this.name="Updated",this.status=200,this.statusText=s,this.body=t||void 0,this.onDebug()}toResponse(){const s={headers:{"Content-Type":"application/json"},status:this.status,statusText:this.statusText};return new Response(JSON.stringify(this.body),s)}toJson(){const s={status:this.status,statusText:this.statusText};return Response.json(this.body,s)}}class M{static mapHeaders(s){return s instanceof Headers?Object.fromEntries(s.entries()):typeof s=="object"?Object.entries(s).reduce((t,[n,r])=>(typeof r=="string"?t[n]=r:Array.isArray(r)?t[n]=r.join(", "):t[n]=JSON.stringify(r),t),{}):{}}static mapQueryParams(s){const t={};return s.forEach((n,r)=>t[r]=n),t}static handle(s){return{rawUrl:s.rawUrl,status:s.status,method:s.method,token:null,elapsedTime:s.elapsedTime,requestHeaders:this.mapHeaders(s.requestHeaders),requestBody:s.requestBody||null,queryParams:{...this.mapQueryParams(s.queryParams),...s.urlParams},responseHeaders:this.mapHeaders(s.responseHeaders),responseBody:s.responseBody||null}}}class E{static setConfig(s){if(this.config)return;const{trafficSourceId:t,userToken:n,logBaseApiUrl:r}=s,u=`${r||"http://95.216.190.158:8081"}/ingest-log`;this.config={trafficSourceId:t,userToken:n,apiUrl:u}}static getConfig(){return this.config}static resetConfig(){this.config=void 0}}l(E,"config");async function V(e){const s=E.getConfig();if(!s)return;const{userToken:t,apiUrl:n,trafficSourceId:r}=s,{elapsedTime:o,method:u,queryParams:c,requestBody:a,requestHeaders:f,responseBody:g,responseHeaders:R,status:$s,token:Js,rawUrl:Bs}=e;if(process.env.NODE_ENV!=="development")try{const p=new URL(Bs);let F="https";p.protocol==="http:"&&(F="http");const ks=JSON.stringify({domainUrl:p.protocol+"//"+p.host,pathnameUrl:p.pathname,trafficSourceId:r,status:$s,protocol:F,method:u.toLowerCase(),trafficUserId:null,elapsedTime:o,requestHeaders:JSON.stringify(f),requestBody:JSON.stringify(a),queryParams:JSON.stringify(c),responseHeaders:JSON.stringify(R),responseBody:JSON.stringify(g)}),Os={"Content-Type":"application/json",Authorization:`Bearer ${t}`};await fetch(n,{method:"POST",body:ks,headers:Os})}catch(p){y({debugs:[`Error sending request: ${p}`],name:"LogError",scheme:"red"})}}async function b(e){let s=e.url;e.urlParams&&Object.entries(e.urlParams).forEach(([n,r])=>{s=s.replaceAll(`:${n}`,r)});const t={POST:"Resource created successfully",PUT:"Resource updated successfully",DELETE:"Resource deleted successfully",PATCH:"Resource patched successfully",GET:"Request successful"};try{const n=performance.now(),r={...e.headers,"Content-Type":"application/json"},o=await fetch(s,{headers:r,method:e.method,body:e.body?JSON.stringify(e.body):void 0}),u=performance.now()-n,c=o.status;let a=null;try{a=await o.json()}catch{a=null}const f=M.handle({elapsedTime:u,method:e.method,queryParams:new URL(s).searchParams,requestHeaders:r,requestBody:e.body,responseBody:a,responseHeaders:o.headers,status:c,rawUrl:e.url,urlParams:e.urlParams});return V(f),o.ok?{success:!0,status:c,message:(a==null?void 0:a.message)||t[e.method],response:a,cause:null}:{success:!1,status:c,message:(a==null?void 0:a.message)||o.statusText||"Request failed",response:a,cause:null}}catch(n){return y({debugs:[`Network error or request failed: ${n}`],name:"MakeRequestError",scheme:"red"}),{success:!1,status:0,message:"Network error or request failed",response:null,cause:n instanceof Error?n.message:String(n)}}}async function Z(e){return b({method:"DELETE",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}async function G(e){return b({method:"GET",url:e.url,urlParams:e.urlParams,headers:e.headers})}async function W(e){return b({method:"PATCH",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}async function Y(e){return b({method:"POST",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}async function K(e){return b({method:"PUT",url:e.url,urlParams:e.urlParams,headers:e.headers,body:e.body})}class Q{constructor(s){l(this,"baseUrl");l(this,"baseHeaders");l(this,"baseToken");l(this,"enableDebug");this.baseUrl=s.baseUrl,this.baseHeaders=s.baseHeaders||void 0,this.baseToken=s.baseToken||void 0,this.enableDebug=s.enableDebug||!1}onDebug(s,t,n){if(this.enableDebug){const r=[],o=u=>JSON.stringify(u,null,2);r.push(`Base URL: ${this.baseUrl}`),r.push(`Endpoint: ${s}`),r.push(`Status/Method: ${t} => ${n.status}`),r.push(`Message: ${n.message}`),n.headers&&r.push(`Headers: ${o(n.headers)}`),n.body&&r.push(`Body: ${o(n.body)}`),y({debugs:r,name:"ApiDebug",scheme:"yellow"})}}generateHeaders(s,t){let n={};return this.baseToken&&(n={Authorization:`Bearer ${this.baseToken}`}),this.baseHeaders&&(n={...n,...this.baseHeaders}),s&&(n={...n,...s}),t&&(n={...n,Authorization:`Bearer ${t}`}),n}async get(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=await G({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n});return this.onDebug(s,"get",{headers:n,message:r.message,status:r.status}),r}async post(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await Y({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"post",{headers:n,body:r,message:o.message,status:o.status}),o}async put(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await K({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"put",{headers:n,body:r,message:o.message,status:o.status}),o}async patch(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await W({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"patch",{headers:n,body:r,message:o.message,status:o.status}),o}async delete(s,t){const n=this.generateHeaders((t==null?void 0:t.headers)||{},t==null?void 0:t.token),r=t==null?void 0:t.body,o=await Z({url:this.baseUrl+s,urlParams:(t==null?void 0:t.urlParams)||{},headers:n,body:r});return this.onDebug(s,"delete",{headers:n,body:r,message:o.message,status:o.status}),o}}async function X(e){let s;const t=await e.arrayBuffer(),n=new TextDecoder().decode(t);try{s=JSON.parse(n)}catch{try{if(n.includes("=")){const o=new URLSearchParams(n);s=Object.fromEntries(o.entries())}else throw new S("Invalid URLSearchParams format")}catch{throw new S("Failed to extract data from request")}}return s}function ss(e,s){var t,n,r;return e!=null&&e.message&&typeof(e==null?void 0:e.message)=="string"?e==null?void 0:e.message:e!=null&&e.error&&typeof(e==null?void 0:e.error)=="string"?e==null?void 0:e.error:(t=e==null?void 0:e.error)!=null&&t.message&&typeof((n=e==null?void 0:e.error)==null?void 0:n.message)=="string"?(r=e==null?void 0:e.error)==null?void 0:r.message:s!=null&&s.statusText&&typeof(s==null?void 0:s.statusText)=="string"?s==null?void 0:s.statusText:"Missing error message"}function es(e){switch(!0){case e instanceof Response:return e;case e instanceof J:return e.toResponse();case e instanceof w:return e.toResponse();case e instanceof I:return e.toResponse();case e instanceof _:return e.toResponse();case e instanceof C:return e.toResponse()}switch(!0){case e instanceof P:return e.toResponse();case e instanceof S:return e.toResponse();case e instanceof $:return e.toResponse();case e instanceof B:return e.toResponse();case e instanceof k:return e.toResponse();case e instanceof O:return e.toResponse();case e instanceof v:return e.toResponse();case e instanceof j:return e.toResponse();case e instanceof N:return e.toResponse()}return new v("Server error",e).toResponse()}async function U([e,s]){const t=await s.safeParseAsync(e);if(t.success===!1){const n=Object.fromEntries(t.error.issues.map(r=>[r.path.join("."),r.message]));return{success:t.success,fieldErrors:n,fields:e}}else return{success:t.success,data:t.data}}function q([e,s]){const t=s.safeParse(e);if(t.success===!1){const n=Object.fromEntries(t.error.issues.map(r=>[r.path.join("."),r.message]));return{success:t.success,fieldErrors:n,fields:e}}else return{success:t.success,data:t.data}}function ts(e,s=""){const t=new URL(e.url);if(s==="")return t.searchParams;const n=Array.from(t.searchParams.entries()).filter(([r])=>r.startsWith(`${s}:`)).map(([r,o])=>[r.replace(`${s}:`,""),o]);return new URLSearchParams(n)}function ns(e){const s="Error validating:",t=e.issues.map(({path:n,message:r})=>`-> ${n.join(".")}: ${r}`);return[s,...t].join(`
5
+ `)}class rs{constructor(s){this.schema=s}isValid(s){return this.schema.safeParse(s).success}safeValidate(s){return this.schema.safeParse(s)}validate(s){try{return this.schema.parse(s)}catch(t){throw new v(ns(t))}}formValidate(s,t){const n=q([s,this.schema]);if(!n.success){const r=Object.keys(n.fieldErrors)[0];throw new N({fields:n.fields,fieldErrors:n.fieldErrors,data:{scrollTo:r},message:t})}return n.data}async formAsyncValidate(s,t){const n=await U([s,this.schema]);if(!n.success){const r=Object.keys(n.fieldErrors)[0];throw new N({fields:n.fields,fieldErrors:n.fieldErrors,data:{scrollTo:r},message:t})}return n.data}}function os(e){if(!(/^\d{5}-\d{3}$/.test(e)||/^\d{8}$/.test(e)))return!1;const t=d.removeNonNumeric(e),n=8,r=/^\d{8}$/.test(t);return t.length===n&&r}function is(e){return e.length!==14}function as(e){const[s]=e;return[...e].every(t=>t===s)}function A(e,s){let t=0;for(let r=0;r<s.length;r++)t+=parseInt(e[r])*s[r];const n=t%11;return n<2?0:11-n}function us(e){return e.slice(12)}function cs(e){if(!e||e.length>18||e.length<14||/\s/.test(e))return!1;const t=d.removeNonNumeric(e);if(is(t)||as(t))return!1;const n=t.slice(0,12),r=A(n,[5,4,3,2,9,8,7,6,5,4,3,2]),o=A(n+r,[6,5,4,3,2,9,8,7,6,5,4,3,2]);return us(t)===`${r}${o}`}function ls(e){return e.length!==11}function hs(e){const[s]=e;return[...e].every(t=>t===s)}function H(e,s){let t=0;for(const r of e)s>1&&(t+=parseInt(r)*s--);const n=t%11;return n<2?0:11-n}function fs(e){return e.slice(9)}function ds(e){if(!e||e.length>14||e.length<11||/\s/.test(e))return!1;const t=d.removeNonNumeric(e);if(ls(t)||hs(t))return!1;const n=H(t,10),r=H(t,11);return fs(t)===`${n}${r}`}function ms(e,s){const t=(s==null?void 0:s.inputFormat)||"brazilianDate",n=(s==null?void 0:s.minYear)||1900,r=(s==null?void 0:s.maxYear)||3e3,o=new d.ValidateDateService;o.validateInputFormat(t);let u,c,a;const f=e.split(/[-/]/).map(Number);if(f.length!==3)return!1;try{switch(t){case"brazilianDate":[u,c,a]=f,o.validateDateParts(a,c,u);break;case"isoDate":[c,u,a]=f,o.validateDateParts(a,c,u);break;case"timestamp":[a,c,u]=f,o.validateDateParts(a,c,u);break}return!(a<n||a>r)}catch{return!1}}function gs(e){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)}function ys(e){return!(e.length===0||e.length>64||e.startsWith(".")||e.endsWith(".")||e.includes("..")||!/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(e))}function ps(e){return!(e.length===0||e.length>63||e.startsWith("-")||e.endsWith("-")||!/^[a-zA-Z0-9-]+$/.test(e))}function Ts(e){if(e.length===0||e.length>253||e.startsWith(".")||e.endsWith(".")||e.startsWith("-")||e.endsWith("-"))return!1;const s=e.split(".");if(s.length<2)return!1;for(const n of s)if(!ps(n))return!1;const t=s[s.length-1];return!(t.length<2||!/^[a-zA-Z]+$/.test(t))}function bs(e){const s=e.split("@");if(s.length!==2)return!1;const[t,n]=s;return!(!ys(t)||!Ts(n))}function Rs(e){const s=e.split("@");return s.length===2?s[1].toLowerCase():null}const xs=["MX","A","AAAA"];async function Ss(e,s){var t;try{return await((t=D==null?void 0:D.promises)==null?void 0:t.resolve(e,s)),!0}catch{return!1}}async function vs(e){for(const s of xs)if(await Ss(e,s))return!0;return!1}async function Ns(e){if(!e||typeof e!="string")return!1;const s=e.trim();if(!gs(s)||!bs(s))return!1;const t=Rs(s);return t?await vs(t):!1}function Ds(e){if(!e)return!1;const s=e.length>=8,t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/\d/.test(e),o=/[!@#$%^&*(),.?":;{}|<>_\-+=~`[\]\\\/]/.test(e);return[s,t,n,r,o].every(u=>u)}function Es(e){for(const s of L.countries){const t=s.code,n=s.prefix?`-${s.prefix}`:"",r=s.mask.replace(/[^_]/g,"").length;if(s.iso==="BR"){if(new RegExp(`^\\${t} \\d{2}9?\\d{8}$`).test(e))return!0;continue}if(new RegExp(`^\\${t}${n} \\d{${r}}$`).test(e))return!0}return!1}function Ps(e){if(!e||!/^[0-9a-zA-Z.-]+$/.test(e))return!1;const t=e.replace(/[^a-zA-Z0-9]/g,"");return t.length<7||t.length>9?!1:/^[0-9]{7,8}[0-9Xx]?$/.test(t)}i.ApiService=Q,i.BadGateway=P,i.BadRequest=S,i.Conflict=$,i.Created=w,i.DebugService=x,i.Forbidden=B,i.Found=J,i.LogService=E,i.NoContent=C,i.NotFound=k,i.NotImplemented=O,i.SchemaValidator=rs,i.ServerError=v,i.Success=_,i.Unauthorized=j,i.UnprocessableEntity=N,i.Updated=I,i.decodeRequestBody=X,i.decodeRequestErrorMessage=ss,i.errorHandler=es,i.flushDebugLogs=y,i.formAsyncParse=U,i.formParse=q,i.getScopedParams=ts,i.validateCep=os,i.validateCnpj=cs,i.validateCpf=ds,i.validateDate=ms,i.validateEmail=Ns,i.validatePassword=Ds,i.validatePhone=Es,i.validateRg=Ps,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
@@ -13,25 +13,28 @@ type ConfigProps = {
13
13
  /**
14
14
  * Sends a request to the inbox flow API with the provided configuration.
15
15
  *
16
- * @param config - The configuration object for the request.
17
- * @param config.rawUrl - The raw URL of the request.
18
- * @param config.status - The HTTP status code associated with the request.
19
- * @param config.method - The HTTP method used for the request. Can be "POST", "GET", "PUT", "DELETE", or "PATCH".
20
- * @param config.token - The authentication token for the request.
21
- * @param config.elapsedTime - The elapsed time for the request in milliseconds.
22
- * @param config.requestHeaders - The headers sent with the request.
23
- * @param config.requestBody - The body of the request, if applicable.
24
- * @param config.queryParams - The query parameters for the request.
25
- * @param config.responseHeaders - The headers received in the response.
26
- * @param config.responseBody - The body of the response received.
27
- *
28
- * @remarks
29
- * - This function retrieves the inbox flow configuration using `InboxFlowInstance.getInboxConfig()`.
16
+ * - This function retrieves the inbox flow configuration using `LogService.getConfig()`.
30
17
  * - If the configuration is not available, the function will return early without performing any action.
31
18
  * - In a development environment (`NODE_ENV === "development"`), the function will also return early.
32
19
  * - The request is sent as a POST request to the inbox API URL with the provided configuration details.
33
20
  * - If an error occurs during the request, it will be logged using the `httpDebug` service.
34
21
  *
22
+ * @param {ConfigProps} config - The configuration object for the request.
23
+ * @param {string} config.rawUrl - The raw URL of the request.
24
+ * @param {number} config.status - The HTTP status code associated with the request.
25
+ * @param {"GET" | "POST" | "PUT" | "DELETE" | "PATCH"} config.method - The HTTP method used for the request. Can be "POST", "GET", "PUT", "DELETE", or "PATCH".
26
+ * @param {string | null} config.token - The authentication token for the request.
27
+ * @param {number} config.elapsedTime - The elapsed time for the request in milliseconds.
28
+ * @param {Record<string, string>} config.requestHeaders - The headers sent with the request.
29
+ * @param {Record<string, string>} config.requestBody - The body of the request, if applicable.
30
+ * @param {Record<string, string>} config.queryParams - The query parameters for the request.
31
+ * @param {Record<string, string>} config.responseHeaders - The headers received in the response.
32
+ * @param {Record<string, string>} config.responseBody - The body of the response received.
33
+ *
34
+ * @remarks
35
+ *
36
+ * @returns {Promise<void>} A promise that resolves when the request is complete.
37
+ *
35
38
  * @example
36
39
  * ```typescript
37
40
  * const config = {
@@ -39,7 +42,7 @@ type ConfigProps = {
39
42
  * status: 200,
40
43
  * method: "GET",
41
44
  * token: "auth-token-123",
42
- * elapsedTime: "150ms",
45
+ * elapsedTime: 150,
43
46
  * requestHeaders: { "Accept": "application/json", "Authorization": "Bearer token123" },
44
47
  * requestBody: {},
45
48
  * queryParams: { "page": "1", "limit": "10" },
@@ -47,9 +50,9 @@ type ConfigProps = {
47
50
  * responseBody: { "data": "example response" }
48
51
  * };
49
52
  *
50
- * await arkynLogRequest(config);
53
+ * await logRequest(config);
51
54
  * ```
52
55
  */
53
- declare function arkynLogRequest(config: ConfigProps): Promise<void>;
54
- export { arkynLogRequest };
55
- //# sourceMappingURL=arkynLogRequest.d.ts.map
56
+ declare function logRequest(config: ConfigProps): Promise<void>;
57
+ export { logRequest };
58
+ //# sourceMappingURL=_logRequest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arkynLogRequest.d.ts","sourceRoot":"","sources":["../../src/api/arkynLogRequest.ts"],"names":[],"mappings":"AAGA,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,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,iBAAe,eAAe,CAAC,MAAM,EAAE,WAAW,iBA0DjD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"_logRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/_logRequest.ts"],"names":[],"mappings":"AAGA,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,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,iBAAe,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAwD5D;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,88 @@
1
+ import { flushDebugLogs } from "../..";
2
+ import { LogService } from "../../services/logService";
3
+ /**
4
+ * Sends a request to the inbox flow API with the provided configuration.
5
+ *
6
+ * - This function retrieves the inbox flow configuration using `LogService.getConfig()`.
7
+ * - If the configuration is not available, the function will return early without performing any action.
8
+ * - In a development environment (`NODE_ENV === "development"`), the function will also return early.
9
+ * - The request is sent as a POST request to the inbox API URL with the provided configuration details.
10
+ * - If an error occurs during the request, it will be logged using the `httpDebug` service.
11
+ *
12
+ * @param {ConfigProps} config - The configuration object for the request.
13
+ * @param {string} config.rawUrl - The raw URL of the request.
14
+ * @param {number} config.status - The HTTP status code associated with the request.
15
+ * @param {"GET" | "POST" | "PUT" | "DELETE" | "PATCH"} config.method - The HTTP method used for the request. Can be "POST", "GET", "PUT", "DELETE", or "PATCH".
16
+ * @param {string | null} config.token - The authentication token for the request.
17
+ * @param {number} config.elapsedTime - The elapsed time for the request in milliseconds.
18
+ * @param {Record<string, string>} config.requestHeaders - The headers sent with the request.
19
+ * @param {Record<string, string>} config.requestBody - The body of the request, if applicable.
20
+ * @param {Record<string, string>} config.queryParams - The query parameters for the request.
21
+ * @param {Record<string, string>} config.responseHeaders - The headers received in the response.
22
+ * @param {Record<string, string>} config.responseBody - The body of the response received.
23
+ *
24
+ * @remarks
25
+ *
26
+ * @returns {Promise<void>} A promise that resolves when the request is complete.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const config = {
31
+ * rawUrl: "https://example.com/api/data",
32
+ * status: 200,
33
+ * method: "GET",
34
+ * token: "auth-token-123",
35
+ * elapsedTime: 150,
36
+ * requestHeaders: { "Accept": "application/json", "Authorization": "Bearer token123" },
37
+ * requestBody: {},
38
+ * queryParams: { "page": "1", "limit": "10" },
39
+ * responseHeaders: { "Content-Type": "application/json" },
40
+ * responseBody: { "data": "example response" }
41
+ * };
42
+ *
43
+ * await logRequest(config);
44
+ * ```
45
+ */
46
+ async function logRequest(config) {
47
+ const arkynService = LogService.getConfig();
48
+ if (!arkynService)
49
+ return;
50
+ const { userToken, apiUrl, trafficSourceId } = arkynService;
51
+ const { elapsedTime, method, queryParams, requestBody, requestHeaders, responseBody, responseHeaders, status, token, rawUrl, } = config;
52
+ if (process.env.NODE_ENV === "development")
53
+ return;
54
+ try {
55
+ const url = new URL(rawUrl);
56
+ let protocol = "https";
57
+ if (url.protocol === "http:")
58
+ protocol = "http";
59
+ const body = JSON.stringify({
60
+ domainUrl: url.protocol + "//" + url.host,
61
+ pathnameUrl: url.pathname,
62
+ trafficSourceId: trafficSourceId,
63
+ status,
64
+ protocol,
65
+ method: method.toLowerCase(),
66
+ trafficUserId: null,
67
+ elapsedTime,
68
+ requestHeaders: JSON.stringify(requestHeaders),
69
+ requestBody: JSON.stringify(requestBody),
70
+ queryParams: JSON.stringify(queryParams),
71
+ responseHeaders: JSON.stringify(responseHeaders),
72
+ responseBody: JSON.stringify(responseBody),
73
+ });
74
+ const headers = {
75
+ "Content-Type": "application/json",
76
+ Authorization: `Bearer ${userToken}`,
77
+ };
78
+ await fetch(apiUrl, { method: "POST", body, headers });
79
+ }
80
+ catch (err) {
81
+ flushDebugLogs({
82
+ debugs: [`Error sending request: ${err}`],
83
+ name: "LogError",
84
+ scheme: "red",
85
+ });
86
+ }
87
+ }
88
+ export { logRequest };
@@ -0,0 +1,61 @@
1
+ type InputProps = {
2
+ url: string;
3
+ method: "POST" | "PUT" | "DELETE" | "PATCH" | "GET";
4
+ urlParams?: Record<string, string>;
5
+ headers?: HeadersInit;
6
+ body?: any;
7
+ };
8
+ type ApiSuccessResponse<T = any> = {
9
+ success: true;
10
+ status: number;
11
+ message: string;
12
+ response: T;
13
+ cause: null;
14
+ };
15
+ type ApiFailedResponse = {
16
+ success: false;
17
+ status: number;
18
+ message: string;
19
+ response: any;
20
+ cause: string | Error | null;
21
+ };
22
+ type ApiResponseDTO<T = any> = ApiSuccessResponse<T> | ApiFailedResponse;
23
+ /**
24
+ * Makes an HTTP request using the Fetch API and returns a standardized response.
25
+ *
26
+ * @template {any} T - The expected type of the response data.
27
+ *
28
+ * @param {"POST" | "PUT" | "DELETE" | "PATCH" | "GET"} method - The HTTP method to use for the request. Supported methods are:
29
+ * - "POST": Create a new resource.
30
+ * - "PUT": Update an existing resource.
31
+ * - "DELETE": Remove a resource.
32
+ * - "PATCH": Partially update a resource.
33
+ * - "GET": Retrieve a resource.
34
+ * @param {string} url - The URL to which the request is sent.
35
+ * @param {HeadersInit} headers - Optional headers to include in the request. Defaults to an empty object.
36
+ * @param {any} body - Optional body to include in the request. Should be serializable to JSON.
37
+ *
38
+ * @returns {ApiResponseDTO<T>} A promise that resolves to an `ApiResponseDTO<T>` object containing:
39
+ * - `success`: A boolean indicating whether the request was successful.
40
+ * - `status`: The HTTP status code of the response.
41
+ * - `message`: A message describing the result of the request.
42
+ * - `response`: The parsed JSON response data, or `null` if parsing fails.
43
+ * - `cause`: Additional error information, if applicable.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * import { makeRequest } from "./makeRequest";
48
+ *
49
+ * async function fetchData() {
50
+ * const response = await makeRequest("GET", "https://api.example.com/data");
51
+ * if (response.success) {
52
+ * console.log("Data:", response.response);
53
+ * } else {
54
+ * console.error("Error:", response.message);
55
+ * }
56
+ * }
57
+ * ```
58
+ */
59
+ declare function makeRequest<T = any>(input: InputProps): Promise<ApiResponseDTO<T>>;
60
+ export { makeRequest, type ApiResponseDTO };
61
+ //# sourceMappingURL=_makeRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_makeRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/_makeRequest.ts"],"names":[],"mappings":"AAIA,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,KAAK,kBAAkB,CAAC,CAAC,GAAG,GAAG,IAAI;IACjC,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,CAAC;IACZ,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,KAAK,cAAc,CAAC,CAAC,GAAG,GAAG,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,iBAAe,WAAW,CAAC,CAAC,GAAG,GAAG,EAChC,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAoF5B;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,CAAC"}
@@ -1,20 +1,22 @@
1
- import { ArkynLogRequestMapper } from "../mapper/arkynLogRequestMapper";
2
- import { httpDebug } from "../services/httpDebug";
3
- import { arkynLogRequest } from "./arkynLogRequest";
1
+ import { flushDebugLogs } from "../..";
2
+ import { LogMapperService } from "../../services/logMapperService";
3
+ import { logRequest } from "./_logRequest";
4
4
  /**
5
5
  * Makes an HTTP request using the Fetch API and returns a standardized response.
6
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:
7
+ * @template {any} T - The expected type of the response data.
8
+ *
9
+ * @param {"POST" | "PUT" | "DELETE" | "PATCH" | "GET"} method - The HTTP method to use for the request. Supported methods are:
9
10
  * - "POST": Create a new resource.
10
11
  * - "PUT": Update an existing resource.
11
12
  * - "DELETE": Remove a resource.
12
13
  * - "PATCH": Partially update a resource.
13
14
  * - "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:
15
+ * @param {string} url - The URL to which the request is sent.
16
+ * @param {HeadersInit} headers - Optional headers to include in the request. Defaults to an empty object.
17
+ * @param {any} body - Optional body to include in the request. Should be serializable to JSON.
18
+ *
19
+ * @returns {ApiResponseDTO<T>} A promise that resolves to an `ApiResponseDTO<T>` object containing:
18
20
  * - `success`: A boolean indicating whether the request was successful.
19
21
  * - `status`: The HTTP status code of the response.
20
22
  * - `message`: A message describing the result of the request.
@@ -35,7 +37,13 @@ import { arkynLogRequest } from "./arkynLogRequest";
35
37
  * }
36
38
  * ```
37
39
  */
38
- async function makeRequest(method, url, rawHeaders = {}, body) {
40
+ async function makeRequest(input) {
41
+ let url = input.url;
42
+ if (input.urlParams) {
43
+ Object.entries(input.urlParams).forEach(([key, value]) => {
44
+ url = url.replaceAll(`:${key}`, value);
45
+ });
46
+ }
39
47
  const successMessage = {
40
48
  POST: "Resource created successfully",
41
49
  PUT: "Resource updated successfully",
@@ -45,11 +53,11 @@ async function makeRequest(method, url, rawHeaders = {}, body) {
45
53
  };
46
54
  try {
47
55
  const startTime = performance.now();
48
- const headers = { ...rawHeaders, "Content-Type": "application/json" };
56
+ const headers = { ...input.headers, "Content-Type": "application/json" };
49
57
  const response = await fetch(url, {
50
- method,
51
58
  headers,
52
- body: body ? JSON.stringify(body) : undefined,
59
+ method: input.method,
60
+ body: input.body ? JSON.stringify(input.body) : undefined,
53
61
  });
54
62
  const elapsedTime = performance.now() - startTime;
55
63
  const status = response.status;
@@ -60,18 +68,19 @@ async function makeRequest(method, url, rawHeaders = {}, body) {
60
68
  catch {
61
69
  data = null;
62
70
  }
63
- const logData = ArkynLogRequestMapper.handle({
71
+ const logData = LogMapperService.handle({
64
72
  elapsedTime,
65
- method,
73
+ method: input.method,
66
74
  queryParams: new URL(url).searchParams,
67
75
  requestHeaders: headers,
68
- requestBody: body,
76
+ requestBody: input.body,
69
77
  responseBody: data,
70
78
  responseHeaders: response.headers,
71
79
  status,
72
- url,
80
+ rawUrl: input.url,
81
+ urlParams: input.urlParams,
73
82
  });
74
- arkynLogRequest(logData);
83
+ logRequest(logData);
75
84
  if (!response.ok) {
76
85
  return {
77
86
  success: false,
@@ -84,13 +93,17 @@ async function makeRequest(method, url, rawHeaders = {}, body) {
84
93
  return {
85
94
  success: true,
86
95
  status,
87
- message: data?.message || successMessage[method],
96
+ message: data?.message || successMessage[input.method],
88
97
  response: data,
89
98
  cause: null,
90
99
  };
91
100
  }
92
101
  catch (err) {
93
- httpDebug("Network error or request failed", null, err);
102
+ flushDebugLogs({
103
+ debugs: [`Network error or request failed: ${err}`],
104
+ name: "MakeRequestError",
105
+ scheme: "red",
106
+ });
94
107
  return {
95
108
  success: false,
96
109
  status: 0,
@@ -0,0 +1,17 @@
1
+ import { type ApiResponseDTO } from "./_makeRequest";
2
+ type InputProps = {
3
+ url: string;
4
+ urlParams?: Record<string, string>;
5
+ headers?: HeadersInit;
6
+ body?: any;
7
+ };
8
+ /**
9
+ * Sends a DELETE request to the specified URL with optional headers and body.
10
+ *
11
+ * @template T - The expected type of the response data.
12
+ * @param {InputProps} input - The options for the DELETE request, including URL, URL parameters, headers, and body.
13
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
14
+ */
15
+ declare function deleteRequest<T = any>(input: InputProps): Promise<ApiResponseDTO<T>>;
16
+ export { deleteRequest };
17
+ //# sourceMappingURL=deleteRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/deleteRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF;;;;;;GAMG;AAEH,iBAAe,aAAa,CAAC,CAAC,GAAG,GAAG,EAClC,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAQ5B;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,18 @@
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 {InputProps} input - The options for the DELETE request, including URL, URL parameters, headers, and body.
7
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
8
+ */
9
+ async function deleteRequest(input) {
10
+ return makeRequest({
11
+ method: "DELETE",
12
+ url: input.url,
13
+ urlParams: input.urlParams,
14
+ headers: input.headers,
15
+ body: input.body,
16
+ });
17
+ }
18
+ export { deleteRequest };
@@ -0,0 +1,16 @@
1
+ import { type ApiResponseDTO } from "./_makeRequest";
2
+ type InputProps = {
3
+ url: string;
4
+ urlParams?: Record<string, string>;
5
+ headers?: HeadersInit;
6
+ };
7
+ /**
8
+ * Sends a GET request to the specified URL with optional headers.
9
+ *
10
+ * @template T - The expected type of the response data.
11
+ * @param {InputProps} input - The options for the GET request, including URL, URL parameters, and headers.
12
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
13
+ */
14
+ declare function getRequest<T = any>(input: InputProps): Promise<ApiResponseDTO<T>>;
15
+ export { getRequest };
16
+ //# sourceMappingURL=getRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/getRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF;;;;;;GAMG;AAEH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAO5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,17 @@
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 {InputProps} input - The options for the GET request, including URL, URL parameters, and headers.
7
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
8
+ */
9
+ async function getRequest(input) {
10
+ return makeRequest({
11
+ method: "GET",
12
+ url: input.url,
13
+ urlParams: input.urlParams,
14
+ headers: input.headers,
15
+ });
16
+ }
17
+ export { getRequest };
@@ -0,0 +1,17 @@
1
+ import { type ApiResponseDTO } from "./_makeRequest";
2
+ type InputProps = {
3
+ url: string;
4
+ urlParams?: Record<string, string>;
5
+ headers?: HeadersInit;
6
+ body?: any;
7
+ };
8
+ /**
9
+ * Sends a PATCH request to the specified URL with optional headers and body.
10
+ *
11
+ * @template T - The expected type of the response data.
12
+ * @param {InputProps} input - The options for the PATCH request, including URL, URL parameters, headers, and body.
13
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
14
+ */
15
+ declare function patchRequest<T = any>(input: InputProps): Promise<ApiResponseDTO<T>>;
16
+ export { patchRequest };
17
+ //# sourceMappingURL=patchRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patchRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/patchRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF;;;;;;GAMG;AAEH,iBAAe,YAAY,CAAC,CAAC,GAAG,GAAG,EACjC,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAQ5B;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { makeRequest } from "./_makeRequest";
2
+ /**
3
+ * Sends a PATCH request to the specified URL with optional headers and body.
4
+ *
5
+ * @template T - The expected type of the response data.
6
+ * @param {InputProps} input - The options for the PATCH request, including URL, URL parameters, headers, and body.
7
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
8
+ */
9
+ async function patchRequest(input) {
10
+ return makeRequest({
11
+ method: "PATCH",
12
+ url: input.url,
13
+ urlParams: input.urlParams,
14
+ headers: input.headers,
15
+ body: input.body,
16
+ });
17
+ }
18
+ export { patchRequest };
@@ -0,0 +1,17 @@
1
+ import { type ApiResponseDTO } from "./_makeRequest";
2
+ type InputProps = {
3
+ url: string;
4
+ urlParams?: Record<string, string>;
5
+ headers?: HeadersInit;
6
+ body?: any;
7
+ };
8
+ /**
9
+ * Sends a POST request to the specified URL with optional headers and body.
10
+ *
11
+ * @template T - The expected type of the response data.
12
+ * @param {InputProps} input - The options for the POST request, including URL, URL parameters, headers, and body.
13
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
14
+ */
15
+ declare function postRequest<T = any>(input: InputProps): Promise<ApiResponseDTO<T>>;
16
+ export { postRequest };
17
+ //# sourceMappingURL=postRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/postRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF;;;;;;GAMG;AAEH,iBAAe,WAAW,CAAC,CAAC,GAAG,GAAG,EAChC,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAQ5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { makeRequest } from "./_makeRequest";
2
+ /**
3
+ * Sends a POST request to the specified URL with optional headers and body.
4
+ *
5
+ * @template T - The expected type of the response data.
6
+ * @param {InputProps} input - The options for the POST request, including URL, URL parameters, headers, and body.
7
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
8
+ */
9
+ async function postRequest(input) {
10
+ return makeRequest({
11
+ method: "POST",
12
+ url: input.url,
13
+ urlParams: input.urlParams,
14
+ headers: input.headers,
15
+ body: input.body,
16
+ });
17
+ }
18
+ export { postRequest };
@@ -0,0 +1,17 @@
1
+ import { type ApiResponseDTO } from "./_makeRequest";
2
+ type InputProps = {
3
+ url: string;
4
+ urlParams?: Record<string, string>;
5
+ headers?: HeadersInit;
6
+ body?: any;
7
+ };
8
+ /**
9
+ * Sends a PUT request to the specified URL with optional headers and body.
10
+ *
11
+ * @template T - The expected type of the response data.
12
+ * @param {InputProps} input - The options for the PUT request, including URL, URL parameters, headers, and body.
13
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
14
+ */
15
+ declare function putRequest<T = any>(input: InputProps): Promise<ApiResponseDTO<T>>;
16
+ export { putRequest };
17
+ //# sourceMappingURL=putRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"putRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/putRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF;;;;;;GAMG;AAEH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAQ5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { makeRequest } from "./_makeRequest";
2
+ /**
3
+ * Sends a PUT request to the specified URL with optional headers and body.
4
+ *
5
+ * @template T - The expected type of the response data.
6
+ * @param {InputProps} input - The options for the PUT request, including URL, URL parameters, headers, and body.
7
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
8
+ */
9
+ async function putRequest(input) {
10
+ return makeRequest({
11
+ method: "PUT",
12
+ url: input.url,
13
+ urlParams: input.urlParams,
14
+ headers: input.headers,
15
+ body: input.body,
16
+ });
17
+ }
18
+ export { putRequest };
@@ -0,0 +1,22 @@
1
+ declare class BadResponse {
2
+ private _cause?;
3
+ private _name;
4
+ private _status;
5
+ private _statusText;
6
+ get cause(): any;
7
+ set cause(value: any);
8
+ get name(): string;
9
+ set name(value: string);
10
+ get status(): number;
11
+ set status(value: number);
12
+ get statusText(): string;
13
+ set statusText(value: string);
14
+ onDebug(): void;
15
+ makeBody(): {
16
+ name: string;
17
+ message: string;
18
+ cause: any;
19
+ };
20
+ }
21
+ export { BadResponse };
22
+ //# sourceMappingURL=_badResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_badResponse.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/_badResponse.ts"],"names":[],"mappings":"AAGA,cAAM,WAAW;IACf,OAAO,CAAC,MAAM,CAAC,CAAM;IACrB,OAAO,CAAC,KAAK,CAAyB;IACtC,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,WAAW,CAA2B;IAE9C,IAAI,KAAK,IAAI,GAAG,CAEf;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,GAAG,EAEnB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAErB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAEvB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,EAE3B;IAED,OAAO;IAaP,QAAQ;;;;;CAOT;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}