Skip to content

Commit 8ebdcf5

Browse files
authored
fix(core): Add PaginationParams to general find method (#3095)
1 parent 97c3ed9 commit 8ebdcf5

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

packages/adapter-commons/src/declarations.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Query, Params, Paginated, Id } from '@feathersjs/feathers'
1+
import { Query, Params, Paginated, Id, PaginationParams, PaginationOptions } from '@feathersjs/feathers'
22

33
export type FilterQueryOptions = {
44
filters?: FilterSettings
@@ -12,12 +12,8 @@ export type FilterSettings = {
1212
[key: string]: QueryFilter | true
1313
}
1414

15-
export interface PaginationOptions {
16-
default?: number
17-
max?: number
18-
}
19-
20-
export type PaginationParams = false | PaginationOptions
15+
// re-export from @feathersjs/feathers to prevent breaking changes
16+
export { PaginationOptions, PaginationParams }
2117

2218
export interface AdapterServiceOptions {
2319
/**

packages/feathers/src/declarations.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export interface ServiceMethods<
7272
ServiceParams = Params,
7373
PatchData = Partial<Data>
7474
> {
75-
find(params?: ServiceParams): Promise<Result | Result[]>
75+
find(params?: ServiceParams & { paginate?: PaginationParams }): Promise<Result | Result[]>
7676

7777
get(id: Id, params?: ServiceParams): Promise<Result>
7878

@@ -137,7 +137,7 @@ export interface ServiceAddons<A = Application, S = Service> extends EventEmitte
137137
}
138138

139139
export interface ServiceHookOverloads<S, P = Params> {
140-
find(params: P, context: HookContext): Promise<HookContext>
140+
find(params: P & { paginate?: PaginationParams }, context: HookContext): Promise<HookContext>
141141

142142
get(id: Id, params: P, context: HookContext): Promise<HookContext>
143143

@@ -331,6 +331,13 @@ export interface Params<Q = Query> {
331331
headers?: { [key: string]: any }
332332
}
333333

334+
export interface PaginationOptions {
335+
default?: number
336+
max?: number
337+
}
338+
339+
export type PaginationParams = false | PaginationOptions
340+
334341
export interface Http {
335342
/**
336343
* A writeable, optional property with status code override.

0 commit comments

Comments
 (0)