@arkyn/server 3.0.1-beta.143 → 3.0.1-beta.145

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 (96) hide show
  1. package/dist/bundle.js +90 -323
  2. package/dist/http/badResponses/badGateway.d.ts +12 -19
  3. package/dist/http/badResponses/badGateway.d.ts.map +1 -1
  4. package/dist/http/badResponses/badGateway.js +12 -19
  5. package/dist/http/badResponses/badRequest.d.ts +10 -19
  6. package/dist/http/badResponses/badRequest.d.ts.map +1 -1
  7. package/dist/http/badResponses/badRequest.js +10 -19
  8. package/dist/http/badResponses/conflict.d.ts +10 -19
  9. package/dist/http/badResponses/conflict.d.ts.map +1 -1
  10. package/dist/http/badResponses/conflict.js +10 -19
  11. package/dist/http/badResponses/forbidden.d.ts +10 -19
  12. package/dist/http/badResponses/forbidden.d.ts.map +1 -1
  13. package/dist/http/badResponses/forbidden.js +10 -19
  14. package/dist/http/badResponses/notFound.d.ts +10 -19
  15. package/dist/http/badResponses/notFound.d.ts.map +1 -1
  16. package/dist/http/badResponses/notFound.js +10 -19
  17. package/dist/http/badResponses/notImplemented.d.ts +10 -19
  18. package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
  19. package/dist/http/badResponses/notImplemented.js +10 -19
  20. package/dist/http/badResponses/serverError.d.ts +10 -19
  21. package/dist/http/badResponses/serverError.d.ts.map +1 -1
  22. package/dist/http/badResponses/serverError.js +10 -19
  23. package/dist/http/badResponses/unauthorized.d.ts +10 -19
  24. package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
  25. package/dist/http/badResponses/unauthorized.js +10 -19
  26. package/dist/http/badResponses/unprocessableEntity.d.ts +17 -22
  27. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
  28. package/dist/http/badResponses/unprocessableEntity.js +17 -22
  29. package/dist/http/successResponses/created.d.ts +10 -14
  30. package/dist/http/successResponses/created.d.ts.map +1 -1
  31. package/dist/http/successResponses/created.js +10 -14
  32. package/dist/http/successResponses/found.d.ts +10 -14
  33. package/dist/http/successResponses/found.d.ts.map +1 -1
  34. package/dist/http/successResponses/found.js +10 -14
  35. package/dist/http/successResponses/noContent.d.ts +9 -7
  36. package/dist/http/successResponses/noContent.d.ts.map +1 -1
  37. package/dist/http/successResponses/noContent.js +9 -7
  38. package/dist/http/successResponses/success.d.ts +10 -14
  39. package/dist/http/successResponses/success.d.ts.map +1 -1
  40. package/dist/http/successResponses/success.js +10 -14
  41. package/dist/http/successResponses/updated.d.ts +11 -14
  42. package/dist/http/successResponses/updated.d.ts.map +1 -1
  43. package/dist/http/successResponses/updated.js +11 -14
  44. package/dist/services/apiService.d.ts +20 -0
  45. package/dist/services/apiService.d.ts.map +1 -1
  46. package/dist/services/apiService.js +16 -0
  47. package/dist/services/debugService.d.ts +10 -42
  48. package/dist/services/debugService.d.ts.map +1 -1
  49. package/dist/services/debugService.js +10 -42
  50. package/dist/services/logService.d.ts +5 -10
  51. package/dist/services/logService.d.ts.map +1 -1
  52. package/dist/services/logService.js +5 -10
  53. package/dist/utilities/decodeRequestBody.d.ts +11 -9
  54. package/dist/utilities/decodeRequestBody.d.ts.map +1 -1
  55. package/dist/utilities/decodeRequestBody.js +11 -9
  56. package/dist/utilities/decodeRequestErrorMessage.d.ts +12 -10
  57. package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -1
  58. package/dist/utilities/decodeRequestErrorMessage.js +12 -10
  59. package/dist/utilities/errorHandler.d.ts +13 -38
  60. package/dist/utilities/errorHandler.d.ts.map +1 -1
  61. package/dist/utilities/errorHandler.js +13 -38
  62. package/dist/utilities/flushDebugLogs.d.ts +6 -28
  63. package/dist/utilities/flushDebugLogs.d.ts.map +1 -1
  64. package/dist/utilities/flushDebugLogs.js +6 -28
  65. package/dist/utilities/formAsyncParse.d.ts +7 -28
  66. package/dist/utilities/formAsyncParse.d.ts.map +1 -1
  67. package/dist/utilities/formAsyncParse.js +7 -28
  68. package/dist/utilities/formParse.d.ts +7 -28
  69. package/dist/utilities/formParse.d.ts.map +1 -1
  70. package/dist/utilities/formParse.js +7 -28
  71. package/dist/utilities/getScopedParams.d.ts +11 -19
  72. package/dist/utilities/getScopedParams.d.ts.map +1 -1
  73. package/dist/utilities/getScopedParams.js +11 -19
  74. package/dist/utilities/schemaValidator.d.ts +31 -102
  75. package/dist/utilities/schemaValidator.d.ts.map +1 -1
  76. package/dist/utilities/schemaValidator.js +31 -102
  77. package/dist/validations/validateCep.d.ts +2 -2
  78. package/dist/validations/validateCep.js +2 -2
  79. package/dist/validations/validateCnpj.d.ts +2 -2
  80. package/dist/validations/validateCnpj.js +2 -2
  81. package/dist/validations/validateCpf.d.ts +4 -11
  82. package/dist/validations/validateCpf.d.ts.map +1 -1
  83. package/dist/validations/validateCpf.js +4 -11
  84. package/dist/validations/validateDate.d.ts +7 -11
  85. package/dist/validations/validateDate.d.ts.map +1 -1
  86. package/dist/validations/validateDate.js +7 -11
  87. package/dist/validations/validateEmail.d.ts +2 -2
  88. package/dist/validations/validateEmail.js +2 -2
  89. package/dist/validations/validatePassword.d.ts +2 -2
  90. package/dist/validations/validatePassword.js +2 -2
  91. package/dist/validations/validatePhone.d.ts +6 -18
  92. package/dist/validations/validatePhone.d.ts.map +1 -1
  93. package/dist/validations/validatePhone.js +6 -18
  94. package/dist/validations/validateRg.d.ts +2 -2
  95. package/dist/validations/validateRg.js +2 -2
  96. package/package.json +1 -1
@@ -1,30 +1,21 @@
1
1
  import { BadResponse } from "./_badResponse";
2
2
  /**
3
- * Represents an HTTP error response with a status code of 500 (Internal Server Error).
4
- * This class is used to standardize the structure of a "Server Error" response,
5
- * including the response body, headers, status, and status text.
3
+ * HTTP 500 Internal Server Error an unexpected condition prevented the server from fulfilling the request.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * throw new ServerError("Failed to connect to the database");
8
+ * ```
6
9
  */
7
10
  declare class ServerError extends BadResponse {
8
11
  /**
9
- * Creates an instance of the `ServerError` class.
10
- *
11
- * @param {string} message - A descriptive message explaining the cause of the server error.
12
- * @param {any} cause - Optional additional information about the cause of the error.
12
+ * @param message - Error description.
13
+ * @param cause - Optional extra context (serialized to JSON).
13
14
  */
14
15
  constructor(message: string, cause?: any);
15
- /**
16
- * Converts the `ServerError` instance into a `Response` object with a JSON body.
17
- * This method ensures the response has the appropriate headers, status, and status text.
18
- *
19
- * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
20
- */
16
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
21
17
  toResponse(): Response;
22
- /**
23
- * Converts the `ServerError` instance into a `Response` object using the `Response.json` method.
24
- * This method is an alternative to `toResponse` for generating JSON error responses.
25
- *
26
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
27
- */
18
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
28
19
  toJson(): Response;
29
20
  }
30
21
  export { ServerError };
@@ -1 +1 @@
1
- {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,WAAY,SAAQ,WAAW;IACnC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAWxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;GAOG;AACH,cAAM,WAAY,SAAQ,WAAW;IACnC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAWxC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,15 +1,16 @@
1
1
  import { BadResponse } from "./_badResponse";
2
2
  /**
3
- * Represents an HTTP error response with a status code of 500 (Internal Server Error).
4
- * This class is used to standardize the structure of a "Server Error" response,
5
- * including the response body, headers, status, and status text.
3
+ * HTTP 500 Internal Server Error an unexpected condition prevented the server from fulfilling the request.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * throw new ServerError("Failed to connect to the database");
8
+ * ```
6
9
  */
7
10
  class ServerError extends BadResponse {
8
11
  /**
9
- * Creates an instance of the `ServerError` class.
10
- *
11
- * @param {string} message - A descriptive message explaining the cause of the server error.
12
- * @param {any} cause - Optional additional information about the cause of the error.
12
+ * @param message - Error description.
13
+ * @param cause - Optional extra context (serialized to JSON).
13
14
  */
14
15
  constructor(message, cause) {
15
16
  super();
@@ -19,12 +20,7 @@ class ServerError extends BadResponse {
19
20
  this.cause = cause ? JSON.stringify(cause) : undefined;
20
21
  this.onDebug();
21
22
  }
22
- /**
23
- * Converts the `ServerError` instance into a `Response` object with a JSON body.
24
- * This method ensures the response has the appropriate headers, status, and status text.
25
- *
26
- * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
27
- */
23
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
28
24
  toResponse() {
29
25
  const responseInit = {
30
26
  headers: { "Content-Type": "application/json" },
@@ -33,12 +29,7 @@ class ServerError extends BadResponse {
33
29
  };
34
30
  return new Response(JSON.stringify(this.makeBody()), responseInit);
35
31
  }
36
- /**
37
- * Converts the `ServerError` instance into a `Response` object using the `Response.json` method.
38
- * This method is an alternative to `toResponse` for generating JSON error responses.
39
- *
40
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
41
- */
32
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
42
33
  toJson() {
43
34
  const responseInit = {
44
35
  status: this.status,
@@ -1,30 +1,21 @@
1
1
  import { BadResponse } from "./_badResponse";
2
2
  /**
3
- * Represents an HTTP error response with a status code of 401 (Unauthorized).
4
- * This class is used to standardize the structure of an "Unauthorized" error response,
5
- * including the response body, headers, status, and status text.
3
+ * HTTP 401 Unauthorized the request lacks valid authentication credentials.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * throw new Unauthorized("Invalid or expired token");
8
+ * ```
6
9
  */
7
10
  declare class Unauthorized extends BadResponse {
8
11
  /**
9
- * Creates an instance of the `Unauthorized` class.
10
- *
11
- * @param message - A descriptive message explaining why the request is unauthorized.
12
- * @param cause - Optional additional information about the cause of the error.
12
+ * @param message - Error description.
13
+ * @param cause - Optional extra context (serialized to JSON).
13
14
  */
14
15
  constructor(message: string, cause?: any);
15
- /**
16
- * Converts the `Unauthorized` instance into a `Response` object with a JSON body.
17
- * This method ensures the response has the appropriate headers, status, and status text.
18
- *
19
- * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
20
- */
16
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
21
17
  toResponse(): Response;
22
- /**
23
- * Converts the `Unauthorized` instance into a `Response` object using the `Response.json` method.
24
- * This method is an alternative to `toResponse` for generating JSON error responses.
25
- *
26
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
27
- */
18
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
28
19
  toJson(): Response;
29
20
  }
30
21
  export { Unauthorized };
@@ -1 +1 @@
1
- {"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,YAAa,SAAQ,WAAW;IACpC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAYxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;GAOG;AACH,cAAM,YAAa,SAAQ,WAAW;IACpC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAYxC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1,15 +1,16 @@
1
1
  import { BadResponse } from "./_badResponse";
2
2
  /**
3
- * Represents an HTTP error response with a status code of 401 (Unauthorized).
4
- * This class is used to standardize the structure of an "Unauthorized" error response,
5
- * including the response body, headers, status, and status text.
3
+ * HTTP 401 Unauthorized the request lacks valid authentication credentials.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * throw new Unauthorized("Invalid or expired token");
8
+ * ```
6
9
  */
7
10
  class Unauthorized extends BadResponse {
8
11
  /**
9
- * Creates an instance of the `Unauthorized` class.
10
- *
11
- * @param message - A descriptive message explaining why the request is unauthorized.
12
- * @param cause - Optional additional information about the cause of the error.
12
+ * @param message - Error description.
13
+ * @param cause - Optional extra context (serialized to JSON).
13
14
  */
14
15
  constructor(message, cause) {
15
16
  super();
@@ -20,12 +21,7 @@ class Unauthorized extends BadResponse {
20
21
  this.cause = cause ? JSON.stringify(cause) : undefined;
21
22
  this.onDebug();
22
23
  }
23
- /**
24
- * Converts the `Unauthorized` instance into a `Response` object with a JSON body.
25
- * This method ensures the response has the appropriate headers, status, and status text.
26
- *
27
- * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
28
- */
24
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
29
25
  toResponse() {
30
26
  const responseInit = {
31
27
  headers: { "Content-Type": "application/json" },
@@ -34,12 +30,7 @@ class Unauthorized extends BadResponse {
34
30
  };
35
31
  return new Response(JSON.stringify(this.makeBody()), responseInit);
36
32
  }
37
- /**
38
- * Converts the `Unauthorized` instance into a `Response` object using the `Response.json` method.
39
- * This method is an alternative to `toResponse` for generating JSON error responses.
40
- *
41
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
42
- */
33
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
43
34
  toJson() {
44
35
  const responseInit = {
45
36
  status: this.status,
@@ -1,18 +1,23 @@
1
1
  import { BadResponse } from "./_badResponse";
2
2
  /**
3
- * Represents an HTTP error response with a status code of 422 (Unprocessable Entity).
4
- * This class is used to standardize the structure of an "Unprocessable Entity" error response,
5
- * including the response body, headers, status, and status text.
3
+ * HTTP 422 Unprocessable Entity the request is well-formed but contains semantic validation errors.
4
+ * Typically used for form field validation failures.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * throw new UnprocessableEntity({
9
+ * message: "Validation failed",
10
+ * fieldErrors: { email: "Invalid email format", age: "Must be 18 or older" },
11
+ * fields: { email: "not-an-email", age: "15" },
12
+ * });
13
+ * ```
6
14
  */
7
15
  declare class UnprocessableEntity extends BadResponse {
8
16
  /**
9
- * Creates an instance of the `UnprocessableEntity` class.
10
- *
11
- * @param {object} props - An object containing details about the error, such as:
12
- * @param {any} [props.data] - `data`: Additional data related to the error.
13
- * @param {Record<string, string>} [props.fieldErrors] - `fieldErrors`: A record of field-specific error messages.
14
- * @param {Record<string, string>} [props.fields] - `fields`: A record of field values that caused the error.
15
- * @param {string} [props.message] - `message`: A descriptive message explaining the error.
17
+ * @param props.message - Human-readable description of the error.
18
+ * @param props.fieldErrors - Per-field validation messages keyed by field name.
19
+ * @param props.fields - Original submitted field values (useful for repopulating forms).
20
+ * @param props.data - Any extra data to include in the response body.
16
21
  */
17
22
  constructor(props: {
18
23
  data?: any;
@@ -20,19 +25,9 @@ declare class UnprocessableEntity extends BadResponse {
20
25
  fields?: Record<string, string>;
21
26
  message?: string;
22
27
  });
23
- /**
24
- * Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
25
- * This method ensures the response has the appropriate headers, status, and status text.
26
- *
27
- * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
28
- */
28
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
29
29
  toResponse(): Response;
30
- /**
31
- * Converts the `UnprocessableEntity` instance into a `Response` object using the `Response.json` method.
32
- * This method is an alternative to `toResponse` for generating JSON error responses.
33
- *
34
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
35
- */
30
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
36
31
  toJson(): Response;
37
32
  }
38
33
  export { UnprocessableEntity };
@@ -1 +1 @@
1
- {"version":3,"file":"unprocessableEntity.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unprocessableEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,mBAAoB,SAAQ,WAAW;IAC3C;;;;;;;;OAQG;gBAES,KAAK,EAAE;QACjB,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAgBD;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"unprocessableEntity.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unprocessableEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,cAAM,mBAAoB,SAAQ,WAAW;IAC3C;;;;;OAKG;gBACS,KAAK,EAAE;QACjB,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAgBD,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -1,18 +1,23 @@
1
1
  import { BadResponse } from "./_badResponse";
2
2
  /**
3
- * Represents an HTTP error response with a status code of 422 (Unprocessable Entity).
4
- * This class is used to standardize the structure of an "Unprocessable Entity" error response,
5
- * including the response body, headers, status, and status text.
3
+ * HTTP 422 Unprocessable Entity the request is well-formed but contains semantic validation errors.
4
+ * Typically used for form field validation failures.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * throw new UnprocessableEntity({
9
+ * message: "Validation failed",
10
+ * fieldErrors: { email: "Invalid email format", age: "Must be 18 or older" },
11
+ * fields: { email: "not-an-email", age: "15" },
12
+ * });
13
+ * ```
6
14
  */
7
15
  class UnprocessableEntity extends BadResponse {
8
16
  /**
9
- * Creates an instance of the `UnprocessableEntity` class.
10
- *
11
- * @param {object} props - An object containing details about the error, such as:
12
- * @param {any} [props.data] - `data`: Additional data related to the error.
13
- * @param {Record<string, string>} [props.fieldErrors] - `fieldErrors`: A record of field-specific error messages.
14
- * @param {Record<string, string>} [props.fields] - `fields`: A record of field values that caused the error.
15
- * @param {string} [props.message] - `message`: A descriptive message explaining the error.
17
+ * @param props.message - Human-readable description of the error.
18
+ * @param props.fieldErrors - Per-field validation messages keyed by field name.
19
+ * @param props.fields - Original submitted field values (useful for repopulating forms).
20
+ * @param props.data - Any extra data to include in the response body.
16
21
  */
17
22
  constructor(props) {
18
23
  super();
@@ -27,12 +32,7 @@ class UnprocessableEntity extends BadResponse {
27
32
  };
28
33
  this.onDebug();
29
34
  }
30
- /**
31
- * Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
32
- * This method ensures the response has the appropriate headers, status, and status text.
33
- *
34
- * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
35
- */
35
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
36
36
  toResponse() {
37
37
  const responseInit = {
38
38
  headers: { "Content-Type": "application/json" },
@@ -41,12 +41,7 @@ class UnprocessableEntity extends BadResponse {
41
41
  };
42
42
  return new Response(JSON.stringify(this.makeBody()), responseInit);
43
43
  }
44
- /**
45
- * Converts the `UnprocessableEntity` instance into a `Response` object using the `Response.json` method.
46
- * This method is an alternative to `toResponse` for generating JSON error responses.
47
- *
48
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
49
- */
44
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
50
45
  toJson() {
51
46
  const responseInit = {
52
47
  status: this.status,
@@ -1,25 +1,21 @@
1
1
  import { SuccessResponse } from "./_successResponse";
2
2
  /**
3
- * Class representing a successful HTTP 201 Created response.
3
+ * HTTP 201 Created — the request succeeded and a new resource was created.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * return new Created("User created successfully", { id: user.id }).toJson();
8
+ * ```
4
9
  */
5
10
  declare class Created extends SuccessResponse {
6
11
  /**
7
- * Creates an instance of the `Created` class.
8
- *
9
- * @param {string} message - A message describing the creation status.
10
- * @param {any} body - The response body to be included in the HTTP response.
12
+ * @param message - Description included in the response status text.
13
+ * @param body - Data to include in the response body.
11
14
  */
12
15
  constructor(message: string, body?: any);
13
- /**
14
- * Converts the `Created` instance into a `Response` object.
15
- * @returns {Response} A `Response` object with the body and response metadata.
16
- */
16
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
17
17
  toResponse(): Response;
18
- /**
19
- * Converts the `Created` instance into a `Response` object using the `Response.json` method.
20
- * This method is an alternative to `toResponse` for generating JSON responses.
21
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
22
- */
18
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
23
19
  toJson(): Response;
24
20
  }
25
21
  export { Created };
@@ -1 +1 @@
1
- {"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/created.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AAEH,cAAM,OAAQ,SAAQ,eAAe;IACnC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC;;;OAGG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;OAIG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/created.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;GAOG;AACH,cAAM,OAAQ,SAAQ,eAAe;IACnC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,13 +1,16 @@
1
1
  import { SuccessResponse } from "./_successResponse";
2
2
  /**
3
- * Class representing a successful HTTP 201 Created response.
3
+ * HTTP 201 Created — the request succeeded and a new resource was created.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * return new Created("User created successfully", { id: user.id }).toJson();
8
+ * ```
4
9
  */
5
10
  class Created extends SuccessResponse {
6
11
  /**
7
- * Creates an instance of the `Created` class.
8
- *
9
- * @param {string} message - A message describing the creation status.
10
- * @param {any} body - The response body to be included in the HTTP response.
12
+ * @param message - Description included in the response status text.
13
+ * @param body - Data to include in the response body.
11
14
  */
12
15
  constructor(message, body) {
13
16
  super();
@@ -17,10 +20,7 @@ class Created extends SuccessResponse {
17
20
  this.body = body || undefined;
18
21
  this.onDebug();
19
22
  }
20
- /**
21
- * Converts the `Created` instance into a `Response` object.
22
- * @returns {Response} A `Response` object with the body and response metadata.
23
- */
23
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
24
24
  toResponse() {
25
25
  const responseInit = {
26
26
  headers: { "Content-Type": "application/json" },
@@ -29,11 +29,7 @@ class Created extends SuccessResponse {
29
29
  };
30
30
  return new Response(JSON.stringify(this.body), responseInit);
31
31
  }
32
- /**
33
- * Converts the `Created` instance into a `Response` object using the `Response.json` method.
34
- * This method is an alternative to `toResponse` for generating JSON responses.
35
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
36
- */
32
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
37
33
  toJson() {
38
34
  const responseInit = {
39
35
  status: this.status,
@@ -1,25 +1,21 @@
1
1
  import { SuccessResponse } from "./_successResponse";
2
2
  /**
3
- * Class representing a successful HTTP 302 Found response.
3
+ * HTTP 302 Found the resource was located and the response includes it in the body.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * return new Found("Products retrieved", { products }).toJson();
8
+ * ```
4
9
  */
5
10
  declare class Found extends SuccessResponse {
6
11
  /**
7
- * Creates an instance of the `Found` class.
8
- *
9
- * @param {string} message - A message describing the creation status.
10
- * @param {any} body - The response body to be included in the HTTP response.
12
+ * @param message - Description included in the response status text.
13
+ * @param body - Data to include in the response body.
11
14
  */
12
15
  constructor(message: string, body?: any);
13
- /**
14
- * Converts the `Found` instance into a `Response` object.
15
- * @returns {Response} A `Response` object with the body and response metadata.
16
- */
16
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
17
17
  toResponse(): Response;
18
- /**
19
- * Converts the `Found` instance into a `Response` object using the `Response.json` method.
20
- * This method is an alternative to `toResponse` for generating JSON responses.
21
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
22
- */
18
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
23
19
  toJson(): Response;
24
20
  }
25
21
  export { Found };
@@ -1 +1 @@
1
- {"version":3,"file":"found.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/found.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AAEH,cAAM,KAAM,SAAQ,eAAe;IACjC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC;;;OAGG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;OAIG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"found.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/found.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;GAOG;AACH,cAAM,KAAM,SAAQ,eAAe;IACjC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -1,13 +1,16 @@
1
1
  import { SuccessResponse } from "./_successResponse";
2
2
  /**
3
- * Class representing a successful HTTP 302 Found response.
3
+ * HTTP 302 Found the resource was located and the response includes it in the body.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * return new Found("Products retrieved", { products }).toJson();
8
+ * ```
4
9
  */
5
10
  class Found extends SuccessResponse {
6
11
  /**
7
- * Creates an instance of the `Found` class.
8
- *
9
- * @param {string} message - A message describing the creation status.
10
- * @param {any} body - The response body to be included in the HTTP response.
12
+ * @param message - Description included in the response status text.
13
+ * @param body - Data to include in the response body.
11
14
  */
12
15
  constructor(message, body) {
13
16
  super();
@@ -17,10 +20,7 @@ class Found extends SuccessResponse {
17
20
  this.body = body || undefined;
18
21
  this.onDebug();
19
22
  }
20
- /**
21
- * Converts the `Found` instance into a `Response` object.
22
- * @returns {Response} A `Response` object with the body and response metadata.
23
- */
23
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
24
24
  toResponse() {
25
25
  const responseInit = {
26
26
  headers: { "Content-Type": "application/json" },
@@ -29,11 +29,7 @@ class Found extends SuccessResponse {
29
29
  };
30
30
  return new Response(JSON.stringify(this.body), responseInit);
31
31
  }
32
- /**
33
- * Converts the `Found` instance into a `Response` object using the `Response.json` method.
34
- * This method is an alternative to `toResponse` for generating JSON responses.
35
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
36
- */
32
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
37
33
  toJson() {
38
34
  const responseInit = {
39
35
  status: this.status,
@@ -1,17 +1,19 @@
1
1
  import { SuccessResponse } from "./_successResponse";
2
2
  /**
3
- * Class representing a successful HTTP 204 NoContent response.
3
+ * HTTP 204 No Content the request succeeded but there is no content to return.
4
+ * Typically used for delete or update operations where a body is not needed.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * return new NoContent("Record deleted").toResponse();
9
+ * ```
4
10
  */
5
11
  declare class NoContent extends SuccessResponse {
6
12
  /**
7
- * Creates an instance of the `NoContent` class.
8
- * @param {string} message - A message describing the creation status.
13
+ * @param message - Description included in the response status text.
9
14
  */
10
15
  constructor(message: string);
11
- /**
12
- * Converts the `NoContent` instance into a `Response` object.
13
- * @returns {Response} A `Response` object with the body and response metadata.
14
- */
16
+ /** Converts to a `Response` with `Content-Type: application/json` header and no body. */
15
17
  toResponse(): Response;
16
18
  }
17
19
  export { NoContent };
@@ -1 +1 @@
1
- {"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/noContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AAEH,cAAM,SAAU,SAAQ,eAAe;IACrC;;;OAGG;gBAES,OAAO,EAAE,MAAM;IAU3B;;;OAGG;IAEH,UAAU,IAAI,QAAQ;CASvB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/noContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;GAQG;AACH,cAAM,SAAU,SAAQ,eAAe;IACrC;;OAEG;gBACS,OAAO,EAAE,MAAM;IAU3B,yFAAyF;IACzF,UAAU,IAAI,QAAQ;CASvB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -1,11 +1,16 @@
1
1
  import { SuccessResponse } from "./_successResponse";
2
2
  /**
3
- * Class representing a successful HTTP 204 NoContent response.
3
+ * HTTP 204 No Content the request succeeded but there is no content to return.
4
+ * Typically used for delete or update operations where a body is not needed.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * return new NoContent("Record deleted").toResponse();
9
+ * ```
4
10
  */
5
11
  class NoContent extends SuccessResponse {
6
12
  /**
7
- * Creates an instance of the `NoContent` class.
8
- * @param {string} message - A message describing the creation status.
13
+ * @param message - Description included in the response status text.
9
14
  */
10
15
  constructor(message) {
11
16
  super();
@@ -14,10 +19,7 @@ class NoContent extends SuccessResponse {
14
19
  this.statusText = message;
15
20
  this.onDebug();
16
21
  }
17
- /**
18
- * Converts the `NoContent` instance into a `Response` object.
19
- * @returns {Response} A `Response` object with the body and response metadata.
20
- */
22
+ /** Converts to a `Response` with `Content-Type: application/json` header and no body. */
21
23
  toResponse() {
22
24
  const responseInit = {
23
25
  headers: { "Content-Type": "application/json" },
@@ -1,25 +1,21 @@
1
1
  import { SuccessResponse } from "./_successResponse";
2
2
  /**
3
- * Class representing a successful HTTP 200 Success response.
3
+ * HTTP 200 OK the request succeeded and the response body contains the result.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * return new Success("Order fetched", { order }).toJson();
8
+ * ```
4
9
  */
5
10
  declare class Success extends SuccessResponse {
6
11
  /**
7
- * Creates an instance of the `Success` class.
8
- *
9
- * @param {string} message - A message describing the creation status.
10
- * @param {any} body - The response body to be included in the HTTP response.
12
+ * @param message - Description included in the response status text.
13
+ * @param body - Data to include in the response body.
11
14
  */
12
15
  constructor(message: string, body?: any);
13
- /**
14
- * Converts the `Success` instance into a `Response` object.
15
- * @returns {Response} A `Response` object with the body and response metadata.
16
- */
16
+ /** Converts to a `Response` with `Content-Type: application/json` header. */
17
17
  toResponse(): Response;
18
- /**
19
- * Converts the `Success` instance into a `Response` object using the `Response.json` method.
20
- * This method is an alternative to `toResponse` for generating JSON responses.
21
- * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
22
- */
18
+ /** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
23
19
  toJson(): Response;
24
20
  }
25
21
  export { Success };
@@ -1 +1 @@
1
- {"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/success.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AAEH,cAAM,OAAQ,SAAQ,eAAe;IACnC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC;;;OAGG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;OAIG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/success.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;GAOG;AACH,cAAM,OAAQ,SAAQ,eAAe;IACnC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}