refactor(sync): make session events schema-first - #24019
Merged
Merged
Conversation
Teach SyncEvent definitions to accept Effect Schema payloads, migrate Session.Event.Created/Updated/Deleted off zod wrappers, and thread the bus-facing payload type through sync definitions. This removes the last zodObject/updateSchema interop from session.ts and lets session.updated emit a true patch shape, which changes the generated SDK type from required-nullable fields to optional-nullable fields.
Migrate message-v2 sync event payloads to Effect Schema and remove the mixed zod/Schema path from SyncEvent definitions. - SyncEvent.define now accepts Effect Schema only and stores the original effect schema alongside derived zod objects for runtime/bus use. - Bus payload typing derives from effectProperties directly; the old phantom _data/_propertiesData fields are gone. - sync tests now define events with Schema.Struct, matching production. This completes the sync-event side of the session/message schema migration and removes the last reason for SyncEvent to accept zod.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SyncEvent.define(...)to work from native Effect Schema payloads and derive zod internally for runtime/bus compatibilitySession.Event.Created,Updated, andDeletedto Schema payloadsMessageV2.Event.Updated,Removed,PartUpdated, andPartRemovedto Schema payloads tooWhat this finishes
This PR completes the sync-event side of the session/message Effect Schema migration:
SyncEventis now Schema-only at the definition layerz.ZodObject | Effect Schemapath is gone_data/_propertiesDatafields are goneeffectPropertiesschema directlyFollow-on cleanup included
updateSchema(zodObject(...))interop fromsession.tsdef.propertieson the bus publish pathisRecord(...)for sync conversion object checkssession.get(...)read inshare-nextSession.Patchin the session projectorSchema.Struct(...), matching productionBehavior change
This changes the generated SDK type for
session.updatedpatches:data.infowere required and nullabledata.infoare optional and nullableExample:
title: string | nulltitle?: string | nullThis matches the actual patch semantics more closely:
key: null= clearedkey: value= updatedVerification
bun typecheck./packages/sdk/js/script/build.ts