index ↓

store

client.store

requests

you ask, the daemon answers. await the tagged result and check .ok

get(KVGet): Promise<TypedRequestResult<StorageResponse, never>>

push form: onResponse (subscribe instead of awaiting)

const res = await client.store.get({ key: '...' });
if (res.ok) {
  console.log(res.response.key);
}

put(KVPut): Promise<TypedRequestResult<StorageResponse, never>>

push form: onResponse (subscribe instead of awaiting)

const res = await client.store.put({ key: '...', value: '...' });
if (res.ok) {
  console.log(res.response.key);
}

delete(KVDelete): Promise<TypedRequestResult<StorageResponse, never>>

push form: onResponse (subscribe instead of awaiting)

const res = await client.store.delete({ key: '...' });
if (res.ok) {
  console.log(res.response.key);
}

types

shapes referenced above, as the sdk types them

type KVGet = {
  key: string;
};
type StorageResponse = {
  key: string;
  value?: string; // `null` after a `delete`, or when `get` finds no entry.
};
type KVPut = {
  key: string;
  value: string;
};
type KVDelete = {
  key: string;
};