/** * Wrapped `useShape`: same signature as `@ng-org/orm`. When a read-cap policy is * declared, the returned set is a read-filtered VIEW (only items in documents the * current user holds a ReadCap for); otherwise it passes the real set through * unchanged. At migration the filtering disappears — the broker only delivers * authorized documents. */ import { getConfig, getCurrentUser, getCaps } from "./polyfill"; import { makeReadFilteredView } from "./read-filter"; export function useShape(shapeType: unknown, scope: unknown): unknown { const set = getConfig().useShape(shapeType, scope) as object; const caps = getCaps(); if (!caps.hasReadPolicy()) return set; // no policy configured → passthrough return makeReadFilteredView(set, caps, getCurrentUser); }