import { type Code } from "ts-poet"; import { type MetaField } from "@metaobjectsdev/metadata"; import type { ColumnNamingStrategy } from "../metaobjects-config.js"; export interface ViewDeclOpts { readonly dialect: "postgres" | "sqlite"; readonly columnNamingStrategy: ColumnNamingStrategy; /** Drives the timestamp column TS type (Date vs string) in the view declaration. */ readonly timestampMode: "date" | "string"; /** * ADR-0044/#228 — resolve a `field.object` / `field.map`'s `@objectRef` to the * value object's EMITTED name (bare when unique in the run, package-qualified on * a cross-package short-name collision) AND its import module, TOGETHER, so the * imported symbol and its module can never diverge (a bare `Note` symbol pointing * at an `./AcmeAlphaNote.js` module, or vice-versa). Callers build this from * `RenderContext.resolveValueObjectName` + `valueObjectModuleSpecifier`. */ readonly voRef: (field: MetaField) => { name: string; module: string; }; /** * Field names of the owning object's PRIMARY identity (see * `primaryIdentityFieldNames` in zod-validators). A PK column sits on the FROM * side of every synthesized view, so it is never NULL even when the field * carries no `@required` — the view column gets `.notNull()` and the read * schema stays non-nullable, matching the generated api-docs, queries and * UpdateSchema, all of which already treat the PK as non-null. */ readonly pkFieldNames: ReadonlySet; } /** * Emit `export const = (, { …cols }).existing();` for a * view-backed read model (projection or write-through replica view). `fields` are the * view's exposed columns (already resolved to effective fields by the caller). */ export declare function renderExistingViewDecl(fields: readonly MetaField[], viewName: string, viewVar: string, opts: ViewDeclOpts): Code; /** * The Zod object body for a view-backed read model — one `field: z.[.nullable()]` * line per column, the read counterpart of {@link renderExistingViewDecl}. A column that * is not `.notNull()` in the view is `.nullable()` (Drizzle's SELECT infers `T | null`), * so `z.infer<>` of the object equals the view row type. This is the dialect-agnostic read * type (a Drizzle view exposes `$inferSelect` on Postgres but not SQLite). A `field.object` * passthrough carries the value-object's schema so the read type exposes the VO shape. * `voModule` resolves a value-object short name → its import module. */ export declare function renderViewReadZodObject(fields: readonly MetaField[], opts: ViewDeclOpts): Code; //# sourceMappingURL=view-decl.d.ts.map