feat(core): MessagePack serialization (toMsgPack, path instead of ref, no nulls) #60

Merged
crapougnax merged 1 commit from feat/msgpack-serialization into develop 2026-11-17 10:45:01 +00:00
Owner

Context

MessagePack C# clients (totalymage/Application#2) cannot use ref (C# reserved keyword) and misread null values. Required by totalymage/backend#208.

Changes

  • ObjectUri.toMsgPack(): { path, label, backend? }, derived from toJSON() through the static helper ObjectUri.toMsgPackReference() (renames ref to path).
  • AbstractObject.toMsgPack(): delegates to uri.toMsgPack().
  • DataObject.toMsgPack(params): same output as toJSON(params) (single shared _serialize()), with ignoreNulls forced (null keys are omitted) and ref renamed to path on ObjectProperty values.
  • DataObject.populateFromData() also accepts { path, label } as input (payloads sent by MessagePack clients).
  • toMsgPack() added to the DataObjectType / DataObjectClass interfaces.

No duplication of _dataToJSON: PersistedDataObject inherits the behaviour unchanged.

Tests

  • ObjectUri.toMsgPack() (with backend)
  • BaseObject / DataObject: path instead of ref, null omission, { path, label } accepted as input
  • packages/core and packages/backend suites green, except MockAdapter.test.ts which already fails on develop (broken @quatrain/core/src import).

Out of scope (separate ticket)

PersistedDataObject._dataToJSON uses prop.val() || null: 0, '' and false become null (and are therefore omitted in MessagePack).

🤖 Generated with Claude Code

https://claude.ai/code/session_015r3zvThmkuw3hwy2db1pyg

## Context MessagePack C# clients (totalymage/Application#2) cannot use `ref` (C# reserved keyword) and misread `null` values. Required by totalymage/backend#208. ## Changes - `ObjectUri.toMsgPack()`: `{ path, label, backend? }`, derived from `toJSON()` through the static helper `ObjectUri.toMsgPackReference()` (renames `ref` to `path`). - `AbstractObject.toMsgPack()`: delegates to `uri.toMsgPack()`. - `DataObject.toMsgPack(params)`: same output as `toJSON(params)` (single shared `_serialize()`), with `ignoreNulls` forced (null keys are omitted) and `ref` renamed to `path` on `ObjectProperty` values. - `DataObject.populateFromData()` also accepts `{ path, label }` as input (payloads sent by MessagePack clients). - `toMsgPack()` added to the `DataObjectType` / `DataObjectClass` interfaces. No duplication of `_dataToJSON`: `PersistedDataObject` inherits the behaviour unchanged. ## Tests - `ObjectUri.toMsgPack()` (with backend) - `BaseObject` / `DataObject`: `path` instead of `ref`, null omission, `{ path, label }` accepted as input - `packages/core` and `packages/backend` suites green, except `MockAdapter.test.ts` which already fails on `develop` (broken `@quatrain/core/src` import). ## Out of scope (separate ticket) `PersistedDataObject._dataToJSON` uses `prop.val() || null`: `0`, `''` and `false` become `null` (and are therefore omitted in MessagePack). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015r3zvThmkuw3hwy2db1pyg
feat(core): add toMsgPack() serialization using path instead of ref on ObjectUri
All checks were successful
Quatrain Core CI / Monorepo Build, Tests & Quality Audit (push) Successful in 2m47s
Quatrain Core CI / Publish Changed Packages to npm (push) Has been skipped
Quatrain Core CI / Monorepo Build, Tests & Quality Audit (pull_request) Successful in 2m57s
Quatrain Core CI / Publish Changed Packages to npm (pull_request) Has been skipped
d4a402f79e
- Add toMsgPack() on ObjectUri (@quatrain/types) returning { path, label } (and backend if defined) to avoid colliding with the C# reserved keyword 'ref'
- Add toMsgPack() on AbstractObject, DataObject, BaseProperty, ObjectProperty, MapProperty (@quatrain/core) and PersistedDataObject (@quatrain/backend)
- Support hydrating ObjectUri from { path, label } references in DataObject.populateFromData()
- Add unit tests for ObjectUri.toMsgPack(), BaseObject.toMsgPack(), and DataObject.toMsgPack()
crapougnax merged commit 6346b0e477 into develop 2026-11-17 10:45:01 +00:00
crapougnax deleted branch feat/msgpack-serialization 2026-11-17 10:45:01 +00:00
Sign in to join this conversation.
No description provided.