@liveblocks/node 3.16.0-flow2 → 3.16.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.cjs +233 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +134 -4
- package/dist/index.d.ts +134 -4
- package/dist/index.js +212 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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.16.0
|
|
6
|
+
var PKG_VERSION = "3.16.0";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -165,7 +165,8 @@ var ALL_PERMISSIONS = Object.freeze([
|
|
|
165
165
|
"room:read",
|
|
166
166
|
"room:presence:write",
|
|
167
167
|
"comments:write",
|
|
168
|
-
"comments:read"
|
|
168
|
+
"comments:read",
|
|
169
|
+
"feeds:write"
|
|
169
170
|
]);
|
|
170
171
|
function isPermission(value) {
|
|
171
172
|
return ALL_PERMISSIONS.includes(value);
|
|
@@ -174,9 +175,11 @@ var MAX_PERMS_PER_SET = 10;
|
|
|
174
175
|
var READ_ACCESS = Object.freeze([
|
|
175
176
|
"room:read",
|
|
176
177
|
"room:presence:write",
|
|
178
|
+
// TODO: Remove once backend no longer requires this
|
|
177
179
|
"comments:read"
|
|
180
|
+
// TODO: Remove — implied by room:read
|
|
178
181
|
]);
|
|
179
|
-
var FULL_ACCESS = Object.freeze(["room:write"
|
|
182
|
+
var FULL_ACCESS = Object.freeze(["room:write"]);
|
|
180
183
|
var roomPatternRegex = /^([*]|[^*]{1,128}[*]?)$/;
|
|
181
184
|
var Session = (_class = class {
|
|
182
185
|
__init() {this.FULL_ACCESS = FULL_ACCESS}
|
|
@@ -360,6 +363,22 @@ var Liveblocks = class {
|
|
|
360
363
|
xwarn(res, "POST", path);
|
|
361
364
|
return res;
|
|
362
365
|
}
|
|
366
|
+
async #patch(path, json, options) {
|
|
367
|
+
const url3 = _core.urljoin.call(void 0, this.#baseUrl, path);
|
|
368
|
+
const headers = {
|
|
369
|
+
Authorization: `Bearer ${this.#secret}`,
|
|
370
|
+
"Content-Type": "application/json"
|
|
371
|
+
};
|
|
372
|
+
const fetch = await fetchPolyfill();
|
|
373
|
+
const res = await fetch(url3, {
|
|
374
|
+
method: "PATCH",
|
|
375
|
+
headers,
|
|
376
|
+
body: JSON.stringify(json),
|
|
377
|
+
signal: _optionalChain([options, 'optionalAccess', _2 => _2.signal])
|
|
378
|
+
});
|
|
379
|
+
xwarn(res, "PATCH", path);
|
|
380
|
+
return res;
|
|
381
|
+
}
|
|
363
382
|
async #putBinary(path, body, params, options) {
|
|
364
383
|
const url3 = _core.urljoin.call(void 0, this.#baseUrl, path, params);
|
|
365
384
|
const headers = {
|
|
@@ -371,7 +390,7 @@ var Liveblocks = class {
|
|
|
371
390
|
method: "PUT",
|
|
372
391
|
headers,
|
|
373
392
|
body,
|
|
374
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
393
|
+
signal: _optionalChain([options, 'optionalAccess', _3 => _3.signal])
|
|
375
394
|
});
|
|
376
395
|
xwarn(res, "PUT", path);
|
|
377
396
|
return res;
|
|
@@ -385,7 +404,7 @@ var Liveblocks = class {
|
|
|
385
404
|
const res = await fetch(url3, {
|
|
386
405
|
method: "DELETE",
|
|
387
406
|
headers,
|
|
388
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
407
|
+
signal: _optionalChain([options, 'optionalAccess', _4 => _4.signal])
|
|
389
408
|
});
|
|
390
409
|
xwarn(res, "DELETE", path);
|
|
391
410
|
return res;
|
|
@@ -399,7 +418,7 @@ var Liveblocks = class {
|
|
|
399
418
|
const res = await fetch(url3, {
|
|
400
419
|
method: "GET",
|
|
401
420
|
headers,
|
|
402
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
421
|
+
signal: _optionalChain([options, 'optionalAccess', _5 => _5.signal])
|
|
403
422
|
});
|
|
404
423
|
xwarn(res, "GET", path);
|
|
405
424
|
return res;
|
|
@@ -430,8 +449,8 @@ var Liveblocks = class {
|
|
|
430
449
|
return new Session(
|
|
431
450
|
this.#post.bind(this),
|
|
432
451
|
userId,
|
|
433
|
-
_optionalChain([options, 'optionalAccess',
|
|
434
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
452
|
+
_optionalChain([options, 'optionalAccess', _6 => _6.userInfo]),
|
|
453
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.organizationId]), () => ( _optionalChain([options, 'optionalAccess', _8 => _8.tenantId]))),
|
|
435
454
|
this.#localDev
|
|
436
455
|
);
|
|
437
456
|
}
|
|
@@ -481,7 +500,7 @@ var Liveblocks = class {
|
|
|
481
500
|
const body = {
|
|
482
501
|
userId,
|
|
483
502
|
groupIds,
|
|
484
|
-
userInfo: _optionalChain([options, 'optionalAccess',
|
|
503
|
+
userInfo: _optionalChain([options, 'optionalAccess', _9 => _9.userInfo])
|
|
485
504
|
};
|
|
486
505
|
if (organizationId !== void 0) {
|
|
487
506
|
body.organizationId = organizationId;
|
|
@@ -567,7 +586,7 @@ var Liveblocks = class {
|
|
|
567
586
|
*/
|
|
568
587
|
async *iterRooms(criteria, options) {
|
|
569
588
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
570
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
589
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _10 => _10.pageSize]), () => ( 40)), 20);
|
|
571
590
|
let cursor = void 0;
|
|
572
591
|
while (true) {
|
|
573
592
|
const { nextCursor, data } = await this.getRooms(
|
|
@@ -616,7 +635,7 @@ var Liveblocks = class {
|
|
|
616
635
|
body.organizationId = tenantId;
|
|
617
636
|
}
|
|
618
637
|
const res = await this.#post(
|
|
619
|
-
_optionalChain([options, 'optionalAccess',
|
|
638
|
+
_optionalChain([options, 'optionalAccess', _11 => _11.idempotent]) ? _core.url`/v2/rooms?idempotent` : _core.url`/v2/rooms`,
|
|
620
639
|
body,
|
|
621
640
|
options
|
|
622
641
|
);
|
|
@@ -1072,7 +1091,7 @@ var Liveblocks = class {
|
|
|
1072
1091
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments`,
|
|
1073
1092
|
{
|
|
1074
1093
|
...data,
|
|
1075
|
-
createdAt: _optionalChain([data, 'access',
|
|
1094
|
+
createdAt: _optionalChain([data, 'access', _12 => _12.createdAt, 'optionalAccess', _13 => _13.toISOString, 'call', _14 => _14()])
|
|
1076
1095
|
},
|
|
1077
1096
|
options
|
|
1078
1097
|
);
|
|
@@ -1098,7 +1117,7 @@ var Liveblocks = class {
|
|
|
1098
1117
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
|
|
1099
1118
|
{
|
|
1100
1119
|
body: data.body,
|
|
1101
|
-
editedAt: _optionalChain([data, 'access',
|
|
1120
|
+
editedAt: _optionalChain([data, 'access', _15 => _15.editedAt, 'optionalAccess', _16 => _16.toISOString, 'call', _17 => _17()]),
|
|
1102
1121
|
metadata: data.metadata
|
|
1103
1122
|
},
|
|
1104
1123
|
options
|
|
@@ -1166,7 +1185,7 @@ var Liveblocks = class {
|
|
|
1166
1185
|
...data,
|
|
1167
1186
|
comment: {
|
|
1168
1187
|
...data.comment,
|
|
1169
|
-
createdAt: _optionalChain([data, 'access',
|
|
1188
|
+
createdAt: _optionalChain([data, 'access', _18 => _18.comment, 'access', _19 => _19.createdAt, 'optionalAccess', _20 => _20.toISOString, 'call', _21 => _21()])
|
|
1170
1189
|
}
|
|
1171
1190
|
},
|
|
1172
1191
|
options
|
|
@@ -1289,7 +1308,7 @@ var Liveblocks = class {
|
|
|
1289
1308
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/metadata`,
|
|
1290
1309
|
{
|
|
1291
1310
|
...data,
|
|
1292
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1311
|
+
updatedAt: _optionalChain([data, 'access', _22 => _22.updatedAt, 'optionalAccess', _23 => _23.toISOString, 'call', _24 => _24()])
|
|
1293
1312
|
},
|
|
1294
1313
|
options
|
|
1295
1314
|
);
|
|
@@ -1315,7 +1334,7 @@ var Liveblocks = class {
|
|
|
1315
1334
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/metadata`,
|
|
1316
1335
|
{
|
|
1317
1336
|
...data,
|
|
1318
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1337
|
+
updatedAt: _optionalChain([data, 'access', _25 => _25.updatedAt, 'optionalAccess', _26 => _26.toISOString, 'call', _27 => _27()])
|
|
1319
1338
|
},
|
|
1320
1339
|
options
|
|
1321
1340
|
);
|
|
@@ -1341,7 +1360,7 @@ var Liveblocks = class {
|
|
|
1341
1360
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/add-reaction`,
|
|
1342
1361
|
{
|
|
1343
1362
|
...data,
|
|
1344
|
-
createdAt: _optionalChain([data, 'access',
|
|
1363
|
+
createdAt: _optionalChain([data, 'access', _28 => _28.createdAt, 'optionalAccess', _29 => _29.toISOString, 'call', _30 => _30()])
|
|
1345
1364
|
},
|
|
1346
1365
|
options
|
|
1347
1366
|
);
|
|
@@ -1367,7 +1386,7 @@ var Liveblocks = class {
|
|
|
1367
1386
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${params.commentId}/remove-reaction`,
|
|
1368
1387
|
{
|
|
1369
1388
|
...data,
|
|
1370
|
-
removedAt: _optionalChain([data, 'access',
|
|
1389
|
+
removedAt: _optionalChain([data, 'access', _31 => _31.removedAt, 'optionalAccess', _32 => _32.toISOString, 'call', _33 => _33()])
|
|
1371
1390
|
},
|
|
1372
1391
|
options
|
|
1373
1392
|
);
|
|
@@ -1448,7 +1467,7 @@ var Liveblocks = class {
|
|
|
1448
1467
|
*/
|
|
1449
1468
|
async *iterInboxNotifications(criteria, options) {
|
|
1450
1469
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
1451
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1470
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.pageSize]), () => ( 50)), 10);
|
|
1452
1471
|
let cursor = void 0;
|
|
1453
1472
|
while (true) {
|
|
1454
1473
|
const { nextCursor, data } = await this.getInboxNotifications(
|
|
@@ -1795,7 +1814,7 @@ var Liveblocks = class {
|
|
|
1795
1814
|
async getGroups(params, options) {
|
|
1796
1815
|
const res = await this.#get(
|
|
1797
1816
|
_core.url`/v2/groups`,
|
|
1798
|
-
{ startingAfter: _optionalChain([params, 'optionalAccess',
|
|
1817
|
+
{ startingAfter: _optionalChain([params, 'optionalAccess', _35 => _35.startingAfter]), limit: _optionalChain([params, 'optionalAccess', _36 => _36.limit]) },
|
|
1799
1818
|
options
|
|
1800
1819
|
);
|
|
1801
1820
|
if (!res.ok) {
|
|
@@ -1857,7 +1876,7 @@ var Liveblocks = class {
|
|
|
1857
1876
|
async massMutateStorage(criteria, callback, massOptions) {
|
|
1858
1877
|
const concurrency = _core.checkBounds.call(void 0,
|
|
1859
1878
|
"concurrency",
|
|
1860
|
-
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess',
|
|
1879
|
+
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess', _37 => _37.concurrency]), () => ( 8)),
|
|
1861
1880
|
1,
|
|
1862
1881
|
20
|
|
1863
1882
|
);
|
|
@@ -1873,7 +1892,7 @@ var Liveblocks = class {
|
|
|
1873
1892
|
}
|
|
1874
1893
|
async #_mutateOneRoom(roomId, room, callback, options) {
|
|
1875
1894
|
const debounceInterval = 200;
|
|
1876
|
-
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess',
|
|
1895
|
+
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess', _38 => _38.signal]));
|
|
1877
1896
|
let opsBuffer = [];
|
|
1878
1897
|
let outstandingFlush$ = void 0;
|
|
1879
1898
|
let lastFlush = performance.now();
|
|
@@ -1939,7 +1958,7 @@ var Liveblocks = class {
|
|
|
1939
1958
|
const res = await this.#post(
|
|
1940
1959
|
_core.url`/v2/rooms/${roomId}/send-message`,
|
|
1941
1960
|
{ messages },
|
|
1942
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
1961
|
+
{ signal: _optionalChain([options, 'optionalAccess', _39 => _39.signal]) }
|
|
1943
1962
|
);
|
|
1944
1963
|
if (!res.ok) {
|
|
1945
1964
|
throw await LiveblocksError.from(res);
|
|
@@ -2076,7 +2095,7 @@ var Liveblocks = class {
|
|
|
2076
2095
|
"Content-Type": params.file.type,
|
|
2077
2096
|
"Content-Length": String(params.file.size)
|
|
2078
2097
|
},
|
|
2079
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
2098
|
+
signal: _optionalChain([options, 'optionalAccess', _40 => _40.signal])
|
|
2080
2099
|
}
|
|
2081
2100
|
);
|
|
2082
2101
|
if (!res.ok) {
|
|
@@ -2208,6 +2227,196 @@ var Liveblocks = class {
|
|
|
2208
2227
|
data: page.data.map(inflateWebKnowledgeSourceLink)
|
|
2209
2228
|
};
|
|
2210
2229
|
}
|
|
2230
|
+
/* -------------------------------------------------------------------------------------------------
|
|
2231
|
+
* Feeds
|
|
2232
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
2233
|
+
/**
|
|
2234
|
+
* Returns a list of feeds in a room.
|
|
2235
|
+
* @param params.roomId The room ID to get the feeds from.
|
|
2236
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2237
|
+
* @returns A list of feeds.
|
|
2238
|
+
*/
|
|
2239
|
+
async getFeeds(params, options) {
|
|
2240
|
+
const { roomId } = params;
|
|
2241
|
+
const res = await this.#get(
|
|
2242
|
+
_core.url`/v2/rooms/${roomId}/feeds`,
|
|
2243
|
+
void 0,
|
|
2244
|
+
options
|
|
2245
|
+
);
|
|
2246
|
+
if (!res.ok) {
|
|
2247
|
+
throw await LiveblocksError.from(res);
|
|
2248
|
+
}
|
|
2249
|
+
return await res.json();
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Creates a new feed in a room.
|
|
2253
|
+
* @param params.roomId The room ID to create the feed in.
|
|
2254
|
+
* @param params.feedId The feed ID.
|
|
2255
|
+
* @param params.metadata (optional) The metadata for the feed.
|
|
2256
|
+
* @param params.createdAt (optional) Creation time in ms. Sent to the API as `timestamp`. If not provided, the server uses the current time.
|
|
2257
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2258
|
+
* @returns The created feed.
|
|
2259
|
+
*/
|
|
2260
|
+
async createFeed(params, options) {
|
|
2261
|
+
const { roomId, feedId, metadata, createdAt } = params;
|
|
2262
|
+
const res = await this.#post(
|
|
2263
|
+
_core.url`/v2/rooms/${roomId}/feeds`,
|
|
2264
|
+
{
|
|
2265
|
+
feedId,
|
|
2266
|
+
...metadata !== void 0 ? { metadata } : {},
|
|
2267
|
+
...createdAt !== void 0 ? { timestamp: createdAt } : {}
|
|
2268
|
+
},
|
|
2269
|
+
options
|
|
2270
|
+
);
|
|
2271
|
+
if (!res.ok) {
|
|
2272
|
+
throw await LiveblocksError.from(res);
|
|
2273
|
+
}
|
|
2274
|
+
return await res.json();
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* Returns a feed with the given id.
|
|
2278
|
+
* @param params.roomId The room ID to get the feed from.
|
|
2279
|
+
* @param params.feedId The feed ID.
|
|
2280
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2281
|
+
* @returns The feed.
|
|
2282
|
+
*/
|
|
2283
|
+
async getFeed(params, options) {
|
|
2284
|
+
const { roomId, feedId } = params;
|
|
2285
|
+
const res = await this.#get(
|
|
2286
|
+
_core.url`/v2/rooms/${roomId}/feeds/${feedId}`,
|
|
2287
|
+
void 0,
|
|
2288
|
+
options
|
|
2289
|
+
);
|
|
2290
|
+
if (!res.ok) {
|
|
2291
|
+
throw await LiveblocksError.from(res);
|
|
2292
|
+
}
|
|
2293
|
+
return await res.json();
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Updates the metadata of a feed.
|
|
2297
|
+
* @param params.roomId The room ID to update the feed in.
|
|
2298
|
+
* @param params.feedId The feed ID to update.
|
|
2299
|
+
* @param params.metadata The metadata for the feed.
|
|
2300
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2301
|
+
* @returns The updated feed.
|
|
2302
|
+
*/
|
|
2303
|
+
async updateFeed(params, options) {
|
|
2304
|
+
const { roomId, feedId, metadata } = params;
|
|
2305
|
+
const res = await this.#patch(
|
|
2306
|
+
_core.url`/v2/rooms/${roomId}/feeds/${feedId}`,
|
|
2307
|
+
{ metadata },
|
|
2308
|
+
options
|
|
2309
|
+
);
|
|
2310
|
+
if (!res.ok) {
|
|
2311
|
+
throw await LiveblocksError.from(res);
|
|
2312
|
+
}
|
|
2313
|
+
return await res.json();
|
|
2314
|
+
}
|
|
2315
|
+
/**
|
|
2316
|
+
* Deletes a feed.
|
|
2317
|
+
* @param params.roomId The room ID to delete the feed from.
|
|
2318
|
+
* @param params.feedId The feed ID to delete.
|
|
2319
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2320
|
+
*/
|
|
2321
|
+
async deleteFeed(params, options) {
|
|
2322
|
+
const { roomId, feedId } = params;
|
|
2323
|
+
const res = await this.#delete(
|
|
2324
|
+
_core.url`/v2/rooms/${roomId}/feeds/${feedId}`,
|
|
2325
|
+
void 0,
|
|
2326
|
+
options
|
|
2327
|
+
);
|
|
2328
|
+
if (!res.ok) {
|
|
2329
|
+
throw await LiveblocksError.from(res);
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* Returns a list of messages in a feed.
|
|
2334
|
+
* @param params.roomId The room ID to get the feed messages from.
|
|
2335
|
+
* @param params.feedId The feed ID to get the messages from.
|
|
2336
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2337
|
+
* @returns A list of feed messages.
|
|
2338
|
+
*/
|
|
2339
|
+
async getFeedMessages(params, options) {
|
|
2340
|
+
const { roomId, feedId } = params;
|
|
2341
|
+
const res = await this.#get(
|
|
2342
|
+
_core.url`/v2/rooms/${roomId}/feeds/${feedId}/messages`,
|
|
2343
|
+
void 0,
|
|
2344
|
+
options
|
|
2345
|
+
);
|
|
2346
|
+
if (!res.ok) {
|
|
2347
|
+
throw await LiveblocksError.from(res);
|
|
2348
|
+
}
|
|
2349
|
+
return await res.json();
|
|
2350
|
+
}
|
|
2351
|
+
/**
|
|
2352
|
+
* Creates a new message in a feed.
|
|
2353
|
+
* @param params.roomId The room ID to create the feed message in.
|
|
2354
|
+
* @param params.feedId The feed ID to create the message in.
|
|
2355
|
+
* @param params.id (optional) The message ID. If not provided, one will be generated.
|
|
2356
|
+
* @param params.createdAt (optional) Creation time in ms. Sent to the API as `timestamp`. If not provided, the server uses the current time.
|
|
2357
|
+
* @param params.data The message data.
|
|
2358
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2359
|
+
* @returns The created feed message.
|
|
2360
|
+
*/
|
|
2361
|
+
async createFeedMessage(params, options) {
|
|
2362
|
+
const { roomId, feedId, id, createdAt, data } = params;
|
|
2363
|
+
const res = await this.#post(
|
|
2364
|
+
_core.url`/v2/rooms/${roomId}/feeds/${feedId}/messages`,
|
|
2365
|
+
{
|
|
2366
|
+
data,
|
|
2367
|
+
...id !== void 0 ? { id } : {},
|
|
2368
|
+
...createdAt !== void 0 ? { timestamp: createdAt } : {}
|
|
2369
|
+
},
|
|
2370
|
+
options
|
|
2371
|
+
);
|
|
2372
|
+
if (!res.ok) {
|
|
2373
|
+
throw await LiveblocksError.from(res);
|
|
2374
|
+
}
|
|
2375
|
+
return await res.json();
|
|
2376
|
+
}
|
|
2377
|
+
/**
|
|
2378
|
+
* Updates a feed message.
|
|
2379
|
+
* @param params.roomId The room ID to update the feed message in.
|
|
2380
|
+
* @param params.feedId The feed ID to update the message in.
|
|
2381
|
+
* @param params.messageId The message ID to update.
|
|
2382
|
+
* @param params.data The message data.
|
|
2383
|
+
* @param params.updatedAt (optional) Update time in ms. Sent to the API as `timestamp`. If omitted, the server uses the current time.
|
|
2384
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2385
|
+
* @returns The updated feed message.
|
|
2386
|
+
*/
|
|
2387
|
+
async updateFeedMessage(params, options) {
|
|
2388
|
+
const { roomId, feedId, messageId, data, updatedAt } = params;
|
|
2389
|
+
const res = await this.#patch(
|
|
2390
|
+
_core.url`/v2/rooms/${roomId}/feeds/${feedId}/messages/${messageId}`,
|
|
2391
|
+
{
|
|
2392
|
+
data,
|
|
2393
|
+
...updatedAt !== void 0 ? { timestamp: updatedAt } : {}
|
|
2394
|
+
},
|
|
2395
|
+
options
|
|
2396
|
+
);
|
|
2397
|
+
if (!res.ok) {
|
|
2398
|
+
throw await LiveblocksError.from(res);
|
|
2399
|
+
}
|
|
2400
|
+
return await res.json();
|
|
2401
|
+
}
|
|
2402
|
+
/**
|
|
2403
|
+
* Deletes a feed message.
|
|
2404
|
+
* @param params.roomId The room ID to delete the feed message from.
|
|
2405
|
+
* @param params.feedId The feed ID to delete the message from.
|
|
2406
|
+
* @param params.messageId The message ID to delete.
|
|
2407
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2408
|
+
*/
|
|
2409
|
+
async deleteFeedMessage(params, options) {
|
|
2410
|
+
const { roomId, feedId, messageId } = params;
|
|
2411
|
+
const res = await this.#delete(
|
|
2412
|
+
_core.url`/v2/rooms/${roomId}/feeds/${feedId}/messages/${messageId}`,
|
|
2413
|
+
void 0,
|
|
2414
|
+
options
|
|
2415
|
+
);
|
|
2416
|
+
if (!res.ok) {
|
|
2417
|
+
throw await LiveblocksError.from(res);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2211
2420
|
};
|
|
2212
2421
|
var LiveblocksError = class _LiveblocksError extends Error {
|
|
2213
2422
|
|