Skip to content

Commit

Permalink
fix(pagination): add flag to optionally add params to body (#3404)
Browse files Browse the repository at this point in the history
## Describe the problem and your solution
Some providers require pagination parameters to be passed as query
parameters for methods other than `GET`. This PR introduces a flag in
the `proxyConfiguration` that, when set to `false`, ensures pagination
parameters are included in the request body for `POST`, `PUT`, and
`PATCH` requests, preserving the original behavior.

<!-- Issue ticket number and link (if applicable) -->

<!-- Testing instructions (skip if just adding/editing providers) -->
  • Loading branch information
hassan254-prog authored Jan 30, 2025
1 parent f323eaf commit e781072
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface Pagination {
limit?: number;
response_path?: string;
limit_name_in_request: string;
in_body?: boolean;
}
interface CursorPagination extends Pagination {
cursor_path_in_response: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/runner-sdk/lib/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export abstract class NangoActionBase {
config.method = config.method || 'GET';

const configMethod = config.method.toLocaleLowerCase();
const passPaginationParamsInBody: boolean = ['post', 'put', 'patch'].includes(configMethod);
const passPaginationParamsInBody: boolean = config.paginate?.in_body ?? ['post', 'put', 'patch'].includes(configMethod);

const updatedBodyOrParams: Record<string, any> = ((passPaginationParamsInBody ? config.data : config.params) as Record<string, any>) ?? {};
const limitParameterName: string = paginationConfig.limit_name_in_request;
Expand Down
1 change: 1 addition & 0 deletions packages/runner-sdk/models.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface Pagination {
limit?: number;
response_path?: string;
limit_name_in_request: string;
in_body?: boolean;
}
interface CursorPagination extends Pagination {
cursor_path_in_response: string;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/lib/models/Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface Pagination {
limit?: number;
response_path?: string;
limit_name_in_request: string;
in_body?: boolean;
}

export interface CursorPagination extends Pagination {
Expand Down
1 change: 1 addition & 0 deletions packages/types/lib/proxy/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface PaginationBase {
limit?: number;
response_path?: string;
limit_name_in_request: string;
in_body?: boolean;
}

export type Pagination = CursorPagination | LinkPagination | OffsetPagination;
Expand Down

0 comments on commit e781072

Please sign in to comment.