{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aslice.sh/schematics/json/package-record.schema.json",
  "title": "Exact package artifact",
  "description": "Normative structure; semantics and authorization: docs/STATE-AND-RECOVERY.md.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "repository": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$"
    },
    "name": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$"
    },
    "version": {
      "type": "string",
      "minLength": 1
    },
    "epoch": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "revision": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "build_id": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "artifact_id": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "manifest_size": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "blob_digest": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "blob_size": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "recipe_digest": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "recipe_size": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "origin": {
      "type": "string",
      "enum": [
        "slice",
        "local-build",
        "vendor-direct"
      ]
    },
    "variants": {
      "type": "object",
      "additionalProperties": {
        "type": "boolean"
      }
    },
    "user_flags": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "cpu_features": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9_]+$"
      },
      "uniqueItems": true
    },
    "requires_i386": {
      "type": "boolean"
    },
    "min_os": {
      "type": "string",
      "enum": [
        "10.11",
        "10.12",
        "10.13",
        "10.14",
        "10.15",
        "11",
        "12"
      ]
    },
    "max_os": {
      "type": "string",
      "enum": [
        "10.11",
        "10.12",
        "10.13",
        "10.14",
        "10.15",
        "11",
        "12"
      ]
    },
    "flavor": {
      "type": "string",
      "enum": [
        "v1",
        "v2",
        "v3"
      ]
    },
    "dependencies": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "repository": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]*$"
          },
          "name": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]*$"
          },
          "artifact_id": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$"
          }
        },
        "required": [
          "repository",
          "name",
          "artifact_id"
        ]
      }
    },
    "vendor": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "signer": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "url",
        "digest"
      ]
    }
  },
  "required": [
    "repository",
    "name",
    "version",
    "epoch",
    "revision",
    "build_id",
    "artifact_id",
    "manifest_size",
    "blob_digest",
    "blob_size",
    "recipe_digest",
    "recipe_size",
    "origin",
    "variants",
    "user_flags",
    "cpu_features",
    "requires_i386",
    "min_os",
    "dependencies"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "origin": {
            "const": "vendor-direct"
          }
        }
      },
      "then": {
        "required": [
          "vendor"
        ]
      }
    }
  ]
}
