name: tasks
functions:
  # API
  updateTaskState:
    path: task.ts:updateTaskState

  indexTasks:
    path: "./task.ts:indexTasks"
    events:
      - page:index
  taskToggle:
    path: "./task.ts:taskToggle"
    events:
      - page:click
  taskToggleCommand:
    path: ./task.ts:taskCycleCommand
    command:
      name: "Task: Cycle State"
      key: Alt-t
      requireMode: rw
  taskPostponeCommand:
    path: ./task.ts:postponeCommand
    command:
      name: "Task: Postpone"
      key: Alt-+
      requireMode: rw
      contexts:
        - DeadlineDate
  previewTaskToggle:
    path: ./task.ts:previewTaskToggle
    events:
      - preview:click

  taskComplete:
    path: ./complete.ts:completeTaskState
    events:
      - editor:complete

  removeCompletedTasksCommand:
    path: task.ts:removeCompletedTasksCommand
    command:
      name: "Task: Remove Completed"
      requireMode: rw

config:
  schema.tag:
    task:
      type: object
      additionalProperties: true
      properties:
        ref:
          type: string
          readOnly: true
        tag:
          type: string
        tags:
          type: array
          items:
            type: string
          nullable: true
        itags:
          type: array
          items:
            type: string
          nullable: true
        name:
          type: string
        page:
          type: string
        parent:
          type: string
        pos:
          type: number
        text:
          type: string
        state:
          type: string
        done:
          type: boolean
        deadline:
          type: string
          nullable: true
    taskstate:
      type: object
      properties:
        ref:
          type: string
          readOnly: true
        tag:
          type: string
        tags:
          type: array
          items:
            type: string
          nullable: true
        itags:
          type: array
          items:
            type: string
          nullable: true
        state:
          type: string
        count:
          type: number