@gravito/echo 3.1.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -9
- package/dist/OrbitEcho.d.ts +76 -60
- package/dist/errors/EchoError.d.ts +29 -0
- package/dist/errors/codes.d.ts +20 -0
- package/dist/index.d.ts +34 -16
- package/dist/index.js +3 -1596
- package/dist/index.js.map +3 -28
- package/dist/{echo/src/middleware → middleware}/RequestBufferMiddleware.d.ts +3 -3
- package/dist/providers/GenericProvider.d.ts +37 -19
- package/dist/providers/GitHubProvider.d.ts +21 -13
- package/dist/providers/StripeProvider.d.ts +20 -13
- package/dist/providers/index.d.ts +14 -4
- package/dist/receive/SignatureValidator.d.ts +33 -1
- package/dist/receive/WebhookReceiver.d.ts +139 -22
- package/dist/receive/index.d.ts +0 -1
- package/dist/resilience/CircuitBreaker.d.ts +6 -0
- package/dist/{echo/src/resilience → resilience}/index.d.ts +2 -1
- package/dist/send/WebhookDispatcher.d.ts +159 -16
- package/dist/send/index.d.ts +0 -1
- package/dist/types.d.ts +671 -57
- package/package.json +9 -3
- package/dist/OrbitEcho.d.ts.map +0 -1
- package/dist/atlas/src/DB.d.ts +0 -348
- package/dist/atlas/src/OrbitAtlas.d.ts +0 -9
- package/dist/atlas/src/config/defineConfig.d.ts +0 -14
- package/dist/atlas/src/config/index.d.ts +0 -7
- package/dist/atlas/src/config/loadConfig.d.ts +0 -41
- package/dist/atlas/src/connection/Connection.d.ts +0 -112
- package/dist/atlas/src/connection/ConnectionManager.d.ts +0 -180
- package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +0 -54
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +0 -32
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +0 -118
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +0 -36
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +0 -79
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +0 -96
- package/dist/atlas/src/drivers/RedisDriver.d.ts +0 -43
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +0 -45
- package/dist/atlas/src/drivers/types.d.ts +0 -260
- package/dist/atlas/src/errors/index.d.ts +0 -45
- package/dist/atlas/src/grammar/Grammar.d.ts +0 -342
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +0 -47
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +0 -54
- package/dist/atlas/src/grammar/NullGrammar.d.ts +0 -35
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +0 -62
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +0 -32
- package/dist/atlas/src/index.d.ts +0 -79
- package/dist/atlas/src/migration/Migration.d.ts +0 -64
- package/dist/atlas/src/migration/MigrationRepository.d.ts +0 -65
- package/dist/atlas/src/migration/Migrator.d.ts +0 -110
- package/dist/atlas/src/migration/index.d.ts +0 -6
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +0 -33
- package/dist/atlas/src/observability/AtlasObservability.d.ts +0 -15
- package/dist/atlas/src/observability/AtlasTracer.d.ts +0 -12
- package/dist/atlas/src/observability/index.d.ts +0 -9
- package/dist/atlas/src/orm/Repository.d.ts +0 -247
- package/dist/atlas/src/orm/index.d.ts +0 -6
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +0 -121
- package/dist/atlas/src/orm/model/Model.d.ts +0 -458
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +0 -20
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +0 -150
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +0 -36
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +0 -92
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +0 -117
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +0 -64
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +0 -15
- package/dist/atlas/src/orm/model/concerns/index.d.ts +0 -12
- package/dist/atlas/src/orm/model/decorators.d.ts +0 -138
- package/dist/atlas/src/orm/model/errors.d.ts +0 -52
- package/dist/atlas/src/orm/model/index.d.ts +0 -10
- package/dist/atlas/src/orm/model/relationships.d.ts +0 -207
- package/dist/atlas/src/orm/model/types.d.ts +0 -12
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +0 -124
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +0 -54
- package/dist/atlas/src/orm/schema/index.d.ts +0 -6
- package/dist/atlas/src/orm/schema/types.d.ts +0 -85
- package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +0 -98
- package/dist/atlas/src/pool/PoolHealthChecker.d.ts +0 -91
- package/dist/atlas/src/pool/PoolStrategy.d.ts +0 -129
- package/dist/atlas/src/pool/PoolWarmer.d.ts +0 -92
- package/dist/atlas/src/query/Expression.d.ts +0 -60
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +0 -10
- package/dist/atlas/src/query/QueryBuilder.d.ts +0 -643
- package/dist/atlas/src/query/RelationshipResolver.d.ts +0 -23
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +0 -51
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +0 -70
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +0 -87
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +0 -82
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +0 -69
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +0 -71
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +0 -167
- package/dist/atlas/src/query/clauses/index.d.ts +0 -11
- package/dist/atlas/src/schema/Blueprint.d.ts +0 -276
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +0 -154
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +0 -37
- package/dist/atlas/src/schema/MigrationGenerator.d.ts +0 -45
- package/dist/atlas/src/schema/Schema.d.ts +0 -131
- package/dist/atlas/src/schema/SchemaDiff.d.ts +0 -73
- package/dist/atlas/src/schema/TypeGenerator.d.ts +0 -57
- package/dist/atlas/src/schema/TypeWriter.d.ts +0 -42
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +0 -23
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +0 -26
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +0 -28
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +0 -97
- package/dist/atlas/src/schema/grammars/index.d.ts +0 -7
- package/dist/atlas/src/schema/index.d.ts +0 -8
- package/dist/atlas/src/seed/Factory.d.ts +0 -90
- package/dist/atlas/src/seed/Seeder.d.ts +0 -28
- package/dist/atlas/src/seed/SeederRunner.d.ts +0 -74
- package/dist/atlas/src/seed/index.d.ts +0 -6
- package/dist/atlas/src/sharding/ShardingManager.d.ts +0 -59
- package/dist/atlas/src/types/index.d.ts +0 -1182
- package/dist/atlas/src/utils/CursorEncoding.d.ts +0 -63
- package/dist/atlas/src/utils/levenshtein.d.ts +0 -9
- package/dist/core/src/Application.d.ts +0 -215
- package/dist/core/src/CommandKernel.d.ts +0 -33
- package/dist/core/src/ConfigManager.d.ts +0 -65
- package/dist/core/src/Container/RequestScopeManager.d.ts +0 -62
- package/dist/core/src/Container/RequestScopeMetrics.d.ts +0 -144
- package/dist/core/src/Container.d.ts +0 -153
- package/dist/core/src/ErrorHandler.d.ts +0 -66
- package/dist/core/src/Event.d.ts +0 -5
- package/dist/core/src/EventManager.d.ts +0 -123
- package/dist/core/src/GlobalErrorHandlers.d.ts +0 -47
- package/dist/core/src/GravitoServer.d.ts +0 -28
- package/dist/core/src/HookManager.d.ts +0 -591
- package/dist/core/src/Listener.d.ts +0 -4
- package/dist/core/src/Logger.d.ts +0 -20
- package/dist/core/src/PlanetCore.d.ts +0 -378
- package/dist/core/src/RequestContext.d.ts +0 -97
- package/dist/core/src/Route.d.ts +0 -36
- package/dist/core/src/Router.d.ts +0 -284
- package/dist/core/src/ServiceProvider.d.ts +0 -178
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +0 -27
- package/dist/core/src/adapters/PhotonAdapter.d.ts +0 -175
- package/dist/core/src/adapters/bun/BunContext.d.ts +0 -49
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +0 -31
- package/dist/core/src/adapters/bun/BunRequest.d.ts +0 -31
- package/dist/core/src/adapters/bun/RadixNode.d.ts +0 -19
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +0 -31
- package/dist/core/src/adapters/bun/types.d.ts +0 -20
- package/dist/core/src/adapters/photon-types.d.ts +0 -73
- package/dist/core/src/adapters/types.d.ts +0 -235
- package/dist/core/src/cli/queue-commands.d.ts +0 -6
- package/dist/core/src/engine/AOTRouter.d.ts +0 -129
- package/dist/core/src/engine/FastContext.d.ts +0 -123
- package/dist/core/src/engine/Gravito.d.ts +0 -136
- package/dist/core/src/engine/MinimalContext.d.ts +0 -100
- package/dist/core/src/engine/analyzer.d.ts +0 -27
- package/dist/core/src/engine/constants.d.ts +0 -23
- package/dist/core/src/engine/index.d.ts +0 -26
- package/dist/core/src/engine/path.d.ts +0 -26
- package/dist/core/src/engine/pool.d.ts +0 -83
- package/dist/core/src/engine/types.d.ts +0 -146
- package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +0 -126
- package/dist/core/src/events/BackpressureManager.d.ts +0 -215
- package/dist/core/src/events/CircuitBreaker.d.ts +0 -229
- package/dist/core/src/events/DeadLetterQueue.d.ts +0 -219
- package/dist/core/src/events/EventBackend.d.ts +0 -12
- package/dist/core/src/events/EventOptions.d.ts +0 -204
- package/dist/core/src/events/EventPriorityQueue.d.ts +0 -301
- package/dist/core/src/events/FlowControlStrategy.d.ts +0 -109
- package/dist/core/src/events/IdempotencyCache.d.ts +0 -60
- package/dist/core/src/events/MessageQueueBridge.d.ts +0 -184
- package/dist/core/src/events/PriorityEscalationManager.d.ts +0 -82
- package/dist/core/src/events/RetryScheduler.d.ts +0 -104
- package/dist/core/src/events/WorkerPool.d.ts +0 -98
- package/dist/core/src/events/WorkerPoolConfig.d.ts +0 -153
- package/dist/core/src/events/WorkerPoolMetrics.d.ts +0 -65
- package/dist/core/src/events/aggregation/AggregationWindow.d.ts +0 -77
- package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +0 -135
- package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +0 -108
- package/dist/core/src/events/aggregation/EventBatcher.d.ts +0 -99
- package/dist/core/src/events/aggregation/types.d.ts +0 -117
- package/dist/core/src/events/index.d.ts +0 -25
- package/dist/core/src/events/observability/EventMetrics.d.ts +0 -132
- package/dist/core/src/events/observability/EventTracer.d.ts +0 -68
- package/dist/core/src/events/observability/EventTracing.d.ts +0 -161
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +0 -332
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +0 -108
- package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +0 -76
- package/dist/core/src/events/observability/index.d.ts +0 -24
- package/dist/core/src/events/observability/metrics-types.d.ts +0 -16
- package/dist/core/src/events/types.d.ts +0 -134
- package/dist/core/src/exceptions/AuthenticationException.d.ts +0 -8
- package/dist/core/src/exceptions/AuthorizationException.d.ts +0 -8
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +0 -9
- package/dist/core/src/exceptions/GravitoException.d.ts +0 -23
- package/dist/core/src/exceptions/HttpException.d.ts +0 -9
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +0 -10
- package/dist/core/src/exceptions/ValidationException.d.ts +0 -22
- package/dist/core/src/exceptions/index.d.ts +0 -7
- package/dist/core/src/health/HealthProvider.d.ts +0 -67
- package/dist/core/src/helpers/Arr.d.ts +0 -19
- package/dist/core/src/helpers/Str.d.ts +0 -23
- package/dist/core/src/helpers/data.d.ts +0 -25
- package/dist/core/src/helpers/errors.d.ts +0 -34
- package/dist/core/src/helpers/response.d.ts +0 -41
- package/dist/core/src/helpers.d.ts +0 -338
- package/dist/core/src/http/CookieJar.d.ts +0 -51
- package/dist/core/src/http/cookie.d.ts +0 -29
- package/dist/core/src/http/middleware/BodySizeLimit.d.ts +0 -16
- package/dist/core/src/http/middleware/Cors.d.ts +0 -24
- package/dist/core/src/http/middleware/Csrf.d.ts +0 -23
- package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +0 -28
- package/dist/core/src/http/middleware/SecurityHeaders.d.ts +0 -29
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -18
- package/dist/core/src/http/types.d.ts +0 -374
- package/dist/core/src/index.d.ts +0 -88
- package/dist/core/src/instrumentation/index.d.ts +0 -35
- package/dist/core/src/instrumentation/opentelemetry.d.ts +0 -178
- package/dist/core/src/instrumentation/types.d.ts +0 -182
- package/dist/core/src/observability/Metrics.d.ts +0 -244
- package/dist/core/src/observability/QueueDashboard.d.ts +0 -136
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +0 -350
- package/dist/core/src/reliability/RetryPolicy.d.ts +0 -217
- package/dist/core/src/reliability/index.d.ts +0 -6
- package/dist/core/src/router/ControllerDispatcher.d.ts +0 -12
- package/dist/core/src/router/RequestValidator.d.ts +0 -20
- package/dist/core/src/runtime.d.ts +0 -119
- package/dist/core/src/security/Encrypter.d.ts +0 -33
- package/dist/core/src/security/Hasher.d.ts +0 -29
- package/dist/core/src/testing/HttpTester.d.ts +0 -39
- package/dist/core/src/testing/TestResponse.d.ts +0 -78
- package/dist/core/src/testing/index.d.ts +0 -2
- package/dist/core/src/types/events.d.ts +0 -94
- package/dist/echo/src/OrbitEcho.d.ts +0 -115
- package/dist/echo/src/index.d.ts +0 -64
- package/dist/echo/src/providers/GenericProvider.d.ts +0 -53
- package/dist/echo/src/providers/GitHubProvider.d.ts +0 -35
- package/dist/echo/src/providers/StripeProvider.d.ts +0 -38
- package/dist/echo/src/providers/index.d.ts +0 -14
- package/dist/echo/src/receive/SignatureValidator.d.ts +0 -67
- package/dist/echo/src/receive/WebhookReceiver.d.ts +0 -185
- package/dist/echo/src/receive/index.d.ts +0 -2
- package/dist/echo/src/resilience/CircuitBreaker.d.ts +0 -117
- package/dist/echo/src/send/WebhookDispatcher.d.ts +0 -198
- package/dist/echo/src/send/index.d.ts +0 -1
- package/dist/echo/src/types.d.ts +0 -756
- package/dist/index.d.ts.map +0 -1
- package/dist/monitor/src/MonitorOrbit.d.ts +0 -43
- package/dist/monitor/src/config.d.ts +0 -106
- package/dist/monitor/src/health/HealthController.d.ts +0 -28
- package/dist/monitor/src/health/HealthRegistry.d.ts +0 -80
- package/dist/monitor/src/health/index.d.ts +0 -36
- package/dist/monitor/src/index.d.ts +0 -13
- package/dist/monitor/src/metrics/MetricsController.d.ts +0 -22
- package/dist/monitor/src/metrics/MetricsRegistry.d.ts +0 -136
- package/dist/monitor/src/metrics/index.d.ts +0 -11
- package/dist/monitor/src/tracing/TracingManager.d.ts +0 -97
- package/dist/monitor/src/tracing/index.d.ts +0 -10
- package/dist/photon/src/index.d.ts +0 -89
- package/dist/photon/src/middleware/binary.d.ts +0 -31
- package/dist/photon/src/middleware/htmx.d.ts +0 -39
- package/dist/photon/src/middleware/ratelimit-redis.d.ts +0 -50
- package/dist/photon/src/middleware/ratelimit.d.ts +0 -161
- package/dist/photon/src/openapi.d.ts +0 -19
- package/dist/providers/GenericProvider.d.ts.map +0 -1
- package/dist/providers/GitHubProvider.d.ts.map +0 -1
- package/dist/providers/StripeProvider.d.ts.map +0 -1
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/receive/SignatureValidator.d.ts.map +0 -1
- package/dist/receive/WebhookReceiver.d.ts.map +0 -1
- package/dist/receive/index.d.ts.map +0 -1
- package/dist/send/WebhookDispatcher.d.ts.map +0 -1
- package/dist/send/index.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- /package/dist/{echo/src/dlq → dlq}/DeadLetterQueue.d.ts +0 -0
- /package/dist/{echo/src/dlq → dlq}/MemoryDeadLetterQueue.d.ts +0 -0
- /package/dist/{echo/src/dlq → dlq}/index.d.ts +0 -0
- /package/dist/{echo/src/middleware → middleware}/index.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/index.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/logging/ConsoleEchoLogger.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/logging/EchoLogger.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/logging/index.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/metrics/MetricsProvider.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/metrics/NoopMetricsProvider.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/metrics/PrometheusMetricsProvider.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/metrics/index.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/tracing/NoopTracer.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/tracing/Tracer.d.ts +0 -0
- /package/dist/{echo/src/observability → observability}/tracing/index.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/LinearProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/PaddleProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/ShopifyProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/SlackProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/TwilioProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/base/BaseProvider.d.ts +0 -0
- /package/dist/{echo/src/providers → providers}/base/HeaderUtils.d.ts +0 -0
- /package/dist/{echo/src/replay → replay}/WebhookReplayService.d.ts +0 -0
- /package/dist/{echo/src/replay → replay}/index.d.ts +0 -0
- /package/dist/{echo/src/rotation → rotation}/KeyRotationManager.d.ts +0 -0
- /package/dist/{echo/src/rotation → rotation}/index.d.ts +0 -0
- /package/dist/{echo/src/storage → storage}/MemoryWebhookStore.d.ts +0 -0
- /package/dist/{echo/src/storage → storage}/WebhookStore.d.ts +0 -0
- /package/dist/{echo/src/storage → storage}/index.d.ts +0 -0
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import type { GravitoHandler, GravitoMiddleware, HttpMethod, ProxyOptions } from './http/types';
|
|
2
|
-
import type { PlanetCore } from './PlanetCore';
|
|
3
|
-
import { Route } from './Route';
|
|
4
|
-
/**
|
|
5
|
-
* Type for Controller Class Constructor
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export type ControllerClass = new (core: PlanetCore) => any;
|
|
9
|
-
/**
|
|
10
|
-
* Handler can be a function or [Class, 'methodName']
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export type RouteHandler = GravitoHandler | [ControllerClass, string];
|
|
14
|
-
/**
|
|
15
|
-
* Interface for FormRequest classes (from @gravito/impulse).
|
|
16
|
-
* Used for duck-typing detection without hard dependency.
|
|
17
|
-
*/
|
|
18
|
-
export interface FormRequestLike {
|
|
19
|
-
schema: unknown;
|
|
20
|
-
source?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Validate the request context.
|
|
23
|
-
* @param ctx - The request context
|
|
24
|
-
*/
|
|
25
|
-
validate?(ctx: unknown): Promise<{
|
|
26
|
-
success: boolean;
|
|
27
|
-
data?: unknown;
|
|
28
|
-
error?: unknown;
|
|
29
|
-
}>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Type for FormRequest class constructor
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
|
-
export type FormRequestClass = new () => FormRequestLike;
|
|
36
|
-
/**
|
|
37
|
-
* Symbol to mark FormRequest classes for fast identification.
|
|
38
|
-
* FormRequest classes from @gravito/impulse should set this symbol.
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* Symbol to mark FormRequest classes for fast identification.
|
|
42
|
-
* FormRequest classes from @gravito/impulse should set this symbol.
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
export declare const FORM_REQUEST_SYMBOL: unique symbol;
|
|
46
|
-
/**
|
|
47
|
-
* Options for route definitions
|
|
48
|
-
* @public
|
|
49
|
-
*/
|
|
50
|
-
export interface RouteOptions {
|
|
51
|
-
/** Route prefix path */
|
|
52
|
-
prefix?: string;
|
|
53
|
-
/** Domain/Hostname constraint */
|
|
54
|
-
domain?: string;
|
|
55
|
-
/** Middleware stack for the route */
|
|
56
|
-
middleware?: GravitoMiddleware[];
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* RouteGroup
|
|
60
|
-
* Helper class for chained route configuration (prefix, domain, etc.)
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* RouteGroup
|
|
64
|
-
* Helper class for chained route configuration (prefix, domain, etc.)
|
|
65
|
-
* @public
|
|
66
|
-
*/
|
|
67
|
-
export declare class RouteGroup {
|
|
68
|
-
private router;
|
|
69
|
-
private options;
|
|
70
|
-
constructor(router: Router, options: RouteOptions);
|
|
71
|
-
/**
|
|
72
|
-
* Add a prefix to the current group
|
|
73
|
-
*/
|
|
74
|
-
prefix(path: string): RouteGroup;
|
|
75
|
-
/**
|
|
76
|
-
* Add middleware to the current group.
|
|
77
|
-
* Accepts individual handlers or arrays of handlers.
|
|
78
|
-
*/
|
|
79
|
-
middleware(...handlers: (GravitoMiddleware | GravitoMiddleware[])[]): RouteGroup;
|
|
80
|
-
/**
|
|
81
|
-
* Define routes within this group
|
|
82
|
-
*/
|
|
83
|
-
group(callback: (router: Router | RouteGroup) => void): void;
|
|
84
|
-
get(path: string, handler: RouteHandler): Route;
|
|
85
|
-
get(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
86
|
-
get(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
87
|
-
post(path: string, handler: RouteHandler): Route;
|
|
88
|
-
post(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
89
|
-
post(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
90
|
-
put(path: string, handler: RouteHandler): Route;
|
|
91
|
-
put(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
92
|
-
put(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
93
|
-
delete(path: string, handler: RouteHandler): Route;
|
|
94
|
-
delete(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
95
|
-
delete(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
96
|
-
patch(path: string, handler: RouteHandler): Route;
|
|
97
|
-
patch(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
98
|
-
patch(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
99
|
-
resource(name: string, controller: ControllerClass, options?: ResourceOptions): void;
|
|
100
|
-
/**
|
|
101
|
-
* Register a route that forwards requests to another URL (Gateway Proxy).
|
|
102
|
-
* @param method - HTTP method or 'all'
|
|
103
|
-
* @param path - Local route path
|
|
104
|
-
* @param target - Remote URL or base URL to forward to
|
|
105
|
-
* @param options - Optional proxy options
|
|
106
|
-
*/
|
|
107
|
-
forward(method: HttpMethod | HttpMethod[] | 'all', path: string, target: string, options?: ProxyOptions): void;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Gravito Router
|
|
111
|
-
*
|
|
112
|
-
* Provides a Laravel-like fluent API for defining routes.
|
|
113
|
-
* Supports:
|
|
114
|
-
* - Controller-based routing: router.get('/', [HomeController, 'index'])
|
|
115
|
-
* - Route groups with prefixes: router.prefix('/api').group(...)
|
|
116
|
-
* - Domain-based routing: router.domain('api.app').group(...)
|
|
117
|
-
* - Middleware chaining: router.middleware(auth).group(...)
|
|
118
|
-
* - FormRequest validation: router.post('/users', StoreUserRequest, [UserController, 'store'])
|
|
119
|
-
* - Inline Middleware: router.get('/users', authMiddleware, [UserController, 'index'])
|
|
120
|
-
*/
|
|
121
|
-
export declare class Router {
|
|
122
|
-
private core;
|
|
123
|
-
routes: Array<{
|
|
124
|
-
method: string;
|
|
125
|
-
path: string;
|
|
126
|
-
domain?: string;
|
|
127
|
-
}>;
|
|
128
|
-
private dispatcher;
|
|
129
|
-
private namedRoutes;
|
|
130
|
-
private bindings;
|
|
131
|
-
/**
|
|
132
|
-
* Compile all registered routes into a flat array for caching or manifest generation.
|
|
133
|
-
* Optimized: O(n) complexity using Set for lookups instead of O(n²) with Array.some()
|
|
134
|
-
*/
|
|
135
|
-
compile(): {
|
|
136
|
-
method: string;
|
|
137
|
-
path: string;
|
|
138
|
-
name?: string;
|
|
139
|
-
domain?: string | undefined;
|
|
140
|
-
}[];
|
|
141
|
-
/**
|
|
142
|
-
* Register a named route
|
|
143
|
-
*/
|
|
144
|
-
registerName(name: string, method: string, path: string, options?: RouteOptions): void;
|
|
145
|
-
/**
|
|
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
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
url(name: string, params?: Record<string, string | number>, query?: Record<string, string | number | boolean | null | undefined>): string;
|
|
164
|
-
/**
|
|
165
|
-
* Export named routes as a serializable manifest (for caching).
|
|
166
|
-
*/
|
|
167
|
-
exportNamedRoutes(): Record<string, {
|
|
168
|
-
method: string;
|
|
169
|
-
path: string;
|
|
170
|
-
domain?: string;
|
|
171
|
-
}>;
|
|
172
|
-
/**
|
|
173
|
-
* Load named routes from a manifest (for caching).
|
|
174
|
-
*/
|
|
175
|
-
loadNamedRoutes(manifest: Record<string, {
|
|
176
|
-
method: string;
|
|
177
|
-
path: string;
|
|
178
|
-
domain?: string;
|
|
179
|
-
}>): void;
|
|
180
|
-
/**
|
|
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
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
bind(param: string, resolver: (id: string) => Promise<unknown>): void;
|
|
195
|
-
/**
|
|
196
|
-
* Register a route model binding for a Model class.
|
|
197
|
-
*/
|
|
198
|
-
model(param: string, modelClass: unknown): void;
|
|
199
|
-
constructor(core: PlanetCore);
|
|
200
|
-
/**
|
|
201
|
-
* Start a route group with a prefix
|
|
202
|
-
*/
|
|
203
|
-
prefix(path: string): RouteGroup;
|
|
204
|
-
/**
|
|
205
|
-
* Start a route group with a domain constraint
|
|
206
|
-
*/
|
|
207
|
-
domain(host: string): RouteGroup;
|
|
208
|
-
/**
|
|
209
|
-
* Start a route group with middleware.
|
|
210
|
-
* Accepts individual handlers or arrays of handlers.
|
|
211
|
-
*/
|
|
212
|
-
middleware(...handlers: (GravitoMiddleware | GravitoMiddleware[])[]): RouteGroup;
|
|
213
|
-
/**
|
|
214
|
-
* Register a GET route.
|
|
215
|
-
*/
|
|
216
|
-
get(path: string, handler: RouteHandler): Route;
|
|
217
|
-
get(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
218
|
-
get(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
219
|
-
/**
|
|
220
|
-
* Register a POST route.
|
|
221
|
-
*/
|
|
222
|
-
post(path: string, handler: RouteHandler): Route;
|
|
223
|
-
post(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
224
|
-
post(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
225
|
-
/**
|
|
226
|
-
* Register a PUT route.
|
|
227
|
-
*/
|
|
228
|
-
put(path: string, handler: RouteHandler): Route;
|
|
229
|
-
put(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
230
|
-
put(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
231
|
-
/**
|
|
232
|
-
* Register a DELETE route.
|
|
233
|
-
*/
|
|
234
|
-
delete(path: string, handler: RouteHandler): Route;
|
|
235
|
-
delete(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
236
|
-
delete(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
237
|
-
/**
|
|
238
|
-
* Register a PATCH route.
|
|
239
|
-
*/
|
|
240
|
-
patch(path: string, handler: RouteHandler): Route;
|
|
241
|
-
patch(path: string, request: FormRequestClass, handler: RouteHandler): Route;
|
|
242
|
-
patch(path: string, middleware: GravitoMiddleware | GravitoMiddleware[], handler: RouteHandler): Route;
|
|
243
|
-
/**
|
|
244
|
-
* Register a route that forwards requests to another URL (Gateway Proxy).
|
|
245
|
-
* @param method - HTTP method or 'all'
|
|
246
|
-
* @param path - Local route path
|
|
247
|
-
* @param target - Remote URL or base URL to forward to
|
|
248
|
-
* @param options - Optional proxy options
|
|
249
|
-
*/
|
|
250
|
-
forward(method: HttpMethod | HttpMethod[] | 'all', path: string, target: string, options?: ProxyOptions): void;
|
|
251
|
-
/**
|
|
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
|
-
* ```
|
|
265
|
-
*/
|
|
266
|
-
resource(name: string, controller: ControllerClass, options?: ResourceOptions): void;
|
|
267
|
-
/**
|
|
268
|
-
* Internal Request Registration
|
|
269
|
-
*/
|
|
270
|
-
req(method: HttpMethod, path: string, requestOrHandlerOrMiddleware: FormRequestClass | RouteHandler | GravitoMiddleware | GravitoMiddleware[], handler?: RouteHandler, options?: RouteOptions): Route;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Standard RESTful resource action names.
|
|
274
|
-
* @public
|
|
275
|
-
*/
|
|
276
|
-
export type ResourceAction = 'index' | 'create' | 'store' | 'show' | 'edit' | 'update' | 'destroy';
|
|
277
|
-
/**
|
|
278
|
-
* Options for resource route registration.
|
|
279
|
-
* @public
|
|
280
|
-
*/
|
|
281
|
-
export interface ResourceOptions {
|
|
282
|
-
only?: ResourceAction[];
|
|
283
|
-
except?: ResourceAction[];
|
|
284
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import type { ConfigManager } from './ConfigManager';
|
|
2
|
-
import type { Container } from './Container';
|
|
3
|
-
import type { PlanetCore } from './PlanetCore';
|
|
4
|
-
/**
|
|
5
|
-
* ServiceProvider - The foundation for modular service registration.
|
|
6
|
-
*
|
|
7
|
-
* Service providers are the central place to configure your application.
|
|
8
|
-
* They bind services to the container and bootstrap application features.
|
|
9
|
-
*
|
|
10
|
-
* Lifecycle:
|
|
11
|
-
* 1. register() - Called during registration phase (sync or async)
|
|
12
|
-
* 2. boot() - Called after ALL providers have registered
|
|
13
|
-
*
|
|
14
|
-
* @since 1.0.0
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* class DatabaseServiceProvider extends ServiceProvider {
|
|
18
|
-
* register(container: Container) {
|
|
19
|
-
* container.singleton('db', () => new DatabaseManager());
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* boot(core: PlanetCore) {
|
|
23
|
-
* const db = core.container.make<DatabaseManager>('db');
|
|
24
|
-
* db.setDefaultConnection(core.config.get('database.default'));
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare abstract class ServiceProvider {
|
|
30
|
-
/**
|
|
31
|
-
* Reference to the application core instance.
|
|
32
|
-
* Set during provider registration.
|
|
33
|
-
*/
|
|
34
|
-
protected core?: PlanetCore;
|
|
35
|
-
/**
|
|
36
|
-
* Whether this provider should be deferred.
|
|
37
|
-
* Deferred providers are only registered when one of their
|
|
38
|
-
* provided services is actually requested from the container.
|
|
39
|
-
*/
|
|
40
|
-
deferred: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Get the services provided by this provider.
|
|
43
|
-
* Used for deferred loading - provider is only loaded when
|
|
44
|
-
* one of these services is requested.
|
|
45
|
-
*
|
|
46
|
-
* @returns Array of service keys this provider offers
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* provides(): string[] {
|
|
51
|
-
* return ['db', 'db.connection'];
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
provides(): string[];
|
|
56
|
-
/**
|
|
57
|
-
* Register bindings in the container.
|
|
58
|
-
*
|
|
59
|
-
* This method is called during the registration phase.
|
|
60
|
-
* **Warning**: Do not resolve services from other providers here,
|
|
61
|
-
* as they may not be registered yet.
|
|
62
|
-
*
|
|
63
|
-
* Supports both synchronous and asynchronous registration.
|
|
64
|
-
*
|
|
65
|
-
* @param container - The IoC container instance
|
|
66
|
-
*/
|
|
67
|
-
abstract register(container: Container): void | Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* Bootstrap any application services.
|
|
70
|
-
*
|
|
71
|
-
* This method is called after ALL providers have registered.
|
|
72
|
-
* You can safely resolve services from the container here.
|
|
73
|
-
*
|
|
74
|
-
* @param core - The PlanetCore application instance
|
|
75
|
-
*/
|
|
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>;
|
|
99
|
-
/**
|
|
100
|
-
* Set the core instance reference.
|
|
101
|
-
* Called internally by the application during registration.
|
|
102
|
-
*
|
|
103
|
-
* @internal
|
|
104
|
-
*/
|
|
105
|
-
setCore(core: PlanetCore): void;
|
|
106
|
-
/**
|
|
107
|
-
* Merge configuration from a value into the application config.
|
|
108
|
-
*
|
|
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.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* this.mergeConfig(config, 'database', {
|
|
120
|
-
* default: 'mysql',
|
|
121
|
-
* connections: { ... }
|
|
122
|
-
* });
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
protected mergeConfig(config: ConfigManager, key: string, value: unknown): void;
|
|
126
|
-
/**
|
|
127
|
-
* Merge configuration from an async loader.
|
|
128
|
-
* Useful for loading config from .ts files dynamically.
|
|
129
|
-
*
|
|
130
|
-
* @param config - The ConfigManager instance
|
|
131
|
-
* @param key - The configuration key
|
|
132
|
-
* @param loader - Async function that returns config value
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* ```typescript
|
|
136
|
-
* await this.mergeConfigFrom(config, 'database', async () => {
|
|
137
|
-
* return (await import('./config/database')).default;
|
|
138
|
-
* });
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
protected mergeConfigFrom(config: ConfigManager, key: string, loader: () => Promise<unknown>): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* Paths that should be published by the CLI.
|
|
144
|
-
* Maps source paths to destination paths.
|
|
145
|
-
*/
|
|
146
|
-
private static publishables;
|
|
147
|
-
/**
|
|
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.
|
|
152
|
-
*
|
|
153
|
-
* @param paths - A record mapping source paths to destination paths.
|
|
154
|
-
* @param group - Optional group name for selective publishing (e.g., 'config', 'views').
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* ```typescript
|
|
158
|
-
* this.publishes({
|
|
159
|
-
* './config/cache.ts': 'config/cache.ts',
|
|
160
|
-
* './views/errors': 'resources/views/errors'
|
|
161
|
-
* }, 'config');
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
protected publishes(paths: Record<string, string>, group?: string): void;
|
|
165
|
-
/**
|
|
166
|
-
* Get all publishable paths for a group.
|
|
167
|
-
*
|
|
168
|
-
* @param group - The group name (defaults to provider class name)
|
|
169
|
-
* @returns Map of source to destination paths
|
|
170
|
-
*/
|
|
171
|
-
static getPublishables(group?: string): Map<string, string>;
|
|
172
|
-
/**
|
|
173
|
-
* Get all publish groups.
|
|
174
|
-
*
|
|
175
|
-
* @returns Array of group names
|
|
176
|
-
*/
|
|
177
|
-
static getPublishGroups(): string[];
|
|
178
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Gravito } from '../engine/Gravito';
|
|
2
|
-
import type { GravitoContext, GravitoErrorHandler, GravitoHandler, GravitoMiddleware, GravitoNotFoundHandler, GravitoVariables, HttpMethod } from '../http/types';
|
|
3
|
-
import type { AdapterConfig, HttpAdapter, RouteDefinition } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* GravitoEngineAdapter - Optimized adapter using the Standalone Gravito Engine
|
|
6
|
-
*
|
|
7
|
-
* This adapter is exclusively for Bun and provides the best performance
|
|
8
|
-
* by using the specialized Gravito engine with object pooling and AOT routing.
|
|
9
|
-
*/
|
|
10
|
-
export declare class GravitoEngineAdapter<V extends GravitoVariables = GravitoVariables> implements HttpAdapter<V> {
|
|
11
|
-
readonly name = "gravito-engine";
|
|
12
|
-
readonly version = "1.0.0";
|
|
13
|
-
private engine;
|
|
14
|
-
constructor(config?: AdapterConfig);
|
|
15
|
-
get native(): Gravito;
|
|
16
|
-
route(method: HttpMethod, path: string, ...handlers: (GravitoHandler<V> | GravitoMiddleware<V>)[]): void;
|
|
17
|
-
routes(routes: RouteDefinition[]): void;
|
|
18
|
-
use(path: string, ...middleware: GravitoMiddleware<V>[]): void;
|
|
19
|
-
useGlobal(...middleware: GravitoMiddleware<V>[]): void;
|
|
20
|
-
mount(path: string, subAdapter: HttpAdapter<V>): void;
|
|
21
|
-
onError(handler: GravitoErrorHandler<V>): void;
|
|
22
|
-
onNotFound(handler: GravitoNotFoundHandler<V>): void;
|
|
23
|
-
fetch: (request: Request, _server?: unknown) => Response | Promise<Response>;
|
|
24
|
-
warmup(paths: string[]): Promise<void>;
|
|
25
|
-
createContext(_request: Request): GravitoContext<V>;
|
|
26
|
-
useScoped(scope: string, path: string, ...middleware: GravitoMiddleware<V>[]): void;
|
|
27
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Photon Adapter Implementation
|
|
3
|
-
*
|
|
4
|
-
* This adapter wraps Photon to implement the Gravito HttpAdapter interface.
|
|
5
|
-
* It serves as the default adapter and reference implementation for others.
|
|
6
|
-
*
|
|
7
|
-
* @module @gravito/core/adapters/photon
|
|
8
|
-
* @since 2.0.0
|
|
9
|
-
*/
|
|
10
|
-
import type { Context, Handler, MiddlewareHandler, Photon } from '@gravito/photon';
|
|
11
|
-
import { RequestScopeManager } from '../Container/RequestScopeManager';
|
|
12
|
-
import type { GravitoContext, GravitoErrorHandler, GravitoHandler, GravitoMiddleware, GravitoNotFoundHandler, GravitoRequest, GravitoVariables, HttpMethod, ProxyOptions, StatusCode } from '../http/types';
|
|
13
|
-
import type { AdapterConfig, HttpAdapter, RouteDefinition } from './types';
|
|
14
|
-
/**
|
|
15
|
-
* Wraps Photon's request object to implement GravitoRequest
|
|
16
|
-
*/
|
|
17
|
-
declare class PhotonRequestWrapper implements GravitoRequest {
|
|
18
|
-
photonCtx: Context;
|
|
19
|
-
/**
|
|
20
|
-
* Reset the wrapper for pooling
|
|
21
|
-
*/
|
|
22
|
-
reset(photonCtx: Context): void;
|
|
23
|
-
/**
|
|
24
|
-
* Create a proxied instance to delegate to Photon's request
|
|
25
|
-
*/
|
|
26
|
-
static create(photonCtx: Context): PhotonRequestWrapper;
|
|
27
|
-
/**
|
|
28
|
-
* Internal proxy wrapper
|
|
29
|
-
*/
|
|
30
|
-
static wrap(instance: PhotonRequestWrapper): PhotonRequestWrapper;
|
|
31
|
-
get url(): string;
|
|
32
|
-
get method(): string;
|
|
33
|
-
get path(): string;
|
|
34
|
-
param(name: string): string | undefined;
|
|
35
|
-
params(): Record<string, string>;
|
|
36
|
-
query(name: string): string | undefined;
|
|
37
|
-
queries(): Record<string, string | string[]>;
|
|
38
|
-
header(name: string): string | undefined;
|
|
39
|
-
header(): Record<string, string>;
|
|
40
|
-
json<T = unknown>(): Promise<T>;
|
|
41
|
-
text(): Promise<string>;
|
|
42
|
-
formData(): Promise<FormData>;
|
|
43
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
44
|
-
parseBody<T = unknown>(): Promise<T>;
|
|
45
|
-
get raw(): Request;
|
|
46
|
-
valid<T = unknown>(target: string): T;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Wraps Photon's context to implement GravitoContext
|
|
50
|
-
*/
|
|
51
|
-
declare class PhotonContextWrapper<V extends GravitoVariables = GravitoVariables> implements GravitoContext<V> {
|
|
52
|
-
private _req;
|
|
53
|
-
private photonCtx;
|
|
54
|
-
private _requestScope;
|
|
55
|
-
route: (name: string, params?: Record<string, any>, query?: Record<string, any>) => string;
|
|
56
|
-
/**
|
|
57
|
-
* Reset the wrapper for pooling
|
|
58
|
-
*/
|
|
59
|
-
reset(photonCtx: Context): void;
|
|
60
|
-
/**
|
|
61
|
-
* Create a proxied instance to enable object destructuring of context variables
|
|
62
|
-
*/
|
|
63
|
-
static create<V extends GravitoVariables = GravitoVariables>(photonCtx: Context): GravitoContext<V>;
|
|
64
|
-
/**
|
|
65
|
-
* Internal proxy wrapper
|
|
66
|
-
*/
|
|
67
|
-
static wrap<V extends GravitoVariables = GravitoVariables>(instance: PhotonContextWrapper<V>): GravitoContext<V>;
|
|
68
|
-
get req(): GravitoRequest;
|
|
69
|
-
get params(): Record<string, string>;
|
|
70
|
-
get query(): Record<string, string | string[]>;
|
|
71
|
-
get data(): unknown;
|
|
72
|
-
set data(value: unknown);
|
|
73
|
-
back(status?: 301 | 302 | 303 | 307 | 308): Response;
|
|
74
|
-
json<T>(data: T, status?: number): Response;
|
|
75
|
-
text(text: string, status?: number): Response;
|
|
76
|
-
html(html: string, status?: number): Response;
|
|
77
|
-
redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): Response;
|
|
78
|
-
body(data: BodyInit | null, status?: number): Response;
|
|
79
|
-
stream(stream: ReadableStream, status?: number): Response;
|
|
80
|
-
notFound(message?: string): Response;
|
|
81
|
-
forbidden(message?: string): Response;
|
|
82
|
-
unauthorized(message?: string): Response;
|
|
83
|
-
badRequest(message?: string): Response;
|
|
84
|
-
header(name: string): string | undefined;
|
|
85
|
-
header(name: string, value: string, options?: {
|
|
86
|
-
append?: boolean;
|
|
87
|
-
}): void;
|
|
88
|
-
status(code: StatusCode): void;
|
|
89
|
-
get<K extends keyof V>(key: K): V[K];
|
|
90
|
-
set<K extends keyof V>(key: K, value: V[K]): void;
|
|
91
|
-
get executionCtx(): ExecutionContext | undefined;
|
|
92
|
-
get env(): Record<string, unknown> | undefined;
|
|
93
|
-
get native(): Context;
|
|
94
|
-
forward(target: string, options?: ProxyOptions): Promise<Response>;
|
|
95
|
-
requestScope(): RequestScopeManager;
|
|
96
|
-
scoped<T>(key: string | symbol, factory: () => T): T;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Convert a GravitoHandler to a Photon Handler
|
|
100
|
-
*/
|
|
101
|
-
declare function toPhotonHandler<V extends GravitoVariables>(handler: GravitoHandler<V>): Handler;
|
|
102
|
-
/**
|
|
103
|
-
* Convert a GravitoMiddleware to a Photon MiddlewareHandler
|
|
104
|
-
*/
|
|
105
|
-
declare function toPhotonMiddleware<V extends GravitoVariables>(middleware: GravitoMiddleware<V>): MiddlewareHandler;
|
|
106
|
-
/**
|
|
107
|
-
* Default HTTP adapter using the optimized Gravito Core Engine.
|
|
108
|
-
*
|
|
109
|
-
* This adapter provides a consistent interface that can be
|
|
110
|
-
* swapped out for other implementations without changing application code.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```typescript
|
|
114
|
-
* import { GravitoAdapter } from '@gravito/core'
|
|
115
|
-
*
|
|
116
|
-
* const adapter = new GravitoAdapter()
|
|
117
|
-
*
|
|
118
|
-
* // Register routes
|
|
119
|
-
* adapter.route('get', '/hello', async (ctx) => {
|
|
120
|
-
* return ctx.json({ message: 'Hello, World!' })
|
|
121
|
-
* })
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
export declare class PhotonAdapter<V extends GravitoVariables = GravitoVariables> implements HttpAdapter<V> {
|
|
125
|
-
private config;
|
|
126
|
-
readonly name = "photon";
|
|
127
|
-
readonly version = "1.0.0";
|
|
128
|
-
private app;
|
|
129
|
-
constructor(config?: AdapterConfig, photonInstance?: unknown);
|
|
130
|
-
/**
|
|
131
|
-
* Get the underlying Photon app instance
|
|
132
|
-
*/
|
|
133
|
-
get native(): Photon;
|
|
134
|
-
/**
|
|
135
|
-
* Set the underlying Photon app instance
|
|
136
|
-
* Used by PlanetCore during initialization
|
|
137
|
-
*/
|
|
138
|
-
setNative(app: Photon): void;
|
|
139
|
-
route(method: HttpMethod, path: string, ...handlers: (GravitoHandler<V> | GravitoMiddleware<V>)[]): void;
|
|
140
|
-
routes(routes: RouteDefinition[]): void;
|
|
141
|
-
use(path: string, ...middleware: GravitoMiddleware<V>[]): void;
|
|
142
|
-
useGlobal(...middleware: GravitoMiddleware<V>[]): void;
|
|
143
|
-
useScoped(scope: string, path: string, ...middleware: GravitoMiddleware<V>[]): void;
|
|
144
|
-
mount(path: string, subAdapter: HttpAdapter<V>): void;
|
|
145
|
-
onError(handler: GravitoErrorHandler<V>): void;
|
|
146
|
-
onNotFound(handler: GravitoNotFoundHandler<V>): void;
|
|
147
|
-
/**
|
|
148
|
-
* Predictive Route Warming (JIT Optimization)
|
|
149
|
-
*/
|
|
150
|
-
warmup(paths: string[]): Promise<void>;
|
|
151
|
-
fetch: (request: Request, server?: unknown) => Response | Promise<Response>;
|
|
152
|
-
createContext(_request: Request): GravitoContext<V>;
|
|
153
|
-
init(): Promise<void>;
|
|
154
|
-
shutdown(): Promise<void>;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Create a new PhotonAdapter instance
|
|
158
|
-
*/
|
|
159
|
-
export declare function createPhotonAdapter<V extends GravitoVariables = GravitoVariables>(config?: AdapterConfig): PhotonAdapter<V>;
|
|
160
|
-
export { PhotonContextWrapper, PhotonRequestWrapper, toPhotonHandler, toPhotonMiddleware };
|
|
161
|
-
/**
|
|
162
|
-
* Rebranded alias for PhotonAdapter.
|
|
163
|
-
* @category Rebranding
|
|
164
|
-
*/
|
|
165
|
-
export declare const GravitoAdapter: typeof PhotonAdapter;
|
|
166
|
-
/**
|
|
167
|
-
* Rebranded alias for PhotonAdapter type.
|
|
168
|
-
* @category Rebranding
|
|
169
|
-
*/
|
|
170
|
-
export type GravitoAdapter<V extends GravitoVariables = GravitoVariables> = PhotonAdapter<V>;
|
|
171
|
-
/**
|
|
172
|
-
* Rebranded alias for createPhotonAdapter.
|
|
173
|
-
* @category Rebranding
|
|
174
|
-
*/
|
|
175
|
-
export declare const createGravitoAdapter: typeof createPhotonAdapter;
|