import type { PgType, Schema } from "extract-pg-schema"; import type { ConnectionConfig } from "pg"; import type { CompositeProperty } from "./generators/composite-types"; import type { GenerateIdentifierTypeV3, GetMetadataV3, GetPropertyMetadataV3, GetRoutineMetadataV3 } from "./metadata-types"; import type Output from "./Output"; import type TypeMap from "./TypeMap"; import type { ConfigV4 } from "./config-types-v4"; type Awaitable = T | PromiseLike; export type InstantiatedConfig = { connection: string | ConnectionConfig; schemas: Record; typeMap: TypeMap; getMetadata: GetMetadataV3; getPropertyMetadata: GetPropertyMetadataV3; generateIdentifierType?: GenerateIdentifierTypeV3; getRoutineMetadata?: GetRoutineMetadataV3; propertySortFunction: (a: CompositeProperty, b: CompositeProperty) => number; enumStyle: "enum" | "type"; outputPath: string; preDeleteOutputFolder: boolean; resolveViews: boolean; importsExtension?: ".ts" | ".js" | ".mjs" | ".cjs"; tsModuleFormat?: "esm" | "commonjs" | "explicit-esm" | "explicit-commonjs"; fileExtension: ".ts" | ".mts" | ".cts"; }; export type PreRenderHookV3 = (outputAcc: Output, instantiatedConfig: InstantiatedConfig) => Awaitable; export type PostRenderHookV3 = (path: string, lines: string[], instantiatedConfig: InstantiatedConfig) => Awaitable; /** * V3 Configuration for Kanel. * This is the legacy config format, maintained for backwards compatibility. * Distinguished from V4 by the absence of the `generators` field. */ export type ConfigV3 = { connection: string | ConnectionConfig; schemas?: string[]; typeFilter?: (pgType: PgType) => boolean; getMetadata?: GetMetadataV3; getPropertyMetadata?: GetPropertyMetadataV3; generateIdentifierType?: GenerateIdentifierTypeV3; propertySortFunction?: (a: CompositeProperty, b: CompositeProperty) => number; getRoutineMetadata?: GetRoutineMetadataV3; enumStyle?: "enum" | "type"; outputPath?: string; preDeleteOutputFolder?: boolean; customTypeMap?: TypeMap; resolveViews?: boolean; preRenderHooks?: PreRenderHookV3[]; postRenderHooks?: PostRenderHookV3[]; /** @deprecated Use tsModuleFormat instead */ importsExtension?: ".ts" | ".js" | ".mjs" | ".cjs"; tsModuleFormat?: "esm" | "commonjs" | "explicit-esm" | "explicit-commonjs"; }; export type { ConfigV4 }; /** * Union type for both V3 and V4 configs. * Use isV3Config() or isV4Config() type guards to distinguish between them. */ export type Config = ConfigV3 | ConfigV4; /** * Type guard to check if a config is a V3 config. * V3 configs are identified by the absence of the `generators` field. */ export declare function isV3Config(config: Config): config is ConfigV3; /** * Type guard to check if a config is a V4 config. * V4 configs are identified by the presence of the `generators` field. */ export declare function isV4Config(config: Config): config is ConfigV4;