Sanity Library Reference Docs
    Preparing search index...
    type GuardHelpers = {
        activeGuardsForDocument: (
            documentId: string,
            as?: Actor,
        ) => Promise<MutationGuardDoc[]>;
        editDocument: (
            opts: {
                action?: EditDocumentAction;
                as?: Actor;
                documentId: string;
                patch?: EditDocumentPatch;
            },
        ) => Promise<StoreDocument | undefined>;
        listGuards: () => Promise<MutationGuardDoc[]>;
    }
    Index

    Properties

    activeGuardsForDocument: (
        documentId: string,
        as?: Actor,
    ) => Promise<MutationGuardDoc[]>

    Guards that would deny an arbitrary edit to documentId right now (i.e. active locks). Probes by changing every non-system field; a guard whose predicate is "true" returns nothing.

    editDocument: (
        opts: {
            action?: EditDocumentAction;
            as?: Actor;
            documentId: string;
            patch?: EditDocumentPatch;
        },
    ) => Promise<StoreDocument | undefined>

    Write to a document through the client's guarded write seam. The bench client gates the write against deployed guards (incl. identity()) and throws the package's re-exported GuardDeniedError on denial — the lake-shaped rejection simulated by the bench. as routes the write through a token-scoped sibling so identity() resolves to that actor.

    Each EditDocumentAction performs that real write, so a guard scoped to its underlying lake mutations is genuinely consulted: update (default) applies patch; delete deletes; publish promotes the existing draft (drafts.<documentId>) onto documentId and deletes the draft; unpublish creates the draft and deletes documentId. documentId is always the published id. A patch (EditDocumentPatch) is required for update and rejected for every other action — the combination is contradictory input.

    Resolves to the post-write document as the DEFAULT identity reads it — undefined after delete/unpublish (the doc is gone), or when the default identity cannot read the written doc.

    listGuards: () => Promise<MutationGuardDoc[]>

    All deployed guard docs (MutationGuardDoc) in the store.