{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mammoth-io/json-schema/mammoth-io-cond-formatting-patch-request-schema.json",
  "title": "CondFormattingPatchRequest",
  "description": "Update Conditional format",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mammoth-io-conditional-format-api-openapi.yml#/components/schemas/CondFormattingPatchRequest",
  "properties": {
    "patch": {
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/PayloadPatchData"
          },
          {
            "$ref": "#/$defs/StatusPatchData"
          },
          {
            "$ref": "#/$defs/OrderPatchData"
          },
          {
            "$ref": "#/$defs/TypePatchData"
          }
        ]
      },
      "type": "array"
    }
  },
  "type": "object",
  "required": [
    "patch"
  ],
  "$defs": {
    "ColorScaleColumnSchema": {
      "properties": {
        "column": {
          "type": "string"
        },
        "scale": {
          "type": "string"
        },
        "colors_change_at": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "min": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "max": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "CONDITION": {
          "oneOf": [
            {
              "$ref": "#/$defs/conditional_formatting_schema_ConditionSchema"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "column",
        "scale"
      ],
      "title": "ColorScaleColumnSchema"
    },
    "FormatSchema": {
      "properties": {
        "name": {
          "type": "string"
        },
        "color": {
          "type": "string",
          "enum": [
            "red",
            "amber",
            "green",
            "blue",
            "purple",
            "teal",
            "coral",
            "grey",
            "text-red",
            "text-amber",
            "text-green",
            "text-blue",
            "text-purple",
            "text-teal",
            "text-coral",
            "text-grey",
            "text-pink",
            "text-lime"
          ]
        },
        "applies_to": {
          "type": "string",
          "enum": [
            "row",
            "columns"
          ]
        },
        "column_ids": {
          "type": "string",
          "default": "[]"
        }
      },
      "type": "object",
      "required": [
        "applies_to",
        "color",
        "name"
      ],
      "title": "FormatSchema"
    },
    "OrderPatchData": {
      "properties": {
        "op": {
          "type": "string",
          "const": "replace"
        },
        "path": {
          "type": "string",
          "const": "order"
        },
        "value": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Value",
          "description": "Ordered list of rule_ids — backend assigns sequence 0, 1, 2... based on position"
        }
      },
      "type": "object",
      "required": [
        "op",
        "path",
        "value"
      ],
      "title": "OrderPatchData"
    },
    "PayloadPatchData": {
      "properties": {
        "op": {
          "type": "string",
          "const": "replace"
        },
        "path": {
          "type": "string",
          "const": "payload"
        },
        "value": {
          "additionalProperties": {
            "oneOf": [
              {
                "$ref": "#/$defs/apiv2_conditional_formatting_schema_ColumnSchema"
              },
              {
                "$ref": "#/$defs/ColorScaleColumnSchema"
              }
            ]
          },
          "type": "object",
          "title": "Value",
          "description": "Map of rule_id to replacement payload. This is a full replacement — the entire existing payload is overwritten. Supply all fields; omitted fields are dropped. cf_type and enabled are preserved from storage. To change cf_type, use path='type'."
        }
      },
      "type": "object",
      "required": [
        "op",
        "path",
        "value"
      ],
      "title": "PayloadPatchData"
    },
    "StatusPatchData": {
      "properties": {
        "op": {
          "type": "string",
          "const": "replace"
        },
        "path": {
          "type": "string",
          "const": "status"
        },
        "value": {
          "additionalProperties": {
            "type": "boolean"
          },
          "type": "object",
          "title": "Value",
          "description": "Map of rule_id to enabled state"
        }
      },
      "type": "object",
      "required": [
        "op",
        "path",
        "value"
      ],
      "title": "StatusPatchData"
    },
    "TypePatchData": {
      "properties": {
        "op": {
          "type": "string",
          "const": "replace"
        },
        "path": {
          "type": "string",
          "const": "type"
        },
        "value": {
          "additionalProperties": {
            "$ref": "#/$defs/TypePatchValue"
          },
          "type": "object",
          "title": "Value",
          "description": "Map of rule_id to new cf_type and replacement payload"
        }
      },
      "type": "object",
      "required": [
        "op",
        "path",
        "value"
      ],
      "title": "TypePatchData"
    },
    "TypePatchValue": {
      "properties": {
        "cf_type": {
          "type": "string",
          "enum": [
            "RULE",
            "COLOR_SCALE"
          ]
        },
        "payload": {
          "oneOf": [
            {
              "$ref": "#/$defs/apiv2_conditional_formatting_schema_ColumnSchema"
            },
            {
              "$ref": "#/$defs/ColorScaleColumnSchema"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "cf_type",
        "payload"
      ],
      "title": "TypePatchValue"
    },
    "apiv2_conditional_formatting_schema_ColumnSchema": {
      "properties": {
        "CONDITION": {
          "$ref": "#/$defs/conditional_formatting_schema_ConditionSchema"
        },
        "FORMAT": {
          "oneOf": [
            {
              "$ref": "#/$defs/FormatSchema"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "CONDITION"
      ],
      "title": "ColumnSchema"
    },
    "conditional_formatting_schema_ConditionSchema": {
      "properties": {
        "OR": {
          "oneOf": [
            {
              "items": {
                "type": "object"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ]
        },
        "AND": {
          "oneOf": [
            {
              "items": {
                "type": "object"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "type": "object",
      "required": [],
      "title": "ConditionSchema"
    }
  }
}