@beignet/core 0.0.1 → 0.0.2
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/CHANGELOG.md +11 -0
- package/README.md +149 -4
- package/dist/application/index.d.ts +93 -9
- package/dist/application/index.d.ts.map +1 -1
- package/dist/application/index.js +11 -11
- package/dist/application/index.js.map +1 -1
- package/dist/client/client.d.ts +73 -12
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +37 -12
- package/dist/client/client.js.map +1 -1
- package/dist/client/index.d.ts +12 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +6 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +69 -8
- package/dist/client/types.d.ts.map +1 -1
- package/dist/config/index.d.ts +84 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +36 -0
- package/dist/config/index.js.map +1 -1
- package/dist/contracts/contract-builder.d.ts +49 -22
- package/dist/contracts/contract-builder.d.ts.map +1 -1
- package/dist/contracts/contract-builder.js +48 -21
- package/dist/contracts/contract-builder.js.map +1 -1
- package/dist/contracts/contract-group.d.ts +35 -19
- package/dist/contracts/contract-group.d.ts.map +1 -1
- package/dist/contracts/contract-group.js +35 -19
- package/dist/contracts/contract-group.js.map +1 -1
- package/dist/contracts/contract-like.d.ts +4 -4
- package/dist/contracts/contract-like.d.ts.map +1 -1
- package/dist/contracts/contract-like.js +2 -1
- package/dist/contracts/contract-like.js.map +1 -1
- package/dist/contracts/index.d.ts +28 -0
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +12 -0
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/openapi-meta.d.ts +8 -8
- package/dist/contracts/openapi-meta.d.ts.map +1 -1
- package/dist/contracts/path-template.d.ts +27 -0
- package/dist/contracts/path-template.d.ts.map +1 -1
- package/dist/contracts/path-template.js +6 -0
- package/dist/contracts/path-template.js.map +1 -1
- package/dist/contracts/types.d.ts +104 -10
- package/dist/contracts/types.d.ts.map +1 -1
- package/dist/contracts/types.js +15 -0
- package/dist/contracts/types.js.map +1 -1
- package/dist/contracts/utils.d.ts +6 -0
- package/dist/contracts/utils.d.ts.map +1 -1
- package/dist/contracts/utils.js +6 -0
- package/dist/contracts/utils.js.map +1 -1
- package/dist/domain/entity.d.ts +22 -11
- package/dist/domain/entity.d.ts.map +1 -1
- package/dist/domain/entity.js +5 -1
- package/dist/domain/entity.js.map +1 -1
- package/dist/domain/events.d.ts +5 -2
- package/dist/domain/events.d.ts.map +1 -1
- package/dist/domain/events.js +4 -1
- package/dist/domain/events.js.map +1 -1
- package/dist/domain/value-object.d.ts +19 -9
- package/dist/domain/value-object.d.ts.map +1 -1
- package/dist/domain/value-object.js +5 -1
- package/dist/domain/value-object.js.map +1 -1
- package/dist/errors/catalog.d.ts +40 -16
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/catalog.js +18 -7
- package/dist/errors/catalog.js.map +1 -1
- package/dist/errors/response.d.ts +16 -4
- package/dist/errors/response.d.ts.map +1 -1
- package/dist/errors/response.js +3 -3
- package/dist/errors/response.js.map +1 -1
- package/dist/errors/validation.d.ts +10 -1
- package/dist/errors/validation.d.ts.map +1 -1
- package/dist/errors/validation.js +3 -0
- package/dist/errors/validation.js.map +1 -1
- package/dist/events/index.d.ts +133 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +30 -0
- package/dist/events/index.js.map +1 -1
- package/dist/idempotency/index.d.ts +355 -0
- package/dist/idempotency/index.d.ts.map +1 -0
- package/dist/idempotency/index.js +360 -0
- package/dist/idempotency/index.js.map +1 -0
- package/dist/jobs/index.d.ts +110 -0
- package/dist/jobs/index.d.ts.map +1 -1
- package/dist/jobs/index.js +22 -0
- package/dist/jobs/index.js.map +1 -1
- package/dist/mail/index.d.ts +149 -0
- package/dist/mail/index.d.ts.map +1 -1
- package/dist/mail/index.js +30 -0
- package/dist/mail/index.js.map +1 -1
- package/dist/notifications/index.d.ts +369 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +310 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/openapi/index.d.ts +132 -16
- package/dist/openapi/index.d.ts.map +1 -1
- package/dist/openapi/index.js +1 -1
- package/dist/openapi/index.js.map +1 -1
- package/dist/outbox/index.d.ts +469 -0
- package/dist/outbox/index.d.ts.map +1 -0
- package/dist/outbox/index.js +482 -0
- package/dist/outbox/index.js.map +1 -0
- package/dist/pagination/index.d.ts +166 -0
- package/dist/pagination/index.d.ts.map +1 -0
- package/dist/pagination/index.js +96 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/ports/audit.d.ts +271 -0
- package/dist/ports/audit.d.ts.map +1 -1
- package/dist/ports/audit.js +128 -0
- package/dist/ports/audit.js.map +1 -1
- package/dist/ports/auth.d.ts +70 -0
- package/dist/ports/auth.d.ts.map +1 -1
- package/dist/ports/auth.js +30 -0
- package/dist/ports/auth.js.map +1 -1
- package/dist/ports/cache.d.ts +41 -0
- package/dist/ports/cache.d.ts.map +1 -1
- package/dist/ports/cache.js +10 -0
- package/dist/ports/cache.js.map +1 -1
- package/dist/ports/clock.d.ts +38 -0
- package/dist/ports/clock.d.ts.map +1 -1
- package/dist/ports/clock.js +20 -0
- package/dist/ports/clock.js.map +1 -1
- package/dist/ports/id-generator.d.ts +37 -0
- package/dist/ports/id-generator.d.ts.map +1 -1
- package/dist/ports/id-generator.js +22 -0
- package/dist/ports/id-generator.js.map +1 -1
- package/dist/ports/index.d.ts +83 -0
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js +41 -5
- package/dist/ports/index.js.map +1 -1
- package/dist/ports/logger.d.ts +56 -0
- package/dist/ports/logger.d.ts.map +1 -1
- package/dist/ports/logger.js +17 -0
- package/dist/ports/logger.js.map +1 -1
- package/dist/ports/policy.d.ts +132 -0
- package/dist/ports/policy.d.ts.map +1 -1
- package/dist/ports/policy.js +45 -0
- package/dist/ports/policy.js.map +1 -1
- package/dist/ports/rate-limit.d.ts +25 -0
- package/dist/ports/rate-limit.d.ts.map +1 -1
- package/dist/ports/rate-limit.js +10 -0
- package/dist/ports/rate-limit.js.map +1 -1
- package/dist/ports/redaction.d.ts +101 -0
- package/dist/ports/redaction.d.ts.map +1 -1
- package/dist/ports/redaction.js +59 -0
- package/dist/ports/redaction.js.map +1 -1
- package/dist/ports/storage.d.ts +100 -0
- package/dist/ports/storage.d.ts.map +1 -1
- package/dist/ports/storage.js +10 -0
- package/dist/ports/storage.js.map +1 -1
- package/dist/ports/testing.d.ts +47 -0
- package/dist/ports/testing.d.ts.map +1 -1
- package/dist/ports/testing.js +23 -0
- package/dist/ports/testing.js.map +1 -1
- package/dist/ports/unit-of-work.d.ts +60 -3
- package/dist/ports/unit-of-work.d.ts.map +1 -1
- package/dist/ports/unit-of-work.js +11 -2
- package/dist/ports/unit-of-work.js.map +1 -1
- package/dist/providers/instrumentation.d.ts +204 -0
- package/dist/providers/instrumentation.d.ts.map +1 -1
- package/dist/providers/instrumentation.js +14 -0
- package/dist/providers/instrumentation.js.map +1 -1
- package/dist/providers/provider.d.ts +14 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/provider.js.map +1 -1
- package/dist/schedules/index.d.ts +246 -0
- package/dist/schedules/index.d.ts.map +1 -1
- package/dist/schedules/index.js +27 -0
- package/dist/schedules/index.js.map +1 -1
- package/dist/server/health.d.ts +14 -5
- package/dist/server/health.d.ts.map +1 -1
- package/dist/server/health.js +5 -2
- package/dist/server/health.js.map +1 -1
- package/dist/server/hooks/auth.d.ts +57 -0
- package/dist/server/hooks/auth.d.ts.map +1 -1
- package/dist/server/hooks/auth.js.map +1 -1
- package/dist/server/hooks/cors.d.ts +27 -0
- package/dist/server/hooks/cors.d.ts.map +1 -1
- package/dist/server/hooks/cors.js +12 -0
- package/dist/server/hooks/cors.js.map +1 -1
- package/dist/server/hooks/errors.d.ts +15 -6
- package/dist/server/hooks/errors.d.ts.map +1 -1
- package/dist/server/hooks/errors.js.map +1 -1
- package/dist/server/hooks/index.d.ts +3 -0
- package/dist/server/hooks/index.d.ts.map +1 -1
- package/dist/server/hooks/index.js +3 -0
- package/dist/server/hooks/index.js.map +1 -1
- package/dist/server/hooks/logging.d.ts +36 -0
- package/dist/server/hooks/logging.d.ts.map +1 -1
- package/dist/server/hooks/logging.js +6 -0
- package/dist/server/hooks/logging.js.map +1 -1
- package/dist/server/hooks/rate-limit.d.ts +33 -0
- package/dist/server/hooks/rate-limit.d.ts.map +1 -1
- package/dist/server/hooks/rate-limit.js +11 -0
- package/dist/server/hooks/rate-limit.js.map +1 -1
- package/dist/server/http.d.ts +170 -0
- package/dist/server/http.d.ts.map +1 -1
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +6 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/openapi.d.ts +5 -3
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/openapi.js +4 -2
- package/dist/server/openapi.js.map +1 -1
- package/dist/server/providers/loadProviderConfig.d.ts +9 -0
- package/dist/server/providers/loadProviderConfig.d.ts.map +1 -1
- package/dist/server/providers/loadProviderConfig.js +9 -0
- package/dist/server/providers/loadProviderConfig.js.map +1 -1
- package/dist/server/server.d.ts +107 -8
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +27 -7
- package/dist/server/server.js.map +1 -1
- package/dist/testing/index.d.ts +167 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +119 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +21 -1
- package/src/application/index.ts +85 -22
- package/src/client/client.ts +73 -12
- package/src/client/index.ts +12 -0
- package/src/client/types.ts +70 -9
- package/src/config/index.ts +86 -0
- package/src/contracts/contract-builder.ts +49 -22
- package/src/contracts/contract-group.ts +35 -19
- package/src/contracts/contract-like.ts +4 -4
- package/src/contracts/index.ts +28 -1
- package/src/contracts/openapi-meta.ts +8 -8
- package/src/contracts/path-template.ts +27 -0
- package/src/contracts/types.ts +111 -10
- package/src/contracts/utils.ts +6 -0
- package/src/domain/entity.ts +22 -11
- package/src/domain/events.ts +5 -2
- package/src/domain/value-object.ts +19 -9
- package/src/errors/catalog.ts +40 -16
- package/src/errors/response.ts +16 -4
- package/src/errors/validation.ts +10 -1
- package/src/events/index.ts +134 -0
- package/src/idempotency/index.ts +767 -0
- package/src/jobs/index.ts +111 -0
- package/src/mail/index.ts +149 -0
- package/src/notifications/index.ts +771 -0
- package/src/openapi/index.ts +133 -16
- package/src/outbox/index.ts +1024 -0
- package/src/pagination/index.ts +278 -0
- package/src/ports/audit.ts +271 -0
- package/src/ports/auth.ts +70 -0
- package/src/ports/cache.ts +41 -0
- package/src/ports/clock.ts +38 -0
- package/src/ports/id-generator.ts +37 -0
- package/src/ports/index.ts +106 -11
- package/src/ports/logger.ts +56 -0
- package/src/ports/policy.ts +133 -0
- package/src/ports/rate-limit.ts +25 -0
- package/src/ports/redaction.ts +101 -0
- package/src/ports/storage.ts +100 -0
- package/src/ports/testing.ts +47 -0
- package/src/ports/unit-of-work.ts +60 -3
- package/src/providers/instrumentation.ts +204 -0
- package/src/providers/provider.ts +14 -1
- package/src/schedules/index.ts +247 -0
- package/src/server/health.ts +14 -5
- package/src/server/hooks/auth.ts +58 -0
- package/src/server/hooks/cors.ts +27 -0
- package/src/server/hooks/errors.ts +15 -6
- package/src/server/hooks/index.ts +3 -0
- package/src/server/hooks/logging.ts +36 -0
- package/src/server/hooks/rate-limit.ts +33 -0
- package/src/server/http.ts +170 -1
- package/src/server/index.ts +18 -1
- package/src/server/openapi.ts +5 -3
- package/src/server/providers/loadProviderConfig.ts +9 -0
- package/src/server/server.ts +107 -9
- package/src/testing/index.ts +337 -0
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
import type { SendMailOptions } from "../mail";
|
|
3
|
+
import type { ProviderInstrumentationTarget } from "../providers";
|
|
4
|
+
import { createProviderInstrumentation } from "../providers";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Any Standard Schema compatible validator.
|
|
8
|
+
*/
|
|
9
|
+
export type StandardSchema = StandardSchemaV1<unknown, unknown>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Value or promise of that value.
|
|
13
|
+
*/
|
|
14
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Infer the parsed output type from a Standard Schema.
|
|
18
|
+
*/
|
|
19
|
+
export type InferSchemaOutput<T extends StandardSchemaV1> =
|
|
20
|
+
StandardSchemaV1.InferOutput<T>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Minimal notification definition shape accepted by notification ports.
|
|
24
|
+
*/
|
|
25
|
+
export interface NotificationPayloadDef<
|
|
26
|
+
Name extends string = string,
|
|
27
|
+
Payload extends StandardSchema = StandardSchema,
|
|
28
|
+
> {
|
|
29
|
+
/**
|
|
30
|
+
* Stable notification name used by dispatchers, tests, and tooling.
|
|
31
|
+
*/
|
|
32
|
+
readonly name: Name;
|
|
33
|
+
/**
|
|
34
|
+
* Standard Schema payload validator.
|
|
35
|
+
*/
|
|
36
|
+
readonly payload: Payload;
|
|
37
|
+
/**
|
|
38
|
+
* Optional human-readable description for docs and tooling.
|
|
39
|
+
*/
|
|
40
|
+
readonly description?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Infer the parsed payload type for a notification definition.
|
|
45
|
+
*/
|
|
46
|
+
export type InferNotificationPayload<N extends NotificationPayloadDef> =
|
|
47
|
+
N["payload"] extends StandardSchemaV1<unknown, infer Output> ? Output : never;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Result for one notification channel.
|
|
51
|
+
*/
|
|
52
|
+
export interface NotificationChannelResult {
|
|
53
|
+
/**
|
|
54
|
+
* Channel name, such as `email`, `sms`, `push`, or `inApp`.
|
|
55
|
+
*/
|
|
56
|
+
channel: string;
|
|
57
|
+
/**
|
|
58
|
+
* Delivery outcome for this channel.
|
|
59
|
+
*/
|
|
60
|
+
status: "sent" | "skipped" | "failed";
|
|
61
|
+
/**
|
|
62
|
+
* Provider delivery ID when available.
|
|
63
|
+
*/
|
|
64
|
+
id?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Provider name when available.
|
|
67
|
+
*/
|
|
68
|
+
provider?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Human-readable skip or failure reason.
|
|
71
|
+
*/
|
|
72
|
+
reason?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Channel-specific metadata. Dispatchers should keep this safe to log.
|
|
75
|
+
*/
|
|
76
|
+
details?: Record<string, unknown>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Arguments passed to a notification channel handler.
|
|
81
|
+
*/
|
|
82
|
+
export interface NotificationChannelHandleArgs<
|
|
83
|
+
Payload extends StandardSchema,
|
|
84
|
+
Ctx,
|
|
85
|
+
> {
|
|
86
|
+
/**
|
|
87
|
+
* Notification definition being delivered.
|
|
88
|
+
*/
|
|
89
|
+
notification: NotificationDef<string, Payload, Ctx>;
|
|
90
|
+
/**
|
|
91
|
+
* Parsed notification payload.
|
|
92
|
+
*/
|
|
93
|
+
payload: InferSchemaOutput<Payload>;
|
|
94
|
+
/**
|
|
95
|
+
* Handler context.
|
|
96
|
+
*/
|
|
97
|
+
ctx: Ctx;
|
|
98
|
+
/**
|
|
99
|
+
* Channel name being delivered.
|
|
100
|
+
*/
|
|
101
|
+
channel: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Handler for one notification channel.
|
|
106
|
+
*/
|
|
107
|
+
export type NotificationChannelHandler<Payload extends StandardSchema, Ctx> = (
|
|
108
|
+
args: NotificationChannelHandleArgs<Payload, Ctx>,
|
|
109
|
+
) => MaybePromise<NotificationChannelResult | undefined>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Notification channel handlers keyed by channel name.
|
|
113
|
+
*/
|
|
114
|
+
export type NotificationChannels<Payload extends StandardSchema, Ctx> = Record<
|
|
115
|
+
string,
|
|
116
|
+
NotificationChannelHandler<Payload, Ctx>
|
|
117
|
+
>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Notification definition created by `defineNotification(...)`.
|
|
121
|
+
*/
|
|
122
|
+
export interface NotificationDef<
|
|
123
|
+
Name extends string = string,
|
|
124
|
+
Payload extends StandardSchema = StandardSchema,
|
|
125
|
+
Ctx = unknown,
|
|
126
|
+
> extends NotificationPayloadDef<Name, Payload> {
|
|
127
|
+
/**
|
|
128
|
+
* Discriminator for notification definitions.
|
|
129
|
+
*/
|
|
130
|
+
readonly kind: "notification";
|
|
131
|
+
/**
|
|
132
|
+
* Channel handlers that deliver the notification.
|
|
133
|
+
*/
|
|
134
|
+
readonly channels: NotificationChannels<Payload, Ctx>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Options for declaring a typed notification.
|
|
139
|
+
*/
|
|
140
|
+
export interface DefineNotificationOptions<
|
|
141
|
+
Payload extends StandardSchema,
|
|
142
|
+
Ctx,
|
|
143
|
+
> {
|
|
144
|
+
/**
|
|
145
|
+
* Standard Schema payload validator.
|
|
146
|
+
*/
|
|
147
|
+
payload: Payload;
|
|
148
|
+
/**
|
|
149
|
+
* Optional human-readable description for docs and tooling.
|
|
150
|
+
*/
|
|
151
|
+
description?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Channel handlers that deliver the notification.
|
|
154
|
+
*/
|
|
155
|
+
channels: NotificationChannels<Payload, Ctx>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Options passed when sending a notification.
|
|
160
|
+
*/
|
|
161
|
+
export interface SendNotificationOptions {
|
|
162
|
+
/**
|
|
163
|
+
* Subset of channels to deliver. Defaults to all channels on the definition.
|
|
164
|
+
*/
|
|
165
|
+
channels?: readonly string[];
|
|
166
|
+
/**
|
|
167
|
+
* Optional app metadata attached to memory deliveries and instrumentation.
|
|
168
|
+
*/
|
|
169
|
+
metadata?: Record<string, unknown>;
|
|
170
|
+
/**
|
|
171
|
+
* Request correlation ID for instrumentation.
|
|
172
|
+
*/
|
|
173
|
+
requestId?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Trace identifier for instrumentation.
|
|
176
|
+
*/
|
|
177
|
+
traceId?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Span identifier for instrumentation.
|
|
180
|
+
*/
|
|
181
|
+
spanId?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Parent span identifier for instrumentation.
|
|
184
|
+
*/
|
|
185
|
+
parentSpanId?: string;
|
|
186
|
+
/**
|
|
187
|
+
* W3C traceparent header value for instrumentation.
|
|
188
|
+
*/
|
|
189
|
+
traceparent?: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Result returned after a notification send attempt.
|
|
194
|
+
*/
|
|
195
|
+
export interface SendNotificationResult {
|
|
196
|
+
/**
|
|
197
|
+
* Notification name.
|
|
198
|
+
*/
|
|
199
|
+
notificationName: string;
|
|
200
|
+
/**
|
|
201
|
+
* Parsed notification payload.
|
|
202
|
+
*/
|
|
203
|
+
payload: unknown;
|
|
204
|
+
/**
|
|
205
|
+
* Channels selected for delivery.
|
|
206
|
+
*/
|
|
207
|
+
channels: readonly string[];
|
|
208
|
+
/**
|
|
209
|
+
* Per-channel delivery results.
|
|
210
|
+
*/
|
|
211
|
+
results: readonly NotificationChannelResult[];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* App-facing notification port.
|
|
216
|
+
*/
|
|
217
|
+
export interface NotificationPort {
|
|
218
|
+
/**
|
|
219
|
+
* Send a typed notification.
|
|
220
|
+
*/
|
|
221
|
+
send<N extends NotificationDef>(
|
|
222
|
+
notification: N,
|
|
223
|
+
payload: InferNotificationPayload<N>,
|
|
224
|
+
options?: SendNotificationOptions,
|
|
225
|
+
): Promise<SendNotificationResult>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Options for the inline notification dispatcher.
|
|
230
|
+
*/
|
|
231
|
+
export interface InlineNotificationDispatcherOptions<Ctx> {
|
|
232
|
+
/**
|
|
233
|
+
* Static notification context or factory evaluated for each send.
|
|
234
|
+
*/
|
|
235
|
+
ctx?: Ctx | (() => MaybePromise<Ctx>);
|
|
236
|
+
/**
|
|
237
|
+
* Called when a channel handler fails. When omitted, errors are rethrown to
|
|
238
|
+
* the caller as `NotificationDeliveryError`.
|
|
239
|
+
*/
|
|
240
|
+
onError?: (
|
|
241
|
+
error: unknown,
|
|
242
|
+
args: NotificationChannelHandleArgs<StandardSchema, Ctx>,
|
|
243
|
+
) => MaybePromise<NotificationChannelResult | undefined>;
|
|
244
|
+
/**
|
|
245
|
+
* Optional devtools/provider instrumentation target.
|
|
246
|
+
*/
|
|
247
|
+
instrumentation?: ProviderInstrumentationTarget;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Delivery captured by the memory notification port.
|
|
252
|
+
*/
|
|
253
|
+
export interface MemoryNotificationDelivery {
|
|
254
|
+
/**
|
|
255
|
+
* Generated delivery ID.
|
|
256
|
+
*/
|
|
257
|
+
id: string;
|
|
258
|
+
/**
|
|
259
|
+
* Notification name.
|
|
260
|
+
*/
|
|
261
|
+
notificationName: string;
|
|
262
|
+
/**
|
|
263
|
+
* Parsed payload that would have been sent.
|
|
264
|
+
*/
|
|
265
|
+
payload: unknown;
|
|
266
|
+
/**
|
|
267
|
+
* Selected channels.
|
|
268
|
+
*/
|
|
269
|
+
channels: readonly string[];
|
|
270
|
+
/**
|
|
271
|
+
* Optional app metadata supplied by the caller.
|
|
272
|
+
*/
|
|
273
|
+
metadata?: Record<string, unknown>;
|
|
274
|
+
/**
|
|
275
|
+
* Timestamp assigned by the memory port.
|
|
276
|
+
*/
|
|
277
|
+
sentAt: Date;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* In-memory notification port for tests and local examples.
|
|
282
|
+
*/
|
|
283
|
+
export interface MemoryNotificationPort extends NotificationPort {
|
|
284
|
+
/**
|
|
285
|
+
* Captured notification sends.
|
|
286
|
+
*/
|
|
287
|
+
readonly deliveries: readonly MemoryNotificationDelivery[];
|
|
288
|
+
/**
|
|
289
|
+
* Clear captured notification sends.
|
|
290
|
+
*/
|
|
291
|
+
clear(): void;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Options for `createMemoryNotificationPort(...)`.
|
|
296
|
+
*/
|
|
297
|
+
export interface CreateMemoryNotificationPortOptions {
|
|
298
|
+
/**
|
|
299
|
+
* Clock used for captured deliveries.
|
|
300
|
+
*/
|
|
301
|
+
now?: () => Date;
|
|
302
|
+
/**
|
|
303
|
+
* ID factory used for captured deliveries.
|
|
304
|
+
*/
|
|
305
|
+
id?: () => string;
|
|
306
|
+
/**
|
|
307
|
+
* Observer called after a delivery is captured.
|
|
308
|
+
*/
|
|
309
|
+
onSend?: (delivery: MemoryNotificationDelivery) => MaybePromise<void>;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Context shape required by `defineMailNotificationChannel(...)`.
|
|
314
|
+
*/
|
|
315
|
+
export interface MailNotificationContext {
|
|
316
|
+
ports: {
|
|
317
|
+
mailer: {
|
|
318
|
+
send(message: SendMailOptions): MaybePromise<{
|
|
319
|
+
id?: string;
|
|
320
|
+
provider?: string;
|
|
321
|
+
}>;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Render a mail message for one notification payload.
|
|
328
|
+
*/
|
|
329
|
+
export type MailNotificationRenderer<
|
|
330
|
+
Payload extends StandardSchema,
|
|
331
|
+
Ctx extends MailNotificationContext,
|
|
332
|
+
> = (
|
|
333
|
+
args: NotificationChannelHandleArgs<Payload, Ctx>,
|
|
334
|
+
) => MaybePromise<SendMailOptions | undefined>;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Context-bound notification helper factory.
|
|
338
|
+
*/
|
|
339
|
+
export interface NotificationHandlers<Ctx> {
|
|
340
|
+
/**
|
|
341
|
+
* Define a notification with the bound context type.
|
|
342
|
+
*/
|
|
343
|
+
defineNotification<Name extends string, Payload extends StandardSchema>(
|
|
344
|
+
name: Name,
|
|
345
|
+
options: DefineNotificationOptions<Payload, Ctx>,
|
|
346
|
+
): NotificationDef<Name, Payload, Ctx>;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Create an inline dispatcher with the bound context type.
|
|
350
|
+
*/
|
|
351
|
+
createInlineNotificationDispatcher(
|
|
352
|
+
options?: InlineNotificationDispatcherOptions<Ctx>,
|
|
353
|
+
): NotificationPort;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Error thrown when notification payload validation fails.
|
|
358
|
+
*/
|
|
359
|
+
export class NotificationValidationError extends Error {
|
|
360
|
+
/**
|
|
361
|
+
* Raw Standard Schema validation issues.
|
|
362
|
+
*/
|
|
363
|
+
readonly issues: readonly StandardSchemaV1.Issue[];
|
|
364
|
+
|
|
365
|
+
constructor(args: {
|
|
366
|
+
name: string;
|
|
367
|
+
issues: readonly StandardSchemaV1.Issue[];
|
|
368
|
+
}) {
|
|
369
|
+
super(
|
|
370
|
+
`Notification "${args.name}" payload validation failed: ${formatIssues(args.issues)}`,
|
|
371
|
+
);
|
|
372
|
+
this.name = "NotificationValidationError";
|
|
373
|
+
this.issues = args.issues;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Error thrown when notification delivery fails.
|
|
379
|
+
*/
|
|
380
|
+
export class NotificationDeliveryError extends Error {
|
|
381
|
+
/**
|
|
382
|
+
* Notification name.
|
|
383
|
+
*/
|
|
384
|
+
readonly notificationName: string;
|
|
385
|
+
/**
|
|
386
|
+
* Channel that failed.
|
|
387
|
+
*/
|
|
388
|
+
readonly channel: string;
|
|
389
|
+
/**
|
|
390
|
+
* Original channel error.
|
|
391
|
+
*/
|
|
392
|
+
readonly cause: unknown;
|
|
393
|
+
|
|
394
|
+
constructor(args: {
|
|
395
|
+
notificationName: string;
|
|
396
|
+
channel: string;
|
|
397
|
+
cause: unknown;
|
|
398
|
+
}) {
|
|
399
|
+
super(
|
|
400
|
+
`Notification "${args.notificationName}" failed on channel "${args.channel}": ${
|
|
401
|
+
args.cause instanceof Error ? args.cause.message : String(args.cause)
|
|
402
|
+
}`,
|
|
403
|
+
);
|
|
404
|
+
this.name = "NotificationDeliveryError";
|
|
405
|
+
this.notificationName = args.notificationName;
|
|
406
|
+
this.channel = args.channel;
|
|
407
|
+
this.cause = args.cause;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function formatPath(path: StandardSchemaV1.Issue["path"]): string {
|
|
412
|
+
if (!path?.length) return "";
|
|
413
|
+
|
|
414
|
+
return path
|
|
415
|
+
.map((segment) =>
|
|
416
|
+
typeof segment === "object" && segment !== null && "key" in segment
|
|
417
|
+
? String(segment.key)
|
|
418
|
+
: String(segment),
|
|
419
|
+
)
|
|
420
|
+
.join(".");
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function formatIssues(issues: readonly StandardSchemaV1.Issue[]): string {
|
|
424
|
+
return issues
|
|
425
|
+
.map((issue) => {
|
|
426
|
+
const path = formatPath(issue.path);
|
|
427
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
428
|
+
})
|
|
429
|
+
.join("; ");
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
async function parsePayload<Schema extends StandardSchemaV1>(
|
|
433
|
+
schema: Schema,
|
|
434
|
+
input: unknown,
|
|
435
|
+
args: { name: string },
|
|
436
|
+
): Promise<InferSchemaOutput<Schema>> {
|
|
437
|
+
const result = await schema["~standard"].validate(input);
|
|
438
|
+
|
|
439
|
+
if (result.issues?.length) {
|
|
440
|
+
throw new NotificationValidationError({
|
|
441
|
+
name: args.name,
|
|
442
|
+
issues: result.issues,
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if ("value" in result) {
|
|
447
|
+
return result.value as InferSchemaOutput<Schema>;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
throw new Error("Invalid Standard Schema result: missing value");
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
async function resolveCtx<Ctx>(
|
|
454
|
+
ctx: Ctx | (() => MaybePromise<Ctx>) | undefined,
|
|
455
|
+
): Promise<Ctx> {
|
|
456
|
+
if (typeof ctx === "function") {
|
|
457
|
+
return (ctx as () => MaybePromise<Ctx>)();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
return ctx as Ctx;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function resolveChannelNames(
|
|
464
|
+
notification: {
|
|
465
|
+
name: string;
|
|
466
|
+
channels: Record<string, unknown>;
|
|
467
|
+
},
|
|
468
|
+
options:
|
|
469
|
+
| {
|
|
470
|
+
channels?: readonly string[];
|
|
471
|
+
}
|
|
472
|
+
| undefined,
|
|
473
|
+
): readonly string[] {
|
|
474
|
+
const available = Object.keys(notification.channels);
|
|
475
|
+
const selected = options?.channels ?? available;
|
|
476
|
+
|
|
477
|
+
for (const channel of selected) {
|
|
478
|
+
if (!notification.channels[channel]) {
|
|
479
|
+
throw new Error(
|
|
480
|
+
`Notification "${notification.name}" does not define channel "${channel}".`,
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return selected;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function summarizeResults(results: readonly NotificationChannelResult[]) {
|
|
489
|
+
const sent = results.filter((result) => result.status === "sent").length;
|
|
490
|
+
const skipped = results.filter(
|
|
491
|
+
(result) => result.status === "skipped",
|
|
492
|
+
).length;
|
|
493
|
+
const failed = results.filter((result) => result.status === "failed").length;
|
|
494
|
+
|
|
495
|
+
return { sent, skipped, failed };
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Define a typed notification.
|
|
500
|
+
*
|
|
501
|
+
* Notifications represent user-facing communication intent. Channel handlers
|
|
502
|
+
* decide how that intent becomes mail, SMS, push, in-app delivery, or another
|
|
503
|
+
* app-owned channel.
|
|
504
|
+
*/
|
|
505
|
+
export function defineNotification<
|
|
506
|
+
Name extends string,
|
|
507
|
+
Payload extends StandardSchema,
|
|
508
|
+
Ctx = unknown,
|
|
509
|
+
>(
|
|
510
|
+
name: Name,
|
|
511
|
+
options: DefineNotificationOptions<Payload, Ctx>,
|
|
512
|
+
): NotificationDef<Name, Payload, Ctx> {
|
|
513
|
+
return {
|
|
514
|
+
kind: "notification",
|
|
515
|
+
name,
|
|
516
|
+
payload: options.payload,
|
|
517
|
+
description: options.description,
|
|
518
|
+
channels: options.channels,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Validate and parse a notification payload with the notification's Standard
|
|
524
|
+
* Schema.
|
|
525
|
+
*/
|
|
526
|
+
export async function parseNotificationPayload<
|
|
527
|
+
N extends NotificationPayloadDef,
|
|
528
|
+
>(notification: N, payload: unknown): Promise<InferNotificationPayload<N>> {
|
|
529
|
+
return (await parsePayload(notification.payload, payload, {
|
|
530
|
+
name: notification.name,
|
|
531
|
+
})) as InferNotificationPayload<N>;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Create an inline notification dispatcher.
|
|
536
|
+
*
|
|
537
|
+
* The dispatcher validates payloads and runs selected channel handlers
|
|
538
|
+
* immediately. Use this directly in tests and local apps, or wrap it in jobs
|
|
539
|
+
* and outbox delivery for production background execution.
|
|
540
|
+
*/
|
|
541
|
+
export function createInlineNotificationDispatcher<Ctx>(
|
|
542
|
+
options: InlineNotificationDispatcherOptions<Ctx> = {},
|
|
543
|
+
): NotificationPort {
|
|
544
|
+
const instrumentation = createProviderInstrumentation(
|
|
545
|
+
options.instrumentation,
|
|
546
|
+
{
|
|
547
|
+
providerName: "notifications",
|
|
548
|
+
watcher: "notifications",
|
|
549
|
+
},
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
return {
|
|
553
|
+
async send<N extends NotificationDef<string, StandardSchema, Ctx>>(
|
|
554
|
+
notification: N,
|
|
555
|
+
payload: InferNotificationPayload<N>,
|
|
556
|
+
sendOptions: SendNotificationOptions = {},
|
|
557
|
+
) {
|
|
558
|
+
const parsed = await parseNotificationPayload(notification, payload);
|
|
559
|
+
const channels = resolveChannelNames(notification, sendOptions);
|
|
560
|
+
const ctx = await resolveCtx(options.ctx);
|
|
561
|
+
const results: NotificationChannelResult[] = [];
|
|
562
|
+
|
|
563
|
+
instrumentation.custom({
|
|
564
|
+
name: "notification.send.started",
|
|
565
|
+
label: "Notification started",
|
|
566
|
+
summary: notification.name,
|
|
567
|
+
requestId: sendOptions.requestId,
|
|
568
|
+
traceId: sendOptions.traceId,
|
|
569
|
+
spanId: sendOptions.spanId,
|
|
570
|
+
parentSpanId: sendOptions.parentSpanId,
|
|
571
|
+
traceparent: sendOptions.traceparent,
|
|
572
|
+
details: {
|
|
573
|
+
notificationName: notification.name,
|
|
574
|
+
channels,
|
|
575
|
+
metadata: sendOptions.metadata,
|
|
576
|
+
},
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
for (const channel of channels) {
|
|
580
|
+
const handler = notification.channels[channel];
|
|
581
|
+
|
|
582
|
+
try {
|
|
583
|
+
const result = await handler({
|
|
584
|
+
notification,
|
|
585
|
+
payload: parsed,
|
|
586
|
+
ctx,
|
|
587
|
+
channel,
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
results.push(
|
|
591
|
+
result ?? {
|
|
592
|
+
channel,
|
|
593
|
+
status: "sent",
|
|
594
|
+
},
|
|
595
|
+
);
|
|
596
|
+
} catch (error) {
|
|
597
|
+
const args = {
|
|
598
|
+
notification,
|
|
599
|
+
payload: parsed,
|
|
600
|
+
ctx,
|
|
601
|
+
channel,
|
|
602
|
+
} satisfies NotificationChannelHandleArgs<StandardSchema, Ctx>;
|
|
603
|
+
const handled = await options.onError?.(error, args);
|
|
604
|
+
if (handled) {
|
|
605
|
+
results.push(handled);
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
instrumentation.custom({
|
|
610
|
+
name: "notification.send.failed",
|
|
611
|
+
label: "Notification failed",
|
|
612
|
+
summary: `${notification.name} (${channel})`,
|
|
613
|
+
requestId: sendOptions.requestId,
|
|
614
|
+
traceId: sendOptions.traceId,
|
|
615
|
+
spanId: sendOptions.spanId,
|
|
616
|
+
parentSpanId: sendOptions.parentSpanId,
|
|
617
|
+
traceparent: sendOptions.traceparent,
|
|
618
|
+
details: {
|
|
619
|
+
notificationName: notification.name,
|
|
620
|
+
channel,
|
|
621
|
+
error: error instanceof Error ? error.message : String(error),
|
|
622
|
+
metadata: sendOptions.metadata,
|
|
623
|
+
},
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
throw new NotificationDeliveryError({
|
|
627
|
+
notificationName: notification.name,
|
|
628
|
+
channel,
|
|
629
|
+
cause: error,
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
const summary = summarizeResults(results);
|
|
635
|
+
instrumentation.custom({
|
|
636
|
+
name: "notification.send.completed",
|
|
637
|
+
label: "Notification sent",
|
|
638
|
+
summary: `${notification.name} (${summary.sent} sent, ${summary.skipped} skipped, ${summary.failed} failed)`,
|
|
639
|
+
requestId: sendOptions.requestId,
|
|
640
|
+
traceId: sendOptions.traceId,
|
|
641
|
+
spanId: sendOptions.spanId,
|
|
642
|
+
parentSpanId: sendOptions.parentSpanId,
|
|
643
|
+
traceparent: sendOptions.traceparent,
|
|
644
|
+
details: {
|
|
645
|
+
notificationName: notification.name,
|
|
646
|
+
channels,
|
|
647
|
+
results,
|
|
648
|
+
metadata: sendOptions.metadata,
|
|
649
|
+
},
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
return {
|
|
653
|
+
notificationName: notification.name,
|
|
654
|
+
payload: parsed,
|
|
655
|
+
channels,
|
|
656
|
+
results,
|
|
657
|
+
};
|
|
658
|
+
},
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Define a mail-backed notification channel.
|
|
664
|
+
*
|
|
665
|
+
* Return `undefined` from the renderer when the channel should be skipped, for
|
|
666
|
+
* example when a recipient does not have an email address.
|
|
667
|
+
*/
|
|
668
|
+
export function defineMailNotificationChannel<
|
|
669
|
+
Payload extends StandardSchema,
|
|
670
|
+
Ctx extends MailNotificationContext,
|
|
671
|
+
>(
|
|
672
|
+
render: MailNotificationRenderer<Payload, Ctx>,
|
|
673
|
+
): NotificationChannelHandler<Payload, Ctx> {
|
|
674
|
+
return async (args) => {
|
|
675
|
+
const message = await render(args);
|
|
676
|
+
if (!message) {
|
|
677
|
+
return {
|
|
678
|
+
channel: args.channel,
|
|
679
|
+
status: "skipped",
|
|
680
|
+
reason: "No mail message was returned.",
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const result = await args.ctx.ports.mailer.send(message);
|
|
685
|
+
return {
|
|
686
|
+
channel: args.channel,
|
|
687
|
+
status: "sent",
|
|
688
|
+
id: result.id,
|
|
689
|
+
provider: result.provider,
|
|
690
|
+
};
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Create an in-memory notification port for tests and examples.
|
|
696
|
+
*
|
|
697
|
+
* The memory port validates payloads and records notification intent without
|
|
698
|
+
* running channel handlers.
|
|
699
|
+
*/
|
|
700
|
+
export function createMemoryNotificationPort(
|
|
701
|
+
options: CreateMemoryNotificationPortOptions = {},
|
|
702
|
+
): MemoryNotificationPort {
|
|
703
|
+
const deliveries: MemoryNotificationDelivery[] = [];
|
|
704
|
+
const now = options.now ?? (() => new Date());
|
|
705
|
+
const id = options.id ?? (() => crypto.randomUUID());
|
|
706
|
+
|
|
707
|
+
return {
|
|
708
|
+
get deliveries() {
|
|
709
|
+
return deliveries;
|
|
710
|
+
},
|
|
711
|
+
|
|
712
|
+
async send<N extends NotificationDef>(
|
|
713
|
+
notification: N,
|
|
714
|
+
payload: InferNotificationPayload<N>,
|
|
715
|
+
sendOptions: SendNotificationOptions = {},
|
|
716
|
+
) {
|
|
717
|
+
const parsed = await parseNotificationPayload(notification, payload);
|
|
718
|
+
const channels = resolveChannelNames(notification, sendOptions);
|
|
719
|
+
const delivery: MemoryNotificationDelivery = {
|
|
720
|
+
id: id(),
|
|
721
|
+
notificationName: notification.name,
|
|
722
|
+
payload: parsed,
|
|
723
|
+
channels,
|
|
724
|
+
metadata: sendOptions.metadata,
|
|
725
|
+
sentAt: now(),
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
deliveries.push(delivery);
|
|
729
|
+
await options.onSend?.(delivery);
|
|
730
|
+
|
|
731
|
+
return {
|
|
732
|
+
notificationName: notification.name,
|
|
733
|
+
payload: parsed,
|
|
734
|
+
channels,
|
|
735
|
+
results: channels.map((channel) => ({
|
|
736
|
+
channel,
|
|
737
|
+
status: "sent",
|
|
738
|
+
id: delivery.id,
|
|
739
|
+
provider: "memory",
|
|
740
|
+
details: {
|
|
741
|
+
mode: "intent",
|
|
742
|
+
},
|
|
743
|
+
})),
|
|
744
|
+
};
|
|
745
|
+
},
|
|
746
|
+
|
|
747
|
+
clear() {
|
|
748
|
+
deliveries.length = 0;
|
|
749
|
+
},
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Create notification helper methods bound to an application context type.
|
|
755
|
+
*/
|
|
756
|
+
export function createNotificationHandlers<Ctx>(): NotificationHandlers<Ctx> {
|
|
757
|
+
return {
|
|
758
|
+
defineNotification<Name extends string, Payload extends StandardSchema>(
|
|
759
|
+
name: Name,
|
|
760
|
+
options: DefineNotificationOptions<Payload, Ctx>,
|
|
761
|
+
): NotificationDef<Name, Payload, Ctx> {
|
|
762
|
+
return defineNotification(name, options);
|
|
763
|
+
},
|
|
764
|
+
|
|
765
|
+
createInlineNotificationDispatcher(
|
|
766
|
+
options: InlineNotificationDispatcherOptions<Ctx> = {},
|
|
767
|
+
): NotificationPort {
|
|
768
|
+
return createInlineNotificationDispatcher(options);
|
|
769
|
+
},
|
|
770
|
+
};
|
|
771
|
+
}
|