Files
deepseek-harness/packages/storage/domain/src/events.ts
T
imccyu 7c27107be4 feat(storage): domain data form — typed schemas over opaque KV units
ctx.storage.domain opens declared domains: zod value schemas parsed at
the durable boundary, one write chain per domain (update(fn) is the only
read-modify-write), domain/changed emitted per record after durability
(new snapshot + operation, no old value, per repo event convention).
Domain-to-backend routing is configuration (default backend + per-domain
overrides); unknown names and missing facets fail loud. Ships the
MemoryStorageBackend test helper and a runtime invariant asserting every
change event matches the in-memory state.
2026-07-25 11:08:04 +08:00

37 lines
1.4 KiB
TypeScript

/**
* Change-event vocabulary of the domain data form. Every durable write emits
* one event after the backend resolves durability, carrying the new snapshot
* and an operation discriminant — never the old value (a diffing consumer
* keeps its own previous snapshot). This is the event source for cross-process
* change push (RPC frames) in a later phase.
* @module @deepseek-ai/dsh-domain/src/events
*/
/** One durable domain change: a record upsert/delete or a global write. */
export interface DomainChanged {
/** Owning domain name. */
readonly domain: string
/** Table name; `''` for a global-singleton write. */
readonly table: string
/** Record key; `''` for a global-singleton write. */
readonly key: string
/** What happened: `put` covers insert and overwrite; `deleted` is a tombstone. */
readonly operation: 'put' | 'deleted'
/** The new snapshot; absent for `deleted`. */
readonly value?: unknown
}
declare module 'cordis' {
interface Events {
/**
* A domain record or the global singleton changed, emitted once per write
* strictly after the backend acknowledged durability. Events of one
* domain arrive in its write-chain order.
* @param change - domain, table (`''` for global), key (`''` for global),
* operation discriminant, and the new snapshot (absent for deletions).
* @mode emit
*/
'domain/changed'(change: DomainChanged): void
}
}