Skip to content
ContractSpec
Start here

Package manual · platform

·Interfaces, presentations and design

lib.personalized-presentation

Schema bridge, React provider and hook that resolve lib.personalization preferences and role variant overrides into cockpit-kit variant literals

platformlibraryv7.0.4stableservernode
@lssm-tech/lib.personalized-presentation
bun add @lssm-tech/lib.personalized-presentation
Package source ↗Manifest ↗

Manifest declarations describe the current workspace; they do not verify registry publication or runtime execution.

Package guide

Schema bridge, React provider/hooks, and contract-driven Layer 7 Personalized Presentation, DataView & Form Progressive Disclosure engine resolving @lssm-tech/lib.personalization preferences, RoleMorph overrides, subject-scoped saved filters, and accessibility overrides across react, markdown, and application/json targets.

Capabilities

  • Cockpit Variant Bridge (Phase 3): density, expansion, mapPreferencesToVariants, resolvePersonalizedVariants, PersonalizedSurfaceProvider, and usePersonalizedVariants.
  • DataView Personalization (Layer 7): resolvePersonalizedDataView and usePersonalizedDataView resolve adaptive field ordering (anchoring primaryField), summary vs detail field/section progressive disclosure, and validated saved filters (resolveSavedViewFilters, applyDataViewFilters).
  • Form Progressive Disclosure (Layer 7): resolvePersonalizedForm and usePersonalizedForm adapt field order, sections vs steps flow, and responsive columns while guaranteeing required, requiredWhen, completion-profile, readOnly, and unlisted fields are never dropped.
  • Multi-Target Parity (react | markdown | application/json): projectPersonalizedDataViewTarget and projectPersonalizedFormTarget emit consistent projections with recursive policy.pii redaction and target validation against PresentationSpec.targets.
  • Presentation-Only Authority Stamp: Every output carries { authority: 'presentation-only', canGrantAuthority: false }. Locked contract filters (filterScope.locked) and cross-subject saved-view isolation (viewerScope) cannot be bypassed.

Installation

json
"@lssm-tech/lib.personalized-presentation": "workspace:*"

Usage

Provider & Cockpit Variants

tsx
import {
  PersonalizedSurfaceProvider,
  usePersonalizedVariants,
  type PersonalizedRoleVariants,
} from "@lssm-tech/lib.personalized-presentation";

const roleVariants: PersonalizedRoleVariants = {
  operator: { components: { NavRail: { expansion: "collapsed" } } },
  executive: {
    surface: { expansion: "collapsed" },
    components: { MetricPanel: { density: "comfortable" } },
  },
};

function CockpitRoot({ children }: { children: React.ReactNode }) {
  return (
    <PersonalizedSurfaceProvider
      role="operator"
      prefs={userPrefs}
      roleVariants={roleVariants}
      viewerScope={{ tenantId: "org-1", subjectId: "user-1" }}
      accessibility={{ readableDensity: false }}
    >
      {children}
    </PersonalizedSurfaceProvider>
  );
}

Contract-Driven DataView, Form & Multi-Target Projection

ts
import {
  projectPersonalizedDataViewTarget,
  resolvePersonalizedDataView,
  resolvePersonalizedForm,
} from "@lssm-tech/lib.personalized-presentation";

const resolvedView = resolvePersonalizedDataView({
  spec: dataViewSpec,
  prefs: userPrefs,
  role: "analyst",
  viewerScope: { tenantId: "org-1", subjectId: "user-1" },
  userFieldOrder: ["status", "score"],
  savedView: {
    id: "view-1",
    dataViewKey: dataViewSpec.meta.key,
    scope: { tenantId: "org-1", subjectId: "user-1" },
    filters: { status: { kind: "single", value: "open" } },
  },
});

const markdown = projectPersonalizedDataViewTarget({
  target: "markdown",
  spec: dataViewSpec,
  resolved: resolvedView,
  items: records,
  presentation: presentationSpec,
});

const resolvedForm = resolvePersonalizedForm({
  spec: formSpec,
  prefs: userPrefs,
  accessibility: { singleColumn: true },
});

Precedence Order

  1. Segment defaults (segmentDataDepth, segmentFieldOrder, segmentFilters)
  2. Tenant reviewed config (tenantDataDepth, tenantFieldOrder, tenantFilters)
  3. User preference & RoleMorph (prefs, roleVariants, userFieldOrder, subject-scoped savedView)
  4. Accessibility overrides (accessibility.readableDensity, accessibility.singleColumn) — always wins over aesthetic compression while filterScope.locked and policy.pii remain immutable.

Wired vs Stub-Protected Dimensions

DimensionInput typeOutput type
densityPreferenceDimensions["density"]Density
expansionPreferenceDimensions["dataDepth"]Expansion

Unwired dimensions (verbosity, trigger, panelMode, enrichedKinds, perKindOptOut) remain stub-protected in ./schema/_stubs/* and throw if called at runtime.

Relationships

THIS PACKAGElib.personalized-presentation12 import paths

Arrows point from a package to its direct dependency. Counts are derived from captured workspace manifests.

2 declarations

Declared capabilities

Lib Personalized Presentation

Schema bridge, React provider and hook that resolve lib.personalization preferences and role variant overrides into cockpit-kit variant literals

Scripts

  • publish:pkgbun publish --tolerate-republish --ignore-scripts --verbose
  • publish:pkg:canarybun publish:pkg --tag canary
  • buildbun run prebuild && bun run build:bundle && bun run build:types
  • build:bundlecontractspec-bun-build transpile --no-bundle
  • build:typescontractspec-bun-build types
  • devcontractspec-bun-build dev
  • cleanrimraf dist .turbo
  • lintbun lint:fix
  • lint:fixnode ../../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../../scripts/biome.cjs check --write .
  • lint:checknode ../../../../scripts/biome.cjs check .
  • testbun test --pass-with-no-tests
  • prebuildcontractspec-bun-build prebuild
  • typechecktsgo --noEmit