{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://nook-ui.dev/schema/registry-item.json",
  "title": "Nook registry item",
  "description": "One installable item (component, theme, icon, block or lib). The same shape works for any registry, including private and paid ones: authentication is handled by the client when it fetches the file, never inside the item.",
  "type": "object",
  "additionalProperties": false,
  "required": ["name", "type", "description", "files"],
  "properties": {
    "$schema": { "type": "string" },
    "name": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", "maxLength": 80 },
    "type": {
      "enum": ["registry:ui", "registry:lib", "registry:icons", "registry:icon", "registry:base", "registry:theme", "registry:block", "registry:template"]
    },
    "title": { "type": "string" },
    "description": { "type": "string", "minLength": 1 },
    "dependencies": {
      "type": "array",
      "items": { "type": "string", "pattern": "^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*(@[A-Za-z0-9._^~*+-]+)?$" },
      "description": "npm packages, optionally with a version range, for example class-variance-authority@^0.7.1."
    },
    "registryDependencies": {
      "type": "array",
      "items": { "type": "string", "pattern": "^(@[a-z0-9-]+/)?[a-z0-9]+(-[a-z0-9]+)*$|^https?://" },
      "description": "Other items: a Nook name, a namespaced name such as @acme/card, or a direct URL."
    },
    "files": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["path", "type", "content"],
        "properties": {
          "path": { "type": "string", "minLength": 1, "pattern": "^(?!/)(?!.*\\.\\.)[^\\\\]+$" },
          "type": { "enum": ["registry:ui", "registry:block", "registry:template", "registry:lib", "registry:icons", "registry:icon", "registry:css", "registry:component", "registry:file"] },
          "target": { "type": "string", "pattern": "^(?!/)(?!.*\\.\\.)[^\\\\]+$", "description": "Optional path relative to the project root. Overrides alias based placement." },
          "content": { "type": "string" }
        }
      }
    },
    "cssVars": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "theme": { "$ref": "#/definitions/vars" },
        "light": { "$ref": "#/definitions/vars" },
        "dark": { "$ref": "#/definitions/vars" }
      },
      "description": "theme: shared variables (:root). light: extra light variables (:root). dark: variables for .dark."
    },
    "meta": { "type": "object" }
  },
  "definitions": {
    "vars": {
      "type": "object",
      "propertyNames": { "pattern": "^[a-z][a-z0-9-]*$" },
      "additionalProperties": { "type": "string" }
    }
  }
}
