Skip to content

Data model

The domain model lives in src/lib/types.ts. This page summarizes it. The file itself is the source of truth.

Field Type Notes
id ID
name string
prefix string Used for codes: gps → gps_001
icon, category, description string
fields FieldDef[] Label schema
slots Slot[] Expected components
nextNumber number Next code number; never decremented

FieldDef: key, label, type (text · number · select · date · boolean), optional options, unit, required.

Slot: id, typeId, optional label, optional qty (unset = any number).

Field Type Notes
id ID
typeId ID
code string drone_001
name string?
status Status operational · attention · maintenance · faulty · retired
parentId ID | null Item it is installed in
slotId ID? Slot of the parent it fills
custodianId ID?
location string?
labels Record<string, string | number | boolean> Keyed by FieldDef.key
watchers ID[]

name, kind (pdf · image · sheet · text · archive · other), size, optional description, and a scope:

type DocScope =
| { kind: 'item'; itemId: ID }
| { kind: 'type'; typeId: ID }
| { kind: 'variant'; typeId: ID; field: string; value: string }

target ({ kind: 'item' | 'type'; id }), authorId, body, via (web · email · qr), optional replyTo.

Field Notes
itemId
fromId Custodian when it started; unset = from stock
toId Recipient
requestedBy Who started it. The other side confirms.
status pending · accepted · declined · cancelled
note, responseNote
checked, missing Component IDs confirmed present / reported missing
condition Status confirmed by the receiver

Both are stored as data (kind plus IDs), never as rendered sentences, so they display in the viewer’s language. Activity kinds: created, status, assigned, unassigned, comment, document, labels, custody, handover, type.

action (delete · restore), entity (item · type · doc · comment · user), label (code or name at the time), actorId, reason, and a snapshot with everything needed to restore.

name, email, role (admin · editor · viewer), team, status (active · invited · disabled).