import type { ComputedRef, Ref } from 'vue'; import type eponymeConfig from '#eponyme/config'; import type { EponymeDataByName, EponymeName, EponymeSchema } from '../types/index.js'; import type { EponymePopulateDepth, EponymePopulatedData, EponymeSchemaByName } from '../types/relations.js'; import type { EponymeAction, EponymeSchedule, EponymeStatus, EponymeVersionSelector } from '../server/services/eponyme-store.js'; import type { ValidationErrors } from '../utils/validate-eponyme-data.js'; type ConfigEponymeName = EponymeName; /** A singleton's data with its relations resolved `Depth` levels deep; `0` is the stored shape. */ export type EponymePopulatedDataByName = Depth extends 0 ? EponymeDataByName : EponymeSchemaByName extends infer Schema extends EponymeSchema ? EponymePopulatedData : never; export interface UseEponymeOptions { version?: EponymeVersionSelector; /** Keep `{{ variables }}` unresolved. The dashboard editor needs the source text. */ raw?: boolean; /** * Levels of relations to resolve: each relation then holds its target rather than its slug. A populated * read is for rendering - `save` still expects the stored shape. */ depth?: Depth; } /** Named, and annotated on the function below, rather than left to inference. */ export interface UseEponymeResult, ReadData extends Record = Data> { data: Ref; status: ComputedRef; publishedAt: ComputedRef; scheduledPublishAt: ComputedRef; scheduledUnpublishAt: ComputedRef; /** * The version this data was read at, sent back with every write so a save made against content someone * else has already replaced is refused rather than silently applied. */ revision: ComputedRef; pending: ComputedRef; error: Ref; errors: Ref; refresh: () => Promise; /** Without a patch, saves the data currently held. Publishes unless told otherwise. */ save: (patch?: Partial, action?: EponymeAction, schedule?: EponymeSchedule) => Promise; } /** What the composable hands back: the refs, and a promise resolving to them. */ export type UseEponymeReturn, ReadData extends Record = Data> = UseEponymeResult & Promise>; /** Read and save a configured eponyme through the public or draft API. */ export declare function useEponyme(name: Name, options?: UseEponymeOptions): UseEponymeReturn, EponymePopulatedDataByName>; export {};