@novu/client
Advanced tools
Comparing version 0.24.2 to 2.0.0-canary.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
46372
25
847
3
+ Added@novu/shared@2.0.0-canary.0(transitive)
- Removed@novu/shared@0.24.2(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaxios@1.7.7(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedform-data@4.0.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedproxy-from-env@1.1.0(transitive)
Updated@novu/shared@2.0.0-canary.0