@functional-systems/lambdadb 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/commonjs/client.d.ts.map +1 -1
  2. package/dist/commonjs/client.js +51 -3
  3. package/dist/commonjs/client.js.map +1 -1
  4. package/dist/commonjs/compat/qdrant/client.d.ts +4 -5
  5. package/dist/commonjs/compat/qdrant/client.d.ts.map +1 -1
  6. package/dist/commonjs/compat/qdrant/client.js +17 -8
  7. package/dist/commonjs/compat/qdrant/client.js.map +1 -1
  8. package/dist/commonjs/compat/qdrant/filters.js +5 -1
  9. package/dist/commonjs/compat/qdrant/filters.js.map +1 -1
  10. package/dist/commonjs/funcs/collectionsDocsListDocs.js +1 -0
  11. package/dist/commonjs/funcs/collectionsDocsListDocs.js.map +1 -1
  12. package/dist/commonjs/funcs/collectionsDocsListDocsExtended.d.ts +15 -0
  13. package/dist/commonjs/funcs/collectionsDocsListDocsExtended.d.ts.map +1 -0
  14. package/dist/commonjs/funcs/collectionsDocsListDocsExtended.js +131 -0
  15. package/dist/commonjs/funcs/collectionsDocsListDocsExtended.js.map +1 -0
  16. package/dist/commonjs/lib/config.d.ts +2 -2
  17. package/dist/commonjs/lib/config.js +2 -2
  18. package/dist/commonjs/models/operations/listdocs.d.ts +60 -0
  19. package/dist/commonjs/models/operations/listdocs.d.ts.map +1 -1
  20. package/dist/commonjs/models/operations/listdocs.js +30 -1
  21. package/dist/commonjs/models/operations/listdocs.js.map +1 -1
  22. package/dist/commonjs/types/public.d.ts +6 -2
  23. package/dist/commonjs/types/public.d.ts.map +1 -1
  24. package/dist/commonjs/types/public.js.map +1 -1
  25. package/dist/esm/client.d.ts.map +1 -1
  26. package/dist/esm/client.js +51 -3
  27. package/dist/esm/client.js.map +1 -1
  28. package/dist/esm/compat/qdrant/client.d.ts +4 -5
  29. package/dist/esm/compat/qdrant/client.d.ts.map +1 -1
  30. package/dist/esm/compat/qdrant/client.js +17 -8
  31. package/dist/esm/compat/qdrant/client.js.map +1 -1
  32. package/dist/esm/compat/qdrant/filters.js +5 -1
  33. package/dist/esm/compat/qdrant/filters.js.map +1 -1
  34. package/dist/esm/funcs/collectionsDocsListDocs.js +1 -0
  35. package/dist/esm/funcs/collectionsDocsListDocs.js.map +1 -1
  36. package/dist/esm/funcs/collectionsDocsListDocsExtended.d.ts +15 -0
  37. package/dist/esm/funcs/collectionsDocsListDocsExtended.d.ts.map +1 -0
  38. package/dist/esm/funcs/collectionsDocsListDocsExtended.js +95 -0
  39. package/dist/esm/funcs/collectionsDocsListDocsExtended.js.map +1 -0
  40. package/dist/esm/lib/config.d.ts +2 -2
  41. package/dist/esm/lib/config.js +2 -2
  42. package/dist/esm/models/operations/listdocs.d.ts +60 -0
  43. package/dist/esm/models/operations/listdocs.d.ts.map +1 -1
  44. package/dist/esm/models/operations/listdocs.js +27 -0
  45. package/dist/esm/models/operations/listdocs.js.map +1 -1
  46. package/dist/esm/types/public.d.ts +6 -2
  47. package/dist/esm/types/public.d.ts.map +1 -1
  48. package/dist/esm/types/public.js.map +1 -1
  49. package/jsr.json +1 -1
  50. package/package.json +1 -1
  51. package/src/client.ts +67 -11
  52. package/src/compat/qdrant/client.ts +20 -9
  53. package/src/compat/qdrant/filters.ts +5 -3
  54. package/src/funcs/collectionsDocsListDocs.ts +1 -0
  55. package/src/funcs/collectionsDocsListDocsExtended.ts +201 -0
  56. package/src/lib/config.ts +2 -2
  57. package/src/models/operations/listdocs.ts +100 -0
  58. package/src/types/public.ts +9 -2
  59. package/test/public-api.test.mjs +51 -0
  60. package/test/qdrant-compat.test.mjs +97 -5
@@ -4,6 +4,7 @@ import test from "node:test";
4
4
  import {
5
5
  QdrantClient,
6
6
  QdrantCompatClient,
7
+ QdrantCompatValidationError,
7
8
  UnsupportedQdrantFeatureError,
8
9
  models,
9
10
  } from "../dist/esm/compat/qdrant.js";
@@ -50,10 +51,16 @@ class FakeDocs {
50
51
  docs: [
51
52
  {
52
53
  collection: "docs",
53
- doc: { id: "1", _qdrant_id: 1, tenant: "acme" },
54
+ doc: {
55
+ id: "1",
56
+ _qdrant_id: 1,
57
+ _qdrant_vector: [0.1, 0.2],
58
+ _qdrant_vector_title: [0.3, 0.4],
59
+ tenant: "acme",
60
+ },
54
61
  },
55
62
  ],
56
- nextPageToken: undefined,
63
+ nextPageToken: "next-token",
57
64
  };
58
65
  }
59
66
  }
@@ -328,6 +335,45 @@ test("queryPoints maps dense vectors, filters, and responses", async () => {
328
335
  );
329
336
  });
330
337
 
338
+ test("MatchText maps to LambdaDB text filter terms", async () => {
339
+ const fake = new FakeLambdaDB();
340
+ const client = new QdrantCompatClient(fake);
341
+
342
+ await client.queryPoints("docs", {
343
+ query: [0.1, 0.2],
344
+ queryFilter: new models.Filter({
345
+ must: [
346
+ new models.FieldCondition({
347
+ key: "body",
348
+ match: new models.MatchText({ text: "serverless database" }),
349
+ }),
350
+ ],
351
+ }),
352
+ });
353
+
354
+ assert.deepEqual(fake.collection("docs").queries[0].query.knn.filter, {
355
+ bool: [
356
+ { queryString: { query: "body:serverless" }, occur: "filter" },
357
+ { queryString: { query: "body:database" }, occur: "filter" },
358
+ ],
359
+ });
360
+
361
+ await assert.rejects(
362
+ client.queryPoints("docs", {
363
+ query: [0.1, 0.2],
364
+ queryFilter: new models.Filter({
365
+ must: [
366
+ new models.FieldCondition({
367
+ key: "body",
368
+ match: new models.MatchText({ text: " " }),
369
+ }),
370
+ ],
371
+ }),
372
+ }),
373
+ QdrantCompatValidationError,
374
+ );
375
+ });
376
+
331
377
  test("payload and vector selectors map to LambdaDB fields and qdrant responses", async () => {
332
378
  const fake = new FakeLambdaDB();
333
379
  const collection = fake.collection("docs");
@@ -445,11 +491,57 @@ test("retrieve, delete, scroll, count, and getCollection return qdrant-style obj
445
491
  },
446
492
  ]);
447
493
 
448
- const [scrollRecords, nextOffset] = await client.scroll("docs", { limit: 3 });
494
+ const [scrollRecords, nextOffset] = await client.scroll("docs", {
495
+ limit: 3,
496
+ withPayload: ["tenant"],
497
+ withVectors: ["title"],
498
+ });
449
499
  assert.equal(scrollRecords[0].id, 1);
450
- assert.equal(nextOffset, undefined);
451
- assert.deepEqual(fake.collection("docs").docs.lists, [{ size: 3 }]);
500
+ assert.deepEqual(scrollRecords[0].payload, { tenant: "acme" });
501
+ assert.deepEqual(scrollRecords[0].vector, { title: [0.3, 0.4] });
502
+ assert.equal(nextOffset, "next-token");
503
+ assert.deepEqual(fake.collection("docs").docs.lists, [
504
+ {
505
+ size: 3,
506
+ includeVectors: true,
507
+ fields: { include: ["_qdrant_id", "tenant", "_qdrant_vector_title"] },
508
+ },
509
+ ]);
452
510
 
453
511
  const count = await client.count("docs");
454
512
  assert.equal(count.count, 12);
455
513
  });
514
+
515
+ test("filtered scroll maps to extended list options and page-token offsets", async () => {
516
+ const fake = new FakeLambdaDB();
517
+ const client = new QdrantCompatClient(fake);
518
+
519
+ const [records, nextOffset] = await client.scroll("docs", {
520
+ scrollFilter: new models.Filter({
521
+ must: [
522
+ new models.FieldCondition({
523
+ key: "tenant",
524
+ match: new models.MatchValue({ value: "acme" }),
525
+ }),
526
+ ],
527
+ }),
528
+ offset: "page-1",
529
+ withPayload: true,
530
+ });
531
+
532
+ assert.equal(nextOffset, "next-token");
533
+ assert.equal(records[0].id, 1);
534
+ assert.deepEqual(fake.collection("docs").docs.lists, [
535
+ {
536
+ size: 10,
537
+ includeVectors: false,
538
+ pageToken: "page-1",
539
+ filter: { queryString: { query: "tenant:acme" } },
540
+ },
541
+ ]);
542
+
543
+ await assert.rejects(
544
+ client.scroll("docs", { offset: 1 }),
545
+ UnsupportedQdrantFeatureError,
546
+ );
547
+ });