MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / orgOf

Function orgOf

e2e/cloud/v2-moved-notice.test.ts:48–62  ·  view source on GitHub ↗
(
  target: TargetShape,
  identity: Identity,
)

Source from the content-addressed store, hash-verified

46
47/** The identity's active org, with the name the dashboard shows. */
48const orgOf = (
49 target: TargetShape,
50 identity: Identity,
51): Effect.Effect<{ readonly id: string; readonly slug: string; readonly name: string }> =>
52 Effect.promise(async () => {
53 const response = await fetch(new URL("/api/auth/me", target.baseUrl), {
54 headers: { cookie: cookieOf(identity) },
55 });
56 if (!response.ok) throw new Error(`/api/auth/me failed (${response.status})`);
57 const body = (await response.json()) as {
58 organization: { id: string; slug: string; name: string } | null;
59 };
60 if (!body.organization) throw new Error("identity has no active organization");
61 return body.organization;
62 });
63
64/** Write WorkOS organization metadata the way v2 does: Update Organization. */
65const setOrgMetadata = (

Callers 1

Calls 3

cookieOfFunction · 0.90
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected