@nestjs-transactional/typeorm 1.0.0-alpha.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/LICENSE +21 -0
- package/README.md +361 -0
- package/dist/adapter/typeorm.adapter.d.ts +39 -0
- package/dist/adapter/typeorm.adapter.js +79 -0
- package/dist/adapter/typeorm.adapter.js.map +1 -0
- package/dist/helpers/get-entity-manager.d.ts +27 -0
- package/dist/helpers/get-entity-manager.js +52 -0
- package/dist/helpers/get-entity-manager.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/module/typeorm-transactional.module.d.ts +157 -0
- package/dist/module/typeorm-transactional.module.js +289 -0
- package/dist/module/typeorm-transactional.module.js.map +1 -0
- package/dist/patching/data-source-patches.d.ts +48 -0
- package/dist/patching/data-source-patches.js +139 -0
- package/dist/patching/data-source-patches.js.map +1 -0
- package/dist/patching/entity-manager-patches.d.ts +31 -0
- package/dist/patching/entity-manager-patches.js +86 -0
- package/dist/patching/entity-manager-patches.js.map +1 -0
- package/dist/patching/index.d.ts +49 -0
- package/dist/patching/index.js +75 -0
- package/dist/patching/index.js.map +1 -0
- package/dist/patching/managed-registry.d.ts +59 -0
- package/dist/patching/managed-registry.js +112 -0
- package/dist/patching/managed-registry.js.map +1 -0
- package/dist/patching/repository-patches.d.ts +56 -0
- package/dist/patching/repository-patches.js +150 -0
- package/dist/patching/repository-patches.js.map +1 -0
- package/dist/patching/symbols.d.ts +53 -0
- package/dist/patching/symbols.js +56 -0
- package/dist/patching/symbols.js.map +1 -0
- package/dist/types/typeorm-transaction-handle.d.ts +17 -0
- package/dist/types/typeorm-transaction-handle.js +3 -0
- package/dist/types/typeorm-transaction-handle.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hidden property keys used by the transparent transactional patching
|
|
3
|
+
* machinery (Phase 14.20).
|
|
4
|
+
*
|
|
5
|
+
* `Symbol.for(...)` is used (not module-local `Symbol(...)`) so the same
|
|
6
|
+
* key resolves identically across realms and across multiple copies of
|
|
7
|
+
* this package that may end up in a single Node process — e.g. via pnpm
|
|
8
|
+
* hoisting glitches or in monorepos with mixed dependency trees. Cross-
|
|
9
|
+
* realm safety is the documented justification (matches the convention
|
|
10
|
+
* used by `Symbol.for('@nestjs-transactional/wrapped')` in the core
|
|
11
|
+
* package — see `docs/status/conventions.md` #8).
|
|
12
|
+
*
|
|
13
|
+
* Namespaced strings prevent collision with arbitrary user code that
|
|
14
|
+
* might assign symbols on TypeORM internals.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Hidden property on each managed `DataSource` instance carrying the
|
|
18
|
+
* dataSource name under which it was registered (`'default'`,
|
|
19
|
+
* `'billing'`, etc.). Stamped at registration time by
|
|
20
|
+
* {@link markAsManaged}; read by the patched
|
|
21
|
+
* `Repository.prototype.manager` getter and the patched instance-
|
|
22
|
+
* level `DataSource.manager` getter to look up the active transaction
|
|
23
|
+
* in `TransactionContext`.
|
|
24
|
+
*
|
|
25
|
+
* Mirrors typeorm-transactional's `'@transactional/data-source'`
|
|
26
|
+
* string key, but kept as a `Symbol.for(...)` to avoid colliding with
|
|
27
|
+
* arbitrary properties user code might set on a `DataSource`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const TYPEORM_DATA_SOURCE_NAME: unique symbol;
|
|
30
|
+
/**
|
|
31
|
+
* Hidden property on each `Repository` instance carrying the original
|
|
32
|
+
* (non-active) `EntityManager` reference. Populated when a repository
|
|
33
|
+
* is constructed (TypeORM's `Repository` constructor runs
|
|
34
|
+
* `this.manager = manager` — that assignment routes through the
|
|
35
|
+
* patched `Repository.prototype.manager` setter and ends up here
|
|
36
|
+
* instead of as an own-property).
|
|
37
|
+
*
|
|
38
|
+
* Used by the patched `Repository.prototype.manager` getter as the
|
|
39
|
+
* fallback when no active transaction is registered for this
|
|
40
|
+
* repository's dataSource. Also used to find the dataSource name —
|
|
41
|
+
* the original manager carries `connection`, which carries the
|
|
42
|
+
* stamped {@link TYPEORM_DATA_SOURCE_NAME}.
|
|
43
|
+
*/
|
|
44
|
+
export declare const TYPEORM_ENTITY_MANAGER_NAME: unique symbol;
|
|
45
|
+
/**
|
|
46
|
+
* Hidden marker on each `DataSource` instance whose per-instance
|
|
47
|
+
* patches ({@link patchDataSourceInstance} in `data-source-patches.ts`)
|
|
48
|
+
* have been applied. Used to make the patch operation idempotent —
|
|
49
|
+
* a DataSource registered through `forRoot` more than once (e.g. on
|
|
50
|
+
* test resets) does not accumulate getter/setter pairs.
|
|
51
|
+
*/
|
|
52
|
+
export declare const TYPEORM_DATA_SOURCE_PATCHED: unique symbol;
|
|
53
|
+
//# sourceMappingURL=symbols.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hidden property keys used by the transparent transactional patching
|
|
4
|
+
* machinery (Phase 14.20).
|
|
5
|
+
*
|
|
6
|
+
* `Symbol.for(...)` is used (not module-local `Symbol(...)`) so the same
|
|
7
|
+
* key resolves identically across realms and across multiple copies of
|
|
8
|
+
* this package that may end up in a single Node process — e.g. via pnpm
|
|
9
|
+
* hoisting glitches or in monorepos with mixed dependency trees. Cross-
|
|
10
|
+
* realm safety is the documented justification (matches the convention
|
|
11
|
+
* used by `Symbol.for('@nestjs-transactional/wrapped')` in the core
|
|
12
|
+
* package — see `docs/status/conventions.md` #8).
|
|
13
|
+
*
|
|
14
|
+
* Namespaced strings prevent collision with arbitrary user code that
|
|
15
|
+
* might assign symbols on TypeORM internals.
|
|
16
|
+
*/
|
|
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
|
+
/**
|
|
20
|
+
* Hidden property on each managed `DataSource` instance carrying the
|
|
21
|
+
* dataSource name under which it was registered (`'default'`,
|
|
22
|
+
* `'billing'`, etc.). Stamped at registration time by
|
|
23
|
+
* {@link markAsManaged}; read by the patched
|
|
24
|
+
* `Repository.prototype.manager` getter and the patched instance-
|
|
25
|
+
* level `DataSource.manager` getter to look up the active transaction
|
|
26
|
+
* in `TransactionContext`.
|
|
27
|
+
*
|
|
28
|
+
* Mirrors typeorm-transactional's `'@transactional/data-source'`
|
|
29
|
+
* string key, but kept as a `Symbol.for(...)` to avoid colliding with
|
|
30
|
+
* arbitrary properties user code might set on a `DataSource`.
|
|
31
|
+
*/
|
|
32
|
+
exports.TYPEORM_DATA_SOURCE_NAME = Symbol.for('@nestjs-transactional/typeorm/data-source-name');
|
|
33
|
+
/**
|
|
34
|
+
* Hidden property on each `Repository` instance carrying the original
|
|
35
|
+
* (non-active) `EntityManager` reference. Populated when a repository
|
|
36
|
+
* is constructed (TypeORM's `Repository` constructor runs
|
|
37
|
+
* `this.manager = manager` — that assignment routes through the
|
|
38
|
+
* patched `Repository.prototype.manager` setter and ends up here
|
|
39
|
+
* instead of as an own-property).
|
|
40
|
+
*
|
|
41
|
+
* Used by the patched `Repository.prototype.manager` getter as the
|
|
42
|
+
* fallback when no active transaction is registered for this
|
|
43
|
+
* repository's dataSource. Also used to find the dataSource name —
|
|
44
|
+
* the original manager carries `connection`, which carries the
|
|
45
|
+
* stamped {@link TYPEORM_DATA_SOURCE_NAME}.
|
|
46
|
+
*/
|
|
47
|
+
exports.TYPEORM_ENTITY_MANAGER_NAME = Symbol.for('@nestjs-transactional/typeorm/entity-manager');
|
|
48
|
+
/**
|
|
49
|
+
* Hidden marker on each `DataSource` instance whose per-instance
|
|
50
|
+
* patches ({@link patchDataSourceInstance} in `data-source-patches.ts`)
|
|
51
|
+
* have been applied. Used to make the patch operation idempotent —
|
|
52
|
+
* a DataSource registered through `forRoot` more than once (e.g. on
|
|
53
|
+
* test resets) does not accumulate getter/setter pairs.
|
|
54
|
+
*/
|
|
55
|
+
exports.TYPEORM_DATA_SOURCE_PATCHED = Symbol.for('@nestjs-transactional/typeorm/data-source-patched');
|
|
56
|
+
//# sourceMappingURL=symbols.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../src/patching/symbols.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;;;;;;;;;GAYG;AACU,QAAA,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAChD,gDAAgD,CACjD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACU,QAAA,2BAA2B,GAAG,MAAM,CAAC,GAAG,CACnD,8CAA8C,CAC/C,CAAC;AAEF;;;;;;GAMG;AACU,QAAA,2BAA2B,GAAG,MAAM,CAAC,GAAG,CACnD,mDAAmD,CACpD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TransactionHandle } from '@nestjs-transactional/core';
|
|
2
|
+
import type { EntityManager } from 'typeorm';
|
|
3
|
+
/**
|
|
4
|
+
* Adapter-specific handle produced by {@link TypeOrmTransactionAdapter}.
|
|
5
|
+
* Extends the core {@link TransactionHandle} with the TypeORM
|
|
6
|
+
* {@link EntityManager} bound to the active transaction.
|
|
7
|
+
*
|
|
8
|
+
* The `EntityManager` carries its own `QueryRunner` internally, so
|
|
9
|
+
* adapters and helpers can issue `SAVEPOINT` / `ROLLBACK TO SAVEPOINT` /
|
|
10
|
+
* `RELEASE SAVEPOINT` SQL via `handle.entityManager.query(...)` without
|
|
11
|
+
* needing a separate query-runner reference on the handle itself.
|
|
12
|
+
*/
|
|
13
|
+
export interface TypeOrmTransactionHandle extends TransactionHandle {
|
|
14
|
+
/** The TypeORM EntityManager scoped to this transaction. */
|
|
15
|
+
readonly entityManager: EntityManager;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=typeorm-transaction-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeorm-transaction-handle.js","sourceRoot":"","sources":["../../src/types/typeorm-transaction-handle.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nestjs-transactional/typeorm",
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
|
+
"description": "TypeORM adapter for @nestjs-transactional/core — EntityManager propagation, savepoints, multi-datasource",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Igor Golovanov",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/igorgolovanov/nestjs-transactional.git",
|
|
10
|
+
"directory": "packages/typeorm"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/igorgolovanov/nestjs-transactional/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/igorgolovanov/nestjs-transactional/tree/main/packages/typeorm#readme",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"nestjs",
|
|
18
|
+
"typeorm",
|
|
19
|
+
"transaction",
|
|
20
|
+
"transactional",
|
|
21
|
+
"spring",
|
|
22
|
+
"entity-manager",
|
|
23
|
+
"savepoint"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22.11.0"
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist/**/*.js",
|
|
32
|
+
"dist/**/*.d.ts",
|
|
33
|
+
"dist/**/*.js.map",
|
|
34
|
+
"!dist/**/*.spec.*"
|
|
35
|
+
],
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"provenance": true
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
48
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
49
|
+
"@nestjs/typeorm": "^10.0.0 || ^11.0.0",
|
|
50
|
+
"reflect-metadata": "^0.1.13 || ^0.2.0",
|
|
51
|
+
"rxjs": "^7.0.0",
|
|
52
|
+
"typeorm": "^0.3.25",
|
|
53
|
+
"@nestjs-transactional/core": "^1.0.0-alpha.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@nestjs/common": "^11.0.0",
|
|
57
|
+
"@nestjs/core": "^11.0.0",
|
|
58
|
+
"@nestjs/testing": "^11.0.0",
|
|
59
|
+
"@nestjs/typeorm": "^11.0.0",
|
|
60
|
+
"@testcontainers/postgresql": "^10.13.0",
|
|
61
|
+
"@types/sql.js": "^1.4.9",
|
|
62
|
+
"reflect-metadata": "^0.2.2",
|
|
63
|
+
"rxjs": "^7.8.1",
|
|
64
|
+
"sql.js": "^1.11.0",
|
|
65
|
+
"testcontainers": "^10.13.0",
|
|
66
|
+
"typeorm": "^0.3.25",
|
|
67
|
+
"@nestjs-transactional/core": "1.0.0-alpha.0"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "tsc -p tsconfig.build.json",
|
|
71
|
+
"clean": "rimraf dist *.tsbuildinfo coverage",
|
|
72
|
+
"test": "jest",
|
|
73
|
+
"test:watch": "jest --watch",
|
|
74
|
+
"test:cov": "jest --coverage",
|
|
75
|
+
"test:integration": "jest --config jest.integration.config.js",
|
|
76
|
+
"type-check": "tsc --noEmit",
|
|
77
|
+
"lint": "eslint \"src/**/*.ts\""
|
|
78
|
+
}
|
|
79
|
+
}
|