@zola_do/crud 0.2.1 → 0.2.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 +31 -0
- package/dist/controller/entity-crud.controller.d.ts +1 -1
- package/dist/controller/entity-crud.controller.js +97 -31
- package/dist/controller/entity-crud.controller.js.map +1 -1
- package/dist/controller/extra-crud.controller.d.ts +1 -1
- package/dist/controller/extra-crud.controller.js +96 -31
- package/dist/controller/extra-crud.controller.js.map +1 -1
- package/dist/controller/relation-crud.controller.js +70 -22
- package/dist/controller/relation-crud.controller.js.map +1 -1
- package/dist/crud-operation/controller/entity-crud.controller.js +3 -3
- package/dist/crud-operation/controller/entity-crud.controller.js.map +1 -1
- package/dist/crud-operation/controller/extra-crud.controller.js +3 -3
- package/dist/crud-operation/controller/extra-crud.controller.js.map +1 -1
- package/dist/crud-operation/controller/relation-crud.controller.js +2 -2
- package/dist/crud-operation/controller/relation-crud.controller.js.map +1 -1
- package/dist/crud-operation/repository/entity-crud.repository.d.ts +3 -3
- package/dist/crud-operation/repository/entity-crud.repository.js +71 -9
- package/dist/crud-operation/repository/entity-crud.repository.js.map +1 -1
- package/dist/crud-operation/repository/extra-crud.repository.d.ts +3 -3
- package/dist/crud-operation/repository/extra-crud.repository.js +71 -9
- package/dist/crud-operation/repository/extra-crud.repository.js.map +1 -1
- package/dist/crud-operation/repository/relation-crud.repository.d.ts +2 -2
- package/dist/crud-operation/repository/relation-crud.repository.js +22 -2
- package/dist/crud-operation/repository/relation-crud.repository.js.map +1 -1
- package/dist/crud-operation/service/entity-crud.service.d.ts +3 -3
- package/dist/crud-operation/service/entity-crud.service.js +28 -6
- package/dist/crud-operation/service/entity-crud.service.js.map +1 -1
- package/dist/crud-operation/service/extra-crud.service.d.ts +3 -3
- package/dist/crud-operation/service/extra-crud.service.js +28 -6
- package/dist/crud-operation/service/extra-crud.service.js.map +1 -1
- package/dist/crud-operation/service/relation-crud.service.d.ts +2 -2
- package/dist/crud-operation/service/relation-crud.service.js +4 -4
- package/dist/crud-operation/service/relation-crud.service.js.map +1 -1
- package/dist/service/entity-crud.service.d.ts +3 -3
- package/dist/service/entity-crud.service.js +71 -9
- package/dist/service/entity-crud.service.js.map +1 -1
- package/dist/service/extra-crud.service.d.ts +3 -3
- package/dist/service/extra-crud.service.js +71 -9
- package/dist/service/extra-crud.service.js.map +1 -1
- package/dist/service/relation-crud.service.d.ts +2 -2
- package/dist/service/relation-crud.service.js +22 -2
- package/dist/service/relation-crud.service.js.map +1 -1
- package/dist/shared/guards/crud-operation-disabled.guard.d.ts +7 -0
- package/dist/shared/guards/crud-operation-disabled.guard.js +16 -0
- package/dist/shared/guards/crud-operation-disabled.guard.js.map +1 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/types/crud-option.type.d.ts +48 -0
- package/dist/shared/utils/crud-hooks.helper.d.ts +10 -0
- package/dist/shared/utils/crud-hooks.helper.js +42 -0
- package/dist/shared/utils/crud-hooks.helper.js.map +1 -0
- package/dist/shared/utils/index.d.ts +1 -0
- package/dist/shared/utils/index.js +1 -0
- package/dist/shared/utils/index.js.map +1 -1
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -85,6 +85,8 @@ export class ProductsModule {}
|
|
|
85
85
|
- `PUT /:id` — Update
|
|
86
86
|
- `DELETE /:id` — Soft delete
|
|
87
87
|
|
|
88
|
+
You can disable specific endpoints via the `operations` option (supports `hide` and `block`).
|
|
89
|
+
|
|
88
90
|
### EntityCrudOptions
|
|
89
91
|
|
|
90
92
|
```typescript
|
|
@@ -104,9 +106,38 @@ const options: EntityCrudOptions = {
|
|
|
104
106
|
organizationName: req?.session?.org?.name,
|
|
105
107
|
createdBy: req?.session?.user?.id,
|
|
106
108
|
}),
|
|
109
|
+
// Optional per-endpoint disabling
|
|
110
|
+
operations: {
|
|
111
|
+
create: 'hide',
|
|
112
|
+
findAll: { mode: 'block', reason: 'listing is temporarily disabled' },
|
|
113
|
+
},
|
|
107
114
|
};
|
|
108
115
|
```
|
|
109
116
|
|
|
117
|
+
### Endpoint Disabling (`operations`)
|
|
118
|
+
|
|
119
|
+
For `EntityCrudController` and `ExtraCrudController`, `operations` supports these keys:
|
|
120
|
+
|
|
121
|
+
- `create`
|
|
122
|
+
- `findAll`
|
|
123
|
+
- `findOne`
|
|
124
|
+
- `update`
|
|
125
|
+
- `delete` (soft-delete)
|
|
126
|
+
- `restore`
|
|
127
|
+
- `findAllArchived`
|
|
128
|
+
|
|
129
|
+
For `RelationCrudController`, `operations` supports these keys:
|
|
130
|
+
|
|
131
|
+
- `bulkSaveFirst`
|
|
132
|
+
- `bulkSaveSecond`
|
|
133
|
+
- `findAllFirst`
|
|
134
|
+
- `findAllSecond`
|
|
135
|
+
|
|
136
|
+
Each operation can be configured as:
|
|
137
|
+
|
|
138
|
+
- `'hide'` — route is not registered (typically `404`)
|
|
139
|
+
- `'block'` — route is registered but denied with a consistent `403`
|
|
140
|
+
|
|
110
141
|
### Request Context Mapping
|
|
111
142
|
|
|
112
143
|
`@zola_do/crud` supports three create-time mapping levels:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntityCrudService } from '../service';
|
|
2
2
|
import { DeepPartial, ObjectLiteral } from 'typeorm';
|
|
3
|
-
import {
|
|
3
|
+
import { DataResponseFormat, EntityCrudOptions } from '../shared';
|
|
4
4
|
export declare function EntityCrudController<TEntity extends ObjectLiteral>(options?: EntityCrudOptions): {
|
|
5
5
|
new (service: EntityCrudService<TEntity>): {
|
|
6
6
|
readonly service: EntityCrudService<TEntity>;
|
|
@@ -17,9 +17,25 @@ const common_1 = require("@nestjs/common");
|
|
|
17
17
|
const service_1 = require("../service");
|
|
18
18
|
const swagger_1 = require("@nestjs/swagger");
|
|
19
19
|
const extra_crud_controller_1 = require("./extra-crud.controller");
|
|
20
|
+
const shared_1 = require("../shared");
|
|
20
21
|
const collection_query_1 = require("@zola_do/collection-query");
|
|
21
22
|
const authorization_1 = require("@zola_do/authorization");
|
|
22
23
|
function EntityCrudController(options) {
|
|
24
|
+
var _a;
|
|
25
|
+
const operations = (_a = options === null || options === void 0 ? void 0 : options.operations) !== null && _a !== void 0 ? _a : {};
|
|
26
|
+
const normalizeDisableConfig = (config) => {
|
|
27
|
+
if (!config)
|
|
28
|
+
return {};
|
|
29
|
+
if (typeof config === 'string')
|
|
30
|
+
return { mode: config };
|
|
31
|
+
return { mode: config.mode, reason: config.reason };
|
|
32
|
+
};
|
|
33
|
+
const applyMethodDecorators = (host, methodName, decorators) => {
|
|
34
|
+
const descriptor = Object.getOwnPropertyDescriptor(host.prototype, methodName);
|
|
35
|
+
for (let i = decorators.length - 1; i >= 0; i--) {
|
|
36
|
+
decorators[i](host.prototype, methodName, descriptor);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
23
39
|
let EntityCrudControllerHost = class EntityCrudControllerHost {
|
|
24
40
|
constructor(service) {
|
|
25
41
|
this.service = service;
|
|
@@ -35,13 +51,13 @@ function EntityCrudController(options) {
|
|
|
35
51
|
return await this.service.findOne(id, req);
|
|
36
52
|
}
|
|
37
53
|
async update(id, itemData, req) {
|
|
38
|
-
return await this.service.update(id, itemData);
|
|
54
|
+
return await this.service.update(id, itemData, req, options);
|
|
39
55
|
}
|
|
40
56
|
async softDelete(id, req) {
|
|
41
|
-
return this.service.softDelete(id, req);
|
|
57
|
+
return this.service.softDelete(id, req, options);
|
|
42
58
|
}
|
|
43
59
|
async restore(id, req) {
|
|
44
|
-
return this.service.restore(id, req);
|
|
60
|
+
return this.service.restore(id, req, options);
|
|
45
61
|
}
|
|
46
62
|
async findAllArchived(q, req) {
|
|
47
63
|
const query = (0, collection_query_1.decodeCollectionQuery)(q);
|
|
@@ -49,9 +65,6 @@ function EntityCrudController(options) {
|
|
|
49
65
|
}
|
|
50
66
|
};
|
|
51
67
|
__decorate([
|
|
52
|
-
(0, common_1.Post)(),
|
|
53
|
-
(0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.createDto) || extra_crud_controller_1.BaseAPIDto }),
|
|
54
|
-
(0, common_1.UseGuards)(authorization_1.JwtGuard, (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.createPermission)),
|
|
55
68
|
__param(0, (0, common_1.Body)()),
|
|
56
69
|
__param(1, (0, common_1.Req)()),
|
|
57
70
|
__metadata("design:type", Function),
|
|
@@ -59,14 +72,6 @@ function EntityCrudController(options) {
|
|
|
59
72
|
__metadata("design:returntype", Promise)
|
|
60
73
|
], EntityCrudControllerHost.prototype, "create", null);
|
|
61
74
|
__decorate([
|
|
62
|
-
(0, common_1.Get)(),
|
|
63
|
-
(0, swagger_1.ApiQuery)({
|
|
64
|
-
name: 'q',
|
|
65
|
-
type: String,
|
|
66
|
-
description: 'Collection Query Parameter. Optional',
|
|
67
|
-
required: false,
|
|
68
|
-
}),
|
|
69
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewPermission)),
|
|
70
75
|
__param(0, (0, common_1.Query)('q')),
|
|
71
76
|
__param(1, (0, common_1.Req)()),
|
|
72
77
|
__metadata("design:type", Function),
|
|
@@ -74,8 +79,6 @@ function EntityCrudController(options) {
|
|
|
74
79
|
__metadata("design:returntype", Promise)
|
|
75
80
|
], EntityCrudControllerHost.prototype, "findAll", null);
|
|
76
81
|
__decorate([
|
|
77
|
-
(0, common_1.Get)(':id'),
|
|
78
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewPermission)),
|
|
79
82
|
__param(0, (0, common_1.Param)('id')),
|
|
80
83
|
__param(1, (0, common_1.Req)()),
|
|
81
84
|
__metadata("design:type", Function),
|
|
@@ -83,9 +86,6 @@ function EntityCrudController(options) {
|
|
|
83
86
|
__metadata("design:returntype", Promise)
|
|
84
87
|
], EntityCrudControllerHost.prototype, "findOne", null);
|
|
85
88
|
__decorate([
|
|
86
|
-
(0, common_1.Put)(':id'),
|
|
87
|
-
(0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.updateDto) || extra_crud_controller_1.BaseAPIDto }),
|
|
88
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.updatePermission)),
|
|
89
89
|
__param(0, (0, common_1.Param)('id')),
|
|
90
90
|
__param(1, (0, common_1.Body)()),
|
|
91
91
|
__param(2, (0, common_1.Req)()),
|
|
@@ -94,8 +94,6 @@ function EntityCrudController(options) {
|
|
|
94
94
|
__metadata("design:returntype", Promise)
|
|
95
95
|
], EntityCrudControllerHost.prototype, "update", null);
|
|
96
96
|
__decorate([
|
|
97
|
-
(0, common_1.Delete)(':id'),
|
|
98
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.deletePermission)),
|
|
99
97
|
__param(0, (0, common_1.Param)('id')),
|
|
100
98
|
__param(1, (0, common_1.Req)()),
|
|
101
99
|
__metadata("design:type", Function),
|
|
@@ -103,8 +101,6 @@ function EntityCrudController(options) {
|
|
|
103
101
|
__metadata("design:returntype", Promise)
|
|
104
102
|
], EntityCrudControllerHost.prototype, "softDelete", null);
|
|
105
103
|
__decorate([
|
|
106
|
-
(0, common_1.Patch)('restore/:id'),
|
|
107
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.restorePermission)),
|
|
108
104
|
__param(0, (0, common_1.Param)('id')),
|
|
109
105
|
__param(1, (0, common_1.Req)()),
|
|
110
106
|
__metadata("design:type", Function),
|
|
@@ -112,14 +108,6 @@ function EntityCrudController(options) {
|
|
|
112
108
|
__metadata("design:returntype", Promise)
|
|
113
109
|
], EntityCrudControllerHost.prototype, "restore", null);
|
|
114
110
|
__decorate([
|
|
115
|
-
(0, common_1.Get)('/archived/items'),
|
|
116
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewArchivedPermission)),
|
|
117
|
-
(0, swagger_1.ApiQuery)({
|
|
118
|
-
name: 'q',
|
|
119
|
-
type: String,
|
|
120
|
-
description: 'Collection Query Parameter. Optional',
|
|
121
|
-
required: false,
|
|
122
|
-
}),
|
|
123
111
|
__param(0, (0, common_1.Query)('q')),
|
|
124
112
|
__param(1, (0, common_1.Req)()),
|
|
125
113
|
__metadata("design:type", Function),
|
|
@@ -132,6 +120,84 @@ function EntityCrudController(options) {
|
|
|
132
120
|
(0, swagger_1.ApiBearerAuth)(),
|
|
133
121
|
__metadata("design:paramtypes", [service_1.EntityCrudService])
|
|
134
122
|
], EntityCrudControllerHost);
|
|
123
|
+
const createDisable = normalizeDisableConfig(operations.create);
|
|
124
|
+
if (createDisable.mode !== 'hide') {
|
|
125
|
+
const guards = createDisable.mode === 'block'
|
|
126
|
+
? [new shared_1.CrudOperationDisabledGuard('create', createDisable.reason)]
|
|
127
|
+
: [authorization_1.JwtGuard, (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.createPermission)];
|
|
128
|
+
applyMethodDecorators(EntityCrudControllerHost, 'create', [
|
|
129
|
+
(0, common_1.Post)(),
|
|
130
|
+
(0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.createDto) || extra_crud_controller_1.BaseAPIDto }),
|
|
131
|
+
(0, common_1.UseGuards)(...guards),
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
const findAllDisable = normalizeDisableConfig(operations.findAll);
|
|
135
|
+
if (findAllDisable.mode !== 'hide') {
|
|
136
|
+
applyMethodDecorators(EntityCrudControllerHost, 'findAll', [
|
|
137
|
+
(0, common_1.Get)(),
|
|
138
|
+
(0, swagger_1.ApiQuery)({
|
|
139
|
+
name: 'q',
|
|
140
|
+
type: String,
|
|
141
|
+
description: 'Collection Query Parameter. Optional',
|
|
142
|
+
required: false,
|
|
143
|
+
}),
|
|
144
|
+
(0, common_1.UseGuards)(findAllDisable.mode === 'block'
|
|
145
|
+
? new shared_1.CrudOperationDisabledGuard('findAll')
|
|
146
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewPermission)),
|
|
147
|
+
]);
|
|
148
|
+
}
|
|
149
|
+
const findOneDisable = normalizeDisableConfig(operations.findOne);
|
|
150
|
+
if (findOneDisable.mode !== 'hide') {
|
|
151
|
+
applyMethodDecorators(EntityCrudControllerHost, 'findOne', [
|
|
152
|
+
(0, common_1.Get)(':id'),
|
|
153
|
+
(0, common_1.UseGuards)(findOneDisable.mode === 'block'
|
|
154
|
+
? new shared_1.CrudOperationDisabledGuard('findOne')
|
|
155
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewPermission)),
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
const updateDisable = normalizeDisableConfig(operations.update);
|
|
159
|
+
if (updateDisable.mode !== 'hide') {
|
|
160
|
+
applyMethodDecorators(EntityCrudControllerHost, 'update', [
|
|
161
|
+
(0, common_1.Put)(':id'),
|
|
162
|
+
(0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.updateDto) || extra_crud_controller_1.BaseAPIDto }),
|
|
163
|
+
(0, common_1.UseGuards)(updateDisable.mode === 'block'
|
|
164
|
+
? new shared_1.CrudOperationDisabledGuard('update')
|
|
165
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.updatePermission)),
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
const deleteDisable = normalizeDisableConfig(operations.delete);
|
|
169
|
+
if (deleteDisable.mode !== 'hide') {
|
|
170
|
+
applyMethodDecorators(EntityCrudControllerHost, 'softDelete', [
|
|
171
|
+
(0, common_1.Delete)(':id'),
|
|
172
|
+
(0, common_1.UseGuards)(deleteDisable.mode === 'block'
|
|
173
|
+
? new shared_1.CrudOperationDisabledGuard('delete')
|
|
174
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.deletePermission)),
|
|
175
|
+
]);
|
|
176
|
+
}
|
|
177
|
+
const restoreDisable = normalizeDisableConfig(operations.restore);
|
|
178
|
+
if (restoreDisable.mode !== 'hide') {
|
|
179
|
+
applyMethodDecorators(EntityCrudControllerHost, 'restore', [
|
|
180
|
+
(0, common_1.Patch)('restore/:id'),
|
|
181
|
+
(0, common_1.UseGuards)(restoreDisable.mode === 'block'
|
|
182
|
+
? new shared_1.CrudOperationDisabledGuard('restore')
|
|
183
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.restorePermission)),
|
|
184
|
+
]);
|
|
185
|
+
}
|
|
186
|
+
const archivedDisable = normalizeDisableConfig(operations.findAllArchived);
|
|
187
|
+
if (archivedDisable.mode !== 'hide') {
|
|
188
|
+
applyMethodDecorators(EntityCrudControllerHost, 'findAllArchived', [
|
|
189
|
+
(0, common_1.Get)('/archived/items'),
|
|
190
|
+
(0, common_1.UseGuards)(archivedDisable.mode === 'block'
|
|
191
|
+
? new shared_1.CrudOperationDisabledGuard('findAllArchived')
|
|
192
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewArchivedPermission)),
|
|
193
|
+
(0, swagger_1.ApiQuery)({
|
|
194
|
+
name: 'q',
|
|
195
|
+
type: String,
|
|
196
|
+
description: 'Collection Query Parameter. Optional',
|
|
197
|
+
required: false,
|
|
198
|
+
}),
|
|
199
|
+
]);
|
|
200
|
+
}
|
|
135
201
|
return EntityCrudControllerHost;
|
|
136
202
|
}
|
|
137
203
|
//# sourceMappingURL=entity-crud.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-crud.controller.js","sourceRoot":"","sources":["../../src/controller/entity-crud.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"entity-crud.controller.js","sourceRoot":"","sources":["../../src/controller/entity-crud.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA4BA,oDAiLC;AA7MD,2CA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AAP,OAAO,CAAE,iBAAiB,CAAC,CACjD;SACF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,eAAe,GAAG,sBAAsB,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAC3E,IAAI,eAAe,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACpC,qBAAqB,CAAC,wBAAwB,EAAE,iBAAiB,EAAE;YACjE,IAAA,YAAG,EAAC,iBAAiB,CAAC;YACtB,IAAA,kBAAS,EACP,eAAe,CAAC,IAAI,KAAK,OAAO;gBAC9B,CAAC,CAAC,IAAI,mCAA0B,CAAC,iBAAiB,CAAC;gBACnD,CAAC,CAAC,IAAA,gCAAgB,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,sBAAsB,CAAC,CACtD;YACD,IAAA,kBAAQ,EAAC;gBACP,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,sCAAsC;gBACnD,QAAQ,EAAE,KAAK;aAChB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeepPartial, ObjectLiteral } from 'typeorm';
|
|
2
2
|
import { ExtraCrudService } from '../service';
|
|
3
|
-
import {
|
|
3
|
+
import { DataResponseFormat, ExtraCrudOptions } from '../shared';
|
|
4
4
|
export declare class BaseAPIDto {
|
|
5
5
|
}
|
|
6
6
|
export declare function ExtraCrudController<TEntity extends ObjectLiteral>(options: ExtraCrudOptions): {
|
|
@@ -19,11 +19,27 @@ const service_1 = require("../service");
|
|
|
19
19
|
const swagger_1 = require("@nestjs/swagger");
|
|
20
20
|
const collection_query_1 = require("@zola_do/collection-query");
|
|
21
21
|
const authorization_1 = require("@zola_do/authorization");
|
|
22
|
+
const shared_1 = require("../shared");
|
|
22
23
|
class BaseAPIDto {
|
|
23
24
|
}
|
|
24
25
|
exports.BaseAPIDto = BaseAPIDto;
|
|
25
26
|
function ExtraCrudController(options) {
|
|
27
|
+
var _a;
|
|
26
28
|
const { createDto, updateDto } = options;
|
|
29
|
+
const operations = (_a = options.operations) !== null && _a !== void 0 ? _a : {};
|
|
30
|
+
const normalizeDisableConfig = (config) => {
|
|
31
|
+
if (!config)
|
|
32
|
+
return {};
|
|
33
|
+
if (typeof config === 'string')
|
|
34
|
+
return { mode: config };
|
|
35
|
+
return { mode: config.mode, reason: config.reason };
|
|
36
|
+
};
|
|
37
|
+
const applyMethodDecorators = (host, methodName, decorators) => {
|
|
38
|
+
const descriptor = Object.getOwnPropertyDescriptor(host.prototype, methodName);
|
|
39
|
+
for (let i = decorators.length - 1; i >= 0; i--) {
|
|
40
|
+
decorators[i](host.prototype, methodName, descriptor);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
27
43
|
let ExtraCrudControllerHost = class ExtraCrudControllerHost {
|
|
28
44
|
constructor(service) {
|
|
29
45
|
this.service = service;
|
|
@@ -39,13 +55,13 @@ function ExtraCrudController(options) {
|
|
|
39
55
|
return await this.service.findOne(id, req);
|
|
40
56
|
}
|
|
41
57
|
async update(id, itemData, req) {
|
|
42
|
-
return await this.service.update(id, itemData);
|
|
58
|
+
return await this.service.update(id, itemData, req, options);
|
|
43
59
|
}
|
|
44
60
|
async softDelete(id, req) {
|
|
45
|
-
return await this.service.softDelete(id, req);
|
|
61
|
+
return await this.service.softDelete(id, req, options);
|
|
46
62
|
}
|
|
47
63
|
async restore(id, req) {
|
|
48
|
-
return await this.service.restore(id, req);
|
|
64
|
+
return await this.service.restore(id, req, options);
|
|
49
65
|
}
|
|
50
66
|
async findAllArchived(id, q, req) {
|
|
51
67
|
const query = (0, collection_query_1.decodeCollectionQuery)(q);
|
|
@@ -53,9 +69,6 @@ function ExtraCrudController(options) {
|
|
|
53
69
|
}
|
|
54
70
|
};
|
|
55
71
|
__decorate([
|
|
56
|
-
(0, common_1.Post)(),
|
|
57
|
-
(0, swagger_1.ApiBody)({ type: createDto || BaseAPIDto }),
|
|
58
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.createPermission)),
|
|
59
72
|
__param(0, (0, common_1.Body)()),
|
|
60
73
|
__param(1, (0, common_1.Req)()),
|
|
61
74
|
__metadata("design:type", Function),
|
|
@@ -63,14 +76,6 @@ function ExtraCrudController(options) {
|
|
|
63
76
|
__metadata("design:returntype", Promise)
|
|
64
77
|
], ExtraCrudControllerHost.prototype, "create", null);
|
|
65
78
|
__decorate([
|
|
66
|
-
(0, common_1.Get)('list/:id'),
|
|
67
|
-
(0, swagger_1.ApiQuery)({
|
|
68
|
-
name: 'q',
|
|
69
|
-
type: String,
|
|
70
|
-
description: 'Collection Query Parameter. Optional',
|
|
71
|
-
required: false,
|
|
72
|
-
}),
|
|
73
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.viewPermission)),
|
|
74
79
|
__param(0, (0, common_1.Param)('id')),
|
|
75
80
|
__param(1, (0, common_1.Query)('q')),
|
|
76
81
|
__param(2, (0, common_1.Req)()),
|
|
@@ -79,8 +84,6 @@ function ExtraCrudController(options) {
|
|
|
79
84
|
__metadata("design:returntype", Promise)
|
|
80
85
|
], ExtraCrudControllerHost.prototype, "findAll", null);
|
|
81
86
|
__decorate([
|
|
82
|
-
(0, common_1.Get)(':id'),
|
|
83
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.viewPermission)),
|
|
84
87
|
__param(0, (0, common_1.Param)('id')),
|
|
85
88
|
__param(1, (0, common_1.Req)()),
|
|
86
89
|
__metadata("design:type", Function),
|
|
@@ -88,9 +91,6 @@ function ExtraCrudController(options) {
|
|
|
88
91
|
__metadata("design:returntype", Promise)
|
|
89
92
|
], ExtraCrudControllerHost.prototype, "findOne", null);
|
|
90
93
|
__decorate([
|
|
91
|
-
(0, common_1.Put)(':id'),
|
|
92
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.updatePermission)),
|
|
93
|
-
(0, swagger_1.ApiBody)({ type: updateDto || BaseAPIDto }),
|
|
94
94
|
__param(0, (0, common_1.Param)('id')),
|
|
95
95
|
__param(1, (0, common_1.Body)()),
|
|
96
96
|
__param(2, (0, common_1.Req)()),
|
|
@@ -99,8 +99,6 @@ function ExtraCrudController(options) {
|
|
|
99
99
|
__metadata("design:returntype", Promise)
|
|
100
100
|
], ExtraCrudControllerHost.prototype, "update", null);
|
|
101
101
|
__decorate([
|
|
102
|
-
(0, common_1.Delete)(':id'),
|
|
103
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.deletePermission)),
|
|
104
102
|
__param(0, (0, common_1.Param)('id')),
|
|
105
103
|
__param(1, (0, common_1.Req)()),
|
|
106
104
|
__metadata("design:type", Function),
|
|
@@ -108,8 +106,6 @@ function ExtraCrudController(options) {
|
|
|
108
106
|
__metadata("design:returntype", Promise)
|
|
109
107
|
], ExtraCrudControllerHost.prototype, "softDelete", null);
|
|
110
108
|
__decorate([
|
|
111
|
-
(0, common_1.Patch)('restore/:id'),
|
|
112
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.restorePermission)),
|
|
113
109
|
__param(0, (0, common_1.Param)('id')),
|
|
114
110
|
__param(1, (0, common_1.Req)()),
|
|
115
111
|
__metadata("design:type", Function),
|
|
@@ -117,14 +113,6 @@ function ExtraCrudController(options) {
|
|
|
117
113
|
__metadata("design:returntype", Promise)
|
|
118
114
|
], ExtraCrudControllerHost.prototype, "restore", null);
|
|
119
115
|
__decorate([
|
|
120
|
-
(0, common_1.Get)('list/archived/items/:id'),
|
|
121
|
-
(0, common_1.UseGuards)((0, authorization_1.PermissionsGuard)(options.viewArchivedPermission)),
|
|
122
|
-
(0, swagger_1.ApiQuery)({
|
|
123
|
-
name: 'q',
|
|
124
|
-
type: String,
|
|
125
|
-
description: 'Collection Query Parameter. Optional',
|
|
126
|
-
required: false,
|
|
127
|
-
}),
|
|
128
116
|
__param(0, (0, common_1.Param)('id')),
|
|
129
117
|
__param(1, (0, common_1.Query)('q')),
|
|
130
118
|
__param(2, (0, common_1.Req)()),
|
|
@@ -138,6 +126,83 @@ function ExtraCrudController(options) {
|
|
|
138
126
|
(0, swagger_1.ApiBearerAuth)(),
|
|
139
127
|
__metadata("design:paramtypes", [service_1.ExtraCrudService])
|
|
140
128
|
], ExtraCrudControllerHost);
|
|
129
|
+
const createDisable = normalizeDisableConfig(operations.create);
|
|
130
|
+
if (createDisable.mode !== 'hide') {
|
|
131
|
+
applyMethodDecorators(ExtraCrudControllerHost, 'create', [
|
|
132
|
+
(0, common_1.Post)(),
|
|
133
|
+
(0, swagger_1.ApiBody)({ type: createDto || BaseAPIDto }),
|
|
134
|
+
(0, common_1.UseGuards)(createDisable.mode === 'block'
|
|
135
|
+
? new shared_1.CrudOperationDisabledGuard('create', createDisable.reason)
|
|
136
|
+
: (0, authorization_1.PermissionsGuard)(options.createPermission)),
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
const findAllDisable = normalizeDisableConfig(operations.findAll);
|
|
140
|
+
if (findAllDisable.mode !== 'hide') {
|
|
141
|
+
applyMethodDecorators(ExtraCrudControllerHost, 'findAll', [
|
|
142
|
+
(0, common_1.Get)('list/:id'),
|
|
143
|
+
(0, swagger_1.ApiQuery)({
|
|
144
|
+
name: 'q',
|
|
145
|
+
type: String,
|
|
146
|
+
description: 'Collection Query Parameter. Optional',
|
|
147
|
+
required: false,
|
|
148
|
+
}),
|
|
149
|
+
(0, common_1.UseGuards)(findAllDisable.mode === 'block'
|
|
150
|
+
? new shared_1.CrudOperationDisabledGuard('findAll')
|
|
151
|
+
: (0, authorization_1.PermissionsGuard)(options.viewPermission)),
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
const findOneDisable = normalizeDisableConfig(operations.findOne);
|
|
155
|
+
if (findOneDisable.mode !== 'hide') {
|
|
156
|
+
applyMethodDecorators(ExtraCrudControllerHost, 'findOne', [
|
|
157
|
+
(0, common_1.Get)(':id'),
|
|
158
|
+
(0, common_1.UseGuards)(findOneDisable.mode === 'block'
|
|
159
|
+
? new shared_1.CrudOperationDisabledGuard('findOne')
|
|
160
|
+
: (0, authorization_1.PermissionsGuard)(options.viewPermission)),
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
const updateDisable = normalizeDisableConfig(operations.update);
|
|
164
|
+
if (updateDisable.mode !== 'hide') {
|
|
165
|
+
applyMethodDecorators(ExtraCrudControllerHost, 'update', [
|
|
166
|
+
(0, common_1.Put)(':id'),
|
|
167
|
+
(0, common_1.UseGuards)(updateDisable.mode === 'block'
|
|
168
|
+
? new shared_1.CrudOperationDisabledGuard('update')
|
|
169
|
+
: (0, authorization_1.PermissionsGuard)(options.updatePermission)),
|
|
170
|
+
(0, swagger_1.ApiBody)({ type: updateDto || BaseAPIDto }),
|
|
171
|
+
]);
|
|
172
|
+
}
|
|
173
|
+
const deleteDisable = normalizeDisableConfig(operations.delete);
|
|
174
|
+
if (deleteDisable.mode !== 'hide') {
|
|
175
|
+
applyMethodDecorators(ExtraCrudControllerHost, 'softDelete', [
|
|
176
|
+
(0, common_1.Delete)(':id'),
|
|
177
|
+
(0, common_1.UseGuards)(deleteDisable.mode === 'block'
|
|
178
|
+
? new shared_1.CrudOperationDisabledGuard('delete', deleteDisable.reason)
|
|
179
|
+
: (0, authorization_1.PermissionsGuard)(options.deletePermission)),
|
|
180
|
+
]);
|
|
181
|
+
}
|
|
182
|
+
const restoreDisable = normalizeDisableConfig(operations.restore);
|
|
183
|
+
if (restoreDisable.mode !== 'hide') {
|
|
184
|
+
applyMethodDecorators(ExtraCrudControllerHost, 'restore', [
|
|
185
|
+
(0, common_1.Patch)('restore/:id'),
|
|
186
|
+
(0, common_1.UseGuards)(restoreDisable.mode === 'block'
|
|
187
|
+
? new shared_1.CrudOperationDisabledGuard('restore', restoreDisable.reason)
|
|
188
|
+
: (0, authorization_1.PermissionsGuard)(options.restorePermission)),
|
|
189
|
+
]);
|
|
190
|
+
}
|
|
191
|
+
const archivedDisable = normalizeDisableConfig(operations.findAllArchived);
|
|
192
|
+
if (archivedDisable.mode !== 'hide') {
|
|
193
|
+
applyMethodDecorators(ExtraCrudControllerHost, 'findAllArchived', [
|
|
194
|
+
(0, common_1.Get)('list/archived/items/:id'),
|
|
195
|
+
(0, common_1.UseGuards)(archivedDisable.mode === 'block'
|
|
196
|
+
? new shared_1.CrudOperationDisabledGuard('findAllArchived', archivedDisable.reason)
|
|
197
|
+
: (0, authorization_1.PermissionsGuard)(options.viewArchivedPermission)),
|
|
198
|
+
(0, swagger_1.ApiQuery)({
|
|
199
|
+
name: 'q',
|
|
200
|
+
type: String,
|
|
201
|
+
description: 'Collection Query Parameter. Optional',
|
|
202
|
+
required: false,
|
|
203
|
+
}),
|
|
204
|
+
]);
|
|
205
|
+
}
|
|
141
206
|
return ExtraCrudControllerHost;
|
|
142
207
|
}
|
|
143
208
|
//# sourceMappingURL=extra-crud.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extra-crud.controller.js","sourceRoot":"","sources":["../../src/controller/extra-crud.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"extra-crud.controller.js","sourceRoot":"","sources":["../../src/controller/extra-crud.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA6BA,kDAoLC;AAjND,2CAawB;AAExB,wCAA8C;AAC9C,6CAAmE;AACnE,gEAAkE;AAClE,0DAA0D;AAC1D,sCAMmB;AAEnB,MAAa,UAAU;CAAG;AAA1B,gCAA0B;AAE1B,SAAgB,mBAAmB,CACjC,OAAyB;;IAEzB,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACzC,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,EAAE,CAAC;IAE5C,MAAM,sBAAsB,GAAG,CAC7B,MAAkC,EACmB,EAAE;QACvD,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QACvB,IAAI,OAAO,MAAM,K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