@mozaik-ai/core 4.2.0-beta.5 → 4.2.0-beta.7

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/dist/index.mjs CHANGED
@@ -77,20 +77,20 @@ var CreateParticipantUseCase = class {
77
77
  }
78
78
  };
79
79
 
80
- // src/application/use-cases/participant-joined.ts
81
- var ParticipantJoinedUseCase = class {
80
+ // src/application/use-cases/participant-join.ts
81
+ var ParticipantJoinUseCase = class {
82
82
  constructor(spaceRepository, eventPublisher) {
83
83
  this.spaceRepository = spaceRepository;
84
84
  this.eventPublisher = eventPublisher;
85
85
  }
86
- async execute(spaceId, participantId) {
86
+ async execute(spaceId, participant) {
87
87
  const space = await this.spaceRepository.findById(spaceId);
88
88
  if (!space) {
89
89
  throw new Error("Space not found");
90
90
  }
91
- const participant = space.getParticipant(participantId);
92
- if (!participant) {
93
- throw new Error("Participant not found");
91
+ const existingParticipant = space.getParticipant(participant.getId());
92
+ if (existingParticipant) {
93
+ throw new Error("Participant already joined");
94
94
  }
95
95
  const event = space.addParticipant(participant);
96
96
  if (event) {
@@ -129,8 +129,8 @@ var EventPublisher = class {
129
129
  }
130
130
  };
131
131
 
132
- // src/application/use-cases/participant-left.ts
133
- var ParticipantLefUseCase = class {
132
+ // src/application/use-cases/participant-leave.ts
133
+ var ParticipantLeaveUseCase = class {
134
134
  constructor(spaceRepository, eventPublisher) {
135
135
  this.spaceRepository = spaceRepository;
136
136
  this.eventPublisher = eventPublisher;
@@ -281,11 +281,11 @@ function defineRuntime() {
281
281
  const createSpace = async (name) => {
282
282
  return await createSpaceUseCase.execute(name);
283
283
  };
284
- const participantJoinedUseCase = new ParticipantJoinedUseCase(spaceRepository, eventPublisher);
285
- const join = async (spaceId, participantId) => {
286
- return await participantJoinedUseCase.execute(spaceId, participantId);
284
+ const participantJoinedUseCase = new ParticipantJoinUseCase(spaceRepository, eventPublisher);
285
+ const join = async (spaceId, participant) => {
286
+ return await participantJoinedUseCase.execute(spaceId, participant);
287
287
  };
288
- const participantLeftUseCase = new ParticipantLefUseCase(spaceRepository, eventPublisher);
288
+ const participantLeftUseCase = new ParticipantLeaveUseCase(spaceRepository, eventPublisher);
289
289
  const leave = async (spaceId, participantId) => {
290
290
  return await participantLeftUseCase.execute(spaceId, participantId);
291
291
  };