@wix/app-management 1.0.30 → 1.0.31

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,5 +1,6 @@
1
- export * as appPlans from '@wix/app-management_app-plans';
2
- export * as appInstances from '@wix/app-management_app-instances';
3
- export * as biEvents from '@wix/app-management_bi-events';
4
- export * as billing from '@wix/app-management_billing';
5
- export * as embeddedScripts from '@wix/app-management_embedded-scripts';
1
+ import * as appPlans from '@wix/app-management_app-plans';
2
+ import * as appInstances from '@wix/app-management_app-instances';
3
+ import * as biEvents from '@wix/app-management_bi-events';
4
+ import * as billing from '@wix/app-management_billing';
5
+ import * as embeddedScripts from '@wix/app-management_embedded-scripts';
6
+ export { appPlans, appInstances, biEvents, billing, embeddedScripts };
@@ -24,9 +24,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.embeddedScripts = exports.billing = exports.biEvents = exports.appInstances = exports.appPlans = void 0;
27
- exports.appPlans = __importStar(require("@wix/app-management_app-plans"));
28
- exports.appInstances = __importStar(require("@wix/app-management_app-instances"));
29
- exports.biEvents = __importStar(require("@wix/app-management_bi-events"));
30
- exports.billing = __importStar(require("@wix/app-management_billing"));
31
- exports.embeddedScripts = __importStar(require("@wix/app-management_embedded-scripts"));
27
+ const appPlans = __importStar(require("@wix/app-management_app-plans"));
28
+ exports.appPlans = appPlans;
29
+ const appInstances = __importStar(require("@wix/app-management_app-instances"));
30
+ exports.appInstances = appInstances;
31
+ const biEvents = __importStar(require("@wix/app-management_bi-events"));
32
+ exports.biEvents = biEvents;
33
+ const billing = __importStar(require("@wix/app-management_billing"));
34
+ exports.billing = billing;
35
+ const embeddedScripts = __importStar(require("@wix/app-management_embedded-scripts"));
36
+ exports.embeddedScripts = embeddedScripts;
32
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA0D;AAC1D,kFAAkE;AAClE,0EAA0D;AAC1D,uEAAuD;AACvD,wFAAwE"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wEAA0D;AAMjD,4BAAQ;AALjB,gFAAkE;AAK/C,oCAAY;AAJ/B,wEAA0D;AAIzB,4BAAQ;AAHzC,qEAAuD;AAGZ,0BAAO;AAFlD,sFAAwE;AAEpB,0CAAe"}
@@ -1,5 +1,6 @@
1
- export * as appPlans from '@wix/app-management_app-plans';
2
- export * as appInstances from '@wix/app-management_app-instances';
3
- export * as biEvents from '@wix/app-management_bi-events';
4
- export * as billing from '@wix/app-management_billing';
5
- export * as embeddedScripts from '@wix/app-management_embedded-scripts';
1
+ import * as appPlans from '@wix/app-management_app-plans';
2
+ import * as appInstances from '@wix/app-management_app-instances';
3
+ import * as biEvents from '@wix/app-management_bi-events';
4
+ import * as billing from '@wix/app-management_billing';
5
+ import * as embeddedScripts from '@wix/app-management_embedded-scripts';
6
+ export { appPlans, appInstances, biEvents, billing, embeddedScripts };
package/build/es/index.js CHANGED
@@ -1,6 +1,7 @@
1
- export * as appPlans from '@wix/app-management_app-plans';
2
- export * as appInstances from '@wix/app-management_app-instances';
3
- export * as biEvents from '@wix/app-management_bi-events';
4
- export * as billing from '@wix/app-management_billing';
5
- export * as embeddedScripts from '@wix/app-management_embedded-scripts';
1
+ import * as appPlans from '@wix/app-management_app-plans';
2
+ import * as appInstances from '@wix/app-management_app-instances';
3
+ import * as biEvents from '@wix/app-management_bi-events';
4
+ import * as billing from '@wix/app-management_billing';
5
+ import * as embeddedScripts from '@wix/app-management_embedded-scripts';
6
+ export { appPlans, appInstances, biEvents, billing, embeddedScripts };
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,YAAY,MAAM,mCAAmC,CAAC;AAClE,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,KAAK,eAAe,MAAM,sCAAsC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,YAAY,MAAM,mCAAmC,CAAC;AAClE,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,KAAK,eAAe,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/app-management",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -19,12 +19,12 @@
19
19
  "service-plugins"
20
20
  ],
21
21
  "dependencies": {
22
- "@wix/app-management_app-instances": "1.0.16",
23
- "@wix/app-management_app-plans": "1.0.16",
24
- "@wix/app-management_bi-events": "1.0.15",
25
- "@wix/app-management_billing": "1.0.16",
22
+ "@wix/app-management_app-instances": "1.0.17",
23
+ "@wix/app-management_app-plans": "1.0.17",
24
+ "@wix/app-management_bi-events": "1.0.16",
25
+ "@wix/app-management_billing": "1.0.17",
26
26
  "@wix/app-management_custom-charges": "1.0.14",
27
- "@wix/app-management_embedded-scripts": "1.0.13"
27
+ "@wix/app-management_embedded-scripts": "1.0.14"
28
28
  },
29
29
  "devDependencies": {
30
30
  "glob": "^10.4.1",
@@ -49,5 +49,5 @@
49
49
  "fqdn": ""
50
50
  }
51
51
  },
52
- "falconPackageHash": "c4c0e29043bcbcef96d15a9644c4df19956fcb419059a6b6d0c43af3"
52
+ "falconPackageHash": "2706f85ff49e879a3fdb9c6f6bb9361bd5ca377d95fdc9389c4caa57"
53
53
  }
@@ -1,10 +1,47 @@
1
- /**
2
- * An `appPlans` object describes how you charge users for using your app.
3
- * You can set up multiple plans for a single app, with different plans giving access to
4
- * different tiers of functionality. For example, you can offer a free plan and
5
- * 3 paid plans with an increasing number of benefits. Learn more about
6
- * [setting up your app pricing](https://dev.wix.com/docs/build-apps/build-your-app/pricing-plans/set-up-your-app-pricing).
7
- */
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>>;
4
+ fetchWithAuth: typeof fetch;
5
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
6
+ }
7
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
8
+ type HttpResponse<T = any> = {
9
+ data: T;
10
+ status: number;
11
+ statusText: string;
12
+ headers: any;
13
+ request?: any;
14
+ };
15
+ type RequestOptions<_TResponse = any, Data = any> = {
16
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
17
+ url: string;
18
+ data?: Data;
19
+ params?: URLSearchParams;
20
+ } & APIMetadata;
21
+ type APIMetadata = {
22
+ methodFqn?: string;
23
+ entityFqdn?: string;
24
+ packageName?: string;
25
+ };
26
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
27
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
28
+ __type: 'event-definition';
29
+ type: Type;
30
+ isDomainEvent?: boolean;
31
+ transformations?: (envelope: unknown) => Payload;
32
+ __payload: Payload;
33
+ };
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;
37
+
38
+ declare global {
39
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
40
+ interface SymbolConstructor {
41
+ readonly observable: symbol;
42
+ }
43
+ }
44
+
8
45
  interface AppPlans {
9
46
  /** App ID, as defined in the [Wix Dev Center](https://dev.wix.com/). */
10
47
  _id?: string;
@@ -234,52 +271,40 @@ interface ListAppPlansByAppIdResponseNonNullableFields {
234
271
  appPlans: AppPlansNonNullableFields[];
235
272
  }
236
273
 
237
- type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
238
- interface HttpClient {
239
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
240
- fetchWithAuth: typeof fetch;
241
- wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
242
- }
243
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
244
- type HttpResponse<T = any> = {
245
- data: T;
246
- status: number;
247
- statusText: string;
248
- headers: any;
249
- request?: any;
250
- };
251
- type RequestOptions<_TResponse = any, Data = any> = {
252
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
253
- url: string;
254
- data?: Data;
255
- params?: URLSearchParams;
256
- } & APIMetadata;
257
- type APIMetadata = {
258
- methodFqn?: string;
259
- entityFqdn?: string;
260
- packageName?: string;
261
- };
262
- type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
263
- type EventDefinition<Payload = unknown, Type extends string = string> = {
264
- __type: 'event-definition';
265
- type: Type;
266
- isDomainEvent?: boolean;
267
- transformations?: (envelope: unknown) => Payload;
268
- __payload: Payload;
269
- };
270
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
271
- type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
272
- type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
273
-
274
- declare global {
275
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
276
- interface SymbolConstructor {
277
- readonly observable: symbol;
278
- }
274
+ declare function listAppPlansByAppId$1(httpClient: HttpClient): ListAppPlansByAppIdSignature;
275
+ interface ListAppPlansByAppIdSignature {
276
+ /**
277
+ * Retrieves plans for the given apps.
278
+ *
279
+ *
280
+ * Also returns tax settings and currency details. Wix calculates this information
281
+ * based on the 2-letter country code in [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
282
+ * format that you pass in the call's header. If you don't pass a country code in
283
+ * the header, Wix calculates the tax settings and currency details based on the
284
+ * call's IP address. Note that the tax settings and currency details may not resolve
285
+ * properly if you call through a VPN.
286
+ *
287
+ * Prices for plans that are managed outside of Wix aren't returned.
288
+ *
289
+ * Consumers must pay for yearly and multi-yearly plans of your app every month.
290
+ * For these plans this endpoint returns the price that the consumer must pay every
291
+ * month and not the total price for the entire year.
292
+ *
293
+ * <blockquote class="important">
294
+ *
295
+ * __Important:__
296
+ * The App Plans API doesn't follow any tenancy model. You don't need any
297
+ * permissions to call `List App Plans by App ID`.
298
+ *
299
+ * </blockquote>
300
+ * @param - List of app IDs to retrieve plans for.
301
+ *
302
+ * Min: 1 app ID
303
+ * Max: 100 app IDs
304
+ */
305
+ (appIds: string[]): Promise<ListAppPlansByAppIdResponse & ListAppPlansByAppIdResponseNonNullableFields>;
279
306
  }
280
307
 
281
- declare function listAppPlansByAppId$1(httpClient: HttpClient): (appIds: string[]) => Promise<ListAppPlansByAppIdResponse & ListAppPlansByAppIdResponseNonNullableFields>;
282
-
283
308
  declare function createRESTModule$4<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
284
309
 
285
310
  type _publicListAppPlansByAppIdType = typeof listAppPlansByAppId$1;
@@ -711,7 +736,22 @@ interface AppInstancePaidPlanAutoRenewalCancelledEnvelope {
711
736
  metadata: BaseEventMetadata;
712
737
  }
713
738
 
714
- declare function getAppInstance$1(httpClient: HttpClient): () => Promise<GetAppInstanceResponse & GetAppInstanceResponseNonNullableFields>;
739
+ declare function getAppInstance$1(httpClient: HttpClient): GetAppInstanceSignature;
740
+ interface GetAppInstanceSignature {
741
+ /**
742
+ * Retrieves data about the instance of your app that's installed on the Wix
743
+ * site and the site itself.
744
+ *
745
+ *
746
+ * You don't have to explicitly pass an identifier for the Wix site as part of
747
+ * the request, since this information is taken automatically from the context.
748
+ *
749
+ * In case you want `site.ownerInfo` to be included in the response, you must
750
+ * have the __Read Site Owner Email__ permission scope in addition to
751
+ * __WIX_DEVELOPERS.MANAGE_APP_INSTANCE__.
752
+ */
753
+ (): Promise<GetAppInstanceResponse & GetAppInstanceResponseNonNullableFields>;
754
+ }
715
755
  declare const onAppInstanceInstalled$1: EventDefinition<AppInstanceInstalledEnvelope, "AppInstalled">;
716
756
  declare const onAppInstanceRemoved$1: EventDefinition<AppInstanceRemovedEnvelope, "AppRemoved">;
717
757
  declare const onAppInstancePaidPlanPurchased$1: EventDefinition<AppInstancePaidPlanPurchasedEnvelope, "PaidPlanPurchased">;
@@ -726,18 +766,35 @@ type _publicGetAppInstanceType = typeof getAppInstance$1;
726
766
  declare const getAppInstance: ReturnType<typeof createRESTModule$3<_publicGetAppInstanceType>>;
727
767
 
728
768
  type _publicOnAppInstanceInstalledType = typeof onAppInstanceInstalled$1;
769
+ /**
770
+ * Triggered when an instance of your app is installed on a Wix site.
771
+ */
729
772
  declare const onAppInstanceInstalled: ReturnType<typeof createEventModule<_publicOnAppInstanceInstalledType>>;
730
773
 
731
774
  type _publicOnAppInstanceRemovedType = typeof onAppInstanceRemoved$1;
775
+ /**
776
+ * Triggered when an instance of your app is uninstalled from a Wix site.
777
+ */
732
778
  declare const onAppInstanceRemoved: ReturnType<typeof createEventModule<_publicOnAppInstanceRemovedType>>;
733
779
 
734
780
  type _publicOnAppInstancePaidPlanPurchasedType = typeof onAppInstancePaidPlanPurchased$1;
781
+ /**
782
+ * Triggered when a site owner purchases a paid plan for your app.
783
+ */
735
784
  declare const onAppInstancePaidPlanPurchased: ReturnType<typeof createEventModule<_publicOnAppInstancePaidPlanPurchasedType>>;
736
785
 
737
786
  type _publicOnAppInstancePaidPlanChangedType = typeof onAppInstancePaidPlanChanged$1;
787
+ /**
788
+ * Triggered when a site owner upgrades or downgrades their plan for your app.
789
+ */
738
790
  declare const onAppInstancePaidPlanChanged: ReturnType<typeof createEventModule<_publicOnAppInstancePaidPlanChangedType>>;
739
791
 
740
792
  type _publicOnAppInstancePaidPlanAutoRenewalCancelledType = typeof onAppInstancePaidPlanAutoRenewalCancelled$1;
793
+ /**
794
+ * Triggered when a site owner cancels a paid plan for your app. The
795
+ * site owner can continue to use your app until the end of the current billing
796
+ * cycle.
797
+ */
741
798
  declare const onAppInstancePaidPlanAutoRenewalCancelled: ReturnType<typeof createEventModule<_publicOnAppInstancePaidPlanAutoRenewalCancelledType>>;
742
799
 
743
800
  type context$3_AppInstalled = AppInstalled;
@@ -872,7 +929,13 @@ interface SendBiEventOptions {
872
929
  eventData?: Record<string, string>;
873
930
  }
874
931
 
875
- declare function sendBiEvent$1(httpClient: HttpClient): (options?: SendBiEventOptions) => Promise<void>;
932
+ declare function sendBiEvent$1(httpClient: HttpClient): SendBiEventSignature;
933
+ interface SendBiEventSignature {
934
+ /**
935
+ * Submit a BI event to Wix.
936
+ */
937
+ (options?: SendBiEventOptions | undefined): Promise<void>;
938
+ }
876
939
 
877
940
  declare function createRESTModule$2<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
878
941
 
@@ -1143,8 +1206,37 @@ interface GetUrlOptions {
1143
1206
  couponCode?: string | null;
1144
1207
  }
1145
1208
 
1146
- declare function getUrl$1(httpClient: HttpClient): (productId: string, options?: GetUrlOptions) => Promise<GetUrlResponse & GetUrlResponseNonNullableFields>;
1147
- declare function getPurchaseHistory$1(httpClient: HttpClient): () => Promise<GetPurchaseHistoryResponse & GetPurchaseHistoryResponseNonNullableFields>;
1209
+ declare function getUrl$1(httpClient: HttpClient): GetUrlSignature;
1210
+ interface GetUrlSignature {
1211
+ /**
1212
+ * Retrieves the URL for a Wix checkout page for the specified paid plan of your app.
1213
+ *
1214
+ *
1215
+ * This call succeeds only in case you have previously
1216
+ * [set up an external pricing page in the Wix Developers Center](https://dev.wix.com/docs/build-apps/build-your-app/pricing-plans/set-up-an-external-pricing-page).
1217
+ *
1218
+ * The returned checkout URL is valid for 48 hours.
1219
+ *
1220
+ * This API allows your app to manage your pricing page outside of Wix while
1221
+ * still using the standard Wix checkout flow.
1222
+ * @param - ID of your app's paid plan to retrieve the Wix checkout URL for. Check the
1223
+ * Wix Developers Center for a list of your app's supported product IDs.
1224
+ */
1225
+ (productId: string, options?: GetUrlOptions | undefined): Promise<GetUrlResponse & GetUrlResponseNonNullableFields>;
1226
+ }
1227
+ declare function getPurchaseHistory$1(httpClient: HttpClient): GetPurchaseHistorySignature;
1228
+ interface GetPurchaseHistorySignature {
1229
+ /**
1230
+ * Retrieves a list of the site owner's past purchases for your app.
1231
+ *
1232
+ *
1233
+ * You don't have to explicitly pass an identifier for the Wix site as part of
1234
+ * the request, since this information is taken automatically from the context.
1235
+ *
1236
+ * The response doesn't include any details about cancellations.
1237
+ */
1238
+ (): Promise<GetPurchaseHistoryResponse & GetPurchaseHistoryResponseNonNullableFields>;
1239
+ }
1148
1240
 
1149
1241
  declare function createRESTModule$1<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
1150
1242
 
@@ -1238,8 +1330,31 @@ interface GetEmbeddedScriptOptions {
1238
1330
  componentId?: string | null;
1239
1331
  }
1240
1332
 
1241
- declare function embedScript$1(httpClient: HttpClient): (properties: ScriptProperties, options?: EmbedScriptOptions) => Promise<EmbedScriptResponse & EmbedScriptResponseNonNullableFields>;
1242
- declare function getEmbeddedScript$1(httpClient: HttpClient): (options?: GetEmbeddedScriptOptions) => Promise<ScriptProperties & ScriptPropertiesNonNullableFields>;
1333
+ declare function embedScript$1(httpClient: HttpClient): EmbedScriptSignature;
1334
+ interface EmbedScriptSignature {
1335
+ /**
1336
+ * Inserts custom script tags into a site.
1337
+ *
1338
+ *
1339
+ * Your app must have an existing
1340
+ * [embedded script component](https://dev.wix.com/docs/build-apps/developer-tools/extensions/embedded-scripts),
1341
+ * with exactly matching parameter names.
1342
+ * @param - Details of the script to embed.
1343
+ */
1344
+ (properties: ScriptProperties, options?: EmbedScriptOptions | undefined): Promise<EmbedScriptResponse & EmbedScriptResponseNonNullableFields>;
1345
+ }
1346
+ declare function getEmbeddedScript$1(httpClient: HttpClient): GetEmbeddedScriptSignature;
1347
+ interface GetEmbeddedScriptSignature {
1348
+ /**
1349
+ * Retrieves information about your app's existing embedded script.
1350
+ *
1351
+ *
1352
+ * The call fails with `404` error in case your app doesn't include an
1353
+ * embedded script on the site.
1354
+ * @returns Details of the retrieved embedded script.
1355
+ */
1356
+ (options?: GetEmbeddedScriptOptions | undefined): Promise<ScriptProperties & ScriptPropertiesNonNullableFields>;
1357
+ }
1243
1358
 
1244
1359
  declare function createRESTModule<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
1245
1360
 
@@ -1,10 +1,47 @@
1
- /**
2
- * An `appPlans` object describes how you charge users for using your app.
3
- * You can set up multiple plans for a single app, with different plans giving access to
4
- * different tiers of functionality. For example, you can offer a free plan and
5
- * 3 paid plans with an increasing number of benefits. Learn more about
6
- * [setting up your app pricing](https://dev.wix.com/docs/build-apps/build-your-app/pricing-plans/set-up-your-app-pricing).
7
- */
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>>;
4
+ fetchWithAuth: typeof fetch;
5
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
6
+ }
7
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
8
+ type HttpResponse<T = any> = {
9
+ data: T;
10
+ status: number;
11
+ statusText: string;
12
+ headers: any;
13
+ request?: any;
14
+ };
15
+ type RequestOptions<_TResponse = any, Data = any> = {
16
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
17
+ url: string;
18
+ data?: Data;
19
+ params?: URLSearchParams;
20
+ } & APIMetadata;
21
+ type APIMetadata = {
22
+ methodFqn?: string;
23
+ entityFqdn?: string;
24
+ packageName?: string;
25
+ };
26
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
27
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
28
+ __type: 'event-definition';
29
+ type: Type;
30
+ isDomainEvent?: boolean;
31
+ transformations?: (envelope: unknown) => Payload;
32
+ __payload: Payload;
33
+ };
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;
37
+
38
+ declare global {
39
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
40
+ interface SymbolConstructor {
41
+ readonly observable: symbol;
42
+ }
43
+ }
44
+
8
45
  interface AppPlans {
9
46
  /** App ID, as defined in the [Wix Dev Center](https://dev.wix.com/). */
10
47
  _id?: string;
@@ -234,52 +271,40 @@ interface ListAppPlansByAppIdResponseNonNullableFields {
234
271
  appPlans: AppPlansNonNullableFields[];
235
272
  }
236
273
 
237
- type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
238
- interface HttpClient {
239
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
240
- fetchWithAuth: typeof fetch;
241
- wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
242
- }
243
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
244
- type HttpResponse<T = any> = {
245
- data: T;
246
- status: number;
247
- statusText: string;
248
- headers: any;
249
- request?: any;
250
- };
251
- type RequestOptions<_TResponse = any, Data = any> = {
252
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
253
- url: string;
254
- data?: Data;
255
- params?: URLSearchParams;
256
- } & APIMetadata;
257
- type APIMetadata = {
258
- methodFqn?: string;
259
- entityFqdn?: string;
260
- packageName?: string;
261
- };
262
- type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
263
- type EventDefinition<Payload = unknown, Type extends string = string> = {
264
- __type: 'event-definition';
265
- type: Type;
266
- isDomainEvent?: boolean;
267
- transformations?: (envelope: unknown) => Payload;
268
- __payload: Payload;
269
- };
270
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
271
- type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
272
- type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
273
-
274
- declare global {
275
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
276
- interface SymbolConstructor {
277
- readonly observable: symbol;
278
- }
274
+ declare function listAppPlansByAppId$1(httpClient: HttpClient): ListAppPlansByAppIdSignature;
275
+ interface ListAppPlansByAppIdSignature {
276
+ /**
277
+ * Retrieves plans for the given apps.
278
+ *
279
+ *
280
+ * Also returns tax settings and currency details. Wix calculates this information
281
+ * based on the 2-letter country code in [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
282
+ * format that you pass in the call's header. If you don't pass a country code in
283
+ * the header, Wix calculates the tax settings and currency details based on the
284
+ * call's IP address. Note that the tax settings and currency details may not resolve
285
+ * properly if you call through a VPN.
286
+ *
287
+ * Prices for plans that are managed outside of Wix aren't returned.
288
+ *
289
+ * Consumers must pay for yearly and multi-yearly plans of your app every month.
290
+ * For these plans this endpoint returns the price that the consumer must pay every
291
+ * month and not the total price for the entire year.
292
+ *
293
+ * <blockquote class="important">
294
+ *
295
+ * __Important:__
296
+ * The App Plans API doesn't follow any tenancy model. You don't need any
297
+ * permissions to call `List App Plans by App ID`.
298
+ *
299
+ * </blockquote>
300
+ * @param - List of app IDs to retrieve plans for.
301
+ *
302
+ * Min: 1 app ID
303
+ * Max: 100 app IDs
304
+ */
305
+ (appIds: string[]): Promise<ListAppPlansByAppIdResponse & ListAppPlansByAppIdResponseNonNullableFields>;
279
306
  }
280
307
 
281
- declare function listAppPlansByAppId$1(httpClient: HttpClient): (appIds: string[]) => Promise<ListAppPlansByAppIdResponse & ListAppPlansByAppIdResponseNonNullableFields>;
282
-
283
308
  declare function createRESTModule$4<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
284
309
 
285
310
  type _publicListAppPlansByAppIdType = typeof listAppPlansByAppId$1;
@@ -711,7 +736,22 @@ interface AppInstancePaidPlanAutoRenewalCancelledEnvelope {
711
736
  metadata: BaseEventMetadata;
712
737
  }
713
738
 
714
- declare function getAppInstance$1(httpClient: HttpClient): () => Promise<GetAppInstanceResponse & GetAppInstanceResponseNonNullableFields>;
739
+ declare function getAppInstance$1(httpClient: HttpClient): GetAppInstanceSignature;
740
+ interface GetAppInstanceSignature {
741
+ /**
742
+ * Retrieves data about the instance of your app that's installed on the Wix
743
+ * site and the site itself.
744
+ *
745
+ *
746
+ * You don't have to explicitly pass an identifier for the Wix site as part of
747
+ * the request, since this information is taken automatically from the context.
748
+ *
749
+ * In case you want `site.ownerInfo` to be included in the response, you must
750
+ * have the __Read Site Owner Email__ permission scope in addition to
751
+ * __WIX_DEVELOPERS.MANAGE_APP_INSTANCE__.
752
+ */
753
+ (): Promise<GetAppInstanceResponse & GetAppInstanceResponseNonNullableFields>;
754
+ }
715
755
  declare const onAppInstanceInstalled$1: EventDefinition<AppInstanceInstalledEnvelope, "AppInstalled">;
716
756
  declare const onAppInstanceRemoved$1: EventDefinition<AppInstanceRemovedEnvelope, "AppRemoved">;
717
757
  declare const onAppInstancePaidPlanPurchased$1: EventDefinition<AppInstancePaidPlanPurchasedEnvelope, "PaidPlanPurchased">;
@@ -726,18 +766,35 @@ type _publicGetAppInstanceType = typeof getAppInstance$1;
726
766
  declare const getAppInstance: ReturnType<typeof createRESTModule$3<_publicGetAppInstanceType>>;
727
767
 
728
768
  type _publicOnAppInstanceInstalledType = typeof onAppInstanceInstalled$1;
769
+ /**
770
+ * Triggered when an instance of your app is installed on a Wix site.
771
+ */
729
772
  declare const onAppInstanceInstalled: ReturnType<typeof createEventModule<_publicOnAppInstanceInstalledType>>;
730
773
 
731
774
  type _publicOnAppInstanceRemovedType = typeof onAppInstanceRemoved$1;
775
+ /**
776
+ * Triggered when an instance of your app is uninstalled from a Wix site.
777
+ */
732
778
  declare const onAppInstanceRemoved: ReturnType<typeof createEventModule<_publicOnAppInstanceRemovedType>>;
733
779
 
734
780
  type _publicOnAppInstancePaidPlanPurchasedType = typeof onAppInstancePaidPlanPurchased$1;
781
+ /**
782
+ * Triggered when a site owner purchases a paid plan for your app.
783
+ */
735
784
  declare const onAppInstancePaidPlanPurchased: ReturnType<typeof createEventModule<_publicOnAppInstancePaidPlanPurchasedType>>;
736
785
 
737
786
  type _publicOnAppInstancePaidPlanChangedType = typeof onAppInstancePaidPlanChanged$1;
787
+ /**
788
+ * Triggered when a site owner upgrades or downgrades their plan for your app.
789
+ */
738
790
  declare const onAppInstancePaidPlanChanged: ReturnType<typeof createEventModule<_publicOnAppInstancePaidPlanChangedType>>;
739
791
 
740
792
  type _publicOnAppInstancePaidPlanAutoRenewalCancelledType = typeof onAppInstancePaidPlanAutoRenewalCancelled$1;
793
+ /**
794
+ * Triggered when a site owner cancels a paid plan for your app. The
795
+ * site owner can continue to use your app until the end of the current billing
796
+ * cycle.
797
+ */
741
798
  declare const onAppInstancePaidPlanAutoRenewalCancelled: ReturnType<typeof createEventModule<_publicOnAppInstancePaidPlanAutoRenewalCancelledType>>;
742
799
 
743
800
  type index_d$3_AppInstalled = AppInstalled;
@@ -872,7 +929,13 @@ interface SendBiEventOptions {
872
929
  eventData?: Record<string, string>;
873
930
  }
874
931
 
875
- declare function sendBiEvent$1(httpClient: HttpClient): (options?: SendBiEventOptions) => Promise<void>;
932
+ declare function sendBiEvent$1(httpClient: HttpClient): SendBiEventSignature;
933
+ interface SendBiEventSignature {
934
+ /**
935
+ * Submit a BI event to Wix.
936
+ */
937
+ (options?: SendBiEventOptions | undefined): Promise<void>;
938
+ }
876
939
 
877
940
  declare function createRESTModule$2<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
878
941
 
@@ -1143,8 +1206,37 @@ interface GetUrlOptions {
1143
1206
  couponCode?: string | null;
1144
1207
  }
1145
1208
 
1146
- declare function getUrl$1(httpClient: HttpClient): (productId: string, options?: GetUrlOptions) => Promise<GetUrlResponse & GetUrlResponseNonNullableFields>;
1147
- declare function getPurchaseHistory$1(httpClient: HttpClient): () => Promise<GetPurchaseHistoryResponse & GetPurchaseHistoryResponseNonNullableFields>;
1209
+ declare function getUrl$1(httpClient: HttpClient): GetUrlSignature;
1210
+ interface GetUrlSignature {
1211
+ /**
1212
+ * Retrieves the URL for a Wix checkout page for the specified paid plan of your app.
1213
+ *
1214
+ *
1215
+ * This call succeeds only in case you have previously
1216
+ * [set up an external pricing page in the Wix Developers Center](https://dev.wix.com/docs/build-apps/build-your-app/pricing-plans/set-up-an-external-pricing-page).
1217
+ *
1218
+ * The returned checkout URL is valid for 48 hours.
1219
+ *
1220
+ * This API allows your app to manage your pricing page outside of Wix while
1221
+ * still using the standard Wix checkout flow.
1222
+ * @param - ID of your app's paid plan to retrieve the Wix checkout URL for. Check the
1223
+ * Wix Developers Center for a list of your app's supported product IDs.
1224
+ */
1225
+ (productId: string, options?: GetUrlOptions | undefined): Promise<GetUrlResponse & GetUrlResponseNonNullableFields>;
1226
+ }
1227
+ declare function getPurchaseHistory$1(httpClient: HttpClient): GetPurchaseHistorySignature;
1228
+ interface GetPurchaseHistorySignature {
1229
+ /**
1230
+ * Retrieves a list of the site owner's past purchases for your app.
1231
+ *
1232
+ *
1233
+ * You don't have to explicitly pass an identifier for the Wix site as part of
1234
+ * the request, since this information is taken automatically from the context.
1235
+ *
1236
+ * The response doesn't include any details about cancellations.
1237
+ */
1238
+ (): Promise<GetPurchaseHistoryResponse & GetPurchaseHistoryResponseNonNullableFields>;
1239
+ }
1148
1240
 
1149
1241
  declare function createRESTModule$1<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
1150
1242
 
@@ -1238,8 +1330,31 @@ interface GetEmbeddedScriptOptions {
1238
1330
  componentId?: string | null;
1239
1331
  }
1240
1332
 
1241
- declare function embedScript$1(httpClient: HttpClient): (properties: ScriptProperties, options?: EmbedScriptOptions) => Promise<EmbedScriptResponse & EmbedScriptResponseNonNullableFields>;
1242
- declare function getEmbeddedScript$1(httpClient: HttpClient): (options?: GetEmbeddedScriptOptions) => Promise<ScriptProperties & ScriptPropertiesNonNullableFields>;
1333
+ declare function embedScript$1(httpClient: HttpClient): EmbedScriptSignature;
1334
+ interface EmbedScriptSignature {
1335
+ /**
1336
+ * Inserts custom script tags into a site.
1337
+ *
1338
+ *
1339
+ * Your app must have an existing
1340
+ * [embedded script component](https://dev.wix.com/docs/build-apps/developer-tools/extensions/embedded-scripts),
1341
+ * with exactly matching parameter names.
1342
+ * @param - Details of the script to embed.
1343
+ */
1344
+ (properties: ScriptProperties, options?: EmbedScriptOptions | undefined): Promise<EmbedScriptResponse & EmbedScriptResponseNonNullableFields>;
1345
+ }
1346
+ declare function getEmbeddedScript$1(httpClient: HttpClient): GetEmbeddedScriptSignature;
1347
+ interface GetEmbeddedScriptSignature {
1348
+ /**
1349
+ * Retrieves information about your app's existing embedded script.
1350
+ *
1351
+ *
1352
+ * The call fails with `404` error in case your app doesn't include an
1353
+ * embedded script on the site.
1354
+ * @returns Details of the retrieved embedded script.
1355
+ */
1356
+ (options?: GetEmbeddedScriptOptions | undefined): Promise<ScriptProperties & ScriptPropertiesNonNullableFields>;
1357
+ }
1243
1358
 
1244
1359
  declare function createRESTModule<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
1245
1360
 
@@ -1,10 +1,3 @@
1
- /**
2
- * An `appPlans` object describes how you charge users for using your app.
3
- * You can set up multiple plans for a single app, with different plans giving access to
4
- * different tiers of functionality. For example, you can offer a free plan and
5
- * 3 paid plans with an increasing number of benefits. Learn more about
6
- * [setting up your app pricing](https://dev.wix.com/docs/build-apps/build-your-app/pricing-plans/set-up-your-app-pricing).
7
- */
8
1
  interface AppPlans$1 {
9
2
  /** App ID, as defined in the [Wix Dev Center](https://dev.wix.com/). */
10
3
  id?: string;
@@ -234,13 +227,6 @@ interface ListAppPlansByAppIdResponseNonNullableFields$1 {
234
227
  appPlans: AppPlansNonNullableFields$1[];
235
228
  }
236
229
 
237
- /**
238
- * An `appPlans` object describes how you charge users for using your app.
239
- * You can set up multiple plans for a single app, with different plans giving access to
240
- * different tiers of functionality. For example, you can offer a free plan and
241
- * 3 paid plans with an increasing number of benefits. Learn more about
242
- * [setting up your app pricing](https://dev.wix.com/docs/build-apps/build-your-app/pricing-plans/set-up-your-app-pricing).
243
- */
244
230
  interface AppPlans {
245
231
  /** App ID, as defined in the [Wix Dev Center](https://dev.wix.com/). */
246
232
  _id?: string;