78 lines
3.6 KiB
JSON
78 lines
3.6 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://yovision.local/contracts/events/v1/event.schema.json",
|
|
"title": "YoVision anonymous safety event v1",
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"schema_version", "producer_id", "source_event_id", "site_ref", "device_ref",
|
|
"profile_ref", "event_type", "occurred_at", "severity", "rule", "model",
|
|
"observation", "region", "evidence"
|
|
],
|
|
"properties": {
|
|
"schema_version": {"const": "yovision.event/v1"},
|
|
"producer_id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"},
|
|
"source_event_id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"},
|
|
"site_ref": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"},
|
|
"device_ref": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"},
|
|
"profile_ref": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"},
|
|
"event_type": {"enum": ["dangerous_area_entered", "directional_line_crossed"]},
|
|
"occurred_at": {"type": "string", "format": "date-time", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"},
|
|
"severity": {"enum": ["low", "medium", "high", "critical"]},
|
|
"rule": {
|
|
"type": "object", "additionalProperties": false, "required": ["rule_id", "version"],
|
|
"properties": {
|
|
"rule_id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"},
|
|
"version": {"type": "string", "minLength": 1, "maxLength": 64}
|
|
}
|
|
},
|
|
"model": {
|
|
"type": "object", "additionalProperties": false, "required": ["name", "version"],
|
|
"properties": {
|
|
"name": {"type": "string", "minLength": 1, "maxLength": 128},
|
|
"version": {"type": "string", "minLength": 1, "maxLength": 64}
|
|
}
|
|
},
|
|
"observation": {
|
|
"type": "object", "additionalProperties": false,
|
|
"required": ["track_id", "category", "confidence"],
|
|
"properties": {
|
|
"track_id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"},
|
|
"category": {"enum": ["person", "vehicle", "other"]},
|
|
"confidence": {"type": "number", "minimum": 0, "maximum": 1},
|
|
"bbox_normalized": {
|
|
"type": "array", "minItems": 4, "maxItems": 4,
|
|
"items": {"type": "number", "minimum": 0, "maximum": 1}
|
|
}
|
|
}
|
|
},
|
|
"region": {
|
|
"type": "object", "additionalProperties": false,
|
|
"required": ["region_id", "kind"],
|
|
"properties": {
|
|
"region_id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"},
|
|
"kind": {"enum": ["area", "line"]},
|
|
"crossing_direction": {"enum": ["a_to_b", "b_to_a"]}
|
|
},
|
|
"allOf": [
|
|
{"if": {"properties": {"kind": {"const": "line"}}, "required": ["kind"]}, "then": {"required": ["crossing_direction"]}},
|
|
{"if": {"properties": {"kind": {"const": "area"}}, "required": ["kind"]}, "then": {"not": {"required": ["crossing_direction"]}}}
|
|
]
|
|
},
|
|
"evidence": {
|
|
"type": "array", "maxItems": 8, "uniqueItems": true,
|
|
"items": {"$ref": "../../evidence/v1/evidence-reference.schema.json"}
|
|
}
|
|
},
|
|
"allOf": [
|
|
{
|
|
"if": {"properties": {"event_type": {"const": "dangerous_area_entered"}}, "required": ["event_type"]},
|
|
"then": {"properties": {"region": {"properties": {"kind": {"const": "area"}}}}}
|
|
},
|
|
{
|
|
"if": {"properties": {"event_type": {"const": "directional_line_crossed"}}, "required": ["event_type"]},
|
|
"then": {"properties": {"region": {"properties": {"kind": {"const": "line"}}}}}
|
|
}
|
|
]
|
|
}
|