# Hook & Filter System

This system supports both hooks (actions/events) and filters (value transforms).

## Usage

### Register a Hook Listener (Action/Event)
```ts
import { HookManager } from './hook.manager';

// Register a hook listener
hookManager.register('user.created', async (event) => {
  console.log('User created:', event.data);
});

// Trigger the hook
await hookManager.trigger('user.created', { userId: 123 });
```

### Register a Filter Listener (Value Transform)
```ts
import { HookManager } from './hook.manager';

// Register a filter listener
hookManager.registerFilter('format.username', (value, event) => {
  return value.toUpperCase();
});

// Trigger the filter
const formatted = await hookManager.triggerFilter('format.username', 'john');
console.log(formatted); // 'JOHN'
```

### Priorities
You can pass a `priority` (higher runs first) when registering listeners:
```ts
hookManager.register('user.created', cb, 10); // Higher priority
hookManager.registerFilter('format.username', cb, 5);
```

### Unregister
```ts
hookManager.unregister('user.created', cb);
```

### Get Registered Hooks/Filters
```ts
hookManager.getRegisteredHooks();
hookManager.getRegisteredFilters();
```

### Clear All
```ts
hookRegistryService.clear(); // Hooks
hookRegistryService.clearFilters(); // Filters
```

## How to Test

1. **Unit Test**: Write a test that registers a hook/filter, triggers it, and checks the result.
2. **Integration**: Use in your service/controller, trigger hooks/filters on events (e.g., after user creation, before saving data, etc.).
3. **Console**: Register listeners in a bootstrap script or controller, trigger them, and observe logs/outputs.

---

**This system is now ready for both event-driven and value-transform use cases!**
