@liveblocks/core 1.12.0-test1 → 1.12.0-test2

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
@@ -1287,8 +1287,8 @@ declare type InboxNotificationActivity = {
1287
1287
  declare type InboxNotificationCustomData = {
1288
1288
  kind: `$${string}`;
1289
1289
  id: string;
1290
- roomId: string;
1291
- subjectId?: string;
1290
+ roomId?: string;
1291
+ subjectId: string;
1292
1292
  notifiedAt: Date;
1293
1293
  readAt: Date | null;
1294
1294
  activities: InboxNotificationActivity[];
@@ -1371,6 +1371,21 @@ declare type PartialNullable<T> = {
1371
1371
  [P in keyof T]?: T[P] | null;
1372
1372
  };
1373
1373
 
1374
+ declare type QueryMetadataStringValue<T extends string> = T | {
1375
+ startsWith: string;
1376
+ };
1377
+ /**
1378
+ * This type can be used to build a metadata query string (compatible
1379
+ * with `@liveblocks/query-parser`) through a type-safe API.
1380
+ *
1381
+ * In addition to exact values (`:` in query string), it adds:
1382
+ * - to strings:
1383
+ * - `startsWith` (`^` in query string)
1384
+ */
1385
+ declare type QueryMetadata<T extends BaseMetadata> = {
1386
+ [K in keyof T]: T[K] extends string ? QueryMetadataStringValue<T[K]> : T[K];
1387
+ };
1388
+
1374
1389
  declare type RoomThreadsNotificationSettings = "all" | "replies_and_mentions" | "none";
1375
1390
  declare type RoomNotificationSettings = {
1376
1391
  threads: RoomThreadsNotificationSettings;
@@ -1681,7 +1696,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1681
1696
  };
1682
1697
  declare type GetThreadsOptions<TThreadMetadata extends BaseMetadata> = {
1683
1698
  query?: {
1684
- metadata?: Partial<TThreadMetadata>;
1699
+ metadata?: Partial<QueryMetadata<TThreadMetadata>>;
1685
1700
  };
1686
1701
  since?: Date;
1687
1702
  };
@@ -2559,6 +2574,39 @@ declare namespace fancyConsole {
2559
2574
  */
2560
2575
  declare const freeze: typeof Object.freeze;
2561
2576
 
2577
+ /**
2578
+ * Converts an object to a query string
2579
+ * Example:
2580
+ * ```ts
2581
+ * const query = objectToQuery({
2582
+ resolved: true,
2583
+ metadata: {
2584
+ status: "open",
2585
+ priority: 3,
2586
+ org: {
2587
+ startsWith: "liveblocks:",
2588
+ },
2589
+ },
2590
+ });
2591
+
2592
+ console.log(query);
2593
+ // resolved:true AND metadata["status"]:open AND metadata["priority"]:3 AND metadata["org"]^"liveblocks:"
2594
+
2595
+ * ```
2596
+ *
2597
+ *
2598
+ */
2599
+ declare type SimpleFilterValue = string | number | boolean;
2600
+ declare type OperatorFilterValue = {
2601
+ startsWith: string;
2602
+ };
2603
+ declare type FilterValue = SimpleFilterValue | OperatorFilterValue;
2604
+ declare function objectToQuery(obj: {
2605
+ [key: string]: FilterValue | {
2606
+ [key: string]: FilterValue | undefined;
2607
+ } | undefined;
2608
+ }): string;
2609
+
2562
2610
  declare type Poller = {
2563
2611
  start(interval: number): void;
2564
2612
  restart(interval: number): void;
@@ -2806,4 +2854,4 @@ declare type EnsureJson<T> = [
2806
2854
  [K in keyof T]: EnsureJson<T[K]>;
2807
2855
  };
2808
2856
 
2809
- 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 ClientOptions, 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 InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, 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, convertToInboxNotificationData, 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 };
2857
+ export { type AckOp, type ActivityData, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type CacheState, type CacheStore, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, 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 InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, 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 QueryMetadata, 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, convertToInboxNotificationData, convertToThreadData, createClient, deleteComment, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, objectToQuery, patchLiveObjectKey, raise, removeReaction, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, upsertComment, withTimeout };
package/dist/index.d.ts CHANGED
@@ -1287,8 +1287,8 @@ declare type InboxNotificationActivity = {
1287
1287
  declare type InboxNotificationCustomData = {
1288
1288
  kind: `$${string}`;
1289
1289
  id: string;
1290
- roomId: string;
1291
- subjectId?: string;
1290
+ roomId?: string;
1291
+ subjectId: string;
1292
1292
  notifiedAt: Date;
1293
1293
  readAt: Date | null;
1294
1294
  activities: InboxNotificationActivity[];
@@ -1371,6 +1371,21 @@ declare type PartialNullable<T> = {
1371
1371
  [P in keyof T]?: T[P] | null;
1372
1372
  };
1373
1373
 
1374
+ declare type QueryMetadataStringValue<T extends string> = T | {
1375
+ startsWith: string;
1376
+ };
1377
+ /**
1378
+ * This type can be used to build a metadata query string (compatible
1379
+ * with `@liveblocks/query-parser`) through a type-safe API.
1380
+ *
1381
+ * In addition to exact values (`:` in query string), it adds:
1382
+ * - to strings:
1383
+ * - `startsWith` (`^` in query string)
1384
+ */
1385
+ declare type QueryMetadata<T extends BaseMetadata> = {
1386
+ [K in keyof T]: T[K] extends string ? QueryMetadataStringValue<T[K]> : T[K];
1387
+ };
1388
+
1374
1389
  declare type RoomThreadsNotificationSettings = "all" | "replies_and_mentions" | "none";
1375
1390
  declare type RoomNotificationSettings = {
1376
1391
  threads: RoomThreadsNotificationSettings;
@@ -1681,7 +1696,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1681
1696
  };
1682
1697
  declare type GetThreadsOptions<TThreadMetadata extends BaseMetadata> = {
1683
1698
  query?: {
1684
- metadata?: Partial<TThreadMetadata>;
1699
+ metadata?: Partial<QueryMetadata<TThreadMetadata>>;
1685
1700
  };
1686
1701
  since?: Date;
1687
1702
  };
@@ -2559,6 +2574,39 @@ declare namespace fancyConsole {
2559
2574
  */
2560
2575
  declare const freeze: typeof Object.freeze;
2561
2576
 
2577
+ /**
2578
+ * Converts an object to a query string
2579
+ * Example:
2580
+ * ```ts
2581
+ * const query = objectToQuery({
2582
+ resolved: true,
2583
+ metadata: {
2584
+ status: "open",
2585
+ priority: 3,
2586
+ org: {
2587
+ startsWith: "liveblocks:",
2588
+ },
2589
+ },
2590
+ });
2591
+
2592
+ console.log(query);
2593
+ // resolved:true AND metadata["status"]:open AND metadata["priority"]:3 AND metadata["org"]^"liveblocks:"
2594
+
2595
+ * ```
2596
+ *
2597
+ *
2598
+ */
2599
+ declare type SimpleFilterValue = string | number | boolean;
2600
+ declare type OperatorFilterValue = {
2601
+ startsWith: string;
2602
+ };
2603
+ declare type FilterValue = SimpleFilterValue | OperatorFilterValue;
2604
+ declare function objectToQuery(obj: {
2605
+ [key: string]: FilterValue | {
2606
+ [key: string]: FilterValue | undefined;
2607
+ } | undefined;
2608
+ }): string;
2609
+
2562
2610
  declare type Poller = {
2563
2611
  start(interval: number): void;
2564
2612
  restart(interval: number): void;
@@ -2806,4 +2854,4 @@ declare type EnsureJson<T> = [
2806
2854
  [K in keyof T]: EnsureJson<T[K]>;
2807
2855
  };
2808
2856
 
2809
- 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 ClientOptions, 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 InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, 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, convertToInboxNotificationData, 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 };
2857
+ export { type AckOp, type ActivityData, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type CacheState, type CacheStore, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, 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 InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, 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 QueryMetadata, 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, convertToInboxNotificationData, convertToThreadData, createClient, deleteComment, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, objectToQuery, patchLiveObjectKey, raise, removeReaction, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, upsertComment, withTimeout };