/** * Wrapped `useShape`: same signature as `@ng-org/orm`. Once the cap emulation is * in force, the returned set is a read-filtered VIEW (only items in documents the * current holder has the ReadCap of); before the first cap is issued it passes the * real set through unchanged. At migration the filtering disappears — the broker * only delivers documents whose cap the wallet holds. */ import { getConfig, 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.isEnforcing()) return set; // no cap issued yet → passthrough return makeReadFilteredView(set, caps); }