@wix/app-management 1.0.40 → 1.0.42
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.
- package/package.json +5 -2
- package/type-bundles/context.bundle.d.ts +2334 -694
- package/type-bundles/index.bundle.d.ts +2334 -694
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
type HostModule<T, H extends Host> = {
|
|
1
|
+
type HostModule$4<T, H extends Host$4> = {
|
|
2
2
|
__type: 'host';
|
|
3
3
|
create(host: H): T;
|
|
4
4
|
};
|
|
5
|
-
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
|
|
6
|
-
type Host<Environment = unknown> = {
|
|
5
|
+
type HostModuleAPI$4<T extends HostModule$4<any, any>> = T extends HostModule$4<infer U, any> ? U : never;
|
|
6
|
+
type Host$4<Environment = unknown> = {
|
|
7
7
|
channel: {
|
|
8
8
|
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
9
9
|
disconnect: () => void;
|
|
@@ -36,92 +36,92 @@ type Host<Environment = unknown> = {
|
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
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>>;
|
|
39
|
+
type RESTFunctionDescriptor$4<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$4) => T;
|
|
40
|
+
interface HttpClient$4 {
|
|
41
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$4<TResponse, TData>): Promise<HttpResponse$4<TResponse>>;
|
|
42
42
|
fetchWithAuth: typeof fetch;
|
|
43
43
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
44
44
|
getActiveToken?: () => string | undefined;
|
|
45
45
|
}
|
|
46
|
-
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
47
|
-
type HttpResponse<T = any> = {
|
|
46
|
+
type RequestOptionsFactory$4<TResponse = any, TData = any> = (context: any) => RequestOptions$4<TResponse, TData>;
|
|
47
|
+
type HttpResponse$4<T = any> = {
|
|
48
48
|
data: T;
|
|
49
49
|
status: number;
|
|
50
50
|
statusText: string;
|
|
51
51
|
headers: any;
|
|
52
52
|
request?: any;
|
|
53
53
|
};
|
|
54
|
-
type RequestOptions<_TResponse = any, Data = any> = {
|
|
54
|
+
type RequestOptions$4<_TResponse = any, Data = any> = {
|
|
55
55
|
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
56
56
|
url: string;
|
|
57
57
|
data?: Data;
|
|
58
58
|
params?: URLSearchParams;
|
|
59
|
-
} & APIMetadata;
|
|
60
|
-
type APIMetadata = {
|
|
59
|
+
} & APIMetadata$4;
|
|
60
|
+
type APIMetadata$4 = {
|
|
61
61
|
methodFqn?: string;
|
|
62
62
|
entityFqdn?: string;
|
|
63
63
|
packageName?: string;
|
|
64
64
|
};
|
|
65
|
-
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
66
|
-
type EventDefinition$
|
|
65
|
+
type BuildRESTFunction$4<T extends RESTFunctionDescriptor$4> = T extends RESTFunctionDescriptor$4<infer U> ? U : never;
|
|
66
|
+
type EventDefinition$5<Payload = unknown, Type extends string = string> = {
|
|
67
67
|
__type: 'event-definition';
|
|
68
68
|
type: Type;
|
|
69
69
|
isDomainEvent?: boolean;
|
|
70
70
|
transformations?: (envelope: unknown) => Payload;
|
|
71
71
|
__payload: Payload;
|
|
72
72
|
};
|
|
73
|
-
declare function EventDefinition$
|
|
74
|
-
type EventHandler$
|
|
75
|
-
type BuildEventDefinition$
|
|
73
|
+
declare function EventDefinition$5<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$5<Payload, Type>;
|
|
74
|
+
type EventHandler$5<T extends EventDefinition$5> = (payload: T['__payload']) => void | Promise<void>;
|
|
75
|
+
type BuildEventDefinition$5<T extends EventDefinition$5<any, string>> = (handler: EventHandler$5<T>) => void;
|
|
76
76
|
|
|
77
|
-
type ServicePluginMethodInput = {
|
|
77
|
+
type ServicePluginMethodInput$4 = {
|
|
78
78
|
request: any;
|
|
79
79
|
metadata: any;
|
|
80
80
|
};
|
|
81
|
-
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
|
|
82
|
-
type ServicePluginMethodMetadata = {
|
|
81
|
+
type ServicePluginContract$4 = Record<string, (payload: ServicePluginMethodInput$4) => unknown | Promise<unknown>>;
|
|
82
|
+
type ServicePluginMethodMetadata$4 = {
|
|
83
83
|
name: string;
|
|
84
84
|
primaryHttpMappingPath: string;
|
|
85
85
|
transformations: {
|
|
86
|
-
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
|
|
86
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$4;
|
|
87
87
|
toREST: (...args: unknown[]) => unknown;
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
|
-
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
|
|
90
|
+
type ServicePluginDefinition$4<Contract extends ServicePluginContract$4> = {
|
|
91
91
|
__type: 'service-plugin-definition';
|
|
92
92
|
componentType: string;
|
|
93
|
-
methods: ServicePluginMethodMetadata[];
|
|
93
|
+
methods: ServicePluginMethodMetadata$4[];
|
|
94
94
|
__contract: Contract;
|
|
95
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";
|
|
96
|
+
declare function ServicePluginDefinition$4<Contract extends ServicePluginContract$4>(componentType: string, methods: ServicePluginMethodMetadata$4[]): ServicePluginDefinition$4<Contract>;
|
|
97
|
+
type BuildServicePluginDefinition$4<T extends ServicePluginDefinition$4<any>> = (implementation: T['__contract']) => void;
|
|
98
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$4 = "wix_spi_error";
|
|
99
99
|
|
|
100
|
-
type RequestContext = {
|
|
100
|
+
type RequestContext$4 = {
|
|
101
101
|
isSSR: boolean;
|
|
102
102
|
host: string;
|
|
103
103
|
protocol?: string;
|
|
104
104
|
};
|
|
105
|
-
type ResponseTransformer = (data: any, headers?: any) => any;
|
|
105
|
+
type ResponseTransformer$4 = (data: any, headers?: any) => any;
|
|
106
106
|
/**
|
|
107
107
|
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
108
108
|
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
109
109
|
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
110
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> = {
|
|
111
|
+
type Method$4 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
112
|
+
type AmbassadorRequestOptions$4<T = any> = {
|
|
113
113
|
_?: T;
|
|
114
114
|
url?: string;
|
|
115
|
-
method?: Method;
|
|
115
|
+
method?: Method$4;
|
|
116
116
|
params?: any;
|
|
117
117
|
data?: any;
|
|
118
|
-
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
118
|
+
transformResponse?: ResponseTransformer$4 | ResponseTransformer$4[];
|
|
119
119
|
};
|
|
120
|
-
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
120
|
+
type AmbassadorFactory$4<Request, Response> = (payload: Request) => ((context: RequestContext$4) => AmbassadorRequestOptions$4<Response>) & {
|
|
121
121
|
__isAmbassador: boolean;
|
|
122
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;
|
|
123
|
+
type AmbassadorFunctionDescriptor$4<Request = any, Response = any> = AmbassadorFactory$4<Request, Response>;
|
|
124
|
+
type BuildAmbassadorFunction$4<T extends AmbassadorFunctionDescriptor$4> = T extends AmbassadorFunctionDescriptor$4<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
125
125
|
|
|
126
126
|
declare global {
|
|
127
127
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -130,7 +130,7 @@ declare global {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
declare const emptyObjectSymbol: unique symbol;
|
|
133
|
+
declare const emptyObjectSymbol$4: unique symbol;
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
Represents a strictly empty plain object, the `{}` value.
|
|
@@ -158,7 +158,7 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
|
|
|
158
158
|
|
|
159
159
|
@category Object
|
|
160
160
|
*/
|
|
161
|
-
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
161
|
+
type EmptyObject$4 = {[emptyObjectSymbol$4]?: never};
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
164
|
Returns a boolean for whether the two given types are equal.
|
|
@@ -186,7 +186,7 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
186
186
|
@category Type Guard
|
|
187
187
|
@category Utilities
|
|
188
188
|
*/
|
|
189
|
-
type IsEqual<A, B> =
|
|
189
|
+
type IsEqual$4<A, B> =
|
|
190
190
|
(<G>() => G extends A ? 1 : 2) extends
|
|
191
191
|
(<G>() => G extends B ? 1 : 2)
|
|
192
192
|
? true
|
|
@@ -219,9 +219,9 @@ type Filtered = Filter<'bar', 'foo'>;
|
|
|
219
219
|
|
|
220
220
|
@see {Except}
|
|
221
221
|
*/
|
|
222
|
-
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
222
|
+
type Filter$4<KeyType, ExcludeType> = IsEqual$4<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
223
223
|
|
|
224
|
-
type ExceptOptions = {
|
|
224
|
+
type ExceptOptions$4 = {
|
|
225
225
|
/**
|
|
226
226
|
Disallow assigning non-specified properties.
|
|
227
227
|
|
|
@@ -265,8 +265,8 @@ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
|
265
265
|
|
|
266
266
|
@category Object
|
|
267
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];
|
|
268
|
+
type Except$4<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$4 = {requireExactProps: false}> = {
|
|
269
|
+
[KeyType in keyof ObjectType as Filter$4<KeyType, KeysType>]: ObjectType[KeyType];
|
|
270
270
|
} & (Options['requireExactProps'] extends true
|
|
271
271
|
? Partial<Record<KeysType, never>>
|
|
272
272
|
: {});
|
|
@@ -303,7 +303,7 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
|
303
303
|
|
|
304
304
|
@category Object
|
|
305
305
|
*/
|
|
306
|
-
type ConditionalKeys<Base, Condition> = NonNullable<
|
|
306
|
+
type ConditionalKeys$4<Base, Condition> = NonNullable<
|
|
307
307
|
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
308
308
|
{
|
|
309
309
|
// Map through all the keys of the given base type.
|
|
@@ -357,9 +357,9 @@ type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
|
357
357
|
|
|
358
358
|
@category Object
|
|
359
359
|
*/
|
|
360
|
-
type ConditionalExcept<Base, Condition> = Except<
|
|
360
|
+
type ConditionalExcept$4<Base, Condition> = Except$4<
|
|
361
361
|
Base,
|
|
362
|
-
ConditionalKeys<Base, Condition>
|
|
362
|
+
ConditionalKeys$4<Base, Condition>
|
|
363
363
|
>;
|
|
364
364
|
|
|
365
365
|
/**
|
|
@@ -367,8 +367,8 @@ ConditionalKeys<Base, Condition>
|
|
|
367
367
|
* can either be a REST module or a host module.
|
|
368
368
|
* This type is recursive, so it can describe nested modules.
|
|
369
369
|
*/
|
|
370
|
-
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition$
|
|
371
|
-
[key: string]: Descriptors | PublicMetadata | any;
|
|
370
|
+
type Descriptors$4 = RESTFunctionDescriptor$4 | AmbassadorFunctionDescriptor$4 | HostModule$4<any, any> | EventDefinition$5<any> | ServicePluginDefinition$4<any> | {
|
|
371
|
+
[key: string]: Descriptors$4 | PublicMetadata$4 | any;
|
|
372
372
|
};
|
|
373
373
|
/**
|
|
374
374
|
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
@@ -376,12 +376,12 @@ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostM
|
|
|
376
376
|
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
377
377
|
* do not match the given host (as they will not work with the given host).
|
|
378
378
|
*/
|
|
379
|
-
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
|
|
379
|
+
type BuildDescriptors$4<T extends Descriptors$4, H extends Host$4<any> | undefined, Depth extends number = 5> = {
|
|
380
380
|
done: T;
|
|
381
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$
|
|
384
|
-
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
|
|
382
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$4;
|
|
383
|
+
} ? never : T extends AmbassadorFunctionDescriptor$4 ? BuildAmbassadorFunction$4<T> : T extends RESTFunctionDescriptor$4 ? BuildRESTFunction$4<T> : T extends EventDefinition$5<any> ? BuildEventDefinition$5<T> : T extends ServicePluginDefinition$4<any> ? BuildServicePluginDefinition$4<T> : T extends HostModule$4<any, any> ? HostModuleAPI$4<T> : ConditionalExcept$4<{
|
|
384
|
+
[Key in keyof T]: T[Key] extends Descriptors$4 ? BuildDescriptors$4<T[Key], H, [
|
|
385
385
|
-1,
|
|
386
386
|
0,
|
|
387
387
|
1,
|
|
@@ -390,9 +390,9 @@ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, De
|
|
|
390
390
|
4,
|
|
391
391
|
5
|
|
392
392
|
][Depth]> : never;
|
|
393
|
-
}, EmptyObject>;
|
|
393
|
+
}, EmptyObject$4>;
|
|
394
394
|
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
395
|
-
type PublicMetadata = {
|
|
395
|
+
type PublicMetadata$4 = {
|
|
396
396
|
PACKAGE_NAME?: string;
|
|
397
397
|
};
|
|
398
398
|
|
|
@@ -404,9 +404,9 @@ declare global {
|
|
|
404
404
|
* A type used to create concerete types from SDK descriptors in
|
|
405
405
|
* case a contextual client is available.
|
|
406
406
|
*/
|
|
407
|
-
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
408
|
-
host: Host;
|
|
409
|
-
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
407
|
+
type MaybeContext$4<T extends Descriptors$4> = globalThis.ContextualClient extends {
|
|
408
|
+
host: Host$4;
|
|
409
|
+
} ? BuildDescriptors$4<T, globalThis.ContextualClient['host']> : T;
|
|
410
410
|
|
|
411
411
|
interface AppPlans {
|
|
412
412
|
/** App ID, as defined in the [app dashboard](https://dev.wix.com/apps/my-apps?viewId=active-apps-view). */
|
|
@@ -681,7 +681,7 @@ interface ListAppPlansByAppIdResponseNonNullableFields {
|
|
|
681
681
|
appPlans: AppPlansNonNullableFields[];
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
-
declare function listAppPlansByAppId$1(httpClient: HttpClient): ListAppPlansByAppIdSignature;
|
|
684
|
+
declare function listAppPlansByAppId$1(httpClient: HttpClient$4): ListAppPlansByAppIdSignature;
|
|
685
685
|
interface ListAppPlansByAppIdSignature {
|
|
686
686
|
/**
|
|
687
687
|
* Retrieves plans for the given apps.
|
|
@@ -715,7 +715,7 @@ interface ListAppPlansByAppIdSignature {
|
|
|
715
715
|
(appIds: string[]): Promise<ListAppPlansByAppIdResponse & ListAppPlansByAppIdResponseNonNullableFields>;
|
|
716
716
|
}
|
|
717
717
|
|
|
718
|
-
declare const listAppPlansByAppId: MaybeContext<BuildRESTFunction<typeof listAppPlansByAppId$1> & typeof listAppPlansByAppId$1>;
|
|
718
|
+
declare const listAppPlansByAppId: MaybeContext$4<BuildRESTFunction$4<typeof listAppPlansByAppId$1> & typeof listAppPlansByAppId$1>;
|
|
719
719
|
|
|
720
720
|
type index_d$4_AppPlans = AppPlans;
|
|
721
721
|
type index_d$4_Cycle = Cycle;
|
|
@@ -743,436 +743,1575 @@ declare namespace index_d$4 {
|
|
|
743
743
|
export { type index_d$4_AppPlans as AppPlans, type index_d$4_Cycle as Cycle, index_d$4_CycleType as CycleType, type index_d$4_Discount as Discount, index_d$4_DiscountType as DiscountType, type index_d$4_Duration as Duration, index_d$4_DurationUnit as DurationUnit, type index_d$4_ListAppPlansByAppIdRequest as ListAppPlansByAppIdRequest, type index_d$4_ListAppPlansByAppIdResponse as ListAppPlansByAppIdResponse, type index_d$4_ListAppPlansByAppIdResponseNonNullableFields as ListAppPlansByAppIdResponseNonNullableFields, type index_d$4_Plan as Plan, type index_d$4_Price as Price, index_d$4_SaleType as SaleType, type index_d$4_TaxSettings as TaxSettings, index_d$4_TaxType as TaxType, type index_d$4_UsageBasedDetails as UsageBasedDetails, index_d$4_listAppPlansByAppId as listAppPlansByAppId };
|
|
744
744
|
}
|
|
745
745
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
* App name, as set by you in the Customs Apps page during the app creation
|
|
761
|
-
* process.
|
|
762
|
-
*/
|
|
763
|
-
appName?: string;
|
|
764
|
-
/** Version of your app that's installed on the Wix site, as set by you during the app creation process. */
|
|
765
|
-
appVersion?: string | null;
|
|
766
|
-
/**
|
|
767
|
-
* Whether the site owners have installed a free or paid version of your app
|
|
768
|
-
* on their site.
|
|
769
|
-
*/
|
|
770
|
-
isFree?: boolean;
|
|
771
|
-
/**
|
|
772
|
-
* Billing information for the app instance. Available only in case
|
|
773
|
-
* `{"isFree": false}`.
|
|
774
|
-
*/
|
|
775
|
-
billing?: BillingInfo;
|
|
776
|
-
/**
|
|
777
|
-
* List of [permissions](https://dev.wix.com/docs/build-apps/developer-tools/developers-center/example-app-walkthrough/build-an-app#4-add-permissions)
|
|
778
|
-
* that the site owners have granted your app. You set the list of permissions that
|
|
779
|
-
* your app requires from the site owners in your app's Permissions page during the
|
|
780
|
-
* app creation process.
|
|
781
|
-
*/
|
|
782
|
-
permissions?: string[];
|
|
783
|
-
/** Plans available to this app instance. */
|
|
784
|
-
availablePlans?: AvailablePlan[];
|
|
746
|
+
type HostModule$3<T, H extends Host$3> = {
|
|
747
|
+
__type: 'host';
|
|
748
|
+
create(host: H): T;
|
|
749
|
+
};
|
|
750
|
+
type HostModuleAPI$3<T extends HostModule$3<any, any>> = T extends HostModule$3<infer U, any> ? U : never;
|
|
751
|
+
type Host$3<Environment = unknown> = {
|
|
752
|
+
channel: {
|
|
753
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
754
|
+
disconnect: () => void;
|
|
755
|
+
} | Promise<{
|
|
756
|
+
disconnect: () => void;
|
|
757
|
+
}>;
|
|
758
|
+
};
|
|
759
|
+
environment?: Environment;
|
|
785
760
|
/**
|
|
786
|
-
*
|
|
787
|
-
* Available only in case `{"copiedFromTemplate": true}`.
|
|
788
|
-
* All visual settings of the Wix site and app data are duplicated during the
|
|
789
|
-
* cloning process. Wix also notifies you in case there is any additional
|
|
790
|
-
* external functionality for the original site.
|
|
761
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
791
762
|
*/
|
|
792
|
-
|
|
763
|
+
apiBaseUrl?: string;
|
|
793
764
|
/**
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
* @deprecated
|
|
765
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
766
|
+
* like internationalization, billing, etc.
|
|
797
767
|
*/
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
768
|
+
essentials?: {
|
|
769
|
+
/**
|
|
770
|
+
* The language of the currently viewed session
|
|
771
|
+
*/
|
|
772
|
+
language?: string;
|
|
773
|
+
/**
|
|
774
|
+
* The locale of the currently viewed session
|
|
775
|
+
*/
|
|
776
|
+
locale?: string;
|
|
777
|
+
/**
|
|
778
|
+
* Any headers that should be passed through to the API requests
|
|
779
|
+
*/
|
|
780
|
+
passThroughHeaders?: Record<string, string>;
|
|
781
|
+
};
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
type RESTFunctionDescriptor$3<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$3) => T;
|
|
785
|
+
interface HttpClient$3 {
|
|
786
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$3<TResponse, TData>): Promise<HttpResponse$3<TResponse>>;
|
|
787
|
+
fetchWithAuth: typeof fetch;
|
|
788
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
789
|
+
getActiveToken?: () => string | undefined;
|
|
803
790
|
}
|
|
804
|
-
|
|
805
|
-
|
|
791
|
+
type RequestOptionsFactory$3<TResponse = any, TData = any> = (context: any) => RequestOptions$3<TResponse, TData>;
|
|
792
|
+
type HttpResponse$3<T = any> = {
|
|
793
|
+
data: T;
|
|
794
|
+
status: number;
|
|
795
|
+
statusText: string;
|
|
796
|
+
headers: any;
|
|
797
|
+
request?: any;
|
|
798
|
+
};
|
|
799
|
+
type RequestOptions$3<_TResponse = any, Data = any> = {
|
|
800
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
801
|
+
url: string;
|
|
802
|
+
data?: Data;
|
|
803
|
+
params?: URLSearchParams;
|
|
804
|
+
} & APIMetadata$3;
|
|
805
|
+
type APIMetadata$3 = {
|
|
806
|
+
methodFqn?: string;
|
|
807
|
+
entityFqdn?: string;
|
|
806
808
|
packageName?: string;
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
809
|
+
};
|
|
810
|
+
type BuildRESTFunction$3<T extends RESTFunctionDescriptor$3> = T extends RESTFunctionDescriptor$3<infer U> ? U : never;
|
|
811
|
+
type EventDefinition$4<Payload = unknown, Type extends string = string> = {
|
|
812
|
+
__type: 'event-definition';
|
|
813
|
+
type: Type;
|
|
814
|
+
isDomainEvent?: boolean;
|
|
815
|
+
transformations?: (envelope: unknown) => Payload;
|
|
816
|
+
__payload: Payload;
|
|
817
|
+
};
|
|
818
|
+
declare function EventDefinition$4<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$4<Payload, Type>;
|
|
819
|
+
type EventHandler$4<T extends EventDefinition$4> = (payload: T['__payload']) => void | Promise<void>;
|
|
820
|
+
type BuildEventDefinition$4<T extends EventDefinition$4<any, string>> = (handler: EventHandler$4<T>) => void;
|
|
821
|
+
|
|
822
|
+
type ServicePluginMethodInput$3 = {
|
|
823
|
+
request: any;
|
|
824
|
+
metadata: any;
|
|
825
|
+
};
|
|
826
|
+
type ServicePluginContract$3 = Record<string, (payload: ServicePluginMethodInput$3) => unknown | Promise<unknown>>;
|
|
827
|
+
type ServicePluginMethodMetadata$3 = {
|
|
828
|
+
name: string;
|
|
829
|
+
primaryHttpMappingPath: string;
|
|
830
|
+
transformations: {
|
|
831
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$3;
|
|
832
|
+
toREST: (...args: unknown[]) => unknown;
|
|
833
|
+
};
|
|
834
|
+
};
|
|
835
|
+
type ServicePluginDefinition$3<Contract extends ServicePluginContract$3> = {
|
|
836
|
+
__type: 'service-plugin-definition';
|
|
837
|
+
componentType: string;
|
|
838
|
+
methods: ServicePluginMethodMetadata$3[];
|
|
839
|
+
__contract: Contract;
|
|
840
|
+
};
|
|
841
|
+
declare function ServicePluginDefinition$3<Contract extends ServicePluginContract$3>(componentType: string, methods: ServicePluginMethodMetadata$3[]): ServicePluginDefinition$3<Contract>;
|
|
842
|
+
type BuildServicePluginDefinition$3<T extends ServicePluginDefinition$3<any>> = (implementation: T['__contract']) => void;
|
|
843
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$3 = "wix_spi_error";
|
|
844
|
+
|
|
845
|
+
type RequestContext$3 = {
|
|
846
|
+
isSSR: boolean;
|
|
847
|
+
host: string;
|
|
848
|
+
protocol?: string;
|
|
849
|
+
};
|
|
850
|
+
type ResponseTransformer$3 = (data: any, headers?: any) => any;
|
|
851
|
+
/**
|
|
852
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
853
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
854
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
855
|
+
*/
|
|
856
|
+
type Method$3 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
857
|
+
type AmbassadorRequestOptions$3<T = any> = {
|
|
858
|
+
_?: T;
|
|
859
|
+
url?: string;
|
|
860
|
+
method?: Method$3;
|
|
861
|
+
params?: any;
|
|
862
|
+
data?: any;
|
|
863
|
+
transformResponse?: ResponseTransformer$3 | ResponseTransformer$3[];
|
|
864
|
+
};
|
|
865
|
+
type AmbassadorFactory$3<Request, Response> = (payload: Request) => ((context: RequestContext$3) => AmbassadorRequestOptions$3<Response>) & {
|
|
866
|
+
__isAmbassador: boolean;
|
|
867
|
+
};
|
|
868
|
+
type AmbassadorFunctionDescriptor$3<Request = any, Response = any> = AmbassadorFactory$3<Request, Response>;
|
|
869
|
+
type BuildAmbassadorFunction$3<T extends AmbassadorFunctionDescriptor$3> = T extends AmbassadorFunctionDescriptor$3<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
870
|
+
|
|
871
|
+
declare global {
|
|
872
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
873
|
+
interface SymbolConstructor {
|
|
874
|
+
readonly observable: symbol;
|
|
875
|
+
}
|
|
851
876
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
877
|
+
|
|
878
|
+
declare const emptyObjectSymbol$3: unique symbol;
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
882
|
+
|
|
883
|
+
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)).
|
|
884
|
+
|
|
885
|
+
@example
|
|
886
|
+
```
|
|
887
|
+
import type {EmptyObject} from 'type-fest';
|
|
888
|
+
|
|
889
|
+
// The following illustrates the problem with `{}`.
|
|
890
|
+
const foo1: {} = {}; // Pass
|
|
891
|
+
const foo2: {} = []; // Pass
|
|
892
|
+
const foo3: {} = 42; // Pass
|
|
893
|
+
const foo4: {} = {a: 1}; // Pass
|
|
894
|
+
|
|
895
|
+
// With `EmptyObject` only the first case is valid.
|
|
896
|
+
const bar1: EmptyObject = {}; // Pass
|
|
897
|
+
const bar2: EmptyObject = 42; // Fail
|
|
898
|
+
const bar3: EmptyObject = []; // Fail
|
|
899
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
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}.
|
|
903
|
+
|
|
904
|
+
@category Object
|
|
905
|
+
*/
|
|
906
|
+
type EmptyObject$3 = {[emptyObjectSymbol$3]?: never};
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
Returns a boolean for whether the two given types are equal.
|
|
910
|
+
|
|
911
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
912
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
913
|
+
|
|
914
|
+
Use-cases:
|
|
915
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
916
|
+
|
|
917
|
+
@example
|
|
918
|
+
```
|
|
919
|
+
import type {IsEqual} from 'type-fest';
|
|
920
|
+
|
|
921
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
922
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
923
|
+
type Includes<Value extends readonly any[], Item> =
|
|
924
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
925
|
+
? IsEqual<Value[0], Item> extends true
|
|
926
|
+
? true
|
|
927
|
+
: Includes<rest, Item>
|
|
928
|
+
: false;
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
@category Type Guard
|
|
932
|
+
@category Utilities
|
|
933
|
+
*/
|
|
934
|
+
type IsEqual$3<A, B> =
|
|
935
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
936
|
+
(<G>() => G extends B ? 1 : 2)
|
|
937
|
+
? true
|
|
938
|
+
: false;
|
|
939
|
+
|
|
940
|
+
/**
|
|
941
|
+
Filter out keys from an object.
|
|
942
|
+
|
|
943
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
944
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
945
|
+
Returns `Key` otherwise.
|
|
946
|
+
|
|
947
|
+
@example
|
|
948
|
+
```
|
|
949
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
950
|
+
//=> never
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
@example
|
|
954
|
+
```
|
|
955
|
+
type Filtered = Filter<'bar', string>;
|
|
956
|
+
//=> never
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
@example
|
|
960
|
+
```
|
|
961
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
962
|
+
//=> 'bar'
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
@see {Except}
|
|
966
|
+
*/
|
|
967
|
+
type Filter$3<KeyType, ExcludeType> = IsEqual$3<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
968
|
+
|
|
969
|
+
type ExceptOptions$3 = {
|
|
970
|
+
/**
|
|
971
|
+
Disallow assigning non-specified properties.
|
|
972
|
+
|
|
973
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
974
|
+
|
|
975
|
+
@default false
|
|
976
|
+
*/
|
|
977
|
+
requireExactProps?: boolean;
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
Create a type from an object type without certain keys.
|
|
982
|
+
|
|
983
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
984
|
+
|
|
985
|
+
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.
|
|
986
|
+
|
|
987
|
+
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)).
|
|
988
|
+
|
|
989
|
+
@example
|
|
990
|
+
```
|
|
991
|
+
import type {Except} from 'type-fest';
|
|
992
|
+
|
|
993
|
+
type Foo = {
|
|
994
|
+
a: number;
|
|
995
|
+
b: string;
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
999
|
+
//=> {b: string}
|
|
1000
|
+
|
|
1001
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
1002
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
1003
|
+
|
|
1004
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
1005
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
1006
|
+
|
|
1007
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
1008
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
@category Object
|
|
1012
|
+
*/
|
|
1013
|
+
type Except$3<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$3 = {requireExactProps: false}> = {
|
|
1014
|
+
[KeyType in keyof ObjectType as Filter$3<KeyType, KeysType>]: ObjectType[KeyType];
|
|
1015
|
+
} & (Options['requireExactProps'] extends true
|
|
1016
|
+
? Partial<Record<KeysType, never>>
|
|
1017
|
+
: {});
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
1021
|
+
|
|
1022
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
1023
|
+
|
|
1024
|
+
@example
|
|
1025
|
+
```
|
|
1026
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1027
|
+
|
|
1028
|
+
interface Example {
|
|
1029
|
+
a: string;
|
|
1030
|
+
b: string | number;
|
|
1031
|
+
c?: string;
|
|
1032
|
+
d: {};
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
1036
|
+
//=> 'a'
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
1040
|
+
|
|
1041
|
+
@example
|
|
1042
|
+
```
|
|
1043
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1044
|
+
|
|
1045
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
1046
|
+
//=> 'a' | 'c'
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
@category Object
|
|
1050
|
+
*/
|
|
1051
|
+
type ConditionalKeys$3<Base, Condition> = NonNullable<
|
|
1052
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
1053
|
+
{
|
|
1054
|
+
// Map through all the keys of the given base type.
|
|
1055
|
+
[Key in keyof Base]:
|
|
1056
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
1057
|
+
Base[Key] extends Condition
|
|
1058
|
+
// Retain this key since the condition passes.
|
|
1059
|
+
? Key
|
|
1060
|
+
// Discard this key since the condition fails.
|
|
1061
|
+
: never;
|
|
1062
|
+
|
|
1063
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
1064
|
+
}[keyof Base]
|
|
1065
|
+
>;
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
1069
|
+
|
|
1070
|
+
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.
|
|
1071
|
+
|
|
1072
|
+
@example
|
|
1073
|
+
```
|
|
1074
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
1075
|
+
|
|
1076
|
+
class Awesome {
|
|
1077
|
+
name: string;
|
|
1078
|
+
successes: number;
|
|
1079
|
+
failures: bigint;
|
|
1080
|
+
|
|
1081
|
+
run() {}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
1085
|
+
//=> {run: () => void}
|
|
1086
|
+
```
|
|
1087
|
+
|
|
1088
|
+
@example
|
|
1089
|
+
```
|
|
1090
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
1091
|
+
|
|
1092
|
+
interface Example {
|
|
1093
|
+
a: string;
|
|
1094
|
+
b: string | number;
|
|
1095
|
+
c: () => void;
|
|
1096
|
+
d: {};
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
1100
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
@category Object
|
|
1104
|
+
*/
|
|
1105
|
+
type ConditionalExcept$3<Base, Condition> = Except$3<
|
|
1106
|
+
Base,
|
|
1107
|
+
ConditionalKeys$3<Base, Condition>
|
|
1108
|
+
>;
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
1112
|
+
* can either be a REST module or a host module.
|
|
1113
|
+
* This type is recursive, so it can describe nested modules.
|
|
1114
|
+
*/
|
|
1115
|
+
type Descriptors$3 = RESTFunctionDescriptor$3 | AmbassadorFunctionDescriptor$3 | HostModule$3<any, any> | EventDefinition$4<any> | ServicePluginDefinition$3<any> | {
|
|
1116
|
+
[key: string]: Descriptors$3 | PublicMetadata$3 | any;
|
|
1117
|
+
};
|
|
1118
|
+
/**
|
|
1119
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
1120
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
1121
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
1122
|
+
* do not match the given host (as they will not work with the given host).
|
|
1123
|
+
*/
|
|
1124
|
+
type BuildDescriptors$3<T extends Descriptors$3, H extends Host$3<any> | undefined, Depth extends number = 5> = {
|
|
1125
|
+
done: T;
|
|
1126
|
+
recurse: T extends {
|
|
1127
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$3;
|
|
1128
|
+
} ? never : T extends AmbassadorFunctionDescriptor$3 ? BuildAmbassadorFunction$3<T> : T extends RESTFunctionDescriptor$3 ? BuildRESTFunction$3<T> : T extends EventDefinition$4<any> ? BuildEventDefinition$4<T> : T extends ServicePluginDefinition$3<any> ? BuildServicePluginDefinition$3<T> : T extends HostModule$3<any, any> ? HostModuleAPI$3<T> : ConditionalExcept$3<{
|
|
1129
|
+
[Key in keyof T]: T[Key] extends Descriptors$3 ? BuildDescriptors$3<T[Key], H, [
|
|
1130
|
+
-1,
|
|
1131
|
+
0,
|
|
1132
|
+
1,
|
|
1133
|
+
2,
|
|
1134
|
+
3,
|
|
1135
|
+
4,
|
|
1136
|
+
5
|
|
1137
|
+
][Depth]> : never;
|
|
1138
|
+
}, EmptyObject$3>;
|
|
1139
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
1140
|
+
type PublicMetadata$3 = {
|
|
1141
|
+
PACKAGE_NAME?: string;
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
declare global {
|
|
1145
|
+
interface ContextualClient {
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* A type used to create concerete types from SDK descriptors in
|
|
1150
|
+
* case a contextual client is available.
|
|
1151
|
+
*/
|
|
1152
|
+
type MaybeContext$3<T extends Descriptors$3> = globalThis.ContextualClient extends {
|
|
1153
|
+
host: Host$3;
|
|
1154
|
+
} ? BuildDescriptors$3<T, globalThis.ContextualClient['host']> : T;
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* An app instance is a specific occurrence of your app on a particular Wix site.
|
|
1158
|
+
* When a site owner installs your app, a unique instance is generated for that
|
|
1159
|
+
* specific site. Use the `instanceId` to keep track of the individual data
|
|
1160
|
+
* associated with each app instance.
|
|
1161
|
+
*/
|
|
1162
|
+
interface AppInstance {
|
|
1163
|
+
/**
|
|
1164
|
+
* ID of the app instance. You can use it to keep track of the individual
|
|
1165
|
+
* data that's associated with the specific occurence of your app that's
|
|
1166
|
+
* installed on a Wix site.
|
|
1167
|
+
*/
|
|
1168
|
+
instanceId?: string;
|
|
1169
|
+
/**
|
|
1170
|
+
* App name, as set by you in the Customs Apps page during the app creation
|
|
1171
|
+
* process.
|
|
1172
|
+
*/
|
|
1173
|
+
appName?: string;
|
|
1174
|
+
/** Version of your app that's installed on the Wix site, as set by you during the app creation process. */
|
|
1175
|
+
appVersion?: string | null;
|
|
1176
|
+
/**
|
|
1177
|
+
* Whether the site owners have installed a free or paid version of your app
|
|
1178
|
+
* on their site.
|
|
1179
|
+
*/
|
|
1180
|
+
isFree?: boolean;
|
|
1181
|
+
/**
|
|
1182
|
+
* Billing information for the app instance. Available only in case
|
|
1183
|
+
* `{"isFree": false}`.
|
|
1184
|
+
*/
|
|
1185
|
+
billing?: BillingInfo;
|
|
1186
|
+
/**
|
|
1187
|
+
* List of [permissions](https://dev.wix.com/docs/build-apps/developer-tools/developers-center/example-app-walkthrough/build-an-app#4-add-permissions)
|
|
1188
|
+
* that the site owners have granted your app. You set the list of permissions that
|
|
1189
|
+
* your app requires from the site owners in your app's Permissions page during the
|
|
1190
|
+
* app creation process.
|
|
1191
|
+
*/
|
|
1192
|
+
permissions?: string[];
|
|
1193
|
+
/** Plans available to this app instance. */
|
|
1194
|
+
availablePlans?: AvailablePlan[];
|
|
1195
|
+
/**
|
|
1196
|
+
* ID of the Wix site from which the instance of your app has been cloned.
|
|
1197
|
+
* Available only in case `{"copiedFromTemplate": true}`.
|
|
1198
|
+
* All visual settings of the Wix site and app data are duplicated during the
|
|
1199
|
+
* cloning process. Wix also notifies you in case there is any additional
|
|
1200
|
+
* external functionality for the original site.
|
|
1201
|
+
*/
|
|
1202
|
+
originInstanceId?: string | null;
|
|
1203
|
+
/**
|
|
1204
|
+
* __Deprecated__. This parameter will be removed on March 30, 2023. Use
|
|
1205
|
+
* `copiedFromTemplate` instead.
|
|
1206
|
+
* @deprecated
|
|
1207
|
+
*/
|
|
1208
|
+
isOriginSiteTemplate?: boolean;
|
|
1209
|
+
/** Whether the app instance was created when another Wix site was cloned. */
|
|
1210
|
+
copiedFromTemplate?: boolean;
|
|
1211
|
+
/** Whether the app instance includes a free trial that hasn't started yet. */
|
|
1212
|
+
freeTrialAvailable?: boolean;
|
|
1213
|
+
}
|
|
1214
|
+
interface BillingInfo {
|
|
1215
|
+
/** Name of the package that the site owner has paid for. */
|
|
1216
|
+
packageName?: string;
|
|
1217
|
+
/**
|
|
1218
|
+
* Interval of the billing cycle. `"ONE_TIME"` means that site owners have
|
|
1219
|
+
* purchased unlimited access to the app with a single, upfront payment.
|
|
1220
|
+
*/
|
|
1221
|
+
billingCycle?: PaymentCycle$1;
|
|
1222
|
+
/**
|
|
1223
|
+
* Date and time the site owners have purchased the app's paid plan in
|
|
1224
|
+
* `YYYY-MM-DDThh:mm:ss.sssZ` format.
|
|
1225
|
+
*/
|
|
1226
|
+
timeStamp?: string;
|
|
1227
|
+
/**
|
|
1228
|
+
* Date and time the app's current billing cycle ends in
|
|
1229
|
+
* `YYYY-MM-DDThh:mm:ss.sssZ` format. Available only for yearly and
|
|
1230
|
+
* multi-yearly plans.
|
|
1231
|
+
*/
|
|
1232
|
+
expirationDate?: string | null;
|
|
1233
|
+
/**
|
|
1234
|
+
* Whether the app's subscription automatically renews at the end of the
|
|
1235
|
+
* current billing cycle.
|
|
1236
|
+
*/
|
|
1237
|
+
autoRenewing?: boolean | null;
|
|
1238
|
+
/** ID of the invoice for the current billing cycle. */
|
|
1239
|
+
invoiceId?: string | null;
|
|
1240
|
+
/**
|
|
1241
|
+
* Information about any discounts applied to the app instance's current billing cycle.
|
|
1242
|
+
* If the site owners applied a developer coupon or Wix Voucher
|
|
1243
|
+
* when installing the paid version of your app, this field holds the coupon's
|
|
1244
|
+
* name or `“Wix discount coupon”`. Site owners may receive a Wix Voucher when
|
|
1245
|
+
* upgrading their Wix subscription. If there is no discount for the
|
|
1246
|
+
* current billing cycle, the field is an empty string.
|
|
1247
|
+
*/
|
|
1248
|
+
source?: string | null;
|
|
1249
|
+
/** Information about the free trial applied, if relevant. */
|
|
1250
|
+
freeTrialInfo?: FreeTrialInfo;
|
|
1251
|
+
}
|
|
1252
|
+
declare enum PaymentCycle$1 {
|
|
1253
|
+
NO_CYCLE = "NO_CYCLE",
|
|
1254
|
+
MONTHLY = "MONTHLY",
|
|
1255
|
+
YEARLY = "YEARLY",
|
|
1256
|
+
ONE_TIME = "ONE_TIME",
|
|
1257
|
+
TWO_YEARS = "TWO_YEARS",
|
|
1258
|
+
THREE_YEARS = "THREE_YEARS",
|
|
1259
|
+
FOUR_YEARS = "FOUR_YEARS",
|
|
1260
|
+
FIVE_YEARS = "FIVE_YEARS"
|
|
1261
|
+
}
|
|
1262
|
+
interface FreeTrialInfo {
|
|
1263
|
+
/**
|
|
1264
|
+
* Current free trial status.
|
|
1265
|
+
*
|
|
1266
|
+
* Supported values:
|
|
1267
|
+
*
|
|
1268
|
+
* - `IN_PROGRESS`: The free trial is currently in progress.
|
|
1269
|
+
* - `ENDED`: The free trial has ended.
|
|
1270
|
+
* - `NOT_AVAILABLE`: No free trial was applied, as none was available.
|
|
866
1271
|
* @readonly
|
|
867
1272
|
*/
|
|
868
|
-
|
|
1273
|
+
status?: FreeTrialStatus;
|
|
1274
|
+
/**
|
|
1275
|
+
* When the free trial has ended. Populated only once the free trial is over.
|
|
1276
|
+
* @readonly
|
|
1277
|
+
*/
|
|
1278
|
+
endDate?: Date;
|
|
1279
|
+
}
|
|
1280
|
+
declare enum FreeTrialStatus {
|
|
1281
|
+
UNKNOWN_STATUS = "UNKNOWN_STATUS",
|
|
1282
|
+
IN_PROGRESS = "IN_PROGRESS",
|
|
1283
|
+
ENDED = "ENDED",
|
|
1284
|
+
NOT_AVAILABLE = "NOT_AVAILABLE"
|
|
1285
|
+
}
|
|
1286
|
+
interface AvailablePlan {
|
|
1287
|
+
/** Package name of the available plan. */
|
|
1288
|
+
packageName?: string;
|
|
1289
|
+
/** Source of the available plan. Can be a bundle or 3rd-party app. */
|
|
1290
|
+
source?: string;
|
|
1291
|
+
}
|
|
1292
|
+
interface AppInstalled {
|
|
1293
|
+
/** Unique identifier of the app within the website. */
|
|
1294
|
+
appId?: string;
|
|
1295
|
+
/** Instance ID of the app in the original website (relevant only when this site was [duplicated from another site](https://support.wix.com/en/article/duplicating-your-site-1472847)). */
|
|
1296
|
+
originInstanceId?: string | null;
|
|
1297
|
+
}
|
|
1298
|
+
interface AppRemoved {
|
|
1299
|
+
/** Unique identifier of the app within the website. */
|
|
1300
|
+
appId?: string;
|
|
1301
|
+
}
|
|
1302
|
+
interface PaidPlanPurchased {
|
|
1303
|
+
/** Date and time of purchase. */
|
|
1304
|
+
operationTimeStamp?: Date;
|
|
1305
|
+
/** Purchased app plan. */
|
|
1306
|
+
vendorProductId?: string;
|
|
1307
|
+
/** Selected payment cycle. */
|
|
1308
|
+
cycle?: PaymentCycle$1;
|
|
1309
|
+
/** Plan expiration date. */
|
|
1310
|
+
expiresOn?: Date;
|
|
1311
|
+
/** Coupon applied to purchase (if relevant). */
|
|
1312
|
+
couponName?: string | null;
|
|
1313
|
+
/** Invoice ID. */
|
|
1314
|
+
invoiceId?: string | null;
|
|
1315
|
+
}
|
|
1316
|
+
interface PaidPlanChanged {
|
|
1317
|
+
/** Date and time of change. */
|
|
1318
|
+
operationTimeStamp?: Date;
|
|
1319
|
+
/** Newly purchased app plan. */
|
|
1320
|
+
vendorProductId?: string;
|
|
1321
|
+
/** Newly selected payment cycle. */
|
|
1322
|
+
cycle?: PaymentCycle$1;
|
|
1323
|
+
/** Previous app plan. */
|
|
1324
|
+
previousVendorProductId?: string | null;
|
|
1325
|
+
/** Previous payment cycle. */
|
|
1326
|
+
previousCycle?: PaymentCycle$1;
|
|
1327
|
+
/** Coupon applied to purchase (if relevant). */
|
|
1328
|
+
couponName?: string | null;
|
|
1329
|
+
/** Invoice ID. */
|
|
1330
|
+
invoiceId?: string | null;
|
|
1331
|
+
}
|
|
1332
|
+
interface PaidPlanAutoRenewalCancelled {
|
|
1333
|
+
/** Date and time of auto-renewal cancellation. */
|
|
1334
|
+
operationTimeStamp?: Date;
|
|
1335
|
+
/** Current app plan. */
|
|
1336
|
+
vendorProductId?: string;
|
|
1337
|
+
/** Current payment cycle. */
|
|
1338
|
+
cycle?: PaymentCycle$1;
|
|
1339
|
+
/** Supported values: `UNKNOWN_CANCELLATION_TYPE_ERROR_STATE`, `USER_CANCEL`, `FAILED_PAYMENT`, `TRANSFER_CANCELLATION_REASON`. Reason provided by app for cancellation (if relevant). */
|
|
1340
|
+
cancelReason?: string | null;
|
|
1341
|
+
/** Reason provided by site owner for cancellation (if relevant). */
|
|
1342
|
+
userReason?: string | null;
|
|
1343
|
+
/** Cancellation type. */
|
|
1344
|
+
subscriptionCancellationType?: string | null;
|
|
1345
|
+
}
|
|
1346
|
+
interface GetAppInstanceRequest {
|
|
1347
|
+
}
|
|
1348
|
+
interface GetAppInstanceResponse {
|
|
1349
|
+
/** Retrieved app instance. */
|
|
1350
|
+
instance?: AppInstance;
|
|
1351
|
+
/** Information about the corresponding Wix site. */
|
|
1352
|
+
site?: SiteInfo;
|
|
1353
|
+
}
|
|
1354
|
+
interface SiteInfo {
|
|
1355
|
+
/** Display name of the site. */
|
|
1356
|
+
siteDisplayName?: string | null;
|
|
1357
|
+
/**
|
|
1358
|
+
* 2-letter language code of the site's locale in
|
|
1359
|
+
* [ISO 639-1 alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format.
|
|
1360
|
+
*/
|
|
1361
|
+
locale?: string;
|
|
1362
|
+
/**
|
|
1363
|
+
* 3-letter currency code for the site's billing in
|
|
1364
|
+
* [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format.
|
|
1365
|
+
*/
|
|
1366
|
+
paymentCurrency?: string;
|
|
1367
|
+
/** Information about the site's supported languages. */
|
|
1368
|
+
multilingual?: Multilingual;
|
|
1369
|
+
/** URL of the site. Available only in case the site has been published. */
|
|
1370
|
+
url?: string | null;
|
|
1371
|
+
/** Description of the site. */
|
|
1372
|
+
description?: string | null;
|
|
1373
|
+
/** Wix apps that are installed on the site. */
|
|
1374
|
+
installedWixApps?: string[];
|
|
1375
|
+
/**
|
|
1376
|
+
* > **Deprecation Notice:** This parameter will be removed on June 30, 2022. Use `ownerInfo` instead.
|
|
1377
|
+
* @deprecated
|
|
1378
|
+
*/
|
|
1379
|
+
ownerEmail?: string | null;
|
|
1380
|
+
/**
|
|
1381
|
+
* Information about the site owner. Available only when calling
|
|
1382
|
+
* _Get App Instance_ with the __Read Site Owner Email__ permission scope.
|
|
1383
|
+
*/
|
|
1384
|
+
ownerInfo?: OwnerInfo;
|
|
1385
|
+
/** Site ID. */
|
|
1386
|
+
siteId?: string;
|
|
1387
|
+
}
|
|
1388
|
+
interface Multilingual {
|
|
1389
|
+
/** Whether the site supports more than a single language. */
|
|
1390
|
+
isMultiLingual?: boolean;
|
|
1391
|
+
/** List of supported languages. Returned only when `{"isMultiLingual": true}`. */
|
|
1392
|
+
supportedLanguages?: SupportedLanguage[];
|
|
1393
|
+
}
|
|
1394
|
+
interface SupportedLanguage {
|
|
1395
|
+
/** Two-letter language code in [ISO 639-1 alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. */
|
|
1396
|
+
languageCode?: string;
|
|
1397
|
+
/** Locale. */
|
|
1398
|
+
locale?: Locale;
|
|
1399
|
+
/** Whether the supported language is the primary language for the site. */
|
|
1400
|
+
isPrimary?: boolean;
|
|
1401
|
+
/** Language icon. */
|
|
1402
|
+
countryCode?: string;
|
|
1403
|
+
/** How the language will be resolved. For internal use. */
|
|
1404
|
+
resolutionMethod?: ResolutionMethod;
|
|
1405
|
+
}
|
|
1406
|
+
interface Locale {
|
|
1407
|
+
/** Two-letter language code in [ISO 639-1 alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. */
|
|
1408
|
+
languageCode?: string;
|
|
1409
|
+
/** Two-letter country code in [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) format. */
|
|
1410
|
+
country?: string;
|
|
1411
|
+
}
|
|
1412
|
+
declare enum ResolutionMethod {
|
|
1413
|
+
QUERY_PARAM = "QUERY_PARAM",
|
|
1414
|
+
SUBDOMAIN = "SUBDOMAIN",
|
|
1415
|
+
SUBDIRECTORY = "SUBDIRECTORY"
|
|
1416
|
+
}
|
|
1417
|
+
interface OwnerInfo {
|
|
1418
|
+
/** Site owner's email address. Identical to the site owner's login email. */
|
|
1419
|
+
email?: string;
|
|
1420
|
+
/**
|
|
1421
|
+
* Supported values: `VERIFIED_OPT_IN`, `VERIFIED_OPT_OUT`,
|
|
1422
|
+
* `NOT_VERIFIED_OPT_IN`, `NOT_VERIFIED_OPT_OUT`.
|
|
1423
|
+
*
|
|
1424
|
+
* Whether the site owner has verified their email and whether they have chosen
|
|
1425
|
+
* to receive email notifications from Wix.
|
|
1426
|
+
*/
|
|
1427
|
+
emailStatus?: string;
|
|
1428
|
+
}
|
|
1429
|
+
interface GetAppInstanceByInstanceIdRequest {
|
|
1430
|
+
/** ID of the app instance to retrieve. */
|
|
1431
|
+
instanceId?: string;
|
|
1432
|
+
}
|
|
1433
|
+
interface MessageEnvelope$1 {
|
|
1434
|
+
/** App instance ID. */
|
|
1435
|
+
instanceId?: string | null;
|
|
1436
|
+
/** Event type. */
|
|
1437
|
+
eventType?: string;
|
|
1438
|
+
/** The identification type and identity data. */
|
|
1439
|
+
identity?: IdentificationData$1;
|
|
1440
|
+
/** Stringify payload. */
|
|
1441
|
+
data?: string;
|
|
1442
|
+
}
|
|
1443
|
+
interface IdentificationData$1 extends IdentificationDataIdOneOf$1 {
|
|
1444
|
+
/** ID of a site visitor that has not logged in to the site. */
|
|
1445
|
+
anonymousVisitorId?: string;
|
|
1446
|
+
/** ID of a site visitor that has logged in to the site. */
|
|
1447
|
+
memberId?: string;
|
|
1448
|
+
/** ID of a Wix user (site owner, contributor, etc.). */
|
|
1449
|
+
wixUserId?: string;
|
|
1450
|
+
/** ID of an app. */
|
|
1451
|
+
appId?: string;
|
|
1452
|
+
/** @readonly */
|
|
1453
|
+
identityType?: WebhookIdentityType$1;
|
|
1454
|
+
}
|
|
1455
|
+
/** @oneof */
|
|
1456
|
+
interface IdentificationDataIdOneOf$1 {
|
|
1457
|
+
/** ID of a site visitor that has not logged in to the site. */
|
|
1458
|
+
anonymousVisitorId?: string;
|
|
1459
|
+
/** ID of a site visitor that has logged in to the site. */
|
|
1460
|
+
memberId?: string;
|
|
1461
|
+
/** ID of a Wix user (site owner, contributor, etc.). */
|
|
1462
|
+
wixUserId?: string;
|
|
1463
|
+
/** ID of an app. */
|
|
1464
|
+
appId?: string;
|
|
1465
|
+
}
|
|
1466
|
+
declare enum WebhookIdentityType$1 {
|
|
1467
|
+
UNKNOWN = "UNKNOWN",
|
|
1468
|
+
ANONYMOUS_VISITOR = "ANONYMOUS_VISITOR",
|
|
1469
|
+
MEMBER = "MEMBER",
|
|
1470
|
+
WIX_USER = "WIX_USER",
|
|
1471
|
+
APP = "APP"
|
|
1472
|
+
}
|
|
1473
|
+
interface FreeTrialInfoNonNullableFields {
|
|
1474
|
+
status: FreeTrialStatus;
|
|
1475
|
+
}
|
|
1476
|
+
interface BillingInfoNonNullableFields {
|
|
1477
|
+
packageName: string;
|
|
1478
|
+
billingCycle: PaymentCycle$1;
|
|
1479
|
+
timeStamp: string;
|
|
1480
|
+
freeTrialInfo?: FreeTrialInfoNonNullableFields;
|
|
1481
|
+
}
|
|
1482
|
+
interface AvailablePlanNonNullableFields {
|
|
1483
|
+
packageName: string;
|
|
1484
|
+
source: string;
|
|
1485
|
+
}
|
|
1486
|
+
interface AppInstanceNonNullableFields {
|
|
1487
|
+
instanceId: string;
|
|
1488
|
+
appName: string;
|
|
1489
|
+
isFree: boolean;
|
|
1490
|
+
billing?: BillingInfoNonNullableFields;
|
|
1491
|
+
permissions: string[];
|
|
1492
|
+
availablePlans: AvailablePlanNonNullableFields[];
|
|
1493
|
+
isOriginSiteTemplate: boolean;
|
|
1494
|
+
copiedFromTemplate: boolean;
|
|
1495
|
+
freeTrialAvailable: boolean;
|
|
1496
|
+
}
|
|
1497
|
+
interface LocaleNonNullableFields {
|
|
1498
|
+
languageCode: string;
|
|
1499
|
+
country: string;
|
|
1500
|
+
}
|
|
1501
|
+
interface SupportedLanguageNonNullableFields {
|
|
1502
|
+
languageCode: string;
|
|
1503
|
+
locale?: LocaleNonNullableFields;
|
|
1504
|
+
isPrimary: boolean;
|
|
1505
|
+
countryCode: string;
|
|
1506
|
+
resolutionMethod: ResolutionMethod;
|
|
1507
|
+
}
|
|
1508
|
+
interface MultilingualNonNullableFields {
|
|
1509
|
+
isMultiLingual: boolean;
|
|
1510
|
+
supportedLanguages: SupportedLanguageNonNullableFields[];
|
|
1511
|
+
}
|
|
1512
|
+
interface OwnerInfoNonNullableFields {
|
|
1513
|
+
email: string;
|
|
1514
|
+
emailStatus: string;
|
|
1515
|
+
}
|
|
1516
|
+
interface SiteInfoNonNullableFields {
|
|
1517
|
+
locale: string;
|
|
1518
|
+
paymentCurrency: string;
|
|
1519
|
+
multilingual?: MultilingualNonNullableFields;
|
|
1520
|
+
installedWixApps: string[];
|
|
1521
|
+
ownerInfo?: OwnerInfoNonNullableFields;
|
|
1522
|
+
siteId: string;
|
|
1523
|
+
}
|
|
1524
|
+
interface GetAppInstanceResponseNonNullableFields {
|
|
1525
|
+
instance?: AppInstanceNonNullableFields;
|
|
1526
|
+
site?: SiteInfoNonNullableFields;
|
|
1527
|
+
}
|
|
1528
|
+
interface BaseEventMetadata {
|
|
1529
|
+
/** App instance ID. */
|
|
1530
|
+
instanceId?: string | null;
|
|
1531
|
+
/** Event type. */
|
|
1532
|
+
eventType?: string;
|
|
1533
|
+
/** The identification type and identity data. */
|
|
1534
|
+
identity?: IdentificationData$1;
|
|
1535
|
+
}
|
|
1536
|
+
interface AppInstanceInstalledEnvelope {
|
|
1537
|
+
data: AppInstalled;
|
|
1538
|
+
metadata: BaseEventMetadata;
|
|
1539
|
+
}
|
|
1540
|
+
interface AppInstanceRemovedEnvelope {
|
|
1541
|
+
data: AppRemoved;
|
|
1542
|
+
metadata: BaseEventMetadata;
|
|
1543
|
+
}
|
|
1544
|
+
interface AppInstancePaidPlanPurchasedEnvelope {
|
|
1545
|
+
data: PaidPlanPurchased;
|
|
1546
|
+
metadata: BaseEventMetadata;
|
|
1547
|
+
}
|
|
1548
|
+
interface AppInstancePaidPlanChangedEnvelope {
|
|
1549
|
+
data: PaidPlanChanged;
|
|
1550
|
+
metadata: BaseEventMetadata;
|
|
1551
|
+
}
|
|
1552
|
+
interface AppInstancePaidPlanAutoRenewalCancelledEnvelope {
|
|
1553
|
+
data: PaidPlanAutoRenewalCancelled;
|
|
1554
|
+
metadata: BaseEventMetadata;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
declare function getAppInstance$1(httpClient: HttpClient$3): GetAppInstanceSignature;
|
|
1558
|
+
interface GetAppInstanceSignature {
|
|
1559
|
+
/**
|
|
1560
|
+
* Retrieves data about the instance of your app that's installed on a Wix site and data about the site itself.
|
|
1561
|
+
*
|
|
1562
|
+
* Call this function when you need information about a specific instance of your app and the site it’s installed on. For example, you may need to know whether the user has installed a free or paid version of your app, or to check what other Wix apps are installed on the site.
|
|
1563
|
+
*
|
|
1564
|
+
* You must authenticate as a [Wix App](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities#wix-apps). If you are calling this function from a [dashboard extension](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/dashboard-extensions/about-dashboard-extensions) in the [CLI](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/about-the-wix-cli-for-apps), Wix App authentication is passed automatically. Otherwise, you need to call the function with [elevated permissions](https://dev.wix.com/docs/sdk/articles/working-with-the-sdk/about-elevated-permissions).
|
|
1565
|
+
*
|
|
1566
|
+
* If you want `site.ownerInfo` to be included in the response, you must have the __Read Site Owner Email__ permission scope in addition to __WIX_DEVELOPERS.MANAGE_APP_INSTANCE__.
|
|
1567
|
+
*/
|
|
1568
|
+
(): Promise<GetAppInstanceResponse & GetAppInstanceResponseNonNullableFields>;
|
|
1569
|
+
}
|
|
1570
|
+
declare const onAppInstanceInstalled$1: EventDefinition$4<AppInstanceInstalledEnvelope, "AppInstalled">;
|
|
1571
|
+
declare const onAppInstanceRemoved$1: EventDefinition$4<AppInstanceRemovedEnvelope, "AppRemoved">;
|
|
1572
|
+
declare const onAppInstancePaidPlanPurchased$1: EventDefinition$4<AppInstancePaidPlanPurchasedEnvelope, "PaidPlanPurchased">;
|
|
1573
|
+
declare const onAppInstancePaidPlanChanged$1: EventDefinition$4<AppInstancePaidPlanChangedEnvelope, "PaidPlanChanged">;
|
|
1574
|
+
declare const onAppInstancePaidPlanAutoRenewalCancelled$1: EventDefinition$4<AppInstancePaidPlanAutoRenewalCancelledEnvelope, "PaidPlanAutoRenewalCancelled">;
|
|
1575
|
+
|
|
1576
|
+
type EventDefinition$3<Payload = unknown, Type extends string = string> = {
|
|
1577
|
+
__type: 'event-definition';
|
|
1578
|
+
type: Type;
|
|
1579
|
+
isDomainEvent?: boolean;
|
|
1580
|
+
transformations?: (envelope: unknown) => Payload;
|
|
1581
|
+
__payload: Payload;
|
|
1582
|
+
};
|
|
1583
|
+
declare function EventDefinition$3<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$3<Payload, Type>;
|
|
1584
|
+
type EventHandler$3<T extends EventDefinition$3> = (payload: T['__payload']) => void | Promise<void>;
|
|
1585
|
+
type BuildEventDefinition$3<T extends EventDefinition$3<any, string>> = (handler: EventHandler$3<T>) => void;
|
|
1586
|
+
|
|
1587
|
+
declare global {
|
|
1588
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
1589
|
+
interface SymbolConstructor {
|
|
1590
|
+
readonly observable: symbol;
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
declare function createEventModule<T extends EventDefinition$3<any, string>>(eventDefinition: T): BuildEventDefinition$3<T> & T;
|
|
1595
|
+
|
|
1596
|
+
declare const getAppInstance: MaybeContext$3<BuildRESTFunction$3<typeof getAppInstance$1> & typeof getAppInstance$1>;
|
|
1597
|
+
|
|
1598
|
+
type _publicOnAppInstanceInstalledType = typeof onAppInstanceInstalled$1;
|
|
1599
|
+
/**
|
|
1600
|
+
* Triggered when an instance of your app is installed on a Wix site.
|
|
1601
|
+
*/
|
|
1602
|
+
declare const onAppInstanceInstalled: ReturnType<typeof createEventModule<_publicOnAppInstanceInstalledType>>;
|
|
1603
|
+
|
|
1604
|
+
type _publicOnAppInstanceRemovedType = typeof onAppInstanceRemoved$1;
|
|
1605
|
+
/**
|
|
1606
|
+
* Triggered when an instance of your app is uninstalled from a Wix site.
|
|
1607
|
+
*/
|
|
1608
|
+
declare const onAppInstanceRemoved: ReturnType<typeof createEventModule<_publicOnAppInstanceRemovedType>>;
|
|
1609
|
+
|
|
1610
|
+
type _publicOnAppInstancePaidPlanPurchasedType = typeof onAppInstancePaidPlanPurchased$1;
|
|
1611
|
+
/**
|
|
1612
|
+
* Triggered when a site owner purchases a paid plan for your app.
|
|
1613
|
+
*/
|
|
1614
|
+
declare const onAppInstancePaidPlanPurchased: ReturnType<typeof createEventModule<_publicOnAppInstancePaidPlanPurchasedType>>;
|
|
1615
|
+
|
|
1616
|
+
type _publicOnAppInstancePaidPlanChangedType = typeof onAppInstancePaidPlanChanged$1;
|
|
1617
|
+
/**
|
|
1618
|
+
* Triggered when a site owner upgrades or downgrades their plan for your app.
|
|
1619
|
+
*/
|
|
1620
|
+
declare const onAppInstancePaidPlanChanged: ReturnType<typeof createEventModule<_publicOnAppInstancePaidPlanChangedType>>;
|
|
1621
|
+
|
|
1622
|
+
type _publicOnAppInstancePaidPlanAutoRenewalCancelledType = typeof onAppInstancePaidPlanAutoRenewalCancelled$1;
|
|
1623
|
+
/**
|
|
1624
|
+
* Triggered when a site owner cancels a paid plan for your app. The
|
|
1625
|
+
* site owner can continue to use your app until the end of the current billing
|
|
1626
|
+
* cycle.
|
|
1627
|
+
*/
|
|
1628
|
+
declare const onAppInstancePaidPlanAutoRenewalCancelled: ReturnType<typeof createEventModule<_publicOnAppInstancePaidPlanAutoRenewalCancelledType>>;
|
|
1629
|
+
|
|
1630
|
+
type index_d$3_AppInstalled = AppInstalled;
|
|
1631
|
+
type index_d$3_AppInstance = AppInstance;
|
|
1632
|
+
type index_d$3_AppInstanceInstalledEnvelope = AppInstanceInstalledEnvelope;
|
|
1633
|
+
type index_d$3_AppInstancePaidPlanAutoRenewalCancelledEnvelope = AppInstancePaidPlanAutoRenewalCancelledEnvelope;
|
|
1634
|
+
type index_d$3_AppInstancePaidPlanChangedEnvelope = AppInstancePaidPlanChangedEnvelope;
|
|
1635
|
+
type index_d$3_AppInstancePaidPlanPurchasedEnvelope = AppInstancePaidPlanPurchasedEnvelope;
|
|
1636
|
+
type index_d$3_AppInstanceRemovedEnvelope = AppInstanceRemovedEnvelope;
|
|
1637
|
+
type index_d$3_AppRemoved = AppRemoved;
|
|
1638
|
+
type index_d$3_AvailablePlan = AvailablePlan;
|
|
1639
|
+
type index_d$3_BaseEventMetadata = BaseEventMetadata;
|
|
1640
|
+
type index_d$3_BillingInfo = BillingInfo;
|
|
1641
|
+
type index_d$3_FreeTrialInfo = FreeTrialInfo;
|
|
1642
|
+
type index_d$3_FreeTrialStatus = FreeTrialStatus;
|
|
1643
|
+
declare const index_d$3_FreeTrialStatus: typeof FreeTrialStatus;
|
|
1644
|
+
type index_d$3_GetAppInstanceByInstanceIdRequest = GetAppInstanceByInstanceIdRequest;
|
|
1645
|
+
type index_d$3_GetAppInstanceRequest = GetAppInstanceRequest;
|
|
1646
|
+
type index_d$3_GetAppInstanceResponse = GetAppInstanceResponse;
|
|
1647
|
+
type index_d$3_GetAppInstanceResponseNonNullableFields = GetAppInstanceResponseNonNullableFields;
|
|
1648
|
+
type index_d$3_Locale = Locale;
|
|
1649
|
+
type index_d$3_Multilingual = Multilingual;
|
|
1650
|
+
type index_d$3_OwnerInfo = OwnerInfo;
|
|
1651
|
+
type index_d$3_PaidPlanAutoRenewalCancelled = PaidPlanAutoRenewalCancelled;
|
|
1652
|
+
type index_d$3_PaidPlanChanged = PaidPlanChanged;
|
|
1653
|
+
type index_d$3_PaidPlanPurchased = PaidPlanPurchased;
|
|
1654
|
+
type index_d$3_ResolutionMethod = ResolutionMethod;
|
|
1655
|
+
declare const index_d$3_ResolutionMethod: typeof ResolutionMethod;
|
|
1656
|
+
type index_d$3_SiteInfo = SiteInfo;
|
|
1657
|
+
type index_d$3_SupportedLanguage = SupportedLanguage;
|
|
1658
|
+
type index_d$3__publicOnAppInstanceInstalledType = _publicOnAppInstanceInstalledType;
|
|
1659
|
+
type index_d$3__publicOnAppInstancePaidPlanAutoRenewalCancelledType = _publicOnAppInstancePaidPlanAutoRenewalCancelledType;
|
|
1660
|
+
type index_d$3__publicOnAppInstancePaidPlanChangedType = _publicOnAppInstancePaidPlanChangedType;
|
|
1661
|
+
type index_d$3__publicOnAppInstancePaidPlanPurchasedType = _publicOnAppInstancePaidPlanPurchasedType;
|
|
1662
|
+
type index_d$3__publicOnAppInstanceRemovedType = _publicOnAppInstanceRemovedType;
|
|
1663
|
+
declare const index_d$3_getAppInstance: typeof getAppInstance;
|
|
1664
|
+
declare const index_d$3_onAppInstanceInstalled: typeof onAppInstanceInstalled;
|
|
1665
|
+
declare const index_d$3_onAppInstancePaidPlanAutoRenewalCancelled: typeof onAppInstancePaidPlanAutoRenewalCancelled;
|
|
1666
|
+
declare const index_d$3_onAppInstancePaidPlanChanged: typeof onAppInstancePaidPlanChanged;
|
|
1667
|
+
declare const index_d$3_onAppInstancePaidPlanPurchased: typeof onAppInstancePaidPlanPurchased;
|
|
1668
|
+
declare const index_d$3_onAppInstanceRemoved: typeof onAppInstanceRemoved;
|
|
1669
|
+
declare namespace index_d$3 {
|
|
1670
|
+
export { type index_d$3_AppInstalled as AppInstalled, type index_d$3_AppInstance as AppInstance, type index_d$3_AppInstanceInstalledEnvelope as AppInstanceInstalledEnvelope, type index_d$3_AppInstancePaidPlanAutoRenewalCancelledEnvelope as AppInstancePaidPlanAutoRenewalCancelledEnvelope, type index_d$3_AppInstancePaidPlanChangedEnvelope as AppInstancePaidPlanChangedEnvelope, type index_d$3_AppInstancePaidPlanPurchasedEnvelope as AppInstancePaidPlanPurchasedEnvelope, type index_d$3_AppInstanceRemovedEnvelope as AppInstanceRemovedEnvelope, type index_d$3_AppRemoved as AppRemoved, type index_d$3_AvailablePlan as AvailablePlan, type index_d$3_BaseEventMetadata as BaseEventMetadata, type index_d$3_BillingInfo as BillingInfo, type index_d$3_FreeTrialInfo as FreeTrialInfo, index_d$3_FreeTrialStatus as FreeTrialStatus, type index_d$3_GetAppInstanceByInstanceIdRequest as GetAppInstanceByInstanceIdRequest, type index_d$3_GetAppInstanceRequest as GetAppInstanceRequest, type index_d$3_GetAppInstanceResponse as GetAppInstanceResponse, type index_d$3_GetAppInstanceResponseNonNullableFields as GetAppInstanceResponseNonNullableFields, type IdentificationData$1 as IdentificationData, type IdentificationDataIdOneOf$1 as IdentificationDataIdOneOf, type index_d$3_Locale as Locale, type MessageEnvelope$1 as MessageEnvelope, type index_d$3_Multilingual as Multilingual, type index_d$3_OwnerInfo as OwnerInfo, type index_d$3_PaidPlanAutoRenewalCancelled as PaidPlanAutoRenewalCancelled, type index_d$3_PaidPlanChanged as PaidPlanChanged, type index_d$3_PaidPlanPurchased as PaidPlanPurchased, PaymentCycle$1 as PaymentCycle, index_d$3_ResolutionMethod as ResolutionMethod, type index_d$3_SiteInfo as SiteInfo, type index_d$3_SupportedLanguage as SupportedLanguage, WebhookIdentityType$1 as WebhookIdentityType, type index_d$3__publicOnAppInstanceInstalledType as _publicOnAppInstanceInstalledType, type index_d$3__publicOnAppInstancePaidPlanAutoRenewalCancelledType as _publicOnAppInstancePaidPlanAutoRenewalCancelledType, type index_d$3__publicOnAppInstancePaidPlanChangedType as _publicOnAppInstancePaidPlanChangedType, type index_d$3__publicOnAppInstancePaidPlanPurchasedType as _publicOnAppInstancePaidPlanPurchasedType, type index_d$3__publicOnAppInstanceRemovedType as _publicOnAppInstanceRemovedType, index_d$3_getAppInstance as getAppInstance, index_d$3_onAppInstanceInstalled as onAppInstanceInstalled, index_d$3_onAppInstancePaidPlanAutoRenewalCancelled as onAppInstancePaidPlanAutoRenewalCancelled, index_d$3_onAppInstancePaidPlanChanged as onAppInstancePaidPlanChanged, index_d$3_onAppInstancePaidPlanPurchased as onAppInstancePaidPlanPurchased, index_d$3_onAppInstanceRemoved as onAppInstanceRemoved, onAppInstanceInstalled$1 as publicOnAppInstanceInstalled, onAppInstancePaidPlanAutoRenewalCancelled$1 as publicOnAppInstancePaidPlanAutoRenewalCancelled, onAppInstancePaidPlanChanged$1 as publicOnAppInstancePaidPlanChanged, onAppInstancePaidPlanPurchased$1 as publicOnAppInstancePaidPlanPurchased, onAppInstanceRemoved$1 as publicOnAppInstanceRemoved };
|
|
869
1671
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
1672
|
+
|
|
1673
|
+
type HostModule$2<T, H extends Host$2> = {
|
|
1674
|
+
__type: 'host';
|
|
1675
|
+
create(host: H): T;
|
|
1676
|
+
};
|
|
1677
|
+
type HostModuleAPI$2<T extends HostModule$2<any, any>> = T extends HostModule$2<infer U, any> ? U : never;
|
|
1678
|
+
type Host$2<Environment = unknown> = {
|
|
1679
|
+
channel: {
|
|
1680
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
1681
|
+
disconnect: () => void;
|
|
1682
|
+
} | Promise<{
|
|
1683
|
+
disconnect: () => void;
|
|
1684
|
+
}>;
|
|
1685
|
+
};
|
|
1686
|
+
environment?: Environment;
|
|
1687
|
+
/**
|
|
1688
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
1689
|
+
*/
|
|
1690
|
+
apiBaseUrl?: string;
|
|
1691
|
+
/**
|
|
1692
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
1693
|
+
* like internationalization, billing, etc.
|
|
1694
|
+
*/
|
|
1695
|
+
essentials?: {
|
|
1696
|
+
/**
|
|
1697
|
+
* The language of the currently viewed session
|
|
1698
|
+
*/
|
|
1699
|
+
language?: string;
|
|
1700
|
+
/**
|
|
1701
|
+
* The locale of the currently viewed session
|
|
1702
|
+
*/
|
|
1703
|
+
locale?: string;
|
|
1704
|
+
/**
|
|
1705
|
+
* Any headers that should be passed through to the API requests
|
|
1706
|
+
*/
|
|
1707
|
+
passThroughHeaders?: Record<string, string>;
|
|
1708
|
+
};
|
|
1709
|
+
};
|
|
1710
|
+
|
|
1711
|
+
type RESTFunctionDescriptor$2<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$2) => T;
|
|
1712
|
+
interface HttpClient$2 {
|
|
1713
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$2<TResponse, TData>): Promise<HttpResponse$2<TResponse>>;
|
|
1714
|
+
fetchWithAuth: typeof fetch;
|
|
1715
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
1716
|
+
getActiveToken?: () => string | undefined;
|
|
875
1717
|
}
|
|
876
|
-
|
|
877
|
-
|
|
1718
|
+
type RequestOptionsFactory$2<TResponse = any, TData = any> = (context: any) => RequestOptions$2<TResponse, TData>;
|
|
1719
|
+
type HttpResponse$2<T = any> = {
|
|
1720
|
+
data: T;
|
|
1721
|
+
status: number;
|
|
1722
|
+
statusText: string;
|
|
1723
|
+
headers: any;
|
|
1724
|
+
request?: any;
|
|
1725
|
+
};
|
|
1726
|
+
type RequestOptions$2<_TResponse = any, Data = any> = {
|
|
1727
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
1728
|
+
url: string;
|
|
1729
|
+
data?: Data;
|
|
1730
|
+
params?: URLSearchParams;
|
|
1731
|
+
} & APIMetadata$2;
|
|
1732
|
+
type APIMetadata$2 = {
|
|
1733
|
+
methodFqn?: string;
|
|
1734
|
+
entityFqdn?: string;
|
|
878
1735
|
packageName?: string;
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1736
|
+
};
|
|
1737
|
+
type BuildRESTFunction$2<T extends RESTFunctionDescriptor$2> = T extends RESTFunctionDescriptor$2<infer U> ? U : never;
|
|
1738
|
+
type EventDefinition$2<Payload = unknown, Type extends string = string> = {
|
|
1739
|
+
__type: 'event-definition';
|
|
1740
|
+
type: Type;
|
|
1741
|
+
isDomainEvent?: boolean;
|
|
1742
|
+
transformations?: (envelope: unknown) => Payload;
|
|
1743
|
+
__payload: Payload;
|
|
1744
|
+
};
|
|
1745
|
+
declare function EventDefinition$2<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$2<Payload, Type>;
|
|
1746
|
+
type EventHandler$2<T extends EventDefinition$2> = (payload: T['__payload']) => void | Promise<void>;
|
|
1747
|
+
type BuildEventDefinition$2<T extends EventDefinition$2<any, string>> = (handler: EventHandler$2<T>) => void;
|
|
1748
|
+
|
|
1749
|
+
type ServicePluginMethodInput$2 = {
|
|
1750
|
+
request: any;
|
|
1751
|
+
metadata: any;
|
|
1752
|
+
};
|
|
1753
|
+
type ServicePluginContract$2 = Record<string, (payload: ServicePluginMethodInput$2) => unknown | Promise<unknown>>;
|
|
1754
|
+
type ServicePluginMethodMetadata$2 = {
|
|
1755
|
+
name: string;
|
|
1756
|
+
primaryHttpMappingPath: string;
|
|
1757
|
+
transformations: {
|
|
1758
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$2;
|
|
1759
|
+
toREST: (...args: unknown[]) => unknown;
|
|
1760
|
+
};
|
|
1761
|
+
};
|
|
1762
|
+
type ServicePluginDefinition$2<Contract extends ServicePluginContract$2> = {
|
|
1763
|
+
__type: 'service-plugin-definition';
|
|
1764
|
+
componentType: string;
|
|
1765
|
+
methods: ServicePluginMethodMetadata$2[];
|
|
1766
|
+
__contract: Contract;
|
|
1767
|
+
};
|
|
1768
|
+
declare function ServicePluginDefinition$2<Contract extends ServicePluginContract$2>(componentType: string, methods: ServicePluginMethodMetadata$2[]): ServicePluginDefinition$2<Contract>;
|
|
1769
|
+
type BuildServicePluginDefinition$2<T extends ServicePluginDefinition$2<any>> = (implementation: T['__contract']) => void;
|
|
1770
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$2 = "wix_spi_error";
|
|
1771
|
+
|
|
1772
|
+
type RequestContext$2 = {
|
|
1773
|
+
isSSR: boolean;
|
|
1774
|
+
host: string;
|
|
1775
|
+
protocol?: string;
|
|
1776
|
+
};
|
|
1777
|
+
type ResponseTransformer$2 = (data: any, headers?: any) => any;
|
|
1778
|
+
/**
|
|
1779
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
1780
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
1781
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
1782
|
+
*/
|
|
1783
|
+
type Method$2 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
1784
|
+
type AmbassadorRequestOptions$2<T = any> = {
|
|
1785
|
+
_?: T;
|
|
1786
|
+
url?: string;
|
|
1787
|
+
method?: Method$2;
|
|
1788
|
+
params?: any;
|
|
1789
|
+
data?: any;
|
|
1790
|
+
transformResponse?: ResponseTransformer$2 | ResponseTransformer$2[];
|
|
1791
|
+
};
|
|
1792
|
+
type AmbassadorFactory$2<Request, Response> = (payload: Request) => ((context: RequestContext$2) => AmbassadorRequestOptions$2<Response>) & {
|
|
1793
|
+
__isAmbassador: boolean;
|
|
1794
|
+
};
|
|
1795
|
+
type AmbassadorFunctionDescriptor$2<Request = any, Response = any> = AmbassadorFactory$2<Request, Response>;
|
|
1796
|
+
type BuildAmbassadorFunction$2<T extends AmbassadorFunctionDescriptor$2> = T extends AmbassadorFunctionDescriptor$2<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
1797
|
+
|
|
1798
|
+
declare global {
|
|
1799
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
1800
|
+
interface SymbolConstructor {
|
|
1801
|
+
readonly observable: symbol;
|
|
1802
|
+
}
|
|
891
1803
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
1804
|
+
|
|
1805
|
+
declare const emptyObjectSymbol$2: unique symbol;
|
|
1806
|
+
|
|
1807
|
+
/**
|
|
1808
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
1809
|
+
|
|
1810
|
+
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)).
|
|
1811
|
+
|
|
1812
|
+
@example
|
|
1813
|
+
```
|
|
1814
|
+
import type {EmptyObject} from 'type-fest';
|
|
1815
|
+
|
|
1816
|
+
// The following illustrates the problem with `{}`.
|
|
1817
|
+
const foo1: {} = {}; // Pass
|
|
1818
|
+
const foo2: {} = []; // Pass
|
|
1819
|
+
const foo3: {} = 42; // Pass
|
|
1820
|
+
const foo4: {} = {a: 1}; // Pass
|
|
1821
|
+
|
|
1822
|
+
// With `EmptyObject` only the first case is valid.
|
|
1823
|
+
const bar1: EmptyObject = {}; // Pass
|
|
1824
|
+
const bar2: EmptyObject = 42; // Fail
|
|
1825
|
+
const bar3: EmptyObject = []; // Fail
|
|
1826
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
1827
|
+
```
|
|
1828
|
+
|
|
1829
|
+
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}.
|
|
1830
|
+
|
|
1831
|
+
@category Object
|
|
1832
|
+
*/
|
|
1833
|
+
type EmptyObject$2 = {[emptyObjectSymbol$2]?: never};
|
|
1834
|
+
|
|
1835
|
+
/**
|
|
1836
|
+
Returns a boolean for whether the two given types are equal.
|
|
1837
|
+
|
|
1838
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
1839
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
1840
|
+
|
|
1841
|
+
Use-cases:
|
|
1842
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
1843
|
+
|
|
1844
|
+
@example
|
|
1845
|
+
```
|
|
1846
|
+
import type {IsEqual} from 'type-fest';
|
|
1847
|
+
|
|
1848
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
1849
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
1850
|
+
type Includes<Value extends readonly any[], Item> =
|
|
1851
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
1852
|
+
? IsEqual<Value[0], Item> extends true
|
|
1853
|
+
? true
|
|
1854
|
+
: Includes<rest, Item>
|
|
1855
|
+
: false;
|
|
1856
|
+
```
|
|
1857
|
+
|
|
1858
|
+
@category Type Guard
|
|
1859
|
+
@category Utilities
|
|
1860
|
+
*/
|
|
1861
|
+
type IsEqual$2<A, B> =
|
|
1862
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
1863
|
+
(<G>() => G extends B ? 1 : 2)
|
|
1864
|
+
? true
|
|
1865
|
+
: false;
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
Filter out keys from an object.
|
|
1869
|
+
|
|
1870
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
1871
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
1872
|
+
Returns `Key` otherwise.
|
|
1873
|
+
|
|
1874
|
+
@example
|
|
1875
|
+
```
|
|
1876
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
1877
|
+
//=> never
|
|
1878
|
+
```
|
|
1879
|
+
|
|
1880
|
+
@example
|
|
1881
|
+
```
|
|
1882
|
+
type Filtered = Filter<'bar', string>;
|
|
1883
|
+
//=> never
|
|
1884
|
+
```
|
|
1885
|
+
|
|
1886
|
+
@example
|
|
1887
|
+
```
|
|
1888
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
1889
|
+
//=> 'bar'
|
|
1890
|
+
```
|
|
1891
|
+
|
|
1892
|
+
@see {Except}
|
|
1893
|
+
*/
|
|
1894
|
+
type Filter$2<KeyType, ExcludeType> = IsEqual$2<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
1895
|
+
|
|
1896
|
+
type ExceptOptions$2 = {
|
|
1897
|
+
/**
|
|
1898
|
+
Disallow assigning non-specified properties.
|
|
1899
|
+
|
|
1900
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
1901
|
+
|
|
1902
|
+
@default false
|
|
1903
|
+
*/
|
|
1904
|
+
requireExactProps?: boolean;
|
|
1905
|
+
};
|
|
1906
|
+
|
|
1907
|
+
/**
|
|
1908
|
+
Create a type from an object type without certain keys.
|
|
1909
|
+
|
|
1910
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
1911
|
+
|
|
1912
|
+
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.
|
|
1913
|
+
|
|
1914
|
+
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)).
|
|
1915
|
+
|
|
1916
|
+
@example
|
|
1917
|
+
```
|
|
1918
|
+
import type {Except} from 'type-fest';
|
|
1919
|
+
|
|
1920
|
+
type Foo = {
|
|
1921
|
+
a: number;
|
|
1922
|
+
b: string;
|
|
1923
|
+
};
|
|
1924
|
+
|
|
1925
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
1926
|
+
//=> {b: string}
|
|
1927
|
+
|
|
1928
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
1929
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
1930
|
+
|
|
1931
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
1932
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
1933
|
+
|
|
1934
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
1935
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
1936
|
+
```
|
|
1937
|
+
|
|
1938
|
+
@category Object
|
|
1939
|
+
*/
|
|
1940
|
+
type Except$2<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$2 = {requireExactProps: false}> = {
|
|
1941
|
+
[KeyType in keyof ObjectType as Filter$2<KeyType, KeysType>]: ObjectType[KeyType];
|
|
1942
|
+
} & (Options['requireExactProps'] extends true
|
|
1943
|
+
? Partial<Record<KeysType, never>>
|
|
1944
|
+
: {});
|
|
1945
|
+
|
|
1946
|
+
/**
|
|
1947
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
1948
|
+
|
|
1949
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
1950
|
+
|
|
1951
|
+
@example
|
|
1952
|
+
```
|
|
1953
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1954
|
+
|
|
1955
|
+
interface Example {
|
|
1956
|
+
a: string;
|
|
1957
|
+
b: string | number;
|
|
1958
|
+
c?: string;
|
|
1959
|
+
d: {};
|
|
905
1960
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1961
|
+
|
|
1962
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
1963
|
+
//=> 'a'
|
|
1964
|
+
```
|
|
1965
|
+
|
|
1966
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
1967
|
+
|
|
1968
|
+
@example
|
|
1969
|
+
```
|
|
1970
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1971
|
+
|
|
1972
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
1973
|
+
//=> 'a' | 'c'
|
|
1974
|
+
```
|
|
1975
|
+
|
|
1976
|
+
@category Object
|
|
1977
|
+
*/
|
|
1978
|
+
type ConditionalKeys$2<Base, Condition> = NonNullable<
|
|
1979
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
1980
|
+
{
|
|
1981
|
+
// Map through all the keys of the given base type.
|
|
1982
|
+
[Key in keyof Base]:
|
|
1983
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
1984
|
+
Base[Key] extends Condition
|
|
1985
|
+
// Retain this key since the condition passes.
|
|
1986
|
+
? Key
|
|
1987
|
+
// Discard this key since the condition fails.
|
|
1988
|
+
: never;
|
|
1989
|
+
|
|
1990
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
1991
|
+
}[keyof Base]
|
|
1992
|
+
>;
|
|
1993
|
+
|
|
1994
|
+
/**
|
|
1995
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
1996
|
+
|
|
1997
|
+
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.
|
|
1998
|
+
|
|
1999
|
+
@example
|
|
2000
|
+
```
|
|
2001
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
2002
|
+
|
|
2003
|
+
class Awesome {
|
|
2004
|
+
name: string;
|
|
2005
|
+
successes: number;
|
|
2006
|
+
failures: bigint;
|
|
2007
|
+
|
|
2008
|
+
run() {}
|
|
921
2009
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
2010
|
+
|
|
2011
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
2012
|
+
//=> {run: () => void}
|
|
2013
|
+
```
|
|
2014
|
+
|
|
2015
|
+
@example
|
|
2016
|
+
```
|
|
2017
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
2018
|
+
|
|
2019
|
+
interface Example {
|
|
2020
|
+
a: string;
|
|
2021
|
+
b: string | number;
|
|
2022
|
+
c: () => void;
|
|
2023
|
+
d: {};
|
|
935
2024
|
}
|
|
936
|
-
|
|
2025
|
+
|
|
2026
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
2027
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
2028
|
+
```
|
|
2029
|
+
|
|
2030
|
+
@category Object
|
|
2031
|
+
*/
|
|
2032
|
+
type ConditionalExcept$2<Base, Condition> = Except$2<
|
|
2033
|
+
Base,
|
|
2034
|
+
ConditionalKeys$2<Base, Condition>
|
|
2035
|
+
>;
|
|
2036
|
+
|
|
2037
|
+
/**
|
|
2038
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
2039
|
+
* can either be a REST module or a host module.
|
|
2040
|
+
* This type is recursive, so it can describe nested modules.
|
|
2041
|
+
*/
|
|
2042
|
+
type Descriptors$2 = RESTFunctionDescriptor$2 | AmbassadorFunctionDescriptor$2 | HostModule$2<any, any> | EventDefinition$2<any> | ServicePluginDefinition$2<any> | {
|
|
2043
|
+
[key: string]: Descriptors$2 | PublicMetadata$2 | any;
|
|
2044
|
+
};
|
|
2045
|
+
/**
|
|
2046
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
2047
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
2048
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
2049
|
+
* do not match the given host (as they will not work with the given host).
|
|
2050
|
+
*/
|
|
2051
|
+
type BuildDescriptors$2<T extends Descriptors$2, H extends Host$2<any> | undefined, Depth extends number = 5> = {
|
|
2052
|
+
done: T;
|
|
2053
|
+
recurse: T extends {
|
|
2054
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$2;
|
|
2055
|
+
} ? never : T extends AmbassadorFunctionDescriptor$2 ? BuildAmbassadorFunction$2<T> : T extends RESTFunctionDescriptor$2 ? BuildRESTFunction$2<T> : T extends EventDefinition$2<any> ? BuildEventDefinition$2<T> : T extends ServicePluginDefinition$2<any> ? BuildServicePluginDefinition$2<T> : T extends HostModule$2<any, any> ? HostModuleAPI$2<T> : ConditionalExcept$2<{
|
|
2056
|
+
[Key in keyof T]: T[Key] extends Descriptors$2 ? BuildDescriptors$2<T[Key], H, [
|
|
2057
|
+
-1,
|
|
2058
|
+
0,
|
|
2059
|
+
1,
|
|
2060
|
+
2,
|
|
2061
|
+
3,
|
|
2062
|
+
4,
|
|
2063
|
+
5
|
|
2064
|
+
][Depth]> : never;
|
|
2065
|
+
}, EmptyObject$2>;
|
|
2066
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
2067
|
+
type PublicMetadata$2 = {
|
|
2068
|
+
PACKAGE_NAME?: string;
|
|
2069
|
+
};
|
|
2070
|
+
|
|
2071
|
+
declare global {
|
|
2072
|
+
interface ContextualClient {
|
|
2073
|
+
}
|
|
937
2074
|
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
2075
|
+
/**
|
|
2076
|
+
* A type used to create concerete types from SDK descriptors in
|
|
2077
|
+
* case a contextual client is available.
|
|
2078
|
+
*/
|
|
2079
|
+
type MaybeContext$2<T extends Descriptors$2> = globalThis.ContextualClient extends {
|
|
2080
|
+
host: Host$2;
|
|
2081
|
+
} ? BuildDescriptors$2<T, globalThis.ContextualClient['host']> : T;
|
|
2082
|
+
|
|
2083
|
+
interface SendBIEventResponse {
|
|
943
2084
|
}
|
|
944
|
-
interface
|
|
945
|
-
/** Display name of the site. */
|
|
946
|
-
siteDisplayName?: string | null;
|
|
2085
|
+
interface SendBIEventRequest {
|
|
947
2086
|
/**
|
|
948
|
-
*
|
|
949
|
-
*
|
|
2087
|
+
* Name of the event that's triggered in your app.
|
|
2088
|
+
*
|
|
2089
|
+
* + `"APP_DASHBOARD_LOADED"`: A site onwer or contributor loads your app's dashboard.
|
|
2090
|
+
* + `"APP_FINISHED_CONFIGURATION"`: The site owner completes all required configurations for your app in your app's dashboard.
|
|
2091
|
+
* + `"APP_UPGRADED"`: The site owner upgrades your app's paid plan. An upgrade means that they have finished the checkout flow on the app's side but not necessarily on Wix's side.
|
|
2092
|
+
* + `"PRIMARY_ACTION_PERFORMED"`: A site owner, contributor, or visitor triggers your app's primary action. For example, a site visitor writes a product review using your product review app.
|
|
2093
|
+
* + `"CHARGE"`: You charge money from the site owner. For example, when the site owner purchases or renews a subscription for your app. Make sure to also send `eventData` and a key of `sum`.
|
|
2094
|
+
* + `"FUNDS_RETURNED"`: Trigger this event when you send money back to a site owner (for example, refunds or chargebacks). Make sure to also send the charge amount inside `eventData`. For example, `{"eventData": {"sum": "5.99"}}`.
|
|
2095
|
+
* + `"CUSTOM"`: Any event that's not listed here. Make sure to also send `customEventName`.
|
|
2096
|
+
* + `"APP_DEPLOYED"`: Your app’s internal code implementation is changed and might affect user flows or cause a regression.
|
|
2097
|
+
* + `"APP_FINISH_BUSINESS_SETUP"`: __Deprecation Notice:__ This enum value will be removed on March 30, 2023. Use `"APP_SETUP_FINISHED"` instead.
|
|
2098
|
+
* + `"APP_SETUP_FINISHED"`: The site owner completes your app's required business setup.
|
|
950
2099
|
*/
|
|
951
|
-
|
|
2100
|
+
eventName?: EventName;
|
|
952
2101
|
/**
|
|
953
|
-
*
|
|
954
|
-
*
|
|
2102
|
+
* Name of your app's custom event that was triggered. Required when `{"eventName": "CUSTOM"}`.
|
|
2103
|
+
*
|
|
2104
|
+
* Min: 2 characters
|
|
955
2105
|
*/
|
|
956
|
-
|
|
957
|
-
/**
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
2106
|
+
customEventName?: string | null;
|
|
2107
|
+
/**
|
|
2108
|
+
* Supported values include: `"cycle_name"`, `"currency"`, `"sum"`, `"reason"`, `"app_plan_id"`.
|
|
2109
|
+
* You may also submit data with keys that aren't listed here.
|
|
2110
|
+
*
|
|
2111
|
+
* Additional data about your app's event.
|
|
2112
|
+
*
|
|
2113
|
+
* + `"cycle_name"`: Supported values: `"monthly"`, `"yearly"`, `"2 years"`, `"one time"`.
|
|
2114
|
+
* + `"currency"`: 3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format.
|
|
2115
|
+
* + `"sum"`: Amount of money. Required for `{"eventName": "CHARGE"}` and `{"eventName": "FUNDS_RETURNED"}`.
|
|
2116
|
+
* + `"reason"`: Information about why the event was triggered in your app.
|
|
2117
|
+
* + `"app_plan_id"`: ID of the your app's plan as displayed in your app's dashboard. Note that it's the same value as `vendorProductId` in the [Paid Plan Purchased webhook](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/paid-plan-purchased).
|
|
2118
|
+
*/
|
|
2119
|
+
eventData?: Record<string, string>;
|
|
2120
|
+
}
|
|
2121
|
+
declare enum EventName {
|
|
2122
|
+
UNKNOWN = "UNKNOWN",
|
|
2123
|
+
APP_DASHBOARD_LOADED = "APP_DASHBOARD_LOADED",
|
|
2124
|
+
APP_FINISHED_CONFIGURATION = "APP_FINISHED_CONFIGURATION",
|
|
2125
|
+
APP_UPGRADED = "APP_UPGRADED",
|
|
2126
|
+
PRIMARY_ACTION_PERFORMED = "PRIMARY_ACTION_PERFORMED",
|
|
2127
|
+
CUSTOM = "CUSTOM",
|
|
2128
|
+
CHARGE = "CHARGE",
|
|
2129
|
+
FUNDS_RETURNED = "FUNDS_RETURNED",
|
|
2130
|
+
APP_FINISH_BUSINESS_SETUP = "APP_FINISH_BUSINESS_SETUP",
|
|
2131
|
+
APP_DEPLOYED = "APP_DEPLOYED",
|
|
2132
|
+
APP_SETUP_FINISHED = "APP_SETUP_FINISHED"
|
|
2133
|
+
}
|
|
2134
|
+
interface SendBiEventOptions {
|
|
965
2135
|
/**
|
|
966
|
-
*
|
|
967
|
-
*
|
|
2136
|
+
* Name of the event that's triggered in your app.
|
|
2137
|
+
*
|
|
2138
|
+
* + `"APP_DASHBOARD_LOADED"`: A site onwer or contributor loads your app's dashboard.
|
|
2139
|
+
* + `"APP_FINISHED_CONFIGURATION"`: The site owner completes all required configurations for your app in your app's dashboard.
|
|
2140
|
+
* + `"APP_UPGRADED"`: The site owner upgrades your app's paid plan. An upgrade means that they have finished the checkout flow on the app's side but not necessarily on Wix's side.
|
|
2141
|
+
* + `"PRIMARY_ACTION_PERFORMED"`: A site owner, contributor, or visitor triggers your app's primary action. For example, a site visitor writes a product review using your product review app.
|
|
2142
|
+
* + `"CHARGE"`: You charge money from the site owner. For example, when the site owner purchases or renews a subscription for your app. Make sure to also send `eventData` and a key of `sum`.
|
|
2143
|
+
* + `"FUNDS_RETURNED"`: Trigger this event when you send money back to a site owner (for example, refunds or chargebacks). Make sure to also send the charge amount inside `eventData`. For example, `{"eventData": {"sum": "5.99"}}`.
|
|
2144
|
+
* + `"CUSTOM"`: Any event that's not listed here. Make sure to also send `customEventName`.
|
|
2145
|
+
* + `"APP_DEPLOYED"`: Your app’s internal code implementation is changed and might affect user flows or cause a regression.
|
|
2146
|
+
* + `"APP_FINISH_BUSINESS_SETUP"`: __Deprecation Notice:__ This enum value will be removed on March 30, 2023. Use `"APP_SETUP_FINISHED"` instead.
|
|
2147
|
+
* + `"APP_SETUP_FINISHED"`: The site owner completes your app's required business setup.
|
|
968
2148
|
*/
|
|
969
|
-
|
|
2149
|
+
eventName?: EventName;
|
|
970
2150
|
/**
|
|
971
|
-
*
|
|
972
|
-
*
|
|
2151
|
+
* Name of your app's custom event that was triggered. Required when `{"eventName": "CUSTOM"}`.
|
|
2152
|
+
*
|
|
2153
|
+
* Min: 2 characters
|
|
973
2154
|
*/
|
|
974
|
-
|
|
975
|
-
/** Site ID. */
|
|
976
|
-
siteId?: string;
|
|
977
|
-
}
|
|
978
|
-
interface Multilingual {
|
|
979
|
-
/** Whether the site supports more than a single language. */
|
|
980
|
-
isMultiLingual?: boolean;
|
|
981
|
-
/** List of supported languages. Returned only when `{"isMultiLingual": true}`. */
|
|
982
|
-
supportedLanguages?: SupportedLanguage[];
|
|
983
|
-
}
|
|
984
|
-
interface SupportedLanguage {
|
|
985
|
-
/** Two-letter language code in [ISO 639-1 alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. */
|
|
986
|
-
languageCode?: string;
|
|
987
|
-
/** Locale. */
|
|
988
|
-
locale?: Locale;
|
|
989
|
-
/** Whether the supported language is the primary language for the site. */
|
|
990
|
-
isPrimary?: boolean;
|
|
991
|
-
/** Language icon. */
|
|
992
|
-
countryCode?: string;
|
|
993
|
-
/** How the language will be resolved. For internal use. */
|
|
994
|
-
resolutionMethod?: ResolutionMethod;
|
|
995
|
-
}
|
|
996
|
-
interface Locale {
|
|
997
|
-
/** Two-letter language code in [ISO 639-1 alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. */
|
|
998
|
-
languageCode?: string;
|
|
999
|
-
/** Two-letter country code in [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) format. */
|
|
1000
|
-
country?: string;
|
|
1001
|
-
}
|
|
1002
|
-
declare enum ResolutionMethod {
|
|
1003
|
-
QUERY_PARAM = "QUERY_PARAM",
|
|
1004
|
-
SUBDOMAIN = "SUBDOMAIN",
|
|
1005
|
-
SUBDIRECTORY = "SUBDIRECTORY"
|
|
1006
|
-
}
|
|
1007
|
-
interface OwnerInfo {
|
|
1008
|
-
/** Site owner's email address. Identical to the site owner's login email. */
|
|
1009
|
-
email?: string;
|
|
2155
|
+
customEventName?: string | null;
|
|
1010
2156
|
/**
|
|
1011
|
-
* Supported values: `
|
|
1012
|
-
*
|
|
2157
|
+
* Supported values include: `"cycle_name"`, `"currency"`, `"sum"`, `"reason"`, `"app_plan_id"`.
|
|
2158
|
+
* You may also submit data with keys that aren't listed here.
|
|
1013
2159
|
*
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
2160
|
+
* Additional data about your app's event.
|
|
2161
|
+
*
|
|
2162
|
+
* + `"cycle_name"`: Supported values: `"monthly"`, `"yearly"`, `"2 years"`, `"one time"`.
|
|
2163
|
+
* + `"currency"`: 3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format.
|
|
2164
|
+
* + `"sum"`: Amount of money. Required for `{"eventName": "CHARGE"}` and `{"eventName": "FUNDS_RETURNED"}`.
|
|
2165
|
+
* + `"reason"`: Information about why the event was triggered in your app.
|
|
2166
|
+
* + `"app_plan_id"`: ID of the your app's plan as displayed in your app's dashboard. Note that it's the same value as `vendorProductId` in the [Paid Plan Purchased webhook](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/paid-plan-purchased).
|
|
1016
2167
|
*/
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
interface GetAppInstanceByInstanceIdRequest {
|
|
1020
|
-
/** ID of the app instance to retrieve. */
|
|
1021
|
-
instanceId?: string;
|
|
1022
|
-
}
|
|
1023
|
-
interface MessageEnvelope$1 {
|
|
1024
|
-
/** App instance ID. */
|
|
1025
|
-
instanceId?: string | null;
|
|
1026
|
-
/** Event type. */
|
|
1027
|
-
eventType?: string;
|
|
1028
|
-
/** The identification type and identity data. */
|
|
1029
|
-
identity?: IdentificationData$1;
|
|
1030
|
-
/** Stringify payload. */
|
|
1031
|
-
data?: string;
|
|
1032
|
-
}
|
|
1033
|
-
interface IdentificationData$1 extends IdentificationDataIdOneOf$1 {
|
|
1034
|
-
/** ID of a site visitor that has not logged in to the site. */
|
|
1035
|
-
anonymousVisitorId?: string;
|
|
1036
|
-
/** ID of a site visitor that has logged in to the site. */
|
|
1037
|
-
memberId?: string;
|
|
1038
|
-
/** ID of a Wix user (site owner, contributor, etc.). */
|
|
1039
|
-
wixUserId?: string;
|
|
1040
|
-
/** ID of an app. */
|
|
1041
|
-
appId?: string;
|
|
1042
|
-
/** @readonly */
|
|
1043
|
-
identityType?: WebhookIdentityType$1;
|
|
1044
|
-
}
|
|
1045
|
-
/** @oneof */
|
|
1046
|
-
interface IdentificationDataIdOneOf$1 {
|
|
1047
|
-
/** ID of a site visitor that has not logged in to the site. */
|
|
1048
|
-
anonymousVisitorId?: string;
|
|
1049
|
-
/** ID of a site visitor that has logged in to the site. */
|
|
1050
|
-
memberId?: string;
|
|
1051
|
-
/** ID of a Wix user (site owner, contributor, etc.). */
|
|
1052
|
-
wixUserId?: string;
|
|
1053
|
-
/** ID of an app. */
|
|
1054
|
-
appId?: string;
|
|
1055
|
-
}
|
|
1056
|
-
declare enum WebhookIdentityType$1 {
|
|
1057
|
-
UNKNOWN = "UNKNOWN",
|
|
1058
|
-
ANONYMOUS_VISITOR = "ANONYMOUS_VISITOR",
|
|
1059
|
-
MEMBER = "MEMBER",
|
|
1060
|
-
WIX_USER = "WIX_USER",
|
|
1061
|
-
APP = "APP"
|
|
1062
|
-
}
|
|
1063
|
-
interface FreeTrialInfoNonNullableFields {
|
|
1064
|
-
status: FreeTrialStatus;
|
|
1065
|
-
}
|
|
1066
|
-
interface BillingInfoNonNullableFields {
|
|
1067
|
-
packageName: string;
|
|
1068
|
-
billingCycle: PaymentCycle$1;
|
|
1069
|
-
timeStamp: string;
|
|
1070
|
-
freeTrialInfo?: FreeTrialInfoNonNullableFields;
|
|
1071
|
-
}
|
|
1072
|
-
interface AvailablePlanNonNullableFields {
|
|
1073
|
-
packageName: string;
|
|
1074
|
-
source: string;
|
|
1075
|
-
}
|
|
1076
|
-
interface AppInstanceNonNullableFields {
|
|
1077
|
-
instanceId: string;
|
|
1078
|
-
appName: string;
|
|
1079
|
-
isFree: boolean;
|
|
1080
|
-
billing?: BillingInfoNonNullableFields;
|
|
1081
|
-
permissions: string[];
|
|
1082
|
-
availablePlans: AvailablePlanNonNullableFields[];
|
|
1083
|
-
isOriginSiteTemplate: boolean;
|
|
1084
|
-
copiedFromTemplate: boolean;
|
|
1085
|
-
freeTrialAvailable: boolean;
|
|
1086
|
-
}
|
|
1087
|
-
interface LocaleNonNullableFields {
|
|
1088
|
-
languageCode: string;
|
|
1089
|
-
country: string;
|
|
1090
|
-
}
|
|
1091
|
-
interface SupportedLanguageNonNullableFields {
|
|
1092
|
-
languageCode: string;
|
|
1093
|
-
locale?: LocaleNonNullableFields;
|
|
1094
|
-
isPrimary: boolean;
|
|
1095
|
-
countryCode: string;
|
|
1096
|
-
resolutionMethod: ResolutionMethod;
|
|
1097
|
-
}
|
|
1098
|
-
interface MultilingualNonNullableFields {
|
|
1099
|
-
isMultiLingual: boolean;
|
|
1100
|
-
supportedLanguages: SupportedLanguageNonNullableFields[];
|
|
1101
|
-
}
|
|
1102
|
-
interface OwnerInfoNonNullableFields {
|
|
1103
|
-
email: string;
|
|
1104
|
-
emailStatus: string;
|
|
1105
|
-
}
|
|
1106
|
-
interface SiteInfoNonNullableFields {
|
|
1107
|
-
locale: string;
|
|
1108
|
-
paymentCurrency: string;
|
|
1109
|
-
multilingual?: MultilingualNonNullableFields;
|
|
1110
|
-
installedWixApps: string[];
|
|
1111
|
-
ownerInfo?: OwnerInfoNonNullableFields;
|
|
1112
|
-
siteId: string;
|
|
1113
|
-
}
|
|
1114
|
-
interface GetAppInstanceResponseNonNullableFields {
|
|
1115
|
-
instance?: AppInstanceNonNullableFields;
|
|
1116
|
-
site?: SiteInfoNonNullableFields;
|
|
1117
|
-
}
|
|
1118
|
-
interface BaseEventMetadata {
|
|
1119
|
-
/** App instance ID. */
|
|
1120
|
-
instanceId?: string | null;
|
|
1121
|
-
/** Event type. */
|
|
1122
|
-
eventType?: string;
|
|
1123
|
-
/** The identification type and identity data. */
|
|
1124
|
-
identity?: IdentificationData$1;
|
|
1125
|
-
}
|
|
1126
|
-
interface AppInstanceInstalledEnvelope {
|
|
1127
|
-
data: AppInstalled;
|
|
1128
|
-
metadata: BaseEventMetadata;
|
|
1129
|
-
}
|
|
1130
|
-
interface AppInstanceRemovedEnvelope {
|
|
1131
|
-
data: AppRemoved;
|
|
1132
|
-
metadata: BaseEventMetadata;
|
|
1133
|
-
}
|
|
1134
|
-
interface AppInstancePaidPlanPurchasedEnvelope {
|
|
1135
|
-
data: PaidPlanPurchased;
|
|
1136
|
-
metadata: BaseEventMetadata;
|
|
2168
|
+
eventData?: Record<string, string>;
|
|
1137
2169
|
}
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
2170
|
+
|
|
2171
|
+
declare function sendBiEvent$1(httpClient: HttpClient$2): SendBiEventSignature;
|
|
2172
|
+
interface SendBiEventSignature {
|
|
2173
|
+
/**
|
|
2174
|
+
* Submit a BI event to Wix.
|
|
2175
|
+
*/
|
|
2176
|
+
(options?: SendBiEventOptions | undefined): Promise<void>;
|
|
1141
2177
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
2178
|
+
|
|
2179
|
+
declare const sendBiEvent: MaybeContext$2<BuildRESTFunction$2<typeof sendBiEvent$1> & typeof sendBiEvent$1>;
|
|
2180
|
+
|
|
2181
|
+
type index_d$2_EventName = EventName;
|
|
2182
|
+
declare const index_d$2_EventName: typeof EventName;
|
|
2183
|
+
type index_d$2_SendBIEventRequest = SendBIEventRequest;
|
|
2184
|
+
type index_d$2_SendBIEventResponse = SendBIEventResponse;
|
|
2185
|
+
type index_d$2_SendBiEventOptions = SendBiEventOptions;
|
|
2186
|
+
declare const index_d$2_sendBiEvent: typeof sendBiEvent;
|
|
2187
|
+
declare namespace index_d$2 {
|
|
2188
|
+
export { index_d$2_EventName as EventName, type index_d$2_SendBIEventRequest as SendBIEventRequest, type index_d$2_SendBIEventResponse as SendBIEventResponse, type index_d$2_SendBiEventOptions as SendBiEventOptions, index_d$2_sendBiEvent as sendBiEvent };
|
|
1145
2189
|
}
|
|
1146
2190
|
|
|
1147
|
-
|
|
1148
|
-
|
|
2191
|
+
type HostModule$1<T, H extends Host$1> = {
|
|
2192
|
+
__type: 'host';
|
|
2193
|
+
create(host: H): T;
|
|
2194
|
+
};
|
|
2195
|
+
type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
|
|
2196
|
+
type Host$1<Environment = unknown> = {
|
|
2197
|
+
channel: {
|
|
2198
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
2199
|
+
disconnect: () => void;
|
|
2200
|
+
} | Promise<{
|
|
2201
|
+
disconnect: () => void;
|
|
2202
|
+
}>;
|
|
2203
|
+
};
|
|
2204
|
+
environment?: Environment;
|
|
1149
2205
|
/**
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1152
|
-
* Call this function when you need information about a specific instance of your app and the site it’s installed on. For example, you may need to know whether the user has installed a free or paid version of your app, or to check what other Wix apps are installed on the site.
|
|
1153
|
-
*
|
|
1154
|
-
* You must authenticate as a [Wix App](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities#wix-apps). If you are calling this function from a [dashboard extension](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/dashboard-extensions/about-dashboard-extensions) in the [CLI](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/about-the-wix-cli-for-apps), Wix App authentication is passed automatically. Otherwise, you need to call the function with [elevated permissions](https://dev.wix.com/docs/sdk/articles/working-with-the-sdk/about-elevated-permissions).
|
|
1155
|
-
*
|
|
1156
|
-
* If you want `site.ownerInfo` to be included in the response, you must have the __Read Site Owner Email__ permission scope in addition to __WIX_DEVELOPERS.MANAGE_APP_INSTANCE__.
|
|
2206
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
1157
2207
|
*/
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
2208
|
+
apiBaseUrl?: string;
|
|
2209
|
+
/**
|
|
2210
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
2211
|
+
* like internationalization, billing, etc.
|
|
2212
|
+
*/
|
|
2213
|
+
essentials?: {
|
|
2214
|
+
/**
|
|
2215
|
+
* The language of the currently viewed session
|
|
2216
|
+
*/
|
|
2217
|
+
language?: string;
|
|
2218
|
+
/**
|
|
2219
|
+
* The locale of the currently viewed session
|
|
2220
|
+
*/
|
|
2221
|
+
locale?: string;
|
|
2222
|
+
/**
|
|
2223
|
+
* Any headers that should be passed through to the API requests
|
|
2224
|
+
*/
|
|
2225
|
+
passThroughHeaders?: Record<string, string>;
|
|
2226
|
+
};
|
|
2227
|
+
};
|
|
1165
2228
|
|
|
1166
|
-
type
|
|
2229
|
+
type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
|
|
2230
|
+
interface HttpClient$1 {
|
|
2231
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
|
|
2232
|
+
fetchWithAuth: typeof fetch;
|
|
2233
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
2234
|
+
getActiveToken?: () => string | undefined;
|
|
2235
|
+
}
|
|
2236
|
+
type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
|
|
2237
|
+
type HttpResponse$1<T = any> = {
|
|
2238
|
+
data: T;
|
|
2239
|
+
status: number;
|
|
2240
|
+
statusText: string;
|
|
2241
|
+
headers: any;
|
|
2242
|
+
request?: any;
|
|
2243
|
+
};
|
|
2244
|
+
type RequestOptions$1<_TResponse = any, Data = any> = {
|
|
2245
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
2246
|
+
url: string;
|
|
2247
|
+
data?: Data;
|
|
2248
|
+
params?: URLSearchParams;
|
|
2249
|
+
} & APIMetadata$1;
|
|
2250
|
+
type APIMetadata$1 = {
|
|
2251
|
+
methodFqn?: string;
|
|
2252
|
+
entityFqdn?: string;
|
|
2253
|
+
packageName?: string;
|
|
2254
|
+
};
|
|
2255
|
+
type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
|
|
2256
|
+
type EventDefinition$1<Payload = unknown, Type extends string = string> = {
|
|
1167
2257
|
__type: 'event-definition';
|
|
1168
2258
|
type: Type;
|
|
1169
2259
|
isDomainEvent?: boolean;
|
|
1170
2260
|
transformations?: (envelope: unknown) => Payload;
|
|
1171
2261
|
__payload: Payload;
|
|
1172
2262
|
};
|
|
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;
|
|
2263
|
+
declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
|
|
2264
|
+
type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
|
|
2265
|
+
type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
|
|
2266
|
+
|
|
2267
|
+
type ServicePluginMethodInput$1 = {
|
|
2268
|
+
request: any;
|
|
2269
|
+
metadata: any;
|
|
2270
|
+
};
|
|
2271
|
+
type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
|
|
2272
|
+
type ServicePluginMethodMetadata$1 = {
|
|
2273
|
+
name: string;
|
|
2274
|
+
primaryHttpMappingPath: string;
|
|
2275
|
+
transformations: {
|
|
2276
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
|
|
2277
|
+
toREST: (...args: unknown[]) => unknown;
|
|
2278
|
+
};
|
|
2279
|
+
};
|
|
2280
|
+
type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
|
|
2281
|
+
__type: 'service-plugin-definition';
|
|
2282
|
+
componentType: string;
|
|
2283
|
+
methods: ServicePluginMethodMetadata$1[];
|
|
2284
|
+
__contract: Contract;
|
|
2285
|
+
};
|
|
2286
|
+
declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
|
|
2287
|
+
type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
|
|
2288
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
|
|
2289
|
+
|
|
2290
|
+
type RequestContext$1 = {
|
|
2291
|
+
isSSR: boolean;
|
|
2292
|
+
host: string;
|
|
2293
|
+
protocol?: string;
|
|
2294
|
+
};
|
|
2295
|
+
type ResponseTransformer$1 = (data: any, headers?: any) => any;
|
|
2296
|
+
/**
|
|
2297
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
2298
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
2299
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
2300
|
+
*/
|
|
2301
|
+
type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
2302
|
+
type AmbassadorRequestOptions$1<T = any> = {
|
|
2303
|
+
_?: T;
|
|
2304
|
+
url?: string;
|
|
2305
|
+
method?: Method$1;
|
|
2306
|
+
params?: any;
|
|
2307
|
+
data?: any;
|
|
2308
|
+
transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
|
|
2309
|
+
};
|
|
2310
|
+
type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
|
|
2311
|
+
__isAmbassador: boolean;
|
|
2312
|
+
};
|
|
2313
|
+
type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
|
|
2314
|
+
type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
1176
2315
|
|
|
1177
2316
|
declare global {
|
|
1178
2317
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -1181,192 +2320,283 @@ declare global {
|
|
|
1181
2320
|
}
|
|
1182
2321
|
}
|
|
1183
2322
|
|
|
1184
|
-
declare
|
|
2323
|
+
declare const emptyObjectSymbol$1: unique symbol;
|
|
2324
|
+
|
|
2325
|
+
/**
|
|
2326
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
2327
|
+
|
|
2328
|
+
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)).
|
|
2329
|
+
|
|
2330
|
+
@example
|
|
2331
|
+
```
|
|
2332
|
+
import type {EmptyObject} from 'type-fest';
|
|
2333
|
+
|
|
2334
|
+
// The following illustrates the problem with `{}`.
|
|
2335
|
+
const foo1: {} = {}; // Pass
|
|
2336
|
+
const foo2: {} = []; // Pass
|
|
2337
|
+
const foo3: {} = 42; // Pass
|
|
2338
|
+
const foo4: {} = {a: 1}; // Pass
|
|
2339
|
+
|
|
2340
|
+
// With `EmptyObject` only the first case is valid.
|
|
2341
|
+
const bar1: EmptyObject = {}; // Pass
|
|
2342
|
+
const bar2: EmptyObject = 42; // Fail
|
|
2343
|
+
const bar3: EmptyObject = []; // Fail
|
|
2344
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
2345
|
+
```
|
|
2346
|
+
|
|
2347
|
+
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}.
|
|
2348
|
+
|
|
2349
|
+
@category Object
|
|
2350
|
+
*/
|
|
2351
|
+
type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
|
|
2352
|
+
|
|
2353
|
+
/**
|
|
2354
|
+
Returns a boolean for whether the two given types are equal.
|
|
2355
|
+
|
|
2356
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
2357
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
2358
|
+
|
|
2359
|
+
Use-cases:
|
|
2360
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
2361
|
+
|
|
2362
|
+
@example
|
|
2363
|
+
```
|
|
2364
|
+
import type {IsEqual} from 'type-fest';
|
|
2365
|
+
|
|
2366
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
2367
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
2368
|
+
type Includes<Value extends readonly any[], Item> =
|
|
2369
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
2370
|
+
? IsEqual<Value[0], Item> extends true
|
|
2371
|
+
? true
|
|
2372
|
+
: Includes<rest, Item>
|
|
2373
|
+
: false;
|
|
2374
|
+
```
|
|
2375
|
+
|
|
2376
|
+
@category Type Guard
|
|
2377
|
+
@category Utilities
|
|
2378
|
+
*/
|
|
2379
|
+
type IsEqual$1<A, B> =
|
|
2380
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
2381
|
+
(<G>() => G extends B ? 1 : 2)
|
|
2382
|
+
? true
|
|
2383
|
+
: false;
|
|
2384
|
+
|
|
2385
|
+
/**
|
|
2386
|
+
Filter out keys from an object.
|
|
2387
|
+
|
|
2388
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
2389
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
2390
|
+
Returns `Key` otherwise.
|
|
2391
|
+
|
|
2392
|
+
@example
|
|
2393
|
+
```
|
|
2394
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
2395
|
+
//=> never
|
|
2396
|
+
```
|
|
2397
|
+
|
|
2398
|
+
@example
|
|
2399
|
+
```
|
|
2400
|
+
type Filtered = Filter<'bar', string>;
|
|
2401
|
+
//=> never
|
|
2402
|
+
```
|
|
2403
|
+
|
|
2404
|
+
@example
|
|
2405
|
+
```
|
|
2406
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
2407
|
+
//=> 'bar'
|
|
2408
|
+
```
|
|
2409
|
+
|
|
2410
|
+
@see {Except}
|
|
2411
|
+
*/
|
|
2412
|
+
type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
2413
|
+
|
|
2414
|
+
type ExceptOptions$1 = {
|
|
2415
|
+
/**
|
|
2416
|
+
Disallow assigning non-specified properties.
|
|
2417
|
+
|
|
2418
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
2419
|
+
|
|
2420
|
+
@default false
|
|
2421
|
+
*/
|
|
2422
|
+
requireExactProps?: boolean;
|
|
2423
|
+
};
|
|
2424
|
+
|
|
2425
|
+
/**
|
|
2426
|
+
Create a type from an object type without certain keys.
|
|
2427
|
+
|
|
2428
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
2429
|
+
|
|
2430
|
+
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.
|
|
2431
|
+
|
|
2432
|
+
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)).
|
|
2433
|
+
|
|
2434
|
+
@example
|
|
2435
|
+
```
|
|
2436
|
+
import type {Except} from 'type-fest';
|
|
2437
|
+
|
|
2438
|
+
type Foo = {
|
|
2439
|
+
a: number;
|
|
2440
|
+
b: string;
|
|
2441
|
+
};
|
|
2442
|
+
|
|
2443
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
2444
|
+
//=> {b: string}
|
|
2445
|
+
|
|
2446
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
2447
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
2448
|
+
|
|
2449
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
2450
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
2451
|
+
|
|
2452
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
2453
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
2454
|
+
```
|
|
2455
|
+
|
|
2456
|
+
@category Object
|
|
2457
|
+
*/
|
|
2458
|
+
type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
|
|
2459
|
+
[KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
|
|
2460
|
+
} & (Options['requireExactProps'] extends true
|
|
2461
|
+
? Partial<Record<KeysType, never>>
|
|
2462
|
+
: {});
|
|
2463
|
+
|
|
2464
|
+
/**
|
|
2465
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
2466
|
+
|
|
2467
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
2468
|
+
|
|
2469
|
+
@example
|
|
2470
|
+
```
|
|
2471
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
2472
|
+
|
|
2473
|
+
interface Example {
|
|
2474
|
+
a: string;
|
|
2475
|
+
b: string | number;
|
|
2476
|
+
c?: string;
|
|
2477
|
+
d: {};
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
2481
|
+
//=> 'a'
|
|
2482
|
+
```
|
|
2483
|
+
|
|
2484
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
2485
|
+
|
|
2486
|
+
@example
|
|
2487
|
+
```
|
|
2488
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
2489
|
+
|
|
2490
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
2491
|
+
//=> 'a' | 'c'
|
|
2492
|
+
```
|
|
2493
|
+
|
|
2494
|
+
@category Object
|
|
2495
|
+
*/
|
|
2496
|
+
type ConditionalKeys$1<Base, Condition> = NonNullable<
|
|
2497
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
2498
|
+
{
|
|
2499
|
+
// Map through all the keys of the given base type.
|
|
2500
|
+
[Key in keyof Base]:
|
|
2501
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
2502
|
+
Base[Key] extends Condition
|
|
2503
|
+
// Retain this key since the condition passes.
|
|
2504
|
+
? Key
|
|
2505
|
+
// Discard this key since the condition fails.
|
|
2506
|
+
: never;
|
|
2507
|
+
|
|
2508
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
2509
|
+
}[keyof Base]
|
|
2510
|
+
>;
|
|
2511
|
+
|
|
2512
|
+
/**
|
|
2513
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
2514
|
+
|
|
2515
|
+
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.
|
|
2516
|
+
|
|
2517
|
+
@example
|
|
2518
|
+
```
|
|
2519
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
2520
|
+
|
|
2521
|
+
class Awesome {
|
|
2522
|
+
name: string;
|
|
2523
|
+
successes: number;
|
|
2524
|
+
failures: bigint;
|
|
2525
|
+
|
|
2526
|
+
run() {}
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
2530
|
+
//=> {run: () => void}
|
|
2531
|
+
```
|
|
1185
2532
|
|
|
1186
|
-
|
|
2533
|
+
@example
|
|
2534
|
+
```
|
|
2535
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
1187
2536
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
2537
|
+
interface Example {
|
|
2538
|
+
a: string;
|
|
2539
|
+
b: string | number;
|
|
2540
|
+
c: () => void;
|
|
2541
|
+
d: {};
|
|
2542
|
+
}
|
|
1193
2543
|
|
|
1194
|
-
type
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
*/
|
|
1198
|
-
declare const onAppInstanceRemoved: ReturnType<typeof createEventModule<_publicOnAppInstanceRemovedType>>;
|
|
2544
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
2545
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
2546
|
+
```
|
|
1199
2547
|
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
2548
|
+
@category Object
|
|
2549
|
+
*/
|
|
2550
|
+
type ConditionalExcept$1<Base, Condition> = Except$1<
|
|
2551
|
+
Base,
|
|
2552
|
+
ConditionalKeys$1<Base, Condition>
|
|
2553
|
+
>;
|
|
1205
2554
|
|
|
1206
|
-
type _publicOnAppInstancePaidPlanChangedType = typeof onAppInstancePaidPlanChanged$1;
|
|
1207
2555
|
/**
|
|
1208
|
-
*
|
|
2556
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
2557
|
+
* can either be a REST module or a host module.
|
|
2558
|
+
* This type is recursive, so it can describe nested modules.
|
|
1209
2559
|
*/
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
2560
|
+
type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$1<any> | ServicePluginDefinition$1<any> | {
|
|
2561
|
+
[key: string]: Descriptors$1 | PublicMetadata$1 | any;
|
|
2562
|
+
};
|
|
1213
2563
|
/**
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1216
|
-
*
|
|
2564
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
2565
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
2566
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
2567
|
+
* do not match the given host (as they will not work with the given host).
|
|
1217
2568
|
*/
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
type
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
type index_d$3_GetAppInstanceResponseNonNullableFields = GetAppInstanceResponseNonNullableFields;
|
|
1238
|
-
type index_d$3_Locale = Locale;
|
|
1239
|
-
type index_d$3_Multilingual = Multilingual;
|
|
1240
|
-
type index_d$3_OwnerInfo = OwnerInfo;
|
|
1241
|
-
type index_d$3_PaidPlanAutoRenewalCancelled = PaidPlanAutoRenewalCancelled;
|
|
1242
|
-
type index_d$3_PaidPlanChanged = PaidPlanChanged;
|
|
1243
|
-
type index_d$3_PaidPlanPurchased = PaidPlanPurchased;
|
|
1244
|
-
type index_d$3_ResolutionMethod = ResolutionMethod;
|
|
1245
|
-
declare const index_d$3_ResolutionMethod: typeof ResolutionMethod;
|
|
1246
|
-
type index_d$3_SiteInfo = SiteInfo;
|
|
1247
|
-
type index_d$3_SupportedLanguage = SupportedLanguage;
|
|
1248
|
-
type index_d$3__publicOnAppInstanceInstalledType = _publicOnAppInstanceInstalledType;
|
|
1249
|
-
type index_d$3__publicOnAppInstancePaidPlanAutoRenewalCancelledType = _publicOnAppInstancePaidPlanAutoRenewalCancelledType;
|
|
1250
|
-
type index_d$3__publicOnAppInstancePaidPlanChangedType = _publicOnAppInstancePaidPlanChangedType;
|
|
1251
|
-
type index_d$3__publicOnAppInstancePaidPlanPurchasedType = _publicOnAppInstancePaidPlanPurchasedType;
|
|
1252
|
-
type index_d$3__publicOnAppInstanceRemovedType = _publicOnAppInstanceRemovedType;
|
|
1253
|
-
declare const index_d$3_getAppInstance: typeof getAppInstance;
|
|
1254
|
-
declare const index_d$3_onAppInstanceInstalled: typeof onAppInstanceInstalled;
|
|
1255
|
-
declare const index_d$3_onAppInstancePaidPlanAutoRenewalCancelled: typeof onAppInstancePaidPlanAutoRenewalCancelled;
|
|
1256
|
-
declare const index_d$3_onAppInstancePaidPlanChanged: typeof onAppInstancePaidPlanChanged;
|
|
1257
|
-
declare const index_d$3_onAppInstancePaidPlanPurchased: typeof onAppInstancePaidPlanPurchased;
|
|
1258
|
-
declare const index_d$3_onAppInstanceRemoved: typeof onAppInstanceRemoved;
|
|
1259
|
-
declare namespace index_d$3 {
|
|
1260
|
-
export { type index_d$3_AppInstalled as AppInstalled, type index_d$3_AppInstance as AppInstance, type index_d$3_AppInstanceInstalledEnvelope as AppInstanceInstalledEnvelope, type index_d$3_AppInstancePaidPlanAutoRenewalCancelledEnvelope as AppInstancePaidPlanAutoRenewalCancelledEnvelope, type index_d$3_AppInstancePaidPlanChangedEnvelope as AppInstancePaidPlanChangedEnvelope, type index_d$3_AppInstancePaidPlanPurchasedEnvelope as AppInstancePaidPlanPurchasedEnvelope, type index_d$3_AppInstanceRemovedEnvelope as AppInstanceRemovedEnvelope, type index_d$3_AppRemoved as AppRemoved, type index_d$3_AvailablePlan as AvailablePlan, type index_d$3_BaseEventMetadata as BaseEventMetadata, type index_d$3_BillingInfo as BillingInfo, type index_d$3_FreeTrialInfo as FreeTrialInfo, index_d$3_FreeTrialStatus as FreeTrialStatus, type index_d$3_GetAppInstanceByInstanceIdRequest as GetAppInstanceByInstanceIdRequest, type index_d$3_GetAppInstanceRequest as GetAppInstanceRequest, type index_d$3_GetAppInstanceResponse as GetAppInstanceResponse, type index_d$3_GetAppInstanceResponseNonNullableFields as GetAppInstanceResponseNonNullableFields, type IdentificationData$1 as IdentificationData, type IdentificationDataIdOneOf$1 as IdentificationDataIdOneOf, type index_d$3_Locale as Locale, type MessageEnvelope$1 as MessageEnvelope, type index_d$3_Multilingual as Multilingual, type index_d$3_OwnerInfo as OwnerInfo, type index_d$3_PaidPlanAutoRenewalCancelled as PaidPlanAutoRenewalCancelled, type index_d$3_PaidPlanChanged as PaidPlanChanged, type index_d$3_PaidPlanPurchased as PaidPlanPurchased, PaymentCycle$1 as PaymentCycle, index_d$3_ResolutionMethod as ResolutionMethod, type index_d$3_SiteInfo as SiteInfo, type index_d$3_SupportedLanguage as SupportedLanguage, WebhookIdentityType$1 as WebhookIdentityType, type index_d$3__publicOnAppInstanceInstalledType as _publicOnAppInstanceInstalledType, type index_d$3__publicOnAppInstancePaidPlanAutoRenewalCancelledType as _publicOnAppInstancePaidPlanAutoRenewalCancelledType, type index_d$3__publicOnAppInstancePaidPlanChangedType as _publicOnAppInstancePaidPlanChangedType, type index_d$3__publicOnAppInstancePaidPlanPurchasedType as _publicOnAppInstancePaidPlanPurchasedType, type index_d$3__publicOnAppInstanceRemovedType as _publicOnAppInstanceRemovedType, index_d$3_getAppInstance as getAppInstance, index_d$3_onAppInstanceInstalled as onAppInstanceInstalled, index_d$3_onAppInstancePaidPlanAutoRenewalCancelled as onAppInstancePaidPlanAutoRenewalCancelled, index_d$3_onAppInstancePaidPlanChanged as onAppInstancePaidPlanChanged, index_d$3_onAppInstancePaidPlanPurchased as onAppInstancePaidPlanPurchased, index_d$3_onAppInstanceRemoved as onAppInstanceRemoved, onAppInstanceInstalled$1 as publicOnAppInstanceInstalled, onAppInstancePaidPlanAutoRenewalCancelled$1 as publicOnAppInstancePaidPlanAutoRenewalCancelled, onAppInstancePaidPlanChanged$1 as publicOnAppInstancePaidPlanChanged, onAppInstancePaidPlanPurchased$1 as publicOnAppInstancePaidPlanPurchased, onAppInstanceRemoved$1 as publicOnAppInstanceRemoved };
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
interface SendBIEventResponse {
|
|
1264
|
-
}
|
|
1265
|
-
interface SendBIEventRequest {
|
|
1266
|
-
/**
|
|
1267
|
-
* Name of the event that's triggered in your app.
|
|
1268
|
-
*
|
|
1269
|
-
* + `"APP_DASHBOARD_LOADED"`: A site onwer or contributor loads your app's dashboard.
|
|
1270
|
-
* + `"APP_FINISHED_CONFIGURATION"`: The site owner completes all required configurations for your app in your app's dashboard.
|
|
1271
|
-
* + `"APP_UPGRADED"`: The site owner upgrades your app's paid plan. An upgrade means that they have finished the checkout flow on the app's side but not necessarily on Wix's side.
|
|
1272
|
-
* + `"PRIMARY_ACTION_PERFORMED"`: A site owner, contributor, or visitor triggers your app's primary action. For example, a site visitor writes a product review using your product review app.
|
|
1273
|
-
* + `"CHARGE"`: You charge money from the site owner. For example, when the site owner purchases or renews a subscription for your app. Make sure to also send `eventData` and a key of `sum`.
|
|
1274
|
-
* + `"FUNDS_RETURNED"`: Trigger this event when you send money back to a site owner (for example, refunds or chargebacks). Make sure to also send the charge amount inside `eventData`. For example, `{"eventData": {"sum": "5.99"}}`.
|
|
1275
|
-
* + `"CUSTOM"`: Any event that's not listed here. Make sure to also send `customEventName`.
|
|
1276
|
-
* + `"APP_DEPLOYED"`: Your app’s internal code implementation is changed and might affect user flows or cause a regression.
|
|
1277
|
-
* + `"APP_FINISH_BUSINESS_SETUP"`: __Deprecation Notice:__ This enum value will be removed on March 30, 2023. Use `"APP_SETUP_FINISHED"` instead.
|
|
1278
|
-
* + `"APP_SETUP_FINISHED"`: The site owner completes your app's required business setup.
|
|
1279
|
-
*/
|
|
1280
|
-
eventName?: EventName;
|
|
1281
|
-
/**
|
|
1282
|
-
* Name of your app's custom event that was triggered. Required when `{"eventName": "CUSTOM"}`.
|
|
1283
|
-
*
|
|
1284
|
-
* Min: 2 characters
|
|
1285
|
-
*/
|
|
1286
|
-
customEventName?: string | null;
|
|
1287
|
-
/**
|
|
1288
|
-
* Supported values include: `"cycle_name"`, `"currency"`, `"sum"`, `"reason"`, `"app_plan_id"`.
|
|
1289
|
-
* You may also submit data with keys that aren't listed here.
|
|
1290
|
-
*
|
|
1291
|
-
* Additional data about your app's event.
|
|
1292
|
-
*
|
|
1293
|
-
* + `"cycle_name"`: Supported values: `"monthly"`, `"yearly"`, `"2 years"`, `"one time"`.
|
|
1294
|
-
* + `"currency"`: 3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format.
|
|
1295
|
-
* + `"sum"`: Amount of money. Required for `{"eventName": "CHARGE"}` and `{"eventName": "FUNDS_RETURNED"}`.
|
|
1296
|
-
* + `"reason"`: Information about why the event was triggered in your app.
|
|
1297
|
-
* + `"app_plan_id"`: ID of the your app's plan as displayed in your app's dashboard. Note that it's the same value as `vendorProductId` in the [Paid Plan Purchased webhook](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/paid-plan-purchased).
|
|
1298
|
-
*/
|
|
1299
|
-
eventData?: Record<string, string>;
|
|
1300
|
-
}
|
|
1301
|
-
declare enum EventName {
|
|
1302
|
-
UNKNOWN = "UNKNOWN",
|
|
1303
|
-
APP_DASHBOARD_LOADED = "APP_DASHBOARD_LOADED",
|
|
1304
|
-
APP_FINISHED_CONFIGURATION = "APP_FINISHED_CONFIGURATION",
|
|
1305
|
-
APP_UPGRADED = "APP_UPGRADED",
|
|
1306
|
-
PRIMARY_ACTION_PERFORMED = "PRIMARY_ACTION_PERFORMED",
|
|
1307
|
-
CUSTOM = "CUSTOM",
|
|
1308
|
-
CHARGE = "CHARGE",
|
|
1309
|
-
FUNDS_RETURNED = "FUNDS_RETURNED",
|
|
1310
|
-
APP_FINISH_BUSINESS_SETUP = "APP_FINISH_BUSINESS_SETUP",
|
|
1311
|
-
APP_DEPLOYED = "APP_DEPLOYED",
|
|
1312
|
-
APP_SETUP_FINISHED = "APP_SETUP_FINISHED"
|
|
1313
|
-
}
|
|
1314
|
-
interface SendBiEventOptions {
|
|
1315
|
-
/**
|
|
1316
|
-
* Name of the event that's triggered in your app.
|
|
1317
|
-
*
|
|
1318
|
-
* + `"APP_DASHBOARD_LOADED"`: A site onwer or contributor loads your app's dashboard.
|
|
1319
|
-
* + `"APP_FINISHED_CONFIGURATION"`: The site owner completes all required configurations for your app in your app's dashboard.
|
|
1320
|
-
* + `"APP_UPGRADED"`: The site owner upgrades your app's paid plan. An upgrade means that they have finished the checkout flow on the app's side but not necessarily on Wix's side.
|
|
1321
|
-
* + `"PRIMARY_ACTION_PERFORMED"`: A site owner, contributor, or visitor triggers your app's primary action. For example, a site visitor writes a product review using your product review app.
|
|
1322
|
-
* + `"CHARGE"`: You charge money from the site owner. For example, when the site owner purchases or renews a subscription for your app. Make sure to also send `eventData` and a key of `sum`.
|
|
1323
|
-
* + `"FUNDS_RETURNED"`: Trigger this event when you send money back to a site owner (for example, refunds or chargebacks). Make sure to also send the charge amount inside `eventData`. For example, `{"eventData": {"sum": "5.99"}}`.
|
|
1324
|
-
* + `"CUSTOM"`: Any event that's not listed here. Make sure to also send `customEventName`.
|
|
1325
|
-
* + `"APP_DEPLOYED"`: Your app’s internal code implementation is changed and might affect user flows or cause a regression.
|
|
1326
|
-
* + `"APP_FINISH_BUSINESS_SETUP"`: __Deprecation Notice:__ This enum value will be removed on March 30, 2023. Use `"APP_SETUP_FINISHED"` instead.
|
|
1327
|
-
* + `"APP_SETUP_FINISHED"`: The site owner completes your app's required business setup.
|
|
1328
|
-
*/
|
|
1329
|
-
eventName?: EventName;
|
|
1330
|
-
/**
|
|
1331
|
-
* Name of your app's custom event that was triggered. Required when `{"eventName": "CUSTOM"}`.
|
|
1332
|
-
*
|
|
1333
|
-
* Min: 2 characters
|
|
1334
|
-
*/
|
|
1335
|
-
customEventName?: string | null;
|
|
1336
|
-
/**
|
|
1337
|
-
* Supported values include: `"cycle_name"`, `"currency"`, `"sum"`, `"reason"`, `"app_plan_id"`.
|
|
1338
|
-
* You may also submit data with keys that aren't listed here.
|
|
1339
|
-
*
|
|
1340
|
-
* Additional data about your app's event.
|
|
1341
|
-
*
|
|
1342
|
-
* + `"cycle_name"`: Supported values: `"monthly"`, `"yearly"`, `"2 years"`, `"one time"`.
|
|
1343
|
-
* + `"currency"`: 3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format.
|
|
1344
|
-
* + `"sum"`: Amount of money. Required for `{"eventName": "CHARGE"}` and `{"eventName": "FUNDS_RETURNED"}`.
|
|
1345
|
-
* + `"reason"`: Information about why the event was triggered in your app.
|
|
1346
|
-
* + `"app_plan_id"`: ID of the your app's plan as displayed in your app's dashboard. Note that it's the same value as `vendorProductId` in the [Paid Plan Purchased webhook](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/paid-plan-purchased).
|
|
1347
|
-
*/
|
|
1348
|
-
eventData?: Record<string, string>;
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
declare function sendBiEvent$1(httpClient: HttpClient): SendBiEventSignature;
|
|
1352
|
-
interface SendBiEventSignature {
|
|
1353
|
-
/**
|
|
1354
|
-
* Submit a BI event to Wix.
|
|
1355
|
-
*/
|
|
1356
|
-
(options?: SendBiEventOptions | undefined): Promise<void>;
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
declare const sendBiEvent: MaybeContext<BuildRESTFunction<typeof sendBiEvent$1> & typeof sendBiEvent$1>;
|
|
2569
|
+
type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
|
|
2570
|
+
done: T;
|
|
2571
|
+
recurse: T extends {
|
|
2572
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
|
|
2573
|
+
} ? never : T extends AmbassadorFunctionDescriptor$1 ? BuildAmbassadorFunction$1<T> : T extends RESTFunctionDescriptor$1 ? BuildRESTFunction$1<T> : T extends EventDefinition$1<any> ? BuildEventDefinition$1<T> : T extends ServicePluginDefinition$1<any> ? BuildServicePluginDefinition$1<T> : T extends HostModule$1<any, any> ? HostModuleAPI$1<T> : ConditionalExcept$1<{
|
|
2574
|
+
[Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
|
|
2575
|
+
-1,
|
|
2576
|
+
0,
|
|
2577
|
+
1,
|
|
2578
|
+
2,
|
|
2579
|
+
3,
|
|
2580
|
+
4,
|
|
2581
|
+
5
|
|
2582
|
+
][Depth]> : never;
|
|
2583
|
+
}, EmptyObject$1>;
|
|
2584
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
2585
|
+
type PublicMetadata$1 = {
|
|
2586
|
+
PACKAGE_NAME?: string;
|
|
2587
|
+
};
|
|
1360
2588
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
type index_d$2_SendBIEventResponse = SendBIEventResponse;
|
|
1365
|
-
type index_d$2_SendBiEventOptions = SendBiEventOptions;
|
|
1366
|
-
declare const index_d$2_sendBiEvent: typeof sendBiEvent;
|
|
1367
|
-
declare namespace index_d$2 {
|
|
1368
|
-
export { index_d$2_EventName as EventName, type index_d$2_SendBIEventRequest as SendBIEventRequest, type index_d$2_SendBIEventResponse as SendBIEventResponse, type index_d$2_SendBiEventOptions as SendBiEventOptions, index_d$2_sendBiEvent as sendBiEvent };
|
|
2589
|
+
declare global {
|
|
2590
|
+
interface ContextualClient {
|
|
2591
|
+
}
|
|
1369
2592
|
}
|
|
2593
|
+
/**
|
|
2594
|
+
* A type used to create concerete types from SDK descriptors in
|
|
2595
|
+
* case a contextual client is available.
|
|
2596
|
+
*/
|
|
2597
|
+
type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
|
|
2598
|
+
host: Host$1;
|
|
2599
|
+
} ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
|
|
1370
2600
|
|
|
1371
2601
|
interface PurchasedItem {
|
|
1372
2602
|
/** ID of your app's paid plan. */
|
|
@@ -1598,92 +2828,502 @@ interface GetUrlOptions {
|
|
|
1598
2828
|
* relevant for in-app purchase flows. When `true`, Wix charges the site
|
|
1599
2829
|
* owners an amount of `0.00`.
|
|
1600
2830
|
*/
|
|
1601
|
-
testCheckout?: boolean;
|
|
1602
|
-
/** Information about the paid plan's billing cycle. */
|
|
1603
|
-
billingCycle?: PaymentCycle;
|
|
2831
|
+
testCheckout?: boolean;
|
|
2832
|
+
/** Information about the paid plan's billing cycle. */
|
|
2833
|
+
billingCycle?: PaymentCycle;
|
|
2834
|
+
/**
|
|
2835
|
+
* 2-letter country code in
|
|
2836
|
+
* [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
|
|
2837
|
+
* format.
|
|
2838
|
+
*
|
|
2839
|
+
* Default: `"US"`
|
|
2840
|
+
*/
|
|
2841
|
+
countryCode?: string | null;
|
|
2842
|
+
/**
|
|
2843
|
+
* 2-letter language code in
|
|
2844
|
+
* [ISO 639-1 alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format.
|
|
2845
|
+
*
|
|
2846
|
+
* Default: `"EN"`
|
|
2847
|
+
*/
|
|
2848
|
+
languageCode?: string | null;
|
|
2849
|
+
/** Coupon code for the paid plan. Available only in case there is a discount. */
|
|
2850
|
+
couponCode?: string | null;
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
declare function getUrl$1(httpClient: HttpClient$1): GetUrlSignature;
|
|
2854
|
+
interface GetUrlSignature {
|
|
2855
|
+
/**
|
|
2856
|
+
* Retrieves the URL for a Wix checkout page for the specified paid plan of your app.
|
|
2857
|
+
*
|
|
2858
|
+
*
|
|
2859
|
+
* This call succeeds only in case you have previously
|
|
2860
|
+
* [set up an external pricing page in your app's dashboard](https://dev.wix.com/docs/build-apps/build-your-app/pricing-plans/set-up-an-external-pricing-page).
|
|
2861
|
+
*
|
|
2862
|
+
* The returned checkout URL is valid for 48 hours.
|
|
2863
|
+
*
|
|
2864
|
+
* This API allows your app to manage your pricing page outside of Wix while
|
|
2865
|
+
* still using the standard Wix checkout flow.
|
|
2866
|
+
* @param - ID of your app's paid plan to retrieve the Wix checkout URL for. Check your app's dashboard
|
|
2867
|
+
* for a list of your app's supported product IDs.
|
|
2868
|
+
*/
|
|
2869
|
+
(productId: string, options?: GetUrlOptions | undefined): Promise<GetUrlResponse & GetUrlResponseNonNullableFields>;
|
|
2870
|
+
}
|
|
2871
|
+
declare function getPurchaseHistory$1(httpClient: HttpClient$1): GetPurchaseHistorySignature;
|
|
2872
|
+
interface GetPurchaseHistorySignature {
|
|
1604
2873
|
/**
|
|
1605
|
-
*
|
|
1606
|
-
* [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
|
|
1607
|
-
* format.
|
|
2874
|
+
* Retrieves a list of the site owner's past purchases for your app.
|
|
1608
2875
|
*
|
|
1609
|
-
*
|
|
2876
|
+
*
|
|
2877
|
+
* You don't have to explicitly pass an identifier for the Wix site as part of
|
|
2878
|
+
* the request, since this information is taken automatically from the context.
|
|
2879
|
+
*
|
|
2880
|
+
* The response doesn't include any details about cancellations.
|
|
1610
2881
|
*/
|
|
1611
|
-
|
|
2882
|
+
(): Promise<GetPurchaseHistoryResponse & GetPurchaseHistoryResponseNonNullableFields>;
|
|
2883
|
+
}
|
|
2884
|
+
|
|
2885
|
+
declare const getUrl: MaybeContext$1<BuildRESTFunction$1<typeof getUrl$1> & typeof getUrl$1>;
|
|
2886
|
+
declare const getPurchaseHistory: MaybeContext$1<BuildRESTFunction$1<typeof getPurchaseHistory$1> & typeof getPurchaseHistory$1>;
|
|
2887
|
+
|
|
2888
|
+
type index_d$1_Charge = Charge;
|
|
2889
|
+
type index_d$1_ChargeOverride = ChargeOverride;
|
|
2890
|
+
type index_d$1_GetMeteredBillingChargesRequest = GetMeteredBillingChargesRequest;
|
|
2891
|
+
type index_d$1_GetMeteredBillingChargesResponse = GetMeteredBillingChargesResponse;
|
|
2892
|
+
type index_d$1_GetPurchaseHistoryRequest = GetPurchaseHistoryRequest;
|
|
2893
|
+
type index_d$1_GetPurchaseHistoryResponse = GetPurchaseHistoryResponse;
|
|
2894
|
+
type index_d$1_GetPurchaseHistoryResponseNonNullableFields = GetPurchaseHistoryResponseNonNullableFields;
|
|
2895
|
+
type index_d$1_GetSitePaymentMethodsStatusRequest = GetSitePaymentMethodsStatusRequest;
|
|
2896
|
+
type index_d$1_GetSitePaymentMethodsStatusResponse = GetSitePaymentMethodsStatusResponse;
|
|
2897
|
+
type index_d$1_GetUrlOptions = GetUrlOptions;
|
|
2898
|
+
type index_d$1_GetUrlRequest = GetUrlRequest;
|
|
2899
|
+
type index_d$1_GetUrlResponse = GetUrlResponse;
|
|
2900
|
+
type index_d$1_GetUrlResponseNonNullableFields = GetUrlResponseNonNullableFields;
|
|
2901
|
+
type index_d$1_IdentificationData = IdentificationData;
|
|
2902
|
+
type index_d$1_IdentificationDataIdOneOf = IdentificationDataIdOneOf;
|
|
2903
|
+
type index_d$1_InvoiceStatus = InvoiceStatus;
|
|
2904
|
+
declare const index_d$1_InvoiceStatus: typeof InvoiceStatus;
|
|
2905
|
+
type index_d$1_InvoiceStatusUpdate = InvoiceStatusUpdate;
|
|
2906
|
+
type index_d$1_MessageEnvelope = MessageEnvelope;
|
|
2907
|
+
type index_d$1_PaymentCycle = PaymentCycle;
|
|
2908
|
+
declare const index_d$1_PaymentCycle: typeof PaymentCycle;
|
|
2909
|
+
type index_d$1_PurchasedItem = PurchasedItem;
|
|
2910
|
+
type index_d$1_WebhookIdentityType = WebhookIdentityType;
|
|
2911
|
+
declare const index_d$1_WebhookIdentityType: typeof WebhookIdentityType;
|
|
2912
|
+
declare const index_d$1_getPurchaseHistory: typeof getPurchaseHistory;
|
|
2913
|
+
declare const index_d$1_getUrl: typeof getUrl;
|
|
2914
|
+
declare namespace index_d$1 {
|
|
2915
|
+
export { type index_d$1_Charge as Charge, type index_d$1_ChargeOverride as ChargeOverride, type index_d$1_GetMeteredBillingChargesRequest as GetMeteredBillingChargesRequest, type index_d$1_GetMeteredBillingChargesResponse as GetMeteredBillingChargesResponse, type index_d$1_GetPurchaseHistoryRequest as GetPurchaseHistoryRequest, type index_d$1_GetPurchaseHistoryResponse as GetPurchaseHistoryResponse, type index_d$1_GetPurchaseHistoryResponseNonNullableFields as GetPurchaseHistoryResponseNonNullableFields, type index_d$1_GetSitePaymentMethodsStatusRequest as GetSitePaymentMethodsStatusRequest, type index_d$1_GetSitePaymentMethodsStatusResponse as GetSitePaymentMethodsStatusResponse, type index_d$1_GetUrlOptions as GetUrlOptions, type index_d$1_GetUrlRequest as GetUrlRequest, type index_d$1_GetUrlResponse as GetUrlResponse, type index_d$1_GetUrlResponseNonNullableFields as GetUrlResponseNonNullableFields, type index_d$1_IdentificationData as IdentificationData, type index_d$1_IdentificationDataIdOneOf as IdentificationDataIdOneOf, index_d$1_InvoiceStatus as InvoiceStatus, type index_d$1_InvoiceStatusUpdate as InvoiceStatusUpdate, type index_d$1_MessageEnvelope as MessageEnvelope, index_d$1_PaymentCycle as PaymentCycle, type index_d$1_PurchasedItem as PurchasedItem, index_d$1_WebhookIdentityType as WebhookIdentityType, index_d$1_getPurchaseHistory as getPurchaseHistory, index_d$1_getUrl as getUrl };
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
type HostModule<T, H extends Host> = {
|
|
2919
|
+
__type: 'host';
|
|
2920
|
+
create(host: H): T;
|
|
2921
|
+
};
|
|
2922
|
+
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
|
|
2923
|
+
type Host<Environment = unknown> = {
|
|
2924
|
+
channel: {
|
|
2925
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
2926
|
+
disconnect: () => void;
|
|
2927
|
+
} | Promise<{
|
|
2928
|
+
disconnect: () => void;
|
|
2929
|
+
}>;
|
|
2930
|
+
};
|
|
2931
|
+
environment?: Environment;
|
|
1612
2932
|
/**
|
|
1613
|
-
*
|
|
1614
|
-
* [ISO 639-1 alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format.
|
|
1615
|
-
*
|
|
1616
|
-
* Default: `"EN"`
|
|
2933
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
1617
2934
|
*/
|
|
1618
|
-
|
|
1619
|
-
/**
|
|
1620
|
-
|
|
2935
|
+
apiBaseUrl?: string;
|
|
2936
|
+
/**
|
|
2937
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
2938
|
+
* like internationalization, billing, etc.
|
|
2939
|
+
*/
|
|
2940
|
+
essentials?: {
|
|
2941
|
+
/**
|
|
2942
|
+
* The language of the currently viewed session
|
|
2943
|
+
*/
|
|
2944
|
+
language?: string;
|
|
2945
|
+
/**
|
|
2946
|
+
* The locale of the currently viewed session
|
|
2947
|
+
*/
|
|
2948
|
+
locale?: string;
|
|
2949
|
+
/**
|
|
2950
|
+
* Any headers that should be passed through to the API requests
|
|
2951
|
+
*/
|
|
2952
|
+
passThroughHeaders?: Record<string, string>;
|
|
2953
|
+
};
|
|
2954
|
+
};
|
|
2955
|
+
|
|
2956
|
+
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
2957
|
+
interface HttpClient {
|
|
2958
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
2959
|
+
fetchWithAuth: typeof fetch;
|
|
2960
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
2961
|
+
getActiveToken?: () => string | undefined;
|
|
2962
|
+
}
|
|
2963
|
+
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
2964
|
+
type HttpResponse<T = any> = {
|
|
2965
|
+
data: T;
|
|
2966
|
+
status: number;
|
|
2967
|
+
statusText: string;
|
|
2968
|
+
headers: any;
|
|
2969
|
+
request?: any;
|
|
2970
|
+
};
|
|
2971
|
+
type RequestOptions<_TResponse = any, Data = any> = {
|
|
2972
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
2973
|
+
url: string;
|
|
2974
|
+
data?: Data;
|
|
2975
|
+
params?: URLSearchParams;
|
|
2976
|
+
} & APIMetadata;
|
|
2977
|
+
type APIMetadata = {
|
|
2978
|
+
methodFqn?: string;
|
|
2979
|
+
entityFqdn?: string;
|
|
2980
|
+
packageName?: string;
|
|
2981
|
+
};
|
|
2982
|
+
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
2983
|
+
type EventDefinition<Payload = unknown, Type extends string = string> = {
|
|
2984
|
+
__type: 'event-definition';
|
|
2985
|
+
type: Type;
|
|
2986
|
+
isDomainEvent?: boolean;
|
|
2987
|
+
transformations?: (envelope: unknown) => Payload;
|
|
2988
|
+
__payload: Payload;
|
|
2989
|
+
};
|
|
2990
|
+
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
|
|
2991
|
+
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
|
|
2992
|
+
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
|
|
2993
|
+
|
|
2994
|
+
type ServicePluginMethodInput = {
|
|
2995
|
+
request: any;
|
|
2996
|
+
metadata: any;
|
|
2997
|
+
};
|
|
2998
|
+
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
|
|
2999
|
+
type ServicePluginMethodMetadata = {
|
|
3000
|
+
name: string;
|
|
3001
|
+
primaryHttpMappingPath: string;
|
|
3002
|
+
transformations: {
|
|
3003
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
|
|
3004
|
+
toREST: (...args: unknown[]) => unknown;
|
|
3005
|
+
};
|
|
3006
|
+
};
|
|
3007
|
+
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
|
|
3008
|
+
__type: 'service-plugin-definition';
|
|
3009
|
+
componentType: string;
|
|
3010
|
+
methods: ServicePluginMethodMetadata[];
|
|
3011
|
+
__contract: Contract;
|
|
3012
|
+
};
|
|
3013
|
+
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
|
|
3014
|
+
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
|
|
3015
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
|
|
3016
|
+
|
|
3017
|
+
type RequestContext = {
|
|
3018
|
+
isSSR: boolean;
|
|
3019
|
+
host: string;
|
|
3020
|
+
protocol?: string;
|
|
3021
|
+
};
|
|
3022
|
+
type ResponseTransformer = (data: any, headers?: any) => any;
|
|
3023
|
+
/**
|
|
3024
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
3025
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
3026
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
3027
|
+
*/
|
|
3028
|
+
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
3029
|
+
type AmbassadorRequestOptions<T = any> = {
|
|
3030
|
+
_?: T;
|
|
3031
|
+
url?: string;
|
|
3032
|
+
method?: Method;
|
|
3033
|
+
params?: any;
|
|
3034
|
+
data?: any;
|
|
3035
|
+
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
3036
|
+
};
|
|
3037
|
+
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
3038
|
+
__isAmbassador: boolean;
|
|
3039
|
+
};
|
|
3040
|
+
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
|
|
3041
|
+
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
3042
|
+
|
|
3043
|
+
declare global {
|
|
3044
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
3045
|
+
interface SymbolConstructor {
|
|
3046
|
+
readonly observable: symbol;
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
declare const emptyObjectSymbol: unique symbol;
|
|
3051
|
+
|
|
3052
|
+
/**
|
|
3053
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
3054
|
+
|
|
3055
|
+
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)).
|
|
3056
|
+
|
|
3057
|
+
@example
|
|
3058
|
+
```
|
|
3059
|
+
import type {EmptyObject} from 'type-fest';
|
|
3060
|
+
|
|
3061
|
+
// The following illustrates the problem with `{}`.
|
|
3062
|
+
const foo1: {} = {}; // Pass
|
|
3063
|
+
const foo2: {} = []; // Pass
|
|
3064
|
+
const foo3: {} = 42; // Pass
|
|
3065
|
+
const foo4: {} = {a: 1}; // Pass
|
|
3066
|
+
|
|
3067
|
+
// With `EmptyObject` only the first case is valid.
|
|
3068
|
+
const bar1: EmptyObject = {}; // Pass
|
|
3069
|
+
const bar2: EmptyObject = 42; // Fail
|
|
3070
|
+
const bar3: EmptyObject = []; // Fail
|
|
3071
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
3072
|
+
```
|
|
3073
|
+
|
|
3074
|
+
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}.
|
|
3075
|
+
|
|
3076
|
+
@category Object
|
|
3077
|
+
*/
|
|
3078
|
+
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
3079
|
+
|
|
3080
|
+
/**
|
|
3081
|
+
Returns a boolean for whether the two given types are equal.
|
|
3082
|
+
|
|
3083
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
3084
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
3085
|
+
|
|
3086
|
+
Use-cases:
|
|
3087
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
3088
|
+
|
|
3089
|
+
@example
|
|
3090
|
+
```
|
|
3091
|
+
import type {IsEqual} from 'type-fest';
|
|
3092
|
+
|
|
3093
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
3094
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
3095
|
+
type Includes<Value extends readonly any[], Item> =
|
|
3096
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
3097
|
+
? IsEqual<Value[0], Item> extends true
|
|
3098
|
+
? true
|
|
3099
|
+
: Includes<rest, Item>
|
|
3100
|
+
: false;
|
|
3101
|
+
```
|
|
3102
|
+
|
|
3103
|
+
@category Type Guard
|
|
3104
|
+
@category Utilities
|
|
3105
|
+
*/
|
|
3106
|
+
type IsEqual<A, B> =
|
|
3107
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
3108
|
+
(<G>() => G extends B ? 1 : 2)
|
|
3109
|
+
? true
|
|
3110
|
+
: false;
|
|
3111
|
+
|
|
3112
|
+
/**
|
|
3113
|
+
Filter out keys from an object.
|
|
3114
|
+
|
|
3115
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
3116
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
3117
|
+
Returns `Key` otherwise.
|
|
3118
|
+
|
|
3119
|
+
@example
|
|
3120
|
+
```
|
|
3121
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
3122
|
+
//=> never
|
|
3123
|
+
```
|
|
3124
|
+
|
|
3125
|
+
@example
|
|
3126
|
+
```
|
|
3127
|
+
type Filtered = Filter<'bar', string>;
|
|
3128
|
+
//=> never
|
|
3129
|
+
```
|
|
3130
|
+
|
|
3131
|
+
@example
|
|
3132
|
+
```
|
|
3133
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
3134
|
+
//=> 'bar'
|
|
3135
|
+
```
|
|
3136
|
+
|
|
3137
|
+
@see {Except}
|
|
3138
|
+
*/
|
|
3139
|
+
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
3140
|
+
|
|
3141
|
+
type ExceptOptions = {
|
|
3142
|
+
/**
|
|
3143
|
+
Disallow assigning non-specified properties.
|
|
3144
|
+
|
|
3145
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
3146
|
+
|
|
3147
|
+
@default false
|
|
3148
|
+
*/
|
|
3149
|
+
requireExactProps?: boolean;
|
|
3150
|
+
};
|
|
3151
|
+
|
|
3152
|
+
/**
|
|
3153
|
+
Create a type from an object type without certain keys.
|
|
3154
|
+
|
|
3155
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
3156
|
+
|
|
3157
|
+
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.
|
|
3158
|
+
|
|
3159
|
+
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)).
|
|
3160
|
+
|
|
3161
|
+
@example
|
|
3162
|
+
```
|
|
3163
|
+
import type {Except} from 'type-fest';
|
|
3164
|
+
|
|
3165
|
+
type Foo = {
|
|
3166
|
+
a: number;
|
|
3167
|
+
b: string;
|
|
3168
|
+
};
|
|
3169
|
+
|
|
3170
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
3171
|
+
//=> {b: string}
|
|
3172
|
+
|
|
3173
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
3174
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
3175
|
+
|
|
3176
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
3177
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
3178
|
+
|
|
3179
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
3180
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
3181
|
+
```
|
|
3182
|
+
|
|
3183
|
+
@category Object
|
|
3184
|
+
*/
|
|
3185
|
+
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
|
|
3186
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
3187
|
+
} & (Options['requireExactProps'] extends true
|
|
3188
|
+
? Partial<Record<KeysType, never>>
|
|
3189
|
+
: {});
|
|
3190
|
+
|
|
3191
|
+
/**
|
|
3192
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
3193
|
+
|
|
3194
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
3195
|
+
|
|
3196
|
+
@example
|
|
3197
|
+
```
|
|
3198
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
3199
|
+
|
|
3200
|
+
interface Example {
|
|
3201
|
+
a: string;
|
|
3202
|
+
b: string | number;
|
|
3203
|
+
c?: string;
|
|
3204
|
+
d: {};
|
|
1621
3205
|
}
|
|
1622
3206
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
3207
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
3208
|
+
//=> 'a'
|
|
3209
|
+
```
|
|
3210
|
+
|
|
3211
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
3212
|
+
|
|
3213
|
+
@example
|
|
3214
|
+
```
|
|
3215
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
3216
|
+
|
|
3217
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
3218
|
+
//=> 'a' | 'c'
|
|
3219
|
+
```
|
|
3220
|
+
|
|
3221
|
+
@category Object
|
|
3222
|
+
*/
|
|
3223
|
+
type ConditionalKeys<Base, Condition> = NonNullable<
|
|
3224
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
3225
|
+
{
|
|
3226
|
+
// Map through all the keys of the given base type.
|
|
3227
|
+
[Key in keyof Base]:
|
|
3228
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
3229
|
+
Base[Key] extends Condition
|
|
3230
|
+
// Retain this key since the condition passes.
|
|
3231
|
+
? Key
|
|
3232
|
+
// Discard this key since the condition fails.
|
|
3233
|
+
: never;
|
|
3234
|
+
|
|
3235
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
3236
|
+
}[keyof Base]
|
|
3237
|
+
>;
|
|
3238
|
+
|
|
3239
|
+
/**
|
|
3240
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
3241
|
+
|
|
3242
|
+
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.
|
|
3243
|
+
|
|
3244
|
+
@example
|
|
3245
|
+
```
|
|
3246
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
3247
|
+
|
|
3248
|
+
class Awesome {
|
|
3249
|
+
name: string;
|
|
3250
|
+
successes: number;
|
|
3251
|
+
failures: bigint;
|
|
3252
|
+
|
|
3253
|
+
run() {}
|
|
1640
3254
|
}
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
3255
|
+
|
|
3256
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
3257
|
+
//=> {run: () => void}
|
|
3258
|
+
```
|
|
3259
|
+
|
|
3260
|
+
@example
|
|
3261
|
+
```
|
|
3262
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
3263
|
+
|
|
3264
|
+
interface Example {
|
|
3265
|
+
a: string;
|
|
3266
|
+
b: string | number;
|
|
3267
|
+
c: () => void;
|
|
3268
|
+
d: {};
|
|
1653
3269
|
}
|
|
1654
3270
|
|
|
1655
|
-
|
|
1656
|
-
|
|
3271
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
3272
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
3273
|
+
```
|
|
1657
3274
|
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
type
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
type
|
|
1669
|
-
|
|
1670
|
-
type
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
type
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
3275
|
+
@category Object
|
|
3276
|
+
*/
|
|
3277
|
+
type ConditionalExcept<Base, Condition> = Except<
|
|
3278
|
+
Base,
|
|
3279
|
+
ConditionalKeys<Base, Condition>
|
|
3280
|
+
>;
|
|
3281
|
+
|
|
3282
|
+
/**
|
|
3283
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
3284
|
+
* can either be a REST module or a host module.
|
|
3285
|
+
* This type is recursive, so it can describe nested modules.
|
|
3286
|
+
*/
|
|
3287
|
+
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
|
|
3288
|
+
[key: string]: Descriptors | PublicMetadata | any;
|
|
3289
|
+
};
|
|
3290
|
+
/**
|
|
3291
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
3292
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
3293
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
3294
|
+
* do not match the given host (as they will not work with the given host).
|
|
3295
|
+
*/
|
|
3296
|
+
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
|
|
3297
|
+
done: T;
|
|
3298
|
+
recurse: T extends {
|
|
3299
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE;
|
|
3300
|
+
} ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
|
|
3301
|
+
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
|
|
3302
|
+
-1,
|
|
3303
|
+
0,
|
|
3304
|
+
1,
|
|
3305
|
+
2,
|
|
3306
|
+
3,
|
|
3307
|
+
4,
|
|
3308
|
+
5
|
|
3309
|
+
][Depth]> : never;
|
|
3310
|
+
}, EmptyObject>;
|
|
3311
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
3312
|
+
type PublicMetadata = {
|
|
3313
|
+
PACKAGE_NAME?: string;
|
|
3314
|
+
};
|
|
3315
|
+
|
|
3316
|
+
declare global {
|
|
3317
|
+
interface ContextualClient {
|
|
3318
|
+
}
|
|
1686
3319
|
}
|
|
3320
|
+
/**
|
|
3321
|
+
* A type used to create concerete types from SDK descriptors in
|
|
3322
|
+
* case a contextual client is available.
|
|
3323
|
+
*/
|
|
3324
|
+
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
3325
|
+
host: Host;
|
|
3326
|
+
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
1687
3327
|
|
|
1688
3328
|
/** Embedded script data */
|
|
1689
3329
|
interface ScriptProperties {
|