@nestjs-cls/transactional-adapter-pg-promise 1.2.0 → 1.3.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionalAdapter } from '@nestjs-cls/transactional';
|
|
2
2
|
import { IDatabase } from 'pg-promise';
|
|
3
3
|
export type Database = IDatabase<unknown>;
|
|
4
|
-
type
|
|
4
|
+
type PgPromiseTxOptions = Parameters<Database['tx']>[0];
|
|
5
5
|
export interface PgPromiseTransactionalAdapterOptions {
|
|
6
6
|
/**
|
|
7
7
|
* The injection token for the pg-promise instance.
|
|
@@ -11,14 +11,14 @@ export interface PgPromiseTransactionalAdapterOptions {
|
|
|
11
11
|
* Default options for the transaction. These will be merged with any transaction-specific options
|
|
12
12
|
* passed to the `@Transactional` decorator or the `TransactionHost#withTransaction` method.
|
|
13
13
|
*/
|
|
14
|
-
defaultTxOptions?:
|
|
14
|
+
defaultTxOptions?: PgPromiseTxOptions;
|
|
15
15
|
}
|
|
16
|
-
export declare class TransactionalAdapterPgPromise implements TransactionalAdapter<Database, Database,
|
|
16
|
+
export declare class TransactionalAdapterPgPromise implements TransactionalAdapter<Database, Database, PgPromiseTxOptions> {
|
|
17
17
|
connectionToken: any;
|
|
18
|
-
defaultTxOptions?:
|
|
18
|
+
defaultTxOptions?: Partial<PgPromiseTxOptions>;
|
|
19
19
|
constructor(options: PgPromiseTransactionalAdapterOptions);
|
|
20
20
|
optionsFactory: (pgPromiseDbInstance: Database) => {
|
|
21
|
-
wrapWithTransaction: (options:
|
|
21
|
+
wrapWithTransaction: (options: PgPromiseTxOptions, fn: (...args: any[]) => Promise<any>, setClient: (client?: Database) => void) => Promise<any>;
|
|
22
22
|
getFallbackInstance: () => Database;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -5,7 +5,7 @@ class TransactionalAdapterPgPromise {
|
|
|
5
5
|
constructor(options) {
|
|
6
6
|
this.optionsFactory = (pgPromiseDbInstance) => ({
|
|
7
7
|
wrapWithTransaction: async (options, fn, setClient) => {
|
|
8
|
-
return pgPromiseDbInstance.tx(
|
|
8
|
+
return pgPromiseDbInstance.tx(options, (tx) => {
|
|
9
9
|
setClient(tx);
|
|
10
10
|
return fn();
|
|
11
11
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs-cls/transactional-adapter-pg-promise",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A pg-promise adapter for @nestjs-cls/transactional",
|
|
5
5
|
"author": "Sam Artuso <samuele.a@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"test:cov": "jest --coverage"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@nestjs-cls/transactional": "^2.
|
|
44
|
+
"@nestjs-cls/transactional": "^2.3.0",
|
|
45
45
|
"nestjs-cls": "^4.3.0",
|
|
46
46
|
"pg-promise": "^11"
|
|
47
47
|
},
|