|
1 | 1 | // 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"; |
7 | 2 | import type { |
8 | 3 | ConfigurableProps, |
9 | 4 | ConfiguredProps, |
@@ -580,7 +575,6 @@ export interface AsyncRequestOptions extends RequestOptions { |
580 | 575 | export abstract class BaseClient { |
581 | 576 | version = sdkVersion; |
582 | 577 | protected apiHost: string; |
583 | | - protected abstract asyncResponseManager: AsyncResponseManager; |
584 | 578 | protected readonly baseApiUrl: string; |
585 | 579 | protected environment: string; |
586 | 580 | protected projectId?: string; |
@@ -744,35 +738,6 @@ export abstract class BaseClient { |
744 | 738 | return this.makeAuthorizedRequest(fullPath, opts); |
745 | 739 | } |
746 | 740 |
|
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 | | - |
776 | 741 | /** |
777 | 742 | * Retrieves the list of accounts associated with the project. |
778 | 743 | * |
@@ -956,14 +921,13 @@ export abstract class BaseClient { |
956 | 921 | : componentId; |
957 | 922 |
|
958 | 923 | const body = { |
959 | | - async_handle: this.asyncResponseManager.createAsyncHandle(), |
960 | 924 | external_user_id: externalUserId, |
961 | 925 | id, |
962 | 926 | prop_name: opts.propName, |
963 | 927 | configured_props: opts.configuredProps, |
964 | 928 | dynamic_props_id: opts.dynamicPropsId, |
965 | 929 | }; |
966 | | - return this.makeConnectRequestAsync<ConfigureComponentResponse>("/components/configure", { |
| 930 | + return this.makeConnectRequest<ConfigureComponentResponse>("/components/configure", { |
967 | 931 | method: "POST", |
968 | 932 | body, |
969 | 933 | }); |
@@ -1013,14 +977,13 @@ export abstract class BaseClient { |
1013 | 977 |
|
1014 | 978 | // RpcActionReloadPropsInput |
1015 | 979 | const body = { |
1016 | | - async_handle: this.asyncResponseManager.createAsyncHandle(), |
1017 | 980 | external_user_id: externalUserId, |
1018 | 981 | id, |
1019 | 982 | configured_props: opts.configuredProps, |
1020 | 983 | dynamic_props_id: opts.dynamicPropsId, |
1021 | 984 | }; |
1022 | 985 |
|
1023 | | - return this.makeConnectRequestAsync<ConfiguredProps<ConfigurableProps>>( |
| 986 | + return this.makeConnectRequest<ConfiguredProps<ConfigurableProps>>( |
1024 | 987 | "/components/props", { |
1025 | 988 | // TODO trigger |
1026 | 989 | method: "POST", |
@@ -1072,13 +1035,12 @@ export abstract class BaseClient { |
1072 | 1035 | : actionId; |
1073 | 1036 |
|
1074 | 1037 | const body = { |
1075 | | - async_handle: this.asyncResponseManager.createAsyncHandle(), |
1076 | 1038 | external_user_id: externalUserId, |
1077 | 1039 | id, |
1078 | 1040 | configured_props: opts.configuredProps, |
1079 | 1041 | dynamic_props_id: opts.dynamicPropsId, |
1080 | 1042 | }; |
1081 | | - return this.makeConnectRequestAsync<RunActionResponse>("/actions/run", { |
| 1043 | + return this.makeConnectRequest<RunActionResponse>("/actions/run", { |
1082 | 1044 | method: "POST", |
1083 | 1045 | body, |
1084 | 1046 | }); |
@@ -1126,14 +1088,13 @@ export abstract class BaseClient { |
1126 | 1088 | : triggerId; |
1127 | 1089 |
|
1128 | 1090 | const body = { |
1129 | | - async_handle: this.asyncResponseManager.createAsyncHandle(), |
1130 | 1091 | external_user_id: externalUserId, |
1131 | 1092 | id, |
1132 | 1093 | configured_props: opts.configuredProps, |
1133 | 1094 | dynamic_props_id: opts.dynamicPropsId, |
1134 | 1095 | webhook_url: opts.webhookUrl, |
1135 | 1096 | }; |
1136 | | - return this.makeConnectRequestAsync<V1DeployedComponent>("/triggers/deploy", { |
| 1097 | + return this.makeConnectRequest<V1DeployedComponent>("/triggers/deploy", { |
1137 | 1098 | method: "POST", |
1138 | 1099 | body, |
1139 | 1100 | }); |
|
0 commit comments