@marianmeres/http-utils 1.11.0 → 1.12.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.
package/dist/error.d.ts CHANGED
@@ -44,6 +44,11 @@ declare class Gone extends HttpError {
44
44
  status: number;
45
45
  statusText: string;
46
46
  }
47
+ declare class UnprocessableContent extends HttpError {
48
+ name: string;
49
+ status: number;
50
+ statusText: string;
51
+ }
47
52
  declare class ImATeapot extends HttpError {
48
53
  name: string;
49
54
  status: number;
@@ -78,10 +83,11 @@ export declare const HTTP_ERROR: {
78
83
  Conflict: typeof Conflict;
79
84
  Gone: typeof Gone;
80
85
  ImATeapot: typeof ImATeapot;
86
+ UnprocessableContent: typeof UnprocessableContent;
81
87
  InternalServerError: typeof InternalServerError;
82
88
  NotImplemented: typeof NotImplemented;
83
89
  BadGateway: typeof BadGateway;
84
90
  ServiceUnavailable: typeof ServiceUnavailable;
85
91
  };
86
- export declare const createHttpError: (code: number | string, message?: string | null, body?: string | null, cause?: any) => BadRequest | Unauthorized | Forbidden | NotFound | MethodNotAllowed | RequestTimeout | Conflict | Gone | ImATeapot | InternalServerError | NotImplemented | BadGateway | ServiceUnavailable;
92
+ export declare const createHttpError: (code: number | string, message?: string | null, body?: string | null, cause?: any) => BadRequest | Unauthorized | Forbidden | NotFound | MethodNotAllowed | RequestTimeout | Conflict | Gone | UnprocessableContent | ImATeapot | InternalServerError | NotImplemented | BadGateway | ServiceUnavailable;
87
93
  export {};
package/dist/index.cjs CHANGED
@@ -103,6 +103,7 @@ class HTTP_STATUS {
103
103
  static METHOD_NOT_ALLOWED = HTTP_STATUS.ERROR_CLIENT.METHOD_NOT_ALLOWED.CODE;
104
104
  static CONFLICT = HTTP_STATUS.ERROR_CLIENT.CONFLICT.CODE;
105
105
  static GONE = HTTP_STATUS.ERROR_CLIENT.GONE.CODE;
106
+ static UNPROCESSABLE_CONTENT = HTTP_STATUS.ERROR_CLIENT.UNPROCESSABLE_CONTENT.CODE;
106
107
  // 5xx
107
108
  static INTERNAL_SERVER_ERROR = HTTP_STATUS.ERROR_SERVER.INTERNAL_SERVER_ERROR.CODE;
108
109
  static NOT_IMPLEMENTED = HTTP_STATUS.ERROR_SERVER.NOT_IMPLEMENTED.CODE;
@@ -173,6 +174,11 @@ class Gone extends HttpError {
173
174
  status = HTTP_STATUS.ERROR_CLIENT.GONE.CODE;
174
175
  statusText = HTTP_STATUS.ERROR_CLIENT.GONE.TEXT;
175
176
  }
177
+ class UnprocessableContent extends HttpError {
178
+ name = 'HttpUnprocessableContentError';
179
+ status = HTTP_STATUS.ERROR_CLIENT.UNPROCESSABLE_CONTENT.CODE;
180
+ statusText = HTTP_STATUS.ERROR_CLIENT.UNPROCESSABLE_CONTENT.TEXT;
181
+ }
176
182
  class ImATeapot extends HttpError {
177
183
  name = 'HttpImATeapotError';
178
184
  status = HTTP_STATUS.ERROR_CLIENT.IM_A_TEAPOT.CODE;
@@ -211,6 +217,7 @@ const HTTP_ERROR = {
211
217
  Conflict,
212
218
  Gone,
213
219
  ImATeapot,
220
+ UnprocessableContent,
214
221
  // server
215
222
  InternalServerError,
216
223
  NotImplemented,
@@ -227,6 +234,7 @@ const _wellKnownCtorMap = {
227
234
  '409': Conflict,
228
235
  '410': Gone,
229
236
  '418': ImATeapot,
237
+ '422': UnprocessableContent,
230
238
  //
231
239
  '500': InternalServerError,
232
240
  '501': NotImplemented,
package/dist/index.js CHANGED
@@ -101,6 +101,7 @@ class HTTP_STATUS {
101
101
  static METHOD_NOT_ALLOWED = HTTP_STATUS.ERROR_CLIENT.METHOD_NOT_ALLOWED.CODE;
102
102
  static CONFLICT = HTTP_STATUS.ERROR_CLIENT.CONFLICT.CODE;
103
103
  static GONE = HTTP_STATUS.ERROR_CLIENT.GONE.CODE;
104
+ static UNPROCESSABLE_CONTENT = HTTP_STATUS.ERROR_CLIENT.UNPROCESSABLE_CONTENT.CODE;
104
105
  // 5xx
105
106
  static INTERNAL_SERVER_ERROR = HTTP_STATUS.ERROR_SERVER.INTERNAL_SERVER_ERROR.CODE;
106
107
  static NOT_IMPLEMENTED = HTTP_STATUS.ERROR_SERVER.NOT_IMPLEMENTED.CODE;
@@ -171,6 +172,11 @@ class Gone extends HttpError {
171
172
  status = HTTP_STATUS.ERROR_CLIENT.GONE.CODE;
172
173
  statusText = HTTP_STATUS.ERROR_CLIENT.GONE.TEXT;
173
174
  }
175
+ class UnprocessableContent extends HttpError {
176
+ name = 'HttpUnprocessableContentError';
177
+ status = HTTP_STATUS.ERROR_CLIENT.UNPROCESSABLE_CONTENT.CODE;
178
+ statusText = HTTP_STATUS.ERROR_CLIENT.UNPROCESSABLE_CONTENT.TEXT;
179
+ }
174
180
  class ImATeapot extends HttpError {
175
181
  name = 'HttpImATeapotError';
176
182
  status = HTTP_STATUS.ERROR_CLIENT.IM_A_TEAPOT.CODE;
@@ -209,6 +215,7 @@ const HTTP_ERROR = {
209
215
  Conflict,
210
216
  Gone,
211
217
  ImATeapot,
218
+ UnprocessableContent,
212
219
  // server
213
220
  InternalServerError,
214
221
  NotImplemented,
@@ -225,6 +232,7 @@ const _wellKnownCtorMap = {
225
232
  '409': Conflict,
226
233
  '410': Gone,
227
234
  '418': ImATeapot,
235
+ '422': UnprocessableContent,
228
236
  //
229
237
  '500': InternalServerError,
230
238
  '501': NotImplemented,
package/dist/status.d.ts CHANGED
@@ -270,6 +270,7 @@ export declare class HTTP_STATUS {
270
270
  static readonly METHOD_NOT_ALLOWED: number;
271
271
  static readonly CONFLICT: number;
272
272
  static readonly GONE: number;
273
+ static readonly UNPROCESSABLE_CONTENT: number;
273
274
  static readonly INTERNAL_SERVER_ERROR: number;
274
275
  static readonly NOT_IMPLEMENTED: number;
275
276
  static readonly SERVICE_UNAVAILABLE: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/http-utils",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Misc DRY http fetch related helpers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",