@flusys/nestjs-event-manager 4.1.0 → 5.0.0

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.
Files changed (52) hide show
  1. package/README.md +126 -337
  2. package/adapters/event-manager.adapter.d.ts +0 -2
  3. package/cjs/adapters/event-manager.adapter.js +1 -7
  4. package/cjs/config/message-keys.js +1 -31
  5. package/cjs/controllers/event.controller.js +10 -60
  6. package/cjs/controllers/index.js +0 -1
  7. package/cjs/docs/event-manager-swagger.config.js +19 -29
  8. package/cjs/docs/index.js +0 -3
  9. package/cjs/dtos/calendar-query.dto.js +46 -20
  10. package/cjs/dtos/event-participant.dto.js +0 -45
  11. package/cjs/dtos/event.dto.js +97 -45
  12. package/cjs/entities/event-participant.entity.js +1 -8
  13. package/cjs/entities/event.entity.js +38 -26
  14. package/cjs/modules/event-manager.module.js +2 -4
  15. package/cjs/services/event-manager-helper.service.js +15 -83
  16. package/cjs/services/event.service.js +143 -122
  17. package/cjs/services/index.js +0 -1
  18. package/config/message-keys.d.ts +0 -56
  19. package/controllers/event.controller.d.ts +2 -5
  20. package/controllers/index.d.ts +0 -1
  21. package/docs/index.d.ts +1 -1
  22. package/dtos/calendar-query.dto.d.ts +8 -5
  23. package/dtos/event-participant.dto.d.ts +0 -6
  24. package/dtos/event.dto.d.ts +14 -10
  25. package/entities/event-participant.entity.d.ts +0 -1
  26. package/entities/event.entity.d.ts +6 -5
  27. package/fesm/adapters/event-manager.adapter.js +1 -7
  28. package/fesm/config/message-keys.js +1 -29
  29. package/fesm/controllers/event.controller.js +11 -61
  30. package/fesm/controllers/index.js +0 -1
  31. package/fesm/docs/event-manager-swagger.config.js +19 -29
  32. package/fesm/docs/index.js +1 -1
  33. package/fesm/dtos/calendar-query.dto.js +47 -21
  34. package/fesm/dtos/event-participant.dto.js +0 -42
  35. package/fesm/dtos/event.dto.js +98 -46
  36. package/fesm/entities/event-participant.entity.js +1 -8
  37. package/fesm/entities/event.entity.js +38 -26
  38. package/fesm/modules/event-manager.module.js +4 -6
  39. package/fesm/services/event-manager-helper.service.js +17 -85
  40. package/fesm/services/event.service.js +144 -123
  41. package/fesm/services/index.js +0 -1
  42. package/interfaces/event.interface.d.ts +6 -6
  43. package/package.json +3 -3
  44. package/services/event-manager-helper.service.d.ts +1 -3
  45. package/services/event.service.d.ts +8 -8
  46. package/services/index.d.ts +0 -1
  47. package/cjs/controllers/event-participant.controller.js +0 -287
  48. package/cjs/services/event-participant.service.js +0 -198
  49. package/controllers/event-participant.controller.d.ts +0 -35
  50. package/fesm/controllers/event-participant.controller.js +0 -277
  51. package/fesm/services/event-participant.service.js +0 -188
  52. package/services/event-participant.service.d.ts +0 -27
@@ -1,277 +0,0 @@
1
- function _define_property(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
- function _ts_decorate(decorators, target, key, desc) {
15
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
- return c > 3 && r && Object.defineProperty(target, key, r), r;
19
- }
20
- function _ts_metadata(k, v) {
21
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
- }
23
- function _ts_param(paramIndex, decorator) {
24
- return function(target, key) {
25
- decorator(target, key, paramIndex);
26
- };
27
- }
28
- import { Body, Controller, HttpCode, HttpStatus, Inject, Post, UseGuards } from '@nestjs/common';
29
- import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
30
- import { plainToInstance } from 'class-transformer';
31
- import { createApiController } from '@flusys/nestjs-shared/classes';
32
- import { EVENT_PARTICIPANT_MESSAGES } from '../config';
33
- import { CurrentUser, RequirePermission } from '@flusys/nestjs-shared/decorators';
34
- import { ListResponseDto, MessageResponseDto, SingleResponseDto } from '@flusys/nestjs-shared/dtos';
35
- import { JwtAuthGuard } from '@flusys/nestjs-shared/guards';
36
- import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
37
- import { CreateEventParticipantDto, EventParticipantResponseDto, UpdateParticipantStatusDto, UpdateEventParticipantDto } from '../dtos';
38
- import { EVENT_PARTICIPANT_PERMISSIONS } from '../docs';
39
- import { EventParticipantService } from '../services/event-participant.service';
40
- export class EventParticipantController extends createApiController(CreateEventParticipantDto, UpdateEventParticipantDto, EventParticipantResponseDto, {
41
- entityName: 'eventParticipant',
42
- security: {
43
- insert: {
44
- level: 'permission',
45
- permissions: [
46
- EVENT_PARTICIPANT_PERMISSIONS.CREATE
47
- ]
48
- },
49
- insertMany: {
50
- level: 'permission',
51
- permissions: [
52
- EVENT_PARTICIPANT_PERMISSIONS.CREATE
53
- ]
54
- },
55
- getById: {
56
- level: 'permission',
57
- permissions: [
58
- EVENT_PARTICIPANT_PERMISSIONS.READ
59
- ]
60
- },
61
- getAll: {
62
- level: 'permission',
63
- permissions: [
64
- EVENT_PARTICIPANT_PERMISSIONS.READ
65
- ]
66
- },
67
- update: {
68
- level: 'permission',
69
- permissions: [
70
- EVENT_PARTICIPANT_PERMISSIONS.UPDATE
71
- ]
72
- },
73
- updateMany: {
74
- level: 'permission',
75
- permissions: [
76
- EVENT_PARTICIPANT_PERMISSIONS.UPDATE
77
- ]
78
- },
79
- delete: {
80
- level: 'permission',
81
- permissions: [
82
- EVENT_PARTICIPANT_PERMISSIONS.DELETE
83
- ]
84
- }
85
- }
86
- }) {
87
- async updateStatus(dto, user) {
88
- const participant = await this.participantService.updateStatus(dto, user);
89
- return {
90
- success: true,
91
- message: 'Participant status updated successfully',
92
- messageKey: EVENT_PARTICIPANT_MESSAGES.STATUS_UPDATE_SUCCESS,
93
- data: plainToInstance(EventParticipantResponseDto, participant)
94
- };
95
- }
96
- async getByEvent(body, user) {
97
- const participants = await this.participantService.getParticipantsByEvent(body.eventId, user);
98
- const data = plainToInstance(EventParticipantResponseDto, participants);
99
- return {
100
- success: true,
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
- }
110
- };
111
- }
112
- async getByUser(body, user) {
113
- const participants = await this.participantService.getParticipantsByUser(body.userId, user);
114
- const data = plainToInstance(EventParticipantResponseDto, participants);
115
- return {
116
- success: true,
117
- message: 'Participations retrieved successfully',
118
- messageKey: EVENT_PARTICIPANT_MESSAGES.GET_ALL_SUCCESS,
119
- data,
120
- meta: {
121
- total: data.length,
122
- page: 0,
123
- pageSize: data.length,
124
- count: data.length
125
- }
126
- };
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
- }
136
- constructor(participantService){
137
- super(participantService), _define_property(this, "participantService", void 0), this.participantService = participantService;
138
- }
139
- }
140
- _ts_decorate([
141
- Post('update-status'),
142
- UseGuards(JwtAuthGuard),
143
- ApiBearerAuth(),
144
- HttpCode(HttpStatus.OK),
145
- RequirePermission(EVENT_PARTICIPANT_PERMISSIONS.UPDATE),
146
- ApiOperation({
147
- summary: 'Update participant status (accept/decline/tentative)'
148
- }),
149
- ApiBody({
150
- type: UpdateParticipantStatusDto
151
- }),
152
- ApiResponse({
153
- status: 200,
154
- description: 'Status updated successfully',
155
- type: SingleResponseDto
156
- }),
157
- _ts_param(0, Body()),
158
- _ts_param(1, CurrentUser()),
159
- _ts_metadata("design:type", Function),
160
- _ts_metadata("design:paramtypes", [
161
- typeof UpdateParticipantStatusDto === "undefined" ? Object : UpdateParticipantStatusDto,
162
- typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
163
- ]),
164
- _ts_metadata("design:returntype", Promise)
165
- ], EventParticipantController.prototype, "updateStatus", null);
166
- _ts_decorate([
167
- Post('get-by-event'),
168
- UseGuards(JwtAuthGuard),
169
- ApiBearerAuth(),
170
- HttpCode(HttpStatus.OK),
171
- RequirePermission(EVENT_PARTICIPANT_PERMISSIONS.READ),
172
- ApiOperation({
173
- summary: 'Get all participants for an event'
174
- }),
175
- ApiBody({
176
- schema: {
177
- properties: {
178
- eventId: {
179
- type: 'string',
180
- format: 'uuid'
181
- }
182
- }
183
- }
184
- }),
185
- ApiResponse({
186
- status: 200,
187
- description: 'Participants retrieved successfully',
188
- type: ListResponseDto
189
- }),
190
- _ts_param(0, Body()),
191
- _ts_param(1, CurrentUser()),
192
- _ts_metadata("design:type", Function),
193
- _ts_metadata("design:paramtypes", [
194
- Object,
195
- typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
196
- ]),
197
- _ts_metadata("design:returntype", Promise)
198
- ], EventParticipantController.prototype, "getByEvent", null);
199
- _ts_decorate([
200
- Post('get-by-user'),
201
- UseGuards(JwtAuthGuard),
202
- ApiBearerAuth(),
203
- HttpCode(HttpStatus.OK),
204
- RequirePermission(EVENT_PARTICIPANT_PERMISSIONS.READ),
205
- ApiOperation({
206
- summary: 'Get all event participations for a user'
207
- }),
208
- ApiBody({
209
- schema: {
210
- properties: {
211
- userId: {
212
- type: 'string',
213
- format: 'uuid'
214
- }
215
- }
216
- }
217
- }),
218
- ApiResponse({
219
- status: 200,
220
- description: 'Participations retrieved successfully',
221
- type: ListResponseDto
222
- }),
223
- _ts_param(0, Body()),
224
- _ts_param(1, CurrentUser()),
225
- _ts_metadata("design:type", Function),
226
- _ts_metadata("design:paramtypes", [
227
- Object,
228
- typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
229
- ]),
230
- _ts_metadata("design:returntype", Promise)
231
- ], EventParticipantController.prototype, "getByUser", null);
232
- _ts_decorate([
233
- Post('remove'),
234
- UseGuards(JwtAuthGuard),
235
- ApiBearerAuth(),
236
- HttpCode(HttpStatus.OK),
237
- RequirePermission(EVENT_PARTICIPANT_PERMISSIONS.DELETE),
238
- ApiOperation({
239
- summary: 'Remove a participant from an event'
240
- }),
241
- ApiBody({
242
- schema: {
243
- properties: {
244
- eventId: {
245
- type: 'string',
246
- format: 'uuid'
247
- },
248
- userId: {
249
- type: 'string',
250
- format: 'uuid'
251
- }
252
- }
253
- }
254
- }),
255
- ApiResponse({
256
- status: 200,
257
- description: 'Participant removed successfully',
258
- type: MessageResponseDto
259
- }),
260
- _ts_param(0, Body()),
261
- _ts_param(1, CurrentUser()),
262
- _ts_metadata("design:type", Function),
263
- _ts_metadata("design:paramtypes", [
264
- Object,
265
- typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
266
- ]),
267
- _ts_metadata("design:returntype", Promise)
268
- ], EventParticipantController.prototype, "removeParticipant", null);
269
- EventParticipantController = _ts_decorate([
270
- ApiTags('Event Participants'),
271
- Controller('event-manager/participant'),
272
- _ts_param(0, Inject(EventParticipantService)),
273
- _ts_metadata("design:type", Function),
274
- _ts_metadata("design:paramtypes", [
275
- typeof EventParticipantService === "undefined" ? Object : EventParticipantService
276
- ])
277
- ], EventParticipantController);
@@ -1,188 +0,0 @@
1
- function _define_property(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
- function _ts_decorate(decorators, target, key, desc) {
15
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
- return c > 3 && r && Object.defineProperty(target, key, r), r;
19
- }
20
- function _ts_metadata(k, v) {
21
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
- }
23
- function _ts_param(paramIndex, decorator) {
24
- return function(target, key) {
25
- decorator(target, key, paramIndex);
26
- };
27
- }
28
- import { HybridCache, RequestScopedApiService } from '@flusys/nestjs-shared/classes';
29
- import { LogAction } from '@flusys/nestjs-shared/decorators';
30
- import { ParticipantStatus } from '@flusys/nestjs-shared/enums';
31
- import { UtilsService } from '@flusys/nestjs-shared/modules';
32
- import { EVENT_PARTICIPANT_MESSAGES } from '../config';
33
- import { Inject, Injectable, NotFoundException, Scope } from '@nestjs/common';
34
- import { EventManagerConfigService } from './event-manager-config.service';
35
- import { UpdateParticipantStatusDto } from '../dtos';
36
- import { EventParticipant } from '../entities';
37
- import { EventManagerDataSourceProvider } from './event-manager-datasource.provider';
38
- export class EventParticipantService extends RequestScopedApiService {
39
- resolveEntity() {
40
- // EventParticipant doesn't need company variant - company context is inherited through Event
41
- return EventParticipant;
42
- }
43
- getDataSourceProvider() {
44
- return this.dataSourceProvider;
45
- }
46
- // Override Methods
47
- async convertSingleDtoToEntity(dto, _user) {
48
- let entity = {};
49
- if ('id' in dto && dto.id && typeof dto.id === 'string') {
50
- const existing = await this.repository.findOne({
51
- where: {
52
- id: dto.id
53
- }
54
- });
55
- if (!existing) throw new NotFoundException({
56
- message: 'Event participant not found',
57
- messageKey: EVENT_PARTICIPANT_MESSAGES.NOT_FOUND
58
- });
59
- entity = existing;
60
- }
61
- // EventParticipant doesn't have companyId - company context comes from Event
62
- return {
63
- ...entity,
64
- eventId: dto.eventId ?? entity.eventId,
65
- userId: dto.userId ?? entity.userId,
66
- status: dto.status ?? entity.status ?? ParticipantStatus.PENDING,
67
- isOrganizer: dto.isOrganizer ?? entity.isOrganizer ?? false,
68
- metadata: dto.metadata ?? entity.metadata
69
- };
70
- }
71
- async getFilterQuery(query, filter, _user) {
72
- for (const [key, value] of Object.entries(filter)){
73
- if (key === 'eventId') {
74
- query.andWhere(`${this.entityName}.eventId = :eventId`, {
75
- eventId: value
76
- });
77
- } else if (key === 'userId') {
78
- query.andWhere(`${this.entityName}.userId = :userId`, {
79
- userId: value
80
- });
81
- } else if (key === 'status') {
82
- query.andWhere(`${this.entityName}.status = :status`, {
83
- status: value
84
- });
85
- } else if (key === 'isOrganizer' && typeof value === 'boolean') {
86
- query.andWhere(`${this.entityName}.isOrganizer = :isOrganizer`, {
87
- isOrganizer: value
88
- });
89
- } else {
90
- query.andWhere(`${this.entityName}.${key} = :value`, {
91
- value
92
- });
93
- }
94
- }
95
- return {
96
- query,
97
- isRaw: false
98
- };
99
- }
100
- // Public Methods
101
- // Note: EventParticipant doesn't have companyId - company filtering happens at Event level
102
- async updateStatus(dto, _user) {
103
- await this.ensureRepositoryInitialized();
104
- const participant = await this.repository.findOne({
105
- where: {
106
- id: dto.id
107
- }
108
- });
109
- if (!participant) {
110
- throw new NotFoundException({
111
- message: 'Event participant not found',
112
- messageKey: EVENT_PARTICIPANT_MESSAGES.NOT_FOUND
113
- });
114
- }
115
- participant.status = dto.status;
116
- return await this.repository.save(participant);
117
- }
118
- async getParticipantsByEvent(eventId, _user) {
119
- await this.ensureRepositoryInitialized();
120
- // Company filtering happens at Event level, not participant level
121
- return await this.repository.createQueryBuilder('event_participant').where('event_participant.eventId = :eventId', {
122
- eventId
123
- }).andWhere('event_participant.deletedAt IS NULL').getMany();
124
- }
125
- async getParticipantsByUser(userId, _user) {
126
- await this.ensureRepositoryInitialized();
127
- // Company filtering happens at Event level, not participant level
128
- return await this.repository.createQueryBuilder('event_participant').where('event_participant.userId = :userId', {
129
- userId
130
- }).andWhere('event_participant.deletedAt IS NULL').getMany();
131
- }
132
- async removeParticipant(eventId, userId, _user) {
133
- await this.ensureRepositoryInitialized();
134
- const participant = await this.repository.findOne({
135
- where: {
136
- eventId,
137
- userId
138
- }
139
- });
140
- if (participant) {
141
- await this.repository.softRemove(participant);
142
- }
143
- }
144
- constructor(cacheManager, utilsService, eventConfig, 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;
146
- }
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);
173
- EventParticipantService = _ts_decorate([
174
- Injectable({
175
- scope: Scope.REQUEST
176
- }),
177
- _ts_param(0, Inject('CACHE_INSTANCE')),
178
- _ts_param(1, Inject(UtilsService)),
179
- _ts_param(2, Inject(EventManagerConfigService)),
180
- _ts_param(3, Inject(EventManagerDataSourceProvider)),
181
- _ts_metadata("design:type", Function),
182
- _ts_metadata("design:paramtypes", [
183
- typeof HybridCache === "undefined" ? Object : HybridCache,
184
- typeof UtilsService === "undefined" ? Object : UtilsService,
185
- typeof EventManagerConfigService === "undefined" ? Object : EventManagerConfigService,
186
- typeof EventManagerDataSourceProvider === "undefined" ? Object : EventManagerDataSourceProvider
187
- ])
188
- ], EventParticipantService);
@@ -1,27 +0,0 @@
1
- import { HybridCache, RequestScopedApiService } from '@flusys/nestjs-shared/classes';
2
- import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
3
- import { UtilsService } from '@flusys/nestjs-shared/modules';
4
- import { EntityTarget, Repository, SelectQueryBuilder } from 'typeorm';
5
- import { EventManagerConfigService } from './event-manager-config.service';
6
- import { CreateEventParticipantDto, UpdateEventParticipantDto, UpdateParticipantStatusDto } from '../dtos';
7
- import { EventParticipantBase } from '../entities';
8
- import { IEventParticipant } from '../interfaces';
9
- import { EventManagerDataSourceProvider } from './event-manager-datasource.provider';
10
- export declare class EventParticipantService extends RequestScopedApiService<CreateEventParticipantDto, UpdateEventParticipantDto, IEventParticipant, EventParticipantBase, Repository<EventParticipantBase>> {
11
- protected cacheManager: HybridCache;
12
- protected utilsService: UtilsService;
13
- private readonly eventConfig;
14
- private readonly dataSourceProvider;
15
- constructor(cacheManager: HybridCache, utilsService: UtilsService, eventConfig: EventManagerConfigService, dataSourceProvider: EventManagerDataSourceProvider);
16
- protected resolveEntity(): EntityTarget<EventParticipantBase>;
17
- protected getDataSourceProvider(): EventManagerDataSourceProvider;
18
- convertSingleDtoToEntity(dto: CreateEventParticipantDto | UpdateEventParticipantDto, _user: ILoggedUserInfo | null): Promise<EventParticipantBase>;
19
- protected getFilterQuery(query: SelectQueryBuilder<EventParticipantBase>, filter: Record<string, any>, _user: ILoggedUserInfo | null): Promise<{
20
- query: SelectQueryBuilder<EventParticipantBase>;
21
- isRaw: boolean;
22
- }>;
23
- updateStatus(dto: UpdateParticipantStatusDto, _user: ILoggedUserInfo | null): Promise<EventParticipantBase>;
24
- getParticipantsByEvent(eventId: string, _user: ILoggedUserInfo | null): Promise<EventParticipantBase[]>;
25
- getParticipantsByUser(userId: string, _user: ILoggedUserInfo | null): Promise<EventParticipantBase[]>;
26
- removeParticipant(eventId: string, userId: string, _user: ILoggedUserInfo | null): Promise<void>;
27
- }