@mozaik-ai/core 4.2.0-beta.6 → 4.2.0-beta.8
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -77,20 +77,20 @@ var CreateParticipantUseCase = class {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
// src/application/use-cases/participant-
|
|
81
|
-
var
|
|
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,
|
|
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
|
|
92
|
-
if (
|
|
93
|
-
throw new Error("Participant
|
|
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-
|
|
133
|
-
var
|
|
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;
|
|
@@ -205,9 +205,6 @@ var Space = class _Space {
|
|
|
205
205
|
}
|
|
206
206
|
getParticipant(id) {
|
|
207
207
|
const participant = this.getParticipants().find((p) => p.getId() === id);
|
|
208
|
-
if (!participant) {
|
|
209
|
-
throw new Error(`Participant ${id} not found`);
|
|
210
|
-
}
|
|
211
208
|
return participant;
|
|
212
209
|
}
|
|
213
210
|
removeParticipant(participant) {
|
|
@@ -281,13 +278,13 @@ function defineRuntime() {
|
|
|
281
278
|
const createSpace = async (name) => {
|
|
282
279
|
return await createSpaceUseCase.execute(name);
|
|
283
280
|
};
|
|
284
|
-
const
|
|
285
|
-
const join = async (spaceId,
|
|
286
|
-
return await
|
|
281
|
+
const participantJoinUseCase = new ParticipantJoinUseCase(spaceRepository, eventPublisher);
|
|
282
|
+
const join = async (spaceId, participant) => {
|
|
283
|
+
return await participantJoinUseCase.execute(spaceId, participant);
|
|
287
284
|
};
|
|
288
|
-
const
|
|
285
|
+
const participantLeaveUseCase = new ParticipantLeaveUseCase(spaceRepository, eventPublisher);
|
|
289
286
|
const leave = async (spaceId, participantId) => {
|
|
290
|
-
return await
|
|
287
|
+
return await participantLeaveUseCase.execute(spaceId, participantId);
|
|
291
288
|
};
|
|
292
289
|
const sendMessageUseCase = new SendMessageUseCase(spaceRepository, eventPublisher);
|
|
293
290
|
const sendMessage = async (spaceId, participantId, message) => {
|