@zola_do/crud 0.1.9

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 (67) hide show
  1. package/dist/controller/entity-crud.controller.d.ts +16 -0
  2. package/dist/controller/entity-crud.controller.js +139 -0
  3. package/dist/controller/entity-crud.controller.js.map +1 -0
  4. package/dist/controller/extra-crud.controller.d.ts +18 -0
  5. package/dist/controller/extra-crud.controller.js +145 -0
  6. package/dist/controller/extra-crud.controller.js.map +1 -0
  7. package/dist/controller/index.d.ts +3 -0
  8. package/dist/controller/index.js +20 -0
  9. package/dist/controller/index.js.map +1 -0
  10. package/dist/controller/relation-crud.controller.d.ts +13 -0
  11. package/dist/controller/relation-crud.controller.js +101 -0
  12. package/dist/controller/relation-crud.controller.js.map +1 -0
  13. package/dist/crud-operation/controller/entity-crud.controller.d.ts +16 -0
  14. package/dist/crud-operation/controller/entity-crud.controller.js +136 -0
  15. package/dist/crud-operation/controller/entity-crud.controller.js.map +1 -0
  16. package/dist/crud-operation/controller/extra-crud.controller.d.ts +18 -0
  17. package/dist/crud-operation/controller/extra-crud.controller.js +142 -0
  18. package/dist/crud-operation/controller/extra-crud.controller.js.map +1 -0
  19. package/dist/crud-operation/controller/index.d.ts +3 -0
  20. package/dist/crud-operation/controller/index.js +20 -0
  21. package/dist/crud-operation/controller/index.js.map +1 -0
  22. package/dist/crud-operation/controller/relation-crud.controller.d.ts +13 -0
  23. package/dist/crud-operation/controller/relation-crud.controller.js +103 -0
  24. package/dist/crud-operation/controller/relation-crud.controller.js.map +1 -0
  25. package/dist/crud-operation/index.d.ts +3 -0
  26. package/dist/crud-operation/index.js +20 -0
  27. package/dist/crud-operation/index.js.map +1 -0
  28. package/dist/crud-operation/repository/entity-crud.repository.d.ts +18 -0
  29. package/dist/crud-operation/repository/entity-crud.repository.js +124 -0
  30. package/dist/crud-operation/repository/entity-crud.repository.js.map +1 -0
  31. package/dist/crud-operation/repository/extra-crud.repository.d.ts +20 -0
  32. package/dist/crud-operation/repository/extra-crud.repository.js +129 -0
  33. package/dist/crud-operation/repository/extra-crud.repository.js.map +1 -0
  34. package/dist/crud-operation/repository/index.d.ts +3 -0
  35. package/dist/crud-operation/repository/index.js +20 -0
  36. package/dist/crud-operation/repository/index.js.map +1 -0
  37. package/dist/crud-operation/repository/relation-crud.repository.d.ts +13 -0
  38. package/dist/crud-operation/repository/relation-crud.repository.js +116 -0
  39. package/dist/crud-operation/repository/relation-crud.repository.js.map +1 -0
  40. package/dist/crud-operation/service/entity-crud.service.d.ts +15 -0
  41. package/dist/crud-operation/service/entity-crud.service.js +49 -0
  42. package/dist/crud-operation/service/entity-crud.service.js.map +1 -0
  43. package/dist/crud-operation/service/extra-crud.service.d.ts +18 -0
  44. package/dist/crud-operation/service/extra-crud.service.js +55 -0
  45. package/dist/crud-operation/service/extra-crud.service.js.map +1 -0
  46. package/dist/crud-operation/service/index.d.ts +3 -0
  47. package/dist/crud-operation/service/index.js +20 -0
  48. package/dist/crud-operation/service/index.js.map +1 -0
  49. package/dist/crud-operation/service/relation-crud.service.d.ts +12 -0
  50. package/dist/crud-operation/service/relation-crud.service.js +37 -0
  51. package/dist/crud-operation/service/relation-crud.service.js.map +1 -0
  52. package/dist/index.d.ts +3 -0
  53. package/dist/index.js +20 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/service/entity-crud.service.d.ts +17 -0
  56. package/dist/service/entity-crud.service.js +115 -0
  57. package/dist/service/entity-crud.service.js.map +1 -0
  58. package/dist/service/extra-crud.service.d.ts +18 -0
  59. package/dist/service/extra-crud.service.js +128 -0
  60. package/dist/service/extra-crud.service.js.map +1 -0
  61. package/dist/service/index.d.ts +3 -0
  62. package/dist/service/index.js +20 -0
  63. package/dist/service/index.js.map +1 -0
  64. package/dist/service/relation-crud.service.d.ts +13 -0
  65. package/dist/service/relation-crud.service.js +102 -0
  66. package/dist/service/relation-crud.service.js.map +1 -0
  67. package/package.json +44 -0
@@ -0,0 +1,16 @@
1
+ import { EntityCrudService } from '../service';
2
+ import { DeepPartial, ObjectLiteral } from 'typeorm';
3
+ import { DataResponseFormat } from '@zola_do/core';
4
+ import { EntityCrudOptions } from '@zola_do/core';
5
+ export declare function EntityCrudController<TEntity extends ObjectLiteral>(options?: EntityCrudOptions): {
6
+ new (service: EntityCrudService<TEntity>): {
7
+ readonly service: EntityCrudService<TEntity>;
8
+ create(itemData: DeepPartial<TEntity>, req?: any): Promise<TEntity>;
9
+ findAll(q?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
10
+ findOne(id: string, req?: any): Promise<TEntity | undefined>;
11
+ update(id: string, itemData: Partial<TEntity>, req?: any): Promise<TEntity | undefined>;
12
+ softDelete(id: string, req?: any): Promise<void>;
13
+ restore(id: string, req?: any): Promise<void>;
14
+ findAllArchived(q?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
15
+ };
16
+ };
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.EntityCrudController = EntityCrudController;
16
+ const common_1 = require("@nestjs/common");
17
+ const service_1 = require("../service");
18
+ const typeorm_1 = require("typeorm");
19
+ const swagger_1 = require("@nestjs/swagger");
20
+ const extra_crud_controller_1 = require("./extra-crud.controller");
21
+ const collection_query_1 = require("@zola_do/collection-query");
22
+ const authorization_1 = require("@zola_do/authorization");
23
+ function EntityCrudController(options) {
24
+ var _a;
25
+ let EntityCrudControllerHost = class EntityCrudControllerHost {
26
+ constructor(service) {
27
+ this.service = service;
28
+ }
29
+ async create(itemData, req) {
30
+ return await this.service.create(itemData, req);
31
+ }
32
+ async findAll(q, req) {
33
+ const query = (0, collection_query_1.decodeCollectionQuery)(q);
34
+ return await this.service.findAll(query, req);
35
+ }
36
+ async findOne(id, req) {
37
+ return await this.service.findOne(id, req);
38
+ }
39
+ async update(id, itemData, req) {
40
+ return await this.service.update(id, itemData);
41
+ }
42
+ async softDelete(id, req) {
43
+ return this.service.softDelete(id, req);
44
+ }
45
+ async restore(id, req) {
46
+ return this.service.restore(id, req);
47
+ }
48
+ async findAllArchived(q, req) {
49
+ const query = (0, collection_query_1.decodeCollectionQuery)(q);
50
+ return this.service.findAllArchived(query, req);
51
+ }
52
+ };
53
+ __decorate([
54
+ (0, common_1.Post)(),
55
+ (0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.createDto) || extra_crud_controller_1.BaseAPIDto }),
56
+ (0, common_1.UseGuards)(authorization_1.JwtGuard, (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.createPermission)),
57
+ __param(0, (0, common_1.Body)()),
58
+ __param(1, (0, common_1.Req)()),
59
+ __metadata("design:type", Function),
60
+ __metadata("design:paramtypes", [typeof (_a = typeof typeorm_1.DeepPartial !== "undefined" && typeorm_1.DeepPartial) === "function" ? _a : Object, Object]),
61
+ __metadata("design:returntype", Promise)
62
+ ], EntityCrudControllerHost.prototype, "create", null);
63
+ __decorate([
64
+ (0, common_1.Get)(),
65
+ (0, swagger_1.ApiQuery)({
66
+ name: 'q',
67
+ type: String,
68
+ description: 'Collection Query Parameter. Optional',
69
+ required: false,
70
+ }),
71
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewPermission)),
72
+ __param(0, (0, common_1.Query)('q')),
73
+ __param(1, (0, common_1.Req)()),
74
+ __metadata("design:type", Function),
75
+ __metadata("design:paramtypes", [String, Object]),
76
+ __metadata("design:returntype", Promise)
77
+ ], EntityCrudControllerHost.prototype, "findAll", null);
78
+ __decorate([
79
+ (0, common_1.Get)(':id'),
80
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewPermission)),
81
+ __param(0, (0, common_1.Param)('id')),
82
+ __param(1, (0, common_1.Req)()),
83
+ __metadata("design:type", Function),
84
+ __metadata("design:paramtypes", [String, Object]),
85
+ __metadata("design:returntype", Promise)
86
+ ], EntityCrudControllerHost.prototype, "findOne", null);
87
+ __decorate([
88
+ (0, common_1.Put)(':id'),
89
+ (0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.updateDto) || extra_crud_controller_1.BaseAPIDto }),
90
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.updatePermission)),
91
+ __param(0, (0, common_1.Param)('id')),
92
+ __param(1, (0, common_1.Body)()),
93
+ __param(2, (0, common_1.Req)()),
94
+ __metadata("design:type", Function),
95
+ __metadata("design:paramtypes", [String, Object, Object]),
96
+ __metadata("design:returntype", Promise)
97
+ ], EntityCrudControllerHost.prototype, "update", null);
98
+ __decorate([
99
+ (0, common_1.Delete)(':id'),
100
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.deletePermission)),
101
+ __param(0, (0, common_1.Param)('id')),
102
+ __param(1, (0, common_1.Req)()),
103
+ __metadata("design:type", Function),
104
+ __metadata("design:paramtypes", [String, Object]),
105
+ __metadata("design:returntype", Promise)
106
+ ], EntityCrudControllerHost.prototype, "softDelete", null);
107
+ __decorate([
108
+ (0, common_1.Patch)('restore/:id'),
109
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.restorePermission)),
110
+ __param(0, (0, common_1.Param)('id')),
111
+ __param(1, (0, common_1.Req)()),
112
+ __metadata("design:type", Function),
113
+ __metadata("design:paramtypes", [String, Object]),
114
+ __metadata("design:returntype", Promise)
115
+ ], EntityCrudControllerHost.prototype, "restore", null);
116
+ __decorate([
117
+ (0, common_1.Get)('/archived/items'),
118
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewArchivedPermission)),
119
+ (0, swagger_1.ApiQuery)({
120
+ name: 'q',
121
+ type: String,
122
+ description: 'Collection Query Parameter. Optional',
123
+ required: false,
124
+ }),
125
+ __param(0, (0, common_1.Query)('q')),
126
+ __param(1, (0, common_1.Req)()),
127
+ __metadata("design:type", Function),
128
+ __metadata("design:paramtypes", [String, Object]),
129
+ __metadata("design:returntype", Promise)
130
+ ], EntityCrudControllerHost.prototype, "findAllArchived", null);
131
+ EntityCrudControllerHost = __decorate([
132
+ (0, common_1.Controller)(),
133
+ (0, common_1.UseInterceptors)(),
134
+ (0, swagger_1.ApiBearerAuth)(),
135
+ __metadata("design:paramtypes", [service_1.EntityCrudService])
136
+ ], EntityCrudControllerHost);
137
+ return EntityCrudControllerHost;
138
+ }
139
+ //# sourceMappingURL=entity-crud.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-crud.controller.js","sourceRoot":"","sources":["../../src/controller/entity-crud.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAuBA,oDAqFC;AA5GD,2CAawB;AACxB,wCAA+C;AAC/C,qCAAqD;AAErD,6CAAmE;AACnE,mEAAqD;AAErD,gEAAkE;AAClE,0DAAoE;AAEpE,SAAgB,oBAAoB,CAClC,OAA2B;;IAE3B,IAGM,wBAAwB,GAH9B,MAGM,wBAAwB;QAC5B,YAA4B,OAAmC;YAAnC,YAAO,GAAP,OAAO,CAA4B;QAAG,CAAC;QAK7D,AAAN,KAAK,CA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A,aAAI,GAAE,CAAA;QACN,WAAA,IAAA,YAAG,GAAE,CAAA;;;;0DAGP;IAIK;QAFL,IAAA,eAAM,EAAC,KAAK,CAAC;QACb,IAAA,kBAAS,EAAC,IAAA,gCAAgB,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,CAAC,CAAC;QACrC,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;QAAc,WAAA,IAAA,YAAG,GAAE,CAAA;;;;8DAE/C;IAIK;QAFL,IAAA,cAAK,EAAC,aAAa,CAAC;QACpB,IAAA,kBAAS,EAAC,IAAA,gCAAgB,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,CAAC,CAAC;QACzC,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;QAAc,WAAA,IAAA,YAAG,GAAE,CAAA;;;;2DAE5C;IAUK;QARL,IAAA,YAAG,EAAC,iBAAiB,CAAC;QACtB,IAAA,kBAAS,EAAC,IAAA,gCAAgB,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,sBAAsB,CAAC,CAAC;QAC5D,IAAA,kBAAQ,EAAC;YACR,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,KAAK;SAChB,CAAC;QAEC,WAAA,IAAA,cAAK,EAAC,GAAG,CAAC,CAAA;QACV,WAAA,IAAA,YAAG,GAAE,CAAA;;;;mEAIP;IA3EG,wBAAwB;QAH7B,IAAA,mBAAU,GAAE;QACZ,IAAA,wBAAe,GAAgC;QAC/C,IAAA,uBAAa,GAAE;yCAEuB,2BAAiB;OADlD,wBAAwB,CA4E7B;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { DeepPartial, ObjectLiteral } from 'typeorm';
2
+ import { DataResponseFormat } from '@zola_do/core';
3
+ import { ExtraCrudService } from '../service';
4
+ import { ExtraCrudOptions } from '@zola_do/core';
5
+ export declare class BaseAPIDto {
6
+ }
7
+ export declare function ExtraCrudController<TEntity extends ObjectLiteral>(options: ExtraCrudOptions): {
8
+ new (service: ExtraCrudService<TEntity>): {
9
+ readonly service: ExtraCrudService<TEntity>;
10
+ create(itemData: DeepPartial<TEntity>, req?: any): Promise<TEntity>;
11
+ findAll(id: string, q: string, req?: any): Promise<DataResponseFormat<TEntity>>;
12
+ findOne(id: string, req?: any): Promise<TEntity | undefined>;
13
+ update(id: string, itemData: Partial<TEntity>, req?: any): Promise<TEntity | undefined>;
14
+ softDelete(id: string, req?: any): Promise<void>;
15
+ restore(id: string, req?: any): Promise<void>;
16
+ findAllArchived(id: string, q?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
17
+ };
18
+ };
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.BaseAPIDto = void 0;
16
+ exports.ExtraCrudController = ExtraCrudController;
17
+ const common_1 = require("@nestjs/common");
18
+ const typeorm_1 = require("typeorm");
19
+ const service_1 = require("../service");
20
+ const swagger_1 = require("@nestjs/swagger");
21
+ const collection_query_1 = require("@zola_do/collection-query");
22
+ const authorization_1 = require("@zola_do/authorization");
23
+ class BaseAPIDto {
24
+ }
25
+ exports.BaseAPIDto = BaseAPIDto;
26
+ function ExtraCrudController(options) {
27
+ var _a;
28
+ const { createDto, updateDto } = options;
29
+ let ExtraCrudControllerHost = class ExtraCrudControllerHost {
30
+ constructor(service) {
31
+ this.service = service;
32
+ }
33
+ async create(itemData, req) {
34
+ return await this.service.create(itemData, req);
35
+ }
36
+ async findAll(id, q, req) {
37
+ const query = (0, collection_query_1.decodeCollectionQuery)(q);
38
+ return await this.service.findAll(id, query, options, req);
39
+ }
40
+ async findOne(id, req) {
41
+ return await this.service.findOne(id, req);
42
+ }
43
+ async update(id, itemData, req) {
44
+ return await this.service.update(id, itemData);
45
+ }
46
+ async softDelete(id, req) {
47
+ return await this.service.softDelete(id, req);
48
+ }
49
+ async restore(id, req) {
50
+ return await this.service.restore(id, req);
51
+ }
52
+ async findAllArchived(id, q, req) {
53
+ const query = (0, collection_query_1.decodeCollectionQuery)(q);
54
+ return await this.service.findAllArchived(id, query, options, req);
55
+ }
56
+ };
57
+ __decorate([
58
+ (0, common_1.Post)(),
59
+ (0, swagger_1.ApiBody)({ type: createDto || BaseAPIDto }),
60
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.createPermission)),
61
+ __param(0, (0, common_1.Body)()),
62
+ __param(1, (0, common_1.Req)()),
63
+ __metadata("design:type", Function),
64
+ __metadata("design:paramtypes", [typeof (_a = typeof typeorm_1.DeepPartial !== "undefined" && typeorm_1.DeepPartial) === "function" ? _a : Object, Object]),
65
+ __metadata("design:returntype", Promise)
66
+ ], ExtraCrudControllerHost.prototype, "create", null);
67
+ __decorate([
68
+ (0, common_1.Get)('list/:id'),
69
+ (0, swagger_1.ApiQuery)({
70
+ name: 'q',
71
+ type: String,
72
+ description: 'Collection Query Parameter. Optional',
73
+ required: false,
74
+ }),
75
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.viewPermission)),
76
+ __param(0, (0, common_1.Param)('id')),
77
+ __param(1, (0, common_1.Query)('q')),
78
+ __param(2, (0, common_1.Req)()),
79
+ __metadata("design:type", Function),
80
+ __metadata("design:paramtypes", [String, String, Object]),
81
+ __metadata("design:returntype", Promise)
82
+ ], ExtraCrudControllerHost.prototype, "findAll", null);
83
+ __decorate([
84
+ (0, common_1.Get)(':id'),
85
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.viewPermission)),
86
+ __param(0, (0, common_1.Param)('id')),
87
+ __param(1, (0, common_1.Req)()),
88
+ __metadata("design:type", Function),
89
+ __metadata("design:paramtypes", [String, Object]),
90
+ __metadata("design:returntype", Promise)
91
+ ], ExtraCrudControllerHost.prototype, "findOne", null);
92
+ __decorate([
93
+ (0, common_1.Put)(':id'),
94
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.updatePermission)),
95
+ (0, swagger_1.ApiBody)({ type: updateDto || BaseAPIDto }),
96
+ __param(0, (0, common_1.Param)('id')),
97
+ __param(1, (0, common_1.Body)()),
98
+ __param(2, (0, common_1.Req)()),
99
+ __metadata("design:type", Function),
100
+ __metadata("design:paramtypes", [String, Object, Object]),
101
+ __metadata("design:returntype", Promise)
102
+ ], ExtraCrudControllerHost.prototype, "update", null);
103
+ __decorate([
104
+ (0, common_1.Delete)(':id'),
105
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.deletePermission)),
106
+ __param(0, (0, common_1.Param)('id')),
107
+ __param(1, (0, common_1.Req)()),
108
+ __metadata("design:type", Function),
109
+ __metadata("design:paramtypes", [String, Object]),
110
+ __metadata("design:returntype", Promise)
111
+ ], ExtraCrudControllerHost.prototype, "softDelete", null);
112
+ __decorate([
113
+ (0, common_1.Patch)('restore/:id'),
114
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.restorePermission)),
115
+ __param(0, (0, common_1.Param)('id')),
116
+ __param(1, (0, common_1.Req)()),
117
+ __metadata("design:type", Function),
118
+ __metadata("design:paramtypes", [String, Object]),
119
+ __metadata("design:returntype", Promise)
120
+ ], ExtraCrudControllerHost.prototype, "restore", null);
121
+ __decorate([
122
+ (0, common_1.Get)('list/archived/items/:id'),
123
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.viewArchivedPermission)),
124
+ (0, swagger_1.ApiQuery)({
125
+ name: 'q',
126
+ type: String,
127
+ description: 'Collection Query Parameter. Optional',
128
+ required: false,
129
+ }),
130
+ __param(0, (0, common_1.Param)('id')),
131
+ __param(1, (0, common_1.Query)('q')),
132
+ __param(2, (0, common_1.Req)()),
133
+ __metadata("design:type", Function),
134
+ __metadata("design:paramtypes", [String, String, Object]),
135
+ __metadata("design:returntype", Promise)
136
+ ], ExtraCrudControllerHost.prototype, "findAllArchived", null);
137
+ ExtraCrudControllerHost = __decorate([
138
+ (0, common_1.Controller)(),
139
+ (0, common_1.UseInterceptors)(),
140
+ (0, swagger_1.ApiBearerAuth)(),
141
+ __metadata("design:paramtypes", [service_1.ExtraCrudService])
142
+ ], ExtraCrudControllerHost);
143
+ return ExtraCrudControllerHost;
144
+ }
145
+ //# sourceMappingURL=extra-crud.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extra-crud.controller.js","sourceRoot":"","sources":["../../src/controller/extra-crud.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAwBA,kDAyFC;AAjHD,2CAawB;AACxB,qCAAqD;AAErD,wCAA8C;AAC9C,6CAAmE;AAEnE,gEAAkE;AAClE,0DAA0D;AAE1D,MAAa,UAAU;CAAG;AAA1B,gCAA0B;AAE1B,SAAgB,mBAAmB,CACjC,OAAyB;;IAEzB,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEzC,IAGM,uBAAuB,GAH7B,MAGM,uBAAuB;QAC3B,YAA4B,OAAkC;YAAlC,YAAO,GAAP,OAAO,CAA2B;QAAG,CAAC;QAK5D,AAAN,KAAK,CAAC,MAAM,CACF,QAA8B,EAC/B,GA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AAM,EAAC,KAAK,CAAC;QACb,IAAA,kBAAS,EAAC,IAAA,gCAAgB,EAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACpC,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;QAAc,WAAA,IAAA,YAAG,GAAE,CAAA;;;;6DAE/C;IAIK;QAFL,IAAA,cAAK,EAAC,aAAa,CAAC;QACpB,IAAA,kBAAS,EAAC,IAAA,gCAAgB,EAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACxC,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;QAAc,WAAA,IAAA,YAAG,GAAE,CAAA;;;;0DAE5C;IAUK;QARL,IAAA,YAAG,EAAC,yBAAyB,CAAC;QAC9B,IAAA,kBAAS,EAAC,IAAA,gCAAgB,EAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAC3D,IAAA,kBAAQ,EAAC;YACR,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,KAAK;SAChB,CAAC;QAEC,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;QACX,WAAA,IAAA,cAAK,EAAC,GAAG,CAAC,CAAA;QACV,WAAA,IAAA,YAAG,GAAE,CAAA;;;;kEAIP;IA7EG,uBAAuB;QAH5B,IAAA,mBAAU,GAAE;QACZ,IAAA,wBAAe,GAAgC;QAC/C,IAAA,uBAAa,GAAE;yCAEuB,0BAAgB;OADjD,uBAAuB,CA8E5B;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './entity-crud.controller';
2
+ export * from './relation-crud.controller';
3
+ export * from './extra-crud.controller';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./entity-crud.controller"), exports);
18
+ __exportStar(require("./relation-crud.controller"), exports);
19
+ __exportStar(require("./extra-crud.controller"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controller/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,6DAA2C;AAC3C,0DAAwC"}
@@ -0,0 +1,13 @@
1
+ import { DataResponseFormat } from '@zola_do/core';
2
+ import { RelationCrudService } from '../service';
3
+ import { RelationCrudOptions } from '@zola_do/core';
4
+ import { ObjectLiteral } from 'typeorm';
5
+ export declare function RelationCrudController<TEntity extends ObjectLiteral>(options: RelationCrudOptions): {
6
+ new (service: RelationCrudService<TEntity>): {
7
+ readonly service: RelationCrudService<TEntity>;
8
+ bulkSaveFirst(itemData: any, req?: any): Promise<any>;
9
+ bulkSaveSecond(itemData: any, req?: any): Promise<any>;
10
+ findAllFirst(id: string, q: string, req?: any): Promise<DataResponseFormat<TEntity>>;
11
+ findAllSecond(id: string, q: string, req?: any): Promise<DataResponseFormat<TEntity>>;
12
+ };
13
+ };
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.RelationCrudController = RelationCrudController;
16
+ const common_1 = require("@nestjs/common");
17
+ const service_1 = require("../service");
18
+ const extra_crud_controller_1 = require("./extra-crud.controller");
19
+ const swagger_1 = require("@nestjs/swagger");
20
+ const collection_query_1 = require("@zola_do/collection-query");
21
+ const authorization_1 = require("@zola_do/authorization");
22
+ function RelationCrudController(options) {
23
+ const { firstEntityIdName, firstInclude = 'first', secondEntityIdName, secondInclude = 'second', assignFirstDto, assignSecondDto, } = options;
24
+ let RelationCrudControllerHost = class RelationCrudControllerHost {
25
+ constructor(service) {
26
+ this.service = service;
27
+ }
28
+ async bulkSaveFirst(itemData, req) {
29
+ return await this.service.bulkSaveFirst(itemData, options);
30
+ }
31
+ async bulkSaveSecond(itemData, req) {
32
+ return await this.service.bulkSaveSecond(itemData, options);
33
+ }
34
+ async findAllFirst(id, q, req) {
35
+ const query = (0, collection_query_1.decodeCollectionQuery)(q);
36
+ return await this.service.findAllFirst(id, query, options);
37
+ }
38
+ async findAllSecond(id, q, req) {
39
+ const query = (0, collection_query_1.decodeCollectionQuery)(q);
40
+ return await this.service.findAllSecond(id, query, options);
41
+ }
42
+ };
43
+ __decorate([
44
+ (0, common_1.Post)(`assign-${firstInclude}`),
45
+ (0, swagger_1.ApiBody)({ type: assignFirstDto || extra_crud_controller_1.BaseAPIDto }),
46
+ __param(0, (0, common_1.Body)()),
47
+ __param(1, (0, common_1.Req)()),
48
+ __metadata("design:type", Function),
49
+ __metadata("design:paramtypes", [Object, Object]),
50
+ __metadata("design:returntype", Promise)
51
+ ], RelationCrudControllerHost.prototype, "bulkSaveFirst", null);
52
+ __decorate([
53
+ (0, common_1.Post)(`assign-${secondInclude}`),
54
+ (0, swagger_1.ApiBody)({ type: assignSecondDto || extra_crud_controller_1.BaseAPIDto }),
55
+ __param(0, (0, common_1.Body)()),
56
+ __param(1, (0, common_1.Req)()),
57
+ __metadata("design:type", Function),
58
+ __metadata("design:paramtypes", [Object, Object]),
59
+ __metadata("design:returntype", Promise)
60
+ ], RelationCrudControllerHost.prototype, "bulkSaveSecond", null);
61
+ __decorate([
62
+ (0, common_1.Get)(`:id/${firstInclude}`),
63
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.viewPermission)),
64
+ (0, swagger_1.ApiQuery)({
65
+ name: 'q',
66
+ type: String,
67
+ description: 'Collection Query Parameter. Optional',
68
+ required: false,
69
+ }),
70
+ __param(0, (0, common_1.Param)('id')),
71
+ __param(1, (0, common_1.Query)('q')),
72
+ __param(2, (0, common_1.Req)()),
73
+ __metadata("design:type", Function),
74
+ __metadata("design:paramtypes", [String, String, Object]),
75
+ __metadata("design:returntype", Promise)
76
+ ], RelationCrudControllerHost.prototype, "findAllFirst", null);
77
+ __decorate([
78
+ (0, common_1.Get)(`:id/${secondInclude}`),
79
+ (0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.viewPermission)),
80
+ (0, swagger_1.ApiQuery)({
81
+ name: 'q',
82
+ type: String,
83
+ description: 'Collection Query Parameter. Optional',
84
+ required: false,
85
+ }),
86
+ __param(0, (0, common_1.Param)('id')),
87
+ __param(1, (0, common_1.Query)('q')),
88
+ __param(2, (0, common_1.Req)()),
89
+ __metadata("design:type", Function),
90
+ __metadata("design:paramtypes", [String, String, Object]),
91
+ __metadata("design:returntype", Promise)
92
+ ], RelationCrudControllerHost.prototype, "findAllSecond", null);
93
+ RelationCrudControllerHost = __decorate([
94
+ (0, common_1.Controller)(),
95
+ (0, common_1.UseInterceptors)(),
96
+ (0, swagger_1.ApiBearerAuth)(),
97
+ __metadata("design:paramtypes", [service_1.RelationCrudService])
98
+ ], RelationCrudControllerHost);
99
+ return RelationCrudControllerHost;
100
+ }
101
+ //# sourceMappingURL=relation-crud.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relation-crud.controller.js","sourceRoot":"","sources":["../../src/controller/relation-crud.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAoBA,wDAqEC;AAzFD,2CAUwB;AAExB,wCAAiD;AACjD,mEAAqD;AACrD,6CAAmE;AAGnE,gEAAkE;AAClE,0DAA0D;AAE1D,SAAgB,sBAAsB,CACpC,OAA4B;IAE5B,MAAM,EACJ,iBAAiB,EACjB,YAAY,GAAG,OAAO,EACtB,kBAAkB,EAClB,aAAa,GAAG,QAAQ,EACxB,cAAc,EACd,eAAe,GAChB,GAAG,OAAO,CAAC;IAEZ,IAGM,0BAA0B,GAHhC,MAGM,0BAA0B;QAC9B,YAA4B,OAAqC;YAArC,YAAO,GAAP,OAAO,CAA8B;QAAG,CAAC;QAI/D,AAAN,KAAK,CAAC,aAAa,CAAS,QAAa,EAAS,GAAS;YACzD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC;QAIK,AAAN,KAAK,CAAC,cAAc,CACV,QAAa,EACd,GAAS;YAEhB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9D,CAAC;QAUK,AAAN,KAAK,CAAC,YAAY,CACH,EAAU,EACX,CAAS,EACd,GAAS;YAEhB,MAAM,KAAK,GAAG,IAAA,wCAAqB,EAAC,CAAC,CAAC,CAAC;YACvC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,E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,OAAO,CAAC,cAAc,CAAC,CAAC;QACnD,IAAA,kBAAQ,EAAC;YACR,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,KAAK;SAChB,CAAC;QAEC,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;QACX,WAAA,IAAA,cAAK,EAAC,GAAG,CAAC,CAAA;QACV,WAAA,IAAA,YAAG,GAAE,CAAA;;;;mEAIP;IAlDG,0BAA0B;QAH/B,IAAA,mBAAU,GAAE;QACZ,IAAA,wBAAe,GAAgC;QAC/C,IAAA,uBAAa,GAAE;yCAEuB,6BAAmB;OADpD,0BAA0B,CAmD/B;IAED,OAAO,0BAA0B,CAAC;AACpC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { EntityCrudService } from '../service';
2
+ import { DeepPartial, ObjectLiteral } from 'typeorm';
3
+ import { DataResponseFormat } from '@zola_do/core';
4
+ import { EntityCrudOptions } from '@zola_do/core';
5
+ export declare function EntityCrudController<TEntity extends ObjectLiteral>(options?: EntityCrudOptions): {
6
+ new (service: EntityCrudService<TEntity>): {
7
+ readonly service: EntityCrudService<TEntity>;
8
+ create(itemData: DeepPartial<TEntity>, req?: any): Promise<TEntity>;
9
+ findAll(q?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
10
+ findOne(id: string, req?: any): Promise<TEntity | undefined>;
11
+ update(id: string, itemData: Partial<TEntity>, req?: any): Promise<TEntity | undefined>;
12
+ softDelete(id: string, req?: any): Promise<void>;
13
+ restore(id: string, req?: any): Promise<void>;
14
+ findAllArchived(q?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
15
+ };
16
+ };
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.EntityCrudController = EntityCrudController;
16
+ const common_1 = require("@nestjs/common");
17
+ const service_1 = require("../service");
18
+ const typeorm_1 = require("typeorm");
19
+ const swagger_1 = require("@nestjs/swagger");
20
+ const extra_crud_controller_1 = require("./extra-crud.controller");
21
+ const collection_query_1 = require("@zola_do/collection-query");
22
+ const core_1 = require("@zola_do/core");
23
+ function EntityCrudController(options) {
24
+ var _a;
25
+ let EntityCrudControllerHost = class EntityCrudControllerHost {
26
+ constructor(service) {
27
+ this.service = service;
28
+ }
29
+ async create(itemData, req) {
30
+ if (options === null || options === void 0 ? void 0 : options.createDto)
31
+ await (0, core_1.validateDto)(options.createDto, itemData);
32
+ return this.service.create(itemData, req);
33
+ }
34
+ async findAll(q, req) {
35
+ const query = (0, collection_query_1.decodeCollectionQuery)(q);
36
+ return this.service.findAll(query, req);
37
+ }
38
+ async findOne(id, req) {
39
+ return this.service.findOne(id, req);
40
+ }
41
+ async update(id, itemData, req) {
42
+ if (options === null || options === void 0 ? void 0 : options.updateDto)
43
+ await (0, core_1.validateDto)(options.updateDto, itemData);
44
+ return this.service.update(id, itemData);
45
+ }
46
+ async softDelete(id, req) {
47
+ return this.service.softDelete(id, req);
48
+ }
49
+ async restore(id, req) {
50
+ return this.service.restore(id, req);
51
+ }
52
+ async findAllArchived(q, req) {
53
+ const query = (0, collection_query_1.decodeCollectionQuery)(q);
54
+ return this.service.findAllArchived(query, req);
55
+ }
56
+ };
57
+ __decorate([
58
+ (0, common_1.Post)(),
59
+ (0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.createDto) || extra_crud_controller_1.BaseAPIDto }),
60
+ __param(0, (0, common_1.Body)()),
61
+ __param(1, (0, common_1.Req)()),
62
+ __metadata("design:type", Function),
63
+ __metadata("design:paramtypes", [typeof (_a = typeof typeorm_1.DeepPartial !== "undefined" && typeorm_1.DeepPartial) === "function" ? _a : Object, Object]),
64
+ __metadata("design:returntype", Promise)
65
+ ], EntityCrudControllerHost.prototype, "create", null);
66
+ __decorate([
67
+ (0, common_1.Get)(),
68
+ (0, swagger_1.ApiQuery)({
69
+ name: 'q',
70
+ type: String,
71
+ description: 'Collection Query Parameter. Optional',
72
+ required: false,
73
+ }),
74
+ __param(0, (0, common_1.Query)('q')),
75
+ __param(1, (0, common_1.Req)()),
76
+ __metadata("design:type", Function),
77
+ __metadata("design:paramtypes", [String, Object]),
78
+ __metadata("design:returntype", Promise)
79
+ ], EntityCrudControllerHost.prototype, "findAll", null);
80
+ __decorate([
81
+ (0, common_1.Get)(':id'),
82
+ __param(0, (0, common_1.Param)('id')),
83
+ __param(1, (0, common_1.Req)()),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", [String, Object]),
86
+ __metadata("design:returntype", Promise)
87
+ ], EntityCrudControllerHost.prototype, "findOne", null);
88
+ __decorate([
89
+ (0, common_1.Put)(':id'),
90
+ (0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.updateDto) || extra_crud_controller_1.BaseAPIDto }),
91
+ __param(0, (0, common_1.Param)('id')),
92
+ __param(1, (0, common_1.Body)()),
93
+ __param(2, (0, common_1.Req)()),
94
+ __metadata("design:type", Function),
95
+ __metadata("design:paramtypes", [String, Object, Object]),
96
+ __metadata("design:returntype", Promise)
97
+ ], EntityCrudControllerHost.prototype, "update", null);
98
+ __decorate([
99
+ (0, common_1.Delete)(':id'),
100
+ __param(0, (0, common_1.Param)('id')),
101
+ __param(1, (0, common_1.Req)()),
102
+ __metadata("design:type", Function),
103
+ __metadata("design:paramtypes", [String, Object]),
104
+ __metadata("design:returntype", Promise)
105
+ ], EntityCrudControllerHost.prototype, "softDelete", null);
106
+ __decorate([
107
+ (0, common_1.Patch)('restore/:id'),
108
+ __param(0, (0, common_1.Param)('id')),
109
+ __param(1, (0, common_1.Req)()),
110
+ __metadata("design:type", Function),
111
+ __metadata("design:paramtypes", [String, Object]),
112
+ __metadata("design:returntype", Promise)
113
+ ], EntityCrudControllerHost.prototype, "restore", null);
114
+ __decorate([
115
+ (0, common_1.Get)('/archived/items'),
116
+ (0, swagger_1.ApiQuery)({
117
+ name: 'q',
118
+ type: String,
119
+ description: 'Collection Query Parameter. Optional',
120
+ required: false,
121
+ }),
122
+ __param(0, (0, common_1.Query)('q')),
123
+ __param(1, (0, common_1.Req)()),
124
+ __metadata("design:type", Function),
125
+ __metadata("design:paramtypes", [String, Object]),
126
+ __metadata("design:returntype", Promise)
127
+ ], EntityCrudControllerHost.prototype, "findAllArchived", null);
128
+ EntityCrudControllerHost = __decorate([
129
+ (0, common_1.Controller)(),
130
+ (0, common_1.UseInterceptors)(),
131
+ (0, swagger_1.ApiBearerAuth)(),
132
+ __metadata("design:paramtypes", [service_1.EntityCrudService])
133
+ ], EntityCrudControllerHost);
134
+ return EntityCrudControllerHost;
135
+ }
136
+ //# sourceMappingURL=entity-crud.controller.js.map