{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/verifiedhandles-org/json-schema/verifiedhandles-org-edit-context-schema.json",
  "title": "EditContext",
  "description": "What an edit of the entry starts from.",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/verifiedhandles-org-openapi.json#/components/schemas/EditContext",
  "type": "object",
  "properties": {
    "vhid": {
      "type": "string"
    },
    "key": {
      "type": "string",
      "description": "Its address: the short, else the VHID."
    },
    "signed_in": {
      "type": "boolean",
      "description": "A bearer was sent. Signed out, the rights are all false and there is no draft."
    },
    "base_revision_id": {
      "description": "Send it back with a change: a later save is a 409 `conflict`.",
      "type": [
        "string",
        "null"
      ]
    },
    "fields": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "subtitle": {
          "type": [
            "string",
            "null"
          ]
        },
        "description": {
          "description": "As stored: sanitized HTML.",
          "type": [
            "string",
            "null"
          ]
        },
        "short": {
          "type": [
            "string",
            "null"
          ]
        },
        "image_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "custom_handle_order": {
          "type": "boolean"
        },
        "gallery": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The gallery’s media ids after the lead, in order. A change sends the whole list after the edit as `changes.gallery` (add, remove, reorder; to promote one, send it as `image_id` and leave it out of `gallery`)."
        }
      },
      "required": [
        "title",
        "subtitle",
        "description",
        "short",
        "image_id",
        "custom_handle_order",
        "gallery"
      ],
      "additionalProperties": false
    },
    "image": {
      "anyOf": [
        {
          "$ref": "#/$defs/EditImage"
        },
        {
          "type": "null"
        }
      ],
      "description": "The lead image, or null when there is none (or its row is gone)."
    },
    "gallery": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/EditImage"
      },
      "description": "Those images as the website editor shows them."
    },
    "gallery_logo": {
      "description": "The gallery image Wikidata’s sync keeps (the item’s logo), or null. Taking it off keeps the sync from putting it back (`provenance.gallery_logo`).",
      "type": [
        "string",
        "null"
      ]
    },
    "gallery_max": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991,
      "description": "At most this many after the lead (`too_many_images` past it)."
    },
    "handles": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "platform_id": {
            "type": "string"
          },
          "value": {
            "description": "Null for an email address the caller may not see (doc 02 §3.5).",
            "type": [
              "string",
              "null"
            ]
          },
          "display": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "owner": {
            "type": "string",
            "enum": [
              "wikidata",
              "site"
            ],
            "description": "Who keeps it: the Wikidata sync, or people."
          },
          "masked": {
            "type": "boolean",
            "description": "An email address the caller may not see: name it by `ref` to keep or remove it."
          },
          "ref": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "platform_id",
          "value",
          "display",
          "name",
          "owner",
          "masked",
          "ref"
        ],
        "additionalProperties": false
      }
    },
    "link_names": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "string"
      },
      "description": "VHID → current title for each entry the description links to (a deleted one left out): a cross-link’s name."
    },
    "description_markdown": {
      "description": "The description as Markdown (a cross-link `[Name](/VHID)`), as the website editor’s Markdown mode shows it. Null with no description.",
      "type": [
        "string",
        "null"
      ]
    },
    "markdown_round_trips": {
      "type": "boolean",
      "description": "Whether the description comes back from Markdown unchanged: false when Markdown cannot say something in it (a table’s spans, a figure’s layout)."
    },
    "description_source": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "title": {
              "type": "string"
            },
            "url": {
              "type": "string"
            },
            "adapted": {
              "type": "boolean"
            }
          },
          "required": [
            "title",
            "url",
            "adapted"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "The “from Wikipedia” credit under the description, or null."
    },
    "provenance": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "string",
        "enum": [
          "wikidata",
          "manual",
          "submission",
          "import"
        ]
      },
      "description": "Each sync-eligible field’s source (`title`, `subtitle`, `description`, `image`, `entity_type`, `gallery_logo`): `wikidata` while the sync manages it."
    },
    "sync_locked": {
      "type": "boolean",
      "description": "The entry is protected or claimed: Wikidata never manages it, whatever `provenance` says."
    },
    "held_back": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "platform_id": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "removed_at": {
            "type": "string"
          },
          "revision_id": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "platform_id",
          "value",
          "name",
          "removed_at",
          "revision_id"
        ],
        "additionalProperties": false
      },
      "description": "Values a person took off that Wikidata still lists, held back from every sync (an email address left out for someone who may not edit live)."
    },
    "qid": {
      "type": [
        "string",
        "null"
      ]
    },
    "rights": {
      "type": "object",
      "properties": {
        "can_edit_live": {
          "type": "boolean",
          "description": "A change is saved at once."
        },
        "can_propose": {
          "type": "boolean",
          "description": "A change is queued for review."
        },
        "can_claim": {
          "type": "boolean",
          "description": "The account may claim the entry (it is not theirs already)."
        },
        "propose_policy": {
          "type": "string"
        },
        "edit_policy": {
          "type": "string"
        },
        "account_blocked": {
          "type": "boolean"
        },
        "sign_in_could_help": {
          "type": "boolean",
          "description": "Any signed-in account may propose to it (`propose_policy` `registered`): what to tell someone signed out before they type."
        }
      },
      "required": [
        "can_edit_live",
        "can_propose",
        "can_claim",
        "propose_policy",
        "edit_policy",
        "account_blocked",
        "sign_in_could_help"
      ],
      "additionalProperties": false
    },
    "draft": {
      "anyOf": [
        {
          "$ref": "#/$defs/AppDraft"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "vhid",
    "key",
    "signed_in",
    "base_revision_id",
    "fields",
    "image",
    "gallery",
    "gallery_logo",
    "gallery_max",
    "handles",
    "link_names",
    "description_markdown",
    "markdown_round_trips",
    "description_source",
    "provenance",
    "sync_locked",
    "held_back",
    "qid",
    "rights",
    "draft"
  ],
  "additionalProperties": false,
  "$defs": {
    "AppDraft": {
      "type": "object",
      "properties": {
        "vhid": {
          "type": "string"
        },
        "base_revision_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "saved_at": {
          "type": "string"
        },
        "expires_at": {
          "type": "string",
          "description": "30 days after the last change."
        },
        "draft": {
          "type": "object",
          "properties": {
            "fields": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              },
              "description": "`title`, `subtitle`, `description` (HTML), `short`, as typed."
            },
            "handles": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "platform_id": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string"
                  }
                },
                "required": [
                  "platform_id",
                  "value"
                ],
                "additionalProperties": {}
              }
            },
            "relinquish": {
              "description": "Fields to hand to the Wikidata sync on save.",
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "takeover": {
              "description": "Fields to take back from the Wikidata sync on save.",
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "dropCredit": {
              "description": "Take the “from Wikipedia” credit off on save.",
              "type": "boolean",
              "const": true
            },
            "creditPage": {
              "description": "The Wikipedia page to credit the description to on save.",
              "type": "string"
            },
            "creditManage": {
              "description": "With `creditPage` (a draft): keep the description site-authored.",
              "type": "boolean",
              "const": false
            }
          },
          "required": [
            "fields"
          ],
          "additionalProperties": false
        },
        "web_only": {
          "type": "boolean",
          "description": "The website’s editor kept more (an image, a gallery, a handle’s ownership, its own handle order): an app’s save replaces it all."
        }
      },
      "required": [
        "vhid",
        "base_revision_id",
        "saved_at",
        "expires_at",
        "draft",
        "web_only"
      ],
      "additionalProperties": false,
      "description": "The person’s unsent edit of an entry, kept on the server."
    },
    "EditImage": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The media id: what `changes.image_id` names."
        },
        "kind": {
          "type": "string",
          "enum": [
            "commons",
            "local"
          ],
          "description": "A Wikimedia Commons file, or an upload to this site."
        },
        "url": {
          "type": "string",
          "description": "A 200px picture, as a path on this site (`/img/w/200q75/<id>`)."
        },
        "width": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ],
          "description": "The original’s width in pixels, or null when it is not known."
        },
        "height": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ],
          "description": "The original’s height in pixels, or null when it is not known."
        },
        "license": {
          "description": "An upload’s licence id (`cc-by-4.0`), or null: a Commons file, or none recorded.",
          "type": [
            "string",
            "null"
          ]
        },
        "license_name": {
          "description": "The licence by name (“CC BY 3.0”), an upload’s or a Commons file’s, or null when not known.",
          "type": [
            "string",
            "null"
          ]
        },
        "credit": {
          "description": "Who to credit in its caption, or null.",
          "type": [
            "string",
            "null"
          ]
        },
        "commons_page": {
          "description": "The Commons file’s page, for its licence and attribution; null for an upload.",
          "type": [
            "string",
            "null"
          ]
        },
        "plate": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "light",
                "dark",
                "none"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "The plate the image is drawn on, as the entry page draws it. `light` or `dark`: a picture with transparent pixels (a logo, most often), drawn on a plate of that colour so its ink shows in light and dark mode alike. `none`: an opaque picture (a photo), drawn as it is, with no plate. Null while the site has not yet looked at its pixels: decide from the picture itself, as the site’s pages then do."
        }
      },
      "required": [
        "id",
        "kind",
        "url",
        "width",
        "height",
        "license",
        "license_name",
        "credit",
        "commons_page",
        "plate"
      ],
      "additionalProperties": false,
      "description": "The lead image as the website editor shows it: `url` a 200px picture, a path on the site; the licence and credit for its caption. `id` is `fields.image_id`. Change it with `changes.image_id` on `POST …/proposals` (an id from `POST /api/v1/media`, or one already on the entry)."
    }
  }
}