@guren/server 2.1.1 → 2.3.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 (281) hide show
  1. package/dist/{DocsViewerServiceProvider-D7RGJPGM.js → DocsViewerServiceProvider-RUYDFBMW.js} +2 -2
  2. package/dist/McpServiceProvider-FRJ5O7LT.js +8 -0
  3. package/dist/auth/AuthManager.d.ts +30 -0
  4. package/dist/auth/AuthenticatableModel.d.ts +25 -0
  5. package/dist/auth/RequestAuthContext.d.ts +24 -0
  6. package/dist/auth/SessionGuard.d.ts +31 -0
  7. package/dist/auth/api-token.d.ts +299 -0
  8. package/dist/auth/email-verification.d.ts +203 -0
  9. package/dist/auth/index.d.ts +18 -110
  10. package/dist/auth/index.js +4 -1
  11. package/dist/auth/oauth/index.d.ts +239 -0
  12. package/dist/auth/password/DefaultHasher.d.ts +13 -0
  13. package/dist/auth/password/NodeHasher.d.ts +22 -0
  14. package/dist/auth/password/PasswordHasher.d.ts +5 -0
  15. package/dist/auth/password/ScryptHasher.d.ts +26 -0
  16. package/dist/auth/password-reset.d.ts +91 -0
  17. package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
  18. package/dist/auth/providers/UserProvider.d.ts +9 -0
  19. package/dist/auth/types.d.ts +102 -0
  20. package/dist/auth/utils.d.ts +39 -0
  21. package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
  22. package/dist/authorization/Policy.d.ts +77 -0
  23. package/dist/authorization/index.d.ts +5 -129
  24. package/dist/authorization/index.js +3 -1
  25. package/dist/authorization/middleware.d.ts +49 -0
  26. package/dist/authorization/types.d.ts +108 -0
  27. package/dist/broadcasting/BroadcastManager.d.ts +205 -0
  28. package/dist/broadcasting/channels/Channel.d.ts +28 -0
  29. package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
  30. package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
  31. package/dist/broadcasting/channels/index.d.ts +3 -0
  32. package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
  33. package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
  34. package/dist/broadcasting/drivers/index.d.ts +2 -0
  35. package/dist/broadcasting/index.d.ts +6 -233
  36. package/dist/broadcasting/index.js +1 -1
  37. package/dist/broadcasting/typed.d.ts +23 -0
  38. package/dist/broadcasting/types.d.ts +155 -0
  39. package/dist/cache/CacheManager.d.ts +87 -0
  40. package/dist/cache/TaggedCache.d.ts +62 -0
  41. package/dist/cache/index.d.ts +6 -233
  42. package/dist/cache/index.js +1 -1
  43. package/dist/cache/stores/FileStore.d.ts +64 -0
  44. package/dist/cache/stores/MemoryStore.d.ts +52 -0
  45. package/dist/cache/stores/RedisStore.d.ts +53 -0
  46. package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
  47. package/dist/chunk-3KV5X2FL.js +31 -0
  48. package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
  49. package/dist/{chunk-DSDX3ASM.js → chunk-5WL2FTC4.js} +67 -85
  50. package/dist/{chunk-5SZTEZ22.js → chunk-6IGN233M.js} +15 -8
  51. package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
  52. package/dist/{chunk-WIXGT4TN.js → chunk-A5JJ7XTH.js} +8 -2
  53. package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
  54. package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
  55. package/dist/{chunk-BZMZEFRG.js → chunk-LHR6OHI7.js} +11 -0
  56. package/dist/{chunk-JBG4AR24.js → chunk-Q2P6YLRR.js} +8 -2
  57. package/dist/{chunk-J6ETA476.js → chunk-TVV5YNEC.js} +101 -9
  58. package/dist/console/Command.d.ts +179 -0
  59. package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
  60. package/dist/console/Input.d.ts +140 -0
  61. package/dist/console/Output.d.ts +161 -0
  62. package/dist/console/index.d.ts +5 -0
  63. package/dist/console/types.d.ts +106 -0
  64. package/dist/container/Container.d.ts +148 -0
  65. package/dist/container/ServiceProvider.d.ts +103 -0
  66. package/dist/container/bindings.d.ts +55 -0
  67. package/dist/container/defineModule.d.ts +88 -0
  68. package/dist/container/definePlugin.d.ts +62 -0
  69. package/dist/container/index.d.ts +8 -0
  70. package/dist/container/types.d.ts +73 -0
  71. package/dist/database/Factory.d.ts +82 -0
  72. package/dist/database/Seeder.d.ts +35 -0
  73. package/dist/database/SeederRunner.d.ts +41 -0
  74. package/dist/database/index.d.ts +4 -0
  75. package/dist/database/types.d.ts +49 -0
  76. package/dist/discovery/AutoDiscovery.d.ts +113 -0
  77. package/dist/discovery/index.d.ts +2 -0
  78. package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
  79. package/dist/docs-viewer/endpoint.d.ts +29 -0
  80. package/dist/encryption/Encrypter.d.ts +96 -0
  81. package/dist/encryption/Hash.d.ts +69 -0
  82. package/dist/encryption/MessageSigner.d.ts +21 -0
  83. package/dist/encryption/Random.d.ts +119 -0
  84. package/dist/encryption/app-key.d.ts +12 -0
  85. package/dist/encryption/index.d.ts +10 -222
  86. package/dist/encryption/signed-url.d.ts +9 -0
  87. package/dist/encryption/types.d.ts +103 -0
  88. package/dist/errors/ExceptionHandler.d.ts +118 -0
  89. package/dist/errors/HttpException.d.ts +106 -0
  90. package/dist/errors/debug-page.d.ts +22 -0
  91. package/dist/errors/error-page.d.ts +1 -0
  92. package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
  93. package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
  94. package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
  95. package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
  96. package/dist/errors/exceptions/ValidationException.d.ts +60 -0
  97. package/dist/errors/exceptions/index.d.ts +5 -0
  98. package/dist/errors/index.d.ts +5 -0
  99. package/dist/errors/types.d.ts +43 -0
  100. package/dist/events/Event.d.ts +33 -0
  101. package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
  102. package/dist/events/Listener.d.ts +79 -0
  103. package/dist/events/builtin.d.ts +73 -0
  104. package/dist/events/index.d.ts +6 -155
  105. package/dist/events/types.d.ts +48 -0
  106. package/dist/facades/index.d.ts +31 -0
  107. package/dist/health/HealthCheck.d.ts +34 -0
  108. package/dist/health/HealthManager.d.ts +53 -0
  109. package/dist/health/checks/CacheCheck.d.ts +35 -0
  110. package/dist/health/checks/CustomCheck.d.ts +23 -0
  111. package/dist/health/checks/DatabaseCheck.d.ts +33 -0
  112. package/dist/health/checks/MemoryCheck.d.ts +32 -0
  113. package/dist/health/checks/RedisCheck.d.ts +27 -0
  114. package/dist/health/checks/StorageCheck.d.ts +35 -0
  115. package/dist/health/checks/index.d.ts +12 -0
  116. package/dist/health/index.d.ts +5 -185
  117. package/dist/health/types.d.ts +52 -0
  118. package/dist/hot-reload/hot-disposables.d.ts +96 -0
  119. package/dist/hot-reload/testing.d.ts +14 -0
  120. package/dist/http/Application.d.ts +199 -0
  121. package/dist/http/FormRequest.d.ts +73 -0
  122. package/dist/http/dev-assets.d.ts +62 -0
  123. package/dist/http/dev-banner.d.ts +7 -0
  124. package/dist/http/inertia-assets.d.ts +31 -0
  125. package/dist/http/middleware/auth.d.ts +13 -0
  126. package/dist/http/middleware/capabilities.d.ts +22 -0
  127. package/dist/http/middleware/cors.d.ts +40 -0
  128. package/dist/http/middleware/csp.d.ts +59 -0
  129. package/dist/http/middleware/csrf.d.ts +121 -0
  130. package/dist/http/middleware/detect-locale.d.ts +65 -0
  131. package/dist/http/middleware/force-https.d.ts +34 -0
  132. package/dist/http/middleware/host-authorization.d.ts +24 -0
  133. package/dist/http/middleware/index.d.ts +19 -0
  134. package/dist/http/middleware/loopback-guard.d.ts +51 -0
  135. package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
  136. package/dist/http/middleware/redirect-safety.d.ts +29 -0
  137. package/dist/http/middleware/request-id.d.ts +19 -0
  138. package/dist/http/middleware/request-logging.d.ts +16 -0
  139. package/dist/http/middleware/response-headers.d.ts +18 -0
  140. package/dist/http/middleware/security-headers.d.ts +49 -0
  141. package/dist/http/middleware/session.d.ts +93 -0
  142. package/dist/http/middleware/validation.d.ts +94 -0
  143. package/dist/http/public-assets.d.ts +15 -0
  144. package/dist/http/request.d.ts +24 -0
  145. package/dist/http/resources/CursorPaginator.d.ts +106 -0
  146. package/dist/http/resources/Paginator.d.ts +130 -0
  147. package/dist/http/resources/Resource.d.ts +67 -0
  148. package/dist/http/resources/ResourceCollection.d.ts +60 -0
  149. package/dist/http/resources/index.d.ts +6 -0
  150. package/dist/http/resources/types.d.ts +91 -0
  151. package/dist/http/validation/Validator.d.ts +128 -0
  152. package/dist/http/validation/index.d.ts +3 -0
  153. package/dist/http/validation/rules.d.ts +196 -0
  154. package/dist/http/validation/types.d.ts +96 -0
  155. package/dist/http/vite-dev-server.d.ts +27 -0
  156. package/dist/i18n/I18nManager.d.ts +114 -0
  157. package/dist/i18n/Translator.d.ts +80 -0
  158. package/dist/i18n/index.d.ts +6 -101
  159. package/dist/i18n/index.js +5 -3
  160. package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
  161. package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
  162. package/dist/i18n/pluralization.d.ts +19 -0
  163. package/dist/i18n/types.d.ts +106 -0
  164. package/dist/index.d.ts +69 -2605
  165. package/dist/index.js +405 -180
  166. package/dist/lambda/index.d.ts +17 -37
  167. package/dist/logging/LogManager.d.ts +83 -0
  168. package/dist/logging/Logger.d.ts +76 -0
  169. package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
  170. package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
  171. package/dist/logging/channels/FileChannel.d.ts +15 -0
  172. package/dist/logging/index.d.ts +8 -50
  173. package/dist/logging/types.d.ts +96 -0
  174. package/dist/mail/Mail.d.ts +138 -0
  175. package/dist/mail/MailManager.d.ts +79 -0
  176. package/dist/mail/address.d.ts +8 -0
  177. package/dist/mail/index.d.ts +7 -316
  178. package/dist/mail/transports/LogTransport.d.ts +19 -0
  179. package/dist/mail/transports/MemoryTransport.d.ts +84 -0
  180. package/dist/mail/transports/ResendTransport.d.ts +32 -0
  181. package/dist/mail/transports/SmtpTransport.d.ts +40 -0
  182. package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
  183. package/dist/mcp/McpServiceProvider.d.ts +17 -0
  184. package/dist/mcp/create-mcp-server.d.ts +152 -0
  185. package/dist/mcp/endpoint.d.ts +47 -0
  186. package/dist/mcp/index.d.ts +3 -185
  187. package/dist/mcp/index.js +3 -3
  188. package/dist/mvc/Controller.d.ts +326 -0
  189. package/dist/mvc/Router.d.ts +239 -0
  190. package/dist/mvc/ViewEngine.d.ts +11 -0
  191. package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
  192. package/dist/mvc/inertia/shared.d.ts +90 -0
  193. package/dist/mvc/mount-route.d.ts +10 -0
  194. package/dist/notifications/Notification.d.ts +99 -0
  195. package/dist/notifications/NotificationManager.d.ts +150 -0
  196. package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
  197. package/dist/notifications/channels/MailChannel.d.ts +45 -0
  198. package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
  199. package/dist/notifications/channels/SlackChannel.d.ts +73 -0
  200. package/dist/notifications/channels/index.d.ts +4 -0
  201. package/dist/notifications/index.d.ts +6 -322
  202. package/dist/notifications/notifiable-type.d.ts +10 -0
  203. package/dist/notifications/registry.d.ts +39 -0
  204. package/dist/notifications/types.d.ts +162 -0
  205. package/dist/providers/AuthServiceProvider.d.ts +7 -0
  206. package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
  207. package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
  208. package/dist/providers/CacheServiceProvider.d.ts +7 -0
  209. package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
  210. package/dist/providers/ErrorServiceProvider.d.ts +9 -0
  211. package/dist/providers/EventServiceProvider.d.ts +7 -0
  212. package/dist/providers/HealthServiceProvider.d.ts +7 -0
  213. package/dist/providers/I18nServiceProvider.d.ts +27 -0
  214. package/dist/providers/InertiaServiceProvider.d.ts +20 -0
  215. package/dist/providers/LogServiceProvider.d.ts +7 -0
  216. package/dist/providers/MailServiceProvider.d.ts +7 -0
  217. package/dist/providers/NotificationServiceProvider.d.ts +8 -0
  218. package/dist/providers/OAuthServiceProvider.d.ts +7 -0
  219. package/dist/providers/QueueServiceProvider.d.ts +7 -0
  220. package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
  221. package/dist/providers/StorageServiceProvider.d.ts +7 -0
  222. package/dist/providers/index.d.ts +17 -0
  223. package/dist/queue/FailedJobReporter.d.ts +40 -0
  224. package/dist/queue/Job.d.ts +140 -0
  225. package/dist/queue/QueueManager.d.ts +79 -0
  226. package/dist/queue/Worker.d.ts +99 -0
  227. package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
  228. package/dist/queue/drivers/RedisDriver.d.ts +96 -0
  229. package/dist/queue/drivers/SqsDriver.d.ts +108 -0
  230. package/dist/queue/drivers/SyncDriver.d.ts +28 -0
  231. package/dist/queue/index.d.ts +9 -453
  232. package/dist/queue/types.d.ts +171 -0
  233. package/dist/redis/RedisApiTokenStore.d.ts +78 -0
  234. package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
  235. package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
  236. package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
  237. package/dist/redis/RedisRateLimitStore.d.ts +77 -0
  238. package/dist/redis/RedisSessionStore.d.ts +61 -0
  239. package/dist/redis/client.d.ts +41 -0
  240. package/dist/redis/index.d.ts +14 -356
  241. package/dist/redis/index.js +45 -9
  242. package/dist/redis/redis-values.d.ts +17 -0
  243. package/dist/redis/scan-keys.d.ts +6 -0
  244. package/dist/runtime/index.d.ts +8 -95
  245. package/dist/runtime/index.js +101 -68
  246. package/dist/scheduling/CronParser.d.ts +37 -0
  247. package/dist/scheduling/Schedule.d.ts +229 -0
  248. package/dist/scheduling/ScheduledTask.d.ts +47 -0
  249. package/dist/scheduling/Scheduler.d.ts +99 -0
  250. package/dist/scheduling/index.d.ts +5 -41
  251. package/dist/scheduling/types.d.ts +97 -0
  252. package/dist/storage/StorageManager.d.ts +65 -0
  253. package/dist/storage/drivers/LocalDriver.d.ts +55 -0
  254. package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
  255. package/dist/storage/drivers/S3Driver.d.ts +72 -0
  256. package/dist/storage/index.d.ts +5 -197
  257. package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
  258. package/dist/support/contained-path.d.ts +26 -0
  259. package/dist/support/error-polyfill.d.ts +9 -0
  260. package/dist/support/expiry.d.ts +47 -0
  261. package/dist/support/expiry.js +12 -0
  262. package/dist/support/import-map.d.ts +13 -0
  263. package/dist/support/redirect-target.d.ts +11 -0
  264. package/dist/support/stack-frames.d.ts +56 -0
  265. package/dist/support/trim-slashes.d.ts +11 -0
  266. package/dist/vite/index.d.ts +2 -35
  267. package/dist/vite/index.js +0 -3
  268. package/dist/vite/plugin.d.ts +34 -0
  269. package/package.json +7 -3
  270. package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
  271. package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
  272. package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
  273. package/dist/I18nManager-BiSoczfV.d.ts +0 -275
  274. package/dist/LogManager-7mxnkaPM.d.ts +0 -256
  275. package/dist/McpServiceProvider-7BB5FPF3.js +0 -8
  276. package/dist/Scheduler-pZiT8i57.d.ts +0 -471
  277. package/dist/api-token-D24VPr_E.d.ts +0 -663
  278. package/dist/app-key-CsBfRC_Q.d.ts +0 -214
  279. package/dist/email-verification-Dx426KLn.d.ts +0 -336
  280. package/dist/index-9_Jzj5jo.d.ts +0 -7
  281. package/dist/validation-yAL53e1S.d.ts +0 -2610
@@ -0,0 +1,5 @@
1
+ export type { ArgumentDefinition, OptionDefinition, ParsedSignature, CommandClass, CommandInstance, ConsoleKernelOptions, OutputInterface, InputInterface, ScheduledCommand, PromptInterface, ProgressInterface, } from './types.js';
2
+ export { Command } from './Command.js';
3
+ export { Input, parseSignature } from './Input.js';
4
+ export { Output, BufferedOutput } from './Output.js';
5
+ export { ConsoleKernel, createConsoleKernel } from './ConsoleKernel.js';
@@ -0,0 +1,106 @@
1
+ import type { Container } from '../container/index.js';
2
+ /**
3
+ * Parsed argument definition.
4
+ */
5
+ export interface ArgumentDefinition {
6
+ name: string;
7
+ description?: string;
8
+ required: boolean;
9
+ array: boolean;
10
+ defaultValue?: string;
11
+ }
12
+ /**
13
+ * Parsed option definition.
14
+ */
15
+ export interface OptionDefinition {
16
+ name: string;
17
+ shortcut?: string;
18
+ description?: string;
19
+ requiresValue: boolean;
20
+ defaultValue?: string | boolean;
21
+ array: boolean;
22
+ }
23
+ /**
24
+ * Parsed signature.
25
+ */
26
+ export interface ParsedSignature {
27
+ name: string;
28
+ arguments: ArgumentDefinition[];
29
+ options: OptionDefinition[];
30
+ }
31
+ /**
32
+ * Command class type.
33
+ */
34
+ export interface CommandClass {
35
+ signature: string;
36
+ description: string;
37
+ new (container?: Container): CommandInstance;
38
+ }
39
+ /**
40
+ * Command instance type.
41
+ */
42
+ export interface CommandInstance {
43
+ setInput(argv: string[]): void;
44
+ setOutput(output: OutputInterface): void;
45
+ setKernel(kernel: {
46
+ handle(argv: string[]): Promise<number>;
47
+ }): void;
48
+ run(): Promise<number>;
49
+ }
50
+ /**
51
+ * Output interface.
52
+ */
53
+ export interface OutputInterface {
54
+ info(message: string): void;
55
+ error(message: string): void;
56
+ warn(message: string): void;
57
+ success(message: string): void;
58
+ line(message: string): void;
59
+ newLine(count?: number): void;
60
+ table(headers: string[], rows: string[][]): void;
61
+ write(message: string): void;
62
+ }
63
+ /**
64
+ * Input interface.
65
+ */
66
+ export interface InputInterface {
67
+ argument<T = string>(name: string): T;
68
+ arguments(): Record<string, string | string[]>;
69
+ option<T = string | boolean>(name: string): T | undefined;
70
+ options(): Record<string, string | boolean | string[]>;
71
+ hasOption(name: string): boolean;
72
+ }
73
+ /**
74
+ * Console kernel options.
75
+ */
76
+ export interface ConsoleKernelOptions {
77
+ container?: Container;
78
+ }
79
+ /**
80
+ * Schedule definition for a command.
81
+ */
82
+ export interface ScheduledCommand {
83
+ command: string;
84
+ args?: string[];
85
+ expression: string;
86
+ timezone?: string;
87
+ description?: string;
88
+ }
89
+ /**
90
+ * Interactive prompt types.
91
+ */
92
+ export interface PromptInterface {
93
+ ask(question: string, defaultValue?: string): Promise<string>;
94
+ confirm(question: string, defaultValue?: boolean): Promise<boolean>;
95
+ choice<T extends string>(question: string, choices: T[], defaultValue?: T): Promise<T>;
96
+ secret(question: string): Promise<string>;
97
+ }
98
+ /**
99
+ * Progress bar interface.
100
+ */
101
+ export interface ProgressInterface {
102
+ start(total: number): void;
103
+ advance(step?: number): void;
104
+ finish(): void;
105
+ setProgress(current: number): void;
106
+ }
@@ -0,0 +1,148 @@
1
+ import type { ServiceFactory, ServiceBinding, ContextualBindingBuilder, ContextualBinding } from './types.js';
2
+ import type { ServiceBindings } from './bindings.js';
3
+ /**
4
+ * Dependency injection container with type-safe service resolution.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const container = new Container()
9
+ *
10
+ * // Register services
11
+ * container.singleton('events', (c) => new EventManager())
12
+ * container.instance('config', loadConfig())
13
+ *
14
+ * // Type-safe resolution (known bindings)
15
+ * const events = container.make('events') // EventManager
16
+ *
17
+ * // Generic resolution (custom bindings)
18
+ * const db = container.make<Database>('db')
19
+ * ```
20
+ */
21
+ export declare class Container {
22
+ protected bindings: Map<string, ServiceBinding>;
23
+ protected aliases: Map<string, string>;
24
+ protected tags: Map<string, Set<string>>;
25
+ protected contextualBindings: ContextualBinding[];
26
+ protected resolvingStack: string[];
27
+ protected scopedInstances: Map<string, unknown>[];
28
+ protected fakes: Map<string, unknown>;
29
+ /** @internal Used by ProviderManager to resolve deferred providers on demand */
30
+ deferredProviderLoader: ((service: string) => Promise<void>) | null;
31
+ /**
32
+ * Bind a service to the container.
33
+ * Each resolution creates a new instance.
34
+ */
35
+ bind<T>(key: string, factory: ServiceFactory<T>): this;
36
+ /**
37
+ * Bind a singleton service to the container.
38
+ * Only one instance is created and reused.
39
+ */
40
+ singleton<T>(key: string, factory: ServiceFactory<T>): this;
41
+ /**
42
+ * Bind an existing instance to the container.
43
+ */
44
+ instance<T>(key: string, value: T): this;
45
+ /**
46
+ * Resolve a service from the container.
47
+ *
48
+ * Known service keys (from ServiceBindings) are automatically typed:
49
+ * ```typescript
50
+ * container.make('events') // EventManager
51
+ * container.make('cache') // CacheManager
52
+ * ```
53
+ *
54
+ * Custom keys require an explicit type parameter:
55
+ * ```typescript
56
+ * container.make<MyService>('myService')
57
+ * ```
58
+ */
59
+ make<K extends keyof ServiceBindings>(key: K): ServiceBindings[K];
60
+ make<T>(key: string): T;
61
+ /**
62
+ * Resolve a service with additional parameters.
63
+ */
64
+ makeWith<T>(key: string, params: Record<string, unknown>): T;
65
+ /**
66
+ * Check if a service is bound in the container.
67
+ */
68
+ has(key: string): boolean;
69
+ /**
70
+ * Create an alias for a service.
71
+ */
72
+ alias(alias: string, key: string): this;
73
+ /**
74
+ * Tag multiple services with a tag name.
75
+ */
76
+ tag(keys: string[], tagName: string): this;
77
+ /**
78
+ * Resolve all services with a given tag.
79
+ */
80
+ tagged<T = unknown>(tagName: string): T[];
81
+ /**
82
+ * Define a contextual binding.
83
+ */
84
+ when(concrete: string): ContextualBindingBuilder;
85
+ /**
86
+ * Run a callback within a scoped context.
87
+ * Services resolved within the scope are cached and released when the scope ends.
88
+ */
89
+ scoped<T>(callback: () => T): T;
90
+ /**
91
+ * Run an async callback within a scoped context.
92
+ */
93
+ scopedAsync<T>(callback: () => Promise<T>): Promise<T>;
94
+ /**
95
+ * Replace a service binding with a fake instance for testing.
96
+ * Returns a disposable that restores the original binding when disposed.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * // Using 'using' declaration (auto-cleanup)
101
+ * using _ = container.fake('events', fakeEventManager)
102
+ *
103
+ * // Manual cleanup
104
+ * const restore = container.fake('mail', fakeMailManager)
105
+ * // ... run tests ...
106
+ * restore[Symbol.dispose]()
107
+ * ```
108
+ */
109
+ fake<K extends keyof ServiceBindings>(key: K, instance: ServiceBindings[K]): Disposable;
110
+ fake(key: string, instance: unknown): Disposable;
111
+ /**
112
+ * Check if a service is currently faked.
113
+ */
114
+ isFaked(key: string): boolean;
115
+ /**
116
+ * Remove all fakes.
117
+ */
118
+ clearFakes(): void;
119
+ /**
120
+ * Flush all resolved singleton instances.
121
+ */
122
+ flush(): void;
123
+ /**
124
+ * Remove a binding from the container.
125
+ */
126
+ forget(key: string): this;
127
+ /**
128
+ * Get all bound service keys.
129
+ */
130
+ getBindings(): string[];
131
+ /**
132
+ * Get all aliases.
133
+ */
134
+ getAliases(): Record<string, string>;
135
+ /**
136
+ * Get all tags.
137
+ */
138
+ getTags(): Record<string, string[]>;
139
+ protected resolveAlias(key: string): string;
140
+ protected findContextualBinding(needs: string): ServiceFactory<unknown> | null;
141
+ }
142
+ /**
143
+ * Create a new container instance.
144
+ */
145
+ export declare function createContainer(): Container;
146
+ export declare function setContainer(container: Container): void;
147
+ export declare function getContainer(): Container;
148
+ export declare function resolve<T = unknown>(key: string): T;
@@ -0,0 +1,103 @@
1
+ import type { Container } from './Container.js';
2
+ import type { Provider } from './types.js';
3
+ /**
4
+ * Constructor shape accepted wherever a provider class can be registered.
5
+ */
6
+ export type ServiceProviderConstructor = new (container: Container) => ServiceProvider;
7
+ /**
8
+ * Base service provider class.
9
+ *
10
+ * Service providers are the central place of all application bootstrapping.
11
+ * Your own application, as well as all core services, are bootstrapped via providers.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * export class AppServiceProvider extends ServiceProvider {
16
+ * register(): void {
17
+ * // Register bindings
18
+ * this.container.singleton('db', (c) => new Database(c.make('config')))
19
+ * }
20
+ *
21
+ * boot(): void {
22
+ * // Bootstrap after all providers registered
23
+ * const db = this.container.make<Database>('db')
24
+ * db.connect()
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ export declare abstract class ServiceProvider implements Provider {
30
+ protected container: Container;
31
+ /**
32
+ * Whether this provider should be deferred.
33
+ * Deferred providers are only loaded when one of their provided services is requested.
34
+ */
35
+ static deferred: boolean;
36
+ /**
37
+ * The services provided by this provider (for deferred loading).
38
+ */
39
+ static provides: string[];
40
+ constructor(container: Container);
41
+ /**
42
+ * Register any application services.
43
+ * This is called before any other providers have booted.
44
+ */
45
+ abstract register(): void | Promise<void>;
46
+ /**
47
+ * Bootstrap any application services.
48
+ * This is called after all providers have registered.
49
+ */
50
+ boot?(): void | Promise<void>;
51
+ /**
52
+ * Get the services provided by the provider.
53
+ */
54
+ provides(): string[];
55
+ /**
56
+ * Check if this provider is deferred.
57
+ */
58
+ isDeferred(): boolean;
59
+ }
60
+ /**
61
+ * Provider manager for registering and booting providers.
62
+ */
63
+ export declare class ProviderManager {
64
+ protected container: Container;
65
+ protected providers: ServiceProvider[];
66
+ protected registered: Set<ServiceProvider>;
67
+ protected booted: Set<ServiceProvider>;
68
+ protected deferredProviders: Map<string, ServiceProvider>;
69
+ private allBooted;
70
+ constructor(container: Container);
71
+ /**
72
+ * Register a provider.
73
+ */
74
+ register(providerOrClass: ServiceProvider | ServiceProviderConstructor): this;
75
+ /**
76
+ * Register multiple providers.
77
+ */
78
+ registerMany(providers: Array<ServiceProvider | ServiceProviderConstructor>): this;
79
+ /**
80
+ * Register all non-deferred providers.
81
+ */
82
+ registerAll(): Promise<void>;
83
+ /**
84
+ * Boot all registered providers.
85
+ */
86
+ bootAll(): Promise<void>;
87
+ /**
88
+ * Load a deferred provider for a service.
89
+ */
90
+ loadDeferredProvider(service: string): Promise<void>;
91
+ /**
92
+ * Check if a service is provided by a deferred provider.
93
+ */
94
+ isDeferredService(service: string): boolean;
95
+ /**
96
+ * Get all registered providers.
97
+ */
98
+ getProviders(): ServiceProvider[];
99
+ /**
100
+ * Get all deferred services.
101
+ */
102
+ getDeferredServices(): string[];
103
+ }
@@ -0,0 +1,55 @@
1
+ import type { Hono } from 'hono';
2
+ import type { Application } from '../http/Application.js';
3
+ import type { EventManager } from '../events/index.js';
4
+ import type { CacheManager } from '../cache/index.js';
5
+ import type { QueueManager } from '../queue/index.js';
6
+ import type { MailManager } from '../mail/index.js';
7
+ import type { LogManager } from '../logging/index.js';
8
+ import type { I18nManager } from '../i18n/index.js';
9
+ import type { NotificationManager } from '../notifications/index.js';
10
+ import type { BroadcastManager } from '../broadcasting/index.js';
11
+ import type { Encrypter } from '../encryption/index.js';
12
+ import type { AppKeyring } from '../encryption/app-key.js';
13
+ import type { AuthManager } from '../auth/AuthManager.js';
14
+ import type { OAuthManager } from '../auth/oauth/index.js';
15
+ import type { StorageManager } from '../storage/index.js';
16
+ import type { HealthManager } from '../health/index.js';
17
+ import type { Scheduler } from '../scheduling/index.js';
18
+ import type { Gate } from '../authorization/Gate.js';
19
+ import type { ExceptionHandler } from '../errors/index.js';
20
+ import type { SharedInertiaPropsRegistry } from '../mvc/inertia/shared.js';
21
+ /**
22
+ * Type-safe service binding map.
23
+ *
24
+ * Maps service keys to their concrete types for type-safe resolution
25
+ * via `container.make('key')`.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const events = container.make('events') // EventManager
30
+ * const cache = container.make('cache') // CacheManager
31
+ * ```
32
+ */
33
+ export interface ServiceBindings {
34
+ app: Application;
35
+ hono: Hono;
36
+ events: EventManager;
37
+ cache: CacheManager;
38
+ queue: QueueManager;
39
+ mail: MailManager;
40
+ log: LogManager;
41
+ i18n: I18nManager;
42
+ notifications: NotificationManager;
43
+ broadcast: BroadcastManager;
44
+ encrypter: Encrypter;
45
+ 'app.keyring': AppKeyring;
46
+ auth: AuthManager;
47
+ oauth: OAuthManager;
48
+ storage: StorageManager;
49
+ health: HealthManager;
50
+ scheduler: Scheduler;
51
+ gate: Gate;
52
+ /** Bound lazily on the first `shareInertiaProps(fn, container)` call. */
53
+ 'inertia.sharedProps': SharedInertiaPropsRegistry;
54
+ 'exception.handler': ExceptionHandler;
55
+ }
@@ -0,0 +1,88 @@
1
+ import type { CommandClass } from '../console/types.js';
2
+ import type { Router } from '../mvc/Router.js';
3
+ import type { ServiceProviderConstructor } from './ServiceProvider.js';
4
+ /**
5
+ * Declarative definition of an application module — a self-contained
6
+ * `modules/<name>/` directory that can register routes and providers, per
7
+ * RFC 0002. Unlike `definePlugin()`, a module has no config stage and no
8
+ * register/boot lifecycle of its own: it's a plain descriptor bundling
9
+ * providers and a route registrar that `Application` folds into its own
10
+ * provider list and route mounting.
11
+ */
12
+ export interface ModuleDefinition {
13
+ /** Diagnostic name; also the expected directory name under `modules/`. */
14
+ name: string;
15
+ /**
16
+ * URL prefix applied to all module routes via `router.group(prefix, ...)`.
17
+ * Declarative on purpose — tooling can read a module's URL surface
18
+ * statically without executing the registrar.
19
+ */
20
+ prefix?: string;
21
+ /** Route registrar, invoked after `options.routes` during boot. */
22
+ routes?: (router: Router) => void | Promise<void>;
23
+ /** Providers appended to the application's provider list. */
24
+ providers?: ServiceProviderConstructor[];
25
+ /**
26
+ * Console commands the module owns, exposed so the project's console
27
+ * entrypoint can register them without importing module internals:
28
+ * `kernel.registerMany(billingModule.commands)`. Nothing registers them
29
+ * automatically — `Application` never builds a `ConsoleKernel`, and
30
+ * command registration stays explicit so a bundled deployment resolves
31
+ * the same commands as a local checkout.
32
+ */
33
+ commands?: CommandClass[];
34
+ }
35
+ /**
36
+ * A module as `Application` consumes it — `providers` and `commands`
37
+ * normalized to always be arrays so callers don't repeat the `?? []`
38
+ * fallback. `commands` in particular is read by hand-written console
39
+ * entrypoints (`kernel.registerMany(billingModule.commands)`), where an
40
+ * `undefined` would be a runtime error rather than a no-op.
41
+ */
42
+ export interface GurenModule {
43
+ name: string;
44
+ prefix?: string;
45
+ routes?: (router: Router) => void | Promise<void>;
46
+ providers: ServiceProviderConstructor[];
47
+ commands: CommandClass[];
48
+ }
49
+ /**
50
+ * Define a Guren application module without boilerplate.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // modules/billing/index.ts
55
+ * export const billingModule = defineModule({
56
+ * name: 'billing',
57
+ * prefix: '/billing',
58
+ * routes: registerBillingRoutes,
59
+ * providers: [BillingServiceProvider],
60
+ * commands: [InvoiceCommand],
61
+ * })
62
+ *
63
+ * // src/app.ts
64
+ * createApp({ routes, providers, modules: [billingModule] })
65
+ *
66
+ * // src/console.ts
67
+ * kernel.registerMany(billingModule.commands)
68
+ * ```
69
+ */
70
+ export declare function defineModule(definition: ModuleDefinition): GurenModule;
71
+ /**
72
+ * Runs a module's route registrar against `router`, applying its `prefix`
73
+ * via `router.group()` when set. Shared by `Application.mountRoutes()` (at
74
+ * boot) and the CLI's route loader (for `guren codegen`/`audit`/`routes`/
75
+ * `openapi:generate`, which need the same route set without booting a real
76
+ * app) so both stay in sync — a bugfix to one path fixes the other.
77
+ *
78
+ * `router.group(prefix, callback)`'s callback is synchronous — it pushes
79
+ * the prefix, invokes the callback, then pops it, with no support for
80
+ * awaiting inside. Capturing the registrar's return value and awaiting it
81
+ * after `group()` returns preserves prefixing for the common case (a
82
+ * synchronous registrar, or an async one that calls `router.get`/`post`/
83
+ * etc. before its first `await`); route calls after an `await` inside an
84
+ * async, prefixed module registrar would run with the prefix already
85
+ * popped. Registrars with no prefix don't go through group() and have no
86
+ * such limitation.
87
+ */
88
+ export declare function mountModuleRoutes(router: Router, gurenModule: GurenModule): Promise<void>;
@@ -0,0 +1,62 @@
1
+ import type { Container } from './Container.js';
2
+ import { type ServiceProviderConstructor } from './ServiceProvider.js';
3
+ /**
4
+ * Declarative definition of a plugin's lifecycle hooks.
5
+ *
6
+ * `register` and `boot` mirror the ServiceProvider hooks and receive the
7
+ * container plus the configuration captured by the plugin factory.
8
+ */
9
+ export interface PluginDefinition<TConfig = void> {
10
+ /**
11
+ * Diagnostic name for the plugin (e.g. 'analytics').
12
+ * Used to derive the generated provider class name.
13
+ */
14
+ name: string;
15
+ /**
16
+ * Register services into the container.
17
+ * Called before any provider has booted.
18
+ */
19
+ register(container: Container, config: TConfig): void | Promise<void>;
20
+ /**
21
+ * Bootstrap after all providers have registered.
22
+ */
23
+ boot?(container: Container, config: TConfig): void | Promise<void>;
24
+ /**
25
+ * Defer instantiation until one of the `provides` services is resolved.
26
+ * Maps to `ServiceProvider.deferred`.
27
+ */
28
+ deferred?: boolean;
29
+ /**
30
+ * Services bound by this plugin (required when `deferred` is true).
31
+ * Maps to `ServiceProvider.provides`.
32
+ */
33
+ provides?: string[];
34
+ }
35
+ /**
36
+ * A factory returned by `definePlugin()`. Each call produces an independent
37
+ * ServiceProvider subclass with the given configuration captured in a closure.
38
+ */
39
+ export type PluginFactory<TConfig = void> = (config: TConfig) => ServiceProviderConstructor;
40
+ /**
41
+ * Define a configurable Guren plugin without ServiceProvider boilerplate.
42
+ *
43
+ * Unlike storing configuration on a static class property, each factory call
44
+ * returns a fresh provider class, so the same plugin can be registered twice
45
+ * with different configurations.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * export const analyticsPlugin = definePlugin<AnalyticsConfig>({
50
+ * name: 'analytics',
51
+ * register(container, config) {
52
+ * container.singleton('analytics', () => new AnalyticsClient(config))
53
+ * },
54
+ * })
55
+ *
56
+ * // In the application:
57
+ * createApp({
58
+ * providers: [analyticsPlugin({ apiKey: process.env.ANALYTICS_API_KEY! })],
59
+ * })
60
+ * ```
61
+ */
62
+ export declare function definePlugin<TConfig = void>(definition: PluginDefinition<TConfig>): PluginFactory<TConfig>;
@@ -0,0 +1,8 @@
1
+ export type { ServiceFactory, ServiceClass, ServiceBinding, ContextualBindingBuilder, ContextualNeedsBuilder, ContextualBinding, ServiceProviderOptions, Provider, ServiceProviderClass, } from './types.js';
2
+ export type { ServiceBindings } from './bindings.js';
3
+ export { Container, createContainer, setContainer, getContainer, resolve, } from './Container.js';
4
+ export { ServiceProvider, ProviderManager } from './ServiceProvider.js';
5
+ export { definePlugin } from './definePlugin.js';
6
+ export type { PluginDefinition, PluginFactory } from './definePlugin.js';
7
+ export { defineModule, mountModuleRoutes } from './defineModule.js';
8
+ export type { ModuleDefinition, GurenModule } from './defineModule.js';
@@ -0,0 +1,73 @@
1
+ import type { Container } from './Container.js';
2
+ /**
3
+ * Structural type for DI containers, avoiding a hard dependency on Container
4
+ * where only resolution is needed (controllers, Inertia shared props).
5
+ */
6
+ export interface ContainerLike {
7
+ make(key: string): unknown;
8
+ has?(key: string): boolean;
9
+ }
10
+ /**
11
+ * Service factory function.
12
+ */
13
+ export type ServiceFactory<T> = (container: Container) => T;
14
+ /**
15
+ * Service class constructor.
16
+ */
17
+ export type ServiceClass<T> = new (...args: unknown[]) => T;
18
+ /**
19
+ * Service binding configuration.
20
+ */
21
+ export interface ServiceBinding {
22
+ factory: ServiceFactory<unknown>;
23
+ singleton: boolean;
24
+ instance?: unknown;
25
+ }
26
+ /**
27
+ * Contextual binding builder interface.
28
+ */
29
+ export interface ContextualBindingBuilder {
30
+ needs(abstract: string): ContextualNeedsBuilder;
31
+ }
32
+ /**
33
+ * Contextual needs builder interface.
34
+ */
35
+ export interface ContextualNeedsBuilder {
36
+ give<T>(factory: ServiceFactory<T> | T): void;
37
+ }
38
+ /**
39
+ * Contextual binding configuration.
40
+ */
41
+ export interface ContextualBinding {
42
+ concrete: string;
43
+ needs: string;
44
+ factory: ServiceFactory<unknown>;
45
+ }
46
+ /**
47
+ * Service provider options.
48
+ */
49
+ export interface ServiceProviderOptions {
50
+ /**
51
+ * Whether this provider should be deferred.
52
+ */
53
+ deferred?: boolean;
54
+ /**
55
+ * Services this provider provides (for deferred loading).
56
+ */
57
+ provides?: string[];
58
+ }
59
+ /**
60
+ * Provider interface for container-based service providers.
61
+ */
62
+ export interface Provider {
63
+ register?(context: unknown): void | Promise<void>;
64
+ boot?(context: unknown): void | Promise<void>;
65
+ }
66
+ /**
67
+ * Service provider class type.
68
+ */
69
+ export interface ServiceProviderClass {
70
+ new (container: Container): Provider;
71
+ deferred?: boolean;
72
+ provides?: string[];
73
+ }