import type { CollectionSchemaBase } from './dsl.js'; import type { DtoField } from './dto.js'; /** A reference to a field within another schema. Carries a .schema back-reference * so the driver knows where the data comes from (route params, page data, etc.). */ export interface RefSchema { name: string; /** Schema back-reference — tells driver the data source. */ schema: CollectionSchemaBase; /** The referenced field instance. */ field: DtoField; } /** Create a reference to a field in a source schema. * Writes back field.schema to the source so the driver can trace origin. */ export function defineRef(source: CollectionSchemaBase, field: DtoField): RefSchema { field.schema = source; return { name: field.name, schema: source, field }; }