@guren/server 2.14.0 → 2.16.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.
- package/dist/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
- package/dist/{Hash-CzrwKeDp.js → Hash-D2DFd8xX.js} +12 -57
- package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
- package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
- package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-nNcbCIQX.js} +11 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +31 -0
- package/dist/agent/approval.d.ts +184 -0
- package/dist/agent/audit-emitter.d.ts +36 -0
- package/dist/agent/audit.d.ts +67 -0
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +53 -63
- package/dist/agent/events.d.ts +11 -19
- package/dist/agent/meta-tools.d.ts +34 -0
- package/dist/agent/public.d.ts +14 -0
- package/dist/agent/public.js +2 -0
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +23 -69
- package/dist/auth/AuthManager.d.ts +19 -40
- package/dist/auth/AuthenticatableModel.d.ts +2 -2
- package/dist/auth/SessionGuard.d.ts +0 -1
- package/dist/auth/TokenGuard.d.ts +6 -26
- package/dist/auth/api-token.d.ts +16 -148
- package/dist/auth/context.d.ts +5 -10
- package/dist/auth/email-verification.d.ts +29 -127
- package/dist/auth/index.js +1 -1
- package/dist/auth/oauth/index.d.ts +35 -57
- package/dist/auth/password/DefaultHasher.d.ts +9 -5
- package/dist/auth/password/PasswordHasher.d.ts +7 -0
- package/dist/auth/password/hash-format.d.ts +11 -0
- package/dist/auth/password-reset.d.ts +16 -42
- package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
- package/dist/auth/providers/UserProvider.d.ts +4 -4
- package/dist/auth/signed-token.d.ts +18 -0
- package/dist/auth/types.d.ts +9 -32
- package/dist/auth/utils.d.ts +6 -27
- package/dist/{auth-BSUc14CD.js → auth-CbdPH4Cd.js} +252 -496
- package/dist/authorization/Gate.d.ts +9 -145
- package/dist/authorization/Policy.d.ts +6 -53
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/middleware.d.ts +16 -62
- package/dist/authorization/types.d.ts +8 -64
- package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
- package/dist/broadcasting/BroadcastManager.d.ts +29 -149
- package/dist/broadcasting/channels/Channel.d.ts +1 -19
- package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
- package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
- package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
- package/dist/broadcasting/drivers/index.d.ts +1 -1
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +7 -88
- package/dist/{broadcasting-BxU-LIfF.js → broadcasting-B5RzB0A2.js} +87 -414
- package/dist/cache/CacheManager.d.ts +8 -62
- package/dist/cache/TaggedCache.d.ts +2 -35
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -36
- package/dist/cache/stores/MemoryStore.d.ts +2 -26
- package/dist/cache/stores/RedisStore.d.ts +1 -29
- package/dist/cache/types.d.ts +21 -128
- package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
- package/dist/client-C4TEr_Dd.js +9 -0
- package/dist/console/Command.d.ts +17 -126
- package/dist/console/ConsoleKernel.d.ts +2 -74
- package/dist/console/Input.d.ts +5 -113
- package/dist/console/Output.d.ts +3 -99
- package/dist/console/types.d.ts +3 -33
- package/dist/container/Container.d.ts +12 -103
- package/dist/container/ServiceProvider.d.ts +17 -61
- package/dist/container/bindings.d.ts +10 -12
- package/dist/container/defineModule.d.ts +16 -54
- package/dist/container/definePlugin.d.ts +12 -45
- package/dist/container/types.d.ts +2 -34
- package/dist/context-CXk_umpT.js +21 -0
- package/dist/database/Factory.d.ts +4 -57
- package/dist/database/Seeder.d.ts +8 -46
- package/dist/database/SeederRunner.d.ts +3 -33
- package/dist/database/types.d.ts +3 -24
- package/dist/discovery/AutoDiscovery.d.ts +10 -82
- package/dist/dispatch-BAwzftws.js +238 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
- package/dist/docs-viewer/endpoint.d.ts +5 -11
- package/dist/encryption/Encrypter.d.ts +5 -71
- package/dist/encryption/Hash.d.ts +7 -57
- package/dist/encryption/Random.d.ts +6 -99
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/types.d.ts +10 -72
- package/dist/{encryption-DJtkkhiw.js → encryption-uwP3Di4D.js} +13 -79
- package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
- package/dist/endpoint-Dsw3Acvq.js +26 -0
- package/dist/errors/ExceptionHandler.d.ts +3 -90
- package/dist/errors/HttpException.d.ts +2 -79
- package/dist/errors/debug-page.d.ts +3 -17
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
- package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
- package/dist/errors/exceptions/ValidationException.d.ts +2 -43
- package/dist/errors/types.d.ts +1 -25
- package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
- package/dist/events/Event.d.ts +1 -28
- package/dist/events/EventManager.d.ts +5 -107
- package/dist/events/Listener.d.ts +7 -55
- package/dist/events/builtin.d.ts +0 -24
- package/dist/events/index.js +1 -1
- package/dist/events/types.d.ts +4 -22
- package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
- package/dist/facades/index.d.ts +2 -14
- package/dist/health/HealthCheck.d.ts +0 -24
- package/dist/health/HealthManager.d.ts +0 -36
- package/dist/health/checks/CacheCheck.d.ts +2 -17
- package/dist/health/checks/CustomCheck.d.ts +0 -9
- package/dist/health/checks/DatabaseCheck.d.ts +2 -17
- package/dist/health/checks/MemoryCheck.d.ts +3 -12
- package/dist/health/checks/RedisCheck.d.ts +1 -13
- package/dist/health/checks/StorageCheck.d.ts +2 -17
- package/dist/health/index.js +1 -1
- package/dist/health/types.d.ts +4 -24
- package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
- package/dist/hot-disposables-B5BXqaIH.js +167 -0
- package/dist/hot-reload/hot-disposables.d.ts +22 -74
- package/dist/hot-reload/testing.d.ts +4 -9
- package/dist/http/Application.d.ts +62 -208
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +16 -18
- package/dist/http/dev-banner.d.ts +2 -5
- package/dist/http/inertia-assets.d.ts +3 -6
- package/dist/http/middleware/capabilities.d.ts +27 -50
- package/dist/http/middleware/cors.d.ts +4 -29
- package/dist/http/middleware/csp.d.ts +2 -25
- package/dist/http/middleware/csrf.d.ts +20 -95
- package/dist/http/middleware/detect-locale.d.ts +7 -27
- package/dist/http/middleware/force-https.d.ts +6 -24
- package/dist/http/middleware/host-authorization.d.ts +2 -12
- package/dist/http/middleware/loopback-guard.d.ts +15 -33
- package/dist/http/middleware/rate-limit.d.ts +29 -126
- package/dist/http/middleware/redirect-safety.d.ts +2 -20
- package/dist/http/middleware/request-id.d.ts +1 -14
- package/dist/http/middleware/request-logging.d.ts +2 -13
- package/dist/http/middleware/response-headers.d.ts +5 -13
- package/dist/http/middleware/security-headers.d.ts +2 -16
- package/dist/http/middleware/session.d.ts +15 -34
- package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
- package/dist/http/middleware/validation.d.ts +8 -63
- package/dist/http/public-assets.d.ts +14 -0
- package/dist/http/request.d.ts +49 -48
- package/dist/http/resources/CursorPaginator.d.ts +5 -64
- package/dist/http/resources/Paginator.d.ts +7 -84
- package/dist/http/resources/Resource.d.ts +9 -65
- package/dist/http/resources/ResourceCollection.d.ts +5 -39
- package/dist/http/resources/types.d.ts +10 -30
- package/dist/http/static-documents.d.ts +21 -0
- package/dist/http/validation/Validator.d.ts +25 -85
- package/dist/http/validation/rules.d.ts +48 -147
- package/dist/http/validation/types.d.ts +16 -61
- package/dist/http/vite-assets.d.ts +5 -28
- package/dist/http/vite-dev-server.d.ts +6 -9
- package/dist/http/vite-manifest.d.ts +19 -33
- package/dist/i18n/I18nManager.d.ts +12 -78
- package/dist/i18n/Translator.d.ts +3 -54
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
- package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
- package/dist/i18n/pluralization.d.ts +4 -13
- package/dist/i18n/types.d.ts +17 -69
- package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
- package/dist/index.d.ts +13 -4
- package/dist/index.js +1036 -3080
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/request.d.ts +10 -17
- package/dist/internal/request.js +2 -2
- package/dist/internal/route-path.d.ts +9 -21
- package/dist/internal/route-path.js +9 -21
- package/dist/internal/zod-compat.d.ts +55 -122
- package/dist/internal/zod-compat.js +39 -70
- package/dist/internal/zod-json-schema.d.ts +18 -54
- package/dist/internal/zod-json-schema.js +46 -123
- package/dist/jsx-runtime.d.ts +3 -8
- package/dist/lambda/index.d.ts +17 -79
- package/dist/lambda/index.js +11 -59
- package/dist/logging/LogManager.d.ts +1 -51
- package/dist/logging/Logger.d.ts +8 -47
- package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
- package/dist/logging/channels/DailyFileChannel.d.ts +1 -5
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +15 -0
- package/dist/logging/index.d.ts +1 -0
- package/dist/logging/index.js +2 -2
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-CPaRMuPP.js → logging-zOY1XCtq.js} +83 -129
- package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
- package/dist/mail/Mail.d.ts +10 -106
- package/dist/mail/MailManager.d.ts +2 -60
- package/dist/mail/index.js +1 -1
- package/dist/mail/transports/LogTransport.d.ts +1 -4
- package/dist/mail/transports/MemoryTransport.d.ts +1 -63
- package/dist/mail/transports/ResendTransport.d.ts +1 -23
- package/dist/mail/transports/SmtpTransport.d.ts +1 -31
- package/dist/mail/types.d.ts +28 -150
- package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
- package/dist/mcp/McpServiceProvider.d.ts +4 -10
- package/dist/mcp/create-mcp-server.d.ts +25 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -253
- package/dist/mvc/Router.d.ts +50 -129
- package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
- package/dist/mvc/inertia/shared.d.ts +6 -19
- package/dist/mvc/mount-route.d.ts +2 -6
- package/dist/mvc/view.d.ts +1 -2
- package/dist/notifications/Notification.d.ts +8 -75
- package/dist/notifications/NotificationManager.d.ts +15 -88
- package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
- package/dist/notifications/channels/MailChannel.d.ts +2 -31
- package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
- package/dist/notifications/channels/SlackChannel.d.ts +3 -48
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/notifiable-type.d.ts +3 -6
- package/dist/notifications/registry.d.ts +8 -27
- package/dist/notifications/types.d.ts +16 -53
- package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
- package/dist/providers/AuthServiceProvider.d.ts +1 -3
- package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
- package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
- package/dist/providers/CacheServiceProvider.d.ts +1 -3
- package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
- package/dist/providers/ErrorServiceProvider.d.ts +1 -4
- package/dist/providers/EventServiceProvider.d.ts +1 -3
- package/dist/providers/HealthServiceProvider.d.ts +1 -3
- package/dist/providers/I18nServiceProvider.d.ts +6 -10
- package/dist/providers/InertiaServiceProvider.d.ts +1 -4
- package/dist/providers/LogServiceProvider.d.ts +1 -3
- package/dist/providers/MailServiceProvider.d.ts +1 -3
- package/dist/providers/NotificationServiceProvider.d.ts +1 -3
- package/dist/providers/OAuthServiceProvider.d.ts +1 -3
- package/dist/providers/QueueServiceProvider.d.ts +1 -3
- package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
- package/dist/providers/StorageServiceProvider.d.ts +1 -3
- package/dist/queue/FailedJobReporter.d.ts +1 -24
- package/dist/queue/Job.d.ts +12 -99
- package/dist/queue/QueueManager.d.ts +6 -57
- package/dist/queue/Worker.d.ts +4 -65
- package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
- package/dist/queue/drivers/RedisDriver.d.ts +7 -65
- package/dist/queue/drivers/SqsDriver.d.ts +6 -57
- package/dist/queue/drivers/SyncDriver.d.ts +10 -13
- package/dist/queue/index.js +2 -2
- package/dist/queue/types.d.ts +10 -92
- package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
- package/dist/redis/RedisApiTokenStore.d.ts +4 -56
- package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
- package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
- package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
- package/dist/redis/RedisRateLimitStore.d.ts +16 -49
- package/dist/redis/RedisSessionStore.d.ts +3 -44
- package/dist/redis/client.d.ts +2 -32
- package/dist/redis/index.js +47 -232
- package/dist/redis/redis-values.d.ts +6 -12
- package/dist/redis/scan-keys.d.ts +1 -4
- package/dist/request-CLOYytGP.js +68 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +108 -74
- package/dist/scheduling/CronParser.d.ts +0 -29
- package/dist/scheduling/Schedule.d.ts +1 -153
- package/dist/scheduling/ScheduledTask.d.ts +0 -31
- package/dist/scheduling/Scheduler.d.ts +0 -70
- package/dist/scheduling/index.js +1 -1
- package/dist/scheduling/types.d.ts +4 -65
- package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
- package/dist/storage/StorageManager.d.ts +0 -48
- package/dist/storage/drivers/LocalDriver.d.ts +1 -25
- package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
- package/dist/storage/drivers/S3Driver.d.ts +6 -36
- package/dist/storage/drivers/s3-acl.d.ts +5 -10
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +27 -265
- package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
- package/dist/support/contained-path.d.ts +10 -20
- package/dist/support/error-polyfill.d.ts +4 -6
- package/dist/support/expiry.d.ts +17 -33
- package/dist/support/expiry.js +17 -33
- package/dist/support/import-map.d.ts +3 -7
- package/dist/support/inertia-defaults.d.ts +5 -10
- package/dist/support/redirect-target.d.ts +4 -6
- package/dist/support/stack-frames.d.ts +11 -50
- package/dist/support/trim-slashes.d.ts +4 -7
- package/dist/support/warn-once.d.ts +2 -6
- package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
- package/dist/{vite-manifest-BGfWbPYp.js → vite-manifest-CTQp-SOo.js} +34 -58
- package/package.json +6 -2
- package/dist/client-Dd7vLcqp.js +0 -27
- package/dist/context-DoD0c7J_.js +0 -26
- package/dist/endpoint-D-20PiHY.js +0 -46
- package/dist/hot-disposables-WsTX2ySN.js +0 -281
- package/dist/request-CRVuIiQr.js +0 -78
package/dist/mail/Mail.d.ts
CHANGED
|
@@ -1,138 +1,42 @@
|
|
|
1
1
|
import type { MailAddress, MailAttachment, MailMessage, SendResult } from './types.js';
|
|
2
2
|
import type { MailManager } from './MailManager.js';
|
|
3
|
-
/**
|
|
4
|
-
* Fluent mail builder for composing and sending emails.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* import { mail, createMailManager } from '@guren/server/mail'
|
|
9
|
-
*
|
|
10
|
-
* const manager = createMailManager({ ... })
|
|
11
|
-
*
|
|
12
|
-
* // Send a simple email
|
|
13
|
-
* await mail(manager)
|
|
14
|
-
* .to('user@example.com')
|
|
15
|
-
* .subject('Hello!')
|
|
16
|
-
* .text('Hello World!')
|
|
17
|
-
* .send()
|
|
18
|
-
*
|
|
19
|
-
* // Send an HTML email with template
|
|
20
|
-
* await mail(manager)
|
|
21
|
-
* .to('user@example.com')
|
|
22
|
-
* .subject('Welcome!')
|
|
23
|
-
* .html('<h1>Welcome to our app!</h1>')
|
|
24
|
-
* .attach({ filename: 'guide.pdf', path: './guide.pdf' })
|
|
25
|
-
* .send()
|
|
26
|
-
*
|
|
27
|
-
* // Queue the email for async sending
|
|
28
|
-
* await mail(manager)
|
|
29
|
-
* .to('user@example.com')
|
|
30
|
-
* .subject('Report')
|
|
31
|
-
* .html('<p>Your report is ready</p>')
|
|
32
|
-
* .queue('emails')
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
3
|
+
/** Fluent mail builder for composing and sending emails. */
|
|
35
4
|
export declare class Mail {
|
|
36
5
|
private readonly manager;
|
|
37
6
|
private message;
|
|
38
7
|
private transportName?;
|
|
39
8
|
constructor(manager: MailManager);
|
|
40
|
-
/**
|
|
41
|
-
* Set the sender address.
|
|
42
|
-
*/
|
|
43
9
|
from(address: string | MailAddress): this;
|
|
44
|
-
/**
|
|
45
|
-
* Add a recipient.
|
|
46
|
-
*/
|
|
47
10
|
to(address: string | MailAddress): this;
|
|
48
|
-
/**
|
|
49
|
-
* Add multiple recipients.
|
|
50
|
-
*/
|
|
51
11
|
toMany(addresses: (string | MailAddress)[]): this;
|
|
52
|
-
/**
|
|
53
|
-
* Add a CC recipient.
|
|
54
|
-
*/
|
|
55
12
|
cc(address: string | MailAddress): this;
|
|
56
|
-
/**
|
|
57
|
-
* Add a BCC recipient.
|
|
58
|
-
*/
|
|
59
13
|
bcc(address: string | MailAddress): this;
|
|
60
|
-
/**
|
|
61
|
-
* Set the reply-to address.
|
|
62
|
-
*/
|
|
63
14
|
replyTo(address: string | MailAddress): this;
|
|
64
|
-
/**
|
|
65
|
-
* Set the subject.
|
|
66
|
-
*/
|
|
67
15
|
subject(subject: string): this;
|
|
68
|
-
/**
|
|
69
|
-
* Set the plain text body.
|
|
70
|
-
*/
|
|
71
16
|
text(content: string): this;
|
|
72
|
-
/**
|
|
73
|
-
* Set the HTML body.
|
|
74
|
-
*/
|
|
75
17
|
html(content: string): this;
|
|
76
|
-
/**
|
|
77
|
-
* Render a React component as HTML body.
|
|
78
|
-
* Requires @react-email/render to be installed.
|
|
79
|
-
*
|
|
80
|
-
* @param component - React component function
|
|
81
|
-
* @param props - Props to pass to the component
|
|
82
|
-
*/
|
|
18
|
+
/** Render a React component as the HTML body; requires @react-email/render. */
|
|
83
19
|
template<P extends Record<string, unknown>>(component: (props: P) => unknown, props: P): Promise<this>;
|
|
84
|
-
/**
|
|
85
|
-
* Add an attachment.
|
|
86
|
-
*/
|
|
87
20
|
attach(attachment: MailAttachment): this;
|
|
88
|
-
/**
|
|
89
|
-
* Add a custom header.
|
|
90
|
-
* Rejects CR/LF characters to prevent SMTP header injection.
|
|
91
|
-
*/
|
|
21
|
+
/** Add a custom header. Rejects CR/LF to prevent SMTP header injection. */
|
|
92
22
|
header(key: string, value: string): this;
|
|
93
|
-
/**
|
|
94
|
-
* Specify which transport to use.
|
|
95
|
-
*/
|
|
23
|
+
/** Specify which transport to use. */
|
|
96
24
|
via(transport: string): this;
|
|
97
25
|
/**
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Mailable subclasses define their content in build() (subject, body, ...).
|
|
102
|
-
* It runs automatically before sending, so `new WelcomeMail(manager).to(x).send()`
|
|
103
|
-
* works without a manual build() call.
|
|
26
|
+
* Mailable subclasses define their content here; it runs automatically before
|
|
27
|
+
* sending, so no manual build() call is needed.
|
|
104
28
|
*/
|
|
105
29
|
protected build?(): this;
|
|
106
30
|
private hasRunBuild;
|
|
107
31
|
private runBuildOnce;
|
|
108
32
|
buildMessage(): MailMessage;
|
|
109
|
-
/**
|
|
110
|
-
* Send the email immediately.
|
|
111
|
-
*/
|
|
33
|
+
/** Send the email immediately. */
|
|
112
34
|
send(): Promise<SendResult>;
|
|
113
|
-
/**
|
|
114
|
-
* Queue the email for async sending.
|
|
115
|
-
*/
|
|
35
|
+
/** Queue the email for async sending. */
|
|
116
36
|
queue(queueName?: string): Promise<string>;
|
|
117
37
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Set the global mail manager for queue jobs.
|
|
120
|
-
*/
|
|
38
|
+
/** Set the global mail manager used by queue jobs. */
|
|
121
39
|
export declare function setMailManager(manager: MailManager): void;
|
|
122
|
-
/**
|
|
123
|
-
* Get the global mail manager.
|
|
124
|
-
*/
|
|
125
40
|
export declare function getMailManager(): MailManager | null;
|
|
126
|
-
/**
|
|
127
|
-
* Create a new mail builder.
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```ts
|
|
131
|
-
* await mail(manager)
|
|
132
|
-
* .to('user@example.com')
|
|
133
|
-
* .subject('Hello')
|
|
134
|
-
* .text('Hello World!')
|
|
135
|
-
* .send()
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
41
|
+
/** Create a new mail builder. */
|
|
138
42
|
export declare function mail(manager: MailManager): Mail;
|
|
@@ -1,79 +1,21 @@
|
|
|
1
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
|
-
*/
|
|
2
|
+
/** Mail manager for handling multiple transports. */
|
|
31
3
|
export declare class MailManager {
|
|
32
4
|
private readonly defaultTransportName;
|
|
33
5
|
private readonly defaultFrom?;
|
|
34
6
|
private readonly transportFactories;
|
|
35
7
|
private readonly resolvedTransports;
|
|
36
8
|
constructor(config?: MailConfig);
|
|
37
|
-
/**
|
|
38
|
-
* Register built-in transport drivers.
|
|
39
|
-
*/
|
|
40
9
|
private registerBuiltinDrivers;
|
|
41
10
|
private driverFactories;
|
|
42
|
-
/**
|
|
43
|
-
* Register a driver factory.
|
|
44
|
-
*/
|
|
45
11
|
private registerDriverFactory;
|
|
46
|
-
/**
|
|
47
|
-
* Register a transport from configuration.
|
|
48
|
-
*/
|
|
49
12
|
private registerTransportFromConfig;
|
|
50
|
-
/**
|
|
51
|
-
* Get a mail transport by name.
|
|
52
|
-
* Returns the default transport if no name is specified.
|
|
53
|
-
*/
|
|
13
|
+
/** Get a mail transport by name, or the default transport when unnamed. */
|
|
54
14
|
transport(name?: string): MailTransport;
|
|
55
|
-
/**
|
|
56
|
-
* Register a custom transport.
|
|
57
|
-
*/
|
|
58
15
|
registerTransport(name: string, factory: MailTransportFactory): void;
|
|
59
|
-
/**
|
|
60
|
-
* Check if a transport is registered.
|
|
61
|
-
*/
|
|
62
16
|
hasTransport(name: string): boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Get the default transport name.
|
|
65
|
-
*/
|
|
66
17
|
getDefaultTransportName(): string;
|
|
67
|
-
/**
|
|
68
|
-
* Get the default from address.
|
|
69
|
-
*/
|
|
70
18
|
getDefaultFrom(): MailAddress | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Get all registered transport names.
|
|
73
|
-
*/
|
|
74
19
|
getTransportNames(): string[];
|
|
75
20
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Create a mail manager with configuration.
|
|
78
|
-
*/
|
|
79
21
|
export declare function createMailManager(config?: MailConfig): MailManager;
|
package/dist/mail/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "../mail-
|
|
1
|
+
import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "../mail-76DWy9lj.js";
|
|
2
2
|
export { LogTransport, Mail, MailManager, MemoryTransport, ResendTransport, SmtpTransport, createMailManager, getMailManager, mail, setMailManager };
|
|
@@ -1,84 +1,22 @@
|
|
|
1
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
|
-
*/
|
|
2
|
+
/** In-memory mail transport for testing: stores every sent message for inspection. */
|
|
23
3
|
export declare class MemoryTransport implements MailTransport {
|
|
24
4
|
readonly name = "memory";
|
|
25
5
|
private messages;
|
|
26
6
|
private simulateFailure;
|
|
27
7
|
private failureMessage;
|
|
28
8
|
constructor(options?: MemoryTransportOptions);
|
|
29
|
-
/**
|
|
30
|
-
* Send an email (stores in memory).
|
|
31
|
-
*/
|
|
32
9
|
send(message: MailMessage): Promise<SendResult>;
|
|
33
|
-
/**
|
|
34
|
-
* Get all sent messages.
|
|
35
|
-
*/
|
|
36
10
|
getMessages(): MailMessage[];
|
|
37
|
-
/**
|
|
38
|
-
* Get the last sent message.
|
|
39
|
-
*/
|
|
40
11
|
getLastMessage(): MailMessage | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Find messages by recipient email.
|
|
43
|
-
*/
|
|
44
12
|
findByRecipient(email: string): MailMessage[];
|
|
45
|
-
/**
|
|
46
|
-
* Find messages by subject.
|
|
47
|
-
*/
|
|
48
13
|
findBySubject(subject: string): MailMessage[];
|
|
49
|
-
/**
|
|
50
|
-
* Check if any message was sent to a recipient.
|
|
51
|
-
*/
|
|
52
14
|
hasSentTo(email: string): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Check if any message was sent with a subject.
|
|
55
|
-
*/
|
|
56
15
|
hasSentWithSubject(subject: string): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Get the count of sent messages.
|
|
59
|
-
*/
|
|
60
16
|
count(): number;
|
|
61
|
-
/**
|
|
62
|
-
* Clear all stored messages.
|
|
63
|
-
*/
|
|
64
17
|
clear(): void;
|
|
65
|
-
/**
|
|
66
|
-
* Set whether to simulate failures.
|
|
67
|
-
*/
|
|
68
18
|
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
19
|
assertSentTo(email: string): void;
|
|
74
|
-
/**
|
|
75
|
-
* Assert that a message was sent with a subject.
|
|
76
|
-
* Throws if no message was found.
|
|
77
|
-
*/
|
|
78
20
|
assertSentWithSubject(subject: string): void;
|
|
79
|
-
/**
|
|
80
|
-
* Assert that exactly n messages were sent.
|
|
81
|
-
* Throws if count doesn't match.
|
|
82
|
-
*/
|
|
83
21
|
assertSentCount(count: number): void;
|
|
84
22
|
}
|
|
@@ -1,32 +1,10 @@
|
|
|
1
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
|
-
*/
|
|
2
|
+
/** Resend mail transport. */
|
|
19
3
|
export declare class ResendTransport implements MailTransport {
|
|
20
4
|
readonly name = "resend";
|
|
21
5
|
private readonly apiKey;
|
|
22
6
|
private readonly baseUrl;
|
|
23
7
|
constructor(options: ResendTransportOptions);
|
|
24
|
-
/**
|
|
25
|
-
* Format email address for Resend API.
|
|
26
|
-
*/
|
|
27
8
|
private formatAddress;
|
|
28
|
-
/**
|
|
29
|
-
* Send an email via Resend API.
|
|
30
|
-
*/
|
|
31
9
|
send(message: MailMessage): Promise<SendResult>;
|
|
32
10
|
}
|
|
@@ -1,40 +1,10 @@
|
|
|
1
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
|
-
*/
|
|
2
|
+
/** SMTP mail transport using Nodemailer. */
|
|
24
3
|
export declare class SmtpTransport implements MailTransport {
|
|
25
4
|
readonly name = "smtp";
|
|
26
5
|
private readonly transporter;
|
|
27
6
|
constructor(options: SmtpTransportOptions);
|
|
28
|
-
/**
|
|
29
|
-
* Send an email via SMTP.
|
|
30
|
-
*/
|
|
31
7
|
send(message: MailMessage): Promise<SendResult>;
|
|
32
|
-
/**
|
|
33
|
-
* Verify SMTP connection.
|
|
34
|
-
*/
|
|
35
8
|
verify(): Promise<boolean>;
|
|
36
|
-
/**
|
|
37
|
-
* Close the transport.
|
|
38
|
-
*/
|
|
39
9
|
close(): void;
|
|
40
10
|
}
|
package/dist/mail/types.d.ts
CHANGED
|
@@ -1,211 +1,89 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Email address with optional display name.
|
|
3
|
-
*/
|
|
1
|
+
/** Email address with optional display name. */
|
|
4
2
|
export interface MailAddress {
|
|
5
|
-
/**
|
|
6
|
-
* Email address.
|
|
7
|
-
*/
|
|
8
3
|
email: string;
|
|
9
|
-
/**
|
|
10
|
-
* Display name.
|
|
11
|
-
*/
|
|
12
4
|
name?: string;
|
|
13
5
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Email attachment.
|
|
16
|
-
*/
|
|
6
|
+
/** Email attachment. */
|
|
17
7
|
export interface MailAttachment {
|
|
18
|
-
/**
|
|
19
|
-
* Filename shown to recipient.
|
|
20
|
-
*/
|
|
8
|
+
/** Filename shown to the recipient. */
|
|
21
9
|
filename: string;
|
|
22
|
-
/**
|
|
23
|
-
* Attachment content (Buffer or string).
|
|
24
|
-
*/
|
|
25
10
|
content?: Buffer | string;
|
|
26
|
-
/**
|
|
27
|
-
* Path to file to attach.
|
|
28
|
-
*/
|
|
11
|
+
/** Path to file to attach. */
|
|
29
12
|
path?: string;
|
|
30
|
-
/**
|
|
31
|
-
* MIME type.
|
|
32
|
-
*/
|
|
33
13
|
contentType?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Content-ID for inline attachments.
|
|
36
|
-
*/
|
|
14
|
+
/** Content-ID for inline attachments. */
|
|
37
15
|
cid?: string;
|
|
38
16
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Email message structure.
|
|
41
|
-
*/
|
|
17
|
+
/** Email message structure. */
|
|
42
18
|
export interface MailMessage {
|
|
43
|
-
/**
|
|
44
|
-
* Sender address.
|
|
45
|
-
*/
|
|
46
19
|
from?: MailAddress;
|
|
47
|
-
/**
|
|
48
|
-
* Primary recipients.
|
|
49
|
-
*/
|
|
50
20
|
to: MailAddress[];
|
|
51
|
-
/**
|
|
52
|
-
* Carbon copy recipients.
|
|
53
|
-
*/
|
|
54
21
|
cc?: MailAddress[];
|
|
55
|
-
/**
|
|
56
|
-
* Blind carbon copy recipients.
|
|
57
|
-
*/
|
|
58
22
|
bcc?: MailAddress[];
|
|
59
|
-
/**
|
|
60
|
-
* Reply-to address.
|
|
61
|
-
*/
|
|
62
23
|
replyTo?: MailAddress;
|
|
63
|
-
/**
|
|
64
|
-
* Email subject.
|
|
65
|
-
*/
|
|
66
24
|
subject: string;
|
|
67
|
-
/**
|
|
68
|
-
* Plain text body.
|
|
69
|
-
*/
|
|
25
|
+
/** Plain text body. */
|
|
70
26
|
text?: string;
|
|
71
|
-
/**
|
|
72
|
-
* HTML body.
|
|
73
|
-
*/
|
|
27
|
+
/** HTML body. */
|
|
74
28
|
html?: string;
|
|
75
|
-
/**
|
|
76
|
-
* Attachments.
|
|
77
|
-
*/
|
|
78
29
|
attachments?: MailAttachment[];
|
|
79
|
-
/**
|
|
80
|
-
* Custom headers.
|
|
81
|
-
*/
|
|
82
30
|
headers?: Record<string, string>;
|
|
83
31
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Result of sending an email.
|
|
86
|
-
*/
|
|
32
|
+
/** Result of sending an email. */
|
|
87
33
|
export interface SendResult {
|
|
88
|
-
/**
|
|
89
|
-
* Whether the email was sent successfully.
|
|
90
|
-
*/
|
|
91
34
|
success: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Message ID from the mail server.
|
|
94
|
-
*/
|
|
35
|
+
/** Message ID from the mail server. */
|
|
95
36
|
messageId?: string;
|
|
96
|
-
/**
|
|
97
|
-
* Response from the mail server.
|
|
98
|
-
*/
|
|
37
|
+
/** Response from the mail server. */
|
|
99
38
|
response?: string;
|
|
100
|
-
/**
|
|
101
|
-
* Error message if sending failed.
|
|
102
|
-
*/
|
|
39
|
+
/** Error message if sending failed. */
|
|
103
40
|
error?: string;
|
|
104
41
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Mail transport interface.
|
|
107
|
-
* Implement this to create custom email providers.
|
|
108
|
-
*/
|
|
42
|
+
/** Mail transport interface. Implement it to add a custom email provider. */
|
|
109
43
|
export interface MailTransport {
|
|
110
|
-
/**
|
|
111
|
-
* Transport name.
|
|
112
|
-
*/
|
|
113
44
|
readonly name: string;
|
|
114
|
-
/**
|
|
115
|
-
* Send an email message.
|
|
116
|
-
*/
|
|
117
45
|
send(message: MailMessage): Promise<SendResult>;
|
|
118
46
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Mail transport factory function.
|
|
121
|
-
*/
|
|
47
|
+
/** Mail transport factory function. */
|
|
122
48
|
export type MailTransportFactory = () => MailTransport;
|
|
123
|
-
/**
|
|
124
|
-
* Mail transport configuration.
|
|
125
|
-
*/
|
|
49
|
+
/** Mail transport configuration. */
|
|
126
50
|
export interface MailTransportConfig {
|
|
127
|
-
/**
|
|
128
|
-
* Transport driver name.
|
|
129
|
-
*/
|
|
130
51
|
driver: string;
|
|
131
|
-
/**
|
|
132
|
-
* Driver-specific options.
|
|
133
|
-
*/
|
|
52
|
+
/** Driver-specific options. */
|
|
134
53
|
[key: string]: unknown;
|
|
135
54
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Mail configuration.
|
|
138
|
-
*/
|
|
55
|
+
/** Mail configuration. */
|
|
139
56
|
export interface MailConfig {
|
|
140
|
-
/**
|
|
141
|
-
* Default transport name.
|
|
142
|
-
* @default 'smtp'
|
|
143
|
-
*/
|
|
57
|
+
/** @default 'smtp' */
|
|
144
58
|
default?: string;
|
|
145
|
-
/**
|
|
146
|
-
* Default from address.
|
|
147
|
-
*/
|
|
59
|
+
/** Default from address. */
|
|
148
60
|
from?: MailAddress;
|
|
149
|
-
/**
|
|
150
|
-
* Transport configurations.
|
|
151
|
-
*/
|
|
152
61
|
transports?: Record<string, MailTransportConfig>;
|
|
153
62
|
}
|
|
154
|
-
/**
|
|
155
|
-
* SMTP transport options.
|
|
156
|
-
*/
|
|
63
|
+
/** SMTP transport options. */
|
|
157
64
|
export interface SmtpTransportOptions {
|
|
158
|
-
/**
|
|
159
|
-
* SMTP server host.
|
|
160
|
-
*/
|
|
161
65
|
host: string;
|
|
162
|
-
/**
|
|
163
|
-
* SMTP server port.
|
|
164
|
-
* @default 587
|
|
165
|
-
*/
|
|
66
|
+
/** @default 587 */
|
|
166
67
|
port?: number;
|
|
167
|
-
/**
|
|
168
|
-
* Use TLS.
|
|
169
|
-
* @default false
|
|
170
|
-
*/
|
|
68
|
+
/** Use TLS. @default false */
|
|
171
69
|
secure?: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Authentication credentials.
|
|
174
|
-
*/
|
|
70
|
+
/** Authentication credentials. */
|
|
175
71
|
auth?: {
|
|
176
72
|
user: string;
|
|
177
73
|
pass: string;
|
|
178
74
|
};
|
|
179
|
-
/**
|
|
180
|
-
* Connection pool.
|
|
181
|
-
* @default true
|
|
182
|
-
*/
|
|
75
|
+
/** Use a connection pool. @default true */
|
|
183
76
|
pool?: boolean;
|
|
184
|
-
/**
|
|
185
|
-
* Maximum connections.
|
|
186
|
-
* @default 5
|
|
187
|
-
*/
|
|
77
|
+
/** @default 5 */
|
|
188
78
|
maxConnections?: number;
|
|
189
79
|
}
|
|
190
|
-
/**
|
|
191
|
-
* Resend transport options.
|
|
192
|
-
*/
|
|
80
|
+
/** Resend transport options. */
|
|
193
81
|
export interface ResendTransportOptions {
|
|
194
|
-
/**
|
|
195
|
-
* Resend API key.
|
|
196
|
-
*/
|
|
197
82
|
apiKey: string;
|
|
198
83
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Memory transport options (for testing).
|
|
201
|
-
*/
|
|
84
|
+
/** Memory transport options (for testing). */
|
|
202
85
|
export interface MemoryTransportOptions {
|
|
203
|
-
/**
|
|
204
|
-
* Whether to simulate failures.
|
|
205
|
-
*/
|
|
206
86
|
simulateFailure?: boolean;
|
|
207
|
-
/**
|
|
208
|
-
* Error message when simulating failures.
|
|
209
|
-
*/
|
|
87
|
+
/** Error message when simulating failures. */
|
|
210
88
|
failureMessage?: string;
|
|
211
89
|
}
|