Add Buckets, Monitoring, Memberships, Networking, SSO, Announcements, Status page
Full set of admin surfaces on top of /platform/* and /admin/* endpoints,
plus a migration of /assistant onto @crema/llm-providers-ui.
Buckets (/buckets):
S3-level CRUD over /platform/buckets — list, create, delete (with the
6-digit confirmation flow the backend enforces), per-bucket configure
for versioning / CORS rules / policy JSON, plus an object browser
with FileGrid/FileList from @crema/file-ui and presigned-URL reveal.
Storage-config picker scopes the view to one credential at a time.
Monitoring (/monitoring):
Live dashboard. Service health board derived from indirect signals
(status-ui OverallStatus + ComponentRow). KPI tiles for sessions,
jobs, audit. Tabs: background jobs (Donut + BarChart + retry recent),
sessions (Sparkline of last 24h sign-ins), audit activity (BarChart
of severity / top resource types), infrastructure (DO summary +
WorldMapSvg coloured by droplet region + droplet list + Spaces),
rate limits. 30s auto-refresh.
Memberships (/memberships):
M:N glue between users and tenants over /admin/memberships. Add /
edit / suspend / activate / remove with role multi-select.
Networking (/networking):
Tabs over /platform/{firewalls,vpcs,domains,floating_ips}.
Read/delete on firewalls, read on VPCs, full DNS-record CRUD, and
inline assign/unassign for floating IPs.
SSO (/sso):
/sso/identity-providers CRUD with PEM cert as write-only field, plus
/sso/sessions list with destroy.
Announcements (/announcements):
/admin/announcements CRUD. Platform-wide vs per-tenant audience,
schedule windows, dismissible + active toggles.
Status page (/status-page):
/admin/status-page/{components,incidents,subscribers}. Components
CRUD, incidents with timeline + post-update + resolve flow,
subscriber list. Public preview at the top using StatusBoard +
IncidentTimeline from @crema/status-ui.
Assistant migration:
/assistant now uses @crema/llm-providers-ui (provider catalog +
vault key resolution) instead of ~/lib/llm-settings. Same async
buildAdapter() flow used by /ai. The legacy lib file is now
unreferenced and can be removed when ready.
New sibling libs wired (cloned from CremaUIStudio):
lib-file-ui, lib-card-ui, lib-dashboard-ui, lib-chart-ui,
lib-map-ui, lib-status-ui.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
79
app/lib/arcadia/announcements.ts
Normal file
79
app/lib/arcadia/announcements.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
// Platform announcements helpers.
|
||||
// Backend: /api/v1/admin/announcements (admin CRUD).
|
||||
|
||||
import type { ArcadiaClient } from "@crema/arcadia-client"
|
||||
|
||||
export type AnnouncementType =
|
||||
| "info"
|
||||
| "warning"
|
||||
| "maintenance"
|
||||
| "incident"
|
||||
| "feature"
|
||||
| string
|
||||
|
||||
export type AnnouncementAudience = "all" | "tenant" | "platform" | string
|
||||
|
||||
export interface Announcement {
|
||||
id: string
|
||||
tenant_id: string | null
|
||||
announcement_type: AnnouncementType
|
||||
title: string
|
||||
body: string | null
|
||||
action_label: string | null
|
||||
action_url: string | null
|
||||
starts_at: string | null
|
||||
ends_at: string | null
|
||||
audience: AnnouncementAudience
|
||||
dismissible: boolean
|
||||
active: boolean
|
||||
created_by_id: string | null
|
||||
inserted_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface AnnouncementInput {
|
||||
title: string
|
||||
body?: string
|
||||
announcement_type?: AnnouncementType
|
||||
audience?: AnnouncementAudience
|
||||
action_label?: string | null
|
||||
action_url?: string | null
|
||||
starts_at?: string | null
|
||||
ends_at?: string | null
|
||||
dismissible?: boolean
|
||||
active?: boolean
|
||||
/** Platform-wide if null, otherwise scoped. */
|
||||
tenant_id?: string | null
|
||||
}
|
||||
|
||||
const BASE = "/api/v1/admin/announcements"
|
||||
|
||||
export async function listAnnouncements(arcadia: ArcadiaClient): Promise<Announcement[]> {
|
||||
const res = await arcadia.GET<{ data: Announcement[] }>(BASE)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function createAnnouncement(
|
||||
arcadia: ArcadiaClient,
|
||||
input: AnnouncementInput,
|
||||
): Promise<Announcement> {
|
||||
const res = await arcadia.POST<{ data: Announcement }>(BASE, {
|
||||
body: { announcement: input },
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function updateAnnouncement(
|
||||
arcadia: ArcadiaClient,
|
||||
id: string,
|
||||
input: Partial<AnnouncementInput>,
|
||||
): Promise<Announcement> {
|
||||
const res = await arcadia.PUT<{ data: Announcement }>(`${BASE}/${id}`, {
|
||||
body: { announcement: input },
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function deleteAnnouncement(arcadia: ArcadiaClient, id: string): Promise<void> {
|
||||
await arcadia.DELETE(`${BASE}/${id}`)
|
||||
}
|
||||
217
app/lib/arcadia/buckets.ts
Normal file
217
app/lib/arcadia/buckets.ts
Normal file
@@ -0,0 +1,217 @@
|
||||
// Platform-level bucket management.
|
||||
// Backend: /api/v1/platform/buckets/*. All operations require a
|
||||
// storage_config_id pointing at a credential row in /api/v1/storage_configs.
|
||||
|
||||
import type { ArcadiaClient } from "@crema/arcadia-client"
|
||||
|
||||
export interface Bucket {
|
||||
name: string
|
||||
region?: string
|
||||
size_bytes?: number | null
|
||||
object_count?: number | null
|
||||
created_at?: string | null
|
||||
/** Backend may return additional provider-specific fields. */
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface BucketObject {
|
||||
key: string
|
||||
size: number
|
||||
last_modified: string | null
|
||||
etag: string | null
|
||||
storage_class: string | null
|
||||
}
|
||||
|
||||
export interface ListObjectsResponse {
|
||||
objects: BucketObject[]
|
||||
is_truncated: boolean
|
||||
continuation_token: string | null
|
||||
prefix: string | null
|
||||
bucket_name: string
|
||||
}
|
||||
|
||||
export interface CreateBucketInput {
|
||||
storage_config_id: string
|
||||
bucket_name: string
|
||||
region?: string
|
||||
acl?: "private" | "public-read" | string
|
||||
versioning?: boolean
|
||||
/** Pre-validate without creating. Default false. */
|
||||
dry_run?: boolean
|
||||
}
|
||||
|
||||
export interface DeleteBucketInput {
|
||||
storage_config_id: string
|
||||
bucket_name: string
|
||||
/** 6-digit code from /confirmation-code. */
|
||||
confirmation_code?: string
|
||||
/** DANGEROUS — empty the bucket first. */
|
||||
force_empty?: boolean
|
||||
/** Verify a backup exists before delete. Default true. */
|
||||
verify_backup?: boolean
|
||||
/** Preview-only. Default true on first call so the UI can confirm. */
|
||||
dry_run?: boolean
|
||||
}
|
||||
|
||||
const BASE = "/api/v1/platform/buckets"
|
||||
|
||||
export async function listBuckets(
|
||||
arcadia: ArcadiaClient,
|
||||
storageConfigId: string,
|
||||
): Promise<Bucket[]> {
|
||||
const res = await arcadia.GET<{ buckets: Bucket[]; count: number }>(`${BASE}/list`, {
|
||||
params: { storage_config_id: storageConfigId },
|
||||
})
|
||||
return res.buckets ?? []
|
||||
}
|
||||
|
||||
export async function createBucket(
|
||||
arcadia: ArcadiaClient,
|
||||
input: CreateBucketInput,
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/create`, { body: input })
|
||||
}
|
||||
|
||||
export async function deleteBucket(
|
||||
arcadia: ArcadiaClient,
|
||||
input: DeleteBucketInput,
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/delete`, { body: input })
|
||||
}
|
||||
|
||||
export async function generateConfirmationCode(
|
||||
arcadia: ArcadiaClient,
|
||||
storageConfigId: string,
|
||||
bucketName: string,
|
||||
): Promise<{ code: string; expires_at?: string }> {
|
||||
return arcadia.GET(`${BASE}/confirmation-code`, {
|
||||
params: { storage_config_id: storageConfigId, bucket_name: bucketName },
|
||||
})
|
||||
}
|
||||
|
||||
export async function listRegions(
|
||||
arcadia: ArcadiaClient,
|
||||
storageConfigId: string,
|
||||
): Promise<string[]> {
|
||||
const res = await arcadia.GET<{ regions?: string[]; data?: string[] }>(`${BASE}/regions`, {
|
||||
params: { storage_config_id: storageConfigId },
|
||||
})
|
||||
return res.regions ?? res.data ?? []
|
||||
}
|
||||
|
||||
// --- Versioning / lifecycle / replication / policy / CORS -----------------
|
||||
|
||||
export async function configureVersioning(
|
||||
arcadia: ArcadiaClient,
|
||||
input: { storage_config_id: string; bucket_name: string; enabled: boolean; dry_run?: boolean },
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/versioning`, { body: input })
|
||||
}
|
||||
|
||||
export async function configureLifecycle(
|
||||
arcadia: ArcadiaClient,
|
||||
input: {
|
||||
storage_config_id: string
|
||||
bucket_name: string
|
||||
rules: Array<Record<string, unknown>>
|
||||
dry_run?: boolean
|
||||
},
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/lifecycle`, { body: input })
|
||||
}
|
||||
|
||||
export async function configureReplication(
|
||||
arcadia: ArcadiaClient,
|
||||
input: {
|
||||
storage_config_id: string
|
||||
bucket_name: string
|
||||
destination_bucket: string
|
||||
destination_region?: string
|
||||
dry_run?: boolean
|
||||
},
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/replication`, { body: input })
|
||||
}
|
||||
|
||||
export async function configurePolicy(
|
||||
arcadia: ArcadiaClient,
|
||||
input: {
|
||||
storage_config_id: string
|
||||
bucket_name: string
|
||||
policy: Record<string, unknown>
|
||||
dry_run?: boolean
|
||||
},
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/policy`, { body: input })
|
||||
}
|
||||
|
||||
export interface CorsRule {
|
||||
allowed_origins: string[]
|
||||
allowed_methods: string[]
|
||||
allowed_headers?: string[]
|
||||
expose_headers?: string[]
|
||||
max_age_seconds?: number
|
||||
}
|
||||
|
||||
export async function getCors(
|
||||
arcadia: ArcadiaClient,
|
||||
storageConfigId: string,
|
||||
bucketName: string,
|
||||
): Promise<{ rules: CorsRule[] } | null> {
|
||||
return arcadia.GET(`${BASE}/cors`, {
|
||||
params: { storage_config_id: storageConfigId, bucket_name: bucketName },
|
||||
})
|
||||
}
|
||||
|
||||
export async function configureCors(
|
||||
arcadia: ArcadiaClient,
|
||||
input: {
|
||||
storage_config_id: string
|
||||
bucket_name: string
|
||||
rules: CorsRule[]
|
||||
dry_run?: boolean
|
||||
},
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/cors`, { body: input })
|
||||
}
|
||||
|
||||
export async function deleteCors(
|
||||
arcadia: ArcadiaClient,
|
||||
storageConfigId: string,
|
||||
bucketName: string,
|
||||
): Promise<unknown> {
|
||||
return arcadia.DELETE(`${BASE}/cors`, {
|
||||
params: { storage_config_id: storageConfigId, bucket_name: bucketName },
|
||||
})
|
||||
}
|
||||
|
||||
// --- Objects ---------------------------------------------------------------
|
||||
|
||||
export async function listObjects(
|
||||
arcadia: ArcadiaClient,
|
||||
params: {
|
||||
storage_config_id: string
|
||||
bucket_name: string
|
||||
prefix?: string
|
||||
max_keys?: number
|
||||
continuation_token?: string
|
||||
},
|
||||
): Promise<ListObjectsResponse> {
|
||||
return arcadia.GET<ListObjectsResponse>(`${BASE}/objects`, {
|
||||
params: params as Record<string, string | number | boolean | null | undefined>,
|
||||
})
|
||||
}
|
||||
|
||||
export async function getPresignedUrl(
|
||||
arcadia: ArcadiaClient,
|
||||
params: {
|
||||
storage_config_id: string
|
||||
bucket_name: string
|
||||
key: string
|
||||
expires_in?: number
|
||||
},
|
||||
): Promise<{ url: string; expires_at?: string; expires_in?: number }> {
|
||||
return arcadia.GET(`${BASE}/presigned-url`, {
|
||||
params: params as Record<string, string | number | undefined>,
|
||||
})
|
||||
}
|
||||
96
app/lib/arcadia/memberships.ts
Normal file
96
app/lib/arcadia/memberships.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
// Tenant memberships — the M:N glue between users and tenants.
|
||||
// Backend: /api/v1/admin/memberships (admin) + /api/v1/me/tenants (self).
|
||||
|
||||
import type { ArcadiaClient } from "@crema/arcadia-client"
|
||||
|
||||
export type MembershipStatus = "active" | "suspended" | "deactivated" | string
|
||||
|
||||
export interface MembershipUser {
|
||||
id: string
|
||||
email: string
|
||||
first_name: string | null
|
||||
last_name: string | null
|
||||
status: string
|
||||
}
|
||||
|
||||
export interface MembershipTenant {
|
||||
id: string
|
||||
name: string
|
||||
slug: string
|
||||
status: string
|
||||
}
|
||||
|
||||
export interface MembershipRole {
|
||||
id: string
|
||||
name: string
|
||||
slug: string
|
||||
}
|
||||
|
||||
export interface Membership {
|
||||
id: string
|
||||
tenant_id: string
|
||||
tenant: MembershipTenant | null
|
||||
user_id: string
|
||||
user: MembershipUser | null
|
||||
status: MembershipStatus
|
||||
is_primary: boolean
|
||||
joined_at: string | null
|
||||
last_accessed_at: string | null
|
||||
metadata: Record<string, unknown>
|
||||
roles: MembershipRole[]
|
||||
}
|
||||
|
||||
export interface MembershipInput {
|
||||
user_id: string
|
||||
status?: MembershipStatus
|
||||
metadata?: Record<string, unknown>
|
||||
role_ids?: string[]
|
||||
}
|
||||
|
||||
const BASE = "/api/v1/admin/memberships"
|
||||
|
||||
export async function listMemberships(arcadia: ArcadiaClient): Promise<Membership[]> {
|
||||
const res = await arcadia.GET<{ data: Membership[] }>(BASE)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function createMembership(
|
||||
arcadia: ArcadiaClient,
|
||||
input: MembershipInput,
|
||||
): Promise<Membership> {
|
||||
const res = await arcadia.POST<{ data: Membership }>(BASE, {
|
||||
body: { membership: input },
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function updateMembership(
|
||||
arcadia: ArcadiaClient,
|
||||
id: string,
|
||||
input: Partial<MembershipInput>,
|
||||
): Promise<Membership> {
|
||||
const res = await arcadia.PATCH<{ data: Membership }>(`${BASE}/${id}`, {
|
||||
body: { membership: input },
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function deleteMembership(arcadia: ArcadiaClient, id: string): Promise<void> {
|
||||
await arcadia.DELETE(`${BASE}/${id}`)
|
||||
}
|
||||
|
||||
export async function suspendMembership(
|
||||
arcadia: ArcadiaClient,
|
||||
id: string,
|
||||
): Promise<Membership> {
|
||||
const res = await arcadia.POST<{ data: Membership }>(`${BASE}/${id}/suspend`)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function activateMembership(
|
||||
arcadia: ArcadiaClient,
|
||||
id: string,
|
||||
): Promise<Membership> {
|
||||
const res = await arcadia.POST<{ data: Membership }>(`${BASE}/${id}/activate`)
|
||||
return res.data
|
||||
}
|
||||
199
app/lib/arcadia/monitoring.ts
Normal file
199
app/lib/arcadia/monitoring.ts
Normal file
@@ -0,0 +1,199 @@
|
||||
// Server stats / health helpers.
|
||||
// Wraps /api/v1/admin/monitoring/* + /api/v1/platform/* + a few observability
|
||||
// endpoints used by the monitoring dashboard.
|
||||
|
||||
import type { ArcadiaClient } from "@crema/arcadia-client"
|
||||
|
||||
// --- Rate limits ---------------------------------------------------------
|
||||
|
||||
export interface RateLimit {
|
||||
type: string
|
||||
max_requests: number
|
||||
window_seconds: number
|
||||
}
|
||||
|
||||
export async function getRateLimits(arcadia: ArcadiaClient): Promise<RateLimit[]> {
|
||||
const res = await arcadia.GET<{ data: { limits: RateLimit[] } }>(
|
||||
"/api/v1/admin/monitoring/rate-limits",
|
||||
)
|
||||
return res.data.limits ?? []
|
||||
}
|
||||
|
||||
// --- Active sessions ----------------------------------------------------
|
||||
|
||||
export interface ActiveSession {
|
||||
user_id: string
|
||||
email: string
|
||||
first_name: string | null
|
||||
last_name: string | null
|
||||
status: string
|
||||
user_type: string | null
|
||||
last_sign_in_at: string
|
||||
tenant_id: string
|
||||
two_factor_enabled: boolean
|
||||
}
|
||||
|
||||
export async function getActiveSessions(
|
||||
arcadia: ArcadiaClient,
|
||||
): Promise<{ sessions: ActiveSession[]; count: number }> {
|
||||
const res = await arcadia.GET<{ data: { sessions: ActiveSession[]; count: number } }>(
|
||||
"/api/v1/admin/monitoring/sessions",
|
||||
)
|
||||
return res.data
|
||||
}
|
||||
|
||||
// --- Background jobs (Oban) ---------------------------------------------
|
||||
|
||||
export type JobState =
|
||||
| "available"
|
||||
| "executing"
|
||||
| "scheduled"
|
||||
| "retryable"
|
||||
| "discarded"
|
||||
| "cancelled"
|
||||
| "completed"
|
||||
|
||||
export interface JobStats {
|
||||
counts: Record<JobState, number>
|
||||
by_queue: Record<string, Partial<Record<JobState, number>>>
|
||||
queues: string[]
|
||||
}
|
||||
|
||||
export interface ObanJob {
|
||||
id: number
|
||||
queue: string
|
||||
state: JobState
|
||||
worker: string
|
||||
attempt: number
|
||||
max_attempts: number
|
||||
inserted_at: string
|
||||
attempted_at: string | null
|
||||
completed_at: string | null
|
||||
scheduled_at: string | null
|
||||
errors: Array<{ at?: string; attempt?: number; error?: string }> | null
|
||||
}
|
||||
|
||||
export async function getJobStats(arcadia: ArcadiaClient): Promise<JobStats> {
|
||||
const res = await arcadia.GET<{ data: JobStats }>(
|
||||
"/api/v1/admin/monitoring/jobs/stats",
|
||||
)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function getRecentJobs(
|
||||
arcadia: ArcadiaClient,
|
||||
params?: { limit?: number; state?: JobState; queue?: string },
|
||||
): Promise<ObanJob[]> {
|
||||
const res = await arcadia.GET<{ data: { jobs: ObanJob[]; count: number } }>(
|
||||
"/api/v1/admin/monitoring/jobs",
|
||||
{ params: params as Record<string, string | number | undefined> },
|
||||
)
|
||||
return res.data.jobs ?? []
|
||||
}
|
||||
|
||||
export async function retryJob(arcadia: ArcadiaClient, id: number): Promise<void> {
|
||||
await arcadia.POST(`/api/v1/admin/monitoring/jobs/${id}/retry`)
|
||||
}
|
||||
|
||||
// --- Platform infrastructure (DigitalOcean) -----------------------------
|
||||
|
||||
/** Provider returns whatever it returns; admin UI surfaces it loosely. */
|
||||
export type InfrastructureSummary = Record<string, unknown>
|
||||
export type Space = Record<string, unknown>
|
||||
|
||||
export async function getInfrastructureSummary(
|
||||
arcadia: ArcadiaClient,
|
||||
): Promise<InfrastructureSummary | null> {
|
||||
try {
|
||||
const res = await arcadia.GET<{ data: InfrastructureSummary }>(
|
||||
"/api/v1/platform/infrastructure/summary",
|
||||
)
|
||||
return res.data
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSpaces(arcadia: ArcadiaClient): Promise<Space[]> {
|
||||
try {
|
||||
const res = await arcadia.GET<{ data: Space[] }>(
|
||||
"/api/v1/platform/infrastructure/spaces",
|
||||
)
|
||||
return res.data ?? []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
// --- Droplets ------------------------------------------------------------
|
||||
|
||||
export interface Droplet {
|
||||
id: number | string
|
||||
name: string
|
||||
status: string
|
||||
region?: { slug?: string; name?: string } | string
|
||||
size_slug?: string
|
||||
vcpus?: number
|
||||
memory?: number
|
||||
disk?: number
|
||||
created_at?: string
|
||||
networks?: unknown
|
||||
/** Provider-specific fields surface verbatim. */
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface DropletMetrics {
|
||||
cpu?: Array<{ time: string; value: number }>
|
||||
memory?: Array<{ time: string; value: number }>
|
||||
disk?: Array<{ time: string; value: number }>
|
||||
bandwidth?: Array<{ time: string; value: number }>
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export async function listDroplets(arcadia: ArcadiaClient): Promise<Droplet[]> {
|
||||
try {
|
||||
const res = await arcadia.GET<{ droplets?: Droplet[]; data?: Droplet[] }>(
|
||||
"/api/v1/platform/droplets",
|
||||
)
|
||||
return res.droplets ?? res.data ?? []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
export async function getDropletMetrics(
|
||||
arcadia: ArcadiaClient,
|
||||
id: number | string,
|
||||
): Promise<DropletMetrics | null> {
|
||||
try {
|
||||
const res = await arcadia.GET<{ data: DropletMetrics }>(
|
||||
`/api/v1/platform/droplets/${id}/metrics`,
|
||||
)
|
||||
return res.data
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
// --- Audit stats (already used by /activity, exposed here for the dashboard) ---
|
||||
|
||||
export interface AuditStats {
|
||||
total: number
|
||||
by_action?: Record<string, number>
|
||||
by_severity?: Record<string, number>
|
||||
by_resource_type?: Record<string, number>
|
||||
/** When backend supports it: { period: ISO, total: number }[] */
|
||||
over_time?: Array<{ period: string; total: number }>
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export async function getAuditStats(
|
||||
arcadia: ArcadiaClient,
|
||||
params?: { from?: string; to?: string },
|
||||
): Promise<AuditStats> {
|
||||
const res = await arcadia.GET<{ data: AuditStats }>(
|
||||
"/api/v1/observability/audit_stats",
|
||||
{ params: params as Record<string, string | undefined> },
|
||||
)
|
||||
return res.data
|
||||
}
|
||||
162
app/lib/arcadia/networking.ts
Normal file
162
app/lib/arcadia/networking.ts
Normal file
@@ -0,0 +1,162 @@
|
||||
// Networking helpers: firewalls, VPCs, domains + DNS records, floating IPs.
|
||||
// Backend: /api/v1/platform/{firewalls,vpcs,domains,floating_ips,...}.
|
||||
|
||||
import type { ArcadiaClient } from "@crema/arcadia-client"
|
||||
|
||||
const BASE = "/api/v1/platform"
|
||||
|
||||
// --- Firewalls ----------------------------------------------------------
|
||||
|
||||
export interface Firewall {
|
||||
id: string | number
|
||||
name: string
|
||||
status?: string
|
||||
inbound_rules?: unknown[]
|
||||
outbound_rules?: unknown[]
|
||||
droplet_ids?: Array<string | number>
|
||||
created_at?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export async function listFirewalls(arcadia: ArcadiaClient): Promise<Firewall[]> {
|
||||
try {
|
||||
const res = await arcadia.GET<{ firewalls?: Firewall[]; data?: Firewall[] }>(
|
||||
`${BASE}/firewalls`,
|
||||
)
|
||||
return res.firewalls ?? res.data ?? []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
export async function createFirewall(
|
||||
arcadia: ArcadiaClient,
|
||||
input: Partial<Firewall>,
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/firewalls`, { body: input })
|
||||
}
|
||||
|
||||
export async function deleteFirewall(
|
||||
arcadia: ArcadiaClient,
|
||||
id: string | number,
|
||||
): Promise<void> {
|
||||
await arcadia.DELETE(`${BASE}/firewalls/${id}`)
|
||||
}
|
||||
|
||||
// --- VPCs ---------------------------------------------------------------
|
||||
|
||||
export interface Vpc {
|
||||
id: string
|
||||
name: string
|
||||
region?: string
|
||||
ip_range?: string
|
||||
default?: boolean
|
||||
created_at?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export async function listVpcs(arcadia: ArcadiaClient): Promise<Vpc[]> {
|
||||
try {
|
||||
const res = await arcadia.GET<{ vpcs?: Vpc[]; data?: Vpc[] }>(`${BASE}/vpcs`)
|
||||
return res.vpcs ?? res.data ?? []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
// --- Domains + DNS records ----------------------------------------------
|
||||
|
||||
export interface Domain {
|
||||
name: string
|
||||
ttl?: number
|
||||
zone_file?: string | null
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface DnsRecord {
|
||||
id: string | number
|
||||
type: string
|
||||
name: string
|
||||
data: string
|
||||
priority?: number | null
|
||||
port?: number | null
|
||||
ttl?: number
|
||||
weight?: number | null
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export async function listDomains(arcadia: ArcadiaClient): Promise<Domain[]> {
|
||||
try {
|
||||
const res = await arcadia.GET<{ domains?: Domain[]; data?: Domain[] }>(`${BASE}/domains`)
|
||||
return res.domains ?? res.data ?? []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
export async function listDnsRecords(
|
||||
arcadia: ArcadiaClient,
|
||||
domainName: string,
|
||||
): Promise<DnsRecord[]> {
|
||||
const res = await arcadia.GET<{ domain_records?: DnsRecord[]; data?: DnsRecord[] }>(
|
||||
`${BASE}/domains/${encodeURIComponent(domainName)}/records`,
|
||||
)
|
||||
return res.domain_records ?? res.data ?? []
|
||||
}
|
||||
|
||||
export async function createDnsRecord(
|
||||
arcadia: ArcadiaClient,
|
||||
domainName: string,
|
||||
input: { type: string; name: string; data: string; ttl?: number; priority?: number },
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/domains/${encodeURIComponent(domainName)}/records`, {
|
||||
body: input,
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteDnsRecord(
|
||||
arcadia: ArcadiaClient,
|
||||
domainName: string,
|
||||
recordId: string | number,
|
||||
): Promise<void> {
|
||||
await arcadia.DELETE(
|
||||
`${BASE}/domains/${encodeURIComponent(domainName)}/records/${recordId}`,
|
||||
)
|
||||
}
|
||||
|
||||
// --- Floating IPs -------------------------------------------------------
|
||||
|
||||
export interface FloatingIp {
|
||||
ip: string
|
||||
region?: { slug?: string; name?: string } | string
|
||||
droplet?: { id: number | string; name?: string } | null
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export async function listFloatingIps(arcadia: ArcadiaClient): Promise<FloatingIp[]> {
|
||||
try {
|
||||
const res = await arcadia.GET<{ floating_ips?: FloatingIp[]; data?: FloatingIp[] }>(
|
||||
`${BASE}/floating_ips`,
|
||||
)
|
||||
return res.floating_ips ?? res.data ?? []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
export async function assignFloatingIp(
|
||||
arcadia: ArcadiaClient,
|
||||
ip: string,
|
||||
dropletId: number | string,
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/floating_ips/${ip}/assign`, {
|
||||
body: { droplet_id: dropletId },
|
||||
})
|
||||
}
|
||||
|
||||
export async function unassignFloatingIp(
|
||||
arcadia: ArcadiaClient,
|
||||
ip: string,
|
||||
): Promise<unknown> {
|
||||
return arcadia.POST(`${BASE}/floating_ips/${ip}/unassign`)
|
||||
}
|
||||
99
app/lib/arcadia/sso.ts
Normal file
99
app/lib/arcadia/sso.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
// SSO / SAML helpers.
|
||||
// Backend: /api/v1/sso/identity-providers (tenant CRUD) + /sessions.
|
||||
// Note: certificates are large and write-only.
|
||||
|
||||
import type { ArcadiaClient } from "@crema/arcadia-client"
|
||||
|
||||
export interface IdentityProvider {
|
||||
id: string
|
||||
tenant_id: string
|
||||
name: string
|
||||
entity_id: string
|
||||
sso_url: string
|
||||
slo_url: string | null
|
||||
name_id_format: string | null
|
||||
attribute_mapping: Record<string, string>
|
||||
sp_entity_id: string | null
|
||||
sign_requests: boolean
|
||||
metadata_url: string | null
|
||||
callback_url: string | null
|
||||
enabled: boolean
|
||||
has_certificate: boolean
|
||||
inserted_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface IdentityProviderInput {
|
||||
name: string
|
||||
entity_id: string
|
||||
sso_url: string
|
||||
slo_url?: string | null
|
||||
name_id_format?: string | null
|
||||
attribute_mapping?: Record<string, string>
|
||||
sp_entity_id?: string | null
|
||||
sign_requests?: boolean
|
||||
metadata_url?: string | null
|
||||
callback_url?: string | null
|
||||
enabled?: boolean
|
||||
/** PEM cert from the IdP. Write-only. */
|
||||
certificate?: string
|
||||
}
|
||||
|
||||
export interface SamlSession {
|
||||
id: string
|
||||
user_id: string
|
||||
idp_id: string
|
||||
name_id: string | null
|
||||
session_index: string | null
|
||||
expires_at: string | null
|
||||
inserted_at: string
|
||||
}
|
||||
|
||||
const BASE = "/api/v1/sso"
|
||||
|
||||
export async function listIdentityProviders(arcadia: ArcadiaClient): Promise<IdentityProvider[]> {
|
||||
const res = await arcadia.GET<{ data: IdentityProvider[] }>(`${BASE}/identity-providers`)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function createIdentityProvider(
|
||||
arcadia: ArcadiaClient,
|
||||
input: IdentityProviderInput,
|
||||
): Promise<IdentityProvider> {
|
||||
const res = await arcadia.POST<{ data: IdentityProvider }>(
|
||||
`${BASE}/identity-providers`,
|
||||
{ body: { identity_provider: input } },
|
||||
)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function updateIdentityProvider(
|
||||
arcadia: ArcadiaClient,
|
||||
id: string,
|
||||
input: Partial<IdentityProviderInput>,
|
||||
): Promise<IdentityProvider> {
|
||||
const res = await arcadia.PATCH<{ data: IdentityProvider }>(
|
||||
`${BASE}/identity-providers/${id}`,
|
||||
{ body: { identity_provider: input } },
|
||||
)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function deleteIdentityProvider(
|
||||
arcadia: ArcadiaClient,
|
||||
id: string,
|
||||
): Promise<void> {
|
||||
await arcadia.DELETE(`${BASE}/identity-providers/${id}`)
|
||||
}
|
||||
|
||||
export async function listSamlSessions(arcadia: ArcadiaClient): Promise<SamlSession[]> {
|
||||
const res = await arcadia.GET<{ data: SamlSession[] }>(`${BASE}/sessions`)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function destroySamlSession(
|
||||
arcadia: ArcadiaClient,
|
||||
sessionId: string,
|
||||
): Promise<void> {
|
||||
await arcadia.DELETE(`${BASE}/sessions/${sessionId}`)
|
||||
}
|
||||
172
app/lib/arcadia/status-page.ts
Normal file
172
app/lib/arcadia/status-page.ts
Normal file
@@ -0,0 +1,172 @@
|
||||
// Status page helpers — components, incidents, subscribers.
|
||||
// Backend: /api/v1/admin/status-page/* (admin CRUD).
|
||||
|
||||
import type { ArcadiaClient } from "@crema/arcadia-client"
|
||||
|
||||
export type ComponentStatus =
|
||||
| "operational"
|
||||
| "degraded_performance"
|
||||
| "partial_outage"
|
||||
| "major_outage"
|
||||
| "maintenance"
|
||||
| string
|
||||
|
||||
export interface StatusComponent {
|
||||
id: string
|
||||
name: string
|
||||
description: string | null
|
||||
status: ComponentStatus
|
||||
display_order: number
|
||||
group_name: string | null
|
||||
inserted_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export type IncidentStatus =
|
||||
| "investigating"
|
||||
| "identified"
|
||||
| "monitoring"
|
||||
| "resolved"
|
||||
| string
|
||||
|
||||
export type IncidentImpact = "none" | "minor" | "major" | "critical" | string
|
||||
|
||||
export interface IncidentUpdate {
|
||||
id: string
|
||||
status: IncidentStatus
|
||||
body: string
|
||||
inserted_at: string
|
||||
}
|
||||
|
||||
export interface Incident {
|
||||
id: string
|
||||
title: string
|
||||
status: IncidentStatus
|
||||
impact: IncidentImpact
|
||||
resolved_at: string | null
|
||||
metadata: Record<string, unknown>
|
||||
updates: IncidentUpdate[]
|
||||
components: StatusComponent[]
|
||||
inserted_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface Subscriber {
|
||||
id: string
|
||||
email: string
|
||||
confirmed_at: string | null
|
||||
inserted_at: string
|
||||
}
|
||||
|
||||
export interface ComponentInput {
|
||||
name: string
|
||||
description?: string
|
||||
status?: ComponentStatus
|
||||
display_order?: number
|
||||
group_name?: string | null
|
||||
}
|
||||
|
||||
export interface IncidentInput {
|
||||
title: string
|
||||
status?: IncidentStatus
|
||||
impact?: IncidentImpact
|
||||
/** IDs of affected components. */
|
||||
component_ids?: string[]
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface IncidentUpdateInput {
|
||||
status: IncidentStatus
|
||||
body: string
|
||||
}
|
||||
|
||||
const BASE = "/api/v1/admin/status-page"
|
||||
|
||||
// --- Components ---------------------------------------------------------
|
||||
|
||||
export async function listComponents(arcadia: ArcadiaClient): Promise<StatusComponent[]> {
|
||||
const res = await arcadia.GET<{ data: StatusComponent[] }>(`${BASE}/components`)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function createComponent(
|
||||
arcadia: ArcadiaClient,
|
||||
input: ComponentInput,
|
||||
): Promise<StatusComponent> {
|
||||
const res = await arcadia.POST<{ data: StatusComponent }>(`${BASE}/components`, {
|
||||
body: { component: input },
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function updateComponent(
|
||||
arcadia: ArcadiaClient,
|
||||
id: string,
|
||||
input: Partial<ComponentInput>,
|
||||
): Promise<StatusComponent> {
|
||||
const res = await arcadia.PUT<{ data: StatusComponent }>(`${BASE}/components/${id}`, {
|
||||
body: { component: input },
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function deleteComponent(arcadia: ArcadiaClient, id: string): Promise<void> {
|
||||
await arcadia.DELETE(`${BASE}/components/${id}`)
|
||||
}
|
||||
|
||||
// --- Incidents ----------------------------------------------------------
|
||||
|
||||
export async function listIncidents(arcadia: ArcadiaClient): Promise<Incident[]> {
|
||||
const res = await arcadia.GET<{ data: Incident[] }>(`${BASE}/incidents`)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function getIncident(arcadia: ArcadiaClient, id: string): Promise<Incident> {
|
||||
const res = await arcadia.GET<{ data: Incident }>(`${BASE}/incidents/${id}`)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function createIncident(
|
||||
arcadia: ArcadiaClient,
|
||||
input: IncidentInput,
|
||||
): Promise<Incident> {
|
||||
const res = await arcadia.POST<{ data: Incident }>(`${BASE}/incidents`, {
|
||||
body: { incident: input },
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function updateIncident(
|
||||
arcadia: ArcadiaClient,
|
||||
id: string,
|
||||
input: Partial<IncidentInput>,
|
||||
): Promise<Incident> {
|
||||
const res = await arcadia.PUT<{ data: Incident }>(`${BASE}/incidents/${id}`, {
|
||||
body: { incident: input },
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function resolveIncident(arcadia: ArcadiaClient, id: string): Promise<Incident> {
|
||||
const res = await arcadia.POST<{ data: Incident }>(`${BASE}/incidents/${id}/resolve`)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function addIncidentUpdate(
|
||||
arcadia: ArcadiaClient,
|
||||
incidentId: string,
|
||||
input: IncidentUpdateInput,
|
||||
): Promise<IncidentUpdate> {
|
||||
const res = await arcadia.POST<{ data: IncidentUpdate }>(
|
||||
`${BASE}/incidents/${incidentId}/updates`,
|
||||
{ body: { update: input } },
|
||||
)
|
||||
return res.data
|
||||
}
|
||||
|
||||
// --- Subscribers --------------------------------------------------------
|
||||
|
||||
export async function listSubscribers(arcadia: ArcadiaClient): Promise<Subscriber[]> {
|
||||
const res = await arcadia.GET<{ data: Subscriber[] }>(`${BASE}/subscribers`)
|
||||
return res.data
|
||||
}
|
||||
Reference in New Issue
Block a user