From e781072bbf5b20501797bf07984e8bfba3a0130a Mon Sep 17 00:00:00 2001 From: Hassan_Wari <85742599+hassan254-prog@users.noreply.github.com> Date: Thu, 30 Jan 2025 22:37:58 +0300 Subject: [PATCH] fix(pagination): add flag to optionally add params to body (#3404) ## 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. --- .../lib/services/__snapshots__/model.service.unit.test.ts.snap | 1 + packages/runner-sdk/lib/action.ts | 2 +- packages/runner-sdk/models.d.ts | 1 + packages/shared/lib/models/Proxy.ts | 1 + packages/types/lib/proxy/api.ts | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cli/lib/services/__snapshots__/model.service.unit.test.ts.snap b/packages/cli/lib/services/__snapshots__/model.service.unit.test.ts.snap index e93b615c94b..c39f41c2401 100644 --- a/packages/cli/lib/services/__snapshots__/model.service.unit.test.ts.snap +++ b/packages/cli/lib/services/__snapshots__/model.service.unit.test.ts.snap @@ -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; diff --git a/packages/runner-sdk/lib/action.ts b/packages/runner-sdk/lib/action.ts index 5b9b340b148..2f2a19261cd 100644 --- a/packages/runner-sdk/lib/action.ts +++ b/packages/runner-sdk/lib/action.ts @@ -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 = ((passPaginationParamsInBody ? config.data : config.params) as Record) ?? {}; const limitParameterName: string = paginationConfig.limit_name_in_request; diff --git a/packages/runner-sdk/models.d.ts b/packages/runner-sdk/models.d.ts index b43ad61986b..a6c8c91f09d 100644 --- a/packages/runner-sdk/models.d.ts +++ b/packages/runner-sdk/models.d.ts @@ -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; diff --git a/packages/shared/lib/models/Proxy.ts b/packages/shared/lib/models/Proxy.ts index 45822bb735c..739d9770fa5 100644 --- a/packages/shared/lib/models/Proxy.ts +++ b/packages/shared/lib/models/Proxy.ts @@ -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 { diff --git a/packages/types/lib/proxy/api.ts b/packages/types/lib/proxy/api.ts index 6ab66df5a0b..974b087384a 100644 --- a/packages/types/lib/proxy/api.ts +++ b/packages/types/lib/proxy/api.ts @@ -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;