@spfn/core 0.3.0-beta.33 → 0.3.0-beta.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -334,7 +334,7 @@ Each module has its own README with the API detail.
334
334
  | `@spfn/core/server` | Server entry: `defineServerConfig()` → `startServer()`, plus `createServerlessApp()` for Vercel. Middleware wiring, infra init, graceful shutdown. | [src/server](./src/server/README.md) |
335
335
  | `@spfn/core/nextjs` | Client-safe: `createApi<AppRouter>()`, `ApiError`, client types. Never touches `next/headers`. | [src/nextjs](./src/nextjs/README.md) |
336
336
  | `@spfn/core/nextjs/server` | Server-only: `createRpcProxy({ routeMap })`, `registerInterceptors`. Uses `next/headers`. | [src/nextjs](./src/nextjs/README.md) |
337
- | `@spfn/core/db` | PostgreSQL through Drizzle: CRUD helpers, `BaseRepository`, schema helpers, transactions, Postgres error mapping. One entry point for all of it. | [src/db](./src/db/README.md) |
337
+ | `@spfn/core/db` | PostgreSQL through Drizzle: CRUD helpers, `BaseRepository`, `TenantRepository` for tables shared by many tenants, schema helpers, transactions, Postgres error mapping. One entry point for all of it. | [src/db](./src/db/README.md) |
338
338
  | `@spfn/core/db` → manager | Connection lifecycle, pool, primary/replica, health check, reconnect (`initDatabase`, `getDatabase`). Re-exported from `@spfn/core/db`. | [src/db/manager](./src/db/manager/README.md) |
339
339
  | `@spfn/core/db` → migrations | Which migrations each installed function package ships, and which the database has applied (`collectMigrationStatus`, `discoverFunctionMigrations`). What `spfn db status`, the boot gate and health all read. Re-exported from `@spfn/core/db`. | [src/db/migrations](https://github.com/fxylabs/spfn/blob/main/packages/core/src/db/migrations/index.ts) |
340
340
  | `@spfn/core/db` → schema | Drizzle column helpers (`id`, `uuid`, `timestamps`, `foreignKey`, `enumText`, `typedJsonb`, `softDelete`, …). Re-exported from `@spfn/core/db`. | [src/db/schema](./src/db/schema/README.md) |
@@ -1,7 +1,7 @@
1
1
  import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
2
2
  import postgres, { Sql } from 'postgres';
3
3
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
4
- import { PgAsyncDatabase, PgAsyncTransaction, PgColumn, PgTable } from 'drizzle-orm/pg-core';
4
+ import { PgAsyncDatabase, PgAsyncTransaction, PgColumn, PgTable, PgAsyncSelectBuilder, SelectedFields } from 'drizzle-orm/pg-core';
5
5
  import * as drizzle_orm from 'drizzle-orm';
6
6
  import { SQL, InferSelectModel, InferInsertModel, AnyRelations, EmptyRelations } from 'drizzle-orm';
7
7
  import * as hono_types from 'hono/types';
@@ -594,6 +594,31 @@ declare function generateDrizzleConfigFile(options?: DrizzleConfigOptions): stri
594
594
  * ```
595
595
  */
596
596
  declare function id(): drizzle_orm_pg_core.SetIsPrimaryKey<drizzle_orm_pg_core.PgBigSerial53Builder>;
597
+ /**
598
+ * Tenant column for a table that many tenants share
599
+ *
600
+ * A not-null bigint holding the tenant's id. Declaring it is what makes the table
601
+ * tenant-aware: TenantRepository requires it, adds `tenant = $id` to every query
602
+ * it builds, and the development query warning checks hand-written queries for
603
+ * it. A table may declare one.
604
+ *
605
+ * It does not create an index — a drizzle column cannot. Declare the table's
606
+ * indexes in its third argument, each starting with the tenant column, so a
607
+ * query that filters on the tenant reads only that tenant's part of the index.
608
+ *
609
+ * @param name - Column name (default `tenant_id`)
610
+ * @returns not-null bigint column (JS `number`)
611
+ *
612
+ * @example
613
+ * ```typescript
614
+ * export const notes = schema.table('notes', {
615
+ * id: id(),
616
+ * tenantId: tenantKey(),
617
+ * title: text('title').notNull(),
618
+ * }, (t) => [index('notes_tenant_id_idx').on(t.tenantId, t.id)]);
619
+ * ```
620
+ */
621
+ declare function tenantKey(name?: string): drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgBigInt53Builder>;
597
622
  /**
598
623
  * Standard timestamp fields (createdAt, updatedAt)
599
624
  *
@@ -1836,79 +1861,31 @@ declare function deleteMany<T extends PgTable>(table: T, where: WhereObject<Infe
1836
1861
  declare function count<T extends PgTable>(table: T, where?: WhereObject<InferSelectModel<T>> | SQL | undefined): Promise<number>;
1837
1862
 
1838
1863
  /**
1839
- * Base Repository Pattern
1840
- *
1841
- * Provides automatic database instance management with transaction context support.
1842
- * Eliminates the need for manual `getDatabaseOrThrow()` calls in repository classes.
1843
- *
1844
- * Features:
1845
- * - Automatic transaction context detection and usage
1846
- * - Read/Write connection separation (with replica support)
1847
- * - Type-safe schema generics
1848
- * - Consistent database access pattern across all repositories
1849
- * - Enhanced error tracking with repository context
1850
- *
1851
- * @example Basic Repository
1852
- * ```typescript
1853
- * import { BaseRepository } from '@spfn/core/db';
1854
- * import { users } from './schema';
1855
- * import { eq } from 'drizzle-orm';
1856
- *
1857
- * export class UserRepository extends BaseRepository {
1858
- * async findById(id: string) {
1859
- * // Uses read replica when available
1860
- * return await this.readDb
1861
- * .select()
1862
- * .from(users)
1863
- * .where(eq(users.id, id));
1864
- * }
1864
+ * Query Utility Functions
1865
1865
  *
1866
- * async create(data: NewUser) {
1867
- * // Uses write primary
1868
- * return await this.db
1869
- * .insert(users)
1870
- * .values(data)
1871
- * .returning();
1872
- * }
1873
- * }
1874
- * ```
1875
- *
1876
- * @example With Transactions
1877
- * ```typescript
1878
- * import { runInTransaction } from '@spfn/core/db';
1879
- *
1880
- * const userRepo = new UserRepository();
1881
- *
1882
- * await runInTransaction(async () => {
1883
- * // Both db and readDb automatically use the transaction context
1884
- * const user = await userRepo.create({ name: 'John' });
1885
- * await userRepo.findById(user.id); // Uses same transaction
1886
- * });
1887
- * ```
1866
+ * Common utilities for building database queries.
1867
+ * Used by both helpers.ts and repository.ts to avoid code duplication.
1888
1868
  *
1889
- * @example With Custom Schema Type
1890
- * ```typescript
1891
- * import type { AppRelations } from './relations';
1892
- *
1893
- * export class UserRepository extends BaseRepository<AppRelations> {
1894
- * // Now this.db and this.readDb preserve the app's Drizzle relations
1895
- * }
1896
- * ```
1869
+ * @internal
1870
+ */
1871
+
1872
+ /** Options for a capped count. */
1873
+ interface CountOptions {
1874
+ /**
1875
+ * Stop counting past this many rows. The result is at most `cap + 1`, and
1876
+ * `cap + 1` means "more than `cap`" — enough for a "1,000+" label without
1877
+ * counting the whole table on every list request.
1878
+ */
1879
+ cap?: number;
1880
+ }
1881
+
1882
+ /**
1883
+ * Repository core
1897
1884
  *
1898
- * @example With Enhanced Error Tracking
1899
- * ```typescript
1900
- * export class UserRepository extends BaseRepository {
1901
- * async updateStatus(id: string, status: string) {
1902
- * // Errors will include repository context automatically
1903
- * return await this.db
1904
- * .update(users)
1905
- * .set({ status })
1906
- * .where(eq(users.id, id))
1907
- * .returning();
1908
- * }
1909
- * }
1910
- * // On error: logs will show "UserRepository" context
1911
- * ```
1885
+ * The database access every repository shares: the write and read instances,
1886
+ * which resolve to the ambient transaction when there is one, and the error
1887
+ * context wrapper. BaseRepository and TenantRepository both extend it and add
1888
+ * their own query methods.
1912
1889
  */
1913
1890
 
1914
1891
  /** Database surface available to repositories inside and outside transactions. */
@@ -1924,20 +1901,12 @@ declare class RepositoryError extends Error {
1924
1901
  constructor(message: string, repository: string, method?: string | undefined, table?: string | undefined, originalError?: Error | undefined);
1925
1902
  }
1926
1903
  /**
1927
- * Base Repository class for database operations
1928
- *
1929
- * Provides automatic database instance management with transaction support.
1930
- * Extend this class to create domain-specific repositories.
1931
- *
1932
- * The repository automatically detects if running within a transaction context
1933
- * and uses the appropriate database instance:
1934
- * - Inside transaction: Uses transaction DB
1935
- * - Outside transaction: Uses global DB instance (with read/write separation)
1904
+ * Shared base of BaseRepository and TenantRepository
1936
1905
  *
1937
1906
  * @template TRelations - Drizzle relations type (defaults to no relations)
1938
1907
  * @template TDatabase - PostgreSQL Drizzle driver type (defaults to postgres.js)
1939
1908
  */
1940
- declare abstract class BaseRepository<TRelations extends AnyRelations = EmptyRelations, TDatabase extends DrizzleDatabase = PostgresJsDatabase<TRelations>> {
1909
+ declare abstract class RepositoryCore<TRelations extends AnyRelations = EmptyRelations, TDatabase extends DrizzleDatabase = PostgresJsDatabase<TRelations>> {
1941
1910
  /**
1942
1911
  * Write database instance
1943
1912
  *
@@ -2005,6 +1974,99 @@ declare abstract class BaseRepository<TRelations extends AnyRelations = EmptyRel
2005
1974
  method?: string;
2006
1975
  table?: string;
2007
1976
  }): Promise<T>;
1977
+ }
1978
+
1979
+ /**
1980
+ * Base Repository Pattern
1981
+ *
1982
+ * Provides automatic database instance management with transaction context support.
1983
+ * Eliminates the need for manual `getDatabaseOrThrow()` calls in repository classes.
1984
+ *
1985
+ * Features:
1986
+ * - Automatic transaction context detection and usage
1987
+ * - Read/Write connection separation (with replica support)
1988
+ * - Type-safe schema generics
1989
+ * - Consistent database access pattern across all repositories
1990
+ * - Enhanced error tracking with repository context
1991
+ *
1992
+ * @example Basic Repository
1993
+ * ```typescript
1994
+ * import { BaseRepository } from '@spfn/core/db';
1995
+ * import { users } from './schema';
1996
+ * import { eq } from 'drizzle-orm';
1997
+ *
1998
+ * export class UserRepository extends BaseRepository {
1999
+ * async findById(id: string) {
2000
+ * // Uses read replica when available
2001
+ * return await this.readDb
2002
+ * .select()
2003
+ * .from(users)
2004
+ * .where(eq(users.id, id));
2005
+ * }
2006
+ *
2007
+ * async create(data: NewUser) {
2008
+ * // Uses write primary
2009
+ * return await this.db
2010
+ * .insert(users)
2011
+ * .values(data)
2012
+ * .returning();
2013
+ * }
2014
+ * }
2015
+ * ```
2016
+ *
2017
+ * @example With Transactions
2018
+ * ```typescript
2019
+ * import { runInTransaction } from '@spfn/core/db';
2020
+ *
2021
+ * const userRepo = new UserRepository();
2022
+ *
2023
+ * await runInTransaction(async () => {
2024
+ * // Both db and readDb automatically use the transaction context
2025
+ * const user = await userRepo.create({ name: 'John' });
2026
+ * await userRepo.findById(user.id); // Uses same transaction
2027
+ * });
2028
+ * ```
2029
+ *
2030
+ * @example With Custom Schema Type
2031
+ * ```typescript
2032
+ * import type { AppRelations } from './relations';
2033
+ *
2034
+ * export class UserRepository extends BaseRepository<AppRelations> {
2035
+ * // Now this.db and this.readDb preserve the app's Drizzle relations
2036
+ * }
2037
+ * ```
2038
+ *
2039
+ * @example With Enhanced Error Tracking
2040
+ * ```typescript
2041
+ * export class UserRepository extends BaseRepository {
2042
+ * async updateStatus(id: string, status: string) {
2043
+ * // Errors will include repository context automatically
2044
+ * return await this.db
2045
+ * .update(users)
2046
+ * .set({ status })
2047
+ * .where(eq(users.id, id))
2048
+ * .returning();
2049
+ * }
2050
+ * }
2051
+ * // On error: logs will show "UserRepository" context
2052
+ * ```
2053
+ */
2054
+
2055
+ /**
2056
+ * Base Repository class for database operations
2057
+ *
2058
+ * Provides automatic database instance management with transaction support.
2059
+ * Extend this class to create domain-specific repositories.
2060
+ *
2061
+ * The repository automatically detects if running within a transaction context
2062
+ * and uses the appropriate database instance:
2063
+ * - Inside transaction: Uses transaction DB
2064
+ * - Outside transaction: Uses global DB instance (with read/write separation)
2065
+ *
2066
+ * @template TRelations - Drizzle relations type (defaults to no relations)
2067
+ * @template TDatabase - PostgreSQL Drizzle driver type (defaults to postgres.js)
2068
+ */
2069
+ declare abstract class BaseRepository<TRelations extends AnyRelations = EmptyRelations, TDatabase extends DrizzleDatabase = PostgresJsDatabase<TRelations>> extends RepositoryCore<TRelations, TDatabase> {
2008
2070
  /**
2009
2071
  * Find a single record
2010
2072
  *
@@ -2190,15 +2252,123 @@ declare abstract class BaseRepository<TRelations extends AnyRelations = EmptyRel
2190
2252
  *
2191
2253
  * @param table - Drizzle table schema
2192
2254
  * @param where - Optional object or SQL condition
2193
- * @returns Number of records
2255
+ * @param options - `cap` stops counting past that many rows
2256
+ * @returns Number of records; with `cap`, at most `cap + 1`, which means "more than cap"
2194
2257
  *
2195
2258
  * @example
2196
2259
  * ```typescript
2197
2260
  * const total = await this._count(users);
2198
2261
  * const activeUsers = await this._count(users, { active: true });
2262
+ *
2263
+ * // A list label: 1001 reads as "1,000+"
2264
+ * const shown = await this._count(users, undefined, { cap: 1000 });
2199
2265
  * ```
2200
2266
  */
2201
- protected _count<T extends PgTable>(table: T, where?: Record<string, any> | SQL | undefined): Promise<number>;
2267
+ protected _count<T extends PgTable>(table: T, where?: Record<string, any> | SQL | undefined, options?: CountOptions): Promise<number>;
2268
+ }
2269
+
2270
+ /**
2271
+ * Tenant Repository
2272
+ *
2273
+ * A repository for tables that many tenants share. Every method takes the
2274
+ * tenant id first and puts it into the query itself — the WHERE of a read,
2275
+ * update or delete, the tenant column of an insert, the ON clause of each
2276
+ * joined tenant-aware table — so no query this class builds can reach another
2277
+ * tenant's rows.
2278
+ *
2279
+ * It does not extend BaseRepository: BaseRepository's `_findOne(table, where)`
2280
+ * would stay callable without a tenant, and TypeScript does not let a subclass
2281
+ * change a method's parameter list. Both extend RepositoryCore, so `this.db`,
2282
+ * `this.readDb` and `withContext` behave the same. A query written by hand on
2283
+ * `this.db` / `this.readDb` is not scoped, and neither is a subquery passed in
2284
+ * as a condition or a join source; the development query warning reports one
2285
+ * that leaves a tenant-aware table without its tenant condition.
2286
+ *
2287
+ * @example
2288
+ * ```typescript
2289
+ * export class NoteRepository extends TenantRepository
2290
+ * {
2291
+ * async list(tenantId: number, after?: number)
2292
+ * {
2293
+ * return this._findManyKeyset(tenantId, notes, { cursorColumn: notes.id, after, limit: 50 });
2294
+ * }
2295
+ *
2296
+ * async listWithAuthor(tenantId: number)
2297
+ * {
2298
+ * return this._select(tenantId, { title: notes.title, author: authors.name })
2299
+ * .from(notes)
2300
+ * .innerJoin(authors, eq(notes.authorId, authors.id));
2301
+ * }
2302
+ * }
2303
+ * ```
2304
+ */
2305
+
2306
+ type WhereInput = Record<string, any> | SQL | undefined;
2307
+ /**
2308
+ * @template TRelations - Drizzle relations type (defaults to no relations)
2309
+ * @template TDatabase - PostgreSQL Drizzle driver type (defaults to postgres.js)
2310
+ */
2311
+ declare abstract class TenantRepository<TRelations extends AnyRelations = EmptyRelations, TDatabase extends DrizzleDatabase = PostgresJsDatabase<TRelations>> extends RepositoryCore<TRelations, TDatabase> {
2312
+ /** One row of the tenant matching `where`, or null. */
2313
+ protected _findOne<T extends PgTable>(tenantId: number, table: T, where: WhereInput): Promise<InferSelectModel<T> | null>;
2314
+ /** Rows of the tenant, with the same options and DB_MAX_ROWS ceiling as BaseRepository. */
2315
+ protected _findMany<T extends PgTable>(tenantId: number, table: T, options?: {
2316
+ where?: WhereInput;
2317
+ orderBy?: SQL | SQL[];
2318
+ limit?: number;
2319
+ offset?: number;
2320
+ }): Promise<InferSelectModel<T>[]>;
2321
+ /**
2322
+ * Keyset (cursor) page of the tenant's rows. Index the table on
2323
+ * (tenant column, cursor column) so a page reads only its own rows.
2324
+ */
2325
+ protected _findManyKeyset<T extends PgTable>(tenantId: number, table: T, options: {
2326
+ cursorColumn: PgColumn;
2327
+ limit: number;
2328
+ after?: string | number | bigint | Date;
2329
+ order?: 'asc' | 'desc';
2330
+ where?: WhereInput;
2331
+ }): Promise<InferSelectModel<T>[]>;
2332
+ /** Number of the tenant's rows; with `cap`, at most `cap + 1` ("more than cap"). */
2333
+ protected _count<T extends PgTable>(tenantId: number, table: T, where?: WhereInput, options?: CountOptions): Promise<number>;
2334
+ /**
2335
+ * A select whose `from` table and every joined tenant-aware table carry the
2336
+ * tenant condition: the `from` table in WHERE, a joined one in its ON clause.
2337
+ * `innerJoin` and `leftJoin` are scoped; right, full, cross and lateral joins,
2338
+ * set operators and a joined view throw.
2339
+ */
2340
+ protected _select(tenantId: number): PgAsyncSelectBuilder<undefined>;
2341
+ protected _select<TSelection extends SelectedFields>(tenantId: number, fields: TSelection): PgAsyncSelectBuilder<TSelection>;
2342
+ /** Insert one row for the tenant; a different tenant value in `data` throws. */
2343
+ protected _create<T extends PgTable>(tenantId: number, table: T, data: InferInsertModel<T>): Promise<InferSelectModel<T>>;
2344
+ /** Insert rows for the tenant; every row is checked before any is written. */
2345
+ protected _createMany<T extends PgTable>(tenantId: number, table: T, data: InferInsertModel<T>[]): Promise<InferSelectModel<T>[]>;
2346
+ /**
2347
+ * Insert, or update on conflict. The conflict target must include the
2348
+ * tenant column: on `id` alone, an insert could collide with another
2349
+ * tenant's row and update it.
2350
+ */
2351
+ protected _upsert<T extends PgTable>(tenantId: number, table: T, data: InferInsertModel<T>, options: {
2352
+ target: PgColumn[];
2353
+ set?: Partial<InferInsertModel<T>> | Record<string, SQL | any>;
2354
+ }): Promise<InferSelectModel<T>>;
2355
+ /** Update the tenant's rows matching `where`; returns the first, or null. */
2356
+ protected _updateOne<T extends PgTable>(tenantId: number, table: T, where: WhereInput, data: Partial<InferInsertModel<T>>): Promise<InferSelectModel<T> | null>;
2357
+ /** Update the tenant's rows matching `where`. */
2358
+ protected _updateMany<T extends PgTable>(tenantId: number, table: T, where: WhereInput, data: Partial<InferInsertModel<T>>): Promise<InferSelectModel<T>[]>;
2359
+ /** Delete the tenant's rows matching `where`; returns the first, or null. */
2360
+ protected _deleteOne<T extends PgTable>(tenantId: number, table: T, where: WhereInput): Promise<InferSelectModel<T> | null>;
2361
+ /** Delete the tenant's rows matching `where`. */
2362
+ protected _deleteMany<T extends PgTable>(tenantId: number, table: T, where: WhereInput): Promise<InferSelectModel<T>[]>;
2363
+ private updateRows;
2364
+ private deleteRows;
2365
+ /** `tenant condition AND where`, after checking the tenant id and the table. */
2366
+ private tenantWhere;
2367
+ /** As tenantWhere, and `where` itself must filter on something besides the tenant. */
2368
+ private requiredWhere;
2369
+ private withTenantValue;
2370
+ private assertTenantUnchanged;
2371
+ private assertTargetHasTenant;
2202
2372
  }
2203
2373
 
2204
- export { type AfterCommitCallback, type AfterRollbackCallback, BaseRepository, type BeforeCommitCallback, type DatabaseClients, type DatabaseInitOptions, type DatabaseOptions, type DatabaseProvider, type DatabaseTransaction, type DefaultDatabase, type DrizzleConfigOptions, type DrizzleDatabase, type FunctionMigrationEntry, type FunctionMigrationInfo, type MigrationStatus, type MigrationStatusDb, type MigrationTargetStatus, type NestedFrameGate, PROJECT_MIGRATIONS_TABLE, PROJECT_TARGET_NAME, type PoolConfig, RUN_MIGRATIONS_HINT, type RenderableDrizzleConfig, type RepositoryDatabase, RepositoryError, type RetryConfig, type RunInTransactionOptions, type TransactionContext, type TransactionDB, Transactional, type TransactionalOptions, auditFields, checkConnection, closeDatabase, collectMigrationStatus, count, countPendingMigrations, create, createDatabaseConnection, createDatabaseFromEnv, createMany, createSchema, deleteMany, deleteOne, detectDialect, discoverFunctionMigrations, enumText, filterPendingEntries, findMany, findOne, forceReconnectDatabase, foreignKey, formatPendingMigrations, fromPostgresError, functionMigrationsTable, generateDrizzleConfigFile, getDatabase, getDatabaseInfo, getDrizzleConfig, getSchemaInfo, getTransaction, getTransactionContext, hasMigrationTargets, id, initDatabase, isConnectionLevelError, migrationTargets, onAfterCommit, onAfterRollback, onBeforeCommit, optionalForeignKey, packageNameToSchema, pendingMigrationTargets, pendingMigrationsSummary, projectMigrationsDir, publishingFields, readMigrationEntries, renderDrizzleConfig, reportDatabaseError, resetConnectionErrorCounter, runInTransaction, runWithTransaction, setDatabase, setDatabaseProvider, softDelete, timestamps, typedJsonb, updateMany, updateOne, upsert, utcTimestamp, uuid, verificationTimestamp };
2374
+ export { type AfterCommitCallback, type AfterRollbackCallback, BaseRepository, type BeforeCommitCallback, type CountOptions, type DatabaseClients, type DatabaseInitOptions, type DatabaseOptions, type DatabaseProvider, type DatabaseTransaction, type DefaultDatabase, type DrizzleConfigOptions, type DrizzleDatabase, type FunctionMigrationEntry, type FunctionMigrationInfo, type MigrationStatus, type MigrationStatusDb, type MigrationTargetStatus, type NestedFrameGate, PROJECT_MIGRATIONS_TABLE, PROJECT_TARGET_NAME, type PoolConfig, RUN_MIGRATIONS_HINT, type RenderableDrizzleConfig, type RepositoryDatabase, RepositoryError, type RetryConfig, type RunInTransactionOptions, TenantRepository, type TransactionContext, type TransactionDB, Transactional, type TransactionalOptions, auditFields, checkConnection, closeDatabase, collectMigrationStatus, count, countPendingMigrations, create, createDatabaseConnection, createDatabaseFromEnv, createMany, createSchema, deleteMany, deleteOne, detectDialect, discoverFunctionMigrations, enumText, filterPendingEntries, findMany, findOne, forceReconnectDatabase, foreignKey, formatPendingMigrations, fromPostgresError, functionMigrationsTable, generateDrizzleConfigFile, getDatabase, getDatabaseInfo, getDrizzleConfig, getSchemaInfo, getTransaction, getTransactionContext, hasMigrationTargets, id, initDatabase, isConnectionLevelError, migrationTargets, onAfterCommit, onAfterRollback, onBeforeCommit, optionalForeignKey, packageNameToSchema, pendingMigrationTargets, pendingMigrationsSummary, projectMigrationsDir, publishingFields, readMigrationEntries, renderDrizzleConfig, reportDatabaseError, resetConnectionErrorCounter, runInTransaction, runWithTransaction, setDatabase, setDatabaseProvider, softDelete, tenantKey, timestamps, typedJsonb, updateMany, updateOne, upsert, utcTimestamp, uuid, verificationTimestamp };