{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/softsync-ai/json-schema/softsync-ai-create-view-dto-schema.json",
  "title": "CreateViewDto",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/softsync-ai-groups-views-api-openapi.yml#/components/schemas/CreateViewDto",
  "type": "object",
  "properties": {
    "groupId": {
      "type": "string",
      "description": "Group ID this view belongs to"
    },
    "tableId": {
      "type": "string",
      "description": "Table ID this view displays"
    },
    "name": {
      "type": "string",
      "description": "View name"
    },
    "viewType": {
      "description": "View type",
      "allOf": [
        {
          "$ref": "#/$defs/ViewType"
        }
      ]
    },
    "config": {
      "$ref": "#/$defs/ViewConfigDto"
    },
    "order": {
      "type": "number",
      "description": "Display order"
    },
    "isDefault": {
      "type": "boolean",
      "description": "Is this the default view?"
    }
  },
  "required": [
    "groupId",
    "tableId",
    "name",
    "viewType"
  ],
  "$defs": {
    "CalendarMode": {
      "type": "string",
      "enum": [
        "day",
        "week",
        "month"
      ],
      "description": "Calendar mode for calendar views"
    },
    "FieldQueryFilter": {
      "type": "object",
      "properties": {
        "fieldId": {
          "description": "Field ID to filter on",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/SystemField"
            }
          ]
        },
        "operator": {
          "description": "Filter operator: eq (equals), ne (not equals), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), contains (substring match), in (value exists in array), is_empty (field has no value), is_not_empty (field has value)",
          "allOf": [
            {
              "$ref": "#/$defs/FilterOperator"
            }
          ]
        },
        "value": {
          "description": "Value to compare against. Type should match the field type and operator requirements.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            },
            {
              "type": "boolean"
            },
            {
              "type": "array"
            }
          ]
        },
        "condition": {
          "description": "Logical condition to chain with the previous filter or group (AND/OR). Defaults to AND if not specified. The first filter in the array ignores this field. For grouped filters, this determines how the group connects to the previous filter/group.",
          "allOf": [
            {
              "$ref": "#/$defs/FilterCondition"
            }
          ]
        },
        "groupId": {
          "type": "string",
          "description": "Optional group identifier. Filters sharing the same groupId are wrapped in parentheses and evaluated together as a logical unit. Filters within a group are chained using their individual condition fields. Groups are connected to each other using the condition field of the first filter in each subsequent group. Use grouping to create complex expressions like: (A OR B) AND (C OR D)."
        }
      },
      "required": [
        "fieldId",
        "operator",
        "value"
      ]
    },
    "FilterCondition": {
      "type": "string",
      "enum": [
        "and",
        "or"
      ],
      "description": "Logical condition to chain with the previous filter or group (AND/OR). Defaults to AND if not specified. The first filter in the array ignores this field. For grouped filters, this determines how the group connects to the previous filter/group."
    },
    "FilterOperator": {
      "type": "string",
      "enum": [
        "eq",
        "ne",
        "gt",
        "gte",
        "lt",
        "lte",
        "contains",
        "in",
        "is_empty",
        "is_not_empty"
      ],
      "description": "Filter operator: eq (equals), ne (not equals), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), contains (substring match), in (value exists in array), is_empty (field has no value), is_not_empty (field has value)"
    },
    "SortConfig": {
      "type": "object",
      "properties": {
        "fieldId": {
          "description": "Field ID to sort by",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/SystemField"
            }
          ]
        },
        "direction": {
          "description": "Sort direction: asc or desc",
          "allOf": [
            {
              "$ref": "#/$defs/SortDirection"
            }
          ]
        }
      },
      "required": [
        "fieldId",
        "direction"
      ]
    },
    "SortDirection": {
      "type": "string",
      "enum": [
        "asc",
        "desc"
      ],
      "description": "Sort direction: asc or desc"
    },
    "SystemField": {
      "type": "string",
      "enum": [
        "__system_created_at",
        "__system_updated_at",
        "__system_created_by",
        "__system_last_interaction_at",
        "__system_last_sent_at",
        "__system_last_received_at"
      ]
    },
    "ViewConfigDto": {
      "type": "object",
      "properties": {
        "filters": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FieldQueryFilter"
          }
        },
        "sort": {
          "$ref": "#/$defs/SortConfig"
        },
        "calendarMode": {
          "description": "Calendar mode for calendar views",
          "allOf": [
            {
              "$ref": "#/$defs/CalendarMode"
            }
          ]
        },
        "dateFieldId": {
          "type": "string",
          "description": "Date field ID used for calendar events"
        },
        "endDateFieldId": {
          "type": "string",
          "description": "Optional end date field ID used for calendar events"
        },
        "dependencyFieldId": {
          "type": "string",
          "description": "Timeline views: optional link field ID (to the same object) naming what each record waits on"
        },
        "coloringFieldId": {
          "type": "string",
          "description": "Optional select field ID used to color calendar events by option color"
        },
        "groupBy": {
          "type": "string",
          "description": "Field API name for Kanban grouping (must be SELECT field)"
        },
        "columns": {
          "description": "Visible column field API names",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "columnWidths": {
          "description": "Visible column field widths",
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "titleColumnWidth": {
          "type": "number",
          "description": "Pixel width of the fixed title column in table views"
        },
        "primary": {
          "type": "string"
        },
        "showColumns": {
          "description": "Kanban only: view-local (group-specific) ordered list of visible group-by choice values. Acts as both the visible set and the column order. When omitted, all columns are shown in field order — so options added to the field elsewhere do not silently appear in or reorder existing views.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "showOthersColumn": {
          "type": "boolean",
          "description": "Kanban only: render the Others column collecting records whose status is a hidden choice."
        },
        "showNoStatusColumn": {
          "type": "boolean",
          "description": "Kanban only: explicit override for the No Status column. When undefined, the column auto-appears if unassigned records exist."
        },
        "header": {
          "type": "object",
          "description": "Optional header layout config for kanban/record headers. rows is a max-3 array of field-id rows.",
          "additionalProperties": true
        }
      }
    },
    "ViewType": {
      "type": "string",
      "enum": [
        "table",
        "kanban",
        "calendar",
        "timeline"
      ]
    }
  }
}