@nestjs-transactional/typeorm 1.0.0-alpha.0 → 1.0.0-alpha.3

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 CHANGED
@@ -50,6 +50,24 @@ TypeORM adapter for [`@nestjs-transactional/core`](../core).
50
50
  pnpm add @nestjs-transactional/typeorm @nestjs-transactional/core typeorm @nestjs/typeorm reflect-metadata
51
51
  ```
52
52
 
53
+ ## Compatibility
54
+
55
+ | Peer | Supported range |
56
+ | ----------------------------------- | -------------------------- |
57
+ | Node.js | `>=22.13.0` |
58
+ | `typeorm` | `^0.3.0 \|\| ^1.0.0` |
59
+ | `@nestjs/typeorm` | `^10.0.0 \|\| ^11.0.0` |
60
+ | `@nestjs/common` / `@nestjs/core` | `^10.0.0 \|\| ^11.0.0` |
61
+ | `reflect-metadata` | `^0.1.13 \|\| ^0.2.0` |
62
+ | `rxjs` | `^7.0.0` |
63
+
64
+ The TypeORM range covers both stable `0.3.x` and stable `1.x`
65
+ releases. CI runs the full unit and integration matrix
66
+ (testcontainers Postgres) against both TypeORM majors, so the
67
+ adapter is exercised end-to-end on every supported peer. TypeORM
68
+ nightly / beta builds are not in the declared range; install them
69
+ explicitly via `pnpm.overrides` if you need to pin to one.
70
+
53
71
  ## Quick start
54
72
 
55
73
  Minimal single-DataSource setup:
@@ -4,7 +4,7 @@
4
4
  * stamp pointing at this `EntityManager`. The patched
5
5
  * `Repository.prototype.manager` getter then has a stable fallback
6
6
  * (the original, non-active manager) and a way to discover the
7
- * dataSource name (via `original.connection`).
7
+ * dataSource name (via `getEmDataSource(original)`).
8
8
  *
9
9
  * This wrap matters specifically for the
10
10
  * `@InjectEntityManager() em.getRepository(Entity).save(...)` user
@@ -15,7 +15,7 @@
15
15
  * itself — and the patched `Repository.prototype.manager` getter
16
16
  * would have nothing to read. With the wrap, the returned repo
17
17
  * carries `em` under the stash symbol, the getter resolves the
18
- * dataSource name from `em.connection`, and the lookup proceeds
18
+ * dataSource name from `em` (via the version-compat helper), and the lookup proceeds
19
19
  * normally. Net effect: even when reaching a Repository through
20
20
  * `@InjectEntityManager`, the active transactional EntityManager is
21
21
  * still used.
@@ -31,7 +31,7 @@ let originalGetRepository;
31
31
  * stamp pointing at this `EntityManager`. The patched
32
32
  * `Repository.prototype.manager` getter then has a stable fallback
33
33
  * (the original, non-active manager) and a way to discover the
34
- * dataSource name (via `original.connection`).
34
+ * dataSource name (via `getEmDataSource(original)`).
35
35
  *
36
36
  * This wrap matters specifically for the
37
37
  * `@InjectEntityManager() em.getRepository(Entity).save(...)` user
@@ -42,7 +42,7 @@ let originalGetRepository;
42
42
  * itself — and the patched `Repository.prototype.manager` getter
43
43
  * would have nothing to read. With the wrap, the returned repo
44
44
  * carries `em` under the stash symbol, the getter resolves the
45
- * dataSource name from `em.connection`, and the lookup proceeds
45
+ * dataSource name from `em` (via the version-compat helper), and the lookup proceeds
46
46
  * normally. Net effect: even when reaching a Repository through
47
47
  * `@InjectEntityManager`, the active transactional EntityManager is
48
48
  * still used.
@@ -0,0 +1,14 @@
1
+ import type { DataSource, EntityManager } from 'typeorm';
2
+ /**
3
+ * Read the owning {@link DataSource} from an {@link EntityManager}
4
+ * across TypeORM versions.
5
+ *
6
+ * TypeORM 0.3.x exposes `EntityManager.connection: DataSource`.
7
+ * TypeORM 1.0 renamed it to `EntityManager.dataSource: DataSource`
8
+ * and removed the legacy name. The two field names never coexist
9
+ * on the same `EntityManager` instance, so checking both keeps the
10
+ * patching layer compatible with both peer ranges without a runtime
11
+ * version check.
12
+ */
13
+ export declare function getEmDataSource(em: EntityManager): DataSource;
14
+ //# sourceMappingURL=get-em-data-source.d.ts.map
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEmDataSource = getEmDataSource;
4
+ /**
5
+ * Read the owning {@link DataSource} from an {@link EntityManager}
6
+ * across TypeORM versions.
7
+ *
8
+ * TypeORM 0.3.x exposes `EntityManager.connection: DataSource`.
9
+ * TypeORM 1.0 renamed it to `EntityManager.dataSource: DataSource`
10
+ * and removed the legacy name. The two field names never coexist
11
+ * on the same `EntityManager` instance, so checking both keeps the
12
+ * patching layer compatible with both peer ranges without a runtime
13
+ * version check.
14
+ */
15
+ function getEmDataSource(em) {
16
+ const shape = em;
17
+ const ds = shape.dataSource ?? shape.connection;
18
+ if (ds === undefined) {
19
+ throw new Error('EntityManager exposes neither `dataSource` nor `connection`. ' +
20
+ 'Unsupported TypeORM version.');
21
+ }
22
+ return ds;
23
+ }
24
+ //# sourceMappingURL=get-em-data-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-em-data-source.js","sourceRoot":"","sources":["../../src/patching/get-em-data-source.ts"],"names":[],"mappings":";;AAaA,0CAaC;AAxBD;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAAC,EAAiB;IAC/C,MAAM,KAAK,GAAG,EAGb,CAAC;IACF,MAAM,EAAE,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC;IAChD,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,+DAA+D;YAC7D,8BAA8B,CACjC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.applyRepositoryPatches = applyRepositoryPatches;
11
11
  exports.areRepositoryPatchesApplied = areRepositoryPatchesApplied;
12
12
  const typeorm_1 = require("typeorm");
13
+ const get_em_data_source_1 = require("./get-em-data-source");
13
14
  const managed_registry_1 = require("./managed-registry");
14
15
  const symbols_1 = require("./symbols");
15
16
  /**
@@ -98,7 +99,7 @@ function applyRepositoryPatches() {
98
99
  if (original === undefined) {
99
100
  return undefined;
100
101
  }
101
- const ds = original.connection;
102
+ const ds = (0, get_em_data_source_1.getEmDataSource)(original);
102
103
  if (!(0, managed_registry_1.isManaged)(ds)) {
103
104
  return original;
104
105
  }
@@ -1 +1 @@
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;;AAyE5C,wDA2EC;AAKD,kEAEC;AAzJD,qCAAqC;AAGrC,yDAAiG;AACjG,uCAAwD;AAExD;;;;;;GAMG;AACH,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB;;;GAGG;AACH,IAAI,cAA8D,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,SAAgB,sBAAsB;IACpC,IAAI,SAAS,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IAED,yDAAyD;IACzD,MAAM,CAAC,cAAc,CAAC,oBAAU,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,qCAA2B,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,QAAQ,CAAC,UAAU,CAAC;YAC/B,IAAI,CAAC,IAAA,4BAAS,EAAC,EAAE,CAAC,EAAE,CAAC;gBACnB,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,MAAM,MAAM,GAAG,IAAA,2CAAwB,EAAC,EAAE,CAAC,CAAC;YAC5C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,QAAQ,CAAC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2B,CAAC,GAAG,OAAO,CAAC;QACvD,CAAC;KACF,CAAC,CAAC;IAEH,kEAAkE;IAClE,wDAAwD;IACxD,6DAA6D;IAC7D,yDAAyD;IACzD,0BAA0B;IAC1B,cAAc,GAAG,oBAAU,CAAC,SAAS,CAAC,MAAM,CAAC;IAC7C,8DAA8D;IAC7D,oBAAU,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,qCAA2B,CAAC,KAAK,SAAS,EAAE,CAAC;YAC/D,8DAA8D;YAC7D,MAAc,CAAC,qCAA2B,CAAC,GAAI,IAAY,CAAC,qCAA2B,CAAC,CAAC;QAC5F,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,2BAA2B;IACzC,OAAO,SAAS,CAAC;AACnB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs-transactional/typeorm",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "TypeORM adapter for @nestjs-transactional/core — EntityManager propagation, savepoints, multi-datasource",
5
5
  "license": "MIT",
6
6
  "author": "Igor Golovanov",
@@ -23,7 +23,7 @@
23
23
  "savepoint"
24
24
  ],
25
25
  "engines": {
26
- "node": ">=22.11.0"
26
+ "node": ">=22.13.0"
27
27
  },
28
28
  "main": "dist/index.js",
29
29
  "types": "dist/index.d.ts",
@@ -41,6 +41,7 @@
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public",
44
+ "tag": "alpha",
44
45
  "provenance": true
45
46
  },
46
47
  "peerDependencies": {
@@ -49,8 +50,8 @@
49
50
  "@nestjs/typeorm": "^10.0.0 || ^11.0.0",
50
51
  "reflect-metadata": "^0.1.13 || ^0.2.0",
51
52
  "rxjs": "^7.0.0",
52
- "typeorm": "^0.3.25",
53
- "@nestjs-transactional/core": "^1.0.0-alpha.0"
53
+ "typeorm": "^0.3.0 || ^1.0.0",
54
+ "@nestjs-transactional/core": "^1.0.0-alpha.3"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@nestjs/common": "^11.0.0",
@@ -63,8 +64,8 @@
63
64
  "rxjs": "^7.8.1",
64
65
  "sql.js": "^1.11.0",
65
66
  "testcontainers": "^10.13.0",
66
- "typeorm": "^0.3.25",
67
- "@nestjs-transactional/core": "1.0.0-alpha.0"
67
+ "typeorm": "^0.3.0 || ^1.0.0",
68
+ "@nestjs-transactional/core": "1.0.0-alpha.3"
68
69
  },
69
70
  "scripts": {
70
71
  "build": "tsc -p tsconfig.build.json",