@zambon-dev/shared 1.0.2 → 1.1.0

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.
@@ -0,0 +1,12 @@
1
+ export interface INotification {
2
+ /** Short heading for the notification. */
3
+ title: string;
4
+ /** Longer descriptive text. */
5
+ description: string;
6
+ /** Icon class shown next to the notification (e.g. a Font Awesome class like `fa-solid fa-envelope`). */
7
+ icon: string;
8
+ /** Optional call-to-action URL. When present, clicking the notification navigates to it. */
9
+ callToActionUrl?: string;
10
+ /** Whether the notification has been read. */
11
+ isRead: boolean;
12
+ }
@@ -1,3 +1,4 @@
1
1
  export { AuthenticationService } from './authentication.service';
2
+ export { NotificationsService } from './notifications.service';
2
3
  export { OperationsHistoryService } from './operations-history.service';
3
4
  export { ServicesHistoryService } from './services-history.service';
@@ -0,0 +1,33 @@
1
+ import { Observable } from 'rxjs';
2
+ import { INotification } from '../models';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Streams top-bar notifications from a SignalR hub.
6
+ *
7
+ * The hub is configured via `AppConfig.notificationsEnabled` and `AppConfig.notificationsUrl`.
8
+ * When enabled, {@link start} opens a connection (authenticated with the current JWT) and
9
+ * listens for the server to push the notification list via the `ReceiveNotifications` client
10
+ * method. Consuming apps do not interact with this service directly — the top bar drives it.
11
+ */
12
+ export declare class NotificationsService {
13
+ private authService;
14
+ private config;
15
+ private connection?;
16
+ private notifications$;
17
+ /** Whether the notifications feature is enabled (toggled on and given a hub URL). */
18
+ get isEnabled(): boolean;
19
+ /** Emits the current list of notifications. */
20
+ getNotifications(): Observable<INotification[]>;
21
+ /** Emits the number of unread notifications. */
22
+ getUnreadCount(): Observable<number>;
23
+ /** Marks every notification as read and notifies the hub. */
24
+ markAllAsRead(): void;
25
+ /** Marks a single notification as read (optimistically; the server reconciles on the next push). */
26
+ markAsRead(notification: INotification): void;
27
+ /** Opens the SignalR connection and starts receiving notifications. Idempotent and a no-op when disabled. */
28
+ start(): void;
29
+ /** Closes the SignalR connection. */
30
+ stop(): Promise<void>;
31
+ static ɵfac: i0.ɵɵFactoryDeclaration<NotificationsService, never>;
32
+ static ɵprov: i0.ɵɵInjectableDeclaration<NotificationsService>;
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zambon-dev/shared",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Shared Angular services, utilities, and styles for Zambon applications.",
5
5
  "keywords": [
6
6
  "angular",
@@ -27,6 +27,7 @@
27
27
  "@angular/forms": "^19.1.0",
28
28
  "@angular/router": "^19.1.0",
29
29
  "@auth0/angular-jwt": "^5.2.0",
30
+ "@microsoft/signalr": "^10.0.0",
30
31
  "@zambon-dev/framework": "^1.0.0",
31
32
  "@zambon-dev/library": "^1.0.0",
32
33
  "@ngx-translate/core": "^16.0.4",