Socket
Socket
Sign inDemoInstall

@novu/headless

Package Overview
Dependencies
29
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.19.0 to 0.20.0-alpha.1

29

dist/lib/headless.service.d.ts

@@ -1,5 +0,5 @@

import { IUserPreferenceSettings, IStoreQuery } from '@novu/client';
import { IUserPreferenceSettings, IStoreQuery, IUserGlobalPreferenceSettings } from '@novu/client';
import { IOrganizationEntity, IMessage, IPaginatedResponse } from '@novu/shared';
import type { ISession } from '../utils/types';
import { FetchResult, IFeedId, IHeadlessServiceOptions, IMessageId, IUpdateActionVariables, IUpdateUserPreferencesVariables, UpdateResult } from './types';
import { FetchResult, IFeedId, IHeadlessServiceOptions, IMessageId, IUpdateActionVariables, IUpdateUserPreferencesVariables, IUpdateUserGlobalPreferencesVariables, UpdateResult } from './types';
export declare const NOTIFICATION_CENTER_TOKEN_KEY = "nc_token";

@@ -18,2 +18,3 @@ export declare class HeadlessService {

private userPreferencesQueryOptions;
private userGlobalPreferencesQueryOptions;
constructor(options: IHeadlessServiceOptions);

@@ -76,2 +77,7 @@ private assertSessionInitialized;

}): () => void;
fetchUserGlobalPreferences({ listener, onSuccess, onError, }: {
listener: (result: FetchResult<IUserGlobalPreferenceSettings[]>) => void;
onSuccess?: (settings: IUserGlobalPreferenceSettings[]) => void;
onError?: (error: unknown) => void;
}): () => void;
updateUserPreferences({ templateId, channelType, checked, listener, onSuccess, onError, }: {

@@ -85,2 +91,9 @@ templateId: IUpdateUserPreferencesVariables['templateId'];

}): Promise<void>;
updateUserGlobalPreferences({ preferences, enabled, listener, onSuccess, onError, }: {
preferences: IUpdateUserGlobalPreferencesVariables['preferences'];
enabled?: IUpdateUserGlobalPreferencesVariables['enabled'];
listener: (result: UpdateResult<IUserGlobalPreferenceSettings, unknown, IUpdateUserGlobalPreferencesVariables>) => void;
onSuccess?: (settings: IUserGlobalPreferenceSettings) => void;
onError?: (error: unknown) => void;
}): Promise<void>;
markNotificationsAsRead({ messageId, listener, onSuccess, onError, }: {

@@ -102,2 +115,14 @@ messageId: IMessageId;

}): Promise<void>;
markNotificationsAs({ messageId, mark, listener, onSuccess, onError, }: {
messageId: IMessageId;
mark: {
seen?: boolean;
read?: boolean;
};
listener: (result: UpdateResult<IMessage[], unknown, {
messageId: IMessageId;
}>) => void;
onSuccess?: (message: IMessage[]) => void;
onError?: (error: unknown) => void;
}): Promise<void>;
removeNotification({ messageId, listener, onSuccess, onError, }: {

@@ -104,0 +129,0 @@ messageId: string;

@@ -62,2 +62,6 @@ "use strict";

};
this.userGlobalPreferencesQueryOptions = {
queryKey: utils_1.USER_GLOBAL_PREFERENCES_QUERY_KEY,
queryFn: () => this.api.getUserGlobalPreference(),
};
this.callFetchListener = (result, listener) => listener({

@@ -258,2 +262,11 @@ data: result.data,

}
fetchUserGlobalPreferences({ listener, onSuccess, onError, }) {
this.assertSessionInitialized();
const { unsubscribe } = this.queryService.subscribeQuery({
options: Object.assign(Object.assign({}, this.userGlobalPreferencesQueryOptions), { onSuccess,
onError }),
listener: (result) => this.callFetchListener(result, listener),
});
return unsubscribe;
}
updateUserPreferences({ templateId, channelType, checked, listener, onSuccess, onError, }) {

@@ -290,2 +303,28 @@ return __awaiter(this, void 0, void 0, function* () {

}
updateUserGlobalPreferences({ preferences, enabled, listener, onSuccess, onError, }) {
return __awaiter(this, void 0, void 0, function* () {
this.assertSessionInitialized();
const { result, unsubscribe } = this.queryService.subscribeMutation({
options: {
mutationFn: (variables) => this.api.updateSubscriberGlobalPreference(variables.preferences, variables.enabled),
onSuccess: (data) => {
this.queryClient.setQueryData(utils_1.USER_GLOBAL_PREFERENCES_QUERY_KEY, () => [data]);
},
},
listener: (res) => this.callUpdateListener(res, listener),
});
result
.mutate({ preferences, enabled })
.then((data) => {
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
return data;
})
.catch((error) => {
onError === null || onError === void 0 ? void 0 : onError(error);
})
.finally(() => {
unsubscribe();
});
});
}
markNotificationsAsRead({ messageId, listener, onSuccess, onError, }) {

@@ -352,2 +391,30 @@ return __awaiter(this, void 0, void 0, function* () {

}
markNotificationsAs({ messageId, mark, listener, onSuccess, onError, }) {
return __awaiter(this, void 0, void 0, function* () {
this.assertSessionInitialized();
const { result, unsubscribe } = this.queryService.subscribeMutation({
options: {
mutationFn: (variables) => this.api.markMessageAs(variables.messageId, mark),
onSuccess: (data) => {
this.queryClient.refetchQueries(utils_1.NOTIFICATIONS_QUERY_KEY, {
exact: false,
});
},
},
listener: (res) => this.callUpdateListener(res, listener),
});
result
.mutate({ messageId })
.then((data) => {
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
return data;
})
.catch((error) => {
onError === null || onError === void 0 ? void 0 : onError(error);
})
.finally(() => {
unsubscribe();
});
});
}
removeNotification({ messageId, listener, onSuccess, onError, }) {

@@ -354,0 +421,0 @@ return __awaiter(this, void 0, void 0, function* () {

import { QueryObserverResult, MutationObserverResult } from '@tanstack/query-core';
import { ButtonTypeEnum, MessageActionStatusEnum } from '@novu/shared';
import { ButtonTypeEnum, ChannelTypeEnum, MessageActionStatusEnum } from '@novu/shared';
export interface IHeadlessServiceOptions {

@@ -19,2 +19,9 @@ backendUrl?: string;

}
export interface IUpdateUserGlobalPreferencesVariables {
preferences?: {
channelType: ChannelTypeEnum;
enabled: boolean;
}[];
enabled?: boolean;
}
export interface IUpdateActionVariables {

@@ -21,0 +28,0 @@ messageId: string;

@@ -5,4 +5,5 @@ export declare const SESSION_QUERY_KEY: string[];

export declare const USER_PREFERENCES_QUERY_KEY: string[];
export declare const USER_GLOBAL_PREFERENCES_QUERY_KEY: string[];
export declare const UNSEEN_COUNT_QUERY_KEY: string[];
export declare const UNREAD_COUNT_QUERY_KEY: string[];
//# sourceMappingURL=query-keys.d.ts.map

3

dist/utils/query-keys.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UNREAD_COUNT_QUERY_KEY = exports.UNSEEN_COUNT_QUERY_KEY = exports.USER_PREFERENCES_QUERY_KEY = exports.NOTIFICATIONS_QUERY_KEY = exports.ORGANIZATION_QUERY_KEY = exports.SESSION_QUERY_KEY = void 0;
exports.UNREAD_COUNT_QUERY_KEY = exports.UNSEEN_COUNT_QUERY_KEY = exports.USER_GLOBAL_PREFERENCES_QUERY_KEY = exports.USER_PREFERENCES_QUERY_KEY = exports.NOTIFICATIONS_QUERY_KEY = exports.ORGANIZATION_QUERY_KEY = exports.SESSION_QUERY_KEY = void 0;
exports.SESSION_QUERY_KEY = ['session'];

@@ -8,3 +8,4 @@ exports.ORGANIZATION_QUERY_KEY = ['organization'];

exports.USER_PREFERENCES_QUERY_KEY = ['user_preferences'];
exports.USER_GLOBAL_PREFERENCES_QUERY_KEY = ['user_global_preferences'];
exports.UNSEEN_COUNT_QUERY_KEY = ['unseen_count'];
exports.UNREAD_COUNT_QUERY_KEY = ['unread_count'];
{
"name": "@novu/headless",
"version": "0.19.0",
"version": "0.20.0-alpha.1",
"repository": "https://github.com/novuhq/novu",

@@ -31,4 +31,4 @@ "description": "Headless client package that is a thin abstraction layer over the API client + state and socket management",

"dependencies": {
"@novu/client": "^0.19.0",
"@novu/shared": "^0.19.0",
"@novu/client": "^0.20.0-alpha.1",
"@novu/shared": "^0.20.0-alpha.1",
"@tanstack/query-core": "^4.15.1",

@@ -51,3 +51,3 @@ "socket.io-client": "4.7.2"

},
"gitHead": "4b3f023925fdd91447cea65776c16a87aab3cb4a"
"gitHead": "11387a3d477dd770d2a6af316b8de8aaa546b58b"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc