Skip to content

Commit

Permalink
fix(core): Add PaginationParams to general find method (#3095)
Browse files Browse the repository at this point in the history
  • Loading branch information
fratzinger committed Mar 10, 2023
1 parent 97c3ed9 commit 8ebdcf5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 3 additions & 7 deletions packages/adapter-commons/src/declarations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Query, Params, Paginated, Id } from '@feathersjs/feathers'
import { Query, Params, Paginated, Id, PaginationParams, PaginationOptions } from '@feathersjs/feathers'

export type FilterQueryOptions = {
filters?: FilterSettings
Expand All @@ -12,12 +12,8 @@ export type FilterSettings = {
[key: string]: QueryFilter | true
}

export interface PaginationOptions {
default?: number
max?: number
}

export type PaginationParams = false | PaginationOptions
// re-export from @feathersjs/feathers to prevent breaking changes
export { PaginationOptions, PaginationParams }

export interface AdapterServiceOptions {
/**
Expand Down
11 changes: 9 additions & 2 deletions packages/feathers/src/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export interface ServiceMethods<
ServiceParams = Params,
PatchData = Partial<Data>
> {
find(params?: ServiceParams): Promise<Result | Result[]>
find(params?: ServiceParams & { paginate?: PaginationParams }): Promise<Result | Result[]>

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

Expand Down Expand Up @@ -137,7 +137,7 @@ export interface ServiceAddons<A = Application, S = Service> extends EventEmitte
}

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

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

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

export interface PaginationOptions {
default?: number
max?: number
}

export type PaginationParams = false | PaginationOptions

export interface Http {
/**
* A writeable, optional property with status code override.
Expand Down

0 comments on commit 8ebdcf5

Please sign in to comment.