{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://submuxhq.github.io/CodeDecay/schemas/product-generated-test-manifest.schema.json",
  "title": "CodeDecay Product Generated Test Manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "generatedAt",
    "target",
    "testSourcePath",
    "reviewRequired",
    "promoteByCopyingTo",
    "tests"
  ],
  "anyOf": [
    { "required": ["sourceFlowMapPath"] },
    { "required": ["sourceOpenApiSchemaPath"] },
    { "required": ["sourceApiEndpoints"] }
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "target": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "baseUrl"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "baseUrl": { "type": "string", "format": "uri" }
      }
    },
    "sourceFlowMapPath": {
      "type": "string",
      "minLength": 1
    },
    "sourceOpenApiSchemaPath": {
      "type": "string",
      "minLength": 1
    },
    "sourceApiEndpoints": {
      "type": "string",
      "minLength": 1
    },
    "testSourcePath": {
      "type": "string",
      "minLength": 1
    },
    "reviewRequired": {
      "const": true
    },
    "promoteByCopyingTo": {
      "type": "string",
      "minLength": 1
    },
    "tests": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title", "kind", "pageUrl", "priority"],
        "properties": {
          "id": { "type": "string", "minLength": 1 },
          "title": { "type": "string", "minLength": 1 },
          "kind": {
            "enum": ["route-load", "link-navigation", "input-state", "form-visibility", "api-operation"]
          },
          "pageUrl": { "type": "string", "format": "uri" },
          "selector": { "type": "string" },
          "targetUrl": { "type": "string", "format": "uri" },
          "method": {
            "enum": ["GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"]
          },
          "operationPath": { "type": "string", "minLength": 1 },
          "operationId": { "type": "string", "minLength": 1 },
          "expectedStatuses": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 100,
              "maximum": 599
            }
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "requestBody": true,
          "destructive": { "type": "boolean" },
          "priority": {
            "enum": ["high", "medium", "low"]
          }
        }
      }
    }
  }
}
