import { DEFAULT_SYSTEM_SCHEMAS } from './constants.js' import { filterByList } from './helpers.js' import { PostgresMetaResult, PostgresType } from './types.js' import { TYPES_SQL } from './sql/types.sql.js' export default class PostgresMetaTypes { query: (sql: string) => Promise> constructor(query: (sql: string) => Promise>) { this.query = query } async list({ includeTableTypes = false, includeArrayTypes = false, includeSystemSchemas = false, includedSchemas, excludedSchemas, limit, offset, }: { includeTableTypes?: boolean includeArrayTypes?: boolean includeSystemSchemas?: boolean includedSchemas?: string[] excludedSchemas?: string[] limit?: number offset?: number } = {}): Promise> { const schemaFilter = filterByList( includedSchemas, excludedSchemas, !includeSystemSchemas ? DEFAULT_SYSTEM_SCHEMAS : undefined ) const sql = TYPES_SQL({ schemaFilter, limit, offset, includeTableTypes, includeArrayTypes }) return await this.query(sql) } }