DEFINE
Purpose
Register the schema for an event type. STORE payloads must conform to this schema.
Form
DEFINE <event_type:WORD> [ AS <version:NUMBER> ] FIELDS { "key_1": "type_1", ... }
Constraints
- Requires authentication and admin role.
Field pairs
- Keys can be STRING or WORD. The parser will quote WORD keys when converting to JSON.
- Values (types) can be:
- STRING literals, for example: “int”, “string”, “string | null”
- Special logical time types:
- “datetime” → event time instant; payload accepts ISO-8601 strings or epoch (s/ms/µs/ns) and is normalized to epoch seconds
- “date” → calendar date; payload accepts “YYYY-MM-DD” (midnight UTC) or epoch and is normalized to epoch seconds
- ARRAY of strings to define an enum, for example: [“pro”, “basic”]
- Enum variants are case-sensitive (“Pro” != “pro”)
- Schema must be flat (no nested objects).
Examples
DEFINE order_created FIELDS { "order_id": "int", "status": "string" }
DEFINE review FIELDS { rating: "int", verified: "bool" }
DEFINE order_created AS 2 FIELDS { order_id: "int", status: "string", note: "string | null" }
DEFINE subscription FIELDS { plan: ["pro", "basic"] }
DEFINE product FIELDS { name: "string", created_at: "datetime", release_date: "date" }
Errors
Authentication required: No user ID provided or authentication failed.Only admin users can define schemas: The authenticated user is not an admin.
Typical validation errors raised during STORE
- No schema defined
- Missing field
statusin payload - Field
order_idis expected to be one ofint, but gotString - Payload contains fields not defined in schema: invalid_field