Events
Publish typed events to the hybriDB event bus. Events trigger downstream pipelines, update audit trails, and integrate with your own subscribers.
publishEvent()
typescript
const event = await hdb.publishEvent(input: PublishEventInput): Promise<HybriDBEvent>Input
typescript
interface PublishEventInput {
type: string; // use HYBRIDB_EVENT_TYPES constants
actorId: string;
payload: Record<string, unknown>;
metadata?: Record<string, unknown>;
}Example
typescript
import { HybriDBClient, HYBRIDB_EVENT_TYPES } from '@hybridb/sdk';
await hdb.publishEvent({
type: HYBRIDB_EVENT_TYPES.PAYMENT_COMPLETED,
actorId: 'user:alice',
payload: {
paymentId: 'pay_9k2x',
amount: 15000,
currency: 'USD',
},
});Built-in event types
Use the HYBRIDB_EVENT_TYPES constants to avoid typos:
typescript
import { HYBRIDB_EVENT_TYPES } from '@hybridb/sdk';Decisions
| Constant | Value |
|---|---|
DECISION_REQUESTED | decision.requested |
DECISION_ALLOWED | decision.allowed |
DECISION_BLOCKED | decision.blocked |
DECISION_ESCALATED | decision.escalated |
Pipelines
| Constant | Value |
|---|---|
PIPELINE_STARTED | pipeline.started |
PIPELINE_COMPLETED | pipeline.completed |
PIPELINE_FAILED | pipeline.failed |
PIPELINE_COMPENSATED | pipeline.compensated |
Payments
| Constant | Value |
|---|---|
PAYMENT_INITIATED | payment.initiated |
PAYMENT_COMPLETED | payment.completed |
PAYMENT_FAILED | payment.failed |
PAYMENT_REVERSED | payment.reversed |
Identity
| Constant | Value |
|---|---|
ACTOR_CREATED | actor.created |
ACTOR_SUSPENDED | actor.suspended |
ACTOR_REVOKED | actor.revoked |
IDENTITY_RESOLVED | identity.resolved |
KYC
| Constant | Value |
|---|---|
KYC_SUBMITTED | kyc.submitted |
KYC_APPROVED | kyc.approved |
KYC_REJECTED | kyc.rejected |
AI
| Constant | Value |
|---|---|
AI_INFERENCE_COMPLETED | ai.inference_completed |
AI_INFERENCE_FAILED | ai.inference_failed |
Fraud
| Constant | Value |
|---|---|
FRAUD_SIGNAL_DETECTED | fraud.signal_detected |