@wix/sdk-types 1.17.2 → 1.17.4
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/build/browser/index.d.mts +368 -5
- package/build/index.d.mts +368 -5
- package/build/index.d.ts +368 -5
- package/internal/build/browser/index.d.mts +368 -5
- package/internal/build/index.d.mts +368 -5
- package/internal/build/index.d.ts +368 -5
- package/package.json +2 -2
|
@@ -562,7 +562,7 @@ type Filter<Entity, Spec extends WQLSpec> = Simplify<{
|
|
|
562
562
|
/**
|
|
563
563
|
* Cursor-based paging configuration
|
|
564
564
|
*/
|
|
565
|
-
interface CursorPaging {
|
|
565
|
+
interface CursorPaging$1 {
|
|
566
566
|
/** Maximum number of items to return in the results. */
|
|
567
567
|
limit?: number | null;
|
|
568
568
|
/**
|
|
@@ -576,7 +576,7 @@ interface CursorPaging {
|
|
|
576
576
|
/**
|
|
577
577
|
* Offset-based paging configuration
|
|
578
578
|
*/
|
|
579
|
-
interface OffsetPaging {
|
|
579
|
+
interface OffsetPaging$1 {
|
|
580
580
|
/** Number of items to load */
|
|
581
581
|
limit?: number | null;
|
|
582
582
|
/** Number of items to skip in the current sort order */
|
|
@@ -592,9 +592,9 @@ type PagingType = 'cursor' | 'offset';
|
|
|
592
592
|
type Paging<Spec extends {
|
|
593
593
|
paging?: PagingType;
|
|
594
594
|
}> = Spec['paging'] extends 'cursor' ? {
|
|
595
|
-
cursorPaging: CursorPaging;
|
|
595
|
+
cursorPaging: CursorPaging$1;
|
|
596
596
|
} : Spec['paging'] extends 'offset' ? {
|
|
597
|
-
paging: OffsetPaging;
|
|
597
|
+
paging: OffsetPaging$1;
|
|
598
598
|
} : {};
|
|
599
599
|
|
|
600
600
|
/**
|
|
@@ -837,6 +837,314 @@ type BaseSearch<Entity, Spec extends SearchSpec> = {
|
|
|
837
837
|
*/
|
|
838
838
|
type Search<Entity, Spec extends SearchSpec> = BaseSearch<Entity, Spec> & Partial<Paging<Spec>>;
|
|
839
839
|
|
|
840
|
+
interface PagingSpec {
|
|
841
|
+
paging: PagingType;
|
|
842
|
+
}
|
|
843
|
+
interface CursorPaging {
|
|
844
|
+
limit: number;
|
|
845
|
+
cursor?: string;
|
|
846
|
+
}
|
|
847
|
+
interface OffsetPaging {
|
|
848
|
+
limit: number;
|
|
849
|
+
offset?: number;
|
|
850
|
+
}
|
|
851
|
+
type PagingFor<S extends PagingSpec> = S['paging'] extends 'cursor' ? CursorPaging : OffsetPaging;
|
|
852
|
+
/**
|
|
853
|
+
* Represents a filter expression that can be combined with other filters
|
|
854
|
+
*/
|
|
855
|
+
interface FilterExpression<T, S extends WQLSpec> {
|
|
856
|
+
readonly filter: Filter<T, S>;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Represents a sort expression
|
|
860
|
+
*/
|
|
861
|
+
interface SortExpression<S extends WQLSpec> {
|
|
862
|
+
readonly sort: Sorting<S>;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Extract fields that support a specific operator from the spec
|
|
866
|
+
*/
|
|
867
|
+
type FieldsWithOperator<S extends WQLSpec, Op extends string> = S['wql'][number] extends infer Group ? Group extends WQL ? Group['operators'] extends readonly string[] ? Op extends Group['operators'][number] ? Group['fields'][number] : never : Group['fields'][number] : never : never;
|
|
868
|
+
/**
|
|
869
|
+
* Check if a specific field supports a specific operator
|
|
870
|
+
*/
|
|
871
|
+
type HasOperator<S extends WQLSpec, Field extends string, Op extends string> = Field extends FieldsWithOperator<S, Op> ? true : false;
|
|
872
|
+
/**
|
|
873
|
+
* Extract sortable fields from the spec
|
|
874
|
+
*/
|
|
875
|
+
type SortableFields<S extends WQLSpec> = S['wql'][number] extends infer Group ? Group extends {
|
|
876
|
+
fields: readonly string[];
|
|
877
|
+
sort: 'ASC' | 'DESC' | 'BOTH';
|
|
878
|
+
} ? Group['fields'][number] : never : never;
|
|
879
|
+
/**
|
|
880
|
+
* Chainable field filter - extends FilterExpression so it can be used directly,
|
|
881
|
+
* but also allows chaining multiple operators on the same field.
|
|
882
|
+
* @example
|
|
883
|
+
* // Single operator - returns ChainableFieldFilter which is also FilterExpression
|
|
884
|
+
* Filter('price').gt(50)
|
|
885
|
+
*
|
|
886
|
+
* // Chained operators - combines into single field filter
|
|
887
|
+
* Filter('price').gt(50).lt(100)
|
|
888
|
+
* // Produces: { price: { $gt: 50, $lt: 100 } }
|
|
889
|
+
*/
|
|
890
|
+
type ChainableFieldFilter<T, S extends WQLSpec, Field extends FilterableFields<S>> = FilterExpression<T, S> & (HasOperator<S, Field & string, '$eq'> extends true ? {
|
|
891
|
+
eq(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
|
|
892
|
+
} : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
|
|
893
|
+
ne(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
|
|
894
|
+
} : {}) & (HasOperator<S, Field & string, '$gt'> extends true ? {
|
|
895
|
+
gt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
|
|
896
|
+
} : {}) & (HasOperator<S, Field & string, '$gte'> extends true ? {
|
|
897
|
+
gte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
|
|
898
|
+
} : {}) & (HasOperator<S, Field & string, '$lt'> extends true ? {
|
|
899
|
+
lt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
|
|
900
|
+
} : {}) & (HasOperator<S, Field & string, '$lte'> extends true ? {
|
|
901
|
+
lte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
|
|
902
|
+
} : {}) & (HasOperator<S, Field & string, '$startsWith'> extends true ? {
|
|
903
|
+
startsWith(value: string): ChainableFieldFilter<T, S, Field>;
|
|
904
|
+
} : {}) & (HasOperator<S, Field & string, '$endsWith'> extends true ? {
|
|
905
|
+
endsWith(value: string): ChainableFieldFilter<T, S, Field>;
|
|
906
|
+
} : {}) & (HasOperator<S, Field & string, '$contains'> extends true ? {
|
|
907
|
+
contains(value: string): ChainableFieldFilter<T, S, Field>;
|
|
908
|
+
} : {}) & (HasOperator<S, Field & string, '$in'> extends true ? {
|
|
909
|
+
in(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
|
|
910
|
+
} : {}) & (HasOperator<S, Field & string, '$nin'> extends true ? {
|
|
911
|
+
nin(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
|
|
912
|
+
} : {}) & (HasOperator<S, Field & string, '$hasSome'> extends true ? {
|
|
913
|
+
hasSome(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
|
|
914
|
+
} : {}) & (HasOperator<S, Field & string, '$hasAll'> extends true ? {
|
|
915
|
+
hasAll(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
|
|
916
|
+
} : {}) & (HasOperator<S, Field & string, '$exists'> extends true ? {
|
|
917
|
+
exists(value?: boolean): ChainableFieldFilter<T, S, Field>;
|
|
918
|
+
} : {}) & (HasOperator<S, Field & string, '$isEmpty'> extends true ? {
|
|
919
|
+
isEmpty(value?: boolean): ChainableFieldFilter<T, S, Field>;
|
|
920
|
+
} : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
|
|
921
|
+
isNotEmpty(): ChainableFieldFilter<T, S, Field>;
|
|
922
|
+
} : {});
|
|
923
|
+
/**
|
|
924
|
+
* Filter methods for a specific field (alias for ChainableFieldFilter)
|
|
925
|
+
* Only shows methods for operators that the field supports
|
|
926
|
+
*/
|
|
927
|
+
type FieldFilter<T, S extends WQLSpec, Field extends FilterableFields<S>> = ChainableFieldFilter<T, S, Field>;
|
|
928
|
+
/**
|
|
929
|
+
* Sort methods for a specific field
|
|
930
|
+
*/
|
|
931
|
+
interface FieldSort<S extends WQLSpec> {
|
|
932
|
+
asc(): SortExpression<S>;
|
|
933
|
+
desc(): SortExpression<S>;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Filter factory interface - creates filter expressions
|
|
937
|
+
* @example
|
|
938
|
+
* Filter('price').gt(50)
|
|
939
|
+
* Filter.and(Filter('title').eq('Product'), Filter('price').gt(50))
|
|
940
|
+
*/
|
|
941
|
+
interface FilterFactory<T, S extends WQLSpec> {
|
|
942
|
+
/** Create a field-specific filter */
|
|
943
|
+
<Field extends FilterableFields<S>>(field: Field): FieldFilter<T, S, Field>;
|
|
944
|
+
/** Combine filters with AND logic */
|
|
945
|
+
and(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
|
|
946
|
+
/** Combine filters with OR logic */
|
|
947
|
+
or(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
|
|
948
|
+
/** Negate a filter */
|
|
949
|
+
not(filter: FilterExpression<T, S>): FilterExpression<T, S>;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Sort factory - creates sort expressions
|
|
953
|
+
* @example
|
|
954
|
+
* Sort('price').desc()
|
|
955
|
+
*/
|
|
956
|
+
type SortFactory<S extends WQLSpec> = <Field extends SortableFields<S>>(field: Field) => FieldSort<S>;
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* The output type from SearchBuilder.build()
|
|
960
|
+
* This is a plain object ready to be sent to an API
|
|
961
|
+
*/
|
|
962
|
+
interface SearchRequest<T, S extends SearchSpec> {
|
|
963
|
+
/** Filter object */
|
|
964
|
+
filter?: Filter<T, S>;
|
|
965
|
+
/** List of sort objects */
|
|
966
|
+
sort?: Sorting<S>[];
|
|
967
|
+
/** Full-text search parameters */
|
|
968
|
+
search?: SearchDetails<S>;
|
|
969
|
+
/** Aggregations to compute */
|
|
970
|
+
aggregations?: Aggregation<S>[];
|
|
971
|
+
/** Paging configuration */
|
|
972
|
+
paging?: PagingFor<S>;
|
|
973
|
+
/** Time zone for date operations */
|
|
974
|
+
timeZone?: string;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Represents a search expression that can be used in SearchBuilder
|
|
978
|
+
*/
|
|
979
|
+
interface SearchExpression<S extends SearchSpec> {
|
|
980
|
+
readonly search: SearchDetails<S>;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Represents an aggregation expression that can be used in SearchBuilder
|
|
984
|
+
*/
|
|
985
|
+
interface AggregationExpression<S extends SearchSpec> {
|
|
986
|
+
readonly aggregation: Aggregation<S>;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Builder for constructing search parameters
|
|
990
|
+
* @example
|
|
991
|
+
* SearchParams('dark shoes')
|
|
992
|
+
* .mode('AND')
|
|
993
|
+
* .fields(['productName', 'description'])
|
|
994
|
+
* .fuzzy(true)
|
|
995
|
+
*/
|
|
996
|
+
interface SearchParamsBuilder<S extends SearchSpec> extends SearchExpression<S> {
|
|
997
|
+
/** Set the search expression/query string */
|
|
998
|
+
expression(expr: string): SearchParamsBuilder<S>;
|
|
999
|
+
/** Set the search mode (how to combine multiple terms) */
|
|
1000
|
+
mode(mode: 'AND' | 'OR'): SearchParamsBuilder<S>;
|
|
1001
|
+
/** Set the fields to search in */
|
|
1002
|
+
fields(fields: SearchableFields<S>[]): SearchParamsBuilder<S>;
|
|
1003
|
+
/** Enable or disable fuzzy matching */
|
|
1004
|
+
fuzzy(enabled?: boolean): SearchParamsBuilder<S>;
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Factory function for creating SearchParamsBuilder
|
|
1008
|
+
* @param expression - Optional search expression to initialize with
|
|
1009
|
+
*/
|
|
1010
|
+
type SearchParamsFactory<S extends SearchSpec> = (expression?: string) => SearchParamsBuilder<S>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Sort configuration for value aggregations
|
|
1013
|
+
*/
|
|
1014
|
+
interface ValueAggregationSort {
|
|
1015
|
+
sortBy(type: 'COUNT' | 'VALUE', direction: 'ASC' | 'DESC'): this;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Builder for VALUE type aggregations
|
|
1019
|
+
*/
|
|
1020
|
+
interface ValueAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S>, ValueAggregationSort {
|
|
1021
|
+
/** Set maximum number of buckets to return */
|
|
1022
|
+
limit(count: number): ValueAggregationBuilder<S>;
|
|
1023
|
+
/** Exclude documents with missing values */
|
|
1024
|
+
excludeMissingValues(): ValueAggregationBuilder<S>;
|
|
1025
|
+
/** Include documents with missing values */
|
|
1026
|
+
includeMissingValues(): ValueAggregationBuilder<S>;
|
|
1027
|
+
/** Include specific values in their own bucket */
|
|
1028
|
+
includeValues(addToBucket: string): ValueAggregationBuilder<S>;
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Builder for RANGE type aggregations
|
|
1032
|
+
*/
|
|
1033
|
+
interface RangeAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1034
|
+
/** Set the range buckets */
|
|
1035
|
+
withBuckets(...buckets: {
|
|
1036
|
+
from?: number | null;
|
|
1037
|
+
to?: number | null;
|
|
1038
|
+
}[]): RangeAggregationBuilder<S>;
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Builder for DATE_HISTOGRAM type aggregations
|
|
1042
|
+
*/
|
|
1043
|
+
interface DateHistogramAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1044
|
+
/** Set the interval for date histogram buckets */
|
|
1045
|
+
interval(interval: 'YEAR' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND'): DateHistogramAggregationBuilder<S>;
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Builder for SCALAR type aggregations
|
|
1049
|
+
*/
|
|
1050
|
+
interface ScalarAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1051
|
+
/** Set the scalar aggregation type */
|
|
1052
|
+
type(scalarType: 'COUNT_DISTINCT' | 'MIN' | 'MAX' | 'SUM' | 'AVG'): ScalarAggregationBuilder<S>;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Builder for NESTED type aggregations
|
|
1056
|
+
*/
|
|
1057
|
+
interface NestedAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1058
|
+
/** Add a nested aggregation */
|
|
1059
|
+
addNestedAggregation(aggregation: AggregationExpression<S>): NestedAggregationBuilder<S>;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Aggregation type configuration
|
|
1063
|
+
*/
|
|
1064
|
+
type AggregationType = 'VALUE' | 'RANGE' | 'DATE_HISTOGRAM' | 'SCALAR' | 'NESTED';
|
|
1065
|
+
/**
|
|
1066
|
+
* Builder for constructing aggregations
|
|
1067
|
+
* @example
|
|
1068
|
+
* Aggregation('status_count')
|
|
1069
|
+
* .ofType('VALUE')
|
|
1070
|
+
* .onField('status')
|
|
1071
|
+
* .asValueAggregation()
|
|
1072
|
+
* .sortBy('COUNT', 'DESC')
|
|
1073
|
+
* .limit(10)
|
|
1074
|
+
*/
|
|
1075
|
+
interface AggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1076
|
+
/** Set the aggregation type */
|
|
1077
|
+
ofType(type: AggregationType): AggregationBuilder<S>;
|
|
1078
|
+
/** Set the field to aggregate on */
|
|
1079
|
+
onField(field: AggregatableFields<S>): AggregationBuilder<S>;
|
|
1080
|
+
/** Configure as a value aggregation */
|
|
1081
|
+
asValueAggregation(): ValueAggregationBuilder<S>;
|
|
1082
|
+
/** Configure as a range aggregation */
|
|
1083
|
+
asRangeAggregation(): RangeAggregationBuilder<S>;
|
|
1084
|
+
/** Configure as a date histogram aggregation */
|
|
1085
|
+
asDateHistogramAggregation(): DateHistogramAggregationBuilder<S>;
|
|
1086
|
+
/** Configure as a scalar aggregation */
|
|
1087
|
+
asScalarAggregation(): ScalarAggregationBuilder<S>;
|
|
1088
|
+
/** Configure as a nested aggregation */
|
|
1089
|
+
asNestedAggregation(): NestedAggregationBuilder<S>;
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Factory function for creating AggregationBuilder
|
|
1093
|
+
*/
|
|
1094
|
+
type AggregationFactory<S extends SearchSpec> = (name: string) => AggregationBuilder<S>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Search builder interface for constructing search requests
|
|
1097
|
+
* @template T - Entity type
|
|
1098
|
+
* @template S - Search spec defining filterable/sortable/searchable/aggregatable fields
|
|
1099
|
+
* @template R - Output type from build() (defaults to SearchRequest<T, S>)
|
|
1100
|
+
* @example
|
|
1101
|
+
* SearchBuilder()
|
|
1102
|
+
* .withFilter(Filter.and(
|
|
1103
|
+
* Filter('title').eq('Product'),
|
|
1104
|
+
* Filter('price').gt(50)
|
|
1105
|
+
* ))
|
|
1106
|
+
* .withSearchClause(SearchParams('shoes').fuzzy(true))
|
|
1107
|
+
* .withAggregation(Aggregation('status_count').ofType('VALUE').onField('status'))
|
|
1108
|
+
* .withSorting(Sort('price').desc())
|
|
1109
|
+
* .withPaging({ limit: 20 })
|
|
1110
|
+
* .build()
|
|
1111
|
+
*/
|
|
1112
|
+
interface SearchBuilder<T, S extends SearchSpec, R = SearchRequest<T, S>> {
|
|
1113
|
+
/** Add a filter to the search */
|
|
1114
|
+
withFilter(filter: FilterExpression<T, S>): SearchBuilder<T, S, R>;
|
|
1115
|
+
/** Add a search clause for full-text search */
|
|
1116
|
+
withSearchClause(search: SearchExpression<S>): SearchBuilder<T, S, R>;
|
|
1117
|
+
/** Add sorting to the search */
|
|
1118
|
+
withSorting(...sorts: SortExpression<S>[]): SearchBuilder<T, S, R>;
|
|
1119
|
+
/** Add aggregations to the search */
|
|
1120
|
+
withAggregation(...aggregations: AggregationExpression<S>[]): SearchBuilder<T, S, R>;
|
|
1121
|
+
/** Add paging to the search */
|
|
1122
|
+
withPaging(paging: PagingFor<S>): SearchBuilder<T, S, R>;
|
|
1123
|
+
/** Set the time zone for date operations */
|
|
1124
|
+
withTimeZone(timeZone: string): SearchBuilder<T, S, R>;
|
|
1125
|
+
/** Build the final search request object */
|
|
1126
|
+
build(): R;
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Complete set of search helpers for an entity
|
|
1130
|
+
* This is what gets spread into module namespaces
|
|
1131
|
+
* @template T - Entity type
|
|
1132
|
+
* @template S - Search spec defining filterable/sortable/searchable/aggregatable fields
|
|
1133
|
+
* @template R - Output type from SearchBuilder.build() (defaults to SearchRequest<T, S>)
|
|
1134
|
+
*/
|
|
1135
|
+
interface SearchHelpers<T, S extends SearchSpec, R = SearchRequest<T, S>> {
|
|
1136
|
+
/** SearchBuilder factory */
|
|
1137
|
+
SearchBuilder: () => SearchBuilder<T, S, R>;
|
|
1138
|
+
/** Filter factory - creates filter expressions (reused from query) */
|
|
1139
|
+
Filter: FilterFactory<T, S>;
|
|
1140
|
+
/** Sort factory - creates sort expressions (reused from query) */
|
|
1141
|
+
Sort: SortFactory<S>;
|
|
1142
|
+
/** Search params factory - creates search expressions */
|
|
1143
|
+
SearchParams: SearchParamsFactory<S>;
|
|
1144
|
+
/** Aggregation factory - creates aggregation expressions */
|
|
1145
|
+
Aggregation: AggregationFactory<S>;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
840
1148
|
/**
|
|
841
1149
|
* Specification for a query API
|
|
842
1150
|
* Defines what fields can be filtered and sorted
|
|
@@ -894,4 +1202,59 @@ type Query<Entity, Spec extends QuerySpec> = {
|
|
|
894
1202
|
sort?: Sorting<Spec>[];
|
|
895
1203
|
} & Partial<Paging<Spec>>;
|
|
896
1204
|
|
|
897
|
-
|
|
1205
|
+
/**
|
|
1206
|
+
* The output type from QueryBuilder.build()
|
|
1207
|
+
* This is a plain object ready to be sent to an API
|
|
1208
|
+
*/
|
|
1209
|
+
interface QueryRequest<T, S extends QuerySpec> {
|
|
1210
|
+
filter?: Filter<T, S>;
|
|
1211
|
+
sort?: Sorting<S>[];
|
|
1212
|
+
paging?: PagingFor<S>;
|
|
1213
|
+
/** Field projection - return only specified fields */
|
|
1214
|
+
fields?: string[];
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Query builder interface
|
|
1218
|
+
* @template T - Entity type
|
|
1219
|
+
* @template S - Query spec defining filterable/sortable fields
|
|
1220
|
+
* @template R - Output type from build() (defaults to QueryRequest<T, S>)
|
|
1221
|
+
* @example
|
|
1222
|
+
* QueryBuilder()
|
|
1223
|
+
* .withFilter(Filter.and(
|
|
1224
|
+
* Filter('title').eq('Product'),
|
|
1225
|
+
* Filter('price').gt(50)
|
|
1226
|
+
* ))
|
|
1227
|
+
* .withFields('title', 'price')
|
|
1228
|
+
* .withSorting(Sort('price').desc())
|
|
1229
|
+
* .withPaging({ limit: 20, offset: 0 })
|
|
1230
|
+
* .build()
|
|
1231
|
+
*/
|
|
1232
|
+
interface QueryBuilder<T, S extends QuerySpec, R = QueryRequest<T, S>> {
|
|
1233
|
+
/** Add a filter to the query */
|
|
1234
|
+
withFilter(filter: FilterExpression<T, S>): QueryBuilder<T, S, R>;
|
|
1235
|
+
/** Add field projection - return only specified fields */
|
|
1236
|
+
withFields(...fields: (keyof T & string)[]): QueryBuilder<T, S, R>;
|
|
1237
|
+
/** Add sorting to the query */
|
|
1238
|
+
withSorting(...sorts: SortExpression<S>[]): QueryBuilder<T, S, R>;
|
|
1239
|
+
/** Add paging to the query */
|
|
1240
|
+
withPaging(paging: PagingFor<S>): QueryBuilder<T, S, R>;
|
|
1241
|
+
/** Build the final query request object */
|
|
1242
|
+
build(): R;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Complete set of query helpers for an entity
|
|
1246
|
+
* This is what gets spread into module namespaces
|
|
1247
|
+
* @template T - Entity type
|
|
1248
|
+
* @template S - Query spec defining filterable/sortable fields
|
|
1249
|
+
* @template R - Output type from QueryBuilder.build() (defaults to QueryRequest<T, S>)
|
|
1250
|
+
*/
|
|
1251
|
+
interface QueryHelpers<T, S extends QuerySpec, R = QueryRequest<T, S>> {
|
|
1252
|
+
/** QueryBuilder factory */
|
|
1253
|
+
QueryBuilder: () => QueryBuilder<T, S, R>;
|
|
1254
|
+
/** Filter factory - creates filter expressions */
|
|
1255
|
+
Filter: FilterFactory<T, S>;
|
|
1256
|
+
/** Sort factory - creates sort expressions */
|
|
1257
|
+
Sort: SortFactory<S>;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
export { type APIMetadata, type AccountInfo, type AggregatableFields, type Aggregation, type AggregationBuilder, type AggregationExpression, type AggregationFactory, type AggregationType, type AmbassadorFactory, type AmbassadorFunctionDescriptor, type AmbassadorRequestOptions, type AuthenticationStrategy, type BaseEventMetadata, type BoundAuthenticationStrategy, type BuildAmbassadorFunction, type BuildDescriptors, type BuildEventDefinition, type BuildRESTFunction, type BuildServicePluginDefinition, type CursorPaging, type DateHistogramAggregationBuilder, type Descriptors, EventDefinition, type EventHandler, type EventIdentity, type ExposeFieldsBasedOnToggle, type FieldFilter, type FieldSort, type Filter, type FilterExpression, type FilterFactory, type FilterableFields, type GetNestedType, type HTTPMethod, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type MaybeContext, type Method, type MigrationOptions, type NestedAggregationBuilder, type NonNullablePaths, type OffsetPaging, type PagingFor, type PublicMetadata, type Query, type QueryBuilder, type QueryHelpers, type QueryRequest, type QuerySpec, type RESTFunctionDescriptor, type RangeAggregationBuilder, type RequestContext, type RequestOptions, type RequestOptionsFactory, type RestModuleMeta, SERVICE_PLUGIN_ERROR_TYPE, SORT_CAPABILITIES, SORT_DIRECTIONS, type ScalarAggregationBuilder, type Search, type SearchBuilder, type SearchDetails, type SearchExpression, type SearchHelpers, type SearchParamsBuilder, type SearchParamsFactory, type SearchRequest, type SearchSpec, type SearchableFields, type ServicePluginContract, ServicePluginDefinition, type ServicePluginMethodInput, type ServicePluginMethodMetadata, type SortCapability, type SortExpression, type SortFactory, type SortOrder, type Sorting, type ValueAggregationBuilder, type ValueAggregationSort, type WQL, type WQLSpec };
|