{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schema.whispir.com/event-0.0.0",
  "title": "Base schema for all Event notifications",
  "type": "object",
  "properties": {
    "schema": true,
    "metadata": {
      "$ref": "#/$defs/metadata"
    },
    "source": {
      "$ref": "#/$defs/appDetails"
    },
    "event": true
  },
  "required": ["schema", "metadata", "source", "event"],
  "additionalProperties": false,
  "$defs": {
    "appDetails": {
      "type": "object",
      "properties": {
        "vendor": {
          "type": "string",
          "format": "hostname",
          "description": "Canonical vendor ID in reverse DNS format",
          "examples": ["com.example", "com.whispir"]
        },
        "application": {
          "type": "string",
          "pattern": "^[\\w](?:[-\\w\\d\\s_.])*$"
        },
        "version": {
          "anyOf": [
            {
              "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/gitCommitHash"
            },
            {
              "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/semVer"
            }
          ]
        },
        "instanceId": {
          "anyOf": [
            {
              "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/dockerContainerLongId"
            },
            {
              "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/dockerContainerShortId"
            },
            {
              "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/uuid"
            }
          ]
        },
        "awsRegion": {
          "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/awsRegion"
        },
        "hostname": {
          "type": "string",
          "format": "hostname"
        },
        "processName": {
          "type": "string",
          "minLength": 1
        },
        "processId": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": ["vendor", "application", "version", "instanceId"]
    },
    "metadata": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/uuid"
        },
        "severity": {
          "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/severity"
        },
        "timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "traceId": {
          "anyOf": [
            {
              "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/uuid"
            },
            {
              "$ref": "https://schema.whispir.com/common-0.0.0#/$defs/xrayTraceId"
            }
          ],
          "$comment": "Producers should always use X-Ray trace IDs where available, otherwise UUIDs"
        }
      },
      "required": ["id", "severity", "timestamp", "traceId"],
      "additionalProperties": false
    }
  }
}
