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