@wix/app-management 1.0.38 → 1.0.40

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,29 +1,127 @@
1
- type RESTFunctionDescriptor$4<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$4) => T;
2
- interface HttpClient$4 {
3
- request<TResponse, TData = any>(req: RequestOptionsFactory$4<TResponse, TData>): Promise<HttpResponse$4<TResponse>>;
1
+ type HostModule<T, H extends Host> = {
2
+ __type: 'host';
3
+ create(host: H): T;
4
+ };
5
+ type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
6
+ type Host<Environment = unknown> = {
7
+ channel: {
8
+ observeState(callback: (props: unknown, environment: Environment) => unknown): {
9
+ disconnect: () => void;
10
+ } | Promise<{
11
+ disconnect: () => void;
12
+ }>;
13
+ };
14
+ environment?: Environment;
15
+ /**
16
+ * Optional bast url to use for API requests, for example `www.wixapis.com`
17
+ */
18
+ apiBaseUrl?: string;
19
+ /**
20
+ * Possible data to be provided by every host, for cross cutting concerns
21
+ * like internationalization, billing, etc.
22
+ */
23
+ essentials?: {
24
+ /**
25
+ * The language of the currently viewed session
26
+ */
27
+ language?: string;
28
+ /**
29
+ * The locale of the currently viewed session
30
+ */
31
+ locale?: string;
32
+ /**
33
+ * Any headers that should be passed through to the API requests
34
+ */
35
+ passThroughHeaders?: Record<string, string>;
36
+ };
37
+ };
38
+
39
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
40
+ interface HttpClient {
41
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
4
42
  fetchWithAuth: typeof fetch;
5
43
  wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
44
+ getActiveToken?: () => string | undefined;
6
45
  }
7
- type RequestOptionsFactory$4<TResponse = any, TData = any> = (context: any) => RequestOptions$4<TResponse, TData>;
8
- type HttpResponse$4<T = any> = {
46
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
47
+ type HttpResponse<T = any> = {
9
48
  data: T;
10
49
  status: number;
11
50
  statusText: string;
12
51
  headers: any;
13
52
  request?: any;
14
53
  };
15
- type RequestOptions$4<_TResponse = any, Data = any> = {
54
+ type RequestOptions<_TResponse = any, Data = any> = {
16
55
  method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
17
56
  url: string;
18
57
  data?: Data;
19
58
  params?: URLSearchParams;
20
- } & APIMetadata$4;
21
- type APIMetadata$4 = {
59
+ } & APIMetadata;
60
+ type APIMetadata = {
22
61
  methodFqn?: string;
23
62
  entityFqdn?: string;
24
63
  packageName?: string;
25
64
  };
26
- type BuildRESTFunction$4<T extends RESTFunctionDescriptor$4> = T extends RESTFunctionDescriptor$4<infer U> ? U : never;
65
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
66
+ type EventDefinition$1<Payload = unknown, Type extends string = string> = {
67
+ __type: 'event-definition';
68
+ type: Type;
69
+ isDomainEvent?: boolean;
70
+ transformations?: (envelope: unknown) => Payload;
71
+ __payload: Payload;
72
+ };
73
+ declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
74
+ type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
75
+ type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
76
+
77
+ type ServicePluginMethodInput = {
78
+ request: any;
79
+ metadata: any;
80
+ };
81
+ type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
82
+ type ServicePluginMethodMetadata = {
83
+ name: string;
84
+ primaryHttpMappingPath: string;
85
+ transformations: {
86
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput;
87
+ toREST: (...args: unknown[]) => unknown;
88
+ };
89
+ };
90
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
91
+ __type: 'service-plugin-definition';
92
+ componentType: string;
93
+ methods: ServicePluginMethodMetadata[];
94
+ __contract: Contract;
95
+ };
96
+ declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
97
+ type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
98
+ declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
99
+
100
+ type RequestContext = {
101
+ isSSR: boolean;
102
+ host: string;
103
+ protocol?: string;
104
+ };
105
+ type ResponseTransformer = (data: any, headers?: any) => any;
106
+ /**
107
+ * Ambassador request options types are copied mostly from AxiosRequestConfig.
108
+ * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
109
+ * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
110
+ */
111
+ type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
112
+ type AmbassadorRequestOptions<T = any> = {
113
+ _?: T;
114
+ url?: string;
115
+ method?: Method;
116
+ params?: any;
117
+ data?: any;
118
+ transformResponse?: ResponseTransformer | ResponseTransformer[];
119
+ };
120
+ type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
121
+ __isAmbassador: boolean;
122
+ };
123
+ type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
124
+ type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
27
125
 
28
126
  declare global {
29
127
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
@@ -32,6 +130,284 @@ declare global {
32
130
  }
33
131
  }
34
132
 
133
+ declare const emptyObjectSymbol: unique symbol;
134
+
135
+ /**
136
+ Represents a strictly empty plain object, the `{}` value.
137
+
138
+ When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
139
+
140
+ @example
141
+ ```
142
+ import type {EmptyObject} from 'type-fest';
143
+
144
+ // The following illustrates the problem with `{}`.
145
+ const foo1: {} = {}; // Pass
146
+ const foo2: {} = []; // Pass
147
+ const foo3: {} = 42; // Pass
148
+ const foo4: {} = {a: 1}; // Pass
149
+
150
+ // With `EmptyObject` only the first case is valid.
151
+ const bar1: EmptyObject = {}; // Pass
152
+ const bar2: EmptyObject = 42; // Fail
153
+ const bar3: EmptyObject = []; // Fail
154
+ const bar4: EmptyObject = {a: 1}; // Fail
155
+ ```
156
+
157
+ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
158
+
159
+ @category Object
160
+ */
161
+ type EmptyObject = {[emptyObjectSymbol]?: never};
162
+
163
+ /**
164
+ Returns a boolean for whether the two given types are equal.
165
+
166
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
167
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
168
+
169
+ Use-cases:
170
+ - If you want to make a conditional branch based on the result of a comparison of two types.
171
+
172
+ @example
173
+ ```
174
+ import type {IsEqual} from 'type-fest';
175
+
176
+ // This type returns a boolean for whether the given array includes the given item.
177
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
178
+ type Includes<Value extends readonly any[], Item> =
179
+ Value extends readonly [Value[0], ...infer rest]
180
+ ? IsEqual<Value[0], Item> extends true
181
+ ? true
182
+ : Includes<rest, Item>
183
+ : false;
184
+ ```
185
+
186
+ @category Type Guard
187
+ @category Utilities
188
+ */
189
+ type IsEqual<A, B> =
190
+ (<G>() => G extends A ? 1 : 2) extends
191
+ (<G>() => G extends B ? 1 : 2)
192
+ ? true
193
+ : false;
194
+
195
+ /**
196
+ Filter out keys from an object.
197
+
198
+ Returns `never` if `Exclude` is strictly equal to `Key`.
199
+ Returns `never` if `Key` extends `Exclude`.
200
+ Returns `Key` otherwise.
201
+
202
+ @example
203
+ ```
204
+ type Filtered = Filter<'foo', 'foo'>;
205
+ //=> never
206
+ ```
207
+
208
+ @example
209
+ ```
210
+ type Filtered = Filter<'bar', string>;
211
+ //=> never
212
+ ```
213
+
214
+ @example
215
+ ```
216
+ type Filtered = Filter<'bar', 'foo'>;
217
+ //=> 'bar'
218
+ ```
219
+
220
+ @see {Except}
221
+ */
222
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
223
+
224
+ type ExceptOptions = {
225
+ /**
226
+ Disallow assigning non-specified properties.
227
+
228
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
229
+
230
+ @default false
231
+ */
232
+ requireExactProps?: boolean;
233
+ };
234
+
235
+ /**
236
+ Create a type from an object type without certain keys.
237
+
238
+ We recommend setting the `requireExactProps` option to `true`.
239
+
240
+ This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
241
+
242
+ This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
243
+
244
+ @example
245
+ ```
246
+ import type {Except} from 'type-fest';
247
+
248
+ type Foo = {
249
+ a: number;
250
+ b: string;
251
+ };
252
+
253
+ type FooWithoutA = Except<Foo, 'a'>;
254
+ //=> {b: string}
255
+
256
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
257
+ //=> errors: 'a' does not exist in type '{ b: string; }'
258
+
259
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
260
+ //=> {a: number} & Partial<Record<"b", never>>
261
+
262
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
263
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
264
+ ```
265
+
266
+ @category Object
267
+ */
268
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
269
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
270
+ } & (Options['requireExactProps'] extends true
271
+ ? Partial<Record<KeysType, never>>
272
+ : {});
273
+
274
+ /**
275
+ Extract the keys from a type where the value type of the key extends the given `Condition`.
276
+
277
+ Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
278
+
279
+ @example
280
+ ```
281
+ import type {ConditionalKeys} from 'type-fest';
282
+
283
+ interface Example {
284
+ a: string;
285
+ b: string | number;
286
+ c?: string;
287
+ d: {};
288
+ }
289
+
290
+ type StringKeysOnly = ConditionalKeys<Example, string>;
291
+ //=> 'a'
292
+ ```
293
+
294
+ To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
295
+
296
+ @example
297
+ ```
298
+ import type {ConditionalKeys} from 'type-fest';
299
+
300
+ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
301
+ //=> 'a' | 'c'
302
+ ```
303
+
304
+ @category Object
305
+ */
306
+ type ConditionalKeys<Base, Condition> = NonNullable<
307
+ // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
308
+ {
309
+ // Map through all the keys of the given base type.
310
+ [Key in keyof Base]:
311
+ // Pick only keys with types extending the given `Condition` type.
312
+ Base[Key] extends Condition
313
+ // Retain this key since the condition passes.
314
+ ? Key
315
+ // Discard this key since the condition fails.
316
+ : never;
317
+
318
+ // Convert the produced object into a union type of the keys which passed the conditional test.
319
+ }[keyof Base]
320
+ >;
321
+
322
+ /**
323
+ Exclude keys from a shape that matches the given `Condition`.
324
+
325
+ This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
326
+
327
+ @example
328
+ ```
329
+ import type {Primitive, ConditionalExcept} from 'type-fest';
330
+
331
+ class Awesome {
332
+ name: string;
333
+ successes: number;
334
+ failures: bigint;
335
+
336
+ run() {}
337
+ }
338
+
339
+ type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
340
+ //=> {run: () => void}
341
+ ```
342
+
343
+ @example
344
+ ```
345
+ import type {ConditionalExcept} from 'type-fest';
346
+
347
+ interface Example {
348
+ a: string;
349
+ b: string | number;
350
+ c: () => void;
351
+ d: {};
352
+ }
353
+
354
+ type NonStringKeysOnly = ConditionalExcept<Example, string>;
355
+ //=> {b: string | number; c: () => void; d: {}}
356
+ ```
357
+
358
+ @category Object
359
+ */
360
+ type ConditionalExcept<Base, Condition> = Except<
361
+ Base,
362
+ ConditionalKeys<Base, Condition>
363
+ >;
364
+
365
+ /**
366
+ * Descriptors are objects that describe the API of a module, and the module
367
+ * can either be a REST module or a host module.
368
+ * This type is recursive, so it can describe nested modules.
369
+ */
370
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition$1<any> | ServicePluginDefinition<any> | {
371
+ [key: string]: Descriptors | PublicMetadata | any;
372
+ };
373
+ /**
374
+ * This type takes in a descriptors object of a certain Host (including an `unknown` host)
375
+ * and returns an object with the same structure, but with all descriptors replaced with their API.
376
+ * Any non-descriptor properties are removed from the returned object, including descriptors that
377
+ * do not match the given host (as they will not work with the given host).
378
+ */
379
+ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
380
+ done: T;
381
+ recurse: T extends {
382
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
383
+ } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition$1<any> ? BuildEventDefinition$1<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
384
+ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
385
+ -1,
386
+ 0,
387
+ 1,
388
+ 2,
389
+ 3,
390
+ 4,
391
+ 5
392
+ ][Depth]> : never;
393
+ }, EmptyObject>;
394
+ }[Depth extends -1 ? 'done' : 'recurse'];
395
+ type PublicMetadata = {
396
+ PACKAGE_NAME?: string;
397
+ };
398
+
399
+ declare global {
400
+ interface ContextualClient {
401
+ }
402
+ }
403
+ /**
404
+ * A type used to create concerete types from SDK descriptors in
405
+ * case a contextual client is available.
406
+ */
407
+ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
408
+ host: Host;
409
+ } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
410
+
35
411
  interface AppPlans {
36
412
  /** App ID, as defined in the [app dashboard](https://dev.wix.com/apps/my-apps?viewId=active-apps-view). */
37
413
  _id?: string;
@@ -50,6 +426,14 @@ declare enum DiscountType {
50
426
  /** Discount is a percentage of the total price. */
51
427
  PERCENTAGE = "PERCENTAGE"
52
428
  }
429
+ declare enum SaleType {
430
+ /** Default value, can be used when no specific sale is associated. */
431
+ SALE_TYPE_UNSPECIFIED = "SALE_TYPE_UNSPECIFIED",
432
+ CYBER_MONDAY = "CYBER_MONDAY",
433
+ NOVEMBER_SALE = "NOVEMBER_SALE",
434
+ BLACK_FRIDAY = "BLACK_FRIDAY",
435
+ DEVELOPER_SALE = "DEVELOPER_SALE"
436
+ }
53
437
  interface Cycle {
54
438
  /**
55
439
  * Type of the billing cycle.
@@ -111,7 +495,6 @@ interface Discount {
111
495
  type?: DiscountType;
112
496
  /** Discount amount */
113
497
  amount?: string;
114
- /** if a discount is applied to a specific sale */
115
498
  saleId?: string | null;
116
499
  /**
117
500
  * Price without taxes. For yearly plans, Wix calculates and returns the
@@ -127,6 +510,7 @@ interface Discount {
127
510
  * Max: 1024 characters
128
511
  */
129
512
  totalPrice?: string;
513
+ saleType?: SaleType;
130
514
  }
131
515
  interface Price {
132
516
  /**
@@ -271,6 +655,7 @@ interface DiscountNonNullableFields {
271
655
  amount: string;
272
656
  priceBeforeTax: string;
273
657
  totalPrice: string;
658
+ saleType: SaleType;
274
659
  }
275
660
  interface PriceNonNullableFields {
276
661
  priceBeforeTax: string;
@@ -296,7 +681,7 @@ interface ListAppPlansByAppIdResponseNonNullableFields {
296
681
  appPlans: AppPlansNonNullableFields[];
297
682
  }
298
683
 
299
- declare function listAppPlansByAppId$1(httpClient: HttpClient$4): ListAppPlansByAppIdSignature;
684
+ declare function listAppPlansByAppId$1(httpClient: HttpClient): ListAppPlansByAppIdSignature;
300
685
  interface ListAppPlansByAppIdSignature {
301
686
  /**
302
687
  * Retrieves plans for the given apps.
@@ -330,7 +715,7 @@ interface ListAppPlansByAppIdSignature {
330
715
  (appIds: string[]): Promise<ListAppPlansByAppIdResponse & ListAppPlansByAppIdResponseNonNullableFields>;
331
716
  }
332
717
 
333
- declare const listAppPlansByAppId: BuildRESTFunction$4<typeof listAppPlansByAppId$1> & typeof listAppPlansByAppId$1;
718
+ declare const listAppPlansByAppId: MaybeContext<BuildRESTFunction<typeof listAppPlansByAppId$1> & typeof listAppPlansByAppId$1>;
334
719
 
335
720
  type context$4_AppPlans = AppPlans;
336
721
  type context$4_Cycle = Cycle;
@@ -347,57 +732,15 @@ type context$4_ListAppPlansByAppIdResponse = ListAppPlansByAppIdResponse;
347
732
  type context$4_ListAppPlansByAppIdResponseNonNullableFields = ListAppPlansByAppIdResponseNonNullableFields;
348
733
  type context$4_Plan = Plan;
349
734
  type context$4_Price = Price;
735
+ type context$4_SaleType = SaleType;
736
+ declare const context$4_SaleType: typeof SaleType;
350
737
  type context$4_TaxSettings = TaxSettings;
351
738
  type context$4_TaxType = TaxType;
352
739
  declare const context$4_TaxType: typeof TaxType;
353
740
  type context$4_UsageBasedDetails = UsageBasedDetails;
354
741
  declare const context$4_listAppPlansByAppId: typeof listAppPlansByAppId;
355
742
  declare namespace context$4 {
356
- export { type context$4_AppPlans as AppPlans, type context$4_Cycle as Cycle, context$4_CycleType as CycleType, type context$4_Discount as Discount, context$4_DiscountType as DiscountType, type context$4_Duration as Duration, context$4_DurationUnit as DurationUnit, type context$4_ListAppPlansByAppIdRequest as ListAppPlansByAppIdRequest, type context$4_ListAppPlansByAppIdResponse as ListAppPlansByAppIdResponse, type context$4_ListAppPlansByAppIdResponseNonNullableFields as ListAppPlansByAppIdResponseNonNullableFields, type context$4_Plan as Plan, type context$4_Price as Price, type context$4_TaxSettings as TaxSettings, context$4_TaxType as TaxType, type context$4_UsageBasedDetails as UsageBasedDetails, context$4_listAppPlansByAppId as listAppPlansByAppId };
357
- }
358
-
359
- type RESTFunctionDescriptor$3<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$3) => T;
360
- interface HttpClient$3 {
361
- request<TResponse, TData = any>(req: RequestOptionsFactory$3<TResponse, TData>): Promise<HttpResponse$3<TResponse>>;
362
- fetchWithAuth: typeof fetch;
363
- wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
364
- }
365
- type RequestOptionsFactory$3<TResponse = any, TData = any> = (context: any) => RequestOptions$3<TResponse, TData>;
366
- type HttpResponse$3<T = any> = {
367
- data: T;
368
- status: number;
369
- statusText: string;
370
- headers: any;
371
- request?: any;
372
- };
373
- type RequestOptions$3<_TResponse = any, Data = any> = {
374
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
375
- url: string;
376
- data?: Data;
377
- params?: URLSearchParams;
378
- } & APIMetadata$3;
379
- type APIMetadata$3 = {
380
- methodFqn?: string;
381
- entityFqdn?: string;
382
- packageName?: string;
383
- };
384
- type BuildRESTFunction$3<T extends RESTFunctionDescriptor$3> = T extends RESTFunctionDescriptor$3<infer U> ? U : never;
385
- type EventDefinition<Payload = unknown, Type extends string = string> = {
386
- __type: 'event-definition';
387
- type: Type;
388
- isDomainEvent?: boolean;
389
- transformations?: (envelope: unknown) => Payload;
390
- __payload: Payload;
391
- };
392
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
393
- type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
394
- type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
395
-
396
- declare global {
397
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
398
- interface SymbolConstructor {
399
- readonly observable: symbol;
400
- }
743
+ export { type context$4_AppPlans as AppPlans, type context$4_Cycle as Cycle, context$4_CycleType as CycleType, type context$4_Discount as Discount, context$4_DiscountType as DiscountType, type context$4_Duration as Duration, context$4_DurationUnit as DurationUnit, type context$4_ListAppPlansByAppIdRequest as ListAppPlansByAppIdRequest, type context$4_ListAppPlansByAppIdResponse as ListAppPlansByAppIdResponse, type context$4_ListAppPlansByAppIdResponseNonNullableFields as ListAppPlansByAppIdResponseNonNullableFields, type context$4_Plan as Plan, type context$4_Price as Price, context$4_SaleType as SaleType, type context$4_TaxSettings as TaxSettings, context$4_TaxType as TaxType, type context$4_UsageBasedDetails as UsageBasedDetails, context$4_listAppPlansByAppId as listAppPlansByAppId };
401
744
  }
402
745
 
403
746
  /**
@@ -801,7 +1144,7 @@ interface AppInstancePaidPlanAutoRenewalCancelledEnvelope {
801
1144
  metadata: BaseEventMetadata;
802
1145
  }
803
1146
 
804
- declare function getAppInstance$1(httpClient: HttpClient$3): GetAppInstanceSignature;
1147
+ declare function getAppInstance$1(httpClient: HttpClient): GetAppInstanceSignature;
805
1148
  interface GetAppInstanceSignature {
806
1149
  /**
807
1150
  * Retrieves data about the instance of your app that's installed on a Wix site and data about the site itself.
@@ -814,15 +1157,33 @@ interface GetAppInstanceSignature {
814
1157
  */
815
1158
  (): Promise<GetAppInstanceResponse & GetAppInstanceResponseNonNullableFields>;
816
1159
  }
817
- declare const onAppInstanceInstalled$1: EventDefinition<AppInstanceInstalledEnvelope, "AppInstalled">;
818
- declare const onAppInstanceRemoved$1: EventDefinition<AppInstanceRemovedEnvelope, "AppRemoved">;
819
- declare const onAppInstancePaidPlanPurchased$1: EventDefinition<AppInstancePaidPlanPurchasedEnvelope, "PaidPlanPurchased">;
820
- declare const onAppInstancePaidPlanChanged$1: EventDefinition<AppInstancePaidPlanChangedEnvelope, "PaidPlanChanged">;
821
- declare const onAppInstancePaidPlanAutoRenewalCancelled$1: EventDefinition<AppInstancePaidPlanAutoRenewalCancelledEnvelope, "PaidPlanAutoRenewalCancelled">;
1160
+ declare const onAppInstanceInstalled$1: EventDefinition$1<AppInstanceInstalledEnvelope, "AppInstalled">;
1161
+ declare const onAppInstanceRemoved$1: EventDefinition$1<AppInstanceRemovedEnvelope, "AppRemoved">;
1162
+ declare const onAppInstancePaidPlanPurchased$1: EventDefinition$1<AppInstancePaidPlanPurchasedEnvelope, "PaidPlanPurchased">;
1163
+ declare const onAppInstancePaidPlanChanged$1: EventDefinition$1<AppInstancePaidPlanChangedEnvelope, "PaidPlanChanged">;
1164
+ declare const onAppInstancePaidPlanAutoRenewalCancelled$1: EventDefinition$1<AppInstancePaidPlanAutoRenewalCancelledEnvelope, "PaidPlanAutoRenewalCancelled">;
1165
+
1166
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
1167
+ __type: 'event-definition';
1168
+ type: Type;
1169
+ isDomainEvent?: boolean;
1170
+ transformations?: (envelope: unknown) => Payload;
1171
+ __payload: Payload;
1172
+ };
1173
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
1174
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
1175
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
1176
+
1177
+ declare global {
1178
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
1179
+ interface SymbolConstructor {
1180
+ readonly observable: symbol;
1181
+ }
1182
+ }
822
1183
 
823
1184
  declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
824
1185
 
825
- declare const getAppInstance: BuildRESTFunction$3<typeof getAppInstance$1> & typeof getAppInstance$1;
1186
+ declare const getAppInstance: MaybeContext<BuildRESTFunction<typeof getAppInstance$1> & typeof getAppInstance$1>;
826
1187
 
827
1188
  type _publicOnAppInstanceInstalledType = typeof onAppInstanceInstalled$1;
828
1189
  /**
@@ -899,40 +1260,6 @@ declare namespace context$3 {
899
1260
  export { type context$3_AppInstalled as AppInstalled, type context$3_AppInstance as AppInstance, type context$3_AppInstanceInstalledEnvelope as AppInstanceInstalledEnvelope, type context$3_AppInstancePaidPlanAutoRenewalCancelledEnvelope as AppInstancePaidPlanAutoRenewalCancelledEnvelope, type context$3_AppInstancePaidPlanChangedEnvelope as AppInstancePaidPlanChangedEnvelope, type context$3_AppInstancePaidPlanPurchasedEnvelope as AppInstancePaidPlanPurchasedEnvelope, type context$3_AppInstanceRemovedEnvelope as AppInstanceRemovedEnvelope, type context$3_AppRemoved as AppRemoved, type context$3_AvailablePlan as AvailablePlan, type context$3_BaseEventMetadata as BaseEventMetadata, type context$3_BillingInfo as BillingInfo, type context$3_FreeTrialInfo as FreeTrialInfo, context$3_FreeTrialStatus as FreeTrialStatus, type context$3_GetAppInstanceByInstanceIdRequest as GetAppInstanceByInstanceIdRequest, type context$3_GetAppInstanceRequest as GetAppInstanceRequest, type context$3_GetAppInstanceResponse as GetAppInstanceResponse, type context$3_GetAppInstanceResponseNonNullableFields as GetAppInstanceResponseNonNullableFields, type IdentificationData$1 as IdentificationData, type IdentificationDataIdOneOf$1 as IdentificationDataIdOneOf, type context$3_Locale as Locale, type MessageEnvelope$1 as MessageEnvelope, type context$3_Multilingual as Multilingual, type context$3_OwnerInfo as OwnerInfo, type context$3_PaidPlanAutoRenewalCancelled as PaidPlanAutoRenewalCancelled, type context$3_PaidPlanChanged as PaidPlanChanged, type context$3_PaidPlanPurchased as PaidPlanPurchased, PaymentCycle$1 as PaymentCycle, context$3_ResolutionMethod as ResolutionMethod, type context$3_SiteInfo as SiteInfo, type context$3_SupportedLanguage as SupportedLanguage, WebhookIdentityType$1 as WebhookIdentityType, type context$3__publicOnAppInstanceInstalledType as _publicOnAppInstanceInstalledType, type context$3__publicOnAppInstancePaidPlanAutoRenewalCancelledType as _publicOnAppInstancePaidPlanAutoRenewalCancelledType, type context$3__publicOnAppInstancePaidPlanChangedType as _publicOnAppInstancePaidPlanChangedType, type context$3__publicOnAppInstancePaidPlanPurchasedType as _publicOnAppInstancePaidPlanPurchasedType, type context$3__publicOnAppInstanceRemovedType as _publicOnAppInstanceRemovedType, context$3_getAppInstance as getAppInstance, context$3_onAppInstanceInstalled as onAppInstanceInstalled, context$3_onAppInstancePaidPlanAutoRenewalCancelled as onAppInstancePaidPlanAutoRenewalCancelled, context$3_onAppInstancePaidPlanChanged as onAppInstancePaidPlanChanged, context$3_onAppInstancePaidPlanPurchased as onAppInstancePaidPlanPurchased, context$3_onAppInstanceRemoved as onAppInstanceRemoved, onAppInstanceInstalled$1 as publicOnAppInstanceInstalled, onAppInstancePaidPlanAutoRenewalCancelled$1 as publicOnAppInstancePaidPlanAutoRenewalCancelled, onAppInstancePaidPlanChanged$1 as publicOnAppInstancePaidPlanChanged, onAppInstancePaidPlanPurchased$1 as publicOnAppInstancePaidPlanPurchased, onAppInstanceRemoved$1 as publicOnAppInstanceRemoved };
900
1261
  }
901
1262
 
902
- type RESTFunctionDescriptor$2<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$2) => T;
903
- interface HttpClient$2 {
904
- request<TResponse, TData = any>(req: RequestOptionsFactory$2<TResponse, TData>): Promise<HttpResponse$2<TResponse>>;
905
- fetchWithAuth: typeof fetch;
906
- wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
907
- }
908
- type RequestOptionsFactory$2<TResponse = any, TData = any> = (context: any) => RequestOptions$2<TResponse, TData>;
909
- type HttpResponse$2<T = any> = {
910
- data: T;
911
- status: number;
912
- statusText: string;
913
- headers: any;
914
- request?: any;
915
- };
916
- type RequestOptions$2<_TResponse = any, Data = any> = {
917
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
918
- url: string;
919
- data?: Data;
920
- params?: URLSearchParams;
921
- } & APIMetadata$2;
922
- type APIMetadata$2 = {
923
- methodFqn?: string;
924
- entityFqdn?: string;
925
- packageName?: string;
926
- };
927
- type BuildRESTFunction$2<T extends RESTFunctionDescriptor$2> = T extends RESTFunctionDescriptor$2<infer U> ? U : never;
928
-
929
- declare global {
930
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
931
- interface SymbolConstructor {
932
- readonly observable: symbol;
933
- }
934
- }
935
-
936
1263
  interface SendBIEventResponse {
937
1264
  }
938
1265
  interface SendBIEventRequest {
@@ -1021,7 +1348,7 @@ interface SendBiEventOptions {
1021
1348
  eventData?: Record<string, string>;
1022
1349
  }
1023
1350
 
1024
- declare function sendBiEvent$1(httpClient: HttpClient$2): SendBiEventSignature;
1351
+ declare function sendBiEvent$1(httpClient: HttpClient): SendBiEventSignature;
1025
1352
  interface SendBiEventSignature {
1026
1353
  /**
1027
1354
  * Submit a BI event to Wix.
@@ -1029,7 +1356,7 @@ interface SendBiEventSignature {
1029
1356
  (options?: SendBiEventOptions | undefined): Promise<void>;
1030
1357
  }
1031
1358
 
1032
- declare const sendBiEvent: BuildRESTFunction$2<typeof sendBiEvent$1> & typeof sendBiEvent$1;
1359
+ declare const sendBiEvent: MaybeContext<BuildRESTFunction<typeof sendBiEvent$1> & typeof sendBiEvent$1>;
1033
1360
 
1034
1361
  type context$2_EventName = EventName;
1035
1362
  declare const context$2_EventName: typeof EventName;
@@ -1041,40 +1368,6 @@ declare namespace context$2 {
1041
1368
  export { context$2_EventName as EventName, type context$2_SendBIEventRequest as SendBIEventRequest, type context$2_SendBIEventResponse as SendBIEventResponse, type context$2_SendBiEventOptions as SendBiEventOptions, context$2_sendBiEvent as sendBiEvent };
1042
1369
  }
1043
1370
 
1044
- type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
1045
- interface HttpClient$1 {
1046
- request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
1047
- fetchWithAuth: typeof fetch;
1048
- wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
1049
- }
1050
- type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
1051
- type HttpResponse$1<T = any> = {
1052
- data: T;
1053
- status: number;
1054
- statusText: string;
1055
- headers: any;
1056
- request?: any;
1057
- };
1058
- type RequestOptions$1<_TResponse = any, Data = any> = {
1059
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
1060
- url: string;
1061
- data?: Data;
1062
- params?: URLSearchParams;
1063
- } & APIMetadata$1;
1064
- type APIMetadata$1 = {
1065
- methodFqn?: string;
1066
- entityFqdn?: string;
1067
- packageName?: string;
1068
- };
1069
- type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
1070
-
1071
- declare global {
1072
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
1073
- interface SymbolConstructor {
1074
- readonly observable: symbol;
1075
- }
1076
- }
1077
-
1078
1371
  interface PurchasedItem {
1079
1372
  /** ID of your app's paid plan. */
1080
1373
  productId?: string;
@@ -1327,7 +1620,7 @@ interface GetUrlOptions {
1327
1620
  couponCode?: string | null;
1328
1621
  }
1329
1622
 
1330
- declare function getUrl$1(httpClient: HttpClient$1): GetUrlSignature;
1623
+ declare function getUrl$1(httpClient: HttpClient): GetUrlSignature;
1331
1624
  interface GetUrlSignature {
1332
1625
  /**
1333
1626
  * Retrieves the URL for a Wix checkout page for the specified paid plan of your app.
@@ -1345,7 +1638,7 @@ interface GetUrlSignature {
1345
1638
  */
1346
1639
  (productId: string, options?: GetUrlOptions | undefined): Promise<GetUrlResponse & GetUrlResponseNonNullableFields>;
1347
1640
  }
1348
- declare function getPurchaseHistory$1(httpClient: HttpClient$1): GetPurchaseHistorySignature;
1641
+ declare function getPurchaseHistory$1(httpClient: HttpClient): GetPurchaseHistorySignature;
1349
1642
  interface GetPurchaseHistorySignature {
1350
1643
  /**
1351
1644
  * Retrieves a list of the site owner's past purchases for your app.
@@ -1359,8 +1652,8 @@ interface GetPurchaseHistorySignature {
1359
1652
  (): Promise<GetPurchaseHistoryResponse & GetPurchaseHistoryResponseNonNullableFields>;
1360
1653
  }
1361
1654
 
1362
- declare const getUrl: BuildRESTFunction$1<typeof getUrl$1> & typeof getUrl$1;
1363
- declare const getPurchaseHistory: BuildRESTFunction$1<typeof getPurchaseHistory$1> & typeof getPurchaseHistory$1;
1655
+ declare const getUrl: MaybeContext<BuildRESTFunction<typeof getUrl$1> & typeof getUrl$1>;
1656
+ declare const getPurchaseHistory: MaybeContext<BuildRESTFunction<typeof getPurchaseHistory$1> & typeof getPurchaseHistory$1>;
1364
1657
 
1365
1658
  type context$1_Charge = Charge;
1366
1659
  type context$1_ChargeOverride = ChargeOverride;
@@ -1392,40 +1685,6 @@ declare namespace context$1 {
1392
1685
  export { type context$1_Charge as Charge, type context$1_ChargeOverride as ChargeOverride, type context$1_GetMeteredBillingChargesRequest as GetMeteredBillingChargesRequest, type context$1_GetMeteredBillingChargesResponse as GetMeteredBillingChargesResponse, type context$1_GetPurchaseHistoryRequest as GetPurchaseHistoryRequest, type context$1_GetPurchaseHistoryResponse as GetPurchaseHistoryResponse, type context$1_GetPurchaseHistoryResponseNonNullableFields as GetPurchaseHistoryResponseNonNullableFields, type context$1_GetSitePaymentMethodsStatusRequest as GetSitePaymentMethodsStatusRequest, type context$1_GetSitePaymentMethodsStatusResponse as GetSitePaymentMethodsStatusResponse, type context$1_GetUrlOptions as GetUrlOptions, type context$1_GetUrlRequest as GetUrlRequest, type context$1_GetUrlResponse as GetUrlResponse, type context$1_GetUrlResponseNonNullableFields as GetUrlResponseNonNullableFields, type context$1_IdentificationData as IdentificationData, type context$1_IdentificationDataIdOneOf as IdentificationDataIdOneOf, context$1_InvoiceStatus as InvoiceStatus, type context$1_InvoiceStatusUpdate as InvoiceStatusUpdate, type context$1_MessageEnvelope as MessageEnvelope, context$1_PaymentCycle as PaymentCycle, type context$1_PurchasedItem as PurchasedItem, context$1_WebhookIdentityType as WebhookIdentityType, context$1_getPurchaseHistory as getPurchaseHistory, context$1_getUrl as getUrl };
1393
1686
  }
1394
1687
 
1395
- type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
1396
- interface HttpClient {
1397
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
1398
- fetchWithAuth: typeof fetch;
1399
- wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
1400
- }
1401
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
1402
- type HttpResponse<T = any> = {
1403
- data: T;
1404
- status: number;
1405
- statusText: string;
1406
- headers: any;
1407
- request?: any;
1408
- };
1409
- type RequestOptions<_TResponse = any, Data = any> = {
1410
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
1411
- url: string;
1412
- data?: Data;
1413
- params?: URLSearchParams;
1414
- } & APIMetadata;
1415
- type APIMetadata = {
1416
- methodFqn?: string;
1417
- entityFqdn?: string;
1418
- packageName?: string;
1419
- };
1420
- type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
1421
-
1422
- declare global {
1423
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
1424
- interface SymbolConstructor {
1425
- readonly observable: symbol;
1426
- }
1427
- }
1428
-
1429
1688
  /** Embedded script data */
1430
1689
  interface ScriptProperties {
1431
1690
  /** Script parameters */
@@ -1486,7 +1745,7 @@ interface EmbedScriptSignature {
1486
1745
  *
1487
1746
  *
1488
1747
  * Your app must have an existing
1489
- * [embedded script component](https://dev.wix.com/docs/build-apps/developer-tools/extensions/embedded-scripts),
1748
+ * [embedded script component](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/about-embedded-scripts),
1490
1749
  * with exactly matching parameter names.
1491
1750
  * @param - Details of the script to embed.
1492
1751
  */
@@ -1505,8 +1764,8 @@ interface GetEmbeddedScriptSignature {
1505
1764
  (options?: GetEmbeddedScriptOptions | undefined): Promise<ScriptProperties & ScriptPropertiesNonNullableFields>;
1506
1765
  }
1507
1766
 
1508
- declare const embedScript: BuildRESTFunction<typeof embedScript$1> & typeof embedScript$1;
1509
- declare const getEmbeddedScript: BuildRESTFunction<typeof getEmbeddedScript$1> & typeof getEmbeddedScript$1;
1767
+ declare const embedScript: MaybeContext<BuildRESTFunction<typeof embedScript$1> & typeof embedScript$1>;
1768
+ declare const getEmbeddedScript: MaybeContext<BuildRESTFunction<typeof getEmbeddedScript$1> & typeof getEmbeddedScript$1>;
1510
1769
 
1511
1770
  type context_EmbedScriptByInstanceIdRequest = EmbedScriptByInstanceIdRequest;
1512
1771
  type context_EmbedScriptOptions = EmbedScriptOptions;