Skip to main content

Module defaults

Module defaults 

Source
Expand description

Built-in resources.

organization, membership, user, api_key and oauth_connection exist in every app. Together they make apps multitenant out of the box: users join organisations through memberships (which also carry their role within that organisation), and every other resource is isolated per organisation by default.

invitation and auth_token are the two tables behind the flows that reach somebody through their mailbox — being invited to an organisation, confirming an address, resetting a password. They exist in every app, and in one with no [email] provider they simply stay empty: the endpoints that write to them are not mounted at all.

Drop a models/<name>.toml with the same name to replace a built-in and add fields or tweak permissions while keeping the machinery working.

Constants§

API_KEY_TOML
Default api_key resource (global). A valid key authenticates as its owner.
AUTH_TOKEN_TOML
A single-use token sent to an address to prove someone reads it.
BILLING_CUSTOMER_TOML
The organisation as Stripe knows it: one row per tenant, holding the customer id every charge and subscription hangs off.
BILLING_EVENT_TOML
Every webhook Stripe has delivered, by its event id.
BILLING_PAYMENT_TOML
One payment that happened: a one-off purchase, or an invoice a subscription generated.
BILLING_PRICE_TOML
One way to pay for a product: an amount, a currency, and either a billing interval (a subscription) or none (a one-off payment).
BILLING_PRODUCT_TOML
A thing the app sells. Global: the catalogue is the same for every tenant.
BILLING_SUBSCRIPTION_TOML
A live (or lapsed) subscription: one organisation paying for one price on a schedule.
INVITATION_TOML
An invitation to join an organisation, addressed to someone who may not have an account yet.
MEMBERSHIP_ROLE_TOML
A single role held by a membership.
MEMBERSHIP_TOML
A user’s membership in an organisation, carrying their role there. The join table behind the N:N between user and organization.
OAUTH_TOML
Default oauth_connection resource (global) linking a user to a provider.
ORGANIZATION_TOML
The organization — the tenant. global because its rows are the organisations; membership (not an organization_id) decides who sees them.
USER_TOML
The default user: global (users are shared across organisations) with email + password auth. Extend via models/users.toml.

Functions§

billing_builtins
The billing resources, in dependency order (product before price, customer before subscription before payment).
builtins
The name → embedded-TOML table of built-ins, in dependency order so foreign keys resolve (organization and user before membership/api_key/oauth).
parse_builtin
Parse one built-in by its embedded TOML. Panics on a malformed built-in — that would be a bug in this crate, caught by the test below.