import { createPlatformClient } from '@bytelyst/platform-client'; import { API_CONFIG } from './config'; import { getAuthClient } from './auth'; import { getApiClient } from './client'; export type MobileNote = { id: string; title: string; body: string; workspaceName: string; }; const FALLBACK_NOTES: MobileNote[] = [ { id: 'note-1', title: 'Product launch checklist', body: 'Finalize launch narrative and mobile scope cut line.', workspaceName: 'Ops', }, { id: 'note-2', title: 'Agent review policy draft', body: 'Human approval required for destructive and external actions.', workspaceName: 'Platform', }, ]; function getClient() { const auth = getAuthClient(); return createPlatformClient({ baseUrl: API_CONFIG.productBaseUrl, productId: API_CONFIG.productId, getAccessToken: () => auth.getAccessToken(), refreshAccessToken: () => auth.refreshAccessToken(), timeoutMs: API_CONFIG.timeoutMs, }); } export async function listNotes(): Promise { try { return await getApiClient().fetch('/notes'); } catch { return FALLBACK_NOTES; } } export async function getNote(id: string): Promise { try { return await getClient().get(`/notes/${id}`); } catch { return FALLBACK_NOTES.find((note) => note.id === id) ?? null; } }