import type { APITemplateType, APIAnyTemplate, APIPageTemplate, APIComponentTemplate, APIDataTemplate, LinkDefinition, Migration } from '@dosgato/templating'; import type { FastifyRequest } from 'fastify'; import { DateTime } from 'luxon'; import { TemplateArea, type DGContextClass, type DGContext } from '../internal.js'; import type { DGStartOpts } from '../index.js'; interface HasHydratedAreas { getLinks: (data: any) => LinkDefinition[]; hydratedAreas: Record; disallowSet: Set; } type PageTemplate = Omit & HasHydratedAreas; type ComponentTemplate = Omit & HasHydratedAreas; type DataTemplate = Omit & HasHydratedAreas; type AnyTemplate = PageTemplate | ComponentTemplate | DataTemplate; export type DGRestrictOperations = 'move' | 'delete' | 'rename' | 'changetemplate' | 'unpublish' | 'into'; declare class TemplateRegistry { protected byType: { page: PageTemplate[]; component: ComponentTemplate[]; data: DataTemplate[]; }; protected byKey: Record; protected migrations: (Migration & { templateKey: string; isPage: boolean; })[]; migrationsForward: (Migration & { templateKey: string; isPage: boolean; })[]; migrationsBackward: (Migration & { templateKey: string; isPage: boolean; })[]; /** * The schema version this API stores data at. Derived from the newest migration registered * across all page, component and data templates, so it advances exactly when a migration is * added and can never fall behind a migration that exists in the build. Falls back to startup * time when no template defines a migration, in which case the value cannot matter. */ currentSchemaVersion: DateTime; serverConfig: Omit & { customContext: DGContextClass; }; register(template: APIAnyTemplate): void; sortMigrations(): void; /** * Use this function to extend a component after importing it. For instance, * if another developer writes a component for a carded layout, and you write a new * card that fits in that layout, you can add your custom card to its availableComponents * while constructing your individual CMS server. */ addAvailableComponent(templateKey: string, area: string, availableComponent: string): void; get(templateKey: string): AnyTemplate; getDataTemplate(templateKey: string): DataTemplate; getPageTemplate(templateKey: string): PageTemplate; getComponentTemplate(templateKey: string): ComponentTemplate; getPageOrComponentTemplate(templateKey: string): PageTemplate | ComponentTemplate; getType(type: APITemplateType): PageTemplate[] | ComponentTemplate[] | DataTemplate[]; getCtx(req: FastifyRequest): Promise; } export declare const templateRegistry: TemplateRegistry; export {};