From 96c605552ea4dba4cd6539af85ab79d6f523429c Mon Sep 17 00:00:00 2001 From: Michael Gartner Date: Fri, 13 Jun 2025 21:35:37 -0600 Subject: [PATCH 1/3] - --- apps/roam/src/utils/supabaseContext.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/roam/src/utils/supabaseContext.ts b/apps/roam/src/utils/supabaseContext.ts index f6e841d0e..f78b339db 100644 --- a/apps/roam/src/utils/supabaseContext.ts +++ b/apps/roam/src/utils/supabaseContext.ts @@ -55,7 +55,7 @@ const fetchOrCreatePlatformAccount = async ( personEmail: string | undefined }): Promise => { const response = await fetch( - `${base_url}/platform_account`, + `${base_url}/platform-account`, { method: "POST", headers: { From e614e7314acd564b7c49e94f1ebbf60c72c591e8 Mon Sep 17 00:00:00 2001 From: Michael Gartner Date: Fri, 13 Jun 2025 21:36:51 -0600 Subject: [PATCH 2/3] prettier formatting --- apps/roam/src/utils/supabaseContext.ts | 71 +++++++++++++------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/apps/roam/src/utils/supabaseContext.ts b/apps/roam/src/utils/supabaseContext.ts index f78b339db..a530f06c5 100644 --- a/apps/roam/src/utils/supabaseContext.ts +++ b/apps/roam/src/utils/supabaseContext.ts @@ -44,49 +44,44 @@ const fetchOrCreateSpaceId = async (): Promise => { return space.id; }; -const fetchOrCreatePlatformAccount = async ( - { - accountLocalId, - personName, - personEmail - }: { - accountLocalId: string, - personName: string, - personEmail: string | undefined - }): Promise => { - const response = await fetch( - `${base_url}/platform-account`, - { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - platform: "Roam", account_local_id: accountLocalId, personName - }), +const fetchOrCreatePlatformAccount = async ({ + accountLocalId, + personName, + personEmail, +}: { + accountLocalId: string; + personName: string; + personEmail: string | undefined; +}): Promise => { + const response = await fetch(`${base_url}/platform-account`, { + method: "POST", + headers: { + "Content-Type": "application/json", }, - ); + body: JSON.stringify({ + platform: "Roam", + account_local_id: accountLocalId, + personName, + }), + }); if (!response.ok) throw new Error( `Platform API failed: \${response.status} \${response.statusText}`, ); const account = await response.json(); if (personEmail !== undefined) { - const idResponse = await fetch( - `${base_url}/agent-identifier`, - { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - account_id: account.id, - identifier_type: "email", - value: personEmail, - trusted: false, // Roam tests email - }), + const idResponse = await fetch(`${base_url}/agent-identifier`, { + method: "POST", + headers: { + "Content-Type": "application/json", }, - ); + body: JSON.stringify({ + account_id: account.id, + identifier_type: "email", + value: personEmail, + trusted: false, // Roam tests email + }), + }); if (!idResponse.ok) { const error = await idResponse.text(); console.error(`Error setting the email for the account: ${error}`); @@ -105,7 +100,11 @@ export const getSupabaseContext = async (): Promise => { const accountLocalId = window.roamAlphaAPI.user.uid(); const personEmail = getCurrentUserEmail(); const personName = getCurrentUserDisplayName(); - const userId = await fetchOrCreatePlatformAccount({accountLocalId, personName, personEmail}); + const userId = await fetchOrCreatePlatformAccount({ + accountLocalId, + personName, + personEmail, + }); CONTEXT_CACHE = { platform: "Roam", spaceId, userId }; } catch (error) { console.error(error); From f857f60e62f0094bffdb6f3b179ec7160e43e1d2 Mon Sep 17 00:00:00 2001 From: Michael Gartner Date: Fri, 13 Jun 2025 22:15:46 -0600 Subject: [PATCH 3/3] name --- apps/roam/src/utils/supabaseContext.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/roam/src/utils/supabaseContext.ts b/apps/roam/src/utils/supabaseContext.ts index a530f06c5..d1b47d50e 100644 --- a/apps/roam/src/utils/supabaseContext.ts +++ b/apps/roam/src/utils/supabaseContext.ts @@ -61,7 +61,7 @@ const fetchOrCreatePlatformAccount = async ({ body: JSON.stringify({ platform: "Roam", account_local_id: accountLocalId, - personName, + name: personName, }), }); if (!response.ok)