{
  "title": "Lunedo template file",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "format": {
      "type": "string",
      "const": "lunedo-template",
      "description": "Always `lunedo-template`."
    },
    "formatVersion": {
      "type": "number",
      "const": 1,
      "description": "Version of this file format."
    },
    "schemaVersion": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991,
      "description": "Version of the editor format of the documents."
    },
    "lunedoVersion": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "Version of Lunedo that wrote the file."
    },
    "templates": {
      "minItems": 1,
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Name of the template."
          },
          "description": {
            "type": "string",
            "maxLength": 300,
            "description": "Short description."
          },
          "category": {
            "type": "string",
            "enum": [
              "meetings",
              "decisions",
              "projects",
              "engineering",
              "operations",
              "knowledge",
              "teams"
            ],
            "description": "Category in the gallery."
          },
          "language": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "en",
                  "de"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Language of the content, or null if unknown."
          },
          "titlePattern": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Title of new pages; `{key}` inserts the value of an input field."
          },
          "fields": {
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "pattern": "^[a-z][a-zA-Z0-9]{0,39}$",
                  "description": "Key of the field: a letter followed by letters and digits, at most 40 characters."
                },
                "label": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "description": "Label shown next to the input."
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "text",
                    "date",
                    "person",
                    "choice"
                  ],
                  "description": "Kind of input: text, date, person or choice."
                },
                "required": {
                  "type": "boolean",
                  "description": "Whether the input must be filled in."
                },
                "options": {
                  "description": "Options of a choice field; other fields have none.",
                  "maxItems": 30,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                }
              },
              "required": [
                "key",
                "label",
                "type",
                "required"
              ],
              "additionalProperties": false,
              "description": "An input field asked for when a page is created from the template."
            },
            "description": "Input fields asked for when a page is created."
          },
          "series": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "rhythm": {
                    "type": "object",
                    "properties": {
                      "frequency": {
                        "type": "string",
                        "enum": [
                          "none",
                          "daily",
                          "weekly",
                          "monthly",
                          "yearly"
                        ],
                        "description": "How often the meeting repeats."
                      },
                      "interval": {
                        "default": 1,
                        "description": "Every how many days, weeks, months or years.",
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 52
                      },
                      "weekdays": {
                        "description": "For `weekly`: the days of the week.",
                        "maxItems": 7,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "MO",
                            "TU",
                            "WE",
                            "TH",
                            "FR",
                            "SA",
                            "SU"
                          ]
                        }
                      },
                      "monthDay": {
                        "description": "For `monthly` by date: the day of the month.",
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 31
                      },
                      "weekOfMonth": {
                        "description": "For `monthly` by weekday: 1 to 4 for the first to fourth, -1 for the last.",
                        "type": "integer",
                        "minimum": -1,
                        "maximum": 4
                      },
                      "weekday": {
                        "description": "For `monthly` by weekday: the day of the week.",
                        "type": "string",
                        "enum": [
                          "MO",
                          "TU",
                          "WE",
                          "TH",
                          "FR",
                          "SA",
                          "SU"
                        ]
                      }
                    },
                    "required": [
                      "frequency"
                    ],
                    "additionalProperties": false,
                    "description": "Default rhythm."
                  },
                  "durationMinutes": {
                    "type": "integer",
                    "minimum": 5,
                    "maximum": 1440,
                    "description": "Default duration in minutes."
                  }
                },
                "required": [
                  "rhythm",
                  "durationMinutes"
                ],
                "additionalProperties": false,
                "description": "Defaults of a series template."
              },
              {
                "type": "null"
              }
            ],
            "description": "Defaults of a series template, or null."
          },
          "files": {
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string",
                  "pattern": "^files\\/([0-9a-f]{64})\\.(png|jpg|gif|webp|svg|excalidraw|drawio)$",
                  "description": "Path of the file in the archive: `files/<sha256>.<extension>`."
                },
                "mediaType": {
                  "type": "string",
                  "enum": [
                    "image/png",
                    "image/jpeg",
                    "image/gif",
                    "image/webp",
                    "image/svg+xml",
                    "application/vnd.excalidraw+json",
                    "application/vnd.jgraph.mxfile"
                  ],
                  "description": "Media type of the file."
                },
                "size": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 5242880,
                  "description": "Size in bytes."
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$",
                  "description": "SHA-256 hash of the content, lowercase hexadecimal."
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 255,
                  "pattern": "^[^/\\\\\\p{Cc}]+$",
                  "description": "File name shown when the template is used."
                }
              },
              "required": [
                "path",
                "mediaType",
                "size",
                "sha256",
                "name"
              ],
              "additionalProperties": false,
              "description": "A file the template uses."
            },
            "description": "Files the content uses."
          },
          "document": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "doc",
                "description": "Always `doc`."
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": {},
            "description": "Content in the editor format of the stated schema version."
          }
        },
        "required": [
          "name",
          "description",
          "category",
          "language",
          "titlePattern",
          "fields",
          "series",
          "files",
          "document"
        ],
        "additionalProperties": false,
        "description": "A template."
      },
      "description": "The templates of the file."
    }
  },
  "required": [
    "format",
    "formatVersion",
    "schemaVersion",
    "lunedoVersion",
    "templates"
  ],
  "additionalProperties": false,
  "description": "A Lunedo template file."
}
