@wix/sdk-types 1.17.2 → 1.17.3

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.
@@ -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
  /**
@@ -894,4 +894,173 @@ type Query<Entity, Spec extends QuerySpec> = {
894
894
  sort?: Sorting<Spec>[];
895
895
  } & Partial<Paging<Spec>>;
896
896
 
897
- 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 Descriptors, EventDefinition, type EventHandler, type EventIdentity, type ExposeFieldsBasedOnToggle, type Filter, 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 PublicMetadata, type Query, 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 SortOrder, type Sorting, type WQL, type WQLSpec };
897
+ interface CursorPaging {
898
+ limit: number;
899
+ cursor?: string;
900
+ }
901
+ interface OffsetPaging {
902
+ limit: number;
903
+ offset?: number;
904
+ }
905
+ type PagingFor<S extends QuerySpec> = S['paging'] extends 'cursor' ? CursorPaging : OffsetPaging;
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
+ }
917
+ /**
918
+ * Represents a filter expression that can be combined with other filters
919
+ */
920
+ interface FilterExpression<T, S extends QuerySpec> {
921
+ readonly filter: Filter<T, S>;
922
+ }
923
+ /**
924
+ * Represents a sort expression
925
+ */
926
+ interface SortExpression<S extends QuerySpec> {
927
+ readonly sort: Sorting<S>;
928
+ }
929
+ /**
930
+ * Extract fields that support a specific operator from the spec
931
+ */
932
+ type FieldsWithOperator<S extends QuerySpec, 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
+ /**
934
+ * Check if a specific field supports a specific operator
935
+ */
936
+ type HasOperator<S extends QuerySpec, Field extends string, Op extends string> = Field extends FieldsWithOperator<S, Op> ? true : false;
937
+ /**
938
+ * Extract sortable fields from the spec
939
+ */
940
+ type SortableFields<S extends QuerySpec> = S['wql'][number] extends infer Group ? Group extends {
941
+ fields: readonly string[];
942
+ sort: 'ASC' | 'DESC' | 'BOTH';
943
+ } ? Group['fields'][number] : never : never;
944
+ /**
945
+ * Chainable field filter - extends FilterExpression so it can be used directly,
946
+ * but also allows chaining multiple operators on the same field.
947
+ * @example
948
+ * // Single operator - returns ChainableFieldFilter which is also FilterExpression
949
+ * Filter('price').gt(50)
950
+ *
951
+ * // Chained operators - combines into single field filter
952
+ * Filter('price').gt(50).lt(100)
953
+ * // Produces: { price: { $gt: 50, $lt: 100 } }
954
+ */
955
+ type ChainableFieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = FilterExpression<T, S> & (HasOperator<S, Field & string, '$eq'> extends true ? {
956
+ eq(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
957
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
958
+ ne(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
959
+ } : {}) & (HasOperator<S, Field & string, '$gt'> extends true ? {
960
+ gt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
961
+ } : {}) & (HasOperator<S, Field & string, '$gte'> extends true ? {
962
+ gte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
963
+ } : {}) & (HasOperator<S, Field & string, '$lt'> extends true ? {
964
+ lt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
965
+ } : {}) & (HasOperator<S, Field & string, '$lte'> extends true ? {
966
+ lte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
967
+ } : {}) & (HasOperator<S, Field & string, '$startsWith'> extends true ? {
968
+ startsWith(value: string): ChainableFieldFilter<T, S, Field>;
969
+ } : {}) & (HasOperator<S, Field & string, '$endsWith'> extends true ? {
970
+ endsWith(value: string): ChainableFieldFilter<T, S, Field>;
971
+ } : {}) & (HasOperator<S, Field & string, '$contains'> extends true ? {
972
+ contains(value: string): ChainableFieldFilter<T, S, Field>;
973
+ } : {}) & (HasOperator<S, Field & string, '$in'> extends true ? {
974
+ in(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
975
+ } : {}) & (HasOperator<S, Field & string, '$nin'> extends true ? {
976
+ nin(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
977
+ } : {}) & (HasOperator<S, Field & string, '$hasSome'> extends true ? {
978
+ hasSome(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
979
+ } : {}) & (HasOperator<S, Field & string, '$hasAll'> extends true ? {
980
+ hasAll(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
981
+ } : {}) & (HasOperator<S, Field & string, '$exists'> extends true ? {
982
+ exists(value?: boolean): ChainableFieldFilter<T, S, Field>;
983
+ } : {}) & (HasOperator<S, Field & string, '$isEmpty'> extends true ? {
984
+ isEmpty(value?: boolean): ChainableFieldFilter<T, S, Field>;
985
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
986
+ isNotEmpty(): ChainableFieldFilter<T, S, Field>;
987
+ } : {});
988
+ /**
989
+ * Filter methods for a specific field (alias for ChainableFieldFilter)
990
+ * Only shows methods for operators that the field supports
991
+ */
992
+ type FieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = ChainableFieldFilter<T, S, Field>;
993
+ /**
994
+ * Sort methods for a specific field
995
+ */
996
+ interface FieldSort<S extends QuerySpec> {
997
+ asc(): SortExpression<S>;
998
+ desc(): SortExpression<S>;
999
+ }
1000
+ /**
1001
+ * Filter factory interface - creates filter expressions
1002
+ * @example
1003
+ * Filter('price').gt(50)
1004
+ * Filter.and(Filter('title').eq('Product'), Filter('price').gt(50))
1005
+ */
1006
+ interface FilterFactory<T, S extends QuerySpec> {
1007
+ /** Create a field-specific filter */
1008
+ <Field extends FilterableFields<S>>(field: Field): FieldFilter<T, S, Field>;
1009
+ /** Combine filters with AND logic */
1010
+ and(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1011
+ /** Combine filters with OR logic */
1012
+ or(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1013
+ /** Negate a filter */
1014
+ not(filter: FilterExpression<T, S>): FilterExpression<T, S>;
1015
+ }
1016
+ /**
1017
+ * Sort factory - creates sort expressions
1018
+ * @example
1019
+ * Sort('price').desc()
1020
+ */
1021
+ type SortFactory<S extends QuerySpec> = <Field extends SortableFields<S>>(field: Field) => FieldSort<S>;
1022
+ /**
1023
+ * Query builder interface
1024
+ * @template T - Entity type
1025
+ * @template S - Query spec defining filterable/sortable fields
1026
+ * @template R - Output type from build() (defaults to QueryRequest<T, S>)
1027
+ * @example
1028
+ * QueryBuilder()
1029
+ * .withFilter(Filter.and(
1030
+ * Filter('title').eq('Product'),
1031
+ * Filter('price').gt(50)
1032
+ * ))
1033
+ * .withFields('title', 'price')
1034
+ * .withSorting(Sort('price').desc())
1035
+ * .withPaging({ limit: 20, offset: 0 })
1036
+ * .build()
1037
+ */
1038
+ interface QueryBuilder<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1039
+ /** Add a filter to the query */
1040
+ withFilter(filter: FilterExpression<T, S>): QueryBuilder<T, S, R>;
1041
+ /** Add field projection - return only specified fields */
1042
+ withFields(...fields: (keyof T & string)[]): QueryBuilder<T, S, R>;
1043
+ /** Add sorting to the query */
1044
+ withSorting(...sorts: SortExpression<S>[]): QueryBuilder<T, S, R>;
1045
+ /** Add paging to the query */
1046
+ withPaging(paging: PagingFor<S>): QueryBuilder<T, S, R>;
1047
+ /** Build the final query request object */
1048
+ build(): R;
1049
+ }
1050
+ /**
1051
+ * Complete set of query helpers for an entity
1052
+ * This is what gets spread into module namespaces
1053
+ * @template T - Entity type
1054
+ * @template S - Query spec defining filterable/sortable fields
1055
+ * @template R - Output type from QueryBuilder.build() (defaults to QueryRequest<T, S>)
1056
+ */
1057
+ interface QueryHelpers<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1058
+ /** QueryBuilder factory */
1059
+ QueryBuilder: () => QueryBuilder<T, S, R>;
1060
+ /** Filter factory - creates filter expressions */
1061
+ Filter: FilterFactory<T, S>;
1062
+ /** Sort factory - creates sort expressions */
1063
+ Sort: SortFactory<S>;
1064
+ }
1065
+
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 };
package/build/index.d.mts CHANGED
@@ -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
  /**
@@ -894,4 +894,173 @@ type Query<Entity, Spec extends QuerySpec> = {
894
894
  sort?: Sorting<Spec>[];
895
895
  } & Partial<Paging<Spec>>;
896
896
 
897
- 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 Descriptors, EventDefinition, type EventHandler, type EventIdentity, type ExposeFieldsBasedOnToggle, type Filter, 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 PublicMetadata, type Query, 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 SortOrder, type Sorting, type WQL, type WQLSpec };
897
+ interface CursorPaging {
898
+ limit: number;
899
+ cursor?: string;
900
+ }
901
+ interface OffsetPaging {
902
+ limit: number;
903
+ offset?: number;
904
+ }
905
+ type PagingFor<S extends QuerySpec> = S['paging'] extends 'cursor' ? CursorPaging : OffsetPaging;
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
+ }
917
+ /**
918
+ * Represents a filter expression that can be combined with other filters
919
+ */
920
+ interface FilterExpression<T, S extends QuerySpec> {
921
+ readonly filter: Filter<T, S>;
922
+ }
923
+ /**
924
+ * Represents a sort expression
925
+ */
926
+ interface SortExpression<S extends QuerySpec> {
927
+ readonly sort: Sorting<S>;
928
+ }
929
+ /**
930
+ * Extract fields that support a specific operator from the spec
931
+ */
932
+ type FieldsWithOperator<S extends QuerySpec, 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
+ /**
934
+ * Check if a specific field supports a specific operator
935
+ */
936
+ type HasOperator<S extends QuerySpec, Field extends string, Op extends string> = Field extends FieldsWithOperator<S, Op> ? true : false;
937
+ /**
938
+ * Extract sortable fields from the spec
939
+ */
940
+ type SortableFields<S extends QuerySpec> = S['wql'][number] extends infer Group ? Group extends {
941
+ fields: readonly string[];
942
+ sort: 'ASC' | 'DESC' | 'BOTH';
943
+ } ? Group['fields'][number] : never : never;
944
+ /**
945
+ * Chainable field filter - extends FilterExpression so it can be used directly,
946
+ * but also allows chaining multiple operators on the same field.
947
+ * @example
948
+ * // Single operator - returns ChainableFieldFilter which is also FilterExpression
949
+ * Filter('price').gt(50)
950
+ *
951
+ * // Chained operators - combines into single field filter
952
+ * Filter('price').gt(50).lt(100)
953
+ * // Produces: { price: { $gt: 50, $lt: 100 } }
954
+ */
955
+ type ChainableFieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = FilterExpression<T, S> & (HasOperator<S, Field & string, '$eq'> extends true ? {
956
+ eq(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
957
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
958
+ ne(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
959
+ } : {}) & (HasOperator<S, Field & string, '$gt'> extends true ? {
960
+ gt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
961
+ } : {}) & (HasOperator<S, Field & string, '$gte'> extends true ? {
962
+ gte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
963
+ } : {}) & (HasOperator<S, Field & string, '$lt'> extends true ? {
964
+ lt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
965
+ } : {}) & (HasOperator<S, Field & string, '$lte'> extends true ? {
966
+ lte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
967
+ } : {}) & (HasOperator<S, Field & string, '$startsWith'> extends true ? {
968
+ startsWith(value: string): ChainableFieldFilter<T, S, Field>;
969
+ } : {}) & (HasOperator<S, Field & string, '$endsWith'> extends true ? {
970
+ endsWith(value: string): ChainableFieldFilter<T, S, Field>;
971
+ } : {}) & (HasOperator<S, Field & string, '$contains'> extends true ? {
972
+ contains(value: string): ChainableFieldFilter<T, S, Field>;
973
+ } : {}) & (HasOperator<S, Field & string, '$in'> extends true ? {
974
+ in(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
975
+ } : {}) & (HasOperator<S, Field & string, '$nin'> extends true ? {
976
+ nin(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
977
+ } : {}) & (HasOperator<S, Field & string, '$hasSome'> extends true ? {
978
+ hasSome(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
979
+ } : {}) & (HasOperator<S, Field & string, '$hasAll'> extends true ? {
980
+ hasAll(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
981
+ } : {}) & (HasOperator<S, Field & string, '$exists'> extends true ? {
982
+ exists(value?: boolean): ChainableFieldFilter<T, S, Field>;
983
+ } : {}) & (HasOperator<S, Field & string, '$isEmpty'> extends true ? {
984
+ isEmpty(value?: boolean): ChainableFieldFilter<T, S, Field>;
985
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
986
+ isNotEmpty(): ChainableFieldFilter<T, S, Field>;
987
+ } : {});
988
+ /**
989
+ * Filter methods for a specific field (alias for ChainableFieldFilter)
990
+ * Only shows methods for operators that the field supports
991
+ */
992
+ type FieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = ChainableFieldFilter<T, S, Field>;
993
+ /**
994
+ * Sort methods for a specific field
995
+ */
996
+ interface FieldSort<S extends QuerySpec> {
997
+ asc(): SortExpression<S>;
998
+ desc(): SortExpression<S>;
999
+ }
1000
+ /**
1001
+ * Filter factory interface - creates filter expressions
1002
+ * @example
1003
+ * Filter('price').gt(50)
1004
+ * Filter.and(Filter('title').eq('Product'), Filter('price').gt(50))
1005
+ */
1006
+ interface FilterFactory<T, S extends QuerySpec> {
1007
+ /** Create a field-specific filter */
1008
+ <Field extends FilterableFields<S>>(field: Field): FieldFilter<T, S, Field>;
1009
+ /** Combine filters with AND logic */
1010
+ and(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1011
+ /** Combine filters with OR logic */
1012
+ or(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1013
+ /** Negate a filter */
1014
+ not(filter: FilterExpression<T, S>): FilterExpression<T, S>;
1015
+ }
1016
+ /**
1017
+ * Sort factory - creates sort expressions
1018
+ * @example
1019
+ * Sort('price').desc()
1020
+ */
1021
+ type SortFactory<S extends QuerySpec> = <Field extends SortableFields<S>>(field: Field) => FieldSort<S>;
1022
+ /**
1023
+ * Query builder interface
1024
+ * @template T - Entity type
1025
+ * @template S - Query spec defining filterable/sortable fields
1026
+ * @template R - Output type from build() (defaults to QueryRequest<T, S>)
1027
+ * @example
1028
+ * QueryBuilder()
1029
+ * .withFilter(Filter.and(
1030
+ * Filter('title').eq('Product'),
1031
+ * Filter('price').gt(50)
1032
+ * ))
1033
+ * .withFields('title', 'price')
1034
+ * .withSorting(Sort('price').desc())
1035
+ * .withPaging({ limit: 20, offset: 0 })
1036
+ * .build()
1037
+ */
1038
+ interface QueryBuilder<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1039
+ /** Add a filter to the query */
1040
+ withFilter(filter: FilterExpression<T, S>): QueryBuilder<T, S, R>;
1041
+ /** Add field projection - return only specified fields */
1042
+ withFields(...fields: (keyof T & string)[]): QueryBuilder<T, S, R>;
1043
+ /** Add sorting to the query */
1044
+ withSorting(...sorts: SortExpression<S>[]): QueryBuilder<T, S, R>;
1045
+ /** Add paging to the query */
1046
+ withPaging(paging: PagingFor<S>): QueryBuilder<T, S, R>;
1047
+ /** Build the final query request object */
1048
+ build(): R;
1049
+ }
1050
+ /**
1051
+ * Complete set of query helpers for an entity
1052
+ * This is what gets spread into module namespaces
1053
+ * @template T - Entity type
1054
+ * @template S - Query spec defining filterable/sortable fields
1055
+ * @template R - Output type from QueryBuilder.build() (defaults to QueryRequest<T, S>)
1056
+ */
1057
+ interface QueryHelpers<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1058
+ /** QueryBuilder factory */
1059
+ QueryBuilder: () => QueryBuilder<T, S, R>;
1060
+ /** Filter factory - creates filter expressions */
1061
+ Filter: FilterFactory<T, S>;
1062
+ /** Sort factory - creates sort expressions */
1063
+ Sort: SortFactory<S>;
1064
+ }
1065
+
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 };
package/build/index.d.ts CHANGED
@@ -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
  /**
@@ -894,4 +894,173 @@ type Query<Entity, Spec extends QuerySpec> = {
894
894
  sort?: Sorting<Spec>[];
895
895
  } & Partial<Paging<Spec>>;
896
896
 
897
- 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 Descriptors, EventDefinition, type EventHandler, type EventIdentity, type ExposeFieldsBasedOnToggle, type Filter, 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 PublicMetadata, type Query, 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 SortOrder, type Sorting, type WQL, type WQLSpec };
897
+ interface CursorPaging {
898
+ limit: number;
899
+ cursor?: string;
900
+ }
901
+ interface OffsetPaging {
902
+ limit: number;
903
+ offset?: number;
904
+ }
905
+ type PagingFor<S extends QuerySpec> = S['paging'] extends 'cursor' ? CursorPaging : OffsetPaging;
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
+ }
917
+ /**
918
+ * Represents a filter expression that can be combined with other filters
919
+ */
920
+ interface FilterExpression<T, S extends QuerySpec> {
921
+ readonly filter: Filter<T, S>;
922
+ }
923
+ /**
924
+ * Represents a sort expression
925
+ */
926
+ interface SortExpression<S extends QuerySpec> {
927
+ readonly sort: Sorting<S>;
928
+ }
929
+ /**
930
+ * Extract fields that support a specific operator from the spec
931
+ */
932
+ type FieldsWithOperator<S extends QuerySpec, 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
+ /**
934
+ * Check if a specific field supports a specific operator
935
+ */
936
+ type HasOperator<S extends QuerySpec, Field extends string, Op extends string> = Field extends FieldsWithOperator<S, Op> ? true : false;
937
+ /**
938
+ * Extract sortable fields from the spec
939
+ */
940
+ type SortableFields<S extends QuerySpec> = S['wql'][number] extends infer Group ? Group extends {
941
+ fields: readonly string[];
942
+ sort: 'ASC' | 'DESC' | 'BOTH';
943
+ } ? Group['fields'][number] : never : never;
944
+ /**
945
+ * Chainable field filter - extends FilterExpression so it can be used directly,
946
+ * but also allows chaining multiple operators on the same field.
947
+ * @example
948
+ * // Single operator - returns ChainableFieldFilter which is also FilterExpression
949
+ * Filter('price').gt(50)
950
+ *
951
+ * // Chained operators - combines into single field filter
952
+ * Filter('price').gt(50).lt(100)
953
+ * // Produces: { price: { $gt: 50, $lt: 100 } }
954
+ */
955
+ type ChainableFieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = FilterExpression<T, S> & (HasOperator<S, Field & string, '$eq'> extends true ? {
956
+ eq(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
957
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
958
+ ne(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
959
+ } : {}) & (HasOperator<S, Field & string, '$gt'> extends true ? {
960
+ gt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
961
+ } : {}) & (HasOperator<S, Field & string, '$gte'> extends true ? {
962
+ gte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
963
+ } : {}) & (HasOperator<S, Field & string, '$lt'> extends true ? {
964
+ lt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
965
+ } : {}) & (HasOperator<S, Field & string, '$lte'> extends true ? {
966
+ lte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
967
+ } : {}) & (HasOperator<S, Field & string, '$startsWith'> extends true ? {
968
+ startsWith(value: string): ChainableFieldFilter<T, S, Field>;
969
+ } : {}) & (HasOperator<S, Field & string, '$endsWith'> extends true ? {
970
+ endsWith(value: string): ChainableFieldFilter<T, S, Field>;
971
+ } : {}) & (HasOperator<S, Field & string, '$contains'> extends true ? {
972
+ contains(value: string): ChainableFieldFilter<T, S, Field>;
973
+ } : {}) & (HasOperator<S, Field & string, '$in'> extends true ? {
974
+ in(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
975
+ } : {}) & (HasOperator<S, Field & string, '$nin'> extends true ? {
976
+ nin(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
977
+ } : {}) & (HasOperator<S, Field & string, '$hasSome'> extends true ? {
978
+ hasSome(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
979
+ } : {}) & (HasOperator<S, Field & string, '$hasAll'> extends true ? {
980
+ hasAll(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
981
+ } : {}) & (HasOperator<S, Field & string, '$exists'> extends true ? {
982
+ exists(value?: boolean): ChainableFieldFilter<T, S, Field>;
983
+ } : {}) & (HasOperator<S, Field & string, '$isEmpty'> extends true ? {
984
+ isEmpty(value?: boolean): ChainableFieldFilter<T, S, Field>;
985
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
986
+ isNotEmpty(): ChainableFieldFilter<T, S, Field>;
987
+ } : {});
988
+ /**
989
+ * Filter methods for a specific field (alias for ChainableFieldFilter)
990
+ * Only shows methods for operators that the field supports
991
+ */
992
+ type FieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = ChainableFieldFilter<T, S, Field>;
993
+ /**
994
+ * Sort methods for a specific field
995
+ */
996
+ interface FieldSort<S extends QuerySpec> {
997
+ asc(): SortExpression<S>;
998
+ desc(): SortExpression<S>;
999
+ }
1000
+ /**
1001
+ * Filter factory interface - creates filter expressions
1002
+ * @example
1003
+ * Filter('price').gt(50)
1004
+ * Filter.and(Filter('title').eq('Product'), Filter('price').gt(50))
1005
+ */
1006
+ interface FilterFactory<T, S extends QuerySpec> {
1007
+ /** Create a field-specific filter */
1008
+ <Field extends FilterableFields<S>>(field: Field): FieldFilter<T, S, Field>;
1009
+ /** Combine filters with AND logic */
1010
+ and(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1011
+ /** Combine filters with OR logic */
1012
+ or(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1013
+ /** Negate a filter */
1014
+ not(filter: FilterExpression<T, S>): FilterExpression<T, S>;
1015
+ }
1016
+ /**
1017
+ * Sort factory - creates sort expressions
1018
+ * @example
1019
+ * Sort('price').desc()
1020
+ */
1021
+ type SortFactory<S extends QuerySpec> = <Field extends SortableFields<S>>(field: Field) => FieldSort<S>;
1022
+ /**
1023
+ * Query builder interface
1024
+ * @template T - Entity type
1025
+ * @template S - Query spec defining filterable/sortable fields
1026
+ * @template R - Output type from build() (defaults to QueryRequest<T, S>)
1027
+ * @example
1028
+ * QueryBuilder()
1029
+ * .withFilter(Filter.and(
1030
+ * Filter('title').eq('Product'),
1031
+ * Filter('price').gt(50)
1032
+ * ))
1033
+ * .withFields('title', 'price')
1034
+ * .withSorting(Sort('price').desc())
1035
+ * .withPaging({ limit: 20, offset: 0 })
1036
+ * .build()
1037
+ */
1038
+ interface QueryBuilder<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1039
+ /** Add a filter to the query */
1040
+ withFilter(filter: FilterExpression<T, S>): QueryBuilder<T, S, R>;
1041
+ /** Add field projection - return only specified fields */
1042
+ withFields(...fields: (keyof T & string)[]): QueryBuilder<T, S, R>;
1043
+ /** Add sorting to the query */
1044
+ withSorting(...sorts: SortExpression<S>[]): QueryBuilder<T, S, R>;
1045
+ /** Add paging to the query */
1046
+ withPaging(paging: PagingFor<S>): QueryBuilder<T, S, R>;
1047
+ /** Build the final query request object */
1048
+ build(): R;
1049
+ }
1050
+ /**
1051
+ * Complete set of query helpers for an entity
1052
+ * This is what gets spread into module namespaces
1053
+ * @template T - Entity type
1054
+ * @template S - Query spec defining filterable/sortable fields
1055
+ * @template R - Output type from QueryBuilder.build() (defaults to QueryRequest<T, S>)
1056
+ */
1057
+ interface QueryHelpers<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1058
+ /** QueryBuilder factory */
1059
+ QueryBuilder: () => QueryBuilder<T, S, R>;
1060
+ /** Filter factory - creates filter expressions */
1061
+ Filter: FilterFactory<T, S>;
1062
+ /** Sort factory - creates sort expressions */
1063
+ Sort: SortFactory<S>;
1064
+ }
1065
+
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 };
@@ -620,7 +620,7 @@ type Filter<Entity, Spec extends WQLSpec> = Simplify<{
620
620
  /**
621
621
  * Cursor-based paging configuration
622
622
  */
623
- interface CursorPaging {
623
+ interface CursorPaging$1 {
624
624
  /** Maximum number of items to return in the results. */
625
625
  limit?: number | null;
626
626
  /**
@@ -634,7 +634,7 @@ interface CursorPaging {
634
634
  /**
635
635
  * Offset-based paging configuration
636
636
  */
637
- interface OffsetPaging {
637
+ interface OffsetPaging$1 {
638
638
  /** Number of items to load */
639
639
  limit?: number | null;
640
640
  /** Number of items to skip in the current sort order */
@@ -650,9 +650,9 @@ type PagingType = 'cursor' | 'offset';
650
650
  type Paging<Spec extends {
651
651
  paging?: PagingType;
652
652
  }> = Spec['paging'] extends 'cursor' ? {
653
- cursorPaging: CursorPaging;
653
+ cursorPaging: CursorPaging$1;
654
654
  } : Spec['paging'] extends 'offset' ? {
655
- paging: OffsetPaging;
655
+ paging: OffsetPaging$1;
656
656
  } : {};
657
657
 
658
658
  /**
@@ -952,4 +952,173 @@ type Query<Entity, Spec extends QuerySpec> = {
952
952
  sort?: Sorting<Spec>[];
953
953
  } & Partial<Paging<Spec>>;
954
954
 
955
- 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 Descriptors, EventDefinition, type EventHandler, type EventIdentity, type ExposeFieldsBasedOnToggle, type Filter, 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 PublicMetadata, type Query, 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 SortOrder, type Sorting, type WQL, type WQLSpec };
955
+ interface CursorPaging {
956
+ limit: number;
957
+ cursor?: string;
958
+ }
959
+ interface OffsetPaging {
960
+ limit: number;
961
+ offset?: number;
962
+ }
963
+ type PagingFor<S extends QuerySpec> = S['paging'] extends 'cursor' ? CursorPaging : OffsetPaging;
964
+ /**
965
+ * The output type from QueryBuilder.build()
966
+ * This is a plain object ready to be sent to an API
967
+ */
968
+ interface QueryRequest<T, S extends QuerySpec> {
969
+ filter?: Filter<T, S>;
970
+ sort?: Sorting<S>[];
971
+ paging?: PagingFor<S>;
972
+ /** Field projection - return only specified fields */
973
+ fields?: string[];
974
+ }
975
+ /**
976
+ * Represents a filter expression that can be combined with other filters
977
+ */
978
+ interface FilterExpression<T, S extends QuerySpec> {
979
+ readonly filter: Filter<T, S>;
980
+ }
981
+ /**
982
+ * Represents a sort expression
983
+ */
984
+ interface SortExpression<S extends QuerySpec> {
985
+ readonly sort: Sorting<S>;
986
+ }
987
+ /**
988
+ * Extract fields that support a specific operator from the spec
989
+ */
990
+ type FieldsWithOperator<S extends QuerySpec, 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;
991
+ /**
992
+ * Check if a specific field supports a specific operator
993
+ */
994
+ type HasOperator<S extends QuerySpec, Field extends string, Op extends string> = Field extends FieldsWithOperator<S, Op> ? true : false;
995
+ /**
996
+ * Extract sortable fields from the spec
997
+ */
998
+ type SortableFields<S extends QuerySpec> = S['wql'][number] extends infer Group ? Group extends {
999
+ fields: readonly string[];
1000
+ sort: 'ASC' | 'DESC' | 'BOTH';
1001
+ } ? Group['fields'][number] : never : never;
1002
+ /**
1003
+ * Chainable field filter - extends FilterExpression so it can be used directly,
1004
+ * but also allows chaining multiple operators on the same field.
1005
+ * @example
1006
+ * // Single operator - returns ChainableFieldFilter which is also FilterExpression
1007
+ * Filter('price').gt(50)
1008
+ *
1009
+ * // Chained operators - combines into single field filter
1010
+ * Filter('price').gt(50).lt(100)
1011
+ * // Produces: { price: { $gt: 50, $lt: 100 } }
1012
+ */
1013
+ type ChainableFieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = FilterExpression<T, S> & (HasOperator<S, Field & string, '$eq'> extends true ? {
1014
+ eq(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1015
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
1016
+ ne(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1017
+ } : {}) & (HasOperator<S, Field & string, '$gt'> extends true ? {
1018
+ gt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1019
+ } : {}) & (HasOperator<S, Field & string, '$gte'> extends true ? {
1020
+ gte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1021
+ } : {}) & (HasOperator<S, Field & string, '$lt'> extends true ? {
1022
+ lt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1023
+ } : {}) & (HasOperator<S, Field & string, '$lte'> extends true ? {
1024
+ lte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1025
+ } : {}) & (HasOperator<S, Field & string, '$startsWith'> extends true ? {
1026
+ startsWith(value: string): ChainableFieldFilter<T, S, Field>;
1027
+ } : {}) & (HasOperator<S, Field & string, '$endsWith'> extends true ? {
1028
+ endsWith(value: string): ChainableFieldFilter<T, S, Field>;
1029
+ } : {}) & (HasOperator<S, Field & string, '$contains'> extends true ? {
1030
+ contains(value: string): ChainableFieldFilter<T, S, Field>;
1031
+ } : {}) & (HasOperator<S, Field & string, '$in'> extends true ? {
1032
+ in(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1033
+ } : {}) & (HasOperator<S, Field & string, '$nin'> extends true ? {
1034
+ nin(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1035
+ } : {}) & (HasOperator<S, Field & string, '$hasSome'> extends true ? {
1036
+ hasSome(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1037
+ } : {}) & (HasOperator<S, Field & string, '$hasAll'> extends true ? {
1038
+ hasAll(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1039
+ } : {}) & (HasOperator<S, Field & string, '$exists'> extends true ? {
1040
+ exists(value?: boolean): ChainableFieldFilter<T, S, Field>;
1041
+ } : {}) & (HasOperator<S, Field & string, '$isEmpty'> extends true ? {
1042
+ isEmpty(value?: boolean): ChainableFieldFilter<T, S, Field>;
1043
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
1044
+ isNotEmpty(): ChainableFieldFilter<T, S, Field>;
1045
+ } : {});
1046
+ /**
1047
+ * Filter methods for a specific field (alias for ChainableFieldFilter)
1048
+ * Only shows methods for operators that the field supports
1049
+ */
1050
+ type FieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = ChainableFieldFilter<T, S, Field>;
1051
+ /**
1052
+ * Sort methods for a specific field
1053
+ */
1054
+ interface FieldSort<S extends QuerySpec> {
1055
+ asc(): SortExpression<S>;
1056
+ desc(): SortExpression<S>;
1057
+ }
1058
+ /**
1059
+ * Filter factory interface - creates filter expressions
1060
+ * @example
1061
+ * Filter('price').gt(50)
1062
+ * Filter.and(Filter('title').eq('Product'), Filter('price').gt(50))
1063
+ */
1064
+ interface FilterFactory<T, S extends QuerySpec> {
1065
+ /** Create a field-specific filter */
1066
+ <Field extends FilterableFields<S>>(field: Field): FieldFilter<T, S, Field>;
1067
+ /** Combine filters with AND logic */
1068
+ and(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1069
+ /** Combine filters with OR logic */
1070
+ or(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1071
+ /** Negate a filter */
1072
+ not(filter: FilterExpression<T, S>): FilterExpression<T, S>;
1073
+ }
1074
+ /**
1075
+ * Sort factory - creates sort expressions
1076
+ * @example
1077
+ * Sort('price').desc()
1078
+ */
1079
+ type SortFactory<S extends QuerySpec> = <Field extends SortableFields<S>>(field: Field) => FieldSort<S>;
1080
+ /**
1081
+ * Query builder interface
1082
+ * @template T - Entity type
1083
+ * @template S - Query spec defining filterable/sortable fields
1084
+ * @template R - Output type from build() (defaults to QueryRequest<T, S>)
1085
+ * @example
1086
+ * QueryBuilder()
1087
+ * .withFilter(Filter.and(
1088
+ * Filter('title').eq('Product'),
1089
+ * Filter('price').gt(50)
1090
+ * ))
1091
+ * .withFields('title', 'price')
1092
+ * .withSorting(Sort('price').desc())
1093
+ * .withPaging({ limit: 20, offset: 0 })
1094
+ * .build()
1095
+ */
1096
+ interface QueryBuilder<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1097
+ /** Add a filter to the query */
1098
+ withFilter(filter: FilterExpression<T, S>): QueryBuilder<T, S, R>;
1099
+ /** Add field projection - return only specified fields */
1100
+ withFields(...fields: (keyof T & string)[]): QueryBuilder<T, S, R>;
1101
+ /** Add sorting to the query */
1102
+ withSorting(...sorts: SortExpression<S>[]): QueryBuilder<T, S, R>;
1103
+ /** Add paging to the query */
1104
+ withPaging(paging: PagingFor<S>): QueryBuilder<T, S, R>;
1105
+ /** Build the final query request object */
1106
+ build(): R;
1107
+ }
1108
+ /**
1109
+ * Complete set of query helpers for an entity
1110
+ * This is what gets spread into module namespaces
1111
+ * @template T - Entity type
1112
+ * @template S - Query spec defining filterable/sortable fields
1113
+ * @template R - Output type from QueryBuilder.build() (defaults to QueryRequest<T, S>)
1114
+ */
1115
+ interface QueryHelpers<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1116
+ /** QueryBuilder factory */
1117
+ QueryBuilder: () => QueryBuilder<T, S, R>;
1118
+ /** Filter factory - creates filter expressions */
1119
+ Filter: FilterFactory<T, S>;
1120
+ /** Sort factory - creates sort expressions */
1121
+ Sort: SortFactory<S>;
1122
+ }
1123
+
1124
+ 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 };
@@ -620,7 +620,7 @@ type Filter<Entity, Spec extends WQLSpec> = Simplify<{
620
620
  /**
621
621
  * Cursor-based paging configuration
622
622
  */
623
- interface CursorPaging {
623
+ interface CursorPaging$1 {
624
624
  /** Maximum number of items to return in the results. */
625
625
  limit?: number | null;
626
626
  /**
@@ -634,7 +634,7 @@ interface CursorPaging {
634
634
  /**
635
635
  * Offset-based paging configuration
636
636
  */
637
- interface OffsetPaging {
637
+ interface OffsetPaging$1 {
638
638
  /** Number of items to load */
639
639
  limit?: number | null;
640
640
  /** Number of items to skip in the current sort order */
@@ -650,9 +650,9 @@ type PagingType = 'cursor' | 'offset';
650
650
  type Paging<Spec extends {
651
651
  paging?: PagingType;
652
652
  }> = Spec['paging'] extends 'cursor' ? {
653
- cursorPaging: CursorPaging;
653
+ cursorPaging: CursorPaging$1;
654
654
  } : Spec['paging'] extends 'offset' ? {
655
- paging: OffsetPaging;
655
+ paging: OffsetPaging$1;
656
656
  } : {};
657
657
 
658
658
  /**
@@ -952,4 +952,173 @@ type Query<Entity, Spec extends QuerySpec> = {
952
952
  sort?: Sorting<Spec>[];
953
953
  } & Partial<Paging<Spec>>;
954
954
 
955
- 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 Descriptors, EventDefinition, type EventHandler, type EventIdentity, type ExposeFieldsBasedOnToggle, type Filter, 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 PublicMetadata, type Query, 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 SortOrder, type Sorting, type WQL, type WQLSpec };
955
+ interface CursorPaging {
956
+ limit: number;
957
+ cursor?: string;
958
+ }
959
+ interface OffsetPaging {
960
+ limit: number;
961
+ offset?: number;
962
+ }
963
+ type PagingFor<S extends QuerySpec> = S['paging'] extends 'cursor' ? CursorPaging : OffsetPaging;
964
+ /**
965
+ * The output type from QueryBuilder.build()
966
+ * This is a plain object ready to be sent to an API
967
+ */
968
+ interface QueryRequest<T, S extends QuerySpec> {
969
+ filter?: Filter<T, S>;
970
+ sort?: Sorting<S>[];
971
+ paging?: PagingFor<S>;
972
+ /** Field projection - return only specified fields */
973
+ fields?: string[];
974
+ }
975
+ /**
976
+ * Represents a filter expression that can be combined with other filters
977
+ */
978
+ interface FilterExpression<T, S extends QuerySpec> {
979
+ readonly filter: Filter<T, S>;
980
+ }
981
+ /**
982
+ * Represents a sort expression
983
+ */
984
+ interface SortExpression<S extends QuerySpec> {
985
+ readonly sort: Sorting<S>;
986
+ }
987
+ /**
988
+ * Extract fields that support a specific operator from the spec
989
+ */
990
+ type FieldsWithOperator<S extends QuerySpec, 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;
991
+ /**
992
+ * Check if a specific field supports a specific operator
993
+ */
994
+ type HasOperator<S extends QuerySpec, Field extends string, Op extends string> = Field extends FieldsWithOperator<S, Op> ? true : false;
995
+ /**
996
+ * Extract sortable fields from the spec
997
+ */
998
+ type SortableFields<S extends QuerySpec> = S['wql'][number] extends infer Group ? Group extends {
999
+ fields: readonly string[];
1000
+ sort: 'ASC' | 'DESC' | 'BOTH';
1001
+ } ? Group['fields'][number] : never : never;
1002
+ /**
1003
+ * Chainable field filter - extends FilterExpression so it can be used directly,
1004
+ * but also allows chaining multiple operators on the same field.
1005
+ * @example
1006
+ * // Single operator - returns ChainableFieldFilter which is also FilterExpression
1007
+ * Filter('price').gt(50)
1008
+ *
1009
+ * // Chained operators - combines into single field filter
1010
+ * Filter('price').gt(50).lt(100)
1011
+ * // Produces: { price: { $gt: 50, $lt: 100 } }
1012
+ */
1013
+ type ChainableFieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = FilterExpression<T, S> & (HasOperator<S, Field & string, '$eq'> extends true ? {
1014
+ eq(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1015
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
1016
+ ne(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1017
+ } : {}) & (HasOperator<S, Field & string, '$gt'> extends true ? {
1018
+ gt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1019
+ } : {}) & (HasOperator<S, Field & string, '$gte'> extends true ? {
1020
+ gte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1021
+ } : {}) & (HasOperator<S, Field & string, '$lt'> extends true ? {
1022
+ lt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1023
+ } : {}) & (HasOperator<S, Field & string, '$lte'> extends true ? {
1024
+ lte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1025
+ } : {}) & (HasOperator<S, Field & string, '$startsWith'> extends true ? {
1026
+ startsWith(value: string): ChainableFieldFilter<T, S, Field>;
1027
+ } : {}) & (HasOperator<S, Field & string, '$endsWith'> extends true ? {
1028
+ endsWith(value: string): ChainableFieldFilter<T, S, Field>;
1029
+ } : {}) & (HasOperator<S, Field & string, '$contains'> extends true ? {
1030
+ contains(value: string): ChainableFieldFilter<T, S, Field>;
1031
+ } : {}) & (HasOperator<S, Field & string, '$in'> extends true ? {
1032
+ in(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1033
+ } : {}) & (HasOperator<S, Field & string, '$nin'> extends true ? {
1034
+ nin(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1035
+ } : {}) & (HasOperator<S, Field & string, '$hasSome'> extends true ? {
1036
+ hasSome(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1037
+ } : {}) & (HasOperator<S, Field & string, '$hasAll'> extends true ? {
1038
+ hasAll(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1039
+ } : {}) & (HasOperator<S, Field & string, '$exists'> extends true ? {
1040
+ exists(value?: boolean): ChainableFieldFilter<T, S, Field>;
1041
+ } : {}) & (HasOperator<S, Field & string, '$isEmpty'> extends true ? {
1042
+ isEmpty(value?: boolean): ChainableFieldFilter<T, S, Field>;
1043
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
1044
+ isNotEmpty(): ChainableFieldFilter<T, S, Field>;
1045
+ } : {});
1046
+ /**
1047
+ * Filter methods for a specific field (alias for ChainableFieldFilter)
1048
+ * Only shows methods for operators that the field supports
1049
+ */
1050
+ type FieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = ChainableFieldFilter<T, S, Field>;
1051
+ /**
1052
+ * Sort methods for a specific field
1053
+ */
1054
+ interface FieldSort<S extends QuerySpec> {
1055
+ asc(): SortExpression<S>;
1056
+ desc(): SortExpression<S>;
1057
+ }
1058
+ /**
1059
+ * Filter factory interface - creates filter expressions
1060
+ * @example
1061
+ * Filter('price').gt(50)
1062
+ * Filter.and(Filter('title').eq('Product'), Filter('price').gt(50))
1063
+ */
1064
+ interface FilterFactory<T, S extends QuerySpec> {
1065
+ /** Create a field-specific filter */
1066
+ <Field extends FilterableFields<S>>(field: Field): FieldFilter<T, S, Field>;
1067
+ /** Combine filters with AND logic */
1068
+ and(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1069
+ /** Combine filters with OR logic */
1070
+ or(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1071
+ /** Negate a filter */
1072
+ not(filter: FilterExpression<T, S>): FilterExpression<T, S>;
1073
+ }
1074
+ /**
1075
+ * Sort factory - creates sort expressions
1076
+ * @example
1077
+ * Sort('price').desc()
1078
+ */
1079
+ type SortFactory<S extends QuerySpec> = <Field extends SortableFields<S>>(field: Field) => FieldSort<S>;
1080
+ /**
1081
+ * Query builder interface
1082
+ * @template T - Entity type
1083
+ * @template S - Query spec defining filterable/sortable fields
1084
+ * @template R - Output type from build() (defaults to QueryRequest<T, S>)
1085
+ * @example
1086
+ * QueryBuilder()
1087
+ * .withFilter(Filter.and(
1088
+ * Filter('title').eq('Product'),
1089
+ * Filter('price').gt(50)
1090
+ * ))
1091
+ * .withFields('title', 'price')
1092
+ * .withSorting(Sort('price').desc())
1093
+ * .withPaging({ limit: 20, offset: 0 })
1094
+ * .build()
1095
+ */
1096
+ interface QueryBuilder<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1097
+ /** Add a filter to the query */
1098
+ withFilter(filter: FilterExpression<T, S>): QueryBuilder<T, S, R>;
1099
+ /** Add field projection - return only specified fields */
1100
+ withFields(...fields: (keyof T & string)[]): QueryBuilder<T, S, R>;
1101
+ /** Add sorting to the query */
1102
+ withSorting(...sorts: SortExpression<S>[]): QueryBuilder<T, S, R>;
1103
+ /** Add paging to the query */
1104
+ withPaging(paging: PagingFor<S>): QueryBuilder<T, S, R>;
1105
+ /** Build the final query request object */
1106
+ build(): R;
1107
+ }
1108
+ /**
1109
+ * Complete set of query helpers for an entity
1110
+ * This is what gets spread into module namespaces
1111
+ * @template T - Entity type
1112
+ * @template S - Query spec defining filterable/sortable fields
1113
+ * @template R - Output type from QueryBuilder.build() (defaults to QueryRequest<T, S>)
1114
+ */
1115
+ interface QueryHelpers<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1116
+ /** QueryBuilder factory */
1117
+ QueryBuilder: () => QueryBuilder<T, S, R>;
1118
+ /** Filter factory - creates filter expressions */
1119
+ Filter: FilterFactory<T, S>;
1120
+ /** Sort factory - creates sort expressions */
1121
+ Sort: SortFactory<S>;
1122
+ }
1123
+
1124
+ 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 };
@@ -620,7 +620,7 @@ type Filter<Entity, Spec extends WQLSpec> = Simplify<{
620
620
  /**
621
621
  * Cursor-based paging configuration
622
622
  */
623
- interface CursorPaging {
623
+ interface CursorPaging$1 {
624
624
  /** Maximum number of items to return in the results. */
625
625
  limit?: number | null;
626
626
  /**
@@ -634,7 +634,7 @@ interface CursorPaging {
634
634
  /**
635
635
  * Offset-based paging configuration
636
636
  */
637
- interface OffsetPaging {
637
+ interface OffsetPaging$1 {
638
638
  /** Number of items to load */
639
639
  limit?: number | null;
640
640
  /** Number of items to skip in the current sort order */
@@ -650,9 +650,9 @@ type PagingType = 'cursor' | 'offset';
650
650
  type Paging<Spec extends {
651
651
  paging?: PagingType;
652
652
  }> = Spec['paging'] extends 'cursor' ? {
653
- cursorPaging: CursorPaging;
653
+ cursorPaging: CursorPaging$1;
654
654
  } : Spec['paging'] extends 'offset' ? {
655
- paging: OffsetPaging;
655
+ paging: OffsetPaging$1;
656
656
  } : {};
657
657
 
658
658
  /**
@@ -952,4 +952,173 @@ type Query<Entity, Spec extends QuerySpec> = {
952
952
  sort?: Sorting<Spec>[];
953
953
  } & Partial<Paging<Spec>>;
954
954
 
955
- 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 Descriptors, EventDefinition, type EventHandler, type EventIdentity, type ExposeFieldsBasedOnToggle, type Filter, 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 PublicMetadata, type Query, 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 SortOrder, type Sorting, type WQL, type WQLSpec };
955
+ interface CursorPaging {
956
+ limit: number;
957
+ cursor?: string;
958
+ }
959
+ interface OffsetPaging {
960
+ limit: number;
961
+ offset?: number;
962
+ }
963
+ type PagingFor<S extends QuerySpec> = S['paging'] extends 'cursor' ? CursorPaging : OffsetPaging;
964
+ /**
965
+ * The output type from QueryBuilder.build()
966
+ * This is a plain object ready to be sent to an API
967
+ */
968
+ interface QueryRequest<T, S extends QuerySpec> {
969
+ filter?: Filter<T, S>;
970
+ sort?: Sorting<S>[];
971
+ paging?: PagingFor<S>;
972
+ /** Field projection - return only specified fields */
973
+ fields?: string[];
974
+ }
975
+ /**
976
+ * Represents a filter expression that can be combined with other filters
977
+ */
978
+ interface FilterExpression<T, S extends QuerySpec> {
979
+ readonly filter: Filter<T, S>;
980
+ }
981
+ /**
982
+ * Represents a sort expression
983
+ */
984
+ interface SortExpression<S extends QuerySpec> {
985
+ readonly sort: Sorting<S>;
986
+ }
987
+ /**
988
+ * Extract fields that support a specific operator from the spec
989
+ */
990
+ type FieldsWithOperator<S extends QuerySpec, 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;
991
+ /**
992
+ * Check if a specific field supports a specific operator
993
+ */
994
+ type HasOperator<S extends QuerySpec, Field extends string, Op extends string> = Field extends FieldsWithOperator<S, Op> ? true : false;
995
+ /**
996
+ * Extract sortable fields from the spec
997
+ */
998
+ type SortableFields<S extends QuerySpec> = S['wql'][number] extends infer Group ? Group extends {
999
+ fields: readonly string[];
1000
+ sort: 'ASC' | 'DESC' | 'BOTH';
1001
+ } ? Group['fields'][number] : never : never;
1002
+ /**
1003
+ * Chainable field filter - extends FilterExpression so it can be used directly,
1004
+ * but also allows chaining multiple operators on the same field.
1005
+ * @example
1006
+ * // Single operator - returns ChainableFieldFilter which is also FilterExpression
1007
+ * Filter('price').gt(50)
1008
+ *
1009
+ * // Chained operators - combines into single field filter
1010
+ * Filter('price').gt(50).lt(100)
1011
+ * // Produces: { price: { $gt: 50, $lt: 100 } }
1012
+ */
1013
+ type ChainableFieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = FilterExpression<T, S> & (HasOperator<S, Field & string, '$eq'> extends true ? {
1014
+ eq(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1015
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
1016
+ ne(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1017
+ } : {}) & (HasOperator<S, Field & string, '$gt'> extends true ? {
1018
+ gt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1019
+ } : {}) & (HasOperator<S, Field & string, '$gte'> extends true ? {
1020
+ gte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1021
+ } : {}) & (HasOperator<S, Field & string, '$lt'> extends true ? {
1022
+ lt(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1023
+ } : {}) & (HasOperator<S, Field & string, '$lte'> extends true ? {
1024
+ lte(value: GetNestedType<T, Field & string>): ChainableFieldFilter<T, S, Field>;
1025
+ } : {}) & (HasOperator<S, Field & string, '$startsWith'> extends true ? {
1026
+ startsWith(value: string): ChainableFieldFilter<T, S, Field>;
1027
+ } : {}) & (HasOperator<S, Field & string, '$endsWith'> extends true ? {
1028
+ endsWith(value: string): ChainableFieldFilter<T, S, Field>;
1029
+ } : {}) & (HasOperator<S, Field & string, '$contains'> extends true ? {
1030
+ contains(value: string): ChainableFieldFilter<T, S, Field>;
1031
+ } : {}) & (HasOperator<S, Field & string, '$in'> extends true ? {
1032
+ in(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1033
+ } : {}) & (HasOperator<S, Field & string, '$nin'> extends true ? {
1034
+ nin(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1035
+ } : {}) & (HasOperator<S, Field & string, '$hasSome'> extends true ? {
1036
+ hasSome(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1037
+ } : {}) & (HasOperator<S, Field & string, '$hasAll'> extends true ? {
1038
+ hasAll(values: GetNestedType<T, Field & string>[]): ChainableFieldFilter<T, S, Field>;
1039
+ } : {}) & (HasOperator<S, Field & string, '$exists'> extends true ? {
1040
+ exists(value?: boolean): ChainableFieldFilter<T, S, Field>;
1041
+ } : {}) & (HasOperator<S, Field & string, '$isEmpty'> extends true ? {
1042
+ isEmpty(value?: boolean): ChainableFieldFilter<T, S, Field>;
1043
+ } : {}) & (HasOperator<S, Field & string, '$ne'> extends true ? {
1044
+ isNotEmpty(): ChainableFieldFilter<T, S, Field>;
1045
+ } : {});
1046
+ /**
1047
+ * Filter methods for a specific field (alias for ChainableFieldFilter)
1048
+ * Only shows methods for operators that the field supports
1049
+ */
1050
+ type FieldFilter<T, S extends QuerySpec, Field extends FilterableFields<S>> = ChainableFieldFilter<T, S, Field>;
1051
+ /**
1052
+ * Sort methods for a specific field
1053
+ */
1054
+ interface FieldSort<S extends QuerySpec> {
1055
+ asc(): SortExpression<S>;
1056
+ desc(): SortExpression<S>;
1057
+ }
1058
+ /**
1059
+ * Filter factory interface - creates filter expressions
1060
+ * @example
1061
+ * Filter('price').gt(50)
1062
+ * Filter.and(Filter('title').eq('Product'), Filter('price').gt(50))
1063
+ */
1064
+ interface FilterFactory<T, S extends QuerySpec> {
1065
+ /** Create a field-specific filter */
1066
+ <Field extends FilterableFields<S>>(field: Field): FieldFilter<T, S, Field>;
1067
+ /** Combine filters with AND logic */
1068
+ and(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1069
+ /** Combine filters with OR logic */
1070
+ or(...filters: FilterExpression<T, S>[]): FilterExpression<T, S>;
1071
+ /** Negate a filter */
1072
+ not(filter: FilterExpression<T, S>): FilterExpression<T, S>;
1073
+ }
1074
+ /**
1075
+ * Sort factory - creates sort expressions
1076
+ * @example
1077
+ * Sort('price').desc()
1078
+ */
1079
+ type SortFactory<S extends QuerySpec> = <Field extends SortableFields<S>>(field: Field) => FieldSort<S>;
1080
+ /**
1081
+ * Query builder interface
1082
+ * @template T - Entity type
1083
+ * @template S - Query spec defining filterable/sortable fields
1084
+ * @template R - Output type from build() (defaults to QueryRequest<T, S>)
1085
+ * @example
1086
+ * QueryBuilder()
1087
+ * .withFilter(Filter.and(
1088
+ * Filter('title').eq('Product'),
1089
+ * Filter('price').gt(50)
1090
+ * ))
1091
+ * .withFields('title', 'price')
1092
+ * .withSorting(Sort('price').desc())
1093
+ * .withPaging({ limit: 20, offset: 0 })
1094
+ * .build()
1095
+ */
1096
+ interface QueryBuilder<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1097
+ /** Add a filter to the query */
1098
+ withFilter(filter: FilterExpression<T, S>): QueryBuilder<T, S, R>;
1099
+ /** Add field projection - return only specified fields */
1100
+ withFields(...fields: (keyof T & string)[]): QueryBuilder<T, S, R>;
1101
+ /** Add sorting to the query */
1102
+ withSorting(...sorts: SortExpression<S>[]): QueryBuilder<T, S, R>;
1103
+ /** Add paging to the query */
1104
+ withPaging(paging: PagingFor<S>): QueryBuilder<T, S, R>;
1105
+ /** Build the final query request object */
1106
+ build(): R;
1107
+ }
1108
+ /**
1109
+ * Complete set of query helpers for an entity
1110
+ * This is what gets spread into module namespaces
1111
+ * @template T - Entity type
1112
+ * @template S - Query spec defining filterable/sortable fields
1113
+ * @template R - Output type from QueryBuilder.build() (defaults to QueryRequest<T, S>)
1114
+ */
1115
+ interface QueryHelpers<T, S extends QuerySpec, R = QueryRequest<T, S>> {
1116
+ /** QueryBuilder factory */
1117
+ QueryBuilder: () => QueryBuilder<T, S, R>;
1118
+ /** Filter factory - creates filter expressions */
1119
+ Filter: FilterFactory<T, S>;
1120
+ /** Sort factory - creates sort expressions */
1121
+ Sort: SortFactory<S>;
1122
+ }
1123
+
1124
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk-types",
3
- "version": "1.17.2",
3
+ "version": "1.17.3",
4
4
  "author": {
5
5
  "name": "Ronny Ringel",
6
6
  "email": "ronnyr@wix.com"
@@ -62,5 +62,5 @@
62
62
  ]
63
63
  }
64
64
  },
65
- "falconPackageHash": "dbcb65b0d495abc60656e5cf051188a2fbdc2f6359aaade41b2465ee"
65
+ "falconPackageHash": "eb15746655965d0002260ab07a45e3c8f10b08ce396d6ea3c7045674"
66
66
  }