@orion-js/paginated-mongodb 4.3.2 → 4.4.0
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/LICENSE +21 -0
- package/dist/index.d.ts +4 -142
- package/dist/paginatedResolver/getModel.d.ts +40 -0
- package/dist/paginatedResolver/index.d.ts +57 -0
- package/dist/paginatedResolver/params.d.ts +29 -0
- package/dist/paginatedResolver/setOptions.d.ts +10 -0
- package/dist/service/index.d.ts +6 -0
- package/dist/tokenPaginatedResolver/getReturnModel.d.ts +5 -0
- package/dist/tokenPaginatedResolver/index.d.ts +6 -0
- package/package.json +19 -20
- package/dist/index.d.cts +0 -142
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Orionjs Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,142 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly page: {
|
|
6
|
-
readonly type: "integer";
|
|
7
|
-
readonly defaultValue: 1;
|
|
8
|
-
readonly optional: true;
|
|
9
|
-
readonly min: 1;
|
|
10
|
-
};
|
|
11
|
-
readonly limit: {
|
|
12
|
-
readonly type: "integer";
|
|
13
|
-
readonly defaultValue: 20;
|
|
14
|
-
readonly optional: true;
|
|
15
|
-
readonly min: 0;
|
|
16
|
-
readonly max: 200;
|
|
17
|
-
};
|
|
18
|
-
readonly sortBy: {
|
|
19
|
-
readonly type: StringConstructor;
|
|
20
|
-
readonly optional: true;
|
|
21
|
-
};
|
|
22
|
-
readonly sortType: {
|
|
23
|
-
readonly type: StringConstructor;
|
|
24
|
-
readonly allowedValues: readonly ["asc", "desc"];
|
|
25
|
-
readonly optional: true;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
interface PaginatedCursor<TReturns extends Schema = any> {
|
|
30
|
-
count?: () => Promise<number> | number;
|
|
31
|
-
toArray: () => Promise<InferSchemaType<TReturns>[]>;
|
|
32
|
-
limit?: (newLimit: number) => void;
|
|
33
|
-
skip?: (newSkip: number) => void;
|
|
34
|
-
sort?: (newSort: {
|
|
35
|
-
[key: string]: 1 | -1;
|
|
36
|
-
}) => void;
|
|
37
|
-
}
|
|
38
|
-
type PaginatedResolverGetCursorResultWithCount<TReturns extends Schema = any> = {
|
|
39
|
-
count: () => Promise<number> | number;
|
|
40
|
-
cursor: PaginatedCursor<TReturns>;
|
|
41
|
-
};
|
|
42
|
-
type PaginatedResolverGetCursorResult<TReturns extends Schema = any> = PaginatedCursor<TReturns> | PaginatedResolverGetCursorResultWithCount<TReturns>;
|
|
43
|
-
interface PaginatedResolverOpts<TParams extends Schema = any, TReturns extends Schema = any, TViewer = any> {
|
|
44
|
-
returns: TReturns;
|
|
45
|
-
getCursor: (params?: InferSchemaType<typeof paginatedResolverBaseParamsSchema & TParams>, viewer?: TViewer) => Promise<PaginatedResolverGetCursorResult<TReturns>>;
|
|
46
|
-
allowedSorts?: string[];
|
|
47
|
-
defaultSortBy?: string;
|
|
48
|
-
defaultSortType?: 'asc' | 'desc';
|
|
49
|
-
params?: TParams;
|
|
50
|
-
modelName?: string;
|
|
51
|
-
/**
|
|
52
|
-
* @deprecated Just check the permissions in the resolver instead
|
|
53
|
-
*/
|
|
54
|
-
permissionsOptions?: any;
|
|
55
|
-
}
|
|
56
|
-
declare function createPaginatedResolver<TParams extends Schema = any, TReturns extends Schema = any, TViewer = any>({ returns, params, allowedSorts, defaultSortBy, defaultSortType, getCursor, modelName, ...otherOptions }: PaginatedResolverOpts<TParams, TReturns, TViewer>): _orion_js_resolvers.GlobalResolver<{
|
|
57
|
-
readonly page: {
|
|
58
|
-
readonly type: "integer";
|
|
59
|
-
readonly defaultValue: 1;
|
|
60
|
-
readonly optional: true;
|
|
61
|
-
readonly min: 1;
|
|
62
|
-
};
|
|
63
|
-
readonly limit: {
|
|
64
|
-
readonly type: "integer";
|
|
65
|
-
readonly defaultValue: 20;
|
|
66
|
-
readonly optional: true;
|
|
67
|
-
readonly min: 0;
|
|
68
|
-
readonly max: 200;
|
|
69
|
-
};
|
|
70
|
-
readonly sortBy: {
|
|
71
|
-
readonly type: StringConstructor;
|
|
72
|
-
readonly optional: true;
|
|
73
|
-
};
|
|
74
|
-
readonly sortType: {
|
|
75
|
-
readonly type: StringConstructor;
|
|
76
|
-
readonly allowedValues: readonly ["asc", "desc"];
|
|
77
|
-
readonly optional: true;
|
|
78
|
-
};
|
|
79
|
-
} & TParams, {
|
|
80
|
-
readonly cursor: {
|
|
81
|
-
readonly type: "any";
|
|
82
|
-
readonly private: true;
|
|
83
|
-
};
|
|
84
|
-
readonly params: {
|
|
85
|
-
readonly type: {
|
|
86
|
-
readonly page: {
|
|
87
|
-
readonly type: "integer";
|
|
88
|
-
readonly defaultValue: 1;
|
|
89
|
-
readonly optional: true;
|
|
90
|
-
readonly min: 1;
|
|
91
|
-
};
|
|
92
|
-
readonly limit: {
|
|
93
|
-
readonly type: "integer";
|
|
94
|
-
readonly defaultValue: 20;
|
|
95
|
-
readonly optional: true;
|
|
96
|
-
readonly min: 0;
|
|
97
|
-
readonly max: 200;
|
|
98
|
-
};
|
|
99
|
-
readonly sortBy: {
|
|
100
|
-
readonly type: StringConstructor;
|
|
101
|
-
readonly optional: true;
|
|
102
|
-
};
|
|
103
|
-
readonly sortType: {
|
|
104
|
-
readonly type: StringConstructor;
|
|
105
|
-
readonly allowedValues: readonly ["asc", "desc"];
|
|
106
|
-
readonly optional: true;
|
|
107
|
-
};
|
|
108
|
-
} & TParams;
|
|
109
|
-
readonly private: true;
|
|
110
|
-
};
|
|
111
|
-
readonly viewer: {
|
|
112
|
-
readonly type: "any";
|
|
113
|
-
readonly private: true;
|
|
114
|
-
};
|
|
115
|
-
readonly options: {
|
|
116
|
-
readonly type: "any";
|
|
117
|
-
readonly private: true;
|
|
118
|
-
};
|
|
119
|
-
readonly count: {
|
|
120
|
-
readonly type: "integer";
|
|
121
|
-
readonly private: true;
|
|
122
|
-
};
|
|
123
|
-
}, any, any>;
|
|
124
|
-
/**
|
|
125
|
-
* @deprecated Use createPaginatedResolver instead
|
|
126
|
-
*/
|
|
127
|
-
declare const paginatedResolver: typeof createPaginatedResolver;
|
|
128
|
-
|
|
129
|
-
declare function export_default({ collection, params, resolve, ...otherOptions }: {
|
|
130
|
-
[x: string]: any;
|
|
131
|
-
collection: any;
|
|
132
|
-
params: any;
|
|
133
|
-
resolve: any;
|
|
134
|
-
}): _orion_js_resolvers.GlobalResolver<any, any, any, any>;
|
|
135
|
-
|
|
136
|
-
interface PagiantedQueryDescriptor extends Omit<PropertyDecorator, 'value'> {
|
|
137
|
-
value?: PaginatedResolverOpts['getCursor'];
|
|
138
|
-
}
|
|
139
|
-
declare function PaginatedQuery(): (method: any, context: ClassFieldDecoratorContext) => any;
|
|
140
|
-
declare function PaginatedQuery(options: Omit<PaginatedResolverOpts, 'getCursor'>): (method: any, context: ClassMethodDecoratorContext) => any;
|
|
141
|
-
|
|
142
|
-
export { type PagiantedQueryDescriptor, PaginatedQuery, createPaginatedResolver, paginatedResolver, export_default as tokenPaginatedResolver };
|
|
1
|
+
import { paginatedResolver, createPaginatedResolver } from './paginatedResolver';
|
|
2
|
+
import tokenPaginatedResolver from './tokenPaginatedResolver';
|
|
3
|
+
export { paginatedResolver, tokenPaginatedResolver, createPaginatedResolver };
|
|
4
|
+
export * from './service';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InferSchemaType, Schema } from '@orion-js/schema';
|
|
2
|
+
import { PaginatedCursor } from '.';
|
|
3
|
+
export declare function getPaginatedResolverReturnSchema<TParams extends Schema>(paramsSchema: TParams): {
|
|
4
|
+
readonly cursor: {
|
|
5
|
+
readonly type: 'any';
|
|
6
|
+
readonly private: true;
|
|
7
|
+
};
|
|
8
|
+
readonly params: {
|
|
9
|
+
readonly type: TParams;
|
|
10
|
+
readonly private: true;
|
|
11
|
+
};
|
|
12
|
+
readonly viewer: {
|
|
13
|
+
readonly type: 'any';
|
|
14
|
+
readonly private: true;
|
|
15
|
+
};
|
|
16
|
+
readonly options: {
|
|
17
|
+
readonly type: 'any';
|
|
18
|
+
readonly private: true;
|
|
19
|
+
};
|
|
20
|
+
readonly count: {
|
|
21
|
+
readonly type: 'integer';
|
|
22
|
+
readonly private: true;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type PaginatedModelResolversInput<TParams extends Schema, TReturns extends Schema> = {
|
|
26
|
+
cursor: PaginatedCursor<TReturns>;
|
|
27
|
+
params: InferSchemaType<TParams>;
|
|
28
|
+
viewer: any;
|
|
29
|
+
options: any;
|
|
30
|
+
count: number;
|
|
31
|
+
};
|
|
32
|
+
export declare function getPaginatedResolverResolvers<TParams extends Schema, TReturns extends Schema>(modelName: string, returns: TReturns): {
|
|
33
|
+
_id: import("@orion-js/resolvers").ModelResolver<PaginatedModelResolversInput<TParams, TReturns>, any, any, any, any>;
|
|
34
|
+
totalCount: import("@orion-js/resolvers").ModelResolver<PaginatedModelResolversInput<TParams, TReturns>, any, any, any, any>;
|
|
35
|
+
totalPages: import("@orion-js/resolvers").ModelResolver<PaginatedModelResolversInput<TParams, TReturns>, any, any, any, any>;
|
|
36
|
+
hasNextPage: import("@orion-js/resolvers").ModelResolver<PaginatedModelResolversInput<TParams, TReturns>, any, any, any, any>;
|
|
37
|
+
hasPreviousPage: import("@orion-js/resolvers").ModelResolver<PaginatedModelResolversInput<TParams, TReturns>, any, any, any, any>;
|
|
38
|
+
items: import("@orion-js/resolvers").ModelResolver<PaginatedModelResolversInput<TParams, TReturns>, any, any, any, any>;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { paginatedResolverBaseParamsSchema } from './params';
|
|
2
|
+
import { InferSchemaType, Schema } from '@orion-js/schema';
|
|
3
|
+
export interface PaginatedCursor<TReturns extends Schema = any> {
|
|
4
|
+
count?: () => Promise<number> | number;
|
|
5
|
+
toArray: () => Promise<InferSchemaType<TReturns>[]>;
|
|
6
|
+
limit?: (newLimit: number) => void;
|
|
7
|
+
skip?: (newSkip: number) => void;
|
|
8
|
+
sort?: (newSort: {
|
|
9
|
+
[key: string]: 1 | -1;
|
|
10
|
+
}) => void;
|
|
11
|
+
}
|
|
12
|
+
export type PaginatedResolverGetCursorResultWithCount<TReturns extends Schema = any> = {
|
|
13
|
+
count: () => Promise<number> | number;
|
|
14
|
+
cursor: PaginatedCursor<TReturns>;
|
|
15
|
+
};
|
|
16
|
+
export type PaginatedResolverGetCursorResult<TReturns extends Schema = any> = PaginatedCursor<TReturns> | PaginatedResolverGetCursorResultWithCount<TReturns>;
|
|
17
|
+
export interface PaginatedResolverOpts<TParams extends Schema = any, TReturns extends Schema = any, TViewer = any> {
|
|
18
|
+
returns: TReturns;
|
|
19
|
+
getCursor: (params?: InferSchemaType<typeof paginatedResolverBaseParamsSchema & TParams>, viewer?: TViewer) => Promise<PaginatedResolverGetCursorResult<TReturns>>;
|
|
20
|
+
allowedSorts?: string[];
|
|
21
|
+
defaultSortBy?: string;
|
|
22
|
+
defaultSortType?: 'asc' | 'desc';
|
|
23
|
+
params?: TParams;
|
|
24
|
+
modelName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Just check the permissions in the resolver instead
|
|
27
|
+
*/
|
|
28
|
+
permissionsOptions?: any;
|
|
29
|
+
}
|
|
30
|
+
export declare function createPaginatedResolver<TParams extends Schema = any, TReturns extends Schema = any, TViewer = any>({ returns, params, allowedSorts, defaultSortBy, defaultSortType, getCursor, modelName, ...otherOptions }: PaginatedResolverOpts<TParams, TReturns, TViewer>): import("@orion-js/resolvers").GlobalResolver<{
|
|
31
|
+
readonly page: {
|
|
32
|
+
readonly type: 'integer';
|
|
33
|
+
readonly defaultValue: 1;
|
|
34
|
+
readonly optional: true;
|
|
35
|
+
readonly min: 1;
|
|
36
|
+
};
|
|
37
|
+
readonly limit: {
|
|
38
|
+
readonly type: 'integer';
|
|
39
|
+
readonly defaultValue: 20;
|
|
40
|
+
readonly optional: true;
|
|
41
|
+
readonly min: 0;
|
|
42
|
+
readonly max: 200;
|
|
43
|
+
};
|
|
44
|
+
readonly sortBy: {
|
|
45
|
+
readonly type: StringConstructor;
|
|
46
|
+
readonly optional: true;
|
|
47
|
+
};
|
|
48
|
+
readonly sortType: {
|
|
49
|
+
readonly type: StringConstructor;
|
|
50
|
+
readonly allowedValues: readonly ['asc', 'desc'];
|
|
51
|
+
readonly optional: true;
|
|
52
|
+
};
|
|
53
|
+
} & TParams, import("@orion-js/schema").SchemaFieldType, any, any>;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use createPaginatedResolver instead
|
|
56
|
+
*/
|
|
57
|
+
export declare const paginatedResolver: typeof createPaginatedResolver;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Schema } from '@orion-js/schema';
|
|
2
|
+
import { PaginatedResolverOpts } from '.';
|
|
3
|
+
type OptionsKeys = 'params' | 'allowedSorts' | 'defaultSortBy' | 'defaultSortType';
|
|
4
|
+
export declare const paginatedResolverBaseParamsSchema: {
|
|
5
|
+
readonly page: {
|
|
6
|
+
readonly type: 'integer';
|
|
7
|
+
readonly defaultValue: 1;
|
|
8
|
+
readonly optional: true;
|
|
9
|
+
readonly min: 1;
|
|
10
|
+
};
|
|
11
|
+
readonly limit: {
|
|
12
|
+
readonly type: 'integer';
|
|
13
|
+
readonly defaultValue: 20;
|
|
14
|
+
readonly optional: true;
|
|
15
|
+
readonly min: 0;
|
|
16
|
+
readonly max: 200;
|
|
17
|
+
};
|
|
18
|
+
readonly sortBy: {
|
|
19
|
+
readonly type: StringConstructor;
|
|
20
|
+
readonly optional: true;
|
|
21
|
+
};
|
|
22
|
+
readonly sortType: {
|
|
23
|
+
readonly type: StringConstructor;
|
|
24
|
+
readonly allowedValues: readonly ['asc', 'desc'];
|
|
25
|
+
readonly optional: true;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function getPaginatedResolverParams<const TDefinedParams extends Schema>(options: Pick<PaginatedResolverOpts, OptionsKeys>): typeof paginatedResolverBaseParamsSchema & TDefinedParams;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PaginatedResolverOpts } from '../paginatedResolver';
|
|
2
|
+
export interface PagiantedQueryDescriptor extends Omit<PropertyDecorator, 'value'> {
|
|
3
|
+
value?: PaginatedResolverOpts['getCursor'];
|
|
4
|
+
}
|
|
5
|
+
export declare function PaginatedQuery(): (method: any, context: ClassFieldDecoratorContext) => any;
|
|
6
|
+
export declare function PaginatedQuery(options: Omit<PaginatedResolverOpts, 'getCursor'>): (method: any, context: ClassMethodDecoratorContext) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/paginated-mongodb",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -8,32 +8,25 @@
|
|
|
8
8
|
],
|
|
9
9
|
"author": "nicolaslopezj",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "bun test",
|
|
13
|
-
"prepare": "bun run build",
|
|
14
|
-
"clean": "rm -rf ./dist",
|
|
15
|
-
"build": "tsup",
|
|
16
|
-
"dev": "tsup --watch"
|
|
17
|
-
},
|
|
18
11
|
"dependencies": {
|
|
19
|
-
"@orion-js/helpers": "4.
|
|
20
|
-
"@orion-js/models": "4.
|
|
21
|
-
"@orion-js/resolvers": "4.
|
|
22
|
-
"@orion-js/schema": "4.
|
|
23
|
-
"@orion-js/services": "4.
|
|
24
|
-
"@orion-js/typed-model": "4.
|
|
25
|
-
"@orion-js/graphql": "4.
|
|
12
|
+
"@orion-js/helpers": "4.4.0",
|
|
13
|
+
"@orion-js/models": "4.4.0",
|
|
14
|
+
"@orion-js/resolvers": "4.4.0",
|
|
15
|
+
"@orion-js/schema": "4.4.0",
|
|
16
|
+
"@orion-js/services": "4.4.0",
|
|
17
|
+
"@orion-js/typed-model": "4.4.0",
|
|
18
|
+
"@orion-js/graphql": "4.4.0"
|
|
26
19
|
},
|
|
27
20
|
"peerDependencies": {
|
|
28
|
-
"@orion-js/logger": "4.
|
|
29
|
-
"@orion-js/mongodb": "4.
|
|
21
|
+
"@orion-js/logger": "4.4.0",
|
|
22
|
+
"@orion-js/mongodb": "4.4.0"
|
|
30
23
|
},
|
|
31
24
|
"devDependencies": {
|
|
32
|
-
"@orion-js/mongodb": "4.
|
|
25
|
+
"@orion-js/mongodb": "4.4.0",
|
|
33
26
|
"@types/node": "^18.0.0",
|
|
34
27
|
"mongodb-memory-server": "^10.1.4",
|
|
35
28
|
"tsup": "^8.0.1",
|
|
36
|
-
"typescript": "^
|
|
29
|
+
"typescript": "^7.0.2"
|
|
37
30
|
},
|
|
38
31
|
"publishConfig": {
|
|
39
32
|
"access": "public"
|
|
@@ -45,5 +38,11 @@
|
|
|
45
38
|
"types": "./dist/index.d.ts",
|
|
46
39
|
"import": "./dist/index.js",
|
|
47
40
|
"require": "./dist/index.cjs"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"test": "bun test",
|
|
44
|
+
"clean": "rm -rf ./dist",
|
|
45
|
+
"build": "tsup && bun run ../../scripts/emit-declarations.ts",
|
|
46
|
+
"dev": "tsup --watch"
|
|
48
47
|
}
|
|
49
|
-
}
|
|
48
|
+
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import * as _orion_js_resolvers from '@orion-js/resolvers';
|
|
2
|
-
import { Schema, InferSchemaType } from '@orion-js/schema';
|
|
3
|
-
|
|
4
|
-
declare const paginatedResolverBaseParamsSchema: {
|
|
5
|
-
readonly page: {
|
|
6
|
-
readonly type: "integer";
|
|
7
|
-
readonly defaultValue: 1;
|
|
8
|
-
readonly optional: true;
|
|
9
|
-
readonly min: 1;
|
|
10
|
-
};
|
|
11
|
-
readonly limit: {
|
|
12
|
-
readonly type: "integer";
|
|
13
|
-
readonly defaultValue: 20;
|
|
14
|
-
readonly optional: true;
|
|
15
|
-
readonly min: 0;
|
|
16
|
-
readonly max: 200;
|
|
17
|
-
};
|
|
18
|
-
readonly sortBy: {
|
|
19
|
-
readonly type: StringConstructor;
|
|
20
|
-
readonly optional: true;
|
|
21
|
-
};
|
|
22
|
-
readonly sortType: {
|
|
23
|
-
readonly type: StringConstructor;
|
|
24
|
-
readonly allowedValues: readonly ["asc", "desc"];
|
|
25
|
-
readonly optional: true;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
interface PaginatedCursor<TReturns extends Schema = any> {
|
|
30
|
-
count?: () => Promise<number> | number;
|
|
31
|
-
toArray: () => Promise<InferSchemaType<TReturns>[]>;
|
|
32
|
-
limit?: (newLimit: number) => void;
|
|
33
|
-
skip?: (newSkip: number) => void;
|
|
34
|
-
sort?: (newSort: {
|
|
35
|
-
[key: string]: 1 | -1;
|
|
36
|
-
}) => void;
|
|
37
|
-
}
|
|
38
|
-
type PaginatedResolverGetCursorResultWithCount<TReturns extends Schema = any> = {
|
|
39
|
-
count: () => Promise<number> | number;
|
|
40
|
-
cursor: PaginatedCursor<TReturns>;
|
|
41
|
-
};
|
|
42
|
-
type PaginatedResolverGetCursorResult<TReturns extends Schema = any> = PaginatedCursor<TReturns> | PaginatedResolverGetCursorResultWithCount<TReturns>;
|
|
43
|
-
interface PaginatedResolverOpts<TParams extends Schema = any, TReturns extends Schema = any, TViewer = any> {
|
|
44
|
-
returns: TReturns;
|
|
45
|
-
getCursor: (params?: InferSchemaType<typeof paginatedResolverBaseParamsSchema & TParams>, viewer?: TViewer) => Promise<PaginatedResolverGetCursorResult<TReturns>>;
|
|
46
|
-
allowedSorts?: string[];
|
|
47
|
-
defaultSortBy?: string;
|
|
48
|
-
defaultSortType?: 'asc' | 'desc';
|
|
49
|
-
params?: TParams;
|
|
50
|
-
modelName?: string;
|
|
51
|
-
/**
|
|
52
|
-
* @deprecated Just check the permissions in the resolver instead
|
|
53
|
-
*/
|
|
54
|
-
permissionsOptions?: any;
|
|
55
|
-
}
|
|
56
|
-
declare function createPaginatedResolver<TParams extends Schema = any, TReturns extends Schema = any, TViewer = any>({ returns, params, allowedSorts, defaultSortBy, defaultSortType, getCursor, modelName, ...otherOptions }: PaginatedResolverOpts<TParams, TReturns, TViewer>): _orion_js_resolvers.GlobalResolver<{
|
|
57
|
-
readonly page: {
|
|
58
|
-
readonly type: "integer";
|
|
59
|
-
readonly defaultValue: 1;
|
|
60
|
-
readonly optional: true;
|
|
61
|
-
readonly min: 1;
|
|
62
|
-
};
|
|
63
|
-
readonly limit: {
|
|
64
|
-
readonly type: "integer";
|
|
65
|
-
readonly defaultValue: 20;
|
|
66
|
-
readonly optional: true;
|
|
67
|
-
readonly min: 0;
|
|
68
|
-
readonly max: 200;
|
|
69
|
-
};
|
|
70
|
-
readonly sortBy: {
|
|
71
|
-
readonly type: StringConstructor;
|
|
72
|
-
readonly optional: true;
|
|
73
|
-
};
|
|
74
|
-
readonly sortType: {
|
|
75
|
-
readonly type: StringConstructor;
|
|
76
|
-
readonly allowedValues: readonly ["asc", "desc"];
|
|
77
|
-
readonly optional: true;
|
|
78
|
-
};
|
|
79
|
-
} & TParams, {
|
|
80
|
-
readonly cursor: {
|
|
81
|
-
readonly type: "any";
|
|
82
|
-
readonly private: true;
|
|
83
|
-
};
|
|
84
|
-
readonly params: {
|
|
85
|
-
readonly type: {
|
|
86
|
-
readonly page: {
|
|
87
|
-
readonly type: "integer";
|
|
88
|
-
readonly defaultValue: 1;
|
|
89
|
-
readonly optional: true;
|
|
90
|
-
readonly min: 1;
|
|
91
|
-
};
|
|
92
|
-
readonly limit: {
|
|
93
|
-
readonly type: "integer";
|
|
94
|
-
readonly defaultValue: 20;
|
|
95
|
-
readonly optional: true;
|
|
96
|
-
readonly min: 0;
|
|
97
|
-
readonly max: 200;
|
|
98
|
-
};
|
|
99
|
-
readonly sortBy: {
|
|
100
|
-
readonly type: StringConstructor;
|
|
101
|
-
readonly optional: true;
|
|
102
|
-
};
|
|
103
|
-
readonly sortType: {
|
|
104
|
-
readonly type: StringConstructor;
|
|
105
|
-
readonly allowedValues: readonly ["asc", "desc"];
|
|
106
|
-
readonly optional: true;
|
|
107
|
-
};
|
|
108
|
-
} & TParams;
|
|
109
|
-
readonly private: true;
|
|
110
|
-
};
|
|
111
|
-
readonly viewer: {
|
|
112
|
-
readonly type: "any";
|
|
113
|
-
readonly private: true;
|
|
114
|
-
};
|
|
115
|
-
readonly options: {
|
|
116
|
-
readonly type: "any";
|
|
117
|
-
readonly private: true;
|
|
118
|
-
};
|
|
119
|
-
readonly count: {
|
|
120
|
-
readonly type: "integer";
|
|
121
|
-
readonly private: true;
|
|
122
|
-
};
|
|
123
|
-
}, any, any>;
|
|
124
|
-
/**
|
|
125
|
-
* @deprecated Use createPaginatedResolver instead
|
|
126
|
-
*/
|
|
127
|
-
declare const paginatedResolver: typeof createPaginatedResolver;
|
|
128
|
-
|
|
129
|
-
declare function export_default({ collection, params, resolve, ...otherOptions }: {
|
|
130
|
-
[x: string]: any;
|
|
131
|
-
collection: any;
|
|
132
|
-
params: any;
|
|
133
|
-
resolve: any;
|
|
134
|
-
}): _orion_js_resolvers.GlobalResolver<any, any, any, any>;
|
|
135
|
-
|
|
136
|
-
interface PagiantedQueryDescriptor extends Omit<PropertyDecorator, 'value'> {
|
|
137
|
-
value?: PaginatedResolverOpts['getCursor'];
|
|
138
|
-
}
|
|
139
|
-
declare function PaginatedQuery(): (method: any, context: ClassFieldDecoratorContext) => any;
|
|
140
|
-
declare function PaginatedQuery(options: Omit<PaginatedResolverOpts, 'getCursor'>): (method: any, context: ClassMethodDecoratorContext) => any;
|
|
141
|
-
|
|
142
|
-
export { type PagiantedQueryDescriptor, PaginatedQuery, createPaginatedResolver, paginatedResolver, export_default as tokenPaginatedResolver };
|