@liveblocks/node 3.22.0-rc1 → 3.23.0-file1
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 +327 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -3
- package/dist/index.d.ts +68 -3
- package/dist/index.js +300 -8
- 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.
|
|
6
|
+
var PKG_VERSION = "3.23.0-file1";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -25,6 +25,11 @@ var PKG_FORMAT = "cjs";
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
|
|
@@ -64,8 +69,8 @@ var LineStream = class extends TransformStream {
|
|
|
64
69
|
constructor() {
|
|
65
70
|
let buffer = "";
|
|
66
71
|
super({
|
|
67
|
-
transform(
|
|
68
|
-
buffer +=
|
|
72
|
+
transform(chunk2, controller) {
|
|
73
|
+
buffer += chunk2;
|
|
69
74
|
if (buffer.includes("\n")) {
|
|
70
75
|
const lines = buffer.split("\n");
|
|
71
76
|
for (let i = 0; i < lines.length - 1; i++) {
|
|
@@ -289,6 +294,120 @@ var Session = (_class = class {
|
|
|
289
294
|
}, _class);
|
|
290
295
|
|
|
291
296
|
// src/client.ts
|
|
297
|
+
var STORAGE_FILE_PART_SIZE = 5 * 1024 * 1024;
|
|
298
|
+
var STORAGE_FILE_RETRY_ATTEMPTS = 10;
|
|
299
|
+
var STORAGE_FILE_RETRY_DELAYS = [
|
|
300
|
+
2e3,
|
|
301
|
+
2e3,
|
|
302
|
+
2e3,
|
|
303
|
+
2e3,
|
|
304
|
+
2e3,
|
|
305
|
+
2e3,
|
|
306
|
+
2e3,
|
|
307
|
+
2e3,
|
|
308
|
+
2e3,
|
|
309
|
+
2e3
|
|
310
|
+
];
|
|
311
|
+
async function uploadStorageFile({
|
|
312
|
+
file,
|
|
313
|
+
signal,
|
|
314
|
+
abortErrorMessage,
|
|
315
|
+
uploadSingle,
|
|
316
|
+
createMultipartUpload,
|
|
317
|
+
uploadMultipartPart,
|
|
318
|
+
completeMultipartUpload,
|
|
319
|
+
abortMultipartUpload
|
|
320
|
+
}) {
|
|
321
|
+
const abortError = createAbortError(abortErrorMessage);
|
|
322
|
+
if (_optionalChain([signal, 'optionalAccess', _2 => _2.aborted])) {
|
|
323
|
+
throw abortError;
|
|
324
|
+
}
|
|
325
|
+
const handleRetryError = (err) => {
|
|
326
|
+
if (_optionalChain([signal, 'optionalAccess', _3 => _3.aborted])) {
|
|
327
|
+
throw abortError;
|
|
328
|
+
}
|
|
329
|
+
if (err instanceof LiveblocksError && err.status === 413) {
|
|
330
|
+
throw err;
|
|
331
|
+
}
|
|
332
|
+
return false;
|
|
333
|
+
};
|
|
334
|
+
if (file.size <= STORAGE_FILE_PART_SIZE) {
|
|
335
|
+
return _core.autoRetry.call(void 0,
|
|
336
|
+
uploadSingle,
|
|
337
|
+
STORAGE_FILE_RETRY_ATTEMPTS,
|
|
338
|
+
STORAGE_FILE_RETRY_DELAYS,
|
|
339
|
+
handleRetryError
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
let uploadId;
|
|
343
|
+
const uploadedParts = [];
|
|
344
|
+
const multipartUpload = await _core.autoRetry.call(void 0,
|
|
345
|
+
createMultipartUpload,
|
|
346
|
+
STORAGE_FILE_RETRY_ATTEMPTS,
|
|
347
|
+
STORAGE_FILE_RETRY_DELAYS,
|
|
348
|
+
handleRetryError
|
|
349
|
+
);
|
|
350
|
+
try {
|
|
351
|
+
uploadId = multipartUpload.uploadId;
|
|
352
|
+
if (_optionalChain([signal, 'optionalAccess', _4 => _4.aborted])) {
|
|
353
|
+
throw abortError;
|
|
354
|
+
}
|
|
355
|
+
const batches = _core.chunk.call(void 0, splitStorageFileIntoParts(file), 5);
|
|
356
|
+
for (const parts of batches) {
|
|
357
|
+
const uploadedPartPromises = [];
|
|
358
|
+
for (const { part, partNumber } of parts) {
|
|
359
|
+
uploadedPartPromises.push(
|
|
360
|
+
_core.autoRetry.call(void 0,
|
|
361
|
+
() => uploadMultipartPart(multipartUpload.uploadId, partNumber, part),
|
|
362
|
+
STORAGE_FILE_RETRY_ATTEMPTS,
|
|
363
|
+
STORAGE_FILE_RETRY_DELAYS,
|
|
364
|
+
handleRetryError
|
|
365
|
+
)
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
uploadedParts.push(...await Promise.all(uploadedPartPromises));
|
|
369
|
+
}
|
|
370
|
+
if (_optionalChain([signal, 'optionalAccess', _5 => _5.aborted])) {
|
|
371
|
+
throw abortError;
|
|
372
|
+
}
|
|
373
|
+
return completeMultipartUpload(
|
|
374
|
+
multipartUpload.uploadId,
|
|
375
|
+
uploadedParts.sort((a, b) => a.partNumber - b.partNumber)
|
|
376
|
+
);
|
|
377
|
+
} catch (err) {
|
|
378
|
+
if (uploadId && isAbortOrTimeoutError(err)) {
|
|
379
|
+
try {
|
|
380
|
+
await abortMultipartUpload(uploadId);
|
|
381
|
+
} catch (e2) {
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
throw err;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
function splitStorageFileIntoParts(file) {
|
|
388
|
+
const parts = [];
|
|
389
|
+
let start = 0;
|
|
390
|
+
while (start < file.size) {
|
|
391
|
+
const end = Math.min(start + STORAGE_FILE_PART_SIZE, file.size);
|
|
392
|
+
parts.push({
|
|
393
|
+
partNumber: parts.length + 1,
|
|
394
|
+
part: file.slice(start, end)
|
|
395
|
+
});
|
|
396
|
+
start = end;
|
|
397
|
+
}
|
|
398
|
+
return parts;
|
|
399
|
+
}
|
|
400
|
+
function isAbortOrTimeoutError(err) {
|
|
401
|
+
return err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
|
|
402
|
+
}
|
|
403
|
+
function createAbortError(message) {
|
|
404
|
+
if (typeof DOMException === "function") {
|
|
405
|
+
return new DOMException(message, "AbortError");
|
|
406
|
+
}
|
|
407
|
+
const err = new Error(message);
|
|
408
|
+
err.name = "AbortError";
|
|
409
|
+
return err;
|
|
410
|
+
}
|
|
292
411
|
function inflateRoomData(room) {
|
|
293
412
|
const createdAt = new Date(room.createdAt);
|
|
294
413
|
const lastConnectionAt = room.lastConnectionAt ? new Date(room.lastConnectionAt) : void 0;
|
|
@@ -337,6 +456,12 @@ function inflateWebKnowledgeSourceLink(link) {
|
|
|
337
456
|
lastIndexedAt: new Date(link.lastIndexedAt)
|
|
338
457
|
};
|
|
339
458
|
}
|
|
459
|
+
function inflateHistoryVersion(version) {
|
|
460
|
+
return {
|
|
461
|
+
...version,
|
|
462
|
+
createdAt: new Date(version.createdAt)
|
|
463
|
+
};
|
|
464
|
+
}
|
|
340
465
|
var Liveblocks = class {
|
|
341
466
|
#secret;
|
|
342
467
|
#baseUrl;
|
|
@@ -353,8 +478,8 @@ var Liveblocks = class {
|
|
|
353
478
|
this.#baseUrl = new URL(getBaseUrl(options.baseUrl));
|
|
354
479
|
this.#localDev = !!options.baseUrl && /^https?:\/\/localhost[:/]/.test(options.baseUrl);
|
|
355
480
|
}
|
|
356
|
-
async #post(path, json, options) {
|
|
357
|
-
const url3 = _core.urljoin.call(void 0, this.#baseUrl, path);
|
|
481
|
+
async #post(path, json, options, params) {
|
|
482
|
+
const url3 = _core.urljoin.call(void 0, this.#baseUrl, path, params);
|
|
358
483
|
const headers = {
|
|
359
484
|
Authorization: `Bearer ${this.#secret}`,
|
|
360
485
|
"Content-Type": "application/json"
|
|
@@ -364,11 +489,17 @@ var Liveblocks = class {
|
|
|
364
489
|
method: "POST",
|
|
365
490
|
headers,
|
|
366
491
|
body: JSON.stringify(json),
|
|
367
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
492
|
+
signal: _optionalChain([options, 'optionalAccess', _6 => _6.signal])
|
|
368
493
|
});
|
|
369
494
|
xwarn(res, "POST", path);
|
|
370
495
|
return res;
|
|
371
496
|
}
|
|
497
|
+
async #readJsonResponse(res) {
|
|
498
|
+
if (!res.ok) {
|
|
499
|
+
throw await LiveblocksError.from(res);
|
|
500
|
+
}
|
|
501
|
+
return await res.json();
|
|
502
|
+
}
|
|
372
503
|
async #patch(path, json, options) {
|
|
373
504
|
const url3 = _core.urljoin.call(void 0, this.#baseUrl, path);
|
|
374
505
|
const headers = {
|
|
@@ -380,7 +511,7 @@ var Liveblocks = class {
|
|
|
380
511
|
method: "PATCH",
|
|
381
512
|
headers,
|
|
382
513
|
body: JSON.stringify(json),
|
|
383
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
514
|
+
signal: _optionalChain([options, 'optionalAccess', _7 => _7.signal])
|
|
384
515
|
});
|
|
385
516
|
xwarn(res, "PATCH", path);
|
|
386
517
|
return res;
|
|
@@ -396,7 +527,23 @@ var Liveblocks = class {
|
|
|
396
527
|
method: "PUT",
|
|
397
528
|
headers,
|
|
398
529
|
body,
|
|
399
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
530
|
+
signal: _optionalChain([options, 'optionalAccess', _8 => _8.signal])
|
|
531
|
+
});
|
|
532
|
+
xwarn(res, "PUT", path);
|
|
533
|
+
return res;
|
|
534
|
+
}
|
|
535
|
+
async #putBlob(path, body, params, options) {
|
|
536
|
+
const url3 = _core.urljoin.call(void 0, this.#baseUrl, path, params);
|
|
537
|
+
const headers = {
|
|
538
|
+
Authorization: `Bearer ${this.#secret}`,
|
|
539
|
+
"Content-Type": "application/octet-stream"
|
|
540
|
+
};
|
|
541
|
+
const fetch = await fetchPolyfill();
|
|
542
|
+
const res = await fetch(url3, {
|
|
543
|
+
method: "PUT",
|
|
544
|
+
headers,
|
|
545
|
+
body,
|
|
546
|
+
signal: _optionalChain([options, 'optionalAccess', _9 => _9.signal])
|
|
400
547
|
});
|
|
401
548
|
xwarn(res, "PUT", path);
|
|
402
549
|
return res;
|
|
@@ -410,7 +557,7 @@ var Liveblocks = class {
|
|
|
410
557
|
const res = await fetch(url3, {
|
|
411
558
|
method: "DELETE",
|
|
412
559
|
headers,
|
|
413
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
560
|
+
signal: _optionalChain([options, 'optionalAccess', _10 => _10.signal])
|
|
414
561
|
});
|
|
415
562
|
xwarn(res, "DELETE", path);
|
|
416
563
|
return res;
|
|
@@ -424,7 +571,7 @@ var Liveblocks = class {
|
|
|
424
571
|
const res = await fetch(url3, {
|
|
425
572
|
method: "GET",
|
|
426
573
|
headers,
|
|
427
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
574
|
+
signal: _optionalChain([options, 'optionalAccess', _11 => _11.signal])
|
|
428
575
|
});
|
|
429
576
|
xwarn(res, "GET", path);
|
|
430
577
|
return res;
|
|
@@ -455,8 +602,8 @@ var Liveblocks = class {
|
|
|
455
602
|
return new Session(
|
|
456
603
|
this.#post.bind(this),
|
|
457
604
|
userId,
|
|
458
|
-
_optionalChain([options, 'optionalAccess',
|
|
459
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
605
|
+
_optionalChain([options, 'optionalAccess', _12 => _12.userInfo]),
|
|
606
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _13 => _13.organizationId]), () => ( _optionalChain([options, 'optionalAccess', _14 => _14.tenantId]))),
|
|
460
607
|
this.#localDev
|
|
461
608
|
);
|
|
462
609
|
}
|
|
@@ -506,7 +653,7 @@ var Liveblocks = class {
|
|
|
506
653
|
const body = {
|
|
507
654
|
userId,
|
|
508
655
|
groupIds,
|
|
509
|
-
userInfo: _optionalChain([options, 'optionalAccess',
|
|
656
|
+
userInfo: _optionalChain([options, 'optionalAccess', _15 => _15.userInfo])
|
|
510
657
|
};
|
|
511
658
|
if (organizationId !== void 0) {
|
|
512
659
|
body.organizationId = organizationId;
|
|
@@ -592,7 +739,7 @@ var Liveblocks = class {
|
|
|
592
739
|
*/
|
|
593
740
|
async *iterRooms(criteria, options) {
|
|
594
741
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
595
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
742
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _16 => _16.pageSize]), () => ( 40)), 20);
|
|
596
743
|
let cursor = void 0;
|
|
597
744
|
while (true) {
|
|
598
745
|
const { nextCursor, data } = await this.getRooms(
|
|
@@ -642,7 +789,7 @@ var Liveblocks = class {
|
|
|
642
789
|
body.organizationId = tenantId;
|
|
643
790
|
}
|
|
644
791
|
const res = await this.#post(
|
|
645
|
-
_optionalChain([options, 'optionalAccess',
|
|
792
|
+
_optionalChain([options, 'optionalAccess', _17 => _17.idempotent]) ? _core.url`/v2/rooms?idempotent` : _core.url`/v2/rooms`,
|
|
646
793
|
body,
|
|
647
794
|
options
|
|
648
795
|
);
|
|
@@ -777,7 +924,7 @@ var Liveblocks = class {
|
|
|
777
924
|
*/
|
|
778
925
|
async getActiveUsers(roomId, options) {
|
|
779
926
|
const res = await this.#get(
|
|
780
|
-
_core.url`/v2/rooms/${roomId}/
|
|
927
|
+
_core.url`/v2/rooms/${roomId}/active-users`,
|
|
781
928
|
void 0,
|
|
782
929
|
options
|
|
783
930
|
);
|
|
@@ -794,7 +941,7 @@ var Liveblocks = class {
|
|
|
794
941
|
*/
|
|
795
942
|
async broadcastEvent(roomId, message, options) {
|
|
796
943
|
const res = await this.#post(
|
|
797
|
-
_core.url`/v2/rooms/${roomId}/
|
|
944
|
+
_core.url`/v2/rooms/${roomId}/broadcast-event`,
|
|
798
945
|
message,
|
|
799
946
|
options
|
|
800
947
|
);
|
|
@@ -961,6 +1108,82 @@ var Liveblocks = class {
|
|
|
961
1108
|
}
|
|
962
1109
|
return res.arrayBuffer();
|
|
963
1110
|
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Returns the version history snapshots for the room, sorted by creation date from newest to oldest.
|
|
1113
|
+
* @param roomId The ID of the room to get the version history from.
|
|
1114
|
+
* @param params.limit (optional) The number of versions to return. The limit can range between 1 and 100, and defaults to 20.
|
|
1115
|
+
* @param params.cursor (optional) A cursor used for pagination. Get the value from the `nextCursor` response of the previous page.
|
|
1116
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1117
|
+
* @returns A list of version history snapshots and the next page cursor.
|
|
1118
|
+
*/
|
|
1119
|
+
async getVersionHistory(roomId, params = {}, options) {
|
|
1120
|
+
const res = await this.#get(
|
|
1121
|
+
_core.url`/v2/rooms/${roomId}/versions`,
|
|
1122
|
+
{ limit: params.limit, cursor: params.cursor },
|
|
1123
|
+
options
|
|
1124
|
+
);
|
|
1125
|
+
if (!res.ok) {
|
|
1126
|
+
throw await LiveblocksError.from(res);
|
|
1127
|
+
}
|
|
1128
|
+
const page = await res.json();
|
|
1129
|
+
return {
|
|
1130
|
+
nextCursor: page.nextCursor,
|
|
1131
|
+
data: page.data.map(inflateHistoryVersion)
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Creates a new version history snapshot of the room, capturing both its Storage and Yjs documents.
|
|
1136
|
+
* @param roomId The ID of the room to create a version history snapshot for.
|
|
1137
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1138
|
+
* @returns The created version ID.
|
|
1139
|
+
*/
|
|
1140
|
+
async createVersionHistorySnapshot(roomId, options) {
|
|
1141
|
+
const res = await this.#post(
|
|
1142
|
+
_core.url`/v2/rooms/${roomId}/versions`,
|
|
1143
|
+
{},
|
|
1144
|
+
options
|
|
1145
|
+
);
|
|
1146
|
+
if (!res.ok) {
|
|
1147
|
+
throw await LiveblocksError.from(res);
|
|
1148
|
+
}
|
|
1149
|
+
return await res.json();
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Returns a specific version of the room's Yjs document encoded as a binary Yjs update.
|
|
1153
|
+
* @param params.roomId The room ID to get the Yjs document version from.
|
|
1154
|
+
* @param params.versionId The ID of the version to get.
|
|
1155
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1156
|
+
* @returns The version's Yjs document encoded as a binary update.
|
|
1157
|
+
*/
|
|
1158
|
+
async getYjsVersion(params, options) {
|
|
1159
|
+
const { roomId, versionId } = params;
|
|
1160
|
+
const res = await this.#get(
|
|
1161
|
+
_core.url`/v2/rooms/${roomId}/versions/${versionId}/yjs`,
|
|
1162
|
+
void 0,
|
|
1163
|
+
options
|
|
1164
|
+
);
|
|
1165
|
+
if (!res.ok) {
|
|
1166
|
+
throw await LiveblocksError.from(res);
|
|
1167
|
+
}
|
|
1168
|
+
return res.arrayBuffer();
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Permanently deletes a version from the room's history.
|
|
1172
|
+
* @param params.roomId The room ID to delete the version in.
|
|
1173
|
+
* @param params.versionId The ID of the version to delete.
|
|
1174
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1175
|
+
*/
|
|
1176
|
+
async deleteVersion(params, options) {
|
|
1177
|
+
const { roomId, versionId } = params;
|
|
1178
|
+
const res = await this.#delete(
|
|
1179
|
+
_core.url`/v2/rooms/${roomId}/versions/${versionId}`,
|
|
1180
|
+
void 0,
|
|
1181
|
+
options
|
|
1182
|
+
);
|
|
1183
|
+
if (!res.ok) {
|
|
1184
|
+
throw await LiveblocksError.from(res);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
964
1187
|
/* -------------------------------------------------------------------------------------------------
|
|
965
1188
|
* Comments
|
|
966
1189
|
* -----------------------------------------------------------------------------------------------*/
|
|
@@ -1102,7 +1325,7 @@ var Liveblocks = class {
|
|
|
1102
1325
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments`,
|
|
1103
1326
|
{
|
|
1104
1327
|
...data,
|
|
1105
|
-
createdAt: _optionalChain([data, 'access',
|
|
1328
|
+
createdAt: _optionalChain([data, 'access', _18 => _18.createdAt, 'optionalAccess', _19 => _19.toISOString, 'call', _20 => _20()])
|
|
1106
1329
|
},
|
|
1107
1330
|
options
|
|
1108
1331
|
);
|
|
@@ -1128,7 +1351,7 @@ var Liveblocks = class {
|
|
|
1128
1351
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
|
|
1129
1352
|
{
|
|
1130
1353
|
body: data.body,
|
|
1131
|
-
editedAt: _optionalChain([data, 'access',
|
|
1354
|
+
editedAt: _optionalChain([data, 'access', _21 => _21.editedAt, 'optionalAccess', _22 => _22.toISOString, 'call', _23 => _23()]),
|
|
1132
1355
|
metadata: data.metadata
|
|
1133
1356
|
},
|
|
1134
1357
|
options
|
|
@@ -1176,6 +1399,73 @@ var Liveblocks = class {
|
|
|
1176
1399
|
}
|
|
1177
1400
|
return await res.json();
|
|
1178
1401
|
}
|
|
1402
|
+
async uploadFile(params, options) {
|
|
1403
|
+
const { roomId, file } = params;
|
|
1404
|
+
const fileId = _core.createStorageFileId.call(void 0, );
|
|
1405
|
+
const fileData = await uploadStorageFile({
|
|
1406
|
+
file,
|
|
1407
|
+
signal: _optionalChain([options, 'optionalAccess', _24 => _24.signal]),
|
|
1408
|
+
abortErrorMessage: `Upload of file ${fileId} was aborted.`,
|
|
1409
|
+
uploadSingle: async () => {
|
|
1410
|
+
const res = await this.#putBlob(
|
|
1411
|
+
_core.url`/v2/rooms/${roomId}/storage/files/${fileId}/upload/${file.name}`,
|
|
1412
|
+
file,
|
|
1413
|
+
{ fileSize: file.size },
|
|
1414
|
+
options
|
|
1415
|
+
);
|
|
1416
|
+
return await this.#readJsonResponse(res);
|
|
1417
|
+
},
|
|
1418
|
+
createMultipartUpload: async () => {
|
|
1419
|
+
const res = await this.#post(
|
|
1420
|
+
_core.url`/v2/rooms/${roomId}/storage/files/${fileId}/multipart/${file.name}`,
|
|
1421
|
+
void 0,
|
|
1422
|
+
options,
|
|
1423
|
+
{ fileSize: file.size }
|
|
1424
|
+
);
|
|
1425
|
+
return await this.#readJsonResponse(res);
|
|
1426
|
+
},
|
|
1427
|
+
uploadMultipartPart: async (uploadId, partNumber, part) => {
|
|
1428
|
+
const res = await this.#putBlob(
|
|
1429
|
+
_core.url`/v2/rooms/${roomId}/storage/files/${fileId}/multipart/${uploadId}/${String(partNumber)}`,
|
|
1430
|
+
part,
|
|
1431
|
+
void 0,
|
|
1432
|
+
options
|
|
1433
|
+
);
|
|
1434
|
+
return await this.#readJsonResponse(res);
|
|
1435
|
+
},
|
|
1436
|
+
completeMultipartUpload: async (uploadId, parts) => {
|
|
1437
|
+
const res = await this.#post(
|
|
1438
|
+
_core.url`/v2/rooms/${roomId}/storage/files/${fileId}/multipart/${uploadId}/complete`,
|
|
1439
|
+
{ parts },
|
|
1440
|
+
options
|
|
1441
|
+
);
|
|
1442
|
+
return await this.#readJsonResponse(res);
|
|
1443
|
+
},
|
|
1444
|
+
abortMultipartUpload: async (uploadId) => {
|
|
1445
|
+
const res = await this.#delete(
|
|
1446
|
+
_core.url`/v2/rooms/${roomId}/storage/files/${fileId}/multipart/${uploadId}`
|
|
1447
|
+
);
|
|
1448
|
+
if (!res.ok) {
|
|
1449
|
+
throw await LiveblocksError.from(res);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
return new (0, _core.LiveFile)(fileData);
|
|
1454
|
+
}
|
|
1455
|
+
async getFileUrl(params, options) {
|
|
1456
|
+
const { roomId, file } = params;
|
|
1457
|
+
const fileId = _core.getLiveFileId.call(void 0, file);
|
|
1458
|
+
const res = await this.#get(
|
|
1459
|
+
_core.url`/v2/rooms/${roomId}/storage/files/${fileId}`,
|
|
1460
|
+
void 0,
|
|
1461
|
+
options
|
|
1462
|
+
);
|
|
1463
|
+
const storageFile = await this.#readJsonResponse(res);
|
|
1464
|
+
return {
|
|
1465
|
+
url: storageFile.url,
|
|
1466
|
+
expiresAt: storageFile.expiresAt
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1179
1469
|
/**
|
|
1180
1470
|
* Creates a new thread. The thread will be created with the specified comment as its first comment.
|
|
1181
1471
|
* If the thread already exists, a `LiveblocksError` will be thrown with status code 409.
|
|
@@ -1196,7 +1486,7 @@ var Liveblocks = class {
|
|
|
1196
1486
|
...data,
|
|
1197
1487
|
comment: {
|
|
1198
1488
|
...data.comment,
|
|
1199
|
-
createdAt: _optionalChain([data, 'access',
|
|
1489
|
+
createdAt: _optionalChain([data, 'access', _25 => _25.comment, 'access', _26 => _26.createdAt, 'optionalAccess', _27 => _27.toISOString, 'call', _28 => _28()])
|
|
1200
1490
|
}
|
|
1201
1491
|
},
|
|
1202
1492
|
options
|
|
@@ -1319,7 +1609,7 @@ var Liveblocks = class {
|
|
|
1319
1609
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/metadata`,
|
|
1320
1610
|
{
|
|
1321
1611
|
...data,
|
|
1322
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1612
|
+
updatedAt: _optionalChain([data, 'access', _29 => _29.updatedAt, 'optionalAccess', _30 => _30.toISOString, 'call', _31 => _31()])
|
|
1323
1613
|
},
|
|
1324
1614
|
options
|
|
1325
1615
|
);
|
|
@@ -1345,7 +1635,7 @@ var Liveblocks = class {
|
|
|
1345
1635
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/metadata`,
|
|
1346
1636
|
{
|
|
1347
1637
|
...data,
|
|
1348
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1638
|
+
updatedAt: _optionalChain([data, 'access', _32 => _32.updatedAt, 'optionalAccess', _33 => _33.toISOString, 'call', _34 => _34()])
|
|
1349
1639
|
},
|
|
1350
1640
|
options
|
|
1351
1641
|
);
|
|
@@ -1371,7 +1661,7 @@ var Liveblocks = class {
|
|
|
1371
1661
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/add-reaction`,
|
|
1372
1662
|
{
|
|
1373
1663
|
...data,
|
|
1374
|
-
createdAt: _optionalChain([data, 'access',
|
|
1664
|
+
createdAt: _optionalChain([data, 'access', _35 => _35.createdAt, 'optionalAccess', _36 => _36.toISOString, 'call', _37 => _37()])
|
|
1375
1665
|
},
|
|
1376
1666
|
options
|
|
1377
1667
|
);
|
|
@@ -1397,7 +1687,7 @@ var Liveblocks = class {
|
|
|
1397
1687
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${params.commentId}/remove-reaction`,
|
|
1398
1688
|
{
|
|
1399
1689
|
...data,
|
|
1400
|
-
removedAt: _optionalChain([data, 'access',
|
|
1690
|
+
removedAt: _optionalChain([data, 'access', _38 => _38.removedAt, 'optionalAccess', _39 => _39.toISOString, 'call', _40 => _40()])
|
|
1401
1691
|
},
|
|
1402
1692
|
options
|
|
1403
1693
|
);
|
|
@@ -1478,7 +1768,7 @@ var Liveblocks = class {
|
|
|
1478
1768
|
*/
|
|
1479
1769
|
async *iterInboxNotifications(criteria, options) {
|
|
1480
1770
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
1481
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1771
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.pageSize]), () => ( 50)), 10);
|
|
1482
1772
|
let cursor = void 0;
|
|
1483
1773
|
while (true) {
|
|
1484
1774
|
const { nextCursor, data } = await this.getInboxNotifications(
|
|
@@ -1825,7 +2115,7 @@ var Liveblocks = class {
|
|
|
1825
2115
|
async getGroups(params, options) {
|
|
1826
2116
|
const res = await this.#get(
|
|
1827
2117
|
_core.url`/v2/groups`,
|
|
1828
|
-
{ startingAfter: _optionalChain([params, 'optionalAccess',
|
|
2118
|
+
{ startingAfter: _optionalChain([params, 'optionalAccess', _42 => _42.startingAfter]), limit: _optionalChain([params, 'optionalAccess', _43 => _43.limit]) },
|
|
1829
2119
|
options
|
|
1830
2120
|
);
|
|
1831
2121
|
if (!res.ok) {
|
|
@@ -1887,7 +2177,7 @@ var Liveblocks = class {
|
|
|
1887
2177
|
async massMutateStorage(criteria, callback, massOptions) {
|
|
1888
2178
|
const concurrency = _core.checkBounds.call(void 0,
|
|
1889
2179
|
"concurrency",
|
|
1890
|
-
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess',
|
|
2180
|
+
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess', _44 => _44.concurrency]), () => ( 8)),
|
|
1891
2181
|
1,
|
|
1892
2182
|
20
|
|
1893
2183
|
);
|
|
@@ -1903,7 +2193,7 @@ var Liveblocks = class {
|
|
|
1903
2193
|
}
|
|
1904
2194
|
async #_mutateOneRoom(roomId, room, callback, options) {
|
|
1905
2195
|
const debounceInterval = 200;
|
|
1906
|
-
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess',
|
|
2196
|
+
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess', _45 => _45.signal]));
|
|
1907
2197
|
let opsBuffer = [];
|
|
1908
2198
|
let outstandingFlush$ = void 0;
|
|
1909
2199
|
let lastFlush = performance.now();
|
|
@@ -1933,7 +2223,7 @@ var Liveblocks = class {
|
|
|
1933
2223
|
try {
|
|
1934
2224
|
const resp = await this.#requestStorageMutation(roomId, { signal });
|
|
1935
2225
|
const { actor, nodes } = resp;
|
|
1936
|
-
const pool = _core.createManagedPool.call(void 0,
|
|
2226
|
+
const pool = _core.createManagedPool.call(void 0, {
|
|
1937
2227
|
getCurrentConnectionId: () => actor,
|
|
1938
2228
|
onDispatch: (ops, _reverse, _storageUpdates) => {
|
|
1939
2229
|
if (ops.length === 0) return;
|
|
@@ -1969,7 +2259,7 @@ var Liveblocks = class {
|
|
|
1969
2259
|
const res = await this.#post(
|
|
1970
2260
|
_core.url`/v2/rooms/${roomId}/send-message`,
|
|
1971
2261
|
{ messages },
|
|
1972
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2262
|
+
{ signal: _optionalChain([options, 'optionalAccess', _46 => _46.signal]) }
|
|
1973
2263
|
);
|
|
1974
2264
|
if (!res.ok) {
|
|
1975
2265
|
throw await LiveblocksError.from(res);
|
|
@@ -2106,7 +2396,7 @@ var Liveblocks = class {
|
|
|
2106
2396
|
"Content-Type": params.file.type,
|
|
2107
2397
|
"Content-Length": String(params.file.size)
|
|
2108
2398
|
},
|
|
2109
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
2399
|
+
signal: _optionalChain([options, 'optionalAccess', _47 => _47.signal])
|
|
2110
2400
|
}
|
|
2111
2401
|
);
|
|
2112
2402
|
if (!res.ok) {
|
|
@@ -2453,7 +2743,7 @@ ${this.details}`;
|
|
|
2453
2743
|
let text;
|
|
2454
2744
|
try {
|
|
2455
2745
|
text = await res.text();
|
|
2456
|
-
} catch (
|
|
2746
|
+
} catch (e3) {
|
|
2457
2747
|
text = FALLBACK;
|
|
2458
2748
|
}
|
|
2459
2749
|
const obj = _nullishCoalesce(_core.tryParseJson.call(void 0, text), () => ( { message: text }));
|
|
@@ -2482,7 +2772,7 @@ var WHITESPACE_REGEX = /\s/;
|
|
|
2482
2772
|
var MarkedCustomTokenizer = class extends _marked.Tokenizer {
|
|
2483
2773
|
url(src) {
|
|
2484
2774
|
const token = super.url(src);
|
|
2485
|
-
if (_optionalChain([token, 'optionalAccess',
|
|
2775
|
+
if (_optionalChain([token, 'optionalAccess', _48 => _48.href, 'access', _49 => _49.startsWith, 'call', _50 => _50("mailto:")])) {
|
|
2486
2776
|
return void 0;
|
|
2487
2777
|
}
|
|
2488
2778
|
return token;
|
|
@@ -2662,7 +2952,7 @@ function tokensToCommentBodyInlines(tokens, formatting = {}) {
|
|
|
2662
2952
|
case "escape":
|
|
2663
2953
|
case "html":
|
|
2664
2954
|
case "text": {
|
|
2665
|
-
if (token.type === "text" && _optionalChain([token, 'access',
|
|
2955
|
+
if (token.type === "text" && _optionalChain([token, 'access', _51 => _51.tokens, 'optionalAccess', _52 => _52.length])) {
|
|
2666
2956
|
appendFormattedInlinesFromTokens(inlines, token.tokens, formatting);
|
|
2667
2957
|
} else {
|
|
2668
2958
|
appendTextWithMentions(inlines, token.text, formatting);
|
|
@@ -3001,6 +3291,7 @@ function isCustomNotificationEvent(event) {
|
|
|
3001
3291
|
|
|
3002
3292
|
|
|
3003
3293
|
|
|
3294
|
+
|
|
3004
3295
|
_core.detectDupes.call(void 0, PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
3005
3296
|
|
|
3006
3297
|
|
|
@@ -3016,5 +3307,6 @@ _core.detectDupes.call(void 0, PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
3016
3307
|
|
|
3017
3308
|
|
|
3018
3309
|
|
|
3019
|
-
|
|
3310
|
+
|
|
3311
|
+
exports.LiveFile = _core.LiveFile; exports.LiveList = _core.LiveList; exports.LiveMap = _core.LiveMap; exports.LiveObject = _core.LiveObject; exports.Liveblocks = Liveblocks; exports.LiveblocksError = LiveblocksError; exports.WebhookHandler = WebhookHandler; exports.getMentionsFromCommentBody = _core.getMentionsFromCommentBody; exports.isCustomNotificationEvent = isCustomNotificationEvent; exports.isNotificationChannelEnabled = _core.isNotificationChannelEnabled; exports.isTextMentionNotificationEvent = isTextMentionNotificationEvent; exports.isThreadNotificationEvent = isThreadNotificationEvent; exports.markdownToCommentBody = markdownToCommentBody; exports.stringifyCommentBody = _core.stringifyCommentBody;
|
|
3020
3312
|
//# sourceMappingURL=index.cjs.map
|