{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://1zworks.com/catalog.schema.json",
  "title": "1zworks public catalog v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["$schema", "schemaVersion", "site", "works"],
  "properties": {
    "$schema": { "const": "https://1zworks.com/catalog.schema.json" },
    "schemaVersion": { "const": 1 },
    "site": {
      "type": "object", "additionalProperties": false,
      "required": ["name", "url", "creator"],
      "properties": { "name": { "type": "string" }, "url": { "$ref": "#/definitions/url" }, "creator": { "type": "string" } }
    },
    "works": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/work" } }
  },
  "definitions": {
    "url": { "type": "string", "pattern": "^https?://[^\\s]+$" },
    "hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "credit": {
      "type": "object", "additionalProperties": false, "required": ["name", "url"],
      "properties": { "name": { "type": "string" }, "url": { "$ref": "#/definitions/url" } }
    },
    "file": {
      "type": "object", "additionalProperties": false,
      "required": ["name", "url", "order", "sizeBytes", "sha256"],
      "properties": {
        "name": { "type": "string", "minLength": 1 }, "url": { "$ref": "#/definitions/url" },
        "order": { "type": "integer", "minimum": 1, "description": "One-based concatenation order." },
        "sizeBytes": { "type": "integer", "minimum": 1 }, "sha256": { "$ref": "#/definitions/hash" }
      }
    },
    "work": {
      "type": "object", "additionalProperties": false,
      "required": ["slug", "title", "url", "date", "durationSeconds", "category", "tags", "thumbnailUrl", "videoUrl", "projectFiles", "projectDownload", "credits", "license"],
      "properties": {
        "slug": { "type": "string", "pattern": "^[a-z0-9.-]+$" }, "title": { "type": "string", "minLength": 1 },
        "url": { "$ref": "#/definitions/url" }, "date": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
        "durationSeconds": { "type": "number", "exclusiveMinimum": 0 }, "category": { "type": "string" },
        "tags": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
        "thumbnailUrl": { "$ref": "#/definitions/url" }, "videoUrl": { "$ref": "#/definitions/url" },
        "projectFiles": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/file" } },
        "projectDownload": {
          "type": "object", "additionalProperties": false,
          "required": ["fileName", "assembly", "sizeBytes", "sha256"],
          "properties": {
            "fileName": { "type": "string", "minLength": 1 },
            "assembly": { "enum": ["single-file", "concatenate-in-order"], "description": "Concatenate the raw bytes of every projectFiles entry in ascending order. Do not unzip individual parts." },
            "sizeBytes": { "type": "integer", "minimum": 1 },
            "sha256": { "$ref": "#/definitions/hash", "description": "SHA-256 of the final assembled file, before opening or extracting it." }
          }
        },
        "credits": { "type": "object", "additionalProperties": { "type": "array", "items": { "$ref": "#/definitions/credit" } } },
        "license": {
          "type": "object", "additionalProperties": false, "required": ["name", "url", "scope"],
          "properties": { "name": { "type": "string" }, "url": { "$ref": "#/definitions/url" }, "scope": { "type": "string" } }
        }
      }
    }
  }
}
