@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.d.mts
CHANGED
|
@@ -97,7 +97,7 @@ declare function defineRuntime<TSharedState extends SharedState>(): {
|
|
|
97
97
|
resolveRuntime: () => RuntimeService<TSharedState>;
|
|
98
98
|
createParticipant: (name: string, capabilities: readonly string[], handlers: SituationHandler[]) => Promise<Participant>;
|
|
99
99
|
createSpace: (name: string) => Promise<Space>;
|
|
100
|
-
join: (spaceId: string,
|
|
100
|
+
join: (spaceId: string, participant: Participant) => Promise<void>;
|
|
101
101
|
leave: (spaceId: string, participantId: string) => Promise<void>;
|
|
102
102
|
sendMessage: (spaceId: string, participantId: string, message: string) => Promise<void>;
|
|
103
103
|
sendMessageTool: FunctionTool;
|
package/dist/index.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ declare function defineRuntime<TSharedState extends SharedState>(): {
|
|
|
97
97
|
resolveRuntime: () => RuntimeService<TSharedState>;
|
|
98
98
|
createParticipant: (name: string, capabilities: readonly string[], handlers: SituationHandler[]) => Promise<Participant>;
|
|
99
99
|
createSpace: (name: string) => Promise<Space>;
|
|
100
|
-
join: (spaceId: string,
|
|
100
|
+
join: (spaceId: string, participant: Participant) => Promise<void>;
|
|
101
101
|
leave: (spaceId: string, participantId: string) => Promise<void>;
|
|
102
102
|
sendMessage: (spaceId: string, participantId: string, message: string) => Promise<void>;
|
|
103
103
|
sendMessageTool: FunctionTool;
|
package/dist/index.js
CHANGED
|
@@ -118,20 +118,20 @@ var CreateParticipantUseCase = class {
|
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
// src/application/use-cases/participant-
|
|
122
|
-
var
|
|
121
|
+
// src/application/use-cases/participant-join.ts
|
|
122
|
+
var ParticipantJoinUseCase = class {
|
|
123
123
|
constructor(spaceRepository, eventPublisher) {
|
|
124
124
|
this.spaceRepository = spaceRepository;
|
|
125
125
|
this.eventPublisher = eventPublisher;
|
|
126
126
|
}
|
|
127
|
-
async execute(spaceId,
|
|
127
|
+
async execute(spaceId, participant) {
|
|
128
128
|
const space = await this.spaceRepository.findById(spaceId);
|
|
129
129
|
if (!space) {
|
|
130
130
|
throw new Error("Space not found");
|
|
131
131
|
}
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
throw new Error("Participant
|
|
132
|
+
const existingParticipant = space.getParticipant(participant.getId());
|
|
133
|
+
if (existingParticipant) {
|
|
134
|
+
throw new Error("Participant already joined");
|
|
135
135
|
}
|
|
136
136
|
const event = space.addParticipant(participant);
|
|
137
137
|
if (event) {
|
|
@@ -170,8 +170,8 @@ var EventPublisher = class {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
-
// src/application/use-cases/participant-
|
|
174
|
-
var
|
|
173
|
+
// src/application/use-cases/participant-leave.ts
|
|
174
|
+
var ParticipantLeaveUseCase = class {
|
|
175
175
|
constructor(spaceRepository, eventPublisher) {
|
|
176
176
|
this.spaceRepository = spaceRepository;
|
|
177
177
|
this.eventPublisher = eventPublisher;
|
|
@@ -246,9 +246,6 @@ var Space = class _Space {
|
|
|
246
246
|
}
|
|
247
247
|
getParticipant(id) {
|
|
248
248
|
const participant = this.getParticipants().find((p) => p.getId() === id);
|
|
249
|
-
if (!participant) {
|
|
250
|
-
throw new Error(`Participant ${id} not found`);
|
|
251
|
-
}
|
|
252
249
|
return participant;
|
|
253
250
|
}
|
|
254
251
|
removeParticipant(participant) {
|
|
@@ -322,13 +319,13 @@ function defineRuntime() {
|
|
|
322
319
|
const createSpace = async (name) => {
|
|
323
320
|
return await createSpaceUseCase.execute(name);
|
|
324
321
|
};
|
|
325
|
-
const
|
|
326
|
-
const join = async (spaceId,
|
|
327
|
-
return await
|
|
322
|
+
const participantJoinUseCase = new ParticipantJoinUseCase(spaceRepository, eventPublisher);
|
|
323
|
+
const join = async (spaceId, participant) => {
|
|
324
|
+
return await participantJoinUseCase.execute(spaceId, participant);
|
|
328
325
|
};
|
|
329
|
-
const
|
|
326
|
+
const participantLeaveUseCase = new ParticipantLeaveUseCase(spaceRepository, eventPublisher);
|
|
330
327
|
const leave = async (spaceId, participantId) => {
|
|
331
|
-
return await
|
|
328
|
+
return await participantLeaveUseCase.execute(spaceId, participantId);
|
|
332
329
|
};
|
|
333
330
|
const sendMessageUseCase = new SendMessageUseCase(spaceRepository, eventPublisher);
|
|
334
331
|
const sendMessage = async (spaceId, participantId, message) => {
|