@decaf-ts/transactional-decorators 0.1.5 → 0.2.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 +1 -1
- package/dist/transactional-decorators.cjs +1 -1
- package/dist/transactional-decorators.cjs.map +1 -1
- package/dist/transactional-decorators.js +1 -1
- package/dist/transactional-decorators.js.map +1 -1
- package/lib/Transaction.cjs +254 -56
- package/lib/Transaction.d.ts +44 -18
- package/lib/Transaction.js.map +1 -1
- package/lib/constants.cjs +0 -1
- package/lib/constants.js.map +1 -1
- package/lib/decorators.cjs +60 -146
- package/lib/decorators.d.ts +1 -11
- package/lib/decorators.js.map +1 -1
- package/lib/errors.cjs +11 -0
- package/lib/errors.d.ts +4 -0
- package/lib/errors.js.map +1 -0
- package/lib/esm/Transaction.d.ts +44 -18
- package/lib/esm/Transaction.js +254 -56
- package/lib/esm/Transaction.js.map +1 -1
- package/lib/esm/constants.js +0 -1
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/decorators.d.ts +1 -11
- package/lib/esm/decorators.js +60 -145
- package/lib/esm/decorators.js.map +1 -1
- package/lib/esm/errors.d.ts +4 -0
- package/lib/esm/errors.js +7 -0
- package/lib/esm/errors.js.map +1 -0
- package/lib/esm/index.d.ts +4 -1
- package/lib/esm/index.js +6 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/TransactionLock.d.ts +2 -2
- package/lib/esm/locks/{SyncronousLock.d.ts → SynchronousLock.d.ts} +10 -6
- package/lib/esm/locks/SynchronousLock.js +131 -0
- package/lib/esm/locks/SynchronousLock.js.map +1 -0
- package/lib/esm/locks/index.d.ts +1 -1
- package/lib/esm/locks/index.js +1 -1
- package/lib/esm/locks/index.js.map +1 -1
- package/lib/esm/overrides/Metadata.d.ts +8 -0
- package/lib/esm/overrides/Metadata.js +2 -0
- package/lib/esm/overrides/Metadata.js.map +1 -0
- package/lib/esm/overrides/index.d.ts +2 -0
- package/lib/esm/overrides/index.js +3 -0
- package/lib/esm/overrides/index.js.map +1 -0
- package/lib/esm/overrides/overrides.d.ts +1 -0
- package/lib/esm/overrides/overrides.js +12 -0
- package/lib/esm/overrides/overrides.js.map +1 -0
- package/lib/esm/types.d.ts +0 -10
- package/lib/esm/types.js +11 -0
- package/lib/esm/types.js.map +1 -1
- package/lib/index.cjs +7 -2
- package/lib/index.d.ts +4 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces/TransactionLock.d.ts +2 -2
- package/lib/locks/SynchronousLock.cjs +135 -0
- package/lib/locks/{SyncronousLock.d.ts → SynchronousLock.d.ts} +10 -6
- package/lib/locks/SynchronousLock.js.map +1 -0
- package/lib/locks/index.cjs +1 -1
- package/lib/locks/index.d.ts +1 -1
- package/lib/locks/index.js.map +1 -1
- package/lib/overrides/Metadata.cjs +4 -0
- package/lib/overrides/Metadata.d.ts +8 -0
- package/lib/overrides/Metadata.js.map +1 -0
- package/lib/overrides/index.cjs +19 -0
- package/lib/overrides/index.d.ts +2 -0
- package/lib/overrides/index.js.map +1 -0
- package/lib/overrides/overrides.cjs +14 -0
- package/lib/overrides/overrides.d.ts +1 -0
- package/lib/overrides/overrides.js.map +1 -0
- package/lib/types.cjs +11 -0
- package/lib/types.d.ts +0 -10
- package/lib/types.js.map +1 -1
- package/package.json +2 -3
- package/lib/esm/locks/SyncronousLock.js +0 -128
- package/lib/esm/locks/SyncronousLock.js.map +0 -1
- package/lib/esm/utils.d.ts +0 -1
- package/lib/esm/utils.js +0 -14
- package/lib/esm/utils.js.map +0 -1
- package/lib/locks/SyncronousLock.cjs +0 -132
- package/lib/locks/SyncronousLock.js.map +0 -1
- package/lib/utils.cjs +0 -17
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js.map +0 -1
package/lib/Transaction.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { TransactionLock } from "./interfaces/TransactionLock";
|
|
2
|
-
import
|
|
2
|
+
import "./overrides";
|
|
3
|
+
import { LoggedClass } from "@decaf-ts/logging";
|
|
4
|
+
type TransactionRunnable<R, C = unknown> = (this: C) => R | Promise<R>;
|
|
3
5
|
/**
|
|
4
6
|
* @description Core transaction management class
|
|
5
7
|
* @summary Manages transaction lifecycle, including creation, execution, and cleanup. Provides mechanisms for binding transactions to objects and methods, ensuring proper transaction context propagation.
|
|
@@ -44,24 +46,37 @@ import { Callback } from "./types";
|
|
|
44
46
|
* T->>L: release(error?)
|
|
45
47
|
* L-->>C: Return result/error
|
|
46
48
|
*/
|
|
47
|
-
export declare class Transaction {
|
|
49
|
+
export declare class Transaction<R> extends LoggedClass {
|
|
50
|
+
static debug: boolean;
|
|
51
|
+
static globalTimeout: number;
|
|
52
|
+
private static readonly metadataCache;
|
|
53
|
+
private static log;
|
|
54
|
+
get log(): any;
|
|
48
55
|
readonly id: number;
|
|
49
|
-
protected action?: () =>
|
|
56
|
+
protected action?: () => Promise<R>;
|
|
50
57
|
readonly method?: string;
|
|
51
58
|
readonly source?: string;
|
|
52
|
-
readonly
|
|
59
|
+
readonly logs: string[];
|
|
53
60
|
private readonly metadata?;
|
|
61
|
+
private readonly completion;
|
|
62
|
+
private resolveCompletion?;
|
|
63
|
+
private rejectCompletion?;
|
|
64
|
+
private initialFireDispatched;
|
|
65
|
+
private released;
|
|
54
66
|
private static lock;
|
|
55
|
-
|
|
67
|
+
private static readonly contexts;
|
|
68
|
+
constructor(source: string, method?: string, action?: () => Promise<R>, metadata?: any[]);
|
|
56
69
|
/**
|
|
57
70
|
* @description Queues a transaction for execution
|
|
58
71
|
* @summary Pushes a transaction to the queue and waits for its resolution. Creates a new transaction with the provided issuer and callback method, then submits it to the transaction lock.
|
|
59
72
|
* @param {any} issuer - Any class instance that will be used as 'this' when calling the callbackMethod
|
|
60
|
-
* @param {Function}
|
|
73
|
+
* @param {Function} method - function containing the transaction logic, will be called with the issuer as 'this'
|
|
61
74
|
* @param {any[]} args - Arguments to pass to the method. Last one must be the callback function
|
|
62
75
|
* @return {void}
|
|
63
76
|
*/
|
|
64
|
-
static push(issuer: any,
|
|
77
|
+
static push<R>(issuer: any, method: (...argzz: any[]) => Promise<R>, ...args: any[]): Promise<R>;
|
|
78
|
+
static run<R, C = unknown>(runnable: TransactionRunnable<R, C>, metadata?: any[]): Promise<R>;
|
|
79
|
+
static run<R, C = unknown>(context: C, runnable: TransactionRunnable<R, C>, metadata?: any[]): Promise<R>;
|
|
65
80
|
/**
|
|
66
81
|
* @description Configures the transaction lock implementation
|
|
67
82
|
* @summary Sets the lock implementation to be used for transaction management, allowing customization of the transaction behavior
|
|
@@ -81,7 +96,7 @@ export declare class Transaction {
|
|
|
81
96
|
* @param {Transaction} transaction - The transaction to submit for processing
|
|
82
97
|
* @return {void}
|
|
83
98
|
*/
|
|
84
|
-
static submit(transaction: Transaction):
|
|
99
|
+
static submit<R>(transaction: Transaction<R>): Promise<R>;
|
|
85
100
|
/**
|
|
86
101
|
* @description Releases the transaction lock
|
|
87
102
|
* @summary Releases the current transaction lock, optionally with an error, allowing the next transaction to proceed
|
|
@@ -89,19 +104,27 @@ export declare class Transaction {
|
|
|
89
104
|
* @return {Promise<void>} A promise that resolves when the lock has been released
|
|
90
105
|
*/
|
|
91
106
|
static release(err?: Error): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* @description Releases the transaction instance once
|
|
109
|
+
* @summary Ensures the underlying lock is released at most a single time for the transaction
|
|
110
|
+
* @param {Error} [err] - Optional error to propagate to the lock implementation
|
|
111
|
+
* @return {Promise<void>} Resolves once the lock release call finishes or immediately when already released
|
|
112
|
+
*/
|
|
113
|
+
release(err?: Error): Promise<void>;
|
|
92
114
|
/**
|
|
93
115
|
* @description Retrieves transaction metadata
|
|
94
116
|
* @summary Returns a copy of the metadata associated with this transaction, ensuring the original metadata remains unmodified
|
|
95
117
|
* @return {any[] | undefined} A copy of the transaction metadata or undefined if no metadata exists
|
|
96
118
|
*/
|
|
97
119
|
getMetadata(): any[] | undefined;
|
|
120
|
+
private static getTransactionalMetadata;
|
|
98
121
|
/**
|
|
99
122
|
* @description Links a new transaction to the current one
|
|
100
123
|
* @summary Binds a new transaction operation to the current transaction, transferring logs and binding methods to maintain transaction context
|
|
101
124
|
* @param {Transaction} nextTransaction - The new transaction to bind to the current one
|
|
102
125
|
* @return {void}
|
|
103
126
|
*/
|
|
104
|
-
bindTransaction(nextTransaction: Transaction): void;
|
|
127
|
+
bindTransaction(nextTransaction: Transaction<any>): void;
|
|
105
128
|
/**
|
|
106
129
|
* @description Binds an object to the current transaction context
|
|
107
130
|
* @summary Binds a transactional decorated object to the transaction by ensuring all transactional methods automatically receive the current transaction as their first argument
|
|
@@ -109,12 +132,19 @@ export declare class Transaction {
|
|
|
109
132
|
* @return {any} The bound object with transaction-aware method wrappers
|
|
110
133
|
*/
|
|
111
134
|
bindToTransaction(obj: any): any;
|
|
135
|
+
/**
|
|
136
|
+
* @description Applies the global timeout to the provided Promise, if configured
|
|
137
|
+
* @param {Promise<R>} execution - Transaction execution promise
|
|
138
|
+
* @return {Promise<R>} Promise that respects the configured global timeout
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
private applyGlobalTimeout;
|
|
112
142
|
/**
|
|
113
143
|
* @description Executes the transaction action
|
|
114
144
|
* @summary Fires the transaction by executing its associated action function, throwing an error if no action is defined
|
|
115
145
|
* @return {any} The result of the transaction action
|
|
116
146
|
*/
|
|
117
|
-
fire():
|
|
147
|
+
fire(): Promise<R>;
|
|
118
148
|
/**
|
|
119
149
|
* @description Provides a string representation of the transaction
|
|
120
150
|
* @summary Overrides the default toString method to provide a formatted string representation of the transaction, optionally including the transaction ID and log
|
|
@@ -123,12 +153,8 @@ export declare class Transaction {
|
|
|
123
153
|
* @return {string} A string representation of the transaction
|
|
124
154
|
*/
|
|
125
155
|
toString(withId?: boolean, withLog?: boolean): string;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
* @param {string} key - The base key to prefix with the transaction reflection namespace
|
|
130
|
-
* @return {string} The complete reflection key for transaction metadata
|
|
131
|
-
* @function key
|
|
132
|
-
*/
|
|
133
|
-
static key(key: string): string;
|
|
156
|
+
static contextTransaction(context: any): Transaction<any> | undefined;
|
|
157
|
+
wait(): Promise<R>;
|
|
158
|
+
private static describeTarget;
|
|
134
159
|
}
|
|
160
|
+
export {};
|
package/lib/Transaction.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../src/Transaction.ts"],"names":[],"mappings":";;;AACA,qDAAkD;AAElD,+DAAwD;AACxD,2DAGiC;AACjC,uCAAwC;AACxC,+CAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAa,WAAW;IAUtB,YACE,MAAc,EACd,MAAe,EACf,MAAkB,EAClB,QAAgB;QAEhB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CACT,MAAW,EACX,cAAsD,EACtD,GAAG,IAAwB;QAE3B,MAAM,QAAQ,GAAa,IAAI,CAAC,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,UAAU;YAC7C,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,MAAM,EAAE,GAAG,CAAC,GAAW,EAAE,GAAG,IAAW,EAAE,EAAE;YACzC,WAAW,CAAC,OAAO,E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F,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,cAAc,CAAC,MAAW;QACvC,IACE,MAAM,KAAK,IAAI;YACf,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,UAAU,CAAC,EAC5D,CAAC;YACD,OAAO,IAAA,uBAAa,EAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;QACD,MAAM,GAAG,GAAG,MAAgB,CAAC;QAC7B,IAAI,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAA,uBAAa,EAAC,MAAM,CAAC,CAAC;YAC/B,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;;AA/bH,kCAgcC"}
|
package/lib/constants.cjs
CHANGED
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;;GAMG;AACU,QAAA,iBAAiB,GAA2B;IACvD,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;;GAMG;AACU,QAAA,iBAAiB,GAA2B;IACvD,aAAa,EAAE,eAAe;CAC/B,CAAC"}
|
package/lib/decorators.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transactional = transactional;
|
|
4
|
-
exports.transactionalSuperCall = transactionalSuperCall;
|
|
5
4
|
const constants_1 = require("./constants.cjs");
|
|
6
|
-
const
|
|
5
|
+
const decoration_1 = require("@decaf-ts/decoration");
|
|
7
6
|
const Transaction_1 = require("./Transaction.cjs");
|
|
8
7
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
9
8
|
/**
|
|
@@ -41,151 +40,66 @@ const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
|
41
40
|
function transactional(...data) {
|
|
42
41
|
return function (target, propertyKey, descriptor) {
|
|
43
42
|
if (!descriptor)
|
|
44
|
-
throw new db_decorators_1.InternalError("
|
|
45
|
-
(0,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
49
|
-
const self = this;
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
const cb = (err, result) => {
|
|
52
|
-
Transaction_1.Transaction.release(err).then(() => {
|
|
53
|
-
if (err)
|
|
54
|
-
return reject(err);
|
|
55
|
-
resolve(result);
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
let transaction = args.shift();
|
|
59
|
-
if (transaction instanceof Transaction_1.Transaction) {
|
|
60
|
-
const updatedTransaction = new Transaction_1.Transaction(this.constructor.name, propertyKey, async () => {
|
|
61
|
-
originalMethod
|
|
62
|
-
.call(updatedTransaction.bindToTransaction(self), ...args)
|
|
63
|
-
.then(resolve)
|
|
64
|
-
.catch(reject);
|
|
65
|
-
}, data.length ? data : undefined);
|
|
66
|
-
transaction.bindTransaction(updatedTransaction);
|
|
67
|
-
transaction.fire();
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
args.unshift(transaction);
|
|
71
|
-
transaction = new Transaction_1.Transaction(this.constructor.name, propertyKey, () => {
|
|
72
|
-
originalMethod
|
|
73
|
-
.call(transaction.bindToTransaction(self), ...args)
|
|
74
|
-
.then((result) => cb(undefined, result))
|
|
75
|
-
.catch(cb);
|
|
76
|
-
}, data.length ? data : undefined);
|
|
77
|
-
Transaction_1.Transaction.submit(transaction);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
Object.defineProperty(methodWrapper, "name", {
|
|
82
|
-
value: propertyKey,
|
|
43
|
+
throw new db_decorators_1.InternalError("This decorator only applies to methods");
|
|
44
|
+
(0, decoration_1.method)()(target, propertyKey, descriptor);
|
|
45
|
+
decoration_1.Metadata.set(target.constructor, decoration_1.Metadata.key(constants_1.TransactionalKeys.TRANSACTIONAL, propertyKey), {
|
|
46
|
+
data: data,
|
|
83
47
|
});
|
|
84
|
-
descriptor.value =
|
|
48
|
+
descriptor.value = new Proxy(descriptor.value, {
|
|
49
|
+
async apply(obj, thisArg, argArray) {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
async function exitFunction(transaction, err, result) {
|
|
52
|
+
if (err && !(err instanceof Error) && !result) {
|
|
53
|
+
result = err;
|
|
54
|
+
err = undefined;
|
|
55
|
+
}
|
|
56
|
+
await transaction.release(err);
|
|
57
|
+
return err
|
|
58
|
+
? reject(err)
|
|
59
|
+
: resolve(result);
|
|
60
|
+
}
|
|
61
|
+
const candidate = argArray[0];
|
|
62
|
+
const transactionPrefixLength = (() => {
|
|
63
|
+
let count = 0;
|
|
64
|
+
while (count < argArray.length &&
|
|
65
|
+
argArray[count] instanceof Transaction_1.Transaction) {
|
|
66
|
+
count++;
|
|
67
|
+
}
|
|
68
|
+
return count;
|
|
69
|
+
})();
|
|
70
|
+
const invocationArgs = transactionPrefixLength > 0
|
|
71
|
+
? argArray.slice(transactionPrefixLength)
|
|
72
|
+
: argArray;
|
|
73
|
+
const activeTransaction = candidate instanceof Transaction_1.Transaction
|
|
74
|
+
? candidate
|
|
75
|
+
: Transaction_1.Transaction.contextTransaction(thisArg);
|
|
76
|
+
if (activeTransaction) {
|
|
77
|
+
const updatedTransaction = new Transaction_1.Transaction(target.name, propertyKey, async () => {
|
|
78
|
+
try {
|
|
79
|
+
return resolve(await Reflect.apply(obj, updatedTransaction.bindToTransaction(thisArg), invocationArgs));
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
return reject(e);
|
|
83
|
+
}
|
|
84
|
+
}, data.length ? data : undefined);
|
|
85
|
+
activeTransaction.bindTransaction(updatedTransaction);
|
|
86
|
+
activeTransaction.fire();
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const newTransaction = new Transaction_1.Transaction(target.name, propertyKey, async () => {
|
|
90
|
+
try {
|
|
91
|
+
return exitFunction(newTransaction, undefined, await Reflect.apply(obj, newTransaction.bindToTransaction(thisArg), invocationArgs));
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
return exitFunction(newTransaction, e);
|
|
95
|
+
}
|
|
96
|
+
}, data.length ? data : undefined);
|
|
97
|
+
Transaction_1.Transaction.submit(newTransaction);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
return descriptor;
|
|
85
103
|
};
|
|
86
104
|
}
|
|
87
|
-
//
|
|
88
|
-
// /**
|
|
89
|
-
// * @summary Sets a class Async method as transactional
|
|
90
|
-
// *
|
|
91
|
-
// * @param {any[]} [metadata] option metadata available to the {@link TransactionLock}
|
|
92
|
-
// *
|
|
93
|
-
// * @function transactionalAsync
|
|
94
|
-
// *
|
|
95
|
-
// * @memberOf module:db-decorators.Decorators.transactions
|
|
96
|
-
// */
|
|
97
|
-
// export function transactionalAsync(...metadata: any[]) {
|
|
98
|
-
// return function (
|
|
99
|
-
// target: any,
|
|
100
|
-
// propertyKey: string,
|
|
101
|
-
// descriptor: PropertyDescriptor,
|
|
102
|
-
// ) {
|
|
103
|
-
// metadasta(getTransactionalKey(TransactionalKeys.TRANSACTIONAL))
|
|
104
|
-
// Reflect.defineMetadata(
|
|
105
|
-
// ,
|
|
106
|
-
// {
|
|
107
|
-
// type: "async",
|
|
108
|
-
// metadata: metadata.length ? metadata : undefined,
|
|
109
|
-
// } as TransactionalMetadata,
|
|
110
|
-
// target,
|
|
111
|
-
// propertyKey,
|
|
112
|
-
// );
|
|
113
|
-
//
|
|
114
|
-
// const originalMethod = descriptor.value;
|
|
115
|
-
//
|
|
116
|
-
// const methodWrapper = function (this: any, ...args: any[]) {
|
|
117
|
-
// const callback: Callback = args.pop();
|
|
118
|
-
// if (!callback || typeof callback !== "function")
|
|
119
|
-
// throw new CriticalError(`Missing Callback`);
|
|
120
|
-
//
|
|
121
|
-
// const cb = (err?: Err, ...args: any[]) => {
|
|
122
|
-
// Transaction.release(err).then((_) => callback(err, ...args));
|
|
123
|
-
// };
|
|
124
|
-
//
|
|
125
|
-
// const self = this;
|
|
126
|
-
//
|
|
127
|
-
// let transaction = args.shift();
|
|
128
|
-
// if (transaction instanceof Transaction) {
|
|
129
|
-
// const updatedTransaction: Transaction = new Transaction(
|
|
130
|
-
// this.constructor.name,
|
|
131
|
-
// propertyKey,
|
|
132
|
-
// () => {
|
|
133
|
-
// try {
|
|
134
|
-
// return originalMethod.call(
|
|
135
|
-
// updatedTransaction.bindToTransaction(self),
|
|
136
|
-
// ...args,
|
|
137
|
-
// callback,
|
|
138
|
-
// );
|
|
139
|
-
// } catch (e: any) {
|
|
140
|
-
// return callback(e);
|
|
141
|
-
// }
|
|
142
|
-
// },
|
|
143
|
-
// metadata.length ? metadata : undefined,
|
|
144
|
-
// );
|
|
145
|
-
//
|
|
146
|
-
// transaction.bindTransaction(updatedTransaction);
|
|
147
|
-
// transaction.fire();
|
|
148
|
-
// } else {
|
|
149
|
-
// args.unshift(transaction);
|
|
150
|
-
// transaction = undefined;
|
|
151
|
-
// transaction = new Transaction(
|
|
152
|
-
// this.constructor.name,
|
|
153
|
-
// propertyKey,
|
|
154
|
-
// () => {
|
|
155
|
-
// try {
|
|
156
|
-
// return originalMethod.call(
|
|
157
|
-
// transaction.bindToTransaction(self),
|
|
158
|
-
// ...args,
|
|
159
|
-
// cb,
|
|
160
|
-
// );
|
|
161
|
-
// } catch (e: any) {
|
|
162
|
-
// return cb(e);
|
|
163
|
-
// }
|
|
164
|
-
// },
|
|
165
|
-
// metadata.length ? metadata : undefined,
|
|
166
|
-
// );
|
|
167
|
-
// Transaction.submit(transaction);
|
|
168
|
-
// }
|
|
169
|
-
// };
|
|
170
|
-
//
|
|
171
|
-
// Object.defineProperty(methodWrapper, "name", {
|
|
172
|
-
// value: propertyKey,
|
|
173
|
-
// });
|
|
174
|
-
// descriptor.value = methodWrapper;
|
|
175
|
-
// };
|
|
176
|
-
// }
|
|
177
|
-
/**
|
|
178
|
-
* @description Utility for handling super calls in transactional methods
|
|
179
|
-
* @summary Wraps super method calls with the current transaction context when the super's method is also transactional, ensuring transaction continuity through the inheritance chain
|
|
180
|
-
* @param {Function} method - The super method (must be bound to the proper this), e.g., super.create.bind(this)
|
|
181
|
-
* @param {any[]} args - The arguments to call the method with
|
|
182
|
-
* @return {any} The result of the super method call
|
|
183
|
-
* @function transactionalSuperCall
|
|
184
|
-
* @memberOf module:transactions
|
|
185
|
-
*/
|
|
186
|
-
function transactionalSuperCall(method, ...args) {
|
|
187
|
-
const lock = Transaction_1.Transaction.getLock();
|
|
188
|
-
const currentTransaction = lock.currentTransaction;
|
|
189
|
-
return method(currentTransaction, ...args);
|
|
190
|
-
}
|
|
191
105
|
//# sourceMappingURL=decorators.js.map
|
package/lib/decorators.d.ts
CHANGED
|
@@ -30,14 +30,4 @@
|
|
|
30
30
|
* T-->>C: Return result/error
|
|
31
31
|
* @category Decorators
|
|
32
32
|
*/
|
|
33
|
-
export declare function transactional(...data: any[]): (target: any, propertyKey?: any, descriptor?:
|
|
34
|
-
/**
|
|
35
|
-
* @description Utility for handling super calls in transactional methods
|
|
36
|
-
* @summary Wraps super method calls with the current transaction context when the super's method is also transactional, ensuring transaction continuity through the inheritance chain
|
|
37
|
-
* @param {Function} method - The super method (must be bound to the proper this), e.g., super.create.bind(this)
|
|
38
|
-
* @param {any[]} args - The arguments to call the method with
|
|
39
|
-
* @return {any} The result of the super method call
|
|
40
|
-
* @function transactionalSuperCall
|
|
41
|
-
* @memberOf module:transactions
|
|
42
|
-
*/
|
|
43
|
-
export declare function transactionalSuperCall(method: any, ...args: any): any;
|
|
33
|
+
export declare function transactional(...data: any[]): (target: any, propertyKey?: any, descriptor?: any) => any;
|
package/lib/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;AAqCA,
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;AAqCA,sCAqGC;AA1ID,+CAAgD;AAChD,qDAAwD;AACxD,mDAA4C;AAC5C,2DAAwD;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,aAAa,CAAC,GAAG,IAAW;IAC1C,OAAO,UAAU,MAAW,EAAE,WAAiB,EAAE,UAAgB;QAC/D,IAAI,CAAC,UAAU;YACb,MAAM,IAAI,6BAAa,CAAC,wCAAwC,CAAC,CAAC;QACpE,IAAA,mBAAM,GAAE,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAC1C,qBAAQ,CAAC,GAAG,CACV,MAAM,CAAC,WAAW,EAClB,qBAAQ,CAAC,GAAG,CAAC,6BAAiB,CAAC,aAAa,EAAE,WAAW,CAAC,EAC1D;YACE,IAAI,EAAE,IAAI;SACX,CACF,CAAC;QACF,UAAU,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE;YAC7C,KAAK,CAAC,KAAK,CAAI,GAAQ,EAAE,OAAY,EAAE,QAAe;gBACpD,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;oBACxC,KAAK,UAAU,YAAY,CACzB,WAA2B,EAC3B,GAAe,EACf,MAAU;wBAEV,IAAI,GAAG,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;4BAC9C,MAAM,GAAG,GAAG,CAAC;4BACb,GAAG,GAAG,SAAS,CAAC;wBAClB,CAAC;wBACD,MAAM,WAAW,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AC,SAAS,CAC/B,CAAC;wBACF,iBAAiB,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;wBACtD,iBAAiB,CAAC,IAAI,EAAE,CAAC;oBAC3B,CAAC;yBAAM,CAAC;wBACN,MAAM,cAAc,GAAmB,IAAI,yBAAW,CACpD,MAAM,CAAC,IAAI,EACX,WAAW,EACX,KAAK,IAAI,EAAE;4BACT,IAAI,CAAC;gCACH,OAAO,YAAY,CACjB,cAAc,EACd,SAAS,EACT,MAAM,OAAO,CAAC,KAAK,CACjB,GAAG,EACH,cAAc,CAAC,iBAAiB,CAAC,OAAO,CAAC,EACzC,cAAc,CACf,CACF,CAAC;4BACJ,CAAC;4BAAC,OAAO,CAAU,EAAE,CAAC;gCACpB,OAAO,YAAY,CAAC,cAAc,EAAE,CAAU,CAAC,CAAC;4BAClD,CAAC;wBACH,CAAC,EACD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAC/B,CAAC;wBACF,yBAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;oBACrC,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/errors.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeoutError = void 0;
|
|
4
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
5
|
+
class TimeoutError extends db_decorators_1.InternalError {
|
|
6
|
+
constructor(message = "Transaction timed out") {
|
|
7
|
+
super(message, TimeoutError.name, 500);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.TimeoutError = TimeoutError;
|
|
11
|
+
//# sourceMappingURL=errors.js.map
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AAExD,MAAa,YAAa,SAAQ,6BAAa;IAC7C,YAAY,UAA0B,uBAAuB;QAC3D,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;CACF;AAJD,oCAIC"}
|
package/lib/esm/Transaction.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { TransactionLock } from "./interfaces/TransactionLock";
|
|
2
|
-
import
|
|
2
|
+
import "./overrides";
|
|
3
|
+
import { LoggedClass } from "@decaf-ts/logging";
|
|
4
|
+
type TransactionRunnable<R, C = unknown> = (this: C) => R | Promise<R>;
|
|
3
5
|
/**
|
|
4
6
|
* @description Core transaction management class
|
|
5
7
|
* @summary Manages transaction lifecycle, including creation, execution, and cleanup. Provides mechanisms for binding transactions to objects and methods, ensuring proper transaction context propagation.
|
|
@@ -44,24 +46,37 @@ import { Callback } from "./types";
|
|
|
44
46
|
* T->>L: release(error?)
|
|
45
47
|
* L-->>C: Return result/error
|
|
46
48
|
*/
|
|
47
|
-
export declare class Transaction {
|
|
49
|
+
export declare class Transaction<R> extends LoggedClass {
|
|
50
|
+
static debug: boolean;
|
|
51
|
+
static globalTimeout: number;
|
|
52
|
+
private static readonly metadataCache;
|
|
53
|
+
private static log;
|
|
54
|
+
get log(): any;
|
|
48
55
|
readonly id: number;
|
|
49
|
-
protected action?: () =>
|
|
56
|
+
protected action?: () => Promise<R>;
|
|
50
57
|
readonly method?: string;
|
|
51
58
|
readonly source?: string;
|
|
52
|
-
readonly
|
|
59
|
+
readonly logs: string[];
|
|
53
60
|
private readonly metadata?;
|
|
61
|
+
private readonly completion;
|
|
62
|
+
private resolveCompletion?;
|
|
63
|
+
private rejectCompletion?;
|
|
64
|
+
private initialFireDispatched;
|
|
65
|
+
private released;
|
|
54
66
|
private static lock;
|
|
55
|
-
|
|
67
|
+
private static readonly contexts;
|
|
68
|
+
constructor(source: string, method?: string, action?: () => Promise<R>, metadata?: any[]);
|
|
56
69
|
/**
|
|
57
70
|
* @description Queues a transaction for execution
|
|
58
71
|
* @summary Pushes a transaction to the queue and waits for its resolution. Creates a new transaction with the provided issuer and callback method, then submits it to the transaction lock.
|
|
59
72
|
* @param {any} issuer - Any class instance that will be used as 'this' when calling the callbackMethod
|
|
60
|
-
* @param {Function}
|
|
73
|
+
* @param {Function} method - function containing the transaction logic, will be called with the issuer as 'this'
|
|
61
74
|
* @param {any[]} args - Arguments to pass to the method. Last one must be the callback function
|
|
62
75
|
* @return {void}
|
|
63
76
|
*/
|
|
64
|
-
static push(issuer: any,
|
|
77
|
+
static push<R>(issuer: any, method: (...argzz: any[]) => Promise<R>, ...args: any[]): Promise<R>;
|
|
78
|
+
static run<R, C = unknown>(runnable: TransactionRunnable<R, C>, metadata?: any[]): Promise<R>;
|
|
79
|
+
static run<R, C = unknown>(context: C, runnable: TransactionRunnable<R, C>, metadata?: any[]): Promise<R>;
|
|
65
80
|
/**
|
|
66
81
|
* @description Configures the transaction lock implementation
|
|
67
82
|
* @summary Sets the lock implementation to be used for transaction management, allowing customization of the transaction behavior
|
|
@@ -81,7 +96,7 @@ export declare class Transaction {
|
|
|
81
96
|
* @param {Transaction} transaction - The transaction to submit for processing
|
|
82
97
|
* @return {void}
|
|
83
98
|
*/
|
|
84
|
-
static submit(transaction: Transaction):
|
|
99
|
+
static submit<R>(transaction: Transaction<R>): Promise<R>;
|
|
85
100
|
/**
|
|
86
101
|
* @description Releases the transaction lock
|
|
87
102
|
* @summary Releases the current transaction lock, optionally with an error, allowing the next transaction to proceed
|
|
@@ -89,19 +104,27 @@ export declare class Transaction {
|
|
|
89
104
|
* @return {Promise<void>} A promise that resolves when the lock has been released
|
|
90
105
|
*/
|
|
91
106
|
static release(err?: Error): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* @description Releases the transaction instance once
|
|
109
|
+
* @summary Ensures the underlying lock is released at most a single time for the transaction
|
|
110
|
+
* @param {Error} [err] - Optional error to propagate to the lock implementation
|
|
111
|
+
* @return {Promise<void>} Resolves once the lock release call finishes or immediately when already released
|
|
112
|
+
*/
|
|
113
|
+
release(err?: Error): Promise<void>;
|
|
92
114
|
/**
|
|
93
115
|
* @description Retrieves transaction metadata
|
|
94
116
|
* @summary Returns a copy of the metadata associated with this transaction, ensuring the original metadata remains unmodified
|
|
95
117
|
* @return {any[] | undefined} A copy of the transaction metadata or undefined if no metadata exists
|
|
96
118
|
*/
|
|
97
119
|
getMetadata(): any[] | undefined;
|
|
120
|
+
private static getTransactionalMetadata;
|
|
98
121
|
/**
|
|
99
122
|
* @description Links a new transaction to the current one
|
|
100
123
|
* @summary Binds a new transaction operation to the current transaction, transferring logs and binding methods to maintain transaction context
|
|
101
124
|
* @param {Transaction} nextTransaction - The new transaction to bind to the current one
|
|
102
125
|
* @return {void}
|
|
103
126
|
*/
|
|
104
|
-
bindTransaction(nextTransaction: Transaction): void;
|
|
127
|
+
bindTransaction(nextTransaction: Transaction<any>): void;
|
|
105
128
|
/**
|
|
106
129
|
* @description Binds an object to the current transaction context
|
|
107
130
|
* @summary Binds a transactional decorated object to the transaction by ensuring all transactional methods automatically receive the current transaction as their first argument
|
|
@@ -109,12 +132,19 @@ export declare class Transaction {
|
|
|
109
132
|
* @return {any} The bound object with transaction-aware method wrappers
|
|
110
133
|
*/
|
|
111
134
|
bindToTransaction(obj: any): any;
|
|
135
|
+
/**
|
|
136
|
+
* @description Applies the global timeout to the provided Promise, if configured
|
|
137
|
+
* @param {Promise<R>} execution - Transaction execution promise
|
|
138
|
+
* @return {Promise<R>} Promise that respects the configured global timeout
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
private applyGlobalTimeout;
|
|
112
142
|
/**
|
|
113
143
|
* @description Executes the transaction action
|
|
114
144
|
* @summary Fires the transaction by executing its associated action function, throwing an error if no action is defined
|
|
115
145
|
* @return {any} The result of the transaction action
|
|
116
146
|
*/
|
|
117
|
-
fire():
|
|
147
|
+
fire(): Promise<R>;
|
|
118
148
|
/**
|
|
119
149
|
* @description Provides a string representation of the transaction
|
|
120
150
|
* @summary Overrides the default toString method to provide a formatted string representation of the transaction, optionally including the transaction ID and log
|
|
@@ -123,12 +153,8 @@ export declare class Transaction {
|
|
|
123
153
|
* @return {string} A string representation of the transaction
|
|
124
154
|
*/
|
|
125
155
|
toString(withId?: boolean, withLog?: boolean): string;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
* @param {string} key - The base key to prefix with the transaction reflection namespace
|
|
130
|
-
* @return {string} The complete reflection key for transaction metadata
|
|
131
|
-
* @function key
|
|
132
|
-
*/
|
|
133
|
-
static key(key: string): string;
|
|
156
|
+
static contextTransaction(context: any): Transaction<any> | undefined;
|
|
157
|
+
wait(): Promise<R>;
|
|
158
|
+
private static describeTarget;
|
|
134
159
|
}
|
|
160
|
+
export {};
|