{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contract": {
      "type": "string",
      "const": "WorkflowColumnBinding"
    },
    "version": {
      "type": "number",
      "const": 1
    },
    "enabled": {
      "type": "boolean"
    },
    "paused": {
      "default": false,
      "type": "boolean"
    },
    "workflow": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "version": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "inputSchemaHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "required": [
        "id",
        "version",
        "inputSchemaHash"
      ],
      "additionalProperties": false
    },
    "inputs": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128
      },
      "additionalProperties": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "default"
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "constant"
              },
              "value": {
                "$ref": "#/$defs/__schema0"
              }
            },
            "required": [
              "kind",
              "value"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "field"
              },
              "field": {
                "type": "object",
                "properties": {
                  "ontologyId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "fieldKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                },
                "required": [
                  "ontologyId",
                  "fieldKey"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "field"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "context"
              },
              "field": {
                "type": "string",
                "enum": [
                  "assetId",
                  "teamId",
                  "ontologyId",
                  "columnId"
                ]
              }
            },
            "required": [
              "kind",
              "field"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "dependencies": {
      "default": [],
      "maxItems": 100,
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "field"
              },
              "field": {
                "type": "object",
                "properties": {
                  "ontologyId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "fieldKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                },
                "required": [
                  "ontologyId",
                  "fieldKey"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "field"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "relation"
              },
              "relation": {
                "type": "object",
                "properties": {
                  "ontologyId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "fieldKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                },
                "required": [
                  "ontologyId",
                  "fieldKey"
                ],
                "additionalProperties": false
              },
              "direction": {
                "type": "string",
                "enum": [
                  "incoming",
                  "outgoing"
                ]
              },
              "fields": {
                "maxItems": 100,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "ontologyId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    },
                    "fieldKey": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "required": [
                    "ontologyId",
                    "fieldKey"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "kind",
              "relation",
              "direction",
              "fields"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "output": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "number",
            "text",
            "json"
          ]
        },
        "path": {
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "nullable": {
          "default": false,
          "type": "boolean"
        }
      },
      "required": [
        "type",
        "path",
        "nullable"
      ],
      "additionalProperties": false
    },
    "policy": {
      "default": {
        "debounceMs": 5000,
        "maxDelayMs": 30000,
        "concurrency": 2
      },
      "type": "object",
      "properties": {
        "debounceMs": {
          "default": 5000,
          "type": "integer",
          "minimum": 0,
          "maximum": 30000
        },
        "maxDelayMs": {
          "default": 30000,
          "type": "integer",
          "minimum": 0,
          "maximum": 30000
        },
        "concurrency": {
          "default": 2,
          "type": "integer",
          "minimum": 1,
          "maximum": 32
        },
        "requireSearchProjection": {
          "type": "boolean"
        }
      },
      "required": [
        "debounceMs",
        "maxDelayMs",
        "concurrency"
      ],
      "additionalProperties": false
    },
    "expiry": {
      "type": "object",
      "properties": {
        "path": {
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        }
      },
      "required": [
        "path"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "contract",
    "version",
    "enabled",
    "paused",
    "workflow",
    "inputs",
    "dependencies",
    "output",
    "policy"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    }
  },
  "$id": "https://schemas.infmonkeys.com/contracts/workflow-column-binding.schema.json",
  "title": "workflow-column-binding"
}
