feat(roles): roles remember the jobs they follow (re-appliable), every role edit is signed
Closes the permissions-matrix loose ends (venue-modules.md §Permissions matrix): - `role_jobs` (migration 0029): a role stores the manifest jobs it was composed from (chips on at save + any bundle fully present). `jobById` / `jobsBehind` in @parking/shared surface a followed job whose bundle grew past the role in a later release; the roles list shows a "behind <job>" badge with a one-click "Update to job" (the union, nothing removed) and the editor lints it. Never a runtime union: the grid stays the explicit enforcement layer and an update never widens a role without a click. - Every role create/update/delete appends a `config_change` (`role.<id>`, prev/value = name + sorted permissions + jobs, operator); a no-op resave signs nothing. roleRoutes now takes the ledger. - booth-supervisor already carries subscription:*; the stale open note is closed. Tests: routes/roles.test.ts. Wiki: venue-modules status, local-jwt-auth, log. Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU
This commit is contained in:
+5
-2
@@ -213,6 +213,9 @@ export interface ManagedRole {
|
||||
name: string;
|
||||
builtin: boolean;
|
||||
permissions: Permission[];
|
||||
/** The manifest JOBS this role follows (composed from their chips). A later release
|
||||
* that grows a job shows the role as "behind" it — re-applied with one click. */
|
||||
jobs: string[];
|
||||
userCount: number;
|
||||
}
|
||||
|
||||
@@ -241,10 +244,10 @@ export function deleteUser(id: string): Promise<{ ok: boolean }> {
|
||||
export function fetchRoles(): Promise<{ catalog: Permission[]; roles: ManagedRole[] }> {
|
||||
return apiFetch("/api/roles");
|
||||
}
|
||||
export function createRole(body: { name: string; permissions: Permission[] }): Promise<ManagedRole> {
|
||||
export function createRole(body: { name: string; permissions: Permission[]; jobs?: string[] }): Promise<ManagedRole> {
|
||||
return apiFetch("/api/roles", { method: "POST", body: JSON.stringify(body) });
|
||||
}
|
||||
export function updateRole(id: string, body: { name?: string; permissions?: Permission[] }): Promise<ManagedRole> {
|
||||
export function updateRole(id: string, body: { name?: string; permissions?: Permission[]; jobs?: string[] }): Promise<ManagedRole> {
|
||||
return apiFetch(`/api/roles/${id}`, { method: "PUT", body: JSON.stringify(body) });
|
||||
}
|
||||
export function deleteRole(id: string): Promise<{ ok: boolean }> {
|
||||
|
||||
Reference in New Issue
Block a user