@wix/search 1.0.43 → 1.0.44

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.
@@ -1,9 +1,9 @@
1
- type HostModule<T, H extends Host> = {
1
+ type HostModule$1<T, H extends Host$1> = {
2
2
  __type: 'host';
3
3
  create(host: H): T;
4
4
  };
5
- type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
6
- type Host<Environment = unknown> = {
5
+ type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
6
+ type Host$1<Environment = unknown> = {
7
7
  channel: {
8
8
  observeState(callback: (props: unknown, environment: Environment) => unknown): {
9
9
  disconnect: () => void;
@@ -36,92 +36,92 @@ type Host<Environment = unknown> = {
36
36
  };
37
37
  };
38
38
 
39
- type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
40
- interface HttpClient {
41
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
39
+ type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
40
+ interface HttpClient$1 {
41
+ request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
42
42
  fetchWithAuth: typeof fetch;
43
43
  wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
44
44
  getActiveToken?: () => string | undefined;
45
45
  }
46
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
47
- type HttpResponse<T = any> = {
46
+ type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
47
+ type HttpResponse$1<T = any> = {
48
48
  data: T;
49
49
  status: number;
50
50
  statusText: string;
51
51
  headers: any;
52
52
  request?: any;
53
53
  };
54
- type RequestOptions<_TResponse = any, Data = any> = {
54
+ type RequestOptions$1<_TResponse = any, Data = any> = {
55
55
  method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
56
56
  url: string;
57
57
  data?: Data;
58
58
  params?: URLSearchParams;
59
- } & APIMetadata;
60
- type APIMetadata = {
59
+ } & APIMetadata$1;
60
+ type APIMetadata$1 = {
61
61
  methodFqn?: string;
62
62
  entityFqdn?: string;
63
63
  packageName?: string;
64
64
  };
65
- type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
66
- type EventDefinition<Payload = unknown, Type extends string = string> = {
65
+ type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
66
+ type EventDefinition$1<Payload = unknown, Type extends string = string> = {
67
67
  __type: 'event-definition';
68
68
  type: Type;
69
69
  isDomainEvent?: boolean;
70
70
  transformations?: (envelope: unknown) => Payload;
71
71
  __payload: Payload;
72
72
  };
73
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
74
- type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
75
- type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
73
+ declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
74
+ type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
75
+ type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
76
76
 
77
- type ServicePluginMethodInput = {
77
+ type ServicePluginMethodInput$1 = {
78
78
  request: any;
79
79
  metadata: any;
80
80
  };
81
- type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
82
- type ServicePluginMethodMetadata = {
81
+ type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
82
+ type ServicePluginMethodMetadata$1 = {
83
83
  name: string;
84
84
  primaryHttpMappingPath: string;
85
85
  transformations: {
86
- fromREST: (...args: unknown[]) => ServicePluginMethodInput;
86
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
87
87
  toREST: (...args: unknown[]) => unknown;
88
88
  };
89
89
  };
90
- type ServicePluginDefinition<Contract extends ServicePluginContract> = {
90
+ type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
91
91
  __type: 'service-plugin-definition';
92
92
  componentType: string;
93
- methods: ServicePluginMethodMetadata[];
93
+ methods: ServicePluginMethodMetadata$1[];
94
94
  __contract: Contract;
95
95
  };
96
- declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
97
- type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
98
- declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
96
+ declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
97
+ type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
98
+ declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
99
99
 
100
- type RequestContext = {
100
+ type RequestContext$1 = {
101
101
  isSSR: boolean;
102
102
  host: string;
103
103
  protocol?: string;
104
104
  };
105
- type ResponseTransformer = (data: any, headers?: any) => any;
105
+ type ResponseTransformer$1 = (data: any, headers?: any) => any;
106
106
  /**
107
107
  * Ambassador request options types are copied mostly from AxiosRequestConfig.
108
108
  * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
109
109
  * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
110
110
  */
111
- type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
112
- type AmbassadorRequestOptions<T = any> = {
111
+ type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
112
+ type AmbassadorRequestOptions$1<T = any> = {
113
113
  _?: T;
114
114
  url?: string;
115
- method?: Method;
115
+ method?: Method$1;
116
116
  params?: any;
117
117
  data?: any;
118
- transformResponse?: ResponseTransformer | ResponseTransformer[];
118
+ transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
119
119
  };
120
- type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
120
+ type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
121
121
  __isAmbassador: boolean;
122
122
  };
123
- type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
124
- type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
123
+ type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
124
+ type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
125
125
 
126
126
  declare global {
127
127
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
@@ -130,7 +130,7 @@ declare global {
130
130
  }
131
131
  }
132
132
 
133
- declare const emptyObjectSymbol: unique symbol;
133
+ declare const emptyObjectSymbol$1: unique symbol;
134
134
 
135
135
  /**
136
136
  Represents a strictly empty plain object, the `{}` value.
@@ -158,7 +158,7 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
158
158
 
159
159
  @category Object
160
160
  */
161
- type EmptyObject = {[emptyObjectSymbol]?: never};
161
+ type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
162
162
 
163
163
  /**
164
164
  Returns a boolean for whether the two given types are equal.
@@ -186,7 +186,7 @@ type Includes<Value extends readonly any[], Item> =
186
186
  @category Type Guard
187
187
  @category Utilities
188
188
  */
189
- type IsEqual<A, B> =
189
+ type IsEqual$1<A, B> =
190
190
  (<G>() => G extends A ? 1 : 2) extends
191
191
  (<G>() => G extends B ? 1 : 2)
192
192
  ? true
@@ -219,9 +219,9 @@ type Filtered = Filter<'bar', 'foo'>;
219
219
 
220
220
  @see {Except}
221
221
  */
222
- type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
222
+ type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
223
223
 
224
- type ExceptOptions = {
224
+ type ExceptOptions$1 = {
225
225
  /**
226
226
  Disallow assigning non-specified properties.
227
227
 
@@ -265,8 +265,8 @@ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
265
265
 
266
266
  @category Object
267
267
  */
268
- type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
269
- [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
268
+ type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
269
+ [KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
270
270
  } & (Options['requireExactProps'] extends true
271
271
  ? Partial<Record<KeysType, never>>
272
272
  : {});
@@ -303,7 +303,7 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
303
303
 
304
304
  @category Object
305
305
  */
306
- type ConditionalKeys<Base, Condition> = NonNullable<
306
+ type ConditionalKeys$1<Base, Condition> = NonNullable<
307
307
  // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
308
308
  {
309
309
  // Map through all the keys of the given base type.
@@ -357,9 +357,9 @@ type NonStringKeysOnly = ConditionalExcept<Example, string>;
357
357
 
358
358
  @category Object
359
359
  */
360
- type ConditionalExcept<Base, Condition> = Except<
360
+ type ConditionalExcept$1<Base, Condition> = Except$1<
361
361
  Base,
362
- ConditionalKeys<Base, Condition>
362
+ ConditionalKeys$1<Base, Condition>
363
363
  >;
364
364
 
365
365
  /**
@@ -367,8 +367,8 @@ ConditionalKeys<Base, Condition>
367
367
  * can either be a REST module or a host module.
368
368
  * This type is recursive, so it can describe nested modules.
369
369
  */
370
- type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
371
- [key: string]: Descriptors | PublicMetadata | any;
370
+ type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$1<any> | ServicePluginDefinition$1<any> | {
371
+ [key: string]: Descriptors$1 | PublicMetadata$1 | any;
372
372
  };
373
373
  /**
374
374
  * This type takes in a descriptors object of a certain Host (including an `unknown` host)
@@ -376,12 +376,12 @@ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostM
376
376
  * Any non-descriptor properties are removed from the returned object, including descriptors that
377
377
  * do not match the given host (as they will not work with the given host).
378
378
  */
379
- type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
379
+ type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
380
380
  done: T;
381
381
  recurse: T extends {
382
- __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
383
- } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
384
- [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
382
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
383
+ } ? never : T extends AmbassadorFunctionDescriptor$1 ? BuildAmbassadorFunction$1<T> : T extends RESTFunctionDescriptor$1 ? BuildRESTFunction$1<T> : T extends EventDefinition$1<any> ? BuildEventDefinition$1<T> : T extends ServicePluginDefinition$1<any> ? BuildServicePluginDefinition$1<T> : T extends HostModule$1<any, any> ? HostModuleAPI$1<T> : ConditionalExcept$1<{
384
+ [Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
385
385
  -1,
386
386
  0,
387
387
  1,
@@ -390,9 +390,9 @@ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, De
390
390
  4,
391
391
  5
392
392
  ][Depth]> : never;
393
- }, EmptyObject>;
393
+ }, EmptyObject$1>;
394
394
  }[Depth extends -1 ? 'done' : 'recurse'];
395
- type PublicMetadata = {
395
+ type PublicMetadata$1 = {
396
396
  PACKAGE_NAME?: string;
397
397
  };
398
398
 
@@ -404,9 +404,9 @@ declare global {
404
404
  * A type used to create concerete types from SDK descriptors in
405
405
  * case a contextual client is available.
406
406
  */
407
- type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
408
- host: Host;
409
- } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
407
+ type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
408
+ host: Host$1;
409
+ } ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
410
410
 
411
411
  interface SiteDocument$1 {
412
412
  /**
@@ -708,7 +708,7 @@ interface SearchOptions$1 {
708
708
  language?: string | null;
709
709
  }
710
710
 
711
- declare function search$3(httpClient: HttpClient): SearchSignature$1;
711
+ declare function search$3(httpClient: HttpClient$1): SearchSignature$1;
712
712
  interface SearchSignature$1 {
713
713
  /**
714
714
  * Retrieves a list of site documents that match the provided search query and optionally performs aggregations on the data queried.
@@ -722,7 +722,7 @@ interface SearchSignature$1 {
722
722
  (search: Search, documentType: DocumentType, options?: SearchOptions$1 | undefined): Promise<SearchResponse$1 & SearchResponseNonNullableFields$1>;
723
723
  }
724
724
 
725
- declare const search$2: MaybeContext<BuildRESTFunction<typeof search$3> & typeof search$3>;
725
+ declare const search$2: MaybeContext$1<BuildRESTFunction$1<typeof search$3> & typeof search$3>;
726
726
 
727
727
  type context$1_AggregationData = AggregationData;
728
728
  type context$1_AggregationKindOneOf = AggregationKindOneOf;
@@ -763,6 +763,416 @@ declare namespace context$1 {
763
763
  export { type Aggregation$1 as Aggregation, type context$1_AggregationData as AggregationData, type context$1_AggregationKindOneOf as AggregationKindOneOf, type context$1_AggregationResults as AggregationResults, type context$1_AggregationResultsResultOneOf as AggregationResultsResultOneOf, type context$1_AggregationResultsScalarResult as AggregationResultsScalarResult, context$1_AggregationType as AggregationType, context$1_DocumentType as DocumentType, type context$1_NestedAggregation as NestedAggregation, type context$1_NestedAggregationItem as NestedAggregationItem, type context$1_NestedAggregationItemKindOneOf as NestedAggregationItemKindOneOf, context$1_NestedAggregationType as NestedAggregationType, type context$1_NestedResultValue as NestedResultValue, type context$1_NestedResultValueResultOneOf as NestedResultValueResultOneOf, type context$1_NestedResults as NestedResults, type context$1_Paging as Paging, type context$1_PagingMetadata as PagingMetadata, type context$1_Results as Results, type context$1_ScalarAggregation as ScalarAggregation, type context$1_ScalarResult as ScalarResult, context$1_ScalarType as ScalarType, type context$1_Search as Search, type context$1_SearchDetails as SearchDetails, type SearchOptions$1 as SearchOptions, type context$1_SearchPagingMethodOneOf as SearchPagingMethodOneOf, type SearchRequest$1 as SearchRequest, type SearchResponse$1 as SearchResponse, type SearchResponseNonNullableFields$1 as SearchResponseNonNullableFields, type context$1_SearchResponsePagingOneOf as SearchResponsePagingOneOf, type SiteDocument$1 as SiteDocument, context$1_SortOrder as SortOrder, type context$1_Sorting as Sorting, type context$1_ValueAggregation as ValueAggregation, type context$1_ValueAggregationResult as ValueAggregationResult, type context$1_ValueResult as ValueResult, type context$1_ValueResults as ValueResults, search$2 as search };
764
764
  }
765
765
 
766
+ type HostModule<T, H extends Host> = {
767
+ __type: 'host';
768
+ create(host: H): T;
769
+ };
770
+ type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
771
+ type Host<Environment = unknown> = {
772
+ channel: {
773
+ observeState(callback: (props: unknown, environment: Environment) => unknown): {
774
+ disconnect: () => void;
775
+ } | Promise<{
776
+ disconnect: () => void;
777
+ }>;
778
+ };
779
+ environment?: Environment;
780
+ /**
781
+ * Optional bast url to use for API requests, for example `www.wixapis.com`
782
+ */
783
+ apiBaseUrl?: string;
784
+ /**
785
+ * Possible data to be provided by every host, for cross cutting concerns
786
+ * like internationalization, billing, etc.
787
+ */
788
+ essentials?: {
789
+ /**
790
+ * The language of the currently viewed session
791
+ */
792
+ language?: string;
793
+ /**
794
+ * The locale of the currently viewed session
795
+ */
796
+ locale?: string;
797
+ /**
798
+ * Any headers that should be passed through to the API requests
799
+ */
800
+ passThroughHeaders?: Record<string, string>;
801
+ };
802
+ };
803
+
804
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
805
+ interface HttpClient {
806
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
807
+ fetchWithAuth: typeof fetch;
808
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
809
+ getActiveToken?: () => string | undefined;
810
+ }
811
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
812
+ type HttpResponse<T = any> = {
813
+ data: T;
814
+ status: number;
815
+ statusText: string;
816
+ headers: any;
817
+ request?: any;
818
+ };
819
+ type RequestOptions<_TResponse = any, Data = any> = {
820
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
821
+ url: string;
822
+ data?: Data;
823
+ params?: URLSearchParams;
824
+ } & APIMetadata;
825
+ type APIMetadata = {
826
+ methodFqn?: string;
827
+ entityFqdn?: string;
828
+ packageName?: string;
829
+ };
830
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
831
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
832
+ __type: 'event-definition';
833
+ type: Type;
834
+ isDomainEvent?: boolean;
835
+ transformations?: (envelope: unknown) => Payload;
836
+ __payload: Payload;
837
+ };
838
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
839
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
840
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
841
+
842
+ type ServicePluginMethodInput = {
843
+ request: any;
844
+ metadata: any;
845
+ };
846
+ type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
847
+ type ServicePluginMethodMetadata = {
848
+ name: string;
849
+ primaryHttpMappingPath: string;
850
+ transformations: {
851
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput;
852
+ toREST: (...args: unknown[]) => unknown;
853
+ };
854
+ };
855
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
856
+ __type: 'service-plugin-definition';
857
+ componentType: string;
858
+ methods: ServicePluginMethodMetadata[];
859
+ __contract: Contract;
860
+ };
861
+ declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
862
+ type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
863
+ declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
864
+
865
+ type RequestContext = {
866
+ isSSR: boolean;
867
+ host: string;
868
+ protocol?: string;
869
+ };
870
+ type ResponseTransformer = (data: any, headers?: any) => any;
871
+ /**
872
+ * Ambassador request options types are copied mostly from AxiosRequestConfig.
873
+ * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
874
+ * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
875
+ */
876
+ type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
877
+ type AmbassadorRequestOptions<T = any> = {
878
+ _?: T;
879
+ url?: string;
880
+ method?: Method;
881
+ params?: any;
882
+ data?: any;
883
+ transformResponse?: ResponseTransformer | ResponseTransformer[];
884
+ };
885
+ type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
886
+ __isAmbassador: boolean;
887
+ };
888
+ type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
889
+ type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
890
+
891
+ declare global {
892
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
893
+ interface SymbolConstructor {
894
+ readonly observable: symbol;
895
+ }
896
+ }
897
+
898
+ declare const emptyObjectSymbol: unique symbol;
899
+
900
+ /**
901
+ Represents a strictly empty plain object, the `{}` value.
902
+
903
+ When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
904
+
905
+ @example
906
+ ```
907
+ import type {EmptyObject} from 'type-fest';
908
+
909
+ // The following illustrates the problem with `{}`.
910
+ const foo1: {} = {}; // Pass
911
+ const foo2: {} = []; // Pass
912
+ const foo3: {} = 42; // Pass
913
+ const foo4: {} = {a: 1}; // Pass
914
+
915
+ // With `EmptyObject` only the first case is valid.
916
+ const bar1: EmptyObject = {}; // Pass
917
+ const bar2: EmptyObject = 42; // Fail
918
+ const bar3: EmptyObject = []; // Fail
919
+ const bar4: EmptyObject = {a: 1}; // Fail
920
+ ```
921
+
922
+ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
923
+
924
+ @category Object
925
+ */
926
+ type EmptyObject = {[emptyObjectSymbol]?: never};
927
+
928
+ /**
929
+ Returns a boolean for whether the two given types are equal.
930
+
931
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
932
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
933
+
934
+ Use-cases:
935
+ - If you want to make a conditional branch based on the result of a comparison of two types.
936
+
937
+ @example
938
+ ```
939
+ import type {IsEqual} from 'type-fest';
940
+
941
+ // This type returns a boolean for whether the given array includes the given item.
942
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
943
+ type Includes<Value extends readonly any[], Item> =
944
+ Value extends readonly [Value[0], ...infer rest]
945
+ ? IsEqual<Value[0], Item> extends true
946
+ ? true
947
+ : Includes<rest, Item>
948
+ : false;
949
+ ```
950
+
951
+ @category Type Guard
952
+ @category Utilities
953
+ */
954
+ type IsEqual<A, B> =
955
+ (<G>() => G extends A ? 1 : 2) extends
956
+ (<G>() => G extends B ? 1 : 2)
957
+ ? true
958
+ : false;
959
+
960
+ /**
961
+ Filter out keys from an object.
962
+
963
+ Returns `never` if `Exclude` is strictly equal to `Key`.
964
+ Returns `never` if `Key` extends `Exclude`.
965
+ Returns `Key` otherwise.
966
+
967
+ @example
968
+ ```
969
+ type Filtered = Filter<'foo', 'foo'>;
970
+ //=> never
971
+ ```
972
+
973
+ @example
974
+ ```
975
+ type Filtered = Filter<'bar', string>;
976
+ //=> never
977
+ ```
978
+
979
+ @example
980
+ ```
981
+ type Filtered = Filter<'bar', 'foo'>;
982
+ //=> 'bar'
983
+ ```
984
+
985
+ @see {Except}
986
+ */
987
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
988
+
989
+ type ExceptOptions = {
990
+ /**
991
+ Disallow assigning non-specified properties.
992
+
993
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
994
+
995
+ @default false
996
+ */
997
+ requireExactProps?: boolean;
998
+ };
999
+
1000
+ /**
1001
+ Create a type from an object type without certain keys.
1002
+
1003
+ We recommend setting the `requireExactProps` option to `true`.
1004
+
1005
+ This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
1006
+
1007
+ This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
1008
+
1009
+ @example
1010
+ ```
1011
+ import type {Except} from 'type-fest';
1012
+
1013
+ type Foo = {
1014
+ a: number;
1015
+ b: string;
1016
+ };
1017
+
1018
+ type FooWithoutA = Except<Foo, 'a'>;
1019
+ //=> {b: string}
1020
+
1021
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
1022
+ //=> errors: 'a' does not exist in type '{ b: string; }'
1023
+
1024
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
1025
+ //=> {a: number} & Partial<Record<"b", never>>
1026
+
1027
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
1028
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
1029
+ ```
1030
+
1031
+ @category Object
1032
+ */
1033
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
1034
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
1035
+ } & (Options['requireExactProps'] extends true
1036
+ ? Partial<Record<KeysType, never>>
1037
+ : {});
1038
+
1039
+ /**
1040
+ Extract the keys from a type where the value type of the key extends the given `Condition`.
1041
+
1042
+ Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
1043
+
1044
+ @example
1045
+ ```
1046
+ import type {ConditionalKeys} from 'type-fest';
1047
+
1048
+ interface Example {
1049
+ a: string;
1050
+ b: string | number;
1051
+ c?: string;
1052
+ d: {};
1053
+ }
1054
+
1055
+ type StringKeysOnly = ConditionalKeys<Example, string>;
1056
+ //=> 'a'
1057
+ ```
1058
+
1059
+ To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
1060
+
1061
+ @example
1062
+ ```
1063
+ import type {ConditionalKeys} from 'type-fest';
1064
+
1065
+ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
1066
+ //=> 'a' | 'c'
1067
+ ```
1068
+
1069
+ @category Object
1070
+ */
1071
+ type ConditionalKeys<Base, Condition> = NonNullable<
1072
+ // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
1073
+ {
1074
+ // Map through all the keys of the given base type.
1075
+ [Key in keyof Base]:
1076
+ // Pick only keys with types extending the given `Condition` type.
1077
+ Base[Key] extends Condition
1078
+ // Retain this key since the condition passes.
1079
+ ? Key
1080
+ // Discard this key since the condition fails.
1081
+ : never;
1082
+
1083
+ // Convert the produced object into a union type of the keys which passed the conditional test.
1084
+ }[keyof Base]
1085
+ >;
1086
+
1087
+ /**
1088
+ Exclude keys from a shape that matches the given `Condition`.
1089
+
1090
+ This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
1091
+
1092
+ @example
1093
+ ```
1094
+ import type {Primitive, ConditionalExcept} from 'type-fest';
1095
+
1096
+ class Awesome {
1097
+ name: string;
1098
+ successes: number;
1099
+ failures: bigint;
1100
+
1101
+ run() {}
1102
+ }
1103
+
1104
+ type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
1105
+ //=> {run: () => void}
1106
+ ```
1107
+
1108
+ @example
1109
+ ```
1110
+ import type {ConditionalExcept} from 'type-fest';
1111
+
1112
+ interface Example {
1113
+ a: string;
1114
+ b: string | number;
1115
+ c: () => void;
1116
+ d: {};
1117
+ }
1118
+
1119
+ type NonStringKeysOnly = ConditionalExcept<Example, string>;
1120
+ //=> {b: string | number; c: () => void; d: {}}
1121
+ ```
1122
+
1123
+ @category Object
1124
+ */
1125
+ type ConditionalExcept<Base, Condition> = Except<
1126
+ Base,
1127
+ ConditionalKeys<Base, Condition>
1128
+ >;
1129
+
1130
+ /**
1131
+ * Descriptors are objects that describe the API of a module, and the module
1132
+ * can either be a REST module or a host module.
1133
+ * This type is recursive, so it can describe nested modules.
1134
+ */
1135
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
1136
+ [key: string]: Descriptors | PublicMetadata | any;
1137
+ };
1138
+ /**
1139
+ * This type takes in a descriptors object of a certain Host (including an `unknown` host)
1140
+ * and returns an object with the same structure, but with all descriptors replaced with their API.
1141
+ * Any non-descriptor properties are removed from the returned object, including descriptors that
1142
+ * do not match the given host (as they will not work with the given host).
1143
+ */
1144
+ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
1145
+ done: T;
1146
+ recurse: T extends {
1147
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
1148
+ } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
1149
+ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
1150
+ -1,
1151
+ 0,
1152
+ 1,
1153
+ 2,
1154
+ 3,
1155
+ 4,
1156
+ 5
1157
+ ][Depth]> : never;
1158
+ }, EmptyObject>;
1159
+ }[Depth extends -1 ? 'done' : 'recurse'];
1160
+ type PublicMetadata = {
1161
+ PACKAGE_NAME?: string;
1162
+ };
1163
+
1164
+ declare global {
1165
+ interface ContextualClient {
1166
+ }
1167
+ }
1168
+ /**
1169
+ * A type used to create concerete types from SDK descriptors in
1170
+ * case a contextual client is available.
1171
+ */
1172
+ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
1173
+ host: Host;
1174
+ } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
1175
+
766
1176
  /** API is not yet fully migrated to FQDN entity */
767
1177
  interface SiteDocument {
768
1178
  /** the document payload */