Skip to content

Commit 1a5c70f

Browse files
committed
Remove unused async code
1 parent 2dbbd91 commit 1a5c70f

File tree

8 files changed

+25
-285
lines changed

8 files changed

+25
-285
lines changed

packages/connect-react/examples/nextjs/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sdk/src/browser/async.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/sdk/src/browser/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// operations, like connecting accounts via Pipedream Connect. See the server/
55
// directory for the server client.
66

7-
import { BrowserAsyncResponseManager } from "./async.js";
87
import {
98
AccountsRequestResponse,
109
BaseClient,
@@ -133,7 +132,6 @@ export function createFrontendClient(opts: CreateBrowserClientOpts = {}) {
133132
* A client for interacting with the Pipedream Connect API from the browser.
134133
*/
135134
export class BrowserClient extends BaseClient {
136-
protected override asyncResponseManager: BrowserAsyncResponseManager;
137135
private baseURL: string;
138136
private iframeURL: string;
139137
private iframe?: HTMLIFrameElement;
@@ -155,10 +153,6 @@ export class BrowserClient extends BaseClient {
155153
this.iframeURL = `${this.baseURL}/_static/connect.html`;
156154
this.tokenCallback = opts.tokenCallback;
157155
this.externalUserId = opts.externalUserId;
158-
this.asyncResponseManager = new BrowserAsyncResponseManager({
159-
apiHost: this.apiHost,
160-
getConnectToken: () => this.token(),
161-
});
162156
}
163157

164158
private async token() {

packages/sdk/src/server/async.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

packages/sdk/src/server/index.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
import {
99
Account, BaseClient, type AppInfo, type ConnectTokenResponse,
1010
} from "../shared";
11-
import { ServerAsyncResponseManager } from "./async";
1211
export * from "../shared";
1312

1413
/**
@@ -137,7 +136,6 @@ export function createBackendClient(opts: BackendClientOpts) {
137136
* A client for interacting with the Pipedream Connect API on the server-side.
138137
*/
139138
export class BackendClient extends BaseClient {
140-
protected override asyncResponseManager: ServerAsyncResponseManager;
141139
private oauthClient: ClientCredentials;
142140
private oauthToken?: AccessToken;
143141
protected projectId: string;
@@ -155,18 +153,6 @@ export class BackendClient extends BaseClient {
155153
this.projectId = opts.projectId;
156154

157155
this.oauthClient = this.newOauthClient(opts.credentials, this.baseApiUrl);
158-
this.asyncResponseManager = new ServerAsyncResponseManager({
159-
apiHost: this.apiHost,
160-
getOauthToken: async () => {
161-
await this.ensureValidOauthToken();
162-
return this.oauthToken as AccessToken;
163-
},
164-
getProjectId: () => {
165-
if (!this.projectId)
166-
throw "Attempted to connect to websocket without a valid Project id";
167-
return this.projectId;
168-
},
169-
});
170156
}
171157

172158
private ensureValidEnvironment(environment?: string) {

packages/sdk/src/shared/async.ts

Lines changed: 0 additions & 118 deletions
This file was deleted.

packages/sdk/src/shared/index.ts

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
// This code is meant to be shared between the browser and server.
2-
import type {
3-
AsyncResponse,
4-
AsyncErrorResponse,
5-
AsyncResponseManager,
6-
} from "./async.js";
72
import type {
83
ConfigurableProps,
94
ConfiguredProps,
@@ -580,7 +575,6 @@ export interface AsyncRequestOptions extends RequestOptions {
580575
export abstract class BaseClient {
581576
version = sdkVersion;
582577
protected apiHost: string;
583-
protected abstract asyncResponseManager: AsyncResponseManager;
584578
protected readonly baseApiUrl: string;
585579
protected environment: string;
586580
protected projectId?: string;
@@ -744,35 +738,6 @@ export abstract class BaseClient {
744738
return this.makeAuthorizedRequest(fullPath, opts);
745739
}
746740

747-
/**
748-
* Makes a request to the Connect API using Connect authorization.
749-
* This version makes an asynchronous request, fulfilled via Websocket.
750-
*
751-
* @template T - The expected response type.
752-
* @param path - The API endpoint path.
753-
* @param opts - The options for the request.
754-
* @returns A promise resolving to the API response.
755-
*/
756-
protected async makeConnectRequestAsync<T extends object>(
757-
path: string,
758-
opts: AsyncRequestOptions,
759-
): Promise<T> {
760-
await this.asyncResponseManager.ensureConnected();
761-
const data = await this.makeConnectRequest<
762-
AsyncResponse | AsyncErrorResponse | T
763-
>(path, opts);
764-
if ("errors" in data && data.errors.length) {
765-
throw new Error(data.errors[0]);
766-
}
767-
if ("async_handle" in data && data.async_handle) {
768-
const result = await this.asyncResponseManager.waitFor<T>(
769-
data.async_handle,
770-
);
771-
return result;
772-
}
773-
return data as T;
774-
}
775-
776741
/**
777742
* Retrieves the list of accounts associated with the project.
778743
*
@@ -956,14 +921,13 @@ export abstract class BaseClient {
956921
: componentId;
957922

958923
const body = {
959-
async_handle: this.asyncResponseManager.createAsyncHandle(),
960924
external_user_id: externalUserId,
961925
id,
962926
prop_name: opts.propName,
963927
configured_props: opts.configuredProps,
964928
dynamic_props_id: opts.dynamicPropsId,
965929
};
966-
return this.makeConnectRequestAsync<ConfigureComponentResponse>("/components/configure", {
930+
return this.makeConnectRequest<ConfigureComponentResponse>("/components/configure", {
967931
method: "POST",
968932
body,
969933
});
@@ -1013,14 +977,13 @@ export abstract class BaseClient {
1013977

1014978
// RpcActionReloadPropsInput
1015979
const body = {
1016-
async_handle: this.asyncResponseManager.createAsyncHandle(),
1017980
external_user_id: externalUserId,
1018981
id,
1019982
configured_props: opts.configuredProps,
1020983
dynamic_props_id: opts.dynamicPropsId,
1021984
};
1022985

1023-
return this.makeConnectRequestAsync<ConfiguredProps<ConfigurableProps>>(
986+
return this.makeConnectRequest<ConfiguredProps<ConfigurableProps>>(
1024987
"/components/props", {
1025988
// TODO trigger
1026989
method: "POST",
@@ -1072,13 +1035,12 @@ export abstract class BaseClient {
10721035
: actionId;
10731036

10741037
const body = {
1075-
async_handle: this.asyncResponseManager.createAsyncHandle(),
10761038
external_user_id: externalUserId,
10771039
id,
10781040
configured_props: opts.configuredProps,
10791041
dynamic_props_id: opts.dynamicPropsId,
10801042
};
1081-
return this.makeConnectRequestAsync<RunActionResponse>("/actions/run", {
1043+
return this.makeConnectRequest<RunActionResponse>("/actions/run", {
10821044
method: "POST",
10831045
body,
10841046
});
@@ -1126,14 +1088,13 @@ export abstract class BaseClient {
11261088
: triggerId;
11271089

11281090
const body = {
1129-
async_handle: this.asyncResponseManager.createAsyncHandle(),
11301091
external_user_id: externalUserId,
11311092
id,
11321093
configured_props: opts.configuredProps,
11331094
dynamic_props_id: opts.dynamicPropsId,
11341095
webhook_url: opts.webhookUrl,
11351096
};
1136-
return this.makeConnectRequestAsync<V1DeployedComponent>("/triggers/deploy", {
1097+
return this.makeConnectRequest<V1DeployedComponent>("/triggers/deploy", {
11371098
method: "POST",
11381099
body,
11391100
});

0 commit comments

Comments
 (0)