@wix/sdk-types 1.17.1 → 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.
@@ -213,9 +213,15 @@ type EventIdentity = {
213
213
  wixUserId: string;
214
214
  appId: string;
215
215
  };
216
+ type AccountInfo = {
217
+ accountId: string;
218
+ parentAccountId?: string;
219
+ siteId?: string;
220
+ };
216
221
  type BaseEventMetadata = {
217
222
  instanceId: string;
218
223
  identity?: EventIdentity;
224
+ accountInfo?: AccountInfo;
219
225
  };
220
226
  type EventDefinition<Payload = unknown, Type extends string = string> = {
221
227
  __type: 'event-definition';
@@ -614,7 +620,7 @@ type Filter<Entity, Spec extends WQLSpec> = Simplify<{
614
620
  /**
615
621
  * Cursor-based paging configuration
616
622
  */
617
- interface CursorPaging {
623
+ interface CursorPaging$1 {
618
624
  /** Maximum number of items to return in the results. */
619
625
  limit?: number | null;
620
626
  /**
@@ -628,7 +634,7 @@ interface CursorPaging {
628
634
  /**
629
635
  * Offset-based paging configuration
630
636
  */
631
- interface OffsetPaging {
637
+ interface OffsetPaging$1 {
632
638
  /** Number of items to load */
633
639
  limit?: number | null;
634
640
  /** Number of items to skip in the current sort order */
@@ -644,9 +650,9 @@ type PagingType = 'cursor' | 'offset';
644
650
  type Paging<Spec extends {
645
651
  paging?: PagingType;
646
652
  }> = Spec['paging'] extends 'cursor' ? {
647
- cursorPaging: CursorPaging;
653
+ cursorPaging: CursorPaging$1;
648
654
  } : Spec['paging'] extends 'offset' ? {
649
- paging: OffsetPaging;
655
+ paging: OffsetPaging$1;
650
656
  } : {};
651
657
 
652
658
  /**
@@ -946,4 +952,173 @@ type Query<Entity, Spec extends QuerySpec> = {
946
952
  sort?: Sorting<Spec>[];
947
953
  } & Partial<Paging<Spec>>;
948
954
 
949
- export { type APIMetadata, 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 };
@@ -213,9 +213,15 @@ type EventIdentity = {
213
213
  wixUserId: string;
214
214
  appId: string;
215
215
  };
216
+ type AccountInfo = {
217
+ accountId: string;
218
+ parentAccountId?: string;
219
+ siteId?: string;
220
+ };
216
221
  type BaseEventMetadata = {
217
222
  instanceId: string;
218
223
  identity?: EventIdentity;
224
+ accountInfo?: AccountInfo;
219
225
  };
220
226
  type EventDefinition<Payload = unknown, Type extends string = string> = {
221
227
  __type: 'event-definition';
@@ -614,7 +620,7 @@ type Filter<Entity, Spec extends WQLSpec> = Simplify<{
614
620
  /**
615
621
  * Cursor-based paging configuration
616
622
  */
617
- interface CursorPaging {
623
+ interface CursorPaging$1 {
618
624
  /** Maximum number of items to return in the results. */
619
625
  limit?: number | null;
620
626
  /**
@@ -628,7 +634,7 @@ interface CursorPaging {
628
634
  /**
629
635
  * Offset-based paging configuration
630
636
  */
631
- interface OffsetPaging {
637
+ interface OffsetPaging$1 {
632
638
  /** Number of items to load */
633
639
  limit?: number | null;
634
640
  /** Number of items to skip in the current sort order */
@@ -644,9 +650,9 @@ type PagingType = 'cursor' | 'offset';
644
650
  type Paging<Spec extends {
645
651
  paging?: PagingType;
646
652
  }> = Spec['paging'] extends 'cursor' ? {
647
- cursorPaging: CursorPaging;
653
+ cursorPaging: CursorPaging$1;
648
654
  } : Spec['paging'] extends 'offset' ? {
649
- paging: OffsetPaging;
655
+ paging: OffsetPaging$1;
650
656
  } : {};
651
657
 
652
658
  /**
@@ -946,4 +952,173 @@ type Query<Entity, Spec extends QuerySpec> = {
946
952
  sort?: Sorting<Spec>[];
947
953
  } & Partial<Paging<Spec>>;
948
954
 
949
- export { type APIMetadata, 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 };
@@ -213,9 +213,15 @@ type EventIdentity = {
213
213
  wixUserId: string;
214
214
  appId: string;
215
215
  };
216
+ type AccountInfo = {
217
+ accountId: string;
218
+ parentAccountId?: string;
219
+ siteId?: string;
220
+ };
216
221
  type BaseEventMetadata = {
217
222
  instanceId: string;
218
223
  identity?: EventIdentity;
224
+ accountInfo?: AccountInfo;
219
225
  };
220
226
  type EventDefinition<Payload = unknown, Type extends string = string> = {
221
227
  __type: 'event-definition';
@@ -614,7 +620,7 @@ type Filter<Entity, Spec extends WQLSpec> = Simplify<{
614
620
  /**
615
621
  * Cursor-based paging configuration
616
622
  */
617
- interface CursorPaging {
623
+ interface CursorPaging$1 {
618
624
  /** Maximum number of items to return in the results. */
619
625
  limit?: number | null;
620
626
  /**
@@ -628,7 +634,7 @@ interface CursorPaging {
628
634
  /**
629
635
  * Offset-based paging configuration
630
636
  */
631
- interface OffsetPaging {
637
+ interface OffsetPaging$1 {
632
638
  /** Number of items to load */
633
639
  limit?: number | null;
634
640
  /** Number of items to skip in the current sort order */
@@ -644,9 +650,9 @@ type PagingType = 'cursor' | 'offset';
644
650
  type Paging<Spec extends {
645
651
  paging?: PagingType;
646
652
  }> = Spec['paging'] extends 'cursor' ? {
647
- cursorPaging: CursorPaging;
653
+ cursorPaging: CursorPaging$1;
648
654
  } : Spec['paging'] extends 'offset' ? {
649
- paging: OffsetPaging;
655
+ paging: OffsetPaging$1;
650
656
  } : {};
651
657
 
652
658
  /**
@@ -946,4 +952,173 @@ type Query<Entity, Spec extends QuerySpec> = {
946
952
  sort?: Sorting<Spec>[];
947
953
  } & Partial<Paging<Spec>>;
948
954
 
949
- export { type APIMetadata, 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 };