fix(ts-sdk): unwrap v1.1 search response in client, fix TS2339 type errors
search() now unwraps { results: [...] } -> [...] internally (same
pattern getAll() already uses), so callers always get Array<Memory>.
Removes redundant unwrap logic from integration test helpers and
search.test.ts that caused TS2339 'Property results does not exist
on type never' — the false branch of Array.isArray() was unreachable
since search() is typed as returning Array<Memory>.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
7f19c499ca
commit
e51df348ce
@@ -108,30 +108,22 @@ describeIntegration("MemoryClient Integration — Search & History", () => {
|
||||
// ─── Edge cases ─────────────────────────────────────────
|
||||
describe("edge cases", () => {
|
||||
test("search for non-existent user returns empty results", async () => {
|
||||
const response = await client.search("anything", {
|
||||
const results = await client.search("anything", {
|
||||
filters: { userId: `nonexistent-user-${randomUUID()}` },
|
||||
});
|
||||
// v3 returns { results: [...] }
|
||||
const results = Array.isArray(response)
|
||||
? response
|
||||
: (response?.results ?? []);
|
||||
|
||||
expect(Array.isArray(results)).toBe(true);
|
||||
expect(results.length).toBe(0);
|
||||
});
|
||||
|
||||
test("search with top_k param does not throw", async () => {
|
||||
const response = await client.search(
|
||||
const results = await client.search(
|
||||
"Tell me about integration test user",
|
||||
{
|
||||
filters: { userId: TEST_USER_ID },
|
||||
topK: 1,
|
||||
},
|
||||
);
|
||||
// v3 returns { results: [...] }
|
||||
const results = Array.isArray(response)
|
||||
? response
|
||||
: (response?.results ?? []);
|
||||
|
||||
expect(Array.isArray(results)).toBe(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user