{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.invalid/umi-compass/registry.schema.json",
  "title": "UMI COMPASS discovery registry",
  "type": "object",
  "required": [
    "schema_version",
    "updated_at",
    "service",
    "method",
    "intents",
    "collections",
    "entries"
  ],
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": "1.0"
    },
    "updated_at": {
      "type": "string",
      "format": "date"
    },
    "service": {
      "type": "object",
      "required": [
        "name",
        "role",
        "default_collection"
      ],
      "additionalProperties": false,
      "properties": {
        "name": {
          "const": "UMI COMPASS"
        },
        "role": {
          "const": "unofficial_experience_discovery_prototype"
        },
        "default_collection": {
          "$ref": "#/$defs/id"
        }
      }
    },
    "method": {
      "type": "object",
      "required": [
        "version",
        "reviewed_at",
        "weight_scale",
        "tie_break",
        "audit_rule"
      ],
      "additionalProperties": false,
      "properties": {
        "version": {
          "type": "string",
          "minLength": 1
        },
        "reviewed_at": {
          "type": "string",
          "format": "date"
        },
        "weight_scale": {
          "type": "object",
          "required": [
            "0",
            "1",
            "2",
            "3"
          ]
        },
        "tie_break": {
          "type": "string",
          "minLength": 1
        },
        "audit_rule": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "intents": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "short",
          "description"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "$ref": "#/$defs/id"
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "short": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "collections": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "name",
          "description"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "$ref": "#/$defs/id"
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "entries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/entry"
      }
    }
  },
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*$"
    },
    "relativePath": {
      "type": "string",
      "pattern": "^\\.\\.?/[a-zA-Z0-9._~!$&'()*+,;=:@%/-]+$"
    },
    "hex": {
      "type": "string",
      "pattern": "^#[0-9a-fA-F]{6}$"
    },
    "entry": {
      "type": "object",
      "required": [
        "id",
        "hotel_catalog_id",
        "collection",
        "order",
        "place",
        "title",
        "eyebrow",
        "lead",
        "href",
        "context",
        "visual",
        "reviewed_at",
        "evidence",
        "practical",
        "weights",
        "reasons"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "hotel_catalog_id": {
          "$ref": "#/$defs/id"
        },
        "collection": {
          "$ref": "#/$defs/id"
        },
        "order": {
          "type": "integer",
          "minimum": 1
        },
        "place": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "eyebrow": {
          "type": "string",
          "minLength": 1
        },
        "lead": {
          "type": "string",
          "minLength": 1
        },
        "href": {
          "$ref": "#/$defs/relativePath"
        },
        "context": {
          "$ref": "#/$defs/relativePath"
        },
        "island_guide": {
          "type": "object",
          "required": [
            "label",
            "href"
          ],
          "additionalProperties": false,
          "properties": {
            "label": {
              "type": "string",
              "minLength": 1
            },
            "href": {
              "$ref": "#/$defs/relativePath"
            }
          }
        },
        "visual": {
          "type": "object",
          "required": [
            "template",
            "colors"
          ],
          "additionalProperties": false,
          "properties": {
            "template": {
              "enum": [
                "settlement",
                "waterway",
                "coast"
              ]
            },
            "colors": {
              "type": "array",
              "minItems": 4,
              "maxItems": 4,
              "items": {
                "$ref": "#/$defs/hex"
              }
            }
          }
        },
        "reviewed_at": {
          "type": "string",
          "format": "date"
        },
        "evidence": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "id",
              "label",
              "claim",
              "source"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "$ref": "#/$defs/id"
              },
              "label": {
                "type": "string",
                "minLength": 1
              },
              "claim": {
                "type": "string",
                "minLength": 1
              },
              "source": {
                "type": "string",
                "format": "uri",
                "pattern": "^https://"
              }
            }
          }
        },
        "practical": {
          "type": "object",
          "required": [
            "access",
            "stay",
            "focus",
            "fit"
          ],
          "additionalProperties": false,
          "properties": {
            "access": {
              "$ref": "#/$defs/practicalItem"
            },
            "stay": {
              "$ref": "#/$defs/practicalItem"
            },
            "focus": {
              "$ref": "#/$defs/practicalItem"
            },
            "fit": {
              "$ref": "#/$defs/practicalItem"
            }
          }
        },
        "weights": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3
          }
        },
        "reasons": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "required": [
              "text",
              "evidence_ids"
            ],
            "additionalProperties": false,
            "properties": {
              "text": {
                "type": "string",
                "minLength": 1
              },
              "evidence_ids": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "$ref": "#/$defs/id"
                }
              }
            }
          }
        },
        "verification": {
          "type": "object",
          "required": [
            "status"
          ],
          "additionalProperties": false,
          "properties": {
            "status": {
              "enum": [
                "verified",
                "pending_source_verification"
              ]
            },
            "note": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      },
      "if": {
        "required": [
          "verification"
        ],
        "properties": {
          "verification": {
            "required": [
              "status"
            ],
            "properties": {
              "status": {
                "const": "pending_source_verification"
              }
            }
          }
        }
      },
      "then": {
        "properties": {
          "weights": {
            "additionalProperties": {
              "maximum": 2
            }
          }
        }
      }
    },
    "practicalItem": {
      "type": "object",
      "required": [
        "label",
        "text",
        "evidence_ids"
      ],
      "additionalProperties": false,
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "text": {
          "type": "string",
          "minLength": 1
        },
        "evidence_ids": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/id"
          }
        }
      }
    }
  }
}
