fix(types): add context_team_id and context_enterprise_id to EnvelopedEvent (closes #2773)#2976
Open
tsushanth wants to merge 2 commits into
Open
fix(types): add context_team_id and context_enterprise_id to EnvelopedEvent (closes #2773)#2976tsushanth wants to merge 2 commits into
tsushanth wants to merge 2 commits into
Conversation
…dEvent (closes slackapi#2773) Slack's Events API delivers `context_team_id` and `context_enterprise_id` on the envelope for Slack Connect channels and Enterprise Grid org-wide apps, where `team_id` may refer to a workspace different from the one the bot is installed in. Without these fields on the `EnvelopedEvent` type, downstream code that routes by workspace had to reach for `@ts-expect-error` or unsafe casts (issue slackapi#2773). Adds both fields as optional `string` with JSDoc pointing at the Enterprise Grid docs, and a tsd regression test on `body.context_team_id` / `body.context_enterprise_id` so the field shapes can't silently regress to `any` via the `StringIndexed` index signature. No runtime change; pure type surface addition.
|
Thanks for the contribution! Before we can merge this, we need @tsushanth to sign the Salesforce Inc. Contributor License Agreement. |
🦋 Changeset detectedLatest commit: 65a00ce The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
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
Closes #2773. Adds the two Enterprise Grid / Slack Connect context fields that Slack's Events API delivers on the envelope but the type didn't surface.
In Slack Connect channels and Enterprise Grid org-wide apps,
body.team_idcan identify a workspace different from the one the bot is installed in. Slack solves this by also sendingcontext_team_id(and its enterprise counterpartcontext_enterprise_id), which always identify the workspace where the bot is actually running. Reporter (@FreQll) hit this when messages from Slack Connect channels were being routed to the wrong inbox.Before this PR, accessing those fields on
bodyrequired@ts-expect-erroror an unsafe cast because theEnvelopedEventinterface only declaredteam_id/enterprise_id. TheStringIndexedindex signature on the interface meant the access would silently returnany, defeating type safety.What changed
src/types/events/index.ts— addedcontext_team_id?: stringandcontext_enterprise_id?: stringtoEnvelopedEvent, with JSDoc pointing at the Enterprise Grid docs so the next reader doesn't have to guess when these are sent.test/types/event.test-d.ts— tsd assertions onbody.context_team_id/body.context_enterprise_idso the fields are exercised asstring | undefinedand can't silently regress intoanyvia theStringIndexedfallback. The test fails on the unpatched source with `Parameter type string | undefined is not identical to argument type any` for both new assertions.Notes
Requirements