@liveblocks/node
Advanced tools
Comparing version 2.16.0-toolbars5 to 2.17.0-channels1
@@ -1,3 +0,3 @@ | ||
import { BaseUserMeta, DU, OptionalTupleUnless, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, KDAD, DAD, LsonObject, ToImmutable, PartialUnless, BaseMetadata, DE, DM, DS } 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'; | ||
import { BaseUserMeta, DU, OptionalTupleUnless, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, KDAD, DAD, ChannelsNotificationSettings, PartialChannelsNotificationSettings, LsonObject, ToImmutable, PartialUnless, BaseMetadata, DE, DM, DS, NotificationChannel } 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, isChannelNotificationSettingEnabled, stringifyCommentBody } from '@liveblocks/core'; | ||
import { IncomingHttpHeaders } from 'http'; | ||
@@ -758,2 +758,25 @@ | ||
}): Promise<void>; | ||
/** | ||
* Get channels notification settings for a user for a project. | ||
* @param params.userId The user ID to get the channels notifications settings for. | ||
*/ | ||
getChannelsNotificationSettings(params: { | ||
userId: string; | ||
}): Promise<ChannelsNotificationSettings>; | ||
/** | ||
* Update the user's channels notification settings. | ||
* @param params.userId The user ID to update the channels notification settings for. | ||
* @param params.data The new channels notification settings for the user. | ||
*/ | ||
updateChannelsNotificationSettings(params: { | ||
userId: string; | ||
data: PartialChannelsNotificationSettings; | ||
}): Promise<ChannelsNotificationSettings>; | ||
/** | ||
* Delete the user's channels notification settings | ||
* @param params.userId The user ID to update the channels notification settings for. | ||
*/ | ||
deleteChannelsNotificationSettings(params: { | ||
userId: string; | ||
}): Promise<void>; | ||
} | ||
@@ -1031,3 +1054,3 @@ declare class LiveblocksError extends Error { | ||
data: { | ||
channel: "email"; | ||
channel: NotificationChannel; | ||
kind: "thread"; | ||
@@ -1049,3 +1072,3 @@ projectId: string; | ||
data: { | ||
channel: "email"; | ||
channel: NotificationChannel; | ||
kind: "textMention"; | ||
@@ -1064,7 +1087,6 @@ projectId: string; | ||
}; | ||
type CustomKind = `$${string}`; | ||
type CustomNotificationEvent = { | ||
type: "notification"; | ||
data: { | ||
channel: "email"; | ||
channel: NotificationChannel; | ||
kind: CustomKind; | ||
@@ -1107,2 +1129,13 @@ projectId: string; | ||
declare function isTextMentionNotificationEvent(event: WebhookEvent): event is TextMentionNotificationEvent; | ||
/** | ||
* Type guard to check if a webhook event is a `CustomNotificationEvent` | ||
* | ||
* The check is made against the event type and event data kind. | ||
* You should use this guard to safely check the webhook event you received | ||
* when you're expecting a `CustomNotificationEvent`. | ||
* | ||
* @param event The webhook event received after calling `webhookHandler.verifyRequest()`. | ||
* @returns A boolean type predicate. | ||
*/ | ||
declare function isCustomNotificationEvent(event: WebhookEvent): event is CustomNotificationEvent; | ||
@@ -1116,2 +1149,2 @@ /** | ||
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CustomNotificationEvent, Liveblocks, LiveblocksError, type LiveblocksOptions, type NotificationEvent, type RoomAccesses, type RoomCreatedEvent, type RoomData, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isTextMentionNotificationEvent, isThreadNotificationEvent }; | ||
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CustomNotificationEvent, Liveblocks, LiveblocksError, type LiveblocksOptions, type NotificationEvent, type RoomAccesses, type RoomCreatedEvent, type RoomData, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isCustomNotificationEvent, isTextMentionNotificationEvent, isThreadNotificationEvent }; |
@@ -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; } var _class;// src/index.ts | ||
var PKG_NAME = "@liveblocks/node"; | ||
var PKG_VERSION = "2.16.0-toolbars5"; | ||
var PKG_VERSION = "2.17.0-channels1"; | ||
var PKG_FORMAT = "cjs"; | ||
@@ -1205,2 +1205,48 @@ | ||
} | ||
/** | ||
* Get channels notification settings for a user for a project. | ||
* @param params.userId The user ID to get the channels notifications settings for. | ||
*/ | ||
async getChannelsNotificationSettings(params) { | ||
const { userId } = params; | ||
const res = await this.#get( | ||
_core.url`/v2/users/${userId}/channels-notification-settings` | ||
); | ||
if (!res.ok) { | ||
const text = await res.text(); | ||
throw new LiveblocksError(res.status, text); | ||
} | ||
return await res.json(); | ||
} | ||
/** | ||
* Update the user's channels notification settings. | ||
* @param params.userId The user ID to update the channels notification settings for. | ||
* @param params.data The new channels notification settings for the user. | ||
*/ | ||
async updateChannelsNotificationSettings(params) { | ||
const { userId, data } = params; | ||
const res = await this.#post( | ||
_core.url`/v2/users/${userId}/channels-notification-settings`, | ||
data | ||
); | ||
if (!res.ok) { | ||
const text = await res.text(); | ||
throw new LiveblocksError(res.status, text); | ||
} | ||
return await res.json(); | ||
} | ||
/** | ||
* Delete the user's channels notification settings | ||
* @param params.userId The user ID to update the channels notification settings for. | ||
*/ | ||
async deleteChannelsNotificationSettings(params) { | ||
const { userId } = params; | ||
const res = await this.#delete( | ||
_core.url`/v2/users/${userId}/channels-notification-settings` | ||
); | ||
if (!res.ok) { | ||
const text = await res.text(); | ||
throw new LiveblocksError(res.status, text); | ||
} | ||
} | ||
}; | ||
@@ -1330,7 +1376,7 @@ var LiveblocksError = class extends Error { | ||
const notification = event; | ||
if (notification.data.kind === "thread" || notification.data.kind === "textMention" || notification.data.kind.startsWith("$")) { | ||
if (notification.data.kind === "thread" || notification.data.kind === "textMention" || isCustomKind(notification.data.kind)) { | ||
return; | ||
} else { | ||
throw new Error( | ||
`Unknown notification kind: ${notification.data.kind}` | ||
`Unknown notification kind: ${JSON.stringify(notification.data.kind)}` | ||
); | ||
@@ -1348,2 +1394,5 @@ } | ||
var isNotUndefined = (value) => value !== void 0; | ||
var isCustomKind = (value) => { | ||
return isString(value) && value.startsWith("$"); | ||
}; | ||
function isThreadNotificationEvent(event) { | ||
@@ -1355,2 +1404,5 @@ return event.type === "notification" && event.data.kind === "thread"; | ||
} | ||
function isCustomNotificationEvent(event) { | ||
return event.type === "notification" && isCustomKind(event.data.kind); | ||
} | ||
@@ -1362,2 +1414,3 @@ // src/index.ts | ||
_core.detectDupes.call(void 0, PKG_NAME, PKG_VERSION, PKG_FORMAT); | ||
@@ -1372,3 +1425,5 @@ | ||
exports.Liveblocks = Liveblocks; exports.LiveblocksError = LiveblocksError; exports.WebhookHandler = WebhookHandler; exports.getMentionedIdsFromCommentBody = _core.getMentionedIdsFromCommentBody; exports.isTextMentionNotificationEvent = isTextMentionNotificationEvent; exports.isThreadNotificationEvent = isThreadNotificationEvent; exports.stringifyCommentBody = _core.stringifyCommentBody; | ||
exports.Liveblocks = Liveblocks; exports.LiveblocksError = LiveblocksError; exports.WebhookHandler = WebhookHandler; exports.getMentionedIdsFromCommentBody = _core.getMentionedIdsFromCommentBody; exports.isChannelNotificationSettingEnabled = _core.isChannelNotificationSettingEnabled; exports.isCustomNotificationEvent = isCustomNotificationEvent; exports.isTextMentionNotificationEvent = isTextMentionNotificationEvent; exports.isThreadNotificationEvent = isThreadNotificationEvent; exports.stringifyCommentBody = _core.stringifyCommentBody; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@liveblocks/node", | ||
"version": "2.16.0-toolbars5", | ||
"version": "2.17.0-channels1", | ||
"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.", | ||
@@ -37,3 +37,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@liveblocks/core": "2.16.0-toolbars5", | ||
"@liveblocks/core": "2.17.0-channels1", | ||
"@stablelib/base64": "^1.0.1", | ||
@@ -40,0 +40,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
409224
3949
+ Added@liveblocks/core@2.17.0-channels1(transitive)
- Removed@liveblocks/core@2.16.0-toolbars5(transitive)