@peerbit/indexer-tests 1.0.4 → 1.1.0

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.
package/dist/src/tests.js CHANGED
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { deserialize, field, fixedArray, option, serialize, variant, vec, } from "@dao-xyz/borsh";
11
11
  import { randomBytes } from "@peerbit/crypto";
12
- import { And, BoolQuery, ByteMatchQuery, Compare, CountRequest, DeleteRequest, IntegerCompare, IsNull, Nested, Not, Or, Query, SearchRequest, Sort, SortDirection, StringMatch, StringMatchMethod, SumRequest, extractFieldValue, getIdProperty, id, iterate, toId, } from "@peerbit/indexer-interface";
12
+ import { And, BoolQuery, ByteMatchQuery, Compare, IntegerCompare, IsNull, Nested, Not, Or, Query, Sort, SortDirection, StringMatch, StringMatchMethod, extractFieldValue, getIdProperty, id, toId, } from "@peerbit/indexer-interface";
13
13
  import {
14
14
  /* delay, */
15
15
  delay, waitForResolved, } from "@peerbit/time";
@@ -127,8 +127,14 @@ DocumentNext = __decorate([
127
127
  const bigIntSort = (a, b) => a > b ? 1 : 0 || -(a < b);
128
128
  const search = (index, query, options) => {
129
129
  // fetch max u32
130
- query.fetch = 0xffffffff;
131
- return index.query(query, options);
130
+ return index.iterate(query, options).all();
131
+ };
132
+ const assertIteratorIsDone = async (iterator) => {
133
+ const next = await iterator.next(1);
134
+ if (next.length > 0) {
135
+ throw new Error(`Iterator is not done, got more results`);
136
+ }
137
+ expect(iterator.done()).to.be.true;
132
138
  };
133
139
  export const tests = (createIndicies, type = "transient", shapingSupported) => {
134
140
  return describe("index", () => {
@@ -263,9 +269,9 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
263
269
  current[path] = docId;
264
270
  }
265
271
  }
266
- await store.del(new DeleteRequest({
272
+ await store.del({
267
273
  query: deleteQueryObject,
268
- }));
274
+ });
269
275
  expect(await store.getSize()).equal(0);
270
276
  result = await store.get(toId(docId));
271
277
  expect(result).equal(undefined);
@@ -337,7 +343,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
337
343
  value: "Hello world",
338
344
  });
339
345
  await store.put(doc);
340
- const results = await search(store, new SearchRequest({
346
+ const results = await search(store, {
341
347
  query: [
342
348
  new StringMatch({
343
349
  key: "id",
@@ -346,8 +352,8 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
346
352
  method: StringMatchMethod.contains,
347
353
  }),
348
354
  ],
349
- }));
350
- expect(results.results).to.have.length(1);
355
+ });
356
+ expect(results).to.have.length(1);
351
357
  });
352
358
  });
353
359
  describe("bytes", () => {
@@ -508,9 +514,9 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
508
514
  describe("fields", () => {
509
515
  it("no-args", async () => {
510
516
  await setupDefault();
511
- const results = await search(store, new SearchRequest({ query: [] }));
512
- expect(results.results).to.have.length(4);
513
- for (const result of results.results) {
517
+ const results = await search(store, { query: [] });
518
+ expect(results).to.have.length(4);
519
+ for (const result of results) {
514
520
  checkDocument(result.value, ...defaultDocs);
515
521
  }
516
522
  });
@@ -519,7 +525,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
519
525
  await setupDefault();
520
526
  });
521
527
  it("exact", async () => {
522
- const responses = await search(store, new SearchRequest({
528
+ const responses = await search(store, {
523
529
  query: [
524
530
  new StringMatch({
525
531
  key: "name",
@@ -527,11 +533,14 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
527
533
  caseInsensitive: true,
528
534
  }),
529
535
  ],
530
- }));
531
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["1", "2"]);
536
+ });
537
+ expect(responses.map((x) => x.id.primitive)).to.have.members([
538
+ "1",
539
+ "2",
540
+ ]);
532
541
  });
533
542
  it("exact-case-insensitive", async () => {
534
- const responses = await search(store, new SearchRequest({
543
+ const responses = await search(store, {
535
544
  query: [
536
545
  new StringMatch({
537
546
  key: "name",
@@ -539,12 +548,15 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
539
548
  caseInsensitive: true,
540
549
  }),
541
550
  ],
542
- }));
543
- expect(responses.results).to.have.length(2);
544
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["1", "2"]);
551
+ });
552
+ expect(responses).to.have.length(2);
553
+ expect(responses.map((x) => x.id.primitive)).to.have.members([
554
+ "1",
555
+ "2",
556
+ ]);
545
557
  });
546
558
  it("exact case sensitive", async () => {
547
- let responses = await search(store, new SearchRequest({
559
+ let responses = await search(store, {
548
560
  query: [
549
561
  new StringMatch({
550
562
  key: "name",
@@ -552,10 +564,10 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
552
564
  caseInsensitive: false,
553
565
  }),
554
566
  ],
555
- }));
556
- expect(responses.results).to.have.length(1);
557
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["2"]);
558
- responses = await search(store, new SearchRequest({
567
+ });
568
+ expect(responses).to.have.length(1);
569
+ expect(responses.map((x) => x.id.primitive)).to.have.members(["2"]);
570
+ responses = await search(store, {
559
571
  query: [
560
572
  new StringMatch({
561
573
  key: "name",
@@ -563,11 +575,11 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
563
575
  caseInsensitive: false,
564
576
  }),
565
577
  ],
566
- }));
567
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["1"]);
578
+ });
579
+ expect(responses.map((x) => x.id.primitive)).to.have.members(["1"]);
568
580
  });
569
581
  it("prefix", async () => {
570
- const responses = await search(store, new SearchRequest({
582
+ const responses = await search(store, {
571
583
  query: [
572
584
  new StringMatch({
573
585
  key: "name",
@@ -576,12 +588,15 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
576
588
  caseInsensitive: true,
577
589
  }),
578
590
  ],
579
- }));
580
- expect(responses.results).to.have.length(2);
581
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["1", "2"]);
591
+ });
592
+ expect(responses).to.have.length(2);
593
+ expect(responses.map((x) => x.id.primitive)).to.have.members([
594
+ "1",
595
+ "2",
596
+ ]);
582
597
  });
583
598
  it("contains", async () => {
584
- const responses = await search(store, new SearchRequest({
599
+ const responses = await search(store, {
585
600
  query: [
586
601
  new StringMatch({
587
602
  key: "name",
@@ -590,13 +605,16 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
590
605
  caseInsensitive: true,
591
606
  }),
592
607
  ],
593
- }));
594
- expect(responses.results).to.have.length(2);
595
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["1", "2"]);
608
+ });
609
+ expect(responses).to.have.length(2);
610
+ expect(responses.map((x) => x.id.primitive)).to.have.members([
611
+ "1",
612
+ "2",
613
+ ]);
596
614
  });
597
615
  describe("arr", () => {
598
616
  it("arr", async () => {
599
- const responses = await search(store, new SearchRequest({
617
+ const responses = await search(store, {
600
618
  query: [
601
619
  new StringMatch({
602
620
  key: "tags",
@@ -605,60 +623,62 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
605
623
  caseInsensitive: true,
606
624
  }),
607
625
  ],
608
- }));
609
- expect(responses.results).to.have.length(1);
610
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["2"]);
611
- checkDocument(responses.results[0].value, ...defaultDocs);
626
+ });
627
+ expect(responses).to.have.length(1);
628
+ expect(responses.map((x) => x.id.primitive)).to.have.members([
629
+ "2",
630
+ ]);
631
+ checkDocument(responses[0].value, ...defaultDocs);
612
632
  });
613
633
  });
614
634
  });
615
635
  it("missing", async () => {
616
636
  await setupDefault();
617
- const responses = await search(store, new SearchRequest({
637
+ const responses = await search(store, {
618
638
  query: [
619
639
  new IsNull({
620
640
  key: "name",
621
641
  }),
622
642
  ],
623
- }));
624
- expect(responses.results).to.have.length(1);
625
- expect(responses.results.map((x) => x.id.primitive)).to.deep.equal([
626
- "4",
627
- ]);
643
+ });
644
+ expect(responses).to.have.length(1);
645
+ expect(responses.map((x) => x.id.primitive)).to.deep.equal(["4"]);
628
646
  });
629
647
  describe("uint8arrays", () => {
630
648
  describe("dynamic", () => {
631
649
  describe("bytematch", () => {
632
650
  it("matches", async () => {
633
651
  await setupDefault();
634
- const responses = await search(store, new SearchRequest({
652
+ const responses = await search(store, {
635
653
  query: [
636
654
  new ByteMatchQuery({
637
655
  key: "data",
638
656
  value: new Uint8Array([1]),
639
657
  }),
640
658
  ],
641
- }));
642
- expect(responses.results).to.have.length(1);
643
- expect(responses.results.map((x) => x.id.primitive)).to.deep.equal(["1"]);
659
+ });
660
+ expect(responses).to.have.length(1);
661
+ expect(responses.map((x) => x.id.primitive)).to.deep.equal([
662
+ "1",
663
+ ]);
644
664
  });
645
665
  it("un-matches", async () => {
646
666
  await setupDefault();
647
- const responses = await search(store, new SearchRequest({
667
+ const responses = await search(store, {
648
668
  query: [
649
669
  new ByteMatchQuery({
650
670
  key: "data",
651
671
  value: new Uint8Array([199]),
652
672
  }),
653
673
  ],
654
- }));
655
- expect(responses.results).to.be.empty;
674
+ });
675
+ expect(responses).to.be.empty;
656
676
  });
657
677
  });
658
678
  describe("integer", () => {
659
679
  it("exists", async () => {
660
680
  await setupDefault();
661
- const responses = await search(store, new SearchRequest({
681
+ const responses = await search(store, {
662
682
  query: [
663
683
  new IntegerCompare({
664
684
  key: "data",
@@ -666,13 +686,15 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
666
686
  value: 1,
667
687
  }),
668
688
  ],
669
- }));
670
- expect(responses.results).to.have.length(1);
671
- expect(responses.results.map((x) => x.id.primitive)).to.deep.equal(["1"]);
689
+ });
690
+ expect(responses).to.have.length(1);
691
+ expect(responses.map((x) => x.id.primitive)).to.deep.equal([
692
+ "1",
693
+ ]);
672
694
  });
673
695
  it("does not exist", async () => {
674
696
  await setupDefault();
675
- const responses = await search(store, new SearchRequest({
697
+ const responses = await search(store, {
676
698
  query: [
677
699
  new IntegerCompare({
678
700
  key: "data",
@@ -680,8 +702,8 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
680
702
  value: 199,
681
703
  }),
682
704
  ],
683
- }));
684
- expect(responses.results).to.be.empty;
705
+ });
706
+ expect(responses).to.be.empty;
685
707
  });
686
708
  });
687
709
  });
@@ -689,34 +711,36 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
689
711
  describe("bytematch", () => {
690
712
  it("matches", async () => {
691
713
  await setupDefault();
692
- const responses = await search(store, new SearchRequest({
714
+ const responses = await search(store, {
693
715
  query: [
694
716
  new ByteMatchQuery({
695
717
  key: "fixedData",
696
718
  value: new Uint8Array(32).fill(1),
697
719
  }),
698
720
  ],
699
- }));
700
- expect(responses.results).to.have.length(1);
701
- expect(responses.results.map((x) => x.id.primitive)).to.deep.equal(["1"]);
721
+ });
722
+ expect(responses).to.have.length(1);
723
+ expect(responses.map((x) => x.id.primitive)).to.deep.equal([
724
+ "1",
725
+ ]);
702
726
  });
703
727
  it("un-matches", async () => {
704
728
  await setupDefault();
705
- const responses = await search(store, new SearchRequest({
729
+ const responses = await search(store, {
706
730
  query: [
707
731
  new ByteMatchQuery({
708
732
  key: "data",
709
733
  value: new Uint8Array(32).fill(99),
710
734
  }),
711
735
  ],
712
- }));
713
- expect(responses.results).to.be.empty;
736
+ });
737
+ expect(responses).to.be.empty;
714
738
  });
715
739
  });
716
740
  describe("integer", () => {
717
741
  it("exists", async () => {
718
742
  await setupDefault();
719
- const responses = await search(store, new SearchRequest({
743
+ const responses = await search(store, {
720
744
  query: [
721
745
  new IntegerCompare({
722
746
  key: "data",
@@ -724,13 +748,15 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
724
748
  value: 1,
725
749
  }),
726
750
  ],
727
- }));
728
- expect(responses.results).to.have.length(1);
729
- expect(responses.results.map((x) => x.id.primitive)).to.deep.equal(["1"]);
751
+ });
752
+ expect(responses).to.have.length(1);
753
+ expect(responses.map((x) => x.id.primitive)).to.deep.equal([
754
+ "1",
755
+ ]);
730
756
  });
731
757
  it("does not exist", async () => {
732
758
  await setupDefault();
733
- const responses = await search(store, new SearchRequest({
759
+ const responses = await search(store, {
734
760
  query: [
735
761
  new IntegerCompare({
736
762
  key: "data",
@@ -738,26 +764,24 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
738
764
  value: 199,
739
765
  }),
740
766
  ],
741
- }));
742
- expect(responses.results).to.be.empty;
767
+ });
768
+ expect(responses).to.be.empty;
743
769
  });
744
770
  });
745
771
  });
746
772
  });
747
773
  +it("bool", async () => {
748
774
  await setupDefault();
749
- const responses = await search(store, new SearchRequest({
775
+ const responses = await search(store, {
750
776
  query: [
751
777
  new BoolQuery({
752
778
  key: "bool",
753
779
  value: true,
754
780
  }),
755
781
  ],
756
- }));
757
- expect(responses.results).to.have.length(1);
758
- expect(responses.results.map((x) => x.id.primitive)).to.deep.equal([
759
- "1",
760
- ]);
782
+ });
783
+ expect(responses).to.have.length(1);
784
+ expect(responses.map((x) => x.id.primitive)).to.deep.equal(["1"]);
761
785
  });
762
786
  describe("array", () => {
763
787
  describe("uint8arrays", () => {
@@ -787,17 +811,15 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
787
811
  await store.put(new Uint8arraysVec({
788
812
  bytesArrays: [new Uint8Array([3])],
789
813
  }));
790
- const results = await search(store, new SearchRequest({
814
+ const results = await search(store, {
791
815
  query: [
792
816
  new ByteMatchQuery({
793
817
  key: "bytesArrays",
794
818
  value: new Uint8Array([2]),
795
819
  }),
796
820
  ],
797
- }));
798
- expect(results.results.map((x) => x.value.id)).to.deep.equal([
799
- d1.id,
800
- ]);
821
+ });
822
+ expect(results.map((x) => x.value.id)).to.deep.equal([d1.id]);
801
823
  });
802
824
  });
803
825
  describe("documents", () => {
@@ -831,16 +853,14 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
831
853
  new Document({ id: uuid(), number: 124n, tags: [] }),
832
854
  ],
833
855
  }));
834
- const results = await search(store, new SearchRequest({
856
+ const results = await search(store, {
835
857
  query: new IntegerCompare({
836
858
  key: ["documents", "number"],
837
859
  compare: Compare.Equal,
838
860
  value: d1.documents[0].number,
839
861
  }),
840
- }));
841
- expect(results.results.map((x) => x.value.id)).to.deep.equal([
842
- d1.id,
843
- ]);
862
+ });
863
+ expect(results.map((x) => x.value.id)).to.deep.equal([d1.id]);
844
864
  });
845
865
  it("update array", async () => {
846
866
  const out = await setup({ schema: DocumentsVec });
@@ -856,20 +876,20 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
856
876
  ];
857
877
  await store.put(d1);
858
878
  // should have update results
859
- expect((await search(store, new SearchRequest({
879
+ expect((await search(store, {
860
880
  query: new IntegerCompare({
861
881
  key: ["documents", "number"],
862
882
  compare: Compare.Equal,
863
883
  value: 123n,
864
884
  }),
865
- }))).results.length).to.equal(0);
866
- expect((await search(store, new SearchRequest({
885
+ })).length).to.equal(0);
886
+ expect((await search(store, {
867
887
  query: new IntegerCompare({
868
888
  key: ["documents", "number"],
869
889
  compare: Compare.Equal,
870
890
  value: 124n,
871
891
  }),
872
- }))).results.map((x) => x.value.id)).to.deep.equal([d1.id]);
892
+ })).map((x) => x.value.id)).to.deep.equal([d1.id]);
873
893
  });
874
894
  it("put delete put", async () => {
875
895
  const { store } = await setup({ schema: DocumentsVec });
@@ -879,37 +899,37 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
879
899
  ],
880
900
  });
881
901
  await store.put(d1);
882
- const [deleted] = await store.del(new DeleteRequest({
902
+ const [deleted] = await store.del({
883
903
  query: {
884
904
  id: d1.id,
885
905
  },
886
- }));
906
+ });
887
907
  expect(deleted.key).to.deep.equal(d1.id);
888
- expect((await search(store, new SearchRequest({
908
+ expect((await search(store, {
889
909
  query: new IntegerCompare({
890
910
  key: ["documents", "number"],
891
911
  compare: Compare.Equal,
892
912
  value: 123n,
893
913
  }),
894
- }))).results.length).to.equal(0);
914
+ })).length).to.equal(0);
895
915
  d1.documents = [
896
916
  new Document({ id: uuid(), number: 124n, tags: [] }),
897
917
  ];
898
918
  await store.put(d1);
899
- expect((await search(store, new SearchRequest({
919
+ expect((await search(store, {
900
920
  query: new IntegerCompare({
901
921
  key: ["documents", "number"],
902
922
  compare: Compare.Equal,
903
923
  value: 124n,
904
924
  }),
905
- }))).results.map((x) => x.value.id)).to.deep.equal([d1.id]);
906
- expect((await search(store, new SearchRequest({
925
+ })).map((x) => x.value.id)).to.deep.equal([d1.id]);
926
+ expect((await search(store, {
907
927
  query: new IntegerCompare({
908
928
  key: ["documents", "number"],
909
929
  compare: Compare.Equal,
910
930
  value: 123n,
911
931
  }),
912
- }))).results.length).to.equal(0);
932
+ })).length).to.equal(0);
913
933
  });
914
934
  });
915
935
  });
@@ -918,7 +938,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
918
938
  await setupDefault();
919
939
  });
920
940
  it("and", async () => {
921
- const responses = await search(store, new SearchRequest({
941
+ const responses = await search(store, {
922
942
  query: [
923
943
  new And([
924
944
  new StringMatch({
@@ -935,12 +955,15 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
935
955
  }),
936
956
  ]),
937
957
  ],
938
- }));
939
- expect(responses.results).to.have.length(2);
940
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["1", "2"]);
958
+ });
959
+ expect(responses).to.have.length(2);
960
+ expect(responses.map((x) => x.id.primitive)).to.have.members([
961
+ "1",
962
+ "2",
963
+ ]);
941
964
  });
942
965
  it("or", async () => {
943
- const responses = await search(store, new SearchRequest({
966
+ const responses = await search(store, {
944
967
  query: [
945
968
  new Or([
946
969
  new StringMatch({
@@ -953,12 +976,15 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
953
976
  }),
954
977
  ]),
955
978
  ],
956
- }));
957
- expect(responses.results).to.have.length(2);
958
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["1", "2"]);
979
+ });
980
+ expect(responses).to.have.length(2);
981
+ expect(responses.map((x) => x.id.primitive)).to.have.members([
982
+ "1",
983
+ "2",
984
+ ]);
959
985
  });
960
986
  it("not", async () => {
961
- const responses = await search(store, new SearchRequest({
987
+ const responses = await search(store, {
962
988
  query: [
963
989
  new And([
964
990
  new Not(new IntegerCompare({
@@ -968,9 +994,9 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
968
994
  })),
969
995
  ]),
970
996
  ],
971
- }));
972
- expect(responses.results).to.have.length(1);
973
- expect(responses.results.map((x) => x.id.primitive)).to.have.members(["1"]);
997
+ });
998
+ expect(responses).to.have.length(1);
999
+ expect(responses.map((x) => x.id.primitive)).to.have.members(["1"]);
974
1000
  });
975
1001
  });
976
1002
  describe("number", () => {
@@ -978,7 +1004,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
978
1004
  await setupDefault();
979
1005
  });
980
1006
  it("equal", async () => {
981
- const response = await search(store, new SearchRequest({
1007
+ const response = await search(store, {
982
1008
  query: [
983
1009
  new IntegerCompare({
984
1010
  key: "number",
@@ -986,12 +1012,12 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
986
1012
  value: 2n,
987
1013
  }),
988
1014
  ],
989
- }));
990
- expect(response.results).to.have.length(1);
991
- expect(response.results[0].value.number).to.be.oneOf([2n, 2]);
1015
+ });
1016
+ expect(response).to.have.length(1);
1017
+ expect(response[0].value.number).to.be.oneOf([2n, 2]);
992
1018
  });
993
1019
  it("gt", async () => {
994
- const response = await search(store, new SearchRequest({
1020
+ const response = await search(store, {
995
1021
  query: [
996
1022
  new IntegerCompare({
997
1023
  key: "number",
@@ -999,12 +1025,12 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
999
1025
  value: 2n,
1000
1026
  }),
1001
1027
  ],
1002
- }));
1003
- expect(response.results).to.have.length(1);
1004
- expect(response.results[0].value.number).to.be.oneOf([3n, 3]);
1028
+ });
1029
+ expect(response).to.have.length(1);
1030
+ expect(response[0].value.number).to.be.oneOf([3n, 3]);
1005
1031
  });
1006
1032
  it("gte", async () => {
1007
- const response = await search(store, new SearchRequest({
1033
+ const response = await search(store, {
1008
1034
  query: [
1009
1035
  new IntegerCompare({
1010
1036
  key: "number",
@@ -1012,14 +1038,14 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1012
1038
  value: 2n,
1013
1039
  }),
1014
1040
  ],
1015
- }));
1016
- response.results.sort((a, b) => bigIntSort(a.value.number, b.value.number));
1017
- expect(response.results).to.have.length(2);
1018
- expect(response.results[0].value.number).to.be.oneOf([2n, 2]);
1019
- expect(response.results[1].value.number).to.be.oneOf([3n, 3]);
1041
+ });
1042
+ response.sort((a, b) => bigIntSort(a.value.number, b.value.number));
1043
+ expect(response).to.have.length(2);
1044
+ expect(response[0].value.number).to.be.oneOf([2n, 2]);
1045
+ expect(response[1].value.number).to.be.oneOf([3n, 3]);
1020
1046
  });
1021
1047
  it("lt", async () => {
1022
- const response = await search(store, new SearchRequest({
1048
+ const response = await search(store, {
1023
1049
  query: [
1024
1050
  new IntegerCompare({
1025
1051
  key: "number",
@@ -1027,12 +1053,12 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1027
1053
  value: 2n,
1028
1054
  }),
1029
1055
  ],
1030
- }));
1031
- expect(response.results).to.have.length(1);
1032
- expect(response.results[0].value.number).to.be.oneOf([1n, 1]);
1056
+ });
1057
+ expect(response).to.have.length(1);
1058
+ expect(response[0].value.number).to.be.oneOf([1n, 1]);
1033
1059
  });
1034
1060
  it("lte", async () => {
1035
- const response = await search(store, new SearchRequest({
1061
+ const response = await search(store, {
1036
1062
  query: [
1037
1063
  new IntegerCompare({
1038
1064
  key: "number",
@@ -1040,11 +1066,11 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1040
1066
  value: 2n,
1041
1067
  }),
1042
1068
  ],
1043
- }));
1044
- response.results.sort((a, b) => bigIntSort(a.value.number, b.value.number));
1045
- expect(response.results).to.have.length(2);
1046
- expect(response.results[0].value.number).to.be.oneOf([1n, 1]);
1047
- expect(response.results[1].value.number).to.be.oneOf([2n, 2]);
1069
+ });
1070
+ response.sort((a, b) => bigIntSort(a.value.number, b.value.number));
1071
+ expect(response).to.have.length(2);
1072
+ expect(response[0].value.number).to.be.oneOf([1n, 1]);
1073
+ expect(response[1].value.number).to.be.oneOf([2n, 2]);
1048
1074
  });
1049
1075
  });
1050
1076
  describe("bigint", () => {
@@ -1080,7 +1106,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1080
1106
  expect(ser).to.equal(first);
1081
1107
  });
1082
1108
  it("equal", async () => {
1083
- const response = await search(store, new SearchRequest({
1109
+ const response = await search(store, {
1084
1110
  query: [
1085
1111
  new IntegerCompare({
1086
1112
  key: "bigint",
@@ -1088,12 +1114,12 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1088
1114
  value: first,
1089
1115
  }),
1090
1116
  ],
1091
- }));
1092
- expect(response.results).to.have.length(1);
1093
- expect(response.results[0].value.bigint).to.equal(first);
1117
+ });
1118
+ expect(response).to.have.length(1);
1119
+ expect(response[0].value.bigint).to.equal(first);
1094
1120
  });
1095
1121
  it("gt", async () => {
1096
- const response = await search(store, new SearchRequest({
1122
+ const response = await search(store, {
1097
1123
  query: [
1098
1124
  new IntegerCompare({
1099
1125
  key: "bigint",
@@ -1101,12 +1127,12 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1101
1127
  value: second,
1102
1128
  }),
1103
1129
  ],
1104
- }));
1105
- expect(response.results).to.have.length(1);
1106
- expect(response.results[0].value.bigint).to.equal(third);
1130
+ });
1131
+ expect(response).to.have.length(1);
1132
+ expect(response[0].value.bigint).to.equal(third);
1107
1133
  });
1108
1134
  it("gte", async () => {
1109
- const response = await search(store, new SearchRequest({
1135
+ const response = await search(store, {
1110
1136
  query: [
1111
1137
  new IntegerCompare({
1112
1138
  key: "bigint",
@@ -1114,14 +1140,14 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1114
1140
  value: second,
1115
1141
  }),
1116
1142
  ],
1117
- }));
1118
- response.results.sort((a, b) => bigIntSort(a.value.bigint, b.value.bigint));
1119
- expect(response.results).to.have.length(2);
1120
- expect(response.results[0].value.bigint).to.equal(second);
1121
- expect(response.results[1].value.bigint).to.equal(third);
1143
+ });
1144
+ response.sort((a, b) => bigIntSort(a.value.bigint, b.value.bigint));
1145
+ expect(response).to.have.length(2);
1146
+ expect(response[0].value.bigint).to.equal(second);
1147
+ expect(response[1].value.bigint).to.equal(third);
1122
1148
  });
1123
1149
  it("lt", async () => {
1124
- const response = await search(store, new SearchRequest({
1150
+ const response = await search(store, {
1125
1151
  query: [
1126
1152
  new IntegerCompare({
1127
1153
  key: "bigint",
@@ -1129,12 +1155,12 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1129
1155
  value: second,
1130
1156
  }),
1131
1157
  ],
1132
- }));
1133
- expect(response.results).to.have.length(1);
1134
- expect(response.results[0].value.bigint).to.equal(first);
1158
+ });
1159
+ expect(response).to.have.length(1);
1160
+ expect(response[0].value.bigint).to.equal(first);
1135
1161
  });
1136
1162
  it("lte", async () => {
1137
- const response = await search(store, new SearchRequest({
1163
+ const response = await search(store, {
1138
1164
  query: [
1139
1165
  new IntegerCompare({
1140
1166
  key: "bigint",
@@ -1142,11 +1168,11 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1142
1168
  value: second,
1143
1169
  }),
1144
1170
  ],
1145
- }));
1146
- response.results.sort((a, b) => bigIntSort(a.value.number, b.value.number));
1147
- expect(response.results).to.have.length(2);
1148
- expect(response.results[0].value.bigint).to.equal(first);
1149
- expect(response.results[1].value.bigint).to.equal(second);
1171
+ });
1172
+ response.sort((a, b) => bigIntSort(a.value.number, b.value.number));
1173
+ expect(response).to.have.length(2);
1174
+ expect(response[0].value.bigint).to.equal(first);
1175
+ expect(response[1].value.bigint).to.equal(second);
1150
1176
  });
1151
1177
  });
1152
1178
  describe("nested", () => {
@@ -1200,7 +1226,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1200
1226
  nested: new Nested({ number: 2n, bool: true }),
1201
1227
  });
1202
1228
  await store.put(doc2);
1203
- const response = await search(store, new SearchRequest({
1229
+ const response = await search(store, {
1204
1230
  query: [
1205
1231
  new IntegerCompare({
1206
1232
  key: ["nested", "number"],
@@ -1208,10 +1234,10 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1208
1234
  value: 2n,
1209
1235
  }),
1210
1236
  ],
1211
- }));
1212
- expect(response.results).to.have.length(1);
1213
- expect(response.results[0].value.id).to.equal("2");
1214
- checkDocument(response.results[0].value, doc2);
1237
+ });
1238
+ expect(response).to.have.length(1);
1239
+ expect(response[0].value.id).to.equal("2");
1240
+ checkDocument(response[0].value, doc2);
1215
1241
  });
1216
1242
  it("bool", async () => {
1217
1243
  const doc1 = new DocumentWithNesting({
@@ -1224,28 +1250,28 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1224
1250
  nested: new Nested({ number: 2n, bool: true }),
1225
1251
  });
1226
1252
  await store.put(doc2);
1227
- let response = await search(store, new SearchRequest({
1253
+ let response = await search(store, {
1228
1254
  query: [
1229
1255
  new BoolQuery({
1230
1256
  key: ["nested", "bool"],
1231
1257
  value: true,
1232
1258
  }),
1233
1259
  ],
1234
- }));
1235
- expect(response.results).to.have.length(1);
1236
- expect(response.results[0].value.id).to.equal("2");
1237
- checkDocument(response.results[0].value, doc2);
1238
- response = await search(store, new SearchRequest({
1260
+ });
1261
+ expect(response).to.have.length(1);
1262
+ expect(response[0].value.id).to.equal("2");
1263
+ checkDocument(response[0].value, doc2);
1264
+ response = await search(store, {
1239
1265
  query: [
1240
1266
  new BoolQuery({
1241
1267
  key: ["nested", "bool"],
1242
1268
  value: false,
1243
1269
  }),
1244
1270
  ],
1245
- }));
1246
- expect(response.results).to.have.length(1);
1247
- expect(response.results[0].value.id).to.equal("1");
1248
- checkDocument(response.results[0].value, doc1);
1271
+ });
1272
+ expect(response).to.have.length(1);
1273
+ expect(response[0].value.id).to.equal("1");
1274
+ checkDocument(response[0].value, doc1);
1249
1275
  });
1250
1276
  });
1251
1277
  describe("one level flat constructor", () => {
@@ -1293,28 +1319,28 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1293
1319
  nested: new Nested(true),
1294
1320
  });
1295
1321
  await store.put(doc2);
1296
- let response = await search(store, new SearchRequest({
1322
+ let response = await search(store, {
1297
1323
  query: [
1298
1324
  new BoolQuery({
1299
1325
  key: ["nested", "bool"],
1300
1326
  value: true,
1301
1327
  }),
1302
1328
  ],
1303
- }));
1304
- expect(response.results).to.have.length(1);
1305
- expect(response.results[0].value.id).to.equal("2");
1306
- checkDocument(response.results[0].value, doc2);
1307
- response = await search(store, new SearchRequest({
1329
+ });
1330
+ expect(response).to.have.length(1);
1331
+ expect(response[0].value.id).to.equal("2");
1332
+ checkDocument(response[0].value, doc2);
1333
+ response = await search(store, {
1308
1334
  query: [
1309
1335
  new BoolQuery({
1310
1336
  key: ["nested", "bool"],
1311
1337
  value: false,
1312
1338
  }),
1313
1339
  ],
1314
- }));
1315
- expect(response.results).to.have.length(1);
1316
- expect(response.results[0].value.id).to.equal("1");
1317
- checkDocument(response.results[0].value, doc1);
1340
+ });
1341
+ expect(response).to.have.length(1);
1342
+ expect(response[0].value.id).to.equal("1");
1343
+ checkDocument(response[0].value, doc1);
1318
1344
  });
1319
1345
  });
1320
1346
  describe("2-level-variants", () => {
@@ -1375,7 +1401,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1375
1401
  }),
1376
1402
  });
1377
1403
  await store.put(doc2);
1378
- const response = await search(store, new SearchRequest({
1404
+ const response = await search(store, {
1379
1405
  query: [
1380
1406
  new IntegerCompare({
1381
1407
  key: ["nested", "nestedAgain", "number"],
@@ -1383,10 +1409,10 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1383
1409
  value: 2n,
1384
1410
  }),
1385
1411
  ],
1386
- }));
1387
- expect(response.results).to.have.length(1);
1388
- expect(response.results[0].value.id).to.equal("2");
1389
- checkDocument(response.results[0].value, doc2);
1412
+ });
1413
+ expect(response).to.have.length(1);
1414
+ expect(response[0].value.id).to.equal("2");
1415
+ checkDocument(response[0].value, doc2);
1390
1416
  });
1391
1417
  });
1392
1418
  describe("3-level-variants", () => {
@@ -1461,7 +1487,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1461
1487
  }),
1462
1488
  });
1463
1489
  await store.put(doc2);
1464
- const response = await search(store, new SearchRequest({
1490
+ const response = await search(store, {
1465
1491
  query: [
1466
1492
  new IntegerCompare({
1467
1493
  key: [
@@ -1474,10 +1500,10 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1474
1500
  value: 2n,
1475
1501
  }),
1476
1502
  ],
1477
- }));
1478
- expect(response.results).to.have.length(1);
1479
- expect(response.results[0].value.id).to.equal("2");
1480
- checkDocument(response.results[0].value, doc2);
1503
+ });
1504
+ expect(response).to.have.length(1);
1505
+ expect(response[0].value.id).to.equal("2");
1506
+ checkDocument(response[0].value, doc2);
1481
1507
  });
1482
1508
  });
1483
1509
  describe("poly-morphism", () => {
@@ -1551,17 +1577,17 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1551
1577
  }),
1552
1578
  });
1553
1579
  await store.put(doc2);
1554
- const response = await search(store, new SearchRequest({
1580
+ const response = await search(store, {
1555
1581
  query: [
1556
1582
  new StringMatch({
1557
1583
  key: ["nested", "string"],
1558
1584
  value: "hello",
1559
1585
  }),
1560
1586
  ],
1561
- }));
1562
- expect(response.results).to.have.length(1);
1563
- expect(response.results[0].value.id).to.equal("2");
1564
- checkDocument(response.results[0].value, doc2);
1587
+ });
1588
+ expect(response).to.have.length(1);
1589
+ expect(response[0].value.id).to.equal("2");
1590
+ checkDocument(response[0].value, doc2);
1565
1591
  });
1566
1592
  });
1567
1593
  describe("non-array-nested", () => {
@@ -1648,17 +1674,17 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1648
1674
  }),
1649
1675
  });
1650
1676
  await store.put(doc2);
1651
- const response = await search(store, new SearchRequest({
1677
+ const response = await search(store, {
1652
1678
  query: [
1653
1679
  new StringMatch({
1654
1680
  key: ["nested", "nestedAgain", "string"],
1655
1681
  value: "hello",
1656
1682
  }),
1657
1683
  ],
1658
- }));
1659
- expect(response.results).to.have.length(1);
1660
- expect(response.results[0].value.id).to.equal("2");
1661
- checkDocument(response.results[0].value, doc2);
1684
+ });
1685
+ expect(response).to.have.length(1);
1686
+ expect(response[0].value.id).to.equal("2");
1687
+ checkDocument(response[0].value, doc2);
1662
1688
  });
1663
1689
  });
1664
1690
  describe("array", () => {
@@ -1742,17 +1768,17 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1742
1768
  ],
1743
1769
  });
1744
1770
  await store.put(doc2);
1745
- const response = await search(store, new SearchRequest({
1771
+ const response = await search(store, {
1746
1772
  query: [
1747
1773
  new StringMatch({
1748
1774
  key: ["array", "string"],
1749
1775
  value: "world",
1750
1776
  }),
1751
1777
  ],
1752
- }));
1753
- expect(response.results).to.have.length(1);
1754
- expect(response.results[0].value.id).to.equal("2");
1755
- checkDocument(response.results[0].value, doc2);
1778
+ });
1779
+ expect(response).to.have.length(1);
1780
+ expect(response[0].value.id).to.equal("2");
1781
+ checkDocument(response[0].value, doc2);
1756
1782
  });
1757
1783
  });
1758
1784
  describe("polymorphism-variant-base", () => {
@@ -1828,17 +1854,17 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1828
1854
  }),
1829
1855
  });
1830
1856
  await store.put(doc2);
1831
- const response = await search(store, new SearchRequest({
1857
+ const response = await search(store, {
1832
1858
  query: [
1833
1859
  new StringMatch({
1834
1860
  key: ["base", "string"],
1835
1861
  value: "world",
1836
1862
  }),
1837
1863
  ],
1838
- }));
1839
- expect(response.results).to.have.length(1);
1840
- expect(response.results[0].value.id).to.equal("2");
1841
- checkDocument(response.results[0].value, doc2);
1864
+ });
1865
+ expect(response).to.have.length(1);
1866
+ expect(response[0].value.id).to.equal("2");
1867
+ checkDocument(response[0].value, doc2);
1842
1868
  });
1843
1869
  });
1844
1870
  describe("nested-string-array", () => {
@@ -1889,17 +1915,19 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1889
1915
  }),
1890
1916
  });
1891
1917
  await store.put(doc2);
1892
- const response = await search(store, new SearchRequest({
1918
+ const response = await search(store, {
1893
1919
  query: [
1894
1920
  new StringMatch({
1895
1921
  key: ["nested", "arr"],
1896
1922
  value: "värld",
1897
1923
  }),
1898
1924
  ],
1899
- }));
1900
- expect(response.results).to.have.length(1);
1901
- expect(response.results.map((x) => x.value.id)).to.have.members(["2"]);
1902
- checkDocument(response.results[0].value, doc2);
1925
+ });
1926
+ expect(response).to.have.length(1);
1927
+ expect(response.map((x) => x.value.id)).to.have.members([
1928
+ "2",
1929
+ ]);
1930
+ checkDocument(response[0].value, doc2);
1903
1931
  });
1904
1932
  });
1905
1933
  describe("nested multiple fields", () => {
@@ -1966,7 +1994,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1966
1994
  }),
1967
1995
  ],
1968
1996
  }));
1969
- const response = await search(store, new SearchRequest({
1997
+ const response = await search(store, {
1970
1998
  query: [
1971
1999
  new Nested({
1972
2000
  path: "array",
@@ -1982,10 +2010,10 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
1982
2010
  ]),
1983
2011
  }),
1984
2012
  ],
1985
- }));
1986
- expect(response.results).to.have.length(1);
1987
- expect(response.results[0].value.id).to.equal("1");
1988
- checkDocument(response.results[0].value, doc1);
2013
+ });
2014
+ expect(response).to.have.length(1);
2015
+ expect(response[0].value.id).to.equal("1");
2016
+ checkDocument(response[0].value, doc1);
1989
2017
  });
1990
2018
  it("nested partial match", async () => {
1991
2019
  // query nested without Nested query to match either or
@@ -2012,7 +2040,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2012
2040
  }),
2013
2041
  ],
2014
2042
  }));
2015
- const response = await search(store, new SearchRequest({
2043
+ const response = await search(store, {
2016
2044
  query: [
2017
2045
  new StringMatch({
2018
2046
  key: ["array", "a"],
@@ -2023,9 +2051,9 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2023
2051
  value: "world",
2024
2052
  }),
2025
2053
  ],
2026
- }));
2027
- expect(response.results).to.have.length(2);
2028
- checkDocument(response.results[0].value, doc1);
2054
+ });
2055
+ expect(response).to.have.length(2);
2056
+ checkDocument(response[0].value, doc1);
2029
2057
  });
2030
2058
  });
2031
2059
  });
@@ -2037,22 +2065,22 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2037
2065
  });
2038
2066
  it("can query one of the version", async () => {
2039
2067
  await store.put(new DocumentNext({ anotherField: "hello" }));
2040
- const result = await search(store, new SearchRequest({
2068
+ const result = await search(store, {
2041
2069
  query: new StringMatch({ key: "anotherField", value: "hello" }),
2042
- }));
2043
- expect(result.results).to.have.length(1);
2044
- const [doc] = result.results;
2070
+ });
2071
+ expect(result).to.have.length(1);
2072
+ const [doc] = result;
2045
2073
  expect(doc.value).to.be.instanceOf(DocumentNext);
2046
2074
  });
2047
2075
  it("can query multiple versions at once", async () => {
2048
2076
  let name = uuid();
2049
2077
  await store.put(new DocumentNext({ name }));
2050
2078
  await store.put(new DocumentNext({ name }));
2051
- const result = await search(store, new SearchRequest({
2079
+ const result = await search(store, {
2052
2080
  query: new StringMatch({ key: "name", value: name }),
2053
- }));
2054
- expect(result.results).to.have.length(2);
2055
- for (const doc of result.results) {
2081
+ });
2082
+ expect(result).to.have.length(2);
2083
+ for (const doc of result) {
2056
2084
  expect(doc.value).to.be.instanceOf(DocumentNext);
2057
2085
  }
2058
2086
  });
@@ -2064,9 +2092,9 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2064
2092
  await setupDefault();
2065
2093
  });
2066
2094
  it("filter field", async () => {
2067
- const results = await search(store, new SearchRequest({ query: [] }), { shape: { id: true } });
2068
- expect(results.results).to.have.length(4);
2069
- for (const result of results.results) {
2095
+ const results = await search(store, { query: [] }, { shape: { id: true } });
2096
+ expect(results).to.have.length(4);
2097
+ for (const result of results) {
2070
2098
  if (shapingSupported) {
2071
2099
  expect(Object.keys(result.value)).to.have.length(1);
2072
2100
  expect(result.value["id"]).to.exist;
@@ -2078,9 +2106,9 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2078
2106
  }
2079
2107
  });
2080
2108
  it("nested field", async () => {
2081
- const results = await search(store, new SearchRequest({ query: [] }), { shape: { nestedVec: { number: true } } });
2082
- expect(results.results).to.have.length(4);
2083
- for (const value of results.results) {
2109
+ const results = await search(store, { query: [] }, { shape: { nestedVec: [{ number: true }] } });
2110
+ expect(results).to.have.length(4);
2111
+ for (const value of results) {
2084
2112
  const arr = value.value["nestedVec"];
2085
2113
  expect(arr).to.be.exist;
2086
2114
  if (arr.length > 0) {
@@ -2141,22 +2169,27 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2141
2169
  index = await setup({ schema: NestedBoolQueryDocument });
2142
2170
  await index.store.put(new NestedBoolQueryDocument("1", new MultifieldNested(true, 1, ["1"])));
2143
2171
  await index.store.put(new NestedBoolQueryDocument("2", new MultifieldNested(false, 2, ["2"])));
2144
- const shapedResults = await iterate(index.store, new SearchRequest({
2145
- query: new BoolQuery({ key: ["nested", "bool"], value: false }),
2146
- fetch: 1,
2147
- })).all({ shape: { id: true } });
2172
+ const shapedResults = await index.store
2173
+ .iterate({
2174
+ query: new BoolQuery({
2175
+ key: ["nested", "bool"],
2176
+ value: false,
2177
+ }),
2178
+ }, { shape: { id: true } })
2179
+ .all();
2148
2180
  expect(shapedResults).to.have.length(1);
2149
2181
  expect(shapedResults[0].value.id).to.equal("2");
2150
2182
  if (shapingSupported) {
2151
- expect(shapedResults[0].value.nested).to.be.undefined;
2183
+ expect(shapedResults[0].value["nested"]).to.be.undefined;
2152
2184
  }
2153
2185
  else {
2154
- expect(shapedResults[0].value.nested).to.exist;
2186
+ expect(shapedResults[0].value["nested"]).to.exist;
2155
2187
  }
2156
- const unshapedResults = await iterate(index.store, new SearchRequest({
2188
+ const unshapedResults = await index.store
2189
+ .iterate({
2157
2190
  query: new BoolQuery({ key: ["nested", "bool"], value: false }),
2158
- fetch: 1,
2159
- })).all();
2191
+ })
2192
+ .all();
2160
2193
  expect(unshapedResults).to.have.length(1);
2161
2194
  expect(unshapedResults[0].value.id).to.equal("2");
2162
2195
  expect(unshapedResults[0].value.nested).to.exist;
@@ -2167,17 +2200,19 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2167
2200
  const d2 = new NestedBoolQueryDocument("2", new MultifieldNested(false, 2, ["2"]));
2168
2201
  await index.store.put(d1);
2169
2202
  await index.store.put(d2);
2170
- const unshapedResults = await iterate(index.store, new SearchRequest({
2203
+ const unshapedResults = await index.store
2204
+ .iterate({
2171
2205
  query: new StringMatch({ key: ["id"], value: "2" }),
2172
- fetch: 1,
2173
- })).all();
2206
+ })
2207
+ .all();
2174
2208
  expect(unshapedResults).to.have.length(1);
2175
2209
  expect(unshapedResults[0].value.id).to.equal(d2.id);
2176
2210
  expect(unshapedResults[0].value.nested).to.deep.equal(d2.nested);
2177
- const shapedResults = await iterate(index.store, new SearchRequest({
2211
+ const shapedResults = await index.store
2212
+ .iterate({
2178
2213
  query: new StringMatch({ key: ["id"], value: "2" }),
2179
- fetch: 1,
2180
- })).all({ shape: { id: true, nested: { bool: true } } });
2214
+ }, { shape: { id: true, nested: { bool: true } } })
2215
+ .all();
2181
2216
  expect(shapedResults).to.have.length(1);
2182
2217
  expect(shapedResults[0].value.id).to.equal(d2.id);
2183
2218
  if (shapingSupported) {
@@ -2271,22 +2306,27 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2271
2306
  index = await setup({ schema: NestedBoolQueryDocument });
2272
2307
  await index.store.put(new NestedBoolQueryDocument("1", new MultifieldNested(true, 1, ["1"])));
2273
2308
  await index.store.put(new NestedBoolQueryDocument("2", new MultifieldNested(false, 2, ["2"])));
2274
- const shapedResults = await iterate(index.store, new SearchRequest({
2275
- query: new BoolQuery({ key: ["nested", "bool"], value: false }),
2276
- fetch: 1,
2277
- })).all({ shape: { id: true } });
2309
+ const shapedResults = await index.store
2310
+ .iterate({
2311
+ query: new BoolQuery({
2312
+ key: ["nested", "bool"],
2313
+ value: false,
2314
+ }),
2315
+ }, { shape: { id: true } })
2316
+ .all();
2278
2317
  expect(shapedResults).to.have.length(1);
2279
2318
  expect(shapedResults[0].value.id).to.equal("2");
2280
2319
  if (shapingSupported) {
2281
- expect(shapedResults[0].value.nested).to.be.undefined;
2320
+ expect(shapedResults[0].value["nested"]).to.be.undefined;
2282
2321
  }
2283
2322
  else {
2284
- expect(shapedResults[0].value.nested).to.exist;
2323
+ expect(shapedResults[0].value["nested"]).to.exist;
2285
2324
  }
2286
- const unshapedResults = await iterate(index.store, new SearchRequest({
2325
+ const unshapedResults = await index.store
2326
+ .iterate({
2287
2327
  query: new BoolQuery({ key: ["nested", "bool"], value: false }),
2288
- fetch: 1,
2289
- })).all();
2328
+ })
2329
+ .all();
2290
2330
  expect(unshapedResults).to.have.length(1);
2291
2331
  expect(unshapedResults[0].value.id).to.equal("2");
2292
2332
  expect(unshapedResults[0].value.nested).to.exist;
@@ -2297,17 +2337,19 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2297
2337
  const d2 = new NestedBoolQueryDocument("2", new MultifieldNested(false, 2, ["2"]));
2298
2338
  await index.store.put(d1);
2299
2339
  await index.store.put(d2);
2300
- const unshapedResults = await iterate(index.store, new SearchRequest({
2340
+ const unshapedResults = await index.store
2341
+ .iterate({
2301
2342
  query: new StringMatch({ key: ["id"], value: "2" }),
2302
- fetch: 1,
2303
- })).all();
2343
+ })
2344
+ .all();
2304
2345
  expect(unshapedResults).to.have.length(1);
2305
2346
  expect(unshapedResults[0].value.id).to.equal(d2.id);
2306
2347
  expect(unshapedResults[0].value.nested).to.deep.equal(d2.nested);
2307
- const shapedResults = await iterate(index.store, new SearchRequest({
2348
+ const shapedResults = await index.store
2349
+ .iterate({
2308
2350
  query: new StringMatch({ key: ["id"], value: "2" }),
2309
- fetch: 1,
2310
- })).all({ shape: { id: true, nested: { bool: true } } });
2351
+ }, { shape: { id: true, nested: { bool: true } } })
2352
+ .all();
2311
2353
  expect(shapedResults).to.have.length(1);
2312
2354
  expect(shapedResults[0].value.id).to.equal(d2.id);
2313
2355
  if (shapingSupported) {
@@ -2367,22 +2409,27 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2367
2409
  index = await setup({ schema: NestedBoolQueryDocument });
2368
2410
  await index.store.put(new NestedBoolQueryDocument("1", new MultifieldNested(true, 1, ["1"])));
2369
2411
  await index.store.put(new NestedBoolQueryDocument("2", new MultifieldNested(false, 2, ["2"])));
2370
- const shapedResults = await iterate(index.store, new SearchRequest({
2371
- query: new BoolQuery({ key: ["nested", "bool"], value: false }),
2372
- fetch: 1,
2373
- })).all({ shape: { id: true } });
2412
+ const shapedResults = await index.store
2413
+ .iterate({
2414
+ query: new BoolQuery({
2415
+ key: ["nested", "bool"],
2416
+ value: false,
2417
+ }),
2418
+ }, { shape: { id: true } })
2419
+ .all();
2374
2420
  expect(shapedResults).to.have.length(1);
2375
2421
  expect(shapedResults[0].value.id).to.equal("2");
2376
2422
  if (shapingSupported) {
2377
- expect(shapedResults[0].value.nested).to.be.undefined;
2423
+ expect(shapedResults[0].value["nested"]).to.be.undefined;
2378
2424
  }
2379
2425
  else {
2380
- expect(shapedResults[0].value.nested).to.exist;
2426
+ expect(shapedResults[0].value["nested"]).to.exist;
2381
2427
  }
2382
- const unshapedResults = await iterate(index.store, new SearchRequest({
2428
+ const unshapedResults = await index.store
2429
+ .iterate({
2383
2430
  query: new BoolQuery({ key: ["nested", "bool"], value: false }),
2384
- fetch: 1,
2385
- })).all();
2431
+ })
2432
+ .all();
2386
2433
  expect(unshapedResults).to.have.length(1);
2387
2434
  expect(unshapedResults[0].value.id).to.equal("2");
2388
2435
  expect(unshapedResults[0].value.nested).to.exist;
@@ -2393,10 +2440,11 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2393
2440
  const d2 = new NestedBoolQueryDocument("2", new MultifieldNested(false, 2, ["2"]));
2394
2441
  await index.store.put(d1);
2395
2442
  await index.store.put(d2);
2396
- const shapedResults = await iterate(index.store, new SearchRequest({
2443
+ const shapedResults = await index.store
2444
+ .iterate({
2397
2445
  query: new StringMatch({ key: ["id"], value: "2" }),
2398
- fetch: 1,
2399
- })).all({ shape: { id: true, nested: { bool: true } } });
2446
+ }, { shape: { id: true, nested: [{ bool: true }] } })
2447
+ .all();
2400
2448
  expect(shapedResults).to.have.length(1);
2401
2449
  expect(shapedResults[0].value.id).to.equal(d2.id);
2402
2450
  if (shapingSupported) {
@@ -2407,14 +2455,28 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2407
2455
  else {
2408
2456
  expect(shapedResults[0].value.nested[0]).to.deep.equal(d2.nested[0]);
2409
2457
  }
2410
- const unshapedResults = await iterate(index.store, new SearchRequest({
2458
+ const unshapedResults = await index.store
2459
+ .iterate({
2411
2460
  query: new StringMatch({ key: ["id"], value: "2" }),
2412
- fetch: 1,
2413
- })).all();
2461
+ })
2462
+ .all();
2414
2463
  expect(unshapedResults).to.have.length(1);
2415
2464
  expect(unshapedResults[0].value.id).to.equal(d2.id);
2416
2465
  expect(unshapedResults[0].value.nested[0]).to.deep.equal(d2.nested[0]);
2417
2466
  });
2467
+ it("true resolves fully", async () => {
2468
+ index = await setup({ schema: NestedBoolQueryDocument });
2469
+ const d1 = new NestedBoolQueryDocument("1", new MultifieldNested(true, 1, ["1"]));
2470
+ await index.store.put(d1);
2471
+ const shapedResults = await index.store
2472
+ .iterate({
2473
+ query: [],
2474
+ }, { shape: { id: true, nested: true } })
2475
+ .all();
2476
+ expect(shapedResults).to.have.length(1);
2477
+ expect(shapedResults[0].value.id).to.equal(d1.id);
2478
+ expect(shapedResults[0].value.nested[0]).to.deep.equal(d1.nested[0]);
2479
+ });
2418
2480
  });
2419
2481
  });
2420
2482
  });
@@ -2439,22 +2501,27 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2439
2501
  new Sort({ direction: SortDirection.ASC, key: "number" }),
2440
2502
  ]) => {
2441
2503
  await waitForResolved(async () => {
2442
- const req = new SearchRequest({
2504
+ const req = {
2443
2505
  query,
2444
2506
  sort,
2445
- });
2446
- const iterator = iterate(store, req);
2507
+ };
2508
+ const iterator = store.iterate(req);
2509
+ // No fetches has been made, so we don't know whether we are done yet
2510
+ expect(iterator.done()).to.be.undefined;
2447
2511
  if (batches.length === 0) {
2448
- // No fetches has been made, so we don't know whether we are done yet
2449
- expect(iterator.done()).to.be.false;
2512
+ await assertIteratorIsDone(iterator);
2450
2513
  }
2451
2514
  else {
2515
+ let first = true;
2452
2516
  for (const batch of batches) {
2453
- expect(iterator.done()).to.be.false;
2517
+ first
2518
+ ? expect(iterator.done()).to.be.undefined
2519
+ : expect(iterator.done()).to.be.false;
2520
+ first = false;
2454
2521
  const next = await iterator.next(batch.length);
2455
- expect(next.results.map((x) => Number(x.value.number))).to.deep.equal(batch.map((x) => Number(x)));
2522
+ expect(next.map((x) => Number(x.value.number))).to.deep.equal(batch.map((x) => Number(x)));
2456
2523
  }
2457
- expect(iterator.done()).to.be.true;
2524
+ await assertIteratorIsDone(iterator);
2458
2525
  }
2459
2526
  });
2460
2527
  };
@@ -2481,50 +2548,38 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2481
2548
  await put(1);
2482
2549
  await put(2);
2483
2550
  {
2484
- const iterator = await iterate(store, new SearchRequest({
2551
+ const iterator = store.iterate({
2485
2552
  query: [],
2486
2553
  sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
2487
- }));
2488
- expect(iterator.done()).to.be.false;
2554
+ });
2555
+ expect(iterator.done()).to.be.undefined;
2489
2556
  const next = await iterator.next(3);
2490
- expect(next.results.map((x) => x.value.name)).to.deep.equal([
2491
- "0",
2492
- "1",
2493
- "2",
2494
- ]);
2495
- expect(iterator.done()).to.be.true;
2557
+ expect(next.map((x) => x.value.name)).to.deep.equal(["0", "1", "2"]);
2558
+ await assertIteratorIsDone(iterator);
2496
2559
  }
2497
2560
  {
2498
- const iterator = await iterate(store, new SearchRequest({
2561
+ const iterator = store.iterate({
2499
2562
  query: [],
2500
2563
  sort: [new Sort({ direction: SortDirection.DESC, key: "name" })],
2501
- }));
2502
- expect(iterator.done()).to.be.false;
2564
+ });
2565
+ expect(iterator.done()).to.be.undefined;
2503
2566
  const next = await iterator.next(3);
2504
- expect(next.results.map((x) => x.value.name)).to.deep.equal([
2505
- "2",
2506
- "1",
2507
- "0",
2508
- ]);
2509
- expect(iterator.done()).to.be.true;
2567
+ expect(next.map((x) => x.value.name)).to.deep.equal(["2", "1", "0"]);
2568
+ await assertIteratorIsDone(iterator);
2510
2569
  }
2511
2570
  });
2512
2571
  it("strings", async () => {
2513
2572
  await put(0);
2514
2573
  await put(1);
2515
2574
  await put(2);
2516
- const iterator = await iterate(store, new SearchRequest({
2575
+ const iterator = await store.iterate({
2517
2576
  query: [],
2518
2577
  sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
2519
- }));
2520
- expect(iterator.done()).to.be.false;
2578
+ });
2579
+ expect(iterator.done()).to.be.undefined;
2521
2580
  const next = await iterator.next(3);
2522
- expect(next.results.map((x) => x.value.name)).to.deep.equal([
2523
- "0",
2524
- "1",
2525
- "2",
2526
- ]);
2527
- expect(iterator.done()).to.be.true;
2581
+ expect(next.map((x) => x.value.name)).to.deep.equal(["0", "1", "2"]);
2582
+ await assertIteratorIsDone(iterator);
2528
2583
  });
2529
2584
  describe("nested", () => {
2530
2585
  it("variants", async () => {
@@ -2538,17 +2593,18 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2538
2593
  });
2539
2594
  await store.put(doc1);
2540
2595
  await store.put(doc2);
2541
- const iterator = iterate(store, new SearchRequest({
2596
+ const iterator = store.iterate({
2542
2597
  sort: [
2543
2598
  new Sort({
2544
2599
  direction: SortDirection.DESC,
2545
2600
  key: ["nested", "number"],
2546
2601
  }),
2547
2602
  ],
2548
- }));
2549
- expect(iterator.done()).to.be.false;
2603
+ });
2604
+ expect(iterator.done()).to.be.undefined;
2550
2605
  const next = await iterator.next(2);
2551
- expect(next.results.map((x) => x.value.id)).to.deep.equal(["2", "1"]);
2606
+ expect(next.map((x) => x.value.id)).to.deep.equal(["2", "1"]);
2607
+ await assertIteratorIsDone(iterator);
2552
2608
  });
2553
2609
  describe("nested-nested-invariant", () => {
2554
2610
  class V0 {
@@ -2595,20 +2651,18 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2595
2651
  await store.put(doc2);
2596
2652
  });
2597
2653
  it("nested-variants", async () => {
2598
- const iterator = iterate(store, new SearchRequest({
2654
+ const iterator = store.iterate({
2599
2655
  sort: [
2600
2656
  new Sort({
2601
2657
  direction: SortDirection.DESC,
2602
2658
  key: ["nested", "v0", "number"],
2603
2659
  }),
2604
2660
  ],
2605
- }));
2606
- expect(iterator.done()).to.be.false;
2661
+ });
2662
+ expect(iterator.done()).to.be.undefined;
2607
2663
  const next = await iterator.next(2);
2608
- expect(next.results.map((x) => x.value.id)).to.deep.equal([
2609
- "2",
2610
- "1",
2611
- ]);
2664
+ expect(next.map((x) => x.value.id)).to.deep.equal(["2", "1"]);
2665
+ await assertIteratorIsDone(iterator);
2612
2666
  });
2613
2667
  });
2614
2668
  describe("variant-nested-invariant", () => {
@@ -2660,79 +2714,76 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2660
2714
  await store.put(doc2);
2661
2715
  });
2662
2716
  it("nested-variants", async () => {
2663
- const iterator = iterate(store, new SearchRequest({
2717
+ const iterator = store.iterate({
2664
2718
  sort: [
2665
2719
  new Sort({
2666
2720
  direction: SortDirection.DESC,
2667
2721
  key: ["nested", "v0", "number"],
2668
2722
  }),
2669
2723
  ],
2670
- }));
2671
- expect(iterator.done()).to.be.false;
2724
+ });
2725
+ expect(iterator.done()).to.be.undefined;
2672
2726
  const next = await iterator.next(2);
2673
- expect(next.results.map((x) => x.value.id)).to.deep.equal([
2674
- "2",
2675
- "1",
2676
- ]);
2727
+ expect(next.map((x) => x.value.id)).to.deep.equal(["2", "1"]);
2677
2728
  });
2678
2729
  });
2679
2730
  /* TODO (requires sort join interleaving)
2680
2731
 
2681
2732
  describe("nested-nested-variant", () => {
2682
-
2733
+
2683
2734
  abstract class Base { }
2684
-
2735
+
2685
2736
  @variant(0)
2686
2737
  class V0 extends Base {
2687
-
2738
+
2688
2739
  @field({ type: 'u64' })
2689
2740
  number: bigint;
2690
-
2741
+
2691
2742
  constructor(number: bigint) {
2692
2743
  super()
2693
2744
  this.number = number;
2694
2745
  }
2695
2746
  }
2696
-
2747
+
2697
2748
  @variant(1)
2698
2749
  class V1 extends Base {
2699
-
2750
+
2700
2751
  @field({ type: 'u64' })
2701
2752
  number: bigint;
2702
-
2753
+
2703
2754
  constructor(number: bigint) {
2704
2755
  super()
2705
2756
  this.number = number;
2706
2757
  }
2707
2758
  }
2708
-
2759
+
2709
2760
  class NestedValue {
2710
2761
  @field({ type: Base })
2711
2762
  v0: Base;
2712
-
2763
+
2713
2764
  constructor(v0?: Base) {
2714
2765
  this.v0 = v0;
2715
2766
  }
2716
2767
  }
2717
-
2768
+
2718
2769
  class Document {
2719
2770
  @id({ type: 'string' })
2720
2771
  id: string;
2721
-
2772
+
2722
2773
  @field({ type: NestedValue })
2723
2774
  nested: NestedValue;
2724
-
2775
+
2725
2776
  constructor(id: string, nested: NestedValue) {
2726
2777
  this.id = id;
2727
2778
  this.nested = nested;
2728
2779
  }
2729
2780
  }
2730
-
2781
+
2731
2782
  const doc1 = new Document("1", new NestedValue(new V0(1n)));
2732
2783
  const doc2 = new Document("2", new NestedValue(new V0(2n)));
2733
2784
  const doc3 = new Document("3", new NestedValue(new V1(3n)));
2734
2785
  const doc4 = new Document("4", new NestedValue(new V1(4n)));
2735
-
2786
+
2736
2787
  beforeEach(async () => {
2737
2788
  await setup({ schema: Document });
2738
2789
  await store.put(doc1);
@@ -2740,15 +2791,15 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2740
2791
  await store.put(doc3);
2741
2792
  await store.put(doc4);
2742
2793
  });
2743
-
2794
+
2744
2795
  it("nested-variants", async () => {
2745
- const iterator = iterate(store, new SearchRequest({ sort: [new Sort({ direction: SortDirection.DESC, key: ["nested", "v0", "number"] })] }));
2796
+ const iterator = iterate(store, ({ sort: [new Sort({ direction: SortDirection.DESC, key: ["nested", "v0", "number"] })] }));
2746
2797
  expect(iterator.done()).to.be.false;
2747
2798
  const next = await iterator.next(4);
2748
2799
  expect(next.results.map((x) => x.value.id)).to.deep.equal(["4", "3", "2", "1"]);
2749
-
2800
+
2750
2801
  })
2751
-
2802
+
2752
2803
  })*/
2753
2804
  /* TODO
2754
2805
  it("array sort", async () => {
@@ -2774,7 +2825,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2774
2825
  await store.put(doc2);
2775
2826
  await store.put(doc3);
2776
2827
 
2777
- const iterator = iterate(store, new SearchRequest({ query: [new IntegerCompare({ key: 'number', compare: 'gte', value: 102n }), new Nested({ path: 'nestedVec', id: 'path-to-nested', query: [new IntegerCompare({ key: 'number', compare: 'gte', value: 200 })] })], sort: [new Sort({ direction: SortDirection.DESC, key: ["path-to-nested", "number"] })] }));
2828
+ const iterator = iterate(store, ({ query: [new IntegerCompare({ key: 'number', compare: 'gte', value: 102n }), new Nested({ path: 'nestedVec', id: 'path-to-nested', query: [new IntegerCompare({ key: 'number', compare: 'gte', value: 200 })] })], sort: [new Sort({ direction: SortDirection.DESC, key: ["path-to-nested", "number"] })] }));
2778
2829
  expect(iterator.done()).to.be.false;
2779
2830
  const next = await iterator.next(2);
2780
2831
  expect(next.results.map((x) => x.value.id)).to.deep.equal(["2", "1"]);
@@ -2786,40 +2837,43 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2786
2837
  await put(0);
2787
2838
  await put(1);
2788
2839
  await put(2);
2789
- const request = new SearchRequest({
2840
+ const request = {
2790
2841
  query: [],
2791
- });
2792
- const iterator = iterate(store, request);
2793
- expect(iterator.done()).to.be.false;
2842
+ };
2843
+ const iterator = store.iterate(request);
2844
+ expect(iterator.done()).to.be.undefined;
2794
2845
  await iterator.next(2); // fetch some, but not all
2795
- expect(store.getPending(request.idString)).equal(1);
2846
+ expect(iterator.done()).to.be.false;
2847
+ expect(await iterator.pending()).equal(1);
2796
2848
  await iterator.close();
2797
- await waitForResolved(() => expect(store.getPending(request.idString)).equal(undefined), { timeout: 3000, delayInterval: 50 });
2849
+ expect(await iterator.pending()).equal(0);
2850
+ expect(iterator.done()).to.be.true;
2798
2851
  });
2799
2852
  it("end of iterator", async () => {
2800
2853
  await put(0);
2801
2854
  await put(1);
2802
2855
  await put(2);
2803
- const request = new SearchRequest({
2856
+ const request = {
2804
2857
  query: [],
2805
- });
2806
- const iterator = await iterate(store, request);
2807
- expect(iterator.done()).to.be.false;
2858
+ };
2859
+ const iterator = store.iterate(request);
2860
+ expect(iterator.done()).to.be.undefined;
2808
2861
  await iterator.next(3); // fetch all
2809
- await waitForResolved(() => expect(store.getPending(request.idString)).equal(undefined), { timeout: 3000, delayInterval: 50 });
2862
+ expect(await iterator.pending()).equal(0);
2863
+ expect(iterator.done()).to.be.true;
2810
2864
  });
2811
2865
  it("end of iterator, multiple nexts", async () => {
2812
2866
  await put(0);
2813
2867
  await put(1);
2814
2868
  await put(2);
2815
- const request = new SearchRequest({
2869
+ const request = {
2816
2870
  query: [],
2817
- });
2818
- const iterator = await iterate(store, request);
2871
+ };
2872
+ const iterator = store.iterate(request);
2819
2873
  await iterator.next(2);
2820
2874
  await iterator.next(1);
2821
- expect(iterator.done()).to.be.true;
2822
- await waitForResolved(() => expect(store.getPending(request.idString)).equal(undefined), { timeout: 3000, delayInterval: 50 });
2875
+ assertIteratorIsDone(iterator);
2876
+ expect(await iterator.pending()).equal(0);
2823
2877
  });
2824
2878
  });
2825
2879
  // TODO test iterator.close() to stop pending promises
@@ -2829,14 +2883,14 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2829
2883
  describe("sum", () => {
2830
2884
  it("it returns sum", async () => {
2831
2885
  await setupDefault();
2832
- const sum = await store.sum(new SumRequest({ key: "number" }));
2886
+ const sum = await store.sum({ key: "number" });
2833
2887
  typeof sum === "bigint"
2834
2888
  ? expect(sum).to.equal(6n)
2835
2889
  : expect(sum).to.equal(6);
2836
2890
  });
2837
2891
  it("it returns sum with query", async () => {
2838
2892
  await setupDefault();
2839
- const sum = await store.sum(new SumRequest({
2893
+ const sum = await store.sum({
2840
2894
  key: "number",
2841
2895
  query: [
2842
2896
  new StringMatch({
@@ -2846,7 +2900,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2846
2900
  caseInsensitive: true,
2847
2901
  }),
2848
2902
  ],
2849
- }));
2903
+ });
2850
2904
  typeof sum === "bigint"
2851
2905
  ? expect(sum).to.equal(2n)
2852
2906
  : expect(sum).to.equal(2);
@@ -2867,9 +2921,9 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2867
2921
  await store.put(doc1);
2868
2922
  await store.put(doc2);
2869
2923
  await store.put(doc3);
2870
- const sum = await store.sum(new SumRequest({
2924
+ const sum = await store.sum({
2871
2925
  key: ["nested", "number"],
2872
- }));
2926
+ });
2873
2927
  typeof sum === "bigint"
2874
2928
  ? expect(sum).to.equal(3n)
2875
2929
  : expect(sum).to.equal(3);
@@ -2878,12 +2932,12 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2878
2932
  describe("count", () => {
2879
2933
  it("it returns count", async () => {
2880
2934
  await setupDefault();
2881
- const sum = await store.count(new CountRequest());
2935
+ const sum = await store.count();
2882
2936
  expect(sum).to.equal(4);
2883
2937
  });
2884
2938
  it("it returns count with query", async () => {
2885
2939
  await setupDefault();
2886
- const sum = await store.count(new CountRequest({
2940
+ const sum = await store.count({
2887
2941
  query: [
2888
2942
  new StringMatch({
2889
2943
  key: "tags",
@@ -2892,14 +2946,14 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2892
2946
  caseInsensitive: true,
2893
2947
  }),
2894
2948
  ],
2895
- }));
2949
+ });
2896
2950
  expect(sum).to.equal(1);
2897
2951
  });
2898
2952
  });
2899
2953
  describe("delete", () => {
2900
2954
  it("delete with query", async () => {
2901
2955
  await setupDefault();
2902
- await store.del(new DeleteRequest({
2956
+ await store.del({
2903
2957
  query: [
2904
2958
  new StringMatch({
2905
2959
  key: "tags",
@@ -2908,7 +2962,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2908
2962
  caseInsensitive: true,
2909
2963
  }),
2910
2964
  ],
2911
- }));
2965
+ });
2912
2966
  expect(await store.getSize()).to.equal(3);
2913
2967
  });
2914
2968
  });
@@ -2938,7 +2992,7 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
2938
2992
  await setupDefault();
2939
2993
  for (let i = 0; i < 100; i++) {
2940
2994
  promises.push((async () => {
2941
- results.push(await store.count(new CountRequest()));
2995
+ results.push(await store.count());
2942
2996
  })());
2943
2997
  }
2944
2998
  await Promise.all(promises);
@@ -3079,9 +3133,9 @@ export const tests = (createIndicies, type = "transient", shapingSupported) => {
3079
3133
  schema: AnotherDocument,
3080
3134
  });
3081
3135
  await aIndex.put(new Document({ id: "a", name: "hello", number: 1n, tags: [] }));
3082
- expect(await aIndex.count(new CountRequest({ query: { id: "a" } }))).to.eq(1);
3136
+ expect(await aIndex.count({ query: { id: "a" } })).to.eq(1);
3083
3137
  await bIndex.put(new AnotherDocument("b"));
3084
- expect(await bIndex.count(new CountRequest({ query: { id: "b" } }))).to.eq(1);
3138
+ expect(await bIndex.count({ query: { id: "b" } })).to.eq(1);
3085
3139
  });
3086
3140
  });
3087
3141
  });
@@ -3132,7 +3186,7 @@ describe("multi-dimensional", () => {
3132
3186
  promises.push(
3133
3187
  search(
3134
3188
  store,
3135
- new SearchRequest({
3189
+ ({
3136
3190
  query: [
3137
3191
  new IntegerCompare({
3138
3192
  key: "number",
@@ -3147,7 +3201,7 @@ describe("multi-dimensional", () => {
3147
3201
  promises.push(
3148
3202
  search(
3149
3203
  store,
3150
- new SearchRequest({
3204
+ ({
3151
3205
  query: [
3152
3206
  new IntegerCompare({
3153
3207
  key: "number",