@wix/search 1.0.44 → 1.0.45

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$1<T, H extends Host$1> = {
1
+ type HostModule<T, H extends Host> = {
2
2
  __type: 'host';
3
3
  create(host: H): T;
4
4
  };
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> = {
5
+ type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
6
+ type Host<Environment = unknown> = {
7
7
  channel: {
8
8
  observeState(callback: (props: unknown, environment: Environment) => unknown): {
9
9
  disconnect: () => void;
@@ -12,6 +12,10 @@ type Host$1<Environment = unknown> = {
12
12
  }>;
13
13
  };
14
14
  environment?: Environment;
15
+ /**
16
+ * Optional name of the environment, use for logging
17
+ */
18
+ name?: string;
15
19
  /**
16
20
  * Optional bast url to use for API requests, for example `www.wixapis.com`
17
21
  */
@@ -36,92 +40,92 @@ type Host$1<Environment = unknown> = {
36
40
  };
37
41
  };
38
42
 
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>>;
43
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
44
+ interface HttpClient {
45
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
42
46
  fetchWithAuth: typeof fetch;
43
47
  wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
44
48
  getActiveToken?: () => string | undefined;
45
49
  }
46
- type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
47
- type HttpResponse$1<T = any> = {
50
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
51
+ type HttpResponse<T = any> = {
48
52
  data: T;
49
53
  status: number;
50
54
  statusText: string;
51
55
  headers: any;
52
56
  request?: any;
53
57
  };
54
- type RequestOptions$1<_TResponse = any, Data = any> = {
58
+ type RequestOptions<_TResponse = any, Data = any> = {
55
59
  method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
56
60
  url: string;
57
61
  data?: Data;
58
62
  params?: URLSearchParams;
59
- } & APIMetadata$1;
60
- type APIMetadata$1 = {
63
+ } & APIMetadata;
64
+ type APIMetadata = {
61
65
  methodFqn?: string;
62
66
  entityFqdn?: string;
63
67
  packageName?: string;
64
68
  };
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> = {
69
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
70
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
67
71
  __type: 'event-definition';
68
72
  type: Type;
69
73
  isDomainEvent?: boolean;
70
74
  transformations?: (envelope: unknown) => Payload;
71
75
  __payload: Payload;
72
76
  };
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;
77
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
78
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
79
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
76
80
 
77
- type ServicePluginMethodInput$1 = {
81
+ type ServicePluginMethodInput = {
78
82
  request: any;
79
83
  metadata: any;
80
84
  };
81
- type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
82
- type ServicePluginMethodMetadata$1 = {
85
+ type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
86
+ type ServicePluginMethodMetadata = {
83
87
  name: string;
84
88
  primaryHttpMappingPath: string;
85
89
  transformations: {
86
- fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
90
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput;
87
91
  toREST: (...args: unknown[]) => unknown;
88
92
  };
89
93
  };
90
- type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
94
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
91
95
  __type: 'service-plugin-definition';
92
96
  componentType: string;
93
- methods: ServicePluginMethodMetadata$1[];
97
+ methods: ServicePluginMethodMetadata[];
94
98
  __contract: Contract;
95
99
  };
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";
100
+ declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
101
+ type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
102
+ declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
99
103
 
100
- type RequestContext$1 = {
104
+ type RequestContext = {
101
105
  isSSR: boolean;
102
106
  host: string;
103
107
  protocol?: string;
104
108
  };
105
- type ResponseTransformer$1 = (data: any, headers?: any) => any;
109
+ type ResponseTransformer = (data: any, headers?: any) => any;
106
110
  /**
107
111
  * Ambassador request options types are copied mostly from AxiosRequestConfig.
108
112
  * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
109
113
  * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
110
114
  */
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> = {
115
+ type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
116
+ type AmbassadorRequestOptions<T = any> = {
113
117
  _?: T;
114
118
  url?: string;
115
- method?: Method$1;
119
+ method?: Method;
116
120
  params?: any;
117
121
  data?: any;
118
- transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
122
+ transformResponse?: ResponseTransformer | ResponseTransformer[];
119
123
  };
120
- type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
124
+ type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
121
125
  __isAmbassador: boolean;
122
126
  };
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;
127
+ type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
128
+ type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
125
129
 
126
130
  declare global {
127
131
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
@@ -130,7 +134,7 @@ declare global {
130
134
  }
131
135
  }
132
136
 
133
- declare const emptyObjectSymbol$1: unique symbol;
137
+ declare const emptyObjectSymbol: unique symbol;
134
138
 
135
139
  /**
136
140
  Represents a strictly empty plain object, the `{}` value.
@@ -158,7 +162,7 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
158
162
 
159
163
  @category Object
160
164
  */
161
- type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
165
+ type EmptyObject = {[emptyObjectSymbol]?: never};
162
166
 
163
167
  /**
164
168
  Returns a boolean for whether the two given types are equal.
@@ -186,7 +190,7 @@ type Includes<Value extends readonly any[], Item> =
186
190
  @category Type Guard
187
191
  @category Utilities
188
192
  */
189
- type IsEqual$1<A, B> =
193
+ type IsEqual<A, B> =
190
194
  (<G>() => G extends A ? 1 : 2) extends
191
195
  (<G>() => G extends B ? 1 : 2)
192
196
  ? true
@@ -219,9 +223,9 @@ type Filtered = Filter<'bar', 'foo'>;
219
223
 
220
224
  @see {Except}
221
225
  */
222
- type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
226
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
223
227
 
224
- type ExceptOptions$1 = {
228
+ type ExceptOptions = {
225
229
  /**
226
230
  Disallow assigning non-specified properties.
227
231
 
@@ -265,12 +269,78 @@ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
265
269
 
266
270
  @category Object
267
271
  */
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];
272
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
273
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
270
274
  } & (Options['requireExactProps'] extends true
271
275
  ? Partial<Record<KeysType, never>>
272
276
  : {});
273
277
 
278
+ /**
279
+ Returns a boolean for whether the given type is `never`.
280
+
281
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
282
+ @link https://stackoverflow.com/a/53984913/10292952
283
+ @link https://www.zhenghao.io/posts/ts-never
284
+
285
+ Useful in type utilities, such as checking if something does not occur.
286
+
287
+ @example
288
+ ```
289
+ import type {IsNever, And} from 'type-fest';
290
+
291
+ // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
292
+ type AreStringsEqual<A extends string, B extends string> =
293
+ And<
294
+ IsNever<Exclude<A, B>> extends true ? true : false,
295
+ IsNever<Exclude<B, A>> extends true ? true : false
296
+ >;
297
+
298
+ type EndIfEqual<I extends string, O extends string> =
299
+ AreStringsEqual<I, O> extends true
300
+ ? never
301
+ : void;
302
+
303
+ function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
304
+ if (input === output) {
305
+ process.exit(0);
306
+ }
307
+ }
308
+
309
+ endIfEqual('abc', 'abc');
310
+ //=> never
311
+
312
+ endIfEqual('abc', '123');
313
+ //=> void
314
+ ```
315
+
316
+ @category Type Guard
317
+ @category Utilities
318
+ */
319
+ type IsNever<T> = [T] extends [never] ? true : false;
320
+
321
+ /**
322
+ An if-else-like type that resolves depending on whether the given type is `never`.
323
+
324
+ @see {@link IsNever}
325
+
326
+ @example
327
+ ```
328
+ import type {IfNever} from 'type-fest';
329
+
330
+ type ShouldBeTrue = IfNever<never>;
331
+ //=> true
332
+
333
+ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
334
+ //=> 'bar'
335
+ ```
336
+
337
+ @category Type Guard
338
+ @category Utilities
339
+ */
340
+ type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
341
+ IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
342
+ );
343
+
274
344
  /**
275
345
  Extract the keys from a type where the value type of the key extends the given `Condition`.
276
346
 
@@ -303,21 +373,19 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
303
373
 
304
374
  @category Object
305
375
  */
306
- type ConditionalKeys$1<Base, Condition> = NonNullable<
307
- // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
376
+ type ConditionalKeys<Base, Condition> =
308
377
  {
309
378
  // Map through all the keys of the given base type.
310
- [Key in keyof Base]:
379
+ [Key in keyof Base]-?:
311
380
  // Pick only keys with types extending the given `Condition` type.
312
381
  Base[Key] extends Condition
313
- // Retain this key since the condition passes.
314
- ? Key
382
+ // Retain this key
383
+ // If the value for the key extends never, only include it if `Condition` also extends never
384
+ ? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
315
385
  // Discard this key since the condition fails.
316
386
  : never;
317
-
318
387
  // Convert the produced object into a union type of the keys which passed the conditional test.
319
- }[keyof Base]
320
- >;
388
+ }[keyof Base];
321
389
 
322
390
  /**
323
391
  Exclude keys from a shape that matches the given `Condition`.
@@ -357,9 +425,9 @@ type NonStringKeysOnly = ConditionalExcept<Example, string>;
357
425
 
358
426
  @category Object
359
427
  */
360
- type ConditionalExcept$1<Base, Condition> = Except$1<
428
+ type ConditionalExcept<Base, Condition> = Except<
361
429
  Base,
362
- ConditionalKeys$1<Base, Condition>
430
+ ConditionalKeys<Base, Condition>
363
431
  >;
364
432
 
365
433
  /**
@@ -367,8 +435,8 @@ ConditionalKeys$1<Base, Condition>
367
435
  * can either be a REST module or a host module.
368
436
  * This type is recursive, so it can describe nested modules.
369
437
  */
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;
438
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
439
+ [key: string]: Descriptors | PublicMetadata | any;
372
440
  };
373
441
  /**
374
442
  * This type takes in a descriptors object of a certain Host (including an `unknown` host)
@@ -376,12 +444,12 @@ type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 |
376
444
  * Any non-descriptor properties are removed from the returned object, including descriptors that
377
445
  * do not match the given host (as they will not work with the given host).
378
446
  */
379
- type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
447
+ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
380
448
  done: T;
381
449
  recurse: T extends {
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, [
450
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
451
+ } ? 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<{
452
+ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
385
453
  -1,
386
454
  0,
387
455
  1,
@@ -390,9 +458,9 @@ type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefin
390
458
  4,
391
459
  5
392
460
  ][Depth]> : never;
393
- }, EmptyObject$1>;
461
+ }, EmptyObject>;
394
462
  }[Depth extends -1 ? 'done' : 'recurse'];
395
- type PublicMetadata$1 = {
463
+ type PublicMetadata = {
396
464
  PACKAGE_NAME?: string;
397
465
  };
398
466
 
@@ -404,9 +472,9 @@ declare global {
404
472
  * A type used to create concerete types from SDK descriptors in
405
473
  * case a contextual client is available.
406
474
  */
407
- type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
408
- host: Host$1;
409
- } ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
475
+ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
476
+ host: Host;
477
+ } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
410
478
 
411
479
  interface SiteDocument$1 {
412
480
  /**
@@ -708,7 +776,7 @@ interface SearchOptions$1 {
708
776
  language?: string | null;
709
777
  }
710
778
 
711
- declare function search$3(httpClient: HttpClient$1): SearchSignature$1;
779
+ declare function search$3(httpClient: HttpClient): SearchSignature$1;
712
780
  interface SearchSignature$1 {
713
781
  /**
714
782
  * Retrieves a list of site documents that match the provided search query and optionally performs aggregations on the data queried.
@@ -722,7 +790,7 @@ interface SearchSignature$1 {
722
790
  (search: Search, documentType: DocumentType, options?: SearchOptions$1 | undefined): Promise<SearchResponse$1 & SearchResponseNonNullableFields$1>;
723
791
  }
724
792
 
725
- declare const search$2: MaybeContext$1<BuildRESTFunction$1<typeof search$3> & typeof search$3>;
793
+ declare const search$2: MaybeContext<BuildRESTFunction<typeof search$3> & typeof search$3>;
726
794
 
727
795
  type index_d$1_AggregationData = AggregationData;
728
796
  type index_d$1_AggregationKindOneOf = AggregationKindOneOf;
@@ -763,416 +831,6 @@ declare namespace index_d$1 {
763
831
  export { type Aggregation$1 as Aggregation, type index_d$1_AggregationData as AggregationData, type index_d$1_AggregationKindOneOf as AggregationKindOneOf, type index_d$1_AggregationResults as AggregationResults, type index_d$1_AggregationResultsResultOneOf as AggregationResultsResultOneOf, type index_d$1_AggregationResultsScalarResult as AggregationResultsScalarResult, index_d$1_AggregationType as AggregationType, index_d$1_DocumentType as DocumentType, type index_d$1_NestedAggregation as NestedAggregation, type index_d$1_NestedAggregationItem as NestedAggregationItem, type index_d$1_NestedAggregationItemKindOneOf as NestedAggregationItemKindOneOf, index_d$1_NestedAggregationType as NestedAggregationType, type index_d$1_NestedResultValue as NestedResultValue, type index_d$1_NestedResultValueResultOneOf as NestedResultValueResultOneOf, type index_d$1_NestedResults as NestedResults, type index_d$1_Paging as Paging, type index_d$1_PagingMetadata as PagingMetadata, type index_d$1_Results as Results, type index_d$1_ScalarAggregation as ScalarAggregation, type index_d$1_ScalarResult as ScalarResult, index_d$1_ScalarType as ScalarType, type index_d$1_Search as Search, type index_d$1_SearchDetails as SearchDetails, type SearchOptions$1 as SearchOptions, type index_d$1_SearchPagingMethodOneOf as SearchPagingMethodOneOf, type SearchRequest$1 as SearchRequest, type SearchResponse$1 as SearchResponse, type SearchResponseNonNullableFields$1 as SearchResponseNonNullableFields, type index_d$1_SearchResponsePagingOneOf as SearchResponsePagingOneOf, type SiteDocument$1 as SiteDocument, index_d$1_SortOrder as SortOrder, type index_d$1_Sorting as Sorting, type index_d$1_ValueAggregation as ValueAggregation, type index_d$1_ValueAggregationResult as ValueAggregationResult, type index_d$1_ValueResult as ValueResult, type index_d$1_ValueResults as ValueResults, search$2 as search };
764
832
  }
765
833
 
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
-
1176
834
  /** API is not yet fully migrated to FQDN entity */
1177
835
  interface SiteDocument {
1178
836
  /** the document payload */
@@ -1210,7 +868,7 @@ interface UpdateInternalDocumentsEvent extends UpdateInternalDocumentsEventOpera
1210
868
  /** id to pass to processing notification */
1211
869
  correlationId?: string | null;
1212
870
  /** when event was created / issued */
1213
- issuedAt?: Date;
871
+ issuedAt?: Date | null;
1214
872
  }
1215
873
  /** @oneof */
1216
874
  interface UpdateInternalDocumentsEventOperationOneOf {
@@ -1762,6 +1420,8 @@ interface TrendingRequest {
1762
1420
  language?: string | null;
1763
1421
  /** Include seo hidden documents. Defaults to false if not provided. */
1764
1422
  includeSeoHidden?: boolean | null;
1423
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1424
+ properties?: SearchProperty[];
1765
1425
  }
1766
1426
  interface TrendingResponse {
1767
1427
  results?: TrendingItems[];
@@ -1983,6 +1643,8 @@ interface TrendingOptions {
1983
1643
  language?: string | null;
1984
1644
  /** Include seo hidden documents. Defaults to false if not provided. */
1985
1645
  includeSeoHidden?: boolean | null;
1646
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1647
+ properties?: SearchProperty[];
1986
1648
  }
1987
1649
 
1988
1650
  declare function search$1(httpClient: HttpClient): SearchSignature;