@wisemen/nestjs-typeorm 1.1.2 → 1.2.1

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,77 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Column, Entity } from "typeorm";
11
+ let TestEntity = class TestEntity {
12
+ requiredColumn;
13
+ optionalColumn;
14
+ defaultColumn;
15
+ embeddedColumn;
16
+ relation;
17
+ };
18
+ __decorate([
19
+ Column({ type: 'varchar' }),
20
+ __metadata("design:type", String)
21
+ ], TestEntity.prototype, "requiredColumn", void 0);
22
+ __decorate([
23
+ Column({ type: 'varchar', nullable: true }),
24
+ __metadata("design:type", Object)
25
+ ], TestEntity.prototype, "optionalColumn", void 0);
26
+ __decorate([
27
+ Column({ type: 'varchar', default: 'default value' }),
28
+ __metadata("design:type", Object)
29
+ ], TestEntity.prototype, "defaultColumn", void 0);
30
+ __decorate([
31
+ Column(() => TestEmbedded),
32
+ __metadata("design:type", Object)
33
+ ], TestEntity.prototype, "embeddedColumn", void 0);
34
+ TestEntity = __decorate([
35
+ Entity()
36
+ ], TestEntity);
37
+ class TestEmbedded {
38
+ requiredColumn;
39
+ optionalColumn;
40
+ defaultColumn;
41
+ }
42
+ __decorate([
43
+ Column({ type: 'varchar' }),
44
+ __metadata("design:type", String)
45
+ ], TestEmbedded.prototype, "requiredColumn", void 0);
46
+ __decorate([
47
+ Column({ type: 'varchar', nullable: true }),
48
+ __metadata("design:type", Object)
49
+ ], TestEmbedded.prototype, "optionalColumn", void 0);
50
+ __decorate([
51
+ Column({ type: 'varchar', default: 'default value' }),
52
+ __metadata("design:type", Object)
53
+ ], TestEmbedded.prototype, "defaultColumn", void 0);
54
+ const _insertOnlyRequired = {
55
+ requiredColumn: 'required value',
56
+ embeddedColumn: {
57
+ requiredColumn: 'required value',
58
+ },
59
+ // relation: 'relation value' <-- not allowed
60
+ };
61
+ const _insertWithOptionals = {
62
+ requiredColumn: 'required value',
63
+ optionalColumn: 'optional value',
64
+ embeddedColumn: {
65
+ requiredColumn: 'required value',
66
+ optionalColumn: 'optional value',
67
+ }
68
+ };
69
+ const _insertOverwriteDefaults = {
70
+ requiredColumn: 'required value',
71
+ defaultColumn: 'optional value',
72
+ embeddedColumn: {
73
+ requiredColumn: 'required value',
74
+ defaultColumn: 'optional value',
75
+ }
76
+ };
77
+ //# sourceMappingURL=test.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.entity.js","sourceRoot":"","sources":["../../lib/example/test.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAOxC,IAAM,UAAU,GAAhB,MAAM,UAAU;IAEd,cAAc,CAAQ;IAGtB,cAAc,CAAe;IAG7B,aAAa,CAAiB;IAG9B,cAAc,CAAwB;IAEtC,QAAQ,CAAkB;CAC3B,CAAA;AAZC;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;kDACN;AAGtB;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACf;AAG7B;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;;iDACxB;AAG9B;IADC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC;;kDACW;AAXlC,UAAU;IADf,MAAM,EAAE;GACH,UAAU,CAcf;AAGD,MAAM,YAAY;IAEhB,cAAc,CAAQ;IAGtB,cAAc,CAAe;IAG7B,aAAa,CAAiB;CAC/B;AAPC;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;oDACN;AAGtB;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACf;AAG7B;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;;mDACxB;AAKhC,MAAM,mBAAmB,GAAe;IACtC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE;QACd,cAAc,EAAE,gBAAgB;KACjC;IACD,6CAA6C;CAC9C,CAAA;AAED,MAAM,oBAAoB,GAAe;IACvC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE;QACd,cAAc,EAAE,gBAAgB;QAChC,cAAc,EAAE,gBAAgB;KACjC;CACF,CAAA;AAED,MAAM,wBAAwB,GAAe;IAC3C,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,gBAAgB;IAC/B,cAAc,EAAE;QACd,cAAc,EAAE,gBAAgB;QAChC,aAAa,EAAE,gBAAgB;KAChC;CACF,CAAA"}
@@ -1,3 +1,21 @@
1
1
  import type { DataSource, EntityManager } from 'typeorm';
2
- export declare function readonly<T>(dataSource: DataSource, fn: () => Promise<T>): Promise<T>;
2
+ /**
3
+ * Runs the provided callback in a readonly database context backed by a slave query runner.
4
+ *
5
+ * If a readonly context is already active, the callback is reused within that context instead of
6
+ * creating a new query runner. Starting a readonly context from inside a transaction is rejected
7
+ * because it would break the current transactional guarantees. Within the callback, injected
8
+ * TypeORM repositories automatically resolve against the active readonly manager, so repository
9
+ * operations also use the readonly query runner without requiring manual rebinding.
10
+ *
11
+ * @template T
12
+ * @param dataSource The TypeORM data source used to create the readonly query runner.
13
+ * @param runInReadonly Async callback that receives the readonly entity manager for all database
14
+ * access. Injected TypeORM repositories used inside this callback automatically participate in the
15
+ * same readonly context.
16
+ * @returns The value returned by `runInReadonly`.
17
+ * @throws {Error} If called while a transaction context is active.
18
+ * @throws {QueryRunnerProviderAlreadyReleasedError} If the current readonly context references a released query runner.
19
+ */
20
+ export declare function readonly<T>(dataSource: DataSource, runInReadonly: (entityManager: EntityManager) => Promise<T>): Promise<T>;
3
21
  export declare function createReadonlyManagerProxy(defaultManager: EntityManager): EntityManager;
@@ -1,7 +1,25 @@
1
1
  import { QueryRunnerProviderAlreadyReleasedError } from 'typeorm';
2
2
  import { isInTransaction, readonlyStorage } from './context.js';
3
- export async function readonly(dataSource, fn) {
4
- // Disallow starting a readonly scope while in a transaction
3
+ import assert from 'node:assert';
4
+ /**
5
+ * Runs the provided callback in a readonly database context backed by a slave query runner.
6
+ *
7
+ * If a readonly context is already active, the callback is reused within that context instead of
8
+ * creating a new query runner. Starting a readonly context from inside a transaction is rejected
9
+ * because it would break the current transactional guarantees. Within the callback, injected
10
+ * TypeORM repositories automatically resolve against the active readonly manager, so repository
11
+ * operations also use the readonly query runner without requiring manual rebinding.
12
+ *
13
+ * @template T
14
+ * @param dataSource The TypeORM data source used to create the readonly query runner.
15
+ * @param runInReadonly Async callback that receives the readonly entity manager for all database
16
+ * access. Injected TypeORM repositories used inside this callback automatically participate in the
17
+ * same readonly context.
18
+ * @returns The value returned by `runInReadonly`.
19
+ * @throws {Error} If called while a transaction context is active.
20
+ * @throws {QueryRunnerProviderAlreadyReleasedError} If the current readonly context references a released query runner.
21
+ */
22
+ export async function readonly(dataSource, runInReadonly) {
5
23
  if (isInTransaction()) {
6
24
  throw new Error('Cannot start a readonly context inside a transaction');
7
25
  }
@@ -10,11 +28,13 @@ export async function readonly(dataSource, fn) {
10
28
  throw new QueryRunnerProviderAlreadyReleasedError();
11
29
  }
12
30
  if (existing != null) {
13
- return await fn();
31
+ assert(existing.queryRunner !== undefined, 'existing readonly without queryRunner');
32
+ return await runInReadonly(existing.queryRunner.manager);
14
33
  }
15
34
  const queryRunner = dataSource.createQueryRunner('slave');
16
35
  try {
17
- return await readonlyStorage.run(queryRunner.manager, fn);
36
+ const callback = async () => await runInReadonly(queryRunner.manager);
37
+ return await readonlyStorage.run(queryRunner.manager, callback);
18
38
  }
19
39
  finally {
20
40
  await queryRunner.release();
@@ -1 +1 @@
1
- {"version":3,"file":"readonly.js","sourceRoot":"","sources":["../../lib/extensions/readonly.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uCAAuC,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE/D,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,UAAsB,EACtB,EAAoB;IAEpB,4DAA4D;IAC5D,IAAI,eAAe,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;IACzE,CAAC;IACD,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IAE3C,IAAI,QAAQ,EAAE,WAAW,IAAI,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QACrE,MAAM,IAAI,uCAAuC,EAAE,CAAA;IACrD,CAAC;IAED,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,OAAO,MAAM,EAAE,EAAE,CAAA;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAEzD,IAAI,CAAC;QACH,OAAO,MAAM,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IAC3D,CAAC;YAAS,CAAC;QACT,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;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WAAW,KAAK,SAAS,EAAE,uCAAuC,CAAC,CAAA;QACnF,OAAO,MAAM,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM,WAAW,GAAG,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAEzD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE,CAAC,MAAM,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACrE,OAAO,MAAM,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACjE,CAAC;YAAS,CAAC;QACT,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAE,cAA6B;IACvE,OAAO,IAAI,KAAK,CAAC,cAAc,EAAE;QAC/B,GAAG,CAAE,MAAM,EAAE,IAAI;YACf,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;YAE1C,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;gBACpB,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;oBAC3B,OAAO,CAAC,GAAG,EAAE;wBACX,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAA;oBACpF,CAAC,CAAY,CAAA;gBACf,CAAC;gBAED,OAAO,OAAO,CAAC,IAAI,CAAY,CAAA;YACjC,CAAC;YAED,OAAO,MAAM,CAAC,IAAI,CAAY,CAAA;QAChC,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -1,3 +1,20 @@
1
1
  import type { DataSource, EntityManager } from 'typeorm';
2
+ /**
3
+ * Runs the provided callback inside a transaction and exposes the active transaction manager.
4
+ *
5
+ * If a transaction is already active, the callback is executed as a nested TypeORM transaction on
6
+ * the current manager. Starting a transaction from inside a readonly context is rejected because
7
+ * writes must not escape the readonly boundary. Within the callback, injected TypeORM repositories
8
+ * automatically resolve against the active transaction manager, so repository operations join the
9
+ * same transaction without requiring manual rebinding.
10
+ *
11
+ * @template T
12
+ * @param dataSource The TypeORM data source used to start the transaction when none is active.
13
+ * @param runInTransaction Async callback that receives the transaction-bound entity manager.
14
+ * Injected TypeORM repositories used inside this callback automatically participate in the same
15
+ * transaction context.
16
+ * @returns The value returned by `runInTransaction`.
17
+ * @throws {Error} If called while a readonly context is active.
18
+ */
2
19
  export declare function transaction<T>(dataSource: DataSource, runInTransaction: (entityManager: EntityManager) => Promise<T>): Promise<T>;
3
20
  export declare function createTransactionManagerProxy(manager: EntityManager): EntityManager;
@@ -1,4 +1,21 @@
1
1
  import { isInReadonly, transactionStorage } from './context.js';
2
+ /**
3
+ * Runs the provided callback inside a transaction and exposes the active transaction manager.
4
+ *
5
+ * If a transaction is already active, the callback is executed as a nested TypeORM transaction on
6
+ * the current manager. Starting a transaction from inside a readonly context is rejected because
7
+ * writes must not escape the readonly boundary. Within the callback, injected TypeORM repositories
8
+ * automatically resolve against the active transaction manager, so repository operations join the
9
+ * same transaction without requiring manual rebinding.
10
+ *
11
+ * @template T
12
+ * @param dataSource The TypeORM data source used to start the transaction when none is active.
13
+ * @param runInTransaction Async callback that receives the transaction-bound entity manager.
14
+ * Injected TypeORM repositories used inside this callback automatically participate in the same
15
+ * transaction context.
16
+ * @returns The value returned by `runInTransaction`.
17
+ * @throws {Error} If called while a readonly context is active.
18
+ */
2
19
  export async function transaction(dataSource, runInTransaction) {
3
20
  if (isInReadonly()) {
4
21
  throw new Error('Cannot start a transaction inside a readonly context');
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../lib/extensions/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAE/D,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,UAAsB,EACtB,gBAA8D;IAE9D,IAAI,YAAY,EAAE,EAAE,CAAC;QACnB,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,kBAAkB,CAAC,QAAQ,EAAE,CAAA;IAExD,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;QAC/B,OAAO,MAAM,kBAAkB,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAA;IAC/D,CAAC;IAED,OAAO,MAAM,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACpD,OAAO,MAAM,kBAAkB,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;YACtD,OAAO,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAA;QACxC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAE,OAAsB;IACnE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;QACxB,GAAG,CAAE,MAAM,EAAE,IAAI;YACf,MAAM,OAAO,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAA;YAE7C,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;gBACpB,OAAO,OAAO,CAAC,IAAI,CAAY,CAAA;YACjC,CAAC;iBAAM,CAAC;gBACN,OAAO,MAAM,CAAC,IAAI,CAAY,CAAA;YAChC,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export { createTypeOrmProviders, NestjsTypeOrmModuleAsyncOptions, TypeOrmModule,
3
3
  export { AnyOrIgnore, AndOrIgnore } from './operators/index.js';
4
4
  export { SnakeNamingStrategy } from './naming/index.js';
5
5
  export { migrate, sslHelper } from './helpers/index.js';
6
- export { Default, Insert } from './types/index.js';
6
+ export { Default, EntityInsert } from './types/index.js';
@@ -0,0 +1,6 @@
1
+ export type Embedded<T> = T & {
2
+ readonly _embedded?: true;
3
+ };
4
+ export type IsEmbedded<K> = [Extract<K, {
5
+ readonly _embedded?: true;
6
+ }>] extends [never] ? false : true;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=embedded.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedded.type.js","sourceRoot":"","sources":["../../lib/types/embedded.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { HasDefault } from './default.type.js';
2
+ import { IsEmbedded } from './embedded.type.js';
3
+ import { IsRelation } from './relation.js';
4
+ type OptionalKeys<T> = {
5
+ [K in keyof T]: null extends T[K] ? K : HasDefault<T[K]> extends true ? K : never;
6
+ }[keyof T];
7
+ type RelationKeys<T> = {
8
+ [K in keyof T]: IsRelation<T[K]> extends true ? K : never;
9
+ }[keyof T];
10
+ type RequiredKeys<T> = Exclude<keyof T, OptionalKeys<T> | RelationKeys<T>>;
11
+ export type EntityInsert<T> = {
12
+ [K in RequiredKeys<T>]: IsEmbedded<T[K]> extends true ? EntityInsert<Omit<T[K], '_embedded'>> : T[K];
13
+ } & {
14
+ [K in OptionalKeys<T>]?: IsEmbedded<T[K]> extends true ? EntityInsert<Omit<T[K], '_embedded'>> : T[K];
15
+ };
16
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=entity-insert.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-insert.type.js","sourceRoot":"","sources":["../../lib/types/entity-insert.type.ts"],"names":[],"mappings":""}
@@ -1,2 +1,4 @@
1
+ export { EntityInsert } from './entity-insert.type.js';
1
2
  export { Default } from './default.type.js';
2
- export { Insert } from './insert.type.js';
3
+ export { Embedded } from './embedded.type.js';
4
+ export { Relation } from './relation.js';
@@ -0,0 +1,6 @@
1
+ export type Relation<T> = T & {
2
+ readonly _relation?: true;
3
+ };
4
+ export type IsRelation<K> = [Extract<K, {
5
+ readonly _relation?: true;
6
+ }>] extends [never] ? false : true;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=relation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relation.js","sourceRoot":"","sources":["../../lib/types/relation.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wisemen/nestjs-typeorm",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -28,7 +28,7 @@
28
28
  "eslint": "10.2.1",
29
29
  "oxlint": "1.59.0",
30
30
  "oxlint-tsgolint": "0.20.0",
31
- "expect": "30.2.0",
31
+ "expect": "30.4.1",
32
32
  "typescript": "^5.9.3",
33
33
  "@wisemen/eslint-config-nestjs": "1.1.1"
34
34
  },
@@ -1,11 +0,0 @@
1
- import { HasDefault } from './default.type.js';
2
- type OptionalKeys<T> = {
3
- [K in keyof T]: null extends T[K] ? K : HasDefault<T[K]> extends true ? K : never;
4
- }[keyof T];
5
- type RequiredKeys<T> = Exclude<keyof T, OptionalKeys<T>>;
6
- export type Insert<T> = {
7
- [K in RequiredKeys<T>]: T[K];
8
- } & {
9
- [K in OptionalKeys<T>]?: T[K];
10
- };
11
- export {};
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=insert.type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"insert.type.js","sourceRoot":"","sources":["../../lib/types/insert.type.ts"],"names":[],"mappings":""}