@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,36 @@
1
+ import { HttpException } from '../HttpException.js';
2
+ /**
3
+ * Not Found HTTP exception.
4
+ *
5
+ * Thrown when a requested resource cannot be found.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * throw new NotFoundHttpException()
10
+ * throw new NotFoundHttpException('User not found')
11
+ * throw NotFoundHttpException.forModel('User', 123)
12
+ * ```
13
+ */
14
+ export declare class NotFoundHttpException extends HttpException {
15
+ /**
16
+ * The type of resource that was not found.
17
+ */
18
+ readonly resourceType?: string;
19
+ /**
20
+ * The ID of the resource that was not found.
21
+ */
22
+ readonly resourceId?: string | number;
23
+ constructor(message?: string, resourceType?: string, resourceId?: string | number);
24
+ /**
25
+ * Create exception for a model not found.
26
+ */
27
+ static forModel(model: string, id: string | number): NotFoundHttpException;
28
+ /**
29
+ * Create exception for a route not found.
30
+ */
31
+ static forRoute(path: string): NotFoundHttpException;
32
+ /**
33
+ * Create exception for a resource not found.
34
+ */
35
+ static forResource(resource: string): NotFoundHttpException;
36
+ }
@@ -0,0 +1,60 @@
1
+ import { HttpException } from '../HttpException.js';
2
+ /**
3
+ * Validation exception.
4
+ *
5
+ * Thrown when request validation fails.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * throw new ValidationException({
10
+ * email: ['Email is required', 'Email must be valid'],
11
+ * password: ['Password is too short'],
12
+ * })
13
+ * ```
14
+ */
15
+ export declare class ValidationException extends HttpException {
16
+ constructor(errors: Record<string, string[]>, message?: string);
17
+ /**
18
+ * Create from Zod error.
19
+ */
20
+ static fromZodError(zodError: ZodLikeError): ValidationException;
21
+ /**
22
+ * Get errors for a specific field.
23
+ */
24
+ getFieldErrors(field: string): string[];
25
+ /**
26
+ * Check if a field has errors.
27
+ */
28
+ hasFieldError(field: string): boolean;
29
+ /**
30
+ * Get the first error for a field.
31
+ */
32
+ getFirstError(field: string): string | null;
33
+ /**
34
+ * Get all error messages as a flat array.
35
+ */
36
+ getAllMessages(): string[];
37
+ /**
38
+ * Create a ValidationException from a plain messages object.
39
+ *
40
+ * Useful for business-logic validation (e.g. duplicate email checks)
41
+ * where Zod is not involved.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * throw ValidationException.withMessages({ email: 'Email already registered' })
46
+ * throw ValidationException.withMessages({ email: ['Must be unique', 'Must be corporate'] })
47
+ * ```
48
+ */
49
+ static withMessages(messages: Record<string, string | string[]>): ValidationException;
50
+ }
51
+ /**
52
+ * Zod-like error interface for compatibility.
53
+ */
54
+ interface ZodLikeError {
55
+ issues: Array<{
56
+ path: PropertyKey[];
57
+ message: string;
58
+ }>;
59
+ }
60
+ export {};
@@ -0,0 +1,5 @@
1
+ export { ValidationException } from './ValidationException.js';
2
+ export { AuthenticationException } from './AuthenticationException.js';
3
+ export { AuthorizationException } from './AuthorizationException.js';
4
+ export { NotFoundHttpException } from './NotFoundHttpException.js';
5
+ export { MethodNotAllowedException } from './MethodNotAllowedException.js';
@@ -0,0 +1,5 @@
1
+ export type { ErrorResponse, ExceptionHandlerOptions, ExceptionReporter, ExceptionRenderer, ExceptionClass, RendererRegistration, } from './types.js';
2
+ export { HttpException } from './HttpException.js';
3
+ export { ExceptionHandler, createExceptionHandler, setExceptionHandler, getExceptionHandler, abort, abortIf, abortUnless, } from './ExceptionHandler.js';
4
+ export { ValidationException, AuthenticationException, AuthorizationException, NotFoundHttpException, MethodNotAllowedException, } from './exceptions/index.js';
5
+ export { renderErrorPage } from './error-page.js';
@@ -0,0 +1,43 @@
1
+ import type { Context } from '../http/Application.js';
2
+ /**
3
+ * Error response structure.
4
+ */
5
+ export interface ErrorResponse {
6
+ message: string;
7
+ errors?: Record<string, string[]>;
8
+ stack?: string;
9
+ exception?: string;
10
+ }
11
+ /**
12
+ * Exception handler options.
13
+ */
14
+ export interface ExceptionHandlerOptions {
15
+ /**
16
+ * Whether to show detailed error information.
17
+ * Default: true in development, false in production.
18
+ */
19
+ debug?: boolean;
20
+ /**
21
+ * Custom debug detection function.
22
+ */
23
+ isDebug?: () => boolean;
24
+ }
25
+ /**
26
+ * Exception reporter callback.
27
+ */
28
+ export type ExceptionReporter = (error: Error) => void | Promise<void>;
29
+ /**
30
+ * Exception renderer callback.
31
+ */
32
+ export type ExceptionRenderer<T extends Error = Error> = (error: T, ctx: Context) => Response | Promise<Response>;
33
+ /**
34
+ * Exception class type.
35
+ */
36
+ export type ExceptionClass<T extends Error = Error> = new (...args: any[]) => T;
37
+ /**
38
+ * Renderer registration.
39
+ */
40
+ export interface RendererRegistration {
41
+ errorClass: ExceptionClass;
42
+ renderer: ExceptionRenderer;
43
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Base class for all application events.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * class UserRegistered extends Event {
7
+ * constructor(
8
+ * public readonly userId: string,
9
+ * public readonly email: string
10
+ * ) {
11
+ * super()
12
+ * }
13
+ * }
14
+ *
15
+ * // Emit the event
16
+ * await events.emit(new UserRegistered('123', 'user@example.com'))
17
+ * ```
18
+ */
19
+ export declare abstract class Event {
20
+ /**
21
+ * Timestamp when the event was created.
22
+ */
23
+ readonly timestamp: Date;
24
+ /**
25
+ * Get the event name (class name by default).
26
+ * Override this to customize the event name.
27
+ */
28
+ static get eventName(): string;
29
+ /**
30
+ * Get the event name from an instance.
31
+ */
32
+ get eventName(): string;
33
+ }
@@ -1,85 +1,5 @@
1
- /**
2
- * Base class for all application events.
3
- *
4
- * @example
5
- * ```ts
6
- * class UserRegistered extends Event {
7
- * constructor(
8
- * public readonly userId: string,
9
- * public readonly email: string
10
- * ) {
11
- * super()
12
- * }
13
- * }
14
- *
15
- * // Emit the event
16
- * await events.emit(new UserRegistered('123', 'user@example.com'))
17
- * ```
18
- */
19
- declare abstract class Event {
20
- /**
21
- * Timestamp when the event was created.
22
- */
23
- readonly timestamp: Date;
24
- /**
25
- * Get the event name (class name by default).
26
- * Override this to customize the event name.
27
- */
28
- static get eventName(): string;
29
- /**
30
- * Get the event name from an instance.
31
- */
32
- get eventName(): string;
33
- }
34
-
35
- /**
36
- * Event class constructor type.
37
- */
38
- interface EventClass<T extends Event = Event> {
39
- new (...args: any[]): T;
40
- eventName: string;
41
- }
42
- /**
43
- * Event listener function type.
44
- */
45
- type EventListener<T extends Event = Event> = (event: T) => void | Promise<void>;
46
- /**
47
- * Options for registering an event listener.
48
- */
49
- interface ListenerOptions {
50
- /**
51
- * If true, the listener will be removed after the first invocation.
52
- * @default false
53
- */
54
- once?: boolean;
55
- /**
56
- * Priority of the listener. Higher values are executed first.
57
- * @default 0
58
- */
59
- priority?: number;
60
- /**
61
- * If specified, the listener will be dispatched to a queue instead of being executed immediately.
62
- * Requires the Queue system to be configured.
63
- */
64
- queue?: string;
65
- }
66
- /**
67
- * Internal representation of a registered listener.
68
- */
69
- interface RegisteredListener<T extends Event = Event> {
70
- listener: EventListener<T>;
71
- options: ListenerOptions;
72
- }
73
- /**
74
- * Event subscription handle for unsubscribing.
75
- */
76
- interface EventSubscription {
77
- /**
78
- * Unsubscribe the listener.
79
- */
80
- unsubscribe(): void;
81
- }
82
-
1
+ import type { Event } from './Event.js';
2
+ import type { EventClass, EventListener, ListenerOptions, EventSubscription } from './types.js';
83
3
  /**
84
4
  * Event manager for registering listeners and emitting events.
85
5
  *
@@ -102,7 +22,7 @@ interface EventSubscription {
102
22
  * await events.emit(new UserRegistered('123', 'user@example.com'))
103
23
  * ```
104
24
  */
105
- declare class EventManager {
25
+ export declare class EventManager {
106
26
  private readonly listeners;
107
27
  /**
108
28
  * Queue dispatcher function (set when Queue system is integrated).
@@ -202,6 +122,4 @@ declare class EventManager {
202
122
  /**
203
123
  * Create a new EventManager instance.
204
124
  */
205
- declare function createEventManager(): EventManager;
206
-
207
- export { EventManager as E, type ListenerOptions as L, type RegisteredListener as R, Event as a, type EventClass as b, type EventListener as c, type EventSubscription as d, createEventManager as e };
125
+ export declare function createEventManager(): EventManager;
@@ -0,0 +1,79 @@
1
+ import type { Event } from './Event.js';
2
+ import type { EventClass } from './types.js';
3
+ /**
4
+ * Base class for event listeners.
5
+ * Extend this class to create reusable, class-based event listeners.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * class SendWelcomeEmail extends Listener<UserRegistered> {
10
+ * static event = UserRegistered
11
+ * static shouldQueue = true
12
+ * static queue = 'emails'
13
+ *
14
+ * async handle(event: UserRegistered): Promise<void> {
15
+ * await mail.to(event.email).subject('Welcome!').send()
16
+ * }
17
+ *
18
+ * shouldHandle(event: UserRegistered): boolean {
19
+ * // Only send to non-admin users
20
+ * return !event.isAdmin
21
+ * }
22
+ * }
23
+ * ```
24
+ */
25
+ export declare abstract class Listener<T extends Event = Event> {
26
+ /**
27
+ * The event class this listener handles.
28
+ * Must be set by subclasses.
29
+ */
30
+ static event: EventClass;
31
+ /**
32
+ * Whether this listener should be queued instead of executed immediately.
33
+ * @default false
34
+ */
35
+ static shouldQueue: boolean;
36
+ /**
37
+ * The queue name to dispatch to when shouldQueue is true.
38
+ * @default 'default'
39
+ */
40
+ static queue: string;
41
+ /**
42
+ * Priority of this listener. Higher values are executed first.
43
+ * @default 0
44
+ */
45
+ static priority: number;
46
+ /**
47
+ * Handle the event.
48
+ * This method must be implemented by subclasses.
49
+ *
50
+ * @param event - The event instance
51
+ */
52
+ abstract handle(event: T): void | Promise<void>;
53
+ /**
54
+ * Determine if this listener should handle the event.
55
+ * Override this method to conditionally handle events.
56
+ *
57
+ * @param event - The event instance
58
+ * @returns true if the listener should handle the event
59
+ */
60
+ shouldHandle?(event: T): boolean;
61
+ /**
62
+ * Called when the listener fails to handle the event.
63
+ * Override this method to handle errors.
64
+ *
65
+ * @param event - The event instance
66
+ * @param error - The error that occurred
67
+ */
68
+ failed?(event: T, error: Error): void | Promise<void>;
69
+ }
70
+ /**
71
+ * Listener class constructor type.
72
+ */
73
+ export interface ListenerClass<T extends Event = Event> {
74
+ new (): Listener<T>;
75
+ event: EventClass<T>;
76
+ shouldQueue: boolean;
77
+ queue: string;
78
+ priority: number;
79
+ }
@@ -0,0 +1,73 @@
1
+ import { Event } from './Event.js';
2
+ /**
3
+ * Emitted when an HTTP request is received.
4
+ */
5
+ export declare class RequestReceived extends Event {
6
+ readonly method: string;
7
+ readonly path: string;
8
+ readonly requestId?: string | undefined;
9
+ constructor(method: string, path: string, requestId?: string | undefined);
10
+ }
11
+ /**
12
+ * Emitted when an HTTP request has finished processing.
13
+ */
14
+ export declare class RequestFinished extends Event {
15
+ readonly method: string;
16
+ readonly path: string;
17
+ readonly status: number;
18
+ readonly durationMs: number;
19
+ readonly requestId?: string | undefined;
20
+ constructor(method: string, path: string, status: number, durationMs: number, requestId?: string | undefined);
21
+ }
22
+ /**
23
+ * Emitted when a user successfully authenticates.
24
+ */
25
+ export declare class UserAuthenticated extends Event {
26
+ readonly userId: string | number;
27
+ readonly guard: string;
28
+ constructor(userId: string | number, guard?: string);
29
+ }
30
+ /**
31
+ * Emitted when a user logs out.
32
+ */
33
+ export declare class UserLoggedOut extends Event {
34
+ readonly userId: string | number;
35
+ readonly guard: string;
36
+ constructor(userId: string | number, guard?: string);
37
+ }
38
+ /**
39
+ * Emitted when a queued job is successfully processed.
40
+ */
41
+ export declare class JobProcessed extends Event {
42
+ readonly jobId: string;
43
+ readonly jobName: string;
44
+ readonly queue: string;
45
+ readonly durationMs: number;
46
+ constructor(jobId: string, jobName: string, queue: string, durationMs: number);
47
+ }
48
+ /**
49
+ * Emitted when a queued job fails.
50
+ */
51
+ export declare class JobFailed extends Event {
52
+ readonly jobId: string;
53
+ readonly jobName: string;
54
+ readonly queue: string;
55
+ readonly error: Error;
56
+ readonly attempts: number;
57
+ constructor(jobId: string, jobName: string, queue: string, error: Error, attempts: number);
58
+ }
59
+ /**
60
+ * Emitted when the application starts.
61
+ */
62
+ export declare class ApplicationStarted extends Event {
63
+ readonly port: number;
64
+ readonly host: string;
65
+ constructor(port: number, host: string);
66
+ }
67
+ /**
68
+ * Emitted when the application is shutting down.
69
+ */
70
+ export declare class ApplicationShutdown extends Event {
71
+ readonly reason?: string | undefined;
72
+ constructor(reason?: string | undefined);
73
+ }
@@ -1,155 +1,6 @@
1
- import { a as Event, b as EventClass } from '../EventManager-CmIoLt7r.js';
2
- export { c as EventListener, E as EventManager, d as EventSubscription, L as ListenerOptions, R as RegisteredListener, e as createEventManager } from '../EventManager-CmIoLt7r.js';
3
-
4
- /**
5
- * Base class for event listeners.
6
- * Extend this class to create reusable, class-based event listeners.
7
- *
8
- * @example
9
- * ```ts
10
- * class SendWelcomeEmail extends Listener<UserRegistered> {
11
- * static event = UserRegistered
12
- * static shouldQueue = true
13
- * static queue = 'emails'
14
- *
15
- * async handle(event: UserRegistered): Promise<void> {
16
- * await mail.to(event.email).subject('Welcome!').send()
17
- * }
18
- *
19
- * shouldHandle(event: UserRegistered): boolean {
20
- * // Only send to non-admin users
21
- * return !event.isAdmin
22
- * }
23
- * }
24
- * ```
25
- */
26
- declare abstract class Listener<T extends Event = Event> {
27
- /**
28
- * The event class this listener handles.
29
- * Must be set by subclasses.
30
- */
31
- static event: EventClass;
32
- /**
33
- * Whether this listener should be queued instead of executed immediately.
34
- * @default false
35
- */
36
- static shouldQueue: boolean;
37
- /**
38
- * The queue name to dispatch to when shouldQueue is true.
39
- * @default 'default'
40
- */
41
- static queue: string;
42
- /**
43
- * Priority of this listener. Higher values are executed first.
44
- * @default 0
45
- */
46
- static priority: number;
47
- /**
48
- * Handle the event.
49
- * This method must be implemented by subclasses.
50
- *
51
- * @param event - The event instance
52
- */
53
- abstract handle(event: T): void | Promise<void>;
54
- /**
55
- * Determine if this listener should handle the event.
56
- * Override this method to conditionally handle events.
57
- *
58
- * @param event - The event instance
59
- * @returns true if the listener should handle the event
60
- */
61
- shouldHandle?(event: T): boolean;
62
- /**
63
- * Called when the listener fails to handle the event.
64
- * Override this method to handle errors.
65
- *
66
- * @param event - The event instance
67
- * @param error - The error that occurred
68
- */
69
- failed?(event: T, error: Error): void | Promise<void>;
70
- }
71
- /**
72
- * Listener class constructor type.
73
- */
74
- interface ListenerClass<T extends Event = Event> {
75
- new (): Listener<T>;
76
- event: EventClass<T>;
77
- shouldQueue: boolean;
78
- queue: string;
79
- priority: number;
80
- }
81
-
82
- /**
83
- * Emitted when an HTTP request is received.
84
- */
85
- declare class RequestReceived extends Event {
86
- readonly method: string;
87
- readonly path: string;
88
- readonly requestId?: string | undefined;
89
- constructor(method: string, path: string, requestId?: string | undefined);
90
- }
91
- /**
92
- * Emitted when an HTTP request has finished processing.
93
- */
94
- declare class RequestFinished extends Event {
95
- readonly method: string;
96
- readonly path: string;
97
- readonly status: number;
98
- readonly durationMs: number;
99
- readonly requestId?: string | undefined;
100
- constructor(method: string, path: string, status: number, durationMs: number, requestId?: string | undefined);
101
- }
102
- /**
103
- * Emitted when a user successfully authenticates.
104
- */
105
- declare class UserAuthenticated extends Event {
106
- readonly userId: string | number;
107
- readonly guard: string;
108
- constructor(userId: string | number, guard?: string);
109
- }
110
- /**
111
- * Emitted when a user logs out.
112
- */
113
- declare class UserLoggedOut extends Event {
114
- readonly userId: string | number;
115
- readonly guard: string;
116
- constructor(userId: string | number, guard?: string);
117
- }
118
- /**
119
- * Emitted when a queued job is successfully processed.
120
- */
121
- declare class JobProcessed extends Event {
122
- readonly jobId: string;
123
- readonly jobName: string;
124
- readonly queue: string;
125
- readonly durationMs: number;
126
- constructor(jobId: string, jobName: string, queue: string, durationMs: number);
127
- }
128
- /**
129
- * Emitted when a queued job fails.
130
- */
131
- declare class JobFailed extends Event {
132
- readonly jobId: string;
133
- readonly jobName: string;
134
- readonly queue: string;
135
- readonly error: Error;
136
- readonly attempts: number;
137
- constructor(jobId: string, jobName: string, queue: string, error: Error, attempts: number);
138
- }
139
- /**
140
- * Emitted when the application starts.
141
- */
142
- declare class ApplicationStarted extends Event {
143
- readonly port: number;
144
- readonly host: string;
145
- constructor(port: number, host: string);
146
- }
147
- /**
148
- * Emitted when the application is shutting down.
149
- */
150
- declare class ApplicationShutdown extends Event {
151
- readonly reason?: string | undefined;
152
- constructor(reason?: string | undefined);
153
- }
154
-
155
- export { ApplicationShutdown, ApplicationStarted, Event, EventClass, JobFailed, JobProcessed, Listener, type ListenerClass, RequestFinished, RequestReceived, UserAuthenticated, UserLoggedOut };
1
+ export { Event } from './Event.js';
2
+ export { EventManager, createEventManager } from './EventManager.js';
3
+ export { Listener } from './Listener.js';
4
+ export type { ListenerClass } from './Listener.js';
5
+ export type { EventClass, EventListener, ListenerOptions, RegisteredListener, EventSubscription, } from './types.js';
6
+ export { RequestReceived, RequestFinished, UserAuthenticated, UserLoggedOut, JobProcessed, JobFailed, ApplicationStarted, ApplicationShutdown, } from './builtin.js';
@@ -0,0 +1,48 @@
1
+ import type { Event } from './Event.js';
2
+ /**
3
+ * Event class constructor type.
4
+ */
5
+ export interface EventClass<T extends Event = Event> {
6
+ new (...args: any[]): T;
7
+ eventName: string;
8
+ }
9
+ /**
10
+ * Event listener function type.
11
+ */
12
+ export type EventListener<T extends Event = Event> = (event: T) => void | Promise<void>;
13
+ /**
14
+ * Options for registering an event listener.
15
+ */
16
+ export interface ListenerOptions {
17
+ /**
18
+ * If true, the listener will be removed after the first invocation.
19
+ * @default false
20
+ */
21
+ once?: boolean;
22
+ /**
23
+ * Priority of the listener. Higher values are executed first.
24
+ * @default 0
25
+ */
26
+ priority?: number;
27
+ /**
28
+ * If specified, the listener will be dispatched to a queue instead of being executed immediately.
29
+ * Requires the Queue system to be configured.
30
+ */
31
+ queue?: string;
32
+ }
33
+ /**
34
+ * Internal representation of a registered listener.
35
+ */
36
+ export interface RegisteredListener<T extends Event = Event> {
37
+ listener: EventListener<T>;
38
+ options: ListenerOptions;
39
+ }
40
+ /**
41
+ * Event subscription handle for unsubscribing.
42
+ */
43
+ export interface EventSubscription {
44
+ /**
45
+ * Unsubscribe the listener.
46
+ */
47
+ unsubscribe(): void;
48
+ }
@@ -0,0 +1,31 @@
1
+ import type { Container } from '../container/Container.js';
2
+ import type { ServiceBindings } from '../container/bindings.js';
3
+ /**
4
+ * Create a proxy-based facade that lazily resolves a service from an application container.
5
+ *
6
+ * The returned proxy intercepts all property access and method calls,
7
+ * resolving the underlying service from the container on each access.
8
+ * This ensures that container fakes and flushes are respected.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { createFacades } from '@guren/server/facades'
13
+ *
14
+ * const { Cache, Events } = createFacades(container)
15
+ * await Cache.get('key')
16
+ * Events.emit('user.created', payload)
17
+ * ```
18
+ */
19
+ export declare function createFacade<K extends keyof ServiceBindings>(container: Pick<Container, 'make'>, key: K): ServiceBindings[K];
20
+ export declare function createFacades(container: Pick<Container, 'make'>): {
21
+ readonly Cache: import("../index.js").CacheManager;
22
+ readonly Events: import("../index.js").EventManager;
23
+ readonly Queue: import("../index.js").QueueManager;
24
+ readonly Mail: import("../index.js").MailManager;
25
+ readonly Log: import("../index.js").LogManager;
26
+ readonly I18n: import("../index.js").I18nManager;
27
+ readonly Notifications: import("../index.js").NotificationManager;
28
+ readonly Broadcast: import("../index.js").BroadcastManager;
29
+ readonly Storage: import("../index.js").StorageManager;
30
+ readonly Scheduler: import("../index.js").Scheduler;
31
+ };