name: index
functions:
  loadBuiltinsIntoIndex:
    path: builtins.ts:loadBuiltinsIntoIndex
    env: server
    events:
      - system:ready

  # 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:clearPageIndex
    env: server
    events:
      - page:saved
      - page: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: 10
      autoAck: true
  reindexSpace:
    path: "./command.ts:reindexSpace"
    env: server

  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

  # 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


  # 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
      key: Ctrl-Alt-r
      page: ""
      requireMode: rw
  renamePrefixCommand:
    path: "./refactor.ts:renamePrefixCommand"
    command:
      name: "Page: Batch Rename Prefix"
      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

  # 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
