agent-messenger 1.0.0 → 1.2.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/commands/release.md +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/e2e.yml.disabled +69 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +18 -15
- package/biome.json +34 -2
- package/bun.lock +63 -0
- package/dist/package.json +8 -4
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +4 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/platforms/discord/cli.js +4 -4
- package/dist/src/platforms/discord/cli.js.map +1 -1
- package/dist/src/platforms/discord/client.d.ts +26 -5
- package/dist/src/platforms/discord/client.d.ts.map +1 -1
- package/dist/src/platforms/discord/client.js +115 -17
- package/dist/src/platforms/discord/client.js.map +1 -1
- package/dist/src/platforms/discord/commands/auth.js +16 -16
- package/dist/src/platforms/discord/commands/auth.js.map +1 -1
- package/dist/src/platforms/discord/commands/channel.js +4 -4
- package/dist/src/platforms/discord/commands/channel.js.map +1 -1
- package/dist/src/platforms/discord/commands/dm.d.ts +9 -0
- package/dist/src/platforms/discord/commands/dm.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/dm.js +68 -0
- package/dist/src/platforms/discord/commands/dm.js.map +1 -0
- package/dist/src/platforms/discord/commands/friend.d.ts +3 -0
- package/dist/src/platforms/discord/commands/friend.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/friend.js +39 -0
- package/dist/src/platforms/discord/commands/friend.js.map +1 -0
- package/dist/src/platforms/discord/commands/index.d.ts +1 -1
- package/dist/src/platforms/discord/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/index.js +1 -1
- package/dist/src/platforms/discord/commands/index.js.map +1 -1
- package/dist/src/platforms/discord/commands/member.d.ts +3 -0
- package/dist/src/platforms/discord/commands/member.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/member.js +47 -0
- package/dist/src/platforms/discord/commands/member.js.map +1 -0
- package/dist/src/platforms/discord/commands/mention.d.ts +8 -0
- package/dist/src/platforms/discord/commands/mention.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/mention.js +47 -0
- package/dist/src/platforms/discord/commands/mention.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.d.ts +13 -0
- package/dist/src/platforms/discord/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/message.js +95 -1
- package/dist/src/platforms/discord/commands/message.js.map +1 -1
- package/dist/src/platforms/discord/commands/note.d.ts +3 -0
- package/dist/src/platforms/discord/commands/note.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/note.js +56 -0
- package/dist/src/platforms/discord/commands/note.js.map +1 -0
- package/dist/src/platforms/discord/commands/profile.d.ts +3 -0
- package/dist/src/platforms/discord/commands/profile.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/profile.js +47 -0
- package/dist/src/platforms/discord/commands/profile.js.map +1 -0
- package/dist/src/platforms/discord/commands/server.d.ts +15 -0
- package/dist/src/platforms/discord/commands/server.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/server.js +102 -0
- package/dist/src/platforms/discord/commands/server.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.js +10 -10
- package/dist/src/platforms/discord/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/discord/commands/thread.d.ts +10 -0
- package/dist/src/platforms/discord/commands/thread.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/thread.js +67 -0
- package/dist/src/platforms/discord/commands/thread.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/user.js +14 -5
- package/dist/src/platforms/discord/commands/user.js.map +1 -1
- package/dist/src/platforms/discord/credential-manager.d.ts +13 -13
- package/dist/src/platforms/discord/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/discord/credential-manager.js +28 -22
- package/dist/src/platforms/discord/credential-manager.js.map +1 -1
- package/dist/src/platforms/discord/super-properties.d.ts +4 -0
- package/dist/src/platforms/discord/super-properties.d.ts.map +1 -0
- package/dist/src/platforms/discord/super-properties.js +50 -0
- package/dist/src/platforms/discord/super-properties.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.d.ts +6 -1
- package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/discord/token-extractor.js +27 -2
- package/dist/src/platforms/discord/token-extractor.js.map +1 -1
- package/dist/src/platforms/discord/types.d.ts +389 -22
- package/dist/src/platforms/discord/types.d.ts.map +1 -1
- package/dist/src/platforms/discord/types.js +46 -4
- package/dist/src/platforms/discord/types.js.map +1 -1
- package/dist/src/platforms/slack/cli.d.ts.map +1 -1
- package/dist/src/platforms/slack/cli.js +7 -2
- package/dist/src/platforms/slack/cli.js.map +1 -1
- package/dist/src/platforms/slack/client.d.ts +19 -1
- package/dist/src/platforms/slack/client.d.ts.map +1 -1
- package/dist/src/platforms/slack/client.js +134 -0
- package/dist/src/platforms/slack/client.js.map +1 -1
- package/dist/src/platforms/slack/commands/activity.d.ts +3 -0
- package/dist/src/platforms/slack/commands/activity.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/activity.js +40 -0
- package/dist/src/platforms/slack/commands/activity.js.map +1 -0
- package/dist/src/platforms/slack/commands/drafts.d.ts +3 -0
- package/dist/src/platforms/slack/commands/drafts.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/drafts.js +45 -0
- package/dist/src/platforms/slack/commands/drafts.js.map +1 -0
- package/dist/src/platforms/slack/commands/index.d.ts +5 -0
- package/dist/src/platforms/slack/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/index.js +5 -0
- package/dist/src/platforms/slack/commands/index.js.map +1 -1
- package/dist/src/platforms/slack/commands/saved.d.ts +3 -0
- package/dist/src/platforms/slack/commands/saved.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/saved.js +54 -0
- package/dist/src/platforms/slack/commands/saved.js.map +1 -0
- package/dist/src/platforms/slack/commands/sections.d.ts +3 -0
- package/dist/src/platforms/slack/commands/sections.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/sections.js +37 -0
- package/dist/src/platforms/slack/commands/sections.js.map +1 -0
- package/dist/src/platforms/slack/commands/unread.d.ts +12 -0
- package/dist/src/platforms/slack/commands/unread.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/unread.js +89 -0
- package/dist/src/platforms/slack/commands/unread.js.map +1 -0
- package/dist/src/platforms/slack/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/slack/credential-manager.js +20 -6
- package/dist/src/platforms/slack/credential-manager.js.map +1 -1
- package/dist/src/platforms/slack/token-extractor.d.ts +8 -1
- package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/slack/token-extractor.js +83 -11
- package/dist/src/platforms/slack/token-extractor.js.map +1 -1
- package/dist/src/platforms/slack/types.d.ts +52 -0
- package/dist/src/platforms/slack/types.d.ts.map +1 -1
- package/dist/src/platforms/slack/types.js.map +1 -1
- package/dist/src/platforms/teams/cli.d.ts.map +1 -0
- package/dist/{cli.js → src/platforms/teams/cli.js} +11 -10
- package/dist/src/platforms/teams/cli.js.map +1 -0
- package/dist/src/platforms/teams/client.d.ts +32 -0
- package/dist/src/platforms/teams/client.d.ts.map +1 -0
- package/dist/src/platforms/teams/client.js +202 -0
- package/dist/src/platforms/teams/client.js.map +1 -0
- package/dist/src/platforms/teams/commands/auth.d.ts +14 -0
- package/dist/src/platforms/teams/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/auth.js +176 -0
- package/dist/src/platforms/teams/commands/auth.js.map +1 -0
- package/dist/src/platforms/teams/commands/channel.d.ts +13 -0
- package/dist/src/platforms/teams/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/channel.js +97 -0
- package/dist/src/platforms/teams/commands/channel.js.map +1 -0
- package/dist/src/platforms/teams/commands/file.d.ts +12 -0
- package/dist/src/platforms/teams/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/file.js +104 -0
- package/dist/src/platforms/teams/commands/file.js.map +1 -0
- package/dist/{commands → src/platforms/teams/commands}/index.d.ts +5 -2
- package/dist/src/platforms/teams/commands/index.d.ts.map +1 -0
- package/dist/{commands → src/platforms/teams/commands}/index.js +5 -2
- package/dist/src/platforms/teams/commands/index.js.map +1 -0
- package/dist/src/platforms/teams/commands/message.d.ts +17 -0
- package/dist/src/platforms/teams/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/message.js +133 -0
- package/dist/src/platforms/teams/commands/message.js.map +1 -0
- package/dist/src/platforms/teams/commands/reaction.d.ts +9 -0
- package/dist/src/platforms/teams/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/reaction.js +68 -0
- package/dist/src/platforms/teams/commands/reaction.js.map +1 -0
- package/dist/src/platforms/teams/commands/snapshot.d.ts +10 -0
- package/dist/src/platforms/teams/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/snapshot.js +85 -0
- package/dist/src/platforms/teams/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/teams/commands/team.d.ts +18 -0
- package/dist/src/platforms/teams/commands/team.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/team.js +130 -0
- package/dist/src/platforms/teams/commands/team.js.map +1 -0
- package/dist/src/platforms/teams/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/user.js +88 -0
- package/dist/src/platforms/teams/commands/user.js.map +1 -0
- package/dist/src/platforms/teams/credential-manager.d.ts +18 -0
- package/dist/src/platforms/teams/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/teams/credential-manager.js +81 -0
- package/dist/src/platforms/teams/credential-manager.js.map +1 -0
- package/dist/src/platforms/teams/index.d.ts +4 -0
- package/dist/src/platforms/teams/index.d.ts.map +1 -0
- package/dist/src/platforms/teams/index.js +6 -0
- package/dist/src/platforms/teams/index.js.map +1 -0
- package/dist/src/platforms/teams/token-extractor.d.ts +41 -0
- package/dist/src/platforms/teams/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/teams/token-extractor.js +360 -0
- package/dist/src/platforms/teams/token-extractor.js.map +1 -0
- package/dist/src/platforms/teams/types.d.ts +209 -0
- package/dist/src/platforms/teams/types.d.ts.map +1 -0
- package/dist/src/platforms/teams/types.js +65 -0
- package/dist/src/platforms/teams/types.js.map +1 -0
- package/dist/src/shared/utils/derived-key-cache.d.ts +20 -0
- package/dist/src/shared/utils/derived-key-cache.d.ts.map +1 -0
- package/dist/src/shared/utils/derived-key-cache.js +52 -0
- package/dist/src/shared/utils/derived-key-cache.js.map +1 -0
- package/docs/README.md +113 -0
- package/docs/biome.json +8 -0
- package/docs/bun.lock +1426 -0
- package/docs/content/docs/agent-skills.mdx +98 -0
- package/docs/content/docs/index.mdx +124 -0
- package/docs/{discord.md → content/docs/integrations/discord.mdx} +46 -21
- package/docs/content/docs/integrations/meta.json +5 -0
- package/docs/{slack.md → content/docs/integrations/slack.mdx} +5 -4
- package/docs/content/docs/integrations/teams.mdx +322 -0
- package/docs/content/docs/meta.json +8 -0
- package/docs/content/docs/quick-start.mdx +103 -0
- package/docs/eslint.config.mjs +30 -0
- package/docs/next.config.ts +10 -0
- package/docs/package.json +42 -0
- package/docs/postcss.config.mjs +7 -0
- package/docs/public/file.svg +1 -0
- package/docs/public/globe.svg +1 -0
- package/docs/public/next.svg +1 -0
- package/docs/public/vercel.svg +1 -0
- package/docs/public/window.svg +1 -0
- package/docs/source.config.ts +11 -0
- package/docs/src/app/api/search/route.ts +4 -0
- package/docs/src/app/docs/[[...slug]]/page.tsx +53 -0
- package/docs/src/app/docs/layout.tsx +21 -0
- package/docs/src/app/globals.css +10 -0
- package/docs/src/app/icon.png +0 -0
- package/docs/src/app/layout.config.tsx +7 -0
- package/docs/src/app/layout.tsx +35 -0
- package/docs/src/app/page.tsx +489 -0
- package/docs/src/lib/source.ts +15 -0
- package/docs/src/mdx-components.tsx +18 -0
- package/docs/tsconfig.json +36 -0
- package/e2e/README.md +256 -0
- package/e2e/config.ts +51 -0
- package/e2e/discord.e2e.test.ts +252 -0
- package/e2e/helpers.ts +107 -0
- package/e2e/slack.e2e.test.ts +309 -0
- package/package.json +8 -4
- package/scripts/postbuild.ts +15 -0
- package/skills/agent-discord/SKILL.md +96 -30
- package/skills/agent-discord/references/authentication.md +27 -27
- package/skills/agent-discord/references/common-patterns.md +15 -15
- package/skills/agent-discord/templates/post-message.sh +6 -6
- package/skills/agent-discord/templates/{guild-summary.sh → server-summary.sh} +20 -20
- package/skills/agent-slack/SKILL.md +53 -0
- package/skills/agent-teams/SKILL.md +292 -0
- package/skills/agent-teams/references/authentication.md +375 -0
- package/skills/agent-teams/references/common-patterns.md +596 -0
- package/skills/agent-teams/templates/monitor-channel.sh +239 -0
- package/skills/agent-teams/templates/post-message.sh +224 -0
- package/skills/agent-teams/templates/team-summary.sh +210 -0
- package/src/cli.ts +4 -0
- package/src/platforms/discord/cli.ts +3 -3
- package/src/platforms/discord/client.test.ts +15 -15
- package/src/platforms/discord/client.ts +163 -17
- package/src/platforms/discord/commands/auth.test.ts +53 -37
- package/src/platforms/discord/commands/auth.ts +16 -16
- package/src/platforms/discord/commands/channel.test.ts +58 -46
- package/src/platforms/discord/commands/channel.ts +4 -4
- package/src/platforms/discord/commands/dm.test.ts +146 -0
- package/src/platforms/discord/commands/dm.ts +85 -0
- package/src/platforms/discord/commands/file.test.ts +40 -53
- package/src/platforms/discord/commands/friend.test.ts +134 -0
- package/src/platforms/discord/commands/friend.ts +45 -0
- package/src/platforms/discord/commands/index.ts +1 -1
- package/src/platforms/discord/commands/member.test.ts +98 -0
- package/src/platforms/discord/commands/member.ts +59 -0
- package/src/platforms/discord/commands/mention.test.ts +129 -0
- package/src/platforms/discord/commands/mention.ts +59 -0
- package/src/platforms/discord/commands/message.test.ts +139 -44
- package/src/platforms/discord/commands/message.ts +134 -1
- package/src/platforms/discord/commands/note.test.ts +84 -0
- package/src/platforms/discord/commands/note.ts +73 -0
- package/src/platforms/discord/commands/profile.test.ts +107 -0
- package/src/platforms/discord/commands/profile.ts +55 -0
- package/src/platforms/discord/commands/reaction.test.ts +54 -42
- package/src/platforms/discord/commands/server.test.ts +137 -0
- package/src/platforms/discord/commands/{guild.ts → server.ts} +31 -31
- package/src/platforms/discord/commands/snapshot.test.ts +1 -1
- package/src/platforms/discord/commands/snapshot.ts +10 -10
- package/src/platforms/discord/commands/thread.test.ts +121 -0
- package/src/platforms/discord/commands/thread.ts +92 -0
- package/src/platforms/discord/commands/user.test.ts +8 -8
- package/src/platforms/discord/commands/user.ts +16 -5
- package/src/platforms/discord/credential-manager.test.ts +137 -136
- package/src/platforms/discord/credential-manager.ts +35 -26
- package/src/platforms/discord/super-properties.ts +55 -0
- package/src/platforms/discord/token-extractor.test.ts +133 -383
- package/src/platforms/discord/token-extractor.ts +37 -3
- package/src/platforms/discord/types.test.ts +8 -8
- package/src/platforms/discord/types.ts +144 -8
- package/{tests → src/platforms/slack}/cli.test.ts +3 -3
- package/src/platforms/slack/cli.ts +10 -0
- package/{tests/slack-client.test.ts → src/platforms/slack/client.test.ts} +1 -1
- package/src/platforms/slack/client.ts +172 -1
- package/src/platforms/slack/commands/activity.test.ts +147 -0
- package/src/platforms/slack/commands/activity.ts +65 -0
- package/{tests → src/platforms/slack}/commands/auth.test.ts +25 -13
- package/{tests → src/platforms/slack}/commands/channel.test.ts +2 -2
- package/src/platforms/slack/commands/drafts.test.ts +136 -0
- package/src/platforms/slack/commands/drafts.ts +62 -0
- package/{tests → src/platforms/slack}/commands/file.test.ts +2 -2
- package/src/platforms/slack/commands/index.ts +5 -0
- package/{tests → src/platforms/slack}/commands/message.test.ts +2 -2
- package/{tests → src/platforms/slack}/commands/reaction.test.ts +1 -1
- package/src/platforms/slack/commands/saved.test.ts +140 -0
- package/src/platforms/slack/commands/saved.ts +71 -0
- package/src/platforms/slack/commands/sections.test.ts +80 -0
- package/src/platforms/slack/commands/sections.ts +50 -0
- package/{tests → src/platforms/slack}/commands/snapshot.test.ts +117 -105
- package/src/platforms/slack/commands/unread.test.ts +139 -0
- package/src/platforms/slack/commands/unread.ts +129 -0
- package/{tests → src/platforms/slack}/commands/user.test.ts +3 -3
- package/{tests → src/platforms/slack}/commands/workspace.test.ts +44 -95
- package/{tests → src/platforms/slack}/credential-manager.test.ts +2 -2
- package/src/platforms/slack/credential-manager.ts +22 -7
- package/src/platforms/slack/token-extractor-node-test.ts +40 -0
- package/src/platforms/slack/token-extractor-node.test.ts +10 -0
- package/src/platforms/slack/token-extractor.ts +93 -12
- package/{tests → src/platforms/slack}/types.test.ts +1 -1
- package/src/platforms/slack/types.ts +58 -0
- package/src/platforms/teams/cli.ts +36 -0
- package/src/platforms/teams/client.test.ts +500 -0
- package/src/platforms/teams/client.ts +365 -0
- package/src/platforms/teams/commands/auth.test.ts +99 -0
- package/src/platforms/teams/commands/auth.ts +232 -0
- package/src/platforms/teams/commands/channel.test.ts +147 -0
- package/src/platforms/teams/commands/channel.ts +129 -0
- package/src/platforms/teams/commands/file.test.ts +88 -0
- package/src/platforms/teams/commands/file.ts +144 -0
- package/src/platforms/teams/commands/index.ts +12 -0
- package/src/platforms/teams/commands/message.test.ts +110 -0
- package/src/platforms/teams/commands/message.ts +188 -0
- package/src/platforms/teams/commands/reaction.test.ts +87 -0
- package/src/platforms/teams/commands/reaction.ts +104 -0
- package/src/platforms/teams/commands/snapshot.test.ts +35 -0
- package/src/platforms/teams/commands/snapshot.ts +115 -0
- package/src/platforms/teams/commands/team.test.ts +157 -0
- package/src/platforms/teams/commands/team.ts +164 -0
- package/src/platforms/teams/commands/user.test.ts +83 -0
- package/src/platforms/teams/commands/user.ts +112 -0
- package/src/platforms/teams/credential-manager.test.ts +178 -0
- package/src/platforms/teams/credential-manager.ts +92 -0
- package/src/platforms/teams/index.ts +5 -0
- package/src/platforms/teams/token-extractor.test.ts +429 -0
- package/src/platforms/teams/token-extractor.ts +490 -0
- package/src/platforms/teams/types.test.ts +226 -0
- package/src/platforms/teams/types.ts +140 -0
- package/src/shared/utils/derived-key-cache.test.ts +136 -0
- package/src/shared/utils/derived-key-cache.ts +63 -0
- package/tsconfig.json +1 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/auth.d.ts +0 -3
- package/dist/commands/auth.d.ts.map +0 -1
- package/dist/commands/auth.js +0 -140
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/channel.d.ts +0 -3
- package/dist/commands/channel.d.ts.map +0 -1
- package/dist/commands/channel.js +0 -118
- package/dist/commands/channel.js.map +0 -1
- package/dist/commands/file.d.ts +0 -3
- package/dist/commands/file.d.ts.map +0 -1
- package/dist/commands/file.js +0 -113
- package/dist/commands/file.js.map +0 -1
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/message.d.ts +0 -3
- package/dist/commands/message.d.ts.map +0 -1
- package/dist/commands/message.js +0 -214
- package/dist/commands/message.js.map +0 -1
- package/dist/commands/reaction.d.ts +0 -3
- package/dist/commands/reaction.d.ts.map +0 -1
- package/dist/commands/reaction.js +0 -100
- package/dist/commands/reaction.js.map +0 -1
- package/dist/commands/snapshot.d.ts +0 -3
- package/dist/commands/snapshot.d.ts.map +0 -1
- package/dist/commands/snapshot.js +0 -88
- package/dist/commands/snapshot.js.map +0 -1
- package/dist/commands/user.d.ts.map +0 -1
- package/dist/commands/user.js +0 -96
- package/dist/commands/user.js.map +0 -1
- package/dist/commands/workspace.d.ts +0 -3
- package/dist/commands/workspace.d.ts.map +0 -1
- package/dist/commands/workspace.js +0 -89
- package/dist/commands/workspace.js.map +0 -1
- package/dist/lib/credential-manager.d.ts +0 -13
- package/dist/lib/credential-manager.d.ts.map +0 -1
- package/dist/lib/credential-manager.js +0 -58
- package/dist/lib/credential-manager.js.map +0 -1
- package/dist/lib/index.d.ts +0 -3
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -3
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/ref-manager.d.ts +0 -26
- package/dist/lib/ref-manager.d.ts.map +0 -1
- package/dist/lib/ref-manager.js +0 -92
- package/dist/lib/ref-manager.js.map +0 -1
- package/dist/lib/slack-client.d.ts +0 -37
- package/dist/lib/slack-client.d.ts.map +0 -1
- package/dist/lib/slack-client.js +0 -379
- package/dist/lib/slack-client.js.map +0 -1
- package/dist/lib/token-extractor.d.ts +0 -28
- package/dist/lib/token-extractor.d.ts.map +0 -1
- package/dist/lib/token-extractor.js +0 -401
- package/dist/lib/token-extractor.js.map +0 -1
- package/dist/src/platforms/discord/client.test.d.ts +0 -2
- package/dist/src/platforms/discord/client.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/client.test.js +0 -367
- package/dist/src/platforms/discord/client.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/auth.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/auth.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/auth.test.js +0 -65
- package/dist/src/platforms/discord/commands/auth.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/channel.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/channel.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/channel.test.js +0 -136
- package/dist/src/platforms/discord/commands/channel.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/file.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/file.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/file.test.js +0 -83
- package/dist/src/platforms/discord/commands/file.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/guild.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/guild.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/guild.test.js +0 -100
- package/dist/src/platforms/discord/commands/guild.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/message.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/message.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/message.test.js +0 -91
- package/dist/src/platforms/discord/commands/message.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/reaction.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/reaction.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/reaction.test.js +0 -115
- package/dist/src/platforms/discord/commands/reaction.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/snapshot.test.js +0 -25
- package/dist/src/platforms/discord/commands/snapshot.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/user.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/user.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/user.test.js +0 -103
- package/dist/src/platforms/discord/commands/user.test.js.map +0 -1
- package/dist/src/platforms/discord/credential-manager.test.d.ts +0 -2
- package/dist/src/platforms/discord/credential-manager.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/credential-manager.test.js +0 -136
- package/dist/src/platforms/discord/credential-manager.test.js.map +0 -1
- package/dist/src/platforms/discord/token-extractor.test.d.ts +0 -2
- package/dist/src/platforms/discord/token-extractor.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/token-extractor.test.js +0 -789
- package/dist/src/platforms/discord/token-extractor.test.js.map +0 -1
- package/dist/src/platforms/discord/types.test.d.ts +0 -2
- package/dist/src/platforms/discord/types.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/types.test.js +0 -211
- package/dist/src/platforms/discord/types.test.js.map +0 -1
- package/dist/src/shared/utils/concurrency.test.d.ts +0 -2
- package/dist/src/shared/utils/concurrency.test.d.ts.map +0 -1
- package/dist/src/shared/utils/concurrency.test.js +0 -39
- package/dist/src/shared/utils/concurrency.test.js.map +0 -1
- package/dist/tests/cli.test.d.ts +0 -2
- package/dist/tests/cli.test.d.ts.map +0 -1
- package/dist/tests/cli.test.js +0 -83
- package/dist/tests/cli.test.js.map +0 -1
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/CURRENT +0 -1
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOCK +0 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG +0 -3
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG.old +0 -1
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/MANIFEST-000004 +0 -0
- package/dist/tests/commands/auth.test.d.ts +0 -2
- package/dist/tests/commands/auth.test.d.ts.map +0 -1
- package/dist/tests/commands/auth.test.js +0 -304
- package/dist/tests/commands/auth.test.js.map +0 -1
- package/dist/tests/commands/channel.test.d.ts +0 -2
- package/dist/tests/commands/channel.test.d.ts.map +0 -1
- package/dist/tests/commands/channel.test.js +0 -166
- package/dist/tests/commands/channel.test.js.map +0 -1
- package/dist/tests/commands/file.test.d.ts +0 -2
- package/dist/tests/commands/file.test.d.ts.map +0 -1
- package/dist/tests/commands/file.test.js +0 -175
- package/dist/tests/commands/file.test.js.map +0 -1
- package/dist/tests/commands/message.test.d.ts +0 -2
- package/dist/tests/commands/message.test.d.ts.map +0 -1
- package/dist/tests/commands/message.test.js +0 -293
- package/dist/tests/commands/message.test.js.map +0 -1
- package/dist/tests/commands/reaction.test.d.ts +0 -2
- package/dist/tests/commands/reaction.test.d.ts.map +0 -1
- package/dist/tests/commands/reaction.test.js +0 -84
- package/dist/tests/commands/reaction.test.js.map +0 -1
- package/dist/tests/commands/snapshot.test.d.ts +0 -2
- package/dist/tests/commands/snapshot.test.d.ts.map +0 -1
- package/dist/tests/commands/snapshot.test.js +0 -280
- package/dist/tests/commands/snapshot.test.js.map +0 -1
- package/dist/tests/commands/user.test.d.ts +0 -2
- package/dist/tests/commands/user.test.d.ts.map +0 -1
- package/dist/tests/commands/user.test.js +0 -117
- package/dist/tests/commands/user.test.js.map +0 -1
- package/dist/tests/commands/workspace.test.d.ts +0 -2
- package/dist/tests/commands/workspace.test.d.ts.map +0 -1
- package/dist/tests/commands/workspace.test.js +0 -453
- package/dist/tests/commands/workspace.test.js.map +0 -1
- package/dist/tests/credential-manager.test.d.ts +0 -2
- package/dist/tests/credential-manager.test.d.ts.map +0 -1
- package/dist/tests/credential-manager.test.js +0 -199
- package/dist/tests/credential-manager.test.js.map +0 -1
- package/dist/tests/slack-client.test.d.ts +0 -2
- package/dist/tests/slack-client.test.d.ts.map +0 -1
- package/dist/tests/slack-client.test.js +0 -741
- package/dist/tests/slack-client.test.js.map +0 -1
- package/dist/tests/types.test.d.ts +0 -2
- package/dist/tests/types.test.d.ts.map +0 -1
- package/dist/tests/types.test.js +0 -215
- package/dist/tests/types.test.js.map +0 -1
- package/dist/types/index.d.ts +0 -369
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -92
- package/dist/types/index.js.map +0 -1
- package/dist/utils/error-handler.d.ts +0 -2
- package/dist/utils/error-handler.d.ts.map +0 -1
- package/dist/utils/error-handler.js +0 -5
- package/dist/utils/error-handler.js.map +0 -1
- package/dist/utils/output.d.ts +0 -2
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/output.js +0 -4
- package/dist/utils/output.js.map +0 -1
- package/src/platforms/discord/commands/guild.test.ts +0 -117
- /package/dist/{cli.d.ts → src/platforms/teams/cli.d.ts} +0 -0
- /package/dist/{commands → src/platforms/teams/commands}/user.d.ts +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler'
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output'
|
|
4
|
+
import { DiscordClient } from '../client'
|
|
5
|
+
import { DiscordCredentialManager } from '../credential-manager'
|
|
6
|
+
|
|
7
|
+
async function getAction(userId: string, options: { pretty?: boolean }): Promise<void> {
|
|
8
|
+
try {
|
|
9
|
+
const credManager = new DiscordCredentialManager()
|
|
10
|
+
const config = await credManager.load()
|
|
11
|
+
|
|
12
|
+
if (!config.token) {
|
|
13
|
+
console.log(
|
|
14
|
+
formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty)
|
|
15
|
+
)
|
|
16
|
+
process.exit(1)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const client = new DiscordClient(config.token)
|
|
20
|
+
const note = await client.getUserNote(userId)
|
|
21
|
+
|
|
22
|
+
if (note === null) {
|
|
23
|
+
console.log(formatOutput({ note: null }, options.pretty))
|
|
24
|
+
} else {
|
|
25
|
+
console.log(formatOutput(note, options.pretty))
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
handleError(error as Error)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function setAction(
|
|
33
|
+
userId: string,
|
|
34
|
+
note: string,
|
|
35
|
+
options: { pretty?: boolean }
|
|
36
|
+
): Promise<void> {
|
|
37
|
+
try {
|
|
38
|
+
const credManager = new DiscordCredentialManager()
|
|
39
|
+
const config = await credManager.load()
|
|
40
|
+
|
|
41
|
+
if (!config.token) {
|
|
42
|
+
console.log(
|
|
43
|
+
formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty)
|
|
44
|
+
)
|
|
45
|
+
process.exit(1)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const client = new DiscordClient(config.token)
|
|
49
|
+
const result = await client.setUserNote(userId, note)
|
|
50
|
+
|
|
51
|
+
console.log(formatOutput(result, options.pretty))
|
|
52
|
+
} catch (error) {
|
|
53
|
+
handleError(error as Error)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const noteCommand = new Command('note')
|
|
58
|
+
.description('User note commands')
|
|
59
|
+
.addCommand(
|
|
60
|
+
new Command('get')
|
|
61
|
+
.description('Get note for a user')
|
|
62
|
+
.argument('<user-id>', 'User ID')
|
|
63
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
64
|
+
.action(getAction)
|
|
65
|
+
)
|
|
66
|
+
.addCommand(
|
|
67
|
+
new Command('set')
|
|
68
|
+
.description('Set note for a user')
|
|
69
|
+
.argument('<user-id>', 'User ID')
|
|
70
|
+
.argument('<note>', 'Note content')
|
|
71
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
72
|
+
.action(setAction)
|
|
73
|
+
)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { expect, mock, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
// Mock DiscordClient
|
|
4
|
+
const mockClient = {
|
|
5
|
+
getUserProfile: mock(async (userId: string) => ({
|
|
6
|
+
user: {
|
|
7
|
+
id: userId,
|
|
8
|
+
username: 'testuser',
|
|
9
|
+
global_name: 'Test User',
|
|
10
|
+
avatar: 'avatar_hash',
|
|
11
|
+
bot: false,
|
|
12
|
+
bio: 'This is my bio',
|
|
13
|
+
},
|
|
14
|
+
connected_accounts: [
|
|
15
|
+
{
|
|
16
|
+
type: 'github',
|
|
17
|
+
id: 'github123',
|
|
18
|
+
name: 'testuser',
|
|
19
|
+
verified: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'twitter',
|
|
23
|
+
id: 'twitter456',
|
|
24
|
+
name: '@testuser',
|
|
25
|
+
verified: false,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
premium_since: '2024-01-15T10:30:00.000Z',
|
|
29
|
+
mutual_guilds: [
|
|
30
|
+
{
|
|
31
|
+
id: 'guild1',
|
|
32
|
+
nick: 'TestNick',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'guild2',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
})),
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
test('get returns user profile with all fields', async () => {
|
|
42
|
+
// given: user id
|
|
43
|
+
const userId = 'user123'
|
|
44
|
+
|
|
45
|
+
// when: getting user profile
|
|
46
|
+
const profile = await mockClient.getUserProfile(userId)
|
|
47
|
+
|
|
48
|
+
// then: returns complete profile
|
|
49
|
+
expect(profile.user.id).toBe('user123')
|
|
50
|
+
expect(profile.user.username).toBe('testuser')
|
|
51
|
+
expect(profile.user.bio).toBe('This is my bio')
|
|
52
|
+
expect(profile.connected_accounts).toHaveLength(2)
|
|
53
|
+
expect(profile.connected_accounts[0].type).toBe('github')
|
|
54
|
+
expect(profile.connected_accounts[0].verified).toBe(true)
|
|
55
|
+
expect(profile.premium_since).toBe('2024-01-15T10:30:00.000Z')
|
|
56
|
+
expect(profile.mutual_guilds).toHaveLength(2)
|
|
57
|
+
expect(profile.mutual_guilds?.[0].nick).toBe('TestNick')
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('get returns profile with minimal fields', async () => {
|
|
61
|
+
// given: mock with minimal profile
|
|
62
|
+
const minimalMock = {
|
|
63
|
+
getUserProfile: mock(async (userId: string) => ({
|
|
64
|
+
user: {
|
|
65
|
+
id: userId,
|
|
66
|
+
username: 'minimaluser',
|
|
67
|
+
global_name: 'Minimal User',
|
|
68
|
+
},
|
|
69
|
+
connected_accounts: [],
|
|
70
|
+
})),
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// when: getting minimal profile
|
|
74
|
+
const profile = await minimalMock.getUserProfile('user456')
|
|
75
|
+
|
|
76
|
+
// then: returns profile without optional fields
|
|
77
|
+
expect(profile.user.id).toBe('user456')
|
|
78
|
+
expect(profile.user.bio).toBeUndefined()
|
|
79
|
+
expect(profile.connected_accounts).toHaveLength(0)
|
|
80
|
+
expect(profile.premium_since).toBeUndefined()
|
|
81
|
+
expect(profile.mutual_guilds).toBeUndefined()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('get formats connected accounts correctly', async () => {
|
|
85
|
+
// given: user with connected accounts
|
|
86
|
+
const userId = 'user789'
|
|
87
|
+
const profile = await mockClient.getUserProfile(userId)
|
|
88
|
+
|
|
89
|
+
// when: extracting connected accounts
|
|
90
|
+
const accounts = profile.connected_accounts.map((acc) => ({
|
|
91
|
+
type: acc.type,
|
|
92
|
+
name: acc.name,
|
|
93
|
+
verified: acc.verified,
|
|
94
|
+
}))
|
|
95
|
+
|
|
96
|
+
// then: accounts are properly formatted
|
|
97
|
+
expect(accounts[0]).toEqual({
|
|
98
|
+
type: 'github',
|
|
99
|
+
name: 'testuser',
|
|
100
|
+
verified: true,
|
|
101
|
+
})
|
|
102
|
+
expect(accounts[1]).toEqual({
|
|
103
|
+
type: 'twitter',
|
|
104
|
+
name: '@testuser',
|
|
105
|
+
verified: false,
|
|
106
|
+
})
|
|
107
|
+
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler'
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output'
|
|
4
|
+
import { DiscordClient } from '../client'
|
|
5
|
+
import { DiscordCredentialManager } from '../credential-manager'
|
|
6
|
+
|
|
7
|
+
async function getAction(userId: string, options: { pretty?: boolean }): Promise<void> {
|
|
8
|
+
try {
|
|
9
|
+
const credManager = new DiscordCredentialManager()
|
|
10
|
+
const config = await credManager.load()
|
|
11
|
+
|
|
12
|
+
if (!config.token) {
|
|
13
|
+
console.log(
|
|
14
|
+
formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty)
|
|
15
|
+
)
|
|
16
|
+
process.exit(1)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const client = new DiscordClient(config.token)
|
|
20
|
+
const profile = await client.getUserProfile(userId)
|
|
21
|
+
|
|
22
|
+
const output = {
|
|
23
|
+
user: {
|
|
24
|
+
id: profile.user.id,
|
|
25
|
+
username: profile.user.username,
|
|
26
|
+
global_name: profile.user.global_name,
|
|
27
|
+
avatar: profile.user.avatar,
|
|
28
|
+
bot: profile.user.bot,
|
|
29
|
+
bio: profile.user.bio,
|
|
30
|
+
},
|
|
31
|
+
connected_accounts: profile.connected_accounts.map((acc) => ({
|
|
32
|
+
type: acc.type,
|
|
33
|
+
id: acc.id,
|
|
34
|
+
name: acc.name,
|
|
35
|
+
verified: acc.verified,
|
|
36
|
+
})),
|
|
37
|
+
premium_since: profile.premium_since,
|
|
38
|
+
mutual_guilds: profile.mutual_guilds,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log(formatOutput(output, options.pretty))
|
|
42
|
+
} catch (error) {
|
|
43
|
+
handleError(error as Error)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const profileCommand = new Command('profile')
|
|
48
|
+
.description('User profile commands')
|
|
49
|
+
.addCommand(
|
|
50
|
+
new Command('get')
|
|
51
|
+
.description('Get user profile')
|
|
52
|
+
.argument('<user-id>', 'User ID')
|
|
53
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
54
|
+
.action(getAction)
|
|
55
|
+
)
|
|
@@ -1,38 +1,53 @@
|
|
|
1
|
-
import { expect, mock, test } from 'bun:test'
|
|
1
|
+
import { afterEach, beforeEach, expect, mock, spyOn, test } from 'bun:test'
|
|
2
|
+
import { DiscordClient } from '../client'
|
|
3
|
+
import { DiscordCredentialManager } from '../credential-manager'
|
|
2
4
|
import { addAction, listAction, removeAction } from './reaction'
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
6
|
+
let clientAddReactionSpy: ReturnType<typeof spyOn>
|
|
7
|
+
let clientRemoveReactionSpy: ReturnType<typeof spyOn>
|
|
8
|
+
let clientGetMessageSpy: ReturnType<typeof spyOn>
|
|
9
|
+
let credManagerLoadSpy: ReturnType<typeof spyOn>
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
// Spy on DiscordClient.prototype methods
|
|
13
|
+
clientAddReactionSpy = spyOn(DiscordClient.prototype, 'addReaction').mockResolvedValue(undefined)
|
|
14
|
+
|
|
15
|
+
clientRemoveReactionSpy = spyOn(DiscordClient.prototype, 'removeReaction').mockResolvedValue(
|
|
16
|
+
undefined
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
clientGetMessageSpy = spyOn(DiscordClient.prototype, 'getMessage').mockResolvedValue({
|
|
20
|
+
id: 'msg123',
|
|
21
|
+
channel_id: 'ch123',
|
|
22
|
+
author: { id: 'user123', username: 'testuser' },
|
|
23
|
+
content: 'test message',
|
|
24
|
+
timestamp: '2024-01-01T00:00:00Z',
|
|
25
|
+
reactions: [
|
|
26
|
+
{
|
|
27
|
+
emoji: { name: 'thumbsup', id: undefined },
|
|
28
|
+
count: 2,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
emoji: { name: 'heart', id: undefined },
|
|
32
|
+
count: 1,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
} as any)
|
|
36
|
+
|
|
37
|
+
// Spy on DiscordCredentialManager.prototype methods
|
|
38
|
+
credManagerLoadSpy = spyOn(DiscordCredentialManager.prototype, 'load').mockResolvedValue({
|
|
39
|
+
token: 'test-token',
|
|
40
|
+
current_server: null,
|
|
41
|
+
servers: {},
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
clientAddReactionSpy?.mockRestore()
|
|
47
|
+
clientRemoveReactionSpy?.mockRestore()
|
|
48
|
+
clientGetMessageSpy?.mockRestore()
|
|
49
|
+
credManagerLoadSpy?.mockRestore()
|
|
50
|
+
})
|
|
36
51
|
|
|
37
52
|
test('add: sends correct PUT request with emoji', async () => {
|
|
38
53
|
const consoleSpy = mock((_msg: string) => {})
|
|
@@ -91,15 +106,12 @@ test('list: extracts reactions from message', async () => {
|
|
|
91
106
|
})
|
|
92
107
|
|
|
93
108
|
test('add: handles missing token gracefully', async () => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
mock.module('../credential-manager', () => ({
|
|
101
|
-
DiscordCredentialManager: credManagerMock,
|
|
102
|
-
}))
|
|
109
|
+
// Temporarily override the credential manager spy to return null token
|
|
110
|
+
credManagerLoadSpy?.mockResolvedValue({
|
|
111
|
+
token: null,
|
|
112
|
+
current_server: null,
|
|
113
|
+
servers: {},
|
|
114
|
+
})
|
|
103
115
|
|
|
104
116
|
const consoleSpy = mock((_msg: string) => {})
|
|
105
117
|
const originalLog = console.log
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { afterEach, beforeEach, expect, spyOn, test } from 'bun:test'
|
|
2
|
+
import { DiscordClient } from '../client'
|
|
3
|
+
import { DiscordCredentialManager } from '../credential-manager'
|
|
4
|
+
|
|
5
|
+
let clientListServersSpy: ReturnType<typeof spyOn>
|
|
6
|
+
let clientGetServerSpy: ReturnType<typeof spyOn>
|
|
7
|
+
let credManagerLoadSpy: ReturnType<typeof spyOn>
|
|
8
|
+
let credManagerSetCurrentServerSpy: ReturnType<typeof spyOn>
|
|
9
|
+
let credManagerGetCurrentServerSpy: ReturnType<typeof spyOn>
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
// Spy on DiscordClient.prototype methods
|
|
13
|
+
clientListServersSpy = spyOn(DiscordClient.prototype, 'listServers').mockResolvedValue([
|
|
14
|
+
{ id: 'server-1', name: 'Server One', icon: 'icon1', owner: true },
|
|
15
|
+
{ id: 'server-2', name: 'Server Two', icon: 'icon2', owner: false },
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
clientGetServerSpy = spyOn(DiscordClient.prototype, 'getServer').mockImplementation(
|
|
19
|
+
async (serverId: string) => {
|
|
20
|
+
if (serverId === 'server-1') {
|
|
21
|
+
return { id: 'server-1', name: 'Server One', icon: 'icon1', owner: true }
|
|
22
|
+
}
|
|
23
|
+
if (serverId === 'server-2') {
|
|
24
|
+
return { id: 'server-2', name: 'Server Two', icon: 'icon2', owner: false }
|
|
25
|
+
}
|
|
26
|
+
throw new Error('Server not found')
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
// Spy on DiscordCredentialManager.prototype methods
|
|
31
|
+
credManagerLoadSpy = spyOn(DiscordCredentialManager.prototype, 'load').mockResolvedValue({
|
|
32
|
+
token: 'test-token',
|
|
33
|
+
current_server: 'server-1',
|
|
34
|
+
servers: {
|
|
35
|
+
'server-1': { server_id: 'server-1', server_name: 'Server One' },
|
|
36
|
+
'server-2': { server_id: 'server-2', server_name: 'Server Two' },
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
credManagerSetCurrentServerSpy = spyOn(
|
|
41
|
+
DiscordCredentialManager.prototype,
|
|
42
|
+
'setCurrentServer'
|
|
43
|
+
).mockResolvedValue(undefined)
|
|
44
|
+
|
|
45
|
+
credManagerGetCurrentServerSpy = spyOn(
|
|
46
|
+
DiscordCredentialManager.prototype,
|
|
47
|
+
'getCurrentServer'
|
|
48
|
+
).mockResolvedValue('server-1')
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
afterEach(() => {
|
|
52
|
+
clientListServersSpy?.mockRestore()
|
|
53
|
+
clientGetServerSpy?.mockRestore()
|
|
54
|
+
credManagerLoadSpy?.mockRestore()
|
|
55
|
+
credManagerSetCurrentServerSpy?.mockRestore()
|
|
56
|
+
credManagerGetCurrentServerSpy?.mockRestore()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('list: returns servers with current marker', async () => {
|
|
60
|
+
// given: credential manager with servers
|
|
61
|
+
const credManager = new DiscordCredentialManager()
|
|
62
|
+
const config = await credManager.load()
|
|
63
|
+
|
|
64
|
+
// when: list action is called
|
|
65
|
+
expect(config.servers).toBeDefined()
|
|
66
|
+
expect(Object.keys(config.servers)).toHaveLength(2)
|
|
67
|
+
|
|
68
|
+
// then: servers are returned
|
|
69
|
+
expect(config.servers['server-1']).toBeDefined()
|
|
70
|
+
expect(config.servers['server-2']).toBeDefined()
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('list: marks current server', async () => {
|
|
74
|
+
// given: credential manager with current server set
|
|
75
|
+
const credManager = new DiscordCredentialManager()
|
|
76
|
+
const config = await credManager.load()
|
|
77
|
+
const current = await credManager.getCurrentServer()
|
|
78
|
+
|
|
79
|
+
// when: checking current server
|
|
80
|
+
expect(current).toBe('server-1')
|
|
81
|
+
|
|
82
|
+
// then: current server is marked
|
|
83
|
+
expect(config.current_server).toBe('server-1')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('info: returns server details', async () => {
|
|
87
|
+
// given: discord client with server data
|
|
88
|
+
const client = new DiscordClient('test-token')
|
|
89
|
+
const server = await client.getServer('server-1')
|
|
90
|
+
|
|
91
|
+
// when: getting server info
|
|
92
|
+
expect(server).toBeDefined()
|
|
93
|
+
|
|
94
|
+
// then: server details are returned
|
|
95
|
+
expect(server.id).toBe('server-1')
|
|
96
|
+
expect(server.name).toBe('Server One')
|
|
97
|
+
expect(server.icon).toBe('icon1')
|
|
98
|
+
expect(server.owner).toBe(true)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
test('info: throws error for non-existent server', async () => {
|
|
102
|
+
// given: discord client
|
|
103
|
+
const client = new DiscordClient('test-token')
|
|
104
|
+
|
|
105
|
+
// when: getting non-existent server
|
|
106
|
+
// then: error is thrown
|
|
107
|
+
try {
|
|
108
|
+
await client.getServer('non-existent')
|
|
109
|
+
expect(true).toBe(false) // should not reach here
|
|
110
|
+
} catch (error) {
|
|
111
|
+
expect((error as Error).message).toContain('Server not found')
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test('switch: updates current server', async () => {
|
|
116
|
+
// given: credential manager
|
|
117
|
+
const credManager = new DiscordCredentialManager()
|
|
118
|
+
|
|
119
|
+
// when: switching server
|
|
120
|
+
await credManager.setCurrentServer('server-2')
|
|
121
|
+
|
|
122
|
+
// then: setCurrentServer is called
|
|
123
|
+
expect(credManager.setCurrentServer).toHaveBeenCalledWith('server-2')
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
test('current: returns current server info', async () => {
|
|
127
|
+
// given: credential manager with current server
|
|
128
|
+
const credManager = new DiscordCredentialManager()
|
|
129
|
+
const config = await credManager.load()
|
|
130
|
+
|
|
131
|
+
// when: getting current server
|
|
132
|
+
const current = await credManager.getCurrentServer()
|
|
133
|
+
|
|
134
|
+
// then: current server is returned
|
|
135
|
+
expect(current).toBe('server-1')
|
|
136
|
+
expect(config.current_server).toBe('server-1')
|
|
137
|
+
})
|
|
@@ -8,12 +8,12 @@ export async function listAction(options: { pretty?: boolean }): Promise<void> {
|
|
|
8
8
|
try {
|
|
9
9
|
const credManager = new DiscordCredentialManager()
|
|
10
10
|
const config = await credManager.load()
|
|
11
|
-
const
|
|
11
|
+
const servers = Object.values(config.servers)
|
|
12
12
|
|
|
13
|
-
const output =
|
|
14
|
-
id:
|
|
15
|
-
name:
|
|
16
|
-
current:
|
|
13
|
+
const output = servers.map((server) => ({
|
|
14
|
+
id: server.server_id,
|
|
15
|
+
name: server.server_name,
|
|
16
|
+
current: server.server_id === config.current_server,
|
|
17
17
|
}))
|
|
18
18
|
|
|
19
19
|
console.log(formatOutput(output, options.pretty))
|
|
@@ -22,7 +22,7 @@ export async function listAction(options: { pretty?: boolean }): Promise<void> {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export async function infoAction(
|
|
25
|
+
export async function infoAction(serverId: string, options: { pretty?: boolean }): Promise<void> {
|
|
26
26
|
try {
|
|
27
27
|
const credManager = new DiscordCredentialManager()
|
|
28
28
|
const config = await credManager.load()
|
|
@@ -35,13 +35,13 @@ export async function infoAction(guildId: string, options: { pretty?: boolean })
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const client = new DiscordClient(config.token)
|
|
38
|
-
const
|
|
38
|
+
const server = await client.getServer(serverId)
|
|
39
39
|
|
|
40
40
|
const output = {
|
|
41
|
-
id:
|
|
42
|
-
name:
|
|
43
|
-
icon:
|
|
44
|
-
owner:
|
|
41
|
+
id: server.id,
|
|
42
|
+
name: server.name,
|
|
43
|
+
icon: server.icon,
|
|
44
|
+
owner: server.owner,
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
console.log(formatOutput(output, options.pretty))
|
|
@@ -50,18 +50,18 @@ export async function infoAction(guildId: string, options: { pretty?: boolean })
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export async function switchAction(
|
|
53
|
+
export async function switchAction(serverId: string, options: { pretty?: boolean }): Promise<void> {
|
|
54
54
|
try {
|
|
55
55
|
const credManager = new DiscordCredentialManager()
|
|
56
56
|
const config = await credManager.load()
|
|
57
57
|
|
|
58
|
-
if (!config.
|
|
59
|
-
console.log(formatOutput({ error: `
|
|
58
|
+
if (!config.servers[serverId]) {
|
|
59
|
+
console.log(formatOutput({ error: `Server not found: ${serverId}` }, options.pretty))
|
|
60
60
|
process.exit(1)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
await credManager.
|
|
64
|
-
console.log(formatOutput({ current:
|
|
63
|
+
await credManager.setCurrentServer(serverId)
|
|
64
|
+
console.log(formatOutput({ current: serverId }, options.pretty))
|
|
65
65
|
} catch (error) {
|
|
66
66
|
handleError(error as Error)
|
|
67
67
|
}
|
|
@@ -72,25 +72,25 @@ export async function currentAction(options: { pretty?: boolean }): Promise<void
|
|
|
72
72
|
const credManager = new DiscordCredentialManager()
|
|
73
73
|
const config = await credManager.load()
|
|
74
74
|
|
|
75
|
-
if (!config.
|
|
75
|
+
if (!config.current_server) {
|
|
76
76
|
console.log(
|
|
77
|
-
formatOutput({ error: 'No current
|
|
77
|
+
formatOutput({ error: 'No current server set. Run "auth extract" first.' }, options.pretty)
|
|
78
78
|
)
|
|
79
79
|
process.exit(1)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
const
|
|
82
|
+
const server = config.servers[config.current_server]
|
|
83
83
|
|
|
84
|
-
if (!
|
|
84
|
+
if (!server) {
|
|
85
85
|
console.log(
|
|
86
|
-
formatOutput({ error: 'Current
|
|
86
|
+
formatOutput({ error: 'Current server not found in configuration.' }, options.pretty)
|
|
87
87
|
)
|
|
88
88
|
process.exit(1)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const output = {
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
server_id: server.server_id,
|
|
93
|
+
server_name: server.server_name,
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
console.log(formatOutput(output, options.pretty))
|
|
@@ -99,31 +99,31 @@ export async function currentAction(options: { pretty?: boolean }): Promise<void
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
export const
|
|
103
|
-
.description('
|
|
102
|
+
export const serverCommand = new Command('server')
|
|
103
|
+
.description('Server management commands')
|
|
104
104
|
.addCommand(
|
|
105
105
|
new Command('list')
|
|
106
|
-
.description('List all
|
|
106
|
+
.description('List all servers')
|
|
107
107
|
.option('--pretty', 'Pretty print JSON output')
|
|
108
108
|
.action(listAction)
|
|
109
109
|
)
|
|
110
110
|
.addCommand(
|
|
111
111
|
new Command('info')
|
|
112
|
-
.description('Get
|
|
113
|
-
.argument('<
|
|
112
|
+
.description('Get server info')
|
|
113
|
+
.argument('<server-id>', 'Server ID')
|
|
114
114
|
.option('--pretty', 'Pretty print JSON output')
|
|
115
115
|
.action(infoAction)
|
|
116
116
|
)
|
|
117
117
|
.addCommand(
|
|
118
118
|
new Command('switch')
|
|
119
|
-
.description('Switch to
|
|
120
|
-
.argument('<
|
|
119
|
+
.description('Switch to server')
|
|
120
|
+
.argument('<server-id>', 'Server ID')
|
|
121
121
|
.option('--pretty', 'Pretty print JSON output')
|
|
122
122
|
.action(switchAction)
|
|
123
123
|
)
|
|
124
124
|
.addCommand(
|
|
125
125
|
new Command('current')
|
|
126
|
-
.description('Show current
|
|
126
|
+
.description('Show current server')
|
|
127
127
|
.option('--pretty', 'Pretty print JSON output')
|
|
128
128
|
.action(currentAction)
|
|
129
129
|
)
|
|
@@ -7,7 +7,7 @@ test('snapshot: command is defined', () => {
|
|
|
7
7
|
})
|
|
8
8
|
|
|
9
9
|
test('snapshot: command has correct description', () => {
|
|
10
|
-
expect(snapshotCommand.description()).toContain('
|
|
10
|
+
expect(snapshotCommand.description()).toContain('server state')
|
|
11
11
|
})
|
|
12
12
|
|
|
13
13
|
test('snapshot: command has --channels-only option', () => {
|