Skip to content

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

ConstantValue
DECISION_REQUESTEDdecision.requested
DECISION_ALLOWEDdecision.allowed
DECISION_BLOCKEDdecision.blocked
DECISION_ESCALATEDdecision.escalated

Pipelines

ConstantValue
PIPELINE_STARTEDpipeline.started
PIPELINE_COMPLETEDpipeline.completed
PIPELINE_FAILEDpipeline.failed
PIPELINE_COMPENSATEDpipeline.compensated

Payments

ConstantValue
PAYMENT_INITIATEDpayment.initiated
PAYMENT_COMPLETEDpayment.completed
PAYMENT_FAILEDpayment.failed
PAYMENT_REVERSEDpayment.reversed

Identity

ConstantValue
ACTOR_CREATEDactor.created
ACTOR_SUSPENDEDactor.suspended
ACTOR_REVOKEDactor.revoked
IDENTITY_RESOLVEDidentity.resolved

KYC

ConstantValue
KYC_SUBMITTEDkyc.submitted
KYC_APPROVEDkyc.approved
KYC_REJECTEDkyc.rejected

AI

ConstantValue
AI_INFERENCE_COMPLETEDai.inference_completed
AI_INFERENCE_FAILEDai.inference_failed

Fraud

ConstantValue
FRAUD_SIGNAL_DETECTEDfraud.signal_detected

hybriDB is the kernel inside Stellrai.