Skip to content
Draft
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
10 changes: 3 additions & 7 deletions src/wrapper/Pipedream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ProjectEnvironment } from "../api/index.js";
import { Workflows } from "../api/resources/workflows/client/Client.js";
import { PipedreamClient } from "../Client.js";
import { PipedreamEnvironment } from "../environments.js";
import { getBaseUrl } from "./utils/getBaseUrl.js";

export type PipedreamClientOpts = {
/**
Expand All @@ -17,9 +16,9 @@ export type PipedreamClientOpts = {
clientSecret?: string;

/**
* The Pipedream environment to connect to.
* Optional base URL for API requests. Defaults to https://api.pipedream.com
*/
environment?: PipedreamEnvironment;
baseUrl?: string;

/**
* The project environment configuration.
Expand Down Expand Up @@ -50,7 +49,6 @@ export class Pipedream extends PipedreamClient {

public constructor(opts: PipedreamClientOpts = {}) {
const {
environment = PipedreamEnvironment.Prod,
projectEnvironment = process.env.PIPEDREAM_PROJECT_ENVIRONMENT ?? ProjectEnvironment.Production,
projectId = process.env.PIPEDREAM_PROJECT_ID,
workflowDomain,
Expand All @@ -68,10 +66,8 @@ export class Pipedream extends PipedreamClient {
);
}

const baseUrl = getBaseUrl(environment);
const clientOpts: PipedreamClient.Options = {
baseUrl,
environment,
baseUrl: opts.baseUrl ?? PipedreamEnvironment.Prod,
projectEnvironment,
projectId: projectId ?? "",
};
Expand Down
121 changes: 121 additions & 0 deletions src/wrapper/Proxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import * as core from "../core/index.js";
import * as Pipedream from "../api/index.js";
import { Proxy as GeneratedProxy } from "../api/resources/proxy/client/Client.js";

export interface ProxyRequestOptions extends GeneratedProxy.RequestOptions {
includeHeaders?: boolean;
}

export class Proxy {
constructor(private readonly _proxy: GeneratedProxy) {}

public get(
url64: string,
request: Pipedream.ProxyGetRequest,
requestOptions: ProxyRequestOptions & { includeHeaders: true },
): Promise<{ data: core.BinaryResponse; headers: Headers }>;
public get(
url64: string,
request: Pipedream.ProxyGetRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse>;
public async get(
url64: string,
request: Pipedream.ProxyGetRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse | { data: core.BinaryResponse; headers: Headers }> {
if (requestOptions?.includeHeaders) {
const { data, rawResponse } = await this._proxy.get(url64, request, requestOptions).withRawResponse();

Check failure on line 28 in src/wrapper/Proxy.ts

View workflow job for this annotation

GitHub Actions / compile

Expected 1-2 arguments, but got 3.
return { data, headers: rawResponse.headers };

Check failure on line 29 in src/wrapper/Proxy.ts

View workflow job for this annotation

GitHub Actions / compile

Type 'unknown' is not assignable to type 'BinaryResponse'.
}
return this._proxy.get(url64, request, requestOptions);

Check failure on line 31 in src/wrapper/Proxy.ts

View workflow job for this annotation

GitHub Actions / compile

Expected 1-2 arguments, but got 3.

Check failure on line 31 in src/wrapper/Proxy.ts

View workflow job for this annotation

GitHub Actions / compile

Type 'unknown' is not assignable to type 'BinaryResponse | { data: BinaryResponse; headers: Headers; }'.
}

public post(
url64: string,
request: Pipedream.ProxyPostRequest,
requestOptions: ProxyRequestOptions & { includeHeaders: true },
): Promise<{ data: core.BinaryResponse; headers: Headers }>;
public post(
url64: string,
request: Pipedream.ProxyPostRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse>;
public async post(
url64: string,
request: Pipedream.ProxyPostRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse | { data: core.BinaryResponse; headers: Headers }> {
if (requestOptions?.includeHeaders) {
const { data, rawResponse } = await this._proxy.post(url64, request, requestOptions).withRawResponse();

Check failure on line 50 in src/wrapper/Proxy.ts

View workflow job for this annotation

GitHub Actions / compile

Expected 1-2 arguments, but got 3.
return { data, headers: rawResponse.headers };

Check failure on line 51 in src/wrapper/Proxy.ts

View workflow job for this annotation

GitHub Actions / compile

Type 'unknown' is not assignable to type 'BinaryResponse'.
}
return this._proxy.post(url64, request, requestOptions);

Check failure on line 53 in src/wrapper/Proxy.ts

View workflow job for this annotation

GitHub Actions / compile

Expected 1-2 arguments, but got 3.

Check failure on line 53 in src/wrapper/Proxy.ts

View workflow job for this annotation

GitHub Actions / compile

Type 'unknown' is not assignable to type 'BinaryResponse | { data: BinaryResponse; headers: Headers; }'.
}

public put(
url64: string,
request: Pipedream.ProxyPutRequest,
requestOptions: ProxyRequestOptions & { includeHeaders: true },
): Promise<{ data: core.BinaryResponse; headers: Headers }>;
public put(
url64: string,
request: Pipedream.ProxyPutRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse>;
public async put(
url64: string,
request: Pipedream.ProxyPutRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse | { data: core.BinaryResponse; headers: Headers }> {
if (requestOptions?.includeHeaders) {
const { data, rawResponse } = await this._proxy.put(url64, request, requestOptions).withRawResponse();
return { data, headers: rawResponse.headers };
}
return this._proxy.put(url64, request, requestOptions);
}

public delete(
url64: string,
request: Pipedream.ProxyDeleteRequest,
requestOptions: ProxyRequestOptions & { includeHeaders: true },
): Promise<{ data: core.BinaryResponse; headers: Headers }>;
public delete(
url64: string,
request: Pipedream.ProxyDeleteRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse>;
public async delete(
url64: string,
request: Pipedream.ProxyDeleteRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse | { data: core.BinaryResponse; headers: Headers }> {
if (requestOptions?.includeHeaders) {
const { data, rawResponse } = await this._proxy.delete(url64, request, requestOptions).withRawResponse();
return { data, headers: rawResponse.headers };
}
return this._proxy.delete(url64, request, requestOptions);
}

public patch(
url64: string,
request: Pipedream.ProxyPatchRequest,
requestOptions: ProxyRequestOptions & { includeHeaders: true },
): Promise<{ data: core.BinaryResponse; headers: Headers }>;
public patch(
url64: string,
request: Pipedream.ProxyPatchRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse>;
public async patch(
url64: string,
request: Pipedream.ProxyPatchRequest,
requestOptions?: ProxyRequestOptions,
): Promise<core.BinaryResponse | { data: core.BinaryResponse; headers: Headers }> {
if (requestOptions?.includeHeaders) {
const { data, rawResponse } = await this._proxy.patch(url64, request, requestOptions).withRawResponse();
return { data, headers: rawResponse.headers };
}
return this._proxy.patch(url64, request, requestOptions);
}
}
9 changes: 0 additions & 9 deletions src/wrapper/utils/getBaseUrl.browser.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/wrapper/utils/getBaseUrl.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/wrapper/utils/index.ts

This file was deleted.

Loading