{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/aura-historia-com/json-schema/aura-historia-com-party-location-data-schema.json",
  "title": "PartyLocationData",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/aura-historia-com-party-api-openapi.yml#/components/schemas/PartyLocationData",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "partyId",
    "label",
    "roles",
    "lifecycle",
    "revision",
    "inputRevision"
  ],
  "properties": {
    "id": {
      "$ref": "#/$defs/PartyLocationId"
    },
    "partyId": {
      "type": "string",
      "pattern": "^pty_"
    },
    "label": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "description": "Trimmed nonblank single-line label, at most 255 UTF-8 bytes. Never establishes site identity."
    },
    "roles": {
      "type": "array",
      "maxItems": 4,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "BUSINESS_PREMISES",
          "WAREHOUSE",
          "REGISTERED_ADDRESS",
          "CORRESPONDENCE"
        ]
      },
      "description": "Business use of a site. No assertion about listing stock, dispatch or pickup."
    },
    "geography": {
      "$ref": "#/$defs/PartyLocationGeography"
    },
    "position": {
      "$ref": "#/$defs/PartyLocationPosition"
    },
    "lifecycle": {
      "type": "string",
      "enum": [
        "ACTIVE",
        "RETIRED"
      ]
    },
    "revision": {
      "type": "integer",
      "format": "int64",
      "minimum": 1,
      "maximum": 9223372036854775807
    },
    "inputRevision": {
      "type": "integer",
      "format": "int64",
      "minimum": 1,
      "maximum": 9223372036854775807
    },
    "evidence": {
      "$ref": "#/$defs/PartyLocationEvidence"
    }
  },
  "$defs": {
    "PartyLocationEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "reference",
        "scope"
      ],
      "properties": {
        "reference": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048,
          "description": "Opaque nonblank single-line evidence/source reference; never fetched. At most 2048 UTF-8 bytes."
        },
        "observedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "scope": {
          "type": "string",
          "enum": [
            "SITE_DESCRIPTION",
            "REGISTERED_ADDRESS",
            "CORRESPONDENCE_ADDRESS"
          ],
          "description": "Declared assertion scope; never caller identity, authorization or trust."
        }
      }
    },
    "PartyLocationGeography": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "referenceRelease"
      ],
      "properties": {
        "referenceRelease": {
          "type": "string",
          "enum": [
            "iso-codes-4.20.1"
          ]
        },
        "addressText": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 4096,
          "description": "Verbatim free-text assertion; at most 4096 UTF-8 bytes. No geocoding or postal inference."
        },
        "country": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[A-Z]{2}$",
          "description": "Exact current ISO alpha-2 country in the named immutable release."
        },
        "subdivision": {
          "type": [
            "string",
            "null"
          ],
          "description": "Complete ISO 3166-2 code in the named release; must agree with country when supplied."
        },
        "postalCode": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 64,
          "description": "Single-line verbatim postal assertion, at most 64 UTF-8 bytes."
        }
      },
      "description": "Partial caller assertions. At least one geographic field must be present and nonblank. Coordinates are separate. No synchronous geocoding."
    },
    "PartyLocationId": {
      "type": "string",
      "pattern": "^ploc_[0-7][0-9a-hjkmnp-tv-z]{25}$",
      "description": "Strict UUIDv7 PartyLocation TypeID; bare UUIDs and foreign prefixes are rejected."
    },
    "PartyLocationPosition": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "latitudeDegrees",
        "longitudeDegrees",
        "precision"
      ],
      "properties": {
        "latitudeDegrees": {
          "type": "number",
          "minimum": -90,
          "maximum": 90
        },
        "longitudeDegrees": {
          "type": "number",
          "minimum": -180,
          "maximum": 180
        },
        "precision": {
          "type": "string",
          "enum": [
            "PREMISES",
            "STREET",
            "LOCALITY",
            "REPRESENTATIVE"
          ]
        },
        "accuracyMetres": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        }
      },
      "description": "Finite caller-asserted WGS84 coordinates with explicit precision. Not geocoder-derived evidence; (0,0) is valid."
    }
  }
}