@arkyn/server 2.0.1-beta.11 → 2.0.1-beta.13

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 (120) hide show
  1. package/dist/api/deleteRequest.d.ts +13 -0
  2. package/dist/api/deleteRequest.d.ts.map +1 -0
  3. package/dist/api/deleteRequest.js +14 -0
  4. package/dist/api/getRequest.d.ts +12 -0
  5. package/dist/api/getRequest.d.ts.map +1 -0
  6. package/dist/api/getRequest.js +13 -0
  7. package/dist/api/inboxFlowRequest.d.ts +40 -0
  8. package/dist/api/inboxFlowRequest.d.ts.map +1 -0
  9. package/dist/api/inboxFlowRequest.js +63 -0
  10. package/dist/api/makeRequest.d.ts +38 -0
  11. package/dist/api/makeRequest.d.ts.map +1 -0
  12. package/dist/api/makeRequest.js +103 -0
  13. package/dist/api/patchRequest.d.ts +13 -0
  14. package/dist/api/patchRequest.d.ts.map +1 -0
  15. package/dist/api/patchRequest.js +14 -0
  16. package/dist/api/postRequest.d.ts +13 -0
  17. package/dist/api/postRequest.d.ts.map +1 -0
  18. package/dist/api/postRequest.js +14 -0
  19. package/dist/api/putRequest.d.ts +13 -0
  20. package/dist/api/putRequest.d.ts.map +1 -0
  21. package/dist/api/putRequest.js +14 -0
  22. package/dist/config/apiInstance.d.ts +80 -0
  23. package/dist/config/apiInstance.d.ts.map +1 -0
  24. package/dist/config/apiInstance.js +111 -0
  25. package/dist/config/inboxFlowInstance.d.ts +44 -0
  26. package/dist/config/inboxFlowInstance.d.ts.map +1 -0
  27. package/dist/config/inboxFlowInstance.js +46 -0
  28. package/dist/http/badResponses/badGateway.d.ts +23 -0
  29. package/dist/http/badResponses/badGateway.d.ts.map +1 -1
  30. package/dist/http/badResponses/badGateway.js +23 -0
  31. package/dist/http/badResponses/badRequest.d.ts +23 -0
  32. package/dist/http/badResponses/badRequest.d.ts.map +1 -1
  33. package/dist/http/badResponses/badRequest.js +23 -0
  34. package/dist/http/badResponses/conflict.d.ts +23 -0
  35. package/dist/http/badResponses/conflict.d.ts.map +1 -1
  36. package/dist/http/badResponses/conflict.js +23 -0
  37. package/dist/http/badResponses/forbidden.d.ts +23 -0
  38. package/dist/http/badResponses/forbidden.d.ts.map +1 -1
  39. package/dist/http/badResponses/forbidden.js +24 -1
  40. package/dist/http/badResponses/notFound.d.ts +23 -0
  41. package/dist/http/badResponses/notFound.d.ts.map +1 -1
  42. package/dist/http/badResponses/notFound.js +23 -0
  43. package/dist/http/badResponses/notImplemented.d.ts +23 -0
  44. package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
  45. package/dist/http/badResponses/notImplemented.js +23 -0
  46. package/dist/http/badResponses/serverError.d.ts +23 -0
  47. package/dist/http/badResponses/serverError.d.ts.map +1 -1
  48. package/dist/http/badResponses/serverError.js +23 -0
  49. package/dist/http/badResponses/unauthorized.d.ts +23 -0
  50. package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
  51. package/dist/http/badResponses/unauthorized.js +23 -0
  52. package/dist/http/badResponses/unprocessableEntity.d.ts +27 -0
  53. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
  54. package/dist/http/badResponses/unprocessableEntity.js +27 -0
  55. package/dist/http/successResponses/created.d.ts +25 -0
  56. package/dist/http/successResponses/created.d.ts.map +1 -1
  57. package/dist/http/successResponses/created.js +25 -0
  58. package/dist/http/successResponses/found.d.ts +28 -0
  59. package/dist/http/successResponses/found.d.ts.map +1 -1
  60. package/dist/http/successResponses/found.js +28 -0
  61. package/dist/http/successResponses/noContent.d.ts +16 -1
  62. package/dist/http/successResponses/noContent.d.ts.map +1 -1
  63. package/dist/http/successResponses/noContent.js +16 -8
  64. package/dist/http/successResponses/success.d.ts +25 -0
  65. package/dist/http/successResponses/success.d.ts.map +1 -1
  66. package/dist/http/successResponses/success.js +25 -0
  67. package/dist/http/successResponses/updated.d.ts +25 -0
  68. package/dist/http/successResponses/updated.d.ts.map +1 -1
  69. package/dist/http/successResponses/updated.js +25 -0
  70. package/dist/index.d.ts +6 -1
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +10 -1
  73. package/dist/services/decodeErrorMessageFromRequest.d.ts +17 -0
  74. package/dist/services/decodeErrorMessageFromRequest.d.ts.map +1 -0
  75. package/dist/services/decodeErrorMessageFromRequest.js +30 -0
  76. package/dist/services/decodeRequestBody.d.ts.map +1 -1
  77. package/dist/services/decodeRequestBody.js +12 -16
  78. package/dist/services/errorHandler.d.ts +42 -1
  79. package/dist/services/errorHandler.d.ts.map +1 -1
  80. package/dist/services/errorHandler.js +42 -0
  81. package/dist/services/formParse.d.ts.map +1 -1
  82. package/dist/services/formParse.js +4 -2
  83. package/dist/services/getCaller.d.ts +11 -0
  84. package/dist/services/getCaller.d.ts.map +1 -1
  85. package/dist/services/getCaller.js +32 -16
  86. package/dist/services/httpDebug.d.ts +32 -0
  87. package/dist/services/httpDebug.d.ts.map +1 -1
  88. package/dist/services/httpDebug.js +44 -6
  89. package/package.json +4 -2
  90. package/src/api/deleteRequest.ts +22 -0
  91. package/src/api/getRequest.ts +20 -0
  92. package/src/api/inboxFlowRequest.ts +76 -0
  93. package/src/api/makeRequest.ts +117 -0
  94. package/src/api/patchRequest.ts +22 -0
  95. package/src/api/postRequest.ts +22 -0
  96. package/src/api/putRequest.ts +22 -0
  97. package/src/config/apiInstance.ts +148 -0
  98. package/src/config/inboxFlowInstance.ts +65 -0
  99. package/src/http/badResponses/badGateway.ts +29 -2
  100. package/src/http/badResponses/badRequest.ts +29 -2
  101. package/src/http/badResponses/conflict.ts +29 -2
  102. package/src/http/badResponses/forbidden.ts +30 -3
  103. package/src/http/badResponses/notFound.ts +29 -2
  104. package/src/http/badResponses/notImplemented.ts +29 -2
  105. package/src/http/badResponses/serverError.ts +29 -2
  106. package/src/http/badResponses/unauthorized.ts +29 -2
  107. package/src/http/badResponses/unprocessableEntity.ts +33 -2
  108. package/src/http/successResponses/created.ts +31 -2
  109. package/src/http/successResponses/found.ts +32 -0
  110. package/src/http/successResponses/noContent.ts +20 -11
  111. package/src/http/successResponses/success.ts +31 -2
  112. package/src/http/successResponses/updated.ts +31 -2
  113. package/src/index.ts +11 -1
  114. package/src/services/decodeErrorMessageFromRequest.ts +36 -0
  115. package/src/services/decodeRequestBody.ts +11 -15
  116. package/src/services/errorHandler.ts +45 -1
  117. package/src/services/formParse.ts +4 -5
  118. package/src/services/getCaller.ts +39 -18
  119. package/src/services/httpDebug.ts +46 -5
  120. package/vitest.config.ts +5 -0
@@ -0,0 +1,44 @@
1
+ type InboxConfigProps = {
2
+ inboxChannelId: string;
3
+ inboxUserToken: string;
4
+ inboxApiUrl: string;
5
+ };
6
+ type SetInboxConfigProps = {
7
+ inboxChannelId: string;
8
+ inboxUserToken: string;
9
+ inboxApiUrl?: string;
10
+ };
11
+ /**
12
+ * The `InboxFlowInstance` class manages the configuration for the inbox flow.
13
+ * It allows you to set and retrieve the inbox configuration, including the channel ID,
14
+ * user token, and API URL.
15
+ */
16
+ declare class InboxFlowInstance {
17
+ private static inboxConfig?;
18
+ /**
19
+ * Sets the configuration for the inbox. This method initializes the inbox configuration
20
+ * with the provided `inboxConfig` values. If the configuration has already been set,
21
+ * the method will return early without making any changes.
22
+ *
23
+ * @param inboxConfig - An object containing the inbox configuration properties.
24
+ * @param inboxConfig.inboxChannelId - The key used to identify the inbox.
25
+ * @param inboxConfig.inboxUserToken - The user token for authenticating with the inbox.
26
+ * @param inboxConfig.inboxApiUrl - (Optional) The API URL for the inbox. If not provided,
27
+ * a default URL will be used.
28
+ */
29
+ static setInboxConfig(inboxConfig: SetInboxConfigProps): void;
30
+ /**
31
+ * Retrieves the current inbox configuration for the InboxFlowInstance.
32
+ *
33
+ * @returns {InboxConfigProps | undefined} The current inbox configuration if set,
34
+ * or `undefined` if no configuration has been initialized.
35
+ */
36
+ static getInboxConfig(): InboxConfigProps | undefined;
37
+ /**
38
+ * Resets the inbox configuration to `undefined`.
39
+ * This method can be used to clear the current configuration.
40
+ */
41
+ static resetInboxConfig(): void;
42
+ }
43
+ export { InboxFlowInstance };
44
+ //# sourceMappingURL=inboxFlowInstance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inboxFlowInstance.d.ts","sourceRoot":"","sources":["../../src/config/inboxFlowInstance.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AAEH,cAAM,iBAAiB;IACrB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAmB;IAE9C;;;;;;;;;;OAUG;IAEH,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,mBAAmB;IAWtD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,IAAI,gBAAgB,GAAG,SAAS;IAIrD;;;OAGG;IAEH,MAAM,CAAC,gBAAgB;CAGxB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The `InboxFlowInstance` class manages the configuration for the inbox flow.
3
+ * It allows you to set and retrieve the inbox configuration, including the channel ID,
4
+ * user token, and API URL.
5
+ */
6
+ class InboxFlowInstance {
7
+ static inboxConfig;
8
+ /**
9
+ * Sets the configuration for the inbox. This method initializes the inbox configuration
10
+ * with the provided `inboxConfig` values. If the configuration has already been set,
11
+ * the method will return early without making any changes.
12
+ *
13
+ * @param inboxConfig - An object containing the inbox configuration properties.
14
+ * @param inboxConfig.inboxChannelId - The key used to identify the inbox.
15
+ * @param inboxConfig.inboxUserToken - The user token for authenticating with the inbox.
16
+ * @param inboxConfig.inboxApiUrl - (Optional) The API URL for the inbox. If not provided,
17
+ * a default URL will be used.
18
+ */
19
+ static setInboxConfig(inboxConfig) {
20
+ const defaultInboxURL = `https://logs-inbox-flow-logs.vw6wo7.easypanel.host/api/call`;
21
+ if (!!this.inboxConfig)
22
+ return;
23
+ this.inboxConfig = {
24
+ inboxChannelId: inboxConfig.inboxChannelId,
25
+ inboxUserToken: inboxConfig.inboxUserToken,
26
+ inboxApiUrl: inboxConfig.inboxApiUrl || defaultInboxURL,
27
+ };
28
+ }
29
+ /**
30
+ * Retrieves the current inbox configuration for the InboxFlowInstance.
31
+ *
32
+ * @returns {InboxConfigProps | undefined} The current inbox configuration if set,
33
+ * or `undefined` if no configuration has been initialized.
34
+ */
35
+ static getInboxConfig() {
36
+ return this.inboxConfig;
37
+ }
38
+ /**
39
+ * Resets the inbox configuration to `undefined`.
40
+ * This method can be used to clear the current configuration.
41
+ */
42
+ static resetInboxConfig() {
43
+ this.inboxConfig = undefined;
44
+ }
45
+ }
46
+ export { InboxFlowInstance };
@@ -1,10 +1,33 @@
1
+ /**
2
+ * Represents an HTTP error response with a status code of 502 (Bad Gateway).
3
+ * This class is used to standardize the structure of a "Bad Gateway" error response,
4
+ * including the response body, headers, status, and status text.
5
+ */
1
6
  declare class BadGateway {
2
7
  body: any;
3
8
  cause?: any;
4
9
  status: number;
5
10
  statusText: string;
11
+ /**
12
+ * Creates an instance of the `BadGateway` class.
13
+ *
14
+ * @param message - A descriptive message explaining the cause of the error.
15
+ * @param cause - Optional additional information about the cause of the error.
16
+ */
6
17
  constructor(message: string, cause?: any);
18
+ /**
19
+ * Converts the `BadGateway` instance into a `Response` object with a JSON body.
20
+ * This method ensures the response has the appropriate headers, status, and status text.
21
+ *
22
+ * @returns A `Response` object with the serialized JSON body and response metadata.
23
+ */
7
24
  toResponse(): Response;
25
+ /**
26
+ * Converts the `BadGateway` instance into a `Response` object using the `Response.json` method.
27
+ * This method is an alternative to `toResponse` for generating JSON error responses.
28
+ *
29
+ * @returns A `Response` object with the JSON body and response metadata.
30
+ */
8
31
  toJson(): Response;
9
32
  }
10
33
  export { BadGateway };
@@ -1 +1 @@
1
- {"version":3,"file":"badGateway.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badGateway.ts"],"names":[],"mappings":"AAEA,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"badGateway.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badGateway.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,15 +1,32 @@
1
1
  import { httpDebug } from "../../services/httpDebug";
2
+ /**
3
+ * Represents an HTTP error response with a status code of 502 (Bad Gateway).
4
+ * This class is used to standardize the structure of a "Bad Gateway" error response,
5
+ * including the response body, headers, status, and status text.
6
+ */
2
7
  class BadGateway {
3
8
  body;
4
9
  cause;
5
10
  status = 502;
6
11
  statusText;
12
+ /**
13
+ * Creates an instance of the `BadGateway` class.
14
+ *
15
+ * @param message - A descriptive message explaining the cause of the error.
16
+ * @param cause - Optional additional information about the cause of the error.
17
+ */
7
18
  constructor(message, cause) {
8
19
  this.body = { name: "BadGateway", message: message };
9
20
  this.statusText = message;
10
21
  this.cause = cause ? JSON.stringify(cause) : undefined;
11
22
  httpDebug("BadGateway", this.body, this.cause);
12
23
  }
24
+ /**
25
+ * Converts the `BadGateway` instance into a `Response` object with a JSON body.
26
+ * This method ensures the response has the appropriate headers, status, and status text.
27
+ *
28
+ * @returns A `Response` object with the serialized JSON body and response metadata.
29
+ */
13
30
  toResponse() {
14
31
  const responseInit = {
15
32
  headers: { "Content-Type": "application/json" },
@@ -18,6 +35,12 @@ class BadGateway {
18
35
  };
19
36
  return new Response(JSON.stringify(this.body), responseInit);
20
37
  }
38
+ /**
39
+ * Converts the `BadGateway` instance into a `Response` object using the `Response.json` method.
40
+ * This method is an alternative to `toResponse` for generating JSON error responses.
41
+ *
42
+ * @returns A `Response` object with the JSON body and response metadata.
43
+ */
21
44
  toJson() {
22
45
  const responseInit = {
23
46
  status: this.status,
@@ -1,10 +1,33 @@
1
+ /**
2
+ * Represents an HTTP error response with a status code of 400 (Bad Request).
3
+ * This class is used to standardize the structure of a "Bad Request" error response,
4
+ * including the response body, headers, status, and status text.
5
+ */
1
6
  declare class BadRequest {
2
7
  body: any;
3
8
  cause?: any;
4
9
  status: number;
5
10
  statusText: string;
11
+ /**
12
+ * Creates an instance of the `BadRequest` class.
13
+ *
14
+ * @param message - A descriptive message explaining the cause of the error.
15
+ * @param cause - Optional additional information about the cause of the error.
16
+ */
6
17
  constructor(message: string, cause?: any);
18
+ /**
19
+ * Converts the `BadRequest` instance into a `Response` object with a JSON body.
20
+ * This method ensures the response has the appropriate headers, status, and status text.
21
+ *
22
+ * @returns A `Response` object with the serialized JSON body and response metadata.
23
+ */
7
24
  toResponse(): Response;
25
+ /**
26
+ * Converts the `BadRequest` instance into a `Response` object using the `Response.json` method.
27
+ * This method is an alternative to `toResponse` for generating JSON error responses.
28
+ *
29
+ * @returns A `Response` object with the JSON body and response metadata.
30
+ */
8
31
  toJson(): Response;
9
32
  }
10
33
  export { BadRequest };
@@ -1 +1 @@
1
- {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badRequest.ts"],"names":[],"mappings":"AAEA,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badRequest.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,15 +1,32 @@
1
1
  import { httpDebug } from "../../services/httpDebug";
2
+ /**
3
+ * Represents an HTTP error response with a status code of 400 (Bad Request).
4
+ * This class is used to standardize the structure of a "Bad Request" error response,
5
+ * including the response body, headers, status, and status text.
6
+ */
2
7
  class BadRequest {
3
8
  body;
4
9
  cause;
5
10
  status = 400;
6
11
  statusText;
12
+ /**
13
+ * Creates an instance of the `BadRequest` class.
14
+ *
15
+ * @param message - A descriptive message explaining the cause of the error.
16
+ * @param cause - Optional additional information about the cause of the error.
17
+ */
7
18
  constructor(message, cause) {
8
19
  this.body = { name: "BadRequest", message: message };
9
20
  this.statusText = message;
10
21
  this.cause = cause ? JSON.stringify(cause) : undefined;
11
22
  httpDebug("BadRequest", this.body, this.cause);
12
23
  }
24
+ /**
25
+ * Converts the `BadRequest` instance into a `Response` object with a JSON body.
26
+ * This method ensures the response has the appropriate headers, status, and status text.
27
+ *
28
+ * @returns A `Response` object with the serialized JSON body and response metadata.
29
+ */
13
30
  toResponse() {
14
31
  const responseInit = {
15
32
  headers: { "Content-Type": "application/json" },
@@ -18,6 +35,12 @@ class BadRequest {
18
35
  };
19
36
  return new Response(JSON.stringify(this.body), responseInit);
20
37
  }
38
+ /**
39
+ * Converts the `BadRequest` instance into a `Response` object using the `Response.json` method.
40
+ * This method is an alternative to `toResponse` for generating JSON error responses.
41
+ *
42
+ * @returns A `Response` object with the JSON body and response metadata.
43
+ */
21
44
  toJson() {
22
45
  const responseInit = {
23
46
  status: this.status,
@@ -1,10 +1,33 @@
1
+ /**
2
+ * Represents an HTTP error response with a status code of 409 (Conflict).
3
+ * This class is used to standardize the structure of a "Conflict" error response,
4
+ * including the response body, headers, status, and status text.
5
+ */
1
6
  declare class Conflict {
2
7
  body: any;
3
8
  cause?: any;
4
9
  status: number;
5
10
  statusText: string;
11
+ /**
12
+ * Creates an instance of the `Conflict` class.
13
+ *
14
+ * @param message - A descriptive message explaining the cause of the conflict.
15
+ * @param cause - Optional additional information about the cause of the conflict.
16
+ */
6
17
  constructor(message: string, cause?: any);
18
+ /**
19
+ * Converts the `Conflict` instance into a `Response` object with a JSON body.
20
+ * This method ensures the response has the appropriate headers, status, and status text.
21
+ *
22
+ * @returns A `Response` object with the serialized JSON body and response metadata.
23
+ */
7
24
  toResponse(): Response;
25
+ /**
26
+ * Converts the `Conflict` instance into a `Response` object using the `Response.json` method.
27
+ * This method is an alternative to `toResponse` for generating JSON error responses.
28
+ *
29
+ * @returns A `Response` object with the JSON body and response metadata.
30
+ */
8
31
  toJson(): Response;
9
32
  }
10
33
  export { Conflict };
@@ -1 +1 @@
1
- {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/conflict.ts"],"names":[],"mappings":"AAEA,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/conflict.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,15 +1,32 @@
1
1
  import { httpDebug } from "../../services/httpDebug";
2
+ /**
3
+ * Represents an HTTP error response with a status code of 409 (Conflict).
4
+ * This class is used to standardize the structure of a "Conflict" error response,
5
+ * including the response body, headers, status, and status text.
6
+ */
2
7
  class Conflict {
3
8
  body;
4
9
  cause;
5
10
  status = 409;
6
11
  statusText;
12
+ /**
13
+ * Creates an instance of the `Conflict` class.
14
+ *
15
+ * @param message - A descriptive message explaining the cause of the conflict.
16
+ * @param cause - Optional additional information about the cause of the conflict.
17
+ */
7
18
  constructor(message, cause) {
8
19
  this.body = { name: "Conflict", message: message };
9
20
  this.statusText = message;
10
21
  this.cause = cause ? JSON.stringify(cause) : undefined;
11
22
  httpDebug("Conflict", this.body, this.cause);
12
23
  }
24
+ /**
25
+ * Converts the `Conflict` instance into a `Response` object with a JSON body.
26
+ * This method ensures the response has the appropriate headers, status, and status text.
27
+ *
28
+ * @returns A `Response` object with the serialized JSON body and response metadata.
29
+ */
13
30
  toResponse() {
14
31
  const responseInit = {
15
32
  headers: { "Content-Type": "application/json" },
@@ -18,6 +35,12 @@ class Conflict {
18
35
  };
19
36
  return new Response(JSON.stringify(this.body), responseInit);
20
37
  }
38
+ /**
39
+ * Converts the `Conflict` instance into a `Response` object using the `Response.json` method.
40
+ * This method is an alternative to `toResponse` for generating JSON error responses.
41
+ *
42
+ * @returns A `Response` object with the JSON body and response metadata.
43
+ */
21
44
  toJson() {
22
45
  const responseInit = {
23
46
  status: this.status,
@@ -1,10 +1,33 @@
1
+ /**
2
+ * Represents an HTTP error response with a status code of 403 (Forbidden).
3
+ * This class is used to standardize the structure of a "Forbidden" error response,
4
+ * including the response body, headers, status, and status text.
5
+ */
1
6
  declare class Forbidden {
2
7
  body: any;
3
8
  cause?: any;
4
9
  status: number;
5
10
  statusText: string;
11
+ /**
12
+ * Creates an instance of the `Forbidden` class.
13
+ *
14
+ * @param message - A descriptive message explaining why access is forbidden.
15
+ * @param cause - Optional additional information about the cause of the error.
16
+ */
6
17
  constructor(message: string, cause?: any);
18
+ /**
19
+ * Converts the `Forbidden` instance into a `Response` object with a JSON body.
20
+ * This method ensures the response has the appropriate headers, status, and status text.
21
+ *
22
+ * @returns A `Response` object with the serialized JSON body and response metadata.
23
+ */
7
24
  toResponse(): Response;
25
+ /**
26
+ * Converts the `Forbidden` instance into a `Response` object using the `Response.json` method.
27
+ * This method is an alternative to `toResponse` for generating JSON error responses.
28
+ *
29
+ * @returns A `Response` object with the JSON body and response metadata.
30
+ */
8
31
  toJson(): Response;
9
32
  }
10
33
  export { Forbidden };
@@ -1 +1 @@
1
- {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/forbidden.ts"],"names":[],"mappings":"AAEA,cAAM,SAAS;IACb,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/forbidden.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,SAAS;IACb,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -1,15 +1,32 @@
1
1
  import { httpDebug } from "../../services/httpDebug";
2
+ /**
3
+ * Represents an HTTP error response with a status code of 403 (Forbidden).
4
+ * This class is used to standardize the structure of a "Forbidden" error response,
5
+ * including the response body, headers, status, and status text.
6
+ */
2
7
  class Forbidden {
3
8
  body;
4
9
  cause;
5
- status = 402;
10
+ status = 403;
6
11
  statusText;
12
+ /**
13
+ * Creates an instance of the `Forbidden` class.
14
+ *
15
+ * @param message - A descriptive message explaining why access is forbidden.
16
+ * @param cause - Optional additional information about the cause of the error.
17
+ */
7
18
  constructor(message, cause) {
8
19
  this.body = { name: "Forbidden", message: message };
9
20
  this.statusText = message;
10
21
  this.cause = cause ? JSON.stringify(cause) : undefined;
11
22
  httpDebug("Forbidden", this.body, this.cause);
12
23
  }
24
+ /**
25
+ * Converts the `Forbidden` instance into a `Response` object with a JSON body.
26
+ * This method ensures the response has the appropriate headers, status, and status text.
27
+ *
28
+ * @returns A `Response` object with the serialized JSON body and response metadata.
29
+ */
13
30
  toResponse() {
14
31
  const responseInit = {
15
32
  headers: { "Content-Type": "application/json" },
@@ -18,6 +35,12 @@ class Forbidden {
18
35
  };
19
36
  return new Response(JSON.stringify(this.body), responseInit);
20
37
  }
38
+ /**
39
+ * Converts the `Forbidden` instance into a `Response` object using the `Response.json` method.
40
+ * This method is an alternative to `toResponse` for generating JSON error responses.
41
+ *
42
+ * @returns A `Response` object with the JSON body and response metadata.
43
+ */
21
44
  toJson() {
22
45
  const responseInit = {
23
46
  status: this.status,
@@ -1,10 +1,33 @@
1
+ /**
2
+ * Represents an HTTP error response with a status code of 404 (Not Found).
3
+ * This class is used to standardize the structure of a "Not Found" error response,
4
+ * including the response body, headers, status, and status text.
5
+ */
1
6
  declare class NotFound {
2
7
  body: any;
3
8
  cause?: any;
4
9
  status: number;
5
10
  statusText: string;
11
+ /**
12
+ * Creates an instance of the `NotFound` class.
13
+ *
14
+ * @param message - A descriptive message explaining the reason the resource was not found.
15
+ * @param cause - Optional additional information about the cause of the error.
16
+ */
6
17
  constructor(message: string, cause?: any);
18
+ /**
19
+ * Converts the `NotFound` instance into a `Response` object with a JSON body.
20
+ * This method ensures the response has the appropriate headers, status, and status text.
21
+ *
22
+ * @returns A `Response` object with the serialized JSON body and response metadata.
23
+ */
7
24
  toResponse(): Response;
25
+ /**
26
+ * Converts the `NotFound` instance into a `Response` object using the `Response.json` method.
27
+ * This method is an alternative to `toResponse` for generating JSON error responses.
28
+ *
29
+ * @returns A `Response` object with the JSON body and response metadata.
30
+ */
8
31
  toJson(): Response;
9
32
  }
10
33
  export { NotFound };
@@ -1 +1 @@
1
- {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notFound.ts"],"names":[],"mappings":"AAEA,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notFound.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,15 +1,32 @@
1
1
  import { httpDebug } from "../../services/httpDebug";
2
+ /**
3
+ * Represents an HTTP error response with a status code of 404 (Not Found).
4
+ * This class is used to standardize the structure of a "Not Found" error response,
5
+ * including the response body, headers, status, and status text.
6
+ */
2
7
  class NotFound {
3
8
  body;
4
9
  cause;
5
10
  status = 404;
6
11
  statusText;
12
+ /**
13
+ * Creates an instance of the `NotFound` class.
14
+ *
15
+ * @param message - A descriptive message explaining the reason the resource was not found.
16
+ * @param cause - Optional additional information about the cause of the error.
17
+ */
7
18
  constructor(message, cause) {
8
19
  this.body = { name: "NotFound", message: message };
9
20
  this.statusText = message;
10
21
  this.cause = cause ? JSON.stringify(cause) : undefined;
11
22
  httpDebug("NotFound", this.body, this.cause);
12
23
  }
24
+ /**
25
+ * Converts the `NotFound` instance into a `Response` object with a JSON body.
26
+ * This method ensures the response has the appropriate headers, status, and status text.
27
+ *
28
+ * @returns A `Response` object with the serialized JSON body and response metadata.
29
+ */
13
30
  toResponse() {
14
31
  const responseInit = {
15
32
  headers: { "Content-Type": "application/json" },
@@ -18,6 +35,12 @@ class NotFound {
18
35
  };
19
36
  return new Response(JSON.stringify(this.body), responseInit);
20
37
  }
38
+ /**
39
+ * Converts the `NotFound` instance into a `Response` object using the `Response.json` method.
40
+ * This method is an alternative to `toResponse` for generating JSON error responses.
41
+ *
42
+ * @returns A `Response` object with the JSON body and response metadata.
43
+ */
21
44
  toJson() {
22
45
  const responseInit = {
23
46
  status: this.status,
@@ -1,10 +1,33 @@
1
+ /**
2
+ * Represents an HTTP error response with a status code of 501 (Not Implemented).
3
+ * This class is used to standardize the structure of a "Not Implemented" error response,
4
+ * including the response body, headers, status, and status text.
5
+ */
1
6
  declare class NotImplemented {
2
7
  body: any;
3
8
  cause?: any;
4
9
  status: number;
5
10
  statusText: string;
11
+ /**
12
+ * Creates an instance of the `NotImplemented` class.
13
+ *
14
+ * @param message - A descriptive message explaining why the functionality is not implemented.
15
+ * @param cause - Optional additional information about the cause of the error.
16
+ */
6
17
  constructor(message: string, cause?: any);
18
+ /**
19
+ * Converts the `NotImplemented` instance into a `Response` object with a JSON body.
20
+ * This method ensures the response has the appropriate headers, status, and status text.
21
+ *
22
+ * @returns A `Response` object with the serialized JSON body and response metadata.
23
+ */
7
24
  toResponse(): Response;
25
+ /**
26
+ * Converts the `NotImplemented` instance into a `Response` object using the `Response.json` method.
27
+ * This method is an alternative to `toResponse` for generating JSON error responses.
28
+ *
29
+ * @returns A `Response` object with the JSON body and response metadata.
30
+ */
8
31
  toJson(): Response;
9
32
  }
10
33
  export { NotImplemented };
@@ -1 +1 @@
1
- {"version":3,"file":"notImplemented.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notImplemented.ts"],"names":[],"mappings":"AAEA,cAAM,cAAc;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"notImplemented.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notImplemented.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,cAAc;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -1,15 +1,32 @@
1
1
  import { httpDebug } from "../../services/httpDebug";
2
+ /**
3
+ * Represents an HTTP error response with a status code of 501 (Not Implemented).
4
+ * This class is used to standardize the structure of a "Not Implemented" error response,
5
+ * including the response body, headers, status, and status text.
6
+ */
2
7
  class NotImplemented {
3
8
  body;
4
9
  cause;
5
10
  status = 501;
6
11
  statusText;
12
+ /**
13
+ * Creates an instance of the `NotImplemented` class.
14
+ *
15
+ * @param message - A descriptive message explaining why the functionality is not implemented.
16
+ * @param cause - Optional additional information about the cause of the error.
17
+ */
7
18
  constructor(message, cause) {
8
19
  this.body = { name: "NotImplemented", message: message };
9
20
  this.statusText = message;
10
21
  this.cause = cause ? JSON.stringify(cause) : undefined;
11
22
  httpDebug("NotImplemented", this.body, this.cause);
12
23
  }
24
+ /**
25
+ * Converts the `NotImplemented` instance into a `Response` object with a JSON body.
26
+ * This method ensures the response has the appropriate headers, status, and status text.
27
+ *
28
+ * @returns A `Response` object with the serialized JSON body and response metadata.
29
+ */
13
30
  toResponse() {
14
31
  const responseInit = {
15
32
  headers: { "Content-Type": "application/json" },
@@ -18,6 +35,12 @@ class NotImplemented {
18
35
  };
19
36
  return new Response(JSON.stringify(this.body), responseInit);
20
37
  }
38
+ /**
39
+ * Converts the `NotImplemented` instance into a `Response` object using the `Response.json` method.
40
+ * This method is an alternative to `toResponse` for generating JSON error responses.
41
+ *
42
+ * @returns A `Response` object with the JSON body and response metadata.
43
+ */
21
44
  toJson() {
22
45
  const responseInit = {
23
46
  status: this.status,
@@ -1,10 +1,33 @@
1
+ /**
2
+ * Represents an HTTP error response with a status code of 500 (Internal Server Error).
3
+ * This class is used to standardize the structure of a "Server Error" response,
4
+ * including the response body, headers, status, and status text.
5
+ */
1
6
  declare class ServerError {
2
7
  body: any;
3
8
  cause?: any;
4
9
  status: number;
5
10
  statusText: string;
11
+ /**
12
+ * Creates an instance of the `ServerError` class.
13
+ *
14
+ * @param message - A descriptive message explaining the cause of the server error.
15
+ * @param cause - Optional additional information about the cause of the error.
16
+ */
6
17
  constructor(message: string, cause?: any);
18
+ /**
19
+ * Converts the `ServerError` instance into a `Response` object with a JSON body.
20
+ * This method ensures the response has the appropriate headers, status, and status text.
21
+ *
22
+ * @returns A `Response` object with the serialized JSON body and response metadata.
23
+ */
7
24
  toResponse(): Response;
25
+ /**
26
+ * Converts the `ServerError` instance into a `Response` object using the `Response.json` method.
27
+ * This method is an alternative to `toResponse` for generating JSON error responses.
28
+ *
29
+ * @returns A `Response` object with the JSON body and response metadata.
30
+ */
8
31
  toJson(): Response;
9
32
  }
10
33
  export { ServerError };
@@ -1 +1 @@
1
- {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAEA,cAAM,WAAW;IACf,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,WAAW;IACf,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}