@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
package/README.md
CHANGED
|
@@ -2,15 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
> 📡 Enterprise-grade webhook handling for Gravito. Secure receiving and reliable sending.
|
|
4
4
|
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- **Request Buffering
|
|
12
|
-
- **
|
|
13
|
-
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- 🪐 **Galaxy-Ready Gateway**: The primary entry/exit point for external asynchronous communication.
|
|
8
|
+
- 🛡️ **Secure Receiving**: HMAC signature verification, timestamp validation, and multi-key support.
|
|
9
|
+
- 🔄 **Boundary Reliability**: Built-in **Circuit Breaker**, **Retry Scheduler**, and **DLQ** for outgoing hooks.
|
|
10
|
+
- 📦 **Built-in Providers**: Native support for Stripe, GitHub, Shopify, Slack, and more.
|
|
11
|
+
- ⚡ **Request Buffering**: Prevents signature failures by handling raw bodies before framework parsing.
|
|
12
|
+
- 🔐 **Key Rotation**: Seamless, zero-downtime secret rotation for enterprise security.
|
|
13
|
+
|
|
14
|
+
## 🌌 Role in Galaxy Architecture
|
|
15
|
+
|
|
16
|
+
In the **Gravito Galaxy Architecture**, Echo acts as the **Deep Space Radar Layer (Boundary Communication)**.
|
|
17
|
+
|
|
18
|
+
- **External Stimuli**: Converts external world signals (Webhooks from Stripe, etc.) into internal `Signal` events that Satellites can react to.
|
|
19
|
+
- **Outbound Pulse**: Provides a reliable way for internal Galaxy state changes to be broadcasted to the outside world (e.g., notifying a 3rd party logistics provider).
|
|
20
|
+
- **Isolation Barrier**: Protects the core Galaxy from external failure ripples by utilizing circuit breakers on outgoing requests.
|
|
21
|
+
|
|
22
|
+
```mermaid
|
|
23
|
+
graph LR
|
|
24
|
+
World([External Service]) -- Webhook --> Echo{Echo Orbit}
|
|
25
|
+
Echo -->|Verified Signal| Sat[Satellite: Payment]
|
|
26
|
+
Sat -->|Internal Event| Stream[Stream Orbit]
|
|
27
|
+
Echo -.->|Circuit Breaker| World
|
|
28
|
+
```
|
|
14
29
|
|
|
15
30
|
## Installation
|
|
16
31
|
|
package/dist/OrbitEcho.d.ts
CHANGED
|
@@ -1,99 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
* @fileoverview OrbitEcho Module
|
|
3
|
-
*
|
|
4
|
-
* Gravito integration for webhook handling.
|
|
5
|
-
*
|
|
6
|
-
* @module @gravito/echo
|
|
7
|
-
*/
|
|
1
|
+
import type { GravitoOrbit, PlanetCore } from '@gravito/core';
|
|
8
2
|
import { WebhookReceiver } from './receive/WebhookReceiver';
|
|
3
|
+
import { KeyRotationManager } from './rotation/KeyRotationManager';
|
|
9
4
|
import { WebhookDispatcher } from './send/WebhookDispatcher';
|
|
10
|
-
import type { EchoConfig } from './types';
|
|
5
|
+
import type { EchoConfig, ProviderKeyEntry } from './types';
|
|
11
6
|
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
interface ModuleConfig {
|
|
15
|
-
singleton?: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Minimal PlanetCore interface
|
|
19
|
-
*/
|
|
20
|
-
interface PlanetCore {
|
|
21
|
-
container: {
|
|
22
|
-
instance<T>(key: string, value: T): void;
|
|
23
|
-
};
|
|
24
|
-
hooks: {
|
|
25
|
-
addAction(hook: string, callback: () => void | Promise<void>): void;
|
|
26
|
-
};
|
|
27
|
-
adapter: {
|
|
28
|
-
use(middleware: unknown): void;
|
|
29
|
-
};
|
|
30
|
-
router: {
|
|
31
|
-
post(path: string, handler: unknown): void;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* OrbitEcho - Gravito Webhook Module
|
|
7
|
+
* OrbitEcho is the official webhook orchestration module for the Gravito ecosystem.
|
|
36
8
|
*
|
|
37
|
-
*
|
|
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.
|
|
38
13
|
*
|
|
39
|
-
* @example
|
|
14
|
+
* @example Basic integration with PlanetCore
|
|
40
15
|
* ```typescript
|
|
41
|
-
*
|
|
16
|
+
* import { PlanetCore } from '@gravito/core';
|
|
17
|
+
* import { OrbitEcho } from '@gravito/echo';
|
|
42
18
|
*
|
|
43
|
-
* core
|
|
19
|
+
* const core = new PlanetCore();
|
|
20
|
+
* const echo = new OrbitEcho({
|
|
44
21
|
* providers: {
|
|
45
|
-
* stripe: { name: 'stripe', secret: process.env.
|
|
46
|
-
* github: { name: 'github', secret: process.env.GITHUB_WEBHOOK_SECRET! }
|
|
22
|
+
* stripe: { name: 'stripe', secret: process.env.STRIPE_SECRET }
|
|
47
23
|
* },
|
|
48
24
|
* dispatcher: {
|
|
49
|
-
* secret: process.env.
|
|
25
|
+
* secret: process.env.APP_WEBHOOK_SECRET
|
|
50
26
|
* }
|
|
51
|
-
* })
|
|
27
|
+
* });
|
|
52
28
|
*
|
|
53
|
-
*
|
|
54
|
-
* const receiver = core.container.make<WebhookReceiver>('echo.receiver')
|
|
55
|
-
* receiver.on('stripe', 'payment_intent.succeeded', async (event) => {
|
|
56
|
-
* console.log('Payment received:', event.payload)
|
|
57
|
-
* })
|
|
29
|
+
* core.install(echo);
|
|
58
30
|
* ```
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
59
33
|
*/
|
|
60
|
-
export declare class OrbitEcho {
|
|
61
|
-
static config: ModuleConfig;
|
|
34
|
+
export declare class OrbitEcho implements GravitoOrbit {
|
|
62
35
|
private receiver;
|
|
63
36
|
private dispatcher?;
|
|
64
37
|
private echoConfig;
|
|
38
|
+
private keyRotationManager?;
|
|
65
39
|
/**
|
|
66
|
-
*
|
|
40
|
+
* Constructs a new OrbitEcho instance with the specified configuration.
|
|
67
41
|
*
|
|
68
|
-
*
|
|
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.
|
|
69
47
|
*/
|
|
70
48
|
constructor(config?: EchoConfig);
|
|
71
49
|
/**
|
|
72
|
-
*
|
|
50
|
+
* Integrates the Echo module into the Gravito application lifecycle.
|
|
73
51
|
*
|
|
74
|
-
*
|
|
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.
|
|
75
56
|
*
|
|
76
|
-
* @param core - The PlanetCore instance.
|
|
57
|
+
* @param core - The PlanetCore instance managing the application.
|
|
58
|
+
* @throws {Error} If the core adapter is missing or improperly configured.
|
|
77
59
|
*/
|
|
78
60
|
install(core: PlanetCore): void;
|
|
79
61
|
/**
|
|
80
|
-
*
|
|
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.
|
|
81
66
|
*
|
|
82
|
-
* @returns The WebhookReceiver instance.
|
|
67
|
+
* @returns The active WebhookReceiver instance.
|
|
83
68
|
*/
|
|
84
69
|
getReceiver(): WebhookReceiver;
|
|
85
70
|
/**
|
|
86
|
-
*
|
|
71
|
+
* Retrieves the dispatcher instance for sending outgoing webhooks.
|
|
87
72
|
*
|
|
88
|
-
* @returns The WebhookDispatcher
|
|
73
|
+
* @returns The configured WebhookDispatcher, or undefined if dispatch is disabled.
|
|
89
74
|
*/
|
|
90
75
|
getDispatcher(): WebhookDispatcher | undefined;
|
|
91
76
|
/**
|
|
92
|
-
*
|
|
77
|
+
* Accesses the active configuration used by this OrbitEcho instance.
|
|
93
78
|
*
|
|
94
|
-
* @returns The EchoConfig object.
|
|
79
|
+
* @returns The immutable EchoConfig object.
|
|
95
80
|
*/
|
|
96
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
|
+
}
|
|
97
115
|
}
|
|
98
|
-
export {};
|
|
99
|
-
//# sourceMappingURL=OrbitEcho.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Echo error types
|
|
3
|
+
*
|
|
4
|
+
* @module @gravito/echo/errors
|
|
5
|
+
*/
|
|
6
|
+
import { InfrastructureException, type InfrastructureExceptionOptions } from '@gravito/core';
|
|
7
|
+
import type { EchoErrorCode } from './codes';
|
|
8
|
+
/**
|
|
9
|
+
* Base error class for Echo module.
|
|
10
|
+
*
|
|
11
|
+
* Provides structured error handling with error codes and messages.
|
|
12
|
+
* Extends InfrastructureException for unified error handling across Gravito.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* throw new EchoError('echo.unknown_provider', 'Unknown provider type: stripe')
|
|
17
|
+
* ```
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare class EchoError extends InfrastructureException {
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new EchoError instance.
|
|
23
|
+
*
|
|
24
|
+
* @param code - The error code.
|
|
25
|
+
* @param message - The error message.
|
|
26
|
+
* @param options - Optional infrastructure exception options.
|
|
27
|
+
*/
|
|
28
|
+
constructor(code: EchoErrorCode, message: string, options?: InfrastructureExceptionOptions);
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Echo error codes
|
|
3
|
+
*
|
|
4
|
+
* Namespaced error codes for the Echo webhook module.
|
|
5
|
+
*
|
|
6
|
+
* @module @gravito/echo/errors
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Error codes for Echo module operations.
|
|
10
|
+
* Follows dot-separated namespace convention.
|
|
11
|
+
*/
|
|
12
|
+
export declare const EchoErrorCodes: {
|
|
13
|
+
readonly UNKNOWN_PROVIDER: "echo.unknown_provider";
|
|
14
|
+
readonly KEY_ROTATION_NOT_SET: "echo.key_rotation_not_set";
|
|
15
|
+
readonly NO_PRIMARY_KEY: "echo.no_primary_key";
|
|
16
|
+
readonly KEY_ROTATION_NOT_ENABLED: "echo.key_rotation_not_enabled";
|
|
17
|
+
readonly NO_DELIVERY_ATTEMPTS: "echo.no_delivery_attempts";
|
|
18
|
+
readonly INVALID_CONFIG: "echo.invalid_config";
|
|
19
|
+
};
|
|
20
|
+
export type EchoErrorCode = (typeof EchoErrorCodes)[keyof typeof EchoErrorCodes];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,49 +1,67 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
2
|
+
* @fileoverview \@gravito/echo - Enterprise Webhook Orchestration
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Echo provides a secure, reliable, and observable layer for handling webhooks
|
|
5
|
+
* in Gravito applications. It standardizes incoming webhook reception with
|
|
6
|
+
* signature verification and dynamic key rotation, while ensuring reliable
|
|
7
|
+
* outgoing delivery via exponential backoff and circuit breaking.
|
|
5
8
|
*
|
|
6
|
-
* @example Receiving webhooks
|
|
9
|
+
* @example Receiving webhooks from Stripe
|
|
7
10
|
* ```typescript
|
|
8
11
|
* import { OrbitEcho, WebhookReceiver } from '@gravito/echo'
|
|
9
12
|
*
|
|
10
13
|
* const core = new PlanetCore()
|
|
11
|
-
*
|
|
12
14
|
* core.install(new OrbitEcho({
|
|
13
15
|
* providers: {
|
|
14
|
-
* stripe: { name: 'stripe', secret: process.env.
|
|
16
|
+
* stripe: { name: 'stripe', secret: process.env.STRIPE_SECRET! }
|
|
15
17
|
* }
|
|
16
18
|
* }))
|
|
17
19
|
*
|
|
18
20
|
* const receiver = core.container.make<WebhookReceiver>('echo.receiver')
|
|
19
21
|
* receiver.on('stripe', 'payment_intent.succeeded', async (event) => {
|
|
20
|
-
*
|
|
22
|
+
* // Securely process validated payment
|
|
21
23
|
* })
|
|
22
24
|
* ```
|
|
23
25
|
*
|
|
24
|
-
* @example
|
|
26
|
+
* @example Dispatching reliable outgoing webhooks
|
|
25
27
|
* ```typescript
|
|
26
28
|
* import { WebhookDispatcher } from '@gravito/echo'
|
|
27
29
|
*
|
|
28
|
-
* const dispatcher = new WebhookDispatcher({
|
|
29
|
-
* secret: 'my-secret'
|
|
30
|
-
* })
|
|
31
|
-
*
|
|
30
|
+
* const dispatcher = new WebhookDispatcher({ secret: 'app-secret' })
|
|
32
31
|
* await dispatcher.dispatch({
|
|
33
|
-
* url: 'https://
|
|
32
|
+
* url: 'https://consumer.com/hook',
|
|
34
33
|
* event: 'order.created',
|
|
35
|
-
* data: {
|
|
34
|
+
* data: { id: 123 }
|
|
36
35
|
* })
|
|
37
36
|
* ```
|
|
38
37
|
*
|
|
39
38
|
* @module @gravito/echo
|
|
40
39
|
*/
|
|
40
|
+
export type { DeadLetterEvent, DeadLetterQueue } from './dlq/DeadLetterQueue';
|
|
41
|
+
export { EchoError } from './errors/EchoError';
|
|
42
|
+
export { EchoErrorCodes } from './errors/codes';
|
|
43
|
+
export type { EchoErrorCode } from './errors/codes';
|
|
44
|
+
export { MemoryDeadLetterQueue } from './dlq/MemoryDeadLetterQueue';
|
|
45
|
+
export { createRequestBufferMiddleware, RequestBufferMiddleware } from './middleware';
|
|
41
46
|
export { OrbitEcho } from './OrbitEcho';
|
|
47
|
+
export type { EchoLogEvent, EchoLogger } from './observability/logging';
|
|
48
|
+
export { ConsoleEchoLogger } from './observability/logging';
|
|
49
|
+
export type { MetricsProvider, WebhookMetricLabels } from './observability/metrics';
|
|
50
|
+
export { EchoMetrics, NoopMetricsProvider, PrometheusMetricsProvider, } from './observability/metrics';
|
|
51
|
+
export type { Span, SpanOptions, Tracer } from './observability/tracing';
|
|
52
|
+
export { NoopSpan, NoopTracer, SpanStatusCode } from './observability/tracing';
|
|
53
|
+
export { BaseProvider, type ProviderOptions } from './providers/base/BaseProvider';
|
|
42
54
|
export { GenericProvider } from './providers/GenericProvider';
|
|
43
55
|
export { GitHubProvider } from './providers/GitHubProvider';
|
|
56
|
+
export { LinearProvider } from './providers/LinearProvider';
|
|
57
|
+
export { PaddleProvider } from './providers/PaddleProvider';
|
|
58
|
+
export { ShopifyProvider } from './providers/ShopifyProvider';
|
|
59
|
+
export { SlackProvider } from './providers/SlackProvider';
|
|
44
60
|
export { StripeProvider } from './providers/StripeProvider';
|
|
61
|
+
export { TwilioProvider } from './providers/TwilioProvider';
|
|
45
62
|
export { computeHmacSha1, computeHmacSha256, parseStripeSignature, timingSafeEqual, validateTimestamp, } from './receive/SignatureValidator';
|
|
46
63
|
export { WebhookReceiver } from './receive/WebhookReceiver';
|
|
47
|
-
export {
|
|
48
|
-
export
|
|
49
|
-
|
|
64
|
+
export { WebhookReplayService } from './replay/WebhookReplayService';
|
|
65
|
+
export { CircuitBreaker } from './resilience';
|
|
66
|
+
export { KeyRotationManager } from './rotation';
|
|
67
|
+
export type { BufferedRequest, CircuitBreakerConfig, CircuitBreakerMetrics, CircuitBreakerState, EchoConfig, EchoObservabilityConfig, KeyRotationConfig, ProviderKeyEntry, ReplayOptions, ReplayResult, RequestBufferConfig, RetryConfig, WebhookDeliveryResult, WebhookDispatcherConfig, WebhookEvent, WebhookHandler, WebhookPayload, WebhookProvider, WebhookProviderConfig, WebhookProviderConfigWithRotation, WebhookVerificationResult, } from './types';
|