@zola_do/crud 0.2.8 → 0.2.12

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.
Files changed (64) hide show
  1. package/README.md +158 -68
  2. package/dist/controller/entity-crud.controller.js +8 -3
  3. package/dist/controller/entity-crud.controller.js.map +1 -1
  4. package/dist/controller/extra-crud.controller.js +5 -0
  5. package/dist/controller/extra-crud.controller.js.map +1 -1
  6. package/dist/controller/relation-crud.controller.js +3 -0
  7. package/dist/controller/relation-crud.controller.js.map +1 -1
  8. package/dist/crud-operation/repository/entity-crud.repository.d.ts +4 -4
  9. package/dist/crud-operation/repository/entity-crud.repository.js +29 -18
  10. package/dist/crud-operation/repository/entity-crud.repository.js.map +1 -1
  11. package/dist/crud-operation/repository/extra-crud.repository.d.ts +4 -4
  12. package/dist/crud-operation/repository/extra-crud.repository.js +28 -14
  13. package/dist/crud-operation/repository/extra-crud.repository.js.map +1 -1
  14. package/dist/crud-operation/repository/relation-crud.repository.js +4 -0
  15. package/dist/crud-operation/repository/relation-crud.repository.js.map +1 -1
  16. package/dist/crud-operation/service/relation-crud.service.js.map +1 -1
  17. package/dist/crud.module.d.ts +3 -0
  18. package/dist/crud.module.js +25 -0
  19. package/dist/crud.module.js.map +1 -0
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +1 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/service/entity-crud.service.d.ts +5 -4
  24. package/dist/service/entity-crud.service.js +72 -60
  25. package/dist/service/entity-crud.service.js.map +1 -1
  26. package/dist/service/extra-crud.service.d.ts +4 -3
  27. package/dist/service/extra-crud.service.js +45 -36
  28. package/dist/service/extra-crud.service.js.map +1 -1
  29. package/dist/service/relation-crud.service.d.ts +4 -3
  30. package/dist/service/relation-crud.service.js +23 -10
  31. package/dist/service/relation-crud.service.js.map +1 -1
  32. package/dist/shared/guards/crud-operation-disabled.guard.js.map +1 -1
  33. package/dist/shared/index.d.ts +2 -0
  34. package/dist/shared/index.js +2 -0
  35. package/dist/shared/index.js.map +1 -1
  36. package/dist/shared/interceptors/transaction-interceptor.d.ts +7 -2
  37. package/dist/shared/interceptors/transaction-interceptor.js +35 -6
  38. package/dist/shared/interceptors/transaction-interceptor.js.map +1 -1
  39. package/dist/shared/request-context/apply-create-context.helper.js +5 -12
  40. package/dist/shared/request-context/apply-create-context.helper.js.map +1 -1
  41. package/dist/shared/tokens/crud-transaction-context.token.d.ts +1 -0
  42. package/dist/shared/tokens/crud-transaction-context.token.js +5 -0
  43. package/dist/shared/tokens/crud-transaction-context.token.js.map +1 -0
  44. package/dist/shared/types/crud-option.type.d.ts +26 -39
  45. package/dist/shared/types/crud-transaction-context-hook.interface.d.ts +8 -0
  46. package/dist/shared/types/crud-transaction-context-hook.interface.js +3 -0
  47. package/dist/shared/types/crud-transaction-context-hook.interface.js.map +1 -0
  48. package/dist/shared/types/index.d.ts +1 -0
  49. package/dist/shared/types/index.js +1 -0
  50. package/dist/shared/types/index.js.map +1 -1
  51. package/dist/shared/utils/crud-hooks.helper.d.ts +7 -4
  52. package/dist/shared/utils/crud-hooks.helper.js +33 -11
  53. package/dist/shared/utils/crud-hooks.helper.js.map +1 -1
  54. package/dist/shared/utils/crud-transaction.decorators.d.ts +1 -0
  55. package/dist/shared/utils/crud-transaction.decorators.js +8 -0
  56. package/dist/shared/utils/crud-transaction.decorators.js.map +1 -0
  57. package/dist/shared/utils/cursor-query.helper.js.map +1 -1
  58. package/dist/shared/utils/index.d.ts +2 -0
  59. package/dist/shared/utils/index.js +2 -0
  60. package/dist/shared/utils/index.js.map +1 -1
  61. package/dist/shared/utils/transactional-repository.helper.d.ts +4 -0
  62. package/dist/shared/utils/transactional-repository.helper.js +23 -0
  63. package/dist/shared/utils/transactional-repository.helper.js.map +1 -0
  64. package/package.json +115 -112
@@ -0,0 +1,4 @@
1
+ import { EntityManager, ObjectLiteral, Repository } from 'typeorm';
2
+ export declare const resolveCrudRepository: <T extends ObjectLiteral>(repository: Repository<T>, req?: any) => Repository<T>;
3
+ export declare const isRequestTransactional: (req?: any) => boolean;
4
+ export declare const withCrudTransaction: <TResult>(repository: Repository<any>, req: any, work: (em: EntityManager) => Promise<TResult>) => Promise<TResult>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withCrudTransaction = exports.isRequestTransactional = exports.resolveCrudRepository = void 0;
4
+ const transaction_interceptor_1 = require("../interceptors/transaction-interceptor");
5
+ const resolveCrudRepository = (repository, req) => {
6
+ const manager = req === null || req === void 0 ? void 0 : req[transaction_interceptor_1.ENTITY_MANAGER_KEY];
7
+ if (manager) {
8
+ return manager.getRepository(repository.target);
9
+ }
10
+ return repository;
11
+ };
12
+ exports.resolveCrudRepository = resolveCrudRepository;
13
+ const isRequestTransactional = (req) => !!(req === null || req === void 0 ? void 0 : req[transaction_interceptor_1.ENTITY_MANAGER_KEY]);
14
+ exports.isRequestTransactional = isRequestTransactional;
15
+ const withCrudTransaction = async (repository, req, work) => {
16
+ const manager = req === null || req === void 0 ? void 0 : req[transaction_interceptor_1.ENTITY_MANAGER_KEY];
17
+ if (manager) {
18
+ return work(manager);
19
+ }
20
+ return repository.manager.transaction(work);
21
+ };
22
+ exports.withCrudTransaction = withCrudTransaction;
23
+ //# sourceMappingURL=transactional-repository.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactional-repository.helper.js","sourceRoot":"","sources":["../../../src/shared/utils/transactional-repository.helper.ts"],"names":[],"mappings":";;;AACA,qFAA6E;AAEtE,MAAM,qBAAqB,GAAG,CACnC,UAAyB,EACzB,GAAS,EACM,EAAE;IACjB,MAAM,OAAO,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAG,4CAAkB,CAAC,CAAC;IAC1C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,CAAkB,CAAC;IACnE,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AATW,QAAA,qBAAqB,yBAShC;AAEK,MAAM,sBAAsB,GAAG,CAAC,GAAS,EAAW,EAAE,CAC3D,CAAC,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAG,4CAAkB,CAAC,CAAA,CAAC;AADjB,QAAA,sBAAsB,0BACL;AAEvB,MAAM,mBAAmB,GAAG,KAAK,EACtC,UAA2B,EAC3B,GAAQ,EACR,IAA6C,EAC3B,EAAE;IACpB,MAAM,OAAO,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAG,4CAAkB,CAA8B,CAAC;IACvE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC,CAAC;AAVW,QAAA,mBAAmB,uBAU9B"}
package/package.json CHANGED
@@ -1,112 +1,115 @@
1
- {
2
- "name": "@zola_do/crud",
3
- "version": "0.2.8",
4
- "description": "Generic CRUD controllers and services for NestJS",
5
- "author": "zolaDO",
6
- "license": "ISC",
7
- "sideEffects": false,
8
- "engines": {
9
- "node": ">=20.0.0"
10
- },
11
- "publishConfig": {
12
- "access": "public"
13
- },
14
- "main": "./dist/index.js",
15
- "types": "./dist/index.d.ts",
16
- "exports": {
17
- ".": {
18
- "types": "./dist/index.d.ts",
19
- "require": "./dist/index.js",
20
- "default": "./dist/index.js"
21
- },
22
- "./controller": {
23
- "types": "./dist/controller/index.d.ts",
24
- "require": "./dist/controller/index.js",
25
- "default": "./dist/controller/index.js"
26
- },
27
- "./service": {
28
- "types": "./dist/service/index.d.ts",
29
- "require": "./dist/service/index.js",
30
- "default": "./dist/service/index.js"
31
- },
32
- "./repository": {
33
- "types": "./dist/repository/index.d.ts",
34
- "require": "./dist/repository/index.js",
35
- "default": "./dist/repository/index.js"
36
- },
37
- "./request-context": {
38
- "types": "./dist/request-context/index.d.ts",
39
- "require": "./dist/request-context/index.js",
40
- "default": "./dist/request-context/index.js"
41
- },
42
- "./optional/rpc": {
43
- "types": "./dist/optional/rpc.d.ts",
44
- "require": "./dist/optional/rpc.js",
45
- "default": "./dist/optional/rpc.js"
46
- }
47
- },
48
- "files": [
49
- "dist",
50
- "README.md"
51
- ],
52
- "scripts": {
53
- "clean": "rimraf dist",
54
- "typecheck": "tsc --noEmit",
55
- "build": "npm run clean && tsc",
56
- "prepublishOnly": "npm run build"
57
- },
58
- "peerDependencies": {
59
- "@nestjs/common": "^10.0.0 || ^11.0.0",
60
- "@nestjs/microservices": "^10.0.0 || ^11.0.0",
61
- "@nestjs/swagger": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
62
- "@nestjs/typeorm": "^10.0.0 || ^11.0.0",
63
- "class-validator": "^0.14.2 || ^0.15.1",
64
- "reflect-metadata": "^0.1.0 || ^0.2.0",
65
- "rxjs": "^7.0.0 || ^8.0.0",
66
- "typeorm": "^0.3.0",
67
- "typeorm-extension": "^3.7.1"
68
- },
69
- "peerDependenciesMeta": {
70
- "@nestjs/microservices": {
71
- "optional": true
72
- },
73
- "@nestjs/swagger": {
74
- "optional": true
75
- }
76
- },
77
- "dependencies": {
78
- "@zola_do/collection-query": "^0.2.7",
79
- "@zola_do/authorization": "^0.2.7"
80
- },
81
- "devDependencies": {
82
- "rimraf": "^6.1.3",
83
- "typescript": "^5.9.3"
84
- },
85
- "repository": {
86
- "directory": "packages/crud",
87
- "type": "git",
88
- "url": "https://github.com/zola0031/zola-nestjs-shared.git"
89
- },
90
- "homepage": "https://github.com/zola0031/zola-nestjs-shared#readme",
91
- "bugs": {
92
- "url": "https://github.com/zola0031/zola-nestjs-shared/issues"
93
- },
94
- "funding": {
95
- "type": "github",
96
- "url": "https://github.com/sponsors/zola0031"
97
- },
98
- "keywords": [
99
- "nestjs",
100
- "typescript",
101
- "library",
102
- "shared",
103
- "monorepo",
104
- "zola_do",
105
- "crud",
106
- "controller",
107
- "service",
108
- "repository",
109
- "typeorm",
110
- "nestjs-shared"
111
- ]
112
- }
1
+ {
2
+ "name": "@zola_do/crud",
3
+ "version": "0.2.12",
4
+ "description": "Generic CRUD controllers and services for NestJS",
5
+ "author": "zolaDO",
6
+ "license": "ISC",
7
+ "sideEffects": false,
8
+ "engines": {
9
+ "node": ">=20.0.0"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "require": "./dist/index.js",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "./controller": {
23
+ "types": "./dist/controller/index.d.ts",
24
+ "require": "./dist/controller/index.js",
25
+ "default": "./dist/controller/index.js"
26
+ },
27
+ "./service": {
28
+ "types": "./dist/service/index.d.ts",
29
+ "require": "./dist/service/index.js",
30
+ "default": "./dist/service/index.js"
31
+ },
32
+ "./repository": {
33
+ "types": "./dist/repository/index.d.ts",
34
+ "require": "./dist/repository/index.js",
35
+ "default": "./dist/repository/index.js"
36
+ },
37
+ "./request-context": {
38
+ "types": "./dist/request-context/index.d.ts",
39
+ "require": "./dist/request-context/index.js",
40
+ "default": "./dist/request-context/index.js"
41
+ },
42
+ "./optional/rpc": {
43
+ "types": "./dist/optional/rpc.d.ts",
44
+ "require": "./dist/optional/rpc.js",
45
+ "default": "./dist/optional/rpc.js"
46
+ }
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "README.md"
51
+ ],
52
+ "scripts": {
53
+ "clean": "rimraf dist",
54
+ "typecheck": "tsc --noEmit",
55
+ "build": "npm run clean && tsc",
56
+ "prepublishOnly": "npm run build"
57
+ },
58
+ "peerDependencies": {
59
+ "@nestjs/common": "^10.0.0 || ^11.0.0",
60
+ "@nestjs/microservices": "^10.0.0 || ^11.0.0",
61
+ "@nestjs/swagger": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
62
+ "@nestjs/typeorm": "^10.0.0 || ^11.0.1",
63
+ "class-validator": "^0.14.2 || ^0.15.1",
64
+ "reflect-metadata": "^0.1.0 || ^0.2.0",
65
+ "rxjs": "^7.0.0 || ^8.0.0",
66
+ "typeorm": "^0.3.0 || ^1.0.0",
67
+ "typeorm-extension": "^3.7.1"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "@nestjs/microservices": {
71
+ "optional": true
72
+ },
73
+ "@nestjs/swagger": {
74
+ "optional": true
75
+ },
76
+ "typeorm-extension": {
77
+ "optional": true
78
+ }
79
+ },
80
+ "dependencies": {
81
+ "@zola_do/collection-query": "^0.2.7",
82
+ "@zola_do/authorization": "^0.2.7"
83
+ },
84
+ "devDependencies": {
85
+ "rimraf": "^6.1.3",
86
+ "typescript": "^5.9.3"
87
+ },
88
+ "repository": {
89
+ "directory": "packages/crud",
90
+ "type": "git",
91
+ "url": "https://github.com/zola0031/zola-nestjs-shared.git"
92
+ },
93
+ "homepage": "https://github.com/zola0031/zola-nestjs-shared#readme",
94
+ "bugs": {
95
+ "url": "https://github.com/zola0031/zola-nestjs-shared/issues"
96
+ },
97
+ "funding": {
98
+ "type": "github",
99
+ "url": "https://github.com/sponsors/zola0031"
100
+ },
101
+ "keywords": [
102
+ "nestjs",
103
+ "typescript",
104
+ "library",
105
+ "shared",
106
+ "monorepo",
107
+ "zola_do",
108
+ "crud",
109
+ "controller",
110
+ "service",
111
+ "repository",
112
+ "typeorm",
113
+ "nestjs-shared"
114
+ ]
115
+ }