@liveblocks/core 1.10.0-beta3 → 1.10.0-beta4

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.mts CHANGED
@@ -179,12 +179,15 @@ interface IWebSocket {
179
179
  /**
180
180
  * The following ranges will be respected by the client:
181
181
  *
182
+ * 10xx: client will reauthorize (just like 41xx)
182
183
  * 40xx: client will disconnect
183
184
  * 41xx: client will reauthorize
184
185
  * 42xx: client will retry without reauthorizing (currently not used)
185
186
  *
186
187
  */
187
188
  declare enum WebsocketCloseCodes {
189
+ /** Normal close of connection, the connection fulfilled its purpose. */
190
+ CLOSE_NORMAL = 1000,
188
191
  /** Unexpected error happened with the network/infra level. In spirit akin to HTTP 503 */
189
192
  CLOSE_ABNORMAL = 1006,
190
193
  /** Unexpected error happened. In spirit akin to HTTP 500 */
@@ -203,6 +206,8 @@ declare enum WebsocketCloseCodes {
203
206
  MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP = 4004,
204
207
  /** Room is full, disconnect */
205
208
  MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM = 4005,
209
+ /** The server kicked the connection from the room. */
210
+ KICKED = 4100,
206
211
  /** The auth token is expired, reauthorize to get a fresh one. In spirit akin to HTTP 401 */
207
212
  TOKEN_EXPIRED = 4109,
208
213
  /** Disconnect immediately */
@@ -237,6 +242,9 @@ declare type LostConnectionEvent = "lost" | "restored" | "failed";
237
242
  * any value (except null).
238
243
  */
239
244
  declare type BaseAuthResult = NonNullable<Json>;
245
+ declare class LiveblocksError extends Error {
246
+ code: number;
247
+ }
240
248
  declare type Delegates<T extends BaseAuthResult> = {
241
249
  authenticate: () => Promise<T>;
242
250
  createSocket: (authValue: T) => IWebSocketInstance;
@@ -1332,6 +1340,7 @@ declare type InternalOthersEvent<TPresence extends JsonObject, TUserMeta extends
1332
1340
  updates: Partial<TPresence>;
1333
1341
  } | {
1334
1342
  type: "reset";
1343
+ user?: never;
1335
1344
  };
1336
1345
  declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = Resolve<InternalOthersEvent<TPresence, TUserMeta> & {
1337
1346
  others: readonly User<TPresence, TUserMeta>[];
@@ -1540,7 +1549,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1540
1549
  * @returns Unsubscribe function.
1541
1550
  *
1542
1551
  */
1543
- (type: "error", listener: ErrorCallback): () => void;
1552
+ (type: "error", listener: Callback<LiveblocksError>): () => void;
1544
1553
  /**
1545
1554
  * @deprecated This API will be removed in a future version of Liveblocks.
1546
1555
  * Prefer using the newer `.subscribe('status')` API.
@@ -1655,11 +1664,8 @@ declare type GetThreadsOptions<TThreadMetadata extends BaseMetadata> = {
1655
1664
  };
1656
1665
  since?: Date;
1657
1666
  };
1658
- declare type CommentsApi<TThreadMetadata extends BaseMetadata = never> = {
1659
- /**
1660
- * @private
1661
- */
1662
- getThreads(options?: GetThreadsOptions<TThreadMetadata>): Promise<{
1667
+ declare type CommentsApi = {
1668
+ getThreads<TThreadMetadata extends BaseMetadata = never>(options?: GetThreadsOptions<TThreadMetadata>): Promise<{
1663
1669
  threads: ThreadData<TThreadMetadata>[];
1664
1670
  inboxNotifications: InboxNotificationData[];
1665
1671
  deletedThreads: ThreadDeleteInfo[];
@@ -1668,72 +1674,48 @@ declare type CommentsApi<TThreadMetadata extends BaseMetadata = never> = {
1668
1674
  requestedAt: Date;
1669
1675
  };
1670
1676
  }>;
1671
- /**
1672
- * @private
1673
- */
1674
- getThread(options: {
1677
+ getThread<TThreadMetadata extends BaseMetadata = never>(options: {
1675
1678
  threadId: string;
1676
1679
  }): Promise<{
1677
1680
  thread: ThreadData<TThreadMetadata>;
1678
1681
  inboxNotification?: InboxNotificationData;
1679
1682
  } | undefined>;
1680
- /**
1681
- * @private
1682
- */
1683
- createThread(options: {
1683
+ createThread<TThreadMetadata extends BaseMetadata = never>(options: {
1684
1684
  threadId: string;
1685
1685
  commentId: string;
1686
1686
  metadata: TThreadMetadata | undefined;
1687
1687
  body: CommentBody;
1688
1688
  }): Promise<ThreadData<TThreadMetadata>>;
1689
- /**
1690
- * @private
1691
- */
1692
- editThreadMetadata(options: {
1689
+ editThreadMetadata<TThreadMetadata extends BaseMetadata = never>(options: {
1693
1690
  metadata: PartialNullable<TThreadMetadata>;
1694
1691
  threadId: string;
1695
1692
  }): Promise<TThreadMetadata>;
1696
- /**
1697
- * @private
1698
- */
1699
1693
  createComment(options: {
1700
1694
  threadId: string;
1701
1695
  commentId: string;
1702
1696
  body: CommentBody;
1703
1697
  }): Promise<CommentData>;
1704
- /**
1705
- * @private
1706
- */
1707
1698
  editComment(options: {
1708
1699
  threadId: string;
1709
1700
  commentId: string;
1710
1701
  body: CommentBody;
1711
1702
  }): Promise<CommentData>;
1712
- /**
1713
- * @private
1714
- */
1715
1703
  deleteComment(options: {
1716
1704
  threadId: string;
1717
1705
  commentId: string;
1718
1706
  }): Promise<void>;
1719
- /**
1720
- * @private
1721
- */
1722
1707
  addReaction(options: {
1723
1708
  threadId: string;
1724
1709
  commentId: string;
1725
1710
  emoji: string;
1726
1711
  }): Promise<CommentUserReaction>;
1727
- /**
1728
- * @private
1729
- */
1730
1712
  removeReaction(options: {
1731
1713
  threadId: string;
1732
1714
  commentId: string;
1733
1715
  emoji: string;
1734
1716
  }): Promise<void>;
1735
1717
  };
1736
- declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = CommentsApi<any> & {
1718
+ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
1737
1719
  /**
1738
1720
  * @private
1739
1721
  *
@@ -1866,7 +1848,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1866
1848
  readonly self: Observable<User<TPresence, TUserMeta>>;
1867
1849
  readonly myPresence: Observable<TPresence>;
1868
1850
  readonly others: Observable<OthersEvent<TPresence, TUserMeta>>;
1869
- readonly error: Observable<Error>;
1851
+ readonly error: Observable<LiveblocksError>;
1870
1852
  readonly storage: Observable<StorageUpdate[]>;
1871
1853
  readonly history: Observable<HistoryEvent>;
1872
1854
  /**
@@ -1879,14 +1861,6 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1879
1861
  readonly ydoc: Observable<YDocUpdateServerMsg | UpdateYDocClientMsg>;
1880
1862
  readonly comments: Observable<CommentsEventServerMsg>;
1881
1863
  };
1882
- /**
1883
- * @private
1884
- */
1885
- getRoomNotificationSettings(): Promise<RoomNotificationSettings>;
1886
- /**
1887
- * @private
1888
- */
1889
- updateRoomNotificationSettings(settings: Partial<RoomNotificationSettings>): Promise<RoomNotificationSettings>;
1890
1864
  /**
1891
1865
  * Batches modifications made during the given function.
1892
1866
  * All the modifications are sent to other clients in a single message.
@@ -1952,8 +1926,11 @@ declare type PrivateRoomApi = {
1952
1926
  explicitClose(event: IWebSocketCloseEvent): void;
1953
1927
  rawSend(data: string): void;
1954
1928
  };
1955
- comments: {
1956
- lastRequestedAt: Date | null;
1929
+ comments: CommentsApi;
1930
+ notifications: {
1931
+ getRoomNotificationSettings(): Promise<RoomNotificationSettings>;
1932
+ updateRoomNotificationSettings(settings: Partial<RoomNotificationSettings>): Promise<RoomNotificationSettings>;
1933
+ markInboxNotificationAsRead(notificationId: string): Promise<void>;
1957
1934
  };
1958
1935
  };
1959
1936
  declare type HistoryOp<TPresence extends JsonObject> = Op | {
@@ -2036,20 +2013,17 @@ declare type EditThreadMetadataOptimisticUpdate<TThreadMetadata extends BaseMeta
2036
2013
  id: string;
2037
2014
  threadId: string;
2038
2015
  metadata: Resolve<PartialNullable<TThreadMetadata>>;
2016
+ updatedAt: Date;
2039
2017
  };
2040
2018
  declare type CreateCommentOptimisticUpdate = {
2041
2019
  type: "create-comment";
2042
2020
  id: string;
2043
2021
  comment: CommentData;
2044
- inboxNotificationId?: string;
2045
2022
  };
2046
2023
  declare type EditCommentOptimisticUpdate = {
2047
2024
  type: "edit-comment";
2048
2025
  id: string;
2049
- threadId: string;
2050
- editedAt: Date;
2051
- commentId: string;
2052
- body: CommentBody;
2026
+ comment: CommentData;
2053
2027
  };
2054
2028
  declare type DeleteCommentOptimisticUpdate = {
2055
2029
  type: "delete-comment";
@@ -2063,9 +2037,7 @@ declare type AddReactionOptimisticUpdate = {
2063
2037
  id: string;
2064
2038
  threadId: string;
2065
2039
  commentId: string;
2066
- emoji: string;
2067
- createdAt: Date;
2068
- userId: string;
2040
+ reaction: CommentUserReaction;
2069
2041
  };
2070
2042
  declare type RemoveReactionOptimisticUpdate = {
2071
2043
  type: "remove-reaction";
@@ -2074,6 +2046,7 @@ declare type RemoveReactionOptimisticUpdate = {
2074
2046
  commentId: string;
2075
2047
  emoji: string;
2076
2048
  userId: string;
2049
+ removedAt: Date;
2077
2050
  };
2078
2051
  declare type MarkInboxNotificationAsReadOptimisticUpdate = {
2079
2052
  type: "mark-inbox-notification-as-read";
@@ -2131,6 +2104,10 @@ interface CacheStore<TThreadMetadata extends BaseMetadata> extends Store<CacheSt
2131
2104
  setQueryState(queryKey: string, queryState: QueryState): void;
2132
2105
  }
2133
2106
  declare function applyOptimisticUpdates<TThreadMetadata extends BaseMetadata>(state: CacheState<TThreadMetadata>): Pick<CacheState<TThreadMetadata>, "threads" | "inboxNotifications" | "notificationSettings">;
2107
+ declare function upsertComment<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, comment: CommentData): ThreadDataWithDeleteInfo<TThreadMetadata>;
2108
+ declare function deleteComment<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, commentId: string, deletedAt: Date): ThreadDataWithDeleteInfo<TThreadMetadata>;
2109
+ declare function addReaction<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, commentId: string, reaction: CommentUserReaction): ThreadDataWithDeleteInfo<TThreadMetadata>;
2110
+ declare function removeReaction<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, commentId: string, emoji: string, userId: string, removedAt: Date): ThreadDataWithDeleteInfo<TThreadMetadata>;
2134
2111
 
2135
2112
  declare type OptionalPromise<T> = T | Promise<T>;
2136
2113
 
@@ -2186,6 +2163,7 @@ declare type EnterOptions<TPresence extends JsonObject, TStorage extends LsonObj
2186
2163
  * will probably happen if you do.
2187
2164
  */
2188
2165
  declare type PrivateClientApi<TUserMeta extends BaseUserMeta> = {
2166
+ notifications: NotificationsApi;
2189
2167
  currentUserIdStore: Store<string | null>;
2190
2168
  resolveMentionSuggestions: ClientOptions["resolveMentionSuggestions"];
2191
2169
  cacheStore: CacheStore<BaseMetadata>;
@@ -2193,10 +2171,7 @@ declare type PrivateClientApi<TUserMeta extends BaseUserMeta> = {
2193
2171
  roomsInfoStore: BatchStore<RoomInfo | undefined, [string]>;
2194
2172
  getRoomIds: () => string[];
2195
2173
  };
2196
- declare type InboxNotificationsApi<TThreadMetadata extends BaseMetadata = never> = {
2197
- /**
2198
- * @private
2199
- */
2174
+ declare type NotificationsApi<TThreadMetadata extends BaseMetadata = never> = {
2200
2175
  getInboxNotifications(options?: GetInboxNotificationsOptions): Promise<{
2201
2176
  inboxNotifications: InboxNotificationData[];
2202
2177
  threads: ThreadData<TThreadMetadata>[];
@@ -2206,20 +2181,11 @@ declare type InboxNotificationsApi<TThreadMetadata extends BaseMetadata = never>
2206
2181
  requestedAt: Date;
2207
2182
  };
2208
2183
  }>;
2209
- /**
2210
- * @private
2211
- */
2212
2184
  getUnreadInboxNotificationsCount(): Promise<number>;
2213
- /**
2214
- * @private
2215
- */
2216
2185
  markAllInboxNotificationsAsRead(): Promise<void>;
2217
- /**
2218
- * @private
2219
- */
2220
2186
  markInboxNotificationAsRead(inboxNotificationId: string): Promise<void>;
2221
2187
  };
2222
- declare type Client<TUserMeta extends BaseUserMeta = BaseUserMeta> = InboxNotificationsApi & {
2188
+ declare type Client<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2223
2189
  /**
2224
2190
  * Gets a room. Returns null if {@link Client.enter} has not been called previously.
2225
2191
  *
@@ -2812,4 +2778,4 @@ declare type EnsureJson<T> = [
2812
2778
  [K in keyof T]: EnsureJson<T[K]>;
2813
2779
  };
2814
2780
 
2815
- export { type AckOp, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type CacheState, type CacheStore, type Client, type ClientMsg, ClientMsgCode, 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 CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationThreadData, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, NotificationsApiError, type Op, OpCode, type OptionalPromise, type Others, type OthersEvent, type ParentToChildNodeMap, type PartialNullable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomInfo, type RoomInitializers, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, applyOptimisticUpdates, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToThreadData, createClient, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, withTimeout };
2781
+ export { type AckOp, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type CacheState, type CacheStore, type Client, type ClientMsg, ClientMsgCode, 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 CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationThreadData, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, NotificationsApiError, type Op, OpCode, type OptionalPromise, type Others, type OthersEvent, type ParentToChildNodeMap, type PartialNullable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomInfo, type RoomInitializers, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, addReaction, applyOptimisticUpdates, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToThreadData, createClient, deleteComment, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, raise, removeReaction, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, upsertComment, withTimeout };
package/dist/index.d.ts CHANGED
@@ -179,12 +179,15 @@ interface IWebSocket {
179
179
  /**
180
180
  * The following ranges will be respected by the client:
181
181
  *
182
+ * 10xx: client will reauthorize (just like 41xx)
182
183
  * 40xx: client will disconnect
183
184
  * 41xx: client will reauthorize
184
185
  * 42xx: client will retry without reauthorizing (currently not used)
185
186
  *
186
187
  */
187
188
  declare enum WebsocketCloseCodes {
189
+ /** Normal close of connection, the connection fulfilled its purpose. */
190
+ CLOSE_NORMAL = 1000,
188
191
  /** Unexpected error happened with the network/infra level. In spirit akin to HTTP 503 */
189
192
  CLOSE_ABNORMAL = 1006,
190
193
  /** Unexpected error happened. In spirit akin to HTTP 500 */
@@ -203,6 +206,8 @@ declare enum WebsocketCloseCodes {
203
206
  MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP = 4004,
204
207
  /** Room is full, disconnect */
205
208
  MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM = 4005,
209
+ /** The server kicked the connection from the room. */
210
+ KICKED = 4100,
206
211
  /** The auth token is expired, reauthorize to get a fresh one. In spirit akin to HTTP 401 */
207
212
  TOKEN_EXPIRED = 4109,
208
213
  /** Disconnect immediately */
@@ -237,6 +242,9 @@ declare type LostConnectionEvent = "lost" | "restored" | "failed";
237
242
  * any value (except null).
238
243
  */
239
244
  declare type BaseAuthResult = NonNullable<Json>;
245
+ declare class LiveblocksError extends Error {
246
+ code: number;
247
+ }
240
248
  declare type Delegates<T extends BaseAuthResult> = {
241
249
  authenticate: () => Promise<T>;
242
250
  createSocket: (authValue: T) => IWebSocketInstance;
@@ -1332,6 +1340,7 @@ declare type InternalOthersEvent<TPresence extends JsonObject, TUserMeta extends
1332
1340
  updates: Partial<TPresence>;
1333
1341
  } | {
1334
1342
  type: "reset";
1343
+ user?: never;
1335
1344
  };
1336
1345
  declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = Resolve<InternalOthersEvent<TPresence, TUserMeta> & {
1337
1346
  others: readonly User<TPresence, TUserMeta>[];
@@ -1540,7 +1549,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1540
1549
  * @returns Unsubscribe function.
1541
1550
  *
1542
1551
  */
1543
- (type: "error", listener: ErrorCallback): () => void;
1552
+ (type: "error", listener: Callback<LiveblocksError>): () => void;
1544
1553
  /**
1545
1554
  * @deprecated This API will be removed in a future version of Liveblocks.
1546
1555
  * Prefer using the newer `.subscribe('status')` API.
@@ -1655,11 +1664,8 @@ declare type GetThreadsOptions<TThreadMetadata extends BaseMetadata> = {
1655
1664
  };
1656
1665
  since?: Date;
1657
1666
  };
1658
- declare type CommentsApi<TThreadMetadata extends BaseMetadata = never> = {
1659
- /**
1660
- * @private
1661
- */
1662
- getThreads(options?: GetThreadsOptions<TThreadMetadata>): Promise<{
1667
+ declare type CommentsApi = {
1668
+ getThreads<TThreadMetadata extends BaseMetadata = never>(options?: GetThreadsOptions<TThreadMetadata>): Promise<{
1663
1669
  threads: ThreadData<TThreadMetadata>[];
1664
1670
  inboxNotifications: InboxNotificationData[];
1665
1671
  deletedThreads: ThreadDeleteInfo[];
@@ -1668,72 +1674,48 @@ declare type CommentsApi<TThreadMetadata extends BaseMetadata = never> = {
1668
1674
  requestedAt: Date;
1669
1675
  };
1670
1676
  }>;
1671
- /**
1672
- * @private
1673
- */
1674
- getThread(options: {
1677
+ getThread<TThreadMetadata extends BaseMetadata = never>(options: {
1675
1678
  threadId: string;
1676
1679
  }): Promise<{
1677
1680
  thread: ThreadData<TThreadMetadata>;
1678
1681
  inboxNotification?: InboxNotificationData;
1679
1682
  } | undefined>;
1680
- /**
1681
- * @private
1682
- */
1683
- createThread(options: {
1683
+ createThread<TThreadMetadata extends BaseMetadata = never>(options: {
1684
1684
  threadId: string;
1685
1685
  commentId: string;
1686
1686
  metadata: TThreadMetadata | undefined;
1687
1687
  body: CommentBody;
1688
1688
  }): Promise<ThreadData<TThreadMetadata>>;
1689
- /**
1690
- * @private
1691
- */
1692
- editThreadMetadata(options: {
1689
+ editThreadMetadata<TThreadMetadata extends BaseMetadata = never>(options: {
1693
1690
  metadata: PartialNullable<TThreadMetadata>;
1694
1691
  threadId: string;
1695
1692
  }): Promise<TThreadMetadata>;
1696
- /**
1697
- * @private
1698
- */
1699
1693
  createComment(options: {
1700
1694
  threadId: string;
1701
1695
  commentId: string;
1702
1696
  body: CommentBody;
1703
1697
  }): Promise<CommentData>;
1704
- /**
1705
- * @private
1706
- */
1707
1698
  editComment(options: {
1708
1699
  threadId: string;
1709
1700
  commentId: string;
1710
1701
  body: CommentBody;
1711
1702
  }): Promise<CommentData>;
1712
- /**
1713
- * @private
1714
- */
1715
1703
  deleteComment(options: {
1716
1704
  threadId: string;
1717
1705
  commentId: string;
1718
1706
  }): Promise<void>;
1719
- /**
1720
- * @private
1721
- */
1722
1707
  addReaction(options: {
1723
1708
  threadId: string;
1724
1709
  commentId: string;
1725
1710
  emoji: string;
1726
1711
  }): Promise<CommentUserReaction>;
1727
- /**
1728
- * @private
1729
- */
1730
1712
  removeReaction(options: {
1731
1713
  threadId: string;
1732
1714
  commentId: string;
1733
1715
  emoji: string;
1734
1716
  }): Promise<void>;
1735
1717
  };
1736
- declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = CommentsApi<any> & {
1718
+ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
1737
1719
  /**
1738
1720
  * @private
1739
1721
  *
@@ -1866,7 +1848,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1866
1848
  readonly self: Observable<User<TPresence, TUserMeta>>;
1867
1849
  readonly myPresence: Observable<TPresence>;
1868
1850
  readonly others: Observable<OthersEvent<TPresence, TUserMeta>>;
1869
- readonly error: Observable<Error>;
1851
+ readonly error: Observable<LiveblocksError>;
1870
1852
  readonly storage: Observable<StorageUpdate[]>;
1871
1853
  readonly history: Observable<HistoryEvent>;
1872
1854
  /**
@@ -1879,14 +1861,6 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1879
1861
  readonly ydoc: Observable<YDocUpdateServerMsg | UpdateYDocClientMsg>;
1880
1862
  readonly comments: Observable<CommentsEventServerMsg>;
1881
1863
  };
1882
- /**
1883
- * @private
1884
- */
1885
- getRoomNotificationSettings(): Promise<RoomNotificationSettings>;
1886
- /**
1887
- * @private
1888
- */
1889
- updateRoomNotificationSettings(settings: Partial<RoomNotificationSettings>): Promise<RoomNotificationSettings>;
1890
1864
  /**
1891
1865
  * Batches modifications made during the given function.
1892
1866
  * All the modifications are sent to other clients in a single message.
@@ -1952,8 +1926,11 @@ declare type PrivateRoomApi = {
1952
1926
  explicitClose(event: IWebSocketCloseEvent): void;
1953
1927
  rawSend(data: string): void;
1954
1928
  };
1955
- comments: {
1956
- lastRequestedAt: Date | null;
1929
+ comments: CommentsApi;
1930
+ notifications: {
1931
+ getRoomNotificationSettings(): Promise<RoomNotificationSettings>;
1932
+ updateRoomNotificationSettings(settings: Partial<RoomNotificationSettings>): Promise<RoomNotificationSettings>;
1933
+ markInboxNotificationAsRead(notificationId: string): Promise<void>;
1957
1934
  };
1958
1935
  };
1959
1936
  declare type HistoryOp<TPresence extends JsonObject> = Op | {
@@ -2036,20 +2013,17 @@ declare type EditThreadMetadataOptimisticUpdate<TThreadMetadata extends BaseMeta
2036
2013
  id: string;
2037
2014
  threadId: string;
2038
2015
  metadata: Resolve<PartialNullable<TThreadMetadata>>;
2016
+ updatedAt: Date;
2039
2017
  };
2040
2018
  declare type CreateCommentOptimisticUpdate = {
2041
2019
  type: "create-comment";
2042
2020
  id: string;
2043
2021
  comment: CommentData;
2044
- inboxNotificationId?: string;
2045
2022
  };
2046
2023
  declare type EditCommentOptimisticUpdate = {
2047
2024
  type: "edit-comment";
2048
2025
  id: string;
2049
- threadId: string;
2050
- editedAt: Date;
2051
- commentId: string;
2052
- body: CommentBody;
2026
+ comment: CommentData;
2053
2027
  };
2054
2028
  declare type DeleteCommentOptimisticUpdate = {
2055
2029
  type: "delete-comment";
@@ -2063,9 +2037,7 @@ declare type AddReactionOptimisticUpdate = {
2063
2037
  id: string;
2064
2038
  threadId: string;
2065
2039
  commentId: string;
2066
- emoji: string;
2067
- createdAt: Date;
2068
- userId: string;
2040
+ reaction: CommentUserReaction;
2069
2041
  };
2070
2042
  declare type RemoveReactionOptimisticUpdate = {
2071
2043
  type: "remove-reaction";
@@ -2074,6 +2046,7 @@ declare type RemoveReactionOptimisticUpdate = {
2074
2046
  commentId: string;
2075
2047
  emoji: string;
2076
2048
  userId: string;
2049
+ removedAt: Date;
2077
2050
  };
2078
2051
  declare type MarkInboxNotificationAsReadOptimisticUpdate = {
2079
2052
  type: "mark-inbox-notification-as-read";
@@ -2131,6 +2104,10 @@ interface CacheStore<TThreadMetadata extends BaseMetadata> extends Store<CacheSt
2131
2104
  setQueryState(queryKey: string, queryState: QueryState): void;
2132
2105
  }
2133
2106
  declare function applyOptimisticUpdates<TThreadMetadata extends BaseMetadata>(state: CacheState<TThreadMetadata>): Pick<CacheState<TThreadMetadata>, "threads" | "inboxNotifications" | "notificationSettings">;
2107
+ declare function upsertComment<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, comment: CommentData): ThreadDataWithDeleteInfo<TThreadMetadata>;
2108
+ declare function deleteComment<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, commentId: string, deletedAt: Date): ThreadDataWithDeleteInfo<TThreadMetadata>;
2109
+ declare function addReaction<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, commentId: string, reaction: CommentUserReaction): ThreadDataWithDeleteInfo<TThreadMetadata>;
2110
+ declare function removeReaction<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, commentId: string, emoji: string, userId: string, removedAt: Date): ThreadDataWithDeleteInfo<TThreadMetadata>;
2134
2111
 
2135
2112
  declare type OptionalPromise<T> = T | Promise<T>;
2136
2113
 
@@ -2186,6 +2163,7 @@ declare type EnterOptions<TPresence extends JsonObject, TStorage extends LsonObj
2186
2163
  * will probably happen if you do.
2187
2164
  */
2188
2165
  declare type PrivateClientApi<TUserMeta extends BaseUserMeta> = {
2166
+ notifications: NotificationsApi;
2189
2167
  currentUserIdStore: Store<string | null>;
2190
2168
  resolveMentionSuggestions: ClientOptions["resolveMentionSuggestions"];
2191
2169
  cacheStore: CacheStore<BaseMetadata>;
@@ -2193,10 +2171,7 @@ declare type PrivateClientApi<TUserMeta extends BaseUserMeta> = {
2193
2171
  roomsInfoStore: BatchStore<RoomInfo | undefined, [string]>;
2194
2172
  getRoomIds: () => string[];
2195
2173
  };
2196
- declare type InboxNotificationsApi<TThreadMetadata extends BaseMetadata = never> = {
2197
- /**
2198
- * @private
2199
- */
2174
+ declare type NotificationsApi<TThreadMetadata extends BaseMetadata = never> = {
2200
2175
  getInboxNotifications(options?: GetInboxNotificationsOptions): Promise<{
2201
2176
  inboxNotifications: InboxNotificationData[];
2202
2177
  threads: ThreadData<TThreadMetadata>[];
@@ -2206,20 +2181,11 @@ declare type InboxNotificationsApi<TThreadMetadata extends BaseMetadata = never>
2206
2181
  requestedAt: Date;
2207
2182
  };
2208
2183
  }>;
2209
- /**
2210
- * @private
2211
- */
2212
2184
  getUnreadInboxNotificationsCount(): Promise<number>;
2213
- /**
2214
- * @private
2215
- */
2216
2185
  markAllInboxNotificationsAsRead(): Promise<void>;
2217
- /**
2218
- * @private
2219
- */
2220
2186
  markInboxNotificationAsRead(inboxNotificationId: string): Promise<void>;
2221
2187
  };
2222
- declare type Client<TUserMeta extends BaseUserMeta = BaseUserMeta> = InboxNotificationsApi & {
2188
+ declare type Client<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2223
2189
  /**
2224
2190
  * Gets a room. Returns null if {@link Client.enter} has not been called previously.
2225
2191
  *
@@ -2812,4 +2778,4 @@ declare type EnsureJson<T> = [
2812
2778
  [K in keyof T]: EnsureJson<T[K]>;
2813
2779
  };
2814
2780
 
2815
- export { type AckOp, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type CacheState, type CacheStore, type Client, type ClientMsg, ClientMsgCode, 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 CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationThreadData, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, NotificationsApiError, type Op, OpCode, type OptionalPromise, type Others, type OthersEvent, type ParentToChildNodeMap, type PartialNullable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomInfo, type RoomInitializers, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, applyOptimisticUpdates, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToThreadData, createClient, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, withTimeout };
2781
+ export { type AckOp, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type CacheState, type CacheStore, type Client, type ClientMsg, ClientMsgCode, 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 CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationThreadData, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, NotificationsApiError, type Op, OpCode, type OptionalPromise, type Others, type OthersEvent, type ParentToChildNodeMap, type PartialNullable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomInfo, type RoomInitializers, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, addReaction, applyOptimisticUpdates, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToThreadData, createClient, deleteComment, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, raise, removeReaction, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, upsertComment, withTimeout };