authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 00:19:41-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 00:19:41-07:00
logbf1c1b09756a56a0600faf52561f0fb4ae94e355
tree2c218fedcbc60d5bd3e2467166e3e9e5cdc400ab
parentc7e93f520bbd1ba4b795a5fb1aad14778aa1d047
signature Signed by PGP key B5690EEEBB952194

refactor(web): remove obsolete cloud listing helpers (#9995)


2 files changed, 0 insertions(+), 101 deletions(-)

apps/web/src/cloud/linkEnvironment.test.ts-45
...@@ -26,10 +26,7 @@ import { remoteHttpClientLayer } from "@t3tools/client-runtime/rpc";...@@ -26,10 +26,7 @@ import { remoteHttpClientLayer } from "@t3tools/client-runtime/rpc";
26import { __resetDesktopPrimaryAuthForTests } from "../environments/primary/desktopAuth";26import { __resetDesktopPrimaryAuthForTests } from "../environments/primary/desktopAuth";
2727
28import {28import {
29 collectCloudLinkTargets,
30 linkPrimaryEnvironmentToCloud,29 linkPrimaryEnvironmentToCloud,
31 listManagedCloudEnvironments,
32 normalizeRelayBaseUrl,
33 readPrimaryCloudLinkState,30 readPrimaryCloudLinkState,
34 type CloudLinkTarget,31 type CloudLinkTarget,
35 unlinkPrimaryEnvironmentFromCloud,32 unlinkPrimaryEnvironmentFromCloud,
...@@ -155,48 +152,6 @@ afterEach(() => {...@@ -155,48 +152,6 @@ afterEach(() => {
155});152});
156153
157describe("web cloud link environment client", () => {154describe("web cloud link environment client", () => {
158 it("normalizes relay URLs and de-duplicates cloud link targets", () => {
159 expect(normalizeRelayBaseUrl(" https://relay.example.test/// ")).toBe(
160 "https://relay.example.test",
161 );
162 expect(normalizeRelayBaseUrl(" ")).toBeNull();
163 expect(
164 collectCloudLinkTargets({
165 primary: TARGET,
166 saved: [TARGET, { ...TARGET, environmentId: "environment-2" }],
167 }).map((target) => target.environmentId),
168 ).toEqual(["environment-1", "environment-2"]);
169 });
170
171 it.effect("lists relay-managed environments through the typed relay client", () =>
172 Effect.gen(function* () {
173 const fetchMock = vi.fn().mockResolvedValue(
174 Response.json({
175 environments: [
176 {
177 environmentId: "environment-1",
178 label: "Desktop",
179 endpoint: {
180 httpBaseUrl: "https://desktop.example.test",
181 wsBaseUrl: "wss://desktop.example.test",
182 providerKind: "cloudflare_tunnel",
183 },
184 linkedAt: "2026-06-06T00:00:00.000Z",
185 },
186 ],
187 }),
188 );
189 vi.stubGlobal("fetch", fetchMock);
190
191 const environments = yield* withServices(
192 listManagedCloudEnvironments({ clerkToken: "clerk-token" }),
193 );
194
195 expect(environments).toHaveLength(1);
196 expect(fetchMock.mock.calls[0]?.[1]?.headers.authorization).toBe("Bearer clerk-token");
197 }),
198 );
199
200 it.effect("reads primary cloud link state from the explicit target", () =>155 it.effect("reads primary cloud link state from the explicit target", () =>
201 Effect.gen(function* () {156 Effect.gen(function* () {
202 const fetchMock = vi.fn().mockResolvedValue(157 const fetchMock = vi.fn().mockResolvedValue(
apps/web/src/cloud/linkEnvironment.ts-56
...@@ -16,7 +16,6 @@ import {...@@ -16,7 +16,6 @@ import {
16 WS_METHODS,16 WS_METHODS,
17} from "@t3tools/contracts";17} from "@t3tools/contracts";
18import {18import {
19 type RelayClientEnvironmentRecord,
20 type RelayEnvironmentLinkResponse,19 type RelayEnvironmentLinkResponse,
21 type RelayManagedEndpointProviderKind,20 type RelayManagedEndpointProviderKind,
22} from "@t3tools/contracts/relay";21} from "@t3tools/contracts/relay";
...@@ -33,14 +32,6 @@ import {...@@ -33,14 +32,6 @@ import {
33 requestRelayClientInstallConfirmation,32 requestRelayClientInstallConfirmation,
34} from "./relayClientInstallDialog";33} from "./relayClientInstallDialog";
3534
36export function normalizeRelayBaseUrl(value: string | null | undefined): string | null {
37 const trimmed = value?.trim();
38 if (!trimmed) {
39 return null;
40 }
41 return trimmed.replace(/\/+$/g, "");
42}
43
44function relayUrl(): string | null {35function relayUrl(): string | null {
45 return resolveCloudPublicConfig().relayUrl;36 return resolveCloudPublicConfig().relayUrl;
46}37}
...@@ -194,53 +185,6 @@ export interface CloudLinkTarget {...@@ -194,53 +185,6 @@ export interface CloudLinkTarget {
194185
195export type CloudLinkState = EnvironmentCloudLinkStateResult;186export type CloudLinkState = EnvironmentCloudLinkStateResult;
196187
197export function collectCloudLinkTargets(input: {
198 readonly primary: CloudLinkTarget | null;
199 readonly saved: ReadonlyArray<CloudLinkTarget>;
200}): ReadonlyArray<CloudLinkTarget> {
201 const byId = new Map<string, CloudLinkTarget>();
202 if (input.primary) {
203 byId.set(input.primary.environmentId, input.primary);
204 }
205 for (const environment of input.saved) {
206 if (!byId.has(environment.environmentId)) {
207 byId.set(environment.environmentId, environment);
208 }
209 }
210 return [...byId.values()];
211}
212
213export function listManagedCloudEnvironments(input: {
214 readonly clerkToken: string;
215}): Effect.Effect<
216 ReadonlyArray<RelayClientEnvironmentRecord>,
217 CloudEnvironmentLinkError,
218 ManagedRelay.ManagedRelayClient
219> {
220 return Effect.gen(function* () {
221 const configuredRelayUrl = relayUrl();
222 if (!configuredRelayUrl) {
223 return yield* new CloudEnvironmentLinkError({
224 message: "T3CODE_RELAY_URL is not configured.",
225 });
226 }
227 const relayClient = yield* ManagedRelay.ManagedRelayClient;
228 return yield* relayClient
229 .listEnvironments({
230 clerkToken: input.clerkToken,
231 })
232 .pipe(
233 Effect.mapError(
234 (cause) =>
235 new CloudEnvironmentLinkError({
236 message: "Could not list relay-managed environments.",
237 cause,
238 }),
239 ),
240 );
241 });
242}
243
244export function readPrimaryCloudLinkState(input: {188export function readPrimaryCloudLinkState(input: {
245 readonly target: CloudLinkTarget;189 readonly target: CloudLinkTarget;
246}): Effect.Effect<CloudLinkState | null, CloudEnvironmentLinkError, HttpClient.HttpClient> {190}): Effect.Effect<CloudLinkState | null, CloudEnvironmentLinkError, HttpClient.HttpClient> {