s-m-r-t
Open the s-m-r-t source on GitHub Switch to dark color scheme
← All packages
Foundation v0.57.40 New

@happyvertical/smrt-preferences

Saved user-interface preferences: tenant defaults and per-user overrides for overview layouts and the app frame, validated per registered kind.

Source ↗

What it gives you

Saved user-interface preferences: tenant defaults and per-user overrides for overview layouts and the app frame, validated per registered kind.

  1. 01Two built-in kinds: overview (widget layout of a customizable overview page) and shell-layout (AdminShell settings)
  2. 02An organization sets the default; each person keeps their own version on top; reset returns to the layer below
  3. 03Every kind validates its payload on save and again on load; invalid data is refused or dropped and reported

Stores, not the model

createPreferenceStore, createOverviewStore, and createShellSettingsPreferences are the application API. The UiPreferenceRecord model refuses writes that do not come from the store and never returns another person’s preferences. Saves pass the revision they loaded; a stale revision returns conflict instead of overwriting.

Permissions are per kind

overviews.customize and shell.customize change the organization default; overviews.personalize and shell.personalize keep a personal version. Owners and admins receive all four when role permissions are seeded; members and viewers receive the two personalize slugs. The store reads them from the signed-in person’s permission set in the request context.

Register more kinds

registerPreferenceKind takes a kind name, a format version, the two permission slugs, and a validate function. The table _smrt_ui_preferences is created by smrt db:migrate, never at runtime.