@mee4dy/crud-nestjs 1.0.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/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +5 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/crud.controller.d.ts +22 -0
- package/dist/crud.controller.js +134 -0
- package/dist/crud.controller.js.map +1 -0
- package/dist/crud.service.d.ts +15 -0
- package/dist/crud.service.js +55 -0
- package/dist/crud.service.js.map +1 -0
- package/dist/decorators/crud-params.decorator.d.ts +5 -0
- package/dist/decorators/crud-params.decorator.js +53 -0
- package/dist/decorators/crud-params.decorator.js.map +1 -0
- package/dist/decorators/crud.decorator.d.ts +3 -0
- package/dist/decorators/crud.decorator.js +77 -0
- package/dist/decorators/crud.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.js +19 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/exceptions/endpoint-disabled.exception.d.ts +4 -0
- package/dist/exceptions/endpoint-disabled.exception.js +14 -0
- package/dist/exceptions/endpoint-disabled.exception.js.map +1 -0
- package/dist/filters/crud-exception.filter.d.ts +4 -0
- package/dist/filters/crud-exception.filter.js +48 -0
- package/dist/filters/crud-exception.filter.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/services/crud-params-adapter.service.d.ts +14 -0
- package/dist/services/crud-params-adapter.service.js +147 -0
- package/dist/services/crud-params-adapter.service.js.map +1 -0
- package/dist/services/query-params-extractor.service.d.ts +14 -0
- package/dist/services/query-params-extractor.service.js +112 -0
- package/dist/services/query-params-extractor.service.js.map +1 -0
- package/dist/types/crud-config.types.d.ts +25 -0
- package/dist/types/crud-config.types.js +3 -0
- package/dist/types/crud-config.types.js.map +1 -0
- package/dist/types/crud-params.types.d.ts +40 -0
- package/dist/types/crud-params.types.js +3 -0
- package/dist/types/crud-params.types.js.map +1 -0
- package/dist/types/crud-query.types.d.ts +16 -0
- package/dist/types/crud-query.types.js +3 -0
- package/dist/types/crud-query.types.js.map +1 -0
- package/dist/types/crud-response.types.d.ts +9 -0
- package/dist/types/crud-response.types.js +3 -0
- package/dist/types/crud-response.types.js.map +1 -0
- package/dist/utils/merge.util.d.ts +1 -0
- package/dist/utils/merge.util.js +45 -0
- package/dist/utils/merge.util.js.map +1 -0
- package/dist/utils/replace-pk.util.d.ts +1 -0
- package/dist/utils/replace-pk.util.js +25 -0
- package/dist/utils/replace-pk.util.js.map +1 -0
- package/package.json +34 -0
- package/readme.md +426 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PK = "pk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,EAAE,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CrudConfig } from './types/crud-config.types';
|
|
2
|
+
import { CrudService } from './crud.service';
|
|
3
|
+
import { CrudParams } from './types/crud-params.types';
|
|
4
|
+
import { Model } from 'sequelize';
|
|
5
|
+
import 'reflect-metadata';
|
|
6
|
+
import { CrudResponse } from './types/crud-response.types';
|
|
7
|
+
export declare class CrudController<T extends Model> {
|
|
8
|
+
constructor();
|
|
9
|
+
protected service: CrudService<T>;
|
|
10
|
+
protected config: CrudConfig;
|
|
11
|
+
private checkEndpoint;
|
|
12
|
+
items(params: CrudParams): Promise<CrudResponse>;
|
|
13
|
+
item(params: CrudParams): Promise<{
|
|
14
|
+
status: boolean;
|
|
15
|
+
data: {
|
|
16
|
+
item: T;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
create(data: object): Promise<CrudResponse>;
|
|
20
|
+
update(params: CrudParams, data: object): Promise<CrudResponse>;
|
|
21
|
+
delete(params: CrudParams): Promise<CrudResponse>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
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.CrudController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const crud_service_1 = require("./crud.service");
|
|
18
|
+
require("reflect-metadata");
|
|
19
|
+
const crud_params_decorator_1 = require("./decorators/crud-params.decorator");
|
|
20
|
+
const crud_exception_filter_1 = require("./filters/crud-exception.filter");
|
|
21
|
+
const endpoint_disabled_exception_1 = require("./exceptions/endpoint-disabled.exception");
|
|
22
|
+
class CrudController {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.config = Reflect.getMetadata('crud:config', this.constructor);
|
|
25
|
+
this.service = new crud_service_1.CrudService(this.config.repository(), this.config.pk);
|
|
26
|
+
}
|
|
27
|
+
checkEndpoint(endpoint) {
|
|
28
|
+
var _a;
|
|
29
|
+
return !!((_a = this.config.endpoints) === null || _a === void 0 ? void 0 : _a[endpoint]);
|
|
30
|
+
}
|
|
31
|
+
async items(params) {
|
|
32
|
+
if (!this.checkEndpoint('items')) {
|
|
33
|
+
throw new endpoint_disabled_exception_1.EndpointDisabledException('items');
|
|
34
|
+
}
|
|
35
|
+
const items = await this.service.getItems(params);
|
|
36
|
+
return {
|
|
37
|
+
status: true,
|
|
38
|
+
data: {
|
|
39
|
+
items: items,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async item(params) {
|
|
44
|
+
if (!this.checkEndpoint('item')) {
|
|
45
|
+
throw new endpoint_disabled_exception_1.EndpointDisabledException('item');
|
|
46
|
+
}
|
|
47
|
+
const item = await this.service.getItem(params);
|
|
48
|
+
return {
|
|
49
|
+
status: true,
|
|
50
|
+
data: {
|
|
51
|
+
item: item,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async create(data) {
|
|
56
|
+
if (!this.checkEndpoint('create')) {
|
|
57
|
+
throw new endpoint_disabled_exception_1.EndpointDisabledException('create');
|
|
58
|
+
}
|
|
59
|
+
const item = await this.service.create(data);
|
|
60
|
+
return {
|
|
61
|
+
status: true,
|
|
62
|
+
data: {
|
|
63
|
+
item: item,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async update(params, data) {
|
|
68
|
+
if (!this.checkEndpoint('update')) {
|
|
69
|
+
throw new endpoint_disabled_exception_1.EndpointDisabledException('update');
|
|
70
|
+
}
|
|
71
|
+
const item = await this.service.update(params, data);
|
|
72
|
+
return {
|
|
73
|
+
status: true,
|
|
74
|
+
data: {
|
|
75
|
+
item: item,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async delete(params) {
|
|
80
|
+
if (!this.checkEndpoint('delete')) {
|
|
81
|
+
throw new endpoint_disabled_exception_1.EndpointDisabledException('delete');
|
|
82
|
+
}
|
|
83
|
+
const result = await this.service.delete(params);
|
|
84
|
+
return {
|
|
85
|
+
status: true,
|
|
86
|
+
data: {
|
|
87
|
+
result: result,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.CrudController = CrudController;
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, common_1.Get)('/'),
|
|
95
|
+
(0, common_1.UseFilters)(crud_exception_filter_1.CrudExceptionFilter),
|
|
96
|
+
__param(0, (0, crud_params_decorator_1.CrudParamsDecorator)()),
|
|
97
|
+
__metadata("design:type", Function),
|
|
98
|
+
__metadata("design:paramtypes", [Object]),
|
|
99
|
+
__metadata("design:returntype", Promise)
|
|
100
|
+
], CrudController.prototype, "items", null);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, common_1.Get)('/:pk'),
|
|
103
|
+
(0, common_1.UseFilters)(crud_exception_filter_1.CrudExceptionFilter),
|
|
104
|
+
__param(0, (0, crud_params_decorator_1.CrudParamsDecorator)()),
|
|
105
|
+
__metadata("design:type", Function),
|
|
106
|
+
__metadata("design:paramtypes", [Object]),
|
|
107
|
+
__metadata("design:returntype", Promise)
|
|
108
|
+
], CrudController.prototype, "item", null);
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, common_1.Post)('/'),
|
|
111
|
+
(0, common_1.UseFilters)(crud_exception_filter_1.CrudExceptionFilter),
|
|
112
|
+
__param(0, (0, common_1.Body)('data')),
|
|
113
|
+
__metadata("design:type", Function),
|
|
114
|
+
__metadata("design:paramtypes", [Object]),
|
|
115
|
+
__metadata("design:returntype", Promise)
|
|
116
|
+
], CrudController.prototype, "create", null);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, common_1.Put)('/:pk'),
|
|
119
|
+
(0, common_1.UseFilters)(crud_exception_filter_1.CrudExceptionFilter),
|
|
120
|
+
__param(0, (0, crud_params_decorator_1.CrudParamsDecorator)()),
|
|
121
|
+
__param(1, (0, common_1.Body)('data')),
|
|
122
|
+
__metadata("design:type", Function),
|
|
123
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
124
|
+
__metadata("design:returntype", Promise)
|
|
125
|
+
], CrudController.prototype, "update", null);
|
|
126
|
+
__decorate([
|
|
127
|
+
(0, common_1.Delete)('/:pk'),
|
|
128
|
+
(0, common_1.UseFilters)(crud_exception_filter_1.CrudExceptionFilter),
|
|
129
|
+
__param(0, (0, crud_params_decorator_1.CrudParamsDecorator)()),
|
|
130
|
+
__metadata("design:type", Function),
|
|
131
|
+
__metadata("design:paramtypes", [Object]),
|
|
132
|
+
__metadata("design:returntype", Promise)
|
|
133
|
+
], CrudController.prototype, "delete", null);
|
|
134
|
+
//# sourceMappingURL=crud.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.controller.js","sourceRoot":"","sources":["../src/crud.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoG;AAEpG,iDAA6C;AAG7C,4BAA0B;AAC1B,8EAAyE;AAEzE,2EAAsE;AACtE,0FAAqF;AAErF,MAAa,cAAc;IACzB;QACE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAe,CAAC;QACjF,IAAI,CAAC,OAAO,GAAG,IAAI,0BAAW,CAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;IAKO,aAAa,CAAC,QAA2D;;QAC/E,OAAO,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,MAAM,CAAC,SAAS,0CAAG,QAAQ,CAAC,CAAA,CAAC;IAC7C,CAAC;IAIK,AAAN,KAAK,CAAC,KAAK,CAAwB,MAAkB;QACnD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,uDAAyB,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAElD,OAAO;YACL,MAAM,EAAE,I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AAkB;QACpD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,uDAAyB,CAAC,QAAQ,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEjD,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE;gBACJ,MAAM,EAAE,MAAM;aACf;SACF,CAAC;IACJ,CAAC;CACF;AAjGD,wCAiGC;AAlFO;IAFL,IAAA,YAAG,EAAC,GAAG,CAAC;IACR,IAAA,mBAAU,EAAC,2CAAmB,CAAC;IACnB,WAAA,IAAA,2CAAmB,GAAE,CAAA;;;;2CAajC;AAIK;IAFL,IAAA,YAAG,EAAC,MAAM,CAAC;IACX,IAAA,mBAAU,EAAC,2CAAmB,CAAC;IACpB,WAAA,IAAA,2CAAmB,GAAE,CAAA;;;;0CAahC;AAIK;IAFL,IAAA,aAAI,EAAC,GAAG,CAAC;IACT,IAAA,mBAAU,EAAC,2CAAmB,CAAC;IAClB,WAAA,IAAA,aAAI,EAAC,MAAM,CAAC,CAAA;;;;4CAazB;AAIK;IAFL,IAAA,YAAG,EAAC,MAAM,CAAC;IACX,IAAA,mBAAU,EAAC,2CAAmB,CAAC;IAClB,WAAA,IAAA,2CAAmB,GAAE,CAAA;IAAsB,WAAA,IAAA,aAAI,EAAC,MAAM,CAAC,CAAA;;;;4CAapE;AAIK;IAFL,IAAA,eAAM,EAAC,MAAM,CAAC;IACd,IAAA,mBAAU,EAAC,2CAAmB,CAAC;IAClB,WAAA,IAAA,2CAAmB,GAAE,CAAA;;;;4CAalC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Model, ModelStatic } from 'sequelize';
|
|
2
|
+
import { CrudParams } from './types/crud-params.types';
|
|
3
|
+
export declare class CrudService<T extends Model> {
|
|
4
|
+
constructor(model: ModelStatic<T>, pk?: string);
|
|
5
|
+
protected pk: string;
|
|
6
|
+
protected repository: ModelStatic<T>;
|
|
7
|
+
getPK(): string;
|
|
8
|
+
getRepository(): ModelStatic<T>;
|
|
9
|
+
private paramsProcessor;
|
|
10
|
+
getItems(params: CrudParams): Promise<T[]>;
|
|
11
|
+
getItem(params: CrudParams): Promise<T>;
|
|
12
|
+
create(data: object): Promise<T>;
|
|
13
|
+
update(params: CrudParams, data: object, returning?: boolean): Promise<any>;
|
|
14
|
+
delete(params: CrudParams): Promise<number>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudService = void 0;
|
|
4
|
+
const crud_params_adapter_service_1 = require("./services/crud-params-adapter.service");
|
|
5
|
+
const replace_pk_util_1 = require("./utils/replace-pk.util");
|
|
6
|
+
class CrudService {
|
|
7
|
+
constructor(model, pk = 'id') {
|
|
8
|
+
this.repository = model;
|
|
9
|
+
this.pk = pk;
|
|
10
|
+
}
|
|
11
|
+
getPK() {
|
|
12
|
+
return this.pk;
|
|
13
|
+
}
|
|
14
|
+
getRepository() {
|
|
15
|
+
return this.repository;
|
|
16
|
+
}
|
|
17
|
+
paramsProcessor(params) {
|
|
18
|
+
const processedParams = (0, replace_pk_util_1.replacePkRecursive)(params, this.pk);
|
|
19
|
+
return new crud_params_adapter_service_1.CrudParamsAdapterService(processedParams).adapt();
|
|
20
|
+
}
|
|
21
|
+
getItems(params) {
|
|
22
|
+
const processedParams = this.paramsProcessor(params);
|
|
23
|
+
return this.repository.findAll(processedParams);
|
|
24
|
+
}
|
|
25
|
+
getItem(params) {
|
|
26
|
+
const processedParams = this.paramsProcessor(params);
|
|
27
|
+
return this.repository.findOne(processedParams);
|
|
28
|
+
}
|
|
29
|
+
create(data) {
|
|
30
|
+
return this.repository.create(data, {
|
|
31
|
+
returning: true,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async update(params, data, returning = true) {
|
|
35
|
+
const processedParams = this.paramsProcessor(params);
|
|
36
|
+
return this.repository
|
|
37
|
+
.update(data, {
|
|
38
|
+
where: processedParams.where,
|
|
39
|
+
})
|
|
40
|
+
.then((result) => {
|
|
41
|
+
if (returning) {
|
|
42
|
+
return this.getItem(params);
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
delete(params) {
|
|
48
|
+
const processedParams = this.paramsProcessor(params);
|
|
49
|
+
return this.repository.destroy({
|
|
50
|
+
where: processedParams.where,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.CrudService = CrudService;
|
|
55
|
+
//# sourceMappingURL=crud.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.service.js","sourceRoot":"","sources":["../src/crud.service.ts"],"names":[],"mappings":";;;AAEA,wFAAkF;AAClF,6DAA6D;AAE7D,MAAa,WAAW;IACtB,YAAY,KAAqB,EAAE,KAAa,IAAI;QAClD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAKM,KAAK;QACV,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEO,eAAe,CAAC,MAAkB;QACxC,MAAM,eAAe,GAAG,IAAA,oCAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5D,OAAO,IAAI,sDAAwB,CAAC,eAAe,CAAC,CAAC,KAAK,EAAE,CAAC;IAC/D,CAAC;IAEM,QAAQ,CAAC,MAAkB;QAChC,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAClD,CAAC;IAEM,OAAO,CAAC,MAAkB;QAC/B,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAClD,CAAC;IAEM,MAAM,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAW,EAAE;YACzC,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,MAAkB,EAAE,IAAY,EAAE,YAAqB,IAAI;QAC7E,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,UAAU;aACnB,MAAM,CAAC,IAAI,EAAE;YACZ,KAAK,EAAE,eAAe,CAAC,KAAK;SAC7B,CAAC;aACD,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;YACpB,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC9B,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,MAAM,CAAC,MAAkB;QAC9B,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YAC7B,KAAK,EAAE,eAAe,CAAC,KAAK;SAC7B,CAAC,CAAC;IACL,CAAC;CACF;AA1DD,kCA0DC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CrudQueryAllowedParams } from '../types/crud-query.types';
|
|
2
|
+
import 'reflect-metadata';
|
|
3
|
+
export declare const CrudParamsDecorator: (...dataOrPipes: ({
|
|
4
|
+
allowedParams?: CrudQueryAllowedParams;
|
|
5
|
+
} | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CrudParamsDecorator = void 0;
|
|
7
|
+
const common_1 = require("@nestjs/common");
|
|
8
|
+
const query_params_extractor_service_1 = require("../services/query-params-extractor.service");
|
|
9
|
+
const merge_util_1 = require("../utils/merge.util");
|
|
10
|
+
const qs_1 = __importDefault(require("qs"));
|
|
11
|
+
require("reflect-metadata");
|
|
12
|
+
const replace_pk_util_1 = require("../utils/replace-pk.util");
|
|
13
|
+
const constants_1 = require("../constants");
|
|
14
|
+
exports.CrudParamsDecorator = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
const request = ctx.switchToHttp().getRequest();
|
|
17
|
+
const pkValue = (_a = request.params) === null || _a === void 0 ? void 0 : _a[constants_1.PK];
|
|
18
|
+
const config = Reflect.getMetadata('crud:config', ctx.getClass());
|
|
19
|
+
const pk = config.pk;
|
|
20
|
+
const defaultParams = ((_b = config === null || config === void 0 ? void 0 : config.params) === null || _b === void 0 ? void 0 : _b.default) || {};
|
|
21
|
+
let params = {};
|
|
22
|
+
if (pkValue !== undefined) {
|
|
23
|
+
params = (0, merge_util_1.merge)(params, {
|
|
24
|
+
filters: {
|
|
25
|
+
[constants_1.PK]: pkValue,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const query = qs_1.default.parse(request.query);
|
|
30
|
+
const queryAllowedParams = ((_c = config === null || config === void 0 ? void 0 : config.query) === null || _c === void 0 ? void 0 : _c.allowedParams) || {};
|
|
31
|
+
const extractor = new query_params_extractor_service_1.QueryParamsExtractorService((0, replace_pk_util_1.replacePkRecursive)(query, pk), (0, replace_pk_util_1.replacePkRecursive)(queryAllowedParams, pk));
|
|
32
|
+
const queryParams = extractor.extract();
|
|
33
|
+
let scopesParams = {};
|
|
34
|
+
const scopes = (config === null || config === void 0 ? void 0 : config.scopes) || {};
|
|
35
|
+
let crudEndpoint = ctx.getHandler().name;
|
|
36
|
+
if (scopes.global) {
|
|
37
|
+
const scopeResult = scopes.global(request);
|
|
38
|
+
if (scopeResult && scopeResult.params) {
|
|
39
|
+
scopesParams = (0, merge_util_1.merge)(scopesParams, scopeResult.params);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (crudEndpoint && scopes[crudEndpoint]) {
|
|
43
|
+
const scopeResult = scopes[crudEndpoint](request);
|
|
44
|
+
if (scopeResult && scopeResult.params) {
|
|
45
|
+
scopesParams = (0, merge_util_1.merge)(scopesParams, scopeResult.params);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return (0, merge_util_1.merge)({
|
|
49
|
+
...(0, replace_pk_util_1.replacePkRecursive)(defaultParams, pk),
|
|
50
|
+
...(0, merge_util_1.merge)((0, replace_pk_util_1.replacePkRecursive)(params, pk), (0, replace_pk_util_1.replacePkRecursive)(scopesParams, pk)),
|
|
51
|
+
}, (0, replace_pk_util_1.replacePkRecursive)(queryParams, pk));
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=crud-params.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud-params.decorator.js","sourceRoot":"","sources":["../../src/decorators/crud-params.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAwE;AAExE,+FAAyF;AACzF,oDAA4C;AAC5C,4CAAoB;AACpB,4BAA0B;AAC1B,8DAA8D;AAC9D,4CAAkC;AAGrB,QAAA,mBAAmB,GAAG,IAAA,6BAAoB,EACrD,CAAC,IAAgD,EAAE,GAAqB,EAAE,EAAE;;IAC1E,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IA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AAO,CAAC,CAAC;QAC3C,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACtC,YAAY,GAAG,IAAA,kBAAK,EAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,IAAI,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QACzC,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACtC,YAAY,GAAG,IAAA,kBAAK,EAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,OAAO,IAAA,kBAAK,EACV;QACE,GAAG,IAAA,oCAAkB,EAAC,aAAa,EAAE,EAAE,CAAC;QACxC,GAAG,IAAA,kBAAK,EAAC,IAAA,oCAAkB,EAAC,MAAM,EAAE,EAAE,CAAC,EAAE,IAAA,oCAAkB,EAAC,YAAY,EAAE,EAAE,CAAC,CAAC;KAC/E,EACD,IAAA,oCAAkB,EAAC,WAAW,EAAE,EAAE,CAAC,CACpC,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Crud = Crud;
|
|
37
|
+
require("reflect-metadata");
|
|
38
|
+
const constants_1 = require("../constants");
|
|
39
|
+
const _ = __importStar(require("lodash"));
|
|
40
|
+
function Crud(config) {
|
|
41
|
+
return function (target) {
|
|
42
|
+
const defaultConfig = {
|
|
43
|
+
pk: 'id',
|
|
44
|
+
endpoints: {
|
|
45
|
+
meta: true,
|
|
46
|
+
items: true,
|
|
47
|
+
item: true,
|
|
48
|
+
create: false,
|
|
49
|
+
update: false,
|
|
50
|
+
delete: false,
|
|
51
|
+
},
|
|
52
|
+
query: {
|
|
53
|
+
allowedParams: {
|
|
54
|
+
filters: [constants_1.PK],
|
|
55
|
+
orders: [constants_1.PK],
|
|
56
|
+
groups: [constants_1.PK],
|
|
57
|
+
limit: false,
|
|
58
|
+
offset: false,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
params: {
|
|
62
|
+
default: {
|
|
63
|
+
limit: 10,
|
|
64
|
+
orders: [[constants_1.PK, 'desc']],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const finalConfig = _.mergeWith({}, defaultConfig, config, (objValue, srcValue, key) => {
|
|
69
|
+
const overrideDefaultKeys = ['filters', 'orders', 'groups'];
|
|
70
|
+
if (overrideDefaultKeys.includes(key)) {
|
|
71
|
+
return srcValue;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
Reflect.defineMetadata('crud:config', finalConfig, target);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=crud.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.decorator.js","sourceRoot":"","sources":["../../src/decorators/crud.decorator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,oBAuCC;AA3CD,4BAA0B;AAC1B,4CAAkC;AAClC,0CAA4B;AAE5B,SAAgB,IAAI,CAAC,MAAkB;IACrC,OAAO,UAAU,MAAW;QAC1B,MAAM,aAAa,GAAmC;YACpD,EAAE,EAAE,IAAI;YACR,SAAS,EAAE;gBACT,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,KAAK;aACd;YACD,KAAK,EAAE;gBACL,aAAa,EAAE;oBACb,OAAO,EAAE,CAAC,cAAE,CAAC;oBACb,MAAM,EAAE,CAAC,cAAE,CAAC;oBACZ,MAAM,EAAE,CAAC,cAAE,CAAC;oBACZ,KAAK,EAAE,KAAK;oBACZ,MAAM,EAAE,KAAK;iBACd;aACF;YACD,MAAM,EAAE;gBACN,OAAO,EAAE;oBACP,KAAK,EAAE,EAAE;oBACT,MAAM,EAAE,CAAC,CAAC,cAAE,EAAE,MAAM,CAAC,CAAC;iBACvB;aACF;SACF,CAAC;QAEF,MAAM,WAAW,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE;YACrF,MAAM,mBAAmB,GAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAEtE,IAAI,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACtC,OAAO,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./crud.decorator"), exports);
|
|
18
|
+
__exportStar(require("./crud-params.decorator"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,0DAAwC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EndpointDisabledException = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
class EndpointDisabledException extends common_1.HttpException {
|
|
6
|
+
constructor(endpoint) {
|
|
7
|
+
super({
|
|
8
|
+
message: `Endpoint "${endpoint}" is disabled`,
|
|
9
|
+
errorType: 'EndpointDisabled',
|
|
10
|
+
}, common_1.HttpStatus.FORBIDDEN);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.EndpointDisabledException = EndpointDisabledException;
|
|
14
|
+
//# sourceMappingURL=endpoint-disabled.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-disabled.exception.js","sourceRoot":"","sources":["../../src/exceptions/endpoint-disabled.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAE3D,MAAa,yBAA0B,SAAQ,sBAAa;IAC1D,YAAY,QAAgB;QAC1B,KAAK,CACH;YACE,OAAO,EAAE,aAAa,QAAQ,eAAe;YAC7C,SAAS,EAAE,kBAAkB;SAC9B,EACD,mBAAU,CAAC,SAAS,CACrB,CAAC;IACJ,CAAC;CACF;AAVD,8DAUC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CrudExceptionFilter = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
let CrudExceptionFilter = class CrudExceptionFilter {
|
|
12
|
+
catch(exception, host) {
|
|
13
|
+
const ctx = host.switchToHttp();
|
|
14
|
+
const response = ctx.getResponse();
|
|
15
|
+
let status = 500;
|
|
16
|
+
let message = 'Internal server error';
|
|
17
|
+
let errorType = 'InternalError';
|
|
18
|
+
if (exception instanceof common_1.HttpException) {
|
|
19
|
+
status = exception.getStatus();
|
|
20
|
+
const res = exception.getResponse();
|
|
21
|
+
if (typeof res === 'string') {
|
|
22
|
+
message = res;
|
|
23
|
+
}
|
|
24
|
+
else if (typeof res === 'object' && res !== null) {
|
|
25
|
+
message = res.message || message;
|
|
26
|
+
errorType = res.error || errorType;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (exception instanceof Error) {
|
|
30
|
+
message = exception.message;
|
|
31
|
+
errorType = exception.name;
|
|
32
|
+
}
|
|
33
|
+
const result = {
|
|
34
|
+
status: false,
|
|
35
|
+
error: {
|
|
36
|
+
message,
|
|
37
|
+
statusCode: status,
|
|
38
|
+
errorType,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
response.status(status).json(result);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.CrudExceptionFilter = CrudExceptionFilter;
|
|
45
|
+
exports.CrudExceptionFilter = CrudExceptionFilter = __decorate([
|
|
46
|
+
(0, common_1.Catch)()
|
|
47
|
+
], CrudExceptionFilter);
|
|
48
|
+
//# sourceMappingURL=crud-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud-exception.filter.js","sourceRoot":"","sources":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IAAA,cAAK,GAAE;GACK,mBAAmB,CAkC/B"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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("./crud.controller"), exports);
|
|
18
|
+
__exportStar(require("./decorators"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,+CAA6B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FindOptions } from 'sequelize';
|
|
2
|
+
import { CrudParams } from '../types/crud-params.types';
|
|
3
|
+
export declare class CrudParamsAdapterService {
|
|
4
|
+
private params;
|
|
5
|
+
constructor(params: CrudParams);
|
|
6
|
+
adapt(): FindOptions;
|
|
7
|
+
private getInclude;
|
|
8
|
+
private getAttributes;
|
|
9
|
+
private getWhere;
|
|
10
|
+
private getGroup;
|
|
11
|
+
private getOrder;
|
|
12
|
+
private getLimit;
|
|
13
|
+
private getOffset;
|
|
14
|
+
}
|