@liveblocks/node
Advanced tools
Comparing version 1.11.3 to 1.12.0-lexical2
@@ -1,2 +0,2 @@ | ||
import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, BaseMetadata, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings } from '@liveblocks/core'; | ||
import { IUserInfo, Json, PlainLsonObject, JsonObject, BaseMetadata, QueryMetadata, ThreadData, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData } from '@liveblocks/core'; | ||
export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, Lson, LsonObject, PlainLsonObject, ResolveUsersArgs, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionedIdsFromCommentBody, stringifyCommentBody } from '@liveblocks/core'; | ||
@@ -178,2 +178,3 @@ import { IncomingHttpHeaders } from 'http'; | ||
declare type RoomMetadata = Record<string, string | string[]>; | ||
declare type QueryRoomMetadata = Record<string, string>; | ||
declare type RoomInfo = { | ||
@@ -270,2 +271,3 @@ type: "room"; | ||
* @param params.groupIds (optional) A filter on groups accesses. Multiple groups can be used. | ||
* @param params.query (optional) A query to filter rooms by. It is based on our query language. You can filter by metadata and room ID. | ||
* @returns A list of rooms. | ||
@@ -276,5 +278,36 @@ */ | ||
startingAfter?: string; | ||
metadata?: RoomMetadata; | ||
/** | ||
* @deprecated Use `query` instead. | ||
*/ | ||
metadata?: QueryRoomMetadata; | ||
userId?: string; | ||
groupIds?: string[]; | ||
/** | ||
* The query to filter rooms by. It is based on our query language. | ||
* @example | ||
* ``` | ||
* { | ||
* query: 'metadata["status"]:"open" AND roomId^"liveblocks:"' | ||
* } | ||
* ``` | ||
* @example | ||
* ``` | ||
* { | ||
* query: { | ||
* metadata: { | ||
* status: "open", | ||
* }, | ||
* roomId: { | ||
* startsWith: "liveblocks:" | ||
* } | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
query?: string | { | ||
metadata?: QueryRoomMetadata; | ||
roomId?: { | ||
startsWith: string; | ||
}; | ||
}; | ||
}): Promise<{ | ||
@@ -462,6 +495,35 @@ nextPage: string | null; | ||
* @param params.roomId The room ID to get the threads from. | ||
* @param params.query The query to filter threads by. It is based on our query language and can filter by metadata. | ||
* @returns A list of threads. | ||
*/ | ||
getThreads(params: { | ||
getThreads<M extends BaseMetadata>(params: { | ||
roomId: string; | ||
/** | ||
* The query to filter threads by. It is based on our query language. | ||
* | ||
* @example | ||
* ``` | ||
* { | ||
* query: "metadata['organization']^'liveblocks:' AND metadata['status']:'open' AND metadata['resolved']:false AND metadata['priority']:3" | ||
* } | ||
* ``` | ||
* @example | ||
* ``` | ||
* { | ||
* query: { | ||
* metadata: { | ||
* status: "open", | ||
* resolved: false, | ||
* priority: 3, | ||
* organization: { | ||
* startsWith: "liveblocks:" | ||
* } | ||
* } | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
query?: string | { | ||
metadata?: Partial<QueryMetadata<M>>; | ||
}; | ||
}): Promise<{ | ||
@@ -477,6 +539,6 @@ data: ThreadData[]; | ||
*/ | ||
getThread<TThreadMetadata extends BaseMetadata = never>(params: { | ||
getThread<M extends BaseMetadata = never>(params: { | ||
roomId: string; | ||
threadId: string; | ||
}): Promise<ThreadData<TThreadMetadata>>; | ||
}): Promise<ThreadData<M>>; | ||
/** | ||
@@ -567,6 +629,6 @@ * Gets a thread's participants. | ||
*/ | ||
createThread<TThreadMetadata extends BaseMetadata = never>(params: { | ||
createThread<M extends BaseMetadata = never>(params: { | ||
roomId: string; | ||
data: { | ||
metadata?: [TThreadMetadata] extends [never] ? Record<string, never> : TThreadMetadata; | ||
metadata?: [M] extends [never] ? Record<string, never> : M; | ||
comment: { | ||
@@ -578,3 +640,3 @@ userId: string; | ||
}; | ||
}): Promise<ThreadData<TThreadMetadata>>; | ||
}): Promise<ThreadData<M>>; | ||
/** | ||
@@ -589,3 +651,3 @@ * Updates the metadata of the specified thread in a room. | ||
*/ | ||
editThreadMetadata<TThreadMetadata extends BaseMetadata = never>(params: { | ||
editThreadMetadata<M extends BaseMetadata = never>(params: { | ||
roomId: string; | ||
@@ -598,3 +660,3 @@ threadId: string; | ||
}; | ||
}): Promise<TThreadMetadata>; | ||
}): Promise<M>; | ||
/** | ||
@@ -686,2 +748,9 @@ * Adds a new comment reaction to a comment. | ||
}): Promise<RoomInfo>; | ||
triggerInboxNotification(params: { | ||
userId: string; | ||
kind: `$${string}`; | ||
roomId?: string; | ||
subjectId: string; | ||
activityData: ActivityData; | ||
}): Promise<void>; | ||
} | ||
@@ -935,3 +1004,3 @@ declare class LiveblocksError extends Error { | ||
}; | ||
declare type NotificationEvent = { | ||
declare type ThreadNotificationEvent = { | ||
type: "notification"; | ||
@@ -953,3 +1022,39 @@ data: { | ||
}; | ||
declare type TextMentionNotificationEvent = { | ||
type: "notification"; | ||
data: { | ||
channel: "email"; | ||
kind: "textMention"; | ||
projectId: string; | ||
roomId: string; | ||
userId: string; | ||
mentionId: string; | ||
inboxNotificationId: string; | ||
/** | ||
* ISO 8601 datestring | ||
* @example "2021-03-01T12:00:00.000Z" | ||
*/ | ||
createdAt: string; | ||
}; | ||
}; | ||
declare type CustomKind = `$${string}`; | ||
declare type CustomNotificationEvent = { | ||
type: "notification"; | ||
data: { | ||
channel: "email"; | ||
kind: CustomKind; | ||
projectId: string; | ||
roomId: string | null; | ||
userId: string; | ||
subjectId: string; | ||
inboxNotificationId: string; | ||
/** | ||
* ISO 8601 datestring | ||
* @example "2021-03-01T12:00:00.000Z" | ||
*/ | ||
createdAt: string; | ||
}; | ||
}; | ||
declare type NotificationEvent = ThreadNotificationEvent | TextMentionNotificationEvent | CustomNotificationEvent; | ||
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, Liveblocks, LiveblocksError, type LiveblocksOptions, type NotificationEvent, type RoomAccesses, type RoomCreatedEvent, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type ThreadCreatedEvent, type ThreadMetadataUpdatedEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest, authorize }; |
@@ -6,3 +6,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/index.ts | ||
var PKG_NAME = "@liveblocks/node"; | ||
var PKG_VERSION = "1.11.3"; | ||
var PKG_VERSION = "1.12.0-lexical2"; | ||
var PKG_FORMAT = "cjs"; | ||
@@ -119,2 +119,4 @@ | ||
// src/Session.ts | ||
@@ -410,2 +412,3 @@ var ALL_PERMISSIONS = Object.freeze([ | ||
* @param params.groupIds (optional) A filter on groups accesses. Multiple groups can be used. | ||
* @param params.query (optional) A query to filter rooms by. It is based on our query language. You can filter by metadata and room ID. | ||
* @returns A list of rooms. | ||
@@ -415,2 +418,8 @@ */ | ||
const path = url`/v2/rooms`; | ||
let query; | ||
if (typeof params.query === "string") { | ||
query = params.query; | ||
} else if (typeof params.query === "object") { | ||
query = _core.objectToQuery.call(void 0, params.query); | ||
} | ||
const queryParams = { | ||
@@ -423,7 +432,8 @@ limit: params.limit, | ||
...Object.fromEntries( | ||
Object.entries(_nullishCoalesce(params.metadata, () => ( {}))).map(([key, val]) => { | ||
const value = Array.isArray(val) ? val.join(",") : val; | ||
return [`metadata.${key}`, value]; | ||
}) | ||
) | ||
Object.entries(_nullishCoalesce(params.metadata, () => ( {}))).map(([key, val]) => [ | ||
`metadata.${key}`, | ||
val | ||
]) | ||
), | ||
query | ||
}; | ||
@@ -799,2 +809,3 @@ const res = await this.get(path, queryParams); | ||
* @param params.roomId The room ID to get the threads from. | ||
* @param params.query The query to filter threads by. It is based on our query language and can filter by metadata. | ||
* @returns A list of threads. | ||
@@ -804,3 +815,11 @@ */ | ||
const { roomId } = params; | ||
const res = await this.get(url`/v2/rooms/${roomId}/threads`); | ||
let query; | ||
if (typeof params.query === "string") { | ||
query = params.query; | ||
} else if (typeof params.query === "object") { | ||
query = _core.objectToQuery.call(void 0, params.query); | ||
} | ||
const res = await this.get(url`/v2/rooms/${roomId}/threads`, { | ||
query | ||
}); | ||
if (!res.ok) { | ||
@@ -829,5 +848,3 @@ const text = await res.text(); | ||
} | ||
return _core.convertToThreadData.call(void 0, | ||
await res.json() | ||
); | ||
return _core.convertToThreadData.call(void 0, await res.json()); | ||
} | ||
@@ -962,5 +979,3 @@ /** | ||
} | ||
return _core.convertToThreadData.call(void 0, | ||
await res.json() | ||
); | ||
return _core.convertToThreadData.call(void 0, await res.json()); | ||
} | ||
@@ -1054,8 +1069,5 @@ /** | ||
} | ||
const data = await res.json(); | ||
return { | ||
...data, | ||
notifiedAt: new Date(data.notifiedAt), | ||
readAt: data.readAt ? new Date(data.readAt) : null | ||
}; | ||
return _core.convertToInboxNotificationData.call(void 0, | ||
await res.json() | ||
); | ||
} | ||
@@ -1135,2 +1147,9 @@ /** | ||
} | ||
async triggerInboxNotification(params) { | ||
const res = await this.post(url`/v2/inbox-notifications/trigger`, params); | ||
if (!res.ok) { | ||
const text = await res.text(); | ||
throw new LiveblocksError(res.status, text); | ||
} | ||
} | ||
}; | ||
@@ -1253,4 +1272,15 @@ var LiveblocksError = class extends Error { | ||
"notification" | ||
].includes(event.type)) | ||
].includes(event.type)) { | ||
if (event.type === "notification") { | ||
const notification = event; | ||
if (notification.data.kind === "thread" || notification.data.kind === "textMention" || notification.data.kind.startsWith("$")) { | ||
return; | ||
} else { | ||
throw new Error( | ||
`Unknown notification kind: ${notification.data.kind}` | ||
); | ||
} | ||
} | ||
return; | ||
} | ||
throw new Error( | ||
@@ -1257,0 +1287,0 @@ "Unknown event type, please upgrade to a higher version of @liveblocks/node" |
{ | ||
"name": "@liveblocks/node", | ||
"version": "1.11.3", | ||
"version": "1.12.0-lexical2", | ||
"description": "A server-side utility that lets you set up a Liveblocks authentication endpoint. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.", | ||
@@ -36,3 +36,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@liveblocks/core": "1.11.3", | ||
"@liveblocks/core": "1.12.0-lexical2", | ||
"@stablelib/base64": "^1.0.1", | ||
@@ -39,0 +39,0 @@ "fast-sha256": "^1.3.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
386919
3611
1
+ Added@liveblocks/core@1.12.0-lexical2(transitive)
- Removed@liveblocks/core@1.11.3(transitive)