|
|
@ -121,6 +121,17 @@ const factTriggers: FactTriggerEntity = {
|
|
|
|
(factTrigger) => factTrigger.id === id
|
|
|
|
(factTrigger) => factTrigger.id === id
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
findByConversationId: async (conversationId) => {
|
|
|
|
|
|
|
|
const messageIds = await dbClient.data.messages
|
|
|
|
|
|
|
|
.filter((m) => m.conversationId === conversationId)
|
|
|
|
|
|
|
|
.map((m) => m.id);
|
|
|
|
|
|
|
|
const factIds = dbClient.data.facts
|
|
|
|
|
|
|
|
.filter((fact) => messageIds.includes(fact.sourceMessageId))
|
|
|
|
|
|
|
|
.map((fact) => fact.id);
|
|
|
|
|
|
|
|
return dbClient.data.factTriggers.filter((factTrigger) =>
|
|
|
|
|
|
|
|
factIds.includes(factTrigger.sourceFactId)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
update: async (id, data: Partial<FactTrigger>) => {
|
|
|
|
update: async (id, data: Partial<FactTrigger>) => {
|
|
|
|
const factTriggerIndex = dbClient.data.factTriggers.findIndex(
|
|
|
|
const factTriggerIndex = dbClient.data.factTriggers.findIndex(
|
|
|
|
(factTrigger) => factTrigger.id === id
|
|
|
|
(factTrigger) => factTrigger.id === id
|
|
|
|