Skip to content

Add readable JSON and binary helpers to generated structs - #1

Merged
happyDemon merged 3 commits into
mainfrom
serialization-formats
Nov 9, 2026
Merged

happyDemon merged 3 commits into
mainfrom
serialization-formats

Conversation

@happyDemon

Copy link
Copy Markdown
Member

Generated structs gain toReadableJson(), toBytes() and fromBytes(), placed after the existing dense JSON methods. fromBytes() hydrates through the same path as the existing dense "from" method, so validation still applies where the generator validates. There's no fromReadableJson(): the existing dense "from" method already accepts readable JSON.

Enums get the same methods from @php-skir/generator-core 0.2.0 (dependency bumped to ^0.2.0). Integration tests round-trip structs and enums through bytes and check readable output against the runtime.

CI is red until php-skir/runtime#2 is merged and @php-skir/generator-core 0.2.0 is published (php-skir/generator-core#1). The lockfile references 0.2.0 without an integrity hash because it isn't published yet. Run npm install once after publishing to fill it in.

Generated structs now expose toReadableJson(), toBytes() and fromBytes() next to the dense JSON helpers. fromBytes() hydrates through makeFromSkirPayload(), so validation still applies. Requires @php-skir/generator-core ^0.2.0, which adds the same helpers to generated enums.
Locks @php-skir/generator-core 0.2.0 from the registry.
@happyDemon
happyDemon force-pushed the serialization-formats branch from e4575c7 to 500fdd6 Compare November 9, 2026 11:48
Linking the checkout directory duplicated zod types (TS2742) and
--package-lock=false crashes npm 10.9. A tarball installs like the published
package while still testing against generator-core main.
@happyDemon
happyDemon force-pushed the serialization-formats branch from bec8531 to 4b8b7bb Compare November 9, 2026 11:53
@happyDemon
happyDemon merged commit b9cf269 into main Nov 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant