agent-messenger 2.8.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +0 -11
- package/dist/package.json +1 -1
- package/dist/src/platforms/channeltalk/commands/snapshot.d.ts +4 -2
- package/dist/src/platforms/channeltalk/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/commands/snapshot.js +86 -31
- package/dist/src/platforms/channeltalk/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/snapshot.d.ts +3 -1
- package/dist/src/platforms/channeltalkbot/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/snapshot.js +110 -60
- package/dist/src/platforms/channeltalkbot/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/discord/commands/snapshot.d.ts +1 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/snapshot.js +48 -34
- package/dist/src/platforms/discord/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/discordbot/commands/snapshot.d.ts +2 -0
- package/dist/src/platforms/discordbot/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/discordbot/commands/snapshot.js +46 -34
- package/dist/src/platforms/discordbot/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/slack/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/snapshot.js +75 -55
- package/dist/src/platforms/slack/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/teams/client.d.ts +9 -1
- package/dist/src/platforms/teams/client.d.ts.map +1 -1
- package/dist/src/platforms/teams/client.js +69 -18
- package/dist/src/platforms/teams/client.js.map +1 -1
- package/dist/src/platforms/teams/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/auth.js +7 -2
- package/dist/src/platforms/teams/commands/auth.js.map +1 -1
- package/dist/src/platforms/teams/commands/channel.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/channel.js +18 -3
- package/dist/src/platforms/teams/commands/channel.js.map +1 -1
- package/dist/src/platforms/teams/commands/file.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/file.js +18 -3
- package/dist/src/platforms/teams/commands/file.js.map +1 -1
- package/dist/src/platforms/teams/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/message.js +24 -4
- package/dist/src/platforms/teams/commands/message.js.map +1 -1
- package/dist/src/platforms/teams/commands/reaction.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/reaction.js +12 -2
- package/dist/src/platforms/teams/commands/reaction.js.map +1 -1
- package/dist/src/platforms/teams/commands/snapshot.d.ts +1 -0
- package/dist/src/platforms/teams/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/snapshot.js +50 -32
- package/dist/src/platforms/teams/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/teams/commands/team.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/team.js +6 -1
- package/dist/src/platforms/teams/commands/team.js.map +1 -1
- package/dist/src/platforms/teams/commands/user.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/user.js +18 -3
- package/dist/src/platforms/teams/commands/user.js.map +1 -1
- package/dist/src/platforms/teams/commands/whoami.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/whoami.js +6 -1
- package/dist/src/platforms/teams/commands/whoami.js.map +1 -1
- package/dist/src/platforms/teams/credential-manager.d.ts +3 -1
- package/dist/src/platforms/teams/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/teams/credential-manager.js +6 -1
- package/dist/src/platforms/teams/credential-manager.js.map +1 -1
- package/dist/src/platforms/teams/ensure-auth.d.ts.map +1 -1
- package/dist/src/platforms/teams/ensure-auth.js +7 -2
- package/dist/src/platforms/teams/ensure-auth.js.map +1 -1
- package/dist/src/platforms/teams/token-extractor.d.ts +3 -1
- package/dist/src/platforms/teams/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/teams/token-extractor.js +67 -10
- package/dist/src/platforms/teams/token-extractor.js.map +1 -1
- package/dist/src/platforms/teams/types.d.ts +17 -0
- package/dist/src/platforms/teams/types.d.ts.map +1 -1
- package/dist/src/platforms/teams/types.js +2 -0
- package/dist/src/platforms/teams/types.js.map +1 -1
- package/dist/src/platforms/webex/client.d.ts +3 -0
- package/dist/src/platforms/webex/client.d.ts.map +1 -1
- package/dist/src/platforms/webex/client.js +58 -13
- package/dist/src/platforms/webex/client.js.map +1 -1
- package/dist/src/platforms/webex/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/auth.js +61 -10
- package/dist/src/platforms/webex/commands/auth.js.map +1 -1
- package/dist/src/platforms/webex/commands/snapshot.d.ts +1 -0
- package/dist/src/platforms/webex/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/snapshot.js +14 -7
- package/dist/src/platforms/webex/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/webex/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/webex/credential-manager.js +18 -6
- package/dist/src/platforms/webex/credential-manager.js.map +1 -1
- package/dist/src/platforms/webex/encryption.d.ts.map +1 -1
- package/dist/src/platforms/webex/encryption.js +3 -1
- package/dist/src/platforms/webex/encryption.js.map +1 -1
- package/dist/src/platforms/webex/ensure-auth.d.ts.map +1 -1
- package/dist/src/platforms/webex/ensure-auth.js +10 -2
- package/dist/src/platforms/webex/ensure-auth.js.map +1 -1
- package/dist/src/platforms/webex/token-extractor.d.ts +1 -0
- package/dist/src/platforms/webex/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/webex/token-extractor.js +21 -4
- package/dist/src/platforms/webex/token-extractor.js.map +1 -1
- package/docs/content/docs/agent-skills.mdx +0 -10
- package/docs/content/docs/cli/channeltalk.mdx +18 -8
- package/docs/content/docs/cli/channeltalkbot.mdx +16 -6
- package/docs/content/docs/cli/discord.mdx +23 -7
- package/docs/content/docs/cli/discordbot.mdx +23 -7
- package/docs/content/docs/cli/slack.mdx +24 -7
- package/docs/content/docs/cli/teams.mdx +24 -8
- package/docs/content/docs/cli/webex.mdx +15 -2
- package/e2e/webex.e2e.test.ts +57 -0
- package/package.json +1 -1
- package/skills/agent-channeltalk/SKILL.md +19 -9
- package/skills/agent-channeltalk/references/common-patterns.md +10 -9
- package/skills/agent-channeltalkbot/SKILL.md +19 -9
- package/skills/agent-channeltalkbot/references/common-patterns.md +10 -9
- package/skills/agent-discord/SKILL.md +18 -9
- package/skills/agent-discord/references/common-patterns.md +8 -7
- package/skills/agent-discordbot/SKILL.md +18 -9
- package/skills/agent-instagram/SKILL.md +1 -1
- package/skills/agent-kakaotalk/SKILL.md +1 -1
- package/skills/agent-line/SKILL.md +1 -1
- package/skills/agent-slack/SKILL.md +19 -10
- package/skills/agent-slack/references/common-patterns.md +4 -7
- package/skills/agent-slackbot/SKILL.md +1 -1
- package/skills/agent-teams/SKILL.md +18 -9
- package/skills/agent-teams/references/common-patterns.md +9 -7
- package/skills/agent-telegram/SKILL.md +1 -1
- package/skills/agent-webex/SKILL.md +13 -4
- package/skills/agent-webex/references/common-patterns.md +8 -2
- package/skills/agent-wechatbot/SKILL.md +1 -1
- package/skills/agent-whatsapp/SKILL.md +1 -1
- package/skills/agent-whatsappbot/SKILL.md +1 -1
- package/src/platforms/channeltalk/commands/snapshot.test.ts +58 -26
- package/src/platforms/channeltalk/commands/snapshot.ts +107 -33
- package/src/platforms/channeltalkbot/commands/snapshot.test.ts +26 -8
- package/src/platforms/channeltalkbot/commands/snapshot.ts +131 -64
- package/src/platforms/discord/commands/snapshot.test.ts +1 -1
- package/src/platforms/discord/commands/snapshot.ts +58 -42
- package/src/platforms/discordbot/commands/snapshot.test.ts +40 -18
- package/src/platforms/discordbot/commands/snapshot.ts +54 -37
- package/src/platforms/slack/commands/snapshot.test.ts +63 -8
- package/src/platforms/slack/commands/snapshot.ts +98 -66
- package/src/platforms/teams/client.test.ts +34 -30
- package/src/platforms/teams/client.ts +92 -20
- package/src/platforms/teams/commands/auth.test.ts +6 -2
- package/src/platforms/teams/commands/auth.ts +7 -2
- package/src/platforms/teams/commands/channel.test.ts +6 -6
- package/src/platforms/teams/commands/channel.ts +18 -3
- package/src/platforms/teams/commands/file.ts +18 -3
- package/src/platforms/teams/commands/message.ts +24 -4
- package/src/platforms/teams/commands/reaction.ts +12 -2
- package/src/platforms/teams/commands/snapshot.test.ts +1 -1
- package/src/platforms/teams/commands/snapshot.ts +59 -39
- package/src/platforms/teams/commands/team.test.ts +2 -2
- package/src/platforms/teams/commands/team.ts +6 -1
- package/src/platforms/teams/commands/user.ts +18 -3
- package/src/platforms/teams/commands/whoami.ts +6 -1
- package/src/platforms/teams/credential-manager.test.ts +25 -0
- package/src/platforms/teams/credential-manager.ts +13 -3
- package/src/platforms/teams/ensure-auth.test.ts +6 -1
- package/src/platforms/teams/ensure-auth.ts +7 -2
- package/src/platforms/teams/token-extractor.ts +77 -12
- package/src/platforms/teams/types.test.ts +17 -0
- package/src/platforms/teams/types.ts +6 -0
- package/src/platforms/webex/client.test.ts +157 -13
- package/src/platforms/webex/client.ts +64 -15
- package/src/platforms/webex/commands/auth.test.ts +122 -1
- package/src/platforms/webex/commands/auth.ts +72 -17
- package/src/platforms/webex/commands/snapshot.test.ts +14 -1
- package/src/platforms/webex/commands/snapshot.ts +17 -9
- package/src/platforms/webex/credential-manager.test.ts +63 -0
- package/src/platforms/webex/credential-manager.ts +22 -8
- package/src/platforms/webex/encryption.test.ts +54 -0
- package/src/platforms/webex/encryption.ts +3 -1
- package/src/platforms/webex/ensure-auth.ts +10 -2
- package/src/platforms/webex/token-extractor.test.ts +32 -3
- package/src/platforms/webex/token-extractor.ts +26 -5
|
@@ -11,6 +11,7 @@ import type { SlackChannel } from '../types'
|
|
|
11
11
|
async function snapshotAction(options: {
|
|
12
12
|
channelsOnly?: boolean
|
|
13
13
|
usersOnly?: boolean
|
|
14
|
+
full?: boolean
|
|
14
15
|
limit?: number
|
|
15
16
|
pretty?: boolean
|
|
16
17
|
}): Promise<void> {
|
|
@@ -26,7 +27,6 @@ async function snapshotAction(options: {
|
|
|
26
27
|
const client = await new SlackClient().login({ token: workspace.token, cookie: workspace.cookie })
|
|
27
28
|
|
|
28
29
|
const auth = await client.testAuth()
|
|
29
|
-
const messageLimit = options.limit || 20
|
|
30
30
|
|
|
31
31
|
const snapshot: Record<string, any> = {
|
|
32
32
|
workspace: {
|
|
@@ -35,88 +35,120 @@ async function snapshotAction(options: {
|
|
|
35
35
|
},
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
name: ch.name,
|
|
44
|
-
is_private: ch.is_private,
|
|
45
|
-
is_archived: ch.is_archived,
|
|
46
|
-
created: ch.created,
|
|
47
|
-
topic: ch.topic?.value,
|
|
48
|
-
purpose: ch.purpose?.value,
|
|
49
|
-
}))
|
|
50
|
-
|
|
51
|
-
if (!options.channelsOnly) {
|
|
52
|
-
const activeChannels = channels.filter((ch) => !ch.is_archived)
|
|
53
|
-
|
|
54
|
-
const channelMessages = await parallelMap(
|
|
55
|
-
activeChannels,
|
|
56
|
-
async (channel: SlackChannel) => {
|
|
57
|
-
const messages = await client.getMessages(channel.id, messageLimit)
|
|
58
|
-
return messages.map((msg) => ({
|
|
59
|
-
...msg,
|
|
60
|
-
channel_id: channel.id,
|
|
61
|
-
channel_name: channel.name,
|
|
62
|
-
}))
|
|
63
|
-
},
|
|
64
|
-
5,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
snapshot.recent_messages = channelMessages.flat().map((msg) => ({
|
|
68
|
-
channel_id: msg.channel_id,
|
|
69
|
-
channel_name: msg.channel_name,
|
|
70
|
-
ts: msg.ts,
|
|
71
|
-
text: msg.text,
|
|
72
|
-
user: msg.user,
|
|
73
|
-
username: msg.username,
|
|
74
|
-
thread_ts: msg.thread_ts,
|
|
75
|
-
}))
|
|
76
|
-
}
|
|
38
|
+
const isFull = options.full || options.channelsOnly || options.usersOnly
|
|
39
|
+
if (isFull) {
|
|
40
|
+
await buildFullSnapshot(client, snapshot, options)
|
|
41
|
+
} else {
|
|
42
|
+
await buildBriefSnapshot(client, snapshot, options)
|
|
77
43
|
}
|
|
78
44
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
name: u.name,
|
|
85
|
-
real_name: u.real_name,
|
|
86
|
-
is_admin: u.is_admin,
|
|
87
|
-
is_bot: u.is_bot,
|
|
88
|
-
profile: u.profile,
|
|
89
|
-
}))
|
|
90
|
-
}
|
|
45
|
+
console.log(formatOutput(snapshot, options.pretty))
|
|
46
|
+
} catch (error) {
|
|
47
|
+
handleError(error as Error)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
91
50
|
|
|
92
|
-
|
|
93
|
-
|
|
51
|
+
async function buildBriefSnapshot(
|
|
52
|
+
client: SlackClient,
|
|
53
|
+
snapshot: Record<string, any>,
|
|
54
|
+
options: { channelsOnly?: boolean; usersOnly?: boolean },
|
|
55
|
+
): Promise<void> {
|
|
56
|
+
if (!options.usersOnly) {
|
|
57
|
+
const channels = await client.listChannels()
|
|
58
|
+
const active = channels.filter((ch) => !ch.is_archived)
|
|
59
|
+
snapshot.channels = active.map((ch) => ({ id: ch.id, name: ch.name }))
|
|
60
|
+
}
|
|
94
61
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
62
|
+
snapshot.hint =
|
|
63
|
+
"Use 'message list <channel>' for messages, 'channel info <channel>' for channel details, 'user list' for users, 'usergroup list' for groups."
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function buildFullSnapshot(
|
|
67
|
+
client: SlackClient,
|
|
68
|
+
snapshot: Record<string, any>,
|
|
69
|
+
options: { channelsOnly?: boolean; usersOnly?: boolean; limit?: number },
|
|
70
|
+
): Promise<void> {
|
|
71
|
+
const messageLimit = options.limit || 20
|
|
72
|
+
|
|
73
|
+
if (!options.usersOnly) {
|
|
74
|
+
const channels = await client.listChannels()
|
|
75
|
+
|
|
76
|
+
snapshot.channels = channels.map((ch) => ({
|
|
77
|
+
id: ch.id,
|
|
78
|
+
name: ch.name,
|
|
79
|
+
is_private: ch.is_private,
|
|
80
|
+
is_archived: ch.is_archived,
|
|
81
|
+
created: ch.created,
|
|
82
|
+
topic: ch.topic?.value,
|
|
83
|
+
purpose: ch.purpose?.value,
|
|
84
|
+
}))
|
|
85
|
+
|
|
86
|
+
if (!options.channelsOnly) {
|
|
87
|
+
const activeChannels = channels.filter((ch) => !ch.is_archived)
|
|
88
|
+
|
|
89
|
+
const channelMessages = await parallelMap(
|
|
90
|
+
activeChannels,
|
|
91
|
+
async (channel: SlackChannel) => {
|
|
92
|
+
const messages = await client.getMessages(channel.id, messageLimit)
|
|
93
|
+
return messages.map((msg) => ({
|
|
94
|
+
...msg,
|
|
95
|
+
channel_id: channel.id,
|
|
96
|
+
channel_name: channel.name,
|
|
97
|
+
}))
|
|
98
|
+
},
|
|
99
|
+
5,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
snapshot.recent_messages = channelMessages.flat().map((msg) => ({
|
|
103
|
+
channel_id: msg.channel_id,
|
|
104
|
+
channel_name: msg.channel_name,
|
|
105
|
+
ts: msg.ts,
|
|
106
|
+
text: msg.text,
|
|
107
|
+
user: msg.user,
|
|
108
|
+
username: msg.username,
|
|
109
|
+
thread_ts: msg.thread_ts,
|
|
102
110
|
}))
|
|
103
111
|
}
|
|
112
|
+
}
|
|
104
113
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
114
|
+
if (!options.channelsOnly) {
|
|
115
|
+
const users = await client.listUsers()
|
|
116
|
+
|
|
117
|
+
snapshot.users = users.map((u) => ({
|
|
118
|
+
id: u.id,
|
|
119
|
+
name: u.name,
|
|
120
|
+
real_name: u.real_name,
|
|
121
|
+
is_admin: u.is_admin,
|
|
122
|
+
is_bot: u.is_bot,
|
|
123
|
+
profile: u.profile,
|
|
124
|
+
}))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!options.channelsOnly && !options.usersOnly) {
|
|
128
|
+
const usergroups = await client.listUsergroups({ includeUsers: true, includeCount: true })
|
|
129
|
+
|
|
130
|
+
snapshot.usergroups = usergroups.map((ug) => ({
|
|
131
|
+
id: ug.id,
|
|
132
|
+
name: ug.name,
|
|
133
|
+
handle: ug.handle,
|
|
134
|
+
description: ug.description,
|
|
135
|
+
user_count: ug.user_count,
|
|
136
|
+
users: ug.users,
|
|
137
|
+
}))
|
|
108
138
|
}
|
|
109
139
|
}
|
|
110
140
|
|
|
111
141
|
export const snapshotCommand = new Command('snapshot')
|
|
112
|
-
.description('Get
|
|
142
|
+
.description('Get workspace overview for AI agents (brief by default, use --full for comprehensive data)')
|
|
143
|
+
.option('--full', 'Include messages, users, and user groups (verbose)')
|
|
113
144
|
.option('--channels-only', 'Include only channels (exclude messages and users)')
|
|
114
145
|
.option('--users-only', 'Include only users (exclude channels and messages)')
|
|
115
|
-
.option('--limit <n>', 'Number of recent messages per channel (default: 20)', '20')
|
|
146
|
+
.option('--limit <n>', 'Number of recent messages per channel with --full (default: 20)', '20')
|
|
116
147
|
.action(async (options) => {
|
|
117
148
|
await snapshotAction({
|
|
118
149
|
channelsOnly: options.channelsOnly,
|
|
119
150
|
usersOnly: options.usersOnly,
|
|
151
|
+
full: options.full,
|
|
120
152
|
limit: parseInt(options.limit, 10),
|
|
121
153
|
pretty: options.pretty,
|
|
122
154
|
})
|
|
@@ -55,18 +55,18 @@ describe('TeamsClient', () => {
|
|
|
55
55
|
|
|
56
56
|
describe('login', () => {
|
|
57
57
|
test('requires token', async () => {
|
|
58
|
-
await expect(new TeamsClient().login({ token: '' })).rejects.toThrow(TeamsError)
|
|
59
|
-
await expect(new TeamsClient().login({ token: '' })).rejects.toThrow('Token is required')
|
|
58
|
+
await expect(new TeamsClient().login({ token: '', region: 'emea' })).rejects.toThrow(TeamsError)
|
|
59
|
+
await expect(new TeamsClient().login({ token: '', region: 'emea' })).rejects.toThrow('Token is required')
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
test('accepts valid token', async () => {
|
|
63
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
63
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
64
64
|
expect(client).toBeInstanceOf(TeamsClient)
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
test('accepts token with expiry time', async () => {
|
|
68
68
|
const expiresAt = new Date(Date.now() + 3600000).toISOString()
|
|
69
|
-
const client = await new TeamsClient().login({ token: 'test-token', tokenExpiresAt: expiresAt })
|
|
69
|
+
const client = await new TeamsClient().login({ token: 'test-token', tokenExpiresAt: expiresAt, region: 'emea' })
|
|
70
70
|
expect(client).toBeInstanceOf(TeamsClient)
|
|
71
71
|
})
|
|
72
72
|
})
|
|
@@ -74,7 +74,11 @@ describe('TeamsClient', () => {
|
|
|
74
74
|
describe('token expiry', () => {
|
|
75
75
|
test('throws when token is expired', async () => {
|
|
76
76
|
const expiredAt = new Date(Date.now() - 1000).toISOString()
|
|
77
|
-
const client = await new TeamsClient().login({
|
|
77
|
+
const client = await new TeamsClient().login({
|
|
78
|
+
token: 'expired-token',
|
|
79
|
+
tokenExpiresAt: expiredAt,
|
|
80
|
+
region: 'emea',
|
|
81
|
+
})
|
|
78
82
|
|
|
79
83
|
await expect(client.testAuth()).rejects.toThrow(TeamsError)
|
|
80
84
|
await expect(client.testAuth()).rejects.toThrow('Token has expired')
|
|
@@ -87,7 +91,7 @@ describe('TeamsClient', () => {
|
|
|
87
91
|
locale: 'en-us',
|
|
88
92
|
})
|
|
89
93
|
|
|
90
|
-
const client = await new TeamsClient().login({ token: 'valid-token', tokenExpiresAt: expiresAt })
|
|
94
|
+
const client = await new TeamsClient().login({ token: 'valid-token', tokenExpiresAt: expiresAt, region: 'emea' })
|
|
91
95
|
const user = await client.testAuth()
|
|
92
96
|
|
|
93
97
|
expect(user.id).toBe('ME')
|
|
@@ -102,7 +106,7 @@ describe('TeamsClient', () => {
|
|
|
102
106
|
locale: 'en-us',
|
|
103
107
|
})
|
|
104
108
|
|
|
105
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
109
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
106
110
|
const user = await client.testAuth()
|
|
107
111
|
|
|
108
112
|
expect(user.id).toBe('ME')
|
|
@@ -117,7 +121,7 @@ describe('TeamsClient', () => {
|
|
|
117
121
|
test('throws TeamsError on API error', async () => {
|
|
118
122
|
mockResponse({ message: 'Unauthorized', code: 'unauthorized' }, 401)
|
|
119
123
|
|
|
120
|
-
const client = await new TeamsClient().login({ token: 'bad-token' })
|
|
124
|
+
const client = await new TeamsClient().login({ token: 'bad-token', region: 'emea' })
|
|
121
125
|
await expect(client.testAuth()).rejects.toThrow(TeamsError)
|
|
122
126
|
})
|
|
123
127
|
})
|
|
@@ -153,7 +157,7 @@ describe('TeamsClient', () => {
|
|
|
153
157
|
],
|
|
154
158
|
})
|
|
155
159
|
|
|
156
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
160
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
157
161
|
const teams = await client.listTeams()
|
|
158
162
|
|
|
159
163
|
expect(teams).toHaveLength(2)
|
|
@@ -169,7 +173,7 @@ describe('TeamsClient', () => {
|
|
|
169
173
|
test('returns team info', async () => {
|
|
170
174
|
mockResponse({ id: '111', name: 'Test Team', description: 'A test team' })
|
|
171
175
|
|
|
172
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
176
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
173
177
|
const team = await client.getTeam('111')
|
|
174
178
|
|
|
175
179
|
expect(team.id).toBe('111')
|
|
@@ -185,7 +189,7 @@ describe('TeamsClient', () => {
|
|
|
185
189
|
{ id: 'ch2', team_id: '111', name: 'Random', type: 'standard' },
|
|
186
190
|
])
|
|
187
191
|
|
|
188
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
192
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
189
193
|
const channels = await client.listChannels('111')
|
|
190
194
|
|
|
191
195
|
expect(channels).toHaveLength(2)
|
|
@@ -198,7 +202,7 @@ describe('TeamsClient', () => {
|
|
|
198
202
|
test('returns channel info', async () => {
|
|
199
203
|
mockResponse({ id: 'ch1', team_id: '111', name: 'General', type: 'standard' })
|
|
200
204
|
|
|
201
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
205
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
202
206
|
const channel = await client.getChannel('111', 'ch1')
|
|
203
207
|
|
|
204
208
|
expect(channel.id).toBe('ch1')
|
|
@@ -217,7 +221,7 @@ describe('TeamsClient', () => {
|
|
|
217
221
|
timestamp: '2024-01-01T00:00:00.000Z',
|
|
218
222
|
})
|
|
219
223
|
|
|
220
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
224
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
221
225
|
const message = await client.sendMessage('111', 'ch1', 'Hello world')
|
|
222
226
|
|
|
223
227
|
expect(message.content).toBe('Hello world')
|
|
@@ -239,7 +243,7 @@ describe('TeamsClient', () => {
|
|
|
239
243
|
},
|
|
240
244
|
])
|
|
241
245
|
|
|
242
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
246
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
243
247
|
const messages = await client.getMessages('111', 'ch1', 50)
|
|
244
248
|
|
|
245
249
|
expect(messages).toHaveLength(1)
|
|
@@ -252,7 +256,7 @@ describe('TeamsClient', () => {
|
|
|
252
256
|
test('uses default limit of 50', async () => {
|
|
253
257
|
mockResponse([])
|
|
254
258
|
|
|
255
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
259
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
256
260
|
await client.getMessages('111', 'ch1')
|
|
257
261
|
|
|
258
262
|
expect(fetchCalls[0].url).toBe(
|
|
@@ -271,7 +275,7 @@ describe('TeamsClient', () => {
|
|
|
271
275
|
timestamp: '2024-01-01T00:00:00.000Z',
|
|
272
276
|
})
|
|
273
277
|
|
|
274
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
278
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
275
279
|
const message = await client.getMessage('111', 'ch1', 'msg1')
|
|
276
280
|
|
|
277
281
|
expect(message.id).toBe('msg1')
|
|
@@ -285,7 +289,7 @@ describe('TeamsClient', () => {
|
|
|
285
289
|
test('deletes message', async () => {
|
|
286
290
|
mockResponse(null, 204)
|
|
287
291
|
|
|
288
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
292
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
289
293
|
await client.deleteMessage('111', 'ch1', 'msg1')
|
|
290
294
|
|
|
291
295
|
expect(fetchCalls[0].url).toBe(
|
|
@@ -299,7 +303,7 @@ describe('TeamsClient', () => {
|
|
|
299
303
|
test('adds reaction to message', async () => {
|
|
300
304
|
mockResponse(null, 204)
|
|
301
305
|
|
|
302
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
306
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
303
307
|
await client.addReaction('111', 'ch1', 'msg1', 'like')
|
|
304
308
|
|
|
305
309
|
expect(fetchCalls[0].url).toBe(
|
|
@@ -314,7 +318,7 @@ describe('TeamsClient', () => {
|
|
|
314
318
|
test('removes reaction from message', async () => {
|
|
315
319
|
mockResponse(null, 204)
|
|
316
320
|
|
|
317
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
321
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
318
322
|
await client.removeReaction('111', 'ch1', 'msg1', 'like')
|
|
319
323
|
|
|
320
324
|
expect(fetchCalls[0].url).toBe(
|
|
@@ -331,7 +335,7 @@ describe('TeamsClient', () => {
|
|
|
331
335
|
{ id: 'u2', displayName: 'User 2', email: 'user2@example.com' },
|
|
332
336
|
])
|
|
333
337
|
|
|
334
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
338
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
335
339
|
const users = await client.listUsers('111')
|
|
336
340
|
|
|
337
341
|
expect(users).toHaveLength(2)
|
|
@@ -344,7 +348,7 @@ describe('TeamsClient', () => {
|
|
|
344
348
|
test('returns user info', async () => {
|
|
345
349
|
mockResponse({ id: 'u1', displayName: 'Test User', email: 'test@example.com' })
|
|
346
350
|
|
|
347
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
351
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
348
352
|
const user = await client.getUser('u1')
|
|
349
353
|
|
|
350
354
|
expect(user.id).toBe('u1')
|
|
@@ -365,7 +369,7 @@ describe('TeamsClient', () => {
|
|
|
365
369
|
url: 'https://teams.microsoft.com/files/file1',
|
|
366
370
|
})
|
|
367
371
|
|
|
368
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
372
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
369
373
|
const file = await client.uploadFile('111', 'ch1', tempFile)
|
|
370
374
|
|
|
371
375
|
expect(file.name).toBe('test-teams-upload.txt')
|
|
@@ -381,7 +385,7 @@ describe('TeamsClient', () => {
|
|
|
381
385
|
{ id: 'file2', name: 'image.png', size: 2048, url: 'https://example.com/image.png' },
|
|
382
386
|
])
|
|
383
387
|
|
|
384
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
388
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
385
389
|
const files = await client.listFiles('111', 'ch1')
|
|
386
390
|
|
|
387
391
|
expect(files).toHaveLength(2)
|
|
@@ -401,7 +405,7 @@ describe('TeamsClient', () => {
|
|
|
401
405
|
'X-RateLimit-Reset': String(Date.now() / 1000 + 60),
|
|
402
406
|
})
|
|
403
407
|
|
|
404
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
408
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
405
409
|
await client.testAuth()
|
|
406
410
|
|
|
407
411
|
const startTime = Date.now()
|
|
@@ -416,7 +420,7 @@ describe('TeamsClient', () => {
|
|
|
416
420
|
mockResponse({ message: 'Rate limited' }, 429, { 'Retry-After': '0.1' })
|
|
417
421
|
mockResponse({ userDetails: JSON.stringify({ name: 'User' }), locale: 'en-us' })
|
|
418
422
|
|
|
419
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
423
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
420
424
|
const user = await client.testAuth()
|
|
421
425
|
|
|
422
426
|
expect(user.id).toBe('ME')
|
|
@@ -428,7 +432,7 @@ describe('TeamsClient', () => {
|
|
|
428
432
|
mockResponse({ message: 'Rate limited' }, 429, { 'Retry-After': '0.01' })
|
|
429
433
|
}
|
|
430
434
|
|
|
431
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
435
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
432
436
|
await expect(client.testAuth()).rejects.toThrow(TeamsError)
|
|
433
437
|
expect(fetchCalls.length).toBeLessThanOrEqual(4)
|
|
434
438
|
})
|
|
@@ -439,7 +443,7 @@ describe('TeamsClient', () => {
|
|
|
439
443
|
mockResponse({ message: 'Internal Server Error' }, 500)
|
|
440
444
|
mockResponse({ userDetails: JSON.stringify({ name: 'User' }), locale: 'en-us' })
|
|
441
445
|
|
|
442
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
446
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
443
447
|
const user = await client.testAuth()
|
|
444
448
|
|
|
445
449
|
expect(user.id).toBe('ME')
|
|
@@ -449,7 +453,7 @@ describe('TeamsClient', () => {
|
|
|
449
453
|
test('does not retry on 4xx client errors (except 429)', async () => {
|
|
450
454
|
mockResponse({ message: 'Not Found' }, 404)
|
|
451
455
|
|
|
452
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
456
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
453
457
|
await expect(client.testAuth()).rejects.toThrow(TeamsError)
|
|
454
458
|
expect(fetchCalls.length).toBe(1)
|
|
455
459
|
})
|
|
@@ -459,7 +463,7 @@ describe('TeamsClient', () => {
|
|
|
459
463
|
mockResponse({ message: 'Error' }, 500)
|
|
460
464
|
mockResponse({ userDetails: JSON.stringify({ name: 'User' }), locale: 'en-us' })
|
|
461
465
|
|
|
462
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
466
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
463
467
|
const startTime = Date.now()
|
|
464
468
|
await client.testAuth()
|
|
465
469
|
const elapsed = Date.now() - startTime
|
|
@@ -474,7 +478,7 @@ describe('TeamsClient', () => {
|
|
|
474
478
|
mockResponse([])
|
|
475
479
|
mockResponse([])
|
|
476
480
|
|
|
477
|
-
const client = await new TeamsClient().login({ token: 'test-token' })
|
|
481
|
+
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
478
482
|
await client.getMessages('team1', 'ch1')
|
|
479
483
|
await client.getMessages('team2', 'ch2')
|
|
480
484
|
|