/** * PgTsGenerator Context * * This is a generator-specific context that provides configuration * for the PostgreSQL to TypeScript generator and its sub-generators. * * This keeps generator-specific concerns separate from the global KanelContext. */ import type { TypeMetadata, PropertyMetadata, RoutineMetadata } from "../config-types-v4"; import type { CompositeProperty, CompositeDetails } from "./composite-types"; import type { RoutineDetails } from "./routine-types"; import type Details from "../Details"; import type { TypeDeclaration } from "../ts-utilities/ts-declaration-types"; import type TypeMap from "../TypeMap"; import type { TableColumn, ForeignTableColumn, TableDetails, ForeignTableDetails } from "extract-pg-schema"; /** * Internal version of GetMetadata. * Does NOT include the builtinMetadata parameter - that's handled by the wrapper. * This is what sub-generators actually call. */ export type InternalGetMetadata = (details: Details, generateFor: "selector" | "initializer" | "mutator" | undefined) => TypeMetadata; /** * Internal version of GetPropertyMetadata. * Does NOT include the builtinMetadata parameter - that's handled by the wrapper. * This is what sub-generators actually call. */ export type InternalGetPropertyMetadata = (property: CompositeProperty, details: CompositeDetails, generateFor: "selector" | "initializer" | "mutator") => PropertyMetadata; /** * Internal version of GenerateIdentifierType. * Does NOT include the builtinType parameter - that's handled by the wrapper. * This is what sub-generators actually call. */ export type InternalGenerateIdentifierType = (column: TableColumn | ForeignTableColumn, details: TableDetails | ForeignTableDetails) => TypeDeclaration; /** * Internal version of GetRoutineMetadata. * Does NOT include the builtinMetadata parameter - that's handled by the wrapper. * This is what sub-generators actually call. */ export type InternalGetRoutineMetadata = (routineDetails: RoutineDetails) => RoutineMetadata; /** * Context specific to the PgTsGenerator. * Available to all sub-generators via usePgTsGeneratorContext(). */ export type PgTsGeneratorContext = { /** Merged type map (builtin + custom) */ typeMap: TypeMap; /** Internal metadata function (already merged with builtin) */ getMetadata: InternalGetMetadata; /** Internal property metadata function (already merged with builtin) */ getPropertyMetadata: InternalGetPropertyMetadata; /** Optional internal identifier type generator (already merged with builtin) */ generateIdentifierType?: InternalGenerateIdentifierType; /** Optional internal routine metadata function (already merged with builtin) */ getRoutineMetadata?: InternalGetRoutineMetadata; /** Property sort function */ propertySortFunction: (a: CompositeProperty, b: CompositeProperty) => number; }; /** * Get the current PgTsGenerator context. * Throws if called outside of a PgTsGenerator execution context. */ export declare const usePgTsGeneratorContext: () => PgTsGeneratorContext; /** * Run a function within a PgTsGenerator context. */ export declare const runWithPgTsGeneratorContext: (context: PgTsGeneratorContext, fn: () => Promise) => Promise;