@liveblocks/node 3.13.0-vincent3 → 3.13.1-hackathon
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 +222 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +202 -27
- package/dist/index.d.ts +202 -27
- package/dist/index.js +214 -2
- 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.13.
|
|
6
|
+
var PKG_VERSION = "3.13.1-hackathon";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -990,6 +990,7 @@ var Liveblocks = class {
|
|
|
990
990
|
* @param params.data.userId The user ID of the user who is set to create the comment.
|
|
991
991
|
* @param params.data.createdAt (optional) The date the comment is set to be created.
|
|
992
992
|
* @param params.data.body The body of the comment.
|
|
993
|
+
* @param params.data.metadata (optional) The metadata for the comment.
|
|
993
994
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
994
995
|
* @returns The created comment.
|
|
995
996
|
*/
|
|
@@ -1014,6 +1015,7 @@ var Liveblocks = class {
|
|
|
1014
1015
|
* @param params.threadId The thread ID to edit the comment in.
|
|
1015
1016
|
* @param params.commentId The comment ID to edit.
|
|
1016
1017
|
* @param params.data.body The body of the comment.
|
|
1018
|
+
* @param params.data.metadata (optional) The metadata for the comment. Value must be a string, boolean or number. Use null to delete a key.
|
|
1017
1019
|
* @param params.data.editedAt (optional) The date the comment was edited.
|
|
1018
1020
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1019
1021
|
* @returns The edited comment.
|
|
@@ -1022,7 +1024,11 @@ var Liveblocks = class {
|
|
|
1022
1024
|
const { roomId, threadId, commentId, data } = params;
|
|
1023
1025
|
const res = await this.#post(
|
|
1024
1026
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
|
|
1025
|
-
{
|
|
1027
|
+
{
|
|
1028
|
+
body: data.body,
|
|
1029
|
+
editedAt: _optionalChain([data, 'access', _13 => _13.editedAt, 'optionalAccess', _14 => _14.toISOString, 'call', _15 => _15()]),
|
|
1030
|
+
metadata: data.metadata
|
|
1031
|
+
},
|
|
1026
1032
|
options
|
|
1027
1033
|
);
|
|
1028
1034
|
if (!res.ok) {
|
|
@@ -1056,6 +1062,7 @@ var Liveblocks = class {
|
|
|
1056
1062
|
* @param params.thread.comment.userId The user ID of the user who created the comment.
|
|
1057
1063
|
* @param params.thread.comment.createdAt (optional) The date the comment was created.
|
|
1058
1064
|
* @param params.thread.comment.body The body of the comment.
|
|
1065
|
+
* @param params.thread.comment.metadata (optional) The metadata for the comment.
|
|
1059
1066
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1060
1067
|
* @returns The created thread. The thread will be created with the specified comment as its first comment.
|
|
1061
1068
|
*/
|
|
@@ -1199,6 +1206,32 @@ var Liveblocks = class {
|
|
|
1199
1206
|
}
|
|
1200
1207
|
return await res.json();
|
|
1201
1208
|
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Updates the metadata of the specified comment in a room.
|
|
1211
|
+
* @param params.roomId The room ID to update the comment in.
|
|
1212
|
+
* @param params.threadId The thread ID to update the comment in.
|
|
1213
|
+
* @param params.commentId The comment ID to update.
|
|
1214
|
+
* @param params.data.metadata The metadata for the comment. Value must be a string, boolean or number. Use null to delete a key.
|
|
1215
|
+
* @param params.data.userId The user ID of the user who updated the comment.
|
|
1216
|
+
* @param params.data.updatedAt (optional) The date the comment metadata is set to be updated.
|
|
1217
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1218
|
+
* @returns The updated comment metadata.
|
|
1219
|
+
*/
|
|
1220
|
+
async editCommentMetadata(params, options) {
|
|
1221
|
+
const { roomId, threadId, commentId, data } = params;
|
|
1222
|
+
const res = await this.#post(
|
|
1223
|
+
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/metadata`,
|
|
1224
|
+
{
|
|
1225
|
+
...data,
|
|
1226
|
+
updatedAt: _optionalChain([data, 'access', _23 => _23.updatedAt, 'optionalAccess', _24 => _24.toISOString, 'call', _25 => _25()])
|
|
1227
|
+
},
|
|
1228
|
+
options
|
|
1229
|
+
);
|
|
1230
|
+
if (!res.ok) {
|
|
1231
|
+
throw await LiveblocksError.from(res);
|
|
1232
|
+
}
|
|
1233
|
+
return await res.json();
|
|
1234
|
+
}
|
|
1202
1235
|
/**
|
|
1203
1236
|
* Adds a new comment reaction to a comment.
|
|
1204
1237
|
* @param params.roomId The room ID to add the comment reaction in.
|
|
@@ -1216,7 +1249,7 @@ var Liveblocks = class {
|
|
|
1216
1249
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/add-reaction`,
|
|
1217
1250
|
{
|
|
1218
1251
|
...data,
|
|
1219
|
-
createdAt: _optionalChain([data, 'access',
|
|
1252
|
+
createdAt: _optionalChain([data, 'access', _26 => _26.createdAt, 'optionalAccess', _27 => _27.toISOString, 'call', _28 => _28()])
|
|
1220
1253
|
},
|
|
1221
1254
|
options
|
|
1222
1255
|
);
|
|
@@ -1242,7 +1275,7 @@ var Liveblocks = class {
|
|
|
1242
1275
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${params.commentId}/remove-reaction`,
|
|
1243
1276
|
{
|
|
1244
1277
|
...data,
|
|
1245
|
-
removedAt: _optionalChain([data, 'access',
|
|
1278
|
+
removedAt: _optionalChain([data, 'access', _29 => _29.removedAt, 'optionalAccess', _30 => _30.toISOString, 'call', _31 => _31()])
|
|
1246
1279
|
},
|
|
1247
1280
|
options
|
|
1248
1281
|
);
|
|
@@ -1318,7 +1351,7 @@ var Liveblocks = class {
|
|
|
1318
1351
|
*/
|
|
1319
1352
|
async *iterInboxNotifications(criteria, options) {
|
|
1320
1353
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
1321
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1354
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _32 => _32.pageSize]), () => ( 50)), 10);
|
|
1322
1355
|
let cursor = void 0;
|
|
1323
1356
|
while (true) {
|
|
1324
1357
|
const { nextCursor, data } = await this.getInboxNotifications(
|
|
@@ -1642,7 +1675,7 @@ var Liveblocks = class {
|
|
|
1642
1675
|
async getGroups(params, options) {
|
|
1643
1676
|
const res = await this.#get(
|
|
1644
1677
|
_core.url`/v2/groups`,
|
|
1645
|
-
{ startingAfter: _optionalChain([params, 'optionalAccess',
|
|
1678
|
+
{ startingAfter: _optionalChain([params, 'optionalAccess', _33 => _33.startingAfter]), limit: _optionalChain([params, 'optionalAccess', _34 => _34.limit]) },
|
|
1646
1679
|
options
|
|
1647
1680
|
);
|
|
1648
1681
|
if (!res.ok) {
|
|
@@ -1704,7 +1737,7 @@ var Liveblocks = class {
|
|
|
1704
1737
|
async massMutateStorage(criteria, callback, massOptions) {
|
|
1705
1738
|
const concurrency = _core.checkBounds.call(void 0,
|
|
1706
1739
|
"concurrency",
|
|
1707
|
-
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess',
|
|
1740
|
+
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess', _35 => _35.concurrency]), () => ( 8)),
|
|
1708
1741
|
1,
|
|
1709
1742
|
20
|
|
1710
1743
|
);
|
|
@@ -1720,7 +1753,7 @@ var Liveblocks = class {
|
|
|
1720
1753
|
}
|
|
1721
1754
|
async #_mutateOneRoom(roomId, room, callback, options) {
|
|
1722
1755
|
const debounceInterval = 200;
|
|
1723
|
-
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess',
|
|
1756
|
+
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess', _36 => _36.signal]));
|
|
1724
1757
|
let opsBuffer = [];
|
|
1725
1758
|
let outstandingFlush$ = void 0;
|
|
1726
1759
|
let lastFlush = performance.now();
|
|
@@ -1786,7 +1819,7 @@ var Liveblocks = class {
|
|
|
1786
1819
|
const res = await this.#post(
|
|
1787
1820
|
_core.url`/v2/rooms/${roomId}/send-message`,
|
|
1788
1821
|
{ messages },
|
|
1789
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
1822
|
+
{ signal: _optionalChain([options, 'optionalAccess', _37 => _37.signal]) }
|
|
1790
1823
|
);
|
|
1791
1824
|
if (!res.ok) {
|
|
1792
1825
|
throw await LiveblocksError.from(res);
|
|
@@ -1923,7 +1956,7 @@ var Liveblocks = class {
|
|
|
1923
1956
|
"Content-Type": params.file.type,
|
|
1924
1957
|
"Content-Length": String(params.file.size)
|
|
1925
1958
|
},
|
|
1926
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
1959
|
+
signal: _optionalChain([options, 'optionalAccess', _38 => _38.signal])
|
|
1927
1960
|
}
|
|
1928
1961
|
);
|
|
1929
1962
|
if (!res.ok) {
|
|
@@ -2055,6 +2088,184 @@ var Liveblocks = class {
|
|
|
2055
2088
|
data: page.data.map(inflateWebKnowledgeSourceLink)
|
|
2056
2089
|
};
|
|
2057
2090
|
}
|
|
2091
|
+
/* -------------------------------------------------------------------------------------------------
|
|
2092
|
+
* Agent Sessions
|
|
2093
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
2094
|
+
/**
|
|
2095
|
+
* Returns a list of agent sessions in a room.
|
|
2096
|
+
* @param params.roomId The room ID to get the agent sessions from.
|
|
2097
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2098
|
+
* @returns A list of agent sessions.
|
|
2099
|
+
*/
|
|
2100
|
+
async getAgentSessions(params, options) {
|
|
2101
|
+
const { roomId } = params;
|
|
2102
|
+
const res = await this.#get(
|
|
2103
|
+
_core.url`/v2/rooms/${roomId}/agent-sessions`,
|
|
2104
|
+
void 0,
|
|
2105
|
+
options
|
|
2106
|
+
);
|
|
2107
|
+
if (!res.ok) {
|
|
2108
|
+
throw await LiveblocksError.from(res);
|
|
2109
|
+
}
|
|
2110
|
+
return await res.json();
|
|
2111
|
+
}
|
|
2112
|
+
/**
|
|
2113
|
+
* Creates a new agent session in a room.
|
|
2114
|
+
* @param params.roomId The room ID to create the agent session in.
|
|
2115
|
+
* @param params.sessionId The session ID for the agent session.
|
|
2116
|
+
* @param params.metadata (optional) The metadata for the agent session.
|
|
2117
|
+
* @param params.timestamp (optional) The timestamp for the agent session. If not provided, the current time will be used.
|
|
2118
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2119
|
+
* @returns The created agent session.
|
|
2120
|
+
*/
|
|
2121
|
+
async createAgentSession(params, options) {
|
|
2122
|
+
const { roomId, sessionId, metadata, timestamp } = params;
|
|
2123
|
+
const res = await this.#post(
|
|
2124
|
+
_core.url`/v2/rooms/${roomId}/agent-sessions`,
|
|
2125
|
+
{ sessionId, metadata, timestamp },
|
|
2126
|
+
options
|
|
2127
|
+
);
|
|
2128
|
+
if (!res.ok) {
|
|
2129
|
+
throw await LiveblocksError.from(res);
|
|
2130
|
+
}
|
|
2131
|
+
return await res.json();
|
|
2132
|
+
}
|
|
2133
|
+
/**
|
|
2134
|
+
* Returns an agent session with the given id.
|
|
2135
|
+
* @param params.roomId The room ID to get the agent session from.
|
|
2136
|
+
* @param params.agentSessionId The agent session ID.
|
|
2137
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2138
|
+
* @returns The agent session.
|
|
2139
|
+
*/
|
|
2140
|
+
async getAgentSession(params, options) {
|
|
2141
|
+
const { roomId, agentSessionId } = params;
|
|
2142
|
+
const res = await this.#get(
|
|
2143
|
+
_core.url`/v2/rooms/${roomId}/agent-sessions/${agentSessionId}`,
|
|
2144
|
+
void 0,
|
|
2145
|
+
options
|
|
2146
|
+
);
|
|
2147
|
+
if (!res.ok) {
|
|
2148
|
+
throw await LiveblocksError.from(res);
|
|
2149
|
+
}
|
|
2150
|
+
return await res.json();
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Updates the metadata of an agent session.
|
|
2154
|
+
* @param params.roomId The room ID to update the agent session in.
|
|
2155
|
+
* @param params.agentSessionId The agent session ID to update.
|
|
2156
|
+
* @param params.metadata The metadata for the agent session.
|
|
2157
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2158
|
+
* @returns The updated agent session.
|
|
2159
|
+
*/
|
|
2160
|
+
async updateAgentSessionMetadata(params, options) {
|
|
2161
|
+
const { roomId, agentSessionId, metadata } = params;
|
|
2162
|
+
const res = await this.#post(
|
|
2163
|
+
_core.url`/v2/rooms/${roomId}/agent-sessions/${agentSessionId}`,
|
|
2164
|
+
{ metadata },
|
|
2165
|
+
options
|
|
2166
|
+
);
|
|
2167
|
+
if (!res.ok) {
|
|
2168
|
+
throw await LiveblocksError.from(res);
|
|
2169
|
+
}
|
|
2170
|
+
return await res.json();
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Deletes an agent session.
|
|
2174
|
+
* @param params.roomId The room ID to delete the agent session from.
|
|
2175
|
+
* @param params.agentSessionId The agent session ID to delete.
|
|
2176
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2177
|
+
*/
|
|
2178
|
+
async deleteAgentSession(params, options) {
|
|
2179
|
+
const { roomId, agentSessionId } = params;
|
|
2180
|
+
const res = await this.#delete(
|
|
2181
|
+
_core.url`/v2/rooms/${roomId}/agent-sessions/${agentSessionId}`,
|
|
2182
|
+
void 0,
|
|
2183
|
+
options
|
|
2184
|
+
);
|
|
2185
|
+
if (!res.ok) {
|
|
2186
|
+
throw await LiveblocksError.from(res);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
/**
|
|
2190
|
+
* Returns a list of agent messages in an agent session.
|
|
2191
|
+
* @param params.roomId The room ID to get the agent messages from.
|
|
2192
|
+
* @param params.agentSessionId The agent session ID to get the messages from.
|
|
2193
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2194
|
+
* @returns A list of agent messages.
|
|
2195
|
+
*/
|
|
2196
|
+
async getAgentMessages(params, options) {
|
|
2197
|
+
const { roomId, agentSessionId } = params;
|
|
2198
|
+
const res = await this.#get(
|
|
2199
|
+
_core.url`/v2/rooms/${roomId}/agent-sessions/${agentSessionId}/messages`,
|
|
2200
|
+
void 0,
|
|
2201
|
+
options
|
|
2202
|
+
);
|
|
2203
|
+
if (!res.ok) {
|
|
2204
|
+
throw await LiveblocksError.from(res);
|
|
2205
|
+
}
|
|
2206
|
+
return await res.json();
|
|
2207
|
+
}
|
|
2208
|
+
/**
|
|
2209
|
+
* Creates a new agent message in an agent session.
|
|
2210
|
+
* @param params.roomId The room ID to create the agent message in.
|
|
2211
|
+
* @param params.agentSessionId The agent session ID to create the message in.
|
|
2212
|
+
* @param params.id (optional) The message ID. If not provided, one will be generated.
|
|
2213
|
+
* @param params.timestamp (optional) The message timestamp. If not provided, the current time will be used.
|
|
2214
|
+
* @param params.data The message data.
|
|
2215
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2216
|
+
* @returns The created agent message.
|
|
2217
|
+
*/
|
|
2218
|
+
async createAgentMessage(params, options) {
|
|
2219
|
+
const { roomId, agentSessionId, id, timestamp, data } = params;
|
|
2220
|
+
const res = await this.#post(
|
|
2221
|
+
_core.url`/v2/rooms/${roomId}/agent-sessions/${agentSessionId}/messages`,
|
|
2222
|
+
{ id, timestamp, data },
|
|
2223
|
+
options
|
|
2224
|
+
);
|
|
2225
|
+
if (!res.ok) {
|
|
2226
|
+
throw await LiveblocksError.from(res);
|
|
2227
|
+
}
|
|
2228
|
+
return await res.json();
|
|
2229
|
+
}
|
|
2230
|
+
/**
|
|
2231
|
+
* Updates an agent message.
|
|
2232
|
+
* @param params.roomId The room ID to update the agent message in.
|
|
2233
|
+
* @param params.agentSessionId The agent session ID to update the message in.
|
|
2234
|
+
* @param params.messageId The message ID to update.
|
|
2235
|
+
* @param params.data The message data.
|
|
2236
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2237
|
+
* @returns The updated agent message.
|
|
2238
|
+
*/
|
|
2239
|
+
async updateAgentMessage(params, options) {
|
|
2240
|
+
const { roomId, agentSessionId, messageId, data } = params;
|
|
2241
|
+
const res = await this.#post(
|
|
2242
|
+
_core.url`/v2/rooms/${roomId}/agent-sessions/${agentSessionId}/messages/${messageId}`,
|
|
2243
|
+
{ data },
|
|
2244
|
+
options
|
|
2245
|
+
);
|
|
2246
|
+
if (!res.ok) {
|
|
2247
|
+
throw await LiveblocksError.from(res);
|
|
2248
|
+
}
|
|
2249
|
+
return await res.json();
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Deletes an agent message.
|
|
2253
|
+
* @param params.roomId The room ID to delete the agent message from.
|
|
2254
|
+
* @param params.agentSessionId The agent session ID to delete the message from.
|
|
2255
|
+
* @param params.messageId The message ID to delete.
|
|
2256
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
2257
|
+
*/
|
|
2258
|
+
async deleteAgentMessage(params, options) {
|
|
2259
|
+
const { roomId, agentSessionId, messageId } = params;
|
|
2260
|
+
const res = await this.#delete(
|
|
2261
|
+
_core.url`/v2/rooms/${roomId}/agent-sessions/${agentSessionId}/messages/${messageId}`,
|
|
2262
|
+
void 0,
|
|
2263
|
+
options
|
|
2264
|
+
);
|
|
2265
|
+
if (!res.ok) {
|
|
2266
|
+
throw await LiveblocksError.from(res);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2058
2269
|
};
|
|
2059
2270
|
var LiveblocksError = class _LiveblocksError extends Error {
|
|
2060
2271
|
|
|
@@ -2199,6 +2410,7 @@ var WebhookHandler = class _WebhookHandler {
|
|
|
2199
2410
|
"commentDeleted",
|
|
2200
2411
|
"commentReactionAdded",
|
|
2201
2412
|
"commentReactionRemoved",
|
|
2413
|
+
"commentMetadataUpdated",
|
|
2202
2414
|
"threadMetadataUpdated",
|
|
2203
2415
|
"threadCreated",
|
|
2204
2416
|
"threadDeleted",
|