{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://kubb.dev/schemas/registry-record.json",
  "title": "Kubb Registry Record",
  "description": "A reviewed entry in the Kubb extension registry, stored at extensions/<owner>/<slug>.json in kubb-labs/registry. Merging the record approves the pinned npm version.",
  "type": "object",
  "required": ["id", "artifact", "repository", "submittedAt", "submittedBy", "publishedAt", "reviewedAt"],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Reference to this schema for editor validation."
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*/[a-z0-9]+(?:-[a-z0-9]+)*$",
      "description": "'<owner>/<slug>': the GitHub owner of the source repository and the npm package name without its scope. Equals the record's path."
    },
    "artifact": {
      "type": "object",
      "required": ["kind", "package", "version"],
      "additionalProperties": false,
      "description": "The install pin.",
      "properties": {
        "kind": { "type": "string", "const": "npm" },
        "package": {
          "type": "string",
          "maxLength": 214,
          "pattern": "^(?:@[a-z0-9][a-z0-9._~-]*/)?[a-z0-9][a-z0-9._~-]*$",
          "description": "npm package name, e.g. '@kubb/plugin-zod'."
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$",
          "description": "Exact npm version, e.g. '5.4.4'."
        }
      }
    },
    "repository": {
      "type": "object",
      "required": ["url"],
      "additionalProperties": false,
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://github\\.com/[A-Za-z0-9-]+/[A-Za-z0-9._-]+(?:/.*)?$",
          "description": "Source repository on GitHub, optionally pointing at the package folder."
        }
      }
    },
    "submittedAt": { "$ref": "#/definitions/timestamp", "description": "When the record was submitted. Never changes." },
    "submittedBy": {
      "type": "string",
      "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$",
      "description": "GitHub username of the submitter."
    },
    "publishedAt": { "$ref": "#/definitions/timestamp", "description": "When the record was first listed. Never changes." },
    "reviewedAt": { "$ref": "#/definitions/timestamp", "description": "When the pinned version was last reviewed. A version bump moves it." },
    "categories": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
      "description": "Reviewer-owned categories from registry/categories.json. The first is the main one and overrides the manifest's category."
    },
    "listing": {
      "type": "object",
      "additionalProperties": false,
      "description": "Reviewer overrides applied over the manifest.",
      "properties": {
        "displayName": { "type": "string", "minLength": 1 },
        "description": { "type": "string", "minLength": 1 },
        "tags": { "type": "array", "items": { "type": "string" } },
        "icon": {
          "type": "object",
          "required": ["light"],
          "additionalProperties": false,
          "properties": {
            "light": { "type": "string", "format": "uri", "pattern": "^https://" },
            "dark": { "type": "string", "format": "uri", "pattern": "^https://" }
          }
        }
      }
    }
  },
  "definitions": {
    "timestamp": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$",
      "description": "UTC timestamp to the second, e.g. '2026-10-12T20:00:00Z'."
    }
  }
}
