- KV: one write primitive, write(changes) with { key, value? }; writeIfAbsent removed.
The server executes exactly what clients send and never reads values, so they can be
encrypted end to end. Adds setFields/getFields on the base class.
- HTTP: no server history or event ids; SSE relays every change (own writes included) and
the client emits resync when a dropped stream reconnects.
- Composite: writes apply locally, then go to the source (undone locally if refused);
pushed changes are applied and announced only where they differ from local values;
offline writes go to a queue store (any KV storage); sync() = replay, diff, replay.
Removes KVReplicaSet, KVOutbox, KeyCounter, SerialQueue and RetryTimer.
- Events: id = <time>_<sha256(time + canonical data)>, so concurrent appends never
collide and retries can't duplicate; no versions or ConcurrencyError.
- Event-sourced documents: read, resolve, append, apply; catchUp folds in foreign events;
getAt takes an event id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qxbkp4tA7G5SCWjzWuxmE
27 lines
784 B
TypeScript
27 lines
784 B
TypeScript
/** A key argument was passed but is `undefined`/`null`, empty, or not a string/number. */
|
|
export class InvalidKeyError extends TypeError {
|
|
constructor(message: string) {
|
|
super(message)
|
|
this.name = 'InvalidKeyError'
|
|
}
|
|
}
|
|
|
|
/** A remote storage could not be reached (network failure or 502/503/504). Writes may be retried later. */
|
|
export class StorageUnavailableError extends Error {
|
|
constructor(message: string, options?: { cause?: unknown }) {
|
|
super(message, options)
|
|
this.name = 'StorageUnavailableError'
|
|
}
|
|
}
|
|
|
|
/** A request was not authenticated (401) or not allowed for this caller (403). */
|
|
export class AuthError extends Error {
|
|
constructor(
|
|
readonly status: 401 | 403,
|
|
message: string,
|
|
) {
|
|
super(message)
|
|
this.name = 'AuthError'
|
|
}
|
|
}
|