2.0.8 • Published 7 years ago
@xyzblocks/web-notifications-domain v2.0.8
@xyzblocks/web-notifications-domain
Web Notifications Domain
Installation
npm install @xyzblocks/web-notifications-domain --save

API
INotification
Properties
image: stringmessage: stringtimestamp: stringtitle: stringurl: string
INotificationRepository
Methods
create(subscriptionId: string, notification: INotification): Promise<void>findAll(subscriptionId: string, timestamp: number): Promise<Array<INotification>>markAsRead(subscriptionId: string, timestamp: number): Promise<void>
ISubscription
Properties
channels: Array<string>id: stringwebPushSubscription: IWebPushSubscription
ISubscriptionRepository
Methods
create(subscription: ISubscription): Promise<void>delete(id: string): Promise<void>find(id: string): Promise<ISubscription>findAll(channel: string): Promise<Array<ISubscription>>update(subscription: ISubscription): Promise<void>
IWebPushSubscription
Properties
endpoint: stringexpirationTime: numberkeys: { auth: string, p256dh: string }
SubscriptionService
Methods
create(subscription: ISubscription): Promise<void>delete(id: string): Promise<void>find(id: string): Promise<ISubscription>generatePrivateKeyAndPublicKey(): { publicKey: string; privateKey: string }readNotifications(id: string, timestamp: number): Promise<Array<INotification>>sendNotification(channel: string, notification: INotification): Promise<void>subscribeToChannel(id: string, channel: string): Promise<void>unsubscribeFromChannel(id: string, channel: string): Promise<void>