abxbus 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,45 +0,0 @@
1
- import { BaseEvent } from './base_event.js';
2
- import type { EventPattern, FindWindow } from './types.js';
3
- export type EventHistoryFindOptions = {
4
- past?: FindWindow;
5
- future?: FindWindow;
6
- child_of?: BaseEvent | null;
7
- event_is_child_of?: (event: BaseEvent, ancestor: BaseEvent) => boolean;
8
- wait_for_future_match?: (event_pattern: string | '*', matches: (event: BaseEvent) => boolean, future: FindWindow) => Promise<BaseEvent | null>;
9
- } & Record<string, unknown>;
10
- export type EventHistoryTrimOptions<TEvent extends BaseEvent = BaseEvent> = {
11
- is_event_complete?: (event: TEvent) => boolean;
12
- on_remove?: (event: TEvent) => void;
13
- owner_label?: string;
14
- max_history_size?: number | null;
15
- max_history_drop?: boolean;
16
- };
17
- export declare class EventHistory<TEvent extends BaseEvent = BaseEvent> implements Iterable<[string, TEvent]> {
18
- max_history_size: number | null;
19
- max_history_drop: boolean;
20
- private _events;
21
- private _warned_about_dropping_uncompleted_events;
22
- constructor(options?: {
23
- max_history_size?: number | null;
24
- max_history_drop?: boolean;
25
- });
26
- get size(): number;
27
- [Symbol.iterator](): Iterator<[string, TEvent]>;
28
- entries(): IterableIterator<[string, TEvent]>;
29
- keys(): IterableIterator<string>;
30
- values(): IterableIterator<TEvent>;
31
- clear(): void;
32
- get(event_id: string): TEvent | undefined;
33
- set(event_id: string, event: TEvent): this;
34
- has(event_id: string): boolean;
35
- delete(event_id: string): boolean;
36
- addEvent(event: TEvent): void;
37
- getEvent(event_id: string): TEvent | undefined;
38
- removeEvent(event_id: string): boolean;
39
- hasEvent(event_id: string): boolean;
40
- static normalizeEventPattern(event_pattern: EventPattern | '*'): string | '*';
41
- find(event_pattern: '*', where?: (event: TEvent) => boolean, options?: EventHistoryFindOptions): Promise<TEvent | null>;
42
- find<TMatch extends TEvent>(event_pattern: EventPattern<TMatch>, where?: (event: TMatch) => boolean, options?: EventHistoryFindOptions): Promise<TMatch | null>;
43
- trimEventHistory(options?: EventHistoryTrimOptions<TEvent>): number;
44
- private eventIsChildOf;
45
- }
@@ -1,86 +0,0 @@
1
- import { z } from 'zod';
2
- import { BaseEvent } from './base_event.js';
3
- import type { EventBus } from './event_bus.js';
4
- import { EventHandler } from './event_handler.js';
5
- import { type HandlerLock } from './lock_manager.js';
6
- import type { Deferred } from './lock_manager.js';
7
- import type { EventResultType } from './types.js';
8
- export type EventResultStatus = 'pending' | 'started' | 'completed' | 'error';
9
- export declare const EventResultJSONSchema: z.ZodObject<{
10
- id: z.ZodString;
11
- status: z.ZodEnum<{
12
- pending: "pending";
13
- started: "started";
14
- completed: "completed";
15
- error: "error";
16
- }>;
17
- event_id: z.ZodString;
18
- handler_id: z.ZodString;
19
- handler_name: z.ZodString;
20
- handler_file_path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
- handler_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
22
- handler_slow_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
23
- handler_registered_at: z.ZodOptional<z.ZodString>;
24
- handler_event_pattern: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>>;
25
- eventbus_name: z.ZodString;
26
- eventbus_id: z.ZodString;
27
- started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
- completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
- result: z.ZodOptional<z.ZodUnknown>;
30
- error: z.ZodOptional<z.ZodUnknown>;
31
- event_children: z.ZodArray<z.ZodString>;
32
- }, z.core.$strict>;
33
- export type EventResultJSON = z.infer<typeof EventResultJSONSchema>;
34
- export declare class EventResult<TEvent extends BaseEvent = BaseEvent> {
35
- id: string;
36
- status: EventResultStatus;
37
- event: TEvent;
38
- handler: EventHandler;
39
- started_at: string | null;
40
- completed_at: string | null;
41
- result?: EventResultType<TEvent>;
42
- error?: unknown;
43
- event_children: BaseEvent[];
44
- _abort: Deferred<never> | null;
45
- _lock: HandlerLock | null;
46
- _queue_jump_pause_releases: Map<EventBus, () => void> | null;
47
- constructor(params: {
48
- event: TEvent;
49
- handler: EventHandler;
50
- });
51
- toString(): string;
52
- get event_id(): string;
53
- get bus(): EventBus;
54
- get handler_id(): string;
55
- get handler_name(): string;
56
- get handler_file_path(): string | null;
57
- get eventbus_name(): string;
58
- get eventbus_id(): string;
59
- get eventbus_label(): string;
60
- private getHookBus;
61
- private _notifyStatusHook;
62
- get value(): EventResultType<TEvent> | undefined;
63
- get result_type(): TEvent['event_result_type'];
64
- _linkEmittedChildEvent(child_event: BaseEvent): void;
65
- get raw_value(): EventResultType<TEvent> | undefined;
66
- get handler_timeout(): number | null;
67
- get handler_slow_timeout(): number | null;
68
- _createSlowHandlerWarningTimer(effective_timeout: number | null): ReturnType<typeof setTimeout> | null;
69
- _ensureQueueJumpPause(bus: EventBus): void;
70
- _releaseQueueJumpPauses(): void;
71
- update(params: {
72
- status?: EventResultStatus;
73
- result?: EventResultType<TEvent> | BaseEvent | undefined;
74
- error?: unknown;
75
- }): this;
76
- private _createHandlerTimeoutError;
77
- private _handleHandlerError;
78
- private _onHandlerExit;
79
- runHandler(handler_lock: HandlerLock | null): Promise<void>;
80
- _signalAbort(error: Error): void;
81
- _markStarted(notify_hook?: boolean): Promise<never>;
82
- _markCompleted(result: EventResultType<TEvent> | BaseEvent | undefined, notify_hook?: boolean): void;
83
- _markError(error: unknown, notify_hook?: boolean): void;
84
- toJSON(): EventResultJSON;
85
- static fromJSON<TEvent extends BaseEvent>(event: TEvent, data: unknown): EventResult<TEvent>;
86
- }
@@ -1,70 +0,0 @@
1
- import type { BaseEvent } from './base_event.js';
2
- import type { EventResult } from './event_result.js';
3
- export type Deferred<T> = {
4
- promise: Promise<T>;
5
- resolve: (value: T | PromiseLike<T>) => void;
6
- reject: (reason?: unknown) => void;
7
- };
8
- export declare const withResolvers: <T>() => Deferred<T>;
9
- export declare const EVENT_CONCURRENCY_MODES: readonly ["global-serial", "bus-serial", "parallel"];
10
- export type EventConcurrencyMode = (typeof EVENT_CONCURRENCY_MODES)[number];
11
- export declare const EVENT_HANDLER_CONCURRENCY_MODES: readonly ["serial", "parallel"];
12
- export type EventHandlerConcurrencyMode = (typeof EVENT_HANDLER_CONCURRENCY_MODES)[number];
13
- export declare const EVENT_HANDLER_COMPLETION_MODES: readonly ["all", "first"];
14
- export type EventHandlerCompletionMode = (typeof EVENT_HANDLER_COMPLETION_MODES)[number];
15
- export declare class AsyncLock {
16
- size: number;
17
- in_use: number;
18
- waiters: Array<() => void>;
19
- constructor(size: number);
20
- acquire(): Promise<void>;
21
- release(): void;
22
- }
23
- export declare const runWithLock: <T>(lock: AsyncLock | null, fn: () => Promise<T>) => Promise<T>;
24
- export type HandlerExecutionState = 'held' | 'yielded' | 'closed';
25
- export declare class HandlerLock {
26
- private lock;
27
- private state;
28
- constructor(lock: AsyncLock | null);
29
- yieldHandlerLockForChildRun(): boolean;
30
- reclaimHandlerLockIfRunning(): Promise<boolean>;
31
- exitHandlerRun(): void;
32
- runQueueJump<T>(fn: () => Promise<T>): Promise<T>;
33
- }
34
- export type EventBusInterfaceForLockManager = {
35
- isIdleAndQueueEmpty: () => boolean;
36
- event_concurrency: EventConcurrencyMode;
37
- _lock_for_event_global_serial: AsyncLock;
38
- };
39
- export type LockManagerOptions = {
40
- auto_schedule_idle_checks?: boolean;
41
- };
42
- export declare class LockManager {
43
- private bus;
44
- private auto_schedule_idle_checks;
45
- readonly bus_event_lock: AsyncLock;
46
- private pause_depth;
47
- private pause_waiters;
48
- private active_handler_results;
49
- private idle_waiters;
50
- private idle_check_pending;
51
- private idle_check_streak;
52
- constructor(bus: EventBusInterfaceForLockManager, options?: LockManagerOptions);
53
- _requestRunloopPause(): () => void;
54
- _waitUntilRunloopResumed(): Promise<void>;
55
- _isPaused(): boolean;
56
- _runWithHandlerDispatchContext<T>(result: EventResult, fn: () => Promise<T>): Promise<T>;
57
- _getActiveHandlerResultForCurrentAsyncContext(): EventResult | undefined;
58
- _getActiveHandlerResults(): EventResult[];
59
- _isAnyHandlerActive(): boolean;
60
- waitForIdle(timeout_seconds?: number | null): Promise<boolean>;
61
- _notifyIdleListeners(): void;
62
- getLockForEvent(event: BaseEvent): AsyncLock | null;
63
- _runWithEventLock<T>(event: BaseEvent, fn: () => Promise<T>, options?: {
64
- bypass_event_locks?: boolean;
65
- pre_acquired_lock?: AsyncLock | null;
66
- }): Promise<T>;
67
- _runWithHandlerLock<T>(event: BaseEvent, default_handler_concurrency: EventHandlerConcurrencyMode | undefined, fn: (lock: HandlerLock | null) => Promise<T>): Promise<T>;
68
- private scheduleIdleCheck;
69
- clear(): void;
70
- }
@@ -1,49 +0,0 @@
1
- import { trace, type Span, type SpanAttributes, type SpanContext, type TimeInput, type Tracer } from '@opentelemetry/api';
2
- import type { BaseEvent } from './base_event.js';
3
- import type { EventBus } from './event_bus.js';
4
- import type { EventResult } from './event_result.js';
5
- import type { EventBusMiddleware } from './middlewares.js';
6
- import type { EventStatus } from './types.js';
7
- type OpenTelemetryTraceApi = Pick<typeof trace, 'getTracer' | 'setSpan'> & Partial<Pick<typeof trace, 'setSpanContext'>>;
8
- export type OtelTracingSpanFactoryInput = {
9
- name: string;
10
- span_context: SpanContext;
11
- parent_span_context?: SpanContext;
12
- attributes: SpanAttributes;
13
- start_time?: TimeInput;
14
- };
15
- export type OtelTracingSpanFactory = (input: OtelTracingSpanFactoryInput) => Span;
16
- export type OtelTracingSpanProvider = object;
17
- export type OtelTracingMiddlewareOptions = {
18
- tracer?: Tracer;
19
- trace_api?: OpenTelemetryTraceApi;
20
- span_provider?: OtelTracingSpanProvider;
21
- span_factory?: OtelTracingSpanFactory;
22
- otlp_endpoint?: string;
23
- service_name?: string;
24
- instrumentation_name?: string;
25
- root_span_attributes?: SpanAttributes | ((eventbus: EventBus, event: BaseEvent) => SpanAttributes);
26
- };
27
- export declare class OtelTracingMiddleware implements EventBusMiddleware {
28
- private readonly tracer;
29
- private readonly trace_api;
30
- private readonly span_factory?;
31
- private readonly span_provider?;
32
- private readonly root_span_attributes;
33
- private readonly event_spans;
34
- private readonly event_contexts;
35
- private readonly handler_spans;
36
- private readonly handler_contexts;
37
- constructor(options?: OtelTracingMiddlewareOptions);
38
- onEventChange(eventbus: EventBus, event: BaseEvent, status: EventStatus): void;
39
- onEventResultChange(eventbus: EventBus, event: BaseEvent, event_result: EventResult, status: EventStatus): void;
40
- private startEventSpan;
41
- private completeEventSpan;
42
- private startHandlerSpan;
43
- private completeHandlerSpan;
44
- private parentContextForEvent;
45
- private completeEventSpanWithFactory;
46
- private exportEventTreeWithFactory;
47
- private exportHandlerSpanWithFactory;
48
- }
49
- export {};
@@ -1,211 +0,0 @@
1
- import { z } from 'zod';
2
- import { EventBus } from './event_bus.js';
3
- import { EventResult } from './event_result.js';
4
- import { EventHandler } from './event_handler.js';
5
- import type { EventConcurrencyMode, EventHandlerConcurrencyMode, EventHandlerCompletionMode, Deferred } from './lock_manager.js';
6
- import { AsyncLock } from './lock_manager.js';
7
- import type { EventHandlerCallable, EventResultType } from './types.js';
8
- export declare const BaseEventSchema: z.ZodObject<{
9
- event_id: z.ZodString;
10
- event_created_at: z.ZodString;
11
- event_type: z.ZodString;
12
- event_version: z.ZodDefault<z.ZodString>;
13
- event_timeout: z.ZodNullable<z.ZodNumber>;
14
- event_slow_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
15
- event_handler_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
16
- event_handler_slow_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
17
- event_blocks_parent_completion: z.ZodOptional<z.ZodBoolean>;
18
- event_parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
- event_path: z.ZodOptional<z.ZodArray<z.ZodString>>;
20
- event_result_type: z.ZodOptional<z.ZodUnknown>;
21
- event_emitted_by_handler_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
- event_pending_bus_count: z.ZodOptional<z.ZodNumber>;
23
- event_status: z.ZodOptional<z.ZodEnum<{
24
- pending: "pending";
25
- started: "started";
26
- completed: "completed";
27
- }>>;
28
- event_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
- event_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
- event_results: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
31
- event_concurrency: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
32
- "global-serial": "global-serial";
33
- "bus-serial": "bus-serial";
34
- parallel: "parallel";
35
- }>>>;
36
- event_handler_concurrency: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
37
- parallel: "parallel";
38
- serial: "serial";
39
- }>>>;
40
- event_handler_completion: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
41
- all: "all";
42
- first: "first";
43
- }>>>;
44
- }, z.core.$loose>;
45
- export type BaseEventData = z.infer<typeof BaseEventSchema>;
46
- export type BaseEventJSON = BaseEventData & Record<string, unknown>;
47
- type BaseEventFields = Pick<BaseEventData, 'event_id' | 'event_created_at' | 'event_type' | 'event_version' | 'event_timeout' | 'event_slow_timeout' | 'event_handler_timeout' | 'event_handler_slow_timeout' | 'event_blocks_parent_completion' | 'event_parent_id' | 'event_path' | 'event_result_type' | 'event_emitted_by_handler_id' | 'event_pending_bus_count' | 'event_status' | 'event_started_at' | 'event_completed_at' | 'event_results' | 'event_concurrency' | 'event_handler_concurrency' | 'event_handler_completion'>;
48
- export type BaseEventInit<TFields extends Record<string, unknown>> = TFields & Partial<BaseEventFields>;
49
- type BaseEventSchemaShape = typeof BaseEventSchema.shape;
50
- export type EventSchema<TShape extends z.ZodRawShape> = z.ZodObject<BaseEventSchemaShape & TShape>;
51
- type EventPayload<TShape extends z.ZodRawShape> = TShape extends Record<string, never> ? {} : z.infer<z.ZodObject<TShape>>;
52
- type EventInput<TShape extends z.ZodRawShape> = z.input<EventSchema<TShape>>;
53
- export type EventInit<TShape extends z.ZodRawShape> = Omit<EventInput<TShape>, keyof BaseEventFields> & Partial<BaseEventFields>;
54
- type EventWithResultSchema<TResult> = BaseEvent & {
55
- __event_result_type__?: TResult;
56
- };
57
- type ResultTypeFromEventResultTypeInput<TInput> = TInput extends z.ZodTypeAny ? z.infer<TInput> : TInput extends StringConstructor ? string : TInput extends NumberConstructor ? number : TInput extends BooleanConstructor ? boolean : TInput extends ArrayConstructor ? unknown[] : TInput extends ObjectConstructor ? Record<string, unknown> : unknown;
58
- type ResultSchemaFromShape<TShape> = TShape extends {
59
- event_result_type: infer S;
60
- } ? ResultTypeFromEventResultTypeInput<S> : unknown;
61
- type EventResultsListInclude<TEvent extends BaseEvent> = (result: EventResultType<TEvent> | undefined, event_result: EventResult<TEvent>) => boolean;
62
- type EventResultsListOptions<TEvent extends BaseEvent> = {
63
- timeout?: number | null;
64
- include?: EventResultsListInclude<TEvent>;
65
- raise_if_any?: boolean;
66
- raise_if_none?: boolean;
67
- };
68
- type EventDoneOptions = {
69
- raise_if_any?: boolean;
70
- };
71
- type EventResultUpdateOptions<TEvent extends BaseEvent> = {
72
- eventbus?: EventBus;
73
- status?: 'pending' | 'started' | 'completed' | 'error';
74
- result?: EventResultType<TEvent> | BaseEvent | undefined;
75
- error?: unknown;
76
- };
77
- export type EventFactory<TShape extends z.ZodRawShape, TResult = unknown> = {
78
- (data: EventInit<TShape>): EventWithResultSchema<TResult> & EventPayload<TShape>;
79
- new (data: EventInit<TShape>): EventWithResultSchema<TResult> & EventPayload<TShape>;
80
- schema: EventSchema<TShape>;
81
- class?: new (data: EventInit<TShape>) => EventWithResultSchema<TResult> & EventPayload<TShape>;
82
- event_type?: string;
83
- event_version?: string;
84
- event_result_type?: z.ZodTypeAny;
85
- fromJSON?: (data: unknown) => EventWithResultSchema<TResult> & EventPayload<TShape>;
86
- };
87
- type ZodShapeFrom<TShape extends Record<string, unknown>> = {
88
- [K in keyof TShape as K extends 'event_result_type' ? never : TShape[K] extends z.ZodTypeAny ? K : never]: Extract<TShape[K], z.ZodTypeAny>;
89
- };
90
- export declare class BaseEvent {
91
- event_id: string;
92
- event_created_at: string;
93
- event_type: string;
94
- event_version: string;
95
- event_timeout: number | null;
96
- event_slow_timeout?: number | null;
97
- event_handler_timeout?: number | null;
98
- event_handler_slow_timeout?: number | null;
99
- event_blocks_parent_completion: boolean;
100
- event_parent_id: string | null;
101
- event_path: string[];
102
- event_result_type?: z.ZodTypeAny;
103
- event_results: Map<string, EventResult<this>>;
104
- event_emitted_by_handler_id: string | null;
105
- event_pending_bus_count: number;
106
- event_status: 'pending' | 'started' | 'completed';
107
- event_started_at: string | null;
108
- event_completed_at: string | null;
109
- event_concurrency?: EventConcurrencyMode | null;
110
- event_handler_concurrency?: EventHandlerConcurrencyMode | null;
111
- event_handler_completion?: EventHandlerCompletionMode | null;
112
- static event_type?: string;
113
- static event_version: string;
114
- static schema: z.ZodObject<{
115
- event_id: z.ZodString;
116
- event_created_at: z.ZodString;
117
- event_type: z.ZodString;
118
- event_version: z.ZodDefault<z.ZodString>;
119
- event_timeout: z.ZodNullable<z.ZodNumber>;
120
- event_slow_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
121
- event_handler_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
122
- event_handler_slow_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
123
- event_blocks_parent_completion: z.ZodOptional<z.ZodBoolean>;
124
- event_parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
125
- event_path: z.ZodOptional<z.ZodArray<z.ZodString>>;
126
- event_result_type: z.ZodOptional<z.ZodUnknown>;
127
- event_emitted_by_handler_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
128
- event_pending_bus_count: z.ZodOptional<z.ZodNumber>;
129
- event_status: z.ZodOptional<z.ZodEnum<{
130
- pending: "pending";
131
- started: "started";
132
- completed: "completed";
133
- }>>;
134
- event_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
135
- event_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
136
- event_results: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
137
- event_concurrency: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
138
- "global-serial": "global-serial";
139
- "bus-serial": "bus-serial";
140
- parallel: "parallel";
141
- }>>>;
142
- event_handler_concurrency: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
143
- parallel: "parallel";
144
- serial: "serial";
145
- }>>>;
146
- event_handler_completion: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
147
- all: "all";
148
- first: "first";
149
- }>>>;
150
- }, z.core.$loose>;
151
- event_bus?: EventBus;
152
- _event_original?: BaseEvent;
153
- _event_dispatch_context?: unknown | null;
154
- _event_completed_signal: Deferred<this> | null;
155
- _lock_for_event_handler: AsyncLock | null;
156
- constructor(data?: BaseEventInit<Record<string, unknown>>);
157
- toString(): string;
158
- static extend<TShape extends z.ZodRawShape>(event_type: string, shape?: TShape): EventFactory<TShape, ResultSchemaFromShape<TShape>>;
159
- static extend<TShape extends Record<string, unknown>>(event_type: string, shape?: TShape): EventFactory<ZodShapeFrom<TShape>, ResultSchemaFromShape<TShape>>;
160
- static fromJSON<T extends typeof BaseEvent>(this: T, data: unknown): InstanceType<T>;
161
- static toJSONArray(events: Iterable<BaseEvent>): BaseEventJSON[];
162
- static fromJSONArray(data: unknown): BaseEvent[];
163
- toJSON(): BaseEventJSON;
164
- _createSlowEventWarningTimer(): ReturnType<typeof setTimeout> | null;
165
- eventResultUpdate(handler: EventHandler | EventHandlerCallable<this>, options?: EventResultUpdateOptions<this>): EventResult<this>;
166
- _createPendingHandlerResults(bus: EventBus): Array<{
167
- handler: EventHandler;
168
- result: EventResult;
169
- }>;
170
- private _collectPendingResults;
171
- private _isFirstModeWinningResult;
172
- private _markFirstModeWinnerIfNeeded;
173
- private _runHandlerWithLock;
174
- _runHandlers(pending_entries?: Array<{
175
- handler: EventHandler;
176
- result: EventResult;
177
- }>): Promise<void>;
178
- _getHandlerLock(default_concurrency?: EventHandlerConcurrencyMode): AsyncLock | null;
179
- _setHandlerLock(lock: AsyncLock | null): void;
180
- _getDispatchContext(): unknown | null | undefined;
181
- _setDispatchContext(dispatch_context: unknown | null | undefined): void;
182
- get event_parent(): BaseEvent | undefined;
183
- get event_children(): BaseEvent[];
184
- get event_descendants(): BaseEvent[];
185
- emit<T extends BaseEvent>(event: T): T;
186
- _cancelPendingChildProcessing(reason: unknown): void;
187
- _markRemainingFirstModeResultCancelled(winner: EventResult): void;
188
- _markCancelled(cause: Error): void;
189
- _notifyEventParentsOfCompletion(): void;
190
- done(options?: EventDoneOptions): Promise<this>;
191
- first(): Promise<EventResultType<this> | undefined>;
192
- eventResultsList(include: EventResultsListInclude<this>, options?: EventResultsListOptions<this>): Promise<Array<EventResultType<this> | undefined>>;
193
- eventResultsList(options?: EventResultsListOptions<this>): Promise<Array<EventResultType<this> | undefined>>;
194
- eventCompleted(): Promise<this>;
195
- _markBlocksParentCompletionIfAwaitedFromEmittingHandler(): void;
196
- _markPending(): this;
197
- eventReset(): this;
198
- _markStarted(started_at?: string | null, notify_hook?: boolean): void;
199
- _markCompleted(force?: boolean, notify_parents?: boolean): void;
200
- private dropFromZeroHistoryBuses;
201
- get event_errors(): unknown[];
202
- private _isFirstModeControlError;
203
- _firstProcessingError(options?: {
204
- ignore_first_mode_control_errors?: boolean;
205
- }): unknown | undefined;
206
- get event_result(): EventResultType<this> | undefined;
207
- _areAllChildrenComplete(visited?: Set<string>): boolean;
208
- private _notifyDoneListeners;
209
- _gc(): void;
210
- }
211
- export {};
@@ -1,45 +0,0 @@
1
- import { BaseEvent } from './base_event.js';
2
- import { EventBus } from './event_bus.js';
3
- import type { EventClass, EventHandlerCallable, UntypedEventHandlerFunction } from './types.js';
4
- type EndpointScheme = 'unix' | 'http' | 'https';
5
- type ParsedEndpoint = {
6
- raw: string;
7
- scheme: EndpointScheme;
8
- host?: string;
9
- port?: number;
10
- path?: string;
11
- };
12
- export type HTTPEventBridgeOptions = {
13
- send_to?: string | null;
14
- listen_on?: string | null;
15
- name?: string;
16
- };
17
- export declare class EventBridge {
18
- readonly send_to: ParsedEndpoint | null;
19
- readonly listen_on: ParsedEndpoint | null;
20
- readonly name: string;
21
- protected readonly inbound_bus: EventBus;
22
- private start_promise;
23
- private node_server;
24
- constructor(send_to?: string | null, listen_on?: string | null, name?: string);
25
- on<T extends BaseEvent>(event_pattern: EventClass<T>, handler: EventHandlerCallable<T>): void;
26
- on<T extends BaseEvent>(event_pattern: string | '*', handler: UntypedEventHandlerFunction<T>): void;
27
- emit<T extends BaseEvent>(event: T): Promise<void>;
28
- dispatch<T extends BaseEvent>(event: T): Promise<void>;
29
- start(): Promise<void>;
30
- close(): Promise<void>;
31
- private ensureListenerStarted;
32
- private handleIncomingPayload;
33
- private sendHttp;
34
- private sendUnix;
35
- private startHttpListener;
36
- private startUnixListener;
37
- }
38
- export declare class HTTPEventBridge extends EventBridge {
39
- constructor(send_to?: string | null, listen_on?: string | null, name?: string);
40
- constructor(options?: HTTPEventBridgeOptions);
41
- }
42
- export declare class SocketEventBridge extends EventBridge {
43
- constructor(path?: string | null, name?: string);
44
- }
45
- export {};
@@ -1,26 +0,0 @@
1
- import { BaseEvent } from './base_event.js';
2
- import type { EventClass, EventHandlerCallable, UntypedEventHandlerFunction } from './types.js';
3
- export declare class JSONLEventBridge {
4
- readonly path: string;
5
- readonly poll_interval: number;
6
- readonly name: string;
7
- private readonly inbound_bus;
8
- private running;
9
- private byte_offset;
10
- private pending_line;
11
- private listener_task;
12
- constructor(path: string, poll_interval?: number, name?: string);
13
- on<T extends BaseEvent>(event_pattern: EventClass<T>, handler: EventHandlerCallable<T>): void;
14
- on<T extends BaseEvent>(event_pattern: string | '*', handler: UntypedEventHandlerFunction<T>): void;
15
- emit<T extends BaseEvent>(event: T): Promise<void>;
16
- dispatch<T extends BaseEvent>(event: T): Promise<void>;
17
- start(): Promise<void>;
18
- close(): Promise<void>;
19
- private ensureStarted;
20
- private listenLoop;
21
- private pollNewLines;
22
- private dispatchInboundPayload;
23
- private readAppended;
24
- private dirname;
25
- private loadFs;
26
- }
@@ -1,20 +0,0 @@
1
- import { BaseEvent } from './base_event.js';
2
- import type { EventClass, EventHandlerCallable, UntypedEventHandlerFunction } from './types.js';
3
- export declare class NATSEventBridge {
4
- readonly server: string;
5
- readonly subject: string;
6
- readonly name: string;
7
- private readonly inbound_bus;
8
- private running;
9
- private nc;
10
- private sub_task;
11
- constructor(server: string, subject: string, name?: string);
12
- on<T extends BaseEvent>(event_pattern: EventClass<T>, handler: EventHandlerCallable<T>): void;
13
- on<T extends BaseEvent>(event_pattern: string | '*', handler: UntypedEventHandlerFunction<T>): void;
14
- emit<T extends BaseEvent>(event: T): Promise<void>;
15
- dispatch<T extends BaseEvent>(event: T): Promise<void>;
16
- start(): Promise<void>;
17
- close(): Promise<void>;
18
- private ensureStarted;
19
- private dispatchInboundPayload;
20
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * PostgreSQL LISTEN/NOTIFY + flat-table bridge for forwarding events.
3
- */
4
- import { BaseEvent } from './base_event.js';
5
- import type { EventClass, EventHandlerCallable, UntypedEventHandlerFunction } from './types.js';
6
- export declare class PostgresEventBridge {
7
- readonly table_url: string;
8
- readonly dsn: string;
9
- readonly table: string;
10
- readonly channel: string;
11
- readonly name: string;
12
- private readonly inbound_bus;
13
- private running;
14
- private client;
15
- private table_columns;
16
- private notification_handler;
17
- constructor(table_url: string, channel?: string, name?: string);
18
- on<T extends BaseEvent>(event_pattern: EventClass<T>, handler: EventHandlerCallable<T>): void;
19
- on<T extends BaseEvent>(event_pattern: string | '*', handler: UntypedEventHandlerFunction<T>): void;
20
- emit<T extends BaseEvent>(event: T): Promise<void>;
21
- dispatch<T extends BaseEvent>(event: T): Promise<void>;
22
- start(): Promise<void>;
23
- close(): Promise<void>;
24
- private ensureStarted;
25
- private dispatchByEventId;
26
- private dispatchInboundPayload;
27
- private ensureTableExists;
28
- private ensureBaseIndexes;
29
- private refreshColumnCache;
30
- private ensureColumns;
31
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * Redis pub/sub bridge for forwarding events between runtimes.
3
- *
4
- * Usage:
5
- * // channel from URL path
6
- * const bridge = new RedisEventBridge('redis://user:pass@localhost:6379/1/my_channel')
7
- *
8
- * // explicit channel override
9
- * const bridge2 = new RedisEventBridge('redis://user:pass@localhost:6379/1', 'my_channel')
10
- *
11
- * URL format:
12
- * redis://user:pass@host:6379/<db>/<optional_channel>
13
- */
14
- import { BaseEvent } from './base_event.js';
15
- import type { EventClass, EventHandlerCallable, UntypedEventHandlerFunction } from './types.js';
16
- export declare class RedisEventBridge {
17
- readonly url: string;
18
- readonly channel: string;
19
- readonly name: string;
20
- private readonly inbound_bus;
21
- private running;
22
- private start_promise;
23
- private redis_pub;
24
- private redis_sub;
25
- constructor(redis_url: string, channel?: string, name?: string);
26
- on<T extends BaseEvent>(event_pattern: EventClass<T>, handler: EventHandlerCallable<T>): void;
27
- on<T extends BaseEvent>(event_pattern: string | '*', handler: UntypedEventHandlerFunction<T>): void;
28
- emit<T extends BaseEvent>(event: T): Promise<void>;
29
- dispatch<T extends BaseEvent>(event: T): Promise<void>;
30
- start(): Promise<void>;
31
- close(): Promise<void>;
32
- private ensureStarted;
33
- private dispatchInboundPayload;
34
- }
@@ -1,30 +0,0 @@
1
- import { BaseEvent } from './base_event.js';
2
- import type { EventClass, EventHandlerCallable, UntypedEventHandlerFunction } from './types.js';
3
- export declare class SQLiteEventBridge {
4
- readonly path: string;
5
- readonly table: string;
6
- readonly poll_interval: number;
7
- readonly name: string;
8
- private readonly inbound_bus;
9
- private running;
10
- private last_seen_event_created_at;
11
- private last_seen_event_id;
12
- private listener_task;
13
- private start_task;
14
- private db;
15
- private table_columns;
16
- constructor(path: string, table?: string, poll_interval?: number, name?: string);
17
- on<T extends BaseEvent>(event_pattern: EventClass<T>, handler: EventHandlerCallable<T>): void;
18
- on<T extends BaseEvent>(event_pattern: string | '*', handler: UntypedEventHandlerFunction<T>): void;
19
- emit<T extends BaseEvent>(event: T): Promise<void>;
20
- dispatch<T extends BaseEvent>(event: T): Promise<void>;
21
- start(): Promise<void>;
22
- close(): Promise<void>;
23
- private ensureStarted;
24
- private listenLoop;
25
- private dispatchInboundPayload;
26
- private refreshColumnCache;
27
- private ensureColumns;
28
- private ensureBaseIndexes;
29
- private setCursorToLatestRow;
30
- }