export type IRType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null" | "enum" | "union" | "intersection" | "literal" | "any" | "unknown" | "never" | "tuple" | "namedTypeRef"; export interface IRNode { signature?: string; /** * The base type of the IR node. */ type: IRType; /** * Optional name for the node (useful for objects, enums, etc.). */ name?: string; /** * For `namedTypeRef` nodes: the external, already-defined type name to emit * verbatim (e.g. "Message"). The node is a reference, not a definition — its * body is not recursed into and it is never extracted. */ namedType?: string; /** * Dot notation path to the node in a runtime object. * For example, "user.profile.name". */ path: string; /** * Indicates whether this property/node is required. * For object properties, this can be derived from the JSON Schema 'required' array. */ required?: boolean; /** * For object types: a mapping of property names to their IR node definitions. */ properties?: { [key: string]: IRNode; }; /** * For object types: indicates whether additional properties are allowed and their type if so. */ additionalProperties?: IRNode | boolean; /** * For array types: the IR node representing the type of items in the array. */ items?: IRNode; /** * For enum types: a list of allowed literal values. */ values?: any[]; /** * For union or intersection types: an array of candidate IR nodes. * Note: This is used regardless of whether the union originated from a 'oneOf' or an 'anyOf'. */ options?: IRNode[]; /** * Additional constraints such as minimum, maximum, pattern, etc. */ constraints?: { [key: string]: any; combinator?: "oneOf" | "anyOf"; maxLength?: number; minLength?: number; pattern?: string; maximum?: number; minimum?: number; exclusiveMinimum?: number; exclusiveMaximum?: number; minItems?: number; maxItems?: number; uniqueItems?: boolean; minProperties?: number; maxProperties?: number; format?: string; value?: any; }; /** * For tuple types: ordered array of IR nodes representing positional item types. */ tupleItems?: IRNode[]; /** * Short label from JSON Schema 'title' keyword. */ title?: string; /** * Human-readable description from JSON Schema 'description' keyword. */ description?: string; /** * Default value from JSON Schema 'default' keyword. */ defaultValue?: unknown; /** * For 'not' keyword: the IR node representing the negated schema. */ not?: IRNode; /** * Conditional schema from JSON Schema if/then/else keywords. */ conditional?: { if: IRNode; then?: IRNode; else?: IRNode; }; /** * For object types with patternProperties: maps regex pattern strings to their value schemas. */ patternProperties?: { [pattern: string]: IRNode; }; } export type SignatureOccurrenceValue = { occurrences: { node: IRNode; nodePath: string; count: number; }[]; signature: string; total: number; }; export type SignatureOccurrences = Map; export interface Context { signatureOccurrences: SignatureOccurrences; } export interface ILanguageConverter { /** The target language (e.g., "typescript", "python", "dart"). */ readonly language: string; /** The generated code output. */ readonly code: string; } /** @deprecated Use ILanguageConverter instead */ export type LanguagePlugin = ILanguageConverter; export interface ConverterOptions { additionalProperties?: boolean; validateSchema?: boolean; transform?: (ir: IRNode) => IRNode; untypedFallback?: "any" | "unknown" | "object"; }