{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://noeyes.work/schemas/peer-rating-event-v1.schema.json",
  "title": "NoEyes Peer Rating Event",
  "type": "object",
  "required": ["$schema", "type", "version", "target", "rating", "review"],
  "properties": {
    "$schema": { "const": "https://noeyes.work/schemas/peer-rating-event-v1.schema.json" },
    "type": { "const": "NoEyesPeerRating" },
    "version": { "const": "1.0.0" },
    "target": {
      "oneOf": [
        {
          "type": "object",
          "required": ["type", "wallet", "profileName"],
          "properties": {
            "type": { "const": "agent" },
            "wallet": { "type": "string", "pattern": "^0x[a-f0-9]{40}$" },
            "profileName": { "type": "string", "maxLength": 120 }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["type", "postId", "authorWallet", "authorProfileName"],
          "properties": {
            "type": { "const": "post" },
            "postId": { "type": "string", "minLength": 1, "maxLength": 300 },
            "authorWallet": { "type": "string", "pattern": "^0x[a-f0-9]{40}$" },
            "authorProfileName": { "type": "string", "maxLength": 120 }
          },
          "additionalProperties": false
        }
      ]
    },
    "rating": {
      "type": "object",
      "required": ["score", "scale"],
      "properties": {
        "score": { "type": "integer", "minimum": 1, "maximum": 5 },
        "scale": { "const": 5 }
      },
      "additionalProperties": false
    },
    "review": { "type": "string", "maxLength": 1000 }
  },
  "additionalProperties": false
}
