@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
|
@@ -1,86 +1,33 @@
|
|
|
1
|
-
import { o as registerJob, t as Job } from "./Job-
|
|
1
|
+
import { o as registerJob, t as Job } from "./Job-DxQK8h3P.js";
|
|
2
2
|
import { t as parseMailAddress } from "./address-D0Iq-XIH.js";
|
|
3
3
|
//#region src/notifications/Notification.ts
|
|
4
4
|
/**
|
|
5
|
-
* Base notification class.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* class OrderShipped extends Notification {
|
|
10
|
-
* static shouldQueue = true
|
|
11
|
-
* static queue = 'notifications'
|
|
12
|
-
*
|
|
13
|
-
* constructor(private order: Order) {
|
|
14
|
-
* super()
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* via(notifiable: Notifiable): string[] {
|
|
18
|
-
* return ['mail', 'database']
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* toMail(notifiable: Notifiable): NotificationMailMessage {
|
|
22
|
-
* return {
|
|
23
|
-
* subject: `Order #${this.order.id} shipped`,
|
|
24
|
-
* html: '<p>Your order is on its way!</p>',
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
*
|
|
28
|
-
* toDatabase(notifiable: Notifiable): Record<string, unknown> {
|
|
29
|
-
* return {
|
|
30
|
-
* orderId: this.order.id,
|
|
31
|
-
* message: 'Your order has shipped',
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
5
|
+
* Base notification class. Subclasses declare their channels in `via()` and one
|
|
6
|
+
* `to*()` method per channel; `static shouldQueue`/`queue`/`delay` control
|
|
7
|
+
* queueing.
|
|
36
8
|
*/
|
|
37
9
|
var Notification = class {
|
|
38
|
-
/**
|
|
39
|
-
* Whether this notification should be queued.
|
|
40
|
-
*/
|
|
41
10
|
static shouldQueue = false;
|
|
42
|
-
/**
|
|
43
|
-
* The queue name for this notification.
|
|
44
|
-
*/
|
|
45
11
|
static queue;
|
|
46
|
-
/**
|
|
47
|
-
* Delay in milliseconds before sending.
|
|
48
|
-
*/
|
|
12
|
+
/** Delay in milliseconds before sending. */
|
|
49
13
|
static delay;
|
|
50
|
-
/**
|
|
51
|
-
* Unique notification ID.
|
|
52
|
-
*/
|
|
53
14
|
id;
|
|
54
|
-
/**
|
|
55
|
-
* When the notification was created.
|
|
56
|
-
*/
|
|
57
15
|
createdAt;
|
|
58
16
|
constructor() {
|
|
59
17
|
this.id = this.generateId();
|
|
60
18
|
this.createdAt = /* @__PURE__ */ new Date();
|
|
61
19
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Get the notification type (default: class name).
|
|
64
|
-
*/
|
|
20
|
+
/** Notification type; defaults to the class name. */
|
|
65
21
|
get type() {
|
|
66
22
|
return this.constructor.name;
|
|
67
23
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Check if the notification should be sent to the given notifiable.
|
|
70
|
-
* Override to add custom logic.
|
|
71
|
-
*/
|
|
24
|
+
/** Override to skip delivery for a given notifiable. */
|
|
72
25
|
shouldSend(_notifiable) {
|
|
73
26
|
return true;
|
|
74
27
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Generate a unique notification ID.
|
|
77
|
-
*/
|
|
78
28
|
generateId() {
|
|
79
29
|
return `notif_${Date.now().toString(36)}${Math.random().toString(36).substring(2, 10)}`;
|
|
80
30
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Get static queue configuration.
|
|
83
|
-
*/
|
|
84
31
|
static getQueueConfig() {
|
|
85
32
|
return {
|
|
86
33
|
shouldQueue: this.shouldQueue,
|
|
@@ -93,10 +40,8 @@ var Notification = class {
|
|
|
93
40
|
//#region src/notifications/registry.ts
|
|
94
41
|
const notificationRegistry = /* @__PURE__ */ new Map();
|
|
95
42
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* Reads the `type` getter off the prototype so a class overriding it registers
|
|
99
|
-
* under the same key the dispatched payload carries.
|
|
43
|
+
* The registry key for a class, read off the prototype's `type` getter so a
|
|
44
|
+
* class overriding it registers under the key its payloads carry.
|
|
100
45
|
*/
|
|
101
46
|
function resolveRegistryKey(notificationClass) {
|
|
102
47
|
try {
|
|
@@ -106,72 +51,34 @@ function resolveRegistryKey(notificationClass) {
|
|
|
106
51
|
return notificationClass.name;
|
|
107
52
|
}
|
|
108
53
|
/**
|
|
109
|
-
* Register a notification class so queued instances can be rebuilt.
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* in a separate process must register them explicitly at boot.
|
|
114
|
-
*
|
|
115
|
-
* Type names must be unique within an application: as with the job registry,
|
|
116
|
-
* registering a second class under an existing type replaces the first.
|
|
117
|
-
*
|
|
118
|
-
* @param notificationClass - The notification class to register
|
|
119
|
-
* @param type - Registry key, defaulting to the class's own `type` value
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```typescript
|
|
123
|
-
* registerNotification(OrderShipped)
|
|
124
|
-
* ```
|
|
54
|
+
* Register a notification class so queued instances can be rebuilt. Queueing
|
|
55
|
+
* registers automatically, which covers a worker in the same process; a worker
|
|
56
|
+
* in a separate process must register at boot. Type names must be unique — a
|
|
57
|
+
* second class under an existing type replaces the first.
|
|
125
58
|
*/
|
|
126
59
|
function registerNotification(notificationClass, type) {
|
|
127
60
|
notificationRegistry.set(type ?? resolveRegistryKey(notificationClass), notificationClass);
|
|
128
61
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Get a registered notification class by type.
|
|
131
|
-
*/
|
|
132
62
|
function getNotification(type) {
|
|
133
63
|
return notificationRegistry.get(type);
|
|
134
64
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Clear all registered notifications (for testing).
|
|
137
|
-
*/
|
|
65
|
+
/** Clear all registered notifications (for testing). */
|
|
138
66
|
function clearNotificationRegistry() {
|
|
139
67
|
notificationRegistry.clear();
|
|
140
68
|
}
|
|
141
69
|
//#endregion
|
|
142
70
|
//#region src/notifications/notifiable-type.ts
|
|
143
71
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* rather than reading `constructor.name` directly: a notifiable rebuilt from a
|
|
148
|
-
* queue payload carries its original name in `notifiableType`, and its
|
|
149
|
-
* constructor is a plain object.
|
|
72
|
+
* The stable type name of a notifiable. Channels must use this rather than
|
|
73
|
+
* `constructor.name`: one rebuilt from a queue payload carries its original
|
|
74
|
+
* name in `notifiableType` and has a plain object as its constructor.
|
|
150
75
|
*/
|
|
151
76
|
function resolveNotifiableType(notifiable) {
|
|
152
77
|
return notifiable.notifiableType ?? notifiable.constructor?.name ?? "Unknown";
|
|
153
78
|
}
|
|
154
79
|
//#endregion
|
|
155
80
|
//#region src/notifications/NotificationManager.ts
|
|
156
|
-
/**
|
|
157
|
-
* Notification manager for sending notifications through multiple channels.
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* const notifications = new NotificationManager()
|
|
162
|
-
*
|
|
163
|
-
* notifications
|
|
164
|
-
* .registerChannel('mail', new MailChannel(mailManager))
|
|
165
|
-
* .registerChannel('database', new DatabaseChannel())
|
|
166
|
-
* .registerChannel('slack', new SlackChannel(webhookUrl))
|
|
167
|
-
*
|
|
168
|
-
* // Send notification
|
|
169
|
-
* await notifications.send(user, new OrderShipped(order))
|
|
170
|
-
*
|
|
171
|
-
* // Send to multiple users
|
|
172
|
-
* await notifications.sendToMany(admins, new NewUserRegistered(user))
|
|
173
|
-
* ```
|
|
174
|
-
*/
|
|
81
|
+
/** Sends notifications through multiple registered channels. */
|
|
175
82
|
var NotificationManager = class {
|
|
176
83
|
channels = /* @__PURE__ */ new Map();
|
|
177
84
|
channelFactories = /* @__PURE__ */ new Map();
|
|
@@ -180,23 +87,14 @@ var NotificationManager = class {
|
|
|
180
87
|
if (options.channels) for (const [name, channel] of Object.entries(options.channels)) this.registerChannel(name, channel);
|
|
181
88
|
if (options.channelFactories) for (const [name, factory] of Object.entries(options.channelFactories)) this.registerChannelFactory(name, factory);
|
|
182
89
|
}
|
|
183
|
-
/**
|
|
184
|
-
* Register a notification channel.
|
|
185
|
-
*/
|
|
186
90
|
registerChannel(name, channel) {
|
|
187
91
|
this.channels.set(name, channel);
|
|
188
92
|
return this;
|
|
189
93
|
}
|
|
190
|
-
/**
|
|
191
|
-
* Register a notification channel factory.
|
|
192
|
-
*/
|
|
193
94
|
registerChannelFactory(name, factory) {
|
|
194
95
|
this.channelFactories.set(name, factory);
|
|
195
96
|
return this;
|
|
196
97
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Get a notification channel by name.
|
|
199
|
-
*/
|
|
200
98
|
channel(name) {
|
|
201
99
|
const resolved = this.resolvedChannels.get(name);
|
|
202
100
|
if (resolved) return resolved;
|
|
@@ -210,15 +108,9 @@ var NotificationManager = class {
|
|
|
210
108
|
}
|
|
211
109
|
throw new Error(`Notification channel "${name}" not found`);
|
|
212
110
|
}
|
|
213
|
-
/**
|
|
214
|
-
* Check if a channel is registered.
|
|
215
|
-
*/
|
|
216
111
|
hasChannel(name) {
|
|
217
112
|
return this.channels.has(name) || this.channelFactories.has(name) || this.resolvedChannels.has(name);
|
|
218
113
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Get all registered channel names.
|
|
221
|
-
*/
|
|
222
114
|
getChannelNames() {
|
|
223
115
|
const names = /* @__PURE__ */ new Set([
|
|
224
116
|
...this.channels.keys(),
|
|
@@ -227,18 +119,13 @@ var NotificationManager = class {
|
|
|
227
119
|
]);
|
|
228
120
|
return Array.from(names);
|
|
229
121
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Send a notification to a notifiable entity.
|
|
232
|
-
* Respects queue configuration on the notification class.
|
|
233
|
-
*/
|
|
122
|
+
/** Send a notification, respecting the queue config on its class. */
|
|
234
123
|
async send(notifiable, notification) {
|
|
235
124
|
const queueConfig = notification.constructor.getQueueConfig?.() ?? { shouldQueue: false };
|
|
236
125
|
if (queueConfig.shouldQueue) await this.queue(notifiable, notification, queueConfig);
|
|
237
126
|
else await this.sendNow(notifiable, notification);
|
|
238
127
|
}
|
|
239
|
-
/**
|
|
240
|
-
* Send a notification immediately (bypasses queue).
|
|
241
|
-
*/
|
|
128
|
+
/** Send a notification immediately, bypassing the queue. */
|
|
242
129
|
async sendNow(notifiable, notification) {
|
|
243
130
|
if (!await notification.shouldSend(notifiable)) return;
|
|
244
131
|
const viaChannels = notification.via(notifiable);
|
|
@@ -251,9 +138,6 @@ var NotificationManager = class {
|
|
|
251
138
|
}
|
|
252
139
|
}));
|
|
253
140
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Queue a notification for later delivery.
|
|
256
|
-
*/
|
|
257
141
|
async queue(notifiable, notification, queueConfig) {
|
|
258
142
|
const job = this.registerQueueJob();
|
|
259
143
|
registerNotification(notification.constructor, notification.type);
|
|
@@ -265,26 +149,16 @@ var NotificationManager = class {
|
|
|
265
149
|
if (queueConfig.delay) await job.dispatchAfter(queueConfig.delay, payload, { queue: queueConfig.queue });
|
|
266
150
|
else await job.dispatch(payload, { queue: queueConfig.queue });
|
|
267
151
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Send notification to multiple notifiables.
|
|
270
|
-
*/
|
|
271
152
|
async sendToMany(notifiables, notification) {
|
|
272
153
|
await Promise.all(notifiables.map((notifiable) => this.send(notifiable, notification)));
|
|
273
154
|
}
|
|
274
|
-
/**
|
|
275
|
-
* Send notification immediately to multiple notifiables.
|
|
276
|
-
*/
|
|
277
155
|
async sendNowToMany(notifiables, notification) {
|
|
278
156
|
await Promise.all(notifiables.map((notifiable) => this.sendNow(notifiable, notification)));
|
|
279
157
|
}
|
|
280
158
|
/**
|
|
281
|
-
* Serialize notifiable for queue storage.
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* is arbitrary user code — often a closure on an object literal — and cannot
|
|
285
|
-
* be reconstructed from a payload.
|
|
286
|
-
*
|
|
287
|
-
* @param channels - Channels to resolve routes for
|
|
159
|
+
* Serialize a notifiable for queue storage. Routing is resolved here rather
|
|
160
|
+
* than in the worker: `routeNotificationFor` is arbitrary user code — often a
|
|
161
|
+
* closure on an object literal — and cannot be rebuilt from a payload.
|
|
288
162
|
*/
|
|
289
163
|
serializeNotifiable(notifiable, channels = []) {
|
|
290
164
|
const routes = {};
|
|
@@ -296,10 +170,9 @@ var NotificationManager = class {
|
|
|
296
170
|
};
|
|
297
171
|
}
|
|
298
172
|
/**
|
|
299
|
-
* Serialize notification for queue storage.
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
* rebuilding the registered class in the job handler, not by serializing it.
|
|
173
|
+
* Serialize a notification for queue storage. Only own enumerable properties
|
|
174
|
+
* are captured; behaviour is restored by rebuilding the registered class in
|
|
175
|
+
* the job handler.
|
|
303
176
|
*/
|
|
304
177
|
serializeNotification(notification) {
|
|
305
178
|
return {
|
|
@@ -309,10 +182,9 @@ var NotificationManager = class {
|
|
|
309
182
|
};
|
|
310
183
|
}
|
|
311
184
|
/**
|
|
312
|
-
* Bind this manager to the queued-notification job and register it.
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
* a notification itself: without it, the worker cannot resolve the job.
|
|
185
|
+
* Bind this manager to the queued-notification job and register it. Call it
|
|
186
|
+
* during boot in a process that runs a worker but may never send a
|
|
187
|
+
* notification itself, or the worker cannot resolve the job.
|
|
316
188
|
*/
|
|
317
189
|
registerQueueJob() {
|
|
318
190
|
SendNotificationJob.notificationManager = this;
|
|
@@ -320,9 +192,6 @@ var NotificationManager = class {
|
|
|
320
192
|
return SendNotificationJob;
|
|
321
193
|
}
|
|
322
194
|
};
|
|
323
|
-
/**
|
|
324
|
-
* Job for sending queued notifications.
|
|
325
|
-
*/
|
|
326
195
|
var SendNotificationJob = class extends Job {
|
|
327
196
|
static jobName = "SendNotificationJob";
|
|
328
197
|
static queue = "notifications";
|
|
@@ -335,9 +204,6 @@ var SendNotificationJob = class extends Job {
|
|
|
335
204
|
const notification = this.rebuildNotification(payload.notificationType, payload.notificationData);
|
|
336
205
|
await manager.sendNow(notifiable, notification);
|
|
337
206
|
}
|
|
338
|
-
/**
|
|
339
|
-
* Rebuild the notifiable from its serialized data.
|
|
340
|
-
*/
|
|
341
207
|
rebuildNotifiable(serialized) {
|
|
342
208
|
const { data, routes } = serialized;
|
|
343
209
|
return {
|
|
@@ -356,11 +222,9 @@ var SendNotificationJob = class extends Job {
|
|
|
356
222
|
};
|
|
357
223
|
}
|
|
358
224
|
/**
|
|
359
|
-
* Rebuild a real notification instance
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
* its prototype, so prototype methods (`via`, `toMail`, `toDatabase`,
|
|
363
|
-
* `toSlack`, `shouldSend`) are restored without running the constructor.
|
|
225
|
+
* Rebuild a real notification instance: the class is looked up in the
|
|
226
|
+
* registry and instantiated via its prototype, so prototype methods are
|
|
227
|
+
* restored without running the constructor.
|
|
364
228
|
*/
|
|
365
229
|
rebuildNotification(type, serialized) {
|
|
366
230
|
const NotificationClass = getNotification(type);
|
|
@@ -372,22 +236,13 @@ var SendNotificationJob = class extends Job {
|
|
|
372
236
|
}
|
|
373
237
|
};
|
|
374
238
|
let globalNotificationManager = null;
|
|
375
|
-
/**
|
|
376
|
-
* Set the global notification manager.
|
|
377
|
-
*/
|
|
378
239
|
function setNotificationManager(manager) {
|
|
379
240
|
globalNotificationManager = manager;
|
|
380
241
|
}
|
|
381
|
-
/**
|
|
382
|
-
* Get the global notification manager.
|
|
383
|
-
*/
|
|
384
242
|
function getNotificationManager() {
|
|
385
243
|
if (!globalNotificationManager) throw new Error("NotificationManager not initialized. Call setNotificationManager() first.");
|
|
386
244
|
return globalNotificationManager;
|
|
387
245
|
}
|
|
388
|
-
/**
|
|
389
|
-
* Create a notification manager.
|
|
390
|
-
*/
|
|
391
246
|
function createNotificationManager(options) {
|
|
392
247
|
return new NotificationManager(options);
|
|
393
248
|
}
|
|
@@ -402,25 +257,7 @@ function parseAddressList(input) {
|
|
|
402
257
|
const parsed = (Array.isArray(input) ? input : [input]).map((item) => parseAddress(item)).filter((item) => Boolean(item));
|
|
403
258
|
return parsed.length > 0 ? parsed : void 0;
|
|
404
259
|
}
|
|
405
|
-
/**
|
|
406
|
-
* Mail notification channel.
|
|
407
|
-
*
|
|
408
|
-
* Sends notifications via email using the MailManager.
|
|
409
|
-
*
|
|
410
|
-
* @example
|
|
411
|
-
* ```typescript
|
|
412
|
-
* const mailChannel = new MailChannel(mailManager)
|
|
413
|
-
* notifications.registerChannel('mail', mailChannel)
|
|
414
|
-
*
|
|
415
|
-
* // In notification class:
|
|
416
|
-
* toMail(notifiable: Notifiable): NotificationMailMessage {
|
|
417
|
-
* return {
|
|
418
|
-
* subject: 'Order Shipped',
|
|
419
|
-
* html: '<p>Your order has shipped!</p>',
|
|
420
|
-
* }
|
|
421
|
-
* }
|
|
422
|
-
* ```
|
|
423
|
-
*/
|
|
260
|
+
/** Mail notification channel: sends notifications through the MailManager. */
|
|
424
261
|
var MailChannel = class {
|
|
425
262
|
mailManager;
|
|
426
263
|
options;
|
|
@@ -429,9 +266,6 @@ var MailChannel = class {
|
|
|
429
266
|
this.mailManager = mailManager;
|
|
430
267
|
this.options = options;
|
|
431
268
|
}
|
|
432
|
-
/**
|
|
433
|
-
* Send the notification via mail.
|
|
434
|
-
*/
|
|
435
269
|
async send(notifiable, notification) {
|
|
436
270
|
const message = notification.toMail?.(notifiable);
|
|
437
271
|
if (!message) return;
|
|
@@ -460,29 +294,7 @@ var MailChannel = class {
|
|
|
460
294
|
};
|
|
461
295
|
//#endregion
|
|
462
296
|
//#region src/notifications/channels/DatabaseChannel.ts
|
|
463
|
-
/**
|
|
464
|
-
* Database notification channel.
|
|
465
|
-
*
|
|
466
|
-
* Stores notifications in the database for in-app notifications.
|
|
467
|
-
*
|
|
468
|
-
* @example
|
|
469
|
-
* ```typescript
|
|
470
|
-
* const dbChannel = new DatabaseChannel({
|
|
471
|
-
* store: async (notifiable, notification) => {
|
|
472
|
-
* await db.insert(notifications).values(notification)
|
|
473
|
-
* },
|
|
474
|
-
* })
|
|
475
|
-
* notifications.registerChannel('database', dbChannel)
|
|
476
|
-
*
|
|
477
|
-
* // In notification class:
|
|
478
|
-
* toDatabase(notifiable: Notifiable): Record<string, unknown> {
|
|
479
|
-
* return {
|
|
480
|
-
* orderId: this.order.id,
|
|
481
|
-
* message: 'Your order has shipped',
|
|
482
|
-
* }
|
|
483
|
-
* }
|
|
484
|
-
* ```
|
|
485
|
-
*/
|
|
297
|
+
/** Database notification channel, for in-app notifications. */
|
|
486
298
|
var DatabaseChannel = class {
|
|
487
299
|
options;
|
|
488
300
|
name = "database";
|
|
@@ -490,9 +302,6 @@ var DatabaseChannel = class {
|
|
|
490
302
|
constructor(options = {}) {
|
|
491
303
|
this.options = options;
|
|
492
304
|
}
|
|
493
|
-
/**
|
|
494
|
-
* Send the notification to the database.
|
|
495
|
-
*/
|
|
496
305
|
async send(notifiable, notification) {
|
|
497
306
|
const data = notification.toDatabase?.(notifiable);
|
|
498
307
|
if (!data) return;
|
|
@@ -511,70 +320,29 @@ var DatabaseChannel = class {
|
|
|
511
320
|
if (notifiable.notifications) notifiable.notifications.push(record);
|
|
512
321
|
}
|
|
513
322
|
}
|
|
514
|
-
/**
|
|
515
|
-
* Get the notifiable ID.
|
|
516
|
-
*/
|
|
517
323
|
getNotifiableId(notifiable) {
|
|
518
324
|
const withId = notifiable;
|
|
519
325
|
if (withId.id !== void 0) return withId.id;
|
|
520
326
|
return String(notifiable);
|
|
521
327
|
}
|
|
522
|
-
/**
|
|
523
|
-
* Get the notifiable type.
|
|
524
|
-
*/
|
|
525
328
|
getNotifiableType(notifiable) {
|
|
526
329
|
return resolveNotifiableType(notifiable);
|
|
527
330
|
}
|
|
528
|
-
/**
|
|
529
|
-
* Get all stored notifications (for testing).
|
|
530
|
-
*/
|
|
531
331
|
getStored() {
|
|
532
332
|
return [...this.stored];
|
|
533
333
|
}
|
|
534
|
-
/**
|
|
535
|
-
* Get stored notifications for a notifiable.
|
|
536
|
-
*/
|
|
537
334
|
getStoredFor(notifiable) {
|
|
538
335
|
const id = this.getNotifiableId(notifiable);
|
|
539
336
|
const type = this.getNotifiableType(notifiable);
|
|
540
337
|
return this.stored.filter((n) => n.notifiableId === id && n.notifiableType === type);
|
|
541
338
|
}
|
|
542
|
-
/**
|
|
543
|
-
* Clear stored notifications (for testing).
|
|
544
|
-
*/
|
|
545
339
|
clear() {
|
|
546
340
|
this.stored = [];
|
|
547
341
|
}
|
|
548
342
|
};
|
|
549
343
|
//#endregion
|
|
550
344
|
//#region src/notifications/channels/SlackChannel.ts
|
|
551
|
-
/**
|
|
552
|
-
* Slack notification channel.
|
|
553
|
-
*
|
|
554
|
-
* Sends notifications to Slack via incoming webhooks.
|
|
555
|
-
*
|
|
556
|
-
* @example
|
|
557
|
-
* ```typescript
|
|
558
|
-
* const slackChannel = new SlackChannel('https://hooks.slack.com/services/...')
|
|
559
|
-
* notifications.registerChannel('slack', slackChannel)
|
|
560
|
-
*
|
|
561
|
-
* // In notification class:
|
|
562
|
-
* toSlack(notifiable: Notifiable): SlackMessage {
|
|
563
|
-
* return {
|
|
564
|
-
* text: `Order #${this.order.id} has been shipped!`,
|
|
565
|
-
* blocks: [
|
|
566
|
-
* {
|
|
567
|
-
* type: 'section',
|
|
568
|
-
* text: {
|
|
569
|
-
* type: 'mrkdwn',
|
|
570
|
-
* text: `*Order Shipped*\nOrder #${this.order.id} is on its way!`,
|
|
571
|
-
* },
|
|
572
|
-
* },
|
|
573
|
-
* ],
|
|
574
|
-
* }
|
|
575
|
-
* }
|
|
576
|
-
* ```
|
|
577
|
-
*/
|
|
345
|
+
/** Slack notification channel: sends notifications via incoming webhooks. */
|
|
578
346
|
var SlackChannel = class {
|
|
579
347
|
webhookUrl;
|
|
580
348
|
options;
|
|
@@ -583,9 +351,6 @@ var SlackChannel = class {
|
|
|
583
351
|
this.webhookUrl = webhookUrl;
|
|
584
352
|
this.options = options;
|
|
585
353
|
}
|
|
586
|
-
/**
|
|
587
|
-
* Send the notification to Slack.
|
|
588
|
-
*/
|
|
589
354
|
async send(notifiable, notification) {
|
|
590
355
|
const message = notification.toSlack?.(notifiable);
|
|
591
356
|
if (!message) return;
|
|
@@ -602,9 +367,6 @@ var SlackChannel = class {
|
|
|
602
367
|
throw new Error(`Slack webhook failed: ${response.status} ${text}`);
|
|
603
368
|
}
|
|
604
369
|
}
|
|
605
|
-
/**
|
|
606
|
-
* Build the Slack webhook payload.
|
|
607
|
-
*/
|
|
608
370
|
buildPayload(message) {
|
|
609
371
|
const payload = {};
|
|
610
372
|
if (message.text) payload.text = message.text;
|
|
@@ -620,30 +382,12 @@ var SlackChannel = class {
|
|
|
620
382
|
//#endregion
|
|
621
383
|
//#region src/notifications/channels/MemoryChannel.ts
|
|
622
384
|
/**
|
|
623
|
-
* Memory notification channel for testing
|
|
624
|
-
*
|
|
625
|
-
* Stores all sent notifications in memory for assertions.
|
|
626
|
-
*
|
|
627
|
-
* @example
|
|
628
|
-
* ```typescript
|
|
629
|
-
* const memoryChannel = new MemoryChannel()
|
|
630
|
-
* notifications.registerChannel('memory', memoryChannel)
|
|
631
|
-
*
|
|
632
|
-
* await notifications.send(user, new OrderShipped(order))
|
|
633
|
-
*
|
|
634
|
-
* memoryChannel.assertSentTo(user, 'OrderShipped')
|
|
635
|
-
* memoryChannel.assertCount(1)
|
|
636
|
-
* ```
|
|
385
|
+
* Memory notification channel for testing: stores every sent notification in
|
|
386
|
+
* memory for assertions.
|
|
637
387
|
*/
|
|
638
388
|
var MemoryChannel = class {
|
|
639
389
|
name = "memory";
|
|
640
|
-
/**
|
|
641
|
-
* All sent notifications.
|
|
642
|
-
*/
|
|
643
390
|
sent = [];
|
|
644
|
-
/**
|
|
645
|
-
* Send (store) the notification.
|
|
646
|
-
*/
|
|
647
391
|
async send(notifiable, notification) {
|
|
648
392
|
this.sent.push({
|
|
649
393
|
notifiable,
|
|
@@ -652,9 +396,6 @@ var MemoryChannel = class {
|
|
|
652
396
|
timestamp: /* @__PURE__ */ new Date()
|
|
653
397
|
});
|
|
654
398
|
}
|
|
655
|
-
/**
|
|
656
|
-
* Assert that a notification was sent to a notifiable.
|
|
657
|
-
*/
|
|
658
399
|
assertSentTo(notifiable, notificationType) {
|
|
659
400
|
if (!this.sent.some((record) => {
|
|
660
401
|
const matchesNotifiable = record.notifiable === notifiable;
|
|
@@ -665,9 +406,6 @@ var MemoryChannel = class {
|
|
|
665
406
|
throw new Error(`Expected notification${typeMsg} to be sent to notifiable`);
|
|
666
407
|
}
|
|
667
408
|
}
|
|
668
|
-
/**
|
|
669
|
-
* Assert that a notification was not sent to a notifiable.
|
|
670
|
-
*/
|
|
671
409
|
assertNotSentTo(notifiable, notificationType) {
|
|
672
410
|
if (this.sent.some((record) => {
|
|
673
411
|
const matchesNotifiable = record.notifiable === notifiable;
|
|
@@ -678,45 +416,24 @@ var MemoryChannel = class {
|
|
|
678
416
|
throw new Error(`Expected notification${typeMsg} not to be sent to notifiable`);
|
|
679
417
|
}
|
|
680
418
|
}
|
|
681
|
-
/**
|
|
682
|
-
* Assert the total count of sent notifications.
|
|
683
|
-
*/
|
|
684
419
|
assertCount(count) {
|
|
685
420
|
if (this.sent.length !== count) throw new Error(`Expected ${count} notifications to be sent, but ${this.sent.length} were sent`);
|
|
686
421
|
}
|
|
687
|
-
/**
|
|
688
|
-
* Assert that a notification type was sent.
|
|
689
|
-
*/
|
|
690
422
|
assertSent(notificationType) {
|
|
691
423
|
if (!this.sent.some((record) => record.notification.type === notificationType)) throw new Error(`Expected notification of type "${notificationType}" to be sent`);
|
|
692
424
|
}
|
|
693
|
-
/**
|
|
694
|
-
* Assert that a notification type was not sent.
|
|
695
|
-
*/
|
|
696
425
|
assertNotSent(notificationType) {
|
|
697
426
|
if (this.sent.some((record) => record.notification.type === notificationType)) throw new Error(`Expected notification of type "${notificationType}" not to be sent`);
|
|
698
427
|
}
|
|
699
|
-
/**
|
|
700
|
-
* Assert that no notifications were sent.
|
|
701
|
-
*/
|
|
702
428
|
assertNothingSent() {
|
|
703
429
|
if (this.sent.length > 0) throw new Error(`Expected no notifications to be sent, but ${this.sent.length} were sent`);
|
|
704
430
|
}
|
|
705
|
-
/**
|
|
706
|
-
* Get notifications sent to a specific notifiable.
|
|
707
|
-
*/
|
|
708
431
|
getSentTo(notifiable) {
|
|
709
432
|
return this.sent.filter((record) => record.notifiable === notifiable);
|
|
710
433
|
}
|
|
711
|
-
/**
|
|
712
|
-
* Get notifications of a specific type.
|
|
713
|
-
*/
|
|
714
434
|
getSentOfType(notificationType) {
|
|
715
435
|
return this.sent.filter((record) => record.notification.type === notificationType);
|
|
716
436
|
}
|
|
717
|
-
/**
|
|
718
|
-
* Check if a notification was sent to a notifiable.
|
|
719
|
-
*/
|
|
720
437
|
hasSentTo(notifiable, notificationType) {
|
|
721
438
|
return this.sent.some((record) => {
|
|
722
439
|
const matchesNotifiable = record.notifiable === notifiable;
|
|
@@ -724,33 +441,18 @@ var MemoryChannel = class {
|
|
|
724
441
|
return matchesNotifiable && matchesType;
|
|
725
442
|
});
|
|
726
443
|
}
|
|
727
|
-
/**
|
|
728
|
-
* Check if a notification type was sent.
|
|
729
|
-
*/
|
|
730
444
|
hasSent(notificationType) {
|
|
731
445
|
return this.sent.some((record) => record.notification.type === notificationType);
|
|
732
446
|
}
|
|
733
|
-
/**
|
|
734
|
-
* Get the count of sent notifications.
|
|
735
|
-
*/
|
|
736
447
|
count() {
|
|
737
448
|
return this.sent.length;
|
|
738
449
|
}
|
|
739
|
-
/**
|
|
740
|
-
* Get the last sent notification.
|
|
741
|
-
*/
|
|
742
450
|
last() {
|
|
743
451
|
return this.sent[this.sent.length - 1];
|
|
744
452
|
}
|
|
745
|
-
/**
|
|
746
|
-
* Get the first sent notification.
|
|
747
|
-
*/
|
|
748
453
|
first() {
|
|
749
454
|
return this.sent[0];
|
|
750
455
|
}
|
|
751
|
-
/**
|
|
752
|
-
* Clear all sent notifications.
|
|
753
|
-
*/
|
|
754
456
|
clear() {
|
|
755
457
|
this.sent = [];
|
|
756
458
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ServiceProvider } from '../container/ServiceProvider.js';
|
|
2
|
-
/**
|
|
3
|
-
* Sets up authentication guards, session middleware, and auth context.
|
|
4
|
-
*/
|
|
2
|
+
/** Sets up authentication guards, session middleware, and auth context. */
|
|
5
3
|
export declare class AuthServiceProvider extends ServiceProvider {
|
|
6
4
|
register(): void;
|
|
7
5
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ServiceProvider } from '../container/ServiceProvider.js';
|
|
2
2
|
/**
|
|
3
|
-
* Binds the Gate as a singleton
|
|
4
|
-
*
|
|
5
|
-
* work without manual wiring.
|
|
3
|
+
* Binds the Gate as a singleton and sets it as the global gate, so `getGate()`,
|
|
4
|
+
* `can()`, and the controller authorization helpers need no manual wiring.
|
|
6
5
|
*/
|
|
7
6
|
export declare class AuthorizationServiceProvider extends ServiceProvider {
|
|
8
7
|
register(): void;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ServiceProvider } from '../container/ServiceProvider.js';
|
|
2
|
-
/**
|
|
3
|
-
* Binds the BroadcastManager as a singleton in the container.
|
|
4
|
-
*/
|
|
2
|
+
/** Binds the BroadcastManager as a singleton in the container. */
|
|
5
3
|
export declare class BroadcastServiceProvider extends ServiceProvider {
|
|
6
4
|
register(): void;
|
|
7
5
|
}
|