import type { Knex } from "knex"; import type { CompositeTypeDetails } from "./kinds/extractCompositeType.ts"; import type { DomainDetails } from "./kinds/extractDomain.ts"; import type { EnumDetails } from "./kinds/extractEnum.ts"; import type { ForeignTableDetails } from "./kinds/extractForeignTable.ts"; import type { FunctionDetails } from "./kinds/extractFunction.ts"; import type { MaterializedViewDetails } from "./kinds/extractMaterializedView.ts"; import type { ProcedureDetails } from "./kinds/extractProcedure.ts"; import type { RangeDetails } from "./kinds/extractRange.ts"; import type { TableDetails } from "./kinds/extractTable.ts"; import type { ViewDetails } from "./kinds/extractView.ts"; import type PgType from "./kinds/PgType.ts"; import { CanonicalType } from "./kinds/query-parts/canonicaliseTypes.ts"; /** * extractSchemas generates a record of all the schemas extracted, indexed by schema name. * The schemas are instances of this type. */ export type Schema = { name: string; domains: DomainDetails[]; enums: EnumDetails[]; ranges: RangeDetails[]; tables: TableDetails[]; foreignTables: ForeignTableDetails[]; views: ViewDetails[]; materializedViews: MaterializedViewDetails[]; composites: CompositeTypeDetails[]; functions: FunctionDetails[]; procedures: ProcedureDetails[]; }; export type SchemaType = DomainDetails | EnumDetails | RangeDetails | TableDetails | ForeignTableDetails | ViewDetails | MaterializedViewDetails | CompositeTypeDetails | FunctionDetails | ProcedureDetails; /** * This is the options object that can be passed to `extractSchemas`. * @see extractSchemas */ export interface ExtractSchemaOptions { /** * Will contain an array of schema names to extract. * If undefined, all non-system schemas will be extracted. */ schemas?: string[]; /** * Filter function that you can use if you want to exclude * certain items from the schemas. */ typeFilter?: (pgType: PgType) => boolean; /** * extractShemas will always attempt to parse view definitions to * discover the "source" of each column, i.e. the table or view that it * is derived from. * If this option is set to `true`, it will attempt to follow this * source and copy values like indices, isNullable, etc. * so that the view data is closer to what the database reflects. */ resolveViews?: boolean; /** * Called with the number of types to extract. */ onProgressStart?: (total: number) => void; /** * Called once for each type that is extracted. */ onProgress?: () => void; /** * Called when all types have been extracted. */ onProgressEnd?: () => void; } export declare class Extractor { private db; /** * @param connectionConfig - Connection string or configuration object for Postgres connection */ constructor(connectionConfig: string | Knex.ConnectionConfig); canonicaliseTypes(types: string[]): Promise; getBuiltinTypes(): Promise<{ name: string; format: string; kind: string; }[]>; /** * Perform the extraction * @param options - Optional options * @returns A record of all the schemas extracted, indexed by schema name. */ extractSchemas(options?: ExtractSchemaOptions): Promise>; }