@zudojs/transactions 1.1.0 → 1.1.1
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 +12 -0
- package/dist/manager/manager.commit.js +9 -1
- package/dist/manager/manager.propagation.js +1 -1
- package/dist/transaction/transaction.core.d.ts +3 -1
- package/dist/transaction/transaction.core.js +8 -1
- package/dist/transaction/transaction.savepoint.d.ts +24 -0
- package/dist/transaction/transaction.savepoint.js +29 -0
- package/dist/transactionErrors/index.d.ts +1 -1
- package/dist/transactionErrors/index.js +1 -1
- package/dist/transactionErrors/transactionError.base.d.ts +5 -11
- package/dist/transactionErrors/transactionError.base.js +5 -15
- package/dist/transactionErrors/transactionError.types.d.ts +5 -70
- package/dist/transactionErrors/transactionError.types.js +5 -125
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Transaction lifecycle and coordination with state machine, AsyncLocalStorage context propagation, savepoints, hooks, and adapter abstraction.
|
|
4
4
|
|
|
5
|
+
<!-- zudo-docs:start -->
|
|
6
|
+
|
|
7
|
+
**Documentation:** [zudojs.oyinlola.site/docs/packages-transactions](https://zudojs.oyinlola.site/docs/packages-transactions) · **For AI agents:** [Markdown version](https://zudojs.oyinlola.site/docs/packages-transactions.md), [llms.txt](https://zudojs.oyinlola.site/llms.txt)
|
|
8
|
+
|
|
9
|
+
<!-- zudo-docs:end -->
|
|
10
|
+
|
|
5
11
|
## Installation
|
|
6
12
|
|
|
7
13
|
```bash
|
|
@@ -105,6 +111,12 @@ the transaction.
|
|
|
105
111
|
- A `nested` transaction rolls back to its savepoint, never to the connection.
|
|
106
112
|
Savepoints are always created on the connection, including when the
|
|
107
113
|
enclosing scope is itself a savepoint or a participant.
|
|
114
|
+
- Releasing a savepoint is not a commit. `afterCommit` and `afterRollback`
|
|
115
|
+
callbacks registered inside a `nested` block, and `hooks.afterCommit` for the
|
|
116
|
+
savepoint, move to the enclosing transaction on release. They run only when
|
|
117
|
+
the outermost transaction commits (or, for `afterRollback`, rolls back). A
|
|
118
|
+
savepoint that is itself rolled back runs its `afterRollback` callbacks at
|
|
119
|
+
once and discards its `afterCommit` callbacks.
|
|
108
120
|
- `begin()` and `run()` both honour `timeout`; completing a transaction through
|
|
109
121
|
`manager.commit()` / `manager.rollback()` releases its timer and registry entry.
|
|
110
122
|
- Failures thrown by `afterCommit` callbacks never undo the commit; they are
|
|
@@ -98,6 +98,13 @@ export async function commitTransaction(transaction, adapter, hooks, emit = noop
|
|
|
98
98
|
if (hooks?.beforeCommit)
|
|
99
99
|
await hooks.beforeCommit({ transaction });
|
|
100
100
|
emit(TRANSACTION_EVENTS.COMMITTING, transaction);
|
|
101
|
+
if (hooks?.afterCommit && transaction.kind === "savepoint") {
|
|
102
|
+
// Releasing a savepoint is not a commit. Registered as a callback, the
|
|
103
|
+
// hook is deferred with the savepoint's own callbacks and fires only if
|
|
104
|
+
// the outermost transaction commits.
|
|
105
|
+
const afterCommit = hooks.afterCommit;
|
|
106
|
+
transaction.afterCommit(() => afterCommit({ transaction }));
|
|
107
|
+
}
|
|
101
108
|
try {
|
|
102
109
|
await adapterCommit(transaction, adapter);
|
|
103
110
|
await transaction.commit();
|
|
@@ -119,8 +126,9 @@ export async function commitTransaction(transaction, adapter, hooks, emit = noop
|
|
|
119
126
|
error: new AggregateError(callbackErrors, "after-commit callback failures"),
|
|
120
127
|
});
|
|
121
128
|
}
|
|
122
|
-
if (hooks?.afterCommit)
|
|
129
|
+
if (hooks?.afterCommit && transaction.kind !== "savepoint") {
|
|
123
130
|
await hooks.afterCommit({ transaction });
|
|
131
|
+
}
|
|
124
132
|
}
|
|
125
133
|
/**
|
|
126
134
|
* Rollback a transaction with hooks and adapter coordination.
|
|
@@ -56,7 +56,7 @@ async function beginSavepoint(parent, context) {
|
|
|
56
56
|
// rule violation, and TransactionCapabilityError names what is missing.
|
|
57
57
|
throw new TransactionCapabilityError("savepoints, required by nested transactions");
|
|
58
58
|
}
|
|
59
|
-
const child = createTransaction(opts, parent.id, "savepoint");
|
|
59
|
+
const child = createTransaction(opts, parent.id, "savepoint", parent);
|
|
60
60
|
if (hooks?.beforeBegin)
|
|
61
61
|
await hooks.beforeBegin({ transaction: child });
|
|
62
62
|
const savepoint = `sp_${child.id}`;
|
|
@@ -9,6 +9,8 @@ import type { TransactionKind } from "../transactionTypes/transactionState.js";
|
|
|
9
9
|
* @param options - Options the transaction was started with.
|
|
10
10
|
* @param parentId - Enclosing transaction id, for nested transactions.
|
|
11
11
|
* @param kind - How this handle relates to the adapter transaction.
|
|
12
|
+
* @param parent - The enclosing transaction of a savepoint. Its callbacks
|
|
13
|
+
* are deferred to `parent` on release instead of running.
|
|
12
14
|
*/
|
|
13
|
-
export declare function createTransaction(options?: TransactionOptions, parentId?: string, kind?: TransactionKind): Transaction;
|
|
15
|
+
export declare function createTransaction(options?: TransactionOptions, parentId?: string, kind?: TransactionKind, parent?: Transaction): Transaction;
|
|
14
16
|
//# sourceMappingURL=transaction.core.d.ts.map
|
|
@@ -5,6 +5,7 @@ import { randomBytes } from "node:crypto";
|
|
|
5
5
|
import { TransactionRollbackError, TransactionStateError, } from "../transactionErrors/transactionError.types.js";
|
|
6
6
|
import { canTransition, createTransitionFunction, } from "./transactionStateMachine.js";
|
|
7
7
|
import { attachInternals } from "./transaction.internal.js";
|
|
8
|
+
import { deferCallbacksToParent } from "./transaction.savepoint.js";
|
|
8
9
|
/**
|
|
9
10
|
* Generate a unique transaction ID.
|
|
10
11
|
*/
|
|
@@ -30,8 +31,10 @@ async function runCallbacks(callbacks) {
|
|
|
30
31
|
* @param options - Options the transaction was started with.
|
|
31
32
|
* @param parentId - Enclosing transaction id, for nested transactions.
|
|
32
33
|
* @param kind - How this handle relates to the adapter transaction.
|
|
34
|
+
* @param parent - The enclosing transaction of a savepoint. Its callbacks
|
|
35
|
+
* are deferred to `parent` on release instead of running.
|
|
33
36
|
*/
|
|
34
|
-
export function createTransaction(options = {}, parentId, kind = "root") {
|
|
37
|
+
export function createTransaction(options = {}, parentId, kind = "root", parent) {
|
|
35
38
|
let state = "pending";
|
|
36
39
|
let rollbackOnly = false;
|
|
37
40
|
let rollbackOnlyReason;
|
|
@@ -91,6 +94,10 @@ export function createTransaction(options = {}, parentId, kind = "root") {
|
|
|
91
94
|
}
|
|
92
95
|
transition("committing");
|
|
93
96
|
transition("committed");
|
|
97
|
+
if (kind === "savepoint" && parent !== undefined) {
|
|
98
|
+
deferCallbacksToParent(parent, afterCommitCallbacks, afterRollbackCallbacks);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
94
101
|
afterRollbackCallbacks.length = 0;
|
|
95
102
|
// The commit stands whatever the callbacks do; their failures are
|
|
96
103
|
// kept for the manager to report instead of being dropped.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Savepoint callback deferral.
|
|
3
|
+
*
|
|
4
|
+
* Releasing a savepoint is not a commit: the enclosing transaction can still
|
|
5
|
+
* roll back and discard everything the savepoint did. Callbacks registered on
|
|
6
|
+
* a savepoint therefore move to its parent when the savepoint is released,
|
|
7
|
+
* the same way a participant registers straight on the transaction it
|
|
8
|
+
* joined. They run once the outermost transaction settles: `afterCommit`
|
|
9
|
+
* when it commits, `afterRollback` when it rolls back.
|
|
10
|
+
*
|
|
11
|
+
* @module transaction/transaction.savepoint
|
|
12
|
+
*/
|
|
13
|
+
import type { Transaction } from "../transactionTypes/transaction.interface.js";
|
|
14
|
+
/**
|
|
15
|
+
* Move a released savepoint's pending callbacks onto its parent.
|
|
16
|
+
*
|
|
17
|
+
* Both arrays are emptied: the callbacks now belong to the parent.
|
|
18
|
+
*
|
|
19
|
+
* @param parent - The transaction the savepoint was created on.
|
|
20
|
+
* @param afterCommit - The savepoint's pending after-commit callbacks.
|
|
21
|
+
* @param afterRollback - The savepoint's pending after-rollback callbacks.
|
|
22
|
+
*/
|
|
23
|
+
export declare function deferCallbacksToParent(parent: Transaction, afterCommit: Array<() => Promise<void>>, afterRollback: Array<() => Promise<void>>): void;
|
|
24
|
+
//# sourceMappingURL=transaction.savepoint.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Savepoint callback deferral.
|
|
3
|
+
*
|
|
4
|
+
* Releasing a savepoint is not a commit: the enclosing transaction can still
|
|
5
|
+
* roll back and discard everything the savepoint did. Callbacks registered on
|
|
6
|
+
* a savepoint therefore move to its parent when the savepoint is released,
|
|
7
|
+
* the same way a participant registers straight on the transaction it
|
|
8
|
+
* joined. They run once the outermost transaction settles: `afterCommit`
|
|
9
|
+
* when it commits, `afterRollback` when it rolls back.
|
|
10
|
+
*
|
|
11
|
+
* @module transaction/transaction.savepoint
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Move a released savepoint's pending callbacks onto its parent.
|
|
15
|
+
*
|
|
16
|
+
* Both arrays are emptied: the callbacks now belong to the parent.
|
|
17
|
+
*
|
|
18
|
+
* @param parent - The transaction the savepoint was created on.
|
|
19
|
+
* @param afterCommit - The savepoint's pending after-commit callbacks.
|
|
20
|
+
* @param afterRollback - The savepoint's pending after-rollback callbacks.
|
|
21
|
+
*/
|
|
22
|
+
export function deferCallbacksToParent(parent, afterCommit, afterRollback) {
|
|
23
|
+
for (const callback of afterCommit.splice(0))
|
|
24
|
+
parent.afterCommit(callback);
|
|
25
|
+
for (const callback of afterRollback.splice(0)) {
|
|
26
|
+
parent.afterRollback(callback);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=transaction.savepoint.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Transaction error types.
|
|
3
3
|
*/
|
|
4
|
-
export { TransactionError } from "./transactionError.base.js";
|
|
4
|
+
export { TransactionError, type TransactionErrorOptions, } from "./transactionError.base.js";
|
|
5
5
|
export { TransactionStateError, TransactionTimeoutError, TransactionCommitError, TransactionRollbackError, TransactionAdapterError, TransactionPropagationError, TransactionIsolationError, SavepointError, TransactionRequiredError, TransactionUnexpectedError, TransactionCapabilityError, } from "./transactionError.types.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Transaction error types.
|
|
3
3
|
*/
|
|
4
|
-
export { TransactionError } from "./transactionError.base.js";
|
|
4
|
+
export { TransactionError, } from "./transactionError.base.js";
|
|
5
5
|
export { TransactionStateError, TransactionTimeoutError, TransactionCommitError, TransactionRollbackError, TransactionAdapterError, TransactionPropagationError, TransactionIsolationError, SavepointError, TransactionRequiredError, TransactionUnexpectedError, TransactionCapabilityError, } from "./transactionError.types.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base transaction error class.
|
|
3
|
+
*
|
|
4
|
+
* Owned by `@zudojs/errors` (round 10 INF-16) and re-exported here, so
|
|
5
|
+
* `instanceof TransactionError` matches whichever package a caller imports
|
|
6
|
+
* it from. Name, constructor, `code` defaults and category are unchanged.
|
|
3
7
|
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Base error for all transaction-related failures.
|
|
7
|
-
*/
|
|
8
|
-
export declare class TransactionError extends BaseError {
|
|
9
|
-
constructor(message: string, options?: {
|
|
10
|
-
readonly code?: ErrorCode;
|
|
11
|
-
readonly metadata?: ErrorMetadata;
|
|
12
|
-
readonly cause?: unknown;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
8
|
+
export { TransactionError, type TransactionErrorOptions } from "@zudojs/errors";
|
|
15
9
|
//# sourceMappingURL=transactionError.base.d.ts.map
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base transaction error class.
|
|
3
|
+
*
|
|
4
|
+
* Owned by `@zudojs/errors` (round 10 INF-16) and re-exported here, so
|
|
5
|
+
* `instanceof TransactionError` matches whichever package a caller imports
|
|
6
|
+
* it from. Name, constructor, `code` defaults and category are unchanged.
|
|
3
7
|
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Base error for all transaction-related failures.
|
|
7
|
-
*/
|
|
8
|
-
export class TransactionError extends BaseError {
|
|
9
|
-
constructor(message, options) {
|
|
10
|
-
super(message, {
|
|
11
|
-
code: options?.code ?? ErrorCode.OPERATION_FAILED,
|
|
12
|
-
category: ErrorCategory.DATABASE,
|
|
13
|
-
severity: ErrorSeverity.ERROR,
|
|
14
|
-
metadata: options?.metadata,
|
|
15
|
-
cause: options?.cause,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
8
|
+
export { TransactionError } from "@zudojs/errors";
|
|
19
9
|
//# sourceMappingURL=transactionError.base.js.map
|
|
@@ -1,74 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Specific transaction error subclasses.
|
|
3
|
+
*
|
|
4
|
+
* Owned by `@zudojs/errors` (round 10 INF-16) and re-exported here with the
|
|
5
|
+
* same names, constructor signatures and codes, so `instanceof` checks match
|
|
6
|
+
* across both import paths.
|
|
3
7
|
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Transaction is in an invalid state for the requested operation.
|
|
7
|
-
*/
|
|
8
|
-
export declare class TransactionStateError extends TransactionError {
|
|
9
|
-
constructor(state: string, operation: string);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Transaction exceeded its timeout.
|
|
13
|
-
*/
|
|
14
|
-
export declare class TransactionTimeoutError extends TransactionError {
|
|
15
|
-
constructor(transactionId: string, timeoutMs: number);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Transaction commit failed.
|
|
19
|
-
*/
|
|
20
|
-
export declare class TransactionCommitError extends TransactionError {
|
|
21
|
-
constructor(transactionId: string, cause?: unknown);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Transaction rollback failed.
|
|
25
|
-
*/
|
|
26
|
-
export declare class TransactionRollbackError extends TransactionError {
|
|
27
|
-
constructor(transactionId: string, options?: {
|
|
28
|
-
readonly cause?: unknown;
|
|
29
|
-
readonly originalError?: unknown;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The underlying adapter threw an error.
|
|
34
|
-
*/
|
|
35
|
-
export declare class TransactionAdapterError extends TransactionError {
|
|
36
|
-
constructor(message: string, cause?: unknown);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Propagation strategy violation.
|
|
40
|
-
*/
|
|
41
|
-
export declare class TransactionPropagationError extends TransactionError {
|
|
42
|
-
constructor(message: string);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Required isolation level is not supported by the adapter.
|
|
46
|
-
*/
|
|
47
|
-
export declare class TransactionIsolationError extends TransactionError {
|
|
48
|
-
constructor(level: string);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Savepoint operation failed.
|
|
52
|
-
*/
|
|
53
|
-
export declare class SavepointError extends TransactionError {
|
|
54
|
-
constructor(message: string, cause?: unknown);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* A transaction is required but none exists.
|
|
58
|
-
*/
|
|
59
|
-
export declare class TransactionRequiredError extends TransactionError {
|
|
60
|
-
constructor();
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* A transaction exists but none was expected.
|
|
64
|
-
*/
|
|
65
|
-
export declare class TransactionUnexpectedError extends TransactionError {
|
|
66
|
-
constructor();
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* The adapter does not support the requested capability.
|
|
70
|
-
*/
|
|
71
|
-
export declare class TransactionCapabilityError extends TransactionError {
|
|
72
|
-
constructor(capability: string);
|
|
73
|
-
}
|
|
8
|
+
export { TransactionStateError, TransactionTimeoutError, TransactionCommitError, TransactionRollbackError, TransactionAdapterError, TransactionPropagationError, TransactionIsolationError, SavepointError, TransactionRequiredError, TransactionUnexpectedError, TransactionCapabilityError, } from "@zudojs/errors";
|
|
74
9
|
//# sourceMappingURL=transactionError.types.d.ts.map
|
|
@@ -1,129 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Specific transaction error subclasses.
|
|
3
|
+
*
|
|
4
|
+
* Owned by `@zudojs/errors` (round 10 INF-16) and re-exported here with the
|
|
5
|
+
* same names, constructor signatures and codes, so `instanceof` checks match
|
|
6
|
+
* across both import paths.
|
|
3
7
|
*/
|
|
4
|
-
|
|
5
|
-
import { TransactionError } from "./transactionError.base.js";
|
|
6
|
-
/**
|
|
7
|
-
* Transaction is in an invalid state for the requested operation.
|
|
8
|
-
*/
|
|
9
|
-
export class TransactionStateError extends TransactionError {
|
|
10
|
-
constructor(state, operation) {
|
|
11
|
-
super(`Cannot ${operation} transaction in state "${state}"`, {
|
|
12
|
-
code: ErrorCode.LIFECYCLE_STATE,
|
|
13
|
-
metadata: { state, operation },
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Transaction exceeded its timeout.
|
|
19
|
-
*/
|
|
20
|
-
export class TransactionTimeoutError extends TransactionError {
|
|
21
|
-
constructor(transactionId, timeoutMs) {
|
|
22
|
-
super(`Transaction "${transactionId}" timed out after ${timeoutMs}ms`, {
|
|
23
|
-
code: ErrorCode.TIMEOUT,
|
|
24
|
-
metadata: { transactionId, timeoutMs },
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Transaction commit failed.
|
|
30
|
-
*/
|
|
31
|
-
export class TransactionCommitError extends TransactionError {
|
|
32
|
-
constructor(transactionId, cause) {
|
|
33
|
-
super(`Transaction "${transactionId}" commit failed`, {
|
|
34
|
-
code: ErrorCode.DATABASE_TRANSACTION,
|
|
35
|
-
cause,
|
|
36
|
-
metadata: { transactionId },
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Transaction rollback failed.
|
|
42
|
-
*/
|
|
43
|
-
export class TransactionRollbackError extends TransactionError {
|
|
44
|
-
constructor(transactionId, options) {
|
|
45
|
-
super(`Transaction "${transactionId}" rollback failed`, {
|
|
46
|
-
code: ErrorCode.DATABASE_TRANSACTION,
|
|
47
|
-
cause: options?.cause,
|
|
48
|
-
metadata: {
|
|
49
|
-
transactionId,
|
|
50
|
-
originalError: options?.originalError instanceof Error
|
|
51
|
-
? options.originalError.message
|
|
52
|
-
: String(options?.originalError ?? "unknown"),
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The underlying adapter threw an error.
|
|
59
|
-
*/
|
|
60
|
-
export class TransactionAdapterError extends TransactionError {
|
|
61
|
-
constructor(message, cause) {
|
|
62
|
-
super(message, {
|
|
63
|
-
code: ErrorCode.ADAPTER_OPERATION_FAILED,
|
|
64
|
-
cause,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Propagation strategy violation.
|
|
70
|
-
*/
|
|
71
|
-
export class TransactionPropagationError extends TransactionError {
|
|
72
|
-
constructor(message) {
|
|
73
|
-
super(message, { code: ErrorCode.VALIDATION_FAILED });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Required isolation level is not supported by the adapter.
|
|
78
|
-
*/
|
|
79
|
-
export class TransactionIsolationError extends TransactionError {
|
|
80
|
-
constructor(level) {
|
|
81
|
-
super(`Isolation level "${level}" is not supported by the adapter`, {
|
|
82
|
-
code: ErrorCode.VALIDATION_FAILED,
|
|
83
|
-
metadata: { level },
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Savepoint operation failed.
|
|
89
|
-
*/
|
|
90
|
-
export class SavepointError extends TransactionError {
|
|
91
|
-
constructor(message, cause) {
|
|
92
|
-
super(message, {
|
|
93
|
-
code: ErrorCode.OPERATION_FAILED,
|
|
94
|
-
cause,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* A transaction is required but none exists.
|
|
100
|
-
*/
|
|
101
|
-
export class TransactionRequiredError extends TransactionError {
|
|
102
|
-
constructor() {
|
|
103
|
-
super("A transaction is required but none exists", {
|
|
104
|
-
code: ErrorCode.PRECONDITION_FAILED,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* A transaction exists but none was expected.
|
|
110
|
-
*/
|
|
111
|
-
export class TransactionUnexpectedError extends TransactionError {
|
|
112
|
-
constructor() {
|
|
113
|
-
super("A transaction already exists but none was expected", {
|
|
114
|
-
code: ErrorCode.CONFLICT,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* The adapter does not support the requested capability.
|
|
120
|
-
*/
|
|
121
|
-
export class TransactionCapabilityError extends TransactionError {
|
|
122
|
-
constructor(capability) {
|
|
123
|
-
super(`Adapter does not support: ${capability}`, {
|
|
124
|
-
code: ErrorCode.NOT_IMPLEMENTED,
|
|
125
|
-
metadata: { capability },
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
8
|
+
export { TransactionStateError, TransactionTimeoutError, TransactionCommitError, TransactionRollbackError, TransactionAdapterError, TransactionPropagationError, TransactionIsolationError, SavepointError, TransactionRequiredError, TransactionUnexpectedError, TransactionCapabilityError, } from "@zudojs/errors";
|
|
129
9
|
//# sourceMappingURL=transactionError.types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zudojs/transactions",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Transaction lifecycle and coordination with state machine, AsyncLocalStorage context propagation, savepoints, hooks, and adapter abstraction.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"!dist/.tsbuildinfo"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@zudojs/errors": "1.0
|
|
28
|
+
"@zudojs/errors": "1.1.0"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=24.0.0"
|