{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://platform.absolutems.com/contracts/aroflo/operation-v1-draft.schema.json",
  "title": "AroFlo normalized operation request",
  "type": "object",
  "additionalProperties": false,
  "required": ["zone", "operation"],
  "properties": {
    "zone": {"type": "string", "pattern": "^[a-z][a-z0-9_]{1,63}$"},
    "operation": {"enum": ["list", "get", "search", "create", "update", "delete", "action"]},
    "record_id": {"type": "string", "minLength": 1, "maxLength": 128},
    "data": {"type": "object"},
    "filters": {
      "type": "array",
      "maxItems": 50,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["field", "operator", "value"],
        "properties": {
          "field": {"type": "string", "pattern": "^[a-z][a-z0-9_]{1,63}$"},
          "operator": {"enum": ["eq", "ne", "in", "contains", "gte", "lte", "between"]},
          "value": {}
        }
      }
    },
    "fields": {
      "type": "array",
      "uniqueItems": true,
      "maxItems": 100,
      "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]{1,63}$"}
    },
    "sort": {
      "type": "array",
      "maxItems": 5,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["field", "direction"],
        "properties": {
          "field": {"type": "string"},
          "direction": {"enum": ["asc", "desc"]}
        }
      }
    },
    "pagination": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "page": {"type": "integer", "minimum": 1, "default": 1},
        "page_size": {"type": "integer", "minimum": 1, "maximum": 100, "default": 50}
      }
    },
    "transport": {"enum": ["auto", "api", "bot"], "default": "auto"},
    "execution": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {"enum": ["sync", "async", "auto"], "default": "auto"},
        "idempotency_key": {"type": "string", "maxLength": 128},
        "confirmed": {"type": "boolean", "default": false}
      }
    }
  }
}

