silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.03k stars 140 forks source link

Editor syscalls not present in the query for all syscalls from the documentation #824

Closed simone-viozzi closed 3 months ago

simone-viozzi commented 3 months ago

This query should list all syscalls:

{{#each @module in {syscall select replace(name, /\.\w+$/, "") as name}}}
## {{@module.name}}
{{#each {syscall where @module.name = replace(name, /\.\w+$/, "")}}}
* `{{name}}`
{{/each}}

{{/each}}

Yet editor.* are not present in this list.

I know they should be present because they are being used in a script https://github.com/gorootde/silverbullet-collection/blob/main/scripts/InsertDate.md:

const picked=await syscall("editor.filterBox","Pick a date",dateOptions)
  if(picked){
    await syscall("editor.insertAtCursor",picked.date.toString())
  }

here is my list:

## event * `event.dispatch` * `event.list` ## space * `space.listPages` * `space.readPage` * `space.getPageMeta` * `space.listPlugs` * `space.listAttachments` * `space.readAttachment` * `space.getAttachmentMeta` * `space.listFiles` * `space.getFileMeta` * `space.readFile` * `space.writePage` * `space.deletePage` * `space.writeAttachment` * `space.deleteAttachment` * `space.writeFile` * `space.deleteFile` ## asset * `asset.readAsset` ## yaml * `yaml.parse` * `yaml.stringify` ## system * `system.invokeFunction` * `system.invokeCommand` * `system.listCommands` * `system.listSyscalls` * `system.reloadPlugs` * `system.loadSpaceScripts` * `system.loadSpaceStyles` * `system.invokeSpaceFunction` * `system.applyAttributeExtractors` * `system.getEnv` * `system.getMode` * `system.getVersion` ## mq * `mq.send` * `mq.batchSend` * `mq.ack` * `mq.batchAck` * `mq.getQueueStats` ## language * `language.parseLanguage` * `language.listLanguages` ## template * `template.renderTemplate` * `template.parseTemplate` ## datastore * `datastore.batchGet` * `datastore.get` * `datastore.query` * `datastore.listFunctions` * `datastore.delete` * `datastore.set` * `datastore.batchSet` * `datastore.batchDelete` * `datastore.queryDelete` ## codeWidget * `codeWidget.render` ## markdown * `markdown.parseMarkdown` ## sandboxFetch * `sandboxFetch.fetch` ## shell * `shell.run`
tmichela commented 3 months ago

cf. this post

Right. These syscalls don’t appear on that page because they’re not available on the server, just on the client. Therefore they can only be used for some use cases like commands (which run in the client), but not custom functions used in templates (rendered on the server). The reason they don’t appear on that list is that that list is rendered by a template, which queries for all available syscalls… on the server.