{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/dotsy-ai/json-schema/dotsy-ai-analyze-shared-section-result-schema.json",
  "title": "AnalyzeSharedSectionResult",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dotsy-ai-content-api-openapi.yml#/components/schemas/AnalyzeSharedSectionResult",
  "type": "object",
  "properties": {
    "sourceKey": {
      "type": "string"
    },
    "sourceEtag": {
      "type": "string",
      "description": "The page's content hash. Send it back as `ifMatch` to share."
    },
    "block": {
      "type": "object",
      "properties": {
        "exact": {
          "type": "string",
          "description": "Hash of the element's normalised HTML (text and classes kept). For `selectors`: the run's id (as in suggestions)."
        },
        "tag": {
          "type": "string",
          "description": "The element's tag; for `selectors`, the wrapper the section gets."
        },
        "text": {
          "type": "string",
          "description": "Its first 120 characters of text, for a label."
        },
        "bytes": {
          "type": "integer"
        }
      },
      "required": [
        "exact",
        "tag",
        "text",
        "bytes"
      ]
    },
    "proposedName": {
      "type": "string",
      "description": "A free section name made from its heading or text."
    },
    "matches": {
      "type": "object",
      "properties": {
        "pages": {
          "type": "integer",
          "description": "Distinct pages, counted in full."
        },
        "keys": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "key": {
                "type": "string"
              },
              "count": {
                "type": "integer",
                "description": "Copies on that page (all are replaced)."
              }
            },
            "required": [
              "key",
              "count"
            ]
          },
          "maxItems": 200,
          "description": "Pages with an exact copy, the source page first, at most 200. For `selectors`: pages with the same run."
        },
        "more": {
          "type": "boolean",
          "description": "True when there are more pages than `keys` lists."
        }
      },
      "required": [
        "pages",
        "keys",
        "more"
      ]
    },
    "similar": {
      "type": "object",
      "properties": {
        "pages": {
          "type": "integer",
          "description": "Distinct pages, counted in full."
        },
        "keys": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "key": {
                "type": "string"
              },
              "score": {
                "type": "number",
                "description": "0–1; higher is closer."
              }
            },
            "required": [
              "key",
              "score"
            ]
          },
          "maxItems": 200,
          "description": "Pages with the same structure but different words, closest first, at most 200. Not shared unless sent in `similar`. Always empty for `selectors` (a run is only shared where it repeats exactly)."
        },
        "more": {
          "type": "boolean",
          "description": "True when there are more pages than `keys` lists."
        }
      },
      "required": [
        "pages",
        "keys",
        "more"
      ]
    },
    "placement": {
      "type": "object",
      "properties": {
        "everyPageAllowed": {
          "type": "boolean"
        },
        "reason": {
          "$ref": "#/$defs/SharedSectionNotEligible"
        },
        "layout": {
          "type": [
            "string",
            "null"
          ]
        },
        "edge": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "top",
            "bottom"
          ],
          "description": "Where the layout slot goes, around the page content."
        },
        "layoutPages": {
          "type": "integer",
          "description": "Pages that use that layout."
        },
        "gaining": {
          "type": "object",
          "properties": {
            "pages": {
              "type": "integer",
              "description": "Distinct pages, counted in full."
            },
            "keys": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "maxItems": 200,
              "description": "Pages on the layout without a copy today. With `every_page` they show it too, unless you list them in `hide`."
            },
            "more": {
              "type": "boolean",
              "description": "True when there are more pages than `keys` lists."
            }
          },
          "required": [
            "pages",
            "keys",
            "more"
          ]
        }
      },
      "required": [
        "everyPageAllowed",
        "reason",
        "layout",
        "edge",
        "layoutPages",
        "gaining"
      ]
    },
    "indexWarming": {
      "type": "boolean",
      "description": "The index is still being built: counts may be low, and sharing is refused until it is done."
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "hint": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "hint"
        ]
      }
    }
  },
  "required": [
    "sourceKey",
    "sourceEtag",
    "block",
    "proposedName",
    "matches",
    "similar",
    "placement",
    "indexWarming",
    "warnings"
  ],
  "$defs": {
    "SharedSectionNotEligible": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "inside_section",
        "spans_template",
        "not_a_block",
        "too_large",
        "collection_page",
        "no_layout",
        "several_layouts",
        "not_at_edge",
        "layout_owned",
        "nested",
        "not_on_page",
        "page_config_invalid",
        "too_deep",
        "has_code"
      ],
      "description": "Why `every_page` is not offered."
    }
  }
}