@zola_do/crud 0.2.2 → 0.2.4
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 +130 -1
- package/dist/controller/entity-crud.controller.d.ts +3 -3
- package/dist/controller/entity-crud.controller.js +154 -38
- package/dist/controller/entity-crud.controller.js.map +1 -1
- package/dist/controller/extra-crud.controller.d.ts +3 -3
- package/dist/controller/extra-crud.controller.js +152 -37
- package/dist/controller/extra-crud.controller.js.map +1 -1
- package/dist/controller/relation-crud.controller.d.ts +2 -2
- package/dist/controller/relation-crud.controller.js +126 -28
- package/dist/controller/relation-crud.controller.js.map +1 -1
- package/dist/crud-operation/repository/entity-crud.repository.js +16 -4
- package/dist/crud-operation/repository/entity-crud.repository.js.map +1 -1
- package/dist/crud-operation/repository/extra-crud.repository.js +16 -4
- package/dist/crud-operation/repository/extra-crud.repository.js.map +1 -1
- package/dist/optional/rpc.d.ts +1 -0
- package/dist/optional/rpc.js +18 -0
- package/dist/optional/rpc.js.map +1 -0
- package/dist/repository/index.d.ts +1 -0
- package/dist/repository/index.js +18 -0
- package/dist/repository/index.js.map +1 -0
- package/dist/request-context/index.d.ts +1 -0
- package/dist/request-context/index.js +18 -0
- package/dist/request-context/index.js.map +1 -0
- package/dist/service/entity-crud.service.d.ts +3 -3
- package/dist/service/entity-crud.service.js +126 -35
- package/dist/service/entity-crud.service.js.map +1 -1
- package/dist/service/extra-crud.service.d.ts +2 -2
- package/dist/service/extra-crud.service.js +126 -40
- package/dist/service/extra-crud.service.js.map +1 -1
- package/dist/service/relation-crud.service.js +15 -1
- package/dist/service/relation-crud.service.js.map +1 -1
- package/dist/shared/api-data/api-paginated-response.js +24 -0
- package/dist/shared/api-data/api-paginated-response.js.map +1 -1
- package/dist/shared/api-data/data-response-format.d.ts +6 -0
- package/dist/shared/api-data/data-response-format.js +24 -0
- package/dist/shared/api-data/data-response-format.js.map +1 -1
- package/dist/shared/exceptions/index.d.ts +0 -1
- package/dist/shared/exceptions/index.js +0 -1
- package/dist/shared/exceptions/index.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/request-context/apply-create-context.helper.js +17 -4
- package/dist/shared/request-context/apply-create-context.helper.js.map +1 -1
- package/dist/shared/types/crud-option.type.d.ts +83 -12
- package/dist/shared/utils/crud-hooks.helper.d.ts +31 -2
- package/dist/shared/utils/crud-hooks.helper.js +172 -1
- package/dist/shared/utils/crud-hooks.helper.js.map +1 -1
- package/dist/shared/utils/cursor-query.helper.d.ts +6 -0
- package/dist/shared/utils/cursor-query.helper.js +49 -0
- package/dist/shared/utils/cursor-query.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 +30 -1
package/README.md
CHANGED
|
@@ -14,6 +14,31 @@ npm install @zola_do/nestjs-shared
|
|
|
14
14
|
|
|
15
15
|
## Dependencies
|
|
16
16
|
|
|
17
|
+
- `@zola_do/collection-query`
|
|
18
|
+
- `@zola_do/authorization`
|
|
19
|
+
- Optional (only for RPC exception filter): `@nestjs/microservices`
|
|
20
|
+
|
|
21
|
+
## Recommended Imports
|
|
22
|
+
|
|
23
|
+
`@zola_do/crud` root imports remain fully supported for backward compatibility.
|
|
24
|
+
For new code, prefer focused subpath imports:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { EntityCrudController } from '@zola_do/crud/controller';
|
|
28
|
+
import { EntityCrudService } from '@zola_do/crud/service';
|
|
29
|
+
import { EntityCrudRepository } from '@zola_do/crud/repository';
|
|
30
|
+
import {
|
|
31
|
+
CRUD_REQUEST_CONTEXT_RESOLVER,
|
|
32
|
+
CrudRequestContextResolver,
|
|
33
|
+
} from '@zola_do/crud/request-context';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Optional RPC exception filter stays available at:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { ExceptionFilter } from '@zola_do/crud/optional/rpc';
|
|
40
|
+
```
|
|
41
|
+
|
|
17
42
|
## Usage
|
|
18
43
|
|
|
19
44
|
### Entity Setup
|
|
@@ -85,6 +110,8 @@ export class ProductsModule {}
|
|
|
85
110
|
- `PUT /:id` — Update
|
|
86
111
|
- `DELETE /:id` — Soft delete
|
|
87
112
|
|
|
113
|
+
You can disable specific endpoints via the `operations` option (supports `hide` and `block`).
|
|
114
|
+
|
|
88
115
|
### EntityCrudOptions
|
|
89
116
|
|
|
90
117
|
```typescript
|
|
@@ -104,9 +131,99 @@ const options: EntityCrudOptions = {
|
|
|
104
131
|
organizationName: req?.session?.org?.name,
|
|
105
132
|
createdBy: req?.session?.user?.id,
|
|
106
133
|
}),
|
|
134
|
+
// Optional per-endpoint disabling
|
|
135
|
+
operations: {
|
|
136
|
+
create: 'hide',
|
|
137
|
+
findAll: { mode: 'block', reason: 'listing is temporarily disabled' },
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Operation Hooks and Policy Callbacks
|
|
143
|
+
|
|
144
|
+
`EntityCrudOptions` and `ExtraCrudOptions` support reusable per-operation hooks:
|
|
145
|
+
|
|
146
|
+
- `beforeCreate` / `afterCreate`
|
|
147
|
+
- `beforeFindAll` / `afterFindAll`
|
|
148
|
+
- `beforeFindOne` / `afterFindOne`
|
|
149
|
+
- `beforeUpdate` / `afterUpdate`
|
|
150
|
+
- `beforeDelete` / `afterDelete` (alias hooks)
|
|
151
|
+
- `beforeRestore` / `afterRestore`
|
|
152
|
+
|
|
153
|
+
Delete hook compatibility is preserved:
|
|
154
|
+
|
|
155
|
+
- Legacy: `beforeSoftDelete` / `afterSoftDelete`
|
|
156
|
+
- New alias: `beforeDelete` / `afterDelete`
|
|
157
|
+
- If both are configured, both run (legacy first, then alias)
|
|
158
|
+
|
|
159
|
+
Hooks receive operation context with request and mutable payload/filter data:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
const options: EntityCrudOptions = {
|
|
163
|
+
blockedWriteFields: ['eventId'],
|
|
164
|
+
|
|
165
|
+
authorize: async ({ req, operation }) => {
|
|
166
|
+
if (!req?.user && operation !== 'findAll') return false;
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
beforeCreate: async ({ req, params, itemData }) => {
|
|
170
|
+
const userId = req?.user?.sub ?? req?.user?.id;
|
|
171
|
+
const eventId = params?.eventId;
|
|
172
|
+
if (!userId || !eventId) throw new UnauthorizedException();
|
|
173
|
+
|
|
174
|
+
await policies.assertCanEditEvent(eventId, userId);
|
|
175
|
+
itemData.eventId = eventId;
|
|
176
|
+
itemData.status ??= 'pending';
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
beforeFindAll: async ({ req, params, where }) => {
|
|
180
|
+
const userId = req?.user?.sub ?? req?.user?.id;
|
|
181
|
+
await policies.assertCanAccessEvent(params?.eventId, userId);
|
|
182
|
+
where.eventId = params?.eventId;
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
canUpdate: async ({ req, params }) => {
|
|
186
|
+
const userId = req?.user?.sub ?? req?.user?.id;
|
|
187
|
+
await policies.assertCanEditEvent(params?.eventId, userId);
|
|
188
|
+
return true;
|
|
189
|
+
},
|
|
107
190
|
};
|
|
108
191
|
```
|
|
109
192
|
|
|
193
|
+
Hook context includes:
|
|
194
|
+
|
|
195
|
+
- `req`, `params`, `query`
|
|
196
|
+
- `operation`, `id`
|
|
197
|
+
- `itemData` (mutable create/update payload)
|
|
198
|
+
- `where` (mutable filter scope for read/list operations)
|
|
199
|
+
- `service`, `repository`
|
|
200
|
+
- `entity`, `result` (when available)
|
|
201
|
+
- `setMeta(key, value)` / `getMeta(key)` for cross-hook metadata
|
|
202
|
+
|
|
203
|
+
### Endpoint Disabling (`operations`)
|
|
204
|
+
|
|
205
|
+
For `EntityCrudController` and `ExtraCrudController`, `operations` supports these keys:
|
|
206
|
+
|
|
207
|
+
- `create`
|
|
208
|
+
- `findAll`
|
|
209
|
+
- `findOne`
|
|
210
|
+
- `update`
|
|
211
|
+
- `delete` (soft-delete)
|
|
212
|
+
- `restore`
|
|
213
|
+
- `findAllArchived`
|
|
214
|
+
|
|
215
|
+
For `RelationCrudController`, `operations` supports these keys:
|
|
216
|
+
|
|
217
|
+
- `bulkSaveFirst`
|
|
218
|
+
- `bulkSaveSecond`
|
|
219
|
+
- `findAllFirst`
|
|
220
|
+
- `findAllSecond`
|
|
221
|
+
|
|
222
|
+
Each operation can be configured as:
|
|
223
|
+
|
|
224
|
+
- `'hide'` — route is not registered (typically `404`)
|
|
225
|
+
- `'block'` — route is registered but denied with a consistent `403`
|
|
226
|
+
|
|
110
227
|
### Request Context Mapping
|
|
111
228
|
|
|
112
229
|
`@zola_do/crud` supports three create-time mapping levels:
|
|
@@ -171,8 +288,20 @@ export class ProductCategoriesController extends RelationCrudController(
|
|
|
171
288
|
- **Services:** `EntityCrudService`, `RelationCrudService`, `ExtraCrudService`
|
|
172
289
|
- **Repositories:** `EntityCrudRepository`, `RelationCrudRepository`, `ExtraCrudRepository`
|
|
173
290
|
- **Context Mapping:** `CRUD_REQUEST_CONTEXT_RESOLVER`, `CrudRequestContextResolver`
|
|
291
|
+
- **Subpath entrypoints:** `@zola_do/crud/controller`, `@zola_do/crud/service`, `@zola_do/crud/repository`, `@zola_do/crud/request-context`
|
|
292
|
+
- **Root entrypoint:** `@zola_do/crud` (supported for backward compatibility)
|
|
293
|
+
|
|
294
|
+
### Optional Features
|
|
295
|
+
|
|
296
|
+
`ExceptionFilter` for Nest microservices transport is available as an optional export:
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import { ExceptionFilter } from '@zola_do/crud/optional/rpc';
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
When using this filter, install `@nestjs/microservices` in your app.
|
|
174
303
|
|
|
175
|
-
##
|
|
304
|
+
## Related Packages
|
|
176
305
|
|
|
177
306
|
- [@zola_do/collection-query](../collection-query) — Query decoding for list endpoints
|
|
178
307
|
- [@zola_do/authorization](../authorization) — Guards for protected CRUD
|
|
@@ -1,15 +1,15 @@
|
|
|
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>;
|
|
7
7
|
create(itemData: DeepPartial<TEntity>, req?: any): Promise<TEntity>;
|
|
8
|
-
findAll(q?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
|
|
8
|
+
findAll(q?: string, cursor?: string, limit?: string, direction?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
|
|
9
9
|
findOne(id: string, req?: any): Promise<TEntity | undefined>;
|
|
10
10
|
update(id: string, itemData: Partial<TEntity>, req?: any): Promise<TEntity | undefined>;
|
|
11
11
|
softDelete(id: string, req?: any): Promise<void>;
|
|
12
12
|
restore(id: string, req?: any): Promise<void>;
|
|
13
|
-
findAllArchived(q?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
|
|
13
|
+
findAllArchived(q?: string, cursor?: string, limit?: string, direction?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
@@ -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;
|
|
@@ -27,12 +43,16 @@ function EntityCrudController(options) {
|
|
|
27
43
|
async create(itemData, req) {
|
|
28
44
|
return await this.service.create(itemData, req, options);
|
|
29
45
|
}
|
|
30
|
-
async findAll(q, req) {
|
|
31
|
-
const query = (0, collection_query_1.decodeCollectionQuery)(q)
|
|
32
|
-
|
|
46
|
+
async findAll(q, cursor, limit, direction, req) {
|
|
47
|
+
const query = (0, shared_1.mergeCursorQueryParams)((0, collection_query_1.decodeCollectionQuery)(q), {
|
|
48
|
+
cursor,
|
|
49
|
+
limit,
|
|
50
|
+
direction,
|
|
51
|
+
});
|
|
52
|
+
return await this.service.findAll(query, req, options);
|
|
33
53
|
}
|
|
34
54
|
async findOne(id, req) {
|
|
35
|
-
return await this.service.findOne(id, req);
|
|
55
|
+
return await this.service.findOne(id, req, options);
|
|
36
56
|
}
|
|
37
57
|
async update(id, itemData, req) {
|
|
38
58
|
return await this.service.update(id, itemData, req, options);
|
|
@@ -43,15 +63,16 @@ function EntityCrudController(options) {
|
|
|
43
63
|
async restore(id, req) {
|
|
44
64
|
return this.service.restore(id, req, options);
|
|
45
65
|
}
|
|
46
|
-
async findAllArchived(q, req) {
|
|
47
|
-
const query = (0, collection_query_1.decodeCollectionQuery)(q)
|
|
66
|
+
async findAllArchived(q, cursor, limit, direction, req) {
|
|
67
|
+
const query = (0, shared_1.mergeCursorQueryParams)((0, collection_query_1.decodeCollectionQuery)(q), {
|
|
68
|
+
cursor,
|
|
69
|
+
limit,
|
|
70
|
+
direction,
|
|
71
|
+
});
|
|
48
72
|
return this.service.findAllArchived(query, req);
|
|
49
73
|
}
|
|
50
74
|
};
|
|
51
75
|
__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
76
|
__param(0, (0, common_1.Body)()),
|
|
56
77
|
__param(1, (0, common_1.Req)()),
|
|
57
78
|
__metadata("design:type", Function),
|
|
@@ -59,23 +80,16 @@ function EntityCrudController(options) {
|
|
|
59
80
|
__metadata("design:returntype", Promise)
|
|
60
81
|
], EntityCrudControllerHost.prototype, "create", null);
|
|
61
82
|
__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
83
|
__param(0, (0, common_1.Query)('q')),
|
|
71
|
-
__param(1, (0, common_1.
|
|
84
|
+
__param(1, (0, common_1.Query)('cursor')),
|
|
85
|
+
__param(2, (0, common_1.Query)('limit')),
|
|
86
|
+
__param(3, (0, common_1.Query)('direction')),
|
|
87
|
+
__param(4, (0, common_1.Req)()),
|
|
72
88
|
__metadata("design:type", Function),
|
|
73
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
89
|
+
__metadata("design:paramtypes", [String, String, String, String, Object]),
|
|
74
90
|
__metadata("design:returntype", Promise)
|
|
75
91
|
], EntityCrudControllerHost.prototype, "findAll", null);
|
|
76
92
|
__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
93
|
__param(0, (0, common_1.Param)('id')),
|
|
80
94
|
__param(1, (0, common_1.Req)()),
|
|
81
95
|
__metadata("design:type", Function),
|
|
@@ -83,9 +97,6 @@ function EntityCrudController(options) {
|
|
|
83
97
|
__metadata("design:returntype", Promise)
|
|
84
98
|
], EntityCrudControllerHost.prototype, "findOne", null);
|
|
85
99
|
__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
100
|
__param(0, (0, common_1.Param)('id')),
|
|
90
101
|
__param(1, (0, common_1.Body)()),
|
|
91
102
|
__param(2, (0, common_1.Req)()),
|
|
@@ -94,8 +105,6 @@ function EntityCrudController(options) {
|
|
|
94
105
|
__metadata("design:returntype", Promise)
|
|
95
106
|
], EntityCrudControllerHost.prototype, "update", null);
|
|
96
107
|
__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
108
|
__param(0, (0, common_1.Param)('id')),
|
|
100
109
|
__param(1, (0, common_1.Req)()),
|
|
101
110
|
__metadata("design:type", Function),
|
|
@@ -103,8 +112,6 @@ function EntityCrudController(options) {
|
|
|
103
112
|
__metadata("design:returntype", Promise)
|
|
104
113
|
], EntityCrudControllerHost.prototype, "softDelete", null);
|
|
105
114
|
__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
115
|
__param(0, (0, common_1.Param)('id')),
|
|
109
116
|
__param(1, (0, common_1.Req)()),
|
|
110
117
|
__metadata("design:type", Function),
|
|
@@ -112,18 +119,13 @@ function EntityCrudController(options) {
|
|
|
112
119
|
__metadata("design:returntype", Promise)
|
|
113
120
|
], EntityCrudControllerHost.prototype, "restore", null);
|
|
114
121
|
__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
122
|
__param(0, (0, common_1.Query)('q')),
|
|
124
|
-
__param(1, (0, common_1.
|
|
123
|
+
__param(1, (0, common_1.Query)('cursor')),
|
|
124
|
+
__param(2, (0, common_1.Query)('limit')),
|
|
125
|
+
__param(3, (0, common_1.Query)('direction')),
|
|
126
|
+
__param(4, (0, common_1.Req)()),
|
|
125
127
|
__metadata("design:type", Function),
|
|
126
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
128
|
+
__metadata("design:paramtypes", [String, String, String, String, Object]),
|
|
127
129
|
__metadata("design:returntype", Promise)
|
|
128
130
|
], EntityCrudControllerHost.prototype, "findAllArchived", null);
|
|
129
131
|
EntityCrudControllerHost = __decorate([
|
|
@@ -132,6 +134,120 @@ function EntityCrudController(options) {
|
|
|
132
134
|
(0, swagger_1.ApiBearerAuth)(),
|
|
133
135
|
__metadata("design:paramtypes", [service_1.EntityCrudService])
|
|
134
136
|
], EntityCrudControllerHost);
|
|
137
|
+
const createDisable = normalizeDisableConfig(operations.create);
|
|
138
|
+
if (createDisable.mode !== 'hide') {
|
|
139
|
+
const guards = createDisable.mode === 'block'
|
|
140
|
+
? [new shared_1.CrudOperationDisabledGuard('create', createDisable.reason)]
|
|
141
|
+
: [authorization_1.JwtGuard, (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.createPermission)];
|
|
142
|
+
applyMethodDecorators(EntityCrudControllerHost, 'create', [
|
|
143
|
+
(0, common_1.Post)(),
|
|
144
|
+
(0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.createDto) || extra_crud_controller_1.BaseAPIDto }),
|
|
145
|
+
(0, common_1.UseGuards)(...guards),
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
const findAllDisable = normalizeDisableConfig(operations.findAll);
|
|
149
|
+
if (findAllDisable.mode !== 'hide') {
|
|
150
|
+
applyMethodDecorators(EntityCrudControllerHost, 'findAll', [
|
|
151
|
+
(0, common_1.Get)(),
|
|
152
|
+
(0, swagger_1.ApiQuery)({
|
|
153
|
+
name: 'q',
|
|
154
|
+
type: String,
|
|
155
|
+
description: 'Collection Query Parameter. Optional',
|
|
156
|
+
required: false,
|
|
157
|
+
}),
|
|
158
|
+
(0, swagger_1.ApiQuery)({
|
|
159
|
+
name: 'cursor',
|
|
160
|
+
type: String,
|
|
161
|
+
description: 'Cursor token for seek pagination. Optional',
|
|
162
|
+
required: false,
|
|
163
|
+
}),
|
|
164
|
+
(0, swagger_1.ApiQuery)({
|
|
165
|
+
name: 'limit',
|
|
166
|
+
type: Number,
|
|
167
|
+
description: 'Cursor page size. Optional',
|
|
168
|
+
required: false,
|
|
169
|
+
}),
|
|
170
|
+
(0, swagger_1.ApiQuery)({
|
|
171
|
+
name: 'direction',
|
|
172
|
+
type: String,
|
|
173
|
+
description: 'Cursor direction (n|p, also accepts next|prev). Optional',
|
|
174
|
+
required: false,
|
|
175
|
+
}),
|
|
176
|
+
(0, common_1.UseGuards)(findAllDisable.mode === 'block'
|
|
177
|
+
? new shared_1.CrudOperationDisabledGuard('findAll')
|
|
178
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewPermission)),
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
const findOneDisable = normalizeDisableConfig(operations.findOne);
|
|
182
|
+
if (findOneDisable.mode !== 'hide') {
|
|
183
|
+
applyMethodDecorators(EntityCrudControllerHost, 'findOne', [
|
|
184
|
+
(0, common_1.Get)(':id'),
|
|
185
|
+
(0, common_1.UseGuards)(findOneDisable.mode === 'block'
|
|
186
|
+
? new shared_1.CrudOperationDisabledGuard('findOne')
|
|
187
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewPermission)),
|
|
188
|
+
]);
|
|
189
|
+
}
|
|
190
|
+
const updateDisable = normalizeDisableConfig(operations.update);
|
|
191
|
+
if (updateDisable.mode !== 'hide') {
|
|
192
|
+
applyMethodDecorators(EntityCrudControllerHost, 'update', [
|
|
193
|
+
(0, common_1.Put)(':id'),
|
|
194
|
+
(0, swagger_1.ApiBody)({ type: (options === null || options === void 0 ? void 0 : options.updateDto) || extra_crud_controller_1.BaseAPIDto }),
|
|
195
|
+
(0, common_1.UseGuards)(updateDisable.mode === 'block'
|
|
196
|
+
? new shared_1.CrudOperationDisabledGuard('update')
|
|
197
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.updatePermission)),
|
|
198
|
+
]);
|
|
199
|
+
}
|
|
200
|
+
const deleteDisable = normalizeDisableConfig(operations.delete);
|
|
201
|
+
if (deleteDisable.mode !== 'hide') {
|
|
202
|
+
applyMethodDecorators(EntityCrudControllerHost, 'softDelete', [
|
|
203
|
+
(0, common_1.Delete)(':id'),
|
|
204
|
+
(0, common_1.UseGuards)(deleteDisable.mode === 'block'
|
|
205
|
+
? new shared_1.CrudOperationDisabledGuard('delete')
|
|
206
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.deletePermission)),
|
|
207
|
+
]);
|
|
208
|
+
}
|
|
209
|
+
const restoreDisable = normalizeDisableConfig(operations.restore);
|
|
210
|
+
if (restoreDisable.mode !== 'hide') {
|
|
211
|
+
applyMethodDecorators(EntityCrudControllerHost, 'restore', [
|
|
212
|
+
(0, common_1.Patch)('restore/:id'),
|
|
213
|
+
(0, common_1.UseGuards)(restoreDisable.mode === 'block'
|
|
214
|
+
? new shared_1.CrudOperationDisabledGuard('restore')
|
|
215
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.restorePermission)),
|
|
216
|
+
]);
|
|
217
|
+
}
|
|
218
|
+
const archivedDisable = normalizeDisableConfig(operations.findAllArchived);
|
|
219
|
+
if (archivedDisable.mode !== 'hide') {
|
|
220
|
+
applyMethodDecorators(EntityCrudControllerHost, 'findAllArchived', [
|
|
221
|
+
(0, common_1.Get)('/archived/items'),
|
|
222
|
+
(0, common_1.UseGuards)(archivedDisable.mode === 'block'
|
|
223
|
+
? new shared_1.CrudOperationDisabledGuard('findAllArchived')
|
|
224
|
+
: (0, authorization_1.PermissionsGuard)(options === null || options === void 0 ? void 0 : options.viewArchivedPermission)),
|
|
225
|
+
(0, swagger_1.ApiQuery)({
|
|
226
|
+
name: 'q',
|
|
227
|
+
type: String,
|
|
228
|
+
description: 'Collection Query Parameter. Optional',
|
|
229
|
+
required: false,
|
|
230
|
+
}),
|
|
231
|
+
(0, swagger_1.ApiQuery)({
|
|
232
|
+
name: 'cursor',
|
|
233
|
+
type: String,
|
|
234
|
+
description: 'Cursor token for seek pagination. Optional',
|
|
235
|
+
required: false,
|
|
236
|
+
}),
|
|
237
|
+
(0, swagger_1.ApiQuery)({
|
|
238
|
+
name: 'limit',
|
|
239
|
+
type: Number,
|
|
240
|
+
description: 'Cursor page size. Optional',
|
|
241
|
+
required: false,
|
|
242
|
+
}),
|
|
243
|
+
(0, swagger_1.ApiQuery)({
|
|
244
|
+
name: 'direction',
|
|
245
|
+
type: String,
|
|
246
|
+
description: 'Cursor direction (n|p, also accepts next|prev). Optional',
|
|
247
|
+
required: false,
|
|
248
|
+
}),
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
135
251
|
return EntityCrudControllerHost;
|
|
136
252
|
}
|
|
137
253
|
//# 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":";;;;;;;;;;;;;;AA6BA,oDAmOC;AAhQD,2CAawB;AACxB,wCAA+C;AAE/C,6CAAmE;AACnE,mEAAqD;AACrD,sCAOmB;AACnB,gEAAkE;AAClE,0DAAoE;AAEpE,SAAgB,oBAAoB,CAClC,OAA2B;;IAE3B,MAAM,UAAU,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,mCAAI,EAAE,CAAC;IAE7C,MAAM,sBAAsB,GAAG,CAC7B,MAAkC,EACmB,EAAE;QACvD,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QACvB,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACxD,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACtD,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAAG,CAC5B,IAAS,EACT,UAAkB,EAClB,UAAs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BACzC,QAAQ,EAAE,KAAK;aAChB,CAAC;YACF,IAAA,kBAAQ,EAAC;gBACP,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,0DAA0D;gBACvE,QAAQ,EAAE,KAAK;aAChB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
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): {
|
|
7
7
|
new (service: ExtraCrudService<TEntity>): {
|
|
8
8
|
readonly service: ExtraCrudService<TEntity>;
|
|
9
9
|
create(itemData: DeepPartial<TEntity>, req?: any): Promise<TEntity>;
|
|
10
|
-
findAll(id: string, q: string, req?: any): Promise<DataResponseFormat<TEntity>>;
|
|
10
|
+
findAll(id: string, q: string, cursor?: string, limit?: string, direction?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
|
|
11
11
|
findOne(id: string, req?: any): Promise<TEntity | undefined>;
|
|
12
12
|
update(id: string, itemData: Partial<TEntity>, req?: any): Promise<TEntity | undefined>;
|
|
13
13
|
softDelete(id: string, req?: any): Promise<void>;
|
|
14
14
|
restore(id: string, req?: any): Promise<void>;
|
|
15
|
-
findAllArchived(id: string, q?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
|
|
15
|
+
findAllArchived(id: string, q?: string, cursor?: string, limit?: string, direction?: string, req?: any): Promise<DataResponseFormat<TEntity>>;
|
|
16
16
|
};
|
|
17
17
|
};
|