{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "const": "signal.fired"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
      "description": "When the rule fired."
    },
    "data": {
      "type": "object",
      "properties": {
        "version": {
          "type": "number",
          "const": 1
        },
        "id": {
          "type": "string",
          "pattern": "^sig_[0-9a-f]{32}$",
          "description": "The same at every attempt and in the webhook-id header. At most 36 characters from [A-Za-z0-9_-], so it can be the order id."
        },
        "rule": {
          "type": "string",
          "minLength": 1,
          "description": "Venndann's id of the rule that fired."
        },
        "market": {
          "type": "string",
          "enum": [
            "crypto",
            "stocks"
          ]
        },
        "statement": {
          "type": "string",
          "minLength": 1,
          "maxLength": 300,
          "description": "What the person confirmed they were waiting for, in their words."
        },
        "chatRef": {
          "type": "string",
          "minLength": 1,
          "description": "The platform's own id of the chat the rule was confirmed in, as the platform sent it."
        },
        "userRef": {
          "type": "string",
          "minLength": 1,
          "description": "The platform's own id of the person who confirmed it, as the platform sent it."
        },
        "order": {
          "description": "What the platform asked to be done, passed back untouched.",
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        },
        "quote": {
          "type": "object",
          "properties": {
            "text": {
              "type": "string",
              "minLength": 1
            },
            "start": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "end": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "text",
            "start",
            "end"
          ],
          "additionalProperties": false,
          "description": "The exact words of the text that state it happened, and where they are in that text: start and end count UTF-16 code units from its beginning, as JavaScript counts a string, and end is the first one after the quote."
        },
        "source": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9-]{0,62}$"
            },
            "name": {
              "type": "string",
              "minLength": 1
            },
            "url": {
              "type": "string",
              "format": "uri"
            }
          },
          "required": [
            "id",
            "name"
          ],
          "additionalProperties": false
        },
        "event": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1
            },
            "publishedAt": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            },
            "updatedAt": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            },
            "receivedAt": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            }
          },
          "required": [
            "id",
            "receivedAt"
          ],
          "additionalProperties": false,
          "description": "The text the quote is from: when its source says it was published, if it says so with a time; else when its source says it was last updated, if it says that; and when Venndann had it."
        },
        "decision": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "The digest of the decision record in Venndann's tamper-evident chain."
        },
        "trace": {
          "type": "string",
          "pattern": "^[0-9a-f]{32}$",
          "description": "Ties together everything Venndann did for this text, for asking about it."
        }
      },
      "required": [
        "version",
        "id",
        "rule",
        "market",
        "statement",
        "chatRef",
        "userRef",
        "quote",
        "source",
        "event",
        "decision",
        "trace"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "type",
    "timestamp",
    "data"
  ],
  "additionalProperties": false,
  "description": "Venndann signal.fired, version 1"
}
