ui/admin_rpc_adapters.ts view source
AdminRpcAdapters The four admin RPC adapters assembled from a shared api.
Admin RPC adapter helpers for consumer UIs.
Bridges a typed throwing RPC client to the four narrow admin RPC interfaces the state classes consume — AdminAccountsRpc, AdminInvitesRpc, AuditLogRpc, AppSettingsRpc. Two calls at the admin shell layout wire everything.
Intentionally admin-only despite the backend-side
create_standard_rpc_actions rename (admin + role-grant-offer + account).
Account-surface methods flow through account_sessions_rpc_context
(wired at the self-service layout), and role-grant-offer methods that
surface in the admin UI (role_grant_offer_create, role_grant_revoke,
role_grant_offer_retract) live inside the AdminAccountsRpc interface —
they belong to the admin UX, not a separate wire pairing. The UI side
and backend factory names diverge by design.
// `api` is the typed throwing Proxy from `create_frontend_rpc_client`.
provide_admin_rpc_contexts(create_admin_rpc_adapters(api));The throwing Proxy spreads the JSON-RPC {code, message, data?} onto
the thrown Error so form components (e.g. ui/RoleGrantOfferForm.svelte)
can match on error.data?.reason via ERROR_ROLE_GRANT_OFFER_* constants —
optional chaining is required because JSON-RPC data is spec-level
optional. Consumers that need a custom unwrap strategy can construct
their own object satisfying AdminRpcApi and pass it directly.
No .svelte.ts suffix — this module holds no reactive state, only
method-name mappings.
5 declarations
ui/admin_rpc_adapters.ts view source
AdminRpcAdapters The four admin RPC adapters assembled from a shared api.
admin_accountsadmin_invitesaudit_logapp_settingsui/admin_rpc_adapters.ts view source
AdminRpcApi The wire-method surface this module needs from the typed throwing RPC
client. Every method returns the unwrapped value or throws an Error
carrying the JSON-RPC {code, message, data?} shape — i.e. the
ThrowingApi<...> view of the corresponding action specs.
Consumers pass the typed throwing Proxy returned by
create_frontend_rpc_client directly. Structural typing means any
superset (e.g. the consumer's full ThrowingApi<ActionsApi>) is
assignable as long as these methods are present at these signatures.
admin_account_list() => Promise<AdminAccountListOutput>admin_session_list() => Promise<AdminSessionListOutput>admin_session_revoke_all(
input: AdminSessionRevokeAllInput,
) => Promise<AdminSessionRevokeAllOutput>admin_token_revoke_all(input: AdminTokenRevokeAllInput) => Promise<AdminTokenRevokeAllOutput>audit_log_list(input: AuditLogListInput) => Promise<AuditLogListOutput>audit_log_role_grant_history(
input: AuditLogRoleGrantHistoryInput,
) => Promise<AuditLogRoleGrantHistoryOutput>invite_list() => Promise<InviteListOutput>invite_create(input: InviteCreateInput) => Promise<InviteCreateOutput>invite_delete(input: InviteDeleteInput) => Promise<InviteDeleteOutput>app_settings_get() => Promise<AppSettingsGetOutput>app_settings_update(input: AppSettingsUpdateInput) => Promise<AppSettingsUpdateOutput>role_grant_offer_create(
input: RoleGrantOfferCreateInput,
) => Promise<RoleGrantOfferCreateOutput>role_grant_offer_retract(input: RoleGrantOfferRetractInput) => Promise<RoleGrantOfferOkOutput>role_grant_revoke(input: RoleGrantRevokeInput) => Promise<RoleGrantRevokeOutput>ui/admin_rpc_adapters.ts view source
(api: AdminRpcApi): AdminRpcAdapters Build the four admin RPC adapters from a typed throwing RPC client.
Method-name mapping:
| Narrow RPC method | Action spec method |
| ----------------------------------- | ---------------------------- |
| admin_accounts.list_accounts | admin_account_list |
| admin_accounts.list_sessions | admin_session_list |
| admin_accounts.create_role_grant | role_grant_offer_create |
| admin_accounts.revoke_role_grant | role_grant_revoke |
| admin_accounts.retract_offer | role_grant_offer_retract |
| admin_accounts.session_revoke_all | admin_session_revoke_all |
| admin_accounts.token_revoke_all | admin_token_revoke_all |
| admin_invites.list | invite_list |
| admin_invites.create | invite_create |
| admin_invites.delete | invite_delete |
| audit_log.list | audit_log_list |
| audit_log.role_grant_history | audit_log_role_grant_history |
| app_settings.get | app_settings_get |
| app_settings.update | app_settings_update |
All four adapter factories call through the same api — consumers
pass the typed throwing Proxy from create_frontend_rpc_client once,
regardless of how many admin surfaces they mount.
apiAdminRpcAdapters ui/admin_rpc_adapters.ts view source
(adapters: AdminRpcAdapters, options?: ProvideAdminRpcContextsOptions | undefined): void Wire all four admin RPC contexts in a single call.
Call once at the admin shell layout (e.g. src/routes/admin/+layout.svelte)
with adapters built from create_admin_rpc_adapters. Every Admin*.svelte
component that reads a context below this point sees the adapters.
Each context accessor reads adapters.{domain} on every invocation, so
mutating an adapter field on the same object propagates. Replacing the
whole adapter set requires calling provide_admin_rpc_contexts again
during init — in practice this is one-shot at layout mount.
Pass options.format_scope to render role_grant/offer scope_id values as
human labels across AdminAccounts, AdminRoleGrantHistory,
RoleGrantOfferInbox, RoleGrantOfferForm, and RoleGrantOfferHistory.
Components that accept a format_scope prop honor the prop first; the
context is the fallback.
adaptersoptions?ProvideAdminRpcContextsOptions | undefinedvoid ui/admin_rpc_adapters.ts view source
ProvideAdminRpcContextsOptions Optional knobs alongside the adapters when wiring admin contexts.
format_scopeRender {scope_id, role} as a human label across role-grant-display
components. Omit (or return null) to fall back to the raw uuid.