import { Collection, Config, Singleton } from "../config.js"; import { ComponentSchema, ObjectField, SlugFormField, ValueForReading, ValueForReadingDeep } from "../form/api.js"; type EntryReaderOpts = { resolveLinkedFiles?: boolean; }; type ValueForReadingWithMode = ResolveLinkedFiles extends true ? ValueForReadingDeep : ValueForReading; type OptionalChain = T extends {} ? T[Key] : undefined; export type Entry | Singleton> = CollectionOrSingleton extends Collection ? CollectionEntry : CollectionOrSingleton extends Singleton ? SingletonEntry : never; export type EntryWithResolvedLinkedFiles | Singleton> = CollectionOrSingleton extends Collection ? CollectionEntryWithResolvedLinkedFiles : CollectionOrSingleton extends Singleton ? SingletonEntryWithResolvedLinkedFiles : never; type CollectionEntryWithResolvedLinkedFiles, SlugField extends string> = { [Key in keyof Schema]: SlugField extends Key ? Schema[Key] extends SlugFormField ? SlugSerializedValue : ValueForReadingDeep : ValueForReadingDeep; }; type CollectionEntry, SlugField extends string> = { [Key in keyof Schema]: SlugField extends Key ? Schema[Key] extends SlugFormField ? SlugSerializedValue : ValueForReading : ValueForReading; }; type SingletonEntryWithResolvedLinkedFiles> = ValueForReadingDeep>; type SingletonEntry> = ValueForReading>; export type CollectionReader, SlugField extends string> = { read: (slug: string, ...opts: Opts & [opts?: EntryReaderOpts]) => Promise<{ [Key in keyof Schema]: SlugField extends Key ? Schema[Key] extends SlugFormField ? SlugSerializedValue : ValueForReadingWithMode> : ValueForReadingWithMode>; } | null>; readOrThrow: (slug: string, ...opts: Opts & [opts?: EntryReaderOpts]) => Promise<{ [Key in keyof Schema]: SlugField extends Key ? Schema[Key] extends SlugFormField ? SlugSerializedValue : ValueForReadingWithMode> : ValueForReadingWithMode>; }>; all: (...opts: Opts & [opts?: EntryReaderOpts]) => Promise<{ slug: string; entry: { [Key in keyof Schema]: SlugField extends Key ? Schema[Key] extends SlugFormField ? SlugSerializedValue : ValueForReadingWithMode> : ValueForReadingWithMode>; }; }[]>; list: () => Promise; }; export type SingletonReader> = { read: (...opts: Opts & [opts?: EntryReaderOpts]) => Promise, OptionalChain> | null>; readOrThrow: (...opts: Opts & [opts?: EntryReaderOpts]) => Promise, OptionalChain>>; }; export type DirEntry = { name: string; kind: 'file' | 'directory'; }; export type MinimalFs = { readFile(path: string): Promise; readdir(path: string): Promise; fileExists(path: string): Promise; }; export declare function collectionReader(collection: string, config: Config, fsReader: MinimalFs): CollectionReader; export declare function singletonReader(singleton: string, config: Config, fsReader: MinimalFs): SingletonReader; export type BaseReader, string>; }, Singletons extends { [key: string]: Singleton>; }> = { collections: { [Key in keyof Collections]: CollectionReader; }; singletons: { [Key in keyof Singletons]: SingletonReader; }; config: Config; }; export {};