@flusys/nestjs-notification 7.0.0 → 7.0.2
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/cjs/services/notification-helper.service.js +1 -1
- package/cjs/services/notification.service.js +1 -4
- package/cjs/services/notification.service.spec.js +10 -9
- package/fesm/services/notification-helper.service.js +1 -1
- package/fesm/services/notification.service.js +2 -5
- package/fesm/services/notification.service.spec.js +10 -9
- package/interfaces/notification-module.interface.d.ts +2 -2
- package/package.json +3 -3
- package/services/notification.service.d.ts +1 -2
|
@@ -139,7 +139,7 @@ let NotificationHelperService = class NotificationHelperService {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
async clearCache() {
|
|
142
|
-
await this.utilsService.clearCache(
|
|
142
|
+
await this.utilsService.clearCache(_config.NOTIFICATION_EVENT_ENTITIES.NOTIFICATION, this.cacheManager);
|
|
143
143
|
}
|
|
144
144
|
constructor(cacheManager, utilsService, configService, dataSourceProvider, gateway){
|
|
145
145
|
_define_property(this, "cacheManager", void 0);
|
|
@@ -47,9 +47,6 @@ function _ts_param(paramIndex, decorator) {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
let NotificationService = class NotificationService extends _classes.ApiService {
|
|
50
|
-
resolveEntity() {
|
|
51
|
-
return this.notificationConfig.isCompanyFeatureEnabled() ? _entities.NotificationWithCompany : _entities.Notification;
|
|
52
|
-
}
|
|
53
50
|
async convertSingleDtoToEntity(dto, user) {
|
|
54
51
|
let entity = {};
|
|
55
52
|
if ('id' in dto && dto.id) {
|
|
@@ -237,7 +234,7 @@ let NotificationService = class NotificationService extends _classes.ApiService
|
|
|
237
234
|
}
|
|
238
235
|
}
|
|
239
236
|
constructor(cacheManager, utilsService, notificationConfig, dataSourceProvider, gateway){
|
|
240
|
-
super(
|
|
237
|
+
super(_config.NOTIFICATION_EVENT_ENTITIES.NOTIFICATION, cacheManager, utilsService, NotificationService.name, false, _config.NOTIFICATION_EVENT_MODULE, dataSourceProvider, notificationConfig.isCompanyFeatureEnabled() ? _entities.NotificationWithCompany : _entities.Notification), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "notificationConfig", void 0), _define_property(this, "gateway", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.notificationConfig = notificationConfig, this.gateway = gateway;
|
|
241
238
|
}
|
|
242
239
|
};
|
|
243
240
|
_ts_decorate([
|
|
@@ -43,11 +43,11 @@ describe('NotificationService', ()=>{
|
|
|
43
43
|
let mockRepo;
|
|
44
44
|
let mockConfig;
|
|
45
45
|
let mockGateway;
|
|
46
|
-
async function buildService(withGateway = true) {
|
|
46
|
+
async function buildService(withGateway = true, companyFeatureEnabled = false) {
|
|
47
47
|
mockRepo = (0, _repositorymock.createMockRepository)();
|
|
48
48
|
const mockDataSourceProvider = (0, _repositorymock.createMockDataSourceProvider)(mockRepo);
|
|
49
49
|
mockConfig = {
|
|
50
|
-
isCompanyFeatureEnabled: jest.fn().mockReturnValue(
|
|
50
|
+
isCompanyFeatureEnabled: jest.fn().mockReturnValue(companyFeatureEnabled)
|
|
51
51
|
};
|
|
52
52
|
mockGateway = {
|
|
53
53
|
emitToUser: jest.fn(),
|
|
@@ -90,13 +90,14 @@ describe('NotificationService', ()=>{
|
|
|
90
90
|
beforeEach(async ()=>{
|
|
91
91
|
service = await buildService();
|
|
92
92
|
});
|
|
93
|
-
describe('
|
|
94
|
-
it('
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
describe('entity selection', ()=>{
|
|
94
|
+
it('uses Notification when the company feature is disabled', async ()=>{
|
|
95
|
+
const built = await buildService(true, false);
|
|
96
|
+
expect(built['_entity']).toBe(_entities.Notification);
|
|
97
|
+
});
|
|
98
|
+
it('uses NotificationWithCompany when the company feature is enabled', async ()=>{
|
|
99
|
+
const built = await buildService(true, true);
|
|
100
|
+
expect(built['_entity']).toBe(_entities.NotificationWithCompany);
|
|
100
101
|
});
|
|
101
102
|
});
|
|
102
103
|
describe('convertSingleDtoToEntity', ()=>{
|
|
@@ -129,7 +129,7 @@ export class NotificationHelperService {
|
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
async clearCache() {
|
|
132
|
-
await this.utilsService.clearCache(
|
|
132
|
+
await this.utilsService.clearCache(NOTIFICATION_EVENT_ENTITIES.NOTIFICATION, this.cacheManager);
|
|
133
133
|
}
|
|
134
134
|
constructor(cacheManager, utilsService, configService, dataSourceProvider, gateway){
|
|
135
135
|
_define_property(this, "cacheManager", void 0);
|
|
@@ -31,15 +31,12 @@ import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
|
31
31
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
32
32
|
import { applyCompanyFilter } from '@flusys/nestjs-shared/utils';
|
|
33
33
|
import { Inject, Injectable, NotFoundException, Optional, Scope } from '@nestjs/common';
|
|
34
|
-
import { NOTIFICATION_EVENT_ACTIONS, NOTIFICATION_MESSAGES } from '../config';
|
|
34
|
+
import { NOTIFICATION_EVENT_ACTIONS, NOTIFICATION_EVENT_ENTITIES, NOTIFICATION_EVENT_MODULE, NOTIFICATION_MESSAGES } from '../config';
|
|
35
35
|
import { Notification, NotificationWithCompany } from '../entities';
|
|
36
36
|
import { NotificationGateway } from '../gateways';
|
|
37
37
|
import { NotificationConfigService } from './notification-config.service';
|
|
38
38
|
import { NotificationDataSourceProvider } from './notification-datasource.provider';
|
|
39
39
|
export class NotificationService extends ApiService {
|
|
40
|
-
resolveEntity() {
|
|
41
|
-
return this.notificationConfig.isCompanyFeatureEnabled() ? NotificationWithCompany : Notification;
|
|
42
|
-
}
|
|
43
40
|
async convertSingleDtoToEntity(dto, user) {
|
|
44
41
|
let entity = {};
|
|
45
42
|
if ('id' in dto && dto.id) {
|
|
@@ -227,7 +224,7 @@ export class NotificationService extends ApiService {
|
|
|
227
224
|
}
|
|
228
225
|
}
|
|
229
226
|
constructor(cacheManager, utilsService, notificationConfig, dataSourceProvider, gateway){
|
|
230
|
-
super(
|
|
227
|
+
super(NOTIFICATION_EVENT_ENTITIES.NOTIFICATION, cacheManager, utilsService, NotificationService.name, false, NOTIFICATION_EVENT_MODULE, dataSourceProvider, notificationConfig.isCompanyFeatureEnabled() ? NotificationWithCompany : Notification), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "notificationConfig", void 0), _define_property(this, "gateway", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.notificationConfig = notificationConfig, this.gateway = gateway;
|
|
231
228
|
}
|
|
232
229
|
}
|
|
233
230
|
_ts_decorate([
|
|
@@ -39,11 +39,11 @@ describe('NotificationService', ()=>{
|
|
|
39
39
|
let mockRepo;
|
|
40
40
|
let mockConfig;
|
|
41
41
|
let mockGateway;
|
|
42
|
-
async function buildService(withGateway = true) {
|
|
42
|
+
async function buildService(withGateway = true, companyFeatureEnabled = false) {
|
|
43
43
|
mockRepo = createMockRepository();
|
|
44
44
|
const mockDataSourceProvider = createMockDataSourceProvider(mockRepo);
|
|
45
45
|
mockConfig = {
|
|
46
|
-
isCompanyFeatureEnabled: jest.fn().mockReturnValue(
|
|
46
|
+
isCompanyFeatureEnabled: jest.fn().mockReturnValue(companyFeatureEnabled)
|
|
47
47
|
};
|
|
48
48
|
mockGateway = {
|
|
49
49
|
emitToUser: jest.fn(),
|
|
@@ -86,13 +86,14 @@ describe('NotificationService', ()=>{
|
|
|
86
86
|
beforeEach(async ()=>{
|
|
87
87
|
service = await buildService();
|
|
88
88
|
});
|
|
89
|
-
describe('
|
|
90
|
-
it('
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
describe('entity selection', ()=>{
|
|
90
|
+
it('uses Notification when the company feature is disabled', async ()=>{
|
|
91
|
+
const built = await buildService(true, false);
|
|
92
|
+
expect(built['_entity']).toBe(Notification);
|
|
93
|
+
});
|
|
94
|
+
it('uses NotificationWithCompany when the company feature is enabled', async ()=>{
|
|
95
|
+
const built = await buildService(true, true);
|
|
96
|
+
expect(built['_entity']).toBe(NotificationWithCompany);
|
|
96
97
|
});
|
|
97
98
|
});
|
|
98
99
|
describe('convertSingleDtoToEntity', ()=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBootstrapAppConfig, IDataSourceServiceOptions, IDynamicModuleConfig
|
|
1
|
+
import { IBootstrapAppConfig, IDataSourceServiceOptions, IDynamicModuleConfig } from '@flusys/nestjs-core';
|
|
2
2
|
import { IModuleEventsConfig } from '@flusys/nestjs-shared/interfaces';
|
|
3
3
|
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
4
4
|
export interface INotificationModuleConfig extends IDataSourceServiceOptions {
|
|
@@ -9,7 +9,7 @@ export interface NotificationModuleOptions extends IDynamicModuleConfig {
|
|
|
9
9
|
bootstrapAppConfig?: IBootstrapAppConfig;
|
|
10
10
|
config?: INotificationModuleConfig;
|
|
11
11
|
}
|
|
12
|
-
export interface NotificationOptionsFactory
|
|
12
|
+
export interface NotificationOptionsFactory {
|
|
13
13
|
createNotificationOptions(): Promise<INotificationModuleConfig> | INotificationModuleConfig;
|
|
14
14
|
}
|
|
15
15
|
export interface NotificationModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'>, IDynamicModuleConfig {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-notification",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"description": "Notification module with real-time Socket.IO support",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "fesm/index.js",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"express": "^5.0.0"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@flusys/nestjs-core": "7.0.
|
|
97
|
-
"@flusys/nestjs-shared": "7.0.
|
|
96
|
+
"@flusys/nestjs-core": "7.0.2",
|
|
97
|
+
"@flusys/nestjs-shared": "7.0.2"
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiService, HybridCache } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
3
3
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
4
|
-
import {
|
|
4
|
+
import { QueryRunner, SelectQueryBuilder } from 'typeorm';
|
|
5
5
|
import { CreateNotificationDto, UpdateNotificationDto } from '../dtos';
|
|
6
6
|
import { NotificationBase } from '../entities';
|
|
7
7
|
import { NotificationGateway } from '../gateways';
|
|
@@ -14,7 +14,6 @@ export declare class NotificationService extends ApiService<CreateNotificationDt
|
|
|
14
14
|
private readonly notificationConfig;
|
|
15
15
|
private readonly gateway?;
|
|
16
16
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, notificationConfig: NotificationConfigService, dataSourceProvider: NotificationDataSourceProvider, gateway?: NotificationGateway | undefined);
|
|
17
|
-
protected resolveEntity(): EntityTarget<NotificationBase>;
|
|
18
17
|
convertSingleDtoToEntity(dto: CreateNotificationDto | UpdateNotificationDto, user: ILoggedUserInfo | null): Promise<NotificationBase>;
|
|
19
18
|
protected getSelectQuery(query: SelectQueryBuilder<NotificationBase>, _user: ILoggedUserInfo | null, select?: string[]): Promise<{
|
|
20
19
|
query: SelectQueryBuilder<NotificationBase>;
|