{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Deck record",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "name",
    "fields"
  ],
  "properties": {
    "id": {
      "description": "Optional. Omit the key to generate a source identity; null and empty strings are invalid. Relationship targets require an explicitly supplied id. Nested field ids stay required.",
      "type": "string",
      "minLength": 1
    },
    "folderId": { "type": ["string", "null"], "minLength": 1 },
    "aiInstructionPresetId": {
      "description": "Optional: omission preserves an existing selection on override; null selects None; an ID requires an explicitly identified companion instruction preset.",
      "type": ["string", "null"],
      "minLength": 1
    },
    "name": { "type": "string", "minLength": 1, "maxLength": 40 },
    "createdAt": {
      "description": "Optional. Omission and null mean unavailable metadata. Malformed timestamps are rejected.",
      "type": ["string", "null"],
      "format": "date-time"
    },
    "updatedAt": {
      "description": "Optional. Omission and null mean unavailable metadata. Malformed timestamps are rejected.",
      "type": ["string", "null"],
      "format": "date-time"
    },
    "fields": {
      "type": "array",
      "minItems": 1,
      "maxItems": 20,
      "items": {
        "allOf": [
          { "$ref": "field_definition.schema.json" },
          { "required": ["id"] }
        ]
      }
    },
    "deckSettings": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "showTags": { "type": ["boolean", "null"], "default": true }
      }
    },
    "modeSettings": { "type": "object" }
  }
}
