{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.anguskit.com/schema/angusmeter/plugins/angus-rabbitmq.json",
  "type": "object",
  "properties": {
    "host": {
      "type": "string",
      "default": "localhost",
      "description": "RabbitMQ server hostname"
    },
    "port": {
      "type": "integer",
      "default": 5672,
      "minimum": 1,
      "maximum": 65535,
      "description": "RabbitMQ server port"
    },
    "username": {
      "type": "string",
      "default": "guest",
      "description": "Authentication username"
    },
    "password": {
      "type": "string",
      "default": "guest",
      "writeOnly": true,
      "description": "Authentication password"
    },
    "virtualHost": {
      "type": "string",
      "default": "/",
      "description": "Virtual host"
    },
    "action": {
      "type": "string",
      "enum": [
        "PUBLISH",
        "CONSUME",
        "GET",
        "DECLARE_QUEUE",
        "DECLARE_EXCHANGE",
        "BIND_QUEUE",
        "UNBIND_QUEUE",
        "PURGE_QUEUE",
        "DELETE_QUEUE",
        "DELETE_EXCHANGE",
        "RPC"
      ],
      "default": "PUBLISH",
      "description": "AMQP operation to perform"
    },
    "exchange": {
      "type": "string",
      "default": "",
      "description": "Exchange name (empty for default exchange)"
    },
    "exchangeType": {
      "type": "string",
      "enum": [
        "direct",
        "fanout",
        "topic",
        "headers"
      ],
      "default": "direct",
      "description": "Exchange type for DECLARE_EXCHANGE"
    },
    "routingKey": {
      "type": "string",
      "default": "",
      "description": "Routing key for publish/bind"
    },
    "queue": {
      "type": "string",
      "description": "Queue name for consume/declare/purge/delete"
    },
    "body": {
      "type": "string",
      "description": "Message body (supports ${var} interpolation)"
    },
    "contentType": {
      "type": "string",
      "default": "text/plain",
      "description": "Message content type"
    },
    "headers": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "AMQP message headers as key-value pairs"
    },
    "durable": {
      "type": "boolean",
      "default": true,
      "description": "Durable queue/exchange"
    },
    "exclusive": {
      "type": "boolean",
      "default": false,
      "description": "Exclusive queue"
    },
    "autoDelete": {
      "type": "boolean",
      "default": false,
      "description": "Auto-delete queue/exchange"
    },
    "autoAck": {
      "type": "boolean",
      "default": true,
      "description": "Auto-acknowledge consumed messages"
    },
    "prefetchCount": {
      "type": "integer",
      "default": 1,
      "minimum": 1,
      "description": "Consumer prefetch count"
    },
    "consumeTimeout": {
      "type": "integer",
      "default": 5000,
      "minimum": 100,
      "maximum": 60000,
      "description": "Consume/RPC timeout in ms"
    },
    "heartbeat": {
      "type": "integer",
      "default": 60,
      "minimum": 0,
      "maximum": 3600,
      "description": "Connection heartbeat in seconds"
    },
    "channelMax": {
      "type": "integer",
      "default": 0,
      "minimum": 0,
      "maximum": 65535,
      "description": "Max channels per connection (0 = unlimited)"
    },
    "mandatory": {
      "type": "boolean",
      "default": false,
      "description": "Enable mandatory flag on publish"
    },
    "replyTo": {
      "type": "string",
      "description": "Reply-to queue for RPC"
    },
    "correlationId": {
      "type": "string",
      "description": "Correlation ID for message tracking"
    },
    "deliveryMode": {
      "type": "integer",
      "enum": [
        1,
        2
      ],
      "default": 2,
      "description": "1=non-persistent, 2=persistent"
    },
    "priority": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9,
      "description": "Message priority (0-9)"
    },
    "expiration": {
      "type": "string",
      "description": "Message TTL in milliseconds (e.g. '60000')"
    },
    "useSsl": {
      "type": "boolean",
      "default": false,
      "description": "Enable TLS/SSL connection"
    },
    "connection": {
      "type": "object",
      "description": "Advanced connection settings",
      "properties": {
        "connectionTimeout": {
          "type": "integer",
          "default": 30000,
          "description": "Connection timeout in ms"
        },
        "networkRecoveryInterval": {
          "type": "integer",
          "default": 5000,
          "description": "Network recovery interval in ms"
        },
        "automaticRecovery": {
          "type": "boolean",
          "default": true,
          "description": "Enable automatic connection recovery"
        }
      }
    },
    "assertions": {
      "type": "array",
      "description": "Optional step-level assertions (operator required per RabbitMQConfigValidator). BODY is an alias for RESPONSE_BODY.",
      "items": {
        "$ref": "#/definitions/rabbitMqAssertion"
      }
    },
    "extractors": {
      "type": "array",
      "description": "Optional extractors from the AMQP operation result (see RabbitMQConfigValidator; Extractor.ExtractorType).",
      "items": {
        "$ref": "#/definitions/rabbitMqExtractor"
      }
    }
  },
  "definitions": {
    "rabbitMqAssertion": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "STATUS_CODE",
            "RESPONSE_TIME",
            "BODY_CONTAINS",
            "BODY_JSON_PATH",
            "BODY_REGEX",
            "HEADER_EXISTS",
            "HEADER_VALUE",
            "BODY_SIZE",
            "NOT_NULL",
            "CUSTOM",
            "BODY_EQUALS",
            "BODY_XPATH",
            "METRIC_SCORE",
            "TOKEN_COUNT",
            "API_COST",
            "LLM_LATENCY",
            "JSON_SCHEMA",
            "NO_PII",
            "RESPONSE_BODY",
            "URL",
            "TITLE",
            "ELEMENT_TEXT",
            "ELEMENT_VALUE",
            "ELEMENT_VISIBLE",
            "ORIENTATION",
            "BODY"
          ]
        },
        "operator": {
          "type": "string"
        },
        "expected": {
          "description": "Expected value for the assertion"
        },
        "expression": {
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        }
      },
      "required": [
        "type",
        "operator"
      ]
    },
    "rabbitMqExtractor": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "JSON_PATH",
            "XPATH",
            "REGEX",
            "HEADER",
            "COOKIE",
            "RESPONSE_CODE",
            "RESPONSE_TIME"
          ]
        },
        "expression": {
          "type": "string"
        },
        "variable": {
          "type": "string"
        },
        "defaultValue": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "variable"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "JSON_PATH",
                  "XPATH",
                  "REGEX",
                  "HEADER",
                  "COOKIE"
                ]
              }
            }
          },
          "then": {
            "required": [
              "expression"
            ]
          }
        }
      ]
    }
  }
}
