Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

# Changelog

## [1.5.3] - 2025-04-18

### Added

- Added `ProxyResponse` type for makeProxyRequest
- changed the location of connect DEBUG calls so they'll still show in the
error case.

## [1.5.2] - 2025-04-15

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pipedream/sdk",
"type": "module",
"version": "1.5.2",
"version": "1.5.3",
"description": "Pipedream SDK",
"main": "./dist/server.js",
"module": "./dist/server.js",
Expand Down
10 changes: 9 additions & 1 deletion packages/sdk/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ export type ProxyTargetApiRequest = {
options: ProxyTargetApiOpts;
};

/**
* The parsed response body from a proxied API request.
*
* If the response has a Content-Type of application/json, the body will be parsed
* and returned as an object. Otherwise the type will be a string.
*/
export type ProxyResponse = Record<string, unknown> | string;

/**
* Creates a new instance of BackendClient with the provided options.
*
Expand Down Expand Up @@ -422,7 +430,7 @@ export class BackendClient extends BaseClient {
*
* @returns A promise resolving to the response from the downstream service
*/
public makeProxyRequest(proxyOptions: ProxyApiOpts, targetRequest: ProxyTargetApiRequest): Promise<string> {
public makeProxyRequest(proxyOptions: ProxyApiOpts, targetRequest: ProxyTargetApiRequest): Promise<ProxyResponse> {
const url64 = btoa(targetRequest.url).replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");
Expand Down
6 changes: 5 additions & 1 deletion packages/sdk/src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,11 +1021,15 @@ export abstract class BaseClient {

const rawBody = await response.text();

DEBUG("status: ", response.status)
DEBUG("url: ", url.toString())
DEBUG("requestOptions: ", requestOptions)
DEBUG("rawBody: ", rawBody)

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}, body: ${rawBody}`);
}

DEBUG(response.status, url.toString(), requestOptions, rawBody)
const contentType = response.headers.get("Content-Type");
if (contentType && contentType.includes("application/json")) {
try {
Expand Down
Loading