Skip to content

MQT-schemas bump + tests#473

Merged
CarlosGamero merged 8 commits into
mainfrom
fix/schemas_bump_and_tests
Jun 12, 2026
Merged

MQT-schemas bump + tests#473
CarlosGamero merged 8 commits into
mainfrom
fix/schemas_bump_and_tests

Conversation

@CarlosGamero

@CarlosGamero CarlosGamero commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

The bump will be done before merging and once #472 is mergeg

Summary by CodeRabbit

  • Tests

    • Added type test suites to verify type inference for domain events and message handlers.
  • Chores

    • Updated message-queue-toolkit/schemas dependency to version 7.2.0.

CarlosGamero and others added 5 commits June 11, 2026 16:57
Consumers receive messages that have already been parsed by the consumer
schema, so ConsumerMessageSchema and AllConsumerMessageSchemas should
resolve to z.output rather than z.input.

For schemas without transforms both types are identical, so this changes
nothing. They diverge once a schema uses transforms or preprocess (e.g. a
field that tolerantly drops unknown enum values): there z.input degrades
to unknown and breaks typing in message handlers, while the handler
actually receives the parsed output.

Publisher-side types intentionally stay z.input, since publishers pass
the raw payload that the schema parses on emit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@CarlosGamero CarlosGamero self-assigned this Jun 11, 2026
@CarlosGamero CarlosGamero changed the title MQT/schemas bump + tests MQT-schemas bump + tests Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 97d32f10-a867-4850-98bb-8dda39565b3d

📥 Commits

Reviewing files that changed from the base of the PR and between c1853e4 and 57d61fa.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/core/lib/events/DomainEventEmitter.types.spec.ts
  • packages/core/package.json
  • packages/core/test/queues/HandlerContainer.types.spec.ts

📝 Walkthrough

Walkthrough

This PR adds type-test suites verifying that event emitters and message handlers correctly infer handler input and emit output types from Zod schemas that use preprocessing transforms. A dependency update to @message-queue-toolkit/schemas ^7.2.0 enables schema transformation support, with two new type-test files confirming handlers receive parsed/transformed schema output types.

Changes

Type Verification for Schema Transformations

Layer / File(s) Summary
DomainEventEmitter transformation type tests
packages/core/package.json, packages/core/lib/events/DomainEventEmitter.types.spec.ts
Dependency version bumped to ^7.2.0. New Vitest type-test suite defines transformingEvent schema with preprocessing that normalizes mode to z.literal('live').optional(). Three test cases use expectTypeOf to verify handler on()/onAny() input types and emit() output types reflect the schema's transformed payload.mode type ('live' | undefined).
MessageHandlerConfigBuilder transformation type verification
packages/core/test/queues/HandlerContainer.types.spec.ts
New type test for MessageHandlerConfigBuilder verifies handler message type inference from schema output type when schema transforms input via z.preprocess. Defines job.scheduled schema with preprocessing and asserts handler receives transformed output type ('fast' | undefined) rather than raw input type.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • kibertoad/message-queue-toolkit#472: The new type tests directly validate the type system fix from PR #472 that makes consumer message schemas use z.output (parsed) instead of z.input (raw), affecting inferred handler payload types.

Suggested labels

minor

Suggested reviewers

  • kibertoad

Poem

🐰 A schema transforms, and types align,
Through preprocess pipes so fine,
Handlers now know what they shall receive,
No raw confusion to deceive!
From input coarse to output neat,
Type tests make the circle complete. ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/schemas_bump_and_tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@CarlosGamero CarlosGamero requested a review from kibertoad June 11, 2026 15:55
@CarlosGamero

Copy link
Copy Markdown
Collaborator Author

CI is red because core's type tests exercise the new z.output consumer types, but core resolves @message-queue-toolkit/schemas from the npm registry (^7.0.0), which still ships the old z.input types. This will resolve itself once #472 is merged and a new schemas version is published — I've verified locally that all type tests pass when core compiles against the fixed schemas package.

Base automatically changed from fix/consumer-message-schema-output-type to main June 12, 2026 14:16
@CarlosGamero CarlosGamero marked this pull request as ready for review June 12, 2026 14:25
@CarlosGamero CarlosGamero merged commit a8b3fca into main Jun 12, 2026
8 of 9 checks passed
@CarlosGamero CarlosGamero deleted the fix/schemas_bump_and_tests branch June 12, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants