@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.
@@ -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
- // Generated by dts-bundle-generator v9.5.1
1
+ import * as _orion_js_resolvers from '@orion-js/resolvers';
2
2
 
3
- // Generated by dts-bundle-generator v9.5.1
4
- // Generated by dts-bundle-generator v9.5.1
5
- export interface StoredCacheData {
6
- value: any;
7
- expires?: Date;
8
- }
9
- export interface SetCacheOptions {
10
- ttl?: number;
11
- }
12
- export interface GetCacheOptions {
13
- ttl?: number;
14
- fallback?(): Promise<any>;
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
- export type PaginatedResolverGetCursorResult = PaginatedCursor | PaginatedResolverGetCursorResultWithCount;
91
- export interface PaginatedResolverOpts {
92
- returns: any;
93
- getCursor: (params?: any, viewer?: any) => Promise<PaginatedResolverGetCursorResult>;
94
- allowedSorts?: string[];
95
- defaultSortBy?: string;
96
- defaultSortType?: "asc" | "desc";
97
- params?: any;
98
- modelName?: string;
99
- permissionsOptions?: any;
100
- }
101
- export function paginatedResolver({ returns, params, allowedSorts, defaultSortBy, defaultSortType, getCursor, getCursorAndCount, modelName, ...otherOptions }: PaginatedResolverOpts & {
102
- [key: string]: any;
103
- }): Resolver<(params: any, viewer: any, info?: any) => Promise<{
104
- cursor: PaginatedCursor;
105
- params: any;
106
- viewer: any;
107
- options: {
108
- skip: number;
109
- limit: any;
110
- };
111
- count: number;
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
- declare function _default({ collection, params, resolve, ...otherOptions }: {
114
- [x: string]: any;
115
- collection: any;
116
- params: any;
117
- resolve: any;
118
- }): Resolver<(params: any, viewer: any, info?: any) => Promise<{
119
- params: any;
120
- cursor: any;
121
- viewer: any;
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
- export {
129
- _default as tokenPaginatedResolver,
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 };