Skip to content

[OINB-1959] Webhook listener command#35

Merged
daleal merged 3 commits intomainfrom
feat/webhook-listener
May 8, 2026
Merged

[OINB-1959] Webhook listener command#35
daleal merged 3 commits intomainfrom
feat/webhook-listener

Conversation

@daleal
Copy link
Copy Markdown
Member

@daleal daleal commented May 8, 2026

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.

@daleal daleal self-assigned this May 8, 2026
Copilot AI review requested due to automatic review settings May 8, 2026 23:08
@daleal daleal merged commit a0d3a9d into main May 8, 2026
2 checks passed
@daleal daleal deleted the feat/webhook-listener branch May 8, 2026 23:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 webhooks command 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 thread src/commands/webhooks.ts
Comment on lines +23 to +25
.action(async (_opts: unknown, actionCmd: Command) => {
const rootOpts = actionCmd.parent!.parent!.opts<RootOpts>()
const auth = resolveAuth(rootOpts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants