@gravito/echo 3.0.1 → 3.1.1
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 +348 -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 +41 -0
- package/dist/atlas/src/connection/Connection.d.ts +112 -0
- package/dist/atlas/src/connection/ConnectionManager.d.ts +180 -0
- package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +54 -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 +79 -0
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +96 -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 +79 -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 +33 -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/Repository.d.ts +247 -0
- package/dist/atlas/src/orm/index.d.ts +6 -0
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
- package/dist/atlas/src/orm/model/Model.d.ts +458 -0
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +150 -0
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +92 -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 +138 -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 +124 -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/pool/AdaptivePoolManager.d.ts +98 -0
- package/dist/atlas/src/pool/PoolHealthChecker.d.ts +91 -0
- package/dist/atlas/src/pool/PoolStrategy.d.ts +129 -0
- package/dist/atlas/src/pool/PoolWarmer.d.ts +92 -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 +643 -0
- package/dist/atlas/src/query/RelationshipResolver.d.ts +23 -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/MigrationGenerator.d.ts +45 -0
- package/dist/atlas/src/schema/Schema.d.ts +131 -0
- package/dist/atlas/src/schema/SchemaDiff.d.ts +73 -0
- package/dist/atlas/src/schema/TypeGenerator.d.ts +57 -0
- package/dist/atlas/src/schema/TypeWriter.d.ts +42 -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/sharding/ShardingManager.d.ts +59 -0
- package/dist/atlas/src/types/index.d.ts +1182 -0
- package/dist/atlas/src/utils/CursorEncoding.d.ts +63 -0
- package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
- package/dist/core/src/Application.d.ts +43 -17
- package/dist/core/src/CommandKernel.d.ts +33 -0
- package/dist/core/src/ConfigManager.d.ts +39 -0
- package/dist/core/src/Container/RequestScopeManager.d.ts +62 -0
- package/dist/core/src/Container/RequestScopeMetrics.d.ts +144 -0
- package/dist/core/src/Container.d.ts +123 -14
- package/dist/core/src/ErrorHandler.d.ts +3 -0
- package/dist/core/src/HookManager.d.ts +517 -8
- package/dist/core/src/PlanetCore.d.ts +141 -7
- package/dist/core/src/RequestContext.d.ts +97 -0
- package/dist/core/src/Router.d.ts +41 -7
- package/dist/core/src/ServiceProvider.d.ts +36 -8
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +1 -0
- package/dist/core/src/adapters/PhotonAdapter.d.ts +5 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +4 -0
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +1 -0
- package/dist/core/src/adapters/types.d.ts +39 -0
- package/dist/core/src/cli/queue-commands.d.ts +6 -0
- package/dist/core/src/engine/AOTRouter.d.ts +7 -12
- package/dist/core/src/engine/FastContext.d.ts +27 -2
- package/dist/core/src/engine/Gravito.d.ts +1 -2
- package/dist/core/src/engine/MinimalContext.d.ts +25 -2
- package/dist/core/src/engine/types.d.ts +9 -1
- package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +126 -0
- package/dist/core/src/events/BackpressureManager.d.ts +215 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +219 -0
- package/dist/core/src/events/EventBackend.d.ts +12 -0
- package/dist/core/src/events/EventOptions.d.ts +204 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +301 -0
- package/dist/core/src/events/FlowControlStrategy.d.ts +109 -0
- package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
- package/dist/core/src/events/MessageQueueBridge.d.ts +184 -0
- package/dist/core/src/events/PriorityEscalationManager.d.ts +82 -0
- package/dist/core/src/events/RetryScheduler.d.ts +104 -0
- package/dist/core/src/events/WorkerPool.d.ts +98 -0
- package/dist/core/src/events/WorkerPoolConfig.d.ts +153 -0
- package/dist/core/src/events/WorkerPoolMetrics.d.ts +65 -0
- package/dist/core/src/events/aggregation/AggregationWindow.d.ts +77 -0
- package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +135 -0
- package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +108 -0
- package/dist/core/src/events/aggregation/EventBatcher.d.ts +99 -0
- package/dist/core/src/events/aggregation/types.d.ts +117 -0
- package/dist/core/src/events/index.d.ts +25 -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 +332 -0
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
- package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +76 -0
- package/dist/core/src/events/observability/index.d.ts +24 -0
- package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
- package/dist/core/src/events/types.d.ts +134 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
- package/dist/core/src/exceptions/index.d.ts +1 -0
- package/dist/core/src/health/HealthProvider.d.ts +67 -0
- package/dist/core/src/http/cookie.d.ts +29 -0
- package/dist/core/src/http/types.d.ts +40 -0
- package/dist/core/src/index.d.ts +26 -4
- 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/observability/Metrics.d.ts +244 -0
- package/dist/core/src/observability/QueueDashboard.d.ts +136 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +350 -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/echo/src/OrbitEcho.d.ts +71 -16
- 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 +31 -15
- 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 +37 -18
- package/dist/echo/src/providers/GitHubProvider.d.ts +21 -12
- 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 +20 -12
- 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 -3
- package/dist/echo/src/receive/SignatureValidator.d.ts +33 -0
- package/dist/echo/src/receive/WebhookReceiver.d.ts +139 -21
- 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 +159 -15
- 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 +656 -64
- package/dist/index.js +1327 -189
- package/dist/index.js.map +28 -10
- package/dist/monitor/src/MonitorOrbit.d.ts +43 -0
- package/dist/monitor/src/config.d.ts +106 -0
- package/dist/monitor/src/health/HealthController.d.ts +28 -0
- package/dist/monitor/src/health/HealthRegistry.d.ts +80 -0
- package/dist/monitor/src/health/index.d.ts +36 -0
- package/dist/monitor/src/index.d.ts +13 -0
- package/dist/monitor/src/metrics/MetricsController.d.ts +22 -0
- package/dist/monitor/src/metrics/MetricsRegistry.d.ts +136 -0
- package/dist/monitor/src/metrics/index.d.ts +11 -0
- package/dist/monitor/src/tracing/TracingManager.d.ts +97 -0
- package/dist/monitor/src/tracing/index.d.ts +10 -0
- package/dist/photon/src/index.d.ts +74 -5
- package/dist/photon/src/middleware/binary.d.ts +12 -15
- package/dist/photon/src/middleware/htmx.d.ts +39 -0
- package/dist/photon/src/middleware/ratelimit-redis.d.ts +50 -0
- package/dist/photon/src/middleware/ratelimit.d.ts +161 -0
- package/dist/photon/src/openapi.d.ts +19 -0
- package/package.json +8 -6
|
@@ -82,6 +82,47 @@ export type GravitoConfig = {
|
|
|
82
82
|
* @since 2.0.0
|
|
83
83
|
*/
|
|
84
84
|
container?: Container;
|
|
85
|
+
/**
|
|
86
|
+
* Observability configuration for event system.
|
|
87
|
+
* @since 2.1.0
|
|
88
|
+
*/
|
|
89
|
+
observability?: {
|
|
90
|
+
/**
|
|
91
|
+
* Enable event system observability (metrics, tracing).
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
enabled?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Enable OpenTelemetry distributed tracing.
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
tracing?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Prefix for metric names.
|
|
102
|
+
* @default 'gravito_event_'
|
|
103
|
+
*/
|
|
104
|
+
metricsPrefix?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Prometheus metrics configuration.
|
|
107
|
+
*/
|
|
108
|
+
prometheus?: {
|
|
109
|
+
/**
|
|
110
|
+
* Enable Prometheus metrics endpoint.
|
|
111
|
+
* @default true
|
|
112
|
+
*/
|
|
113
|
+
enabled?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Port for Prometheus metrics endpoint.
|
|
116
|
+
* @default 9090
|
|
117
|
+
*/
|
|
118
|
+
port?: number;
|
|
119
|
+
/**
|
|
120
|
+
* Endpoint path for metrics.
|
|
121
|
+
* @default '/metrics'
|
|
122
|
+
*/
|
|
123
|
+
endpoint?: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
85
126
|
};
|
|
86
127
|
import { Router } from './Router';
|
|
87
128
|
import { Encrypter } from './security/Encrypter';
|
|
@@ -122,8 +163,25 @@ export declare class PlanetCore {
|
|
|
122
163
|
private providers;
|
|
123
164
|
private deferredProviders;
|
|
124
165
|
private bootedProviders;
|
|
166
|
+
private isShuttingDown;
|
|
167
|
+
/**
|
|
168
|
+
* Initialize observability asynchronously (metrics, tracing, Prometheus).
|
|
169
|
+
* This is called from constructor but doesn't block initialization.
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
private initializeObservabilityAsync;
|
|
125
174
|
/**
|
|
126
|
-
*
|
|
175
|
+
* Initialize Prometheus metrics asynchronously.
|
|
176
|
+
*
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
179
|
+
private initializePrometheusAsync;
|
|
180
|
+
/**
|
|
181
|
+
* Register a service provider to the core.
|
|
182
|
+
*
|
|
183
|
+
* Service providers are the central place to configure your application.
|
|
184
|
+
* They bind services to the container and bootstrap application features.
|
|
127
185
|
*
|
|
128
186
|
* @param provider - The ServiceProvider instance to register.
|
|
129
187
|
* @returns The PlanetCore instance for chaining.
|
|
@@ -137,14 +195,49 @@ export declare class PlanetCore {
|
|
|
137
195
|
/**
|
|
138
196
|
* Bootstrap the application by registering and booting providers.
|
|
139
197
|
*
|
|
140
|
-
* This method
|
|
141
|
-
*
|
|
198
|
+
* This method orchestrates the two-phase startup sequence:
|
|
199
|
+
* 1. Registration: Calls `register()` on all providers to bind services.
|
|
200
|
+
* 2. Booting: Calls `boot()` on all providers once all bindings are ready.
|
|
142
201
|
*
|
|
143
|
-
*
|
|
202
|
+
* This method must be called before the application starts handling requests.
|
|
144
203
|
*
|
|
145
204
|
* @returns Promise that resolves when bootstrapping is complete.
|
|
205
|
+
* @throws Error if a deferred provider has an asynchronous register method.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* await core.bootstrap();
|
|
210
|
+
* ```
|
|
146
211
|
*/
|
|
147
212
|
bootstrap(): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Called when the application is ready to accept requests.
|
|
215
|
+
*
|
|
216
|
+
* Invokes the `onReady()` lifecycle hook on all providers.
|
|
217
|
+
* Called automatically at the end of `bootstrap()`.
|
|
218
|
+
*
|
|
219
|
+
* @returns Promise that resolves when all providers are ready.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* await core.ready();
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
ready(): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Gracefully shutdown the application.
|
|
229
|
+
*
|
|
230
|
+
* Invokes the `onShutdown()` lifecycle hook on all providers in reverse order (LIFO).
|
|
231
|
+
* Should be called when the application receives a termination signal.
|
|
232
|
+
*
|
|
233
|
+
* @returns Promise that resolves when all providers have shut down.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* process.on('SIGTERM', () => core.shutdown());
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
shutdown(): Promise<void>;
|
|
148
241
|
/**
|
|
149
242
|
* Setup deferred provider resolution.
|
|
150
243
|
* Wraps container.make to auto-register deferred providers on first request.
|
|
@@ -170,6 +263,12 @@ export declare class PlanetCore {
|
|
|
170
263
|
adapter?: HttpAdapter;
|
|
171
264
|
container?: Container;
|
|
172
265
|
});
|
|
266
|
+
/**
|
|
267
|
+
* Setup process signal handlers for graceful shutdown
|
|
268
|
+
*
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
private setupSignalHandlers;
|
|
173
272
|
/**
|
|
174
273
|
* Programmatically register an infrastructure module (Orbit).
|
|
175
274
|
* @since 2.0.0
|
|
@@ -197,11 +296,36 @@ export declare class PlanetCore {
|
|
|
197
296
|
* ```
|
|
198
297
|
*/
|
|
199
298
|
use(satellite: ServiceProvider | ((core: PlanetCore) => void | Promise<void>)): Promise<this>;
|
|
299
|
+
/**
|
|
300
|
+
* Register a global error handler for process-level exceptions.
|
|
301
|
+
*
|
|
302
|
+
* Captures `unhandledRejection` and `uncaughtException` to prevent process crashes
|
|
303
|
+
* and allow for graceful shutdown or error reporting.
|
|
304
|
+
*
|
|
305
|
+
* @param options - Configuration for global error handling.
|
|
306
|
+
* @returns A function to unregister the global error handlers.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```typescript
|
|
310
|
+
* const unregister = core.registerGlobalErrorHandlers({
|
|
311
|
+
* exitOnFatal: true
|
|
312
|
+
* });
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
200
315
|
registerGlobalErrorHandlers(options?: Omit<RegisterGlobalErrorHandlersOptions, 'core'>): () => void;
|
|
201
316
|
/**
|
|
202
|
-
* Predictive Route Warming (JIT Optimization)
|
|
317
|
+
* Predictive Route Warming (JIT Optimization).
|
|
203
318
|
*
|
|
204
|
-
*
|
|
319
|
+
* Pre-compiles or warms up the specified paths in the HTTP adapter to reduce
|
|
320
|
+
* latency for the first request to these endpoints.
|
|
321
|
+
*
|
|
322
|
+
* @param paths - List of paths to warm up.
|
|
323
|
+
* @returns Promise that resolves when warming is complete.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* await core.warmup(['/api/v1/products', '/api/v1/categories']);
|
|
328
|
+
* ```
|
|
205
329
|
*/
|
|
206
330
|
warmup(paths: string[]): Promise<void>;
|
|
207
331
|
/**
|
|
@@ -217,10 +341,19 @@ export declare class PlanetCore {
|
|
|
217
341
|
*/
|
|
218
342
|
static boot(config: GravitoConfig): Promise<PlanetCore>;
|
|
219
343
|
/**
|
|
220
|
-
* Mount an Orbit (a PlanetCore instance or native app) to a path.
|
|
344
|
+
* Mount an Orbit (a PlanetCore instance or native app) to a specific URL path.
|
|
345
|
+
*
|
|
346
|
+
* This allows for micro-service like composition where different parts of the
|
|
347
|
+
* application can be developed as independent Orbits and mounted together.
|
|
221
348
|
*
|
|
222
349
|
* @param path - The URL path to mount the orbit at.
|
|
223
350
|
* @param orbitApp - The application instance (PlanetCore, HttpAdapter, or native app).
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```typescript
|
|
354
|
+
* const blogOrbit = new PlanetCore();
|
|
355
|
+
* core.mountOrbit('/blog', blogOrbit);
|
|
356
|
+
* ```
|
|
224
357
|
*/
|
|
225
358
|
mountOrbit(path: string, orbitApp: unknown): void;
|
|
226
359
|
/**
|
|
@@ -240,5 +373,6 @@ export declare class PlanetCore {
|
|
|
240
373
|
port: number;
|
|
241
374
|
fetch: (request: Request, server?: unknown) => Response | Promise<Response>;
|
|
242
375
|
core: PlanetCore;
|
|
376
|
+
websocket?: HttpAdapter['websocket'];
|
|
243
377
|
};
|
|
244
378
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview RequestContext - AsyncLocalStorage-based request context management
|
|
3
|
+
*
|
|
4
|
+
* Allows deep service layers to access request-scoped data (requestId, userId, etc.)
|
|
5
|
+
* without passing parameters through the call stack.
|
|
6
|
+
*
|
|
7
|
+
* @module @gravito/core/RequestContext
|
|
8
|
+
* @since 2.2.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 請求上下文資料介面
|
|
12
|
+
* 包含請求相關的唯一識別碼和上下文資訊
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface RequestContextData {
|
|
16
|
+
/** 唯一的請求識別碼 */
|
|
17
|
+
requestId: string;
|
|
18
|
+
/** 使用者 ID(可選) */
|
|
19
|
+
userId?: string;
|
|
20
|
+
/** 租戶 ID(可選) */
|
|
21
|
+
tenantId?: string;
|
|
22
|
+
/** 追蹤 ID(可選) */
|
|
23
|
+
traceId?: string;
|
|
24
|
+
/** 自訂欄位 */
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* RequestContext 物件 - 管理請求上下文的 API
|
|
29
|
+
*
|
|
30
|
+
* 提供在非同步鏈中存取和設定請求上下文的方法
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare const RequestContext: {
|
|
34
|
+
/**
|
|
35
|
+
* 在給定的上下文中執行函式
|
|
36
|
+
*
|
|
37
|
+
* 確保函式及其所有非同步呼叫都在同一個上下文中執行
|
|
38
|
+
*
|
|
39
|
+
* @param data - 請求上下文資料
|
|
40
|
+
* @param fn - 要執行的函式(可以是非同步的或同步的)
|
|
41
|
+
* @returns 如果函式是非同步的,返回 Promise;如果是同步的,直接返回值
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* await RequestContext.run({ requestId: 'req-123' }, async () => {
|
|
46
|
+
* const userId = RequestContext.get()?.userId;
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* const result = RequestContext.run({ requestId: 'req-123' }, () => {
|
|
50
|
+
* return 'sync-result';
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
run<T>(data: RequestContextData, fn: () => T | Promise<T>): T | Promise<T>;
|
|
55
|
+
/**
|
|
56
|
+
* 獲取當前請求的上下文資料
|
|
57
|
+
*
|
|
58
|
+
* @returns 請求上下文資料,如果不在請求上下文中則返回 undefined
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const context = RequestContext.get();
|
|
63
|
+
* if (context) {
|
|
64
|
+
* console.log(context.requestId);
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
get(): RequestContextData | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* 獲取當前請求的上下文資料,如果不存在則拋出錯誤
|
|
71
|
+
*
|
|
72
|
+
* @returns 請求上下文資料
|
|
73
|
+
* @throws Error 如果不在請求上下文中
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const context = RequestContext.getOrThrow();
|
|
78
|
+
* console.log(context.requestId); // 保證不為 undefined
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
getOrThrow(): RequestContextData;
|
|
82
|
+
/**
|
|
83
|
+
* 在當前上下文中設定或修改值
|
|
84
|
+
*
|
|
85
|
+
* @param key - 要設定的欄位名稱
|
|
86
|
+
* @param value - 要設定的值
|
|
87
|
+
* @throws Error 如果不在請求上下文中
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* RequestContext.set('userId', 'user-456');
|
|
92
|
+
* const userId = RequestContext.get()?.userId; // 'user-456'
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
set(key: string, value: unknown): void;
|
|
96
|
+
};
|
|
97
|
+
export default RequestContext;
|
|
@@ -5,7 +5,7 @@ import { Route } from './Route';
|
|
|
5
5
|
* Type for Controller Class Constructor
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export type ControllerClass = new (core: PlanetCore) =>
|
|
8
|
+
export type ControllerClass = new (core: PlanetCore) => any;
|
|
9
9
|
/**
|
|
10
10
|
* Handler can be a function or [Class, 'methodName']
|
|
11
11
|
* @public
|
|
@@ -125,7 +125,7 @@ export declare class Router {
|
|
|
125
125
|
path: string;
|
|
126
126
|
domain?: string;
|
|
127
127
|
}>;
|
|
128
|
-
private
|
|
128
|
+
private dispatcher;
|
|
129
129
|
private namedRoutes;
|
|
130
130
|
private bindings;
|
|
131
131
|
/**
|
|
@@ -144,6 +144,21 @@ export declare class Router {
|
|
|
144
144
|
registerName(name: string, method: string, path: string, options?: RouteOptions): void;
|
|
145
145
|
/**
|
|
146
146
|
* Generate a URL from a named route.
|
|
147
|
+
*
|
|
148
|
+
* Replaces route parameters (e.g., `:id`) with provided values and appends
|
|
149
|
+
* query parameters to the URL.
|
|
150
|
+
*
|
|
151
|
+
* @param name - The name of the route.
|
|
152
|
+
* @param params - Key-value pairs for route parameters.
|
|
153
|
+
* @param query - Key-value pairs for query string parameters.
|
|
154
|
+
* @returns The generated URL string.
|
|
155
|
+
* @throws Error if the named route is not found or if a required parameter is missing.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const url = router.url('users.show', { id: 1 }, { tab: 'profile' });
|
|
160
|
+
* // Result: "/users/1?tab=profile"
|
|
161
|
+
* ```
|
|
147
162
|
*/
|
|
148
163
|
url(name: string, params?: Record<string, string | number>, query?: Record<string, string | number | boolean | null | undefined>): string;
|
|
149
164
|
/**
|
|
@@ -164,6 +179,17 @@ export declare class Router {
|
|
|
164
179
|
}>): void;
|
|
165
180
|
/**
|
|
166
181
|
* Register a route model binding.
|
|
182
|
+
*
|
|
183
|
+
* Automatically resolves a route parameter to an object using the provided
|
|
184
|
+
* resolver function. The resolved object is then available in the request context.
|
|
185
|
+
*
|
|
186
|
+
* @param param - The name of the route parameter to bind.
|
|
187
|
+
* @param resolver - An async function that resolves the parameter value to an object.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* router.bind('user', async (id) => await User.find(id));
|
|
192
|
+
* ```
|
|
167
193
|
*/
|
|
168
194
|
bind(param: string, resolver: (id: string) => Promise<unknown>): void;
|
|
169
195
|
/**
|
|
@@ -223,17 +249,25 @@ export declare class Router {
|
|
|
223
249
|
*/
|
|
224
250
|
forward(method: HttpMethod | HttpMethod[] | 'all', path: string, target: string, options?: ProxyOptions): void;
|
|
225
251
|
/**
|
|
226
|
-
* Register a resource route (
|
|
252
|
+
* Register a resource route (RESTful).
|
|
253
|
+
*
|
|
254
|
+
* Automatically creates multiple routes for a resource (index, create, store,
|
|
255
|
+
* show, edit, update, destroy) mapping to specific controller methods.
|
|
256
|
+
*
|
|
257
|
+
* @param name - The resource name (e.g., 'users').
|
|
258
|
+
* @param controller - The controller class handling the resource.
|
|
259
|
+
* @param options - Optional constraints (only/except) for resource actions.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* router.resource('photos', PhotoController);
|
|
264
|
+
* ```
|
|
227
265
|
*/
|
|
228
266
|
resource(name: string, controller: ControllerClass, options?: ResourceOptions): void;
|
|
229
267
|
/**
|
|
230
268
|
* Internal Request Registration
|
|
231
269
|
*/
|
|
232
270
|
req(method: HttpMethod, path: string, requestOrHandlerOrMiddleware: FormRequestClass | RouteHandler | GravitoMiddleware | GravitoMiddleware[], handler?: RouteHandler, options?: RouteOptions): Route;
|
|
233
|
-
/**
|
|
234
|
-
* Resolve Controller Instance and Method
|
|
235
|
-
*/
|
|
236
|
-
private resolveControllerHandler;
|
|
237
271
|
}
|
|
238
272
|
/**
|
|
239
273
|
* Standard RESTful resource action names.
|
|
@@ -74,6 +74,28 @@ export declare abstract class ServiceProvider {
|
|
|
74
74
|
* @param core - The PlanetCore application instance
|
|
75
75
|
*/
|
|
76
76
|
boot?(core: PlanetCore): void | Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Called when the application is ready to accept requests.
|
|
79
|
+
*
|
|
80
|
+
* This method is called after ALL providers have booted.
|
|
81
|
+
* Use this for final initialization before the server starts accepting traffic.
|
|
82
|
+
*
|
|
83
|
+
* @param core - The PlanetCore application instance
|
|
84
|
+
* @since 2.2.0
|
|
85
|
+
*/
|
|
86
|
+
onReady?(core: PlanetCore): void | Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Called when the application is shutting down.
|
|
89
|
+
*
|
|
90
|
+
* This method is called during graceful shutdown.
|
|
91
|
+
* Use this to clean up resources, close connections, etc.
|
|
92
|
+
*
|
|
93
|
+
* Providers are called in reverse order (LIFO).
|
|
94
|
+
*
|
|
95
|
+
* @param core - The PlanetCore application instance
|
|
96
|
+
* @since 2.2.0
|
|
97
|
+
*/
|
|
98
|
+
onShutdown?(core: PlanetCore): void | Promise<void>;
|
|
77
99
|
/**
|
|
78
100
|
* Set the core instance reference.
|
|
79
101
|
* Called internally by the application during registration.
|
|
@@ -82,11 +104,15 @@ export declare abstract class ServiceProvider {
|
|
|
82
104
|
*/
|
|
83
105
|
setCore(core: PlanetCore): void;
|
|
84
106
|
/**
|
|
85
|
-
* Merge configuration from a
|
|
107
|
+
* Merge configuration from a value into the application config.
|
|
86
108
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
109
|
+
* If the configuration key already exists and both the existing value and
|
|
110
|
+
* the new value are objects, they will be shallow-merged. Otherwise, the
|
|
111
|
+
* new value will overwrite the existing one.
|
|
112
|
+
*
|
|
113
|
+
* @param config - The ConfigManager instance.
|
|
114
|
+
* @param key - The configuration key to set (supports dot notation).
|
|
115
|
+
* @param value - The configuration value or object to merge.
|
|
90
116
|
*
|
|
91
117
|
* @example
|
|
92
118
|
* ```typescript
|
|
@@ -119,11 +145,13 @@ export declare abstract class ServiceProvider {
|
|
|
119
145
|
*/
|
|
120
146
|
private static publishables;
|
|
121
147
|
/**
|
|
122
|
-
* Register paths to be published.
|
|
123
|
-
*
|
|
148
|
+
* Register paths to be published by the CLI.
|
|
149
|
+
*
|
|
150
|
+
* Used by CLI commands like `gravito vendor:publish` to copy configuration,
|
|
151
|
+
* views, or assets from the package to the application directory.
|
|
124
152
|
*
|
|
125
|
-
* @param paths -
|
|
126
|
-
* @param group - Optional group name for selective publishing
|
|
153
|
+
* @param paths - A record mapping source paths to destination paths.
|
|
154
|
+
* @param group - Optional group name for selective publishing (e.g., 'config', 'views').
|
|
127
155
|
*
|
|
128
156
|
* @example
|
|
129
157
|
* ```typescript
|
|
@@ -23,4 +23,5 @@ export declare class GravitoEngineAdapter<V extends GravitoVariables = GravitoVa
|
|
|
23
23
|
fetch: (request: Request, _server?: unknown) => Response | Promise<Response>;
|
|
24
24
|
warmup(paths: string[]): Promise<void>;
|
|
25
25
|
createContext(_request: Request): GravitoContext<V>;
|
|
26
|
+
useScoped(scope: string, path: string, ...middleware: GravitoMiddleware<V>[]): void;
|
|
26
27
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @since 2.0.0
|
|
9
9
|
*/
|
|
10
10
|
import type { Context, Handler, MiddlewareHandler, Photon } from '@gravito/photon';
|
|
11
|
+
import { RequestScopeManager } from '../Container/RequestScopeManager';
|
|
11
12
|
import type { GravitoContext, GravitoErrorHandler, GravitoHandler, GravitoMiddleware, GravitoNotFoundHandler, GravitoRequest, GravitoVariables, HttpMethod, ProxyOptions, StatusCode } from '../http/types';
|
|
12
13
|
import type { AdapterConfig, HttpAdapter, RouteDefinition } from './types';
|
|
13
14
|
/**
|
|
@@ -50,6 +51,7 @@ declare class PhotonRequestWrapper implements GravitoRequest {
|
|
|
50
51
|
declare class PhotonContextWrapper<V extends GravitoVariables = GravitoVariables> implements GravitoContext<V> {
|
|
51
52
|
private _req;
|
|
52
53
|
private photonCtx;
|
|
54
|
+
private _requestScope;
|
|
53
55
|
route: (name: string, params?: Record<string, any>, query?: Record<string, any>) => string;
|
|
54
56
|
/**
|
|
55
57
|
* Reset the wrapper for pooling
|
|
@@ -90,6 +92,8 @@ declare class PhotonContextWrapper<V extends GravitoVariables = GravitoVariables
|
|
|
90
92
|
get env(): Record<string, unknown> | undefined;
|
|
91
93
|
get native(): Context;
|
|
92
94
|
forward(target: string, options?: ProxyOptions): Promise<Response>;
|
|
95
|
+
requestScope(): RequestScopeManager;
|
|
96
|
+
scoped<T>(key: string | symbol, factory: () => T): T;
|
|
93
97
|
}
|
|
94
98
|
/**
|
|
95
99
|
* Convert a GravitoHandler to a Photon Handler
|
|
@@ -136,6 +140,7 @@ export declare class PhotonAdapter<V extends GravitoVariables = GravitoVariables
|
|
|
136
140
|
routes(routes: RouteDefinition[]): void;
|
|
137
141
|
use(path: string, ...middleware: GravitoMiddleware<V>[]): void;
|
|
138
142
|
useGlobal(...middleware: GravitoMiddleware<V>[]): void;
|
|
143
|
+
useScoped(scope: string, path: string, ...middleware: GravitoMiddleware<V>[]): void;
|
|
139
144
|
mount(path: string, subAdapter: HttpAdapter<V>): void;
|
|
140
145
|
onError(handler: GravitoErrorHandler<V>): void;
|
|
141
146
|
onNotFound(handler: GravitoNotFoundHandler<V>): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RequestScopeManager } from '../../Container/RequestScopeManager';
|
|
1
2
|
import type { ContentfulStatusCode, GravitoContext, GravitoVariables, ProxyOptions, StatusCode } from '../../http/types';
|
|
2
3
|
import { BunRequest } from './BunRequest';
|
|
3
4
|
/**
|
|
@@ -8,6 +9,7 @@ export declare class BunContext<V extends GravitoVariables = GravitoVariables> i
|
|
|
8
9
|
readonly env: Record<string, unknown>;
|
|
9
10
|
readonly req: BunRequest;
|
|
10
11
|
private _variables;
|
|
12
|
+
private _requestScope;
|
|
11
13
|
/**
|
|
12
14
|
* URL generator helper
|
|
13
15
|
*/
|
|
@@ -42,4 +44,6 @@ export declare class BunContext<V extends GravitoVariables = GravitoVariables> i
|
|
|
42
44
|
get<K extends keyof V>(key: K): V[K];
|
|
43
45
|
set<K extends keyof V>(key: K, value: V[K]): void;
|
|
44
46
|
get executionCtx(): ExecutionContext | undefined;
|
|
47
|
+
requestScope(): RequestScopeManager;
|
|
48
|
+
scoped<T>(key: string | symbol, factory: () => T): T;
|
|
45
49
|
}
|
|
@@ -17,6 +17,7 @@ export declare class BunNativeAdapter implements HttpAdapter {
|
|
|
17
17
|
routes(routes: RouteDefinition[]): void;
|
|
18
18
|
use(path: string, ...middleware: GravitoMiddleware[]): void;
|
|
19
19
|
useGlobal(...middleware: GravitoMiddleware[]): void;
|
|
20
|
+
useScoped(scope: string, path: string, ...middleware: GravitoMiddleware[]): void;
|
|
20
21
|
mount(path: string, subAdapter: HttpAdapter): void;
|
|
21
22
|
createContext(request: Request): GravitoContext;
|
|
22
23
|
onError(handler: GravitoErrorHandler): void;
|
|
@@ -115,6 +115,33 @@ export interface HttpAdapter<V extends GravitoVariables = GravitoVariables> {
|
|
|
115
115
|
* @param middleware - Middleware function
|
|
116
116
|
*/
|
|
117
117
|
useGlobal(...middleware: GravitoMiddleware<V>[]): void;
|
|
118
|
+
/**
|
|
119
|
+
* Register a scoped middleware for Orbit-level isolation
|
|
120
|
+
*
|
|
121
|
+
* Unlike regular `use()`, this method enforces stricter scoping rules:
|
|
122
|
+
* - REJECTS '*' wildcard paths (prevents global middleware in Orbits)
|
|
123
|
+
* - ENFORCES that all middleware paths must include the scope prefix
|
|
124
|
+
* - Throws error if attempting to register global middleware within an Orbit scope
|
|
125
|
+
*
|
|
126
|
+
* This is designed to prevent accidental middleware cross-contamination
|
|
127
|
+
* when multiple Orbits are mounted to a single PlanetCore instance.
|
|
128
|
+
*
|
|
129
|
+
* @param scope - The scope/path prefix (e.g., '/api', '/blog')
|
|
130
|
+
* @param path - Path pattern to match (cannot be '*')
|
|
131
|
+
* @param middleware - One or more middleware functions
|
|
132
|
+
* @throws {Error} If path is '*' when in Orbit scope
|
|
133
|
+
* @since 2.3.0
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* // Correct: Scoped to specific path
|
|
138
|
+
* adapter.useScoped('/api', '/users/*', authMiddleware)
|
|
139
|
+
*
|
|
140
|
+
* // Error: Cannot use wildcard in Orbit scope
|
|
141
|
+
* adapter.useScoped('/api', '*', loggerMiddleware)
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
useScoped(scope: string, path: string, ...middleware: GravitoMiddleware<V>[]): void;
|
|
118
145
|
/**
|
|
119
146
|
* Mount a sub-adapter at a path
|
|
120
147
|
*
|
|
@@ -164,6 +191,18 @@ export interface HttpAdapter<V extends GravitoVariables = GravitoVariables> {
|
|
|
164
191
|
* @since 2.1.0
|
|
165
192
|
*/
|
|
166
193
|
warmup?(paths: string[]): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* WebSocket Handler for Bun.serve
|
|
196
|
+
*
|
|
197
|
+
* @since 2.2.0
|
|
198
|
+
*/
|
|
199
|
+
websocket?: {
|
|
200
|
+
open?(ws: unknown): void | Promise<void>;
|
|
201
|
+
message?(ws: unknown, message: string | Buffer | Uint8Array): void | Promise<void>;
|
|
202
|
+
close?(ws: unknown, code: number, message: string): void | Promise<void>;
|
|
203
|
+
drain?(ws: unknown): void | Promise<void>;
|
|
204
|
+
[key: string]: unknown;
|
|
205
|
+
};
|
|
167
206
|
/**
|
|
168
207
|
* Initialize the adapter
|
|
169
208
|
*
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommandKernel } from '../CommandKernel';
|
|
2
|
+
import type { QueueDashboard } from '../observability/QueueDashboard';
|
|
3
|
+
/**
|
|
4
|
+
* Register queue management commands with CommandKernel
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerQueueCommands(kernel: CommandKernel, dashboard: QueueDashboard): void;
|
|
@@ -34,9 +34,15 @@ export declare class AOTRouter {
|
|
|
34
34
|
readonly globalMiddleware: Middleware[];
|
|
35
35
|
/** @internal */
|
|
36
36
|
readonly pathMiddleware: Map<string, Middleware[]>;
|
|
37
|
+
private dynamicRoutePatterns;
|
|
37
38
|
private middlewareCache;
|
|
38
39
|
private cacheMaxSize;
|
|
39
|
-
private
|
|
40
|
+
private _version;
|
|
41
|
+
/**
|
|
42
|
+
* Get the current version for cache invalidation
|
|
43
|
+
* Incremented whenever middleware or routes are modified
|
|
44
|
+
*/
|
|
45
|
+
get version(): number;
|
|
40
46
|
/**
|
|
41
47
|
* Register a route
|
|
42
48
|
*
|
|
@@ -111,17 +117,6 @@ export declare class AOTRouter {
|
|
|
111
117
|
* @returns True if pattern matches
|
|
112
118
|
*/
|
|
113
119
|
private matchPattern;
|
|
114
|
-
/**
|
|
115
|
-
* Find the original route key for a matched dynamic route
|
|
116
|
-
*
|
|
117
|
-
* This is needed to look up route-specific middleware.
|
|
118
|
-
* It's a bit of a hack, but avoids storing duplicate data.
|
|
119
|
-
*
|
|
120
|
-
* @param method - HTTP method
|
|
121
|
-
* @param path - Matched path
|
|
122
|
-
* @returns Route key or null
|
|
123
|
-
*/
|
|
124
|
-
private findDynamicRouteKey;
|
|
125
120
|
/**
|
|
126
121
|
* Get all registered routes (for debugging)
|
|
127
122
|
*/
|