@liveblocks/node 1.11.3 → 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
@@ -1,4 +1,4 @@
1
- import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, BaseMetadata, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings } from '@liveblocks/core';
1
+ import { IUserInfo, Json, PlainLsonObject, JsonObject, BaseMetadata, QueryMetadata, ThreadData, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData } from '@liveblocks/core';
2
2
  export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, Lson, LsonObject, PlainLsonObject, ResolveUsersArgs, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionedIdsFromCommentBody, stringifyCommentBody } from '@liveblocks/core';
3
3
  import { IncomingHttpHeaders } from 'http';
4
4
 
@@ -175,6 +175,7 @@ declare type RoomAccesses = Record<string, [
175
175
  "room:write"
176
176
  ] | ["room:read", "room:presence:write"]>;
177
177
  declare type RoomMetadata = Record<string, string | string[]>;
178
+ declare type QueryRoomMetadata = Record<string, string>;
178
179
  declare type RoomInfo = {
179
180
  type: "room";
180
181
  id: string;
@@ -266,14 +267,46 @@ declare class Liveblocks {
266
267
  * @param params.userId (optional) A filter on users accesses.
267
268
  * @param params.metadata (optional) A filter on metadata. Multiple metadata keys can be used to filter rooms.
268
269
  * @param params.groupIds (optional) A filter on groups accesses. Multiple groups can be used.
270
+ * @param params.query (optional) A query to filter rooms by. It is based on our query language. You can filter by metadata and room ID.
269
271
  * @returns A list of rooms.
270
272
  */
271
273
  getRooms(params?: {
272
274
  limit?: number;
273
275
  startingAfter?: string;
274
- metadata?: RoomMetadata;
276
+ /**
277
+ * @deprecated Use `query` instead.
278
+ */
279
+ metadata?: QueryRoomMetadata;
275
280
  userId?: string;
276
281
  groupIds?: string[];
282
+ /**
283
+ * The query to filter rooms by. It is based on our query language.
284
+ * @example
285
+ * ```
286
+ * {
287
+ * query: 'metadata["status"]:"open" AND roomId^"liveblocks:"'
288
+ * }
289
+ * ```
290
+ * @example
291
+ * ```
292
+ * {
293
+ * query: {
294
+ * metadata: {
295
+ * status: "open",
296
+ * },
297
+ * roomId: {
298
+ * startsWith: "liveblocks:"
299
+ * }
300
+ * }
301
+ * }
302
+ * ```
303
+ */
304
+ query?: string | {
305
+ metadata?: QueryRoomMetadata;
306
+ roomId?: {
307
+ startsWith: string;
308
+ };
309
+ };
277
310
  }): Promise<{
278
311
  nextPage: string | null;
279
312
  nextCursor: string | null;
@@ -456,10 +489,39 @@ declare class Liveblocks {
456
489
  * Gets all the threads in a room.
457
490
  *
458
491
  * @param params.roomId The room ID to get the threads from.
492
+ * @param params.query The query to filter threads by. It is based on our query language and can filter by metadata.
459
493
  * @returns A list of threads.
460
494
  */
461
- getThreads(params: {
495
+ getThreads<TThreadMetadata extends BaseMetadata>(params: {
462
496
  roomId: string;
497
+ /**
498
+ * The query to filter threads by. It is based on our query language.
499
+ *
500
+ * @example
501
+ * ```
502
+ * {
503
+ * query: "metadata['organization']^'liveblocks:' AND metadata['status']:'open' AND metadata['resolved']:false AND metadata['priority']:3"
504
+ * }
505
+ * ```
506
+ * @example
507
+ * ```
508
+ * {
509
+ * query: {
510
+ * metadata: {
511
+ * status: "open",
512
+ * resolved: false,
513
+ * priority: 3,
514
+ * organization: {
515
+ * startsWith: "liveblocks:"
516
+ * }
517
+ * }
518
+ * }
519
+ * }
520
+ * ```
521
+ */
522
+ query?: string | {
523
+ metadata?: Partial<QueryMetadata<TThreadMetadata>>;
524
+ };
463
525
  }): Promise<{
464
526
  data: ThreadData[];
465
527
  }>;
@@ -674,6 +736,13 @@ declare class Liveblocks {
674
736
  currentRoomId: string;
675
737
  newRoomId: string;
676
738
  }): Promise<RoomInfo>;
739
+ triggerInboxNotification(params: {
740
+ userId: string;
741
+ kind: `$${string}`;
742
+ roomId?: string;
743
+ subjectId: string;
744
+ activityData: ActivityData;
745
+ }): Promise<void>;
677
746
  }
678
747
  declare class LiveblocksError extends Error {
679
748
  status: number;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, BaseMetadata, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings } from '@liveblocks/core';
1
+ import { IUserInfo, Json, PlainLsonObject, JsonObject, BaseMetadata, QueryMetadata, ThreadData, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData } from '@liveblocks/core';
2
2
  export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, Lson, LsonObject, PlainLsonObject, ResolveUsersArgs, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionedIdsFromCommentBody, stringifyCommentBody } from '@liveblocks/core';
3
3
  import { IncomingHttpHeaders } from 'http';
4
4
 
@@ -175,6 +175,7 @@ declare type RoomAccesses = Record<string, [
175
175
  "room:write"
176
176
  ] | ["room:read", "room:presence:write"]>;
177
177
  declare type RoomMetadata = Record<string, string | string[]>;
178
+ declare type QueryRoomMetadata = Record<string, string>;
178
179
  declare type RoomInfo = {
179
180
  type: "room";
180
181
  id: string;
@@ -266,14 +267,46 @@ declare class Liveblocks {
266
267
  * @param params.userId (optional) A filter on users accesses.
267
268
  * @param params.metadata (optional) A filter on metadata. Multiple metadata keys can be used to filter rooms.
268
269
  * @param params.groupIds (optional) A filter on groups accesses. Multiple groups can be used.
270
+ * @param params.query (optional) A query to filter rooms by. It is based on our query language. You can filter by metadata and room ID.
269
271
  * @returns A list of rooms.
270
272
  */
271
273
  getRooms(params?: {
272
274
  limit?: number;
273
275
  startingAfter?: string;
274
- metadata?: RoomMetadata;
276
+ /**
277
+ * @deprecated Use `query` instead.
278
+ */
279
+ metadata?: QueryRoomMetadata;
275
280
  userId?: string;
276
281
  groupIds?: string[];
282
+ /**
283
+ * The query to filter rooms by. It is based on our query language.
284
+ * @example
285
+ * ```
286
+ * {
287
+ * query: 'metadata["status"]:"open" AND roomId^"liveblocks:"'
288
+ * }
289
+ * ```
290
+ * @example
291
+ * ```
292
+ * {
293
+ * query: {
294
+ * metadata: {
295
+ * status: "open",
296
+ * },
297
+ * roomId: {
298
+ * startsWith: "liveblocks:"
299
+ * }
300
+ * }
301
+ * }
302
+ * ```
303
+ */
304
+ query?: string | {
305
+ metadata?: QueryRoomMetadata;
306
+ roomId?: {
307
+ startsWith: string;
308
+ };
309
+ };
277
310
  }): Promise<{
278
311
  nextPage: string | null;
279
312
  nextCursor: string | null;
@@ -456,10 +489,39 @@ declare class Liveblocks {
456
489
  * Gets all the threads in a room.
457
490
  *
458
491
  * @param params.roomId The room ID to get the threads from.
492
+ * @param params.query The query to filter threads by. It is based on our query language and can filter by metadata.
459
493
  * @returns A list of threads.
460
494
  */
461
- getThreads(params: {
495
+ getThreads<TThreadMetadata extends BaseMetadata>(params: {
462
496
  roomId: string;
497
+ /**
498
+ * The query to filter threads by. It is based on our query language.
499
+ *
500
+ * @example
501
+ * ```
502
+ * {
503
+ * query: "metadata['organization']^'liveblocks:' AND metadata['status']:'open' AND metadata['resolved']:false AND metadata['priority']:3"
504
+ * }
505
+ * ```
506
+ * @example
507
+ * ```
508
+ * {
509
+ * query: {
510
+ * metadata: {
511
+ * status: "open",
512
+ * resolved: false,
513
+ * priority: 3,
514
+ * organization: {
515
+ * startsWith: "liveblocks:"
516
+ * }
517
+ * }
518
+ * }
519
+ * }
520
+ * ```
521
+ */
522
+ query?: string | {
523
+ metadata?: Partial<QueryMetadata<TThreadMetadata>>;
524
+ };
463
525
  }): Promise<{
464
526
  data: ThreadData[];
465
527
  }>;
@@ -674,6 +736,13 @@ declare class Liveblocks {
674
736
  currentRoomId: string;
675
737
  newRoomId: string;
676
738
  }): Promise<RoomInfo>;
739
+ triggerInboxNotification(params: {
740
+ userId: string;
741
+ kind: `$${string}`;
742
+ roomId?: string;
743
+ subjectId: string;
744
+ activityData: ActivityData;
745
+ }): Promise<void>;
677
746
  }
678
747
  declare class LiveblocksError extends Error {
679
748
  status: number;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var _core = require('@liveblocks/core');
3
3
 
4
4
  // src/version.ts
5
5
  var PKG_NAME = "@liveblocks/node";
6
- var PKG_VERSION = "1.11.3";
6
+ var PKG_VERSION = "1.12.0-test2";
7
7
  var PKG_FORMAT = "cjs";
8
8
 
9
9
  // src/utils.ts
@@ -115,6 +115,8 @@ function buildLiveblocksAuthorizeEndpoint(options, roomId) {
115
115
 
116
116
 
117
117
 
118
+
119
+
118
120
  // src/Session.ts
119
121
  var ALL_PERMISSIONS = Object.freeze([
120
122
  "room:write",
@@ -405,10 +407,17 @@ var Liveblocks = class {
405
407
  * @param params.userId (optional) A filter on users accesses.
406
408
  * @param params.metadata (optional) A filter on metadata. Multiple metadata keys can be used to filter rooms.
407
409
  * @param params.groupIds (optional) A filter on groups accesses. Multiple groups can be used.
410
+ * @param params.query (optional) A query to filter rooms by. It is based on our query language. You can filter by metadata and room ID.
408
411
  * @returns A list of rooms.
409
412
  */
410
413
  async getRooms(params = {}) {
411
414
  const path = url`/v2/rooms`;
415
+ let query;
416
+ if (typeof params.query === "string") {
417
+ query = params.query;
418
+ } else if (typeof params.query === "object") {
419
+ query = _core.objectToQuery.call(void 0, params.query);
420
+ }
412
421
  const queryParams = {
413
422
  limit: params.limit,
414
423
  startingAfter: params.startingAfter,
@@ -416,11 +425,12 @@ var Liveblocks = class {
416
425
  groupIds: params.groupIds ? params.groupIds.join(",") : void 0,
417
426
  // "Flatten" {metadata: {foo: "bar"}} to {"metadata.foo": "bar"}
418
427
  ...Object.fromEntries(
419
- Object.entries(_nullishCoalesce(params.metadata, () => ( {}))).map(([key, val]) => {
420
- const value = Array.isArray(val) ? val.join(",") : val;
421
- return [`metadata.${key}`, value];
422
- })
423
- )
428
+ Object.entries(_nullishCoalesce(params.metadata, () => ( {}))).map(([key, val]) => [
429
+ `metadata.${key}`,
430
+ val
431
+ ])
432
+ ),
433
+ query
424
434
  };
425
435
  const res = await this.get(path, queryParams);
426
436
  if (!res.ok) {
@@ -791,11 +801,20 @@ var Liveblocks = class {
791
801
  * Gets all the threads in a room.
792
802
  *
793
803
  * @param params.roomId The room ID to get the threads from.
804
+ * @param params.query The query to filter threads by. It is based on our query language and can filter by metadata.
794
805
  * @returns A list of threads.
795
806
  */
796
807
  async getThreads(params) {
797
808
  const { roomId } = params;
798
- const res = await this.get(url`/v2/rooms/${roomId}/threads`);
809
+ let query;
810
+ if (typeof params.query === "string") {
811
+ query = params.query;
812
+ } else if (typeof params.query === "object") {
813
+ query = _core.objectToQuery.call(void 0, params.query);
814
+ }
815
+ const res = await this.get(url`/v2/rooms/${roomId}/threads`, {
816
+ query
817
+ });
799
818
  if (!res.ok) {
800
819
  const text = await res.text();
801
820
  throw new LiveblocksError(res.status, text);
@@ -1042,12 +1061,9 @@ var Liveblocks = class {
1042
1061
  const text = await res.text();
1043
1062
  throw new LiveblocksError(res.status, text);
1044
1063
  }
1045
- const data = await res.json();
1046
- return {
1047
- ...data,
1048
- notifiedAt: new Date(data.notifiedAt),
1049
- readAt: data.readAt ? new Date(data.readAt) : null
1050
- };
1064
+ return _core.convertToInboxNotificationData.call(void 0,
1065
+ await res.json()
1066
+ );
1051
1067
  }
1052
1068
  /**
1053
1069
  * Gets the user's room notification settings.
@@ -1122,6 +1138,13 @@ var Liveblocks = class {
1122
1138
  lastConnectionAt: data.lastConnectionAt ? new Date(data.lastConnectionAt) : void 0
1123
1139
  };
1124
1140
  }
1141
+ async triggerInboxNotification(params) {
1142
+ const res = await this.post(url`/v2/inbox-notifications/trigger`, params);
1143
+ if (!res.ok) {
1144
+ const text = await res.text();
1145
+ throw new LiveblocksError(res.status, text);
1146
+ }
1147
+ }
1125
1148
  };
1126
1149
  var LiveblocksError = class extends Error {
1127
1150
  constructor(status, message = "") {