1414from loguru import logger
1515
1616from basic_memory .deps import (
17- EntityServiceDep ,
18- SearchServiceDep ,
19- LinkResolverDep ,
20- ProjectConfigDep ,
17+ EntityServiceV2Dep ,
18+ SearchServiceV2Dep ,
19+ LinkResolverV2Dep ,
20+ ProjectConfigV2Dep ,
2121 AppConfigDep ,
22- SyncServiceDep ,
23- EntityRepositoryDep ,
22+ SyncServiceV2Dep ,
23+ EntityRepositoryV2Dep ,
24+ ProjectIdPathDep ,
2425)
2526from basic_memory .schemas import EntityResponse , DeleteEntitiesResponse
2627from basic_memory .schemas .base import Entity
@@ -58,8 +59,9 @@ async def resolve_relations_background(sync_service, entity_id: int, entity_perm
5859
5960@router .post ("/resolve" , response_model = EntityResolveResponse )
6061async def resolve_identifier (
62+ project_id : ProjectIdPathDep ,
6163 data : EntityResolveRequest ,
62- link_resolver : LinkResolverDep ,
64+ link_resolver : LinkResolverV2Dep ,
6365) -> EntityResolveResponse :
6466 """Resolve a string identifier (permalink, title, or path) to an entity ID.
6567
@@ -128,8 +130,9 @@ async def resolve_identifier(
128130
129131@router .get ("/entities/{entity_id}" , response_model = EntityResponseV2 )
130132async def get_entity_by_id (
133+ project_id : ProjectIdPathDep ,
131134 entity_id : int ,
132- entity_repository : EntityRepositoryDep ,
135+ entity_repository : EntityRepositoryV2Dep ,
133136) -> EntityResponseV2 :
134137 """Get an entity by its numeric ID.
135138
@@ -162,10 +165,11 @@ async def get_entity_by_id(
162165
163166@router .post ("/entities" , response_model = EntityResponse )
164167async def create_entity (
168+ project_id : ProjectIdPathDep ,
165169 data : Entity ,
166170 background_tasks : BackgroundTasks ,
167- entity_service : EntityServiceDep ,
168- search_service : SearchServiceDep ,
171+ entity_service : EntityServiceV2Dep ,
172+ search_service : SearchServiceV2Dep ,
169173) -> EntityResponse :
170174 """Create a new entity.
171175
@@ -199,14 +203,15 @@ async def create_entity(
199203
200204@router .put ("/entities/{entity_id}" , response_model = EntityResponse )
201205async def update_entity_by_id (
206+ project_id : ProjectIdPathDep ,
202207 entity_id : int ,
203208 data : Entity ,
204209 response : Response ,
205210 background_tasks : BackgroundTasks ,
206- entity_service : EntityServiceDep ,
207- search_service : SearchServiceDep ,
208- sync_service : SyncServiceDep ,
209- entity_repository : EntityRepositoryDep ,
211+ entity_service : EntityServiceV2Dep ,
212+ search_service : SearchServiceV2Dep ,
213+ sync_service : SyncServiceV2Dep ,
214+ entity_repository : EntityRepositoryV2Dep ,
210215) -> EntityResponse :
211216 """Update an entity by ID.
212217
@@ -248,12 +253,13 @@ async def update_entity_by_id(
248253
249254@router .patch ("/entities/{entity_id}" , response_model = EntityResponse )
250255async def edit_entity_by_id (
256+ project_id : ProjectIdPathDep ,
251257 entity_id : int ,
252258 data : EditEntityRequest ,
253259 background_tasks : BackgroundTasks ,
254- entity_service : EntityServiceDep ,
255- search_service : SearchServiceDep ,
256- entity_repository : EntityRepositoryDep ,
260+ entity_service : EntityServiceV2Dep ,
261+ search_service : SearchServiceV2Dep ,
262+ entity_repository : EntityRepositoryV2Dep ,
257263) -> EntityResponse :
258264 """Edit an existing entity by ID using operations like append, prepend, etc.
259265
@@ -267,7 +273,9 @@ async def edit_entity_by_id(
267273 Raises:
268274 HTTPException: 404 if entity not found, 400 if edit fails
269275 """
270- logger .info (f"API v2 request: edit_entity_by_id entity_id={ entity_id } , operation='{ data .operation } '" )
276+ logger .info (
277+ f"API v2 request: edit_entity_by_id entity_id={ entity_id } , operation='{ data .operation } '"
278+ )
271279
272280 # Verify entity exists
273281 entity = await entity_repository .get_by_id (entity_id )
@@ -307,10 +315,11 @@ async def edit_entity_by_id(
307315
308316@router .delete ("/entities/{entity_id}" , response_model = DeleteEntitiesResponse )
309317async def delete_entity_by_id (
318+ project_id : ProjectIdPathDep ,
310319 entity_id : int ,
311320 background_tasks : BackgroundTasks ,
312- entity_service : EntityServiceDep ,
313- entity_repository : EntityRepositoryDep ,
321+ entity_service : EntityServiceV2Dep ,
322+ entity_repository : EntityRepositoryV2Dep ,
314323 search_service = Depends (lambda : None ), # Optional for now
315324) -> DeleteEntitiesResponse :
316325 """Delete an entity by ID.
@@ -347,12 +356,13 @@ async def delete_entity_by_id(
347356
348357@router .post ("/move" , response_model = EntityResponse )
349358async def move_entity (
359+ project_id : ProjectIdPathDep ,
350360 data : MoveEntityRequest ,
351361 background_tasks : BackgroundTasks ,
352- entity_service : EntityServiceDep ,
353- project_config : ProjectConfigDep ,
362+ entity_service : EntityServiceV2Dep ,
363+ project_config : ProjectConfigV2Dep ,
354364 app_config : AppConfigDep ,
355- search_service : SearchServiceDep ,
365+ search_service : SearchServiceV2Dep ,
356366) -> EntityResponse :
357367 """Move an entity to a new file location.
358368
0 commit comments