@nestjs-transactional/typeorm 1.0.0-alpha.5 → 2.0.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 +150 -308
- package/dist/adapter/typeorm.adapter.d.ts +26 -2
- package/dist/adapter/typeorm.adapter.js +81 -8
- package/dist/adapter/typeorm.adapter.js.map +1 -1
- package/dist/helpers/get-entity-manager.js +6 -10
- package/dist/helpers/get-entity-manager.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -20
- package/dist/index.js.map +1 -1
- package/dist/module/typeorm-transactional.module.d.ts +3 -3
- package/dist/module/typeorm-transactional.module.js +26 -29
- package/dist/module/typeorm-transactional.module.js.map +1 -1
- package/dist/patching/data-source-patches.js +10 -13
- package/dist/patching/data-source-patches.js.map +1 -1
- package/dist/patching/entity-manager-patches.d.ts +2 -2
- package/dist/patching/entity-manager-patches.js +11 -15
- package/dist/patching/entity-manager-patches.js.map +1 -1
- package/dist/patching/get-em-data-source.js +1 -4
- package/dist/patching/get-em-data-source.js.map +1 -1
- package/dist/patching/index.d.ts +6 -6
- package/dist/patching/index.js +14 -32
- package/dist/patching/index.js.map +1 -1
- package/dist/patching/managed-registry.js +10 -17
- package/dist/patching/managed-registry.js.map +1 -1
- package/dist/patching/repository-patches.js +17 -21
- package/dist/patching/repository-patches.js.map +1 -1
- package/dist/patching/symbols.d.ts +1 -1
- package/dist/patching/symbols.js +4 -7
- package/dist/patching/symbols.js.map +1 -1
- package/dist/types/typeorm-transaction-handle.js +1 -2
- package/package.json +30 -21
package/dist/patching/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Transparent transactional repositories — patching
|
|
3
3
|
* machinery. Exported so the module layer can drive `applyAllPatches`
|
|
4
4
|
* in `forRoot`, and so unit tests can probe state directly. None of
|
|
5
5
|
* these symbols are intended for application code — public API stays
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
export { applyRepositoryPatches, areRepositoryPatchesApplied
|
|
11
|
-
export { applyEntityManagerPatches, areEntityManagerPatchesApplied, } from './entity-manager-patches';
|
|
12
|
-
export { patchDataSourceInstance } from './data-source-patches';
|
|
13
|
-
export { getActiveEntityManager, getManagedDataSourceName, isManaged, markAsManaged, resetManagedRegistry, } from './managed-registry';
|
|
14
|
-
export { TYPEORM_DATA_SOURCE_NAME, TYPEORM_DATA_SOURCE_PATCHED, TYPEORM_ENTITY_MANAGER_NAME, } from './symbols';
|
|
10
|
+
export { applyRepositoryPatches, areRepositoryPatchesApplied } from './repository-patches.js';
|
|
11
|
+
export { applyEntityManagerPatches, areEntityManagerPatchesApplied, } from './entity-manager-patches.js';
|
|
12
|
+
export { patchDataSourceInstance } from './data-source-patches.js';
|
|
13
|
+
export { getActiveEntityManager, getManagedDataSourceName, isManaged, markAsManaged, resetManagedRegistry, } from './managed-registry.js';
|
|
14
|
+
export { TYPEORM_DATA_SOURCE_NAME, TYPEORM_DATA_SOURCE_PATCHED, TYPEORM_ENTITY_MANAGER_NAME, } from './symbols.js';
|
|
15
15
|
/**
|
|
16
16
|
* Apply both prototype-level patch families in one call. Used by
|
|
17
17
|
* `TypeOrmTransactionalModule.forRoot`'s registration factory.
|
package/dist/patching/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Transparent transactional repositories — patching
|
|
4
3
|
* machinery. Exported so the module layer can drive `applyAllPatches`
|
|
5
4
|
* in `forRoot`, and so unit tests can probe state directly. None of
|
|
6
5
|
* these symbols are intended for application code — public API stays
|
|
@@ -8,31 +7,14 @@
|
|
|
8
7
|
*
|
|
9
8
|
* @internal
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(exports, "applyRepositoryPatches", { enumerable: true, get: function () { return repository_patches_2.applyRepositoryPatches; } });
|
|
20
|
-
Object.defineProperty(exports, "areRepositoryPatchesApplied", { enumerable: true, get: function () { return repository_patches_2.areRepositoryPatchesApplied; } });
|
|
21
|
-
var entity_manager_patches_2 = require("./entity-manager-patches");
|
|
22
|
-
Object.defineProperty(exports, "applyEntityManagerPatches", { enumerable: true, get: function () { return entity_manager_patches_2.applyEntityManagerPatches; } });
|
|
23
|
-
Object.defineProperty(exports, "areEntityManagerPatchesApplied", { enumerable: true, get: function () { return entity_manager_patches_2.areEntityManagerPatchesApplied; } });
|
|
24
|
-
var data_source_patches_1 = require("./data-source-patches");
|
|
25
|
-
Object.defineProperty(exports, "patchDataSourceInstance", { enumerable: true, get: function () { return data_source_patches_1.patchDataSourceInstance; } });
|
|
26
|
-
var managed_registry_2 = require("./managed-registry");
|
|
27
|
-
Object.defineProperty(exports, "getActiveEntityManager", { enumerable: true, get: function () { return managed_registry_2.getActiveEntityManager; } });
|
|
28
|
-
Object.defineProperty(exports, "getManagedDataSourceName", { enumerable: true, get: function () { return managed_registry_2.getManagedDataSourceName; } });
|
|
29
|
-
Object.defineProperty(exports, "isManaged", { enumerable: true, get: function () { return managed_registry_2.isManaged; } });
|
|
30
|
-
Object.defineProperty(exports, "markAsManaged", { enumerable: true, get: function () { return managed_registry_2.markAsManaged; } });
|
|
31
|
-
Object.defineProperty(exports, "resetManagedRegistry", { enumerable: true, get: function () { return managed_registry_2.resetManagedRegistry; } });
|
|
32
|
-
var symbols_1 = require("./symbols");
|
|
33
|
-
Object.defineProperty(exports, "TYPEORM_DATA_SOURCE_NAME", { enumerable: true, get: function () { return symbols_1.TYPEORM_DATA_SOURCE_NAME; } });
|
|
34
|
-
Object.defineProperty(exports, "TYPEORM_DATA_SOURCE_PATCHED", { enumerable: true, get: function () { return symbols_1.TYPEORM_DATA_SOURCE_PATCHED; } });
|
|
35
|
-
Object.defineProperty(exports, "TYPEORM_ENTITY_MANAGER_NAME", { enumerable: true, get: function () { return symbols_1.TYPEORM_ENTITY_MANAGER_NAME; } });
|
|
10
|
+
import { applyEntityManagerPatches } from './entity-manager-patches.js';
|
|
11
|
+
import { resetManagedRegistry } from './managed-registry.js';
|
|
12
|
+
import { applyRepositoryPatches } from './repository-patches.js';
|
|
13
|
+
export { applyRepositoryPatches, areRepositoryPatchesApplied } from './repository-patches.js';
|
|
14
|
+
export { applyEntityManagerPatches, areEntityManagerPatchesApplied, } from './entity-manager-patches.js';
|
|
15
|
+
export { patchDataSourceInstance } from './data-source-patches.js';
|
|
16
|
+
export { getActiveEntityManager, getManagedDataSourceName, isManaged, markAsManaged, resetManagedRegistry, } from './managed-registry.js';
|
|
17
|
+
export { TYPEORM_DATA_SOURCE_NAME, TYPEORM_DATA_SOURCE_PATCHED, TYPEORM_ENTITY_MANAGER_NAME, } from './symbols.js';
|
|
36
18
|
/**
|
|
37
19
|
* Apply both prototype-level patch families in one call. Used by
|
|
38
20
|
* `TypeOrmTransactionalModule.forRoot`'s registration factory.
|
|
@@ -43,9 +25,9 @@ Object.defineProperty(exports, "TYPEORM_ENTITY_MANAGER_NAME", { enumerable: true
|
|
|
43
25
|
* are NOT included here because they apply to a specific instance
|
|
44
26
|
* and are driven separately at registration time, also idempotent.
|
|
45
27
|
*/
|
|
46
|
-
function applyAllPatches() {
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
export function applyAllPatches() {
|
|
29
|
+
applyRepositoryPatches();
|
|
30
|
+
applyEntityManagerPatches();
|
|
49
31
|
}
|
|
50
32
|
/**
|
|
51
33
|
* Test-only — drop the managed-DataSources WeakSet so cached
|
|
@@ -69,7 +51,7 @@ function applyAllPatches() {
|
|
|
69
51
|
*
|
|
70
52
|
* @internal
|
|
71
53
|
*/
|
|
72
|
-
function resetPatchingForTesting() {
|
|
73
|
-
|
|
54
|
+
export function resetPatchingForTesting() {
|
|
55
|
+
resetManagedRegistry();
|
|
74
56
|
}
|
|
75
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/patching/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/patching/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAC9F,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,SAAS,EACT,aAAa,EACb,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe;IAC7B,sBAAsB,EAAE,CAAC;IACzB,yBAAyB,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,uBAAuB;IACrC,oBAAoB,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */
|
|
3
2
|
// The patching machinery stamps and reads hidden symbol-keyed
|
|
4
3
|
// properties on TypeORM internals (`DataSource`, `EntityManager`,
|
|
@@ -6,14 +5,8 @@
|
|
|
6
5
|
// types by design, so unsafe-access lint rules fire on every
|
|
7
6
|
// access. File-level disable keeps the patch code readable; the
|
|
8
7
|
// runtime contract is documented in JSDoc above each patch.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.isManaged = isManaged;
|
|
12
|
-
exports.getManagedDataSourceName = getManagedDataSourceName;
|
|
13
|
-
exports.getActiveEntityManager = getActiveEntityManager;
|
|
14
|
-
exports.resetManagedRegistry = resetManagedRegistry;
|
|
15
|
-
const core_1 = require("@nestjs-transactional/core");
|
|
16
|
-
const symbols_1 = require("./symbols");
|
|
8
|
+
import { TransactionContext } from '@nestjs-transactional/core';
|
|
9
|
+
import { TYPEORM_DATA_SOURCE_NAME } from './symbols.js';
|
|
17
10
|
/**
|
|
18
11
|
* Process-wide set of `DataSource` instances we have registered as
|
|
19
12
|
* "managed" via {@link markAsManaged}. The patched
|
|
@@ -51,16 +44,16 @@ let managedDataSources = new WeakSet();
|
|
|
51
44
|
* own static-Map mechanism, so this collision should never occur in
|
|
52
45
|
* production.
|
|
53
46
|
*/
|
|
54
|
-
function markAsManaged(dataSource, name) {
|
|
47
|
+
export function markAsManaged(dataSource, name) {
|
|
55
48
|
managedDataSources.add(dataSource);
|
|
56
49
|
// Stamp the name as a hidden property. Cast to any to avoid a
|
|
57
50
|
// TypeORM type-shape change: we intentionally augment the runtime
|
|
58
51
|
// object without touching its public surface.
|
|
59
52
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
-
dataSource[
|
|
53
|
+
dataSource[TYPEORM_DATA_SOURCE_NAME] = name;
|
|
61
54
|
}
|
|
62
55
|
/** Predicate: is `dataSource` registered as managed? */
|
|
63
|
-
function isManaged(dataSource) {
|
|
56
|
+
export function isManaged(dataSource) {
|
|
64
57
|
return managedDataSources.has(dataSource);
|
|
65
58
|
}
|
|
66
59
|
/**
|
|
@@ -68,9 +61,9 @@ function isManaged(dataSource) {
|
|
|
68
61
|
* {@link markAsManaged}. Returns `undefined` if the DataSource has
|
|
69
62
|
* not been registered as managed.
|
|
70
63
|
*/
|
|
71
|
-
function getManagedDataSourceName(dataSource) {
|
|
64
|
+
export function getManagedDataSourceName(dataSource) {
|
|
72
65
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
-
return dataSource[
|
|
66
|
+
return dataSource[TYPEORM_DATA_SOURCE_NAME];
|
|
74
67
|
}
|
|
75
68
|
/**
|
|
76
69
|
* Resolve the active transactional `EntityManager` for the given
|
|
@@ -83,8 +76,8 @@ function getManagedDataSourceName(dataSource) {
|
|
|
83
76
|
* resolution rule — one place to evolve when the underlying lookup
|
|
84
77
|
* changes.
|
|
85
78
|
*/
|
|
86
|
-
function getActiveEntityManager(dataSourceName) {
|
|
87
|
-
const activeTx =
|
|
79
|
+
export function getActiveEntityManager(dataSourceName) {
|
|
80
|
+
const activeTx = TransactionContext.getActiveTransactionByDataSource(dataSourceName);
|
|
88
81
|
if (activeTx === undefined) {
|
|
89
82
|
return undefined;
|
|
90
83
|
}
|
|
@@ -106,7 +99,7 @@ function getActiveEntityManager(dataSourceName) {
|
|
|
106
99
|
*
|
|
107
100
|
* @internal
|
|
108
101
|
*/
|
|
109
|
-
function resetManagedRegistry() {
|
|
102
|
+
export function resetManagedRegistry() {
|
|
110
103
|
managedDataSources = new WeakSet();
|
|
111
104
|
}
|
|
112
105
|
//# sourceMappingURL=managed-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managed-registry.js","sourceRoot":"","sources":["../../src/patching/managed-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"managed-registry.js","sourceRoot":"","sources":["../../src/patching/managed-registry.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,8DAA8D;AAC9D,kEAAkE;AAClE,gEAAgE;AAChE,6DAA6D;AAC7D,gEAAgE;AAChE,4DAA4D;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAKhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD;;;;;;;;;;;;;;;;GAgBG;AACH,IAAI,kBAAkB,GAAG,IAAI,OAAO,EAAc,CAAC;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa,CAAC,UAAsB,EAAE,IAAY;IAChE,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACnC,8DAA8D;IAC9D,kEAAkE;IAClE,8CAA8C;IAC9C,8DAA8D;IAC7D,UAAkB,CAAC,wBAAwB,CAAC,GAAG,IAAI,CAAC;AACvD,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,SAAS,CAAC,UAAsB;IAC9C,OAAO,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,UAAsB;IAC7D,8DAA8D;IAC9D,OAAQ,UAAkB,CAAC,wBAAwB,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,cAAsB;IAC3D,MAAM,QAAQ,GAAG,kBAAkB,CAAC,gCAAgC,CAAC,cAAc,CAAC,CAAC;IACrF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAQ,QAAQ,CAAC,MAAmC,CAAC,aAAa,CAAC;AACrE,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB;IAClC,kBAAkB,GAAG,IAAI,OAAO,EAAc,CAAC;AACjD,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/unbound-method */
|
|
3
2
|
// The patching machinery stamps and reads hidden symbol-keyed
|
|
4
3
|
// properties on TypeORM `Repository` instances. These properties
|
|
@@ -6,13 +5,10 @@
|
|
|
6
5
|
// and unbound-method lint rules fire on every access. File-level
|
|
7
6
|
// disable keeps the patch code readable; the runtime contract is
|
|
8
7
|
// documented in the JSDoc above each patch.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const get_em_data_source_1 = require("./get-em-data-source");
|
|
14
|
-
const managed_registry_1 = require("./managed-registry");
|
|
15
|
-
const symbols_1 = require("./symbols");
|
|
8
|
+
import { Repository } from 'typeorm';
|
|
9
|
+
import { getEmDataSource } from './get-em-data-source.js';
|
|
10
|
+
import { getActiveEntityManager, getManagedDataSourceName, isManaged } from './managed-registry.js';
|
|
11
|
+
import { TYPEORM_ENTITY_MANAGER_NAME } from './symbols.js';
|
|
16
12
|
/**
|
|
17
13
|
* Tracks whether the prototype patch has been installed on
|
|
18
14
|
* `Repository.prototype`. Once installed, the patch lives for the
|
|
@@ -76,12 +72,12 @@ let originalExtend;
|
|
|
76
72
|
* patched getter to their captured original manager (autocommit) —
|
|
77
73
|
* never a broken `undefined`.
|
|
78
74
|
*/
|
|
79
|
-
function applyRepositoryPatches() {
|
|
75
|
+
export function applyRepositoryPatches() {
|
|
80
76
|
if (installed) {
|
|
81
77
|
return;
|
|
82
78
|
}
|
|
83
79
|
// (1) Repository.prototype.manager — getter/setter pair.
|
|
84
|
-
Object.defineProperty(
|
|
80
|
+
Object.defineProperty(Repository.prototype, 'manager', {
|
|
85
81
|
configurable: true,
|
|
86
82
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
83
|
get() {
|
|
@@ -91,7 +87,7 @@ function applyRepositoryPatches() {
|
|
|
91
87
|
// or (b) the `EntityManager.prototype.getRepository` wrapper
|
|
92
88
|
// when it stamps newly-resolved repositories.
|
|
93
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
-
const original = this[
|
|
90
|
+
const original = this[TYPEORM_ENTITY_MANAGER_NAME];
|
|
95
91
|
// Defensive: a Repository ending up here without ever having
|
|
96
92
|
// had its setter called (shouldn't happen in practice) yields
|
|
97
93
|
// `undefined`, mirroring the pre-patch behaviour for an
|
|
@@ -99,15 +95,15 @@ function applyRepositoryPatches() {
|
|
|
99
95
|
if (original === undefined) {
|
|
100
96
|
return undefined;
|
|
101
97
|
}
|
|
102
|
-
const ds =
|
|
103
|
-
if (!
|
|
98
|
+
const ds = getEmDataSource(original);
|
|
99
|
+
if (!isManaged(ds)) {
|
|
104
100
|
return original;
|
|
105
101
|
}
|
|
106
|
-
const dsName =
|
|
102
|
+
const dsName = getManagedDataSourceName(ds);
|
|
107
103
|
if (dsName === undefined) {
|
|
108
104
|
return original;
|
|
109
105
|
}
|
|
110
|
-
const active =
|
|
106
|
+
const active = getActiveEntityManager(dsName);
|
|
111
107
|
return active ?? original;
|
|
112
108
|
},
|
|
113
109
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -115,7 +111,7 @@ function applyRepositoryPatches() {
|
|
|
115
111
|
// Constructor's `this.manager = manager` reaches us here.
|
|
116
112
|
// Stash under the hidden symbol so the getter has a fallback.
|
|
117
113
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
-
this[
|
|
114
|
+
this[TYPEORM_ENTITY_MANAGER_NAME] = manager;
|
|
119
115
|
},
|
|
120
116
|
});
|
|
121
117
|
// (2) Repository.prototype.extend — wrap to preserve the stash on
|
|
@@ -123,9 +119,9 @@ function applyRepositoryPatches() {
|
|
|
123
119
|
// `extend` resists clean typing on the wrapper; cast through
|
|
124
120
|
// `any` to keep the wrap a single statement (the runtime
|
|
125
121
|
// contract is unchanged).
|
|
126
|
-
originalExtend =
|
|
122
|
+
originalExtend = Repository.prototype.extend;
|
|
127
123
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
-
|
|
124
|
+
Repository.prototype.extend = function patchedExtend(
|
|
129
125
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
126
|
customs) {
|
|
131
127
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -134,9 +130,9 @@ function applyRepositoryPatches() {
|
|
|
134
130
|
// patched setter, so the stash is already in place. Defensive
|
|
135
131
|
// copy in case TypeORM's internal extension shape changes.
|
|
136
132
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
-
if (result[
|
|
133
|
+
if (result[TYPEORM_ENTITY_MANAGER_NAME] === undefined) {
|
|
138
134
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
-
result[
|
|
135
|
+
result[TYPEORM_ENTITY_MANAGER_NAME] = this[TYPEORM_ENTITY_MANAGER_NAME];
|
|
140
136
|
}
|
|
141
137
|
return result;
|
|
142
138
|
};
|
|
@@ -145,7 +141,7 @@ function applyRepositoryPatches() {
|
|
|
145
141
|
/**
|
|
146
142
|
* Predicate exported for unit tests. @internal
|
|
147
143
|
*/
|
|
148
|
-
function areRepositoryPatchesApplied() {
|
|
144
|
+
export function areRepositoryPatchesApplied() {
|
|
149
145
|
return installed;
|
|
150
146
|
}
|
|
151
147
|
//# sourceMappingURL=repository-patches.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-patches.js","sourceRoot":"","sources":["../../src/patching/repository-patches.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repository-patches.js","sourceRoot":"","sources":["../../src/patching/repository-patches.ts"],"names":[],"mappings":"AAAA,2IAA2I;AAC3I,8DAA8D;AAC9D,iEAAiE;AACjE,kEAAkE;AAClE,iEAAiE;AACjE,iEAAiE;AACjE,4CAA4C;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D;;;;;;GAMG;AACH,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB;;;GAGG;AACH,IAAI,cAA8D,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,UAAU,sBAAsB;IACpC,IAAI,SAAS,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IAED,yDAAyD;IACzD,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE;QACrD,YAAY,EAAE,IAAI;QAClB,8DAA8D;QAC9D,GAAG;YACD,yDAAyD;YACzD,sDAAsD;YACtD,kEAAkE;YAClE,6DAA6D;YAC7D,8CAA8C;YAC9C,8DAA8D;YAC9D,MAAM,QAAQ,GAA+B,IAAY,CAAC,2BAA2B,CAAC,CAAC;YAEvF,6DAA6D;YAC7D,8DAA8D;YAC9D,wDAAwD;YACxD,iCAAiC;YACjC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,OAAO,SAAqC,CAAC;YAC/C,CAAC;YAED,MAAM,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;gBACnB,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,MAAM,MAAM,GAAG,wBAAwB,CAAC,EAAE,CAAC,CAAC;YAC5C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,MAAM,IAAI,QAAQ,CAAC;QAC5B,CAAC;QACD,8DAA8D;QAC9D,GAAG,CAAwB,OAAsB;YAC/C,0DAA0D;YAC1D,8DAA8D;YAC9D,8DAA8D;YAC7D,IAAY,CAAC,2BAA2B,CAAC,GAAG,OAAO,CAAC;QACvD,CAAC;KACF,CAAC,CAAC;IAEH,kEAAkE;IAClE,wDAAwD;IACxD,6DAA6D;IAC7D,yDAAyD;IACzD,0BAA0B;IAC1B,cAAc,GAAG,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC;IAC7C,8DAA8D;IAC7D,UAAU,CAAC,SAAiB,CAAC,MAAM,GAAG,SAAS,aAAa;IAG3D,8DAA8D;IAC9D,OAAY;QAEZ,oEAAoE;QACpE,MAAM,MAAM,GAAG,cAAe,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACnD,0DAA0D;QAC1D,8DAA8D;QAC9D,2DAA2D;QAC3D,8DAA8D;QAC9D,IAAK,MAAc,CAAC,2BAA2B,CAAC,KAAK,SAAS,EAAE,CAAC;YAC/D,8DAA8D;YAC7D,MAAc,CAAC,2BAA2B,CAAC,GAAI,IAAY,CAAC,2BAA2B,CAAC,CAAC;QAC5F,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hidden property keys used by the transparent transactional patching
|
|
3
|
-
* machinery
|
|
3
|
+
* machinery.
|
|
4
4
|
*
|
|
5
5
|
* `Symbol.for(...)` is used (not module-local `Symbol(...)`) so the same
|
|
6
6
|
* key resolves identically across realms and across multiple copies of
|
package/dist/patching/symbols.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Hidden property keys used by the transparent transactional patching
|
|
4
|
-
* machinery
|
|
3
|
+
* machinery.
|
|
5
4
|
*
|
|
6
5
|
* `Symbol.for(...)` is used (not module-local `Symbol(...)`) so the same
|
|
7
6
|
* key resolves identically across realms and across multiple copies of
|
|
@@ -14,8 +13,6 @@
|
|
|
14
13
|
* Namespaced strings prevent collision with arbitrary user code that
|
|
15
14
|
* might assign symbols on TypeORM internals.
|
|
16
15
|
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.TYPEORM_DATA_SOURCE_PATCHED = exports.TYPEORM_ENTITY_MANAGER_NAME = exports.TYPEORM_DATA_SOURCE_NAME = void 0;
|
|
19
16
|
/**
|
|
20
17
|
* Hidden property on each managed `DataSource` instance carrying the
|
|
21
18
|
* dataSource name under which it was registered (`'default'`,
|
|
@@ -29,7 +26,7 @@ exports.TYPEORM_DATA_SOURCE_PATCHED = exports.TYPEORM_ENTITY_MANAGER_NAME = expo
|
|
|
29
26
|
* string key, but kept as a `Symbol.for(...)` to avoid colliding with
|
|
30
27
|
* arbitrary properties user code might set on a `DataSource`.
|
|
31
28
|
*/
|
|
32
|
-
|
|
29
|
+
export const TYPEORM_DATA_SOURCE_NAME = Symbol.for('@nestjs-transactional/typeorm/data-source-name');
|
|
33
30
|
/**
|
|
34
31
|
* Hidden property on each `Repository` instance carrying the original
|
|
35
32
|
* (non-active) `EntityManager` reference. Populated when a repository
|
|
@@ -44,7 +41,7 @@ exports.TYPEORM_DATA_SOURCE_NAME = Symbol.for('@nestjs-transactional/typeorm/dat
|
|
|
44
41
|
* the original manager carries `connection`, which carries the
|
|
45
42
|
* stamped {@link TYPEORM_DATA_SOURCE_NAME}.
|
|
46
43
|
*/
|
|
47
|
-
|
|
44
|
+
export const TYPEORM_ENTITY_MANAGER_NAME = Symbol.for('@nestjs-transactional/typeorm/entity-manager');
|
|
48
45
|
/**
|
|
49
46
|
* Hidden marker on each `DataSource` instance whose per-instance
|
|
50
47
|
* patches ({@link patchDataSourceInstance} in `data-source-patches.ts`)
|
|
@@ -52,5 +49,5 @@ exports.TYPEORM_ENTITY_MANAGER_NAME = Symbol.for('@nestjs-transactional/typeorm/
|
|
|
52
49
|
* a DataSource registered through `forRoot` more than once (e.g. on
|
|
53
50
|
* test resets) does not accumulate getter/setter pairs.
|
|
54
51
|
*/
|
|
55
|
-
|
|
52
|
+
export const TYPEORM_DATA_SOURCE_PATCHED = Symbol.for('@nestjs-transactional/typeorm/data-source-patched');
|
|
56
53
|
//# sourceMappingURL=symbols.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../src/patching/symbols.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../src/patching/symbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAChD,gDAAgD,CACjD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,GAAG,CACnD,8CAA8C,CAC/C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,GAAG,CACnD,mDAAmD,CACpD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs-transactional/typeorm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "TypeORM adapter for @nestjs-transactional/core — EntityManager propagation, savepoints, multi-datasource",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"./dist/module/typeorm-transactional.module.js"
|
|
9
|
+
],
|
|
6
10
|
"author": "Igor Golovanov",
|
|
7
11
|
"repository": {
|
|
8
12
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/igorgolovanov/nestjs-transactional.git",
|
|
13
|
+
"url": "git+https://github.com/igorgolovanov/nestjs-transactional.git",
|
|
10
14
|
"directory": "packages/typeorm"
|
|
11
15
|
},
|
|
12
16
|
"bugs": {
|
|
@@ -41,40 +45,45 @@
|
|
|
41
45
|
},
|
|
42
46
|
"publishConfig": {
|
|
43
47
|
"access": "public",
|
|
44
|
-
"tag": "alpha",
|
|
45
48
|
"provenance": true
|
|
46
49
|
},
|
|
47
50
|
"peerDependencies": {
|
|
48
|
-
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
49
|
-
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
50
|
-
"@nestjs/typeorm": "^10.0.0 || ^11.0.0",
|
|
51
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
52
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
53
|
+
"@nestjs/typeorm": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
51
54
|
"reflect-metadata": "^0.1.13 || ^0.2.0",
|
|
52
55
|
"rxjs": "^7.0.0",
|
|
53
56
|
"typeorm": "^0.3.0 || ^1.0.0",
|
|
54
|
-
"@nestjs-transactional/core": "^
|
|
57
|
+
"@nestjs-transactional/core": "^2.0.0"
|
|
55
58
|
},
|
|
56
59
|
"devDependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"@nestjs/
|
|
59
|
-
"@nestjs/
|
|
60
|
-
"@nestjs/
|
|
61
|
-
"@
|
|
60
|
+
"@jest/globals": "^30.4.2",
|
|
61
|
+
"@nestjs/common": "^11.2.3",
|
|
62
|
+
"@nestjs/core": "^11.2.3",
|
|
63
|
+
"@nestjs/testing": "^11.2.3",
|
|
64
|
+
"@nestjs/typeorm": "^11.0.3",
|
|
65
|
+
"@testcontainers/postgresql": "^12.1.0",
|
|
66
|
+
"@types/jest": "^30.0.0",
|
|
67
|
+
"@types/node": "^22.20.1",
|
|
62
68
|
"@types/sql.js": "^1.4.9",
|
|
63
69
|
"reflect-metadata": "^0.2.2",
|
|
64
70
|
"rxjs": "^7.8.1",
|
|
65
|
-
"sql.js": "^1.
|
|
66
|
-
"testcontainers": "^
|
|
67
|
-
"typeorm": "^
|
|
68
|
-
"@nestjs-transactional/core": "
|
|
71
|
+
"sql.js": "^1.14.2",
|
|
72
|
+
"testcontainers": "^12.1.0",
|
|
73
|
+
"typeorm": "^1.1.0",
|
|
74
|
+
"@nestjs-transactional/core": "2.0.0"
|
|
69
75
|
},
|
|
70
76
|
"scripts": {
|
|
71
77
|
"build": "tsc -p tsconfig.build.json",
|
|
72
78
|
"clean": "rimraf dist *.tsbuildinfo coverage",
|
|
73
|
-
"test": "jest",
|
|
74
|
-
"test:watch": "jest --watch",
|
|
75
|
-
"test:cov": "jest --coverage",
|
|
76
|
-
"test:integration": "jest --config jest.integration.config.
|
|
79
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
80
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
|
|
81
|
+
"test:cov": "NODE_OPTIONS=--experimental-vm-modules jest --config jest.coverage.config.cjs --coverage",
|
|
82
|
+
"test:integration": "NODE_OPTIONS=--experimental-vm-modules jest --config jest.integration.config.cjs",
|
|
77
83
|
"type-check": "tsc --noEmit",
|
|
78
|
-
"lint": "eslint
|
|
84
|
+
"lint": "eslint .",
|
|
85
|
+
"api:check": "api-extractor run",
|
|
86
|
+
"api:update": "api-extractor run --local",
|
|
87
|
+
"publish:check": "publint && attw --pack . --profile esm-only"
|
|
79
88
|
}
|
|
80
89
|
}
|