@nathapp/nestjs-data 3.0.3 → 3.0.4
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/constant/tokens.js +1 -1
- package/dist/constant/tokens.js.map +1 -1
- package/lib/constant/tokens.ts +33 -1
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
package/dist/constant/tokens.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TRANSACTION_MANAGER = void 0;
|
|
4
|
-
exports.TRANSACTION_MANAGER = Symbol('TRANSACTION_MANAGER');
|
|
4
|
+
exports.TRANSACTION_MANAGER = Symbol.for('TRANSACTION_MANAGER');
|
|
5
5
|
//# sourceMappingURL=tokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../lib/constant/tokens.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../lib/constant/tokens.ts"],"names":[],"mappings":";;;AAgCa,QAAA,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC"}
|
package/lib/constant/tokens.ts
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Global DI token for ITransactionManager.
|
|
3
|
+
*
|
|
4
|
+
* Uses Symbol.for (not Symbol) so the token is identical across all
|
|
5
|
+
* JavaScript realms, bundles, and duplicate package installations.
|
|
6
|
+
* This prevents UnknownDependenciesException when the consuming app
|
|
7
|
+
* and @nathapp/nestjs-prisma / @nathapp/nestjs-typeorm resolve
|
|
8
|
+
* @nathapp/nestjs-data from different node_modules paths or bundles.
|
|
9
|
+
*
|
|
10
|
+
* --------------------------------------------------------------------------
|
|
11
|
+
* IMPORTANT — Single-DB vs Multi-DB usage
|
|
12
|
+
* --------------------------------------------------------------------------
|
|
13
|
+
*
|
|
14
|
+
* **Single-DB apps (recommended):**
|
|
15
|
+
* @Inject(TRANSACTION_MANAGER) private readonly tx: ITransactionManager
|
|
16
|
+
*
|
|
17
|
+
* This works because the default connection registers TRANSACTION_MANAGER
|
|
18
|
+
* as an alias to the default transaction manager automatically.
|
|
19
|
+
*
|
|
20
|
+
* **Multi-DB apps (MUST use named tokens):**
|
|
21
|
+
* // CORRECT — explicit per-connection token
|
|
22
|
+
* @Inject(getPrismaTransactionManagerToken('dbA')) private readonly txA: ITransactionManager
|
|
23
|
+
* @Inject(getTypeOrmTransactionManagerToken('analytics')) private readonly txAnalytics: ITransactionManager
|
|
24
|
+
*
|
|
25
|
+
* // WRONG — TRANSACTION_MANAGER is only an alias for the DEFAULT connection.
|
|
26
|
+
* // Named connections do NOT register this global token.
|
|
27
|
+
* @Inject(TRANSACTION_MANAGER) private readonly tx: ITransactionManager // ❌ only resolves default!
|
|
28
|
+
*
|
|
29
|
+
* If you inject TRANSACTION_MANAGER in a multi-DB app, you silently get the
|
|
30
|
+
* default connection's tx manager. Writes to other databases will NOT be
|
|
31
|
+
* covered by the transaction. Use named tokens for every non-default connection.
|
|
32
|
+
*/
|
|
33
|
+
export const TRANSACTION_MANAGER = Symbol.for('TRANSACTION_MANAGER');
|