Skip to content

feat(core): implement TriggerHookAction handler#1494

Merged
kitelev merged 1 commit intomainfrom
feat/core-implement-triggerhookaction-handler
Jan 7, 2026
Merged

feat(core): implement TriggerHookAction handler#1494
kitelev merged 1 commit intomainfrom
feat/core-implement-triggerhookaction-handler

Conversation

@kitelev
Copy link
Owner

@kitelev kitelev commented Jan 7, 2026

Summary

Implements TriggerHookAction handler for ActionInterpreter (Phase 3, Handler 6/8).

Changes

  • Added webhookService as 5th constructor parameter to ActionInterpreter
  • Implemented triggerHookHandler with full functionality:
    • Takes hookName (required) and payload (optional) parameters
    • Dispatches webhook event via WebhookService.dispatchEvent()
    • Supports payload as JSON string or direct object
    • Includes currentAsset.path in webhook payload
    • Handles errors gracefully with descriptive messages
  • Added 7 comprehensive unit tests

Test Coverage

Test Case Status
Webhook triggering with hookName and payload
Missing hookName validation
WebhookService not initialized error
Object payload (not stringified)
Empty payload handling
Webhook dispatch failure handling
Including filePath from currentAsset

Technical Approach

private triggerHookHandler: ActionHandler = async (def, ctx) => {
  const hookName = def.params['hookName'] as string;
  const payload = def.params['payload'];

  // Dispatch via WebhookService
  await this.webhookService.dispatchEvent({
    event: "property.changed",
    timestamp: new Date().toISOString(),
    filePath: ctx.currentAsset?.path ?? "",
    data: { hookName, payload },
  });

  return { success: true };
};

Test Plan

  • All 7 new TriggerHookAction tests pass
  • All 60 ActionInterpreter tests pass
  • Build passes with no TypeScript errors
  • No new lint errors introduced

Closes #1410

Implements TriggerHookAction handler for ActionInterpreter (Issue #1410).

The handler:
- Takes hookName (required) and payload (optional) parameters
- Dispatches webhook event via WebhookService
- Supports payload as JSON string or direct object
- Includes currentAsset's filePath in webhook payload
- Handles errors gracefully with descriptive messages

Changes:
- Added webhookService as 5th constructor parameter to ActionInterpreter
- Implemented triggerHookHandler with full functionality
- Added 7 comprehensive unit tests for TriggerHookAction

Tests cover:
- Webhook triggering with hookName and payload
- Missing hookName validation
- WebhookService not initialized error
- Object payload (not stringified)
- Empty payload handling
- Webhook dispatch failure handling
- Including filePath from currentAsset

Closes #1410
@kitelev kitelev enabled auto-merge (squash) January 7, 2026 03:59
@kitelev kitelev merged commit 8df2f62 into main Jan 7, 2026
45 of 50 checks passed
@kitelev kitelev deleted the feat/core-implement-triggerhookaction-handler branch January 7, 2026 04:13
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.

[Core] Implement TriggerHookAction handler

1 participant