@gravito/echo 3.1.1 → 4.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.
- package/README.md +24 -9
- package/dist/OrbitEcho.d.ts +76 -60
- package/dist/errors/EchoError.d.ts +29 -0
- package/dist/errors/codes.d.ts +20 -0
- package/dist/index.d.ts +34 -16
- package/dist/index.js +3 -1596
- package/dist/index.js.map +3 -28
- package/dist/{echo/src/middleware → middleware}/RequestBufferMiddleware.d.ts +3 -3
- package/dist/providers/GenericProvider.d.ts +37 -19
- package/dist/providers/GitHubProvider.d.ts +21 -13
- package/dist/providers/StripeProvider.d.ts +20 -13
- package/dist/providers/index.d.ts +14 -4
- package/dist/receive/SignatureValidator.d.ts +33 -1
- package/dist/receive/WebhookReceiver.d.ts +139 -22
- package/dist/receive/index.d.ts +0 -1
- package/dist/resilience/CircuitBreaker.d.ts +6 -0
- package/dist/{echo/src/resilience → resilience}/index.d.ts +2 -1
- package/dist/send/WebhookDispatcher.d.ts +159 -16
- package/dist/send/index.d.ts +0 -1
- package/dist/types.d.ts +671 -57
- package/package.json +9 -3
- package/dist/OrbitEcho.d.ts.map +0 -1
- package/dist/atlas/src/DB.d.ts +0 -348
- package/dist/atlas/src/OrbitAtlas.d.ts +0 -9
- package/dist/atlas/src/config/defineConfig.d.ts +0 -14
- package/dist/atlas/src/config/index.d.ts +0 -7
- package/dist/atlas/src/config/loadConfig.d.ts +0 -41
- package/dist/atlas/src/connection/Connection.d.ts +0 -112
- package/dist/atlas/src/connection/ConnectionManager.d.ts +0 -180
- package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +0 -54
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +0 -32
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +0 -118
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +0 -36
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +0 -79
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +0 -96
- package/dist/atlas/src/drivers/RedisDriver.d.ts +0 -43
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +0 -45
- package/dist/atlas/src/drivers/types.d.ts +0 -260
- package/dist/atlas/src/errors/index.d.ts +0 -45
- package/dist/atlas/src/grammar/Grammar.d.ts +0 -342
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +0 -47
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +0 -54
- package/dist/atlas/src/grammar/NullGrammar.d.ts +0 -35
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +0 -62
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +0 -32
- package/dist/atlas/src/index.d.ts +0 -79
- package/dist/atlas/src/migration/Migration.d.ts +0 -64
- package/dist/atlas/src/migration/MigrationRepository.d.ts +0 -65
- package/dist/atlas/src/migration/Migrator.d.ts +0 -110
- package/dist/atlas/src/migration/index.d.ts +0 -6
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +0 -33
- package/dist/atlas/src/observability/AtlasObservability.d.ts +0 -15
- package/dist/atlas/src/observability/AtlasTracer.d.ts +0 -12
- package/dist/atlas/src/observability/index.d.ts +0 -9
- package/dist/atlas/src/orm/Repository.d.ts +0 -247
- package/dist/atlas/src/orm/index.d.ts +0 -6
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +0 -121
- package/dist/atlas/src/orm/model/Model.d.ts +0 -458
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +0 -20
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +0 -150
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +0 -36
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +0 -92
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +0 -117
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +0 -64
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +0 -15
- package/dist/atlas/src/orm/model/concerns/index.d.ts +0 -12
- package/dist/atlas/src/orm/model/decorators.d.ts +0 -138
- package/dist/atlas/src/orm/model/errors.d.ts +0 -52
- package/dist/atlas/src/orm/model/index.d.ts +0 -10
- package/dist/atlas/src/orm/model/relationships.d.ts +0 -207
- package/dist/atlas/src/orm/model/types.d.ts +0 -12
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +0 -124
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +0 -54
- package/dist/atlas/src/orm/schema/index.d.ts +0 -6
- package/dist/atlas/src/orm/schema/types.d.ts +0 -85
- package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +0 -98
- package/dist/atlas/src/pool/PoolHealthChecker.d.ts +0 -91
- package/dist/atlas/src/pool/PoolStrategy.d.ts +0 -129
- package/dist/atlas/src/pool/PoolWarmer.d.ts +0 -92
- package/dist/atlas/src/query/Expression.d.ts +0 -60
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +0 -10
- package/dist/atlas/src/query/QueryBuilder.d.ts +0 -643
- package/dist/atlas/src/query/RelationshipResolver.d.ts +0 -23
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +0 -51
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +0 -70
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +0 -87
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +0 -82
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +0 -69
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +0 -71
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +0 -167
- package/dist/atlas/src/query/clauses/index.d.ts +0 -11
- package/dist/atlas/src/schema/Blueprint.d.ts +0 -276
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +0 -154
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +0 -37
- package/dist/atlas/src/schema/MigrationGenerator.d.ts +0 -45
- package/dist/atlas/src/schema/Schema.d.ts +0 -131
- package/dist/atlas/src/schema/SchemaDiff.d.ts +0 -73
- package/dist/atlas/src/schema/TypeGenerator.d.ts +0 -57
- package/dist/atlas/src/schema/TypeWriter.d.ts +0 -42
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +0 -23
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +0 -26
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +0 -28
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +0 -97
- package/dist/atlas/src/schema/grammars/index.d.ts +0 -7
- package/dist/atlas/src/schema/index.d.ts +0 -8
- package/dist/atlas/src/seed/Factory.d.ts +0 -90
- package/dist/atlas/src/seed/Seeder.d.ts +0 -28
- package/dist/atlas/src/seed/SeederRunner.d.ts +0 -74
- package/dist/atlas/src/seed/index.d.ts +0 -6
- package/dist/atlas/src/sharding/ShardingManager.d.ts +0 -59
- package/dist/atlas/src/types/index.d.ts +0 -1182
- package/dist/atlas/src/utils/CursorEncoding.d.ts +0 -63
- package/dist/atlas/src/utils/levenshtein.d.ts +0 -9
- package/dist/core/src/Application.d.ts +0 -215
- package/dist/core/src/CommandKernel.d.ts +0 -33
- package/dist/core/src/ConfigManager.d.ts +0 -65
- package/dist/core/src/Container/RequestScopeManager.d.ts +0 -62
- package/dist/core/src/Container/RequestScopeMetrics.d.ts +0 -144
- package/dist/core/src/Container.d.ts +0 -153
- package/dist/core/src/ErrorHandler.d.ts +0 -66
- package/dist/core/src/Event.d.ts +0 -5
- package/dist/core/src/EventManager.d.ts +0 -123
- package/dist/core/src/GlobalErrorHandlers.d.ts +0 -47
- package/dist/core/src/GravitoServer.d.ts +0 -28
- package/dist/core/src/HookManager.d.ts +0 -591
- package/dist/core/src/Listener.d.ts +0 -4
- package/dist/core/src/Logger.d.ts +0 -20
- package/dist/core/src/PlanetCore.d.ts +0 -378
- package/dist/core/src/RequestContext.d.ts +0 -97
- package/dist/core/src/Route.d.ts +0 -36
- package/dist/core/src/Router.d.ts +0 -284
- package/dist/core/src/ServiceProvider.d.ts +0 -178
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +0 -27
- package/dist/core/src/adapters/PhotonAdapter.d.ts +0 -175
- package/dist/core/src/adapters/bun/BunContext.d.ts +0 -49
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +0 -31
- package/dist/core/src/adapters/bun/BunRequest.d.ts +0 -31
- package/dist/core/src/adapters/bun/RadixNode.d.ts +0 -19
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +0 -31
- package/dist/core/src/adapters/bun/types.d.ts +0 -20
- package/dist/core/src/adapters/photon-types.d.ts +0 -73
- package/dist/core/src/adapters/types.d.ts +0 -235
- package/dist/core/src/cli/queue-commands.d.ts +0 -6
- package/dist/core/src/engine/AOTRouter.d.ts +0 -129
- package/dist/core/src/engine/FastContext.d.ts +0 -123
- package/dist/core/src/engine/Gravito.d.ts +0 -136
- package/dist/core/src/engine/MinimalContext.d.ts +0 -100
- package/dist/core/src/engine/analyzer.d.ts +0 -27
- package/dist/core/src/engine/constants.d.ts +0 -23
- package/dist/core/src/engine/index.d.ts +0 -26
- package/dist/core/src/engine/path.d.ts +0 -26
- package/dist/core/src/engine/pool.d.ts +0 -83
- package/dist/core/src/engine/types.d.ts +0 -146
- package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +0 -126
- package/dist/core/src/events/BackpressureManager.d.ts +0 -215
- package/dist/core/src/events/CircuitBreaker.d.ts +0 -229
- package/dist/core/src/events/DeadLetterQueue.d.ts +0 -219
- package/dist/core/src/events/EventBackend.d.ts +0 -12
- package/dist/core/src/events/EventOptions.d.ts +0 -204
- package/dist/core/src/events/EventPriorityQueue.d.ts +0 -301
- package/dist/core/src/events/FlowControlStrategy.d.ts +0 -109
- package/dist/core/src/events/IdempotencyCache.d.ts +0 -60
- package/dist/core/src/events/MessageQueueBridge.d.ts +0 -184
- package/dist/core/src/events/PriorityEscalationManager.d.ts +0 -82
- package/dist/core/src/events/RetryScheduler.d.ts +0 -104
- package/dist/core/src/events/WorkerPool.d.ts +0 -98
- package/dist/core/src/events/WorkerPoolConfig.d.ts +0 -153
- package/dist/core/src/events/WorkerPoolMetrics.d.ts +0 -65
- package/dist/core/src/events/aggregation/AggregationWindow.d.ts +0 -77
- package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +0 -135
- package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +0 -108
- package/dist/core/src/events/aggregation/EventBatcher.d.ts +0 -99
- package/dist/core/src/events/aggregation/types.d.ts +0 -117
- package/dist/core/src/events/index.d.ts +0 -25
- package/dist/core/src/events/observability/EventMetrics.d.ts +0 -132
- package/dist/core/src/events/observability/EventTracer.d.ts +0 -68
- package/dist/core/src/events/observability/EventTracing.d.ts +0 -161
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +0 -332
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +0 -108
- package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +0 -76
- package/dist/core/src/events/observability/index.d.ts +0 -24
- package/dist/core/src/events/observability/metrics-types.d.ts +0 -16
- package/dist/core/src/events/types.d.ts +0 -134
- package/dist/core/src/exceptions/AuthenticationException.d.ts +0 -8
- package/dist/core/src/exceptions/AuthorizationException.d.ts +0 -8
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +0 -9
- package/dist/core/src/exceptions/GravitoException.d.ts +0 -23
- package/dist/core/src/exceptions/HttpException.d.ts +0 -9
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +0 -10
- package/dist/core/src/exceptions/ValidationException.d.ts +0 -22
- package/dist/core/src/exceptions/index.d.ts +0 -7
- package/dist/core/src/health/HealthProvider.d.ts +0 -67
- package/dist/core/src/helpers/Arr.d.ts +0 -19
- package/dist/core/src/helpers/Str.d.ts +0 -23
- package/dist/core/src/helpers/data.d.ts +0 -25
- package/dist/core/src/helpers/errors.d.ts +0 -34
- package/dist/core/src/helpers/response.d.ts +0 -41
- package/dist/core/src/helpers.d.ts +0 -338
- package/dist/core/src/http/CookieJar.d.ts +0 -51
- package/dist/core/src/http/cookie.d.ts +0 -29
- package/dist/core/src/http/middleware/BodySizeLimit.d.ts +0 -16
- package/dist/core/src/http/middleware/Cors.d.ts +0 -24
- package/dist/core/src/http/middleware/Csrf.d.ts +0 -23
- package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +0 -28
- package/dist/core/src/http/middleware/SecurityHeaders.d.ts +0 -29
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -18
- package/dist/core/src/http/types.d.ts +0 -374
- package/dist/core/src/index.d.ts +0 -88
- package/dist/core/src/instrumentation/index.d.ts +0 -35
- package/dist/core/src/instrumentation/opentelemetry.d.ts +0 -178
- package/dist/core/src/instrumentation/types.d.ts +0 -182
- package/dist/core/src/observability/Metrics.d.ts +0 -244
- package/dist/core/src/observability/QueueDashboard.d.ts +0 -136
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +0 -350
- package/dist/core/src/reliability/RetryPolicy.d.ts +0 -217
- package/dist/core/src/reliability/index.d.ts +0 -6
- package/dist/core/src/router/ControllerDispatcher.d.ts +0 -12
- package/dist/core/src/router/RequestValidator.d.ts +0 -20
- package/dist/core/src/runtime.d.ts +0 -119
- package/dist/core/src/security/Encrypter.d.ts +0 -33
- package/dist/core/src/security/Hasher.d.ts +0 -29
- package/dist/core/src/testing/HttpTester.d.ts +0 -39
- package/dist/core/src/testing/TestResponse.d.ts +0 -78
- package/dist/core/src/testing/index.d.ts +0 -2
- package/dist/core/src/types/events.d.ts +0 -94
- package/dist/echo/src/OrbitEcho.d.ts +0 -115
- package/dist/echo/src/index.d.ts +0 -64
- package/dist/echo/src/providers/GenericProvider.d.ts +0 -53
- package/dist/echo/src/providers/GitHubProvider.d.ts +0 -35
- package/dist/echo/src/providers/StripeProvider.d.ts +0 -38
- package/dist/echo/src/providers/index.d.ts +0 -14
- package/dist/echo/src/receive/SignatureValidator.d.ts +0 -67
- package/dist/echo/src/receive/WebhookReceiver.d.ts +0 -185
- package/dist/echo/src/receive/index.d.ts +0 -2
- package/dist/echo/src/resilience/CircuitBreaker.d.ts +0 -117
- package/dist/echo/src/send/WebhookDispatcher.d.ts +0 -198
- package/dist/echo/src/send/index.d.ts +0 -1
- package/dist/echo/src/types.d.ts +0 -756
- package/dist/index.d.ts.map +0 -1
- package/dist/monitor/src/MonitorOrbit.d.ts +0 -43
- package/dist/monitor/src/config.d.ts +0 -106
- package/dist/monitor/src/health/HealthController.d.ts +0 -28
- package/dist/monitor/src/health/HealthRegistry.d.ts +0 -80
- package/dist/monitor/src/health/index.d.ts +0 -36
- package/dist/monitor/src/index.d.ts +0 -13
- package/dist/monitor/src/metrics/MetricsController.d.ts +0 -22
- package/dist/monitor/src/metrics/MetricsRegistry.d.ts +0 -136
- package/dist/monitor/src/metrics/index.d.ts +0 -11
- package/dist/monitor/src/tracing/TracingManager.d.ts +0 -97
- package/dist/monitor/src/tracing/index.d.ts +0 -10
- package/dist/photon/src/index.d.ts +0 -89
- package/dist/photon/src/middleware/binary.d.ts +0 -31
- package/dist/photon/src/middleware/htmx.d.ts +0 -39
- package/dist/photon/src/middleware/ratelimit-redis.d.ts +0 -50
- package/dist/photon/src/middleware/ratelimit.d.ts +0 -161
- package/dist/photon/src/openapi.d.ts +0 -19
- package/dist/providers/GenericProvider.d.ts.map +0 -1
- package/dist/providers/GitHubProvider.d.ts.map +0 -1
- package/dist/providers/StripeProvider.d.ts.map +0 -1
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/receive/SignatureValidator.d.ts.map +0 -1
- package/dist/receive/WebhookReceiver.d.ts.map +0 -1
- package/dist/receive/index.d.ts.map +0 -1
- package/dist/send/WebhookDispatcher.d.ts.map +0 -1
- package/dist/send/index.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- /package/dist/{echo/src/dlq → dlq}/DeadLetterQueue.d.ts +0 -0
- /package/dist/{echo/src/dlq → dlq}/MemoryDeadLetterQueue.d.ts +0 -0
- /package/dist/{echo/src/dlq → dlq}/index.d.ts +0 -0
- /package/dist/{echo/src/middleware → middleware}/index.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/index.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/logging/ConsoleEchoLogger.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/logging/EchoLogger.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/logging/index.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/metrics/MetricsProvider.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/metrics/NoopMetricsProvider.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/metrics/PrometheusMetricsProvider.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/metrics/index.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/tracing/NoopTracer.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/tracing/Tracer.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/tracing/index.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/LinearProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/PaddleProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/ShopifyProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/SlackProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/TwilioProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/base/BaseProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/base/HeaderUtils.d.ts +0 -0
- /package/dist/{echo/src/replay → replay}/WebhookReplayService.d.ts +0 -0
- /package/dist/{echo/src/replay → replay}/index.d.ts +0 -0
- /package/dist/{echo/src/rotation → rotation}/KeyRotationManager.d.ts +0 -0
- /package/dist/{echo/src/rotation → rotation}/index.d.ts +0 -0
- /package/dist/{echo/src/storage → storage}/MemoryWebhookStore.d.ts +0 -0
- /package/dist/{echo/src/storage → storage}/WebhookStore.d.ts +0 -0
- /package/dist/{echo/src/storage → storage}/index.d.ts +0 -0
|
@@ -1,591 +0,0 @@
|
|
|
1
|
-
import type { ConnectionContract } from '@gravito/atlas';
|
|
2
|
-
import { type CircuitBreakerOptions } from './events/CircuitBreaker';
|
|
3
|
-
import { DeadLetterQueue } from './events/DeadLetterQueue';
|
|
4
|
-
import type { EventBackend } from './events/EventBackend';
|
|
5
|
-
import type { EventOptions } from './events/EventOptions';
|
|
6
|
-
import { EventPriorityQueue, type EventQueueConfig } from './events/EventPriorityQueue';
|
|
7
|
-
import { DeadLetterQueueManager } from './reliability/DeadLetterQueueManager';
|
|
8
|
-
/**
|
|
9
|
-
* Callback function for filters (transforms values).
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export type FilterCallback<T = unknown> = (value: T, ...args: unknown[]) => Promise<T> | T;
|
|
13
|
-
/**
|
|
14
|
-
* Callback function for actions (side effects).
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export type ActionCallback<TArgs = unknown> = (args: TArgs) => Promise<void> | void;
|
|
18
|
-
/**
|
|
19
|
-
* Options for listener registration.
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export interface ListenerOptions {
|
|
23
|
-
/**
|
|
24
|
-
* Explicitly specify the listener type.
|
|
25
|
-
* - 'sync': Force synchronous dispatch for this listener
|
|
26
|
-
* - 'async': Force asynchronous dispatch for this listener
|
|
27
|
-
* - 'auto': Auto-detect based on function signature (default)
|
|
28
|
-
* @default 'auto'
|
|
29
|
-
*/
|
|
30
|
-
type?: 'sync' | 'async' | 'auto';
|
|
31
|
-
/**
|
|
32
|
-
* Circuit breaker configuration for this listener.
|
|
33
|
-
*/
|
|
34
|
-
circuitBreaker?: CircuitBreakerOptions;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Information about a registered listener.
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
export interface ListenerInfo {
|
|
41
|
-
/**
|
|
42
|
-
* The callback function.
|
|
43
|
-
*/
|
|
44
|
-
callback: ActionCallback;
|
|
45
|
-
/**
|
|
46
|
-
* Whether the listener is considered async.
|
|
47
|
-
*/
|
|
48
|
-
isAsync: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* The explicit type override, if any.
|
|
51
|
-
*/
|
|
52
|
-
typeOverride?: 'sync' | 'async' | 'auto';
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Configuration for HookManager.
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export interface HookManagerConfig {
|
|
59
|
-
/**
|
|
60
|
-
* Enable async event dispatch by default.
|
|
61
|
-
* When true, doAction() will automatically use async dispatch if any listener is async.
|
|
62
|
-
* @default false
|
|
63
|
-
*/
|
|
64
|
-
asyncByDefault?: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Migration mode for backward compatibility.
|
|
67
|
-
* - 'sync': All events use synchronous dispatch (legacy mode)
|
|
68
|
-
* - 'hybrid': Auto-detect and use async for async listeners (recommended)
|
|
69
|
-
* - 'async': All events use async dispatch (future mode)
|
|
70
|
-
* @default 'sync'
|
|
71
|
-
*/
|
|
72
|
-
migrationMode?: 'sync' | 'hybrid' | 'async';
|
|
73
|
-
/**
|
|
74
|
-
* Enable deprecation warnings for synchronous event dispatch.
|
|
75
|
-
* @default false
|
|
76
|
-
*/
|
|
77
|
-
showDeprecationWarnings?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Enable Dead Letter Queue for failed events.
|
|
80
|
-
* @default true
|
|
81
|
-
*/
|
|
82
|
-
enableDLQ?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Configuration for the event priority queue (Backpressure).
|
|
85
|
-
*/
|
|
86
|
-
queue?: EventQueueConfig;
|
|
87
|
-
/**
|
|
88
|
-
* Custom event backend for distributed processing.
|
|
89
|
-
*/
|
|
90
|
-
backend?: EventBackend;
|
|
91
|
-
/**
|
|
92
|
-
* Database connection for persistent DLQ (optional).
|
|
93
|
-
* If provided, failed events after max retries will be persisted to database.
|
|
94
|
-
*/
|
|
95
|
-
db?: ConnectionContract;
|
|
96
|
-
/**
|
|
97
|
-
* Enable persistent DLQ for failed events (requires db).
|
|
98
|
-
* @default false
|
|
99
|
-
*/
|
|
100
|
-
enablePersistentDLQ?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Message Queue Bridge for distributed event processing via Bull Queue.
|
|
103
|
-
* When provided, enables dispatchQueued() method for routing events to Redis-backed queue.
|
|
104
|
-
*/
|
|
105
|
-
messageQueueBridge?: any;
|
|
106
|
-
/**
|
|
107
|
-
* Event aggregation configuration (FS-102).
|
|
108
|
-
* Enables deduplication and micro-batching for improved throughput.
|
|
109
|
-
*/
|
|
110
|
-
aggregation?: any;
|
|
111
|
-
}
|
|
112
|
-
export declare class HookManager {
|
|
113
|
-
private filters;
|
|
114
|
-
private actions;
|
|
115
|
-
private eventQueue;
|
|
116
|
-
private backend;
|
|
117
|
-
private dlq?;
|
|
118
|
-
private persistentDlqManager?;
|
|
119
|
-
private messageQueueBridge?;
|
|
120
|
-
private idempotencyCache;
|
|
121
|
-
private config;
|
|
122
|
-
private migrationWarner;
|
|
123
|
-
private aggregationManager?;
|
|
124
|
-
/**
|
|
125
|
-
* Cache for async detection results (WeakMap for automatic garbage collection).
|
|
126
|
-
* @internal
|
|
127
|
-
*/
|
|
128
|
-
private asyncDetectionCache;
|
|
129
|
-
/**
|
|
130
|
-
* Count of items in the async detection cache (for testing/debugging).
|
|
131
|
-
* @internal
|
|
132
|
-
*/
|
|
133
|
-
private asyncDetectionCacheCount;
|
|
134
|
-
/**
|
|
135
|
-
* Map of listener type overrides (callback -> type).
|
|
136
|
-
* @internal
|
|
137
|
-
*/
|
|
138
|
-
private listenerTypeOverrides;
|
|
139
|
-
constructor(config?: HookManagerConfig);
|
|
140
|
-
/**
|
|
141
|
-
* Register a filter hook.
|
|
142
|
-
*
|
|
143
|
-
* Filters are used to transform a value (input/output) through a chain of
|
|
144
|
-
* callbacks. Each callback must return the modified value.
|
|
145
|
-
*
|
|
146
|
-
* @template T - The type of value being filtered.
|
|
147
|
-
* @param hook - The unique name of the hook.
|
|
148
|
-
* @param callback - The callback function to execute.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* core.hooks.addFilter('content', async (content: string) => {
|
|
153
|
-
* return content.toUpperCase();
|
|
154
|
-
* });
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
addFilter<T = unknown>(hook: string, callback: FilterCallback<T>): void;
|
|
158
|
-
/**
|
|
159
|
-
* Apply all registered filters sequentially.
|
|
160
|
-
*
|
|
161
|
-
* Each callback receives the previous callback's return value.
|
|
162
|
-
*
|
|
163
|
-
* @template T - The type of value being filtered.
|
|
164
|
-
* @param hook - The name of the hook.
|
|
165
|
-
* @param initialValue - The initial value to filter.
|
|
166
|
-
* @param args - Additional arguments to pass to the callbacks.
|
|
167
|
-
* @returns The final filtered value.
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```typescript
|
|
171
|
-
* const content = await core.hooks.applyFilters('content', 'hello world');
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
applyFilters<T = unknown>(hook: string, initialValue: T, ...args: unknown[]): Promise<T>;
|
|
175
|
-
/**
|
|
176
|
-
* Register an action hook.
|
|
177
|
-
*
|
|
178
|
-
* Actions are used to trigger side effects (e.g., logging, sending emails)
|
|
179
|
-
* at specific points in the application lifecycle.
|
|
180
|
-
*
|
|
181
|
-
* @template TArgs - The type of arguments passed to the action.
|
|
182
|
-
* @param hook - The unique name of the hook.
|
|
183
|
-
* @param callback - The callback function to execute.
|
|
184
|
-
* @param options - Optional listener options (type override, circuit breaker).
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```typescript
|
|
188
|
-
* core.hooks.addAction('user_registered', async (user: User) => {
|
|
189
|
-
* await sendWelcomeEmail(user);
|
|
190
|
-
* });
|
|
191
|
-
*
|
|
192
|
-
* // With explicit type override
|
|
193
|
-
* core.hooks.addAction('sync_handler', handler, { type: 'async' });
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
addAction<TArgs = unknown>(hook: string, callback: ActionCallback<TArgs>, options?: ListenerOptions): void;
|
|
197
|
-
/**
|
|
198
|
-
* Run all registered actions.
|
|
199
|
-
*
|
|
200
|
-
* This method supports both synchronous and asynchronous dispatch based on configuration.
|
|
201
|
-
* In hybrid mode, it auto-detects async listeners and uses async dispatch.
|
|
202
|
-
*
|
|
203
|
-
* @template TArgs - The type of arguments passed to the action.
|
|
204
|
-
* @param hook - The name of the hook.
|
|
205
|
-
* @param args - The arguments to pass to the callbacks.
|
|
206
|
-
* @param options - Optional event options for async dispatch.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```typescript
|
|
210
|
-
* await core.hooks.doAction('user_registered', user);
|
|
211
|
-
* ```
|
|
212
|
-
*/
|
|
213
|
-
doAction<TArgs = unknown>(hook: string, args: TArgs, options?: EventOptions): Promise<void>;
|
|
214
|
-
/**
|
|
215
|
-
* Run all registered actions synchronously (legacy mode).
|
|
216
|
-
*
|
|
217
|
-
* @template TArgs - The type of arguments passed to the action.
|
|
218
|
-
* @param hook - The name of the hook.
|
|
219
|
-
* @param args - The arguments to pass to the callbacks.
|
|
220
|
-
* @internal
|
|
221
|
-
*/
|
|
222
|
-
doActionSync<TArgs = unknown>(hook: string, args: TArgs): Promise<void>;
|
|
223
|
-
/**
|
|
224
|
-
* Run all registered actions asynchronously via priority queue.
|
|
225
|
-
*
|
|
226
|
-
* This method uses EventPriorityQueue for async dispatch with support for:
|
|
227
|
-
* - Priority-based processing (high > normal > low)
|
|
228
|
-
* - Timeout handling
|
|
229
|
-
* - Ordering guarantees (strict, partition, none)
|
|
230
|
-
* - Idempotency
|
|
231
|
-
*
|
|
232
|
-
* @template TArgs - The type of arguments passed to the action.
|
|
233
|
-
* @param hook - The name of the hook.
|
|
234
|
-
* @param args - The arguments to pass to the callbacks.
|
|
235
|
-
* @param options - Event options for async dispatch.
|
|
236
|
-
*
|
|
237
|
-
* @example
|
|
238
|
-
* ```typescript
|
|
239
|
-
* await core.hooks.doActionAsync('order:created', order, {
|
|
240
|
-
* priority: 'high',
|
|
241
|
-
* ordering: 'partition',
|
|
242
|
-
* partitionKey: order.id,
|
|
243
|
-
* timeout: 5000,
|
|
244
|
-
* });
|
|
245
|
-
* ```
|
|
246
|
-
*/
|
|
247
|
-
doActionAsync<TArgs = unknown>(hook: string, args: TArgs, options?: EventOptions): Promise<void>;
|
|
248
|
-
/**
|
|
249
|
-
* Determine if async dispatch should be used.
|
|
250
|
-
*
|
|
251
|
-
* @param callbacks - Callbacks to check
|
|
252
|
-
* @param options - Event options
|
|
253
|
-
* @returns True if async dispatch should be used
|
|
254
|
-
* @internal
|
|
255
|
-
*/
|
|
256
|
-
/**
|
|
257
|
-
* Determine the dispatch mode for an event.
|
|
258
|
-
*
|
|
259
|
-
* @param eventName - The name of the event
|
|
260
|
-
* @param options - Optional event options
|
|
261
|
-
* @returns The dispatch mode: 'sync' or 'async'
|
|
262
|
-
* @public
|
|
263
|
-
*/
|
|
264
|
-
detectMode(eventName: string, options?: EventOptions): 'sync' | 'async';
|
|
265
|
-
/**
|
|
266
|
-
* Check if a callback is an async function (with caching).
|
|
267
|
-
*
|
|
268
|
-
* Detection methods:
|
|
269
|
-
* 1. Check cache first
|
|
270
|
-
* 2. Check type override
|
|
271
|
-
* 3. Check constructor.name === 'AsyncFunction'
|
|
272
|
-
* 4. Fallback: Check function string representation
|
|
273
|
-
*
|
|
274
|
-
* @param callback - The callback to check
|
|
275
|
-
* @returns True if the callback is async
|
|
276
|
-
* @public
|
|
277
|
-
*/
|
|
278
|
-
isAsyncListener(callback: ActionCallback): boolean;
|
|
279
|
-
/**
|
|
280
|
-
* Cache async detection result.
|
|
281
|
-
* @internal
|
|
282
|
-
*/
|
|
283
|
-
private cacheAsyncResult;
|
|
284
|
-
/**
|
|
285
|
-
* Runtime detection for functions that return Promises but aren't declared async.
|
|
286
|
-
*
|
|
287
|
-
* This method executes the callback with test args and checks if the result is a Promise.
|
|
288
|
-
* Use with caution as it actually invokes the callback.
|
|
289
|
-
*
|
|
290
|
-
* @param callback - The callback to check
|
|
291
|
-
* @param testArgs - Arguments to pass to the callback for testing
|
|
292
|
-
* @returns True if the callback returns a Promise
|
|
293
|
-
* @public
|
|
294
|
-
*/
|
|
295
|
-
isAsyncListenerRuntime<TArgs = unknown>(callback: ActionCallback<TArgs>, testArgs: TArgs): Promise<boolean>;
|
|
296
|
-
/**
|
|
297
|
-
* Get the size of the async detection cache (for testing/debugging).
|
|
298
|
-
*
|
|
299
|
-
* @returns Number of cached detection results
|
|
300
|
-
* @public
|
|
301
|
-
*/
|
|
302
|
-
getAsyncDetectionCacheSize(): number;
|
|
303
|
-
/**
|
|
304
|
-
* Clear the async detection cache.
|
|
305
|
-
*
|
|
306
|
-
* @public
|
|
307
|
-
*/
|
|
308
|
-
clearAsyncDetectionCache(): void;
|
|
309
|
-
/**
|
|
310
|
-
* Check if any listener for a hook is async (including type overrides).
|
|
311
|
-
*
|
|
312
|
-
* @param hook - Hook name
|
|
313
|
-
* @returns True if any listener is async
|
|
314
|
-
* @public
|
|
315
|
-
*/
|
|
316
|
-
hasAsyncListeners(hook: string): boolean;
|
|
317
|
-
/**
|
|
318
|
-
* Check if a listener is effectively async (considering type override).
|
|
319
|
-
*
|
|
320
|
-
* @param callback - The callback to check
|
|
321
|
-
* @returns True if the listener should be treated as async
|
|
322
|
-
* @internal
|
|
323
|
-
*/
|
|
324
|
-
private isListenerEffectivelyAsync;
|
|
325
|
-
/**
|
|
326
|
-
* Get detailed information about all listeners for a hook.
|
|
327
|
-
*
|
|
328
|
-
* @param hook - Hook name
|
|
329
|
-
* @returns Array of listener info objects
|
|
330
|
-
* @public
|
|
331
|
-
*/
|
|
332
|
-
getListenerInfo(hook: string): ListenerInfo[];
|
|
333
|
-
private shouldUseAsyncDispatch;
|
|
334
|
-
/**
|
|
335
|
-
* Get the current event queue depth.
|
|
336
|
-
*
|
|
337
|
-
* @returns Total number of events in the queue
|
|
338
|
-
*/
|
|
339
|
-
getQueueDepth(): number;
|
|
340
|
-
/**
|
|
341
|
-
* Get the event queue depth for a specific priority.
|
|
342
|
-
*
|
|
343
|
-
* @param priority - Priority level
|
|
344
|
-
* @returns Number of events in the specified priority queue
|
|
345
|
-
*/
|
|
346
|
-
getQueueDepthByPriority(priority: 'high' | 'normal' | 'low'): number;
|
|
347
|
-
/**
|
|
348
|
-
* Get the EventPriorityQueue instance.
|
|
349
|
-
*
|
|
350
|
-
* @returns EventPriorityQueue instance
|
|
351
|
-
* @protected
|
|
352
|
-
*/
|
|
353
|
-
protected getEventQueue(): EventPriorityQueue;
|
|
354
|
-
/**
|
|
355
|
-
* Get all registered listeners for a hook.
|
|
356
|
-
*
|
|
357
|
-
* @param hook - Hook name
|
|
358
|
-
* @returns Array of callbacks
|
|
359
|
-
* @internal
|
|
360
|
-
*/
|
|
361
|
-
getListeners(hook: string): ActionCallback[];
|
|
362
|
-
/**
|
|
363
|
-
* Update HookManager configuration.
|
|
364
|
-
*
|
|
365
|
-
* @param config - New configuration
|
|
366
|
-
*/
|
|
367
|
-
configure(config: Partial<HookManagerConfig>): void;
|
|
368
|
-
/**
|
|
369
|
-
* Get current configuration.
|
|
370
|
-
*
|
|
371
|
-
* @returns Current configuration
|
|
372
|
-
*/
|
|
373
|
-
getConfig(): HookManagerConfig;
|
|
374
|
-
/**
|
|
375
|
-
* Suppress migration warnings for a specific event.
|
|
376
|
-
*
|
|
377
|
-
* @param eventName - The name of the event to suppress warnings for
|
|
378
|
-
* @public
|
|
379
|
-
*/
|
|
380
|
-
suppressMigrationWarning(eventName: string): void;
|
|
381
|
-
/**
|
|
382
|
-
* Set the event backend for distributed processing.
|
|
383
|
-
*
|
|
384
|
-
* @param backend - Event backend instance
|
|
385
|
-
*/
|
|
386
|
-
setBackend(backend: EventBackend): void;
|
|
387
|
-
/**
|
|
388
|
-
* Get the Dead Letter Queue instance.
|
|
389
|
-
*
|
|
390
|
-
* @returns Dead Letter Queue
|
|
391
|
-
*/
|
|
392
|
-
getDLQ(): DeadLetterQueue | undefined;
|
|
393
|
-
/**
|
|
394
|
-
* Requeue a failed event from the Dead Letter Queue.
|
|
395
|
-
*
|
|
396
|
-
* @param dlqEntryId - DLQ entry ID
|
|
397
|
-
* @returns True if requeued successfully, false if entry not found
|
|
398
|
-
*/
|
|
399
|
-
requeueDLQEntry(dlqEntryId: string): Promise<boolean>;
|
|
400
|
-
/**
|
|
401
|
-
* Requeue all failed events for a specific event name.
|
|
402
|
-
*
|
|
403
|
-
* @param eventName - Event name to requeue
|
|
404
|
-
* @returns Number of events requeued
|
|
405
|
-
*/
|
|
406
|
-
requeueDLQBatch(eventName: string): Promise<number>;
|
|
407
|
-
/**
|
|
408
|
-
* Get Dead Letter Queue entries with optional filtering.
|
|
409
|
-
*
|
|
410
|
-
* @param filter - Filter options
|
|
411
|
-
* @returns Array of DLQ entries
|
|
412
|
-
*/
|
|
413
|
-
getDLQEntries(filter?: {
|
|
414
|
-
eventName?: string;
|
|
415
|
-
from?: number;
|
|
416
|
-
to?: number;
|
|
417
|
-
limit?: number;
|
|
418
|
-
}): import("@gravito/core").DLQEntry[];
|
|
419
|
-
/**
|
|
420
|
-
* Get count of Dead Letter Queue entries for an event.
|
|
421
|
-
*
|
|
422
|
-
* @param eventName - Event name
|
|
423
|
-
* @returns Count of entries
|
|
424
|
-
*/
|
|
425
|
-
getDLQCount(eventName: string): number;
|
|
426
|
-
/**
|
|
427
|
-
* Delete a DLQ entry.
|
|
428
|
-
*
|
|
429
|
-
* @param entryId - DLQ entry ID
|
|
430
|
-
* @returns True if deleted, false if not found
|
|
431
|
-
*/
|
|
432
|
-
deleteDLQEntry(entryId: string): boolean;
|
|
433
|
-
/**
|
|
434
|
-
* Get circuit breaker statistics for all events.
|
|
435
|
-
*
|
|
436
|
-
* @returns Array of circuit breaker statistics
|
|
437
|
-
*/
|
|
438
|
-
getCircuitBreakerStats(): Array<{
|
|
439
|
-
eventName: string;
|
|
440
|
-
state: string;
|
|
441
|
-
failureCount: number;
|
|
442
|
-
successCount: number;
|
|
443
|
-
lastFailureAt?: Date;
|
|
444
|
-
lastSuccessAt?: Date;
|
|
445
|
-
openedAt?: Date;
|
|
446
|
-
totalRequests: number;
|
|
447
|
-
totalFailures: number;
|
|
448
|
-
totalSuccesses: number;
|
|
449
|
-
}>;
|
|
450
|
-
/**
|
|
451
|
-
* Reset a circuit breaker for an event.
|
|
452
|
-
*
|
|
453
|
-
* @param eventName - Event name
|
|
454
|
-
* @returns True if reset, false if circuit breaker not found
|
|
455
|
-
*/
|
|
456
|
-
resetCircuitBreaker(eventName: string): boolean;
|
|
457
|
-
/**
|
|
458
|
-
* Get the current backpressure state.
|
|
459
|
-
*
|
|
460
|
-
* @returns Backpressure state ('NORMAL', 'WARNING', 'CRITICAL', 'OVERFLOW') or undefined if not enabled
|
|
461
|
-
*/
|
|
462
|
-
getBackpressureState(): string | undefined;
|
|
463
|
-
/**
|
|
464
|
-
* Get backpressure metrics snapshot.
|
|
465
|
-
*
|
|
466
|
-
* @returns Backpressure metrics snapshot or undefined if not enabled
|
|
467
|
-
*/
|
|
468
|
-
getBackpressureMetrics(): object | undefined;
|
|
469
|
-
/**
|
|
470
|
-
* Remove all listeners for a specific action hook.
|
|
471
|
-
*
|
|
472
|
-
* @param hook - Hook name
|
|
473
|
-
*/
|
|
474
|
-
removeAction(hook: string): void;
|
|
475
|
-
/**
|
|
476
|
-
* Get the persistent DLQ manager instance.
|
|
477
|
-
*
|
|
478
|
-
* @returns DeadLetterQueueManager or undefined if not configured
|
|
479
|
-
* @public
|
|
480
|
-
*/
|
|
481
|
-
getPersistentDLQManager(): DeadLetterQueueManager | undefined;
|
|
482
|
-
/**
|
|
483
|
-
* Create a handler function for persistent DLQ.
|
|
484
|
-
* This handler is used by EventPriorityQueue to persist failed events.
|
|
485
|
-
*
|
|
486
|
-
* @returns Handler function
|
|
487
|
-
* @internal
|
|
488
|
-
*/
|
|
489
|
-
private createPersistentDLQHandler;
|
|
490
|
-
/**
|
|
491
|
-
* Requeue a failed event from the persistent DLQ.
|
|
492
|
-
*
|
|
493
|
-
* @param dlqId - DLQ entry UUID
|
|
494
|
-
* @returns True if requeued successfully
|
|
495
|
-
* @public
|
|
496
|
-
*/
|
|
497
|
-
requeuePersistentDLQEntry(dlqId: string): Promise<boolean>;
|
|
498
|
-
/**
|
|
499
|
-
* Requeue multiple events from persistent DLQ.
|
|
500
|
-
*
|
|
501
|
-
* @param filter - Filter criteria
|
|
502
|
-
* @returns Result statistics
|
|
503
|
-
* @public
|
|
504
|
-
*/
|
|
505
|
-
requeuePersistentDLQBatch(filter?: {
|
|
506
|
-
eventName?: string;
|
|
507
|
-
status?: 'pending' | 'requeued' | 'resolved' | 'abandoned';
|
|
508
|
-
}): Promise<{
|
|
509
|
-
total: number;
|
|
510
|
-
succeeded: number;
|
|
511
|
-
failed: number;
|
|
512
|
-
}>;
|
|
513
|
-
/**
|
|
514
|
-
* Dispatch an event through Bull Queue (分佈式異步處理).
|
|
515
|
-
*
|
|
516
|
-
* 與 doActionAsync() 不同:
|
|
517
|
-
* - doActionAsync() 使用 EventPriorityQueue (Memory-based)
|
|
518
|
-
* - dispatchQueued() 使用 Bull Queue (Redis-backed, 分佈式)
|
|
519
|
-
*
|
|
520
|
-
* 適用於需要持久化和跨進程處理的事件。
|
|
521
|
-
*
|
|
522
|
-
* @template TArgs - 事件參數類型
|
|
523
|
-
* @param event - 事件名稱
|
|
524
|
-
* @param args - 事件參數
|
|
525
|
-
* @param options - 事件選項(可選)
|
|
526
|
-
* @returns Job ID
|
|
527
|
-
* @throws 如果未配置 MessageQueueBridge 或沒有 listeners
|
|
528
|
-
*
|
|
529
|
-
* @example
|
|
530
|
-
* ```typescript
|
|
531
|
-
* const jobId = await hookManager.dispatchQueued('order:created', {
|
|
532
|
-
* orderId: 'ORD-123',
|
|
533
|
-
* amount: 999.99
|
|
534
|
-
* })
|
|
535
|
-
* ```
|
|
536
|
-
*
|
|
537
|
-
* @public
|
|
538
|
-
*/
|
|
539
|
-
dispatchQueued<TArgs = unknown>(event: string, args: TArgs, options?: any): Promise<string>;
|
|
540
|
-
/**
|
|
541
|
-
* Dispatch an event through Bull Queue with delay (延遲隊列分發).
|
|
542
|
-
*
|
|
543
|
-
* 通過 Bull Queue 的 delayed jobs 功能實現延遲處理。
|
|
544
|
-
*
|
|
545
|
-
* @template TArgs - 事件參數類型
|
|
546
|
-
* @param event - 事件名稱
|
|
547
|
-
* @param args - 事件參數
|
|
548
|
-
* @param delay - 延遲時間(毫秒)
|
|
549
|
-
* @param options - 事件選項(可選)
|
|
550
|
-
* @returns Job ID
|
|
551
|
-
* @throws 如果未配置 MessageQueueBridge
|
|
552
|
-
*
|
|
553
|
-
* @example
|
|
554
|
-
* ```typescript
|
|
555
|
-
* // 延遲 5 秒後處理
|
|
556
|
-
* const jobId = await hookManager.dispatchDeferredQueued(
|
|
557
|
-
* 'reminder:send',
|
|
558
|
-
* { userId: '123' },
|
|
559
|
-
* 5000
|
|
560
|
-
* )
|
|
561
|
-
* ```
|
|
562
|
-
*
|
|
563
|
-
* @public
|
|
564
|
-
*/
|
|
565
|
-
dispatchDeferredQueued<TArgs = unknown>(event: string, args: TArgs, delay: number, options?: any): Promise<string>;
|
|
566
|
-
/**
|
|
567
|
-
* Get the execution status of an event.
|
|
568
|
-
*
|
|
569
|
-
* 查詢事件執行狀態,支持查詢 Bull Queue 和 DLQ 中的事件。
|
|
570
|
-
*
|
|
571
|
-
* @param eventId - 事件 ID (task.id 或 jobId)
|
|
572
|
-
* @returns 事件狀態信息
|
|
573
|
-
* @throws 如果未配置 MessageQueueBridge
|
|
574
|
-
*
|
|
575
|
-
* @example
|
|
576
|
-
* ```typescript
|
|
577
|
-
* const status = await hookManager.getEventStatus('queue-1707000000000-abc123')
|
|
578
|
-
* console.log(status) // { eventId, status, attempts, createdAt, ... }
|
|
579
|
-
* ```
|
|
580
|
-
*
|
|
581
|
-
* @public
|
|
582
|
-
*/
|
|
583
|
-
getEventStatus(eventId: string): Promise<any>;
|
|
584
|
-
/**
|
|
585
|
-
* Get persistent DLQ statistics.
|
|
586
|
-
*
|
|
587
|
-
* @returns Statistics object with total, byEvent, and byStatus counts
|
|
588
|
-
* @public
|
|
589
|
-
*/
|
|
590
|
-
getPersistentDLQStats(): Promise<import("@gravito/core").DLQStats | undefined>;
|
|
591
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|