@crvouga/mockingbird-notifications 0.2.0 → 0.2.1
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/{chunk-4QVURMVP.js → chunk-SNOESDNW.js} +2 -2
- package/dist/{chunk-4QVURMVP.js.map → chunk-SNOESDNW.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +5 -479
- package/dist/server.d.ts +1 -220
- package/dist/server.js +1 -1
- package/dist/types-C4yF6DQp.d.ts +244 -0
- package/dist/types-CU0LKNyA.d.ts +238 -0
- package/dist/ui.d.ts +5 -379
- package/package.json +1 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/** The kinds of device a notification lands on. */
|
|
2
|
+
type Channel = "sms" | "email" | "push" | "chat";
|
|
3
|
+
/** Every channel, in the order the devices are laid out. */
|
|
4
|
+
declare const CHANNELS: readonly Channel[];
|
|
5
|
+
/** Emulators the harness knows how to read. */
|
|
6
|
+
type ServiceKind = "twilio" | "resend" | "fcm" | "ses" | "sns" | "customerio" | "mailosaur" | "slack";
|
|
7
|
+
declare const SERVICE_KINDS: readonly ServiceKind[];
|
|
8
|
+
declare const SERVICE_LABELS: Record<ServiceKind, string>;
|
|
9
|
+
type Address = {
|
|
10
|
+
name: string | null;
|
|
11
|
+
address: string;
|
|
12
|
+
};
|
|
13
|
+
type SmsContent = {
|
|
14
|
+
body: string;
|
|
15
|
+
/** One-time code the sender included (Twilio Verify), when known. */
|
|
16
|
+
code: string | null;
|
|
17
|
+
media: string[];
|
|
18
|
+
/** `whatsapp` when the message went to a `whatsapp:` address; plain text messages omit it. */
|
|
19
|
+
via?: "sms" | "whatsapp";
|
|
20
|
+
};
|
|
21
|
+
type EmailAttachment = {
|
|
22
|
+
filename: string;
|
|
23
|
+
contentType: string | null;
|
|
24
|
+
size: number | null;
|
|
25
|
+
};
|
|
26
|
+
type EmailContent = {
|
|
27
|
+
subject: string;
|
|
28
|
+
html: string | null;
|
|
29
|
+
text: string | null;
|
|
30
|
+
cc: string[];
|
|
31
|
+
bcc: string[];
|
|
32
|
+
replyTo: string[];
|
|
33
|
+
attachments: EmailAttachment[];
|
|
34
|
+
headers: Record<string, string>;
|
|
35
|
+
};
|
|
36
|
+
type PushPlatform = "android" | "ios" | "web" | "unknown";
|
|
37
|
+
type PushContent = {
|
|
38
|
+
title: string | null;
|
|
39
|
+
body: string | null;
|
|
40
|
+
imageUrl: string | null;
|
|
41
|
+
/** The app the notification belongs to (the FCM project, for example). */
|
|
42
|
+
app: string;
|
|
43
|
+
platform: PushPlatform;
|
|
44
|
+
data: Record<string, string>;
|
|
45
|
+
badge: number | null;
|
|
46
|
+
sound: string | null;
|
|
47
|
+
};
|
|
48
|
+
type ChatReaction = {
|
|
49
|
+
name: string;
|
|
50
|
+
count: number;
|
|
51
|
+
};
|
|
52
|
+
/** A message posted into a team chat channel (Slack). */
|
|
53
|
+
type ChatContent = {
|
|
54
|
+
/** The message text, in the provider's own markup (Slack mrkdwn). */
|
|
55
|
+
text: string;
|
|
56
|
+
/** Workspace the message was posted in. */
|
|
57
|
+
workspace: string | null;
|
|
58
|
+
/** How it arrived: `chat.postMessage`, `chat.postEphemeral` or `incoming-webhook`. */
|
|
59
|
+
method: string;
|
|
60
|
+
/** Block Kit blocks, exactly as sent. */
|
|
61
|
+
blocks: unknown[];
|
|
62
|
+
/** Legacy attachments, exactly as sent. */
|
|
63
|
+
attachments: unknown[];
|
|
64
|
+
/** Parent message timestamp when this is a threaded reply. */
|
|
65
|
+
threadTs: string | null;
|
|
66
|
+
/** Shown to one member only. */
|
|
67
|
+
ephemeral: boolean;
|
|
68
|
+
edited: boolean;
|
|
69
|
+
reactions: ChatReaction[];
|
|
70
|
+
/** Display names of the users and channels the message mentions by id (`U…` → `ada`). */
|
|
71
|
+
names?: Record<string, string>;
|
|
72
|
+
};
|
|
73
|
+
/** One message as a recipient would receive it, normalized across emulators. */
|
|
74
|
+
type Notification = {
|
|
75
|
+
/** Stable across polls: `<service entry>:<namespace>:<provider id>`. */
|
|
76
|
+
id: string;
|
|
77
|
+
/** The provider's own id (Twilio SID, Resend id, FCM message name, …). */
|
|
78
|
+
providerId: string;
|
|
79
|
+
channel: Channel;
|
|
80
|
+
/** The fleet entry name (`twilio`, or an alias such as `push`). */
|
|
81
|
+
source: string;
|
|
82
|
+
service: ServiceKind;
|
|
83
|
+
namespace: string;
|
|
84
|
+
/** Phone number, email address, push registration token, or chat channel (`#alerts`). */
|
|
85
|
+
to: string;
|
|
86
|
+
from: Address;
|
|
87
|
+
/** ISO-8601, on the emulator's clock. */
|
|
88
|
+
createdAt: string;
|
|
89
|
+
/** Short plain-text preview. */
|
|
90
|
+
preview: string;
|
|
91
|
+
/** Provider delivery state when it reports one (`queued`, `delivered`, `suppressed`, …). */
|
|
92
|
+
status: string | null;
|
|
93
|
+
sms: SmsContent | null;
|
|
94
|
+
email: EmailContent | null;
|
|
95
|
+
push: PushContent | null;
|
|
96
|
+
/** Set on `chat` notifications; absent or null on every other channel. */
|
|
97
|
+
chat?: ChatContent | null;
|
|
98
|
+
/** The record exactly as the emulator reported it. */
|
|
99
|
+
raw: unknown;
|
|
100
|
+
};
|
|
101
|
+
type NotificationFilter = {
|
|
102
|
+
channel?: Channel | undefined;
|
|
103
|
+
service?: ServiceKind | undefined;
|
|
104
|
+
source?: string | undefined;
|
|
105
|
+
namespace?: string | undefined;
|
|
106
|
+
/** Exact recipient (case-insensitive for email). */
|
|
107
|
+
to?: string | undefined;
|
|
108
|
+
/** Case-insensitive text search across sender, subject, title and body. */
|
|
109
|
+
contains?: string | undefined;
|
|
110
|
+
/** Only notifications created at or after this instant (ISO-8601 or epoch ms). */
|
|
111
|
+
since?: string | number | undefined;
|
|
112
|
+
};
|
|
113
|
+
type SourceStatus = {
|
|
114
|
+
name: string;
|
|
115
|
+
service: ServiceKind | null;
|
|
116
|
+
url: string;
|
|
117
|
+
ok: boolean;
|
|
118
|
+
error: string | null;
|
|
119
|
+
count: number;
|
|
120
|
+
lastSyncAt: string | null;
|
|
121
|
+
};
|
|
122
|
+
declare const matches: (n: Notification, filter: NotificationFilter) => boolean;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Where the emulators are. The harness reads the same fleet the application uses: the live fleet
|
|
126
|
+
* controller (`adminBase`), the fleet's ready manifest, or explicit URLs and in-process runtimes.
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
type FetchLike = (request: Request) => Response | Promise<Response>;
|
|
130
|
+
/** A service emulator: its base URL, an `{ url, adminUrl?, service? }` entry, or an in-process runtime. */
|
|
131
|
+
type ServiceInput = string | {
|
|
132
|
+
url: string;
|
|
133
|
+
adminUrl?: string;
|
|
134
|
+
service?: ServiceKind;
|
|
135
|
+
} | {
|
|
136
|
+
fetch: FetchLike;
|
|
137
|
+
service?: ServiceKind;
|
|
138
|
+
adminPrefix?: string;
|
|
139
|
+
};
|
|
140
|
+
/** The subset of a fleet ready manifest (`--ready-file`) the harness reads. */
|
|
141
|
+
type FleetManifest = {
|
|
142
|
+
adminBase?: string;
|
|
143
|
+
services: Record<string, {
|
|
144
|
+
protocol?: string;
|
|
145
|
+
url?: string;
|
|
146
|
+
adminUrl?: string;
|
|
147
|
+
target?: string;
|
|
148
|
+
} | undefined>;
|
|
149
|
+
};
|
|
150
|
+
type Endpoint = {
|
|
151
|
+
/** The fleet entry name, e.g. `twilio`, or an alias such as `push`. */
|
|
152
|
+
name: string;
|
|
153
|
+
/** Null until the emulator's health route has told us what it is. */
|
|
154
|
+
service: ServiceKind | null;
|
|
155
|
+
/** Absolute admin prefix, e.g. `http://127.0.0.1:8798/__admin`. */
|
|
156
|
+
adminUrl: string;
|
|
157
|
+
fetch: FetchLike;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* An emulator whose admin API the dashboard fronts. Unlike {@link Endpoint} this is every HTTP
|
|
161
|
+
* emulator, messaging or not (stripe, cognito, …).
|
|
162
|
+
*/
|
|
163
|
+
type AdminTarget = {
|
|
164
|
+
/** The fleet entry name, e.g. `stripe`, or an alias such as `push`. */
|
|
165
|
+
name: string;
|
|
166
|
+
/** The emulator it runs, e.g. `fcm` for the alias `push`. The name when nobody said. */
|
|
167
|
+
target: string;
|
|
168
|
+
/** Absolute admin prefix, e.g. `http://127.0.0.1:8798/__admin`. */
|
|
169
|
+
adminUrl: string;
|
|
170
|
+
fetch: FetchLike;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
type HarnessOptions = {
|
|
174
|
+
/** A running fleet controller's `adminBase` (`http://127.0.0.1:9000/__admin/fleet`). */
|
|
175
|
+
fleet?: string;
|
|
176
|
+
/** A fleet ready manifest, or a function that reads the current one (re-read on every sync). */
|
|
177
|
+
manifest?: FleetManifest | (() => FleetManifest | Promise<FleetManifest>);
|
|
178
|
+
/** Explicit emulators by name: base URLs, `{ url, adminUrl }`, or in-process runtimes. */
|
|
179
|
+
services?: Record<string, ServiceInput>;
|
|
180
|
+
/**
|
|
181
|
+
* Namespaces to watch in the background. `"all"` follows the fleet's namespace list.
|
|
182
|
+
* Any namespace an API call or the UI asks for is watched from then on. Default `["default"]`,
|
|
183
|
+
* or `"all"` with `fleet`.
|
|
184
|
+
*/
|
|
185
|
+
namespaces?: "all" | string[];
|
|
186
|
+
/** Background polling interval. `0` turns it off; reads still sync on demand. Default 750 ms. */
|
|
187
|
+
pollIntervalMs?: number;
|
|
188
|
+
/** Sent as `x-mockingbird-admin-key` to the fleet and every emulator. */
|
|
189
|
+
adminKey?: string;
|
|
190
|
+
/** Admin keys by emulator name, for emulators whose key is not `adminKey`. */
|
|
191
|
+
adminKeys?: Record<string, string>;
|
|
192
|
+
/**
|
|
193
|
+
* Front every emulator's admin API on this origin, so the page shows an Emulators tab next to
|
|
194
|
+
* Notifications. `createServer` (the `./server` entry) turns it on; pass `adminGateway()` from
|
|
195
|
+
* that entry to turn it on for a harness you serve yourself.
|
|
196
|
+
*/
|
|
197
|
+
admin?: AdminGatewayFactory | false;
|
|
198
|
+
/** The tab the page opens on when it has both. Default `notifications`. */
|
|
199
|
+
defaultTab?: "emulators" | "notifications";
|
|
200
|
+
/** Transport for URL endpoints. Default: global `fetch`. */
|
|
201
|
+
fetch?: FetchLike;
|
|
202
|
+
/** Page title. */
|
|
203
|
+
title?: string;
|
|
204
|
+
};
|
|
205
|
+
type AdminGatewayContext = {
|
|
206
|
+
/** Every HTTP emulator the harness knows, messaging or not, after a fresh discovery. */
|
|
207
|
+
targets(): Promise<AdminTarget[]>;
|
|
208
|
+
/** The admin key header for one emulator: empty when the harness has no key for it. */
|
|
209
|
+
headers(name: string): Record<string, string>;
|
|
210
|
+
title: string;
|
|
211
|
+
};
|
|
212
|
+
type AdminGateway = {
|
|
213
|
+
/** The admin UI's mount config for the current emulators; null when there are none. */
|
|
214
|
+
config(): Promise<Record<string, unknown> | null>;
|
|
215
|
+
/** Everything under `/admin/`: the admin UI script and each emulator's admin API. */
|
|
216
|
+
fetch(request: Request): Promise<Response>;
|
|
217
|
+
};
|
|
218
|
+
type AdminGatewayFactory = (context: AdminGatewayContext) => AdminGateway;
|
|
219
|
+
type WaitOptions = {
|
|
220
|
+
timeoutMs?: number;
|
|
221
|
+
count?: number;
|
|
222
|
+
};
|
|
223
|
+
type NotificationHarness = {
|
|
224
|
+
/** The harness UI and JSON API as a Fetch handler. */
|
|
225
|
+
fetch(request: Request): Promise<Response>;
|
|
226
|
+
/** Read every emulator now. Resolves after a read that started after this call. */
|
|
227
|
+
sync(namespace?: string): Promise<void>;
|
|
228
|
+
/** Notifications matching `filter`, oldest first, after a fresh sync. */
|
|
229
|
+
list(filter?: NotificationFilter): Promise<Notification[]>;
|
|
230
|
+
/** Resolve once at least `count` (default 1) notifications match; reject after `timeoutMs`. */
|
|
231
|
+
waitFor(filter: NotificationFilter, options?: WaitOptions): Promise<Notification[]>;
|
|
232
|
+
sources(): SourceStatus[];
|
|
233
|
+
close(): void;
|
|
234
|
+
};
|
|
235
|
+
declare const createNotificationHarness: (options?: HarnessOptions) => NotificationHarness;
|
|
236
|
+
|
|
237
|
+
export { CHANNELS as f, SERVICE_KINDS as n, SERVICE_LABELS as o, createNotificationHarness as s, matches as t };
|
|
238
|
+
export type { Address as A, Channel as C, EmailAttachment as E, FetchLike as F, HarnessOptions as H, NotificationFilter as N, PushContent as P, SourceStatus as S, WaitOptions as W, Notification as a, AdminGateway as b, AdminGatewayContext as c, AdminGatewayFactory as d, AdminTarget as e, ChatContent as g, ChatReaction as h, EmailContent as i, Endpoint as j, FleetManifest as k, NotificationHarness as l, PushPlatform as m, ServiceInput as p, ServiceKind as q, SmsContent as r };
|
package/dist/ui.d.ts
CHANGED
|
@@ -1,368 +1,11 @@
|
|
|
1
|
+
export { T as TEST_IDS, a as TestId, s as selectors } from './types-C4yF6DQp.js';
|
|
2
|
+
import { Notification, Channel, SourceStatus, NotificationHarness } from './index.js';
|
|
3
|
+
|
|
1
4
|
/** The class on the UI root. Every rule below is scoped to it. */
|
|
2
5
|
declare const ROOT_CLASS = "mb-notifications";
|
|
3
6
|
/** The stylesheet, every rule scoped to `.mb-notifications`. */
|
|
4
7
|
declare const STYLES: string;
|
|
5
8
|
|
|
6
|
-
/**
|
|
7
|
-
* Every `data-testid` the harness UI renders, and selector helpers for browser tests.
|
|
8
|
-
*
|
|
9
|
-
* Elements that show one notification also carry its fields as attributes, so a test can narrow by
|
|
10
|
-
* what it knows instead of by position:
|
|
11
|
-
*
|
|
12
|
-
* data-notification-id data-channel data-service data-source data-to data-from
|
|
13
|
-
* data-status data-created-at data-unread ("true" | "false")
|
|
14
|
-
* data-via ("whatsapp", only on WhatsApp messages)
|
|
15
|
-
*
|
|
16
|
-
* The UI root (`TEST_IDS.app`) reports its state the same way: `data-ready` ("true" once the first
|
|
17
|
-
* read finished), `data-view`, `data-namespace`, `data-count`, `data-version`, `data-connected`,
|
|
18
|
-
* `data-sound`, `data-motion`, `data-layout` ("grid" = devices side by side, "tabs" = one device at
|
|
19
|
-
* a time) and `data-tab` (the selected channel tab: "all", "sms", "push", "email" or "chat").
|
|
20
|
-
*
|
|
21
|
-
* This module has no dependencies, so Playwright, Cypress or WebdriverIO specs can import it.
|
|
22
|
-
*/
|
|
23
|
-
declare const TEST_IDS: {
|
|
24
|
-
/** The UI root. */
|
|
25
|
-
readonly app: "notifications-app";
|
|
26
|
-
readonly topbar: "topbar";
|
|
27
|
-
/** `<select>` of namespaces. */
|
|
28
|
-
readonly namespace: "namespace";
|
|
29
|
-
/** Filter `<input>` (recipient, sender, text). */
|
|
30
|
-
readonly search: "search";
|
|
31
|
-
/** View tabs; `aria-pressed="true"` on the active one. */
|
|
32
|
-
readonly viewDevices: "view-devices";
|
|
33
|
-
readonly viewTimeline: "view-timeline";
|
|
34
|
-
/** "Follow new" checkbox. */
|
|
35
|
-
readonly follow: "follow";
|
|
36
|
-
/** Sound on/off button; `aria-pressed`. */
|
|
37
|
-
readonly sound: "sound-toggle";
|
|
38
|
-
/** Live stream indicator; `data-state="live" | "reconnecting"`. */
|
|
39
|
-
readonly connection: "connection";
|
|
40
|
-
/** One pill per emulator; `data-name`, `data-service`, `data-ok`, `data-count`. */
|
|
41
|
-
readonly source: "source";
|
|
42
|
-
/** Discovery or emulator errors, or the "no emulators" hint; `data-kind="error" | "empty"`. */
|
|
43
|
-
readonly notice: "notice";
|
|
44
|
-
/** Bottom-left message after an action, e.g. "Conversation archived." */
|
|
45
|
-
readonly toast: "toast";
|
|
46
|
-
readonly toastUndo: "toast-undo";
|
|
47
|
-
/** The `role="tablist"` that switches between devices; `data-layout="grid" | "tabs"`. */
|
|
48
|
-
readonly channelTabs: "channel-tabs";
|
|
49
|
-
/** One `role="tab"`; `data-value="all" | "sms" | "push" | "email" | "chat"`, `aria-selected`, `data-unread` (a count). */
|
|
50
|
-
readonly channelTab: "channel-tab";
|
|
51
|
-
/** Unread badge on a tab whose device is not showing its newest arrivals (absent when 0). */
|
|
52
|
-
readonly channelTabUnread: "channel-tab-unread";
|
|
53
|
-
/** The phone; `data-screen="threads" | "conversation"`, `data-recipient`, `data-thread`, and `data-via="whatsapp"` while a WhatsApp chat is open. */
|
|
54
|
-
readonly smsDevice: "sms-device";
|
|
55
|
-
/** Phone number `<select>`; option values are E.164 numbers. */
|
|
56
|
-
readonly smsRecipient: "sms-recipient";
|
|
57
|
-
/** Unread SMS badge next to the column title (absent when 0). */
|
|
58
|
-
readonly smsUnreadCount: "sms-unread-count";
|
|
59
|
-
/** One conversation in the list; `data-from` (the sender address), `data-unread`, `data-pinned`, `data-muted`, `data-via`. */
|
|
60
|
-
readonly smsThread: "sms-thread";
|
|
61
|
-
readonly smsThreadName: "sms-thread-name";
|
|
62
|
-
readonly smsThreadPreview: "sms-thread-preview";
|
|
63
|
-
readonly smsThreadTime: "sms-thread-time";
|
|
64
|
-
readonly smsThreadUnread: "sms-thread-unread";
|
|
65
|
-
/** "WhatsApp" label on a WhatsApp conversation in the list. */
|
|
66
|
-
readonly smsThreadVia: "sms-thread-via";
|
|
67
|
-
/** Swipe actions behind a thread (also reachable with the keyboard: focus the thread, press Delete). */
|
|
68
|
-
readonly smsThreadDelete: "sms-thread-delete";
|
|
69
|
-
readonly smsThreadMute: "sms-thread-mute";
|
|
70
|
-
readonly smsThreadPin: "sms-thread-pin";
|
|
71
|
-
readonly smsThreadToggleUnread: "sms-thread-toggle-unread";
|
|
72
|
-
/** Shown when the phone has no messages. */
|
|
73
|
-
readonly smsEmpty: "sms-empty";
|
|
74
|
-
/** An open conversation; `data-from`, `data-via="sms" | "whatsapp"`. */
|
|
75
|
-
readonly smsConversation: "sms-conversation";
|
|
76
|
-
readonly smsConversationTitle: "sms-conversation-title";
|
|
77
|
-
readonly smsBack: "sms-back";
|
|
78
|
-
/** One message; carries the notification attributes plus `data-code` when it holds a one-time code. */
|
|
79
|
-
readonly smsBubble: "sms-bubble";
|
|
80
|
-
readonly smsBubbleMedia: "sms-bubble-media";
|
|
81
|
-
/** The time revealed by swiping the conversation left. */
|
|
82
|
-
readonly smsBubbleTime: "sms-bubble-time";
|
|
83
|
-
/** A reaction added with the long-press menu; `data-tapback`. */
|
|
84
|
-
readonly smsTapback: "sms-tapback";
|
|
85
|
-
/** Centered date stamp between messages. */
|
|
86
|
-
readonly smsTimestamp: "sms-timestamp";
|
|
87
|
-
/** One-time code suggestion above the keyboard; `data-code`. */
|
|
88
|
-
readonly smsCode: "sms-code";
|
|
89
|
-
/** Long-press menu on a bubble. */
|
|
90
|
-
readonly smsMenu: "sms-menu";
|
|
91
|
-
readonly smsMenuCopy: "sms-menu-copy";
|
|
92
|
-
/** One tapback in the menu; `data-tapback="heart" | "like" | "dislike" | "laugh" | "emphasize" | "question"`. */
|
|
93
|
-
readonly smsMenuTapback: "sms-menu-tapback";
|
|
94
|
-
/** The phone; `data-skin="ios" | "android"`, `data-recipient`, `data-platform`. */
|
|
95
|
-
readonly pushDevice: "push-device";
|
|
96
|
-
/** Device token `<select>`. */
|
|
97
|
-
readonly pushRecipient: "push-recipient";
|
|
98
|
-
/** Skin buttons; `data-value`, `aria-pressed`. */
|
|
99
|
-
readonly pushSkin: "push-skin";
|
|
100
|
-
readonly pushUnreadCount: "push-unread-count";
|
|
101
|
-
/** One notification; notification attributes plus `data-expanded`, `data-platform`, `data-app`, `data-stacked`. */
|
|
102
|
-
readonly pushNotification: "push-notification";
|
|
103
|
-
readonly pushNotificationApp: "push-notification-app";
|
|
104
|
-
readonly pushNotificationTitle: "push-notification-title";
|
|
105
|
-
readonly pushNotificationBody: "push-notification-body";
|
|
106
|
-
readonly pushNotificationTime: "push-notification-time";
|
|
107
|
-
readonly pushNotificationImage: "push-notification-image";
|
|
108
|
-
/** The `data` payload, shown when expanded. */
|
|
109
|
-
readonly pushNotificationData: "push-notification-data";
|
|
110
|
-
/** Service, status, badge and sound, shown when expanded. */
|
|
111
|
-
readonly pushNotificationMeta: "push-notification-meta";
|
|
112
|
-
/** iOS: a group of notifications from one app; `data-app`, `data-count`, `data-open`. */
|
|
113
|
-
readonly pushGroup: "push-group";
|
|
114
|
-
/** iOS: "N more notifications" under a collapsed group (click to open it); `data-count`. */
|
|
115
|
-
readonly pushGroupMore: "push-group-more";
|
|
116
|
-
/** iOS: "Show less" on an open group. */
|
|
117
|
-
readonly pushGroupCollapse: "push-group-collapse";
|
|
118
|
-
/** iOS: swipe-left actions. */
|
|
119
|
-
readonly pushClear: "push-clear";
|
|
120
|
-
readonly pushOptions: "push-options";
|
|
121
|
-
/** iOS long-press preview; Android long-press settings. */
|
|
122
|
-
readonly pushPreview: "push-preview";
|
|
123
|
-
readonly pushSettings: "push-settings";
|
|
124
|
-
/** Android "Clear all". */
|
|
125
|
-
readonly pushClearAll: "push-clear-all";
|
|
126
|
-
readonly pushEmpty: "push-empty";
|
|
127
|
-
/** The browser window; `data-screen="inbox" | "message"`, `data-recipient`. */
|
|
128
|
-
readonly emailDevice: "email-device";
|
|
129
|
-
/** Mailbox `<select>`; option values are lower-case addresses. */
|
|
130
|
-
readonly emailRecipient: "email-recipient";
|
|
131
|
-
readonly emailUnreadCount: "email-unread-count";
|
|
132
|
-
/** One inbox row; notification attributes plus `data-starred`. */
|
|
133
|
-
readonly emailRow: "email-row";
|
|
134
|
-
readonly emailRowFrom: "email-row-from";
|
|
135
|
-
readonly emailRowSubject: "email-row-subject";
|
|
136
|
-
readonly emailRowSnippet: "email-row-snippet";
|
|
137
|
-
readonly emailRowDate: "email-row-date";
|
|
138
|
-
readonly emailRowService: "email-row-service";
|
|
139
|
-
readonly emailRowAttachment: "email-row-attachment";
|
|
140
|
-
readonly emailRowStar: "email-row-star";
|
|
141
|
-
/** Hover actions on a row. */
|
|
142
|
-
readonly emailRowArchive: "email-row-archive";
|
|
143
|
-
readonly emailRowDelete: "email-row-delete";
|
|
144
|
-
readonly emailRowToggleRead: "email-row-toggle-read";
|
|
145
|
-
readonly emailRefresh: "email-refresh";
|
|
146
|
-
readonly emailEmpty: "email-empty";
|
|
147
|
-
/** The open message; notification attributes. */
|
|
148
|
-
readonly emailOpen: "email-open";
|
|
149
|
-
readonly emailBack: "email-back";
|
|
150
|
-
readonly emailArchive: "email-archive";
|
|
151
|
-
readonly emailDelete: "email-delete";
|
|
152
|
-
readonly emailMarkUnread: "email-mark-unread";
|
|
153
|
-
readonly emailSubject: "email-subject";
|
|
154
|
-
readonly emailFromName: "email-from-name";
|
|
155
|
-
readonly emailFromAddress: "email-from-address";
|
|
156
|
-
/** "to me, …" line; click to toggle the details. */
|
|
157
|
-
readonly emailTo: "email-to";
|
|
158
|
-
readonly emailDate: "email-date";
|
|
159
|
-
readonly emailDetails: "email-details";
|
|
160
|
-
/** One row of the details; `data-field="from" | "to" | "cc" | "bcc" | "reply-to" | "date" | "subject" | "mailed-by" | "message-id"`. */
|
|
161
|
-
readonly emailDetail: "email-detail";
|
|
162
|
-
/** The HTML body `<iframe>` (same origin: use `frameLocator`). */
|
|
163
|
-
readonly emailBody: "email-body";
|
|
164
|
-
/** The plain-text body when there is no HTML. */
|
|
165
|
-
readonly emailText: "email-text";
|
|
166
|
-
readonly emailAttachments: "email-attachments";
|
|
167
|
-
/** One attachment; `data-filename`, `data-content-type`, `data-size`. */
|
|
168
|
-
readonly emailAttachment: "email-attachment";
|
|
169
|
-
/** The chat window; `data-recipient` (the open channel), `data-workspace`. */
|
|
170
|
-
readonly chatDevice: "chat-device";
|
|
171
|
-
/** Channel `<select>`; option values are channel names (`#alerts`) or webhook paths. */
|
|
172
|
-
readonly chatRecipient: "chat-recipient";
|
|
173
|
-
readonly chatUnreadCount: "chat-unread-count";
|
|
174
|
-
readonly chatWorkspace: "chat-workspace";
|
|
175
|
-
/** One channel in the sidebar; `data-to`, `data-unread` (a count), `aria-current`. */
|
|
176
|
-
readonly chatChannel: "chat-channel";
|
|
177
|
-
/** The open channel's name in the header. */
|
|
178
|
-
readonly chatTitle: "chat-title";
|
|
179
|
-
/** One message; notification attributes plus `data-method`, `data-ephemeral`, `data-thread`. */
|
|
180
|
-
readonly chatMessage: "chat-message";
|
|
181
|
-
readonly chatMessageAuthor: "chat-message-author";
|
|
182
|
-
readonly chatMessageTime: "chat-message-time";
|
|
183
|
-
/** The message text, with mrkdwn formatting applied. */
|
|
184
|
-
readonly chatMessageText: "chat-message-text";
|
|
185
|
-
/** Block Kit blocks; each block inside carries `data-block="<type>"`. */
|
|
186
|
-
readonly chatMessageBlocks: "chat-message-blocks";
|
|
187
|
-
/** Legacy attachments; each one inside carries `data-color`. */
|
|
188
|
-
readonly chatMessageAttachments: "chat-message-attachments";
|
|
189
|
-
/** One reaction; `data-name`, `data-count`. */
|
|
190
|
-
readonly chatMessageReaction: "chat-message-reaction";
|
|
191
|
-
readonly chatEmpty: "chat-empty";
|
|
192
|
-
readonly timeline: "timeline";
|
|
193
|
-
/** One row; notification attributes. Click it to inspect. */
|
|
194
|
-
readonly timelineRow: "timeline-row";
|
|
195
|
-
readonly timelineEmpty: "timeline-empty";
|
|
196
|
-
/** The JSON inspector; notification attributes. Opened by clicking a timeline row or double-clicking any notification. */
|
|
197
|
-
readonly inspector: "inspector";
|
|
198
|
-
readonly inspectorTitle: "inspector-title";
|
|
199
|
-
readonly inspectorClose: "inspector-close";
|
|
200
|
-
readonly inspectorShowOnDevice: "inspector-show-on-device";
|
|
201
|
-
/** One normalized field; `data-field`. */
|
|
202
|
-
readonly inspectorField: "inspector-field";
|
|
203
|
-
/** The full record, normalized fields plus `raw`, as JSON text. */
|
|
204
|
-
readonly inspectorJson: "inspector-json";
|
|
205
|
-
/** The dashboard root; `data-tab` is the open tab's id. */
|
|
206
|
-
readonly dashboard: "dashboard";
|
|
207
|
-
/** One tab button; `data-tab` (`emulators`, `notifications`, or an embedder's id), `aria-selected`. */
|
|
208
|
-
readonly dashboardTab: "dashboard-tab";
|
|
209
|
-
/** One tab's panel; `data-tab`. Hidden unless its tab is open. */
|
|
210
|
-
readonly dashboardPanel: "dashboard-panel";
|
|
211
|
-
/** Notifications that arrived while another tab was open; `data-count`. Hidden at 0. */
|
|
212
|
-
readonly dashboardBadge: "dashboard-badge";
|
|
213
|
-
};
|
|
214
|
-
type TestId = (typeof TEST_IDS)[keyof typeof TEST_IDS];
|
|
215
|
-
/** CSS selectors for the harness UI. Each one works with `page.locator()` or `querySelector`. */
|
|
216
|
-
declare const selectors: {
|
|
217
|
-
/** `[data-testid="…"]` */
|
|
218
|
-
testId: (id: TestId) => string;
|
|
219
|
-
/** The ready UI root: wait for this before asserting. */
|
|
220
|
-
ready: () => string;
|
|
221
|
-
/** Any element showing this notification (bubble, thread, card, row, open email, timeline row). */
|
|
222
|
-
notification: (id: string) => string;
|
|
223
|
-
/** A message bubble, optionally from one sender. */
|
|
224
|
-
smsBubble: (filter?: {
|
|
225
|
-
from?: string;
|
|
226
|
-
id?: string;
|
|
227
|
-
}) => string;
|
|
228
|
-
/** A conversation in the Messages list. */
|
|
229
|
-
smsThread: (from: string) => string;
|
|
230
|
-
/** A channel tab: `"all"`, `"sms"`, `"push"`, `"email"` or `"chat"`. */
|
|
231
|
-
channelTab: (value: "all" | "sms" | "push" | "email" | "chat") => string;
|
|
232
|
-
/** A chat message, optionally by id. */
|
|
233
|
-
chatMessage: (id?: string) => string;
|
|
234
|
-
/** A channel in the chat sidebar. */
|
|
235
|
-
chatChannel: (to: string) => string;
|
|
236
|
-
/** A push notification card, optionally by id. */
|
|
237
|
-
pushNotification: (id?: string) => string;
|
|
238
|
-
/** An inbox row, optionally by id. */
|
|
239
|
-
emailRow: (id?: string) => string;
|
|
240
|
-
/** A timeline row, optionally by id. */
|
|
241
|
-
timelineRow: (id?: string) => string;
|
|
242
|
-
/** A dashboard tab button by tab id (`emulators`, `notifications`, …). */
|
|
243
|
-
dashboardTab: (id: string) => string;
|
|
244
|
-
/** A dashboard tab's panel by tab id. */
|
|
245
|
-
dashboardPanel: (id: string) => string;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
/** The kinds of device a notification lands on. */
|
|
249
|
-
type Channel = "sms" | "email" | "push" | "chat";
|
|
250
|
-
/** Emulators the harness knows how to read. */
|
|
251
|
-
type ServiceKind = "twilio" | "resend" | "fcm" | "ses" | "sns" | "customerio" | "mailosaur" | "slack";
|
|
252
|
-
type Address = {
|
|
253
|
-
name: string | null;
|
|
254
|
-
address: string;
|
|
255
|
-
};
|
|
256
|
-
type SmsContent = {
|
|
257
|
-
body: string;
|
|
258
|
-
/** One-time code the sender included (Twilio Verify), when known. */
|
|
259
|
-
code: string | null;
|
|
260
|
-
media: string[];
|
|
261
|
-
/** `whatsapp` when the message went to a `whatsapp:` address; plain text messages omit it. */
|
|
262
|
-
via?: "sms" | "whatsapp";
|
|
263
|
-
};
|
|
264
|
-
type EmailAttachment = {
|
|
265
|
-
filename: string;
|
|
266
|
-
contentType: string | null;
|
|
267
|
-
size: number | null;
|
|
268
|
-
};
|
|
269
|
-
type EmailContent = {
|
|
270
|
-
subject: string;
|
|
271
|
-
html: string | null;
|
|
272
|
-
text: string | null;
|
|
273
|
-
cc: string[];
|
|
274
|
-
bcc: string[];
|
|
275
|
-
replyTo: string[];
|
|
276
|
-
attachments: EmailAttachment[];
|
|
277
|
-
headers: Record<string, string>;
|
|
278
|
-
};
|
|
279
|
-
type PushPlatform = "android" | "ios" | "web" | "unknown";
|
|
280
|
-
type PushContent = {
|
|
281
|
-
title: string | null;
|
|
282
|
-
body: string | null;
|
|
283
|
-
imageUrl: string | null;
|
|
284
|
-
/** The app the notification belongs to (the FCM project, for example). */
|
|
285
|
-
app: string;
|
|
286
|
-
platform: PushPlatform;
|
|
287
|
-
data: Record<string, string>;
|
|
288
|
-
badge: number | null;
|
|
289
|
-
sound: string | null;
|
|
290
|
-
};
|
|
291
|
-
type ChatReaction = {
|
|
292
|
-
name: string;
|
|
293
|
-
count: number;
|
|
294
|
-
};
|
|
295
|
-
/** A message posted into a team chat channel (Slack). */
|
|
296
|
-
type ChatContent = {
|
|
297
|
-
/** The message text, in the provider's own markup (Slack mrkdwn). */
|
|
298
|
-
text: string;
|
|
299
|
-
/** Workspace the message was posted in. */
|
|
300
|
-
workspace: string | null;
|
|
301
|
-
/** How it arrived: `chat.postMessage`, `chat.postEphemeral` or `incoming-webhook`. */
|
|
302
|
-
method: string;
|
|
303
|
-
/** Block Kit blocks, exactly as sent. */
|
|
304
|
-
blocks: unknown[];
|
|
305
|
-
/** Legacy attachments, exactly as sent. */
|
|
306
|
-
attachments: unknown[];
|
|
307
|
-
/** Parent message timestamp when this is a threaded reply. */
|
|
308
|
-
threadTs: string | null;
|
|
309
|
-
/** Shown to one member only. */
|
|
310
|
-
ephemeral: boolean;
|
|
311
|
-
edited: boolean;
|
|
312
|
-
reactions: ChatReaction[];
|
|
313
|
-
/** Display names of the users and channels the message mentions by id (`U…` → `ada`). */
|
|
314
|
-
names?: Record<string, string>;
|
|
315
|
-
};
|
|
316
|
-
/** One message as a recipient would receive it, normalized across emulators. */
|
|
317
|
-
type Notification = {
|
|
318
|
-
/** Stable across polls: `<service entry>:<namespace>:<provider id>`. */
|
|
319
|
-
id: string;
|
|
320
|
-
/** The provider's own id (Twilio SID, Resend id, FCM message name, …). */
|
|
321
|
-
providerId: string;
|
|
322
|
-
channel: Channel;
|
|
323
|
-
/** The fleet entry name (`twilio`, or an alias such as `push`). */
|
|
324
|
-
source: string;
|
|
325
|
-
service: ServiceKind;
|
|
326
|
-
namespace: string;
|
|
327
|
-
/** Phone number, email address, push registration token, or chat channel (`#alerts`). */
|
|
328
|
-
to: string;
|
|
329
|
-
from: Address;
|
|
330
|
-
/** ISO-8601, on the emulator's clock. */
|
|
331
|
-
createdAt: string;
|
|
332
|
-
/** Short plain-text preview. */
|
|
333
|
-
preview: string;
|
|
334
|
-
/** Provider delivery state when it reports one (`queued`, `delivered`, `suppressed`, …). */
|
|
335
|
-
status: string | null;
|
|
336
|
-
sms: SmsContent | null;
|
|
337
|
-
email: EmailContent | null;
|
|
338
|
-
push: PushContent | null;
|
|
339
|
-
/** Set on `chat` notifications; absent or null on every other channel. */
|
|
340
|
-
chat?: ChatContent | null;
|
|
341
|
-
/** The record exactly as the emulator reported it. */
|
|
342
|
-
raw: unknown;
|
|
343
|
-
};
|
|
344
|
-
type NotificationFilter = {
|
|
345
|
-
channel?: Channel | undefined;
|
|
346
|
-
service?: ServiceKind | undefined;
|
|
347
|
-
source?: string | undefined;
|
|
348
|
-
namespace?: string | undefined;
|
|
349
|
-
/** Exact recipient (case-insensitive for email). */
|
|
350
|
-
to?: string | undefined;
|
|
351
|
-
/** Case-insensitive text search across sender, subject, title and body. */
|
|
352
|
-
contains?: string | undefined;
|
|
353
|
-
/** Only notifications created at or after this instant (ISO-8601 or epoch ms). */
|
|
354
|
-
since?: string | number | undefined;
|
|
355
|
-
};
|
|
356
|
-
type SourceStatus = {
|
|
357
|
-
name: string;
|
|
358
|
-
service: ServiceKind | null;
|
|
359
|
-
url: string;
|
|
360
|
-
ok: boolean;
|
|
361
|
-
error: string | null;
|
|
362
|
-
count: number;
|
|
363
|
-
lastSyncAt: string | null;
|
|
364
|
-
};
|
|
365
|
-
|
|
366
9
|
/**
|
|
367
10
|
* The channel tab bar's rules, kept free of the DOM so they are unit-tested directly.
|
|
368
11
|
*
|
|
@@ -504,23 +147,6 @@ type PushSkin = "auto" | "ios" | "android";
|
|
|
504
147
|
type Tapback = "heart" | "like" | "dislike" | "laugh" | "emphasize" | "question";
|
|
505
148
|
declare function createApp(root: HTMLElement, options?: AppOptions): AppHandle;
|
|
506
149
|
|
|
507
|
-
type WaitOptions = {
|
|
508
|
-
timeoutMs?: number;
|
|
509
|
-
count?: number;
|
|
510
|
-
};
|
|
511
|
-
type NotificationHarness = {
|
|
512
|
-
/** The harness UI and JSON API as a Fetch handler. */
|
|
513
|
-
fetch(request: Request): Promise<Response>;
|
|
514
|
-
/** Read every emulator now. Resolves after a read that started after this call. */
|
|
515
|
-
sync(namespace?: string): Promise<void>;
|
|
516
|
-
/** Notifications matching `filter`, oldest first, after a fresh sync. */
|
|
517
|
-
list(filter?: NotificationFilter): Promise<Notification[]>;
|
|
518
|
-
/** Resolve once at least `count` (default 1) notifications match; reject after `timeoutMs`. */
|
|
519
|
-
waitFor(filter: NotificationFilter, options?: WaitOptions): Promise<Notification[]>;
|
|
520
|
-
sources(): SourceStatus[];
|
|
521
|
-
close(): void;
|
|
522
|
-
};
|
|
523
|
-
|
|
524
150
|
type MountOptions = Omit<AppOptions, "fetch"> & {
|
|
525
151
|
/** An in-process harness (anything with a Fetch handler). Omit it to read `baseUrl` over HTTP. */
|
|
526
152
|
harness?: Pick<NotificationHarness, "fetch">;
|
|
@@ -595,5 +221,5 @@ declare const DASHBOARD_ROOT_CLASS = "mb-dashboard";
|
|
|
595
221
|
/** The dashboard shell's stylesheet: the tab bar and its panels, nothing inside them. */
|
|
596
222
|
declare const DASHBOARD_STYLES: string;
|
|
597
223
|
|
|
598
|
-
export { DASHBOARD_ROOT_CLASS, DASHBOARD_STYLES, ROOT_CLASS, STYLES,
|
|
599
|
-
export type { AppHandle, AppOptions, DashboardHandle, DashboardOptions, DashboardTab, MotionPreference, MountOptions, PushSkin,
|
|
224
|
+
export { DASHBOARD_ROOT_CLASS, DASHBOARD_STYLES, ROOT_CLASS, STYLES, createApp, mountDashboard, mountNotifications };
|
|
225
|
+
export type { AppHandle, AppOptions, DashboardHandle, DashboardOptions, DashboardTab, MotionPreference, MountOptions, PushSkin, View };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-notifications",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Notification test harness for Mockingbird fleets: every SMS, WhatsApp message, email, push and chat message your app sends through the Twilio, Resend, FCM, SES, SNS, Customer.io, Mailosaur and Slack emulators, on lifelike phone, mail and chat screens and a JSON API for tests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|