@keq-request/exception 5.0.0-alpha.21 → 5.0.0-alpha.23

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,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0-alpha.23
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [842e555]
8
+ - Updated dependencies [7873a0a]
9
+ - keq@5.0.0-alpha.23
10
+
11
+ ## 5.0.0-alpha.22
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [df114d1]
16
+ - keq@5.0.0-alpha.22
17
+
3
18
  ## 5.0.0-alpha.21
4
19
 
5
20
  ### Patch Changes
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ function catchException(handler) {
48
48
  // src/validate-status-code.ts
49
49
  var import_keq = require("keq");
50
50
  function validateStatusCode() {
51
- return async (context, next) => {
51
+ return async function validateStatusCode2(context, next) {
52
52
  await next();
53
53
  const response = context.response;
54
54
  if (!response) return;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/throw-exception.ts","../src/catch-exception.ts","../src/validate-status-code.ts"],"sourcesContent":["export * from './throw-exception.js'\nexport * from './catch-exception.js'\nexport * from './validate-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 KeqMiddleware,\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 validateStatusCode(): KeqMiddleware {\n return async (context, next) => {\n await next()\n\n const response = context.response\n if (!response) return\n\n const { status, statusText } = 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 // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n throw new BadRequestException(statusText)\n case 401:\n throw new UnauthorizedException(statusText)\n case 403:\n throw new ForbiddenException(statusText)\n case 404:\n throw new NotFoundedException(statusText)\n case 405:\n throw new MethodNotAllowedException(statusText)\n case 406:\n throw new NotAcceptableException(statusText)\n case 407:\n throw new ProxyAuthenticationRequiredException(statusText)\n case 408:\n throw new RequestTimeoutException(statusText)\n case 409:\n throw new ConflictException(statusText)\n case 412:\n throw new PreconditionFailedException(statusText)\n case 413:\n throw new ContentTooLargeException(statusText)\n case 414:\n throw new UriTooLongException(statusText)\n case 415:\n throw new UnsupportedMediaTypeException(statusText)\n case 418:\n throw new ImATeapotException(statusText)\n case 429:\n throw new TooManyRequestsException(statusText)\n default:\n // Other 4xx errors, don't retry by default\n throw new RequestException(status, statusText, false)\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n throw new InternalServerErrorException(statusText)\n case 501:\n throw new NotImplementedException(statusText)\n case 502:\n throw new BadGatewayException(statusText)\n case 503:\n throw new ServiceUnavailableException(statusText)\n case 504:\n throw new GatewayTimeoutException(statusText)\n default:\n // Other 5xx errors, retry by default\n throw new RequestException(status, statusText, true)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA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gBAAM,IAAI,+BAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,yCAA8B,UAAU;AAAA,QACpD,KAAK;AACH,gBAAM,IAAI,8BAAmB,UAAU;AAAA,QACzC,KAAK;AACH,gBAAM,IAAI,oCAAyB,UAAU;AAAA,QAC/C;AAEE,gBAAM,IAAI,4BAAiB,QAAQ,YAAY,KAAK;AAAA,MACtD;AAAA,IACF;AAGA,QAAI,UAAU,KAAK;AACjB,cAAQ,QAAQ;AAAA,QAChB,KAAK;AACH,gBAAM,IAAI,wCAA6B,UAAU;AAAA,QACnD,KAAK;AACH,gBAAM,IAAI,mCAAwB,UAAU;AAAA,QAC9C,KAAK;AACH,gBAAM,IAAI,+BAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,uCAA4B,UAAU;AAAA,QAClD,KAAK;AACH,gBAAM,IAAI,mCAAwB,UAAU;AAAA,QAC9C;AAEE,gBAAM,IAAI,4BAAiB,QAAQ,YAAY,IAAI;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACF;","names":["throwException","catchException"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/throw-exception.ts","../src/catch-exception.ts","../src/validate-status-code.ts"],"sourcesContent":["export * from './throw-exception.js'\nexport * from './catch-exception.js'\nexport * from './validate-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 KeqMiddleware,\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 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, statusText } = 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 // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n throw new BadRequestException(statusText)\n case 401:\n throw new UnauthorizedException(statusText)\n case 403:\n throw new ForbiddenException(statusText)\n case 404:\n throw new NotFoundedException(statusText)\n case 405:\n throw new MethodNotAllowedException(statusText)\n case 406:\n throw new NotAcceptableException(statusText)\n case 407:\n throw new ProxyAuthenticationRequiredException(statusText)\n case 408:\n throw new RequestTimeoutException(statusText)\n case 409:\n throw new ConflictException(statusText)\n case 412:\n throw new PreconditionFailedException(statusText)\n case 413:\n throw new ContentTooLargeException(statusText)\n case 414:\n throw new UriTooLongException(statusText)\n case 415:\n throw new UnsupportedMediaTypeException(statusText)\n case 418:\n throw new ImATeapotException(statusText)\n case 429:\n throw new TooManyRequestsException(statusText)\n default:\n // Other 4xx errors, don't retry by default\n throw new RequestException(status, statusText, false)\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n throw new InternalServerErrorException(statusText)\n case 501:\n throw new NotImplementedException(statusText)\n case 502:\n throw new BadGatewayException(statusText)\n case 503:\n throw new ServiceUnavailableException(statusText)\n case 504:\n throw new GatewayTimeoutException(statusText)\n default:\n // Other 5xx errors, retry by default\n throw new RequestException(status, statusText, true)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;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/C,KAAK;AACH,gBAAM,IAAI,+BAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,yCAA8B,UAAU;AAAA,QACpD,KAAK;AACH,gBAAM,IAAI,8BAAmB,UAAU;AAAA,QACzC,KAAK;AACH,gBAAM,IAAI,oCAAyB,UAAU;AAAA,QAC/C;AAEE,gBAAM,IAAI,4BAAiB,QAAQ,YAAY,KAAK;AAAA,MACtD;AAAA,IACF;AAGA,QAAI,UAAU,KAAK;AACjB,cAAQ,QAAQ;AAAA,QAChB,KAAK;AACH,gBAAM,IAAI,wCAA6B,UAAU;AAAA,QACnD,KAAK;AACH,gBAAM,IAAI,mCAAwB,UAAU;AAAA,QAC9C,KAAK;AACH,gBAAM,IAAI,+BAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,uCAA4B,UAAU;AAAA,QAClD,KAAK;AACH,gBAAM,IAAI,mCAAwB,UAAU;AAAA,QAC9C;AAEE,gBAAM,IAAI,4BAAiB,QAAQ,YAAY,IAAI;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACF;","names":["throwException","catchException","validateStatusCode"]}
package/dist/index.mjs CHANGED
@@ -42,7 +42,7 @@ import {
42
42
  UnsupportedMediaTypeException
43
43
  } from "keq";
44
44
  function validateStatusCode() {
45
- return async (context, next) => {
45
+ return async function validateStatusCode2(context, next) {
46
46
  await next();
47
47
  const response = context.response;
48
48
  if (!response) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/throw-exception.ts","../src/catch-exception.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 KeqMiddleware,\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 validateStatusCode(): KeqMiddleware {\n return async (context, next) => {\n await next()\n\n const response = context.response\n if (!response) return\n\n const { status, statusText } = 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 // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n throw new BadRequestException(statusText)\n case 401:\n throw new UnauthorizedException(statusText)\n case 403:\n throw new ForbiddenException(statusText)\n case 404:\n throw new NotFoundedException(statusText)\n case 405:\n throw new MethodNotAllowedException(statusText)\n case 406:\n throw new NotAcceptableException(statusText)\n case 407:\n throw new ProxyAuthenticationRequiredException(statusText)\n case 408:\n throw new RequestTimeoutException(statusText)\n case 409:\n throw new ConflictException(statusText)\n case 412:\n throw new PreconditionFailedException(statusText)\n case 413:\n throw new ContentTooLargeException(statusText)\n case 414:\n throw new UriTooLongException(statusText)\n case 415:\n throw new UnsupportedMediaTypeException(statusText)\n case 418:\n throw new ImATeapotException(statusText)\n case 429:\n throw new TooManyRequestsException(statusText)\n default:\n // Other 4xx errors, don't retry by default\n throw new RequestException(status, statusText, false)\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n throw new InternalServerErrorException(statusText)\n case 501:\n throw new NotImplementedException(statusText)\n case 502:\n throw new BadGatewayException(statusText)\n case 503:\n throw new ServiceUnavailableException(statusText)\n case 504:\n throw new GatewayTimeoutException(statusText)\n default:\n // Other 5xx errors, retry by default\n throw new RequestException(status, statusText, true)\n }\n }\n }\n}\n"],"mappings":";AAMO,SAAS,eAAe,OAA6B;AAC1D,SAAO,eAAeA,gBAAe,KAAK,MAAM;AAC9C,UAAM,KAAK;AAEX,UAAM,MAAM,GAAG;AAAA,EACjB;AACF;;;ACRO,SAAS,eAAe,SAA0D;AACvF,SAAO,eAAeC,gBAAe,KAAK,MAAM;AAC9C,QAAI;AACF,YAAM,KAAK;AAAA,IACb,SAAS,KAAK;AACZ,YAAM,QAAQ,GAAG;AAAA,IACnB;AAAA,EACF;AACF;;;ACZA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,SAAS,qBAAoC;AAClD,SAAO,OAAO,SAAS,SAAS;AAC9B,UAAM,KAAK;AAEX,UAAM,WAAW,QAAQ;AACzB,QAAI,CAAC,SAAU;AAEf,UAAM,EAAE,QAAQ,WAAW,IAAI;AAG/B,QAAI,UAAU,OAAO,SAAS,IAAK;AAGnC,QAAI,UAAU,OAAO,SAAS,IAAK;AAGnC,QAAI,UAAU,OAAO,SAAS,KAAK;AACjC,cAAQ,QAAQ;AAAA,QAChB,KAAK;AACH,gBAAM,IAAI,oBAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,sBAAsB,UAAU;AAAA,QAC5C,KAAK;AACH,gBAAM,IAAI,mBAAmB,UAAU;AAAA,QACzC,KAAK;AACH,gBAAM,IAAI,oBAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,0BAA0B,UAAU;AAAA,QAChD,KAAK;AACH,gBAAM,IAAI,uBAAuB,UAAU;AAAA,QAC7C,KAAK;AACH,gBAAM,IAAI,qCAAqC,UAAU;AAAA,QAC3D,KAAK;AACH,gBAAM,IAAI,wBAAwB,UAAU;AAAA,QAC9C,KAAK;AACH,gBAAM,IAAI,kBAAkB,UAAU;AAAA,QACxC,KAAK;AACH,gBAAM,IAAI,4BAA4B,UAAU;AAAA,QAClD,KAAK;AACH,gBAAM,IAAI,yBAAyB,UAAU;AAAA,QAC/C,KAAK;AACH,gBAAM,IAAI,oBAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,8BAA8B,UAAU;AAAA,QACpD,KAAK;AACH,gBAAM,IAAI,mBAAmB,UAAU;AAAA,QACzC,KAAK;AACH,gBAAM,IAAI,yBAAyB,UAAU;AAAA,QAC/C;AAEE,gBAAM,IAAI,iBAAiB,QAAQ,YAAY,KAAK;AAAA,MACtD;AAAA,IACF;AAGA,QAAI,UAAU,KAAK;AACjB,cAAQ,QAAQ;AAAA,QAChB,KAAK;AACH,gBAAM,IAAI,6BAA6B,UAAU;AAAA,QACnD,KAAK;AACH,gBAAM,IAAI,wBAAwB,UAAU;AAAA,QAC9C,KAAK;AACH,gBAAM,IAAI,oBAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,4BAA4B,UAAU;AAAA,QAClD,KAAK;AACH,gBAAM,IAAI,wBAAwB,UAAU;AAAA,QAC9C;AAEE,gBAAM,IAAI,iBAAiB,QAAQ,YAAY,IAAI;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACF;","names":["throwException","catchException"]}
1
+ {"version":3,"sources":["../src/throw-exception.ts","../src/catch-exception.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 KeqMiddleware,\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 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, statusText } = 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 // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n throw new BadRequestException(statusText)\n case 401:\n throw new UnauthorizedException(statusText)\n case 403:\n throw new ForbiddenException(statusText)\n case 404:\n throw new NotFoundedException(statusText)\n case 405:\n throw new MethodNotAllowedException(statusText)\n case 406:\n throw new NotAcceptableException(statusText)\n case 407:\n throw new ProxyAuthenticationRequiredException(statusText)\n case 408:\n throw new RequestTimeoutException(statusText)\n case 409:\n throw new ConflictException(statusText)\n case 412:\n throw new PreconditionFailedException(statusText)\n case 413:\n throw new ContentTooLargeException(statusText)\n case 414:\n throw new UriTooLongException(statusText)\n case 415:\n throw new UnsupportedMediaTypeException(statusText)\n case 418:\n throw new ImATeapotException(statusText)\n case 429:\n throw new TooManyRequestsException(statusText)\n default:\n // Other 4xx errors, don't retry by default\n throw new RequestException(status, statusText, false)\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n throw new InternalServerErrorException(statusText)\n case 501:\n throw new NotImplementedException(statusText)\n case 502:\n throw new BadGatewayException(statusText)\n case 503:\n throw new ServiceUnavailableException(statusText)\n case 504:\n throw new GatewayTimeoutException(statusText)\n default:\n // Other 5xx errors, retry by default\n throw new RequestException(status, statusText, true)\n }\n }\n }\n}\n"],"mappings":";AAMO,SAAS,eAAe,OAA6B;AAC1D,SAAO,eAAeA,gBAAe,KAAK,MAAM;AAC9C,UAAM,KAAK;AAEX,UAAM,MAAM,GAAG;AAAA,EACjB;AACF;;;ACRO,SAAS,eAAe,SAA0D;AACvF,SAAO,eAAeC,gBAAe,KAAK,MAAM;AAC9C,QAAI;AACF,YAAM,KAAK;AAAA,IACb,SAAS,KAAK;AACZ,YAAM,QAAQ,GAAG;AAAA,IACnB;AAAA,EACF;AACF;;;ACZA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,SAAS,qBAAoC;AAClD,SAAO,eAAeC,oBAAmB,SAAS,MAAM;AACtD,UAAM,KAAK;AAEX,UAAM,WAAW,QAAQ;AACzB,QAAI,CAAC,SAAU;AAEf,UAAM,EAAE,QAAQ,WAAW,IAAI;AAG/B,QAAI,UAAU,OAAO,SAAS,IAAK;AAGnC,QAAI,UAAU,OAAO,SAAS,IAAK;AAGnC,QAAI,UAAU,OAAO,SAAS,KAAK;AACjC,cAAQ,QAAQ;AAAA,QAChB,KAAK;AACH,gBAAM,IAAI,oBAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,sBAAsB,UAAU;AAAA,QAC5C,KAAK;AACH,gBAAM,IAAI,mBAAmB,UAAU;AAAA,QACzC,KAAK;AACH,gBAAM,IAAI,oBAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,0BAA0B,UAAU;AAAA,QAChD,KAAK;AACH,gBAAM,IAAI,uBAAuB,UAAU;AAAA,QAC7C,KAAK;AACH,gBAAM,IAAI,qCAAqC,UAAU;AAAA,QAC3D,KAAK;AACH,gBAAM,IAAI,wBAAwB,UAAU;AAAA,QAC9C,KAAK;AACH,gBAAM,IAAI,kBAAkB,UAAU;AAAA,QACxC,KAAK;AACH,gBAAM,IAAI,4BAA4B,UAAU;AAAA,QAClD,KAAK;AACH,gBAAM,IAAI,yBAAyB,UAAU;AAAA,QAC/C,KAAK;AACH,gBAAM,IAAI,oBAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,8BAA8B,UAAU;AAAA,QACpD,KAAK;AACH,gBAAM,IAAI,mBAAmB,UAAU;AAAA,QACzC,KAAK;AACH,gBAAM,IAAI,yBAAyB,UAAU;AAAA,QAC/C;AAEE,gBAAM,IAAI,iBAAiB,QAAQ,YAAY,KAAK;AAAA,MACtD;AAAA,IACF;AAGA,QAAI,UAAU,KAAK;AACjB,cAAQ,QAAQ;AAAA,QAChB,KAAK;AACH,gBAAM,IAAI,6BAA6B,UAAU;AAAA,QACnD,KAAK;AACH,gBAAM,IAAI,wBAAwB,UAAU;AAAA,QAC9C,KAAK;AACH,gBAAM,IAAI,oBAAoB,UAAU;AAAA,QAC1C,KAAK;AACH,gBAAM,IAAI,4BAA4B,UAAU;AAAA,QAClD,KAAK;AACH,gBAAM,IAAI,wBAAwB,UAAU;AAAA,QAC9C;AAEE,gBAAM,IAAI,iBAAiB,QAAQ,YAAY,IAAI;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACF;","names":["throwException","catchException","validateStatusCode"]}
@@ -32,10 +32,9 @@ var ValidateStatusCodePlugin = class _ValidateStatusCodePlugin {
32
32
  }
33
33
  apply(compiler) {
34
34
  if (this.options.modules && this.options.modules.length === 0) return;
35
- compiler.hooks.afterShaking.tap(_ValidateStatusCodePlugin.name, () => {
36
- if (!compiler.context.shaken) return;
37
- const documents = compiler.context.shaken.documents;
38
- compiler.context.shaken.documents = documents.map((document) => {
35
+ compiler.hooks.afterDownload.tap(_ValidateStatusCodePlugin.name, () => {
36
+ const documents = compiler.context.documents;
37
+ compiler.context.documents = documents.map((document) => {
39
38
  if (this.options.modules && !this.options.modules.includes(document.module.name)) {
40
39
  return document;
41
40
  }
@@ -68,11 +67,14 @@ var ValidateStatusCodePlugin = class _ValidateStatusCodePlugin {
68
67
  return new import_cli.ApiDocumentV3_1({ ...spec, paths }, document.module);
69
68
  });
70
69
  });
71
- compiler.hooks.afterCompileKeqRequest.tap(_ValidateStatusCodePlugin.name, (artifact) => {
72
- artifact.addDependence("@keq-request/exception", ["validateStatusCode"]);
70
+ compiler.hooks.afterCompile.tap(_ValidateStatusCodePlugin.name, () => {
71
+ const artifact = compiler.context.artifacts.find((artifact2) => artifact2.id === "request");
72
+ if (!artifact) return;
73
73
  if (!this.options.modules) {
74
+ artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
74
75
  artifact.anchor.prepend("file:end", "request.use(validateStatusCode())\n");
75
76
  } else {
77
+ artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
76
78
  artifact.anchor.prepend(
77
79
  "file:end",
78
80
  [
@@ -6,10 +6,9 @@ var ValidateStatusCodePlugin = class _ValidateStatusCodePlugin {
6
6
  }
7
7
  apply(compiler) {
8
8
  if (this.options.modules && this.options.modules.length === 0) return;
9
- compiler.hooks.afterShaking.tap(_ValidateStatusCodePlugin.name, () => {
10
- if (!compiler.context.shaken) return;
11
- const documents = compiler.context.shaken.documents;
12
- compiler.context.shaken.documents = documents.map((document) => {
9
+ compiler.hooks.afterDownload.tap(_ValidateStatusCodePlugin.name, () => {
10
+ const documents = compiler.context.documents;
11
+ compiler.context.documents = documents.map((document) => {
13
12
  if (this.options.modules && !this.options.modules.includes(document.module.name)) {
14
13
  return document;
15
14
  }
@@ -42,11 +41,14 @@ var ValidateStatusCodePlugin = class _ValidateStatusCodePlugin {
42
41
  return new ApiDocumentV3_1({ ...spec, paths }, document.module);
43
42
  });
44
43
  });
45
- compiler.hooks.afterCompileKeqRequest.tap(_ValidateStatusCodePlugin.name, (artifact) => {
46
- artifact.addDependence("@keq-request/exception", ["validateStatusCode"]);
44
+ compiler.hooks.afterCompile.tap(_ValidateStatusCodePlugin.name, () => {
45
+ const artifact = compiler.context.artifacts.find((artifact2) => artifact2.id === "request");
46
+ if (!artifact) return;
47
47
  if (!this.options.modules) {
48
+ artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
48
49
  artifact.anchor.prepend("file:end", "request.use(validateStatusCode())\n");
49
50
  } else {
51
+ artifact.anchor.append("file:start", "import { validateStatusCode } from '@keq-request/exception'\n");
50
52
  artifact.anchor.prepend(
51
53
  "file:end",
52
54
  [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keq-request/exception",
3
- "version": "5.0.0-alpha.21",
3
+ "version": "5.0.0-alpha.23",
4
4
  "description": "Request exception for keq",
5
5
  "keywords": [
6
6
  "keq",
@@ -39,14 +39,14 @@
39
39
  "devDependencies": {
40
40
  "@scalar/openapi-types": "^0.5.2",
41
41
  "@types/node": "^20.19.25",
42
- "@keq-request/cli": "5.0.0-alpha.21",
43
- "keq": "5.0.0-alpha.21"
42
+ "@keq-request/cli": "5.0.0-alpha.23",
43
+ "keq": "5.0.0-alpha.23"
44
44
  },
45
45
  "peerDependencies": {
46
- "keq": "^5.0.0-alpha.21"
46
+ "keq": "^5.0.0-alpha.23"
47
47
  },
48
48
  "optionalDependencies": {
49
- "@keq-request/cli": "5.0.0-alpha.21"
49
+ "@keq-request/cli": "5.0.0-alpha.23"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup",
@@ -13,12 +13,10 @@ export class ValidateStatusCodePlugin implements Plugin {
13
13
  if (this.options.modules && this.options.modules.length === 0) return
14
14
 
15
15
  // remove 4xx and 5xx responses from OpenAPI documents
16
- compiler.hooks.afterShaking.tap(ValidateStatusCodePlugin.name, () => {
17
- if (!compiler.context.shaken) return
16
+ compiler.hooks.afterDownload.tap(ValidateStatusCodePlugin.name, () => {
17
+ const documents = compiler.context.documents!
18
18
 
19
- const documents = compiler.context.shaken.documents
20
-
21
- compiler.context.shaken.documents = documents.map((document: ApiDocumentV3_1): ApiDocumentV3_1 => {
19
+ compiler.context.documents = documents.map((document: ApiDocumentV3_1): ApiDocumentV3_1 => {
22
20
  if (this.options.modules && !this.options.modules.includes(document.module.name)) {
23
21
  return document
24
22
  }
@@ -64,12 +62,15 @@ export class ValidateStatusCodePlugin implements Plugin {
64
62
  })
65
63
 
66
64
  // inject validateStatusCode middleware into generated code
67
- compiler.hooks.afterCompileKeqRequest.tap(ValidateStatusCodePlugin.name, (artifact: Artifact) => {
68
- artifact.addDependence('@keq-request/exception', ['validateStatusCode'])
65
+ compiler.hooks.afterCompile.tap(ValidateStatusCodePlugin.name, () => {
66
+ const artifact = compiler.context.artifacts!.find((artifact) => artifact.id === 'request')
67
+ if (!artifact) return
69
68
 
70
69
  if (!this.options.modules) {
70
+ artifact.anchor.append('file:start', "import { validateStatusCode } from '@keq-request/exception'\n")
71
71
  artifact.anchor.prepend('file:end', 'request.use(validateStatusCode())\n')
72
72
  } else {
73
+ artifact.anchor.append('file:start', "import { validateStatusCode } from '@keq-request/exception'\n")
73
74
  artifact.anchor.prepend(
74
75
  'file:end',
75
76
  [