Skip to content

Interface: PlasmaClient<S, M>

Defined in: client/src/sync/client.ts:389

S extends Schema<Record<string, AnyTable>>

M

readonly db: Db<S>

Defined in: client/src/sync/client.ts:390

mutate<K>(name, args): Promise<void>

Defined in: client/src/sync/client.ts:392

Enqueue and locally apply a mutation. Push is triggered automatically.

K extends string

K

MutatorArgs<M, K>

Promise<void>


newId(): string

Defined in: client/src/sync/client.ts:399

Generate a fresh id suitable for passing into a mutator’s args.id. Optimistic + canonical runs must agree on the id — the mutator itself only sees args, so ids MUST be produced at the call site (here) and threaded through. Uses crypto.randomUUID().

string


pullOnce(): Promise<void>

Defined in: client/src/sync/client.ts:401

Force a pull now; resolves when the patch has been applied locally.

Promise<void>


pushOnce(): Promise<void>

Defined in: client/src/sync/client.ts:403

Force a push of the current outbox now.

Promise<void>


start(): void

Defined in: client/src/sync/client.ts:405

Begin the background poll loop.

void


stop(): void

Defined in: client/src/sync/client.ts:407

Stop the background poll loop.

void


flush(): Promise<void>

Defined in: client/src/sync/client.ts:409

Await this before shutdown to make sure buffered writes have flushed.

Promise<void>


resetLocalState(): Promise<void>

Defined in: client/src/sync/client.ts:423

Clear every locally-cached row + the pull cookie + the outbox + every blob-related store so the client re-hydrates from the server on its next pull. Used by onSchemaMismatch returning "reset" and callable directly for user-initiated resets. The clientID is deliberately rotated during reset — keeping the old id would leave the server’s last_mutation_id watermark at N, so every re-numbered post-reset mutation (1..N) would silently drop as a duplicate. The clientGroupID is untouched.

Throws when PlasmaClientOptions.offline is true — the offline outbox is unrecoverable without a server to re-hydrate from.

Promise<void>


readFile(ref, options?): Promise<PlasmaFileReadResult>

Defined in: client/src/sync/client.ts:431

Read the bytes for a FileRef — either from local IndexedDB cache (upload-in-flight or previously fetched) or from the sync API, caching the result on the way through. BrokenFileRef sentinels decode to { status: "missing" } so a corrupt manifest cell never throws at the call site.

FileRef | BrokenFileRef

AbortSignal

Promise<PlasmaFileReadResult>


retryBlobUpload(hash): Promise<void>

Defined in: client/src/sync/client.ts:441

Reset a failed blob upload back to queued and nudge the upload worker. Intended for a UI “Retry” affordance after the user has addressed whatever produced the permanent failure (regained connectivity, freed R2 quota, resigned auth, …).

string

Promise<void>


discardMutation(mutationID): Promise<void>

Defined in: client/src/sync/client.ts:450

Abandon a queued mutation. Removes it from the outbox and drops its blob dependency mapping. Local bytes in _plasma_blobs_local are kept — they are content-addressed and may be shared with other mutations. The mutation’s local optimistic effect is not reverted here; call pullOnce() afterwards to let the server’s canonical state overwrite it.

number

Promise<void>