@zudojs/database 1.4.0 → 1.5.0
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 +47 -0
- package/dist/cache/cache.memory.d.ts +0 -1
- package/dist/cache/cache.memory.js +0 -1
- package/dist/cache/index.d.ts +0 -1
- package/dist/cache/index.js +0 -1
- package/dist/database/database.core.d.ts +0 -1
- package/dist/database/database.core.js +0 -1
- package/dist/database/index.d.ts +0 -1
- package/dist/database/index.js +0 -1
- package/dist/databaseClient/databaseClient.core.d.ts +0 -1
- package/dist/databaseClient/databaseClient.core.js +0 -1
- package/dist/databaseClient/databaseClient.errors.d.ts +19 -2
- package/dist/databaseClient/databaseClient.errors.js +8 -1
- package/dist/databaseClient/databaseClient.logger.d.ts +0 -1
- package/dist/databaseClient/databaseClient.logger.js +0 -1
- package/dist/databaseClient/databaseClient.type.d.ts +0 -1
- package/dist/databaseClient/databaseClient.type.js +0 -1
- package/dist/databaseClient/index.d.ts +1 -2
- package/dist/databaseClient/index.js +1 -2
- package/dist/databaseConnection/databaseConnection.manager.d.ts +0 -1
- package/dist/databaseConnection/databaseConnection.manager.js +0 -1
- package/dist/databaseConnection/index.d.ts +0 -1
- package/dist/databaseConnection/index.js +0 -1
- package/dist/databaseType/databaseType.type.d.ts +6 -5
- package/dist/databaseType/databaseType.type.js +0 -1
- package/dist/databaseType/index.d.ts +0 -1
- package/dist/databaseType/index.js +0 -1
- package/dist/health/health.check.d.ts +0 -1
- package/dist/health/health.check.js +0 -1
- package/dist/health/index.d.ts +0 -1
- package/dist/health/index.js +0 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -3
- package/dist/locks/index.d.ts +0 -1
- package/dist/locks/index.js +0 -1
- package/dist/locks/locks.core.d.ts +0 -1
- package/dist/locks/locks.core.js +0 -1
- package/dist/migration/index.d.ts +0 -1
- package/dist/migration/index.js +0 -1
- package/dist/migration/migration.dialect.d.ts +0 -1
- package/dist/migration/migration.dialect.js +0 -1
- package/dist/migration/migration.helpers.d.ts +0 -1
- package/dist/migration/migration.helpers.js +4 -1
- package/dist/migration/migration.runner.d.ts +12 -1
- package/dist/migration/migration.runner.js +69 -17
- package/dist/migration/migration.types.d.ts +12 -1
- package/dist/migration/migration.types.js +0 -1
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/index.js +1 -1
- package/dist/pagination/pagination.core.d.ts +0 -1
- package/dist/pagination/pagination.core.js +0 -1
- package/dist/pagination/pagination.cursorError.d.ts +0 -1
- package/dist/pagination/pagination.cursorError.js +0 -1
- package/dist/pagination/pagination.keyset.d.ts +12 -1
- package/dist/pagination/pagination.keyset.js +15 -3
- package/dist/pagination/pagination.keysetDirection.d.ts +0 -1
- package/dist/pagination/pagination.keysetDirection.js +0 -1
- package/dist/pagination/pagination.keysetValue.d.ts +37 -0
- package/dist/pagination/pagination.keysetValue.js +55 -0
- package/dist/queryBuilder/index.d.ts +0 -1
- package/dist/queryBuilder/index.js +0 -1
- package/dist/queryBuilder/queryBuilder.core.d.ts +0 -1
- package/dist/queryBuilder/queryBuilder.core.js +0 -1
- package/dist/queryBuilder/queryBuilder.factory.d.ts +0 -1
- package/dist/queryBuilder/queryBuilder.factory.js +0 -1
- package/dist/queryBuilder/queryBuilder.filter.d.ts +0 -1
- package/dist/queryBuilder/queryBuilder.filter.js +0 -1
- package/dist/queryBuilder/queryBuilder.prisma.d.ts +0 -1
- package/dist/queryBuilder/queryBuilder.prisma.js +0 -1
- package/dist/queryBuilder/queryBuilder.type.d.ts +0 -1
- package/dist/queryBuilder/queryBuilder.type.js +0 -1
- package/dist/relations/index.d.ts +0 -1
- package/dist/relations/index.js +0 -1
- package/dist/relations/relations.definition.d.ts +0 -1
- package/dist/relations/relations.definition.js +0 -1
- package/dist/repository/index.d.ts +1 -2
- package/dist/repository/index.js +0 -1
- package/dist/repository/repository.base.d.ts +27 -1
- package/dist/repository/repository.base.js +13 -2
- package/dist/repository/repository.delegate.d.ts +0 -1
- package/dist/repository/repository.delegate.js +0 -1
- package/dist/repository/repository.errors.d.ts +3 -1
- package/dist/repository/repository.errors.js +17 -2
- package/dist/seed/index.d.ts +0 -1
- package/dist/seed/index.js +0 -1
- package/dist/seed/seed.runner.d.ts +0 -1
- package/dist/seed/seed.runner.js +0 -1
- package/dist/transaction/index.d.ts +0 -1
- package/dist/transaction/index.js +0 -1
- package/dist/transaction/transaction.backoff.d.ts +0 -1
- package/dist/transaction/transaction.backoff.js +0 -1
- package/dist/transaction/transaction.core.d.ts +16 -3
- package/dist/transaction/transaction.core.js +8 -2
- package/dist/unitOfWork/index.d.ts +0 -1
- package/dist/unitOfWork/index.js +0 -1
- package/dist/unitOfWork/unitOfWork.core.d.ts +0 -1
- package/dist/unitOfWork/unitOfWork.core.js +0 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -117,6 +117,13 @@ runtime, which only exists with the `prisma-client-js` generator. With the
|
|
|
117
117
|
`prisma-client` generator, construct the client yourself and pass it as
|
|
118
118
|
`prisma`.
|
|
119
119
|
|
|
120
|
+
**Writing your own transaction client** (a hand-written adapter, a test
|
|
121
|
+
double, a PGlite wrapper): since 1.4.0 `DatabaseTransactionContext` is a real
|
|
122
|
+
structural type rather than a type that resolved to `any`, so an object you
|
|
123
|
+
return as one must implement all four raw-query methods — `$queryRaw`,
|
|
124
|
+
`$executeRaw`, `$queryRawUnsafe` and `$executeRawUnsafe` — or TypeScript
|
|
125
|
+
reports TS2739. Code that only *receives* a transaction client is unaffected.
|
|
126
|
+
|
|
120
127
|
## Querying
|
|
121
128
|
|
|
122
129
|
```typescript
|
|
@@ -173,6 +180,21 @@ cursor or its contents. Building keyset pages by hand? Fetch with
|
|
|
173
180
|
`keysetFetchSort(sort, getKeysetDirection(payload))` and pass that
|
|
174
181
|
`direction` to `createKeysetPage`.
|
|
175
182
|
|
|
183
|
+
`paginateCursor` appends the id field to `sort` as a tiebreaker, so a cursor
|
|
184
|
+
positioned at a row you hold must include it: use
|
|
185
|
+
`users.createCursor(row, { sort })` (signed with `cursorSecret`), not
|
|
186
|
+
`createKeysetCursor(row, sort)` with the bare sort, which `paginateCursor`
|
|
187
|
+
rejects as missing the id field.
|
|
188
|
+
|
|
189
|
+
A `Date` sort value is encoded at millisecond precision. PostgreSQL
|
|
190
|
+
`timestamp`/`timestamptz` columns keep microseconds unless declared `(3)`,
|
|
191
|
+
and Prisma returns `Date`s, so the cursor compares such a value as its
|
|
192
|
+
millisecond bucket (`>= C AND < C + 1ms` for a tie) and lets the id
|
|
193
|
+
tiebreaker order rows created in the same millisecond. That is exact for
|
|
194
|
+
identical timestamps (rows inserted by one statement or transaction) and for
|
|
195
|
+
ids that increase with insertion order (serial, ULID, UUIDv7) — with random
|
|
196
|
+
ids, sort by a millisecond-precision column or add a monotonic tiebreaker.
|
|
197
|
+
|
|
176
198
|
## Migrations and seeds
|
|
177
199
|
|
|
178
200
|
```typescript
|
|
@@ -216,6 +238,31 @@ Each migration or seed runs in its own transaction by default
|
|
|
216
238
|
(`perItemTransaction: true`); pass `transaction: { timeoutMs, maxWaitMs, isolationLevel }`
|
|
217
239
|
to size it for long-running steps.
|
|
218
240
|
|
|
241
|
+
A migration that cannot run inside a transaction (`CREATE INDEX CONCURRENTLY`,
|
|
242
|
+
`ALTER TYPE ... ADD VALUE`) sets `transaction: false`. Its `up`/`down` then
|
|
243
|
+
receive the root client and run outside any transaction; the applied check
|
|
244
|
+
and the history record still happen in short transactions under the advisory
|
|
245
|
+
lock, which is released while the body runs, so write such a migration
|
|
246
|
+
idempotently (`IF NOT EXISTS`). It requires `perItemTransaction: true`; a
|
|
247
|
+
batch runner refuses it at construction.
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
{
|
|
251
|
+
version: 20260926120000,
|
|
252
|
+
name: "orders_customer_idx",
|
|
253
|
+
transaction: false,
|
|
254
|
+
up: (db) => db.$executeRawUnsafe(
|
|
255
|
+
'CREATE INDEX CONCURRENTLY IF NOT EXISTS "orders_customer_idx" ON "orders" ("customerId")',
|
|
256
|
+
),
|
|
257
|
+
down: (db) => db.$executeRawUnsafe('DROP INDEX CONCURRENTLY IF EXISTS "orders_customer_idx"'),
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
`createTransactionContext` here builds the immutable status record that
|
|
262
|
+
`TransactionManager.run` reports (`transactionId`, `startedAt`, `status`);
|
|
263
|
+
it is unrelated to the `createTransactionContext` of `@zudojs/transactions`,
|
|
264
|
+
which creates that package's AsyncLocalStorage propagation store.
|
|
265
|
+
|
|
219
266
|
## Errors
|
|
220
267
|
|
|
221
268
|
Errors your own transaction callback throws that are already `@zudojs/errors`
|
package/dist/cache/index.d.ts
CHANGED
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* In-memory LRU cache for database read results.
|
|
5
5
|
*/
|
|
6
6
|
export { MemoryDatabaseCache, createDatabaseCache, createCacheKey, escapeCachePart, serializeCachePart, getOrSet, invalidateByPrefix, CACHE_KEY_SEPARATOR, type CacheEntry, type CacheOptions, type MemoryCacheOptions, type CacheStats, type DatabaseCache, } from "./cache.memory.js";
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/cache/index.js
CHANGED
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* In-memory LRU cache for database read results.
|
|
5
5
|
*/
|
|
6
6
|
export { MemoryDatabaseCache, createDatabaseCache, createCacheKey, escapeCachePart, serializeCachePart, getOrSet, invalidateByPrefix, CACHE_KEY_SEPARATOR, } from "./cache.memory.js";
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/dist/database/index.d.ts
CHANGED
package/dist/database/index.js
CHANGED
|
@@ -227,4 +227,3 @@ export declare function raceAbort<T>(promise: Promise<T>, signal: AbortSignal |
|
|
|
227
227
|
* the delegates.
|
|
228
228
|
*/
|
|
229
229
|
export declare function createDatabaseClient<TClient extends PrismaClientLike = PrismaClientLike>(options?: DatabaseClientOptions<TClient>): DatabaseClient<TransactionClientOf<TClient>>;
|
|
230
|
-
//# sourceMappingURL=databaseClient.core.d.ts.map
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* `clientVersion`), so the mapping works regardless of which copy of
|
|
12
12
|
* `@prisma/client` produced the error.
|
|
13
13
|
*/
|
|
14
|
-
import { DatabaseError, DatabaseOperation, type BaseError, type DatabaseErrorOptions } from "@zudojs/errors";
|
|
14
|
+
import { DatabaseError, DatabaseOperation, ErrorCode, type BaseError, type DatabaseErrorOptions } from "@zudojs/errors";
|
|
15
15
|
import type { DatabaseErrorInfo } from "../databaseType/databaseType.type.js";
|
|
16
16
|
/**
|
|
17
17
|
* Structural `DatabaseError` guard.
|
|
@@ -67,10 +67,28 @@ export interface PrismaErrorLike {
|
|
|
67
67
|
readonly message?: string;
|
|
68
68
|
readonly retryable?: boolean;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* How a Prisma error code is normalised: its classification, HTTP status,
|
|
72
|
+
* framework error code, client-safe message and whether that message may
|
|
73
|
+
* be exposed.
|
|
74
|
+
*/
|
|
75
|
+
export interface PrismaCodeMapping {
|
|
76
|
+
readonly kind: DatabaseErrorKind;
|
|
77
|
+
readonly statusCode: number;
|
|
78
|
+
readonly code: ErrorCode;
|
|
79
|
+
readonly message: string;
|
|
80
|
+
readonly expose: boolean;
|
|
81
|
+
}
|
|
70
82
|
/**
|
|
71
83
|
* Codes that indicate a transient transaction failure worth retrying.
|
|
72
84
|
*/
|
|
73
85
|
export declare const RETRYABLE_DATABASE_CODES: ReadonlySet<string>;
|
|
86
|
+
/**
|
|
87
|
+
* The mapping {@link normalizeDatabaseError} applies to a Prisma error
|
|
88
|
+
* code, or `undefined` for a code it does not know. Shared with the
|
|
89
|
+
* repository mapper so both classify the same code the same way.
|
|
90
|
+
*/
|
|
91
|
+
export declare function getPrismaCodeMapping(code: string): PrismaCodeMapping | undefined;
|
|
74
92
|
/**
|
|
75
93
|
* Detects a Prisma error structurally.
|
|
76
94
|
*/
|
|
@@ -120,4 +138,3 @@ export declare function normalizeDatabaseError(error: unknown, options?: Normali
|
|
|
120
138
|
* normalised first, so Prisma codes appear as `code`.
|
|
121
139
|
*/
|
|
122
140
|
export declare function toDatabaseErrorInfo(error: unknown, options?: NormalizeDatabaseErrorOptions): DatabaseErrorInfo;
|
|
123
|
-
//# sourceMappingURL=databaseClient.errors.d.ts.map
|
|
@@ -199,6 +199,14 @@ export const RETRYABLE_DATABASE_CODES = new Set([
|
|
|
199
199
|
"40001", // PostgreSQL: serialization_failure
|
|
200
200
|
"40P01", // PostgreSQL: deadlock_detected
|
|
201
201
|
]);
|
|
202
|
+
/**
|
|
203
|
+
* The mapping {@link normalizeDatabaseError} applies to a Prisma error
|
|
204
|
+
* code, or `undefined` for a code it does not know. Shared with the
|
|
205
|
+
* repository mapper so both classify the same code the same way.
|
|
206
|
+
*/
|
|
207
|
+
export function getPrismaCodeMapping(code) {
|
|
208
|
+
return PRISMA_CODE_MAP[code];
|
|
209
|
+
}
|
|
202
210
|
/**
|
|
203
211
|
* Detects a Prisma error structurally.
|
|
204
212
|
*/
|
|
@@ -435,4 +443,3 @@ export function toDatabaseErrorInfo(error, options = {}) {
|
|
|
435
443
|
metadata,
|
|
436
444
|
};
|
|
437
445
|
}
|
|
438
|
-
//# sourceMappingURL=databaseClient.errors.js.map
|
|
@@ -17,4 +17,3 @@ export declare const DEFAULT_DATABASE_LOGGER_NAME = "@zudojs/database";
|
|
|
17
17
|
export declare function createDatabaseLoggerAdapter(logger: Logger): DatabaseLogger;
|
|
18
18
|
/** Creates the fallback database logger, backed by `@zudojs/logger`. */
|
|
19
19
|
export declare function createDefaultLogger(): DatabaseLogger;
|
|
20
|
-
//# sourceMappingURL=databaseClient.logger.d.ts.map
|
|
@@ -50,4 +50,3 @@ export type DatabaseTransactionContext = {
|
|
|
50
50
|
export type TransactionClientOf<TClient> = TClient extends {
|
|
51
51
|
$transaction(callback: (transaction: infer TTransaction) => never, ...rest: never[]): unknown;
|
|
52
52
|
} ? [TTransaction] extends [never] ? DatabaseTransactionContext : [TTransaction] extends [DatabaseTransactionContext] ? TTransaction : DatabaseTransactionContext : DatabaseTransactionContext;
|
|
53
|
-
//# sourceMappingURL=databaseClient.type.d.ts.map
|
|
@@ -4,5 +4,4 @@
|
|
|
4
4
|
* Prisma-backed database client and connection infrastructure.
|
|
5
5
|
*/
|
|
6
6
|
export { DatabaseClient, DatabaseAbortError, createDatabaseClient, buildPrismaTransactionOptions, createAbortError, raceAbort, throwIfAborted, SUPPORTED_ISOLATION_LEVELS, type DatabaseClientOptions, type DatabaseTransactionContext, type PrismaClientLike, type PrismaDriverAdapterLike, type PrismaQueryEvent, type PrismaTransactionOptions, type PrismaSqlLike, type RawQueryOptions, type TransactionClientOf, } from "./databaseClient.core.js";
|
|
7
|
-
export { normalizeDatabaseError, withDatabaseErrorMetadata, isPrismaError, isRetryableTransactionError, isConflictError, isNotFoundError, getDatabaseErrorCode, getDatabaseErrorKind, isDatabaseErrorLike, isNonDatabaseBaseError, toDatabaseErrorInfo, RETRYABLE_DATABASE_CODES, type DatabaseErrorKind, type NormalizeDatabaseErrorOptions, type PrismaErrorLike, } from "./databaseClient.errors.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
7
|
+
export { normalizeDatabaseError, withDatabaseErrorMetadata, isPrismaError, isRetryableTransactionError, isConflictError, isNotFoundError, getDatabaseErrorCode, getDatabaseErrorKind, getPrismaCodeMapping, isDatabaseErrorLike, isNonDatabaseBaseError, toDatabaseErrorInfo, RETRYABLE_DATABASE_CODES, type DatabaseErrorKind, type NormalizeDatabaseErrorOptions, type PrismaCodeMapping, type PrismaErrorLike, } from "./databaseClient.errors.js";
|
|
@@ -4,5 +4,4 @@
|
|
|
4
4
|
* Prisma-backed database client and connection infrastructure.
|
|
5
5
|
*/
|
|
6
6
|
export { DatabaseClient, DatabaseAbortError, createDatabaseClient, buildPrismaTransactionOptions, createAbortError, raceAbort, throwIfAborted, SUPPORTED_ISOLATION_LEVELS, } from "./databaseClient.core.js";
|
|
7
|
-
export { normalizeDatabaseError, withDatabaseErrorMetadata, isPrismaError, isRetryableTransactionError, isConflictError, isNotFoundError, getDatabaseErrorCode, getDatabaseErrorKind, isDatabaseErrorLike, isNonDatabaseBaseError, toDatabaseErrorInfo, RETRYABLE_DATABASE_CODES, } from "./databaseClient.errors.js";
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
7
|
+
export { normalizeDatabaseError, withDatabaseErrorMetadata, isPrismaError, isRetryableTransactionError, isConflictError, isNotFoundError, getDatabaseErrorCode, getDatabaseErrorKind, getPrismaCodeMapping, isDatabaseErrorLike, isNonDatabaseBaseError, toDatabaseErrorInfo, RETRYABLE_DATABASE_CODES, } from "./databaseClient.errors.js";
|
|
@@ -165,4 +165,3 @@ export declare class DatabaseConnectionManager {
|
|
|
165
165
|
* Creates a database connection manager.
|
|
166
166
|
*/
|
|
167
167
|
export declare function createConnectionManager(options?: DatabaseConnectionManagerOptions): DatabaseConnectionManager;
|
|
168
|
-
//# sourceMappingURL=databaseConnection.manager.d.ts.map
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* Connection lifecycle management with health checks.
|
|
5
5
|
*/
|
|
6
6
|
export { DatabaseConnectionManager, createConnectionManager, type DatabaseConnectionEvent, type DatabaseConnectionListener, type DatabaseConnectionEventDetails, type DatabaseConnectionManagerOptions, type DatabaseReconnectOptions, } from "./databaseConnection.manager.js";
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -174,15 +174,17 @@ export interface DatabaseEntity<TId = string> {
|
|
|
174
174
|
readonly updatedAt: Date;
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
|
-
* Soft-deletable entity contract.
|
|
177
|
+
* Soft-deletable entity contract. `TId` is the primary key type (default
|
|
178
|
+
* `string`), as on {@link DatabaseEntity}.
|
|
178
179
|
*/
|
|
179
|
-
export interface SoftDeletableEntity extends DatabaseEntity {
|
|
180
|
+
export interface SoftDeletableEntity<TId = string> extends DatabaseEntity<TId> {
|
|
180
181
|
readonly deletedAt: Date | null;
|
|
181
182
|
}
|
|
182
183
|
/**
|
|
183
|
-
* Auditable entity contract.
|
|
184
|
+
* Auditable entity contract. `TId` is the primary key type (default
|
|
185
|
+
* `string`), as on {@link DatabaseEntity}.
|
|
184
186
|
*/
|
|
185
|
-
export interface AuditableEntity extends DatabaseEntity {
|
|
187
|
+
export interface AuditableEntity<TId = string> extends DatabaseEntity<TId> {
|
|
186
188
|
readonly createdBy?: string;
|
|
187
189
|
readonly updatedBy?: string;
|
|
188
190
|
}
|
|
@@ -221,4 +223,3 @@ export interface DatabaseLogger {
|
|
|
221
223
|
* Default no-op database logger.
|
|
222
224
|
*/
|
|
223
225
|
export declare const noopDatabaseLogger: DatabaseLogger;
|
|
224
|
-
//# sourceMappingURL=databaseType.type.d.ts.map
|
|
@@ -71,4 +71,3 @@ export declare function assertDatabaseHealth(client: DatabaseClient, options?: D
|
|
|
71
71
|
* Checks whether a database is reachable.
|
|
72
72
|
*/
|
|
73
73
|
export declare function isDatabaseHealthy(client: DatabaseClient, options?: DatabaseHealthOptions): Promise<boolean>;
|
|
74
|
-
//# sourceMappingURL=health.check.d.ts.map
|
package/dist/health/index.d.ts
CHANGED
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* Database health and readiness monitoring.
|
|
5
5
|
*/
|
|
6
6
|
export { checkDatabaseHealth, checkDatabaseReadiness, assertDatabaseHealth, isDatabaseHealthy, getHealthCheckCause, DatabaseUnhealthyError, DEFAULT_HEALTH_TIMEOUT_MS, type DatabaseHealthStatus, type DatabaseHealth, type DatabaseHealthOptions, type DatabaseReadiness, } from "./health.check.js";
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/health/index.js
CHANGED
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* Database health and readiness monitoring.
|
|
5
5
|
*/
|
|
6
6
|
export { checkDatabaseHealth, checkDatabaseReadiness, assertDatabaseHealth, isDatabaseHealthy, getHealthCheckCause, DatabaseUnhealthyError, DEFAULT_HEALTH_TIMEOUT_MS, } from "./health.check.js";
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -18,19 +18,18 @@
|
|
|
18
18
|
*/
|
|
19
19
|
export type { DatabaseOperationOptions, DatabaseStatus, TransactionIsolationLevel, DatabaseOperation, DatabaseConnectionOptions, DatabaseClientHealth, DatabaseHealth as DatabaseHealthInfo, TransactionOptions, TransactionCallback, Repository, SoftDeletableRepository, PaginationInput, PaginationMeta, PaginatedResult, SortDirection, SortInput, QueryOptions, DatabaseEntity, SoftDeletableEntity, AuditableEntity, DatabaseErrorInfo, DatabaseLogger, } from "./databaseType/index.js";
|
|
20
20
|
export { noopDatabaseLogger } from "./databaseType/index.js";
|
|
21
|
-
export { DatabaseClient, DatabaseAbortError, createDatabaseClient, buildPrismaTransactionOptions, createAbortError, raceAbort, throwIfAborted, SUPPORTED_ISOLATION_LEVELS, normalizeDatabaseError, withDatabaseErrorMetadata, isPrismaError, isRetryableTransactionError, isConflictError, isNotFoundError, getDatabaseErrorCode, getDatabaseErrorKind, isDatabaseErrorLike, isNonDatabaseBaseError, toDatabaseErrorInfo, RETRYABLE_DATABASE_CODES, type DatabaseClientOptions, type DatabaseTransactionContext, type PrismaClientLike, type PrismaDriverAdapterLike, type PrismaQueryEvent, type PrismaTransactionOptions, type PrismaSqlLike, type RawQueryOptions, type TransactionClientOf, type DatabaseErrorKind, type NormalizeDatabaseErrorOptions, type PrismaErrorLike, } from "./databaseClient/index.js";
|
|
21
|
+
export { DatabaseClient, DatabaseAbortError, createDatabaseClient, buildPrismaTransactionOptions, createAbortError, raceAbort, throwIfAborted, SUPPORTED_ISOLATION_LEVELS, normalizeDatabaseError, withDatabaseErrorMetadata, isPrismaError, isRetryableTransactionError, isConflictError, isNotFoundError, getPrismaCodeMapping, getDatabaseErrorCode, getDatabaseErrorKind, isDatabaseErrorLike, isNonDatabaseBaseError, toDatabaseErrorInfo, RETRYABLE_DATABASE_CODES, type DatabaseClientOptions, type DatabaseTransactionContext, type PrismaClientLike, type PrismaDriverAdapterLike, type PrismaQueryEvent, type PrismaTransactionOptions, type PrismaSqlLike, type RawQueryOptions, type TransactionClientOf, type DatabaseErrorKind, type NormalizeDatabaseErrorOptions, type PrismaErrorLike, type PrismaCodeMapping, } from "./databaseClient/index.js";
|
|
22
22
|
export { DatabaseConnectionManager, createConnectionManager, type DatabaseConnectionEvent, type DatabaseConnectionListener, type DatabaseConnectionEventDetails, type DatabaseConnectionManagerOptions, type DatabaseReconnectOptions, } from "./databaseConnection/index.js";
|
|
23
23
|
export { Database, createDatabase, getDatabase, connectDatabase, disconnectDatabase, resetDatabase, } from "./database/index.js";
|
|
24
|
-
export { BaseRepository, mapRepositoryError, isPrismaErrorLike, toDatabaseOperation, type RepositoryDelegate, type RepositoryDelegateOperations, type BaseRepositoryOptions, type SoftDeleteOptions, type CursorQueryOptions, type TransactionClientLike, type RepositoryOperation, type RepositoryErrorContext, } from "./repository/index.js";
|
|
24
|
+
export { BaseRepository, mapRepositoryError, isPrismaErrorLike, toDatabaseOperation, type RepositoryDelegate, type RepositoryDelegateOperations, type BaseRepositoryOptions, type SoftDeleteOptions, type CreateCursorOptions, type CursorQueryOptions, type TransactionClientLike, type RepositoryOperation, type RepositoryErrorContext, } from "./repository/index.js";
|
|
25
25
|
export { TransactionManager, createTransactionManager, withTransaction, withTransactionRetry, createTransactionContext, createTransactionId, getTransactionContextFromError, isTransactionActive, isTransactionCommitted, isTransactionFailed, type TransactionStatus, type TransactionContext, type TransactionOutcome, type TransactionRetryOptions, type ManagedTransactionOptions, } from "./transaction/index.js";
|
|
26
26
|
export { DatabaseUnitOfWork, createUnitOfWork, executeUnitOfWork, type UnitOfWork, type UnitOfWorkOptions, } from "./unitOfWork/index.js";
|
|
27
27
|
export { QueryBuilder, createQueryBuilder, toPrismaWhere, toPrismaArgs, toPrismaOrderBy, toPrismaSelect, toPrismaSkipTake, type QueryCondition, type QueryFilter, type QueryOperator, type RelationOperator, type QueryBuilderState, type PrismaWhere, type PrismaQueryArgs, type ToPrismaArgsOptions, } from "./queryBuilder/index.js";
|
|
28
28
|
export { equals, notEquals, inList, notInList, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual, contains, startsWith, endsWith, isNull, isNotNull, and, or, not, condition, allOf, anyOf, fromObject, dateRange, oneOf, noneOf, optionalEquals, optionalContains, hasConditions, flattenAnd, cloneFilter, between, matchesPattern, isEmpty, isNotEmpty, dateOnly, isBefore, isAfter, isBetween, notCondition, relational, } from "./queryBuilder/index.js";
|
|
29
|
-
export { normalizePagination, normalizePage, normalizeLimit, calculateOffset, calculateTotalPages, createPaginationMeta, createPaginatedResult, getNextPage, getPreviousPage, isValidPage, getItemRange, paginateCollection, encodeCursor, decodeCursor, validateCursorPayload, decodeKeysetCursor, buildKeysetWhere, createKeysetCursor, createKeysetPage, KEYSET_BACKWARD_KEY, getKeysetDirection, reverseKeysetSort, keysetFetchSort, createInvalidCursorError, normalizeCursorPagination, createCursorPaginationMeta, createCursorPaginatedResult, DEFAULT_PAGE, DEFAULT_LIMIT, MAX_LIMIT, type NormalizedPagination, type CursorPaginationInput, type CursorPaginationMeta, type CursorPaginatedResult, type CursorPayload, type EncodeCursorOptions, type DecodeCursorOptions, type KeysetPageOptions, type KeysetWhere, type KeysetDirection, type InvalidCursorReason, } from "./pagination/index.js";
|
|
29
|
+
export { normalizePagination, normalizePage, normalizeLimit, calculateOffset, calculateTotalPages, createPaginationMeta, createPaginatedResult, getNextPage, getPreviousPage, isValidPage, getItemRange, paginateCollection, encodeCursor, decodeCursor, validateCursorPayload, decodeKeysetCursor, buildKeysetWhere, createKeysetCursor, createKeysetPage, KEYSET_BACKWARD_KEY, getKeysetDirection, reverseKeysetSort, keysetFetchSort, createInvalidCursorError, isDateCursorValue, keysetStrictFilter, keysetTieFilter, nextMillisecond, normalizeCursorPagination, createCursorPaginationMeta, createCursorPaginatedResult, DEFAULT_PAGE, DEFAULT_LIMIT, MAX_LIMIT, type NormalizedPagination, type CursorPaginationInput, type CursorPaginationMeta, type CursorPaginatedResult, type CursorPayload, type EncodeCursorOptions, type DecodeCursorOptions, type KeysetPageOptions, type KeysetWhere, type KeysetDirection, type InvalidCursorReason, } from "./pagination/index.js";
|
|
30
30
|
export { oneToOne, oneToMany, manyToOne, manyToMany, includeRelation, includeRelations, RelationRegistry, createRelationRegistry, validateRelation, validateInclude, toPrismaInclude, DEFAULT_INCLUDE_DEPTH, isRelationType, isCollectionRelation, isSingleRelation, type RelationDefinition, type RelationType, type RelationLoadOptions, type RelationInclude, type ToPrismaIncludeOptions, } from "./relations/index.js";
|
|
31
31
|
export { DatabaseLockManager, createLockManager, acquireAdvisoryLock, lockRow, buildLockClause, normalizeAdvisoryKey, normalizeAdvisoryKeyPair, resolveLockTransactionOptions, type DatabaseLockMode, type DatabaseLockOptions, type DatabaseLockResult, } from "./locks/index.js";
|
|
32
32
|
export { MemoryDatabaseCache, createDatabaseCache, createCacheKey, escapeCachePart, serializeCachePart, getOrSet, invalidateByPrefix, CACHE_KEY_SEPARATOR, type CacheEntry, type CacheOptions, type MemoryCacheOptions, type CacheStats, type DatabaseCache, } from "./cache/index.js";
|
|
33
33
|
export { MigrationRunner, createMigrationRunner, normalizeMigrations, validateMigration, getLatestVersion, getCurrentVersion, DEFAULT_MIGRATION_TABLE, DEFAULT_MIGRATION_LOCK, SQL_IDENTIFIER_PATTERN, validateIdentifier, validateLockKey, quoteIdentifier, hashLockKey, fnv1a64, getSqlDialect, isSqlDialectName, UnsupportedDialectError, DEFAULT_SQL_DIALECT, type Migration, type MigrationRecord, type MigrationResult, type MigrationStatus, type MigrationRunnerOptions, type RunnerTransactionOptions, type SqlDialect, type SqlDialectName, } from "./migration/index.js";
|
|
34
34
|
export { SeedRunner, createSeedRunner, normalizeSeeds, validateSeed, DEFAULT_SEED_TABLE, DEFAULT_SEED_LOCK, type Seed, type SeedRecord, type SeedResult, type SeedStatus, type SeedRunnerOptions, } from "./seed/index.js";
|
|
35
35
|
export { checkDatabaseHealth, checkDatabaseReadiness, assertDatabaseHealth, isDatabaseHealthy, getHealthCheckCause, DatabaseUnhealthyError, DEFAULT_HEALTH_TIMEOUT_MS, type DatabaseHealthStatus, type DatabaseHealth, type DatabaseHealthOptions, type DatabaseReadiness, } from "./health/index.js";
|
|
36
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
export { noopDatabaseLogger } from "./databaseType/index.js";
|
|
20
20
|
// Client
|
|
21
|
-
export { DatabaseClient, DatabaseAbortError, createDatabaseClient, buildPrismaTransactionOptions, createAbortError, raceAbort, throwIfAborted, SUPPORTED_ISOLATION_LEVELS, normalizeDatabaseError, withDatabaseErrorMetadata, isPrismaError, isRetryableTransactionError, isConflictError, isNotFoundError, getDatabaseErrorCode, getDatabaseErrorKind, isDatabaseErrorLike, isNonDatabaseBaseError, toDatabaseErrorInfo, RETRYABLE_DATABASE_CODES, } from "./databaseClient/index.js";
|
|
21
|
+
export { DatabaseClient, DatabaseAbortError, createDatabaseClient, buildPrismaTransactionOptions, createAbortError, raceAbort, throwIfAborted, SUPPORTED_ISOLATION_LEVELS, normalizeDatabaseError, withDatabaseErrorMetadata, isPrismaError, isRetryableTransactionError, isConflictError, isNotFoundError, getPrismaCodeMapping, getDatabaseErrorCode, getDatabaseErrorKind, isDatabaseErrorLike, isNonDatabaseBaseError, toDatabaseErrorInfo, RETRYABLE_DATABASE_CODES, } from "./databaseClient/index.js";
|
|
22
22
|
// Connection
|
|
23
23
|
export { DatabaseConnectionManager, createConnectionManager, } from "./databaseConnection/index.js";
|
|
24
24
|
// Database facade
|
|
@@ -33,7 +33,7 @@ export { DatabaseUnitOfWork, createUnitOfWork, executeUnitOfWork, } from "./unit
|
|
|
33
33
|
export { QueryBuilder, createQueryBuilder, toPrismaWhere, toPrismaArgs, toPrismaOrderBy, toPrismaSelect, toPrismaSkipTake, } from "./queryBuilder/index.js";
|
|
34
34
|
export { equals, notEquals, inList, notInList, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual, contains, startsWith, endsWith, isNull, isNotNull, and, or, not, condition, allOf, anyOf, fromObject, dateRange, oneOf, noneOf, optionalEquals, optionalContains, hasConditions, flattenAnd, cloneFilter, between, matchesPattern, isEmpty, isNotEmpty, dateOnly, isBefore, isAfter, isBetween, notCondition, relational, } from "./queryBuilder/index.js";
|
|
35
35
|
// Pagination
|
|
36
|
-
export { normalizePagination, normalizePage, normalizeLimit, calculateOffset, calculateTotalPages, createPaginationMeta, createPaginatedResult, getNextPage, getPreviousPage, isValidPage, getItemRange, paginateCollection, encodeCursor, decodeCursor, validateCursorPayload, decodeKeysetCursor, buildKeysetWhere, createKeysetCursor, createKeysetPage, KEYSET_BACKWARD_KEY, getKeysetDirection, reverseKeysetSort, keysetFetchSort, createInvalidCursorError, normalizeCursorPagination, createCursorPaginationMeta, createCursorPaginatedResult, DEFAULT_PAGE, DEFAULT_LIMIT, MAX_LIMIT, } from "./pagination/index.js";
|
|
36
|
+
export { normalizePagination, normalizePage, normalizeLimit, calculateOffset, calculateTotalPages, createPaginationMeta, createPaginatedResult, getNextPage, getPreviousPage, isValidPage, getItemRange, paginateCollection, encodeCursor, decodeCursor, validateCursorPayload, decodeKeysetCursor, buildKeysetWhere, createKeysetCursor, createKeysetPage, KEYSET_BACKWARD_KEY, getKeysetDirection, reverseKeysetSort, keysetFetchSort, createInvalidCursorError, isDateCursorValue, keysetStrictFilter, keysetTieFilter, nextMillisecond, normalizeCursorPagination, createCursorPaginationMeta, createCursorPaginatedResult, DEFAULT_PAGE, DEFAULT_LIMIT, MAX_LIMIT, } from "./pagination/index.js";
|
|
37
37
|
// Relations
|
|
38
38
|
export { oneToOne, oneToMany, manyToOne, manyToMany, includeRelation, includeRelations, RelationRegistry, createRelationRegistry, validateRelation, validateInclude, toPrismaInclude, DEFAULT_INCLUDE_DEPTH, isRelationType, isCollectionRelation, isSingleRelation, } from "./relations/index.js";
|
|
39
39
|
// Locks
|
|
@@ -46,4 +46,3 @@ export { MigrationRunner, createMigrationRunner, normalizeMigrations, validateMi
|
|
|
46
46
|
export { SeedRunner, createSeedRunner, normalizeSeeds, validateSeed, DEFAULT_SEED_TABLE, DEFAULT_SEED_LOCK, } from "./seed/index.js";
|
|
47
47
|
// Health
|
|
48
48
|
export { checkDatabaseHealth, checkDatabaseReadiness, assertDatabaseHealth, isDatabaseHealthy, getHealthCheckCause, DatabaseUnhealthyError, DEFAULT_HEALTH_TIMEOUT_MS, } from "./health/index.js";
|
|
49
|
-
//# sourceMappingURL=index.js.map
|
package/dist/locks/index.d.ts
CHANGED
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* Advisory and row-level database locking (PostgreSQL).
|
|
5
5
|
*/
|
|
6
6
|
export { DatabaseLockManager, createLockManager, acquireAdvisoryLock, lockRow, buildLockClause, normalizeAdvisoryKey, normalizeAdvisoryKeyPair, resolveLockTransactionOptions, type DatabaseLockMode, type DatabaseLockOptions, type DatabaseLockResult, } from "./locks.core.js";
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/locks/index.js
CHANGED
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* Advisory and row-level database locking (PostgreSQL).
|
|
5
5
|
*/
|
|
6
6
|
export { DatabaseLockManager, createLockManager, acquireAdvisoryLock, lockRow, buildLockClause, normalizeAdvisoryKey, normalizeAdvisoryKeyPair, resolveLockTransactionOptions, } from "./locks.core.js";
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -131,4 +131,3 @@ export declare function normalizeAdvisoryKeyPair(namespace: string, lockKey: str
|
|
|
131
131
|
* than `timeoutMs`.
|
|
132
132
|
*/
|
|
133
133
|
export declare function resolveLockTransactionOptions(options?: DatabaseLockOptions): TransactionOptions | undefined;
|
|
134
|
-
//# sourceMappingURL=locks.core.d.ts.map
|
package/dist/locks/locks.core.js
CHANGED
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
export { MigrationRunner, createMigrationRunner, normalizeMigrations, validateMigration, getLatestVersion, getCurrentVersion, DEFAULT_MIGRATION_TABLE, DEFAULT_MIGRATION_LOCK, type Migration, type MigrationRecord, type MigrationResult, type MigrationStatus, type MigrationRunnerOptions, type RunnerTransactionOptions, } from "./migration.runner.js";
|
|
7
7
|
export { SQL_IDENTIFIER_PATTERN, validateIdentifier, validateLockKey, quoteIdentifier, hashLockKey, fnv1a64, FNV1A_64_OFFSET_BASIS, FNV1A_64_PRIME, } from "./migration.helpers.js";
|
|
8
8
|
export { getSqlDialect, isSqlDialectName, UnsupportedDialectError, DEFAULT_SQL_DIALECT, type SqlDialect, type SqlDialectName, } from "./migration.dialect.js";
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/migration/index.js
CHANGED
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
export { MigrationRunner, createMigrationRunner, normalizeMigrations, validateMigration, getLatestVersion, getCurrentVersion, DEFAULT_MIGRATION_TABLE, DEFAULT_MIGRATION_LOCK, } from "./migration.runner.js";
|
|
7
7
|
export { SQL_IDENTIFIER_PATTERN, validateIdentifier, validateLockKey, quoteIdentifier, hashLockKey, fnv1a64, FNV1A_64_OFFSET_BASIS, FNV1A_64_PRIME, } from "./migration.helpers.js";
|
|
8
8
|
export { getSqlDialect, isSqlDialectName, UnsupportedDialectError, DEFAULT_SQL_DIALECT, } from "./migration.dialect.js";
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -58,6 +58,10 @@ export function validateMigration(migration) {
|
|
|
58
58
|
if (migration.down !== undefined && typeof migration.down !== "function") {
|
|
59
59
|
throw new TypeError(`Migration "${migration.name}" has an invalid down function.`);
|
|
60
60
|
}
|
|
61
|
+
if (migration.transaction !== undefined &&
|
|
62
|
+
typeof migration.transaction !== "boolean") {
|
|
63
|
+
throw new TypeError(`Migration "${migration.name}" has an invalid transaction flag.`);
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
/**
|
|
63
67
|
* Returns the highest registered migration version.
|
|
@@ -138,4 +142,3 @@ export function fnv1a64(value) {
|
|
|
138
142
|
export function hashLockKey(value) {
|
|
139
143
|
return BigInt.asIntN(64, fnv1a64(value));
|
|
140
144
|
}
|
|
141
|
-
//# sourceMappingURL=migration.helpers.js.map
|
|
@@ -26,6 +26,14 @@ export declare class MigrationRunner<TTransaction extends DatabaseTransactionCon
|
|
|
26
26
|
* Applies every pending migration in version order.
|
|
27
27
|
*/
|
|
28
28
|
migrate(): Promise<MigrationResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Applies a `transaction: false` migration: the applied check and the
|
|
31
|
+
* history record run in short transactions under the advisory lock, the
|
|
32
|
+
* body runs on the root client outside any transaction.
|
|
33
|
+
*/
|
|
34
|
+
private applyDetached;
|
|
35
|
+
/** The root Prisma client, handed to migrations that opt out of a transaction. */
|
|
36
|
+
private rootClient;
|
|
29
37
|
/**
|
|
30
38
|
* Alias of {@link migrate}.
|
|
31
39
|
*/
|
|
@@ -58,7 +66,11 @@ export declare class MigrationRunner<TTransaction extends DatabaseTransactionCon
|
|
|
58
66
|
*/
|
|
59
67
|
getHistory(): Promise<readonly MigrationRecord[]>;
|
|
60
68
|
private rollbackSteps;
|
|
69
|
+
/** Reverts a `transaction: false` migration; see {@link applyDetached}. */
|
|
70
|
+
private revertDetached;
|
|
61
71
|
private revertRecord;
|
|
72
|
+
private requireRollback;
|
|
73
|
+
private runDown;
|
|
62
74
|
private computePending;
|
|
63
75
|
private buildTransactionOptions;
|
|
64
76
|
private executor;
|
|
@@ -72,4 +84,3 @@ export declare class MigrationRunner<TTransaction extends DatabaseTransactionCon
|
|
|
72
84
|
* Creates a migration runner.
|
|
73
85
|
*/
|
|
74
86
|
export declare function createMigrationRunner<TTransaction extends DatabaseTransactionContext = DatabaseTransactionContext>(client: DatabaseClient<TTransaction>, migrations: readonly Migration<TTransaction>[], options?: MigrationRunnerOptions): MigrationRunner<TTransaction>;
|
|
75
|
-
//# sourceMappingURL=migration.runner.d.ts.map
|