resolveTablePermissions
resolveTablePermissions(
grants,schema):Record<string,Record<CrudAction,boolean>>
Defined in: packages/permissions/src/resolve-table-permissions.ts:30
Resolves table-level CRUD permissions for every table in a schema.
Iterates each key in the schema map, extracts its table name, and calls
can for each of the four CRUD actions (read, create, update,
delete). Returns a flat, serializable map suitable for embedding in
loader data and sending to the client.
This is a pure grant-structural check — no database access, no SQL.
Row-level where clauses on grants are ignored; the result reflects
whether the user has any grant for the action on the table.
Parameters
Section titled “Parameters”grants
Section titled “grants”Grant[]
The user’s resolved permission grants.
schema
Section titled “schema”A schema map (e.g. import * as schema from "./schema").
Returns
Section titled “Returns”Record<string, Record<CrudAction, boolean>>
A record keyed by SQL table name, each mapping CRUD actions to booleans.
Example
Section titled “Example”import { resolveTablePermissions } from "@cfast/permissions";import * as schema from "../db/schema";
const perms = resolveTablePermissions(grants, schema);// { posts: { read: true, create: true, update: false, delete: false }, ... }