Skip to main content

Module builtins

Module builtins 

Source
Expand description

Functions the framework ships with.

A built-in is an ordinary Rust fn registered in the function registry under a manifest of its own. It sees the same HostBridge a dynamically-loaded function does — database, config, caller, hook context — so anything a built-in does, an app could have written itself as a functions/ library, and an app that ships a function with the same name replaces it.

They exist for the logic that has to live behind the API rather than in front of it. organization_join is the example: turning an email address into a member of an organisation needs a user lookup that the person doing the adding is deliberately not allowed to perform themselves.

Built-ins are private: they have no HTTP endpoint and are reached only as a resource’s lifecycle hook.

Constants§

ORGANIZATION_JOIN
Name of the membership before_create built-in, as MEMBERSHIP_TOML declares it.
PREFIX
Reserved name prefix. Every built-in wears it so that an app naming a function of its own can never collide with one by accident — and so that a hook pointing at apiplant_… is visibly the framework’s, not the app’s.
STRIPE_PRICE
Name of the billing_price catalogue hook, as BILLING_PRICE_TOML declares it.
STRIPE_PRODUCT
Name of the billing_product catalogue hook, as BILLING_PRODUCT_TOML declares it.

Functions§

organization_join
before_create on membership: work out who is being added.
register_all
Register every built-in into a fresh registry. Called by FunctionRegistry::load.
stripe_price
before_create / before_update on billing_price: create the price in Stripe, or replace it when the change is one Stripe won’t apply in place.
stripe_product
before_create / before_update on billing_product: create or update the product in Stripe, and write its id into the row being saved.