@flusys/nestjs-event-manager 7.0.0-beta.1 → 7.0.1
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/config/event-actions.js +4 -0
- package/cjs/services/event.service.js +1 -4
- package/cjs/services/event.service.spec.js +9 -7
- package/config/event-actions.d.ts +1 -0
- package/fesm/config/event-actions.js +1 -0
- package/fesm/services/event.service.js +2 -5
- package/fesm/services/event.service.spec.js +9 -7
- package/interfaces/event-manager-module.interface.d.ts +2 -2
- package/package.json +3 -3
- package/services/event.service.d.ts +1 -2
|
@@ -17,6 +17,9 @@ _export(exports, {
|
|
|
17
17
|
},
|
|
18
18
|
get EVENT_MANAGER_EVENT_ENTITIES () {
|
|
19
19
|
return EVENT_MANAGER_EVENT_ENTITIES;
|
|
20
|
+
},
|
|
21
|
+
get EVENT_MANAGER_EVENT_MODULE () {
|
|
22
|
+
return EVENT_MANAGER_EVENT_MODULE;
|
|
20
23
|
}
|
|
21
24
|
});
|
|
22
25
|
const EVENT_MANAGER_EVENT_ACTIONS = {
|
|
@@ -25,3 +28,4 @@ const EVENT_MANAGER_EVENT_ACTIONS = {
|
|
|
25
28
|
const EVENT_MANAGER_EVENT_ENTITIES = {
|
|
26
29
|
EVENT: 'event'
|
|
27
30
|
};
|
|
31
|
+
const EVENT_MANAGER_EVENT_MODULE = 'event-manager';
|
|
@@ -48,9 +48,6 @@ function _ts_param(paramIndex, decorator) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
let EventService = class EventService extends _classes.ApiService {
|
|
51
|
-
resolveEntity() {
|
|
52
|
-
return this.eventConfig.isCompanyFeatureEnabled() ? _entities.EventWithCompany : _entities.Event;
|
|
53
|
-
}
|
|
54
51
|
// Override methods
|
|
55
52
|
async convertSingleDtoToEntity(dto, user) {
|
|
56
53
|
await this.ensureDataSourceRepository();
|
|
@@ -451,7 +448,7 @@ let EventService = class EventService extends _classes.ApiService {
|
|
|
451
448
|
};
|
|
452
449
|
}
|
|
453
450
|
constructor(cacheManager, utilsService, eventConfig, dataSourceProvider){
|
|
454
|
-
super(
|
|
451
|
+
super(_config.EVENT_MANAGER_EVENT_ENTITIES.EVENT, cacheManager, utilsService, EventService.name, true, _config.EVENT_MANAGER_EVENT_MODULE, dataSourceProvider, eventConfig.isCompanyFeatureEnabled() ? _entities.EventWithCompany : _entities.Event), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "eventConfig", void 0), _define_property(this, "dataSourceProvider", void 0), _define_property(this, "participantRepository", void 0), _define_property(this, "pendingParticipantsList", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.eventConfig = eventConfig, this.dataSourceProvider = dataSourceProvider, this.participantRepository = null, this.pendingParticipantsList = [];
|
|
455
452
|
}
|
|
456
453
|
};
|
|
457
454
|
_ts_decorate([
|
|
@@ -84,14 +84,16 @@ describe('EventService', ()=>{
|
|
|
84
84
|
};
|
|
85
85
|
service = new _eventservice.EventService({}, mockUtilsService, mockConfigService, mockDataSourceProvider);
|
|
86
86
|
});
|
|
87
|
-
describe('
|
|
88
|
-
|
|
89
|
-
mockConfigService.isCompanyFeatureEnabled.mockReturnValue(
|
|
90
|
-
|
|
87
|
+
describe('entity selection', ()=>{
|
|
88
|
+
function buildWithCompanyFeature(enabled) {
|
|
89
|
+
mockConfigService.isCompanyFeatureEnabled.mockReturnValue(enabled);
|
|
90
|
+
return new _eventservice.EventService({}, mockUtilsService, mockConfigService, mockDataSourceProvider);
|
|
91
|
+
}
|
|
92
|
+
it('uses the company-scoped entity when the company feature is enabled', ()=>{
|
|
93
|
+
expect(buildWithCompanyFeature(true)['_entity']).toBe(_entities.EventWithCompany);
|
|
91
94
|
});
|
|
92
|
-
it('
|
|
93
|
-
|
|
94
|
-
expect(service.resolveEntity()).toBe(_entities.Event);
|
|
95
|
+
it('uses the core entity when the company feature is disabled', ()=>{
|
|
96
|
+
expect(buildWithCompanyFeature(false)['_entity']).toBe(_entities.Event);
|
|
95
97
|
});
|
|
96
98
|
});
|
|
97
99
|
describe('convertSingleDtoToEntity', ()=>{
|
|
@@ -32,15 +32,12 @@ import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
|
32
32
|
import { applyCompanyFilter } from '@flusys/nestjs-shared/utils';
|
|
33
33
|
import { Inject, Injectable, NotFoundException, Scope } from '@nestjs/common';
|
|
34
34
|
import { In, IsNull } from 'typeorm';
|
|
35
|
-
import { EVENT_MANAGER_EVENT_ACTIONS, EVENT_MESSAGES, EVENT_PARTICIPANT_MESSAGES } from '../config';
|
|
35
|
+
import { EVENT_MANAGER_EVENT_ACTIONS, EVENT_MANAGER_EVENT_ENTITIES, EVENT_MANAGER_EVENT_MODULE, EVENT_MESSAGES, EVENT_PARTICIPANT_MESSAGES } from '../config';
|
|
36
36
|
import { UpdateParticipantStatusDto } from '../dtos';
|
|
37
37
|
import { Event, EventParticipant, EventWithCompany } from '../entities';
|
|
38
38
|
import { EventManagerConfigService } from './event-manager-config.service';
|
|
39
39
|
import { EventManagerDataSourceProvider } from './event-manager-datasource.provider';
|
|
40
40
|
export class EventService extends ApiService {
|
|
41
|
-
resolveEntity() {
|
|
42
|
-
return this.eventConfig.isCompanyFeatureEnabled() ? EventWithCompany : Event;
|
|
43
|
-
}
|
|
44
41
|
// Override methods
|
|
45
42
|
async convertSingleDtoToEntity(dto, user) {
|
|
46
43
|
await this.ensureDataSourceRepository();
|
|
@@ -441,7 +438,7 @@ export class EventService extends ApiService {
|
|
|
441
438
|
};
|
|
442
439
|
}
|
|
443
440
|
constructor(cacheManager, utilsService, eventConfig, dataSourceProvider){
|
|
444
|
-
super(
|
|
441
|
+
super(EVENT_MANAGER_EVENT_ENTITIES.EVENT, cacheManager, utilsService, EventService.name, true, EVENT_MANAGER_EVENT_MODULE, dataSourceProvider, eventConfig.isCompanyFeatureEnabled() ? EventWithCompany : Event), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "eventConfig", void 0), _define_property(this, "dataSourceProvider", void 0), _define_property(this, "participantRepository", void 0), _define_property(this, "pendingParticipantsList", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.eventConfig = eventConfig, this.dataSourceProvider = dataSourceProvider, this.participantRepository = null, this.pendingParticipantsList = [];
|
|
445
442
|
}
|
|
446
443
|
}
|
|
447
444
|
_ts_decorate([
|
|
@@ -80,14 +80,16 @@ describe('EventService', ()=>{
|
|
|
80
80
|
};
|
|
81
81
|
service = new EventService({}, mockUtilsService, mockConfigService, mockDataSourceProvider);
|
|
82
82
|
});
|
|
83
|
-
describe('
|
|
84
|
-
|
|
85
|
-
mockConfigService.isCompanyFeatureEnabled.mockReturnValue(
|
|
86
|
-
|
|
83
|
+
describe('entity selection', ()=>{
|
|
84
|
+
function buildWithCompanyFeature(enabled) {
|
|
85
|
+
mockConfigService.isCompanyFeatureEnabled.mockReturnValue(enabled);
|
|
86
|
+
return new EventService({}, mockUtilsService, mockConfigService, mockDataSourceProvider);
|
|
87
|
+
}
|
|
88
|
+
it('uses the company-scoped entity when the company feature is enabled', ()=>{
|
|
89
|
+
expect(buildWithCompanyFeature(true)['_entity']).toBe(EventWithCompany);
|
|
87
90
|
});
|
|
88
|
-
it('
|
|
89
|
-
|
|
90
|
-
expect(service.resolveEntity()).toBe(Event);
|
|
91
|
+
it('uses the core entity when the company feature is disabled', ()=>{
|
|
92
|
+
expect(buildWithCompanyFeature(false)['_entity']).toBe(Event);
|
|
91
93
|
});
|
|
92
94
|
});
|
|
93
95
|
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 IEventManagerModuleConfig extends IDataSourceServiceOptions {
|
|
@@ -10,7 +10,7 @@ export interface EventManagerModuleOptions extends IDynamicModuleConfig {
|
|
|
10
10
|
bootstrapAppConfig?: IBootstrapAppConfig;
|
|
11
11
|
config?: IEventManagerModuleConfig;
|
|
12
12
|
}
|
|
13
|
-
export interface EventManagerOptionsFactory
|
|
13
|
+
export interface EventManagerOptionsFactory {
|
|
14
14
|
createEventManagerOptions(): Promise<IEventManagerModuleConfig> | IEventManagerModuleConfig;
|
|
15
15
|
}
|
|
16
16
|
export interface EventManagerModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'>, IDynamicModuleConfig {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-event-manager",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Event manager module with calendar support and recurrence",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "fesm/index.js",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"express": "^5.0.0"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@flusys/nestjs-core": "7.0.
|
|
88
|
-
"@flusys/nestjs-shared": "7.0.
|
|
87
|
+
"@flusys/nestjs-core": "7.0.1",
|
|
88
|
+
"@flusys/nestjs-shared": "7.0.1"
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -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 { CalendarQueryDto, CreateEventDto, UpdateEventDto, UpdateParticipantStatusDto } from '../dtos';
|
|
6
6
|
import { EventBase, EventParticipant } from '../entities';
|
|
7
7
|
import { ICalendarEvent, IEvent } from '../interfaces';
|
|
@@ -15,7 +15,6 @@ export declare class EventService extends ApiService<CreateEventDto, UpdateEvent
|
|
|
15
15
|
private participantRepository;
|
|
16
16
|
private pendingParticipantsList;
|
|
17
17
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, eventConfig: EventManagerConfigService, dataSourceProvider: EventManagerDataSourceProvider);
|
|
18
|
-
protected resolveEntity(): EntityTarget<EventBase>;
|
|
19
18
|
convertSingleDtoToEntity(dto: CreateEventDto | UpdateEventDto, user: ILoggedUserInfo | null): Promise<EventBase>;
|
|
20
19
|
protected getFilterQuery(query: SelectQueryBuilder<EventBase>, filter: Record<string, unknown>, _user: ILoggedUserInfo | null): Promise<{
|
|
21
20
|
query: SelectQueryBuilder<EventBase>;
|