@liveblocks/node 3.15.0-feeds1 → 3.15.0-rc1

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.cjs 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 = "3.15.0-feeds1";
6
+ var PKG_VERSION = "3.15.0-rc1";
7
7
  var PKG_FORMAT = "cjs";
8
8
 
9
9
  // src/client.ts
@@ -165,9 +165,7 @@ var ALL_PERMISSIONS = Object.freeze([
165
165
  "room:read",
166
166
  "room:presence:write",
167
167
  "comments:write",
168
- "comments:read",
169
- "feeds:write",
170
- "feeds:read"
168
+ "comments:read"
171
169
  ]);
172
170
  function isPermission(value) {
173
171
  return ALL_PERMISSIONS.includes(value);
@@ -176,14 +174,9 @@ var MAX_PERMS_PER_SET = 10;
176
174
  var READ_ACCESS = Object.freeze([
177
175
  "room:read",
178
176
  "room:presence:write",
179
- "comments:read",
180
- "feeds:read"
181
- ]);
182
- var FULL_ACCESS = Object.freeze([
183
- "room:write",
184
- "comments:write",
185
- "feeds:write"
177
+ "comments:read"
186
178
  ]);
179
+ var FULL_ACCESS = Object.freeze(["room:write", "comments:write"]);
187
180
  var roomPatternRegex = /^([*]|[^*]{1,128}[*]?)$/;
188
181
  var Session = (_class = class {
189
182
  __init() {this.FULL_ACCESS = FULL_ACCESS}
@@ -367,22 +360,6 @@ var Liveblocks = class {
367
360
  xwarn(res, "POST", path);
368
361
  return res;
369
362
  }
370
- async #patch(path, json, options) {
371
- const url3 = _core.urljoin.call(void 0, this.#baseUrl, path);
372
- const headers = {
373
- Authorization: `Bearer ${this.#secret}`,
374
- "Content-Type": "application/json"
375
- };
376
- const fetch = await fetchPolyfill();
377
- const res = await fetch(url3, {
378
- method: "PATCH",
379
- headers,
380
- body: JSON.stringify(json),
381
- signal: _optionalChain([options, 'optionalAccess', _2 => _2.signal])
382
- });
383
- xwarn(res, "PATCH", path);
384
- return res;
385
- }
386
363
  async #putBinary(path, body, params, options) {
387
364
  const url3 = _core.urljoin.call(void 0, this.#baseUrl, path, params);
388
365
  const headers = {
@@ -394,7 +371,7 @@ var Liveblocks = class {
394
371
  method: "PUT",
395
372
  headers,
396
373
  body,
397
- signal: _optionalChain([options, 'optionalAccess', _3 => _3.signal])
374
+ signal: _optionalChain([options, 'optionalAccess', _2 => _2.signal])
398
375
  });
399
376
  xwarn(res, "PUT", path);
400
377
  return res;
@@ -408,7 +385,7 @@ var Liveblocks = class {
408
385
  const res = await fetch(url3, {
409
386
  method: "DELETE",
410
387
  headers,
411
- signal: _optionalChain([options, 'optionalAccess', _4 => _4.signal])
388
+ signal: _optionalChain([options, 'optionalAccess', _3 => _3.signal])
412
389
  });
413
390
  xwarn(res, "DELETE", path);
414
391
  return res;
@@ -422,7 +399,7 @@ var Liveblocks = class {
422
399
  const res = await fetch(url3, {
423
400
  method: "GET",
424
401
  headers,
425
- signal: _optionalChain([options, 'optionalAccess', _5 => _5.signal])
402
+ signal: _optionalChain([options, 'optionalAccess', _4 => _4.signal])
426
403
  });
427
404
  xwarn(res, "GET", path);
428
405
  return res;
@@ -453,8 +430,8 @@ var Liveblocks = class {
453
430
  return new Session(
454
431
  this.#post.bind(this),
455
432
  userId,
456
- _optionalChain([options, 'optionalAccess', _6 => _6.userInfo]),
457
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.organizationId]), () => ( _optionalChain([options, 'optionalAccess', _8 => _8.tenantId]))),
433
+ _optionalChain([options, 'optionalAccess', _5 => _5.userInfo]),
434
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.organizationId]), () => ( _optionalChain([options, 'optionalAccess', _7 => _7.tenantId]))),
458
435
  this.#localDev
459
436
  );
460
437
  }
@@ -504,7 +481,7 @@ var Liveblocks = class {
504
481
  const body = {
505
482
  userId,
506
483
  groupIds,
507
- userInfo: _optionalChain([options, 'optionalAccess', _9 => _9.userInfo])
484
+ userInfo: _optionalChain([options, 'optionalAccess', _8 => _8.userInfo])
508
485
  };
509
486
  if (organizationId !== void 0) {
510
487
  body.organizationId = organizationId;
@@ -590,7 +567,7 @@ var Liveblocks = class {
590
567
  */
591
568
  async *iterRooms(criteria, options) {
592
569
  const { signal } = _nullishCoalesce(options, () => ( {}));
593
- const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _10 => _10.pageSize]), () => ( 40)), 20);
570
+ const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.pageSize]), () => ( 40)), 20);
594
571
  let cursor = void 0;
595
572
  while (true) {
596
573
  const { nextCursor, data } = await this.getRooms(
@@ -641,7 +618,7 @@ var Liveblocks = class {
641
618
  body.organizationId = tenantId;
642
619
  }
643
620
  const res = await this.#post(
644
- _optionalChain([options, 'optionalAccess', _11 => _11.idempotent]) ? _core.url`/v2/rooms?idempotent` : _core.url`/v2/rooms`,
621
+ _optionalChain([options, 'optionalAccess', _10 => _10.idempotent]) ? _core.url`/v2/rooms?idempotent` : _core.url`/v2/rooms`,
645
622
  body,
646
623
  options
647
624
  );
@@ -1097,7 +1074,7 @@ var Liveblocks = class {
1097
1074
  _core.url`/v2/rooms/${roomId}/threads/${threadId}/comments`,
1098
1075
  {
1099
1076
  ...data,
1100
- createdAt: _optionalChain([data, 'access', _12 => _12.createdAt, 'optionalAccess', _13 => _13.toISOString, 'call', _14 => _14()])
1077
+ createdAt: _optionalChain([data, 'access', _11 => _11.createdAt, 'optionalAccess', _12 => _12.toISOString, 'call', _13 => _13()])
1101
1078
  },
1102
1079
  options
1103
1080
  );
@@ -1123,7 +1100,7 @@ var Liveblocks = class {
1123
1100
  _core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
1124
1101
  {
1125
1102
  body: data.body,
1126
- editedAt: _optionalChain([data, 'access', _15 => _15.editedAt, 'optionalAccess', _16 => _16.toISOString, 'call', _17 => _17()]),
1103
+ editedAt: _optionalChain([data, 'access', _14 => _14.editedAt, 'optionalAccess', _15 => _15.toISOString, 'call', _16 => _16()]),
1127
1104
  metadata: data.metadata
1128
1105
  },
1129
1106
  options
@@ -1171,7 +1148,7 @@ var Liveblocks = class {
1171
1148
  ...data,
1172
1149
  comment: {
1173
1150
  ...data.comment,
1174
- createdAt: _optionalChain([data, 'access', _18 => _18.comment, 'access', _19 => _19.createdAt, 'optionalAccess', _20 => _20.toISOString, 'call', _21 => _21()])
1151
+ createdAt: _optionalChain([data, 'access', _17 => _17.comment, 'access', _18 => _18.createdAt, 'optionalAccess', _19 => _19.toISOString, 'call', _20 => _20()])
1175
1152
  }
1176
1153
  },
1177
1154
  options
@@ -1294,7 +1271,7 @@ var Liveblocks = class {
1294
1271
  _core.url`/v2/rooms/${roomId}/threads/${threadId}/metadata`,
1295
1272
  {
1296
1273
  ...data,
1297
- updatedAt: _optionalChain([data, 'access', _22 => _22.updatedAt, 'optionalAccess', _23 => _23.toISOString, 'call', _24 => _24()])
1274
+ updatedAt: _optionalChain([data, 'access', _21 => _21.updatedAt, 'optionalAccess', _22 => _22.toISOString, 'call', _23 => _23()])
1298
1275
  },
1299
1276
  options
1300
1277
  );
@@ -1320,7 +1297,7 @@ var Liveblocks = class {
1320
1297
  _core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/metadata`,
1321
1298
  {
1322
1299
  ...data,
1323
- updatedAt: _optionalChain([data, 'access', _25 => _25.updatedAt, 'optionalAccess', _26 => _26.toISOString, 'call', _27 => _27()])
1300
+ updatedAt: _optionalChain([data, 'access', _24 => _24.updatedAt, 'optionalAccess', _25 => _25.toISOString, 'call', _26 => _26()])
1324
1301
  },
1325
1302
  options
1326
1303
  );
@@ -1346,7 +1323,7 @@ var Liveblocks = class {
1346
1323
  _core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/add-reaction`,
1347
1324
  {
1348
1325
  ...data,
1349
- createdAt: _optionalChain([data, 'access', _28 => _28.createdAt, 'optionalAccess', _29 => _29.toISOString, 'call', _30 => _30()])
1326
+ createdAt: _optionalChain([data, 'access', _27 => _27.createdAt, 'optionalAccess', _28 => _28.toISOString, 'call', _29 => _29()])
1350
1327
  },
1351
1328
  options
1352
1329
  );
@@ -1372,7 +1349,7 @@ var Liveblocks = class {
1372
1349
  _core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${params.commentId}/remove-reaction`,
1373
1350
  {
1374
1351
  ...data,
1375
- removedAt: _optionalChain([data, 'access', _31 => _31.removedAt, 'optionalAccess', _32 => _32.toISOString, 'call', _33 => _33()])
1352
+ removedAt: _optionalChain([data, 'access', _30 => _30.removedAt, 'optionalAccess', _31 => _31.toISOString, 'call', _32 => _32()])
1376
1353
  },
1377
1354
  options
1378
1355
  );
@@ -1453,7 +1430,7 @@ var Liveblocks = class {
1453
1430
  */
1454
1431
  async *iterInboxNotifications(criteria, options) {
1455
1432
  const { signal } = _nullishCoalesce(options, () => ( {}));
1456
- const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.pageSize]), () => ( 50)), 10);
1433
+ const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _33 => _33.pageSize]), () => ( 50)), 10);
1457
1434
  let cursor = void 0;
1458
1435
  while (true) {
1459
1436
  const { nextCursor, data } = await this.getInboxNotifications(
@@ -1800,7 +1777,7 @@ var Liveblocks = class {
1800
1777
  async getGroups(params, options) {
1801
1778
  const res = await this.#get(
1802
1779
  _core.url`/v2/groups`,
1803
- { startingAfter: _optionalChain([params, 'optionalAccess', _35 => _35.startingAfter]), limit: _optionalChain([params, 'optionalAccess', _36 => _36.limit]) },
1780
+ { startingAfter: _optionalChain([params, 'optionalAccess', _34 => _34.startingAfter]), limit: _optionalChain([params, 'optionalAccess', _35 => _35.limit]) },
1804
1781
  options
1805
1782
  );
1806
1783
  if (!res.ok) {
@@ -1862,7 +1839,7 @@ var Liveblocks = class {
1862
1839
  async massMutateStorage(criteria, callback, massOptions) {
1863
1840
  const concurrency = _core.checkBounds.call(void 0,
1864
1841
  "concurrency",
1865
- _nullishCoalesce(_optionalChain([massOptions, 'optionalAccess', _37 => _37.concurrency]), () => ( 8)),
1842
+ _nullishCoalesce(_optionalChain([massOptions, 'optionalAccess', _36 => _36.concurrency]), () => ( 8)),
1866
1843
  1,
1867
1844
  20
1868
1845
  );
@@ -1878,7 +1855,7 @@ var Liveblocks = class {
1878
1855
  }
1879
1856
  async #_mutateOneRoom(roomId, room, callback, options) {
1880
1857
  const debounceInterval = 200;
1881
- const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess', _38 => _38.signal]));
1858
+ const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess', _37 => _37.signal]));
1882
1859
  let opsBuffer = [];
1883
1860
  let outstandingFlush$ = void 0;
1884
1861
  let lastFlush = performance.now();
@@ -1944,7 +1921,7 @@ var Liveblocks = class {
1944
1921
  const res = await this.#post(
1945
1922
  _core.url`/v2/rooms/${roomId}/send-message`,
1946
1923
  { messages },
1947
- { signal: _optionalChain([options, 'optionalAccess', _39 => _39.signal]) }
1924
+ { signal: _optionalChain([options, 'optionalAccess', _38 => _38.signal]) }
1948
1925
  );
1949
1926
  if (!res.ok) {
1950
1927
  throw await LiveblocksError.from(res);
@@ -2081,7 +2058,7 @@ var Liveblocks = class {
2081
2058
  "Content-Type": params.file.type,
2082
2059
  "Content-Length": String(params.file.size)
2083
2060
  },
2084
- signal: _optionalChain([options, 'optionalAccess', _40 => _40.signal])
2061
+ signal: _optionalChain([options, 'optionalAccess', _39 => _39.signal])
2085
2062
  }
2086
2063
  );
2087
2064
  if (!res.ok) {
@@ -2213,180 +2190,6 @@ var Liveblocks = class {
2213
2190
  data: page.data.map(inflateWebKnowledgeSourceLink)
2214
2191
  };
2215
2192
  }
2216
- /* -------------------------------------------------------------------------------------------------
2217
- * Feeds
2218
- * -----------------------------------------------------------------------------------------------*/
2219
- /**
2220
- * Returns a list of feeds in a room.
2221
- * @param params.roomId The room ID to get the feeds from.
2222
- * @param options.signal (optional) An abort signal to cancel the request.
2223
- * @returns A list of feeds.
2224
- */
2225
- async getFeeds(params, options) {
2226
- const { roomId } = params;
2227
- const res = await this.#get(
2228
- _core.url`/v2/rooms/${roomId}/feeds`,
2229
- void 0,
2230
- options
2231
- );
2232
- if (!res.ok) {
2233
- throw await LiveblocksError.from(res);
2234
- }
2235
- return await res.json();
2236
- }
2237
- /**
2238
- * Creates a new feed in a room.
2239
- * @param params.roomId The room ID to create the feed in.
2240
- * @param params.feedId The feed ID.
2241
- * @param params.metadata (optional) The metadata for the feed.
2242
- * @param params.timestamp (optional) The timestamp for the feed. If not provided, the current time will be used.
2243
- * @param options.signal (optional) An abort signal to cancel the request.
2244
- * @returns The created feed.
2245
- */
2246
- async createFeed(params, options) {
2247
- const { roomId, feedId, metadata, timestamp } = params;
2248
- const res = await this.#post(
2249
- _core.url`/v2/rooms/${roomId}/feed`,
2250
- { feedId, metadata, timestamp },
2251
- options
2252
- );
2253
- if (!res.ok) {
2254
- throw await LiveblocksError.from(res);
2255
- }
2256
- return (await res.json()).data;
2257
- }
2258
- /**
2259
- * Returns a feed with the given id.
2260
- * @param params.roomId The room ID to get the feed from.
2261
- * @param params.feedId The feed ID.
2262
- * @param options.signal (optional) An abort signal to cancel the request.
2263
- * @returns The feed.
2264
- */
2265
- async getFeed(params, options) {
2266
- const { roomId, feedId } = params;
2267
- const res = await this.#get(
2268
- _core.url`/v2/rooms/${roomId}/feeds/${feedId}`,
2269
- void 0,
2270
- options
2271
- );
2272
- if (!res.ok) {
2273
- throw await LiveblocksError.from(res);
2274
- }
2275
- return (await res.json()).data;
2276
- }
2277
- /**
2278
- * Updates the metadata of a feed.
2279
- * @param params.roomId The room ID to update the feed in.
2280
- * @param params.feedId The feed ID to update.
2281
- * @param params.metadata The metadata for the feed.
2282
- * @param options.signal (optional) An abort signal to cancel the request.
2283
- */
2284
- async updateFeed(params, options) {
2285
- const { roomId, feedId, metadata } = params;
2286
- const res = await this.#patch(
2287
- _core.url`/v2/rooms/${roomId}/feeds/${feedId}`,
2288
- { metadata },
2289
- options
2290
- );
2291
- if (!res.ok) {
2292
- throw await LiveblocksError.from(res);
2293
- }
2294
- }
2295
- /**
2296
- * Deletes a feed.
2297
- * @param params.roomId The room ID to delete the feed from.
2298
- * @param params.feedId The feed ID to delete.
2299
- * @param options.signal (optional) An abort signal to cancel the request.
2300
- */
2301
- async deleteFeed(params, options) {
2302
- const { roomId, feedId } = params;
2303
- const res = await this.#delete(
2304
- _core.url`/v2/rooms/${roomId}/feeds/${feedId}`,
2305
- void 0,
2306
- options
2307
- );
2308
- if (!res.ok) {
2309
- throw await LiveblocksError.from(res);
2310
- }
2311
- }
2312
- /**
2313
- * Returns a list of messages in a feed.
2314
- * @param params.roomId The room ID to get the feed messages from.
2315
- * @param params.feedId The feed ID to get the messages from.
2316
- * @param options.signal (optional) An abort signal to cancel the request.
2317
- * @returns A list of feed messages.
2318
- */
2319
- async getFeedMessages(params, options) {
2320
- const { roomId, feedId } = params;
2321
- const res = await this.#get(
2322
- _core.url`/v2/rooms/${roomId}/feeds/${feedId}/messages`,
2323
- void 0,
2324
- options
2325
- );
2326
- if (!res.ok) {
2327
- throw await LiveblocksError.from(res);
2328
- }
2329
- return await res.json();
2330
- }
2331
- /**
2332
- * Creates a new message in a feed.
2333
- * @param params.roomId The room ID to create the feed message in.
2334
- * @param params.feedId The feed ID to create the message in.
2335
- * @param params.id (optional) The message ID. If not provided, one will be generated.
2336
- * @param params.timestamp (optional) The message timestamp. If not provided, the current time will be used.
2337
- * @param params.data The message data.
2338
- * @param options.signal (optional) An abort signal to cancel the request.
2339
- * @returns The created feed message.
2340
- */
2341
- async createFeedMessage(params, options) {
2342
- const { roomId, feedId, id, timestamp, data } = params;
2343
- const res = await this.#post(
2344
- _core.url`/v2/rooms/${roomId}/feeds/${feedId}/messages`,
2345
- { id, timestamp, data },
2346
- options
2347
- );
2348
- if (!res.ok) {
2349
- throw await LiveblocksError.from(res);
2350
- }
2351
- return (await res.json()).data;
2352
- }
2353
- /**
2354
- * Updates a feed message.
2355
- * @param params.roomId The room ID to update the feed message in.
2356
- * @param params.feedId The feed ID to update the message in.
2357
- * @param params.messageId The message ID to update.
2358
- * @param params.data The message data.
2359
- * @param options.signal (optional) An abort signal to cancel the request.
2360
- */
2361
- async updateFeedMessage(params, options) {
2362
- const { roomId, feedId, messageId, data } = params;
2363
- const res = await this.#patch(
2364
- _core.url`/v2/rooms/${roomId}/feeds/${feedId}/messages/${messageId}`,
2365
- { data },
2366
- options
2367
- );
2368
- if (!res.ok) {
2369
- throw await LiveblocksError.from(res);
2370
- }
2371
- }
2372
- /**
2373
- * Deletes a feed message.
2374
- * @param params.roomId The room ID to delete the feed message from.
2375
- * @param params.feedId The feed ID to delete the message from.
2376
- * @param params.messageId The message ID to delete.
2377
- * @param options.signal (optional) An abort signal to cancel the request.
2378
- */
2379
- async deleteFeedMessage(params, options) {
2380
- const { roomId, feedId, messageId } = params;
2381
- const res = await this.#delete(
2382
- _core.url`/v2/rooms/${roomId}/feeds/${feedId}/messages/${messageId}`,
2383
- void 0,
2384
- options
2385
- );
2386
- if (!res.ok) {
2387
- throw await LiveblocksError.from(res);
2388
- }
2389
- }
2390
2193
  };
2391
2194
  var LiveblocksError = class _LiveblocksError extends Error {
2392
2195