@x-spacy/pagination 1.0.7 → 1.0.9
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/@types/enums/PaginationLinkType.d.ts +7 -0
- package/@types/index.d.ts +6 -18
- package/@types/interceptors/PaginationInterceptor.d.ts +8 -0
- package/@types/operators/paginate.d.ts +2 -0
- package/@types/schemas/Page.d.ts +5 -0
- package/@types/schemas/PaginatedResponse.d.ts +13 -0
- package/@types/schemas/PaginationLink.d.ts +8 -0
- package/@types/schemas/PaginationMeta.d.ts +9 -0
- package/README.md +2 -2
- package/package.json +1 -1
- package/tsconfig.json +3 -0
package/@types/index.d.ts
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
LAST = 'LAST',
|
|
8
|
-
PREVIOUS = 'PREVIOUS',
|
|
9
|
-
NEXT = 'NEXT',
|
|
10
|
-
PAGE = 'PAGE'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export declare class PaginateInterceptor<T> implements NestInterceptor {
|
|
14
|
-
intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<PaginatedResponse<T>>>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function paginate<T>(items: Array<T>, total: number): Page<T>;
|
|
18
|
-
}
|
|
1
|
+
export * from '@x-spacy/pagination/interceptors/PaginationInterceptor';
|
|
2
|
+
export * from '@x-spacy/pagination/operators/paginate';
|
|
3
|
+
export * from '@x-spacy/pagination/schemas/Page';
|
|
4
|
+
export * from '@x-spacy/pagination/schemas/PaginatedResponse';
|
|
5
|
+
export * from '@x-spacy/pagination/schemas/PaginationLink';
|
|
6
|
+
export * from '@x-spacy/pagination/schemas/PaginationMeta';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
|
2
|
+
import { Page } from '@x-spacy/pagination/schemas/Page';
|
|
3
|
+
import { PaginatedResponse } from '@x-spacy/pagination/schemas/PaginatedResponse';
|
|
4
|
+
import { PaginationLink } from '@x-spacy/pagination/schemas/PaginationLink';
|
|
5
|
+
export declare class PaginateInterceptor<T> implements NestInterceptor<Page<T>, PaginatedResponse<T>> {
|
|
6
|
+
intercept(context: ExecutionContext, next: CallHandler<Page<T>>): import("rxjs").Observable<PaginatedResponse<T>>;
|
|
7
|
+
protected buildLinks(currentPage: number, lastPage: number, buildUrl: (page: number) => string): PaginationLink[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PaginationLink } from '@x-spacy/pagination/schemas/PaginationLink';
|
|
2
|
+
import { PaginationMeta } from '@x-spacy/pagination/schemas/PaginationMeta';
|
|
3
|
+
export declare class PaginatedResponse<T> {
|
|
4
|
+
readonly items: Array<T>;
|
|
5
|
+
readonly meta: PaginationMeta;
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly firstPageURL: string;
|
|
8
|
+
readonly previousPageURL: string | null;
|
|
9
|
+
readonly nextPageURL: string | null;
|
|
10
|
+
readonly lastPageURL: string;
|
|
11
|
+
readonly links: Array<PaginationLink>;
|
|
12
|
+
constructor(items: Array<T>, meta: PaginationMeta, path: string, firstPageURL: string, previousPageURL: string | null, nextPageURL: string | null, lastPageURL: string, links: Array<PaginationLink>);
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PaginationLinkType } from '@x-spacy/pagination/enums/PaginationLinkType';
|
|
2
|
+
export declare class PaginationLink {
|
|
3
|
+
readonly url: string | null;
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly type: PaginationLinkType;
|
|
6
|
+
readonly active: boolean;
|
|
7
|
+
constructor(url: string | null, label: string, type: PaginationLinkType, active: boolean);
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class PaginationMeta {
|
|
2
|
+
readonly from: number;
|
|
3
|
+
readonly to: number;
|
|
4
|
+
readonly currentPage: number;
|
|
5
|
+
readonly lastPage: number;
|
|
6
|
+
readonly perPage: number;
|
|
7
|
+
readonly total: number;
|
|
8
|
+
constructor(from: number, to: number, currentPage: number, lastPage: number, perPage: number, total: number);
|
|
9
|
+
}
|
package/README.md
CHANGED
|
@@ -138,7 +138,7 @@ The paginated response follows this format:
|
|
|
138
138
|
{
|
|
139
139
|
"url": null,
|
|
140
140
|
"label": "« Previous",
|
|
141
|
-
"type": "
|
|
141
|
+
"type": "PREVIOUS",
|
|
142
142
|
"active": false
|
|
143
143
|
},
|
|
144
144
|
{
|
|
@@ -203,7 +203,7 @@ Enum that defines the types of navigation links:
|
|
|
203
203
|
enum PaginationLinkType {
|
|
204
204
|
FIRST = 'FIRST',
|
|
205
205
|
LAST = 'LAST',
|
|
206
|
-
PREV = '
|
|
206
|
+
PREV = 'PREVIOUS',
|
|
207
207
|
NEXT = 'NEXT',
|
|
208
208
|
PAGE = 'PAGE'
|
|
209
209
|
}
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "es2024",
|
|
4
4
|
"module": "commonjs",
|
|
5
|
+
"rootDir": "src",
|
|
5
6
|
"outDir": "dist",
|
|
7
|
+
"declarationDir": "@types",
|
|
6
8
|
"paths": {
|
|
7
9
|
"@x-spacy/pagination/*": [
|
|
8
10
|
"./src/*"
|
|
9
11
|
]
|
|
10
12
|
},
|
|
11
13
|
"strict": true,
|
|
14
|
+
"declaration": true,
|
|
12
15
|
"skipLibCheck": true,
|
|
13
16
|
"removeComments": true,
|
|
14
17
|
"esModuleInterop": true,
|