@wix/sdk-types 1.17.3 → 1.17.5
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 +277 -78
- package/build/index.d.mts +277 -78
- package/build/index.d.ts +277 -78
- package/internal/build/browser/index.d.mts +277 -78
- package/internal/build/index.d.mts +277 -78
- package/internal/build/index.d.ts +277 -78
- package/package.json +2 -2
|
@@ -73,7 +73,12 @@ interface HttpClient {
|
|
|
73
73
|
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
74
74
|
fetchWithAuth: typeof fetch;
|
|
75
75
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
76
|
+
/** Returns the current access token synchronously, if available. */
|
|
76
77
|
getActiveToken?: () => string | undefined;
|
|
78
|
+
/** Returns auth headers (may trigger token refresh). Prefer this over getActiveToken when making authenticated requests. */
|
|
79
|
+
getAuthHeaders?: () => Promise<{
|
|
80
|
+
headers: Record<string, string>;
|
|
81
|
+
}>;
|
|
77
82
|
}
|
|
78
83
|
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
79
84
|
type HttpResponse<T = any> = {
|
|
@@ -837,63 +842,9 @@ type BaseSearch<Entity, Spec extends SearchSpec> = {
|
|
|
837
842
|
*/
|
|
838
843
|
type Search<Entity, Spec extends SearchSpec> = BaseSearch<Entity, Spec> & Partial<Paging<Spec>>;
|
|
839
844
|
|
|
840
|
-
|
|
841
|
-
* Specification for a query API
|
|
842
|
-
* Defines what fields can be filtered and sorted
|
|
843
|
-
* @example
|
|
844
|
-
* interface MyQuerySpec extends QuerySpec {
|
|
845
|
-
* wql: [{
|
|
846
|
-
* operators: ['$eq', '$ne'],
|
|
847
|
-
* fields: ['id', 'title'],
|
|
848
|
-
* sort: 'BOTH'
|
|
849
|
-
* }],
|
|
850
|
-
* paging: 'offset', // or 'cursor' for cursor-based pagination
|
|
851
|
-
* };
|
|
852
|
-
*/
|
|
853
|
-
interface QuerySpec extends WQLSpec {
|
|
854
|
-
/**
|
|
855
|
-
* Supported paging type for this query API
|
|
856
|
-
* - 'cursor': Uses cursor-based pagination
|
|
857
|
-
* - 'offset': Uses offset-based pagination
|
|
858
|
-
*/
|
|
845
|
+
interface PagingSpec {
|
|
859
846
|
paging: PagingType;
|
|
860
847
|
}
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* Complete query request for an entity type
|
|
864
|
-
* @template Entity The entity type being queried
|
|
865
|
-
* @template Spec The query specification type
|
|
866
|
-
* @example
|
|
867
|
-
* // Define a query type for products
|
|
868
|
-
* type QueryProducts = Query<Product, ProductQuerySpec>;
|
|
869
|
-
*
|
|
870
|
-
* // Create a query request with offset paging
|
|
871
|
-
* const query: QueryProducts = {
|
|
872
|
-
* filter: { price: { $gte: 10 } },
|
|
873
|
-
* sort: [{ fieldName: 'price', order: 'ASC' }],
|
|
874
|
-
* paging: { limit: 20, offset: 0 }
|
|
875
|
-
* };
|
|
876
|
-
*
|
|
877
|
-
* // Or with cursor paging (if spec.paging = 'cursor')
|
|
878
|
-
* const query: QueryProducts = {
|
|
879
|
-
* filter: { price: { $gte: 10 } },
|
|
880
|
-
* sort: [{ fieldName: 'price', order: 'ASC' }],
|
|
881
|
-
* cursorPaging: { limit: 20, cursor: "..." }
|
|
882
|
-
* };
|
|
883
|
-
*/
|
|
884
|
-
type Query<Entity, Spec extends QuerySpec> = {
|
|
885
|
-
/**
|
|
886
|
-
* Filter object.
|
|
887
|
-
* Learn more about the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language#the-filter-section).
|
|
888
|
-
*/
|
|
889
|
-
filter?: Filter<Entity, Spec>;
|
|
890
|
-
/**
|
|
891
|
-
* List of sort objects.
|
|
892
|
-
* Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language#the-sort-section).
|
|
893
|
-
*/
|
|
894
|
-
sort?: Sorting<Spec>[];
|
|
895
|
-
} & Partial<Paging<Spec>>;
|
|
896
|
-
|
|
897
848
|
interface CursorPaging {
|
|
898
849
|
limit: number;
|
|
899
850
|
cursor?: string;
|
|
@@ -902,42 +853,31 @@ interface OffsetPaging {
|
|
|
902
853
|
limit: number;
|
|
903
854
|
offset?: number;
|
|
904
855
|
}
|
|
905
|
-
type PagingFor<S extends
|
|
906
|
-
/**
|
|
907
|
-
* The output type from QueryBuilder.build()
|
|
908
|
-
* This is a plain object ready to be sent to an API
|
|
909
|
-
*/
|
|
910
|
-
interface QueryRequest<T, S extends QuerySpec> {
|
|
911
|
-
filter?: Filter<T, S>;
|
|
912
|
-
sort?: Sorting<S>[];
|
|
913
|
-
paging?: PagingFor<S>;
|
|
914
|
-
/** Field projection - return only specified fields */
|
|
915
|
-
fields?: string[];
|
|
916
|
-
}
|
|
856
|
+
type PagingFor<S extends PagingSpec> = S['paging'] extends 'cursor' ? CursorPaging : OffsetPaging;
|
|
917
857
|
/**
|
|
918
858
|
* Represents a filter expression that can be combined with other filters
|
|
919
859
|
*/
|
|
920
|
-
interface FilterExpression<T, S extends
|
|
860
|
+
interface FilterExpression<T, S extends WQLSpec> {
|
|
921
861
|
readonly filter: Filter<T, S>;
|
|
922
862
|
}
|
|
923
863
|
/**
|
|
924
864
|
* Represents a sort expression
|
|
925
865
|
*/
|
|
926
|
-
interface SortExpression<S extends
|
|
866
|
+
interface SortExpression<S extends WQLSpec> {
|
|
927
867
|
readonly sort: Sorting<S>;
|
|
928
868
|
}
|
|
929
869
|
/**
|
|
930
870
|
* Extract fields that support a specific operator from the spec
|
|
931
871
|
*/
|
|
932
|
-
type FieldsWithOperator<S extends
|
|
872
|
+
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;
|
|
933
873
|
/**
|
|
934
874
|
* Check if a specific field supports a specific operator
|
|
935
875
|
*/
|
|
936
|
-
type HasOperator<S extends
|
|
876
|
+
type HasOperator<S extends WQLSpec, Field extends string, Op extends string> = Field extends FieldsWithOperator<S, Op> ? true : false;
|
|
937
877
|
/**
|
|
938
878
|
* Extract sortable fields from the spec
|
|
939
879
|
*/
|
|
940
|
-
type SortableFields<S extends
|
|
880
|
+
type SortableFields<S extends WQLSpec> = S['wql'][number] extends infer Group ? Group extends {
|
|
941
881
|
fields: readonly string[];
|
|
942
882
|
sort: 'ASC' | 'DESC' | 'BOTH';
|
|
943
883
|
} ? Group['fields'][number] : never : never;
|
|
@@ -952,7 +892,7 @@ type SortableFields<S extends QuerySpec> = S['wql'][number] extends infer Group
|
|
|
952
892
|
* Filter('price').gt(50).lt(100)
|
|
953
893
|
* // Produces: { price: { $gt: 50, $lt: 100 } }
|
|
954
894
|
*/
|
|
955
|
-
type ChainableFieldFilter<T, S extends
|
|
895
|
+
type ChainableFieldFilter<T, S extends WQLSpec, Field extends FilterableFields<S>> = FilterExpression<T, S> & (HasOperator<S, Field & string, '$eq'> extends true ? {
|
|
956
896
|
eq(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
|
|
957
897
|
} : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
|
|
958
898
|
ne(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
|
|
@@ -989,11 +929,11 @@ type ChainableFieldFilter<T, S extends QuerySpec, Field extends FilterableFields
|
|
|
989
929
|
* Filter methods for a specific field (alias for ChainableFieldFilter)
|
|
990
930
|
* Only shows methods for operators that the field supports
|
|
991
931
|
*/
|
|
992
|
-
type FieldFilter<T, S extends
|
|
932
|
+
type FieldFilter<T, S extends WQLSpec, Field extends FilterableFields<S>> = ChainableFieldFilter<T, S, Field>;
|
|
993
933
|
/**
|
|
994
934
|
* Sort methods for a specific field
|
|
995
935
|
*/
|
|
996
|
-
interface FieldSort<S extends
|
|
936
|
+
interface FieldSort<S extends WQLSpec> {
|
|
997
937
|
asc(): SortExpression<S>;
|
|
998
938
|
desc(): SortExpression<S>;
|
|
999
939
|
}
|
|
@@ -1003,7 +943,7 @@ interface FieldSort<S extends QuerySpec> {
|
|
|
1003
943
|
* Filter('price').gt(50)
|
|
1004
944
|
* Filter.and(Filter('title').eq('Product'), Filter('price').gt(50))
|
|
1005
945
|
*/
|
|
1006
|
-
interface FilterFactory<T, S extends
|
|
946
|
+
interface FilterFactory<T, S extends WQLSpec> {
|
|
1007
947
|
/** Create a field-specific filter */
|
|
1008
948
|
<Field extends FilterableFields<S>>(field: Field): FieldFilter<T, S, Field>;
|
|
1009
949
|
/** Combine filters with AND logic */
|
|
@@ -1018,7 +958,266 @@ interface FilterFactory<T, S extends QuerySpec> {
|
|
|
1018
958
|
* @example
|
|
1019
959
|
* Sort('price').desc()
|
|
1020
960
|
*/
|
|
1021
|
-
type SortFactory<S extends
|
|
961
|
+
type SortFactory<S extends WQLSpec> = <Field extends SortableFields<S>>(field: Field) => FieldSort<S>;
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* The output type from SearchBuilder.build()
|
|
965
|
+
* This is a plain object ready to be sent to an API
|
|
966
|
+
*/
|
|
967
|
+
interface SearchRequest<T, S extends SearchSpec> {
|
|
968
|
+
/** Filter object */
|
|
969
|
+
filter?: Filter<T, S>;
|
|
970
|
+
/** List of sort objects */
|
|
971
|
+
sort?: Sorting<S>[];
|
|
972
|
+
/** Full-text search parameters */
|
|
973
|
+
search?: SearchDetails<S>;
|
|
974
|
+
/** Aggregations to compute */
|
|
975
|
+
aggregations?: Aggregation<S>[];
|
|
976
|
+
/** Paging configuration */
|
|
977
|
+
paging?: PagingFor<S>;
|
|
978
|
+
/** Time zone for date operations */
|
|
979
|
+
timeZone?: string;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Represents a search expression that can be used in SearchBuilder
|
|
983
|
+
*/
|
|
984
|
+
interface SearchExpression<S extends SearchSpec> {
|
|
985
|
+
readonly search: SearchDetails<S>;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Represents an aggregation expression that can be used in SearchBuilder
|
|
989
|
+
*/
|
|
990
|
+
interface AggregationExpression<S extends SearchSpec> {
|
|
991
|
+
readonly aggregation: Aggregation<S>;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Builder for constructing search parameters
|
|
995
|
+
* @example
|
|
996
|
+
* SearchParams('dark shoes')
|
|
997
|
+
* .mode('AND')
|
|
998
|
+
* .fields(['productName', 'description'])
|
|
999
|
+
* .fuzzy(true)
|
|
1000
|
+
*/
|
|
1001
|
+
interface SearchParamsBuilder<S extends SearchSpec> extends SearchExpression<S> {
|
|
1002
|
+
/** Set the search expression/query string */
|
|
1003
|
+
expression(expr: string): SearchParamsBuilder<S>;
|
|
1004
|
+
/** Set the search mode (how to combine multiple terms) */
|
|
1005
|
+
mode(mode: 'AND' | 'OR'): SearchParamsBuilder<S>;
|
|
1006
|
+
/** Set the fields to search in */
|
|
1007
|
+
fields(fields: SearchableFields<S>[]): SearchParamsBuilder<S>;
|
|
1008
|
+
/** Enable or disable fuzzy matching */
|
|
1009
|
+
fuzzy(enabled?: boolean): SearchParamsBuilder<S>;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Factory function for creating SearchParamsBuilder
|
|
1013
|
+
* @param expression - Optional search expression to initialize with
|
|
1014
|
+
*/
|
|
1015
|
+
type SearchParamsFactory<S extends SearchSpec> = (expression?: string) => SearchParamsBuilder<S>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Sort configuration for value aggregations
|
|
1018
|
+
*/
|
|
1019
|
+
interface ValueAggregationSort {
|
|
1020
|
+
sortBy(type: 'COUNT' | 'VALUE', direction: 'ASC' | 'DESC'): this;
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Builder for VALUE type aggregations
|
|
1024
|
+
*/
|
|
1025
|
+
interface ValueAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S>, ValueAggregationSort {
|
|
1026
|
+
/** Set maximum number of buckets to return */
|
|
1027
|
+
limit(count: number): ValueAggregationBuilder<S>;
|
|
1028
|
+
/** Exclude documents with missing values */
|
|
1029
|
+
excludeMissingValues(): ValueAggregationBuilder<S>;
|
|
1030
|
+
/** Include documents with missing values */
|
|
1031
|
+
includeMissingValues(): ValueAggregationBuilder<S>;
|
|
1032
|
+
/** Include specific values in their own bucket */
|
|
1033
|
+
includeValues(addToBucket: string): ValueAggregationBuilder<S>;
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Builder for RANGE type aggregations
|
|
1037
|
+
*/
|
|
1038
|
+
interface RangeAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1039
|
+
/** Set the range buckets */
|
|
1040
|
+
withBuckets(...buckets: {
|
|
1041
|
+
from?: number | null;
|
|
1042
|
+
to?: number | null;
|
|
1043
|
+
}[]): RangeAggregationBuilder<S>;
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Builder for DATE_HISTOGRAM type aggregations
|
|
1047
|
+
*/
|
|
1048
|
+
interface DateHistogramAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1049
|
+
/** Set the interval for date histogram buckets */
|
|
1050
|
+
interval(interval: 'YEAR' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND'): DateHistogramAggregationBuilder<S>;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Builder for SCALAR type aggregations
|
|
1054
|
+
*/
|
|
1055
|
+
interface ScalarAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1056
|
+
/** Set the scalar aggregation type */
|
|
1057
|
+
type(scalarType: 'COUNT_DISTINCT' | 'MIN' | 'MAX' | 'SUM' | 'AVG'): ScalarAggregationBuilder<S>;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Builder for NESTED type aggregations
|
|
1061
|
+
*/
|
|
1062
|
+
interface NestedAggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1063
|
+
/** Add a nested aggregation */
|
|
1064
|
+
addNestedAggregation(aggregation: AggregationExpression<S>): NestedAggregationBuilder<S>;
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Aggregation type configuration
|
|
1068
|
+
*/
|
|
1069
|
+
type AggregationType = 'VALUE' | 'RANGE' | 'DATE_HISTOGRAM' | 'SCALAR' | 'NESTED';
|
|
1070
|
+
/**
|
|
1071
|
+
* Builder for constructing aggregations
|
|
1072
|
+
* @example
|
|
1073
|
+
* Aggregation('status_count')
|
|
1074
|
+
* .ofType('VALUE')
|
|
1075
|
+
* .onField('status')
|
|
1076
|
+
* .asValueAggregation()
|
|
1077
|
+
* .sortBy('COUNT', 'DESC')
|
|
1078
|
+
* .limit(10)
|
|
1079
|
+
*/
|
|
1080
|
+
interface AggregationBuilder<S extends SearchSpec> extends AggregationExpression<S> {
|
|
1081
|
+
/** Set the aggregation type */
|
|
1082
|
+
ofType(type: AggregationType): AggregationBuilder<S>;
|
|
1083
|
+
/** Set the field to aggregate on */
|
|
1084
|
+
onField(field: AggregatableFields<S>): AggregationBuilder<S>;
|
|
1085
|
+
/** Configure as a value aggregation */
|
|
1086
|
+
asValueAggregation(): ValueAggregationBuilder<S>;
|
|
1087
|
+
/** Configure as a range aggregation */
|
|
1088
|
+
asRangeAggregation(): RangeAggregationBuilder<S>;
|
|
1089
|
+
/** Configure as a date histogram aggregation */
|
|
1090
|
+
asDateHistogramAggregation(): DateHistogramAggregationBuilder<S>;
|
|
1091
|
+
/** Configure as a scalar aggregation */
|
|
1092
|
+
asScalarAggregation(): ScalarAggregationBuilder<S>;
|
|
1093
|
+
/** Configure as a nested aggregation */
|
|
1094
|
+
asNestedAggregation(): NestedAggregationBuilder<S>;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Factory function for creating AggregationBuilder
|
|
1098
|
+
*/
|
|
1099
|
+
type AggregationFactory<S extends SearchSpec> = (name: string) => AggregationBuilder<S>;
|
|
1100
|
+
/**
|
|
1101
|
+
* Search builder interface for constructing search requests
|
|
1102
|
+
* @template T - Entity type
|
|
1103
|
+
* @template S - Search spec defining filterable/sortable/searchable/aggregatable fields
|
|
1104
|
+
* @template R - Output type from build() (defaults to SearchRequest<T, S>)
|
|
1105
|
+
* @example
|
|
1106
|
+
* SearchBuilder()
|
|
1107
|
+
* .withFilter(Filter.and(
|
|
1108
|
+
* Filter('title').eq('Product'),
|
|
1109
|
+
* Filter('price').gt(50)
|
|
1110
|
+
* ))
|
|
1111
|
+
* .withSearchClause(SearchParams('shoes').fuzzy(true))
|
|
1112
|
+
* .withAggregation(Aggregation('status_count').ofType('VALUE').onField('status'))
|
|
1113
|
+
* .withSorting(Sort('price').desc())
|
|
1114
|
+
* .withPaging({ limit: 20 })
|
|
1115
|
+
* .build()
|
|
1116
|
+
*/
|
|
1117
|
+
interface SearchBuilder<T, S extends SearchSpec, R = SearchRequest<T, S>> {
|
|
1118
|
+
/** Add a filter to the search */
|
|
1119
|
+
withFilter(filter: FilterExpression<T, S>): SearchBuilder<T, S, R>;
|
|
1120
|
+
/** Add a search clause for full-text search */
|
|
1121
|
+
withSearchClause(search: SearchExpression<S>): SearchBuilder<T, S, R>;
|
|
1122
|
+
/** Add sorting to the search */
|
|
1123
|
+
withSorting(...sorts: SortExpression<S>[]): SearchBuilder<T, S, R>;
|
|
1124
|
+
/** Add aggregations to the search */
|
|
1125
|
+
withAggregation(...aggregations: AggregationExpression<S>[]): SearchBuilder<T, S, R>;
|
|
1126
|
+
/** Add paging to the search */
|
|
1127
|
+
withPaging(paging: PagingFor<S>): SearchBuilder<T, S, R>;
|
|
1128
|
+
/** Set the time zone for date operations */
|
|
1129
|
+
withTimeZone(timeZone: string): SearchBuilder<T, S, R>;
|
|
1130
|
+
/** Build the final search request object */
|
|
1131
|
+
build(): R;
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Complete set of search helpers for an entity
|
|
1135
|
+
* This is what gets spread into module namespaces
|
|
1136
|
+
* @template T - Entity type
|
|
1137
|
+
* @template S - Search spec defining filterable/sortable/searchable/aggregatable fields
|
|
1138
|
+
* @template R - Output type from SearchBuilder.build() (defaults to SearchRequest<T, S>)
|
|
1139
|
+
*/
|
|
1140
|
+
interface SearchHelpers<T, S extends SearchSpec, R = SearchRequest<T, S>> {
|
|
1141
|
+
/** SearchBuilder factory */
|
|
1142
|
+
SearchBuilder: () => SearchBuilder<T, S, R>;
|
|
1143
|
+
/** Filter factory - creates filter expressions (reused from query) */
|
|
1144
|
+
Filter: FilterFactory<T, S>;
|
|
1145
|
+
/** Sort factory - creates sort expressions (reused from query) */
|
|
1146
|
+
Sort: SortFactory<S>;
|
|
1147
|
+
/** Search params factory - creates search expressions */
|
|
1148
|
+
SearchParams: SearchParamsFactory<S>;
|
|
1149
|
+
/** Aggregation factory - creates aggregation expressions */
|
|
1150
|
+
Aggregation: AggregationFactory<S>;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* Specification for a query API
|
|
1155
|
+
* Defines what fields can be filtered and sorted
|
|
1156
|
+
* @example
|
|
1157
|
+
* interface MyQuerySpec extends QuerySpec {
|
|
1158
|
+
* wql: [{
|
|
1159
|
+
* operators: ['$eq', '$ne'],
|
|
1160
|
+
* fields: ['id', 'title'],
|
|
1161
|
+
* sort: 'BOTH'
|
|
1162
|
+
* }],
|
|
1163
|
+
* paging: 'offset', // or 'cursor' for cursor-based pagination
|
|
1164
|
+
* };
|
|
1165
|
+
*/
|
|
1166
|
+
interface QuerySpec extends WQLSpec {
|
|
1167
|
+
/**
|
|
1168
|
+
* Supported paging type for this query API
|
|
1169
|
+
* - 'cursor': Uses cursor-based pagination
|
|
1170
|
+
* - 'offset': Uses offset-based pagination
|
|
1171
|
+
*/
|
|
1172
|
+
paging: PagingType;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Complete query request for an entity type
|
|
1177
|
+
* @template Entity The entity type being queried
|
|
1178
|
+
* @template Spec The query specification type
|
|
1179
|
+
* @example
|
|
1180
|
+
* // Define a query type for products
|
|
1181
|
+
* type QueryProducts = Query<Product, ProductQuerySpec>;
|
|
1182
|
+
*
|
|
1183
|
+
* // Create a query request with offset paging
|
|
1184
|
+
* const query: QueryProducts = {
|
|
1185
|
+
* filter: { price: { $gte: 10 } },
|
|
1186
|
+
* sort: [{ fieldName: 'price', order: 'ASC' }],
|
|
1187
|
+
* paging: { limit: 20, offset: 0 }
|
|
1188
|
+
* };
|
|
1189
|
+
*
|
|
1190
|
+
* // Or with cursor paging (if spec.paging = 'cursor')
|
|
1191
|
+
* const query: QueryProducts = {
|
|
1192
|
+
* filter: { price: { $gte: 10 } },
|
|
1193
|
+
* sort: [{ fieldName: 'price', order: 'ASC' }],
|
|
1194
|
+
* cursorPaging: { limit: 20, cursor: "..." }
|
|
1195
|
+
* };
|
|
1196
|
+
*/
|
|
1197
|
+
type Query<Entity, Spec extends QuerySpec> = {
|
|
1198
|
+
/**
|
|
1199
|
+
* Filter object.
|
|
1200
|
+
* Learn more about the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language#the-filter-section).
|
|
1201
|
+
*/
|
|
1202
|
+
filter?: Filter<Entity, Spec>;
|
|
1203
|
+
/**
|
|
1204
|
+
* List of sort objects.
|
|
1205
|
+
* Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language#the-sort-section).
|
|
1206
|
+
*/
|
|
1207
|
+
sort?: Sorting<Spec>[];
|
|
1208
|
+
} & Partial<Paging<Spec>>;
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* The output type from QueryBuilder.build()
|
|
1212
|
+
* This is a plain object ready to be sent to an API
|
|
1213
|
+
*/
|
|
1214
|
+
interface QueryRequest<T, S extends QuerySpec> {
|
|
1215
|
+
filter?: Filter<T, S>;
|
|
1216
|
+
sort?: Sorting<S>[];
|
|
1217
|
+
paging?: PagingFor<S>;
|
|
1218
|
+
/** Field projection - return only specified fields */
|
|
1219
|
+
fields?: string[];
|
|
1220
|
+
}
|
|
1022
1221
|
/**
|
|
1023
1222
|
* Query builder interface
|
|
1024
1223
|
* @template T - Entity type
|
|
@@ -1063,4 +1262,4 @@ interface QueryHelpers<T, S extends QuerySpec, R = QueryRequest<T, S>> {
|
|
|
1063
1262
|
Sort: SortFactory<S>;
|
|
1064
1263
|
}
|
|
1065
1264
|
|
|
1066
|
-
export { type APIMetadata, type AccountInfo, 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 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 NonNullablePaths, type OffsetPaging, type PagingFor, type PublicMetadata, type Query, type QueryBuilder, type QueryHelpers, type QueryRequest, type QuerySpec, type RESTFunctionDescriptor, type RequestContext, type RequestOptions, type RequestOptionsFactory, type RestModuleMeta, SERVICE_PLUGIN_ERROR_TYPE, SORT_CAPABILITIES, SORT_DIRECTIONS, type Search, type SearchSpec, type ServicePluginContract, ServicePluginDefinition, type ServicePluginMethodInput, type ServicePluginMethodMetadata, type SortCapability, type SortExpression, type SortFactory, type SortOrder, type Sorting, type WQL, type WQLSpec };
|
|
1265
|
+
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 };
|