/** * @omnify/ts — Form Field Metadata Generator (issue omnify-jp/omnify-go#54) * * Emits a `Metadata` constant alongside the existing generated * `base/.ts`. The constant is a flat description of every field's * type, validation rules, translatable flag, enum binding, label, and * placeholder dictionaries. * * Downstream tools (forms, stories, smoke tests, validation, headless form * runners) read from this single source of truth instead of each project * rolling its own per-model lookup tables. * * The metadata is a *new* artifact emitted in addition to the existing * interface, zod schemas, and i18n object — none of those are modified. */ import type { GeneratorOptions, PropertyDefinition, SchemaDefinition, SchemaDisplayNames } from './types.js'; /** Coarse field-type taxonomy that downstream form runners switch on. */ export type MetadataFieldType = 'string' | 'text' | 'number' | 'boolean' | 'date' | 'datetime' | 'time' | 'json' | 'enum' | 'uuid' | 'file' | 'compound'; /** Per-field entry in the metadata constant. */ export interface MetadataField { /** Coarse field type (see taxonomy above). */ type: MetadataFieldType; /** Whether the field is required by the create schema. */ required: boolean; /** Whether the YAML declared the field nullable. */ nullable: boolean; /** Whether the YAML declared the field translatable. */ translatable: boolean; /** Validation rules that apply to this field type. Empty object if none. */ validation: Record; /** Enum name (only for `type: 'enum'`). */ enum?: string; /** Enum value list (only for `type: 'enum'`); always emitted with `as const`. */ enumValues?: readonly string[]; /** Relation info (only for `type: 'uuid'`/'number' association FK). */ relation?: { model: string; table?: string; onDelete?: string; }; /** Compound type identifier (only for `type: 'compound'`). */ compoundType?: string; /** Localized label dictionary (locale → string). */ label: Record; /** Localized placeholder dictionary (locale → string). Optional. */ placeholder?: Record; /** Localized description dictionary (locale → string). Optional. Issue #59. */ description?: Record; } /** Aggregations exported alongside the per-field entries for ergonomics. */ export interface MetadataAggregations { translatableFields: string[]; requiredFields: string[]; enumFields: string[]; relationFields: string[]; } /** Resolved metadata for a single schema. */ export interface SchemaMetadata { modelName: string; table?: string; fields: Record; aggregations: MetadataAggregations; } /** * Map a YAML property to the coarse metadata type taxonomy. Used by both * #54 (metadata generator) and #55 (payload builder) so the two stay in * lockstep. */ export declare function classifyFieldType(prop: PropertyDefinition, allSchemas: Record, customSimpleTypes: Record): MetadataFieldType; /** * Build the metadata IR for a single schema. Pure function — formatter * does the string work. */ export declare function buildSchemaMetadata(schema: SchemaDefinition, allSchemas: Record, options: GeneratorOptions, displayNames: SchemaDisplayNames): SchemaMetadata; /** Render the SchemaMetadata IR to a TypeScript const literal block. */ export declare function formatMetadataConst(meta: SchemaMetadata): string;