{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/onclarity-com/json-schema/onclarity-com-collection-response-schema.json",
  "title": "CollectionResponse",
  "description": "Collection as returned by both the user and the admin API.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/onclarity-com-agent-store-admin-api-openapi.yml#/components/schemas/CollectionResponse",
  "properties": {
    "id": {
      "type": "integer",
      "title": "Id",
      "description": "Collection id (registry)."
    },
    "project_id": {
      "type": "integer",
      "title": "Project Id",
      "description": "Owning project id."
    },
    "owner_id": {
      "type": "integer",
      "title": "Owner Id",
      "description": "User id of the owning client (may delete it)."
    },
    "owner_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Owner Name",
      "description": "Owner's full name, joined from users; null when unknown."
    },
    "owner_email": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Owner Email",
      "description": "Owner's email, joined from users; the fallback label."
    },
    "slug": {
      "type": "string",
      "title": "Slug",
      "description": "Stable kebab-case slug, unique per project."
    },
    "title": {
      "type": "string",
      "title": "Title",
      "description": "Human title."
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Description",
      "description": "Human description."
    },
    "json_schema": {
      "additionalProperties": true,
      "type": "object",
      "title": "Json Schema",
      "description": "Record contract (JSON Schema)."
    },
    "indexes": {
      "items": {
        "$ref": "#/$defs/IndexSpec"
      },
      "type": "array",
      "title": "Indexes",
      "description": "Indexes materialized on the dynamic table."
    },
    "columns": {
      "items": {
        "$ref": "#/$defs/CollectionColumn"
      },
      "type": "array",
      "title": "Columns",
      "description": "Materialized columns derived from json_schema."
    },
    "column_order": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Column Order",
      "description": "Fields to display, in order, as stored. Empty means every field."
    },
    "visible_column_names": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Visible Column Names",
      "description": "Resolved: exactly what the grid should render, in order."
    },
    "ticket_link_field": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ticket Link Field",
      "description": "Field whose values identify tickets; null when the collection is not linked to tickets (and so exposes no ticket filters)."
    },
    "ticket_link_es_field": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ticket Link Es Field",
      "description": "ES ticket field the link values are matched against; null = unique_id."
    },
    "table_name": {
      "type": "string",
      "title": "Table Name",
      "description": "Physical table name inside the agent_store schema."
    },
    "version": {
      "type": "integer",
      "title": "Version",
      "description": "Schema version (evolution is out of v1 scope)."
    },
    "record_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Record Count",
      "description": "Number of records; present on list/detail views."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "Creation timestamp."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At",
      "description": "Last update timestamp."
    }
  },
  "type": "object",
  "required": [
    "id",
    "project_id",
    "owner_id",
    "slug",
    "title",
    "json_schema",
    "table_name",
    "version",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "CollectionColumn": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name",
          "description": "Field name (snake_case)."
        },
        "label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Label",
          "description": "Human-readable name (the JSON Schema property 'title'); UI falls back to name."
        },
        "pg_type": {
          "type": "string",
          "title": "Pg Type",
          "description": "Materialized Postgres type."
        },
        "json_type": {
          "type": "string",
          "title": "Json Type",
          "description": "JSON Schema type the field was declared with."
        },
        "format": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Format",
          "description": "JSON Schema format, if any."
        }
      },
      "type": "object",
      "required": [
        "name",
        "pg_type",
        "json_type"
      ],
      "title": "CollectionColumn",
      "description": "One materialized column of the dynamic table."
    },
    "IndexSpec": {
      "properties": {
        "fields": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Fields",
          "description": "Schema fields the index covers (1..5)."
        },
        "unique": {
          "type": "boolean",
          "title": "Unique",
          "description": "Create as a UNIQUE index.",
          "default": false
        }
      },
      "type": "object",
      "required": [
        "fields"
      ],
      "title": "IndexSpec",
      "description": "One requested index over the collection's dynamic table (btree, scalar fields)."
    }
  }
}