{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://jsonpad.io/schema/sync-v1.json",
  "title": "JSONPad schema sync document",
  "description": "Lists and indexes to create or update with POST /sync-schema. Lists are matched by path name and indexes by path name within their list, so the document contains no ids. Fields left out are left as they are.",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "scope": {
      "description": "The scope this document manages, e.g. the name of the app the lists belong to. Lists the document declares are tagged with it, and a list managed by one scope can't be changed by a document with a different scope (or with no scope)",
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{1,50}$"
    },
    "lists": {
      "description": "Lists, keyed by path name",
      "type": "object",
      "patternProperties": {
        "^[A-Za-z0-9_-]+$": {
          "$ref": "#/definitions/list"
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "lists"
  ],
  "additionalProperties": false,
  "definitions": {
    "tags": {
      "description": "Tags for grouping related resources. Letters, numbers, hyphens and underscores; stored lowercase",
      "type": "array",
      "maxItems": 20,
      "items": {
        "type": "string",
        "pattern": "^[A-Za-z0-9_-]{1,50}$"
      }
    },
    "list": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string"
        },
        "tags": {
          "$ref": "#/definitions/tags"
        },
        "schema": {
          "description": "A JSON schema that new and updated items must match, or null for no schema",
          "type": [
            "object",
            "null"
          ]
        },
        "readonly": {
          "type": "boolean"
        },
        "realtime": {
          "type": "boolean"
        },
        "protected": {
          "type": "boolean"
        },
        "indexable": {
          "type": "boolean"
        },
        "generative": {
          "type": "boolean"
        },
        "generativePrompt": {
          "type": [
            "string",
            "null"
          ]
        },
        "indexes": {
          "description": "Indexes, keyed by path name. Indexes that aren't listed are left as they are",
          "type": "object",
          "patternProperties": {
            "^[A-Za-z0-9_-]+$": {
              "$ref": "#/definitions/index"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "index": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string"
        },
        "tags": {
          "$ref": "#/definitions/tags"
        },
        "pointer": {
          "description": "A JSON pointer to the value to index. Required when the index is created",
          "type": "string"
        },
        "valueType": {
          "type": "string",
          "enum": [
            "string",
            "number",
            "date"
          ]
        },
        "alias": {
          "type": "boolean"
        },
        "sorting": {
          "type": "boolean"
        },
        "filtering": {
          "type": "boolean"
        },
        "searching": {
          "type": "boolean"
        },
        "guard": {
          "type": "boolean"
        },
        "defaultOrderDirection": {
          "type": "string",
          "enum": [
            "asc",
            "desc"
          ]
        }
      },
      "additionalProperties": false
    }
  }
}
