{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://vocab.groundx.ag/agro/v1/schemas/product-efficacy-report.json",
  "title": "ProductEfficacyReport",
  "description": "Estructura JSON-LD de un informe agregado y anonimizado de eficacia de productos agro. Combina indicadores derivados (NDVI, senescencia, clorofila, biomasa) por par (producto, cultivo) sobre un periodo dado. Conforme al perfil sectorial agro/v1.",
  "type": "object",
  "required": ["@context", "@type", "dct:title", "dct:publisher", "agro:reportPeriod", "agro:measurements"],
  "properties": {
    "@context": {
      "description": "Como mínimo el contexto agro: https://vocab.groundx.ag/agro/v1/context.jsonld",
      "oneOf": [
        { "type": "string", "format": "uri" },
        { "type": "array", "items": {} }
      ]
    },
    "@id":   { "type": "string", "format": "uri" },
    "@type": {
      "description": "Recomendado: ['agro:ProductEfficacyReportDataset','dcat:Dataset'].",
      "oneOf": [
        { "type": "string" },
        { "type": "array", "items": { "type": "string" }, "minItems": 1 }
      ]
    },

    "dct:title":       { "type": "string", "minLength": 1 },
    "dct:description": { "type": "string" },
    "dct:publisher": {
      "type": "object",
      "required": ["@id"],
      "properties": { "@id": { "type": "string", "pattern": "^did:" } }
    },
    "dct:license": {
      "type": "object",
      "required": ["@id"],
      "properties": { "@id": { "type": "string", "format": "uri" } }
    },
    "dct:modified": { "type": "string", "format": "date" },
    "dct:conformsTo": {
      "type": "object",
      "properties": { "@id": { "type": "string", "format": "uri" } }
    },

    "agro:reportPeriod": {
      "type": "string",
      "description": "Intervalo ISO 8601 (ej. '2026-04-01/2026-06-30')."
    },
    "agro:samplesAggregated": { "type": "integer", "minimum": 0 },
    "agro:cooperativesContributing": { "type": "integer", "minimum": 0 },
    "agro:anonymizationMethod": { "type": "string" },
    "agro:methodology": { "type": "string" },

    "agro:measurements": {
      "type": "array",
      "minItems": 0,
      "items": { "$ref": "#/$defs/measurement" }
    }
  },
  "additionalProperties": true,
  "$defs": {
    "measurement": {
      "type": "object",
      "required": ["agro:appliedProduct", "agro:cropType", "agro:samplesAggregated"],
      "properties": {
        "@type": { "type": "string" },
        "agro:appliedProduct": {
          "type": "object",
          "required": ["@id"],
          "properties": { "@id": { "type": "string", "format": "uri" } }
        },
        "agro:cropType":         { "type": "string" },
        "agro:samplesAggregated":{ "type": "integer", "minimum": 1 },

        "agro:ndvi":        { "type": "number", "minimum": -1, "maximum": 1 },
        "agro:senescence":  { "type": "number", "minimum": 0, "maximum": 1 },
        "agro:chlorophyll": { "type": "number", "minimum": 0 },
        "agro:biomass":     { "type": "number", "minimum": 0 }
      },
      "additionalProperties": true
    }
  }
}
