name: index
functions:
  # Public API
  batchSet:
    path: api.ts:batchSet
    env: server
  query:
    path: api.ts:query
  indexObjects:
    path: api.ts:indexObjects
    env: server
  queryObjects:
    path: api.ts:queryObjects
    # Note: not setting env: server to allow for client-side datastore query caching
  getObjectByRef:
    path: api.ts:getObjectByRef
    env: server
  objectSourceProvider:
    path: api.ts:objectSourceProvider
    events:
      - query:*
  discoverSources:
    path: api.ts:discoverSources
    events:
      - query_
  clearIndex:
    path: api.ts:clearIndex
    env: server

  clearDSIndex:
    path: api.ts:clearFileIndex
    env: server
    events:
      - file:deleted

  parseIndexTextRepublish:
    path: "./command.ts:parseIndexTextRepublish"
    env: server
    events:
      - page:index_text

  reindexSpaceCommand:
    path: "./command.ts:reindexCommand"
    command:
      name: "Space: Reindex"
      requireMode: rw

  processIndexQueue:
    path: ./command.ts:processIndexQueue
    mqSubscriptions:
      - queue: indexQueue
        batchSize: 3
        autoAck: true
  reindexSpace:
    path: "./command.ts:reindexSpace"
    env: server

  indexAttachment:
    path: "./attachment.ts:indexAttachment"
    events:
      - attachment:index

  indexPage:
    path: page.ts:indexPage
    events:
      - page:index

  indexParagraphs:
    path: "./paragraph.ts:indexParagraphs"
    events:
      - page:index

  # Backlinks
  indexLinks:
    path: "./page_links.ts:indexLinks"
    events:
      - page:index

  attributeComplete:
    path: "./attributes.ts:attributeComplete"
    events:
      - editor:complete

  objectAttributeCompleter:
    path: ./attributes.ts:objectAttributeCompleter
    events:
      - attribute:complete:*

  # Item indexing
  indexItem:
    path: "./item.ts:indexItems"
    events:
      - page:index

  # Anchors
  indexAnchors:
    path: "./anchor.ts:indexAnchors"
    events:
      - page:index
  anchorComplete:
    path: "./anchor.ts:anchorComplete"
    events:
      - editor:complete

  # Tables
  indexTables:
    path: "table.ts:indexTables"
    events:
      - page:index

  # Headers
  indexHeaders:
    path: header.ts:indexHeaders
    events:
      - page:index
  headerComplete:
    path: header.ts:headerComplete
    events:
      - editor:complete

  # Data
  indexData:
    path: data.ts:indexData
    events:
      - page:index

  # Script
  indexSpaceScript:
    path: script.ts:indexSpaceScript
    events:
      - page:index
  indexSpaceLua:
    path: script.ts:indexSpaceLua
    events:
      - page:index

  # Style
  indexSpaceStyle:
    path: style.ts:indexSpaceStyle
    events:
      - page:index

  # Config
  indexSpaceConfig:
    path: config.ts:indexSpaceConfig
    events:
      - page:index

  # Hashtags
  indexTags:
    path: tags.ts:indexTags
    events:
      - page:index
  tagComplete:
    path: tags.ts:tagComplete
    events:
      - editor:complete

  renamePageCommand:
    path: "./refactor.ts:renamePageCommand"
    command:
      name: "Page: Rename"
      mac: Cmd-Alt-r
      page: ""
      requireMode: rw
  renamePrefixCommand:
    path: "./refactor.ts:renamePrefixCommand"
    command:
      name: "Page: Batch Rename Prefix"
      requireMode: rw
  renamePageLinkCommand:
    path: "./refactor.ts:renamePageLinkCommand"
    command:
      name: "Page: Rename Linked Page"
      mac: Cmd-Ctrl-Alt-r
      key: Ctrl-Shift-Alt-r
      requireMode: rw

  # Refactoring Commands
  extractToPageCommand:
    path: ./refactor.ts:extractToPageCommand
    command:
      name: "Page: Extract"
      requireMode: rw

  # TOC
  tocWidget:
    path: toc.ts:widget
    codeWidget: toc
    renderMode: markdown

  # Template Widgets
  renderTemplateWidgetsTop:
    path: widget.ts:renderTemplateWidgets
    env: client
    panelWidget: top

  renderTemplateWidgetsBottom:
    path: widget.ts:renderTemplateWidgets
    env: client
    panelWidget: bottom

  refreshWidgets:
    path: widget.ts:refreshWidgets

  lintYAML:
    path: lint.ts:lintYAML
    events:
      - editor:lint

  lintLua:
    path: lint.ts:lintLua
    events:
      - editor:lint

  # Tag file system
  readFileTag:
    path: tag_page.ts:readFileTag
    pageNamespace:
      pattern: "📌 .+"
      operation: readFile

  writePageTag:
    path: tag_page.ts:writeFileTag
    pageNamespace:
      pattern: "📌 .+"
      operation: readFile

  getPageMetaTag:
    path: tag_page.ts:getFileMetaTag
    pageNamespace:
      pattern: "📌 .+"
      operation: getFileMeta

  syscallSourceProvider:
    path: builtins.ts:syscallSourceProvider
    events:
      - query:syscall

  commandSourceProvider:
    path: builtins.ts:commandSourceProvider
    events:
      - query:command
config:
  # Schema for the built-in tags indexed by this plug
  schema.tag:
    page:
      type: object
      additionalProperties: true
      properties:
        ref:
          type: string
          readOnly: true
        tag:
          type: string
          readOnly: true
        tags:
          anyOf:
            - type: array
              items:
                type: string
            - type: string
        itags:
          type: array
          readOnly: true
          items:
            type: string
          nullable: true
        name:
          type: string
          readOnly: true
        pageDecoration:
          type: object
          properties:
            prefix:
              type: string
              nullable: true
            cssClasses:
              type: array
              items:
                type: string
              nullable: true
            hide:
              type: boolean
              nullable: true
            renderWidgets:
              type: boolean
              nullable: true
          nullable: true
        displayName:
          type: string
          nullable: true
        aliases:
          type: array
          items:
            type: string
          nullable: true
        created:
          type: string
          readOnly: true
        contentType:
          type: string
          readOnly: true
        size:
          type: number
          readOnly: true
        lastModified:
          type: string
          readOnly: true
        perm:
          type: string
          readOnly: true
          enum:
            - ro
            - rw
        lastOpened:
          type: number
          readOnly: true
          nullable: true
    aspiring-page:
      type: object
      additionalProperties: true
      properties:
        ref:
          type: string
          readOnly: true
        tag:
          type: string
          readOnly: true
        name:
          type: string
          readOnly: true
        page:
          type: string
          readOnly: true
        pos:
          type: number
          readOnly: true
    attachment:
      type: object
      additionalProperties: true
      properties:
        ref:
          type: string
          readOnly: true
        tag:
          type: string
          readOnly: true
        tags:
          type: array
          readOnly: true
          items:
            type: string
          nullable: true
        itags:
          type: array
          readOnly: true
          items:
            type: string
          nullable: true
        name:
          type: string
          readOnly: true
        created:
          readOnly: true
          type: string
        contentType:
          type: string
          readOnly: true
        size:
          type: number
          readOnly: true
        lastModified:
          type: string
          readOnly: true
        perm:
          type: string
          readOnly: true
          enum:
            - ro
            - rw
    item:
      type: object
      additionalProperties: true
      properties:
        ref:
          type: string
          readOnly: true
        tag:
          type: string
          readOnly: true
        tags:
          type: array
          items:
            type: string
          nullable: true
        itags:
          type: array
          readOnly: true
          items:
            type: string
          nullable: true
        name:
          type: string
          readOnly: true
        page:
          type: string
          readOnly: true
        parent:
          type: string
          readOnly: true
        pos:
          type: number
          readOnly: true
        text:
          type: string
          readOnly: true
    tag:
      type: object
      properties:
        ref:
          type: string
          readOnly: true
        tag:
          type: string
          readOnly: true
        tags:
          type: array
          readOnly: true
          items:
            type: string
          nullable: true
        itags:
          type: array
          readOnly: true
          items:
            type: string
          nullable: true
        name:
          type: string
          readOnly: true
        page:
          type: string
          readOnly: true
        parent:
          type: string
          readOnly: true
        context:
          type: string
          readOnly: true
    anchor:
      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
        name:
          type: string
        page:
          type: string
        pos:
          type: number
    link:
      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
        name:
          type: string
        page:
          type: string
        toFile:
          type: string
          nullable: true
        toPage:
          type: string
          nullable: true
        snippet:
          type: string
        pos:
          type: number
        alias:
          type: string
        asTemplate:
          type: boolean
    header:
      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
        name:
          type: string
        page:
          type: string
        pos:
          type: number
        level:
          type: string
    paragraph:
      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
        text:
          type: string
        page:
          type: string
        pos:
          type: number
    template:
      type: object
      properties:
        ref:
          type: string
          readOnly: true
        tag:
          type: string
        tags:
          anyOf:
            - type: array
              items:
                type: string
            - type: string
        itags:
          type: array
          items:
            type: string
          nullable: true
        page:
          type: string
        pageName:
          type: string
        description:
          type: string
        pos:
          type: number
        hooks:
          type: object
        frontmatter:
          anyOf:
            - type: object
            - type: string
    table:
      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
        page:
          type: string
        pos:
          type: number