Skip to content

fix: tighten v2 wrapper event typing#316

Draft
CorieW wants to merge 3 commits into
masterfrom
codex/tighten-wrapped-v2-function
Draft

fix: tighten v2 wrapper event typing#316
CorieW wants to merge 3 commits into
masterfrom
codex/tighten-wrapped-v2-function

Conversation

@CorieW
Copy link
Copy Markdown
Member

@CorieW CorieW commented May 28, 2026

Summary

Touches on #205

  • Tighten WrappedV2Function so wrapper arguments must keep CloudEvent shape.
  • Preserve flexible data overrides for generated mock payloads and JSON test data.
  • Add a compile-time regression check showing wrapped({ data: change }) is valid while raw wrapped(change) is rejected.

Why

V2 wrapped functions accept CloudEvent partials, but the previous DeepPartial<T | object> type let callers pass raw event data. For Firestore change triggers, that makes wrapped(change) compile even though runtime code reads cloudEventPartial.data and falls back to example data.

Validation

  • npm run pretest
  • npm run lint
  • env -u GOOGLE_APPLICATION_CREDENTIALS npm test

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the WrappedV2Function type in src/v2.ts to use a new WrappedV2CloudEventPartial type, ensuring that V2 wrappers accept CloudEvent partials rather than raw event data. In the test suite, a helper function assertWrappedV2FunctionTypes was added to assert these types. However, this helper function is currently unused, resulting in dead code. It is recommended to wrap these type assertions directly in a standard Mocha it block to ensure they are executed and to prevent potential linter or compiler warnings.

Comment thread spec/v2.spec.ts Outdated
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.

2 participants