@wix/search 1.0.41 → 1.0.43

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.
@@ -26,3 +26,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.siteSearch = exports.wixSiteSearch = void 0;
27
27
  exports.wixSiteSearch = __importStar(require("@wix/search_wix-site-search/context"));
28
28
  exports.siteSearch = __importStar(require("@wix/search_site-search/context"));
29
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAqE;AACrE,8EAA8D"}
@@ -28,3 +28,4 @@ const wixSiteSearch = __importStar(require("@wix/search_wix-site-search"));
28
28
  exports.wixSiteSearch = wixSiteSearch;
29
29
  const siteSearch = __importStar(require("@wix/search_site-search"));
30
30
  exports.siteSearch = siteSearch;
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAA6D;AAGpD,sCAAa;AAFtB,oEAAsD;AAE9B,gCAAU"}
package/build/cjs/meta.js CHANGED
@@ -26,3 +26,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.siteSearch = exports.wixSiteSearch = void 0;
27
27
  exports.wixSiteSearch = __importStar(require("@wix/search_wix-site-search/meta"));
28
28
  exports.siteSearch = __importStar(require("@wix/search_site-search/meta"));
29
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../meta.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kFAAkE;AAClE,2EAA2D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/search",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -18,8 +18,8 @@
18
18
  "type-bundles"
19
19
  ],
20
20
  "dependencies": {
21
- "@wix/search_site-search": "1.0.26",
22
- "@wix/search_wix-site-search": "1.0.18"
21
+ "@wix/search_site-search": "1.0.28",
22
+ "@wix/search_wix-site-search": "1.0.20"
23
23
  },
24
24
  "devDependencies": {
25
25
  "glob": "^10.4.1",
@@ -44,5 +44,5 @@
44
44
  "fqdn": ""
45
45
  }
46
46
  },
47
- "falconPackageHash": "b498e91bce583d0721228cf057213cccf54c898da4c3b53a53028527"
47
+ "falconPackageHash": "bb418f4be5dfcd9cb89b029f462209b98cb9a5e8c303afb82a37750c"
48
48
  }
@@ -1,29 +1,127 @@
1
- type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
2
- interface HttpClient$1 {
3
- request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
1
+ type HostModule<T, H extends Host> = {
2
+ __type: 'host';
3
+ create(host: H): T;
4
+ };
5
+ type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
6
+ type Host<Environment = unknown> = {
7
+ channel: {
8
+ observeState(callback: (props: unknown, environment: Environment) => unknown): {
9
+ disconnect: () => void;
10
+ } | Promise<{
11
+ disconnect: () => void;
12
+ }>;
13
+ };
14
+ environment?: Environment;
15
+ /**
16
+ * Optional bast url to use for API requests, for example `www.wixapis.com`
17
+ */
18
+ apiBaseUrl?: string;
19
+ /**
20
+ * Possible data to be provided by every host, for cross cutting concerns
21
+ * like internationalization, billing, etc.
22
+ */
23
+ essentials?: {
24
+ /**
25
+ * The language of the currently viewed session
26
+ */
27
+ language?: string;
28
+ /**
29
+ * The locale of the currently viewed session
30
+ */
31
+ locale?: string;
32
+ /**
33
+ * Any headers that should be passed through to the API requests
34
+ */
35
+ passThroughHeaders?: Record<string, string>;
36
+ };
37
+ };
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>>;
4
42
  fetchWithAuth: typeof fetch;
5
43
  wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
44
+ getActiveToken?: () => string | undefined;
6
45
  }
7
- type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
8
- type HttpResponse$1<T = any> = {
46
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
47
+ type HttpResponse<T = any> = {
9
48
  data: T;
10
49
  status: number;
11
50
  statusText: string;
12
51
  headers: any;
13
52
  request?: any;
14
53
  };
15
- type RequestOptions$1<_TResponse = any, Data = any> = {
54
+ type RequestOptions<_TResponse = any, Data = any> = {
16
55
  method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
17
56
  url: string;
18
57
  data?: Data;
19
58
  params?: URLSearchParams;
20
- } & APIMetadata$1;
21
- type APIMetadata$1 = {
59
+ } & APIMetadata;
60
+ type APIMetadata = {
22
61
  methodFqn?: string;
23
62
  entityFqdn?: string;
24
63
  packageName?: string;
25
64
  };
26
- type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
65
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
66
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
67
+ __type: 'event-definition';
68
+ type: Type;
69
+ isDomainEvent?: boolean;
70
+ transformations?: (envelope: unknown) => Payload;
71
+ __payload: Payload;
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;
76
+
77
+ type ServicePluginMethodInput = {
78
+ request: any;
79
+ metadata: any;
80
+ };
81
+ type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
82
+ type ServicePluginMethodMetadata = {
83
+ name: string;
84
+ primaryHttpMappingPath: string;
85
+ transformations: {
86
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput;
87
+ toREST: (...args: unknown[]) => unknown;
88
+ };
89
+ };
90
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
91
+ __type: 'service-plugin-definition';
92
+ componentType: string;
93
+ methods: ServicePluginMethodMetadata[];
94
+ __contract: Contract;
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";
99
+
100
+ type RequestContext = {
101
+ isSSR: boolean;
102
+ host: string;
103
+ protocol?: string;
104
+ };
105
+ type ResponseTransformer = (data: any, headers?: any) => any;
106
+ /**
107
+ * Ambassador request options types are copied mostly from AxiosRequestConfig.
108
+ * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
109
+ * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
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> = {
113
+ _?: T;
114
+ url?: string;
115
+ method?: Method;
116
+ params?: any;
117
+ data?: any;
118
+ transformResponse?: ResponseTransformer | ResponseTransformer[];
119
+ };
120
+ type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
121
+ __isAmbassador: boolean;
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;
27
125
 
28
126
  declare global {
29
127
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
@@ -32,6 +130,284 @@ declare global {
32
130
  }
33
131
  }
34
132
 
133
+ declare const emptyObjectSymbol: unique symbol;
134
+
135
+ /**
136
+ Represents a strictly empty plain object, the `{}` value.
137
+
138
+ 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)).
139
+
140
+ @example
141
+ ```
142
+ import type {EmptyObject} from 'type-fest';
143
+
144
+ // The following illustrates the problem with `{}`.
145
+ const foo1: {} = {}; // Pass
146
+ const foo2: {} = []; // Pass
147
+ const foo3: {} = 42; // Pass
148
+ const foo4: {} = {a: 1}; // Pass
149
+
150
+ // With `EmptyObject` only the first case is valid.
151
+ const bar1: EmptyObject = {}; // Pass
152
+ const bar2: EmptyObject = 42; // Fail
153
+ const bar3: EmptyObject = []; // Fail
154
+ const bar4: EmptyObject = {a: 1}; // Fail
155
+ ```
156
+
157
+ 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}.
158
+
159
+ @category Object
160
+ */
161
+ type EmptyObject = {[emptyObjectSymbol]?: never};
162
+
163
+ /**
164
+ Returns a boolean for whether the two given types are equal.
165
+
166
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
167
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
168
+
169
+ Use-cases:
170
+ - If you want to make a conditional branch based on the result of a comparison of two types.
171
+
172
+ @example
173
+ ```
174
+ import type {IsEqual} from 'type-fest';
175
+
176
+ // This type returns a boolean for whether the given array includes the given item.
177
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
178
+ type Includes<Value extends readonly any[], Item> =
179
+ Value extends readonly [Value[0], ...infer rest]
180
+ ? IsEqual<Value[0], Item> extends true
181
+ ? true
182
+ : Includes<rest, Item>
183
+ : false;
184
+ ```
185
+
186
+ @category Type Guard
187
+ @category Utilities
188
+ */
189
+ type IsEqual<A, B> =
190
+ (<G>() => G extends A ? 1 : 2) extends
191
+ (<G>() => G extends B ? 1 : 2)
192
+ ? true
193
+ : false;
194
+
195
+ /**
196
+ Filter out keys from an object.
197
+
198
+ Returns `never` if `Exclude` is strictly equal to `Key`.
199
+ Returns `never` if `Key` extends `Exclude`.
200
+ Returns `Key` otherwise.
201
+
202
+ @example
203
+ ```
204
+ type Filtered = Filter<'foo', 'foo'>;
205
+ //=> never
206
+ ```
207
+
208
+ @example
209
+ ```
210
+ type Filtered = Filter<'bar', string>;
211
+ //=> never
212
+ ```
213
+
214
+ @example
215
+ ```
216
+ type Filtered = Filter<'bar', 'foo'>;
217
+ //=> 'bar'
218
+ ```
219
+
220
+ @see {Except}
221
+ */
222
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
223
+
224
+ type ExceptOptions = {
225
+ /**
226
+ Disallow assigning non-specified properties.
227
+
228
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
229
+
230
+ @default false
231
+ */
232
+ requireExactProps?: boolean;
233
+ };
234
+
235
+ /**
236
+ Create a type from an object type without certain keys.
237
+
238
+ We recommend setting the `requireExactProps` option to `true`.
239
+
240
+ 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.
241
+
242
+ 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)).
243
+
244
+ @example
245
+ ```
246
+ import type {Except} from 'type-fest';
247
+
248
+ type Foo = {
249
+ a: number;
250
+ b: string;
251
+ };
252
+
253
+ type FooWithoutA = Except<Foo, 'a'>;
254
+ //=> {b: string}
255
+
256
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
257
+ //=> errors: 'a' does not exist in type '{ b: string; }'
258
+
259
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
260
+ //=> {a: number} & Partial<Record<"b", never>>
261
+
262
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
263
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
264
+ ```
265
+
266
+ @category Object
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];
270
+ } & (Options['requireExactProps'] extends true
271
+ ? Partial<Record<KeysType, never>>
272
+ : {});
273
+
274
+ /**
275
+ Extract the keys from a type where the value type of the key extends the given `Condition`.
276
+
277
+ Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
278
+
279
+ @example
280
+ ```
281
+ import type {ConditionalKeys} from 'type-fest';
282
+
283
+ interface Example {
284
+ a: string;
285
+ b: string | number;
286
+ c?: string;
287
+ d: {};
288
+ }
289
+
290
+ type StringKeysOnly = ConditionalKeys<Example, string>;
291
+ //=> 'a'
292
+ ```
293
+
294
+ To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
295
+
296
+ @example
297
+ ```
298
+ import type {ConditionalKeys} from 'type-fest';
299
+
300
+ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
301
+ //=> 'a' | 'c'
302
+ ```
303
+
304
+ @category Object
305
+ */
306
+ type ConditionalKeys<Base, Condition> = NonNullable<
307
+ // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
308
+ {
309
+ // Map through all the keys of the given base type.
310
+ [Key in keyof Base]:
311
+ // Pick only keys with types extending the given `Condition` type.
312
+ Base[Key] extends Condition
313
+ // Retain this key since the condition passes.
314
+ ? Key
315
+ // Discard this key since the condition fails.
316
+ : never;
317
+
318
+ // Convert the produced object into a union type of the keys which passed the conditional test.
319
+ }[keyof Base]
320
+ >;
321
+
322
+ /**
323
+ Exclude keys from a shape that matches the given `Condition`.
324
+
325
+ 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.
326
+
327
+ @example
328
+ ```
329
+ import type {Primitive, ConditionalExcept} from 'type-fest';
330
+
331
+ class Awesome {
332
+ name: string;
333
+ successes: number;
334
+ failures: bigint;
335
+
336
+ run() {}
337
+ }
338
+
339
+ type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
340
+ //=> {run: () => void}
341
+ ```
342
+
343
+ @example
344
+ ```
345
+ import type {ConditionalExcept} from 'type-fest';
346
+
347
+ interface Example {
348
+ a: string;
349
+ b: string | number;
350
+ c: () => void;
351
+ d: {};
352
+ }
353
+
354
+ type NonStringKeysOnly = ConditionalExcept<Example, string>;
355
+ //=> {b: string | number; c: () => void; d: {}}
356
+ ```
357
+
358
+ @category Object
359
+ */
360
+ type ConditionalExcept<Base, Condition> = Except<
361
+ Base,
362
+ ConditionalKeys<Base, Condition>
363
+ >;
364
+
365
+ /**
366
+ * Descriptors are objects that describe the API of a module, and the module
367
+ * can either be a REST module or a host module.
368
+ * This type is recursive, so it can describe nested modules.
369
+ */
370
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
371
+ [key: string]: Descriptors | PublicMetadata | any;
372
+ };
373
+ /**
374
+ * This type takes in a descriptors object of a certain Host (including an `unknown` host)
375
+ * and returns an object with the same structure, but with all descriptors replaced with their API.
376
+ * Any non-descriptor properties are removed from the returned object, including descriptors that
377
+ * do not match the given host (as they will not work with the given host).
378
+ */
379
+ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
380
+ done: T;
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, [
385
+ -1,
386
+ 0,
387
+ 1,
388
+ 2,
389
+ 3,
390
+ 4,
391
+ 5
392
+ ][Depth]> : never;
393
+ }, EmptyObject>;
394
+ }[Depth extends -1 ? 'done' : 'recurse'];
395
+ type PublicMetadata = {
396
+ PACKAGE_NAME?: string;
397
+ };
398
+
399
+ declare global {
400
+ interface ContextualClient {
401
+ }
402
+ }
403
+ /**
404
+ * A type used to create concerete types from SDK descriptors in
405
+ * case a contextual client is available.
406
+ */
407
+ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
408
+ host: Host;
409
+ } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
410
+
35
411
  interface SiteDocument$1 {
36
412
  /**
37
413
  * Result ID.
@@ -332,7 +708,7 @@ interface SearchOptions$1 {
332
708
  language?: string | null;
333
709
  }
334
710
 
335
- declare function search$3(httpClient: HttpClient$1): SearchSignature$1;
711
+ declare function search$3(httpClient: HttpClient): SearchSignature$1;
336
712
  interface SearchSignature$1 {
337
713
  /**
338
714
  * Retrieves a list of site documents that match the provided search query and optionally performs aggregations on the data queried.
@@ -346,7 +722,7 @@ interface SearchSignature$1 {
346
722
  (search: Search, documentType: DocumentType, options?: SearchOptions$1 | undefined): Promise<SearchResponse$1 & SearchResponseNonNullableFields$1>;
347
723
  }
348
724
 
349
- declare const search$2: BuildRESTFunction$1<typeof search$3> & typeof search$3;
725
+ declare const search$2: MaybeContext<BuildRESTFunction<typeof search$3> & typeof search$3>;
350
726
 
351
727
  type context$1_AggregationData = AggregationData;
352
728
  type context$1_AggregationKindOneOf = AggregationKindOneOf;
@@ -387,40 +763,6 @@ declare namespace context$1 {
387
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 };
388
764
  }
389
765
 
390
- type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
391
- interface HttpClient {
392
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
393
- fetchWithAuth: typeof fetch;
394
- wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
395
- }
396
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
397
- type HttpResponse<T = any> = {
398
- data: T;
399
- status: number;
400
- statusText: string;
401
- headers: any;
402
- request?: any;
403
- };
404
- type RequestOptions<_TResponse = any, Data = any> = {
405
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
406
- url: string;
407
- data?: Data;
408
- params?: URLSearchParams;
409
- } & APIMetadata;
410
- type APIMetadata = {
411
- methodFqn?: string;
412
- entityFqdn?: string;
413
- packageName?: string;
414
- };
415
- type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
416
-
417
- declare global {
418
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
419
- interface SymbolConstructor {
420
- readonly observable: symbol;
421
- }
422
- }
423
-
424
766
  /** API is not yet fully migrated to FQDN entity */
425
767
  interface SiteDocument {
426
768
  /** the document payload */
@@ -457,6 +799,8 @@ interface UpdateInternalDocumentsEvent extends UpdateInternalDocumentsEventOpera
457
799
  removeDocumentIds?: string[];
458
800
  /** id to pass to processing notification */
459
801
  correlationId?: string | null;
802
+ /** when event was created / issued */
803
+ issuedAt?: Date;
460
804
  }
461
805
  /** @oneof */
462
806
  interface UpdateInternalDocumentsEventOperationOneOf {
@@ -689,7 +1033,7 @@ interface SearchRequest {
689
1033
  searchFields?: string[];
690
1034
  /** A list of fields to include in the result set. If not provided, all fields of schema will be included. */
691
1035
  fields?: string[];
692
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1036
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
693
1037
  properties?: SearchProperty[];
694
1038
  /** Include seo hidden documents. Defaults to false if not provided. */
695
1039
  includeSeoHidden?: boolean | null;
@@ -862,6 +1206,8 @@ interface FederatedSearchRequest {
862
1206
  documentTypes?: string[];
863
1207
  /** Include seo hidden documents. Defaults to false if not provided. */
864
1208
  includeSeoHidden?: boolean | null;
1209
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1210
+ properties?: SearchProperty[];
865
1211
  }
866
1212
  interface FederatedSearchResponse {
867
1213
  /** Search results from multiple indexes. */
@@ -894,7 +1240,7 @@ interface SuggestRequest {
894
1240
  fields?: string[];
895
1241
  /** Include seo hidden documents. Defaults to false if not provided. */
896
1242
  includeSeoHidden?: boolean | null;
897
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1243
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
898
1244
  properties?: SearchProperty[];
899
1245
  }
900
1246
  interface SuggestResponse {
@@ -914,6 +1260,8 @@ interface FederatedSuggestRequest {
914
1260
  documentTypes?: string[];
915
1261
  /** Include seo hidden documents. Defaults to false if not provided. */
916
1262
  includeSeoHidden?: boolean | null;
1263
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1264
+ properties?: SearchProperty[];
917
1265
  }
918
1266
  interface FederatedSuggestResponse {
919
1267
  /** Suggest results from multiple indexes. */
@@ -1105,7 +1453,7 @@ interface SearchOptions {
1105
1453
  searchFields?: string[];
1106
1454
  /** A list of fields to include in the result set. If not provided, all fields of schema will be included. */
1107
1455
  fields?: string[];
1108
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1456
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1109
1457
  properties?: SearchProperty[];
1110
1458
  /** Include seo hidden documents. Defaults to false if not provided. */
1111
1459
  includeSeoHidden?: boolean | null;
@@ -1127,6 +1475,8 @@ interface FederatedSearchOptions {
1127
1475
  documentTypes?: string[];
1128
1476
  /** Include seo hidden documents. Defaults to false if not provided. */
1129
1477
  includeSeoHidden?: boolean | null;
1478
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1479
+ properties?: SearchProperty[];
1130
1480
  }
1131
1481
  interface SuggestOptions {
1132
1482
  /** Text to search for. Fields configured in suggester configuration will be searched. */
@@ -1147,7 +1497,7 @@ interface SuggestOptions {
1147
1497
  fields?: string[];
1148
1498
  /** Include seo hidden documents. Defaults to false if not provided. */
1149
1499
  includeSeoHidden?: boolean | null;
1150
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1500
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1151
1501
  properties?: SearchProperty[];
1152
1502
  }
1153
1503
  interface FederatedSuggestOptions {
@@ -1163,6 +1513,8 @@ interface FederatedSuggestOptions {
1163
1513
  documentTypes?: string[];
1164
1514
  /** Include seo hidden documents. Defaults to false if not provided. */
1165
1515
  includeSeoHidden?: boolean | null;
1516
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1517
+ properties?: SearchProperty[];
1166
1518
  }
1167
1519
  interface RelatedOptions {
1168
1520
  /** ID of the document to fetch related documents for. */
@@ -1286,14 +1638,14 @@ interface TrendingSignature {
1286
1638
  (options?: TrendingOptions | undefined): Promise<TrendingResponse & TrendingResponseNonNullableFields>;
1287
1639
  }
1288
1640
 
1289
- declare const search: BuildRESTFunction<typeof search$1> & typeof search$1;
1290
- declare const federatedSearch: BuildRESTFunction<typeof federatedSearch$1> & typeof federatedSearch$1;
1291
- declare const suggest: BuildRESTFunction<typeof suggest$1> & typeof suggest$1;
1292
- declare const federatedSuggest: BuildRESTFunction<typeof federatedSuggest$1> & typeof federatedSuggest$1;
1293
- declare const related: BuildRESTFunction<typeof related$1> & typeof related$1;
1294
- declare const autocomplete: BuildRESTFunction<typeof autocomplete$1> & typeof autocomplete$1;
1295
- declare const federatedAutocomplete: BuildRESTFunction<typeof federatedAutocomplete$1> & typeof federatedAutocomplete$1;
1296
- declare const trending: BuildRESTFunction<typeof trending$1> & typeof trending$1;
1641
+ declare const search: MaybeContext<BuildRESTFunction<typeof search$1> & typeof search$1>;
1642
+ declare const federatedSearch: MaybeContext<BuildRESTFunction<typeof federatedSearch$1> & typeof federatedSearch$1>;
1643
+ declare const suggest: MaybeContext<BuildRESTFunction<typeof suggest$1> & typeof suggest$1>;
1644
+ declare const federatedSuggest: MaybeContext<BuildRESTFunction<typeof federatedSuggest$1> & typeof federatedSuggest$1>;
1645
+ declare const related: MaybeContext<BuildRESTFunction<typeof related$1> & typeof related$1>;
1646
+ declare const autocomplete: MaybeContext<BuildRESTFunction<typeof autocomplete$1> & typeof autocomplete$1>;
1647
+ declare const federatedAutocomplete: MaybeContext<BuildRESTFunction<typeof federatedAutocomplete$1> & typeof federatedAutocomplete$1>;
1648
+ declare const trending: MaybeContext<BuildRESTFunction<typeof trending$1> & typeof trending$1>;
1297
1649
 
1298
1650
  type context_Aggregation = Aggregation;
1299
1651
  declare const context_Aggregation: typeof Aggregation;
@@ -1,29 +1,127 @@
1
- type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
2
- interface HttpClient$1 {
3
- request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
1
+ type HostModule<T, H extends Host> = {
2
+ __type: 'host';
3
+ create(host: H): T;
4
+ };
5
+ type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
6
+ type Host<Environment = unknown> = {
7
+ channel: {
8
+ observeState(callback: (props: unknown, environment: Environment) => unknown): {
9
+ disconnect: () => void;
10
+ } | Promise<{
11
+ disconnect: () => void;
12
+ }>;
13
+ };
14
+ environment?: Environment;
15
+ /**
16
+ * Optional bast url to use for API requests, for example `www.wixapis.com`
17
+ */
18
+ apiBaseUrl?: string;
19
+ /**
20
+ * Possible data to be provided by every host, for cross cutting concerns
21
+ * like internationalization, billing, etc.
22
+ */
23
+ essentials?: {
24
+ /**
25
+ * The language of the currently viewed session
26
+ */
27
+ language?: string;
28
+ /**
29
+ * The locale of the currently viewed session
30
+ */
31
+ locale?: string;
32
+ /**
33
+ * Any headers that should be passed through to the API requests
34
+ */
35
+ passThroughHeaders?: Record<string, string>;
36
+ };
37
+ };
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>>;
4
42
  fetchWithAuth: typeof fetch;
5
43
  wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
44
+ getActiveToken?: () => string | undefined;
6
45
  }
7
- type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
8
- type HttpResponse$1<T = any> = {
46
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
47
+ type HttpResponse<T = any> = {
9
48
  data: T;
10
49
  status: number;
11
50
  statusText: string;
12
51
  headers: any;
13
52
  request?: any;
14
53
  };
15
- type RequestOptions$1<_TResponse = any, Data = any> = {
54
+ type RequestOptions<_TResponse = any, Data = any> = {
16
55
  method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
17
56
  url: string;
18
57
  data?: Data;
19
58
  params?: URLSearchParams;
20
- } & APIMetadata$1;
21
- type APIMetadata$1 = {
59
+ } & APIMetadata;
60
+ type APIMetadata = {
22
61
  methodFqn?: string;
23
62
  entityFqdn?: string;
24
63
  packageName?: string;
25
64
  };
26
- type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
65
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
66
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
67
+ __type: 'event-definition';
68
+ type: Type;
69
+ isDomainEvent?: boolean;
70
+ transformations?: (envelope: unknown) => Payload;
71
+ __payload: Payload;
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;
76
+
77
+ type ServicePluginMethodInput = {
78
+ request: any;
79
+ metadata: any;
80
+ };
81
+ type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
82
+ type ServicePluginMethodMetadata = {
83
+ name: string;
84
+ primaryHttpMappingPath: string;
85
+ transformations: {
86
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput;
87
+ toREST: (...args: unknown[]) => unknown;
88
+ };
89
+ };
90
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
91
+ __type: 'service-plugin-definition';
92
+ componentType: string;
93
+ methods: ServicePluginMethodMetadata[];
94
+ __contract: Contract;
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";
99
+
100
+ type RequestContext = {
101
+ isSSR: boolean;
102
+ host: string;
103
+ protocol?: string;
104
+ };
105
+ type ResponseTransformer = (data: any, headers?: any) => any;
106
+ /**
107
+ * Ambassador request options types are copied mostly from AxiosRequestConfig.
108
+ * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
109
+ * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
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> = {
113
+ _?: T;
114
+ url?: string;
115
+ method?: Method;
116
+ params?: any;
117
+ data?: any;
118
+ transformResponse?: ResponseTransformer | ResponseTransformer[];
119
+ };
120
+ type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
121
+ __isAmbassador: boolean;
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;
27
125
 
28
126
  declare global {
29
127
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
@@ -32,6 +130,284 @@ declare global {
32
130
  }
33
131
  }
34
132
 
133
+ declare const emptyObjectSymbol: unique symbol;
134
+
135
+ /**
136
+ Represents a strictly empty plain object, the `{}` value.
137
+
138
+ 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)).
139
+
140
+ @example
141
+ ```
142
+ import type {EmptyObject} from 'type-fest';
143
+
144
+ // The following illustrates the problem with `{}`.
145
+ const foo1: {} = {}; // Pass
146
+ const foo2: {} = []; // Pass
147
+ const foo3: {} = 42; // Pass
148
+ const foo4: {} = {a: 1}; // Pass
149
+
150
+ // With `EmptyObject` only the first case is valid.
151
+ const bar1: EmptyObject = {}; // Pass
152
+ const bar2: EmptyObject = 42; // Fail
153
+ const bar3: EmptyObject = []; // Fail
154
+ const bar4: EmptyObject = {a: 1}; // Fail
155
+ ```
156
+
157
+ 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}.
158
+
159
+ @category Object
160
+ */
161
+ type EmptyObject = {[emptyObjectSymbol]?: never};
162
+
163
+ /**
164
+ Returns a boolean for whether the two given types are equal.
165
+
166
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
167
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
168
+
169
+ Use-cases:
170
+ - If you want to make a conditional branch based on the result of a comparison of two types.
171
+
172
+ @example
173
+ ```
174
+ import type {IsEqual} from 'type-fest';
175
+
176
+ // This type returns a boolean for whether the given array includes the given item.
177
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
178
+ type Includes<Value extends readonly any[], Item> =
179
+ Value extends readonly [Value[0], ...infer rest]
180
+ ? IsEqual<Value[0], Item> extends true
181
+ ? true
182
+ : Includes<rest, Item>
183
+ : false;
184
+ ```
185
+
186
+ @category Type Guard
187
+ @category Utilities
188
+ */
189
+ type IsEqual<A, B> =
190
+ (<G>() => G extends A ? 1 : 2) extends
191
+ (<G>() => G extends B ? 1 : 2)
192
+ ? true
193
+ : false;
194
+
195
+ /**
196
+ Filter out keys from an object.
197
+
198
+ Returns `never` if `Exclude` is strictly equal to `Key`.
199
+ Returns `never` if `Key` extends `Exclude`.
200
+ Returns `Key` otherwise.
201
+
202
+ @example
203
+ ```
204
+ type Filtered = Filter<'foo', 'foo'>;
205
+ //=> never
206
+ ```
207
+
208
+ @example
209
+ ```
210
+ type Filtered = Filter<'bar', string>;
211
+ //=> never
212
+ ```
213
+
214
+ @example
215
+ ```
216
+ type Filtered = Filter<'bar', 'foo'>;
217
+ //=> 'bar'
218
+ ```
219
+
220
+ @see {Except}
221
+ */
222
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
223
+
224
+ type ExceptOptions = {
225
+ /**
226
+ Disallow assigning non-specified properties.
227
+
228
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
229
+
230
+ @default false
231
+ */
232
+ requireExactProps?: boolean;
233
+ };
234
+
235
+ /**
236
+ Create a type from an object type without certain keys.
237
+
238
+ We recommend setting the `requireExactProps` option to `true`.
239
+
240
+ 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.
241
+
242
+ 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)).
243
+
244
+ @example
245
+ ```
246
+ import type {Except} from 'type-fest';
247
+
248
+ type Foo = {
249
+ a: number;
250
+ b: string;
251
+ };
252
+
253
+ type FooWithoutA = Except<Foo, 'a'>;
254
+ //=> {b: string}
255
+
256
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
257
+ //=> errors: 'a' does not exist in type '{ b: string; }'
258
+
259
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
260
+ //=> {a: number} & Partial<Record<"b", never>>
261
+
262
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
263
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
264
+ ```
265
+
266
+ @category Object
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];
270
+ } & (Options['requireExactProps'] extends true
271
+ ? Partial<Record<KeysType, never>>
272
+ : {});
273
+
274
+ /**
275
+ Extract the keys from a type where the value type of the key extends the given `Condition`.
276
+
277
+ Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
278
+
279
+ @example
280
+ ```
281
+ import type {ConditionalKeys} from 'type-fest';
282
+
283
+ interface Example {
284
+ a: string;
285
+ b: string | number;
286
+ c?: string;
287
+ d: {};
288
+ }
289
+
290
+ type StringKeysOnly = ConditionalKeys<Example, string>;
291
+ //=> 'a'
292
+ ```
293
+
294
+ To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
295
+
296
+ @example
297
+ ```
298
+ import type {ConditionalKeys} from 'type-fest';
299
+
300
+ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
301
+ //=> 'a' | 'c'
302
+ ```
303
+
304
+ @category Object
305
+ */
306
+ type ConditionalKeys<Base, Condition> = NonNullable<
307
+ // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
308
+ {
309
+ // Map through all the keys of the given base type.
310
+ [Key in keyof Base]:
311
+ // Pick only keys with types extending the given `Condition` type.
312
+ Base[Key] extends Condition
313
+ // Retain this key since the condition passes.
314
+ ? Key
315
+ // Discard this key since the condition fails.
316
+ : never;
317
+
318
+ // Convert the produced object into a union type of the keys which passed the conditional test.
319
+ }[keyof Base]
320
+ >;
321
+
322
+ /**
323
+ Exclude keys from a shape that matches the given `Condition`.
324
+
325
+ 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.
326
+
327
+ @example
328
+ ```
329
+ import type {Primitive, ConditionalExcept} from 'type-fest';
330
+
331
+ class Awesome {
332
+ name: string;
333
+ successes: number;
334
+ failures: bigint;
335
+
336
+ run() {}
337
+ }
338
+
339
+ type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
340
+ //=> {run: () => void}
341
+ ```
342
+
343
+ @example
344
+ ```
345
+ import type {ConditionalExcept} from 'type-fest';
346
+
347
+ interface Example {
348
+ a: string;
349
+ b: string | number;
350
+ c: () => void;
351
+ d: {};
352
+ }
353
+
354
+ type NonStringKeysOnly = ConditionalExcept<Example, string>;
355
+ //=> {b: string | number; c: () => void; d: {}}
356
+ ```
357
+
358
+ @category Object
359
+ */
360
+ type ConditionalExcept<Base, Condition> = Except<
361
+ Base,
362
+ ConditionalKeys<Base, Condition>
363
+ >;
364
+
365
+ /**
366
+ * Descriptors are objects that describe the API of a module, and the module
367
+ * can either be a REST module or a host module.
368
+ * This type is recursive, so it can describe nested modules.
369
+ */
370
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
371
+ [key: string]: Descriptors | PublicMetadata | any;
372
+ };
373
+ /**
374
+ * This type takes in a descriptors object of a certain Host (including an `unknown` host)
375
+ * and returns an object with the same structure, but with all descriptors replaced with their API.
376
+ * Any non-descriptor properties are removed from the returned object, including descriptors that
377
+ * do not match the given host (as they will not work with the given host).
378
+ */
379
+ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
380
+ done: T;
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, [
385
+ -1,
386
+ 0,
387
+ 1,
388
+ 2,
389
+ 3,
390
+ 4,
391
+ 5
392
+ ][Depth]> : never;
393
+ }, EmptyObject>;
394
+ }[Depth extends -1 ? 'done' : 'recurse'];
395
+ type PublicMetadata = {
396
+ PACKAGE_NAME?: string;
397
+ };
398
+
399
+ declare global {
400
+ interface ContextualClient {
401
+ }
402
+ }
403
+ /**
404
+ * A type used to create concerete types from SDK descriptors in
405
+ * case a contextual client is available.
406
+ */
407
+ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
408
+ host: Host;
409
+ } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
410
+
35
411
  interface SiteDocument$1 {
36
412
  /**
37
413
  * Result ID.
@@ -332,7 +708,7 @@ interface SearchOptions$1 {
332
708
  language?: string | null;
333
709
  }
334
710
 
335
- declare function search$3(httpClient: HttpClient$1): SearchSignature$1;
711
+ declare function search$3(httpClient: HttpClient): SearchSignature$1;
336
712
  interface SearchSignature$1 {
337
713
  /**
338
714
  * Retrieves a list of site documents that match the provided search query and optionally performs aggregations on the data queried.
@@ -346,7 +722,7 @@ interface SearchSignature$1 {
346
722
  (search: Search, documentType: DocumentType, options?: SearchOptions$1 | undefined): Promise<SearchResponse$1 & SearchResponseNonNullableFields$1>;
347
723
  }
348
724
 
349
- declare const search$2: BuildRESTFunction$1<typeof search$3> & typeof search$3;
725
+ declare const search$2: MaybeContext<BuildRESTFunction<typeof search$3> & typeof search$3>;
350
726
 
351
727
  type index_d$1_AggregationData = AggregationData;
352
728
  type index_d$1_AggregationKindOneOf = AggregationKindOneOf;
@@ -387,40 +763,6 @@ declare namespace index_d$1 {
387
763
  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 };
388
764
  }
389
765
 
390
- type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
391
- interface HttpClient {
392
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
393
- fetchWithAuth: typeof fetch;
394
- wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
395
- }
396
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
397
- type HttpResponse<T = any> = {
398
- data: T;
399
- status: number;
400
- statusText: string;
401
- headers: any;
402
- request?: any;
403
- };
404
- type RequestOptions<_TResponse = any, Data = any> = {
405
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
406
- url: string;
407
- data?: Data;
408
- params?: URLSearchParams;
409
- } & APIMetadata;
410
- type APIMetadata = {
411
- methodFqn?: string;
412
- entityFqdn?: string;
413
- packageName?: string;
414
- };
415
- type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
416
-
417
- declare global {
418
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
419
- interface SymbolConstructor {
420
- readonly observable: symbol;
421
- }
422
- }
423
-
424
766
  /** API is not yet fully migrated to FQDN entity */
425
767
  interface SiteDocument {
426
768
  /** the document payload */
@@ -457,6 +799,8 @@ interface UpdateInternalDocumentsEvent extends UpdateInternalDocumentsEventOpera
457
799
  removeDocumentIds?: string[];
458
800
  /** id to pass to processing notification */
459
801
  correlationId?: string | null;
802
+ /** when event was created / issued */
803
+ issuedAt?: Date;
460
804
  }
461
805
  /** @oneof */
462
806
  interface UpdateInternalDocumentsEventOperationOneOf {
@@ -689,7 +1033,7 @@ interface SearchRequest {
689
1033
  searchFields?: string[];
690
1034
  /** A list of fields to include in the result set. If not provided, all fields of schema will be included. */
691
1035
  fields?: string[];
692
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1036
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
693
1037
  properties?: SearchProperty[];
694
1038
  /** Include seo hidden documents. Defaults to false if not provided. */
695
1039
  includeSeoHidden?: boolean | null;
@@ -862,6 +1206,8 @@ interface FederatedSearchRequest {
862
1206
  documentTypes?: string[];
863
1207
  /** Include seo hidden documents. Defaults to false if not provided. */
864
1208
  includeSeoHidden?: boolean | null;
1209
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1210
+ properties?: SearchProperty[];
865
1211
  }
866
1212
  interface FederatedSearchResponse {
867
1213
  /** Search results from multiple indexes. */
@@ -894,7 +1240,7 @@ interface SuggestRequest {
894
1240
  fields?: string[];
895
1241
  /** Include seo hidden documents. Defaults to false if not provided. */
896
1242
  includeSeoHidden?: boolean | null;
897
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1243
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
898
1244
  properties?: SearchProperty[];
899
1245
  }
900
1246
  interface SuggestResponse {
@@ -914,6 +1260,8 @@ interface FederatedSuggestRequest {
914
1260
  documentTypes?: string[];
915
1261
  /** Include seo hidden documents. Defaults to false if not provided. */
916
1262
  includeSeoHidden?: boolean | null;
1263
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1264
+ properties?: SearchProperty[];
917
1265
  }
918
1266
  interface FederatedSuggestResponse {
919
1267
  /** Suggest results from multiple indexes. */
@@ -1105,7 +1453,7 @@ interface SearchOptions {
1105
1453
  searchFields?: string[];
1106
1454
  /** A list of fields to include in the result set. If not provided, all fields of schema will be included. */
1107
1455
  fields?: string[];
1108
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1456
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1109
1457
  properties?: SearchProperty[];
1110
1458
  /** Include seo hidden documents. Defaults to false if not provided. */
1111
1459
  includeSeoHidden?: boolean | null;
@@ -1127,6 +1475,8 @@ interface FederatedSearchOptions {
1127
1475
  documentTypes?: string[];
1128
1476
  /** Include seo hidden documents. Defaults to false if not provided. */
1129
1477
  includeSeoHidden?: boolean | null;
1478
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1479
+ properties?: SearchProperty[];
1130
1480
  }
1131
1481
  interface SuggestOptions {
1132
1482
  /** Text to search for. Fields configured in suggester configuration will be searched. */
@@ -1147,7 +1497,7 @@ interface SuggestOptions {
1147
1497
  fields?: string[];
1148
1498
  /** Include seo hidden documents. Defaults to false if not provided. */
1149
1499
  includeSeoHidden?: boolean | null;
1150
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1500
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1151
1501
  properties?: SearchProperty[];
1152
1502
  }
1153
1503
  interface FederatedSuggestOptions {
@@ -1163,6 +1513,8 @@ interface FederatedSuggestOptions {
1163
1513
  documentTypes?: string[];
1164
1514
  /** Include seo hidden documents. Defaults to false if not provided. */
1165
1515
  includeSeoHidden?: boolean | null;
1516
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1517
+ properties?: SearchProperty[];
1166
1518
  }
1167
1519
  interface RelatedOptions {
1168
1520
  /** ID of the document to fetch related documents for. */
@@ -1286,14 +1638,14 @@ interface TrendingSignature {
1286
1638
  (options?: TrendingOptions | undefined): Promise<TrendingResponse & TrendingResponseNonNullableFields>;
1287
1639
  }
1288
1640
 
1289
- declare const search: BuildRESTFunction<typeof search$1> & typeof search$1;
1290
- declare const federatedSearch: BuildRESTFunction<typeof federatedSearch$1> & typeof federatedSearch$1;
1291
- declare const suggest: BuildRESTFunction<typeof suggest$1> & typeof suggest$1;
1292
- declare const federatedSuggest: BuildRESTFunction<typeof federatedSuggest$1> & typeof federatedSuggest$1;
1293
- declare const related: BuildRESTFunction<typeof related$1> & typeof related$1;
1294
- declare const autocomplete: BuildRESTFunction<typeof autocomplete$1> & typeof autocomplete$1;
1295
- declare const federatedAutocomplete: BuildRESTFunction<typeof federatedAutocomplete$1> & typeof federatedAutocomplete$1;
1296
- declare const trending: BuildRESTFunction<typeof trending$1> & typeof trending$1;
1641
+ declare const search: MaybeContext<BuildRESTFunction<typeof search$1> & typeof search$1>;
1642
+ declare const federatedSearch: MaybeContext<BuildRESTFunction<typeof federatedSearch$1> & typeof federatedSearch$1>;
1643
+ declare const suggest: MaybeContext<BuildRESTFunction<typeof suggest$1> & typeof suggest$1>;
1644
+ declare const federatedSuggest: MaybeContext<BuildRESTFunction<typeof federatedSuggest$1> & typeof federatedSuggest$1>;
1645
+ declare const related: MaybeContext<BuildRESTFunction<typeof related$1> & typeof related$1>;
1646
+ declare const autocomplete: MaybeContext<BuildRESTFunction<typeof autocomplete$1> & typeof autocomplete$1>;
1647
+ declare const federatedAutocomplete: MaybeContext<BuildRESTFunction<typeof federatedAutocomplete$1> & typeof federatedAutocomplete$1>;
1648
+ declare const trending: MaybeContext<BuildRESTFunction<typeof trending$1> & typeof trending$1>;
1297
1649
 
1298
1650
  type index_d_Aggregation = Aggregation;
1299
1651
  declare const index_d_Aggregation: typeof Aggregation;
@@ -629,7 +629,7 @@ interface SearchRequest$1 {
629
629
  searchFields?: string[];
630
630
  /** A list of fields to include in the result set. If not provided, all fields of schema will be included. */
631
631
  fields?: string[];
632
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
632
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
633
633
  properties?: SearchProperty$1[];
634
634
  /** Include seo hidden documents. Defaults to false if not provided. */
635
635
  includeSeoHidden?: boolean | null;
@@ -802,6 +802,8 @@ interface FederatedSearchRequest$1 {
802
802
  documentTypes?: string[];
803
803
  /** Include seo hidden documents. Defaults to false if not provided. */
804
804
  includeSeoHidden?: boolean | null;
805
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
806
+ properties?: SearchProperty$1[];
805
807
  }
806
808
  interface FederatedSearchResponse$1 {
807
809
  /** Search results from multiple indexes. */
@@ -834,7 +836,7 @@ interface SuggestRequest$1 {
834
836
  fields?: string[];
835
837
  /** Include seo hidden documents. Defaults to false if not provided. */
836
838
  includeSeoHidden?: boolean | null;
837
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
839
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
838
840
  properties?: SearchProperty$1[];
839
841
  }
840
842
  interface SuggestResponse$1 {
@@ -854,6 +856,8 @@ interface FederatedSuggestRequest$1 {
854
856
  documentTypes?: string[];
855
857
  /** Include seo hidden documents. Defaults to false if not provided. */
856
858
  includeSeoHidden?: boolean | null;
859
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
860
+ properties?: SearchProperty$1[];
857
861
  }
858
862
  interface FederatedSuggestResponse$1 {
859
863
  /** Suggest results from multiple indexes. */
@@ -1046,7 +1050,7 @@ interface SearchRequest {
1046
1050
  searchFields?: string[];
1047
1051
  /** A list of fields to include in the result set. If not provided, all fields of schema will be included. */
1048
1052
  fields?: string[];
1049
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1053
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1050
1054
  properties?: SearchProperty[];
1051
1055
  /** Include seo hidden documents. Defaults to false if not provided. */
1052
1056
  includeSeoHidden?: boolean | null;
@@ -1219,6 +1223,8 @@ interface FederatedSearchRequest {
1219
1223
  documentTypes?: string[];
1220
1224
  /** Include seo hidden documents. Defaults to false if not provided. */
1221
1225
  includeSeoHidden?: boolean | null;
1226
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1227
+ properties?: SearchProperty[];
1222
1228
  }
1223
1229
  interface FederatedSearchResponse {
1224
1230
  /** Search results from multiple indexes. */
@@ -1251,7 +1257,7 @@ interface SuggestRequest {
1251
1257
  fields?: string[];
1252
1258
  /** Include seo hidden documents. Defaults to false if not provided. */
1253
1259
  includeSeoHidden?: boolean | null;
1254
- /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`. */
1260
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1255
1261
  properties?: SearchProperty[];
1256
1262
  }
1257
1263
  interface SuggestResponse {
@@ -1271,6 +1277,8 @@ interface FederatedSuggestRequest {
1271
1277
  documentTypes?: string[];
1272
1278
  /** Include seo hidden documents. Defaults to false if not provided. */
1273
1279
  includeSeoHidden?: boolean | null;
1280
+ /** The properties/overrides/experiments to enable for this request. Currently supported: `scoring_profile`, `result-format`. */
1281
+ properties?: SearchProperty[];
1274
1282
  }
1275
1283
  interface FederatedSuggestResponse {
1276
1284
  /** Suggest results from multiple indexes. */