UNPKG

pgsql-test

Version:

pgsql-test offers isolated, role-aware, and rollback-friendly PostgreSQL environments for integration tests — giving developers realistic test coverage without external state pollution

35 lines (34 loc) 1.99 kB
import { extractPgErrorFields, formatPgErrorFields, formatPgError, type PgErrorFields, type PgErrorContext } from '@pgpmjs/types'; export { extractPgErrorFields, formatPgErrorFields, formatPgError, type PgErrorFields, type PgErrorContext }; /** * Extract the error code from an error message. * * Enhanced error messages from PgTestClient include additional context on subsequent lines * (Where, Query, Values, etc.). This function returns only the first line, which contains * the actual error code raised by PostgreSQL. * * @param message - The error message (may contain multiple lines with debug context) * @returns The first line of the error message (the error code) * * @example * // Error message with enhanced context: * // "NONEXISTENT_TYPE\nWhere: PL/pgSQL function...\nQuery: INSERT INTO..." * getErrorCode(err.message) // => "NONEXISTENT_TYPE" */ export declare function getErrorCode(message: string): string; export type IdHash = Record<string, number | string>; type AnyObject = Record<string, any>; export declare const pruneDates: (row: AnyObject) => AnyObject; export declare const pruneIds: (row: AnyObject, idHash?: IdHash) => AnyObject; export declare const pruneIdArrays: (row: AnyObject) => AnyObject; export declare const pruneUUIDs: (row: AnyObject) => AnyObject; export declare const pruneHashes: (row: AnyObject) => AnyObject; export declare const pruneSchemas: (row: AnyObject) => AnyObject; export declare const prunePeoplestamps: (row: AnyObject) => AnyObject; export declare const pruneTokens: (row: AnyObject) => AnyObject; type Pruner = (row: AnyObject) => AnyObject; export declare const composePruners: (...pruners: Pruner[]) => Pruner; export declare const defaultPruners: Pruner[]; export declare const prune: (row: AnyObject, idHash?: IdHash) => AnyObject; export declare const createSnapshot: (pruners: Pruner[]) => (obj: unknown, idHash?: IdHash) => unknown; export declare const snapshot: (obj: unknown, idHash?: IdHash) => unknown;