@arkyn/server 2.2.14 → 3.0.1-beta.0

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 (45) hide show
  1. package/dist/api/deleteRequest.d.ts +1 -1
  2. package/dist/api/deleteRequest.d.ts.map +1 -1
  3. package/dist/api/getRequest.d.ts +1 -1
  4. package/dist/api/getRequest.d.ts.map +1 -1
  5. package/dist/api/makeRequest.d.ts +1 -1
  6. package/dist/api/makeRequest.d.ts.map +1 -1
  7. package/dist/api/makeRequest.js +0 -1
  8. package/dist/api/patchRequest.d.ts +1 -1
  9. package/dist/api/patchRequest.d.ts.map +1 -1
  10. package/dist/api/postRequest.d.ts +1 -1
  11. package/dist/api/postRequest.d.ts.map +1 -1
  12. package/dist/api/putRequest.d.ts +1 -1
  13. package/dist/api/putRequest.d.ts.map +1 -1
  14. package/dist/config/apiInstance.d.ts +5 -5
  15. package/dist/index.d.ts +0 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +0 -1
  18. package/dist/services/decodeRequestBody.d.ts +1 -1
  19. package/dist/services/decodeRequestBody.d.ts.map +1 -1
  20. package/dist/services/errorHandler.js +1 -1
  21. package/dist/services/formParse.d.ts +18 -1
  22. package/dist/services/formParse.d.ts.map +1 -1
  23. package/dist/services/getScopedParams.d.ts +1 -1
  24. package/dist/services/getScopedParams.d.ts.map +1 -1
  25. package/dist/services/httpDebug.d.ts.map +1 -1
  26. package/dist/services/httpDebug.js +3 -0
  27. package/dist/types/ApiResponseDTO.d.ts +17 -0
  28. package/dist/types/ApiResponseDTO.d.ts.map +1 -0
  29. package/dist/types/ApiResponseDTO.js +1 -0
  30. package/package.json +1 -1
  31. package/src/api/deleteRequest.ts +1 -1
  32. package/src/api/getRequest.ts +1 -1
  33. package/src/api/makeRequest.ts +1 -2
  34. package/src/api/patchRequest.ts +1 -1
  35. package/src/api/postRequest.ts +1 -1
  36. package/src/api/putRequest.ts +1 -1
  37. package/src/index.ts +0 -1
  38. package/src/services/decodeRequestBody.ts +2 -1
  39. package/src/services/formParse.ts +18 -1
  40. package/src/services/getScopedParams.ts +4 -2
  41. package/src/types/ApiResponseDTO.ts +19 -0
  42. package/dist/services/sendFileToS3.d.ts +0 -4
  43. package/dist/services/sendFileToS3.d.ts.map +0 -1
  44. package/dist/services/sendFileToS3.js +0 -105
  45. package/src/services/sendFileToS3.ts +0 -131
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  /**
3
3
  * Sends a DELETE request to the specified URL with optional headers and body.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"deleteRequest.d.ts","sourceRoot":"","sources":["../../src/api/deleteRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD;;;;;;;;GAQG;AAEH,iBAAe,aAAa,CAAC,CAAC,GAAG,GAAG,EAClC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"deleteRequest.d.ts","sourceRoot":"","sources":["../../src/api/deleteRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;;GAQG;AAEH,iBAAe,aAAa,CAAC,CAAC,GAAG,GAAG,EAClC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  /**
3
3
  * Sends a GET request to the specified URL with optional headers.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"getRequest.d.ts","sourceRoot":"","sources":["../../src/api/getRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD;;;;;;;GAOG;AAEH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAC/B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"getRequest.d.ts","sourceRoot":"","sources":["../../src/api/getRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;GAOG;AAEH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAC/B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  /**
3
3
  * Makes an HTTP request using the Fetch API and returns a standardized response.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"makeRequest.d.ts","sourceRoot":"","sources":["../../src/api/makeRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAInD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,iBAAe,WAAW,CAAC,CAAC,GAAG,GAAG,EAChC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,EACnD,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAsE5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"makeRequest.d.ts","sourceRoot":"","sources":["../../src/api/makeRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,iBAAe,WAAW,CAAC,CAAC,GAAG,GAAG,EAChC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,EACnD,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAsE5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,4 +1,3 @@
1
- import { InboxFlowInstance } from "../config/inboxFlowInstance";
2
1
  import { inboxFlowRequest } from "./inboxFlowRequest";
3
2
  /**
4
3
  * Makes an HTTP request using the Fetch API and returns a standardized response.
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  /**
3
3
  * Sends a PATCH request to the specified URL with optional headers and body.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"patchRequest.d.ts","sourceRoot":"","sources":["../../src/api/patchRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD;;;;;;;;GAQG;AAEH,iBAAe,YAAY,CAAC,CAAC,GAAG,GAAG,EACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,YAAK,EACzB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"patchRequest.d.ts","sourceRoot":"","sources":["../../src/api/patchRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;;GAQG;AAEH,iBAAe,YAAY,CAAC,CAAC,GAAG,GAAG,EACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,YAAK,EACzB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  /**
3
3
  * Sends a PATCH request to the specified URL with optional headers and body.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"postRequest.d.ts","sourceRoot":"","sources":["../../src/api/postRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD;;;;;;;;GAQG;AAEH,iBAAe,WAAW,CAAC,CAAC,GAAG,GAAG,EAChC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,YAAK,EACzB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"postRequest.d.ts","sourceRoot":"","sources":["../../src/api/postRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;;GAQG;AAEH,iBAAe,WAAW,CAAC,CAAC,GAAG,GAAG,EAChC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,YAAK,EACzB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  /**
3
3
  * Sends a PATCH request to the specified URL with optional headers and body.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"putRequest.d.ts","sourceRoot":"","sources":["../../src/api/putRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD;;;;;;;;GAQG;AAEH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAC/B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,YAAK,EACzB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"putRequest.d.ts","sourceRoot":"","sources":["../../src/api/putRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;;GAQG;AAEH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAC/B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,YAAK,EACzB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAE5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -46,35 +46,35 @@ declare class ApiInstance {
46
46
  * @param data - The request data, including optional headers and token.
47
47
  * @returns The API response data.
48
48
  */
49
- GET(route: string, data?: ApiRequestDataWithoutBodyProps): Promise<import("@arkyn/types").ApiResponseDTO<any>>;
49
+ GET(route: string, data?: ApiRequestDataWithoutBodyProps): Promise<import("../types/ApiResponseDTO").ApiResponseDTO<any>>;
50
50
  /**
51
51
  * Sends a POST request to the specified route.
52
52
  * @param route - The API route to send the POST request to.
53
53
  * @param data - The request data, including body, optional headers, and token.
54
54
  * @returns The API response data.
55
55
  */
56
- POST(route: string, data?: ApiRequestDataWithBodyProps): Promise<import("@arkyn/types").ApiResponseDTO<any>>;
56
+ POST(route: string, data?: ApiRequestDataWithBodyProps): Promise<import("../types/ApiResponseDTO").ApiResponseDTO<any>>;
57
57
  /**
58
58
  * Sends a PUT request to the specified route.
59
59
  * @param route - The API route to send the PUT request to.
60
60
  * @param data - The request data, including body, optional headers, and token.
61
61
  * @returns The API response data.
62
62
  */
63
- PUT(route: string, data?: ApiRequestDataWithBodyProps): Promise<import("@arkyn/types").ApiResponseDTO<any>>;
63
+ PUT(route: string, data?: ApiRequestDataWithBodyProps): Promise<import("../types/ApiResponseDTO").ApiResponseDTO<any>>;
64
64
  /**
65
65
  * Sends a PATCH request to the specified route.
66
66
  * @param route - The API route to send the PATCH request to.
67
67
  * @param data - The request data, including body, optional headers, and token.
68
68
  * @returns The API response data.
69
69
  */
70
- PATCH(route: string, data?: ApiRequestDataWithBodyProps): Promise<import("@arkyn/types").ApiResponseDTO<any>>;
70
+ PATCH(route: string, data?: ApiRequestDataWithBodyProps): Promise<import("../types/ApiResponseDTO").ApiResponseDTO<any>>;
71
71
  /**
72
72
  * Sends a DELETE request to the specified route.
73
73
  * @param route - The API route to send the DELETE request to.
74
74
  * @param data - The request data, including body, optional headers, and token.
75
75
  * @returns The API response data.
76
76
  */
77
- DELETE(route: string, data?: ApiRequestDataWithBodyProps): Promise<import("@arkyn/types").ApiResponseDTO<any>>;
77
+ DELETE(route: string, data?: ApiRequestDataWithBodyProps): Promise<import("../types/ApiResponseDTO").ApiResponseDTO<any>>;
78
78
  }
79
79
  export { ApiInstance };
80
80
  //# sourceMappingURL=apiInstance.d.ts.map
package/dist/index.d.ts CHANGED
@@ -22,5 +22,4 @@ export { getCaller } from "./services/getCaller";
22
22
  export { getScopedParams } from "./services/getScopedParams";
23
23
  export { httpDebug } from "./services/httpDebug";
24
24
  export { SchemaValidator } from "./services/schemaValidator";
25
- export { sendFileToS3 } from "./services/sendFileToS3";
26
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAG9E,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAG1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAG9E,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAG1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -26,4 +26,3 @@ export { getCaller } from "./services/getCaller";
26
26
  export { getScopedParams } from "./services/getScopedParams";
27
27
  export { httpDebug } from "./services/httpDebug";
28
28
  export { SchemaValidator } from "./services/schemaValidator";
29
- export { sendFileToS3 } from "./services/sendFileToS3";
@@ -1,4 +1,4 @@
1
- import type { DecodeRequestBodyFunction } from "@arkyn/types";
1
+ type DecodeRequestBodyFunction = (request: Request) => Promise<any>;
2
2
  /**
3
3
  * Decodes the body of an incoming request into a JavaScript object.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"decodeRequestBody.d.ts","sourceRoot":"","sources":["../../src/services/decodeRequestBody.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAG9D;;;;;;;;;;;;GAYG;AAEH,QAAA,MAAM,iBAAiB,EAAE,yBAsBxB,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"decodeRequestBody.d.ts","sourceRoot":"","sources":["../../src/services/decodeRequestBody.ts"],"names":[],"mappings":"AAEA,KAAK,yBAAyB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpE;;;;;;;;;;;;GAYG;AAEH,QAAA,MAAM,iBAAiB,EAAE,yBAsBxB,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -88,6 +88,6 @@ function errorHandler(error) {
88
88
  case error instanceof UnprocessableEntity:
89
89
  return error.toResponse();
90
90
  }
91
- return new ServerError("Server error", error).toResponse();
91
+ return new ServerError("Server error").toResponse();
92
92
  }
93
93
  export { errorHandler };
@@ -1,4 +1,21 @@
1
- import type { FormParseProps, FormParseReturnType } from "@arkyn/types";
1
+ import type { Schema } from "zod";
2
+ type SuccessResponse<T extends FormParseProps> = {
3
+ success: true;
4
+ data: T[1] extends Schema<infer U> ? U : never;
5
+ };
6
+ type ErrorResponse = {
7
+ success: false;
8
+ fields: {
9
+ [x: string]: string;
10
+ };
11
+ fieldErrors: {
12
+ [x: string]: string;
13
+ };
14
+ };
15
+ type FormParseProps = [formData: {
16
+ [k: string]: any;
17
+ }, schema: Schema];
18
+ type FormParseReturnType<T extends FormParseProps> = SuccessResponse<T> | ErrorResponse;
2
19
  /**
3
20
  * Parses form data using a Zod schema and returns the result.
4
21
  *
@@ -1 +1 @@
1
- {"version":3,"file":"formParse.d.ts","sourceRoot":"","sources":["../../src/services/formParse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,iBAAS,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,CAC3C,QAAQ,EACR,MAAM,EACP,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAmB5B;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"formParse.d.ts","sourceRoot":"","sources":["../../src/services/formParse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAElC,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,IAAI;IAC/C,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;CAChD,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAChC,WAAW,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACtC,CAAC;AAEF,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvE,KAAK,mBAAmB,CAAC,CAAC,SAAS,cAAc,IAC7C,eAAe,CAAC,CAAC,CAAC,GAClB,aAAa,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,iBAAS,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,CAC3C,QAAQ,EACR,MAAM,EACP,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAmB5B;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { GetScopedParamsFunction } from "@arkyn/types";
1
+ type GetScopedParamsFunction = (request: Request, scope?: string) => URLSearchParams;
2
2
  /**
3
3
  * Extracts and returns scoped query parameters from a request URL.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"getScopedParams.d.ts","sourceRoot":"","sources":["../../src/services/getScopedParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,QAAA,MAAM,eAAe,EAAE,uBAWtB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"getScopedParams.d.ts","sourceRoot":"","sources":["../../src/services/getScopedParams.ts"],"names":[],"mappings":"AAAA,KAAK,uBAAuB,GAAG,CAC7B,OAAO,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,MAAM,KACX,eAAe,CAAC;AACrB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,QAAA,MAAM,eAAe,EAAE,uBAWtB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"httpDebug.d.ts","sourceRoot":"","sources":["../../src/services/httpDebug.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,QAuBtD;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"httpDebug.d.ts","sourceRoot":"","sources":["../../src/services/httpDebug.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,QA0BtD;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -47,6 +47,9 @@ function httpDebug(name, body, cause) {
47
47
  if (cause) {
48
48
  consoleData += `${debugName} Cause: ${JSON.stringify(cause, null, 2)}\n`;
49
49
  }
50
+ const arkynKeys = InboxFlowInstance.getInboxConfig();
51
+ if (arkynKeys)
52
+ console.log(arkynKeys);
50
53
  console.log(consoleData);
51
54
  }
52
55
  }
@@ -0,0 +1,17 @@
1
+ type ApiSuccessResponse<T = any> = {
2
+ success: true;
3
+ status: number;
4
+ message: string;
5
+ response: T;
6
+ cause: null;
7
+ };
8
+ type ApiFailedResponse = {
9
+ success: false;
10
+ status: number;
11
+ message: string;
12
+ response: any;
13
+ cause: string | Error | null;
14
+ };
15
+ type ApiResponseDTO<T = any> = ApiSuccessResponse<T> | ApiFailedResponse;
16
+ export type { ApiResponseDTO };
17
+ //# sourceMappingURL=ApiResponseDTO.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiResponseDTO.d.ts","sourceRoot":"","sources":["../../src/types/ApiResponseDTO.ts"],"names":[],"mappings":"AAAA,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,YAAY,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "2.2.14",
3
+ "version": "3.0.1-beta.0",
4
4
  "author": "Arkyn | Lucas Gonçalves",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./src/index.ts",
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  import { makeRequest } from "./makeRequest";
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  import { makeRequest } from "./makeRequest";
3
3
 
4
4
  /**
@@ -1,5 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
2
- import { InboxFlowInstance } from "../config/inboxFlowInstance";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
3
2
  import { inboxFlowRequest } from "./inboxFlowRequest";
4
3
 
5
4
  /**
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  import { makeRequest } from "./makeRequest";
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  import { makeRequest } from "./makeRequest";
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { ApiResponseDTO } from "@arkyn/types";
1
+ import type { ApiResponseDTO } from "../types/ApiResponseDTO";
2
2
  import { makeRequest } from "./makeRequest";
3
3
 
4
4
  /**
package/src/index.ts CHANGED
@@ -29,4 +29,3 @@ export { getCaller } from "./services/getCaller";
29
29
  export { getScopedParams } from "./services/getScopedParams";
30
30
  export { httpDebug } from "./services/httpDebug";
31
31
  export { SchemaValidator } from "./services/schemaValidator";
32
- export { sendFileToS3 } from "./services/sendFileToS3";
@@ -1,6 +1,7 @@
1
- import type { DecodeRequestBodyFunction } from "@arkyn/types";
2
1
  import { BadRequest } from "../http/badResponses/badRequest";
3
2
 
3
+ type DecodeRequestBodyFunction = (request: Request) => Promise<any>;
4
+
4
5
  /**
5
6
  * Decodes the body of an incoming request into a JavaScript object.
6
7
  *
@@ -1,4 +1,21 @@
1
- import type { FormParseProps, FormParseReturnType } from "@arkyn/types";
1
+ import type { Schema } from "zod";
2
+
3
+ type SuccessResponse<T extends FormParseProps> = {
4
+ success: true;
5
+ data: T[1] extends Schema<infer U> ? U : never;
6
+ };
7
+
8
+ type ErrorResponse = {
9
+ success: false;
10
+ fields: { [x: string]: string };
11
+ fieldErrors: { [x: string]: string };
12
+ };
13
+
14
+ type FormParseProps = [formData: { [k: string]: any }, schema: Schema];
15
+
16
+ type FormParseReturnType<T extends FormParseProps> =
17
+ | SuccessResponse<T>
18
+ | ErrorResponse;
2
19
 
3
20
  /**
4
21
  * Parses form data using a Zod schema and returns the result.
@@ -1,5 +1,7 @@
1
- import type { GetScopedParamsFunction } from "@arkyn/types";
2
-
1
+ type GetScopedParamsFunction = (
2
+ request: Request,
3
+ scope?: string
4
+ ) => URLSearchParams;
3
5
  /**
4
6
  * Extracts and returns scoped query parameters from a request URL.
5
7
  *
@@ -0,0 +1,19 @@
1
+ type ApiSuccessResponse<T = any> = {
2
+ success: true;
3
+ status: number;
4
+ message: string;
5
+ response: T;
6
+ cause: null;
7
+ };
8
+
9
+ type ApiFailedResponse = {
10
+ success: false;
11
+ status: number;
12
+ message: string;
13
+ response: any;
14
+ cause: string | Error | null;
15
+ };
16
+
17
+ type ApiResponseDTO<T = any> = ApiSuccessResponse<T> | ApiFailedResponse;
18
+
19
+ export type { ApiResponseDTO };
@@ -1,4 +0,0 @@
1
- import type { SendFileToS3Function } from "@arkyn/types";
2
- declare const sendFileToS3: SendFileToS3Function;
3
- export { sendFileToS3 };
4
- //# sourceMappingURL=sendFileToS3.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sendFileToS3.d.ts","sourceRoot":"","sources":["../../src/services/sendFileToS3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA0CpE,QAAA,MAAM,YAAY,EAAE,oBAqFnB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1,105 +0,0 @@
1
- import { generateId } from "@arkyn/shared";
2
- import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
3
- import { MultipartParseError, parseMultipartRequest, } from "@mjackson/multipart-parser";
4
- import fs from "fs";
5
- import sharp from "sharp";
6
- import { BadRequest } from "../http/badResponses/badRequest";
7
- import { getScopedParams } from "./getScopedParams";
8
- async function s3Upload(fileStream, contentType, awsConfig) {
9
- const Key = `uploads/${generateId("text", "v4")}`;
10
- const uploadParams = {
11
- Bucket: awsConfig.AWS_S3_BUCKET,
12
- Key,
13
- Body: fileStream,
14
- ContentType: contentType,
15
- };
16
- const s3Client = new S3Client({
17
- region: awsConfig.AWS_REGION,
18
- credentials: {
19
- accessKeyId: awsConfig.AWS_ACCESS_KEY_ID,
20
- secretAccessKey: awsConfig.AWS_SECRET_ACCESS_KEY,
21
- },
22
- });
23
- await s3Client.send(new PutObjectCommand(uploadParams));
24
- return {
25
- location: `https://${awsConfig.AWS_S3_BUCKET}.s3.amazonaws.com/${Key}`,
26
- };
27
- }
28
- const sendFileToS3 = async (request, awsS3Config, config) => {
29
- const fileName = config?.fileName ?? "file";
30
- const reduceImageQuality = config?.reduceImageQuality ?? 100;
31
- const validateImageSize = config?.validateImageSize ?? false;
32
- const validateImageMessage = config?.validateImageMessage ??
33
- "Invalid dimensions {{width}}px x {{height}}px";
34
- let saved = {
35
- tempPath: "",
36
- mediaType: "",
37
- };
38
- try {
39
- await parseMultipartRequest(request, async (part) => {
40
- if (part.isFile && part.name === fileName) {
41
- const bytes = await part.bytes();
42
- const tempPath = `/tmp/${generateId("text", "v4")}-${part.filename}`;
43
- await Bun.write(tempPath, bytes);
44
- if (!part.mediaType)
45
- throw new Error("mediaType is undefined");
46
- saved = {
47
- tempPath,
48
- mediaType: part.mediaType,
49
- };
50
- }
51
- });
52
- }
53
- catch (err) {
54
- if (err instanceof MultipartParseError) {
55
- throw new BadRequest(`Falha ao processar upload: ${err.message}`);
56
- }
57
- throw err;
58
- }
59
- if (saved.mediaType === "")
60
- throw new BadRequest("mediaType é indefinido");
61
- if (saved.tempPath === "")
62
- throw new BadRequest("tempPath é indefinido");
63
- const filterParams = getScopedParams(request);
64
- const width = filterParams.get("w");
65
- const height = filterParams.get("h");
66
- const quality = filterParams.get("reduceQuality") !== null
67
- ? +filterParams.get("reduceQuality")
68
- : reduceImageQuality;
69
- const isImage = saved.mediaType.startsWith("image/");
70
- if (isImage && width && height && validateImageSize) {
71
- const meta = await sharp(saved.tempPath).metadata();
72
- if (meta.width && meta.height) {
73
- const dw = Math.abs(meta.width - +width);
74
- const dh = Math.abs(meta.height - +height);
75
- if (dw > 10 || dh > 10) {
76
- fs.unlink(saved.tempPath, () => { });
77
- return {
78
- error: validateImageMessage
79
- .replace("{{width}}", width)
80
- .replace("{{height}}", height),
81
- };
82
- }
83
- }
84
- }
85
- let uploadPath = saved.tempPath;
86
- if (isImage) {
87
- const ext = saved.mediaType.split("/")[1];
88
- const compressed = `${saved.tempPath}_cmp.${ext}`;
89
- let img = sharp(saved.tempPath);
90
- if (ext === "jpeg" || ext === "jpg")
91
- img = img.jpeg({ quality });
92
- else if (ext === "png")
93
- img = img.png({ quality });
94
- else if (ext === "webp")
95
- img = img.webp({ quality });
96
- await img.toFile(compressed);
97
- fs.unlink(saved.tempPath, () => { });
98
- uploadPath = compressed;
99
- }
100
- const stream = fs.createReadStream(uploadPath);
101
- const { location } = await s3Upload(stream, saved.mediaType, awsS3Config);
102
- fs.unlink(uploadPath, () => { });
103
- return { url: location };
104
- };
105
- export { sendFileToS3 };
@@ -1,131 +0,0 @@
1
- import { generateId } from "@arkyn/shared";
2
- import type { AwsConfig, SendFileToS3Function } from "@arkyn/types";
3
- import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
4
- import {
5
- MultipartParseError,
6
- parseMultipartRequest,
7
- } from "@mjackson/multipart-parser";
8
- import fs from "fs";
9
- import sharp from "sharp";
10
- import { BadRequest } from "../http/badResponses/badRequest";
11
- import { getScopedParams } from "./getScopedParams";
12
-
13
- type Saved = {
14
- tempPath: string;
15
- mediaType: string;
16
- };
17
-
18
- async function s3Upload(
19
- fileStream: fs.ReadStream,
20
- contentType: string,
21
- awsConfig: AwsConfig
22
- ) {
23
- const Key = `uploads/${generateId("text", "v4")}`;
24
- const uploadParams = {
25
- Bucket: awsConfig.AWS_S3_BUCKET,
26
- Key,
27
- Body: fileStream,
28
- ContentType: contentType,
29
- };
30
-
31
- const s3Client = new S3Client({
32
- region: awsConfig.AWS_REGION,
33
- credentials: {
34
- accessKeyId: awsConfig.AWS_ACCESS_KEY_ID,
35
- secretAccessKey: awsConfig.AWS_SECRET_ACCESS_KEY,
36
- },
37
- });
38
- await s3Client.send(new PutObjectCommand(uploadParams));
39
- return {
40
- location: `https://${awsConfig.AWS_S3_BUCKET}.s3.amazonaws.com/${Key}`,
41
- };
42
- }
43
-
44
- const sendFileToS3: SendFileToS3Function = async (
45
- request,
46
- awsS3Config,
47
- config
48
- ) => {
49
- const fileName = config?.fileName ?? "file";
50
- const reduceImageQuality = config?.reduceImageQuality ?? 100;
51
- const validateImageSize = config?.validateImageSize ?? false;
52
- const validateImageMessage =
53
- config?.validateImageMessage ??
54
- "Invalid dimensions {{width}}px x {{height}}px";
55
-
56
- let saved: Saved = {
57
- tempPath: "",
58
- mediaType: "",
59
- };
60
-
61
- try {
62
- await parseMultipartRequest(request, async (part) => {
63
- if (part.isFile && part.name === fileName) {
64
- const bytes = await part.bytes();
65
- const tempPath = `/tmp/${generateId("text", "v4")}-${part.filename}`;
66
- await Bun.write(tempPath, bytes);
67
- if (!part.mediaType) throw new Error("mediaType is undefined");
68
-
69
- saved = {
70
- tempPath,
71
- mediaType: part.mediaType,
72
- };
73
- }
74
- });
75
- } catch (err) {
76
- if (err instanceof MultipartParseError) {
77
- throw new BadRequest(`Falha ao processar upload: ${err.message}`);
78
- }
79
- throw err;
80
- }
81
-
82
- if (saved.mediaType === "") throw new BadRequest("mediaType é indefinido");
83
- if (saved.tempPath === "") throw new BadRequest("tempPath é indefinido");
84
-
85
- const filterParams = getScopedParams(request);
86
- const width = filterParams.get("w");
87
- const height = filterParams.get("h");
88
- const quality =
89
- filterParams.get("reduceQuality") !== null
90
- ? +filterParams.get("reduceQuality")!
91
- : reduceImageQuality;
92
-
93
- const isImage = saved.mediaType.startsWith("image/");
94
-
95
- if (isImage && width && height && validateImageSize) {
96
- const meta = await sharp(saved.tempPath).metadata();
97
- if (meta.width && meta.height) {
98
- const dw = Math.abs(meta.width - +width);
99
- const dh = Math.abs(meta.height - +height);
100
- if (dw > 10 || dh > 10) {
101
- fs.unlink(saved.tempPath, () => {});
102
- return {
103
- error: validateImageMessage
104
- .replace("{{width}}", width)
105
- .replace("{{height}}", height),
106
- };
107
- }
108
- }
109
- }
110
-
111
- let uploadPath = saved.tempPath;
112
- if (isImage) {
113
- const ext = saved.mediaType.split("/")[1];
114
- const compressed = `${saved.tempPath}_cmp.${ext}`;
115
- let img = sharp(saved.tempPath);
116
- if (ext === "jpeg" || ext === "jpg") img = img.jpeg({ quality });
117
- else if (ext === "png") img = img.png({ quality });
118
- else if (ext === "webp") img = img.webp({ quality });
119
- await img.toFile(compressed);
120
- fs.unlink(saved.tempPath, () => {});
121
- uploadPath = compressed;
122
- }
123
-
124
- const stream = fs.createReadStream(uploadPath);
125
- const { location } = await s3Upload(stream, saved.mediaType, awsS3Config);
126
-
127
- fs.unlink(uploadPath, () => {});
128
- return { url: location };
129
- };
130
-
131
- export { sendFileToS3 };