@liveblocks/node 3.15.0-components1 → 3.15.0-feeds2
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/README.md +6 -16
- package/dist/index.cjs +222 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +128 -5
- package/dist/index.d.ts +128 -5
- package/dist/index.js +201 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
<p
|
|
2
|
-
<a href="https://liveblocks.io#gh-light-mode-only">
|
|
3
|
-
|
|
4
|
-
</a>
|
|
5
|
-
<a href="https://liveblocks.io#gh-dark-mode-only">
|
|
6
|
-
<img src="https://raw.githubusercontent.com/liveblocks/liveblocks/main/.github/assets/header-dark.svg" alt="Liveblocks" />
|
|
7
|
-
</a>
|
|
1
|
+
<p>
|
|
2
|
+
<a href="https://liveblocks.io#gh-light-mode-only"><img src="https://raw.githubusercontent.com/liveblocks/liveblocks/main/.github/assets/header-light.svg" alt="Liveblocks" /></a>
|
|
3
|
+
<a href="https://liveblocks.io#gh-dark-mode-only"><img src="https://raw.githubusercontent.com/liveblocks/liveblocks/main/.github/assets/header-dark.svg" alt="Liveblocks" /></a>
|
|
8
4
|
</p>
|
|
9
5
|
|
|
10
6
|
# `@liveblocks/node`
|
|
11
7
|
|
|
12
8
|
<p>
|
|
13
|
-
<a href="https://npmjs.org/package/@liveblocks/node">
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<a href="https://bundlephobia.com/package/@liveblocks/node">
|
|
17
|
-
<img src="https://img.shields.io/bundlephobia/minzip/@liveblocks/node?style=flat&label=size&color=09f" alt="Size" />
|
|
18
|
-
</a>
|
|
19
|
-
<a href="https://github.com/liveblocks/liveblocks/blob/main/LICENSE">
|
|
20
|
-
<img src="https://img.shields.io/github/license/liveblocks/liveblocks?style=flat&label=license&color=f80" alt="License" />
|
|
21
|
-
</a>
|
|
9
|
+
<a href="https://npmjs.org/package/@liveblocks/node"><img src="https://img.shields.io/npm/v/@liveblocks/node?style=flat&label=npm&color=c33" alt="NPM" /></a>
|
|
10
|
+
<a href="https://bundlephobia.com/package/@liveblocks/node"><img src="https://img.shields.io/bundlephobia/minzip/@liveblocks/node?style=flat&label=size&color=09f" alt="Size" /></a>
|
|
11
|
+
<a href="https://github.com/liveblocks/liveblocks/blob/main/licenses/LICENSE-APACHE-2.0"><img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="License" /></a>
|
|
22
12
|
</p>
|
|
23
13
|
|
|
24
14
|
`@liveblocks/node` provides server-side utilities to set up
|
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-
|
|
6
|
+
var PKG_VERSION = "3.15.0-feeds2";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -165,7 +165,9 @@ 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",
|
|
170
|
+
"feeds:read"
|
|
169
171
|
]);
|
|
170
172
|
function isPermission(value) {
|
|
171
173
|
return ALL_PERMISSIONS.includes(value);
|
|
@@ -174,9 +176,14 @@ var MAX_PERMS_PER_SET = 10;
|
|
|
174
176
|
var READ_ACCESS = Object.freeze([
|
|
175
177
|
"room:read",
|
|
176
178
|
"room:presence:write",
|
|
177
|
-
"comments:read"
|
|
179
|
+
"comments:read",
|
|
180
|
+
"feeds:read"
|
|
181
|
+
]);
|
|
182
|
+
var FULL_ACCESS = Object.freeze([
|
|
183
|
+
"room:write",
|
|
184
|
+
"comments:write",
|
|
185
|
+
"feeds:write"
|
|
178
186
|
]);
|
|
179
|
-
var FULL_ACCESS = Object.freeze(["room:write", "comments:write"]);
|
|
180
187
|
var roomPatternRegex = /^([*]|[^*]{1,128}[*]?)$/;
|
|
181
188
|
var Session = (_class = class {
|
|
182
189
|
__init() {this.FULL_ACCESS = FULL_ACCESS}
|
|
@@ -360,6 +367,22 @@ var Liveblocks = class {
|
|
|
360
367
|
xwarn(res, "POST", path);
|
|
361
368
|
return res;
|
|
362
369
|
}
|
|
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
|
+
}
|
|
363
386
|
async #putBinary(path, body, params, options) {
|
|
364
387
|
const url3 = _core.urljoin.call(void 0, this.#baseUrl, path, params);
|
|
365
388
|
const headers = {
|
|
@@ -371,7 +394,7 @@ var Liveblocks = class {
|
|
|
371
394
|
method: "PUT",
|
|
372
395
|
headers,
|
|
373
396
|
body,
|
|
374
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
397
|
+
signal: _optionalChain([options, 'optionalAccess', _3 => _3.signal])
|
|
375
398
|
});
|
|
376
399
|
xwarn(res, "PUT", path);
|
|
377
400
|
return res;
|
|
@@ -385,7 +408,7 @@ var Liveblocks = class {
|
|
|
385
408
|
const res = await fetch(url3, {
|
|
386
409
|
method: "DELETE",
|
|
387
410
|
headers,
|
|
388
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
411
|
+
signal: _optionalChain([options, 'optionalAccess', _4 => _4.signal])
|
|
389
412
|
});
|
|
390
413
|
xwarn(res, "DELETE", path);
|
|
391
414
|
return res;
|
|
@@ -399,7 +422,7 @@ var Liveblocks = class {
|
|
|
399
422
|
const res = await fetch(url3, {
|
|
400
423
|
method: "GET",
|
|
401
424
|
headers,
|
|
402
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
425
|
+
signal: _optionalChain([options, 'optionalAccess', _5 => _5.signal])
|
|
403
426
|
});
|
|
404
427
|
xwarn(res, "GET", path);
|
|
405
428
|
return res;
|
|
@@ -430,8 +453,8 @@ var Liveblocks = class {
|
|
|
430
453
|
return new Session(
|
|
431
454
|
this.#post.bind(this),
|
|
432
455
|
userId,
|
|
433
|
-
_optionalChain([options, 'optionalAccess',
|
|
434
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
456
|
+
_optionalChain([options, 'optionalAccess', _6 => _6.userInfo]),
|
|
457
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.organizationId]), () => ( _optionalChain([options, 'optionalAccess', _8 => _8.tenantId]))),
|
|
435
458
|
this.#localDev
|
|
436
459
|
);
|
|
437
460
|
}
|
|
@@ -481,7 +504,7 @@ var Liveblocks = class {
|
|
|
481
504
|
const body = {
|
|
482
505
|
userId,
|
|
483
506
|
groupIds,
|
|
484
|
-
userInfo: _optionalChain([options, 'optionalAccess',
|
|
507
|
+
userInfo: _optionalChain([options, 'optionalAccess', _9 => _9.userInfo])
|
|
485
508
|
};
|
|
486
509
|
if (organizationId !== void 0) {
|
|
487
510
|
body.organizationId = organizationId;
|
|
@@ -567,7 +590,7 @@ var Liveblocks = class {
|
|
|
567
590
|
*/
|
|
568
591
|
async *iterRooms(criteria, options) {
|
|
569
592
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
570
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
593
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _10 => _10.pageSize]), () => ( 40)), 20);
|
|
571
594
|
let cursor = void 0;
|
|
572
595
|
while (true) {
|
|
573
596
|
const { nextCursor, data } = await this.getRooms(
|
|
@@ -618,7 +641,7 @@ var Liveblocks = class {
|
|
|
618
641
|
body.organizationId = tenantId;
|
|
619
642
|
}
|
|
620
643
|
const res = await this.#post(
|
|
621
|
-
_optionalChain([options, 'optionalAccess',
|
|
644
|
+
_optionalChain([options, 'optionalAccess', _11 => _11.idempotent]) ? _core.url`/v2/rooms?idempotent` : _core.url`/v2/rooms`,
|
|
622
645
|
body,
|
|
623
646
|
options
|
|
624
647
|
);
|
|
@@ -1074,7 +1097,7 @@ var Liveblocks = class {
|
|
|
1074
1097
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments`,
|
|
1075
1098
|
{
|
|
1076
1099
|
...data,
|
|
1077
|
-
createdAt: _optionalChain([data, 'access',
|
|
1100
|
+
createdAt: _optionalChain([data, 'access', _12 => _12.createdAt, 'optionalAccess', _13 => _13.toISOString, 'call', _14 => _14()])
|
|
1078
1101
|
},
|
|
1079
1102
|
options
|
|
1080
1103
|
);
|
|
@@ -1100,7 +1123,7 @@ var Liveblocks = class {
|
|
|
1100
1123
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
|
|
1101
1124
|
{
|
|
1102
1125
|
body: data.body,
|
|
1103
|
-
editedAt: _optionalChain([data, 'access',
|
|
1126
|
+
editedAt: _optionalChain([data, 'access', _15 => _15.editedAt, 'optionalAccess', _16 => _16.toISOString, 'call', _17 => _17()]),
|
|
1104
1127
|
metadata: data.metadata
|
|
1105
1128
|
},
|
|
1106
1129
|
options
|
|
@@ -1148,7 +1171,7 @@ var Liveblocks = class {
|
|
|
1148
1171
|
...data,
|
|
1149
1172
|
comment: {
|
|
1150
1173
|
...data.comment,
|
|
1151
|
-
createdAt: _optionalChain([data, 'access',
|
|
1174
|
+
createdAt: _optionalChain([data, 'access', _18 => _18.comment, 'access', _19 => _19.createdAt, 'optionalAccess', _20 => _20.toISOString, 'call', _21 => _21()])
|
|
1152
1175
|
}
|
|
1153
1176
|
},
|
|
1154
1177
|
options
|
|
@@ -1271,7 +1294,7 @@ var Liveblocks = class {
|
|
|
1271
1294
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/metadata`,
|
|
1272
1295
|
{
|
|
1273
1296
|
...data,
|
|
1274
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1297
|
+
updatedAt: _optionalChain([data, 'access', _22 => _22.updatedAt, 'optionalAccess', _23 => _23.toISOString, 'call', _24 => _24()])
|
|
1275
1298
|
},
|
|
1276
1299
|
options
|
|
1277
1300
|
);
|
|
@@ -1297,7 +1320,7 @@ var Liveblocks = class {
|
|
|
1297
1320
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/metadata`,
|
|
1298
1321
|
{
|
|
1299
1322
|
...data,
|
|
1300
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1323
|
+
updatedAt: _optionalChain([data, 'access', _25 => _25.updatedAt, 'optionalAccess', _26 => _26.toISOString, 'call', _27 => _27()])
|
|
1301
1324
|
},
|
|
1302
1325
|
options
|
|
1303
1326
|
);
|
|
@@ -1323,7 +1346,7 @@ var Liveblocks = class {
|
|
|
1323
1346
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/add-reaction`,
|
|
1324
1347
|
{
|
|
1325
1348
|
...data,
|
|
1326
|
-
createdAt: _optionalChain([data, 'access',
|
|
1349
|
+
createdAt: _optionalChain([data, 'access', _28 => _28.createdAt, 'optionalAccess', _29 => _29.toISOString, 'call', _30 => _30()])
|
|
1327
1350
|
},
|
|
1328
1351
|
options
|
|
1329
1352
|
);
|
|
@@ -1349,7 +1372,7 @@ var Liveblocks = class {
|
|
|
1349
1372
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${params.commentId}/remove-reaction`,
|
|
1350
1373
|
{
|
|
1351
1374
|
...data,
|
|
1352
|
-
removedAt: _optionalChain([data, 'access',
|
|
1375
|
+
removedAt: _optionalChain([data, 'access', _31 => _31.removedAt, 'optionalAccess', _32 => _32.toISOString, 'call', _33 => _33()])
|
|
1353
1376
|
},
|
|
1354
1377
|
options
|
|
1355
1378
|
);
|
|
@@ -1430,7 +1453,7 @@ var Liveblocks = class {
|
|
|
1430
1453
|
*/
|
|
1431
1454
|
async *iterInboxNotifications(criteria, options) {
|
|
1432
1455
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
1433
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1456
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.pageSize]), () => ( 50)), 10);
|
|
1434
1457
|
let cursor = void 0;
|
|
1435
1458
|
while (true) {
|
|
1436
1459
|
const { nextCursor, data } = await this.getInboxNotifications(
|
|
@@ -1777,7 +1800,7 @@ var Liveblocks = class {
|
|
|
1777
1800
|
async getGroups(params, options) {
|
|
1778
1801
|
const res = await this.#get(
|
|
1779
1802
|
_core.url`/v2/groups`,
|
|
1780
|
-
{ startingAfter: _optionalChain([params, 'optionalAccess',
|
|
1803
|
+
{ startingAfter: _optionalChain([params, 'optionalAccess', _35 => _35.startingAfter]), limit: _optionalChain([params, 'optionalAccess', _36 => _36.limit]) },
|
|
1781
1804
|
options
|
|
1782
1805
|
);
|
|
1783
1806
|
if (!res.ok) {
|
|
@@ -1839,7 +1862,7 @@ var Liveblocks = class {
|
|
|
1839
1862
|
async massMutateStorage(criteria, callback, massOptions) {
|
|
1840
1863
|
const concurrency = _core.checkBounds.call(void 0,
|
|
1841
1864
|
"concurrency",
|
|
1842
|
-
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess',
|
|
1865
|
+
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess', _37 => _37.concurrency]), () => ( 8)),
|
|
1843
1866
|
1,
|
|
1844
1867
|
20
|
|
1845
1868
|
);
|
|
@@ -1855,7 +1878,7 @@ var Liveblocks = class {
|
|
|
1855
1878
|
}
|
|
1856
1879
|
async #_mutateOneRoom(roomId, room, callback, options) {
|
|
1857
1880
|
const debounceInterval = 200;
|
|
1858
|
-
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess',
|
|
1881
|
+
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess', _38 => _38.signal]));
|
|
1859
1882
|
let opsBuffer = [];
|
|
1860
1883
|
let outstandingFlush$ = void 0;
|
|
1861
1884
|
let lastFlush = performance.now();
|
|
@@ -1921,7 +1944,7 @@ var Liveblocks = class {
|
|
|
1921
1944
|
const res = await this.#post(
|
|
1922
1945
|
_core.url`/v2/rooms/${roomId}/send-message`,
|
|
1923
1946
|
{ messages },
|
|
1924
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
1947
|
+
{ signal: _optionalChain([options, 'optionalAccess', _39 => _39.signal]) }
|
|
1925
1948
|
);
|
|
1926
1949
|
if (!res.ok) {
|
|
1927
1950
|
throw await LiveblocksError.from(res);
|
|
@@ -2058,7 +2081,7 @@ var Liveblocks = class {
|
|
|
2058
2081
|
"Content-Type": params.file.type,
|
|
2059
2082
|
"Content-Length": String(params.file.size)
|
|
2060
2083
|
},
|
|
2061
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
2084
|
+
signal: _optionalChain([options, 'optionalAccess', _40 => _40.signal])
|
|
2062
2085
|
}
|
|
2063
2086
|
);
|
|
2064
2087
|
if (!res.ok) {
|
|
@@ -2190,6 +2213,180 @@ var Liveblocks = class {
|
|
|
2190
2213
|
data: page.data.map(inflateWebKnowledgeSourceLink)
|
|
2191
2214
|
};
|
|
2192
2215
|
}
|
|
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
|
+
}
|
|
2193
2390
|
};
|
|
2194
2391
|
var LiveblocksError = class _LiveblocksError extends Error {
|
|
2195
2392
|
|