{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://uiuxengine.com/schema/v2/registry-item.json",
  "title": "UI/UX Engine registry item, format 2",
  "description": "One installable item: its files with their content, and what a project and a registry need to know about it.",
  "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": "This schema. Optional: itemFormat identifies the format."
    },
    "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/file"
      },
      "description": "The files the CLI copies into the item's folder in the project's blocks folder. No two may share a path, compared without case."
    }
  },
  "$defs": {
    "file": {
      "type": "object",
      "required": [
        "path",
        "content"
      ],
      "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."
        },
        "content": {
          "type": "string",
          "description": "The file's text, as written to disk."
        }
      }
    }
  }
}
