fix(ts): entity store isolation, backward compat, pgvector + redis init fixes (#4841)

This commit is contained in:
Saket Aryan
2026-04-15 21:01:01 +05:30
committed by GitHub
parent e6d6276bb9
commit 86fe275f53
9 changed files with 71 additions and 36 deletions
@@ -85,14 +85,16 @@ describe("MemoryVectorStore - search", () => {
expect(results).toHaveLength(1);
});
test("filters by userId", async () => {
const results = await store.search(vec([1, 0, 0, 0]), 10, { userId: "u2" });
expect(results.every((r) => r.payload.userId === "u2")).toBe(true);
test("filters by user_id", async () => {
const results = await store.search(vec([1, 0, 0, 0]), 10, {
user_id: "u2",
});
expect(results.every((r) => r.payload.user_id === "u2")).toBe(true);
});
test("returns empty when filter matches nothing", async () => {
const results = await store.search(vec([1, 0, 0, 0]), 10, {
userId: "nobody",
user_id: "nobody",
});
expect(results).toHaveLength(0);
});
@@ -168,10 +170,10 @@ describe("MemoryVectorStore - list", () => {
expect(results).toHaveLength(3);
});
test("filters by userId", async () => {
const [results, count] = await store.list({ userId: "u1" });
test("filters by user_id", async () => {
const [results, count] = await store.list({ user_id: "u1" });
expect(count).toBe(2);
expect(results.every((r) => r.payload.userId === "u1")).toBe(true);
expect(results.every((r) => r.payload.user_id === "u1")).toBe(true);
});
test("respects limit", async () => {
@@ -95,19 +95,19 @@ describe("MemoryVectorStore – full backward compat", () => {
expect(results.length).toBe(2);
expect(results[0].id).toBe("id-1");
// Search with filters
const filtered = await store.search(vec1, 2, { userId: "u1" });
// Search with filters (camelCase in payload is normalized to snake_case)
const filtered = await store.search(vec1, 2, { user_id: "u1" });
expect(filtered.length).toBe(2);
// Update
const vec3 = new Array(1536).fill(0);
vec3[2] = 1.0;
await store.update("id-1", vec3, { data: "updated", userId: "u1" });
await store.update("id-1", vec3, { data: "updated", user_id: "u1" });
const updated = await store.get("id-1");
expect(updated!.payload.data).toBe("updated");
// List
const [listed, count] = await store.list({ userId: "u1" });
const [listed, count] = await store.list({ user_id: "u1" });
expect(count).toBe(2);
// List with limit