import { type Code } from "ts-poet"; import { type MetaObject, type MetaField, type MetaRoot } from "@metaobjectsdev/metadata"; /** One concrete subtype in a {@link TphPlan}. */ export interface TphSubtypePlan { /** The concrete subtype entity. */ entity: MetaObject; /** Its `@discriminatorValue`. */ value: string; /** The per-subtype REST route segment (e.g. `"bridge"`). The ONE place this * rule is derived — see {@link tphRouteSegment}. */ routeSegment: string; } /** * The single source of truth for a TPH base's polymorphic shape: the * discriminator field name, the concrete subtypes (stable name-sorted order), * each subtype's `@discriminatorValue`, and its per-subtype route segment. * * Every generator in the stack (entity, queries, routes, hooks, grid, forms) * derives its TPH behavior from this one model rather than re-walking the root * and re-deriving the segment / write-shape independently — so the route-segment * rule and subtype set can never drift between, say, the generated routes and * the generated hooks that call them. */ export interface TphPlan { base: MetaObject; discriminatorField: string; subtypes: TphSubtypePlan[]; } /** The per-subtype REST route segment for a discriminator value. The ONE place * this rule lives: `routesFile` and the TanStack hooks both read it through the * plan, so generated hooks can't call a URL the generated routes don't serve. */ export declare function tphRouteSegment(discriminatorValue: string): string; /** The {@link TphPlan} for a discriminator base, or `null` when `base` is not a * discriminator base (no `@discriminator`, or no concrete subtypes). */ export declare function tphPlan(base: MetaObject, root: MetaRoot): TphPlan | null; /** True when this entity is a TPH discriminator base — it carries * `@discriminator` AND at least one concrete subtype declares * `@discriminatorValue` extending it. This is the predicate the generator * stack uses to switch into single-table-inheritance emission. */ export declare function isTphDiscriminatorBase(obj: MetaObject, root: MetaRoot): boolean; /** The concrete subtypes bound to this discriminator base, in stable * (name-sorted) order. Returns `[]` when `base` is not a discriminator base. */ export declare function tphConcreteSubtypes(base: MetaObject, root: MetaRoot): MetaObject[]; /** * The subtype-only fields that must be folded into the base's single TPH table. * For each concrete subtype, every effective field NOT already on the base is * collected (effective, so fields declared on abstract intermediate levels of a * multi-level hierarchy are captured too). Deduplicated by field name across * subtypes — two subtypes sharing a column name contribute one column. The * caller emits each as a nullable column (rows of other subtypes store NULL). */ export declare function collectTphSubtypeFields(base: MetaObject, root: MetaRoot): MetaField[]; /** Render the TPH union + guards + dispatcher block, or null when the entity * is not a discriminator-bearing base with at least one concrete subtype. */ export declare function renderTphDiscriminatorUnion(base: MetaObject, root: MetaRoot): Code | null; //# sourceMappingURL=tph-discriminator.d.ts.map