{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.anguskit.com/schema/angusmeter/plugins/angus-pop3.json",
  "title": "angus-pop3 step configuration",
  "description": "Configuration schema for the AngusMeter POP3 email retrieval plugin",
  "type": "object",
  "properties": {
    "host": {
      "type": "string",
      "description": "POP3 server hostname or IP address",
      "default": "localhost"
    },
    "port": {
      "type": "integer",
      "description": "POP3 server port (110 for POP3, 995 for POP3S)",
      "default": 110,
      "minimum": 1,
      "maximum": 65535
    },
    "username": {
      "type": "string",
      "description": "Authentication username"
    },
    "password": {
      "type": "string",
      "description": "Authentication password",
      "writeOnly": true
    },
    "action": {
      "type": "string",
      "description": "POP3 command to execute",
      "enum": [
        "USER",
        "PASS",
        "STAT",
        "LIST",
        "RETR",
        "DELE",
        "TOP",
        "UIDL",
        "NOOP",
        "RSET",
        "QUIT",
        "CAPA"
      ],
      "default": "LIST"
    },
    "messageNumber": {
      "type": "string",
      "description": "Message number for RETR, DELE, TOP, LIST (single), and UIDL (single). Must be a positive integer.",
      "pattern": "^[1-9]\\d*$"
    },
    "lineCount": {
      "type": "integer",
      "description": "Number of body lines to retrieve for TOP command",
      "default": 0,
      "minimum": 0
    },
    "useSsl": {
      "type": "boolean",
      "description": "Use POP3S (POP3 over SSL/TLS)",
      "default": false
    },
    "trustAll": {
      "type": "boolean",
      "description": "Trust all SSL certificates (for self-signed certs)",
      "default": false
    },
    "timeout": {
      "type": "integer",
      "description": "Socket read timeout in milliseconds",
      "default": 10000,
      "minimum": 1,
      "maximum": 300000
    },
    "connectTimeout": {
      "type": "integer",
      "description": "Socket connect timeout in milliseconds",
      "default": 5000,
      "minimum": 1,
      "maximum": 300000
    },
    "assertions": {
      "type": "array",
      "description": "Optional step-level assertions (see Pop3ConfigValidator; Assertion.AssertionType). Operator is required when assertions are present.",
      "items": {
        "$ref": "#/definitions/pop3Assertion"
      }
    },
    "extractors": {
      "type": "array",
      "description": "Optional extractors (see Pop3ConfigValidator; Extractor.ExtractorType).",
      "items": {
        "$ref": "#/definitions/pop3Extractor"
      }
    }
  },
  "definitions": {
    "pop3Assertion": {
      "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"
          ]
        },
        "operator": {
          "type": "string"
        },
        "expected": {
          "description": "Expected value for the assertion"
        },
        "expression": {
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        }
      },
      "required": [
        "type",
        "operator"
      ]
    },
    "pop3Extractor": {
      "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"
            ]
          }
        }
      ]
    }
  }
}
