From ffa60fcfb7e089b9fc64226fe9fdc29fdbf8a730 Mon Sep 17 00:00:00 2001 From: Saravana Achu Mac Date: Sat, 4 Apr 2026 18:03:49 -0700 Subject: [PATCH] refactor: remove live web supabase dependency --- .env.example | 3 -- docs/OPERATIONS.md | 2 +- docs/ROADMAP.md | 2 +- pnpm-lock.yaml | 3 -- shared/supabase-config.ts | 54 ------------------------------ web/README.md | 8 ++--- web/package.json | 1 - web/src/lib/supabaseClient.test.ts | 9 ++--- web/src/lib/supabaseClient.ts | 21 +++--------- 9 files changed, 14 insertions(+), 89 deletions(-) delete mode 100644 shared/supabase-config.ts diff --git a/.env.example b/.env.example index 4594fe1..b97cdf9 100644 --- a/.env.example +++ b/.env.example @@ -25,9 +25,6 @@ NEXT_PUBLIC_TRADING_API_URL=http://localhost:4018/api VITE_PRODUCT_ID=invttrdg VITE_PLATFORM_URL=http://localhost:4003/api VITE_TRADING_API_URL=http://localhost:4018/api -# Legacy data-plane fallback only. Auth no longer uses Supabase. -VITE_SUPABASE_URL= -VITE_SUPABASE_ANON_KEY= # Mobile public envs EXPO_PUBLIC_PRODUCT_ID=invttrdg diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.md index 3cbbcb0..94131c2 100644 --- a/docs/OPERATIONS.md +++ b/docs/OPERATIONS.md @@ -225,7 +225,7 @@ Manual mobile release smoke is still required before broad rollout: ## Known Remaining Gaps - Cosmos-only execution persistence is now in place for the main backend runtime paths, but dormant legacy code and one-off reference scripts still need cleanup -- web still carries some compatibility layers around auth/profile bootstrap +- web now uses platform-session handling end to end; the remaining auth cleanup is removing dormant compatibility stubs and aligning profile bootstrap contracts fully with backend-owned product APIs - root `pnpm verify` is green again after aligning the web Vitest harness with platform-session storage and current API contracts - mobile does not yet include push notification infrastructure - feature-flag ownership and correlation-ID propagation are not fully standardized yet diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 4c1aa1a..3ab86ae 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -510,7 +510,7 @@ Validate that the new monorepo is safer and more coherent than the legacy setup ### Risk: auth model remains split between compatibility layers and the target platform-service session contract - [x] Mitigation: preserve domain behavior while removing migration-only storage fallbacks -- [ ] Mitigation: define one authoritative session model early +- [x] Mitigation: define the platform-service session model as the authoritative web/mobile auth contract - [ ] Mitigation: document transitional behavior explicitly ### Risk: repo-level verification stays red due to test-harness drift instead of product regressions diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0624c7f..09e2722 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -242,9 +242,6 @@ importers: '@bytelyst/telemetry-client': specifier: link:../../../learning_ai/learning_ai_common_plat/packages/telemetry-client version: link:../../../learning_ai/learning_ai_common_plat/packages/telemetry-client - '@supabase/supabase-js': - specifier: ^2.90.1 - version: 2.101.1 lucide-react: specifier: ^0.562.0 version: 0.562.0(react@19.2.4) diff --git a/shared/supabase-config.ts b/shared/supabase-config.ts deleted file mode 100644 index 555190f..0000000 --- a/shared/supabase-config.ts +++ /dev/null @@ -1,54 +0,0 @@ -export interface SupabaseRuntimeConfig { - url: string; - anonKey: string; - isConfigured: boolean; -} - -const fallbackSupabaseUrl = 'https://placeholder.bytilyst.local'; -const fallbackSupabaseAnonKey = 'placeholder-anon-key'; - -function pickConfiguredValue(...values: Array): string | undefined { - return values.find((value) => typeof value === 'string' && value.trim().length > 0)?.trim(); -} - -export function getWebSupabaseConfig(): SupabaseRuntimeConfig { - const url = pickConfiguredValue( - process.env.NEXT_PUBLIC_SUPABASE_URL, - process.env.VITE_SUPABASE_URL, - process.env.VITE_PLATFORM_SUPABASE_URL, - process.env.VITE_PUBLIC_SUPABASE_URL - ); - - const anonKey = pickConfiguredValue( - process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY, - process.env.VITE_SUPABASE_ANON_KEY, - process.env.VITE_PLATFORM_SUPABASE_ANON_KEY, - process.env.VITE_PUBLIC_SUPABASE_ANON_KEY - ); - - return { - url: url || fallbackSupabaseUrl, - anonKey: anonKey || fallbackSupabaseAnonKey, - isConfigured: Boolean(url && anonKey), - }; -} - -export function getMobileSupabaseConfig(): SupabaseRuntimeConfig { - const url = pickConfiguredValue( - process.env.EXPO_PUBLIC_SUPABASE_URL, - process.env.EXPO_PUBLIC_PLATFORM_SUPABASE_URL, - process.env.EXPO_PUBLIC_PUBLIC_SUPABASE_URL - ); - - const anonKey = pickConfiguredValue( - process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY, - process.env.EXPO_PUBLIC_PLATFORM_SUPABASE_ANON_KEY, - process.env.EXPO_PUBLIC_PUBLIC_SUPABASE_ANON_KEY - ); - - return { - url: url || fallbackSupabaseUrl, - anonKey: anonKey || fallbackSupabaseAnonKey, - isConfigured: Boolean(url && anonKey), - }; -} diff --git a/web/README.md b/web/README.md index e072104..3241d4e 100644 --- a/web/README.md +++ b/web/README.md @@ -98,7 +98,7 @@ src/ ├── hooks/ │ └── useWebSocket.ts # Socket.IO hook for real-time data ├── lib/ -│ ├── supabaseClient.ts # Supabase client initialization +│ ├── authSession.ts # Platform-service session bootstrap + token refresh │ └── const.ts # Table names + constants ├── App.tsx # Main app layout + tab navigation ├── main.tsx # React entry point @@ -109,9 +109,9 @@ src/ | Variable | Required | Description | |---|---|---| -| `VITE_SUPABASE_URL` | Yes | Supabase project URL | -| `VITE_SUPABASE_ANON_KEY` | Yes | Supabase anonymous key | -| `VITE_API_URL` | Yes | Bot service API URL (default: `http://localhost:5000`) | +| `VITE_PLATFORM_URL` | Yes | Platform-service API base URL | +| `VITE_TRADING_API_URL` | Yes | Trading backend API base URL | +| `VITE_PRODUCT_ID` | No | Product identifier override | | `VITE_SOCKET_PATH` | No | Custom Socket.IO path | ## Dashboard Tabs diff --git a/web/package.json b/web/package.json index a4ef896..61b3bf8 100644 --- a/web/package.json +++ b/web/package.json @@ -21,7 +21,6 @@ "@bytelyst/kill-switch-client": "link:../../../learning_ai/learning_ai_common_plat/packages/kill-switch-client", "@bytelyst/react-auth": "link:../../../learning_ai/learning_ai_common_plat/packages/react-auth", "@bytelyst/telemetry-client": "link:../../../learning_ai/learning_ai_common_plat/packages/telemetry-client", - "@supabase/supabase-js": "^2.90.1", "lucide-react": "^0.562.0", "react": "^19.2.0", "react-dom": "^19.2.0", diff --git a/web/src/lib/supabaseClient.test.ts b/web/src/lib/supabaseClient.test.ts index 7bfcd14..43ccccf 100644 --- a/web/src/lib/supabaseClient.test.ts +++ b/web/src/lib/supabaseClient.test.ts @@ -1,12 +1,9 @@ import { describe, expect, it, vi } from 'vitest'; describe('supabaseClient', () => { - it('creates a client when environment variables are present', async () => { + it('throws when legacy supabase access is used', async () => { vi.resetModules(); - vi.stubEnv('VITE_SUPABASE_URL', 'https://example.supabase.co'); - vi.stubEnv('VITE_SUPABASE_ANON_KEY', 'anon-key'); - const mod = await import('./supabaseClient'); - expect(mod.supabase).toBeTruthy(); + expect(() => mod.supabase.from('orders')).toThrowError(/no longer supported/i); }); -}); +}); diff --git a/web/src/lib/supabaseClient.ts b/web/src/lib/supabaseClient.ts index c044ad9..ae3fc33 100644 --- a/web/src/lib/supabaseClient.ts +++ b/web/src/lib/supabaseClient.ts @@ -1,21 +1,10 @@ -import { createClient } from '@supabase/supabase-js'; -import { getWebSupabaseConfig } from '../../../shared/supabase-config.js'; - -const supabaseConfig = getWebSupabaseConfig(); - -if (!supabaseConfig.isConfigured) { - console.warn('Missing Supabase environment variables for legacy data client fallback'); -} - -const dataClient = supabaseConfig.isConfigured - ? createClient(supabaseConfig.url, supabaseConfig.anonKey) - : null; +const unsupportedMessage = 'Legacy Supabase data access is no longer supported in learning_ai_invt_trdg web runtime.'; export const supabase = { from: (...args: any[]) => { - if (!dataClient) { - throw new Error('Legacy Supabase data client is not configured'); - } - return (dataClient.from as any)(...args); + void args; + throw new Error(unsupportedMessage); }, }; + +export const SUPABASE_UNSUPPORTED_MESSAGE = unsupportedMessage;