import { ArrayItems, UnionToIntersection } from "../utils.js"; import { UseFetch, UseFetchOptions } from "./fetch.js"; import { AsyncData, AsyncDataMiddleware, AsyncDataOptions, UseAsyncData, _AsyncData } from "./asyncData.js"; import { FetchOptions } from "ofetch"; //#region src/app/composables/addons.d.ts declare const AddonMarker: unique symbol; type SerializableValue = string | number | boolean | null | undefined | SerializableValue[] | { [key: string]: SerializableValue; }; export type AsyncDataAddonInstance = _AsyncData; export type AsyncDataAddonSetup = (asyncData: AsyncDataAddonInstance) => Ext | void; interface AddonChains { middleware: AsyncDataMiddleware[]; } export type UseAsyncDataAddonOptions = {}> = Omit, 'transform' | 'middleware'> & AddonChains & Opts; export type UseFetchAddonOptions = {}> = Omit, 'transform' | 'middleware' | 'onRequest' | 'onRequestError' | 'onResponse' | 'onResponseError'> & AddonChains & { onRequest: ArrayItems[]; onRequestError: ArrayItems[]; onResponse: ArrayItems[]; onResponseError: ArrayItems[]; } & Opts; export interface UseAsyncDataAddon = {}, Ext = {}> { setup: (options: UseAsyncDataAddonOptions) => AsyncDataAddonSetup | void; /** @internal */ [AddonMarker]?: { options: Opts; extension: Ext; }; } export interface UseFetchAddon = {}, Ext = {}> { /** Segment added to the auto-generated key, derived from custom options that affect the response. */ key?: (options: UseFetchAddonOptions) => SerializableValue; setup: (options: UseFetchAddonOptions) => AsyncDataAddonSetup | void; /** @internal */ [AddonMarker]?: { options: Opts; extension: Ext; }; } /** * Define a reusable addon for composables created with `createUseFetch`. * @since 4.6.0 */ export declare function defineUseFetchAddon = {}, Ext = {}>(addon: UseFetchAddon): UseFetchAddon; /** * Define a reusable addon for composables created with `createUseAsyncData`. * @since 4.6.0 */ export declare function defineUseAsyncDataAddon = {}, Ext = {}>(addon: UseAsyncDataAddon): UseAsyncDataAddon; export type MergedAddonsOptions> = [Addons[number]] extends [never] ? {} : UnionToIntersection; type AddonsExtensions> = UnionToIntersection; export type MergedAddonsExtensions> = [keyof AddonsExtensions] extends [never] ? {} : Omit, PromiseMethod>; declare const PROMISE_METHODS: readonly ["then", "catch", "finally"]; type PromiseMethod = typeof PROMISE_METHODS[number]; /** @internal */ export declare function applyUseFetchAddons(create: (options: Record) => (...args: any[]) => AsyncData, { addons, ...factoryOptions }: Record): UseFetch; /** @internal */ export declare function applyUseAsyncDataAddons(create: (options: Record) => (...args: any[]) => AsyncData, { addons, ...factoryOptions }: Record): UseAsyncData; //#endregion export {};