{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.cuddler.dev/standards/artifact-definitions/module-stat-catalog/1.0.0/data.schema.json",
  "title": "Module Stat Catalog Data Schema",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "meta",
    "content"
  ],
  "cuddler": {
    "specVersion": "1.0.0",
    "documentTypeId": "module-stat-catalog",
    "schemaVersion": "1.0.0",
    "output": {
      "primaryContentType": "application/json",
      "supportedContentTypes": [
        "application/json"
      ]
    },
    "profile": {
      "id": "module-stat-catalog",
      "version": "1.0.0",
      "for-ai": [
        {
          "instruction": "Explain what this Cuddler schema profile governs so AI consumers understand when to use this schema family.",
          "input": "",
          "output": "Module Stat Catalog documents define the stat metadata that Builder users can choose when placing StatCard controls on module pages."
        }
      ]
    },
    "schemaLinks": [
      {
        "rel": "self",
        "targetSchema": "https://www.cuddler.dev/standards/artifact-definitions/module-stat-catalog/1.0.0/data.schema.json",
        "targetDocumentTypeId": "module-stat-catalog",
        "for-ai": [
          {
            "instruction": "Explain why this related schema is linked here and when an AI consumer should follow it.",
            "input": "",
            "output": "Use this immutable schema URL when validating or generating module stat catalog documents."
          }
        ]
      }
    ],
    "artifactType": "Module Stat Catalog",
    "status": "Public normative publication",
    "publisher": "TrackThat Inc.",
    "sourceUrl": "https://www.cuddler.dev/standards/artifact-definitions/module-stat-catalog/",
    "attributionNotice": "© 2026 TrackThat. This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). See https://www.cuddler.dev/license/ for the site license summary. You are free to share, use, adapt, and modify this material, including for commercial purposes, provided you give appropriate attribution and include a link to the original source URL and the CC BY 4.0 license at https://creativecommons.org/licenses/by/4.0/.",
    "governingDomainSpecification": {
      "title": "Data Document Role",
      "url": "https://www.cuddler.dev/standards/document-role/data/v1.0.0/"
    },
    "governingArtifactSpecification": {
      "title": "Cuddler Artifact Specification",
      "version": "1.0.0",
      "url": "https://www.cuddler.dev/standards/artifact-specification/v1.0.0/"
    }
  },
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri",
      "const": "https://www.cuddler.dev/standards/artifact-definitions/module-stat-catalog/1.0.0/data.schema.json",
      "for-ai": [
        {
          "instruction": "Use this guidance when preparing a valid value for this schema node.",
          "input": "",
          "output": "Absolute URI of this immutable Module Stat Catalog Data Schema."
        }
      ]
    },
    "meta": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "documentTypeId",
        "title"
      ],
      "properties": {
        "schemaVersion": {
          "const": "1.0.0"
        },
        "documentTypeId": {
          "const": "module-stat-catalog"
        },
        "title": {
          "$ref": "#/$defs/nonEmptyText"
        },
        "summary": {
          "$ref": "#/$defs/nonEmptyText"
        }
      },
      "for-ai": [
        {
          "instruction": "Use this guidance when preparing a valid value for this schema node.",
          "input": "",
          "output": "Document identity and reader-facing metadata for the Module Stat Catalog."
        }
      ]
    },
    "content": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "moduleId",
        "moduleKey",
        "stats"
      ],
      "properties": {
        "moduleId": {
          "type": "string",
          "format": "uuid"
        },
        "moduleKey": {
          "$ref": "#/$defs/moduleKey"
        },
        "moduleTitle": {
          "$ref": "#/$defs/nonEmptyText"
        },
        "stats": {
          "type": "array",
          "minItems": 0,
          "items": {
            "$ref": "#/$defs/statDefinition"
          },
          "default": []
        }
      },
      "for-ai": [
        {
          "instruction": "Use this guidance when preparing a valid value for this schema node.",
          "input": "",
          "output": "Module stat metadata used by Builder selection and runtime StatCard configuration."
        }
      ]
    }
  },
  "$defs": {
    "moduleKey": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$"
    },
    "statKey": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\\.[a-z][a-z0-9]*(?:-[a-z0-9]+)*)*$"
    },
    "nonEmptyText": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[^<>]*$"
    },
    "tone": {
      "type": "string",
      "enum": [
        "Default",
        "Primary",
        "Info",
        "Success",
        "Warning",
        "Danger",
        "Neutral"
      ]
    },
    "statDefinition": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "key",
        "label"
      ],
      "properties": {
        "key": {
          "$ref": "#/$defs/statKey"
        },
        "label": {
          "$ref": "#/$defs/nonEmptyText"
        },
        "description": {
          "$ref": "#/$defs/nonEmptyText"
        },
        "tone": {
          "$ref": "#/$defs/tone"
        },
        "href": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference",
          "pattern": "^[^<>]*$"
        }
      }
    }
  },
  "for-ai": [
    {
      "instruction": "Use this guidance when preparing a valid value for this schema node.",
      "input": "",
      "output": "Use this schema to generate Module Stat Catalog data documents that define Builder-selectable stat metadata for module pages."
    }
  ]
}
