feat(sense): implement Control API v1 [T-011]
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://yovision.local/contracts/sense-device-audit-v2.schema.json",
|
||||
"title": "Sense Device Audit Event v2",
|
||||
"description": "v1 的向后兼容后继:增加脱敏设备配置受理事实,仍不定义 Bell relay。",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"event_id", "event_type", "tenant_id", "site_id", "device_id",
|
||||
"actor", "reason", "trace_id", "aggregate_generation",
|
||||
"projection_versions", "data", "occurred_at"
|
||||
],
|
||||
"properties": {
|
||||
"event_id": {"type": "string", "pattern": "^audit_[0-9a-f]{32}$"},
|
||||
"event_type": {
|
||||
"enum": [
|
||||
"device.created",
|
||||
"device.desired_state.accepted",
|
||||
"device.configuration.accepted"
|
||||
]
|
||||
},
|
||||
"tenant_id": {"$ref": "#/$defs/logicalId"},
|
||||
"site_id": {"$ref": "#/$defs/logicalId"},
|
||||
"device_id": {"$ref": "#/$defs/logicalId"},
|
||||
"actor": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["type", "id"],
|
||||
"properties": {
|
||||
"type": {"enum": ["user", "service", "system"]},
|
||||
"id": {"type": "string", "minLength": 1, "maxLength": 200}
|
||||
}
|
||||
},
|
||||
"reason": {"type": ["string", "null"], "maxLength": 500},
|
||||
"trace_id": {"type": ["string", "null"], "maxLength": 128},
|
||||
"aggregate_generation": {"type": "integer", "minimum": 1},
|
||||
"projection_versions": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["quota_source_version", "area_policy_source_version"],
|
||||
"properties": {
|
||||
"quota_source_version": {"type": ["integer", "null"], "minimum": 1},
|
||||
"area_policy_source_version": {"type": ["integer", "null"], "minimum": 1}
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"oneOf": [
|
||||
{"$ref": "#/$defs/deviceCreatedData"},
|
||||
{"$ref": "#/$defs/desiredStateData"},
|
||||
{"$ref": "#/$defs/configurationData"}
|
||||
]
|
||||
},
|
||||
"occurred_at": {"type": "string", "format": "date-time"}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {"properties": {"event_type": {"const": "device.created"}}},
|
||||
"then": {"properties": {"data": {"$ref": "#/$defs/deviceCreatedData"}}}
|
||||
},
|
||||
{
|
||||
"if": {"properties": {"event_type": {"const": "device.desired_state.accepted"}}},
|
||||
"then": {"properties": {"data": {"$ref": "#/$defs/desiredStateData"}}}
|
||||
},
|
||||
{
|
||||
"if": {"properties": {"event_type": {"const": "device.configuration.accepted"}}},
|
||||
"then": {"properties": {"data": {"$ref": "#/$defs/configurationData"}}}
|
||||
}
|
||||
],
|
||||
"$defs": {
|
||||
"logicalId": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 128,
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
|
||||
},
|
||||
"desiredState": {"enum": ["disabled", "enabled"]},
|
||||
"deviceCreatedData": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["kind", "area_id", "modality", "capabilities", "desired_state"],
|
||||
"properties": {
|
||||
"kind": {"const": "device_created"},
|
||||
"area_id": {"$ref": "#/$defs/logicalId"},
|
||||
"modality": {"enum": ["video", "radar", "contact", "button", "wearable", "other"]},
|
||||
"capabilities": {
|
||||
"type": "array",
|
||||
"maxItems": 16,
|
||||
"uniqueItems": true,
|
||||
"items": {"enum": ["video_capture", "audio_capture", "spatial_rule", "telemetry"]}
|
||||
},
|
||||
"desired_state": {"$ref": "#/$defs/desiredState"}
|
||||
}
|
||||
},
|
||||
"desiredStateData": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["kind", "previous_desired_state", "desired_state", "changed"],
|
||||
"properties": {
|
||||
"kind": {"const": "desired_state_accepted"},
|
||||
"previous_desired_state": {"$ref": "#/$defs/desiredState"},
|
||||
"desired_state": {"$ref": "#/$defs/desiredState"},
|
||||
"changed": {"type": "boolean"}
|
||||
}
|
||||
},
|
||||
"configurationData": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["kind", "changed", "changed_fields", "area_id"],
|
||||
"properties": {
|
||||
"kind": {"const": "configuration_accepted"},
|
||||
"changed": {"type": "boolean"},
|
||||
"changed_fields": {
|
||||
"type": "array",
|
||||
"maxItems": 5,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"enum": ["name", "area_id", "endpoint_ref", "credential_ref", "profile_token"]
|
||||
}
|
||||
},
|
||||
"area_id": {"$ref": "#/$defs/logicalId"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user