{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://overseer.studio/schemas/dataset/manifest.json",
  "title": "Overseer Dataset Manifest",
  "description": "Schema for a dataset manifest file inside an Overseer plugin package",
  "oneOf": [{ "$ref": "#/$defs/staticDataset" }, { "$ref": "#/$defs/dynamicDataset" }],
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[a-zA-Z0-9_-]+$",
      "description": "Dataset identifier, unique within the plugin. Restricted to letters, numbers, hyphens, and underscores because it is used to derive on-disk file paths."
    },
    "label": {
      "type": "string",
      "minLength": 1,
      "description": "Human-readable dataset name"
    },
    "description": {
      "type": "string",
      "description": "Short description of the dataset"
    },
    "version": {
      "type": "string",
      "minLength": 1,
      "description": "Dataset version"
    },
    "staticDataset": {
      "type": "object",
      "required": ["id", "label", "version", "source"],
      "additionalProperties": false,
      "properties": {
        "$schema": {
          "type": "string",
          "description": "Reference to this schema"
        },
        "id": { "$ref": "#/$defs/id" },
        "label": { "$ref": "#/$defs/label" },
        "description": { "$ref": "#/$defs/description" },
        "version": { "$ref": "#/$defs/version" },
        "idField": {
          "type": "string",
          "description": "Name of the field that uniquely identifies each record"
        },
        "schema": {
          "type": "object",
          "required": ["$ref"],
          "additionalProperties": false,
          "properties": {
            "$ref": { "type": "string", "description": "Relative path to a record schema file" }
          },
          "description": "Optional schema describing the shape of each record"
        },
        "source": {
          "type": "object",
          "required": ["local"],
          "additionalProperties": false,
          "properties": {
            "local": {
              "type": "object",
              "required": ["$ref"],
              "additionalProperties": false,
              "properties": {
                "$ref": {
                  "type": "string",
                  "description": "Relative path to the local JSON records file"
                }
              },
              "description": "Local records file shipped with the plugin"
            }
          },
          "description": "Static dataset source"
        }
      }
    },
    "dynamicDataset": {
      "type": "object",
      "required": ["id", "label", "version", "source"],
      "additionalProperties": false,
      "properties": {
        "$schema": {
          "type": "string",
          "description": "Reference to this schema"
        },
        "id": { "$ref": "#/$defs/id" },
        "label": { "$ref": "#/$defs/label" },
        "description": { "$ref": "#/$defs/description" },
        "version": { "$ref": "#/$defs/version" },
        "source": {
          "type": "object",
          "required": ["remote"],
          "additionalProperties": false,
          "properties": {
            "remote": {
              "type": "object",
              "additionalProperties": {
                "type": "string",
                "pattern": "^https://",
                "description": "HTTPS URL template; tokens like {id} are substituted at request time"
              },
              "description": "Map of action name to HTTPS URL template"
            }
          },
          "description": "Dynamic dataset source backed by remote HTTPS endpoints"
        }
      }
    }
  }
}
