keq 5.0.0-alpha.23 → 5.0.0-alpha.24

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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/context/orchestrator-context.ts","../src/context/execution-context.ts","../src/context/shared-context.ts","../src/validator/validator.ts","../src/utils/shallow-clone.ts","../src/exception/exception.ts","../src/request-init/utils/clone-body.ts","../src/request-init/utils/clone-headers.ts","../src/request-init/utils/compile-url.ts","../src/request-init/utils/to-form-data.ts","../src/request-init/utils/to-url-search-params.ts","../src/request-init/utils/clone-request-init.ts","../src/request-init/request-init.ts","../src/context/utils/watch-object.ts","../src/context/utils/clone-shared-context.ts","../src/context/utils/fork.ts","../src/context/utils/create-proxy-response.ts","../src/exception/type.exception.ts","../src/exception/abort.exception.ts","../src/exception/timeout.exception.ts","../src/exception/http-exceptions/request.exception.ts","../src/exception/http-exceptions/bad-request.exception.ts","../src/exception/http-exceptions/unauthorized.exception.ts","../src/exception/http-exceptions/forbidden.exception.ts","../src/exception/http-exceptions/not-founded.exception.ts","../src/exception/http-exceptions/method-not-allowed.exception.ts","../src/exception/http-exceptions/not-acceptable.exception.ts","../src/exception/http-exceptions/proxy-authentication-required.exception.ts","../src/exception/http-exceptions/request-timeout.exception.ts","../src/exception/http-exceptions/conflict.exception.ts","../src/exception/http-exceptions/precondition-failed.exception.ts","../src/exception/http-exceptions/content-too-large.exception.ts","../src/exception/http-exceptions/uri-too-long.exception.ts","../src/exception/http-exceptions/unsupported-media-type.exception.ts","../src/exception/http-exceptions/im-a-teapot.exception.ts","../src/exception/http-exceptions/too-many-requests.exception.ts","../src/exception/http-exceptions/internal-server-error.exception.ts","../src/exception/http-exceptions/not-implemented.exception.ts","../src/exception/http-exceptions/bad-gateway.exception.ts","../src/exception/http-exceptions/service-unavailable.exception.ts","../src/exception/http-exceptions/gateway-timeout.exception.ts","../src/utils/base64.ts","../src/utils/sleep.ts","../src/middleware/utils/get-middleware-name.ts","../src/middleware/utils/compose-middleware.ts","../src/context/middleware-context.ts","../src/orchestrator/executor.ts","../src/request-init/utils/assign-request-init.ts","../src/context/utils/assign-shared-context.ts","../src/orchestrator/orchestrator.ts","../src/request/utils/fix-content-type.ts","../src/request/utils/get-location-id.ts","../src/request/utils/intelligent-parse-response.ts","../src/request/utils/merge-keq-request-body.ts","../src/request/utils/query-stringify.ts","../src/request/core.ts","../src/request/keq.ts","../src/router/utils/compose-route.ts","../src/router/keq-host-route.ts","../src/router/keq-location-route.ts","../src/router/keq-method-route.ts","../src/router/keq-module-route.ts","../src/router/keq-pathname-route.ts","../src/router/keq-router.ts","../src/middlewares/timeout-middleware/index.ts","../src/middlewares/flow-control-middleware/serial-flow-control-middleware.ts","../src/middlewares/flow-control-middleware/abort-flow-control-middleware.ts","../src/middlewares/flow-control-middleware/index.ts","../src/middlewares/fetch-middleware/index.ts","../src/request/request.ts","../src/request/create-request.ts"],"sourcesContent":["export {\n createRequest,\n Keq,\n request,\n KeqRequest,\n type KeqOptions,\n type KeqApiSchema,\n type KeqOperation,\n type KeqDefaultOperation,\n type KeqQueryInit,\n type KeqPathParameterInit,\n type KeqQueryOptions,\n} from './request'\n\nexport {\n type KeqBodyInit,\n} from './request-init'\n\nexport {\n composeMiddleware,\n type KeqMiddleware,\n type KeqNext,\n} from './middleware'\n\nexport {\n type KeqRoute,\n composeRoute,\n keqHostRoute,\n keqLocationRoute,\n keqMethodRoute,\n keqModuleRoute,\n keqPathnameRoute,\n} from './router'\n\nexport {\n createProxyResponse,\n KeqExecutionContext,\n KeqSharedContext,\n type KeqSharedContextOptions,\n type KeqContext,\n type KeqContextData,\n type KeqContextEmitter,\n type KeqGlobal,\n type KeqContextOptions,\n type KeqMiddlewareOptions,\n type KeqEvents,\n type KeqRetryDelay,\n type KeqRetryOn,\n} from './context'\n\nexport {\n Exception,\n TypeException,\n TimeoutException,\n AbortException,\n\n RequestException,\n\n BadRequestException,\n UnauthorizedException,\n ForbiddenException,\n NotFoundedException,\n MethodNotAllowedException,\n NotAcceptableException,\n ProxyAuthenticationRequiredException,\n RequestTimeoutException,\n ConflictException,\n PreconditionFailedException,\n ContentTooLargeException,\n UriTooLongException,\n ImATeapotException,\n TooManyRequestsException,\n UnsupportedMediaTypeException,\n\n InternalServerErrorException,\n NotImplementedException,\n BadGatewayException,\n ServiceUnavailableException,\n GatewayTimeoutException,\n} from './exception'\n\nexport {\n KeqMiddlewareOrchestrator,\n KeqMiddlewareExecutor,\n} from './orchestrator'\n","import type { KeqMiddlewareExecutor, KeqMiddlewareOrchestrator } from '~/orchestrator/index.js'\nimport { KeqMiddlewareContext } from './middleware-context.js'\n\n\nconst OrchestratorProperty = Symbol('protected context.orchestration.orchestrator')\nconst ExecutorProperty = Symbol('protected context.orchestration.executor')\n\nexport class KeqOrchestratorContext {\n readonly [OrchestratorProperty]: KeqMiddlewareOrchestrator\n readonly [ExecutorProperty]: KeqMiddlewareExecutor\n\n constructor(orchestrator: KeqMiddlewareOrchestrator, executor: KeqMiddlewareExecutor) {\n this[OrchestratorProperty] = orchestrator\n this[ExecutorProperty] = executor\n }\n\n get middlewares(): KeqMiddlewareContext[] {\n return this[OrchestratorProperty].executors.map((exe) => exe.context)\n }\n\n // NOTE: For Future\n // get executing(): KeqMiddlewareContext {\n // const current = this[OrchestratorProperty].current\n // const executors = this[OrchestratorProperty].executors\n // const executor = executors[current]\n // return executor.context\n // }\n\n /**\n * The middleware context of the current middleware\n */\n get middleware(): KeqMiddlewareContext {\n return this[ExecutorProperty].context\n }\n\n fork(): KeqMiddlewareOrchestrator {\n return this[OrchestratorProperty].fork()\n }\n\n merge(source: KeqMiddlewareOrchestrator): void {\n this[OrchestratorProperty].merge(source)\n }\n}\n","import { KeqMiddlewareExecutor, KeqMiddlewareOrchestrator } from '~/orchestrator/index.js'\nimport { KeqRequestInit } from '~/request-init/index.js'\nimport { KeqOrchestratorContext } from './orchestrator-context.js'\nimport type {\n KeqContext,\n KeqContextData,\n KeqContextEmitter,\n KeqContextOptions,\n KeqGlobal,\n} from './types/index.js'\n\nexport const ContextOrchestratorProperty = Symbol('protected context.orchestrator')\nexport const ContextOrchestrationProperty = Symbol('protected context.orchestration')\n\n\nexport class KeqExecutionContext implements KeqContext {\n private [ContextOrchestratorProperty]: KeqMiddlewareOrchestrator\n private [ContextOrchestrationProperty]: KeqOrchestratorContext\n\n constructor(orchestrator: KeqMiddlewareOrchestrator, executor: KeqMiddlewareExecutor) {\n this[ContextOrchestratorProperty] = orchestrator\n this[ContextOrchestrationProperty] = new KeqOrchestratorContext(orchestrator, executor)\n }\n\n get orchestration(): KeqOrchestratorContext {\n return this[ContextOrchestrationProperty]\n }\n\n /**\n * The unique identifier of the request's location in the code\n */\n get locationId(): string | undefined {\n return this[ContextOrchestratorProperty].context.locationId\n }\n\n get request(): KeqRequestInit {\n return this[ContextOrchestratorProperty].context.request\n }\n\n get global(): KeqGlobal {\n return this[ContextOrchestratorProperty].context.global\n }\n\n get emitter(): KeqContextEmitter {\n return this[ContextOrchestratorProperty].context.emitter\n }\n\n get options(): KeqContextOptions {\n return this[ContextOrchestratorProperty].context.options\n }\n\n // The result get by user if resolveWith is set to 'intelligent' or not set\n set output(value: any) {\n if (this.options.resolveWith && this.options.resolveWith !== 'intelligent') {\n console.warn(`The request is configured to resolve with ${this.options.resolveWith}, so setting context.output maybe no effect.`)\n }\n this[ContextOrchestratorProperty].context.output = value\n }\n\n // The original response\n get res(): Response | undefined {\n return this[ContextOrchestratorProperty].context.res\n }\n\n // The original response\n set res(value: Response | undefined) {\n this[ContextOrchestratorProperty].context.res = value\n }\n\n // The request response\n get response(): Response | undefined {\n return this[ContextOrchestratorProperty].context.response\n }\n\n // The properties extends by middleware\n get data(): KeqContextData {\n return this[ContextOrchestratorProperty].context.data\n }\n}\n","import mitt from 'mitt'\nimport {\n KeqRequestInit,\n KeqRequestInitOptions,\n} from '~/request-init/index.js'\nimport { shallowClone } from '~/utils/shallow-clone.js'\nimport {\n watchObject,\n createProxyResponse,\n} from './utils/index.js'\nimport type {\n KeqContext,\n KeqContextOptions,\n KeqContextEmitter,\n KeqContextData,\n KeqGlobal,\n KeqEvents,\n} from './types/index.js'\n\nexport interface KeqSharedContextOptions {\n locationId?: string\n request: KeqRequestInitOptions\n global: KeqGlobal\n options?: KeqContextOptions\n data?: KeqContextData\n emitter?: KeqContextEmitter\n}\n\nexport const ContextLocationIdProperty = Symbol('protected context.locationId')\nexport const ContextRequestProperty = Symbol('protected context.request')\nexport const ContextGlobalProperty = Symbol('protected context.global')\nexport const ContextEmitterProperty = Symbol('protected context.emitter')\nexport const ContextOptionsProperty = Symbol('protected context.options')\nexport const ContextDataProperty = Symbol('protected context.data')\nexport const ContextOutputProperty = Symbol('protected context.output')\n\nexport class KeqSharedContext implements KeqContext {\n readonly [ContextLocationIdProperty]?: string\n [ContextRequestProperty]: KeqRequestInit\n [ContextGlobalProperty]: Record<string, any>\n [ContextEmitterProperty]: KeqContextEmitter\n [ContextOptionsProperty]: KeqContextOptions\n [ContextOutputProperty]?: any\n\n // The properties extends by middleware\n [ContextDataProperty]: KeqContextData = {}\n\n\n /**\n * original response\n */\n res?: Response\n\n constructor(options: KeqSharedContextOptions) {\n this[ContextLocationIdProperty] = options.locationId\n\n this[ContextRequestProperty] = watchObject(new KeqRequestInit(options.request), {\n abort: (target, thisArg, argArray) => {\n this[ContextEmitterProperty].emit('abort', { context: this, reason: argArray[0] })\n },\n })\n\n this[ContextEmitterProperty] = options.emitter || mitt<Omit<KeqEvents, never>>()\n this[ContextGlobalProperty] = options.global\n this[ContextOptionsProperty] = options.options ? shallowClone(options.options) : {}\n this[ContextDataProperty] = options.data || {}\n }\n\n /**\n * The unique identifier of the request's location in the code\n */\n get locationId(): string | undefined {\n return this[ContextLocationIdProperty]\n }\n\n get request(): KeqRequestInit {\n return this[ContextRequestProperty]\n }\n\n get global(): KeqGlobal {\n return this[ContextGlobalProperty]\n }\n\n get emitter(): KeqContextEmitter {\n return this[ContextEmitterProperty]\n }\n\n get options(): KeqContextOptions {\n return this[ContextOptionsProperty]\n }\n\n set output(value: any) {\n this[ContextOutputProperty] = value\n }\n\n get response(): Response | undefined {\n if (!this.res) return undefined\n\n return createProxyResponse(this.res)\n }\n\n get data(): KeqContextData {\n return this[ContextDataProperty]\n }\n}\n\n\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Validator 类用于类型检查\n */\nexport class Validator {\n /**\n * 检查是否为浏览器环境\n */\n static isBrowser(): boolean {\n return typeof window !== 'undefined'\n }\n\n /**\n * 检查是否为字符串\n */\n static isString(value: any): boolean {\n return typeof value === 'string'\n }\n\n /**\n * 检查是否为对象\n */\n static isObject(value: any): value is Exclude<object, null> {\n return typeof value === 'object' && value !== null\n }\n\n /**\n * 检查是否为函数\n */\n static isFunction(value: any): boolean {\n return typeof value === 'function'\n }\n\n /**\n * 检查是否为 ArrayBuffer\n */\n static isArrayBuffer(body: any): body is ArrayBuffer {\n return body instanceof ArrayBuffer\n }\n\n /**\n * 检查是否为 ReadableStream\n */\n static isReadableStream(body: any): body is ReadableStream {\n return body instanceof ReadableStream\n }\n\n /**\n * 检查是否为 Blob 或 File 类对象\n */\n static isBlob(value: any): value is Blob {\n if (value instanceof Blob) return true\n\n const names = ['Blob', 'File']\n\n return Validator.isObject(value)\n && Validator.isString(value['type'])\n && Validator.isFunction(value['arrayBuffer'])\n && Validator.isFunction(value['stream'])\n && Validator.isFunction(value.constructor)\n && names.includes(value.constructor.name)\n && 'size' in value\n }\n\n /**\n * 检查是否为 File\n */\n static isFile(object: any): object is File {\n if (Validator.isBrowser()) return object instanceof Blob\n\n return Validator.isBlob(object)\n }\n\n /**\n * 检查是否为 Buffer\n */\n static isBuffer(obj: any): obj is Buffer {\n return Validator.isBrowser() ? false : Buffer.isBuffer(obj)\n }\n\n /**\n * 检查是否为 FormData\n */\n static isFormData(object: any): object is FormData {\n if (object instanceof FormData) return true\n\n return (\n Validator.isObject(object)\n && Validator.isFunction(object['append'])\n && Validator.isFunction(object['delete'])\n && Validator.isFunction(object['get'])\n && Validator.isFunction(object['getAll'])\n && Validator.isFunction(object['has'])\n && Validator.isFunction(object['set'])\n && Validator.isFunction(object['entries'])\n && Validator.isFunction(object['keys'])\n && Validator.isFunction(object['values'])\n )\n }\n\n /**\n * 检查是否为 Headers\n */\n static isHeaders(obj: any): obj is Headers {\n if (obj instanceof Headers) return true\n\n if (\n Validator.isObject(obj)\n && Validator.isFunction(obj['forEach'])\n && Validator.isFunction(obj['get'])\n && Validator.isFunction(obj['has'])\n && Validator.isFunction(obj['set'])\n && Validator.isFunction(obj['append'])\n && Validator.isFunction(obj['delete'])\n && Validator.isFunction(obj['entries'])\n && Validator.isFunction(obj['keys'])\n && Validator.isFunction(obj['values'])\n ) {\n return true\n }\n\n return false\n }\n\n /**\n * 检查是否为 URLSearchParams\n */\n static isUrlSearchParams(obj: any): obj is URLSearchParams {\n if (obj instanceof URLSearchParams) return true\n\n return (\n Validator.isObject(obj)\n && Validator.isFunction(obj['append'])\n && Validator.isFunction(obj['delete'])\n && Validator.isFunction(obj['entries'])\n && Validator.isFunction(obj['forEach'])\n && Validator.isFunction(obj['get'])\n && Validator.isFunction(obj['getAll'])\n && Validator.isFunction(obj['has'])\n && Validator.isFunction(obj['keys'])\n && Validator.isFunction(obj['set'])\n && Validator.isFunction(obj['values'])\n && Validator.isFunction(obj['sort'])\n && Validator.isFunction(obj['toString'])\n )\n }\n\n /**\n * 检查是否为合法的 Header 值\n * 允许范围: HTAB(\\t), 0x20-0x7E, 0x80-0xFF\n * 禁止换行等控制字符\n */\n static isHeaderValue(str: any): boolean {\n const regex = /^[\\t\\x20-\\x7E\\x80-\\xFF]*$/\n return regex.test(String(str))\n }\n\n /**\n * 检查是否为 BodyInit 类型\n * BodyInit 包括: Blob | ArrayBuffer | TypedArray | DataView | FormData | URLSearchParams | ReadableStream | string\n */\n static isBodyInit(value: any): value is BodyInit {\n if (value === null || value === undefined) return false\n\n return (\n Validator.isString(value)\n || Validator.isBlob(value)\n || Validator.isArrayBuffer(value)\n || Validator.isFormData(value)\n || Validator.isUrlSearchParams(value)\n || Validator.isReadableStream(value)\n || Validator.isBuffer(value)\n // TypedArray or DataView\n || ArrayBuffer.isView(value)\n )\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Validator } from '~/validator/index.js'\n\n\n/**\n * @description 浅拷贝\n */\nexport function shallowClone<T = any>(obj: T): T {\n if (Array.isArray(obj)) {\n return [...obj] as T\n }\n\n if (Validator.isObject(obj)) {\n return { ...obj }\n }\n\n return obj\n}\n","import { CustomError } from 'ts-custom-error'\n\nexport class Exception extends CustomError {\n constructor(message?: string) {\n super(message)\n\n Object.defineProperty(this, 'name', { value: 'KeqError' })\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Validator } from '~/validator/index.js'\n\n\nexport function cloneBody<T>(obj: T): T {\n if (Validator.isFormData(obj)) {\n const formData = new FormData()\n for (const [key, value] of obj.entries()) {\n formData.append(key, value)\n }\n return formData as unknown as T\n }\n\n if (Validator.isUrlSearchParams(obj)) {\n const urlSearchParams = new URLSearchParams()\n for (const [key, value] of obj.entries()) {\n urlSearchParams.append(key, value)\n }\n return urlSearchParams as unknown as T\n }\n\n if (Validator.isFile(obj)) {\n return obj\n }\n\n if (Validator.isBlob(obj)) {\n return obj\n }\n\n if (Validator.isBuffer(obj)) {\n return obj\n }\n\n if (obj === null) {\n return null as T\n }\n\n if (Array.isArray(obj)) {\n return obj.map(cloneBody) as unknown as T\n }\n\n if (Validator.isObject(obj)) {\n const cloned: any = {}\n\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n cloned[key] = cloneBody(obj[key])\n }\n }\n return cloned\n }\n\n return obj\n}\n","export function cloneHeaders(headers: Headers): Headers {\n const cloned = new Headers()\n for (const [key, value] of headers.entries()) {\n cloned.append(key, value)\n }\n\n return cloned\n}\n","import { UriTemplateContext, UriTemplateParser } from '@opendoc/uri-template'\n\n\nexport function compileUrl(obj: string | URL, pathParameters: UriTemplateContext): URL {\n const url = new URL(typeof obj === 'string' ? obj : obj.href)\n\n url.pathname = new UriTemplateParser(\n decodeURIComponent(url.pathname),\n pathParameters,\n ).expand()\n\n return url\n}\n","export function toFormData(body: object): FormData {\n const form = new FormData()\n\n for (const [key, value] of Object.entries(body)) {\n if (Array.isArray(value)) {\n for (const v of value) {\n form.append(key, v)\n }\n } else {\n form.append(key, value)\n }\n }\n\n return form\n}\n","export function toUrlSearchParams(body: object): URLSearchParams {\n const params = new URLSearchParams()\n Object.entries(body).map(([key, value]) => {\n if (Array.isArray(value)) {\n for (const v of value) {\n params.append(key, v)\n }\n } else {\n params.append(key, value)\n }\n })\n\n return params\n}\n","import { KeqRequestInit } from '../request-init'\n\n\nexport function cloneRequestInit(init: KeqRequestInit): KeqRequestInit {\n return new KeqRequestInit({\n url: init.url,\n pathParameters: init.pathParameters,\n method: init.method,\n headers: init.headers,\n body: init.body,\n cache: init.cache,\n credentials: init.credentials,\n integrity: init.integrity,\n keepalive: init.keepalive,\n mode: init.mode,\n redirect: init.redirect,\n referrer: init.referrer,\n referrerPolicy: init.referrerPolicy,\n })\n}\n","import { UriTemplateContext } from '@opendoc/uri-template'\nimport { shallowClone } from '~/utils/shallow-clone.js'\nimport { Validator } from '~/validator/index.js'\nimport { Exception } from '~/exception/exception.js'\nimport { KeqRequestMethod, KeqBodyInit } from './types/index.js'\nimport {\n toUrlSearchParams,\n toFormData,\n cloneBody,\n cloneHeaders,\n compileUrl,\n} from './utils/index.js'\n\nexport interface KeqRequestInitOptions {\n url: URL\n pathParameters: UriTemplateContext\n method: KeqRequestMethod\n headers: Headers\n body: KeqBodyInit\n cache?: RequestCache\n credentials?: RequestCredentials\n integrity?: string\n keepalive?: boolean\n mode?: RequestMode\n redirect?: RequestRedirect\n referrer?: string\n referrerPolicy?: ReferrerPolicy\n}\n\nexport const AbortControllerProperty = Symbol('context.request.abortController')\n\nexport class KeqRequestInit {\n url: URL\n pathParameters: UriTemplateContext\n\n method: KeqRequestMethod\n headers: Headers\n body: KeqBodyInit\n cache?: RequestCache\n credentials?: RequestCredentials\n integrity?: string\n keepalive?: boolean\n mode?: RequestMode\n redirect?: RequestRedirect\n referrer?: string\n referrerPolicy?: ReferrerPolicy\n\n [AbortControllerProperty]: AbortController = new AbortController()\n\n constructor(options: KeqRequestInitOptions) {\n this.url = new URL(options.url.href)\n this.pathParameters = shallowClone(options.pathParameters)\n this.method = options.method\n this.headers = cloneHeaders(options.headers)\n this.body = cloneBody(options.body)\n this.cache = options.cache\n this.credentials = options.credentials\n this.integrity = options.integrity\n this.keepalive = options.keepalive\n this.mode = options.mode\n this.redirect = options.redirect\n this.referrer = options.referrer\n this.referrerPolicy = options.referrerPolicy\n }\n\n // the url merged pathParameters\n get __url__(): Readonly<URL> {\n return compileUrl(this.url, this.pathParameters)\n }\n\n get signal(): AbortSignal {\n return this[AbortControllerProperty].signal\n }\n\n abort(reason: any): void {\n if (!this[AbortControllerProperty].signal.aborted) {\n this[AbortControllerProperty].abort(reason)\n }\n }\n\n private getContentType(): string | undefined {\n const contentType = this.headers.get('Content-Type')\n if (contentType) return contentType\n if (!this.body) return undefined\n\n if (Validator.isFormData(this.body)) return 'multipart/form-data'\n if (Validator.isUrlSearchParams(this.body)) return 'application/x-www-form-urlencoded'\n if (Validator.isArrayBuffer(this.body)) return 'application/octet-stream'\n if (typeof this.body === 'object') return 'application/json'\n\n return undefined\n }\n\n private toFetchBody(contentType: string | undefined): RequestInit['body'] {\n const body = this.body\n if (body === undefined) return\n if (body === null) return null\n if (Validator.isBodyInit(body)) return body\n\n if (!contentType || contentType === 'application/json') {\n return JSON.stringify(body)\n }\n\n if (contentType === 'application/x-www-form-urlencoded') {\n if (Array.isArray(body)) {\n throw new Exception('request.body is an array, that cannot be serialized as application/x-www-form-urlencoded format')\n }\n\n return toUrlSearchParams(body)\n }\n\n if (contentType === 'multipart/form-data') {\n if (Array.isArray(body)) {\n throw new Exception('FormData cannot send array')\n }\n\n return toFormData(body)\n }\n\n throw new Exception(`Cannot auto serialize request.body with Content-Type: ${contentType}`)\n }\n\n toFetchArguments(): [string, RequestInit] {\n const contentType = this.getContentType()\n const headers = cloneHeaders(this.headers)\n if (contentType) headers.set('Content-Type', contentType)\n\n const body = this.toFetchBody(contentType)\n if (contentType === 'multipart/form-data') {\n headers.delete('Content-Type')\n }\n\n const requestInit: RequestInit = {\n method: this.method.toUpperCase(),\n headers,\n body,\n cache: this.cache,\n credentials: this.credentials,\n integrity: this.integrity,\n keepalive: this.keepalive,\n mode: this.mode,\n redirect: this.redirect,\n referrer: this.referrer,\n referrerPolicy: this.referrerPolicy,\n signal: this.signal,\n }\n\n return [this.__url__.href, requestInit]\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-function-type */\nimport { ConditionalPick } from 'type-fest'\n\n\ntype Watcher = (target: any, thisArg: any, argArray: any[]) => void\n\nexport function watchObject<T extends object>(obj: T, listeners: Partial<Record<keyof ConditionalPick<T, Function>, Watcher>>): T {\n return new Proxy(obj, {\n get(target, prop) {\n if (prop in listeners) {\n return new Proxy(target[prop], {\n apply(target: Function, thisArg, argArray) {\n const listener: Function = listeners[prop]\n listener(target, thisArg, argArray)\n return target.apply(thisArg, argArray)\n },\n })\n }\n\n return target[prop]\n },\n })\n}\n","import { cloneRequestInit } from '~/request-init'\nimport {\n ContextDataProperty,\n ContextEmitterProperty,\n ContextGlobalProperty,\n ContextLocationIdProperty,\n ContextOptionsProperty,\n ContextRequestProperty,\n KeqSharedContext,\n} from '../shared-context'\nimport { klona } from 'klona'\n\n\nexport function cloneSharedContext(context: KeqSharedContext): KeqSharedContext {\n const cloned = new KeqSharedContext({\n locationId: context[ContextLocationIdProperty],\n request: cloneRequestInit(context[ContextRequestProperty]),\n global: context[ContextGlobalProperty],\n options: klona(context[ContextOptionsProperty]),\n data: klona(context[ContextDataProperty]),\n })\n\n context[ContextEmitterProperty].all.forEach((handlers, type) => {\n for (const handler of handlers) {\n cloned.emitter.on(type as any, handler as any)\n }\n })\n\n return cloned\n}\n","\n/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { klona } from 'klona/json'\n\n\nconst UnWrapPropertyKey = Symbol('UnWrapPropertyKey')\n\nconst ARRAY_MUTATORS = new Set([\n 'push',\n 'pop',\n 'shift',\n 'unshift',\n 'splice',\n 'sort',\n 'reverse',\n 'fill',\n 'copyWithin',\n])\n\nfunction objectPath(obj: any, path: PropertyKey[]): any {\n return path.reduce((o, k) => o[k], obj)\n}\n\n/**\n * Fork an json object, using copy-on-write strategy to avoid unnecessary deep cloning.\n */\nexport function fork<T>(original: T): T {\n if (original === null || typeof original !== 'object') {\n // primitive value, return directly\n return original\n }\n\n let current = original\n\n const ensureCopy = (): T => {\n if (current === original) {\n current = klona(original)\n }\n\n return current\n }\n\n\n const createProxy = (path: PropertyKey[] = []): any => {\n return new Proxy({} as any, {\n get(_, prop) {\n const target = objectPath(current, path)\n if (prop === UnWrapPropertyKey) return target\n\n const value = target[prop]\n\n // return value directly if already copied\n if (current !== original) {\n return value\n }\n\n // handle array mutator methods\n if (Array.isArray(target) && ARRAY_MUTATORS.has(prop as string)) {\n return new Proxy(value, {\n apply(fn, thisArg, args) {\n ensureCopy()\n const t = objectPath(current, path)\n return Reflect.apply(t[prop], t, args)\n },\n })\n }\n\n // 未复制,嵌套对象需要继续代理\n if (typeof value === 'object' && value !== null) {\n return createProxy([...path, prop])\n }\n\n return value\n },\n\n set(_, prop, value) {\n ensureCopy()\n objectPath(current, path)[prop] = value\n return true\n },\n\n deleteProperty(_, prop) {\n ensureCopy()\n delete objectPath(current, path)[prop]\n return true\n },\n })\n }\n\n return createProxy()\n}\n\nexport function unwrap<T>(proxy: T): T {\n return proxy && (proxy as any)[UnWrapPropertyKey] ? (proxy as any)[UnWrapPropertyKey] : proxy\n}\n","import { fork } from './fork'\n\nconst JsonCachePropertyKey = Symbol('KeqResponseProxyJsonCachePropertyKey')\nconst TextCachePropertyKey = Symbol('KeqResponseProxyTextCachePropertyKey')\n\nexport function createProxyResponse(response: Response): Response {\n return new Proxy(response, {\n get(res, prop) {\n if (typeof prop === 'string') {\n if (prop === 'json') {\n return new Proxy(res[prop], {\n apply() {\n if (res[JsonCachePropertyKey]) {\n return fork(res[JsonCachePropertyKey]) as unknown\n }\n\n return res.clone().json()\n .then((body) => {\n res[JsonCachePropertyKey] = body\n return fork(body) as unknown\n })\n },\n })\n } else if (prop === 'text') {\n return new Proxy(res[prop], {\n apply() {\n if (res[TextCachePropertyKey]) {\n return fork(res[TextCachePropertyKey]) as unknown\n }\n\n return res.clone().text()\n .then((body) => {\n res[TextCachePropertyKey] = body\n return body\n })\n },\n })\n } else if (['arrayBuffer', 'blob', 'buffer', 'formData'].includes(prop)) {\n /**\n * clone when invoking body, json, text, arrayBuffer, blob, buffer, formData\n * to avoid time-consuming cloning\n */\n return new Proxy(res[prop], {\n apply(target, thisArg, argArray) {\n return res.clone()[prop](...argArray) as unknown\n },\n }) as unknown\n } else if (prop === 'body') {\n const mirror = res.clone()\n return mirror.body\n }\n }\n\n if (typeof res[prop] === 'function') {\n return res[prop].bind(res) as unknown\n }\n\n return res[prop] as unknown\n },\n })\n}\n","import { Exception } from './exception.js'\n\n\nexport class TypeException extends Exception {\n constructor(msg?: string) {\n super(msg || 'Invalid Type')\n }\n}\n","export class AbortException extends DOMException {\n constructor(msg: string) {\n super(msg, 'AbortError')\n Object.setPrototypeOf(this, AbortException.prototype)\n }\n}\n","import { AbortException } from './abort.exception.js'\n\n\nexport class TimeoutException extends AbortException {\n constructor(msg: string) {\n super(msg)\n }\n}\n","import { Exception } from '../exception.js'\n\n\nexport class RequestException extends Exception {\n statusCode: number\n retry: boolean\n\n constructor(statusCode: number, message?: string, retry = true) {\n super(message)\n\n this.statusCode = statusCode\n this.retry = retry\n\n Object.defineProperty(this, 'name', { value: 'RequestException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class BadRequestException extends RequestException {\n constructor(message: string = 'Bad Request', retry = false) {\n super(400, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'BadRequestException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class UnauthorizedException extends RequestException {\n constructor(message: string = 'Unauthorized', retry = false) {\n super(401, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'UnauthorizedException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ForbiddenException extends RequestException {\n constructor(message: string = 'Forbidden', retry = false) {\n super(403, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'ForbiddenException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class NotFoundedException extends RequestException {\n constructor(message: string = 'Not Founded', retry = false) {\n super(404, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'NotFoundedException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class MethodNotAllowedException extends RequestException {\n constructor(message: string = 'Method Not Allowed', retry = false) {\n super(405, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'MethodNotAllowedException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class NotAcceptableException extends RequestException {\n constructor(message: string = 'Not Acceptable', retry = false) {\n super(406, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'NotAcceptableException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ProxyAuthenticationRequiredException extends RequestException {\n constructor(message: string = 'Proxy Authentication Required', retry = false) {\n super(407, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'ProxyAuthenticationRequiredException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class RequestTimeoutException extends RequestException {\n constructor(message: string = 'Request Timeout', retry = true) {\n super(408, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'RequestTimeoutException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ConflictException extends RequestException {\n constructor(message: string = 'Conflict', retry = false) {\n super(409, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'ConflictException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class PreconditionFailedException extends RequestException {\n constructor(message: string = 'Precondition Failed', retry = false) {\n super(412, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'PreconditionFailedException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ContentTooLargeException extends RequestException {\n constructor(message: string = 'Content Too Large', retry = false) {\n super(413, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'ContentTooLargeException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class UriTooLongException extends RequestException {\n constructor(message: string = 'URI Too Long', retry = false) {\n super(414, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'UriTooLongException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class UnsupportedMediaTypeException extends RequestException {\n constructor(message: string = 'Unsupported Media Type', retry = false) {\n super(415, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'UnsupportedMediaTypeException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ImATeapotException extends RequestException {\n constructor(message: string = \"I'm a teapot\", retry = false) {\n super(418, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'ImATeapotException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class TooManyRequestsException extends RequestException {\n constructor(message: string = 'Too Many Requests', retry = true) {\n super(429, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'TooManyRequestsException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class InternalServerErrorException extends RequestException {\n constructor(message: string = 'Internal Server Error', retry = true) {\n super(500, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'InternalServerErrorException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class NotImplementedException extends RequestException {\n constructor(message: string = 'Not Implemented', retry = false) {\n super(501, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'NotImplementedException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class BadGatewayException extends RequestException {\n constructor(message: string = 'Bad Gateway', retry = true) {\n super(502, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'BadGatewayException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class ServiceUnavailableException extends RequestException {\n constructor(message: string = 'Service Unavailable', retry = true) {\n super(503, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'ServiceUnavailableException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class GatewayTimeoutException extends RequestException {\n constructor(message: string = 'Gateway Timeout', retry = true) {\n super(504, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'GatewayTimeoutException' })\n }\n}\n","export const base64Encode: ((str: string) => string) = globalThis.btoa || ((str: string) => Buffer.from(str).toString('base64'))\nexport const base64Decode: ((str: string) => string) = globalThis.atob || ((str: string) => Buffer.from(str, 'base64').toString('utf8'))\n","export function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n","import { KeqMiddleware } from '../types'\n\n\nexport function getMiddlewareName(middleware: KeqMiddleware): string {\n return middleware.__keqMiddlewareName__ || middleware.name || 'anonymous'\n}\n","import { TypeException } from '~/exception/index.js'\nimport type { KeqMiddleware } from '../types/keq-middleware.js'\nimport { getMiddlewareName } from './get-middleware-name.js'\n\n\ninterface ComposeMiddlewareOptions {\n name?: string\n}\n\nexport function composeMiddleware(middlewares: KeqMiddleware[], options?: ComposeMiddlewareOptions): KeqMiddleware {\n if (!middlewares.length) {\n throw new TypeException('At least one middleware')\n }\n\n const middleware = [...middlewares]\n .reverse()\n .reduce(function (prev, curr): KeqMiddleware {\n return async (ctx, next) => {\n await curr(ctx, async () => prev(ctx, next))\n }\n })\n\n if (options?.name) {\n middleware.__keqMiddlewareName__ = options.name\n } else {\n middleware.__keqMiddlewareName__ = `composeMiddleware(${middlewares.map((i) => getMiddlewareName(i)).join(', ')})`\n }\n\n return middleware\n}\n","import { type KeqMiddlewareExecutor } from '../orchestrator/executor.js'\n\n\nconst ExecutorProperty = Symbol('protected context.orchestration.middlewares')\n\nexport class KeqMiddlewareContext {\n readonly [ExecutorProperty]: KeqMiddlewareExecutor\n\n constructor(executor: KeqMiddlewareExecutor) {\n this[ExecutorProperty] = executor\n }\n\n get name(): string {\n return this[ExecutorProperty].name\n }\n\n get status(): KeqMiddlewareExecutor['status'] {\n return this[ExecutorProperty].status\n }\n\n get finished(): boolean {\n return this.status === 'fulfilled' || this.status === 'rejected'\n }\n}\n","import { Exception } from '~/exception/index.js'\nimport { KeqExecutionContext } from '~/context/index.js'\nimport { KeqNext } from '~/middleware/types/keq-next.js'\nimport { getMiddlewareName, KeqMiddleware } from '~/middleware/index.js'\nimport { KeqMiddlewareContext } from '~/context/middleware-context'\n\nexport class KeqMiddlewareExecutor {\n readonly name: string\n status: 'idle' | 'pending' | 'canceled' | 'fulfilled' | 'rejected' = 'idle'\n context: KeqMiddlewareContext\n\n constructor(\n public readonly middleware: KeqMiddleware,\n ) {\n this.name = getMiddlewareName(middleware)\n this.context = new KeqMiddlewareContext(this)\n }\n\n async execute(context: KeqExecutionContext, next: KeqNext): Promise<void> {\n if (this.status !== 'idle') {\n throw new Exception(`Middleware \"${this.name}\" has already been executed.`)\n }\n\n try {\n this.status = 'pending'\n context.emitter.emit('middleware:before', { context })\n await this.middleware(context, next)\n context.emitter.emit('middleware:after', { context })\n\n if (this.status === 'pending') {\n this.status = 'fulfilled'\n }\n } catch (error) {\n if (this.status === 'pending') {\n this.status = 'rejected'\n }\n throw error\n }\n }\n}\n","import { AbortControllerProperty, KeqRequestInit } from '../request-init'\n\nexport function assignRequestInit(\n target: KeqRequestInit,\n source: KeqRequestInit,\n): void {\n target.url = source.url\n target.pathParameters = source.pathParameters\n target.method = source.method\n target.headers = source.headers\n target.body = source.body\n target.cache = source.cache\n target.credentials = source.credentials\n target.integrity = source.integrity\n target.keepalive = source.keepalive\n target.mode = source.mode\n target.redirect = source.redirect\n target.referrer = source.referrer\n target.referrerPolicy = source.referrerPolicy\n target[AbortControllerProperty] = source[AbortControllerProperty]\n}\n","import { assignRequestInit } from '~/request-init/utils/assign-request-init'\nimport { ContextEmitterProperty, ContextOutputProperty, KeqSharedContext } from '../shared-context'\n\nexport function assignSharedContext(\n target: KeqSharedContext,\n source: KeqSharedContext,\n): void {\n assignRequestInit(target.request, source.request)\n\n Object.assign(target.global, source.global)\n Object.assign(target.options, source.options)\n Object.assign(target.data, source.data)\n\n target[ContextEmitterProperty] = source[ContextEmitterProperty]\n target[ContextOutputProperty] = source[ContextOutputProperty]\n\n target.res = source.res\n}\n","import { Exception, TypeException } from '~/exception/index.js'\nimport { KeqExecutionContext, KeqSharedContext } from '~/context/index.js'\nimport { KeqMiddleware } from '~/middleware/index.js'\nimport { KeqMiddlewareExecutor } from './executor.js'\nimport { cloneSharedContext } from '~/context/utils/clone-shared-context.js'\nimport { assignSharedContext } from '~/context/utils/assign-shared-context.js'\n\n\nexport class KeqMiddlewareOrchestrator {\n main?: {\n orchestrator: KeqMiddlewareOrchestrator\n index: number\n }\n\n status: 'idle' | 'pending' | 'fulfilled' | 'rejected' = 'idle'\n context: KeqSharedContext\n executors: KeqMiddlewareExecutor[] = []\n\n current: number = -1\n\n constructor(\n context: KeqSharedContext,\n middlewares: KeqMiddleware[] = [],\n ) {\n this.context = context\n this.executors = middlewares.map((mw) => new KeqMiddlewareExecutor(mw))\n }\n\n private cancelNotFinished(): void {\n const current = this.current\n\n for (let i = current + 1; i < this.executors.length; i++) {\n const executor = this.executors[i]\n if (executor.status === 'pending') {\n executor.status = 'canceled'\n }\n }\n }\n\n private async run(): Promise<void> {\n if (this.executors.length === 0) return\n\n // clone executors array to avoid mutation during execution\n const executors = [...this.executors]\n\n const next = async (nextIndex: number): Promise<void> => {\n if (nextIndex >= executors.length) return\n\n const nextExecutor = executors[nextIndex]\n if (nextExecutor.status !== 'idle') {\n const msg = `Cannot call next() because the next Middleware(${nextExecutor.name}) status is ${nextExecutor.status}. If you want to re-execute it, please fork a new orchestrator.`\n throw new Exception(msg)\n }\n\n if (this.current + 1 !== nextIndex) {\n const parentExecutor = executors[nextIndex - 1]\n const msg = parentExecutor\n ? `Cannot call next() outside Middleware(${parentExecutor.name}) runtime. You can fork a new orchestration and execute the forked one anywhere.`\n : 'Cannot jump to non-sequential middleware. Please call next() in order.'\n\n throw new Exception(msg)\n }\n\n const last = this.current\n this.current = nextIndex\n const context = new KeqExecutionContext(this, nextExecutor)\n\n try {\n await nextExecutor.execute(context, () => next.call(this, nextIndex + 1))\n } finally {\n if (this.current === last + 1) {\n this.current = last\n } else if (this.current > last) {\n this.cancelNotFinished()\n this.current = last\n }\n }\n }\n\n await next.call(this, 0)\n }\n\n async execute(): Promise<void> {\n if (this.status !== 'idle') {\n throw new Exception('Orchestrator has already been executed.')\n }\n\n this.status = 'pending'\n\n try {\n await this.run()\n this.status = 'fulfilled'\n } catch (error) {\n this.status = 'rejected'\n throw error\n }\n }\n\n fork(): KeqMiddlewareOrchestrator {\n const context = cloneSharedContext(this.context)\n const next = this.current + 1\n const middlewares = this.executors.slice(next)\n .map((executor) => executor.middleware)\n\n const forkedOrchestrator = new KeqMiddlewareOrchestrator(context, middlewares)\n forkedOrchestrator.main = {\n orchestrator: this.main ? this.main.orchestrator : this,\n index: this.main ? this.main.index + next : next,\n }\n\n return forkedOrchestrator\n }\n\n merge(source: KeqMiddlewareOrchestrator): void {\n if (!source.main) throw new TypeException('Source orchestrator is not a forked orchestrator.')\n\n const target = this.main ? this.main.orchestrator : this\n if (source.main.orchestrator !== target) throw new TypeException('Cannot rebase to unrelated orchestrator')\n if (source.main.index !== this.current + 1) throw new TypeException(`Cannot merge from non-current(expected: ${this.current + 1}, actual: ${source.main.index}) forked orchestrator`)\n\n // copy context\n assignSharedContext(this.context, source.context)\n\n // copy executors status\n for (const [i, executor] of this.executors.slice(source.main.index).entries()) {\n executor.status = source.executors[i].status\n }\n }\n}\n","import type { ShorthandContentType } from '~/request/types/content-type.js'\n\n\nexport function fixContentType(contentType: ShorthandContentType): string\nexport function fixContentType(contentType: string): string\nexport function fixContentType(contentType: string): string {\n if (['json', 'xml'].includes(contentType)) {\n return `application/${contentType}`\n } else if (['html', 'css'].includes(contentType)) {\n return `text/${contentType}`\n } else if (['form-data'].includes(contentType)) {\n return `multipart/${contentType}`\n } else if (['jpeg', 'bmp', 'apng', 'gif', 'x-icon', 'png', 'webp', 'tiff'].includes(contentType)) {\n return `image/${contentType}`\n } else if (contentType === 'form') {\n return 'application/x-www-form-urlencoded'\n } else if (contentType === 'svg') {\n return 'image/svg+xml'\n }\n return contentType\n}\n","export function getLocationId(depth = 0): string {\n const err = new Error()\n if (!err.stack) return ''\n\n const stackLine = err.stack.split('\\n')[depth + 2]\n\n return stackLine.trim()\n}\n","import { unwrap } from '~/context'\n\nexport async function intelligentParseResponse<T>(response?: Response): Promise<T> {\n if (!response) return undefined as T\n\n if (response.status === 204) {\n // 204: NO CONTENT\n return undefined as T\n }\n\n const contentType = response.headers.get('content-type') || ''\n try {\n if (contentType.includes('application/json')) {\n return unwrap(await response.json()) as T\n } else if (contentType.includes('multipart/form-data')) {\n return await response.formData() as T\n } else if (contentType.includes('plain/text')) {\n return await response.text() as T\n }\n } catch (e) {\n console.warn('Failed to auto parse response body', e)\n }\n\n /**\n * Unable to parse response body\n * Return undefined\n * Enable users to discover the problem\n * And modify the method of parsing response\n */\n return undefined as T\n}\n","\nimport { Validator } from '~/validator/index.js'\nimport { Exception } from '~/exception/index.js'\nimport { KeqBodyInit } from '~/request-init/index.js'\n\n\nexport function mergeKeqRequestBody(left: KeqBodyInit, right: KeqBodyInit): KeqBodyInit {\n if (right === undefined) return left\n\n if (typeof right === 'number') {\n throw new TypeError('Cannot set request body to a number.')\n }\n\n if (\n left === null\n || right === null\n || Validator.isBuffer(right)\n || Validator.isArrayBuffer(right)\n || Validator.isBlob(right)\n || Validator.isReadableStream(right)\n || Validator.isBuffer(left)\n || Validator.isArrayBuffer(left)\n || Validator.isBlob(left)\n || Validator.isReadableStream(left)\n || Array.isArray(left)\n || Array.isArray(right)\n || (typeof left !== 'object' && left !== undefined)\n || typeof right !== 'object'\n ) {\n return Array.isArray(right) ? [...right] : right\n }\n\n const result = left || {}\n\n if (Validator.isUrlSearchParams(right)) {\n const keys = right.keys()\n for (const key of keys) {\n const values = right.getAll(key)\n if (values.length === 1) {\n result[key] = values[0]\n } else if (values.length > 1) {\n result[key] = values\n }\n }\n } else if (Validator.isFormData(right)) {\n const keys = right.keys()\n for (const key of keys) {\n const values = right.getAll(key)\n if (values.length === 1) {\n result[key] = values[0]\n } else if (values.length > 1) {\n result[key] = values\n }\n }\n } else if (typeof right === 'object') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const key in (right as any)) {\n result[key] = right[key]\n }\n } else {\n throw new Exception(`Not support request body type: ${typeof right}`)\n }\n\n return result\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport qs, { IStringifyOptions } from 'qs'\nimport { KeqQueryObject, KeqQueryOptions, KeqQueryValue } from '../types'\n\nfunction normalize(value: KeqQueryValue, options?: KeqQueryOptions): KeqQueryValue {\n if (Array.isArray(value)) {\n return value.map((v) => normalize(v, options))\n }\n\n if (typeof value === 'bigint') {\n return value.toString()\n }\n\n if (typeof value === 'object' && value !== null) {\n const obj = { ...value }\n for (const key of Object.keys(obj)) {\n obj[key] = normalize(obj[key], options)\n }\n\n return obj\n }\n\n\n return value\n}\n\nexport function queryStringify(query: KeqQueryObject, options?: KeqQueryOptions): string {\n const value = normalize(query, options)\n\n const opts: IStringifyOptions = {}\n\n\n if (options?.allowDots !== undefined) {\n opts.allowDots = options.allowDots\n // if (options.encodeDotInKeys !== undefined) {\n // opts.encodeDotInKeys = options.encodeDotInKeys as any\n // }\n }\n\n if (options?.indices !== undefined) {\n opts.indices = options.indices\n }\n\n if (options?.arrayFormat === 'pipe') {\n opts.filter = (_, val) => {\n if (Array.isArray(val)) return val.join('|')\n return val\n }\n } else if (options?.arrayFormat === 'space') {\n opts.filter = (_, val) => {\n if (Array.isArray(val)) return val.join(' ')\n return val\n }\n } else if (options?.arrayFormat) {\n opts.arrayFormat = options.arrayFormat\n }\n\n return qs.stringify(value, opts)\n}\n","import { KeqEvents, KeqGlobal, KeqListeners, KeqMiddlewareOptionsParameter, KeqMiddlewareOptionsReturnType, unwrap } from '~/context/index.js'\nimport { Exception, RequestException } from '~/exception/index.js'\nimport { sleep } from '~/utils/index.js'\nimport { KeqRequestInit } from '~/request-init/index.js'\nimport { KeqSharedContext, KeqContextOptions } from '~/context/index.js'\nimport { KeqMiddlewareOrchestrator } from '~/orchestrator/index.js'\nimport { KeqMiddleware } from '~/middleware/index.js'\nimport { intelligentParseResponse } from './utils/index.js'\nimport { KeqDefaultOperation, KeqOperation, KeqQueryOptions } from './types/index.js'\n\n\nexport type KeqOptions = Partial<Omit<KeqRequestInit, 'url' | '__url__' | 'signal' | 'abort' | 'clone'>> & {\n locationId?: string\n global?: KeqGlobal\n qs?: KeqQueryOptions\n}\n\n/**\n * Core class that provides the foundational structure for managing middlewares, events, and request execution.\n */\nexport class Core<\n OP extends KeqOperation = KeqDefaultOperation,\n RES_BODY extends KeqOperation['responseBody'] = OP['responseBody'],\n> {\n /**\n * The unique identifier of the request's location in the code\n */\n __locationId__?: string\n\n private requestPromise?: Promise<RES_BODY>\n\n protected requestInit: KeqRequestInit\n\n protected __listeners__: KeqListeners = {}\n\n protected __global__: Record<string, any>\n protected __prepend_middlewares__: KeqMiddleware[] = []\n protected __append_middlewares__: KeqMiddleware[] = []\n protected __qs__: KeqQueryOptions | undefined\n\n protected get __middlewares__(): KeqMiddleware[] {\n return [...this.__prepend_middlewares__, ...this.__append_middlewares__]\n }\n\n protected __options__: KeqContextOptions = {\n resolveWithFullResponse: false,\n resolveWith: 'intelligent',\n }\n\n public constructor(url: URL, options: KeqOptions) {\n this.__global__ = options.global || {}\n this.__locationId__ = options.locationId\n this.__qs__ = options.qs\n\n this.requestInit = new KeqRequestInit({\n method: 'get',\n headers: new Headers(),\n pathParameters: {},\n body: undefined,\n ...options,\n url: new URL(url.href),\n })\n }\n\n prependMiddlewares(...middlewares: KeqMiddleware[]): this {\n this.__prepend_middlewares__.push(...middlewares)\n return this\n }\n\n /**\n * Appends middlewares to the end of the middleware chain.\n * Using this method indiscriminately is discouraged;\n * prefer using `.use` to maintain predictable execution order.\n */\n appendMiddlewares(...middlewares: KeqMiddleware[]): this {\n this.__append_middlewares__.unshift(...middlewares)\n return this\n }\n\n use(...middlewares: KeqMiddleware[]): this {\n return this.prependMiddlewares(...middlewares)\n }\n\n on<K extends keyof KeqEvents>(event: K, listener: (data: KeqEvents[K]) => void): this {\n this.__listeners__[event] = this.__listeners__[event] || []\n this.__listeners__[event]!.push(listener)\n return this\n }\n\n option<K extends keyof KeqMiddlewareOptionsReturnType<OP>>(key: K, value?: KeqMiddlewareOptionsParameter[K]): KeqMiddlewareOptionsReturnType<OP>[K]\n option(key: string, value?: any): this\n option(key: string, value: any = true): this {\n this.__options__[key] = value\n return this\n }\n\n options(opts: KeqContextOptions): this {\n for (const [key, value] of Object.entries(opts)) {\n this.__options__[key] = value\n }\n return this\n }\n\n\n private buildSharedContext(): KeqSharedContext {\n const coreContext = new KeqSharedContext({\n locationId: this.__locationId__,\n request: this.requestInit,\n global: this.__global__,\n options: this.__options__,\n })\n\n for (const eventName in this.__listeners__) {\n const listeners = this.__listeners__[eventName]\n for (const listener of listeners) {\n coreContext.emitter.on(eventName as keyof KeqEvents, listener)\n }\n }\n\n return coreContext\n }\n\n private async run(): Promise<KeqSharedContext> {\n let attempt: number | undefined\n\n while (true) {\n const attemptWithDefault = attempt || 0\n const sharedContext = this.buildSharedContext()\n const orchestrator = new KeqMiddlewareOrchestrator(sharedContext, this.__middlewares__)\n\n if (attempt !== undefined) sharedContext.data.retry = { attempt }\n if (attempt && attempt >= 1) sharedContext.emitter.emit('retry', { context: sharedContext })\n\n let error: unknown = null\n\n try {\n await orchestrator.execute()\n } catch (err) {\n error = err\n }\n\n const retryOn = typeof sharedContext.options.retry?.on === 'function'\n ? sharedContext.options.retry.on\n : (attempt, error) => {\n if (error instanceof RequestException && error.retry === false) return false\n return !!error\n }\n let retryTimes = sharedContext.options.retry?.times || 0\n if (retryTimes) {\n if (retryTimes < 0) retryTimes = 0\n else if (!Number.isInteger(retryTimes)) retryTimes = Math.floor(retryTimes)\n }\n\n if (\n attemptWithDefault >= retryTimes\n || (await retryOn(attemptWithDefault, error, sharedContext)) === false\n ) {\n if (error) {\n sharedContext.emitter.emit('error', { context: sharedContext })\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw error\n }\n return sharedContext\n }\n\n const retryDelay = typeof sharedContext.options.retry?.delay === 'function'\n ? await sharedContext.options.retry.delay(attemptWithDefault, error, sharedContext)\n : sharedContext.options.retry?.delay || 0\n\n if (retryDelay) await sleep(retryDelay)\n attempt = attemptWithDefault + 1\n }\n }\n\n async end(): Promise<RES_BODY> {\n const coreContext = await this.run()\n\n if (coreContext.options.resolveWith === 'response') {\n // NOTE: return a clone of the response rather than the proxy response\n return coreContext.response?.clone() as RES_BODY\n }\n\n const response = coreContext.response\n\n if (coreContext.options.resolveWith && coreContext.options.resolveWith !== 'intelligent' && !response) {\n throw new Exception([\n `Unable to process the response with '${coreContext.options.resolveWith}'. Possible causes:`,\n '1. The request was never initiated or sent',\n '2. The request failed before a response was received.',\n ].join('\\n'))\n }\n\n if (coreContext.options.resolveWith === 'text') {\n return await response!.text() as RES_BODY\n } else if (coreContext.options.resolveWith === 'json') {\n return unwrap(await response!.json()) as RES_BODY\n } else if (coreContext.options.resolveWith === 'form-data') {\n return await response!.formData() as RES_BODY\n } else if (coreContext.options.resolveWith === 'blob') {\n return await response!.blob() as RES_BODY\n } else if (coreContext.options.resolveWith === 'array-buffer') {\n return await response!.arrayBuffer() as RES_BODY\n }\n\n const output: any = coreContext.output\n if (output !== undefined) {\n return output as RES_BODY\n }\n\n return await intelligentParseResponse<RES_BODY>(response)\n }\n\n /**\n * Attaches callbacks for the resolution and/or rejection of the Promise.\n * @param onfulfilled The callback to execute when the Promise is resolved.\n * @param onrejected The callback to execute when the Promise is rejected.\n * @returns A Promise for the completion of which ever callback is executed.\n */\n then<TResult1 = RES_BODY, TResult2 = never>(onfulfilled?: ((value: RES_BODY) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2> {\n if (!this.requestPromise) this.requestPromise = this.end()\n return this.requestPromise.then(onfulfilled, onrejected)\n }\n\n catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<RES_BODY | TResult> {\n return this.end().catch(onrejected)\n }\n\n finally(onfinally?: (() => void) | null): Promise<RES_BODY> {\n return this.end().finally(onfinally)\n }\n}\n","\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Core } from './core.js'\nimport { Exception, TypeException } from '~/exception/index.js'\nimport { Validator } from '~/validator/index.js'\nimport { KeqFlowControlOptions, KeqFlowControlMode, KeqFlowControlSignal } from '~/middlewares/index.js'\nimport { mergeKeqRequestBody, fixContentType, queryStringify } from './utils/index.js'\nimport { base64Encode } from '~/utils/index.js'\nimport { KeqBodyInit } from '~/request-init/index.js'\n\nimport type { KeqRetryOn, KeqRetryDelay, KeqResolveWithMode } from '~/context/index.js'\nimport type { CommonContentType, ShorthandContentType, KeqDefaultOperation, KeqOperation, KeqAttachableFile, KeqQueryOptions, KeqPathParameterInit, KeqQueryInit } from './types/index.js'\nimport type { ConditionalPick, Merge, Primitive } from 'type-fest'\nimport type { LiteralKeys, StringIndexValueOf, EnabledIfStringIndex, LooseNestedObject, EnableLooseNestedLike, LooseNestedLike } from '~/types/index.js'\n\n\n/**\n * extends Core to provide a fluent API for building HTTP requests\n */\nexport class Keq<\n OP extends KeqOperation = KeqDefaultOperation,\n RES_BODY extends KeqOperation['responseBody'] = OP['responseBody'],\n REQ_PARAMS extends KeqOperation['requestParams'] = OP['requestParams'],\n REQ_QUERY extends KeqOperation['requestQuery'] = OP['requestQuery'],\n REQ_HEADERS extends KeqOperation['requestHeaders'] = OP['requestHeaders'],\n REQ_BODY extends KeqOperation['requestBody'] = OP['requestBody'],\n> extends Core<OP> {\n /**\n * Set request header\n *\n * @description 设置请求头\n */\n set(headers: Partial<REQ_HEADERS> | Headers): this\n set<T extends keyof LiteralKeys<REQ_HEADERS>>(name: T, value: LiteralKeys<REQ_HEADERS>[T]): this\n set<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_HEADERS>): this\n set<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(key: string, value: StringIndexValueOf<REQ_HEADERS> & EnabledIfStringIndex<REQ_HEADERS>): this\n set(headersOrName: Partial<REQ_HEADERS> | string | Headers, value?: string | number): this {\n if (Validator.isHeaders(headersOrName)) {\n headersOrName.forEach((value, key) => {\n this.requestInit.headers.set(key, value)\n })\n } else if (typeof headersOrName === 'string' && value) {\n if (!Validator.isHeaderValue(value)) {\n throw new Exception(`[Invalid header] Key: ${headersOrName} Value: ${value}`)\n }\n\n this.requestInit.headers.set(headersOrName, String(value))\n } else if (typeof headersOrName === 'object') {\n for (const [key, value] of Object.entries(headersOrName)) {\n if (!Validator.isHeaderValue(value)) {\n throw new Exception(`[Invalid header] Key: ${key} Value: ${String(value)}`)\n }\n\n this.requestInit.headers.set(key, String(value))\n }\n }\n return this\n }\n\n /**\n * Set request headers\n */\n headers(headers: Partial<REQ_HEADERS> | Headers): this\n headers<T extends keyof LiteralKeys<REQ_HEADERS>>(name: T, value: LiteralKeys<REQ_HEADERS>[T]): this\n headers<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_HEADERS>): this\n headers<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(key: string, value: StringIndexValueOf<REQ_HEADERS> & EnabledIfStringIndex<REQ_HEADERS>): this\n headers(headersOrName: Partial<REQ_HEADERS> | string | Headers, value?: string | number): this {\n return this.set(headersOrName as any, value as any)\n }\n\n /**\n * Set request query/searchParams\n */\n query(obj: Partial<REQ_QUERY>, options?: KeqQueryOptions): this\n query<T extends keyof LiteralKeys<REQ_QUERY>>(key: T, value: LiteralKeys<REQ_QUERY>[T], options?: KeqQueryOptions): this\n query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(key: string, obj: StringIndexValueOf<REQ_QUERY> & EnabledIfStringIndex<REQ_QUERY>, options?: KeqQueryOptions): this\n query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_QUERY>, options?: KeqQueryOptions): this\n query<O extends object>(\n arg: O\n & Partial<LooseNestedObject<REQ_QUERY, O>>\n & EnableLooseNestedLike<StringIndexValueOf<REQ_QUERY>, O>\n & EnabledIfStringIndex<REQ_QUERY>\n ): this\n query<K extends keyof REQ_QUERY, O extends object>(\n key: K,\n arg: O\n & LooseNestedLike<StringIndexValueOf<REQ_QUERY>, O>\n & EnableLooseNestedLike<StringIndexValueOf<REQ_QUERY>, O>\n & EnabledIfStringIndex<REQ_QUERY>,\n options?: KeqQueryOptions,\n ): this\n query(arg1: string | Partial<REQ_QUERY>, arg2?: KeqQueryInit | KeqQueryOptions, arg3?: KeqQueryOptions): this {\n if (Validator.isObject(arg1)) {\n const str = queryStringify(arg1, (arg2 as KeqQueryOptions) || this.__qs__)\n\n for (const [k, v] of new URLSearchParams(str).entries()) {\n for (const item of Array.isArray(v) ? v : [v]) {\n this.requestInit.url.searchParams.append(k, item)\n }\n }\n\n this.requestInit.url.search = this.requestInit.url.searchParams.toString().replace(/\\+/g, '%20')\n return this\n }\n\n if (typeof arg1 === 'string') {\n this.query({ [arg1]: arg2 } as Partial<REQ_QUERY>, arg3)\n return this\n }\n\n throw new TypeException('Invalid Arguments for .query()')\n }\n\n /**\n * Set request route params\n */\n params(params: Partial<REQ_PARAMS>): this\n params<T extends keyof LiteralKeys<REQ_PARAMS>>(key: T, value: LiteralKeys<REQ_PARAMS>[T]): this\n params<O extends { [K in keyof O]: StringIndexValueOf<REQ_PARAMS> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_PARAMS>): this\n params<O extends { [K in keyof O]: StringIndexValueOf<REQ_PARAMS> }>(key: string, value: StringIndexValueOf<REQ_PARAMS> & EnabledIfStringIndex<REQ_PARAMS>): this\n params(arg1: string | Partial<REQ_PARAMS>, arg2?: KeqPathParameterInit): this {\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n this.requestInit.pathParameters[arg1] = arg2\n } else if (typeof arg1 === 'object' && arg1 !== null) {\n for (const k of Object.keys(arg1)) {\n if (arg1[k]) this.requestInit.pathParameters[k] = arg1[k]\n }\n } else {\n throw new TypeError('Invalid Arguments for .params()')\n }\n\n return this\n }\n\n /**\n * Set request body\n */\n body(value: KeqBodyInit): this {\n this.requestInit.body = value\n return this\n }\n\n\n /**\n * Setting the Content-Type\n */\n type(contentType: ShorthandContentType): this\n type(contentType: CommonContentType): this\n type(contentType: string): this\n type(contentType: string): this {\n const type = fixContentType(contentType)\n this.set('content-type', type as any)\n return this\n }\n\n\n /**\n * Http Basic Authentication\n */\n auth(username: string, password: string): this {\n this.set('Authorization', `Basic ${base64Encode(`${username}:${password}`)}` as any)\n return this\n }\n\n private setTypeIfEmpty(contentType: ShorthandContentType): void\n private setTypeIfEmpty(contentType: CommonContentType): void\n private setTypeIfEmpty(contentType: string): void\n private setTypeIfEmpty(contentType: string): void {\n if (!this.requestInit.headers.has('Content-Type')) void this.type(contentType)\n }\n\n /**\n * set request body\n */\n send(value: Partial<REQ_BODY>): this\n send(value: KeqBodyInit): this {\n this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, value)\n\n if (Validator.isUrlSearchParams(value)) {\n this.setTypeIfEmpty('form')\n } else if (Validator.isFormData(value)) {\n this.setTypeIfEmpty('form-data')\n } else if (Validator.isBlob(value) || Validator.isReadableStream(value) || Validator.isArrayBuffer(value)) {\n // don't set content-type\n } else if (typeof value === 'object') {\n this.setTypeIfEmpty('json')\n }\n\n return this\n }\n\n\n field<T extends ConditionalPick<RES_BODY, Primitive>, K extends keyof T>(arg1: K, value: T[K]): this\n field(arg1: ConditionalPick<RES_BODY, Primitive>): this\n field(arg1: string, value: string | string[]): this\n field(arg1: Record<string, string>): this\n field(arg1: string | Record<string, string>, arg2?: any): this {\n if (typeof arg1 === 'object') {\n this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, arg1)\n } else if (arg2) {\n this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, { [arg1]: arg2 })\n } else {\n throw new TypeException('Invalid arguments for .field()')\n }\n\n this.setTypeIfEmpty('form-data')\n return this\n }\n\n\n attach<T extends keyof ConditionalPick<REQ_BODY, KeqAttachableFile>>(key: T, value: KeqAttachableFile, filename: string): this\n attach<T extends keyof ConditionalPick<REQ_BODY, KeqAttachableFile>>(key: T, value: KeqAttachableFile | KeqAttachableFile[]): this\n attach(key: string, value: KeqAttachableFile, filename: string): this\n attach(key: string, value: KeqAttachableFile | KeqAttachableFile[]): this\n attach(key: string, value: KeqAttachableFile | KeqAttachableFile[], arg3 = 'file'): this {\n const formData = new FormData()\n\n const appendFile = (file: KeqAttachableFile): void => {\n if (Validator.isBlob(file)) {\n formData.append(key, file, arg3)\n } else if (Validator.isFile(file)) {\n formData.append(key, file)\n } else if (Validator.isBuffer(file)) {\n formData.append(key, new Blob([file as any]), arg3)\n } else {\n throw new TypeException('Invalid file type for .attach()')\n }\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) {\n throw new TypeException('Empty array provided to .attach() is not valid')\n }\n\n for (const item of value) {\n appendFile(item)\n }\n } else {\n appendFile(value)\n }\n\n const files = formData.getAll(key)\n\n this.requestInit.body = mergeKeqRequestBody(\n this.requestInit.body,\n {\n [key]: files.length === 1 ? files[0] : files,\n },\n )\n\n this.setTypeIfEmpty('form-data')\n return this\n }\n\n /**\n *\n * @param retryTimes Max number of retries per call\n * @param retryDelay Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)\n * @param retryCallback Will be called after request failed\n */\n retry(retryTimes: number, retryDelay: KeqRetryDelay = 0, retryOn: KeqRetryOn = (attempt, error) => !!error): this {\n this.option('retry', {\n times: retryTimes,\n delay: retryDelay,\n on: retryOn,\n })\n\n return this\n }\n\n\n redirect(mod: RequestRedirect): this {\n this.requestInit.redirect = mod\n return this\n }\n\n credentials(mod: RequestCredentials): this {\n this.requestInit.credentials = mod\n return this\n }\n\n mode(mod: RequestMode): this {\n this.requestInit.mode = mod\n return this\n }\n\n flowControl(mode: KeqFlowControlMode, signal?: KeqFlowControlSignal): this {\n const sig = signal ? signal : this.__locationId__\n\n if (!sig) {\n throw new Exception('please set signal to .flowControl()')\n }\n\n const flowControl: KeqFlowControlOptions = {\n mode,\n signal: sig,\n }\n\n this.option('flowControl', flowControl)\n return this\n }\n\n timeout(milliseconds: number): this {\n this.option('timeout', { millisecond: milliseconds })\n return this\n }\n\n resolveWith(m: 'response'): Keq<Merge<OP, { responseBody: Response }>>\n resolveWith(m: 'array-buffer'): Keq<Merge<OP, { responseBody: ArrayBuffer }>>\n resolveWith(m: 'blob'): Keq<Merge<OP, { responseBody: Blob }>>\n resolveWith(m: 'text'): Keq<Merge<OP, { responseBody: string }>>\n resolveWith<T = any>(m: 'json' | 'form-data'): Keq<Merge<OP, { responseBody: T }>>\n resolveWith(m: KeqResolveWithMode | any): any {\n this.option('resolveWith', m)\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this as any\n }\n}\n","/* eslint-disable @typescript-eslint/await-thenable */\nimport { Exception } from '../../exception/exception.js'\nimport { KeqRoute } from '../types/keq-route.js'\n\n\nexport function composeRoute(routes: KeqRoute[]): KeqRoute {\n if (!routes.length) {\n throw new Exception('At least one route')\n }\n\n return async (ctx) => {\n const results = await Promise.all(routes.map((route) => route(ctx)))\n return results.every((result) => result === true)\n }\n}\n","import type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport function keqHostRoute(host: string): KeqRoute {\n return (ctx) => ctx.request.url.host === host\n}\n","import { Validator } from '../validator/index.js'\n\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\nexport function keqLocationRoute(): KeqRoute {\n return (ctx) => Validator.isBrowser() && ctx.request.url.host === window.location.host\n}\n","import type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport function keqMethodRoute(method): KeqRoute {\n return (ctx) => ctx.request.method.toLowerCase() === method.toLowerCase()\n}\n","import { Exception } from '../exception/exception.js'\n\nimport type { KeqRoute } from './types/keq-route.js'\n\n\nexport function keqModuleRoute(moduleName: string): KeqRoute {\n if (!moduleName) {\n throw new Exception('Module name should not be empty')\n }\n\n return (ctx) => ctx.options.module?.name === moduleName\n}\n","import * as m from 'minimatch'\n\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\nexport function keqPathnameRoute(pathname: string): KeqRoute {\n return (ctx) => {\n // TODO: minimatch will cause each request to consume an additional 1-2ms.\n return m.minimatch(ctx.request.url.pathname, pathname)\n }\n}\n","import { TypeException } from '~/exception/type.exception.js'\nimport { keqHostRoute } from './keq-host-route.js'\nimport { keqLocationRoute } from './keq-location-route.js'\nimport { keqMethodRoute } from './keq-method-route.js'\nimport { keqModuleRoute } from './keq-module-route.js'\nimport { keqPathnameRoute } from './keq-pathname-route.js'\nimport { composeMiddleware, getMiddlewareName } from '~/middleware/index.js'\n\nimport type { KeqMiddleware } from '~/middleware/index.js'\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport class KeqRouter {\n constructor(\n private readonly middlewares: KeqMiddleware[] = [],\n ) { }\n\n private buildMiddleware(route: KeqRoute, middlewares: KeqMiddleware[]): KeqMiddleware {\n if (middlewares.length === 0) {\n throw new TypeException('At least one middleware is required to build a route middleware')\n }\n\n const composedMiddleware = middlewares.length > 1 ? composeMiddleware(middlewares) : middlewares[0]\n\n const middleware: KeqMiddleware = async function router(ctx, next) {\n if (route(ctx)) await composedMiddleware(ctx, next)\n else await next()\n }\n\n return middleware\n }\n\n route(route: KeqRoute, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(route, middlewares)\n middleware.__keqMiddlewareName__ = `route(${route.__keqRouteName__ || route.name}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n host(host: string, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqHostRoute(host), middlewares)\n middleware.__keqMiddlewareName__ = `host(${JSON.stringify(host)}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n method(method: string, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqMethodRoute(method), middlewares)\n middleware.__keqMiddlewareName__ = `method(${JSON.stringify(method)}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n pathname(pathname: string, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqPathnameRoute(pathname), middlewares)\n middleware.__keqMiddlewareName__ = `pathname(${JSON.stringify(pathname)}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n location(...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqLocationRoute(), middlewares)\n middleware.__keqMiddlewareName__ = `location(${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n module(moduleName: string, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqModuleRoute(moduleName), middlewares)\n middleware.__keqMiddlewareName__ = `module(${JSON.stringify(moduleName)}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n}\n","import { TimeoutException } from '~/exception/index.js'\nimport { KeqMiddleware } from '~/middleware/types/index.js'\n\nexport interface KeqTimeoutOptions {\n millisecond: number\n}\n\nexport function keqTimeoutMiddleware(): KeqMiddleware {\n return async function timeoutMiddleware(ctx, next) {\n if (!ctx.options.timeout || ctx.options.timeout.millisecond <= 0) {\n await next()\n return\n }\n\n const millisecond = ctx.options.timeout.millisecond\n ctx.emitter.on('fetch:after', ({ context }) => {\n setTimeout(\n () => {\n const err = new TimeoutException(`keq request timeout(${millisecond}ms)`)\n context.request.abort(err)\n context.emitter.emit('timeout', { context })\n },\n millisecond,\n )\n })\n\n await next()\n }\n}\n","import type { queueAsPromised } from 'fastq'\nimport * as fastq from 'fastq'\nimport type { KeqMiddleware, KeqNext } from '~/middleware/types/index.js'\n\n\nexport function keqSerialFlowControlMiddleware(): KeqMiddleware {\n return async function serialFlowControlMiddleware(ctx, next) {\n if (!ctx.options.flowControl || ctx.options.flowControl.mode !== 'serial') {\n await next()\n return\n }\n\n const { signal } = ctx.options.flowControl\n\n const key = typeof signal === 'string' ? signal : signal(ctx)\n\n if (!ctx.global.serialFlowControl) ctx.global.serialFlowControl = {}\n\n if (!ctx.global.serialFlowControl[key]) {\n ctx.global.serialFlowControl[key] = fastq.promise(async (next: KeqNext) => {\n await next()\n }, 1)\n }\n\n const queue: queueAsPromised<KeqNext> = ctx.global.serialFlowControl[key]\n await queue.push(next)\n }\n}\n","import { AbortException } from '~/exception/index.js'\nimport { KeqMiddleware } from '~/middleware/types/index.js'\n\n\nexport function keqAbortFlowControlMiddleware(): KeqMiddleware {\n return async function abortFlowControlMiddleware(ctx, next) {\n if (!ctx.options.flowControl || ctx.options.flowControl.mode !== 'abort') {\n await next()\n return\n }\n\n const { signal } = ctx.options.flowControl\n\n const key = typeof signal === 'string' ? signal : signal(ctx)\n\n\n if (!ctx.global.abortFlowControl) ctx.global.abortFlowControl = {}\n\n const abort = ctx.global.abortFlowControl[key]\n\n if (abort) {\n const reason = new AbortException(`Previous request was aborted by AbortFlowControl with key \"${key}\"`)\n abort(reason)\n }\n\n const fn = ctx.request.abort.bind(ctx.request)\n ctx.global.abortFlowControl[key] = fn\n\n try {\n await next()\n } finally {\n if (ctx.global.abortFlowControl[key] === fn) {\n ctx.global.abortFlowControl[key] = undefined\n }\n }\n }\n}\n","import { keqSerialFlowControlMiddleware } from './serial-flow-control-middleware'\nimport { keqAbortFlowControlMiddleware } from './abort-flow-control-middleware'\nimport { KeqMiddleware } from '~/middleware/types'\nimport { composeMiddleware } from '~/middleware/utils'\n\nexport * from './types/keq-flow-control.js'\n\n\nexport function keqFlowControlMiddleware(): KeqMiddleware {\n return composeMiddleware(\n [keqSerialFlowControlMiddleware(), keqAbortFlowControlMiddleware()],\n { name: 'flowControlMiddleware' },\n )\n}\n","import { KeqExecutionContext } from '~/context/execution-context.js'\nimport { KeqMiddleware } from '~/middleware/types/index.js'\n\n/**\n * Send Request\n */\nexport function keqFetchMiddleware(): KeqMiddleware {\n return async function fetchMiddleware(context: KeqExecutionContext) {\n const fetch = context.options.fetchAPI || globalThis.fetch\n\n context.emitter.emit('fetch:before', { context })\n const response = await fetch(...context.request.toFetchArguments())\n context.emitter.emit('fetch:after', { context })\n\n context.res = response\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { KeqGlobal } from '~/context'\nimport { Keq } from './keq'\nimport { KeqApiSchema, KeqDefaultOperation, KeqQueryOptions } from './types'\nimport { getLocationId } from './utils'\nimport { KeqMiddleware } from '~/middleware'\nimport { Validator } from '~/validator'\nimport { KeqRequestInit, KeqRequestMethod } from '~/request-init'\nimport { ExtractMethodOperations } from './types'\nimport { KeqRouter } from '~/router'\nimport { keqFetchMiddleware, keqFlowControlMiddleware, keqTimeoutMiddleware } from '~/middlewares'\n\n\nexport interface KeqRequestOptions {\n preMiddlewares?: KeqMiddleware[]\n\n /**\n * Append middlewares to the end of the middleware chain.\n * Using this option indiscriminately is discouraged.\n */\n postMiddlewares?: KeqMiddleware[]\n\n baseOrigin?: string\n qs?: KeqQueryOptions\n}\n\nexport type KeqRequestFetchOptions<M extends KeqRequestMethod = KeqRequestMethod> = Partial<Omit<KeqRequestInit, 'url' | '__url__' | 'signal' | 'abort' | 'clone' | 'toFetchArguments' | 'method'>> & {\n method: M\n}\n\n/**\n * Keq instance factory class,\n * and shares global data and middlewares across requests\n */\nexport class KeqRequest<SCHEMA extends KeqApiSchema = KeqApiSchema> {\n baseOrigin: string\n qs?: KeqQueryOptions\n\n /**\n * share data between requests, used to implement flowControl\n * @description 跨请求共享数据,用于实现 flowControl的功能\n */\n readonly global: KeqGlobal = {}\n\n readonly preMiddlewares: KeqMiddleware[] = []\n readonly postMiddlewares: KeqMiddleware[] = []\n\n constructor(options?: KeqRequestOptions) {\n if (options?.baseOrigin) {\n this.baseOrigin = options.baseOrigin\n } else {\n this.baseOrigin = Validator.isBrowser() ? location.origin : 'http://127.0.0.1'\n }\n\n this.qs = options?.qs\n\n this.postMiddlewares = options?.postMiddlewares || [\n keqFlowControlMiddleware(),\n keqTimeoutMiddleware(),\n keqFetchMiddleware(),\n ]\n this.preMiddlewares = options?.preMiddlewares || []\n }\n\n private __formatUrl__(url: string | URL): URL {\n if (typeof url === 'string') {\n return new URL(url, this.baseOrigin)\n }\n\n return new URL(url.href)\n }\n\n private __fetch__(\n url: string | URL,\n init: KeqRequestFetchOptions,\n locationId?: string,\n ): Keq<any> {\n const keq = new Keq(this.__formatUrl__(url), { ...init, locationId, global: this.global, qs: this.qs })\n\n keq.appendMiddlewares(...this.postMiddlewares)\n keq.prependMiddlewares(...this.preMiddlewares)\n return keq as Keq<any>\n }\n\n\n fetch<P extends keyof SCHEMA, M extends KeqRequestMethod>(url: P, init: KeqRequestFetchOptions<M>): Keq<Exclude<SCHEMA[P][M], undefined>>\n fetch<T = unknown>(url: string | URL, init: KeqRequestFetchOptions): Keq<KeqDefaultOperation<{ responseBody: T }>>\n fetch(url: string | URL, init: KeqRequestFetchOptions): Keq<any> {\n return this.__fetch__(\n url,\n init,\n getLocationId(1),\n )\n }\n\n get<P extends keyof ExtractMethodOperations<SCHEMA, 'get'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'get'>[P], ExtractMethodOperations<SCHEMA, 'get'>[P]>\n get<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n get(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'get' },\n getLocationId(1),\n )\n }\n\n put<P extends keyof ExtractMethodOperations<SCHEMA, 'put'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'put'>[P], ExtractMethodOperations<SCHEMA, 'put'>[P]>\n put<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n put(url: string | URL): Keq<any> {\n const locationId = getLocationId(1)\n const keq = new Keq(\n this.__formatUrl__(url),\n {\n method: 'put',\n locationId,\n global: this.global,\n },\n )\n\n keq.appendMiddlewares(...this.postMiddlewares)\n keq.prependMiddlewares(...this.preMiddlewares)\n return keq\n }\n\n delete<P extends keyof ExtractMethodOperations<SCHEMA, 'delete'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'delete'>[P], ExtractMethodOperations<SCHEMA, 'delete'>[P]>\n delete<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n delete(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'delete' },\n getLocationId(1),\n )\n }\n\n del<P extends keyof ExtractMethodOperations<SCHEMA, 'delete'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'delete'>[P], ExtractMethodOperations<SCHEMA, 'delete'>[P]>\n del<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n del(url: string | URL): Keq<any> {\n return this.delete(url)\n }\n\n post<P extends keyof ExtractMethodOperations<SCHEMA, 'post'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'post'>[P], ExtractMethodOperations<SCHEMA, 'post'>[P]>\n post<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n post(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'post' },\n getLocationId(1),\n )\n }\n\n head<P extends keyof ExtractMethodOperations<SCHEMA, 'head'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'head'>[P], ExtractMethodOperations<SCHEMA, 'head'>[P]>\n head<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n head(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'head' },\n getLocationId(1),\n )\n }\n\n patch<P extends keyof ExtractMethodOperations<SCHEMA, 'patch'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'patch'>[P], ExtractMethodOperations<SCHEMA, 'patch'>[P]>\n patch<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n patch(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'patch' },\n getLocationId(1),\n )\n }\n\n options<P extends keyof ExtractMethodOperations<SCHEMA, 'options'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'options'>[P], ExtractMethodOperations<SCHEMA, 'options'>[P]>\n options<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n options(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'options' },\n getLocationId(1),\n )\n }\n\n use(firstMiddleware: KeqMiddleware, ...middleware: KeqMiddleware[]): this {\n this.preMiddlewares.push(firstMiddleware, ...middleware)\n return this\n }\n\n useRouter(): KeqRouter {\n return new KeqRouter(this.preMiddlewares)\n }\n}\n\nexport const request = new KeqRequest()\n","import { KeqApiSchema } from './types'\nimport { KeqRequest, KeqRequestOptions } from './request'\n\n\n/**\n * @deprecated use new KeqRequest<SCHEMA>(options) instead\n */\nexport function createRequest<SCHEMA extends KeqApiSchema>(options?: KeqRequestOptions): KeqRequest<SCHEMA> {\n return new KeqRequest<SCHEMA>(options)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAA,EAEA,YAAuB;AACrB,WAAO,IAAI,UAAU,KAAK,cAAc;AAAA,EAC1C;AACF;AAEO,IAAM,UAAU,IAAI,WAAW;;;ACtL/B,SAAS,cAA2C,SAAiD;AAC1G,SAAO,IAAI,WAAmB,OAAO;AACvC;","names":["_a","_b","_a","target","_a","_b","mitt","ExecutorProperty","_a","qs","_a","_b","_c","_d","attempt","error","value","m","_a","next"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/exception/exception.ts","../src/exception/type.exception.ts","../src/exception/abort.exception.ts","../src/exception/timeout.exception.ts","../src/exception/http-exceptions/request.exception.ts","../src/exception/http-exceptions/bad-request.exception.ts","../src/exception/http-exceptions/unauthorized.exception.ts","../src/exception/http-exceptions/forbidden.exception.ts","../src/exception/http-exceptions/not-founded.exception.ts","../src/exception/http-exceptions/method-not-allowed.exception.ts","../src/exception/http-exceptions/not-acceptable.exception.ts","../src/exception/http-exceptions/proxy-authentication-required.exception.ts","../src/exception/http-exceptions/request-timeout.exception.ts","../src/exception/http-exceptions/conflict.exception.ts","../src/exception/http-exceptions/precondition-failed.exception.ts","../src/exception/http-exceptions/content-too-large.exception.ts","../src/exception/http-exceptions/uri-too-long.exception.ts","../src/exception/http-exceptions/unsupported-media-type.exception.ts","../src/exception/http-exceptions/im-a-teapot.exception.ts","../src/exception/http-exceptions/too-many-requests.exception.ts","../src/exception/http-exceptions/internal-server-error.exception.ts","../src/exception/http-exceptions/not-implemented.exception.ts","../src/exception/http-exceptions/bad-gateway.exception.ts","../src/exception/http-exceptions/service-unavailable.exception.ts","../src/exception/http-exceptions/gateway-timeout.exception.ts","../src/utils/base64.ts","../src/validator/validator.ts","../src/utils/shallow-clone.ts","../src/utils/sleep.ts","../src/request-init/utils/clone-body.ts","../src/request-init/utils/clone-headers.ts","../src/request-init/utils/compile-url.ts","../src/request-init/utils/to-form-data.ts","../src/request-init/utils/to-url-search-params.ts","../src/request-init/utils/clone-request-init.ts","../src/request-init/request-init.ts","../src/context/orchestrator-context.ts","../src/context/execution-context.ts","../src/context/shared-context.ts","../src/context/utils/watch-object.ts","../src/context/utils/clone-shared-context.ts","../src/context/utils/fork.ts","../src/context/utils/create-proxy-response.ts","../src/middleware/utils/get-middleware-name.ts","../src/middleware/utils/compose-middleware.ts","../src/context/middleware-context.ts","../src/orchestrator/executor.ts","../src/request-init/utils/assign-request-init.ts","../src/context/utils/assign-shared-context.ts","../src/orchestrator/orchestrator.ts","../src/request/utils/fix-content-type.ts","../src/request/utils/get-location-id.ts","../src/request/utils/resolve-with.ts","../src/request/utils/intelligent-parse-response.ts","../src/request/utils/merge-keq-request-body.ts","../src/request/utils/query-stringify.ts","../src/request/core.ts","../src/request/keq.ts","../src/router/utils/compose-route.ts","../src/router/keq-host-route.ts","../src/router/keq-location-route.ts","../src/router/keq-method-route.ts","../src/router/keq-module-route.ts","../src/router/keq-pathname-route.ts","../src/router/keq-router.ts","../src/middlewares/timeout-middleware/index.ts","../src/middlewares/flow-control-middleware/serial-flow-control-middleware.ts","../src/middlewares/flow-control-middleware/abort-flow-control-middleware.ts","../src/middlewares/flow-control-middleware/index.ts","../src/middlewares/fetch-middleware/index.ts","../src/request/request.ts","../src/request/create-request.ts"],"sourcesContent":["export {\n createRequest,\n Keq,\n request,\n KeqRequest,\n type KeqOptions,\n type KeqApiSchema,\n type KeqOperation,\n type KeqDefaultOperation,\n type KeqQueryInit,\n type KeqPathParameterInit,\n type KeqQueryOptions,\n type ServerSentEvent,\n} from './request'\n\nexport {\n type KeqBodyInit,\n} from './request-init'\n\nexport {\n composeMiddleware,\n type KeqMiddleware,\n type KeqNext,\n} from './middleware'\n\nexport {\n type KeqRoute,\n composeRoute,\n keqHostRoute,\n keqLocationRoute,\n keqMethodRoute,\n keqModuleRoute,\n keqPathnameRoute,\n} from './router'\n\nexport {\n createProxyResponse,\n KeqExecutionContext,\n KeqSharedContext,\n type KeqSharedContextOptions,\n type KeqContext,\n type KeqContextData,\n type KeqContextEmitter,\n type KeqGlobal,\n type KeqContextOptions,\n type KeqMiddlewareOptions,\n type KeqEvents,\n type KeqRetryDelay,\n type KeqRetryOn,\n} from './context'\n\nexport {\n Exception,\n TypeException,\n TimeoutException,\n AbortException,\n\n RequestException,\n\n BadRequestException,\n UnauthorizedException,\n ForbiddenException,\n NotFoundedException,\n MethodNotAllowedException,\n NotAcceptableException,\n ProxyAuthenticationRequiredException,\n RequestTimeoutException,\n ConflictException,\n PreconditionFailedException,\n ContentTooLargeException,\n UriTooLongException,\n ImATeapotException,\n TooManyRequestsException,\n UnsupportedMediaTypeException,\n\n InternalServerErrorException,\n NotImplementedException,\n BadGatewayException,\n ServiceUnavailableException,\n GatewayTimeoutException,\n} from './exception'\n\nexport {\n KeqMiddlewareOrchestrator,\n KeqMiddlewareExecutor,\n} from './orchestrator'\n","import { CustomError } from 'ts-custom-error'\n\nexport class Exception extends CustomError {\n constructor(message?: string) {\n super(message)\n\n Object.defineProperty(this, 'name', { value: 'KeqError' })\n }\n}\n","import { Exception } from './exception.js'\n\n\nexport class TypeException extends Exception {\n constructor(msg?: string) {\n super(msg || 'Invalid Type')\n }\n}\n","export class AbortException extends DOMException {\n constructor(msg: string) {\n super(msg, 'AbortError')\n Object.setPrototypeOf(this, AbortException.prototype)\n }\n}\n","import { AbortException } from './abort.exception.js'\n\n\nexport class TimeoutException extends AbortException {\n constructor(msg: string) {\n super(msg)\n }\n}\n","import { Exception } from '../exception.js'\n\n\nexport class RequestException extends Exception {\n statusCode: number\n retry: boolean\n\n constructor(statusCode: number, message?: string, retry = true) {\n super(message)\n\n this.statusCode = statusCode\n this.retry = retry\n\n Object.defineProperty(this, 'name', { value: 'RequestException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class BadRequestException extends RequestException {\n constructor(message: string = 'Bad Request', retry = false) {\n super(400, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'BadRequestException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class UnauthorizedException extends RequestException {\n constructor(message: string = 'Unauthorized', retry = false) {\n super(401, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'UnauthorizedException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ForbiddenException extends RequestException {\n constructor(message: string = 'Forbidden', retry = false) {\n super(403, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'ForbiddenException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class NotFoundedException extends RequestException {\n constructor(message: string = 'Not Founded', retry = false) {\n super(404, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'NotFoundedException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class MethodNotAllowedException extends RequestException {\n constructor(message: string = 'Method Not Allowed', retry = false) {\n super(405, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'MethodNotAllowedException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class NotAcceptableException extends RequestException {\n constructor(message: string = 'Not Acceptable', retry = false) {\n super(406, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'NotAcceptableException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ProxyAuthenticationRequiredException extends RequestException {\n constructor(message: string = 'Proxy Authentication Required', retry = false) {\n super(407, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'ProxyAuthenticationRequiredException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class RequestTimeoutException extends RequestException {\n constructor(message: string = 'Request Timeout', retry = true) {\n super(408, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'RequestTimeoutException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ConflictException extends RequestException {\n constructor(message: string = 'Conflict', retry = false) {\n super(409, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'ConflictException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class PreconditionFailedException extends RequestException {\n constructor(message: string = 'Precondition Failed', retry = false) {\n super(412, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'PreconditionFailedException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ContentTooLargeException extends RequestException {\n constructor(message: string = 'Content Too Large', retry = false) {\n super(413, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'ContentTooLargeException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class UriTooLongException extends RequestException {\n constructor(message: string = 'URI Too Long', retry = false) {\n super(414, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'UriTooLongException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class UnsupportedMediaTypeException extends RequestException {\n constructor(message: string = 'Unsupported Media Type', retry = false) {\n super(415, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'UnsupportedMediaTypeException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class ImATeapotException extends RequestException {\n constructor(message: string = \"I'm a teapot\", retry = false) {\n super(418, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'ImATeapotException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class TooManyRequestsException extends RequestException {\n constructor(message: string = 'Too Many Requests', retry = true) {\n super(429, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'TooManyRequestsException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class InternalServerErrorException extends RequestException {\n constructor(message: string = 'Internal Server Error', retry = true) {\n super(500, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'InternalServerErrorException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class NotImplementedException extends RequestException {\n constructor(message: string = 'Not Implemented', retry = false) {\n super(501, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'NotImplementedException' })\n }\n}\n","import { RequestException } from './request.exception'\n\n\nexport class BadGatewayException extends RequestException {\n constructor(message: string = 'Bad Gateway', retry = true) {\n super(502, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'BadGatewayException' })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class ServiceUnavailableException extends RequestException {\n constructor(message: string = 'Service Unavailable', retry = true) {\n super(503, message, retry)\n\n Object.defineProperty(this, 'name', {\n value: 'ServiceUnavailableException',\n })\n }\n}\n","import { RequestException } from './request.exception'\n\nexport class GatewayTimeoutException extends RequestException {\n constructor(message: string = 'Gateway Timeout', retry = true) {\n super(504, message, retry)\n\n Object.defineProperty(this, 'name', { value: 'GatewayTimeoutException' })\n }\n}\n","export const base64Encode: ((str: string) => string) = globalThis.btoa || ((str: string) => Buffer.from(str).toString('base64'))\nexport const base64Decode: ((str: string) => string) = globalThis.atob || ((str: string) => Buffer.from(str, 'base64').toString('utf8'))\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Validator 类用于类型检查\n */\nexport class Validator {\n /**\n * 检查是否为浏览器环境\n */\n static isBrowser(): boolean {\n return typeof window !== 'undefined'\n }\n\n /**\n * 检查是否为字符串\n */\n static isString(value: any): boolean {\n return typeof value === 'string'\n }\n\n /**\n * 检查是否为对象\n */\n static isObject(value: any): value is Exclude<object, null> {\n return typeof value === 'object' && value !== null\n }\n\n /**\n * 检查是否为函数\n */\n static isFunction(value: any): boolean {\n return typeof value === 'function'\n }\n\n /**\n * 检查是否为 ArrayBuffer\n */\n static isArrayBuffer(body: any): body is ArrayBuffer {\n return body instanceof ArrayBuffer\n }\n\n /**\n * 检查是否为 ReadableStream\n */\n static isReadableStream(body: any): body is ReadableStream {\n return body instanceof ReadableStream\n }\n\n /**\n * 检查是否为 Blob 或 File 类对象\n */\n static isBlob(value: any): value is Blob {\n if (value instanceof Blob) return true\n\n const names = ['Blob', 'File']\n\n return Validator.isObject(value)\n && Validator.isString(value['type'])\n && Validator.isFunction(value['arrayBuffer'])\n && Validator.isFunction(value['stream'])\n && Validator.isFunction(value.constructor)\n && names.includes(value.constructor.name)\n && 'size' in value\n }\n\n /**\n * 检查是否为 File\n */\n static isFile(object: any): object is File {\n if (Validator.isBrowser()) return object instanceof Blob\n\n return Validator.isBlob(object)\n }\n\n /**\n * 检查是否为 Buffer\n */\n static isBuffer(obj: any): obj is Buffer {\n return Validator.isBrowser() ? false : Buffer.isBuffer(obj)\n }\n\n /**\n * 检查是否为 FormData\n */\n static isFormData(object: any): object is FormData {\n if (object instanceof FormData) return true\n\n return (\n Validator.isObject(object)\n && Validator.isFunction(object['append'])\n && Validator.isFunction(object['delete'])\n && Validator.isFunction(object['get'])\n && Validator.isFunction(object['getAll'])\n && Validator.isFunction(object['has'])\n && Validator.isFunction(object['set'])\n && Validator.isFunction(object['entries'])\n && Validator.isFunction(object['keys'])\n && Validator.isFunction(object['values'])\n )\n }\n\n /**\n * 检查是否为 Headers\n */\n static isHeaders(obj: any): obj is Headers {\n if (obj instanceof Headers) return true\n\n if (\n Validator.isObject(obj)\n && Validator.isFunction(obj['forEach'])\n && Validator.isFunction(obj['get'])\n && Validator.isFunction(obj['has'])\n && Validator.isFunction(obj['set'])\n && Validator.isFunction(obj['append'])\n && Validator.isFunction(obj['delete'])\n && Validator.isFunction(obj['entries'])\n && Validator.isFunction(obj['keys'])\n && Validator.isFunction(obj['values'])\n ) {\n return true\n }\n\n return false\n }\n\n /**\n * 检查是否为 URLSearchParams\n */\n static isUrlSearchParams(obj: any): obj is URLSearchParams {\n if (obj instanceof URLSearchParams) return true\n\n return (\n Validator.isObject(obj)\n && Validator.isFunction(obj['append'])\n && Validator.isFunction(obj['delete'])\n && Validator.isFunction(obj['entries'])\n && Validator.isFunction(obj['forEach'])\n && Validator.isFunction(obj['get'])\n && Validator.isFunction(obj['getAll'])\n && Validator.isFunction(obj['has'])\n && Validator.isFunction(obj['keys'])\n && Validator.isFunction(obj['set'])\n && Validator.isFunction(obj['values'])\n && Validator.isFunction(obj['sort'])\n && Validator.isFunction(obj['toString'])\n )\n }\n\n /**\n * 检查是否为合法的 Header 值\n * 允许范围: HTAB(\\t), 0x20-0x7E, 0x80-0xFF\n * 禁止换行等控制字符\n */\n static isHeaderValue(str: any): boolean {\n const regex = /^[\\t\\x20-\\x7E\\x80-\\xFF]*$/\n return regex.test(String(str))\n }\n\n /**\n * 检查是否为 BodyInit 类型\n * BodyInit 包括: Blob | ArrayBuffer | TypedArray | DataView | FormData | URLSearchParams | ReadableStream | string\n */\n static isBodyInit(value: any): value is BodyInit {\n if (value === null || value === undefined) return false\n\n return (\n Validator.isString(value)\n || Validator.isBlob(value)\n || Validator.isArrayBuffer(value)\n || Validator.isFormData(value)\n || Validator.isUrlSearchParams(value)\n || Validator.isReadableStream(value)\n || Validator.isBuffer(value)\n // TypedArray or DataView\n || ArrayBuffer.isView(value)\n )\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Validator } from '~/validator/index.js'\n\n\n/**\n * @description 浅拷贝\n */\nexport function shallowClone<T = any>(obj: T): T {\n if (Array.isArray(obj)) {\n return [...obj] as T\n }\n\n if (Validator.isObject(obj)) {\n return { ...obj }\n }\n\n return obj\n}\n","export function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Validator } from '~/validator/index.js'\n\n\nexport function cloneBody<T>(obj: T): T {\n if (Validator.isFormData(obj)) {\n const formData = new FormData()\n for (const [key, value] of obj.entries()) {\n formData.append(key, value)\n }\n return formData as unknown as T\n }\n\n if (Validator.isUrlSearchParams(obj)) {\n const urlSearchParams = new URLSearchParams()\n for (const [key, value] of obj.entries()) {\n urlSearchParams.append(key, value)\n }\n return urlSearchParams as unknown as T\n }\n\n if (Validator.isFile(obj)) {\n return obj\n }\n\n if (Validator.isBlob(obj)) {\n return obj\n }\n\n if (Validator.isBuffer(obj)) {\n return obj\n }\n\n if (obj === null) {\n return null as T\n }\n\n if (Array.isArray(obj)) {\n return obj.map(cloneBody) as unknown as T\n }\n\n if (Validator.isObject(obj)) {\n const cloned: any = {}\n\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n cloned[key] = cloneBody(obj[key])\n }\n }\n return cloned\n }\n\n return obj\n}\n","export function cloneHeaders(headers: Headers): Headers {\n const cloned = new Headers()\n for (const [key, value] of headers.entries()) {\n cloned.append(key, value)\n }\n\n return cloned\n}\n","import { UriTemplateContext, UriTemplateParser } from '@opendoc/uri-template'\n\n\nexport function compileUrl(obj: string | URL, pathParameters: UriTemplateContext): URL {\n const url = new URL(typeof obj === 'string' ? obj : obj.href)\n\n url.pathname = new UriTemplateParser(\n decodeURIComponent(url.pathname),\n pathParameters,\n ).expand()\n\n return url\n}\n","export function toFormData(body: object): FormData {\n const form = new FormData()\n\n for (const [key, value] of Object.entries(body)) {\n if (Array.isArray(value)) {\n for (const v of value) {\n form.append(key, v)\n }\n } else {\n form.append(key, value)\n }\n }\n\n return form\n}\n","export function toUrlSearchParams(body: object): URLSearchParams {\n const params = new URLSearchParams()\n Object.entries(body).map(([key, value]) => {\n if (Array.isArray(value)) {\n for (const v of value) {\n params.append(key, v)\n }\n } else {\n params.append(key, value)\n }\n })\n\n return params\n}\n","import { KeqRequestInit } from '../request-init'\n\n\nexport function cloneRequestInit(init: KeqRequestInit): KeqRequestInit {\n return new KeqRequestInit({\n url: init.url,\n pathParameters: init.pathParameters,\n method: init.method,\n headers: init.headers,\n body: init.body,\n cache: init.cache,\n credentials: init.credentials,\n integrity: init.integrity,\n keepalive: init.keepalive,\n mode: init.mode,\n redirect: init.redirect,\n referrer: init.referrer,\n referrerPolicy: init.referrerPolicy,\n })\n}\n","import { UriTemplateContext } from '@opendoc/uri-template'\nimport { shallowClone } from '~/utils/shallow-clone.js'\nimport { Validator } from '~/validator/index.js'\nimport { Exception } from '~/exception/exception.js'\nimport { KeqRequestMethod, KeqBodyInit } from './types/index.js'\nimport {\n toUrlSearchParams,\n toFormData,\n cloneBody,\n cloneHeaders,\n compileUrl,\n} from './utils/index.js'\n\nexport interface KeqRequestInitOptions {\n url: URL\n pathParameters: UriTemplateContext\n method: KeqRequestMethod\n headers: Headers\n body: KeqBodyInit\n cache?: RequestCache\n credentials?: RequestCredentials\n integrity?: string\n keepalive?: boolean\n mode?: RequestMode\n redirect?: RequestRedirect\n referrer?: string\n referrerPolicy?: ReferrerPolicy\n}\n\nexport const AbortControllerProperty = Symbol('context.request.abortController')\n\nexport class KeqRequestInit {\n url: URL\n pathParameters: UriTemplateContext\n\n method: KeqRequestMethod\n headers: Headers\n body: KeqBodyInit\n cache?: RequestCache\n credentials?: RequestCredentials\n integrity?: string\n keepalive?: boolean\n mode?: RequestMode\n redirect?: RequestRedirect\n referrer?: string\n referrerPolicy?: ReferrerPolicy\n\n [AbortControllerProperty]: AbortController = new AbortController()\n\n constructor(options: KeqRequestInitOptions) {\n this.url = new URL(options.url.href)\n this.pathParameters = shallowClone(options.pathParameters)\n this.method = options.method\n this.headers = cloneHeaders(options.headers)\n this.body = cloneBody(options.body)\n this.cache = options.cache\n this.credentials = options.credentials\n this.integrity = options.integrity\n this.keepalive = options.keepalive\n this.mode = options.mode\n this.redirect = options.redirect\n this.referrer = options.referrer\n this.referrerPolicy = options.referrerPolicy\n }\n\n // the url merged pathParameters\n get __url__(): Readonly<URL> {\n return compileUrl(this.url, this.pathParameters)\n }\n\n get signal(): AbortSignal {\n return this[AbortControllerProperty].signal\n }\n\n abort(reason: any): void {\n if (!this[AbortControllerProperty].signal.aborted) {\n this[AbortControllerProperty].abort(reason)\n }\n }\n\n private getContentType(): string | undefined {\n const contentType = this.headers.get('Content-Type')\n if (contentType) return contentType\n if (!this.body) return undefined\n\n if (Validator.isFormData(this.body)) return 'multipart/form-data'\n if (Validator.isUrlSearchParams(this.body)) return 'application/x-www-form-urlencoded'\n if (Validator.isArrayBuffer(this.body)) return 'application/octet-stream'\n if (typeof this.body === 'object') return 'application/json'\n\n return undefined\n }\n\n private toFetchBody(contentType: string | undefined): RequestInit['body'] {\n const body = this.body\n if (body === undefined) return\n if (body === null) return null\n if (Validator.isBodyInit(body)) return body\n\n if (!contentType || contentType === 'application/json') {\n return JSON.stringify(body)\n }\n\n if (contentType === 'application/x-www-form-urlencoded') {\n if (Array.isArray(body)) {\n throw new Exception('request.body is an array, that cannot be serialized as application/x-www-form-urlencoded format')\n }\n\n return toUrlSearchParams(body)\n }\n\n if (contentType === 'multipart/form-data') {\n if (Array.isArray(body)) {\n throw new Exception('FormData cannot send array')\n }\n\n return toFormData(body)\n }\n\n throw new Exception(`Cannot auto serialize request.body with Content-Type: ${contentType}`)\n }\n\n toFetchArguments(): [string, RequestInit] {\n const contentType = this.getContentType()\n const headers = cloneHeaders(this.headers)\n if (contentType) headers.set('Content-Type', contentType)\n\n const body = this.toFetchBody(contentType)\n if (contentType === 'multipart/form-data') {\n headers.delete('Content-Type')\n }\n\n const requestInit: RequestInit = {\n method: this.method.toUpperCase(),\n headers,\n body,\n cache: this.cache,\n credentials: this.credentials,\n integrity: this.integrity,\n keepalive: this.keepalive,\n mode: this.mode,\n redirect: this.redirect,\n referrer: this.referrer,\n referrerPolicy: this.referrerPolicy,\n signal: this.signal,\n }\n\n return [this.__url__.href, requestInit]\n }\n}\n","import type { KeqMiddlewareExecutor, KeqMiddlewareOrchestrator } from '~/orchestrator/index.js'\nimport { KeqMiddlewareContext } from './middleware-context.js'\n\n\nconst OrchestratorProperty = Symbol('protected context.orchestration.orchestrator')\nconst ExecutorProperty = Symbol('protected context.orchestration.executor')\n\nexport class KeqOrchestratorContext {\n readonly [OrchestratorProperty]: KeqMiddlewareOrchestrator\n readonly [ExecutorProperty]: KeqMiddlewareExecutor\n\n constructor(orchestrator: KeqMiddlewareOrchestrator, executor: KeqMiddlewareExecutor) {\n this[OrchestratorProperty] = orchestrator\n this[ExecutorProperty] = executor\n }\n\n get middlewares(): KeqMiddlewareContext[] {\n return this[OrchestratorProperty].executors.map((exe) => exe.context)\n }\n\n // NOTE: For Future\n // get executing(): KeqMiddlewareContext {\n // const current = this[OrchestratorProperty].current\n // const executors = this[OrchestratorProperty].executors\n // const executor = executors[current]\n // return executor.context\n // }\n\n /**\n * The middleware context of the current middleware\n */\n get middleware(): KeqMiddlewareContext {\n return this[ExecutorProperty].context\n }\n\n fork(): KeqMiddlewareOrchestrator {\n return this[OrchestratorProperty].fork()\n }\n\n merge(source: KeqMiddlewareOrchestrator): void {\n this[OrchestratorProperty].merge(source)\n }\n}\n","import { KeqMiddlewareExecutor, KeqMiddlewareOrchestrator } from '~/orchestrator/index.js'\nimport { KeqRequestInit } from '~/request-init/index.js'\nimport { KeqOrchestratorContext } from './orchestrator-context.js'\nimport type {\n KeqContext,\n KeqContextData,\n KeqContextEmitter,\n KeqContextOptions,\n KeqGlobal,\n} from './types/index.js'\n\nexport const ContextOrchestratorProperty = Symbol('protected context.orchestrator')\nexport const ContextOrchestrationProperty = Symbol('protected context.orchestration')\n\n\nexport class KeqExecutionContext implements KeqContext {\n private [ContextOrchestratorProperty]: KeqMiddlewareOrchestrator\n private [ContextOrchestrationProperty]: KeqOrchestratorContext\n\n constructor(orchestrator: KeqMiddlewareOrchestrator, executor: KeqMiddlewareExecutor) {\n this[ContextOrchestratorProperty] = orchestrator\n this[ContextOrchestrationProperty] = new KeqOrchestratorContext(orchestrator, executor)\n }\n\n get orchestration(): KeqOrchestratorContext {\n return this[ContextOrchestrationProperty]\n }\n\n /**\n * The unique identifier of the request's location in the code\n */\n get locationId(): string | undefined {\n return this[ContextOrchestratorProperty].context.locationId\n }\n\n get request(): KeqRequestInit {\n return this[ContextOrchestratorProperty].context.request\n }\n\n get global(): KeqGlobal {\n return this[ContextOrchestratorProperty].context.global\n }\n\n get emitter(): KeqContextEmitter {\n return this[ContextOrchestratorProperty].context.emitter\n }\n\n get options(): KeqContextOptions {\n return this[ContextOrchestratorProperty].context.options\n }\n\n // The result get by user if resolveWith is set to 'intelligent' or not set\n set output(value: any) {\n if (this.options.resolveWith && this.options.resolveWith !== 'intelligent') {\n console.warn(`The request is configured to resolve with ${this.options.resolveWith}, so setting context.output maybe no effect.`)\n }\n this[ContextOrchestratorProperty].context.output = value\n }\n\n // The original response\n get res(): Response | undefined {\n return this[ContextOrchestratorProperty].context.res\n }\n\n // The original response\n set res(value: Response | undefined) {\n this[ContextOrchestratorProperty].context.res = value\n }\n\n // The request response\n get response(): Response | undefined {\n return this[ContextOrchestratorProperty].context.response\n }\n\n // The properties extends by middleware\n get data(): KeqContextData {\n return this[ContextOrchestratorProperty].context.data\n }\n}\n","import mitt from 'mitt'\nimport {\n KeqRequestInit,\n KeqRequestInitOptions,\n} from '~/request-init/index.js'\nimport { shallowClone } from '~/utils/shallow-clone.js'\nimport {\n watchObject,\n createProxyResponse,\n} from './utils/index.js'\nimport type {\n KeqContext,\n KeqContextOptions,\n KeqContextEmitter,\n KeqContextData,\n KeqGlobal,\n KeqEvents,\n} from './types/index.js'\n\nexport interface KeqSharedContextOptions {\n locationId?: string\n request: KeqRequestInitOptions\n global: KeqGlobal\n options?: KeqContextOptions\n data?: KeqContextData\n emitter?: KeqContextEmitter\n}\n\nexport const ContextLocationIdProperty = Symbol('protected context.locationId')\nexport const ContextRequestProperty = Symbol('protected context.request')\nexport const ContextGlobalProperty = Symbol('protected context.global')\nexport const ContextEmitterProperty = Symbol('protected context.emitter')\nexport const ContextOptionsProperty = Symbol('protected context.options')\nexport const ContextDataProperty = Symbol('protected context.data')\nexport const ContextOutputProperty = Symbol('protected context.output')\n\nexport class KeqSharedContext implements KeqContext {\n readonly [ContextLocationIdProperty]?: string\n [ContextRequestProperty]: KeqRequestInit\n [ContextGlobalProperty]: Record<string, any>\n [ContextEmitterProperty]: KeqContextEmitter\n [ContextOptionsProperty]: KeqContextOptions\n [ContextOutputProperty]?: any\n\n // The properties extends by middleware\n [ContextDataProperty]: KeqContextData = {}\n\n\n /**\n * original response\n */\n res?: Response\n\n constructor(options: KeqSharedContextOptions) {\n this[ContextLocationIdProperty] = options.locationId\n\n this[ContextRequestProperty] = watchObject(new KeqRequestInit(options.request), {\n abort: (target, thisArg, argArray) => {\n this[ContextEmitterProperty].emit('abort', { context: this, reason: argArray[0] })\n },\n })\n\n this[ContextEmitterProperty] = options.emitter || mitt<Omit<KeqEvents, never>>()\n this[ContextGlobalProperty] = options.global\n this[ContextOptionsProperty] = options.options ? shallowClone(options.options) : {}\n this[ContextDataProperty] = options.data || {}\n }\n\n /**\n * The unique identifier of the request's location in the code\n */\n get locationId(): string | undefined {\n return this[ContextLocationIdProperty]\n }\n\n get request(): KeqRequestInit {\n return this[ContextRequestProperty]\n }\n\n get global(): KeqGlobal {\n return this[ContextGlobalProperty]\n }\n\n get emitter(): KeqContextEmitter {\n return this[ContextEmitterProperty]\n }\n\n get options(): KeqContextOptions {\n return this[ContextOptionsProperty]\n }\n\n set output(value: any) {\n this[ContextOutputProperty] = value\n }\n\n get response(): Response | undefined {\n if (!this.res) return undefined\n\n return createProxyResponse(this.res)\n }\n\n get data(): KeqContextData {\n return this[ContextDataProperty]\n }\n}\n\n\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-function-type */\nimport { ConditionalPick } from 'type-fest'\n\n\ntype Watcher = (target: any, thisArg: any, argArray: any[]) => void\n\nexport function watchObject<T extends object>(obj: T, listeners: Partial<Record<keyof ConditionalPick<T, Function>, Watcher>>): T {\n return new Proxy(obj, {\n get(target, prop) {\n if (prop in listeners) {\n return new Proxy(target[prop], {\n apply(target: Function, thisArg, argArray) {\n const listener: Function = listeners[prop]\n listener(target, thisArg, argArray)\n return target.apply(thisArg, argArray)\n },\n })\n }\n\n return target[prop]\n },\n })\n}\n","import { cloneRequestInit } from '~/request-init'\nimport {\n ContextDataProperty,\n ContextEmitterProperty,\n ContextGlobalProperty,\n ContextLocationIdProperty,\n ContextOptionsProperty,\n ContextRequestProperty,\n KeqSharedContext,\n} from '../shared-context'\nimport { klona } from 'klona'\n\n\nexport function cloneSharedContext(context: KeqSharedContext): KeqSharedContext {\n const cloned = new KeqSharedContext({\n locationId: context[ContextLocationIdProperty],\n request: cloneRequestInit(context[ContextRequestProperty]),\n global: context[ContextGlobalProperty],\n options: klona(context[ContextOptionsProperty]),\n data: klona(context[ContextDataProperty]),\n })\n\n context[ContextEmitterProperty].all.forEach((handlers, type) => {\n for (const handler of handlers) {\n cloned.emitter.on(type as any, handler as any)\n }\n })\n\n return cloned\n}\n","\n/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { klona } from 'klona/json'\n\n\nconst UnWrapPropertyKey = Symbol('UnWrapPropertyKey')\n\nconst ARRAY_MUTATORS = new Set([\n 'push',\n 'pop',\n 'shift',\n 'unshift',\n 'splice',\n 'sort',\n 'reverse',\n 'fill',\n 'copyWithin',\n])\n\nfunction objectPath(obj: any, path: PropertyKey[]): any {\n return path.reduce((o, k) => o[k], obj)\n}\n\n/**\n * Fork an json object, using copy-on-write strategy to avoid unnecessary deep cloning.\n */\nexport function fork<T>(original: T): T {\n if (original === null || typeof original !== 'object') {\n // primitive value, return directly\n return original\n }\n\n let current = original\n\n const ensureCopy = (): T => {\n if (current === original) {\n current = klona(original)\n }\n\n return current\n }\n\n\n const createProxy = (path: PropertyKey[] = []): any => {\n return new Proxy({} as any, {\n get(_, prop) {\n const target = objectPath(current, path)\n if (prop === UnWrapPropertyKey) return target\n\n const value = target[prop]\n\n // return value directly if already copied\n if (current !== original) {\n return value\n }\n\n // handle array mutator methods\n if (Array.isArray(target) && ARRAY_MUTATORS.has(prop as string)) {\n return new Proxy(value, {\n apply(fn, thisArg, args) {\n ensureCopy()\n const t = objectPath(current, path)\n return Reflect.apply(t[prop], t, args)\n },\n })\n }\n\n // 未复制,嵌套对象需要继续代理\n if (typeof value === 'object' && value !== null) {\n return createProxy([...path, prop])\n }\n\n return value\n },\n\n set(_, prop, value) {\n ensureCopy()\n objectPath(current, path)[prop] = value\n return true\n },\n\n deleteProperty(_, prop) {\n ensureCopy()\n delete objectPath(current, path)[prop]\n return true\n },\n })\n }\n\n return createProxy()\n}\n\nexport function unwrap<T>(proxy: T): T {\n return proxy && (proxy as any)[UnWrapPropertyKey] ? (proxy as any)[UnWrapPropertyKey] : proxy\n}\n","import { fork } from './fork'\n\nconst JsonCachePropertyKey = Symbol('KeqResponseProxyJsonCachePropertyKey')\nconst TextCachePropertyKey = Symbol('KeqResponseProxyTextCachePropertyKey')\n\nexport function createProxyResponse(response: Response): Response {\n return new Proxy(response, {\n get(res, prop) {\n if (typeof prop === 'string') {\n if (prop === 'json') {\n return new Proxy(res[prop], {\n apply() {\n if (res[JsonCachePropertyKey]) {\n return fork(res[JsonCachePropertyKey]) as unknown\n }\n\n return res.clone().json()\n .then((body) => {\n res[JsonCachePropertyKey] = body\n return fork(body) as unknown\n })\n },\n })\n } else if (prop === 'text') {\n return new Proxy(res[prop], {\n apply() {\n if (res[TextCachePropertyKey]) {\n return fork(res[TextCachePropertyKey]) as unknown\n }\n\n return res.clone().text()\n .then((body) => {\n res[TextCachePropertyKey] = body\n return body\n })\n },\n })\n } else if (['arrayBuffer', 'blob', 'buffer', 'formData'].includes(prop)) {\n /**\n * clone when invoking body, json, text, arrayBuffer, blob, buffer, formData\n * to avoid time-consuming cloning\n */\n return new Proxy(res[prop], {\n apply(target, thisArg, argArray) {\n return res.clone()[prop](...argArray) as unknown\n },\n }) as unknown\n } else if (prop === 'body') {\n const mirror = res.clone()\n return mirror.body\n }\n }\n\n if (typeof res[prop] === 'function') {\n return res[prop].bind(res) as unknown\n }\n\n return res[prop] as unknown\n },\n })\n}\n","import { KeqMiddleware } from '../types'\n\n\nexport function getMiddlewareName(middleware: KeqMiddleware): string {\n return middleware.__keqMiddlewareName__ || middleware.name || 'anonymous'\n}\n","import { TypeException } from '~/exception/index.js'\nimport type { KeqMiddleware } from '../types/keq-middleware.js'\nimport { getMiddlewareName } from './get-middleware-name.js'\n\n\ninterface ComposeMiddlewareOptions {\n name?: string\n}\n\nexport function composeMiddleware(middlewares: KeqMiddleware[], options?: ComposeMiddlewareOptions): KeqMiddleware {\n if (!middlewares.length) {\n throw new TypeException('At least one middleware')\n }\n\n const middleware = [...middlewares]\n .reverse()\n .reduce(function (prev, curr): KeqMiddleware {\n return async (ctx, next) => {\n await curr(ctx, async () => prev(ctx, next))\n }\n })\n\n if (options?.name) {\n middleware.__keqMiddlewareName__ = options.name\n } else {\n middleware.__keqMiddlewareName__ = `composeMiddleware(${middlewares.map((i) => getMiddlewareName(i)).join(', ')})`\n }\n\n return middleware\n}\n","import { type KeqMiddlewareExecutor } from '../orchestrator/executor.js'\n\n\nconst ExecutorProperty = Symbol('protected context.orchestration.middlewares')\n\nexport class KeqMiddlewareContext {\n readonly [ExecutorProperty]: KeqMiddlewareExecutor\n\n constructor(executor: KeqMiddlewareExecutor) {\n this[ExecutorProperty] = executor\n }\n\n get name(): string {\n return this[ExecutorProperty].name\n }\n\n get status(): KeqMiddlewareExecutor['status'] {\n return this[ExecutorProperty].status\n }\n\n get finished(): boolean {\n return this.status === 'fulfilled' || this.status === 'rejected'\n }\n}\n","import { Exception } from '~/exception/index.js'\nimport { KeqExecutionContext } from '~/context/index.js'\nimport { KeqNext } from '~/middleware/types/keq-next.js'\nimport { getMiddlewareName, KeqMiddleware } from '~/middleware/index.js'\nimport { KeqMiddlewareContext } from '~/context/middleware-context'\n\nexport class KeqMiddlewareExecutor {\n readonly name: string\n status: 'idle' | 'pending' | 'canceled' | 'fulfilled' | 'rejected' = 'idle'\n context: KeqMiddlewareContext\n\n constructor(\n public readonly middleware: KeqMiddleware,\n ) {\n this.name = getMiddlewareName(middleware)\n this.context = new KeqMiddlewareContext(this)\n }\n\n async execute(context: KeqExecutionContext, next: KeqNext): Promise<void> {\n if (this.status !== 'idle') {\n throw new Exception(`Middleware \"${this.name}\" has already been executed.`)\n }\n\n try {\n this.status = 'pending'\n context.emitter.emit('middleware:before', { context })\n await this.middleware(context, next)\n context.emitter.emit('middleware:after', { context })\n\n if (this.status === 'pending') {\n this.status = 'fulfilled'\n }\n } catch (error) {\n if (this.status === 'pending') {\n this.status = 'rejected'\n }\n throw error\n }\n }\n}\n","import { AbortControllerProperty, KeqRequestInit } from '../request-init'\n\nexport function assignRequestInit(\n target: KeqRequestInit,\n source: KeqRequestInit,\n): void {\n target.url = source.url\n target.pathParameters = source.pathParameters\n target.method = source.method\n target.headers = source.headers\n target.body = source.body\n target.cache = source.cache\n target.credentials = source.credentials\n target.integrity = source.integrity\n target.keepalive = source.keepalive\n target.mode = source.mode\n target.redirect = source.redirect\n target.referrer = source.referrer\n target.referrerPolicy = source.referrerPolicy\n target[AbortControllerProperty] = source[AbortControllerProperty]\n}\n","import { assignRequestInit } from '~/request-init/utils/assign-request-init'\nimport { ContextEmitterProperty, ContextOutputProperty, KeqSharedContext } from '../shared-context'\n\nexport function assignSharedContext(\n target: KeqSharedContext,\n source: KeqSharedContext,\n): void {\n assignRequestInit(target.request, source.request)\n\n Object.assign(target.global, source.global)\n Object.assign(target.options, source.options)\n Object.assign(target.data, source.data)\n\n target[ContextEmitterProperty] = source[ContextEmitterProperty]\n target[ContextOutputProperty] = source[ContextOutputProperty]\n\n target.res = source.res\n}\n","import { Exception, TypeException } from '~/exception/index.js'\nimport { KeqExecutionContext, KeqSharedContext } from '~/context/index.js'\nimport { KeqMiddleware } from '~/middleware/index.js'\nimport { KeqMiddlewareExecutor } from './executor.js'\nimport { cloneSharedContext } from '~/context/utils/clone-shared-context.js'\nimport { assignSharedContext } from '~/context/utils/assign-shared-context.js'\n\n\nexport class KeqMiddlewareOrchestrator {\n main?: {\n orchestrator: KeqMiddlewareOrchestrator\n index: number\n }\n\n status: 'idle' | 'pending' | 'fulfilled' | 'rejected' = 'idle'\n context: KeqSharedContext\n executors: KeqMiddlewareExecutor[] = []\n\n current: number = -1\n\n constructor(\n context: KeqSharedContext,\n middlewares: KeqMiddleware[] = [],\n ) {\n this.context = context\n this.executors = middlewares.map((mw) => new KeqMiddlewareExecutor(mw))\n }\n\n private cancelNotFinished(): void {\n const current = this.current\n\n for (let i = current + 1; i < this.executors.length; i++) {\n const executor = this.executors[i]\n if (executor.status === 'pending') {\n executor.status = 'canceled'\n }\n }\n }\n\n private async run(): Promise<void> {\n if (this.executors.length === 0) return\n\n // clone executors array to avoid mutation during execution\n const executors = [...this.executors]\n\n const next = async (nextIndex: number): Promise<void> => {\n if (nextIndex >= executors.length) return\n\n const nextExecutor = executors[nextIndex]\n if (nextExecutor.status !== 'idle') {\n const msg = `Cannot call next() because the next Middleware(${nextExecutor.name}) status is ${nextExecutor.status}. If you want to re-execute it, please fork a new orchestrator.`\n throw new Exception(msg)\n }\n\n if (this.current + 1 !== nextIndex) {\n const parentExecutor = executors[nextIndex - 1]\n const msg = parentExecutor\n ? `Cannot call next() outside Middleware(${parentExecutor.name}) runtime. You can fork a new orchestration and execute the forked one anywhere.`\n : 'Cannot jump to non-sequential middleware. Please call next() in order.'\n\n throw new Exception(msg)\n }\n\n const last = this.current\n this.current = nextIndex\n const context = new KeqExecutionContext(this, nextExecutor)\n\n try {\n await nextExecutor.execute(context, () => next.call(this, nextIndex + 1))\n } finally {\n if (this.current === last + 1) {\n this.current = last\n } else if (this.current > last) {\n this.cancelNotFinished()\n this.current = last\n }\n }\n }\n\n await next.call(this, 0)\n }\n\n async execute(): Promise<void> {\n if (this.status !== 'idle') {\n throw new Exception('Orchestrator has already been executed.')\n }\n\n this.status = 'pending'\n\n try {\n await this.run()\n this.status = 'fulfilled'\n } catch (error) {\n this.status = 'rejected'\n throw error\n }\n }\n\n fork(): KeqMiddlewareOrchestrator {\n const context = cloneSharedContext(this.context)\n const next = this.current + 1\n const middlewares = this.executors.slice(next)\n .map((executor) => executor.middleware)\n\n const forkedOrchestrator = new KeqMiddlewareOrchestrator(context, middlewares)\n forkedOrchestrator.main = {\n orchestrator: this.main ? this.main.orchestrator : this,\n index: this.main ? this.main.index + next : next,\n }\n\n return forkedOrchestrator\n }\n\n merge(source: KeqMiddlewareOrchestrator): void {\n if (!source.main) throw new TypeException('Source orchestrator is not a forked orchestrator.')\n\n const target = this.main ? this.main.orchestrator : this\n if (source.main.orchestrator !== target) throw new TypeException('Cannot rebase to unrelated orchestrator')\n if (source.main.index !== this.current + 1) throw new TypeException(`Cannot merge from non-current(expected: ${this.current + 1}, actual: ${source.main.index}) forked orchestrator`)\n\n // copy context\n assignSharedContext(this.context, source.context)\n\n // copy executors status\n for (const [i, executor] of this.executors.slice(source.main.index).entries()) {\n executor.status = source.executors[i].status\n }\n }\n}\n","import type { ShorthandContentType } from '~/request/types/content-type.js'\n\n\nexport function fixContentType(contentType: ShorthandContentType): string\nexport function fixContentType(contentType: string): string\nexport function fixContentType(contentType: string): string {\n if (['json', 'xml'].includes(contentType)) {\n return `application/${contentType}`\n } else if (['html', 'css'].includes(contentType)) {\n return `text/${contentType}`\n } else if (['form-data'].includes(contentType)) {\n return `multipart/${contentType}`\n } else if (['jpeg', 'bmp', 'apng', 'gif', 'x-icon', 'png', 'webp', 'tiff'].includes(contentType)) {\n return `image/${contentType}`\n } else if (contentType === 'form') {\n return 'application/x-www-form-urlencoded'\n } else if (contentType === 'svg') {\n return 'image/svg+xml'\n }\n return contentType\n}\n","export function getLocationId(depth = 0): string {\n const err = new Error()\n if (!err.stack) return ''\n\n const stackLine = err.stack.split('\\n')[depth + 2]\n\n return stackLine.trim()\n}\n","import { EventSourceParserStream } from 'eventsource-parser/stream'\nimport { KeqResolveWithMode, unwrap } from '~/context'\n\n\nexport async function resolveWith<T>(response: Response, mode: Exclude<KeqResolveWithMode, 'intelligent'>): Promise<T> {\n if (mode === 'response') return response.clone() as T\n if (mode === 'text') return await response.text() as T\n if (mode === 'json') return unwrap(await response.json()) as T\n if (mode === 'form-data') return await response.formData() as T\n if (mode === 'blob') return await response.blob() as T\n if (mode === 'array-buffer') return await response.arrayBuffer() as T\n if (mode === 'sse') {\n if (!response.body) return response.body as T\n\n return response.clone().body!\n .pipeThrough(new TextDecoderStream())\n .pipeThrough(new EventSourceParserStream()) as T\n }\n\n return undefined as T\n}\n","import { resolveWith } from './resolve-with'\n\n\nexport async function intelligentParseResponse<T>(response?: Response): Promise<T> {\n if (!response) return undefined as T\n\n if (response.status === 204) {\n // 204: NO CONTENT\n return undefined as T\n }\n\n const contentType = response.headers.get('content-type') || ''\n try {\n if (contentType.match(/^application\\/(.+\\+)?json/)) {\n return resolveWith<T>(response, 'json')\n } else if (contentType.includes('multipart/form-data')) {\n return resolveWith<T>(response, 'form-data')\n } else if (contentType.includes('plain/text')) {\n return resolveWith<T>(response, 'text')\n } else if (contentType.includes('text/event-stream')) {\n return resolveWith<T>(response, 'sse')\n }\n } catch (err) {\n console.warn(`Failed to intelligent parse response body: ${response.url}`, err)\n throw err\n }\n\n /**\n * Unable to parse response body\n * Return undefined\n * Enable users to discover the problem\n * And modify the method of parsing response\n */\n return undefined as T\n}\n","\nimport { Validator } from '~/validator/index.js'\nimport { Exception } from '~/exception/index.js'\nimport { KeqBodyInit } from '~/request-init/index.js'\n\n\nexport function mergeKeqRequestBody(left: KeqBodyInit, right: KeqBodyInit): KeqBodyInit {\n if (right === undefined) return left\n\n if (typeof right === 'number') {\n throw new TypeError('Cannot set request body to a number.')\n }\n\n if (\n left === null\n || right === null\n || Validator.isBuffer(right)\n || Validator.isArrayBuffer(right)\n || Validator.isBlob(right)\n || Validator.isReadableStream(right)\n || Validator.isBuffer(left)\n || Validator.isArrayBuffer(left)\n || Validator.isBlob(left)\n || Validator.isReadableStream(left)\n || Array.isArray(left)\n || Array.isArray(right)\n || (typeof left !== 'object' && left !== undefined)\n || typeof right !== 'object'\n ) {\n return Array.isArray(right) ? [...right] : right\n }\n\n const result = left || {}\n\n if (Validator.isUrlSearchParams(right)) {\n const keys = right.keys()\n for (const key of keys) {\n const values = right.getAll(key)\n if (values.length === 1) {\n result[key] = values[0]\n } else if (values.length > 1) {\n result[key] = values\n }\n }\n } else if (Validator.isFormData(right)) {\n const keys = right.keys()\n for (const key of keys) {\n const values = right.getAll(key)\n if (values.length === 1) {\n result[key] = values[0]\n } else if (values.length > 1) {\n result[key] = values\n }\n }\n } else if (typeof right === 'object') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const key in (right as any)) {\n result[key] = right[key]\n }\n } else {\n throw new Exception(`Not support request body type: ${typeof right}`)\n }\n\n return result\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport qs, { IStringifyOptions } from 'qs'\nimport { KeqQueryObject, KeqQueryOptions, KeqQueryValue } from '../types'\n\nfunction normalize(value: KeqQueryValue, options?: KeqQueryOptions): KeqQueryValue {\n if (Array.isArray(value)) {\n return value.map((v) => normalize(v, options))\n }\n\n if (typeof value === 'bigint') {\n return value.toString()\n }\n\n if (typeof value === 'object' && value !== null) {\n const obj = { ...value }\n for (const key of Object.keys(obj)) {\n obj[key] = normalize(obj[key], options)\n }\n\n return obj\n }\n\n\n return value\n}\n\nexport function queryStringify(query: KeqQueryObject, options?: KeqQueryOptions): string {\n const value = normalize(query, options)\n\n const opts: IStringifyOptions = {}\n\n\n if (options?.allowDots !== undefined) {\n opts.allowDots = options.allowDots\n // if (options.encodeDotInKeys !== undefined) {\n // opts.encodeDotInKeys = options.encodeDotInKeys as any\n // }\n }\n\n if (options?.indices !== undefined) {\n opts.indices = options.indices\n }\n\n if (options?.arrayFormat === 'pipe') {\n opts.filter = (_, val) => {\n if (Array.isArray(val)) return val.join('|')\n return val\n }\n } else if (options?.arrayFormat === 'space') {\n opts.filter = (_, val) => {\n if (Array.isArray(val)) return val.join(' ')\n return val\n }\n } else if (options?.arrayFormat) {\n opts.arrayFormat = options.arrayFormat\n }\n\n return qs.stringify(value, opts)\n}\n","import { KeqEvents, KeqGlobal, KeqListeners, KeqMiddlewareOptionsParameter, KeqMiddlewareOptionsReturnType, unwrap } from '~/context/index.js'\nimport { Exception, RequestException } from '~/exception/index.js'\nimport { sleep } from '~/utils/index.js'\nimport { KeqRequestInit } from '~/request-init/index.js'\nimport { KeqSharedContext, KeqContextOptions } from '~/context/index.js'\nimport { KeqMiddlewareOrchestrator } from '~/orchestrator/index.js'\nimport { KeqMiddleware } from '~/middleware/index.js'\nimport { intelligentParseResponse, resolveWith } from './utils/index.js'\nimport { KeqDefaultOperation, KeqOperation, KeqQueryOptions } from './types/index.js'\n\n\nexport type KeqOptions = Partial<Omit<KeqRequestInit, 'url' | '__url__' | 'signal' | 'abort' | 'clone'>> & {\n locationId?: string\n global?: KeqGlobal\n qs?: KeqQueryOptions\n}\n\n/**\n * Core class that provides the foundational structure for managing middlewares, events, and request execution.\n */\nexport class Core<\n OP extends KeqOperation = KeqDefaultOperation,\n RES_BODY extends KeqOperation['responseBody'] = OP['responseBody'],\n> {\n /**\n * The unique identifier of the request's location in the code\n */\n __locationId__?: string\n\n private requestPromise?: Promise<RES_BODY>\n\n protected requestInit: KeqRequestInit\n\n protected __listeners__: KeqListeners = {}\n\n protected __global__: Record<string, any>\n protected __prepend_middlewares__: KeqMiddleware[] = []\n protected __append_middlewares__: KeqMiddleware[] = []\n protected __qs__: KeqQueryOptions | undefined\n\n protected get __middlewares__(): KeqMiddleware[] {\n return [...this.__prepend_middlewares__, ...this.__append_middlewares__]\n }\n\n protected __options__: KeqContextOptions = {\n resolveWithFullResponse: false,\n resolveWith: 'intelligent',\n }\n\n public constructor(url: URL, options: KeqOptions) {\n this.__global__ = options.global || {}\n this.__locationId__ = options.locationId\n this.__qs__ = options.qs\n\n this.requestInit = new KeqRequestInit({\n method: 'get',\n headers: new Headers(),\n pathParameters: {},\n body: undefined,\n ...options,\n url: new URL(url.href),\n })\n }\n\n prependMiddlewares(...middlewares: KeqMiddleware[]): this {\n this.__prepend_middlewares__.push(...middlewares)\n return this\n }\n\n /**\n * Appends middlewares to the end of the middleware chain.\n * Using this method indiscriminately is discouraged;\n * prefer using `.use` to maintain predictable execution order.\n */\n appendMiddlewares(...middlewares: KeqMiddleware[]): this {\n this.__append_middlewares__.unshift(...middlewares)\n return this\n }\n\n use(...middlewares: KeqMiddleware[]): this {\n return this.prependMiddlewares(...middlewares)\n }\n\n on<K extends keyof KeqEvents>(event: K, listener: (data: KeqEvents[K]) => void): this {\n this.__listeners__[event] = this.__listeners__[event] || []\n this.__listeners__[event]!.push(listener)\n return this\n }\n\n option<K extends keyof KeqMiddlewareOptionsReturnType<OP>>(key: K, value?: KeqMiddlewareOptionsParameter[K]): KeqMiddlewareOptionsReturnType<OP>[K]\n option(key: string, value?: any): this\n option(key: string, value: any = true): this {\n this.__options__[key] = value\n return this\n }\n\n options(opts: KeqContextOptions): this {\n for (const [key, value] of Object.entries(opts)) {\n this.__options__[key] = value\n }\n return this\n }\n\n\n private buildSharedContext(): KeqSharedContext {\n const coreContext = new KeqSharedContext({\n locationId: this.__locationId__,\n request: this.requestInit,\n global: this.__global__,\n options: this.__options__,\n })\n\n for (const eventName in this.__listeners__) {\n const listeners = this.__listeners__[eventName]\n for (const listener of listeners) {\n coreContext.emitter.on(eventName as keyof KeqEvents, listener)\n }\n }\n\n return coreContext\n }\n\n private async run(): Promise<KeqSharedContext> {\n let attempt: number | undefined\n\n while (true) {\n const attemptWithDefault = attempt || 0\n const sharedContext = this.buildSharedContext()\n const orchestrator = new KeqMiddlewareOrchestrator(sharedContext, this.__middlewares__)\n\n if (attempt !== undefined) sharedContext.data.retry = { attempt }\n if (attempt && attempt >= 1) sharedContext.emitter.emit('retry', { context: sharedContext })\n\n let error: unknown = null\n\n try {\n await orchestrator.execute()\n } catch (err) {\n error = err\n }\n\n const retryOn = typeof sharedContext.options.retry?.on === 'function'\n ? sharedContext.options.retry.on\n : (attempt, error) => {\n if (error instanceof RequestException && error.retry === false) return false\n return !!error\n }\n let retryTimes = sharedContext.options.retry?.times || 0\n if (retryTimes) {\n if (retryTimes < 0) retryTimes = 0\n else if (!Number.isInteger(retryTimes)) retryTimes = Math.floor(retryTimes)\n }\n\n if (\n attemptWithDefault >= retryTimes\n || (await retryOn(attemptWithDefault, error, sharedContext)) === false\n ) {\n if (error) {\n sharedContext.emitter.emit('error', { context: sharedContext })\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw error\n }\n return sharedContext\n }\n\n const retryDelay = typeof sharedContext.options.retry?.delay === 'function'\n ? await sharedContext.options.retry.delay(attemptWithDefault, error, sharedContext)\n : sharedContext.options.retry?.delay || 0\n\n if (retryDelay) await sleep(retryDelay)\n attempt = attemptWithDefault + 1\n }\n }\n\n async end(): Promise<RES_BODY> {\n const coreContext = await this.run()\n const resolveWithMode = coreContext.options.resolveWith\n\n if (resolveWithMode === 'response') {\n // NOTE: return a clone of the response rather than the proxy response\n return coreContext.response?.clone() as RES_BODY\n }\n\n const response = coreContext.response\n\n if (!resolveWithMode || resolveWithMode === 'intelligent') {\n const output: any = coreContext.output\n if (output !== undefined) {\n return output as RES_BODY\n }\n\n return await intelligentParseResponse<RES_BODY>(response)\n }\n\n if (!response) {\n throw new Exception([\n `Unable to process the response with '${resolveWithMode}'. Possible causes:`,\n '1. The request was never initiated or sent',\n '2. The request failed before a response was received.',\n ].join('\\n'))\n }\n\n return await resolveWith(response, resolveWithMode)\n }\n\n /**\n * Attaches callbacks for the resolution and/or rejection of the Promise.\n * @param onfulfilled The callback to execute when the Promise is resolved.\n * @param onrejected The callback to execute when the Promise is rejected.\n * @returns A Promise for the completion of which ever callback is executed.\n */\n then<TResult1 = RES_BODY, TResult2 = never>(onfulfilled?: ((value: RES_BODY) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2> {\n if (!this.requestPromise) this.requestPromise = this.end()\n return this.requestPromise.then(onfulfilled, onrejected)\n }\n\n catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<RES_BODY | TResult> {\n return this.end().catch(onrejected)\n }\n\n finally(onfinally?: (() => void) | null): Promise<RES_BODY> {\n return this.end().finally(onfinally)\n }\n}\n","\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Core } from './core.js'\nimport { Exception, TypeException } from '~/exception/index.js'\nimport { Validator } from '~/validator/index.js'\nimport { KeqFlowControlOptions, KeqFlowControlMode, KeqFlowControlSignal } from '~/middlewares/index.js'\nimport { mergeKeqRequestBody, fixContentType, queryStringify } from './utils/index.js'\nimport { base64Encode } from '~/utils/index.js'\nimport { KeqBodyInit } from '~/request-init/index.js'\n\nimport type { KeqRetryOn, KeqRetryDelay, KeqResolveWithMode } from '~/context/index.js'\nimport type { CommonContentType, ShorthandContentType, KeqDefaultOperation, KeqOperation, KeqAttachableFile, KeqQueryOptions, KeqPathParameterInit, KeqQueryInit, ServerSentEvent } from './types/index.js'\nimport type { ConditionalPick, Merge, Primitive } from 'type-fest'\nimport type { LiteralKeys, StringIndexValueOf, EnabledIfStringIndex, LooseNestedObject, EnableLooseNestedLike, LooseNestedLike } from '~/types/index.js'\n\n\n/**\n * extends Core to provide a fluent API for building HTTP requests\n */\nexport class Keq<\n OP extends KeqOperation = KeqDefaultOperation,\n RES_BODY extends KeqOperation['responseBody'] = OP['responseBody'],\n REQ_PARAMS extends KeqOperation['requestParams'] = OP['requestParams'],\n REQ_QUERY extends KeqOperation['requestQuery'] = OP['requestQuery'],\n REQ_HEADERS extends KeqOperation['requestHeaders'] = OP['requestHeaders'],\n REQ_BODY extends KeqOperation['requestBody'] = OP['requestBody'],\n> extends Core<OP> {\n /**\n * Set request header\n *\n * @description 设置请求头\n */\n set(headers: Partial<REQ_HEADERS> | Headers): this\n set<T extends keyof LiteralKeys<REQ_HEADERS>>(name: T, value: LiteralKeys<REQ_HEADERS>[T]): this\n set<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_HEADERS>): this\n set<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(key: string, value: StringIndexValueOf<REQ_HEADERS> & EnabledIfStringIndex<REQ_HEADERS>): this\n set(headersOrName: Partial<REQ_HEADERS> | string | Headers, value?: string | number): this {\n if (Validator.isHeaders(headersOrName)) {\n headersOrName.forEach((value, key) => {\n this.requestInit.headers.set(key, value)\n })\n } else if (typeof headersOrName === 'string' && value) {\n if (!Validator.isHeaderValue(value)) {\n throw new Exception(`[Invalid header] Key: ${headersOrName} Value: ${value}`)\n }\n\n this.requestInit.headers.set(headersOrName, String(value))\n } else if (typeof headersOrName === 'object') {\n for (const [key, value] of Object.entries(headersOrName)) {\n if (!Validator.isHeaderValue(value)) {\n throw new Exception(`[Invalid header] Key: ${key} Value: ${String(value)}`)\n }\n\n this.requestInit.headers.set(key, String(value))\n }\n }\n return this\n }\n\n /**\n * Set request headers\n */\n headers(headers: Partial<REQ_HEADERS> | Headers): this\n headers<T extends keyof LiteralKeys<REQ_HEADERS>>(name: T, value: LiteralKeys<REQ_HEADERS>[T]): this\n headers<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_HEADERS>): this\n headers<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(key: string, value: StringIndexValueOf<REQ_HEADERS> & EnabledIfStringIndex<REQ_HEADERS>): this\n headers(headersOrName: Partial<REQ_HEADERS> | string | Headers, value?: string | number): this {\n return this.set(headersOrName as any, value as any)\n }\n\n /**\n * Set request query/searchParams\n */\n query(obj: Partial<REQ_QUERY>, options?: KeqQueryOptions): this\n query<T extends keyof LiteralKeys<REQ_QUERY>>(key: T, value: LiteralKeys<REQ_QUERY>[T], options?: KeqQueryOptions): this\n query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(key: string, obj: StringIndexValueOf<REQ_QUERY> & EnabledIfStringIndex<REQ_QUERY>, options?: KeqQueryOptions): this\n query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_QUERY>, options?: KeqQueryOptions): this\n query<O extends object>(\n arg: O\n & Partial<LooseNestedObject<REQ_QUERY, O>>\n & EnableLooseNestedLike<StringIndexValueOf<REQ_QUERY>, O>\n & EnabledIfStringIndex<REQ_QUERY>\n ): this\n query<K extends keyof REQ_QUERY, O extends object>(\n key: K,\n arg: O\n & LooseNestedLike<StringIndexValueOf<REQ_QUERY>, O>\n & EnableLooseNestedLike<StringIndexValueOf<REQ_QUERY>, O>\n & EnabledIfStringIndex<REQ_QUERY>,\n options?: KeqQueryOptions,\n ): this\n query(arg1: string | Partial<REQ_QUERY>, arg2?: KeqQueryInit | KeqQueryOptions, arg3?: KeqQueryOptions): this {\n if (Validator.isObject(arg1)) {\n const str = queryStringify(arg1, (arg2 as KeqQueryOptions) || this.__qs__)\n\n for (const [k, v] of new URLSearchParams(str).entries()) {\n for (const item of Array.isArray(v) ? v : [v]) {\n this.requestInit.url.searchParams.append(k, item)\n }\n }\n\n this.requestInit.url.search = this.requestInit.url.searchParams.toString().replace(/\\+/g, '%20')\n return this\n }\n\n if (typeof arg1 === 'string') {\n this.query({ [arg1]: arg2 } as Partial<REQ_QUERY>, arg3)\n return this\n }\n\n throw new TypeException('Invalid Arguments for .query()')\n }\n\n /**\n * Set request route params\n */\n params(params: Partial<REQ_PARAMS>): this\n params<T extends keyof LiteralKeys<REQ_PARAMS>>(key: T, value: LiteralKeys<REQ_PARAMS>[T]): this\n params<O extends { [K in keyof O]: StringIndexValueOf<REQ_PARAMS> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_PARAMS>): this\n params<O extends { [K in keyof O]: StringIndexValueOf<REQ_PARAMS> }>(key: string, value: StringIndexValueOf<REQ_PARAMS> & EnabledIfStringIndex<REQ_PARAMS>): this\n params(arg1: string | Partial<REQ_PARAMS>, arg2?: KeqPathParameterInit): this {\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n this.requestInit.pathParameters[arg1] = arg2\n } else if (typeof arg1 === 'object' && arg1 !== null) {\n for (const k of Object.keys(arg1)) {\n if (arg1[k]) this.requestInit.pathParameters[k] = arg1[k]\n }\n } else {\n throw new TypeError('Invalid Arguments for .params()')\n }\n\n return this\n }\n\n /**\n * Set request body\n */\n body(value: KeqBodyInit): this {\n this.requestInit.body = value\n return this\n }\n\n\n /**\n * Setting the Content-Type\n */\n type(contentType: ShorthandContentType): this\n type(contentType: CommonContentType): this\n type(contentType: string): this\n type(contentType: string): this {\n const type = fixContentType(contentType)\n this.set('content-type', type as any)\n return this\n }\n\n\n /**\n * Http Basic Authentication\n */\n auth(username: string, password: string): this {\n this.set('Authorization', `Basic ${base64Encode(`${username}:${password}`)}` as any)\n return this\n }\n\n private setTypeIfEmpty(contentType: ShorthandContentType): void\n private setTypeIfEmpty(contentType: CommonContentType): void\n private setTypeIfEmpty(contentType: string): void\n private setTypeIfEmpty(contentType: string): void {\n if (!this.requestInit.headers.has('Content-Type')) void this.type(contentType)\n }\n\n /**\n * set request body\n */\n send(value: Partial<REQ_BODY>): this\n send(value: KeqBodyInit): this {\n this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, value)\n\n if (Validator.isUrlSearchParams(value)) {\n this.setTypeIfEmpty('form')\n } else if (Validator.isFormData(value)) {\n this.setTypeIfEmpty('form-data')\n } else if (Validator.isBlob(value) || Validator.isReadableStream(value) || Validator.isArrayBuffer(value)) {\n // don't set content-type\n } else if (typeof value === 'object') {\n this.setTypeIfEmpty('json')\n }\n\n return this\n }\n\n\n field<T extends ConditionalPick<RES_BODY, Primitive>, K extends keyof T>(arg1: K, value: T[K]): this\n field(arg1: ConditionalPick<RES_BODY, Primitive>): this\n field(arg1: string, value: string | string[]): this\n field(arg1: Record<string, string>): this\n field(arg1: string | Record<string, string>, arg2?: any): this {\n if (typeof arg1 === 'object') {\n this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, arg1)\n } else if (arg2) {\n this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, { [arg1]: arg2 })\n } else {\n throw new TypeException('Invalid arguments for .field()')\n }\n\n this.setTypeIfEmpty('form-data')\n return this\n }\n\n\n attach<T extends keyof ConditionalPick<REQ_BODY, KeqAttachableFile>>(key: T, value: KeqAttachableFile, filename: string): this\n attach<T extends keyof ConditionalPick<REQ_BODY, KeqAttachableFile>>(key: T, value: KeqAttachableFile | KeqAttachableFile[]): this\n attach(key: string, value: KeqAttachableFile, filename: string): this\n attach(key: string, value: KeqAttachableFile | KeqAttachableFile[]): this\n attach(key: string, value: KeqAttachableFile | KeqAttachableFile[], arg3 = 'file'): this {\n const formData = new FormData()\n\n const appendFile = (file: KeqAttachableFile): void => {\n if (Validator.isBlob(file)) {\n formData.append(key, file, arg3)\n } else if (Validator.isFile(file)) {\n formData.append(key, file)\n } else if (Validator.isBuffer(file)) {\n formData.append(key, new Blob([file as any]), arg3)\n } else {\n throw new TypeException('Invalid file type for .attach()')\n }\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) {\n throw new TypeException('Empty array provided to .attach() is not valid')\n }\n\n for (const item of value) {\n appendFile(item)\n }\n } else {\n appendFile(value)\n }\n\n const files = formData.getAll(key)\n\n this.requestInit.body = mergeKeqRequestBody(\n this.requestInit.body,\n {\n [key]: files.length === 1 ? files[0] : files,\n },\n )\n\n this.setTypeIfEmpty('form-data')\n return this\n }\n\n /**\n *\n * @param retryTimes Max number of retries per call\n * @param retryDelay Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)\n * @param retryCallback Will be called after request failed\n */\n retry(retryTimes: number, retryDelay: KeqRetryDelay = 0, retryOn: KeqRetryOn = (attempt, error) => !!error): this {\n this.option('retry', {\n times: retryTimes,\n delay: retryDelay,\n on: retryOn,\n })\n\n return this\n }\n\n\n redirect(mod: RequestRedirect): this {\n this.requestInit.redirect = mod\n return this\n }\n\n credentials(mod: RequestCredentials): this {\n this.requestInit.credentials = mod\n return this\n }\n\n mode(mod: RequestMode): this {\n this.requestInit.mode = mod\n return this\n }\n\n flowControl(mode: KeqFlowControlMode, signal?: KeqFlowControlSignal): this {\n const sig = signal ? signal : this.__locationId__\n\n if (!sig) {\n throw new Exception('please set signal to .flowControl()')\n }\n\n const flowControl: KeqFlowControlOptions = {\n mode,\n signal: sig,\n }\n\n this.option('flowControl', flowControl)\n return this\n }\n\n timeout(milliseconds: number): this {\n this.option('timeout', { millisecond: milliseconds })\n return this\n }\n\n resolveWith(m: 'response'): Keq<Merge<OP, { responseBody: Response }>>\n resolveWith(m: 'array-buffer'): Keq<Merge<OP, { responseBody: ArrayBuffer }>>\n resolveWith(m: 'blob'): Keq<Merge<OP, { responseBody: Blob }>>\n resolveWith(m: 'text'): Keq<Merge<OP, { responseBody: string }>>\n resolveWith(m: 'sse'): Keq<Merge<OP, { responseBody: ReadableStream<ServerSentEvent> }>>\n resolveWith<T = any>(m: 'json' | 'form-data'): Keq<Merge<OP, { responseBody: T }>>\n resolveWith(m: KeqResolveWithMode | any): any {\n this.option('resolveWith', m)\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this as any\n }\n}\n","/* eslint-disable @typescript-eslint/await-thenable */\nimport { Exception } from '../../exception/exception.js'\nimport { KeqRoute } from '../types/keq-route.js'\n\n\nexport function composeRoute(routes: KeqRoute[]): KeqRoute {\n if (!routes.length) {\n throw new Exception('At least one route')\n }\n\n return async (ctx) => {\n const results = await Promise.all(routes.map((route) => route(ctx)))\n return results.every((result) => result === true)\n }\n}\n","import type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport function keqHostRoute(host: string): KeqRoute {\n return (ctx) => ctx.request.url.host === host\n}\n","import { Validator } from '../validator/index.js'\n\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\nexport function keqLocationRoute(): KeqRoute {\n return (ctx) => Validator.isBrowser() && ctx.request.url.host === window.location.host\n}\n","import type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport function keqMethodRoute(method): KeqRoute {\n return (ctx) => ctx.request.method.toLowerCase() === method.toLowerCase()\n}\n","import { Exception } from '../exception/exception.js'\n\nimport type { KeqRoute } from './types/keq-route.js'\n\n\nexport function keqModuleRoute(moduleName: string): KeqRoute {\n if (!moduleName) {\n throw new Exception('Module name should not be empty')\n }\n\n return (ctx) => ctx.options.module?.name === moduleName\n}\n","import * as m from 'minimatch'\n\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\nexport function keqPathnameRoute(pathname: string): KeqRoute {\n return (ctx) => {\n // TODO: minimatch will cause each request to consume an additional 1-2ms.\n return m.minimatch(ctx.request.url.pathname, pathname)\n }\n}\n","import { TypeException } from '~/exception/type.exception.js'\nimport { keqHostRoute } from './keq-host-route.js'\nimport { keqLocationRoute } from './keq-location-route.js'\nimport { keqMethodRoute } from './keq-method-route.js'\nimport { keqModuleRoute } from './keq-module-route.js'\nimport { keqPathnameRoute } from './keq-pathname-route.js'\nimport { composeMiddleware, getMiddlewareName } from '~/middleware/index.js'\n\nimport type { KeqMiddleware } from '~/middleware/index.js'\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport class KeqRouter {\n constructor(\n private readonly middlewares: KeqMiddleware[] = [],\n ) { }\n\n private buildMiddleware(route: KeqRoute, middlewares: KeqMiddleware[]): KeqMiddleware {\n if (middlewares.length === 0) {\n throw new TypeException('At least one middleware is required to build a route middleware')\n }\n\n const composedMiddleware = middlewares.length > 1 ? composeMiddleware(middlewares) : middlewares[0]\n\n const middleware: KeqMiddleware = async function router(ctx, next) {\n if (route(ctx)) await composedMiddleware(ctx, next)\n else await next()\n }\n\n return middleware\n }\n\n route(route: KeqRoute, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(route, middlewares)\n middleware.__keqMiddlewareName__ = `route(${route.__keqRouteName__ || route.name}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n host(host: string, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqHostRoute(host), middlewares)\n middleware.__keqMiddlewareName__ = `host(${JSON.stringify(host)}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n method(method: string, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqMethodRoute(method), middlewares)\n middleware.__keqMiddlewareName__ = `method(${JSON.stringify(method)}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n pathname(pathname: string, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqPathnameRoute(pathname), middlewares)\n middleware.__keqMiddlewareName__ = `pathname(${JSON.stringify(pathname)}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n location(...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqLocationRoute(), middlewares)\n middleware.__keqMiddlewareName__ = `location(${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n\n module(moduleName: string, ...middlewares: KeqMiddleware[]): this {\n const middleware = this.buildMiddleware(keqModuleRoute(moduleName), middlewares)\n middleware.__keqMiddlewareName__ = `module(${JSON.stringify(moduleName)}, ${middlewares.map(getMiddlewareName).join(', ')})`\n this.middlewares.push(middleware)\n return this\n }\n}\n","import { TimeoutException } from '~/exception/index.js'\nimport { KeqMiddleware } from '~/middleware/types/index.js'\n\nexport interface KeqTimeoutOptions {\n millisecond: number\n}\n\nexport function keqTimeoutMiddleware(): KeqMiddleware {\n return async function timeoutMiddleware(ctx, next) {\n if (!ctx.options.timeout || ctx.options.timeout.millisecond <= 0) {\n await next()\n return\n }\n\n const millisecond = ctx.options.timeout.millisecond\n ctx.emitter.on('fetch:after', ({ context }) => {\n setTimeout(\n () => {\n const err = new TimeoutException(`keq request timeout(${millisecond}ms)`)\n context.request.abort(err)\n context.emitter.emit('timeout', { context })\n },\n millisecond,\n )\n })\n\n await next()\n }\n}\n","import type { queueAsPromised } from 'fastq'\nimport * as fastq from 'fastq'\nimport type { KeqMiddleware, KeqNext } from '~/middleware/types/index.js'\n\n\nexport function keqSerialFlowControlMiddleware(): KeqMiddleware {\n return async function serialFlowControlMiddleware(ctx, next) {\n if (!ctx.options.flowControl || ctx.options.flowControl.mode !== 'serial') {\n await next()\n return\n }\n\n const { signal } = ctx.options.flowControl\n\n const key = typeof signal === 'string' ? signal : signal(ctx)\n\n if (!ctx.global.serialFlowControl) ctx.global.serialFlowControl = {}\n\n if (!ctx.global.serialFlowControl[key]) {\n ctx.global.serialFlowControl[key] = fastq.promise(async (next: KeqNext) => {\n await next()\n }, 1)\n }\n\n const queue: queueAsPromised<KeqNext> = ctx.global.serialFlowControl[key]\n await queue.push(next)\n }\n}\n","import { AbortException } from '~/exception/index.js'\nimport { KeqMiddleware } from '~/middleware/types/index.js'\n\n\nexport function keqAbortFlowControlMiddleware(): KeqMiddleware {\n return async function abortFlowControlMiddleware(ctx, next) {\n if (!ctx.options.flowControl || ctx.options.flowControl.mode !== 'abort') {\n await next()\n return\n }\n\n const { signal } = ctx.options.flowControl\n\n const key = typeof signal === 'string' ? signal : signal(ctx)\n\n\n if (!ctx.global.abortFlowControl) ctx.global.abortFlowControl = {}\n\n const abort = ctx.global.abortFlowControl[key]\n\n if (abort) {\n const reason = new AbortException(`Previous request was aborted by AbortFlowControl with key \"${key}\"`)\n abort(reason)\n }\n\n const fn = ctx.request.abort.bind(ctx.request)\n ctx.global.abortFlowControl[key] = fn\n\n try {\n await next()\n } finally {\n if (ctx.global.abortFlowControl[key] === fn) {\n ctx.global.abortFlowControl[key] = undefined\n }\n }\n }\n}\n","import { keqSerialFlowControlMiddleware } from './serial-flow-control-middleware'\nimport { keqAbortFlowControlMiddleware } from './abort-flow-control-middleware'\nimport { KeqMiddleware } from '~/middleware/types'\nimport { composeMiddleware } from '~/middleware/utils'\n\nexport * from './types/keq-flow-control.js'\n\n\nexport function keqFlowControlMiddleware(): KeqMiddleware {\n return composeMiddleware(\n [keqSerialFlowControlMiddleware(), keqAbortFlowControlMiddleware()],\n { name: 'flowControlMiddleware' },\n )\n}\n","import { KeqExecutionContext } from '~/context/execution-context.js'\nimport { KeqMiddleware } from '~/middleware/types/index.js'\n\n/**\n * Send Request\n */\nexport function keqFetchMiddleware(): KeqMiddleware {\n return async function fetchMiddleware(context: KeqExecutionContext) {\n const fetch = context.options.fetchAPI || globalThis.fetch\n\n context.emitter.emit('fetch:before', { context })\n const response = await fetch(...context.request.toFetchArguments())\n context.emitter.emit('fetch:after', { context })\n\n context.res = response\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { KeqGlobal } from '~/context'\nimport { Keq } from './keq'\nimport { KeqApiSchema, KeqDefaultOperation, KeqQueryOptions } from './types'\nimport { getLocationId } from './utils'\nimport { KeqMiddleware } from '~/middleware'\nimport { Validator } from '~/validator'\nimport { KeqRequestInit, KeqRequestMethod } from '~/request-init'\nimport { ExtractMethodOperations } from './types'\nimport { KeqRouter } from '~/router'\nimport { keqFetchMiddleware, keqFlowControlMiddleware, keqTimeoutMiddleware } from '~/middlewares'\n\n\nexport interface KeqRequestOptions {\n preMiddlewares?: KeqMiddleware[]\n\n /**\n * Append middlewares to the end of the middleware chain.\n * Using this option indiscriminately is discouraged.\n */\n postMiddlewares?: KeqMiddleware[]\n\n baseOrigin?: string\n qs?: KeqQueryOptions\n}\n\nexport type KeqRequestFetchOptions<M extends KeqRequestMethod = KeqRequestMethod> = Partial<Omit<KeqRequestInit, 'url' | '__url__' | 'signal' | 'abort' | 'clone' | 'toFetchArguments' | 'method'>> & {\n method: M\n}\n\n/**\n * Keq instance factory class,\n * and shares global data and middlewares across requests\n */\nexport class KeqRequest<SCHEMA extends KeqApiSchema = KeqApiSchema> {\n baseOrigin: string\n qs?: KeqQueryOptions\n\n /**\n * share data between requests, used to implement flowControl\n * @description 跨请求共享数据,用于实现 flowControl的功能\n */\n readonly global: KeqGlobal = {}\n\n readonly preMiddlewares: KeqMiddleware[] = []\n readonly postMiddlewares: KeqMiddleware[] = []\n\n constructor(options?: KeqRequestOptions) {\n if (options?.baseOrigin) {\n this.baseOrigin = options.baseOrigin\n } else {\n this.baseOrigin = Validator.isBrowser() ? location.origin : 'http://127.0.0.1'\n }\n\n this.qs = options?.qs\n\n this.postMiddlewares = options?.postMiddlewares || [\n keqFlowControlMiddleware(),\n keqTimeoutMiddleware(),\n keqFetchMiddleware(),\n ]\n this.preMiddlewares = options?.preMiddlewares || []\n }\n\n private __formatUrl__(url: string | URL): URL {\n if (typeof url === 'string') {\n return new URL(url, this.baseOrigin)\n }\n\n return new URL(url.href)\n }\n\n private __fetch__(\n url: string | URL,\n init: KeqRequestFetchOptions,\n locationId?: string,\n ): Keq<any> {\n const keq = new Keq(this.__formatUrl__(url), { ...init, locationId, global: this.global, qs: this.qs })\n\n keq.appendMiddlewares(...this.postMiddlewares)\n keq.prependMiddlewares(...this.preMiddlewares)\n return keq as Keq<any>\n }\n\n\n fetch<P extends keyof SCHEMA, M extends KeqRequestMethod>(url: P, init: KeqRequestFetchOptions<M>): Keq<Exclude<SCHEMA[P][M], undefined>>\n fetch<T = unknown>(url: string | URL, init: KeqRequestFetchOptions): Keq<KeqDefaultOperation<{ responseBody: T }>>\n fetch(url: string | URL, init: KeqRequestFetchOptions): Keq<any> {\n return this.__fetch__(\n url,\n init,\n getLocationId(1),\n )\n }\n\n get<P extends keyof ExtractMethodOperations<SCHEMA, 'get'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'get'>[P], ExtractMethodOperations<SCHEMA, 'get'>[P]>\n get<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n get(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'get' },\n getLocationId(1),\n )\n }\n\n put<P extends keyof ExtractMethodOperations<SCHEMA, 'put'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'put'>[P], ExtractMethodOperations<SCHEMA, 'put'>[P]>\n put<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n put(url: string | URL): Keq<any> {\n const locationId = getLocationId(1)\n const keq = new Keq(\n this.__formatUrl__(url),\n {\n method: 'put',\n locationId,\n global: this.global,\n },\n )\n\n keq.appendMiddlewares(...this.postMiddlewares)\n keq.prependMiddlewares(...this.preMiddlewares)\n return keq\n }\n\n delete<P extends keyof ExtractMethodOperations<SCHEMA, 'delete'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'delete'>[P], ExtractMethodOperations<SCHEMA, 'delete'>[P]>\n delete<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n delete(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'delete' },\n getLocationId(1),\n )\n }\n\n del<P extends keyof ExtractMethodOperations<SCHEMA, 'delete'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'delete'>[P], ExtractMethodOperations<SCHEMA, 'delete'>[P]>\n del<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n del(url: string | URL): Keq<any> {\n return this.delete(url)\n }\n\n post<P extends keyof ExtractMethodOperations<SCHEMA, 'post'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'post'>[P], ExtractMethodOperations<SCHEMA, 'post'>[P]>\n post<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n post(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'post' },\n getLocationId(1),\n )\n }\n\n head<P extends keyof ExtractMethodOperations<SCHEMA, 'head'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'head'>[P], ExtractMethodOperations<SCHEMA, 'head'>[P]>\n head<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n head(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'head' },\n getLocationId(1),\n )\n }\n\n patch<P extends keyof ExtractMethodOperations<SCHEMA, 'patch'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'patch'>[P], ExtractMethodOperations<SCHEMA, 'patch'>[P]>\n patch<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n patch(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'patch' },\n getLocationId(1),\n )\n }\n\n options<P extends keyof ExtractMethodOperations<SCHEMA, 'options'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'options'>[P], ExtractMethodOperations<SCHEMA, 'options'>[P]>\n options<T>(url: string | URL): Keq<KeqDefaultOperation<{ responseBody: T }>>\n options(url: string | URL): Keq<any> {\n return this.__fetch__(\n url,\n { method: 'options' },\n getLocationId(1),\n )\n }\n\n use(firstMiddleware: KeqMiddleware, ...middleware: KeqMiddleware[]): this {\n this.preMiddlewares.push(firstMiddleware, ...middleware)\n return this\n }\n\n useRouter(): KeqRouter {\n return new KeqRouter(this.preMiddlewares)\n }\n}\n\nexport const request = new KeqRequest()\n","import { KeqApiSchema } from './types'\nimport { KeqRequest, KeqRequestOptions } from './request'\n\n\n/**\n * @deprecated use new KeqRequest<SCHEMA>(options) instead\n */\nexport function createRequest<SCHEMA extends KeqApiSchema>(options?: KeqRequestOptions): KeqRequest<SCHEMA> {\n return new KeqRequest<SCHEMA>(options)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,6BAA4B;AAErB,IAAM,YAAN,cAAwB,mCAAY;AAAA,EACzC,YAAY,SAAkB;AAC5B,UAAM,OAAO;AAEb,WAAO,eAAe,MAAM,QAAQ,EAAE,OAAO,WAAW,CAAC;AAAA,EAC3D;AACF;;;ACLO,IAAM,gBAAN,cAA4B,UAAU;AAAA,EAC3C,YAAY,KAAc;AACxB,UAAM,OAAO,cAAc;AAAA,EAC7B;AACF;;;ACPO,IAAM,iBAAN,MAAM,wBAAuB,aAAa;AAAA,EAC/C,YAAY,KAAa;AACvB,UAAM,KAAK,YAAY;AACvB,WAAO,eAAe,MAAM,gBAAe,SAAS;AAAA,EACtD;AACF;;;ACFO,IAAM,mBAAN,cAA+B,eAAe;AAAA,EACnD,YAAY,KAAa;AACvB,UAAM,GAAG;AAAA,EACX;AACF;;;ACJO,IAAM,mBAAN,cAA+B,UAAU;AAAA,EAI9C,YAAY,YAAoB,SAAkB,QAAQ,MAAM;AAC9D,UAAM,OAAO;AAJf;AACA;AAKE,SAAK,aAAa;AAClB,SAAK,QAAQ;AAEb,WAAO,eAAe,MAAM,QAAQ,EAAE,OAA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AClC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,EAAE,QAAQ,SAAS;AAAA,MACnB,cAAc,CAAC;AAAA,IACjB;AAAA,EACF;AAAA,EAIA,IAAI,KAA6B;AAC/B,WAAO,KAAK,OAAO,GAAG;AAAA,EACxB;AAAA,EAIA,KAAK,KAA6B;AAChC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,EAAE,QAAQ,OAAO;AAAA,MACjB,cAAc,CAAC;AAAA,IACjB;AAAA,EACF;AAAA,EAIA,KAAK,KAA6B;AAChC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,EAAE,QAAQ,OAAO;AAAA,MACjB,cAAc,CAAC;AAAA,IACjB;AAAA,EACF;AAAA,EAIA,MAAM,KAA6B;AACjC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,EAAE,QAAQ,QAAQ;AAAA,MAClB,cAAc,CAAC;AAAA,IACjB;AAAA,EACF;AAAA,EAIA,QAAQ,KAA6B;AACnC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,EAAE,QAAQ,UAAU;AAAA,MACpB,cAAc,CAAC;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,IAAI,oBAAmC,YAAmC;AACxE,SAAK,eAAe,KAAK,iBAAiB,GAAG,UAAU;AACvD,WAAO;AAAA,EACT;AAAA,EAEA,YAAuB;AACrB,WAAO,IAAI,UAAU,KAAK,cAAc;AAAA,EAC1C;AACF;AAEO,IAAM,UAAU,IAAI,WAAW;;;ACtL/B,SAAS,cAA2C,SAAiD;AAC1G,SAAO,IAAI,WAAmB,OAAO;AACvC;","names":["_a","_a","_b","target","_a","_b","mitt","ExecutorProperty","_a","qs","_a","_b","_c","_d","attempt","error","value","m","_a","next"]}