A CRUD layer with single-doc operations that MCP tools will call.
Firestore env works, datamodel entities exist, serialization works.
createdAt/updatedAt on createsupdatedAt on updatescreateDoc throws if document already existsupdateDoc throws if document missing (without upsert)deleteDoc returns { id, deleted: false } if doc missingsrc/firestore/crud.tsbuildEntityCollectionPath(entity, pathParams)buildEntityDocRef({ firestore, entity, pathParams, id })listDocs({ firestore, entity, pathParams, limit? }) → array of docsgetDoc({ firestore, entity, pathParams, id }) → doc or nullcreateDoc({ firestore, entity, pathParams, id?, data })id: ref.id and { [docIdParamName]: ref.id } if differentupdateDoc({ firestore, entity, pathParams, id, data })deleteDoc({ firestore, entity, pathParams, id }) → { id, deleted }upsertDoc({ firestore, entity, pathParams, id, data, merge? })createdAt on new docs, updatedAt alwaysfromJsonSafeToFirestore before writingtoJsonSafe after readingmerge: true for upsert
Reacties