{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://llodev.github.io/skills/schemas/pm-tasks-asana.json",
  "title": "pm-tasks-asana config",
  "type": "object",
  "required": ["version", "projects", "sections"],
  "additionalProperties": false,
  "properties": {
    "$schema": { "type": "string" },
    "version": { "const": "1" },
    "locale": {
      "type": "string",
      "enum": ["en-US", "pt-BR", "es-ES"]
    },
    "workspace": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "minLength": 4 },
        "name": { "type": "string" }
      }
    },
    "projects": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["id", "alias"],
        "additionalProperties": false,
        "properties": {
          "id": { "type": "string", "minLength": 4 },
          "name": { "type": "string" },
          "alias": { "type": "string", "pattern": "^[a-z0-9-]+$" },
          "url": { "type": "string", "format": "uri" }
        }
      }
    },
    "sections": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["projectAlias", "id", "alias"],
        "additionalProperties": false,
        "properties": {
          "projectAlias": { "type": "string" },
          "id": { "type": "string", "minLength": 4 },
          "name": { "type": "string" },
          "alias": { "type": "string", "pattern": "^[a-z0-9-]+$" }
        }
      }
    },
    "customFields": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["projectAlias", "id", "name", "type", "alias"],
        "additionalProperties": false,
        "properties": {
          "projectAlias": { "type": "string" },
          "id": { "type": "string", "minLength": 4 },
          "name": { "type": "string" },
          "type": {
            "type": "string",
            "enum": ["text", "number", "enum", "multi_enum", "date", "people"]
          },
          "unit": {
            "type": "string",
            "enum": ["minutes", "hours", "days", "points"],
            "description": "Native unit a number field is stored in. When the source value uses a different unit, convert to this unit before writing (e.g. hours→minutes ×60). Only meaningful for type:\"number\"."
          },
          "rollsUpFromSubtasks": {
            "type": "boolean",
            "description": "True when Asana already sums this field from a task's subtasks (e.g. the built-in \"Estimated time\"). Such a field is written ONLY on leaf tasks (num_subtasks === 0); writing it on a parent double-counts, because Asana adds the parent's own value on top of the rolled-up total. A field with this flag must never appear in subtaskDefaults.inheritParentFields. Only meaningful for type:\"number\"."
          },
          "alias": { "type": "string", "pattern": "^[a-z0-9-]+$" },
          "options": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["id", "name"],
              "additionalProperties": false,
              "properties": {
                "id": { "type": "string", "minLength": 4 },
                "name": { "type": "string" },
                "alias": { "type": "string", "pattern": "^[a-z0-9-]+$" }
              }
            }
          }
        }
      }
    },
    "subtaskDefaults": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "inheritParentFields": {
          "type": "array",
          "items": { "type": "string", "minLength": 4 },
          "description": "Custom field IDs auto-copied parent->subtask at create time (a floor, NOT a whitelist). Fields not listed are still set per-task from the card's actual scope and must never be left blank just because they are absent here."
        },
        "inheritAssignee": { "type": "boolean" }
      }
    },
    "members": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "alias"],
        "additionalProperties": false,
        "properties": {
          "id": { "type": "string", "minLength": 4 },
          "name": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "alias": { "type": "string", "pattern": "^[a-z0-9-]+$" }
        }
      }
    },
    "defaults": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "projectAlias": { "type": "string" },
        "sectionAlias": { "type": "string" },
        "closeSectionAlias": { "type": "string" },
        "assigneeAlias": { "type": "string" },
        "escalateToAlias": { "type": "string" }
      }
    },
    "taskAliases": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["alias", "id"],
        "additionalProperties": false,
        "properties": {
          "alias": { "type": "string", "pattern": "^[a-z0-9-]+$" },
          "id": { "type": "string" },
          "url": { "type": "string", "format": "uri" }
        }
      }
    },
    "attribution": { "$ref": "https://llodev.com/pm-tasks/attribution.schema.json" },
    "autonomous": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "enabled": { "type": "boolean" },
        "allow": {
          "type": "array",
          "items": {
            "enum": [
              "task.create",
              "task.move",
              "checklist.check",
              "task.close",
              "task.due-date.set",
              "task.assignee.add",
              "task.comment.add"
            ]
          }
        },
        "scope": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "projects": { "type": "array", "items": { "type": "string" } },
            "sections": { "type": "array", "items": { "type": "string" } }
          }
        },
        "rateLimit": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "writesPerMinute": { "type": "integer", "minimum": 1, "maximum": 600 },
            "commentsPerMinute": { "type": "integer", "minimum": 1, "maximum": 600 }
          }
        },
        "auditLog": { "type": "string" }
      }
    }
  }
}
