@liveblocks/core 2.24.0-deque1 → 2.24.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.
package/dist/index.d.ts CHANGED
@@ -1299,6 +1299,20 @@ type UpdateYDocClientMsg = {
1299
1299
  readonly v2?: boolean;
1300
1300
  };
1301
1301
 
1302
+ type RoomThreadsSubscriptionSettings = "all" | "replies_and_mentions" | "none";
1303
+ type RoomTextMentionsSubscriptionSettings = "mine" | "none";
1304
+ type RoomSubscriptionSettings = {
1305
+ threads: RoomThreadsSubscriptionSettings;
1306
+ textMentions: RoomTextMentionsSubscriptionSettings;
1307
+ };
1308
+ type UserRoomSubscriptionSettings = {
1309
+ roomId: string;
1310
+ } & RoomSubscriptionSettings;
1311
+ /**
1312
+ * @deprecated Renamed to `RoomSubscriptionSettings`
1313
+ */
1314
+ type RoomNotificationSettings = RoomSubscriptionSettings;
1315
+
1302
1316
  declare enum ServerMsgCode {
1303
1317
  UPDATE_PRESENCE = 100,
1304
1318
  USER_JOINED = 101,
@@ -1537,6 +1551,122 @@ type RejectedStorageOpServerMsg = {
1537
1551
  readonly reason: string;
1538
1552
  };
1539
1553
 
1554
+ /**
1555
+ * Pre-defined notification channels support list.
1556
+ */
1557
+ type NotificationChannel = "email" | "slack" | "teams" | "webPush";
1558
+ /**
1559
+ * `K` represents custom notification kinds
1560
+ * defined in the augmentation `ActivitiesData` (e.g `liveblocks.config.ts`).
1561
+ * It means the type `NotificationKind` will be shaped like:
1562
+ * thread | textMention | $customKind1 | $customKind2 | ...
1563
+ */
1564
+ type NotificationKind<K extends keyof DAD = keyof DAD> = "thread" | "textMention" | K;
1565
+ /**
1566
+ * A notification channel settings is a set of notification kinds.
1567
+ * One setting can have multiple kinds (+ augmentation)
1568
+ */
1569
+ type NotificationChannelSettings = {
1570
+ [K in NotificationKind]: boolean;
1571
+ };
1572
+ /**
1573
+ * @private
1574
+ *
1575
+ * Base definition of notification settings.
1576
+ * Plain means it's a simple object coming from the remote backend.
1577
+ *
1578
+ * It's the raw settings object where somme channels cannot exists
1579
+ * because there are no notification kinds enabled on the dashboard.
1580
+ * And this object isn't yet proxied by the creator factory `createNotificationSettings`.
1581
+ */
1582
+ type NotificationSettingsPlain = {
1583
+ [C in NotificationChannel]?: NotificationChannelSettings;
1584
+ };
1585
+ /**
1586
+ * @deprecated Renamed to `NotificationSettings`
1587
+ *
1588
+ * Notification settings.
1589
+ * One channel for one set of settings.
1590
+ */
1591
+ type UserNotificationSettings = NotificationSettings;
1592
+ /**
1593
+ * Notification settings.
1594
+ * One channel for one set of settings.
1595
+ */
1596
+ type NotificationSettings = {
1597
+ [C in NotificationChannel]: NotificationChannelSettings | null;
1598
+ };
1599
+ /**
1600
+ * It creates a deep partial specific for `NotificationSettings`
1601
+ * to offer a nice DX when updating the settings (e.g not being forced to define every keys)
1602
+ * and at the same the some preserver the augmentation for custom kinds (e.g `liveblocks.config.ts`).
1603
+ */
1604
+ type DeepPartialWithAugmentation<T> = T extends object ? {
1605
+ [P in keyof T]?: T[P] extends {
1606
+ [K in NotificationKind]: boolean;
1607
+ } ? Partial<T[P]> & {
1608
+ [K in keyof DAD]?: boolean;
1609
+ } : DeepPartialWithAugmentation<T[P]>;
1610
+ } : T;
1611
+ /**
1612
+ * Partial notification settings with augmentation preserved gracefully.
1613
+ * It means you can update the settings without being forced to define every keys.
1614
+ * Useful when implementing update functions.
1615
+ */
1616
+ type PartialNotificationSettings = DeepPartialWithAugmentation<NotificationSettingsPlain>;
1617
+ /**
1618
+ * @private
1619
+ *
1620
+ * Creates a `NotificationSettings` object with the given initial plain settings.
1621
+ * It defines a getter for each channel to access the settings and returns `null` with an error log
1622
+ * in case the required channel isn't enabled in the dashboard.
1623
+ *
1624
+ * You can see this function as `Proxy` like around `NotificationSettingsPlain` type.
1625
+ * We can't predict what will be enabled on the dashboard or not, so it's important
1626
+ * provide a good DX to developers by returning `null` completed by an error log
1627
+ * when they try to access a channel that isn't enabled in the dashboard.
1628
+ */
1629
+ declare function createNotificationSettings(plain: NotificationSettingsPlain): NotificationSettings;
1630
+ /**
1631
+ * @private
1632
+ *
1633
+ * Patch a `NotificationSettings` object by applying notification kind updates
1634
+ * coming from a `PartialNotificationSettings` object.
1635
+ */
1636
+ declare function patchNotificationSettings(existing: NotificationSettings, patch: PartialNotificationSettings): NotificationSettings;
1637
+ /**
1638
+ *
1639
+ * Utility to check if a notification channel settings
1640
+ * is enabled for every notification kinds.
1641
+ *
1642
+ * Usage:
1643
+ * ```ts
1644
+ * const isEmailChannelEnabled = isNotificationChannelEnabled(settings.email);
1645
+ * ```
1646
+ */
1647
+ declare function isNotificationChannelEnabled(settings: NotificationChannelSettings | null): boolean;
1648
+
1649
+ type SubscriptionData<K extends keyof DAD = keyof DAD> = {
1650
+ kind: NotificationKind<K>;
1651
+ subjectId: string;
1652
+ createdAt: Date;
1653
+ };
1654
+ type SubscriptionDataPlain = DateToString<SubscriptionData>;
1655
+ type UserSubscriptionData<K extends keyof DAD = keyof DAD> = SubscriptionData<K> & {
1656
+ userId: string;
1657
+ };
1658
+ type UserSubscriptionDataPlain = DateToString<UserSubscriptionData>;
1659
+ type SubscriptionDeleteInfo = {
1660
+ type: "deletedSubscription";
1661
+ kind: NotificationKind;
1662
+ subjectId: string;
1663
+ deletedAt: Date;
1664
+ };
1665
+ type SubscriptionDeleteInfoPlain = DateToString<SubscriptionDeleteInfo>;
1666
+ type SubscriptionKey = `${NotificationKind}:${string}`;
1667
+ declare function getSubscriptionKey(subscription: SubscriptionData | SubscriptionDeleteInfo): SubscriptionKey;
1668
+ declare function getSubscriptionKey(kind: NotificationKind, subjectId: string): SubscriptionKey;
1669
+
1540
1670
  type HistoryVersion = {
1541
1671
  type: "historyVersion";
1542
1672
  kind: "yjs";
@@ -1621,7 +1751,7 @@ type CommentsOrNotificationsErrorContext = {
1621
1751
  threadId: string;
1622
1752
  metadata: Patchable<BaseMetadata>;
1623
1753
  } | {
1624
- type: "MARK_THREAD_AS_RESOLVED_ERROR" | "MARK_THREAD_AS_UNRESOLVED_ERROR";
1754
+ type: "MARK_THREAD_AS_RESOLVED_ERROR" | "MARK_THREAD_AS_UNRESOLVED_ERROR" | "SUBSCRIBE_TO_THREAD_ERROR" | "UNSUBSCRIBE_FROM_THREAD_ERROR";
1625
1755
  roomId: string;
1626
1756
  threadId: string;
1627
1757
  } | {
@@ -1653,6 +1783,9 @@ type CommentsOrNotificationsErrorContext = {
1653
1783
  } | {
1654
1784
  type: "UPDATE_NOTIFICATION_SETTINGS_ERROR";
1655
1785
  roomId: string;
1786
+ } | {
1787
+ type: "UPDATE_ROOM_SUBSCRIPTION_SETTINGS_ERROR";
1788
+ roomId: string;
1656
1789
  } | {
1657
1790
  type: "UPDATE_USER_NOTIFICATION_SETTINGS_ERROR";
1658
1791
  };
@@ -1725,11 +1858,6 @@ declare enum TextEditorType {
1725
1858
  BlockNote = "blocknote"
1726
1859
  }
1727
1860
 
1728
- type RoomThreadsNotificationSettings = "all" | "replies_and_mentions" | "none";
1729
- type RoomNotificationSettings = {
1730
- threads: RoomThreadsNotificationSettings;
1731
- };
1732
-
1733
1861
  type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
1734
1862
  type: "leave";
1735
1863
  user: User<P, U>;
@@ -2000,7 +2128,7 @@ type ListTextVersionsSinceOptions = {
2000
2128
  since: Date;
2001
2129
  signal?: AbortSignal;
2002
2130
  };
2003
- type GetNotificationSettingsOptions = {
2131
+ type GetSubscriptionSettingsOptions = {
2004
2132
  signal?: AbortSignal;
2005
2133
  };
2006
2134
  /**
@@ -2224,18 +2352,20 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
2224
2352
  * const {
2225
2353
  * threads,
2226
2354
  * inboxNotifications,
2355
+ * subscriptions,
2227
2356
  * requestedAt
2228
2357
  * } = await room.getThreads({ query: { resolved: false }});
2229
2358
  */
2230
2359
  getThreads(options?: GetThreadsOptions<M>): Promise<{
2231
2360
  threads: ThreadData<M>[];
2232
2361
  inboxNotifications: InboxNotificationData[];
2362
+ subscriptions: SubscriptionData[];
2233
2363
  requestedAt: Date;
2234
2364
  nextCursor: string | null;
2235
2365
  permissionHints: Record<string, Permission[]>;
2236
2366
  }>;
2237
2367
  /**
2238
- * Returns the updated and deleted threads and their associated inbox notifications since the requested date.
2368
+ * Returns the updated and deleted threads and their associated inbox notifications and subscriptions since the requested date.
2239
2369
  *
2240
2370
  * @example
2241
2371
  * const result = await room.getThreads();
@@ -2251,18 +2381,23 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
2251
2381
  updated: InboxNotificationData[];
2252
2382
  deleted: InboxNotificationDeleteInfo[];
2253
2383
  };
2384
+ subscriptions: {
2385
+ updated: SubscriptionData[];
2386
+ deleted: SubscriptionDeleteInfo[];
2387
+ };
2254
2388
  requestedAt: Date;
2255
2389
  permissionHints: Record<string, Permission[]>;
2256
2390
  }>;
2257
2391
  /**
2258
- * Returns a thread and the associated inbox notification if it exists.
2392
+ * Returns a thread and the associated inbox notification and subscription if it exists.
2259
2393
  *
2260
2394
  * @example
2261
- * const { thread, inboxNotification } = await room.getThread("th_xxx");
2395
+ * const { thread, inboxNotification, subscription } = await room.getThread("th_xxx");
2262
2396
  */
2263
2397
  getThread(threadId: string): Promise<{
2264
2398
  thread?: ThreadData<M>;
2265
2399
  inboxNotification?: InboxNotificationData;
2400
+ subscription?: SubscriptionData;
2266
2401
  }>;
2267
2402
  /**
2268
2403
  * Creates a thread.
@@ -2314,6 +2449,20 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
2314
2449
  * await room.markThreadAsUnresolved("th_xxx");
2315
2450
  */
2316
2451
  markThreadAsUnresolved(threadId: string): Promise<void>;
2452
+ /**
2453
+ * Subscribes the user to a thread.
2454
+ *
2455
+ * @example
2456
+ * await room.subscribeToThread("th_xxx");
2457
+ */
2458
+ subscribeToThread(threadId: string): Promise<SubscriptionData>;
2459
+ /**
2460
+ * Unsubscribes the user from a thread.
2461
+ *
2462
+ * @example
2463
+ * await room.unsubscribeFromThread("th_xxx");
2464
+ */
2465
+ unsubscribeFromThread(threadId: string): Promise<void>;
2317
2466
  /**
2318
2467
  * Creates a comment.
2319
2468
  *
@@ -2410,20 +2559,34 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
2410
2559
  */
2411
2560
  getAttachmentUrl(attachmentId: string): Promise<string>;
2412
2561
  /**
2413
- * Gets the user's notification settings for the current room.
2562
+ * @deprecated Renamed to `getSubscriptionSettings`
2563
+ *
2564
+ * Gets the user's subscription settings for the current room.
2565
+ */
2566
+ getNotificationSettings(options?: GetSubscriptionSettingsOptions): Promise<RoomSubscriptionSettings>;
2567
+ /**
2568
+ * Gets the user's subscription settings for the current room.
2414
2569
  *
2415
2570
  * @example
2416
- * const settings = await room.getNotificationSettings();
2571
+ * const settings = await room.getSubscriptionSettings();
2417
2572
  */
2418
- getNotificationSettings(options?: GetNotificationSettingsOptions): Promise<RoomNotificationSettings>;
2573
+ getSubscriptionSettings(options?: GetSubscriptionSettingsOptions): Promise<RoomSubscriptionSettings>;
2419
2574
  /**
2420
- * Updates the user's notification settings for the current room.
2575
+ * @deprecated Renamed to `getSubscriptionSettings`
2576
+ *
2577
+ * Updates the user's subscription settings for the current room.
2578
+ */
2579
+ updateNotificationSettings(settings: Partial<RoomSubscriptionSettings>): Promise<RoomSubscriptionSettings>;
2580
+ /**
2581
+ * Updates the user's subscription settings for the current room.
2421
2582
  *
2422
2583
  * @example
2423
- * await room.updateNotificationSettings({ threads: "replies_and_mentions" });
2584
+ * await room.updateSubscriptionSettings({ threads: "replies_and_mentions" });
2424
2585
  */
2425
- updateNotificationSettings(settings: Partial<RoomNotificationSettings>): Promise<RoomNotificationSettings>;
2586
+ updateSubscriptionSettings(settings: Partial<RoomSubscriptionSettings>): Promise<RoomSubscriptionSettings>;
2426
2587
  /**
2588
+ * @private
2589
+ *
2427
2590
  * Internal use only. Signature might change in the future.
2428
2591
  */
2429
2592
  markInboxNotificationAsRead(notificationId: string): Promise<void>;
@@ -2531,94 +2694,6 @@ type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ?
2531
2694
  ] extends [never] ? OptionalTuple<T> : T;
2532
2695
  type LargeMessageStrategy = "default" | "split" | "experimental-fallback-to-http";
2533
2696
 
2534
- /**
2535
- * Pre-defined notification channels support list.
2536
- */
2537
- type NotificationChannel = "email" | "slack" | "teams" | "webPush";
2538
- /**
2539
- * `K` represents custom notification kinds
2540
- * defined in the augmentation `ActivitiesData` (e.g `liveblocks.config.ts`).
2541
- * It means the type `NotificationKind` will be shaped like:
2542
- * thread | textMention | $customKind1 | $customKind2 | ...
2543
- */
2544
- type NotificationKind<K extends keyof DAD = keyof DAD> = "thread" | "textMention" | K;
2545
- /**
2546
- * A notification channel settings is a set of notification kinds.
2547
- * One setting can have multiple kinds (+ augmentation)
2548
- */
2549
- type NotificationChannelSettings = {
2550
- [K in NotificationKind]: boolean;
2551
- };
2552
- /**
2553
- * @private
2554
- *
2555
- * Base definition of user notification settings.
2556
- * Plain means it's a simple object coming from the remote backend.
2557
- *
2558
- * It's the raw settings object where somme channels cannot exists
2559
- * because there are no notification kinds enabled on the dashboard.
2560
- * And this object isn't yet proxied by the creator factory `createUserNotificationSettings`.
2561
- */
2562
- type UserNotificationSettingsPlain = {
2563
- [C in NotificationChannel]?: NotificationChannelSettings;
2564
- };
2565
- /**
2566
- * User notification settings.
2567
- * One channel for one set of settings.
2568
- */
2569
- type UserNotificationSettings = {
2570
- [C in NotificationChannel]: NotificationChannelSettings | null;
2571
- };
2572
- /**
2573
- * It creates a deep partial specific for `UserNotificationSettings`
2574
- * to offer a nice DX when updating the settings (e.g not being forced to define every keys)
2575
- * and at the same the some preserver the augmentation for custom kinds (e.g `liveblocks.config.ts`).
2576
- */
2577
- type DeepPartialWithAugmentation<T> = T extends object ? {
2578
- [P in keyof T]?: T[P] extends {
2579
- [K in NotificationKind]: boolean;
2580
- } ? Partial<T[P]> & {
2581
- [K in keyof DAD]?: boolean;
2582
- } : DeepPartialWithAugmentation<T[P]>;
2583
- } : T;
2584
- /**
2585
- * Partial user notification settings with augmentation preserved gracefully.
2586
- * It means you can update the settings without being forced to define every keys.
2587
- * Useful when implementing update functions.
2588
- */
2589
- type PartialUserNotificationSettings = DeepPartialWithAugmentation<UserNotificationSettingsPlain>;
2590
- /**
2591
- * @private
2592
- *
2593
- * Creates a `UserNotificationSettings` object with the given initial plain settings.
2594
- * It defines a getter for each channel to access the settings and returns `null` with an error log
2595
- * in case the required channel isn't enabled in the dashboard.
2596
- *
2597
- * You can see this function as `Proxy` like around `UserNotificationSettingsPlain` type.
2598
- * We can't predict what will be enabled on the dashboard or not, so it's important
2599
- * provide a good DX to developers by returning `null` completed by an error log
2600
- * when they try to access a channel that isn't enabled in the dashboard.
2601
- */
2602
- declare function createUserNotificationSettings(plain: UserNotificationSettingsPlain): UserNotificationSettings;
2603
- /**
2604
- * @private
2605
- *
2606
- * Patch a `UserNotificationSettings` object by applying notification kind updates
2607
- * coming from a `PartialUserNotificationSettings` object.
2608
- */
2609
- declare function patchUserNotificationSettings(existing: UserNotificationSettings, patch: PartialUserNotificationSettings): UserNotificationSettings;
2610
- /**
2611
- *
2612
- * Utility to check if a notification channel settings
2613
- * is enabled for every notification kinds.
2614
- *
2615
- * Usage:
2616
- * ```ts
2617
- * const isEmailChannelEnabled = isNotificationChannelEnabled(settings.email);
2618
- * ```
2619
- */
2620
- declare function isNotificationChannelEnabled(settings: NotificationChannelSettings | null): boolean;
2621
-
2622
2697
  interface RoomHttpApi<M extends BaseMetadata> {
2623
2698
  getThreads(options: {
2624
2699
  roomId: string;
@@ -2630,6 +2705,7 @@ interface RoomHttpApi<M extends BaseMetadata> {
2630
2705
  }): Promise<{
2631
2706
  threads: ThreadData<M>[];
2632
2707
  inboxNotifications: InboxNotificationData[];
2708
+ subscriptions: SubscriptionData[];
2633
2709
  requestedAt: Date;
2634
2710
  nextCursor: string | null;
2635
2711
  permissionHints: Record<string, Permission[]>;
@@ -2647,6 +2723,10 @@ interface RoomHttpApi<M extends BaseMetadata> {
2647
2723
  updated: InboxNotificationData[];
2648
2724
  deleted: InboxNotificationDeleteInfo[];
2649
2725
  };
2726
+ subscriptions: {
2727
+ updated: SubscriptionData[];
2728
+ deleted: SubscriptionDeleteInfo[];
2729
+ };
2650
2730
  requestedAt: Date;
2651
2731
  permissionHints: Record<string, Permission[]>;
2652
2732
  }>;
@@ -2664,6 +2744,7 @@ interface RoomHttpApi<M extends BaseMetadata> {
2664
2744
  }): Promise<{
2665
2745
  thread?: ThreadData<M>;
2666
2746
  inboxNotification?: InboxNotificationData;
2747
+ subscription?: SubscriptionData;
2667
2748
  }>;
2668
2749
  deleteThread({ roomId, threadId, }: {
2669
2750
  roomId: string;
@@ -2713,18 +2794,26 @@ interface RoomHttpApi<M extends BaseMetadata> {
2713
2794
  roomId: string;
2714
2795
  threadId: string;
2715
2796
  }): Promise<void>;
2797
+ subscribeToThread({ roomId, threadId, }: {
2798
+ roomId: string;
2799
+ threadId: string;
2800
+ }): Promise<SubscriptionData>;
2801
+ unsubscribeFromThread({ roomId, threadId, }: {
2802
+ roomId: string;
2803
+ threadId: string;
2804
+ }): Promise<void>;
2716
2805
  markRoomInboxNotificationAsRead({ roomId, inboxNotificationId, }: {
2717
2806
  roomId: string;
2718
2807
  inboxNotificationId: string;
2719
2808
  }): Promise<string>;
2720
- getNotificationSettings({ roomId, signal, }: {
2809
+ getSubscriptionSettings({ roomId, signal, }: {
2721
2810
  roomId: string;
2722
2811
  signal?: AbortSignal;
2723
- }): Promise<RoomNotificationSettings>;
2724
- updateNotificationSettings({ roomId, settings, }: {
2812
+ }): Promise<RoomSubscriptionSettings>;
2813
+ updateSubscriptionSettings({ roomId, settings, }: {
2725
2814
  roomId: string;
2726
- settings: Partial<RoomNotificationSettings>;
2727
- }): Promise<RoomNotificationSettings>;
2815
+ settings: Partial<RoomSubscriptionSettings>;
2816
+ }): Promise<RoomSubscriptionSettings>;
2728
2817
  getAttachmentUrl(options: {
2729
2818
  roomId: string;
2730
2819
  attachmentId: string;
@@ -2811,6 +2900,7 @@ interface NotificationHttpApi<M extends BaseMetadata> {
2811
2900
  }): Promise<{
2812
2901
  inboxNotifications: InboxNotificationData[];
2813
2902
  threads: ThreadData<M>[];
2903
+ subscriptions: SubscriptionData[];
2814
2904
  nextCursor: string | null;
2815
2905
  requestedAt: Date;
2816
2906
  }>;
@@ -2826,6 +2916,10 @@ interface NotificationHttpApi<M extends BaseMetadata> {
2826
2916
  updated: ThreadData<M>[];
2827
2917
  deleted: ThreadDeleteInfo[];
2828
2918
  };
2919
+ subscriptions: {
2920
+ updated: SubscriptionData[];
2921
+ deleted: SubscriptionDeleteInfo[];
2922
+ };
2829
2923
  requestedAt: Date;
2830
2924
  }>;
2831
2925
  getUnreadInboxNotificationsCount(): Promise<number>;
@@ -2833,10 +2927,10 @@ interface NotificationHttpApi<M extends BaseMetadata> {
2833
2927
  markInboxNotificationAsRead(inboxNotificationId: string): Promise<void>;
2834
2928
  deleteAllInboxNotifications(): Promise<void>;
2835
2929
  deleteInboxNotification(inboxNotificationId: string): Promise<void>;
2836
- getUserNotificationSettings(options?: {
2930
+ getNotificationSettings(options?: {
2837
2931
  signal?: AbortSignal;
2838
- }): Promise<UserNotificationSettingsPlain>;
2839
- updateUserNotificationSettings(settings: PartialUserNotificationSettings): Promise<UserNotificationSettingsPlain>;
2932
+ }): Promise<NotificationSettingsPlain>;
2933
+ updateNotificationSettings(settings: PartialNotificationSettings): Promise<NotificationSettingsPlain>;
2840
2934
  }
2841
2935
  interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, NotificationHttpApi<M> {
2842
2936
  getUserThreads_experimental(options?: {
@@ -2848,6 +2942,7 @@ interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, Noti
2848
2942
  }): Promise<{
2849
2943
  threads: ThreadData<M>[];
2850
2944
  inboxNotifications: InboxNotificationData[];
2945
+ subscriptions: SubscriptionData[];
2851
2946
  nextCursor: string | null;
2852
2947
  requestedAt: Date;
2853
2948
  permissionHints: Record<string, Permission[]>;
@@ -2864,6 +2959,10 @@ interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, Noti
2864
2959
  updated: ThreadData<M>[];
2865
2960
  deleted: ThreadDeleteInfo[];
2866
2961
  };
2962
+ subscriptions: {
2963
+ updated: SubscriptionData[];
2964
+ deleted: SubscriptionDeleteInfo[];
2965
+ };
2867
2966
  requestedAt: Date;
2868
2967
  permissionHints: Record<string, Permission[]>;
2869
2968
  }>;
@@ -3035,7 +3134,7 @@ type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
3035
3134
  type NotificationsApi<M extends BaseMetadata> = {
3036
3135
  /**
3037
3136
  * Gets a page (or the initial page) for user inbox notifications and their
3038
- * associated threads.
3137
+ * associated threads and thread subscriptions.
3039
3138
  *
3040
3139
  * This function should NOT be used for delta updates, only for pagination
3041
3140
  * (including the first page fetch). For delta updates (done during the
@@ -3045,6 +3144,7 @@ type NotificationsApi<M extends BaseMetadata> = {
3045
3144
  * const {
3046
3145
  * inboxNotifications,
3047
3146
  * threads,
3147
+ * subscriptions,
3048
3148
  * nextCursor,
3049
3149
  * } = await client.getInboxNotifications();
3050
3150
  * const data = await client.getInboxNotifications(); // Fetch initial page (of 20 inbox notifications)
@@ -3055,6 +3155,7 @@ type NotificationsApi<M extends BaseMetadata> = {
3055
3155
  }): Promise<{
3056
3156
  inboxNotifications: InboxNotificationData[];
3057
3157
  threads: ThreadData<M>[];
3158
+ subscriptions: SubscriptionData[];
3058
3159
  nextCursor: string | null;
3059
3160
  requestedAt: Date;
3060
3161
  }>;
@@ -3073,7 +3174,11 @@ type NotificationsApi<M extends BaseMetadata> = {
3073
3174
  * threads: {
3074
3175
  * updated,
3075
3176
  * deleted,
3076
- * },
3177
+ * },
3178
+ * subscriptions: {
3179
+ * updated,
3180
+ * deleted,
3181
+ * },
3077
3182
  * requestedAt,
3078
3183
  * } = await client.getInboxNotificationsSince({ since: result.requestedAt }});
3079
3184
  */
@@ -3089,6 +3194,10 @@ type NotificationsApi<M extends BaseMetadata> = {
3089
3194
  updated: ThreadData<M>[];
3090
3195
  deleted: ThreadDeleteInfo[];
3091
3196
  };
3197
+ subscriptions: {
3198
+ updated: SubscriptionData[];
3199
+ deleted: SubscriptionDeleteInfo[];
3200
+ };
3092
3201
  requestedAt: Date;
3093
3202
  }>;
3094
3203
  /**
@@ -3134,7 +3243,7 @@ type NotificationsApi<M extends BaseMetadata> = {
3134
3243
  */
3135
3244
  getNotificationSettings(options?: {
3136
3245
  signal?: AbortSignal;
3137
- }): Promise<UserNotificationSettings>;
3246
+ }): Promise<NotificationSettings>;
3138
3247
  /**
3139
3248
  * Update notifications settings for a user for a project.
3140
3249
  *
@@ -3147,7 +3256,7 @@ type NotificationsApi<M extends BaseMetadata> = {
3147
3256
  * }
3148
3257
  * })
3149
3258
  */
3150
- updateNotificationSettings(settings: PartialUserNotificationSettings): Promise<UserNotificationSettings>;
3259
+ updateNotificationSettings(settings: PartialNotificationSettings): Promise<NotificationSettings>;
3151
3260
  };
3152
3261
  /**
3153
3262
  * @private Widest-possible Client type, matching _any_ Client instance. Note
@@ -3460,6 +3569,20 @@ declare function convertToCommentUserReaction(data: CommentUserReactionPlain): C
3460
3569
  * @returns The rich inbox notification data object that can be used by the client.
3461
3570
  */
3462
3571
  declare function convertToInboxNotificationData(data: InboxNotificationDataPlain): InboxNotificationData;
3572
+ /**
3573
+ * Converts a plain subscription data object (usually returned by the API) to a subscription data object that can be used by the client.
3574
+ * This is necessary because the plain data object stores dates as ISO strings, but the client expects them as Date objects.
3575
+ * @param data The plain subscription data object (usually returned by the API)
3576
+ * @returns The rich subscription data object that can be used by the client.
3577
+ */
3578
+ declare function convertToSubscriptionData(data: SubscriptionDataPlain): SubscriptionData;
3579
+ /**
3580
+ * Converts a plain user subscription data object (usually returned by the API) to a user subscription data object that can be used by the client.
3581
+ * This is necessary because the plain data object stores dates as ISO strings, but the client expects them as Date objects.
3582
+ * @param data The plain user subscription data object (usually returned by the API)
3583
+ * @returns The rich user subscription data object that can be used by the client.
3584
+ */
3585
+ declare function convertToUserSubscriptionData(data: UserSubscriptionDataPlain): UserSubscriptionData;
3463
3586
 
3464
3587
  /**
3465
3588
  * Lookup table for nodes (= SerializedCrdt values) by their IDs.
@@ -3745,6 +3868,11 @@ type Poller = {
3745
3868
  * the next poll at the regular interval.
3746
3869
  */
3747
3870
  pollNowIfStale(): void;
3871
+ /**
3872
+ * Marks the poller as stale. This can be used to force the next call
3873
+ * to `.pollNowIfStale()` to poll immediately.
3874
+ */
3875
+ markAsStale(): void;
3748
3876
  };
3749
3877
  /**
3750
3878
  * Makes a poller that will call `await callback()` at the desired interval (in
@@ -3918,6 +4046,15 @@ declare function asPos(str: string): Pos;
3918
4046
  * Testing goes one level deep.
3919
4047
  */
3920
4048
  declare function shallow(a: unknown, b: unknown): boolean;
4049
+ /**
4050
+ * Two-level deep shallow check.
4051
+ * Useful for checking equality of { isLoading: false, myData: [ ... ] } like
4052
+ * data structures, where you want to do a shallow comparison on the "data"
4053
+ * key.
4054
+ *
4055
+ * NOTE: Works on objects only, not on arrays!
4056
+ */
4057
+ declare function shallow2(a: unknown, b: unknown): boolean;
3921
4058
 
3922
4059
  /**
3923
4060
  * A datastructure to keep elements in ascending order, as defined by the "less
@@ -4118,4 +4255,4 @@ declare const CommentsApiError: typeof HttpError;
4118
4255
  /** @deprecated Use HttpError instead. */
4119
4256
  declare const NotificationsApiError: typeof HttpError;
4120
4257
 
4121
- export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, type ManagedPool, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, type UserNotificationSettingsPlain, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createThreadId, createUserNotificationSettings, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchUserNotificationSettings, raise, resolveUsersInCommentBody, shallow, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
4258
+ export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, type ManagedPool, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type RoomSubscriptionSettings, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, getSubscriptionKey, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveUsersInCommentBody, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };