refactor(core): allow SyncEvent.define and BusEvent.define to accept Effect Schema#23765
Open
kitlangton wants to merge 2 commits intodevfrom
Open
refactor(core): allow SyncEvent.define and BusEvent.define to accept Effect Schema#23765kitlangton wants to merge 2 commits intodevfrom
kitlangton wants to merge 2 commits intodevfrom
Conversation
d808041 to
b2e84cf
Compare
38eaf7d to
3871125
Compare
b2e84cf to
51334b9
Compare
e0c10e9 to
a097c74
Compare
63bd01a to
62d9778
Compare
a097c74 to
5f7efaf
Compare
Adds namedSchemaError helper that preserves the existing NamedError API surface (.Schema, .isInstance, .toObject, new X({...}, { cause })) while backing the schema with Schema.Struct under the hood. Wire shape stays {name, data}, so the OpenAPI output is byte-identical.
…Effect Schema Overloads BusEvent.define and SyncEvent.define so payload schemas can be passed as Effect Schema values directly. Effect Schemas are converted to Zod via the effect-zod walker since the sync/bus pipelines still use Zod internally. Migrates MessageV2.Event.* to use Schema.Struct directly instead of z.object with .zod references.
62d9778 to
68b3a39
Compare
5f7efaf to
b4b7500
Compare
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.
Stacked on #23764.
Overloads
BusEvent.defineandSyncEvent.defineso payload schemas can be passed as Effect Schema values directly. Effect Schemas are converted to Zod via theeffect-zodwalker since the sync/bus pipelines still use Zod internally for serialization and JSON Schema generation.Migrates MessageV2.Event.* payload schemas to use
Schema.Structdirectly instead ofz.object(...)with.zodreferences on each field.Design
BusEvent.defineandSyncEvent.definegain overloads that take eitherSchema.Top/Schema.Structor the original Zod shapes..astproperty to distinguish and converts viazod().Types.DeepMutableso inferred payload types stay mutable (matches pre-migration z.infer behavior).Acceptance check
bun typecheckclean.bun run test→ 2010 pass / 0 fail.bun dev generatebyte-identical to committedpackages/sdk/openapi.json.packages/sdk/js/src/v2/gen/types.gen.tsunchanged afterbun script/build.ts.Follow-up
Other modules' event definitions (
session/session.ts,session/status.ts,project/project.ts,permission/index.ts,question/index.ts, etc.) can now migrate to pass Schema directly whenever their payload schemas are already Schema-first. Not done in this PR to keep the diff small.