#pragma once #include "db_gateway.hpp" #include #include #include #include namespace svapi { /// Metadata describing a managed collection. struct CollectionMeta { std::string name; std::string kind; uint32_t vectorDimension = 0; std::string embeddingModel; uint64_t createdAt = 0; static CollectionMeta fromJson(const nlohmann::json&); nlohmann::json toJson() const; }; /// Project-scoped registry: one document per managed collection stored in /// qualify(project, "vectorapi_collections"). class CollectionRegistry { public: explicit CollectionRegistry(DbGateway& db); /// Ensure the registry collection for `project` exists (idempotent). void ensure(const std::string& project); /// Add (or overwrite) a collection entry. Returns true on success. bool add(const std::string& project, const CollectionMeta& meta); /// Look up a single collection entry by name. std::optional get(const std::string& project, const std::string& name); /// List all collection entries for the project. std::vector list(const std::string& project); /// Remove a collection entry. Returns true if the document was present. bool remove(const std::string& project, const std::string& name); private: DbGateway& db_; /// Qualified registry collection name for the given project. std::string coll(const std::string& project) const { return qualify(project, "vectorapi_collections"); } }; } // namespace svapi