@@ -11,30 +11,32 @@ import { PrimitiveKeys, toBase64FromMedia } from '../../index.js';
1111import { Bm25QueryProperty } from '../query/types.js' ;
1212import { Serialize } from '../serialize/index.js' ;
1313
14- export type AggregateBaseOptions < T , M > = {
14+ export type AggregateBaseOptions < M > = {
1515 filters ?: FilterValue ;
1616 returnMetrics ?: M ;
1717} ;
1818
19- export type AggregateGroupByOptions < T , M > = AggregateBaseOptions < T , M > & {
20- groupBy : T extends undefined ? string : ( keyof T & string ) | GroupByAggregate < T > ;
19+ export type PropertyOf < T > = T extends undefined ? string : keyof T & string ;
20+
21+ export type AggregateGroupByOptions < T , M > = AggregateBaseOptions < M > & {
22+ groupBy : PropertyOf < T > | GroupByAggregate < T > ;
2123} ;
2224
2325export type GroupByAggregate < T > = {
2426 property : T extends undefined ? string : keyof T & string ;
2527 limit ?: number ;
2628} ;
2729
28- export type AggregateOverAllOptions < T , M > = AggregateBaseOptions < T , M > ;
30+ export type AggregateOverAllOptions < M > = AggregateBaseOptions < M > ;
2931
30- export type AggregateNearOptions < T , M > = AggregateBaseOptions < T , M > & {
32+ export type AggregateNearOptions < M > = AggregateBaseOptions < M > & {
3133 certainty ?: number ;
3234 distance ?: number ;
3335 objectLimit ?: number ;
3436 targetVector ?: string ;
3537} ;
3638
37- export type AggregateHybridOptions < T , M > = AggregateBaseOptions < T , M > & {
39+ export type AggregateHybridOptions < T , M > = AggregateBaseOptions < M > & {
3840 alpha ?: number ;
3941 maxVectorDistance ?: number ;
4042 objectLimit ?: number ;
@@ -44,11 +46,11 @@ export type AggregateHybridOptions<T, M> = AggregateBaseOptions<T, M> & {
4446} ;
4547
4648export type AggregateGroupByHybridOptions < T , M > = AggregateHybridOptions < T , M > & {
47- groupBy : T extends undefined ? string : ( keyof T & string ) | GroupByAggregate < T > ;
49+ groupBy : PropertyOf < T > | GroupByAggregate < T > ;
4850} ;
4951
50- export type AggregateGroupByNearOptions < T , M > = AggregateNearOptions < T , M > & {
51- groupBy : T extends undefined ? string : ( keyof T & string ) | GroupByAggregate < T > ;
52+ export type AggregateGroupByNearOptions < T , M > = AggregateNearOptions < M > & {
53+ groupBy : PropertyOf < T > | GroupByAggregate < T > ;
5254} ;
5355
5456export type AggregateBoolean = {
@@ -538,7 +540,7 @@ class AggregateManager<T> implements Aggregate<T> {
538540
539541 async nearImage < M extends PropertiesMetrics < T > > (
540542 image : string | Buffer ,
541- opts ?: AggregateNearOptions < T , M >
543+ opts ?: AggregateNearOptions < M >
542544 ) : Promise < AggregateResult < T , M > > {
543545 const builder = this . base ( opts ?. returnMetrics , opts ?. filters ) . withNearImage ( {
544546 image : await toBase64FromMedia ( image ) ,
@@ -554,7 +556,7 @@ class AggregateManager<T> implements Aggregate<T> {
554556
555557 nearObject < M extends PropertiesMetrics < T > > (
556558 id : string ,
557- opts ?: AggregateNearOptions < T , M >
559+ opts ?: AggregateNearOptions < M >
558560 ) : Promise < AggregateResult < T , M > > {
559561 const builder = this . base ( opts ?. returnMetrics , opts ?. filters ) . withNearObject ( {
560562 id : id ,
@@ -570,7 +572,7 @@ class AggregateManager<T> implements Aggregate<T> {
570572
571573 nearText < M extends PropertiesMetrics < T > > (
572574 query : string | string [ ] ,
573- opts ?: AggregateNearOptions < T , M >
575+ opts ?: AggregateNearOptions < M >
574576 ) : Promise < AggregateResult < T , M > > {
575577 const builder = this . base ( opts ?. returnMetrics , opts ?. filters ) . withNearText ( {
576578 concepts : Array . isArray ( query ) ? query : [ query ] ,
@@ -586,7 +588,7 @@ class AggregateManager<T> implements Aggregate<T> {
586588
587589 nearVector < M extends PropertiesMetrics < T > > (
588590 vector : number [ ] ,
589- opts ?: AggregateNearOptions < T , M >
591+ opts ?: AggregateNearOptions < M >
590592 ) : Promise < AggregateResult < T , M > > {
591593 const builder = this . base ( opts ?. returnMetrics , opts ?. filters ) . withNearVector ( {
592594 vector : vector ,
@@ -600,9 +602,7 @@ class AggregateManager<T> implements Aggregate<T> {
600602 return this . do ( builder ) ;
601603 }
602604
603- overAll < M extends PropertiesMetrics < T > > (
604- opts ?: AggregateOverAllOptions < T , M >
605- ) : Promise < AggregateResult < T , M > > {
605+ overAll < M extends PropertiesMetrics < T > > ( opts ?: AggregateOverAllOptions < M > ) : Promise < AggregateResult < T , M > > {
606606 const builder = this . base ( opts ?. returnMetrics , opts ?. filters ) ;
607607 return this . do ( builder ) ;
608608 }
@@ -677,7 +677,7 @@ export interface Aggregate<T> {
677677 */
678678 nearImage < M extends PropertiesMetrics < T > > (
679679 image : string | Buffer ,
680- opts ?: AggregateNearOptions < T , M >
680+ opts ?: AggregateNearOptions < M >
681681 ) : Promise < AggregateResult < T , M > > ;
682682 /**
683683 * Aggregate metrics over the objects returned by a near object search on this collection.
@@ -692,7 +692,7 @@ export interface Aggregate<T> {
692692 */
693693 nearObject < M extends PropertiesMetrics < T > > (
694694 id : string ,
695- opts ?: AggregateNearOptions < T , M >
695+ opts ?: AggregateNearOptions < M >
696696 ) : Promise < AggregateResult < T , M > > ;
697697 /**
698698 * Aggregate metrics over the objects returned by a near vector search on this collection.
@@ -707,7 +707,7 @@ export interface Aggregate<T> {
707707 */
708708 nearText < M extends PropertiesMetrics < T > > (
709709 query : string | string [ ] ,
710- opts ?: AggregateNearOptions < T , M >
710+ opts ?: AggregateNearOptions < M >
711711 ) : Promise < AggregateResult < T , M > > ;
712712 /**
713713 * Aggregate metrics over the objects returned by a near vector search on this collection.
@@ -722,17 +722,15 @@ export interface Aggregate<T> {
722722 */
723723 nearVector < M extends PropertiesMetrics < T > > (
724724 vector : number [ ] ,
725- opts ?: AggregateNearOptions < T , M >
725+ opts ?: AggregateNearOptions < M >
726726 ) : Promise < AggregateResult < T , M > > ;
727727 /**
728728 * Aggregate metrics over all the objects in this collection without any vector search.
729729 *
730730 * @param {AggregateOptions<T, M> } [opts] The options for the request.
731731 * @returns {Promise<AggregateResult<T, M>[]> } The aggregated metrics for the objects in the collection.
732732 */
733- overAll < M extends PropertiesMetrics < T > > (
734- opts ?: AggregateOverAllOptions < T , M >
735- ) : Promise < AggregateResult < T , M > > ;
733+ overAll < M extends PropertiesMetrics < T > > ( opts ?: AggregateOverAllOptions < M > ) : Promise < AggregateResult < T , M > > ;
736734}
737735
738736export interface AggregateGroupBy < T > {
0 commit comments