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", ... }
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"
- 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"] }
Typical validation errors raised during STORE
- No schema defined
- Missing field
status
in payload - Field
order_id
is expected to be one ofint
, but gotString
- Payload contains fields not defined in schema: invalid_field