feat: add discord service emulator#90
Open
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
Open
Conversation
Contributor
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
81d88ae to
bd75dd5
Compare
Type-check failure on the GitHub Actions build caught a stale 5-arg seedFromConfig() call in the test. The signature is now 4 args (the tokenMap parameter moved to a closure captured during plugin.register to match the slack pattern, see this branch's earlier rebase commit). Tests still set up tokenMap correctly via the prior register() call -- this is just removing the redundant trailing arg.
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
Adds a Discord service emulator with stateful guilds, channels, members, roles, and messages, plus full OAuth 2.0 (authorization code flow) and a Message / Guild Inspector. Snowflake IDs match Discord's documented 64-bit format. Both
Authorization: Bot <token>andAuthorization: Bearer <token>are supported.Closes the OAuth + REST surface — interactions / signature verification, guild webhooks, and Gateway WebSocket are intentionally separate follow-ups.
Why this matters
Discord has become the community plane for most modern SaaS — community bots, role automation, slash-command integrations, magic-link sign-ins through Discord OAuth. The official
discord.jsSDK has ~700K weekly npm downloads and@discordjs/restis in every modern bot stack. CI tests against Discord today either hit production (rate limits, real users, real channels) or stub at the HTTP level. No general-purpose emulator covers Discord — WireMock is too low-level and MSW is browser-only.emulate's
Storegives us stateful guilds + channels + messages; the shared OAuth helpers give us a real authorization_code + Bearer/Bot token flow.Inspector
Browse seeded guilds, channels, messages, members, and roles. Tabbed navigation, terminal-green aesthetic from
core/src/ui.ts.OAuth Consent
Standard
/oauth2/authorizeflow with a user picker.Discord API Coverage
GET /api/v10/users/@meGET /api/v10/guilds/POSTGET /api/v10/guilds/:idPATCH /api/v10/guilds/:id/DELETEGET /api/v10/guilds/:id/channels/POSTGET /api/v10/channels/:id/PATCH/DELETEGET /api/v10/channels/:id/messages/POSTGET /api/v10/channels/:id/messages/:id/PATCH/DELETEGET /api/v10/guilds/:id/membersPUT /api/v10/guilds/:id/members/:userIdPATCH /api/v10/guilds/:id/members/:userId/DELETEGET /api/v10/guilds/:id/roles/POSTPATCH /api/v10/guilds/:id/roles/:roleId/DELETEGET /oauth2/authorizePOST /api/oauth2/tokenBot tokens
Configure applications in seed config; bot tokens auto-register with the emulator's tokenMap so
Authorization: Bot <token>works immediately:Default port
4012(appended at the end ofSERVICE_NAME_LISTafterclerk— no other service's port shifts).What's not yet covered
WebhookDispatcher(separate PR)Tests
35 Vitest tests covering guild / channel / message / member / role CRUD, OAuth code flow, snowflake bit layout, both auth header shapes (
BotandBearer), inspector rendering, and seed-config token registration.