{
  "lexicon": 1,
  "id": "actor.rpg.generator",
  "description": "Generator metadata and decomposed layers for a sprite built with the rpg.actor sprite generator.",
  "defs": {
    "main": {
      "type": "record",
      "description": "Stores the individual recolored layers and configuration used to build a sprite via the generator. Enables recomposition by third-party tools (e.g. adding items/overlays) without the full generator pipeline. One record per user (rkey: self).",
      "key": "literal:self",
      "record": {
        "type": "object",
        "required": ["version", "bodyType", "layers", "createdAt"],
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "Generator version that produced this record."
          },
          "bodyType": {
            "type": "string",
            "maxLength": 20,
            "description": "Body type used (e.g. 'male', 'female')."
          },
          "skin": {
            "type": "object",
            "description": "Skin configuration.",
            "properties": {
              "tone": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100,
                "description": "Gradient skin tone index."
              },
              "mode": {
                "type": "string",
                "maxLength": 10,
                "description": "'gradient' or 'custom'."
              },
              "hex": {
                "type": "string",
                "maxLength": 7,
                "description": "Custom skin hex color (if mode is custom)."
              }
            }
          },
          "eyes": {
            "type": "object",
            "description": "Eye color configuration.",
            "properties": {
              "mode": {
                "type": "string",
                "maxLength": 10,
                "description": "'gradient' or 'custom'."
              },
              "tone": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100,
                "description": "Gradient eye tone index."
              },
              "hex": {
                "type": "string",
                "maxLength": 7,
                "description": "Custom eye hex color."
              }
            }
          },
          "layers": {
            "type": "array",
            "description": "Ordered array of recolored layer images, back-to-front. Body is always index 0.",
            "maxLength": 20,
            "items": {
              "type": "object",
              "required": ["id", "blob"],
              "properties": {
                "id": {
                  "type": "string",
                  "maxLength": 30,
                  "description": "Layer category identifier (e.g. 'body', 'tops', 'hair', 'bangs')."
                },
                "blob": {
                  "type": "blob",
                  "accept": ["image/png"],
                  "maxSize": 1000000,
                  "description": "The recolored layer PNG."
                },
                "assetName": {
                  "type": "string",
                  "maxLength": 100,
                  "description": "Generator asset filename (e.g. '001_basic_short')."
                },
                "title": {
                  "type": "string",
                  "maxLength": 100,
                  "description": "Human-readable name derived from the asset filename."
                },
                "colors": {
                  "type": "object",
                  "description": "Color selections applied to this layer. Only channels defined by the asset's colorway are included.",
                  "properties": {
                    "main": { "type": "string", "maxLength": 7 },
                    "sub1": { "type": "string", "maxLength": 7 },
                    "sub2": { "type": "string", "maxLength": 7 },
                    "sub3": { "type": "string", "maxLength": 7 }
                  }
                },
                "subtractMask": {
                  "type": "blob",
                  "accept": ["image/png"],
                  "maxSize": 50000,
                  "description": "Binary mask PNG. Opaque black pixels erase the composite below this layer before it is drawn. Extracted from the asset's colorway black regions at save time."
                },
                "behindRows": {
                  "type": "array",
                  "description": "Sprite-sheet row indices (0-3) where this layer should composite behind the body (destination-over). Row 0=down, 1=left, 2=right, 3=up. Omit for normal source-over on all rows.",
                  "maxLength": 4,
                  "items": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 3
                  }
                }
              }
            }
          },
          "items": {
            "type": "array",
            "description": "Freeform item identifiers applied on top of the sprite (e.g. 'popcorn').",
            "maxLength": 20,
            "items": {
              "type": "string",
              "maxLength": 50
            }
          },
          "createdAt": {
            "type": "string",
            "format": "datetime",
            "description": "When this record was first created."
          },
          "updatedAt": {
            "type": "string",
            "format": "datetime",
            "description": "When this record was last modified."
          }
        }
      }
    }
  }
}
