listpage-next-nest 0.0.5 → 0.0.7
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/cjs/index.cjs +24 -1
- package/dist/cjs/index.d.ts +108 -0
- package/dist/esm/index.d.ts +108 -0
- package/dist/esm/index.js +19 -2
- package/package.json +8 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -28,6 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
HttpExceptionFilter: ()=>HttpExceptionFilter,
|
|
29
29
|
RequestContextMiddleware: ()=>RequestContextMiddleware,
|
|
30
30
|
setup: ()=>setup,
|
|
31
|
+
PaginationData: ()=>PaginationData,
|
|
32
|
+
PaginatedResponse: ()=>PaginatedResponse,
|
|
31
33
|
RequestContextService: ()=>RequestContextService,
|
|
32
34
|
RequestIdMiddleware: ()=>RequestIdMiddleware,
|
|
33
35
|
LoggingInterceptor: ()=>LoggingInterceptor,
|
|
@@ -155,6 +157,23 @@ class ApiResponse {
|
|
|
155
157
|
return new ApiResponse(50001, message);
|
|
156
158
|
}
|
|
157
159
|
}
|
|
160
|
+
class PaginationData {
|
|
161
|
+
constructor(list, current, pageSize, total){
|
|
162
|
+
this.total = total;
|
|
163
|
+
this.pageSize = pageSize;
|
|
164
|
+
this.current = current;
|
|
165
|
+
this.list = list;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
class PaginatedResponse extends ApiResponse {
|
|
169
|
+
constructor(list, current, pageSize, total, message = '操作成功'){
|
|
170
|
+
const paginationData = new PaginationData(list, current, pageSize, total);
|
|
171
|
+
super(10000, message, paginationData);
|
|
172
|
+
}
|
|
173
|
+
static create(list, current, pageSize, total, message = '操作成功') {
|
|
174
|
+
return new PaginatedResponse(list, current, pageSize, total, message);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
158
177
|
function http_exception_filter_ts_decorate(decorators, target, key, desc) {
|
|
159
178
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
160
179
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -294,8 +313,8 @@ class ResponseInterceptor {
|
|
|
294
313
|
ResponseInterceptor = response_interceptor_ts_decorate([
|
|
295
314
|
(0, common_namespaceObject.Injectable)()
|
|
296
315
|
], ResponseInterceptor);
|
|
297
|
-
const external_class_transformer_namespaceObject = require("class-transformer");
|
|
298
316
|
const external_class_validator_namespaceObject = require("class-validator");
|
|
317
|
+
const external_class_transformer_namespaceObject = require("class-transformer");
|
|
299
318
|
function query_dto_ts_decorate(decorators, target, key, desc) {
|
|
300
319
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
301
320
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -356,6 +375,8 @@ exports.BaseQueryDto = __webpack_exports__.BaseQueryDto;
|
|
|
356
375
|
exports.CorsInterceptor = __webpack_exports__.CorsInterceptor;
|
|
357
376
|
exports.HttpExceptionFilter = __webpack_exports__.HttpExceptionFilter;
|
|
358
377
|
exports.LoggingInterceptor = __webpack_exports__.LoggingInterceptor;
|
|
378
|
+
exports.PaginatedResponse = __webpack_exports__.PaginatedResponse;
|
|
379
|
+
exports.PaginationData = __webpack_exports__.PaginationData;
|
|
359
380
|
exports.RequestContextMiddleware = __webpack_exports__.RequestContextMiddleware;
|
|
360
381
|
exports.RequestContextService = __webpack_exports__.RequestContextService;
|
|
361
382
|
exports.RequestIdMiddleware = __webpack_exports__.RequestIdMiddleware;
|
|
@@ -367,6 +388,8 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
367
388
|
"CorsInterceptor",
|
|
368
389
|
"HttpExceptionFilter",
|
|
369
390
|
"LoggingInterceptor",
|
|
391
|
+
"PaginatedResponse",
|
|
392
|
+
"PaginationData",
|
|
370
393
|
"RequestContextMiddleware",
|
|
371
394
|
"RequestContextService",
|
|
372
395
|
"RequestIdMiddleware",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { CallHandler } from '@nestjs/common';
|
|
3
|
+
import { ExceptionFilter } from '@nestjs/common';
|
|
4
|
+
import { ExecutionContext } from '@nestjs/common';
|
|
5
|
+
import { INestApplication } from '@nestjs/common';
|
|
6
|
+
import { NestInterceptor } from '@nestjs/common';
|
|
7
|
+
import { NestMiddleware } from '@nestjs/common';
|
|
8
|
+
import { NextFunction } from 'express';
|
|
9
|
+
import { Observable } from 'rxjs';
|
|
10
|
+
import { Request as Request_2 } from 'express';
|
|
11
|
+
import { Response as Response_2 } from 'express';
|
|
12
|
+
|
|
13
|
+
export declare class ApiResponse<T = any> {
|
|
14
|
+
code: number;
|
|
15
|
+
message: string;
|
|
16
|
+
data?: T;
|
|
17
|
+
constructor(code: number, message: string, data?: T);
|
|
18
|
+
static success<T>(data?: T, message?: string): ApiResponse<T>;
|
|
19
|
+
static error(message: string, code?: number): ApiResponse;
|
|
20
|
+
static created<T>(data?: T, message?: string): ApiResponse<T>;
|
|
21
|
+
static badRequest(message?: string): ApiResponse;
|
|
22
|
+
static unauthorized(message?: string): ApiResponse;
|
|
23
|
+
static forbidden(message?: string): ApiResponse;
|
|
24
|
+
static notFound(message?: string): ApiResponse;
|
|
25
|
+
static conflict(message?: string): ApiResponse;
|
|
26
|
+
static validationError(message?: string): ApiResponse;
|
|
27
|
+
static internalError(message?: string): ApiResponse;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare class BaseQueryDto {
|
|
31
|
+
current?: number;
|
|
32
|
+
pageSize?: number;
|
|
33
|
+
sort?: string;
|
|
34
|
+
get sortField(): string;
|
|
35
|
+
get sortOrder(): 'asc' | 'desc';
|
|
36
|
+
get skip(): number;
|
|
37
|
+
get take(): number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare class CorsInterceptor implements NestInterceptor {
|
|
41
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare class HttpExceptionFilter implements ExceptionFilter {
|
|
45
|
+
private readonly logger;
|
|
46
|
+
catch(exception: unknown, host: ArgumentsHost): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare class LoggingInterceptor implements NestInterceptor {
|
|
50
|
+
private readonly logger;
|
|
51
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare class PaginatedResponse<T> extends ApiResponse<PaginationData<T>> {
|
|
55
|
+
constructor(list: T[], current: number, pageSize: number, total: number, message?: string);
|
|
56
|
+
static create<T>(list: T[], current: number, pageSize: number, total: number, message?: string): PaginatedResponse<T>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare class PaginationData<T> {
|
|
60
|
+
total: number;
|
|
61
|
+
pageSize: number;
|
|
62
|
+
current: number;
|
|
63
|
+
list: T[];
|
|
64
|
+
constructor(list: T[], current: number, pageSize: number, total: number);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare interface RequestContext {
|
|
68
|
+
requestId: string;
|
|
69
|
+
startTime: number;
|
|
70
|
+
method: string;
|
|
71
|
+
url: string;
|
|
72
|
+
ip: string;
|
|
73
|
+
userAgent: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare class RequestContextMiddleware implements NestMiddleware {
|
|
77
|
+
use(req: RequestWithId, res: Response_2, next: NextFunction): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export declare class RequestContextService {
|
|
81
|
+
private static asyncLocalStorage;
|
|
82
|
+
static run<T>(context: RequestContext, callback: () => T): T;
|
|
83
|
+
static getContext(): RequestContext | undefined;
|
|
84
|
+
static getRequestId(): string | undefined;
|
|
85
|
+
static setRequestId(requestId: string): void;
|
|
86
|
+
getRequestId(): string | undefined;
|
|
87
|
+
getContext(): RequestContext | undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export declare class RequestIdMiddleware implements NestMiddleware {
|
|
91
|
+
use(req: RequestWithId_2, res: Response_2, next: NextFunction): void;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare interface RequestWithId extends Request_2 {
|
|
95
|
+
requestId: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare interface RequestWithId_2 extends Request_2 {
|
|
99
|
+
requestId: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export declare class ResponseInterceptor<T> implements NestInterceptor<T, any> {
|
|
103
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export declare function setup(app: INestApplication): void;
|
|
107
|
+
|
|
108
|
+
export { }
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { CallHandler } from '@nestjs/common';
|
|
3
|
+
import { ExceptionFilter } from '@nestjs/common';
|
|
4
|
+
import { ExecutionContext } from '@nestjs/common';
|
|
5
|
+
import { INestApplication } from '@nestjs/common';
|
|
6
|
+
import { NestInterceptor } from '@nestjs/common';
|
|
7
|
+
import { NestMiddleware } from '@nestjs/common';
|
|
8
|
+
import { NextFunction } from 'express';
|
|
9
|
+
import { Observable } from 'rxjs';
|
|
10
|
+
import { Request as Request_2 } from 'express';
|
|
11
|
+
import { Response as Response_2 } from 'express';
|
|
12
|
+
|
|
13
|
+
export declare class ApiResponse<T = any> {
|
|
14
|
+
code: number;
|
|
15
|
+
message: string;
|
|
16
|
+
data?: T;
|
|
17
|
+
constructor(code: number, message: string, data?: T);
|
|
18
|
+
static success<T>(data?: T, message?: string): ApiResponse<T>;
|
|
19
|
+
static error(message: string, code?: number): ApiResponse;
|
|
20
|
+
static created<T>(data?: T, message?: string): ApiResponse<T>;
|
|
21
|
+
static badRequest(message?: string): ApiResponse;
|
|
22
|
+
static unauthorized(message?: string): ApiResponse;
|
|
23
|
+
static forbidden(message?: string): ApiResponse;
|
|
24
|
+
static notFound(message?: string): ApiResponse;
|
|
25
|
+
static conflict(message?: string): ApiResponse;
|
|
26
|
+
static validationError(message?: string): ApiResponse;
|
|
27
|
+
static internalError(message?: string): ApiResponse;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare class BaseQueryDto {
|
|
31
|
+
current?: number;
|
|
32
|
+
pageSize?: number;
|
|
33
|
+
sort?: string;
|
|
34
|
+
get sortField(): string;
|
|
35
|
+
get sortOrder(): 'asc' | 'desc';
|
|
36
|
+
get skip(): number;
|
|
37
|
+
get take(): number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare class CorsInterceptor implements NestInterceptor {
|
|
41
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare class HttpExceptionFilter implements ExceptionFilter {
|
|
45
|
+
private readonly logger;
|
|
46
|
+
catch(exception: unknown, host: ArgumentsHost): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare class LoggingInterceptor implements NestInterceptor {
|
|
50
|
+
private readonly logger;
|
|
51
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare class PaginatedResponse<T> extends ApiResponse<PaginationData<T>> {
|
|
55
|
+
constructor(list: T[], current: number, pageSize: number, total: number, message?: string);
|
|
56
|
+
static create<T>(list: T[], current: number, pageSize: number, total: number, message?: string): PaginatedResponse<T>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare class PaginationData<T> {
|
|
60
|
+
total: number;
|
|
61
|
+
pageSize: number;
|
|
62
|
+
current: number;
|
|
63
|
+
list: T[];
|
|
64
|
+
constructor(list: T[], current: number, pageSize: number, total: number);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare interface RequestContext {
|
|
68
|
+
requestId: string;
|
|
69
|
+
startTime: number;
|
|
70
|
+
method: string;
|
|
71
|
+
url: string;
|
|
72
|
+
ip: string;
|
|
73
|
+
userAgent: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare class RequestContextMiddleware implements NestMiddleware {
|
|
77
|
+
use(req: RequestWithId, res: Response_2, next: NextFunction): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export declare class RequestContextService {
|
|
81
|
+
private static asyncLocalStorage;
|
|
82
|
+
static run<T>(context: RequestContext, callback: () => T): T;
|
|
83
|
+
static getContext(): RequestContext | undefined;
|
|
84
|
+
static getRequestId(): string | undefined;
|
|
85
|
+
static setRequestId(requestId: string): void;
|
|
86
|
+
getRequestId(): string | undefined;
|
|
87
|
+
getContext(): RequestContext | undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export declare class RequestIdMiddleware implements NestMiddleware {
|
|
91
|
+
use(req: RequestWithId_2, res: Response_2, next: NextFunction): void;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare interface RequestWithId extends Request_2 {
|
|
95
|
+
requestId: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare interface RequestWithId_2 extends Request_2 {
|
|
99
|
+
requestId: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export declare class ResponseInterceptor<T> implements NestInterceptor<T, any> {
|
|
103
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export declare function setup(app: INestApplication): void;
|
|
107
|
+
|
|
108
|
+
export { }
|
package/dist/esm/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { Catch, HttpException, HttpStatus, Injectable, Logger, Scope } from "@ne
|
|
|
2
2
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3
3
|
import { v4 } from "uuid";
|
|
4
4
|
import { map, tap } from "rxjs/operators";
|
|
5
|
-
import { Type } from "class-transformer";
|
|
6
5
|
import { IsInt, IsOptional, IsString, Max, Min } from "class-validator";
|
|
6
|
+
import { Type } from "class-transformer";
|
|
7
7
|
function _ts_decorate(decorators, target, key, desc) {
|
|
8
8
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
9
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -121,6 +121,23 @@ class ApiResponse {
|
|
|
121
121
|
return new ApiResponse(50001, message);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
+
class PaginationData {
|
|
125
|
+
constructor(list, current, pageSize, total){
|
|
126
|
+
this.total = total;
|
|
127
|
+
this.pageSize = pageSize;
|
|
128
|
+
this.current = current;
|
|
129
|
+
this.list = list;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
class PaginatedResponse extends ApiResponse {
|
|
133
|
+
constructor(list, current, pageSize, total, message = '操作成功'){
|
|
134
|
+
const paginationData = new PaginationData(list, current, pageSize, total);
|
|
135
|
+
super(10000, message, paginationData);
|
|
136
|
+
}
|
|
137
|
+
static create(list, current, pageSize, total, message = '操作成功') {
|
|
138
|
+
return new PaginatedResponse(list, current, pageSize, total, message);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
124
141
|
function http_exception_filter_ts_decorate(decorators, target, key, desc) {
|
|
125
142
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
126
143
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -314,4 +331,4 @@ function setup(app) {
|
|
|
314
331
|
app.useGlobalFilters(new HttpExceptionFilter());
|
|
315
332
|
console.log('✅ 全局异常过滤器配置完成');
|
|
316
333
|
}
|
|
317
|
-
export { ApiResponse, BaseQueryDto, CorsInterceptor, HttpExceptionFilter, LoggingInterceptor, RequestContextMiddleware, RequestContextService, RequestIdMiddleware, ResponseInterceptor, setup };
|
|
334
|
+
export { ApiResponse, BaseQueryDto, CorsInterceptor, HttpExceptionFilter, LoggingInterceptor, PaginatedResponse, PaginationData, RequestContextMiddleware, RequestContextService, RequestIdMiddleware, ResponseInterceptor, setup };
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "listpage-next-nest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "A React component library for creating filter forms with Ant Design",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.js",
|
|
6
|
+
"main": "./dist/cjs/index.js",
|
|
7
|
+
"module": "./dist/cjs/index.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js"
|
|
10
|
+
"types": "./dist/cjs/index.d.ts",
|
|
11
|
+
"import": "./dist/cjs/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
14
|
+
"types": "./dist/cjs/index.d.ts",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"@rsbuild/plugin-react": "^1.4.0",
|
|
35
35
|
"@rslib/core": "^0.13.3",
|
|
36
36
|
"prettier": "^3.6.2",
|
|
37
|
-
"typescript": "^5.9.2"
|
|
37
|
+
"typescript": "^5.9.2",
|
|
38
|
+
"@microsoft/api-extractor": "~7.52.13"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {"class-transformer":"~0.5.1","class-validator":"~0.14.2","@nestjs/common":"~11.1.6","uuid":"~13.0.0","express":"~5.1.0","@types/express":"~5.0.3","rxjs":"~7.8.2"}
|
|
40
41
|
}
|