{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.kiket.dev/intake_form.json",
  "title": "Kiket Intake Form Definition",
  "description": "Defines a public or internal intake form with fields, validation, and routing.",
  "type": "object",
  "required": [
    "model_version",
    "intake_form"
  ],
  "properties": {
    "model_version": {
      "type": "string",
      "const": "1.0"
    },
    "intake_form": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "key": {
          "type": "string",
          "pattern": "^[a-z0-9_-]+$"
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "slug": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      },
      "anyOf": [
        {
          "required": [
            "key"
          ]
        },
        {
          "required": [
            "id"
          ]
        }
      ],
      "additionalProperties": false
    },
    "settings": {
      "type": "object",
      "properties": {
        "public": {
          "type": "boolean",
          "default": false
        },
        "active": {
          "type": "boolean",
          "default": true
        },
        "requires_approval": {
          "type": "boolean",
          "default": false
        },
        "submit_label": {
          "type": "string",
          "default": "Submit"
        },
        "require_auth": {
          "type": "boolean",
          "default": false
        },
        "notify_on_submission": {
          "type": "boolean",
          "default": true
        },
        "confirmation_message": {
          "type": "string"
        },
        "redirect_url": {
          "type": "string",
          "format": "uri"
        },
        "notify_emails": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "email"
          }
        },
        "default_issue_type": {
          "type": "string"
        },
        "default_status": {
          "type": "string"
        },
        "default_priority": {
          "type": "string"
        },
        "default_labels": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "fields": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "key"
        ],
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^[a-z0-9_]+$"
          },
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "string",
              "text",
              "markdown",
              "number",
              "boolean",
              "enum",
              "multi_enum",
              "email",
              "phone",
              "url",
              "date",
              "datetime",
              "time",
              "file",
              "rating",
              "scale",
              "heading",
              "paragraph",
              "divider"
            ],
            "default": "string"
          },
          "required": {
            "type": "boolean",
            "default": false
          },
          "hidden": {
            "type": "boolean",
            "default": false
          },
          "placeholder": {
            "type": "string"
          },
          "helper_text": {
            "type": "string"
          },
          "default_value": {},
          "position": {
            "type": "integer"
          },
          "maps_to": {
            "type": "string",
            "enum": [
              "title",
              "description",
              "priority",
              "assignee",
              "custom_field",
              "label",
              "due_date"
            ]
          },
          "custom_field_key": {
            "type": "string"
          },
          "options": {
            "type": "object",
            "properties": {
              "values": {
                "type": "array"
              }
            }
          },
          "validation": {
            "type": "object"
          },
          "conditional": {
            "type": "object"
          }
        }
      }
    },
    "routing": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "events": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "additionalProperties": false
}
