/** * module: event —— 对外类型(编码规范 §10.1)。 */ import type { Delivery, Envelope, EnvelopeDraft, EventId, ListenerId, ListenerSpec, OwnershipResolution, PositionId, RegisteredListener, TaskId } from '@contracts'; import type { InboundFacts, OutboundRef, OwnershipKeyRules } from './internal/domain/ownership.ts'; import type { ConsumptionPlan } from './internal/domain/delivery.ts'; export type { Delivery, Envelope, EnvelopeDraft, ListenerSpec, OwnershipResolution, RegisteredListener }; export type { InboundFacts, OutboundRef, OwnershipKeyRules, ConsumptionPlan }; export declare class ListenerDeadlineError extends Error { readonly detail: string; constructor(detail: string); } /** 发布结果 —— 三级消费的判定结果,ingest 路由据此回执 */ export type PublishResult = { readonly eventId: EventId; readonly plan: ConsumptionPlan; }; export type InboundResult = PublishResult & { readonly resolution: OwnershipResolution; }; export type EventService = { /** 先持久后投递:信封落 sys.event 与入队在同一事务 */ publish(draft: EnvelopeDraft): Promise; /** 通道入站:归属解析 → 归一 → 抛数据事件 */ ingestInbound(input: { readonly facts: InboundFacts; readonly rules: OwnershipKeyRules; readonly draft: EnvelopeDraft; }): Promise; getEvent(id: EventId): Promise; listByTask(taskId: TaskId, limit?: number): Promise; /** 监听注册表 —— 时限必配,注册即校验 */ registerListener(taskId: TaskId, spec: ListenerSpec): Promise; cancelListener(id: ListenerId): Promise; listListeners(taskId: TaskId): Promise; /** 到期扫描:抛时间事件,按阶梯催办 */ sweepExpiredListeners(): Promise; /** 出站关联记录 —— 归属解析①③级的对表来源 */ recordOutbound(ref: OutboundRef): Promise; /** 消费幂等:事件 ID × 消费者;已消费返回 false */ claimConsumption(eventId: EventId, consumer: string): Promise; /** 投递失败回执:重试或入死信 */ reportFailure(deliveryId: string, error: string): Promise; }; /** 无主兜底的收件岗位 —— 由通道实例配置给出 */ export type FallbackPosition = PositionId;