add generic attribute field to NotificationPayload

Signed-off-by: Frank Ye <franky@spotify.com>
This commit is contained in:
Frank Ye
2025-05-21 11:28:08 -04:00
parent d34be3831c
commit 9152ba8f36
8 changed files with 87 additions and 7 deletions
+8 -3
View File
@@ -31,7 +31,9 @@ export type NewNotificationSignal = {
};
// @public (undocumented)
type Notification_2 = {
type Notification_2<
T extends Record<string, unknown> = Record<string, unknown>,
> = {
id: string;
user: string | null;
created: Date;
@@ -39,12 +41,14 @@ type Notification_2 = {
read?: Date;
updated?: Date;
origin: string;
payload: NotificationPayload;
payload: NotificationPayload<T>;
};
export { Notification_2 as Notification };
// @public (undocumented)
export type NotificationPayload = {
export type NotificationPayload<
T extends Record<string, unknown> = Record<string, unknown>,
> = {
title: string;
description?: string;
link?: string;
@@ -52,6 +56,7 @@ export type NotificationPayload = {
topic?: string;
scope?: string;
icon?: string;
attributes?: T;
};
// @public (undocumented)
+11 -3
View File
@@ -18,7 +18,9 @@
export type NotificationSeverity = 'critical' | 'high' | 'normal' | 'low';
/** @public */
export type NotificationPayload = {
export type NotificationPayload<
T extends Record<string, unknown> = Record<string, unknown>,
> = {
/**
* Notification title
*/
@@ -50,10 +52,16 @@ export type NotificationPayload = {
* Optional notification icon
*/
icon?: string;
/**
* Optional additional customizable attributes.
*/
attributes?: T;
};
/** @public */
export type Notification = {
export type Notification<
T extends Record<string, unknown> = Record<string, unknown>,
> = {
/**
* Unique identifier for the notification
*/
@@ -87,7 +95,7 @@ export type Notification = {
/**
* Actual notification payload
*/
payload: NotificationPayload;
payload: NotificationPayload<T>;
};
/** @public */