@liveblocks/node 1.12.0-test1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.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;
@@ -887,6 +956,11 @@ declare type YDocUpdatedEvent = {
887
956
  data: {
888
957
  projectId: string;
889
958
  roomId: string;
959
+ /**
960
+ * ISO 8601 datestring
961
+ * @example "2021-03-01T12:00:00.000Z"
962
+ */
963
+ updatedAt: string;
890
964
  };
891
965
  };
892
966
  declare type ThreadMetadataUpdatedEvent = {
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;
@@ -887,6 +956,11 @@ declare type YDocUpdatedEvent = {
887
956
  data: {
888
957
  projectId: string;
889
958
  roomId: string;
959
+ /**
960
+ * ISO 8601 datestring
961
+ * @example "2021-03-01T12:00:00.000Z"
962
+ */
963
+ updatedAt: string;
890
964
  };
891
965
  };
892
966
  declare type ThreadMetadataUpdatedEvent = {
package/dist/index.js CHANGED
@@ -3,13 +3,12 @@ var _core = require('@liveblocks/core');
3
3
 
4
4
  // src/version.ts
5
5
  var PKG_NAME = "@liveblocks/node";
6
- var PKG_VERSION = "1.12.0-test1";
6
+ var PKG_VERSION = "1.12.0";
7
7
  var PKG_FORMAT = "cjs";
8
8
 
9
9
  // src/utils.ts
10
10
  var DEFAULT_BASE_URL = "https://api.liveblocks.io";
11
11
  function getBaseUrl(baseUrl) {
12
- baseUrl || (baseUrl = process.env.LIVEBLOCKS_BASE_URL || process.env.NEXT_PUBLIC_LIVEBLOCKS_BASE_URL || process.env.VITE_LIVEBLOCKS_BASE_URL || void 0);
13
12
  if (typeof baseUrl === "string" && baseUrl.startsWith("http")) {
14
13
  return baseUrl;
15
14
  } else {
@@ -117,6 +116,7 @@ function buildLiveblocksAuthorizeEndpoint(options, roomId) {
117
116
 
118
117
 
119
118
 
119
+
120
120
  // src/Session.ts
121
121
  var ALL_PERMISSIONS = Object.freeze([
122
122
  "room:write",
@@ -407,10 +407,17 @@ var Liveblocks = class {
407
407
  * @param params.userId (optional) A filter on users accesses.
408
408
  * @param params.metadata (optional) A filter on metadata. Multiple metadata keys can be used to filter rooms.
409
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.
410
411
  * @returns A list of rooms.
411
412
  */
412
413
  async getRooms(params = {}) {
413
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
+ }
414
421
  const queryParams = {
415
422
  limit: params.limit,
416
423
  startingAfter: params.startingAfter,
@@ -418,11 +425,12 @@ var Liveblocks = class {
418
425
  groupIds: params.groupIds ? params.groupIds.join(",") : void 0,
419
426
  // "Flatten" {metadata: {foo: "bar"}} to {"metadata.foo": "bar"}
420
427
  ...Object.fromEntries(
421
- Object.entries(_nullishCoalesce(params.metadata, () => ( {}))).map(([key, val]) => {
422
- const value = Array.isArray(val) ? val.join(",") : val;
423
- return [`metadata.${key}`, value];
424
- })
425
- )
428
+ Object.entries(_nullishCoalesce(params.metadata, () => ( {}))).map(([key, val]) => [
429
+ `metadata.${key}`,
430
+ val
431
+ ])
432
+ ),
433
+ query
426
434
  };
427
435
  const res = await this.get(path, queryParams);
428
436
  if (!res.ok) {
@@ -793,11 +801,20 @@ var Liveblocks = class {
793
801
  * Gets all the threads in a room.
794
802
  *
795
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.
796
805
  * @returns A list of threads.
797
806
  */
798
807
  async getThreads(params) {
799
808
  const { roomId } = params;
800
- 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
+ });
801
818
  if (!res.ok) {
802
819
  const text = await res.text();
803
820
  throw new LiveblocksError(res.status, text);
@@ -1121,6 +1138,13 @@ var Liveblocks = class {
1121
1138
  lastConnectionAt: data.lastConnectionAt ? new Date(data.lastConnectionAt) : void 0
1122
1139
  };
1123
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
+ }
1124
1148
  };
1125
1149
  var LiveblocksError = class extends Error {
1126
1150
  constructor(status, message = "") {