feat!: useShapeQuery prend le Scope du SDK, et un store se nomme par sa reference
This commit is contained in:
@@ -85,7 +85,7 @@ import { hasReadCap, isNuri } from "../model/nuri";
|
||||
import { mintCap } from "../emulated-verifier/caps";
|
||||
import { mustNotAttempt } from "../emulated-verifier/reach";
|
||||
import { accessLogPrefix, logStage, shortNuri } from "./access-log";
|
||||
import type { InboxScope, Nuri, Scope } from "../model/types";
|
||||
import type { InboxScope, Nuri, StoreType } from "../model/types";
|
||||
|
||||
// --- sharedWalletShim model ----------------------------------------------
|
||||
|
||||
@@ -918,7 +918,7 @@ export async function isKnownInbox(nuri: Nuri): Promise<boolean> {
|
||||
}
|
||||
|
||||
/** The index document NURI of an account for a scope (the store-container). */
|
||||
export function storeOf(record: VirtualUserRecord, scope: Scope): Nuri {
|
||||
export function storeOf(record: VirtualUserRecord, scope: StoreType): Nuri {
|
||||
return scope === "public"
|
||||
? record.docPublic
|
||||
: scope === "protected"
|
||||
@@ -931,7 +931,7 @@ export function storeOf(record: VirtualUserRecord, scope: Scope): Nuri {
|
||||
* per-scope index document, for entities that need no per-entity document / no
|
||||
* inbox). For per-entity scopes use {@link createEntityDoc} instead.
|
||||
*/
|
||||
export async function resolveWriteGraph(id: string, scope: Scope): Promise<Nuri> {
|
||||
export async function resolveWriteGraph(id: string, scope: StoreType): Promise<Nuri> {
|
||||
const record = await ensureAccount(id);
|
||||
return storeOf(record, scope);
|
||||
}
|
||||
@@ -952,7 +952,7 @@ export async function resolveWriteGraph(id: string, scope: Scope): Promise<Nuri>
|
||||
|
||||
/** The native store NURI backing `scope`, resolved from the injected session.
|
||||
* Requires `protectedStoreId` on the session for the non-private scopes. */
|
||||
async function scopeStoreNuri(scope: Scope): Promise<Nuri> {
|
||||
async function scopeStoreNuri(scope: StoreType): Promise<Nuri> {
|
||||
const s = await session();
|
||||
if (scope === "private") return `did:ng:${s.privateStoreId}`;
|
||||
// public + protected → the protected native store (see note above). Falls
|
||||
@@ -969,7 +969,7 @@ async function scopeStoreNuri(scope: Scope): Promise<Nuri> {
|
||||
* (`useShape(shape, nuri)`) and the `@graph` write target.
|
||||
*/
|
||||
// @provenance storeRegistry.resolveScopeGraph kind=aligned level=2 ref=sdk/js/web/src/index.ts:Session — `did:ng:` + `private_store_id | protected_store_id | public_store_id`, straight off the session
|
||||
export async function resolveScopeGraph(scope: Scope): Promise<Nuri> {
|
||||
export async function resolveScopeGraph(scope: StoreType): Promise<Nuri> {
|
||||
return scopeStoreNuri(scope);
|
||||
}
|
||||
|
||||
@@ -1037,7 +1037,7 @@ const inboxCache = new Map<string, Nuri>();
|
||||
* says anything about inboxes — `@ng-org/web` has no method containing "inbox" and the
|
||||
* session exposes none — so the engine's model is what decides, and it says two.
|
||||
*
|
||||
* **The private store has none**, hence {@link InboxScope} rather than `Scope`: asking
|
||||
* **The private store has none**, hence {@link InboxScope} rather than `StoreType`: asking
|
||||
* for a private inbox is not a lookup that returns nothing, it is a question the model
|
||||
* has no meaning for.
|
||||
*
|
||||
@@ -1140,7 +1140,7 @@ export async function userInbox(id: string, scope: InboxScope): Promise<Nuri> {
|
||||
* it does not carry its key. The key goes to what the creator holds (see
|
||||
* {@link holdOwnCap}), which is where you look it up.
|
||||
*/
|
||||
export async function createEntityDoc(id: string, scope: Scope): Promise<Nuri> {
|
||||
export async function createEntityDoc(id: string, scope: StoreType): Promise<Nuri> {
|
||||
const record = await ensureAccount(id);
|
||||
const indexDoc = storeOf(record, scope);
|
||||
const entityNuri = await createDoc();
|
||||
@@ -1273,7 +1273,7 @@ export async function readUserStore(indexDoc: Nuri): Promise<Nuri[]> {
|
||||
* user's real per-scope store NURI (the container the store itself provides).
|
||||
*/
|
||||
// @provenance userStoreDoc kind=aligned level=2 ref=sdk/js/web/src/index.ts:Session — the per-scope index document stands in for the store the session names directly
|
||||
export async function userStoreDoc(id: string, scope: Scope): Promise<Nuri> {
|
||||
export async function userStoreDoc(id: string, scope: StoreType): Promise<Nuri> {
|
||||
const record = await ensureAccount(id);
|
||||
return storeOf(record, scope);
|
||||
}
|
||||
@@ -1300,7 +1300,7 @@ export async function userStoreDoc(id: string, scope: Scope): Promise<Nuri> {
|
||||
* Nothing to list is NOT a failure and stays silent: a store that answers with zero
|
||||
* documents means this account created none, which is a fact.
|
||||
*/
|
||||
export async function listMyEntityDocs(id: string, scope: Scope): Promise<Nuri[]> {
|
||||
export async function listMyEntityDocs(id: string, scope: StoreType): Promise<Nuri[]> {
|
||||
const record = await ensureAccount(id);
|
||||
const store = storeOf(record, scope);
|
||||
const docs = await readUserStore(store);
|
||||
|
||||
Reference in New Issue
Block a user