Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend request improvements #14642

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
18 changes: 17 additions & 1 deletion packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
<!-- markdownlint-disable MD024 -->
# Changelog

## [1.0.0-rc.1] - 2024-11-01
## [1.0.2] - 2024-11-14

### Changed

- Deprecated the `environment_name` field in the `ConnectTokenOpts` type, as it
is no longer used by the SDK nor the Connect API. The environment name is now
exclusively determined by the `environment` field in the `BackendClientOpts`
type, read during the client creation.

### Added

- Added a new optional flag to `RequestOptions` called `fullResponse`, which
allows the user to get the full HTTP response object, including the headers
and status code.

## [1.0.0] - 2024-11-01

### Changed

Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/sdk",
"version": "1.0.1",
"version": "1.0.2",
"description": "Pipedream SDK",
"main": "dist/server/index.js",
"module": "dist/server/index.js",
Expand Down
15 changes: 15 additions & 0 deletions packages/sdk/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export type ConnectTokenOpts = {
/**
* Specify the environment ("production" or "development") to use for the
* account connection flow. Defaults to "production".
*
* @deprecated in favor of the `environment` field in `BackendClientOpts`.
* This field is completely ignored.
*/
environment_name?: string;
};
Expand Down Expand Up @@ -292,6 +295,14 @@ interface RequestOptions extends Omit<RequestInit, "headers" | "body"> {
* The body of the request.
*/
body?: Record<string, unknown> | string | FormData | URLSearchParams | null;

/**
* A flag to indicate that you want to get the full response object, not just
* the body. Note that when this flag is set, responses with unsuccessful HTTP
* statuses won't throw exceptions. Instead, you'll need to check the status
* code in the response object. Defaults to false.
*/
fullResponse?: boolean;
}

/**
Expand Down Expand Up @@ -422,6 +433,7 @@ export class BackendClient {
body,
method = "GET",
baseURL = this.baseApiUrl,
fullResponse = false,
...fetchOpts
} = opts;

Expand Down Expand Up @@ -472,6 +484,9 @@ export class BackendClient {
}

const response: Response = await fetch(url.toString(), requestOptions);
if (fullResponse) {
return response as unknown as T;
}

if (!response.ok) {
const errorBody = await response.text();
Expand Down
Loading