@liveblocks/node 3.23.0-file3 → 3.23.0-file4
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 +82 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -10
- 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.23.0-
|
|
6
|
+
var PKG_VERSION = "3.23.0-file4";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -338,28 +338,69 @@ async function uploadStorageFile({
|
|
|
338
338
|
}
|
|
339
339
|
let uploadId;
|
|
340
340
|
const uploadedParts = [];
|
|
341
|
-
const multipartUpload = await
|
|
341
|
+
const multipartUpload = await _core.autoRetry.call(void 0,
|
|
342
|
+
createMultipartUpload,
|
|
343
|
+
STORAGE_FILE_RETRY_ATTEMPTS,
|
|
344
|
+
STORAGE_FILE_RETRY_DELAYS,
|
|
345
|
+
handleRetryError
|
|
346
|
+
);
|
|
347
|
+
const partUploadController = new AbortController();
|
|
348
|
+
const partUploadSignal = partUploadController.signal;
|
|
349
|
+
const abortPartUploads = (reason) => {
|
|
350
|
+
partUploadController.abort(reason);
|
|
351
|
+
};
|
|
352
|
+
const handleExternalAbort = () => abortPartUploads();
|
|
353
|
+
if (_optionalChain([signal, 'optionalAccess', _4 => _4.aborted])) {
|
|
354
|
+
handleExternalAbort();
|
|
355
|
+
} else {
|
|
356
|
+
_optionalChain([signal, 'optionalAccess', _5 => _5.addEventListener, 'call', _6 => _6("abort", handleExternalAbort, { once: true })]);
|
|
357
|
+
}
|
|
342
358
|
try {
|
|
343
359
|
uploadId = multipartUpload.uploadId;
|
|
344
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
360
|
+
if (_optionalChain([signal, 'optionalAccess', _7 => _7.aborted])) {
|
|
345
361
|
throw abortError;
|
|
346
362
|
}
|
|
347
363
|
const batches = _core.chunk.call(void 0, splitStorageFileIntoParts(file), 5);
|
|
348
364
|
for (const parts of batches) {
|
|
349
|
-
const
|
|
365
|
+
const firstPartUploadFailure = {};
|
|
366
|
+
const partUploads$ = [];
|
|
350
367
|
for (const { part, partNumber } of parts) {
|
|
351
|
-
|
|
368
|
+
partUploads$.push(
|
|
352
369
|
_core.autoRetry.call(void 0,
|
|
353
|
-
() => uploadMultipartPart(
|
|
370
|
+
() => uploadMultipartPart(
|
|
371
|
+
multipartUpload.uploadId,
|
|
372
|
+
partNumber,
|
|
373
|
+
part,
|
|
374
|
+
partUploadSignal
|
|
375
|
+
),
|
|
354
376
|
STORAGE_FILE_RETRY_ATTEMPTS,
|
|
355
377
|
STORAGE_FILE_RETRY_DELAYS,
|
|
356
|
-
|
|
357
|
-
|
|
378
|
+
(error) => {
|
|
379
|
+
if (_optionalChain([signal, 'optionalAccess', _8 => _8.aborted])) {
|
|
380
|
+
throw abortError;
|
|
381
|
+
}
|
|
382
|
+
return partUploadSignal.aborted || handleRetryError(error);
|
|
383
|
+
}
|
|
384
|
+
).catch((error) => {
|
|
385
|
+
if (firstPartUploadFailure.value === void 0) {
|
|
386
|
+
firstPartUploadFailure.value = { error };
|
|
387
|
+
abortPartUploads(error);
|
|
388
|
+
}
|
|
389
|
+
throw error;
|
|
390
|
+
})
|
|
358
391
|
);
|
|
359
392
|
}
|
|
360
|
-
|
|
393
|
+
const settledPartUploads = await Promise.allSettled(partUploads$);
|
|
394
|
+
if (firstPartUploadFailure.value !== void 0) {
|
|
395
|
+
throw firstPartUploadFailure.value.error;
|
|
396
|
+
}
|
|
397
|
+
for (const settledPartUpload of settledPartUploads) {
|
|
398
|
+
if (settledPartUpload.status === "fulfilled") {
|
|
399
|
+
uploadedParts.push(settledPartUpload.value);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
361
402
|
}
|
|
362
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
403
|
+
if (_optionalChain([signal, 'optionalAccess', _9 => _9.aborted])) {
|
|
363
404
|
throw abortError;
|
|
364
405
|
}
|
|
365
406
|
const sortedParts = uploadedParts.sort(
|
|
@@ -379,6 +420,8 @@ async function uploadStorageFile({
|
|
|
379
420
|
}
|
|
380
421
|
}
|
|
381
422
|
throw err;
|
|
423
|
+
} finally {
|
|
424
|
+
_optionalChain([signal, 'optionalAccess', _10 => _10.removeEventListener, 'call', _11 => _11("abort", handleExternalAbort)]);
|
|
382
425
|
}
|
|
383
426
|
}
|
|
384
427
|
function splitStorageFileIntoParts(file) {
|
|
@@ -483,7 +526,7 @@ var Liveblocks = class {
|
|
|
483
526
|
method: "POST",
|
|
484
527
|
headers,
|
|
485
528
|
body: JSON.stringify(json),
|
|
486
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
529
|
+
signal: _optionalChain([options, 'optionalAccess', _12 => _12.signal])
|
|
487
530
|
});
|
|
488
531
|
xwarn(res, "POST", path);
|
|
489
532
|
return res;
|
|
@@ -505,7 +548,7 @@ var Liveblocks = class {
|
|
|
505
548
|
method: "PATCH",
|
|
506
549
|
headers,
|
|
507
550
|
body: JSON.stringify(json),
|
|
508
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
551
|
+
signal: _optionalChain([options, 'optionalAccess', _13 => _13.signal])
|
|
509
552
|
});
|
|
510
553
|
xwarn(res, "PATCH", path);
|
|
511
554
|
return res;
|
|
@@ -521,7 +564,7 @@ var Liveblocks = class {
|
|
|
521
564
|
method: "PUT",
|
|
522
565
|
headers,
|
|
523
566
|
body,
|
|
524
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
567
|
+
signal: _optionalChain([options, 'optionalAccess', _14 => _14.signal])
|
|
525
568
|
});
|
|
526
569
|
xwarn(res, "PUT", path);
|
|
527
570
|
return res;
|
|
@@ -537,7 +580,7 @@ var Liveblocks = class {
|
|
|
537
580
|
method: "PUT",
|
|
538
581
|
headers,
|
|
539
582
|
body,
|
|
540
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
583
|
+
signal: _optionalChain([options, 'optionalAccess', _15 => _15.signal])
|
|
541
584
|
});
|
|
542
585
|
xwarn(res, "PUT", path);
|
|
543
586
|
return res;
|
|
@@ -551,7 +594,7 @@ var Liveblocks = class {
|
|
|
551
594
|
const res = await fetch(url3, {
|
|
552
595
|
method: "DELETE",
|
|
553
596
|
headers,
|
|
554
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
597
|
+
signal: _optionalChain([options, 'optionalAccess', _16 => _16.signal])
|
|
555
598
|
});
|
|
556
599
|
xwarn(res, "DELETE", path);
|
|
557
600
|
return res;
|
|
@@ -565,7 +608,7 @@ var Liveblocks = class {
|
|
|
565
608
|
const res = await fetch(url3, {
|
|
566
609
|
method: "GET",
|
|
567
610
|
headers,
|
|
568
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
611
|
+
signal: _optionalChain([options, 'optionalAccess', _17 => _17.signal])
|
|
569
612
|
});
|
|
570
613
|
xwarn(res, "GET", path);
|
|
571
614
|
return res;
|
|
@@ -596,8 +639,8 @@ var Liveblocks = class {
|
|
|
596
639
|
return new Session(
|
|
597
640
|
this.#post.bind(this),
|
|
598
641
|
userId,
|
|
599
|
-
_optionalChain([options, 'optionalAccess',
|
|
600
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
642
|
+
_optionalChain([options, 'optionalAccess', _18 => _18.userInfo]),
|
|
643
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _19 => _19.organizationId]), () => ( _optionalChain([options, 'optionalAccess', _20 => _20.tenantId]))),
|
|
601
644
|
this.#localDev
|
|
602
645
|
);
|
|
603
646
|
}
|
|
@@ -647,7 +690,7 @@ var Liveblocks = class {
|
|
|
647
690
|
const body = {
|
|
648
691
|
userId,
|
|
649
692
|
groupIds,
|
|
650
|
-
userInfo: _optionalChain([options, 'optionalAccess',
|
|
693
|
+
userInfo: _optionalChain([options, 'optionalAccess', _21 => _21.userInfo])
|
|
651
694
|
};
|
|
652
695
|
if (organizationId !== void 0) {
|
|
653
696
|
body.organizationId = organizationId;
|
|
@@ -733,7 +776,7 @@ var Liveblocks = class {
|
|
|
733
776
|
*/
|
|
734
777
|
async *iterRooms(criteria, options) {
|
|
735
778
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
736
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
779
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.pageSize]), () => ( 40)), 20);
|
|
737
780
|
let cursor = void 0;
|
|
738
781
|
while (true) {
|
|
739
782
|
const { nextCursor, data } = await this.getRooms(
|
|
@@ -783,7 +826,7 @@ var Liveblocks = class {
|
|
|
783
826
|
body.organizationId = tenantId;
|
|
784
827
|
}
|
|
785
828
|
const res = await this.#post(
|
|
786
|
-
_optionalChain([options, 'optionalAccess',
|
|
829
|
+
_optionalChain([options, 'optionalAccess', _23 => _23.idempotent]) ? _core.url`/v2/rooms?idempotent` : _core.url`/v2/rooms`,
|
|
787
830
|
body,
|
|
788
831
|
options
|
|
789
832
|
);
|
|
@@ -1319,7 +1362,7 @@ var Liveblocks = class {
|
|
|
1319
1362
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments`,
|
|
1320
1363
|
{
|
|
1321
1364
|
...data,
|
|
1322
|
-
createdAt: _optionalChain([data, 'access',
|
|
1365
|
+
createdAt: _optionalChain([data, 'access', _24 => _24.createdAt, 'optionalAccess', _25 => _25.toISOString, 'call', _26 => _26()])
|
|
1323
1366
|
},
|
|
1324
1367
|
options
|
|
1325
1368
|
);
|
|
@@ -1345,7 +1388,7 @@ var Liveblocks = class {
|
|
|
1345
1388
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
|
|
1346
1389
|
{
|
|
1347
1390
|
body: data.body,
|
|
1348
|
-
editedAt: _optionalChain([data, 'access',
|
|
1391
|
+
editedAt: _optionalChain([data, 'access', _27 => _27.editedAt, 'optionalAccess', _28 => _28.toISOString, 'call', _29 => _29()]),
|
|
1349
1392
|
metadata: data.metadata
|
|
1350
1393
|
},
|
|
1351
1394
|
options
|
|
@@ -1398,7 +1441,7 @@ var Liveblocks = class {
|
|
|
1398
1441
|
const fileId = _core.createStorageFileId.call(void 0, );
|
|
1399
1442
|
const fileData = await uploadStorageFile({
|
|
1400
1443
|
file,
|
|
1401
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
1444
|
+
signal: _optionalChain([options, 'optionalAccess', _30 => _30.signal]),
|
|
1402
1445
|
abortErrorMessage: `Upload of file ${fileId} was aborted.`,
|
|
1403
1446
|
uploadSingle: async () => {
|
|
1404
1447
|
const res = await this.#putBlob(
|
|
@@ -1418,12 +1461,12 @@ var Liveblocks = class {
|
|
|
1418
1461
|
);
|
|
1419
1462
|
return await this.#readJsonResponse(res);
|
|
1420
1463
|
},
|
|
1421
|
-
uploadMultipartPart: async (uploadId, partNumber, part) => {
|
|
1464
|
+
uploadMultipartPart: async (uploadId, partNumber, part, signal) => {
|
|
1422
1465
|
const res = await this.#putBlob(
|
|
1423
1466
|
_core.url`/v2/rooms/${roomId}/storage/files/${fileId}/multipart/${uploadId}/${String(partNumber)}`,
|
|
1424
1467
|
part,
|
|
1425
1468
|
void 0,
|
|
1426
|
-
|
|
1469
|
+
{ signal }
|
|
1427
1470
|
);
|
|
1428
1471
|
return await this.#readJsonResponse(res);
|
|
1429
1472
|
},
|
|
@@ -1480,7 +1523,7 @@ var Liveblocks = class {
|
|
|
1480
1523
|
...data,
|
|
1481
1524
|
comment: {
|
|
1482
1525
|
...data.comment,
|
|
1483
|
-
createdAt: _optionalChain([data, 'access',
|
|
1526
|
+
createdAt: _optionalChain([data, 'access', _31 => _31.comment, 'access', _32 => _32.createdAt, 'optionalAccess', _33 => _33.toISOString, 'call', _34 => _34()])
|
|
1484
1527
|
}
|
|
1485
1528
|
},
|
|
1486
1529
|
options
|
|
@@ -1603,7 +1646,7 @@ var Liveblocks = class {
|
|
|
1603
1646
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/metadata`,
|
|
1604
1647
|
{
|
|
1605
1648
|
...data,
|
|
1606
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1649
|
+
updatedAt: _optionalChain([data, 'access', _35 => _35.updatedAt, 'optionalAccess', _36 => _36.toISOString, 'call', _37 => _37()])
|
|
1607
1650
|
},
|
|
1608
1651
|
options
|
|
1609
1652
|
);
|
|
@@ -1629,7 +1672,7 @@ var Liveblocks = class {
|
|
|
1629
1672
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/metadata`,
|
|
1630
1673
|
{
|
|
1631
1674
|
...data,
|
|
1632
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1675
|
+
updatedAt: _optionalChain([data, 'access', _38 => _38.updatedAt, 'optionalAccess', _39 => _39.toISOString, 'call', _40 => _40()])
|
|
1633
1676
|
},
|
|
1634
1677
|
options
|
|
1635
1678
|
);
|
|
@@ -1655,7 +1698,7 @@ var Liveblocks = class {
|
|
|
1655
1698
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/add-reaction`,
|
|
1656
1699
|
{
|
|
1657
1700
|
...data,
|
|
1658
|
-
createdAt: _optionalChain([data, 'access',
|
|
1701
|
+
createdAt: _optionalChain([data, 'access', _41 => _41.createdAt, 'optionalAccess', _42 => _42.toISOString, 'call', _43 => _43()])
|
|
1659
1702
|
},
|
|
1660
1703
|
options
|
|
1661
1704
|
);
|
|
@@ -1681,7 +1724,7 @@ var Liveblocks = class {
|
|
|
1681
1724
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${params.commentId}/remove-reaction`,
|
|
1682
1725
|
{
|
|
1683
1726
|
...data,
|
|
1684
|
-
removedAt: _optionalChain([data, 'access',
|
|
1727
|
+
removedAt: _optionalChain([data, 'access', _44 => _44.removedAt, 'optionalAccess', _45 => _45.toISOString, 'call', _46 => _46()])
|
|
1685
1728
|
},
|
|
1686
1729
|
options
|
|
1687
1730
|
);
|
|
@@ -1762,7 +1805,7 @@ var Liveblocks = class {
|
|
|
1762
1805
|
*/
|
|
1763
1806
|
async *iterInboxNotifications(criteria, options) {
|
|
1764
1807
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
1765
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1808
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _47 => _47.pageSize]), () => ( 50)), 10);
|
|
1766
1809
|
let cursor = void 0;
|
|
1767
1810
|
while (true) {
|
|
1768
1811
|
const { nextCursor, data } = await this.getInboxNotifications(
|
|
@@ -2109,7 +2152,7 @@ var Liveblocks = class {
|
|
|
2109
2152
|
async getGroups(params, options) {
|
|
2110
2153
|
const res = await this.#get(
|
|
2111
2154
|
_core.url`/v2/groups`,
|
|
2112
|
-
{ startingAfter: _optionalChain([params, 'optionalAccess',
|
|
2155
|
+
{ startingAfter: _optionalChain([params, 'optionalAccess', _48 => _48.startingAfter]), limit: _optionalChain([params, 'optionalAccess', _49 => _49.limit]) },
|
|
2113
2156
|
options
|
|
2114
2157
|
);
|
|
2115
2158
|
if (!res.ok) {
|
|
@@ -2171,7 +2214,7 @@ var Liveblocks = class {
|
|
|
2171
2214
|
async massMutateStorage(criteria, callback, massOptions) {
|
|
2172
2215
|
const concurrency = _core.checkBounds.call(void 0,
|
|
2173
2216
|
"concurrency",
|
|
2174
|
-
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess',
|
|
2217
|
+
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess', _50 => _50.concurrency]), () => ( 8)),
|
|
2175
2218
|
1,
|
|
2176
2219
|
20
|
|
2177
2220
|
);
|
|
@@ -2187,7 +2230,7 @@ var Liveblocks = class {
|
|
|
2187
2230
|
}
|
|
2188
2231
|
async #_mutateOneRoom(roomId, room, callback, options) {
|
|
2189
2232
|
const debounceInterval = 200;
|
|
2190
|
-
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess',
|
|
2233
|
+
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess', _51 => _51.signal]));
|
|
2191
2234
|
let opsBuffer = [];
|
|
2192
2235
|
let outstandingFlush$ = void 0;
|
|
2193
2236
|
let lastFlush = performance.now();
|
|
@@ -2253,7 +2296,7 @@ var Liveblocks = class {
|
|
|
2253
2296
|
const res = await this.#post(
|
|
2254
2297
|
_core.url`/v2/rooms/${roomId}/send-message`,
|
|
2255
2298
|
{ messages },
|
|
2256
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2299
|
+
{ signal: _optionalChain([options, 'optionalAccess', _52 => _52.signal]) }
|
|
2257
2300
|
);
|
|
2258
2301
|
if (!res.ok) {
|
|
2259
2302
|
throw await LiveblocksError.from(res);
|
|
@@ -2390,7 +2433,7 @@ var Liveblocks = class {
|
|
|
2390
2433
|
"Content-Type": params.file.type,
|
|
2391
2434
|
"Content-Length": String(params.file.size)
|
|
2392
2435
|
},
|
|
2393
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
2436
|
+
signal: _optionalChain([options, 'optionalAccess', _53 => _53.signal])
|
|
2394
2437
|
}
|
|
2395
2438
|
);
|
|
2396
2439
|
if (!res.ok) {
|
|
@@ -2766,7 +2809,7 @@ var WHITESPACE_REGEX = /\s/;
|
|
|
2766
2809
|
var MarkedCustomTokenizer = class extends _marked.Tokenizer {
|
|
2767
2810
|
url(src) {
|
|
2768
2811
|
const token = super.url(src);
|
|
2769
|
-
if (_optionalChain([token, 'optionalAccess',
|
|
2812
|
+
if (_optionalChain([token, 'optionalAccess', _54 => _54.href, 'access', _55 => _55.startsWith, 'call', _56 => _56("mailto:")])) {
|
|
2770
2813
|
return void 0;
|
|
2771
2814
|
}
|
|
2772
2815
|
return token;
|
|
@@ -2946,7 +2989,7 @@ function tokensToCommentBodyInlines(tokens, formatting = {}) {
|
|
|
2946
2989
|
case "escape":
|
|
2947
2990
|
case "html":
|
|
2948
2991
|
case "text": {
|
|
2949
|
-
if (token.type === "text" && _optionalChain([token, 'access',
|
|
2992
|
+
if (token.type === "text" && _optionalChain([token, 'access', _57 => _57.tokens, 'optionalAccess', _58 => _58.length])) {
|
|
2950
2993
|
appendFormattedInlinesFromTokens(inlines, token.tokens, formatting);
|
|
2951
2994
|
} else {
|
|
2952
2995
|
appendTextWithMentions(inlines, token.text, formatting);
|