tenant-settings
Per-tenant Currency + Locale defaults, exposed as two config keys (tenant-settings:config:currency, tenant-settings:config:locale) that surface in the self-populating Settings-Hub via mask. Pair with defineCreateWithTenantDefaults to auto-fill a money field’s currency or a locale field on create instead of hard-coding a literal per entity.
Quick example
Section titled “Quick example”From recipes-tenant-settings — the smallest working mount:
// Consuming tenant-settings: an `invoice` entity whose `amount` (money) and// `language` (locale) are auto-filled from the tenant's currency/locale// setting when the caller omits them — instead of hard-coding "EUR"/"en" on// the field, the mistake this recipe exists to prevent (solon#P19).
import { defineCreateWithTenantDefaults } from "@cosmicdrift/kumiko-bundled-features/tenant-settings";import { createEntity, createMoneyField, createSelectField, createTextField, defineFeature,} from "@cosmicdrift/kumiko-framework/engine";
export const invoiceEntity = createEntity({ table: "read_invoices", fields: { title: createTextField({ personal: false, reason: "is_business_data", required: true }), amount: createMoneyField({ required: true }), language: createSelectField({ options: ["en", "de", "fr"] as const }), },});
const ACCESS = { roles: ["Admin"] } as const;
export const invoiceFeature = defineFeature("invoice", (r) => { r.entity({ name: "invoice", ...invoiceEntity }); r.writeHandler( defineCreateWithTenantDefaults("invoice", invoiceEntity, { access: ACCESS, currencyFields: ["amount"], localeField: "language", }), );});📄 On GitHub: samples/recipes/tenant-settings/src/feature.ts
Live preview
Section titled “Live preview”
How it fits
Section titled “How it fits”What this feature needs to run (Requires).
flowchart TB
n_tenant_settings["tenant-settings"]
subgraph how_reqs["Requires"]
n_config["config"]
end
n_config --> n_tenant_settings
Getting started
Section titled “Getting started”Start with recipes-tenant-settings for a step-by-step walkthrough with runnable code and integration tests.
Dependencies
Section titled “Dependencies”- Requires:
config - Activation: always on (not toggleable)
Configuration
Section titled “Configuration”Per-tenant config keys, set via the tenant-admin UI or a seed. 🔒 = encrypted at rest.
| Key | Type | Default | Scope | Who can write | Who can read |
|---|---|---|---|---|---|
currency | select (EUR | USD | GBP | CHF | JPY | SEK | NOK | DKK | PLN | CZK | CAD | AUD | NZD | CNY | INR) | EUR | tenant | TenantAdmin, Admin, SystemAdmin | all |
locale | select (de | en | es) | en | tenant | TenantAdmin, Admin, SystemAdmin | all |