@keq-request/exception 5.0.0-alpha.34 → 5.0.0-alpha.35

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0-alpha.35
4
+
5
+ ### Major Changes
6
+
7
+ - 0a04864: **Fix:** fix: update browser targets to chrome91/firefox90/safari15/edge91 to resolve esbuild 0.27 destructuring build errors.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [0a04864]
12
+ - keq@5.0.0-alpha.35
13
+
3
14
  ## 5.0.0-alpha.34
4
15
 
5
16
  ### Patch Changes
@@ -0,0 +1,18 @@
1
+ import { KeqContext, KeqMiddleware } from "keq";
2
+ import { Promisable } from "type-fest";
3
+
4
+ //#region src/throw-exception.d.ts
5
+ type Check = (ctx: KeqContext) => Promisable<void>;
6
+ declare function throwException(check: Check): KeqMiddleware;
7
+ //#endregion
8
+ //#region src/catch-exception.d.ts
9
+ declare function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware;
10
+ //#endregion
11
+ //#region src/validate-status-code.d.ts
12
+ declare function validateStatusCode(): KeqMiddleware;
13
+ //#endregion
14
+ //#region src/create-exception-by-status-code.d.ts
15
+ declare function createExceptionByStatusCode(response: Response): Error;
16
+ //#endregion
17
+ export { Check, catchException, createExceptionByStatusCode, throwException, validateStatusCode };
18
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/throw-exception.ts","../src/catch-exception.ts","../src/validate-status-code.ts","../src/create-exception-by-status-code.ts"],"mappings":";;;;KAIY,KAAA,IAAS,GAAA,EAAK,UAAA,KAAe,UAAA;AAAA,iBAEzB,cAAA,CAAe,KAAA,EAAO,KAAA,GAAQ,aAAA;;;iBCF9B,cAAA,CAAe,OAAA,GAAU,CAAA,cAAe,UAAA,SAAmB,aAAA;;;iBCD3D,kBAAA,CAAA,GAAsB,aAAA;;;iBCqBtB,2BAAA,CAA4B,QAAA,EAAU,QAAA,GAAW,KAAA"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,18 @@
1
- export * from './throw-exception.js';
2
- export * from './catch-exception.js';
3
- export * from './validate-status-code.js';
4
- export * from './create-exception-by-status-code.js';
1
+ import { KeqContext, KeqMiddleware } from "keq";
2
+ import { Promisable } from "type-fest";
3
+
4
+ //#region src/throw-exception.d.ts
5
+ type Check = (ctx: KeqContext) => Promisable<void>;
6
+ declare function throwException(check: Check): KeqMiddleware;
7
+ //#endregion
8
+ //#region src/catch-exception.d.ts
9
+ declare function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware;
10
+ //#endregion
11
+ //#region src/validate-status-code.d.ts
12
+ declare function validateStatusCode(): KeqMiddleware;
13
+ //#endregion
14
+ //#region src/create-exception-by-status-code.d.ts
15
+ declare function createExceptionByStatusCode(response: Response): Error;
16
+ //#endregion
17
+ export { Check, catchException, createExceptionByStatusCode, throwException, validateStatusCode };
5
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sCAAsC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/throw-exception.ts","../src/catch-exception.ts","../src/validate-status-code.ts","../src/create-exception-by-status-code.ts"],"mappings":";;;;KAIY,KAAA,IAAS,GAAA,EAAK,UAAA,KAAe,UAAA;AAAA,iBAEzB,cAAA,CAAe,KAAA,EAAO,KAAA,GAAQ,aAAA;;;iBCF9B,cAAA,CAAe,OAAA,GAAU,CAAA,cAAe,UAAA,SAAmB,aAAA;;;iBCD3D,kBAAA,CAAA,GAAsB,aAAA;;;iBCqBtB,2BAAA,CAA4B,QAAA,EAAU,QAAA,GAAW,KAAA"}
package/dist/index.js CHANGED
@@ -1,120 +1,81 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- catchException: () => catchException,
24
- createExceptionByStatusCode: () => createExceptionByStatusCode,
25
- throwException: () => throwException,
26
- validateStatusCode: () => validateStatusCode
27
- });
28
- module.exports = __toCommonJS(index_exports);
29
-
30
- // src/throw-exception.ts
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let keq = require("keq");
3
+ //#region src/throw-exception.ts
31
4
  function throwException(check) {
32
- return async function throwException2(ctx, next) {
33
- await next();
34
- await check(ctx);
35
- };
5
+ return async function throwException(ctx, next) {
6
+ await next();
7
+ await check(ctx);
8
+ };
36
9
  }
37
-
38
- // src/catch-exception.ts
10
+ //#endregion
11
+ //#region src/catch-exception.ts
39
12
  function catchException(handler) {
40
- return async function catchException2(ctx, next) {
41
- try {
42
- await next();
43
- } catch (err) {
44
- await handler(err);
45
- }
46
- };
13
+ return async function catchException(ctx, next) {
14
+ try {
15
+ await next();
16
+ } catch (err) {
17
+ await handler(err);
18
+ }
19
+ };
47
20
  }
48
-
49
- // src/create-exception-by-status-code.ts
50
- var import_keq = require("keq");
21
+ //#endregion
22
+ //#region src/create-exception-by-status-code.ts
51
23
  function createExceptionByStatusCode(response) {
52
- const { status, statusText } = response;
53
- if (status >= 400 && status < 500) {
54
- switch (status) {
55
- case 400:
56
- return new import_keq.BadRequestException(statusText, { response });
57
- case 401:
58
- return new import_keq.UnauthorizedException(statusText, { response });
59
- case 403:
60
- return new import_keq.ForbiddenException(statusText, { response });
61
- case 404:
62
- return new import_keq.NotFoundedException(statusText, { response });
63
- case 405:
64
- return new import_keq.MethodNotAllowedException(statusText, { response });
65
- case 406:
66
- return new import_keq.NotAcceptableException(statusText, { response });
67
- case 407:
68
- return new import_keq.ProxyAuthenticationRequiredException(statusText, { response });
69
- case 408:
70
- return new import_keq.RequestTimeoutException(statusText, { response });
71
- case 409:
72
- return new import_keq.ConflictException(statusText, { response });
73
- case 412:
74
- return new import_keq.PreconditionFailedException(statusText, { response });
75
- case 413:
76
- return new import_keq.ContentTooLargeException(statusText, { response });
77
- case 414:
78
- return new import_keq.UriTooLongException(statusText, { response });
79
- case 415:
80
- return new import_keq.UnsupportedMediaTypeException(statusText, { response });
81
- case 418:
82
- return new import_keq.ImATeapotException(statusText, { response });
83
- case 429:
84
- return new import_keq.TooManyRequestsException(statusText, { response });
85
- default:
86
- return new import_keq.RequestException(status, statusText, { fatal: true, response });
87
- }
88
- }
89
- if (status >= 500) {
90
- switch (status) {
91
- case 500:
92
- return new import_keq.InternalServerErrorException(statusText, { response });
93
- case 501:
94
- return new import_keq.NotImplementedException(statusText, { response });
95
- case 502:
96
- return new import_keq.BadGatewayException(statusText, { response });
97
- case 503:
98
- return new import_keq.ServiceUnavailableException(statusText, { response });
99
- case 504:
100
- return new import_keq.GatewayTimeoutException(statusText, { response });
101
- default:
102
- return new import_keq.RequestException(status, statusText, { fatal: false, response });
103
- }
104
- }
105
- return new import_keq.RequestException(status, statusText, { fatal: false, response });
24
+ const { status, statusText } = response;
25
+ if (status >= 400 && status < 500) switch (status) {
26
+ case 400: return new keq.BadRequestException(statusText, { response });
27
+ case 401: return new keq.UnauthorizedException(statusText, { response });
28
+ case 403: return new keq.ForbiddenException(statusText, { response });
29
+ case 404: return new keq.NotFoundedException(statusText, { response });
30
+ case 405: return new keq.MethodNotAllowedException(statusText, { response });
31
+ case 406: return new keq.NotAcceptableException(statusText, { response });
32
+ case 407: return new keq.ProxyAuthenticationRequiredException(statusText, { response });
33
+ case 408: return new keq.RequestTimeoutException(statusText, { response });
34
+ case 409: return new keq.ConflictException(statusText, { response });
35
+ case 412: return new keq.PreconditionFailedException(statusText, { response });
36
+ case 413: return new keq.ContentTooLargeException(statusText, { response });
37
+ case 414: return new keq.UriTooLongException(statusText, { response });
38
+ case 415: return new keq.UnsupportedMediaTypeException(statusText, { response });
39
+ case 418: return new keq.ImATeapotException(statusText, { response });
40
+ case 429: return new keq.TooManyRequestsException(statusText, { response });
41
+ default: return new keq.RequestException(status, statusText, {
42
+ fatal: true,
43
+ response
44
+ });
45
+ }
46
+ if (status >= 500) switch (status) {
47
+ case 500: return new keq.InternalServerErrorException(statusText, { response });
48
+ case 501: return new keq.NotImplementedException(statusText, { response });
49
+ case 502: return new keq.BadGatewayException(statusText, { response });
50
+ case 503: return new keq.ServiceUnavailableException(statusText, { response });
51
+ case 504: return new keq.GatewayTimeoutException(statusText, { response });
52
+ default: return new keq.RequestException(status, statusText, {
53
+ fatal: false,
54
+ response
55
+ });
56
+ }
57
+ return new keq.RequestException(status, statusText, {
58
+ fatal: false,
59
+ response
60
+ });
106
61
  }
107
-
108
- // src/validate-status-code.ts
62
+ //#endregion
63
+ //#region src/validate-status-code.ts
109
64
  function validateStatusCode() {
110
- return async function validateStatusCode2(context, next) {
111
- await next();
112
- const response = context.response;
113
- if (!response) return;
114
- const { status } = response;
115
- if (status >= 200 && status < 300) return;
116
- if (status >= 300 && status < 400) return;
117
- throw createExceptionByStatusCode(response);
118
- };
65
+ return async function validateStatusCode(context, next) {
66
+ await next();
67
+ const response = context.response;
68
+ if (!response) return;
69
+ const { status } = response;
70
+ if (status >= 200 && status < 300) return;
71
+ if (status >= 300 && status < 400) return;
72
+ throw createExceptionByStatusCode(response);
73
+ };
119
74
  }
75
+ //#endregion
76
+ exports.catchException = catchException;
77
+ exports.createExceptionByStatusCode = createExceptionByStatusCode;
78
+ exports.throwException = throwException;
79
+ exports.validateStatusCode = validateStatusCode;
80
+
120
81
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/throw-exception.ts","../src/catch-exception.ts","../src/create-exception-by-status-code.ts","../src/validate-status-code.ts"],"sourcesContent":["export * from './throw-exception.js'\nexport * from './catch-exception.js'\nexport * from './validate-status-code.js'\nexport * from './create-exception-by-status-code.js'\n","import { KeqContext, KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport type Check = (ctx: KeqContext) => Promisable<void>\n\nexport function throwException(check: Check): KeqMiddleware {\n return async function throwException(ctx, next) {\n await next()\n\n await check(ctx)\n }\n}\n","import { KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware {\n return async function catchException(ctx, next) {\n try {\n await next()\n } catch (err) {\n await handler(err)\n }\n }\n}\n","import {\n BadGatewayException,\n BadRequestException,\n ConflictException,\n ForbiddenException,\n GatewayTimeoutException,\n InternalServerErrorException,\n NotAcceptableException,\n NotFoundedException,\n PreconditionFailedException,\n RequestException,\n ServiceUnavailableException,\n UnauthorizedException,\n ImATeapotException,\n MethodNotAllowedException,\n UriTooLongException,\n ContentTooLargeException,\n ProxyAuthenticationRequiredException,\n RequestTimeoutException,\n TooManyRequestsException,\n NotImplementedException,\n UnsupportedMediaTypeException,\n} from 'keq'\n\nexport function createExceptionByStatusCode(response: Response): Error {\n const { status, statusText } = response\n\n // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n return new BadRequestException(statusText, { response })\n case 401:\n return new UnauthorizedException(statusText, { response })\n case 403:\n return new ForbiddenException(statusText, { response })\n case 404:\n return new NotFoundedException(statusText, { response })\n case 405:\n return new MethodNotAllowedException(statusText, { response })\n case 406:\n return new NotAcceptableException(statusText, { response })\n case 407:\n return new ProxyAuthenticationRequiredException(statusText, { response })\n case 408:\n return new RequestTimeoutException(statusText, { response })\n case 409:\n return new ConflictException(statusText, { response })\n case 412:\n return new PreconditionFailedException(statusText, { response })\n case 413:\n return new ContentTooLargeException(statusText, { response })\n case 414:\n return new UriTooLongException(statusText, { response })\n case 415:\n return new UnsupportedMediaTypeException(statusText, { response })\n case 418:\n return new ImATeapotException(statusText, { response })\n case 429:\n return new TooManyRequestsException(statusText, { response })\n default:\n // Other 4xx errors, don't retry by default\n return new RequestException(status, statusText, { fatal: true, response })\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n return new InternalServerErrorException(statusText, { response })\n case 501:\n return new NotImplementedException(statusText, { response })\n case 502:\n return new BadGatewayException(statusText, { response })\n case 503:\n return new ServiceUnavailableException(statusText, { response })\n case 504:\n return new GatewayTimeoutException(statusText, { response })\n default:\n // Other 5xx errors, retry by default\n return new RequestException(status, statusText, { fatal: false, response })\n }\n }\n\n return new RequestException(status, statusText, { fatal: false, response })\n}\n","import { KeqMiddleware } from 'keq'\nimport { createExceptionByStatusCode } from './create-exception-by-status-code.js'\n\nexport function validateStatusCode(): KeqMiddleware {\n return async function validateStatusCode(context, next) {\n await next()\n\n const response = context.response\n if (!response) return\n\n const { status } = response\n\n // 2xx success status codes - no error\n if (status >= 200 && status < 300) return\n\n // 3xx redirection status codes - no error (handled by fetch)\n if (status >= 300 && status < 400) return\n\n throw createExceptionByStatusCode(response)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,SAAS,eAAe,OAA6B;AAC1D,SAAO,eAAeA,gBAAe,KAAK,MAAM;AAC9C,UAAM,KAAK;AAEX,UAAM,MAAM,GA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AACH,eAAO,IAAI,8BAAmB,YAAY,EAAE,SAAS,CAAC;AAAA,MACxD,KAAK;AACH,eAAO,IAAI,oCAAyB,YAAY,EAAE,SAAS,CAAC;AAAA,MAC9D;AAEE,eAAO,IAAI,4BAAiB,QAAQ,YAAY,EAAE,OAAO,MAAM,SAAS,CAAC;AAAA,IAC7E;AAAA,EACF;AAGA,MAAI,UAAU,KAAK;AACjB,YAAQ,QAAQ;AAAA,MACd,KAAK;AACH,eAAO,IAAI,wCAA6B,YAAY,EAAE,SAAS,CAAC;AAAA,MAClE,KAAK;AACH,eAAO,IAAI,mCAAwB,YAAY,EAAE,SAAS,CAAC;AAAA,MAC7D,KAAK;AACH,eAAO,IAAI,+BAAoB,YAAY,EAAE,SAAS,CAAC;AAAA,MACzD,KAAK;AACH,eAAO,IAAI,uCAA4B,YAAY,EAAE,SAAS,CAAC;AAAA,MACjE,KAAK;AACH,eAAO,IAAI,mCAAwB,YAAY,EAAE,SAAS,CAAC;AAAA,MAC7D;AAEE,eAAO,IAAI,4BAAiB,QAAQ,YAAY,EAAE,OAAO,OAAO,SAAS,CAAC;AAAA,IAC9E;AAAA,EACF;AAEA,SAAO,IAAI,4BAAiB,QAAQ,YAAY,EAAE,OAAO,OAAO,SAAS,CAAC;AAC5E;;;ACnFO,SAAS,qBAAoC;AAClD,SAAO,eAAeC,oBAAmB,SAAS,MAAM;AACtD,UAAM,KAAK;AAEX,UAAM,WAAW,QAAQ;AACzB,QAAI,CAAC,SAAU;AAEf,UAAM,EAAE,OAAO,IAAI;AAGnB,QAAI,UAAU,OAAO,SAAS,IAAK;AAGnC,QAAI,UAAU,OAAO,SAAS,IAAK;AAEnC,UAAM,4BAA4B,QAAQ;AAAA,EAC5C;AACF;","names":["throwException","catchException","validateStatusCode"]}
1
+ {"version":3,"file":"index.js","names":["BadRequestException","UnauthorizedException","ForbiddenException","NotFoundedException","MethodNotAllowedException","NotAcceptableException","ProxyAuthenticationRequiredException","RequestTimeoutException","ConflictException","PreconditionFailedException","ContentTooLargeException","UriTooLongException","UnsupportedMediaTypeException","ImATeapotException","TooManyRequestsException","RequestException","InternalServerErrorException","NotImplementedException","BadGatewayException","ServiceUnavailableException","GatewayTimeoutException"],"sources":["../src/throw-exception.ts","../src/catch-exception.ts","../src/create-exception-by-status-code.ts","../src/validate-status-code.ts"],"sourcesContent":["import { KeqContext, KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport type Check = (ctx: KeqContext) => Promisable<void>\n\nexport function throwException(check: Check): KeqMiddleware {\n return async function throwException(ctx, next) {\n await next()\n\n await check(ctx)\n }\n}\n","import { KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware {\n return async function catchException(ctx, next) {\n try {\n await next()\n } catch (err) {\n await handler(err)\n }\n }\n}\n","import {\n BadGatewayException,\n BadRequestException,\n ConflictException,\n ForbiddenException,\n GatewayTimeoutException,\n InternalServerErrorException,\n NotAcceptableException,\n NotFoundedException,\n PreconditionFailedException,\n RequestException,\n ServiceUnavailableException,\n UnauthorizedException,\n ImATeapotException,\n MethodNotAllowedException,\n UriTooLongException,\n ContentTooLargeException,\n ProxyAuthenticationRequiredException,\n RequestTimeoutException,\n TooManyRequestsException,\n NotImplementedException,\n UnsupportedMediaTypeException,\n} from 'keq'\n\nexport function createExceptionByStatusCode(response: Response): Error {\n const { status, statusText } = response\n\n // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n return new BadRequestException(statusText, { response })\n case 401:\n return new UnauthorizedException(statusText, { response })\n case 403:\n return new ForbiddenException(statusText, { response })\n case 404:\n return new NotFoundedException(statusText, { response })\n case 405:\n return new MethodNotAllowedException(statusText, { response })\n case 406:\n return new NotAcceptableException(statusText, { response })\n case 407:\n return new ProxyAuthenticationRequiredException(statusText, { response })\n case 408:\n return new RequestTimeoutException(statusText, { response })\n case 409:\n return new ConflictException(statusText, { response })\n case 412:\n return new PreconditionFailedException(statusText, { response })\n case 413:\n return new ContentTooLargeException(statusText, { response })\n case 414:\n return new UriTooLongException(statusText, { response })\n case 415:\n return new UnsupportedMediaTypeException(statusText, { response })\n case 418:\n return new ImATeapotException(statusText, { response })\n case 429:\n return new TooManyRequestsException(statusText, { response })\n default:\n // Other 4xx errors, don't retry by default\n return new RequestException(status, statusText, { fatal: true, response })\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n return new InternalServerErrorException(statusText, { response })\n case 501:\n return new NotImplementedException(statusText, { response })\n case 502:\n return new BadGatewayException(statusText, { response })\n case 503:\n return new ServiceUnavailableException(statusText, { response })\n case 504:\n return new GatewayTimeoutException(statusText, { response })\n default:\n // Other 5xx errors, retry by default\n return new RequestException(status, statusText, { fatal: false, response })\n }\n }\n\n return new RequestException(status, statusText, { fatal: false, response })\n}\n","import { KeqMiddleware } from 'keq'\nimport { createExceptionByStatusCode } from './create-exception-by-status-code.js'\n\nexport function validateStatusCode(): KeqMiddleware {\n return async function validateStatusCode(context, next) {\n await next()\n\n const response = context.response\n if (!response) return\n\n const { status } = response\n\n // 2xx success status codes - no error\n if (status >= 200 && status < 300) return\n\n // 3xx redirection status codes - no error (handled by fetch)\n if (status >= 300 && status < 400) return\n\n throw createExceptionByStatusCode(response)\n }\n}\n"],"mappings":";;;AAMA,SAAgB,eAAe,OAA6B;AAC1D,QAAO,eAAe,eAAe,KAAK,MAAM;AAC9C,QAAM,MAAM;AAEZ,QAAM,MAAM,IAAI;;;;;ACNpB,SAAgB,eAAe,SAA0D;AACvF,QAAO,eAAe,eAAe,KAAK,MAAM;AAC9C,MAAI;AACF,SAAM,MAAM;WACL,KAAK;AACZ,SAAM,QAAQ,IAAI;;;;;;ACexB,SAAgB,4BAA4B,UAA2B;CACrE,MAAM,EAAE,QAAQ,eAAe;AAG/B,KAAI,UAAU,OAAO,SAAS,IAC5B,SAAQ,QAAR;EACE,KAAK,IACH,QAAO,IAAIA,IAAAA,oBAAoB,YAA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AAAA,wBAAwB,YAAY,EAAE,UAAU,CAAC;EAC9D,KAAK,IACH,QAAO,IAAIC,IAAAA,oBAAoB,YAAY,EAAE,UAAU,CAAC;EAC1D,KAAK,IACH,QAAO,IAAIC,IAAAA,4BAA4B,YAAY,EAAE,UAAU,CAAC;EAClE,KAAK,IACH,QAAO,IAAIC,IAAAA,wBAAwB,YAAY,EAAE,UAAU,CAAC;EAC9D,QAEE,QAAO,IAAIL,IAAAA,iBAAiB,QAAQ,YAAY;GAAE,OAAO;GAAO;GAAU,CAAC;;AAIjF,QAAO,IAAIA,IAAAA,iBAAiB,QAAQ,YAAY;EAAE,OAAO;EAAO;EAAU,CAAC;;;;AClF7E,SAAgB,qBAAoC;AAClD,QAAO,eAAe,mBAAmB,SAAS,MAAM;AACtD,QAAM,MAAM;EAEZ,MAAM,WAAW,QAAQ;AACzB,MAAI,CAAC,SAAU;EAEf,MAAM,EAAE,WAAW;AAGnB,MAAI,UAAU,OAAO,SAAS,IAAK;AAGnC,MAAI,UAAU,OAAO,SAAS,IAAK;AAEnC,QAAM,4BAA4B,SAAS"}
package/dist/index.mjs CHANGED
@@ -1,119 +1,77 @@
1
- // src/throw-exception.ts
1
+ import { BadGatewayException, BadRequestException, ConflictException, ContentTooLargeException, ForbiddenException, GatewayTimeoutException, ImATeapotException, InternalServerErrorException, MethodNotAllowedException, NotAcceptableException, NotFoundedException, NotImplementedException, PreconditionFailedException, ProxyAuthenticationRequiredException, RequestException, RequestTimeoutException, ServiceUnavailableException, TooManyRequestsException, UnauthorizedException, UnsupportedMediaTypeException, UriTooLongException } from "keq";
2
+ //#region src/throw-exception.ts
2
3
  function throwException(check) {
3
- return async function throwException2(ctx, next) {
4
- await next();
5
- await check(ctx);
6
- };
4
+ return async function throwException(ctx, next) {
5
+ await next();
6
+ await check(ctx);
7
+ };
7
8
  }
8
-
9
- // src/catch-exception.ts
9
+ //#endregion
10
+ //#region src/catch-exception.ts
10
11
  function catchException(handler) {
11
- return async function catchException2(ctx, next) {
12
- try {
13
- await next();
14
- } catch (err) {
15
- await handler(err);
16
- }
17
- };
12
+ return async function catchException(ctx, next) {
13
+ try {
14
+ await next();
15
+ } catch (err) {
16
+ await handler(err);
17
+ }
18
+ };
18
19
  }
19
-
20
- // src/create-exception-by-status-code.ts
21
- import {
22
- BadGatewayException,
23
- BadRequestException,
24
- ConflictException,
25
- ForbiddenException,
26
- GatewayTimeoutException,
27
- InternalServerErrorException,
28
- NotAcceptableException,
29
- NotFoundedException,
30
- PreconditionFailedException,
31
- RequestException,
32
- ServiceUnavailableException,
33
- UnauthorizedException,
34
- ImATeapotException,
35
- MethodNotAllowedException,
36
- UriTooLongException,
37
- ContentTooLargeException,
38
- ProxyAuthenticationRequiredException,
39
- RequestTimeoutException,
40
- TooManyRequestsException,
41
- NotImplementedException,
42
- UnsupportedMediaTypeException
43
- } from "keq";
20
+ //#endregion
21
+ //#region src/create-exception-by-status-code.ts
44
22
  function createExceptionByStatusCode(response) {
45
- const { status, statusText } = response;
46
- if (status >= 400 && status < 500) {
47
- switch (status) {
48
- case 400:
49
- return new BadRequestException(statusText, { response });
50
- case 401:
51
- return new UnauthorizedException(statusText, { response });
52
- case 403:
53
- return new ForbiddenException(statusText, { response });
54
- case 404:
55
- return new NotFoundedException(statusText, { response });
56
- case 405:
57
- return new MethodNotAllowedException(statusText, { response });
58
- case 406:
59
- return new NotAcceptableException(statusText, { response });
60
- case 407:
61
- return new ProxyAuthenticationRequiredException(statusText, { response });
62
- case 408:
63
- return new RequestTimeoutException(statusText, { response });
64
- case 409:
65
- return new ConflictException(statusText, { response });
66
- case 412:
67
- return new PreconditionFailedException(statusText, { response });
68
- case 413:
69
- return new ContentTooLargeException(statusText, { response });
70
- case 414:
71
- return new UriTooLongException(statusText, { response });
72
- case 415:
73
- return new UnsupportedMediaTypeException(statusText, { response });
74
- case 418:
75
- return new ImATeapotException(statusText, { response });
76
- case 429:
77
- return new TooManyRequestsException(statusText, { response });
78
- default:
79
- return new RequestException(status, statusText, { fatal: true, response });
80
- }
81
- }
82
- if (status >= 500) {
83
- switch (status) {
84
- case 500:
85
- return new InternalServerErrorException(statusText, { response });
86
- case 501:
87
- return new NotImplementedException(statusText, { response });
88
- case 502:
89
- return new BadGatewayException(statusText, { response });
90
- case 503:
91
- return new ServiceUnavailableException(statusText, { response });
92
- case 504:
93
- return new GatewayTimeoutException(statusText, { response });
94
- default:
95
- return new RequestException(status, statusText, { fatal: false, response });
96
- }
97
- }
98
- return new RequestException(status, statusText, { fatal: false, response });
23
+ const { status, statusText } = response;
24
+ if (status >= 400 && status < 500) switch (status) {
25
+ case 400: return new BadRequestException(statusText, { response });
26
+ case 401: return new UnauthorizedException(statusText, { response });
27
+ case 403: return new ForbiddenException(statusText, { response });
28
+ case 404: return new NotFoundedException(statusText, { response });
29
+ case 405: return new MethodNotAllowedException(statusText, { response });
30
+ case 406: return new NotAcceptableException(statusText, { response });
31
+ case 407: return new ProxyAuthenticationRequiredException(statusText, { response });
32
+ case 408: return new RequestTimeoutException(statusText, { response });
33
+ case 409: return new ConflictException(statusText, { response });
34
+ case 412: return new PreconditionFailedException(statusText, { response });
35
+ case 413: return new ContentTooLargeException(statusText, { response });
36
+ case 414: return new UriTooLongException(statusText, { response });
37
+ case 415: return new UnsupportedMediaTypeException(statusText, { response });
38
+ case 418: return new ImATeapotException(statusText, { response });
39
+ case 429: return new TooManyRequestsException(statusText, { response });
40
+ default: return new RequestException(status, statusText, {
41
+ fatal: true,
42
+ response
43
+ });
44
+ }
45
+ if (status >= 500) switch (status) {
46
+ case 500: return new InternalServerErrorException(statusText, { response });
47
+ case 501: return new NotImplementedException(statusText, { response });
48
+ case 502: return new BadGatewayException(statusText, { response });
49
+ case 503: return new ServiceUnavailableException(statusText, { response });
50
+ case 504: return new GatewayTimeoutException(statusText, { response });
51
+ default: return new RequestException(status, statusText, {
52
+ fatal: false,
53
+ response
54
+ });
55
+ }
56
+ return new RequestException(status, statusText, {
57
+ fatal: false,
58
+ response
59
+ });
99
60
  }
100
-
101
- // src/validate-status-code.ts
61
+ //#endregion
62
+ //#region src/validate-status-code.ts
102
63
  function validateStatusCode() {
103
- return async function validateStatusCode2(context, next) {
104
- await next();
105
- const response = context.response;
106
- if (!response) return;
107
- const { status } = response;
108
- if (status >= 200 && status < 300) return;
109
- if (status >= 300 && status < 400) return;
110
- throw createExceptionByStatusCode(response);
111
- };
64
+ return async function validateStatusCode(context, next) {
65
+ await next();
66
+ const response = context.response;
67
+ if (!response) return;
68
+ const { status } = response;
69
+ if (status >= 200 && status < 300) return;
70
+ if (status >= 300 && status < 400) return;
71
+ throw createExceptionByStatusCode(response);
72
+ };
112
73
  }
113
- export {
114
- catchException,
115
- createExceptionByStatusCode,
116
- throwException,
117
- validateStatusCode
118
- };
74
+ //#endregion
75
+ export { catchException, createExceptionByStatusCode, throwException, validateStatusCode };
76
+
119
77
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/throw-exception.ts","../src/catch-exception.ts","../src/create-exception-by-status-code.ts","../src/validate-status-code.ts"],"sourcesContent":["import { KeqContext, KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport type Check = (ctx: KeqContext) => Promisable<void>\n\nexport function throwException(check: Check): KeqMiddleware {\n return async function throwException(ctx, next) {\n await next()\n\n await check(ctx)\n }\n}\n","import { KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware {\n return async function catchException(ctx, next) {\n try {\n await next()\n } catch (err) {\n await handler(err)\n }\n }\n}\n","import {\n BadGatewayException,\n BadRequestException,\n ConflictException,\n ForbiddenException,\n GatewayTimeoutException,\n InternalServerErrorException,\n NotAcceptableException,\n NotFoundedException,\n PreconditionFailedException,\n RequestException,\n ServiceUnavailableException,\n UnauthorizedException,\n ImATeapotException,\n MethodNotAllowedException,\n UriTooLongException,\n ContentTooLargeException,\n ProxyAuthenticationRequiredException,\n RequestTimeoutException,\n TooManyRequestsException,\n NotImplementedException,\n UnsupportedMediaTypeException,\n} from 'keq'\n\nexport function createExceptionByStatusCode(response: Response): Error {\n const { status, statusText } = response\n\n // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n return new BadRequestException(statusText, { response })\n case 401:\n return new UnauthorizedException(statusText, { response })\n case 403:\n return new ForbiddenException(statusText, { response })\n case 404:\n return new NotFoundedException(statusText, { response })\n case 405:\n return new MethodNotAllowedException(statusText, { response })\n case 406:\n return new NotAcceptableException(statusText, { response })\n case 407:\n return new ProxyAuthenticationRequiredException(statusText, { response })\n case 408:\n return new RequestTimeoutException(statusText, { response })\n case 409:\n return new ConflictException(statusText, { response })\n case 412:\n return new PreconditionFailedException(statusText, { response })\n case 413:\n return new ContentTooLargeException(statusText, { response })\n case 414:\n return new UriTooLongException(statusText, { response })\n case 415:\n return new UnsupportedMediaTypeException(statusText, { response })\n case 418:\n return new ImATeapotException(statusText, { response })\n case 429:\n return new TooManyRequestsException(statusText, { response })\n default:\n // Other 4xx errors, don't retry by default\n return new RequestException(status, statusText, { fatal: true, response })\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n return new InternalServerErrorException(statusText, { response })\n case 501:\n return new NotImplementedException(statusText, { response })\n case 502:\n return new BadGatewayException(statusText, { response })\n case 503:\n return new ServiceUnavailableException(statusText, { response })\n case 504:\n return new GatewayTimeoutException(statusText, { response })\n default:\n // Other 5xx errors, retry by default\n return new RequestException(status, statusText, { fatal: false, response })\n }\n }\n\n return new RequestException(status, statusText, { fatal: false, response })\n}\n","import { KeqMiddleware } from 'keq'\nimport { createExceptionByStatusCode } from './create-exception-by-status-code.js'\n\nexport function validateStatusCode(): KeqMiddleware {\n return async function validateStatusCode(context, next) {\n await next()\n\n const response = context.response\n if (!response) return\n\n const { status } = response\n\n // 2xx success status codes - no error\n if (status >= 200 && status < 300) return\n\n // 3xx redirection status codes - no error (handled by fetch)\n if (status >= 300 && status < 400) return\n\n throw create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M,KAAK;AAEX,UAAM,WAAW,QAAQ;AACzB,QAAI,CAAC,SAAU;AAEf,UAAM,EAAE,OAAO,IAAI;AAGnB,QAAI,UAAU,OAAO,SAAS,IAAK;AAGnC,QAAI,UAAU,OAAO,SAAS,IAAK;AAEnC,UAAM,4BAA4B,QAAQ;AAAA,EAC5C;AACF;","names":["throwException","catchException","validateStatusCode"]}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/throw-exception.ts","../src/catch-exception.ts","../src/create-exception-by-status-code.ts","../src/validate-status-code.ts"],"sourcesContent":["import { KeqContext, KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport type Check = (ctx: KeqContext) => Promisable<void>\n\nexport function throwException(check: Check): KeqMiddleware {\n return async function throwException(ctx, next) {\n await next()\n\n await check(ctx)\n }\n}\n","import { KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware {\n return async function catchException(ctx, next) {\n try {\n await next()\n } catch (err) {\n await handler(err)\n }\n }\n}\n","import {\n BadGatewayException,\n BadRequestException,\n ConflictException,\n ForbiddenException,\n GatewayTimeoutException,\n InternalServerErrorException,\n NotAcceptableException,\n NotFoundedException,\n PreconditionFailedException,\n RequestException,\n ServiceUnavailableException,\n UnauthorizedException,\n ImATeapotException,\n MethodNotAllowedException,\n UriTooLongException,\n ContentTooLargeException,\n ProxyAuthenticationRequiredException,\n RequestTimeoutException,\n TooManyRequestsException,\n NotImplementedException,\n UnsupportedMediaTypeException,\n} from 'keq'\n\nexport function createExceptionByStatusCode(response: Response): Error {\n const { status, statusText } = response\n\n // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n return new BadRequestException(statusText, { response })\n case 401:\n return new UnauthorizedException(statusText, { response })\n case 403:\n return new ForbiddenException(statusText, { response })\n case 404:\n return new NotFoundedException(statusText, { response })\n case 405:\n return new MethodNotAllowedException(statusText, { response })\n case 406:\n return new NotAcceptableException(statusText, { response })\n case 407:\n return new ProxyAuthenticationRequiredException(statusText, { response })\n case 408:\n return new RequestTimeoutException(statusText, { response })\n case 409:\n return new ConflictException(statusText, { response })\n case 412:\n return new PreconditionFailedException(statusText, { response })\n case 413:\n return new ContentTooLargeException(statusText, { response })\n case 414:\n return new UriTooLongException(statusText, { response })\n case 415:\n return new UnsupportedMediaTypeException(statusText, { response })\n case 418:\n return new ImATeapotException(statusText, { response })\n case 429:\n return new TooManyRequestsException(statusText, { response })\n default:\n // Other 4xx errors, don't retry by default\n return new RequestException(status, statusText, { fatal: true, response })\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n return new InternalServerErrorException(statusText, { response })\n case 501:\n return new NotImplementedException(statusText, { response })\n case 502:\n return new BadGatewayException(statusText, { response })\n case 503:\n return new ServiceUnavailableException(statusText, { response })\n case 504:\n return new GatewayTimeoutException(statusText, { response })\n default:\n // Other 5xx errors, retry by default\n return new RequestException(status, statusText, { fatal: false, response })\n }\n }\n\n return new RequestException(status, statusText, { fatal: false, response })\n}\n","import { KeqMiddleware } from 'keq'\nimport { createExceptionByStatusCode } from './create-exception-by-status-code.js'\n\nexport function validateStatusCode(): KeqMiddleware {\n return async function validateStatusCode(context, next) {\n await next()\n\n const response = context.response\n if (!response) return\n\n const { status } = response\n\n // 2xx success status codes - no error\n if (status >= 200 && status < 300) return\n\n // 3xx redirection status codes - no error (handled by fetch)\n if (status >= 300 && status < 400) return\n\n throw createExceptionByStatusCode(response)\n }\n}\n"],"mappings":";;AAMA,SAAgB,eAAe,OAA6B;AAC1D,QAAO,eAAe,eAAe,KAAK,MAAM;AAC9C,QAAM,MAAM;AAEZ,QAAM,MAAM,IAAI;;;;;ACNpB,SAAgB,eAAe,SAA0D;AACvF,QAAO,eAAe,eAAe,KAAK,MAAM;AAC9C,MAAI;AACF,SAAM,MAAM;WACL,KAAK;AACZ,SAAM,QAAQ,IAAI;;;;;;ACexB,SAAgB,4BAA4B,UAA2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Y,EAAE,UAAU,CAAC;EAC9D,KAAK,IACH,QAAO,IAAI,oBAAoB,YAAY,EAAE,UAAU,CAAC;EAC1D,KAAK,IACH,QAAO,IAAI,4BAA4B,YAAY,EAAE,UAAU,CAAC;EAClE,KAAK,IACH,QAAO,IAAI,wBAAwB,YAAY,EAAE,UAAU,CAAC;EAC9D,QAEE,QAAO,IAAI,iBAAiB,QAAQ,YAAY;GAAE,OAAO;GAAO;GAAU,CAAC;;AAIjF,QAAO,IAAI,iBAAiB,QAAQ,YAAY;EAAE,OAAO;EAAO;EAAU,CAAC;;;;AClF7E,SAAgB,qBAAoC;AAClD,QAAO,eAAe,mBAAmB,SAAS,MAAM;AACtD,QAAM,MAAM;EAEZ,MAAM,WAAW,QAAQ;AACzB,MAAI,CAAC,SAAU;EAEf,MAAM,EAAE,WAAW;AAGnB,MAAI,UAAU,OAAO,SAAS,IAAK;AAGnC,MAAI,UAAU,OAAO,SAAS,IAAK;AAEnC,QAAM,4BAA4B,SAAS"}
@@ -1,12 +1,14 @@
1
- import { Plugin, Compiler } from '@keq-request/cli';
1
+ import { Compiler, Plugin } from "@keq-request/cli";
2
2
 
3
+ //#region plugins/validate-status-code.d.ts
3
4
  interface Options {
4
- modules?: string[];
5
+ modules?: string[];
5
6
  }
6
7
  declare class ValidateStatusCodePlugin implements Plugin {
7
- private options;
8
- constructor(options?: Options);
9
- apply(compiler: Compiler): void;
8
+ private options;
9
+ constructor(options?: Options);
10
+ apply(compiler: Compiler): void;
10
11
  }
11
-
12
+ //#endregion
12
13
  export { ValidateStatusCodePlugin };
14
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../plugins/validate-status-code.ts"],"mappings":";;;UAIU,OAAA;EACR,OAAA;AAAA;AAAA,cAGW,wBAAA,YAAoC,MAAA;EAAA,QAC3B,OAAA;cAAA,OAAA,GAAS,OAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;AAAA"}
@@ -1,12 +1,14 @@
1
- import { Plugin, Compiler } from '@keq-request/cli';
1
+ import { Compiler, Plugin } from "@keq-request/cli";
2
2
 
3
+ //#region plugins/validate-status-code.d.ts
3
4
  interface Options {
4
- modules?: string[];
5
+ modules?: string[];
5
6
  }
6
7
  declare class ValidateStatusCodePlugin implements Plugin {
7
- private options;
8
- constructor(options?: Options);
9
- apply(compiler: Compiler): void;
8
+ private options;
9
+ constructor(options?: Options);
10
+ apply(compiler: Compiler): void;
10
11
  }
11
-
12
+ //#endregion
12
13
  export { ValidateStatusCodePlugin };
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../plugins/validate-status-code.ts"],"mappings":";;;UAIU,OAAA;EACR,OAAA;AAAA;AAAA,cAGW,wBAAA,YAAoC,MAAA;EAAA,QAC3B,OAAA;cAAA,OAAA,GAAS,OAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;AAAA"}
@@ -1,95 +1,54 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _keq_request_cli = require("@keq-request/cli");
3
+ //#region plugins/validate-status-code.ts
4
+ var ValidateStatusCodePlugin = class ValidateStatusCodePlugin {
5
+ constructor(options = {}) {
6
+ this.options = options;
7
+ }
8
+ apply(compiler) {
9
+ if (this.options.modules && this.options.modules.length === 0) return;
10
+ compiler.hooks.afterDownload.tap(ValidateStatusCodePlugin.name, () => {
11
+ const documents = compiler.context.documents;
12
+ compiler.context.documents = documents.map((document) => {
13
+ if (this.options.modules && !this.options.modules.includes(document.module.name)) return document;
14
+ const spec = document.specification;
15
+ if (!spec.paths || typeof spec.paths !== "object" || spec.paths === null) return document;
16
+ const paths = Object.fromEntries(Object.entries(spec.paths).map(([path, pathItem]) => {
17
+ if (!pathItem || typeof pathItem !== "object" || pathItem === null) return [path, pathItem];
18
+ return [path, Object.fromEntries(Object.entries(pathItem).map(([method, operation]) => {
19
+ if (!operation || typeof operation !== "object" || operation === null) return [method, operation];
20
+ const responses = operation.responses;
21
+ if (!responses) return [method, operation];
22
+ return [method, {
23
+ ...operation,
24
+ responses: Object.fromEntries(Object.entries(responses).filter(([statusCode]) => parseInt(statusCode, 10) < 400))
25
+ }];
26
+ }))];
27
+ }));
28
+ return new _keq_request_cli.ApiDocumentV3_1({
29
+ ...spec,
30
+ paths
31
+ }, document.module);
32
+ });
33
+ });
34
+ compiler.hooks.afterCompile.tap(ValidateStatusCodePlugin.name, () => {
35
+ const artifact = compiler.context.artifacts.find((artifact) => artifact.id === "request");
36
+ if (!artifact) return;
37
+ if (!this.options.modules) {
38
+ artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
39
+ artifact.anchor.prepend("file:end", "request.use(validateStatusCode())\n");
40
+ } else {
41
+ artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
42
+ artifact.anchor.prepend("file:end", [
43
+ "request",
44
+ " .useRouter()",
45
+ ...this.options.modules.map((moduleName) => ` .module(${JSON.stringify(moduleName)}, validateStatusCode())`),
46
+ ""
47
+ ].join("\n"));
48
+ }
49
+ return artifact;
50
+ });
51
+ }
9
52
  };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // plugins/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- ValidateStatusCodePlugin: () => ValidateStatusCodePlugin
24
- });
25
- module.exports = __toCommonJS(index_exports);
26
-
27
- // plugins/validate-status-code.ts
28
- var import_cli = require("@keq-request/cli");
29
- var ValidateStatusCodePlugin = class _ValidateStatusCodePlugin {
30
- constructor(options = {}) {
31
- this.options = options;
32
- }
33
- apply(compiler) {
34
- if (this.options.modules && this.options.modules.length === 0) return;
35
- compiler.hooks.afterDownload.tap(_ValidateStatusCodePlugin.name, () => {
36
- const documents = compiler.context.documents;
37
- compiler.context.documents = documents.map((document) => {
38
- if (this.options.modules && !this.options.modules.includes(document.module.name)) {
39
- return document;
40
- }
41
- const spec = document.specification;
42
- if (!spec.paths || typeof spec.paths !== "object" || spec.paths === null) return document;
43
- const paths = Object.fromEntries(
44
- Object.entries(spec.paths).map(([path, pathItem]) => {
45
- if (!pathItem || typeof pathItem !== "object" || pathItem === null) return [path, pathItem];
46
- return [
47
- path,
48
- Object.fromEntries(
49
- Object.entries(pathItem).map(([method, operation]) => {
50
- if (!operation || typeof operation !== "object" || operation === null) return [method, operation];
51
- const responses = operation.responses;
52
- if (!responses) return [method, operation];
53
- return [
54
- method,
55
- {
56
- ...operation,
57
- responses: Object.fromEntries(
58
- Object.entries(responses).filter(([statusCode]) => parseInt(statusCode, 10) < 400)
59
- )
60
- }
61
- ];
62
- })
63
- )
64
- ];
65
- })
66
- );
67
- return new import_cli.ApiDocumentV3_1({ ...spec, paths }, document.module);
68
- });
69
- });
70
- compiler.hooks.afterCompile.tap(_ValidateStatusCodePlugin.name, () => {
71
- const artifact = compiler.context.artifacts.find((artifact2) => artifact2.id === "request");
72
- if (!artifact) return;
73
- if (!this.options.modules) {
74
- artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
75
- artifact.anchor.prepend("file:end", "request.use(validateStatusCode())\n");
76
- } else {
77
- artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
78
- artifact.anchor.prepend(
79
- "file:end",
80
- [
81
- "request",
82
- " .useRouter()",
83
- ...this.options.modules.map((moduleName) => ` .module(${JSON.stringify(moduleName)}, validateStatusCode())`),
84
- ""
85
- ].join("\n")
86
- );
87
- }
88
- return artifact;
89
- });
90
- }
91
- };
92
- // Annotate the CommonJS export names for ESM import in node:
93
- 0 && (module.exports = {
94
- ValidateStatusCodePlugin
95
- });
53
+ //#endregion
54
+ exports.ValidateStatusCodePlugin = ValidateStatusCodePlugin;
@@ -1,68 +1,55 @@
1
- // plugins/validate-status-code.ts
2
1
  import { ApiDocumentV3_1 } from "@keq-request/cli";
3
- var ValidateStatusCodePlugin = class _ValidateStatusCodePlugin {
4
- constructor(options = {}) {
5
- this.options = options;
6
- }
7
- apply(compiler) {
8
- if (this.options.modules && this.options.modules.length === 0) return;
9
- compiler.hooks.afterDownload.tap(_ValidateStatusCodePlugin.name, () => {
10
- const documents = compiler.context.documents;
11
- compiler.context.documents = documents.map((document) => {
12
- if (this.options.modules && !this.options.modules.includes(document.module.name)) {
13
- return document;
14
- }
15
- const spec = document.specification;
16
- if (!spec.paths || typeof spec.paths !== "object" || spec.paths === null) return document;
17
- const paths = Object.fromEntries(
18
- Object.entries(spec.paths).map(([path, pathItem]) => {
19
- if (!pathItem || typeof pathItem !== "object" || pathItem === null) return [path, pathItem];
20
- return [
21
- path,
22
- Object.fromEntries(
23
- Object.entries(pathItem).map(([method, operation]) => {
24
- if (!operation || typeof operation !== "object" || operation === null) return [method, operation];
25
- const responses = operation.responses;
26
- if (!responses) return [method, operation];
27
- return [
28
- method,
29
- {
30
- ...operation,
31
- responses: Object.fromEntries(
32
- Object.entries(responses).filter(([statusCode]) => parseInt(statusCode, 10) < 400)
33
- )
34
- }
35
- ];
36
- })
37
- )
38
- ];
39
- })
40
- );
41
- return new ApiDocumentV3_1({ ...spec, paths }, document.module);
42
- });
43
- });
44
- compiler.hooks.afterCompile.tap(_ValidateStatusCodePlugin.name, () => {
45
- const artifact = compiler.context.artifacts.find((artifact2) => artifact2.id === "request");
46
- if (!artifact) return;
47
- if (!this.options.modules) {
48
- artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
49
- artifact.anchor.prepend("file:end", "request.use(validateStatusCode())\n");
50
- } else {
51
- artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
52
- artifact.anchor.prepend(
53
- "file:end",
54
- [
55
- "request",
56
- " .useRouter()",
57
- ...this.options.modules.map((moduleName) => ` .module(${JSON.stringify(moduleName)}, validateStatusCode())`),
58
- ""
59
- ].join("\n")
60
- );
61
- }
62
- return artifact;
63
- });
64
- }
65
- };
66
- export {
67
- ValidateStatusCodePlugin
2
+ //#region plugins/validate-status-code.ts
3
+ var ValidateStatusCodePlugin = class ValidateStatusCodePlugin {
4
+ constructor(options = {}) {
5
+ this.options = options;
6
+ }
7
+ apply(compiler) {
8
+ if (this.options.modules && this.options.modules.length === 0) return;
9
+ compiler.hooks.afterDownload.tap(ValidateStatusCodePlugin.name, () => {
10
+ const documents = compiler.context.documents;
11
+ compiler.context.documents = documents.map((document) => {
12
+ if (this.options.modules && !this.options.modules.includes(document.module.name)) return document;
13
+ const spec = document.specification;
14
+ if (!spec.paths || typeof spec.paths !== "object" || spec.paths === null) return document;
15
+ const paths = Object.fromEntries(Object.entries(spec.paths).map(([path, pathItem]) => {
16
+ if (!pathItem || typeof pathItem !== "object" || pathItem === null) return [path, pathItem];
17
+ return [path, Object.fromEntries(Object.entries(pathItem).map(([method, operation]) => {
18
+ if (!operation || typeof operation !== "object" || operation === null) return [method, operation];
19
+ const responses = operation.responses;
20
+ if (!responses) return [method, operation];
21
+ return [method, {
22
+ ...operation,
23
+ responses: Object.fromEntries(Object.entries(responses).filter(([statusCode]) => parseInt(statusCode, 10) < 400))
24
+ }];
25
+ }))];
26
+ }));
27
+ return new ApiDocumentV3_1({
28
+ ...spec,
29
+ paths
30
+ }, document.module);
31
+ });
32
+ });
33
+ compiler.hooks.afterCompile.tap(ValidateStatusCodePlugin.name, () => {
34
+ const artifact = compiler.context.artifacts.find((artifact) => artifact.id === "request");
35
+ if (!artifact) return;
36
+ if (!this.options.modules) {
37
+ artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
38
+ artifact.anchor.prepend("file:end", "request.use(validateStatusCode())\n");
39
+ } else {
40
+ artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
41
+ artifact.anchor.prepend("file:end", [
42
+ "request",
43
+ " .useRouter()",
44
+ ...this.options.modules.map((moduleName) => ` .module(${JSON.stringify(moduleName)}, validateStatusCode())`),
45
+ ""
46
+ ].join("\n"));
47
+ }
48
+ return artifact;
49
+ });
50
+ }
68
51
  };
52
+ //#endregion
53
+ export { ValidateStatusCodePlugin };
54
+
55
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../plugins/validate-status-code.ts"],"sourcesContent":["import { ApiDocumentV3_1, Artifact, Compiler, Plugin } from '@keq-request/cli'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\n\ninterface Options {\n modules?: string[]\n}\n\nexport class ValidateStatusCodePlugin implements Plugin {\n constructor(private options: Options = {}) {}\n\n apply(compiler: Compiler): void {\n if (this.options.modules && this.options.modules.length === 0) return\n\n // remove 4xx and 5xx responses from OpenAPI documents\n compiler.hooks.afterDownload.tap(ValidateStatusCodePlugin.name, () => {\n const documents = compiler.context.documents!\n\n compiler.context.documents = documents.map((document: ApiDocumentV3_1): ApiDocumentV3_1 => {\n if (this.options.modules && !this.options.modules.includes(document.module.name)) {\n return document\n }\n\n const spec: OpenAPIV3_1.Document = document.specification\n\n if (!spec.paths || typeof spec.paths !== 'object' || spec.paths === null) return document\n\n const paths = Object.fromEntries(\n Object.entries(spec.paths)\n .map(([path, pathItem]) => {\n if (!pathItem || typeof pathItem !== 'object' || pathItem === null) return [path, pathItem]\n\n return [\n path,\n Object.fromEntries(\n Object.entries(pathItem)\n .map(([method, operation]) => {\n if (!operation || typeof operation !== 'object' || operation === null) return [method, operation]\n\n const responses = operation.responses\n if (!responses) return [method, operation]\n\n return [\n method,\n {\n ...operation,\n\n responses: Object.fromEntries(\n Object.entries(responses)\n .filter(([statusCode]) => parseInt(statusCode, 10) < 400),\n ),\n },\n ]\n }),\n ),\n ]\n }),\n )\n\n return new ApiDocumentV3_1({ ...spec, paths }, document.module)\n })\n })\n\n // inject validateStatusCode middleware into generated code\n compiler.hooks.afterCompile.tap(ValidateStatusCodePlugin.name, () => {\n const artifact = compiler.context.artifacts!.find((artifact) => artifact.id === 'request')\n if (!artifact) return\n\n if (!this.options.modules) {\n artifact.anchor.append('file:start', \"import { validateStatusCode } from '@keq-request/exception'\\n\")\n artifact.anchor.prepend('file:end', 'request.use(validateStatusCode())\\n')\n } else {\n artifact.anchor.append('file:start', \"import { validateStatusCode } from '@keq-request/exception'\\n\")\n artifact.anchor.prepend(\n 'file:end',\n [\n 'request',\n ' .useRouter()',\n ...this.options.modules.map((moduleName) => ` .module(${JSON.stringify(moduleName)}, validateStatusCode())`),\n '',\n ].join('\\n'),\n )\n }\n\n return artifact\n })\n }\n}\n"],"mappings":";;AAQA,IAAa,2BAAb,MAAa,yBAA2C;CACtD,YAAY,UAA2B,EAAE,EAAE;AAAvB,OAAA,UAAA;;CAEpB,MAAM,UAA0B;AAC9B,MAAI,KAAK,QAAQ,WAAW,KAAK,QAAQ,QAAQ,WAAW,EAAG;AAG/D,WAAS,MAAM,cAAc,IAAI,yBAAyB,YAAY;GACpE,MAAM,YAAY,SAAS,QAAQ;AAEnC,YAAS,QAAQ,YAAY,UAAU,KAAK,aAA+C;AACzF,QAAI,KAAK,QAAQ,WAAW,CAAC,KAAK,QAAQ,QAAQ,SAAS,SAAS,OAAO,KAAK,CAC9E,QAAO;IAGT,MAAM,OAA6B,SAAS;AAE5C,QAAI,CAAC,KAAK,SAAS,OAAO,KAAK,UAAU,YAAY,KAAK,UAAU,KAAM,QAAO;IAEjF,M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.35",
4
4
  "description": "Request exception for keq",
5
5
  "keywords": [
6
6
  "keq",
@@ -34,23 +34,23 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "type-fest": "^5.3.0"
37
+ "type-fest": "^5.6.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@scalar/openapi-types": "^0.5.2",
41
- "@types/node": "^20.19.25",
42
- "@keq-request/cli": "5.0.0-alpha.34",
43
- "keq": "5.0.0-alpha.34"
40
+ "@scalar/openapi-types": "^0.8.0",
41
+ "@types/node": "^20.19.39",
42
+ "@keq-request/cli": "5.0.0-alpha.35",
43
+ "keq": "5.0.0-alpha.35"
44
44
  },
45
45
  "peerDependencies": {
46
- "keq": "^5.0.0-alpha.34"
46
+ "keq": "^5.0.0-alpha.35"
47
47
  },
48
48
  "optionalDependencies": {
49
- "@keq-request/cli": "5.0.0-alpha.34"
49
+ "@keq-request/cli": "5.0.0-alpha.35"
50
50
  },
51
51
  "scripts": {
52
- "build": "tsup",
53
- "dev": "tsup --watch",
52
+ "build": "tsdown",
53
+ "dev": "tsdown --watch",
54
54
  "test": "jest",
55
55
  "test:update": "jest -u"
56
56
  }
@@ -0,0 +1,25 @@
1
+ import { defineConfig } from 'tsdown'
2
+
3
+ export default defineConfig([
4
+ {
5
+ entry: ['src/index.ts'],
6
+ format: ['cjs', 'esm'],
7
+ target: ['chrome91', 'firefox90', 'safari15', 'edge91', 'node20'],
8
+ outDir: 'dist',
9
+ platform: 'neutral',
10
+ tsconfig: 'tsconfig.lib.json',
11
+ dts: { sourcemap: true },
12
+ sourcemap: true,
13
+ clean: true,
14
+ },
15
+ {
16
+ entry: ['./plugins/index.ts'],
17
+ format: ['cjs', 'esm'],
18
+ outDir: 'dist/plugins',
19
+ platform: 'neutral',
20
+ target: ['node20'],
21
+ dts: true,
22
+ tsconfig: './plugins/tsconfig.json',
23
+ deps: { neverBundle: ['@keq-request/cli', '@scalar/openapi-types'] },
24
+ },
25
+ ])
@@ -1,4 +0,0 @@
1
- import { KeqMiddleware } from 'keq';
2
- import { Promisable } from 'type-fest';
3
- export declare function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware;
4
- //# sourceMappingURL=catch-exception.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"catch-exception.d.ts","sourceRoot":"","sources":["../src/catch-exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAGtC,wBAAgB,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,UAAU,CAAC,IAAI,CAAC,GAAG,aAAa,CAQvF"}
@@ -1,2 +0,0 @@
1
- export declare function createExceptionByStatusCode(response: Response): Error;
2
- //# sourceMappingURL=create-exception-by-status-code.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-exception-by-status-code.d.ts","sourceRoot":"","sources":["../src/create-exception-by-status-code.ts"],"names":[],"mappings":"AAwBA,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CA8DrE"}
@@ -1,5 +0,0 @@
1
- import { KeqContext, KeqMiddleware } from 'keq';
2
- import { Promisable } from 'type-fest';
3
- export type Check = (ctx: KeqContext) => Promisable<void>;
4
- export declare function throwException(check: Check): KeqMiddleware;
5
- //# sourceMappingURL=throw-exception.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"throw-exception.d.ts","sourceRoot":"","sources":["../src/throw-exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAGtC,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,UAAU,KAAK,UAAU,CAAC,IAAI,CAAC,CAAA;AAEzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAM1D"}
@@ -1,3 +0,0 @@
1
- import { KeqMiddleware } from 'keq';
2
- export declare function validateStatusCode(): KeqMiddleware;
3
- //# sourceMappingURL=validate-status-code.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-status-code.d.ts","sourceRoot":"","sources":["../src/validate-status-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAGnC,wBAAgB,kBAAkB,IAAI,aAAa,CAiBlD"}