Files
arcadia-admin/app/lib/arcadia/roles.ts
jules a907e25a7c Add Storage, Users, Secrets, Webhooks, Scheduled tasks, Audit log screens
Full management surfaces for the platform-admin tenant, mirroring the
existing Tenants pattern (DataTable + row actions + create/edit dialogs +
ConfirmDialog for destructive ops, all data-action tagged for the
command bus, useRegisterAdminContext publishing for the assistant).

- Storage (/storage): backends + credentials. Write-only secret fields,
  Validate/Activate/Deactivate/Set-default/Mark-degraded/Maintenance.
- Users (/users): tabs for Users, Invitations, Roles. Per-user View
  drawer with profile, role add/remove, API keys (one-time reveal on
  create), usage + quota.
- Secrets (/secrets): /api/v1/admin/secrets — create/rotate/rollback,
  versions dialog, enable/disable, generate-value helper.
- Webhooks (/webhooks): CRUD, pause/resume, regenerate-secret with
  one-time reveal, send test event, deliveries dialog.
- Scheduled tasks (/scheduled-tasks): cron CRUD, run-now trigger,
  enable/disable, expandable run history.
- Audit log (/activity): replaces the empty stub. Filter by severity,
  resource type, date range; click for full JSON detail.

All endpoints are hand-rolled HTTP because most aren't covered by the
generated OpenAPI typed paths yet — switch to arcadia.typed.* when the
backend wires them into OpenApiSpex.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 22:50:09 +10:00

56 lines
1.5 KiB
TypeScript

// Arcadia roles API helpers.
// Backed by /api/v1/roles (resources route, except :new and :edit).
import type { ArcadiaClient } from "@crema/arcadia-client"
export interface Role {
id: string
name: string
slug: string
description: string | null
permissions: string[]
is_system: boolean
metadata: Record<string, unknown>
tenant_id: string
inserted_at: string
updated_at: string
}
export interface RoleInput {
name: string
slug: string
description?: string | null
permissions?: string[]
metadata?: Record<string, unknown>
}
export async function listRoles(arcadia: ArcadiaClient): Promise<Role[]> {
const res = await arcadia.GET<{ data: Role[] }>("/api/v1/roles")
return res.data
}
export async function getRole(arcadia: ArcadiaClient, id: string): Promise<Role> {
const res = await arcadia.GET<{ data: Role }>(`/api/v1/roles/${id}`)
return res.data
}
export async function createRole(arcadia: ArcadiaClient, input: RoleInput): Promise<Role> {
const res = await arcadia.POST<{ data: Role }>("/api/v1/roles", { body: { role: input } })
return res.data
}
export async function updateRole(
arcadia: ArcadiaClient,
id: string,
input: Partial<RoleInput>,
): Promise<Role> {
const res = await arcadia.PATCH<{ data: Role }>(`/api/v1/roles/${id}`, {
body: { role: input },
})
return res.data
}
export async function deleteRole(arcadia: ArcadiaClient, id: string): Promise<void> {
await arcadia.DELETE(`/api/v1/roles/${id}`)
}