{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:registry-snapshot:0.1",
  "title": "Snapshot Junexis Registry 0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "snapshotId", "artifacts"],
  "properties": {
    "schemaVersion": { "const": "junexis.registry-snapshot/0.1" },
    "snapshotId": { "$ref": "#/$defs/sha256" },
    "artifacts": {
      "type": "array",
      "maxItems": 10000,
      "items": {
        "oneOf": [
          { "$ref": "#/$defs/packageArtifact" },
          { "$ref": "#/$defs/providerArtifact" }
        ]
      }
    }
  },
  "$defs": {
    "packageArtifact": {
      "type": "object",
      "additionalProperties": false,
      "required": ["artifactType", "id", "version", "namespace", "artifactPath", "mediaType", "sizeBytes", "sha256", "manifestSha256", "dependencies", "compatibility", "source"],
      "properties": {
        "artifactType": { "const": "package" },
        "id": { "$ref": "#/$defs/artifactId" },
        "version": { "$ref": "#/$defs/semver" },
        "namespace": { "$ref": "#/$defs/moduleIdentity" },
        "artifactPath": { "$ref": "#/$defs/artifactPath" },
        "mediaType": { "$ref": "#/$defs/mediaType" },
        "sizeBytes": { "$ref": "#/$defs/artifactSize" },
        "sha256": { "$ref": "#/$defs/sha256" },
        "manifestSha256": { "$ref": "#/$defs/sha256" },
        "dependencies": {
          "type": "array",
          "maxItems": 1000,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/dependency" }
        },
        "compatibility": { "$ref": "#/$defs/packageCompatibility" },
        "source": { "type": "string", "maxLength": 512, "pattern": "^registry:[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*@[0-9A-Za-z.+-]+(?![\\s\\S])" }
      }
    },
    "providerArtifact": {
      "type": "object",
      "additionalProperties": false,
      "required": ["artifactType", "id", "version", "artifactPath", "mediaType", "sizeBytes", "sha256", "manifestSha256", "compatibility", "contract"],
      "properties": {
        "artifactType": { "const": "provider" },
        "id": { "$ref": "#/$defs/artifactId" },
        "version": { "$ref": "#/$defs/semver" },
        "artifactPath": { "$ref": "#/$defs/artifactPath" },
        "mediaType": { "$ref": "#/$defs/mediaType" },
        "sizeBytes": { "$ref": "#/$defs/artifactSize" },
        "sha256": { "$ref": "#/$defs/sha256" },
        "manifestSha256": { "$ref": "#/$defs/sha256" },
        "compatibility": { "$ref": "#/$defs/providerCompatibility" },
        "contract": { "$ref": "#/$defs/contractId" }
      }
    },
    "dependency": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "version"],
      "properties": {
        "id": { "$ref": "#/$defs/artifactId" },
        "version": { "$ref": "#/$defs/semver" }
      }
    },
    "packageCompatibility": {
      "type": "object",
      "additionalProperties": false,
      "required": ["language", "languageTargets"],
      "properties": {
        "language": {
          "type": "object",
          "additionalProperties": false,
          "required": ["minimum", "maximumExclusive"],
          "properties": {
            "minimum": { "$ref": "#/$defs/semver" },
            "maximumExclusive": { "$ref": "#/$defs/semver" }
          }
        },
        "languageTargets": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "enum": ["embedded", "server", "report"] }
        }
      }
    },
    "providerCompatibility": {
      "type": "object",
      "additionalProperties": false,
      "required": ["platformRid", "supportedPlatformRids", "sdkVersion", "abiVersion", "targetFramework", "platformVersion", "compatibilitySet"],
      "properties": {
        "platformRid": { "$ref": "#/$defs/rid" },
        "supportedPlatformRids": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/rid" }
        },
        "sdkVersion": { "$ref": "#/$defs/semver" },
        "abiVersion": { "$ref": "#/$defs/contractId" },
        "targetFramework": { "type": "string", "pattern": "^[a-z][a-z0-9]*(?:\\.[0-9]+)?(?![\\s\\S])" },
        "platformVersion": { "$ref": "#/$defs/semver" },
        "compatibilitySet": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{2,63}(?![\\s\\S])" }
      }
    },
    "artifactId": { "type": "string", "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*(?![\\s\\S])" },
    "moduleIdentity": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*(?![\\s\\S])" },
    "artifactPath": {
      "type": "string",
      "maxLength": 1024,
      "pattern": "^(?!.*(?:^|/)\\.{1,2}(?:/|$))[A-Za-z0-9_-](?:[A-Za-z0-9._-]*[A-Za-z0-9_-])?(?:/[A-Za-z0-9_-](?:[A-Za-z0-9._-]*[A-Za-z0-9_-])?)*(?![\\s\\S])",
      "not": { "$ref": "#/$defs/windowsDevicePath" }
    },
    "windowsDevicePath": {
      "type": "string",
      "pattern": "(?:^|/)(?:[Cc][Oo][Nn]|[Pp][Rr][Nn]|[Aa][Uu][Xx]|[Nn][Uu][Ll]|[Cc][Oo][Mm][1-9]|[Ll][Pp][Tt][1-9])(?:\\.|/|(?![\\s\\S]))"
    },
    "mediaType": { "type": "string", "maxLength": 127, "pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*/[a-z0-9][a-z0-9!#$&^_.+-]*(?![\\s\\S])" },
    "artifactSize": { "type": "integer", "minimum": 1, "maximum": 1073741824 },
    "rid": { "type": "string", "pattern": "^[a-z0-9]+-[a-z0-9]+(?![\\s\\S])" },
    "contractId": { "type": "string", "pattern": "^[a-z][a-z0-9.-]*/[0-9]+\\.[0-9]+(?![\\s\\S])" },
    "semver": {
      "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-]+)*))?(?![\\s\\S])"
    },
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}(?![\\s\\S])" }
  }
}