Skip to content

Commit d77b45c

Browse files
authored
Backend request improvements (#14642)
* Add the `fullResponse` flag as an option for `makeRequest` to return the raw HTTP response * Deprecate the `environment_name` field when creating a Connect token, in favour of the `environment` name in the client's constructor * Disable markdown lint rule for dup headers in the changelog * Bump patch version to `1.0.2`
1 parent 874142e commit d77b45c

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

packages/sdk/CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
<!-- markdownlint-disable MD024 -->
12
# Changelog
23

3-
## [1.0.0-rc.1] - 2024-11-01
4+
## [1.0.2] - 2024-11-14
5+
6+
### Changed
7+
8+
- Deprecated the `environment_name` field in the `ConnectTokenOpts` type, as it
9+
is no longer used by the SDK nor the Connect API. The environment name is now
10+
exclusively determined by the `environment` field in the `BackendClientOpts`
11+
type, read during the client creation.
12+
13+
### Added
14+
15+
- Added a new optional flag to `RequestOptions` called `fullResponse`, which
16+
allows the user to get the full HTTP response object, including the headers
17+
and status code.
18+
19+
## [1.0.0] - 2024-11-01
420

521
### Changed
622

packages/sdk/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/sdk",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Pipedream SDK",
55
"main": "dist/server/index.js",
66
"module": "dist/server/index.js",

packages/sdk/src/server/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export type ConnectTokenOpts = {
8787
/**
8888
* Specify the environment ("production" or "development") to use for the
8989
* account connection flow. Defaults to "production".
90+
*
91+
* @deprecated in favor of the `environment` field in `BackendClientOpts`.
92+
* This field is completely ignored.
9093
*/
9194
environment_name?: string;
9295
};
@@ -292,6 +295,14 @@ interface RequestOptions extends Omit<RequestInit, "headers" | "body"> {
292295
* The body of the request.
293296
*/
294297
body?: Record<string, unknown> | string | FormData | URLSearchParams | null;
298+
299+
/**
300+
* A flag to indicate that you want to get the full response object, not just
301+
* the body. Note that when this flag is set, responses with unsuccessful HTTP
302+
* statuses won't throw exceptions. Instead, you'll need to check the status
303+
* code in the response object. Defaults to false.
304+
*/
305+
fullResponse?: boolean;
295306
}
296307

297308
/**
@@ -422,6 +433,7 @@ export class BackendClient {
422433
body,
423434
method = "GET",
424435
baseURL = this.baseApiUrl,
436+
fullResponse = false,
425437
...fetchOpts
426438
} = opts;
427439

@@ -472,6 +484,9 @@ export class BackendClient {
472484
}
473485

474486
const response: Response = await fetch(url.toString(), requestOptions);
487+
if (fullResponse) {
488+
return response as unknown as T;
489+
}
475490

476491
if (!response.ok) {
477492
const errorBody = await response.text();

0 commit comments

Comments
 (0)