@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.
- package/dist/{DocsViewerServiceProvider-D7RGJPGM.js → DocsViewerServiceProvider-RUYDFBMW.js} +2 -2
- package/dist/McpServiceProvider-FRJ5O7LT.js +8 -0
- package/dist/auth/AuthManager.d.ts +30 -0
- package/dist/auth/AuthenticatableModel.d.ts +25 -0
- package/dist/auth/RequestAuthContext.d.ts +24 -0
- package/dist/auth/SessionGuard.d.ts +31 -0
- package/dist/auth/api-token.d.ts +299 -0
- package/dist/auth/email-verification.d.ts +203 -0
- package/dist/auth/index.d.ts +18 -110
- package/dist/auth/index.js +4 -1
- package/dist/auth/oauth/index.d.ts +239 -0
- package/dist/auth/password/DefaultHasher.d.ts +13 -0
- package/dist/auth/password/NodeHasher.d.ts +22 -0
- package/dist/auth/password/PasswordHasher.d.ts +5 -0
- package/dist/auth/password/ScryptHasher.d.ts +26 -0
- package/dist/auth/password-reset.d.ts +91 -0
- package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
- package/dist/auth/providers/UserProvider.d.ts +9 -0
- package/dist/auth/types.d.ts +102 -0
- package/dist/auth/utils.d.ts +39 -0
- package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
- package/dist/authorization/Policy.d.ts +77 -0
- package/dist/authorization/index.d.ts +5 -129
- package/dist/authorization/index.js +3 -1
- package/dist/authorization/middleware.d.ts +49 -0
- package/dist/authorization/types.d.ts +108 -0
- package/dist/broadcasting/BroadcastManager.d.ts +205 -0
- package/dist/broadcasting/channels/Channel.d.ts +28 -0
- package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
- package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
- package/dist/broadcasting/channels/index.d.ts +3 -0
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
- package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
- package/dist/broadcasting/drivers/index.d.ts +2 -0
- package/dist/broadcasting/index.d.ts +6 -233
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/typed.d.ts +23 -0
- package/dist/broadcasting/types.d.ts +155 -0
- package/dist/cache/CacheManager.d.ts +87 -0
- package/dist/cache/TaggedCache.d.ts +62 -0
- package/dist/cache/index.d.ts +6 -233
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +64 -0
- package/dist/cache/stores/MemoryStore.d.ts +52 -0
- package/dist/cache/stores/RedisStore.d.ts +53 -0
- package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
- package/dist/chunk-3KV5X2FL.js +31 -0
- package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
- package/dist/{chunk-DSDX3ASM.js → chunk-5WL2FTC4.js} +67 -85
- package/dist/{chunk-5SZTEZ22.js → chunk-6IGN233M.js} +15 -8
- package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
- package/dist/{chunk-WIXGT4TN.js → chunk-A5JJ7XTH.js} +8 -2
- package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
- package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
- package/dist/{chunk-BZMZEFRG.js → chunk-LHR6OHI7.js} +11 -0
- package/dist/{chunk-JBG4AR24.js → chunk-Q2P6YLRR.js} +8 -2
- package/dist/{chunk-J6ETA476.js → chunk-TVV5YNEC.js} +101 -9
- package/dist/console/Command.d.ts +179 -0
- package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
- package/dist/console/Input.d.ts +140 -0
- package/dist/console/Output.d.ts +161 -0
- package/dist/console/index.d.ts +5 -0
- package/dist/console/types.d.ts +106 -0
- package/dist/container/Container.d.ts +148 -0
- package/dist/container/ServiceProvider.d.ts +103 -0
- package/dist/container/bindings.d.ts +55 -0
- package/dist/container/defineModule.d.ts +88 -0
- package/dist/container/definePlugin.d.ts +62 -0
- package/dist/container/index.d.ts +8 -0
- package/dist/container/types.d.ts +73 -0
- package/dist/database/Factory.d.ts +82 -0
- package/dist/database/Seeder.d.ts +35 -0
- package/dist/database/SeederRunner.d.ts +41 -0
- package/dist/database/index.d.ts +4 -0
- package/dist/database/types.d.ts +49 -0
- package/dist/discovery/AutoDiscovery.d.ts +113 -0
- package/dist/discovery/index.d.ts +2 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
- package/dist/docs-viewer/endpoint.d.ts +29 -0
- package/dist/encryption/Encrypter.d.ts +96 -0
- package/dist/encryption/Hash.d.ts +69 -0
- package/dist/encryption/MessageSigner.d.ts +21 -0
- package/dist/encryption/Random.d.ts +119 -0
- package/dist/encryption/app-key.d.ts +12 -0
- package/dist/encryption/index.d.ts +10 -222
- package/dist/encryption/signed-url.d.ts +9 -0
- package/dist/encryption/types.d.ts +103 -0
- package/dist/errors/ExceptionHandler.d.ts +118 -0
- package/dist/errors/HttpException.d.ts +106 -0
- package/dist/errors/debug-page.d.ts +22 -0
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
- package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
- package/dist/errors/exceptions/ValidationException.d.ts +60 -0
- package/dist/errors/exceptions/index.d.ts +5 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/types.d.ts +43 -0
- package/dist/events/Event.d.ts +33 -0
- package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
- package/dist/events/Listener.d.ts +79 -0
- package/dist/events/builtin.d.ts +73 -0
- package/dist/events/index.d.ts +6 -155
- package/dist/events/types.d.ts +48 -0
- package/dist/facades/index.d.ts +31 -0
- package/dist/health/HealthCheck.d.ts +34 -0
- package/dist/health/HealthManager.d.ts +53 -0
- package/dist/health/checks/CacheCheck.d.ts +35 -0
- package/dist/health/checks/CustomCheck.d.ts +23 -0
- package/dist/health/checks/DatabaseCheck.d.ts +33 -0
- package/dist/health/checks/MemoryCheck.d.ts +32 -0
- package/dist/health/checks/RedisCheck.d.ts +27 -0
- package/dist/health/checks/StorageCheck.d.ts +35 -0
- package/dist/health/checks/index.d.ts +12 -0
- package/dist/health/index.d.ts +5 -185
- package/dist/health/types.d.ts +52 -0
- package/dist/hot-reload/hot-disposables.d.ts +96 -0
- package/dist/hot-reload/testing.d.ts +14 -0
- package/dist/http/Application.d.ts +199 -0
- package/dist/http/FormRequest.d.ts +73 -0
- package/dist/http/dev-assets.d.ts +62 -0
- package/dist/http/dev-banner.d.ts +7 -0
- package/dist/http/inertia-assets.d.ts +31 -0
- package/dist/http/middleware/auth.d.ts +13 -0
- package/dist/http/middleware/capabilities.d.ts +22 -0
- package/dist/http/middleware/cors.d.ts +40 -0
- package/dist/http/middleware/csp.d.ts +59 -0
- package/dist/http/middleware/csrf.d.ts +121 -0
- package/dist/http/middleware/detect-locale.d.ts +65 -0
- package/dist/http/middleware/force-https.d.ts +34 -0
- package/dist/http/middleware/host-authorization.d.ts +24 -0
- package/dist/http/middleware/index.d.ts +19 -0
- package/dist/http/middleware/loopback-guard.d.ts +51 -0
- package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
- package/dist/http/middleware/redirect-safety.d.ts +29 -0
- package/dist/http/middleware/request-id.d.ts +19 -0
- package/dist/http/middleware/request-logging.d.ts +16 -0
- package/dist/http/middleware/response-headers.d.ts +18 -0
- package/dist/http/middleware/security-headers.d.ts +49 -0
- package/dist/http/middleware/session.d.ts +93 -0
- package/dist/http/middleware/validation.d.ts +94 -0
- package/dist/http/public-assets.d.ts +15 -0
- package/dist/http/request.d.ts +24 -0
- package/dist/http/resources/CursorPaginator.d.ts +106 -0
- package/dist/http/resources/Paginator.d.ts +130 -0
- package/dist/http/resources/Resource.d.ts +67 -0
- package/dist/http/resources/ResourceCollection.d.ts +60 -0
- package/dist/http/resources/index.d.ts +6 -0
- package/dist/http/resources/types.d.ts +91 -0
- package/dist/http/validation/Validator.d.ts +128 -0
- package/dist/http/validation/index.d.ts +3 -0
- package/dist/http/validation/rules.d.ts +196 -0
- package/dist/http/validation/types.d.ts +96 -0
- package/dist/http/vite-dev-server.d.ts +27 -0
- package/dist/i18n/I18nManager.d.ts +114 -0
- package/dist/i18n/Translator.d.ts +80 -0
- package/dist/i18n/index.d.ts +6 -101
- package/dist/i18n/index.js +5 -3
- package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
- package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
- package/dist/i18n/pluralization.d.ts +19 -0
- package/dist/i18n/types.d.ts +106 -0
- package/dist/index.d.ts +69 -2605
- package/dist/index.js +405 -180
- package/dist/lambda/index.d.ts +17 -37
- package/dist/logging/LogManager.d.ts +83 -0
- package/dist/logging/Logger.d.ts +76 -0
- package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
- package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
- package/dist/logging/channels/FileChannel.d.ts +15 -0
- package/dist/logging/index.d.ts +8 -50
- package/dist/logging/types.d.ts +96 -0
- package/dist/mail/Mail.d.ts +138 -0
- package/dist/mail/MailManager.d.ts +79 -0
- package/dist/mail/address.d.ts +8 -0
- package/dist/mail/index.d.ts +7 -316
- package/dist/mail/transports/LogTransport.d.ts +19 -0
- package/dist/mail/transports/MemoryTransport.d.ts +84 -0
- package/dist/mail/transports/ResendTransport.d.ts +32 -0
- package/dist/mail/transports/SmtpTransport.d.ts +40 -0
- package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
- package/dist/mcp/McpServiceProvider.d.ts +17 -0
- package/dist/mcp/create-mcp-server.d.ts +152 -0
- package/dist/mcp/endpoint.d.ts +47 -0
- package/dist/mcp/index.d.ts +3 -185
- package/dist/mcp/index.js +3 -3
- package/dist/mvc/Controller.d.ts +326 -0
- package/dist/mvc/Router.d.ts +239 -0
- package/dist/mvc/ViewEngine.d.ts +11 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
- package/dist/mvc/inertia/shared.d.ts +90 -0
- package/dist/mvc/mount-route.d.ts +10 -0
- package/dist/notifications/Notification.d.ts +99 -0
- package/dist/notifications/NotificationManager.d.ts +150 -0
- package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
- package/dist/notifications/channels/MailChannel.d.ts +45 -0
- package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
- package/dist/notifications/channels/SlackChannel.d.ts +73 -0
- package/dist/notifications/channels/index.d.ts +4 -0
- package/dist/notifications/index.d.ts +6 -322
- package/dist/notifications/notifiable-type.d.ts +10 -0
- package/dist/notifications/registry.d.ts +39 -0
- package/dist/notifications/types.d.ts +162 -0
- package/dist/providers/AuthServiceProvider.d.ts +7 -0
- package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
- package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
- package/dist/providers/CacheServiceProvider.d.ts +7 -0
- package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
- package/dist/providers/ErrorServiceProvider.d.ts +9 -0
- package/dist/providers/EventServiceProvider.d.ts +7 -0
- package/dist/providers/HealthServiceProvider.d.ts +7 -0
- package/dist/providers/I18nServiceProvider.d.ts +27 -0
- package/dist/providers/InertiaServiceProvider.d.ts +20 -0
- package/dist/providers/LogServiceProvider.d.ts +7 -0
- package/dist/providers/MailServiceProvider.d.ts +7 -0
- package/dist/providers/NotificationServiceProvider.d.ts +8 -0
- package/dist/providers/OAuthServiceProvider.d.ts +7 -0
- package/dist/providers/QueueServiceProvider.d.ts +7 -0
- package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
- package/dist/providers/StorageServiceProvider.d.ts +7 -0
- package/dist/providers/index.d.ts +17 -0
- package/dist/queue/FailedJobReporter.d.ts +40 -0
- package/dist/queue/Job.d.ts +140 -0
- package/dist/queue/QueueManager.d.ts +79 -0
- package/dist/queue/Worker.d.ts +99 -0
- package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
- package/dist/queue/drivers/RedisDriver.d.ts +96 -0
- package/dist/queue/drivers/SqsDriver.d.ts +108 -0
- package/dist/queue/drivers/SyncDriver.d.ts +28 -0
- package/dist/queue/index.d.ts +9 -453
- package/dist/queue/types.d.ts +171 -0
- package/dist/redis/RedisApiTokenStore.d.ts +78 -0
- package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
- package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
- package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
- package/dist/redis/RedisRateLimitStore.d.ts +77 -0
- package/dist/redis/RedisSessionStore.d.ts +61 -0
- package/dist/redis/client.d.ts +41 -0
- package/dist/redis/index.d.ts +14 -356
- package/dist/redis/index.js +45 -9
- package/dist/redis/redis-values.d.ts +17 -0
- package/dist/redis/scan-keys.d.ts +6 -0
- package/dist/runtime/index.d.ts +8 -95
- package/dist/runtime/index.js +101 -68
- package/dist/scheduling/CronParser.d.ts +37 -0
- package/dist/scheduling/Schedule.d.ts +229 -0
- package/dist/scheduling/ScheduledTask.d.ts +47 -0
- package/dist/scheduling/Scheduler.d.ts +99 -0
- package/dist/scheduling/index.d.ts +5 -41
- package/dist/scheduling/types.d.ts +97 -0
- package/dist/storage/StorageManager.d.ts +65 -0
- package/dist/storage/drivers/LocalDriver.d.ts +55 -0
- package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
- package/dist/storage/drivers/S3Driver.d.ts +72 -0
- package/dist/storage/index.d.ts +5 -197
- package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
- package/dist/support/contained-path.d.ts +26 -0
- package/dist/support/error-polyfill.d.ts +9 -0
- package/dist/support/expiry.d.ts +47 -0
- package/dist/support/expiry.js +12 -0
- package/dist/support/import-map.d.ts +13 -0
- package/dist/support/redirect-target.d.ts +11 -0
- package/dist/support/stack-frames.d.ts +56 -0
- package/dist/support/trim-slashes.d.ts +11 -0
- package/dist/vite/index.d.ts +2 -35
- package/dist/vite/index.js +0 -3
- package/dist/vite/plugin.d.ts +34 -0
- package/package.json +7 -3
- package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
- package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
- package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
- package/dist/I18nManager-BiSoczfV.d.ts +0 -275
- package/dist/LogManager-7mxnkaPM.d.ts +0 -256
- package/dist/McpServiceProvider-7BB5FPF3.js +0 -8
- package/dist/Scheduler-pZiT8i57.d.ts +0 -471
- package/dist/api-token-D24VPr_E.d.ts +0 -663
- package/dist/app-key-CsBfRC_Q.d.ts +0 -214
- package/dist/email-verification-Dx426KLn.d.ts +0 -336
- package/dist/index-9_Jzj5jo.d.ts +0 -7
- package/dist/validation-yAL53e1S.d.ts +0 -2610
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-response form of {@link InertiaDocumentOptions}: the same fields, already
|
|
3
|
+
* resolved to strings. Each one overrides the app-wide default registered
|
|
4
|
+
* through {@link setInertiaDocument}.
|
|
5
|
+
*/
|
|
6
|
+
type InertiaDocumentOverrides = {
|
|
7
|
+
readonly [K in keyof InertiaDocumentOptions]?: string;
|
|
8
|
+
};
|
|
9
|
+
export interface InertiaOptions extends InertiaDocumentOverrides {
|
|
10
|
+
readonly url?: string;
|
|
11
|
+
readonly version?: string;
|
|
12
|
+
readonly status?: number;
|
|
13
|
+
readonly headers?: HeadersInit;
|
|
14
|
+
readonly request?: Request;
|
|
15
|
+
readonly title?: string;
|
|
16
|
+
/** Value for the root `<html lang>` attribute. Defaults to "en". */
|
|
17
|
+
readonly lang?: string;
|
|
18
|
+
readonly entry?: string;
|
|
19
|
+
readonly importMap?: Record<string, string>;
|
|
20
|
+
readonly styles?: string[];
|
|
21
|
+
readonly ssr?: InertiaSsrOptions;
|
|
22
|
+
}
|
|
23
|
+
export interface InertiaPagePayload {
|
|
24
|
+
component: string;
|
|
25
|
+
props: Record<string, unknown>;
|
|
26
|
+
url: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface InertiaSsrContext {
|
|
30
|
+
page: InertiaPagePayload;
|
|
31
|
+
request?: Request;
|
|
32
|
+
manifest?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface InertiaSsrResult {
|
|
35
|
+
head: string[];
|
|
36
|
+
body: string;
|
|
37
|
+
}
|
|
38
|
+
export type InertiaSsrRenderer = (context: InertiaSsrContext) => Promise<InertiaSsrResult> | InertiaSsrResult;
|
|
39
|
+
export interface InertiaSsrOptions {
|
|
40
|
+
enabled?: boolean;
|
|
41
|
+
entry?: string;
|
|
42
|
+
manifest?: string;
|
|
43
|
+
render?: InertiaSsrRenderer;
|
|
44
|
+
}
|
|
45
|
+
export interface InertiaDocumentContext {
|
|
46
|
+
/** Page component being rendered, e.g. `"Docs/Show"`. */
|
|
47
|
+
readonly component: string;
|
|
48
|
+
}
|
|
49
|
+
type InertiaDocumentValue = string | ((context: InertiaDocumentContext) => string | undefined);
|
|
50
|
+
export interface InertiaDocumentOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Class attribute for the root `<body>` element. Pass a function to vary it
|
|
53
|
+
* per page component — a docs section that needs a light surface while the
|
|
54
|
+
* marketing pages keep a dark one, for instance.
|
|
55
|
+
*/
|
|
56
|
+
readonly bodyClass?: InertiaDocumentValue;
|
|
57
|
+
/**
|
|
58
|
+
* CSS inlined into `<head>` ahead of the stylesheet links. Keep it to the
|
|
59
|
+
* few declarations that decide the first paint (surface and text colors);
|
|
60
|
+
* the main stylesheet still wins for everything it defines later.
|
|
61
|
+
*/
|
|
62
|
+
readonly criticalCss?: InertiaDocumentValue;
|
|
63
|
+
/**
|
|
64
|
+
* Body of a blocking inline `<script>` executed before the first paint.
|
|
65
|
+
* Use it for theme prepaint logic that has to read `localStorage` or
|
|
66
|
+
* `matchMedia` before React hydrates.
|
|
67
|
+
*/
|
|
68
|
+
readonly prepaintScript?: InertiaDocumentValue;
|
|
69
|
+
/**
|
|
70
|
+
* Raw markup inlined into `<head>`, ahead of the critical CSS and stylesheet
|
|
71
|
+
* links. Unescaped — the app author owns this string. Use it for static,
|
|
72
|
+
* site-wide tags the framework has no way to infer on its own, such as
|
|
73
|
+
* `<link rel="icon">` favicons.
|
|
74
|
+
*/
|
|
75
|
+
readonly head?: InertiaDocumentValue;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Register app-wide document defaults for server-rendered Inertia responses.
|
|
79
|
+
*
|
|
80
|
+
* Without this, the `<body>` ships without a class and nothing is inlined into
|
|
81
|
+
* `<head>`, so a page whose theme is applied by a client effect flashes the
|
|
82
|
+
* stylesheet's default surface color until React hydrates. Call it at module
|
|
83
|
+
* scope in the app entry so every runtime (Bun, serverless handlers, generated
|
|
84
|
+
* worker bundles) picks it up.
|
|
85
|
+
*
|
|
86
|
+
* Registration is process-wide and not request-scoped: calling this while
|
|
87
|
+
* requests are in flight leaks the new policy into them. Use the matching
|
|
88
|
+
* {@link InertiaOptions} fields for a single response instead.
|
|
89
|
+
*
|
|
90
|
+
* The values are emitted verbatim — inside `<style>` / `<script>` elements,
|
|
91
|
+
* or as raw markup for `head` — they are developer-authored assets, never
|
|
92
|
+
* user input.
|
|
93
|
+
*
|
|
94
|
+
* ```typescript
|
|
95
|
+
* setInertiaDocument({
|
|
96
|
+
* bodyClass: ({ component }) => (component.startsWith('Docs/') ? 'docs-theme' : undefined),
|
|
97
|
+
* })
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* Pass `undefined` to clear (test isolation).
|
|
101
|
+
*/
|
|
102
|
+
export declare function setInertiaDocument(options: InertiaDocumentOptions | undefined): void;
|
|
103
|
+
/**
|
|
104
|
+
* Register a process-wide default SSR renderer.
|
|
105
|
+
*
|
|
106
|
+
* Serverless adapters whose bundlers cannot resolve a runtime file path
|
|
107
|
+
* (Cloudflare Workers has no filesystem for `GUREN_INERTIA_SSR_ENTRY`'s
|
|
108
|
+
* dynamic import) register the statically imported renderer once at module
|
|
109
|
+
* scope. Per-call `ssr.render` still takes precedence; pass `undefined` to
|
|
110
|
+
* clear (test isolation).
|
|
111
|
+
*/
|
|
112
|
+
export declare function setInertiaSsrRenderer(renderer: InertiaSsrRenderer | undefined): void;
|
|
113
|
+
export declare function inertia(component: string, props: Record<string, unknown>, options?: InertiaOptions): Promise<Response>;
|
|
114
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { ContainerLike } from '../../container/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Application-level shared props shape for Inertia responses.
|
|
5
|
+
* Extend this interface in your app (via declaration merging) to type shared props.
|
|
6
|
+
*/
|
|
7
|
+
export interface InertiaSharedProps {
|
|
8
|
+
}
|
|
9
|
+
type SharedPropsDefault = Record<string, unknown>;
|
|
10
|
+
export type ResolvedSharedInertiaProps = InertiaSharedProps extends Record<string, unknown> ? InertiaSharedProps : SharedPropsDefault;
|
|
11
|
+
export type SharedInertiaPropsResolver<Props extends Record<string, unknown> = ResolvedSharedInertiaProps> = (ctx: Context) => Promise<Props> | Props;
|
|
12
|
+
/**
|
|
13
|
+
* Container able to own a scoped registry. `Container` satisfies this; the
|
|
14
|
+
* read-only {@link ContainerLike} does not, so a partial container cannot
|
|
15
|
+
* silently register app props into the module-global registry.
|
|
16
|
+
*/
|
|
17
|
+
export interface SharedPropsContainer extends ContainerLike {
|
|
18
|
+
has(key: string): boolean;
|
|
19
|
+
instance(key: string, value: unknown): unknown;
|
|
20
|
+
}
|
|
21
|
+
/** Container binding key for the scoped {@link SharedInertiaPropsRegistry}. */
|
|
22
|
+
export declare const INERTIA_SHARED_PROPS_BINDING = "inertia.sharedProps";
|
|
23
|
+
interface OrderedResolver {
|
|
24
|
+
seq: number;
|
|
25
|
+
resolve: SharedInertiaPropsResolver<ResolvedSharedInertiaProps>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Holds the shared-props resolvers for one scope: either a single
|
|
29
|
+
* Application's container or the module-global fallback for bare-Hono apps.
|
|
30
|
+
*/
|
|
31
|
+
export declare class SharedInertiaPropsRegistry {
|
|
32
|
+
private resolvers;
|
|
33
|
+
/** Replace every resolver registered in this scope. */
|
|
34
|
+
set<Props extends Record<string, unknown> = ResolvedSharedInertiaProps>(resolverFn: SharedInertiaPropsResolver<Props> | null): void;
|
|
35
|
+
/**
|
|
36
|
+
* Register additional shared props without replacing resolvers registered
|
|
37
|
+
* earlier — the new resolver's props are merged over the previous ones.
|
|
38
|
+
*/
|
|
39
|
+
share<Props extends Record<string, unknown>>(resolverFn: SharedInertiaPropsResolver<Props>): void;
|
|
40
|
+
/** The resolvers registered in this scope, ordered by registration. */
|
|
41
|
+
entries(): readonly OrderedResolver[];
|
|
42
|
+
/**
|
|
43
|
+
* The scope's registrations composed into one resolver, or null when empty.
|
|
44
|
+
* The composition is a snapshot: resolvers registered later are not picked up.
|
|
45
|
+
*/
|
|
46
|
+
get(): SharedInertiaPropsResolver<ResolvedSharedInertiaProps> | null;
|
|
47
|
+
resolve(ctx: Context): Promise<ResolvedSharedInertiaProps>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The shared-props registry scoped to `container`, binding a fresh one on
|
|
51
|
+
* first use.
|
|
52
|
+
*/
|
|
53
|
+
export declare function ensureSharedInertiaPropsRegistry(container: SharedPropsContainer): SharedInertiaPropsRegistry;
|
|
54
|
+
/**
|
|
55
|
+
* Replace the module-global shared props resolver. Props registered on an
|
|
56
|
+
* application's container (see {@link shareInertiaProps}) are unaffected.
|
|
57
|
+
*/
|
|
58
|
+
export declare function setInertiaSharedProps<Props extends Record<string, unknown> = ResolvedSharedInertiaProps>(resolverFn: SharedInertiaPropsResolver<Props> | null): void;
|
|
59
|
+
/**
|
|
60
|
+
* The module-global registrations composed into one resolver, for manual
|
|
61
|
+
* composition. Container-scoped props are not included — get those from
|
|
62
|
+
* `ensureSharedInertiaPropsRegistry(container).get()`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function getInertiaSharedPropsResolver(): SharedInertiaPropsResolver<ResolvedSharedInertiaProps> | null;
|
|
65
|
+
/**
|
|
66
|
+
* Register additional shared props without replacing resolvers registered
|
|
67
|
+
* earlier — the new resolver's props are merged over the previous ones.
|
|
68
|
+
* Use this from app providers so multiple providers can each contribute
|
|
69
|
+
* shared props (setInertiaSharedProps replaces the resolver wholesale).
|
|
70
|
+
*
|
|
71
|
+
* Pass the provider's `this.container` to scope the props to one application.
|
|
72
|
+
* Without it the props are module-global, so a second Application booted in
|
|
73
|
+
* the same process shares them.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* export class AuthProvider extends ServiceProvider {
|
|
78
|
+
* boot(): void {
|
|
79
|
+
* shareInertiaProps(async (ctx) => ({ auth: { user: await currentUser(ctx) } }), this.container)
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function shareInertiaProps<Props extends Record<string, unknown>>(resolverFn: SharedInertiaPropsResolver<Props>, container?: SharedPropsContainer): void;
|
|
85
|
+
/**
|
|
86
|
+
* Resolve shared props for a request, merging the module-global registrations
|
|
87
|
+
* with those scoped to `container` in registration order.
|
|
88
|
+
*/
|
|
89
|
+
export declare function resolveSharedInertiaProps(ctx: Context, container?: ContainerLike | null): Promise<ResolvedSharedInertiaProps>;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MiddlewareHandler, Hono } from 'hono';
|
|
2
|
+
/**
|
|
3
|
+
* Mounts a route on a Hono app with a dynamic HTTP method string.
|
|
4
|
+
*
|
|
5
|
+
* Hono's app.on() uses complex overloads that expect literal types for the
|
|
6
|
+
* method parameter, making it incompatible with dynamic `string` values at
|
|
7
|
+
* the type level. This helper encapsulates the single narrowing cast needed,
|
|
8
|
+
* keeping the rest of the codebase cast-free.
|
|
9
|
+
*/
|
|
10
|
+
export declare function mountRoute(app: Hono, method: string, path: string, ...handlers: MiddlewareHandler[]): void;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Notifiable, NotificationMailMessage, SlackMessage } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base notification class.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* class OrderShipped extends Notification {
|
|
8
|
+
* static shouldQueue = true
|
|
9
|
+
* static queue = 'notifications'
|
|
10
|
+
*
|
|
11
|
+
* constructor(private order: Order) {
|
|
12
|
+
* super()
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* via(notifiable: Notifiable): string[] {
|
|
16
|
+
* return ['mail', 'database']
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* toMail(notifiable: Notifiable): NotificationMailMessage {
|
|
20
|
+
* return {
|
|
21
|
+
* subject: `Order #${this.order.id} shipped`,
|
|
22
|
+
* html: '<p>Your order is on its way!</p>',
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* toDatabase(notifiable: Notifiable): Record<string, unknown> {
|
|
27
|
+
* return {
|
|
28
|
+
* orderId: this.order.id,
|
|
29
|
+
* message: 'Your order has shipped',
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare abstract class Notification {
|
|
36
|
+
/**
|
|
37
|
+
* Whether this notification should be queued.
|
|
38
|
+
*/
|
|
39
|
+
static shouldQueue: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The queue name for this notification.
|
|
42
|
+
*/
|
|
43
|
+
static queue?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Delay in milliseconds before sending.
|
|
46
|
+
*/
|
|
47
|
+
static delay?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Unique notification ID.
|
|
50
|
+
*/
|
|
51
|
+
readonly id: string;
|
|
52
|
+
/**
|
|
53
|
+
* When the notification was created.
|
|
54
|
+
*/
|
|
55
|
+
readonly createdAt: Date;
|
|
56
|
+
constructor();
|
|
57
|
+
/**
|
|
58
|
+
* Get the notification's delivery channels.
|
|
59
|
+
*/
|
|
60
|
+
abstract via(notifiable: Notifiable): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Get the mail representation of the notification.
|
|
63
|
+
*/
|
|
64
|
+
toMail?(notifiable: Notifiable): NotificationMailMessage;
|
|
65
|
+
/**
|
|
66
|
+
* Get the database representation of the notification.
|
|
67
|
+
*/
|
|
68
|
+
toDatabase?(notifiable: Notifiable): Record<string, unknown>;
|
|
69
|
+
/**
|
|
70
|
+
* Get the Slack representation of the notification.
|
|
71
|
+
*/
|
|
72
|
+
toSlack?(notifiable: Notifiable): SlackMessage;
|
|
73
|
+
/**
|
|
74
|
+
* Get the array representation of the notification.
|
|
75
|
+
* Used as a fallback for any channel.
|
|
76
|
+
*/
|
|
77
|
+
toArray?(notifiable: Notifiable): Record<string, unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* Get the notification type (default: class name).
|
|
80
|
+
*/
|
|
81
|
+
get type(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Check if the notification should be sent to the given notifiable.
|
|
84
|
+
* Override to add custom logic.
|
|
85
|
+
*/
|
|
86
|
+
shouldSend(_notifiable: Notifiable): boolean | Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* Generate a unique notification ID.
|
|
89
|
+
*/
|
|
90
|
+
protected generateId(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Get static queue configuration.
|
|
93
|
+
*/
|
|
94
|
+
static getQueueConfig(): {
|
|
95
|
+
shouldQueue: boolean;
|
|
96
|
+
queue?: string;
|
|
97
|
+
delay?: number;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { Notifiable, NotificationChannel, NotificationChannelFactory, NotificationManagerOptions } from './types.js';
|
|
2
|
+
import type { Notification } from './Notification.js';
|
|
3
|
+
import { Job } from '../queue/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Notification manager for sending notifications through multiple channels.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const notifications = new NotificationManager()
|
|
10
|
+
*
|
|
11
|
+
* notifications
|
|
12
|
+
* .registerChannel('mail', new MailChannel(mailManager))
|
|
13
|
+
* .registerChannel('database', new DatabaseChannel())
|
|
14
|
+
* .registerChannel('slack', new SlackChannel(webhookUrl))
|
|
15
|
+
*
|
|
16
|
+
* // Send notification
|
|
17
|
+
* await notifications.send(user, new OrderShipped(order))
|
|
18
|
+
*
|
|
19
|
+
* // Send to multiple users
|
|
20
|
+
* await notifications.sendToMany(admins, new NewUserRegistered(user))
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class NotificationManager {
|
|
24
|
+
protected channels: Map<string, NotificationChannel>;
|
|
25
|
+
protected channelFactories: Map<string, NotificationChannelFactory>;
|
|
26
|
+
protected resolvedChannels: Map<string, NotificationChannel>;
|
|
27
|
+
constructor(options?: NotificationManagerOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Register a notification channel.
|
|
30
|
+
*/
|
|
31
|
+
registerChannel(name: string, channel: NotificationChannel): this;
|
|
32
|
+
/**
|
|
33
|
+
* Register a notification channel factory.
|
|
34
|
+
*/
|
|
35
|
+
registerChannelFactory(name: string, factory: NotificationChannelFactory): this;
|
|
36
|
+
/**
|
|
37
|
+
* Get a notification channel by name.
|
|
38
|
+
*/
|
|
39
|
+
channel(name: string): NotificationChannel;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a channel is registered.
|
|
42
|
+
*/
|
|
43
|
+
hasChannel(name: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get all registered channel names.
|
|
46
|
+
*/
|
|
47
|
+
getChannelNames(): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Send a notification to a notifiable entity.
|
|
50
|
+
* Respects queue configuration on the notification class.
|
|
51
|
+
*/
|
|
52
|
+
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Send a notification immediately (bypasses queue).
|
|
55
|
+
*/
|
|
56
|
+
sendNow(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Queue a notification for later delivery.
|
|
59
|
+
*/
|
|
60
|
+
protected queue(notifiable: Notifiable, notification: Notification, queueConfig: {
|
|
61
|
+
queue?: string;
|
|
62
|
+
delay?: number;
|
|
63
|
+
}): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Send notification to multiple notifiables.
|
|
66
|
+
*/
|
|
67
|
+
sendToMany(notifiables: Notifiable[], notification: Notification): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Send notification immediately to multiple notifiables.
|
|
70
|
+
*/
|
|
71
|
+
sendNowToMany(notifiables: Notifiable[], notification: Notification): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Serialize notifiable for queue storage.
|
|
74
|
+
*
|
|
75
|
+
* Routing is resolved here rather than in the worker: `routeNotificationFor`
|
|
76
|
+
* is arbitrary user code — often a closure on an object literal — and cannot
|
|
77
|
+
* be reconstructed from a payload.
|
|
78
|
+
*
|
|
79
|
+
* @param channels - Channels to resolve routes for
|
|
80
|
+
*/
|
|
81
|
+
protected serializeNotifiable(notifiable: Notifiable, channels?: string[]): SerializedNotifiable;
|
|
82
|
+
/**
|
|
83
|
+
* Serialize notification for queue storage.
|
|
84
|
+
*
|
|
85
|
+
* Only own enumerable properties are captured. Behaviour is restored by
|
|
86
|
+
* rebuilding the registered class in the job handler, not by serializing it.
|
|
87
|
+
*/
|
|
88
|
+
protected serializeNotification(notification: Notification): SerializedNotification;
|
|
89
|
+
/**
|
|
90
|
+
* Bind this manager to the queued-notification job and register it.
|
|
91
|
+
*
|
|
92
|
+
* Call this during boot in a process that runs a worker but may never send
|
|
93
|
+
* a notification itself: without it, the worker cannot resolve the job.
|
|
94
|
+
*/
|
|
95
|
+
registerQueueJob(): typeof SendNotificationJob;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Payload for queued notifications.
|
|
99
|
+
*/
|
|
100
|
+
interface SendNotificationPayload {
|
|
101
|
+
notifiableData: SerializedNotifiable;
|
|
102
|
+
notificationData: SerializedNotification;
|
|
103
|
+
notificationType: string;
|
|
104
|
+
}
|
|
105
|
+
interface SerializedNotifiable {
|
|
106
|
+
type: string;
|
|
107
|
+
/** Channel routes resolved at dispatch time. Absent on legacy payloads. */
|
|
108
|
+
routes?: Record<string, string | null>;
|
|
109
|
+
data: Record<string, unknown>;
|
|
110
|
+
}
|
|
111
|
+
interface SerializedNotification {
|
|
112
|
+
id: string;
|
|
113
|
+
createdAt: string;
|
|
114
|
+
data: Record<string, unknown>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Job for sending queued notifications.
|
|
118
|
+
*/
|
|
119
|
+
declare class SendNotificationJob extends Job<SendNotificationPayload> {
|
|
120
|
+
static jobName: string;
|
|
121
|
+
static queue: string;
|
|
122
|
+
static maxAttempts: number;
|
|
123
|
+
static notificationManager: NotificationManager | null;
|
|
124
|
+
handle(payload: SendNotificationPayload): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Rebuild the notifiable from its serialized data.
|
|
127
|
+
*/
|
|
128
|
+
protected rebuildNotifiable(serialized: SerializedNotifiable): Notifiable;
|
|
129
|
+
/**
|
|
130
|
+
* Rebuild a real notification instance from its serialized data.
|
|
131
|
+
*
|
|
132
|
+
* The class is looked up in the notification registry and instantiated via
|
|
133
|
+
* its prototype, so prototype methods (`via`, `toMail`, `toDatabase`,
|
|
134
|
+
* `toSlack`, `shouldSend`) are restored without running the constructor.
|
|
135
|
+
*/
|
|
136
|
+
protected rebuildNotification(type: string, serialized: SerializedNotification): Notification;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Set the global notification manager.
|
|
140
|
+
*/
|
|
141
|
+
export declare function setNotificationManager(manager: NotificationManager): void;
|
|
142
|
+
/**
|
|
143
|
+
* Get the global notification manager.
|
|
144
|
+
*/
|
|
145
|
+
export declare function getNotificationManager(): NotificationManager;
|
|
146
|
+
/**
|
|
147
|
+
* Create a notification manager.
|
|
148
|
+
*/
|
|
149
|
+
export declare function createNotificationManager(options?: NotificationManagerOptions): NotificationManager;
|
|
150
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { NotificationChannel, Notifiable, DatabaseNotification, DatabaseChannelOptions } from '../types.js';
|
|
2
|
+
import type { Notification } from '../Notification.js';
|
|
3
|
+
/**
|
|
4
|
+
* Database notification channel.
|
|
5
|
+
*
|
|
6
|
+
* Stores notifications in the database for in-app notifications.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const dbChannel = new DatabaseChannel({
|
|
11
|
+
* store: async (notifiable, notification) => {
|
|
12
|
+
* await db.insert(notifications).values(notification)
|
|
13
|
+
* },
|
|
14
|
+
* })
|
|
15
|
+
* notifications.registerChannel('database', dbChannel)
|
|
16
|
+
*
|
|
17
|
+
* // In notification class:
|
|
18
|
+
* toDatabase(notifiable: Notifiable): Record<string, unknown> {
|
|
19
|
+
* return {
|
|
20
|
+
* orderId: this.order.id,
|
|
21
|
+
* message: 'Your order has shipped',
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class DatabaseChannel implements NotificationChannel {
|
|
27
|
+
private options;
|
|
28
|
+
readonly name = "database";
|
|
29
|
+
protected stored: DatabaseNotification[];
|
|
30
|
+
constructor(options?: DatabaseChannelOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Send the notification to the database.
|
|
33
|
+
*/
|
|
34
|
+
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the notifiable ID.
|
|
37
|
+
*/
|
|
38
|
+
protected getNotifiableId(notifiable: Notifiable): string | number;
|
|
39
|
+
/**
|
|
40
|
+
* Get the notifiable type.
|
|
41
|
+
*/
|
|
42
|
+
protected getNotifiableType(notifiable: Notifiable): string;
|
|
43
|
+
/**
|
|
44
|
+
* Get all stored notifications (for testing).
|
|
45
|
+
*/
|
|
46
|
+
getStored(): DatabaseNotification[];
|
|
47
|
+
/**
|
|
48
|
+
* Get stored notifications for a notifiable.
|
|
49
|
+
*/
|
|
50
|
+
getStoredFor(notifiable: Notifiable): DatabaseNotification[];
|
|
51
|
+
/**
|
|
52
|
+
* Clear stored notifications (for testing).
|
|
53
|
+
*/
|
|
54
|
+
clear(): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { NotificationChannel, Notifiable } from '../types.js';
|
|
2
|
+
import type { Notification } from '../Notification.js';
|
|
3
|
+
import type { MailManager } from '../../mail/MailManager.js';
|
|
4
|
+
/**
|
|
5
|
+
* Mail notification channel.
|
|
6
|
+
*
|
|
7
|
+
* Sends notifications via email using the MailManager.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const mailChannel = new MailChannel(mailManager)
|
|
12
|
+
* notifications.registerChannel('mail', mailChannel)
|
|
13
|
+
*
|
|
14
|
+
* // In notification class:
|
|
15
|
+
* toMail(notifiable: Notifiable): NotificationMailMessage {
|
|
16
|
+
* return {
|
|
17
|
+
* subject: 'Order Shipped',
|
|
18
|
+
* html: '<p>Your order has shipped!</p>',
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class MailChannel implements NotificationChannel {
|
|
24
|
+
private mailManager;
|
|
25
|
+
private options;
|
|
26
|
+
readonly name = "mail";
|
|
27
|
+
constructor(mailManager: MailManager, options?: MailChannelOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Send the notification via mail.
|
|
30
|
+
*/
|
|
31
|
+
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Mail channel options.
|
|
35
|
+
*/
|
|
36
|
+
export interface MailChannelOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Default from address.
|
|
39
|
+
*/
|
|
40
|
+
from?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Transport name to use.
|
|
43
|
+
*/
|
|
44
|
+
transport?: string;
|
|
45
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { NotificationChannel, Notifiable, SentNotification } from '../types.js';
|
|
2
|
+
import type { Notification } from '../Notification.js';
|
|
3
|
+
/**
|
|
4
|
+
* Memory notification channel for testing.
|
|
5
|
+
*
|
|
6
|
+
* Stores all sent notifications in memory for assertions.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const memoryChannel = new MemoryChannel()
|
|
11
|
+
* notifications.registerChannel('memory', memoryChannel)
|
|
12
|
+
*
|
|
13
|
+
* await notifications.send(user, new OrderShipped(order))
|
|
14
|
+
*
|
|
15
|
+
* memoryChannel.assertSentTo(user, 'OrderShipped')
|
|
16
|
+
* memoryChannel.assertCount(1)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class MemoryChannel implements NotificationChannel {
|
|
20
|
+
readonly name = "memory";
|
|
21
|
+
/**
|
|
22
|
+
* All sent notifications.
|
|
23
|
+
*/
|
|
24
|
+
sent: SentNotification[];
|
|
25
|
+
/**
|
|
26
|
+
* Send (store) the notification.
|
|
27
|
+
*/
|
|
28
|
+
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Assert that a notification was sent to a notifiable.
|
|
31
|
+
*/
|
|
32
|
+
assertSentTo(notifiable: Notifiable, notificationType?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Assert that a notification was not sent to a notifiable.
|
|
35
|
+
*/
|
|
36
|
+
assertNotSentTo(notifiable: Notifiable, notificationType?: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Assert the total count of sent notifications.
|
|
39
|
+
*/
|
|
40
|
+
assertCount(count: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* Assert that a notification type was sent.
|
|
43
|
+
*/
|
|
44
|
+
assertSent(notificationType: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Assert that a notification type was not sent.
|
|
47
|
+
*/
|
|
48
|
+
assertNotSent(notificationType: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Assert that no notifications were sent.
|
|
51
|
+
*/
|
|
52
|
+
assertNothingSent(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get notifications sent to a specific notifiable.
|
|
55
|
+
*/
|
|
56
|
+
getSentTo(notifiable: Notifiable): SentNotification[];
|
|
57
|
+
/**
|
|
58
|
+
* Get notifications of a specific type.
|
|
59
|
+
*/
|
|
60
|
+
getSentOfType(notificationType: string): SentNotification[];
|
|
61
|
+
/**
|
|
62
|
+
* Check if a notification was sent to a notifiable.
|
|
63
|
+
*/
|
|
64
|
+
hasSentTo(notifiable: Notifiable, notificationType?: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Check if a notification type was sent.
|
|
67
|
+
*/
|
|
68
|
+
hasSent(notificationType: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get the count of sent notifications.
|
|
71
|
+
*/
|
|
72
|
+
count(): number;
|
|
73
|
+
/**
|
|
74
|
+
* Get the last sent notification.
|
|
75
|
+
*/
|
|
76
|
+
last(): SentNotification | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Get the first sent notification.
|
|
79
|
+
*/
|
|
80
|
+
first(): SentNotification | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Clear all sent notifications.
|
|
83
|
+
*/
|
|
84
|
+
clear(): void;
|
|
85
|
+
}
|