Conversation
There was a problem hiding this comment.
Pull request overview
Adds a webhooks listen utility command to the CLI by introducing an internal “CLI session” API call and an ActionCable/WebSocket relay listener, so developers can observe webhook events in real time from the terminal.
Changes:
- Added internal API client + webhook session creation (
/internal/v1/cli/sessions) with Zod validation. - Added ActionCable relay listener over WebSocket and webhook-event message handlers.
- Registered new
webhookscommand in CLI help/groups and added unit tests for the new modules/command help.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/webhooks/sessions.ts | Creates/validates CLI relay sessions for webhook streaming. |
| src/lib/webhooks/handlers.ts | Parses and prints incoming relay webhook-event messages. |
| src/lib/webhooks/tests/sessions.test.ts | Unit tests for session creation and response validation. |
| src/lib/webhooks/tests/handlers.test.ts | Unit tests for webhook relay handler output behavior. |
| src/lib/api.ts | New low-level fetch wrapper for internal API calls with error shaping. |
| src/lib/action-cable.ts | WebSocket ActionCable listener, subscription wiring, and message parsing. |
| src/lib/tests/action-cable.test.ts | Unit tests for ActionCable helpers and parsing behavior. |
| src/commands/webhooks.ts | Implements fintoc webhooks listen command and relay wiring. |
| src/index.ts | Registers webhooks command and includes it in Utilities help grouping. |
| src/tests/index.test.ts | Ensures help output includes webhooks and default help behavior. |
| package.json | Adds runtime deps (ws, zod) and dev dep (@types/ws). |
| package-lock.json | Lockfile updates for new dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+18
to
+23
| export const handleWebhookEvent: WebhookRelayHandler = (message, _options) => { | ||
| const result = webhookEventMessageSchema.safeParse(message) | ||
| if (!result.success) { | ||
| throw new Error(`Invalid webhook event message: ${z.prettifyError(result.error)}`) | ||
| } | ||
|
|
| throw new Error(`Invalid webhook event message: ${z.prettifyError(result.error)}`) | ||
| } | ||
|
|
||
| printJson(JSON.parse(result.data.event)) |
Comment on lines
+24
to
+27
| createWebhookRelayHandlers({}).webhook_event!(message) | ||
|
|
||
| expect(printJson).toHaveBeenCalledWith({ id: 'evt_123' }) | ||
| }) |
Comment on lines
+23
to
+25
| .action(async (_opts: unknown, actionCmd: Command) => { | ||
| const rootOpts = actionCmd.parent!.parent!.opts<RootOpts>() | ||
| const auth = resolveAuth(rootOpts) |
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.
Contexto
Faltaba poder escuchar los webhooks.
Que hay de nuevo?
Un comando para poder escuchar los webhooks directo en el CLI.
Tests
Tests unitarios y pruebas locales.