@zudojs/transactions 0.0.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/LICENSE +21 -0
- package/README.md +40 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/adapter/adapter.core.d.ts +15 -0
- package/dist/adapter/adapter.core.d.ts.map +1 -0
- package/dist/adapter/adapter.core.js +47 -0
- package/dist/adapter/adapter.core.js.map +1 -0
- package/dist/adapter/index.d.ts +7 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +7 -0
- package/dist/adapter/index.js.map +1 -0
- package/dist/context/context.core.d.ts +19 -0
- package/dist/context/context.core.d.ts.map +1 -0
- package/dist/context/context.core.js +38 -0
- package/dist/context/context.core.js.map +1 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +7 -0
- package/dist/context/index.js.map +1 -0
- package/dist/hooks/hooks.core.d.ts +11 -0
- package/dist/hooks/hooks.core.d.ts.map +1 -0
- package/dist/hooks/hooks.core.js +78 -0
- package/dist/hooks/hooks.core.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/manager/index.d.ts +7 -0
- package/dist/manager/index.d.ts.map +1 -0
- package/dist/manager/index.js +7 -0
- package/dist/manager/index.js.map +1 -0
- package/dist/manager/manager.commit.d.ts +17 -0
- package/dist/manager/manager.commit.d.ts.map +1 -0
- package/dist/manager/manager.commit.js +66 -0
- package/dist/manager/manager.commit.js.map +1 -0
- package/dist/manager/manager.core.d.ts +26 -0
- package/dist/manager/manager.core.d.ts.map +1 -0
- package/dist/manager/manager.core.js +92 -0
- package/dist/manager/manager.core.js.map +1 -0
- package/dist/manager/manager.propagation.d.ts +15 -0
- package/dist/manager/manager.propagation.d.ts.map +1 -0
- package/dist/manager/manager.propagation.js +56 -0
- package/dist/manager/manager.propagation.js.map +1 -0
- package/dist/registry/index.d.ts +7 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +7 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/registry.core.d.ts +11 -0
- package/dist/registry/registry.core.d.ts.map +1 -0
- package/dist/registry/registry.core.js +26 -0
- package/dist/registry/registry.core.js.map +1 -0
- package/dist/transaction/index.d.ts +7 -0
- package/dist/transaction/index.d.ts.map +1 -0
- package/dist/transaction/index.js +7 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction/transaction.core.d.ts +9 -0
- package/dist/transaction/transaction.core.d.ts.map +1 -0
- package/dist/transaction/transaction.core.js +139 -0
- package/dist/transaction/transaction.core.js.map +1 -0
- package/dist/transaction/transactionStateMachine.d.ts +9 -0
- package/dist/transaction/transactionStateMachine.d.ts.map +1 -0
- package/dist/transaction/transactionStateMachine.js +27 -0
- package/dist/transaction/transactionStateMachine.js.map +1 -0
- package/dist/transactionErrors/index.d.ts +6 -0
- package/dist/transactionErrors/index.d.ts.map +1 -0
- package/dist/transactionErrors/index.js +6 -0
- package/dist/transactionErrors/index.js.map +1 -0
- package/dist/transactionErrors/transactionError.base.d.ts +15 -0
- package/dist/transactionErrors/transactionError.base.d.ts.map +1 -0
- package/dist/transactionErrors/transactionError.base.js +19 -0
- package/dist/transactionErrors/transactionError.base.js.map +1 -0
- package/dist/transactionErrors/transactionError.types.d.ts +74 -0
- package/dist/transactionErrors/transactionError.types.d.ts.map +1 -0
- package/dist/transactionErrors/transactionError.types.js +129 -0
- package/dist/transactionErrors/transactionError.types.js.map +1 -0
- package/dist/transactionTypes/index.d.ts +10 -0
- package/dist/transactionTypes/index.d.ts.map +1 -0
- package/dist/transactionTypes/index.js +10 -0
- package/dist/transactionTypes/index.js.map +1 -0
- package/dist/transactionTypes/transaction.interface.d.ts +62 -0
- package/dist/transactionTypes/transaction.interface.d.ts.map +1 -0
- package/dist/transactionTypes/transaction.interface.js +7 -0
- package/dist/transactionTypes/transaction.interface.js.map +1 -0
- package/dist/transactionTypes/transactionAdapter.d.ts +56 -0
- package/dist/transactionTypes/transactionAdapter.d.ts.map +1 -0
- package/dist/transactionTypes/transactionAdapter.js +7 -0
- package/dist/transactionTypes/transactionAdapter.js.map +1 -0
- package/dist/transactionTypes/transactionHooks.d.ts +63 -0
- package/dist/transactionTypes/transactionHooks.d.ts.map +1 -0
- package/dist/transactionTypes/transactionHooks.js +17 -0
- package/dist/transactionTypes/transactionHooks.js.map +1 -0
- package/dist/transactionTypes/transactionState.d.ts +12 -0
- package/dist/transactionTypes/transactionState.d.ts.map +1 -0
- package/dist/transactionTypes/transactionState.js +7 -0
- package/dist/transactionTypes/transactionState.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/utils.helper.d.ts +20 -0
- package/dist/utils/utils.helper.d.ts.map +1 -0
- package/dist/utils/utils.helper.js +33 -0
- package/dist/utils/utils.helper.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.interface.js","sourceRoot":"","sources":["../../src/transactionTypes/transaction.interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction adapter contract, capabilities, savepoints, and context.
|
|
3
|
+
*
|
|
4
|
+
* @module transactionTypes/transactionAdapter
|
|
5
|
+
*/
|
|
6
|
+
import type { TransactionIsolationLevel } from "./transactionState.js";
|
|
7
|
+
import type { Transaction } from "./transaction.interface.js";
|
|
8
|
+
/** Handle returned by the adapter's begin(), used for commit/rollback. */
|
|
9
|
+
export type TransactionHandle = unknown;
|
|
10
|
+
/** Capabilities reported by a transaction adapter. */
|
|
11
|
+
export interface TransactionAdapterCapabilities {
|
|
12
|
+
/** Whether savepoints are supported. */
|
|
13
|
+
readonly savepoints: boolean;
|
|
14
|
+
/** Whether nested transactions are supported. */
|
|
15
|
+
readonly nestedTransactions: boolean;
|
|
16
|
+
/** Supported isolation levels. */
|
|
17
|
+
readonly isolationLevels: readonly TransactionIsolationLevel[];
|
|
18
|
+
/** Whether read-only transactions are supported. */
|
|
19
|
+
readonly readOnlyTransactions: boolean;
|
|
20
|
+
/** Whether timeouts are supported. */
|
|
21
|
+
readonly timeouts: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Adapter contract for database-specific transaction behavior. */
|
|
24
|
+
export interface TransactionAdapter {
|
|
25
|
+
/** Adapter capabilities. */
|
|
26
|
+
readonly capabilities: TransactionAdapterCapabilities;
|
|
27
|
+
/** Begin a new transaction. Returns a handle. */
|
|
28
|
+
begin(options?: import("./transaction.interface.js").TransactionOptions): Promise<TransactionHandle>;
|
|
29
|
+
/** Commit a transaction. */
|
|
30
|
+
commit(handle: TransactionHandle): Promise<void>;
|
|
31
|
+
/** Rollback a transaction. */
|
|
32
|
+
rollback(handle: TransactionHandle, reason?: unknown): Promise<void>;
|
|
33
|
+
/** Create a savepoint (optional). */
|
|
34
|
+
createSavepoint?(handle: TransactionHandle, name: string): Promise<void>;
|
|
35
|
+
/** Rollback to a savepoint (optional). */
|
|
36
|
+
rollbackToSavepoint?(handle: TransactionHandle, name: string): Promise<void>;
|
|
37
|
+
/** Release a savepoint (optional). */
|
|
38
|
+
releaseSavepoint?(handle: TransactionHandle, name: string): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
/** A savepoint within a transaction. */
|
|
41
|
+
export interface Savepoint {
|
|
42
|
+
/** Savepoint name. */
|
|
43
|
+
readonly name: string;
|
|
44
|
+
/** Rollback to this savepoint. */
|
|
45
|
+
rollback(): Promise<void>;
|
|
46
|
+
/** Release this savepoint. */
|
|
47
|
+
release(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
/** Transaction context for async propagation. */
|
|
50
|
+
export interface TransactionContext {
|
|
51
|
+
/** Get the current active transaction, if any. */
|
|
52
|
+
get(): Transaction | undefined;
|
|
53
|
+
/** Run a callback within a transaction context. */
|
|
54
|
+
run<T>(transaction: Transaction, callback: () => Promise<T>): Promise<T>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=transactionAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionAdapter.d.ts","sourceRoot":"","sources":["../../src/transactionTypes/transactionAdapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAExC,sDAAsD;AACtD,MAAM,WAAW,8BAA8B;IAC7C,wCAAwC;IACxC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,iDAAiD;IACjD,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,kCAAkC;IAClC,QAAQ,CAAC,eAAe,EAAE,SAAS,yBAAyB,EAAE,CAAC;IAC/D,oDAAoD;IACpD,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IACvC,sCAAsC;IACtC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,QAAQ,CAAC,YAAY,EAAE,8BAA8B,CAAC;IACtD,iDAAiD;IACjD,KAAK,CACH,OAAO,CAAC,EAAE,OAAO,4BAA4B,EAAE,kBAAkB,GAChE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9B,4BAA4B;IAC5B,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,qCAAqC;IACrC,eAAe,CAAC,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,0CAA0C;IAC1C,mBAAmB,CAAC,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E,sCAAsC;IACtC,gBAAgB,CAAC,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3E;AAED,wCAAwC;AACxC,MAAM,WAAW,SAAS;IACxB,sBAAsB;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,8BAA8B;IAC9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,iDAAiD;AACjD,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,GAAG,IAAI,WAAW,GAAG,SAAS,CAAC;IAC/B,mDAAmD;IACnD,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionAdapter.js","sourceRoot":"","sources":["../../src/transactionTypes/transactionAdapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction hooks, registry, result, and events.
|
|
3
|
+
*
|
|
4
|
+
* @module transactionTypes/transactionHooks
|
|
5
|
+
*/
|
|
6
|
+
import type { Transaction } from "./transaction.interface.js";
|
|
7
|
+
/** Context passed to transaction hooks. */
|
|
8
|
+
export interface TransactionHookContext {
|
|
9
|
+
/** The transaction. */
|
|
10
|
+
readonly transaction: Transaction;
|
|
11
|
+
}
|
|
12
|
+
/** Context passed to error hooks. */
|
|
13
|
+
export interface TransactionErrorContext {
|
|
14
|
+
/** The transaction. */
|
|
15
|
+
readonly transaction: Transaction;
|
|
16
|
+
/** The error that occurred. */
|
|
17
|
+
readonly error: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** Lifecycle hooks for transactions. */
|
|
20
|
+
export interface TransactionHooks {
|
|
21
|
+
beforeBegin?(context: TransactionHookContext): Promise<void>;
|
|
22
|
+
afterBegin?(context: TransactionHookContext): Promise<void>;
|
|
23
|
+
beforeCommit?(context: TransactionHookContext): Promise<void>;
|
|
24
|
+
afterCommit?(context: TransactionHookContext): Promise<void>;
|
|
25
|
+
beforeRollback?(context: TransactionHookContext): Promise<void>;
|
|
26
|
+
afterRollback?(context: TransactionHookContext): Promise<void>;
|
|
27
|
+
onError?(context: TransactionErrorContext): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/** Registry for tracking active transactions. */
|
|
30
|
+
export interface TransactionRegistry {
|
|
31
|
+
register(transaction: Transaction): void;
|
|
32
|
+
unregister(transactionId: string): void;
|
|
33
|
+
get(transactionId: string): Transaction | undefined;
|
|
34
|
+
getActive(): readonly Transaction[];
|
|
35
|
+
}
|
|
36
|
+
/** Result of a transaction.run() call. */
|
|
37
|
+
export interface TransactionResult<T> {
|
|
38
|
+
readonly value: T;
|
|
39
|
+
readonly transactionId: string;
|
|
40
|
+
readonly committed: boolean;
|
|
41
|
+
readonly duration: number;
|
|
42
|
+
}
|
|
43
|
+
/** Transaction event types. */
|
|
44
|
+
export declare const TRANSACTION_EVENTS: {
|
|
45
|
+
readonly STARTED: "transaction.started";
|
|
46
|
+
readonly COMMITTING: "transaction.committing";
|
|
47
|
+
readonly COMMITTED: "transaction.committed";
|
|
48
|
+
readonly ROLLING_BACK: "transaction.rolling_back";
|
|
49
|
+
readonly ROLLED_BACK: "transaction.rolled_back";
|
|
50
|
+
readonly FAILED: "transaction.failed";
|
|
51
|
+
readonly TIMED_OUT: "transaction.timed_out";
|
|
52
|
+
};
|
|
53
|
+
/** A transaction lifecycle event. */
|
|
54
|
+
export interface TransactionEvent {
|
|
55
|
+
readonly type: (typeof TRANSACTION_EVENTS)[keyof typeof TRANSACTION_EVENTS];
|
|
56
|
+
readonly transactionId: string;
|
|
57
|
+
readonly timestamp: number;
|
|
58
|
+
readonly duration?: number;
|
|
59
|
+
readonly error?: unknown;
|
|
60
|
+
}
|
|
61
|
+
/** Handler for transaction events. */
|
|
62
|
+
export type TransactionEventHandler = (event: TransactionEvent) => void;
|
|
63
|
+
//# sourceMappingURL=transactionHooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionHooks.d.ts","sourceRoot":"","sources":["../../src/transactionTypes/transactionHooks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAI9D,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB;IACrC,uBAAuB;IACvB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC;AAED,qCAAqC;AACrC,MAAM,WAAW,uBAAuB;IACtC,uBAAuB;IACvB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,UAAU,CAAC,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,YAAY,CAAC,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,WAAW,CAAC,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,cAAc,CAAC,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,aAAa,CAAC,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,OAAO,CAAC,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D;AAID,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IACpD,SAAS,IAAI,SAAS,WAAW,EAAE,CAAC;CACrC;AAID,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAID,+BAA+B;AAC/B,eAAO,MAAM,kBAAkB;aAC7B,OAAO,EAAE,qBAAqB;aAC9B,UAAU,EAAE,wBAAwB;aACpC,SAAS,EAAE,uBAAuB;aAClC,YAAY,EAAE,0BAA0B;aACxC,WAAW,EAAE,yBAAyB;aACtC,MAAM,EAAE,oBAAoB;aAC5B,SAAS,EAAE,uBAAuB;CAC1B,CAAC;AAEX,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;IAC5E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,sCAAsC;AACtC,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction hooks, registry, result, and events.
|
|
3
|
+
*
|
|
4
|
+
* @module transactionTypes/transactionHooks
|
|
5
|
+
*/
|
|
6
|
+
// ─── Events ───────────────────────────────────────────────────────────────
|
|
7
|
+
/** Transaction event types. */
|
|
8
|
+
export const TRANSACTION_EVENTS = {
|
|
9
|
+
STARTED: "transaction.started",
|
|
10
|
+
COMMITTING: "transaction.committing",
|
|
11
|
+
COMMITTED: "transaction.committed",
|
|
12
|
+
ROLLING_BACK: "transaction.rolling_back",
|
|
13
|
+
ROLLED_BACK: "transaction.rolled_back",
|
|
14
|
+
FAILED: "transaction.failed",
|
|
15
|
+
TIMED_OUT: "transaction.timed_out",
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=transactionHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionHooks.js","sourceRoot":"","sources":["../../src/transactionTypes/transactionHooks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmDH,6EAA6E;AAE7E,+BAA+B;AAC/B,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,qBAAqB;IAC9B,UAAU,EAAE,wBAAwB;IACpC,SAAS,EAAE,uBAAuB;IAClC,YAAY,EAAE,0BAA0B;IACxC,WAAW,EAAE,yBAAyB;IACtC,MAAM,EAAE,oBAAoB;IAC5B,SAAS,EAAE,uBAAuB;CAC1B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction state machine, propagation strategies, and isolation levels.
|
|
3
|
+
*
|
|
4
|
+
* @module transactionTypes/transactionState
|
|
5
|
+
*/
|
|
6
|
+
/** Lifecycle states of a transaction. */
|
|
7
|
+
export type TransactionState = "pending" | "active" | "committing" | "committed" | "rolling_back" | "rolled_back" | "failed";
|
|
8
|
+
/** Transaction propagation strategies for nested calls. */
|
|
9
|
+
export type TransactionPropagation = "required" | "requires_new" | "supports" | "not_supported" | "mandatory" | "never" | "nested";
|
|
10
|
+
/** Database isolation levels. */
|
|
11
|
+
export type TransactionIsolationLevel = "read_uncommitted" | "read_committed" | "repeatable_read" | "serializable";
|
|
12
|
+
//# sourceMappingURL=transactionState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionState.d.ts","sourceRoot":"","sources":["../../src/transactionTypes/transactionState.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yCAAyC;AACzC,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,WAAW,GACX,cAAc,GACd,aAAa,GACb,QAAQ,CAAC;AAEb,2DAA2D;AAC3D,MAAM,MAAM,sBAAsB,GAC9B,UAAU,GACV,cAAc,GACd,UAAU,GACV,eAAe,GACf,WAAW,GACX,OAAO,GACP,QAAQ,CAAC;AAEb,iCAAiC;AACjC,MAAM,MAAM,yBAAyB,GACnC,kBAAkB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionState.js","sourceRoot":"","sources":["../../src/transactionTypes/transactionState.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,oBAAoB,GACrB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,oBAAoB,GACrB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility helpers for the transactions package.
|
|
3
|
+
*
|
|
4
|
+
* @module utils/utils
|
|
5
|
+
*/
|
|
6
|
+
import type { Transaction } from "../transactionTypes/transaction.interface.js";
|
|
7
|
+
import type { TransactionState } from "../transactionTypes/transactionState.js";
|
|
8
|
+
/**
|
|
9
|
+
* Check if a transaction is in a terminal state (committed, rolled_back, or failed).
|
|
10
|
+
*/
|
|
11
|
+
export declare function isTerminalState(state: TransactionState): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a transaction can still be modified (active or pending).
|
|
14
|
+
*/
|
|
15
|
+
export declare function isModifiable(transaction: Transaction): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Get a human-readable summary of a transaction.
|
|
18
|
+
*/
|
|
19
|
+
export declare function summarizeTransaction(transaction: Transaction): string;
|
|
20
|
+
//# sourceMappingURL=utils.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.helper.d.ts","sourceRoot":"","sources":["../../src/utils/utils.helper.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAEhF;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAEhE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAWrE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility helpers for the transactions package.
|
|
3
|
+
*
|
|
4
|
+
* @module utils/utils
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Check if a transaction is in a terminal state (committed, rolled_back, or failed).
|
|
8
|
+
*/
|
|
9
|
+
export function isTerminalState(state) {
|
|
10
|
+
return state === "committed" || state === "rolled_back" || state === "failed";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Check if a transaction can still be modified (active or pending).
|
|
14
|
+
*/
|
|
15
|
+
export function isModifiable(transaction) {
|
|
16
|
+
return transaction.state === "active" || transaction.state === "pending";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get a human-readable summary of a transaction.
|
|
20
|
+
*/
|
|
21
|
+
export function summarizeTransaction(transaction) {
|
|
22
|
+
const duration = Date.now() - transaction.startedAt;
|
|
23
|
+
return [
|
|
24
|
+
`Transaction ${transaction.id}`,
|
|
25
|
+
`state=${transaction.state}`,
|
|
26
|
+
`duration=${duration}ms`,
|
|
27
|
+
transaction.parentId ? `parent=${transaction.parentId}` : "",
|
|
28
|
+
transaction.isRollbackOnly() ? "rollback-only" : "",
|
|
29
|
+
]
|
|
30
|
+
.filter(Boolean)
|
|
31
|
+
.join(", ");
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=utils.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.helper.js","sourceRoot":"","sources":["../../src/utils/utils.helper.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAuB;IACrD,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,aAAa,IAAI,KAAK,KAAK,QAAQ,CAAC;AAChF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,WAAwB;IACnD,OAAO,WAAW,CAAC,KAAK,KAAK,QAAQ,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAwB;IAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,SAAS,CAAC;IACpD,OAAO;QACL,eAAe,WAAW,CAAC,EAAE,EAAE;QAC/B,SAAS,WAAW,CAAC,KAAK,EAAE;QAC5B,YAAY,QAAQ,IAAI;QACxB,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE;QAC5D,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;KACpD;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zudojs/transactions",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Transaction lifecycle and coordination with state machine, AsyncLocalStorage context propagation, savepoints, hooks, and adapter abstraction.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@zudojs/errors": "0.0.1"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=24.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^7.0.2",
|
|
28
|
+
"vitest": "^4.1.11"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"zudojs",
|
|
35
|
+
"transactions",
|
|
36
|
+
"savepoints",
|
|
37
|
+
"rollback"
|
|
38
|
+
],
|
|
39
|
+
"homepage": "https://github.com/oyinlola-tech/zudo#readme",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/oyinlola-tech/zudo"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -p tsconfig.json",
|
|
46
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
47
|
+
"clean": "rm -rf dist",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"test:watch": "vitest"
|
|
50
|
+
}
|
|
51
|
+
}
|