S
Store

API Reference

Current TypeScript client API reference for records, events, blobs, kv, sync, and migration planning.

createStore

import { createStore } from "@cuitty/store/client";

function createStore(config: StoreConfig): Promise<StoreClient>

Creates a local-first client. config.module is the namespace, config.profile selects local and remote adapters, and config.schema names the storage classes exposed by the client.

Records API

store.record(collection).put(id, value)

Write or overwrite a record. Returns a write receipt with operation metadata.

const users = store.record("users");
const receipt = await users.put("user:1", { name: "Alice" });
console.log(receipt.remoteState); // "queued"

store.record(collection).get(id)

Read a record by key. Returns null if the key does not exist.

const record = await users.get("user:1");

store.record(collection).delete(id)

Delete a record. Creates a tombstone for sync propagation.

store.record(collection).query(options?)

List records with optional exact-match filters, ordering, and limits.

const records = await users.query({
  where: { active: true },
  orderBy: [{ field: "name", direction: "asc" }],
  limit: 100,
});

Events API

store.event(stream).append(payload)

Append an immutable event to a stream.

const deploys = store.event("deploy");
await deploys.append({ version: "2.4.1" });

store.event(stream).query(options?)

Read events from a stream.

const events = await deploys.query({
  limit: 50,
  orderBy: [{ field: "createdAt", direction: "desc" }],
});

store.event(stream).appendBatch(payloads)

Append multiple immutable events and receive one write receipt for the batch.

Blobs API

store.blob(bucket).put(key, data, options?)

Write a blob from a string or Uint8Array.

store.blob(bucket).get(key)

Read a blob as an object containing key, body, checksum, and optional contentType.

store.blob(bucket).delete(key)

Delete a blob.

store.blob(bucket).signedUrl?.(key, options)

Generate a signed URL when the active blob adapter supports it.

KV API

store.kv(collection).set(key, value)

Set a JSON-serializable value.

store.kv(collection).get(key)

Get a value. Returns null if not found.

store.kv(collection).delete(key)

Delete a key.

store.kv(collection).entries(options?)

List key-value entries with query options.

Sync API

await store.sync.status();
await store.sync.flush();
await store.sync.pause();
await store.sync.resume();

Migration Planning API

const plan = await store.migrate.dryRun({
  from: "local.sqlite",
  to: "postgres.record",
  namespace: "users",
});