Guard / foldkit-guard/drizzle

GuardDrizzle

namespace · packages/guard/src/drizzle.ts:37

const GuardDrizzle = { visible }

In the guides

Members

GuardDrizzle.visible

function · packages/guard/src/drizzle.ts:54

visible<User, const Es extends ReadonlyArray<AnyEntity>>(
  policy: Policy<User>,
  entities: Es,
  options?: {
    readonly operators?: DrizzleOperators | undefined
  },
): {
  readonly [K in Es[number]['name']]: Visible
}

The visible rule of each of entities, the Entities as Guards.attach returned them, by name, for bind's storage. Checked here, before any request: a row guard this compiler cannot run, and an inherited Read whose Entity is not listed, has no Read rule, or leads back to itself, throw. operators is the SQL table each rule is checked against here and compiled by (the kernel's when not given), and the policy's table decides what a rule reads from the input alone, so a server that starts can compile every rule whatever table its bindings were given. Give it the bindings' SQL table, so a rule and a query over one operator compile it alike.

ts
const visible = GuardDrizzle.visible(Policy, [Todo, Project])
bind(Domain, { Todo: { table: todos, visible: visible.Todo, … }, … })