{
  "$id": "https://raw.githubusercontent.com/netwerk-digitaal-erfgoed/ld-workbench/main/static/ld-workbench.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Configuration",
  "description": "JSON Schema for LDWorkbench.\nIt helps with the writing of the configuration needed to run LDWorkbench pipelines.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "name": {
      "type": "string",
      "description": "The name of your pipeline. It must be unique over all your configurations."
    },
    "description": {
      "type": "string",
      "description": "An optional description for your pipeline."
    },
    "baseDir": {
      "type": "string",
      "description": "An optional base directory for files referenced by `file://...` paths. This defaults to the directory that contains the YAML configuration file."
    },
    "destination": {
      "type": "string",
      "description": "The file where the final result of your pipeline is saved."
    },
    "stages": {
      "type": "array",
      "description": "A pipeline stage consists of an iterator and one or more generators.",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the stage. It must be unique within the pipeline."
          },
          "iterator": {
            "type": "object",
            "additionalProperties": false,
            "required": ["query"],
            "properties": {
              "query": {
                "type": "string",
                "description": "SPARQL SELECT query that returns a `$this` binding for each URI that will be passed to the generator(s). Either an inline string (`SELECT $this WHERE {...}`) or a reference to a file (`file://...`) that contains the query."
              },
              "endpoint": {
                "type": "string",
                "description": "SPARQL endpoint for the iterator. If it starts with `file://`, a local RDF file is queried. If omitted the result of the previous stage is used."
              },
              "importTo": {
                "type": "string",
                "description": "Optional name of the store this endpoint should be imported into before querying. If omitted, the endpoint is queried directly."
              },
              "batchSize": {
                "type": "number",
                "minimum": 1,
                "description": "Number of `$this` bindings retrieved per query. Defaults to the LIMIT value of your iterator query or 10 if no LIMIT is present."
              },
              "delay": {
                "type": "string",
                "description": "Human-readable time delay for requests to the the iterator’s SPARQL endpoint (e.g. `5ms`, `100 milliseconds`, `1s`)."
              }
            }
          },
          "generator": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["query"],
              "properties": {
                "query": {
                  "type": "string",
                  "description": "SPARQL CONSTRUCT query that takes a `$this` binding from the iterator and generates triples for it. Either an inline string (`CONSTRUCT $this schema:name ?name WHERE {$this ...}`) or a reference to a file (`file://...`) that contains the query."
                },
                "endpoint": {
                  "type": "string",
                  "description": "The SPARQL endpoint for the generator. If it starts with `file://`, a local RDF file is queried. If omitted, the endpoint of the iterator is used."
                },
                "batchSize": {
                  "type": "number",
                  "minimum": 1,
                  "description": "Overrule the generator's behaviour of fetching results for 10 bindings of `$this` per request.",
                  "default": 10
                }
              }
          }
        },
          "destination": {
            "type": "string",
            "description": "The optional path where the results are saved. If omitted, a temporary file will be created."
          }
        },
        "required": ["name", "iterator", "generator"]
      }
    },
    "stores": {
      "type": "array",
      "description": "A list of SPARQL 1.1 Graph Stores that can be used in the pipeline.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "queryUrl": {
            "type": "string",
            "description": "The store’s query URL."
          },
          "storeUrl": {
            "type": "string",
            "description": "The store’s Graph Store HTTP Protocol URL."
          },
          "updateUrl": {
            "type": "string",
            "description": "The store’s SPARQL Update URL."
          }
        },
        "required": ["queryUrl"]
      }
    }
  },
  "required": ["name", "stages"]
}
