Skip to content

Commit f8f13ab

Browse files
add ProxyResponse type, change DEBUG location (#16366)
* add ProxyResponse type, change DEBUG location * Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * linting --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent cf26c91 commit f8f13ab

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

packages/sdk/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
# Changelog
44

5+
## [1.5.3] - 2025-04-18
6+
7+
### Added
8+
9+
- Added `ProxyResponse` type for makeProxyRequest
10+
- changed the location of connect DEBUG calls so they'll still show in the
11+
error case.
12+
513
## [1.5.2] - 2025-04-15
614

715
### Added

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pipedream/sdk",
33
"type": "module",
4-
"version": "1.5.2",
4+
"version": "1.5.3",
55
"description": "Pipedream SDK",
66
"main": "./dist/server.js",
77
"module": "./dist/server.js",

packages/sdk/src/server/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ export type ProxyTargetApiRequest = {
149149
options: ProxyTargetApiOpts;
150150
};
151151

152+
/**
153+
* The parsed response body from a proxied API request.
154+
*
155+
* If the response has a Content-Type of application/json, the body will be parsed
156+
* and returned as an object. Otherwise the type will be a string.
157+
*/
158+
export type ProxyResponse = Record<string, unknown> | string;
159+
152160
/**
153161
* Creates a new instance of BackendClient with the provided options.
154162
*
@@ -422,7 +430,7 @@ export class BackendClient extends BaseClient {
422430
*
423431
* @returns A promise resolving to the response from the downstream service
424432
*/
425-
public makeProxyRequest(proxyOptions: ProxyApiOpts, targetRequest: ProxyTargetApiRequest): Promise<string> {
433+
public makeProxyRequest(proxyOptions: ProxyApiOpts, targetRequest: ProxyTargetApiRequest): Promise<ProxyResponse> {
426434
const url64 = btoa(targetRequest.url).replace(/\+/g, "-")
427435
.replace(/\//g, "_")
428436
.replace(/=+$/, "");

packages/sdk/src/shared/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,11 +1021,15 @@ export abstract class BaseClient {
10211021

10221022
const rawBody = await response.text();
10231023

1024+
DEBUG("status: ", response.status)
1025+
DEBUG("url: ", url.toString())
1026+
DEBUG("requestOptions: ", requestOptions)
1027+
DEBUG("rawBody: ", rawBody)
1028+
10241029
if (!response.ok) {
10251030
throw new Error(`HTTP error! status: ${response.status}, body: ${rawBody}`);
10261031
}
10271032

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

0 commit comments

Comments
 (0)