{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/certifyos/main/json-schema/certifyos-anchor-history-page-schema.json",
  "title": "AnchorHistoryPage",
  "description": "A page of anchor history entries, newest first.",
  "x-generated": "2026-10-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/certifyos-anchoroverride-api-openapi.yml#/components/schemas/AnchorHistoryPage",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AnchorHistoryEntry"
      },
      "description": "History entries, newest first."
    },
    "totalCount": {
      "type": "integer",
      "format": "int64",
      "description": "Total entries, when knowable across both stores."
    }
  },
  "$defs": {
    "AnchorHistoryEntry": {
      "type": "object",
      "description": "One audit event in a practitioner's anchor history.",
      "properties": {
        "id": {
          "type": "string",
          "description": "Event id."
        },
        "eventType": {
          "type": "string",
          "description": "Audit event type."
        },
        "entityType": {
          "type": "string",
          "description": "Entity the event is about."
        },
        "previousValue": {
          "$ref": "#/$defs/JsonNode",
          "type": "array",
          "description": "Value before the change; shape depends on eventType."
        },
        "newValue": {
          "$ref": "#/$defs/JsonNode",
          "type": "array",
          "description": "Value after the change; shape depends on eventType."
        },
        "reason": {
          "type": "string",
          "description": "Recorded reason, when the producer set one."
        },
        "triggeringEvent": {
          "type": "string",
          "description": "What triggered the change."
        },
        "metadata": {
          "$ref": "#/$defs/JsonNode",
          "type": "array",
          "description": "Producer context for the event; keys depend on eventType. For ANCHOR_REVIEW_REQUIRED: source, drift (computedDateMoved, eligibleSetMoved, triggeringTenantId) and repeat."
        },
        "actor": {
          "type": "string",
          "description": "Internal user id, or SYSTEM."
        },
        "actorName": {
          "type": "string",
          "description": "The actor's full name, resolved at read time. Null when the lookup found nothing or failed; the panel falls back to the id."
        },
        "occurredAt": {
          "$ref": "#/$defs/Instant",
          "type": "string",
          "description": "Commit time of the change."
        },
        "source": {
          "$ref": "#/$defs/Source",
          "type": "string",
          "description": "Which audit store the entry came from."
        }
      }
    },
    "Instant": {
      "type": "string",
      "format": "date-time"
    },
    "JsonNode": {
      "type": "object",
      "properties": {
        "empty": {
          "type": "boolean"
        },
        "valueNode": {
          "type": "boolean"
        },
        "containerNode": {
          "type": "boolean"
        },
        "missingNode": {
          "type": "boolean"
        },
        "array": {
          "type": "boolean"
        },
        "object": {
          "type": "boolean"
        },
        "nodeType": {
          "$ref": "#/$defs/JsonNodeType"
        },
        "pojo": {
          "type": "boolean"
        },
        "number": {
          "type": "boolean"
        },
        "integralNumber": {
          "type": "boolean"
        },
        "floatingPointNumber": {
          "type": "boolean"
        },
        "short": {
          "type": "boolean"
        },
        "int": {
          "type": "boolean"
        },
        "long": {
          "type": "boolean"
        },
        "float": {
          "type": "boolean"
        },
        "double": {
          "type": "boolean"
        },
        "bigDecimal": {
          "type": "boolean"
        },
        "bigInteger": {
          "type": "boolean"
        },
        "textual": {
          "type": "boolean"
        },
        "boolean": {
          "type": "boolean"
        },
        "null": {
          "type": "boolean"
        },
        "binary": {
          "type": "boolean"
        }
      }
    },
    "JsonNodeType": {
      "type": "string",
      "enum": [
        "ARRAY",
        "BINARY",
        "BOOLEAN",
        "MISSING",
        "NULL",
        "NUMBER",
        "OBJECT",
        "POJO",
        "STRING"
      ]
    },
    "Source": {
      "type": "string",
      "enum": [
        "NSCP",
        "DAL"
      ]
    }
  }
}