Skip to content
TypeScript

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

Julius Marmingebf1c1b09756a
diff --git a/apps/web/src/cloud/linkEnvironment.test.ts b/apps/web/src/cloud/linkEnvironment.test.ts
index 7ae5e7ed03a..3ae0dbd7428 100644
--- a/apps/web/src/cloud/linkEnvironment.test.ts
+++ b/apps/web/src/cloud/linkEnvironment.test.ts
@@ -26,10 +26,7 @@ import { remoteHttpClientLayer } from "@t3tools/client-runtime/rpc";
import { __resetDesktopPrimaryAuthForTests } from "../environments/primary/desktopAuth";
import {
- collectCloudLinkTargets,
linkPrimaryEnvironmentToCloud,
- listManagedCloudEnvironments,
- normalizeRelayBaseUrl,
readPrimaryCloudLinkState,
type CloudLinkTarget,
unlinkPrimaryEnvironmentFromCloud,
@@ -155,48 +152,6 @@ afterEach(() => {
});
describe("web cloud link environment client", () => {
- it("normalizes relay URLs and de-duplicates cloud link targets", () => {
- expect(normalizeRelayBaseUrl(" https://relay.example.test/// ")).toBe(
- "https://relay.example.test",
- );
- expect(normalizeRelayBaseUrl(" ")).toBeNull();
- expect(
- collectCloudLinkTargets({
- primary: TARGET,
- saved: [TARGET, { ...TARGET, environmentId: "environment-2" }],
- }).map((target) => target.environmentId),
- ).toEqual(["environment-1", "environment-2"]);
- });
-
- it.effect("lists relay-managed environments through the typed relay client", () =>
- Effect.gen(function* () {
- const fetchMock = vi.fn().mockResolvedValue(
- Response.json({
- environments: [
- {
- environmentId: "environment-1",
- label: "Desktop",
- endpoint: {
- httpBaseUrl: "https://desktop.example.test",
- wsBaseUrl: "wss://desktop.example.test",
- providerKind: "cloudflare_tunnel",
- },
- linkedAt: "2026-06-06T00:00:00.000Z",
- },
- ],
- }),
- );
- vi.stubGlobal("fetch", fetchMock);
-
- const environments = yield* withServices(
- listManagedCloudEnvironments({ clerkToken: "clerk-token" }),
- );
-
- expect(environments).toHaveLength(1);
- expect(fetchMock.mock.calls[0]?.[1]?.headers.authorization).toBe("Bearer clerk-token");
- }),
- );
-
it.effect("reads primary cloud link state from the explicit target", () =>
Effect.gen(function* () {
const fetchMock = vi.fn().mockResolvedValue(
diff --git a/apps/web/src/cloud/linkEnvironment.ts b/apps/web/src/cloud/linkEnvironment.ts
index 29353e480f5..f88e7863969 100644
--- a/apps/web/src/cloud/linkEnvironment.ts
+++ b/apps/web/src/cloud/linkEnvironment.ts
@@ -16,7 +16,6 @@ import {
WS_METHODS,
} from "@t3tools/contracts";
import {
- type RelayClientEnvironmentRecord,
type RelayEnvironmentLinkResponse,
type RelayManagedEndpointProviderKind,
} from "@t3tools/contracts/relay";
@@ -33,14 +32,6 @@ import {
requestRelayClientInstallConfirmation,
} from "./relayClientInstallDialog";
-export function normalizeRelayBaseUrl(value: string | null | undefined): string | null {
- const trimmed = value?.trim();
- if (!trimmed) {
- return null;
- }
- return trimmed.replace(/\/+$/g, "");
-}
-
function relayUrl(): string | null {
return resolveCloudPublicConfig().relayUrl;
}
@@ -194,53 +185,6 @@ export interface CloudLinkTarget {
export type CloudLinkState = EnvironmentCloudLinkStateResult;
-export function collectCloudLinkTargets(input: {
- readonly primary: CloudLinkTarget | null;
- readonly saved: ReadonlyArray<CloudLinkTarget>;
-}): ReadonlyArray<CloudLinkTarget> {
- const byId = new Map<string, CloudLinkTarget>();
- if (input.primary) {
- byId.set(input.primary.environmentId, input.primary);
- }
- for (const environment of input.saved) {
- if (!byId.has(environment.environmentId)) {
- byId.set(environment.environmentId, environment);
- }
- }
- return [...byId.values()];
-}
-
-export function listManagedCloudEnvironments(input: {
- readonly clerkToken: string;
-}): Effect.Effect<
- ReadonlyArray<RelayClientEnvironmentRecord>,
- CloudEnvironmentLinkError,
- ManagedRelay.ManagedRelayClient
-> {
- return Effect.gen(function* () {
- const configuredRelayUrl = relayUrl();
- if (!configuredRelayUrl) {
- return yield* new CloudEnvironmentLinkError({
- message: "T3CODE_RELAY_URL is not configured.",
- });
- }
- const relayClient = yield* ManagedRelay.ManagedRelayClient;
- return yield* relayClient
- .listEnvironments({
- clerkToken: input.clerkToken,
- })
- .pipe(
- Effect.mapError(
- (cause) =>
- new CloudEnvironmentLinkError({
- message: "Could not list relay-managed environments.",
- cause,
- }),
- ),
- );
- });
-}
-
export function readPrimaryCloudLinkState(input: {
readonly target: CloudLinkTarget;
}): Effect.Effect<CloudLinkState | null, CloudEnvironmentLinkError, HttpClient.HttpClient> {