@orion-js/paginated-mongodb 4.0.0-next.3 → 4.0.0-next.4
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 +155 -5632
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +105 -26
- package/dist/index.d.ts +105 -26
- package/dist/index.js +141 -5632
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,56 +1,135 @@
|
|
|
1
1
|
import * as _orion_js_resolvers from '@orion-js/resolvers';
|
|
2
|
+
import { Schema, InferSchemaType } from '@orion-js/schema';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
declare const paginatedResolverBaseParamsSchema: {
|
|
5
|
+
readonly page: {
|
|
6
|
+
readonly type: "integer";
|
|
7
|
+
readonly defaultValue: 1;
|
|
8
|
+
readonly min: 1;
|
|
9
|
+
};
|
|
10
|
+
readonly limit: {
|
|
11
|
+
readonly type: "integer";
|
|
12
|
+
readonly defaultValue: 0;
|
|
13
|
+
readonly min: 0;
|
|
14
|
+
readonly max: 200;
|
|
15
|
+
};
|
|
16
|
+
readonly sortBy: {
|
|
17
|
+
readonly type: StringConstructor;
|
|
18
|
+
readonly optional: true;
|
|
19
|
+
};
|
|
20
|
+
readonly sortType: {
|
|
21
|
+
readonly type: StringConstructor;
|
|
22
|
+
readonly allowedValues: readonly ["asc", "desc"];
|
|
23
|
+
readonly optional: true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface PaginatedCursor<TReturns extends Schema = Schema> {
|
|
4
28
|
count?: () => Promise<number> | number;
|
|
5
|
-
toArray: () => Promise<
|
|
29
|
+
toArray: () => Promise<InferSchemaType<TReturns>[]>;
|
|
6
30
|
limit?: (newLimit: number) => void;
|
|
7
31
|
skip?: (newSkip: number) => void;
|
|
8
32
|
sort?: (newSort: {
|
|
9
33
|
[key: string]: 1 | -1;
|
|
10
34
|
}) => void;
|
|
11
35
|
}
|
|
12
|
-
type PaginatedResolverGetCursorResultWithCount = {
|
|
36
|
+
type PaginatedResolverGetCursorResultWithCount<TReturns extends Schema = Schema> = {
|
|
13
37
|
count: () => Promise<number> | number;
|
|
14
|
-
cursor: PaginatedCursor
|
|
38
|
+
cursor: PaginatedCursor<TReturns>;
|
|
15
39
|
};
|
|
16
|
-
type PaginatedResolverGetCursorResult = PaginatedCursor | PaginatedResolverGetCursorResultWithCount
|
|
17
|
-
interface PaginatedResolverOpts {
|
|
18
|
-
returns:
|
|
19
|
-
getCursor: (params?:
|
|
40
|
+
type PaginatedResolverGetCursorResult<TReturns extends Schema = Schema> = PaginatedCursor<TReturns> | PaginatedResolverGetCursorResultWithCount<TReturns>;
|
|
41
|
+
interface PaginatedResolverOpts<TParams extends Schema = Schema, TReturns extends Schema = Schema, TViewer = any> {
|
|
42
|
+
returns: TReturns;
|
|
43
|
+
getCursor: (params?: InferSchemaType<typeof paginatedResolverBaseParamsSchema & TParams>, viewer?: TViewer) => Promise<PaginatedResolverGetCursorResult<TReturns>>;
|
|
20
44
|
allowedSorts?: string[];
|
|
21
45
|
defaultSortBy?: string;
|
|
22
46
|
defaultSortType?: 'asc' | 'desc';
|
|
23
|
-
params?:
|
|
47
|
+
params?: TParams;
|
|
24
48
|
modelName?: string;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Just check the permissions in the resolver instead
|
|
51
|
+
*/
|
|
25
52
|
permissionsOptions?: any;
|
|
26
53
|
}
|
|
27
|
-
declare function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
declare function createPaginatedResolver<TParams extends Schema = Schema, TReturns extends Schema = Schema, TViewer = any>({ returns, params, allowedSorts, defaultSortBy, defaultSortType, getCursor, modelName, ...otherOptions }: PaginatedResolverOpts<TParams, TReturns, TViewer>): _orion_js_resolvers.Resolver<_orion_js_resolvers.GlobalResolverResolve<{
|
|
55
|
+
readonly page: {
|
|
56
|
+
readonly type: "integer";
|
|
57
|
+
readonly defaultValue: 1;
|
|
58
|
+
readonly min: 1;
|
|
59
|
+
};
|
|
60
|
+
readonly limit: {
|
|
61
|
+
readonly type: "integer";
|
|
62
|
+
readonly defaultValue: 0;
|
|
63
|
+
readonly min: 0;
|
|
64
|
+
readonly max: 200;
|
|
36
65
|
};
|
|
37
|
-
|
|
38
|
-
|
|
66
|
+
readonly sortBy: {
|
|
67
|
+
readonly type: StringConstructor;
|
|
68
|
+
readonly optional: true;
|
|
69
|
+
};
|
|
70
|
+
readonly sortType: {
|
|
71
|
+
readonly type: StringConstructor;
|
|
72
|
+
readonly allowedValues: readonly ["asc", "desc"];
|
|
73
|
+
readonly optional: true;
|
|
74
|
+
};
|
|
75
|
+
} & TParams, {
|
|
76
|
+
readonly cursor: {
|
|
77
|
+
readonly type: "any";
|
|
78
|
+
readonly private: true;
|
|
79
|
+
};
|
|
80
|
+
readonly params: {
|
|
81
|
+
readonly type: {
|
|
82
|
+
readonly page: {
|
|
83
|
+
readonly type: "integer";
|
|
84
|
+
readonly defaultValue: 1;
|
|
85
|
+
readonly min: 1;
|
|
86
|
+
};
|
|
87
|
+
readonly limit: {
|
|
88
|
+
readonly type: "integer";
|
|
89
|
+
readonly defaultValue: 0;
|
|
90
|
+
readonly min: 0;
|
|
91
|
+
readonly max: 200;
|
|
92
|
+
};
|
|
93
|
+
readonly sortBy: {
|
|
94
|
+
readonly type: StringConstructor;
|
|
95
|
+
readonly optional: true;
|
|
96
|
+
};
|
|
97
|
+
readonly sortType: {
|
|
98
|
+
readonly type: StringConstructor;
|
|
99
|
+
readonly allowedValues: readonly ["asc", "desc"];
|
|
100
|
+
readonly optional: true;
|
|
101
|
+
};
|
|
102
|
+
} & TParams;
|
|
103
|
+
readonly private: true;
|
|
104
|
+
};
|
|
105
|
+
readonly viewer: {
|
|
106
|
+
readonly type: "any";
|
|
107
|
+
readonly private: true;
|
|
108
|
+
};
|
|
109
|
+
readonly options: {
|
|
110
|
+
readonly type: "any";
|
|
111
|
+
readonly private: true;
|
|
112
|
+
};
|
|
113
|
+
readonly count: {
|
|
114
|
+
readonly type: "integer";
|
|
115
|
+
readonly private: true;
|
|
116
|
+
};
|
|
117
|
+
}, any, any>, undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated Use createPaginatedResolver instead
|
|
120
|
+
*/
|
|
121
|
+
declare const paginatedResolver: typeof createPaginatedResolver;
|
|
39
122
|
|
|
40
123
|
declare function export_default({ collection, params, resolve, ...otherOptions }: {
|
|
41
124
|
[x: string]: any;
|
|
42
125
|
collection: any;
|
|
43
126
|
params: any;
|
|
44
127
|
resolve: any;
|
|
45
|
-
}): _orion_js_resolvers.Resolver<
|
|
46
|
-
params: any;
|
|
47
|
-
cursor: any;
|
|
48
|
-
viewer: any;
|
|
49
|
-
}>, undefined>;
|
|
128
|
+
}): _orion_js_resolvers.Resolver<_orion_js_resolvers.GlobalResolverResolve<any, any, any, any>, undefined>;
|
|
50
129
|
|
|
51
130
|
interface PagiantedQueryDescriptor extends Omit<PropertyDecorator, 'value'> {
|
|
52
131
|
value?: PaginatedResolverOpts['getCursor'];
|
|
53
132
|
}
|
|
54
133
|
declare function PaginatedQuery(options: Omit<PaginatedResolverOpts, 'getCursor'>): (target: any, propertyKey: string, descriptor: PagiantedQueryDescriptor) => void;
|
|
55
134
|
|
|
56
|
-
export { type PagiantedQueryDescriptor, PaginatedQuery, paginatedResolver, export_default as tokenPaginatedResolver };
|
|
135
|
+
export { type PagiantedQueryDescriptor, PaginatedQuery, createPaginatedResolver, paginatedResolver, export_default as tokenPaginatedResolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,56 +1,135 @@
|
|
|
1
1
|
import * as _orion_js_resolvers from '@orion-js/resolvers';
|
|
2
|
+
import { Schema, InferSchemaType } from '@orion-js/schema';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
declare const paginatedResolverBaseParamsSchema: {
|
|
5
|
+
readonly page: {
|
|
6
|
+
readonly type: "integer";
|
|
7
|
+
readonly defaultValue: 1;
|
|
8
|
+
readonly min: 1;
|
|
9
|
+
};
|
|
10
|
+
readonly limit: {
|
|
11
|
+
readonly type: "integer";
|
|
12
|
+
readonly defaultValue: 0;
|
|
13
|
+
readonly min: 0;
|
|
14
|
+
readonly max: 200;
|
|
15
|
+
};
|
|
16
|
+
readonly sortBy: {
|
|
17
|
+
readonly type: StringConstructor;
|
|
18
|
+
readonly optional: true;
|
|
19
|
+
};
|
|
20
|
+
readonly sortType: {
|
|
21
|
+
readonly type: StringConstructor;
|
|
22
|
+
readonly allowedValues: readonly ["asc", "desc"];
|
|
23
|
+
readonly optional: true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface PaginatedCursor<TReturns extends Schema = Schema> {
|
|
4
28
|
count?: () => Promise<number> | number;
|
|
5
|
-
toArray: () => Promise<
|
|
29
|
+
toArray: () => Promise<InferSchemaType<TReturns>[]>;
|
|
6
30
|
limit?: (newLimit: number) => void;
|
|
7
31
|
skip?: (newSkip: number) => void;
|
|
8
32
|
sort?: (newSort: {
|
|
9
33
|
[key: string]: 1 | -1;
|
|
10
34
|
}) => void;
|
|
11
35
|
}
|
|
12
|
-
type PaginatedResolverGetCursorResultWithCount = {
|
|
36
|
+
type PaginatedResolverGetCursorResultWithCount<TReturns extends Schema = Schema> = {
|
|
13
37
|
count: () => Promise<number> | number;
|
|
14
|
-
cursor: PaginatedCursor
|
|
38
|
+
cursor: PaginatedCursor<TReturns>;
|
|
15
39
|
};
|
|
16
|
-
type PaginatedResolverGetCursorResult = PaginatedCursor | PaginatedResolverGetCursorResultWithCount
|
|
17
|
-
interface PaginatedResolverOpts {
|
|
18
|
-
returns:
|
|
19
|
-
getCursor: (params?:
|
|
40
|
+
type PaginatedResolverGetCursorResult<TReturns extends Schema = Schema> = PaginatedCursor<TReturns> | PaginatedResolverGetCursorResultWithCount<TReturns>;
|
|
41
|
+
interface PaginatedResolverOpts<TParams extends Schema = Schema, TReturns extends Schema = Schema, TViewer = any> {
|
|
42
|
+
returns: TReturns;
|
|
43
|
+
getCursor: (params?: InferSchemaType<typeof paginatedResolverBaseParamsSchema & TParams>, viewer?: TViewer) => Promise<PaginatedResolverGetCursorResult<TReturns>>;
|
|
20
44
|
allowedSorts?: string[];
|
|
21
45
|
defaultSortBy?: string;
|
|
22
46
|
defaultSortType?: 'asc' | 'desc';
|
|
23
|
-
params?:
|
|
47
|
+
params?: TParams;
|
|
24
48
|
modelName?: string;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Just check the permissions in the resolver instead
|
|
51
|
+
*/
|
|
25
52
|
permissionsOptions?: any;
|
|
26
53
|
}
|
|
27
|
-
declare function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
declare function createPaginatedResolver<TParams extends Schema = Schema, TReturns extends Schema = Schema, TViewer = any>({ returns, params, allowedSorts, defaultSortBy, defaultSortType, getCursor, modelName, ...otherOptions }: PaginatedResolverOpts<TParams, TReturns, TViewer>): _orion_js_resolvers.Resolver<_orion_js_resolvers.GlobalResolverResolve<{
|
|
55
|
+
readonly page: {
|
|
56
|
+
readonly type: "integer";
|
|
57
|
+
readonly defaultValue: 1;
|
|
58
|
+
readonly min: 1;
|
|
59
|
+
};
|
|
60
|
+
readonly limit: {
|
|
61
|
+
readonly type: "integer";
|
|
62
|
+
readonly defaultValue: 0;
|
|
63
|
+
readonly min: 0;
|
|
64
|
+
readonly max: 200;
|
|
36
65
|
};
|
|
37
|
-
|
|
38
|
-
|
|
66
|
+
readonly sortBy: {
|
|
67
|
+
readonly type: StringConstructor;
|
|
68
|
+
readonly optional: true;
|
|
69
|
+
};
|
|
70
|
+
readonly sortType: {
|
|
71
|
+
readonly type: StringConstructor;
|
|
72
|
+
readonly allowedValues: readonly ["asc", "desc"];
|
|
73
|
+
readonly optional: true;
|
|
74
|
+
};
|
|
75
|
+
} & TParams, {
|
|
76
|
+
readonly cursor: {
|
|
77
|
+
readonly type: "any";
|
|
78
|
+
readonly private: true;
|
|
79
|
+
};
|
|
80
|
+
readonly params: {
|
|
81
|
+
readonly type: {
|
|
82
|
+
readonly page: {
|
|
83
|
+
readonly type: "integer";
|
|
84
|
+
readonly defaultValue: 1;
|
|
85
|
+
readonly min: 1;
|
|
86
|
+
};
|
|
87
|
+
readonly limit: {
|
|
88
|
+
readonly type: "integer";
|
|
89
|
+
readonly defaultValue: 0;
|
|
90
|
+
readonly min: 0;
|
|
91
|
+
readonly max: 200;
|
|
92
|
+
};
|
|
93
|
+
readonly sortBy: {
|
|
94
|
+
readonly type: StringConstructor;
|
|
95
|
+
readonly optional: true;
|
|
96
|
+
};
|
|
97
|
+
readonly sortType: {
|
|
98
|
+
readonly type: StringConstructor;
|
|
99
|
+
readonly allowedValues: readonly ["asc", "desc"];
|
|
100
|
+
readonly optional: true;
|
|
101
|
+
};
|
|
102
|
+
} & TParams;
|
|
103
|
+
readonly private: true;
|
|
104
|
+
};
|
|
105
|
+
readonly viewer: {
|
|
106
|
+
readonly type: "any";
|
|
107
|
+
readonly private: true;
|
|
108
|
+
};
|
|
109
|
+
readonly options: {
|
|
110
|
+
readonly type: "any";
|
|
111
|
+
readonly private: true;
|
|
112
|
+
};
|
|
113
|
+
readonly count: {
|
|
114
|
+
readonly type: "integer";
|
|
115
|
+
readonly private: true;
|
|
116
|
+
};
|
|
117
|
+
}, any, any>, undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated Use createPaginatedResolver instead
|
|
120
|
+
*/
|
|
121
|
+
declare const paginatedResolver: typeof createPaginatedResolver;
|
|
39
122
|
|
|
40
123
|
declare function export_default({ collection, params, resolve, ...otherOptions }: {
|
|
41
124
|
[x: string]: any;
|
|
42
125
|
collection: any;
|
|
43
126
|
params: any;
|
|
44
127
|
resolve: any;
|
|
45
|
-
}): _orion_js_resolvers.Resolver<
|
|
46
|
-
params: any;
|
|
47
|
-
cursor: any;
|
|
48
|
-
viewer: any;
|
|
49
|
-
}>, undefined>;
|
|
128
|
+
}): _orion_js_resolvers.Resolver<_orion_js_resolvers.GlobalResolverResolve<any, any, any, any>, undefined>;
|
|
50
129
|
|
|
51
130
|
interface PagiantedQueryDescriptor extends Omit<PropertyDecorator, 'value'> {
|
|
52
131
|
value?: PaginatedResolverOpts['getCursor'];
|
|
53
132
|
}
|
|
54
133
|
declare function PaginatedQuery(options: Omit<PaginatedResolverOpts, 'getCursor'>): (target: any, propertyKey: string, descriptor: PagiantedQueryDescriptor) => void;
|
|
55
134
|
|
|
56
|
-
export { type PagiantedQueryDescriptor, PaginatedQuery, paginatedResolver, export_default as tokenPaginatedResolver };
|
|
135
|
+
export { type PagiantedQueryDescriptor, PaginatedQuery, createPaginatedResolver, paginatedResolver, export_default as tokenPaginatedResolver };
|