Skip to content

Commit 7c310ea

Browse files
WilliamBergaminClaude
andauthored
feat(types): add the user_connection and user_connection_status_requested events (#2783)
Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
1 parent 89b0b1d commit 7c310ea

4 files changed

Lines changed: 82 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@slack/types": minor
3+
---
4+
5+
feat(types): add the [`user_connection`](https://docs.slack.dev/reference/events/user_connection) and [`user_connection_status_requested`](https://docs.slack.dev/reference/events/user_connection_status_requested) event interfaces

‎packages/types/src/events/index.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ import type {
8787
TeamRenameEvent,
8888
} from './team';
8989
import type { TokensRevokedEvent } from './token';
90-
import type { UserChangeEvent, UserHuddleChangedEvent, UserProfileChangedEvent, UserStatusChangedEvent } from './user';
90+
import type {
91+
UserChangeEvent,
92+
UserConnectionEvent,
93+
UserConnectionStatusRequestedEvent,
94+
UserHuddleChangedEvent,
95+
UserProfileChangedEvent,
96+
UserStatusChangedEvent,
97+
} from './user';
9198

9299
export * from './agent';
93100
export * from './app';
@@ -205,6 +212,8 @@ export type SlackEvent =
205212
// TODO: url_verification event is missing, but maybe we don't need it?
206213
// NOTE: url_verification does not use the envelope, but it's also not interesting for an app developer. it's omitted.
207214
| UserChangeEvent
215+
| UserConnectionEvent
216+
| UserConnectionStatusRequestedEvent
208217
| UserHuddleChangedEvent
209218
| UserProfileChangedEvent
210219
| UserStatusChangedEvent

‎packages/types/src/events/user.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,30 @@ export interface UserChangeEvent {
8282
event_ts: string;
8383
}
8484

85+
export type UserConnectionEvent = UserConnectionConnectEvent | UserConnectionDisconnectEvent;
86+
87+
export interface UserConnectionConnectEvent {
88+
type: 'user_connection';
89+
subtype: 'connect';
90+
user: string;
91+
trigger_id: string;
92+
event_ts: string;
93+
}
94+
95+
export interface UserConnectionDisconnectEvent {
96+
type: 'user_connection';
97+
subtype: 'disconnect';
98+
user: string;
99+
enterprise_id?: string;
100+
event_ts: string;
101+
}
102+
103+
export interface UserConnectionStatusRequestedEvent {
104+
type: 'user_connection_status_requested';
105+
user: string;
106+
event_ts: string;
107+
}
108+
85109
export interface UserHuddleChangedEvent {
86110
type: 'user_huddle_changed';
87111
user: {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { expectAssignable, expectError, expectType } from 'tsd';
2+
import type { SlackEvent, UserConnectionEvent, UserConnectionStatusRequestedEvent } from '../../src/index';
3+
4+
const connect: UserConnectionEvent = {
5+
type: 'user_connection',
6+
subtype: 'connect',
7+
user: 'U0123456789',
8+
trigger_id: '1293638028594.1249184885746.0d121a0e01d2e7a795ecc7a62880a406',
9+
event_ts: '1764264284.841251',
10+
};
11+
expectAssignable<SlackEvent>(connect);
12+
13+
const disconnect: UserConnectionEvent = {
14+
type: 'user_connection',
15+
subtype: 'disconnect',
16+
enterprise_id: 'E0123456789',
17+
user: 'U0123456789',
18+
event_ts: '1764264317.061589',
19+
};
20+
expectAssignable<SlackEvent>(disconnect);
21+
22+
expectError<UserConnectionEvent>({
23+
type: 'user_connection',
24+
subtype: 'connect',
25+
user: 'U0123456789',
26+
event_ts: '1764264284.841251',
27+
});
28+
29+
declare const userConnection: UserConnectionEvent;
30+
if (userConnection.subtype === 'connect') {
31+
expectType<string>(userConnection.trigger_id);
32+
}
33+
34+
const statusRequested: UserConnectionStatusRequestedEvent = {
35+
type: 'user_connection_status_requested',
36+
user: 'U0123456789',
37+
event_ts: '1764264284.841251',
38+
};
39+
expectAssignable<SlackEvent>(statusRequested);
40+
41+
expectError<UserConnectionStatusRequestedEvent>({
42+
type: 'user_connection_status_requested',
43+
});

0 commit comments

Comments
 (0)