@liveblocks/core 3.13.0-vincent3 → 3.13.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 +298 -313
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +232 -211
- package/dist/index.d.ts +232 -211
- package/dist/index.js +229 -244
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -331,6 +331,80 @@ type ContextualPromptContext = {
|
|
|
331
331
|
afterSelection: string;
|
|
332
332
|
};
|
|
333
333
|
|
|
334
|
+
declare const brand: unique symbol;
|
|
335
|
+
type Brand<T, TBrand extends string> = T & {
|
|
336
|
+
[brand]: TBrand;
|
|
337
|
+
};
|
|
338
|
+
type ISODateString = Brand<string, "ISODateString">;
|
|
339
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
|
|
340
|
+
type WithRequired<T, K extends keyof T> = T & {
|
|
341
|
+
[P in K]-?: T[P];
|
|
342
|
+
};
|
|
343
|
+
type WithOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
344
|
+
[P in K]?: T[P];
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Throw an error, but as an expression instead of a statement.
|
|
348
|
+
*/
|
|
349
|
+
declare function raise(msg: string): never;
|
|
350
|
+
/**
|
|
351
|
+
* Drop-in replacement for Object.entries() that retains better types.
|
|
352
|
+
*/
|
|
353
|
+
declare function entries<O extends {
|
|
354
|
+
[key: string]: unknown;
|
|
355
|
+
}, K extends keyof O>(obj: O): [K, O[K]][];
|
|
356
|
+
/**
|
|
357
|
+
* Drop-in replacement for Object.keys() that retains better types.
|
|
358
|
+
*/
|
|
359
|
+
declare function keys<O extends {
|
|
360
|
+
[key: string]: unknown;
|
|
361
|
+
}, K extends keyof O>(obj: O): K[];
|
|
362
|
+
/**
|
|
363
|
+
* Creates a new object by mapping a function over all values. Keys remain the
|
|
364
|
+
* same. Think Array.prototype.map(), but for values in an object.
|
|
365
|
+
*/
|
|
366
|
+
declare function mapValues<V, O extends Record<string, unknown>>(obj: O, mapFn: (value: O[keyof O], key: keyof O) => V): {
|
|
367
|
+
[K in keyof O]: V;
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Alternative to JSON.parse() that will not throw in production. If the passed
|
|
371
|
+
* string cannot be parsed, this will return `undefined`.
|
|
372
|
+
*/
|
|
373
|
+
declare function tryParseJson(rawMessage: string): Json | undefined;
|
|
374
|
+
/**
|
|
375
|
+
* Decode base64 string.
|
|
376
|
+
*/
|
|
377
|
+
declare function b64decode(b64value: string): string;
|
|
378
|
+
type RemoveUndefinedValues<T> = {
|
|
379
|
+
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* Returns a new object instance where all explictly-undefined values are
|
|
383
|
+
* removed.
|
|
384
|
+
*/
|
|
385
|
+
declare function compactObject<O extends Record<string, unknown>>(obj: O): RemoveUndefinedValues<O>;
|
|
386
|
+
/**
|
|
387
|
+
* Returns a promise that resolves after the given number of milliseconds.
|
|
388
|
+
*/
|
|
389
|
+
declare function wait(millis: number): Promise<void>;
|
|
390
|
+
/**
|
|
391
|
+
* Returns whatever the given promise returns, but will be rejected with
|
|
392
|
+
* a "Timed out" error if the given promise does not return or reject within
|
|
393
|
+
* the given timeout period (in milliseconds).
|
|
394
|
+
*/
|
|
395
|
+
declare function withTimeout<T>(promise: Promise<T>, millis: number, errmsg: string): Promise<T>;
|
|
396
|
+
/**
|
|
397
|
+
* Memoize a promise factory, so that each subsequent call will return the same
|
|
398
|
+
* pending or success promise. If the promise rejects, will retain that failed
|
|
399
|
+
* promise for a small time period, after which the next attempt will reset the
|
|
400
|
+
* memoized value.
|
|
401
|
+
*/
|
|
402
|
+
declare function memoizeOnSuccess<T>(factoryFn: () => Promise<T>): () => Promise<T>;
|
|
403
|
+
/**
|
|
404
|
+
* Polyfill for Array.prototype.findLastIndex()
|
|
405
|
+
*/
|
|
406
|
+
declare function findLastIndex<T>(arr: T[], predicate: (value: T, index: number, obj: T[]) => boolean): number;
|
|
407
|
+
|
|
334
408
|
type OpCode = (typeof OpCode)[keyof typeof OpCode];
|
|
335
409
|
declare const OpCode: Readonly<{
|
|
336
410
|
INIT: 0;
|
|
@@ -358,7 +432,7 @@ declare namespace OpCode {
|
|
|
358
432
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
359
433
|
* only.
|
|
360
434
|
*/
|
|
361
|
-
type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp
|
|
435
|
+
type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
|
|
362
436
|
type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
363
437
|
type UpdateObjectOp = {
|
|
364
438
|
readonly opId?: string;
|
|
@@ -426,6 +500,24 @@ type DeleteObjectKeyOp = {
|
|
|
426
500
|
readonly type: OpCode.DELETE_OBJECT_KEY;
|
|
427
501
|
readonly key: string;
|
|
428
502
|
};
|
|
503
|
+
type HasOpId = {
|
|
504
|
+
opId: string;
|
|
505
|
+
};
|
|
506
|
+
/**
|
|
507
|
+
* Ops sent from client → server. Always includes an opId so the server can
|
|
508
|
+
* acknowledge the receipt.
|
|
509
|
+
*/
|
|
510
|
+
type ClientWireOp = Op & HasOpId;
|
|
511
|
+
/**
|
|
512
|
+
* ServerWireOp: Ops sent from server → client. Three variants:
|
|
513
|
+
* 1. ClientWireOp — Full echo back of our own op, confirming it was applied
|
|
514
|
+
* 2. AckOp — Our op was seen but intentionally ignored (still counts as ack)
|
|
515
|
+
* 3. Op without opId — Another client's op being forwarded to us
|
|
516
|
+
*/
|
|
517
|
+
type ServerWireOp = ClientWireOp | AckOp | TheirOp;
|
|
518
|
+
type TheirOp = DistributiveOmit<Op, "opId"> & {
|
|
519
|
+
opId?: undefined;
|
|
520
|
+
};
|
|
429
521
|
|
|
430
522
|
type ClientMsgCode = (typeof ClientMsgCode)[keyof typeof ClientMsgCode];
|
|
431
523
|
declare const ClientMsgCode: Readonly<{
|
|
@@ -480,7 +572,7 @@ type UpdatePresenceClientMsg<P extends JsonObject> = {
|
|
|
480
572
|
};
|
|
481
573
|
type UpdateStorageClientMsg = {
|
|
482
574
|
readonly type: ClientMsgCode.UPDATE_STORAGE;
|
|
483
|
-
readonly ops:
|
|
575
|
+
readonly ops: ClientWireOp[];
|
|
484
576
|
};
|
|
485
577
|
type FetchStorageClientMsg = {
|
|
486
578
|
readonly type: ClientMsgCode.FETCH_STORAGE;
|
|
@@ -590,7 +682,6 @@ declare namespace CrdtType {
|
|
|
590
682
|
}
|
|
591
683
|
type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
592
684
|
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
593
|
-
type NodeStream = Iterable<IdTuple<SerializedCrdt>>;
|
|
594
685
|
type SerializedRootObject = {
|
|
595
686
|
readonly type: CrdtType.OBJECT;
|
|
596
687
|
readonly data: JsonObject;
|
|
@@ -619,36 +710,6 @@ type SerializedRegister = {
|
|
|
619
710
|
readonly parentKey: string;
|
|
620
711
|
readonly data: Json;
|
|
621
712
|
};
|
|
622
|
-
type CompactNode = CompactRootNode | CompactChildNode;
|
|
623
|
-
type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode;
|
|
624
|
-
type CompactRootNode = readonly [id: "root", data: JsonObject];
|
|
625
|
-
type CompactObjectNode = readonly [
|
|
626
|
-
id: string,
|
|
627
|
-
type: CrdtType.OBJECT,
|
|
628
|
-
parentId: string,
|
|
629
|
-
parentKey: string,
|
|
630
|
-
data: JsonObject
|
|
631
|
-
];
|
|
632
|
-
type CompactListNode = readonly [
|
|
633
|
-
id: string,
|
|
634
|
-
type: CrdtType.LIST,
|
|
635
|
-
parentId: string,
|
|
636
|
-
parentKey: string
|
|
637
|
-
];
|
|
638
|
-
type CompactMapNode = readonly [
|
|
639
|
-
id: string,
|
|
640
|
-
type: CrdtType.MAP,
|
|
641
|
-
parentId: string,
|
|
642
|
-
parentKey: string
|
|
643
|
-
];
|
|
644
|
-
type CompactRegisterNode = readonly [
|
|
645
|
-
id: string,
|
|
646
|
-
type: CrdtType.REGISTER,
|
|
647
|
-
parentId: string,
|
|
648
|
-
parentKey: string,
|
|
649
|
-
data: Json
|
|
650
|
-
];
|
|
651
|
-
declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
|
|
652
713
|
|
|
653
714
|
type LiveObjectUpdateDelta<O extends {
|
|
654
715
|
[key: string]: unknown;
|
|
@@ -682,7 +743,7 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
682
743
|
*/
|
|
683
744
|
static detectLargeObjects: boolean;
|
|
684
745
|
/** @private Do not use this API directly */
|
|
685
|
-
static _fromItems<O extends LsonObject>(
|
|
746
|
+
static _fromItems<O extends LsonObject>(items: IdTuple<SerializedCrdt>[], pool: ManagedPool): LiveObject<O>;
|
|
686
747
|
constructor(obj?: O);
|
|
687
748
|
/**
|
|
688
749
|
* Transform the LiveObject into a javascript object
|
|
@@ -838,7 +899,7 @@ interface ManagedPool {
|
|
|
838
899
|
* - Add reverse operations to the undo/redo stack
|
|
839
900
|
* - Notify room subscribers with updates (in-client, no networking)
|
|
840
901
|
*/
|
|
841
|
-
dispatch: (ops:
|
|
902
|
+
dispatch: (ops: ClientWireOp[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
|
|
842
903
|
/**
|
|
843
904
|
* Ensures storage can be written to else throws an error.
|
|
844
905
|
* This is used to prevent writing to storage when the user does not have
|
|
@@ -858,7 +919,7 @@ type CreateManagedPoolOptions = {
|
|
|
858
919
|
/**
|
|
859
920
|
* Will get invoked when any Live structure calls .dispatch() on the pool.
|
|
860
921
|
*/
|
|
861
|
-
onDispatch?: (ops:
|
|
922
|
+
onDispatch?: (ops: ClientWireOp[], reverse: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
|
|
862
923
|
/**
|
|
863
924
|
* Will get invoked when any Live structure calls .assertStorageIsWritable()
|
|
864
925
|
* on the pool. Defaults to true when not provided. Return false if you want
|
|
@@ -1169,7 +1230,7 @@ declare global {
|
|
|
1169
1230
|
[key: string]: unknown;
|
|
1170
1231
|
}
|
|
1171
1232
|
}
|
|
1172
|
-
type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "RoomInfo" | "GroupInfo" | "ActivitiesData";
|
|
1233
|
+
type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "CommentMetadata" | "RoomInfo" | "GroupInfo" | "ActivitiesData";
|
|
1173
1234
|
type MakeErrorString<K extends ExtendableTypes, Reason extends string = "does not match its requirements"> = `The type you provided for '${K}' ${Reason}. To learn how to fix this, see https://liveblocks.io/docs/errors/${K}`;
|
|
1174
1235
|
type GetOverride<K extends ExtendableTypes, B, Reason extends string = "does not match its requirements"> = GetOverrideOrErrorValue<K, B, MakeErrorString<K, Reason>>;
|
|
1175
1236
|
type GetOverrideOrErrorValue<K extends ExtendableTypes, B, ErrorType> = unknown extends Liveblocks[K] ? B : Liveblocks[K] extends B ? Liveblocks[K] : ErrorType;
|
|
@@ -1177,7 +1238,8 @@ type DP = GetOverride<"Presence", JsonObject, "is not a valid JSON object">;
|
|
|
1177
1238
|
type DS = GetOverride<"Storage", LsonObject, "is not a valid LSON value">;
|
|
1178
1239
|
type DU = GetOverrideOrErrorValue<"UserMeta", BaseUserMeta, Record<"id" | "info", MakeErrorString<"UserMeta">>>;
|
|
1179
1240
|
type DE = GetOverride<"RoomEvent", Json, "is not a valid JSON value">;
|
|
1180
|
-
type
|
|
1241
|
+
type DTM = GetOverride<"ThreadMetadata", BaseMetadata>;
|
|
1242
|
+
type DCM = GetOverride<"CommentMetadata", BaseMetadata>;
|
|
1181
1243
|
type DRI = GetOverride<"RoomInfo", BaseRoomInfo>;
|
|
1182
1244
|
type DGI = GetOverride<"GroupInfo", BaseGroupInfo>;
|
|
1183
1245
|
type DAD = GetOverrideOrErrorValue<"ActivitiesData", BaseActivitiesData, {
|
|
@@ -1242,7 +1304,7 @@ type CommentMixedAttachment = CommentAttachment | CommentLocalAttachment;
|
|
|
1242
1304
|
/**
|
|
1243
1305
|
* Represents a comment.
|
|
1244
1306
|
*/
|
|
1245
|
-
type CommentData = {
|
|
1307
|
+
type CommentData<CM extends BaseMetadata = DCM> = {
|
|
1246
1308
|
type: "comment";
|
|
1247
1309
|
id: string;
|
|
1248
1310
|
threadId: string;
|
|
@@ -1252,13 +1314,15 @@ type CommentData = {
|
|
|
1252
1314
|
editedAt?: Date;
|
|
1253
1315
|
reactions: CommentReaction[];
|
|
1254
1316
|
attachments: CommentAttachment[];
|
|
1317
|
+
metadata: CM;
|
|
1255
1318
|
} & Relax<{
|
|
1256
1319
|
body: CommentBody;
|
|
1257
1320
|
} | {
|
|
1258
1321
|
deletedAt: Date;
|
|
1259
1322
|
}>;
|
|
1260
|
-
type CommentDataPlain = Omit<DateToString<CommentData
|
|
1323
|
+
type CommentDataPlain<CM extends BaseMetadata = DCM> = Omit<DateToString<CommentData<CM>>, "reactions" | "body" | "metadata"> & {
|
|
1261
1324
|
reactions: DateToString<CommentReaction>[];
|
|
1325
|
+
metadata: CM;
|
|
1262
1326
|
} & Relax<{
|
|
1263
1327
|
body: CommentBody;
|
|
1264
1328
|
} | {
|
|
@@ -1288,13 +1352,15 @@ type CommentBodyLink = {
|
|
|
1288
1352
|
url: string;
|
|
1289
1353
|
text?: string;
|
|
1290
1354
|
};
|
|
1291
|
-
type CommentBodyText = {
|
|
1355
|
+
type CommentBodyText = Resolve<{
|
|
1292
1356
|
bold?: boolean;
|
|
1293
1357
|
italic?: boolean;
|
|
1294
1358
|
strikethrough?: boolean;
|
|
1295
1359
|
code?: boolean;
|
|
1296
1360
|
text: string;
|
|
1297
|
-
}
|
|
1361
|
+
} & {
|
|
1362
|
+
[K in Exclude<keyof Relax<CommentBodyMention | CommentBodyLink>, "text">]?: never;
|
|
1363
|
+
}>;
|
|
1298
1364
|
type CommentBody = {
|
|
1299
1365
|
version: 1;
|
|
1300
1366
|
content: CommentBodyBlockElement[];
|
|
@@ -1313,22 +1379,22 @@ type SearchCommentsResult = {
|
|
|
1313
1379
|
/**
|
|
1314
1380
|
* Represents a thread of comments.
|
|
1315
1381
|
*/
|
|
1316
|
-
type ThreadData<
|
|
1382
|
+
type ThreadData<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> = {
|
|
1317
1383
|
type: "thread";
|
|
1318
1384
|
id: string;
|
|
1319
1385
|
roomId: string;
|
|
1320
1386
|
createdAt: Date;
|
|
1321
1387
|
updatedAt: Date;
|
|
1322
|
-
comments: CommentData[];
|
|
1323
|
-
metadata:
|
|
1388
|
+
comments: CommentData<CM>[];
|
|
1389
|
+
metadata: TM;
|
|
1324
1390
|
resolved: boolean;
|
|
1325
1391
|
};
|
|
1326
|
-
interface ThreadDataWithDeleteInfo<
|
|
1392
|
+
interface ThreadDataWithDeleteInfo<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> extends ThreadData<TM, CM> {
|
|
1327
1393
|
deletedAt?: Date;
|
|
1328
1394
|
}
|
|
1329
|
-
type ThreadDataPlain<
|
|
1330
|
-
comments: CommentDataPlain[];
|
|
1331
|
-
metadata:
|
|
1395
|
+
type ThreadDataPlain<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> = Omit<DateToString<ThreadData<TM, CM>>, "comments" | "metadata"> & {
|
|
1396
|
+
comments: CommentDataPlain<CM>[];
|
|
1397
|
+
metadata: TM;
|
|
1332
1398
|
};
|
|
1333
1399
|
type ThreadDeleteInfo = {
|
|
1334
1400
|
type: "deletedThread";
|
|
@@ -1566,17 +1632,17 @@ type MakeOptionalFieldsNullable<T> = {
|
|
|
1566
1632
|
};
|
|
1567
1633
|
type Patchable<T> = Partial<MakeOptionalFieldsNullable<T>>;
|
|
1568
1634
|
|
|
1569
|
-
interface RoomHttpApi<
|
|
1635
|
+
interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
1570
1636
|
getThreads(options: {
|
|
1571
1637
|
roomId: string;
|
|
1572
1638
|
cursor?: string;
|
|
1573
1639
|
query?: {
|
|
1574
1640
|
resolved?: boolean;
|
|
1575
1641
|
subscribed?: boolean;
|
|
1576
|
-
metadata?: Partial<QueryMetadata<
|
|
1642
|
+
metadata?: Partial<QueryMetadata<TM>>;
|
|
1577
1643
|
};
|
|
1578
1644
|
}): Promise<{
|
|
1579
|
-
threads: ThreadData<
|
|
1645
|
+
threads: ThreadData<TM, CM>[];
|
|
1580
1646
|
inboxNotifications: InboxNotificationData[];
|
|
1581
1647
|
subscriptions: SubscriptionData[];
|
|
1582
1648
|
requestedAt: Date;
|
|
@@ -1589,7 +1655,7 @@ interface RoomHttpApi<M extends BaseMetadata> {
|
|
|
1589
1655
|
signal?: AbortSignal;
|
|
1590
1656
|
}): Promise<{
|
|
1591
1657
|
threads: {
|
|
1592
|
-
updated: ThreadData<
|
|
1658
|
+
updated: ThreadData<TM, CM>[];
|
|
1593
1659
|
deleted: ThreadDeleteInfo[];
|
|
1594
1660
|
};
|
|
1595
1661
|
inboxNotifications: {
|
|
@@ -1606,7 +1672,7 @@ interface RoomHttpApi<M extends BaseMetadata> {
|
|
|
1606
1672
|
searchComments(options: {
|
|
1607
1673
|
roomId: string;
|
|
1608
1674
|
query: {
|
|
1609
|
-
threadMetadata?: Partial<QueryMetadata<
|
|
1675
|
+
threadMetadata?: Partial<QueryMetadata<TM>>;
|
|
1610
1676
|
threadResolved?: boolean;
|
|
1611
1677
|
hasAttachments?: boolean;
|
|
1612
1678
|
hasMentions?: boolean;
|
|
@@ -1617,19 +1683,20 @@ interface RoomHttpApi<M extends BaseMetadata> {
|
|
|
1617
1683
|
}): Promise<{
|
|
1618
1684
|
data: Array<SearchCommentsResult>;
|
|
1619
1685
|
}>;
|
|
1620
|
-
createThread({ roomId, metadata, body, commentId, threadId, attachmentIds, }: {
|
|
1686
|
+
createThread({ roomId, metadata, body, commentId, threadId, commentMetadata, attachmentIds, }: {
|
|
1621
1687
|
roomId: string;
|
|
1622
1688
|
threadId?: string;
|
|
1623
1689
|
commentId?: string;
|
|
1624
|
-
metadata:
|
|
1690
|
+
metadata: TM | undefined;
|
|
1691
|
+
commentMetadata: CM | undefined;
|
|
1625
1692
|
body: CommentBody;
|
|
1626
1693
|
attachmentIds?: string[];
|
|
1627
|
-
}): Promise<ThreadData<
|
|
1694
|
+
}): Promise<ThreadData<TM, CM>>;
|
|
1628
1695
|
getThread(options: {
|
|
1629
1696
|
roomId: string;
|
|
1630
1697
|
threadId: string;
|
|
1631
1698
|
}): Promise<{
|
|
1632
|
-
thread?: ThreadData<
|
|
1699
|
+
thread?: ThreadData<TM, CM>;
|
|
1633
1700
|
inboxNotification?: InboxNotificationData;
|
|
1634
1701
|
subscription?: SubscriptionData;
|
|
1635
1702
|
}>;
|
|
@@ -1639,23 +1706,31 @@ interface RoomHttpApi<M extends BaseMetadata> {
|
|
|
1639
1706
|
}): Promise<void>;
|
|
1640
1707
|
editThreadMetadata({ roomId, metadata, threadId, }: {
|
|
1641
1708
|
roomId: string;
|
|
1642
|
-
metadata: Patchable<
|
|
1709
|
+
metadata: Patchable<TM>;
|
|
1710
|
+
threadId: string;
|
|
1711
|
+
}): Promise<TM>;
|
|
1712
|
+
editCommentMetadata({ roomId, threadId, commentId, metadata, }: {
|
|
1713
|
+
roomId: string;
|
|
1643
1714
|
threadId: string;
|
|
1644
|
-
|
|
1645
|
-
|
|
1715
|
+
commentId: string;
|
|
1716
|
+
metadata: Patchable<CM>;
|
|
1717
|
+
}): Promise<CM>;
|
|
1718
|
+
createComment({ roomId, threadId, commentId, body, metadata, attachmentIds, }: {
|
|
1646
1719
|
roomId: string;
|
|
1647
1720
|
threadId: string;
|
|
1648
1721
|
commentId?: string;
|
|
1649
1722
|
body: CommentBody;
|
|
1723
|
+
metadata?: CM;
|
|
1650
1724
|
attachmentIds?: string[];
|
|
1651
|
-
}): Promise<CommentData
|
|
1652
|
-
editComment({ roomId, threadId, commentId, body, attachmentIds, }: {
|
|
1725
|
+
}): Promise<CommentData<CM>>;
|
|
1726
|
+
editComment({ roomId, threadId, commentId, body, attachmentIds, metadata, }: {
|
|
1653
1727
|
roomId: string;
|
|
1654
1728
|
threadId: string;
|
|
1655
1729
|
commentId: string;
|
|
1656
1730
|
body: CommentBody;
|
|
1657
1731
|
attachmentIds?: string[];
|
|
1658
|
-
|
|
1732
|
+
metadata?: Patchable<CM>;
|
|
1733
|
+
}): Promise<CommentData<CM>>;
|
|
1659
1734
|
deleteComment({ roomId, threadId, commentId, }: {
|
|
1660
1735
|
roomId: string;
|
|
1661
1736
|
threadId: string;
|
|
@@ -1793,7 +1868,7 @@ interface RoomHttpApi<M extends BaseMetadata> {
|
|
|
1793
1868
|
signal: AbortSignal;
|
|
1794
1869
|
}): Promise<string>;
|
|
1795
1870
|
}
|
|
1796
|
-
interface NotificationHttpApi<
|
|
1871
|
+
interface NotificationHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
1797
1872
|
getInboxNotifications(options?: {
|
|
1798
1873
|
cursor?: string;
|
|
1799
1874
|
query?: {
|
|
@@ -1802,7 +1877,7 @@ interface NotificationHttpApi<M extends BaseMetadata> {
|
|
|
1802
1877
|
};
|
|
1803
1878
|
}): Promise<{
|
|
1804
1879
|
inboxNotifications: InboxNotificationData[];
|
|
1805
|
-
threads: ThreadData<
|
|
1880
|
+
threads: ThreadData<TM, CM>[];
|
|
1806
1881
|
subscriptions: SubscriptionData[];
|
|
1807
1882
|
nextCursor: string | null;
|
|
1808
1883
|
requestedAt: Date;
|
|
@@ -1820,7 +1895,7 @@ interface NotificationHttpApi<M extends BaseMetadata> {
|
|
|
1820
1895
|
deleted: InboxNotificationDeleteInfo[];
|
|
1821
1896
|
};
|
|
1822
1897
|
threads: {
|
|
1823
|
-
updated: ThreadData<
|
|
1898
|
+
updated: ThreadData<TM, CM>[];
|
|
1824
1899
|
deleted: ThreadDeleteInfo[];
|
|
1825
1900
|
};
|
|
1826
1901
|
subscriptions: {
|
|
@@ -1845,16 +1920,16 @@ interface NotificationHttpApi<M extends BaseMetadata> {
|
|
|
1845
1920
|
}): Promise<NotificationSettingsPlain>;
|
|
1846
1921
|
updateNotificationSettings(settings: PartialNotificationSettings): Promise<NotificationSettingsPlain>;
|
|
1847
1922
|
}
|
|
1848
|
-
interface LiveblocksHttpApi<
|
|
1923
|
+
interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> extends RoomHttpApi<TM, CM>, NotificationHttpApi<TM, CM> {
|
|
1849
1924
|
getUrlMetadata(url: string): Promise<UrlMetadata>;
|
|
1850
1925
|
getUserThreads_experimental(options?: {
|
|
1851
1926
|
cursor?: string;
|
|
1852
1927
|
query?: {
|
|
1853
1928
|
resolved?: boolean;
|
|
1854
|
-
metadata?: Partial<QueryMetadata<
|
|
1929
|
+
metadata?: Partial<QueryMetadata<TM>>;
|
|
1855
1930
|
};
|
|
1856
1931
|
}): Promise<{
|
|
1857
|
-
threads: ThreadData<
|
|
1932
|
+
threads: ThreadData<TM, CM>[];
|
|
1858
1933
|
inboxNotifications: InboxNotificationData[];
|
|
1859
1934
|
subscriptions: SubscriptionData[];
|
|
1860
1935
|
nextCursor: string | null;
|
|
@@ -1870,7 +1945,7 @@ interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, Noti
|
|
|
1870
1945
|
deleted: InboxNotificationDeleteInfo[];
|
|
1871
1946
|
};
|
|
1872
1947
|
threads: {
|
|
1873
|
-
updated: ThreadData<
|
|
1948
|
+
updated: ThreadData<TM, CM>[];
|
|
1874
1949
|
deleted: ThreadDeleteInfo[];
|
|
1875
1950
|
};
|
|
1876
1951
|
subscriptions: {
|
|
@@ -1930,6 +2005,7 @@ type CommentsOrNotificationsErrorContext = {
|
|
|
1930
2005
|
commentId: string;
|
|
1931
2006
|
body: CommentBody;
|
|
1932
2007
|
metadata: BaseMetadata;
|
|
2008
|
+
commentMetadata: BaseMetadata;
|
|
1933
2009
|
} | {
|
|
1934
2010
|
type: "DELETE_THREAD_ERROR";
|
|
1935
2011
|
roomId: string;
|
|
@@ -1939,6 +2015,12 @@ type CommentsOrNotificationsErrorContext = {
|
|
|
1939
2015
|
roomId: string;
|
|
1940
2016
|
threadId: string;
|
|
1941
2017
|
metadata: Patchable<BaseMetadata>;
|
|
2018
|
+
} | {
|
|
2019
|
+
type: "EDIT_COMMENT_METADATA_ERROR";
|
|
2020
|
+
roomId: string;
|
|
2021
|
+
threadId: string;
|
|
2022
|
+
commentId: string;
|
|
2023
|
+
metadata: Patchable<BaseMetadata>;
|
|
1942
2024
|
} | {
|
|
1943
2025
|
type: "MARK_THREAD_AS_RESOLVED_ERROR" | "MARK_THREAD_AS_UNRESOLVED_ERROR" | "SUBSCRIBE_TO_THREAD_ERROR" | "UNSUBSCRIBE_FROM_THREAD_ERROR";
|
|
1944
2026
|
roomId: string;
|
|
@@ -1949,6 +2031,7 @@ type CommentsOrNotificationsErrorContext = {
|
|
|
1949
2031
|
threadId: string;
|
|
1950
2032
|
commentId: string;
|
|
1951
2033
|
body: CommentBody;
|
|
2034
|
+
metadata: BaseMetadata;
|
|
1952
2035
|
} | {
|
|
1953
2036
|
type: "DELETE_COMMENT_ERROR";
|
|
1954
2037
|
roomId: string;
|
|
@@ -2059,7 +2142,7 @@ type InternalSyncStatus = SyncStatus | "has-local-changes";
|
|
|
2059
2142
|
* of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
|
|
2060
2143
|
* will probably happen if you do.
|
|
2061
2144
|
*/
|
|
2062
|
-
type PrivateClientApi<U extends BaseUserMeta,
|
|
2145
|
+
type PrivateClientApi<U extends BaseUserMeta, TM extends BaseMetadata, CM extends BaseMetadata> = {
|
|
2063
2146
|
readonly currentUserId: Signal<string | undefined>;
|
|
2064
2147
|
readonly mentionSuggestionsCache: Map<string, MentionData[]>;
|
|
2065
2148
|
readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
|
|
@@ -2067,13 +2150,13 @@ type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
|
|
|
2067
2150
|
readonly roomsInfoStore: BatchStore<DRI | undefined, string>;
|
|
2068
2151
|
readonly groupsInfoStore: BatchStore<DGI | undefined, string>;
|
|
2069
2152
|
readonly getRoomIds: () => string[];
|
|
2070
|
-
readonly httpClient: LiveblocksHttpApi<
|
|
2071
|
-
as<
|
|
2153
|
+
readonly httpClient: LiveblocksHttpApi<TM, CM>;
|
|
2154
|
+
as<TM2 extends BaseMetadata, CM2 extends BaseMetadata>(): Client<U, TM2, CM2>;
|
|
2072
2155
|
createSyncSource(): SyncSource;
|
|
2073
2156
|
emitError(context: LiveblocksErrorContext, cause?: Error): void;
|
|
2074
2157
|
ai: Ai;
|
|
2075
2158
|
};
|
|
2076
|
-
type NotificationsApi<
|
|
2159
|
+
type NotificationsApi<TM extends BaseMetadata, CM extends BaseMetadata> = {
|
|
2077
2160
|
/**
|
|
2078
2161
|
* Gets a page (or the initial page) for user inbox notifications and their
|
|
2079
2162
|
* associated threads and thread subscriptions.
|
|
@@ -2100,7 +2183,7 @@ type NotificationsApi<M extends BaseMetadata> = {
|
|
|
2100
2183
|
};
|
|
2101
2184
|
}): Promise<{
|
|
2102
2185
|
inboxNotifications: InboxNotificationData[];
|
|
2103
|
-
threads: ThreadData<
|
|
2186
|
+
threads: ThreadData<TM, CM>[];
|
|
2104
2187
|
subscriptions: SubscriptionData[];
|
|
2105
2188
|
nextCursor: string | null;
|
|
2106
2189
|
requestedAt: Date;
|
|
@@ -2141,7 +2224,7 @@ type NotificationsApi<M extends BaseMetadata> = {
|
|
|
2141
2224
|
deleted: InboxNotificationDeleteInfo[];
|
|
2142
2225
|
};
|
|
2143
2226
|
threads: {
|
|
2144
|
-
updated: ThreadData<
|
|
2227
|
+
updated: ThreadData<TM, CM>[];
|
|
2145
2228
|
deleted: ThreadDeleteInfo[];
|
|
2146
2229
|
};
|
|
2147
2230
|
subscriptions: {
|
|
@@ -2221,23 +2304,23 @@ type NotificationsApi<M extends BaseMetadata> = {
|
|
|
2221
2304
|
* narrower.
|
|
2222
2305
|
*/
|
|
2223
2306
|
type OpaqueClient = Client<BaseUserMeta>;
|
|
2224
|
-
type Client<U extends BaseUserMeta = DU,
|
|
2307
|
+
type Client<U extends BaseUserMeta = DU, TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> = {
|
|
2225
2308
|
/**
|
|
2226
2309
|
* Gets a room. Returns null if {@link Client.enter} has not been called previously.
|
|
2227
2310
|
*
|
|
2228
2311
|
* @param roomId The id of the room
|
|
2229
2312
|
*/
|
|
2230
|
-
getRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE,
|
|
2313
|
+
getRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, TM2 extends BaseMetadata = TM, CM2 extends BaseMetadata = CM>(roomId: string): Room<P, S, U, E, TM2, CM2> | null;
|
|
2231
2314
|
/**
|
|
2232
2315
|
* Enter a room.
|
|
2233
2316
|
* @param roomId The id of the room
|
|
2234
2317
|
* @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
|
|
2235
2318
|
* @returns The room and a leave function. Call the returned leave() function when you no longer need the room.
|
|
2236
2319
|
*/
|
|
2237
|
-
enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE,
|
|
2320
|
+
enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, TM2 extends BaseMetadata = TM, CM2 extends BaseMetadata = CM>(roomId: string, ...args: OptionalTupleUnless<P & S, [
|
|
2238
2321
|
options: EnterOptions<NoInfr<P>, NoInfr<S>>
|
|
2239
2322
|
]>): {
|
|
2240
|
-
room: Room<P, S, U, E,
|
|
2323
|
+
room: Room<P, S, U, E, TM2, CM2>;
|
|
2241
2324
|
leave: () => void;
|
|
2242
2325
|
};
|
|
2243
2326
|
/**
|
|
@@ -2303,7 +2386,7 @@ type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> = {
|
|
|
2303
2386
|
* of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
|
|
2304
2387
|
* will probably happen if you do.
|
|
2305
2388
|
*/
|
|
2306
|
-
readonly [kInternal]: PrivateClientApi<U,
|
|
2389
|
+
readonly [kInternal]: PrivateClientApi<U, TM, CM>;
|
|
2307
2390
|
/**
|
|
2308
2391
|
* Returns the current global sync status of the Liveblocks client. If any
|
|
2309
2392
|
* part of Liveblocks has any local pending changes that haven't been
|
|
@@ -2327,7 +2410,7 @@ type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> = {
|
|
|
2327
2410
|
readonly error: Observable<LiveblocksError>;
|
|
2328
2411
|
readonly syncStatus: Observable<void>;
|
|
2329
2412
|
};
|
|
2330
|
-
} & NotificationsApi<
|
|
2413
|
+
} & NotificationsApi<TM, CM>;
|
|
2331
2414
|
type AuthEndpoint = string | ((room?: string) => Promise<CustomAuthenticationResult>);
|
|
2332
2415
|
/**
|
|
2333
2416
|
* The authentication endpoint that is called to ensure that the current user has access to a room.
|
|
@@ -2521,9 +2604,7 @@ declare const ServerMsgCode: Readonly<{
|
|
|
2521
2604
|
USER_LEFT: 102;
|
|
2522
2605
|
BROADCASTED_EVENT: 103;
|
|
2523
2606
|
ROOM_STATE: 104;
|
|
2524
|
-
|
|
2525
|
-
STORAGE_CHUNK: 210;
|
|
2526
|
-
STORAGE_STREAM_END: 211;
|
|
2607
|
+
STORAGE_STATE: 200;
|
|
2527
2608
|
UPDATE_STORAGE: 201;
|
|
2528
2609
|
UPDATE_YDOC: 300;
|
|
2529
2610
|
THREAD_CREATED: 400;
|
|
@@ -2535,6 +2616,7 @@ declare const ServerMsgCode: Readonly<{
|
|
|
2535
2616
|
COMMENT_DELETED: 404;
|
|
2536
2617
|
COMMENT_REACTION_ADDED: 405;
|
|
2537
2618
|
COMMENT_REACTION_REMOVED: 406;
|
|
2619
|
+
COMMENT_METADATA_UPDATED: 409;
|
|
2538
2620
|
REJECT_STORAGE_OP: 299;
|
|
2539
2621
|
}>;
|
|
2540
2622
|
declare namespace ServerMsgCode {
|
|
@@ -2543,9 +2625,7 @@ declare namespace ServerMsgCode {
|
|
|
2543
2625
|
type USER_LEFT = typeof ServerMsgCode.USER_LEFT;
|
|
2544
2626
|
type BROADCASTED_EVENT = typeof ServerMsgCode.BROADCASTED_EVENT;
|
|
2545
2627
|
type ROOM_STATE = typeof ServerMsgCode.ROOM_STATE;
|
|
2546
|
-
type
|
|
2547
|
-
type STORAGE_CHUNK = typeof ServerMsgCode.STORAGE_CHUNK;
|
|
2548
|
-
type STORAGE_STREAM_END = typeof ServerMsgCode.STORAGE_STREAM_END;
|
|
2628
|
+
type STORAGE_STATE = typeof ServerMsgCode.STORAGE_STATE;
|
|
2549
2629
|
type UPDATE_STORAGE = typeof ServerMsgCode.UPDATE_STORAGE;
|
|
2550
2630
|
type UPDATE_YDOC = typeof ServerMsgCode.UPDATE_YDOC;
|
|
2551
2631
|
type THREAD_CREATED = typeof ServerMsgCode.THREAD_CREATED;
|
|
@@ -2557,13 +2637,14 @@ declare namespace ServerMsgCode {
|
|
|
2557
2637
|
type COMMENT_DELETED = typeof ServerMsgCode.COMMENT_DELETED;
|
|
2558
2638
|
type COMMENT_REACTION_ADDED = typeof ServerMsgCode.COMMENT_REACTION_ADDED;
|
|
2559
2639
|
type COMMENT_REACTION_REMOVED = typeof ServerMsgCode.COMMENT_REACTION_REMOVED;
|
|
2640
|
+
type COMMENT_METADATA_UPDATED = typeof ServerMsgCode.COMMENT_METADATA_UPDATED;
|
|
2560
2641
|
type REJECT_STORAGE_OP = typeof ServerMsgCode.REJECT_STORAGE_OP;
|
|
2561
2642
|
}
|
|
2562
2643
|
/**
|
|
2563
2644
|
* Messages that can be sent from the server to the client.
|
|
2564
2645
|
*/
|
|
2565
|
-
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> |
|
|
2566
|
-
type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
|
|
2646
|
+
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | StorageStateServerMsg | UpdateStorageServerMsg | YDocUpdateServerMsg | RejectedStorageOpServerMsg | CommentsEventServerMsg;
|
|
2647
|
+
type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | CommentMetadataUpdatedEvent;
|
|
2567
2648
|
type ThreadCreatedEvent = {
|
|
2568
2649
|
type: ServerMsgCode.THREAD_CREATED;
|
|
2569
2650
|
threadId: string;
|
|
@@ -2607,6 +2688,11 @@ type CommentReactionRemoved = {
|
|
|
2607
2688
|
commentId: string;
|
|
2608
2689
|
emoji: string;
|
|
2609
2690
|
};
|
|
2691
|
+
type CommentMetadataUpdatedEvent = {
|
|
2692
|
+
type: ServerMsgCode.COMMENT_METADATA_UPDATED;
|
|
2693
|
+
threadId: string;
|
|
2694
|
+
commentId: string;
|
|
2695
|
+
};
|
|
2610
2696
|
/**
|
|
2611
2697
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
2612
2698
|
* a User updated their presence. For example, when a user moves their cursor.
|
|
@@ -2726,46 +2812,39 @@ type BroadcastedEventServerMsg<E extends Json> = {
|
|
|
2726
2812
|
*/
|
|
2727
2813
|
type RoomStateServerMsg<U extends BaseUserMeta> = {
|
|
2728
2814
|
readonly type: ServerMsgCode.ROOM_STATE;
|
|
2729
|
-
/**
|
|
2815
|
+
/**
|
|
2816
|
+
* Informs the client what their actor ID is going to be.
|
|
2817
|
+
* @since v1.2 (WS API v7)
|
|
2818
|
+
*/
|
|
2730
2819
|
readonly actor: number;
|
|
2731
|
-
/**
|
|
2820
|
+
/**
|
|
2821
|
+
* Secure nonce for the current session.
|
|
2822
|
+
* @since v1.2 (WS API v7)
|
|
2823
|
+
*/
|
|
2732
2824
|
readonly nonce: string;
|
|
2733
|
-
/**
|
|
2825
|
+
/**
|
|
2826
|
+
* Informs the client what permissions the current User (self) has.
|
|
2827
|
+
* @since v1.2 (WS API v7)
|
|
2828
|
+
*/
|
|
2734
2829
|
readonly scopes: string[];
|
|
2735
2830
|
readonly users: {
|
|
2736
2831
|
readonly [otherActor: number]: U & {
|
|
2737
2832
|
scopes: string[];
|
|
2738
2833
|
};
|
|
2739
2834
|
};
|
|
2740
|
-
/**
|
|
2835
|
+
/**
|
|
2836
|
+
* Metadata sent from the server to the client.
|
|
2837
|
+
*/
|
|
2741
2838
|
readonly meta: JsonObject;
|
|
2742
2839
|
};
|
|
2743
|
-
/**
|
|
2744
|
-
* No longer used as of WS API v8.
|
|
2745
|
-
*/
|
|
2746
|
-
type StorageStateServerMsg_V7 = {
|
|
2747
|
-
readonly type: ServerMsgCode.STORAGE_STATE_V7;
|
|
2748
|
-
readonly items: IdTuple<SerializedCrdt>[];
|
|
2749
|
-
};
|
|
2750
2840
|
/**
|
|
2751
2841
|
* Sent by the WebSocket server to a single client in response to the client
|
|
2752
|
-
* sending a FetchStorageClientMsg message, to provide
|
|
2753
|
-
*
|
|
2754
|
-
*
|
|
2755
|
-
* The server will respond with 1+ STORAGE_CHUNK messages, followed by exactly
|
|
2756
|
-
* one STORAGE_STREAM_END message to mark the end of the transmission.
|
|
2757
|
-
*
|
|
2758
|
-
* If the room is using the new storage engine that supports streaming, then
|
|
2759
|
-
* potentially multiple chunks might get sent. If the room is using the old
|
|
2760
|
-
* storage engine, then all nodes will be sent in a single/large chunk
|
|
2761
|
-
* (non-streaming).
|
|
2842
|
+
* sending a FetchStorageClientMsg message, to provide the initial Storage
|
|
2843
|
+
* state of the Room. The payload includes the entire Storage document.
|
|
2762
2844
|
*/
|
|
2763
|
-
type
|
|
2764
|
-
readonly type: ServerMsgCode.
|
|
2765
|
-
readonly
|
|
2766
|
-
};
|
|
2767
|
-
type StorageEndServerMsg = {
|
|
2768
|
-
readonly type: ServerMsgCode.STORAGE_STREAM_END;
|
|
2845
|
+
type StorageStateServerMsg = {
|
|
2846
|
+
readonly type: ServerMsgCode.STORAGE_STATE;
|
|
2847
|
+
readonly items: IdTuple<SerializedCrdt>[];
|
|
2769
2848
|
};
|
|
2770
2849
|
/**
|
|
2771
2850
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
@@ -2776,7 +2855,7 @@ type StorageEndServerMsg = {
|
|
|
2776
2855
|
*/
|
|
2777
2856
|
type UpdateStorageServerMsg = {
|
|
2778
2857
|
readonly type: ServerMsgCode.UPDATE_STORAGE;
|
|
2779
|
-
readonly ops:
|
|
2858
|
+
readonly ops: ServerWireOp[];
|
|
2780
2859
|
};
|
|
2781
2860
|
/**
|
|
2782
2861
|
* Sent by the WebSocket server to the client to indicate that certain opIds
|
|
@@ -3095,12 +3174,12 @@ type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U extends B
|
|
|
3095
3174
|
(type: "storage-status", listener: Callback<StorageStatus>): () => void;
|
|
3096
3175
|
(type: "comments", listener: Callback<CommentsEventServerMsg>): () => void;
|
|
3097
3176
|
};
|
|
3098
|
-
type GetThreadsOptions<
|
|
3177
|
+
type GetThreadsOptions<TM extends BaseMetadata> = {
|
|
3099
3178
|
cursor?: string;
|
|
3100
3179
|
query?: {
|
|
3101
3180
|
resolved?: boolean;
|
|
3102
3181
|
subscribed?: boolean;
|
|
3103
|
-
metadata?: Partial<QueryMetadata<
|
|
3182
|
+
metadata?: Partial<QueryMetadata<TM>>;
|
|
3104
3183
|
};
|
|
3105
3184
|
};
|
|
3106
3185
|
type GetThreadsSinceOptions = {
|
|
@@ -3123,7 +3202,7 @@ type GetSubscriptionSettingsOptions = {
|
|
|
3123
3202
|
* a Room instance using globally augmented types only, which is narrower.
|
|
3124
3203
|
*/
|
|
3125
3204
|
type OpaqueRoom = Room<JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata>;
|
|
3126
|
-
type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE,
|
|
3205
|
+
type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE, TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> = {
|
|
3127
3206
|
/**
|
|
3128
3207
|
* @private
|
|
3129
3208
|
*
|
|
@@ -3337,8 +3416,8 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3337
3416
|
* requestedAt
|
|
3338
3417
|
* } = await room.getThreads({ query: { resolved: false }});
|
|
3339
3418
|
*/
|
|
3340
|
-
getThreads(options?: GetThreadsOptions<
|
|
3341
|
-
threads: ThreadData<
|
|
3419
|
+
getThreads(options?: GetThreadsOptions<TM>): Promise<{
|
|
3420
|
+
threads: ThreadData<TM, CM>[];
|
|
3342
3421
|
inboxNotifications: InboxNotificationData[];
|
|
3343
3422
|
subscriptions: SubscriptionData[];
|
|
3344
3423
|
requestedAt: Date;
|
|
@@ -3355,7 +3434,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3355
3434
|
*/
|
|
3356
3435
|
getThreadsSince(options: GetThreadsSinceOptions): Promise<{
|
|
3357
3436
|
threads: {
|
|
3358
|
-
updated: ThreadData<
|
|
3437
|
+
updated: ThreadData<TM, CM>[];
|
|
3359
3438
|
deleted: ThreadDeleteInfo[];
|
|
3360
3439
|
};
|
|
3361
3440
|
inboxNotifications: {
|
|
@@ -3376,7 +3455,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3376
3455
|
* const { thread, inboxNotification, subscription } = await room.getThread("th_xxx");
|
|
3377
3456
|
*/
|
|
3378
3457
|
getThread(threadId: string): Promise<{
|
|
3379
|
-
thread?: ThreadData<
|
|
3458
|
+
thread?: ThreadData<TM, CM>;
|
|
3380
3459
|
inboxNotification?: InboxNotificationData;
|
|
3381
3460
|
subscription?: SubscriptionData;
|
|
3382
3461
|
}>;
|
|
@@ -3394,10 +3473,11 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3394
3473
|
createThread(options: {
|
|
3395
3474
|
threadId?: string;
|
|
3396
3475
|
commentId?: string;
|
|
3397
|
-
metadata:
|
|
3476
|
+
metadata: TM | undefined;
|
|
3398
3477
|
body: CommentBody;
|
|
3478
|
+
commentMetadata?: CM;
|
|
3399
3479
|
attachmentIds?: string[];
|
|
3400
|
-
}): Promise<ThreadData<
|
|
3480
|
+
}): Promise<ThreadData<TM, CM>>;
|
|
3401
3481
|
/**
|
|
3402
3482
|
* Deletes a thread.
|
|
3403
3483
|
*
|
|
@@ -3413,9 +3493,21 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3413
3493
|
* await room.editThreadMetadata({ threadId: "th_xxx", metadata: { x: 100, y: 100 } })
|
|
3414
3494
|
*/
|
|
3415
3495
|
editThreadMetadata(options: {
|
|
3416
|
-
metadata: Patchable<
|
|
3496
|
+
metadata: Patchable<TM>;
|
|
3497
|
+
threadId: string;
|
|
3498
|
+
}): Promise<TM>;
|
|
3499
|
+
/**
|
|
3500
|
+
* Edits a comment's metadata.
|
|
3501
|
+
* To delete an existing metadata property, set its value to `null`.
|
|
3502
|
+
*
|
|
3503
|
+
* @example
|
|
3504
|
+
* await room.editCommentMetadata({ threadId: "th_xxx", commentId: "cm_xxx", metadata: { tag: "important", externalId: 1234 } })
|
|
3505
|
+
*/
|
|
3506
|
+
editCommentMetadata(options: {
|
|
3417
3507
|
threadId: string;
|
|
3418
|
-
|
|
3508
|
+
commentId: string;
|
|
3509
|
+
metadata: Patchable<CM>;
|
|
3510
|
+
}): Promise<CM>;
|
|
3419
3511
|
/**
|
|
3420
3512
|
* Marks a thread as resolved.
|
|
3421
3513
|
*
|
|
@@ -3460,8 +3552,9 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3460
3552
|
threadId: string;
|
|
3461
3553
|
commentId?: string;
|
|
3462
3554
|
body: CommentBody;
|
|
3555
|
+
metadata?: CM;
|
|
3463
3556
|
attachmentIds?: string[];
|
|
3464
|
-
}): Promise<CommentData
|
|
3557
|
+
}): Promise<CommentData<CM>>;
|
|
3465
3558
|
/**
|
|
3466
3559
|
* Edits a comment.
|
|
3467
3560
|
*
|
|
@@ -3479,8 +3572,9 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3479
3572
|
threadId: string;
|
|
3480
3573
|
commentId: string;
|
|
3481
3574
|
body: CommentBody;
|
|
3575
|
+
metadata?: Patchable<CM>;
|
|
3482
3576
|
attachmentIds?: string[];
|
|
3483
|
-
}): Promise<CommentData
|
|
3577
|
+
}): Promise<CommentData<CM>>;
|
|
3484
3578
|
/**
|
|
3485
3579
|
* Deletes a comment.
|
|
3486
3580
|
* If it is the last non-deleted comment, the thread also gets deleted.
|
|
@@ -3595,7 +3689,7 @@ interface SyncSource {
|
|
|
3595
3689
|
*/
|
|
3596
3690
|
type PrivateRoomApi = {
|
|
3597
3691
|
presenceBuffer: Json | undefined;
|
|
3598
|
-
undoStack: readonly (readonly Readonly<
|
|
3692
|
+
undoStack: readonly (readonly Readonly<Stackframe<JsonObject>>[])[];
|
|
3599
3693
|
nodeCount: number;
|
|
3600
3694
|
getYjsProvider(): IYjsProvider | undefined;
|
|
3601
3695
|
setYjsProvider(provider: IYjsProvider | undefined): void;
|
|
@@ -3630,7 +3724,8 @@ type PrivateRoomApi = {
|
|
|
3630
3724
|
};
|
|
3631
3725
|
attachmentUrlsStore: BatchStore<string, string>;
|
|
3632
3726
|
};
|
|
3633
|
-
type
|
|
3727
|
+
type Stackframe<P extends JsonObject> = Op | PresenceStackframe<P>;
|
|
3728
|
+
type PresenceStackframe<P extends JsonObject> = {
|
|
3634
3729
|
readonly type: "presence";
|
|
3635
3730
|
readonly data: P;
|
|
3636
3731
|
};
|
|
@@ -3673,80 +3768,6 @@ type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ?
|
|
|
3673
3768
|
] extends [never] ? OptionalTuple<T> : T;
|
|
3674
3769
|
type LargeMessageStrategy = "default" | "split" | "experimental-fallback-to-http";
|
|
3675
3770
|
|
|
3676
|
-
declare const brand: unique symbol;
|
|
3677
|
-
type Brand<T, TBrand extends string> = T & {
|
|
3678
|
-
[brand]: TBrand;
|
|
3679
|
-
};
|
|
3680
|
-
type ISODateString = Brand<string, "ISODateString">;
|
|
3681
|
-
type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
|
|
3682
|
-
type WithRequired<T, K extends keyof T> = T & {
|
|
3683
|
-
[P in K]-?: T[P];
|
|
3684
|
-
};
|
|
3685
|
-
type WithOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
3686
|
-
[P in K]?: T[P];
|
|
3687
|
-
};
|
|
3688
|
-
/**
|
|
3689
|
-
* Throw an error, but as an expression instead of a statement.
|
|
3690
|
-
*/
|
|
3691
|
-
declare function raise(msg: string): never;
|
|
3692
|
-
/**
|
|
3693
|
-
* Drop-in replacement for Object.entries() that retains better types.
|
|
3694
|
-
*/
|
|
3695
|
-
declare function entries<O extends {
|
|
3696
|
-
[key: string]: unknown;
|
|
3697
|
-
}, K extends keyof O>(obj: O): [K, O[K]][];
|
|
3698
|
-
/**
|
|
3699
|
-
* Drop-in replacement for Object.keys() that retains better types.
|
|
3700
|
-
*/
|
|
3701
|
-
declare function keys<O extends {
|
|
3702
|
-
[key: string]: unknown;
|
|
3703
|
-
}, K extends keyof O>(obj: O): K[];
|
|
3704
|
-
/**
|
|
3705
|
-
* Creates a new object by mapping a function over all values. Keys remain the
|
|
3706
|
-
* same. Think Array.prototype.map(), but for values in an object.
|
|
3707
|
-
*/
|
|
3708
|
-
declare function mapValues<V, O extends Record<string, unknown>>(obj: O, mapFn: (value: O[keyof O], key: keyof O) => V): {
|
|
3709
|
-
[K in keyof O]: V;
|
|
3710
|
-
};
|
|
3711
|
-
/**
|
|
3712
|
-
* Alternative to JSON.parse() that will not throw in production. If the passed
|
|
3713
|
-
* string cannot be parsed, this will return `undefined`.
|
|
3714
|
-
*/
|
|
3715
|
-
declare function tryParseJson(rawMessage: string): Json | undefined;
|
|
3716
|
-
/**
|
|
3717
|
-
* Decode base64 string.
|
|
3718
|
-
*/
|
|
3719
|
-
declare function b64decode(b64value: string): string;
|
|
3720
|
-
type RemoveUndefinedValues<T> = {
|
|
3721
|
-
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
3722
|
-
};
|
|
3723
|
-
/**
|
|
3724
|
-
* Returns a new object instance where all explictly-undefined values are
|
|
3725
|
-
* removed.
|
|
3726
|
-
*/
|
|
3727
|
-
declare function compactObject<O extends Record<string, unknown>>(obj: O): RemoveUndefinedValues<O>;
|
|
3728
|
-
/**
|
|
3729
|
-
* Returns a promise that resolves after the given number of milliseconds.
|
|
3730
|
-
*/
|
|
3731
|
-
declare function wait(millis: number): Promise<void>;
|
|
3732
|
-
/**
|
|
3733
|
-
* Returns whatever the given promise returns, but will be rejected with
|
|
3734
|
-
* a "Timed out" error if the given promise does not return or reject within
|
|
3735
|
-
* the given timeout period (in milliseconds).
|
|
3736
|
-
*/
|
|
3737
|
-
declare function withTimeout<T>(promise: Promise<T>, millis: number, errmsg: string): Promise<T>;
|
|
3738
|
-
/**
|
|
3739
|
-
* Memoize a promise factory, so that each subsequent call will return the same
|
|
3740
|
-
* pending or success promise. If the promise rejects, will retain that failed
|
|
3741
|
-
* promise for a small time period, after which the next attempt will reset the
|
|
3742
|
-
* memoized value.
|
|
3743
|
-
*/
|
|
3744
|
-
declare function memoizeOnSuccess<T>(factoryFn: () => Promise<T>): () => Promise<T>;
|
|
3745
|
-
/**
|
|
3746
|
-
* Polyfill for Array.prototype.findLastIndex()
|
|
3747
|
-
*/
|
|
3748
|
-
declare function findLastIndex<T>(arr: T[], predicate: (value: T, index: number, obj: T[]) => boolean): number;
|
|
3749
|
-
|
|
3750
3771
|
type Cursor = Brand<string, "Cursor">;
|
|
3751
3772
|
type ChatId = string;
|
|
3752
3773
|
type MessageId = Brand<`ms_${string}`, "MessageId">;
|
|
@@ -4499,14 +4520,14 @@ declare const MENTION_CHARACTER = "@";
|
|
|
4499
4520
|
* @param data The plain comment data object (usually returned by the API)
|
|
4500
4521
|
* @returns The rich comment data object that can be used by the client.
|
|
4501
4522
|
*/
|
|
4502
|
-
declare function convertToCommentData(data: CommentDataPlain): CommentData
|
|
4523
|
+
declare function convertToCommentData<CM extends BaseMetadata>(data: CommentDataPlain<CM>): CommentData<CM>;
|
|
4503
4524
|
/**
|
|
4504
4525
|
* Converts a plain thread data object (usually returned by the API) to a thread data object that can be used by the client.
|
|
4505
4526
|
* This is necessary because the plain data object stores dates as ISO strings, but the client expects them as Date objects.
|
|
4506
4527
|
* @param data The plain thread data object (usually returned by the API)
|
|
4507
4528
|
* @returns The rich thread data object that can be used by the client.
|
|
4508
4529
|
*/
|
|
4509
|
-
declare function convertToThreadData<
|
|
4530
|
+
declare function convertToThreadData<TM extends BaseMetadata, CM extends BaseMetadata>(data: ThreadDataPlain<TM, CM>): ThreadData<TM, CM>;
|
|
4510
4531
|
/**
|
|
4511
4532
|
* Converts a plain comment reaction object (usually returned by the API) to a comment reaction object that can be used by the client.
|
|
4512
4533
|
* This is necessary because the plain data object stores dates as ISO strings, but the client expects them as Date objects.
|
|
@@ -5222,4 +5243,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5222
5243
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5223
5244
|
};
|
|
5224
5245
|
|
|
5225
|
-
export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type
|
|
5246
|
+
export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, type LayerKey, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStateServerMsg, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isNumberOperator, isPlainObject, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|