@recursyve/nestjs-data-filter 11.1.3 → 11.2.1
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/lib/filter/controllers/open-api-dynamic-filter.controller.d.ts +8 -0
- package/lib/filter/controllers/open-api-dynamic-filter.controller.js +127 -0
- package/lib/filter/controllers/open-api-filter.controller.js +1 -1
- package/lib/filter/index.d.ts +1 -0
- package/lib/filter/index.js +1 -0
- package/lib/filter/models/rule.model.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Type } from "@nestjs/common";
|
|
2
|
+
import { ApiParamOptions } from "@nestjs/swagger/dist/decorators/api-param.decorator";
|
|
3
|
+
import { DynamicFilterController } from "../..";
|
|
4
|
+
import { FilterService } from "../filter.service";
|
|
5
|
+
export type OpenApiDynamicFilterControllerOptions = {
|
|
6
|
+
param?: ApiParamOptions;
|
|
7
|
+
};
|
|
8
|
+
export declare function OpenApiDynamicFilterController<T extends Type, D>(Base: T, options?: OpenApiDynamicFilterControllerOptions): Type<DynamicFilterController<D>> & (abstract new (filterService: FilterService<D>) => DynamicFilterController<D>);
|
|
@@ -0,0 +1,127 @@
|
|
|
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.OpenApiDynamicFilterController = OpenApiDynamicFilterController;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const __1 = require("../..");
|
|
19
|
+
const filter_query_guard_1 = require("../guards/filter-query.guard");
|
|
20
|
+
const data_file_download_interceptor_1 = require("../interceptors/data-file-download.interceptor");
|
|
21
|
+
const filter_resource_value_model_1 = require("../models/filter-resource-value.model");
|
|
22
|
+
function OpenApiDynamicFilterController(Base, options) {
|
|
23
|
+
const _FilterResultModel = (0, __1.FilterResultModelMixin)(Base);
|
|
24
|
+
class _FilterController extends __1.DynamicFilterController {
|
|
25
|
+
async filter(query, req) {
|
|
26
|
+
return super.filter(query, req);
|
|
27
|
+
}
|
|
28
|
+
async filterCount(query, req) {
|
|
29
|
+
return super.filterCount(query, req);
|
|
30
|
+
}
|
|
31
|
+
async downloadData(query, type, req) {
|
|
32
|
+
return super.downloadData(query, type, req);
|
|
33
|
+
}
|
|
34
|
+
async getFilterConfig(req) {
|
|
35
|
+
return super.getFilterConfig(req);
|
|
36
|
+
}
|
|
37
|
+
async searchFilterResourceValue(search, req) {
|
|
38
|
+
return super.searchFilterResourceValue(search, req);
|
|
39
|
+
}
|
|
40
|
+
async searchFilterConfigValues(search, req) {
|
|
41
|
+
return super.searchFilterConfigValues(search, req);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, common_1.Post)("filter"),
|
|
46
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
47
|
+
(0, common_1.UseGuards)(filter_query_guard_1.FilterQueryGuard),
|
|
48
|
+
(0, swagger_1.ApiOkResponse)({ type: () => _FilterResultModel }),
|
|
49
|
+
(0, swagger_1.ApiOperation)({ operationId: `filter${Base.name}` }),
|
|
50
|
+
__param(0, (0, common_1.Body)()),
|
|
51
|
+
__param(1, (0, common_1.Req)()),
|
|
52
|
+
__metadata("design:type", Function),
|
|
53
|
+
__metadata("design:paramtypes", [__1.FilterQueryModel, Object]),
|
|
54
|
+
__metadata("design:returntype", Promise)
|
|
55
|
+
], _FilterController.prototype, "filter", null);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, common_1.Post)("filter-count"),
|
|
58
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
59
|
+
(0, swagger_1.ApiOkResponse)({ schema: { type: "number" } }),
|
|
60
|
+
(0, swagger_1.ApiOperation)({ operationId: `filter${Base.name}Count` }),
|
|
61
|
+
__param(0, (0, common_1.Body)()),
|
|
62
|
+
__param(1, (0, common_1.Req)()),
|
|
63
|
+
__metadata("design:type", Function),
|
|
64
|
+
__metadata("design:paramtypes", [__1.FilterQueryModel, Object]),
|
|
65
|
+
__metadata("design:returntype", Promise)
|
|
66
|
+
], _FilterController.prototype, "filterCount", null);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, common_1.Post)("download/:type"),
|
|
69
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
70
|
+
(0, common_1.UseInterceptors)(data_file_download_interceptor_1.DataFileDownloadInterceptor),
|
|
71
|
+
(0, swagger_1.ApiOkResponse)({
|
|
72
|
+
description: "Returns file data as binary (Buffer) or as text (string) depending on the export type.",
|
|
73
|
+
content: {
|
|
74
|
+
"application/octet-stream": {
|
|
75
|
+
schema: {
|
|
76
|
+
oneOf: [
|
|
77
|
+
{ type: "string", format: "binary" },
|
|
78
|
+
{ type: "string" }
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
(0, swagger_1.ApiParam)({ name: "type", enum: __1.ExportTypes, enumName: "ExportTypes" }),
|
|
85
|
+
(0, swagger_1.ApiOperation)({ operationId: `download${Base.name}Data` }),
|
|
86
|
+
__param(0, (0, common_1.Body)()),
|
|
87
|
+
__param(1, (0, common_1.Param)("type")),
|
|
88
|
+
__param(2, (0, common_1.Req)()),
|
|
89
|
+
__metadata("design:type", Function),
|
|
90
|
+
__metadata("design:paramtypes", [__1.FilterQueryModel, String, Object]),
|
|
91
|
+
__metadata("design:returntype", Promise)
|
|
92
|
+
], _FilterController.prototype, "downloadData", null);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, common_1.Post)("filter/config"),
|
|
95
|
+
(0, swagger_1.ApiOkResponse)({ type: () => __1.FilterConfigurationModel, isArray: true }),
|
|
96
|
+
(0, swagger_1.ApiOperation)({ operationId: `get${Base.name}FilterConfig` }),
|
|
97
|
+
__param(0, (0, common_1.Req)()),
|
|
98
|
+
__metadata("design:type", Function),
|
|
99
|
+
__metadata("design:paramtypes", [Object]),
|
|
100
|
+
__metadata("design:returntype", Promise)
|
|
101
|
+
], _FilterController.prototype, "getFilterConfig", null);
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, common_1.Post)("filter/config/id"),
|
|
104
|
+
(0, swagger_1.ApiOkResponse)({ type: () => __1.SelectFilterValue }),
|
|
105
|
+
(0, swagger_1.ApiOperation)({ operationId: `search${Base.name}FilterResourceValue` }),
|
|
106
|
+
__param(0, (0, common_1.Query)()),
|
|
107
|
+
__param(1, (0, common_1.Req)()),
|
|
108
|
+
__metadata("design:type", Function),
|
|
109
|
+
__metadata("design:paramtypes", [filter_resource_value_model_1.FilterResourceValueModel, Object]),
|
|
110
|
+
__metadata("design:returntype", Promise)
|
|
111
|
+
], _FilterController.prototype, "searchFilterResourceValue", null);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, common_1.Post)("filter/config/value"),
|
|
114
|
+
(0, swagger_1.ApiOkResponse)({ type: () => __1.SelectFilterValue, isArray: true }),
|
|
115
|
+
(0, swagger_1.ApiOperation)({ operationId: `search${Base.name}FilterConfigValues` }),
|
|
116
|
+
__param(0, (0, common_1.Query)()),
|
|
117
|
+
__param(1, (0, common_1.Req)()),
|
|
118
|
+
__metadata("design:type", Function),
|
|
119
|
+
__metadata("design:paramtypes", [__1.FilterConfigurationSearchModel, Object]),
|
|
120
|
+
__metadata("design:returntype", Promise)
|
|
121
|
+
], _FilterController.prototype, "searchFilterConfigValues", null);
|
|
122
|
+
if (options === null || options === void 0 ? void 0 : options.param) {
|
|
123
|
+
(0, common_1.applyDecorators)((0, swagger_1.ApiParam)(options.param))(_FilterController);
|
|
124
|
+
}
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
return _FilterController;
|
|
127
|
+
}
|
|
@@ -14,10 +14,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.OpenApiFilterController = OpenApiFilterController;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
17
18
|
const __1 = require("../..");
|
|
18
19
|
const filter_query_guard_1 = require("../guards/filter-query.guard");
|
|
19
20
|
const data_file_download_interceptor_1 = require("../interceptors/data-file-download.interceptor");
|
|
20
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
21
21
|
const filter_resource_value_model_1 = require("../models/filter-resource-value.model");
|
|
22
22
|
function OpenApiFilterController(Base) {
|
|
23
23
|
const _FilterResultModel = (0, __1.FilterResultModelMixin)(Base);
|
package/lib/filter/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./filter.service";
|
|
|
5
5
|
export * from "./base-filter";
|
|
6
6
|
export * from "./controllers/dynamic-filter.controller";
|
|
7
7
|
export * from "./controllers/filter.controller";
|
|
8
|
+
export * from "./controllers/open-api-dynamic-filter.controller";
|
|
8
9
|
export * from "./controllers/open-api-filter.controller";
|
|
9
10
|
export * from "./decorators/inject-filter.decorator";
|
|
10
11
|
export * from "./filter.utils";
|
package/lib/filter/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./filter.service"), exports);
|
|
|
21
21
|
__exportStar(require("./base-filter"), exports);
|
|
22
22
|
__exportStar(require("./controllers/dynamic-filter.controller"), exports);
|
|
23
23
|
__exportStar(require("./controllers/filter.controller"), exports);
|
|
24
|
+
__exportStar(require("./controllers/open-api-dynamic-filter.controller"), exports);
|
|
24
25
|
__exportStar(require("./controllers/open-api-filter.controller"), exports);
|
|
25
26
|
__exportStar(require("./decorators/inject-filter.decorator"), exports);
|
|
26
27
|
__exportStar(require("./filter.utils"), exports);
|