{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://akarya.id/schema/module-manifest-v1.json",
  "title": "Doka Module Manifest",
  "description": "Declares one marketplace widget module (ADR-0015): its identity, the JSON Schema for a widget's options, and how it renders. Version 1.",
  "type": "object",
  "required": ["manifestVersion", "slug", "name", "version", "kind", "render"],
  "additionalProperties": false,
  "properties": {
    "manifestVersion": { "const": 1 },
    "slug": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]{1,38}$",
      "description": "Stable identifier, unique per scope. Also the value a widget puts in `module`. Must not collide with a reserved native module."
    },
    "name": { "type": "string", "minLength": 1, "maxLength": 120 },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$",
      "description": "Semantic version."
    },
    "description": { "type": "string", "maxLength": 2000 },
    "author": { "type": "string", "maxLength": 200 },
    "homepage": { "type": "string", "format": "uri", "maxLength": 500 },
    "kind": {
      "enum": ["static", "media", "data"],
      "description": "static: options only. media: also takes library media. data: also bound to a server-side data provider (increment 2)."
    },
    "settingsSchema": {
      "type": "object",
      "description": "A JSON Schema (draft 2020-12) that the widget's `options` object is validated against on publish. Keep it to string/number/integer/boolean/enum properties so the console can build a form for it."
    },
    "defaults": {
      "type": "object",
      "description": "Default `options` applied when a widget of this module is added in the editor.",
      "default": {}
    },
    "preview": {
      "$ref": "#/$defs/sha256",
      "description": "Optional thumbnail: the sha256 of a media row to show in the marketplace."
    },
    "dataProvider": {
      "type": "object",
      "description": "kind:\"data\" only. Not consumed until increment 2; declared so manifests are forward-stable.",
      "required": ["type", "refreshS"],
      "additionalProperties": false,
      "properties": {
        "type": { "enum": ["url", "json", "rss", "weather"] },
        "refreshS": { "type": "integer", "minimum": 60, "maximum": 86400 },
        "settings": { "type": "object", "default": {} }
      }
    },
    "render": {
      "type": "object",
      "required": ["engine"],
      "additionalProperties": false,
      "properties": {
        "engine": {
          "const": "html",
          "description": "One engine: a single self-contained HTML document rendered in a sandboxed iframe. A .akmod zip package (ADR-0016) is flattened to this on install."
        },
        "entry": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._/-]{1,120}$",
          "description": "Entry HTML file within a .akmod package. Default \"template.html\".",
          "default": "template.html"
        },
        "bundle": {
          "$ref": "#/$defs/sha256",
          "description": "sha256 of the media row (mime text/html) holding the flattened template. Computed on install/sync — omit it in an authored manifest."
        }
      }
    },
    "capabilities": {
      "type": "object",
      "additionalProperties": false,
      "description": "Advisory flags for what the module expects. v1 wires none of these; they document intent.",
      "properties": {
        "media": { "type": "boolean", "default": false },
        "network": { "type": "boolean", "default": false }
      }
    }
  },
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$",
      "description": "Lowercase hex SHA-256 of the asset bytes (ADR-0005)."
    }
  }
}
