keq 5.2.2 → 5.3.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["ExecutorProperty","klona","klona"],"sources":["../src/exception/exception.ts","../src/exception/type.exception.ts","../src/exception/abort.exception.ts","../src/exception/timeout.exception.ts","../src/exception/mutex.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/utils/watch-object.ts","../src/context/utils/clone-shared-context.ts","../src/context/utils/fork.ts","../src/context/utils/create-proxy-response.ts","../src/context/shared-context.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/router/utils/build-route.ts","../src/router/utils/not-route.ts","../src/router/utils/or-route.ts","../src/router/keq-middleware-applicator.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/mutex-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":["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 MutexException extends Exception {\n constructor(message: string) {\n super(message)\n\n Object.defineProperty(this, 'name', { value: 'MutexException' })\n }\n}\n","import { Exception } from '../exception.js'\n\n\nexport interface RequestExceptionOptions {\n // disable retry for this exception\n fatal?: boolean\n\n // proxy response object\n response?: Response\n}\n\nexport class RequestException extends Exception {\n statusCode: number | string\n fatal: boolean\n response?: Response\n\n /** @deprecated Use `fatal` instead. `retry === true` is equivalent to `fatal === false`. */\n get retry(): boolean {\n return !this.fatal\n }\n\n /** @deprecated Pass `RequestExceptionOptions` instead. `retry: true` maps to `{ fatal: false }`. */\n constructor(statusCode: number | string, message: string, retry: boolean)\n constructor(statusCode: number | string, message?: string, options?: RequestExceptionOptions)\n constructor(statusCode: number | string, message?: string, options?: boolean | RequestExceptionOptions) {\n super(message)\n\n if (typeof options === 'boolean') {\n options = { fatal: !options }\n }\n\n this.statusCode = statusCode\n this.fatal = options?.fatal ?? false\n this.response = options?.response\n\n Object.defineProperty(this, 'name', { value: 'RequestException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class BadRequestException extends RequestException {\n constructor(message: string = 'Bad Request', options?: RequestExceptionOptions) {\n super(400, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'BadRequestException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class UnauthorizedException extends RequestException {\n constructor(message: string = 'Unauthorized', options?: RequestExceptionOptions) {\n super(401, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'UnauthorizedException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ForbiddenException extends RequestException {\n constructor(message: string = 'Forbidden', options?: RequestExceptionOptions) {\n super(403, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'ForbiddenException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class NotFoundedException extends RequestException {\n constructor(message: string = 'Not Founded', options?: RequestExceptionOptions) {\n super(404, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'NotFoundedException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class MethodNotAllowedException extends RequestException {\n constructor(message: string = 'Method Not Allowed', options?: RequestExceptionOptions) {\n super(405, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'MethodNotAllowedException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class NotAcceptableException extends RequestException {\n constructor(message: string = 'Not Acceptable', options?: RequestExceptionOptions) {\n super(406, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'NotAcceptableException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ProxyAuthenticationRequiredException extends RequestException {\n constructor(message: string = 'Proxy Authentication Required', options?: RequestExceptionOptions) {\n super(407, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'ProxyAuthenticationRequiredException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class RequestTimeoutException extends RequestException {\n constructor(message: string = 'Request Timeout', options?: RequestExceptionOptions) {\n super(408, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'RequestTimeoutException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ConflictException extends RequestException {\n constructor(message: string = 'Conflict', options?: RequestExceptionOptions) {\n super(409, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'ConflictException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class PreconditionFailedException extends RequestException {\n constructor(message: string = 'Precondition Failed', options?: RequestExceptionOptions) {\n super(412, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'PreconditionFailedException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ContentTooLargeException extends RequestException {\n constructor(message: string = 'Content Too Large', options?: RequestExceptionOptions) {\n super(413, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'ContentTooLargeException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class UriTooLongException extends RequestException {\n constructor(message: string = 'URI Too Long', options?: RequestExceptionOptions) {\n super(414, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'UriTooLongException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class UnsupportedMediaTypeException extends RequestException {\n constructor(message: string = 'Unsupported Media Type', options?: RequestExceptionOptions) {\n super(415, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'UnsupportedMediaTypeException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ImATeapotException extends RequestException {\n constructor(message: string = \"I'm a teapot\", options?: RequestExceptionOptions) {\n super(418, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'ImATeapotException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class TooManyRequestsException extends RequestException {\n constructor(message: string = 'Too Many Requests', options?: RequestExceptionOptions) {\n super(429, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', { value: 'TooManyRequestsException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class InternalServerErrorException extends RequestException {\n constructor(message: string = 'Internal Server Error', options?: RequestExceptionOptions) {\n super(500, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'InternalServerErrorException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class NotImplementedException extends RequestException {\n constructor(message: string = 'Not Implemented', options?: RequestExceptionOptions) {\n super(501, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'NotImplementedException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class BadGatewayException extends RequestException {\n constructor(message: string = 'Bad Gateway', options?: RequestExceptionOptions) {\n super(502, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', { value: 'BadGatewayException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ServiceUnavailableException extends RequestException {\n constructor(message: string = 'Service Unavailable', options?: RequestExceptionOptions) {\n super(503, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'ServiceUnavailableException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class GatewayTimeoutException extends RequestException {\n constructor(message: string = 'Gateway Timeout', options?: RequestExceptionOptions) {\n super(504, message, { fatal: false, ...options })\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 = '__KeqProtectedProperty(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 = '__KeyProtectedProperty(context.orchestration.orchestrator)__'\nconst ExecutorProperty = '__KeyProtectedProperty(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 = '__KeyProtectedProperty(context.orchestrator)__'\nexport const ContextOrchestrationProperty = '__KeyProtectedProperty(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","/* 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 ForkedObjectBrandPropertyKey = '__KeqProtectedProperty(forked.object.brand)__'\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 const getTarget = (): any => objectPath(current, path)\n\n return new Proxy(getTarget(), {\n get(target, prop) {\n const realTarget = getTarget()\n if (prop === ForkedObjectBrandPropertyKey) return realTarget\n\n const value = realTarget[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(realTarget) && 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(target, prop, value) {\n ensureCopy()\n objectPath(current, path)[prop] = value\n return true\n },\n\n deleteProperty(target, prop) {\n ensureCopy()\n delete objectPath(current, path)[prop]\n return true\n },\n\n ownKeys(target) {\n const realTarget = getTarget()\n return Reflect.ownKeys(realTarget)\n },\n\n getOwnPropertyDescriptor(target, prop) {\n const realTarget = getTarget()\n return Reflect.getOwnPropertyDescriptor(realTarget, prop)\n },\n })\n }\n\n return createProxy()\n}\n\nexport function unwrap<T>(proxy: T): T {\n return proxy && (proxy as any)[ForkedObjectBrandPropertyKey] ? (proxy as any)[ForkedObjectBrandPropertyKey] : proxy\n}\n","import { fork } from './fork'\n\nconst JsonCachePropertyKey = '__KeqProtectedProperty(response.proxy.cache.json)__'\nconst TextCachePropertyKey = '__KeqProtectedProperty(response.proxy.cache.text)__'\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 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 = '__KeqProtectedProperty(context.locationId)__'\nexport const ContextRequestProperty = '__KeqProtectedProperty(context.request)__'\nexport const ContextGlobalProperty = '__KeqProtectedProperty(context.global)__'\nexport const ContextEmitterProperty = '__KeqProtectedProperty(context.emitter)__'\nexport const ContextOptionsProperty = '__KeqProtectedProperty(context.options)__'\nexport const ContextDataProperty = '__KeqProtectedProperty(context.data)__'\nexport const ContextOutputProperty = '__KeqProtectedProperty(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 /** @deprecated Use `locationId` instead */\n get identifier(): 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","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 = '__KeyProtectedProperty(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\ninterface KeqMiddlewareOrchestratorPointer {\n orchestrator: KeqMiddlewareOrchestrator\n index: number\n}\n\nexport type KeqMiddlewareOrchestratorStatus = 'idle' | 'pending' | 'fulfilled' | 'rejected'\n\nexport class KeqMiddlewareOrchestrator {\n main?: KeqMiddlewareOrchestratorPointer\n\n status: KeqMiddlewareOrchestratorStatus = 'idle'\n context: KeqSharedContext\n executors: KeqMiddlewareExecutor[] = []\n\n current: number = -1\n\n constructor(\n context: KeqSharedContext,\n middlewares: KeqMiddleware[] = [],\n inherit?: {\n main?: KeqMiddlewareOrchestratorPointer\n },\n ) {\n this.context = context\n this.executors = middlewares.map((mw) => new KeqMiddlewareExecutor(mw))\n\n if (inherit?.main) this.main = inherit.main\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 main: {\n orchestrator: this.main ? this.main.orchestrator : this,\n index: this.main ? this.main.index + next : next,\n },\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 lines = err.stack.split('\\n')\n const offset = depth + 2\n\n if (lines[offset]) return lines[offset].trim()\n\n // JavaScriptCore (iOS Safari) may omit stack frames across async/await\n // resume and tail-call boundaries, so `lines[offset]` can be out of range.\n // Fall back to the deepest non-empty frame instead of crashing on `.trim()`.\n for (let i = lines.length - 1; i >= 0; i--) {\n const line = lines[i].trim()\n if (line) return line\n }\n\n return ''\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.startsWith('text/') && !contentType.includes('text/event-stream')) {\n return resolveWith<T>(response, 'text')\n } else if (contentType.includes('text/event-stream')) {\n return resolveWith<T>(response, 'sse')\n } else if (\n contentType.startsWith('image/')\n || contentType.startsWith('audio/')\n || contentType.startsWith('video/')\n || contentType.startsWith('font/')\n || contentType === 'application/octet-stream'\n || contentType === 'application/pdf'\n ) {\n return resolveWith<T>(response, 'array-buffer')\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'\nimport { klona } from 'klona/json'\n\n\nexport type KeqOptions = Partial<Omit<KeqRequestInit, 'url' | '__url__' | 'signal' | 'abort' | 'clone'>> & {\n locationId?: string\n global?: KeqGlobal\n qs?: KeqQueryOptions\n middlewares?: KeqMiddleware[]\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> extends Promise<RES_BODY> {\n /**\n * Ensures `.then()`, `.catch()`, `.finally()` return plain Promise instances instead of Core/Keq instances.\n */\n static get [Symbol.species](): PromiseConstructor {\n return Promise\n }\n\n /**\n * The unique identifier of the request's location in the code\n */\n __locationId__?: string\n\n /** Deferred resolve callback captured from the Promise executor. */\n private __resolve__!: (value: RES_BODY | PromiseLike<RES_BODY>) => void\n /** Deferred reject callback captured from the Promise executor. */\n private __reject__!: (reason: unknown) => void\n /** Whether the request has been lazily triggered by `.then()`. */\n private __triggered__ = false\n /** Cached promise for idempotent `end()` calls. */\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 let resolve!: (value: RES_BODY | PromiseLike<RES_BODY>) => void\n let reject!: (reason: unknown) => void\n super((res, rej) => {\n resolve = res\n reject = rej\n })\n this.__resolve__ = resolve\n this.__reject__ = reject\n\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 if (options.middlewares) {\n this.__append_middlewares__.push(...options.middlewares)\n }\n }\n\n use(...middlewares: KeqMiddleware[]): this {\n this.__prepend_middlewares__.push(...middlewares)\n return this\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 derive(): this {\n const derived = new (this.constructor as new (url: URL, options: KeqOptions) => this)(\n this.requestInit.url,\n {\n method: this.requestInit.method,\n headers: this.requestInit.headers,\n body: this.requestInit.body,\n pathParameters: this.requestInit.pathParameters,\n cache: this.requestInit.cache,\n credentials: this.requestInit.credentials,\n integrity: this.requestInit.integrity,\n keepalive: this.requestInit.keepalive,\n mode: this.requestInit.mode,\n redirect: this.requestInit.redirect,\n referrer: this.requestInit.referrer,\n referrerPolicy: this.requestInit.referrerPolicy,\n locationId: this.__locationId__,\n global: this.__global__,\n qs: this.__qs__ ? { ...this.__qs__ } : undefined,\n middlewares: [...this.__append_middlewares__],\n },\n )\n\n derived.__prepend_middlewares__ = [...this.__prepend_middlewares__]\n\n derived.__listeners__ = {}\n for (const key in this.__listeners__) {\n derived.__listeners__[key] = [...this.__listeners__[key]!]\n }\n\n derived.__options__ = klona(this.__options__)\n\n return derived\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.fatal) 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 private __execute__(): Promise<RES_BODY> {\n if (!this.__requestPromise__) {\n this.__requestPromise__ = (async () => {\n const coreContext = await this.run()\n const resolveWithMode = coreContext.options.resolveWith\n\n if (resolveWithMode === '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 return this.__requestPromise__\n }\n\n fire(): void {\n if (!this.__triggered__) {\n this.__triggered__ = true\n this.__execute__().then(this.__resolve__, this.__reject__)\n }\n }\n\n /** @deprecated Await the Keq instance directly or use `.fire()` for fire-and-forget. */\n end(): Promise<RES_BODY> {\n if (!this.__triggered__) {\n this.__triggered__ = true\n this.__execute__().then(this.__resolve__, this.__reject__)\n }\n return new Promise<RES_BODY>((resolve, reject) => {\n super.then(resolve, reject)\n })\n }\n\n override then<TResult1 = RES_BODY, TResult2 = never>(\n onfulfilled?: ((value: RES_BODY) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null,\n ): Promise<TResult1 | TResult2> {\n if (!this.__triggered__) {\n this.__triggered__ = true\n this.__execute__().then(this.__resolve__, this.__reject__)\n }\n return super.then(onfulfilled, onrejected)\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, Primitive } from 'type-fest'\nimport type { Override } from '~/types/index.js'\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 /**\n * The following two overloads handle flat (non-nested) query params\n * with arbitrary key names when REQ_QUERY has a string index signature (`[key: string]: ...`).\n * Values must be directly assignable to the string index value type — no nested objects.\n *\n * @example\n * ```ts\n * // Given REQ_QUERY = { [key: string]: string }\n * request.query('customKey', 'value')\n * request.query({ customKey: 'value', anotherKey: 'value2' })\n * ```\n */\n query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(key: string, obj: (StringIndexValueOf<REQ_QUERY> & EnabledIfStringIndex<REQ_QUERY>) | undefined, options?: KeqQueryOptions): this\n query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_QUERY>, options?: KeqQueryOptions): this\n /**\n * The following two overloads handle nested object query params\n * when REQ_QUERY has a string index signature (`[key: string]: ...`).\n * Every leaf value in the nested object must be assignable to the string index value type of REQ_QUERY.\n *\n * @example\n * ```ts\n * // Given REQ_QUERY = { [key: string]: string }\n * request.query({ filter: { status: 'active', tags: ['a', 'b'] } })\n * request.query('filter', { status: 'active', tags: ['a', 'b'] })\n * ```\n */\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>) | undefined,\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> | ConditionalPick<RES_BODY, Primitive>, 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: 'concurrent', limit: number, signal?: KeqFlowControlSignal): this\n flowControl(mode: 'serial', signal?: KeqFlowControlSignal): this\n flowControl(mode: 'abort', signal?: KeqFlowControlSignal): this\n flowControl(mode: 'mutex', signal?: KeqFlowControlSignal): this\n flowControl(mode: KeqFlowControlMode, arg2?: KeqFlowControlSignal | number, arg3?: KeqFlowControlSignal): this {\n const concurrencyLimit = typeof arg2 === 'number' ? arg2 : undefined\n const sig = (typeof arg2 === 'function' || typeof arg2 === 'string')\n ? arg2\n : arg3 && (typeof arg3 === 'function' || typeof arg3 === 'string')\n ? arg3\n : this.__locationId__\n\n if (!sig) {\n throw new Exception('please set signal to .flowControl()')\n }\n\n const flowControl: KeqFlowControlOptions = {\n mode,\n concurrencyLimit,\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<Override<OP, { responseBody: Response }>>\n resolveWith(m: 'array-buffer'): Keq<Override<OP, { responseBody: ArrayBuffer }>>\n resolveWith(m: 'blob'): Keq<Override<OP, { responseBody: Blob }>>\n resolveWith(m: 'text'): Keq<Override<OP, { responseBody: string }>>\n resolveWith(m: 'sse'): Keq<Override<OP, { responseBody: ReadableStream<ServerSentEvent> }>>\n resolveWith<T = any>(m: 'json' | 'form-data'): Keq<Override<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\n/**\n * @deprecated This function exists solely for backward compatibility with v2.\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 picomatch from 'picomatch'\n\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\nexport function keqPathnameRoute(pathname: string): KeqRoute {\n const isMatch = picomatch(pathname)\n return (ctx) => {\n return isMatch(ctx.request.url.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\n/**\n * @deprecated Use `request.apply(...middlewares).forRoutes(...)` instead.\n */\nexport class KeqRouter {\n constructor(\n private readonly middlewares: KeqMiddleware[] = [],\n ) { }\n\n private static 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, middleware: KeqMiddleware[]): this\n route(route: KeqRoute, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n route(route: KeqRoute, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.route(route, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n host(host: string, middleware: KeqMiddleware[]): this\n host(host: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n host(host: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.host(host, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n method(method: string, middleware: KeqMiddleware[]): this\n method(method: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n method(method: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.method(method, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n pathname(pathname: string, middleware: KeqMiddleware[]): this\n pathname(pathname: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n pathname(pathname: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.pathname(pathname, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n location(middleware: KeqMiddleware[]): this\n location(middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n location(middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.location(middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n /**\n * @deprecated This method exists solely for backward compatibility with v2.\n */\n module(moduleName: string, middleware: KeqMiddleware[]): this\n module(moduleName: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n module(moduleName: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.module(moduleName, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n static route(route: KeqRoute, middleware: KeqMiddleware[]): KeqMiddleware\n static route(route: KeqRoute, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static route(route: KeqRoute, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(route, list)\n mid.__keqMiddlewareName__ = `route(${route.__keqRouteName__ || route.name}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n\n static host(host: string, middleware: KeqMiddleware[]): KeqMiddleware\n static host(host: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static host(host: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqHostRoute(host), list)\n mid.__keqMiddlewareName__ = `host(${JSON.stringify(host)}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n static method(method: string, middleware: KeqMiddleware[]): KeqMiddleware\n static method(method: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static method(method: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqMethodRoute(method), list)\n mid.__keqMiddlewareName__ = `method(${JSON.stringify(method)}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n\n static pathname(pathname: string, middleware: KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static pathname(pathname: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static pathname(pathname: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqPathnameRoute(pathname), list)\n mid.__keqMiddlewareName__ = `pathname(${JSON.stringify(pathname)}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n static location(middleware: KeqMiddleware[]): KeqMiddleware\n static location(middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static location(middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqLocationRoute(), list)\n mid.__keqMiddlewareName__ = `location(${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n /**\n * @deprecated This method exists solely for backward compatibility with v2.\n */\n static module(moduleName: string, middleware: KeqMiddleware[]): KeqMiddleware\n static module(moduleName: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static module(moduleName: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqModuleRoute(moduleName), list)\n mid.__keqMiddlewareName__ = `module(${JSON.stringify(moduleName)}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n}\n","import { keqHostRoute } from '~/router/keq-host-route.js'\nimport { keqMethodRoute } from '~/router/keq-method-route.js'\nimport { keqPathnameRoute } from '~/router/keq-pathname-route.js'\nimport { composeRoute } from './compose-route.js'\n\nimport type { KeqRoute } from '~/router/types/keq-route.js'\nimport type { KeqRoutePattern } from '~/router/types/keq-route-pattern.js'\n\n\nexport function buildRoute(pattern: KeqRoutePattern): KeqRoute {\n const routes: KeqRoute[] = []\n\n if (pattern.host) routes.push(keqHostRoute(pattern.host))\n if (pattern.method) routes.push(keqMethodRoute(pattern.method))\n if (pattern.pathname) routes.push(keqPathnameRoute(pattern.pathname))\n\n if (routes.length === 0) {\n const always: KeqRoute = () => true\n always.__keqRouteName__ = 'always'\n return always\n }\n\n if (routes.length === 1) return routes[0]\n return composeRoute(routes)\n}\n","import type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport function notRoute(route: KeqRoute): KeqRoute {\n const negated: KeqRoute = async (ctx) => !(await route(ctx))\n negated.__keqRouteName__ = `not(${route.__keqRouteName__ || route.name || 'anonymous'})`\n return negated\n}\n","import { Exception } from '~/exception/exception.js'\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport function orRoute(routes: KeqRoute[]): KeqRoute {\n if (!routes.length) {\n throw new Exception('At least one route')\n }\n\n const combined: KeqRoute = async (ctx) => {\n const results = await Promise.all(routes.map((route) => route(ctx)))\n return results.some((result) => result === true)\n }\n\n combined.__keqRouteName__ = `or(${routes.map((r) => r.__keqRouteName__ || r.name || 'anonymous').join(', ')})`\n return combined\n}\n","import { composeMiddleware } from '~/middleware/index.js'\nimport { buildRoute } from './utils/build-route.js'\nimport { composeRoute } from './utils/compose-route.js'\nimport { notRoute } from './utils/not-route.js'\nimport { orRoute } from './utils/or-route.js'\n\nimport type { KeqMiddleware } from '~/middleware/index.js'\nimport type { KeqRoute } from './types/keq-route.js'\nimport type { KeqRoutePattern } from './types/keq-route-pattern.js'\n\n\nexport type KeqRouteTarget = KeqRoutePattern | KeqRoute\n\nfunction normalizeTarget(target: KeqRouteTarget): KeqRoute {\n if (typeof target === 'function') return target\n return buildRoute(target)\n}\n\nexport class KeqMiddlewareApplicator<TReturn> {\n private readonly excludedTargets: KeqRouteTarget[] = []\n\n constructor(\n private readonly middlewares: KeqMiddleware[],\n private readonly registeredMiddlewares: KeqMiddleware[],\n private readonly returnValue: TReturn,\n ) {}\n\n exclude(...routes: KeqRouteTarget[]): this {\n this.excludedTargets.push(...routes)\n return this\n }\n\n forRoutes(...routes: KeqRouteTarget[]): TReturn {\n const inclusionRoutes = routes.map(normalizeTarget)\n const inclusionRoute = inclusionRoutes.length === 1\n ? inclusionRoutes[0]\n : orRoute(inclusionRoutes)\n\n let finalRoute: KeqRoute\n if (this.excludedTargets.length > 0) {\n const exclusionRoutes = this.excludedTargets.map(normalizeTarget)\n const exclusionRoute = exclusionRoutes.length === 1\n ? exclusionRoutes[0]\n : orRoute(exclusionRoutes)\n finalRoute = composeRoute([inclusionRoute, notRoute(exclusionRoute)])\n } else {\n finalRoute = inclusionRoute\n }\n\n const composedMiddleware = this.middlewares.length > 1\n ? composeMiddleware(this.middlewares)\n : this.middlewares[0]\n\n const routeMiddleware: KeqMiddleware = async function routeApply(ctx, next) {\n if (await finalRoute(ctx)) await composedMiddleware(ctx, next)\n else await next()\n }\n\n this.registeredMiddlewares.push(routeMiddleware)\n return this.returnValue\n }\n\n forAllRoutes(): TReturn {\n const composedMiddleware = this.middlewares.length > 1\n ? composeMiddleware(this.middlewares)\n : this.middlewares[0]\n\n if (this.excludedTargets.length > 0) {\n const exclusionRoutes = this.excludedTargets.map(normalizeTarget)\n const exclusionRoute = exclusionRoutes.length === 1\n ? exclusionRoutes[0]\n : orRoute(exclusionRoutes)\n const finalRoute = notRoute(exclusionRoute)\n\n const routeMiddleware: KeqMiddleware = async function routeApply(ctx, next) {\n if (await finalRoute(ctx)) await composedMiddleware(ctx, next)\n else await next()\n }\n\n this.registeredMiddlewares.push(routeMiddleware)\n } else {\n this.registeredMiddlewares.push(composedMiddleware)\n }\n\n return this.returnValue\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 let timer: ReturnType<typeof setTimeout> | undefined\n\n ctx.emitter.on('fetch:before', ({ context }) => {\n timer = setTimeout(() => {\n const err = new TimeoutException(`keq request timeout(${millisecond}ms)`)\n context.request.abort(err)\n context.emitter.emit('timeout', { context })\n }, millisecond)\n })\n\n ctx.emitter.on('fetch:after', () => {\n if (timer !== undefined) {\n clearTimeout(timer)\n timer = undefined\n }\n })\n\n await next()\n }\n}\n","import * as fastq from 'fastq'\nimport { KeqGlobal } from '~/context'\nimport type { KeqMiddleware } from '~/middleware/types/index.js'\n\n\nexport function keqSerialFlowControlMiddleware(): KeqMiddleware {\n return async function serialFlowControlMiddleware(ctx, next) {\n if (!ctx.options.flowControl || !['serial', 'concurrent'].includes(ctx.options.flowControl.mode)) {\n await next()\n return\n }\n\n const { signal } = ctx.options.flowControl\n const concurrent = ctx.options.flowControl.mode === 'serial'\n ? 1\n : !ctx.options.flowControl.concurrencyLimit || ctx.options.flowControl.concurrencyLimit < 1\n ? 1\n : Math.floor(ctx.options.flowControl.concurrencyLimit)\n\n const key = typeof signal === 'string' ? signal : signal(ctx)\n\n if (!ctx.global.core) ctx.global.core = {}\n if (!ctx.global.core.serialFlowControl) ctx.global.core.serialFlowControl = {}\n\n if (!ctx.global.core.serialFlowControl[key]) {\n ctx.global.core.serialFlowControl[key] = fastq.promise(async ({ next }) => {\n await next()\n }, concurrent)\n }\n\n const queue: Required<Required<KeqGlobal>['core']>['serialFlowControl'][string] = ctx.global.core.serialFlowControl[key]\n\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.core) ctx.global.core = {}\n if (!ctx.global.core.abortFlowControl) ctx.global.core.abortFlowControl = {}\n\n const abort = ctx.global.core.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.core.abortFlowControl[key] = fn\n\n try {\n await next()\n } finally {\n if (ctx.global.core.abortFlowControl[key] === fn) {\n ctx.global.core.abortFlowControl[key] = undefined\n }\n }\n }\n}\n","import { MutexException } from '~/exception/index.js'\nimport { KeqMiddleware } from '~/middleware/types/index.js'\n\n\nexport function keqMutexFlowControlMiddleware(): KeqMiddleware {\n return async function mutexFlowControlMiddleware(ctx, next) {\n if (!ctx.options.flowControl || ctx.options.flowControl.mode !== 'mutex') {\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.core) ctx.global.core = {}\n if (!ctx.global.core.mutexFlowControl) ctx.global.core.mutexFlowControl = new Set()\n\n if (ctx.global.core.mutexFlowControl.has(key)) {\n throw new MutexException(`Request rejected by MutexFlowControl: a request with key \"${key}\" is already in-flight`)\n }\n\n ctx.global.core.mutexFlowControl.add(key)\n\n try {\n await next()\n } finally {\n ctx.global.core.mutexFlowControl.delete(key)\n }\n }\n}\n","import { keqSerialFlowControlMiddleware } from './serial-flow-control-middleware'\nimport { keqAbortFlowControlMiddleware } from './abort-flow-control-middleware'\nimport { keqMutexFlowControlMiddleware } from './mutex-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 [keqMutexFlowControlMiddleware(), 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 { KeqEvents, 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 { KeqMiddlewareApplicator } from '~/router/keq-middleware-applicator'\nimport { keqFetchMiddleware, keqFlowControlMiddleware, keqTimeoutMiddleware } from '~/middlewares'\n\n\nexport interface KeqRequestOptions {\n middlewares?: KeqMiddleware[]\n terminalMiddlewares?: KeqMiddleware[]\n baseOrigin?: string\n qs?: KeqQueryOptions\n}\n\nexport interface KeqRequestForkOptions {\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 middlewares: KeqMiddleware[] = []\n private readonly __terminalMiddlewares__: KeqMiddleware[] = []\n private __parent__?: KeqRequest\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.__terminalMiddlewares__ = options?.terminalMiddlewares || [\n keqFlowControlMiddleware(),\n keqTimeoutMiddleware(),\n keqFetchMiddleware(),\n ]\n this.middlewares = options?.middlewares || []\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 resolveMiddlewares(): KeqMiddleware[] {\n if (!this.__parent__) {\n return this.middlewares\n }\n return [...this.__parent__.resolveMiddlewares(), ...this.middlewares]\n }\n\n private __fetch__(\n url: string | URL,\n init: KeqRequestFetchOptions,\n locationId?: string,\n ): Keq<any> {\n const keq = new Keq(\n this.__formatUrl__(url),\n {\n ...init, locationId,\n global: this.global,\n qs: this.qs,\n middlewares: [\n ...this.resolveMiddlewares(),\n ...this.__terminalMiddlewares__,\n ],\n })\n\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 return this.__fetch__(\n url,\n { method: 'put' },\n getLocationId(1),\n )\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.middlewares.push(firstMiddleware, ...middleware)\n return this\n }\n\n apply(middleware: KeqMiddleware[]): KeqMiddlewareApplicator<this>\n apply(middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddlewareApplicator<this>\n apply(middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddlewareApplicator<this> {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n return new KeqMiddlewareApplicator(list, this.middlewares, this)\n }\n\n /**\n * @deprecated Use `request.apply(...middlewares).forRoutes(...)` instead.\n */\n useRouter(): KeqRouter {\n return new KeqRouter(this.middlewares)\n }\n\n fork(options?: KeqRequestForkOptions): KeqRequest {\n const child = new KeqRequest({\n baseOrigin: options?.baseOrigin ?? this.baseOrigin,\n qs: options?.qs ?? (this.qs ? { ...this.qs } : undefined),\n })\n child.__parent__ = this\n return child\n }\n\n inherit(parent: KeqRequest): this {\n this.__parent__ = parent\n return this\n }\n\n adopt(child: KeqRequest): this {\n child.__parent__ = this\n return this\n }\n\n /** @deprecated Use `middlewares` instead */\n get preMiddlewares(): KeqMiddleware[] {\n return this.middlewares\n }\n\n on<K extends keyof KeqEvents>(event: K, listener: (data: KeqEvents[K]) => void): this {\n const middleware: KeqMiddleware = async (context, next) => {\n context.emitter.on(event, listener)\n await next()\n }\n\n middleware.__keqMiddlewareName__ = `listen(${event}, ${listener.name || 'anonymous'})`\n\n this.use(middleware)\n\n return this\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":";;;;;;;;;;AAEA,IAAa,YAAb,cAA+B,YAAY;CACzC,YAAY,SAAkB;AAC5B,QAAM,QAAQ;AAEd,SAAO,eAAe,MAAM,QAAQ,EAAE,OAAO,YAAY,CAAC;;;;;ACH9D,IAAa,gBAAb,cAAmC,UAAU;CAC3C,YAAY,KAAc;AACxB,QAAM,OAAO,eAAe;;;;;ACLhC,IAAa,iBAAb,MAAa,uBAAuB,aAAa;CAC/C,YAAY,KAAa;AACvB,QAAM,KAAK,aAAa;AACxB,SAAO,eAAe,MAAM,eAAe,UAAU;;;;;ACAzD,IAAa,mBAAb,cAAsC,eAAe;CACnD,YAAY,KAAa;AACvB,QAAM,IAAI;;;;;ACFd,IAAa,iBAAb,cAAoC,UAAU;CAC5C,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AAEd,SAAO,eAAe,MAAM,QAAQ,EAAE,OAAO,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACIpE,IAAa,mBAAb,cAAsC,UAAU;;CAM9C,IAAI,QAAiB;AACnB,SAAO,CAAC,KAAK;;CAMf,YAAY,YAA6B,SAAkB,SAA6C;AACtG,QAAM,QAAQ;wBAbhB,cAAA,KAAA,EAA2B;wBAC3B,SAAA,KAAA,EAAc;wBACd,YAAA,KAAA,EAAmB;AAajB,MAAI,OAAO,YAAY,UACrB,WAAU,EAAE,OAAO,CAAC,SAAS;AAG/B,OAAK,aAAa;AAClB,OAAK,QAAQ,SAAS,SAAS;AAC/B,OAAK,WAAW,SAAS;AAEzB,SAAO,eAAe,MAAM,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AAa,KAAK;;;;;CAMlE,YAAuB;AACrB,SAAO,IAAI,UAAU,KAAK,YAAY;;CAGxC,KAAK,SAA6C;EAChD,MAAM,QAAQ,IAAI,WAAW;GAC3B,YAAY,SAAS,cAAc,KAAK;GACxC,IAAI,SAAS,OAAO,KAAK,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,KAAA;GAChD,CAAC;AACF,QAAM,aAAa;AACnB,SAAO;;CAGT,QAAQ,QAA0B;AAChC,OAAK,aAAa;AAClB,SAAO;;CAGT,MAAM,OAAyB;AAC7B,QAAM,aAAa;AACnB,SAAO;;;CAIT,IAAI,iBAAkC;AACpC,SAAO,KAAK;;CAGd,GAA8B,OAAU,UAA8C;EACpF,MAAM,aAA4B,OAAO,SAAS,SAAS;AACzD,WAAQ,QAAQ,GAAG,OAAO,SAAS;AACnC,SAAM,MAAM;;AAGd,aAAW,wBAAwB,UAAU,MAAM,IAAI,SAAS,QAAQ,YAAY;AAEpF,OAAK,IAAI,WAAW;AAEpB,SAAO;;;AAIX,MAAa,UAAU,IAAI,YAAY;;;;;;AC7OvC,SAAgB,cAA2C,SAAiD;AAC1G,QAAO,IAAI,WAAmB,QAAQ"}
1
+ {"version":3,"file":"index.mjs","names":["ExecutorProperty","klona","klona"],"sources":["../src/exception/exception.ts","../src/exception/type.exception.ts","../src/exception/abort.exception.ts","../src/exception/timeout.exception.ts","../src/exception/mutex.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/validator/validator.ts","../src/utils/shallow-clone.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/utils/watch-object.ts","../src/context/utils/clone-shared-context.ts","../src/context/utils/fork.ts","../src/context/utils/create-proxy-response.ts","../src/context/shared-context.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/utils/base64.ts","../src/utils/semaphore.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/router/utils/build-route.ts","../src/router/utils/not-route.ts","../src/router/utils/or-route.ts","../src/router/keq-middleware-applicator.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/mutex-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":["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 MutexException extends Exception {\n constructor(message: string) {\n super(message)\n\n Object.defineProperty(this, 'name', { value: 'MutexException' })\n }\n}\n","import { Exception } from '../exception.js'\n\n\nexport interface RequestExceptionOptions {\n // disable retry for this exception\n fatal?: boolean\n\n // proxy response object\n response?: Response\n}\n\nexport class RequestException extends Exception {\n statusCode: number | string\n fatal: boolean\n response?: Response\n\n /** @deprecated Use `fatal` instead. `retry === true` is equivalent to `fatal === false`. */\n get retry(): boolean {\n return !this.fatal\n }\n\n /** @deprecated Pass `RequestExceptionOptions` instead. `retry: true` maps to `{ fatal: false }`. */\n constructor(statusCode: number | string, message: string, retry: boolean)\n constructor(statusCode: number | string, message?: string, options?: RequestExceptionOptions)\n constructor(statusCode: number | string, message?: string, options?: boolean | RequestExceptionOptions) {\n super(message)\n\n if (typeof options === 'boolean') {\n options = { fatal: !options }\n }\n\n this.statusCode = statusCode\n this.fatal = options?.fatal ?? false\n this.response = options?.response\n\n Object.defineProperty(this, 'name', { value: 'RequestException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class BadRequestException extends RequestException {\n constructor(message: string = 'Bad Request', options?: RequestExceptionOptions) {\n super(400, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'BadRequestException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class UnauthorizedException extends RequestException {\n constructor(message: string = 'Unauthorized', options?: RequestExceptionOptions) {\n super(401, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'UnauthorizedException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ForbiddenException extends RequestException {\n constructor(message: string = 'Forbidden', options?: RequestExceptionOptions) {\n super(403, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'ForbiddenException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class NotFoundedException extends RequestException {\n constructor(message: string = 'Not Founded', options?: RequestExceptionOptions) {\n super(404, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'NotFoundedException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class MethodNotAllowedException extends RequestException {\n constructor(message: string = 'Method Not Allowed', options?: RequestExceptionOptions) {\n super(405, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'MethodNotAllowedException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class NotAcceptableException extends RequestException {\n constructor(message: string = 'Not Acceptable', options?: RequestExceptionOptions) {\n super(406, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'NotAcceptableException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ProxyAuthenticationRequiredException extends RequestException {\n constructor(message: string = 'Proxy Authentication Required', options?: RequestExceptionOptions) {\n super(407, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'ProxyAuthenticationRequiredException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class RequestTimeoutException extends RequestException {\n constructor(message: string = 'Request Timeout', options?: RequestExceptionOptions) {\n super(408, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'RequestTimeoutException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ConflictException extends RequestException {\n constructor(message: string = 'Conflict', options?: RequestExceptionOptions) {\n super(409, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'ConflictException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class PreconditionFailedException extends RequestException {\n constructor(message: string = 'Precondition Failed', options?: RequestExceptionOptions) {\n super(412, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'PreconditionFailedException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ContentTooLargeException extends RequestException {\n constructor(message: string = 'Content Too Large', options?: RequestExceptionOptions) {\n super(413, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'ContentTooLargeException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class UriTooLongException extends RequestException {\n constructor(message: string = 'URI Too Long', options?: RequestExceptionOptions) {\n super(414, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'UriTooLongException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class UnsupportedMediaTypeException extends RequestException {\n constructor(message: string = 'Unsupported Media Type', options?: RequestExceptionOptions) {\n super(415, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'UnsupportedMediaTypeException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ImATeapotException extends RequestException {\n constructor(message: string = \"I'm a teapot\", options?: RequestExceptionOptions) {\n super(418, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'ImATeapotException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class TooManyRequestsException extends RequestException {\n constructor(message: string = 'Too Many Requests', options?: RequestExceptionOptions) {\n super(429, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', { value: 'TooManyRequestsException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class InternalServerErrorException extends RequestException {\n constructor(message: string = 'Internal Server Error', options?: RequestExceptionOptions) {\n super(500, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'InternalServerErrorException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class NotImplementedException extends RequestException {\n constructor(message: string = 'Not Implemented', options?: RequestExceptionOptions) {\n super(501, message, { fatal: true, ...options })\n\n Object.defineProperty(this, 'name', { value: 'NotImplementedException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class BadGatewayException extends RequestException {\n constructor(message: string = 'Bad Gateway', options?: RequestExceptionOptions) {\n super(502, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', { value: 'BadGatewayException' })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\n\nexport class ServiceUnavailableException extends RequestException {\n constructor(message: string = 'Service Unavailable', options?: RequestExceptionOptions) {\n super(503, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', {\n value: 'ServiceUnavailableException',\n })\n }\n}\n","import { RequestException, RequestExceptionOptions } from './request.exception'\n\nexport class GatewayTimeoutException extends RequestException {\n constructor(message: string = 'Gateway Timeout', options?: RequestExceptionOptions) {\n super(504, message, { fatal: false, ...options })\n\n Object.defineProperty(this, 'name', { value: 'GatewayTimeoutException' })\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 * 检查是否为 AbortSignal\n */\n static isAbortSignal(obj: any): obj is AbortSignal {\n if (typeof AbortSignal !== 'undefined' && obj instanceof AbortSignal) return true\n\n return (\n Validator.isObject(obj)\n && typeof obj['aborted'] === 'boolean'\n && Validator.isFunction(obj['addEventListener'])\n && Validator.isFunction(obj['removeEventListener'])\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","/* 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 = '__KeqProtectedProperty(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 = '__KeyProtectedProperty(context.orchestration.orchestrator)__'\nconst ExecutorProperty = '__KeyProtectedProperty(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 = '__KeyProtectedProperty(context.orchestrator)__'\nexport const ContextOrchestrationProperty = '__KeyProtectedProperty(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","/* 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 ForkedObjectBrandPropertyKey = '__KeqProtectedProperty(forked.object.brand)__'\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 const getTarget = (): any => objectPath(current, path)\n\n return new Proxy(getTarget(), {\n get(target, prop) {\n const realTarget = getTarget()\n if (prop === ForkedObjectBrandPropertyKey) return realTarget\n\n const value = realTarget[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(realTarget) && 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(target, prop, value) {\n ensureCopy()\n objectPath(current, path)[prop] = value\n return true\n },\n\n deleteProperty(target, prop) {\n ensureCopy()\n delete objectPath(current, path)[prop]\n return true\n },\n\n ownKeys(target) {\n const realTarget = getTarget()\n return Reflect.ownKeys(realTarget)\n },\n\n getOwnPropertyDescriptor(target, prop) {\n const realTarget = getTarget()\n return Reflect.getOwnPropertyDescriptor(realTarget, prop)\n },\n })\n }\n\n return createProxy()\n}\n\nexport function unwrap<T>(proxy: T): T {\n return proxy && (proxy as any)[ForkedObjectBrandPropertyKey] ? (proxy as any)[ForkedObjectBrandPropertyKey] : proxy\n}\n","import { fork } from './fork'\n\nconst JsonCachePropertyKey = '__KeqProtectedProperty(response.proxy.cache.json)__'\nconst TextCachePropertyKey = '__KeqProtectedProperty(response.proxy.cache.text)__'\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 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 = '__KeqProtectedProperty(context.locationId)__'\nexport const ContextRequestProperty = '__KeqProtectedProperty(context.request)__'\nexport const ContextGlobalProperty = '__KeqProtectedProperty(context.global)__'\nexport const ContextEmitterProperty = '__KeqProtectedProperty(context.emitter)__'\nexport const ContextOptionsProperty = '__KeqProtectedProperty(context.options)__'\nexport const ContextDataProperty = '__KeqProtectedProperty(context.data)__'\nexport const ContextOutputProperty = '__KeqProtectedProperty(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 /** @deprecated Use `locationId` instead */\n get identifier(): 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","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 = '__KeyProtectedProperty(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\ninterface KeqMiddlewareOrchestratorPointer {\n orchestrator: KeqMiddlewareOrchestrator\n index: number\n}\n\nexport type KeqMiddlewareOrchestratorStatus = 'idle' | 'pending' | 'fulfilled' | 'rejected'\n\nexport class KeqMiddlewareOrchestrator {\n main?: KeqMiddlewareOrchestratorPointer\n\n status: KeqMiddlewareOrchestratorStatus = 'idle'\n context: KeqSharedContext\n executors: KeqMiddlewareExecutor[] = []\n\n current: number = -1\n\n constructor(\n context: KeqSharedContext,\n middlewares: KeqMiddleware[] = [],\n inherit?: {\n main?: KeqMiddlewareOrchestratorPointer\n },\n ) {\n this.context = context\n this.executors = middlewares.map((mw) => new KeqMiddlewareExecutor(mw))\n\n if (inherit?.main) this.main = inherit.main\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 main: {\n orchestrator: this.main ? this.main.orchestrator : this,\n index: this.main ? this.main.index + next : next,\n },\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 lines = err.stack.split('\\n')\n const offset = depth + 2\n\n if (lines[offset]) return lines[offset].trim()\n\n // JavaScriptCore (iOS Safari) may omit stack frames across async/await\n // resume and tail-call boundaries, so `lines[offset]` can be out of range.\n // Fall back to the deepest non-empty frame instead of crashing on `.trim()`.\n for (let i = lines.length - 1; i >= 0; i--) {\n const line = lines[i].trim()\n if (line) return line\n }\n\n return ''\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.startsWith('text/') && !contentType.includes('text/event-stream')) {\n return resolveWith<T>(response, 'text')\n } else if (contentType.includes('text/event-stream')) {\n return resolveWith<T>(response, 'sse')\n } else if (\n contentType.startsWith('image/')\n || contentType.startsWith('audio/')\n || contentType.startsWith('video/')\n || contentType.startsWith('font/')\n || contentType === 'application/octet-stream'\n || contentType === 'application/pdf'\n ) {\n return resolveWith<T>(response, 'array-buffer')\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 { AbortException, Exception, RequestException, TypeException } from '~/exception/index.js'\nimport { Validator } from '~/validator/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'\nimport { klona } from 'klona/json'\n\n\nexport type KeqOptions = Partial<Omit<KeqRequestInit, 'url' | '__url__' | 'signal' | 'abort' | 'clone'>> & {\n locationId?: string\n global?: KeqGlobal\n qs?: KeqQueryOptions\n middlewares?: KeqMiddleware[]\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> extends Promise<RES_BODY> {\n /**\n * Ensures `.then()`, `.catch()`, `.finally()` return plain Promise instances instead of Core/Keq instances.\n */\n static get [Symbol.species](): PromiseConstructor {\n return Promise\n }\n\n /**\n * The unique identifier of the request's location in the code\n */\n __locationId__?: string\n\n /** Deferred resolve callback captured from the Promise executor. */\n private __resolve__!: (value: RES_BODY | PromiseLike<RES_BODY>) => void\n /** Deferred reject callback captured from the Promise executor. */\n private __reject__!: (reason: unknown) => void\n /** Whether the request has been lazily triggered by `.then()`. */\n private __triggered__ = false\n /** Cached promise for idempotent `end()` calls. */\n private __requestPromise__?: Promise<RES_BODY>\n\n /** Whether `abort()` has been called on this request. */\n private __aborted__ = false\n /** The reason passed to `abort()`. */\n private __abortReason__: any\n /** The shared context of the running attempt, used to abort the in-flight fetch. */\n private __activeSharedContext__?: KeqSharedContext\n /** Resolves as soon as `abort()` is called, used to interrupt retry delays. */\n private __resolveAbort__!: (reason: any) => void\n private __abortPromise__: Promise<any> = new Promise((resolve) => {\n this.__resolveAbort__ = resolve\n })\n\n /** Cleanup callbacks registered by `abortWhen()`. */\n private __abortWhenCleanups__: (() => void)[] = []\n /** Whether the request has settled (resolved or rejected). */\n private __settled__ = false\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 let resolve!: (value: RES_BODY | PromiseLike<RES_BODY>) => void\n let reject!: (reason: unknown) => void\n super((res, rej) => {\n resolve = res\n reject = rej\n })\n this.__resolve__ = resolve\n this.__reject__ = reject\n\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 if (options.middlewares) {\n this.__append_middlewares__.push(...options.middlewares)\n }\n }\n\n use(...middlewares: KeqMiddleware[]): this {\n this.__prepend_middlewares__.push(...middlewares)\n return this\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 * Abort the request manually.\n *\n * The request rejects with the given reason (an {@link AbortException} by default),\n * the `abort` event is emitted, and no further retry is performed.\n * It is safe to call `abort()` before the request is sent: the request will be\n * aborted as soon as it starts.\n *\n * @description 手动中止请求\n * @param reason Abort reason. Defaults to `new AbortException('Request aborted')`.\n */\n abort(reason: any = new AbortException('Request aborted')): void {\n if (this.__aborted__) return\n\n this.__aborted__ = true\n this.__abortReason__ = reason\n this.__resolveAbort__(reason)\n this.__activeSharedContext__?.request.abort(reason)\n this.__clearAbortWhenCleanups__()\n }\n\n /**\n * Abort the request when the given `AbortSignal` aborts,\n * or when the given `Promise` settles (resolves or rejects).\n *\n * It is designed for the normal `await` flow, so business code\n * does not need to call `.fire()` first:\n * `await request.get('/api/cats').abortWhen(signal)`.\n *\n * @description 当 signal 中止或 promise 完成时终止请求\n */\n abortWhen(source: AbortSignal | PromiseLike<unknown>): this {\n if (this.__aborted__ || this.__settled__) return this\n\n if (Validator.isAbortSignal(source)) {\n const reason = (): any => source.reason ?? new AbortException('Request aborted by AbortSignal passed to abortWhen()')\n\n if (source.aborted) {\n this.abort(reason())\n return this\n }\n\n const onAbort = (): void => this.abort(reason())\n source.addEventListener('abort', onAbort, { once: true })\n this.__abortWhenCleanups__.push(() => source.removeEventListener('abort', onAbort))\n\n return this\n }\n\n if (Validator.isObject(source) && typeof source.then === 'function') {\n const reason = new AbortException('Request aborted by Promise passed to abortWhen()')\n let cancelled = false\n this.__abortWhenCleanups__.push(() => {\n cancelled = true\n })\n\n void Promise.resolve(source).then(\n () => {\n if (!cancelled) this.abort(reason)\n },\n () => {\n if (!cancelled) this.abort(reason)\n },\n )\n\n return this\n }\n\n throw new TypeException('abortWhen() expects an AbortSignal or a Promise')\n }\n\n derive(): this {\n const derived = new (this.constructor as new (url: URL, options: KeqOptions) => this)(\n this.requestInit.url,\n {\n method: this.requestInit.method,\n headers: this.requestInit.headers,\n body: this.requestInit.body,\n pathParameters: this.requestInit.pathParameters,\n cache: this.requestInit.cache,\n credentials: this.requestInit.credentials,\n integrity: this.requestInit.integrity,\n keepalive: this.requestInit.keepalive,\n mode: this.requestInit.mode,\n redirect: this.requestInit.redirect,\n referrer: this.requestInit.referrer,\n referrerPolicy: this.requestInit.referrerPolicy,\n locationId: this.__locationId__,\n global: this.__global__,\n qs: this.__qs__ ? { ...this.__qs__ } : undefined,\n middlewares: [...this.__append_middlewares__],\n },\n )\n\n derived.__prepend_middlewares__ = [...this.__prepend_middlewares__]\n\n derived.__listeners__ = {}\n for (const key in this.__listeners__) {\n derived.__listeners__[key] = [...this.__listeners__[key]!]\n }\n\n derived.__options__ = klona(this.__options__)\n\n return derived\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 this.__activeSharedContext__ = coreContext\n\n if (this.__aborted__) {\n coreContext.request.abort(this.__abortReason__)\n }\n\n return coreContext\n }\n\n private async run(): Promise<KeqSharedContext> {\n let attempt: number | undefined\n\n try {\n while (true) {\n if (this.__aborted__ && attempt !== undefined) {\n throw this.__abortReason__\n }\n\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 if (this.__aborted__) {\n const reason = error ?? this.__abortReason__\n sharedContext.emitter.emit('error', { context: sharedContext })\n throw reason\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.fatal) 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) {\n await new Promise<void>((resolve) => {\n const timer = setTimeout(resolve, retryDelay)\n\n // The retry delay should be interrupted when the request is aborted.\n void this.__abortPromise__.then(() => {\n clearTimeout(timer)\n resolve()\n })\n })\n }\n attempt = attemptWithDefault + 1\n }\n } finally {\n this.__activeSharedContext__ = undefined\n }\n }\n\n private __execute__(): Promise<RES_BODY> {\n if (!this.__requestPromise__) {\n this.__requestPromise__ = (async () => {\n try {\n const coreContext = await this.run()\n const resolveWithMode = coreContext.options.resolveWith\n\n if (resolveWithMode === '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 } finally {\n this.__settled__ = true\n this.__clearAbortWhenCleanups__()\n }\n })()\n }\n\n return this.__requestPromise__\n }\n\n private __clearAbortWhenCleanups__(): void {\n const cleanups = this.__abortWhenCleanups__\n this.__abortWhenCleanups__ = []\n for (const cleanup of cleanups) cleanup()\n }\n\n /**\n * Trigger the request without waiting for the result.\n *\n * Returns the request instance itself, so the handler can still be used later,\n * for example `request.get('/api/cats').fire().abort()`.\n */\n fire(): this {\n if (!this.__triggered__) {\n this.__triggered__ = true\n this.__execute__().then(this.__resolve__, this.__reject__)\n }\n\n return this\n }\n\n /** @deprecated Await the Keq instance directly or use `.fire()` for fire-and-forget. */\n end(): Promise<RES_BODY> {\n if (!this.__triggered__) {\n this.__triggered__ = true\n this.__execute__().then(this.__resolve__, this.__reject__)\n }\n return new Promise<RES_BODY>((resolve, reject) => {\n super.then(resolve, reject)\n })\n }\n\n override then<TResult1 = RES_BODY, TResult2 = never>(\n onfulfilled?: ((value: RES_BODY) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null,\n ): Promise<TResult1 | TResult2> {\n if (!this.__triggered__) {\n this.__triggered__ = true\n this.__execute__().then(this.__resolve__, this.__reject__)\n }\n return super.then(onfulfilled, onrejected)\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","/**\n * Concurrency limiter that preserves the caller's async context.\n *\n * @description\n * 并发限流器。等待者 await 属于自己的 Promise,`release()` 仅负责 resolve,\n * 因此等待者在自己的 async context 中恢复 —— Node 的 AsyncLocalStorage\n * 上下文得以保留。这是它与 fastq 等「由前一个任务的完成回调驱动下一个任务」\n * 的队列实现的关键区别。\n */\nexport class Semaphore {\n private running = 0\n private readonly waiters: (() => void)[] = []\n\n constructor(private readonly concurrency: number) {\n if (!Number.isInteger(concurrency) || concurrency < 1) {\n throw new TypeError('Semaphore concurrency must be a positive integer')\n }\n }\n\n /**\n * Acquire a slot, waiting until one is released if the limit is reached.\n *\n * @description 获取一个名额。若已达并发上限,则等待直到有名额释放。\n */\n async acquire(): Promise<void> {\n if (this.running < this.concurrency) {\n this.running++\n return\n }\n\n await new Promise<void>((resolve) => {\n this.waiters.push(resolve)\n })\n }\n\n /**\n * Release a slot, handing it directly to the next waiter when one exists.\n *\n * @description 释放名额。存在等待者时直接移交名额(不减计数),否则减少计数。\n */\n release(): void {\n const waiter = this.waiters.shift()\n\n if (waiter) {\n waiter()\n } else if (this.running > 0) {\n this.running--\n }\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, Primitive } from 'type-fest'\nimport type { Override } from '~/types/index.js'\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 /**\n * The following two overloads handle flat (non-nested) query params\n * with arbitrary key names when REQ_QUERY has a string index signature (`[key: string]: ...`).\n * Values must be directly assignable to the string index value type — no nested objects.\n *\n * @example\n * ```ts\n * // Given REQ_QUERY = { [key: string]: string }\n * request.query('customKey', 'value')\n * request.query({ customKey: 'value', anotherKey: 'value2' })\n * ```\n */\n query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(key: string, obj: (StringIndexValueOf<REQ_QUERY> & EnabledIfStringIndex<REQ_QUERY>) | undefined, options?: KeqQueryOptions): this\n query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_QUERY>, options?: KeqQueryOptions): this\n /**\n * The following two overloads handle nested object query params\n * when REQ_QUERY has a string index signature (`[key: string]: ...`).\n * Every leaf value in the nested object must be assignable to the string index value type of REQ_QUERY.\n *\n * @example\n * ```ts\n * // Given REQ_QUERY = { [key: string]: string }\n * request.query({ filter: { status: 'active', tags: ['a', 'b'] } })\n * request.query('filter', { status: 'active', tags: ['a', 'b'] })\n * ```\n */\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>) | undefined,\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> | ConditionalPick<RES_BODY, Primitive>, 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: 'concurrent', limit: number, signal?: KeqFlowControlSignal): this\n flowControl(mode: 'serial', signal?: KeqFlowControlSignal): this\n flowControl(mode: 'abort', signal?: KeqFlowControlSignal): this\n flowControl(mode: 'mutex', signal?: KeqFlowControlSignal): this\n flowControl(mode: KeqFlowControlMode, arg2?: KeqFlowControlSignal | number, arg3?: KeqFlowControlSignal): this {\n const concurrencyLimit = typeof arg2 === 'number' ? arg2 : undefined\n const sig = (typeof arg2 === 'function' || typeof arg2 === 'string')\n ? arg2\n : arg3 && (typeof arg3 === 'function' || typeof arg3 === 'string')\n ? arg3\n : this.__locationId__\n\n if (!sig) {\n throw new Exception('please set signal to .flowControl()')\n }\n\n const flowControl: KeqFlowControlOptions = {\n mode,\n concurrencyLimit,\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<Override<OP, { responseBody: Response }>>\n resolveWith(m: 'array-buffer'): Keq<Override<OP, { responseBody: ArrayBuffer }>>\n resolveWith(m: 'blob'): Keq<Override<OP, { responseBody: Blob }>>\n resolveWith(m: 'text'): Keq<Override<OP, { responseBody: string }>>\n resolveWith(m: 'sse'): Keq<Override<OP, { responseBody: ReadableStream<ServerSentEvent> }>>\n resolveWith<T = any>(m: 'json' | 'form-data'): Keq<Override<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\n/**\n * @deprecated This function exists solely for backward compatibility with v2.\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 picomatch from 'picomatch'\n\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\nexport function keqPathnameRoute(pathname: string): KeqRoute {\n const isMatch = picomatch(pathname)\n return (ctx) => {\n return isMatch(ctx.request.url.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\n/**\n * @deprecated Use `request.apply(...middlewares).forRoutes(...)` instead.\n */\nexport class KeqRouter {\n constructor(\n private readonly middlewares: KeqMiddleware[] = [],\n ) { }\n\n private static 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, middleware: KeqMiddleware[]): this\n route(route: KeqRoute, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n route(route: KeqRoute, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.route(route, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n host(host: string, middleware: KeqMiddleware[]): this\n host(host: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n host(host: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.host(host, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n method(method: string, middleware: KeqMiddleware[]): this\n method(method: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n method(method: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.method(method, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n pathname(pathname: string, middleware: KeqMiddleware[]): this\n pathname(pathname: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n pathname(pathname: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.pathname(pathname, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n location(middleware: KeqMiddleware[]): this\n location(middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n location(middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.location(middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n /**\n * @deprecated This method exists solely for backward compatibility with v2.\n */\n module(moduleName: string, middleware: KeqMiddleware[]): this\n module(moduleName: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this\n module(moduleName: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): this {\n // @ts-ignore\n const mid = KeqRouter.module(moduleName, middleware, ...additionalMiddlewares)\n this.middlewares.push(mid)\n return this\n }\n\n static route(route: KeqRoute, middleware: KeqMiddleware[]): KeqMiddleware\n static route(route: KeqRoute, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static route(route: KeqRoute, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(route, list)\n mid.__keqMiddlewareName__ = `route(${route.__keqRouteName__ || route.name}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n\n static host(host: string, middleware: KeqMiddleware[]): KeqMiddleware\n static host(host: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static host(host: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqHostRoute(host), list)\n mid.__keqMiddlewareName__ = `host(${JSON.stringify(host)}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n static method(method: string, middleware: KeqMiddleware[]): KeqMiddleware\n static method(method: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static method(method: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqMethodRoute(method), list)\n mid.__keqMiddlewareName__ = `method(${JSON.stringify(method)}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n\n static pathname(pathname: string, middleware: KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static pathname(pathname: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static pathname(pathname: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqPathnameRoute(pathname), list)\n mid.__keqMiddlewareName__ = `pathname(${JSON.stringify(pathname)}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n static location(middleware: KeqMiddleware[]): KeqMiddleware\n static location(middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static location(middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqLocationRoute(), list)\n mid.__keqMiddlewareName__ = `location(${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n /**\n * @deprecated This method exists solely for backward compatibility with v2.\n */\n static module(moduleName: string, middleware: KeqMiddleware[]): KeqMiddleware\n static module(moduleName: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware\n static module(moduleName: string, middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n const mid = KeqRouter.buildMiddleware(keqModuleRoute(moduleName), list)\n mid.__keqMiddlewareName__ = `module(${JSON.stringify(moduleName)}, ${list.map(getMiddlewareName).join(', ')})`\n return mid\n }\n\n}\n","import { keqHostRoute } from '~/router/keq-host-route.js'\nimport { keqMethodRoute } from '~/router/keq-method-route.js'\nimport { keqPathnameRoute } from '~/router/keq-pathname-route.js'\nimport { composeRoute } from './compose-route.js'\n\nimport type { KeqRoute } from '~/router/types/keq-route.js'\nimport type { KeqRoutePattern } from '~/router/types/keq-route-pattern.js'\n\n\nexport function buildRoute(pattern: KeqRoutePattern): KeqRoute {\n const routes: KeqRoute[] = []\n\n if (pattern.host) routes.push(keqHostRoute(pattern.host))\n if (pattern.method) routes.push(keqMethodRoute(pattern.method))\n if (pattern.pathname) routes.push(keqPathnameRoute(pattern.pathname))\n\n if (routes.length === 0) {\n const always: KeqRoute = () => true\n always.__keqRouteName__ = 'always'\n return always\n }\n\n if (routes.length === 1) return routes[0]\n return composeRoute(routes)\n}\n","import type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport function notRoute(route: KeqRoute): KeqRoute {\n const negated: KeqRoute = async (ctx) => !(await route(ctx))\n negated.__keqRouteName__ = `not(${route.__keqRouteName__ || route.name || 'anonymous'})`\n return negated\n}\n","import { Exception } from '~/exception/exception.js'\nimport type { KeqRoute } from '~/router/types/keq-route.js'\n\n\nexport function orRoute(routes: KeqRoute[]): KeqRoute {\n if (!routes.length) {\n throw new Exception('At least one route')\n }\n\n const combined: KeqRoute = async (ctx) => {\n const results = await Promise.all(routes.map((route) => route(ctx)))\n return results.some((result) => result === true)\n }\n\n combined.__keqRouteName__ = `or(${routes.map((r) => r.__keqRouteName__ || r.name || 'anonymous').join(', ')})`\n return combined\n}\n","import { composeMiddleware } from '~/middleware/index.js'\nimport { buildRoute } from './utils/build-route.js'\nimport { composeRoute } from './utils/compose-route.js'\nimport { notRoute } from './utils/not-route.js'\nimport { orRoute } from './utils/or-route.js'\n\nimport type { KeqMiddleware } from '~/middleware/index.js'\nimport type { KeqRoute } from './types/keq-route.js'\nimport type { KeqRoutePattern } from './types/keq-route-pattern.js'\n\n\nexport type KeqRouteTarget = KeqRoutePattern | KeqRoute\n\nfunction normalizeTarget(target: KeqRouteTarget): KeqRoute {\n if (typeof target === 'function') return target\n return buildRoute(target)\n}\n\nexport class KeqMiddlewareApplicator<TReturn> {\n private readonly excludedTargets: KeqRouteTarget[] = []\n\n constructor(\n private readonly middlewares: KeqMiddleware[],\n private readonly registeredMiddlewares: KeqMiddleware[],\n private readonly returnValue: TReturn,\n ) {}\n\n exclude(...routes: KeqRouteTarget[]): this {\n this.excludedTargets.push(...routes)\n return this\n }\n\n forRoutes(...routes: KeqRouteTarget[]): TReturn {\n const inclusionRoutes = routes.map(normalizeTarget)\n const inclusionRoute = inclusionRoutes.length === 1\n ? inclusionRoutes[0]\n : orRoute(inclusionRoutes)\n\n let finalRoute: KeqRoute\n if (this.excludedTargets.length > 0) {\n const exclusionRoutes = this.excludedTargets.map(normalizeTarget)\n const exclusionRoute = exclusionRoutes.length === 1\n ? exclusionRoutes[0]\n : orRoute(exclusionRoutes)\n finalRoute = composeRoute([inclusionRoute, notRoute(exclusionRoute)])\n } else {\n finalRoute = inclusionRoute\n }\n\n const composedMiddleware = this.middlewares.length > 1\n ? composeMiddleware(this.middlewares)\n : this.middlewares[0]\n\n const routeMiddleware: KeqMiddleware = async function routeApply(ctx, next) {\n if (await finalRoute(ctx)) await composedMiddleware(ctx, next)\n else await next()\n }\n\n this.registeredMiddlewares.push(routeMiddleware)\n return this.returnValue\n }\n\n forAllRoutes(): TReturn {\n const composedMiddleware = this.middlewares.length > 1\n ? composeMiddleware(this.middlewares)\n : this.middlewares[0]\n\n if (this.excludedTargets.length > 0) {\n const exclusionRoutes = this.excludedTargets.map(normalizeTarget)\n const exclusionRoute = exclusionRoutes.length === 1\n ? exclusionRoutes[0]\n : orRoute(exclusionRoutes)\n const finalRoute = notRoute(exclusionRoute)\n\n const routeMiddleware: KeqMiddleware = async function routeApply(ctx, next) {\n if (await finalRoute(ctx)) await composedMiddleware(ctx, next)\n else await next()\n }\n\n this.registeredMiddlewares.push(routeMiddleware)\n } else {\n this.registeredMiddlewares.push(composedMiddleware)\n }\n\n return this.returnValue\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 let timer: ReturnType<typeof setTimeout> | undefined\n\n ctx.emitter.on('fetch:before', ({ context }) => {\n timer = setTimeout(() => {\n const err = new TimeoutException(`keq request timeout(${millisecond}ms)`)\n context.request.abort(err)\n context.emitter.emit('timeout', { context })\n }, millisecond)\n })\n\n ctx.emitter.on('fetch:after', () => {\n if (timer !== undefined) {\n clearTimeout(timer)\n timer = undefined\n }\n })\n\n await next()\n }\n}\n","import { Semaphore } from '~/utils/index.js'\nimport type { KeqMiddleware } from '~/middleware/types/index.js'\n\n\nexport function keqSerialFlowControlMiddleware(): KeqMiddleware {\n return async function serialFlowControlMiddleware(ctx, next) {\n if (!ctx.options.flowControl || !['serial', 'concurrent'].includes(ctx.options.flowControl.mode)) {\n await next()\n return\n }\n\n const { signal } = ctx.options.flowControl\n const concurrent = ctx.options.flowControl.mode === 'serial'\n ? 1\n : !ctx.options.flowControl.concurrencyLimit || ctx.options.flowControl.concurrencyLimit < 1\n ? 1\n : Math.floor(ctx.options.flowControl.concurrencyLimit)\n\n const key = typeof signal === 'string' ? signal : signal(ctx)\n\n if (!ctx.global.core) ctx.global.core = {}\n if (!ctx.global.core.serialFlowControl) ctx.global.core.serialFlowControl = {}\n\n if (!ctx.global.core.serialFlowControl[key]) {\n ctx.global.core.serialFlowControl[key] = new Semaphore(concurrent)\n }\n\n const semaphore = ctx.global.core.serialFlowControl[key]\n\n await semaphore.acquire()\n try {\n await next()\n } finally {\n semaphore.release()\n }\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.core) ctx.global.core = {}\n if (!ctx.global.core.abortFlowControl) ctx.global.core.abortFlowControl = {}\n\n const abort = ctx.global.core.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.core.abortFlowControl[key] = fn\n\n try {\n await next()\n } finally {\n if (ctx.global.core.abortFlowControl[key] === fn) {\n ctx.global.core.abortFlowControl[key] = undefined\n }\n }\n }\n}\n","import { MutexException } from '~/exception/index.js'\nimport { KeqMiddleware } from '~/middleware/types/index.js'\n\n\nexport function keqMutexFlowControlMiddleware(): KeqMiddleware {\n return async function mutexFlowControlMiddleware(ctx, next) {\n if (!ctx.options.flowControl || ctx.options.flowControl.mode !== 'mutex') {\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.core) ctx.global.core = {}\n if (!ctx.global.core.mutexFlowControl) ctx.global.core.mutexFlowControl = new Set()\n\n if (ctx.global.core.mutexFlowControl.has(key)) {\n throw new MutexException(`Request rejected by MutexFlowControl: a request with key \"${key}\" is already in-flight`)\n }\n\n ctx.global.core.mutexFlowControl.add(key)\n\n try {\n await next()\n } finally {\n ctx.global.core.mutexFlowControl.delete(key)\n }\n }\n}\n","import { keqSerialFlowControlMiddleware } from './serial-flow-control-middleware'\nimport { keqAbortFlowControlMiddleware } from './abort-flow-control-middleware'\nimport { keqMutexFlowControlMiddleware } from './mutex-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 [keqMutexFlowControlMiddleware(), 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 { KeqEvents, 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 { KeqMiddlewareApplicator } from '~/router/keq-middleware-applicator'\nimport { keqFetchMiddleware, keqFlowControlMiddleware, keqTimeoutMiddleware } from '~/middlewares'\n\n\nexport interface KeqRequestOptions {\n middlewares?: KeqMiddleware[]\n terminalMiddlewares?: KeqMiddleware[]\n baseOrigin?: string\n qs?: KeqQueryOptions\n}\n\nexport interface KeqRequestForkOptions {\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 middlewares: KeqMiddleware[] = []\n private readonly __terminalMiddlewares__: KeqMiddleware[] = []\n private __parent__?: KeqRequest\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.__terminalMiddlewares__ = options?.terminalMiddlewares || [\n keqFlowControlMiddleware(),\n keqTimeoutMiddleware(),\n keqFetchMiddleware(),\n ]\n this.middlewares = options?.middlewares || []\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 resolveMiddlewares(): KeqMiddleware[] {\n if (!this.__parent__) {\n return this.middlewares\n }\n return [...this.__parent__.resolveMiddlewares(), ...this.middlewares]\n }\n\n private __fetch__(\n url: string | URL,\n init: KeqRequestFetchOptions,\n locationId?: string,\n ): Keq<any> {\n const keq = new Keq(\n this.__formatUrl__(url),\n {\n ...init, locationId,\n global: this.global,\n qs: this.qs,\n middlewares: [\n ...this.resolveMiddlewares(),\n ...this.__terminalMiddlewares__,\n ],\n })\n\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 return this.__fetch__(\n url,\n { method: 'put' },\n getLocationId(1),\n )\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.middlewares.push(firstMiddleware, ...middleware)\n return this\n }\n\n apply(middleware: KeqMiddleware[]): KeqMiddlewareApplicator<this>\n apply(middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddlewareApplicator<this>\n apply(middleware: KeqMiddleware | KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddlewareApplicator<this> {\n const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares]\n return new KeqMiddlewareApplicator(list, this.middlewares, this)\n }\n\n /**\n * @deprecated Use `request.apply(...middlewares).forRoutes(...)` instead.\n */\n useRouter(): KeqRouter {\n return new KeqRouter(this.middlewares)\n }\n\n fork(options?: KeqRequestForkOptions): KeqRequest {\n const child = new KeqRequest({\n baseOrigin: options?.baseOrigin ?? this.baseOrigin,\n qs: options?.qs ?? (this.qs ? { ...this.qs } : undefined),\n })\n child.__parent__ = this\n return child\n }\n\n inherit(parent: KeqRequest): this {\n this.__parent__ = parent\n return this\n }\n\n adopt(child: KeqRequest): this {\n child.__parent__ = this\n return this\n }\n\n /** @deprecated Use `middlewares` instead */\n get preMiddlewares(): KeqMiddleware[] {\n return this.middlewares\n }\n\n on<K extends keyof KeqEvents>(event: K, listener: (data: KeqEvents[K]) => void): this {\n const middleware: KeqMiddleware = async (context, next) => {\n context.emitter.on(event, listener)\n await next()\n }\n\n middleware.__keqMiddlewareName__ = `listen(${event}, ${listener.name || 'anonymous'})`\n\n this.use(middleware)\n\n return this\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<SC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