@gravito/echo 3.1.1 → 3.1.2

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.
Files changed (292) hide show
  1. package/README.md +24 -9
  2. package/dist/OrbitEcho.d.ts +76 -60
  3. package/dist/index.d.ts +31 -16
  4. package/dist/index.js +1 -1596
  5. package/dist/index.js.map +3 -28
  6. package/dist/{echo/src/middleware → middleware}/RequestBufferMiddleware.d.ts +3 -3
  7. package/dist/providers/GenericProvider.d.ts +37 -19
  8. package/dist/providers/GitHubProvider.d.ts +21 -13
  9. package/dist/providers/StripeProvider.d.ts +20 -13
  10. package/dist/providers/index.d.ts +14 -4
  11. package/dist/receive/SignatureValidator.d.ts +33 -1
  12. package/dist/receive/WebhookReceiver.d.ts +139 -22
  13. package/dist/receive/index.d.ts +0 -1
  14. package/dist/send/WebhookDispatcher.d.ts +159 -16
  15. package/dist/send/index.d.ts +0 -1
  16. package/dist/types.d.ts +669 -57
  17. package/package.json +5 -2
  18. package/dist/OrbitEcho.d.ts.map +0 -1
  19. package/dist/atlas/src/DB.d.ts +0 -348
  20. package/dist/atlas/src/OrbitAtlas.d.ts +0 -9
  21. package/dist/atlas/src/config/defineConfig.d.ts +0 -14
  22. package/dist/atlas/src/config/index.d.ts +0 -7
  23. package/dist/atlas/src/config/loadConfig.d.ts +0 -41
  24. package/dist/atlas/src/connection/Connection.d.ts +0 -112
  25. package/dist/atlas/src/connection/ConnectionManager.d.ts +0 -180
  26. package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +0 -54
  27. package/dist/atlas/src/drivers/BunSQLDriver.d.ts +0 -32
  28. package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +0 -118
  29. package/dist/atlas/src/drivers/MongoDBDriver.d.ts +0 -36
  30. package/dist/atlas/src/drivers/MySQLDriver.d.ts +0 -79
  31. package/dist/atlas/src/drivers/PostgresDriver.d.ts +0 -96
  32. package/dist/atlas/src/drivers/RedisDriver.d.ts +0 -43
  33. package/dist/atlas/src/drivers/SQLiteDriver.d.ts +0 -45
  34. package/dist/atlas/src/drivers/types.d.ts +0 -260
  35. package/dist/atlas/src/errors/index.d.ts +0 -45
  36. package/dist/atlas/src/grammar/Grammar.d.ts +0 -342
  37. package/dist/atlas/src/grammar/MongoGrammar.d.ts +0 -47
  38. package/dist/atlas/src/grammar/MySQLGrammar.d.ts +0 -54
  39. package/dist/atlas/src/grammar/NullGrammar.d.ts +0 -35
  40. package/dist/atlas/src/grammar/PostgresGrammar.d.ts +0 -62
  41. package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +0 -32
  42. package/dist/atlas/src/index.d.ts +0 -79
  43. package/dist/atlas/src/migration/Migration.d.ts +0 -64
  44. package/dist/atlas/src/migration/MigrationRepository.d.ts +0 -65
  45. package/dist/atlas/src/migration/Migrator.d.ts +0 -110
  46. package/dist/atlas/src/migration/index.d.ts +0 -6
  47. package/dist/atlas/src/observability/AtlasMetrics.d.ts +0 -33
  48. package/dist/atlas/src/observability/AtlasObservability.d.ts +0 -15
  49. package/dist/atlas/src/observability/AtlasTracer.d.ts +0 -12
  50. package/dist/atlas/src/observability/index.d.ts +0 -9
  51. package/dist/atlas/src/orm/Repository.d.ts +0 -247
  52. package/dist/atlas/src/orm/index.d.ts +0 -6
  53. package/dist/atlas/src/orm/model/DirtyTracker.d.ts +0 -121
  54. package/dist/atlas/src/orm/model/Model.d.ts +0 -458
  55. package/dist/atlas/src/orm/model/ModelRegistry.d.ts +0 -20
  56. package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +0 -150
  57. package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +0 -36
  58. package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +0 -92
  59. package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +0 -117
  60. package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +0 -64
  61. package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +0 -15
  62. package/dist/atlas/src/orm/model/concerns/index.d.ts +0 -12
  63. package/dist/atlas/src/orm/model/decorators.d.ts +0 -138
  64. package/dist/atlas/src/orm/model/errors.d.ts +0 -52
  65. package/dist/atlas/src/orm/model/index.d.ts +0 -10
  66. package/dist/atlas/src/orm/model/relationships.d.ts +0 -207
  67. package/dist/atlas/src/orm/model/types.d.ts +0 -12
  68. package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +0 -124
  69. package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +0 -54
  70. package/dist/atlas/src/orm/schema/index.d.ts +0 -6
  71. package/dist/atlas/src/orm/schema/types.d.ts +0 -85
  72. package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +0 -98
  73. package/dist/atlas/src/pool/PoolHealthChecker.d.ts +0 -91
  74. package/dist/atlas/src/pool/PoolStrategy.d.ts +0 -129
  75. package/dist/atlas/src/pool/PoolWarmer.d.ts +0 -92
  76. package/dist/atlas/src/query/Expression.d.ts +0 -60
  77. package/dist/atlas/src/query/NPlusOneDetector.d.ts +0 -10
  78. package/dist/atlas/src/query/QueryBuilder.d.ts +0 -643
  79. package/dist/atlas/src/query/RelationshipResolver.d.ts +0 -23
  80. package/dist/atlas/src/query/clauses/GroupByClause.d.ts +0 -51
  81. package/dist/atlas/src/query/clauses/HavingClause.d.ts +0 -70
  82. package/dist/atlas/src/query/clauses/JoinClause.d.ts +0 -87
  83. package/dist/atlas/src/query/clauses/LimitClause.d.ts +0 -82
  84. package/dist/atlas/src/query/clauses/OrderByClause.d.ts +0 -69
  85. package/dist/atlas/src/query/clauses/SelectClause.d.ts +0 -71
  86. package/dist/atlas/src/query/clauses/WhereClause.d.ts +0 -167
  87. package/dist/atlas/src/query/clauses/index.d.ts +0 -11
  88. package/dist/atlas/src/schema/Blueprint.d.ts +0 -276
  89. package/dist/atlas/src/schema/ColumnDefinition.d.ts +0 -154
  90. package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +0 -37
  91. package/dist/atlas/src/schema/MigrationGenerator.d.ts +0 -45
  92. package/dist/atlas/src/schema/Schema.d.ts +0 -131
  93. package/dist/atlas/src/schema/SchemaDiff.d.ts +0 -73
  94. package/dist/atlas/src/schema/TypeGenerator.d.ts +0 -57
  95. package/dist/atlas/src/schema/TypeWriter.d.ts +0 -42
  96. package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +0 -23
  97. package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +0 -26
  98. package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +0 -28
  99. package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +0 -97
  100. package/dist/atlas/src/schema/grammars/index.d.ts +0 -7
  101. package/dist/atlas/src/schema/index.d.ts +0 -8
  102. package/dist/atlas/src/seed/Factory.d.ts +0 -90
  103. package/dist/atlas/src/seed/Seeder.d.ts +0 -28
  104. package/dist/atlas/src/seed/SeederRunner.d.ts +0 -74
  105. package/dist/atlas/src/seed/index.d.ts +0 -6
  106. package/dist/atlas/src/sharding/ShardingManager.d.ts +0 -59
  107. package/dist/atlas/src/types/index.d.ts +0 -1182
  108. package/dist/atlas/src/utils/CursorEncoding.d.ts +0 -63
  109. package/dist/atlas/src/utils/levenshtein.d.ts +0 -9
  110. package/dist/core/src/Application.d.ts +0 -215
  111. package/dist/core/src/CommandKernel.d.ts +0 -33
  112. package/dist/core/src/ConfigManager.d.ts +0 -65
  113. package/dist/core/src/Container/RequestScopeManager.d.ts +0 -62
  114. package/dist/core/src/Container/RequestScopeMetrics.d.ts +0 -144
  115. package/dist/core/src/Container.d.ts +0 -153
  116. package/dist/core/src/ErrorHandler.d.ts +0 -66
  117. package/dist/core/src/Event.d.ts +0 -5
  118. package/dist/core/src/EventManager.d.ts +0 -123
  119. package/dist/core/src/GlobalErrorHandlers.d.ts +0 -47
  120. package/dist/core/src/GravitoServer.d.ts +0 -28
  121. package/dist/core/src/HookManager.d.ts +0 -591
  122. package/dist/core/src/Listener.d.ts +0 -4
  123. package/dist/core/src/Logger.d.ts +0 -20
  124. package/dist/core/src/PlanetCore.d.ts +0 -378
  125. package/dist/core/src/RequestContext.d.ts +0 -97
  126. package/dist/core/src/Route.d.ts +0 -36
  127. package/dist/core/src/Router.d.ts +0 -284
  128. package/dist/core/src/ServiceProvider.d.ts +0 -178
  129. package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +0 -27
  130. package/dist/core/src/adapters/PhotonAdapter.d.ts +0 -175
  131. package/dist/core/src/adapters/bun/BunContext.d.ts +0 -49
  132. package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +0 -31
  133. package/dist/core/src/adapters/bun/BunRequest.d.ts +0 -31
  134. package/dist/core/src/adapters/bun/RadixNode.d.ts +0 -19
  135. package/dist/core/src/adapters/bun/RadixRouter.d.ts +0 -31
  136. package/dist/core/src/adapters/bun/types.d.ts +0 -20
  137. package/dist/core/src/adapters/photon-types.d.ts +0 -73
  138. package/dist/core/src/adapters/types.d.ts +0 -235
  139. package/dist/core/src/cli/queue-commands.d.ts +0 -6
  140. package/dist/core/src/engine/AOTRouter.d.ts +0 -129
  141. package/dist/core/src/engine/FastContext.d.ts +0 -123
  142. package/dist/core/src/engine/Gravito.d.ts +0 -136
  143. package/dist/core/src/engine/MinimalContext.d.ts +0 -100
  144. package/dist/core/src/engine/analyzer.d.ts +0 -27
  145. package/dist/core/src/engine/constants.d.ts +0 -23
  146. package/dist/core/src/engine/index.d.ts +0 -26
  147. package/dist/core/src/engine/path.d.ts +0 -26
  148. package/dist/core/src/engine/pool.d.ts +0 -83
  149. package/dist/core/src/engine/types.d.ts +0 -146
  150. package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +0 -126
  151. package/dist/core/src/events/BackpressureManager.d.ts +0 -215
  152. package/dist/core/src/events/CircuitBreaker.d.ts +0 -229
  153. package/dist/core/src/events/DeadLetterQueue.d.ts +0 -219
  154. package/dist/core/src/events/EventBackend.d.ts +0 -12
  155. package/dist/core/src/events/EventOptions.d.ts +0 -204
  156. package/dist/core/src/events/EventPriorityQueue.d.ts +0 -301
  157. package/dist/core/src/events/FlowControlStrategy.d.ts +0 -109
  158. package/dist/core/src/events/IdempotencyCache.d.ts +0 -60
  159. package/dist/core/src/events/MessageQueueBridge.d.ts +0 -184
  160. package/dist/core/src/events/PriorityEscalationManager.d.ts +0 -82
  161. package/dist/core/src/events/RetryScheduler.d.ts +0 -104
  162. package/dist/core/src/events/WorkerPool.d.ts +0 -98
  163. package/dist/core/src/events/WorkerPoolConfig.d.ts +0 -153
  164. package/dist/core/src/events/WorkerPoolMetrics.d.ts +0 -65
  165. package/dist/core/src/events/aggregation/AggregationWindow.d.ts +0 -77
  166. package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +0 -135
  167. package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +0 -108
  168. package/dist/core/src/events/aggregation/EventBatcher.d.ts +0 -99
  169. package/dist/core/src/events/aggregation/types.d.ts +0 -117
  170. package/dist/core/src/events/index.d.ts +0 -25
  171. package/dist/core/src/events/observability/EventMetrics.d.ts +0 -132
  172. package/dist/core/src/events/observability/EventTracer.d.ts +0 -68
  173. package/dist/core/src/events/observability/EventTracing.d.ts +0 -161
  174. package/dist/core/src/events/observability/OTelEventMetrics.d.ts +0 -332
  175. package/dist/core/src/events/observability/ObservableHookManager.d.ts +0 -108
  176. package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +0 -76
  177. package/dist/core/src/events/observability/index.d.ts +0 -24
  178. package/dist/core/src/events/observability/metrics-types.d.ts +0 -16
  179. package/dist/core/src/events/types.d.ts +0 -134
  180. package/dist/core/src/exceptions/AuthenticationException.d.ts +0 -8
  181. package/dist/core/src/exceptions/AuthorizationException.d.ts +0 -8
  182. package/dist/core/src/exceptions/CircularDependencyException.d.ts +0 -9
  183. package/dist/core/src/exceptions/GravitoException.d.ts +0 -23
  184. package/dist/core/src/exceptions/HttpException.d.ts +0 -9
  185. package/dist/core/src/exceptions/ModelNotFoundException.d.ts +0 -10
  186. package/dist/core/src/exceptions/ValidationException.d.ts +0 -22
  187. package/dist/core/src/exceptions/index.d.ts +0 -7
  188. package/dist/core/src/health/HealthProvider.d.ts +0 -67
  189. package/dist/core/src/helpers/Arr.d.ts +0 -19
  190. package/dist/core/src/helpers/Str.d.ts +0 -23
  191. package/dist/core/src/helpers/data.d.ts +0 -25
  192. package/dist/core/src/helpers/errors.d.ts +0 -34
  193. package/dist/core/src/helpers/response.d.ts +0 -41
  194. package/dist/core/src/helpers.d.ts +0 -338
  195. package/dist/core/src/http/CookieJar.d.ts +0 -51
  196. package/dist/core/src/http/cookie.d.ts +0 -29
  197. package/dist/core/src/http/middleware/BodySizeLimit.d.ts +0 -16
  198. package/dist/core/src/http/middleware/Cors.d.ts +0 -24
  199. package/dist/core/src/http/middleware/Csrf.d.ts +0 -23
  200. package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +0 -28
  201. package/dist/core/src/http/middleware/SecurityHeaders.d.ts +0 -29
  202. package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -18
  203. package/dist/core/src/http/types.d.ts +0 -374
  204. package/dist/core/src/index.d.ts +0 -88
  205. package/dist/core/src/instrumentation/index.d.ts +0 -35
  206. package/dist/core/src/instrumentation/opentelemetry.d.ts +0 -178
  207. package/dist/core/src/instrumentation/types.d.ts +0 -182
  208. package/dist/core/src/observability/Metrics.d.ts +0 -244
  209. package/dist/core/src/observability/QueueDashboard.d.ts +0 -136
  210. package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +0 -350
  211. package/dist/core/src/reliability/RetryPolicy.d.ts +0 -217
  212. package/dist/core/src/reliability/index.d.ts +0 -6
  213. package/dist/core/src/router/ControllerDispatcher.d.ts +0 -12
  214. package/dist/core/src/router/RequestValidator.d.ts +0 -20
  215. package/dist/core/src/runtime.d.ts +0 -119
  216. package/dist/core/src/security/Encrypter.d.ts +0 -33
  217. package/dist/core/src/security/Hasher.d.ts +0 -29
  218. package/dist/core/src/testing/HttpTester.d.ts +0 -39
  219. package/dist/core/src/testing/TestResponse.d.ts +0 -78
  220. package/dist/core/src/testing/index.d.ts +0 -2
  221. package/dist/core/src/types/events.d.ts +0 -94
  222. package/dist/echo/src/OrbitEcho.d.ts +0 -115
  223. package/dist/echo/src/index.d.ts +0 -64
  224. package/dist/echo/src/providers/GenericProvider.d.ts +0 -53
  225. package/dist/echo/src/providers/GitHubProvider.d.ts +0 -35
  226. package/dist/echo/src/providers/StripeProvider.d.ts +0 -38
  227. package/dist/echo/src/providers/index.d.ts +0 -14
  228. package/dist/echo/src/receive/SignatureValidator.d.ts +0 -67
  229. package/dist/echo/src/receive/WebhookReceiver.d.ts +0 -185
  230. package/dist/echo/src/receive/index.d.ts +0 -2
  231. package/dist/echo/src/send/WebhookDispatcher.d.ts +0 -198
  232. package/dist/echo/src/send/index.d.ts +0 -1
  233. package/dist/echo/src/types.d.ts +0 -756
  234. package/dist/index.d.ts.map +0 -1
  235. package/dist/monitor/src/MonitorOrbit.d.ts +0 -43
  236. package/dist/monitor/src/config.d.ts +0 -106
  237. package/dist/monitor/src/health/HealthController.d.ts +0 -28
  238. package/dist/monitor/src/health/HealthRegistry.d.ts +0 -80
  239. package/dist/monitor/src/health/index.d.ts +0 -36
  240. package/dist/monitor/src/index.d.ts +0 -13
  241. package/dist/monitor/src/metrics/MetricsController.d.ts +0 -22
  242. package/dist/monitor/src/metrics/MetricsRegistry.d.ts +0 -136
  243. package/dist/monitor/src/metrics/index.d.ts +0 -11
  244. package/dist/monitor/src/tracing/TracingManager.d.ts +0 -97
  245. package/dist/monitor/src/tracing/index.d.ts +0 -10
  246. package/dist/photon/src/index.d.ts +0 -89
  247. package/dist/photon/src/middleware/binary.d.ts +0 -31
  248. package/dist/photon/src/middleware/htmx.d.ts +0 -39
  249. package/dist/photon/src/middleware/ratelimit-redis.d.ts +0 -50
  250. package/dist/photon/src/middleware/ratelimit.d.ts +0 -161
  251. package/dist/photon/src/openapi.d.ts +0 -19
  252. package/dist/providers/GenericProvider.d.ts.map +0 -1
  253. package/dist/providers/GitHubProvider.d.ts.map +0 -1
  254. package/dist/providers/StripeProvider.d.ts.map +0 -1
  255. package/dist/providers/index.d.ts.map +0 -1
  256. package/dist/receive/SignatureValidator.d.ts.map +0 -1
  257. package/dist/receive/WebhookReceiver.d.ts.map +0 -1
  258. package/dist/receive/index.d.ts.map +0 -1
  259. package/dist/send/WebhookDispatcher.d.ts.map +0 -1
  260. package/dist/send/index.d.ts.map +0 -1
  261. package/dist/types.d.ts.map +0 -1
  262. /package/dist/{echo/src/dlq → dlq}/DeadLetterQueue.d.ts +0 -0
  263. /package/dist/{echo/src/dlq → dlq}/MemoryDeadLetterQueue.d.ts +0 -0
  264. /package/dist/{echo/src/dlq → dlq}/index.d.ts +0 -0
  265. /package/dist/{echo/src/middleware → middleware}/index.d.ts +0 -0
  266. /package/dist/{echo/src/observability → observability}/index.d.ts +0 -0
  267. /package/dist/{echo/src/observability → observability}/logging/ConsoleEchoLogger.d.ts +0 -0
  268. /package/dist/{echo/src/observability → observability}/logging/EchoLogger.d.ts +0 -0
  269. /package/dist/{echo/src/observability → observability}/logging/index.d.ts +0 -0
  270. /package/dist/{echo/src/observability → observability}/metrics/MetricsProvider.d.ts +0 -0
  271. /package/dist/{echo/src/observability → observability}/metrics/NoopMetricsProvider.d.ts +0 -0
  272. /package/dist/{echo/src/observability → observability}/metrics/PrometheusMetricsProvider.d.ts +0 -0
  273. /package/dist/{echo/src/observability → observability}/metrics/index.d.ts +0 -0
  274. /package/dist/{echo/src/observability → observability}/tracing/NoopTracer.d.ts +0 -0
  275. /package/dist/{echo/src/observability → observability}/tracing/Tracer.d.ts +0 -0
  276. /package/dist/{echo/src/observability → observability}/tracing/index.d.ts +0 -0
  277. /package/dist/{echo/src/providers → providers}/LinearProvider.d.ts +0 -0
  278. /package/dist/{echo/src/providers → providers}/PaddleProvider.d.ts +0 -0
  279. /package/dist/{echo/src/providers → providers}/ShopifyProvider.d.ts +0 -0
  280. /package/dist/{echo/src/providers → providers}/SlackProvider.d.ts +0 -0
  281. /package/dist/{echo/src/providers → providers}/TwilioProvider.d.ts +0 -0
  282. /package/dist/{echo/src/providers → providers}/base/BaseProvider.d.ts +0 -0
  283. /package/dist/{echo/src/providers → providers}/base/HeaderUtils.d.ts +0 -0
  284. /package/dist/{echo/src/replay → replay}/WebhookReplayService.d.ts +0 -0
  285. /package/dist/{echo/src/replay → replay}/index.d.ts +0 -0
  286. /package/dist/{echo/src/resilience → resilience}/CircuitBreaker.d.ts +0 -0
  287. /package/dist/{echo/src/resilience → resilience}/index.d.ts +0 -0
  288. /package/dist/{echo/src/rotation → rotation}/KeyRotationManager.d.ts +0 -0
  289. /package/dist/{echo/src/rotation → rotation}/index.d.ts +0 -0
  290. /package/dist/{echo/src/storage → storage}/MemoryWebhookStore.d.ts +0 -0
  291. /package/dist/{echo/src/storage → storage}/WebhookStore.d.ts +0 -0
  292. /package/dist/{echo/src/storage → storage}/index.d.ts +0 -0
@@ -1,123 +0,0 @@
1
- /**
2
- * @fileoverview FastContext - Pooled Request Context
3
- *
4
- * Minimal, high-performance context implementation designed for object pooling.
5
- * Lazy parsing strategy: only parse what's actually accessed.
6
- *
7
- * @module @gravito/core/engine
8
- */
9
- import { RequestScopeManager } from '../Container/RequestScopeManager';
10
- import type { FastRequest, FastContext as IFastContext } from './types';
11
- /**
12
- * Lazy-parsed request wrapper
13
- *
14
- * Delays parsing of query params, headers, and body until accessed.
15
- * This is a key optimization for requests that don't need all data.
16
- */
17
- declare class FastRequestImpl implements FastRequest {
18
- private _request;
19
- private _params;
20
- private _path;
21
- private _routePattern?;
22
- private _url;
23
- private _query;
24
- private _headers;
25
- private _cachedJson;
26
- private _jsonParsed;
27
- private _cachedText;
28
- private _textParsed;
29
- private _cachedFormData;
30
- private _formDataParsed;
31
- private _cachedQueries;
32
- private _ctx;
33
- constructor(ctx: FastContext);
34
- /**
35
- * Initialize for new request
36
- */
37
- init(request: Request, params?: Record<string, string>, path?: string, routePattern?: string): this;
38
- /**
39
- * Reset for pooling
40
- */
41
- reset(): void;
42
- private checkReleased;
43
- get url(): string;
44
- get method(): string;
45
- get path(): string;
46
- get routePattern(): string | undefined;
47
- param(name: string): string | undefined;
48
- params(): Record<string, string>;
49
- private getUrl;
50
- query(name: string): string | undefined;
51
- queries(): Record<string, string | string[]>;
52
- header(name: string): string | undefined;
53
- headers(): Record<string, string>;
54
- json<T = unknown>(): Promise<T>;
55
- text(): Promise<string>;
56
- formData(): Promise<FormData>;
57
- get raw(): Request;
58
- }
59
- /**
60
- * FastContext - Pooled request context
61
- *
62
- * Designed for minimal memory allocation and maximum reuse.
63
- * All response helpers create Response objects directly without intermediate wrappers.
64
- */
65
- export declare class FastContext implements IFastContext {
66
- readonly req: FastRequestImpl;
67
- private _headers;
68
- _isReleased: boolean;
69
- private _requestScope;
70
- /**
71
- * Initialize context for a new request
72
- *
73
- * This is called when acquiring from the pool.
74
- */
75
- init(request: Request, params?: Record<string, string>, path?: string, routePattern?: string): this;
76
- /**
77
- * Reset context for pooling (Cleanup)
78
- *
79
- * This is called when releasing back to the pool.
80
- * Implements "Deep-Reset Protocol" and "Release Guard".
81
- */
82
- reset(): void;
83
- /**
84
- * Check if context is released
85
- */
86
- private checkReleased;
87
- json<T>(data: T, status?: number): Response;
88
- text(text: string, status?: number): Response;
89
- html(html: string, status?: number): Response;
90
- redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): Response;
91
- body(data: BodyInit | null, status?: number): Response;
92
- stream(stream: ReadableStream, status?: number): Response;
93
- notFound(message?: string): Response;
94
- forbidden(message?: string): Response;
95
- unauthorized(message?: string): Response;
96
- badRequest(message?: string): Response;
97
- forward(target: string, _options?: any): Promise<Response>;
98
- header(name: string): string | undefined;
99
- header(name: string, value: string): void;
100
- status(_code: number): void;
101
- private _store;
102
- get<T>(key: string): T;
103
- set(key: string, value: any): void;
104
- /**
105
- * Get the request-scoped service manager for this request.
106
- *
107
- * @returns The RequestScopeManager for this request.
108
- * @throws Error if called before init() or after reset().
109
- */
110
- requestScope(): RequestScopeManager;
111
- /**
112
- * Resolve a request-scoped service (convenience method).
113
- *
114
- * @template T - The service type.
115
- * @param key - The service key for caching.
116
- * @param factory - Factory function to create the service.
117
- * @returns The cached or newly created service instance.
118
- */
119
- scoped<T>(key: string | symbol, factory: () => T): T;
120
- route: (name: string, params?: any, query?: any) => string;
121
- get native(): this;
122
- }
123
- export {};
@@ -1,136 +0,0 @@
1
- /**
2
- * @fileoverview Gravito - High-Performance Web Engine for Bun
3
- *
4
- * The standalone engine optimized exclusively for Bun runtime.
5
- * 99% API-compatible with Hono, but faster through Bun-specific optimizations.
6
- *
7
- * Key optimizations:
8
- * 1. Object pooling for zero-allocation request handling
9
- * 2. AOT router with O(1) static route lookup
10
- * 3. Lazy parsing - only parse what's accessed
11
- * 4. Direct Bun.serve integration without wrapper layers
12
- *
13
- * @module @gravito/core/engine
14
- */
15
- import type { EngineOptions, ErrorHandler, Handler, Middleware, NotFoundHandler, RouteMetadata } from './types';
16
- /**
17
- * Gravito - The High-Performance Web Engine
18
- */
19
- export declare class Gravito {
20
- private router;
21
- private contextPool;
22
- private errorHandler?;
23
- private notFoundHandler?;
24
- /** @internal */
25
- staticRoutes: Map<string, RouteMetadata>;
26
- private isPureStaticApp;
27
- private compiledDynamicRoutes;
28
- /**
29
- * Create a new Gravito instance
30
- *
31
- * @param options - Engine configuration options
32
- */
33
- constructor(options?: EngineOptions);
34
- /**
35
- * Register a GET route
36
- *
37
- * @param path - Route path (e.g., '/users/:id')
38
- * @param handlers - Handler and optional middleware
39
- * @returns This instance for chaining
40
- */
41
- get(path: string, ...handlers: Handler[]): this;
42
- /**
43
- * Register a POST route
44
- */
45
- post(path: string, ...handlers: Handler[]): this;
46
- /**
47
- * Register a PUT route
48
- */
49
- put(path: string, ...handlers: Handler[]): this;
50
- /**
51
- * Register a DELETE route
52
- */
53
- delete(path: string, ...handlers: Handler[]): this;
54
- /**
55
- * Register a PDF route
56
- */
57
- patch(path: string, ...handlers: Handler[]): this;
58
- /**
59
- * Register an OPTIONS route
60
- */
61
- options(path: string, ...handlers: Handler[]): this;
62
- /**
63
- * Register a HEAD route
64
- */
65
- head(path: string, ...handlers: Handler[]): this;
66
- /**
67
- * Register a route for all HTTP methods
68
- */
69
- all(path: string, ...handlers: Handler[]): this;
70
- /**
71
- * Register global or path-based middleware
72
- */
73
- use(path: string, ...middleware: Middleware[]): this;
74
- use(...middleware: Middleware[]): this;
75
- /**
76
- * Mount a sub-application at a path prefix
77
- */
78
- route(path: string, app: Gravito): this;
79
- /**
80
- * Set custom error handler
81
- */
82
- onError(handler: ErrorHandler): this;
83
- /**
84
- * Set custom 404 handler
85
- */
86
- notFound(handler: NotFoundHandler): this;
87
- /**
88
- * Predictive Route Warming (JIT Optimization)
89
- *
90
- * Simulates requests to specified routes to trigger JIT compilation (FTL)
91
- * before real traffic arrives.
92
- *
93
- * @param paths List of paths to warm up (e.g. ['/api/users', '/health'])
94
- */
95
- warmup(paths: string[]): Promise<void>;
96
- /**
97
- * Handle an incoming request
98
- */
99
- fetch: (request: Request) => Promise<Response>;
100
- /**
101
- * Handle routes with middleware (async path)
102
- */
103
- private handleWithMiddleware;
104
- /**
105
- * Handle dynamic routes (Radix Tree lookup)
106
- */
107
- private handleDynamicRoute;
108
- /**
109
- * Sync error handler (for ultra-fast path)
110
- */
111
- private handleErrorSync;
112
- /**
113
- * Sync 404 handler (for ultra-fast path)
114
- */
115
- private handleNotFoundSync;
116
- /**
117
- * Collect middleware for a specific path
118
- */
119
- private collectMiddlewareForPath;
120
- /**
121
- * Compile routes for optimization
122
- */
123
- private compileRoutes;
124
- /**
125
- * Add a route to the router
126
- */
127
- private addRoute;
128
- /**
129
- * Execute middleware chain followed by handler
130
- */
131
- private executeMiddleware;
132
- /**
133
- * Handle errors (Async version for dynamic/middleware paths)
134
- */
135
- private handleError;
136
- }
@@ -1,100 +0,0 @@
1
- /**
2
- * @fileoverview MinimalContext - Ultra-lightweight Request Context
3
- *
4
- * Designed for zero-middleware static routes where pool overhead
5
- * exceeds the cost of creating a new object.
6
- *
7
- * Key difference from FastContext:
8
- * - No object pooling (direct instantiation is faster for simple cases)
9
- * - No Headers object reuse (creates inline)
10
- * - Minimal memory footprint
11
- *
12
- * @module @gravito/core/engine
13
- */
14
- import { RequestScopeManager } from '../Container/RequestScopeManager';
15
- import type { FastRequest, FastContext as IFastContext } from './types';
16
- /**
17
- * Minimal request wrapper
18
- */
19
- declare class MinimalRequest implements FastRequest {
20
- private readonly _request;
21
- private readonly _params;
22
- private readonly _path;
23
- private readonly _routePattern?;
24
- private _searchParams;
25
- private _cachedQueries;
26
- private _cachedJsonPromise;
27
- private _cachedTextPromise;
28
- private _cachedFormDataPromise;
29
- constructor(_request: Request, _params: Record<string, string>, _path: string, _routePattern?: string | undefined);
30
- get url(): string;
31
- get method(): string;
32
- get path(): string;
33
- get routePattern(): string | undefined;
34
- param(name: string): string | undefined;
35
- params(): Record<string, string>;
36
- /**
37
- * Lazy-initialize searchParams, only parse once
38
- */
39
- private getSearchParams;
40
- query(name: string): string | undefined;
41
- queries(): Record<string, string | string[]>;
42
- header(name: string): string | undefined;
43
- headers(): Record<string, string>;
44
- json<T = unknown>(): Promise<T>;
45
- text(): Promise<string>;
46
- formData(): Promise<FormData>;
47
- get raw(): Request;
48
- }
49
- /**
50
- * MinimalContext - Optimized for simple, fast responses
51
- *
52
- * Use when:
53
- * - No middleware
54
- * - Static routes
55
- * - Simple JSON/text responses
56
- * - No custom headers needed
57
- */
58
- export declare class MinimalContext implements IFastContext {
59
- readonly req: MinimalRequest;
60
- private _resHeaders;
61
- private _requestScope;
62
- constructor(request: Request, params: Record<string, string>, path: string, routePattern?: string);
63
- private getHeaders;
64
- json<T>(data: T, status?: number): Response;
65
- text(text: string, status?: number): Response;
66
- html(html: string, status?: number): Response;
67
- redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): Response;
68
- body(data: BodyInit | null, status?: number): Response;
69
- header(name: string): string | undefined;
70
- header(name: string, value: string): void;
71
- status(_code: number): void;
72
- stream(stream: ReadableStream, status?: number): Response;
73
- notFound(message?: string): Response;
74
- forbidden(message?: string): Response;
75
- unauthorized(message?: string): Response;
76
- badRequest(message?: string): Response;
77
- forward(target: string, _options?: any): Promise<Response>;
78
- get<T>(_key: string): T;
79
- set(_key: string, _value: any): void;
80
- /**
81
- * Get the request-scoped service manager for this request.
82
- *
83
- * @returns The RequestScopeManager for this request.
84
- */
85
- requestScope(): RequestScopeManager;
86
- /**
87
- * Resolve a request-scoped service (convenience method).
88
- *
89
- * @template T - The service type.
90
- * @param key - The service key for caching.
91
- * @param factory - Factory function to create the service.
92
- * @returns The cached or newly created service instance.
93
- */
94
- scoped<T>(key: string | symbol, factory: () => T): T;
95
- route: (name: string, params?: any, query?: any) => string;
96
- get native(): this;
97
- init(_request: Request, _params?: Record<string, string>, _path?: string): this;
98
- reset(): void;
99
- }
100
- export {};
@@ -1,27 +0,0 @@
1
- /**
2
- * Handler Static Analyzer (Elysia-inspired)
3
- *
4
- * Analyzes handler functions to determine what request properties
5
- * they access, allowing for optimized code paths.
6
- */
7
- /**
8
- * Represents the results of a static analysis performed on a handler function.
9
- *
10
- * @public
11
- * @since 3.0.0
12
- */
13
- export interface HandlerAnalysis {
14
- usesHeaders: boolean;
15
- usesQuery: boolean;
16
- usesBody: boolean;
17
- usesParams: boolean;
18
- isAsync: boolean;
19
- }
20
- /**
21
- * Analyze a handler function to detect what it accesses
22
- */
23
- export declare function analyzeHandler(handler: Function): HandlerAnalysis;
24
- /**
25
- * Determine optimal context type based on analysis
26
- */
27
- export declare function getOptimalContextType(analysis: HandlerAnalysis): 'minimal' | 'fast' | 'full';
@@ -1,23 +0,0 @@
1
- /**
2
- * @fileoverview Engine Constants & Cached Buffers
3
- *
4
- * Pre-allocated resources to minimize runtime allocation overhead.
5
- * Specifically targets Bun's zero-copy capabilities.
6
- */
7
- export declare const CACHED_RESPONSES: {
8
- readonly NOT_FOUND: Uint8Array<ArrayBuffer>;
9
- readonly INTERNAL_ERROR: Uint8Array<ArrayBuffer>;
10
- readonly OK: Uint8Array<ArrayBuffer>;
11
- readonly EMPTY: Uint8Array<ArrayBuffer>;
12
- };
13
- export declare const HEADERS: {
14
- readonly JSON: {
15
- readonly 'Content-Type': "application/json; charset=utf-8";
16
- };
17
- readonly TEXT: {
18
- readonly 'Content-Type': "text/plain; charset=utf-8";
19
- };
20
- readonly HTML: {
21
- readonly 'Content-Type': "text/html; charset=utf-8";
22
- };
23
- };
@@ -1,26 +0,0 @@
1
- /**
2
- * @fileoverview Gravito Core Engine - Public API
3
- *
4
- * The High-Performance Web Engine for Bun
5
- *
6
- * @module @gravito/core/engine
7
- * @packageDocumentation
8
- *
9
- * @example
10
- * ```typescript
11
- * import { Gravito } from '@gravito/core/engine'
12
- *
13
- * const app = new Gravito()
14
- *
15
- * app.get('/', (c) => c.json({ message: 'Hello, World!' }))
16
- *
17
- * export default app
18
- * ```
19
- */
20
- export { Gravito } from './Gravito';
21
- export type { EngineOptions, ErrorHandler, FastContext, FastRequest, Handler, Middleware, NotFoundHandler, RouteMatch, } from './types';
22
- export { AOTRouter } from './AOTRouter';
23
- export { FastContext as FastContextImpl } from './FastContext';
24
- export { MinimalContext } from './MinimalContext';
25
- export { extractPath } from './path';
26
- export { ObjectPool } from './pool';
@@ -1,26 +0,0 @@
1
- /**
2
- * @fileoverview Lightweight Path Utilities
3
- *
4
- * High-performance path extraction without creating URL objects.
5
- * Performance critical - every optimization matters.
6
- *
7
- * @module @gravito/core/engine
8
- */
9
- /**
10
- * Extract pathname from URL string without creating URL object
11
- *
12
- * @param url - Full URL string (e.g., "http://localhost:3000/api/users?id=1")
13
- * @returns pathname (e.g., "/api/users")
14
- *
15
- * @example
16
- * ```typescript
17
- * extractPath("http://localhost:3000/api/users?id=1") // "/api/users"
18
- * extractPath("https://example.com/") // "/"
19
- * ```
20
- */
21
- export declare function extractPath(url: string): string;
22
- /**
23
- * Extract pathname using simpler logic (alternative implementation)
24
- * Use this if the above doesn't cover edge cases
25
- */
26
- export declare function extractPathSimple(url: string): string;
@@ -1,83 +0,0 @@
1
- /**
2
- * @fileoverview Generic Object Pool Implementation
3
- *
4
- * High-performance object pooling to reduce GC pressure.
5
- * Implements "fixed pool + overflow fallback" strategy.
6
- *
7
- * @module @gravito/core/engine
8
- */
9
- /**
10
- * Generic object pool with fixed size and overflow handling
11
- *
12
- * @typeParam T - Type of objects to pool
13
- *
14
- * @example
15
- * ```typescript
16
- * const pool = new ObjectPool(
17
- * () => new MyObject(),
18
- * (obj) => obj.reset(),
19
- * 256
20
- * )
21
- *
22
- * const obj = pool.acquire()
23
- * try {
24
- * // Use object
25
- * } finally {
26
- * pool.release(obj)
27
- * }
28
- * ```
29
- */
30
- export declare class ObjectPool<T> {
31
- private pool;
32
- private readonly factory;
33
- private readonly reset;
34
- private readonly maxSize;
35
- /**
36
- * Create a new object pool
37
- *
38
- * @param factory - Function to create new objects
39
- * @param reset - Function to reset objects before reuse
40
- * @param maxSize - Maximum pool size (default: 256)
41
- */
42
- constructor(factory: () => T, reset: (obj: T) => void, maxSize?: number);
43
- /**
44
- * Acquire an object from the pool
45
- *
46
- * If the pool is empty, creates a new object (overflow strategy).
47
- * This ensures the pool never blocks under high load.
48
- *
49
- * @returns Object from pool or newly created
50
- */
51
- acquire(): T;
52
- /**
53
- * Release an object back to the pool
54
- *
55
- * If the pool is full, the object is discarded (will be GC'd).
56
- * This prevents unbounded memory growth.
57
- *
58
- * @param obj - Object to release
59
- */
60
- release(obj: T): void;
61
- /**
62
- * Clear all objects from the pool
63
- *
64
- * Useful for testing or when you need to force a clean slate.
65
- */
66
- clear(): void;
67
- /**
68
- * Get current pool size
69
- */
70
- get size(): number;
71
- /**
72
- * Get maximum pool size
73
- */
74
- get capacity(): number;
75
- /**
76
- * Pre-warm the pool by creating objects in advance
77
- *
78
- * This can reduce latency for the first N requests.
79
- *
80
- * @param count - Number of objects to pre-create
81
- */
82
- prewarm(count: number): void;
83
- }
@@ -1,146 +0,0 @@
1
- /**
2
- * @fileoverview Gravito Core Engine Types
3
- *
4
- * Minimal, high-performance types for the standalone engine.
5
- * These are intentionally simpler than the full framework types.
6
- *
7
- * @module @gravito/core/engine
8
- */
9
- import type { HttpMethod } from '../http/types';
10
- /**
11
- * FastContext - The pooled request context
12
- */
13
- export interface FastContext {
14
- /** Request accessor */
15
- readonly req: FastRequest;
16
- /** Response helpers */
17
- json<T>(data: T, status?: number): Response;
18
- text(text: string, status?: number): Response;
19
- html(html: string, status?: number): Response;
20
- redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): Response;
21
- body(data: BodyInit | null, status?: number): Response;
22
- stream(stream: ReadableStream, status?: number): Response;
23
- notFound(message?: string): Response;
24
- forbidden(message?: string): Response;
25
- unauthorized(message?: string): Response;
26
- badRequest(message?: string): Response;
27
- forward(target: string, options?: any): Promise<Response>;
28
- /** Header management */
29
- header(name: string): string | undefined;
30
- header(name: string, value: string): void;
31
- status(code: number): void;
32
- /** Context Variables */
33
- get<T>(key: string): T;
34
- set(key: string, value: any): void;
35
- /** Request Scope Management */
36
- requestScope(): any;
37
- scoped<T>(key: string | symbol, factory: () => T): T;
38
- /** Lifecycle helpers */
39
- route: (name: string, params?: any, query?: any) => string;
40
- readonly native: any;
41
- /** Internal initialization for pooling */
42
- init(request: Request, params?: Record<string, string>, path?: string, routePattern?: string): this;
43
- /** Internal cleanup for pooling */
44
- reset(): void;
45
- }
46
- /**
47
- * FastRequest - Minimal request interface
48
- */
49
- export interface FastRequest {
50
- /** Full URL */
51
- readonly url: string;
52
- /** HTTP method */
53
- readonly method: string;
54
- /** Path without query */
55
- readonly path: string;
56
- /**
57
- * Route pattern (e.g., /users/:id) for metrics labeling
58
- * Prevents high cardinality issues in monitoring systems
59
- */
60
- readonly routePattern?: string;
61
- /** Get route parameter */
62
- param(name: string): string | undefined;
63
- /** Get all route parameters */
64
- params(): Record<string, string>;
65
- /** Get query parameter */
66
- query(name: string): string | undefined;
67
- /** Get all query parameters */
68
- queries(): Record<string, string | string[]>;
69
- /** Get header */
70
- header(name: string): string | undefined;
71
- /** Get all headers */
72
- headers(): Record<string, string>;
73
- /** Parse JSON body */
74
- json<T = unknown>(): Promise<T>;
75
- /** Parse text body */
76
- text(): Promise<string>;
77
- /** Parse form data */
78
- formData(): Promise<FormData>;
79
- /** Raw Request object */
80
- readonly raw: Request;
81
- }
82
- /**
83
- * Route handler function
84
- */
85
- export type Handler = (ctx: FastContext) => Response | Promise<Response>;
86
- /**
87
- * Middleware function
88
- */
89
- export type Middleware = (ctx: FastContext, next: () => Promise<Response | undefined>) => Response | undefined | Promise<Response | undefined>;
90
- /**
91
- * Error handler function
92
- */
93
- export type ErrorHandler = (error: Error, ctx: FastContext) => Response | Promise<Response>;
94
- /**
95
- * Not found handler function
96
- */
97
- export type NotFoundHandler = (ctx: FastContext) => Response | Promise<Response>;
98
- /**
99
- * Route metadata for middleware management
100
- */
101
- export interface RouteMetadata {
102
- handler: Handler;
103
- middleware: Middleware[];
104
- compiled?: CompiledHandler;
105
- useMinimal?: boolean;
106
- compiledVersion?: number;
107
- }
108
- /**
109
- * Compiled handler function
110
- */
111
- export type CompiledHandler = (ctx: FastContext) => Promise<Response>;
112
- /**
113
- * Route match result from router
114
- */
115
- export interface RouteMatch {
116
- /** Matched handler */
117
- handler: Handler | null;
118
- /** Extracted route parameters */
119
- params: Record<string, string>;
120
- /** Middleware to execute */
121
- middleware: Middleware[];
122
- /** Optional stable route pattern for caching */
123
- routePattern?: string;
124
- }
125
- /**
126
- * Internal route node
127
- */
128
- export interface RouteNode {
129
- method: HttpMethod;
130
- path: string;
131
- handler: Handler;
132
- middleware: Middleware[];
133
- }
134
- /**
135
- * Engine configuration options
136
- */
137
- export interface EngineOptions {
138
- /** Context pool size (default: 256) */
139
- poolSize?: number;
140
- /** Enable route compilation optimization (default: true) */
141
- enableAOT?: boolean;
142
- /** Custom error handler */
143
- onError?: ErrorHandler;
144
- /** Custom 404 handler */
145
- onNotFound?: NotFoundHandler;
146
- }