everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
69 lines • 3.46 kB
text/typescript
//#region src/db/core.d.ts
interface MigrationStorage {
schema: string;
table: string;
slug: string;
}
declare function normalizeSlug(name: string): string;
declare function getMigrationSlug(dir?: string): string;
declare function getMigrationStorage(slug?: string, options?: {
isolated?: boolean;
}): MigrationStorage;
/**
* Format a JavaScript string array as a PostgreSQL text array literal for use
* with Drizzle's `sql` tag. Example return:
* `'{"h1","h2"}'::text[]`
*
* Usage: sql`WHERE col = ANY(${toSqlArray(values)})`
*
* Drizzle's default parameter binding does not handle array types correctly
* with the pg driver (it emits `ANY(($1))` with a single string, which
* Postgres rejects as a malformed array literal).
*/
declare function toSqlArray(arr: string[]): string;
declare function pluginMigrationSlug(key: string): string;
declare function getDatabaseUrlSecretName(slug: string): string;
declare const DUPLICATE_OBJECT_SQLSTATES: readonly string[];
/**
* Walk `error` and its `cause` chain (bounded), invoking `visit` on each link.
* Postgres driver errors arrive wrapped by drizzle/Effect at varying depths,
* so every error-shape predicate below shares this traversal.
*/
declare function visitCauses(error: unknown, depth: number, visit: (link: object) => boolean): boolean;
/**
* Whether a SQLSTATE 23505 unique violation is the concurrent-DDL catalog
* collision signature rather than a data-level constraint on a user table.
* Data-level violations must keep failing loudly; only the pg_catalog indexes
* above are treated as duplicate-DDL tolerance candidates.
*/
declare function isConcurrentDdlUniqueViolation(error: unknown): boolean;
/**
* Decide whether a failed migration-init statement (schema/journal creation)
* is worth retrying. Covers the concurrent `CREATE SCHEMA IF NOT EXISTS`
* race (unique violation on `pg_namespace`, duplicate-object errors),
* serialization/deadlock errors, and transient connection failures.
*/
declare function isRetryableMigrationError(error: unknown): boolean;
/**
* Decide whether a failed migration *statement* (inside its transaction) is
* worth retrying. Deliberately narrower than `isRetryableMigrationError`:
* duplicate-object classes are tolerated at the SAVEPOINT level, and a 23505
* is either the concurrent-DDL catalog collision (also tolerated) or a
* deterministic data-level violation (retrying is pointless) — so only
* lock/serialization/transient-connection states justify re-running the
* transaction.
*/
declare function isRetryableMigrationExecutionError(error: unknown): boolean;
/**
* Silence pg's query-queue deprecation warning (fires once per process from
* pg-pool's internal dispatch under concurrent boot load — node-postgres#3612,
* #3617). Node's default warning handler prints even when user listeners are
* attached, so it is removed first; every other warning is re-printed here.
*/
declare function suppressPgQueryQueueDeprecation(): void;
declare function extractExpectedTables(migrations: {
sql: string[];
}[]): string[];
//#endregion
export { DUPLICATE_OBJECT_SQLSTATES, MigrationStorage, extractExpectedTables, getDatabaseUrlSecretName, getMigrationSlug, getMigrationStorage, isConcurrentDdlUniqueViolation, isRetryableMigrationError, isRetryableMigrationExecutionError, normalizeSlug, pluginMigrationSlug, suppressPgQueryQueueDeprecation, toSqlArray, visitCauses };
//# sourceMappingURL=core.d.cts.map