Expand description
Per-tenant extensible fields for extensible JSON/JSONB columns.
A column declared "extensible": true in config becomes a extensible-fields bag: a JSON
document whose keys are defined per tenant in a KV-stored registry, not in the schema.
Those keys become first-class RSQL-filterable/sortable fields via the <column>.<key>
dotted syntax (e.g. q=attributes.warrantyMonths=ge=12, sort=-attributes.voltage).
§Registry storage
Definitions live in _sys_kv_data under the reserved namespace REGISTRY_NAMESPACE,
one row per entity keyed by the entity’s path_segment. The stored value maps each
extensible column name to its list of field definitions:
{
"attributes": [
{ "key": "warrantyMonths", "type": "int", "filterable": true, "sortable": true },
{ "key": "voltage", "type": "decimal" }
]
}Field keys are stored verbatim (no case conversion), so the convention is camelCase — that is exactly how they round-trip to API clients.
Structs§
- Cached
Registry - A cached registry plus the instant it was loaded (for TTL expiry).
- Extensible
Field Def - One extensible-field definition: its key, declared type, and validation/query flags.
- Extensible
Registry - Resolved extensible-field registry for a single entity: extensible column → (field key → def).
Enums§
- Validate
Mode - Validation mode:
Fullenforces required extensible fields (create);Partialvalidates only the fields present in the request (update/PATCH).
Constants§
- REGISTRY_
CACHE_ TTL - How long a cached registry stays valid before it is reloaded from the config DB. Bounds cross-instance staleness when another node updates the registry (single-instance updates are evicted immediately on write).
- REGISTRY_
NAMESPACE - Reserved KV namespace under which extensible-field registries are stored.
Functions§
- apply_
indexes - Execute index DDL statements against
pool, best-effort. Returns(applied, errors): statements that succeeded, and(statement, message)for those that failed (e.g. a MySQL “duplicate key name” when the index already exists). Never fails the whole batch on one error. - delete_
registry - Delete the registry document for one entity. Returns
truewhen a row was removed. - index_
ddl - Build
CREATE INDEXstatements for every filterable or sortable extensible field in the registry, one per (column, key), using the dialect’s typed JSON extraction so the index matches the expression the query builder emits. - load_
registry - Load the extensible-field registry for one entity from the KV store.
- load_
registry_ raw - Read the raw registry document for one entity (the value stored in
_sys_kv_data), orNonewhen no registry has been defined. Unlikeload_registry, this returns the untouched JSON for display in the admin API rather than the parsed/indexed structure. - store_
registry - Upsert the registry document for one entity into
_sys_kv_dataunder the reservedREGISTRY_NAMESPACE, keyed bypath_segment. Writes directly, bypassing the_sys_kv_storesnamespace check the public KV API enforces. - validate_
extensible_ fields - Validate the extensible-fields bags in a (snake_cased top-level) request body against the per-tenant registry. Rejects unknown keys, type mismatches, and constraint violations with HTTP 422. Plain (non-extensible) JSON columns are ignored entirely.
- validate_
registry_ document - Validate a raw registry document intended for
entity: it must be a JSON object whose top-level keys are all extensible columns on the entity, and whose values parse as field definition lists. Returns the validated registry on success (HTTP 422 on any problem).
Type Aliases§
- Registry
Cache - Process-shared, tenant-scoped registry cache keyed by
(tenant_id, package_id, path_segment). Lives onAppState; read-through on load, evicted on admin write.