{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tsep-protocol.org/veille/observatoire-robots-ia/seals/schema.json",
  "title": "TSEP public aggregate daily seals \u2014 manifest and discovery index",
  "oneOf": [
    {
      "$ref": "#/$defs/manifest"
    },
    {
      "$ref": "#/$defs/index"
    }
  ],
  "$defs": {
    "manifest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "schema_version": {
          "const": "tsep-daily-seal-1.0.0"
        },
        "kind": {
          "enum": [
            "daily_closed",
            "daily_supplement",
            "checkpoint_partial"
          ]
        },
        "day": {
          "type": "string",
          "format": "date",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "period": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "start": {
              "type": "string",
              "format": "date-time"
            },
            "end": {
              "type": "string",
              "format": "date-time"
            },
            "basis": {
              "const": "publisher_receipt_utc"
            }
          },
          "required": [
            "start",
            "end",
            "basis"
          ]
        },
        "coverage_start_day": {
          "type": "string",
          "format": "date",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
        },
        "previous_seal": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "id": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "proof_sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "id",
                "proof_sha256"
              ]
            }
          ]
        },
        "supplements": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "uniqueItems": true
        },
        "final_events": {
          "const": false
        },
        "scope": {
          "type": "string"
        },
        "publication_dates_are": {
          "const": "publisher_receipt_times_not_exact_availability_or_independent_timestamps"
        },
        "publications": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/publication"
          }
        }
      },
      "required": [
        "schema_version",
        "kind",
        "day",
        "created_at",
        "period",
        "coverage_start_day",
        "previous_seal",
        "supplements",
        "final_events",
        "scope",
        "publication_dates_are",
        "publications"
      ]
    },
    "index": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "schema_version": {
          "const": "tsep-daily-seal-index-1.0.0"
        },
        "seals": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/record"
          }
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        },
        "pending": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/pending"
          }
        },
        "final_events": {
          "const": false
        }
      },
      "required": [
        "schema_version",
        "seals",
        "updated_at",
        "pending",
        "final_events"
      ]
    },
    "publication": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "publication_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "snapshot_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "snapshot_bytes": {
          "type": "integer",
          "minimum": 1
        },
        "snapshot_url": {
          "type": "string",
          "format": "uri"
        },
        "published_at": {
          "type": "string",
          "format": "date-time"
        },
        "generated_at": {
          "type": "string",
          "format": "date-time"
        },
        "last_import_at": {
          "type": "string",
          "format": "date-time"
        },
        "release_manifest_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "release_manifest_bytes": {
          "type": "integer",
          "minimum": 1
        },
        "release_manifest_url": {
          "type": "string",
          "format": "uri"
        },
        "publication_time_status": {
          "enum": [
            "recorded_after_activation",
            "recovered_after_interruption"
          ]
        },
        "recovered": {
          "type": "boolean"
        },
        "prepared_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "publication_sha256",
        "snapshot_sha256",
        "snapshot_bytes",
        "snapshot_url",
        "published_at",
        "generated_at",
        "last_import_at",
        "release_manifest_sha256",
        "release_manifest_bytes",
        "release_manifest_url",
        "publication_time_status",
        "recovered"
      ]
    },
    "record": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "day": {
          "type": "string",
          "format": "date",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
        },
        "kind": {
          "enum": [
            "daily_closed",
            "daily_supplement",
            "checkpoint_partial"
          ]
        },
        "signed_at": {
          "type": "string",
          "format": "date-time"
        },
        "manifest_url": {
          "type": "string",
          "format": "uri"
        },
        "proof_url": {
          "type": "string",
          "format": "uri"
        },
        "proof_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "files": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "manifest.json": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "request.tsq": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "response.tsr": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "authority.pem": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "chain.pem": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "verification.txt": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          "required": [
            "manifest.json",
            "request.tsq",
            "response.tsr",
            "authority.pem",
            "chain.pem",
            "verification.txt"
          ]
        }
      },
      "required": [
        "id",
        "day",
        "kind",
        "signed_at",
        "manifest_url",
        "proof_url",
        "proof_sha256",
        "files"
      ]
    },
    "pending": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "day": {
          "type": "string",
          "format": "date",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
        },
        "kind": {
          "enum": [
            "daily_closed",
            "daily_supplement",
            "checkpoint_partial"
          ]
        },
        "reason": {
          "type": "string",
          "maxLength": 100
        },
        "attempted_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "reason",
        "attempted_at"
      ]
    }
  }
}
