Skip to content

Conversation

jsendo
Copy link
Contributor

@jsendo jsendo commented Feb 4, 2025

WHY

Summary by CodeRabbit

  • New Features

    • Introduced enhanced proxy request functionality, allowing flexible and secure requests with customizable options.
  • Bug Fixes

    • Improved the handling of headers in authorized requests for greater consistency.
  • Deprecations

    • Updated API method naming for improved clarity, deprecating older versions in favor of more intuitive alternatives.

Copy link

vercel bot commented Feb 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Feb 5, 2025 9:19pm
pipedream-docs ⬜️ Ignored (Inspect) Feb 5, 2025 9:19pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Feb 5, 2025 9:19pm

Copy link
Contributor

coderabbitai bot commented Feb 4, 2025

Walkthrough

This update introduces a new proxy request capability in the SDK. The BackendClient now features a makeProxyRequest method that encodes URLs in base64 and customizes headers before delegating to the makeConnectRequest method. Additionally, new types for defining proxy request options have been added. In the shared client, header handling in the makeAuthorizedRequest method has been clarified. Furthermore, several methods and types in the BaseClient have been deprecated in favor of renamed alternatives to improve API consistency.

Changes

File(s) Change Summary
packages/sdk/src/server/index.ts Added ProxyApiOpts, ProxyTargetApiOpts, and ProxyTargetApiRequest types; introduced makeProxyRequest method in BackendClient that encodes URLs and adjusts headers; imported RequestOptions.
packages/sdk/src/shared/index.ts Revised header handling in makeAuthorizedRequest and deprecated multiple methods/types in BaseClient, renaming them to more descriptive alternatives.
packages/sdk/CHANGELOG.md Added version entry [1.3.3] - 2025-02-5 indicating the addition of makeProxyRequest function to BaseClient.
packages/sdk/package.json Updated package version from "1.3.2" to "1.3.3".

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant B as BackendClient
    participant M as makeConnectRequest
    participant S as Proxy Service

    C->>B: makeProxyRequest(url, query, opts)
    B->>B: Encode URL (base64)\nModify Headers (add prefix)
    B->>M: Call makeConnectRequest with constructed options
    M-->>B: Return response
    B-->>C: Return proxy response
Loading

Suggested labels

enhancement, pd-api, javascript, tracked internally, prioritized

Suggested reviewers

  • dylburger

Poem

I'm a little rabbit with code to share,
Hopping through lines with extra flair.
A proxy method now hops in place,
And headers dance with base64 grace.
Deprecations cleared with a cheerful leap—
My bunny heart celebrates this code so deep!
🐰💻

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jsendo jsendo requested a review from bzwrk February 4, 2025 18:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d57c8f6 and 1e87d88.

📒 Files selected for processing (2)
  • packages/sdk/src/server/index.ts (3 hunks)
  • packages/sdk/src/shared/index.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Lint Code Base
packages/sdk/src/server/index.ts

[failure] 7-7:
Missing trailing comma


[failure] 120-120:
Unexpected any. Specify a different type


[failure] 396-396:
Unexpected any. Specify a different type


[failure] 396-396:
Unexpected any. Specify a different type


[failure] 398-398:
Expected indentation of 6 spaces but found 4


[failure] 399-399:
Expected indentation of 6 spaces but found 4

🪛 ESLint
packages/sdk/src/server/index.ts

[error] 7-8: Missing trailing comma.

(comma-dangle)


[error] 120-120: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)


[error] 396-396: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)


[error] 396-396: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)


[error] 398-398: Expected indentation of 6 spaces but found 4.

(indent)


[error] 399-399: Expected indentation of 6 spaces but found 4.

(indent)

🪛 GitHub Actions: Pull Request Checks
packages/sdk/src/server/index.ts

[error] 7-7: Missing trailing comma

🔇 Additional comments (1)
packages/sdk/src/shared/index.ts (1)

999-999: LGTM!

The header handling change in makeAuthorizedRequest is correct and maintains proper type safety.

@@ -4,7 +4,7 @@

import * as oauth from "oauth4webapi";
import {
Account, BaseClient, type AppInfo, type ConnectTokenResponse,
Account, BaseClient, type AppInfo, type ConnectTokenResponse, type RequestOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add missing trailing comma in import statement.

Add a trailing comma after RequestOptions to comply with the project's linting rules.

-  Account, BaseClient, type AppInfo, type ConnectTokenResponse, type RequestOptions
+  Account, BaseClient, type AppInfo, type ConnectTokenResponse, type RequestOptions,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Account, BaseClient, type AppInfo, type ConnectTokenResponse, type RequestOptions
Account, BaseClient, type AppInfo, type ConnectTokenResponse, type RequestOptions,
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 7-7:
Missing trailing comma

🪛 ESLint

[error] 7-8: Missing trailing comma.

(comma-dangle)

🪛 GitHub Actions: Pull Request Checks

[error] 7-7: Missing trailing comma

Comment on lines 110 to 121
/**
* Parameters for the retrieval of an account from the Connect API
*/
export type MakeProxyRequestOpts = {
/**
* Whether to retrieve the account's credentials or not.
*/
method: string;
headers?: Record<string, string>;
//headers: Record<string, string>;
body?: any
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix type definition issues.

The MakeProxyRequestOpts type definition has several issues:

  1. The JSDoc comment is incorrect (copied from GetAccountByIdOpts)
  2. Contains commented out code
  3. Uses any type which should be properly typed
 /**
- * Parameters for the retrieval of an account from the Connect API
+ * Options for making a proxy request through the Connect API
  */
 export type MakeProxyRequestOpts = {
   /**
-   * Whether to retrieve the account's credentials or not.
+   * The HTTP method to use for the proxy request
    */
   method: string;
+  /**
+   * Headers to include in the proxy request
+   */
   headers?: Record<string, string>;
-  //headers: Record<string, string>;
+  /**
+   * The request body
+   */
-  body?: any
+  body?: Record<string, unknown> | string | FormData | URLSearchParams | null;
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Parameters for the retrieval of an account from the Connect API
*/
export type MakeProxyRequestOpts = {
/**
* Whether to retrieve the account's credentials or not.
*/
method: string;
headers?: Record<string, string>;
//headers: Record<string, string>;
body?: any
};
/**
* Options for making a proxy request through the Connect API
*/
export type MakeProxyRequestOpts = {
/**
* The HTTP method to use for the proxy request
*/
method: string;
/**
* Headers to include in the proxy request
*/
headers?: Record<string, string>;
/**
* The request body
*/
body?: Record<string, unknown> | string | FormData | URLSearchParams | null;
};
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 120-120:
Unexpected any. Specify a different type

🪛 ESLint

[error] 120-120: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)

Comment on lines 396 to 419
public makeProxyRequest(url: string, query: any, opts: MakeProxyRequestOpts): Promise<any> {
const url64 = btoa(url).replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");

const headers = opts.headers || {};

const newHeaders = Object.keys(headers).reduce<{ [key: string]: string }>((acc, key) => {
acc[`x-pd-proxy-${key}`] = headers[key];
return acc;
}, {});

const newOpts: RequestOptions = {
method: opts.method,
headers: newHeaders,
params: query,
}

if (opts.body) {
newOpts.body = opts.body
}

return this.makeConnectRequest(`/proxy/${url64}`, newOpts);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve type safety and error handling in proxy request implementation.

The implementation should:

  1. Use proper types instead of any
  2. Add input validation
  3. Handle potential base64 encoding errors
  4. Fix indentation
-  public makeProxyRequest(url: string, query: any, opts: MakeProxyRequestOpts): Promise<any> {
+  public makeProxyRequest(
+    url: string,
+    query: Record<string, string | number | boolean | null>,
+    opts: MakeProxyRequestOpts
+  ): Promise<unknown> {
+    if (!url?.trim()) {
+      throw new Error("URL is required");
+    }

+    let url64: string;
+    try {
       url64 = btoa(url).replace(/\+/g, "-")
-    .replace(/\//g, "_")
-    .replace(/=+$/, "");
+        .replace(/\//g, "_")
+        .replace(/=+$/, "");
+    } catch (error) {
+      throw new Error(`Failed to encode URL: ${error.message}`);
+    }

     const headers = opts.headers || {};

     const newHeaders = Object.keys(headers).reduce<{ [key: string]: string }>((acc, key) => {
       acc[`x-pd-proxy-${key}`] = headers[key];
       return acc;
     }, {});

     const newOpts: RequestOptions = {
       method: opts.method,
       headers: newHeaders,
       params: query,
     }

     if (opts.body) {
       newOpts.body = opts.body
     }

     return this.makeConnectRequest(`/proxy/${url64}`, newOpts);
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public makeProxyRequest(url: string, query: any, opts: MakeProxyRequestOpts): Promise<any> {
const url64 = btoa(url).replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");
const headers = opts.headers || {};
const newHeaders = Object.keys(headers).reduce<{ [key: string]: string }>((acc, key) => {
acc[`x-pd-proxy-${key}`] = headers[key];
return acc;
}, {});
const newOpts: RequestOptions = {
method: opts.method,
headers: newHeaders,
params: query,
}
if (opts.body) {
newOpts.body = opts.body
}
return this.makeConnectRequest(`/proxy/${url64}`, newOpts);
}
public makeProxyRequest(
url: string,
query: Record<string, string | number | boolean | null>,
opts: MakeProxyRequestOpts
): Promise<unknown> {
if (!url?.trim()) {
throw new Error("URL is required");
}
let url64: string;
try {
url64 = btoa(url).replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");
} catch (error: any) {
throw new Error(`Failed to encode URL: ${error.message}`);
}
const headers = opts.headers || {};
const newHeaders = Object.keys(headers).reduce<{ [key: string]: string }>((acc, key) => {
acc[`x-pd-proxy-${key}`] = headers[key];
return acc;
}, {});
const newOpts: RequestOptions = {
method: opts.method,
headers: newHeaders,
params: query,
}
if (opts.body) {
newOpts.body = opts.body;
}
return this.makeConnectRequest(`/proxy/${url64}`, newOpts);
}
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 396-396:
Unexpected any. Specify a different type


[failure] 396-396:
Unexpected any. Specify a different type


[failure] 398-398:
Expected indentation of 6 spaces but found 4


[failure] 399-399:
Expected indentation of 6 spaces but found 4

🪛 ESLint

[error] 396-396: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)


[error] 396-396: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)


[error] 398-398: Expected indentation of 6 spaces but found 4.

(indent)


[error] 399-399: Expected indentation of 6 spaces but found 4.

(indent)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
packages/sdk/src/server/index.ts (3)

113-118: Strengthen type safety for required search parameters.

The searchParams type should explicitly define required fields for better type safety and developer experience.

-  searchParams: Record<string, string>;
+  searchParams: {
+    external_user_id: string;
+    account_id: string;
+    [key: string]: string;
+  };

123-136: Improve body type to support common request payload types.

The body type is too restrictive. Consider supporting other common payload types like JSON objects, FormData, etc.

-  body?: string;
+  body?: string | Record<string, unknown> | FormData | URLSearchParams;

420-424: Improve JSDoc documentation for makeProxyRequest method.

The current documentation lacks:

  1. Parameter descriptions
  2. Return type details
  3. Usage example
   /**
    * Makes a proxy request to the target app API with the specified query parameters and options.
+   *
+   * @param proxyOptions - Options containing required search parameters (external_user_id and account_id)
+   * @param targetRequest - Target request details including URL and request options
+   * @returns A promise resolving to the response from the downstream service
+   *
+   * @example
+   * ```typescript
+   * const response = await client.makeProxyRequest(
+   *   {
+   *     searchParams: {
+   *       external_user_id: "user123",
+   *       account_id: "acc456"
+   *     }
+   *   },
+   *   {
+   *     url: "https://api.example.com/data",
+   *     options: {
+   *       method: "GET",
+   *       headers: { "Accept": "application/json" }
+   *     }
+   *   }
+   * );
+   * ```
    */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1e87d88 and 9ab1113.

📒 Files selected for processing (1)
  • packages/sdk/src/server/index.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: pnpm publish
🔇 Additional comments (1)
packages/sdk/src/server/index.ts (1)

7-7: Add missing trailing comma in import statement.

Add a trailing comma after RequestOptions to comply with the project's linting rules.

-  Account, BaseClient, type AppInfo, type ConnectTokenResponse, type RequestOptions
+  Account, BaseClient, type AppInfo, type ConnectTokenResponse, type RequestOptions,

Comment on lines +425 to +448
public makeProxyRequest(proxyOptions: ProxyApiOpts, targetRequest: ProxyTargetApiRequest): Promise<string> {
const url64 = btoa(targetRequest.url).replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");

const headers = targetRequest.options.headers || {};

const newHeaders = Object.keys(headers).reduce<{ [key: string]: string }>((acc, key) => {
acc[`x-pd-proxy-${key}`] = headers[key];
return acc;
}, {});

const newOpts: RequestOptions = {
method: targetRequest.options.method,
headers: newHeaders,
params: proxyOptions.searchParams,
}

if (targetRequest.options.body) {
newOpts.body = targetRequest.options.body
}

return this.makeConnectRequest(`/proxy/${url64}`, newOpts);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve error handling and input validation in proxy request implementation.

The implementation needs:

  1. URL validation
  2. Error handling for base64 encoding
  3. Validation for required search parameters
  4. Proper indentation
   public makeProxyRequest(proxyOptions: ProxyApiOpts, targetRequest: ProxyTargetApiRequest): Promise<string> {
+    // Validate required search parameters
+    if (!proxyOptions.searchParams.external_user_id || !proxyOptions.searchParams.account_id) {
+      throw new Error("external_user_id and account_id are required in searchParams");
+    }
+
+    // Validate URL
+    if (!targetRequest.url?.trim()) {
+      throw new Error("URL is required");
+    }
+
+    let url64: string;
+    try {
       url64 = btoa(targetRequest.url).replace(/\+/g, "-")
-      .replace(/\//g, "_")
-      .replace(/=+$/, "");
+        .replace(/\//g, "_")
+        .replace(/=+$/, "");
+    } catch (error) {
+      throw new Error(`Failed to encode URL: ${error.message}`);
+    }

     const headers = targetRequest.options.headers || {};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public makeProxyRequest(proxyOptions: ProxyApiOpts, targetRequest: ProxyTargetApiRequest): Promise<string> {
const url64 = btoa(targetRequest.url).replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");
const headers = targetRequest.options.headers || {};
const newHeaders = Object.keys(headers).reduce<{ [key: string]: string }>((acc, key) => {
acc[`x-pd-proxy-${key}`] = headers[key];
return acc;
}, {});
const newOpts: RequestOptions = {
method: targetRequest.options.method,
headers: newHeaders,
params: proxyOptions.searchParams,
}
if (targetRequest.options.body) {
newOpts.body = targetRequest.options.body
}
return this.makeConnectRequest(`/proxy/${url64}`, newOpts);
}
public makeProxyRequest(proxyOptions: ProxyApiOpts, targetRequest: ProxyTargetApiRequest): Promise<string> {
// Validate required search parameters
if (!proxyOptions.searchParams.external_user_id || !proxyOptions.searchParams.account_id) {
throw new Error("external_user_id and account_id are required in searchParams");
}
// Validate URL
if (!targetRequest.url?.trim()) {
throw new Error("URL is required");
}
let url64: string;
try {
url64 = btoa(targetRequest.url).replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");
} catch (error) {
throw new Error(`Failed to encode URL: ${error.message}`);
}
const headers = targetRequest.options.headers || {};
const newHeaders = Object.keys(headers).reduce<{ [key: string]: string }>((acc, key) => {
acc[`x-pd-proxy-${key}`] = headers[key];
return acc;
}, {});
const newOpts: RequestOptions = {
method: targetRequest.options.method,
headers: newHeaders,
params: proxyOptions.searchParams,
}
if (targetRequest.options.body) {
newOpts.body = targetRequest.options.body;
}
return this.makeConnectRequest(`/proxy/${url64}`, newOpts);
}

/**
* http method for the request
*/
method: string;
Copy link
Contributor

@bzwrk bzwrk Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should list all supported methods as a type like get | post | put | delete

@@ -4,7 +4,7 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing version update and CHANGELOG

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9ab1113 and 76a8ff7.

📒 Files selected for processing (3)
  • packages/sdk/CHANGELOG.md (1 hunks)
  • packages/sdk/package.json (1 hunks)
  • packages/sdk/src/server/index.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/sdk/package.json
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: pnpm publish
🔇 Additional comments (2)
packages/sdk/src/server/index.ts (2)

7-7: Add missing trailing comma in import statement.


425-448: Improve error handling and input validation in proxy request implementation.

Comment on lines +113 to +118
export type ProxyApiOpts = {
/**
* Search parameters to be added to the proxy request. external_user_id and account_id are required.
*/
searchParams: Record<string, string>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enforce required fields in ProxyApiOpts type.

The type definition should enforce the required fields mentioned in the JSDoc comment.

 export type ProxyApiOpts  = {
   /**
    * Search parameters to be added to the proxy request.  external_user_id and account_id are required.
    */
-  searchParams: Record<string, string>;
+  searchParams: {
+    external_user_id: string;
+    account_id: string;
+    [key: string]: string;
+  };
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export type ProxyApiOpts = {
/**
* Search parameters to be added to the proxy request. external_user_id and account_id are required.
*/
searchParams: Record<string, string>;
};
export type ProxyApiOpts = {
/**
* Search parameters to be added to the proxy request. external_user_id and account_id are required.
*/
searchParams: {
external_user_id: string;
account_id: string;
[key: string]: string;
};
};

Comment on lines +5 to +10
## [1.3.3] - 2025-02-5

### Changed

- Add makeProxyRequest function to BaseClient

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance the changelog entry with more details.

The changelog entry should provide more context about the proxy request feature:

  1. Describe the purpose and benefits
  2. Document the new types added
  3. Include usage examples or migration guidance
 ## [1.3.3] - 2025-02-5
 
 ### Changed
 
-- Add makeProxyRequest function to BaseClient
+### Added
+
+- Added proxy request support to enable secure API calls through Pipedream's infrastructure
+  - New `makeProxyRequest` function in BaseClient for making proxy requests
+  - New types: `ProxyApiOpts`, `ProxyTargetApiOpts`, and `ProxyTargetApiRequest`
+
+Example usage:
+```typescript
+const response = await client.makeProxyRequest(
+  { searchParams: { external_user_id: "user123", account_id: "acc456" } },
+  {
+    url: "https://api.example.com/data",
+    options: {
+      method: "GET",
+      headers: { "Accept": "application/json" }
+    }
+  }
+);
+```

@jsendo jsendo requested a review from bzwrk February 5, 2025 21:30
@jsendo jsendo merged commit 4e6a586 into master Feb 5, 2025
12 checks passed
@jsendo jsendo deleted the je/connect-proxy-support branch February 5, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants