Event
User-facing event (flow type) definitions and decorators
An Event is a user-facing flow type that appears in the Code0 platform UI as a trigger for flows. It is always
linked to a RuntimeEvent which defines the internal behaviour.
import { Identifier, Name, Editable } from '@code0-tech/hercules';Overview
Events follow the same two-layer pattern as functions:
- RuntimeEvent — the internal event definition (identifier, signature, settings)
- Event — extends the RuntimeEvent, adds public metadata, registered separately
// Internal layer
@Identifier('user_created')
@Signature('(userId: number): void')
@Name({ code: 'en-US', content: 'User Created' })
export class UserCreatedRuntimeEvent {}
// Public layer
@Identifier('user_created_event')
@Name({ code: 'en-US', content: 'On User Created' })
@Editable(false)
export class UserCreatedEvent extends UserCreatedRuntimeEvent {}Register both with the Action:
action.registerRuntimeEventClass(UserCreatedRuntimeEvent);
action.registerEventClass(UserCreatedEvent);The resulting descriptor stored in action.events is documented on the EventManager page.
EventClass
type EventClass<T extends RuntimeEventClass = RuntimeEventClass> = new () => InstanceType<T>;The constructor type used when calling action.registerEventClass().
Firing an Event
await action.fire(UserCreatedRuntimeEvent, projectId, { userId: 42 });See action.fire() for the full reference.
Decorators
| Decorator | Description |
|---|---|
@Identifier | Sets the unique runtime identifier |
@Name | Sets the localised display name |
@Description | Sets a short localised description |
@Documentation | Sets long-form documentation text |
@DisplayMessage | Sets the summary text shown in the flow UI |
@Alias | Sets alternative search terms |
@DeprecationMessage | Marks the event as deprecated |
@Signature | Sets the TypeScript-like signature string |
@DisplayIcon | Sets the icon shown in the flow UI |
@Editable | Controls editability in the platform UI |
@EventSetting | Adds a configurable setting |
@OmitEvent | Prevents auto-generation of a public event definition |