@techextensor/tab-sdk 0.0.58 → 0.0.60

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,82 @@
1
+ import { NotificationConnectParams, UiNotification } from '@techextensor/tab-core-utility';
2
+ import { Observable } from 'rxjs';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * SDK facade over the core notification inbox service.
6
+ *
7
+ * The app passes the auth identifiers at connect time — the core services don't
8
+ * read them from storage. This facade is the single place that knows how to
9
+ * compose the BE's `workspaceKey` from the four IDs.
10
+ *
11
+ * Exposes only the surface that app/extension code needs:
12
+ * - lifecycle (connect / disconnect)
13
+ * - inbox actions (loadMore, markAsRead, markAllAsRead, clearOne, clearAll)
14
+ * - state streams for UI (latestNotifications$, unreadCount$, etc.)
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * // In a route resolver
19
+ * await TabSdk.notification.connect({
20
+ * userId: TabSdk.store.userId,
21
+ * appId: TabSdk.store.appId,
22
+ * tenantId: TabSdk.store.tenantId,
23
+ * environmentId: TabSdk.store.environmentId,
24
+ * });
25
+ *
26
+ * // In header for the badge
27
+ * TabSdk.notification.unreadCount$.subscribe(count => this.badge = count);
28
+ *
29
+ * // In notification list
30
+ * TabSdk.notification.loadMore(1);
31
+ * TabSdk.notification.markAsRead(id);
32
+ *
33
+ * // In auth signOut
34
+ * await TabSdk.notification.disconnect();
35
+ * ```
36
+ */
37
+ export declare class NotificationSdkService {
38
+ private readonly inbox;
39
+ /**
40
+ * Connect to the notification WebSocket. Awaitable, idempotent.
41
+ *
42
+ * The app supplies the auth identifiers — the core services stay pure
43
+ * (no storage / auth coupling). This facade composes the BE's workspaceKey
44
+ * from the four IDs and passes everything down.
45
+ */
46
+ connect(params: NotificationConnectParams): Promise<void>;
47
+ /**
48
+ * Tear down the connection (call from auth signOut / cross-tab logout).
49
+ */
50
+ disconnect(): Promise<void>;
51
+ /** Fetch a page of notifications from the inbox. */
52
+ loadMore(pageNumber: number, pageSize?: number): void;
53
+ /** Re-request unread count (header badge auto-refreshes via the stream). */
54
+ requestUnreadCount(): void;
55
+ /** Mark a single notification as read. */
56
+ markAsRead(notificationId: string): void;
57
+ /** Mark all notifications as read. */
58
+ markAllAsRead(): void;
59
+ /** Clear a single notification from the inbox. */
60
+ clearOne(notificationId: string): void;
61
+ /** Clear all notifications from the inbox. */
62
+ clearAll(): void;
63
+ /**
64
+ * Emits notifications as they arrive.
65
+ * - Inbox page fetch → emits an array.
66
+ * - Live push → emits a single notification (component should prepend it).
67
+ * Component logic should branch on Array.isArray(value).
68
+ */
69
+ readonly latestNotifications$: Observable<UiNotification | UiNotification[]>;
70
+ /** Current unread count. Header subscribes for the badge. */
71
+ readonly unreadCount$: Observable<number>;
72
+ /** Emits notificationId when a notification is marked read; null when all are. */
73
+ readonly markAsReadEvents$: Observable<string | null>;
74
+ /** Emits cleared notification IDs; null when all are cleared. */
75
+ readonly clearEvents$: Observable<string[] | null>;
76
+ /** Loading state — true while a page fetch is in flight. */
77
+ readonly loading$: Observable<boolean>;
78
+ /** Total pages (page-based pagination per BE). */
79
+ readonly totalPages$: Observable<number>;
80
+ static ɵfac: i0.ɵɵFactoryDeclaration<NotificationSdkService, never>;
81
+ static ɵprov: i0.ɵɵInjectableDeclaration<NotificationSdkService>;
82
+ }
@@ -0,0 +1,63 @@
1
+ import { NotificationCallback } from '@techextensor/tab-core-utility';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * SDK facade over the core SignalR service.
5
+ *
6
+ * Exposes only the surface that app/extension code needs:
7
+ * - lifecycle (connect / disconnect)
8
+ * - per-component subscription (register / unregister) for live CRUD push
9
+ *
10
+ * Async correlation-id tracking (`waitForOperation`) is intentionally NOT exposed —
11
+ * that's an internal concern of the core CRUD services in tab-core-utility.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // In a route resolver (route waits until the first connection attempt settles)
16
+ * await TabSdk.signalR.connect();
17
+ *
18
+ * // In a component
19
+ * ngOnInit() {
20
+ * TabSdk.signalR.register(this.componentId, this.appObjectId, n => this.handle(n));
21
+ * }
22
+ * ngOnDestroy() {
23
+ * TabSdk.signalR.unregister(this.componentId, this.appObjectId);
24
+ * }
25
+ *
26
+ * // In auth signOut
27
+ * await TabSdk.signalR.disconnect();
28
+ * ```
29
+ */
30
+ export declare class SignalRSdkService {
31
+ private readonly signalR;
32
+ /**
33
+ * Establish a connection to the SignalR hub.
34
+ *
35
+ * Awaitable — resolves when the first connection attempt settles (success or
36
+ * failure). Idempotent: repeated calls are de-duplicated; if already
37
+ * CONNECTED, resolves immediately. Any stale (non-Connected) connection is
38
+ * torn down before rebuild.
39
+ *
40
+ * Use in route resolvers to gate navigation until the hub is ready.
41
+ */
42
+ connect(): Promise<void>;
43
+ /**
44
+ * Tear down the connection (call from auth signOut / cross-tab logout).
45
+ *
46
+ * Stops the hub, clears component registrations, and errors any in-flight
47
+ * waitForOperation observers so CRUD UIs resolve immediately instead of
48
+ * stranding until the 120s timeout.
49
+ */
50
+ disconnect(): Promise<void>;
51
+ /**
52
+ * Subscribe a component to real-time CRUD notifications for an AppObject.
53
+ * Refcounted — the first registrant for an `appObjectId` joins the hub group;
54
+ * the last `unregister` leaves it.
55
+ */
56
+ register(componentId: string, appObjectId: string, callback: NotificationCallback): void;
57
+ /**
58
+ * Unsubscribe a component (call from `ngOnDestroy`).
59
+ */
60
+ unregister(componentId: string, appObjectId: string): void;
61
+ static ɵfac: i0.ɵɵFactoryDeclaration<SignalRSdkService, never>;
62
+ static ɵprov: i0.ɵɵInjectableDeclaration<SignalRSdkService>;
63
+ }
@@ -15,6 +15,8 @@ import { HttpService } from './http/http.service';
15
15
  import { StoreService } from './store/store.service';
16
16
  import { StateSdkService } from './state/state.service';
17
17
  import { WorkflowService } from './workflow/workflow.service';
18
+ import { SignalRSdkService } from './signalr/signalr.service';
19
+ import { NotificationSdkService } from './notification/notification.service';
18
20
  import * as i0 from "@angular/core";
19
21
  export declare class TabSdk {
20
22
  static app: AppService;
@@ -34,6 +36,8 @@ export declare class TabSdk {
34
36
  static workflow: WorkflowService;
35
37
  static util: any;
36
38
  static state: StateSdkService;
39
+ static signalR: SignalRSdkService;
40
+ static notification: NotificationSdkService;
37
41
  /**
38
42
  * Initialize the SDK with necessary services
39
43
  */
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@techextensor/tab-sdk",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^19.2.15",
6
6
  "@angular/core": "^19.2.15",
7
- "@techextensor/tab-core-utility": "2.2.199"
7
+ "@techextensor/tab-core-utility": "2.2.200"
8
8
  },
9
9
  "dependencies": {
10
10
  "tslib": "^2.8.1"