{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://uiuxengine.com/schema/v2/registry.json",
  "title": "UI/UX Engine registry index, format 2",
  "description": "Every item of a registry, without file contents.",
  "type": "object",
  "required": [
    "name",
    "items"
  ],
  "properties": {
    "$schema": {
      "const": "https://uiuxengine.com/schema/v2/registry.json",
      "description": "This schema. Optional: each entry's itemFormat identifies the format."
    },
    "name": {
      "type": "string",
      "description": "The registry's name."
    },
    "homepage": {
      "type": "string",
      "description": "Where people learn about the registry."
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/entry"
      },
      "description": "Each item as in its own file, without $schema and file contents."
    }
  },
  "$defs": {
    "entry": {
      "type": "object",
      "required": [
        "itemFormat",
        "kind",
        "name",
        "id",
        "version",
        "title",
        "description",
        "engine",
        "license",
        "access",
        "hash",
        "dependencies",
        "requires",
        "icons",
        "definition",
        "files"
      ],
      "properties": {
        "$schema": {
          "const": "https://uiuxengine.com/schema/v2/registry-item.json",
          "description": "Entries usually leave it out."
        },
        "itemFormat": {
          "const": 2,
          "description": "The format of this file. It goes up when a reader of the previous format would misread the new one."
        },
        "kind": {
          "enum": [
            "block"
          ],
          "description": "What the item installs."
        },
        "name": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
          "description": "The item's folder name, kebab-case."
        },
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*(?:\\.[a-z][a-z0-9-]*)+$",
          "description": "The definition's full id: namespace.name."
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+$",
          "description": "The item's version, its contract's. It goes up when the content, and so the hash, changes."
        },
        "title": {
          "type": "string",
          "description": "A human-readable name."
        },
        "description": {
          "type": "string",
          "description": "What the item is for."
        },
        "engine": {
          "type": "string",
          "minLength": 1,
          "description": "The Engine versions the content was made and checked for: ^x.y.z, or comparators (>=, >, <=, <, =) separated by spaces. Declare only versions the item has been run with."
        },
        "license": {
          "type": "string",
          "minLength": 1,
          "description": "The license the files are under."
        },
        "access": {
          "enum": [
            "free",
            "pro"
          ],
          "description": "Who may download the item. Metadata for registries; not part of the hash."
        },
        "hash": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 of the installable content, as lowercase hex. See the registry format guide for what it covers."
        },
        "dependencies": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^(?:@[a-z0-9][a-z0-9._~-]*\\/)?[a-z0-9][a-z0-9._~-]*$"
          },
          "description": "npm packages the files import."
        },
        "requires": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "description": "Other items, by name, to install first."
        },
        "icons": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "description": "UI/UX Icons ids the design uses."
        },
        "definition": {
          "type": "object",
          "required": [
            "contract",
            "design"
          ],
          "properties": {
            "contract": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_][A-Za-z0-9._-]*(?:\\/[A-Za-z0-9_][A-Za-z0-9._-]*)*$",
              "maxLength": 200,
              "description": "The file, among files, that exports the contract."
            },
            "design": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_][A-Za-z0-9._-]*(?:\\/[A-Za-z0-9_][A-Za-z0-9._-]*)*$",
              "maxLength": 200,
              "description": "The file, among files, that exports the design."
            }
          },
          "description": "The files that export the item's definition."
        },
        "files": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/entryFile"
          },
          "description": "The item's files, without content."
        }
      }
    },
    "entryFile": {
      "type": "object",
      "required": [
        "path"
      ],
      "properties": {
        "path": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_][A-Za-z0-9._-]*(?:\\/[A-Za-z0-9_][A-Za-z0-9._-]*)*$",
          "maxLength": 200,
          "description": "Relative to the item's folder, with / separators."
        }
      }
    }
  }
}
