Socket
Socket
Sign inDemoInstall

@novu/client

Package Overview
Dependencies
Maintainers
0
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@novu/client - npm Package Compare versions

Comparing version 0.24.2 to 2.0.0-canary.0

dist/cjs/http-client/http-client.d.ts

34

dist/cjs/api/api.service.d.ts

@@ -1,11 +0,12 @@

import { IMessage, ButtonTypeEnum, MessageActionStatusEnum, IPaginatedResponse } from '@novu/shared';
import { ITabCountQuery, IStoreQuery, IUserPreferenceSettings, IUnseenCountQuery, IUnreadCountQuery, IUserGlobalPreferenceSettings } from '../index';
import type { ButtonTypeEnum, MessageActionStatusEnum, IPaginatedResponse, ISessionDto, INotificationDto, MessagesStatusEnum, PreferenceLevelEnum } from '@novu/shared';
import { ITabCountQuery, IStoreQuery, IUserPreferenceSettings, IUnseenCountQuery, IUnreadCountQuery, IUserGlobalPreferenceSettings, ApiOptions } from '../index';
export declare class ApiService {
private backendUrl;
private httpClient;
isAuthenticated: boolean;
constructor(backendUrl: string);
constructor(backendUrl: string, apiVersion?: ApiOptions['apiVersion']);
constructor(options?: ApiOptions);
private removeNullUndefined;
setAuthorizationToken(token: string): void;
disposeAuthorizationToken(): void;
updateAction(messageId: string, executedType: ButtonTypeEnum, status: MessageActionStatusEnum, payload?: Record<string, unknown>): Promise<any>;
updateAction(messageId: string, executedType: `${ButtonTypeEnum}`, status: `${MessageActionStatusEnum}`, payload?: Record<string, unknown>): Promise<INotificationDto>;
markMessageAs(messageId: string | string[], mark: {

@@ -15,14 +16,22 @@ seen?: boolean;

}): Promise<any>;
markMessagesAs({ messageId, markAs, }: {
messageId: string | string[];
markAs: `${MessagesStatusEnum}`;
}): Promise<INotificationDto[]>;
removeMessage(messageId: string): Promise<any>;
removeMessages(messageIds: string[]): Promise<any>;
removeAllMessages(feedId?: string): Promise<any>;
markAllMessagesAsRead(feedId?: string | string[]): Promise<any>;
markAllMessagesAsSeen(feedId?: string | string[]): Promise<any>;
getNotificationsList(page: number, { payload, ...rest }?: IStoreQuery): Promise<IPaginatedResponse<IMessage>>;
initializeSession(appId: string, subscriberId: string, hmacHash?: any): Promise<any>;
markAllMessagesAsRead(feedId?: string | string[]): Promise<number>;
markAllMessagesAsSeen(feedId?: string | string[]): Promise<number>;
getNotificationsList(page: number, { payload, ...rest }?: IStoreQuery): Promise<IPaginatedResponse<INotificationDto>>;
initializeSession(appId: string, subscriberId: string, hmacHash?: any): Promise<ISessionDto>;
postUsageLog(name: string, payload: {
[key: string]: string | boolean | undefined;
}): Promise<any>;
getUnseenCount(query?: IUnseenCountQuery): Promise<any>;
getUnreadCount(query?: IUnreadCountQuery): Promise<any>;
getUnseenCount(query?: IUnseenCountQuery): Promise<{
count: number;
}>;
getUnreadCount(query?: IUnreadCountQuery): Promise<{
count: number;
}>;
getTabCount(query?: ITabCountQuery): Promise<any>;

@@ -32,2 +41,5 @@ getOrganization(): Promise<any>;

getUserGlobalPreference(): Promise<IUserGlobalPreferenceSettings[]>;
getPreferences({ level, }: {
level?: `${PreferenceLevelEnum}`;
}): Promise<Array<IUserPreferenceSettings | IUserGlobalPreferenceSettings>>;
updateSubscriberPreference(templateId: string, channelType: string, enabled: boolean): Promise<IUserPreferenceSettings>;

@@ -34,0 +46,0 @@ updateSubscriberGlobalPreference(preferences: {

@@ -24,9 +24,29 @@ "use strict";

exports.ApiService = void 0;
const shared_1 = require("@novu/shared");
const http_client_1 = require("../http-client");
class ApiService {
constructor(backendUrl) {
this.backendUrl = backendUrl;
constructor(...args) {
this.isAuthenticated = false;
this.httpClient = new shared_1.HttpClient(backendUrl);
if (arguments.length === 2) {
this.httpClient = new http_client_1.HttpClient({
backendUrl: args[0],
apiVersion: args[1],
});
}
else if (arguments.length === 1) {
if (typeof args[0] === 'object') {
this.httpClient = new http_client_1.HttpClient(args[0]);
}
else if (typeof args[0] === 'string') {
this.httpClient = new http_client_1.HttpClient({
backendUrl: args[0],
});
}
}
else {
this.httpClient = new http_client_1.HttpClient();
}
}
removeNullUndefined(obj) {
return Object.fromEntries(Object.entries(obj).filter(([_, value]) => value != null));
}
setAuthorizationToken(token) {

@@ -60,2 +80,10 @@ this.httpClient.setAuthorizationToken(token);

}
markMessagesAs({ messageId, markAs, }) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.httpClient.post(`/widgets/messages/mark-as`, {
messageId,
markAs,
});
});
}
removeMessage(messageId) {

@@ -99,3 +127,3 @@ return __awaiter(this, void 0, void 0, function* () {

const payloadString = payload ? btoa(JSON.stringify(payload)) : undefined;
return yield this.httpClient.getFullResponse(`/widgets/notifications/feed`, Object.assign({ page, payload: payloadString }, rest));
return yield this.httpClient.getFullResponse(`/widgets/notifications/feed`, Object.assign(Object.assign({ page }, (payloadString && { payload: payloadString })), rest));
});

@@ -122,3 +150,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.httpClient.get('/widgets/notifications/unseen', query);
return yield this.httpClient.get('/widgets/notifications/unseen', this.removeNullUndefined(query));
});

@@ -128,3 +156,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.httpClient.get('/widgets/notifications/unread', query);
return yield this.httpClient.get('/widgets/notifications/unread', this.removeNullUndefined(query));
});

@@ -152,2 +180,7 @@ }

}
getPreferences({ level, }) {
return __awaiter(this, void 0, void 0, function* () {
return this.httpClient.get(`/widgets/preferences/${level}`);
});
}
updateSubscriberPreference(templateId, channelType, enabled) {

@@ -154,0 +187,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -1,2 +0,2 @@

import { IPreferenceChannels, NotificationTemplateCustomData } from '@novu/shared';
import type { IPreferenceChannels, NotificationTemplateCustomData } from '@novu/shared';
export interface IUnseenCountQuery {

@@ -42,3 +42,9 @@ feedIdentifier?: string | string[];

};
export type ApiOptions = {
apiVersion?: string;
backendUrl?: string;
userAgent?: string;
};
export { ApiService } from './api/api.service';
export { HttpClient } from './http-client';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiService = void 0;
exports.HttpClient = exports.ApiService = void 0;
var api_service_1 = require("./api/api.service");
Object.defineProperty(exports, "ApiService", { enumerable: true, get: function () { return api_service_1.ApiService; } });
var http_client_1 = require("./http-client");
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return http_client_1.HttpClient; } });

@@ -1,11 +0,12 @@

import { IMessage, ButtonTypeEnum, MessageActionStatusEnum, IPaginatedResponse } from '@novu/shared';
import { ITabCountQuery, IStoreQuery, IUserPreferenceSettings, IUnseenCountQuery, IUnreadCountQuery, IUserGlobalPreferenceSettings } from '../index';
import type { ButtonTypeEnum, MessageActionStatusEnum, IPaginatedResponse, ISessionDto, INotificationDto, MessagesStatusEnum, PreferenceLevelEnum } from '@novu/shared';
import { ITabCountQuery, IStoreQuery, IUserPreferenceSettings, IUnseenCountQuery, IUnreadCountQuery, IUserGlobalPreferenceSettings, ApiOptions } from '../index';
export declare class ApiService {
private backendUrl;
private httpClient;
isAuthenticated: boolean;
constructor(backendUrl: string);
constructor(backendUrl: string, apiVersion?: ApiOptions['apiVersion']);
constructor(options?: ApiOptions);
private removeNullUndefined;
setAuthorizationToken(token: string): void;
disposeAuthorizationToken(): void;
updateAction(messageId: string, executedType: ButtonTypeEnum, status: MessageActionStatusEnum, payload?: Record<string, unknown>): Promise<any>;
updateAction(messageId: string, executedType: `${ButtonTypeEnum}`, status: `${MessageActionStatusEnum}`, payload?: Record<string, unknown>): Promise<INotificationDto>;
markMessageAs(messageId: string | string[], mark: {

@@ -15,14 +16,22 @@ seen?: boolean;

}): Promise<any>;
markMessagesAs({ messageId, markAs, }: {
messageId: string | string[];
markAs: `${MessagesStatusEnum}`;
}): Promise<INotificationDto[]>;
removeMessage(messageId: string): Promise<any>;
removeMessages(messageIds: string[]): Promise<any>;
removeAllMessages(feedId?: string): Promise<any>;
markAllMessagesAsRead(feedId?: string | string[]): Promise<any>;
markAllMessagesAsSeen(feedId?: string | string[]): Promise<any>;
getNotificationsList(page: number, { payload, ...rest }?: IStoreQuery): Promise<IPaginatedResponse<IMessage>>;
initializeSession(appId: string, subscriberId: string, hmacHash?: any): Promise<any>;
markAllMessagesAsRead(feedId?: string | string[]): Promise<number>;
markAllMessagesAsSeen(feedId?: string | string[]): Promise<number>;
getNotificationsList(page: number, { payload, ...rest }?: IStoreQuery): Promise<IPaginatedResponse<INotificationDto>>;
initializeSession(appId: string, subscriberId: string, hmacHash?: any): Promise<ISessionDto>;
postUsageLog(name: string, payload: {
[key: string]: string | boolean | undefined;
}): Promise<any>;
getUnseenCount(query?: IUnseenCountQuery): Promise<any>;
getUnreadCount(query?: IUnreadCountQuery): Promise<any>;
getUnseenCount(query?: IUnseenCountQuery): Promise<{
count: number;
}>;
getUnreadCount(query?: IUnreadCountQuery): Promise<{
count: number;
}>;
getTabCount(query?: ITabCountQuery): Promise<any>;

@@ -32,2 +41,5 @@ getOrganization(): Promise<any>;

getUserGlobalPreference(): Promise<IUserGlobalPreferenceSettings[]>;
getPreferences({ level, }: {
level?: `${PreferenceLevelEnum}`;
}): Promise<Array<IUserPreferenceSettings | IUserGlobalPreferenceSettings>>;
updateSubscriberPreference(templateId: string, channelType: string, enabled: boolean): Promise<IUserPreferenceSettings>;

@@ -34,0 +46,0 @@ updateSubscriberGlobalPreference(preferences: {

@@ -21,9 +21,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import { HttpClient, } from '@novu/shared';
import { HttpClient } from '../http-client';
export class ApiService {
constructor(backendUrl) {
this.backendUrl = backendUrl;
constructor(...args) {
this.isAuthenticated = false;
this.httpClient = new HttpClient(backendUrl);
if (arguments.length === 2) {
this.httpClient = new HttpClient({
backendUrl: args[0],
apiVersion: args[1],
});
}
else if (arguments.length === 1) {
if (typeof args[0] === 'object') {
this.httpClient = new HttpClient(args[0]);
}
else if (typeof args[0] === 'string') {
this.httpClient = new HttpClient({
backendUrl: args[0],
});
}
}
else {
this.httpClient = new HttpClient();
}
}
removeNullUndefined(obj) {
return Object.fromEntries(Object.entries(obj).filter(([_, value]) => value != null));
}
setAuthorizationToken(token) {

@@ -57,2 +77,10 @@ this.httpClient.setAuthorizationToken(token);

}
markMessagesAs({ messageId, markAs, }) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.httpClient.post(`/widgets/messages/mark-as`, {
messageId,
markAs,
});
});
}
removeMessage(messageId) {

@@ -96,3 +124,3 @@ return __awaiter(this, void 0, void 0, function* () {

const payloadString = payload ? btoa(JSON.stringify(payload)) : undefined;
return yield this.httpClient.getFullResponse(`/widgets/notifications/feed`, Object.assign({ page, payload: payloadString }, rest));
return yield this.httpClient.getFullResponse(`/widgets/notifications/feed`, Object.assign(Object.assign({ page }, (payloadString && { payload: payloadString })), rest));
});

@@ -119,3 +147,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.httpClient.get('/widgets/notifications/unseen', query);
return yield this.httpClient.get('/widgets/notifications/unseen', this.removeNullUndefined(query));
});

@@ -125,3 +153,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.httpClient.get('/widgets/notifications/unread', query);
return yield this.httpClient.get('/widgets/notifications/unread', this.removeNullUndefined(query));
});

@@ -149,2 +177,7 @@ }

}
getPreferences({ level, }) {
return __awaiter(this, void 0, void 0, function* () {
return this.httpClient.get(`/widgets/preferences/${level}`);
});
}
updateSubscriberPreference(templateId, channelType, enabled) {

@@ -151,0 +184,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -1,2 +0,2 @@

import { IPreferenceChannels, NotificationTemplateCustomData } from '@novu/shared';
import type { IPreferenceChannels, NotificationTemplateCustomData } from '@novu/shared';
export interface IUnseenCountQuery {

@@ -42,3 +42,9 @@ feedIdentifier?: string | string[];

};
export type ApiOptions = {
apiVersion?: string;
backendUrl?: string;
userAgent?: string;
};
export { ApiService } from './api/api.service';
export { HttpClient } from './http-client';
//# sourceMappingURL=index.d.ts.map
export { ApiService } from './api/api.service';
export { HttpClient } from './http-client';
{
"name": "@novu/client",
"version": "0.24.2",
"version": "2.0.0-canary.0",
"repository": "https://github.com/novuhq/novu",

@@ -47,3 +47,3 @@ "description": "API client to be used in end user environments",

"dependencies": {
"@novu/shared": "^0.24.2"
"@novu/shared": "2.0.0-canary.0"
},

@@ -63,4 +63,3 @@ "devDependencies": {

"singleQuote": true
},
"gitHead": "b2b1ce3b8df394d1e73787c22c548f3d354a22f8"
}
}

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc