{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "url": {
      "type": "string",
      "format": "uri"
    },
    "canonical_url": {
      "type": "string",
      "format": "uri"
    },
    "host": {
      "type": "string",
      "minLength": 1
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "description": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 500
        },
        {
          "type": "null"
        }
      ]
    },
    "site_name": {
      "type": ["string", "null"]
    },
    "author": {
      "type": ["string", "null"]
    },
    "published_at": {
      "type": ["string", "null"]
    },
    "reading_minutes": {
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "image_url": {
      "anyOf": [
        {
          "type": "string",
          "format": "uri"
        },
        {
          "type": "null"
        }
      ]
    },
    "favicon_url": {
      "anyOf": [
        {
          "type": "string",
          "format": "uri"
        },
        {
          "type": "null"
        }
      ]
    },
    "favicon_key": {
      "type": ["string", "null"]
    },
    "context": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 500
        },
        {
          "type": "null"
        }
      ]
    },
    "origin": {
      "type": "string",
      "enum": ["page", "shared_text", "caption", "transcript", "on_screen"]
    },
    "mention": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ]
    },
    "metadata": {
      "type": "string",
      "enum": ["read", "unavailable"]
    },
    "resolved_from": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "method": {
              "type": "string",
              "enum": ["domain_guess", "search"]
            },
            "identity": {
              "type": "string"
            },
            "topic": {
              "type": "string"
            },
            "meta": {
              "type": "object",
              "properties": {
                "created_at": {
                  "type": ["string", "null"]
                },
                "updated_at": {
                  "type": ["string", "null"]
                },
                "deleted_at": {
                  "type": ["string", "null"]
                },
                "legacy_ref": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "table": {
                          "type": "string"
                        },
                        "key": {
                          "type": ["string", "number"]
                        },
                        "row": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": ["table", "key", "row"],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "dataset": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          },
          "required": ["name", "method", "identity", "topic"],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "affiliate": {
      "type": "boolean"
    },
    "preview": {
      "type": "string",
      "enum": ["image", "favicon", "none"]
    },
    "meta": {
      "type": "object",
      "properties": {
        "created_at": {
          "type": ["string", "null"]
        },
        "updated_at": {
          "type": ["string", "null"]
        },
        "deleted_at": {
          "type": ["string", "null"]
        },
        "legacy_ref": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "table": {
                  "type": "string"
                },
                "key": {
                  "type": ["string", "number"]
                },
                "row": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": ["table", "key", "row"],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "dataset": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "url",
    "canonical_url",
    "host",
    "title",
    "description",
    "site_name",
    "author",
    "published_at",
    "reading_minutes",
    "image_url",
    "context",
    "origin",
    "metadata"
  ],
  "additionalProperties": false,
  "$id": "https://sendtopigeon.com/schemas/link@1.schema.json",
  "title": "Pigeon Open Data: link@1",
  "$comment": "Apache-2.0. Structural schema; use Zod/parseRecord for semantic invariants. This published schema URL is immutable.",
  "examples": [
    {
      "url": "https://example.invalid/item",
      "canonical_url": "https://example.invalid/item",
      "host": "demo",
      "title": "demo",
      "description": "demo",
      "site_name": null,
      "author": null,
      "published_at": null,
      "reading_minutes": 1,
      "image_url": "https://example.invalid/item",
      "context": "demo",
      "origin": "page",
      "metadata": "read"
    }
  ]
}
