{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/bithot-news/json-schema/bithot-news-selected-changes-schema.json",
  "title": "SelectedChanges",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/bithot-news-openapi.json#/components/schemas/SelectedChanges",
  "type": "object",
  "required": [
    "schemaVersion",
    "fields",
    "cursor",
    "count",
    "hasMore",
    "changes"
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "fields": {
      "type": "string",
      "enum": [
        "default",
        "minimal"
      ]
    },
    "cursor": {
      "type": "string"
    },
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "hasMore": {
      "type": "boolean"
    },
    "changes": {
      "type": "array"
    }
  },
  "oneOf": [
    {
      "properties": {
        "fields": {
          "const": "default"
        },
        "changes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/SelectedUpsert"
              },
              {
                "$ref": "#/$defs/SelectedRemove"
              }
            ]
          }
        }
      }
    },
    {
      "properties": {
        "fields": {
          "const": "minimal"
        },
        "changes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/SelectedUpsertMinimal"
              },
              {
                "$ref": "#/$defs/SelectedRemove"
              }
            ]
          }
        }
      }
    }
  ],
  "$defs": {
    "Attribution": {
      "type": "object",
      "description": "Machine-readable BITHOT provenance for traceability. Retain it where technically feasible. Attribution alone is not authorization; see the public terms.",
      "required": [
        "name",
        "url"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "Item": {
      "type": "object",
      "required": [
        "id",
        "title",
        "originalTitle",
        "summary",
        "source",
        "links",
        "publishedAt",
        "discoveredAt",
        "category",
        "score",
        "selected"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "originalTitle": {
          "type": [
            "string",
            "null"
          ]
        },
        "summary": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "type": "object",
          "required": [
            "name"
          ],
          "properties": {
            "name": {
              "type": "string"
            }
          }
        },
        "links": {
          "type": "object",
          "required": [
            "aihot",
            "original"
          ],
          "properties": {
            "aihot": {
              "type": "string",
              "format": "uri"
            },
            "original": {
              "type": "string",
              "format": "uri"
            }
          }
        },
        "publishedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "discoveredAt": {
          "type": "string",
          "format": "date-time"
        },
        "category": {
          "type": [
            "string",
            "null"
          ],
          "description": "Current values: projects, memecoins, products, markets, investment, industry, security, tip, opinion. Clients must tolerate future string values."
        },
        "score": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0,
          "maximum": 100
        },
        "selected": {
          "type": "boolean"
        },
        "reason": {
          "type": [
            "string",
            "null"
          ],
          "description": "Reader-facing recommendation reason, the same text shown as 推荐理由 on the website. Always present on /api/v1/items; null when the item is not selected or has no reader-facing reason. Selected snapshot and changes do not include this field yet."
        },
        "attribution": {
          "$ref": "#/$defs/Attribution"
        }
      }
    },
    "ItemMinimal": {
      "type": "object",
      "required": [
        "id",
        "title",
        "source",
        "links",
        "publishedAt",
        "discoveredAt",
        "category",
        "score",
        "selected"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "source": {
          "type": "object",
          "required": [
            "name"
          ],
          "properties": {
            "name": {
              "type": "string"
            }
          }
        },
        "links": {
          "type": "object",
          "required": [
            "aihot"
          ],
          "properties": {
            "aihot": {
              "type": "string",
              "format": "uri"
            }
          }
        },
        "publishedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "discoveredAt": {
          "type": "string",
          "format": "date-time"
        },
        "category": {
          "type": [
            "string",
            "null"
          ],
          "description": "Current values: projects, memecoins, products, markets, investment, industry, security, tip, opinion. Clients must tolerate future string values."
        },
        "score": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0,
          "maximum": 100
        },
        "selected": {
          "type": "boolean"
        }
      }
    },
    "SelectedRemove": {
      "type": "object",
      "required": [
        "op",
        "changedAt",
        "id"
      ],
      "properties": {
        "op": {
          "const": "remove"
        },
        "changedAt": {
          "type": "string",
          "format": "date-time"
        },
        "id": {
          "type": "string"
        }
      }
    },
    "SelectedUpsert": {
      "type": "object",
      "required": [
        "op",
        "changedAt",
        "item"
      ],
      "properties": {
        "op": {
          "const": "upsert"
        },
        "changedAt": {
          "type": "string",
          "format": "date-time"
        },
        "item": {
          "$ref": "#/$defs/Item"
        }
      }
    },
    "SelectedUpsertMinimal": {
      "type": "object",
      "required": [
        "op",
        "changedAt",
        "item"
      ],
      "properties": {
        "op": {
          "const": "upsert"
        },
        "changedAt": {
          "type": "string",
          "format": "date-time"
        },
        "item": {
          "$ref": "#/$defs/ItemMinimal"
        }
      }
    }
  }
}