refactor(sharing): read and judge grants from a leaf module

lib/sharing/grants.ts held both the grant transitions and the predicates
every reader asks (state, level, scope, the live grant for a pair). The
transitions reach into the managed-profile lifecycle and the OAuth connect
target, and both of those read a live grant, so grants, lifecycle and
connect-target formed an import cycle.

The predicates, findActiveGrant and touchGrantUsage move verbatim to
lib/sharing/grant-access.ts, which imports only the database client and
the scope vocabulary. Importers and the mocks that replaced those
functions point at the new module. Runtime import cycles fall from 7 to 6.
This commit is contained in:
Marc-André Bombeck committed 2026-10-23 11:02:10 +02:00
1 parent e84b80ee3c
commit 78ac2c5aeb
27 files changed
+315 -296

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ import {
grantCoversDomain,
touchGrantUsage,
type GrantNeed,
} from "@/lib/sharing/grants";
} from "@/lib/sharing/grant-access";
import type { ShareScope } from "@/lib/sharing/scope";
import { assertRecordSessionFence } from "@/lib/sharing/record-session-fence";
import {