refactor(events): drop the registry's unused push fields

notify, defaultDelivery, PushMessage, NotifyProjection and pushProjection were read only by registry.test. Every subject was unpushable and broadcast by default; the subscription's delivery class stays in DeliveryClass, which the stores use.
This commit is contained in:
Daniel Salazar committed 2026-10-10 19:28:42 -04:00
1 parent 2a460a6127
commit 270591f17b
2 files changed
-60

No files matched your search

@@ -28,7 +28,6 @@ import {
lookupFsSubject,
lookupKvSubject,
lookupPublicSubject,
pushProjection,
type FsDeliveryContext,
type FsPublicSubject,
type KvDeliveryContext,
@@ -181,20 +180,6 @@ describe('PUBLIC_SUBJECTS', () => {
it('requires list to subscribe — see alone is not enough', () => {
for (const subject of fsSubjects()) expect(subject.mode).toBe('list');
});
it('produces no push payload while notify is null', () => {
for (const subject of fsSubjects()) {
expect(subject.notify).toBeNull();
expect(
pushProjection(subject, subject.project(delivery)),
).toBeNull();
}
});
it('defaults every entry to broadcast', () => {
for (const subject of PUBLIC_SUBJECTS)
expect(subject.defaultDelivery).toBe('broadcast');
});
});
describe('the kv subject', () => {
@@ -256,11 +241,6 @@ describe('the kv subject', () => {
'cart:items:1',
);
});
it('is not pushable and broadcasts by default', () => {
expect(subject().notify).toBeNull();
expect(subject().defaultDelivery).toBe('broadcast');
});
});
describe('lookupPublicSubject', () => {
-40
View File
@@ -197,21 +197,6 @@ export type FsDeliveryContext = FsEventContext & DeliveryFields;
export type KvDeliveryContext = KvEventContext & DeliveryFields;
export type NotifDeliveryContext = NotifEventContext & DeliveryFields;
export interface PushMessage {
title: string;
body?: string;
icon?: string;
url?: string;
}
/**
* Human-facing projection. Its absence is what makes a subject unpushable —
* which subjects have one is a privacy decision, not a formatting one.
*/
export type NotifyProjection<P extends ProjectedEvent = ProjectedEvent> = (
event: P,
) => PushMessage | null;
/** How one family's filters are compiled and what they are tested against. */
export interface MatchSpec {
/** Delimiter a single `*` will not cross in this family's filters. */
@@ -239,8 +224,6 @@ export interface SubjectSpec<
/** What a match filter globs against. */
matchOn: (event: C) => string;
project: (delivery: C & DeliveryFields) => P;
notify: NotifyProjection<P> | null;
defaultDelivery: DeliveryClass;
}
export interface FsPublicSubject extends SubjectSpec<
@@ -291,9 +274,6 @@ const fsTokens = (event: FsEventContext): string[] => [
const fsMatchOn = (event: FsEventContext): string => event.entry.path;
/** No human-facing projection, so nothing is push-eligible yet. */
const NOT_PUSHABLE: NotifyProjection<never> | null = null;
const fsProject =
(op: FsOp) =>
(delivery: FsDeliveryContext): ProjectedFsEvent => ({
@@ -372,8 +352,6 @@ export const PUBLIC_SUBJECTS = [
matchSeparator: '/',
matchScope: relativeTo,
project: fsProject('write'),
notify: NOT_PUSHABLE,
defaultDelivery: 'broadcast',
},
{
family: 'fs',
@@ -385,8 +363,6 @@ export const PUBLIC_SUBJECTS = [
matchSeparator: '/',
matchScope: relativeTo,
project: fsProject('add'),
notify: NOT_PUSHABLE,
defaultDelivery: 'broadcast',
},
{
family: 'fs',
@@ -398,8 +374,6 @@ export const PUBLIC_SUBJECTS = [
matchSeparator: '/',
matchScope: relativeTo,
project: fsProject('move'),
notify: NOT_PUSHABLE,
defaultDelivery: 'broadcast',
},
{
family: 'fs',
@@ -411,8 +385,6 @@ export const PUBLIC_SUBJECTS = [
matchSeparator: '/',
matchScope: relativeTo,
project: fsProject('remove'),
notify: NOT_PUSHABLE,
defaultDelivery: 'broadcast',
},
{
family: 'kv',
@@ -423,8 +395,6 @@ export const PUBLIC_SUBJECTS = [
matchSeparator: KV_MATCH_SEPARATOR,
matchScope: kvMatchScope,
project: kvProject,
notify: NOT_PUSHABLE,
defaultDelivery: 'broadcast',
},
{
family: 'notif',
@@ -435,10 +405,6 @@ export const PUBLIC_SUBJECTS = [
matchSeparator: NOTIF_MATCH_SEPARATOR,
matchScope: notifMatchScope,
project: notifProject,
// The push seam fills this in; until then a notification is delivered
// to what is connected, and found in the mailbox otherwise.
notify: NOT_PUSHABLE,
defaultDelivery: 'broadcast',
},
] as const satisfies readonly PublicSubject[];
@@ -507,9 +473,3 @@ export const lookupNotifSubject = (
const found = lookupPublicSubject(key);
return found?.family === 'notif' ? found : undefined;
};
/** The push payload for an event, or `null` when the subject isn't pushable. */
export const pushProjection = <P extends ProjectedEvent>(
subject: { notify: NotifyProjection<P> | null },
event: P,
): PushMessage | null => subject.notify?.(event) ?? null;