@stone-js/notifications 0.8.18 → 0.8.19
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Channel } from './declarations.js';
|
|
2
2
|
/**
|
|
3
3
|
* Holds the configured channels and hands one out by name.
|
|
4
4
|
*
|
|
@@ -25,7 +25,7 @@ export declare class NotificationManager {
|
|
|
25
25
|
* @param channel - The channel.
|
|
26
26
|
* @returns This manager.
|
|
27
27
|
*/
|
|
28
|
-
register(channel:
|
|
28
|
+
register(channel: Channel): this;
|
|
29
29
|
/**
|
|
30
30
|
* Register a channel to be built on first use.
|
|
31
31
|
*
|
|
@@ -33,7 +33,7 @@ export declare class NotificationManager {
|
|
|
33
33
|
* @param factory - How to build it.
|
|
34
34
|
* @returns This manager.
|
|
35
35
|
*/
|
|
36
|
-
registerFactory(name: string, factory: () =>
|
|
36
|
+
registerFactory(name: string, factory: () => Channel): this;
|
|
37
37
|
/** Whether a channel is registered under this name. */
|
|
38
38
|
has(name: string): boolean;
|
|
39
39
|
/** The names of every registered channel. */
|
|
@@ -45,5 +45,5 @@ export declare class NotificationManager {
|
|
|
45
45
|
* @returns The channel.
|
|
46
46
|
* @throws {NotificationConfigurationError} When nothing is registered under that name.
|
|
47
47
|
*/
|
|
48
|
-
channel(name: string):
|
|
48
|
+
channel(name: string): Channel;
|
|
49
49
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeliveryOutcome, InAppChannelConfig,
|
|
1
|
+
import { DeliveryOutcome, InAppChannelConfig, Channel, Recipient, RenderedNotification } from '../declarations.js';
|
|
2
2
|
/** The shape this channel needs from a broadcaster, duck-typed so no realtime import is required. */
|
|
3
3
|
export interface BroadcasterLike {
|
|
4
4
|
to: (channel: string) => {
|
|
@@ -20,7 +20,7 @@ export interface BroadcasterLike {
|
|
|
20
20
|
* It reports `unreachable` rather than `failed` when nobody is listening, because that is not an
|
|
21
21
|
* error: a person who is not looking at the screen is exactly why the other channels exist.
|
|
22
22
|
*/
|
|
23
|
-
export declare class InAppChannel implements
|
|
23
|
+
export declare class InAppChannel implements Channel {
|
|
24
24
|
readonly name: string;
|
|
25
25
|
private readonly event;
|
|
26
26
|
private readonly broadcaster?;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ILogger } from '@stone-js/core';
|
|
2
|
-
import { ChannelConfig, DeliveryOutcome,
|
|
2
|
+
import { ChannelConfig, DeliveryOutcome, Channel, Recipient, RenderedNotification } from '../declarations.js';
|
|
3
3
|
/**
|
|
4
4
|
* The channel that delivers nothing, and is honest about it.
|
|
5
5
|
*
|
|
@@ -12,7 +12,7 @@ import { ChannelConfig, DeliveryOutcome, NotificationChannel, Recipient, Rendere
|
|
|
12
12
|
* what is configured, for the same reason: a module that delivers nothing must not look like one that
|
|
13
13
|
* delivers.
|
|
14
14
|
*/
|
|
15
|
-
export declare class LogChannel implements
|
|
15
|
+
export declare class LogChannel implements Channel {
|
|
16
16
|
readonly name: string;
|
|
17
17
|
private readonly logger?;
|
|
18
18
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeliveryOutcome,
|
|
1
|
+
import { DeliveryOutcome, Channel, Recipient, RenderedNotification, SmtpChannelConfig } from '../declarations.js';
|
|
2
2
|
/**
|
|
3
3
|
* Email, over SMTP.
|
|
4
4
|
*
|
|
@@ -11,7 +11,7 @@ import { DeliveryOutcome, NotificationChannel, Recipient, RenderedNotification,
|
|
|
11
11
|
* the container: a transport is a **resource**, not state, and nodemailer pools its own connections,
|
|
12
12
|
* so an application under load should pass a transport it owns.
|
|
13
13
|
*/
|
|
14
|
-
export declare class SmtpChannel implements
|
|
14
|
+
export declare class SmtpChannel implements Channel {
|
|
15
15
|
readonly name: string;
|
|
16
16
|
private readonly config;
|
|
17
17
|
private transportPromise?;
|
package/dist/declarations.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export interface DeliveryOutcome {
|
|
|
77
77
|
* it before calling here. A channel that started deciding would be a second policy to keep in step
|
|
78
78
|
* with the first.
|
|
79
79
|
*/
|
|
80
|
-
export interface
|
|
80
|
+
export interface Channel {
|
|
81
81
|
/** The name a notification refers to it by. */
|
|
82
82
|
readonly name: string;
|
|
83
83
|
/**
|
|
@@ -90,7 +90,7 @@ export interface NotificationChannel {
|
|
|
90
90
|
send: (message: RenderedNotification, recipient: Recipient) => Promise<DeliveryOutcome>;
|
|
91
91
|
}
|
|
92
92
|
/** How a channel is built from what the application configured. */
|
|
93
|
-
export type NotificationChannelFactory = (config: ChannelConfig) =>
|
|
93
|
+
export type NotificationChannelFactory = (config: ChannelConfig) => Channel;
|
|
94
94
|
/** The channels this package ships. Any other name is one an application registered. */
|
|
95
95
|
export type NotificationDriver = 'log' | 'in-app' | 'smtp' | (string & {});
|
|
96
96
|
/** What a configured channel declares. */
|
package/dist/index.js
CHANGED
|
@@ -1123,7 +1123,7 @@ class NotificationServiceProvider {
|
|
|
1123
1123
|
manager.registerFactory(config.name, () => config.factory?.(config));
|
|
1124
1124
|
return;
|
|
1125
1125
|
}
|
|
1126
|
-
// A class the application declared with `@
|
|
1126
|
+
// A class the application declared with `@Channel`. Built through the container, so
|
|
1127
1127
|
// its constructor is auto-wired: a channel needing a provider client asks for it.
|
|
1128
1128
|
if (typeof config.module === 'function') {
|
|
1129
1129
|
manager.registerFactory(config.name, () => this.build(config));
|
|
@@ -1202,21 +1202,6 @@ function defineNotice(module, options, isClass = true) {
|
|
|
1202
1202
|
return { ...options, module, isClass };
|
|
1203
1203
|
}
|
|
1204
1204
|
|
|
1205
|
-
/**
|
|
1206
|
-
* Where a class declares itself a notification channel.
|
|
1207
|
-
*
|
|
1208
|
-
* A string rather than a symbol, by the convention every first-party module follows: another package
|
|
1209
|
-
* can read it without importing this one.
|
|
1210
|
-
*/
|
|
1211
|
-
const CHANNEL_KEY = '@stone-js/notifications/channel';
|
|
1212
|
-
/**
|
|
1213
|
-
* Where a class declares itself a notice.
|
|
1214
|
-
*
|
|
1215
|
-
* A string rather than a symbol, by the convention every first-party module follows: another package
|
|
1216
|
-
* can read what an application declared without importing this one.
|
|
1217
|
-
*/
|
|
1218
|
-
const NOTICE_KEY = '@stone-js/notifications/notice';
|
|
1219
|
-
|
|
1220
1205
|
/**
|
|
1221
1206
|
* The worker side of a notification: it performs the delivery the request decided on.
|
|
1222
1207
|
*
|
|
@@ -1308,6 +1293,21 @@ const MetaNoticeSubscriptionsMiddleware = {
|
|
|
1308
1293
|
priority: 5
|
|
1309
1294
|
};
|
|
1310
1295
|
|
|
1296
|
+
/**
|
|
1297
|
+
* Where a class declares itself a notification channel.
|
|
1298
|
+
*
|
|
1299
|
+
* A string rather than a symbol, by the convention every first-party module follows: another package
|
|
1300
|
+
* can read it without importing this one.
|
|
1301
|
+
*/
|
|
1302
|
+
const CHANNEL_KEY = '@stone-js/notifications/channel';
|
|
1303
|
+
/**
|
|
1304
|
+
* Where a class declares itself a notice.
|
|
1305
|
+
*
|
|
1306
|
+
* A string rather than a symbol, by the convention every first-party module follows: another package
|
|
1307
|
+
* can read what an application declared without importing this one.
|
|
1308
|
+
*/
|
|
1309
|
+
const NOTICE_KEY = '@stone-js/notifications/notice';
|
|
1310
|
+
|
|
1311
1311
|
/**
|
|
1312
1312
|
* Opt-in blueprint: register it to reach people.
|
|
1313
1313
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stone-js/notifications",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.19",
|
|
4
4
|
"description": "Notifications for Stone.js: one declaration reaches a person wherever they are, delivered out of band.",
|
|
5
5
|
"author": "Mr. Stone <evensstone@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"nodemailer": "^9.0.1",
|
|
41
|
-
"@stone-js/core": "0.8.
|
|
42
|
-
"@stone-js/queue": "0.8.
|
|
43
|
-
"@stone-js/realtime": "0.8.
|
|
44
|
-
"@stone-js/i18n": "0.8.
|
|
41
|
+
"@stone-js/core": "0.8.19",
|
|
42
|
+
"@stone-js/queue": "0.8.19",
|
|
43
|
+
"@stone-js/realtime": "0.8.19",
|
|
44
|
+
"@stone-js/i18n": "0.8.19"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@stone-js/config": "0.8.
|
|
47
|
+
"@stone-js/config": "0.8.19"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@commitlint/cli": "^19.8.1",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"typedoc-plugin-markdown": "^4.7.0",
|
|
67
67
|
"typescript": "^5.6.3",
|
|
68
68
|
"vitest": "^3.2.4",
|
|
69
|
-
"@stone-js/core": "0.8.
|
|
70
|
-
"@stone-js/
|
|
71
|
-
"@stone-js/
|
|
72
|
-
"@stone-js/
|
|
73
|
-
"@stone-js/
|
|
74
|
-
"@stone-js/
|
|
69
|
+
"@stone-js/core": "0.8.19",
|
|
70
|
+
"@stone-js/http-core": "0.8.19",
|
|
71
|
+
"@stone-js/i18n": "0.8.19",
|
|
72
|
+
"@stone-js/queue": "0.8.19",
|
|
73
|
+
"@stone-js/realtime": "0.8.19",
|
|
74
|
+
"@stone-js/router": "0.8.19"
|
|
75
75
|
},
|
|
76
76
|
"ts-standard": {
|
|
77
77
|
"globals": [
|
|
@@ -105,10 +105,11 @@
|
|
|
105
105
|
"doc": "typedoc",
|
|
106
106
|
"clean": "rimraf dist",
|
|
107
107
|
"build": "rollup -c",
|
|
108
|
-
"test": "vitest run",
|
|
109
|
-
"test:cvg": "npm run test
|
|
108
|
+
"test": "vitest run && npm run test:types",
|
|
109
|
+
"test:cvg": "vitest run --coverage && npm run test:types",
|
|
110
110
|
"test:text": "npm run test:cvg -- --coverage.reporter=text",
|
|
111
111
|
"test:html": "npm run test:cvg -- --coverage.reporter=html",
|
|
112
|
-
"test:clover": "npm run test:cvg -- --coverage.reporter=clover"
|
|
112
|
+
"test:clover": "npm run test:cvg -- --coverage.reporter=clover",
|
|
113
|
+
"test:types": "tsc -p tsconfig.types.json"
|
|
113
114
|
}
|
|
114
115
|
}
|