feat(core): single MessagePack wire contract with refAsPath option #82
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
qa:preview
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
quatrain/core!82
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude-bot/feat/msgpack-lowest-level-normalizer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
MessagePack payloads only got
pathinstead ofrefwhen they still held live objects exposingtoMsgPack(). References already serialized by a handler (toJSON(),toReference(), plain literals) kept theirrefkey, so clients received a mix of both.This moves the MessagePack wire contract to a single function in
@quatrain/coreand reduces the HTTP layer to negotiation and encoding.Changes
@quatrain/core:normalizeForMsgPack(value, options)enforces the contract on any value, whatever produced it:toMsgPack()/toJSON()are applied and their output is normalized again;refkey is emitted aspath, at any depth (arrays,Map,Set, nested objects);null,undefined, functions, symbols and circular references are omitted;bigintis converted.refAsPathoption (defaulttrue):{ refAsPath: false }keepsref. It is handed down totoMsgPack()onObjectUri,AbstractObjectandDataObject, so live objects and serialized references give the same result.@quatrain/http:msgPackContentNegotiation(options)creates a framework-agnostic middleware (structural request/response types, no Express dependency) that decodes MessagePack request bodies and encodesres.json()/res.send()payloads when the client asks for MessagePack.@quatrain/types:MsgPackOptionstype;ObjectUri.toMsgPackReference()no longer overwrites an existingpathkey and ignores arrays.packages/http/tsconfig.jsonnow resetspathsand excludes tests from the build, like its sibling packages.Behaviour to review
reftopathrule applies to any dictionary carrying arefkey, not only to dictionaries shaped like a reference.refandpathis left untouched.nullitems are removed from arrays, which shifts indexes.Validation
jest packages/http packages/core packages/types packages/backend/src: 28 suites, 194 tests passing.turbo run build --filter=...@quatrain/types: 76 packages built.RequestHandler.jestrun: the only failing suites are the Firestore and Postgres integration tests, which need a live database and fail the same way ondevelop.Supersedes
Branch
feat/msgpack-content-negotiation(Express-specific middleware in@quatrain/api-server-express), which can be deleted.The `ref` to `path` rule stays on by default and can now be turned off per application: normalizeForMsgPack(value, { refAsPath: false }). The option is handed down to toMsgPack() on ObjectUri, AbstractObject and DataObject, so live objects and already serialized references give the same result. msgPackContentNegotiation() in @quatrain/http becomes a factory taking the same options. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>