import { type Code } from "ts-poet"; import { MetaObject } from "@metaobjectsdev/metadata"; import { type RenderContext } from "../render-context.js"; /** * FR-017 Tier 1 — when this object is a TPH subtype (@discriminatorValue set * and an ancestor carries @discriminator), return the discriminator-field-name * → pinned-literal-value pair. Subtypes emit `: z.literal("")` * instead of the inherited field's normal type expression. Returns undefined * when the object is not a TPH subtype. */ export declare function tphDiscriminatorPin(obj: MetaObject): { fieldName: string; value: string; } | undefined; /** True when this object is a TPH subtype — it declares @discriminatorValue * and an ancestor carries @discriminator. */ export declare function isTphSubtype(obj: MetaObject): boolean; /** True when this object declares at least one @autoSet timestamp field * (onCreate or onUpdate). Drives whether codegen emits the #203 * `InsertPreservingSchema` + `insertPreserving` escape hatch — * a plain entity has nothing to preserve, so both are omitted. Resolving * (ADR-0039): honors an @autoSet inherited via extends. */ export declare function hasAutoSetFields(obj: MetaObject): boolean; /** * FR-017 Tier 2 — the per-subtype FULL read schema `Schema`. Unlike the * insert schema, this includes every effective field (PK included) so a raw DB * row parses through it. The discriminator field is pinned to its literal value * (`type: z.literal("Bridge")`) so the schema rejects a row of another subtype. * * This is the schema parse(row) dispatches to (see tph-discriminator.ts). * Non-required columns are `.nullable()`-tolerant: a nullable TPH column read * back from the DB arrives as `null`, not `undefined`, so the read schema must * accept null (the insert schema, by contrast, makes them `.optional()`). */ export declare function renderTphSubtypeReadSchema(obj: MetaObject, ctx?: RenderContext): Code; /** Field names participating in the object's PRIMARY identity, normalized to a * list. Empty when the object has no primary identity. Exported for the * view-decl read-schema path, which must type PK columns non-null too. */ export declare function primaryIdentityFieldNames(obj: MetaObject): string[]; /** * Emit ONLY the `InsertSchema`. Used by the value-object file emitter * for metaobjects with no writable source.rdb — those have no PATCH/update * semantics, so emitting an UpdateSchema would be misleading. * * The schema name is kept as `InsertSchema` even for pure value objects * so consumer imports don't churn. A future polish PR could add a `Schema` * alias for clarity. */ export declare function renderInsertSchemaOnly(obj: MetaObject, ctx?: RenderContext): Code; /** One documented field in an Insert/Update schema's accepted shape. */ export interface SchemaFieldShape { /** The field name (the schema property key). */ name: string; /** Whether the property is optional in the schema (`.optional()` / omitted-OK). */ optional: boolean; /** For the @discriminator field on a TPH subtype's InsertSchema: the pinned * literal value (`z.literal("Bridge")`). Undefined otherwise. */ pinnedLiteral?: string; /** True for @autoSet timestamp fields the schema fills server-side * (`z.string().optional().transform(...)`). */ autoSet?: boolean; } /** * The field SET (name + optionality) the `InsertSchema` accepts — derived * by the SAME iteration + skip rules `renderInsertSchemaOnly` / * `renderZodValidators` use to EMIT that schema, so a documented create-payload * shape can never drift from the real schema: * • auto-generated PK fields are omitted (caller doesn't provide them); * • @readOnly fields are omitted (DB / replication owns the write path); * • a TPH subtype's @discriminator field is a pinned `z.literal(value)`; * • @autoSet fields are present but optional (server fills them); * • an ASSIGNED primary key with no @default is required (see * assignedPkFieldNames — its Drizzle column has no default); * • every other field's optionality is `fieldWillBeOptional` (not required, or * carries a @default). */ export declare function insertSchemaFields(obj: MetaObject): SchemaFieldShape[]; /** * The field SET the `UpdateSchema` accepts — same iteration + skip rules * as `insertSchemaFields`, but mirroring the UpdateSchema branch of * `renderZodValidators`: * • a TPH subtype's @discriminator field is OMITTED (clients can't change subtype); * • @autoSet onCreate fields are OMITTED (creation timestamps are immutable); * • @autoSet onUpdate fields are present + optional (server fills them); * • every other field is optional (PATCH semantics). */ export declare function updateSchemaFields(obj: MetaObject): SchemaFieldShape[]; export declare function renderZodValidators(obj: MetaObject, ctx?: RenderContext): Code; //# sourceMappingURL=zod-validators.d.ts.map