@orion-js/paginated-mongodb 4.0.0-alpha.3 → 4.0.0-next.2
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/index.cjs +5959 -18316
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +56 -0
- package/dist/index.d.ts +50 -126
- package/dist/index.js +5943 -18287
- package/dist/index.js.map +1 -0
- package/package.json +18 -18
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as _orion_js_resolvers from '@orion-js/resolvers';
|
|
2
|
+
|
|
3
|
+
interface PaginatedCursor {
|
|
4
|
+
count?: () => Promise<number> | number;
|
|
5
|
+
toArray: () => Promise<any[]>;
|
|
6
|
+
limit?: (newLimit: number) => void;
|
|
7
|
+
skip?: (newSkip: number) => void;
|
|
8
|
+
sort?: (newSort: {
|
|
9
|
+
[key: string]: 1 | -1;
|
|
10
|
+
}) => void;
|
|
11
|
+
}
|
|
12
|
+
type PaginatedResolverGetCursorResultWithCount = {
|
|
13
|
+
count: () => Promise<number> | number;
|
|
14
|
+
cursor: PaginatedCursor;
|
|
15
|
+
};
|
|
16
|
+
type PaginatedResolverGetCursorResult = PaginatedCursor | PaginatedResolverGetCursorResultWithCount;
|
|
17
|
+
interface PaginatedResolverOpts {
|
|
18
|
+
returns: any;
|
|
19
|
+
getCursor: (params?: any, viewer?: any) => Promise<PaginatedResolverGetCursorResult>;
|
|
20
|
+
allowedSorts?: string[];
|
|
21
|
+
defaultSortBy?: string;
|
|
22
|
+
defaultSortType?: 'asc' | 'desc';
|
|
23
|
+
params?: any;
|
|
24
|
+
modelName?: string;
|
|
25
|
+
permissionsOptions?: any;
|
|
26
|
+
}
|
|
27
|
+
declare function paginatedResolver({ returns, params, allowedSorts, defaultSortBy, defaultSortType, getCursor, getCursorAndCount, modelName, ...otherOptions }: PaginatedResolverOpts & {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}): _orion_js_resolvers.Resolver<(params: any, viewer: any, info?: any) => Promise<{
|
|
30
|
+
cursor: PaginatedCursor;
|
|
31
|
+
params: any;
|
|
32
|
+
viewer: any;
|
|
33
|
+
options: {
|
|
34
|
+
skip: number;
|
|
35
|
+
limit: any;
|
|
36
|
+
};
|
|
37
|
+
count: number;
|
|
38
|
+
}>, undefined>;
|
|
39
|
+
|
|
40
|
+
declare function export_default({ collection, params, resolve, ...otherOptions }: {
|
|
41
|
+
[x: string]: any;
|
|
42
|
+
collection: any;
|
|
43
|
+
params: any;
|
|
44
|
+
resolve: any;
|
|
45
|
+
}): _orion_js_resolvers.Resolver<(params: any, viewer: any, info?: any) => Promise<{
|
|
46
|
+
params: any;
|
|
47
|
+
cursor: any;
|
|
48
|
+
viewer: any;
|
|
49
|
+
}>, undefined>;
|
|
50
|
+
|
|
51
|
+
interface PagiantedQueryDescriptor extends Omit<PropertyDecorator, 'value'> {
|
|
52
|
+
value?: PaginatedResolverOpts['getCursor'];
|
|
53
|
+
}
|
|
54
|
+
declare function PaginatedQuery(options: Omit<PaginatedResolverOpts, 'getCursor'>): (target: any, propertyKey: string, descriptor: PagiantedQueryDescriptor) => void;
|
|
55
|
+
|
|
56
|
+
export { type PagiantedQueryDescriptor, PaginatedQuery, paginatedResolver, export_default as tokenPaginatedResolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,132 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _orion_js_resolvers from '@orion-js/resolvers';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
export interface OrionCache {
|
|
17
|
-
/**
|
|
18
|
-
* Save data in the cache
|
|
19
|
-
*/
|
|
20
|
-
set(key: string, value: any, options?: SetCacheOptions): Promise<void> | void;
|
|
21
|
-
/**
|
|
22
|
-
* Get data from the cache
|
|
23
|
-
*/
|
|
24
|
-
get(key: string, options?: GetCacheOptions): Promise<StoredCacheData>;
|
|
25
|
-
/**
|
|
26
|
-
* Removes data from the cache
|
|
27
|
-
*/
|
|
28
|
-
invalidate(key: string): Promise<void> | void;
|
|
29
|
-
}
|
|
30
|
-
export type Blackbox = {
|
|
31
|
-
[name: string]: any;
|
|
32
|
-
};
|
|
33
|
-
export type GlobalCheckPermissions = (params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
34
|
-
export type ModelCheckPermissions = (parent: any, params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
35
|
-
export type GlobalGetCacheKey = (params: any, viewer: any, info: any) => Promise<any>;
|
|
36
|
-
export type ModelGetCacheKey = (parent: any, params: any, viewer: any, info: any) => Promise<any>;
|
|
37
|
-
export interface ExecuteOptions {
|
|
38
|
-
params: Blackbox;
|
|
39
|
-
viewer: any;
|
|
40
|
-
parent?: any;
|
|
41
|
-
info?: any;
|
|
42
|
-
options: ResolverOptions;
|
|
43
|
-
}
|
|
44
|
-
export type Parameters$1<T> = T extends (...args: infer P) => any ? P : never;
|
|
45
|
-
export type ReturnType$1<T> = T extends (...args: any) => infer R ? R : any;
|
|
46
|
-
export type ResolverParams<Resolve, IsModel> = IsModel extends undefined ? Parameters$1<Resolve>[0] : Parameters$1<Resolve>[1];
|
|
47
|
-
export interface ExecuteParams<Resolve = Function, IsModel = undefined> {
|
|
48
|
-
params?: ResolverParams<Resolve, IsModel>;
|
|
49
|
-
viewer?: any;
|
|
50
|
-
parent?: IsModel extends undefined ? undefined : Parameters$1<Resolve>[0];
|
|
51
|
-
info?: any;
|
|
52
|
-
}
|
|
53
|
-
export type Execute<Resolve = Function, IsModel = undefined> = (executeOptions: ExecuteParams<Resolve, IsModel>) => ReturnType$1<Resolve>;
|
|
54
|
-
export interface SharedResolverOptions {
|
|
55
|
-
resolverId?: string;
|
|
56
|
-
params?: any;
|
|
57
|
-
returns?: any;
|
|
58
|
-
mutation?: boolean;
|
|
59
|
-
private?: boolean;
|
|
60
|
-
checkPermission?: GlobalCheckPermissions | ModelCheckPermissions;
|
|
61
|
-
getCacheKey?: GlobalGetCacheKey | ModelGetCacheKey;
|
|
62
|
-
cache?: number;
|
|
63
|
-
cacheProvider?: OrionCache;
|
|
64
|
-
permissionsOptions?: any;
|
|
65
|
-
middlewares?: ResolverMiddleware[];
|
|
66
|
-
}
|
|
67
|
-
export interface ResolverOptions<Resolve = Function> extends SharedResolverOptions {
|
|
68
|
-
resolve: Resolve;
|
|
69
|
-
}
|
|
70
|
-
export type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
71
|
-
export interface Resolver<Resolve = Function, IsModel = undefined> extends SharedResolverOptions {
|
|
72
|
-
execute: Execute<Resolve, IsModel>;
|
|
73
|
-
resolve: Resolve;
|
|
74
|
-
modelResolve: IsModel extends undefined ? undefined : OmitFirstArg<Resolve>;
|
|
75
|
-
}
|
|
76
|
-
export type ResolverMiddleware = (executeOptions: ExecuteOptions, next: () => Promise<any>) => Promise<any>;
|
|
77
|
-
export interface PaginatedCursor {
|
|
78
|
-
count?: () => Promise<number> | number;
|
|
79
|
-
toArray: () => Promise<any[]>;
|
|
80
|
-
limit?: (newLimit: number) => void;
|
|
81
|
-
skip?: (newSkip: number) => void;
|
|
82
|
-
sort?: (newSort: {
|
|
83
|
-
[key: string]: 1 | -1;
|
|
84
|
-
}) => void;
|
|
85
|
-
}
|
|
86
|
-
export type PaginatedResolverGetCursorResultWithCount = {
|
|
87
|
-
count: () => Promise<number> | number;
|
|
88
|
-
cursor: PaginatedCursor;
|
|
3
|
+
interface PaginatedCursor {
|
|
4
|
+
count?: () => Promise<number> | number;
|
|
5
|
+
toArray: () => Promise<any[]>;
|
|
6
|
+
limit?: (newLimit: number) => void;
|
|
7
|
+
skip?: (newSkip: number) => void;
|
|
8
|
+
sort?: (newSort: {
|
|
9
|
+
[key: string]: 1 | -1;
|
|
10
|
+
}) => void;
|
|
11
|
+
}
|
|
12
|
+
type PaginatedResolverGetCursorResultWithCount = {
|
|
13
|
+
count: () => Promise<number> | number;
|
|
14
|
+
cursor: PaginatedCursor;
|
|
89
15
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}): Resolver<(params: any, viewer: any, info?: any) => Promise<{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
16
|
+
type PaginatedResolverGetCursorResult = PaginatedCursor | PaginatedResolverGetCursorResultWithCount;
|
|
17
|
+
interface PaginatedResolverOpts {
|
|
18
|
+
returns: any;
|
|
19
|
+
getCursor: (params?: any, viewer?: any) => Promise<PaginatedResolverGetCursorResult>;
|
|
20
|
+
allowedSorts?: string[];
|
|
21
|
+
defaultSortBy?: string;
|
|
22
|
+
defaultSortType?: 'asc' | 'desc';
|
|
23
|
+
params?: any;
|
|
24
|
+
modelName?: string;
|
|
25
|
+
permissionsOptions?: any;
|
|
26
|
+
}
|
|
27
|
+
declare function paginatedResolver({ returns, params, allowedSorts, defaultSortBy, defaultSortType, getCursor, getCursorAndCount, modelName, ...otherOptions }: PaginatedResolverOpts & {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}): _orion_js_resolvers.Resolver<(params: any, viewer: any, info?: any) => Promise<{
|
|
30
|
+
cursor: PaginatedCursor;
|
|
31
|
+
params: any;
|
|
32
|
+
viewer: any;
|
|
33
|
+
options: {
|
|
34
|
+
skip: number;
|
|
35
|
+
limit: any;
|
|
36
|
+
};
|
|
37
|
+
count: number;
|
|
112
38
|
}>, undefined>;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
39
|
+
|
|
40
|
+
declare function export_default({ collection, params, resolve, ...otherOptions }: {
|
|
41
|
+
[x: string]: any;
|
|
42
|
+
collection: any;
|
|
43
|
+
params: any;
|
|
44
|
+
resolve: any;
|
|
45
|
+
}): _orion_js_resolvers.Resolver<(params: any, viewer: any, info?: any) => Promise<{
|
|
46
|
+
params: any;
|
|
47
|
+
cursor: any;
|
|
48
|
+
viewer: any;
|
|
122
49
|
}>, undefined>;
|
|
123
|
-
export interface PagiantedQueryDescriptor extends Omit<PropertyDecorator, "value"> {
|
|
124
|
-
value?: PaginatedResolverOpts["getCursor"];
|
|
125
|
-
}
|
|
126
|
-
export declare function PaginatedQuery(options: Omit<PaginatedResolverOpts, "getCursor">): (target: any, propertyKey: string, descriptor: PagiantedQueryDescriptor) => void;
|
|
127
50
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
51
|
+
interface PagiantedQueryDescriptor extends Omit<PropertyDecorator, 'value'> {
|
|
52
|
+
value?: PaginatedResolverOpts['getCursor'];
|
|
53
|
+
}
|
|
54
|
+
declare function PaginatedQuery(options: Omit<PaginatedResolverOpts, 'getCursor'>): (target: any, propertyKey: string, descriptor: PagiantedQueryDescriptor) => void;
|
|
131
55
|
|
|
132
|
-
export {};
|
|
56
|
+
export { type PagiantedQueryDescriptor, PaginatedQuery, paginatedResolver, export_default as tokenPaginatedResolver };
|