electrodb 3.5.3 → 3.6.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/index.d.ts +627 -276
- package/index.js +5 -1
- package/package.json +1 -1
- package/src/clauses.js +1 -0
- package/src/client.js +6 -0
- package/src/entity.js +171 -89
- package/src/errors.js +19 -12
- package/src/operations.js +33 -23
- package/src/schema.js +25 -2
- package/src/service.js +23 -12
- package/src/types.js +15 -0
- package/src/util.js +11 -0
- package/src/validations.js +22 -1
package/index.d.ts
CHANGED
|
@@ -258,8 +258,8 @@ export interface CollectionWhereOperations {
|
|
|
258
258
|
export type CollectionWhereCallback<
|
|
259
259
|
E extends { [name: string]: Entity<any, any, any, any> },
|
|
260
260
|
I extends Partial<AllEntityAttributes<E>>,
|
|
261
|
-
> =
|
|
262
|
-
attributes:
|
|
261
|
+
> = (
|
|
262
|
+
attributes: { [A in keyof I]: WhereAttributeSymbol<I[A]> },
|
|
263
263
|
operations: CollectionWhereOperations,
|
|
264
264
|
) => string;
|
|
265
265
|
|
|
@@ -270,8 +270,20 @@ export type CollectionWhereClause<
|
|
|
270
270
|
C extends string,
|
|
271
271
|
S extends Schema<A, F, C>,
|
|
272
272
|
I extends Partial<AllEntityAttributes<E>>,
|
|
273
|
+
Collections extends CollectionAssociations<E>,
|
|
274
|
+
Collection extends keyof Collections,
|
|
273
275
|
T,
|
|
274
|
-
> = (
|
|
276
|
+
> = (
|
|
277
|
+
where: Pick<
|
|
278
|
+
I,
|
|
279
|
+
CollectionProjectedAttributeNames<E, Collections, Collection>
|
|
280
|
+
> extends Partial<AllEntityAttributes<E>>
|
|
281
|
+
? CollectionWhereCallback<
|
|
282
|
+
E,
|
|
283
|
+
Pick<I, CollectionProjectedAttributeNames<E, Collections, Collection>>
|
|
284
|
+
>
|
|
285
|
+
: never,
|
|
286
|
+
) => T;
|
|
275
287
|
|
|
276
288
|
export interface ServiceWhereRecordsActionOptions<
|
|
277
289
|
E extends { [name: string]: Entity<any, any, any, any> },
|
|
@@ -280,10 +292,11 @@ export interface ServiceWhereRecordsActionOptions<
|
|
|
280
292
|
C extends string,
|
|
281
293
|
S extends Schema<A, F, C>,
|
|
282
294
|
I extends Partial<AllEntityAttributes<E>>,
|
|
283
|
-
|
|
295
|
+
Collections extends CollectionAssociations<E>,
|
|
296
|
+
Collection extends keyof Collections,
|
|
284
297
|
IndexCompositeAttributes,
|
|
285
298
|
> {
|
|
286
|
-
go: ServiceQueryRecordsGo<
|
|
299
|
+
go: ServiceQueryRecordsGo<E, Collections, Collection, keyof I>;
|
|
287
300
|
params: ParamRecord;
|
|
288
301
|
where: CollectionWhereClause<
|
|
289
302
|
E,
|
|
@@ -292,6 +305,8 @@ export interface ServiceWhereRecordsActionOptions<
|
|
|
292
305
|
C,
|
|
293
306
|
S,
|
|
294
307
|
I,
|
|
308
|
+
Collections,
|
|
309
|
+
Collection,
|
|
295
310
|
ServiceWhereRecordsActionOptions<
|
|
296
311
|
E,
|
|
297
312
|
A,
|
|
@@ -299,7 +314,8 @@ export interface ServiceWhereRecordsActionOptions<
|
|
|
299
314
|
C,
|
|
300
315
|
S,
|
|
301
316
|
I,
|
|
302
|
-
|
|
317
|
+
Collections,
|
|
318
|
+
Collection,
|
|
303
319
|
IndexCompositeAttributes
|
|
304
320
|
>
|
|
305
321
|
>;
|
|
@@ -574,32 +590,144 @@ export type CollectionQueries<
|
|
|
574
590
|
>[0]
|
|
575
591
|
>,
|
|
576
592
|
) => {
|
|
577
|
-
go: ServiceQueryRecordsGo<
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
593
|
+
go: ServiceQueryRecordsGo<
|
|
594
|
+
E,
|
|
595
|
+
Collections,
|
|
596
|
+
Collection,
|
|
597
|
+
keyof Pick<
|
|
598
|
+
AllEntityAttributes<E>,
|
|
599
|
+
Extract<
|
|
600
|
+
AllEntityAttributeNames<E>,
|
|
601
|
+
CollectionAttributes<E, Collections>[Collection]
|
|
602
|
+
>
|
|
603
|
+
>
|
|
604
|
+
>;
|
|
589
605
|
params: ParamRecord;
|
|
590
606
|
where: {
|
|
591
607
|
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
592
|
-
? E[EntityResultName] extends Entity<
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
608
|
+
? E[EntityResultName] extends Entity<any, any, any, any>
|
|
609
|
+
? E[EntityResultName]["schema"] extends Schema<
|
|
610
|
+
infer A,
|
|
611
|
+
infer F,
|
|
612
|
+
infer C
|
|
613
|
+
>
|
|
614
|
+
? Collection extends keyof EntityCollections<
|
|
615
|
+
A,
|
|
616
|
+
F,
|
|
617
|
+
C,
|
|
618
|
+
E[EntityResultName]["schema"]
|
|
619
|
+
>
|
|
620
|
+
? Pick<
|
|
621
|
+
AllEntityAttributes<E>,
|
|
622
|
+
Extract<
|
|
623
|
+
AllEntityAttributeNames<E>,
|
|
624
|
+
CollectionAttributes<E, Collections>[Collection]
|
|
625
|
+
>
|
|
626
|
+
> extends Partial<AllEntityAttributes<E>>
|
|
627
|
+
? CollectionWhereClause<
|
|
628
|
+
E,
|
|
629
|
+
A,
|
|
630
|
+
F,
|
|
631
|
+
C,
|
|
632
|
+
E[EntityResultName]["schema"],
|
|
633
|
+
Pick<
|
|
634
|
+
AllEntityAttributes<E>,
|
|
635
|
+
Extract<
|
|
636
|
+
AllEntityAttributeNames<E>,
|
|
637
|
+
CollectionAttributes<E, Collections>[Collection]
|
|
638
|
+
>
|
|
639
|
+
>,
|
|
640
|
+
Collections,
|
|
641
|
+
Collection,
|
|
642
|
+
ServiceWhereRecordsActionOptions<
|
|
643
|
+
E,
|
|
644
|
+
A,
|
|
645
|
+
F,
|
|
646
|
+
C,
|
|
647
|
+
E[EntityResultName]["schema"],
|
|
648
|
+
Pick<
|
|
649
|
+
AllEntityAttributes<E>,
|
|
650
|
+
Extract<
|
|
651
|
+
AllEntityAttributeNames<E>,
|
|
652
|
+
CollectionAttributes<E, Collections>[Collection]
|
|
653
|
+
>
|
|
654
|
+
>,
|
|
655
|
+
Collections,
|
|
656
|
+
Collection,
|
|
657
|
+
Partial<
|
|
658
|
+
Spread<
|
|
659
|
+
Collection extends keyof CollectionPageAttributes<
|
|
660
|
+
E,
|
|
661
|
+
Collections
|
|
662
|
+
>
|
|
663
|
+
? CollectionPageAttributes<
|
|
664
|
+
E,
|
|
665
|
+
Collections
|
|
666
|
+
>[Collection]
|
|
667
|
+
: {},
|
|
668
|
+
Collection extends keyof CollectionIndexAttributes<
|
|
669
|
+
E,
|
|
670
|
+
Collections
|
|
671
|
+
>
|
|
672
|
+
? CollectionIndexAttributes<
|
|
673
|
+
E,
|
|
674
|
+
Collections
|
|
675
|
+
>[Collection]
|
|
676
|
+
: {}
|
|
677
|
+
>
|
|
678
|
+
>
|
|
679
|
+
>
|
|
680
|
+
>
|
|
681
|
+
: never
|
|
682
|
+
: never
|
|
683
|
+
: never
|
|
684
|
+
: never
|
|
685
|
+
: never;
|
|
686
|
+
}[Collections[Collection]];
|
|
687
|
+
}
|
|
688
|
+
: never;
|
|
689
|
+
}[keyof E];
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
type ClusteredCollectionOperations<
|
|
693
|
+
E extends { [name: string]: Entity<any, any, any, any> },
|
|
694
|
+
Collections extends ClusteredCollectionAssociations<E>,
|
|
695
|
+
Collection extends keyof Collections,
|
|
696
|
+
EntityName extends keyof E,
|
|
697
|
+
> = EntityName extends Collections[Collection]
|
|
698
|
+
? {
|
|
699
|
+
go: ServiceQueryRecordsGo<
|
|
700
|
+
E,
|
|
701
|
+
Collections,
|
|
702
|
+
Collection,
|
|
703
|
+
keyof Pick<
|
|
704
|
+
AllEntityAttributes<E>,
|
|
705
|
+
Extract<
|
|
706
|
+
AllEntityAttributeNames<E>,
|
|
707
|
+
ClusteredCollectionAttributes<E, Collections>[Collection]
|
|
708
|
+
>
|
|
709
|
+
>
|
|
710
|
+
>;
|
|
711
|
+
params: ParamRecord;
|
|
712
|
+
where: {
|
|
713
|
+
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
714
|
+
? E[EntityResultName] extends Entity<any, any, any, any>
|
|
715
|
+
? E[EntityResultName]["schema"] extends Schema<
|
|
716
|
+
infer A,
|
|
717
|
+
infer F,
|
|
718
|
+
infer C
|
|
719
|
+
>
|
|
720
|
+
? Collection extends keyof ClusteredEntityCollections<
|
|
721
|
+
A,
|
|
722
|
+
F,
|
|
723
|
+
C,
|
|
724
|
+
E[EntityResultName]["schema"]
|
|
597
725
|
>
|
|
598
726
|
? Pick<
|
|
599
727
|
AllEntityAttributes<E>,
|
|
600
728
|
Extract<
|
|
601
729
|
AllEntityAttributeNames<E>,
|
|
602
|
-
|
|
730
|
+
ClusteredCollectionAttributes<E, Collections>[Collection]
|
|
603
731
|
>
|
|
604
732
|
> extends Partial<AllEntityAttributes<E>>
|
|
605
733
|
? CollectionWhereClause<
|
|
@@ -607,55 +735,53 @@ export type CollectionQueries<
|
|
|
607
735
|
A,
|
|
608
736
|
F,
|
|
609
737
|
C,
|
|
610
|
-
|
|
738
|
+
E[EntityResultName]["schema"],
|
|
611
739
|
Pick<
|
|
612
740
|
AllEntityAttributes<E>,
|
|
613
741
|
Extract<
|
|
614
742
|
AllEntityAttributeNames<E>,
|
|
615
|
-
|
|
743
|
+
ClusteredCollectionAttributes<
|
|
744
|
+
E,
|
|
745
|
+
Collections
|
|
746
|
+
>[Collection]
|
|
616
747
|
>
|
|
617
748
|
>,
|
|
749
|
+
Collections,
|
|
750
|
+
Collection,
|
|
618
751
|
ServiceWhereRecordsActionOptions<
|
|
619
752
|
E,
|
|
620
753
|
A,
|
|
621
754
|
F,
|
|
622
755
|
C,
|
|
623
|
-
|
|
756
|
+
E[EntityResultName]["schema"],
|
|
624
757
|
Pick<
|
|
625
758
|
AllEntityAttributes<E>,
|
|
626
759
|
Extract<
|
|
627
760
|
AllEntityAttributeNames<E>,
|
|
628
|
-
|
|
761
|
+
ClusteredCollectionAttributes<
|
|
762
|
+
E,
|
|
763
|
+
Collections
|
|
764
|
+
>[Collection]
|
|
629
765
|
>
|
|
630
766
|
>,
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
? E[EntityResultName] extends Entity<
|
|
634
|
-
infer A,
|
|
635
|
-
infer F,
|
|
636
|
-
infer C,
|
|
637
|
-
infer S
|
|
638
|
-
>
|
|
639
|
-
? ResponseItem<A, F, C, S>[]
|
|
640
|
-
: never
|
|
641
|
-
: never;
|
|
642
|
-
},
|
|
767
|
+
Collections,
|
|
768
|
+
Collection,
|
|
643
769
|
Partial<
|
|
644
770
|
Spread<
|
|
645
|
-
Collection extends keyof
|
|
771
|
+
Collection extends keyof ClusteredCollectionPageAttributes<
|
|
646
772
|
E,
|
|
647
773
|
Collections
|
|
648
774
|
>
|
|
649
|
-
?
|
|
775
|
+
? ClusteredCollectionPageAttributes<
|
|
650
776
|
E,
|
|
651
777
|
Collections
|
|
652
778
|
>[Collection]
|
|
653
779
|
: {},
|
|
654
|
-
Collection extends keyof
|
|
780
|
+
Collection extends keyof ClusteredCollectionIndexAttributes<
|
|
655
781
|
E,
|
|
656
782
|
Collections
|
|
657
783
|
>
|
|
658
|
-
?
|
|
784
|
+
? ClusteredCollectionIndexAttributes<
|
|
659
785
|
E,
|
|
660
786
|
Collections
|
|
661
787
|
>[Collection]
|
|
@@ -666,113 +792,6 @@ export type CollectionQueries<
|
|
|
666
792
|
>
|
|
667
793
|
: never
|
|
668
794
|
: never
|
|
669
|
-
: never;
|
|
670
|
-
}[Collections[Collection]];
|
|
671
|
-
}
|
|
672
|
-
: never;
|
|
673
|
-
}[keyof E];
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
type ClusteredCollectionOperations<
|
|
677
|
-
E extends { [name: string]: Entity<any, any, any, any> },
|
|
678
|
-
Collections extends ClusteredCollectionAssociations<E>,
|
|
679
|
-
Collection extends keyof Collections,
|
|
680
|
-
EntityName extends keyof E,
|
|
681
|
-
> = EntityName extends Collections[Collection]
|
|
682
|
-
? {
|
|
683
|
-
go: ServiceQueryRecordsGo<{
|
|
684
|
-
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
685
|
-
? E[EntityResultName] extends Entity<
|
|
686
|
-
infer A,
|
|
687
|
-
infer F,
|
|
688
|
-
infer C,
|
|
689
|
-
infer S
|
|
690
|
-
>
|
|
691
|
-
? ResponseItem<A, F, C, S>[]
|
|
692
|
-
: never
|
|
693
|
-
: never;
|
|
694
|
-
}>;
|
|
695
|
-
params: ParamRecord;
|
|
696
|
-
where: {
|
|
697
|
-
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
698
|
-
? E[EntityResultName] extends Entity<
|
|
699
|
-
infer A,
|
|
700
|
-
infer F,
|
|
701
|
-
infer C,
|
|
702
|
-
infer S
|
|
703
|
-
>
|
|
704
|
-
? Pick<
|
|
705
|
-
AllEntityAttributes<E>,
|
|
706
|
-
Extract<
|
|
707
|
-
AllEntityAttributeNames<E>,
|
|
708
|
-
ClusteredCollectionAttributes<E, Collections>[Collection]
|
|
709
|
-
>
|
|
710
|
-
> extends Partial<AllEntityAttributes<E>>
|
|
711
|
-
? CollectionWhereClause<
|
|
712
|
-
E,
|
|
713
|
-
A,
|
|
714
|
-
F,
|
|
715
|
-
C,
|
|
716
|
-
S,
|
|
717
|
-
Pick<
|
|
718
|
-
AllEntityAttributes<E>,
|
|
719
|
-
Extract<
|
|
720
|
-
AllEntityAttributeNames<E>,
|
|
721
|
-
ClusteredCollectionAttributes<E, Collections>[Collection]
|
|
722
|
-
>
|
|
723
|
-
>,
|
|
724
|
-
ServiceWhereRecordsActionOptions<
|
|
725
|
-
E,
|
|
726
|
-
A,
|
|
727
|
-
F,
|
|
728
|
-
C,
|
|
729
|
-
S,
|
|
730
|
-
Pick<
|
|
731
|
-
AllEntityAttributes<E>,
|
|
732
|
-
Extract<
|
|
733
|
-
AllEntityAttributeNames<E>,
|
|
734
|
-
ClusteredCollectionAttributes<
|
|
735
|
-
E,
|
|
736
|
-
Collections
|
|
737
|
-
>[Collection]
|
|
738
|
-
>
|
|
739
|
-
>,
|
|
740
|
-
{
|
|
741
|
-
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
742
|
-
? E[EntityResultName] extends Entity<
|
|
743
|
-
infer A,
|
|
744
|
-
infer F,
|
|
745
|
-
infer C,
|
|
746
|
-
infer S
|
|
747
|
-
>
|
|
748
|
-
? ResponseItem<A, F, C, S>[]
|
|
749
|
-
: never
|
|
750
|
-
: never;
|
|
751
|
-
},
|
|
752
|
-
Partial<
|
|
753
|
-
Spread<
|
|
754
|
-
Collection extends keyof ClusteredCollectionPageAttributes<
|
|
755
|
-
E,
|
|
756
|
-
Collections
|
|
757
|
-
>
|
|
758
|
-
? ClusteredCollectionPageAttributes<
|
|
759
|
-
E,
|
|
760
|
-
Collections
|
|
761
|
-
>[Collection]
|
|
762
|
-
: {},
|
|
763
|
-
Collection extends keyof ClusteredCollectionIndexAttributes<
|
|
764
|
-
E,
|
|
765
|
-
Collections
|
|
766
|
-
>
|
|
767
|
-
? ClusteredCollectionIndexAttributes<
|
|
768
|
-
E,
|
|
769
|
-
Collections
|
|
770
|
-
>[Collection]
|
|
771
|
-
: {}
|
|
772
|
-
>
|
|
773
|
-
>
|
|
774
|
-
>
|
|
775
|
-
>
|
|
776
795
|
: never
|
|
777
796
|
: never
|
|
778
797
|
: never;
|
|
@@ -903,41 +922,34 @@ export type IsolatedCollectionQueries<
|
|
|
903
922
|
>[0]
|
|
904
923
|
>,
|
|
905
924
|
) => {
|
|
906
|
-
go: ServiceQueryRecordsGo<
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
925
|
+
go: ServiceQueryRecordsGo<
|
|
926
|
+
E,
|
|
927
|
+
Collections,
|
|
928
|
+
Collection,
|
|
929
|
+
keyof Pick<
|
|
930
|
+
AllEntityAttributes<E>,
|
|
931
|
+
Extract<
|
|
932
|
+
AllEntityAttributeNames<E>,
|
|
933
|
+
IsolatedCollectionAttributes<E, Collections>[Collection]
|
|
934
|
+
>
|
|
935
|
+
>
|
|
936
|
+
>;
|
|
918
937
|
params: ParamRecord;
|
|
919
938
|
where: {
|
|
920
939
|
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
921
|
-
? E[EntityResultName] extends Entity<
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
AllEntityAttributes<E>,
|
|
929
|
-
Extract<
|
|
930
|
-
AllEntityAttributeNames<E>,
|
|
931
|
-
IsolatedCollectionAttributes<E, Collections>[Collection]
|
|
932
|
-
>
|
|
933
|
-
> extends Partial<AllEntityAttributes<E>>
|
|
934
|
-
? CollectionWhereClause<
|
|
935
|
-
E,
|
|
940
|
+
? E[EntityResultName] extends Entity<any, any, any, any>
|
|
941
|
+
? E[EntityResultName]["schema"] extends Schema<
|
|
942
|
+
infer A,
|
|
943
|
+
infer F,
|
|
944
|
+
infer C
|
|
945
|
+
>
|
|
946
|
+
? Collection extends keyof IsolatedEntityCollections<
|
|
936
947
|
A,
|
|
937
948
|
F,
|
|
938
949
|
C,
|
|
939
|
-
|
|
940
|
-
|
|
950
|
+
E[EntityResultName]["schema"]
|
|
951
|
+
>
|
|
952
|
+
? Pick<
|
|
941
953
|
AllEntityAttributes<E>,
|
|
942
954
|
Extract<
|
|
943
955
|
AllEntityAttributeNames<E>,
|
|
@@ -946,59 +958,69 @@ export type IsolatedCollectionQueries<
|
|
|
946
958
|
Collections
|
|
947
959
|
>[Collection]
|
|
948
960
|
>
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
>
|
|
965
|
-
>,
|
|
966
|
-
{
|
|
967
|
-
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
968
|
-
? E[EntityResultName] extends Entity<
|
|
969
|
-
infer A,
|
|
970
|
-
infer F,
|
|
971
|
-
infer C,
|
|
972
|
-
infer S
|
|
973
|
-
>
|
|
974
|
-
? ResponseItem<A, F, C, S>[]
|
|
975
|
-
: never
|
|
976
|
-
: never;
|
|
977
|
-
},
|
|
978
|
-
Partial<
|
|
979
|
-
Spread<
|
|
980
|
-
Collection extends keyof IsolatedCollectionPageAttributes<
|
|
981
|
-
E,
|
|
982
|
-
Collections
|
|
961
|
+
> extends Partial<AllEntityAttributes<E>>
|
|
962
|
+
? CollectionWhereClause<
|
|
963
|
+
E,
|
|
964
|
+
A,
|
|
965
|
+
F,
|
|
966
|
+
C,
|
|
967
|
+
E[EntityResultName]["schema"],
|
|
968
|
+
Pick<
|
|
969
|
+
AllEntityAttributes<E>,
|
|
970
|
+
Extract<
|
|
971
|
+
AllEntityAttributeNames<E>,
|
|
972
|
+
IsolatedCollectionAttributes<
|
|
973
|
+
E,
|
|
974
|
+
Collections
|
|
975
|
+
>[Collection]
|
|
983
976
|
>
|
|
984
|
-
|
|
977
|
+
>,
|
|
978
|
+
Collections,
|
|
979
|
+
Collection,
|
|
980
|
+
ServiceWhereRecordsActionOptions<
|
|
981
|
+
E,
|
|
982
|
+
A,
|
|
983
|
+
F,
|
|
984
|
+
C,
|
|
985
|
+
E[EntityResultName]["schema"],
|
|
986
|
+
Pick<
|
|
987
|
+
AllEntityAttributes<E>,
|
|
988
|
+
Extract<
|
|
989
|
+
AllEntityAttributeNames<E>,
|
|
990
|
+
IsolatedCollectionAttributes<
|
|
985
991
|
E,
|
|
986
992
|
Collections
|
|
987
993
|
>[Collection]
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
+
>
|
|
995
|
+
>,
|
|
996
|
+
Collections,
|
|
997
|
+
Collection,
|
|
998
|
+
Partial<
|
|
999
|
+
Spread<
|
|
1000
|
+
Collection extends keyof IsolatedCollectionPageAttributes<
|
|
994
1001
|
E,
|
|
995
1002
|
Collections
|
|
996
|
-
>
|
|
997
|
-
|
|
1003
|
+
>
|
|
1004
|
+
? IsolatedCollectionPageAttributes<
|
|
1005
|
+
E,
|
|
1006
|
+
Collections
|
|
1007
|
+
>[Collection]
|
|
1008
|
+
: {},
|
|
1009
|
+
Collection extends keyof IsolatedCollectionIndexAttributes<
|
|
1010
|
+
E,
|
|
1011
|
+
Collections
|
|
1012
|
+
>
|
|
1013
|
+
? IsolatedCollectionIndexAttributes<
|
|
1014
|
+
E,
|
|
1015
|
+
Collections
|
|
1016
|
+
>[Collection]
|
|
1017
|
+
: {}
|
|
1018
|
+
>
|
|
1019
|
+
>
|
|
998
1020
|
>
|
|
999
1021
|
>
|
|
1000
|
-
|
|
1001
|
-
|
|
1022
|
+
: never
|
|
1023
|
+
: never
|
|
1002
1024
|
: never
|
|
1003
1025
|
: never
|
|
1004
1026
|
: never;
|
|
@@ -1065,6 +1087,13 @@ export type ElectroEventListener = (event: ElectroEvent) => void;
|
|
|
1065
1087
|
// details: any;
|
|
1066
1088
|
// };
|
|
1067
1089
|
|
|
1090
|
+
export declare const EntityIdentifiers: {
|
|
1091
|
+
name: "__edb_e__";
|
|
1092
|
+
version: "__edb_v__";
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
export declare const EntityIdentifierFields: string[];
|
|
1096
|
+
|
|
1068
1097
|
export type EntityIdentifiers<E extends Entity<any, any, any, any>> =
|
|
1069
1098
|
E extends Entity<infer A, infer F, infer C, infer S>
|
|
1070
1099
|
? AllTableIndexCompositeAttributes<A, F, C, S>
|
|
@@ -1211,6 +1240,29 @@ export type CollectionResponse<
|
|
|
1211
1240
|
cursor: string | null;
|
|
1212
1241
|
};
|
|
1213
1242
|
|
|
1243
|
+
export type IndexSpecificSchema<
|
|
1244
|
+
A extends string,
|
|
1245
|
+
F extends string,
|
|
1246
|
+
C extends string,
|
|
1247
|
+
S extends Schema<A, F, C>,
|
|
1248
|
+
I extends keyof S["indexes"],
|
|
1249
|
+
> = Omit<S, "attributes" | "indexes"> & {
|
|
1250
|
+
attributes: {
|
|
1251
|
+
[a in keyof S["attributes"] as a extends IndexProjectedAttributeNames<
|
|
1252
|
+
A,
|
|
1253
|
+
F,
|
|
1254
|
+
C,
|
|
1255
|
+
S,
|
|
1256
|
+
I
|
|
1257
|
+
>
|
|
1258
|
+
? a
|
|
1259
|
+
: never]: S["attributes"][a];
|
|
1260
|
+
};
|
|
1261
|
+
indexes: {
|
|
1262
|
+
[i in keyof S["indexes"] as i extends I ? i : never]: S["indexes"][i];
|
|
1263
|
+
};
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1214
1266
|
export interface QueryBranches<
|
|
1215
1267
|
A extends string,
|
|
1216
1268
|
F extends string,
|
|
@@ -1218,17 +1270,37 @@ export interface QueryBranches<
|
|
|
1218
1270
|
S extends Schema<A, F, C>,
|
|
1219
1271
|
ResponseItem,
|
|
1220
1272
|
IndexCompositeAttributes,
|
|
1273
|
+
I extends keyof S["indexes"],
|
|
1221
1274
|
> {
|
|
1222
|
-
go: GoQueryTerminal<A, F, C, S, ResponseItem>;
|
|
1275
|
+
go: GoQueryTerminal<A, F, C, S, ResponseItem, I>;
|
|
1223
1276
|
params: ParamTerminal<A, F, C, S, ResponseItem>;
|
|
1224
|
-
where:
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1277
|
+
where: IndexSpecificSchema<A, F, C, S, I> extends Schema<
|
|
1278
|
+
infer A2,
|
|
1279
|
+
infer F2,
|
|
1280
|
+
infer C2
|
|
1281
|
+
>
|
|
1282
|
+
? WhereClause<
|
|
1283
|
+
A2,
|
|
1284
|
+
F2,
|
|
1285
|
+
C2,
|
|
1286
|
+
IndexSpecificSchema<A, F, C, S, I>,
|
|
1287
|
+
Item<
|
|
1288
|
+
A2,
|
|
1289
|
+
F2,
|
|
1290
|
+
C2,
|
|
1291
|
+
IndexSpecificSchema<A, F, C, S, I>,
|
|
1292
|
+
IndexSpecificSchema<A, F, C, S, I>["attributes"]
|
|
1293
|
+
>,
|
|
1294
|
+
QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes, I>
|
|
1295
|
+
>
|
|
1296
|
+
: WhereClause<
|
|
1297
|
+
A,
|
|
1298
|
+
F,
|
|
1299
|
+
C,
|
|
1300
|
+
S,
|
|
1301
|
+
Item<A, F, C, S, S["attributes"]>,
|
|
1302
|
+
QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes, I>
|
|
1303
|
+
>;
|
|
1232
1304
|
}
|
|
1233
1305
|
|
|
1234
1306
|
export interface RecordsActionOptions<
|
|
@@ -1239,7 +1311,7 @@ export interface RecordsActionOptions<
|
|
|
1239
1311
|
ResponseItem,
|
|
1240
1312
|
IndexCompositeAttributes,
|
|
1241
1313
|
> {
|
|
1242
|
-
go: QueryRecordsGo<ResponseItem>;
|
|
1314
|
+
go: QueryRecordsGo<ResponseItem, S>;
|
|
1243
1315
|
params: ParamRecord;
|
|
1244
1316
|
where: WhereClause<
|
|
1245
1317
|
A,
|
|
@@ -1299,7 +1371,7 @@ type GoGetTerminalTransaction<
|
|
|
1299
1371
|
Params,
|
|
1300
1372
|
> = <Options extends TransactGetQueryOptions<keyof ResponseItem>>(
|
|
1301
1373
|
options?: Options,
|
|
1302
|
-
) => Options extends GoQueryTerminalOptions<infer Attr>
|
|
1374
|
+
) => Options extends GoQueryTerminalOptions<infer Attr, S>
|
|
1303
1375
|
? CommittedTransactionResult<
|
|
1304
1376
|
{
|
|
1305
1377
|
[Name in keyof ResponseItem as Name extends Attr
|
|
@@ -2300,27 +2372,28 @@ interface QueryOperations<
|
|
|
2300
2372
|
CompositeAttributes,
|
|
2301
2373
|
ResponseItem,
|
|
2302
2374
|
IndexCompositeAttributes,
|
|
2375
|
+
I extends keyof S["indexes"],
|
|
2303
2376
|
> {
|
|
2304
2377
|
between: (
|
|
2305
2378
|
skCompositeAttributesStart: CompositeAttributes,
|
|
2306
2379
|
skCompositeAttributesEnd: CompositeAttributes,
|
|
2307
|
-
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes>;
|
|
2380
|
+
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes, I>;
|
|
2308
2381
|
gt: (
|
|
2309
2382
|
skCompositeAttributes: CompositeAttributes,
|
|
2310
|
-
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes>;
|
|
2383
|
+
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes, I>;
|
|
2311
2384
|
gte: (
|
|
2312
2385
|
skCompositeAttributes: CompositeAttributes,
|
|
2313
|
-
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes>;
|
|
2386
|
+
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes, I>;
|
|
2314
2387
|
lt: (
|
|
2315
2388
|
skCompositeAttributes: CompositeAttributes,
|
|
2316
|
-
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes>;
|
|
2389
|
+
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes, I>;
|
|
2317
2390
|
lte: (
|
|
2318
2391
|
skCompositeAttributes: CompositeAttributes,
|
|
2319
|
-
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes>;
|
|
2392
|
+
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes, I>;
|
|
2320
2393
|
begins: (
|
|
2321
2394
|
skCompositeAttributes: CompositeAttributes,
|
|
2322
|
-
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes>;
|
|
2323
|
-
go: GoQueryTerminal<A, F, C, S, ResponseItem>;
|
|
2395
|
+
) => QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes, I>;
|
|
2396
|
+
go: GoQueryTerminal<A, F, C, S, ResponseItem, I>;
|
|
2324
2397
|
params: ParamTerminal<A, F, C, S, ResponseItem>;
|
|
2325
2398
|
where: WhereClause<
|
|
2326
2399
|
A,
|
|
@@ -2328,7 +2401,7 @@ interface QueryOperations<
|
|
|
2328
2401
|
C,
|
|
2329
2402
|
S,
|
|
2330
2403
|
Item<A, F, C, S, S["attributes"]>,
|
|
2331
|
-
QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes>
|
|
2404
|
+
QueryBranches<A, F, C, S, ResponseItem, IndexCompositeAttributes, I>
|
|
2332
2405
|
>;
|
|
2333
2406
|
}
|
|
2334
2407
|
|
|
@@ -2451,6 +2524,23 @@ export type Conversions<
|
|
|
2451
2524
|
};
|
|
2452
2525
|
};
|
|
2453
2526
|
|
|
2527
|
+
export type IndexScans<
|
|
2528
|
+
A extends string,
|
|
2529
|
+
F extends string,
|
|
2530
|
+
C extends string,
|
|
2531
|
+
S extends Schema<A, F, C>,
|
|
2532
|
+
> = {
|
|
2533
|
+
[I in keyof S["indexes"]]: QueryBranches<
|
|
2534
|
+
A,
|
|
2535
|
+
F,
|
|
2536
|
+
C,
|
|
2537
|
+
S,
|
|
2538
|
+
ResponseItem<A, F, C, S>,
|
|
2539
|
+
AllTableIndexCompositeAttributes<A, F, C, S>,
|
|
2540
|
+
I
|
|
2541
|
+
>;
|
|
2542
|
+
};
|
|
2543
|
+
|
|
2454
2544
|
export type Queries<
|
|
2455
2545
|
A extends string,
|
|
2456
2546
|
F extends string,
|
|
@@ -2471,7 +2561,8 @@ export type Queries<
|
|
|
2471
2561
|
S,
|
|
2472
2562
|
ResponseItem<A, F, C, S>,
|
|
2473
2563
|
AllTableIndexCompositeAttributes<A, F, C, S> &
|
|
2474
|
-
Required<CompositeAttributes
|
|
2564
|
+
Required<CompositeAttributes>,
|
|
2565
|
+
I
|
|
2475
2566
|
>
|
|
2476
2567
|
: // If there is no SK, dont show query operations (When no PK is specified)
|
|
2477
2568
|
S["indexes"][I] extends IndexWithSortKey
|
|
@@ -2488,7 +2579,8 @@ export type Queries<
|
|
|
2488
2579
|
ResponseItem<A, F, C, S>,
|
|
2489
2580
|
AllTableIndexCompositeAttributes<A, F, C, S> &
|
|
2490
2581
|
Required<CompositeAttributes> &
|
|
2491
|
-
SK
|
|
2582
|
+
SK,
|
|
2583
|
+
I
|
|
2492
2584
|
>
|
|
2493
2585
|
: QueryBranches<
|
|
2494
2586
|
A,
|
|
@@ -2498,7 +2590,8 @@ export type Queries<
|
|
|
2498
2590
|
ResponseItem<A, F, C, S>,
|
|
2499
2591
|
AllTableIndexCompositeAttributes<A, F, C, S> &
|
|
2500
2592
|
Required<CompositeAttributes> &
|
|
2501
|
-
SK
|
|
2593
|
+
SK,
|
|
2594
|
+
I
|
|
2502
2595
|
>
|
|
2503
2596
|
: never;
|
|
2504
2597
|
};
|
|
@@ -2640,7 +2733,12 @@ export type QueryExecutionComparisonParts = {
|
|
|
2640
2733
|
compare?: "v2"
|
|
2641
2734
|
}
|
|
2642
2735
|
|
|
2643
|
-
type ServiceQueryGoTerminalOptions
|
|
2736
|
+
type ServiceQueryGoTerminalOptions<
|
|
2737
|
+
E extends { [entity: string]: Entity<any, any, any, any> },
|
|
2738
|
+
Collections extends { [collection: string]: keyof E },
|
|
2739
|
+
Collection extends keyof Collections,
|
|
2740
|
+
Attributes,
|
|
2741
|
+
> = {
|
|
2644
2742
|
cursor?: string | null;
|
|
2645
2743
|
data?: "raw" | "includeKeys" | "attributes";
|
|
2646
2744
|
table?: string;
|
|
@@ -2652,11 +2750,61 @@ type ServiceQueryGoTerminalOptions = {
|
|
|
2652
2750
|
listeners?: Array<ElectroEventListener>;
|
|
2653
2751
|
logger?: ElectroEventListener;
|
|
2654
2752
|
order?: "asc" | "desc";
|
|
2655
|
-
hydrate?: boolean;
|
|
2656
2753
|
consistent?: boolean;
|
|
2657
|
-
} & QueryExecutionComparisonParts
|
|
2754
|
+
} & QueryExecutionComparisonParts &
|
|
2755
|
+
(
|
|
2756
|
+
| {
|
|
2757
|
+
// if should hydrate, all attributes will be available from the main table
|
|
2758
|
+
hydrate: true;
|
|
2759
|
+
attributes?: ReadonlyArray<Attributes>;
|
|
2760
|
+
}
|
|
2761
|
+
| {
|
|
2762
|
+
// if should not hydrate, the only available attributes are the ones that are projected to the index
|
|
2763
|
+
hydrate?: false | undefined;
|
|
2764
|
+
attributes?: ReadonlyArray<
|
|
2765
|
+
{
|
|
2766
|
+
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
2767
|
+
? E[EntityResultName] extends Entity<any, any, any, any>
|
|
2768
|
+
? E[EntityResultName]["schema"] extends Schema<
|
|
2769
|
+
infer A,
|
|
2770
|
+
infer F,
|
|
2771
|
+
infer C
|
|
2772
|
+
>
|
|
2773
|
+
? Collection extends keyof EntityCollections<
|
|
2774
|
+
A,
|
|
2775
|
+
F,
|
|
2776
|
+
C,
|
|
2777
|
+
E[EntityResultName]["schema"]
|
|
2778
|
+
>
|
|
2779
|
+
? Extract<
|
|
2780
|
+
IndexProjectedAttributeNames<
|
|
2781
|
+
A,
|
|
2782
|
+
F,
|
|
2783
|
+
C,
|
|
2784
|
+
E[EntityResultName]["schema"],
|
|
2785
|
+
EntityCollections<
|
|
2786
|
+
A,
|
|
2787
|
+
F,
|
|
2788
|
+
C,
|
|
2789
|
+
E[EntityResultName]["schema"]
|
|
2790
|
+
>[Collection]
|
|
2791
|
+
>,
|
|
2792
|
+
Attributes
|
|
2793
|
+
>
|
|
2794
|
+
: never
|
|
2795
|
+
: never
|
|
2796
|
+
: never
|
|
2797
|
+
: never;
|
|
2798
|
+
}[Collections[Collection]]
|
|
2799
|
+
>;
|
|
2800
|
+
}
|
|
2801
|
+
);
|
|
2658
2802
|
|
|
2659
|
-
type GoQueryTerminalOptions<
|
|
2803
|
+
type GoQueryTerminalOptions<
|
|
2804
|
+
Attributes,
|
|
2805
|
+
S extends Schema<any, any, any>,
|
|
2806
|
+
I extends keyof S["indexes"] | undefined = undefined,
|
|
2807
|
+
> = {
|
|
2660
2808
|
cursor?: string | null;
|
|
2661
2809
|
data?: "raw" | "includeKeys" | "attributes";
|
|
2662
2810
|
table?: string;
|
|
@@ -2666,13 +2814,28 @@ type GoQueryTerminalOptions<Attributes> = {
|
|
|
2666
2814
|
originalErr?: boolean;
|
|
2667
2815
|
ignoreOwnership?: boolean;
|
|
2668
2816
|
pages?: number | "all";
|
|
2669
|
-
attributes?: ReadonlyArray<Attributes>;
|
|
2670
2817
|
listeners?: Array<ElectroEventListener>;
|
|
2671
2818
|
logger?: ElectroEventListener;
|
|
2672
2819
|
order?: "asc" | "desc";
|
|
2673
2820
|
hydrate?: boolean;
|
|
2674
2821
|
consistent?: boolean;
|
|
2675
|
-
} & QueryExecutionComparisonParts
|
|
2822
|
+
} & QueryExecutionComparisonParts &
|
|
2823
|
+
(
|
|
2824
|
+
| {
|
|
2825
|
+
// if should hydrate, all attributes will be available from the main table
|
|
2826
|
+
hydrate: true;
|
|
2827
|
+
attributes?: ReadonlyArray<Attributes>;
|
|
2828
|
+
}
|
|
2829
|
+
| {
|
|
2830
|
+
// if should not hydrate, the only available attributes are the ones that are projected to the index
|
|
2831
|
+
hydrate?: false | undefined;
|
|
2832
|
+
attributes?: S extends Schema<infer A, infer F, infer C>
|
|
2833
|
+
? ReadonlyArray<
|
|
2834
|
+
Extract<IndexProjectedAttributeNames<A, F, C, S, I>, Attributes>
|
|
2835
|
+
>
|
|
2836
|
+
: ReadonlyArray<Attributes>;
|
|
2837
|
+
}
|
|
2838
|
+
);
|
|
2676
2839
|
|
|
2677
2840
|
interface TransactWriteQueryOptions {
|
|
2678
2841
|
data?: "raw" | "includeKeys" | "attributes";
|
|
@@ -2789,9 +2952,9 @@ type GoGetTerminal<
|
|
|
2789
2952
|
C extends string,
|
|
2790
2953
|
S extends Schema<A, F, C>,
|
|
2791
2954
|
ResponseItem,
|
|
2792
|
-
> = <Options extends GoQueryTerminalOptions<keyof ResponseItem>>(
|
|
2955
|
+
> = <Options extends GoQueryTerminalOptions<keyof ResponseItem, S>>(
|
|
2793
2956
|
options?: Options,
|
|
2794
|
-
) => Options extends GoQueryTerminalOptions<infer Attr>
|
|
2957
|
+
) => Options extends GoQueryTerminalOptions<infer Attr, S>
|
|
2795
2958
|
? Promise<{
|
|
2796
2959
|
data:
|
|
2797
2960
|
| {
|
|
@@ -2809,16 +2972,13 @@ export type GoQueryTerminal<
|
|
|
2809
2972
|
C extends string,
|
|
2810
2973
|
S extends Schema<A, F, C>,
|
|
2811
2974
|
Item,
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
cursor: string | null;
|
|
2820
|
-
}>
|
|
2821
|
-
: Promise<{ data: Array<Item>; cursor: string | null }>;
|
|
2975
|
+
I extends keyof S["indexes"] | undefined = undefined,
|
|
2976
|
+
> = {
|
|
2977
|
+
<Options extends GoQueryTerminalOptions<keyof Item, S, I>>(
|
|
2978
|
+
options: Options,
|
|
2979
|
+
): Promise<IndexResponse<Options, Item, S, I>>;
|
|
2980
|
+
(): Promise<IndexResponse<{}, Item, S, I>>;
|
|
2981
|
+
}
|
|
2822
2982
|
|
|
2823
2983
|
export type EntityParseMultipleItems<
|
|
2824
2984
|
A extends string,
|
|
@@ -2855,16 +3015,157 @@ export type ParamTerminal<
|
|
|
2855
3015
|
options?: Options,
|
|
2856
3016
|
) => P;
|
|
2857
3017
|
|
|
3018
|
+
export type EntityCollectionResponse<
|
|
3019
|
+
S extends Schema<string, string, string>,
|
|
3020
|
+
ResponseItem,
|
|
3021
|
+
Attr,
|
|
3022
|
+
Index extends keyof S["indexes"],
|
|
3023
|
+
Options extends ServiceQueryGoTerminalOptions<any, any, any, Attr>,
|
|
3024
|
+
> = Array<{
|
|
3025
|
+
[Name in keyof ResponseItem as Name extends Attr
|
|
3026
|
+
? Options["hydrate"] extends true
|
|
3027
|
+
? Name
|
|
3028
|
+
: Index extends keyof S["indexes"]
|
|
3029
|
+
? "projection" extends keyof S["indexes"][Index]
|
|
3030
|
+
? S["indexes"][Index]["projection"] extends ReadonlyArray<infer P>
|
|
3031
|
+
? Name extends P
|
|
3032
|
+
? Name
|
|
3033
|
+
: never
|
|
3034
|
+
: S["indexes"][Index]["projection"] extends "keys_only"
|
|
3035
|
+
? never
|
|
3036
|
+
: Name
|
|
3037
|
+
: Name
|
|
3038
|
+
: Name
|
|
3039
|
+
: never]: ResponseItem[Name];
|
|
3040
|
+
}>;
|
|
3041
|
+
|
|
2858
3042
|
export type ServiceQueryRecordsGo<
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
3043
|
+
E extends { [name: string]: Entity<any, any, any, any> },
|
|
3044
|
+
Collections extends CollectionAssociations<E>,
|
|
3045
|
+
Collection extends keyof Collections,
|
|
3046
|
+
Attributes,
|
|
3047
|
+
> = {
|
|
3048
|
+
<
|
|
3049
|
+
Options extends ServiceQueryGoTerminalOptions<
|
|
3050
|
+
E,
|
|
3051
|
+
Collections,
|
|
3052
|
+
Collection,
|
|
3053
|
+
Attributes
|
|
3054
|
+
>,
|
|
3055
|
+
>(
|
|
3056
|
+
options: Options,
|
|
3057
|
+
): Promise<
|
|
3058
|
+
Options extends ServiceQueryGoTerminalOptions<
|
|
3059
|
+
E,
|
|
3060
|
+
Collections,
|
|
3061
|
+
Collection,
|
|
3062
|
+
infer Attr
|
|
3063
|
+
>
|
|
3064
|
+
? {
|
|
3065
|
+
data: {
|
|
3066
|
+
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
3067
|
+
? E[EntityResultName] extends Entity<
|
|
3068
|
+
infer A,
|
|
3069
|
+
infer F,
|
|
3070
|
+
infer C,
|
|
3071
|
+
infer S
|
|
3072
|
+
>
|
|
3073
|
+
? Collection extends keyof EntityCollections<A, F, C, S>
|
|
3074
|
+
? EntityCollectionResponse<
|
|
3075
|
+
S,
|
|
3076
|
+
ResponseItem<A, F, C, S>,
|
|
3077
|
+
Attr,
|
|
3078
|
+
EntityCollections<A, F, C, S>[Collection],
|
|
3079
|
+
Options
|
|
3080
|
+
>
|
|
3081
|
+
: never
|
|
3082
|
+
: never
|
|
3083
|
+
: never;
|
|
3084
|
+
};
|
|
3085
|
+
cursor: string | null;
|
|
3086
|
+
}
|
|
3087
|
+
: {
|
|
3088
|
+
data: {
|
|
3089
|
+
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
3090
|
+
? E[EntityResultName] extends Entity<
|
|
3091
|
+
infer A,
|
|
3092
|
+
infer F,
|
|
3093
|
+
infer C,
|
|
3094
|
+
infer S
|
|
3095
|
+
>
|
|
3096
|
+
? Collection extends keyof EntityCollections<A, F, C, S>
|
|
3097
|
+
? EntityCollectionResponse<
|
|
3098
|
+
S,
|
|
3099
|
+
ResponseItem<A, F, C, S>,
|
|
3100
|
+
Attributes,
|
|
3101
|
+
EntityCollections<A, F, C, S>[Collection],
|
|
3102
|
+
{}
|
|
3103
|
+
>
|
|
3104
|
+
: never
|
|
3105
|
+
: never
|
|
3106
|
+
: never;
|
|
3107
|
+
};
|
|
3108
|
+
cursor: string | null;
|
|
3109
|
+
}
|
|
3110
|
+
>;
|
|
3111
|
+
(): Promise<{
|
|
3112
|
+
data: {
|
|
3113
|
+
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
3114
|
+
? E[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
3115
|
+
? Collection extends keyof EntityCollections<A, F, C, S>
|
|
3116
|
+
? EntityCollectionResponse<
|
|
3117
|
+
S,
|
|
3118
|
+
ResponseItem<A, F, C, S>,
|
|
3119
|
+
Attributes,
|
|
3120
|
+
EntityCollections<A, F, C, S>[Collection],
|
|
3121
|
+
{}
|
|
3122
|
+
>
|
|
3123
|
+
: never
|
|
3124
|
+
: never
|
|
3125
|
+
: never;
|
|
3126
|
+
};
|
|
3127
|
+
cursor: string | null;
|
|
3128
|
+
}>;
|
|
3129
|
+
};
|
|
3130
|
+
|
|
3131
|
+
export type IndexResponse<
|
|
3132
|
+
Options extends GoQueryTerminalOptions<keyof Item, S, any>,
|
|
3133
|
+
Item,
|
|
3134
|
+
S extends Schema<string, string, string>,
|
|
3135
|
+
I extends keyof S["indexes"] | undefined = undefined,
|
|
3136
|
+
> = Options extends GoQueryTerminalOptions<infer Attr, S>
|
|
3137
|
+
? {
|
|
3138
|
+
data: Array<{
|
|
3139
|
+
[Name in keyof Item as Name extends Attr
|
|
3140
|
+
? Options["hydrate"] extends true
|
|
3141
|
+
? Name
|
|
3142
|
+
: I extends keyof S["indexes"]
|
|
3143
|
+
? "projection" extends keyof S["indexes"][I]
|
|
3144
|
+
? S["indexes"][I]["projection"] extends ReadonlyArray<
|
|
3145
|
+
infer P
|
|
3146
|
+
>
|
|
3147
|
+
? Name extends P
|
|
3148
|
+
? Name
|
|
3149
|
+
: never
|
|
3150
|
+
: S["indexes"][I]["projection"] extends 'keys_only'
|
|
3151
|
+
? never
|
|
3152
|
+
: Name
|
|
3153
|
+
: Name
|
|
3154
|
+
: Name
|
|
3155
|
+
: never]: Item[Name];
|
|
3156
|
+
}>;
|
|
3157
|
+
cursor: string | null;
|
|
3158
|
+
}
|
|
3159
|
+
: {
|
|
3160
|
+
data: Array<Item>;
|
|
3161
|
+
cursor: string | null;
|
|
3162
|
+
};
|
|
2864
3163
|
|
|
2865
|
-
export type QueryRecordsGo<Item
|
|
3164
|
+
export type QueryRecordsGo<Item, S extends Schema<string, string, string>> = <
|
|
3165
|
+
Options extends GoQueryTerminalOptions<keyof Item, S>,
|
|
3166
|
+
>(
|
|
2866
3167
|
options?: Options,
|
|
2867
|
-
) => Options extends GoQueryTerminalOptions<infer Attr>
|
|
3168
|
+
) => Options extends GoQueryTerminalOptions<infer Attr, any>
|
|
2868
3169
|
? Promise<{
|
|
2869
3170
|
data: Array<{
|
|
2870
3171
|
[Name in keyof Item as Name extends Attr ? Name : never]: Item[Name];
|
|
@@ -3668,7 +3969,7 @@ export type KeyCastOption = "string" | "number";
|
|
|
3668
3969
|
|
|
3669
3970
|
export type KeyCasingOption = "upper" | "lower" | "none" | "default";
|
|
3670
3971
|
|
|
3671
|
-
export interface Schema<A extends string, F extends string, C extends string> {
|
|
3972
|
+
export interface Schema<A extends string, F extends string, C extends string, P extends string = string> {
|
|
3672
3973
|
readonly model: {
|
|
3673
3974
|
readonly entity: string;
|
|
3674
3975
|
readonly service: string;
|
|
@@ -3679,7 +3980,12 @@ export interface Schema<A extends string, F extends string, C extends string> {
|
|
|
3679
3980
|
};
|
|
3680
3981
|
readonly indexes: {
|
|
3681
3982
|
[accessPattern: string]: {
|
|
3983
|
+
/**
|
|
3984
|
+
* @deprecated use "projection" instead
|
|
3985
|
+
*/
|
|
3682
3986
|
readonly project?: "keys_only";
|
|
3987
|
+
|
|
3988
|
+
readonly projection?: "all" | "keys_only" | ReadonlyArray<P>;
|
|
3683
3989
|
readonly index?: string;
|
|
3684
3990
|
readonly scope?: string;
|
|
3685
3991
|
readonly type?: "clustered" | "isolated";
|
|
@@ -3705,6 +4011,47 @@ export interface Schema<A extends string, F extends string, C extends string> {
|
|
|
3705
4011
|
|
|
3706
4012
|
export type Attributes<A extends string> = Record<A, Attribute>;
|
|
3707
4013
|
|
|
4014
|
+
export type IndexProjectedAttributeNames<
|
|
4015
|
+
A extends string,
|
|
4016
|
+
F extends string,
|
|
4017
|
+
C extends string,
|
|
4018
|
+
S extends Schema<A, F, C>,
|
|
4019
|
+
I extends keyof S["indexes"] | undefined,
|
|
4020
|
+
> = I extends keyof S["indexes"]
|
|
4021
|
+
? S["indexes"][I]["projection"] extends ReadonlyArray<infer R extends A>
|
|
4022
|
+
? R
|
|
4023
|
+
: S["indexes"][I]["projection"] extends "keys_only"
|
|
4024
|
+
? never
|
|
4025
|
+
: A
|
|
4026
|
+
: A;
|
|
4027
|
+
|
|
4028
|
+
export type CollectionProjectedAttributeNames<
|
|
4029
|
+
E extends { [entityName: string]: Entity<any, any, any, any> },
|
|
4030
|
+
Collections extends CollectionAssociations<E>,
|
|
4031
|
+
Collection extends keyof Collections,
|
|
4032
|
+
> = {
|
|
4033
|
+
[EntityName in keyof E]: EntityName extends Collections[Collection]
|
|
4034
|
+
? E[EntityName] extends Entity<any, any, any, any>
|
|
4035
|
+
? E[EntityName]["schema"] extends Schema<infer A, infer F, infer C>
|
|
4036
|
+
? Collection extends keyof EntityCollections<
|
|
4037
|
+
A,
|
|
4038
|
+
F,
|
|
4039
|
+
C,
|
|
4040
|
+
E[EntityName]["schema"]
|
|
4041
|
+
>
|
|
4042
|
+
? IndexProjectedAttributeNames<
|
|
4043
|
+
A,
|
|
4044
|
+
F,
|
|
4045
|
+
C,
|
|
4046
|
+
E[EntityName]["schema"],
|
|
4047
|
+
EntityCollections<A, F, C, E[EntityName]["schema"]>[Collection]
|
|
4048
|
+
>
|
|
4049
|
+
: never
|
|
4050
|
+
: never
|
|
4051
|
+
: never
|
|
4052
|
+
: never;
|
|
4053
|
+
}[keyof E];
|
|
4054
|
+
|
|
3708
4055
|
export type IndexCollections<
|
|
3709
4056
|
A extends string,
|
|
3710
4057
|
F extends string,
|
|
@@ -5022,7 +5369,8 @@ export class Entity<
|
|
|
5022
5369
|
A extends string,
|
|
5023
5370
|
F extends string,
|
|
5024
5371
|
C extends string,
|
|
5025
|
-
S extends Schema<A, F, C>,
|
|
5372
|
+
S extends Schema<A, F, C, P>,
|
|
5373
|
+
P extends string = string,
|
|
5026
5374
|
> {
|
|
5027
5375
|
readonly schema: S;
|
|
5028
5376
|
private config?: EntityConfiguration;
|
|
@@ -5290,7 +5638,9 @@ export class Entity<
|
|
|
5290
5638
|
S,
|
|
5291
5639
|
ResponseItem<A, F, C, S>,
|
|
5292
5640
|
TableIndexCompositeAttributes<A, F, C, S>
|
|
5293
|
-
|
|
5641
|
+
> &
|
|
5642
|
+
IndexScans<A, F, C, S>;
|
|
5643
|
+
|
|
5294
5644
|
query: Queries<A, F, C, S>;
|
|
5295
5645
|
|
|
5296
5646
|
parse<Options extends ParseOptions<keyof ResponseItem<A, F, C, S>>>(
|
|
@@ -5738,5 +6088,6 @@ declare function createSchema<
|
|
|
5738
6088
|
A extends string,
|
|
5739
6089
|
F extends string,
|
|
5740
6090
|
C extends string,
|
|
5741
|
-
S extends Schema<A, F, C>,
|
|
6091
|
+
S extends Schema<A, F, C, P>,
|
|
6092
|
+
P extends string,
|
|
5742
6093
|
>(schema: S): S;
|