@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,79 @@
1
+ import type { MailTransport, MailTransportFactory, MailConfig, MailAddress } from './types.js';
2
+ /**
3
+ * Mail manager for handling multiple transports.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const mailManager = new MailManager({
8
+ * default: 'smtp',
9
+ * from: { email: 'noreply@example.com', name: 'MyApp' },
10
+ * transports: {
11
+ * smtp: {
12
+ * driver: 'smtp',
13
+ * host: 'smtp.example.com',
14
+ * port: 587,
15
+ * auth: { user: 'user', pass: 'pass' },
16
+ * },
17
+ * resend: {
18
+ * driver: 'resend',
19
+ * apiKey: 'your-api-key',
20
+ * },
21
+ * },
22
+ * })
23
+ *
24
+ * // Get the default transport
25
+ * const transport = mailManager.transport()
26
+ *
27
+ * // Get a specific transport
28
+ * const resendTransport = mailManager.transport('resend')
29
+ * ```
30
+ */
31
+ export declare class MailManager {
32
+ private readonly defaultTransportName;
33
+ private readonly defaultFrom?;
34
+ private readonly transportFactories;
35
+ private readonly resolvedTransports;
36
+ constructor(config?: MailConfig);
37
+ /**
38
+ * Register built-in transport drivers.
39
+ */
40
+ private registerBuiltinDrivers;
41
+ private driverFactories;
42
+ /**
43
+ * Register a driver factory.
44
+ */
45
+ private registerDriverFactory;
46
+ /**
47
+ * Register a transport from configuration.
48
+ */
49
+ private registerTransportFromConfig;
50
+ /**
51
+ * Get a mail transport by name.
52
+ * Returns the default transport if no name is specified.
53
+ */
54
+ transport(name?: string): MailTransport;
55
+ /**
56
+ * Register a custom transport.
57
+ */
58
+ registerTransport(name: string, factory: MailTransportFactory): void;
59
+ /**
60
+ * Check if a transport is registered.
61
+ */
62
+ hasTransport(name: string): boolean;
63
+ /**
64
+ * Get the default transport name.
65
+ */
66
+ getDefaultTransportName(): string;
67
+ /**
68
+ * Get the default from address.
69
+ */
70
+ getDefaultFrom(): MailAddress | undefined;
71
+ /**
72
+ * Get all registered transport names.
73
+ */
74
+ getTransportNames(): string[];
75
+ }
76
+ /**
77
+ * Create a mail manager with configuration.
78
+ */
79
+ export declare function createMailManager(config?: MailConfig): MailManager;
@@ -0,0 +1,8 @@
1
+ import type { MailAddress } from './types.js';
2
+ /**
3
+ * Parse an email address string or object into MailAddress, supporting the
4
+ * `Name <email>` format. Parsed with string scanning — the previous
5
+ * `/^(.+)\s*<(.+)>$/` backtracks polynomially on crafted recipient strings,
6
+ * which can be request-derived (e.g. password reset forms).
7
+ */
8
+ export declare function parseMailAddress(input: string | MailAddress): MailAddress;
@@ -1,316 +1,7 @@
1
- import { e as MailTransport, i as SmtpTransportOptions, d as MailMessage, S as SendResult, R as ResendTransportOptions, h as MemoryTransportOptions, M as MailManager, a as MailAddress, b as MailAttachment } from '../MailManager-DpMvYiP9.js';
2
- export { c as MailConfig, f as MailTransportConfig, g as MailTransportFactory, j as createMailManager } from '../MailManager-DpMvYiP9.js';
3
-
4
- /**
5
- * SMTP mail transport using Nodemailer.
6
- *
7
- * @example
8
- * ```ts
9
- * const transport = new SmtpTransport({
10
- * host: 'smtp.example.com',
11
- * port: 587,
12
- * auth: {
13
- * user: 'user@example.com',
14
- * pass: 'password',
15
- * },
16
- * })
17
- *
18
- * await transport.send({
19
- * from: { email: 'sender@example.com' },
20
- * to: [{ email: 'recipient@example.com' }],
21
- * subject: 'Hello',
22
- * text: 'Hello World!',
23
- * })
24
- * ```
25
- */
26
- declare class SmtpTransport implements MailTransport {
27
- readonly name = "smtp";
28
- private readonly transporter;
29
- constructor(options: SmtpTransportOptions);
30
- /**
31
- * Send an email via SMTP.
32
- */
33
- send(message: MailMessage): Promise<SendResult>;
34
- /**
35
- * Verify SMTP connection.
36
- */
37
- verify(): Promise<boolean>;
38
- /**
39
- * Close the transport.
40
- */
41
- close(): void;
42
- }
43
-
44
- /**
45
- * Resend mail transport.
46
- *
47
- * @example
48
- * ```ts
49
- * const transport = new ResendTransport({
50
- * apiKey: process.env.RESEND_API_KEY,
51
- * })
52
- *
53
- * await transport.send({
54
- * from: { email: 'sender@example.com' },
55
- * to: [{ email: 'recipient@example.com' }],
56
- * subject: 'Hello',
57
- * html: '<p>Hello World!</p>',
58
- * })
59
- * ```
60
- */
61
- declare class ResendTransport implements MailTransport {
62
- readonly name = "resend";
63
- private readonly apiKey;
64
- private readonly baseUrl;
65
- constructor(options: ResendTransportOptions);
66
- /**
67
- * Format email address for Resend API.
68
- */
69
- private formatAddress;
70
- /**
71
- * Send an email via Resend API.
72
- */
73
- send(message: MailMessage): Promise<SendResult>;
74
- }
75
-
76
- /**
77
- * In-memory mail transport for testing.
78
- *
79
- * Stores all sent messages in memory for inspection.
80
- *
81
- * @example
82
- * ```ts
83
- * const transport = new MemoryTransport()
84
- *
85
- * await transport.send({
86
- * from: { email: 'sender@example.com' },
87
- * to: [{ email: 'recipient@example.com' }],
88
- * subject: 'Hello',
89
- * text: 'Hello World!',
90
- * })
91
- *
92
- * // Inspect sent messages
93
- * const messages = transport.getMessages()
94
- * console.log(messages[0].subject) // 'Hello'
95
- * ```
96
- */
97
- declare class MemoryTransport implements MailTransport {
98
- readonly name = "memory";
99
- private messages;
100
- private simulateFailure;
101
- private failureMessage;
102
- constructor(options?: MemoryTransportOptions);
103
- /**
104
- * Send an email (stores in memory).
105
- */
106
- send(message: MailMessage): Promise<SendResult>;
107
- /**
108
- * Get all sent messages.
109
- */
110
- getMessages(): MailMessage[];
111
- /**
112
- * Get the last sent message.
113
- */
114
- getLastMessage(): MailMessage | undefined;
115
- /**
116
- * Find messages by recipient email.
117
- */
118
- findByRecipient(email: string): MailMessage[];
119
- /**
120
- * Find messages by subject.
121
- */
122
- findBySubject(subject: string): MailMessage[];
123
- /**
124
- * Check if any message was sent to a recipient.
125
- */
126
- hasSentTo(email: string): boolean;
127
- /**
128
- * Check if any message was sent with a subject.
129
- */
130
- hasSentWithSubject(subject: string): boolean;
131
- /**
132
- * Get the count of sent messages.
133
- */
134
- count(): number;
135
- /**
136
- * Clear all stored messages.
137
- */
138
- clear(): void;
139
- /**
140
- * Set whether to simulate failures.
141
- */
142
- setSimulateFailure(simulate: boolean, message?: string): void;
143
- /**
144
- * Assert that a message was sent to a recipient.
145
- * Throws if no message was found.
146
- */
147
- assertSentTo(email: string): void;
148
- /**
149
- * Assert that a message was sent with a subject.
150
- * Throws if no message was found.
151
- */
152
- assertSentWithSubject(subject: string): void;
153
- /**
154
- * Assert that exactly n messages were sent.
155
- * Throws if count doesn't match.
156
- */
157
- assertSentCount(count: number): void;
158
- }
159
-
160
- interface LogTransportOptions {
161
- /**
162
- * Log function to write to.
163
- * @default console.log
164
- */
165
- logger?: (message: string) => void;
166
- }
167
- /**
168
- * Log mail transport: writes each email to the log instead of sending it.
169
- * This is the development default (`MAIL_MAILER=log`) — every send succeeds
170
- * and the full message is visible in the server output.
171
- */
172
- declare class LogTransport implements MailTransport {
173
- readonly name = "log";
174
- private readonly logger;
175
- constructor(options?: LogTransportOptions);
176
- send(message: MailMessage): Promise<SendResult>;
177
- }
178
-
179
- /**
180
- * Fluent mail builder for composing and sending emails.
181
- *
182
- * @example
183
- * ```ts
184
- * import { mail, createMailManager } from '@guren/server/mail'
185
- *
186
- * const manager = createMailManager({ ... })
187
- *
188
- * // Send a simple email
189
- * await mail(manager)
190
- * .to('user@example.com')
191
- * .subject('Hello!')
192
- * .text('Hello World!')
193
- * .send()
194
- *
195
- * // Send an HTML email with template
196
- * await mail(manager)
197
- * .to('user@example.com')
198
- * .subject('Welcome!')
199
- * .html('<h1>Welcome to our app!</h1>')
200
- * .attach({ filename: 'guide.pdf', path: './guide.pdf' })
201
- * .send()
202
- *
203
- * // Queue the email for async sending
204
- * await mail(manager)
205
- * .to('user@example.com')
206
- * .subject('Report')
207
- * .html('<p>Your report is ready</p>')
208
- * .queue('emails')
209
- * ```
210
- */
211
- declare class Mail {
212
- private readonly manager;
213
- private message;
214
- private transportName?;
215
- constructor(manager: MailManager);
216
- /**
217
- * Set the sender address.
218
- */
219
- from(address: string | MailAddress): this;
220
- /**
221
- * Add a recipient.
222
- */
223
- to(address: string | MailAddress): this;
224
- /**
225
- * Add multiple recipients.
226
- */
227
- toMany(addresses: (string | MailAddress)[]): this;
228
- /**
229
- * Add a CC recipient.
230
- */
231
- cc(address: string | MailAddress): this;
232
- /**
233
- * Add a BCC recipient.
234
- */
235
- bcc(address: string | MailAddress): this;
236
- /**
237
- * Set the reply-to address.
238
- */
239
- replyTo(address: string | MailAddress): this;
240
- /**
241
- * Set the subject.
242
- */
243
- subject(subject: string): this;
244
- /**
245
- * Set the plain text body.
246
- */
247
- text(content: string): this;
248
- /**
249
- * Set the HTML body.
250
- */
251
- html(content: string): this;
252
- /**
253
- * Render a React component as HTML body.
254
- * Requires @react-email/render to be installed.
255
- *
256
- * @param component - React component function
257
- * @param props - Props to pass to the component
258
- */
259
- template<P extends Record<string, unknown>>(component: (props: P) => unknown, props: P): Promise<this>;
260
- /**
261
- * Add an attachment.
262
- */
263
- attach(attachment: MailAttachment): this;
264
- /**
265
- * Add a custom header.
266
- * Rejects CR/LF characters to prevent SMTP header injection.
267
- */
268
- header(key: string, value: string): this;
269
- /**
270
- * Specify which transport to use.
271
- */
272
- via(transport: string): this;
273
- /**
274
- * Build the final message.
275
- */
276
- /**
277
- * Mailable subclasses define their content in build() (subject, body, ...).
278
- * It runs automatically before sending, so `new WelcomeMail(manager).to(x).send()`
279
- * works without a manual build() call.
280
- */
281
- protected build?(): this;
282
- private hasRunBuild;
283
- private runBuildOnce;
284
- buildMessage(): MailMessage;
285
- /**
286
- * Send the email immediately.
287
- */
288
- send(): Promise<SendResult>;
289
- /**
290
- * Queue the email for async sending.
291
- */
292
- queue(queueName?: string): Promise<string>;
293
- }
294
- /**
295
- * Set the global mail manager for queue jobs.
296
- */
297
- declare function setMailManager(manager: MailManager): void;
298
- /**
299
- * Get the global mail manager.
300
- */
301
- declare function getMailManager(): MailManager | null;
302
- /**
303
- * Create a new mail builder.
304
- *
305
- * @example
306
- * ```ts
307
- * await mail(manager)
308
- * .to('user@example.com')
309
- * .subject('Hello')
310
- * .text('Hello World!')
311
- * .send()
312
- * ```
313
- */
314
- declare function mail(manager: MailManager): Mail;
315
-
316
- export { LogTransport, type LogTransportOptions, Mail, MailAddress, MailAttachment, MailManager, MailMessage, MailTransport, MemoryTransport, MemoryTransportOptions, ResendTransport, ResendTransportOptions, SendResult, SmtpTransport, SmtpTransportOptions, getMailManager, mail, setMailManager };
1
+ export type { MailAddress, MailAttachment, MailMessage, SendResult, MailTransport, MailTransportFactory, MailTransportConfig, MailConfig, SmtpTransportOptions, ResendTransportOptions, MemoryTransportOptions, } from './types.js';
2
+ export { SmtpTransport } from './transports/SmtpTransport.js';
3
+ export { ResendTransport } from './transports/ResendTransport.js';
4
+ export { MemoryTransport } from './transports/MemoryTransport.js';
5
+ export { LogTransport, type LogTransportOptions } from './transports/LogTransport.js';
6
+ export { MailManager, createMailManager } from './MailManager.js';
7
+ export { Mail, mail, setMailManager, getMailManager } from './Mail.js';
@@ -0,0 +1,19 @@
1
+ import type { MailMessage, MailTransport, SendResult } from '../types.js';
2
+ export interface LogTransportOptions {
3
+ /**
4
+ * Log function to write to.
5
+ * @default console.log
6
+ */
7
+ logger?: (message: string) => void;
8
+ }
9
+ /**
10
+ * Log mail transport: writes each email to the log instead of sending it.
11
+ * This is the development default (`MAIL_MAILER=log`) — every send succeeds
12
+ * and the full message is visible in the server output.
13
+ */
14
+ export declare class LogTransport implements MailTransport {
15
+ readonly name = "log";
16
+ private readonly logger;
17
+ constructor(options?: LogTransportOptions);
18
+ send(message: MailMessage): Promise<SendResult>;
19
+ }
@@ -0,0 +1,84 @@
1
+ import type { MailTransport, MailMessage, SendResult, MemoryTransportOptions } from '../types.js';
2
+ /**
3
+ * In-memory mail transport for testing.
4
+ *
5
+ * Stores all sent messages in memory for inspection.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const transport = new MemoryTransport()
10
+ *
11
+ * await transport.send({
12
+ * from: { email: 'sender@example.com' },
13
+ * to: [{ email: 'recipient@example.com' }],
14
+ * subject: 'Hello',
15
+ * text: 'Hello World!',
16
+ * })
17
+ *
18
+ * // Inspect sent messages
19
+ * const messages = transport.getMessages()
20
+ * console.log(messages[0].subject) // 'Hello'
21
+ * ```
22
+ */
23
+ export declare class MemoryTransport implements MailTransport {
24
+ readonly name = "memory";
25
+ private messages;
26
+ private simulateFailure;
27
+ private failureMessage;
28
+ constructor(options?: MemoryTransportOptions);
29
+ /**
30
+ * Send an email (stores in memory).
31
+ */
32
+ send(message: MailMessage): Promise<SendResult>;
33
+ /**
34
+ * Get all sent messages.
35
+ */
36
+ getMessages(): MailMessage[];
37
+ /**
38
+ * Get the last sent message.
39
+ */
40
+ getLastMessage(): MailMessage | undefined;
41
+ /**
42
+ * Find messages by recipient email.
43
+ */
44
+ findByRecipient(email: string): MailMessage[];
45
+ /**
46
+ * Find messages by subject.
47
+ */
48
+ findBySubject(subject: string): MailMessage[];
49
+ /**
50
+ * Check if any message was sent to a recipient.
51
+ */
52
+ hasSentTo(email: string): boolean;
53
+ /**
54
+ * Check if any message was sent with a subject.
55
+ */
56
+ hasSentWithSubject(subject: string): boolean;
57
+ /**
58
+ * Get the count of sent messages.
59
+ */
60
+ count(): number;
61
+ /**
62
+ * Clear all stored messages.
63
+ */
64
+ clear(): void;
65
+ /**
66
+ * Set whether to simulate failures.
67
+ */
68
+ setSimulateFailure(simulate: boolean, message?: string): void;
69
+ /**
70
+ * Assert that a message was sent to a recipient.
71
+ * Throws if no message was found.
72
+ */
73
+ assertSentTo(email: string): void;
74
+ /**
75
+ * Assert that a message was sent with a subject.
76
+ * Throws if no message was found.
77
+ */
78
+ assertSentWithSubject(subject: string): void;
79
+ /**
80
+ * Assert that exactly n messages were sent.
81
+ * Throws if count doesn't match.
82
+ */
83
+ assertSentCount(count: number): void;
84
+ }
@@ -0,0 +1,32 @@
1
+ import type { MailTransport, MailMessage, SendResult, ResendTransportOptions } from '../types.js';
2
+ /**
3
+ * Resend mail transport.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const transport = new ResendTransport({
8
+ * apiKey: process.env.RESEND_API_KEY,
9
+ * })
10
+ *
11
+ * await transport.send({
12
+ * from: { email: 'sender@example.com' },
13
+ * to: [{ email: 'recipient@example.com' }],
14
+ * subject: 'Hello',
15
+ * html: '<p>Hello World!</p>',
16
+ * })
17
+ * ```
18
+ */
19
+ export declare class ResendTransport implements MailTransport {
20
+ readonly name = "resend";
21
+ private readonly apiKey;
22
+ private readonly baseUrl;
23
+ constructor(options: ResendTransportOptions);
24
+ /**
25
+ * Format email address for Resend API.
26
+ */
27
+ private formatAddress;
28
+ /**
29
+ * Send an email via Resend API.
30
+ */
31
+ send(message: MailMessage): Promise<SendResult>;
32
+ }
@@ -0,0 +1,40 @@
1
+ import type { MailTransport, MailMessage, SendResult, SmtpTransportOptions } from '../types.js';
2
+ /**
3
+ * SMTP mail transport using Nodemailer.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const transport = new SmtpTransport({
8
+ * host: 'smtp.example.com',
9
+ * port: 587,
10
+ * auth: {
11
+ * user: 'user@example.com',
12
+ * pass: 'password',
13
+ * },
14
+ * })
15
+ *
16
+ * await transport.send({
17
+ * from: { email: 'sender@example.com' },
18
+ * to: [{ email: 'recipient@example.com' }],
19
+ * subject: 'Hello',
20
+ * text: 'Hello World!',
21
+ * })
22
+ * ```
23
+ */
24
+ export declare class SmtpTransport implements MailTransport {
25
+ readonly name = "smtp";
26
+ private readonly transporter;
27
+ constructor(options: SmtpTransportOptions);
28
+ /**
29
+ * Send an email via SMTP.
30
+ */
31
+ send(message: MailMessage): Promise<SendResult>;
32
+ /**
33
+ * Verify SMTP connection.
34
+ */
35
+ verify(): Promise<boolean>;
36
+ /**
37
+ * Close the transport.
38
+ */
39
+ close(): void;
40
+ }