Repository navigation
feat(api): add the invitation event contract - #2930
Conversation
Declare invitation.created, invitation.accepted, invitation.rejected and invitation.cancelled with the payloads from ADR 086 §5. They sit in the events catalog's Contracted section until the invitation service emits them (#2852, #2853). Payloads never carry metadata or the token. The type objects reuse the invitation resource's project_member and team_member schemas. Closes #2850 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: fdc76c5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
🟡 Changes recommended
The invitation event payloads allow missing or mismatched member objects for their declared type, so consumers may not receive the promised grant details.
1 open issue
2 files not reviewed
packages/go/api/oas_interfaces_gen.go: Generated filepackages/go/api/oas_operations_gen.go: Generated file
What changed in this PR
Publishes the invitation event contract for the events API and webhooks, preparing clients for the invitation producers planned in #2852 and #2853. No events are emitted yet.
Changes:
- Defines four invitation events and their payloads, excluding invitation metadata and tokens.
- Adds shared Go payload structs and regenerates API schemas and client types.
- Documents the contracted events and adds payload-mapping coverage and release notes.
| File | Description |
|---|---|
packages/go/api/oas_validators_gen.go |
Adds generated invitation event validation. |
packages/go/api/oas_schemas_gen.go |
Adds generated event and payload types. |
packages/go/api/oas_operations_gen.go |
Adds webhook operation names. |
packages/go/api/oas_interfaces_gen.go |
Adds webhook response interfaces. |
docs/design/api/events-catalog.md |
Lists invitation events as contracted. |
apps/api/internal/domain/event.go |
Defines four invitation event constants. |
apps/api/internal/domain/event_payload.go |
Adds shared producer payload structs. |
apps/api/internal/api/generated/oas_validators_gen.go |
Adds generated server-side validation. |
apps/api/internal/api/generated/oas_operations_gen.go |
Adds generated webhook operation names. |
apps/api/internal/api/generated/oas_interfaces_gen.go |
Adds generated webhook response interfaces. |
apps/api/internal/api/event_map_test.go |
Tests invitation payload decoding into API events. |
apps/api/api/openapi/openapi-spec.yaml |
Registers the four webhooks. |
apps/api/api/openapi/endpoints/events/webhooks/invitation-rejected.yaml |
Defines the rejection webhook contract. |
apps/api/api/openapi/endpoints/events/webhooks/invitation-created.yaml |
Defines the creation webhook contract. |
apps/api/api/openapi/endpoints/events/webhooks/invitation-cancelled.yaml |
Defines the cancellation webhook contract. |
apps/api/api/openapi/endpoints/events/webhooks/invitation-accepted.yaml |
Defines the acceptance webhook contract. |
apps/api/api/openapi/endpoints/events/types/invitation-rejected-event.yaml |
Connects rejection payload to the event envelope. |
apps/api/api/openapi/endpoints/events/types/invitation-created-event.yaml |
Connects creation payload to the event envelope. |
apps/api/api/openapi/endpoints/events/types/invitation-cancelled-event.yaml |
Connects cancellation payload to the event envelope. |
apps/api/api/openapi/endpoints/events/types/invitation-accepted-event.yaml |
Connects acceptance payload to the event envelope. |
apps/api/api/openapi/endpoints/events/payloads/invitation-rejected-payload.yaml |
Defines journey and declining-user fields. |
apps/api/api/openapi/endpoints/events/payloads/invitation-created-payload.yaml |
Defines invitation details, replacement link and expiry. |
apps/api/api/openapi/endpoints/events/payloads/invitation-cancelled-payload.yaml |
Defines cancellation reason and replacement reference. |
apps/api/api/openapi/endpoints/events/payloads/invitation-accepted-payload.yaml |
Defines invitation details and accepting-user fields. |
apps/api/api/openapi/endpoints/events/event.yaml |
Extends the event union and discriminator. |
apps/api/api/openapi/bundled/openapi.json |
Includes the new contracts in the generated bundle. |
apps/api/api/cmd/gen_event_schemas/main.go |
Registers payload mappings and webhook descriptions. |
apps/api/api/cmd/gen_event_schemas/main_test.go |
Updates the expected event-type count. |
.changeset/invitation-events-contract.md |
Adds a server minor-release note. |
Review effort: Balanced
Model the invitation.created and invitation.accepted payloads as a oneOf discriminated on type, as the invitation resource is, so each variant requires its project_member or team_member object. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The invitation-acceptance descriptions incorrectly promise a companion event for every acceptance, even when an identical active grant already exists and no new grant is created.
1 open issue
1 resolved since last review
Review effort: Balanced
Accepting with an identical active grant writes no grant, so the invitation.accepted description no longer promises a companion event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split the invitation.cancelled payload on reason so a replaced one requires replaced_by_invitation_id. Narrow the accepted wording to ADR 086 §4: no grant event only when the user holds an identical active grant. List the invitation types in the console's EVENT_TYPES, which main now checks against the spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


Summary
The contract for invitation events, per ADR 086 §5. Spec, generated clients, catalog and Go payload structs only; nothing emits them yet.
invitation.created,invitation.accepted,invitation.rejectedandinvitation.cancelledin the events API union and as webhooks.createdandacceptedcarrytypeand its object, reusing the invitation resource'sproject_member/team_memberschemas from feat(api): add invitations OpenAPI contract #2918.cancelledcarriesreason(cancelledorreplaced) andreplaced_by_invitation_id.events-catalog.md's Contracted section; the Go payload structs indomain/event_payload.goare for the producers to share.Notes
invitation.accepted'srequest_idwith the grant service's authz events.Closes #2850
🤖 Generated with Claude Code