diff --git a/.changeset/notification-outcome-grouping.md b/.changeset/notification-outcome-grouping.md new file mode 100644 index 0000000..d1c22d9 --- /dev/null +++ b/.changeset/notification-outcome-grouping.md @@ -0,0 +1,12 @@ +--- +'@thatopen/services': patch +--- + +Add `outcome`, `groupKey` and `groupLabel` to `NotificationDto`, matching what +the API already returns. + +Read `outcome` to tell how an automation run ended rather than matching on the +copy: `title` is built from the user's own automation name, so an automation +called "Failover sync" makes every successful run look failed to anything +parsing the text. `groupKey` and `groupLabel` are what a client needs to +collapse a busy automation's runs into one row. diff --git a/src/types/notifications.ts b/src/types/notifications.ts index 8fd2106..523e21d 100644 --- a/src/types/notifications.ts +++ b/src/types/notifications.ts @@ -39,6 +39,29 @@ export interface NotificationDto { muted: boolean; readAt: string | null; createdAt: string; + /** + * What to group consecutive notifications by — the automation id for a run, + * absent for anything that should stand alone. + * + * Derived rather than the raw producer payload, so fifty runs of one + * automation can collapse into a single row without the whole payload being + * on the wire for every notification type, forever. + */ + groupKey?: string; + /** + * How an automation run ended, straight from the producer's result. + * + * Use this rather than reading the copy. `title` is built from the user's own + * automation name, so an automation called "Failover sync" makes every + * successful run look failed to anything matching on the text. + */ + outcome?: 'success' | 'error' | 'warning'; + /** + * The automation's name, for a grouped row's heading. Here for the same + * reason as `outcome`: recovering it by stripping words off the title breaks + * on any name that contains them. + */ + groupLabel?: string; } /** `nextCursor` is opaque — pass it back verbatim. Null means the last page. */