/** * @omnify/ts — Payload Builder Generator (issue omnify-jp/omnify-go#55) * * Emits per-model form-state interfaces and payload-builder helpers * alongside the existing zod schemas. Translatable fields are typed as * `Record` in the form state (matching the design * system's `` component shape) and the builder * collapses them into the nested locale-keyed payload that the create / * update zod schemas accept (see issue #53). * * Output (added to base/.ts): * * export interface CreateFormState { ... } * export interface UpdateFormState { ... } * export function emptyCreateForm() { ... } * export function buildCreatePayload(form) { ... } * export function buildUpdatePayload(form) { ... } * * The shared `buildI18nPayload` utility is emitted exactly once at the * codegen output root in `payload-helpers.ts` so per-model files can * import it. */ import type { GeneratorOptions, SchemaDefinition } from './types.js'; import { type MetadataFieldType } from './metadata-generator.js'; /** A single field as seen by the form-state / payload builder. */ export interface FormField { /** Field key as it appears on the wire (snake_case, with `_id` suffix on FKs). */ fieldName: string; /** TypeScript primitive used in the form-state interface. */ tsType: string; /** Coarse type taxonomy from the metadata generator. */ metaType: MetadataFieldType; /** Whether the YAML declared the field translatable. */ translatable: boolean; /** Whether the field is required by the create schema. */ required: boolean; /** Whether the YAML declared the field nullable. */ nullable: boolean; /** Default value for `emptyCreateForm()`, as a JS literal string. */ defaultLiteral: string; /** * When true, the field is intentionally omitted from the * `emptyCreateForm()` factory body. Used for optional enum * reference fields where no sensible default exists — the interface * marks the field `?:` so omitting the key is valid, and this is * safer than emitting `undefined` under `exactOptionalPropertyTypes`. * Issue omnify-jp/omnify-go#56. */ omitFromEmpty?: boolean; } /** Resolved per-schema form metadata. */ export interface SchemaFormShape { modelName: string; fields: FormField[]; } /** Build the form shape IR from a schema. */ export declare function buildFormShape(schema: SchemaDefinition, allSchemas: Record, options: GeneratorOptions): SchemaFormShape; /** Render the full payload-builder section for a schema. */ export declare function formatPayloadBuilderSection(shape: SchemaFormShape, defaultLocale: string): string;