Skip to content

ViewPermissionCheck

ViewPermissionCheck<TUser, TOrg> = boolean | ((props) => boolean | undefined)

Defined in: packages/core/src/access/types.ts:220

Permission check shape for ViewActions (readViews/createView/ updateView/deleteView) — developer-reported: these actions type-accepted a FieldPermissionMap return value exactly like read/update do, which is meaningless for them. A saved view is a whole row in vex_views, never read/written per-field or per-document-field the way a collection’s own documents are — so neither a field map NOR the narrowing { where, filter, withIndex } object form (ConstrainedPermissionCheck, equally document-query-shaped) make sense here. Only a flat boolean, or a callback resolving to one (undefined still denies, same as every other check), is valid — a field map is now a compile error at the action itself.

Developer decision: the callback takes AccessRuleProps — user (plus organization when configured) ONLY, no data — a SINGLE props object shape matching every other permission callback, so a view property (the stored view the action targets) can be added here later without a breaking change. Per-view access (passing the stored view, plus an updatedBy field) is deferred to the backlog — NOT implemented here.

Runtime counterpart: hasPermission fails closed (with a dev warning) if a view-action rule returns a map anyway (untyped/JS config, or an as cast).

TUser = Record<string, unknown>

TOrg = Record<string, unknown>