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