@flusys/nestjs-event-manager 3.0.1 → 4.0.0-lts

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  _export_star(require("./event-manager.constants"), exports);
6
+ _export_star(require("./message-keys"), exports);
6
7
  function _export_star(from, to) {
7
8
  Object.keys(from).forEach(function(k) {
8
9
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -0,0 +1,57 @@
1
+ // ==================== EVENT MANAGER MODULE MESSAGE KEYS ====================
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ function _export(target, all) {
7
+ for(var name in all)Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: Object.getOwnPropertyDescriptor(all, name).get
10
+ });
11
+ }
12
+ _export(exports, {
13
+ get EVENT_MANAGER_MODULE_MESSAGES () {
14
+ return EVENT_MANAGER_MODULE_MESSAGES;
15
+ },
16
+ get EVENT_MESSAGES () {
17
+ return EVENT_MESSAGES;
18
+ },
19
+ get EVENT_PARTICIPANT_MESSAGES () {
20
+ return EVENT_PARTICIPANT_MESSAGES;
21
+ }
22
+ });
23
+ const EVENT_MESSAGES = {
24
+ CREATE_SUCCESS: 'event.create.success',
25
+ CREATE_MANY_SUCCESS: 'event.create.many.success',
26
+ GET_SUCCESS: 'event.get.success',
27
+ GET_ALL_SUCCESS: 'event.get.all.success',
28
+ UPDATE_SUCCESS: 'event.update.success',
29
+ UPDATE_MANY_SUCCESS: 'event.update.many.success',
30
+ DELETE_SUCCESS: 'event.delete.success',
31
+ RESTORE_SUCCESS: 'event.restore.success',
32
+ NOT_FOUND: 'event.not.found',
33
+ PUBLISH_SUCCESS: 'event.publish.success',
34
+ UNPUBLISH_SUCCESS: 'event.unpublish.success',
35
+ CANCEL_SUCCESS: 'event.cancel.success',
36
+ UPCOMING_SUCCESS: 'event.upcoming.success',
37
+ MY_EVENTS_SUCCESS: 'event.my.events.success'
38
+ };
39
+ const EVENT_PARTICIPANT_MESSAGES = {
40
+ CREATE_SUCCESS: 'event.participant.create.success',
41
+ CREATE_MANY_SUCCESS: 'event.participant.create.many.success',
42
+ GET_SUCCESS: 'event.participant.get.success',
43
+ GET_ALL_SUCCESS: 'event.participant.get.all.success',
44
+ UPDATE_SUCCESS: 'event.participant.update.success',
45
+ UPDATE_MANY_SUCCESS: 'event.participant.update.many.success',
46
+ DELETE_SUCCESS: 'event.participant.delete.success',
47
+ RESTORE_SUCCESS: 'event.participant.restore.success',
48
+ NOT_FOUND: 'event.participant.not.found',
49
+ REGISTER_SUCCESS: 'event.participant.register.success',
50
+ UNREGISTER_SUCCESS: 'event.participant.unregister.success',
51
+ CHECKIN_SUCCESS: 'event.participant.checkin.success',
52
+ STATUS_UPDATE_SUCCESS: 'event.participant.status.update.success'
53
+ };
54
+ const EVENT_MANAGER_MODULE_MESSAGES = {
55
+ EVENT: EVENT_MESSAGES,
56
+ EVENT_PARTICIPANT: EVENT_PARTICIPANT_MESSAGES
57
+ };
@@ -10,7 +10,9 @@ Object.defineProperty(exports, "EventParticipantController", {
10
10
  });
11
11
  const _common = require("@nestjs/common");
12
12
  const _swagger = require("@nestjs/swagger");
13
+ const _classtransformer = require("class-transformer");
13
14
  const _classes = require("@flusys/nestjs-shared/classes");
15
+ const _config = require("../config");
14
16
  const _decorators = require("@flusys/nestjs-shared/decorators");
15
17
  const _dtos = require("@flusys/nestjs-shared/dtos");
16
18
  const _guards = require("@flusys/nestjs-shared/guards");
@@ -46,6 +48,7 @@ function _ts_param(paramIndex, decorator) {
46
48
  };
47
49
  }
48
50
  let EventParticipantController = class EventParticipantController extends (0, _classes.createApiController)(_dtos1.CreateEventParticipantDto, _dtos1.UpdateEventParticipantDto, _dtos1.EventParticipantResponseDto, {
51
+ entityName: 'eventParticipant',
49
52
  security: {
50
53
  insert: {
51
54
  level: 'permission',
@@ -96,29 +99,34 @@ let EventParticipantController = class EventParticipantController extends (0, _c
96
99
  return {
97
100
  success: true,
98
101
  message: 'Participant status updated successfully',
99
- data: participant
102
+ messageKey: _config.EVENT_PARTICIPANT_MESSAGES.STATUS_UPDATE_SUCCESS,
103
+ data: (0, _classtransformer.plainToInstance)(_dtos1.EventParticipantResponseDto, participant)
100
104
  };
101
105
  }
102
106
  async getByEvent(body, user) {
103
107
  const participants = await this.participantService.getParticipantsByEvent(body.eventId, user);
104
- return this.buildListResponse(participants, 'Participants retrieved successfully');
105
- }
106
- async getByUser(body, user) {
107
- const participants = await this.participantService.getParticipantsByUser(body.userId, user);
108
- return this.buildListResponse(participants, 'Participations retrieved successfully');
109
- }
110
- async removeParticipant(body, user) {
111
- await this.participantService.removeParticipant(body.eventId, body.userId, user);
108
+ const data = (0, _classtransformer.plainToInstance)(_dtos1.EventParticipantResponseDto, participants);
112
109
  return {
113
110
  success: true,
114
- message: 'Participant removed successfully'
111
+ message: 'Participants retrieved successfully',
112
+ messageKey: _config.EVENT_PARTICIPANT_MESSAGES.GET_ALL_SUCCESS,
113
+ data,
114
+ meta: {
115
+ total: data.length,
116
+ page: 0,
117
+ pageSize: data.length,
118
+ count: data.length
119
+ }
115
120
  };
116
121
  }
117
- buildListResponse(data, message) {
122
+ async getByUser(body, user) {
123
+ const participants = await this.participantService.getParticipantsByUser(body.userId, user);
124
+ const data = (0, _classtransformer.plainToInstance)(_dtos1.EventParticipantResponseDto, participants);
118
125
  return {
119
126
  success: true,
120
- message,
121
- data: data,
127
+ message: 'Participations retrieved successfully',
128
+ messageKey: _config.EVENT_PARTICIPANT_MESSAGES.GET_ALL_SUCCESS,
129
+ data,
122
130
  meta: {
123
131
  total: data.length,
124
132
  page: 0,
@@ -127,6 +135,14 @@ let EventParticipantController = class EventParticipantController extends (0, _c
127
135
  }
128
136
  };
129
137
  }
138
+ async removeParticipant(body, user) {
139
+ await this.participantService.removeParticipant(body.eventId, body.userId, user);
140
+ return {
141
+ success: true,
142
+ message: 'Participant removed successfully',
143
+ messageKey: _config.EVENT_PARTICIPANT_MESSAGES.DELETE_SUCCESS
144
+ };
145
+ }
130
146
  constructor(participantService){
131
147
  super(participantService), _define_property(this, "participantService", void 0), this.participantService = participantService;
132
148
  }
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "EventController", {
11
11
  const _common = require("@nestjs/common");
12
12
  const _swagger = require("@nestjs/swagger");
13
13
  const _classes = require("@flusys/nestjs-shared/classes");
14
+ const _config = require("../config");
14
15
  const _decorators = require("@flusys/nestjs-shared/decorators");
15
16
  const _dtos = require("@flusys/nestjs-shared/dtos");
16
17
  const _guards = require("@flusys/nestjs-shared/guards");
@@ -47,6 +48,7 @@ function _ts_param(paramIndex, decorator) {
47
48
  };
48
49
  }
49
50
  let EventController = class EventController extends (0, _classes.createApiController)(_dtos1.CreateEventDto, _dtos1.UpdateEventDto, _dtos1.EventResponseDto, {
51
+ entityName: 'event',
50
52
  security: {
51
53
  insert: {
52
54
  level: 'permission',
@@ -98,6 +100,7 @@ let EventController = class EventController extends (0, _classes.createApiContro
98
100
  return {
99
101
  success: true,
100
102
  message: 'Calendar events retrieved successfully',
103
+ messageKey: _config.EVENT_MESSAGES.GET_ALL_SUCCESS,
101
104
  data,
102
105
  meta: {
103
106
  total: data.length,
@@ -112,12 +115,14 @@ let EventController = class EventController extends (0, _classes.createApiContro
112
115
  if (!event) {
113
116
  return {
114
117
  success: false,
115
- message: 'Event not found'
118
+ message: 'Event not found',
119
+ messageKey: _config.EVENT_MESSAGES.NOT_FOUND
116
120
  };
117
121
  }
118
122
  return {
119
123
  success: true,
120
124
  message: 'Event retrieved successfully',
125
+ messageKey: _config.EVENT_MESSAGES.GET_SUCCESS,
121
126
  data: (0, _classtransformer.plainToInstance)(_dtos1.EventResponseDto, event)
122
127
  };
123
128
  }
@@ -126,6 +131,7 @@ let EventController = class EventController extends (0, _classes.createApiContro
126
131
  return {
127
132
  success: true,
128
133
  message: 'Participants added successfully',
134
+ messageKey: _config.EVENT_PARTICIPANT_MESSAGES.CREATE_SUCCESS,
129
135
  data: (0, _classtransformer.plainToInstance)(_dtos1.EventParticipantResponseDto, participants)
130
136
  };
131
137
  }
@@ -9,9 +9,11 @@ Object.defineProperty(exports, "EventManagerDataSourceProvider", {
9
9
  }
10
10
  });
11
11
  const _modules = require("@flusys/nestjs-shared/modules");
12
+ const _constants = require("@flusys/nestjs-shared/constants");
12
13
  const _common = require("@nestjs/common");
13
14
  const _core = require("@nestjs/core");
14
15
  const _express = require("express");
16
+ const _entities = require("../entities");
15
17
  const _eventmanagerconfigservice = require("./event-manager-config.service");
16
18
  function _define_property(obj, key, value) {
17
19
  if (key in obj) {
@@ -26,47 +28,6 @@ function _define_property(obj, key, value) {
26
28
  }
27
29
  return obj;
28
30
  }
29
- function _getRequireWildcardCache(nodeInterop) {
30
- if (typeof WeakMap !== "function") return null;
31
- var cacheBabelInterop = new WeakMap();
32
- var cacheNodeInterop = new WeakMap();
33
- return (_getRequireWildcardCache = function(nodeInterop) {
34
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
35
- })(nodeInterop);
36
- }
37
- function _interop_require_wildcard(obj, nodeInterop) {
38
- if (!nodeInterop && obj && obj.__esModule) {
39
- return obj;
40
- }
41
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
42
- return {
43
- default: obj
44
- };
45
- }
46
- var cache = _getRequireWildcardCache(nodeInterop);
47
- if (cache && cache.has(obj)) {
48
- return cache.get(obj);
49
- }
50
- var newObj = {
51
- __proto__: null
52
- };
53
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
54
- for(var key in obj){
55
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
56
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
57
- if (desc && (desc.get || desc.set)) {
58
- Object.defineProperty(newObj, key, desc);
59
- } else {
60
- newObj[key] = obj[key];
61
- }
62
- }
63
- }
64
- newObj.default = obj;
65
- if (cache) {
66
- cache.set(obj, newObj);
67
- }
68
- return newObj;
69
- }
70
31
  function _ts_decorate(decorators, target, key, desc) {
71
32
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
72
33
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -95,24 +56,11 @@ let EventManagerDataSourceProvider = class EventManagerDataSourceProvider extend
95
56
  getEnableCompanyFeatureForTenant(tenant) {
96
57
  return tenant?.enableCompanyFeature ?? this.configService.isCompanyFeatureEnabled();
97
58
  }
98
- // Entity Management
99
- async getEventManagerEntities(enableCompanyFeature) {
100
- const enable = enableCompanyFeature ?? this.configService.isCompanyFeatureEnabled();
101
- const entities = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("../entities")));
102
- // EventParticipant doesn't need company variant - company context comes from Event
103
- return enable ? [
104
- entities.EventWithCompany,
105
- entities.EventParticipant
106
- ] : [
107
- entities.Event,
108
- entities.EventParticipant
109
- ];
110
- }
111
59
  // Overrides
112
60
  async createDataSourceFromConfig(config) {
113
61
  const currentTenant = this.getCurrentTenant();
114
62
  const enableCompanyFeature = this.getEnableCompanyFeatureForTenant(currentTenant ?? undefined);
115
- const entities = await this.getEventManagerEntities(enableCompanyFeature);
63
+ const entities = (0, _entities.getEventManagerEntitiesByConfig)(enableCompanyFeature);
116
64
  return super.createDataSourceFromConfig(config, entities);
117
65
  }
118
66
  async getSingleDataSource() {
@@ -124,7 +72,10 @@ let EventManagerDataSourceProvider = class EventManagerDataSourceProvider extend
124
72
  }
125
73
  const config = this.getDefaultDatabaseConfig();
126
74
  if (!config) {
127
- throw new _common.InternalServerErrorException('No database config available. Provide defaultDatabaseConfig or tenantDefaultDatabaseConfig.');
75
+ throw new _common.InternalServerErrorException({
76
+ message: 'No database config available. Provide defaultDatabaseConfig or tenantDefaultDatabaseConfig.',
77
+ messageKey: _constants.SYSTEM_MESSAGES.DATABASE_CONFIG_NOT_AVAILABLE
78
+ });
128
79
  }
129
80
  const connectionPromise = this.createDataSourceFromConfig(config);
130
81
  EventManagerDataSourceProvider.singleConnectionLock = connectionPromise;
@@ -157,7 +108,7 @@ let EventManagerDataSourceProvider = class EventManagerDataSourceProvider extend
157
108
  }
158
109
  }
159
110
  constructor(configService, request){
160
- super(EventManagerDataSourceProvider.buildParentOptions(configService.getOptions()), request), _define_property(this, "configService", void 0), _define_property(this, "logger", void 0), this.configService = configService, this.logger = new _common.Logger(EventManagerDataSourceProvider.name);
111
+ super(EventManagerDataSourceProvider.buildParentOptions(configService.getOptions()), request), _define_property(this, "configService", void 0), this.configService = configService;
161
112
  }
162
113
  };
163
114
  _define_property(EventManagerDataSourceProvider, "tenantConnections", new Map());
@@ -8,9 +8,11 @@ Object.defineProperty(exports, "EventManagerHelperService", {
8
8
  return EventManagerHelperService;
9
9
  }
10
10
  });
11
+ const _config = require("../config");
11
12
  const _common = require("@nestjs/common");
12
13
  const _typeorm = require("typeorm");
13
14
  const _classes = require("@flusys/nestjs-shared/classes");
15
+ const _decorators = require("@flusys/nestjs-shared/decorators");
14
16
  const _modules = require("@flusys/nestjs-shared/modules");
15
17
  const _nestjsshared = require("@flusys/nestjs-shared");
16
18
  const _eventmanagerconfigservice = require("./event-manager-config.service");
@@ -80,7 +82,6 @@ let EventManagerHelperService = class EventManagerHelperService {
80
82
  const saved = await repo.save(entity);
81
83
  await this.addEventParticipants(saved.id, options.participantIds ?? [], options.organizerId);
82
84
  await this.clearCache();
83
- this.logger.debug(`Event created: ${saved.id} - ${options.title}`);
84
85
  return this.toEventResult(saved);
85
86
  }
86
87
  async addParticipants(eventId, userIds, _companyId) {
@@ -93,7 +94,10 @@ let EventManagerHelperService = class EventManagerHelperService {
93
94
  }
94
95
  });
95
96
  if (!event) {
96
- throw new _common.NotFoundException('Event not found');
97
+ throw new _common.NotFoundException({
98
+ message: 'Event not found',
99
+ messageKey: _config.EVENT_MESSAGES.NOT_FOUND
100
+ });
97
101
  }
98
102
  const existingParticipants = await participantRepo.find({
99
103
  where: {
@@ -111,7 +115,6 @@ let EventManagerHelperService = class EventManagerHelperService {
111
115
  }));
112
116
  if (newParticipants.length > 0) {
113
117
  await participantRepo.save(newParticipants);
114
- this.logger.debug(`Added ${newParticipants.length} participants to event ${eventId}`);
115
118
  }
116
119
  }
117
120
  async removeParticipant(eventId, userId) {
@@ -125,7 +128,6 @@ let EventManagerHelperService = class EventManagerHelperService {
125
128
  });
126
129
  if (participant) {
127
130
  await participantRepo.softRemove(participant);
128
- this.logger.debug(`Removed participant ${userId} from event ${eventId}`);
129
131
  }
130
132
  }
131
133
  async updateParticipantStatus(participantId, status) {
@@ -137,11 +139,13 @@ let EventManagerHelperService = class EventManagerHelperService {
137
139
  }
138
140
  });
139
141
  if (!participant) {
140
- throw new _common.NotFoundException('Event participant not found');
142
+ throw new _common.NotFoundException({
143
+ message: 'Event participant not found',
144
+ messageKey: _config.EVENT_PARTICIPANT_MESSAGES.NOT_FOUND
145
+ });
141
146
  }
142
147
  participant.status = status;
143
148
  await participantRepo.save(participant);
144
- this.logger.debug(`Updated participant ${participantId} status to ${status}`);
145
149
  }
146
150
  async getEventsForUser(userId, startDate, endDate, companyId) {
147
151
  const eventRepo = await this.getEventRepository();
@@ -225,18 +229,64 @@ let EventManagerHelperService = class EventManagerHelperService {
225
229
  _define_property(this, "utilsService", void 0);
226
230
  _define_property(this, "configService", void 0);
227
231
  _define_property(this, "dataSourceProvider", void 0);
228
- _define_property(this, "logger", void 0);
229
232
  _define_property(this, "eventEntityName", void 0);
230
233
  _define_property(this, "dataSource", void 0);
231
234
  this.cacheManager = cacheManager;
232
235
  this.utilsService = utilsService;
233
236
  this.configService = configService;
234
237
  this.dataSourceProvider = dataSourceProvider;
235
- this.logger = new _common.Logger(EventManagerHelperService.name);
236
238
  this.eventEntityName = 'event';
237
239
  this.dataSource = null;
238
240
  }
239
241
  };
242
+ _ts_decorate([
243
+ (0, _decorators.LogAction)({
244
+ action: 'event.create',
245
+ module: 'event-manager'
246
+ }),
247
+ _ts_metadata("design:type", Function),
248
+ _ts_metadata("design:paramtypes", [
249
+ typeof _nestjsshared.CreateEventOptions === "undefined" ? Object : _nestjsshared.CreateEventOptions
250
+ ]),
251
+ _ts_metadata("design:returntype", Promise)
252
+ ], EventManagerHelperService.prototype, "createEvent", null);
253
+ _ts_decorate([
254
+ (0, _decorators.LogAction)({
255
+ action: 'eventParticipant.addMany',
256
+ module: 'event-manager'
257
+ }),
258
+ _ts_metadata("design:type", Function),
259
+ _ts_metadata("design:paramtypes", [
260
+ String,
261
+ Array,
262
+ String
263
+ ]),
264
+ _ts_metadata("design:returntype", Promise)
265
+ ], EventManagerHelperService.prototype, "addParticipants", null);
266
+ _ts_decorate([
267
+ (0, _decorators.LogAction)({
268
+ action: 'eventParticipant.remove',
269
+ module: 'event-manager'
270
+ }),
271
+ _ts_metadata("design:type", Function),
272
+ _ts_metadata("design:paramtypes", [
273
+ String,
274
+ String
275
+ ]),
276
+ _ts_metadata("design:returntype", Promise)
277
+ ], EventManagerHelperService.prototype, "removeParticipant", null);
278
+ _ts_decorate([
279
+ (0, _decorators.LogAction)({
280
+ action: 'eventParticipant.updateStatus',
281
+ module: 'event-manager'
282
+ }),
283
+ _ts_metadata("design:type", Function),
284
+ _ts_metadata("design:paramtypes", [
285
+ String,
286
+ typeof _nestjsshared.ParticipantStatus === "undefined" ? Object : _nestjsshared.ParticipantStatus
287
+ ]),
288
+ _ts_metadata("design:returntype", Promise)
289
+ ], EventManagerHelperService.prototype, "updateParticipantStatus", null);
240
290
  EventManagerHelperService = _ts_decorate([
241
291
  (0, _common.Injectable)(),
242
292
  _ts_param(0, (0, _common.Inject)('CACHE_INSTANCE')),
@@ -9,10 +9,13 @@ Object.defineProperty(exports, "EventParticipantService", {
9
9
  }
10
10
  });
11
11
  const _classes = require("@flusys/nestjs-shared/classes");
12
+ const _decorators = require("@flusys/nestjs-shared/decorators");
12
13
  const _enums = require("@flusys/nestjs-shared/enums");
13
14
  const _modules = require("@flusys/nestjs-shared/modules");
15
+ const _config = require("../config");
14
16
  const _common = require("@nestjs/common");
15
17
  const _eventmanagerconfigservice = require("./event-manager-config.service");
18
+ const _dtos = require("../dtos");
16
19
  const _entities = require("../entities");
17
20
  const _eventmanagerdatasourceprovider = require("./event-manager-datasource.provider");
18
21
  function _define_property(obj, key, value) {
@@ -59,7 +62,10 @@ let EventParticipantService = class EventParticipantService extends _classes.Req
59
62
  id: dto.id
60
63
  }
61
64
  });
62
- if (!existing) throw new _common.NotFoundException('Event participant not found');
65
+ if (!existing) throw new _common.NotFoundException({
66
+ message: 'Event participant not found',
67
+ messageKey: _config.EVENT_PARTICIPANT_MESSAGES.NOT_FOUND
68
+ });
63
69
  entity = existing;
64
70
  }
65
71
  // EventParticipant doesn't have companyId - company context comes from Event
@@ -111,22 +117,25 @@ let EventParticipantService = class EventParticipantService extends _classes.Req
111
117
  }
112
118
  });
113
119
  if (!participant) {
114
- throw new _common.NotFoundException('Event participant not found');
120
+ throw new _common.NotFoundException({
121
+ message: 'Event participant not found',
122
+ messageKey: _config.EVENT_PARTICIPANT_MESSAGES.NOT_FOUND
123
+ });
115
124
  }
116
125
  participant.status = dto.status;
117
- return this.repository.save(participant);
126
+ return await this.repository.save(participant);
118
127
  }
119
128
  async getParticipantsByEvent(eventId, _user) {
120
129
  await this.ensureRepositoryInitialized();
121
130
  // Company filtering happens at Event level, not participant level
122
- return this.repository.createQueryBuilder('event_participant').where('event_participant.eventId = :eventId', {
131
+ return await this.repository.createQueryBuilder('event_participant').where('event_participant.eventId = :eventId', {
123
132
  eventId
124
133
  }).andWhere('event_participant.deletedAt IS NULL').getMany();
125
134
  }
126
135
  async getParticipantsByUser(userId, _user) {
127
136
  await this.ensureRepositoryInitialized();
128
137
  // Company filtering happens at Event level, not participant level
129
- return this.repository.createQueryBuilder('event_participant').where('event_participant.userId = :userId', {
138
+ return await this.repository.createQueryBuilder('event_participant').where('event_participant.userId = :userId', {
130
139
  userId
131
140
  }).andWhere('event_participant.deletedAt IS NULL').getMany();
132
141
  }
@@ -143,9 +152,34 @@ let EventParticipantService = class EventParticipantService extends _classes.Req
143
152
  }
144
153
  }
145
154
  constructor(cacheManager, utilsService, eventConfig, dataSourceProvider){
146
- super('event_participant', null, cacheManager, utilsService, EventParticipantService.name, true), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "eventConfig", void 0), _define_property(this, "dataSourceProvider", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.eventConfig = eventConfig, this.dataSourceProvider = dataSourceProvider;
155
+ super('event_participant', null, cacheManager, utilsService, EventParticipantService.name, true, 'event-manager'), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "eventConfig", void 0), _define_property(this, "dataSourceProvider", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.eventConfig = eventConfig, this.dataSourceProvider = dataSourceProvider;
147
156
  }
148
157
  };
158
+ _ts_decorate([
159
+ (0, _decorators.LogAction)({
160
+ action: 'eventParticipant.updateStatus',
161
+ module: 'event-manager'
162
+ }),
163
+ _ts_metadata("design:type", Function),
164
+ _ts_metadata("design:paramtypes", [
165
+ typeof _dtos.UpdateParticipantStatusDto === "undefined" ? Object : _dtos.UpdateParticipantStatusDto,
166
+ Object
167
+ ]),
168
+ _ts_metadata("design:returntype", Promise)
169
+ ], EventParticipantService.prototype, "updateStatus", null);
170
+ _ts_decorate([
171
+ (0, _decorators.LogAction)({
172
+ action: 'eventParticipant.remove',
173
+ module: 'event-manager'
174
+ }),
175
+ _ts_metadata("design:type", Function),
176
+ _ts_metadata("design:paramtypes", [
177
+ String,
178
+ String,
179
+ Object
180
+ ]),
181
+ _ts_metadata("design:returntype", Promise)
182
+ ], EventParticipantService.prototype, "removeParticipant", null);
149
183
  EventParticipantService = _ts_decorate([
150
184
  (0, _common.Injectable)({
151
185
  scope: _common.Scope.REQUEST
@@ -9,9 +9,11 @@ Object.defineProperty(exports, "EventService", {
9
9
  }
10
10
  });
11
11
  const _classes = require("@flusys/nestjs-shared/classes");
12
+ const _decorators = require("@flusys/nestjs-shared/decorators");
12
13
  const _enums = require("@flusys/nestjs-shared/enums");
13
14
  const _modules = require("@flusys/nestjs-shared/modules");
14
15
  const _utils = require("@flusys/nestjs-shared/utils");
16
+ const _config = require("../config");
15
17
  const _common = require("@nestjs/common");
16
18
  const _typeorm = require("typeorm");
17
19
  const _eventmanagerconfigservice = require("./event-manager-config.service");
@@ -61,7 +63,10 @@ let EventService = class EventService extends _classes.RequestScopedApiService {
61
63
  id: dto.id
62
64
  }
63
65
  });
64
- if (!existing) throw new _common.NotFoundException('Event not found');
66
+ if (!existing) throw new _common.NotFoundException({
67
+ message: 'Event not found',
68
+ messageKey: _config.EVENT_MESSAGES.NOT_FOUND
69
+ });
65
70
  entity = existing;
66
71
  }
67
72
  const merged = {
@@ -96,7 +101,7 @@ let EventService = class EventService extends _classes.RequestScopedApiService {
96
101
  query.andWhere(`${this.entityName}.recurrenceType = :recurrenceType`, {
97
102
  recurrenceType: value
98
103
  });
99
- } else if (key === 'participantUserId' && value) {
104
+ } else if (key === 'participantUserId' && typeof value === 'string') {
100
105
  const eventIds = await this.getParticipantEventIds(value);
101
106
  if (eventIds.length > 0) {
102
107
  query.andWhere(`${this.entityName}.id IN (:...participantEventIds)`, {
@@ -188,7 +193,10 @@ let EventService = class EventService extends _classes.RequestScopedApiService {
188
193
  }
189
194
  });
190
195
  if (!event) {
191
- throw new _common.NotFoundException('Event not found');
196
+ throw new _common.NotFoundException({
197
+ message: 'Event not found',
198
+ messageKey: _config.EVENT_MESSAGES.NOT_FOUND
199
+ });
192
200
  }
193
201
  const existingParticipants = await participantRepo.find({
194
202
  where: {
@@ -400,9 +408,22 @@ let EventService = class EventService extends _classes.RequestScopedApiService {
400
408
  };
401
409
  }
402
410
  constructor(cacheManager, utilsService, eventConfig, dataSourceProvider){
403
- super('event', null, cacheManager, utilsService, EventService.name, true), _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 = [];
411
+ super('event', null, cacheManager, utilsService, EventService.name, true, 'event-manager'), _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 = [];
404
412
  }
405
413
  };
414
+ _ts_decorate([
415
+ (0, _decorators.LogAction)({
416
+ action: 'event.addParticipants',
417
+ module: 'event-manager'
418
+ }),
419
+ _ts_metadata("design:type", Function),
420
+ _ts_metadata("design:paramtypes", [
421
+ String,
422
+ Array,
423
+ Object
424
+ ]),
425
+ _ts_metadata("design:returntype", Promise)
426
+ ], EventService.prototype, "addParticipants", null);
406
427
  EventService = _ts_decorate([
407
428
  (0, _common.Injectable)({
408
429
  scope: _common.Scope.REQUEST
package/config/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './event-manager.constants';
2
+ export * from './message-keys';
@@ -0,0 +1,64 @@
1
+ export declare const EVENT_MESSAGES: {
2
+ readonly CREATE_SUCCESS: "event.create.success";
3
+ readonly CREATE_MANY_SUCCESS: "event.create.many.success";
4
+ readonly GET_SUCCESS: "event.get.success";
5
+ readonly GET_ALL_SUCCESS: "event.get.all.success";
6
+ readonly UPDATE_SUCCESS: "event.update.success";
7
+ readonly UPDATE_MANY_SUCCESS: "event.update.many.success";
8
+ readonly DELETE_SUCCESS: "event.delete.success";
9
+ readonly RESTORE_SUCCESS: "event.restore.success";
10
+ readonly NOT_FOUND: "event.not.found";
11
+ readonly PUBLISH_SUCCESS: "event.publish.success";
12
+ readonly UNPUBLISH_SUCCESS: "event.unpublish.success";
13
+ readonly CANCEL_SUCCESS: "event.cancel.success";
14
+ readonly UPCOMING_SUCCESS: "event.upcoming.success";
15
+ readonly MY_EVENTS_SUCCESS: "event.my.events.success";
16
+ };
17
+ export declare const EVENT_PARTICIPANT_MESSAGES: {
18
+ readonly CREATE_SUCCESS: "event.participant.create.success";
19
+ readonly CREATE_MANY_SUCCESS: "event.participant.create.many.success";
20
+ readonly GET_SUCCESS: "event.participant.get.success";
21
+ readonly GET_ALL_SUCCESS: "event.participant.get.all.success";
22
+ readonly UPDATE_SUCCESS: "event.participant.update.success";
23
+ readonly UPDATE_MANY_SUCCESS: "event.participant.update.many.success";
24
+ readonly DELETE_SUCCESS: "event.participant.delete.success";
25
+ readonly RESTORE_SUCCESS: "event.participant.restore.success";
26
+ readonly NOT_FOUND: "event.participant.not.found";
27
+ readonly REGISTER_SUCCESS: "event.participant.register.success";
28
+ readonly UNREGISTER_SUCCESS: "event.participant.unregister.success";
29
+ readonly CHECKIN_SUCCESS: "event.participant.checkin.success";
30
+ readonly STATUS_UPDATE_SUCCESS: "event.participant.status.update.success";
31
+ };
32
+ export declare const EVENT_MANAGER_MODULE_MESSAGES: {
33
+ readonly EVENT: {
34
+ readonly CREATE_SUCCESS: "event.create.success";
35
+ readonly CREATE_MANY_SUCCESS: "event.create.many.success";
36
+ readonly GET_SUCCESS: "event.get.success";
37
+ readonly GET_ALL_SUCCESS: "event.get.all.success";
38
+ readonly UPDATE_SUCCESS: "event.update.success";
39
+ readonly UPDATE_MANY_SUCCESS: "event.update.many.success";
40
+ readonly DELETE_SUCCESS: "event.delete.success";
41
+ readonly RESTORE_SUCCESS: "event.restore.success";
42
+ readonly NOT_FOUND: "event.not.found";
43
+ readonly PUBLISH_SUCCESS: "event.publish.success";
44
+ readonly UNPUBLISH_SUCCESS: "event.unpublish.success";
45
+ readonly CANCEL_SUCCESS: "event.cancel.success";
46
+ readonly UPCOMING_SUCCESS: "event.upcoming.success";
47
+ readonly MY_EVENTS_SUCCESS: "event.my.events.success";
48
+ };
49
+ readonly EVENT_PARTICIPANT: {
50
+ readonly CREATE_SUCCESS: "event.participant.create.success";
51
+ readonly CREATE_MANY_SUCCESS: "event.participant.create.many.success";
52
+ readonly GET_SUCCESS: "event.participant.get.success";
53
+ readonly GET_ALL_SUCCESS: "event.participant.get.all.success";
54
+ readonly UPDATE_SUCCESS: "event.participant.update.success";
55
+ readonly UPDATE_MANY_SUCCESS: "event.participant.update.many.success";
56
+ readonly DELETE_SUCCESS: "event.participant.delete.success";
57
+ readonly RESTORE_SUCCESS: "event.participant.restore.success";
58
+ readonly NOT_FOUND: "event.participant.not.found";
59
+ readonly REGISTER_SUCCESS: "event.participant.register.success";
60
+ readonly UNREGISTER_SUCCESS: "event.participant.unregister.success";
61
+ readonly CHECKIN_SUCCESS: "event.participant.checkin.success";
62
+ readonly STATUS_UPDATE_SUCCESS: "event.participant.status.update.success";
63
+ };
64
+ };
@@ -26,6 +26,5 @@ export declare class EventParticipantController extends EventParticipantControll
26
26
  eventId: string;
27
27
  userId: string;
28
28
  }, user: ILoggedUserInfo): Promise<MessageResponseDto>;
29
- private buildListResponse;
30
29
  }
31
30
  export {};
@@ -1 +1,2 @@
1
1
  export * from './event-manager.constants';
2
+ export * from './message-keys';
@@ -0,0 +1,37 @@
1
+ // ==================== EVENT MANAGER MODULE MESSAGE KEYS ====================
2
+ export const EVENT_MESSAGES = {
3
+ CREATE_SUCCESS: 'event.create.success',
4
+ CREATE_MANY_SUCCESS: 'event.create.many.success',
5
+ GET_SUCCESS: 'event.get.success',
6
+ GET_ALL_SUCCESS: 'event.get.all.success',
7
+ UPDATE_SUCCESS: 'event.update.success',
8
+ UPDATE_MANY_SUCCESS: 'event.update.many.success',
9
+ DELETE_SUCCESS: 'event.delete.success',
10
+ RESTORE_SUCCESS: 'event.restore.success',
11
+ NOT_FOUND: 'event.not.found',
12
+ PUBLISH_SUCCESS: 'event.publish.success',
13
+ UNPUBLISH_SUCCESS: 'event.unpublish.success',
14
+ CANCEL_SUCCESS: 'event.cancel.success',
15
+ UPCOMING_SUCCESS: 'event.upcoming.success',
16
+ MY_EVENTS_SUCCESS: 'event.my.events.success'
17
+ };
18
+ export const EVENT_PARTICIPANT_MESSAGES = {
19
+ CREATE_SUCCESS: 'event.participant.create.success',
20
+ CREATE_MANY_SUCCESS: 'event.participant.create.many.success',
21
+ GET_SUCCESS: 'event.participant.get.success',
22
+ GET_ALL_SUCCESS: 'event.participant.get.all.success',
23
+ UPDATE_SUCCESS: 'event.participant.update.success',
24
+ UPDATE_MANY_SUCCESS: 'event.participant.update.many.success',
25
+ DELETE_SUCCESS: 'event.participant.delete.success',
26
+ RESTORE_SUCCESS: 'event.participant.restore.success',
27
+ NOT_FOUND: 'event.participant.not.found',
28
+ REGISTER_SUCCESS: 'event.participant.register.success',
29
+ UNREGISTER_SUCCESS: 'event.participant.unregister.success',
30
+ CHECKIN_SUCCESS: 'event.participant.checkin.success',
31
+ STATUS_UPDATE_SUCCESS: 'event.participant.status.update.success'
32
+ };
33
+ // Aggregated export for backward compatibility
34
+ export const EVENT_MANAGER_MODULE_MESSAGES = {
35
+ EVENT: EVENT_MESSAGES,
36
+ EVENT_PARTICIPANT: EVENT_PARTICIPANT_MESSAGES
37
+ };
@@ -27,7 +27,9 @@ function _ts_param(paramIndex, decorator) {
27
27
  }
28
28
  import { Body, Controller, HttpCode, HttpStatus, Inject, Post, UseGuards } from '@nestjs/common';
29
29
  import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
30
+ import { plainToInstance } from 'class-transformer';
30
31
  import { createApiController } from '@flusys/nestjs-shared/classes';
32
+ import { EVENT_PARTICIPANT_MESSAGES } from '../config';
31
33
  import { CurrentUser, RequirePermission } from '@flusys/nestjs-shared/decorators';
32
34
  import { ListResponseDto, MessageResponseDto, SingleResponseDto } from '@flusys/nestjs-shared/dtos';
33
35
  import { JwtAuthGuard } from '@flusys/nestjs-shared/guards';
@@ -36,6 +38,7 @@ import { CreateEventParticipantDto, EventParticipantResponseDto, UpdateParticipa
36
38
  import { EVENT_PARTICIPANT_PERMISSIONS } from '../docs';
37
39
  import { EventParticipantService } from '../services/event-participant.service';
38
40
  export class EventParticipantController extends createApiController(CreateEventParticipantDto, UpdateEventParticipantDto, EventParticipantResponseDto, {
41
+ entityName: 'eventParticipant',
39
42
  security: {
40
43
  insert: {
41
44
  level: 'permission',
@@ -86,29 +89,34 @@ export class EventParticipantController extends createApiController(CreateEventP
86
89
  return {
87
90
  success: true,
88
91
  message: 'Participant status updated successfully',
89
- data: participant
92
+ messageKey: EVENT_PARTICIPANT_MESSAGES.STATUS_UPDATE_SUCCESS,
93
+ data: plainToInstance(EventParticipantResponseDto, participant)
90
94
  };
91
95
  }
92
96
  async getByEvent(body, user) {
93
97
  const participants = await this.participantService.getParticipantsByEvent(body.eventId, user);
94
- return this.buildListResponse(participants, 'Participants retrieved successfully');
95
- }
96
- async getByUser(body, user) {
97
- const participants = await this.participantService.getParticipantsByUser(body.userId, user);
98
- return this.buildListResponse(participants, 'Participations retrieved successfully');
99
- }
100
- async removeParticipant(body, user) {
101
- await this.participantService.removeParticipant(body.eventId, body.userId, user);
98
+ const data = plainToInstance(EventParticipantResponseDto, participants);
102
99
  return {
103
100
  success: true,
104
- message: 'Participant removed successfully'
101
+ message: 'Participants retrieved successfully',
102
+ messageKey: EVENT_PARTICIPANT_MESSAGES.GET_ALL_SUCCESS,
103
+ data,
104
+ meta: {
105
+ total: data.length,
106
+ page: 0,
107
+ pageSize: data.length,
108
+ count: data.length
109
+ }
105
110
  };
106
111
  }
107
- buildListResponse(data, message) {
112
+ async getByUser(body, user) {
113
+ const participants = await this.participantService.getParticipantsByUser(body.userId, user);
114
+ const data = plainToInstance(EventParticipantResponseDto, participants);
108
115
  return {
109
116
  success: true,
110
- message,
111
- data: data,
117
+ message: 'Participations retrieved successfully',
118
+ messageKey: EVENT_PARTICIPANT_MESSAGES.GET_ALL_SUCCESS,
119
+ data,
112
120
  meta: {
113
121
  total: data.length,
114
122
  page: 0,
@@ -117,6 +125,14 @@ export class EventParticipantController extends createApiController(CreateEventP
117
125
  }
118
126
  };
119
127
  }
128
+ async removeParticipant(body, user) {
129
+ await this.participantService.removeParticipant(body.eventId, body.userId, user);
130
+ return {
131
+ success: true,
132
+ message: 'Participant removed successfully',
133
+ messageKey: EVENT_PARTICIPANT_MESSAGES.DELETE_SUCCESS
134
+ };
135
+ }
120
136
  constructor(participantService){
121
137
  super(participantService), _define_property(this, "participantService", void 0), this.participantService = participantService;
122
138
  }
@@ -28,6 +28,7 @@ function _ts_param(paramIndex, decorator) {
28
28
  import { Body, Controller, HttpCode, HttpStatus, Inject, Post, UseGuards } from '@nestjs/common';
29
29
  import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
30
30
  import { createApiController } from '@flusys/nestjs-shared/classes';
31
+ import { EVENT_MESSAGES, EVENT_PARTICIPANT_MESSAGES } from '../config';
31
32
  import { CurrentUser, RequirePermission } from '@flusys/nestjs-shared/decorators';
32
33
  import { ListResponseDto, SingleResponseDto } from '@flusys/nestjs-shared/dtos';
33
34
  import { JwtAuthGuard } from '@flusys/nestjs-shared/guards';
@@ -37,6 +38,7 @@ import { BulkAddParticipantsDto, CalendarQueryDto, CalendarEventResponseDto, Cre
37
38
  import { EVENT_PERMISSIONS } from '../docs';
38
39
  import { EventService } from '../services/event.service';
39
40
  export class EventController extends createApiController(CreateEventDto, UpdateEventDto, EventResponseDto, {
41
+ entityName: 'event',
40
42
  security: {
41
43
  insert: {
42
44
  level: 'permission',
@@ -88,6 +90,7 @@ export class EventController extends createApiController(CreateEventDto, UpdateE
88
90
  return {
89
91
  success: true,
90
92
  message: 'Calendar events retrieved successfully',
93
+ messageKey: EVENT_MESSAGES.GET_ALL_SUCCESS,
91
94
  data,
92
95
  meta: {
93
96
  total: data.length,
@@ -102,12 +105,14 @@ export class EventController extends createApiController(CreateEventDto, UpdateE
102
105
  if (!event) {
103
106
  return {
104
107
  success: false,
105
- message: 'Event not found'
108
+ message: 'Event not found',
109
+ messageKey: EVENT_MESSAGES.NOT_FOUND
106
110
  };
107
111
  }
108
112
  return {
109
113
  success: true,
110
114
  message: 'Event retrieved successfully',
115
+ messageKey: EVENT_MESSAGES.GET_SUCCESS,
111
116
  data: plainToInstance(EventResponseDto, event)
112
117
  };
113
118
  }
@@ -116,6 +121,7 @@ export class EventController extends createApiController(CreateEventDto, UpdateE
116
121
  return {
117
122
  success: true,
118
123
  message: 'Participants added successfully',
124
+ messageKey: EVENT_PARTICIPANT_MESSAGES.CREATE_SUCCESS,
119
125
  data: plainToInstance(EventParticipantResponseDto, participants)
120
126
  };
121
127
  }
@@ -26,9 +26,11 @@ function _ts_param(paramIndex, decorator) {
26
26
  };
27
27
  }
28
28
  import { MultiTenantDataSourceService } from '@flusys/nestjs-shared/modules';
29
- import { Inject, Injectable, InternalServerErrorException, Logger, Optional, Scope } from '@nestjs/common';
29
+ import { SYSTEM_MESSAGES } from '@flusys/nestjs-shared/constants';
30
+ import { Inject, Injectable, InternalServerErrorException, Optional, Scope } from '@nestjs/common';
30
31
  import { REQUEST } from '@nestjs/core';
31
32
  import { Request } from 'express';
33
+ import { getEventManagerEntitiesByConfig } from '../entities';
32
34
  import { EventManagerConfigService } from './event-manager-config.service';
33
35
  export class EventManagerDataSourceProvider extends MultiTenantDataSourceService {
34
36
  // Factory Methods
@@ -44,24 +46,11 @@ export class EventManagerDataSourceProvider extends MultiTenantDataSourceService
44
46
  getEnableCompanyFeatureForTenant(tenant) {
45
47
  return tenant?.enableCompanyFeature ?? this.configService.isCompanyFeatureEnabled();
46
48
  }
47
- // Entity Management
48
- async getEventManagerEntities(enableCompanyFeature) {
49
- const enable = enableCompanyFeature ?? this.configService.isCompanyFeatureEnabled();
50
- const entities = await import('../entities');
51
- // EventParticipant doesn't need company variant - company context comes from Event
52
- return enable ? [
53
- entities.EventWithCompany,
54
- entities.EventParticipant
55
- ] : [
56
- entities.Event,
57
- entities.EventParticipant
58
- ];
59
- }
60
49
  // Overrides
61
50
  async createDataSourceFromConfig(config) {
62
51
  const currentTenant = this.getCurrentTenant();
63
52
  const enableCompanyFeature = this.getEnableCompanyFeatureForTenant(currentTenant ?? undefined);
64
- const entities = await this.getEventManagerEntities(enableCompanyFeature);
53
+ const entities = getEventManagerEntitiesByConfig(enableCompanyFeature);
65
54
  return super.createDataSourceFromConfig(config, entities);
66
55
  }
67
56
  async getSingleDataSource() {
@@ -73,7 +62,10 @@ export class EventManagerDataSourceProvider extends MultiTenantDataSourceService
73
62
  }
74
63
  const config = this.getDefaultDatabaseConfig();
75
64
  if (!config) {
76
- throw new InternalServerErrorException('No database config available. Provide defaultDatabaseConfig or tenantDefaultDatabaseConfig.');
65
+ throw new InternalServerErrorException({
66
+ message: 'No database config available. Provide defaultDatabaseConfig or tenantDefaultDatabaseConfig.',
67
+ messageKey: SYSTEM_MESSAGES.DATABASE_CONFIG_NOT_AVAILABLE
68
+ });
77
69
  }
78
70
  const connectionPromise = this.createDataSourceFromConfig(config);
79
71
  EventManagerDataSourceProvider.singleConnectionLock = connectionPromise;
@@ -106,7 +98,7 @@ export class EventManagerDataSourceProvider extends MultiTenantDataSourceService
106
98
  }
107
99
  }
108
100
  constructor(configService, request){
109
- super(EventManagerDataSourceProvider.buildParentOptions(configService.getOptions()), request), _define_property(this, "configService", void 0), _define_property(this, "logger", void 0), this.configService = configService, this.logger = new Logger(EventManagerDataSourceProvider.name);
101
+ super(EventManagerDataSourceProvider.buildParentOptions(configService.getOptions()), request), _define_property(this, "configService", void 0), this.configService = configService;
110
102
  }
111
103
  }
112
104
  _define_property(EventManagerDataSourceProvider, "tenantConnections", new Map());
@@ -25,11 +25,13 @@ function _ts_param(paramIndex, decorator) {
25
25
  decorator(target, key, paramIndex);
26
26
  };
27
27
  }
28
- import { Inject, Injectable, Logger, NotFoundException } from '@nestjs/common';
28
+ import { EVENT_MESSAGES, EVENT_PARTICIPANT_MESSAGES } from '../config';
29
+ import { Inject, Injectable, NotFoundException } from '@nestjs/common';
29
30
  import { In, IsNull } from 'typeorm';
30
31
  import { HybridCache } from '@flusys/nestjs-shared/classes';
32
+ import { LogAction } from '@flusys/nestjs-shared/decorators';
31
33
  import { UtilsService } from '@flusys/nestjs-shared/modules';
32
- import { ParticipantStatus, RecurrenceType } from '@flusys/nestjs-shared';
34
+ import { CreateEventOptions, ParticipantStatus, RecurrenceType } from '@flusys/nestjs-shared';
33
35
  import { EventManagerConfigService } from './event-manager-config.service';
34
36
  import { EventManagerDataSourceProvider } from './event-manager-datasource.provider';
35
37
  import { Event, EventWithCompany, EventParticipant } from '../entities';
@@ -70,7 +72,6 @@ export class EventManagerHelperService {
70
72
  const saved = await repo.save(entity);
71
73
  await this.addEventParticipants(saved.id, options.participantIds ?? [], options.organizerId);
72
74
  await this.clearCache();
73
- this.logger.debug(`Event created: ${saved.id} - ${options.title}`);
74
75
  return this.toEventResult(saved);
75
76
  }
76
77
  async addParticipants(eventId, userIds, _companyId) {
@@ -83,7 +84,10 @@ export class EventManagerHelperService {
83
84
  }
84
85
  });
85
86
  if (!event) {
86
- throw new NotFoundException('Event not found');
87
+ throw new NotFoundException({
88
+ message: 'Event not found',
89
+ messageKey: EVENT_MESSAGES.NOT_FOUND
90
+ });
87
91
  }
88
92
  const existingParticipants = await participantRepo.find({
89
93
  where: {
@@ -101,7 +105,6 @@ export class EventManagerHelperService {
101
105
  }));
102
106
  if (newParticipants.length > 0) {
103
107
  await participantRepo.save(newParticipants);
104
- this.logger.debug(`Added ${newParticipants.length} participants to event ${eventId}`);
105
108
  }
106
109
  }
107
110
  async removeParticipant(eventId, userId) {
@@ -115,7 +118,6 @@ export class EventManagerHelperService {
115
118
  });
116
119
  if (participant) {
117
120
  await participantRepo.softRemove(participant);
118
- this.logger.debug(`Removed participant ${userId} from event ${eventId}`);
119
121
  }
120
122
  }
121
123
  async updateParticipantStatus(participantId, status) {
@@ -127,11 +129,13 @@ export class EventManagerHelperService {
127
129
  }
128
130
  });
129
131
  if (!participant) {
130
- throw new NotFoundException('Event participant not found');
132
+ throw new NotFoundException({
133
+ message: 'Event participant not found',
134
+ messageKey: EVENT_PARTICIPANT_MESSAGES.NOT_FOUND
135
+ });
131
136
  }
132
137
  participant.status = status;
133
138
  await participantRepo.save(participant);
134
- this.logger.debug(`Updated participant ${participantId} status to ${status}`);
135
139
  }
136
140
  async getEventsForUser(userId, startDate, endDate, companyId) {
137
141
  const eventRepo = await this.getEventRepository();
@@ -215,18 +219,64 @@ export class EventManagerHelperService {
215
219
  _define_property(this, "utilsService", void 0);
216
220
  _define_property(this, "configService", void 0);
217
221
  _define_property(this, "dataSourceProvider", void 0);
218
- _define_property(this, "logger", void 0);
219
222
  _define_property(this, "eventEntityName", void 0);
220
223
  _define_property(this, "dataSource", void 0);
221
224
  this.cacheManager = cacheManager;
222
225
  this.utilsService = utilsService;
223
226
  this.configService = configService;
224
227
  this.dataSourceProvider = dataSourceProvider;
225
- this.logger = new Logger(EventManagerHelperService.name);
226
228
  this.eventEntityName = 'event';
227
229
  this.dataSource = null;
228
230
  }
229
231
  }
232
+ _ts_decorate([
233
+ LogAction({
234
+ action: 'event.create',
235
+ module: 'event-manager'
236
+ }),
237
+ _ts_metadata("design:type", Function),
238
+ _ts_metadata("design:paramtypes", [
239
+ typeof CreateEventOptions === "undefined" ? Object : CreateEventOptions
240
+ ]),
241
+ _ts_metadata("design:returntype", Promise)
242
+ ], EventManagerHelperService.prototype, "createEvent", null);
243
+ _ts_decorate([
244
+ LogAction({
245
+ action: 'eventParticipant.addMany',
246
+ module: 'event-manager'
247
+ }),
248
+ _ts_metadata("design:type", Function),
249
+ _ts_metadata("design:paramtypes", [
250
+ String,
251
+ Array,
252
+ String
253
+ ]),
254
+ _ts_metadata("design:returntype", Promise)
255
+ ], EventManagerHelperService.prototype, "addParticipants", null);
256
+ _ts_decorate([
257
+ LogAction({
258
+ action: 'eventParticipant.remove',
259
+ module: 'event-manager'
260
+ }),
261
+ _ts_metadata("design:type", Function),
262
+ _ts_metadata("design:paramtypes", [
263
+ String,
264
+ String
265
+ ]),
266
+ _ts_metadata("design:returntype", Promise)
267
+ ], EventManagerHelperService.prototype, "removeParticipant", null);
268
+ _ts_decorate([
269
+ LogAction({
270
+ action: 'eventParticipant.updateStatus',
271
+ module: 'event-manager'
272
+ }),
273
+ _ts_metadata("design:type", Function),
274
+ _ts_metadata("design:paramtypes", [
275
+ String,
276
+ typeof ParticipantStatus === "undefined" ? Object : ParticipantStatus
277
+ ]),
278
+ _ts_metadata("design:returntype", Promise)
279
+ ], EventManagerHelperService.prototype, "updateParticipantStatus", null);
230
280
  EventManagerHelperService = _ts_decorate([
231
281
  Injectable(),
232
282
  _ts_param(0, Inject('CACHE_INSTANCE')),
@@ -26,10 +26,13 @@ function _ts_param(paramIndex, decorator) {
26
26
  };
27
27
  }
28
28
  import { HybridCache, RequestScopedApiService } from '@flusys/nestjs-shared/classes';
29
+ import { LogAction } from '@flusys/nestjs-shared/decorators';
29
30
  import { ParticipantStatus } from '@flusys/nestjs-shared/enums';
30
31
  import { UtilsService } from '@flusys/nestjs-shared/modules';
32
+ import { EVENT_PARTICIPANT_MESSAGES } from '../config';
31
33
  import { Inject, Injectable, NotFoundException, Scope } from '@nestjs/common';
32
34
  import { EventManagerConfigService } from './event-manager-config.service';
35
+ import { UpdateParticipantStatusDto } from '../dtos';
33
36
  import { EventParticipant } from '../entities';
34
37
  import { EventManagerDataSourceProvider } from './event-manager-datasource.provider';
35
38
  export class EventParticipantService extends RequestScopedApiService {
@@ -49,7 +52,10 @@ export class EventParticipantService extends RequestScopedApiService {
49
52
  id: dto.id
50
53
  }
51
54
  });
52
- if (!existing) throw new NotFoundException('Event participant not found');
55
+ if (!existing) throw new NotFoundException({
56
+ message: 'Event participant not found',
57
+ messageKey: EVENT_PARTICIPANT_MESSAGES.NOT_FOUND
58
+ });
53
59
  entity = existing;
54
60
  }
55
61
  // EventParticipant doesn't have companyId - company context comes from Event
@@ -101,22 +107,25 @@ export class EventParticipantService extends RequestScopedApiService {
101
107
  }
102
108
  });
103
109
  if (!participant) {
104
- throw new NotFoundException('Event participant not found');
110
+ throw new NotFoundException({
111
+ message: 'Event participant not found',
112
+ messageKey: EVENT_PARTICIPANT_MESSAGES.NOT_FOUND
113
+ });
105
114
  }
106
115
  participant.status = dto.status;
107
- return this.repository.save(participant);
116
+ return await this.repository.save(participant);
108
117
  }
109
118
  async getParticipantsByEvent(eventId, _user) {
110
119
  await this.ensureRepositoryInitialized();
111
120
  // Company filtering happens at Event level, not participant level
112
- return this.repository.createQueryBuilder('event_participant').where('event_participant.eventId = :eventId', {
121
+ return await this.repository.createQueryBuilder('event_participant').where('event_participant.eventId = :eventId', {
113
122
  eventId
114
123
  }).andWhere('event_participant.deletedAt IS NULL').getMany();
115
124
  }
116
125
  async getParticipantsByUser(userId, _user) {
117
126
  await this.ensureRepositoryInitialized();
118
127
  // Company filtering happens at Event level, not participant level
119
- return this.repository.createQueryBuilder('event_participant').where('event_participant.userId = :userId', {
128
+ return await this.repository.createQueryBuilder('event_participant').where('event_participant.userId = :userId', {
120
129
  userId
121
130
  }).andWhere('event_participant.deletedAt IS NULL').getMany();
122
131
  }
@@ -133,9 +142,34 @@ export class EventParticipantService extends RequestScopedApiService {
133
142
  }
134
143
  }
135
144
  constructor(cacheManager, utilsService, eventConfig, dataSourceProvider){
136
- super('event_participant', null, cacheManager, utilsService, EventParticipantService.name, true), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "eventConfig", void 0), _define_property(this, "dataSourceProvider", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.eventConfig = eventConfig, this.dataSourceProvider = dataSourceProvider;
145
+ super('event_participant', null, cacheManager, utilsService, EventParticipantService.name, true, 'event-manager'), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "eventConfig", void 0), _define_property(this, "dataSourceProvider", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.eventConfig = eventConfig, this.dataSourceProvider = dataSourceProvider;
137
146
  }
138
147
  }
148
+ _ts_decorate([
149
+ LogAction({
150
+ action: 'eventParticipant.updateStatus',
151
+ module: 'event-manager'
152
+ }),
153
+ _ts_metadata("design:type", Function),
154
+ _ts_metadata("design:paramtypes", [
155
+ typeof UpdateParticipantStatusDto === "undefined" ? Object : UpdateParticipantStatusDto,
156
+ Object
157
+ ]),
158
+ _ts_metadata("design:returntype", Promise)
159
+ ], EventParticipantService.prototype, "updateStatus", null);
160
+ _ts_decorate([
161
+ LogAction({
162
+ action: 'eventParticipant.remove',
163
+ module: 'event-manager'
164
+ }),
165
+ _ts_metadata("design:type", Function),
166
+ _ts_metadata("design:paramtypes", [
167
+ String,
168
+ String,
169
+ Object
170
+ ]),
171
+ _ts_metadata("design:returntype", Promise)
172
+ ], EventParticipantService.prototype, "removeParticipant", null);
139
173
  EventParticipantService = _ts_decorate([
140
174
  Injectable({
141
175
  scope: Scope.REQUEST
@@ -26,9 +26,11 @@ function _ts_param(paramIndex, decorator) {
26
26
  };
27
27
  }
28
28
  import { HybridCache, RequestScopedApiService } from '@flusys/nestjs-shared/classes';
29
+ import { LogAction } from '@flusys/nestjs-shared/decorators';
29
30
  import { RecurrenceType } from '@flusys/nestjs-shared/enums';
30
31
  import { UtilsService } from '@flusys/nestjs-shared/modules';
31
32
  import { applyCompanyFilter } from '@flusys/nestjs-shared/utils';
33
+ import { EVENT_MESSAGES } from '../config';
32
34
  import { Inject, Injectable, NotFoundException, Scope } from '@nestjs/common';
33
35
  import { In, IsNull } from 'typeorm';
34
36
  import { EventManagerConfigService } from './event-manager-config.service';
@@ -51,7 +53,10 @@ export class EventService extends RequestScopedApiService {
51
53
  id: dto.id
52
54
  }
53
55
  });
54
- if (!existing) throw new NotFoundException('Event not found');
56
+ if (!existing) throw new NotFoundException({
57
+ message: 'Event not found',
58
+ messageKey: EVENT_MESSAGES.NOT_FOUND
59
+ });
55
60
  entity = existing;
56
61
  }
57
62
  const merged = {
@@ -86,7 +91,7 @@ export class EventService extends RequestScopedApiService {
86
91
  query.andWhere(`${this.entityName}.recurrenceType = :recurrenceType`, {
87
92
  recurrenceType: value
88
93
  });
89
- } else if (key === 'participantUserId' && value) {
94
+ } else if (key === 'participantUserId' && typeof value === 'string') {
90
95
  const eventIds = await this.getParticipantEventIds(value);
91
96
  if (eventIds.length > 0) {
92
97
  query.andWhere(`${this.entityName}.id IN (:...participantEventIds)`, {
@@ -178,7 +183,10 @@ export class EventService extends RequestScopedApiService {
178
183
  }
179
184
  });
180
185
  if (!event) {
181
- throw new NotFoundException('Event not found');
186
+ throw new NotFoundException({
187
+ message: 'Event not found',
188
+ messageKey: EVENT_MESSAGES.NOT_FOUND
189
+ });
182
190
  }
183
191
  const existingParticipants = await participantRepo.find({
184
192
  where: {
@@ -390,9 +398,22 @@ export class EventService extends RequestScopedApiService {
390
398
  };
391
399
  }
392
400
  constructor(cacheManager, utilsService, eventConfig, dataSourceProvider){
393
- super('event', null, cacheManager, utilsService, EventService.name, true), _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 = [];
401
+ super('event', null, cacheManager, utilsService, EventService.name, true, 'event-manager'), _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 = [];
394
402
  }
395
403
  }
404
+ _ts_decorate([
405
+ LogAction({
406
+ action: 'event.addParticipants',
407
+ module: 'event-manager'
408
+ }),
409
+ _ts_metadata("design:type", Function),
410
+ _ts_metadata("design:paramtypes", [
411
+ String,
412
+ Array,
413
+ Object
414
+ ]),
415
+ _ts_metadata("design:returntype", Promise)
416
+ ], EventService.prototype, "addParticipants", null);
396
417
  EventService = _ts_decorate([
397
418
  Injectable({
398
419
  scope: Scope.REQUEST
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flusys/nestjs-event-manager",
3
- "version": "3.0.1",
3
+ "version": "4.0.0-lts",
4
4
  "description": "Event manager module with calendar support and recurrence",
5
5
  "main": "cjs/index.js",
6
6
  "module": "fesm/index.js",
@@ -80,10 +80,11 @@
80
80
  "@nestjs/typeorm": "^10.0.0 || ^11.0.0",
81
81
  "class-transformer": "^0.5.0",
82
82
  "class-validator": "^0.14.0",
83
- "typeorm": "^0.3.0"
83
+ "typeorm": "^0.3.0",
84
+ "express": "^4.18.0"
84
85
  },
85
86
  "dependencies": {
86
- "@flusys/nestjs-core": "3.0.1",
87
- "@flusys/nestjs-shared": "3.0.1"
87
+ "@flusys/nestjs-core": "4.0.0-lts",
88
+ "@flusys/nestjs-shared": "4.0.0-lts"
88
89
  }
89
90
  }
@@ -1,12 +1,10 @@
1
1
  import { MultiTenantDataSourceService } from '@flusys/nestjs-shared/modules';
2
2
  import { IDatabaseConfig, ITenantDatabaseConfig } from '@flusys/nestjs-core';
3
- import { Logger } from '@nestjs/common';
4
3
  import { Request } from 'express';
5
4
  import { DataSource } from 'typeorm';
6
5
  import { EventManagerConfigService } from './event-manager-config.service';
7
6
  export declare class EventManagerDataSourceProvider extends MultiTenantDataSourceService {
8
7
  private readonly configService;
9
- protected readonly logger: Logger;
10
8
  protected static readonly tenantConnections: Map<string, DataSource>;
11
9
  protected static singleDataSource: DataSource | null;
12
10
  protected static readonly tenantsRegistry: Map<string, ITenantDatabaseConfig>;
@@ -16,7 +14,6 @@ export declare class EventManagerDataSourceProvider extends MultiTenantDataSourc
16
14
  constructor(configService: EventManagerConfigService, request?: Request);
17
15
  private static buildParentOptions;
18
16
  getEnableCompanyFeatureForTenant(tenant?: ITenantDatabaseConfig): boolean;
19
- getEventManagerEntities(enableCompanyFeature?: boolean): Promise<any[]>;
20
17
  protected createDataSourceFromConfig(config: IDatabaseConfig): Promise<DataSource>;
21
18
  protected getSingleDataSource(): Promise<DataSource>;
22
19
  protected getOrCreateTenantConnection(tenant: ITenantDatabaseConfig): Promise<DataSource>;
@@ -8,7 +8,6 @@ export declare class EventManagerHelperService {
8
8
  private readonly utilsService;
9
9
  private readonly configService;
10
10
  private readonly dataSourceProvider;
11
- private readonly logger;
12
11
  private readonly eventEntityName;
13
12
  private dataSource;
14
13
  constructor(cacheManager: HybridCache, utilsService: UtilsService, configService: EventManagerConfigService, dataSourceProvider: EventManagerDataSourceProvider);
@@ -21,11 +21,11 @@ export declare class EventService extends RequestScopedApiService<CreateEventDto
21
21
  protected resolveEntity(): EntityTarget<EventBase>;
22
22
  protected getDataSourceProvider(): EventManagerDataSourceProvider;
23
23
  convertSingleDtoToEntity(dto: CreateEventDto | UpdateEventDto, user: ILoggedUserInfo | null): Promise<EventBase>;
24
- protected getFilterQuery(query: SelectQueryBuilder<EventBase>, filter: Record<string, any>, _user: ILoggedUserInfo | null): Promise<{
24
+ protected getFilterQuery(query: SelectQueryBuilder<EventBase>, filter: Record<string, unknown>, _user: ILoggedUserInfo | null): Promise<{
25
25
  query: SelectQueryBuilder<EventBase>;
26
26
  isRaw: boolean;
27
27
  }>;
28
- protected getExtraManipulateQuery(query: SelectQueryBuilder<EventBase>, filterDto: any, user: ILoggedUserInfo | null): Promise<{
28
+ protected getExtraManipulateQuery(query: SelectQueryBuilder<EventBase>, filterDto: Record<string, unknown>, user: ILoggedUserInfo | null): Promise<{
29
29
  query: SelectQueryBuilder<EventBase>;
30
30
  isRaw: boolean;
31
31
  }>;