Delete the text-scan payload guards, the schemaId overloads and the definition-less decode door
The two payload-decode-owner text-scan tests go, as do the string-schemaId overloads and branches of the cultMeshDocumentFrom* functions and statics, decodeCultMeshPayload, decodeCultNetRawDocumentPayload, toUint8Array, replication's second decodeDocumentValue, and the undefined branch of decodeDocumentPayload. decodeDocumentPayload now requires the definition and also runs its schema (the one reader). A publication binding names a definition, never a bare schema id; the RUDP put handler refuses a schema with no registered definition instead of plain-decoding it. Builds in every package; tests not yet rerun. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
294469e300
commit
a3a45c79eb
7 changed files with 105 additions and 463 deletions
|
|
@ -7,6 +7,7 @@ import type {
|
|||
CultCacheSchemaCatalogMember,
|
||||
CultCacheDocumentDefinition,
|
||||
CultCacheDocumentRegistry,
|
||||
CultCacheDocumentValue,
|
||||
CultCacheSchema,
|
||||
} from "./types";
|
||||
|
||||
|
|
@ -90,10 +91,13 @@ const plainDocumentFormatter: CultCacheDocumentFormatter<unknown> = {
|
|||
decode: (payload: Uint8Array) => decode(payload),
|
||||
};
|
||||
|
||||
// The one reader of a document payload outside the cache: through the definition's formatter, or as a plain msgpack
|
||||
// value when the caller holds no definition for the schema. Every package above the cache reads a payload through here.
|
||||
export function decodeDocumentPayload(definition: AnyCultCacheDocumentDefinition | undefined, payload: Uint8Array): unknown {
|
||||
return (definition ? resolveDocumentFormatter(definition) : plainDocumentFormatter).decode(payload);
|
||||
// The one reader of a document payload: through the definition's formatter, codec or plain map, then its schema. A
|
||||
// reader holds the definition or it has no business reading the bytes, so there is no definition-less form.
|
||||
export function decodeDocumentPayload<TDefinition extends AnyCultCacheDocumentDefinition>(
|
||||
definition: TDefinition,
|
||||
payload: Uint8Array,
|
||||
): CultCacheDocumentValue<TDefinition> {
|
||||
return definition.schema.parse(resolveDocumentFormatter(definition).decode(payload)) as CultCacheDocumentValue<TDefinition>;
|
||||
}
|
||||
|
||||
// The schema members of a document: the ones it declares, else those its codec derives, else none.
|
||||
|
|
|
|||
Loading…
Reference in a new issue