@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,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reliability and retry exports.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
export { DeadLetterQueueManager, type DLQManagerFilter, type DLQRecord, type DLQStats, } from './DeadLetterQueueManager';
|
|
6
|
+
export { getDefaultRetryPolicy, getPresetRetryPolicy, RetryEngine, type RetryPolicy, } from './RetryPolicy';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GravitoHandler } from '../http/types';
|
|
2
|
+
import type { PlanetCore } from '../PlanetCore';
|
|
3
|
+
import type { ControllerClass } from '../Router';
|
|
4
|
+
export declare class ControllerDispatcher {
|
|
5
|
+
private core;
|
|
6
|
+
private controllers;
|
|
7
|
+
constructor(core: PlanetCore);
|
|
8
|
+
/**
|
|
9
|
+
* Resolve Controller Instance and Method
|
|
10
|
+
*/
|
|
11
|
+
resolve(CtrlClass: ControllerClass, methodName: string): GravitoHandler;
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GravitoMiddleware } from '../http/types';
|
|
2
|
+
import { type FormRequestClass } from '../Router';
|
|
3
|
+
/**
|
|
4
|
+
* Handles validation of incoming requests using FormRequest classes.
|
|
5
|
+
* Provides mechanisms to detect and convert FormRequest classes into Gravito middleware.
|
|
6
|
+
*/
|
|
7
|
+
export declare class RequestValidator {
|
|
8
|
+
/**
|
|
9
|
+
* Check if a value is a FormRequest class.
|
|
10
|
+
* Optimized with Symbol check, prototype check, and caching.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
static isFormRequestClass(value: unknown): value is FormRequestClass;
|
|
14
|
+
/**
|
|
15
|
+
* Convert a FormRequest class to middleware.
|
|
16
|
+
* Uses instance caching to avoid re-instantiation on every request.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
static formRequestToMiddleware(RequestClass: FormRequestClass): GravitoMiddleware;
|
|
20
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detected Javascript Runtime Environment
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export type RuntimeKind = 'bun' | 'node' | 'deno' | 'unknown';
|
|
6
|
+
/**
|
|
7
|
+
* Options for spawning subprocesses
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface RuntimeSpawnOptions {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
env?: Record<string, string | undefined>;
|
|
13
|
+
stdin?: 'pipe' | 'inherit' | 'ignore';
|
|
14
|
+
stdout?: 'pipe' | 'inherit' | 'ignore';
|
|
15
|
+
stderr?: 'pipe' | 'inherit' | 'ignore';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Abstract subprocess interface
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export interface RuntimeProcess {
|
|
22
|
+
exited: Promise<number>;
|
|
23
|
+
stdout?: ReadableStream<Uint8Array> | null;
|
|
24
|
+
stderr?: ReadableStream<Uint8Array> | null;
|
|
25
|
+
kill?: (signal?: string | number) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* File statistics abstraction
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export interface RuntimeFileStat {
|
|
32
|
+
size: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* HTTP Server configuration
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export interface RuntimeServeConfig {
|
|
39
|
+
port?: number;
|
|
40
|
+
fetch: (req: Request, server?: unknown) => Response | Promise<Response>;
|
|
41
|
+
websocket?: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* HTTP Server interface
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export interface RuntimeServer {
|
|
48
|
+
stop?: () => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Abstraction layer for filesystem and process operations across runtimes.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export interface RuntimeAdapter {
|
|
55
|
+
kind: RuntimeKind;
|
|
56
|
+
spawn(command: string[], options?: RuntimeSpawnOptions): RuntimeProcess;
|
|
57
|
+
writeFile(path: string, data: Blob | Buffer | string | ArrayBuffer | Uint8Array): Promise<void>;
|
|
58
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
59
|
+
readFileAsBlob(path: string): Promise<Blob>;
|
|
60
|
+
exists(path: string): Promise<boolean>;
|
|
61
|
+
stat(path: string): Promise<RuntimeFileStat>;
|
|
62
|
+
deleteFile(path: string): Promise<void>;
|
|
63
|
+
serve(config: RuntimeServeConfig): RuntimeServer;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Abstraction layer for password hashing
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export interface RuntimePasswordAdapter {
|
|
70
|
+
hash(value: string, options: {
|
|
71
|
+
algorithm: 'bcrypt';
|
|
72
|
+
cost?: number;
|
|
73
|
+
} | {
|
|
74
|
+
algorithm: 'argon2id';
|
|
75
|
+
memoryCost?: number;
|
|
76
|
+
timeCost?: number;
|
|
77
|
+
parallelism?: number;
|
|
78
|
+
}): Promise<string>;
|
|
79
|
+
verify(value: string, hashed: string): Promise<boolean>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* SQLite Statement abstraction
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export interface RuntimeSqliteStatement {
|
|
86
|
+
run(params?: Record<string, unknown>): void;
|
|
87
|
+
get(params?: Record<string, unknown>): unknown;
|
|
88
|
+
all(params?: Record<string, unknown>): unknown[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* SQLite Database abstraction
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export interface RuntimeSqliteDatabase {
|
|
95
|
+
run(sql: string): void;
|
|
96
|
+
prepare(sql: string): RuntimeSqliteStatement;
|
|
97
|
+
query(sql: string): RuntimeSqliteStatement;
|
|
98
|
+
close(): void;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get environment variables from the current runtime.
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare const getRuntimeEnv: () => Record<string, string | undefined>;
|
|
105
|
+
/**
|
|
106
|
+
* Get the runtime abstraction adapter (Bun/Node/Deno).
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export declare const getRuntimeAdapter: () => RuntimeAdapter;
|
|
110
|
+
/**
|
|
111
|
+
* Get the password hashing adapter using native optimized implementations if available.
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export declare const getPasswordAdapter: () => RuntimePasswordAdapter;
|
|
115
|
+
/**
|
|
116
|
+
* Create a SQLite database connection using runtime-native drivers.
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
export declare const createSqliteDatabase: (path: string) => Promise<RuntimeSqliteDatabase>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for the Encrypter class.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export interface EncrypterOptions {
|
|
6
|
+
key: string;
|
|
7
|
+
cipher?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Service for OpenSSL encryption/decryption.
|
|
11
|
+
* Compatible with Laravel's encryption format.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class Encrypter {
|
|
15
|
+
private algorithm;
|
|
16
|
+
private key;
|
|
17
|
+
constructor(options: EncrypterOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Encrypt a value
|
|
20
|
+
*/
|
|
21
|
+
encrypt(value: unknown, serialize?: boolean): string;
|
|
22
|
+
/**
|
|
23
|
+
* Decrypt a value
|
|
24
|
+
*/
|
|
25
|
+
decrypt(payload: string, deserialize?: boolean): unknown;
|
|
26
|
+
private hash;
|
|
27
|
+
private validPayload;
|
|
28
|
+
private validMac;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a new key
|
|
31
|
+
*/
|
|
32
|
+
static generateKey(cipher?: string): string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hashing interface
|
|
3
|
+
*/
|
|
4
|
+
export interface Hasher {
|
|
5
|
+
/**
|
|
6
|
+
* Hash the given value
|
|
7
|
+
*/
|
|
8
|
+
make(value: string, options?: Record<string, unknown>): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Check the given plain value against a hash
|
|
11
|
+
*/
|
|
12
|
+
check(value: string, hashedValue: string): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Check if the given hash has been hashed using the given options
|
|
15
|
+
*/
|
|
16
|
+
needsRehash(hashedValue: string, options?: Record<string, unknown>): boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Bun Hasher
|
|
20
|
+
* Uses Bun's native password hashing (bcrypt by default)
|
|
21
|
+
*/
|
|
22
|
+
export declare class BunHasher implements Hasher {
|
|
23
|
+
make(value: string, options?: {
|
|
24
|
+
algorithm?: 'bcrypt' | 'argon2id';
|
|
25
|
+
cost?: number;
|
|
26
|
+
}): Promise<string>;
|
|
27
|
+
check(value: string, hashedValue: string): Promise<boolean>;
|
|
28
|
+
needsRehash(_hashedValue: string, _options?: Record<string, unknown>): boolean;
|
|
29
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PlanetCore } from '../PlanetCore';
|
|
2
|
+
import { TestResponse } from './TestResponse';
|
|
3
|
+
/**
|
|
4
|
+
* HttpTester provides a way to simulate HTTP requests against a PlanetCore instance
|
|
5
|
+
* and returns a TestResponse for assertions.
|
|
6
|
+
*/
|
|
7
|
+
export declare class HttpTester {
|
|
8
|
+
private core;
|
|
9
|
+
private cookies;
|
|
10
|
+
constructor(core: PlanetCore);
|
|
11
|
+
/**
|
|
12
|
+
* Make a GET request
|
|
13
|
+
*/
|
|
14
|
+
get(uri: string, headers?: Record<string, string>): Promise<TestResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Make a POST request
|
|
17
|
+
*/
|
|
18
|
+
post(uri: string, data?: any, headers?: Record<string, string>): Promise<TestResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Make a PUT request
|
|
21
|
+
*/
|
|
22
|
+
put(uri: string, data?: any, headers?: Record<string, string>): Promise<TestResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* Make a PATCH request
|
|
25
|
+
*/
|
|
26
|
+
patch(uri: string, data?: any, headers?: Record<string, string>): Promise<TestResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Make a DELETE request
|
|
29
|
+
*/
|
|
30
|
+
delete(uri: string, data?: any, headers?: Record<string, string>): Promise<TestResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Core call method
|
|
33
|
+
*/
|
|
34
|
+
private call;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Helper to create an HttpTester for a PlanetCore instance
|
|
38
|
+
*/
|
|
39
|
+
export declare function createHttpTester(core: PlanetCore): HttpTester;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TestResponse wraps a standard Fetch Response and provides fluent assertion methods
|
|
3
|
+
* inspired by Laravel's TestResponse.
|
|
4
|
+
*/
|
|
5
|
+
export declare class TestResponse {
|
|
6
|
+
readonly response: Response;
|
|
7
|
+
private _jsonData;
|
|
8
|
+
private _textData;
|
|
9
|
+
constructor(response: Response);
|
|
10
|
+
/**
|
|
11
|
+
* Assert the response status code
|
|
12
|
+
*/
|
|
13
|
+
assertStatus(status: number): this;
|
|
14
|
+
/**
|
|
15
|
+
* Assert that the response has a 200 status code
|
|
16
|
+
*/
|
|
17
|
+
assertOk(): this;
|
|
18
|
+
/**
|
|
19
|
+
* Assert that the response has a 201 status code
|
|
20
|
+
*/
|
|
21
|
+
assertCreated(): this;
|
|
22
|
+
/**
|
|
23
|
+
* Assert that the response has a 404 status code
|
|
24
|
+
*/
|
|
25
|
+
assertNotFound(): this;
|
|
26
|
+
/**
|
|
27
|
+
* Assert that the response has a 403 status code
|
|
28
|
+
*/
|
|
29
|
+
assertForbidden(): this;
|
|
30
|
+
/**
|
|
31
|
+
* Assert that the response has a 401 status code
|
|
32
|
+
*/
|
|
33
|
+
assertUnauthorized(): this;
|
|
34
|
+
/**
|
|
35
|
+
* Assert the response is a redirect
|
|
36
|
+
*/
|
|
37
|
+
assertRedirect(uri?: string): this;
|
|
38
|
+
/**
|
|
39
|
+
* Assert that the response contains the given JSON data.
|
|
40
|
+
*/
|
|
41
|
+
assertJson(data: any): Promise<this>;
|
|
42
|
+
/**
|
|
43
|
+
* Assert that the response contains exactly the given JSON data.
|
|
44
|
+
*/
|
|
45
|
+
assertExactJson(data: any): Promise<this>;
|
|
46
|
+
/**
|
|
47
|
+
* Assert the structure of the JSON response.
|
|
48
|
+
*/
|
|
49
|
+
assertJsonStructure(structure: any): Promise<this>;
|
|
50
|
+
/**
|
|
51
|
+
* Assert that the response contains the given string.
|
|
52
|
+
*/
|
|
53
|
+
assertSee(value: string): Promise<this>;
|
|
54
|
+
/**
|
|
55
|
+
* Assert that the response does not contain the given string.
|
|
56
|
+
*/
|
|
57
|
+
assertDontSee(value: string): Promise<this>;
|
|
58
|
+
/**
|
|
59
|
+
* Assert a header exists and matches value
|
|
60
|
+
*/
|
|
61
|
+
assertHeader(header: string, value: string): this;
|
|
62
|
+
/**
|
|
63
|
+
* Assert a header does not exist
|
|
64
|
+
*/
|
|
65
|
+
assertHeaderMissing(header: string): this;
|
|
66
|
+
/**
|
|
67
|
+
* Get the JSON content
|
|
68
|
+
*/
|
|
69
|
+
getJson(): Promise<any>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the text content
|
|
72
|
+
*/
|
|
73
|
+
getText(): Promise<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Alias for getText for standard expectations if needed
|
|
76
|
+
*/
|
|
77
|
+
get body(): Promise<string>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event system type definitions.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Listener interface.
|
|
6
|
+
*
|
|
7
|
+
* All event listeners must implement this interface.
|
|
8
|
+
*/
|
|
9
|
+
export interface Listener<TEvent extends Event = Event> {
|
|
10
|
+
/**
|
|
11
|
+
* Handle an event.
|
|
12
|
+
* @param event - Event instance
|
|
13
|
+
*/
|
|
14
|
+
handle(event: TEvent): Promise<void> | void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Marker interface for listeners that should be queued.
|
|
18
|
+
*
|
|
19
|
+
* Listeners implementing this interface can be dispatched asynchronously via a queue.
|
|
20
|
+
*/
|
|
21
|
+
export interface ShouldQueue {
|
|
22
|
+
/**
|
|
23
|
+
* Queue name (optional).
|
|
24
|
+
*/
|
|
25
|
+
queue?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Connection name (optional).
|
|
28
|
+
*/
|
|
29
|
+
connection?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Delay before execution (seconds).
|
|
32
|
+
*/
|
|
33
|
+
delay?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Marker interface for events that should be broadcast.
|
|
37
|
+
*
|
|
38
|
+
* Events implementing this interface can be automatically broadcast to clients.
|
|
39
|
+
*/
|
|
40
|
+
export interface ShouldBroadcast {
|
|
41
|
+
/**
|
|
42
|
+
* Define the broadcast channel.
|
|
43
|
+
* @returns Channel name or channel object
|
|
44
|
+
*/
|
|
45
|
+
broadcastOn(): string | Channel;
|
|
46
|
+
/**
|
|
47
|
+
* Define broadcast payload (optional).
|
|
48
|
+
* If omitted, public event properties will be used.
|
|
49
|
+
* @returns Broadcast payload
|
|
50
|
+
*/
|
|
51
|
+
broadcastWith?(): Record<string, unknown>;
|
|
52
|
+
/**
|
|
53
|
+
* Define the broadcast event name (optional).
|
|
54
|
+
* If omitted, the event class name will be used.
|
|
55
|
+
* @returns Event name
|
|
56
|
+
*/
|
|
57
|
+
broadcastAs?(): string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Channel interface.
|
|
61
|
+
*/
|
|
62
|
+
export interface Channel {
|
|
63
|
+
/**
|
|
64
|
+
* Channel name.
|
|
65
|
+
*/
|
|
66
|
+
name: string;
|
|
67
|
+
/**
|
|
68
|
+
* Channel type.
|
|
69
|
+
*/
|
|
70
|
+
type: 'public' | 'private' | 'presence';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Base event class.
|
|
74
|
+
*
|
|
75
|
+
* All events should extend this class.
|
|
76
|
+
*/
|
|
77
|
+
export declare abstract class Event {
|
|
78
|
+
/**
|
|
79
|
+
* Whether this event should be broadcast.
|
|
80
|
+
*/
|
|
81
|
+
shouldBroadcast(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Get broadcast channel.
|
|
84
|
+
*/
|
|
85
|
+
getBroadcastChannel(): string | Channel | null;
|
|
86
|
+
/**
|
|
87
|
+
* Get broadcast payload.
|
|
88
|
+
*/
|
|
89
|
+
getBroadcastData(): Record<string, unknown>;
|
|
90
|
+
/**
|
|
91
|
+
* Get broadcast event name.
|
|
92
|
+
*/
|
|
93
|
+
getBroadcastEventName(): string;
|
|
94
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { GravitoOrbit, PlanetCore } from '@gravito/core';
|
|
2
|
+
import { WebhookReceiver } from './receive/WebhookReceiver';
|
|
3
|
+
import { KeyRotationManager } from './rotation/KeyRotationManager';
|
|
4
|
+
import { WebhookDispatcher } from './send/WebhookDispatcher';
|
|
5
|
+
import type { EchoConfig, ProviderKeyEntry } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* OrbitEcho is the official webhook orchestration module for the Gravito ecosystem.
|
|
8
|
+
*
|
|
9
|
+
* It serves as a comprehensive hub for managing the entire webhook lifecycle,
|
|
10
|
+
* including secure reception, signature verification across multiple providers,
|
|
11
|
+
* persistent storage for auditing, and reliable outgoing dispatch with
|
|
12
|
+
* exponential backoff and circuit breaking.
|
|
13
|
+
*
|
|
14
|
+
* @example Basic integration with PlanetCore
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { PlanetCore } from '@gravito/core';
|
|
17
|
+
* import { OrbitEcho } from '@gravito/echo';
|
|
18
|
+
*
|
|
19
|
+
* const core = new PlanetCore();
|
|
20
|
+
* const echo = new OrbitEcho({
|
|
21
|
+
* providers: {
|
|
22
|
+
* stripe: { name: 'stripe', secret: process.env.STRIPE_SECRET }
|
|
23
|
+
* },
|
|
24
|
+
* dispatcher: {
|
|
25
|
+
* secret: process.env.APP_WEBHOOK_SECRET
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* core.install(echo);
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare class OrbitEcho implements GravitoOrbit {
|
|
35
|
+
private receiver;
|
|
36
|
+
private dispatcher?;
|
|
37
|
+
private echoConfig;
|
|
38
|
+
private keyRotationManager?;
|
|
39
|
+
/**
|
|
40
|
+
* Constructs a new OrbitEcho instance with the specified configuration.
|
|
41
|
+
*
|
|
42
|
+
* This constructor initializes the core receiver component, sets up key rotation
|
|
43
|
+
* orchestration if enabled, registers defined providers, and connects the
|
|
44
|
+
* observability stack (metrics, tracing, logging).
|
|
45
|
+
*
|
|
46
|
+
* @param config - The global configuration defining providers, dispatchers, and infrastructure.
|
|
47
|
+
*/
|
|
48
|
+
constructor(config?: EchoConfig);
|
|
49
|
+
/**
|
|
50
|
+
* Integrates the Echo module into the Gravito application lifecycle.
|
|
51
|
+
*
|
|
52
|
+
* This method performs the following setup tasks:
|
|
53
|
+
* 1. Installs request buffering middleware (if enabled) to preserve raw bodies.
|
|
54
|
+
* 2. Binds Echo components to the service container (`echo`, `echo.receiver`).
|
|
55
|
+
* 3. Injects the Echo instance into the request context for easy access in handlers.
|
|
56
|
+
*
|
|
57
|
+
* @param core - The PlanetCore instance managing the application.
|
|
58
|
+
* @throws {Error} If the core adapter is missing or improperly configured.
|
|
59
|
+
*/
|
|
60
|
+
install(core: PlanetCore): void;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the underlying receiver instance for manual webhook processing.
|
|
63
|
+
*
|
|
64
|
+
* Use this when you need fine-grained control over how incoming webhooks
|
|
65
|
+
* are routed or verified outside of the standard middleware flow.
|
|
66
|
+
*
|
|
67
|
+
* @returns The active WebhookReceiver instance.
|
|
68
|
+
*/
|
|
69
|
+
getReceiver(): WebhookReceiver;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves the dispatcher instance for sending outgoing webhooks.
|
|
72
|
+
*
|
|
73
|
+
* @returns The configured WebhookDispatcher, or undefined if dispatch is disabled.
|
|
74
|
+
*/
|
|
75
|
+
getDispatcher(): WebhookDispatcher | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Accesses the active configuration used by this OrbitEcho instance.
|
|
78
|
+
*
|
|
79
|
+
* @returns The immutable EchoConfig object.
|
|
80
|
+
*/
|
|
81
|
+
getConfig(): EchoConfig;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the key rotation manager responsible for secret lifecycle.
|
|
84
|
+
*
|
|
85
|
+
* @returns The manager instance, or undefined if key rotation is disabled.
|
|
86
|
+
*/
|
|
87
|
+
getKeyRotationManager(): KeyRotationManager | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Initiates a zero-downtime primary key rotation for a specific provider.
|
|
90
|
+
*
|
|
91
|
+
* This method promotes a new key to primary status while maintaining valid old keys
|
|
92
|
+
* for a grace period, ensuring that webhooks signed with either key are accepted
|
|
93
|
+
* during the transition.
|
|
94
|
+
*
|
|
95
|
+
* @param providerName - The identifier of the provider to update.
|
|
96
|
+
* @param newKey - Metadata and value for the replacement key.
|
|
97
|
+
* @throws {Error} If key rotation is not enabled in the global configuration.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* await echo.rotateProviderKey('stripe', {
|
|
102
|
+
* key: 'whsec_new_secret',
|
|
103
|
+
* version: 'v2',
|
|
104
|
+
* activeFrom: new Date()
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
rotateProviderKey(providerName: string, newKey: Omit<ProviderKeyEntry, 'isPrimary'>): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
declare module '@gravito/core' {
|
|
111
|
+
interface GravitoVariables {
|
|
112
|
+
/** Webhook receiver and dispatcher */
|
|
113
|
+
echo?: OrbitEcho;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { IncomingWebhookRecord, OutgoingWebhookRecord } from '../storage/WebhookStore';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for a Dead Letter Queue (DLQ) implementation.
|
|
4
|
+
*
|
|
5
|
+
* A DLQ serves as a safety net for webhook events that have permanently failed
|
|
6
|
+
* all processing or delivery attempts. It enables manual inspection, diagnostic
|
|
7
|
+
* analysis, and eventual re-processing of high-value events that would otherwise
|
|
8
|
+
* be lost due to transient or permanent failures.
|
|
9
|
+
*
|
|
10
|
+
* @example Inspected failed events
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const dlq: DeadLetterQueue = new MyPersistentDlq();
|
|
13
|
+
*
|
|
14
|
+
* // Retrieve recent failures for manual triage
|
|
15
|
+
* const failedEvents = await dlq.peek(10);
|
|
16
|
+
* for (const event of failedEvents) {
|
|
17
|
+
* console.log(`Event ${event.id} failed after ${event.retryCount} attempts: ${event.failureReason}`);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export interface DeadLetterQueue {
|
|
24
|
+
/**
|
|
25
|
+
* Appends a permanently failed event to the queue for later inspection.
|
|
26
|
+
*
|
|
27
|
+
* @param event - The dead letter event metadata and original record.
|
|
28
|
+
* @returns A promise resolving to a unique identifier for the event within the queue.
|
|
29
|
+
* @throws {Error} If the underlying storage fails to persist the event.
|
|
30
|
+
*/
|
|
31
|
+
enqueue(event: DeadLetterEvent): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves a snapshot of failed events from the queue without removing them.
|
|
34
|
+
*
|
|
35
|
+
* @param limit - Maximum number of events to retrieve (ordered by failure time).
|
|
36
|
+
* @returns A collection of dead letter events.
|
|
37
|
+
*/
|
|
38
|
+
peek(limit?: number): Promise<DeadLetterEvent[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Permanently removes an event from the queue after successful manual resolution.
|
|
41
|
+
*
|
|
42
|
+
* @param id - The unique identifier assigned during the `enqueue` process.
|
|
43
|
+
* @throws {Error} If the event ID is invalid or not found in the queue.
|
|
44
|
+
*/
|
|
45
|
+
dequeue(id: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Calculates the total number of events currently residing in the queue.
|
|
48
|
+
*
|
|
49
|
+
* @returns The total count of dead letter events.
|
|
50
|
+
*/
|
|
51
|
+
size(): Promise<number>;
|
|
52
|
+
/**
|
|
53
|
+
* Removes all events from the queue, resetting it to an empty state.
|
|
54
|
+
*/
|
|
55
|
+
clear(): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Metadata and payload for a failed webhook event stored in the Dead Letter Queue.
|
|
59
|
+
*
|
|
60
|
+
* This structure captures the complete context of a failure, including the original
|
|
61
|
+
* data and the diagnostic reason for the final failure.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export interface DeadLetterEvent {
|
|
66
|
+
/**
|
|
67
|
+
* A unique identifier for the entry within the DLQ storage.
|
|
68
|
+
*/
|
|
69
|
+
id?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Indicates whether the failure occurred during reception or dispatch.
|
|
72
|
+
*/
|
|
73
|
+
type: 'incoming' | 'outgoing';
|
|
74
|
+
/**
|
|
75
|
+
* The complete original record of the webhook at the moment of failure.
|
|
76
|
+
*/
|
|
77
|
+
originalEvent: IncomingWebhookRecord | OutgoingWebhookRecord;
|
|
78
|
+
/**
|
|
79
|
+
* A descriptive diagnostic message explaining why the event was sent to the DLQ.
|
|
80
|
+
*/
|
|
81
|
+
failureReason: string;
|
|
82
|
+
/**
|
|
83
|
+
* The exact timestamp when the event reached its maximum retry limit or terminal error.
|
|
84
|
+
*/
|
|
85
|
+
failedAt: Date;
|
|
86
|
+
/**
|
|
87
|
+
* The total number of automated attempts made before giving up on the event.
|
|
88
|
+
*/
|
|
89
|
+
retryCount: number;
|
|
90
|
+
/**
|
|
91
|
+
* The timestamp of the final attempted processing or delivery action.
|
|
92
|
+
*/
|
|
93
|
+
lastRetryAt?: Date;
|
|
94
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { DeadLetterEvent, DeadLetterQueue } from './DeadLetterQueue';
|
|
2
|
+
/**
|
|
3
|
+
* An in-memory implementation of {@link DeadLetterQueue}.
|
|
4
|
+
* Suitable for development, testing, or small-scale applications where persistence is not required.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const dlq = new MemoryDeadLetterQueue();
|
|
9
|
+
* await dlq.enqueue(failedEvent);
|
|
10
|
+
* const size = await dlq.size();
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class MemoryDeadLetterQueue implements DeadLetterQueue {
|
|
14
|
+
private queue;
|
|
15
|
+
/**
|
|
16
|
+
* Stores the event in an internal Map.
|
|
17
|
+
* Generates a UUID if the event does not have an ID.
|
|
18
|
+
*/
|
|
19
|
+
enqueue(event: DeadLetterEvent): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Returns events sorted by failure timestamp.
|
|
22
|
+
*/
|
|
23
|
+
peek(limit?: number): Promise<DeadLetterEvent[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Removes the event from the internal Map.
|
|
26
|
+
*/
|
|
27
|
+
dequeue(id: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the number of items in the internal Map.
|
|
30
|
+
*/
|
|
31
|
+
size(): Promise<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Clears the internal Map.
|
|
34
|
+
*/
|
|
35
|
+
clear(): Promise<void>;
|
|
36
|
+
}
|