import * as ft from 'funtypes'; export interface TestConfig { /** * Whether to output logs to stdout/stderr from docker * scripts. * * @default false */ debug: boolean; /** * Optional script to run after the database * has been started but before running tests */ migrationsScript?: string | string[]; /** * The docker image to use when testing * using @databases/pg-test * * @default "postgres:18.4-alpine" */ image: string; /** * The default name to give the docker * containers run by @database/pg-test * * @default "pg-test" */ containerName: string; /** * The timeout in seconds when waiting for the test docker image to start * * @default 20 * @minimum 0 * @TJS-type integer */ connectTimeoutSeconds: number; /** * The port to run postgres on when running docker * for tests. Defaults to 5432 or the first available * port after that. * * @minimum 0 * @maximum 65535 * @TJS-type integer */ port?: number; /** * The user name to configure in the test docker container * * @default "test-user" */ pgUser: string; /** * The db to create in the test docker container * * @default "test-db" */ pgDb: string; } export declare const TestConfigSchema: ft.Runtype; export declare enum PgTypesDomainTypeMode { strict_brand = "strict_brand", loose_brand = "loose_brand", alias = "alias", inline = "inline" } export declare enum PgTypesEnumTypeMode { enum = "enum", union_alias = "union_alias", union_alias_with_object = "union_alias_with_object", inline = "inline" } export declare enum PgTypesPrimaryKeyTypeMode { strict_brand = "strict_brand", loose_brand = "loose_brand", inline_strict_brand = "inline_strict_brand", inline_loose_brand = "inline_loose_brand", inline_no_brand = "inline_no_brand" } export interface TypesConfig { /** * The directory (relative to this config) to put the generated code in * * @default "__generated__" */ directory: string; /** * What should be generated for custom types with constraints? * * @default "loose_brand" */ domainTypeMode: PgTypesDomainTypeMode; /** * What should custom types be called (ignored for domainTypeMode="inline") * * @default "{{ TYPE_NAME | pascal-case }}" */ domainTypeName: string; /** * Where should generated types for domains be put (ignored for domainTypeMode="inline") * * @default "_custom_types.ts" */ domainFileName: string; /** * How should Postgres enums be represented in TypeScript? * * @default "union_alias" */ enumTypeMode: 'enum' | 'union_alias' | 'union_alias_with_object' | 'inline'; /** * What should enums be called (ignored for enumTypeMode="inline") * * @default "{{ TYPE_NAME | pascal-case }}" */ enumTypeName: string; /** * Where should generated types for enums be put (ignored for enumTypeMode="inline") * * @default "_enums.ts" */ enumFileName: string; /** * Do you want to use branded types for primary keys? * * @default "inline_loose_brand" */ primaryKeyTypeMode: 'strict_brand' | 'loose_brand' | 'inline_strict_brand' | 'inline_loose_brand' | 'inline_no_brand'; /** * What should types for primary keys be called (ignored for primaryKeyMode="inline_*") * * @default "{{ TABLE_NAME | pascal-case }}_{{ COLUMN_NAME | pascal-case }}" */ primaryKeyTypeName: string; /** * Where should generated types for primary keys be put (ignored for primaryKeyMode="inline") * * @default "{{ TABLE_NAME }}.ts" */ primaryKeyFileName: string; /** * What should TypeScript types for table records be called * * @default "{{ TABLE_NAME | pascal-case }}" */ tableTypeName: string; /** * What filename do you want to use for tables * * @default "{{ TABLE_NAME }}.ts" */ tableFileName: string; /** * Also re-export the table record type from this file. * Set this to `null` or to the same value as `tableFileName` * to disable this feature. * * @default "index.ts" */ tableReExportFileName: string | null; /** * What should TypeScript types for table insert parameters be called * * @default "{{ TABLE_NAME | pascal-case }}_InsertParameters" */ tableInsertParametersTypeName: string; /** * What filename do you want to use for tables insert parameters * * @default "{{ TABLE_NAME }}.ts" */ tableInsertParametersFileName: string; /** * Also re-export the table insert parameters type from this file. * Set this to `null` or to the same value as `tableFileName` * to disable this feature. * * @default "index.ts" */ tableInsertParametersReExportFileName: string | null; /** * What should the main generated "schema" type be called * * @default "DatabaseSchema" */ schemaTypeName: string; /** * What filename do you want to use for the main generated "schema" type * * @default "index.ts" */ schemaFileName: string; /** * What filename do you want to use for the generated "schema" object. * * Set this explicitly to `null` to prevent this file being written. * * @default "schema.json" */ schemaJsonFileName: string | null; /** * What should the generated "serializeValue" function be called * * @default "serializeValue" */ serializeValueTypeName: string; /** * What filename do you want to use for the generated "serializeValue" function * * @default "index.ts" */ serializeValueFileName: string; /** * Override column types for some columns. The name can be either: * * - "table_name.column_name" * - "schema_name.table_name.column_name" * * @default {} */ columnTypeOverrides: { [x: string]: string | undefined; }; /** * Override generated TypeScript types for some types. The name can be either: * * - key of @databases/pg-data-type-id (e.g. "json") * - value of @databases/pg-data-type-id (e.g. 114) * - "custom_type_name" * - "schema_name.custom_type_name" * * @default {} */ typeOverrides: { [x: string]: string | undefined; }; /** * Tables you want to generate types for. Use * null to generate types for all tables * * @default null */ includeTables: string[] | null; /** * Tables you do not want to generate types for. * Overrides includeTables * * @default [] */ ignoreTables: string[]; /** * Enum values to exclude from generated types. * This can be useful when you know you have no records * that use an enum value anymore, but cannot remove it * from the database type because the migration would be * too costly. * * @default {} */ ignoreEnumValues: Record; /** * If true, the types will require a value to be provided, * even if a column has a constant default value specified * in the database schema. This can improve type safety due * to the way that undefined is treated as equivalent to null * at runtime. * * This will still allow you to omit columns on insert if they * use `nextval('something')` to generate a unique key, or if * they use `CURRENT_TIMESTAMP` to set a column to the current db * time, or if they use any function call like `now()` or * `uuid_generate_v4()`. Only constant defaults will still require * an explicit value to be provided. * * @default false */ requireExplicitDefaults: boolean; } export declare const TypesConfigSchema: ft.Runtype; interface PgConfig { /** * The environment variable containing the * connection string to the postgres database * * @default "DATABASE_URL" */ connectionStringEnvironmentVariable: string; /** * The directory containing migrations (when using @databases/pg-migrations) */ migrationsDirectory?: string; /** * Config for pg-test * * @default {} */ test: TestConfig; /** * Config for pg-schema-print-types * * @default {} */ types: TypesConfig; } export declare const PgConfigSchema: ft.Runtype; export default PgConfig;