Skip to content

Interface: PlasmaClient<S, M>

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

S extends Schema<Record<string, AnyTable>>

M

readonly db: Db<S>

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


readonly userActionRequired: boolean

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

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

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

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:433

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:435

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

Promise<void>


pushOnce(): Promise<void>

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

Force a push of the current outbox now.

Promise<void>


start(): void

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

Begin the background poll loop.

void


stop(): void

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

Stop the background poll loop.

void


flush(): Promise<void>

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

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

Promise<void>


getOutboxDepth(): Promise<number>

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

Read the current number of un-confirmed mutations in the outbox. Useful for a “N unsaved changes” UI hint or a shutdown gate. Reads IDB, so treat as async — expect single-digit-ms latency.

Promise<number>


getPendingResetDiagnostics(): Promise<PendingResetDiagnostics>

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

Promise<PendingResetDiagnostics>


resetLocalState(): Promise<void>

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

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:472

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:482

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:491

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>