cultnet-ts: the registry decodes the value a raw put would store
CultNetDocumentRegistry.decodeRawDocumentPut returns the binding and value applyRawDocumentPutMessage would store for a raw put, so a server can build the receipt that would acknowledge a put before storing it. It throws, as the put would, when no binding accepts the document. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ee593f392e
commit
6861b55db3
1 changed files with 14 additions and 0 deletions
|
|
@ -268,6 +268,20 @@ export class CultNetDocumentRegistry {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The binding and value `applyRawDocumentPutMessage` would store for this raw
|
||||
* put, decoded as that binding reads it. A server uses it to build the reply
|
||||
* that would acknowledge the put before storing it. Throws, as the put would,
|
||||
* when no binding accepts the document.
|
||||
*/
|
||||
decodeRawDocumentPut(message: CultNetDocumentPutRawMessage): {
|
||||
binding: CultNetDocumentBinding;
|
||||
value: unknown;
|
||||
} {
|
||||
const { binding, envelope } = this.#rawPutEnvelope(message);
|
||||
return { binding, value: decodeDocumentValue(binding.definition, envelope.payload) };
|
||||
}
|
||||
|
||||
#rawPutEnvelope(message: CultNetDocumentPutRawMessage): {
|
||||
binding: CultNetDocumentBinding;
|
||||
envelope: CultCacheEnvelope;
|
||||
|
|
|
|||
Loading…
Reference in a new issue