@guren/server 2.1.0 → 2.2.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.
Files changed (270) hide show
  1. package/dist/{McpServiceProvider-7BB5FPF3.js → McpServiceProvider-GRDYNEQG.js} +1 -1
  2. package/dist/auth/AuthManager.d.ts +30 -0
  3. package/dist/auth/AuthenticatableModel.d.ts +25 -0
  4. package/dist/auth/RequestAuthContext.d.ts +24 -0
  5. package/dist/auth/SessionGuard.d.ts +31 -0
  6. package/dist/auth/api-token.d.ts +299 -0
  7. package/dist/auth/email-verification.d.ts +203 -0
  8. package/dist/auth/index.d.ts +18 -110
  9. package/dist/auth/index.js +3 -1
  10. package/dist/auth/oauth/index.d.ts +239 -0
  11. package/dist/auth/password/DefaultHasher.d.ts +13 -0
  12. package/dist/auth/password/NodeHasher.d.ts +22 -0
  13. package/dist/auth/password/PasswordHasher.d.ts +5 -0
  14. package/dist/auth/password/ScryptHasher.d.ts +26 -0
  15. package/dist/auth/password-reset.d.ts +91 -0
  16. package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
  17. package/dist/auth/providers/UserProvider.d.ts +9 -0
  18. package/dist/auth/types.d.ts +102 -0
  19. package/dist/auth/utils.d.ts +39 -0
  20. package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
  21. package/dist/authorization/Policy.d.ts +77 -0
  22. package/dist/authorization/index.d.ts +5 -129
  23. package/dist/authorization/index.js +3 -1
  24. package/dist/authorization/middleware.d.ts +49 -0
  25. package/dist/authorization/types.d.ts +108 -0
  26. package/dist/broadcasting/BroadcastManager.d.ts +205 -0
  27. package/dist/broadcasting/channels/Channel.d.ts +28 -0
  28. package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
  29. package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
  30. package/dist/broadcasting/channels/index.d.ts +3 -0
  31. package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
  32. package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
  33. package/dist/broadcasting/drivers/index.d.ts +2 -0
  34. package/dist/broadcasting/index.d.ts +6 -233
  35. package/dist/broadcasting/index.js +1 -1
  36. package/dist/broadcasting/typed.d.ts +23 -0
  37. package/dist/broadcasting/types.d.ts +155 -0
  38. package/dist/cache/CacheManager.d.ts +87 -0
  39. package/dist/cache/TaggedCache.d.ts +62 -0
  40. package/dist/cache/index.d.ts +6 -233
  41. package/dist/cache/index.js +1 -1
  42. package/dist/cache/stores/FileStore.d.ts +64 -0
  43. package/dist/cache/stores/MemoryStore.d.ts +52 -0
  44. package/dist/cache/stores/RedisStore.d.ts +53 -0
  45. package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
  46. package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
  47. package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
  48. package/dist/{chunk-HONCNQXZ.js → chunk-BUQXOZCT.js} +97 -10
  49. package/dist/{chunk-DSDX3ASM.js → chunk-CDZUNKI6.js} +65 -83
  50. package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
  51. package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
  52. package/dist/{chunk-EARA7JM4.js → chunk-PZKUDFMW.js} +11 -8
  53. package/dist/console/Command.d.ts +179 -0
  54. package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
  55. package/dist/console/Input.d.ts +140 -0
  56. package/dist/console/Output.d.ts +161 -0
  57. package/dist/console/index.d.ts +5 -0
  58. package/dist/console/types.d.ts +106 -0
  59. package/dist/container/Container.d.ts +148 -0
  60. package/dist/container/ServiceProvider.d.ts +103 -0
  61. package/dist/container/bindings.d.ts +55 -0
  62. package/dist/container/defineModule.d.ts +88 -0
  63. package/dist/container/definePlugin.d.ts +62 -0
  64. package/dist/container/index.d.ts +8 -0
  65. package/dist/container/types.d.ts +73 -0
  66. package/dist/database/Factory.d.ts +82 -0
  67. package/dist/database/Seeder.d.ts +35 -0
  68. package/dist/database/SeederRunner.d.ts +41 -0
  69. package/dist/database/index.d.ts +4 -0
  70. package/dist/database/types.d.ts +49 -0
  71. package/dist/discovery/AutoDiscovery.d.ts +113 -0
  72. package/dist/discovery/index.d.ts +2 -0
  73. package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
  74. package/dist/docs-viewer/endpoint.d.ts +19 -0
  75. package/dist/encryption/Encrypter.d.ts +96 -0
  76. package/dist/encryption/Hash.d.ts +69 -0
  77. package/dist/encryption/MessageSigner.d.ts +21 -0
  78. package/dist/encryption/Random.d.ts +119 -0
  79. package/dist/encryption/app-key.d.ts +12 -0
  80. package/dist/encryption/index.d.ts +10 -222
  81. package/dist/encryption/signed-url.d.ts +9 -0
  82. package/dist/encryption/types.d.ts +103 -0
  83. package/dist/errors/ExceptionHandler.d.ts +118 -0
  84. package/dist/errors/HttpException.d.ts +106 -0
  85. package/dist/errors/debug-page.d.ts +22 -0
  86. package/dist/errors/error-page.d.ts +1 -0
  87. package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
  88. package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
  89. package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
  90. package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
  91. package/dist/errors/exceptions/ValidationException.d.ts +60 -0
  92. package/dist/errors/exceptions/index.d.ts +5 -0
  93. package/dist/errors/index.d.ts +5 -0
  94. package/dist/errors/types.d.ts +43 -0
  95. package/dist/events/Event.d.ts +33 -0
  96. package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
  97. package/dist/events/Listener.d.ts +79 -0
  98. package/dist/events/builtin.d.ts +73 -0
  99. package/dist/events/index.d.ts +6 -155
  100. package/dist/events/types.d.ts +48 -0
  101. package/dist/facades/index.d.ts +31 -0
  102. package/dist/health/HealthCheck.d.ts +34 -0
  103. package/dist/health/HealthManager.d.ts +53 -0
  104. package/dist/health/checks/CacheCheck.d.ts +35 -0
  105. package/dist/health/checks/CustomCheck.d.ts +23 -0
  106. package/dist/health/checks/DatabaseCheck.d.ts +33 -0
  107. package/dist/health/checks/MemoryCheck.d.ts +32 -0
  108. package/dist/health/checks/RedisCheck.d.ts +27 -0
  109. package/dist/health/checks/StorageCheck.d.ts +35 -0
  110. package/dist/health/checks/index.d.ts +12 -0
  111. package/dist/health/index.d.ts +5 -185
  112. package/dist/health/types.d.ts +52 -0
  113. package/dist/hot-reload/hot-disposables.d.ts +96 -0
  114. package/dist/hot-reload/testing.d.ts +14 -0
  115. package/dist/http/Application.d.ts +187 -0
  116. package/dist/http/FormRequest.d.ts +73 -0
  117. package/dist/http/dev-assets.d.ts +51 -0
  118. package/dist/http/dev-banner.d.ts +7 -0
  119. package/dist/http/inertia-assets.d.ts +22 -0
  120. package/dist/http/middleware/auth.d.ts +13 -0
  121. package/dist/http/middleware/capabilities.d.ts +22 -0
  122. package/dist/http/middleware/cors.d.ts +40 -0
  123. package/dist/http/middleware/csp.d.ts +59 -0
  124. package/dist/http/middleware/csrf.d.ts +121 -0
  125. package/dist/http/middleware/detect-locale.d.ts +65 -0
  126. package/dist/http/middleware/force-https.d.ts +34 -0
  127. package/dist/http/middleware/host-authorization.d.ts +24 -0
  128. package/dist/http/middleware/index.d.ts +19 -0
  129. package/dist/http/middleware/loopback-guard.d.ts +38 -0
  130. package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
  131. package/dist/http/middleware/redirect-safety.d.ts +29 -0
  132. package/dist/http/middleware/request-id.d.ts +19 -0
  133. package/dist/http/middleware/request-logging.d.ts +16 -0
  134. package/dist/http/middleware/security-headers.d.ts +49 -0
  135. package/dist/http/middleware/session.d.ts +93 -0
  136. package/dist/http/middleware/validation.d.ts +94 -0
  137. package/dist/http/public-assets.d.ts +15 -0
  138. package/dist/http/request.d.ts +24 -0
  139. package/dist/http/resources/CursorPaginator.d.ts +106 -0
  140. package/dist/http/resources/Paginator.d.ts +130 -0
  141. package/dist/http/resources/Resource.d.ts +67 -0
  142. package/dist/http/resources/ResourceCollection.d.ts +60 -0
  143. package/dist/http/resources/index.d.ts +6 -0
  144. package/dist/http/resources/types.d.ts +91 -0
  145. package/dist/http/validation/Validator.d.ts +128 -0
  146. package/dist/http/validation/index.d.ts +3 -0
  147. package/dist/http/validation/rules.d.ts +196 -0
  148. package/dist/http/validation/types.d.ts +96 -0
  149. package/dist/http/vite-dev-server.d.ts +27 -0
  150. package/dist/i18n/I18nManager.d.ts +114 -0
  151. package/dist/i18n/Translator.d.ts +80 -0
  152. package/dist/i18n/index.d.ts +6 -101
  153. package/dist/i18n/index.js +5 -3
  154. package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
  155. package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
  156. package/dist/i18n/pluralization.d.ts +19 -0
  157. package/dist/i18n/types.d.ts +106 -0
  158. package/dist/index.d.ts +69 -2605
  159. package/dist/index.js +332 -152
  160. package/dist/lambda/index.d.ts +17 -37
  161. package/dist/logging/LogManager.d.ts +83 -0
  162. package/dist/logging/Logger.d.ts +76 -0
  163. package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
  164. package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
  165. package/dist/logging/channels/FileChannel.d.ts +15 -0
  166. package/dist/logging/index.d.ts +8 -50
  167. package/dist/logging/types.d.ts +96 -0
  168. package/dist/mail/Mail.d.ts +138 -0
  169. package/dist/mail/MailManager.d.ts +79 -0
  170. package/dist/mail/address.d.ts +8 -0
  171. package/dist/mail/index.d.ts +7 -316
  172. package/dist/mail/transports/LogTransport.d.ts +19 -0
  173. package/dist/mail/transports/MemoryTransport.d.ts +84 -0
  174. package/dist/mail/transports/ResendTransport.d.ts +32 -0
  175. package/dist/mail/transports/SmtpTransport.d.ts +40 -0
  176. package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
  177. package/dist/mcp/McpServiceProvider.d.ts +17 -0
  178. package/dist/mcp/create-mcp-server.d.ts +144 -0
  179. package/dist/mcp/endpoint.d.ts +29 -0
  180. package/dist/mcp/index.d.ts +3 -185
  181. package/dist/mcp/index.js +1 -1
  182. package/dist/mvc/Controller.d.ts +326 -0
  183. package/dist/mvc/Router.d.ts +239 -0
  184. package/dist/mvc/ViewEngine.d.ts +11 -0
  185. package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
  186. package/dist/mvc/inertia/shared.d.ts +90 -0
  187. package/dist/mvc/mount-route.d.ts +10 -0
  188. package/dist/notifications/Notification.d.ts +99 -0
  189. package/dist/notifications/NotificationManager.d.ts +150 -0
  190. package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
  191. package/dist/notifications/channels/MailChannel.d.ts +45 -0
  192. package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
  193. package/dist/notifications/channels/SlackChannel.d.ts +73 -0
  194. package/dist/notifications/channels/index.d.ts +4 -0
  195. package/dist/notifications/index.d.ts +6 -322
  196. package/dist/notifications/notifiable-type.d.ts +10 -0
  197. package/dist/notifications/registry.d.ts +39 -0
  198. package/dist/notifications/types.d.ts +162 -0
  199. package/dist/providers/AuthServiceProvider.d.ts +7 -0
  200. package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
  201. package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
  202. package/dist/providers/CacheServiceProvider.d.ts +7 -0
  203. package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
  204. package/dist/providers/ErrorServiceProvider.d.ts +9 -0
  205. package/dist/providers/EventServiceProvider.d.ts +7 -0
  206. package/dist/providers/HealthServiceProvider.d.ts +7 -0
  207. package/dist/providers/I18nServiceProvider.d.ts +27 -0
  208. package/dist/providers/InertiaServiceProvider.d.ts +20 -0
  209. package/dist/providers/LogServiceProvider.d.ts +7 -0
  210. package/dist/providers/MailServiceProvider.d.ts +7 -0
  211. package/dist/providers/NotificationServiceProvider.d.ts +8 -0
  212. package/dist/providers/OAuthServiceProvider.d.ts +7 -0
  213. package/dist/providers/QueueServiceProvider.d.ts +7 -0
  214. package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
  215. package/dist/providers/StorageServiceProvider.d.ts +7 -0
  216. package/dist/providers/index.d.ts +17 -0
  217. package/dist/queue/FailedJobReporter.d.ts +40 -0
  218. package/dist/queue/Job.d.ts +140 -0
  219. package/dist/queue/QueueManager.d.ts +79 -0
  220. package/dist/queue/Worker.d.ts +99 -0
  221. package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
  222. package/dist/queue/drivers/RedisDriver.d.ts +96 -0
  223. package/dist/queue/drivers/SqsDriver.d.ts +108 -0
  224. package/dist/queue/drivers/SyncDriver.d.ts +28 -0
  225. package/dist/queue/index.d.ts +9 -453
  226. package/dist/queue/types.d.ts +171 -0
  227. package/dist/redis/RedisApiTokenStore.d.ts +78 -0
  228. package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
  229. package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
  230. package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
  231. package/dist/redis/RedisRateLimitStore.d.ts +77 -0
  232. package/dist/redis/RedisSessionStore.d.ts +61 -0
  233. package/dist/redis/client.d.ts +41 -0
  234. package/dist/redis/index.d.ts +14 -356
  235. package/dist/redis/index.js +5 -2
  236. package/dist/redis/scan-keys.d.ts +6 -0
  237. package/dist/runtime/index.d.ts +8 -95
  238. package/dist/runtime/index.js +1 -1
  239. package/dist/scheduling/CronParser.d.ts +37 -0
  240. package/dist/scheduling/Schedule.d.ts +229 -0
  241. package/dist/scheduling/ScheduledTask.d.ts +47 -0
  242. package/dist/scheduling/Scheduler.d.ts +99 -0
  243. package/dist/scheduling/index.d.ts +5 -41
  244. package/dist/scheduling/types.d.ts +97 -0
  245. package/dist/storage/StorageManager.d.ts +65 -0
  246. package/dist/storage/drivers/LocalDriver.d.ts +55 -0
  247. package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
  248. package/dist/storage/drivers/S3Driver.d.ts +72 -0
  249. package/dist/storage/index.d.ts +5 -197
  250. package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
  251. package/dist/support/error-polyfill.d.ts +9 -0
  252. package/dist/support/import-map.d.ts +13 -0
  253. package/dist/support/redirect-target.d.ts +11 -0
  254. package/dist/support/stack-frames.d.ts +56 -0
  255. package/dist/support/trim-slashes.d.ts +11 -0
  256. package/dist/vite/index.d.ts +2 -35
  257. package/dist/vite/index.js +0 -3
  258. package/dist/vite/plugin.d.ts +34 -0
  259. package/package.json +3 -3
  260. package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
  261. package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
  262. package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
  263. package/dist/I18nManager-BiSoczfV.d.ts +0 -275
  264. package/dist/LogManager-7mxnkaPM.d.ts +0 -256
  265. package/dist/Scheduler-pZiT8i57.d.ts +0 -471
  266. package/dist/api-token-D24VPr_E.d.ts +0 -663
  267. package/dist/app-key-CsBfRC_Q.d.ts +0 -214
  268. package/dist/email-verification-D60YF2ZO.d.ts +0 -329
  269. package/dist/index-9_Jzj5jo.d.ts +0 -7
  270. package/dist/validation-yAL53e1S.d.ts +0 -2610
@@ -0,0 +1,34 @@
1
+ import type { CheckResult } from './types.js';
2
+ /**
3
+ * Abstract base class for health checks.
4
+ */
5
+ export declare abstract class HealthCheck {
6
+ /**
7
+ * The name of this health check.
8
+ */
9
+ abstract readonly name: string;
10
+ /**
11
+ * Perform the health check.
12
+ */
13
+ abstract check(): Promise<CheckResult>;
14
+ /**
15
+ * Create a healthy result.
16
+ */
17
+ protected healthy(message?: string, meta?: Record<string, unknown>): CheckResult;
18
+ /**
19
+ * Create a degraded result.
20
+ */
21
+ protected degraded(message?: string, meta?: Record<string, unknown>): CheckResult;
22
+ /**
23
+ * Create an unhealthy result.
24
+ */
25
+ protected unhealthy(message?: string, meta?: Record<string, unknown>): CheckResult;
26
+ /**
27
+ * Create an unhealthy result from a caught error.
28
+ */
29
+ protected handleError(error: unknown, fallbackMessage: string): CheckResult;
30
+ /**
31
+ * Create a check result.
32
+ */
33
+ private result;
34
+ }
@@ -0,0 +1,53 @@
1
+ import type { Middleware } from '../http/middleware/index.js';
2
+ import type { HealthReport, CheckResult, HealthCheckOptions, HealthMiddlewareOptions } from './types.js';
3
+ import type { HealthCheck } from './HealthCheck.js';
4
+ /**
5
+ * Health check manager.
6
+ */
7
+ export declare class HealthManager {
8
+ private checks;
9
+ /**
10
+ * Register a health check.
11
+ */
12
+ register(check: HealthCheck, options?: HealthCheckOptions): this;
13
+ /**
14
+ * Unregister a health check.
15
+ */
16
+ unregister(name: string): this;
17
+ /**
18
+ * Get all registered check names.
19
+ */
20
+ getCheckNames(): string[];
21
+ /**
22
+ * Run all health checks.
23
+ */
24
+ check(): Promise<HealthReport>;
25
+ /**
26
+ * Run specific health checks.
27
+ */
28
+ checkOnly(names: string[]): Promise<HealthReport>;
29
+ /**
30
+ * Get a specific check result.
31
+ */
32
+ getCheck(name: string): Promise<CheckResult | null>;
33
+ /**
34
+ * Create middleware for health endpoints.
35
+ */
36
+ middleware(options?: HealthMiddlewareOptions): Middleware;
37
+ /**
38
+ * Run the specified checks.
39
+ */
40
+ private runChecks;
41
+ /**
42
+ * Run a single check with timeout.
43
+ */
44
+ private runCheck;
45
+ /**
46
+ * Create a timeout promise.
47
+ */
48
+ private timeoutPromise;
49
+ }
50
+ /**
51
+ * Create a health manager.
52
+ */
53
+ export declare function createHealthManager(): HealthManager;
@@ -0,0 +1,35 @@
1
+ import type { CheckResult } from '../types.js';
2
+ import { HealthCheck } from '../HealthCheck.js';
3
+ /**
4
+ * Cache store interface (minimal).
5
+ */
6
+ export interface CacheStoreInterface {
7
+ get<T>(key: string): Promise<T | null>;
8
+ put<T>(key: string, value: T, ttl?: number): Promise<void>;
9
+ forget(key: string): Promise<boolean>;
10
+ }
11
+ /**
12
+ * Options for cache health check.
13
+ */
14
+ export interface CacheCheckOptions {
15
+ /**
16
+ * Custom name for this check.
17
+ * @default 'cache'
18
+ */
19
+ name?: string;
20
+ /**
21
+ * Key to use for health check test.
22
+ * @default '__health_check__'
23
+ */
24
+ testKey?: string;
25
+ }
26
+ /**
27
+ * Health check for cache functionality.
28
+ */
29
+ export declare class CacheCheck extends HealthCheck {
30
+ readonly name: string;
31
+ private cache;
32
+ private testKey;
33
+ constructor(cache: CacheStoreInterface, options?: CacheCheckOptions);
34
+ check(): Promise<CheckResult>;
35
+ }
@@ -0,0 +1,23 @@
1
+ import type { CheckResult, HealthStatus } from '../types.js';
2
+ import { HealthCheck } from '../HealthCheck.js';
3
+ /**
4
+ * Callback for custom health check.
5
+ */
6
+ export type CustomCheckCallback = () => Promise<{
7
+ status: HealthStatus;
8
+ message?: string;
9
+ meta?: Record<string, unknown>;
10
+ }>;
11
+ /**
12
+ * Custom health check with callback.
13
+ */
14
+ export declare class CustomCheck extends HealthCheck {
15
+ readonly name: string;
16
+ private callback;
17
+ constructor(name: string, callback: CustomCheckCallback);
18
+ check(): Promise<CheckResult>;
19
+ }
20
+ /**
21
+ * Create a custom health check.
22
+ */
23
+ export declare function customCheck(name: string, callback: CustomCheckCallback): CustomCheck;
@@ -0,0 +1,33 @@
1
+ import type { CheckResult } from '../types.js';
2
+ import { HealthCheck } from '../HealthCheck.js';
3
+ /**
4
+ * Database connection interface (minimal).
5
+ */
6
+ export interface DatabaseConnection {
7
+ query(sql: string): Promise<unknown>;
8
+ }
9
+ /**
10
+ * Options for database health check.
11
+ */
12
+ export interface DatabaseCheckOptions {
13
+ /**
14
+ * Custom name for this check.
15
+ * @default 'database'
16
+ */
17
+ name?: string;
18
+ /**
19
+ * Custom query to execute.
20
+ * @default 'SELECT 1'
21
+ */
22
+ query?: string;
23
+ }
24
+ /**
25
+ * Health check for database connectivity.
26
+ */
27
+ export declare class DatabaseCheck extends HealthCheck {
28
+ readonly name: string;
29
+ private db;
30
+ private query;
31
+ constructor(db: DatabaseConnection, options?: DatabaseCheckOptions);
32
+ check(): Promise<CheckResult>;
33
+ }
@@ -0,0 +1,32 @@
1
+ import type { CheckResult } from '../types.js';
2
+ import { HealthCheck } from '../HealthCheck.js';
3
+ /**
4
+ * Options for memory health check.
5
+ */
6
+ export interface MemoryCheckOptions {
7
+ /**
8
+ * Custom name for this check.
9
+ * @default 'memory'
10
+ */
11
+ name?: string;
12
+ /**
13
+ * Memory threshold in MB. Above this is degraded.
14
+ * @default 512
15
+ */
16
+ thresholdMb?: number;
17
+ /**
18
+ * Critical memory threshold in MB. Above this is unhealthy.
19
+ * @default 1024
20
+ */
21
+ criticalThresholdMb?: number;
22
+ }
23
+ /**
24
+ * Health check for memory usage.
25
+ */
26
+ export declare class MemoryCheck extends HealthCheck {
27
+ readonly name: string;
28
+ private thresholdMb;
29
+ private criticalThresholdMb;
30
+ constructor(options?: MemoryCheckOptions);
31
+ check(): Promise<CheckResult>;
32
+ }
@@ -0,0 +1,27 @@
1
+ import type { CheckResult } from '../types.js';
2
+ import { HealthCheck } from '../HealthCheck.js';
3
+ /**
4
+ * Redis client interface (minimal).
5
+ */
6
+ export interface RedisClient {
7
+ ping(): Promise<string>;
8
+ }
9
+ /**
10
+ * Options for Redis health check.
11
+ */
12
+ export interface RedisCheckOptions {
13
+ /**
14
+ * Custom name for this check.
15
+ * @default 'redis'
16
+ */
17
+ name?: string;
18
+ }
19
+ /**
20
+ * Health check for Redis connectivity.
21
+ */
22
+ export declare class RedisCheck extends HealthCheck {
23
+ readonly name: string;
24
+ private redis;
25
+ constructor(redis: RedisClient, options?: RedisCheckOptions);
26
+ check(): Promise<CheckResult>;
27
+ }
@@ -0,0 +1,35 @@
1
+ import type { CheckResult } from '../types.js';
2
+ import { HealthCheck } from '../HealthCheck.js';
3
+ /**
4
+ * Storage driver interface (minimal).
5
+ */
6
+ export interface StorageDriverInterface {
7
+ put(path: string, contents: string | Buffer): Promise<void>;
8
+ get(path: string): Promise<Buffer | null>;
9
+ delete(path: string): Promise<boolean>;
10
+ }
11
+ /**
12
+ * Options for storage health check.
13
+ */
14
+ export interface StorageCheckOptions {
15
+ /**
16
+ * Custom name for this check.
17
+ * @default 'storage'
18
+ */
19
+ name?: string;
20
+ /**
21
+ * Test file path.
22
+ * @default '__health_check__.txt'
23
+ */
24
+ testPath?: string;
25
+ }
26
+ /**
27
+ * Health check for storage functionality.
28
+ */
29
+ export declare class StorageCheck extends HealthCheck {
30
+ readonly name: string;
31
+ private storage;
32
+ private testPath;
33
+ constructor(storage: StorageDriverInterface, options?: StorageCheckOptions);
34
+ check(): Promise<CheckResult>;
35
+ }
@@ -0,0 +1,12 @@
1
+ export { DatabaseCheck } from './DatabaseCheck.js';
2
+ export type { DatabaseConnection, DatabaseCheckOptions } from './DatabaseCheck.js';
3
+ export { RedisCheck } from './RedisCheck.js';
4
+ export type { RedisClient, RedisCheckOptions } from './RedisCheck.js';
5
+ export { CacheCheck } from './CacheCheck.js';
6
+ export type { CacheStoreInterface, CacheCheckOptions } from './CacheCheck.js';
7
+ export { StorageCheck } from './StorageCheck.js';
8
+ export type { StorageDriverInterface, StorageCheckOptions } from './StorageCheck.js';
9
+ export { MemoryCheck } from './MemoryCheck.js';
10
+ export type { MemoryCheckOptions } from './MemoryCheck.js';
11
+ export { CustomCheck, customCheck } from './CustomCheck.js';
12
+ export type { CustomCheckCallback } from './CustomCheck.js';
@@ -1,185 +1,5 @@
1
- import { a as HealthCheck, C as CheckResult, e as HealthStatus } from '../HealthManager-DUyMIzsZ.js';
2
- export { b as HealthCheckOptions, H as HealthManager, c as HealthMiddlewareOptions, d as HealthReport, f as createHealthManager } from '../HealthManager-DUyMIzsZ.js';
3
- import '../index-9_Jzj5jo.js';
4
- import 'hono';
5
-
6
- /**
7
- * Database connection interface (minimal).
8
- */
9
- interface DatabaseConnection {
10
- query(sql: string): Promise<unknown>;
11
- }
12
- /**
13
- * Options for database health check.
14
- */
15
- interface DatabaseCheckOptions {
16
- /**
17
- * Custom name for this check.
18
- * @default 'database'
19
- */
20
- name?: string;
21
- /**
22
- * Custom query to execute.
23
- * @default 'SELECT 1'
24
- */
25
- query?: string;
26
- }
27
- /**
28
- * Health check for database connectivity.
29
- */
30
- declare class DatabaseCheck extends HealthCheck {
31
- readonly name: string;
32
- private db;
33
- private query;
34
- constructor(db: DatabaseConnection, options?: DatabaseCheckOptions);
35
- check(): Promise<CheckResult>;
36
- }
37
-
38
- /**
39
- * Redis client interface (minimal).
40
- */
41
- interface RedisClient {
42
- ping(): Promise<string>;
43
- }
44
- /**
45
- * Options for Redis health check.
46
- */
47
- interface RedisCheckOptions {
48
- /**
49
- * Custom name for this check.
50
- * @default 'redis'
51
- */
52
- name?: string;
53
- }
54
- /**
55
- * Health check for Redis connectivity.
56
- */
57
- declare class RedisCheck extends HealthCheck {
58
- readonly name: string;
59
- private redis;
60
- constructor(redis: RedisClient, options?: RedisCheckOptions);
61
- check(): Promise<CheckResult>;
62
- }
63
-
64
- /**
65
- * Cache store interface (minimal).
66
- */
67
- interface CacheStoreInterface {
68
- get<T>(key: string): Promise<T | null>;
69
- put<T>(key: string, value: T, ttl?: number): Promise<void>;
70
- forget(key: string): Promise<boolean>;
71
- }
72
- /**
73
- * Options for cache health check.
74
- */
75
- interface CacheCheckOptions {
76
- /**
77
- * Custom name for this check.
78
- * @default 'cache'
79
- */
80
- name?: string;
81
- /**
82
- * Key to use for health check test.
83
- * @default '__health_check__'
84
- */
85
- testKey?: string;
86
- }
87
- /**
88
- * Health check for cache functionality.
89
- */
90
- declare class CacheCheck extends HealthCheck {
91
- readonly name: string;
92
- private cache;
93
- private testKey;
94
- constructor(cache: CacheStoreInterface, options?: CacheCheckOptions);
95
- check(): Promise<CheckResult>;
96
- }
97
-
98
- /**
99
- * Storage driver interface (minimal).
100
- */
101
- interface StorageDriverInterface {
102
- put(path: string, contents: string | Buffer): Promise<void>;
103
- get(path: string): Promise<Buffer | null>;
104
- delete(path: string): Promise<boolean>;
105
- }
106
- /**
107
- * Options for storage health check.
108
- */
109
- interface StorageCheckOptions {
110
- /**
111
- * Custom name for this check.
112
- * @default 'storage'
113
- */
114
- name?: string;
115
- /**
116
- * Test file path.
117
- * @default '__health_check__.txt'
118
- */
119
- testPath?: string;
120
- }
121
- /**
122
- * Health check for storage functionality.
123
- */
124
- declare class StorageCheck extends HealthCheck {
125
- readonly name: string;
126
- private storage;
127
- private testPath;
128
- constructor(storage: StorageDriverInterface, options?: StorageCheckOptions);
129
- check(): Promise<CheckResult>;
130
- }
131
-
132
- /**
133
- * Options for memory health check.
134
- */
135
- interface MemoryCheckOptions {
136
- /**
137
- * Custom name for this check.
138
- * @default 'memory'
139
- */
140
- name?: string;
141
- /**
142
- * Memory threshold in MB. Above this is degraded.
143
- * @default 512
144
- */
145
- thresholdMb?: number;
146
- /**
147
- * Critical memory threshold in MB. Above this is unhealthy.
148
- * @default 1024
149
- */
150
- criticalThresholdMb?: number;
151
- }
152
- /**
153
- * Health check for memory usage.
154
- */
155
- declare class MemoryCheck extends HealthCheck {
156
- readonly name: string;
157
- private thresholdMb;
158
- private criticalThresholdMb;
159
- constructor(options?: MemoryCheckOptions);
160
- check(): Promise<CheckResult>;
161
- }
162
-
163
- /**
164
- * Callback for custom health check.
165
- */
166
- type CustomCheckCallback = () => Promise<{
167
- status: HealthStatus;
168
- message?: string;
169
- meta?: Record<string, unknown>;
170
- }>;
171
- /**
172
- * Custom health check with callback.
173
- */
174
- declare class CustomCheck extends HealthCheck {
175
- readonly name: string;
176
- private callback;
177
- constructor(name: string, callback: CustomCheckCallback);
178
- check(): Promise<CheckResult>;
179
- }
180
- /**
181
- * Create a custom health check.
182
- */
183
- declare function customCheck(name: string, callback: CustomCheckCallback): CustomCheck;
184
-
185
- export { CacheCheck, type CacheCheckOptions, type CacheStoreInterface, CheckResult, CustomCheck, type CustomCheckCallback, DatabaseCheck, type DatabaseCheckOptions, type DatabaseConnection, HealthCheck, HealthStatus, MemoryCheck, type MemoryCheckOptions, RedisCheck, type RedisCheckOptions, type RedisClient, StorageCheck, type StorageCheckOptions, type StorageDriverInterface, customCheck };
1
+ export type { HealthStatus, CheckResult, HealthReport, HealthCheckOptions, HealthMiddlewareOptions, } from './types.js';
2
+ export { HealthCheck } from './HealthCheck.js';
3
+ export { HealthManager, createHealthManager } from './HealthManager.js';
4
+ export { DatabaseCheck, RedisCheck, CacheCheck, StorageCheck, MemoryCheck, CustomCheck, customCheck, } from './checks/index.js';
5
+ export type { DatabaseConnection, DatabaseCheckOptions, RedisClient, RedisCheckOptions, CacheStoreInterface, CacheCheckOptions, StorageDriverInterface, StorageCheckOptions, MemoryCheckOptions, CustomCheckCallback, } from './checks/index.js';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Health check status.
3
+ */
4
+ export type HealthStatus = 'healthy' | 'degraded' | 'unhealthy';
5
+ /**
6
+ * Result of a single health check.
7
+ */
8
+ export interface CheckResult {
9
+ name: string;
10
+ status: HealthStatus;
11
+ message?: string;
12
+ meta?: Record<string, unknown>;
13
+ duration: number;
14
+ }
15
+ /**
16
+ * Complete health report.
17
+ */
18
+ export interface HealthReport {
19
+ status: HealthStatus;
20
+ timestamp: Date;
21
+ checks: CheckResult[];
22
+ meta?: Record<string, unknown>;
23
+ }
24
+ /**
25
+ * Options for registering a health check.
26
+ */
27
+ export interface HealthCheckOptions {
28
+ /**
29
+ * Timeout in milliseconds for the check.
30
+ * @default 5000
31
+ */
32
+ timeout?: number;
33
+ /**
34
+ * If true, failure of this check will set overall status to unhealthy.
35
+ * @default false
36
+ */
37
+ critical?: boolean;
38
+ }
39
+ /**
40
+ * Options for health middleware.
41
+ */
42
+ export interface HealthMiddlewareOptions {
43
+ /**
44
+ * Only run these specific checks.
45
+ */
46
+ checks?: string[];
47
+ /**
48
+ * Include detailed check results.
49
+ * @default true
50
+ */
51
+ detailed?: boolean;
52
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Stops the timers a previous module evaluation left running.
3
+ *
4
+ * `bun --hot` re-runs the module graph inside the same process. Anything the
5
+ * previous evaluation built is dropped on the floor — but a `setInterval`
6
+ * callback keeps its owner reachable, so a store, manager, or scheduler that
7
+ * nothing references any more goes on firing forever. One extra timer per
8
+ * reload, each one retaining the dead object graph behind it.
9
+ *
10
+ * `globalThis` survives re-evaluation, so it is where the previous owner's
11
+ * teardown is parked — the same storage `Application.listen()` uses for the Bun
12
+ * and Vite dev servers, and the same approach `@guren/orm` uses for database
13
+ * connections. Bun does not expose `import.meta.hot` to `bun --hot` (checked on
14
+ * 1.3.14), so there is no reload hook to register with instead.
15
+ *
16
+ * This is deliberately not the ORM's registry with the names changed. Closing a
17
+ * connection is an async operation that can hang on a wedged socket, which is
18
+ * what forces that module's serialized claims and teardown timeout. Every
19
+ * teardown here is synchronous — `clearInterval`, and the `destroy()`/`stop()`
20
+ * methods wrapping it — so a claim can simply run the previous teardown inline
21
+ * and be done. Sharing the registries would buy machinery neither side needs in
22
+ * the same shape.
23
+ *
24
+ * Its twin is `packages/orm/src/active-connections.ts`. `parseFrameLocation` and
25
+ * `describeCallerFile`'s walk past a synthetic frame follow the same rule in
26
+ * both — a fix to either has to be carried to the other by hand. That has
27
+ * already failed once: this walk predates the ORM's, and the ORM kept keying
28
+ * handles to `unknown` in the meantime. Nothing forces the duplication —
29
+ * `@guren/server` already depends on `@guren/orm`, so this layer could live
30
+ * there and be imported here — it is only that the shared part is small next to
31
+ * the two packages' very different teardown semantics (see above). Extract the
32
+ * rest if it drifts again.
33
+ *
34
+ * One piece already went that way, for a reason worth recording: the debug error
35
+ * page turned out to read frames too, and had written its own, wrong version of
36
+ * the paren rule. That scan now lives in `../support/stack-frames`, imported by
37
+ * both readers in this package — the ORM's copy of it is still hand-synced like
38
+ * everything else here.
39
+ *
40
+ * An owner is identified by the file that built it plus a discriminator, so it
41
+ * is replaced only by a later evaluation of that same file. Keying on the exact
42
+ * line would be more precise, but a line number changes the moment anything
43
+ * above it does — adding an import would orphan the previous entry and leak the
44
+ * timer it was holding, during the very workflow this exists to fix. The file is
45
+ * stable across every edit that isn't a rename.
46
+ */
47
+ type Dispose = () => void;
48
+ /** Frees the slot an owner claimed, unless a newer owner has since taken it. */
49
+ export interface HotDisposableClaim {
50
+ release(): void;
51
+ }
52
+ /**
53
+ * Whether modules can be re-evaluated in this process.
54
+ *
55
+ * `bun --watch` restarts the process instead, which drops every timer with it,
56
+ * so `--hot` is the only mode that leaks. Everywhere else — production, tests,
57
+ * CLI commands, serverless — nothing is ever torn down automatically.
58
+ *
59
+ * Exported so callers can skip building the `Error` whose stack identifies them:
60
+ * capturing one formats the whole stack into a string, and outside `--hot` it
61
+ * would only be thrown away.
62
+ */
63
+ export declare function isHotReloadRuntime(): boolean;
64
+ /**
65
+ * The file that built the timer owner.
66
+ *
67
+ * `stack` must come from an `Error` constructed inside the constructor or
68
+ * factory itself, so frame 0 is `Error`, frame 1 is that function, and frame 2
69
+ * is the caller — or the first frame after it that names a real file, since the
70
+ * engine may have synthesized the frames in between. Only the path is kept: a
71
+ * reload re-runs the same file, but not necessarily at the same line.
72
+ */
73
+ export declare function describeCallerFile(stack: string | undefined): string | undefined;
74
+ /**
75
+ * Identity for a timer owner across hot reloads, or `undefined` when the owner
76
+ * must be left alone.
77
+ *
78
+ * `target` separates owners that share a call site — the name of a cache store,
79
+ * say — so one module building several does not collapse them into a slot where
80
+ * each new one stops the last.
81
+ */
82
+ export declare function hotReloadKey(scope: string, stack: string | undefined, target: string): string | undefined;
83
+ /**
84
+ * Records `dispose` as the live owner for this identity, stops whichever owner
85
+ * held it before, and hands back the claim so the new owner can give it up.
86
+ *
87
+ * Returns `undefined` outside `--hot`, or when the stack does not name a caller
88
+ * — the owner is then simply left alone, which is how things behaved before this
89
+ * registry existed.
90
+ *
91
+ * A teardown that throws is reported and swallowed: the replacement has already
92
+ * been built by the time this runs, and refusing to register it would leak the
93
+ * very timer this is here to stop.
94
+ */
95
+ export declare function claimHotDisposable(scope: string, stack: string | undefined, target: string, dispose: Dispose): HotDisposableClaim | undefined;
96
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Test-only helpers for the hot-reload registry.
3
+ *
4
+ * Not reachable from any tsup entry point, so it never ships — it lives beside
5
+ * the code it exercises because both test files in this directory need it and
6
+ * `@guren/server` has no shared test-support module.
7
+ */
8
+ /**
9
+ * Runs `callback` with the registry's `--hot` guard satisfied.
10
+ *
11
+ * The guard reads `process.execArgv`, which is also how the real thing detects
12
+ * `bun --hot`; there is no flag or injection seam to prefer over it.
13
+ */
14
+ export declare function withHotRuntime<T>(callback: () => T): T;