(observations: { entityName: string; contents: string[] }[])
| 137 | } |
| 138 | |
| 139 | async addObservations(observations: { entityName: string; contents: string[] }[]): Promise<{ entityName: string; addedObservations: string[] }[]> { |
| 140 | const graph = await this.loadGraph(); |
| 141 | const results = observations.map(o => { |
| 142 | const entity = graph.entities.find(e => e.name === o.entityName); |
| 143 | if (!entity) { |
| 144 | throw new Error(`Entity with name ${o.entityName} not found`); |
| 145 | } |
| 146 | const newObservations = o.contents.filter(content => !entity.observations.includes(content)); |
| 147 | entity.observations.push(...newObservations); |
| 148 | return { entityName: o.entityName, addedObservations: newObservations }; |
| 149 | }); |
| 150 | await this.saveGraph(graph); |
| 151 | return results; |
| 152 | } |
| 153 | |
| 154 | async deleteEntities(entityNames: string[]): Promise<void> { |
| 155 | const graph = await this.loadGraph(); |
no test coverage detected