Skip to content

Commit 803db16

Browse files
refactor(web): remove obsolete cloud listing helpers
1 parent d2c3e2e commit 803db16

2 files changed

Lines changed: 0 additions & 101 deletions

File tree

‎apps/web/src/cloud/linkEnvironment.test.ts‎

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ import { remoteHttpClientLayer } from "@t3tools/client-runtime/rpc";
2626
import { __resetDesktopPrimaryAuthForTests } from "../environments/primary/desktopAuth";
2727

2828
import {
29-
collectCloudLinkTargets,
3029
linkPrimaryEnvironmentToCloud,
31-
listManagedCloudEnvironments,
32-
normalizeRelayBaseUrl,
3330
readPrimaryCloudLinkState,
3431
type CloudLinkTarget,
3532
unlinkPrimaryEnvironmentFromCloud,
@@ -155,48 +152,6 @@ afterEach(() => {
155152
});
156153

157154
describe("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-
200155
it.effect("reads primary cloud link state from the explicit target", () =>
201156
Effect.gen(function* () {
202157
const fetchMock = vi.fn().mockResolvedValue(

‎apps/web/src/cloud/linkEnvironment.ts‎

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
WS_METHODS,
1717
} from "@t3tools/contracts";
1818
import {
19-
type RelayClientEnvironmentRecord,
2019
type RelayEnvironmentLinkResponse,
2120
type RelayManagedEndpointProviderKind,
2221
} from "@t3tools/contracts/relay";
@@ -33,14 +32,6 @@ import {
3332
requestRelayClientInstallConfirmation,
3433
} from "./relayClientInstallDialog";
3534

36-
export 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-
4435
function relayUrl(): string | null {
4536
return resolveCloudPublicConfig().relayUrl;
4637
}
@@ -194,53 +185,6 @@ export interface CloudLinkTarget {
194185

195186
export type CloudLinkState = EnvironmentCloudLinkStateResult;
196187

197-
export 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-
213-
export 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-
244188
export function readPrimaryCloudLinkState(input: {
245189
readonly target: CloudLinkTarget;
246190
}): Effect.Effect<CloudLinkState | null, CloudEnvironmentLinkError, HttpClient.HttpClient> {

0 commit comments

Comments
 (0)