/** * Per-field copies of Prisma's shared `FieldUpdateOperationsInput`. * * An update offers two ways to write the same column: * * data: { label: 'nope' } * data: { label: { set: 'nope' } } * * and the emitted property line is a union of the two: * * z.union([Typed, z.lazy(() => StringFieldUpdateOperationsInputObjectSchema)]) * * `StringFieldUpdateOperationsInput` is shared by every String column in the schema, so * it cannot carry one column's annotation. Left as it is, the second arm accepts what * the first one rejects and the annotation constrains nothing. * * The fix is a copy of the shared input per annotated column - `Post.label` gets * `PostLabelFieldUpdateOperationsInput` - with the reference rewritten to point at it. * Every unannotated column keeps pointing at the shared input, which itself is never * touched. * * This module only plans. It rewrites the DMMF the emitters read and hands back a * lookup; the schemas themselves are emitted by the ordinary object-schema path, so a * copy is byte-identical to the shared input apart from the members that carry values. */ import type { DMMF } from '@prisma/generator-helper'; import type { ResolvedTypedJsonConfig } from '../config/typed-json'; /** The model column a copy's value members take their annotation from. */ export interface TypedFieldUpdateOperationsTarget { modelName: string; field: DMMF.Field; } interface VariantRecord extends TypedFieldUpdateOperationsTarget { /** The shared input this was copied from, which is also its Prisma type. */ sharedName: string; } /** * What the emitters need to know about the copies: which schema names are copies, what * column each one belongs to, and which Prisma type it still binds to. */ export declare class TypedFieldUpdateOperationsPlan { private readonly variants; constructor(variants?: ReadonlyMap); get size(): number; /** * The column a member of `schemaName` takes its annotation from, or null when * `schemaName` is not a copy or the member is not one that holds a value. * * `set` is the only member of an update-operations input that holds a value of the * column. `increment` and its siblings are arithmetic on whatever is already stored, * so an annotation has no business narrowing them: an Int column typed `1 | 2` is * still incremented by 5. */ targetFor(schemaName: string, memberName: string): TypedFieldUpdateOperationsTarget | null; /** The model a copy belongs to, for resolving the imports its file needs. */ ownerOf(schemaName: string): string | null; /** * The Prisma type a copy binds to. * * There is no `Prisma.PostLabelFieldUpdateOperationsInput`; the copy is structurally * the shared input and binds to that, so the emitted file still typechecks against the * client. */ prismaTypeNameFor(schemaName: string): string | null; } export declare const EMPTY_TYPED_FIELD_UPDATE_OPERATIONS_PLAN: TypedFieldUpdateOperationsPlan; export interface PlanTypedFieldUpdateOperationsArgs { inputObjectTypes: DMMF.InputType[]; models: DMMF.Model[]; config: ResolvedTypedJsonConfig | null | undefined; /** * The model an input-object schema's members refer to, as the emitters read it. * Injected rather than imported so this module stays free of the transformer. */ extractModelName: (schemaName: string) => string | null; } export interface PlanTypedFieldUpdateOperationsResult { /** The input types to emit: the originals, with references rewritten, plus the copies. */ inputObjectTypes: DMMF.InputType[]; plan: TypedFieldUpdateOperationsPlan; } /** * Plan the copies and rewrite the references to them. * * With no `typedJson` block this returns the input untouched and an empty plan, so * nothing downstream behaves differently and the output is byte-identical. */ export declare function planTypedFieldUpdateOperations(args: PlanTypedFieldUpdateOperationsArgs): PlanTypedFieldUpdateOperationsResult; export {};