@gravito/echo 3.0.0 → 3.1.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 +211 -0
- package/dist/atlas/src/DB.d.ts +301 -0
- package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
- package/dist/atlas/src/config/defineConfig.d.ts +14 -0
- package/dist/atlas/src/config/index.d.ts +7 -0
- package/dist/atlas/src/config/loadConfig.d.ts +48 -0
- package/dist/atlas/src/connection/Connection.d.ts +108 -0
- package/dist/atlas/src/connection/ConnectionManager.d.ts +111 -0
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +32 -0
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +118 -0
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +36 -0
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +66 -0
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +83 -0
- package/dist/atlas/src/drivers/RedisDriver.d.ts +43 -0
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +45 -0
- package/dist/atlas/src/drivers/types.d.ts +260 -0
- package/dist/atlas/src/errors/index.d.ts +45 -0
- package/dist/atlas/src/grammar/Grammar.d.ts +342 -0
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +47 -0
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +54 -0
- package/dist/atlas/src/grammar/NullGrammar.d.ts +35 -0
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +62 -0
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +32 -0
- package/dist/atlas/src/index.d.ts +67 -0
- package/dist/atlas/src/migration/Migration.d.ts +64 -0
- package/dist/atlas/src/migration/MigrationRepository.d.ts +65 -0
- package/dist/atlas/src/migration/Migrator.d.ts +110 -0
- package/dist/atlas/src/migration/index.d.ts +6 -0
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +11 -0
- package/dist/atlas/src/observability/AtlasObservability.d.ts +15 -0
- package/dist/atlas/src/observability/AtlasTracer.d.ts +12 -0
- package/dist/atlas/src/observability/index.d.ts +9 -0
- package/dist/atlas/src/orm/index.d.ts +5 -0
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
- package/dist/atlas/src/orm/model/Model.d.ts +449 -0
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +136 -0
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +87 -0
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
- package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
- package/dist/atlas/src/orm/model/decorators.d.ts +109 -0
- package/dist/atlas/src/orm/model/errors.d.ts +52 -0
- package/dist/atlas/src/orm/model/index.d.ts +10 -0
- package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
- package/dist/atlas/src/orm/model/types.d.ts +12 -0
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +123 -0
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
- package/dist/atlas/src/orm/schema/index.d.ts +6 -0
- package/dist/atlas/src/orm/schema/types.d.ts +85 -0
- package/dist/atlas/src/query/Expression.d.ts +60 -0
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
- package/dist/atlas/src/query/QueryBuilder.d.ts +573 -0
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
- package/dist/atlas/src/query/clauses/index.d.ts +11 -0
- package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
- package/dist/atlas/src/schema/Schema.d.ts +131 -0
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
- package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
- package/dist/atlas/src/schema/index.d.ts +8 -0
- package/dist/atlas/src/seed/Factory.d.ts +90 -0
- package/dist/atlas/src/seed/Seeder.d.ts +28 -0
- package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
- package/dist/atlas/src/seed/index.d.ts +6 -0
- package/dist/atlas/src/types/index.d.ts +1100 -0
- package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
- package/dist/core/src/Application.d.ts +215 -0
- package/dist/core/src/CommandKernel.d.ts +33 -0
- package/dist/core/src/ConfigManager.d.ts +26 -0
- package/dist/core/src/Container.d.ts +108 -0
- package/dist/core/src/ErrorHandler.d.ts +63 -0
- package/dist/core/src/Event.d.ts +5 -0
- package/dist/core/src/EventManager.d.ts +123 -0
- package/dist/core/src/GlobalErrorHandlers.d.ts +47 -0
- package/dist/core/src/GravitoServer.d.ts +28 -0
- package/dist/core/src/HookManager.d.ts +496 -0
- package/dist/core/src/Listener.d.ts +4 -0
- package/dist/core/src/Logger.d.ts +20 -0
- package/dist/core/src/PlanetCore.d.ts +289 -0
- package/dist/core/src/Route.d.ts +36 -0
- package/dist/core/src/Router.d.ts +284 -0
- package/dist/core/src/ServiceProvider.d.ts +156 -0
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +27 -0
- package/dist/core/src/adapters/PhotonAdapter.d.ts +171 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +45 -0
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +31 -0
- package/dist/core/src/adapters/bun/BunRequest.d.ts +31 -0
- package/dist/core/src/adapters/bun/RadixNode.d.ts +19 -0
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +31 -0
- package/dist/core/src/adapters/bun/types.d.ts +20 -0
- package/dist/core/src/adapters/photon-types.d.ts +73 -0
- package/dist/core/src/adapters/types.d.ts +235 -0
- package/dist/core/src/engine/AOTRouter.d.ts +124 -0
- package/dist/core/src/engine/FastContext.d.ts +100 -0
- package/dist/core/src/engine/Gravito.d.ts +137 -0
- package/dist/core/src/engine/MinimalContext.d.ts +79 -0
- package/dist/core/src/engine/analyzer.d.ts +27 -0
- package/dist/core/src/engine/constants.d.ts +23 -0
- package/dist/core/src/engine/index.d.ts +26 -0
- package/dist/core/src/engine/path.d.ts +26 -0
- package/dist/core/src/engine/pool.d.ts +83 -0
- package/dist/core/src/engine/types.d.ts +143 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +145 -0
- package/dist/core/src/events/EventBackend.d.ts +11 -0
- package/dist/core/src/events/EventOptions.d.ts +109 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +202 -0
- package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
- package/dist/core/src/events/index.d.ts +14 -0
- package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
- package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
- package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +240 -0
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
- package/dist/core/src/events/observability/index.d.ts +20 -0
- package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
- package/dist/core/src/events/types.d.ts +75 -0
- package/dist/core/src/exceptions/AuthenticationException.d.ts +8 -0
- package/dist/core/src/exceptions/AuthorizationException.d.ts +8 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
- package/dist/core/src/exceptions/GravitoException.d.ts +23 -0
- package/dist/core/src/exceptions/HttpException.d.ts +9 -0
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +10 -0
- package/dist/core/src/exceptions/ValidationException.d.ts +22 -0
- package/dist/core/src/exceptions/index.d.ts +7 -0
- package/dist/core/src/helpers/Arr.d.ts +19 -0
- package/dist/core/src/helpers/Str.d.ts +23 -0
- package/dist/core/src/helpers/data.d.ts +25 -0
- package/dist/core/src/helpers/errors.d.ts +34 -0
- package/dist/core/src/helpers/response.d.ts +41 -0
- package/dist/core/src/helpers.d.ts +338 -0
- package/dist/core/src/http/CookieJar.d.ts +51 -0
- package/dist/core/src/http/cookie.d.ts +29 -0
- package/dist/core/src/http/middleware/BodySizeLimit.d.ts +16 -0
- package/dist/core/src/http/middleware/Cors.d.ts +24 -0
- package/dist/core/src/http/middleware/Csrf.d.ts +23 -0
- package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +28 -0
- package/dist/core/src/http/middleware/SecurityHeaders.d.ts +29 -0
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +18 -0
- package/dist/core/src/http/types.d.ts +355 -0
- package/dist/core/src/index.d.ts +76 -0
- package/dist/core/src/instrumentation/index.d.ts +35 -0
- package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
- package/dist/core/src/instrumentation/types.d.ts +182 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +316 -0
- package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
- package/dist/core/src/reliability/index.d.ts +6 -0
- package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
- package/dist/core/src/router/RequestValidator.d.ts +20 -0
- package/dist/core/src/runtime.d.ts +119 -0
- package/dist/core/src/security/Encrypter.d.ts +33 -0
- package/dist/core/src/security/Hasher.d.ts +29 -0
- package/dist/core/src/testing/HttpTester.d.ts +39 -0
- package/dist/core/src/testing/TestResponse.d.ts +78 -0
- package/dist/core/src/testing/index.d.ts +2 -0
- package/dist/core/src/types/events.d.ts +94 -0
- package/dist/echo/src/OrbitEcho.d.ts +115 -0
- package/dist/echo/src/dlq/DeadLetterQueue.d.ts +94 -0
- package/dist/echo/src/dlq/MemoryDeadLetterQueue.d.ts +36 -0
- package/dist/echo/src/dlq/index.d.ts +2 -0
- package/dist/echo/src/index.d.ts +64 -0
- package/dist/echo/src/middleware/RequestBufferMiddleware.d.ts +62 -0
- package/dist/echo/src/middleware/index.d.ts +8 -0
- package/dist/echo/src/observability/index.d.ts +3 -0
- package/dist/echo/src/observability/logging/ConsoleEchoLogger.d.ts +37 -0
- package/dist/echo/src/observability/logging/EchoLogger.d.ts +38 -0
- package/dist/echo/src/observability/logging/index.d.ts +2 -0
- package/dist/echo/src/observability/metrics/MetricsProvider.d.ts +69 -0
- package/dist/echo/src/observability/metrics/NoopMetricsProvider.d.ts +17 -0
- package/dist/echo/src/observability/metrics/PrometheusMetricsProvider.d.ts +39 -0
- package/dist/echo/src/observability/metrics/index.d.ts +3 -0
- package/dist/echo/src/observability/tracing/NoopTracer.d.ts +33 -0
- package/dist/echo/src/observability/tracing/Tracer.d.ts +75 -0
- package/dist/echo/src/observability/tracing/index.d.ts +2 -0
- package/dist/echo/src/providers/GenericProvider.d.ts +53 -0
- package/dist/echo/src/providers/GitHubProvider.d.ts +35 -0
- package/dist/echo/src/providers/LinearProvider.d.ts +27 -0
- package/dist/echo/src/providers/PaddleProvider.d.ts +31 -0
- package/dist/echo/src/providers/ShopifyProvider.d.ts +27 -0
- package/dist/echo/src/providers/SlackProvider.d.ts +27 -0
- package/dist/echo/src/providers/StripeProvider.d.ts +38 -0
- package/dist/echo/src/providers/TwilioProvider.d.ts +31 -0
- package/dist/echo/src/providers/base/BaseProvider.d.ts +87 -0
- package/dist/echo/src/providers/base/HeaderUtils.d.ts +34 -0
- package/dist/echo/src/providers/index.d.ts +14 -0
- package/dist/echo/src/receive/SignatureValidator.d.ts +67 -0
- package/dist/echo/src/receive/WebhookReceiver.d.ts +185 -0
- package/dist/echo/src/receive/index.d.ts +2 -0
- package/dist/echo/src/replay/WebhookReplayService.d.ts +35 -0
- package/dist/echo/src/replay/index.d.ts +1 -0
- package/dist/echo/src/resilience/CircuitBreaker.d.ts +117 -0
- package/dist/echo/src/resilience/index.d.ts +10 -0
- package/dist/echo/src/rotation/KeyRotationManager.d.ts +127 -0
- package/dist/echo/src/rotation/index.d.ts +10 -0
- package/dist/echo/src/send/WebhookDispatcher.d.ts +198 -0
- package/dist/echo/src/send/index.d.ts +1 -0
- package/dist/echo/src/storage/MemoryWebhookStore.d.ts +14 -0
- package/dist/echo/src/storage/WebhookStore.d.ts +236 -0
- package/dist/echo/src/storage/index.d.ts +2 -0
- package/dist/echo/src/types.d.ts +756 -0
- package/dist/index.js +1332 -190
- package/dist/index.js.map +28 -10
- package/dist/photon/src/index.d.ts +84 -0
- package/dist/photon/src/middleware/binary.d.ts +31 -0
- package/dist/photon/src/middleware/htmx.d.ts +39 -0
- package/dist/photon/src/middleware/ratelimit.d.ts +157 -0
- package/dist/photon/src/openapi.d.ts +19 -0
- package/package.json +7 -5
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Engine Constants & Cached Buffers
|
|
3
|
+
*
|
|
4
|
+
* Pre-allocated resources to minimize runtime allocation overhead.
|
|
5
|
+
* Specifically targets Bun's zero-copy capabilities.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CACHED_RESPONSES: {
|
|
8
|
+
readonly NOT_FOUND: Uint8Array<ArrayBuffer>;
|
|
9
|
+
readonly INTERNAL_ERROR: Uint8Array<ArrayBuffer>;
|
|
10
|
+
readonly OK: Uint8Array<ArrayBuffer>;
|
|
11
|
+
readonly EMPTY: Uint8Array<ArrayBuffer>;
|
|
12
|
+
};
|
|
13
|
+
export declare const HEADERS: {
|
|
14
|
+
readonly JSON: {
|
|
15
|
+
readonly 'Content-Type': "application/json; charset=utf-8";
|
|
16
|
+
};
|
|
17
|
+
readonly TEXT: {
|
|
18
|
+
readonly 'Content-Type': "text/plain; charset=utf-8";
|
|
19
|
+
};
|
|
20
|
+
readonly HTML: {
|
|
21
|
+
readonly 'Content-Type': "text/html; charset=utf-8";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Gravito Core Engine - Public API
|
|
3
|
+
*
|
|
4
|
+
* The High-Performance Web Engine for Bun
|
|
5
|
+
*
|
|
6
|
+
* @module @gravito/core/engine
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Gravito } from '@gravito/core/engine'
|
|
12
|
+
*
|
|
13
|
+
* const app = new Gravito()
|
|
14
|
+
*
|
|
15
|
+
* app.get('/', (c) => c.json({ message: 'Hello, World!' }))
|
|
16
|
+
*
|
|
17
|
+
* export default app
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export { Gravito } from './Gravito';
|
|
21
|
+
export type { EngineOptions, ErrorHandler, FastContext, FastRequest, Handler, Middleware, NotFoundHandler, RouteMatch, } from './types';
|
|
22
|
+
export { AOTRouter } from './AOTRouter';
|
|
23
|
+
export { FastContext as FastContextImpl } from './FastContext';
|
|
24
|
+
export { MinimalContext } from './MinimalContext';
|
|
25
|
+
export { extractPath } from './path';
|
|
26
|
+
export { ObjectPool } from './pool';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Lightweight Path Utilities
|
|
3
|
+
*
|
|
4
|
+
* High-performance path extraction without creating URL objects.
|
|
5
|
+
* Performance critical - every optimization matters.
|
|
6
|
+
*
|
|
7
|
+
* @module @gravito/core/engine
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Extract pathname from URL string without creating URL object
|
|
11
|
+
*
|
|
12
|
+
* @param url - Full URL string (e.g., "http://localhost:3000/api/users?id=1")
|
|
13
|
+
* @returns pathname (e.g., "/api/users")
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* extractPath("http://localhost:3000/api/users?id=1") // "/api/users"
|
|
18
|
+
* extractPath("https://example.com/") // "/"
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractPath(url: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Extract pathname using simpler logic (alternative implementation)
|
|
24
|
+
* Use this if the above doesn't cover edge cases
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractPathSimple(url: string): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic Object Pool Implementation
|
|
3
|
+
*
|
|
4
|
+
* High-performance object pooling to reduce GC pressure.
|
|
5
|
+
* Implements "fixed pool + overflow fallback" strategy.
|
|
6
|
+
*
|
|
7
|
+
* @module @gravito/core/engine
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Generic object pool with fixed size and overflow handling
|
|
11
|
+
*
|
|
12
|
+
* @typeParam T - Type of objects to pool
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const pool = new ObjectPool(
|
|
17
|
+
* () => new MyObject(),
|
|
18
|
+
* (obj) => obj.reset(),
|
|
19
|
+
* 256
|
|
20
|
+
* )
|
|
21
|
+
*
|
|
22
|
+
* const obj = pool.acquire()
|
|
23
|
+
* try {
|
|
24
|
+
* // Use object
|
|
25
|
+
* } finally {
|
|
26
|
+
* pool.release(obj)
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class ObjectPool<T> {
|
|
31
|
+
private pool;
|
|
32
|
+
private readonly factory;
|
|
33
|
+
private readonly reset;
|
|
34
|
+
private readonly maxSize;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new object pool
|
|
37
|
+
*
|
|
38
|
+
* @param factory - Function to create new objects
|
|
39
|
+
* @param reset - Function to reset objects before reuse
|
|
40
|
+
* @param maxSize - Maximum pool size (default: 256)
|
|
41
|
+
*/
|
|
42
|
+
constructor(factory: () => T, reset: (obj: T) => void, maxSize?: number);
|
|
43
|
+
/**
|
|
44
|
+
* Acquire an object from the pool
|
|
45
|
+
*
|
|
46
|
+
* If the pool is empty, creates a new object (overflow strategy).
|
|
47
|
+
* This ensures the pool never blocks under high load.
|
|
48
|
+
*
|
|
49
|
+
* @returns Object from pool or newly created
|
|
50
|
+
*/
|
|
51
|
+
acquire(): T;
|
|
52
|
+
/**
|
|
53
|
+
* Release an object back to the pool
|
|
54
|
+
*
|
|
55
|
+
* If the pool is full, the object is discarded (will be GC'd).
|
|
56
|
+
* This prevents unbounded memory growth.
|
|
57
|
+
*
|
|
58
|
+
* @param obj - Object to release
|
|
59
|
+
*/
|
|
60
|
+
release(obj: T): void;
|
|
61
|
+
/**
|
|
62
|
+
* Clear all objects from the pool
|
|
63
|
+
*
|
|
64
|
+
* Useful for testing or when you need to force a clean slate.
|
|
65
|
+
*/
|
|
66
|
+
clear(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get current pool size
|
|
69
|
+
*/
|
|
70
|
+
get size(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Get maximum pool size
|
|
73
|
+
*/
|
|
74
|
+
get capacity(): number;
|
|
75
|
+
/**
|
|
76
|
+
* Pre-warm the pool by creating objects in advance
|
|
77
|
+
*
|
|
78
|
+
* This can reduce latency for the first N requests.
|
|
79
|
+
*
|
|
80
|
+
* @param count - Number of objects to pre-create
|
|
81
|
+
*/
|
|
82
|
+
prewarm(count: number): void;
|
|
83
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Gravito Core Engine Types
|
|
3
|
+
*
|
|
4
|
+
* Minimal, high-performance types for the standalone engine.
|
|
5
|
+
* These are intentionally simpler than the full framework types.
|
|
6
|
+
*
|
|
7
|
+
* @module @gravito/core/engine
|
|
8
|
+
*/
|
|
9
|
+
import type { HttpMethod } from '../http/types';
|
|
10
|
+
/**
|
|
11
|
+
* FastContext - The pooled request context
|
|
12
|
+
*/
|
|
13
|
+
export interface FastContext {
|
|
14
|
+
/** Request accessor */
|
|
15
|
+
readonly req: FastRequest;
|
|
16
|
+
/** Response helpers */
|
|
17
|
+
json<T>(data: T, status?: number): Response;
|
|
18
|
+
text(text: string, status?: number): Response;
|
|
19
|
+
html(html: string, status?: number): Response;
|
|
20
|
+
redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): Response;
|
|
21
|
+
body(data: BodyInit | null, status?: number): Response;
|
|
22
|
+
stream(stream: ReadableStream, status?: number): Response;
|
|
23
|
+
notFound(message?: string): Response;
|
|
24
|
+
forbidden(message?: string): Response;
|
|
25
|
+
unauthorized(message?: string): Response;
|
|
26
|
+
badRequest(message?: string): Response;
|
|
27
|
+
forward(target: string, options?: any): Promise<Response>;
|
|
28
|
+
/** Header management */
|
|
29
|
+
header(name: string): string | undefined;
|
|
30
|
+
header(name: string, value: string): void;
|
|
31
|
+
status(code: number): void;
|
|
32
|
+
/** Context Variables */
|
|
33
|
+
get<T>(key: string): T;
|
|
34
|
+
set(key: string, value: any): void;
|
|
35
|
+
/** Lifecycle helpers */
|
|
36
|
+
route: (name: string, params?: any, query?: any) => string;
|
|
37
|
+
readonly native: any;
|
|
38
|
+
/** Internal initialization for pooling */
|
|
39
|
+
init(request: Request, params?: Record<string, string>, path?: string, routePattern?: string): this;
|
|
40
|
+
/** Internal cleanup for pooling */
|
|
41
|
+
reset(): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* FastRequest - Minimal request interface
|
|
45
|
+
*/
|
|
46
|
+
export interface FastRequest {
|
|
47
|
+
/** Full URL */
|
|
48
|
+
readonly url: string;
|
|
49
|
+
/** HTTP method */
|
|
50
|
+
readonly method: string;
|
|
51
|
+
/** Path without query */
|
|
52
|
+
readonly path: string;
|
|
53
|
+
/**
|
|
54
|
+
* Route pattern (e.g., /users/:id) for metrics labeling
|
|
55
|
+
* Prevents high cardinality issues in monitoring systems
|
|
56
|
+
*/
|
|
57
|
+
readonly routePattern?: string;
|
|
58
|
+
/** Get route parameter */
|
|
59
|
+
param(name: string): string | undefined;
|
|
60
|
+
/** Get all route parameters */
|
|
61
|
+
params(): Record<string, string>;
|
|
62
|
+
/** Get query parameter */
|
|
63
|
+
query(name: string): string | undefined;
|
|
64
|
+
/** Get all query parameters */
|
|
65
|
+
queries(): Record<string, string | string[]>;
|
|
66
|
+
/** Get header */
|
|
67
|
+
header(name: string): string | undefined;
|
|
68
|
+
/** Get all headers */
|
|
69
|
+
headers(): Record<string, string>;
|
|
70
|
+
/** Parse JSON body */
|
|
71
|
+
json<T = unknown>(): Promise<T>;
|
|
72
|
+
/** Parse text body */
|
|
73
|
+
text(): Promise<string>;
|
|
74
|
+
/** Parse form data */
|
|
75
|
+
formData(): Promise<FormData>;
|
|
76
|
+
/** Raw Request object */
|
|
77
|
+
readonly raw: Request;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Route handler function
|
|
81
|
+
*/
|
|
82
|
+
export type Handler = (ctx: FastContext) => Response | Promise<Response>;
|
|
83
|
+
/**
|
|
84
|
+
* Middleware function
|
|
85
|
+
*/
|
|
86
|
+
export type Middleware = (ctx: FastContext, next: () => Promise<Response | undefined>) => Response | undefined | Promise<Response | undefined>;
|
|
87
|
+
/**
|
|
88
|
+
* Error handler function
|
|
89
|
+
*/
|
|
90
|
+
export type ErrorHandler = (error: Error, ctx: FastContext) => Response | Promise<Response>;
|
|
91
|
+
/**
|
|
92
|
+
* Not found handler function
|
|
93
|
+
*/
|
|
94
|
+
export type NotFoundHandler = (ctx: FastContext) => Response | Promise<Response>;
|
|
95
|
+
/**
|
|
96
|
+
* Route metadata for middleware management
|
|
97
|
+
*/
|
|
98
|
+
export interface RouteMetadata {
|
|
99
|
+
handler: Handler;
|
|
100
|
+
middleware: Middleware[];
|
|
101
|
+
compiled?: CompiledHandler;
|
|
102
|
+
useMinimal?: boolean;
|
|
103
|
+
compiledVersion?: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compiled handler function
|
|
107
|
+
*/
|
|
108
|
+
export type CompiledHandler = (ctx: FastContext) => Promise<Response>;
|
|
109
|
+
/**
|
|
110
|
+
* Route match result from router
|
|
111
|
+
*/
|
|
112
|
+
export interface RouteMatch {
|
|
113
|
+
/** Matched handler */
|
|
114
|
+
handler: Handler | null;
|
|
115
|
+
/** Extracted route parameters */
|
|
116
|
+
params: Record<string, string>;
|
|
117
|
+
/** Middleware to execute */
|
|
118
|
+
middleware: Middleware[];
|
|
119
|
+
/** Optional stable route pattern for caching */
|
|
120
|
+
routePattern?: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Internal route node
|
|
124
|
+
*/
|
|
125
|
+
export interface RouteNode {
|
|
126
|
+
method: HttpMethod;
|
|
127
|
+
path: string;
|
|
128
|
+
handler: Handler;
|
|
129
|
+
middleware: Middleware[];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Engine configuration options
|
|
133
|
+
*/
|
|
134
|
+
export interface EngineOptions {
|
|
135
|
+
/** Context pool size (default: 256) */
|
|
136
|
+
poolSize?: number;
|
|
137
|
+
/** Enable route compilation optimization (default: true) */
|
|
138
|
+
enableAOT?: boolean;
|
|
139
|
+
/** Custom error handler */
|
|
140
|
+
onError?: ErrorHandler;
|
|
141
|
+
/** Custom 404 handler */
|
|
142
|
+
onNotFound?: NotFoundHandler;
|
|
143
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Circuit Breaker state enum.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export declare enum CircuitBreakerState {
|
|
6
|
+
CLOSED = "CLOSED",
|
|
7
|
+
OPEN = "OPEN",
|
|
8
|
+
HALF_OPEN = "HALF_OPEN"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Circuit Breaker metrics snapshot.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export interface CircuitBreakerMetrics {
|
|
15
|
+
/**
|
|
16
|
+
* Current state of the circuit breaker
|
|
17
|
+
*/
|
|
18
|
+
state: CircuitBreakerState;
|
|
19
|
+
/**
|
|
20
|
+
* Number of failures in the current window
|
|
21
|
+
*/
|
|
22
|
+
failures: number;
|
|
23
|
+
/**
|
|
24
|
+
* Number of successes in the current window
|
|
25
|
+
*/
|
|
26
|
+
successes: number;
|
|
27
|
+
/**
|
|
28
|
+
* Timestamp of the last failure
|
|
29
|
+
*/
|
|
30
|
+
lastFailureAt?: Date;
|
|
31
|
+
/**
|
|
32
|
+
* Timestamp of the last success
|
|
33
|
+
*/
|
|
34
|
+
lastSuccessAt?: Date;
|
|
35
|
+
/**
|
|
36
|
+
* Timestamp when the circuit was opened
|
|
37
|
+
*/
|
|
38
|
+
openedAt?: Date;
|
|
39
|
+
/**
|
|
40
|
+
* Total requests processed
|
|
41
|
+
*/
|
|
42
|
+
totalRequests: number;
|
|
43
|
+
/**
|
|
44
|
+
* Total failures recorded
|
|
45
|
+
*/
|
|
46
|
+
totalFailures: number;
|
|
47
|
+
/**
|
|
48
|
+
* Total successes recorded
|
|
49
|
+
*/
|
|
50
|
+
totalSuccesses: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Circuit Breaker metrics recorder interface.
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export interface CircuitBreakerMetricsRecorder {
|
|
57
|
+
/**
|
|
58
|
+
* Record current state of the circuit breaker.
|
|
59
|
+
* @param eventName - Name of the event
|
|
60
|
+
* @param state - State as number (0=CLOSED, 1=HALF_OPEN, 2=OPEN)
|
|
61
|
+
*/
|
|
62
|
+
recordState: (eventName: string, state: number) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Record state transition.
|
|
65
|
+
*/
|
|
66
|
+
recordTransition: (eventName: string, fromState: string, toState: string) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Record a failure.
|
|
69
|
+
*/
|
|
70
|
+
recordFailure: (eventName: string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Record a success.
|
|
73
|
+
*/
|
|
74
|
+
recordSuccess: (eventName: string) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Record OPEN state duration.
|
|
77
|
+
*/
|
|
78
|
+
recordOpenDuration: (eventName: string, seconds: number) => void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Circuit Breaker configuration options.
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export interface CircuitBreakerOptions {
|
|
85
|
+
/**
|
|
86
|
+
* Number of consecutive failures before opening the circuit.
|
|
87
|
+
* @default 5
|
|
88
|
+
*/
|
|
89
|
+
failureThreshold?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Time in milliseconds to wait before attempting to close the circuit (move to HALF_OPEN).
|
|
92
|
+
* @default 30000
|
|
93
|
+
*/
|
|
94
|
+
resetTimeout?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Number of test requests to allow given the circuit is in HALF_OPEN state.
|
|
97
|
+
* If these succeed, the circuit closes. If any fail, it opens again.
|
|
98
|
+
* @default 3
|
|
99
|
+
*/
|
|
100
|
+
halfOpenRequests?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Number of successes required in HALF_OPEN state to close the circuit.
|
|
103
|
+
* @default 2
|
|
104
|
+
*/
|
|
105
|
+
successThreshold?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Time in milliseconds for the sliding window to track failures.
|
|
108
|
+
* Failures outside this window are not counted.
|
|
109
|
+
* @default 60000
|
|
110
|
+
*/
|
|
111
|
+
windowSize?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Enable or disable the circuit breaker.
|
|
114
|
+
* @default true
|
|
115
|
+
*/
|
|
116
|
+
enabled?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Callback when circuit opens.
|
|
119
|
+
*/
|
|
120
|
+
onOpen?: (name?: string) => void;
|
|
121
|
+
/**
|
|
122
|
+
* Callback when circuit moves to half-open.
|
|
123
|
+
*/
|
|
124
|
+
onHalfOpen?: (name?: string) => void;
|
|
125
|
+
/**
|
|
126
|
+
* Callback when circuit closes.
|
|
127
|
+
*/
|
|
128
|
+
onClose?: (name?: string) => void;
|
|
129
|
+
/**
|
|
130
|
+
* Metrics recorder for recording circuit breaker events.
|
|
131
|
+
* Optional - if not provided, metrics will not be recorded.
|
|
132
|
+
*/
|
|
133
|
+
metricsRecorder?: CircuitBreakerMetricsRecorder | undefined;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Required Circuit Breaker configuration (with defaults applied).
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
export interface RequiredCircuitBreakerOptions extends Required<Omit<CircuitBreakerOptions, 'metricsRecorder'>> {
|
|
140
|
+
metricsRecorder?: CircuitBreakerMetricsRecorder;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Circuit Breaker implementation for fault tolerance.
|
|
144
|
+
*
|
|
145
|
+
* Prevents cascading failures by stopping execution of a failing operation
|
|
146
|
+
* for a specified period after a threshold of failures is reached.
|
|
147
|
+
*
|
|
148
|
+
* Supports sliding window algorithm, enabling/disabling, and detailed metrics.
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
export declare class CircuitBreaker {
|
|
153
|
+
private state;
|
|
154
|
+
private failureCount;
|
|
155
|
+
private successCount;
|
|
156
|
+
private name;
|
|
157
|
+
private config;
|
|
158
|
+
private metricsRecorder?;
|
|
159
|
+
private lastFailureAt?;
|
|
160
|
+
private lastSuccessAt?;
|
|
161
|
+
private openedAt?;
|
|
162
|
+
private totalRequests;
|
|
163
|
+
private totalFailures;
|
|
164
|
+
private totalSuccesses;
|
|
165
|
+
private halfOpenAttempts;
|
|
166
|
+
/**
|
|
167
|
+
* Create a new Circuit Breaker.
|
|
168
|
+
*
|
|
169
|
+
* Supports two signatures for backward compatibility:
|
|
170
|
+
* - CircuitBreaker(options?: CircuitBreakerOptions) - anonymous breaker
|
|
171
|
+
* - CircuitBreaker(name: string, options?: CircuitBreakerOptions) - named breaker
|
|
172
|
+
*
|
|
173
|
+
* @param nameOrOptions - Circuit breaker name or options
|
|
174
|
+
* @param maybeOptions - Options (used when first param is a string)
|
|
175
|
+
*/
|
|
176
|
+
constructor(nameOrOptions?: string | CircuitBreakerOptions, maybeOptions?: CircuitBreakerOptions);
|
|
177
|
+
/**
|
|
178
|
+
* Execute an operation through the circuit breaker.
|
|
179
|
+
*
|
|
180
|
+
* @param operation - Async operation to execute
|
|
181
|
+
* @returns Operation result
|
|
182
|
+
* @throws Error if circuit is open or operation fails
|
|
183
|
+
*/
|
|
184
|
+
execute<T>(operation: () => Promise<T>): Promise<T>;
|
|
185
|
+
/**
|
|
186
|
+
* Check if the circuit breaker is currently OPEN.
|
|
187
|
+
*/
|
|
188
|
+
isOpen(): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Check if the circuit breaker is currently HALF_OPEN.
|
|
191
|
+
*/
|
|
192
|
+
isHalfOpen(): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Check if the circuit breaker is currently CLOSED.
|
|
195
|
+
*/
|
|
196
|
+
isClosed(): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Get current state of the circuit breaker.
|
|
199
|
+
*/
|
|
200
|
+
getState(): CircuitBreakerState;
|
|
201
|
+
/**
|
|
202
|
+
* Get failure count (deprecated, use getMetrics for complete information).
|
|
203
|
+
*/
|
|
204
|
+
getFailureCount(): number;
|
|
205
|
+
/**
|
|
206
|
+
* Get the name of this circuit breaker.
|
|
207
|
+
*/
|
|
208
|
+
getName(): string;
|
|
209
|
+
/**
|
|
210
|
+
* Get detailed metrics snapshot of the circuit breaker.
|
|
211
|
+
*/
|
|
212
|
+
getMetrics(): CircuitBreakerMetrics;
|
|
213
|
+
/**
|
|
214
|
+
* Manually reset the circuit breaker to CLOSED state.
|
|
215
|
+
*/
|
|
216
|
+
reset(): void;
|
|
217
|
+
/**
|
|
218
|
+
* Forcefully reset the circuit breaker (alias for reset).
|
|
219
|
+
*/
|
|
220
|
+
manualReset(): void;
|
|
221
|
+
/**
|
|
222
|
+
* Check for automatic state transitions based on time and sliding window.
|
|
223
|
+
*/
|
|
224
|
+
checkStateTransition(): void;
|
|
225
|
+
private onSuccess;
|
|
226
|
+
private onFailure;
|
|
227
|
+
private transitionTo;
|
|
228
|
+
private stateToNumber;
|
|
229
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { EventOptions } from './EventOptions';
|
|
2
|
+
/**
|
|
3
|
+
* Dead Letter Queue entry representing a failed event.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface DLQEntry {
|
|
7
|
+
/**
|
|
8
|
+
* Unique identifier for this DLQ entry.
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* Event hook name.
|
|
13
|
+
*/
|
|
14
|
+
eventName: string;
|
|
15
|
+
/**
|
|
16
|
+
* Event payload.
|
|
17
|
+
*/
|
|
18
|
+
payload: unknown;
|
|
19
|
+
/**
|
|
20
|
+
* Event options used when dispatching.
|
|
21
|
+
*/
|
|
22
|
+
options: EventOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Error that caused the event to fail.
|
|
25
|
+
*/
|
|
26
|
+
error: {
|
|
27
|
+
message: string;
|
|
28
|
+
stack?: string;
|
|
29
|
+
code?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Number of retry attempts made.
|
|
33
|
+
*/
|
|
34
|
+
retryCount: number;
|
|
35
|
+
/**
|
|
36
|
+
* Timestamp when the event first failed.
|
|
37
|
+
*/
|
|
38
|
+
firstFailedAt: number;
|
|
39
|
+
/**
|
|
40
|
+
* Timestamp when the event was added to DLQ.
|
|
41
|
+
*/
|
|
42
|
+
failedAt: number;
|
|
43
|
+
/**
|
|
44
|
+
* Timestamp when the event was last retried (if any).
|
|
45
|
+
*/
|
|
46
|
+
lastRetriedAt?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Filter options for querying DLQ entries.
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export interface DLQFilter {
|
|
53
|
+
/**
|
|
54
|
+
* Filter by event name.
|
|
55
|
+
*/
|
|
56
|
+
eventName?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Filter by entries failed after this timestamp.
|
|
59
|
+
*/
|
|
60
|
+
from?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Filter by entries failed before this timestamp.
|
|
63
|
+
*/
|
|
64
|
+
to?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Maximum number of entries to return.
|
|
67
|
+
*/
|
|
68
|
+
limit?: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Dead Letter Queue Manager for handling failed events.
|
|
72
|
+
*
|
|
73
|
+
* The DLQ stores events that have exceeded their retry limit,
|
|
74
|
+
* allowing for manual inspection, reprocessing, or analysis.
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
export declare class DeadLetterQueue {
|
|
79
|
+
private entries;
|
|
80
|
+
private entryIdCounter;
|
|
81
|
+
/**
|
|
82
|
+
* Add a failed event to the Dead Letter Queue.
|
|
83
|
+
*
|
|
84
|
+
* @param eventName - Name of the failed event
|
|
85
|
+
* @param payload - Event payload
|
|
86
|
+
* @param options - Event options
|
|
87
|
+
* @param error - Error that caused the failure
|
|
88
|
+
* @param retryCount - Number of retry attempts made
|
|
89
|
+
* @param firstFailedAt - Timestamp of first failure
|
|
90
|
+
* @returns DLQ entry ID
|
|
91
|
+
*/
|
|
92
|
+
add(eventName: string, payload: unknown, options: EventOptions, error: Error, retryCount: number, firstFailedAt: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* Get a specific DLQ entry by ID.
|
|
95
|
+
*
|
|
96
|
+
* @param entryId - DLQ entry ID
|
|
97
|
+
* @returns DLQ entry or undefined if not found
|
|
98
|
+
*/
|
|
99
|
+
get(entryId: string): DLQEntry | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* List DLQ entries with optional filtering.
|
|
102
|
+
*
|
|
103
|
+
* @param filter - Filter options
|
|
104
|
+
* @returns Array of DLQ entries
|
|
105
|
+
*/
|
|
106
|
+
list(filter?: DLQFilter): DLQEntry[];
|
|
107
|
+
/**
|
|
108
|
+
* Delete a DLQ entry.
|
|
109
|
+
*
|
|
110
|
+
* @param entryId - DLQ entry ID
|
|
111
|
+
* @returns True if entry was deleted, false if not found
|
|
112
|
+
*/
|
|
113
|
+
delete(entryId: string): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Delete all DLQ entries matching the filter.
|
|
116
|
+
*
|
|
117
|
+
* @param filter - Filter options
|
|
118
|
+
* @returns Number of entries deleted
|
|
119
|
+
*/
|
|
120
|
+
deleteAll(filter?: DLQFilter): number;
|
|
121
|
+
/**
|
|
122
|
+
* Get the total number of entries in the DLQ.
|
|
123
|
+
*
|
|
124
|
+
* @returns Total entry count
|
|
125
|
+
*/
|
|
126
|
+
getCount(): number;
|
|
127
|
+
/**
|
|
128
|
+
* Get the count of entries for a specific event.
|
|
129
|
+
*
|
|
130
|
+
* @param eventName - Event name
|
|
131
|
+
* @returns Entry count for the event
|
|
132
|
+
*/
|
|
133
|
+
getCountByEvent(eventName: string): number;
|
|
134
|
+
/**
|
|
135
|
+
* Clear all entries from the DLQ.
|
|
136
|
+
*/
|
|
137
|
+
clear(): void;
|
|
138
|
+
/**
|
|
139
|
+
* Update the last retried timestamp for an entry.
|
|
140
|
+
*
|
|
141
|
+
* @param entryId - DLQ entry ID
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
updateLastRetried(entryId: string): void;
|
|
145
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EventTask } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for event dispatch backends.
|
|
4
|
+
*/
|
|
5
|
+
export interface EventBackend {
|
|
6
|
+
/**
|
|
7
|
+
* Enqueue an event for processing.
|
|
8
|
+
* @param task - The event task to process
|
|
9
|
+
*/
|
|
10
|
+
enqueue(task: EventTask): Promise<void> | void;
|
|
11
|
+
}
|