@gravito/core 1.6.0 → 2.0.0

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.
Files changed (171) hide show
  1. package/README.md +100 -6
  2. package/README.zh-TW.md +101 -6
  3. package/dist/Application.d.ts +256 -0
  4. package/dist/CommandKernel.d.ts +33 -0
  5. package/dist/ConfigManager.d.ts +65 -0
  6. package/dist/Container/RequestScopeManager.d.ts +62 -0
  7. package/dist/Container/RequestScopeMetrics.d.ts +144 -0
  8. package/dist/Container.d.ts +153 -0
  9. package/dist/ErrorHandler.d.ts +66 -0
  10. package/dist/Event.d.ts +5 -0
  11. package/dist/EventManager.d.ts +123 -0
  12. package/dist/GlobalErrorHandlers.d.ts +47 -0
  13. package/dist/GravitoServer.d.ts +28 -0
  14. package/dist/HookManager.d.ts +435 -0
  15. package/dist/Listener.d.ts +4 -0
  16. package/dist/Logger.d.ts +20 -0
  17. package/dist/PlanetCore.d.ts +402 -0
  18. package/dist/RequestContext.d.ts +97 -0
  19. package/dist/Route.d.ts +36 -0
  20. package/dist/Router.d.ts +270 -0
  21. package/dist/ServiceProvider.d.ts +178 -0
  22. package/dist/adapters/GravitoEngineAdapter.d.ts +27 -0
  23. package/dist/adapters/bun/AdaptiveAdapter.d.ts +99 -0
  24. package/dist/adapters/bun/BunContext.d.ts +54 -0
  25. package/dist/adapters/bun/BunNativeAdapter.d.ts +66 -0
  26. package/dist/adapters/bun/BunRequest.d.ts +31 -0
  27. package/dist/adapters/bun/BunWebSocketHandler.d.ts +48 -0
  28. package/dist/adapters/bun/RadixNode.d.ts +19 -0
  29. package/dist/adapters/bun/RadixRouter.d.ts +32 -0
  30. package/dist/adapters/bun/index.d.ts +7 -0
  31. package/dist/adapters/bun/types.d.ts +20 -0
  32. package/dist/adapters/index.d.ts +12 -0
  33. package/dist/adapters/types.d.ts +235 -0
  34. package/dist/binary/BinaryUtils.d.ts +105 -0
  35. package/dist/binary/index.d.ts +5 -0
  36. package/dist/cli/queue-commands.d.ts +6 -0
  37. package/dist/compat/async-local-storage.browser.d.ts +9 -0
  38. package/dist/compat/async-local-storage.d.ts +7 -0
  39. package/dist/compat/crypto.browser.d.ts +5 -0
  40. package/dist/compat/crypto.d.ts +6 -0
  41. package/dist/compat.cjs +42 -11
  42. package/dist/compat.cjs.map +9 -0
  43. package/dist/compat.d.ts +23 -1
  44. package/dist/compat.js +3 -0
  45. package/dist/compat.js.map +9 -0
  46. package/dist/engine/AOTRouter.d.ts +139 -0
  47. package/dist/engine/FastContext.d.ts +141 -0
  48. package/dist/engine/Gravito.d.ts +131 -0
  49. package/dist/engine/MinimalContext.d.ts +102 -0
  50. package/dist/engine/analyzer.d.ts +113 -0
  51. package/dist/engine/constants.d.ts +23 -0
  52. package/dist/engine/index.cjs +758 -532
  53. package/dist/engine/index.cjs.map +22 -0
  54. package/dist/engine/index.d.ts +14 -690
  55. package/dist/engine/index.js +758 -508
  56. package/dist/engine/index.js.map +22 -0
  57. package/dist/engine/path.d.ts +26 -0
  58. package/dist/engine/pool.d.ts +83 -0
  59. package/dist/engine/types.d.ts +149 -0
  60. package/dist/error-handling/RequestScopeErrorContext.d.ts +126 -0
  61. package/dist/events/BackpressureManager.d.ts +215 -0
  62. package/dist/events/CircuitBreaker.d.ts +229 -0
  63. package/dist/events/DeadLetterQueue.d.ts +219 -0
  64. package/dist/events/EventBackend.d.ts +12 -0
  65. package/dist/events/EventOptions.d.ts +204 -0
  66. package/dist/events/EventPriorityQueue.d.ts +63 -0
  67. package/dist/events/FlowControlStrategy.d.ts +109 -0
  68. package/dist/events/IdempotencyCache.d.ts +60 -0
  69. package/dist/events/MessageQueueBridge.d.ts +184 -0
  70. package/dist/events/PriorityEscalationManager.d.ts +82 -0
  71. package/dist/events/RetryScheduler.d.ts +104 -0
  72. package/dist/events/WorkerPool.d.ts +98 -0
  73. package/dist/events/WorkerPoolConfig.d.ts +153 -0
  74. package/dist/events/WorkerPoolMetrics.d.ts +65 -0
  75. package/dist/events/aggregation/AggregationWindow.d.ts +77 -0
  76. package/dist/events/aggregation/DeduplicationManager.d.ts +135 -0
  77. package/dist/events/aggregation/EventAggregationManager.d.ts +108 -0
  78. package/dist/events/aggregation/EventBatcher.d.ts +99 -0
  79. package/dist/events/aggregation/index.d.ts +10 -0
  80. package/dist/events/aggregation/types.d.ts +117 -0
  81. package/dist/events/index.d.ts +26 -0
  82. package/dist/events/observability/EventMetrics.d.ts +132 -0
  83. package/dist/events/observability/EventTracer.d.ts +68 -0
  84. package/dist/events/observability/EventTracing.d.ts +161 -0
  85. package/dist/events/observability/OTelEventMetrics.d.ts +332 -0
  86. package/dist/events/observability/ObservableHookManager.d.ts +108 -0
  87. package/dist/events/observability/StreamWorkerMetrics.d.ts +76 -0
  88. package/dist/events/observability/index.d.ts +24 -0
  89. package/dist/events/observability/metrics-types.d.ts +16 -0
  90. package/dist/events/queue-core.d.ts +77 -0
  91. package/dist/events/task-executor.d.ts +51 -0
  92. package/dist/events/types.d.ts +134 -0
  93. package/dist/exceptions/AuthenticationException.d.ts +8 -0
  94. package/dist/exceptions/AuthorizationException.d.ts +8 -0
  95. package/dist/exceptions/CircularDependencyException.d.ts +9 -0
  96. package/dist/exceptions/GravitoException.d.ts +23 -0
  97. package/dist/exceptions/HttpException.d.ts +9 -0
  98. package/dist/exceptions/ModelNotFoundException.d.ts +10 -0
  99. package/dist/exceptions/ValidationException.d.ts +22 -0
  100. package/dist/exceptions/index.d.ts +7 -0
  101. package/dist/ffi/NativeAccelerator.d.ts +69 -0
  102. package/dist/ffi/NativeHasher.d.ts +139 -0
  103. package/dist/ffi/cbor-fallback.d.ts +96 -0
  104. package/dist/ffi/hash-fallback.d.ts +33 -0
  105. package/dist/ffi/index.cjs +621 -0
  106. package/dist/ffi/index.cjs.map +14 -0
  107. package/dist/ffi/index.d.ts +10 -0
  108. package/dist/ffi/index.js +602 -0
  109. package/dist/ffi/index.js.map +14 -0
  110. package/dist/ffi/types.d.ts +135 -0
  111. package/dist/health/HealthProvider.d.ts +67 -0
  112. package/dist/helpers/Arr.d.ts +19 -0
  113. package/dist/helpers/Str.d.ts +38 -0
  114. package/dist/helpers/data.d.ts +25 -0
  115. package/dist/helpers/errors.d.ts +34 -0
  116. package/dist/helpers/response.d.ts +41 -0
  117. package/dist/helpers.d.ts +338 -0
  118. package/dist/hooks/ActionManager.d.ts +132 -0
  119. package/dist/hooks/AsyncDetector.d.ts +84 -0
  120. package/dist/hooks/FilterManager.d.ts +71 -0
  121. package/dist/hooks/MigrationWarner.d.ts +24 -0
  122. package/dist/hooks/dlq-operations.d.ts +60 -0
  123. package/dist/hooks/index.d.ts +11 -0
  124. package/dist/hooks/types.d.ts +107 -0
  125. package/dist/http/CookieJar.d.ts +51 -0
  126. package/dist/http/cookie.d.ts +29 -0
  127. package/dist/http/index.d.ts +12 -0
  128. package/dist/{compat-C4Src6NN.d.cts → http/types.d.ts} +48 -16
  129. package/dist/index.browser.d.ts +34 -0
  130. package/dist/index.cjs +12909 -9492
  131. package/dist/index.cjs.map +168 -0
  132. package/dist/index.d.ts +58 -8707
  133. package/dist/index.js +12906 -9381
  134. package/dist/index.js.map +168 -0
  135. package/dist/observability/QueueDashboard.d.ts +136 -0
  136. package/dist/observability/contracts.d.ts +137 -0
  137. package/dist/observability/index.d.ts +13 -0
  138. package/dist/reliability/DeadLetterQueueManager.d.ts +349 -0
  139. package/dist/reliability/RetryPolicy.d.ts +217 -0
  140. package/dist/reliability/index.d.ts +6 -0
  141. package/dist/router/ControllerDispatcher.d.ts +12 -0
  142. package/dist/router/RequestValidator.d.ts +20 -0
  143. package/dist/runtime/adapter-bun.d.ts +12 -0
  144. package/dist/runtime/adapter-deno.d.ts +12 -0
  145. package/dist/runtime/adapter-node.d.ts +12 -0
  146. package/dist/runtime/adapter-unknown.d.ts +13 -0
  147. package/dist/runtime/archive.d.ts +17 -0
  148. package/dist/runtime/compression.d.ts +21 -0
  149. package/dist/runtime/deep-equals.d.ts +56 -0
  150. package/dist/runtime/detection.d.ts +22 -0
  151. package/dist/runtime/escape.d.ts +34 -0
  152. package/dist/runtime/index.browser.d.ts +20 -0
  153. package/dist/runtime/index.d.ts +44 -0
  154. package/dist/runtime/markdown.d.ts +44 -0
  155. package/dist/runtime/types.d.ts +436 -0
  156. package/dist/runtime-helpers.d.ts +67 -0
  157. package/dist/runtime.d.ts +11 -0
  158. package/dist/security/Encrypter.d.ts +33 -0
  159. package/dist/security/Hasher.d.ts +29 -0
  160. package/dist/testing/HttpTester.d.ts +39 -0
  161. package/dist/testing/TestResponse.d.ts +78 -0
  162. package/dist/testing/index.d.ts +2 -0
  163. package/dist/transpiler-utils.d.ts +170 -0
  164. package/dist/types/events.d.ts +94 -0
  165. package/dist/types.d.ts +13 -0
  166. package/package.json +23 -53
  167. package/src/ffi/native/cbor.c +1148 -0
  168. package/dist/compat-C4Src6NN.d.ts +0 -357
  169. package/dist/compat.d.cts +0 -1
  170. package/dist/engine/index.d.cts +0 -702
  171. package/dist/index.d.cts +0 -8734
@@ -0,0 +1,435 @@
1
+ import { DeadLetterQueue } from './events/DeadLetterQueue';
2
+ import type { EventBackend } from './events/EventBackend';
3
+ import type { EventOptions } from './events/EventOptions';
4
+ import { EventPriorityQueue } from './events/EventPriorityQueue';
5
+ import { DeadLetterQueueManager } from './reliability/DeadLetterQueueManager';
6
+ export type { ActionCallback, FilterCallback, HookManagerConfig, ListenerInfo, ListenerOptions, } from './hooks/types';
7
+ import type { ActionCallback, FilterCallback, HookManagerConfig, ListenerInfo, ListenerOptions } from './hooks/types';
8
+ /**
9
+ * Manager for WordPress-style hooks (actions and filters).
10
+ *
11
+ * 此為 facade 類別,將職責委派給專門的管理器:
12
+ * - FilterManager:處理 filter hook 的登記與執行
13
+ * - ActionManager:處理 action hook 的登記與執行
14
+ * - AsyncDetector:非同步偵測快取
15
+ * - MigrationWarner:遷移警告管理
16
+ *
17
+ * @public
18
+ */
19
+ export declare class HookManager {
20
+ private filterManager;
21
+ private actionManager;
22
+ private asyncDetector;
23
+ private migrationWarner;
24
+ private eventQueue;
25
+ private backend;
26
+ private dlq?;
27
+ private persistentDlqManager?;
28
+ private messageQueueBridge?;
29
+ private config;
30
+ constructor(config?: HookManagerConfig);
31
+ /**
32
+ * Register a filter hook.
33
+ *
34
+ * Filters are used to transform a value (input/output) through a chain of
35
+ * callbacks. Each callback must return the modified value.
36
+ *
37
+ * @template T - The type of value being filtered.
38
+ * @param hook - The unique name of the hook.
39
+ * @param callback - The callback function to execute.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * core.hooks.addFilter('content', async (content: string) => {
44
+ * return content.toUpperCase()
45
+ * })
46
+ * ```
47
+ */
48
+ addFilter<T = unknown>(hook: string, callback: FilterCallback<T>): void;
49
+ /**
50
+ * Apply all registered filters sequentially.
51
+ *
52
+ * Each callback receives the previous callback's return value.
53
+ *
54
+ * @template T - The type of value being filtered.
55
+ * @param hook - The name of the hook.
56
+ * @param initialValue - The initial value to filter.
57
+ * @param args - Additional arguments to pass to the callbacks.
58
+ * @returns The final filtered value.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const content = await core.hooks.applyFilters('content', 'hello world')
63
+ * ```
64
+ */
65
+ applyFilters<T = unknown>(hook: string, initialValue: T, ...args: unknown[]): Promise<T>;
66
+ /**
67
+ * Register an action hook.
68
+ *
69
+ * Actions are used to trigger side effects (e.g., logging, sending emails)
70
+ * at specific points in the application lifecycle.
71
+ *
72
+ * @template TArgs - The type of arguments passed to the action.
73
+ * @param hook - The unique name of the hook.
74
+ * @param callback - The callback function to execute.
75
+ * @param options - Optional listener options (type override, circuit breaker).
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * core.hooks.addAction('user_registered', async (user: User) => {
80
+ * await sendWelcomeEmail(user)
81
+ * })
82
+ * ```
83
+ */
84
+ addAction<TArgs = unknown>(hook: string, callback: ActionCallback<TArgs>, options?: ListenerOptions): void;
85
+ /**
86
+ * Run all registered actions.
87
+ *
88
+ * This method supports both synchronous and asynchronous dispatch based on configuration.
89
+ * In hybrid mode, it auto-detects async listeners and uses async dispatch.
90
+ *
91
+ * 注意:dispatch 模式決策在此層級完成,以確保子類別(如 ObservableHookManager)
92
+ * 可透過多型覆寫正確攔截 doActionSync / doActionAsync 的呼叫。
93
+ *
94
+ * @template TArgs - The type of arguments passed to the action.
95
+ * @param hook - The name of the hook.
96
+ * @param args - The arguments to pass to the callbacks.
97
+ * @param options - Optional event options for async dispatch.
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * await core.hooks.doAction('user_registered', user)
102
+ * ```
103
+ */
104
+ doAction<TArgs = unknown>(hook: string, args: TArgs, options?: EventOptions): Promise<void>;
105
+ /**
106
+ * Run all registered actions synchronously (legacy mode).
107
+ *
108
+ * @template TArgs - The type of arguments passed to the action.
109
+ * @param hook - The name of the hook.
110
+ * @param args - The arguments to pass to the callbacks.
111
+ */
112
+ doActionSync<TArgs = unknown>(hook: string, args: TArgs): Promise<void>;
113
+ /**
114
+ * Run all registered actions asynchronously via priority queue.
115
+ *
116
+ * @template TArgs - The type of arguments passed to the action.
117
+ * @param hook - The name of the hook.
118
+ * @param args - The arguments to pass to the callbacks.
119
+ * @param options - Event options for async dispatch.
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * await core.hooks.doActionAsync('order:created', order, {
124
+ * priority: 'high',
125
+ * ordering: 'partition',
126
+ * partitionKey: order.id,
127
+ * timeout: 5000,
128
+ * })
129
+ * ```
130
+ */
131
+ doActionAsync<TArgs = unknown>(hook: string, args: TArgs, options?: EventOptions): Promise<void>;
132
+ /**
133
+ * Determine the dispatch mode for an event.
134
+ *
135
+ * @param eventName - The name of the event
136
+ * @param options - Optional event options
137
+ * @returns The dispatch mode: 'sync' or 'async'
138
+ * @public
139
+ */
140
+ detectMode(eventName: string, options?: EventOptions): 'sync' | 'async';
141
+ /**
142
+ * Check if a callback is an async function (with caching).
143
+ *
144
+ * @param callback - The callback to check
145
+ * @returns True if the callback is async
146
+ * @public
147
+ */
148
+ isAsyncListener(callback: ActionCallback): boolean;
149
+ /**
150
+ * Runtime detection for functions that return Promises but aren't declared async.
151
+ *
152
+ * @param callback - The callback to check
153
+ * @param testArgs - Arguments to pass to the callback for testing
154
+ * @returns True if the callback returns a Promise
155
+ * @public
156
+ */
157
+ isAsyncListenerRuntime<TArgs = unknown>(callback: ActionCallback<TArgs>, testArgs: TArgs): Promise<boolean>;
158
+ /**
159
+ * Get the size of the async detection cache (for testing/debugging).
160
+ *
161
+ * @returns Number of cached detection results
162
+ * @public
163
+ */
164
+ getAsyncDetectionCacheSize(): number;
165
+ /**
166
+ * Clear the async detection cache.
167
+ *
168
+ * @public
169
+ */
170
+ clearAsyncDetectionCache(): void;
171
+ /**
172
+ * Check if any listener for a hook is async (including type overrides).
173
+ *
174
+ * @param hook - Hook name
175
+ * @returns True if any listener is async
176
+ * @public
177
+ */
178
+ hasAsyncListeners(hook: string): boolean;
179
+ /**
180
+ * Get detailed information about all listeners for a hook.
181
+ *
182
+ * @param hook - Hook name
183
+ * @returns Array of listener info objects
184
+ * @public
185
+ */
186
+ getListenerInfo(hook: string): ListenerInfo[];
187
+ /**
188
+ * Get the current event queue depth.
189
+ *
190
+ * @returns Total number of events in the queue
191
+ */
192
+ getQueueDepth(): number;
193
+ /**
194
+ * Get the event queue depth for a specific priority.
195
+ *
196
+ * @param priority - Priority level
197
+ * @returns Number of events in the specified priority queue
198
+ */
199
+ getQueueDepthByPriority(priority: 'high' | 'normal' | 'low'): number;
200
+ /**
201
+ * Get the EventPriorityQueue instance.
202
+ *
203
+ * @returns EventPriorityQueue instance
204
+ * @protected
205
+ */
206
+ protected getEventQueue(): EventPriorityQueue;
207
+ /**
208
+ * Get all registered listeners for a hook.
209
+ *
210
+ * @param hook - Hook name
211
+ * @returns Array of callbacks
212
+ */
213
+ getListeners(hook: string): ActionCallback[];
214
+ /**
215
+ * Remove all listeners for a specific action hook.
216
+ *
217
+ * @param hook - Hook name
218
+ */
219
+ removeAction(hook: string): void;
220
+ /**
221
+ * Update HookManager configuration.
222
+ *
223
+ * @param config - New configuration
224
+ */
225
+ configure(config: Partial<HookManagerConfig>): void;
226
+ /**
227
+ * Get current configuration.
228
+ *
229
+ * @returns Current configuration
230
+ */
231
+ getConfig(): HookManagerConfig;
232
+ /**
233
+ * Suppress migration warnings for a specific event.
234
+ *
235
+ * @param eventName - The name of the event to suppress warnings for
236
+ * @public
237
+ */
238
+ suppressMigrationWarning(eventName: string): void;
239
+ /**
240
+ * Set the event backend for distributed processing.
241
+ *
242
+ * @param backend - Event backend instance
243
+ */
244
+ setBackend(backend: EventBackend): void;
245
+ /**
246
+ * Get the Dead Letter Queue instance.
247
+ *
248
+ * @returns Dead Letter Queue
249
+ */
250
+ getDLQ(): DeadLetterQueue | undefined;
251
+ /**
252
+ * Requeue a failed event from the Dead Letter Queue.
253
+ *
254
+ * @param dlqEntryId - DLQ entry ID
255
+ * @returns True if requeued successfully, false if entry not found
256
+ */
257
+ requeueDLQEntry(dlqEntryId: string): Promise<boolean>;
258
+ /**
259
+ * Requeue all failed events for a specific event name.
260
+ *
261
+ * @param eventName - Event name to requeue
262
+ * @returns Number of events requeued
263
+ */
264
+ requeueDLQBatch(eventName: string): Promise<number>;
265
+ /**
266
+ * Get Dead Letter Queue entries with optional filtering.
267
+ *
268
+ * @param filter - Filter options
269
+ * @returns Array of DLQ entries
270
+ */
271
+ getDLQEntries(filter?: {
272
+ eventName?: string;
273
+ from?: number;
274
+ to?: number;
275
+ limit?: number;
276
+ }): import("./events").DLQEntry[];
277
+ /**
278
+ * Get count of Dead Letter Queue entries for an event.
279
+ *
280
+ * @param eventName - Event name
281
+ * @returns Count of entries
282
+ */
283
+ getDLQCount(eventName: string): number;
284
+ /**
285
+ * Delete a DLQ entry.
286
+ *
287
+ * @param entryId - DLQ entry ID
288
+ * @returns True if deleted, false if not found
289
+ */
290
+ deleteDLQEntry(entryId: string): boolean;
291
+ /**
292
+ * Get circuit breaker statistics for all events.
293
+ *
294
+ * @returns Array of circuit breaker statistics
295
+ */
296
+ getCircuitBreakerStats(): Array<{
297
+ eventName: string;
298
+ state: string;
299
+ failureCount: number;
300
+ successCount: number;
301
+ lastFailureAt?: Date;
302
+ lastSuccessAt?: Date;
303
+ openedAt?: Date;
304
+ totalRequests: number;
305
+ totalFailures: number;
306
+ totalSuccesses: number;
307
+ }>;
308
+ /**
309
+ * Reset a circuit breaker for an event.
310
+ *
311
+ * @param eventName - Event name
312
+ * @returns True if reset, false if circuit breaker not found
313
+ */
314
+ resetCircuitBreaker(eventName: string): boolean;
315
+ /**
316
+ * Get the current backpressure state.
317
+ *
318
+ * @returns Backpressure state ('NORMAL', 'WARNING', 'CRITICAL', 'OVERFLOW') or undefined if not enabled
319
+ */
320
+ getBackpressureState(): string | undefined;
321
+ /**
322
+ * Get backpressure metrics snapshot.
323
+ *
324
+ * @returns Backpressure metrics snapshot or undefined if not enabled
325
+ */
326
+ getBackpressureMetrics(): object | undefined;
327
+ /**
328
+ * Get the persistent DLQ manager instance.
329
+ *
330
+ * @returns DeadLetterQueueManager or undefined if not configured
331
+ * @public
332
+ */
333
+ getPersistentDLQManager(): DeadLetterQueueManager | undefined;
334
+ /**
335
+ * Create a handler function for persistent DLQ.
336
+ * This handler is used by EventPriorityQueue to persist failed events.
337
+ *
338
+ * @returns Handler function
339
+ * @internal
340
+ */
341
+ private createPersistentDLQHandler;
342
+ /**
343
+ * Requeue a failed event from the persistent DLQ.
344
+ *
345
+ * @param dlqId - DLQ entry UUID
346
+ * @returns True if requeued successfully
347
+ * @public
348
+ */
349
+ requeuePersistentDLQEntry(dlqId: string): Promise<boolean>;
350
+ /**
351
+ * Requeue multiple events from persistent DLQ.
352
+ *
353
+ * @param filter - Filter criteria
354
+ * @returns Result statistics
355
+ * @public
356
+ */
357
+ requeuePersistentDLQBatch(filter?: {
358
+ eventName?: string;
359
+ status?: 'pending' | 'requeued' | 'resolved' | 'abandoned';
360
+ }): Promise<{
361
+ total: number;
362
+ succeeded: number;
363
+ failed: number;
364
+ }>;
365
+ /**
366
+ * Dispatch an event through Bull Queue(分佈式異步處理).
367
+ *
368
+ * 與 doActionAsync() 不同:
369
+ * - doActionAsync() 使用 EventPriorityQueue (Memory-based)
370
+ * - dispatchQueued() 使用 Bull Queue (Redis-backed, 分佈式)
371
+ *
372
+ * 適用於需要持久化和跨進程處理的事件。
373
+ *
374
+ * @template TArgs - 事件參數類型
375
+ * @param event - 事件名稱
376
+ * @param args - 事件參數
377
+ * @param options - 事件選項(可選)
378
+ * @returns Job ID
379
+ * @throws 如果未配置 MessageQueueBridge 或沒有 listeners
380
+ *
381
+ * @example
382
+ * ```typescript
383
+ * const jobId = await hookManager.dispatchQueued('order:created', {
384
+ * orderId: 'ORD-123',
385
+ * amount: 999.99
386
+ * })
387
+ * ```
388
+ *
389
+ * @public
390
+ */
391
+ dispatchQueued<TArgs = unknown>(event: string, args: TArgs, options?: any): Promise<string>;
392
+ /**
393
+ * Dispatch an event through Bull Queue with delay(延遲隊列分發).
394
+ *
395
+ * @template TArgs - 事件參數類型
396
+ * @param event - 事件名稱
397
+ * @param args - 事件參數
398
+ * @param delay - 延遲時間(毫秒)
399
+ * @param options - 事件選項(可選)
400
+ * @returns Job ID
401
+ * @throws 如果未配置 MessageQueueBridge
402
+ *
403
+ * @example
404
+ * ```typescript
405
+ * // 延遲 5 秒後處理
406
+ * const jobId = await hookManager.dispatchDeferredQueued(
407
+ * 'reminder:send',
408
+ * { userId: '123' },
409
+ * 5000
410
+ * )
411
+ * ```
412
+ *
413
+ * @public
414
+ */
415
+ dispatchDeferredQueued<TArgs = unknown>(event: string, args: TArgs, delay: number, options?: any): Promise<string>;
416
+ /**
417
+ * Get the execution status of an event.
418
+ *
419
+ * 查詢事件執行狀態,支持查詢 Bull Queue 和 DLQ 中的事件。
420
+ *
421
+ * @param eventId - 事件 ID (task.id 或 jobId)
422
+ * @returns 事件狀態信息
423
+ * @throws 如果未配置 MessageQueueBridge
424
+ *
425
+ * @public
426
+ */
427
+ getEventStatus(eventId: string): Promise<any>;
428
+ /**
429
+ * Get persistent DLQ statistics.
430
+ *
431
+ * @returns Statistics object with total, byEvent, and byStatus counts
432
+ * @public
433
+ */
434
+ getPersistentDLQStats(): Promise<import("./reliability").DLQStats>;
435
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Listener-related types and interfaces.
3
+ */
4
+ export type { Listener, ShouldQueue } from './types/events';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Standard logger interface.
3
+ *
4
+ * PSR-3 inspired API for easy swapping (e.g., Winston, Pino).
5
+ */
6
+ export interface Logger {
7
+ debug(message: string, ...args: unknown[]): void;
8
+ info(message: string, ...args: unknown[]): void;
9
+ warn(message: string, ...args: unknown[]): void;
10
+ error(message: string, ...args: unknown[]): void;
11
+ }
12
+ /**
13
+ * Default console logger implementation.
14
+ */
15
+ export declare class ConsoleLogger implements Logger {
16
+ debug(message: string, ...args: unknown[]): void;
17
+ info(message: string, ...args: unknown[]): void;
18
+ warn(message: string, ...args: unknown[]): void;
19
+ error(message: string, ...args: unknown[]): void;
20
+ }