@cosmicdrift/kumiko-headless 0.319.0 → 0.320.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/nav/resolve.ts +5 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-headless",
3
- "version": "0.319.0",
3
+ "version": "0.320.0",
4
4
  "description": "Headless UI logic for Kumiko — Dispatcher contract, Form-Controller, View-Model, Nav-Resolver. Plattform- und React-frei; jeder Renderer (renderer, renderer-web, renderer-native, …) komponiert darauf.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -36,7 +36,7 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@cosmicdrift/kumiko-framework": "0.319.0",
39
+ "@cosmicdrift/kumiko-framework": "0.320.0",
40
40
  "temporal-polyfill": "^0.3.2",
41
41
  "zod": "^4.4.3"
42
42
  },
@@ -1,5 +1,5 @@
1
- import type { AccessRule, NavDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
2
- import { isOpenToAllGranted } from "@cosmicdrift/kumiko-framework/ui-types";
1
+ import type { NavDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
2
+ import { isUiAccessGranted } from "@cosmicdrift/kumiko-framework/ui-types";
3
3
  import type { NavNode, NavTree, ResolveNavigationOptions } from "./types";
4
4
 
5
5
  // Assembles the renderable nav tree from the registry's pre-grouped
@@ -16,7 +16,9 @@ export function resolveNavigation(options: ResolveNavigationOptions): NavTree {
16
16
  const { source, user } = options;
17
17
 
18
18
  function build(entry: NavDefinition): NavNode | null {
19
- if (!userCanSee(entry.access, user)) return null;
19
+ // Shared default-visible UI predicate, not hasAccess from the engine:
20
+ // that module pulls server-side deps and would break bundle purity.
21
+ if (!isUiAccessGranted(entry.access, user?.roles)) return null;
20
22
  // `entry.id` is already the qualified name — the registry stores
21
23
  // it that way. No reverse-index lookup needed.
22
24
  const children: NavNode[] = [];
@@ -56,27 +58,3 @@ function bySortKey(a: NavNode, b: NavNode): number {
56
58
  if (a.order !== b.order) return a.order - b.order;
57
59
  return a.qualifiedName.localeCompare(b.qualifiedName);
58
60
  }
59
-
60
- // Access evaluator. Duplicated minimal logic instead of importing
61
- // hasAccess from @cosmicdrift/kumiko-framework/engine at runtime — that module pulls
62
- // in server-side deps (tenant-db, ownership-evaluator) and would break
63
- // ui-core's bundle-purity guarantee. Only roles + openToAll are checked;
64
- // ownership-level row-filtering is a server-side concern and doesn't
65
- // apply to navigation entries (they're a menu, not a dataset).
66
- function userCanSee(
67
- access: AccessRule | undefined,
68
- user: ResolveNavigationOptions["user"],
69
- ): boolean {
70
- // No rule = always visible — matches the framework's "engine stays
71
- // un-opinionated about who sees what" stance in the nav docs.
72
- if (!access) return true;
73
- if ("openToAll" in access && isOpenToAllGranted(access)) return true;
74
- if (!user) return false; // anonymous can't match a role-gated rule
75
- if ("roles" in access) {
76
- const allowed = access.roles;
77
- for (const role of user.roles) {
78
- if (allowed.includes(role)) return true;
79
- }
80
- }
81
- return false;
82
- }