{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cleanedweb.com/schemas/property-event-v1.json",
  "title": "CleanedWeb canonical property event",
  "description": "A finalized observed change associated with one maintained canonical property.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "id", "type", "timestamp", "data"],
  "properties": {
    "schema_version": {"const": "property-event-v1"},
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 300,
      "pattern": "^[^.]+$"
    },
    "type": {
      "enum": [
        "property.match.created",
        "property.price.changed",
        "property.status.changed"
      ]
    },
    "timestamp": {"type": "string", "format": "date-time"},
    "data": {
      "type": "object",
      "additionalProperties": false,
      "required": ["property_entity_id", "change", "property"],
      "properties": {
        "workspace_id": {"type": "string", "minLength": 1},
        "saved_search_id": {"type": "string", "minLength": 1},
        "property_entity_id": {"type": "string", "minLength": 1, "maxLength": 300},
        "available_at": {"type": "string", "format": "date-time"},
        "change": {"type": "object", "additionalProperties": true},
        "property": {
          "$ref": "./property-profile-v2.json"
        },
        "record_count": {"const": 1},
        "units": {"type": "number", "minimum": 0}
      }
    }
  }
}
