@liveblocks/core 2.19.0 → 2.21.0-emails1
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 +88 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -9
- package/dist/index.d.ts +48 -9
- package/dist/index.js +87 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2495,11 +2495,24 @@ type NotificationChannelSettings = {
|
|
|
2495
2495
|
[K in NotificationKind]: boolean;
|
|
2496
2496
|
};
|
|
2497
2497
|
/**
|
|
2498
|
-
*
|
|
2498
|
+
* @private
|
|
2499
|
+
*
|
|
2500
|
+
* Base definition of user notification settings.
|
|
2501
|
+
* Plain means it's a simple object coming from the remote backend.
|
|
2502
|
+
*
|
|
2503
|
+
* It's the raw settings object where somme channels cannot exists
|
|
2504
|
+
* because there are no notification kinds enabled on the dashboard.
|
|
2505
|
+
* And this object isn't yet proxied by the creator factory `createUserNotificationSettings`.
|
|
2506
|
+
*/
|
|
2507
|
+
type UserNotificationSettingsPlain = {
|
|
2508
|
+
[C in NotificationChannel]?: NotificationChannelSettings;
|
|
2509
|
+
};
|
|
2510
|
+
/**
|
|
2511
|
+
* User notification settings.
|
|
2499
2512
|
* One channel for one set of settings.
|
|
2500
2513
|
*/
|
|
2501
2514
|
type UserNotificationSettings = {
|
|
2502
|
-
[C in NotificationChannel]: NotificationChannelSettings;
|
|
2515
|
+
[C in NotificationChannel]: NotificationChannelSettings | null;
|
|
2503
2516
|
};
|
|
2504
2517
|
/**
|
|
2505
2518
|
* It creates a deep partial specific for `UserNotificationSettings`
|
|
@@ -2514,16 +2527,42 @@ type DeepPartialWithAugmentation<T> = T extends object ? {
|
|
|
2514
2527
|
} : DeepPartialWithAugmentation<T[P]>;
|
|
2515
2528
|
} : T;
|
|
2516
2529
|
/**
|
|
2517
|
-
* Partial user notification settings
|
|
2518
|
-
*
|
|
2530
|
+
* Partial user notification settings with augmentation preserved gracefully.
|
|
2531
|
+
* It means you can update the settings without being forced to define every keys.
|
|
2532
|
+
* Useful when implementing update functions.
|
|
2519
2533
|
*/
|
|
2520
|
-
type PartialUserNotificationSettings = DeepPartialWithAugmentation<
|
|
2534
|
+
type PartialUserNotificationSettings = DeepPartialWithAugmentation<UserNotificationSettingsPlain>;
|
|
2535
|
+
/**
|
|
2536
|
+
* @private
|
|
2537
|
+
*
|
|
2538
|
+
* Creates a `UserNotificationSettings` object with the given initial plain settings.
|
|
2539
|
+
* It defines a getter for each channel to access the settings and returns `null` with an error log
|
|
2540
|
+
* in case the required channel isn't enabled in the dashboard.
|
|
2541
|
+
*
|
|
2542
|
+
* You can see this function as `Proxy` like around `UserNotificationSettingsPlain` type.
|
|
2543
|
+
* We can't predict what will be enabled on the dashboard or not, so it's important
|
|
2544
|
+
* provide a good DX to developers by returning `null` completed by an error log
|
|
2545
|
+
* when they try to access a channel that isn't enabled in the dashboard.
|
|
2546
|
+
*/
|
|
2547
|
+
declare function createUserNotificationSettings(plain: UserNotificationSettingsPlain): UserNotificationSettings;
|
|
2548
|
+
/**
|
|
2549
|
+
* @private
|
|
2550
|
+
*
|
|
2551
|
+
* Patch a `UserNotificationSettings` object by applying notification kind updates
|
|
2552
|
+
* coming from a `PartialUserNotificationSettings` object.
|
|
2553
|
+
*/
|
|
2554
|
+
declare function patchUserNotificationSettings(existing: UserNotificationSettings, patch: PartialUserNotificationSettings): UserNotificationSettings;
|
|
2521
2555
|
/**
|
|
2522
2556
|
*
|
|
2523
2557
|
* Utility to check if a notification channel settings
|
|
2524
2558
|
* is enabled for every notification kinds.
|
|
2559
|
+
*
|
|
2560
|
+
* Usage:
|
|
2561
|
+
* ```ts
|
|
2562
|
+
* const isEmailChannelEnabled = isNotificationChannelEnabled(settings.email);
|
|
2563
|
+
* ```
|
|
2525
2564
|
*/
|
|
2526
|
-
declare function isNotificationChannelEnabled(settings: NotificationChannelSettings): boolean;
|
|
2565
|
+
declare function isNotificationChannelEnabled(settings: NotificationChannelSettings | null): boolean;
|
|
2527
2566
|
|
|
2528
2567
|
interface RoomHttpApi<M extends BaseMetadata> {
|
|
2529
2568
|
getThreads(options: {
|
|
@@ -2741,8 +2780,8 @@ interface NotificationHttpApi<M extends BaseMetadata> {
|
|
|
2741
2780
|
deleteInboxNotification(inboxNotificationId: string): Promise<void>;
|
|
2742
2781
|
getUserNotificationSettings(options?: {
|
|
2743
2782
|
signal?: AbortSignal;
|
|
2744
|
-
}): Promise<
|
|
2745
|
-
updateUserNotificationSettings(settings: PartialUserNotificationSettings): Promise<
|
|
2783
|
+
}): Promise<UserNotificationSettingsPlain>;
|
|
2784
|
+
updateUserNotificationSettings(settings: PartialUserNotificationSettings): Promise<UserNotificationSettingsPlain>;
|
|
2746
2785
|
}
|
|
2747
2786
|
interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, NotificationHttpApi<M> {
|
|
2748
2787
|
getUserThreads_experimental(options?: {
|
|
@@ -3974,4 +4013,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
3974
4013
|
/** @deprecated Use HttpError instead. */
|
|
3975
4014
|
declare const NotificationsApiError: typeof HttpError;
|
|
3976
4015
|
|
|
3977
|
-
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
|
4016
|
+
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, type UserNotificationSettingsPlain, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, createUserNotificationSettings, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchUserNotificationSettings, raise, resolveUsersInCommentBody, shallow, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -2495,11 +2495,24 @@ type NotificationChannelSettings = {
|
|
|
2495
2495
|
[K in NotificationKind]: boolean;
|
|
2496
2496
|
};
|
|
2497
2497
|
/**
|
|
2498
|
-
*
|
|
2498
|
+
* @private
|
|
2499
|
+
*
|
|
2500
|
+
* Base definition of user notification settings.
|
|
2501
|
+
* Plain means it's a simple object coming from the remote backend.
|
|
2502
|
+
*
|
|
2503
|
+
* It's the raw settings object where somme channels cannot exists
|
|
2504
|
+
* because there are no notification kinds enabled on the dashboard.
|
|
2505
|
+
* And this object isn't yet proxied by the creator factory `createUserNotificationSettings`.
|
|
2506
|
+
*/
|
|
2507
|
+
type UserNotificationSettingsPlain = {
|
|
2508
|
+
[C in NotificationChannel]?: NotificationChannelSettings;
|
|
2509
|
+
};
|
|
2510
|
+
/**
|
|
2511
|
+
* User notification settings.
|
|
2499
2512
|
* One channel for one set of settings.
|
|
2500
2513
|
*/
|
|
2501
2514
|
type UserNotificationSettings = {
|
|
2502
|
-
[C in NotificationChannel]: NotificationChannelSettings;
|
|
2515
|
+
[C in NotificationChannel]: NotificationChannelSettings | null;
|
|
2503
2516
|
};
|
|
2504
2517
|
/**
|
|
2505
2518
|
* It creates a deep partial specific for `UserNotificationSettings`
|
|
@@ -2514,16 +2527,42 @@ type DeepPartialWithAugmentation<T> = T extends object ? {
|
|
|
2514
2527
|
} : DeepPartialWithAugmentation<T[P]>;
|
|
2515
2528
|
} : T;
|
|
2516
2529
|
/**
|
|
2517
|
-
* Partial user notification settings
|
|
2518
|
-
*
|
|
2530
|
+
* Partial user notification settings with augmentation preserved gracefully.
|
|
2531
|
+
* It means you can update the settings without being forced to define every keys.
|
|
2532
|
+
* Useful when implementing update functions.
|
|
2519
2533
|
*/
|
|
2520
|
-
type PartialUserNotificationSettings = DeepPartialWithAugmentation<
|
|
2534
|
+
type PartialUserNotificationSettings = DeepPartialWithAugmentation<UserNotificationSettingsPlain>;
|
|
2535
|
+
/**
|
|
2536
|
+
* @private
|
|
2537
|
+
*
|
|
2538
|
+
* Creates a `UserNotificationSettings` object with the given initial plain settings.
|
|
2539
|
+
* It defines a getter for each channel to access the settings and returns `null` with an error log
|
|
2540
|
+
* in case the required channel isn't enabled in the dashboard.
|
|
2541
|
+
*
|
|
2542
|
+
* You can see this function as `Proxy` like around `UserNotificationSettingsPlain` type.
|
|
2543
|
+
* We can't predict what will be enabled on the dashboard or not, so it's important
|
|
2544
|
+
* provide a good DX to developers by returning `null` completed by an error log
|
|
2545
|
+
* when they try to access a channel that isn't enabled in the dashboard.
|
|
2546
|
+
*/
|
|
2547
|
+
declare function createUserNotificationSettings(plain: UserNotificationSettingsPlain): UserNotificationSettings;
|
|
2548
|
+
/**
|
|
2549
|
+
* @private
|
|
2550
|
+
*
|
|
2551
|
+
* Patch a `UserNotificationSettings` object by applying notification kind updates
|
|
2552
|
+
* coming from a `PartialUserNotificationSettings` object.
|
|
2553
|
+
*/
|
|
2554
|
+
declare function patchUserNotificationSettings(existing: UserNotificationSettings, patch: PartialUserNotificationSettings): UserNotificationSettings;
|
|
2521
2555
|
/**
|
|
2522
2556
|
*
|
|
2523
2557
|
* Utility to check if a notification channel settings
|
|
2524
2558
|
* is enabled for every notification kinds.
|
|
2559
|
+
*
|
|
2560
|
+
* Usage:
|
|
2561
|
+
* ```ts
|
|
2562
|
+
* const isEmailChannelEnabled = isNotificationChannelEnabled(settings.email);
|
|
2563
|
+
* ```
|
|
2525
2564
|
*/
|
|
2526
|
-
declare function isNotificationChannelEnabled(settings: NotificationChannelSettings): boolean;
|
|
2565
|
+
declare function isNotificationChannelEnabled(settings: NotificationChannelSettings | null): boolean;
|
|
2527
2566
|
|
|
2528
2567
|
interface RoomHttpApi<M extends BaseMetadata> {
|
|
2529
2568
|
getThreads(options: {
|
|
@@ -2741,8 +2780,8 @@ interface NotificationHttpApi<M extends BaseMetadata> {
|
|
|
2741
2780
|
deleteInboxNotification(inboxNotificationId: string): Promise<void>;
|
|
2742
2781
|
getUserNotificationSettings(options?: {
|
|
2743
2782
|
signal?: AbortSignal;
|
|
2744
|
-
}): Promise<
|
|
2745
|
-
updateUserNotificationSettings(settings: PartialUserNotificationSettings): Promise<
|
|
2783
|
+
}): Promise<UserNotificationSettingsPlain>;
|
|
2784
|
+
updateUserNotificationSettings(settings: PartialUserNotificationSettings): Promise<UserNotificationSettingsPlain>;
|
|
2746
2785
|
}
|
|
2747
2786
|
interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, NotificationHttpApi<M> {
|
|
2748
2787
|
getUserThreads_experimental(options?: {
|
|
@@ -3974,4 +4013,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
3974
4013
|
/** @deprecated Use HttpError instead. */
|
|
3975
4014
|
declare const NotificationsApiError: typeof HttpError;
|
|
3976
4015
|
|
|
3977
|
-
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
|
4016
|
+
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, type UserNotificationSettingsPlain, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, createUserNotificationSettings, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchUserNotificationSettings, raise, resolveUsersInCommentBody, shallow, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "2.
|
|
9
|
+
var PKG_VERSION = "2.21.0-emails1";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -187,6 +187,12 @@ function keys(obj) {
|
|
|
187
187
|
function values(obj) {
|
|
188
188
|
return Object.values(obj);
|
|
189
189
|
}
|
|
190
|
+
function create(obj, descriptors) {
|
|
191
|
+
if (typeof descriptors !== "undefined") {
|
|
192
|
+
return Object.create(obj, descriptors);
|
|
193
|
+
}
|
|
194
|
+
return Object.create(obj);
|
|
195
|
+
}
|
|
190
196
|
function mapValues(obj, mapFn) {
|
|
191
197
|
const result = {};
|
|
192
198
|
for (const pair of Object.entries(obj)) {
|
|
@@ -3597,6 +3603,71 @@ function unlinkDevTools(roomId) {
|
|
|
3597
3603
|
});
|
|
3598
3604
|
}
|
|
3599
3605
|
|
|
3606
|
+
// src/protocol/UserNotificationSettings.ts
|
|
3607
|
+
var kPlain = Symbol("user-notification-settings-plain");
|
|
3608
|
+
function createUserNotificationSettings(plain) {
|
|
3609
|
+
const channels = [
|
|
3610
|
+
"email",
|
|
3611
|
+
"slack",
|
|
3612
|
+
"teams",
|
|
3613
|
+
"webPush"
|
|
3614
|
+
];
|
|
3615
|
+
const descriptors = {
|
|
3616
|
+
[kPlain]: {
|
|
3617
|
+
value: plain,
|
|
3618
|
+
enumerable: false
|
|
3619
|
+
}
|
|
3620
|
+
};
|
|
3621
|
+
for (const channel of channels) {
|
|
3622
|
+
descriptors[channel] = {
|
|
3623
|
+
enumerable: true,
|
|
3624
|
+
/**
|
|
3625
|
+
* In the TypeScript standard library definitions, the built-in interface for a property descriptor
|
|
3626
|
+
* does not include a specialized type for the “this” context in the getter or setter functions.
|
|
3627
|
+
* As a result, both the get and set methods implicitly have this: any.
|
|
3628
|
+
* The reason is that property descriptors in JavaScript are used across various objects with
|
|
3629
|
+
* no enforced shape for this. And so the standard library definitions have to remain as broad as possible
|
|
3630
|
+
* to support any valid JavaScript usage (e.g `Object.defineProperty`).
|
|
3631
|
+
*
|
|
3632
|
+
* So we can safely tells that this getter is typed as `this: UserNotificationSettings` because we're
|
|
3633
|
+
* creating a well known shaped object → `UserNotificationSettings`.
|
|
3634
|
+
*/
|
|
3635
|
+
get() {
|
|
3636
|
+
const value = this[kPlain][channel];
|
|
3637
|
+
if (typeof value === "undefined") {
|
|
3638
|
+
error2(
|
|
3639
|
+
`In order to use the '${channel}' channel, please set up your project first. For more information: https://liveblocks.io/docs/errors/enable-a-notification-channel`
|
|
3640
|
+
);
|
|
3641
|
+
return null;
|
|
3642
|
+
}
|
|
3643
|
+
return value;
|
|
3644
|
+
}
|
|
3645
|
+
};
|
|
3646
|
+
}
|
|
3647
|
+
return create(null, descriptors);
|
|
3648
|
+
}
|
|
3649
|
+
function patchUserNotificationSettings(existing, patch) {
|
|
3650
|
+
const outcoming = createUserNotificationSettings({
|
|
3651
|
+
...existing[kPlain]
|
|
3652
|
+
});
|
|
3653
|
+
for (const channel of keys(patch)) {
|
|
3654
|
+
const updates = patch[channel];
|
|
3655
|
+
if (updates !== void 0) {
|
|
3656
|
+
const kindUpdates = Object.fromEntries(
|
|
3657
|
+
entries(updates).filter(([, value]) => value !== void 0)
|
|
3658
|
+
);
|
|
3659
|
+
outcoming[kPlain][channel] = {
|
|
3660
|
+
...outcoming[kPlain][channel],
|
|
3661
|
+
...kindUpdates
|
|
3662
|
+
};
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
return outcoming;
|
|
3666
|
+
}
|
|
3667
|
+
function isNotificationChannelEnabled(settings) {
|
|
3668
|
+
return settings !== null ? values(settings).every((enabled) => enabled === true) : false;
|
|
3669
|
+
}
|
|
3670
|
+
|
|
3600
3671
|
// src/lib/position.ts
|
|
3601
3672
|
var MIN_CODE = 32;
|
|
3602
3673
|
var MAX_CODE = 126;
|
|
@@ -8189,6 +8260,16 @@ function createClient(options) {
|
|
|
8189
8260
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
8190
8261
|
win?.addEventListener("beforeunload", maybePreventClose);
|
|
8191
8262
|
}
|
|
8263
|
+
async function getNotificationSettings(options2) {
|
|
8264
|
+
const plainSettings = await httpClient.getUserNotificationSettings(options2);
|
|
8265
|
+
const settings = createUserNotificationSettings(plainSettings);
|
|
8266
|
+
return settings;
|
|
8267
|
+
}
|
|
8268
|
+
async function updateNotificationSettings(settings) {
|
|
8269
|
+
const plainSettings = await httpClient.updateUserNotificationSettings(settings);
|
|
8270
|
+
const settingsObject = createUserNotificationSettings(plainSettings);
|
|
8271
|
+
return settingsObject;
|
|
8272
|
+
}
|
|
8192
8273
|
const client = Object.defineProperty(
|
|
8193
8274
|
{
|
|
8194
8275
|
enterRoom,
|
|
@@ -8202,9 +8283,9 @@ function createClient(options) {
|
|
|
8202
8283
|
markInboxNotificationAsRead: httpClient.markInboxNotificationAsRead,
|
|
8203
8284
|
deleteAllInboxNotifications: httpClient.deleteAllInboxNotifications,
|
|
8204
8285
|
deleteInboxNotification: httpClient.deleteInboxNotification,
|
|
8205
|
-
// Public
|
|
8206
|
-
getNotificationSettings
|
|
8207
|
-
updateNotificationSettings
|
|
8286
|
+
// Public user notification settings API
|
|
8287
|
+
getNotificationSettings,
|
|
8288
|
+
updateNotificationSettings,
|
|
8208
8289
|
// Advanced resolvers APIs
|
|
8209
8290
|
resolvers: {
|
|
8210
8291
|
invalidateUsers: invalidateResolvedUsers,
|
|
@@ -9194,11 +9275,6 @@ var SortedList = class _SortedList {
|
|
|
9194
9275
|
}
|
|
9195
9276
|
};
|
|
9196
9277
|
|
|
9197
|
-
// src/protocol/UserNotificationSettings.ts
|
|
9198
|
-
function isNotificationChannelEnabled(settings) {
|
|
9199
|
-
return values(settings).every((enabled) => enabled === true);
|
|
9200
|
-
}
|
|
9201
|
-
|
|
9202
9278
|
// src/types/Others.ts
|
|
9203
9279
|
var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
|
|
9204
9280
|
TextEditorType2["Lexical"] = "lexical";
|
|
@@ -9251,6 +9327,7 @@ export {
|
|
|
9251
9327
|
createCommentId,
|
|
9252
9328
|
createInboxNotificationId,
|
|
9253
9329
|
createThreadId,
|
|
9330
|
+
createUserNotificationSettings,
|
|
9254
9331
|
deprecate,
|
|
9255
9332
|
deprecateIf,
|
|
9256
9333
|
detectDupes,
|
|
@@ -9286,6 +9363,7 @@ export {
|
|
|
9286
9363
|
nn,
|
|
9287
9364
|
objectToQuery,
|
|
9288
9365
|
patchLiveObjectKey,
|
|
9366
|
+
patchUserNotificationSettings,
|
|
9289
9367
|
raise,
|
|
9290
9368
|
resolveUsersInCommentBody,
|
|
9291
9369
|
shallow,
|