{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Patternfield Threads JSON Feed 1.1 extension",
  "type": "object",
  "properties": {
    "version": {
      "const": "https://jsonfeed.org/version/1.1"
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "home_page_url": {
      "type": "string",
      "format": "uri"
    },
    "feed_url": {
      "type": "string",
      "format": "uri"
    },
    "language": {
      "const": "en-AU"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "minItems": 1
    },
    "_patternfield": {
      "$ref": "#/$defs/patternfield"
    }
  },
  "required": [
    "version",
    "title",
    "home_page_url",
    "feed_url",
    "language",
    "items",
    "_patternfield"
  ],
  "additionalProperties": false,
  "$defs": {
    "date": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "value": {
              "type": "null"
            },
            "precision": {
              "const": "unknown"
            },
            "zone": {
              "type": "null"
            }
          },
          "required": [
            "value",
            "precision",
            "zone"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "value": {
              "type": "string",
              "format": "date"
            },
            "precision": {
              "const": "day"
            },
            "zone": {
              "enum": [
                "Pacific/Fiji",
                "Australia/Brisbane"
              ]
            }
          },
          "required": [
            "value",
            "precision",
            "zone"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "value": {
              "type": "string",
              "format": "date-time"
            },
            "precision": {
              "enum": [
                "minute",
                "second"
              ]
            },
            "zone": {
              "const": "Pacific/Fiji"
            }
          },
          "required": [
            "value",
            "precision",
            "zone"
          ],
          "additionalProperties": false
        }
      ]
    },
    "lifecycle": {
      "type": "object",
      "properties": {
        "state": {
          "enum": [
            "Following",
            "Dormant",
            "Concluded",
            "Archived"
          ]
        },
        "date": {
          "$ref": "#/$defs/date"
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "sourceIds": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "outcomeClaimId": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        }
      },
      "required": [
        "state",
        "date",
        "reason",
        "sourceIds"
      ],
      "additionalProperties": false
    },
    "citation": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "publisher": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "enum": [
            "secondary_reporting",
            "secondary_follow_up",
            "primary_context",
            "primary_proponent_context",
            "primary_decision",
            "editorial_archive"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "published": {
          "$ref": "#/$defs/date"
        },
        "verifiedAsOf": {
          "$ref": "#/$defs/date"
        },
        "scope": {
          "type": "string",
          "minLength": 1
        },
        "verification": {
          "enum": [
            "publisher_copy_checked",
            "live_anchor_and_archive_checked"
          ]
        }
      },
      "required": [
        "id",
        "publisher",
        "title",
        "type",
        "url",
        "published",
        "verifiedAsOf",
        "scope",
        "verification"
      ],
      "additionalProperties": false
    },
    "edition": {
      "type": "object",
      "properties": {
        "sourceId": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "issue": {
          "type": "string",
          "pattern": "^[0-9]{3}$"
        },
        "editionDate": {
          "type": "string",
          "format": "date"
        },
        "publishedBy": {
          "$ref": "#/$defs/date"
        },
        "firstPublic": {
          "$ref": "#/$defs/date"
        }
      },
      "required": [
        "sourceId",
        "issue",
        "editionDate",
        "publishedBy",
        "firstPublic"
      ],
      "additionalProperties": false
    },
    "claim": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "kind": {
          "enum": [
            "attributed_fact",
            "documented_fact"
          ]
        },
        "status": {
          "enum": [
            "attributed_reporting",
            "documented_context"
          ]
        },
        "confidence": {
          "enum": [
            "A",
            "B"
          ]
        },
        "verification": {
          "enum": [
            "attribution_verified",
            "documented"
          ]
        },
        "subjectStatus": {
          "enum": [
            "context",
            "reported_proposal",
            "reported_scope"
          ]
        },
        "attribution": {
          "type": "string",
          "minLength": 1
        },
        "text": {
          "type": "string",
          "minLength": 1
        },
        "evidenceRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "measurements": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              "role": {
                "enum": [
                  "reported_baseline",
                  "proposed"
                ]
              },
              "value": {
                "type": "number"
              },
              "unit": {
                "const": "metres"
              }
            },
            "required": [
              "id",
              "role",
              "value",
              "unit"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "id",
        "kind",
        "status",
        "confidence",
        "verification",
        "subjectStatus",
        "attribution",
        "text",
        "evidenceRefs"
      ],
      "additionalProperties": false
    },
    "uncertainty": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "text": {
          "type": "string",
          "minLength": 1
        },
        "kind": {
          "const": "uncertainty"
        },
        "status": {
          "const": "unresolved"
        },
        "evidenceRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "minItems": 0,
          "uniqueItems": true
        }
      },
      "required": [
        "id",
        "title",
        "text",
        "kind",
        "status",
        "evidenceRefs"
      ],
      "additionalProperties": false
    },
    "relationship": {
      "type": "object",
      "properties": {
        "fromEventId": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "toEventId": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "type": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "text": {
          "type": "string",
          "minLength": 1
        },
        "evidenceRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "minItems": 0,
          "uniqueItems": true
        }
      },
      "required": [
        "fromEventId",
        "toEventId",
        "type",
        "text",
        "evidenceRefs"
      ],
      "additionalProperties": false
    },
    "revision": {
      "type": "object",
      "properties": {
        "version": {
          "type": "integer",
          "minimum": 1
        },
        "supersedes": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "date": {
          "type": "string",
          "format": "date"
        },
        "kind": {
          "enum": [
            "baseline",
            "clarification",
            "correction"
          ]
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "evidenceRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "changes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/change"
          },
          "minItems": 0
        }
      },
      "required": [
        "version",
        "supersedes",
        "date",
        "kind",
        "title",
        "reason",
        "evidenceRefs",
        "changes"
      ],
      "additionalProperties": false
    },
    "change": {
      "type": "object",
      "properties": {
        "eventId": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "field": {
          "type": "string",
          "minLength": 1
        },
        "fromRevision": {
          "type": "integer",
          "minimum": 1
        },
        "toRevision": {
          "type": "integer",
          "minimum": 1
        },
        "before": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "after": {
          "type": "string",
          "minLength": 1
        },
        "evidenceRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "minItems": 0,
          "uniqueItems": true
        }
      },
      "required": [
        "eventId",
        "field",
        "fromRevision",
        "toRevision",
        "before",
        "after",
        "evidenceRefs"
      ],
      "additionalProperties": false
    },
    "item": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uri"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "content_text": {
          "type": "string",
          "minLength": 1
        },
        "_patternfield": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            },
            "revision": {
              "type": "integer",
              "minimum": 1
            },
            "dateBasis": {
              "enum": [
                "Event date",
                "Report date",
                "Coverage date"
              ]
            },
            "observed": {
              "$ref": "#/$defs/date"
            },
            "reported": {
              "$ref": "#/$defs/date"
            },
            "verifiedAsOf": {
              "$ref": "#/$defs/date"
            },
            "claims": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/claim"
              },
              "minItems": 1
            },
            "editionRefs": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              "minItems": 0,
              "uniqueItems": true
            },
            "contextRefs": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              "minItems": 0,
              "uniqueItems": true
            },
            "unresolvedRefs": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              "minItems": 0,
              "uniqueItems": true
            },
            "interpretation": {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "interpretation"
                },
                "text": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "kind",
                "text"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "id",
            "revision",
            "dateBasis",
            "observed",
            "reported",
            "verifiedAsOf",
            "claims",
            "editionRefs",
            "contextRefs",
            "unresolvedRefs",
            "interpretation"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "id",
        "url",
        "title",
        "content_text",
        "_patternfield"
      ],
      "additionalProperties": false
    },
    "patternfield": {
      "type": "object",
      "properties": {
        "about": {
          "type": "string",
          "format": "uri"
        },
        "schema": {
          "type": "string",
          "format": "uri"
        },
        "schemaVersion": {
          "const": 1
        },
        "publicationStatus": {
          "anyOf": [
            {
              "const": "owner_review"
            },
            {
              "const": "published"
            }
          ]
        },
        "thread": {
          "type": "object",
          "properties": {
            "subjectId": {
              "type": "string",
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            },
            "title": {
              "type": "string",
              "minLength": 1
            },
            "dateZone": {
              "const": "Pacific/Fiji"
            },
            "revision": {
              "type": "integer",
              "minimum": 1
            },
            "url": {
              "type": "string",
              "format": "uri"
            },
            "lifecycle": {
              "$ref": "#/$defs/lifecycle"
            },
            "lifecycleHistory": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/lifecycle"
              },
              "minItems": 1
            }
          },
          "required": [
            "subjectId",
            "title",
            "dateZone",
            "revision",
            "url",
            "lifecycle",
            "lifecycleHistory"
          ],
          "additionalProperties": false
        },
        "citations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/citation"
          },
          "minItems": 1
        },
        "editions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/edition"
          },
          "minItems": 1
        },
        "unresolved": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/uncertainty"
          },
          "minItems": 0
        },
        "relationships": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/relationship"
          },
          "minItems": 0
        },
        "history": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/revision"
          },
          "minItems": 1
        }
      },
      "required": [
        "about",
        "schema",
        "schemaVersion",
        "publicationStatus",
        "thread",
        "citations",
        "editions",
        "unresolved",
        "relationships",
        "history"
      ],
      "additionalProperties": false
    }
  }
}
