@wix/motion 1.0.46 → 1.0.48

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,39 +1,127 @@
1
- type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
2
- interface HttpClient {
3
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
1
+ type HostModule$2<T, H extends Host$2> = {
2
+ __type: 'host';
3
+ create(host: H): T;
4
+ };
5
+ type HostModuleAPI$2<T extends HostModule$2<any, any>> = T extends HostModule$2<infer U, any> ? U : never;
6
+ type Host$2<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$2<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$2) => T;
40
+ interface HttpClient$2 {
41
+ request<TResponse, TData = any>(req: RequestOptionsFactory$2<TResponse, TData>): Promise<HttpResponse$2<TResponse>>;
4
42
  fetchWithAuth: typeof fetch;
5
43
  wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
44
+ getActiveToken?: () => string | undefined;
6
45
  }
7
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
8
- type HttpResponse<T = any> = {
46
+ type RequestOptionsFactory$2<TResponse = any, TData = any> = (context: any) => RequestOptions$2<TResponse, TData>;
47
+ type HttpResponse$2<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<_TResponse = any, Data = any> = {
54
+ type RequestOptions$2<_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;
21
- type APIMetadata = {
59
+ } & APIMetadata$2;
60
+ type APIMetadata$2 = {
22
61
  methodFqn?: string;
23
62
  entityFqdn?: string;
24
63
  packageName?: string;
25
64
  };
26
- type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
27
- type EventDefinition<Payload = unknown, Type extends string = string> = {
65
+ type BuildRESTFunction$2<T extends RESTFunctionDescriptor$2> = T extends RESTFunctionDescriptor$2<infer U> ? U : never;
66
+ type EventDefinition$4<Payload = unknown, Type extends string = string> = {
28
67
  __type: 'event-definition';
29
68
  type: Type;
30
69
  isDomainEvent?: boolean;
31
70
  transformations?: (envelope: unknown) => Payload;
32
71
  __payload: Payload;
33
72
  };
34
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
35
- type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
36
- type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
73
+ declare function EventDefinition$4<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$4<Payload, Type>;
74
+ type EventHandler$4<T extends EventDefinition$4> = (payload: T['__payload']) => void | Promise<void>;
75
+ type BuildEventDefinition$4<T extends EventDefinition$4<any, string>> = (handler: EventHandler$4<T>) => void;
76
+
77
+ type ServicePluginMethodInput$2 = {
78
+ request: any;
79
+ metadata: any;
80
+ };
81
+ type ServicePluginContract$2 = Record<string, (payload: ServicePluginMethodInput$2) => unknown | Promise<unknown>>;
82
+ type ServicePluginMethodMetadata$2 = {
83
+ name: string;
84
+ primaryHttpMappingPath: string;
85
+ transformations: {
86
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput$2;
87
+ toREST: (...args: unknown[]) => unknown;
88
+ };
89
+ };
90
+ type ServicePluginDefinition$2<Contract extends ServicePluginContract$2> = {
91
+ __type: 'service-plugin-definition';
92
+ componentType: string;
93
+ methods: ServicePluginMethodMetadata$2[];
94
+ __contract: Contract;
95
+ };
96
+ declare function ServicePluginDefinition$2<Contract extends ServicePluginContract$2>(componentType: string, methods: ServicePluginMethodMetadata$2[]): ServicePluginDefinition$2<Contract>;
97
+ type BuildServicePluginDefinition$2<T extends ServicePluginDefinition$2<any>> = (implementation: T['__contract']) => void;
98
+ declare const SERVICE_PLUGIN_ERROR_TYPE$2 = "wix_spi_error";
99
+
100
+ type RequestContext$2 = {
101
+ isSSR: boolean;
102
+ host: string;
103
+ protocol?: string;
104
+ };
105
+ type ResponseTransformer$2 = (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$2 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
112
+ type AmbassadorRequestOptions$2<T = any> = {
113
+ _?: T;
114
+ url?: string;
115
+ method?: Method$2;
116
+ params?: any;
117
+ data?: any;
118
+ transformResponse?: ResponseTransformer$2 | ResponseTransformer$2[];
119
+ };
120
+ type AmbassadorFactory$2<Request, Response> = (payload: Request) => ((context: RequestContext$2) => AmbassadorRequestOptions$2<Response>) & {
121
+ __isAmbassador: boolean;
122
+ };
123
+ type AmbassadorFunctionDescriptor$2<Request = any, Response = any> = AmbassadorFactory$2<Request, Response>;
124
+ type BuildAmbassadorFunction$2<T extends AmbassadorFunctionDescriptor$2> = T extends AmbassadorFunctionDescriptor$2<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
37
125
 
38
126
  declare global {
39
127
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
@@ -42,6 +130,284 @@ declare global {
42
130
  }
43
131
  }
44
132
 
133
+ declare const emptyObjectSymbol$2: 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$2 = {[emptyObjectSymbol$2]?: 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$2<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$2<KeyType, ExcludeType> = IsEqual$2<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
223
+
224
+ type ExceptOptions$2 = {
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$2<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$2 = {requireExactProps: false}> = {
269
+ [KeyType in keyof ObjectType as Filter$2<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$2<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$2<Base, Condition> = Except$2<
361
+ Base,
362
+ ConditionalKeys$2<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$2 = RESTFunctionDescriptor$2 | AmbassadorFunctionDescriptor$2 | HostModule$2<any, any> | EventDefinition$4<any> | ServicePluginDefinition$2<any> | {
371
+ [key: string]: Descriptors$2 | PublicMetadata$2 | 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$2<T extends Descriptors$2, H extends Host$2<any> | undefined, Depth extends number = 5> = {
380
+ done: T;
381
+ recurse: T extends {
382
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE$2;
383
+ } ? never : T extends AmbassadorFunctionDescriptor$2 ? BuildAmbassadorFunction$2<T> : T extends RESTFunctionDescriptor$2 ? BuildRESTFunction$2<T> : T extends EventDefinition$4<any> ? BuildEventDefinition$4<T> : T extends ServicePluginDefinition$2<any> ? BuildServicePluginDefinition$2<T> : T extends HostModule$2<any, any> ? HostModuleAPI$2<T> : ConditionalExcept$2<{
384
+ [Key in keyof T]: T[Key] extends Descriptors$2 ? BuildDescriptors$2<T[Key], H, [
385
+ -1,
386
+ 0,
387
+ 1,
388
+ 2,
389
+ 3,
390
+ 4,
391
+ 5
392
+ ][Depth]> : never;
393
+ }, EmptyObject$2>;
394
+ }[Depth extends -1 ? 'done' : 'recurse'];
395
+ type PublicMetadata$2 = {
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$2<T extends Descriptors$2> = globalThis.ContextualClient extends {
408
+ host: Host$2;
409
+ } ? BuildDescriptors$2<T, globalThis.ContextualClient['host']> : T;
410
+
45
411
  interface AlarmMessage {
46
412
  _id?: string;
47
413
  seconds?: number;
@@ -260,28 +626,46 @@ interface UpdateAlarm {
260
626
  seconds?: number;
261
627
  }
262
628
 
263
- declare function alarm$1(httpClient: HttpClient): AlarmSignature;
629
+ declare function alarm$1(httpClient: HttpClient$2): AlarmSignature;
264
630
  interface AlarmSignature {
265
631
  /**
266
632
  * sets up an alarm after {seconds}
267
633
  */
268
634
  (seconds: number, options?: AlarmOptions | undefined): Promise<AlarmResponse>;
269
635
  }
270
- declare function updateAlarm$1(httpClient: HttpClient): UpdateAlarmSignature;
636
+ declare function updateAlarm$1(httpClient: HttpClient$2): UpdateAlarmSignature;
271
637
  interface UpdateAlarmSignature {
272
638
  /**
273
639
  * sets up an existing alarm with id {id}
274
640
  */
275
641
  (_id: string, alarm: UpdateAlarm): Promise<UpdateAlarmResponse & UpdateAlarmResponseNonNullableFields>;
276
642
  }
277
- declare const onAlarmTriggered$1: EventDefinition<AlarmTriggeredEnvelope, "wix.alarm.v1.alarm_alarm_triggered">;
278
- declare const onAlarmSnoozed$1: EventDefinition<AlarmSnoozedEnvelope, "wix.alarm.v1.alarm_alarm_snoozed">;
279
- declare const onAlarmDeleted$1: EventDefinition<AlarmDeletedEnvelope, "wix.alarm.v1.alarm_alarm_deleted">;
643
+ declare const onAlarmTriggered$1: EventDefinition$4<AlarmTriggeredEnvelope, "wix.alarm.v1.alarm_alarm_triggered">;
644
+ declare const onAlarmSnoozed$1: EventDefinition$4<AlarmSnoozedEnvelope, "wix.alarm.v1.alarm_alarm_snoozed">;
645
+ declare const onAlarmDeleted$1: EventDefinition$4<AlarmDeletedEnvelope, "wix.alarm.v1.alarm_alarm_deleted">;
646
+
647
+ type EventDefinition$3<Payload = unknown, Type extends string = string> = {
648
+ __type: 'event-definition';
649
+ type: Type;
650
+ isDomainEvent?: boolean;
651
+ transformations?: (envelope: unknown) => Payload;
652
+ __payload: Payload;
653
+ };
654
+ declare function EventDefinition$3<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$3<Payload, Type>;
655
+ type EventHandler$3<T extends EventDefinition$3> = (payload: T['__payload']) => void | Promise<void>;
656
+ type BuildEventDefinition$3<T extends EventDefinition$3<any, string>> = (handler: EventHandler$3<T>) => void;
657
+
658
+ declare global {
659
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
660
+ interface SymbolConstructor {
661
+ readonly observable: symbol;
662
+ }
663
+ }
280
664
 
281
- declare function createEventModule$1<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
665
+ declare function createEventModule$1<T extends EventDefinition$3<any, string>>(eventDefinition: T): BuildEventDefinition$3<T> & T;
282
666
 
283
- declare const alarm: BuildRESTFunction<typeof alarm$1> & typeof alarm$1;
284
- declare const updateAlarm: BuildRESTFunction<typeof updateAlarm$1> & typeof updateAlarm$1;
667
+ declare const alarm: MaybeContext$2<BuildRESTFunction$2<typeof alarm$1> & typeof alarm$1>;
668
+ declare const updateAlarm: MaybeContext$2<BuildRESTFunction$2<typeof updateAlarm$1> & typeof updateAlarm$1>;
285
669
 
286
670
  type _publicOnAlarmTriggeredType = typeof onAlarmTriggered$1;
287
671
  /**
@@ -329,6 +713,416 @@ declare namespace index_d$2 {
329
713
  export { type ActionEvent$2 as ActionEvent, type index_d$2_AlarmDeleted as AlarmDeleted, type index_d$2_AlarmDeletedEnvelope as AlarmDeletedEnvelope, type index_d$2_AlarmMessage as AlarmMessage, type index_d$2_AlarmOptions as AlarmOptions, type index_d$2_AlarmRequest as AlarmRequest, type index_d$2_AlarmRequestRequiredFields as AlarmRequestRequiredFields, type index_d$2_AlarmResponse as AlarmResponse, type index_d$2_AlarmSnoozed as AlarmSnoozed, type index_d$2_AlarmSnoozedEnvelope as AlarmSnoozedEnvelope, type index_d$2_AlarmTriggered as AlarmTriggered, type index_d$2_AlarmTriggeredEnvelope as AlarmTriggeredEnvelope, type BaseEventMetadata$1 as BaseEventMetadata, type DomainEvent$2 as DomainEvent, type DomainEventBodyOneOf$2 as DomainEventBodyOneOf, type EntityCreatedEvent$2 as EntityCreatedEvent, type EntityDeletedEvent$2 as EntityDeletedEvent, type EntityUpdatedEvent$2 as EntityUpdatedEvent, type EventMetadata$1 as EventMetadata, type IdentificationData$2 as IdentificationData, type IdentificationDataIdOneOf$2 as IdentificationDataIdOneOf, type MessageEnvelope$2 as MessageEnvelope, type RestoreInfo$2 as RestoreInfo, type index_d$2_UpdateAlarm as UpdateAlarm, type index_d$2_UpdateAlarmRequest as UpdateAlarmRequest, type index_d$2_UpdateAlarmRequestRequiredFields as UpdateAlarmRequestRequiredFields, type index_d$2_UpdateAlarmResponse as UpdateAlarmResponse, type index_d$2_UpdateAlarmResponseNonNullableFields as UpdateAlarmResponseNonNullableFields, WebhookIdentityType$2 as WebhookIdentityType, type index_d$2__publicOnAlarmDeletedType as _publicOnAlarmDeletedType, type index_d$2__publicOnAlarmSnoozedType as _publicOnAlarmSnoozedType, type index_d$2__publicOnAlarmTriggeredType as _publicOnAlarmTriggeredType, index_d$2_alarm as alarm, index_d$2_onAlarmDeleted as onAlarmDeleted, index_d$2_onAlarmSnoozed as onAlarmSnoozed, index_d$2_onAlarmTriggered as onAlarmTriggered, onAlarmDeleted$1 as publicOnAlarmDeleted, onAlarmSnoozed$1 as publicOnAlarmSnoozed, onAlarmTriggered$1 as publicOnAlarmTriggered, index_d$2_updateAlarm as updateAlarm };
330
714
  }
331
715
 
716
+ type HostModule$1<T, H extends Host$1> = {
717
+ __type: 'host';
718
+ create(host: H): T;
719
+ };
720
+ type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
721
+ type Host$1<Environment = unknown> = {
722
+ channel: {
723
+ observeState(callback: (props: unknown, environment: Environment) => unknown): {
724
+ disconnect: () => void;
725
+ } | Promise<{
726
+ disconnect: () => void;
727
+ }>;
728
+ };
729
+ environment?: Environment;
730
+ /**
731
+ * Optional bast url to use for API requests, for example `www.wixapis.com`
732
+ */
733
+ apiBaseUrl?: string;
734
+ /**
735
+ * Possible data to be provided by every host, for cross cutting concerns
736
+ * like internationalization, billing, etc.
737
+ */
738
+ essentials?: {
739
+ /**
740
+ * The language of the currently viewed session
741
+ */
742
+ language?: string;
743
+ /**
744
+ * The locale of the currently viewed session
745
+ */
746
+ locale?: string;
747
+ /**
748
+ * Any headers that should be passed through to the API requests
749
+ */
750
+ passThroughHeaders?: Record<string, string>;
751
+ };
752
+ };
753
+
754
+ type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
755
+ interface HttpClient$1 {
756
+ request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
757
+ fetchWithAuth: typeof fetch;
758
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
759
+ getActiveToken?: () => string | undefined;
760
+ }
761
+ type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
762
+ type HttpResponse$1<T = any> = {
763
+ data: T;
764
+ status: number;
765
+ statusText: string;
766
+ headers: any;
767
+ request?: any;
768
+ };
769
+ type RequestOptions$1<_TResponse = any, Data = any> = {
770
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
771
+ url: string;
772
+ data?: Data;
773
+ params?: URLSearchParams;
774
+ } & APIMetadata$1;
775
+ type APIMetadata$1 = {
776
+ methodFqn?: string;
777
+ entityFqdn?: string;
778
+ packageName?: string;
779
+ };
780
+ type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
781
+ type EventDefinition$2<Payload = unknown, Type extends string = string> = {
782
+ __type: 'event-definition';
783
+ type: Type;
784
+ isDomainEvent?: boolean;
785
+ transformations?: (envelope: unknown) => Payload;
786
+ __payload: Payload;
787
+ };
788
+ declare function EventDefinition$2<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$2<Payload, Type>;
789
+ type EventHandler$2<T extends EventDefinition$2> = (payload: T['__payload']) => void | Promise<void>;
790
+ type BuildEventDefinition$2<T extends EventDefinition$2<any, string>> = (handler: EventHandler$2<T>) => void;
791
+
792
+ type ServicePluginMethodInput$1 = {
793
+ request: any;
794
+ metadata: any;
795
+ };
796
+ type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
797
+ type ServicePluginMethodMetadata$1 = {
798
+ name: string;
799
+ primaryHttpMappingPath: string;
800
+ transformations: {
801
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
802
+ toREST: (...args: unknown[]) => unknown;
803
+ };
804
+ };
805
+ type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
806
+ __type: 'service-plugin-definition';
807
+ componentType: string;
808
+ methods: ServicePluginMethodMetadata$1[];
809
+ __contract: Contract;
810
+ };
811
+ declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
812
+ type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
813
+ declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
814
+
815
+ type RequestContext$1 = {
816
+ isSSR: boolean;
817
+ host: string;
818
+ protocol?: string;
819
+ };
820
+ type ResponseTransformer$1 = (data: any, headers?: any) => any;
821
+ /**
822
+ * Ambassador request options types are copied mostly from AxiosRequestConfig.
823
+ * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
824
+ * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
825
+ */
826
+ type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
827
+ type AmbassadorRequestOptions$1<T = any> = {
828
+ _?: T;
829
+ url?: string;
830
+ method?: Method$1;
831
+ params?: any;
832
+ data?: any;
833
+ transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
834
+ };
835
+ type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
836
+ __isAmbassador: boolean;
837
+ };
838
+ type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
839
+ type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
840
+
841
+ declare global {
842
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
843
+ interface SymbolConstructor {
844
+ readonly observable: symbol;
845
+ }
846
+ }
847
+
848
+ declare const emptyObjectSymbol$1: unique symbol;
849
+
850
+ /**
851
+ Represents a strictly empty plain object, the `{}` value.
852
+
853
+ 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)).
854
+
855
+ @example
856
+ ```
857
+ import type {EmptyObject} from 'type-fest';
858
+
859
+ // The following illustrates the problem with `{}`.
860
+ const foo1: {} = {}; // Pass
861
+ const foo2: {} = []; // Pass
862
+ const foo3: {} = 42; // Pass
863
+ const foo4: {} = {a: 1}; // Pass
864
+
865
+ // With `EmptyObject` only the first case is valid.
866
+ const bar1: EmptyObject = {}; // Pass
867
+ const bar2: EmptyObject = 42; // Fail
868
+ const bar3: EmptyObject = []; // Fail
869
+ const bar4: EmptyObject = {a: 1}; // Fail
870
+ ```
871
+
872
+ 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}.
873
+
874
+ @category Object
875
+ */
876
+ type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
877
+
878
+ /**
879
+ Returns a boolean for whether the two given types are equal.
880
+
881
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
882
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
883
+
884
+ Use-cases:
885
+ - If you want to make a conditional branch based on the result of a comparison of two types.
886
+
887
+ @example
888
+ ```
889
+ import type {IsEqual} from 'type-fest';
890
+
891
+ // This type returns a boolean for whether the given array includes the given item.
892
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
893
+ type Includes<Value extends readonly any[], Item> =
894
+ Value extends readonly [Value[0], ...infer rest]
895
+ ? IsEqual<Value[0], Item> extends true
896
+ ? true
897
+ : Includes<rest, Item>
898
+ : false;
899
+ ```
900
+
901
+ @category Type Guard
902
+ @category Utilities
903
+ */
904
+ type IsEqual$1<A, B> =
905
+ (<G>() => G extends A ? 1 : 2) extends
906
+ (<G>() => G extends B ? 1 : 2)
907
+ ? true
908
+ : false;
909
+
910
+ /**
911
+ Filter out keys from an object.
912
+
913
+ Returns `never` if `Exclude` is strictly equal to `Key`.
914
+ Returns `never` if `Key` extends `Exclude`.
915
+ Returns `Key` otherwise.
916
+
917
+ @example
918
+ ```
919
+ type Filtered = Filter<'foo', 'foo'>;
920
+ //=> never
921
+ ```
922
+
923
+ @example
924
+ ```
925
+ type Filtered = Filter<'bar', string>;
926
+ //=> never
927
+ ```
928
+
929
+ @example
930
+ ```
931
+ type Filtered = Filter<'bar', 'foo'>;
932
+ //=> 'bar'
933
+ ```
934
+
935
+ @see {Except}
936
+ */
937
+ type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
938
+
939
+ type ExceptOptions$1 = {
940
+ /**
941
+ Disallow assigning non-specified properties.
942
+
943
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
944
+
945
+ @default false
946
+ */
947
+ requireExactProps?: boolean;
948
+ };
949
+
950
+ /**
951
+ Create a type from an object type without certain keys.
952
+
953
+ We recommend setting the `requireExactProps` option to `true`.
954
+
955
+ 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.
956
+
957
+ 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)).
958
+
959
+ @example
960
+ ```
961
+ import type {Except} from 'type-fest';
962
+
963
+ type Foo = {
964
+ a: number;
965
+ b: string;
966
+ };
967
+
968
+ type FooWithoutA = Except<Foo, 'a'>;
969
+ //=> {b: string}
970
+
971
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
972
+ //=> errors: 'a' does not exist in type '{ b: string; }'
973
+
974
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
975
+ //=> {a: number} & Partial<Record<"b", never>>
976
+
977
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
978
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
979
+ ```
980
+
981
+ @category Object
982
+ */
983
+ type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
984
+ [KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
985
+ } & (Options['requireExactProps'] extends true
986
+ ? Partial<Record<KeysType, never>>
987
+ : {});
988
+
989
+ /**
990
+ Extract the keys from a type where the value type of the key extends the given `Condition`.
991
+
992
+ Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
993
+
994
+ @example
995
+ ```
996
+ import type {ConditionalKeys} from 'type-fest';
997
+
998
+ interface Example {
999
+ a: string;
1000
+ b: string | number;
1001
+ c?: string;
1002
+ d: {};
1003
+ }
1004
+
1005
+ type StringKeysOnly = ConditionalKeys<Example, string>;
1006
+ //=> 'a'
1007
+ ```
1008
+
1009
+ To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
1010
+
1011
+ @example
1012
+ ```
1013
+ import type {ConditionalKeys} from 'type-fest';
1014
+
1015
+ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
1016
+ //=> 'a' | 'c'
1017
+ ```
1018
+
1019
+ @category Object
1020
+ */
1021
+ type ConditionalKeys$1<Base, Condition> = NonNullable<
1022
+ // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
1023
+ {
1024
+ // Map through all the keys of the given base type.
1025
+ [Key in keyof Base]:
1026
+ // Pick only keys with types extending the given `Condition` type.
1027
+ Base[Key] extends Condition
1028
+ // Retain this key since the condition passes.
1029
+ ? Key
1030
+ // Discard this key since the condition fails.
1031
+ : never;
1032
+
1033
+ // Convert the produced object into a union type of the keys which passed the conditional test.
1034
+ }[keyof Base]
1035
+ >;
1036
+
1037
+ /**
1038
+ Exclude keys from a shape that matches the given `Condition`.
1039
+
1040
+ 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.
1041
+
1042
+ @example
1043
+ ```
1044
+ import type {Primitive, ConditionalExcept} from 'type-fest';
1045
+
1046
+ class Awesome {
1047
+ name: string;
1048
+ successes: number;
1049
+ failures: bigint;
1050
+
1051
+ run() {}
1052
+ }
1053
+
1054
+ type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
1055
+ //=> {run: () => void}
1056
+ ```
1057
+
1058
+ @example
1059
+ ```
1060
+ import type {ConditionalExcept} from 'type-fest';
1061
+
1062
+ interface Example {
1063
+ a: string;
1064
+ b: string | number;
1065
+ c: () => void;
1066
+ d: {};
1067
+ }
1068
+
1069
+ type NonStringKeysOnly = ConditionalExcept<Example, string>;
1070
+ //=> {b: string | number; c: () => void; d: {}}
1071
+ ```
1072
+
1073
+ @category Object
1074
+ */
1075
+ type ConditionalExcept$1<Base, Condition> = Except$1<
1076
+ Base,
1077
+ ConditionalKeys$1<Base, Condition>
1078
+ >;
1079
+
1080
+ /**
1081
+ * Descriptors are objects that describe the API of a module, and the module
1082
+ * can either be a REST module or a host module.
1083
+ * This type is recursive, so it can describe nested modules.
1084
+ */
1085
+ type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$2<any> | ServicePluginDefinition$1<any> | {
1086
+ [key: string]: Descriptors$1 | PublicMetadata$1 | any;
1087
+ };
1088
+ /**
1089
+ * This type takes in a descriptors object of a certain Host (including an `unknown` host)
1090
+ * and returns an object with the same structure, but with all descriptors replaced with their API.
1091
+ * Any non-descriptor properties are removed from the returned object, including descriptors that
1092
+ * do not match the given host (as they will not work with the given host).
1093
+ */
1094
+ type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
1095
+ done: T;
1096
+ recurse: T extends {
1097
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
1098
+ } ? never : T extends AmbassadorFunctionDescriptor$1 ? BuildAmbassadorFunction$1<T> : T extends RESTFunctionDescriptor$1 ? BuildRESTFunction$1<T> : T extends EventDefinition$2<any> ? BuildEventDefinition$2<T> : T extends ServicePluginDefinition$1<any> ? BuildServicePluginDefinition$1<T> : T extends HostModule$1<any, any> ? HostModuleAPI$1<T> : ConditionalExcept$1<{
1099
+ [Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
1100
+ -1,
1101
+ 0,
1102
+ 1,
1103
+ 2,
1104
+ 3,
1105
+ 4,
1106
+ 5
1107
+ ][Depth]> : never;
1108
+ }, EmptyObject$1>;
1109
+ }[Depth extends -1 ? 'done' : 'recurse'];
1110
+ type PublicMetadata$1 = {
1111
+ PACKAGE_NAME?: string;
1112
+ };
1113
+
1114
+ declare global {
1115
+ interface ContextualClient {
1116
+ }
1117
+ }
1118
+ /**
1119
+ * A type used to create concerete types from SDK descriptors in
1120
+ * case a contextual client is available.
1121
+ */
1122
+ type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
1123
+ host: Host$1;
1124
+ } ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
1125
+
332
1126
  interface MessageItem {
333
1127
  /** inner_message comment from EchoMessage proto def */
334
1128
  innerMessage?: string;
@@ -541,7 +1335,7 @@ interface EchoOptions {
541
1335
  someDate?: Date;
542
1336
  }
543
1337
 
544
- declare function echo$1(httpClient: HttpClient): EchoSignature;
1338
+ declare function echo$1(httpClient: HttpClient$1): EchoSignature;
545
1339
  interface EchoSignature {
546
1340
  /**
547
1341
  * echo given arg1 and arg2
@@ -551,11 +1345,29 @@ interface EchoSignature {
551
1345
  */
552
1346
  (arg1: string, options?: EchoOptions | undefined): Promise<string>;
553
1347
  }
554
- declare const onEchoDispatched$1: EventDefinition<EchoDispatchedEnvelope, "wix.metroinspector.v1.echo_dispatched">;
1348
+ declare const onEchoDispatched$1: EventDefinition$2<EchoDispatchedEnvelope, "wix.metroinspector.v1.echo_dispatched">;
555
1349
 
556
- declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
1350
+ type EventDefinition$1<Payload = unknown, Type extends string = string> = {
1351
+ __type: 'event-definition';
1352
+ type: Type;
1353
+ isDomainEvent?: boolean;
1354
+ transformations?: (envelope: unknown) => Payload;
1355
+ __payload: Payload;
1356
+ };
1357
+ declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
1358
+ type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
1359
+ type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
557
1360
 
558
- declare const echo: BuildRESTFunction<typeof echo$1> & typeof echo$1;
1361
+ declare global {
1362
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
1363
+ interface SymbolConstructor {
1364
+ readonly observable: symbol;
1365
+ }
1366
+ }
1367
+
1368
+ declare function createEventModule<T extends EventDefinition$1<any, string>>(eventDefinition: T): BuildEventDefinition$1<T> & T;
1369
+
1370
+ declare const echo: MaybeContext$1<BuildRESTFunction$1<typeof echo$1> & typeof echo$1>;
559
1371
 
560
1372
  type _publicOnEchoDispatchedType = typeof onEchoDispatched$1;
561
1373
  /**
@@ -581,6 +1393,416 @@ declare namespace index_d$1 {
581
1393
  export { type ActionEvent$1 as ActionEvent, type index_d$1_BaseEventMetadata as BaseEventMetadata, type index_d$1_Dispatched as Dispatched, type DomainEvent$1 as DomainEvent, type DomainEventBodyOneOf$1 as DomainEventBodyOneOf, type index_d$1_EchoDispatchedEnvelope as EchoDispatchedEnvelope, type index_d$1_EchoMessage as EchoMessage, type index_d$1_EchoOptions as EchoOptions, type index_d$1_EchoRequest as EchoRequest, type index_d$1_EchoRequestRequiredFields as EchoRequestRequiredFields, type index_d$1_EchoResponse as EchoResponse, type index_d$1_EchoResponseNonNullableFields as EchoResponseNonNullableFields, type EntityCreatedEvent$1 as EntityCreatedEvent, type EntityDeletedEvent$1 as EntityDeletedEvent, type EntityUpdatedEvent$1 as EntityUpdatedEvent, type index_d$1_EventMetadata as EventMetadata, type IdentificationData$1 as IdentificationData, type IdentificationDataIdOneOf$1 as IdentificationDataIdOneOf, type MessageEnvelope$1 as MessageEnvelope, type index_d$1_MessageItem as MessageItem, type RestoreInfo$1 as RestoreInfo, WebhookIdentityType$1 as WebhookIdentityType, type index_d$1__publicOnEchoDispatchedType as _publicOnEchoDispatchedType, index_d$1_echo as echo, index_d$1_onEchoDispatched as onEchoDispatched, onEchoDispatched$1 as publicOnEchoDispatched };
582
1394
  }
583
1395
 
1396
+ type HostModule<T, H extends Host> = {
1397
+ __type: 'host';
1398
+ create(host: H): T;
1399
+ };
1400
+ type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
1401
+ type Host<Environment = unknown> = {
1402
+ channel: {
1403
+ observeState(callback: (props: unknown, environment: Environment) => unknown): {
1404
+ disconnect: () => void;
1405
+ } | Promise<{
1406
+ disconnect: () => void;
1407
+ }>;
1408
+ };
1409
+ environment?: Environment;
1410
+ /**
1411
+ * Optional bast url to use for API requests, for example `www.wixapis.com`
1412
+ */
1413
+ apiBaseUrl?: string;
1414
+ /**
1415
+ * Possible data to be provided by every host, for cross cutting concerns
1416
+ * like internationalization, billing, etc.
1417
+ */
1418
+ essentials?: {
1419
+ /**
1420
+ * The language of the currently viewed session
1421
+ */
1422
+ language?: string;
1423
+ /**
1424
+ * The locale of the currently viewed session
1425
+ */
1426
+ locale?: string;
1427
+ /**
1428
+ * Any headers that should be passed through to the API requests
1429
+ */
1430
+ passThroughHeaders?: Record<string, string>;
1431
+ };
1432
+ };
1433
+
1434
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
1435
+ interface HttpClient {
1436
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
1437
+ fetchWithAuth: typeof fetch;
1438
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
1439
+ getActiveToken?: () => string | undefined;
1440
+ }
1441
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
1442
+ type HttpResponse<T = any> = {
1443
+ data: T;
1444
+ status: number;
1445
+ statusText: string;
1446
+ headers: any;
1447
+ request?: any;
1448
+ };
1449
+ type RequestOptions<_TResponse = any, Data = any> = {
1450
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
1451
+ url: string;
1452
+ data?: Data;
1453
+ params?: URLSearchParams;
1454
+ } & APIMetadata;
1455
+ type APIMetadata = {
1456
+ methodFqn?: string;
1457
+ entityFqdn?: string;
1458
+ packageName?: string;
1459
+ };
1460
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
1461
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
1462
+ __type: 'event-definition';
1463
+ type: Type;
1464
+ isDomainEvent?: boolean;
1465
+ transformations?: (envelope: unknown) => Payload;
1466
+ __payload: Payload;
1467
+ };
1468
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
1469
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
1470
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
1471
+
1472
+ type ServicePluginMethodInput = {
1473
+ request: any;
1474
+ metadata: any;
1475
+ };
1476
+ type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
1477
+ type ServicePluginMethodMetadata = {
1478
+ name: string;
1479
+ primaryHttpMappingPath: string;
1480
+ transformations: {
1481
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput;
1482
+ toREST: (...args: unknown[]) => unknown;
1483
+ };
1484
+ };
1485
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
1486
+ __type: 'service-plugin-definition';
1487
+ componentType: string;
1488
+ methods: ServicePluginMethodMetadata[];
1489
+ __contract: Contract;
1490
+ };
1491
+ declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
1492
+ type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
1493
+ declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
1494
+
1495
+ type RequestContext = {
1496
+ isSSR: boolean;
1497
+ host: string;
1498
+ protocol?: string;
1499
+ };
1500
+ type ResponseTransformer = (data: any, headers?: any) => any;
1501
+ /**
1502
+ * Ambassador request options types are copied mostly from AxiosRequestConfig.
1503
+ * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
1504
+ * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
1505
+ */
1506
+ type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
1507
+ type AmbassadorRequestOptions<T = any> = {
1508
+ _?: T;
1509
+ url?: string;
1510
+ method?: Method;
1511
+ params?: any;
1512
+ data?: any;
1513
+ transformResponse?: ResponseTransformer | ResponseTransformer[];
1514
+ };
1515
+ type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
1516
+ __isAmbassador: boolean;
1517
+ };
1518
+ type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
1519
+ type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
1520
+
1521
+ declare global {
1522
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
1523
+ interface SymbolConstructor {
1524
+ readonly observable: symbol;
1525
+ }
1526
+ }
1527
+
1528
+ declare const emptyObjectSymbol: unique symbol;
1529
+
1530
+ /**
1531
+ Represents a strictly empty plain object, the `{}` value.
1532
+
1533
+ 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)).
1534
+
1535
+ @example
1536
+ ```
1537
+ import type {EmptyObject} from 'type-fest';
1538
+
1539
+ // The following illustrates the problem with `{}`.
1540
+ const foo1: {} = {}; // Pass
1541
+ const foo2: {} = []; // Pass
1542
+ const foo3: {} = 42; // Pass
1543
+ const foo4: {} = {a: 1}; // Pass
1544
+
1545
+ // With `EmptyObject` only the first case is valid.
1546
+ const bar1: EmptyObject = {}; // Pass
1547
+ const bar2: EmptyObject = 42; // Fail
1548
+ const bar3: EmptyObject = []; // Fail
1549
+ const bar4: EmptyObject = {a: 1}; // Fail
1550
+ ```
1551
+
1552
+ 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}.
1553
+
1554
+ @category Object
1555
+ */
1556
+ type EmptyObject = {[emptyObjectSymbol]?: never};
1557
+
1558
+ /**
1559
+ Returns a boolean for whether the two given types are equal.
1560
+
1561
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
1562
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
1563
+
1564
+ Use-cases:
1565
+ - If you want to make a conditional branch based on the result of a comparison of two types.
1566
+
1567
+ @example
1568
+ ```
1569
+ import type {IsEqual} from 'type-fest';
1570
+
1571
+ // This type returns a boolean for whether the given array includes the given item.
1572
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
1573
+ type Includes<Value extends readonly any[], Item> =
1574
+ Value extends readonly [Value[0], ...infer rest]
1575
+ ? IsEqual<Value[0], Item> extends true
1576
+ ? true
1577
+ : Includes<rest, Item>
1578
+ : false;
1579
+ ```
1580
+
1581
+ @category Type Guard
1582
+ @category Utilities
1583
+ */
1584
+ type IsEqual<A, B> =
1585
+ (<G>() => G extends A ? 1 : 2) extends
1586
+ (<G>() => G extends B ? 1 : 2)
1587
+ ? true
1588
+ : false;
1589
+
1590
+ /**
1591
+ Filter out keys from an object.
1592
+
1593
+ Returns `never` if `Exclude` is strictly equal to `Key`.
1594
+ Returns `never` if `Key` extends `Exclude`.
1595
+ Returns `Key` otherwise.
1596
+
1597
+ @example
1598
+ ```
1599
+ type Filtered = Filter<'foo', 'foo'>;
1600
+ //=> never
1601
+ ```
1602
+
1603
+ @example
1604
+ ```
1605
+ type Filtered = Filter<'bar', string>;
1606
+ //=> never
1607
+ ```
1608
+
1609
+ @example
1610
+ ```
1611
+ type Filtered = Filter<'bar', 'foo'>;
1612
+ //=> 'bar'
1613
+ ```
1614
+
1615
+ @see {Except}
1616
+ */
1617
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
1618
+
1619
+ type ExceptOptions = {
1620
+ /**
1621
+ Disallow assigning non-specified properties.
1622
+
1623
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
1624
+
1625
+ @default false
1626
+ */
1627
+ requireExactProps?: boolean;
1628
+ };
1629
+
1630
+ /**
1631
+ Create a type from an object type without certain keys.
1632
+
1633
+ We recommend setting the `requireExactProps` option to `true`.
1634
+
1635
+ 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.
1636
+
1637
+ 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)).
1638
+
1639
+ @example
1640
+ ```
1641
+ import type {Except} from 'type-fest';
1642
+
1643
+ type Foo = {
1644
+ a: number;
1645
+ b: string;
1646
+ };
1647
+
1648
+ type FooWithoutA = Except<Foo, 'a'>;
1649
+ //=> {b: string}
1650
+
1651
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
1652
+ //=> errors: 'a' does not exist in type '{ b: string; }'
1653
+
1654
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
1655
+ //=> {a: number} & Partial<Record<"b", never>>
1656
+
1657
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
1658
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
1659
+ ```
1660
+
1661
+ @category Object
1662
+ */
1663
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
1664
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
1665
+ } & (Options['requireExactProps'] extends true
1666
+ ? Partial<Record<KeysType, never>>
1667
+ : {});
1668
+
1669
+ /**
1670
+ Extract the keys from a type where the value type of the key extends the given `Condition`.
1671
+
1672
+ Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
1673
+
1674
+ @example
1675
+ ```
1676
+ import type {ConditionalKeys} from 'type-fest';
1677
+
1678
+ interface Example {
1679
+ a: string;
1680
+ b: string | number;
1681
+ c?: string;
1682
+ d: {};
1683
+ }
1684
+
1685
+ type StringKeysOnly = ConditionalKeys<Example, string>;
1686
+ //=> 'a'
1687
+ ```
1688
+
1689
+ To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
1690
+
1691
+ @example
1692
+ ```
1693
+ import type {ConditionalKeys} from 'type-fest';
1694
+
1695
+ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
1696
+ //=> 'a' | 'c'
1697
+ ```
1698
+
1699
+ @category Object
1700
+ */
1701
+ type ConditionalKeys<Base, Condition> = NonNullable<
1702
+ // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
1703
+ {
1704
+ // Map through all the keys of the given base type.
1705
+ [Key in keyof Base]:
1706
+ // Pick only keys with types extending the given `Condition` type.
1707
+ Base[Key] extends Condition
1708
+ // Retain this key since the condition passes.
1709
+ ? Key
1710
+ // Discard this key since the condition fails.
1711
+ : never;
1712
+
1713
+ // Convert the produced object into a union type of the keys which passed the conditional test.
1714
+ }[keyof Base]
1715
+ >;
1716
+
1717
+ /**
1718
+ Exclude keys from a shape that matches the given `Condition`.
1719
+
1720
+ 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.
1721
+
1722
+ @example
1723
+ ```
1724
+ import type {Primitive, ConditionalExcept} from 'type-fest';
1725
+
1726
+ class Awesome {
1727
+ name: string;
1728
+ successes: number;
1729
+ failures: bigint;
1730
+
1731
+ run() {}
1732
+ }
1733
+
1734
+ type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
1735
+ //=> {run: () => void}
1736
+ ```
1737
+
1738
+ @example
1739
+ ```
1740
+ import type {ConditionalExcept} from 'type-fest';
1741
+
1742
+ interface Example {
1743
+ a: string;
1744
+ b: string | number;
1745
+ c: () => void;
1746
+ d: {};
1747
+ }
1748
+
1749
+ type NonStringKeysOnly = ConditionalExcept<Example, string>;
1750
+ //=> {b: string | number; c: () => void; d: {}}
1751
+ ```
1752
+
1753
+ @category Object
1754
+ */
1755
+ type ConditionalExcept<Base, Condition> = Except<
1756
+ Base,
1757
+ ConditionalKeys<Base, Condition>
1758
+ >;
1759
+
1760
+ /**
1761
+ * Descriptors are objects that describe the API of a module, and the module
1762
+ * can either be a REST module or a host module.
1763
+ * This type is recursive, so it can describe nested modules.
1764
+ */
1765
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
1766
+ [key: string]: Descriptors | PublicMetadata | any;
1767
+ };
1768
+ /**
1769
+ * This type takes in a descriptors object of a certain Host (including an `unknown` host)
1770
+ * and returns an object with the same structure, but with all descriptors replaced with their API.
1771
+ * Any non-descriptor properties are removed from the returned object, including descriptors that
1772
+ * do not match the given host (as they will not work with the given host).
1773
+ */
1774
+ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
1775
+ done: T;
1776
+ recurse: T extends {
1777
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
1778
+ } ? 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<{
1779
+ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
1780
+ -1,
1781
+ 0,
1782
+ 1,
1783
+ 2,
1784
+ 3,
1785
+ 4,
1786
+ 5
1787
+ ][Depth]> : never;
1788
+ }, EmptyObject>;
1789
+ }[Depth extends -1 ? 'done' : 'recurse'];
1790
+ type PublicMetadata = {
1791
+ PACKAGE_NAME?: string;
1792
+ };
1793
+
1794
+ declare global {
1795
+ interface ContextualClient {
1796
+ }
1797
+ }
1798
+ /**
1799
+ * A type used to create concerete types from SDK descriptors in
1800
+ * case a contextual client is available.
1801
+ */
1802
+ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
1803
+ host: Host;
1804
+ } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
1805
+
584
1806
  /** Physical address */
585
1807
  interface Address extends AddressStreetOneOf {
586
1808
  /** Street name and number. */
@@ -1276,15 +2498,15 @@ interface BulkDeleteProductsSignature {
1276
2498
  (productIds: string[]): Promise<BulkDeleteProductsResponse & BulkDeleteProductsResponseNonNullableFields>;
1277
2499
  }
1278
2500
 
1279
- declare const createProduct: BuildRESTFunction<typeof createProduct$1> & typeof createProduct$1;
1280
- declare const deleteProduct: BuildRESTFunction<typeof deleteProduct$1> & typeof deleteProduct$1;
1281
- declare const updateProduct: BuildRESTFunction<typeof updateProduct$1> & typeof updateProduct$1;
1282
- declare const getProduct: BuildRESTFunction<typeof getProduct$1> & typeof getProduct$1;
1283
- declare const getProductsStartWith: BuildRESTFunction<typeof getProductsStartWith$1> & typeof getProductsStartWith$1;
1284
- declare const queryProducts: BuildRESTFunction<typeof queryProducts$1> & typeof queryProducts$1;
1285
- declare const bulkCreateProducts: BuildRESTFunction<typeof bulkCreateProducts$1> & typeof bulkCreateProducts$1;
1286
- declare const bulkUpdateProducts: BuildRESTFunction<typeof bulkUpdateProducts$1> & typeof bulkUpdateProducts$1;
1287
- declare const bulkDeleteProducts: BuildRESTFunction<typeof bulkDeleteProducts$1> & typeof bulkDeleteProducts$1;
2501
+ declare const createProduct: MaybeContext<BuildRESTFunction<typeof createProduct$1> & typeof createProduct$1>;
2502
+ declare const deleteProduct: MaybeContext<BuildRESTFunction<typeof deleteProduct$1> & typeof deleteProduct$1>;
2503
+ declare const updateProduct: MaybeContext<BuildRESTFunction<typeof updateProduct$1> & typeof updateProduct$1>;
2504
+ declare const getProduct: MaybeContext<BuildRESTFunction<typeof getProduct$1> & typeof getProduct$1>;
2505
+ declare const getProductsStartWith: MaybeContext<BuildRESTFunction<typeof getProductsStartWith$1> & typeof getProductsStartWith$1>;
2506
+ declare const queryProducts: MaybeContext<BuildRESTFunction<typeof queryProducts$1> & typeof queryProducts$1>;
2507
+ declare const bulkCreateProducts: MaybeContext<BuildRESTFunction<typeof bulkCreateProducts$1> & typeof bulkCreateProducts$1>;
2508
+ declare const bulkUpdateProducts: MaybeContext<BuildRESTFunction<typeof bulkUpdateProducts$1> & typeof bulkUpdateProducts$1>;
2509
+ declare const bulkDeleteProducts: MaybeContext<BuildRESTFunction<typeof bulkDeleteProducts$1> & typeof bulkDeleteProducts$1>;
1288
2510
 
1289
2511
  type index_d_ActionEvent = ActionEvent;
1290
2512
  type index_d_Address = Address;