{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:pop:schema:blueprint-package:0.1",
  "title": "POP Data-only Blueprint Package 0.1",
  "description": "Portable metadata for a package containing declarative Blueprint artifacts and no executable entry point.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "package", "compatibility", "blueprints", "files"],
  "properties": {
    "schema": { "const": "pop.blueprint-package/0.1" },
    "package": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "namespace", "version", "license"],
      "properties": {
        "name": { "$ref": "#/$defs/namespacedId" },
        "namespace": { "$ref": "#/$defs/namespacedId" },
        "version": { "$ref": "#/$defs/semanticVersion" },
        "license": { "$ref": "#/$defs/nonBlankString" }
      }
    },
    "compatibility": {
      "type": "object",
      "additionalProperties": false,
      "required": ["pop"],
      "properties": {
        "pop": { "$ref": "#/$defs/versionRange" },
        "implementations": {
          "type": "object",
          "propertyNames": { "$ref": "#/$defs/namespacedId" },
          "additionalProperties": { "$ref": "#/$defs/versionRange" }
        }
      }
    },
    "blueprints": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "version", "path"],
        "properties": {
          "id": { "$ref": "#/$defs/namespacedId" },
          "version": { "$ref": "#/$defs/semanticVersion" },
          "path": { "$ref": "#/$defs/relativePath" }
        }
      }
    },
    "files": {
      "type": "object",
      "minProperties": 1,
      "propertyNames": { "$ref": "#/$defs/relativePath" },
      "additionalProperties": { "$ref": "#/$defs/integrity" }
    },
    "dependencies": {
      "type": "object",
      "propertyNames": { "$ref": "#/$defs/namespacedId" },
      "additionalProperties": { "$ref": "#/$defs/versionRange" }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "source": { "$ref": "#/$defs/nonBlankString" },
        "revision": { "$ref": "#/$defs/nonBlankString" }
      }
    },
    "signature": {
      "type": "object",
      "additionalProperties": false,
      "required": ["algorithm", "key_id", "value"],
      "properties": {
        "algorithm": { "const": "Ed25519" },
        "key_id": { "$ref": "#/$defs/nonBlankString" },
        "value": { "type": "string", "pattern": "^[A-Za-z0-9+/]+={0,2}$" }
      }
    },
    "extensions": {
      "type": "object",
      "propertyNames": { "$ref": "#/$defs/namespacedId" }
    }
  },
  "$defs": {
    "nonBlankString": { "type": "string", "minLength": 1, "pattern": "\\S" },
    "namespacedId": {
      "type": "string",
      "maxLength": 160,
      "pattern": "^(?!pop\\.)(?:[a-z0-9]+(?:[._-][a-z0-9]+)+)$"
    },
    "semanticVersion": {
      "type": "string",
      "pattern": "^(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)(?:-(?:(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$"
    },
    "versionRange": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "pattern": "^[0-9A-Za-z*^~<>=| .+-]+$"
    },
    "relativePath": {
      "type": "string",
      "maxLength": 1024,
      "pattern": "^(?![\\\\/])(?!.*(?:^|[\\\\/])\\.\\.(?:[\\\\/]|$))(?!.+:)[^\\u0000]+$"
    },
    "integrity": {
      "type": "string",
      "pattern": "^sha256-[A-Za-z0-9+/]{43}=$"
    }
  }
}
