@guren/server 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{McpServiceProvider-7BB5FPF3.js → McpServiceProvider-GRDYNEQG.js} +1 -1
- 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 +3 -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-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
- package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
- package/dist/{chunk-HONCNQXZ.js → chunk-BUQXOZCT.js} +97 -10
- package/dist/{chunk-DSDX3ASM.js → chunk-CDZUNKI6.js} +65 -83
- package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
- package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
- package/dist/{chunk-EARA7JM4.js → chunk-PZKUDFMW.js} +11 -8
- 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 +19 -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 +187 -0
- package/dist/http/FormRequest.d.ts +73 -0
- package/dist/http/dev-assets.d.ts +51 -0
- package/dist/http/dev-banner.d.ts +7 -0
- package/dist/http/inertia-assets.d.ts +22 -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 +38 -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/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 +332 -152
- 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 +144 -0
- package/dist/mcp/endpoint.d.ts +29 -0
- package/dist/mcp/index.d.ts +3 -185
- package/dist/mcp/index.js +1 -1
- 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 +5 -2
- package/dist/redis/scan-keys.d.ts +6 -0
- package/dist/runtime/index.d.ts +8 -95
- package/dist/runtime/index.js +1 -1
- 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/error-polyfill.d.ts +9 -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 +3 -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/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-D60YF2ZO.d.ts +0 -329
- package/dist/index-9_Jzj5jo.d.ts +0 -7
- package/dist/validation-yAL53e1S.d.ts +0 -2610
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { NotificationChannel, Notifiable, SlackMessage } from '../types.js';
|
|
2
|
+
import type { Notification } from '../Notification.js';
|
|
3
|
+
/**
|
|
4
|
+
* Slack notification channel.
|
|
5
|
+
*
|
|
6
|
+
* Sends notifications to Slack via incoming webhooks.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const slackChannel = new SlackChannel('https://hooks.slack.com/services/...')
|
|
11
|
+
* notifications.registerChannel('slack', slackChannel)
|
|
12
|
+
*
|
|
13
|
+
* // In notification class:
|
|
14
|
+
* toSlack(notifiable: Notifiable): SlackMessage {
|
|
15
|
+
* return {
|
|
16
|
+
* text: `Order #${this.order.id} has been shipped!`,
|
|
17
|
+
* blocks: [
|
|
18
|
+
* {
|
|
19
|
+
* type: 'section',
|
|
20
|
+
* text: {
|
|
21
|
+
* type: 'mrkdwn',
|
|
22
|
+
* text: `*Order Shipped*\nOrder #${this.order.id} is on its way!`,
|
|
23
|
+
* },
|
|
24
|
+
* },
|
|
25
|
+
* ],
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class SlackChannel implements NotificationChannel {
|
|
31
|
+
private webhookUrl;
|
|
32
|
+
private options;
|
|
33
|
+
readonly name = "slack";
|
|
34
|
+
constructor(webhookUrl: string, options?: SlackChannelOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Send the notification to Slack.
|
|
37
|
+
*/
|
|
38
|
+
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Build the Slack webhook payload.
|
|
41
|
+
*/
|
|
42
|
+
protected buildPayload(message: SlackMessage): SlackWebhookPayload;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Slack channel options.
|
|
46
|
+
*/
|
|
47
|
+
export interface SlackChannelOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Default username for messages.
|
|
50
|
+
*/
|
|
51
|
+
username?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Default icon emoji for messages.
|
|
54
|
+
*/
|
|
55
|
+
iconEmoji?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Default icon URL for messages.
|
|
58
|
+
*/
|
|
59
|
+
iconUrl?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Slack webhook payload.
|
|
63
|
+
*/
|
|
64
|
+
interface SlackWebhookPayload {
|
|
65
|
+
text?: string;
|
|
66
|
+
blocks?: unknown[];
|
|
67
|
+
attachments?: unknown[];
|
|
68
|
+
channel?: string;
|
|
69
|
+
username?: string;
|
|
70
|
+
icon_emoji?: string;
|
|
71
|
+
icon_url?: string;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
@@ -1,322 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import '@guren/orm';
|
|
8
|
-
import 'vite';
|
|
9
|
-
import '../EventManager-CmIoLt7r.js';
|
|
10
|
-
import '../CacheManager-BmDzUKrF.js';
|
|
11
|
-
import '../LogManager-7mxnkaPM.js';
|
|
12
|
-
import '../I18nManager-BiSoczfV.js';
|
|
13
|
-
import '../BroadcastManager-D8KoJxiV.js';
|
|
14
|
-
import '../index-9_Jzj5jo.js';
|
|
15
|
-
import '../app-key-CsBfRC_Q.js';
|
|
16
|
-
import '../StorageManager-oZTHqaza.js';
|
|
17
|
-
import '../HealthManager-DUyMIzsZ.js';
|
|
18
|
-
import '../Scheduler-pZiT8i57.js';
|
|
19
|
-
import '../Gate-CynjZCtS.js';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* A notification class usable for queue reconstruction.
|
|
23
|
-
*
|
|
24
|
-
* Only the prototype and name are required: queued notifications are rebuilt
|
|
25
|
-
* with `Object.create(prototype)` and never constructed, so classes with
|
|
26
|
-
* required constructor arguments are supported.
|
|
27
|
-
*/
|
|
28
|
-
interface NotificationConstructor {
|
|
29
|
-
readonly name: string;
|
|
30
|
-
readonly prototype: Notification;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Register a notification class so queued instances can be rebuilt.
|
|
34
|
-
*
|
|
35
|
-
* Notifications are registered automatically when they are queued, which
|
|
36
|
-
* covers delivery by a worker running in the same process. A worker running
|
|
37
|
-
* in a separate process must register them explicitly at boot.
|
|
38
|
-
*
|
|
39
|
-
* Type names must be unique within an application: as with the job registry,
|
|
40
|
-
* registering a second class under an existing type replaces the first.
|
|
41
|
-
*
|
|
42
|
-
* @param notificationClass - The notification class to register
|
|
43
|
-
* @param type - Registry key, defaulting to the class's own `type` value
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* registerNotification(OrderShipped)
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
declare function registerNotification(notificationClass: NotificationConstructor, type?: string): void;
|
|
51
|
-
/**
|
|
52
|
-
* Get a registered notification class by type.
|
|
53
|
-
*/
|
|
54
|
-
declare function getNotification(type: string): NotificationConstructor | undefined;
|
|
55
|
-
/**
|
|
56
|
-
* Clear all registered notifications (for testing).
|
|
57
|
-
*/
|
|
58
|
-
declare function clearNotificationRegistry(): void;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Resolve the stable type name of a notifiable.
|
|
62
|
-
*
|
|
63
|
-
* Channels that record which entity a notification belongs to should use this
|
|
64
|
-
* rather than reading `constructor.name` directly: a notifiable rebuilt from a
|
|
65
|
-
* queue payload carries its original name in `notifiableType`, and its
|
|
66
|
-
* constructor is a plain object.
|
|
67
|
-
*/
|
|
68
|
-
declare function resolveNotifiableType(notifiable: Notifiable): string;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Mail notification channel.
|
|
72
|
-
*
|
|
73
|
-
* Sends notifications via email using the MailManager.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* const mailChannel = new MailChannel(mailManager)
|
|
78
|
-
* notifications.registerChannel('mail', mailChannel)
|
|
79
|
-
*
|
|
80
|
-
* // In notification class:
|
|
81
|
-
* toMail(notifiable: Notifiable): NotificationMailMessage {
|
|
82
|
-
* return {
|
|
83
|
-
* subject: 'Order Shipped',
|
|
84
|
-
* html: '<p>Your order has shipped!</p>',
|
|
85
|
-
* }
|
|
86
|
-
* }
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
declare class MailChannel implements NotificationChannel {
|
|
90
|
-
private mailManager;
|
|
91
|
-
private options;
|
|
92
|
-
readonly name = "mail";
|
|
93
|
-
constructor(mailManager: MailManager, options?: MailChannelOptions);
|
|
94
|
-
/**
|
|
95
|
-
* Send the notification via mail.
|
|
96
|
-
*/
|
|
97
|
-
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Mail channel options.
|
|
101
|
-
*/
|
|
102
|
-
interface MailChannelOptions {
|
|
103
|
-
/**
|
|
104
|
-
* Default from address.
|
|
105
|
-
*/
|
|
106
|
-
from?: string;
|
|
107
|
-
/**
|
|
108
|
-
* Transport name to use.
|
|
109
|
-
*/
|
|
110
|
-
transport?: string;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Database notification channel.
|
|
115
|
-
*
|
|
116
|
-
* Stores notifications in the database for in-app notifications.
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* ```typescript
|
|
120
|
-
* const dbChannel = new DatabaseChannel({
|
|
121
|
-
* store: async (notifiable, notification) => {
|
|
122
|
-
* await db.insert(notifications).values(notification)
|
|
123
|
-
* },
|
|
124
|
-
* })
|
|
125
|
-
* notifications.registerChannel('database', dbChannel)
|
|
126
|
-
*
|
|
127
|
-
* // In notification class:
|
|
128
|
-
* toDatabase(notifiable: Notifiable): Record<string, unknown> {
|
|
129
|
-
* return {
|
|
130
|
-
* orderId: this.order.id,
|
|
131
|
-
* message: 'Your order has shipped',
|
|
132
|
-
* }
|
|
133
|
-
* }
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
declare class DatabaseChannel implements NotificationChannel {
|
|
137
|
-
private options;
|
|
138
|
-
readonly name = "database";
|
|
139
|
-
protected stored: DatabaseNotification[];
|
|
140
|
-
constructor(options?: DatabaseChannelOptions);
|
|
141
|
-
/**
|
|
142
|
-
* Send the notification to the database.
|
|
143
|
-
*/
|
|
144
|
-
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
145
|
-
/**
|
|
146
|
-
* Get the notifiable ID.
|
|
147
|
-
*/
|
|
148
|
-
protected getNotifiableId(notifiable: Notifiable): string | number;
|
|
149
|
-
/**
|
|
150
|
-
* Get the notifiable type.
|
|
151
|
-
*/
|
|
152
|
-
protected getNotifiableType(notifiable: Notifiable): string;
|
|
153
|
-
/**
|
|
154
|
-
* Get all stored notifications (for testing).
|
|
155
|
-
*/
|
|
156
|
-
getStored(): DatabaseNotification[];
|
|
157
|
-
/**
|
|
158
|
-
* Get stored notifications for a notifiable.
|
|
159
|
-
*/
|
|
160
|
-
getStoredFor(notifiable: Notifiable): DatabaseNotification[];
|
|
161
|
-
/**
|
|
162
|
-
* Clear stored notifications (for testing).
|
|
163
|
-
*/
|
|
164
|
-
clear(): void;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Slack notification channel.
|
|
169
|
-
*
|
|
170
|
-
* Sends notifications to Slack via incoming webhooks.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```typescript
|
|
174
|
-
* const slackChannel = new SlackChannel('https://hooks.slack.com/services/...')
|
|
175
|
-
* notifications.registerChannel('slack', slackChannel)
|
|
176
|
-
*
|
|
177
|
-
* // In notification class:
|
|
178
|
-
* toSlack(notifiable: Notifiable): SlackMessage {
|
|
179
|
-
* return {
|
|
180
|
-
* text: `Order #${this.order.id} has been shipped!`,
|
|
181
|
-
* blocks: [
|
|
182
|
-
* {
|
|
183
|
-
* type: 'section',
|
|
184
|
-
* text: {
|
|
185
|
-
* type: 'mrkdwn',
|
|
186
|
-
* text: `*Order Shipped*\nOrder #${this.order.id} is on its way!`,
|
|
187
|
-
* },
|
|
188
|
-
* },
|
|
189
|
-
* ],
|
|
190
|
-
* }
|
|
191
|
-
* }
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
declare class SlackChannel implements NotificationChannel {
|
|
195
|
-
private webhookUrl;
|
|
196
|
-
private options;
|
|
197
|
-
readonly name = "slack";
|
|
198
|
-
constructor(webhookUrl: string, options?: SlackChannelOptions);
|
|
199
|
-
/**
|
|
200
|
-
* Send the notification to Slack.
|
|
201
|
-
*/
|
|
202
|
-
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
203
|
-
/**
|
|
204
|
-
* Build the Slack webhook payload.
|
|
205
|
-
*/
|
|
206
|
-
protected buildPayload(message: SlackMessage): SlackWebhookPayload;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Slack channel options.
|
|
210
|
-
*/
|
|
211
|
-
interface SlackChannelOptions {
|
|
212
|
-
/**
|
|
213
|
-
* Default username for messages.
|
|
214
|
-
*/
|
|
215
|
-
username?: string;
|
|
216
|
-
/**
|
|
217
|
-
* Default icon emoji for messages.
|
|
218
|
-
*/
|
|
219
|
-
iconEmoji?: string;
|
|
220
|
-
/**
|
|
221
|
-
* Default icon URL for messages.
|
|
222
|
-
*/
|
|
223
|
-
iconUrl?: string;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Slack webhook payload.
|
|
227
|
-
*/
|
|
228
|
-
interface SlackWebhookPayload {
|
|
229
|
-
text?: string;
|
|
230
|
-
blocks?: unknown[];
|
|
231
|
-
attachments?: unknown[];
|
|
232
|
-
channel?: string;
|
|
233
|
-
username?: string;
|
|
234
|
-
icon_emoji?: string;
|
|
235
|
-
icon_url?: string;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Memory notification channel for testing.
|
|
240
|
-
*
|
|
241
|
-
* Stores all sent notifications in memory for assertions.
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* ```typescript
|
|
245
|
-
* const memoryChannel = new MemoryChannel()
|
|
246
|
-
* notifications.registerChannel('memory', memoryChannel)
|
|
247
|
-
*
|
|
248
|
-
* await notifications.send(user, new OrderShipped(order))
|
|
249
|
-
*
|
|
250
|
-
* memoryChannel.assertSentTo(user, 'OrderShipped')
|
|
251
|
-
* memoryChannel.assertCount(1)
|
|
252
|
-
* ```
|
|
253
|
-
*/
|
|
254
|
-
declare class MemoryChannel implements NotificationChannel {
|
|
255
|
-
readonly name = "memory";
|
|
256
|
-
/**
|
|
257
|
-
* All sent notifications.
|
|
258
|
-
*/
|
|
259
|
-
sent: SentNotification[];
|
|
260
|
-
/**
|
|
261
|
-
* Send (store) the notification.
|
|
262
|
-
*/
|
|
263
|
-
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
264
|
-
/**
|
|
265
|
-
* Assert that a notification was sent to a notifiable.
|
|
266
|
-
*/
|
|
267
|
-
assertSentTo(notifiable: Notifiable, notificationType?: string): void;
|
|
268
|
-
/**
|
|
269
|
-
* Assert that a notification was not sent to a notifiable.
|
|
270
|
-
*/
|
|
271
|
-
assertNotSentTo(notifiable: Notifiable, notificationType?: string): void;
|
|
272
|
-
/**
|
|
273
|
-
* Assert the total count of sent notifications.
|
|
274
|
-
*/
|
|
275
|
-
assertCount(count: number): void;
|
|
276
|
-
/**
|
|
277
|
-
* Assert that a notification type was sent.
|
|
278
|
-
*/
|
|
279
|
-
assertSent(notificationType: string): void;
|
|
280
|
-
/**
|
|
281
|
-
* Assert that a notification type was not sent.
|
|
282
|
-
*/
|
|
283
|
-
assertNotSent(notificationType: string): void;
|
|
284
|
-
/**
|
|
285
|
-
* Assert that no notifications were sent.
|
|
286
|
-
*/
|
|
287
|
-
assertNothingSent(): void;
|
|
288
|
-
/**
|
|
289
|
-
* Get notifications sent to a specific notifiable.
|
|
290
|
-
*/
|
|
291
|
-
getSentTo(notifiable: Notifiable): SentNotification[];
|
|
292
|
-
/**
|
|
293
|
-
* Get notifications of a specific type.
|
|
294
|
-
*/
|
|
295
|
-
getSentOfType(notificationType: string): SentNotification[];
|
|
296
|
-
/**
|
|
297
|
-
* Check if a notification was sent to a notifiable.
|
|
298
|
-
*/
|
|
299
|
-
hasSentTo(notifiable: Notifiable, notificationType?: string): boolean;
|
|
300
|
-
/**
|
|
301
|
-
* Check if a notification type was sent.
|
|
302
|
-
*/
|
|
303
|
-
hasSent(notificationType: string): boolean;
|
|
304
|
-
/**
|
|
305
|
-
* Get the count of sent notifications.
|
|
306
|
-
*/
|
|
307
|
-
count(): number;
|
|
308
|
-
/**
|
|
309
|
-
* Get the last sent notification.
|
|
310
|
-
*/
|
|
311
|
-
last(): SentNotification | undefined;
|
|
312
|
-
/**
|
|
313
|
-
* Get the first sent notification.
|
|
314
|
-
*/
|
|
315
|
-
first(): SentNotification | undefined;
|
|
316
|
-
/**
|
|
317
|
-
* Clear all sent notifications.
|
|
318
|
-
*/
|
|
319
|
-
clear(): void;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export { DatabaseChannel, DatabaseChannelOptions, DatabaseNotification, MailChannel, type MailChannelOptions, MemoryChannel, Notifiable, Notification, NotificationChannel, type NotificationConstructor, SentNotification, SlackChannel, type SlackChannelOptions, SlackMessage, clearNotificationRegistry, getNotification, registerNotification, resolveNotifiableType };
|
|
1
|
+
export type { NotificationChannel, Notifiable, DatabaseNotification, NotificationMailMessage, NotificationAttachment, SlackMessage, SlackBlock, SlackAttachment, NotificationChannelFactory, NotificationManagerOptions, DatabaseChannelOptions, SentNotification, NotificationClass, } from './types.js';
|
|
2
|
+
export { Notification } from './Notification.js';
|
|
3
|
+
export { NotificationManager, setNotificationManager, getNotificationManager, createNotificationManager, } from './NotificationManager.js';
|
|
4
|
+
export { registerNotification, getNotification, clearNotificationRegistry, type NotificationConstructor, } from './registry.js';
|
|
5
|
+
export { resolveNotifiableType } from './notifiable-type.js';
|
|
6
|
+
export { MailChannel, type MailChannelOptions, DatabaseChannel, SlackChannel, type SlackChannelOptions, MemoryChannel, } from './channels/index.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Notifiable } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the stable type name of a notifiable.
|
|
4
|
+
*
|
|
5
|
+
* Channels that record which entity a notification belongs to should use this
|
|
6
|
+
* rather than reading `constructor.name` directly: a notifiable rebuilt from a
|
|
7
|
+
* queue payload carries its original name in `notifiableType`, and its
|
|
8
|
+
* constructor is a plain object.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveNotifiableType(notifiable: Notifiable): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Notification } from './Notification.js';
|
|
2
|
+
/**
|
|
3
|
+
* A notification class usable for queue reconstruction.
|
|
4
|
+
*
|
|
5
|
+
* Only the prototype and name are required: queued notifications are rebuilt
|
|
6
|
+
* with `Object.create(prototype)` and never constructed, so classes with
|
|
7
|
+
* required constructor arguments are supported.
|
|
8
|
+
*/
|
|
9
|
+
export interface NotificationConstructor {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly prototype: Notification;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Register a notification class so queued instances can be rebuilt.
|
|
15
|
+
*
|
|
16
|
+
* Notifications are registered automatically when they are queued, which
|
|
17
|
+
* covers delivery by a worker running in the same process. A worker running
|
|
18
|
+
* in a separate process must register them explicitly at boot.
|
|
19
|
+
*
|
|
20
|
+
* Type names must be unique within an application: as with the job registry,
|
|
21
|
+
* registering a second class under an existing type replaces the first.
|
|
22
|
+
*
|
|
23
|
+
* @param notificationClass - The notification class to register
|
|
24
|
+
* @param type - Registry key, defaulting to the class's own `type` value
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* registerNotification(OrderShipped)
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function registerNotification(notificationClass: NotificationConstructor, type?: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get a registered notification class by type.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getNotification(type: string): NotificationConstructor | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Clear all registered notifications (for testing).
|
|
38
|
+
*/
|
|
39
|
+
export declare function clearNotificationRegistry(): void;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { Notification } from './Notification.js';
|
|
2
|
+
/**
|
|
3
|
+
* Notification channel interface.
|
|
4
|
+
*/
|
|
5
|
+
export interface NotificationChannel {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Notifiable entity interface.
|
|
11
|
+
*/
|
|
12
|
+
export interface Notifiable {
|
|
13
|
+
/**
|
|
14
|
+
* Get the notification routing information for a given channel.
|
|
15
|
+
*/
|
|
16
|
+
routeNotificationFor(channel: string): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Stable type name for this notifiable (optional).
|
|
19
|
+
*
|
|
20
|
+
* Defaults to the constructor name. Set this when the notifiable is rebuilt
|
|
21
|
+
* from a queue payload, or when the class name is not durable (bundlers that
|
|
22
|
+
* mangle identifiers).
|
|
23
|
+
*/
|
|
24
|
+
notifiableType?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Database notifications (optional).
|
|
27
|
+
*/
|
|
28
|
+
notifications?: DatabaseNotification[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Database notification record.
|
|
32
|
+
*/
|
|
33
|
+
export interface DatabaseNotification {
|
|
34
|
+
id: string;
|
|
35
|
+
type: string;
|
|
36
|
+
notifiableId: string | number;
|
|
37
|
+
notifiableType: string;
|
|
38
|
+
data: Record<string, unknown>;
|
|
39
|
+
readAt: Date | null;
|
|
40
|
+
createdAt: Date;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Mail message for notifications.
|
|
44
|
+
*/
|
|
45
|
+
export interface NotificationMailMessage {
|
|
46
|
+
subject: string;
|
|
47
|
+
html?: string;
|
|
48
|
+
text?: string;
|
|
49
|
+
from?: string;
|
|
50
|
+
replyTo?: string;
|
|
51
|
+
cc?: string | string[];
|
|
52
|
+
bcc?: string | string[];
|
|
53
|
+
attachments?: NotificationAttachment[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Notification attachment.
|
|
57
|
+
*/
|
|
58
|
+
export interface NotificationAttachment {
|
|
59
|
+
filename: string;
|
|
60
|
+
content?: string | Buffer;
|
|
61
|
+
path?: string;
|
|
62
|
+
contentType?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Slack message for notifications.
|
|
66
|
+
*/
|
|
67
|
+
export interface SlackMessage {
|
|
68
|
+
text?: string;
|
|
69
|
+
blocks?: SlackBlock[];
|
|
70
|
+
attachments?: SlackAttachment[];
|
|
71
|
+
channel?: string;
|
|
72
|
+
username?: string;
|
|
73
|
+
icon_emoji?: string;
|
|
74
|
+
icon_url?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Slack block.
|
|
78
|
+
*/
|
|
79
|
+
export interface SlackBlock {
|
|
80
|
+
type: string;
|
|
81
|
+
text?: {
|
|
82
|
+
type: string;
|
|
83
|
+
text: string;
|
|
84
|
+
emoji?: boolean;
|
|
85
|
+
};
|
|
86
|
+
elements?: unknown[];
|
|
87
|
+
accessory?: unknown;
|
|
88
|
+
fields?: Array<{
|
|
89
|
+
type: string;
|
|
90
|
+
text: string;
|
|
91
|
+
}>;
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Slack attachment.
|
|
96
|
+
*/
|
|
97
|
+
export interface SlackAttachment {
|
|
98
|
+
color?: string;
|
|
99
|
+
fallback?: string;
|
|
100
|
+
pretext?: string;
|
|
101
|
+
author_name?: string;
|
|
102
|
+
author_link?: string;
|
|
103
|
+
author_icon?: string;
|
|
104
|
+
title?: string;
|
|
105
|
+
title_link?: string;
|
|
106
|
+
text?: string;
|
|
107
|
+
fields?: Array<{
|
|
108
|
+
title: string;
|
|
109
|
+
value: string;
|
|
110
|
+
short?: boolean;
|
|
111
|
+
}>;
|
|
112
|
+
image_url?: string;
|
|
113
|
+
thumb_url?: string;
|
|
114
|
+
footer?: string;
|
|
115
|
+
footer_icon?: string;
|
|
116
|
+
ts?: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Notification channel factory.
|
|
120
|
+
*/
|
|
121
|
+
export interface NotificationChannelFactory {
|
|
122
|
+
(config: Record<string, unknown>): NotificationChannel;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Notification manager options.
|
|
126
|
+
*/
|
|
127
|
+
export interface NotificationManagerOptions {
|
|
128
|
+
channels?: Record<string, NotificationChannel>;
|
|
129
|
+
channelFactories?: Record<string, NotificationChannelFactory>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Database channel options.
|
|
133
|
+
*/
|
|
134
|
+
export interface DatabaseChannelOptions {
|
|
135
|
+
/**
|
|
136
|
+
* Callback to store the notification.
|
|
137
|
+
*/
|
|
138
|
+
store?: (notifiable: Notifiable, notification: DatabaseNotification) => Promise<void>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Sent notification record (for testing).
|
|
142
|
+
*/
|
|
143
|
+
export interface SentNotification {
|
|
144
|
+
notifiable: Notifiable;
|
|
145
|
+
notification: Notification;
|
|
146
|
+
channels: string[];
|
|
147
|
+
timestamp: Date;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Notification class type.
|
|
151
|
+
*/
|
|
152
|
+
export interface NotificationClass<T extends Notification = Notification> {
|
|
153
|
+
new (...args: unknown[]): T;
|
|
154
|
+
shouldQueue?: boolean;
|
|
155
|
+
queue?: string;
|
|
156
|
+
delay?: number;
|
|
157
|
+
getQueueConfig?: () => {
|
|
158
|
+
shouldQueue: boolean;
|
|
159
|
+
queue?: string;
|
|
160
|
+
delay?: number;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ServiceProvider } from '../container/ServiceProvider.js';
|
|
2
|
+
/**
|
|
3
|
+
* Binds the Gate as a singleton in the container and exposes it as the
|
|
4
|
+
* global gate so `getGate()`, `can()`, and controller authorization helpers
|
|
5
|
+
* work without manual wiring.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AuthorizationServiceProvider extends ServiceProvider {
|
|
8
|
+
register(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ServiceProvider } from '../container/ServiceProvider.js';
|
|
2
|
+
/**
|
|
3
|
+
* Binds the ExceptionHandler as a singleton in the container
|
|
4
|
+
* and attaches it as global error-handling middleware.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ErrorServiceProvider extends ServiceProvider {
|
|
7
|
+
register(): void;
|
|
8
|
+
boot(): void;
|
|
9
|
+
}
|