@liveblocks/core 3.12.1 → 3.13.0-metadata1

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
@@ -1144,7 +1144,7 @@ declare global {
1144
1144
  [key: string]: unknown;
1145
1145
  }
1146
1146
  }
1147
- type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "RoomInfo" | "GroupInfo" | "ActivitiesData";
1147
+ type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "CommentMetadata" | "RoomInfo" | "GroupInfo" | "ActivitiesData";
1148
1148
  type MakeErrorString<K extends ExtendableTypes, Reason extends string = "does not match its requirements"> = `The type you provided for '${K}' ${Reason}. To learn how to fix this, see https://liveblocks.io/docs/errors/${K}`;
1149
1149
  type GetOverride<K extends ExtendableTypes, B, Reason extends string = "does not match its requirements"> = GetOverrideOrErrorValue<K, B, MakeErrorString<K, Reason>>;
1150
1150
  type GetOverrideOrErrorValue<K extends ExtendableTypes, B, ErrorType> = unknown extends Liveblocks[K] ? B : Liveblocks[K] extends B ? Liveblocks[K] : ErrorType;
@@ -1152,7 +1152,8 @@ type DP = GetOverride<"Presence", JsonObject, "is not a valid JSON object">;
1152
1152
  type DS = GetOverride<"Storage", LsonObject, "is not a valid LSON value">;
1153
1153
  type DU = GetOverrideOrErrorValue<"UserMeta", BaseUserMeta, Record<"id" | "info", MakeErrorString<"UserMeta">>>;
1154
1154
  type DE = GetOverride<"RoomEvent", Json, "is not a valid JSON value">;
1155
- type DM = GetOverride<"ThreadMetadata", BaseMetadata>;
1155
+ type DTM = GetOverride<"ThreadMetadata", BaseMetadata>;
1156
+ type DCM = GetOverride<"CommentMetadata", BaseMetadata>;
1156
1157
  type DRI = GetOverride<"RoomInfo", BaseRoomInfo>;
1157
1158
  type DGI = GetOverride<"GroupInfo", BaseGroupInfo>;
1158
1159
  type DAD = GetOverrideOrErrorValue<"ActivitiesData", BaseActivitiesData, {
@@ -1217,7 +1218,7 @@ type CommentMixedAttachment = CommentAttachment | CommentLocalAttachment;
1217
1218
  /**
1218
1219
  * Represents a comment.
1219
1220
  */
1220
- type CommentData = {
1221
+ type CommentData<CM extends BaseMetadata = DCM> = {
1221
1222
  type: "comment";
1222
1223
  id: string;
1223
1224
  threadId: string;
@@ -1227,13 +1228,15 @@ type CommentData = {
1227
1228
  editedAt?: Date;
1228
1229
  reactions: CommentReaction[];
1229
1230
  attachments: CommentAttachment[];
1231
+ metadata: CM;
1230
1232
  } & Relax<{
1231
1233
  body: CommentBody;
1232
1234
  } | {
1233
1235
  deletedAt: Date;
1234
1236
  }>;
1235
- type CommentDataPlain = Omit<DateToString<CommentData>, "reactions" | "body"> & {
1237
+ type CommentDataPlain<CM extends BaseMetadata = DCM> = Omit<DateToString<CommentData<CM>>, "reactions" | "body" | "metadata"> & {
1236
1238
  reactions: DateToString<CommentReaction>[];
1239
+ metadata: CM;
1237
1240
  } & Relax<{
1238
1241
  body: CommentBody;
1239
1242
  } | {
@@ -1288,22 +1291,22 @@ type SearchCommentsResult = {
1288
1291
  /**
1289
1292
  * Represents a thread of comments.
1290
1293
  */
1291
- type ThreadData<M extends BaseMetadata = DM> = {
1294
+ type ThreadData<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> = {
1292
1295
  type: "thread";
1293
1296
  id: string;
1294
1297
  roomId: string;
1295
1298
  createdAt: Date;
1296
1299
  updatedAt: Date;
1297
- comments: CommentData[];
1298
- metadata: M;
1300
+ comments: CommentData<CM>[];
1301
+ metadata: TM;
1299
1302
  resolved: boolean;
1300
1303
  };
1301
- interface ThreadDataWithDeleteInfo<M extends BaseMetadata = DM> extends ThreadData<M> {
1304
+ interface ThreadDataWithDeleteInfo<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> extends ThreadData<TM, CM> {
1302
1305
  deletedAt?: Date;
1303
1306
  }
1304
- type ThreadDataPlain<M extends BaseMetadata> = Omit<DateToString<ThreadData<M>>, "comments" | "metadata"> & {
1305
- comments: CommentDataPlain[];
1306
- metadata: M;
1307
+ type ThreadDataPlain<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> = Omit<DateToString<ThreadData<TM, CM>>, "comments" | "metadata"> & {
1308
+ comments: CommentDataPlain<CM>[];
1309
+ metadata: TM;
1307
1310
  };
1308
1311
  type ThreadDeleteInfo = {
1309
1312
  type: "deletedThread";
@@ -1541,17 +1544,17 @@ type MakeOptionalFieldsNullable<T> = {
1541
1544
  };
1542
1545
  type Patchable<T> = Partial<MakeOptionalFieldsNullable<T>>;
1543
1546
 
1544
- interface RoomHttpApi<M extends BaseMetadata> {
1547
+ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
1545
1548
  getThreads(options: {
1546
1549
  roomId: string;
1547
1550
  cursor?: string;
1548
1551
  query?: {
1549
1552
  resolved?: boolean;
1550
1553
  subscribed?: boolean;
1551
- metadata?: Partial<QueryMetadata<M>>;
1554
+ metadata?: Partial<QueryMetadata<TM>>;
1552
1555
  };
1553
1556
  }): Promise<{
1554
- threads: ThreadData<M>[];
1557
+ threads: ThreadData<TM, CM>[];
1555
1558
  inboxNotifications: InboxNotificationData[];
1556
1559
  subscriptions: SubscriptionData[];
1557
1560
  requestedAt: Date;
@@ -1564,7 +1567,7 @@ interface RoomHttpApi<M extends BaseMetadata> {
1564
1567
  signal?: AbortSignal;
1565
1568
  }): Promise<{
1566
1569
  threads: {
1567
- updated: ThreadData<M>[];
1570
+ updated: ThreadData<TM, CM>[];
1568
1571
  deleted: ThreadDeleteInfo[];
1569
1572
  };
1570
1573
  inboxNotifications: {
@@ -1581,7 +1584,7 @@ interface RoomHttpApi<M extends BaseMetadata> {
1581
1584
  searchComments(options: {
1582
1585
  roomId: string;
1583
1586
  query: {
1584
- threadMetadata?: Partial<QueryMetadata<M>>;
1587
+ threadMetadata?: Partial<QueryMetadata<TM>>;
1585
1588
  threadResolved?: boolean;
1586
1589
  hasAttachments?: boolean;
1587
1590
  hasMentions?: boolean;
@@ -1592,19 +1595,20 @@ interface RoomHttpApi<M extends BaseMetadata> {
1592
1595
  }): Promise<{
1593
1596
  data: Array<SearchCommentsResult>;
1594
1597
  }>;
1595
- createThread({ roomId, metadata, body, commentId, threadId, attachmentIds, }: {
1598
+ createThread({ roomId, metadata, body, commentId, threadId, commentMetadata, attachmentIds, }: {
1596
1599
  roomId: string;
1597
1600
  threadId?: string;
1598
1601
  commentId?: string;
1599
- metadata: M | undefined;
1602
+ metadata: TM | undefined;
1603
+ commentMetadata: CM | undefined;
1600
1604
  body: CommentBody;
1601
1605
  attachmentIds?: string[];
1602
- }): Promise<ThreadData<M>>;
1606
+ }): Promise<ThreadData<TM, CM>>;
1603
1607
  getThread(options: {
1604
1608
  roomId: string;
1605
1609
  threadId: string;
1606
1610
  }): Promise<{
1607
- thread?: ThreadData<M>;
1611
+ thread?: ThreadData<TM, CM>;
1608
1612
  inboxNotification?: InboxNotificationData;
1609
1613
  subscription?: SubscriptionData;
1610
1614
  }>;
@@ -1614,23 +1618,31 @@ interface RoomHttpApi<M extends BaseMetadata> {
1614
1618
  }): Promise<void>;
1615
1619
  editThreadMetadata({ roomId, metadata, threadId, }: {
1616
1620
  roomId: string;
1617
- metadata: Patchable<M>;
1621
+ metadata: Patchable<TM>;
1618
1622
  threadId: string;
1619
- }): Promise<M>;
1620
- createComment({ roomId, threadId, commentId, body, attachmentIds, }: {
1623
+ }): Promise<TM>;
1624
+ editCommentMetadata({ roomId, threadId, commentId, metadata, }: {
1625
+ roomId: string;
1626
+ threadId: string;
1627
+ commentId: string;
1628
+ metadata: Patchable<CM>;
1629
+ }): Promise<CM>;
1630
+ createComment({ roomId, threadId, commentId, body, metadata, attachmentIds, }: {
1621
1631
  roomId: string;
1622
1632
  threadId: string;
1623
1633
  commentId?: string;
1624
1634
  body: CommentBody;
1635
+ metadata?: CM;
1625
1636
  attachmentIds?: string[];
1626
- }): Promise<CommentData>;
1627
- editComment({ roomId, threadId, commentId, body, attachmentIds, }: {
1637
+ }): Promise<CommentData<CM>>;
1638
+ editComment({ roomId, threadId, commentId, body, attachmentIds, metadata, }: {
1628
1639
  roomId: string;
1629
1640
  threadId: string;
1630
1641
  commentId: string;
1631
1642
  body: CommentBody;
1632
1643
  attachmentIds?: string[];
1633
- }): Promise<CommentData>;
1644
+ metadata?: Patchable<CM>;
1645
+ }): Promise<CommentData<CM>>;
1634
1646
  deleteComment({ roomId, threadId, commentId, }: {
1635
1647
  roomId: string;
1636
1648
  threadId: string;
@@ -1768,7 +1780,7 @@ interface RoomHttpApi<M extends BaseMetadata> {
1768
1780
  signal: AbortSignal;
1769
1781
  }): Promise<string>;
1770
1782
  }
1771
- interface NotificationHttpApi<M extends BaseMetadata> {
1783
+ interface NotificationHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
1772
1784
  getInboxNotifications(options?: {
1773
1785
  cursor?: string;
1774
1786
  query?: {
@@ -1777,7 +1789,7 @@ interface NotificationHttpApi<M extends BaseMetadata> {
1777
1789
  };
1778
1790
  }): Promise<{
1779
1791
  inboxNotifications: InboxNotificationData[];
1780
- threads: ThreadData<M>[];
1792
+ threads: ThreadData<TM, CM>[];
1781
1793
  subscriptions: SubscriptionData[];
1782
1794
  nextCursor: string | null;
1783
1795
  requestedAt: Date;
@@ -1795,7 +1807,7 @@ interface NotificationHttpApi<M extends BaseMetadata> {
1795
1807
  deleted: InboxNotificationDeleteInfo[];
1796
1808
  };
1797
1809
  threads: {
1798
- updated: ThreadData<M>[];
1810
+ updated: ThreadData<TM, CM>[];
1799
1811
  deleted: ThreadDeleteInfo[];
1800
1812
  };
1801
1813
  subscriptions: {
@@ -1820,16 +1832,16 @@ interface NotificationHttpApi<M extends BaseMetadata> {
1820
1832
  }): Promise<NotificationSettingsPlain>;
1821
1833
  updateNotificationSettings(settings: PartialNotificationSettings): Promise<NotificationSettingsPlain>;
1822
1834
  }
1823
- interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, NotificationHttpApi<M> {
1835
+ interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> extends RoomHttpApi<TM, CM>, NotificationHttpApi<TM, CM> {
1824
1836
  getUrlMetadata(url: string): Promise<UrlMetadata>;
1825
1837
  getUserThreads_experimental(options?: {
1826
1838
  cursor?: string;
1827
1839
  query?: {
1828
1840
  resolved?: boolean;
1829
- metadata?: Partial<QueryMetadata<M>>;
1841
+ metadata?: Partial<QueryMetadata<TM>>;
1830
1842
  };
1831
1843
  }): Promise<{
1832
- threads: ThreadData<M>[];
1844
+ threads: ThreadData<TM, CM>[];
1833
1845
  inboxNotifications: InboxNotificationData[];
1834
1846
  subscriptions: SubscriptionData[];
1835
1847
  nextCursor: string | null;
@@ -1845,7 +1857,7 @@ interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, Noti
1845
1857
  deleted: InboxNotificationDeleteInfo[];
1846
1858
  };
1847
1859
  threads: {
1848
- updated: ThreadData<M>[];
1860
+ updated: ThreadData<TM, CM>[];
1849
1861
  deleted: ThreadDeleteInfo[];
1850
1862
  };
1851
1863
  subscriptions: {
@@ -1905,6 +1917,7 @@ type CommentsOrNotificationsErrorContext = {
1905
1917
  commentId: string;
1906
1918
  body: CommentBody;
1907
1919
  metadata: BaseMetadata;
1920
+ commentMetadata: BaseMetadata;
1908
1921
  } | {
1909
1922
  type: "DELETE_THREAD_ERROR";
1910
1923
  roomId: string;
@@ -1914,6 +1927,12 @@ type CommentsOrNotificationsErrorContext = {
1914
1927
  roomId: string;
1915
1928
  threadId: string;
1916
1929
  metadata: Patchable<BaseMetadata>;
1930
+ } | {
1931
+ type: "EDIT_COMMENT_METADATA_ERROR";
1932
+ roomId: string;
1933
+ threadId: string;
1934
+ commentId: string;
1935
+ metadata: Patchable<BaseMetadata>;
1917
1936
  } | {
1918
1937
  type: "MARK_THREAD_AS_RESOLVED_ERROR" | "MARK_THREAD_AS_UNRESOLVED_ERROR" | "SUBSCRIBE_TO_THREAD_ERROR" | "UNSUBSCRIBE_FROM_THREAD_ERROR";
1919
1938
  roomId: string;
@@ -1924,6 +1943,7 @@ type CommentsOrNotificationsErrorContext = {
1924
1943
  threadId: string;
1925
1944
  commentId: string;
1926
1945
  body: CommentBody;
1946
+ metadata: BaseMetadata;
1927
1947
  } | {
1928
1948
  type: "DELETE_COMMENT_ERROR";
1929
1949
  roomId: string;
@@ -2028,7 +2048,7 @@ type InternalSyncStatus = SyncStatus | "has-local-changes";
2028
2048
  * of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
2029
2049
  * will probably happen if you do.
2030
2050
  */
2031
- type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
2051
+ type PrivateClientApi<U extends BaseUserMeta, TM extends BaseMetadata, CM extends BaseMetadata> = {
2032
2052
  readonly currentUserId: Signal<string | undefined>;
2033
2053
  readonly mentionSuggestionsCache: Map<string, MentionData[]>;
2034
2054
  readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
@@ -2036,13 +2056,13 @@ type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
2036
2056
  readonly roomsInfoStore: BatchStore<DRI | undefined, string>;
2037
2057
  readonly groupsInfoStore: BatchStore<DGI | undefined, string>;
2038
2058
  readonly getRoomIds: () => string[];
2039
- readonly httpClient: LiveblocksHttpApi<M>;
2040
- as<M2 extends BaseMetadata>(): Client<U, M2>;
2059
+ readonly httpClient: LiveblocksHttpApi<TM, CM>;
2060
+ as<TM2 extends BaseMetadata, CM2 extends BaseMetadata>(): Client<U, TM2, CM2>;
2041
2061
  createSyncSource(): SyncSource;
2042
2062
  emitError(context: LiveblocksErrorContext, cause?: Error): void;
2043
2063
  ai: Ai;
2044
2064
  };
2045
- type NotificationsApi<M extends BaseMetadata> = {
2065
+ type NotificationsApi<TM extends BaseMetadata, CM extends BaseMetadata> = {
2046
2066
  /**
2047
2067
  * Gets a page (or the initial page) for user inbox notifications and their
2048
2068
  * associated threads and thread subscriptions.
@@ -2069,7 +2089,7 @@ type NotificationsApi<M extends BaseMetadata> = {
2069
2089
  };
2070
2090
  }): Promise<{
2071
2091
  inboxNotifications: InboxNotificationData[];
2072
- threads: ThreadData<M>[];
2092
+ threads: ThreadData<TM, CM>[];
2073
2093
  subscriptions: SubscriptionData[];
2074
2094
  nextCursor: string | null;
2075
2095
  requestedAt: Date;
@@ -2110,7 +2130,7 @@ type NotificationsApi<M extends BaseMetadata> = {
2110
2130
  deleted: InboxNotificationDeleteInfo[];
2111
2131
  };
2112
2132
  threads: {
2113
- updated: ThreadData<M>[];
2133
+ updated: ThreadData<TM, CM>[];
2114
2134
  deleted: ThreadDeleteInfo[];
2115
2135
  };
2116
2136
  subscriptions: {
@@ -2190,23 +2210,23 @@ type NotificationsApi<M extends BaseMetadata> = {
2190
2210
  * narrower.
2191
2211
  */
2192
2212
  type OpaqueClient = Client<BaseUserMeta>;
2193
- type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> = {
2213
+ type Client<U extends BaseUserMeta = DU, TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> = {
2194
2214
  /**
2195
2215
  * Gets a room. Returns null if {@link Client.enter} has not been called previously.
2196
2216
  *
2197
2217
  * @param roomId The id of the room
2198
2218
  */
2199
- getRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, M2 extends BaseMetadata = M>(roomId: string): Room<P, S, U, E, M2> | null;
2219
+ getRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, TM2 extends BaseMetadata = TM, CM2 extends BaseMetadata = CM>(roomId: string): Room<P, S, U, E, TM2, CM2> | null;
2200
2220
  /**
2201
2221
  * Enter a room.
2202
2222
  * @param roomId The id of the room
2203
2223
  * @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
2204
2224
  * @returns The room and a leave function. Call the returned leave() function when you no longer need the room.
2205
2225
  */
2206
- enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, M2 extends BaseMetadata = M>(roomId: string, ...args: OptionalTupleUnless<P & S, [
2226
+ enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, TM2 extends BaseMetadata = TM, CM2 extends BaseMetadata = CM>(roomId: string, ...args: OptionalTupleUnless<P & S, [
2207
2227
  options: EnterOptions<NoInfr<P>, NoInfr<S>>
2208
2228
  ]>): {
2209
- room: Room<P, S, U, E, M2>;
2229
+ room: Room<P, S, U, E, TM2, CM2>;
2210
2230
  leave: () => void;
2211
2231
  };
2212
2232
  /**
@@ -2272,7 +2292,7 @@ type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> = {
2272
2292
  * of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
2273
2293
  * will probably happen if you do.
2274
2294
  */
2275
- readonly [kInternal]: PrivateClientApi<U, M>;
2295
+ readonly [kInternal]: PrivateClientApi<U, TM, CM>;
2276
2296
  /**
2277
2297
  * Returns the current global sync status of the Liveblocks client. If any
2278
2298
  * part of Liveblocks has any local pending changes that haven't been
@@ -2296,7 +2316,7 @@ type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> = {
2296
2316
  readonly error: Observable<LiveblocksError>;
2297
2317
  readonly syncStatus: Observable<void>;
2298
2318
  };
2299
- } & NotificationsApi<M>;
2319
+ } & NotificationsApi<TM, CM>;
2300
2320
  type AuthEndpoint = string | ((room?: string) => Promise<CustomAuthenticationResult>);
2301
2321
  /**
2302
2322
  * The authentication endpoint that is called to ensure that the current user has access to a room.
@@ -2502,6 +2522,7 @@ declare const ServerMsgCode: Readonly<{
2502
2522
  COMMENT_DELETED: 404;
2503
2523
  COMMENT_REACTION_ADDED: 405;
2504
2524
  COMMENT_REACTION_REMOVED: 406;
2525
+ COMMENT_METADATA_UPDATED: 409;
2505
2526
  REJECT_STORAGE_OP: 299;
2506
2527
  }>;
2507
2528
  declare namespace ServerMsgCode {
@@ -2522,13 +2543,14 @@ declare namespace ServerMsgCode {
2522
2543
  type COMMENT_DELETED = typeof ServerMsgCode.COMMENT_DELETED;
2523
2544
  type COMMENT_REACTION_ADDED = typeof ServerMsgCode.COMMENT_REACTION_ADDED;
2524
2545
  type COMMENT_REACTION_REMOVED = typeof ServerMsgCode.COMMENT_REACTION_REMOVED;
2546
+ type COMMENT_METADATA_UPDATED = typeof ServerMsgCode.COMMENT_METADATA_UPDATED;
2525
2547
  type REJECT_STORAGE_OP = typeof ServerMsgCode.REJECT_STORAGE_OP;
2526
2548
  }
2527
2549
  /**
2528
2550
  * Messages that can be sent from the server to the client.
2529
2551
  */
2530
2552
  type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | YDocUpdateServerMsg | RejectedStorageOpServerMsg | CommentsEventServerMsg;
2531
- type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
2553
+ type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | CommentMetadataUpdatedEvent;
2532
2554
  type ThreadCreatedEvent = {
2533
2555
  type: ServerMsgCode.THREAD_CREATED;
2534
2556
  threadId: string;
@@ -2572,6 +2594,11 @@ type CommentReactionRemoved = {
2572
2594
  commentId: string;
2573
2595
  emoji: string;
2574
2596
  };
2597
+ type CommentMetadataUpdatedEvent = {
2598
+ type: ServerMsgCode.COMMENT_METADATA_UPDATED;
2599
+ threadId: string;
2600
+ commentId: string;
2601
+ };
2575
2602
  /**
2576
2603
  * Sent by the WebSocket server and broadcasted to all clients to announce that
2577
2604
  * a User updated their presence. For example, when a user moves their cursor.
@@ -3053,12 +3080,12 @@ type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U extends B
3053
3080
  (type: "storage-status", listener: Callback<StorageStatus>): () => void;
3054
3081
  (type: "comments", listener: Callback<CommentsEventServerMsg>): () => void;
3055
3082
  };
3056
- type GetThreadsOptions<M extends BaseMetadata> = {
3083
+ type GetThreadsOptions<TM extends BaseMetadata> = {
3057
3084
  cursor?: string;
3058
3085
  query?: {
3059
3086
  resolved?: boolean;
3060
3087
  subscribed?: boolean;
3061
- metadata?: Partial<QueryMetadata<M>>;
3088
+ metadata?: Partial<QueryMetadata<TM>>;
3062
3089
  };
3063
3090
  };
3064
3091
  type GetThreadsSinceOptions = {
@@ -3081,7 +3108,7 @@ type GetSubscriptionSettingsOptions = {
3081
3108
  * a Room instance using globally augmented types only, which is narrower.
3082
3109
  */
3083
3110
  type OpaqueRoom = Room<JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata>;
3084
- type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE, M extends BaseMetadata = DM> = {
3111
+ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE, TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> = {
3085
3112
  /**
3086
3113
  * @private
3087
3114
  *
@@ -3295,8 +3322,8 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
3295
3322
  * requestedAt
3296
3323
  * } = await room.getThreads({ query: { resolved: false }});
3297
3324
  */
3298
- getThreads(options?: GetThreadsOptions<M>): Promise<{
3299
- threads: ThreadData<M>[];
3325
+ getThreads(options?: GetThreadsOptions<TM>): Promise<{
3326
+ threads: ThreadData<TM, CM>[];
3300
3327
  inboxNotifications: InboxNotificationData[];
3301
3328
  subscriptions: SubscriptionData[];
3302
3329
  requestedAt: Date;
@@ -3313,7 +3340,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
3313
3340
  */
3314
3341
  getThreadsSince(options: GetThreadsSinceOptions): Promise<{
3315
3342
  threads: {
3316
- updated: ThreadData<M>[];
3343
+ updated: ThreadData<TM, CM>[];
3317
3344
  deleted: ThreadDeleteInfo[];
3318
3345
  };
3319
3346
  inboxNotifications: {
@@ -3334,7 +3361,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
3334
3361
  * const { thread, inboxNotification, subscription } = await room.getThread("th_xxx");
3335
3362
  */
3336
3363
  getThread(threadId: string): Promise<{
3337
- thread?: ThreadData<M>;
3364
+ thread?: ThreadData<TM, CM>;
3338
3365
  inboxNotification?: InboxNotificationData;
3339
3366
  subscription?: SubscriptionData;
3340
3367
  }>;
@@ -3352,10 +3379,11 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
3352
3379
  createThread(options: {
3353
3380
  threadId?: string;
3354
3381
  commentId?: string;
3355
- metadata: M | undefined;
3382
+ metadata: TM | undefined;
3356
3383
  body: CommentBody;
3384
+ commentMetadata?: CM;
3357
3385
  attachmentIds?: string[];
3358
- }): Promise<ThreadData<M>>;
3386
+ }): Promise<ThreadData<TM, CM>>;
3359
3387
  /**
3360
3388
  * Deletes a thread.
3361
3389
  *
@@ -3371,9 +3399,21 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
3371
3399
  * await room.editThreadMetadata({ threadId: "th_xxx", metadata: { x: 100, y: 100 } })
3372
3400
  */
3373
3401
  editThreadMetadata(options: {
3374
- metadata: Patchable<M>;
3402
+ metadata: Patchable<TM>;
3375
3403
  threadId: string;
3376
- }): Promise<M>;
3404
+ }): Promise<TM>;
3405
+ /**
3406
+ * Edits a comment's metadata.
3407
+ * To delete an existing metadata property, set its value to `null`.
3408
+ *
3409
+ * @example
3410
+ * await room.editCommentMetadata({ threadId: "th_xxx", commentId: "cm_xxx", metadata: { slackChannelId: "C024BE91L", slackMessageTs: "1700311782.001200" } })
3411
+ */
3412
+ editCommentMetadata(options: {
3413
+ threadId: string;
3414
+ commentId: string;
3415
+ metadata: Patchable<CM>;
3416
+ }): Promise<CM>;
3377
3417
  /**
3378
3418
  * Marks a thread as resolved.
3379
3419
  *
@@ -3418,8 +3458,9 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
3418
3458
  threadId: string;
3419
3459
  commentId?: string;
3420
3460
  body: CommentBody;
3461
+ metadata?: CM;
3421
3462
  attachmentIds?: string[];
3422
- }): Promise<CommentData>;
3463
+ }): Promise<CommentData<CM>>;
3423
3464
  /**
3424
3465
  * Edits a comment.
3425
3466
  *
@@ -3437,8 +3478,9 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
3437
3478
  threadId: string;
3438
3479
  commentId: string;
3439
3480
  body: CommentBody;
3481
+ metadata?: Patchable<CM>;
3440
3482
  attachmentIds?: string[];
3441
- }): Promise<CommentData>;
3483
+ }): Promise<CommentData<CM>>;
3442
3484
  /**
3443
3485
  * Deletes a comment.
3444
3486
  * If it is the last non-deleted comment, the thread also gets deleted.
@@ -4457,14 +4499,14 @@ declare const MENTION_CHARACTER = "@";
4457
4499
  * @param data The plain comment data object (usually returned by the API)
4458
4500
  * @returns The rich comment data object that can be used by the client.
4459
4501
  */
4460
- declare function convertToCommentData(data: CommentDataPlain): CommentData;
4502
+ declare function convertToCommentData<CM extends BaseMetadata>(data: CommentDataPlain<CM>): CommentData<CM>;
4461
4503
  /**
4462
4504
  * Converts a plain thread data object (usually returned by the API) to a thread data object that can be used by the client.
4463
4505
  * This is necessary because the plain data object stores dates as ISO strings, but the client expects them as Date objects.
4464
4506
  * @param data The plain thread data object (usually returned by the API)
4465
4507
  * @returns The rich thread data object that can be used by the client.
4466
4508
  */
4467
- declare function convertToThreadData<M extends BaseMetadata>(data: ThreadDataPlain<M>): ThreadData<M>;
4509
+ declare function convertToThreadData<TM extends BaseMetadata, CM extends BaseMetadata>(data: ThreadDataPlain<TM, CM>): ThreadData<TM, CM>;
4468
4510
  /**
4469
4511
  * Converts a plain comment reaction object (usually returned by the API) to a comment reaction object that can be used by the client.
4470
4512
  * This is necessary because the plain data object stores dates as ISO strings, but the client expects them as Date objects.
@@ -5180,4 +5222,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
5180
5222
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
5181
5223
  };
5182
5224
 
5183
- export { type AckOpV7, type AckOpV8, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, 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, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DE, type DGI, 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 GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type History, type HistoryVersion, HttpError, type ISODateString, 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 InferFromSchema, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, type LayerKey, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, 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 RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SearchCommentsResult, 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 ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isNumberOperator, isPlainObject, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
5225
+ export { type AckOpV7, type AckOpV8, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, 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, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, 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 GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type History, type HistoryVersion, HttpError, type ISODateString, 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 InferFromSchema, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, type LayerKey, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, 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 RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SearchCommentsResult, 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 ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isNumberOperator, isPlainObject, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };