// deno-lint-ignore-file no-explicit-any import type Collection from "./core/collection.ts"; import type Document from "./core/document.ts"; import type Upload from "./core/upload.ts"; /** Generic data to store */ export type Data = Record; export interface EntryMetadata { name: string; src: string; } export interface SiteInfo { name: string; description?: string; url?: string; } /** A storage mechanism for data */ export interface Storage extends AsyncIterable { name(name: string): string; get(name: string): Entry; directory(name: string): Storage; delete(name: string): Promise; rename(name: string, newName: string): Promise; } export interface Entry { src?: string; metadata: EntryMetadata; readData(): Promise; writeData(content: Data): Promise; readFile(): Promise; writeFile(content: File): Promise; } export interface Version { name: string; isCurrent: boolean; isProduction: boolean; } export interface Versioning extends AsyncIterable { current(): Promise; create(id: string): Promise; change(id: string): Promise; publish(id: string): Promise; delete(id: string): Promise; } /** A transformer to convert from/to Data */ export interface Transformer { toData(content: T): Data | Promise; fromData(data: Data): T | Promise; } /** The schema for a field */ export interface Field { type: string; name: string; value?: unknown; fields?: (Field | string)[]; label?: string; description?: string; options?: Option[]; uploads?: string; publicPath?: string; attributes?: { required?: boolean; min?: number; max?: number; step?: number; maxlength?: number; pattern?: string; [key: string]: unknown; }; init?: (field: ResolvedField) => void | Promise; transform?(value: any, field: ResolvedField): any; [key: string]: unknown; } export interface ResolvedField extends Field { tag: string; label: string; fields?: ResolvedField[]; cmsContent: CMSContent; applyChanges( data: Data, changes: Data, field: ResolvedField, ): void | Promise; } export interface FielType { tag: string; jsImport: string; init?: (field: ResolvedField) => void; applyChanges( data: Data, changes: Data, field: ResolvedField, ): void | Promise; } type Option = string | { value: string | number; label: string }; export interface CMSContent { basePath: string; site: SiteInfo; collections: Record; documents: Record; uploads: Record; versioning?: Versioning; data: Record; }