@decoraxios/awe-axios-core 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/config.ts","../src/metadata.ts","../src/runtime/request.ts","../src/utils/path.ts","../src/runtime/params.ts","../src/decorators/http.ts","../src/decorators/params.ts","../src/runtime/strategies.ts","../src/decorators/extensions.ts","../src/runtime/signal.ts"],"sourcesContent":["import axios from 'axios';\n\nexport { HttpApi, Get, Post, Put, Delete, Patch, Options, Head } from './decorators/http.js';\nexport { BodyParam, PathParam, QueryParam } from './decorators/params.js';\nexport {\n AxiosRef,\n Debounce,\n Retry,\n RefAxios,\n Throttle,\n TransformRequest,\n TransformResponse,\n withHttpClassConfig,\n withHttpClassPlugins,\n withHttpMethodConfig,\n withHttpMethodPlugins,\n} from './decorators/extensions.js';\nexport { executeHttpCall } from './runtime/request.js';\nexport { SignalController } from './runtime/signal.js';\nexport {\n createDebouncePlugin,\n createRetryPlugin,\n createThrottlePlugin,\n useDebounce,\n useRequest,\n useRetry,\n useThrottle,\n} from './runtime/strategies.js';\nexport {\n composeDecoratedUrl,\n isAbsoluteHttpUrl,\n joinPathname,\n resolveAbsoluteHttpTarget,\n resolvePathParams,\n} from './utils/path.js';\nexport type * from './types.js';\n\nexport const axiosPlus = axios;\n","import { AxiosHeaders } from 'axios';\n\nimport type { HttpMethodConfig, ResolvedHttpRequestConfig } from '../types.js';\n\nexport function normalizeArray<T>(value?: T | T[]): T[] {\n if (value === undefined) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n}\n\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\nexport function toPlainHeaders(headers: HttpMethodConfig['headers']): Record<string, unknown> | undefined {\n if (!headers) {\n return undefined;\n }\n\n if (headers instanceof AxiosHeaders) {\n return headers.toJSON();\n }\n\n const maybeSerializable = headers as unknown as { toJSON?: () => Record<string, unknown> };\n if (typeof maybeSerializable.toJSON === 'function') {\n return maybeSerializable.toJSON();\n }\n\n return { ...(headers as Record<string, unknown>) };\n}\n\nexport function mergeHeaders(\n ...headersList: Array<HttpMethodConfig['headers'] | undefined>\n): Record<string, unknown> | undefined {\n const merged = headersList.reduce<Record<string, unknown>>((accumulator, current) => {\n const plainHeaders = toPlainHeaders(current);\n if (plainHeaders) {\n Object.assign(accumulator, plainHeaders);\n }\n return accumulator;\n }, {});\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nexport function mergeHttpConfigPatch<T extends HttpMethodConfig>(base: T, patch: Partial<T>): T {\n const next = {\n ...base,\n ...patch,\n } as T;\n\n const headers = mergeHeaders(base.headers, patch.headers);\n if (headers) {\n next.headers = headers as T['headers'];\n }\n\n const transformRequest = [\n ...normalizeArray(base.transformRequest),\n ...normalizeArray(patch.transformRequest),\n ];\n if (transformRequest.length > 0) {\n next.transformRequest = transformRequest as T['transformRequest'];\n }\n\n const transformResponse = [\n ...normalizeArray(base.transformResponse),\n ...normalizeArray(patch.transformResponse),\n ];\n if (transformResponse.length > 0) {\n next.transformResponse = transformResponse as T['transformResponse'];\n }\n\n const plugins = [...(base.plugins ?? []), ...(patch.plugins ?? [])];\n if (plugins.length > 0) {\n next.plugins = plugins as T['plugins'];\n }\n\n return next;\n}\n\nexport function mergeRecords(\n ...values: Array<Record<string, unknown> | undefined>\n): Record<string, unknown> | undefined {\n const merged = values.reduce<Record<string, unknown>>((accumulator, current) => {\n if (current) {\n Object.assign(accumulator, current);\n }\n return accumulator;\n }, {});\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nexport function toAxiosRequestConfig<TRequestData>(\n config: ResolvedHttpRequestConfig<TRequestData>,\n): HttpMethodConfig<TRequestData> {\n const { refAxios: _refAxios, methodId: _methodId, plugins: _plugins, ...axiosConfig } = config;\n return axiosConfig;\n}\n","import type { HttpApiConfig, HttpMethodConfig, MethodKey, ParamBinding } from './types.js';\nimport { mergeHttpConfigPatch } from './utils/config.js';\n\ninterface StoredMethodConfig extends HttpMethodConfig {\n methodId: string;\n}\n\nconst classConfigStore = new WeakMap<object, HttpApiConfig>();\nconst methodConfigStore = new WeakMap<object, Map<MethodKey, StoredMethodConfig>>();\nconst paramBindingStore = new WeakMap<object, Map<MethodKey, ParamBinding[]>>();\nconst wrappedStore = new WeakMap<object, Set<MethodKey>>();\n\nlet methodCounter = 0;\n\nfunction getOrCreateMethodMap(target: object): Map<MethodKey, StoredMethodConfig> {\n let map = methodConfigStore.get(target);\n if (!map) {\n map = new Map();\n methodConfigStore.set(target, map);\n }\n return map;\n}\n\nfunction getOrCreateParamMap(target: object): Map<MethodKey, ParamBinding[]> {\n let map = paramBindingStore.get(target);\n if (!map) {\n map = new Map();\n paramBindingStore.set(target, map);\n }\n return map;\n}\n\nfunction createMethodId(propertyKey: MethodKey): string {\n methodCounter += 1;\n return `${String(propertyKey)}_${methodCounter}`;\n}\n\nexport function getClassConfig(target: object): HttpApiConfig | undefined {\n return classConfigStore.get(target);\n}\n\nexport function mergeClassConfig(target: object, patch: Partial<HttpApiConfig>): HttpApiConfig {\n const current = classConfigStore.get(target) ?? {};\n const next = mergeHttpConfigPatch(current, patch);\n classConfigStore.set(target, next);\n return next;\n}\n\nexport function getMethodConfig(target: object, propertyKey: MethodKey): StoredMethodConfig | undefined {\n return methodConfigStore.get(target)?.get(propertyKey);\n}\n\nexport function mergeMethodConfig(\n target: object,\n propertyKey: MethodKey,\n patch: Partial<HttpMethodConfig>,\n): StoredMethodConfig {\n const map = getOrCreateMethodMap(target);\n const current: StoredMethodConfig = map.get(propertyKey) ?? {\n methodId: createMethodId(propertyKey),\n };\n const next = mergeHttpConfigPatch(current, patch as Partial<StoredMethodConfig>) as StoredMethodConfig;\n map.set(propertyKey, next);\n return next;\n}\n\nexport function addParamBinding(target: object, propertyKey: MethodKey, binding: ParamBinding): void {\n const map = getOrCreateParamMap(target);\n const bindings = map.get(propertyKey) ?? [];\n bindings.push(binding);\n bindings.sort((left, right) => left.index - right.index);\n map.set(propertyKey, bindings);\n}\n\nexport function getParamBindings(target: object, propertyKey: MethodKey): ParamBinding[] {\n return [...(paramBindingStore.get(target)?.get(propertyKey) ?? [])];\n}\n\nexport function isMethodWrapped(target: object, propertyKey: MethodKey): boolean {\n return wrappedStore.get(target)?.has(propertyKey) ?? false;\n}\n\nexport function markMethodWrapped(target: object, propertyKey: MethodKey): void {\n let wrapped = wrappedStore.get(target);\n if (!wrapped) {\n wrapped = new Set();\n wrappedStore.set(target, wrapped);\n }\n\n wrapped.add(propertyKey);\n}\n","import axios from 'axios';\n\nimport { getClassConfig, getMethodConfig, getParamBindings } from '../metadata.js';\nimport type {\n HttpRequestExecutor,\n HttpRuntimeContext,\n MethodKey,\n ResolvedHttpRequestConfig,\n} from '../types.js';\nimport { mergeHeaders, mergeRecords, normalizeArray, toAxiosRequestConfig } from '../utils/config.js';\nimport { composeDecoratedUrl, isAbsoluteHttpUrl, resolvePathParams } from '../utils/path.js';\nimport { extractBoundParams } from './params.js';\n\nfunction resolveClassConfig(instance: unknown, target: object) {\n if (instance && typeof instance === 'object') {\n const ctor = (instance as { constructor?: object }).constructor;\n if (ctor) {\n return getClassConfig(ctor);\n }\n }\n\n return getClassConfig(target);\n}\n\nfunction buildResolvedRequestConfig(\n instance: unknown,\n target: object,\n propertyKey: MethodKey,\n args: unknown[],\n): ResolvedHttpRequestConfig {\n const methodConfig = getMethodConfig(target, propertyKey);\n if (!methodConfig?.method) {\n throw new Error(`Method \"${String(propertyKey)}\" is missing an HTTP decorator.`);\n }\n\n const classConfig = resolveClassConfig(instance, target) ?? {};\n const { pathParams, queryParams, body } = extractBoundParams(getParamBindings(target, propertyKey), args);\n const refAxios = methodConfig.refAxios ?? classConfig.refAxios ?? axios;\n const baseURL = methodConfig.baseURL ?? classConfig.baseURL ?? refAxios.defaults.baseURL;\n const composedUrl = composeDecoratedUrl(classConfig.url, methodConfig.url);\n const url = resolvePathParams(composedUrl, pathParams);\n\n if (!baseURL && !isAbsoluteHttpUrl(url)) {\n throw new Error(`Method \"${String(propertyKey)}\" requires a baseURL or an absolute URL.`);\n }\n\n const params = mergeRecords(\n classConfig.params as Record<string, unknown> | undefined,\n methodConfig.params as Record<string, unknown> | undefined,\n queryParams,\n );\n\n const plugins = [...(classConfig.plugins ?? []), ...(methodConfig.plugins ?? [])];\n const transformRequest = [\n ...normalizeArray(refAxios.defaults.transformRequest),\n ...normalizeArray(classConfig.transformRequest),\n ...normalizeArray(methodConfig.transformRequest),\n ];\n const transformResponse = [\n ...normalizeArray(refAxios.defaults.transformResponse),\n ...normalizeArray(classConfig.transformResponse),\n ...normalizeArray(methodConfig.transformResponse),\n ];\n\n return {\n ...classConfig,\n ...methodConfig,\n baseURL,\n url,\n params,\n data: body !== undefined ? body : methodConfig.data ?? classConfig.data,\n headers: mergeHeaders(classConfig.headers, methodConfig.headers) as ResolvedHttpRequestConfig['headers'],\n transformRequest: transformRequest.length > 0 ? transformRequest : undefined,\n transformResponse: transformResponse.length > 0 ? transformResponse : undefined,\n refAxios,\n plugins,\n methodId: methodConfig.methodId,\n method: methodConfig.method as ResolvedHttpRequestConfig['method'],\n };\n}\n\nconst baseExecutor: HttpRequestExecutor = config => {\n return config.refAxios.request(toAxiosRequestConfig(config));\n};\n\nexport function executeHttpCall(\n instance: unknown,\n target: object,\n propertyKey: MethodKey,\n originalMethod: (...args: any[]) => unknown,\n args: unknown[],\n) {\n const resolvedConfig = buildResolvedRequestConfig(instance, target, propertyKey, args);\n const context: HttpRuntimeContext = {\n instance,\n target,\n propertyKey,\n methodId: resolvedConfig.methodId,\n args,\n originalMethod,\n };\n\n const executor = [...(resolvedConfig.plugins ?? [])].reverse().reduce<HttpRequestExecutor>((next, plugin) => {\n return plugin(next, context);\n }, baseExecutor);\n\n return executor(resolvedConfig);\n}\n","export function isAbsoluteHttpUrl(value?: string): value is string {\n return typeof value === 'string' && /^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(value);\n}\n\nfunction trimSegment(value: string): string {\n return value.trim().replace(/^\\/+|\\/+$/g, '');\n}\n\nexport function joinPathname(...parts: Array<string | undefined>): string {\n const filtered = parts.filter((part): part is string => typeof part === 'string' && part.trim().length > 0);\n if (filtered.length === 0) {\n return '';\n }\n\n const leadingSlash = filtered.some(part => part.startsWith('/'));\n const segments = filtered.map(trimSegment).filter(Boolean);\n\n if (segments.length === 0) {\n return leadingSlash ? '/' : '';\n }\n\n return `${leadingSlash ? '/' : ''}${segments.join('/')}`;\n}\n\nexport function composeDecoratedUrl(classUrl?: string, methodUrl?: string): string {\n if (isAbsoluteHttpUrl(methodUrl)) {\n return methodUrl;\n }\n\n if (isAbsoluteHttpUrl(classUrl)) {\n const parsed = new URL(classUrl);\n if (!methodUrl) {\n return classUrl;\n }\n\n return `${parsed.origin}${joinPathname(parsed.pathname, methodUrl)}`;\n }\n\n return joinPathname(classUrl, methodUrl);\n}\n\nexport function resolvePathParams(url: string, params: Record<string, unknown>): string {\n if (!url) {\n return url;\n }\n\n return url.replace(/:([\\w-]+)/g, (placeholder, key: string) => {\n const value = params[key];\n if (value === undefined || value === null) {\n return placeholder;\n }\n\n return encodeURIComponent(String(value));\n });\n}\n\nexport function resolveAbsoluteHttpTarget(baseURL: string | undefined, url: string): { origin: string; pathname: string } {\n if (isAbsoluteHttpUrl(url)) {\n const parsed = new URL(url);\n return {\n origin: parsed.origin,\n pathname: joinPathname(parsed.pathname),\n };\n }\n\n if (!baseURL || !isAbsoluteHttpUrl(baseURL)) {\n throw new Error('Mock support requires an absolute baseURL or an absolute request URL.');\n }\n\n const parsed = new URL(baseURL);\n return {\n origin: parsed.origin,\n pathname: joinPathname(parsed.pathname, url),\n };\n}\n","import type { ParamBinding } from '../types.js';\nimport { isPlainObject } from '../utils/config.js';\n\nexport interface BoundParams {\n pathParams: Record<string, unknown>;\n queryParams: Record<string, unknown>;\n body: unknown;\n}\n\nfunction assignMultiValue(target: Record<string, unknown>, key: string, value: unknown): void {\n const current = target[key];\n if (current === undefined) {\n target[key] = value;\n return;\n }\n\n if (Array.isArray(current)) {\n current.push(value);\n return;\n }\n\n target[key] = [current, value];\n}\n\nexport function extractBoundParams(bindings: ParamBinding[], args: unknown[]): BoundParams {\n const pathParams: Record<string, unknown> = {};\n const queryParams: Record<string, unknown> = {};\n const namedBody: Record<string, unknown> = {};\n const unnamedBody: unknown[] = [];\n\n for (const binding of bindings) {\n const value = args[binding.index];\n\n if (binding.kind === 'path' && binding.name) {\n pathParams[binding.name] = value;\n continue;\n }\n\n if (binding.kind === 'query' && binding.name) {\n assignMultiValue(queryParams, binding.name, value);\n continue;\n }\n\n if (binding.kind === 'body') {\n if (binding.name) {\n namedBody[binding.name] = value;\n } else {\n unnamedBody.push(value);\n }\n }\n }\n\n let body: unknown = undefined;\n\n if (Object.keys(namedBody).length > 0) {\n const mergedUnnamed = unnamedBody.filter(isPlainObject).reduce<Record<string, unknown>>((accumulator, current) => {\n Object.assign(accumulator, current);\n return accumulator;\n }, {});\n\n body = {\n ...mergedUnnamed,\n ...namedBody,\n };\n } else if (unnamedBody.length === 1) {\n body = unnamedBody[0];\n } else if (unnamedBody.length > 1) {\n if (unnamedBody.every(isPlainObject)) {\n body = unnamedBody.reduce<Record<string, unknown>>((accumulator, current) => {\n Object.assign(accumulator, current);\n return accumulator;\n }, {});\n } else {\n body = unnamedBody;\n }\n }\n\n return {\n pathParams,\n queryParams,\n body,\n };\n}\n","import type { AxiosInstance, Method } from 'axios';\n\nimport { getMethodConfig, isMethodWrapped, markMethodWrapped, mergeClassConfig, mergeMethodConfig } from '../metadata.js';\nimport { executeHttpCall } from '../runtime/request.js';\nimport type { HttpApiConfig, HttpMethodConfig, MethodKey } from '../types.js';\nimport { isAbsoluteHttpUrl } from '../utils/path.js';\n\nfunction isAxiosInstance(value: unknown): value is AxiosInstance {\n return !!value && typeof value === 'object' && typeof (value as AxiosInstance).request === 'function';\n}\n\nfunction normalizeMethodConfig(config: HttpMethodConfig | string | undefined, method: Method): HttpMethodConfig {\n if (typeof config === 'string') {\n return {\n method,\n url: config,\n };\n }\n\n return {\n ...(config ?? {}),\n method,\n };\n}\n\nfunction normalizeClassConfig(config?: HttpApiConfig | string | AxiosInstance): HttpApiConfig {\n if (typeof config === 'string') {\n return isAbsoluteHttpUrl(config) ? { baseURL: config } : { url: config };\n }\n\n if (isAxiosInstance(config)) {\n return { refAxios: config };\n }\n\n return config ?? {};\n}\n\nfunction wrapHttpMethod(\n target: object,\n propertyKey: MethodKey,\n descriptor: PropertyDescriptor,\n): PropertyDescriptor {\n if (isMethodWrapped(target, propertyKey)) {\n return descriptor;\n }\n\n const originalMethod = descriptor.value;\n if (typeof originalMethod !== 'function') {\n throw new Error(`\"${String(propertyKey)}\" must be a method to use HTTP decorators.`);\n }\n\n descriptor.value = function wrappedHttpMethod(...args: unknown[]) {\n return executeHttpCall(this, target, propertyKey, originalMethod, args);\n };\n\n markMethodWrapped(target, propertyKey);\n return descriptor;\n}\n\nfunction createHttpMethodDecorator(method: Method) {\n return (config?: HttpMethodConfig | string): MethodDecorator => {\n return (target, propertyKey, descriptor) => {\n if (propertyKey === undefined || descriptor === undefined) {\n throw new Error(`\"${method}\" can only be used on instance methods.`);\n }\n\n const existing = getMethodConfig(target, propertyKey);\n if (existing?.method && existing.method !== method) {\n throw new Error(`\"${String(propertyKey)}\" already has an HTTP decorator.`);\n }\n\n mergeMethodConfig(target, propertyKey, normalizeMethodConfig(config, method));\n return wrapHttpMethod(target, propertyKey, descriptor);\n };\n };\n}\n\nexport function HttpApi(config?: HttpApiConfig | string | AxiosInstance): ClassDecorator {\n return target => {\n mergeClassConfig(target, normalizeClassConfig(config));\n };\n}\n\nexport const Get = createHttpMethodDecorator('get');\nexport const Post = createHttpMethodDecorator('post');\nexport const Put = createHttpMethodDecorator('put');\nexport const Delete = createHttpMethodDecorator('delete');\nexport const Patch = createHttpMethodDecorator('patch');\nexport const Options = createHttpMethodDecorator('options');\nexport const Head = createHttpMethodDecorator('head');\n","import { addParamBinding } from '../metadata.js';\nimport type { ParamBindingKind } from '../types.js';\n\nfunction createParamDecorator(kind: ParamBindingKind, name?: string): ParameterDecorator {\n return (target, propertyKey, parameterIndex) => {\n if (propertyKey === undefined) {\n throw new Error(`\"${kind}\" parameter decorators are only supported on instance methods.`);\n }\n\n addParamBinding(target, propertyKey, {\n index: parameterIndex,\n kind,\n name,\n });\n };\n}\n\nexport function BodyParam(name?: string): ParameterDecorator {\n return createParamDecorator('body', name);\n}\n\nexport function PathParam(name: string): ParameterDecorator {\n return createParamDecorator('path', name);\n}\n\nexport function QueryParam(name: string): ParameterDecorator {\n return createParamDecorator('query', name);\n}\n","import type { HttpRequestExecutor, HttpRuntimePlugin } from '../types.js';\n\nexport interface RetryOptions {\n count?: number;\n delay?: number;\n signal?: AbortSignal;\n shouldRetry?: (error: unknown, attempt: number) => boolean;\n}\n\nexport interface DebounceOptions {\n delay?: number;\n immediate?: boolean;\n}\n\nexport interface ThrottleOptions {\n interval?: number;\n}\n\ntype AsyncFn<TArgs extends unknown[], TResult> = (...args: TArgs) => Promise<TResult>;\n\nfunction sleep(delay: number) {\n return new Promise(resolve => {\n setTimeout(resolve, delay);\n });\n}\n\nexport function useRequest<TArgs extends unknown[], TResult>(requester: AsyncFn<TArgs, TResult>) {\n return requester;\n}\n\nexport function useRetry<TArgs extends unknown[], TResult>(\n requester: AsyncFn<TArgs, TResult>,\n options: RetryOptions = {},\n): AsyncFn<TArgs, TResult> {\n const {\n count = 3,\n delay = 100,\n signal,\n shouldRetry = () => true,\n } = options;\n\n return async (...args: TArgs) => {\n let attempt = 0;\n let lastError: unknown;\n\n while (attempt < count) {\n if (signal?.aborted) {\n throw signal.reason ?? new Error('Retry execution was aborted.');\n }\n\n try {\n return await requester(...args);\n } catch (error) {\n attempt += 1;\n lastError = error;\n\n if (attempt >= count || !shouldRetry(error, attempt)) {\n throw error;\n }\n\n await sleep(delay);\n }\n }\n\n throw lastError;\n };\n}\n\nexport function useDebounce<TArgs extends unknown[], TResult>(\n requester: AsyncFn<TArgs, TResult>,\n options: DebounceOptions = {},\n): AsyncFn<TArgs, TResult> {\n const { delay = 100, immediate = false } = options;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let latestArgs: TArgs | undefined;\n let pending: Array<{ resolve: (value: TResult) => void; reject: (reason?: unknown) => void }> = [];\n\n const flush = async () => {\n const resolvers = pending;\n pending = [];\n timer = undefined;\n\n if (!latestArgs) {\n return;\n }\n\n try {\n const result = await requester(...latestArgs);\n resolvers.forEach(item => item.resolve(result));\n } catch (error) {\n resolvers.forEach(item => item.reject(error));\n }\n };\n\n return (...args: TArgs) => {\n latestArgs = args;\n\n return new Promise<TResult>((resolve, reject) => {\n pending.push({ resolve, reject });\n\n const shouldCallImmediately = immediate && !timer;\n if (timer) {\n clearTimeout(timer);\n }\n\n if (shouldCallImmediately) {\n void flush();\n timer = setTimeout(() => {\n timer = undefined;\n }, delay);\n return;\n }\n\n timer = setTimeout(() => {\n void flush();\n }, delay);\n });\n };\n}\n\nfunction createSingleConfigPlugin(\n factory: (executor: HttpRequestExecutor) => HttpRequestExecutor,\n): HttpRuntimePlugin {\n let wrapped: HttpRequestExecutor | undefined;\n\n return next => {\n if (!wrapped) {\n wrapped = factory(next);\n }\n\n return config => wrapped!(config);\n };\n}\n\nexport function createRetryPlugin(options: RetryOptions = {}): HttpRuntimePlugin {\n return createSingleConfigPlugin(next => useRetry(config => next(config), options));\n}\n\nexport function createDebouncePlugin(options: DebounceOptions = {}): HttpRuntimePlugin {\n return createSingleConfigPlugin(next => useDebounce(config => next(config), options));\n}\n\nexport function createThrottlePlugin(options: ThrottleOptions = {}): HttpRuntimePlugin {\n return createSingleConfigPlugin(next => useThrottle(config => next(config), options));\n}\n\nexport function useThrottle<TArgs extends unknown[], TResult>(\n requester: AsyncFn<TArgs, TResult>,\n options: ThrottleOptions = {},\n): AsyncFn<TArgs, TResult> {\n const { interval = 100 } = options;\n let active = false;\n let trailingArgs: TArgs | undefined;\n let trailingResolvers: Array<{ resolve: (value: TResult) => void; reject: (reason?: unknown) => void }> = [];\n\n const run = async (args: TArgs, resolvers: typeof trailingResolvers) => {\n active = true;\n\n try {\n const result = await requester(...args);\n resolvers.forEach(item => item.resolve(result));\n } catch (error) {\n resolvers.forEach(item => item.reject(error));\n } finally {\n setTimeout(() => {\n active = false;\n\n if (trailingArgs) {\n const nextArgs = trailingArgs;\n const nextResolvers = trailingResolvers;\n trailingArgs = undefined;\n trailingResolvers = [];\n void run(nextArgs, nextResolvers);\n }\n }, interval);\n }\n };\n\n return (...args: TArgs) => {\n return new Promise<TResult>((resolve, reject) => {\n if (!active) {\n void run(args, [{ resolve, reject }]);\n return;\n }\n\n trailingArgs = args;\n trailingResolvers.push({ resolve, reject });\n });\n };\n}\n","import type { AxiosInstance, AxiosRequestTransformer, AxiosResponseTransformer } from 'axios';\n\nimport { mergeClassConfig, mergeMethodConfig } from '../metadata.js';\nimport {\n createDebouncePlugin,\n createRetryPlugin,\n createThrottlePlugin,\n type DebounceOptions,\n type RetryOptions,\n type ThrottleOptions,\n} from '../runtime/strategies.js';\nimport type { HttpApiConfig, HttpMethodConfig, HttpRuntimePlugin } from '../types.js';\n\nexport function withHttpMethodConfig(config: Partial<HttpMethodConfig>): MethodDecorator {\n return (target, propertyKey) => {\n if (propertyKey === undefined) {\n throw new Error('HTTP method config decorators can only be used on instance methods.');\n }\n\n mergeMethodConfig(target, propertyKey, config);\n };\n}\n\nexport function withHttpClassConfig(config: Partial<HttpApiConfig>): ClassDecorator {\n return target => {\n mergeClassConfig(target, config);\n };\n}\n\nexport function withHttpMethodPlugins(...plugins: HttpRuntimePlugin[]): MethodDecorator {\n return withHttpMethodConfig({ plugins });\n}\n\nexport function withHttpClassPlugins(...plugins: HttpRuntimePlugin[]): ClassDecorator {\n return withHttpClassConfig({ plugins });\n}\n\nexport function TransformRequest(\n transformRequest: AxiosRequestTransformer | AxiosRequestTransformer[],\n): MethodDecorator {\n return withHttpMethodConfig({\n transformRequest: Array.isArray(transformRequest) ? transformRequest : [transformRequest],\n });\n}\n\nexport function TransformResponse(\n transformResponse: AxiosResponseTransformer | AxiosResponseTransformer[],\n): MethodDecorator {\n return withHttpMethodConfig({\n transformResponse: Array.isArray(transformResponse) ? transformResponse : [transformResponse],\n });\n}\n\nexport function RefAxios(refAxios: AxiosInstance): ClassDecorator {\n return withHttpClassConfig({ refAxios });\n}\n\nexport function AxiosRef(refAxios: AxiosInstance): MethodDecorator {\n return withHttpMethodConfig({ refAxios });\n}\n\nexport function Retry(options: RetryOptions = {}): MethodDecorator {\n return withHttpMethodPlugins(createRetryPlugin(options));\n}\n\nexport function Debounce(options: DebounceOptions = {}): MethodDecorator {\n return withHttpMethodPlugins(createDebouncePlugin(options));\n}\n\nexport function Throttle(options: ThrottleOptions = {}): MethodDecorator {\n return withHttpMethodPlugins(createThrottlePlugin(options));\n}\n","export class SignalController {\n private controller = new AbortController();\n\n get signal(): AbortSignal {\n return this.controller.signal;\n }\n\n abort(reason?: string) {\n this.controller.abort(reason);\n }\n\n enable() {\n if (this.controller.signal.aborted) {\n this.controller = new AbortController();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAAA,gBAAkB;;;ACAlB,mBAA6B;AAItB,SAASC,eAAkBC,OAAe;AAC/C,MAAIA,UAAUC,QAAW;AACvB,WAAO,CAAA;EACT;AAEA,SAAOC,MAAMC,QAAQH,KAAAA,IAASA,QAAQ;IAACA;;AACzC;AANgBD;AAQT,SAASK,cAAcJ,OAAc;AAC1C,SAAOK,OAAOC,UAAUC,SAASC,KAAKR,KAAAA,MAAW;AACnD;AAFgBI;AAIT,SAASK,eAAeC,SAAoC;AACjE,MAAI,CAACA,SAAS;AACZ,WAAOT;EACT;AAEA,MAAIS,mBAAmBC,2BAAc;AACnC,WAAOD,QAAQE,OAAM;EACvB;AAEA,QAAMC,oBAAoBH;AAC1B,MAAI,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C,WAAKN,aAAa,IAAIC,gBAAAA;IACxB;EACF;AACF;;;AVqBO,IAAMM,YAAYC,cAAAA;","names":["import_axios","normalizeArray","value","undefined","Array","isArray","isPlainObject","Object","prototype","toString","call","toPlainHeaders","headers","AxiosHeaders","toJSON","maybeSerializable","mergeHeaders","headersList","merged","reduce","accumulator","current","plainHeaders","assign","keys","length","mergeHttpConfigPatch","base","patch","next","transformRequest","transformResponse","plugins","mergeRecords","values","toAxiosRequestConfig","config","refAxios","_refAxios","methodId","_methodId","_plugins","axiosConfig","classConfigStore","WeakMap","methodConfigStore","paramBindingStore","wrappedStore","methodCounter","getOrCreateMethodMap","target","map","get","Map","set","getOrCreateParamMap","createMethodId","propertyKey","String","getClassConfig","mergeClassConfig","patch","current","next","mergeHttpConfigPatch","getMethodConfig","mergeMethodConfig","methodId","addParamBinding","binding","bindings","push","sort","left","right","index","getParamBindings","isMethodWrapped","has","markMethodWrapped","wrapped","Set","add","import_axios","isAbsoluteHttpUrl","value","test","trimSegment","trim","replace","joinPathname","parts","filtered","filter","part","length","leadingSlash","some","startsWith","segments","map","Boolean","join","composeDecoratedUrl","classUrl","methodUrl","parsed","URL","origin","pathname","resolvePathParams","url","params","placeholder","key","undefined","encodeURIComponent","String","resolveAbsoluteHttpTarget","baseURL","Error","assignMultiValue","target","key","value","current","undefined","Array","isArray","push","extractBoundParams","bindings","args","pathParams","queryParams","namedBody","unnamedBody","binding","index","kind","name","body","Object","keys","length","mergedUnnamed","filter","isPlainObject","reduce","accumulator","assign","every","resolveClassConfig","instance","target","ctor","getClassConfig","buildResolvedRequestConfig","propertyKey","args","methodConfig","getMethodConfig","method","Error","String","classConfig","pathParams","queryParams","body","extractBoundParams","getParamBindings","refAxios","axios","baseURL","defaults","composedUrl","composeDecoratedUrl","url","resolvePathParams","isAbsoluteHttpUrl","params","mergeRecords","plugins","transformRequest","normalizeArray","transformResponse","data","undefined","headers","mergeHeaders","length","methodId","baseExecutor","config","request","toAxiosRequestConfig","executeHttpCall","originalMethod","resolvedConfig","context","executor","reverse","reduce","next","plugin","isAxiosInstance","value","request","normalizeMethodConfig","config","method","url","normalizeClassConfig","isAbsoluteHttpUrl","baseURL","refAxios","wrapHttpMethod","target","propertyKey","descriptor","isMethodWrapped","originalMethod","Error","String","wrappedHttpMethod","args","executeHttpCall","markMethodWrapped","createHttpMethodDecorator","undefined","existing","getMethodConfig","mergeMethodConfig","HttpApi","mergeClassConfig","Get","Post","Put","Delete","Patch","Options","Head","createParamDecorator","kind","name","target","propertyKey","parameterIndex","undefined","Error","addParamBinding","index","BodyParam","PathParam","QueryParam","sleep","delay","Promise","resolve","setTimeout","useRequest","requester","useRetry","options","count","signal","shouldRetry","args","attempt","lastError","aborted","reason","Error","error","useDebounce","immediate","timer","latestArgs","pending","flush","resolvers","undefined","result","forEach","item","reject","push","shouldCallImmediately","clearTimeout","createSingleConfigPlugin","factory","wrapped","next","config","createRetryPlugin","createDebouncePlugin","createThrottlePlugin","useThrottle","interval","active","trailingArgs","trailingResolvers","run","nextArgs","nextResolvers","withHttpMethodConfig","config","target","propertyKey","undefined","Error","mergeMethodConfig","withHttpClassConfig","mergeClassConfig","withHttpMethodPlugins","plugins","withHttpClassPlugins","TransformRequest","transformRequest","Array","isArray","TransformResponse","transformResponse","RefAxios","refAxios","AxiosRef","Retry","options","createRetryPlugin","Debounce","createDebouncePlugin","Throttle","createThrottlePlugin","SignalController","controller","AbortController","signal","abort","reason","enable","aborted","axiosPlus","axios"]}
@@ -0,0 +1,102 @@
1
+ import * as axios from 'axios';
2
+ import { AxiosRequestConfig, AxiosInstance, Method, AxiosResponse, AxiosRequestTransformer, AxiosResponseTransformer } from 'axios';
3
+
4
+ type MethodKey = string | symbol;
5
+ type ApiCall<TData = unknown, TRequest = unknown> = Promise<AxiosResponse<TData, TRequest>>;
6
+ interface HttpRuntimeContext {
7
+ instance: unknown;
8
+ target: object;
9
+ propertyKey: MethodKey;
10
+ methodId: string;
11
+ args: unknown[];
12
+ originalMethod: (...args: any[]) => unknown;
13
+ }
14
+ interface HttpMethodConfig<TRequestData = unknown> extends AxiosRequestConfig<TRequestData> {
15
+ refAxios?: AxiosInstance;
16
+ plugins?: HttpRuntimePlugin[];
17
+ }
18
+ type HttpMethodDecoratorConfig<TRequestData = unknown> = HttpMethodConfig<TRequestData>;
19
+ interface HttpApiConfig<TRequestData = unknown> extends Omit<HttpMethodConfig<TRequestData>, 'method'> {
20
+ }
21
+ interface ResolvedHttpRequestConfig<TRequestData = unknown> extends HttpMethodConfig<TRequestData> {
22
+ method: Method;
23
+ methodId: string;
24
+ refAxios: AxiosInstance;
25
+ }
26
+ type HttpRequestExecutor = <TResponse = unknown, TRequestData = unknown>(config: ResolvedHttpRequestConfig<TRequestData>) => Promise<AxiosResponse<TResponse, TRequestData>>;
27
+ type HttpRuntimePlugin = (next: HttpRequestExecutor, context: HttpRuntimeContext) => HttpRequestExecutor;
28
+ type ParamBindingKind = 'path' | 'query' | 'body';
29
+ interface ParamBinding {
30
+ index: number;
31
+ kind: ParamBindingKind;
32
+ name?: string;
33
+ }
34
+
35
+ declare function HttpApi(config?: HttpApiConfig | string | AxiosInstance): ClassDecorator;
36
+ declare const Get: (config?: HttpMethodConfig | string) => MethodDecorator;
37
+ declare const Post: (config?: HttpMethodConfig | string) => MethodDecorator;
38
+ declare const Put: (config?: HttpMethodConfig | string) => MethodDecorator;
39
+ declare const Delete: (config?: HttpMethodConfig | string) => MethodDecorator;
40
+ declare const Patch: (config?: HttpMethodConfig | string) => MethodDecorator;
41
+ declare const Options: (config?: HttpMethodConfig | string) => MethodDecorator;
42
+ declare const Head: (config?: HttpMethodConfig | string) => MethodDecorator;
43
+
44
+ declare function BodyParam(name?: string): ParameterDecorator;
45
+ declare function PathParam(name: string): ParameterDecorator;
46
+ declare function QueryParam(name: string): ParameterDecorator;
47
+
48
+ interface RetryOptions {
49
+ count?: number;
50
+ delay?: number;
51
+ signal?: AbortSignal;
52
+ shouldRetry?: (error: unknown, attempt: number) => boolean;
53
+ }
54
+ interface DebounceOptions {
55
+ delay?: number;
56
+ immediate?: boolean;
57
+ }
58
+ interface ThrottleOptions {
59
+ interval?: number;
60
+ }
61
+ type AsyncFn<TArgs extends unknown[], TResult> = (...args: TArgs) => Promise<TResult>;
62
+ declare function useRequest<TArgs extends unknown[], TResult>(requester: AsyncFn<TArgs, TResult>): AsyncFn<TArgs, TResult>;
63
+ declare function useRetry<TArgs extends unknown[], TResult>(requester: AsyncFn<TArgs, TResult>, options?: RetryOptions): AsyncFn<TArgs, TResult>;
64
+ declare function useDebounce<TArgs extends unknown[], TResult>(requester: AsyncFn<TArgs, TResult>, options?: DebounceOptions): AsyncFn<TArgs, TResult>;
65
+ declare function createRetryPlugin(options?: RetryOptions): HttpRuntimePlugin;
66
+ declare function createDebouncePlugin(options?: DebounceOptions): HttpRuntimePlugin;
67
+ declare function createThrottlePlugin(options?: ThrottleOptions): HttpRuntimePlugin;
68
+ declare function useThrottle<TArgs extends unknown[], TResult>(requester: AsyncFn<TArgs, TResult>, options?: ThrottleOptions): AsyncFn<TArgs, TResult>;
69
+
70
+ declare function withHttpMethodConfig(config: Partial<HttpMethodConfig>): MethodDecorator;
71
+ declare function withHttpClassConfig(config: Partial<HttpApiConfig>): ClassDecorator;
72
+ declare function withHttpMethodPlugins(...plugins: HttpRuntimePlugin[]): MethodDecorator;
73
+ declare function withHttpClassPlugins(...plugins: HttpRuntimePlugin[]): ClassDecorator;
74
+ declare function TransformRequest(transformRequest: AxiosRequestTransformer | AxiosRequestTransformer[]): MethodDecorator;
75
+ declare function TransformResponse(transformResponse: AxiosResponseTransformer | AxiosResponseTransformer[]): MethodDecorator;
76
+ declare function RefAxios(refAxios: AxiosInstance): ClassDecorator;
77
+ declare function AxiosRef(refAxios: AxiosInstance): MethodDecorator;
78
+ declare function Retry(options?: RetryOptions): MethodDecorator;
79
+ declare function Debounce(options?: DebounceOptions): MethodDecorator;
80
+ declare function Throttle(options?: ThrottleOptions): MethodDecorator;
81
+
82
+ declare function executeHttpCall(instance: unknown, target: object, propertyKey: MethodKey, originalMethod: (...args: any[]) => unknown, args: unknown[]): Promise<axios.AxiosResponse<unknown, unknown>>;
83
+
84
+ declare class SignalController {
85
+ private controller;
86
+ get signal(): AbortSignal;
87
+ abort(reason?: string): void;
88
+ enable(): void;
89
+ }
90
+
91
+ declare function isAbsoluteHttpUrl(value?: string): value is string;
92
+ declare function joinPathname(...parts: Array<string | undefined>): string;
93
+ declare function composeDecoratedUrl(classUrl?: string, methodUrl?: string): string;
94
+ declare function resolvePathParams(url: string, params: Record<string, unknown>): string;
95
+ declare function resolveAbsoluteHttpTarget(baseURL: string | undefined, url: string): {
96
+ origin: string;
97
+ pathname: string;
98
+ };
99
+
100
+ declare const axiosPlus: axios.AxiosStatic;
101
+
102
+ export { type ApiCall, AxiosRef, BodyParam, Debounce, Delete, Get, Head, HttpApi, type HttpApiConfig, type HttpMethodConfig, type HttpMethodDecoratorConfig, type HttpRequestExecutor, type HttpRuntimeContext, type HttpRuntimePlugin, type MethodKey, Options, type ParamBinding, type ParamBindingKind, Patch, PathParam, Post, Put, QueryParam, RefAxios, type ResolvedHttpRequestConfig, Retry, SignalController, Throttle, TransformRequest, TransformResponse, axiosPlus, composeDecoratedUrl, createDebouncePlugin, createRetryPlugin, createThrottlePlugin, executeHttpCall, isAbsoluteHttpUrl, joinPathname, resolveAbsoluteHttpTarget, resolvePathParams, useDebounce, useRequest, useRetry, useThrottle, withHttpClassConfig, withHttpClassPlugins, withHttpMethodConfig, withHttpMethodPlugins };
@@ -0,0 +1,102 @@
1
+ import * as axios from 'axios';
2
+ import { AxiosRequestConfig, AxiosInstance, Method, AxiosResponse, AxiosRequestTransformer, AxiosResponseTransformer } from 'axios';
3
+
4
+ type MethodKey = string | symbol;
5
+ type ApiCall<TData = unknown, TRequest = unknown> = Promise<AxiosResponse<TData, TRequest>>;
6
+ interface HttpRuntimeContext {
7
+ instance: unknown;
8
+ target: object;
9
+ propertyKey: MethodKey;
10
+ methodId: string;
11
+ args: unknown[];
12
+ originalMethod: (...args: any[]) => unknown;
13
+ }
14
+ interface HttpMethodConfig<TRequestData = unknown> extends AxiosRequestConfig<TRequestData> {
15
+ refAxios?: AxiosInstance;
16
+ plugins?: HttpRuntimePlugin[];
17
+ }
18
+ type HttpMethodDecoratorConfig<TRequestData = unknown> = HttpMethodConfig<TRequestData>;
19
+ interface HttpApiConfig<TRequestData = unknown> extends Omit<HttpMethodConfig<TRequestData>, 'method'> {
20
+ }
21
+ interface ResolvedHttpRequestConfig<TRequestData = unknown> extends HttpMethodConfig<TRequestData> {
22
+ method: Method;
23
+ methodId: string;
24
+ refAxios: AxiosInstance;
25
+ }
26
+ type HttpRequestExecutor = <TResponse = unknown, TRequestData = unknown>(config: ResolvedHttpRequestConfig<TRequestData>) => Promise<AxiosResponse<TResponse, TRequestData>>;
27
+ type HttpRuntimePlugin = (next: HttpRequestExecutor, context: HttpRuntimeContext) => HttpRequestExecutor;
28
+ type ParamBindingKind = 'path' | 'query' | 'body';
29
+ interface ParamBinding {
30
+ index: number;
31
+ kind: ParamBindingKind;
32
+ name?: string;
33
+ }
34
+
35
+ declare function HttpApi(config?: HttpApiConfig | string | AxiosInstance): ClassDecorator;
36
+ declare const Get: (config?: HttpMethodConfig | string) => MethodDecorator;
37
+ declare const Post: (config?: HttpMethodConfig | string) => MethodDecorator;
38
+ declare const Put: (config?: HttpMethodConfig | string) => MethodDecorator;
39
+ declare const Delete: (config?: HttpMethodConfig | string) => MethodDecorator;
40
+ declare const Patch: (config?: HttpMethodConfig | string) => MethodDecorator;
41
+ declare const Options: (config?: HttpMethodConfig | string) => MethodDecorator;
42
+ declare const Head: (config?: HttpMethodConfig | string) => MethodDecorator;
43
+
44
+ declare function BodyParam(name?: string): ParameterDecorator;
45
+ declare function PathParam(name: string): ParameterDecorator;
46
+ declare function QueryParam(name: string): ParameterDecorator;
47
+
48
+ interface RetryOptions {
49
+ count?: number;
50
+ delay?: number;
51
+ signal?: AbortSignal;
52
+ shouldRetry?: (error: unknown, attempt: number) => boolean;
53
+ }
54
+ interface DebounceOptions {
55
+ delay?: number;
56
+ immediate?: boolean;
57
+ }
58
+ interface ThrottleOptions {
59
+ interval?: number;
60
+ }
61
+ type AsyncFn<TArgs extends unknown[], TResult> = (...args: TArgs) => Promise<TResult>;
62
+ declare function useRequest<TArgs extends unknown[], TResult>(requester: AsyncFn<TArgs, TResult>): AsyncFn<TArgs, TResult>;
63
+ declare function useRetry<TArgs extends unknown[], TResult>(requester: AsyncFn<TArgs, TResult>, options?: RetryOptions): AsyncFn<TArgs, TResult>;
64
+ declare function useDebounce<TArgs extends unknown[], TResult>(requester: AsyncFn<TArgs, TResult>, options?: DebounceOptions): AsyncFn<TArgs, TResult>;
65
+ declare function createRetryPlugin(options?: RetryOptions): HttpRuntimePlugin;
66
+ declare function createDebouncePlugin(options?: DebounceOptions): HttpRuntimePlugin;
67
+ declare function createThrottlePlugin(options?: ThrottleOptions): HttpRuntimePlugin;
68
+ declare function useThrottle<TArgs extends unknown[], TResult>(requester: AsyncFn<TArgs, TResult>, options?: ThrottleOptions): AsyncFn<TArgs, TResult>;
69
+
70
+ declare function withHttpMethodConfig(config: Partial<HttpMethodConfig>): MethodDecorator;
71
+ declare function withHttpClassConfig(config: Partial<HttpApiConfig>): ClassDecorator;
72
+ declare function withHttpMethodPlugins(...plugins: HttpRuntimePlugin[]): MethodDecorator;
73
+ declare function withHttpClassPlugins(...plugins: HttpRuntimePlugin[]): ClassDecorator;
74
+ declare function TransformRequest(transformRequest: AxiosRequestTransformer | AxiosRequestTransformer[]): MethodDecorator;
75
+ declare function TransformResponse(transformResponse: AxiosResponseTransformer | AxiosResponseTransformer[]): MethodDecorator;
76
+ declare function RefAxios(refAxios: AxiosInstance): ClassDecorator;
77
+ declare function AxiosRef(refAxios: AxiosInstance): MethodDecorator;
78
+ declare function Retry(options?: RetryOptions): MethodDecorator;
79
+ declare function Debounce(options?: DebounceOptions): MethodDecorator;
80
+ declare function Throttle(options?: ThrottleOptions): MethodDecorator;
81
+
82
+ declare function executeHttpCall(instance: unknown, target: object, propertyKey: MethodKey, originalMethod: (...args: any[]) => unknown, args: unknown[]): Promise<axios.AxiosResponse<unknown, unknown>>;
83
+
84
+ declare class SignalController {
85
+ private controller;
86
+ get signal(): AbortSignal;
87
+ abort(reason?: string): void;
88
+ enable(): void;
89
+ }
90
+
91
+ declare function isAbsoluteHttpUrl(value?: string): value is string;
92
+ declare function joinPathname(...parts: Array<string | undefined>): string;
93
+ declare function composeDecoratedUrl(classUrl?: string, methodUrl?: string): string;
94
+ declare function resolvePathParams(url: string, params: Record<string, unknown>): string;
95
+ declare function resolveAbsoluteHttpTarget(baseURL: string | undefined, url: string): {
96
+ origin: string;
97
+ pathname: string;
98
+ };
99
+
100
+ declare const axiosPlus: axios.AxiosStatic;
101
+
102
+ export { type ApiCall, AxiosRef, BodyParam, Debounce, Delete, Get, Head, HttpApi, type HttpApiConfig, type HttpMethodConfig, type HttpMethodDecoratorConfig, type HttpRequestExecutor, type HttpRuntimeContext, type HttpRuntimePlugin, type MethodKey, Options, type ParamBinding, type ParamBindingKind, Patch, PathParam, Post, Put, QueryParam, RefAxios, type ResolvedHttpRequestConfig, Retry, SignalController, Throttle, TransformRequest, TransformResponse, axiosPlus, composeDecoratedUrl, createDebouncePlugin, createRetryPlugin, createThrottlePlugin, executeHttpCall, isAbsoluteHttpUrl, joinPathname, resolveAbsoluteHttpTarget, resolvePathParams, useDebounce, useRequest, useRetry, useThrottle, withHttpClassConfig, withHttpClassPlugins, withHttpMethodConfig, withHttpMethodPlugins };