@gravito/core 1.6.1 → 2.0.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.
Files changed (168) hide show
  1. package/README.md +100 -6
  2. package/README.zh-TW.md +101 -6
  3. package/dist/Application.d.ts +256 -0
  4. package/dist/CommandKernel.d.ts +33 -0
  5. package/dist/ConfigManager.d.ts +65 -0
  6. package/dist/Container/RequestScopeManager.d.ts +62 -0
  7. package/dist/Container/RequestScopeMetrics.d.ts +144 -0
  8. package/dist/Container.d.ts +153 -0
  9. package/dist/ErrorHandler.d.ts +66 -0
  10. package/dist/Event.d.ts +5 -0
  11. package/dist/EventManager.d.ts +123 -0
  12. package/dist/GlobalErrorHandlers.d.ts +47 -0
  13. package/dist/GravitoServer.d.ts +28 -0
  14. package/dist/HookManager.d.ts +435 -0
  15. package/dist/Listener.d.ts +4 -0
  16. package/dist/Logger.d.ts +20 -0
  17. package/dist/PlanetCore.d.ts +402 -0
  18. package/dist/RequestContext.d.ts +97 -0
  19. package/dist/Route.d.ts +36 -0
  20. package/dist/Router.d.ts +270 -0
  21. package/dist/ServiceProvider.d.ts +178 -0
  22. package/dist/adapters/GravitoEngineAdapter.d.ts +27 -0
  23. package/dist/adapters/bun/AdaptiveAdapter.d.ts +99 -0
  24. package/dist/adapters/bun/BunContext.d.ts +54 -0
  25. package/dist/adapters/bun/BunNativeAdapter.d.ts +66 -0
  26. package/dist/adapters/bun/BunRequest.d.ts +31 -0
  27. package/dist/adapters/bun/BunWebSocketHandler.d.ts +48 -0
  28. package/dist/adapters/bun/RadixNode.d.ts +19 -0
  29. package/dist/adapters/bun/RadixRouter.d.ts +32 -0
  30. package/dist/adapters/bun/index.d.ts +7 -0
  31. package/dist/adapters/bun/types.d.ts +20 -0
  32. package/dist/adapters/index.d.ts +12 -0
  33. package/dist/adapters/types.d.ts +235 -0
  34. package/dist/binary/BinaryUtils.d.ts +105 -0
  35. package/dist/binary/index.d.ts +5 -0
  36. package/dist/cli/queue-commands.d.ts +6 -0
  37. package/dist/compat/async-local-storage.browser.d.ts +9 -0
  38. package/dist/compat/async-local-storage.d.ts +7 -0
  39. package/dist/compat/crypto.browser.d.ts +5 -0
  40. package/dist/compat/crypto.d.ts +6 -0
  41. package/dist/compat.d.ts +23 -1
  42. package/dist/compat.js +3 -0
  43. package/dist/compat.js.map +9 -0
  44. package/dist/engine/AOTRouter.d.ts +139 -0
  45. package/dist/engine/FastContext.d.ts +141 -0
  46. package/dist/engine/Gravito.d.ts +131 -0
  47. package/dist/engine/MinimalContext.d.ts +102 -0
  48. package/dist/engine/analyzer.d.ts +113 -0
  49. package/dist/engine/constants.d.ts +23 -0
  50. package/dist/engine/index.d.ts +14 -910
  51. package/dist/engine/index.js +623 -622
  52. package/dist/engine/index.js.map +23 -0
  53. package/dist/engine/path.d.ts +26 -0
  54. package/dist/engine/pool.d.ts +83 -0
  55. package/dist/engine/types.d.ts +149 -0
  56. package/dist/error-handling/RequestScopeErrorContext.d.ts +126 -0
  57. package/dist/events/BackpressureManager.d.ts +215 -0
  58. package/dist/events/CircuitBreaker.d.ts +229 -0
  59. package/dist/events/DeadLetterQueue.d.ts +219 -0
  60. package/dist/events/EventBackend.d.ts +12 -0
  61. package/dist/events/EventOptions.d.ts +204 -0
  62. package/dist/events/EventPriorityQueue.d.ts +63 -0
  63. package/dist/events/FlowControlStrategy.d.ts +109 -0
  64. package/dist/events/IdempotencyCache.d.ts +60 -0
  65. package/dist/events/MessageQueueBridge.d.ts +184 -0
  66. package/dist/events/PriorityEscalationManager.d.ts +82 -0
  67. package/dist/events/RetryScheduler.d.ts +104 -0
  68. package/dist/events/WorkerPool.d.ts +98 -0
  69. package/dist/events/WorkerPoolConfig.d.ts +153 -0
  70. package/dist/events/WorkerPoolMetrics.d.ts +65 -0
  71. package/dist/events/aggregation/AggregationWindow.d.ts +77 -0
  72. package/dist/events/aggregation/DeduplicationManager.d.ts +135 -0
  73. package/dist/events/aggregation/EventAggregationManager.d.ts +108 -0
  74. package/dist/events/aggregation/EventBatcher.d.ts +99 -0
  75. package/dist/events/aggregation/index.d.ts +10 -0
  76. package/dist/events/aggregation/types.d.ts +117 -0
  77. package/dist/events/index.d.ts +26 -0
  78. package/dist/events/observability/EventMetrics.d.ts +132 -0
  79. package/dist/events/observability/EventTracer.d.ts +68 -0
  80. package/dist/events/observability/EventTracing.d.ts +161 -0
  81. package/dist/events/observability/OTelEventMetrics.d.ts +332 -0
  82. package/dist/events/observability/ObservableHookManager.d.ts +108 -0
  83. package/dist/events/observability/StreamWorkerMetrics.d.ts +76 -0
  84. package/dist/events/observability/index.d.ts +24 -0
  85. package/dist/events/observability/metrics-types.d.ts +16 -0
  86. package/dist/events/queue-core.d.ts +77 -0
  87. package/dist/events/task-executor.d.ts +51 -0
  88. package/dist/events/types.d.ts +134 -0
  89. package/dist/exceptions/AuthenticationException.d.ts +8 -0
  90. package/dist/exceptions/AuthorizationException.d.ts +8 -0
  91. package/dist/exceptions/CircularDependencyException.d.ts +9 -0
  92. package/dist/exceptions/GravitoException.d.ts +23 -0
  93. package/dist/exceptions/HttpException.d.ts +9 -0
  94. package/dist/exceptions/ModelNotFoundException.d.ts +10 -0
  95. package/dist/exceptions/ValidationException.d.ts +22 -0
  96. package/dist/exceptions/index.d.ts +7 -0
  97. package/dist/ffi/NativeAccelerator.d.ts +69 -0
  98. package/dist/ffi/NativeHasher.d.ts +139 -0
  99. package/dist/ffi/cbor-fallback.d.ts +96 -0
  100. package/dist/ffi/hash-fallback.d.ts +33 -0
  101. package/dist/ffi/index.d.ts +10 -0
  102. package/dist/ffi/index.js +131 -0
  103. package/dist/ffi/index.js.map +11 -0
  104. package/dist/ffi/types.d.ts +135 -0
  105. package/dist/health/HealthProvider.d.ts +67 -0
  106. package/dist/helpers/Arr.d.ts +19 -0
  107. package/dist/helpers/Str.d.ts +38 -0
  108. package/dist/helpers/data.d.ts +25 -0
  109. package/dist/helpers/errors.d.ts +34 -0
  110. package/dist/helpers/response.d.ts +41 -0
  111. package/dist/helpers.d.ts +338 -0
  112. package/dist/hooks/ActionManager.d.ts +132 -0
  113. package/dist/hooks/AsyncDetector.d.ts +84 -0
  114. package/dist/hooks/FilterManager.d.ts +71 -0
  115. package/dist/hooks/MigrationWarner.d.ts +24 -0
  116. package/dist/hooks/dlq-operations.d.ts +60 -0
  117. package/dist/hooks/index.d.ts +11 -0
  118. package/dist/hooks/types.d.ts +107 -0
  119. package/dist/http/CookieJar.d.ts +51 -0
  120. package/dist/http/cookie.d.ts +29 -0
  121. package/dist/http/index.d.ts +12 -0
  122. package/dist/{compat-CI8hiulX.d.cts → http/types.d.ts} +35 -16
  123. package/dist/index.browser.d.ts +34 -0
  124. package/dist/index.d.ts +60 -10981
  125. package/dist/index.js +10808 -11273
  126. package/dist/index.js.map +166 -0
  127. package/dist/observability/QueueDashboard.d.ts +136 -0
  128. package/dist/observability/contracts.d.ts +137 -0
  129. package/dist/observability/index.d.ts +13 -0
  130. package/dist/reliability/DeadLetterQueueManager.d.ts +349 -0
  131. package/dist/reliability/RetryPolicy.d.ts +217 -0
  132. package/dist/reliability/index.d.ts +6 -0
  133. package/dist/router/ControllerDispatcher.d.ts +12 -0
  134. package/dist/router/RequestValidator.d.ts +20 -0
  135. package/dist/runtime/adapter-bun.d.ts +12 -0
  136. package/dist/runtime/adapter-deno.d.ts +12 -0
  137. package/dist/runtime/adapter-node.d.ts +12 -0
  138. package/dist/runtime/adapter-unknown.d.ts +13 -0
  139. package/dist/runtime/archive.d.ts +17 -0
  140. package/dist/runtime/compression.d.ts +21 -0
  141. package/dist/runtime/deep-equals.d.ts +56 -0
  142. package/dist/runtime/detection.d.ts +22 -0
  143. package/dist/runtime/escape.d.ts +34 -0
  144. package/dist/runtime/index.browser.d.ts +20 -0
  145. package/dist/runtime/index.d.ts +44 -0
  146. package/dist/runtime/markdown.d.ts +44 -0
  147. package/dist/runtime/types.d.ts +436 -0
  148. package/dist/runtime-helpers.d.ts +67 -0
  149. package/dist/runtime.d.ts +11 -0
  150. package/dist/security/Encrypter.d.ts +33 -0
  151. package/dist/security/Hasher.d.ts +29 -0
  152. package/dist/testing/HttpTester.d.ts +39 -0
  153. package/dist/testing/TestResponse.d.ts +78 -0
  154. package/dist/testing/index.d.ts +2 -0
  155. package/dist/transpiler-utils.d.ts +170 -0
  156. package/dist/types/events.d.ts +94 -0
  157. package/dist/types.d.ts +13 -0
  158. package/package.json +25 -56
  159. package/src/ffi/native/cbor.c +1148 -0
  160. package/dist/Metrics-VOWWRNNR.js +0 -219
  161. package/dist/chunk-R5U7XKVJ.js +0 -16
  162. package/dist/compat-CI8hiulX.d.ts +0 -376
  163. package/dist/compat.cjs +0 -18
  164. package/dist/compat.d.cts +0 -1
  165. package/dist/engine/index.cjs +0 -1764
  166. package/dist/engine/index.d.cts +0 -922
  167. package/dist/index.cjs +0 -14906
  168. package/dist/index.d.cts +0 -11008
@@ -0,0 +1,60 @@
1
+ import type { DeadLetterQueue } from '../events/DeadLetterQueue';
2
+ import type { EventOptions } from '../events/EventOptions';
3
+ import type { DeadLetterQueueManager } from '../reliability/DeadLetterQueueManager';
4
+ /**
5
+ * DLQ 操作輔助函式模組。
6
+ *
7
+ * 提取自 HookManager 的 DLQ 管理邏輯,以降低 HookManager 複雜度。
8
+ * 這些函式接受所需依賴作為參數,便於測試與重用。
9
+ *
10
+ * @internal
11
+ */
12
+ /**
13
+ * 重新加入單一 DLQ 項目到事件佇列。
14
+ *
15
+ * @param dlqEntryId - DLQ 項目 ID
16
+ * @param dlq - 記憶體內 DLQ 實例
17
+ * @param requeue - 重新加入佇列的回調函式
18
+ * @returns 是否成功重新加入
19
+ */
20
+ export declare function requeueDLQEntry(dlqEntryId: string, dlq: DeadLetterQueue, requeue: (eventName: string, payload: unknown, options: EventOptions) => Promise<void>): Promise<boolean>;
21
+ /**
22
+ * 批次重新加入指定事件名稱的所有 DLQ 項目。
23
+ *
24
+ * @param eventName - 事件名稱
25
+ * @param dlq - 記憶體內 DLQ 實例
26
+ * @param requeue - 重新加入佇列的回調函式
27
+ * @returns 成功重新加入的項目數
28
+ */
29
+ export declare function requeueDLQBatch(eventName: string, dlq: DeadLetterQueue, requeue: (entryId: string) => Promise<boolean>): Promise<number>;
30
+ /**
31
+ * 建立 EventPriorityQueue 持久化 DLQ 處理器。
32
+ *
33
+ * @param persistentDlqManager - 持久化 DLQ 管理器
34
+ * @returns 持久化 DLQ 處理器函式
35
+ */
36
+ export declare function createPersistentDLQHandler(persistentDlqManager: DeadLetterQueueManager): (hook: string, args: unknown, options: EventOptions, error: Error, retryCount: number, _firstFailedAt: number) => Promise<void>;
37
+ /**
38
+ * 重新加入持久化 DLQ 單一項目到事件佇列。
39
+ *
40
+ * @param dlqId - 持久化 DLQ 項目 UUID
41
+ * @param persistentDlqManager - 持久化 DLQ 管理器
42
+ * @param doActionAsync - 重新加入佇列的回調函式
43
+ * @returns 是否成功重新加入
44
+ */
45
+ export declare function requeuePersistentDLQEntry(dlqId: string, persistentDlqManager: DeadLetterQueueManager, doActionAsync: (event: string, args: unknown, options: EventOptions) => Promise<void>): Promise<boolean>;
46
+ /**
47
+ * 批次重新加入持久化 DLQ 項目。
48
+ *
49
+ * @param filter - 過濾條件
50
+ * @param persistentDlqManager - 持久化 DLQ 管理器
51
+ * @returns 批次操作結果統計
52
+ */
53
+ export declare function requeuePersistentDLQBatch(filter: {
54
+ eventName?: string;
55
+ status?: 'pending' | 'requeued' | 'resolved' | 'abandoned';
56
+ } | undefined, persistentDlqManager: DeadLetterQueueManager): Promise<{
57
+ total: number;
58
+ succeeded: number;
59
+ failed: number;
60
+ }>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Hook subsystem 的公開匯出。
3
+ *
4
+ * 此 barrel file 匯出 hook 系統所有的型別定義和子模組。
5
+ * HookManager facade 已在 ../HookManager.ts 中,對外繼續透過 index.ts 匯出。
6
+ */
7
+ export { ActionManager } from './ActionManager';
8
+ export { AsyncDetector } from './AsyncDetector';
9
+ export { FilterManager } from './FilterManager';
10
+ export { MigrationWarner } from './MigrationWarner';
11
+ export type { ActionCallback, FilterCallback, HookManagerConfig, ListenerInfo, ListenerOptions, } from './types';
@@ -0,0 +1,107 @@
1
+ import type { CircuitBreakerOptions } from '../events/CircuitBreaker';
2
+ import type { EventBackend } from '../events/EventBackend';
3
+ import type { EventQueueConfig } from '../events/EventPriorityQueue';
4
+ /**
5
+ * Callback function for filters (transforms values).
6
+ * @public
7
+ */
8
+ export type FilterCallback<T = unknown> = (value: T, ...args: unknown[]) => Promise<T> | T;
9
+ /**
10
+ * Callback function for actions (side effects).
11
+ * @public
12
+ */
13
+ export type ActionCallback<TArgs = unknown> = (args: TArgs) => Promise<void> | void;
14
+ /**
15
+ * Options for listener registration.
16
+ * @public
17
+ */
18
+ export interface ListenerOptions {
19
+ /**
20
+ * Explicitly specify the listener type.
21
+ * - 'sync': Force synchronous dispatch for this listener
22
+ * - 'async': Force asynchronous dispatch for this listener
23
+ * - 'auto': Auto-detect based on function signature (default)
24
+ * @default 'auto'
25
+ */
26
+ type?: 'sync' | 'async' | 'auto';
27
+ /**
28
+ * Circuit breaker configuration for this listener.
29
+ */
30
+ circuitBreaker?: CircuitBreakerOptions;
31
+ }
32
+ /**
33
+ * Information about a registered listener.
34
+ * @public
35
+ */
36
+ export interface ListenerInfo {
37
+ /**
38
+ * The callback function.
39
+ */
40
+ callback: ActionCallback;
41
+ /**
42
+ * Whether the listener is considered async.
43
+ */
44
+ isAsync: boolean;
45
+ /**
46
+ * The explicit type override, if any.
47
+ */
48
+ typeOverride?: 'sync' | 'async' | 'auto';
49
+ }
50
+ /**
51
+ * Configuration for HookManager.
52
+ * @public
53
+ */
54
+ export interface HookManagerConfig {
55
+ /**
56
+ * Enable async event dispatch by default.
57
+ * When true, doAction() will automatically use async dispatch if any listener is async.
58
+ * @default false
59
+ */
60
+ asyncByDefault?: boolean;
61
+ /**
62
+ * Migration mode for backward compatibility.
63
+ * - 'sync': All events use synchronous dispatch (legacy mode)
64
+ * - 'hybrid': Auto-detect and use async for async listeners (recommended)
65
+ * - 'async': All events use async dispatch (future mode)
66
+ * @default 'sync'
67
+ */
68
+ migrationMode?: 'sync' | 'hybrid' | 'async';
69
+ /**
70
+ * Enable deprecation warnings for synchronous event dispatch.
71
+ * @default false
72
+ */
73
+ showDeprecationWarnings?: boolean;
74
+ /**
75
+ * Enable Dead Letter Queue for failed events.
76
+ * @default true
77
+ */
78
+ enableDLQ?: boolean;
79
+ /**
80
+ * Configuration for the event priority queue (Backpressure).
81
+ */
82
+ queue?: EventQueueConfig;
83
+ /**
84
+ * Custom event backend for distributed processing.
85
+ */
86
+ backend?: EventBackend;
87
+ /**
88
+ * Database connection for persistent DLQ (optional).
89
+ * If provided, failed events after max retries will be persisted to database.
90
+ */
91
+ db?: any;
92
+ /**
93
+ * Enable persistent DLQ for failed events (requires db).
94
+ * @default false
95
+ */
96
+ enablePersistentDLQ?: boolean;
97
+ /**
98
+ * Message Queue Bridge for distributed event processing via Bull Queue.
99
+ * When provided, enables dispatchQueued() method for routing events to Redis-backed queue.
100
+ */
101
+ messageQueueBridge?: any;
102
+ /**
103
+ * Event aggregation configuration (FS-102).
104
+ * Enables deduplication and micro-batching for improved throughput.
105
+ */
106
+ aggregation?: any;
107
+ }
@@ -0,0 +1,51 @@
1
+ import type { Encrypter } from '../security/Encrypter';
2
+ import type { GravitoContext } from './types';
3
+ /**
4
+ * Options for setting cookies
5
+ * @public
6
+ */
7
+ export interface CookieOptions {
8
+ path?: string;
9
+ domain?: string;
10
+ secure?: boolean;
11
+ httpOnly?: boolean;
12
+ sameSite?: 'Strict' | 'Lax' | 'None';
13
+ maxAge?: number;
14
+ expires?: Date;
15
+ encrypt?: boolean;
16
+ }
17
+ /**
18
+ * Utility for managing cookies (request/response/encryption).
19
+ * @public
20
+ */
21
+ export declare class CookieJar {
22
+ private encrypter?;
23
+ private queued;
24
+ constructor(encrypter?: Encrypter);
25
+ /**
26
+ * Parse cookies from a Cookie header string using Bun's native CookieMap
27
+ * @param header - The Cookie header value
28
+ * @returns Parsed cookies as key-value pairs
29
+ */
30
+ static parseCookies(header: string): Record<string, string>;
31
+ /**
32
+ * Queue a cookie to be sent with the response
33
+ */
34
+ queue(name: string, value: string, minutes?: number, options?: CookieOptions): void;
35
+ /**
36
+ * Make a cookie that lasts "forever" (5 years)
37
+ */
38
+ forever(name: string, value: string, options?: CookieOptions): void;
39
+ /**
40
+ * Expire a cookie
41
+ */
42
+ forget(name: string, options?: CookieOptions): void;
43
+ /**
44
+ * Serialize a cookie to a Set-Cookie header value using Bun's native Cookie API
45
+ */
46
+ private serializeCookie;
47
+ /**
48
+ * Attach queued cookies to the context
49
+ */
50
+ attach(c: GravitoContext): void;
51
+ }
@@ -0,0 +1,29 @@
1
+ import { type CookieOptions } from './CookieJar';
2
+ import type { GravitoContext } from './types';
3
+ /**
4
+ * Get a cookie value from the request
5
+ * @param c - Context object
6
+ * @param name - Cookie name
7
+ * @returns Cookie value or undefined
8
+ * @public
9
+ */
10
+ export declare function getCookie(c: GravitoContext, name: string): string | undefined;
11
+ /**
12
+ * Set a cookie in the response
13
+ * @param c - Context object
14
+ * @param name - Cookie name
15
+ * @param value - Cookie value
16
+ * @param options - Cookie options
17
+ * @public
18
+ */
19
+ export declare function setCookie(c: GravitoContext, name: string, value: string, options?: CookieOptions & {
20
+ maxAge?: number;
21
+ }): void;
22
+ /**
23
+ * Delete a cookie (expire it)
24
+ * @param c - Context object
25
+ * @param name - Cookie name
26
+ * @param options - Cookie options (path, domain, etc.)
27
+ * @public
28
+ */
29
+ export declare function deleteCookie(c: GravitoContext, name: string, options?: CookieOptions): void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @fileoverview HTTP Module
3
+ *
4
+ * Export all HTTP-related types, utilities, and components.
5
+ *
6
+ * @module @gravito/core/http
7
+ * @since 2.0.0
8
+ */
9
+ export type { CookieOptions } from './CookieJar';
10
+ export { CookieJar } from './CookieJar';
11
+ export { deleteCookie, getCookie, setCookie } from './cookie';
12
+ export type { ContentfulStatusCode, GravitoContext, GravitoErrorHandler, GravitoHandler, GravitoMiddleware, GravitoNext, GravitoNotFoundHandler, GravitoRequest, GravitoVariables, HttpMethod, StatusCode, ValidationTarget, } from './types';
@@ -16,15 +16,15 @@ declare global {
16
16
  /**
17
17
  * Standard HTTP methods supported by Gravito
18
18
  */
19
- type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
19
+ export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
20
20
  /**
21
21
  * HTTP status codes
22
22
  */
23
- type StatusCode = number;
23
+ export type StatusCode = number;
24
24
  /**
25
25
  * Content-bearing HTTP status codes (excludes 1xx, 204, 304)
26
26
  */
27
- type ContentfulStatusCode = Exclude<StatusCode, 100 | 101 | 102 | 103 | 204 | 304>;
27
+ export type ContentfulStatusCode = Exclude<StatusCode, 100 | 101 | 102 | 103 | 204 | 304>;
28
28
  /**
29
29
  * Base context variables available in every request
30
30
  * Orbits can extend this interface via module augmentation
@@ -39,7 +39,7 @@ type ContentfulStatusCode = Exclude<StatusCode, 100 | 101 | 102 | 103 | 204 | 30
39
39
  * }
40
40
  * ```
41
41
  */
42
- interface GravitoVariables {
42
+ export interface GravitoVariables {
43
43
  /**
44
44
  * The PlanetCore instance
45
45
  * @remarks Always available in PlanetCore-managed contexts
@@ -71,7 +71,7 @@ interface GravitoVariables {
71
71
  /**
72
72
  * Validated request data targets
73
73
  */
74
- type ValidationTarget = 'json' | 'query' | 'param' | 'header' | 'form' | 'cookie';
74
+ export type ValidationTarget = 'json' | 'query' | 'param' | 'header' | 'form' | 'cookie';
75
75
  /**
76
76
  * GravitoRequest - Unified request interface
77
77
  *
@@ -85,7 +85,7 @@ type ValidationTarget = 'json' | 'query' | 'param' | 'header' | 'form' | 'cookie
85
85
  * const body = await ctx.req.json<CreateUserDto>()
86
86
  * ```
87
87
  */
88
- interface GravitoRequest {
88
+ export interface GravitoRequest {
89
89
  /** Full request URL */
90
90
  readonly url: string;
91
91
  /** HTTP method (uppercase) */
@@ -106,6 +106,11 @@ interface GravitoRequest {
106
106
  * ```
107
107
  */
108
108
  readonly routePattern?: string;
109
+ /**
110
+ * Alias for routePattern (for Hono/Express compatibility)
111
+ * @deprecated Use `routePattern` instead
112
+ */
113
+ readonly routePath?: string;
109
114
  /**
110
115
  * Get a route parameter value
111
116
  * @param name - Parameter name (e.g., 'id' for route '/users/:id')
@@ -164,11 +169,17 @@ interface GravitoRequest {
164
169
  * @throws {Error} If validation was not performed for this target
165
170
  */
166
171
  valid<T = unknown>(target: ValidationTarget): T;
172
+ /**
173
+ * Store validated data for a specific source
174
+ * @param target - The validation target
175
+ * @param data - The validated data to store
176
+ */
177
+ setValidated(target: ValidationTarget, data: unknown): void;
167
178
  }
168
179
  /**
169
180
  * Options for request forwarding (Proxy)
170
181
  */
171
- interface ProxyOptions {
182
+ export interface ProxyOptions {
172
183
  /** Override or add request headers */
173
184
  headers?: Record<string, string>;
174
185
  /** Whether to keep the original Host header (default: false) */
@@ -196,9 +207,20 @@ interface ProxyOptions {
196
207
  * }
197
208
  * ```
198
209
  */
199
- interface GravitoContext<V extends GravitoVariables = GravitoVariables> {
210
+ export interface GravitoContext<V extends GravitoVariables = GravitoVariables> {
200
211
  /** The incoming request */
201
212
  readonly req: GravitoRequest;
213
+ /**
214
+ * The response object (for middleware introspection).
215
+ * Middleware can read response headers and status, or mutate the response.
216
+ *
217
+ * @remarks
218
+ * This property is mutable, allowing middleware to replace the response object.
219
+ * Example: `c.res = new Response(...)`
220
+ *
221
+ * May be undefined until a handler creates a response.
222
+ */
223
+ res?: Response;
202
224
  /**
203
225
  * Send a JSON response
204
226
  * @param data - Data to serialize as JSON
@@ -335,7 +357,7 @@ interface GravitoContext<V extends GravitoVariables = GravitoVariables> {
335
357
  /**
336
358
  * Next function for middleware chain
337
359
  */
338
- type GravitoNext = () => Promise<Response | undefined>;
360
+ export type GravitoNext = () => Promise<void>;
339
361
  /**
340
362
  * GravitoHandler - Standard route handler type
341
363
  *
@@ -348,7 +370,7 @@ type GravitoNext = () => Promise<Response | undefined>;
348
370
  * }
349
371
  * ```
350
372
  */
351
- type GravitoHandler<V extends GravitoVariables = GravitoVariables> = (ctx: GravitoContext<V>) => Response | Promise<Response>;
373
+ export type GravitoHandler<V extends GravitoVariables = GravitoVariables> = (ctx: GravitoContext<V>) => Response | Promise<Response>;
352
374
  /**
353
375
  * GravitoMiddleware - Standard middleware type
354
376
  *
@@ -359,18 +381,15 @@ type GravitoHandler<V extends GravitoVariables = GravitoVariables> = (ctx: Gravi
359
381
  * const logger: GravitoMiddleware = async (ctx, next) => {
360
382
  * console.log(`${ctx.req.method} ${ctx.req.path}`)
361
383
  * await next()
362
- * return undefined
363
384
  * }
364
385
  * ```
365
386
  */
366
- type GravitoMiddleware<V extends GravitoVariables = GravitoVariables> = (ctx: GravitoContext<V>, next: GravitoNext) => Response | undefined | Promise<Response | undefined | undefined>;
387
+ export type GravitoMiddleware<V extends GravitoVariables = GravitoVariables> = (ctx: GravitoContext<V>, next: GravitoNext) => Response | void | Promise<Response | void>;
367
388
  /**
368
389
  * Error handler type
369
390
  */
370
- type GravitoErrorHandler<V extends GravitoVariables = GravitoVariables> = (error: Error, ctx: GravitoContext<V>) => Response | Promise<Response>;
391
+ export type GravitoErrorHandler<V extends GravitoVariables = GravitoVariables> = (error: Error, ctx: GravitoContext<V>) => Response | Promise<Response>;
371
392
  /**
372
393
  * Not found handler type
373
394
  */
374
- type GravitoNotFoundHandler<V extends GravitoVariables = GravitoVariables> = (ctx: GravitoContext<V>) => Response | Promise<Response>;
375
-
376
- export type { ContentfulStatusCode as C, GravitoVariables as G, HttpMethod as H, ProxyOptions as P, StatusCode as S, ValidationTarget as V, GravitoHandler as a, GravitoMiddleware as b, GravitoErrorHandler as c, GravitoNotFoundHandler as d, GravitoContext as e, GravitoRequest as f, GravitoNext as g };
395
+ export type GravitoNotFoundHandler<V extends GravitoVariables = GravitoVariables> = (ctx: GravitoContext<V>) => Response | Promise<Response>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @gravito/core
3
+ *
4
+ * Browser-safe entry point for the core micro-kernel.
5
+ * Excludes Node.js specific modules like runtime adapters and FFI.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Current version of @gravito/core.
11
+ * @public
12
+ */
13
+ export declare const VERSION: string;
14
+ export { GravitoEngineAdapter } from './adapters/GravitoEngineAdapter';
15
+ export type { AdapterConfig, AdapterFactory, HttpAdapter, RouteDefinition } from './adapters/types';
16
+ export { isHttpAdapter } from './adapters/types';
17
+ export type { ContentfulStatusCode, GravitoContext, GravitoErrorHandler, GravitoHandler, GravitoMiddleware, GravitoNext, GravitoNotFoundHandler, GravitoRequest, GravitoVariables, HttpMethod, ProxyOptions, StatusCode, ValidationTarget, } from './http/types';
18
+ export { ConfigManager } from './ConfigManager';
19
+ export { Container, type Factory, type ServiceKey, type ServiceMap } from './Container';
20
+ export { registerQueueCommands } from './cli/queue-commands';
21
+ export { codeFromStatus, ErrorHandler, type ErrorHandlerDeps, messageFromStatus, } from './ErrorHandler';
22
+ export { EventManager } from './EventManager';
23
+ export * from './events';
24
+ export { HookManager, type HookManagerConfig } from './HookManager';
25
+ export { HealthProvider } from './health/HealthProvider';
26
+ export { Arr, abort, abortIf, abortUnless, app, blank, config, DumpDieError, dd, dump, env, filled, hasApp, logger, router, Str, setApp, tap, throwIf, throwUnless, value, } from './helpers';
27
+ export * from './helpers/data';
28
+ export * from './helpers/errors';
29
+ export * from './helpers/response';
30
+ export { CookieJar, type CookieOptions } from './http/CookieJar';
31
+ export { deleteCookie, getCookie, setCookie } from './http/cookie';
32
+ export { ServiceProvider } from './ServiceProvider';
33
+ export * from './runtime/index.browser';
34
+ export declare function defineConfig(config: any): any;