* Classify a vector request by operation and provider based on HTTP method and pathname.
( method: string, pathname: string, )
| 235 | * Classify a vector request by operation and provider based on HTTP method and pathname. |
| 236 | */ |
| 237 | function classifyVectorRequest( |
| 238 | method: string, |
| 239 | pathname: string, |
| 240 | ): { operation: string; provider: string } { |
| 241 | // Pinecone paths |
| 242 | if (pathname === "/query" && method === "POST") { |
| 243 | return { operation: "query", provider: "pinecone" }; |
| 244 | } |
| 245 | if (pathname === "/vectors/upsert" && method === "POST") { |
| 246 | return { operation: "upsert", provider: "pinecone" }; |
| 247 | } |
| 248 | if (pathname === "/vectors/delete" && method === "POST") { |
| 249 | return { operation: "delete", provider: "pinecone" }; |
| 250 | } |
| 251 | if (pathname === "/describe-index-stats" && method === "GET") { |
| 252 | return { operation: "describe", provider: "pinecone" }; |
| 253 | } |
| 254 | |
| 255 | // Qdrant paths |
| 256 | if (/^\/collections\/[^/]+\/points\/search$/.test(pathname) && method === "POST") { |
| 257 | return { operation: "query", provider: "qdrant" }; |
| 258 | } |
| 259 | if (/^\/collections\/[^/]+\/points$/.test(pathname) && method === "PUT") { |
| 260 | return { operation: "upsert", provider: "qdrant" }; |
| 261 | } |
| 262 | if (/^\/collections\/[^/]+\/points\/delete$/.test(pathname) && method === "POST") { |
| 263 | return { operation: "delete", provider: "qdrant" }; |
| 264 | } |
| 265 | |
| 266 | // ChromaDB paths |
| 267 | if (/^\/api\/v1\/collections\/[^/]+\/query$/.test(pathname) && method === "POST") { |
| 268 | return { operation: "query", provider: "chromadb" }; |
| 269 | } |
| 270 | if (/^\/api\/v1\/collections\/[^/]+\/add$/.test(pathname) && method === "POST") { |
| 271 | return { operation: "upsert", provider: "chromadb" }; |
| 272 | } |
| 273 | if (pathname === "/api/v1/collections" && method === "GET") { |
| 274 | return { operation: "list", provider: "chromadb" }; |
| 275 | } |
| 276 | if (/^\/api\/v1\/collections\/[^/]+$/.test(pathname) && method === "DELETE") { |
| 277 | return { operation: "delete", provider: "chromadb" }; |
| 278 | } |
| 279 | |
| 280 | return { operation: "unknown", provider: "unknown" }; |
| 281 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…