(target: TargetShape, identity: Identity)
| 159 | /** The caller's own account id — the `externalId` the admin plane reports and |
| 160 | * the users page renders in mono. */ |
| 161 | export const accountIdOf = (target: TargetShape, identity: Identity): Effect.Effect<string> => |
| 162 | Effect.promise(async () => { |
| 163 | const response = await fetch(new URL("/api/account/me", target.baseUrl), { |
| 164 | headers: { cookie: cookieOf(identity) }, |
| 165 | }); |
| 166 | if (!response.ok) throw new Error(`/api/account/me failed (${response.status})`); |
| 167 | const body = (await response.json()) as { user: { id: string } }; |
| 168 | return body.user.id; |
| 169 | }); |
| 170 | |
| 171 | /** The org this identity's session is currently bound to: id and URL slug. */ |
| 172 | export const activeOrg = ( |
no test coverage detected