Skip to content

Documentation / @super-line/server / CollectionPolicy

Interface: CollectionPolicy<Ctx, Row>

Defined in: collections/types.ts:108

Row-security policy for one collection (see ADR-0006, decision 7). Server-side only — callbacks, never serialized to clients. Deny-by-default: omit read and clients cannot read the collection at all; omit write and clients cannot write it. Server co-writes via srv.collection(n) bypass both.

Type Parameters

Ctx

Ctx = unknown

Row

Row = unknown

Properties

read?

optional read?: (principal, ctx) => Awaitable<Expr | undefined>

Defined in: collections/types.ts:115

A caller's visibility filter, ANDed into every snapshot, subscription, and change-route for that caller. Return undefined for "no filter" (the whole collection is visible). Return an Expr to restrict. Caveat: it is evaluated at subscribe time; principal-side state captured here (e.g. the caller's channel list) goes stale until the client resubscribes — row-side predicates re-evaluate on every change naturally.

Parameters

principal

string

ctx

Ctx

Returns

Awaitable<Expr | undefined>


write?

optional write?: (principal, op, next, prev, ctx) => Awaitable<boolean>

Defined in: collections/types.ts:120

Per-row write guard. next is the incoming row (absent on delete), prev the current row (absent on insert). Return false to reject the op — which aborts the whole atomic batch it belongs to.

Parameters

principal

string

op

WriteOp

next

Row | undefined

prev

Row | undefined

ctx

Ctx

Returns

Awaitable<boolean>

Released under the MIT License.