mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 19:05:06 +03:00
Replaces the seeded store with GET /v2/projects/{ref}/workers, and reshapes the
view model, state pill and resource formatting to what the endpoint returns.
25 lines
945 B
TypeScript
25 lines
945 B
TypeScript
import type { components } from 'api-types'
|
|
|
|
import type { Worker, WorkerBuildState } from '@/components/interfaces/Workers/Workers.types'
|
|
|
|
type WorkerDatum = components['schemas']['V2WorkerResponse']['data']
|
|
|
|
const BUILD_STATES: WorkerBuildState[] = ['building', 'active', 'failed']
|
|
|
|
const parseBuildState = (value: string): WorkerBuildState =>
|
|
BUILD_STATES.find((state) => state === value) ?? 'failed'
|
|
|
|
export const parseWorker = ({ id, attributes }: WorkerDatum): Worker => ({
|
|
name: id,
|
|
buildState: parseBuildState(attributes.build_state),
|
|
isDeleting: attributes.deleting ?? false,
|
|
runtime: attributes.spec.runtime,
|
|
size: attributes.spec.size,
|
|
access: attributes.spec.exposure === 'public' ? 'public' : 'private',
|
|
declaredInstances: attributes.spec.instances,
|
|
instances: attributes.instances,
|
|
imageVersion: attributes.image_version,
|
|
stateReason: attributes.state_reason,
|
|
instancesError: attributes.instances_error,
|
|
})
|