@wix/motion 1.0.49 → 1.0.51
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 +1037 -217
- package/type-bundles/index.bundle.d.ts +1037 -217
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
type HostModule<T, H extends Host> = {
|
|
1
|
+
type HostModule$2<T, H extends Host$2> = {
|
|
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$2<T extends HostModule$2<any, any>> = T extends HostModule$2<infer U, any> ? U : never;
|
|
6
|
+
type Host$2<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$2<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$2) => T;
|
|
40
|
+
interface HttpClient$2 {
|
|
41
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$2<TResponse, TData>): Promise<HttpResponse$2<TResponse>>;
|
|
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$2<TResponse = any, TData = any> = (context: any) => RequestOptions$2<TResponse, TData>;
|
|
47
|
+
type HttpResponse$2<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$2<_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$2;
|
|
60
|
+
type APIMetadata$2 = {
|
|
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$2<T extends RESTFunctionDescriptor$2> = T extends RESTFunctionDescriptor$2<infer U> ? U : never;
|
|
66
|
+
type EventDefinition$4<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$4<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$4<Payload, Type>;
|
|
74
|
+
type EventHandler$4<T extends EventDefinition$4> = (payload: T['__payload']) => void | Promise<void>;
|
|
75
|
+
type BuildEventDefinition$4<T extends EventDefinition$4<any, string>> = (handler: EventHandler$4<T>) => void;
|
|
76
76
|
|
|
77
|
-
type ServicePluginMethodInput = {
|
|
77
|
+
type ServicePluginMethodInput$2 = {
|
|
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$2 = Record<string, (payload: ServicePluginMethodInput$2) => unknown | Promise<unknown>>;
|
|
82
|
+
type ServicePluginMethodMetadata$2 = {
|
|
83
83
|
name: string;
|
|
84
84
|
primaryHttpMappingPath: string;
|
|
85
85
|
transformations: {
|
|
86
|
-
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
|
|
86
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$2;
|
|
87
87
|
toREST: (...args: unknown[]) => unknown;
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
|
-
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
|
|
90
|
+
type ServicePluginDefinition$2<Contract extends ServicePluginContract$2> = {
|
|
91
91
|
__type: 'service-plugin-definition';
|
|
92
92
|
componentType: string;
|
|
93
|
-
methods: ServicePluginMethodMetadata[];
|
|
93
|
+
methods: ServicePluginMethodMetadata$2[];
|
|
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$2<Contract extends ServicePluginContract$2>(componentType: string, methods: ServicePluginMethodMetadata$2[]): ServicePluginDefinition$2<Contract>;
|
|
97
|
+
type BuildServicePluginDefinition$2<T extends ServicePluginDefinition$2<any>> = (implementation: T['__contract']) => void;
|
|
98
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$2 = "wix_spi_error";
|
|
99
99
|
|
|
100
|
-
type RequestContext = {
|
|
100
|
+
type RequestContext$2 = {
|
|
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$2 = (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$2 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
112
|
+
type AmbassadorRequestOptions$2<T = any> = {
|
|
113
113
|
_?: T;
|
|
114
114
|
url?: string;
|
|
115
|
-
method?: Method;
|
|
115
|
+
method?: Method$2;
|
|
116
116
|
params?: any;
|
|
117
117
|
data?: any;
|
|
118
|
-
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
118
|
+
transformResponse?: ResponseTransformer$2 | ResponseTransformer$2[];
|
|
119
119
|
};
|
|
120
|
-
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
120
|
+
type AmbassadorFactory$2<Request, Response> = (payload: Request) => ((context: RequestContext$2) => AmbassadorRequestOptions$2<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$2<Request = any, Response = any> = AmbassadorFactory$2<Request, Response>;
|
|
124
|
+
type BuildAmbassadorFunction$2<T extends AmbassadorFunctionDescriptor$2> = T extends AmbassadorFunctionDescriptor$2<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
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$2: 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$2 = {[emptyObjectSymbol$2]?: 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$2<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$2<KeyType, ExcludeType> = IsEqual$2<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
223
223
|
|
|
224
|
-
type ExceptOptions = {
|
|
224
|
+
type ExceptOptions$2 = {
|
|
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$2<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$2 = {requireExactProps: false}> = {
|
|
269
|
+
[KeyType in keyof ObjectType as Filter$2<KeyType, KeysType>]: ObjectType[KeyType];
|
|
270
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$2<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$2<Base, Condition> = Except$2<
|
|
361
361
|
Base,
|
|
362
|
-
ConditionalKeys<Base, Condition>
|
|
362
|
+
ConditionalKeys$2<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$2 = RESTFunctionDescriptor$2 | AmbassadorFunctionDescriptor$2 | HostModule$2<any, any> | EventDefinition$4<any> | ServicePluginDefinition$2<any> | {
|
|
371
|
+
[key: string]: Descriptors$2 | PublicMetadata$2 | 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$2<T extends Descriptors$2, H extends Host$2<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$2;
|
|
383
|
+
} ? never : T extends AmbassadorFunctionDescriptor$2 ? BuildAmbassadorFunction$2<T> : T extends RESTFunctionDescriptor$2 ? BuildRESTFunction$2<T> : T extends EventDefinition$4<any> ? BuildEventDefinition$4<T> : T extends ServicePluginDefinition$2<any> ? BuildServicePluginDefinition$2<T> : T extends HostModule$2<any, any> ? HostModuleAPI$2<T> : ConditionalExcept$2<{
|
|
384
|
+
[Key in keyof T]: T[Key] extends Descriptors$2 ? BuildDescriptors$2<T[Key], H, [
|
|
385
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$2>;
|
|
394
394
|
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
395
|
-
type PublicMetadata = {
|
|
395
|
+
type PublicMetadata$2 = {
|
|
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$2<T extends Descriptors$2> = globalThis.ContextualClient extends {
|
|
408
|
+
host: Host$2;
|
|
409
|
+
} ? BuildDescriptors$2<T, globalThis.ContextualClient['host']> : T;
|
|
410
410
|
|
|
411
411
|
interface AlarmMessage {
|
|
412
412
|
_id?: string;
|
|
@@ -626,34 +626,34 @@ interface UpdateAlarm {
|
|
|
626
626
|
seconds?: number;
|
|
627
627
|
}
|
|
628
628
|
|
|
629
|
-
declare function alarm$1(httpClient: HttpClient): AlarmSignature;
|
|
629
|
+
declare function alarm$1(httpClient: HttpClient$2): AlarmSignature;
|
|
630
630
|
interface AlarmSignature {
|
|
631
631
|
/**
|
|
632
632
|
* sets up an alarm after {seconds}
|
|
633
633
|
*/
|
|
634
634
|
(seconds: number, options?: AlarmOptions | undefined): Promise<AlarmResponse>;
|
|
635
635
|
}
|
|
636
|
-
declare function updateAlarm$1(httpClient: HttpClient): UpdateAlarmSignature;
|
|
636
|
+
declare function updateAlarm$1(httpClient: HttpClient$2): UpdateAlarmSignature;
|
|
637
637
|
interface UpdateAlarmSignature {
|
|
638
638
|
/**
|
|
639
639
|
* sets up an existing alarm with id {id}
|
|
640
640
|
*/
|
|
641
641
|
(_id: string, alarm: UpdateAlarm): Promise<UpdateAlarmResponse & UpdateAlarmResponseNonNullableFields>;
|
|
642
642
|
}
|
|
643
|
-
declare const onAlarmTriggered$1: EventDefinition$
|
|
644
|
-
declare const onAlarmSnoozed$1: EventDefinition$
|
|
645
|
-
declare const onAlarmDeleted$1: EventDefinition$
|
|
643
|
+
declare const onAlarmTriggered$1: EventDefinition$4<AlarmTriggeredEnvelope, "wix.alarm.v1.alarm_alarm_triggered">;
|
|
644
|
+
declare const onAlarmSnoozed$1: EventDefinition$4<AlarmSnoozedEnvelope, "wix.alarm.v1.alarm_alarm_snoozed">;
|
|
645
|
+
declare const onAlarmDeleted$1: EventDefinition$4<AlarmDeletedEnvelope, "wix.alarm.v1.alarm_alarm_deleted">;
|
|
646
646
|
|
|
647
|
-
type EventDefinition$
|
|
647
|
+
type EventDefinition$3<Payload = unknown, Type extends string = string> = {
|
|
648
648
|
__type: 'event-definition';
|
|
649
649
|
type: Type;
|
|
650
650
|
isDomainEvent?: boolean;
|
|
651
651
|
transformations?: (envelope: unknown) => Payload;
|
|
652
652
|
__payload: Payload;
|
|
653
653
|
};
|
|
654
|
-
declare function EventDefinition$
|
|
655
|
-
type EventHandler$
|
|
656
|
-
type BuildEventDefinition$
|
|
654
|
+
declare function EventDefinition$3<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$3<Payload, Type>;
|
|
655
|
+
type EventHandler$3<T extends EventDefinition$3> = (payload: T['__payload']) => void | Promise<void>;
|
|
656
|
+
type BuildEventDefinition$3<T extends EventDefinition$3<any, string>> = (handler: EventHandler$3<T>) => void;
|
|
657
657
|
|
|
658
658
|
declare global {
|
|
659
659
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -662,10 +662,10 @@ declare global {
|
|
|
662
662
|
}
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
-
declare function createEventModule$1<T extends EventDefinition$
|
|
665
|
+
declare function createEventModule$1<T extends EventDefinition$3<any, string>>(eventDefinition: T): BuildEventDefinition$3<T> & T;
|
|
666
666
|
|
|
667
|
-
declare const alarm: MaybeContext<BuildRESTFunction<typeof alarm$1> & typeof alarm$1>;
|
|
668
|
-
declare const updateAlarm: MaybeContext<BuildRESTFunction<typeof updateAlarm$1> & typeof updateAlarm$1>;
|
|
667
|
+
declare const alarm: MaybeContext$2<BuildRESTFunction$2<typeof alarm$1> & typeof alarm$1>;
|
|
668
|
+
declare const updateAlarm: MaybeContext$2<BuildRESTFunction$2<typeof updateAlarm$1> & typeof updateAlarm$1>;
|
|
669
669
|
|
|
670
670
|
type _publicOnAlarmTriggeredType = typeof onAlarmTriggered$1;
|
|
671
671
|
/**
|
|
@@ -713,116 +713,526 @@ declare namespace index_d$2 {
|
|
|
713
713
|
export { type ActionEvent$2 as ActionEvent, type index_d$2_AlarmDeleted as AlarmDeleted, type index_d$2_AlarmDeletedEnvelope as AlarmDeletedEnvelope, type index_d$2_AlarmMessage as AlarmMessage, type index_d$2_AlarmOptions as AlarmOptions, type index_d$2_AlarmRequest as AlarmRequest, type index_d$2_AlarmRequestRequiredFields as AlarmRequestRequiredFields, type index_d$2_AlarmResponse as AlarmResponse, type index_d$2_AlarmSnoozed as AlarmSnoozed, type index_d$2_AlarmSnoozedEnvelope as AlarmSnoozedEnvelope, type index_d$2_AlarmTriggered as AlarmTriggered, type index_d$2_AlarmTriggeredEnvelope as AlarmTriggeredEnvelope, type BaseEventMetadata$1 as BaseEventMetadata, type DomainEvent$2 as DomainEvent, type DomainEventBodyOneOf$2 as DomainEventBodyOneOf, type EntityCreatedEvent$2 as EntityCreatedEvent, type EntityDeletedEvent$2 as EntityDeletedEvent, type EntityUpdatedEvent$2 as EntityUpdatedEvent, type EventMetadata$1 as EventMetadata, type IdentificationData$2 as IdentificationData, type IdentificationDataIdOneOf$2 as IdentificationDataIdOneOf, type MessageEnvelope$2 as MessageEnvelope, type RestoreInfo$2 as RestoreInfo, type index_d$2_UpdateAlarm as UpdateAlarm, type index_d$2_UpdateAlarmRequest as UpdateAlarmRequest, type index_d$2_UpdateAlarmRequestRequiredFields as UpdateAlarmRequestRequiredFields, type index_d$2_UpdateAlarmResponse as UpdateAlarmResponse, type index_d$2_UpdateAlarmResponseNonNullableFields as UpdateAlarmResponseNonNullableFields, WebhookIdentityType$2 as WebhookIdentityType, type index_d$2__publicOnAlarmDeletedType as _publicOnAlarmDeletedType, type index_d$2__publicOnAlarmSnoozedType as _publicOnAlarmSnoozedType, type index_d$2__publicOnAlarmTriggeredType as _publicOnAlarmTriggeredType, index_d$2_alarm as alarm, index_d$2_onAlarmDeleted as onAlarmDeleted, index_d$2_onAlarmSnoozed as onAlarmSnoozed, index_d$2_onAlarmTriggered as onAlarmTriggered, onAlarmDeleted$1 as publicOnAlarmDeleted, onAlarmSnoozed$1 as publicOnAlarmSnoozed, onAlarmTriggered$1 as publicOnAlarmTriggered, index_d$2_updateAlarm as updateAlarm };
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
interface EchoResponse {
|
|
731
|
-
/** message result as EchoMessage */
|
|
732
|
-
echoMessage?: EchoMessage;
|
|
733
|
-
/** messge reseult as string */
|
|
734
|
-
message?: string;
|
|
735
|
-
}
|
|
736
|
-
interface Dispatched {
|
|
737
|
-
/** the message someone says */
|
|
738
|
-
echo?: EchoMessage;
|
|
739
|
-
}
|
|
740
|
-
interface DomainEvent$1 extends DomainEventBodyOneOf$1 {
|
|
741
|
-
createdEvent?: EntityCreatedEvent$1;
|
|
742
|
-
updatedEvent?: EntityUpdatedEvent$1;
|
|
743
|
-
deletedEvent?: EntityDeletedEvent$1;
|
|
744
|
-
actionEvent?: ActionEvent$1;
|
|
745
|
-
/**
|
|
746
|
-
* Unique event ID.
|
|
747
|
-
* Allows clients to ignore duplicate webhooks.
|
|
748
|
-
*/
|
|
749
|
-
_id?: string;
|
|
750
|
-
/**
|
|
751
|
-
* Assumes actions are also always typed to an entity_type
|
|
752
|
-
* Example: wix.stores.catalog.product, wix.bookings.session, wix.payments.transaction
|
|
753
|
-
*/
|
|
754
|
-
entityFqdn?: string;
|
|
755
|
-
/**
|
|
756
|
-
* This is top level to ease client code dispatching of messages (switch on entity_fqdn+slug)
|
|
757
|
-
* This is although the created/updated/deleted notion is duplication of the oneof types
|
|
758
|
-
* Example: created/updated/deleted/started/completed/email_opened
|
|
759
|
-
*/
|
|
760
|
-
slug?: string;
|
|
761
|
-
/** ID of the entity associated with the event. */
|
|
762
|
-
entityId?: string;
|
|
763
|
-
/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
|
|
764
|
-
eventTime?: Date;
|
|
765
|
-
/**
|
|
766
|
-
* Whether the event was triggered as a result of a privacy regulation application
|
|
767
|
-
* (for example, GDPR).
|
|
768
|
-
*/
|
|
769
|
-
triggeredByAnonymizeRequest?: boolean | null;
|
|
770
|
-
/** If present, indicates the action that triggered the event. */
|
|
771
|
-
originatedFrom?: string | null;
|
|
716
|
+
type HostModule$1<T, H extends Host$1> = {
|
|
717
|
+
__type: 'host';
|
|
718
|
+
create(host: H): T;
|
|
719
|
+
};
|
|
720
|
+
type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
|
|
721
|
+
type Host$1<Environment = unknown> = {
|
|
722
|
+
channel: {
|
|
723
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
724
|
+
disconnect: () => void;
|
|
725
|
+
} | Promise<{
|
|
726
|
+
disconnect: () => void;
|
|
727
|
+
}>;
|
|
728
|
+
};
|
|
729
|
+
environment?: Environment;
|
|
772
730
|
/**
|
|
773
|
-
*
|
|
774
|
-
* For example, given that some entity was updated at 16:00 and than again at 16:01,
|
|
775
|
-
* it is guaranteed that the sequence number of the second update is strictly higher than the first.
|
|
776
|
-
* As the consumer, you can use this value to ensure that you handle messages in the correct order.
|
|
777
|
-
* To do so, you will need to persist this number on your end, and compare the sequence number from the
|
|
778
|
-
* message against the one you have stored. Given that the stored number is higher, you should ignore the message.
|
|
731
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
779
732
|
*/
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
/** @oneof */
|
|
783
|
-
interface DomainEventBodyOneOf$1 {
|
|
784
|
-
createdEvent?: EntityCreatedEvent$1;
|
|
785
|
-
updatedEvent?: EntityUpdatedEvent$1;
|
|
786
|
-
deletedEvent?: EntityDeletedEvent$1;
|
|
787
|
-
actionEvent?: ActionEvent$1;
|
|
788
|
-
}
|
|
789
|
-
interface EntityCreatedEvent$1 {
|
|
790
|
-
entity?: string;
|
|
791
|
-
}
|
|
792
|
-
interface RestoreInfo$1 {
|
|
793
|
-
deletedDate?: Date;
|
|
794
|
-
}
|
|
795
|
-
interface EntityUpdatedEvent$1 {
|
|
733
|
+
apiBaseUrl?: string;
|
|
796
734
|
/**
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
* We don't want to impose this on all developers and so we leave this traversal to the notification recipients which need it.
|
|
735
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
736
|
+
* like internationalization, billing, etc.
|
|
800
737
|
*/
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
738
|
+
essentials?: {
|
|
739
|
+
/**
|
|
740
|
+
* The language of the currently viewed session
|
|
741
|
+
*/
|
|
742
|
+
language?: string;
|
|
743
|
+
/**
|
|
744
|
+
* The locale of the currently viewed session
|
|
745
|
+
*/
|
|
746
|
+
locale?: string;
|
|
747
|
+
/**
|
|
748
|
+
* Any headers that should be passed through to the API requests
|
|
749
|
+
*/
|
|
750
|
+
passThroughHeaders?: Record<string, string>;
|
|
751
|
+
};
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
|
|
755
|
+
interface HttpClient$1 {
|
|
756
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
|
|
757
|
+
fetchWithAuth: typeof fetch;
|
|
758
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
759
|
+
getActiveToken?: () => string | undefined;
|
|
809
760
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
761
|
+
type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
|
|
762
|
+
type HttpResponse$1<T = any> = {
|
|
763
|
+
data: T;
|
|
764
|
+
status: number;
|
|
765
|
+
statusText: string;
|
|
766
|
+
headers: any;
|
|
767
|
+
request?: any;
|
|
768
|
+
};
|
|
769
|
+
type RequestOptions$1<_TResponse = any, Data = any> = {
|
|
770
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
771
|
+
url: string;
|
|
772
|
+
data?: Data;
|
|
773
|
+
params?: URLSearchParams;
|
|
774
|
+
} & APIMetadata$1;
|
|
775
|
+
type APIMetadata$1 = {
|
|
776
|
+
methodFqn?: string;
|
|
777
|
+
entityFqdn?: string;
|
|
778
|
+
packageName?: string;
|
|
779
|
+
};
|
|
780
|
+
type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
|
|
781
|
+
type EventDefinition$2<Payload = unknown, Type extends string = string> = {
|
|
782
|
+
__type: 'event-definition';
|
|
783
|
+
type: Type;
|
|
784
|
+
isDomainEvent?: boolean;
|
|
785
|
+
transformations?: (envelope: unknown) => Payload;
|
|
786
|
+
__payload: Payload;
|
|
787
|
+
};
|
|
788
|
+
declare function EventDefinition$2<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$2<Payload, Type>;
|
|
789
|
+
type EventHandler$2<T extends EventDefinition$2> = (payload: T['__payload']) => void | Promise<void>;
|
|
790
|
+
type BuildEventDefinition$2<T extends EventDefinition$2<any, string>> = (handler: EventHandler$2<T>) => void;
|
|
791
|
+
|
|
792
|
+
type ServicePluginMethodInput$1 = {
|
|
793
|
+
request: any;
|
|
794
|
+
metadata: any;
|
|
795
|
+
};
|
|
796
|
+
type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
|
|
797
|
+
type ServicePluginMethodMetadata$1 = {
|
|
798
|
+
name: string;
|
|
799
|
+
primaryHttpMappingPath: string;
|
|
800
|
+
transformations: {
|
|
801
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
|
|
802
|
+
toREST: (...args: unknown[]) => unknown;
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
|
|
806
|
+
__type: 'service-plugin-definition';
|
|
807
|
+
componentType: string;
|
|
808
|
+
methods: ServicePluginMethodMetadata$1[];
|
|
809
|
+
__contract: Contract;
|
|
810
|
+
};
|
|
811
|
+
declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
|
|
812
|
+
type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
|
|
813
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
|
|
814
|
+
|
|
815
|
+
type RequestContext$1 = {
|
|
816
|
+
isSSR: boolean;
|
|
817
|
+
host: string;
|
|
818
|
+
protocol?: string;
|
|
819
|
+
};
|
|
820
|
+
type ResponseTransformer$1 = (data: any, headers?: any) => any;
|
|
821
|
+
/**
|
|
822
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
823
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
824
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
825
|
+
*/
|
|
826
|
+
type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
827
|
+
type AmbassadorRequestOptions$1<T = any> = {
|
|
828
|
+
_?: T;
|
|
829
|
+
url?: string;
|
|
830
|
+
method?: Method$1;
|
|
831
|
+
params?: any;
|
|
832
|
+
data?: any;
|
|
833
|
+
transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
|
|
834
|
+
};
|
|
835
|
+
type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
|
|
836
|
+
__isAmbassador: boolean;
|
|
837
|
+
};
|
|
838
|
+
type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
|
|
839
|
+
type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
840
|
+
|
|
841
|
+
declare global {
|
|
842
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
843
|
+
interface SymbolConstructor {
|
|
844
|
+
readonly observable: symbol;
|
|
845
|
+
}
|
|
819
846
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
847
|
+
|
|
848
|
+
declare const emptyObjectSymbol$1: unique symbol;
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
852
|
+
|
|
853
|
+
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
|
|
854
|
+
|
|
855
|
+
@example
|
|
856
|
+
```
|
|
857
|
+
import type {EmptyObject} from 'type-fest';
|
|
858
|
+
|
|
859
|
+
// The following illustrates the problem with `{}`.
|
|
860
|
+
const foo1: {} = {}; // Pass
|
|
861
|
+
const foo2: {} = []; // Pass
|
|
862
|
+
const foo3: {} = 42; // Pass
|
|
863
|
+
const foo4: {} = {a: 1}; // Pass
|
|
864
|
+
|
|
865
|
+
// With `EmptyObject` only the first case is valid.
|
|
866
|
+
const bar1: EmptyObject = {}; // Pass
|
|
867
|
+
const bar2: EmptyObject = 42; // Fail
|
|
868
|
+
const bar3: EmptyObject = []; // Fail
|
|
869
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
|
|
873
|
+
|
|
874
|
+
@category Object
|
|
875
|
+
*/
|
|
876
|
+
type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
Returns a boolean for whether the two given types are equal.
|
|
880
|
+
|
|
881
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
882
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
883
|
+
|
|
884
|
+
Use-cases:
|
|
885
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
886
|
+
|
|
887
|
+
@example
|
|
888
|
+
```
|
|
889
|
+
import type {IsEqual} from 'type-fest';
|
|
890
|
+
|
|
891
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
892
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
893
|
+
type Includes<Value extends readonly any[], Item> =
|
|
894
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
895
|
+
? IsEqual<Value[0], Item> extends true
|
|
896
|
+
? true
|
|
897
|
+
: Includes<rest, Item>
|
|
898
|
+
: false;
|
|
899
|
+
```
|
|
900
|
+
|
|
901
|
+
@category Type Guard
|
|
902
|
+
@category Utilities
|
|
903
|
+
*/
|
|
904
|
+
type IsEqual$1<A, B> =
|
|
905
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
906
|
+
(<G>() => G extends B ? 1 : 2)
|
|
907
|
+
? true
|
|
908
|
+
: false;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
Filter out keys from an object.
|
|
912
|
+
|
|
913
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
914
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
915
|
+
Returns `Key` otherwise.
|
|
916
|
+
|
|
917
|
+
@example
|
|
918
|
+
```
|
|
919
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
920
|
+
//=> never
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
@example
|
|
924
|
+
```
|
|
925
|
+
type Filtered = Filter<'bar', string>;
|
|
926
|
+
//=> never
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
@example
|
|
930
|
+
```
|
|
931
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
932
|
+
//=> 'bar'
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
@see {Except}
|
|
936
|
+
*/
|
|
937
|
+
type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
938
|
+
|
|
939
|
+
type ExceptOptions$1 = {
|
|
940
|
+
/**
|
|
941
|
+
Disallow assigning non-specified properties.
|
|
942
|
+
|
|
943
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
944
|
+
|
|
945
|
+
@default false
|
|
946
|
+
*/
|
|
947
|
+
requireExactProps?: boolean;
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
Create a type from an object type without certain keys.
|
|
952
|
+
|
|
953
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
954
|
+
|
|
955
|
+
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
956
|
+
|
|
957
|
+
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
958
|
+
|
|
959
|
+
@example
|
|
960
|
+
```
|
|
961
|
+
import type {Except} from 'type-fest';
|
|
962
|
+
|
|
963
|
+
type Foo = {
|
|
964
|
+
a: number;
|
|
965
|
+
b: string;
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
969
|
+
//=> {b: string}
|
|
970
|
+
|
|
971
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
972
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
973
|
+
|
|
974
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
975
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
976
|
+
|
|
977
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
978
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
979
|
+
```
|
|
980
|
+
|
|
981
|
+
@category Object
|
|
982
|
+
*/
|
|
983
|
+
type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
|
|
984
|
+
[KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
|
|
985
|
+
} & (Options['requireExactProps'] extends true
|
|
986
|
+
? Partial<Record<KeysType, never>>
|
|
987
|
+
: {});
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
991
|
+
|
|
992
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
993
|
+
|
|
994
|
+
@example
|
|
995
|
+
```
|
|
996
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
997
|
+
|
|
998
|
+
interface Example {
|
|
999
|
+
a: string;
|
|
1000
|
+
b: string | number;
|
|
1001
|
+
c?: string;
|
|
1002
|
+
d: {};
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
1006
|
+
//=> 'a'
|
|
1007
|
+
```
|
|
1008
|
+
|
|
1009
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
1010
|
+
|
|
1011
|
+
@example
|
|
1012
|
+
```
|
|
1013
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1014
|
+
|
|
1015
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
1016
|
+
//=> 'a' | 'c'
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
@category Object
|
|
1020
|
+
*/
|
|
1021
|
+
type ConditionalKeys$1<Base, Condition> = NonNullable<
|
|
1022
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
1023
|
+
{
|
|
1024
|
+
// Map through all the keys of the given base type.
|
|
1025
|
+
[Key in keyof Base]:
|
|
1026
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
1027
|
+
Base[Key] extends Condition
|
|
1028
|
+
// Retain this key since the condition passes.
|
|
1029
|
+
? Key
|
|
1030
|
+
// Discard this key since the condition fails.
|
|
1031
|
+
: never;
|
|
1032
|
+
|
|
1033
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
1034
|
+
}[keyof Base]
|
|
1035
|
+
>;
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
1039
|
+
|
|
1040
|
+
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
|
|
1041
|
+
|
|
1042
|
+
@example
|
|
1043
|
+
```
|
|
1044
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
1045
|
+
|
|
1046
|
+
class Awesome {
|
|
1047
|
+
name: string;
|
|
1048
|
+
successes: number;
|
|
1049
|
+
failures: bigint;
|
|
1050
|
+
|
|
1051
|
+
run() {}
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
1055
|
+
//=> {run: () => void}
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
@example
|
|
1059
|
+
```
|
|
1060
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
1061
|
+
|
|
1062
|
+
interface Example {
|
|
1063
|
+
a: string;
|
|
1064
|
+
b: string | number;
|
|
1065
|
+
c: () => void;
|
|
1066
|
+
d: {};
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
1070
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
1071
|
+
```
|
|
1072
|
+
|
|
1073
|
+
@category Object
|
|
1074
|
+
*/
|
|
1075
|
+
type ConditionalExcept$1<Base, Condition> = Except$1<
|
|
1076
|
+
Base,
|
|
1077
|
+
ConditionalKeys$1<Base, Condition>
|
|
1078
|
+
>;
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
1082
|
+
* can either be a REST module or a host module.
|
|
1083
|
+
* This type is recursive, so it can describe nested modules.
|
|
1084
|
+
*/
|
|
1085
|
+
type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$2<any> | ServicePluginDefinition$1<any> | {
|
|
1086
|
+
[key: string]: Descriptors$1 | PublicMetadata$1 | any;
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
1090
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
1091
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
1092
|
+
* do not match the given host (as they will not work with the given host).
|
|
1093
|
+
*/
|
|
1094
|
+
type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
|
|
1095
|
+
done: T;
|
|
1096
|
+
recurse: T extends {
|
|
1097
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
|
|
1098
|
+
} ? never : T extends AmbassadorFunctionDescriptor$1 ? BuildAmbassadorFunction$1<T> : T extends RESTFunctionDescriptor$1 ? BuildRESTFunction$1<T> : T extends EventDefinition$2<any> ? BuildEventDefinition$2<T> : T extends ServicePluginDefinition$1<any> ? BuildServicePluginDefinition$1<T> : T extends HostModule$1<any, any> ? HostModuleAPI$1<T> : ConditionalExcept$1<{
|
|
1099
|
+
[Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
|
|
1100
|
+
-1,
|
|
1101
|
+
0,
|
|
1102
|
+
1,
|
|
1103
|
+
2,
|
|
1104
|
+
3,
|
|
1105
|
+
4,
|
|
1106
|
+
5
|
|
1107
|
+
][Depth]> : never;
|
|
1108
|
+
}, EmptyObject$1>;
|
|
1109
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
1110
|
+
type PublicMetadata$1 = {
|
|
1111
|
+
PACKAGE_NAME?: string;
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
declare global {
|
|
1115
|
+
interface ContextualClient {
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* A type used to create concerete types from SDK descriptors in
|
|
1120
|
+
* case a contextual client is available.
|
|
1121
|
+
*/
|
|
1122
|
+
type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
|
|
1123
|
+
host: Host$1;
|
|
1124
|
+
} ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
|
|
1125
|
+
|
|
1126
|
+
interface MessageItem {
|
|
1127
|
+
/** inner_message comment from EchoMessage proto def */
|
|
1128
|
+
innerMessage?: string;
|
|
1129
|
+
}
|
|
1130
|
+
interface EchoRequest {
|
|
1131
|
+
/** 1st part of the message */
|
|
1132
|
+
arg1: string;
|
|
1133
|
+
/** 2nd part of the message */
|
|
1134
|
+
arg2?: string;
|
|
1135
|
+
/** this field test translatable annotation */
|
|
1136
|
+
titleField?: string;
|
|
1137
|
+
someInt32?: number;
|
|
1138
|
+
someDate?: Date;
|
|
1139
|
+
}
|
|
1140
|
+
interface EchoResponse {
|
|
1141
|
+
/** message result as EchoMessage */
|
|
1142
|
+
echoMessage?: EchoMessage;
|
|
1143
|
+
/** messge reseult as string */
|
|
1144
|
+
message?: string;
|
|
1145
|
+
}
|
|
1146
|
+
interface Dispatched {
|
|
1147
|
+
/** the message someone says */
|
|
1148
|
+
echo?: EchoMessage;
|
|
1149
|
+
}
|
|
1150
|
+
interface DomainEvent$1 extends DomainEventBodyOneOf$1 {
|
|
1151
|
+
createdEvent?: EntityCreatedEvent$1;
|
|
1152
|
+
updatedEvent?: EntityUpdatedEvent$1;
|
|
1153
|
+
deletedEvent?: EntityDeletedEvent$1;
|
|
1154
|
+
actionEvent?: ActionEvent$1;
|
|
1155
|
+
/**
|
|
1156
|
+
* Unique event ID.
|
|
1157
|
+
* Allows clients to ignore duplicate webhooks.
|
|
1158
|
+
*/
|
|
1159
|
+
_id?: string;
|
|
1160
|
+
/**
|
|
1161
|
+
* Assumes actions are also always typed to an entity_type
|
|
1162
|
+
* Example: wix.stores.catalog.product, wix.bookings.session, wix.payments.transaction
|
|
1163
|
+
*/
|
|
1164
|
+
entityFqdn?: string;
|
|
1165
|
+
/**
|
|
1166
|
+
* This is top level to ease client code dispatching of messages (switch on entity_fqdn+slug)
|
|
1167
|
+
* This is although the created/updated/deleted notion is duplication of the oneof types
|
|
1168
|
+
* Example: created/updated/deleted/started/completed/email_opened
|
|
1169
|
+
*/
|
|
1170
|
+
slug?: string;
|
|
1171
|
+
/** ID of the entity associated with the event. */
|
|
1172
|
+
entityId?: string;
|
|
1173
|
+
/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
|
|
1174
|
+
eventTime?: Date;
|
|
1175
|
+
/**
|
|
1176
|
+
* Whether the event was triggered as a result of a privacy regulation application
|
|
1177
|
+
* (for example, GDPR).
|
|
1178
|
+
*/
|
|
1179
|
+
triggeredByAnonymizeRequest?: boolean | null;
|
|
1180
|
+
/** If present, indicates the action that triggered the event. */
|
|
1181
|
+
originatedFrom?: string | null;
|
|
1182
|
+
/**
|
|
1183
|
+
* A sequence number defining the order of updates to the underlying entity.
|
|
1184
|
+
* For example, given that some entity was updated at 16:00 and than again at 16:01,
|
|
1185
|
+
* it is guaranteed that the sequence number of the second update is strictly higher than the first.
|
|
1186
|
+
* As the consumer, you can use this value to ensure that you handle messages in the correct order.
|
|
1187
|
+
* To do so, you will need to persist this number on your end, and compare the sequence number from the
|
|
1188
|
+
* message against the one you have stored. Given that the stored number is higher, you should ignore the message.
|
|
1189
|
+
*/
|
|
1190
|
+
entityEventSequence?: string | null;
|
|
1191
|
+
}
|
|
1192
|
+
/** @oneof */
|
|
1193
|
+
interface DomainEventBodyOneOf$1 {
|
|
1194
|
+
createdEvent?: EntityCreatedEvent$1;
|
|
1195
|
+
updatedEvent?: EntityUpdatedEvent$1;
|
|
1196
|
+
deletedEvent?: EntityDeletedEvent$1;
|
|
1197
|
+
actionEvent?: ActionEvent$1;
|
|
1198
|
+
}
|
|
1199
|
+
interface EntityCreatedEvent$1 {
|
|
1200
|
+
entity?: string;
|
|
1201
|
+
}
|
|
1202
|
+
interface RestoreInfo$1 {
|
|
1203
|
+
deletedDate?: Date;
|
|
1204
|
+
}
|
|
1205
|
+
interface EntityUpdatedEvent$1 {
|
|
1206
|
+
/**
|
|
1207
|
+
* Since platformized APIs only expose PATCH and not PUT we can't assume that the fields sent from the client are the actual diff.
|
|
1208
|
+
* This means that to generate a list of changed fields (as opposed to sent fields) one needs to traverse both objects.
|
|
1209
|
+
* We don't want to impose this on all developers and so we leave this traversal to the notification recipients which need it.
|
|
1210
|
+
*/
|
|
1211
|
+
currentEntity?: string;
|
|
1212
|
+
}
|
|
1213
|
+
interface EntityDeletedEvent$1 {
|
|
1214
|
+
/** Entity that was deleted */
|
|
1215
|
+
deletedEntity?: string | null;
|
|
1216
|
+
}
|
|
1217
|
+
interface ActionEvent$1 {
|
|
1218
|
+
body?: string;
|
|
1219
|
+
}
|
|
1220
|
+
interface MessageEnvelope$1 {
|
|
1221
|
+
/** App instance ID. */
|
|
1222
|
+
instanceId?: string | null;
|
|
1223
|
+
/** Event type. */
|
|
1224
|
+
eventType?: string;
|
|
1225
|
+
/** The identification type and identity data. */
|
|
1226
|
+
identity?: IdentificationData$1;
|
|
1227
|
+
/** Stringify payload. */
|
|
1228
|
+
data?: string;
|
|
1229
|
+
}
|
|
1230
|
+
interface IdentificationData$1 extends IdentificationDataIdOneOf$1 {
|
|
1231
|
+
/** ID of a site visitor that has not logged in to the site. */
|
|
1232
|
+
anonymousVisitorId?: string;
|
|
1233
|
+
/** ID of a site visitor that has logged in to the site. */
|
|
1234
|
+
memberId?: string;
|
|
1235
|
+
/** ID of a Wix user (site owner, contributor, etc.). */
|
|
826
1236
|
wixUserId?: string;
|
|
827
1237
|
/** ID of an app. */
|
|
828
1238
|
appId?: string;
|
|
@@ -925,63 +1335,473 @@ interface EchoOptions {
|
|
|
925
1335
|
someDate?: Date;
|
|
926
1336
|
}
|
|
927
1337
|
|
|
928
|
-
declare function echo$1(httpClient: HttpClient): EchoSignature;
|
|
929
|
-
interface EchoSignature {
|
|
930
|
-
/**
|
|
931
|
-
* echo given arg1 and arg2
|
|
932
|
-
* @param - 1st part of the message
|
|
933
|
-
* @param - modified comment for arg2 el hovav
|
|
934
|
-
* @returns messge reseult as string
|
|
935
|
-
*/
|
|
936
|
-
(arg1: string, options?: EchoOptions | undefined): Promise<string>;
|
|
1338
|
+
declare function echo$1(httpClient: HttpClient$1): EchoSignature;
|
|
1339
|
+
interface EchoSignature {
|
|
1340
|
+
/**
|
|
1341
|
+
* echo given arg1 and arg2
|
|
1342
|
+
* @param - 1st part of the message
|
|
1343
|
+
* @param - modified comment for arg2 el hovav
|
|
1344
|
+
* @returns messge reseult as string
|
|
1345
|
+
*/
|
|
1346
|
+
(arg1: string, options?: EchoOptions | undefined): Promise<string>;
|
|
1347
|
+
}
|
|
1348
|
+
declare const onEchoDispatched$1: EventDefinition$2<EchoDispatchedEnvelope, "wix.metroinspector.v1.echo_dispatched">;
|
|
1349
|
+
|
|
1350
|
+
type EventDefinition$1<Payload = unknown, Type extends string = string> = {
|
|
1351
|
+
__type: 'event-definition';
|
|
1352
|
+
type: Type;
|
|
1353
|
+
isDomainEvent?: boolean;
|
|
1354
|
+
transformations?: (envelope: unknown) => Payload;
|
|
1355
|
+
__payload: Payload;
|
|
1356
|
+
};
|
|
1357
|
+
declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
|
|
1358
|
+
type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
|
|
1359
|
+
type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
|
|
1360
|
+
|
|
1361
|
+
declare global {
|
|
1362
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
1363
|
+
interface SymbolConstructor {
|
|
1364
|
+
readonly observable: symbol;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
declare function createEventModule<T extends EventDefinition$1<any, string>>(eventDefinition: T): BuildEventDefinition$1<T> & T;
|
|
1369
|
+
|
|
1370
|
+
declare const echo: MaybeContext$1<BuildRESTFunction$1<typeof echo$1> & typeof echo$1>;
|
|
1371
|
+
|
|
1372
|
+
type _publicOnEchoDispatchedType = typeof onEchoDispatched$1;
|
|
1373
|
+
/**
|
|
1374
|
+
* echo event that might be consumed when somone says something!
|
|
1375
|
+
*/
|
|
1376
|
+
declare const onEchoDispatched: ReturnType<typeof createEventModule<_publicOnEchoDispatchedType>>;
|
|
1377
|
+
|
|
1378
|
+
type index_d$1_BaseEventMetadata = BaseEventMetadata;
|
|
1379
|
+
type index_d$1_Dispatched = Dispatched;
|
|
1380
|
+
type index_d$1_EchoDispatchedEnvelope = EchoDispatchedEnvelope;
|
|
1381
|
+
type index_d$1_EchoMessage = EchoMessage;
|
|
1382
|
+
type index_d$1_EchoOptions = EchoOptions;
|
|
1383
|
+
type index_d$1_EchoRequest = EchoRequest;
|
|
1384
|
+
type index_d$1_EchoRequestRequiredFields = EchoRequestRequiredFields;
|
|
1385
|
+
type index_d$1_EchoResponse = EchoResponse;
|
|
1386
|
+
type index_d$1_EchoResponseNonNullableFields = EchoResponseNonNullableFields;
|
|
1387
|
+
type index_d$1_EventMetadata = EventMetadata;
|
|
1388
|
+
type index_d$1_MessageItem = MessageItem;
|
|
1389
|
+
type index_d$1__publicOnEchoDispatchedType = _publicOnEchoDispatchedType;
|
|
1390
|
+
declare const index_d$1_echo: typeof echo;
|
|
1391
|
+
declare const index_d$1_onEchoDispatched: typeof onEchoDispatched;
|
|
1392
|
+
declare namespace index_d$1 {
|
|
1393
|
+
export { type ActionEvent$1 as ActionEvent, type index_d$1_BaseEventMetadata as BaseEventMetadata, type index_d$1_Dispatched as Dispatched, type DomainEvent$1 as DomainEvent, type DomainEventBodyOneOf$1 as DomainEventBodyOneOf, type index_d$1_EchoDispatchedEnvelope as EchoDispatchedEnvelope, type index_d$1_EchoMessage as EchoMessage, type index_d$1_EchoOptions as EchoOptions, type index_d$1_EchoRequest as EchoRequest, type index_d$1_EchoRequestRequiredFields as EchoRequestRequiredFields, type index_d$1_EchoResponse as EchoResponse, type index_d$1_EchoResponseNonNullableFields as EchoResponseNonNullableFields, type EntityCreatedEvent$1 as EntityCreatedEvent, type EntityDeletedEvent$1 as EntityDeletedEvent, type EntityUpdatedEvent$1 as EntityUpdatedEvent, type index_d$1_EventMetadata as EventMetadata, type IdentificationData$1 as IdentificationData, type IdentificationDataIdOneOf$1 as IdentificationDataIdOneOf, type MessageEnvelope$1 as MessageEnvelope, type index_d$1_MessageItem as MessageItem, type RestoreInfo$1 as RestoreInfo, WebhookIdentityType$1 as WebhookIdentityType, type index_d$1__publicOnEchoDispatchedType as _publicOnEchoDispatchedType, index_d$1_echo as echo, index_d$1_onEchoDispatched as onEchoDispatched, onEchoDispatched$1 as publicOnEchoDispatched };
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
type HostModule<T, H extends Host> = {
|
|
1397
|
+
__type: 'host';
|
|
1398
|
+
create(host: H): T;
|
|
1399
|
+
};
|
|
1400
|
+
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
|
|
1401
|
+
type Host<Environment = unknown> = {
|
|
1402
|
+
channel: {
|
|
1403
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
1404
|
+
disconnect: () => void;
|
|
1405
|
+
} | Promise<{
|
|
1406
|
+
disconnect: () => void;
|
|
1407
|
+
}>;
|
|
1408
|
+
};
|
|
1409
|
+
environment?: Environment;
|
|
1410
|
+
/**
|
|
1411
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
1412
|
+
*/
|
|
1413
|
+
apiBaseUrl?: string;
|
|
1414
|
+
/**
|
|
1415
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
1416
|
+
* like internationalization, billing, etc.
|
|
1417
|
+
*/
|
|
1418
|
+
essentials?: {
|
|
1419
|
+
/**
|
|
1420
|
+
* The language of the currently viewed session
|
|
1421
|
+
*/
|
|
1422
|
+
language?: string;
|
|
1423
|
+
/**
|
|
1424
|
+
* The locale of the currently viewed session
|
|
1425
|
+
*/
|
|
1426
|
+
locale?: string;
|
|
1427
|
+
/**
|
|
1428
|
+
* Any headers that should be passed through to the API requests
|
|
1429
|
+
*/
|
|
1430
|
+
passThroughHeaders?: Record<string, string>;
|
|
1431
|
+
};
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
1435
|
+
interface HttpClient {
|
|
1436
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
1437
|
+
fetchWithAuth: typeof fetch;
|
|
1438
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
1439
|
+
getActiveToken?: () => string | undefined;
|
|
1440
|
+
}
|
|
1441
|
+
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
1442
|
+
type HttpResponse<T = any> = {
|
|
1443
|
+
data: T;
|
|
1444
|
+
status: number;
|
|
1445
|
+
statusText: string;
|
|
1446
|
+
headers: any;
|
|
1447
|
+
request?: any;
|
|
1448
|
+
};
|
|
1449
|
+
type RequestOptions<_TResponse = any, Data = any> = {
|
|
1450
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
1451
|
+
url: string;
|
|
1452
|
+
data?: Data;
|
|
1453
|
+
params?: URLSearchParams;
|
|
1454
|
+
} & APIMetadata;
|
|
1455
|
+
type APIMetadata = {
|
|
1456
|
+
methodFqn?: string;
|
|
1457
|
+
entityFqdn?: string;
|
|
1458
|
+
packageName?: string;
|
|
1459
|
+
};
|
|
1460
|
+
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
1461
|
+
type EventDefinition<Payload = unknown, Type extends string = string> = {
|
|
1462
|
+
__type: 'event-definition';
|
|
1463
|
+
type: Type;
|
|
1464
|
+
isDomainEvent?: boolean;
|
|
1465
|
+
transformations?: (envelope: unknown) => Payload;
|
|
1466
|
+
__payload: Payload;
|
|
1467
|
+
};
|
|
1468
|
+
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
|
|
1469
|
+
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
|
|
1470
|
+
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
|
|
1471
|
+
|
|
1472
|
+
type ServicePluginMethodInput = {
|
|
1473
|
+
request: any;
|
|
1474
|
+
metadata: any;
|
|
1475
|
+
};
|
|
1476
|
+
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
|
|
1477
|
+
type ServicePluginMethodMetadata = {
|
|
1478
|
+
name: string;
|
|
1479
|
+
primaryHttpMappingPath: string;
|
|
1480
|
+
transformations: {
|
|
1481
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
|
|
1482
|
+
toREST: (...args: unknown[]) => unknown;
|
|
1483
|
+
};
|
|
1484
|
+
};
|
|
1485
|
+
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
|
|
1486
|
+
__type: 'service-plugin-definition';
|
|
1487
|
+
componentType: string;
|
|
1488
|
+
methods: ServicePluginMethodMetadata[];
|
|
1489
|
+
__contract: Contract;
|
|
1490
|
+
};
|
|
1491
|
+
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
|
|
1492
|
+
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
|
|
1493
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
|
|
1494
|
+
|
|
1495
|
+
type RequestContext = {
|
|
1496
|
+
isSSR: boolean;
|
|
1497
|
+
host: string;
|
|
1498
|
+
protocol?: string;
|
|
1499
|
+
};
|
|
1500
|
+
type ResponseTransformer = (data: any, headers?: any) => any;
|
|
1501
|
+
/**
|
|
1502
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
1503
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
1504
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
1505
|
+
*/
|
|
1506
|
+
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
1507
|
+
type AmbassadorRequestOptions<T = any> = {
|
|
1508
|
+
_?: T;
|
|
1509
|
+
url?: string;
|
|
1510
|
+
method?: Method;
|
|
1511
|
+
params?: any;
|
|
1512
|
+
data?: any;
|
|
1513
|
+
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
1514
|
+
};
|
|
1515
|
+
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
1516
|
+
__isAmbassador: boolean;
|
|
1517
|
+
};
|
|
1518
|
+
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
|
|
1519
|
+
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
1520
|
+
|
|
1521
|
+
declare global {
|
|
1522
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
1523
|
+
interface SymbolConstructor {
|
|
1524
|
+
readonly observable: symbol;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
declare const emptyObjectSymbol: unique symbol;
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
1532
|
+
|
|
1533
|
+
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
|
|
1534
|
+
|
|
1535
|
+
@example
|
|
1536
|
+
```
|
|
1537
|
+
import type {EmptyObject} from 'type-fest';
|
|
1538
|
+
|
|
1539
|
+
// The following illustrates the problem with `{}`.
|
|
1540
|
+
const foo1: {} = {}; // Pass
|
|
1541
|
+
const foo2: {} = []; // Pass
|
|
1542
|
+
const foo3: {} = 42; // Pass
|
|
1543
|
+
const foo4: {} = {a: 1}; // Pass
|
|
1544
|
+
|
|
1545
|
+
// With `EmptyObject` only the first case is valid.
|
|
1546
|
+
const bar1: EmptyObject = {}; // Pass
|
|
1547
|
+
const bar2: EmptyObject = 42; // Fail
|
|
1548
|
+
const bar3: EmptyObject = []; // Fail
|
|
1549
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
1550
|
+
```
|
|
1551
|
+
|
|
1552
|
+
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
|
|
1553
|
+
|
|
1554
|
+
@category Object
|
|
1555
|
+
*/
|
|
1556
|
+
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
1557
|
+
|
|
1558
|
+
/**
|
|
1559
|
+
Returns a boolean for whether the two given types are equal.
|
|
1560
|
+
|
|
1561
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
1562
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
1563
|
+
|
|
1564
|
+
Use-cases:
|
|
1565
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
1566
|
+
|
|
1567
|
+
@example
|
|
1568
|
+
```
|
|
1569
|
+
import type {IsEqual} from 'type-fest';
|
|
1570
|
+
|
|
1571
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
1572
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
1573
|
+
type Includes<Value extends readonly any[], Item> =
|
|
1574
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
1575
|
+
? IsEqual<Value[0], Item> extends true
|
|
1576
|
+
? true
|
|
1577
|
+
: Includes<rest, Item>
|
|
1578
|
+
: false;
|
|
1579
|
+
```
|
|
1580
|
+
|
|
1581
|
+
@category Type Guard
|
|
1582
|
+
@category Utilities
|
|
1583
|
+
*/
|
|
1584
|
+
type IsEqual<A, B> =
|
|
1585
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
1586
|
+
(<G>() => G extends B ? 1 : 2)
|
|
1587
|
+
? true
|
|
1588
|
+
: false;
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
Filter out keys from an object.
|
|
1592
|
+
|
|
1593
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
1594
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
1595
|
+
Returns `Key` otherwise.
|
|
1596
|
+
|
|
1597
|
+
@example
|
|
1598
|
+
```
|
|
1599
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
1600
|
+
//=> never
|
|
1601
|
+
```
|
|
1602
|
+
|
|
1603
|
+
@example
|
|
1604
|
+
```
|
|
1605
|
+
type Filtered = Filter<'bar', string>;
|
|
1606
|
+
//=> never
|
|
1607
|
+
```
|
|
1608
|
+
|
|
1609
|
+
@example
|
|
1610
|
+
```
|
|
1611
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
1612
|
+
//=> 'bar'
|
|
1613
|
+
```
|
|
1614
|
+
|
|
1615
|
+
@see {Except}
|
|
1616
|
+
*/
|
|
1617
|
+
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
1618
|
+
|
|
1619
|
+
type ExceptOptions = {
|
|
1620
|
+
/**
|
|
1621
|
+
Disallow assigning non-specified properties.
|
|
1622
|
+
|
|
1623
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
1624
|
+
|
|
1625
|
+
@default false
|
|
1626
|
+
*/
|
|
1627
|
+
requireExactProps?: boolean;
|
|
1628
|
+
};
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
Create a type from an object type without certain keys.
|
|
1632
|
+
|
|
1633
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
1634
|
+
|
|
1635
|
+
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
1636
|
+
|
|
1637
|
+
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
1638
|
+
|
|
1639
|
+
@example
|
|
1640
|
+
```
|
|
1641
|
+
import type {Except} from 'type-fest';
|
|
1642
|
+
|
|
1643
|
+
type Foo = {
|
|
1644
|
+
a: number;
|
|
1645
|
+
b: string;
|
|
1646
|
+
};
|
|
1647
|
+
|
|
1648
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
1649
|
+
//=> {b: string}
|
|
1650
|
+
|
|
1651
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
1652
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
1653
|
+
|
|
1654
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
1655
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
1656
|
+
|
|
1657
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
1658
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
1659
|
+
```
|
|
1660
|
+
|
|
1661
|
+
@category Object
|
|
1662
|
+
*/
|
|
1663
|
+
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
|
|
1664
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
1665
|
+
} & (Options['requireExactProps'] extends true
|
|
1666
|
+
? Partial<Record<KeysType, never>>
|
|
1667
|
+
: {});
|
|
1668
|
+
|
|
1669
|
+
/**
|
|
1670
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
1671
|
+
|
|
1672
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
1673
|
+
|
|
1674
|
+
@example
|
|
1675
|
+
```
|
|
1676
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1677
|
+
|
|
1678
|
+
interface Example {
|
|
1679
|
+
a: string;
|
|
1680
|
+
b: string | number;
|
|
1681
|
+
c?: string;
|
|
1682
|
+
d: {};
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
1686
|
+
//=> 'a'
|
|
1687
|
+
```
|
|
1688
|
+
|
|
1689
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
1690
|
+
|
|
1691
|
+
@example
|
|
1692
|
+
```
|
|
1693
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1694
|
+
|
|
1695
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
1696
|
+
//=> 'a' | 'c'
|
|
1697
|
+
```
|
|
1698
|
+
|
|
1699
|
+
@category Object
|
|
1700
|
+
*/
|
|
1701
|
+
type ConditionalKeys<Base, Condition> = NonNullable<
|
|
1702
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
1703
|
+
{
|
|
1704
|
+
// Map through all the keys of the given base type.
|
|
1705
|
+
[Key in keyof Base]:
|
|
1706
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
1707
|
+
Base[Key] extends Condition
|
|
1708
|
+
// Retain this key since the condition passes.
|
|
1709
|
+
? Key
|
|
1710
|
+
// Discard this key since the condition fails.
|
|
1711
|
+
: never;
|
|
1712
|
+
|
|
1713
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
1714
|
+
}[keyof Base]
|
|
1715
|
+
>;
|
|
1716
|
+
|
|
1717
|
+
/**
|
|
1718
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
1719
|
+
|
|
1720
|
+
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
|
|
1721
|
+
|
|
1722
|
+
@example
|
|
1723
|
+
```
|
|
1724
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
1725
|
+
|
|
1726
|
+
class Awesome {
|
|
1727
|
+
name: string;
|
|
1728
|
+
successes: number;
|
|
1729
|
+
failures: bigint;
|
|
1730
|
+
|
|
1731
|
+
run() {}
|
|
937
1732
|
}
|
|
938
|
-
declare const onEchoDispatched$1: EventDefinition$2<EchoDispatchedEnvelope, "wix.metroinspector.v1.echo_dispatched">;
|
|
939
1733
|
|
|
940
|
-
type
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
isDomainEvent?: boolean;
|
|
944
|
-
transformations?: (envelope: unknown) => Payload;
|
|
945
|
-
__payload: Payload;
|
|
946
|
-
};
|
|
947
|
-
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
|
|
948
|
-
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
|
|
949
|
-
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
|
|
1734
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
1735
|
+
//=> {run: () => void}
|
|
1736
|
+
```
|
|
950
1737
|
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1738
|
+
@example
|
|
1739
|
+
```
|
|
1740
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
1741
|
+
|
|
1742
|
+
interface Example {
|
|
1743
|
+
a: string;
|
|
1744
|
+
b: string | number;
|
|
1745
|
+
c: () => void;
|
|
1746
|
+
d: {};
|
|
956
1747
|
}
|
|
957
1748
|
|
|
958
|
-
|
|
1749
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
1750
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
1751
|
+
```
|
|
959
1752
|
|
|
960
|
-
|
|
1753
|
+
@category Object
|
|
1754
|
+
*/
|
|
1755
|
+
type ConditionalExcept<Base, Condition> = Except<
|
|
1756
|
+
Base,
|
|
1757
|
+
ConditionalKeys<Base, Condition>
|
|
1758
|
+
>;
|
|
961
1759
|
|
|
962
|
-
type _publicOnEchoDispatchedType = typeof onEchoDispatched$1;
|
|
963
1760
|
/**
|
|
964
|
-
*
|
|
1761
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
1762
|
+
* can either be a REST module or a host module.
|
|
1763
|
+
* This type is recursive, so it can describe nested modules.
|
|
965
1764
|
*/
|
|
966
|
-
|
|
1765
|
+
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
|
|
1766
|
+
[key: string]: Descriptors | PublicMetadata | any;
|
|
1767
|
+
};
|
|
1768
|
+
/**
|
|
1769
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
1770
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
1771
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
1772
|
+
* do not match the given host (as they will not work with the given host).
|
|
1773
|
+
*/
|
|
1774
|
+
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
|
|
1775
|
+
done: T;
|
|
1776
|
+
recurse: T extends {
|
|
1777
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE;
|
|
1778
|
+
} ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
|
|
1779
|
+
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
|
|
1780
|
+
-1,
|
|
1781
|
+
0,
|
|
1782
|
+
1,
|
|
1783
|
+
2,
|
|
1784
|
+
3,
|
|
1785
|
+
4,
|
|
1786
|
+
5
|
|
1787
|
+
][Depth]> : never;
|
|
1788
|
+
}, EmptyObject>;
|
|
1789
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
1790
|
+
type PublicMetadata = {
|
|
1791
|
+
PACKAGE_NAME?: string;
|
|
1792
|
+
};
|
|
967
1793
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
type index_d$1_EchoMessage = EchoMessage;
|
|
972
|
-
type index_d$1_EchoOptions = EchoOptions;
|
|
973
|
-
type index_d$1_EchoRequest = EchoRequest;
|
|
974
|
-
type index_d$1_EchoRequestRequiredFields = EchoRequestRequiredFields;
|
|
975
|
-
type index_d$1_EchoResponse = EchoResponse;
|
|
976
|
-
type index_d$1_EchoResponseNonNullableFields = EchoResponseNonNullableFields;
|
|
977
|
-
type index_d$1_EventMetadata = EventMetadata;
|
|
978
|
-
type index_d$1_MessageItem = MessageItem;
|
|
979
|
-
type index_d$1__publicOnEchoDispatchedType = _publicOnEchoDispatchedType;
|
|
980
|
-
declare const index_d$1_echo: typeof echo;
|
|
981
|
-
declare const index_d$1_onEchoDispatched: typeof onEchoDispatched;
|
|
982
|
-
declare namespace index_d$1 {
|
|
983
|
-
export { type ActionEvent$1 as ActionEvent, type index_d$1_BaseEventMetadata as BaseEventMetadata, type index_d$1_Dispatched as Dispatched, type DomainEvent$1 as DomainEvent, type DomainEventBodyOneOf$1 as DomainEventBodyOneOf, type index_d$1_EchoDispatchedEnvelope as EchoDispatchedEnvelope, type index_d$1_EchoMessage as EchoMessage, type index_d$1_EchoOptions as EchoOptions, type index_d$1_EchoRequest as EchoRequest, type index_d$1_EchoRequestRequiredFields as EchoRequestRequiredFields, type index_d$1_EchoResponse as EchoResponse, type index_d$1_EchoResponseNonNullableFields as EchoResponseNonNullableFields, type EntityCreatedEvent$1 as EntityCreatedEvent, type EntityDeletedEvent$1 as EntityDeletedEvent, type EntityUpdatedEvent$1 as EntityUpdatedEvent, type index_d$1_EventMetadata as EventMetadata, type IdentificationData$1 as IdentificationData, type IdentificationDataIdOneOf$1 as IdentificationDataIdOneOf, type MessageEnvelope$1 as MessageEnvelope, type index_d$1_MessageItem as MessageItem, type RestoreInfo$1 as RestoreInfo, WebhookIdentityType$1 as WebhookIdentityType, type index_d$1__publicOnEchoDispatchedType as _publicOnEchoDispatchedType, index_d$1_echo as echo, index_d$1_onEchoDispatched as onEchoDispatched, onEchoDispatched$1 as publicOnEchoDispatched };
|
|
1794
|
+
declare global {
|
|
1795
|
+
interface ContextualClient {
|
|
1796
|
+
}
|
|
984
1797
|
}
|
|
1798
|
+
/**
|
|
1799
|
+
* A type used to create concerete types from SDK descriptors in
|
|
1800
|
+
* case a contextual client is available.
|
|
1801
|
+
*/
|
|
1802
|
+
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
1803
|
+
host: Host;
|
|
1804
|
+
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
985
1805
|
|
|
986
1806
|
/** Physical address */
|
|
987
1807
|
interface Address extends AddressStreetOneOf {
|