Bases: API for plugins to add custom functions

Hello!

This post is the continuation of a conversation started in OMG’s #plugin-dev channel.
The objective is to better measure interest, and keep the conversation better referenced for Obsidian team and every member of the community interested in the feature.

What is it about ?

In the early days of Bases, one could read « Some planned features include: Bases API for plugins to add more power through custom functions ».

This was, and still is, a wonderful idea! It solves a lot of different uses cases like:

  • Share a formula between different Bases files & embeds
  • Distribute a formula to different vaults & users
  • Grant a way to have complex logic more readable
  • Possibly yields better performances

Relevant Feature Requests

Here is a just a few recent Feature Requests submitted on the forum that I believe solvable by this:

Implementation Considerations

Summarizing some chats from the community on implementation.

  1. Concern about duplicated function/formula names: To address this, functions exposed by a plugin would be available to user by first accessing a unique id/name for the plugin, as we already do for views. So perhaps azaol_astro.western_emojified(dateProperty).

I’ll update this post from time to time with other piece of information gathered discussing this on the Discord group and this forum post. Comment below if you want to add or improve something written above!

7 Likes

I really would love this functionality so I could make Bases fit my usecase/base structure more succinctly.

x-posting from discord:

My usecase/need is that my workflow is heavily incorporating a parent-child structure of links with various note “types”, so i have an entire relationship graph that i’d looove to filter on.

The simplest example of this/small improvement for significant QOL gain: I’d love to implement flatten over a property key, so that i can map/reduce/filter on whether or not any of the notes above the certain properties.

ex:
currently use domain: [[...]] on notes that links to my company note, or a Client note, or a project, and
currently use context: [[...]] to link create the parent-child tree (more granular – generally agile-related: domain > epic > story > task)

I really want to have a base view that shows me every single note that is a descendant of my company’s note – ideally i’d be able to flatten over domain to coalesce the [[project]], [[client]], [[company]] chain, so i can do a simple filter by contains(flatten(domain), [[company]])

Additional thoughts: Ideally (imo) this example functionality I’ve described just gets baked into Bases-upstream, but I’d argue it’s beneficial to the Obisidan dev team to make bases functions extensible to allow users/devs to hack on what functions are useful for different usecases, and either supply plugins or chatter/share on the discord/forum after trying things out. That way (to reference/appeal to the team) we can help the team determine which functions have usefulness that is ongoing, popular, niche, etc. :^)