g1t/apps/sudo/app/lib/services.server.ts

34 lines1,283 bytesCodeBlame
1import { env } from "cloudflare:workers";
2
3import {
4 type StatusAdminApi,
5 accountsAdminClient,
6 billingAdminClient,
7 billingClient,
8 eventsClient,
9 identityAdminClient,
10} from "@g1t/contracts";
11
12/** Staff-only billing, on the billing service. */
13export const admin = billingAdminClient(env.BILLING);
14
15/** The public price book, read-only, from the same service. */
16export const priceBook = () => billingClient(env.BILLING).prices();
17
18/** Staff-only identity: every workspace, its owners and members. */
19export const identity = identityAdminClient(env.IDENTITY);
20
21/** Staff-only accounts: a person's email addresses and security log. */
22export const accountsAdmin = accountsAdminClient(env.IDENTITY);
23
24/** The workspace's plan, caps and pause, as billing gives them to every service. */
25export const entitlements = (workspace: string) => billingClient(env.BILLING).entitlements(workspace);
26
27/** The event log, read-only: sudo lists `abuse.flagged`. */
28export const events = eventsClient(env.EVENTS);
29
30/** The status page's incidents (apps/status's `StatusAdmin` entrypoint). */
31export const statusAdmin = env.STATUS as unknown as StatusAdminApi;
32
33/** STAFF_EMAILS, for suggesting staff in the incident roles. */
34export const staffEmails = (): string => env.STAFF_EMAILS ?? "";