@wix/payments 1.0.14 → 1.0.15

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 OnboardingAvailability {
46
412
  /**
47
413
  * ID of this entity
@@ -367,43 +733,61 @@ interface UpdatePartnerFlowOptions {
367
733
  partnerFlow?: PartnerFlow;
368
734
  }
369
735
 
370
- declare function getOnboardingAvailability$1(httpClient: HttpClient): GetOnboardingAvailabilitySignature;
736
+ declare function getOnboardingAvailability$1(httpClient: HttpClient$2): GetOnboardingAvailabilitySignature;
371
737
  interface GetOnboardingAvailabilitySignature {
372
738
  /**
373
739
  * Fetch current state of onboarding availability for meta site.
374
740
  */
375
741
  (): Promise<GetOnboardingAvailabilityResponse & GetOnboardingAvailabilityResponseNonNullableFields>;
376
742
  }
377
- declare function updateCbdFlow$1(httpClient: HttpClient): UpdateCbdFlowSignature;
743
+ declare function updateCbdFlow$1(httpClient: HttpClient$2): UpdateCbdFlowSignature;
378
744
  interface UpdateCbdFlowSignature {
379
745
  /**
380
746
  * Update current state of CBD flow for meta site.
381
747
  */
382
748
  (options?: UpdateCbdFlowOptions | undefined): Promise<UpdateCbdFlowResponse & UpdateCbdFlowResponseNonNullableFields>;
383
749
  }
384
- declare function updateRestrictedGoodsFlow$1(httpClient: HttpClient): UpdateRestrictedGoodsFlowSignature;
750
+ declare function updateRestrictedGoodsFlow$1(httpClient: HttpClient$2): UpdateRestrictedGoodsFlowSignature;
385
751
  interface UpdateRestrictedGoodsFlowSignature {
386
752
  /**
387
753
  * Update current state of Restricted Goods flow for meta site.
388
754
  */
389
755
  (options?: UpdateRestrictedGoodsFlowOptions | undefined): Promise<UpdateRestrictedGoodsFlowResponse & UpdateRestrictedGoodsFlowResponseNonNullableFields>;
390
756
  }
391
- declare function updatePartnerFlow$1(httpClient: HttpClient): UpdatePartnerFlowSignature;
757
+ declare function updatePartnerFlow$1(httpClient: HttpClient$2): UpdatePartnerFlowSignature;
392
758
  interface UpdatePartnerFlowSignature {
393
759
  /**
394
760
  * Update current state of partner flow for meta site.
395
761
  */
396
762
  (options?: UpdatePartnerFlowOptions | undefined): Promise<UpdatePartnerFlowResponse & UpdatePartnerFlowResponseNonNullableFields>;
397
763
  }
398
- declare const onOnboardingAvailabilityCreated$1: EventDefinition<OnboardingAvailabilityCreatedEnvelope, "wix.cashier.onboarding_availability.v1.onboarding_availability_created">;
399
- declare const onOnboardingAvailabilityUpdated$1: EventDefinition<OnboardingAvailabilityUpdatedEnvelope, "wix.cashier.onboarding_availability.v1.onboarding_availability_updated">;
764
+ declare const onOnboardingAvailabilityCreated$1: EventDefinition$4<OnboardingAvailabilityCreatedEnvelope, "wix.cashier.onboarding_availability.v1.onboarding_availability_created">;
765
+ declare const onOnboardingAvailabilityUpdated$1: EventDefinition$4<OnboardingAvailabilityUpdatedEnvelope, "wix.cashier.onboarding_availability.v1.onboarding_availability_updated">;
766
+
767
+ type EventDefinition$3<Payload = unknown, Type extends string = string> = {
768
+ __type: 'event-definition';
769
+ type: Type;
770
+ isDomainEvent?: boolean;
771
+ transformations?: (envelope: unknown) => Payload;
772
+ __payload: Payload;
773
+ };
774
+ declare function EventDefinition$3<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$3<Payload, Type>;
775
+ type EventHandler$3<T extends EventDefinition$3> = (payload: T['__payload']) => void | Promise<void>;
776
+ type BuildEventDefinition$3<T extends EventDefinition$3<any, string>> = (handler: EventHandler$3<T>) => void;
777
+
778
+ declare global {
779
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
780
+ interface SymbolConstructor {
781
+ readonly observable: symbol;
782
+ }
783
+ }
400
784
 
401
- declare function createEventModule$1<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
785
+ declare function createEventModule$1<T extends EventDefinition$3<any, string>>(eventDefinition: T): BuildEventDefinition$3<T> & T;
402
786
 
403
- declare const getOnboardingAvailability: BuildRESTFunction<typeof getOnboardingAvailability$1> & typeof getOnboardingAvailability$1;
404
- declare const updateCbdFlow: BuildRESTFunction<typeof updateCbdFlow$1> & typeof updateCbdFlow$1;
405
- declare const updateRestrictedGoodsFlow: BuildRESTFunction<typeof updateRestrictedGoodsFlow$1> & typeof updateRestrictedGoodsFlow$1;
406
- declare const updatePartnerFlow: BuildRESTFunction<typeof updatePartnerFlow$1> & typeof updatePartnerFlow$1;
787
+ declare const getOnboardingAvailability: MaybeContext$2<BuildRESTFunction$2<typeof getOnboardingAvailability$1> & typeof getOnboardingAvailability$1>;
788
+ declare const updateCbdFlow: MaybeContext$2<BuildRESTFunction$2<typeof updateCbdFlow$1> & typeof updateCbdFlow$1>;
789
+ declare const updateRestrictedGoodsFlow: MaybeContext$2<BuildRESTFunction$2<typeof updateRestrictedGoodsFlow$1> & typeof updateRestrictedGoodsFlow$1>;
790
+ declare const updatePartnerFlow: MaybeContext$2<BuildRESTFunction$2<typeof updatePartnerFlow$1> & typeof updatePartnerFlow$1>;
407
791
 
408
792
  type _publicOnOnboardingAvailabilityCreatedType = typeof onOnboardingAvailabilityCreated$1;
409
793
  /** */
@@ -453,6 +837,416 @@ declare namespace index_d$2 {
453
837
  export { type ActionEvent$1 as ActionEvent, type index_d$2_AttestationInfo as AttestationInfo, type BaseEventMetadata$1 as BaseEventMetadata, type index_d$2_CbdFlow as CbdFlow, type DomainEvent$1 as DomainEvent, type DomainEventBodyOneOf$1 as DomainEventBodyOneOf, type EntityCreatedEvent$1 as EntityCreatedEvent, type EntityDeletedEvent$1 as EntityDeletedEvent, type EntityUpdatedEvent$1 as EntityUpdatedEvent, type EventMetadata$1 as EventMetadata, type index_d$2_GetOnboardingAvailabilityRequest as GetOnboardingAvailabilityRequest, type index_d$2_GetOnboardingAvailabilityResponse as GetOnboardingAvailabilityResponse, type index_d$2_GetOnboardingAvailabilityResponseNonNullableFields as GetOnboardingAvailabilityResponseNonNullableFields, type IdentificationData$1 as IdentificationData, type IdentificationDataIdOneOf$1 as IdentificationDataIdOneOf, type MessageEnvelope$1 as MessageEnvelope, type index_d$2_OnboardingAvailability as OnboardingAvailability, type index_d$2_OnboardingAvailabilityCreatedEnvelope as OnboardingAvailabilityCreatedEnvelope, type index_d$2_OnboardingAvailabilityUpdatedEnvelope as OnboardingAvailabilityUpdatedEnvelope, type index_d$2_PartnerFlow as PartnerFlow, index_d$2_PartnerFlowStatus as PartnerFlowStatus, type RestoreInfo$1 as RestoreInfo, index_d$2_RestrictedGoodsCategory as RestrictedGoodsCategory, type index_d$2_RestrictedGoodsFlow as RestrictedGoodsFlow, index_d$2_RestrictedGoodsFlowStatus as RestrictedGoodsFlowStatus, Status$1 as Status, type index_d$2_UpdateCbdFlowOptions as UpdateCbdFlowOptions, type index_d$2_UpdateCbdFlowRequest as UpdateCbdFlowRequest, type index_d$2_UpdateCbdFlowResponse as UpdateCbdFlowResponse, type index_d$2_UpdateCbdFlowResponseNonNullableFields as UpdateCbdFlowResponseNonNullableFields, type index_d$2_UpdatePartnerFlowOptions as UpdatePartnerFlowOptions, type index_d$2_UpdatePartnerFlowRequest as UpdatePartnerFlowRequest, type index_d$2_UpdatePartnerFlowResponse as UpdatePartnerFlowResponse, type index_d$2_UpdatePartnerFlowResponseNonNullableFields as UpdatePartnerFlowResponseNonNullableFields, type index_d$2_UpdateRestrictedGoodsFlowOptions as UpdateRestrictedGoodsFlowOptions, type index_d$2_UpdateRestrictedGoodsFlowRequest as UpdateRestrictedGoodsFlowRequest, type index_d$2_UpdateRestrictedGoodsFlowResponse as UpdateRestrictedGoodsFlowResponse, type index_d$2_UpdateRestrictedGoodsFlowResponseNonNullableFields as UpdateRestrictedGoodsFlowResponseNonNullableFields, WebhookIdentityType$1 as WebhookIdentityType, type index_d$2__publicOnOnboardingAvailabilityCreatedType as _publicOnOnboardingAvailabilityCreatedType, type index_d$2__publicOnOnboardingAvailabilityUpdatedType as _publicOnOnboardingAvailabilityUpdatedType, index_d$2_getOnboardingAvailability as getOnboardingAvailability, index_d$2_onOnboardingAvailabilityCreated as onOnboardingAvailabilityCreated, index_d$2_onOnboardingAvailabilityUpdated as onOnboardingAvailabilityUpdated, onOnboardingAvailabilityCreated$1 as publicOnOnboardingAvailabilityCreated, onOnboardingAvailabilityUpdated$1 as publicOnOnboardingAvailabilityUpdated, index_d$2_updateCbdFlow as updateCbdFlow, index_d$2_updatePartnerFlow as updatePartnerFlow, index_d$2_updateRestrictedGoodsFlow as updateRestrictedGoodsFlow };
454
838
  }
455
839
 
840
+ type HostModule$1<T, H extends Host$1> = {
841
+ __type: 'host';
842
+ create(host: H): T;
843
+ };
844
+ type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
845
+ type Host$1<Environment = unknown> = {
846
+ channel: {
847
+ observeState(callback: (props: unknown, environment: Environment) => unknown): {
848
+ disconnect: () => void;
849
+ } | Promise<{
850
+ disconnect: () => void;
851
+ }>;
852
+ };
853
+ environment?: Environment;
854
+ /**
855
+ * Optional bast url to use for API requests, for example `www.wixapis.com`
856
+ */
857
+ apiBaseUrl?: string;
858
+ /**
859
+ * Possible data to be provided by every host, for cross cutting concerns
860
+ * like internationalization, billing, etc.
861
+ */
862
+ essentials?: {
863
+ /**
864
+ * The language of the currently viewed session
865
+ */
866
+ language?: string;
867
+ /**
868
+ * The locale of the currently viewed session
869
+ */
870
+ locale?: string;
871
+ /**
872
+ * Any headers that should be passed through to the API requests
873
+ */
874
+ passThroughHeaders?: Record<string, string>;
875
+ };
876
+ };
877
+
878
+ type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
879
+ interface HttpClient$1 {
880
+ request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
881
+ fetchWithAuth: typeof fetch;
882
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
883
+ getActiveToken?: () => string | undefined;
884
+ }
885
+ type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
886
+ type HttpResponse$1<T = any> = {
887
+ data: T;
888
+ status: number;
889
+ statusText: string;
890
+ headers: any;
891
+ request?: any;
892
+ };
893
+ type RequestOptions$1<_TResponse = any, Data = any> = {
894
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
895
+ url: string;
896
+ data?: Data;
897
+ params?: URLSearchParams;
898
+ } & APIMetadata$1;
899
+ type APIMetadata$1 = {
900
+ methodFqn?: string;
901
+ entityFqdn?: string;
902
+ packageName?: string;
903
+ };
904
+ type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
905
+ type EventDefinition$2<Payload = unknown, Type extends string = string> = {
906
+ __type: 'event-definition';
907
+ type: Type;
908
+ isDomainEvent?: boolean;
909
+ transformations?: (envelope: unknown) => Payload;
910
+ __payload: Payload;
911
+ };
912
+ declare function EventDefinition$2<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$2<Payload, Type>;
913
+ type EventHandler$2<T extends EventDefinition$2> = (payload: T['__payload']) => void | Promise<void>;
914
+ type BuildEventDefinition$2<T extends EventDefinition$2<any, string>> = (handler: EventHandler$2<T>) => void;
915
+
916
+ type ServicePluginMethodInput$1 = {
917
+ request: any;
918
+ metadata: any;
919
+ };
920
+ type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
921
+ type ServicePluginMethodMetadata$1 = {
922
+ name: string;
923
+ primaryHttpMappingPath: string;
924
+ transformations: {
925
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
926
+ toREST: (...args: unknown[]) => unknown;
927
+ };
928
+ };
929
+ type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
930
+ __type: 'service-plugin-definition';
931
+ componentType: string;
932
+ methods: ServicePluginMethodMetadata$1[];
933
+ __contract: Contract;
934
+ };
935
+ declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
936
+ type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
937
+ declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
938
+
939
+ type RequestContext$1 = {
940
+ isSSR: boolean;
941
+ host: string;
942
+ protocol?: string;
943
+ };
944
+ type ResponseTransformer$1 = (data: any, headers?: any) => any;
945
+ /**
946
+ * Ambassador request options types are copied mostly from AxiosRequestConfig.
947
+ * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
948
+ * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
949
+ */
950
+ type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
951
+ type AmbassadorRequestOptions$1<T = any> = {
952
+ _?: T;
953
+ url?: string;
954
+ method?: Method$1;
955
+ params?: any;
956
+ data?: any;
957
+ transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
958
+ };
959
+ type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
960
+ __isAmbassador: boolean;
961
+ };
962
+ type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
963
+ type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
964
+
965
+ declare global {
966
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
967
+ interface SymbolConstructor {
968
+ readonly observable: symbol;
969
+ }
970
+ }
971
+
972
+ declare const emptyObjectSymbol$1: unique symbol;
973
+
974
+ /**
975
+ Represents a strictly empty plain object, the `{}` value.
976
+
977
+ 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)).
978
+
979
+ @example
980
+ ```
981
+ import type {EmptyObject} from 'type-fest';
982
+
983
+ // The following illustrates the problem with `{}`.
984
+ const foo1: {} = {}; // Pass
985
+ const foo2: {} = []; // Pass
986
+ const foo3: {} = 42; // Pass
987
+ const foo4: {} = {a: 1}; // Pass
988
+
989
+ // With `EmptyObject` only the first case is valid.
990
+ const bar1: EmptyObject = {}; // Pass
991
+ const bar2: EmptyObject = 42; // Fail
992
+ const bar3: EmptyObject = []; // Fail
993
+ const bar4: EmptyObject = {a: 1}; // Fail
994
+ ```
995
+
996
+ 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}.
997
+
998
+ @category Object
999
+ */
1000
+ type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
1001
+
1002
+ /**
1003
+ Returns a boolean for whether the two given types are equal.
1004
+
1005
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
1006
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
1007
+
1008
+ Use-cases:
1009
+ - If you want to make a conditional branch based on the result of a comparison of two types.
1010
+
1011
+ @example
1012
+ ```
1013
+ import type {IsEqual} from 'type-fest';
1014
+
1015
+ // This type returns a boolean for whether the given array includes the given item.
1016
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
1017
+ type Includes<Value extends readonly any[], Item> =
1018
+ Value extends readonly [Value[0], ...infer rest]
1019
+ ? IsEqual<Value[0], Item> extends true
1020
+ ? true
1021
+ : Includes<rest, Item>
1022
+ : false;
1023
+ ```
1024
+
1025
+ @category Type Guard
1026
+ @category Utilities
1027
+ */
1028
+ type IsEqual$1<A, B> =
1029
+ (<G>() => G extends A ? 1 : 2) extends
1030
+ (<G>() => G extends B ? 1 : 2)
1031
+ ? true
1032
+ : false;
1033
+
1034
+ /**
1035
+ Filter out keys from an object.
1036
+
1037
+ Returns `never` if `Exclude` is strictly equal to `Key`.
1038
+ Returns `never` if `Key` extends `Exclude`.
1039
+ Returns `Key` otherwise.
1040
+
1041
+ @example
1042
+ ```
1043
+ type Filtered = Filter<'foo', 'foo'>;
1044
+ //=> never
1045
+ ```
1046
+
1047
+ @example
1048
+ ```
1049
+ type Filtered = Filter<'bar', string>;
1050
+ //=> never
1051
+ ```
1052
+
1053
+ @example
1054
+ ```
1055
+ type Filtered = Filter<'bar', 'foo'>;
1056
+ //=> 'bar'
1057
+ ```
1058
+
1059
+ @see {Except}
1060
+ */
1061
+ type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
1062
+
1063
+ type ExceptOptions$1 = {
1064
+ /**
1065
+ Disallow assigning non-specified properties.
1066
+
1067
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
1068
+
1069
+ @default false
1070
+ */
1071
+ requireExactProps?: boolean;
1072
+ };
1073
+
1074
+ /**
1075
+ Create a type from an object type without certain keys.
1076
+
1077
+ We recommend setting the `requireExactProps` option to `true`.
1078
+
1079
+ 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.
1080
+
1081
+ 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)).
1082
+
1083
+ @example
1084
+ ```
1085
+ import type {Except} from 'type-fest';
1086
+
1087
+ type Foo = {
1088
+ a: number;
1089
+ b: string;
1090
+ };
1091
+
1092
+ type FooWithoutA = Except<Foo, 'a'>;
1093
+ //=> {b: string}
1094
+
1095
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
1096
+ //=> errors: 'a' does not exist in type '{ b: string; }'
1097
+
1098
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
1099
+ //=> {a: number} & Partial<Record<"b", never>>
1100
+
1101
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
1102
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
1103
+ ```
1104
+
1105
+ @category Object
1106
+ */
1107
+ type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
1108
+ [KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
1109
+ } & (Options['requireExactProps'] extends true
1110
+ ? Partial<Record<KeysType, never>>
1111
+ : {});
1112
+
1113
+ /**
1114
+ Extract the keys from a type where the value type of the key extends the given `Condition`.
1115
+
1116
+ Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
1117
+
1118
+ @example
1119
+ ```
1120
+ import type {ConditionalKeys} from 'type-fest';
1121
+
1122
+ interface Example {
1123
+ a: string;
1124
+ b: string | number;
1125
+ c?: string;
1126
+ d: {};
1127
+ }
1128
+
1129
+ type StringKeysOnly = ConditionalKeys<Example, string>;
1130
+ //=> 'a'
1131
+ ```
1132
+
1133
+ To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
1134
+
1135
+ @example
1136
+ ```
1137
+ import type {ConditionalKeys} from 'type-fest';
1138
+
1139
+ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
1140
+ //=> 'a' | 'c'
1141
+ ```
1142
+
1143
+ @category Object
1144
+ */
1145
+ type ConditionalKeys$1<Base, Condition> = NonNullable<
1146
+ // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
1147
+ {
1148
+ // Map through all the keys of the given base type.
1149
+ [Key in keyof Base]:
1150
+ // Pick only keys with types extending the given `Condition` type.
1151
+ Base[Key] extends Condition
1152
+ // Retain this key since the condition passes.
1153
+ ? Key
1154
+ // Discard this key since the condition fails.
1155
+ : never;
1156
+
1157
+ // Convert the produced object into a union type of the keys which passed the conditional test.
1158
+ }[keyof Base]
1159
+ >;
1160
+
1161
+ /**
1162
+ Exclude keys from a shape that matches the given `Condition`.
1163
+
1164
+ 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.
1165
+
1166
+ @example
1167
+ ```
1168
+ import type {Primitive, ConditionalExcept} from 'type-fest';
1169
+
1170
+ class Awesome {
1171
+ name: string;
1172
+ successes: number;
1173
+ failures: bigint;
1174
+
1175
+ run() {}
1176
+ }
1177
+
1178
+ type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
1179
+ //=> {run: () => void}
1180
+ ```
1181
+
1182
+ @example
1183
+ ```
1184
+ import type {ConditionalExcept} from 'type-fest';
1185
+
1186
+ interface Example {
1187
+ a: string;
1188
+ b: string | number;
1189
+ c: () => void;
1190
+ d: {};
1191
+ }
1192
+
1193
+ type NonStringKeysOnly = ConditionalExcept<Example, string>;
1194
+ //=> {b: string | number; c: () => void; d: {}}
1195
+ ```
1196
+
1197
+ @category Object
1198
+ */
1199
+ type ConditionalExcept$1<Base, Condition> = Except$1<
1200
+ Base,
1201
+ ConditionalKeys$1<Base, Condition>
1202
+ >;
1203
+
1204
+ /**
1205
+ * Descriptors are objects that describe the API of a module, and the module
1206
+ * can either be a REST module or a host module.
1207
+ * This type is recursive, so it can describe nested modules.
1208
+ */
1209
+ type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$2<any> | ServicePluginDefinition$1<any> | {
1210
+ [key: string]: Descriptors$1 | PublicMetadata$1 | any;
1211
+ };
1212
+ /**
1213
+ * This type takes in a descriptors object of a certain Host (including an `unknown` host)
1214
+ * and returns an object with the same structure, but with all descriptors replaced with their API.
1215
+ * Any non-descriptor properties are removed from the returned object, including descriptors that
1216
+ * do not match the given host (as they will not work with the given host).
1217
+ */
1218
+ type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
1219
+ done: T;
1220
+ recurse: T extends {
1221
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
1222
+ } ? 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<{
1223
+ [Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
1224
+ -1,
1225
+ 0,
1226
+ 1,
1227
+ 2,
1228
+ 3,
1229
+ 4,
1230
+ 5
1231
+ ][Depth]> : never;
1232
+ }, EmptyObject$1>;
1233
+ }[Depth extends -1 ? 'done' : 'recurse'];
1234
+ type PublicMetadata$1 = {
1235
+ PACKAGE_NAME?: string;
1236
+ };
1237
+
1238
+ declare global {
1239
+ interface ContextualClient {
1240
+ }
1241
+ }
1242
+ /**
1243
+ * A type used to create concerete types from SDK descriptors in
1244
+ * case a contextual client is available.
1245
+ */
1246
+ type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
1247
+ host: Host$1;
1248
+ } ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
1249
+
456
1250
  /** Provider platform event */
457
1251
  interface ProviderPlatformEvent extends ProviderPlatformEventResourceOneOf {
458
1252
  /** Refund event data. */
@@ -542,7 +1336,7 @@ interface SubmitEventRequest {
542
1336
  interface SubmitEventResponse {
543
1337
  }
544
1338
 
545
- declare function submitEvent$1(httpClient: HttpClient): SubmitEventSignature;
1339
+ declare function submitEvent$1(httpClient: HttpClient$1): SubmitEventSignature;
546
1340
  interface SubmitEventSignature {
547
1341
  /**
548
1342
  * This Wix API is used by a Payment Service Provider (PSP) to send webhooks about payment and refund states to Wix.
@@ -559,7 +1353,7 @@ interface SubmitEventSignature {
559
1353
  (event: ProviderPlatformEvent): Promise<void>;
560
1354
  }
561
1355
 
562
- declare const submitEvent: BuildRESTFunction<typeof submitEvent$1> & typeof submitEvent$1;
1356
+ declare const submitEvent: MaybeContext$1<BuildRESTFunction$1<typeof submitEvent$1> & typeof submitEvent$1>;
563
1357
 
564
1358
  type index_d$1_CardDetails = CardDetails;
565
1359
  type index_d$1_CardReference = CardReference;
@@ -577,6 +1371,416 @@ declare namespace index_d$1 {
577
1371
  export { type index_d$1_CardDetails as CardDetails, type index_d$1_CardReference as CardReference, type index_d$1_CredentialsOnFile as CredentialsOnFile, type index_d$1_CredentialsOnFileInfoOneOf as CredentialsOnFileInfoOneOf, type index_d$1_PaymentMethodReference as PaymentMethodReference, type index_d$1_ProviderPlatformEvent as ProviderPlatformEvent, type index_d$1_ProviderPlatformEventResourceOneOf as ProviderPlatformEventResourceOneOf, type index_d$1_RefundEvent as RefundEvent, type index_d$1_SubmitEventRequest as SubmitEventRequest, type index_d$1_SubmitEventResponse as SubmitEventResponse, type index_d$1_TransactionEvent as TransactionEvent, index_d$1_submitEvent as submitEvent };
578
1372
  }
579
1373
 
1374
+ type HostModule<T, H extends Host> = {
1375
+ __type: 'host';
1376
+ create(host: H): T;
1377
+ };
1378
+ type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
1379
+ type Host<Environment = unknown> = {
1380
+ channel: {
1381
+ observeState(callback: (props: unknown, environment: Environment) => unknown): {
1382
+ disconnect: () => void;
1383
+ } | Promise<{
1384
+ disconnect: () => void;
1385
+ }>;
1386
+ };
1387
+ environment?: Environment;
1388
+ /**
1389
+ * Optional bast url to use for API requests, for example `www.wixapis.com`
1390
+ */
1391
+ apiBaseUrl?: string;
1392
+ /**
1393
+ * Possible data to be provided by every host, for cross cutting concerns
1394
+ * like internationalization, billing, etc.
1395
+ */
1396
+ essentials?: {
1397
+ /**
1398
+ * The language of the currently viewed session
1399
+ */
1400
+ language?: string;
1401
+ /**
1402
+ * The locale of the currently viewed session
1403
+ */
1404
+ locale?: string;
1405
+ /**
1406
+ * Any headers that should be passed through to the API requests
1407
+ */
1408
+ passThroughHeaders?: Record<string, string>;
1409
+ };
1410
+ };
1411
+
1412
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
1413
+ interface HttpClient {
1414
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
1415
+ fetchWithAuth: typeof fetch;
1416
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
1417
+ getActiveToken?: () => string | undefined;
1418
+ }
1419
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
1420
+ type HttpResponse<T = any> = {
1421
+ data: T;
1422
+ status: number;
1423
+ statusText: string;
1424
+ headers: any;
1425
+ request?: any;
1426
+ };
1427
+ type RequestOptions<_TResponse = any, Data = any> = {
1428
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
1429
+ url: string;
1430
+ data?: Data;
1431
+ params?: URLSearchParams;
1432
+ } & APIMetadata;
1433
+ type APIMetadata = {
1434
+ methodFqn?: string;
1435
+ entityFqdn?: string;
1436
+ packageName?: string;
1437
+ };
1438
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
1439
+ type EventDefinition$1<Payload = unknown, Type extends string = string> = {
1440
+ __type: 'event-definition';
1441
+ type: Type;
1442
+ isDomainEvent?: boolean;
1443
+ transformations?: (envelope: unknown) => Payload;
1444
+ __payload: Payload;
1445
+ };
1446
+ declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
1447
+ type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
1448
+ type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
1449
+
1450
+ type ServicePluginMethodInput = {
1451
+ request: any;
1452
+ metadata: any;
1453
+ };
1454
+ type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
1455
+ type ServicePluginMethodMetadata = {
1456
+ name: string;
1457
+ primaryHttpMappingPath: string;
1458
+ transformations: {
1459
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput;
1460
+ toREST: (...args: unknown[]) => unknown;
1461
+ };
1462
+ };
1463
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
1464
+ __type: 'service-plugin-definition';
1465
+ componentType: string;
1466
+ methods: ServicePluginMethodMetadata[];
1467
+ __contract: Contract;
1468
+ };
1469
+ declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
1470
+ type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
1471
+ declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
1472
+
1473
+ type RequestContext = {
1474
+ isSSR: boolean;
1475
+ host: string;
1476
+ protocol?: string;
1477
+ };
1478
+ type ResponseTransformer = (data: any, headers?: any) => any;
1479
+ /**
1480
+ * Ambassador request options types are copied mostly from AxiosRequestConfig.
1481
+ * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
1482
+ * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
1483
+ */
1484
+ type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
1485
+ type AmbassadorRequestOptions<T = any> = {
1486
+ _?: T;
1487
+ url?: string;
1488
+ method?: Method;
1489
+ params?: any;
1490
+ data?: any;
1491
+ transformResponse?: ResponseTransformer | ResponseTransformer[];
1492
+ };
1493
+ type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
1494
+ __isAmbassador: boolean;
1495
+ };
1496
+ type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
1497
+ type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
1498
+
1499
+ declare global {
1500
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
1501
+ interface SymbolConstructor {
1502
+ readonly observable: symbol;
1503
+ }
1504
+ }
1505
+
1506
+ declare const emptyObjectSymbol: unique symbol;
1507
+
1508
+ /**
1509
+ Represents a strictly empty plain object, the `{}` value.
1510
+
1511
+ 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)).
1512
+
1513
+ @example
1514
+ ```
1515
+ import type {EmptyObject} from 'type-fest';
1516
+
1517
+ // The following illustrates the problem with `{}`.
1518
+ const foo1: {} = {}; // Pass
1519
+ const foo2: {} = []; // Pass
1520
+ const foo3: {} = 42; // Pass
1521
+ const foo4: {} = {a: 1}; // Pass
1522
+
1523
+ // With `EmptyObject` only the first case is valid.
1524
+ const bar1: EmptyObject = {}; // Pass
1525
+ const bar2: EmptyObject = 42; // Fail
1526
+ const bar3: EmptyObject = []; // Fail
1527
+ const bar4: EmptyObject = {a: 1}; // Fail
1528
+ ```
1529
+
1530
+ 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}.
1531
+
1532
+ @category Object
1533
+ */
1534
+ type EmptyObject = {[emptyObjectSymbol]?: never};
1535
+
1536
+ /**
1537
+ Returns a boolean for whether the two given types are equal.
1538
+
1539
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
1540
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
1541
+
1542
+ Use-cases:
1543
+ - If you want to make a conditional branch based on the result of a comparison of two types.
1544
+
1545
+ @example
1546
+ ```
1547
+ import type {IsEqual} from 'type-fest';
1548
+
1549
+ // This type returns a boolean for whether the given array includes the given item.
1550
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
1551
+ type Includes<Value extends readonly any[], Item> =
1552
+ Value extends readonly [Value[0], ...infer rest]
1553
+ ? IsEqual<Value[0], Item> extends true
1554
+ ? true
1555
+ : Includes<rest, Item>
1556
+ : false;
1557
+ ```
1558
+
1559
+ @category Type Guard
1560
+ @category Utilities
1561
+ */
1562
+ type IsEqual<A, B> =
1563
+ (<G>() => G extends A ? 1 : 2) extends
1564
+ (<G>() => G extends B ? 1 : 2)
1565
+ ? true
1566
+ : false;
1567
+
1568
+ /**
1569
+ Filter out keys from an object.
1570
+
1571
+ Returns `never` if `Exclude` is strictly equal to `Key`.
1572
+ Returns `never` if `Key` extends `Exclude`.
1573
+ Returns `Key` otherwise.
1574
+
1575
+ @example
1576
+ ```
1577
+ type Filtered = Filter<'foo', 'foo'>;
1578
+ //=> never
1579
+ ```
1580
+
1581
+ @example
1582
+ ```
1583
+ type Filtered = Filter<'bar', string>;
1584
+ //=> never
1585
+ ```
1586
+
1587
+ @example
1588
+ ```
1589
+ type Filtered = Filter<'bar', 'foo'>;
1590
+ //=> 'bar'
1591
+ ```
1592
+
1593
+ @see {Except}
1594
+ */
1595
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
1596
+
1597
+ type ExceptOptions = {
1598
+ /**
1599
+ Disallow assigning non-specified properties.
1600
+
1601
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
1602
+
1603
+ @default false
1604
+ */
1605
+ requireExactProps?: boolean;
1606
+ };
1607
+
1608
+ /**
1609
+ Create a type from an object type without certain keys.
1610
+
1611
+ We recommend setting the `requireExactProps` option to `true`.
1612
+
1613
+ 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.
1614
+
1615
+ 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)).
1616
+
1617
+ @example
1618
+ ```
1619
+ import type {Except} from 'type-fest';
1620
+
1621
+ type Foo = {
1622
+ a: number;
1623
+ b: string;
1624
+ };
1625
+
1626
+ type FooWithoutA = Except<Foo, 'a'>;
1627
+ //=> {b: string}
1628
+
1629
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
1630
+ //=> errors: 'a' does not exist in type '{ b: string; }'
1631
+
1632
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
1633
+ //=> {a: number} & Partial<Record<"b", never>>
1634
+
1635
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
1636
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
1637
+ ```
1638
+
1639
+ @category Object
1640
+ */
1641
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
1642
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
1643
+ } & (Options['requireExactProps'] extends true
1644
+ ? Partial<Record<KeysType, never>>
1645
+ : {});
1646
+
1647
+ /**
1648
+ Extract the keys from a type where the value type of the key extends the given `Condition`.
1649
+
1650
+ Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
1651
+
1652
+ @example
1653
+ ```
1654
+ import type {ConditionalKeys} from 'type-fest';
1655
+
1656
+ interface Example {
1657
+ a: string;
1658
+ b: string | number;
1659
+ c?: string;
1660
+ d: {};
1661
+ }
1662
+
1663
+ type StringKeysOnly = ConditionalKeys<Example, string>;
1664
+ //=> 'a'
1665
+ ```
1666
+
1667
+ To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
1668
+
1669
+ @example
1670
+ ```
1671
+ import type {ConditionalKeys} from 'type-fest';
1672
+
1673
+ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
1674
+ //=> 'a' | 'c'
1675
+ ```
1676
+
1677
+ @category Object
1678
+ */
1679
+ type ConditionalKeys<Base, Condition> = NonNullable<
1680
+ // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
1681
+ {
1682
+ // Map through all the keys of the given base type.
1683
+ [Key in keyof Base]:
1684
+ // Pick only keys with types extending the given `Condition` type.
1685
+ Base[Key] extends Condition
1686
+ // Retain this key since the condition passes.
1687
+ ? Key
1688
+ // Discard this key since the condition fails.
1689
+ : never;
1690
+
1691
+ // Convert the produced object into a union type of the keys which passed the conditional test.
1692
+ }[keyof Base]
1693
+ >;
1694
+
1695
+ /**
1696
+ Exclude keys from a shape that matches the given `Condition`.
1697
+
1698
+ 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.
1699
+
1700
+ @example
1701
+ ```
1702
+ import type {Primitive, ConditionalExcept} from 'type-fest';
1703
+
1704
+ class Awesome {
1705
+ name: string;
1706
+ successes: number;
1707
+ failures: bigint;
1708
+
1709
+ run() {}
1710
+ }
1711
+
1712
+ type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
1713
+ //=> {run: () => void}
1714
+ ```
1715
+
1716
+ @example
1717
+ ```
1718
+ import type {ConditionalExcept} from 'type-fest';
1719
+
1720
+ interface Example {
1721
+ a: string;
1722
+ b: string | number;
1723
+ c: () => void;
1724
+ d: {};
1725
+ }
1726
+
1727
+ type NonStringKeysOnly = ConditionalExcept<Example, string>;
1728
+ //=> {b: string | number; c: () => void; d: {}}
1729
+ ```
1730
+
1731
+ @category Object
1732
+ */
1733
+ type ConditionalExcept<Base, Condition> = Except<
1734
+ Base,
1735
+ ConditionalKeys<Base, Condition>
1736
+ >;
1737
+
1738
+ /**
1739
+ * Descriptors are objects that describe the API of a module, and the module
1740
+ * can either be a REST module or a host module.
1741
+ * This type is recursive, so it can describe nested modules.
1742
+ */
1743
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition$1<any> | ServicePluginDefinition<any> | {
1744
+ [key: string]: Descriptors | PublicMetadata | any;
1745
+ };
1746
+ /**
1747
+ * This type takes in a descriptors object of a certain Host (including an `unknown` host)
1748
+ * and returns an object with the same structure, but with all descriptors replaced with their API.
1749
+ * Any non-descriptor properties are removed from the returned object, including descriptors that
1750
+ * do not match the given host (as they will not work with the given host).
1751
+ */
1752
+ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
1753
+ done: T;
1754
+ recurse: T extends {
1755
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
1756
+ } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition$1<any> ? BuildEventDefinition$1<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
1757
+ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
1758
+ -1,
1759
+ 0,
1760
+ 1,
1761
+ 2,
1762
+ 3,
1763
+ 4,
1764
+ 5
1765
+ ][Depth]> : never;
1766
+ }, EmptyObject>;
1767
+ }[Depth extends -1 ? 'done' : 'recurse'];
1768
+ type PublicMetadata = {
1769
+ PACKAGE_NAME?: string;
1770
+ };
1771
+
1772
+ declare global {
1773
+ interface ContextualClient {
1774
+ }
1775
+ }
1776
+ /**
1777
+ * A type used to create concerete types from SDK descriptors in
1778
+ * case a contextual client is available.
1779
+ */
1780
+ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
1781
+ host: Host;
1782
+ } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
1783
+
580
1784
  /**
581
1785
  * A refund a record of an attempt of
582
1786
  * returning funds for a charge from a merchant to a customer to who has made a purchase.
@@ -1264,16 +2468,34 @@ interface GetRefundabilitySignature {
1264
2468
  */
1265
2469
  (chargeId: string): Promise<GetRefundabilityResponse & GetRefundabilityResponseNonNullableFields>;
1266
2470
  }
1267
- declare const onRefundCreated$1: EventDefinition<RefundCreatedEnvelope, "wix.payments.refunds.v1.refund_created">;
1268
- declare const onRefundUpdated$1: EventDefinition<RefundUpdatedEnvelope, "wix.payments.refunds.v1.refund_updated">;
2471
+ declare const onRefundCreated$1: EventDefinition$1<RefundCreatedEnvelope, "wix.payments.refunds.v1.refund_created">;
2472
+ declare const onRefundUpdated$1: EventDefinition$1<RefundUpdatedEnvelope, "wix.payments.refunds.v1.refund_updated">;
2473
+
2474
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
2475
+ __type: 'event-definition';
2476
+ type: Type;
2477
+ isDomainEvent?: boolean;
2478
+ transformations?: (envelope: unknown) => Payload;
2479
+ __payload: Payload;
2480
+ };
2481
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
2482
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
2483
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
2484
+
2485
+ declare global {
2486
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
2487
+ interface SymbolConstructor {
2488
+ readonly observable: symbol;
2489
+ }
2490
+ }
1269
2491
 
1270
2492
  declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
1271
2493
 
1272
- declare const createRefund: BuildRESTFunction<typeof createRefund$1> & typeof createRefund$1;
1273
- declare const getRefund: BuildRESTFunction<typeof getRefund$1> & typeof getRefund$1;
1274
- declare const queryRefunds: BuildRESTFunction<typeof queryRefunds$1> & typeof queryRefunds$1;
1275
- declare const updateExtendedFields: BuildRESTFunction<typeof updateExtendedFields$1> & typeof updateExtendedFields$1;
1276
- declare const getRefundability: BuildRESTFunction<typeof getRefundability$1> & typeof getRefundability$1;
2494
+ declare const createRefund: MaybeContext<BuildRESTFunction<typeof createRefund$1> & typeof createRefund$1>;
2495
+ declare const getRefund: MaybeContext<BuildRESTFunction<typeof getRefund$1> & typeof getRefund$1>;
2496
+ declare const queryRefunds: MaybeContext<BuildRESTFunction<typeof queryRefunds$1> & typeof queryRefunds$1>;
2497
+ declare const updateExtendedFields: MaybeContext<BuildRESTFunction<typeof updateExtendedFields$1> & typeof updateExtendedFields$1>;
2498
+ declare const getRefundability: MaybeContext<BuildRESTFunction<typeof getRefundability$1> & typeof getRefundability$1>;
1277
2499
 
1278
2500
  type _publicOnRefundCreatedType = typeof onRefundCreated$1;
1279
2501
  /** */