import type { GeneratorMetadata, PostgresForeignTable, PostgresMaterializedView, PostgresSchema, PostgresTable, PostgresType, PostgresView } from "../types.ts"; export interface GenerateTypescriptOptions { /** * Emit `isOneToOne` on each relationship entry. Mirrors postgres-meta's * `detect_one_to_one_relationships` query flag. Default `false`. */ detectOneToOneRelationships?: boolean; /** * When set, emit `__InternalSupabase.PostgrestVersion` so `createClient` * can be instantiated with the right options automatically. */ postgrestVersion?: string; /** * Schema treated as the default for the generated `Tables`/`Enums`/etc. * helper types. Replaces postgres-meta's `GENERATE_TYPES_DEFAULT_SCHEMA` * env read. Default `'public'`. When it is not among the generated schemas, * the first generated schema is used instead, so the helpers keep resolving. */ defaultSchema?: string; /** * Formatter used on the generated output. Defaults to `oxfmt`, an optional * peer dependency that is imported only when this default runs, so callers * that always pass their own formatter need not install it. Callers on a * latency-sensitive request path (e.g. postgres-meta's hosted * `/generators/typescript` route) can substitute a worker-pool-backed * formatter here instead of blocking the event loop on every call. */ format?: (code: string) => Promise; } /** * Collections `pgTypeToTsType` resolves a relation-typed value against. * * Foreign tables are generated under `Tables` and materialized views under * `Views`, exactly like their plain counterparts, so a value typed as one has * a `Row` to point at and belongs here. Both are optional so the exported * `pgTypeToTsType` signature stays backwards compatible. */ export type TypeResolutionContext = { types: PostgresType[]; schemas: PostgresSchema[]; tables: PostgresTable[]; views: PostgresView[]; foreignTables?: PostgresForeignTable[]; materializedViews?: PostgresMaterializedView[]; }; /** * Does not re-sort collections; pass input pre-sorted with * `sortGeneratorMetadata` first. Still merge-sorts tables+foreign tables and * views+materialized views per schema, since that cross-collection grouping * can't be expressed by the single-collection `sortGeneratorMetadata` pass. */ export declare const generateTypescript: (metadata: GeneratorMetadata, opts?: GenerateTypescriptOptions) => Promise; export declare const pgTypeToTsType: (schema: PostgresSchema, pgType: string, context: TypeResolutionContext, typeSchema?: string) => string;