import type { Filter } from './adapters/types.js'; import type { RelationGraph } from './introspection/relations.js'; import type { Model } from './types/schema.js'; export interface AdminPlugin { name: string; pages?: AdminPluginPage[]; recordActions?: AdminPluginRecordAction[]; } export interface AdminPluginPage { pattern: string[]; models?: string[]; render: (ctx: PluginPageContext) => PluginPageResult | Promise; } export interface PluginPageResult { html: string; styles?: string; scripts?: string; } export interface AdminPluginRecordAction { label: string; models?: string[]; href: (ctx: { model: string; id: string | number; basePath: string; }) => string; } export interface PluginPageContext { event: any; route: { view: string; model?: string; id?: string; }; basePath: string; /** Set only when the page pattern captures `:id` (after a 404 skip). */ record?: Record; escapeHtml: (s: string) => string; findModel: (name?: string) => Model | undefined; relationGraph: RelationGraph | null; resolveLabel: (target: Model, row: Record, labelTemplate?: string) => string; hiddenFieldsOf: (model: Model) => Set; isSensitiveFieldName: (name: string) => boolean; loadRecord: (modelName: string, id: string | number) => Promise | null>; listRecords: (modelName: string, extraFilter?: Filter) => Promise[]>; getM2mSelectedIds: (modelName: string, fieldName: string, recordId: string | number) => Promise>; }