@wix/multilingual 1.0.68 → 1.0.69
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 +8 -8
- package/type-bundles/context.bundle.d.ts +2764 -360
- package/type-bundles/index.bundle.d.ts +2764 -360
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
type HostModule<T, H extends Host> = {
|
|
1
|
+
type HostModule$5<T, H extends Host$5> = {
|
|
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$5<T extends HostModule$5<any, any>> = T extends HostModule$5<infer U, any> ? U : never;
|
|
6
|
+
type Host$5<Environment = unknown> = {
|
|
7
7
|
channel: {
|
|
8
8
|
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
9
9
|
disconnect: () => void;
|
|
@@ -12,6 +12,10 @@ type Host<Environment = unknown> = {
|
|
|
12
12
|
}>;
|
|
13
13
|
};
|
|
14
14
|
environment?: Environment;
|
|
15
|
+
/**
|
|
16
|
+
* Optional name of the environment, use for logging
|
|
17
|
+
*/
|
|
18
|
+
name?: string;
|
|
15
19
|
/**
|
|
16
20
|
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
17
21
|
*/
|
|
@@ -36,92 +40,92 @@ type Host<Environment = unknown> = {
|
|
|
36
40
|
};
|
|
37
41
|
};
|
|
38
42
|
|
|
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>>;
|
|
43
|
+
type RESTFunctionDescriptor$5<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$5) => T;
|
|
44
|
+
interface HttpClient$5 {
|
|
45
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$5<TResponse, TData>): Promise<HttpResponse$5<TResponse>>;
|
|
42
46
|
fetchWithAuth: typeof fetch;
|
|
43
47
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
44
48
|
getActiveToken?: () => string | undefined;
|
|
45
49
|
}
|
|
46
|
-
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
47
|
-
type HttpResponse<T = any> = {
|
|
50
|
+
type RequestOptionsFactory$5<TResponse = any, TData = any> = (context: any) => RequestOptions$5<TResponse, TData>;
|
|
51
|
+
type HttpResponse$5<T = any> = {
|
|
48
52
|
data: T;
|
|
49
53
|
status: number;
|
|
50
54
|
statusText: string;
|
|
51
55
|
headers: any;
|
|
52
56
|
request?: any;
|
|
53
57
|
};
|
|
54
|
-
type RequestOptions<_TResponse = any, Data = any> = {
|
|
58
|
+
type RequestOptions$5<_TResponse = any, Data = any> = {
|
|
55
59
|
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
56
60
|
url: string;
|
|
57
61
|
data?: Data;
|
|
58
62
|
params?: URLSearchParams;
|
|
59
|
-
} & APIMetadata;
|
|
60
|
-
type APIMetadata = {
|
|
63
|
+
} & APIMetadata$5;
|
|
64
|
+
type APIMetadata$5 = {
|
|
61
65
|
methodFqn?: string;
|
|
62
66
|
entityFqdn?: string;
|
|
63
67
|
packageName?: string;
|
|
64
68
|
};
|
|
65
|
-
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
66
|
-
type EventDefinition$
|
|
69
|
+
type BuildRESTFunction$5<T extends RESTFunctionDescriptor$5> = T extends RESTFunctionDescriptor$5<infer U> ? U : never;
|
|
70
|
+
type EventDefinition$5<Payload = unknown, Type extends string = string> = {
|
|
67
71
|
__type: 'event-definition';
|
|
68
72
|
type: Type;
|
|
69
73
|
isDomainEvent?: boolean;
|
|
70
74
|
transformations?: (envelope: unknown) => Payload;
|
|
71
75
|
__payload: Payload;
|
|
72
76
|
};
|
|
73
|
-
declare function EventDefinition$
|
|
74
|
-
type EventHandler$
|
|
75
|
-
type BuildEventDefinition$
|
|
77
|
+
declare function EventDefinition$5<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$5<Payload, Type>;
|
|
78
|
+
type EventHandler$5<T extends EventDefinition$5> = (payload: T['__payload']) => void | Promise<void>;
|
|
79
|
+
type BuildEventDefinition$5<T extends EventDefinition$5<any, string>> = (handler: EventHandler$5<T>) => void;
|
|
76
80
|
|
|
77
|
-
type ServicePluginMethodInput = {
|
|
81
|
+
type ServicePluginMethodInput$5 = {
|
|
78
82
|
request: any;
|
|
79
83
|
metadata: any;
|
|
80
84
|
};
|
|
81
|
-
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
|
|
82
|
-
type ServicePluginMethodMetadata = {
|
|
85
|
+
type ServicePluginContract$5 = Record<string, (payload: ServicePluginMethodInput$5) => unknown | Promise<unknown>>;
|
|
86
|
+
type ServicePluginMethodMetadata$5 = {
|
|
83
87
|
name: string;
|
|
84
88
|
primaryHttpMappingPath: string;
|
|
85
89
|
transformations: {
|
|
86
|
-
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
|
|
90
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$5;
|
|
87
91
|
toREST: (...args: unknown[]) => unknown;
|
|
88
92
|
};
|
|
89
93
|
};
|
|
90
|
-
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
|
|
94
|
+
type ServicePluginDefinition$5<Contract extends ServicePluginContract$5> = {
|
|
91
95
|
__type: 'service-plugin-definition';
|
|
92
96
|
componentType: string;
|
|
93
|
-
methods: ServicePluginMethodMetadata[];
|
|
97
|
+
methods: ServicePluginMethodMetadata$5[];
|
|
94
98
|
__contract: Contract;
|
|
95
99
|
};
|
|
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";
|
|
100
|
+
declare function ServicePluginDefinition$5<Contract extends ServicePluginContract$5>(componentType: string, methods: ServicePluginMethodMetadata$5[]): ServicePluginDefinition$5<Contract>;
|
|
101
|
+
type BuildServicePluginDefinition$5<T extends ServicePluginDefinition$5<any>> = (implementation: T['__contract']) => void;
|
|
102
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$5 = "wix_spi_error";
|
|
99
103
|
|
|
100
|
-
type RequestContext = {
|
|
104
|
+
type RequestContext$5 = {
|
|
101
105
|
isSSR: boolean;
|
|
102
106
|
host: string;
|
|
103
107
|
protocol?: string;
|
|
104
108
|
};
|
|
105
|
-
type ResponseTransformer = (data: any, headers?: any) => any;
|
|
109
|
+
type ResponseTransformer$5 = (data: any, headers?: any) => any;
|
|
106
110
|
/**
|
|
107
111
|
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
108
112
|
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
109
113
|
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
110
114
|
*/
|
|
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> = {
|
|
115
|
+
type Method$5 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
116
|
+
type AmbassadorRequestOptions$5<T = any> = {
|
|
113
117
|
_?: T;
|
|
114
118
|
url?: string;
|
|
115
|
-
method?: Method;
|
|
119
|
+
method?: Method$5;
|
|
116
120
|
params?: any;
|
|
117
121
|
data?: any;
|
|
118
|
-
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
122
|
+
transformResponse?: ResponseTransformer$5 | ResponseTransformer$5[];
|
|
119
123
|
};
|
|
120
|
-
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
124
|
+
type AmbassadorFactory$5<Request, Response> = (payload: Request) => ((context: RequestContext$5) => AmbassadorRequestOptions$5<Response>) & {
|
|
121
125
|
__isAmbassador: boolean;
|
|
122
126
|
};
|
|
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;
|
|
127
|
+
type AmbassadorFunctionDescriptor$5<Request = any, Response = any> = AmbassadorFactory$5<Request, Response>;
|
|
128
|
+
type BuildAmbassadorFunction$5<T extends AmbassadorFunctionDescriptor$5> = T extends AmbassadorFunctionDescriptor$5<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
125
129
|
|
|
126
130
|
declare global {
|
|
127
131
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -130,7 +134,7 @@ declare global {
|
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
declare const emptyObjectSymbol: unique symbol;
|
|
137
|
+
declare const emptyObjectSymbol$5: unique symbol;
|
|
134
138
|
|
|
135
139
|
/**
|
|
136
140
|
Represents a strictly empty plain object, the `{}` value.
|
|
@@ -158,7 +162,7 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
|
|
|
158
162
|
|
|
159
163
|
@category Object
|
|
160
164
|
*/
|
|
161
|
-
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
165
|
+
type EmptyObject$5 = {[emptyObjectSymbol$5]?: never};
|
|
162
166
|
|
|
163
167
|
/**
|
|
164
168
|
Returns a boolean for whether the two given types are equal.
|
|
@@ -186,7 +190,7 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
186
190
|
@category Type Guard
|
|
187
191
|
@category Utilities
|
|
188
192
|
*/
|
|
189
|
-
type IsEqual<A, B> =
|
|
193
|
+
type IsEqual$5<A, B> =
|
|
190
194
|
(<G>() => G extends A ? 1 : 2) extends
|
|
191
195
|
(<G>() => G extends B ? 1 : 2)
|
|
192
196
|
? true
|
|
@@ -219,9 +223,9 @@ type Filtered = Filter<'bar', 'foo'>;
|
|
|
219
223
|
|
|
220
224
|
@see {Except}
|
|
221
225
|
*/
|
|
222
|
-
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
226
|
+
type Filter$5<KeyType, ExcludeType> = IsEqual$5<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
223
227
|
|
|
224
|
-
type ExceptOptions = {
|
|
228
|
+
type ExceptOptions$5 = {
|
|
225
229
|
/**
|
|
226
230
|
Disallow assigning non-specified properties.
|
|
227
231
|
|
|
@@ -265,12 +269,78 @@ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
|
265
269
|
|
|
266
270
|
@category Object
|
|
267
271
|
*/
|
|
268
|
-
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
|
|
269
|
-
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
272
|
+
type Except$5<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$5 = {requireExactProps: false}> = {
|
|
273
|
+
[KeyType in keyof ObjectType as Filter$5<KeyType, KeysType>]: ObjectType[KeyType];
|
|
270
274
|
} & (Options['requireExactProps'] extends true
|
|
271
275
|
? Partial<Record<KeysType, never>>
|
|
272
276
|
: {});
|
|
273
277
|
|
|
278
|
+
/**
|
|
279
|
+
Returns a boolean for whether the given type is `never`.
|
|
280
|
+
|
|
281
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
282
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
283
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
284
|
+
|
|
285
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
286
|
+
|
|
287
|
+
@example
|
|
288
|
+
```
|
|
289
|
+
import type {IsNever, And} from 'type-fest';
|
|
290
|
+
|
|
291
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
292
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
293
|
+
And<
|
|
294
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
295
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
296
|
+
>;
|
|
297
|
+
|
|
298
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
299
|
+
AreStringsEqual<I, O> extends true
|
|
300
|
+
? never
|
|
301
|
+
: void;
|
|
302
|
+
|
|
303
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
304
|
+
if (input === output) {
|
|
305
|
+
process.exit(0);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
endIfEqual('abc', 'abc');
|
|
310
|
+
//=> never
|
|
311
|
+
|
|
312
|
+
endIfEqual('abc', '123');
|
|
313
|
+
//=> void
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
@category Type Guard
|
|
317
|
+
@category Utilities
|
|
318
|
+
*/
|
|
319
|
+
type IsNever$5<T> = [T] extends [never] ? true : false;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
323
|
+
|
|
324
|
+
@see {@link IsNever}
|
|
325
|
+
|
|
326
|
+
@example
|
|
327
|
+
```
|
|
328
|
+
import type {IfNever} from 'type-fest';
|
|
329
|
+
|
|
330
|
+
type ShouldBeTrue = IfNever<never>;
|
|
331
|
+
//=> true
|
|
332
|
+
|
|
333
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
334
|
+
//=> 'bar'
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
@category Type Guard
|
|
338
|
+
@category Utilities
|
|
339
|
+
*/
|
|
340
|
+
type IfNever$5<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
341
|
+
IsNever$5<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
342
|
+
);
|
|
343
|
+
|
|
274
344
|
/**
|
|
275
345
|
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
276
346
|
|
|
@@ -303,21 +373,19 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
|
303
373
|
|
|
304
374
|
@category Object
|
|
305
375
|
*/
|
|
306
|
-
type ConditionalKeys<Base, Condition> =
|
|
307
|
-
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
376
|
+
type ConditionalKeys$5<Base, Condition> =
|
|
308
377
|
{
|
|
309
378
|
// Map through all the keys of the given base type.
|
|
310
|
-
[Key in keyof Base]
|
|
379
|
+
[Key in keyof Base]-?:
|
|
311
380
|
// Pick only keys with types extending the given `Condition` type.
|
|
312
381
|
Base[Key] extends Condition
|
|
313
|
-
// Retain this key
|
|
314
|
-
|
|
382
|
+
// Retain this key
|
|
383
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
384
|
+
? IfNever$5<Base[Key], IfNever$5<Condition, Key, never>, Key>
|
|
315
385
|
// Discard this key since the condition fails.
|
|
316
386
|
: never;
|
|
317
|
-
|
|
318
387
|
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
319
|
-
}[keyof Base]
|
|
320
|
-
>;
|
|
388
|
+
}[keyof Base];
|
|
321
389
|
|
|
322
390
|
/**
|
|
323
391
|
Exclude keys from a shape that matches the given `Condition`.
|
|
@@ -357,9 +425,9 @@ type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
|
357
425
|
|
|
358
426
|
@category Object
|
|
359
427
|
*/
|
|
360
|
-
type ConditionalExcept<Base, Condition> = Except<
|
|
428
|
+
type ConditionalExcept$5<Base, Condition> = Except$5<
|
|
361
429
|
Base,
|
|
362
|
-
ConditionalKeys<Base, Condition>
|
|
430
|
+
ConditionalKeys$5<Base, Condition>
|
|
363
431
|
>;
|
|
364
432
|
|
|
365
433
|
/**
|
|
@@ -367,8 +435,8 @@ ConditionalKeys<Base, Condition>
|
|
|
367
435
|
* can either be a REST module or a host module.
|
|
368
436
|
* This type is recursive, so it can describe nested modules.
|
|
369
437
|
*/
|
|
370
|
-
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition$
|
|
371
|
-
[key: string]: Descriptors | PublicMetadata | any;
|
|
438
|
+
type Descriptors$5 = RESTFunctionDescriptor$5 | AmbassadorFunctionDescriptor$5 | HostModule$5<any, any> | EventDefinition$5<any> | ServicePluginDefinition$5<any> | {
|
|
439
|
+
[key: string]: Descriptors$5 | PublicMetadata$5 | any;
|
|
372
440
|
};
|
|
373
441
|
/**
|
|
374
442
|
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
@@ -376,12 +444,12 @@ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostM
|
|
|
376
444
|
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
377
445
|
* do not match the given host (as they will not work with the given host).
|
|
378
446
|
*/
|
|
379
|
-
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
|
|
447
|
+
type BuildDescriptors$5<T extends Descriptors$5, H extends Host$5<any> | undefined, Depth extends number = 5> = {
|
|
380
448
|
done: T;
|
|
381
449
|
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, [
|
|
450
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$5;
|
|
451
|
+
} ? never : T extends AmbassadorFunctionDescriptor$5 ? BuildAmbassadorFunction$5<T> : T extends RESTFunctionDescriptor$5 ? BuildRESTFunction$5<T> : T extends EventDefinition$5<any> ? BuildEventDefinition$5<T> : T extends ServicePluginDefinition$5<any> ? BuildServicePluginDefinition$5<T> : T extends HostModule$5<any, any> ? HostModuleAPI$5<T> : ConditionalExcept$5<{
|
|
452
|
+
[Key in keyof T]: T[Key] extends Descriptors$5 ? BuildDescriptors$5<T[Key], H, [
|
|
385
453
|
-1,
|
|
386
454
|
0,
|
|
387
455
|
1,
|
|
@@ -390,9 +458,9 @@ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, De
|
|
|
390
458
|
4,
|
|
391
459
|
5
|
|
392
460
|
][Depth]> : never;
|
|
393
|
-
}, EmptyObject>;
|
|
461
|
+
}, EmptyObject$5>;
|
|
394
462
|
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
395
|
-
type PublicMetadata = {
|
|
463
|
+
type PublicMetadata$5 = {
|
|
396
464
|
PACKAGE_NAME?: string;
|
|
397
465
|
};
|
|
398
466
|
|
|
@@ -404,9 +472,9 @@ declare global {
|
|
|
404
472
|
* A type used to create concerete types from SDK descriptors in
|
|
405
473
|
* case a contextual client is available.
|
|
406
474
|
*/
|
|
407
|
-
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
408
|
-
host: Host;
|
|
409
|
-
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
475
|
+
type MaybeContext$5<T extends Descriptors$5> = globalThis.ContextualClient extends {
|
|
476
|
+
host: Host$5;
|
|
477
|
+
} ? BuildDescriptors$5<T, globalThis.ContextualClient['host']> : T;
|
|
410
478
|
|
|
411
479
|
interface Mapper {
|
|
412
480
|
_id?: string | null;
|
|
@@ -844,7 +912,7 @@ interface SyncEditorDataOptions {
|
|
|
844
912
|
syncFilter?: SyncFilter;
|
|
845
913
|
}
|
|
846
914
|
|
|
847
|
-
declare function syncEditorData$1(httpClient: HttpClient): SyncEditorDataSignature;
|
|
915
|
+
declare function syncEditorData$1(httpClient: HttpClient$5): SyncEditorDataSignature;
|
|
848
916
|
interface SyncEditorDataSignature {
|
|
849
917
|
/**
|
|
850
918
|
* Update localization content with editor data
|
|
@@ -852,7 +920,7 @@ interface SyncEditorDataSignature {
|
|
|
852
920
|
(options?: SyncEditorDataOptions | undefined): Promise<void>;
|
|
853
921
|
}
|
|
854
922
|
|
|
855
|
-
declare const syncEditorData: MaybeContext<BuildRESTFunction<typeof syncEditorData$1> & typeof syncEditorData$1>;
|
|
923
|
+
declare const syncEditorData: MaybeContext$5<BuildRESTFunction$5<typeof syncEditorData$1> & typeof syncEditorData$1>;
|
|
856
924
|
|
|
857
925
|
type context$5_ChangedPages = ChangedPages;
|
|
858
926
|
type context$5_CreateOrUpdateAction = CreateOrUpdateAction;
|
|
@@ -904,87 +972,565 @@ declare namespace context$5 {
|
|
|
904
972
|
export { type ActionEvent$3 as ActionEvent, type context$5_ChangedPages as ChangedPages, type context$5_CreateOrUpdateAction as CreateOrUpdateAction, type context$5_CreateOrUpdateEditorMapperRequest as CreateOrUpdateEditorMapperRequest, type context$5_CreateOrUpdateEditorMapperResponse as CreateOrUpdateEditorMapperResponse, type context$5_CreateOrUpdateNileMapperRequest as CreateOrUpdateNileMapperRequest, type context$5_CreateOrUpdateNileMapperResponse as CreateOrUpdateNileMapperResponse, type context$5_DeleteAction as DeleteAction, type context$5_DeleteEntityMapperRequest as DeleteEntityMapperRequest, type context$5_DeleteEntityMapperResponse as DeleteEntityMapperResponse, type context$5_DeleteMapperRequest as DeleteMapperRequest, type context$5_DeleteMapperResponse as DeleteMapperResponse, type DomainEvent$3 as DomainEvent, type DomainEventBodyOneOf$3 as DomainEventBodyOneOf, type Empty$2 as Empty, type EntityCreatedEvent$3 as EntityCreatedEvent, type EntityDeletedEvent$3 as EntityDeletedEvent, type EntityUpdatedEvent$3 as EntityUpdatedEvent, type context$5_FieldSequence as FieldSequence, FieldType$1 as FieldType, type context$5_GetEntityMapperRequest as GetEntityMapperRequest, type context$5_GetEntityMapperResponse as GetEntityMapperResponse, type context$5_GetMapperRequest as GetMapperRequest, type context$5_GetMapperResponse as GetMapperResponse, type context$5_GetSubscribedTopicsRequest as GetSubscribedTopicsRequest, type context$5_GetSubscribedTopicsResponse as GetSubscribedTopicsResponse, type context$5_HtmlNewRevisionSavedMessage as HtmlNewRevisionSavedMessage, type IdentificationData$3 as IdentificationData, type IdentificationDataIdOneOf$3 as IdentificationDataIdOneOf, type context$5_ListEntityMapperRequest as ListEntityMapperRequest, type context$5_ListEntityMapperResponse as ListEntityMapperResponse, type context$5_ListMappersRequest as ListMappersRequest, type context$5_ListMappersResponse as ListMappersResponse, type context$5_LocalizationPublicAction as LocalizationPublicAction, type context$5_LocalizationPublicActionActionOneOf as LocalizationPublicActionActionOneOf, type context$5_LocalizedContentKey as LocalizedContentKey, type context$5_LocalizedPublishedContent as LocalizedPublishedContent, type context$5_LocalizedPublishedContentField as LocalizedPublishedContentField, type context$5_LocalizedPublishedContentFieldValueOneOf as LocalizedPublishedContentFieldValueOneOf, type context$5_LocalizedPublishedLanguageContentChanged as LocalizedPublishedLanguageContentChanged, type context$5_Mapper as Mapper, type context$5_MapperField as MapperField, type context$5_MediaItem as MediaItem, type context$5_MediaItemMediaOneOf as MediaItemMediaOneOf, type MessageEnvelope$3 as MessageEnvelope, type context$5_Page as Page, type context$5_PublishSiteTranslationsRequest as PublishSiteTranslationsRequest, type context$5_PublishSiteTranslationsResponse as PublishSiteTranslationsResponse, type RestoreInfo$3 as RestoreInfo, type context$5_RevisionInfo as RevisionInfo, type SchemaKey$2 as SchemaKey, SchemaScope$2 as SchemaScope, type context$5_SequencePath as SequencePath, type context$5_StressDMRequest as StressDMRequest, type context$5_StressDMResponse as StressDMResponse, type context$5_SyncEditorDataOptions as SyncEditorDataOptions, type context$5_SyncEditorDataRequest as SyncEditorDataRequest, type context$5_SyncEditorDataResponse as SyncEditorDataResponse, type context$5_SyncFilter as SyncFilter, type VideoResolution$2 as VideoResolution, WebhookIdentityType$3 as WebhookIdentityType, context$5_syncEditorData as syncEditorData };
|
|
905
973
|
}
|
|
906
974
|
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
* Published content locale.
|
|
922
|
-
* @readonly
|
|
923
|
-
*/
|
|
924
|
-
locale?: string;
|
|
925
|
-
/** List of fields that have been translated and published for the given locale. */
|
|
926
|
-
fields?: PublishedContentField[];
|
|
927
|
-
/** A reference to the parent content. For example, if the content is a menu item, this property would contain the `entityId` of the menu it belongs to. */
|
|
928
|
-
parentEntityId?: string | null;
|
|
929
|
-
/** Custom field data for the published content object. */
|
|
930
|
-
extendedFields?: ExtendedFields;
|
|
931
|
-
}
|
|
932
|
-
interface SchemaKey$1 {
|
|
975
|
+
type HostModule$4<T, H extends Host$4> = {
|
|
976
|
+
__type: 'host';
|
|
977
|
+
create(host: H): T;
|
|
978
|
+
};
|
|
979
|
+
type HostModuleAPI$4<T extends HostModule$4<any, any>> = T extends HostModule$4<infer U, any> ? U : never;
|
|
980
|
+
type Host$4<Environment = unknown> = {
|
|
981
|
+
channel: {
|
|
982
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
983
|
+
disconnect: () => void;
|
|
984
|
+
} | Promise<{
|
|
985
|
+
disconnect: () => void;
|
|
986
|
+
}>;
|
|
987
|
+
};
|
|
988
|
+
environment?: Environment;
|
|
933
989
|
/**
|
|
934
|
-
*
|
|
935
|
-
* @readonly
|
|
990
|
+
* Optional name of the environment, use for logging
|
|
936
991
|
*/
|
|
937
|
-
|
|
938
|
-
/** A unique name defined by the app developer to differentiate translation schemas for various entities within their app. For example, if an app developer is creating a translation schema for blog posts, the `entityType` can be `'blog-posts'`. */
|
|
939
|
-
entityType?: string;
|
|
992
|
+
name?: string;
|
|
940
993
|
/**
|
|
941
|
-
*
|
|
942
|
-
* Supported values:
|
|
943
|
-
* + `GLOBAL`: A global schema for all sites.
|
|
944
|
-
* + `SITE`: A custom schema for a specific site.
|
|
994
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
945
995
|
*/
|
|
946
|
-
|
|
947
|
-
}
|
|
948
|
-
declare enum SchemaScope$1 {
|
|
949
|
-
UNKNOWN_SCOPE = "UNKNOWN_SCOPE",
|
|
950
|
-
/** Global schema, relevant to all sites */
|
|
951
|
-
GLOBAL = "GLOBAL",
|
|
952
|
-
/** Site schema, relevant to specific site only */
|
|
953
|
-
SITE = "SITE"
|
|
954
|
-
}
|
|
955
|
-
interface PublishedContentField extends PublishedContentFieldValueOneOf {
|
|
956
|
-
/** Plain text. */
|
|
957
|
-
textValue?: string;
|
|
958
|
-
/** Rich content. */
|
|
959
|
-
richContent?: RichContent$2;
|
|
960
|
-
/** Wix Media Manager image. */
|
|
961
|
-
image?: string;
|
|
962
|
-
/** Wix Media Manager video. */
|
|
963
|
-
video?: string;
|
|
964
|
-
/** Wix Media Manager document. */
|
|
965
|
-
document?: string;
|
|
996
|
+
apiBaseUrl?: string;
|
|
966
997
|
/**
|
|
967
|
-
*
|
|
968
|
-
*
|
|
998
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
999
|
+
* like internationalization, billing, etc.
|
|
969
1000
|
*/
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1001
|
+
essentials?: {
|
|
1002
|
+
/**
|
|
1003
|
+
* The language of the currently viewed session
|
|
1004
|
+
*/
|
|
1005
|
+
language?: string;
|
|
1006
|
+
/**
|
|
1007
|
+
* The locale of the currently viewed session
|
|
1008
|
+
*/
|
|
1009
|
+
locale?: string;
|
|
1010
|
+
/**
|
|
1011
|
+
* Any headers that should be passed through to the API requests
|
|
1012
|
+
*/
|
|
1013
|
+
passThroughHeaders?: Record<string, string>;
|
|
1014
|
+
};
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
type RESTFunctionDescriptor$4<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$4) => T;
|
|
1018
|
+
interface HttpClient$4 {
|
|
1019
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$4<TResponse, TData>): Promise<HttpResponse$4<TResponse>>;
|
|
1020
|
+
fetchWithAuth: typeof fetch;
|
|
1021
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
1022
|
+
getActiveToken?: () => string | undefined;
|
|
973
1023
|
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1024
|
+
type RequestOptionsFactory$4<TResponse = any, TData = any> = (context: any) => RequestOptions$4<TResponse, TData>;
|
|
1025
|
+
type HttpResponse$4<T = any> = {
|
|
1026
|
+
data: T;
|
|
1027
|
+
status: number;
|
|
1028
|
+
statusText: string;
|
|
1029
|
+
headers: any;
|
|
1030
|
+
request?: any;
|
|
1031
|
+
};
|
|
1032
|
+
type RequestOptions$4<_TResponse = any, Data = any> = {
|
|
1033
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
1034
|
+
url: string;
|
|
1035
|
+
data?: Data;
|
|
1036
|
+
params?: URLSearchParams;
|
|
1037
|
+
} & APIMetadata$4;
|
|
1038
|
+
type APIMetadata$4 = {
|
|
1039
|
+
methodFqn?: string;
|
|
1040
|
+
entityFqdn?: string;
|
|
1041
|
+
packageName?: string;
|
|
1042
|
+
};
|
|
1043
|
+
type BuildRESTFunction$4<T extends RESTFunctionDescriptor$4> = T extends RESTFunctionDescriptor$4<infer U> ? U : never;
|
|
1044
|
+
type EventDefinition$4<Payload = unknown, Type extends string = string> = {
|
|
1045
|
+
__type: 'event-definition';
|
|
1046
|
+
type: Type;
|
|
1047
|
+
isDomainEvent?: boolean;
|
|
1048
|
+
transformations?: (envelope: unknown) => Payload;
|
|
1049
|
+
__payload: Payload;
|
|
1050
|
+
};
|
|
1051
|
+
declare function EventDefinition$4<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$4<Payload, Type>;
|
|
1052
|
+
type EventHandler$4<T extends EventDefinition$4> = (payload: T['__payload']) => void | Promise<void>;
|
|
1053
|
+
type BuildEventDefinition$4<T extends EventDefinition$4<any, string>> = (handler: EventHandler$4<T>) => void;
|
|
1054
|
+
|
|
1055
|
+
type ServicePluginMethodInput$4 = {
|
|
1056
|
+
request: any;
|
|
1057
|
+
metadata: any;
|
|
1058
|
+
};
|
|
1059
|
+
type ServicePluginContract$4 = Record<string, (payload: ServicePluginMethodInput$4) => unknown | Promise<unknown>>;
|
|
1060
|
+
type ServicePluginMethodMetadata$4 = {
|
|
1061
|
+
name: string;
|
|
1062
|
+
primaryHttpMappingPath: string;
|
|
1063
|
+
transformations: {
|
|
1064
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$4;
|
|
1065
|
+
toREST: (...args: unknown[]) => unknown;
|
|
1066
|
+
};
|
|
1067
|
+
};
|
|
1068
|
+
type ServicePluginDefinition$4<Contract extends ServicePluginContract$4> = {
|
|
1069
|
+
__type: 'service-plugin-definition';
|
|
1070
|
+
componentType: string;
|
|
1071
|
+
methods: ServicePluginMethodMetadata$4[];
|
|
1072
|
+
__contract: Contract;
|
|
1073
|
+
};
|
|
1074
|
+
declare function ServicePluginDefinition$4<Contract extends ServicePluginContract$4>(componentType: string, methods: ServicePluginMethodMetadata$4[]): ServicePluginDefinition$4<Contract>;
|
|
1075
|
+
type BuildServicePluginDefinition$4<T extends ServicePluginDefinition$4<any>> = (implementation: T['__contract']) => void;
|
|
1076
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$4 = "wix_spi_error";
|
|
1077
|
+
|
|
1078
|
+
type RequestContext$4 = {
|
|
1079
|
+
isSSR: boolean;
|
|
1080
|
+
host: string;
|
|
1081
|
+
protocol?: string;
|
|
1082
|
+
};
|
|
1083
|
+
type ResponseTransformer$4 = (data: any, headers?: any) => any;
|
|
1084
|
+
/**
|
|
1085
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
1086
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
1087
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
1088
|
+
*/
|
|
1089
|
+
type Method$4 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
1090
|
+
type AmbassadorRequestOptions$4<T = any> = {
|
|
1091
|
+
_?: T;
|
|
1092
|
+
url?: string;
|
|
1093
|
+
method?: Method$4;
|
|
1094
|
+
params?: any;
|
|
1095
|
+
data?: any;
|
|
1096
|
+
transformResponse?: ResponseTransformer$4 | ResponseTransformer$4[];
|
|
1097
|
+
};
|
|
1098
|
+
type AmbassadorFactory$4<Request, Response> = (payload: Request) => ((context: RequestContext$4) => AmbassadorRequestOptions$4<Response>) & {
|
|
1099
|
+
__isAmbassador: boolean;
|
|
1100
|
+
};
|
|
1101
|
+
type AmbassadorFunctionDescriptor$4<Request = any, Response = any> = AmbassadorFactory$4<Request, Response>;
|
|
1102
|
+
type BuildAmbassadorFunction$4<T extends AmbassadorFunctionDescriptor$4> = T extends AmbassadorFunctionDescriptor$4<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
1103
|
+
|
|
1104
|
+
declare global {
|
|
1105
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
1106
|
+
interface SymbolConstructor {
|
|
1107
|
+
readonly observable: symbol;
|
|
1108
|
+
}
|
|
986
1109
|
}
|
|
987
|
-
|
|
1110
|
+
|
|
1111
|
+
declare const emptyObjectSymbol$4: unique symbol;
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
1115
|
+
|
|
1116
|
+
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)).
|
|
1117
|
+
|
|
1118
|
+
@example
|
|
1119
|
+
```
|
|
1120
|
+
import type {EmptyObject} from 'type-fest';
|
|
1121
|
+
|
|
1122
|
+
// The following illustrates the problem with `{}`.
|
|
1123
|
+
const foo1: {} = {}; // Pass
|
|
1124
|
+
const foo2: {} = []; // Pass
|
|
1125
|
+
const foo3: {} = 42; // Pass
|
|
1126
|
+
const foo4: {} = {a: 1}; // Pass
|
|
1127
|
+
|
|
1128
|
+
// With `EmptyObject` only the first case is valid.
|
|
1129
|
+
const bar1: EmptyObject = {}; // Pass
|
|
1130
|
+
const bar2: EmptyObject = 42; // Fail
|
|
1131
|
+
const bar3: EmptyObject = []; // Fail
|
|
1132
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
1133
|
+
```
|
|
1134
|
+
|
|
1135
|
+
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}.
|
|
1136
|
+
|
|
1137
|
+
@category Object
|
|
1138
|
+
*/
|
|
1139
|
+
type EmptyObject$4 = {[emptyObjectSymbol$4]?: never};
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
Returns a boolean for whether the two given types are equal.
|
|
1143
|
+
|
|
1144
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
1145
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
1146
|
+
|
|
1147
|
+
Use-cases:
|
|
1148
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
1149
|
+
|
|
1150
|
+
@example
|
|
1151
|
+
```
|
|
1152
|
+
import type {IsEqual} from 'type-fest';
|
|
1153
|
+
|
|
1154
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
1155
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
1156
|
+
type Includes<Value extends readonly any[], Item> =
|
|
1157
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
1158
|
+
? IsEqual<Value[0], Item> extends true
|
|
1159
|
+
? true
|
|
1160
|
+
: Includes<rest, Item>
|
|
1161
|
+
: false;
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
@category Type Guard
|
|
1165
|
+
@category Utilities
|
|
1166
|
+
*/
|
|
1167
|
+
type IsEqual$4<A, B> =
|
|
1168
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
1169
|
+
(<G>() => G extends B ? 1 : 2)
|
|
1170
|
+
? true
|
|
1171
|
+
: false;
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
Filter out keys from an object.
|
|
1175
|
+
|
|
1176
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
1177
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
1178
|
+
Returns `Key` otherwise.
|
|
1179
|
+
|
|
1180
|
+
@example
|
|
1181
|
+
```
|
|
1182
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
1183
|
+
//=> never
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1186
|
+
@example
|
|
1187
|
+
```
|
|
1188
|
+
type Filtered = Filter<'bar', string>;
|
|
1189
|
+
//=> never
|
|
1190
|
+
```
|
|
1191
|
+
|
|
1192
|
+
@example
|
|
1193
|
+
```
|
|
1194
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
1195
|
+
//=> 'bar'
|
|
1196
|
+
```
|
|
1197
|
+
|
|
1198
|
+
@see {Except}
|
|
1199
|
+
*/
|
|
1200
|
+
type Filter$4<KeyType, ExcludeType> = IsEqual$4<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
1201
|
+
|
|
1202
|
+
type ExceptOptions$4 = {
|
|
1203
|
+
/**
|
|
1204
|
+
Disallow assigning non-specified properties.
|
|
1205
|
+
|
|
1206
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
1207
|
+
|
|
1208
|
+
@default false
|
|
1209
|
+
*/
|
|
1210
|
+
requireExactProps?: boolean;
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
Create a type from an object type without certain keys.
|
|
1215
|
+
|
|
1216
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
1217
|
+
|
|
1218
|
+
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.
|
|
1219
|
+
|
|
1220
|
+
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)).
|
|
1221
|
+
|
|
1222
|
+
@example
|
|
1223
|
+
```
|
|
1224
|
+
import type {Except} from 'type-fest';
|
|
1225
|
+
|
|
1226
|
+
type Foo = {
|
|
1227
|
+
a: number;
|
|
1228
|
+
b: string;
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1231
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
1232
|
+
//=> {b: string}
|
|
1233
|
+
|
|
1234
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
1235
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
1236
|
+
|
|
1237
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
1238
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
1239
|
+
|
|
1240
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
1241
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
1242
|
+
```
|
|
1243
|
+
|
|
1244
|
+
@category Object
|
|
1245
|
+
*/
|
|
1246
|
+
type Except$4<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$4 = {requireExactProps: false}> = {
|
|
1247
|
+
[KeyType in keyof ObjectType as Filter$4<KeyType, KeysType>]: ObjectType[KeyType];
|
|
1248
|
+
} & (Options['requireExactProps'] extends true
|
|
1249
|
+
? Partial<Record<KeysType, never>>
|
|
1250
|
+
: {});
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
Returns a boolean for whether the given type is `never`.
|
|
1254
|
+
|
|
1255
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
1256
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
1257
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
1258
|
+
|
|
1259
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
1260
|
+
|
|
1261
|
+
@example
|
|
1262
|
+
```
|
|
1263
|
+
import type {IsNever, And} from 'type-fest';
|
|
1264
|
+
|
|
1265
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
1266
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
1267
|
+
And<
|
|
1268
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
1269
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
1270
|
+
>;
|
|
1271
|
+
|
|
1272
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
1273
|
+
AreStringsEqual<I, O> extends true
|
|
1274
|
+
? never
|
|
1275
|
+
: void;
|
|
1276
|
+
|
|
1277
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
1278
|
+
if (input === output) {
|
|
1279
|
+
process.exit(0);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
endIfEqual('abc', 'abc');
|
|
1284
|
+
//=> never
|
|
1285
|
+
|
|
1286
|
+
endIfEqual('abc', '123');
|
|
1287
|
+
//=> void
|
|
1288
|
+
```
|
|
1289
|
+
|
|
1290
|
+
@category Type Guard
|
|
1291
|
+
@category Utilities
|
|
1292
|
+
*/
|
|
1293
|
+
type IsNever$4<T> = [T] extends [never] ? true : false;
|
|
1294
|
+
|
|
1295
|
+
/**
|
|
1296
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
1297
|
+
|
|
1298
|
+
@see {@link IsNever}
|
|
1299
|
+
|
|
1300
|
+
@example
|
|
1301
|
+
```
|
|
1302
|
+
import type {IfNever} from 'type-fest';
|
|
1303
|
+
|
|
1304
|
+
type ShouldBeTrue = IfNever<never>;
|
|
1305
|
+
//=> true
|
|
1306
|
+
|
|
1307
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
1308
|
+
//=> 'bar'
|
|
1309
|
+
```
|
|
1310
|
+
|
|
1311
|
+
@category Type Guard
|
|
1312
|
+
@category Utilities
|
|
1313
|
+
*/
|
|
1314
|
+
type IfNever$4<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
1315
|
+
IsNever$4<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
1316
|
+
);
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
1320
|
+
|
|
1321
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
1322
|
+
|
|
1323
|
+
@example
|
|
1324
|
+
```
|
|
1325
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1326
|
+
|
|
1327
|
+
interface Example {
|
|
1328
|
+
a: string;
|
|
1329
|
+
b: string | number;
|
|
1330
|
+
c?: string;
|
|
1331
|
+
d: {};
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
1335
|
+
//=> 'a'
|
|
1336
|
+
```
|
|
1337
|
+
|
|
1338
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
1339
|
+
|
|
1340
|
+
@example
|
|
1341
|
+
```
|
|
1342
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1343
|
+
|
|
1344
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
1345
|
+
//=> 'a' | 'c'
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
@category Object
|
|
1349
|
+
*/
|
|
1350
|
+
type ConditionalKeys$4<Base, Condition> =
|
|
1351
|
+
{
|
|
1352
|
+
// Map through all the keys of the given base type.
|
|
1353
|
+
[Key in keyof Base]-?:
|
|
1354
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
1355
|
+
Base[Key] extends Condition
|
|
1356
|
+
// Retain this key
|
|
1357
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
1358
|
+
? IfNever$4<Base[Key], IfNever$4<Condition, Key, never>, Key>
|
|
1359
|
+
// Discard this key since the condition fails.
|
|
1360
|
+
: never;
|
|
1361
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
1362
|
+
}[keyof Base];
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
1366
|
+
|
|
1367
|
+
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.
|
|
1368
|
+
|
|
1369
|
+
@example
|
|
1370
|
+
```
|
|
1371
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
1372
|
+
|
|
1373
|
+
class Awesome {
|
|
1374
|
+
name: string;
|
|
1375
|
+
successes: number;
|
|
1376
|
+
failures: bigint;
|
|
1377
|
+
|
|
1378
|
+
run() {}
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
1382
|
+
//=> {run: () => void}
|
|
1383
|
+
```
|
|
1384
|
+
|
|
1385
|
+
@example
|
|
1386
|
+
```
|
|
1387
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
1388
|
+
|
|
1389
|
+
interface Example {
|
|
1390
|
+
a: string;
|
|
1391
|
+
b: string | number;
|
|
1392
|
+
c: () => void;
|
|
1393
|
+
d: {};
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
1397
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
1398
|
+
```
|
|
1399
|
+
|
|
1400
|
+
@category Object
|
|
1401
|
+
*/
|
|
1402
|
+
type ConditionalExcept$4<Base, Condition> = Except$4<
|
|
1403
|
+
Base,
|
|
1404
|
+
ConditionalKeys$4<Base, Condition>
|
|
1405
|
+
>;
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
1409
|
+
* can either be a REST module or a host module.
|
|
1410
|
+
* This type is recursive, so it can describe nested modules.
|
|
1411
|
+
*/
|
|
1412
|
+
type Descriptors$4 = RESTFunctionDescriptor$4 | AmbassadorFunctionDescriptor$4 | HostModule$4<any, any> | EventDefinition$4<any> | ServicePluginDefinition$4<any> | {
|
|
1413
|
+
[key: string]: Descriptors$4 | PublicMetadata$4 | any;
|
|
1414
|
+
};
|
|
1415
|
+
/**
|
|
1416
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
1417
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
1418
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
1419
|
+
* do not match the given host (as they will not work with the given host).
|
|
1420
|
+
*/
|
|
1421
|
+
type BuildDescriptors$4<T extends Descriptors$4, H extends Host$4<any> | undefined, Depth extends number = 5> = {
|
|
1422
|
+
done: T;
|
|
1423
|
+
recurse: T extends {
|
|
1424
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$4;
|
|
1425
|
+
} ? never : T extends AmbassadorFunctionDescriptor$4 ? BuildAmbassadorFunction$4<T> : T extends RESTFunctionDescriptor$4 ? BuildRESTFunction$4<T> : T extends EventDefinition$4<any> ? BuildEventDefinition$4<T> : T extends ServicePluginDefinition$4<any> ? BuildServicePluginDefinition$4<T> : T extends HostModule$4<any, any> ? HostModuleAPI$4<T> : ConditionalExcept$4<{
|
|
1426
|
+
[Key in keyof T]: T[Key] extends Descriptors$4 ? BuildDescriptors$4<T[Key], H, [
|
|
1427
|
+
-1,
|
|
1428
|
+
0,
|
|
1429
|
+
1,
|
|
1430
|
+
2,
|
|
1431
|
+
3,
|
|
1432
|
+
4,
|
|
1433
|
+
5
|
|
1434
|
+
][Depth]> : never;
|
|
1435
|
+
}, EmptyObject$4>;
|
|
1436
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
1437
|
+
type PublicMetadata$4 = {
|
|
1438
|
+
PACKAGE_NAME?: string;
|
|
1439
|
+
};
|
|
1440
|
+
|
|
1441
|
+
declare global {
|
|
1442
|
+
interface ContextualClient {
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* A type used to create concerete types from SDK descriptors in
|
|
1447
|
+
* case a contextual client is available.
|
|
1448
|
+
*/
|
|
1449
|
+
type MaybeContext$4<T extends Descriptors$4> = globalThis.ContextualClient extends {
|
|
1450
|
+
host: Host$4;
|
|
1451
|
+
} ? BuildDescriptors$4<T, globalThis.ContextualClient['host']> : T;
|
|
1452
|
+
|
|
1453
|
+
interface PublishedContent {
|
|
1454
|
+
/**
|
|
1455
|
+
* Published content ID.
|
|
1456
|
+
* @readonly
|
|
1457
|
+
*/
|
|
1458
|
+
_id?: string | null;
|
|
1459
|
+
/** Schema key of the published content. */
|
|
1460
|
+
schemaKey?: SchemaKey$1;
|
|
1461
|
+
/**
|
|
1462
|
+
* A unique identifier defined by the app developer to differentiate translation content for various entities within the site. For example, if an app developer is creating translation content for blog posts, the `entityId` can be `'blog-posts-1'`.
|
|
1463
|
+
* @readonly
|
|
1464
|
+
*/
|
|
1465
|
+
entityId?: string;
|
|
1466
|
+
/**
|
|
1467
|
+
* Published content locale.
|
|
1468
|
+
* @readonly
|
|
1469
|
+
*/
|
|
1470
|
+
locale?: string;
|
|
1471
|
+
/** List of fields that have been translated and published for the given locale. */
|
|
1472
|
+
fields?: PublishedContentField[];
|
|
1473
|
+
/** A reference to the parent content. For example, if the content is a menu item, this property would contain the `entityId` of the menu it belongs to. */
|
|
1474
|
+
parentEntityId?: string | null;
|
|
1475
|
+
/** Custom field data for the published content object. */
|
|
1476
|
+
extendedFields?: ExtendedFields;
|
|
1477
|
+
}
|
|
1478
|
+
interface SchemaKey$1 {
|
|
1479
|
+
/**
|
|
1480
|
+
* ID of the app that created the schema.
|
|
1481
|
+
* @readonly
|
|
1482
|
+
*/
|
|
1483
|
+
appId?: string;
|
|
1484
|
+
/** A unique name defined by the app developer to differentiate translation schemas for various entities within their app. For example, if an app developer is creating a translation schema for blog posts, the `entityType` can be `'blog-posts'`. */
|
|
1485
|
+
entityType?: string;
|
|
1486
|
+
/**
|
|
1487
|
+
* Scope of the translation schema.
|
|
1488
|
+
* Supported values:
|
|
1489
|
+
* + `GLOBAL`: A global schema for all sites.
|
|
1490
|
+
* + `SITE`: A custom schema for a specific site.
|
|
1491
|
+
*/
|
|
1492
|
+
scope?: SchemaScope$1;
|
|
1493
|
+
}
|
|
1494
|
+
declare enum SchemaScope$1 {
|
|
1495
|
+
UNKNOWN_SCOPE = "UNKNOWN_SCOPE",
|
|
1496
|
+
/** Global schema, relevant to all sites */
|
|
1497
|
+
GLOBAL = "GLOBAL",
|
|
1498
|
+
/** Site schema, relevant to specific site only */
|
|
1499
|
+
SITE = "SITE"
|
|
1500
|
+
}
|
|
1501
|
+
interface PublishedContentField extends PublishedContentFieldValueOneOf {
|
|
1502
|
+
/** Plain text. */
|
|
1503
|
+
textValue?: string;
|
|
1504
|
+
/** Rich content. */
|
|
1505
|
+
richContent?: RichContent$2;
|
|
1506
|
+
/** Wix Media Manager image. */
|
|
1507
|
+
image?: string;
|
|
1508
|
+
/** Wix Media Manager video. */
|
|
1509
|
+
video?: string;
|
|
1510
|
+
/** Wix Media Manager document. */
|
|
1511
|
+
document?: string;
|
|
1512
|
+
/**
|
|
1513
|
+
* Unique string identifier that links a specific content field to its corresponding field in the schema.
|
|
1514
|
+
* @readonly
|
|
1515
|
+
*/
|
|
1516
|
+
schemaFieldKey?: string;
|
|
1517
|
+
/** For repeated fields. Contains the IDs of the messages linked to this field. */
|
|
1518
|
+
sequenceIds?: string[];
|
|
1519
|
+
}
|
|
1520
|
+
/** @oneof */
|
|
1521
|
+
interface PublishedContentFieldValueOneOf {
|
|
1522
|
+
/** Plain text. */
|
|
1523
|
+
textValue?: string;
|
|
1524
|
+
/** Rich content. */
|
|
1525
|
+
richContent?: RichContent$2;
|
|
1526
|
+
/** Wix Media Manager image. */
|
|
1527
|
+
image?: string;
|
|
1528
|
+
/** Wix Media Manager video. */
|
|
1529
|
+
video?: string;
|
|
1530
|
+
/** Wix Media Manager document. */
|
|
1531
|
+
document?: string;
|
|
1532
|
+
}
|
|
1533
|
+
interface RichContent$2 {
|
|
988
1534
|
/** Node objects representing a rich content document. */
|
|
989
1535
|
nodes?: Node$2[];
|
|
990
1536
|
/** Object metadata. */
|
|
@@ -2815,7 +3361,7 @@ interface PublishedContentQueryBuilder {
|
|
|
2815
3361
|
find: () => Promise<PublishedContentQueryResult>;
|
|
2816
3362
|
}
|
|
2817
3363
|
|
|
2818
|
-
declare function queryPublishedContent$1(httpClient: HttpClient): QueryPublishedContentSignature;
|
|
3364
|
+
declare function queryPublishedContent$1(httpClient: HttpClient$4): QueryPublishedContentSignature;
|
|
2819
3365
|
interface QueryPublishedContentSignature {
|
|
2820
3366
|
/**
|
|
2821
3367
|
* Creates a query to retrieve a list of translation content items.
|
|
@@ -2841,20 +3387,185 @@ interface QueryPublishedContentSignature {
|
|
|
2841
3387
|
*/
|
|
2842
3388
|
(): PublishedContentQueryBuilder;
|
|
2843
3389
|
}
|
|
2844
|
-
declare const onPublishedContentCreated$1: EventDefinition$
|
|
2845
|
-
declare const onPublishedContentUpdated$1: EventDefinition$
|
|
2846
|
-
declare const onPublishedContentDeleted$1: EventDefinition$
|
|
3390
|
+
declare const onPublishedContentCreated$1: EventDefinition$4<PublishedContentCreatedEnvelope, "wix.multilingual.localization_public.v3.published_content_created">;
|
|
3391
|
+
declare const onPublishedContentUpdated$1: EventDefinition$4<PublishedContentUpdatedEnvelope, "wix.multilingual.localization_public.v3.published_content_updated">;
|
|
3392
|
+
declare const onPublishedContentDeleted$1: EventDefinition$4<PublishedContentDeletedEnvelope, "wix.multilingual.localization_public.v3.published_content_deleted">;
|
|
2847
3393
|
|
|
2848
|
-
|
|
3394
|
+
declare function createEventModule$2<T extends EventDefinition$4<any, string>>(eventDefinition: T): BuildEventDefinition$4<T> & T;
|
|
3395
|
+
|
|
3396
|
+
declare const queryPublishedContent: MaybeContext$4<BuildRESTFunction$4<typeof queryPublishedContent$1> & typeof queryPublishedContent$1>;
|
|
3397
|
+
|
|
3398
|
+
type _publicOnPublishedContentCreatedType = typeof onPublishedContentCreated$1;
|
|
3399
|
+
/**
|
|
3400
|
+
* Triggered when published content is created.
|
|
3401
|
+
*/
|
|
3402
|
+
declare const onPublishedContentCreated: ReturnType<typeof createEventModule$2<_publicOnPublishedContentCreatedType>>;
|
|
3403
|
+
|
|
3404
|
+
type _publicOnPublishedContentUpdatedType = typeof onPublishedContentUpdated$1;
|
|
3405
|
+
/**
|
|
3406
|
+
* Triggered when published content is updated.
|
|
3407
|
+
*/
|
|
3408
|
+
declare const onPublishedContentUpdated: ReturnType<typeof createEventModule$2<_publicOnPublishedContentUpdatedType>>;
|
|
3409
|
+
|
|
3410
|
+
type _publicOnPublishedContentDeletedType = typeof onPublishedContentDeleted$1;
|
|
3411
|
+
/**
|
|
3412
|
+
* Triggered when published content is deleted.
|
|
3413
|
+
*/
|
|
3414
|
+
declare const onPublishedContentDeleted: ReturnType<typeof createEventModule$2<_publicOnPublishedContentDeletedType>>;
|
|
3415
|
+
|
|
3416
|
+
type context$4_ExtendedFields = ExtendedFields;
|
|
3417
|
+
type context$4_GetPublishedContentRequest = GetPublishedContentRequest;
|
|
3418
|
+
type context$4_GetPublishedContentResponse = GetPublishedContentResponse;
|
|
3419
|
+
type context$4_PublishedContent = PublishedContent;
|
|
3420
|
+
type context$4_PublishedContentCreatedEnvelope = PublishedContentCreatedEnvelope;
|
|
3421
|
+
type context$4_PublishedContentDeletedEnvelope = PublishedContentDeletedEnvelope;
|
|
3422
|
+
type context$4_PublishedContentField = PublishedContentField;
|
|
3423
|
+
type context$4_PublishedContentFieldValueOneOf = PublishedContentFieldValueOneOf;
|
|
3424
|
+
type context$4_PublishedContentQueryBuilder = PublishedContentQueryBuilder;
|
|
3425
|
+
type context$4_PublishedContentQueryResult = PublishedContentQueryResult;
|
|
3426
|
+
type context$4_PublishedContentUpdatedEnvelope = PublishedContentUpdatedEnvelope;
|
|
3427
|
+
type context$4_QueryPublishedContentRequest = QueryPublishedContentRequest;
|
|
3428
|
+
type context$4_QueryPublishedContentResponse = QueryPublishedContentResponse;
|
|
3429
|
+
type context$4_QueryPublishedContentResponseNonNullableFields = QueryPublishedContentResponseNonNullableFields;
|
|
3430
|
+
type context$4__publicOnPublishedContentCreatedType = _publicOnPublishedContentCreatedType;
|
|
3431
|
+
type context$4__publicOnPublishedContentDeletedType = _publicOnPublishedContentDeletedType;
|
|
3432
|
+
type context$4__publicOnPublishedContentUpdatedType = _publicOnPublishedContentUpdatedType;
|
|
3433
|
+
declare const context$4_onPublishedContentCreated: typeof onPublishedContentCreated;
|
|
3434
|
+
declare const context$4_onPublishedContentDeleted: typeof onPublishedContentDeleted;
|
|
3435
|
+
declare const context$4_onPublishedContentUpdated: typeof onPublishedContentUpdated;
|
|
3436
|
+
declare const context$4_queryPublishedContent: typeof queryPublishedContent;
|
|
3437
|
+
declare namespace context$4 {
|
|
3438
|
+
export { type ActionEvent$2 as ActionEvent, Alignment$2 as Alignment, type AnchorData$2 as AnchorData, type AppEmbedData$2 as AppEmbedData, type AppEmbedDataAppDataOneOf$2 as AppEmbedDataAppDataOneOf, AppType$2 as AppType, type AudioData$2 as AudioData, type Background$2 as Background, type BackgroundBackgroundOneOf$2 as BackgroundBackgroundOneOf, BackgroundType$2 as BackgroundType, type BaseEventMetadata$2 as BaseEventMetadata, type BlockquoteData$2 as BlockquoteData, type BookingData$2 as BookingData, type Border$2 as Border, type BorderColors$2 as BorderColors, type BulletedListData$2 as BulletedListData, type ButtonData$2 as ButtonData, type CellStyle$2 as CellStyle, type CodeBlockData$2 as CodeBlockData, type CollapsibleListData$2 as CollapsibleListData, type ColorData$2 as ColorData, type Colors$2 as Colors, Crop$2 as Crop, type CursorPaging$2 as CursorPaging, type CursorPagingMetadata$2 as CursorPagingMetadata, type CursorQuery$2 as CursorQuery, type CursorQueryPagingMethodOneOf$2 as CursorQueryPagingMethodOneOf, type Cursors$2 as Cursors, type Decoration$2 as Decoration, type DecorationDataOneOf$2 as DecorationDataOneOf, DecorationType$2 as DecorationType, type Design$2 as Design, type Dimensions$2 as Dimensions, Direction$2 as Direction, type DividerData$2 as DividerData, type DocumentStyle$2 as DocumentStyle, type DomainEvent$2 as DomainEvent, type DomainEventBodyOneOf$2 as DomainEventBodyOneOf, type EmbedData$2 as EmbedData, type EntityCreatedEvent$2 as EntityCreatedEvent, type EntityDeletedEvent$2 as EntityDeletedEvent, type EntityUpdatedEvent$2 as EntityUpdatedEvent, type EventData$2 as EventData, type EventMetadata$2 as EventMetadata, type context$4_ExtendedFields as ExtendedFields, type FileData$2 as FileData, type FileSource$2 as FileSource, type FileSourceDataOneOf$2 as FileSourceDataOneOf, type FontSizeData$2 as FontSizeData, FontType$2 as FontType, type GIF$2 as GIF, type GIFData$2 as GIFData, type GalleryData$2 as GalleryData, type GalleryOptions$2 as GalleryOptions, type context$4_GetPublishedContentRequest as GetPublishedContentRequest, type context$4_GetPublishedContentResponse as GetPublishedContentResponse, type Gradient$2 as Gradient, type HTMLData$2 as HTMLData, type HTMLDataDataOneOf$2 as HTMLDataDataOneOf, type HeadingData$2 as HeadingData, type Height$2 as Height, type IdentificationData$2 as IdentificationData, type IdentificationDataIdOneOf$2 as IdentificationDataIdOneOf, type Image$2 as Image, type ImageData$2 as ImageData, InitialExpandedItems$2 as InitialExpandedItems, type Item$2 as Item, type ItemDataOneOf$2 as ItemDataOneOf, type ItemStyle$2 as ItemStyle, type Layout$2 as Layout, LayoutType$2 as LayoutType, LineStyle$2 as LineStyle, type Link$2 as Link, type LinkData$2 as LinkData, type LinkDataOneOf$2 as LinkDataOneOf, type LinkPreviewData$2 as LinkPreviewData, type ListValue$2 as ListValue, type MapData$2 as MapData, type MapSettings$2 as MapSettings, MapType$2 as MapType, type Media$2 as Media, type MentionData$2 as MentionData, type MessageEnvelope$2 as MessageEnvelope, type Metadata$2 as Metadata, type Node$2 as Node, type NodeDataOneOf$2 as NodeDataOneOf, type NodeStyle$2 as NodeStyle, NodeType$2 as NodeType, NullValue$2 as NullValue, type Oembed$2 as Oembed, type Option$2 as Option, type OptionDesign$2 as OptionDesign, type OptionLayout$2 as OptionLayout, type OrderedListData$2 as OrderedListData, Orientation$2 as Orientation, type PDFSettings$2 as PDFSettings, type ParagraphData$2 as ParagraphData, type Permissions$2 as Permissions, type PlaybackOptions$2 as PlaybackOptions, type PluginContainerData$2 as PluginContainerData, PluginContainerDataAlignment$2 as PluginContainerDataAlignment, type PluginContainerDataWidth$2 as PluginContainerDataWidth, type PluginContainerDataWidthDataOneOf$2 as PluginContainerDataWidthDataOneOf, type Poll$2 as Poll, type PollData$2 as PollData, type PollDataLayout$2 as PollDataLayout, type PollDesign$2 as PollDesign, type PollLayout$2 as PollLayout, PollLayoutDirection$2 as PollLayoutDirection, PollLayoutType$2 as PollLayoutType, type context$4_PublishedContent as PublishedContent, type context$4_PublishedContentCreatedEnvelope as PublishedContentCreatedEnvelope, type context$4_PublishedContentDeletedEnvelope as PublishedContentDeletedEnvelope, type context$4_PublishedContentField as PublishedContentField, type context$4_PublishedContentFieldValueOneOf as PublishedContentFieldValueOneOf, type context$4_PublishedContentQueryBuilder as PublishedContentQueryBuilder, type context$4_PublishedContentQueryResult as PublishedContentQueryResult, type context$4_PublishedContentUpdatedEnvelope as PublishedContentUpdatedEnvelope, type context$4_QueryPublishedContentRequest as QueryPublishedContentRequest, type context$4_QueryPublishedContentResponse as QueryPublishedContentResponse, type context$4_QueryPublishedContentResponseNonNullableFields as QueryPublishedContentResponseNonNullableFields, type Rel$2 as Rel, type RestoreInfo$2 as RestoreInfo, type RichContent$2 as RichContent, type SchemaKey$1 as SchemaKey, SchemaScope$1 as SchemaScope, type Settings$2 as Settings, SortOrder$2 as SortOrder, type Sorting$2 as Sorting, Source$2 as Source, type Spoiler$2 as Spoiler, type SpoilerData$2 as SpoilerData, type Styles$2 as Styles, type TableCellData$2 as TableCellData, type TableData$2 as TableData, Target$2 as Target, TextAlignment$2 as TextAlignment, type TextData$2 as TextData, type TextNodeStyle$2 as TextNodeStyle, type TextStyle$2 as TextStyle, type Thumbnails$2 as Thumbnails, ThumbnailsAlignment$2 as ThumbnailsAlignment, Type$2 as Type, VerticalAlignment$2 as VerticalAlignment, type Video$2 as Video, type VideoData$2 as VideoData, type VideoResolution$1 as VideoResolution, ViewMode$2 as ViewMode, ViewRole$2 as ViewRole, VoteRole$2 as VoteRole, WebhookIdentityType$2 as WebhookIdentityType, Width$2 as Width, WidthType$2 as WidthType, type context$4__publicOnPublishedContentCreatedType as _publicOnPublishedContentCreatedType, type context$4__publicOnPublishedContentDeletedType as _publicOnPublishedContentDeletedType, type context$4__publicOnPublishedContentUpdatedType as _publicOnPublishedContentUpdatedType, context$4_onPublishedContentCreated as onPublishedContentCreated, context$4_onPublishedContentDeleted as onPublishedContentDeleted, context$4_onPublishedContentUpdated as onPublishedContentUpdated, onPublishedContentCreated$1 as publicOnPublishedContentCreated, onPublishedContentDeleted$1 as publicOnPublishedContentDeleted, onPublishedContentUpdated$1 as publicOnPublishedContentUpdated, context$4_queryPublishedContent as queryPublishedContent };
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3441
|
+
type HostModule$3<T, H extends Host$3> = {
|
|
3442
|
+
__type: 'host';
|
|
3443
|
+
create(host: H): T;
|
|
3444
|
+
};
|
|
3445
|
+
type HostModuleAPI$3<T extends HostModule$3<any, any>> = T extends HostModule$3<infer U, any> ? U : never;
|
|
3446
|
+
type Host$3<Environment = unknown> = {
|
|
3447
|
+
channel: {
|
|
3448
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
3449
|
+
disconnect: () => void;
|
|
3450
|
+
} | Promise<{
|
|
3451
|
+
disconnect: () => void;
|
|
3452
|
+
}>;
|
|
3453
|
+
};
|
|
3454
|
+
environment?: Environment;
|
|
3455
|
+
/**
|
|
3456
|
+
* Optional name of the environment, use for logging
|
|
3457
|
+
*/
|
|
3458
|
+
name?: string;
|
|
3459
|
+
/**
|
|
3460
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
3461
|
+
*/
|
|
3462
|
+
apiBaseUrl?: string;
|
|
3463
|
+
/**
|
|
3464
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
3465
|
+
* like internationalization, billing, etc.
|
|
3466
|
+
*/
|
|
3467
|
+
essentials?: {
|
|
3468
|
+
/**
|
|
3469
|
+
* The language of the currently viewed session
|
|
3470
|
+
*/
|
|
3471
|
+
language?: string;
|
|
3472
|
+
/**
|
|
3473
|
+
* The locale of the currently viewed session
|
|
3474
|
+
*/
|
|
3475
|
+
locale?: string;
|
|
3476
|
+
/**
|
|
3477
|
+
* Any headers that should be passed through to the API requests
|
|
3478
|
+
*/
|
|
3479
|
+
passThroughHeaders?: Record<string, string>;
|
|
3480
|
+
};
|
|
3481
|
+
};
|
|
3482
|
+
|
|
3483
|
+
type RESTFunctionDescriptor$3<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$3) => T;
|
|
3484
|
+
interface HttpClient$3 {
|
|
3485
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$3<TResponse, TData>): Promise<HttpResponse$3<TResponse>>;
|
|
3486
|
+
fetchWithAuth: typeof fetch;
|
|
3487
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
3488
|
+
getActiveToken?: () => string | undefined;
|
|
3489
|
+
}
|
|
3490
|
+
type RequestOptionsFactory$3<TResponse = any, TData = any> = (context: any) => RequestOptions$3<TResponse, TData>;
|
|
3491
|
+
type HttpResponse$3<T = any> = {
|
|
3492
|
+
data: T;
|
|
3493
|
+
status: number;
|
|
3494
|
+
statusText: string;
|
|
3495
|
+
headers: any;
|
|
3496
|
+
request?: any;
|
|
3497
|
+
};
|
|
3498
|
+
type RequestOptions$3<_TResponse = any, Data = any> = {
|
|
3499
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
3500
|
+
url: string;
|
|
3501
|
+
data?: Data;
|
|
3502
|
+
params?: URLSearchParams;
|
|
3503
|
+
} & APIMetadata$3;
|
|
3504
|
+
type APIMetadata$3 = {
|
|
3505
|
+
methodFqn?: string;
|
|
3506
|
+
entityFqdn?: string;
|
|
3507
|
+
packageName?: string;
|
|
3508
|
+
};
|
|
3509
|
+
type BuildRESTFunction$3<T extends RESTFunctionDescriptor$3> = T extends RESTFunctionDescriptor$3<infer U> ? U : never;
|
|
3510
|
+
type EventDefinition$3<Payload = unknown, Type extends string = string> = {
|
|
2849
3511
|
__type: 'event-definition';
|
|
2850
3512
|
type: Type;
|
|
2851
3513
|
isDomainEvent?: boolean;
|
|
2852
3514
|
transformations?: (envelope: unknown) => Payload;
|
|
2853
3515
|
__payload: Payload;
|
|
2854
3516
|
};
|
|
2855
|
-
declare function EventDefinition$
|
|
2856
|
-
type EventHandler$
|
|
2857
|
-
type BuildEventDefinition$
|
|
3517
|
+
declare function EventDefinition$3<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$3<Payload, Type>;
|
|
3518
|
+
type EventHandler$3<T extends EventDefinition$3> = (payload: T['__payload']) => void | Promise<void>;
|
|
3519
|
+
type BuildEventDefinition$3<T extends EventDefinition$3<any, string>> = (handler: EventHandler$3<T>) => void;
|
|
3520
|
+
|
|
3521
|
+
type ServicePluginMethodInput$3 = {
|
|
3522
|
+
request: any;
|
|
3523
|
+
metadata: any;
|
|
3524
|
+
};
|
|
3525
|
+
type ServicePluginContract$3 = Record<string, (payload: ServicePluginMethodInput$3) => unknown | Promise<unknown>>;
|
|
3526
|
+
type ServicePluginMethodMetadata$3 = {
|
|
3527
|
+
name: string;
|
|
3528
|
+
primaryHttpMappingPath: string;
|
|
3529
|
+
transformations: {
|
|
3530
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$3;
|
|
3531
|
+
toREST: (...args: unknown[]) => unknown;
|
|
3532
|
+
};
|
|
3533
|
+
};
|
|
3534
|
+
type ServicePluginDefinition$3<Contract extends ServicePluginContract$3> = {
|
|
3535
|
+
__type: 'service-plugin-definition';
|
|
3536
|
+
componentType: string;
|
|
3537
|
+
methods: ServicePluginMethodMetadata$3[];
|
|
3538
|
+
__contract: Contract;
|
|
3539
|
+
};
|
|
3540
|
+
declare function ServicePluginDefinition$3<Contract extends ServicePluginContract$3>(componentType: string, methods: ServicePluginMethodMetadata$3[]): ServicePluginDefinition$3<Contract>;
|
|
3541
|
+
type BuildServicePluginDefinition$3<T extends ServicePluginDefinition$3<any>> = (implementation: T['__contract']) => void;
|
|
3542
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$3 = "wix_spi_error";
|
|
3543
|
+
|
|
3544
|
+
type RequestContext$3 = {
|
|
3545
|
+
isSSR: boolean;
|
|
3546
|
+
host: string;
|
|
3547
|
+
protocol?: string;
|
|
3548
|
+
};
|
|
3549
|
+
type ResponseTransformer$3 = (data: any, headers?: any) => any;
|
|
3550
|
+
/**
|
|
3551
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
3552
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
3553
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
3554
|
+
*/
|
|
3555
|
+
type Method$3 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
3556
|
+
type AmbassadorRequestOptions$3<T = any> = {
|
|
3557
|
+
_?: T;
|
|
3558
|
+
url?: string;
|
|
3559
|
+
method?: Method$3;
|
|
3560
|
+
params?: any;
|
|
3561
|
+
data?: any;
|
|
3562
|
+
transformResponse?: ResponseTransformer$3 | ResponseTransformer$3[];
|
|
3563
|
+
};
|
|
3564
|
+
type AmbassadorFactory$3<Request, Response> = (payload: Request) => ((context: RequestContext$3) => AmbassadorRequestOptions$3<Response>) & {
|
|
3565
|
+
__isAmbassador: boolean;
|
|
3566
|
+
};
|
|
3567
|
+
type AmbassadorFunctionDescriptor$3<Request = any, Response = any> = AmbassadorFactory$3<Request, Response>;
|
|
3568
|
+
type BuildAmbassadorFunction$3<T extends AmbassadorFunctionDescriptor$3> = T extends AmbassadorFunctionDescriptor$3<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
2858
3569
|
|
|
2859
3570
|
declare global {
|
|
2860
3571
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -2863,52 +3574,347 @@ declare global {
|
|
|
2863
3574
|
}
|
|
2864
3575
|
}
|
|
2865
3576
|
|
|
2866
|
-
declare
|
|
3577
|
+
declare const emptyObjectSymbol$3: unique symbol;
|
|
3578
|
+
|
|
3579
|
+
/**
|
|
3580
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
3581
|
+
|
|
3582
|
+
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)).
|
|
3583
|
+
|
|
3584
|
+
@example
|
|
3585
|
+
```
|
|
3586
|
+
import type {EmptyObject} from 'type-fest';
|
|
3587
|
+
|
|
3588
|
+
// The following illustrates the problem with `{}`.
|
|
3589
|
+
const foo1: {} = {}; // Pass
|
|
3590
|
+
const foo2: {} = []; // Pass
|
|
3591
|
+
const foo3: {} = 42; // Pass
|
|
3592
|
+
const foo4: {} = {a: 1}; // Pass
|
|
3593
|
+
|
|
3594
|
+
// With `EmptyObject` only the first case is valid.
|
|
3595
|
+
const bar1: EmptyObject = {}; // Pass
|
|
3596
|
+
const bar2: EmptyObject = 42; // Fail
|
|
3597
|
+
const bar3: EmptyObject = []; // Fail
|
|
3598
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
3599
|
+
```
|
|
3600
|
+
|
|
3601
|
+
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}.
|
|
3602
|
+
|
|
3603
|
+
@category Object
|
|
3604
|
+
*/
|
|
3605
|
+
type EmptyObject$3 = {[emptyObjectSymbol$3]?: never};
|
|
3606
|
+
|
|
3607
|
+
/**
|
|
3608
|
+
Returns a boolean for whether the two given types are equal.
|
|
3609
|
+
|
|
3610
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
3611
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
3612
|
+
|
|
3613
|
+
Use-cases:
|
|
3614
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
3615
|
+
|
|
3616
|
+
@example
|
|
3617
|
+
```
|
|
3618
|
+
import type {IsEqual} from 'type-fest';
|
|
3619
|
+
|
|
3620
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
3621
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
3622
|
+
type Includes<Value extends readonly any[], Item> =
|
|
3623
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
3624
|
+
? IsEqual<Value[0], Item> extends true
|
|
3625
|
+
? true
|
|
3626
|
+
: Includes<rest, Item>
|
|
3627
|
+
: false;
|
|
3628
|
+
```
|
|
3629
|
+
|
|
3630
|
+
@category Type Guard
|
|
3631
|
+
@category Utilities
|
|
3632
|
+
*/
|
|
3633
|
+
type IsEqual$3<A, B> =
|
|
3634
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
3635
|
+
(<G>() => G extends B ? 1 : 2)
|
|
3636
|
+
? true
|
|
3637
|
+
: false;
|
|
3638
|
+
|
|
3639
|
+
/**
|
|
3640
|
+
Filter out keys from an object.
|
|
3641
|
+
|
|
3642
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
3643
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
3644
|
+
Returns `Key` otherwise.
|
|
3645
|
+
|
|
3646
|
+
@example
|
|
3647
|
+
```
|
|
3648
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
3649
|
+
//=> never
|
|
3650
|
+
```
|
|
3651
|
+
|
|
3652
|
+
@example
|
|
3653
|
+
```
|
|
3654
|
+
type Filtered = Filter<'bar', string>;
|
|
3655
|
+
//=> never
|
|
3656
|
+
```
|
|
3657
|
+
|
|
3658
|
+
@example
|
|
3659
|
+
```
|
|
3660
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
3661
|
+
//=> 'bar'
|
|
3662
|
+
```
|
|
3663
|
+
|
|
3664
|
+
@see {Except}
|
|
3665
|
+
*/
|
|
3666
|
+
type Filter$3<KeyType, ExcludeType> = IsEqual$3<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
3667
|
+
|
|
3668
|
+
type ExceptOptions$3 = {
|
|
3669
|
+
/**
|
|
3670
|
+
Disallow assigning non-specified properties.
|
|
3671
|
+
|
|
3672
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
3673
|
+
|
|
3674
|
+
@default false
|
|
3675
|
+
*/
|
|
3676
|
+
requireExactProps?: boolean;
|
|
3677
|
+
};
|
|
3678
|
+
|
|
3679
|
+
/**
|
|
3680
|
+
Create a type from an object type without certain keys.
|
|
3681
|
+
|
|
3682
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
3683
|
+
|
|
3684
|
+
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.
|
|
3685
|
+
|
|
3686
|
+
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)).
|
|
3687
|
+
|
|
3688
|
+
@example
|
|
3689
|
+
```
|
|
3690
|
+
import type {Except} from 'type-fest';
|
|
3691
|
+
|
|
3692
|
+
type Foo = {
|
|
3693
|
+
a: number;
|
|
3694
|
+
b: string;
|
|
3695
|
+
};
|
|
3696
|
+
|
|
3697
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
3698
|
+
//=> {b: string}
|
|
3699
|
+
|
|
3700
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
3701
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
3702
|
+
|
|
3703
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
3704
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
3705
|
+
|
|
3706
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
3707
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
3708
|
+
```
|
|
3709
|
+
|
|
3710
|
+
@category Object
|
|
3711
|
+
*/
|
|
3712
|
+
type Except$3<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$3 = {requireExactProps: false}> = {
|
|
3713
|
+
[KeyType in keyof ObjectType as Filter$3<KeyType, KeysType>]: ObjectType[KeyType];
|
|
3714
|
+
} & (Options['requireExactProps'] extends true
|
|
3715
|
+
? Partial<Record<KeysType, never>>
|
|
3716
|
+
: {});
|
|
3717
|
+
|
|
3718
|
+
/**
|
|
3719
|
+
Returns a boolean for whether the given type is `never`.
|
|
3720
|
+
|
|
3721
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
3722
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
3723
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
3724
|
+
|
|
3725
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
3726
|
+
|
|
3727
|
+
@example
|
|
3728
|
+
```
|
|
3729
|
+
import type {IsNever, And} from 'type-fest';
|
|
3730
|
+
|
|
3731
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
3732
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
3733
|
+
And<
|
|
3734
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
3735
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
3736
|
+
>;
|
|
3737
|
+
|
|
3738
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
3739
|
+
AreStringsEqual<I, O> extends true
|
|
3740
|
+
? never
|
|
3741
|
+
: void;
|
|
3742
|
+
|
|
3743
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
3744
|
+
if (input === output) {
|
|
3745
|
+
process.exit(0);
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
endIfEqual('abc', 'abc');
|
|
3750
|
+
//=> never
|
|
3751
|
+
|
|
3752
|
+
endIfEqual('abc', '123');
|
|
3753
|
+
//=> void
|
|
3754
|
+
```
|
|
3755
|
+
|
|
3756
|
+
@category Type Guard
|
|
3757
|
+
@category Utilities
|
|
3758
|
+
*/
|
|
3759
|
+
type IsNever$3<T> = [T] extends [never] ? true : false;
|
|
3760
|
+
|
|
3761
|
+
/**
|
|
3762
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
3763
|
+
|
|
3764
|
+
@see {@link IsNever}
|
|
3765
|
+
|
|
3766
|
+
@example
|
|
3767
|
+
```
|
|
3768
|
+
import type {IfNever} from 'type-fest';
|
|
3769
|
+
|
|
3770
|
+
type ShouldBeTrue = IfNever<never>;
|
|
3771
|
+
//=> true
|
|
3772
|
+
|
|
3773
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
3774
|
+
//=> 'bar'
|
|
3775
|
+
```
|
|
3776
|
+
|
|
3777
|
+
@category Type Guard
|
|
3778
|
+
@category Utilities
|
|
3779
|
+
*/
|
|
3780
|
+
type IfNever$3<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
3781
|
+
IsNever$3<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
3782
|
+
);
|
|
3783
|
+
|
|
3784
|
+
/**
|
|
3785
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
3786
|
+
|
|
3787
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
3788
|
+
|
|
3789
|
+
@example
|
|
3790
|
+
```
|
|
3791
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
3792
|
+
|
|
3793
|
+
interface Example {
|
|
3794
|
+
a: string;
|
|
3795
|
+
b: string | number;
|
|
3796
|
+
c?: string;
|
|
3797
|
+
d: {};
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
3801
|
+
//=> 'a'
|
|
3802
|
+
```
|
|
3803
|
+
|
|
3804
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
3805
|
+
|
|
3806
|
+
@example
|
|
3807
|
+
```
|
|
3808
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
3809
|
+
|
|
3810
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
3811
|
+
//=> 'a' | 'c'
|
|
3812
|
+
```
|
|
3813
|
+
|
|
3814
|
+
@category Object
|
|
3815
|
+
*/
|
|
3816
|
+
type ConditionalKeys$3<Base, Condition> =
|
|
3817
|
+
{
|
|
3818
|
+
// Map through all the keys of the given base type.
|
|
3819
|
+
[Key in keyof Base]-?:
|
|
3820
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
3821
|
+
Base[Key] extends Condition
|
|
3822
|
+
// Retain this key
|
|
3823
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
3824
|
+
? IfNever$3<Base[Key], IfNever$3<Condition, Key, never>, Key>
|
|
3825
|
+
// Discard this key since the condition fails.
|
|
3826
|
+
: never;
|
|
3827
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
3828
|
+
}[keyof Base];
|
|
3829
|
+
|
|
3830
|
+
/**
|
|
3831
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
3832
|
+
|
|
3833
|
+
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.
|
|
3834
|
+
|
|
3835
|
+
@example
|
|
3836
|
+
```
|
|
3837
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
3838
|
+
|
|
3839
|
+
class Awesome {
|
|
3840
|
+
name: string;
|
|
3841
|
+
successes: number;
|
|
3842
|
+
failures: bigint;
|
|
3843
|
+
|
|
3844
|
+
run() {}
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3847
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
3848
|
+
//=> {run: () => void}
|
|
3849
|
+
```
|
|
3850
|
+
|
|
3851
|
+
@example
|
|
3852
|
+
```
|
|
3853
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
3854
|
+
|
|
3855
|
+
interface Example {
|
|
3856
|
+
a: string;
|
|
3857
|
+
b: string | number;
|
|
3858
|
+
c: () => void;
|
|
3859
|
+
d: {};
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
3863
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
3864
|
+
```
|
|
2867
3865
|
|
|
2868
|
-
|
|
3866
|
+
@category Object
|
|
3867
|
+
*/
|
|
3868
|
+
type ConditionalExcept$3<Base, Condition> = Except$3<
|
|
3869
|
+
Base,
|
|
3870
|
+
ConditionalKeys$3<Base, Condition>
|
|
3871
|
+
>;
|
|
2869
3872
|
|
|
2870
|
-
type _publicOnPublishedContentCreatedType = typeof onPublishedContentCreated$1;
|
|
2871
3873
|
/**
|
|
2872
|
-
*
|
|
3874
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
3875
|
+
* can either be a REST module or a host module.
|
|
3876
|
+
* This type is recursive, so it can describe nested modules.
|
|
2873
3877
|
*/
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
3878
|
+
type Descriptors$3 = RESTFunctionDescriptor$3 | AmbassadorFunctionDescriptor$3 | HostModule$3<any, any> | EventDefinition$3<any> | ServicePluginDefinition$3<any> | {
|
|
3879
|
+
[key: string]: Descriptors$3 | PublicMetadata$3 | any;
|
|
3880
|
+
};
|
|
2877
3881
|
/**
|
|
2878
|
-
*
|
|
3882
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
3883
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
3884
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
3885
|
+
* do not match the given host (as they will not work with the given host).
|
|
2879
3886
|
*/
|
|
2880
|
-
|
|
3887
|
+
type BuildDescriptors$3<T extends Descriptors$3, H extends Host$3<any> | undefined, Depth extends number = 5> = {
|
|
3888
|
+
done: T;
|
|
3889
|
+
recurse: T extends {
|
|
3890
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$3;
|
|
3891
|
+
} ? never : T extends AmbassadorFunctionDescriptor$3 ? BuildAmbassadorFunction$3<T> : T extends RESTFunctionDescriptor$3 ? BuildRESTFunction$3<T> : T extends EventDefinition$3<any> ? BuildEventDefinition$3<T> : T extends ServicePluginDefinition$3<any> ? BuildServicePluginDefinition$3<T> : T extends HostModule$3<any, any> ? HostModuleAPI$3<T> : ConditionalExcept$3<{
|
|
3892
|
+
[Key in keyof T]: T[Key] extends Descriptors$3 ? BuildDescriptors$3<T[Key], H, [
|
|
3893
|
+
-1,
|
|
3894
|
+
0,
|
|
3895
|
+
1,
|
|
3896
|
+
2,
|
|
3897
|
+
3,
|
|
3898
|
+
4,
|
|
3899
|
+
5
|
|
3900
|
+
][Depth]> : never;
|
|
3901
|
+
}, EmptyObject$3>;
|
|
3902
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
3903
|
+
type PublicMetadata$3 = {
|
|
3904
|
+
PACKAGE_NAME?: string;
|
|
3905
|
+
};
|
|
2881
3906
|
|
|
2882
|
-
|
|
3907
|
+
declare global {
|
|
3908
|
+
interface ContextualClient {
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
2883
3911
|
/**
|
|
2884
|
-
*
|
|
3912
|
+
* A type used to create concerete types from SDK descriptors in
|
|
3913
|
+
* case a contextual client is available.
|
|
2885
3914
|
*/
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
type context$4_GetPublishedContentRequest = GetPublishedContentRequest;
|
|
2890
|
-
type context$4_GetPublishedContentResponse = GetPublishedContentResponse;
|
|
2891
|
-
type context$4_PublishedContent = PublishedContent;
|
|
2892
|
-
type context$4_PublishedContentCreatedEnvelope = PublishedContentCreatedEnvelope;
|
|
2893
|
-
type context$4_PublishedContentDeletedEnvelope = PublishedContentDeletedEnvelope;
|
|
2894
|
-
type context$4_PublishedContentField = PublishedContentField;
|
|
2895
|
-
type context$4_PublishedContentFieldValueOneOf = PublishedContentFieldValueOneOf;
|
|
2896
|
-
type context$4_PublishedContentQueryBuilder = PublishedContentQueryBuilder;
|
|
2897
|
-
type context$4_PublishedContentQueryResult = PublishedContentQueryResult;
|
|
2898
|
-
type context$4_PublishedContentUpdatedEnvelope = PublishedContentUpdatedEnvelope;
|
|
2899
|
-
type context$4_QueryPublishedContentRequest = QueryPublishedContentRequest;
|
|
2900
|
-
type context$4_QueryPublishedContentResponse = QueryPublishedContentResponse;
|
|
2901
|
-
type context$4_QueryPublishedContentResponseNonNullableFields = QueryPublishedContentResponseNonNullableFields;
|
|
2902
|
-
type context$4__publicOnPublishedContentCreatedType = _publicOnPublishedContentCreatedType;
|
|
2903
|
-
type context$4__publicOnPublishedContentDeletedType = _publicOnPublishedContentDeletedType;
|
|
2904
|
-
type context$4__publicOnPublishedContentUpdatedType = _publicOnPublishedContentUpdatedType;
|
|
2905
|
-
declare const context$4_onPublishedContentCreated: typeof onPublishedContentCreated;
|
|
2906
|
-
declare const context$4_onPublishedContentDeleted: typeof onPublishedContentDeleted;
|
|
2907
|
-
declare const context$4_onPublishedContentUpdated: typeof onPublishedContentUpdated;
|
|
2908
|
-
declare const context$4_queryPublishedContent: typeof queryPublishedContent;
|
|
2909
|
-
declare namespace context$4 {
|
|
2910
|
-
export { type ActionEvent$2 as ActionEvent, Alignment$2 as Alignment, type AnchorData$2 as AnchorData, type AppEmbedData$2 as AppEmbedData, type AppEmbedDataAppDataOneOf$2 as AppEmbedDataAppDataOneOf, AppType$2 as AppType, type AudioData$2 as AudioData, type Background$2 as Background, type BackgroundBackgroundOneOf$2 as BackgroundBackgroundOneOf, BackgroundType$2 as BackgroundType, type BaseEventMetadata$2 as BaseEventMetadata, type BlockquoteData$2 as BlockquoteData, type BookingData$2 as BookingData, type Border$2 as Border, type BorderColors$2 as BorderColors, type BulletedListData$2 as BulletedListData, type ButtonData$2 as ButtonData, type CellStyle$2 as CellStyle, type CodeBlockData$2 as CodeBlockData, type CollapsibleListData$2 as CollapsibleListData, type ColorData$2 as ColorData, type Colors$2 as Colors, Crop$2 as Crop, type CursorPaging$2 as CursorPaging, type CursorPagingMetadata$2 as CursorPagingMetadata, type CursorQuery$2 as CursorQuery, type CursorQueryPagingMethodOneOf$2 as CursorQueryPagingMethodOneOf, type Cursors$2 as Cursors, type Decoration$2 as Decoration, type DecorationDataOneOf$2 as DecorationDataOneOf, DecorationType$2 as DecorationType, type Design$2 as Design, type Dimensions$2 as Dimensions, Direction$2 as Direction, type DividerData$2 as DividerData, type DocumentStyle$2 as DocumentStyle, type DomainEvent$2 as DomainEvent, type DomainEventBodyOneOf$2 as DomainEventBodyOneOf, type EmbedData$2 as EmbedData, type EntityCreatedEvent$2 as EntityCreatedEvent, type EntityDeletedEvent$2 as EntityDeletedEvent, type EntityUpdatedEvent$2 as EntityUpdatedEvent, type EventData$2 as EventData, type EventMetadata$2 as EventMetadata, type context$4_ExtendedFields as ExtendedFields, type FileData$2 as FileData, type FileSource$2 as FileSource, type FileSourceDataOneOf$2 as FileSourceDataOneOf, type FontSizeData$2 as FontSizeData, FontType$2 as FontType, type GIF$2 as GIF, type GIFData$2 as GIFData, type GalleryData$2 as GalleryData, type GalleryOptions$2 as GalleryOptions, type context$4_GetPublishedContentRequest as GetPublishedContentRequest, type context$4_GetPublishedContentResponse as GetPublishedContentResponse, type Gradient$2 as Gradient, type HTMLData$2 as HTMLData, type HTMLDataDataOneOf$2 as HTMLDataDataOneOf, type HeadingData$2 as HeadingData, type Height$2 as Height, type IdentificationData$2 as IdentificationData, type IdentificationDataIdOneOf$2 as IdentificationDataIdOneOf, type Image$2 as Image, type ImageData$2 as ImageData, InitialExpandedItems$2 as InitialExpandedItems, type Item$2 as Item, type ItemDataOneOf$2 as ItemDataOneOf, type ItemStyle$2 as ItemStyle, type Layout$2 as Layout, LayoutType$2 as LayoutType, LineStyle$2 as LineStyle, type Link$2 as Link, type LinkData$2 as LinkData, type LinkDataOneOf$2 as LinkDataOneOf, type LinkPreviewData$2 as LinkPreviewData, type ListValue$2 as ListValue, type MapData$2 as MapData, type MapSettings$2 as MapSettings, MapType$2 as MapType, type Media$2 as Media, type MentionData$2 as MentionData, type MessageEnvelope$2 as MessageEnvelope, type Metadata$2 as Metadata, type Node$2 as Node, type NodeDataOneOf$2 as NodeDataOneOf, type NodeStyle$2 as NodeStyle, NodeType$2 as NodeType, NullValue$2 as NullValue, type Oembed$2 as Oembed, type Option$2 as Option, type OptionDesign$2 as OptionDesign, type OptionLayout$2 as OptionLayout, type OrderedListData$2 as OrderedListData, Orientation$2 as Orientation, type PDFSettings$2 as PDFSettings, type ParagraphData$2 as ParagraphData, type Permissions$2 as Permissions, type PlaybackOptions$2 as PlaybackOptions, type PluginContainerData$2 as PluginContainerData, PluginContainerDataAlignment$2 as PluginContainerDataAlignment, type PluginContainerDataWidth$2 as PluginContainerDataWidth, type PluginContainerDataWidthDataOneOf$2 as PluginContainerDataWidthDataOneOf, type Poll$2 as Poll, type PollData$2 as PollData, type PollDataLayout$2 as PollDataLayout, type PollDesign$2 as PollDesign, type PollLayout$2 as PollLayout, PollLayoutDirection$2 as PollLayoutDirection, PollLayoutType$2 as PollLayoutType, type context$4_PublishedContent as PublishedContent, type context$4_PublishedContentCreatedEnvelope as PublishedContentCreatedEnvelope, type context$4_PublishedContentDeletedEnvelope as PublishedContentDeletedEnvelope, type context$4_PublishedContentField as PublishedContentField, type context$4_PublishedContentFieldValueOneOf as PublishedContentFieldValueOneOf, type context$4_PublishedContentQueryBuilder as PublishedContentQueryBuilder, type context$4_PublishedContentQueryResult as PublishedContentQueryResult, type context$4_PublishedContentUpdatedEnvelope as PublishedContentUpdatedEnvelope, type context$4_QueryPublishedContentRequest as QueryPublishedContentRequest, type context$4_QueryPublishedContentResponse as QueryPublishedContentResponse, type context$4_QueryPublishedContentResponseNonNullableFields as QueryPublishedContentResponseNonNullableFields, type Rel$2 as Rel, type RestoreInfo$2 as RestoreInfo, type RichContent$2 as RichContent, type SchemaKey$1 as SchemaKey, SchemaScope$1 as SchemaScope, type Settings$2 as Settings, SortOrder$2 as SortOrder, type Sorting$2 as Sorting, Source$2 as Source, type Spoiler$2 as Spoiler, type SpoilerData$2 as SpoilerData, type Styles$2 as Styles, type TableCellData$2 as TableCellData, type TableData$2 as TableData, Target$2 as Target, TextAlignment$2 as TextAlignment, type TextData$2 as TextData, type TextNodeStyle$2 as TextNodeStyle, type TextStyle$2 as TextStyle, type Thumbnails$2 as Thumbnails, ThumbnailsAlignment$2 as ThumbnailsAlignment, Type$2 as Type, VerticalAlignment$2 as VerticalAlignment, type Video$2 as Video, type VideoData$2 as VideoData, type VideoResolution$1 as VideoResolution, ViewMode$2 as ViewMode, ViewRole$2 as ViewRole, VoteRole$2 as VoteRole, WebhookIdentityType$2 as WebhookIdentityType, Width$2 as Width, WidthType$2 as WidthType, type context$4__publicOnPublishedContentCreatedType as _publicOnPublishedContentCreatedType, type context$4__publicOnPublishedContentDeletedType as _publicOnPublishedContentDeletedType, type context$4__publicOnPublishedContentUpdatedType as _publicOnPublishedContentUpdatedType, context$4_onPublishedContentCreated as onPublishedContentCreated, context$4_onPublishedContentDeleted as onPublishedContentDeleted, context$4_onPublishedContentUpdated as onPublishedContentUpdated, onPublishedContentCreated$1 as publicOnPublishedContentCreated, onPublishedContentDeleted$1 as publicOnPublishedContentDeleted, onPublishedContentUpdated$1 as publicOnPublishedContentUpdated, context$4_queryPublishedContent as queryPublishedContent };
|
|
2911
|
-
}
|
|
3915
|
+
type MaybeContext$3<T extends Descriptors$3> = globalThis.ContextualClient extends {
|
|
3916
|
+
host: Host$3;
|
|
3917
|
+
} ? BuildDescriptors$3<T, globalThis.ContextualClient['host']> : T;
|
|
2912
3918
|
|
|
2913
3919
|
/**
|
|
2914
3920
|
* A translatable content is a unit of content to translate.
|
|
@@ -4813,90 +5819,568 @@ interface BulkMachineTranslateOptions {
|
|
|
4813
5819
|
contentToTranslate?: TranslatableContent[];
|
|
4814
5820
|
}
|
|
4815
5821
|
|
|
4816
|
-
declare function machineTranslate$1(httpClient: HttpClient): MachineTranslateSignature;
|
|
4817
|
-
interface MachineTranslateSignature {
|
|
4818
|
-
/**
|
|
4819
|
-
* Translates the text of a translatable unit of content from one supported language to another.
|
|
4820
|
-
*
|
|
4821
|
-
* The `translatedContent` object returns with the same `id` used for `contentToTranslate.id` but the text within the
|
|
4822
|
-
* content fields is replaced with the translated text. Note that Wix does not overwrite the original content object.
|
|
4823
|
-
* To retrieve the translated content later, make sure to store it separately.
|
|
4824
|
-
*
|
|
4825
|
-
* Only text content is translated, even if the content is `htmlContent` or `richContent`. Note that [collapsible text](https://support.wix.com/en/article/adding-and-setting-up-collapsible-text)
|
|
4826
|
-
* cannot be translated using this method.
|
|
4827
|
-
*
|
|
4828
|
-
* The translatable content must not exceed 5,000 characters. If this limit is exceeded, the method returns a `TEXT_TOO_LONG` error.
|
|
4829
|
-
* For `richContent`, the 5,000-character limit applies separately to each node in `richContent.nodes`.
|
|
4830
|
-
* The total translatable content may be more than 5,000 characters as long as no individual node surpasses this limit.
|
|
4831
|
-
* If any node exceeds 5,000 characters, the entire request fails.
|
|
4832
|
-
*
|
|
4833
|
-
* Each site has a [word credit](/machine-translation/introduction#terminology) balance, starting at 3,000 words.
|
|
4834
|
-
* Each successful translation request reduces the word credits by the number of words in `contentToTranslate`.
|
|
4835
|
-
* If the site does not have sufficient word credits to translate all of the text in the request, the request fails
|
|
4836
|
-
* with a `NOT_ENOUGH_CREDITS` error. Additional credits can be [purchased through the Dashboard](https://support.wix.com/en/article/wix-multilingual-auto-translating-your-site?tabs=Dashboard-5#purchasing-translation-packages).
|
|
4837
|
-
*
|
|
4838
|
-
* To translate up to 1,000 `translatableContent` units at once, use [Bulk Machine Translate](/machine-translation/bulk-machine-translate).
|
|
4839
|
-
* @param - Language of the source text to translate.
|
|
4840
|
-
*/
|
|
4841
|
-
(sourceLanguage: SupportedLanguage, options: MachineTranslateOptions): Promise<MachineTranslateResponse & MachineTranslateResponseNonNullableFields>;
|
|
5822
|
+
declare function machineTranslate$1(httpClient: HttpClient$3): MachineTranslateSignature;
|
|
5823
|
+
interface MachineTranslateSignature {
|
|
5824
|
+
/**
|
|
5825
|
+
* Translates the text of a translatable unit of content from one supported language to another.
|
|
5826
|
+
*
|
|
5827
|
+
* The `translatedContent` object returns with the same `id` used for `contentToTranslate.id` but the text within the
|
|
5828
|
+
* content fields is replaced with the translated text. Note that Wix does not overwrite the original content object.
|
|
5829
|
+
* To retrieve the translated content later, make sure to store it separately.
|
|
5830
|
+
*
|
|
5831
|
+
* Only text content is translated, even if the content is `htmlContent` or `richContent`. Note that [collapsible text](https://support.wix.com/en/article/adding-and-setting-up-collapsible-text)
|
|
5832
|
+
* cannot be translated using this method.
|
|
5833
|
+
*
|
|
5834
|
+
* The translatable content must not exceed 5,000 characters. If this limit is exceeded, the method returns a `TEXT_TOO_LONG` error.
|
|
5835
|
+
* For `richContent`, the 5,000-character limit applies separately to each node in `richContent.nodes`.
|
|
5836
|
+
* The total translatable content may be more than 5,000 characters as long as no individual node surpasses this limit.
|
|
5837
|
+
* If any node exceeds 5,000 characters, the entire request fails.
|
|
5838
|
+
*
|
|
5839
|
+
* Each site has a [word credit](/machine-translation/introduction#terminology) balance, starting at 3,000 words.
|
|
5840
|
+
* Each successful translation request reduces the word credits by the number of words in `contentToTranslate`.
|
|
5841
|
+
* If the site does not have sufficient word credits to translate all of the text in the request, the request fails
|
|
5842
|
+
* with a `NOT_ENOUGH_CREDITS` error. Additional credits can be [purchased through the Dashboard](https://support.wix.com/en/article/wix-multilingual-auto-translating-your-site?tabs=Dashboard-5#purchasing-translation-packages).
|
|
5843
|
+
*
|
|
5844
|
+
* To translate up to 1,000 `translatableContent` units at once, use [Bulk Machine Translate](/machine-translation/bulk-machine-translate).
|
|
5845
|
+
* @param - Language of the source text to translate.
|
|
5846
|
+
*/
|
|
5847
|
+
(sourceLanguage: SupportedLanguage, options: MachineTranslateOptions): Promise<MachineTranslateResponse & MachineTranslateResponseNonNullableFields>;
|
|
5848
|
+
}
|
|
5849
|
+
declare function bulkMachineTranslate$1(httpClient: HttpClient$3): BulkMachineTranslateSignature;
|
|
5850
|
+
interface BulkMachineTranslateSignature {
|
|
5851
|
+
/**
|
|
5852
|
+
* Translates the text of multiple units of translatable content from one supported language to another.
|
|
5853
|
+
*
|
|
5854
|
+
* Each translated content item in the `results` array returns with the same `id` as the corresponding `contentToTranslate.id`, but with the text in the
|
|
5855
|
+
* content fields replaced with the translated text. Note that Wix does not overwrite the original content source,
|
|
5856
|
+
* to retrieve the translated content later, make sure to store it separately.
|
|
5857
|
+
*
|
|
5858
|
+
* Only text content is translated, even if the content is `htmlContent` or `richContent`. Note that [collapsible text](https://support.wix.com/en/article/adding-and-setting-up-collapsible-text)
|
|
5859
|
+
* cannot be translated using this method.
|
|
5860
|
+
*
|
|
5861
|
+
* Each unit of translatable content must not exceed 5,000 characters. If this limit is exceeded, the method returns a `TEXT_TOO_LONG` error.
|
|
5862
|
+
* For `richContent`, the 5,000-character limit applies separately to each node in `richContent.nodes`.
|
|
5863
|
+
* The total request may exceed 5,000 characters as long as no individual node surpasses this limit.
|
|
5864
|
+
* If any node exceeds 5,000 characters, then the request fails for that specific `contentToTranslate` item and the error details for that
|
|
5865
|
+
* error are returned in `itemMetadata`. Even if some translations fail due to the character limit,
|
|
5866
|
+
* the machine translation for other items will succeed if they are under the character limit.
|
|
5867
|
+
*
|
|
5868
|
+
* Each site has a [word credit](/machine-translation/introduction#terminology) balance, starting at 3,000 words.
|
|
5869
|
+
* Each successful translation request reduces the word credits by the number of words included in `contentToTranslate`.
|
|
5870
|
+
* If the site does not have sufficient word credits to complete the translation, then the entire request fails
|
|
5871
|
+
* with a `NOT_ENOUGH_CREDITS` error. Additional credits can be [purchased through the Dashboard](https://support.wix.com/en/article/wix-multilingual-auto-translating-your-site?tabs=Dashboard-5#purchasing-translation-packages).
|
|
5872
|
+
*
|
|
5873
|
+
* To translate a single unit of `translatableContent`, use [Machine Translate](/machine-translation/machine-translate).
|
|
5874
|
+
* @param - Language of the source text to translate.
|
|
5875
|
+
*/
|
|
5876
|
+
(sourceLanguage: SupportedLanguage, options?: BulkMachineTranslateOptions | undefined): Promise<BulkMachineTranslateResponse & BulkMachineTranslateResponseNonNullableFields>;
|
|
5877
|
+
}
|
|
5878
|
+
|
|
5879
|
+
declare const machineTranslate: MaybeContext$3<BuildRESTFunction$3<typeof machineTranslate$1> & typeof machineTranslate$1>;
|
|
5880
|
+
declare const bulkMachineTranslate: MaybeContext$3<BuildRESTFunction$3<typeof bulkMachineTranslate$1> & typeof bulkMachineTranslate$1>;
|
|
5881
|
+
|
|
5882
|
+
type context$3_BulkMachineTranslateOptions = BulkMachineTranslateOptions;
|
|
5883
|
+
type context$3_BulkMachineTranslateRequest = BulkMachineTranslateRequest;
|
|
5884
|
+
type context$3_BulkMachineTranslateResponse = BulkMachineTranslateResponse;
|
|
5885
|
+
type context$3_BulkMachineTranslateResponseNonNullableFields = BulkMachineTranslateResponseNonNullableFields;
|
|
5886
|
+
type context$3_BulkTranslateResult = BulkTranslateResult;
|
|
5887
|
+
type context$3_Format = Format;
|
|
5888
|
+
declare const context$3_Format: typeof Format;
|
|
5889
|
+
type context$3_MachineTranslateOptions = MachineTranslateOptions;
|
|
5890
|
+
type context$3_MachineTranslateRequest = MachineTranslateRequest;
|
|
5891
|
+
type context$3_MachineTranslateResponse = MachineTranslateResponse;
|
|
5892
|
+
type context$3_MachineTranslateResponseNonNullableFields = MachineTranslateResponseNonNullableFields;
|
|
5893
|
+
type context$3_NotEnoughCreditsError = NotEnoughCreditsError;
|
|
5894
|
+
type context$3_SameLanguageArgumentsError = SameLanguageArgumentsError;
|
|
5895
|
+
type context$3_SupportedLanguage = SupportedLanguage;
|
|
5896
|
+
declare const context$3_SupportedLanguage: typeof SupportedLanguage;
|
|
5897
|
+
type context$3_TextTooLongError = TextTooLongError;
|
|
5898
|
+
type context$3_TranslatableContent = TranslatableContent;
|
|
5899
|
+
type context$3_TranslatableContentContentOneOf = TranslatableContentContentOneOf;
|
|
5900
|
+
type context$3_UnknownFormatError = UnknownFormatError;
|
|
5901
|
+
declare const context$3_bulkMachineTranslate: typeof bulkMachineTranslate;
|
|
5902
|
+
declare const context$3_machineTranslate: typeof machineTranslate;
|
|
5903
|
+
declare namespace context$3 {
|
|
5904
|
+
export { Alignment$1 as Alignment, type AnchorData$1 as AnchorData, type AppEmbedData$1 as AppEmbedData, type AppEmbedDataAppDataOneOf$1 as AppEmbedDataAppDataOneOf, AppType$1 as AppType, type ApplicationError$1 as ApplicationError, type AudioData$1 as AudioData, type Background$1 as Background, type BackgroundBackgroundOneOf$1 as BackgroundBackgroundOneOf, BackgroundType$1 as BackgroundType, type BlockquoteData$1 as BlockquoteData, type BookingData$1 as BookingData, type Border$1 as Border, type BorderColors$1 as BorderColors, type BulkActionMetadata$1 as BulkActionMetadata, type context$3_BulkMachineTranslateOptions as BulkMachineTranslateOptions, type context$3_BulkMachineTranslateRequest as BulkMachineTranslateRequest, type context$3_BulkMachineTranslateResponse as BulkMachineTranslateResponse, type context$3_BulkMachineTranslateResponseNonNullableFields as BulkMachineTranslateResponseNonNullableFields, type context$3_BulkTranslateResult as BulkTranslateResult, type BulletedListData$1 as BulletedListData, type ButtonData$1 as ButtonData, type CellStyle$1 as CellStyle, type CodeBlockData$1 as CodeBlockData, type CollapsibleListData$1 as CollapsibleListData, type ColorData$1 as ColorData, type Colors$1 as Colors, Crop$1 as Crop, type Decoration$1 as Decoration, type DecorationDataOneOf$1 as DecorationDataOneOf, DecorationType$1 as DecorationType, type Design$1 as Design, type Dimensions$1 as Dimensions, Direction$1 as Direction, type DividerData$1 as DividerData, type DocumentStyle$1 as DocumentStyle, type EmbedData$1 as EmbedData, type EventData$1 as EventData, type FileData$1 as FileData, type FileSource$1 as FileSource, type FileSourceDataOneOf$1 as FileSourceDataOneOf, type FontSizeData$1 as FontSizeData, FontType$1 as FontType, context$3_Format as Format, type GIF$1 as GIF, type GIFData$1 as GIFData, type GalleryData$1 as GalleryData, type GalleryOptions$1 as GalleryOptions, type Gradient$1 as Gradient, type HTMLData$1 as HTMLData, type HTMLDataDataOneOf$1 as HTMLDataDataOneOf, type HeadingData$1 as HeadingData, type Height$1 as Height, type Image$1 as Image, type ImageData$1 as ImageData, InitialExpandedItems$1 as InitialExpandedItems, type Item$1 as Item, type ItemDataOneOf$1 as ItemDataOneOf, type ItemMetadata$1 as ItemMetadata, type ItemStyle$1 as ItemStyle, type Layout$1 as Layout, LayoutType$1 as LayoutType, LineStyle$1 as LineStyle, type Link$1 as Link, type LinkData$1 as LinkData, type LinkDataOneOf$1 as LinkDataOneOf, type LinkPreviewData$1 as LinkPreviewData, type ListValue$1 as ListValue, type context$3_MachineTranslateOptions as MachineTranslateOptions, type context$3_MachineTranslateRequest as MachineTranslateRequest, type context$3_MachineTranslateResponse as MachineTranslateResponse, type context$3_MachineTranslateResponseNonNullableFields as MachineTranslateResponseNonNullableFields, type MapData$1 as MapData, type MapSettings$1 as MapSettings, MapType$1 as MapType, type Media$1 as Media, type MentionData$1 as MentionData, type Metadata$1 as Metadata, type Node$1 as Node, type NodeDataOneOf$1 as NodeDataOneOf, type NodeStyle$1 as NodeStyle, NodeType$1 as NodeType, type context$3_NotEnoughCreditsError as NotEnoughCreditsError, NullValue$1 as NullValue, type Oembed$1 as Oembed, type Option$1 as Option, type OptionDesign$1 as OptionDesign, type OptionLayout$1 as OptionLayout, type OrderedListData$1 as OrderedListData, Orientation$1 as Orientation, type PDFSettings$1 as PDFSettings, type ParagraphData$1 as ParagraphData, type Permissions$1 as Permissions, type PlaybackOptions$1 as PlaybackOptions, type PluginContainerData$1 as PluginContainerData, PluginContainerDataAlignment$1 as PluginContainerDataAlignment, type PluginContainerDataWidth$1 as PluginContainerDataWidth, type PluginContainerDataWidthDataOneOf$1 as PluginContainerDataWidthDataOneOf, type Poll$1 as Poll, type PollData$1 as PollData, type PollDataLayout$1 as PollDataLayout, type PollDesign$1 as PollDesign, type PollLayout$1 as PollLayout, PollLayoutDirection$1 as PollLayoutDirection, PollLayoutType$1 as PollLayoutType, type Rel$1 as Rel, type RichContent$1 as RichContent, type context$3_SameLanguageArgumentsError as SameLanguageArgumentsError, type Settings$1 as Settings, Source$1 as Source, type Spoiler$1 as Spoiler, type SpoilerData$1 as SpoilerData, type Styles$1 as Styles, context$3_SupportedLanguage as SupportedLanguage, type TableCellData$1 as TableCellData, type TableData$1 as TableData, Target$1 as Target, TextAlignment$1 as TextAlignment, type TextData$1 as TextData, type TextNodeStyle$1 as TextNodeStyle, type TextStyle$1 as TextStyle, type context$3_TextTooLongError as TextTooLongError, type Thumbnails$1 as Thumbnails, ThumbnailsAlignment$1 as ThumbnailsAlignment, type context$3_TranslatableContent as TranslatableContent, type context$3_TranslatableContentContentOneOf as TranslatableContentContentOneOf, Type$1 as Type, type context$3_UnknownFormatError as UnknownFormatError, VerticalAlignment$1 as VerticalAlignment, type Video$1 as Video, type VideoData$1 as VideoData, ViewMode$1 as ViewMode, ViewRole$1 as ViewRole, VoteRole$1 as VoteRole, Width$1 as Width, WidthType$1 as WidthType, context$3_bulkMachineTranslate as bulkMachineTranslate, context$3_machineTranslate as machineTranslate };
|
|
5905
|
+
}
|
|
5906
|
+
|
|
5907
|
+
type HostModule$2<T, H extends Host$2> = {
|
|
5908
|
+
__type: 'host';
|
|
5909
|
+
create(host: H): T;
|
|
5910
|
+
};
|
|
5911
|
+
type HostModuleAPI$2<T extends HostModule$2<any, any>> = T extends HostModule$2<infer U, any> ? U : never;
|
|
5912
|
+
type Host$2<Environment = unknown> = {
|
|
5913
|
+
channel: {
|
|
5914
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
5915
|
+
disconnect: () => void;
|
|
5916
|
+
} | Promise<{
|
|
5917
|
+
disconnect: () => void;
|
|
5918
|
+
}>;
|
|
5919
|
+
};
|
|
5920
|
+
environment?: Environment;
|
|
5921
|
+
/**
|
|
5922
|
+
* Optional name of the environment, use for logging
|
|
5923
|
+
*/
|
|
5924
|
+
name?: string;
|
|
5925
|
+
/**
|
|
5926
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
5927
|
+
*/
|
|
5928
|
+
apiBaseUrl?: string;
|
|
5929
|
+
/**
|
|
5930
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
5931
|
+
* like internationalization, billing, etc.
|
|
5932
|
+
*/
|
|
5933
|
+
essentials?: {
|
|
5934
|
+
/**
|
|
5935
|
+
* The language of the currently viewed session
|
|
5936
|
+
*/
|
|
5937
|
+
language?: string;
|
|
5938
|
+
/**
|
|
5939
|
+
* The locale of the currently viewed session
|
|
5940
|
+
*/
|
|
5941
|
+
locale?: string;
|
|
5942
|
+
/**
|
|
5943
|
+
* Any headers that should be passed through to the API requests
|
|
5944
|
+
*/
|
|
5945
|
+
passThroughHeaders?: Record<string, string>;
|
|
5946
|
+
};
|
|
5947
|
+
};
|
|
5948
|
+
|
|
5949
|
+
type RESTFunctionDescriptor$2<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$2) => T;
|
|
5950
|
+
interface HttpClient$2 {
|
|
5951
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$2<TResponse, TData>): Promise<HttpResponse$2<TResponse>>;
|
|
5952
|
+
fetchWithAuth: typeof fetch;
|
|
5953
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
5954
|
+
getActiveToken?: () => string | undefined;
|
|
5955
|
+
}
|
|
5956
|
+
type RequestOptionsFactory$2<TResponse = any, TData = any> = (context: any) => RequestOptions$2<TResponse, TData>;
|
|
5957
|
+
type HttpResponse$2<T = any> = {
|
|
5958
|
+
data: T;
|
|
5959
|
+
status: number;
|
|
5960
|
+
statusText: string;
|
|
5961
|
+
headers: any;
|
|
5962
|
+
request?: any;
|
|
5963
|
+
};
|
|
5964
|
+
type RequestOptions$2<_TResponse = any, Data = any> = {
|
|
5965
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
5966
|
+
url: string;
|
|
5967
|
+
data?: Data;
|
|
5968
|
+
params?: URLSearchParams;
|
|
5969
|
+
} & APIMetadata$2;
|
|
5970
|
+
type APIMetadata$2 = {
|
|
5971
|
+
methodFqn?: string;
|
|
5972
|
+
entityFqdn?: string;
|
|
5973
|
+
packageName?: string;
|
|
5974
|
+
};
|
|
5975
|
+
type BuildRESTFunction$2<T extends RESTFunctionDescriptor$2> = T extends RESTFunctionDescriptor$2<infer U> ? U : never;
|
|
5976
|
+
type EventDefinition$2<Payload = unknown, Type extends string = string> = {
|
|
5977
|
+
__type: 'event-definition';
|
|
5978
|
+
type: Type;
|
|
5979
|
+
isDomainEvent?: boolean;
|
|
5980
|
+
transformations?: (envelope: unknown) => Payload;
|
|
5981
|
+
__payload: Payload;
|
|
5982
|
+
};
|
|
5983
|
+
declare function EventDefinition$2<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$2<Payload, Type>;
|
|
5984
|
+
type EventHandler$2<T extends EventDefinition$2> = (payload: T['__payload']) => void | Promise<void>;
|
|
5985
|
+
type BuildEventDefinition$2<T extends EventDefinition$2<any, string>> = (handler: EventHandler$2<T>) => void;
|
|
5986
|
+
|
|
5987
|
+
type ServicePluginMethodInput$2 = {
|
|
5988
|
+
request: any;
|
|
5989
|
+
metadata: any;
|
|
5990
|
+
};
|
|
5991
|
+
type ServicePluginContract$2 = Record<string, (payload: ServicePluginMethodInput$2) => unknown | Promise<unknown>>;
|
|
5992
|
+
type ServicePluginMethodMetadata$2 = {
|
|
5993
|
+
name: string;
|
|
5994
|
+
primaryHttpMappingPath: string;
|
|
5995
|
+
transformations: {
|
|
5996
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$2;
|
|
5997
|
+
toREST: (...args: unknown[]) => unknown;
|
|
5998
|
+
};
|
|
5999
|
+
};
|
|
6000
|
+
type ServicePluginDefinition$2<Contract extends ServicePluginContract$2> = {
|
|
6001
|
+
__type: 'service-plugin-definition';
|
|
6002
|
+
componentType: string;
|
|
6003
|
+
methods: ServicePluginMethodMetadata$2[];
|
|
6004
|
+
__contract: Contract;
|
|
6005
|
+
};
|
|
6006
|
+
declare function ServicePluginDefinition$2<Contract extends ServicePluginContract$2>(componentType: string, methods: ServicePluginMethodMetadata$2[]): ServicePluginDefinition$2<Contract>;
|
|
6007
|
+
type BuildServicePluginDefinition$2<T extends ServicePluginDefinition$2<any>> = (implementation: T['__contract']) => void;
|
|
6008
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$2 = "wix_spi_error";
|
|
6009
|
+
|
|
6010
|
+
type RequestContext$2 = {
|
|
6011
|
+
isSSR: boolean;
|
|
6012
|
+
host: string;
|
|
6013
|
+
protocol?: string;
|
|
6014
|
+
};
|
|
6015
|
+
type ResponseTransformer$2 = (data: any, headers?: any) => any;
|
|
6016
|
+
/**
|
|
6017
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
6018
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
6019
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
6020
|
+
*/
|
|
6021
|
+
type Method$2 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
6022
|
+
type AmbassadorRequestOptions$2<T = any> = {
|
|
6023
|
+
_?: T;
|
|
6024
|
+
url?: string;
|
|
6025
|
+
method?: Method$2;
|
|
6026
|
+
params?: any;
|
|
6027
|
+
data?: any;
|
|
6028
|
+
transformResponse?: ResponseTransformer$2 | ResponseTransformer$2[];
|
|
6029
|
+
};
|
|
6030
|
+
type AmbassadorFactory$2<Request, Response> = (payload: Request) => ((context: RequestContext$2) => AmbassadorRequestOptions$2<Response>) & {
|
|
6031
|
+
__isAmbassador: boolean;
|
|
6032
|
+
};
|
|
6033
|
+
type AmbassadorFunctionDescriptor$2<Request = any, Response = any> = AmbassadorFactory$2<Request, Response>;
|
|
6034
|
+
type BuildAmbassadorFunction$2<T extends AmbassadorFunctionDescriptor$2> = T extends AmbassadorFunctionDescriptor$2<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
6035
|
+
|
|
6036
|
+
declare global {
|
|
6037
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
6038
|
+
interface SymbolConstructor {
|
|
6039
|
+
readonly observable: symbol;
|
|
6040
|
+
}
|
|
6041
|
+
}
|
|
6042
|
+
|
|
6043
|
+
declare const emptyObjectSymbol$2: unique symbol;
|
|
6044
|
+
|
|
6045
|
+
/**
|
|
6046
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
6047
|
+
|
|
6048
|
+
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)).
|
|
6049
|
+
|
|
6050
|
+
@example
|
|
6051
|
+
```
|
|
6052
|
+
import type {EmptyObject} from 'type-fest';
|
|
6053
|
+
|
|
6054
|
+
// The following illustrates the problem with `{}`.
|
|
6055
|
+
const foo1: {} = {}; // Pass
|
|
6056
|
+
const foo2: {} = []; // Pass
|
|
6057
|
+
const foo3: {} = 42; // Pass
|
|
6058
|
+
const foo4: {} = {a: 1}; // Pass
|
|
6059
|
+
|
|
6060
|
+
// With `EmptyObject` only the first case is valid.
|
|
6061
|
+
const bar1: EmptyObject = {}; // Pass
|
|
6062
|
+
const bar2: EmptyObject = 42; // Fail
|
|
6063
|
+
const bar3: EmptyObject = []; // Fail
|
|
6064
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
6065
|
+
```
|
|
6066
|
+
|
|
6067
|
+
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}.
|
|
6068
|
+
|
|
6069
|
+
@category Object
|
|
6070
|
+
*/
|
|
6071
|
+
type EmptyObject$2 = {[emptyObjectSymbol$2]?: never};
|
|
6072
|
+
|
|
6073
|
+
/**
|
|
6074
|
+
Returns a boolean for whether the two given types are equal.
|
|
6075
|
+
|
|
6076
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
6077
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
6078
|
+
|
|
6079
|
+
Use-cases:
|
|
6080
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
6081
|
+
|
|
6082
|
+
@example
|
|
6083
|
+
```
|
|
6084
|
+
import type {IsEqual} from 'type-fest';
|
|
6085
|
+
|
|
6086
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
6087
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
6088
|
+
type Includes<Value extends readonly any[], Item> =
|
|
6089
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
6090
|
+
? IsEqual<Value[0], Item> extends true
|
|
6091
|
+
? true
|
|
6092
|
+
: Includes<rest, Item>
|
|
6093
|
+
: false;
|
|
6094
|
+
```
|
|
6095
|
+
|
|
6096
|
+
@category Type Guard
|
|
6097
|
+
@category Utilities
|
|
6098
|
+
*/
|
|
6099
|
+
type IsEqual$2<A, B> =
|
|
6100
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
6101
|
+
(<G>() => G extends B ? 1 : 2)
|
|
6102
|
+
? true
|
|
6103
|
+
: false;
|
|
6104
|
+
|
|
6105
|
+
/**
|
|
6106
|
+
Filter out keys from an object.
|
|
6107
|
+
|
|
6108
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
6109
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
6110
|
+
Returns `Key` otherwise.
|
|
6111
|
+
|
|
6112
|
+
@example
|
|
6113
|
+
```
|
|
6114
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
6115
|
+
//=> never
|
|
6116
|
+
```
|
|
6117
|
+
|
|
6118
|
+
@example
|
|
6119
|
+
```
|
|
6120
|
+
type Filtered = Filter<'bar', string>;
|
|
6121
|
+
//=> never
|
|
6122
|
+
```
|
|
6123
|
+
|
|
6124
|
+
@example
|
|
6125
|
+
```
|
|
6126
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
6127
|
+
//=> 'bar'
|
|
6128
|
+
```
|
|
6129
|
+
|
|
6130
|
+
@see {Except}
|
|
6131
|
+
*/
|
|
6132
|
+
type Filter$2<KeyType, ExcludeType> = IsEqual$2<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
6133
|
+
|
|
6134
|
+
type ExceptOptions$2 = {
|
|
6135
|
+
/**
|
|
6136
|
+
Disallow assigning non-specified properties.
|
|
6137
|
+
|
|
6138
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
6139
|
+
|
|
6140
|
+
@default false
|
|
6141
|
+
*/
|
|
6142
|
+
requireExactProps?: boolean;
|
|
6143
|
+
};
|
|
6144
|
+
|
|
6145
|
+
/**
|
|
6146
|
+
Create a type from an object type without certain keys.
|
|
6147
|
+
|
|
6148
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
6149
|
+
|
|
6150
|
+
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.
|
|
6151
|
+
|
|
6152
|
+
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)).
|
|
6153
|
+
|
|
6154
|
+
@example
|
|
6155
|
+
```
|
|
6156
|
+
import type {Except} from 'type-fest';
|
|
6157
|
+
|
|
6158
|
+
type Foo = {
|
|
6159
|
+
a: number;
|
|
6160
|
+
b: string;
|
|
6161
|
+
};
|
|
6162
|
+
|
|
6163
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
6164
|
+
//=> {b: string}
|
|
6165
|
+
|
|
6166
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
6167
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
6168
|
+
|
|
6169
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
6170
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
6171
|
+
|
|
6172
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
6173
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
6174
|
+
```
|
|
6175
|
+
|
|
6176
|
+
@category Object
|
|
6177
|
+
*/
|
|
6178
|
+
type Except$2<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$2 = {requireExactProps: false}> = {
|
|
6179
|
+
[KeyType in keyof ObjectType as Filter$2<KeyType, KeysType>]: ObjectType[KeyType];
|
|
6180
|
+
} & (Options['requireExactProps'] extends true
|
|
6181
|
+
? Partial<Record<KeysType, never>>
|
|
6182
|
+
: {});
|
|
6183
|
+
|
|
6184
|
+
/**
|
|
6185
|
+
Returns a boolean for whether the given type is `never`.
|
|
6186
|
+
|
|
6187
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
6188
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
6189
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
6190
|
+
|
|
6191
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
6192
|
+
|
|
6193
|
+
@example
|
|
6194
|
+
```
|
|
6195
|
+
import type {IsNever, And} from 'type-fest';
|
|
6196
|
+
|
|
6197
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
6198
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
6199
|
+
And<
|
|
6200
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
6201
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
6202
|
+
>;
|
|
6203
|
+
|
|
6204
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
6205
|
+
AreStringsEqual<I, O> extends true
|
|
6206
|
+
? never
|
|
6207
|
+
: void;
|
|
6208
|
+
|
|
6209
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
6210
|
+
if (input === output) {
|
|
6211
|
+
process.exit(0);
|
|
6212
|
+
}
|
|
4842
6213
|
}
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
6214
|
+
|
|
6215
|
+
endIfEqual('abc', 'abc');
|
|
6216
|
+
//=> never
|
|
6217
|
+
|
|
6218
|
+
endIfEqual('abc', '123');
|
|
6219
|
+
//=> void
|
|
6220
|
+
```
|
|
6221
|
+
|
|
6222
|
+
@category Type Guard
|
|
6223
|
+
@category Utilities
|
|
6224
|
+
*/
|
|
6225
|
+
type IsNever$2<T> = [T] extends [never] ? true : false;
|
|
6226
|
+
|
|
6227
|
+
/**
|
|
6228
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
6229
|
+
|
|
6230
|
+
@see {@link IsNever}
|
|
6231
|
+
|
|
6232
|
+
@example
|
|
6233
|
+
```
|
|
6234
|
+
import type {IfNever} from 'type-fest';
|
|
6235
|
+
|
|
6236
|
+
type ShouldBeTrue = IfNever<never>;
|
|
6237
|
+
//=> true
|
|
6238
|
+
|
|
6239
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
6240
|
+
//=> 'bar'
|
|
6241
|
+
```
|
|
6242
|
+
|
|
6243
|
+
@category Type Guard
|
|
6244
|
+
@category Utilities
|
|
6245
|
+
*/
|
|
6246
|
+
type IfNever$2<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
6247
|
+
IsNever$2<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
6248
|
+
);
|
|
6249
|
+
|
|
6250
|
+
/**
|
|
6251
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
6252
|
+
|
|
6253
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
6254
|
+
|
|
6255
|
+
@example
|
|
6256
|
+
```
|
|
6257
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
6258
|
+
|
|
6259
|
+
interface Example {
|
|
6260
|
+
a: string;
|
|
6261
|
+
b: string | number;
|
|
6262
|
+
c?: string;
|
|
6263
|
+
d: {};
|
|
6264
|
+
}
|
|
6265
|
+
|
|
6266
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
6267
|
+
//=> 'a'
|
|
6268
|
+
```
|
|
6269
|
+
|
|
6270
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
6271
|
+
|
|
6272
|
+
@example
|
|
6273
|
+
```
|
|
6274
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
6275
|
+
|
|
6276
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
6277
|
+
//=> 'a' | 'c'
|
|
6278
|
+
```
|
|
6279
|
+
|
|
6280
|
+
@category Object
|
|
6281
|
+
*/
|
|
6282
|
+
type ConditionalKeys$2<Base, Condition> =
|
|
6283
|
+
{
|
|
6284
|
+
// Map through all the keys of the given base type.
|
|
6285
|
+
[Key in keyof Base]-?:
|
|
6286
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
6287
|
+
Base[Key] extends Condition
|
|
6288
|
+
// Retain this key
|
|
6289
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
6290
|
+
? IfNever$2<Base[Key], IfNever$2<Condition, Key, never>, Key>
|
|
6291
|
+
// Discard this key since the condition fails.
|
|
6292
|
+
: never;
|
|
6293
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
6294
|
+
}[keyof Base];
|
|
6295
|
+
|
|
6296
|
+
/**
|
|
6297
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
6298
|
+
|
|
6299
|
+
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.
|
|
6300
|
+
|
|
6301
|
+
@example
|
|
6302
|
+
```
|
|
6303
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
6304
|
+
|
|
6305
|
+
class Awesome {
|
|
6306
|
+
name: string;
|
|
6307
|
+
successes: number;
|
|
6308
|
+
failures: bigint;
|
|
6309
|
+
|
|
6310
|
+
run() {}
|
|
4871
6311
|
}
|
|
4872
6312
|
|
|
4873
|
-
|
|
4874
|
-
|
|
6313
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
6314
|
+
//=> {run: () => void}
|
|
6315
|
+
```
|
|
4875
6316
|
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
type
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
type
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
type
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
6317
|
+
@example
|
|
6318
|
+
```
|
|
6319
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
6320
|
+
|
|
6321
|
+
interface Example {
|
|
6322
|
+
a: string;
|
|
6323
|
+
b: string | number;
|
|
6324
|
+
c: () => void;
|
|
6325
|
+
d: {};
|
|
6326
|
+
}
|
|
6327
|
+
|
|
6328
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
6329
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
6330
|
+
```
|
|
6331
|
+
|
|
6332
|
+
@category Object
|
|
6333
|
+
*/
|
|
6334
|
+
type ConditionalExcept$2<Base, Condition> = Except$2<
|
|
6335
|
+
Base,
|
|
6336
|
+
ConditionalKeys$2<Base, Condition>
|
|
6337
|
+
>;
|
|
6338
|
+
|
|
6339
|
+
/**
|
|
6340
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
6341
|
+
* can either be a REST module or a host module.
|
|
6342
|
+
* This type is recursive, so it can describe nested modules.
|
|
6343
|
+
*/
|
|
6344
|
+
type Descriptors$2 = RESTFunctionDescriptor$2 | AmbassadorFunctionDescriptor$2 | HostModule$2<any, any> | EventDefinition$2<any> | ServicePluginDefinition$2<any> | {
|
|
6345
|
+
[key: string]: Descriptors$2 | PublicMetadata$2 | any;
|
|
6346
|
+
};
|
|
6347
|
+
/**
|
|
6348
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
6349
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
6350
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
6351
|
+
* do not match the given host (as they will not work with the given host).
|
|
6352
|
+
*/
|
|
6353
|
+
type BuildDescriptors$2<T extends Descriptors$2, H extends Host$2<any> | undefined, Depth extends number = 5> = {
|
|
6354
|
+
done: T;
|
|
6355
|
+
recurse: T extends {
|
|
6356
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$2;
|
|
6357
|
+
} ? 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<{
|
|
6358
|
+
[Key in keyof T]: T[Key] extends Descriptors$2 ? BuildDescriptors$2<T[Key], H, [
|
|
6359
|
+
-1,
|
|
6360
|
+
0,
|
|
6361
|
+
1,
|
|
6362
|
+
2,
|
|
6363
|
+
3,
|
|
6364
|
+
4,
|
|
6365
|
+
5
|
|
6366
|
+
][Depth]> : never;
|
|
6367
|
+
}, EmptyObject$2>;
|
|
6368
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
6369
|
+
type PublicMetadata$2 = {
|
|
6370
|
+
PACKAGE_NAME?: string;
|
|
6371
|
+
};
|
|
6372
|
+
|
|
6373
|
+
declare global {
|
|
6374
|
+
interface ContextualClient {
|
|
6375
|
+
}
|
|
4899
6376
|
}
|
|
6377
|
+
/**
|
|
6378
|
+
* A type used to create concerete types from SDK descriptors in
|
|
6379
|
+
* case a contextual client is available.
|
|
6380
|
+
*/
|
|
6381
|
+
type MaybeContext$2<T extends Descriptors$2> = globalThis.ContextualClient extends {
|
|
6382
|
+
host: Host$2;
|
|
6383
|
+
} ? BuildDescriptors$2<T, globalThis.ContextualClient['host']> : T;
|
|
4900
6384
|
|
|
4901
6385
|
interface SiteTranslatableProperties {
|
|
4902
6386
|
/** Total number of words that exist in the main_language */
|
|
@@ -5214,48 +6698,526 @@ interface TranslateSiteOptions {
|
|
|
5214
6698
|
/** Language into which the site content is translated */
|
|
5215
6699
|
translatedLanguage: Locale;
|
|
5216
6700
|
}
|
|
5217
|
-
interface GetSiteTranslatablesPropertiesOptions {
|
|
5218
|
-
/** Number of words already translated from main_language to translated_language */
|
|
5219
|
-
translatedLanguage?: Locale;
|
|
6701
|
+
interface GetSiteTranslatablesPropertiesOptions {
|
|
6702
|
+
/** Number of words already translated from main_language to translated_language */
|
|
6703
|
+
translatedLanguage?: Locale;
|
|
6704
|
+
}
|
|
6705
|
+
|
|
6706
|
+
declare function translateSite$1(httpClient: HttpClient$2): TranslateSiteSignature;
|
|
6707
|
+
interface TranslateSiteSignature {
|
|
6708
|
+
/**
|
|
6709
|
+
* Start a task to auto-translate all site content that hasn't been translated yet
|
|
6710
|
+
* @param - Language from which the site content is translated
|
|
6711
|
+
*/
|
|
6712
|
+
(mainLanguage: Locale, options: TranslateSiteOptions): Promise<void>;
|
|
6713
|
+
}
|
|
6714
|
+
declare function getSiteTranslatablesProperties$1(httpClient: HttpClient$2): GetSiteTranslatablesPropertiesSignature;
|
|
6715
|
+
interface GetSiteTranslatablesPropertiesSignature {
|
|
6716
|
+
/**
|
|
6717
|
+
* Receive the site's translation status
|
|
6718
|
+
* @param - Number of words included in main_language
|
|
6719
|
+
*/
|
|
6720
|
+
(mainLanguage: Locale, options?: GetSiteTranslatablesPropertiesOptions | undefined): Promise<GetSiteTranslatablesPropertiesResponse & GetSiteTranslatablesPropertiesResponseNonNullableFields>;
|
|
6721
|
+
}
|
|
6722
|
+
|
|
6723
|
+
declare const translateSite: MaybeContext$2<BuildRESTFunction$2<typeof translateSite$1> & typeof translateSite$1>;
|
|
6724
|
+
declare const getSiteTranslatablesProperties: MaybeContext$2<BuildRESTFunction$2<typeof getSiteTranslatablesProperties$1> & typeof getSiteTranslatablesProperties$1>;
|
|
6725
|
+
|
|
6726
|
+
type context$2_ApplicationTranslatableProperties = ApplicationTranslatableProperties;
|
|
6727
|
+
type context$2_Flag = Flag;
|
|
6728
|
+
declare const context$2_Flag: typeof Flag;
|
|
6729
|
+
type context$2_GetSiteTranslatablesPropertiesOptions = GetSiteTranslatablesPropertiesOptions;
|
|
6730
|
+
type context$2_GetSiteTranslatablesPropertiesRequest = GetSiteTranslatablesPropertiesRequest;
|
|
6731
|
+
type context$2_GetSiteTranslatablesPropertiesResponse = GetSiteTranslatablesPropertiesResponse;
|
|
6732
|
+
type context$2_GetSiteTranslatablesPropertiesResponseNonNullableFields = GetSiteTranslatablesPropertiesResponseNonNullableFields;
|
|
6733
|
+
type context$2_Locale = Locale;
|
|
6734
|
+
type context$2_SiteTranslatableProperties = SiteTranslatableProperties;
|
|
6735
|
+
type context$2_TranslateSiteOptions = TranslateSiteOptions;
|
|
6736
|
+
type context$2_TranslateSiteRequest = TranslateSiteRequest;
|
|
6737
|
+
type context$2_TranslateSiteResponse = TranslateSiteResponse;
|
|
6738
|
+
declare const context$2_getSiteTranslatablesProperties: typeof getSiteTranslatablesProperties;
|
|
6739
|
+
declare const context$2_translateSite: typeof translateSite;
|
|
6740
|
+
declare namespace context$2 {
|
|
6741
|
+
export { type context$2_ApplicationTranslatableProperties as ApplicationTranslatableProperties, context$2_Flag as Flag, type context$2_GetSiteTranslatablesPropertiesOptions as GetSiteTranslatablesPropertiesOptions, type context$2_GetSiteTranslatablesPropertiesRequest as GetSiteTranslatablesPropertiesRequest, type context$2_GetSiteTranslatablesPropertiesResponse as GetSiteTranslatablesPropertiesResponse, type context$2_GetSiteTranslatablesPropertiesResponseNonNullableFields as GetSiteTranslatablesPropertiesResponseNonNullableFields, type context$2_Locale as Locale, type context$2_SiteTranslatableProperties as SiteTranslatableProperties, type context$2_TranslateSiteOptions as TranslateSiteOptions, type context$2_TranslateSiteRequest as TranslateSiteRequest, type context$2_TranslateSiteResponse as TranslateSiteResponse, context$2_getSiteTranslatablesProperties as getSiteTranslatablesProperties, context$2_translateSite as translateSite };
|
|
6742
|
+
}
|
|
6743
|
+
|
|
6744
|
+
type HostModule$1<T, H extends Host$1> = {
|
|
6745
|
+
__type: 'host';
|
|
6746
|
+
create(host: H): T;
|
|
6747
|
+
};
|
|
6748
|
+
type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
|
|
6749
|
+
type Host$1<Environment = unknown> = {
|
|
6750
|
+
channel: {
|
|
6751
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
6752
|
+
disconnect: () => void;
|
|
6753
|
+
} | Promise<{
|
|
6754
|
+
disconnect: () => void;
|
|
6755
|
+
}>;
|
|
6756
|
+
};
|
|
6757
|
+
environment?: Environment;
|
|
6758
|
+
/**
|
|
6759
|
+
* Optional name of the environment, use for logging
|
|
6760
|
+
*/
|
|
6761
|
+
name?: string;
|
|
6762
|
+
/**
|
|
6763
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
6764
|
+
*/
|
|
6765
|
+
apiBaseUrl?: string;
|
|
6766
|
+
/**
|
|
6767
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
6768
|
+
* like internationalization, billing, etc.
|
|
6769
|
+
*/
|
|
6770
|
+
essentials?: {
|
|
6771
|
+
/**
|
|
6772
|
+
* The language of the currently viewed session
|
|
6773
|
+
*/
|
|
6774
|
+
language?: string;
|
|
6775
|
+
/**
|
|
6776
|
+
* The locale of the currently viewed session
|
|
6777
|
+
*/
|
|
6778
|
+
locale?: string;
|
|
6779
|
+
/**
|
|
6780
|
+
* Any headers that should be passed through to the API requests
|
|
6781
|
+
*/
|
|
6782
|
+
passThroughHeaders?: Record<string, string>;
|
|
6783
|
+
};
|
|
6784
|
+
};
|
|
6785
|
+
|
|
6786
|
+
type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
|
|
6787
|
+
interface HttpClient$1 {
|
|
6788
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
|
|
6789
|
+
fetchWithAuth: typeof fetch;
|
|
6790
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
6791
|
+
getActiveToken?: () => string | undefined;
|
|
6792
|
+
}
|
|
6793
|
+
type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
|
|
6794
|
+
type HttpResponse$1<T = any> = {
|
|
6795
|
+
data: T;
|
|
6796
|
+
status: number;
|
|
6797
|
+
statusText: string;
|
|
6798
|
+
headers: any;
|
|
6799
|
+
request?: any;
|
|
6800
|
+
};
|
|
6801
|
+
type RequestOptions$1<_TResponse = any, Data = any> = {
|
|
6802
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
6803
|
+
url: string;
|
|
6804
|
+
data?: Data;
|
|
6805
|
+
params?: URLSearchParams;
|
|
6806
|
+
} & APIMetadata$1;
|
|
6807
|
+
type APIMetadata$1 = {
|
|
6808
|
+
methodFqn?: string;
|
|
6809
|
+
entityFqdn?: string;
|
|
6810
|
+
packageName?: string;
|
|
6811
|
+
};
|
|
6812
|
+
type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
|
|
6813
|
+
type EventDefinition$1<Payload = unknown, Type extends string = string> = {
|
|
6814
|
+
__type: 'event-definition';
|
|
6815
|
+
type: Type;
|
|
6816
|
+
isDomainEvent?: boolean;
|
|
6817
|
+
transformations?: (envelope: unknown) => Payload;
|
|
6818
|
+
__payload: Payload;
|
|
6819
|
+
};
|
|
6820
|
+
declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
|
|
6821
|
+
type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
|
|
6822
|
+
type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
|
|
6823
|
+
|
|
6824
|
+
type ServicePluginMethodInput$1 = {
|
|
6825
|
+
request: any;
|
|
6826
|
+
metadata: any;
|
|
6827
|
+
};
|
|
6828
|
+
type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
|
|
6829
|
+
type ServicePluginMethodMetadata$1 = {
|
|
6830
|
+
name: string;
|
|
6831
|
+
primaryHttpMappingPath: string;
|
|
6832
|
+
transformations: {
|
|
6833
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
|
|
6834
|
+
toREST: (...args: unknown[]) => unknown;
|
|
6835
|
+
};
|
|
6836
|
+
};
|
|
6837
|
+
type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
|
|
6838
|
+
__type: 'service-plugin-definition';
|
|
6839
|
+
componentType: string;
|
|
6840
|
+
methods: ServicePluginMethodMetadata$1[];
|
|
6841
|
+
__contract: Contract;
|
|
6842
|
+
};
|
|
6843
|
+
declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
|
|
6844
|
+
type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
|
|
6845
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
|
|
6846
|
+
|
|
6847
|
+
type RequestContext$1 = {
|
|
6848
|
+
isSSR: boolean;
|
|
6849
|
+
host: string;
|
|
6850
|
+
protocol?: string;
|
|
6851
|
+
};
|
|
6852
|
+
type ResponseTransformer$1 = (data: any, headers?: any) => any;
|
|
6853
|
+
/**
|
|
6854
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
6855
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
6856
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
6857
|
+
*/
|
|
6858
|
+
type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
6859
|
+
type AmbassadorRequestOptions$1<T = any> = {
|
|
6860
|
+
_?: T;
|
|
6861
|
+
url?: string;
|
|
6862
|
+
method?: Method$1;
|
|
6863
|
+
params?: any;
|
|
6864
|
+
data?: any;
|
|
6865
|
+
transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
|
|
6866
|
+
};
|
|
6867
|
+
type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
|
|
6868
|
+
__isAmbassador: boolean;
|
|
6869
|
+
};
|
|
6870
|
+
type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
|
|
6871
|
+
type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
6872
|
+
|
|
6873
|
+
declare global {
|
|
6874
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
6875
|
+
interface SymbolConstructor {
|
|
6876
|
+
readonly observable: symbol;
|
|
6877
|
+
}
|
|
6878
|
+
}
|
|
6879
|
+
|
|
6880
|
+
declare const emptyObjectSymbol$1: unique symbol;
|
|
6881
|
+
|
|
6882
|
+
/**
|
|
6883
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
6884
|
+
|
|
6885
|
+
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)).
|
|
6886
|
+
|
|
6887
|
+
@example
|
|
6888
|
+
```
|
|
6889
|
+
import type {EmptyObject} from 'type-fest';
|
|
6890
|
+
|
|
6891
|
+
// The following illustrates the problem with `{}`.
|
|
6892
|
+
const foo1: {} = {}; // Pass
|
|
6893
|
+
const foo2: {} = []; // Pass
|
|
6894
|
+
const foo3: {} = 42; // Pass
|
|
6895
|
+
const foo4: {} = {a: 1}; // Pass
|
|
6896
|
+
|
|
6897
|
+
// With `EmptyObject` only the first case is valid.
|
|
6898
|
+
const bar1: EmptyObject = {}; // Pass
|
|
6899
|
+
const bar2: EmptyObject = 42; // Fail
|
|
6900
|
+
const bar3: EmptyObject = []; // Fail
|
|
6901
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
6902
|
+
```
|
|
6903
|
+
|
|
6904
|
+
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}.
|
|
6905
|
+
|
|
6906
|
+
@category Object
|
|
6907
|
+
*/
|
|
6908
|
+
type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
|
|
6909
|
+
|
|
6910
|
+
/**
|
|
6911
|
+
Returns a boolean for whether the two given types are equal.
|
|
6912
|
+
|
|
6913
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
6914
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
6915
|
+
|
|
6916
|
+
Use-cases:
|
|
6917
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
6918
|
+
|
|
6919
|
+
@example
|
|
6920
|
+
```
|
|
6921
|
+
import type {IsEqual} from 'type-fest';
|
|
6922
|
+
|
|
6923
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
6924
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
6925
|
+
type Includes<Value extends readonly any[], Item> =
|
|
6926
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
6927
|
+
? IsEqual<Value[0], Item> extends true
|
|
6928
|
+
? true
|
|
6929
|
+
: Includes<rest, Item>
|
|
6930
|
+
: false;
|
|
6931
|
+
```
|
|
6932
|
+
|
|
6933
|
+
@category Type Guard
|
|
6934
|
+
@category Utilities
|
|
6935
|
+
*/
|
|
6936
|
+
type IsEqual$1<A, B> =
|
|
6937
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
6938
|
+
(<G>() => G extends B ? 1 : 2)
|
|
6939
|
+
? true
|
|
6940
|
+
: false;
|
|
6941
|
+
|
|
6942
|
+
/**
|
|
6943
|
+
Filter out keys from an object.
|
|
6944
|
+
|
|
6945
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
6946
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
6947
|
+
Returns `Key` otherwise.
|
|
6948
|
+
|
|
6949
|
+
@example
|
|
6950
|
+
```
|
|
6951
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
6952
|
+
//=> never
|
|
6953
|
+
```
|
|
6954
|
+
|
|
6955
|
+
@example
|
|
6956
|
+
```
|
|
6957
|
+
type Filtered = Filter<'bar', string>;
|
|
6958
|
+
//=> never
|
|
6959
|
+
```
|
|
6960
|
+
|
|
6961
|
+
@example
|
|
6962
|
+
```
|
|
6963
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
6964
|
+
//=> 'bar'
|
|
6965
|
+
```
|
|
6966
|
+
|
|
6967
|
+
@see {Except}
|
|
6968
|
+
*/
|
|
6969
|
+
type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
6970
|
+
|
|
6971
|
+
type ExceptOptions$1 = {
|
|
6972
|
+
/**
|
|
6973
|
+
Disallow assigning non-specified properties.
|
|
6974
|
+
|
|
6975
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
6976
|
+
|
|
6977
|
+
@default false
|
|
6978
|
+
*/
|
|
6979
|
+
requireExactProps?: boolean;
|
|
6980
|
+
};
|
|
6981
|
+
|
|
6982
|
+
/**
|
|
6983
|
+
Create a type from an object type without certain keys.
|
|
6984
|
+
|
|
6985
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
6986
|
+
|
|
6987
|
+
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.
|
|
6988
|
+
|
|
6989
|
+
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)).
|
|
6990
|
+
|
|
6991
|
+
@example
|
|
6992
|
+
```
|
|
6993
|
+
import type {Except} from 'type-fest';
|
|
6994
|
+
|
|
6995
|
+
type Foo = {
|
|
6996
|
+
a: number;
|
|
6997
|
+
b: string;
|
|
6998
|
+
};
|
|
6999
|
+
|
|
7000
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
7001
|
+
//=> {b: string}
|
|
7002
|
+
|
|
7003
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
7004
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
7005
|
+
|
|
7006
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
7007
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
7008
|
+
|
|
7009
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
7010
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
7011
|
+
```
|
|
7012
|
+
|
|
7013
|
+
@category Object
|
|
7014
|
+
*/
|
|
7015
|
+
type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
|
|
7016
|
+
[KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
|
|
7017
|
+
} & (Options['requireExactProps'] extends true
|
|
7018
|
+
? Partial<Record<KeysType, never>>
|
|
7019
|
+
: {});
|
|
7020
|
+
|
|
7021
|
+
/**
|
|
7022
|
+
Returns a boolean for whether the given type is `never`.
|
|
7023
|
+
|
|
7024
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
7025
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
7026
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
7027
|
+
|
|
7028
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
7029
|
+
|
|
7030
|
+
@example
|
|
7031
|
+
```
|
|
7032
|
+
import type {IsNever, And} from 'type-fest';
|
|
7033
|
+
|
|
7034
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
7035
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
7036
|
+
And<
|
|
7037
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
7038
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
7039
|
+
>;
|
|
7040
|
+
|
|
7041
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
7042
|
+
AreStringsEqual<I, O> extends true
|
|
7043
|
+
? never
|
|
7044
|
+
: void;
|
|
7045
|
+
|
|
7046
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
7047
|
+
if (input === output) {
|
|
7048
|
+
process.exit(0);
|
|
7049
|
+
}
|
|
7050
|
+
}
|
|
7051
|
+
|
|
7052
|
+
endIfEqual('abc', 'abc');
|
|
7053
|
+
//=> never
|
|
7054
|
+
|
|
7055
|
+
endIfEqual('abc', '123');
|
|
7056
|
+
//=> void
|
|
7057
|
+
```
|
|
7058
|
+
|
|
7059
|
+
@category Type Guard
|
|
7060
|
+
@category Utilities
|
|
7061
|
+
*/
|
|
7062
|
+
type IsNever$1<T> = [T] extends [never] ? true : false;
|
|
7063
|
+
|
|
7064
|
+
/**
|
|
7065
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
7066
|
+
|
|
7067
|
+
@see {@link IsNever}
|
|
7068
|
+
|
|
7069
|
+
@example
|
|
7070
|
+
```
|
|
7071
|
+
import type {IfNever} from 'type-fest';
|
|
7072
|
+
|
|
7073
|
+
type ShouldBeTrue = IfNever<never>;
|
|
7074
|
+
//=> true
|
|
7075
|
+
|
|
7076
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
7077
|
+
//=> 'bar'
|
|
7078
|
+
```
|
|
7079
|
+
|
|
7080
|
+
@category Type Guard
|
|
7081
|
+
@category Utilities
|
|
7082
|
+
*/
|
|
7083
|
+
type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
7084
|
+
IsNever$1<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
7085
|
+
);
|
|
7086
|
+
|
|
7087
|
+
/**
|
|
7088
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
7089
|
+
|
|
7090
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
7091
|
+
|
|
7092
|
+
@example
|
|
7093
|
+
```
|
|
7094
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
7095
|
+
|
|
7096
|
+
interface Example {
|
|
7097
|
+
a: string;
|
|
7098
|
+
b: string | number;
|
|
7099
|
+
c?: string;
|
|
7100
|
+
d: {};
|
|
5220
7101
|
}
|
|
5221
7102
|
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
7103
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
7104
|
+
//=> 'a'
|
|
7105
|
+
```
|
|
7106
|
+
|
|
7107
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
7108
|
+
|
|
7109
|
+
@example
|
|
7110
|
+
```
|
|
7111
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
7112
|
+
|
|
7113
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
7114
|
+
//=> 'a' | 'c'
|
|
7115
|
+
```
|
|
7116
|
+
|
|
7117
|
+
@category Object
|
|
7118
|
+
*/
|
|
7119
|
+
type ConditionalKeys$1<Base, Condition> =
|
|
7120
|
+
{
|
|
7121
|
+
// Map through all the keys of the given base type.
|
|
7122
|
+
[Key in keyof Base]-?:
|
|
7123
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
7124
|
+
Base[Key] extends Condition
|
|
7125
|
+
// Retain this key
|
|
7126
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
7127
|
+
? IfNever$1<Base[Key], IfNever$1<Condition, Key, never>, Key>
|
|
7128
|
+
// Discard this key since the condition fails.
|
|
7129
|
+
: never;
|
|
7130
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
7131
|
+
}[keyof Base];
|
|
7132
|
+
|
|
7133
|
+
/**
|
|
7134
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
7135
|
+
|
|
7136
|
+
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.
|
|
7137
|
+
|
|
7138
|
+
@example
|
|
7139
|
+
```
|
|
7140
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
7141
|
+
|
|
7142
|
+
class Awesome {
|
|
7143
|
+
name: string;
|
|
7144
|
+
successes: number;
|
|
7145
|
+
failures: bigint;
|
|
7146
|
+
|
|
7147
|
+
run() {}
|
|
5229
7148
|
}
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
7149
|
+
|
|
7150
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
7151
|
+
//=> {run: () => void}
|
|
7152
|
+
```
|
|
7153
|
+
|
|
7154
|
+
@example
|
|
7155
|
+
```
|
|
7156
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
7157
|
+
|
|
7158
|
+
interface Example {
|
|
7159
|
+
a: string;
|
|
7160
|
+
b: string | number;
|
|
7161
|
+
c: () => void;
|
|
7162
|
+
d: {};
|
|
5237
7163
|
}
|
|
5238
7164
|
|
|
5239
|
-
|
|
5240
|
-
|
|
7165
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
7166
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
7167
|
+
```
|
|
7168
|
+
|
|
7169
|
+
@category Object
|
|
7170
|
+
*/
|
|
7171
|
+
type ConditionalExcept$1<Base, Condition> = Except$1<
|
|
7172
|
+
Base,
|
|
7173
|
+
ConditionalKeys$1<Base, Condition>
|
|
7174
|
+
>;
|
|
7175
|
+
|
|
7176
|
+
/**
|
|
7177
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
7178
|
+
* can either be a REST module or a host module.
|
|
7179
|
+
* This type is recursive, so it can describe nested modules.
|
|
7180
|
+
*/
|
|
7181
|
+
type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$1<any> | ServicePluginDefinition$1<any> | {
|
|
7182
|
+
[key: string]: Descriptors$1 | PublicMetadata$1 | any;
|
|
7183
|
+
};
|
|
7184
|
+
/**
|
|
7185
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
7186
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
7187
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
7188
|
+
* do not match the given host (as they will not work with the given host).
|
|
7189
|
+
*/
|
|
7190
|
+
type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
|
|
7191
|
+
done: T;
|
|
7192
|
+
recurse: T extends {
|
|
7193
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
|
|
7194
|
+
} ? 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<{
|
|
7195
|
+
[Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
|
|
7196
|
+
-1,
|
|
7197
|
+
0,
|
|
7198
|
+
1,
|
|
7199
|
+
2,
|
|
7200
|
+
3,
|
|
7201
|
+
4,
|
|
7202
|
+
5
|
|
7203
|
+
][Depth]> : never;
|
|
7204
|
+
}, EmptyObject$1>;
|
|
7205
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
7206
|
+
type PublicMetadata$1 = {
|
|
7207
|
+
PACKAGE_NAME?: string;
|
|
7208
|
+
};
|
|
5241
7209
|
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
type context$2_GetSiteTranslatablesPropertiesOptions = GetSiteTranslatablesPropertiesOptions;
|
|
5246
|
-
type context$2_GetSiteTranslatablesPropertiesRequest = GetSiteTranslatablesPropertiesRequest;
|
|
5247
|
-
type context$2_GetSiteTranslatablesPropertiesResponse = GetSiteTranslatablesPropertiesResponse;
|
|
5248
|
-
type context$2_GetSiteTranslatablesPropertiesResponseNonNullableFields = GetSiteTranslatablesPropertiesResponseNonNullableFields;
|
|
5249
|
-
type context$2_Locale = Locale;
|
|
5250
|
-
type context$2_SiteTranslatableProperties = SiteTranslatableProperties;
|
|
5251
|
-
type context$2_TranslateSiteOptions = TranslateSiteOptions;
|
|
5252
|
-
type context$2_TranslateSiteRequest = TranslateSiteRequest;
|
|
5253
|
-
type context$2_TranslateSiteResponse = TranslateSiteResponse;
|
|
5254
|
-
declare const context$2_getSiteTranslatablesProperties: typeof getSiteTranslatablesProperties;
|
|
5255
|
-
declare const context$2_translateSite: typeof translateSite;
|
|
5256
|
-
declare namespace context$2 {
|
|
5257
|
-
export { type context$2_ApplicationTranslatableProperties as ApplicationTranslatableProperties, context$2_Flag as Flag, type context$2_GetSiteTranslatablesPropertiesOptions as GetSiteTranslatablesPropertiesOptions, type context$2_GetSiteTranslatablesPropertiesRequest as GetSiteTranslatablesPropertiesRequest, type context$2_GetSiteTranslatablesPropertiesResponse as GetSiteTranslatablesPropertiesResponse, type context$2_GetSiteTranslatablesPropertiesResponseNonNullableFields as GetSiteTranslatablesPropertiesResponseNonNullableFields, type context$2_Locale as Locale, type context$2_SiteTranslatableProperties as SiteTranslatableProperties, type context$2_TranslateSiteOptions as TranslateSiteOptions, type context$2_TranslateSiteRequest as TranslateSiteRequest, type context$2_TranslateSiteResponse as TranslateSiteResponse, context$2_getSiteTranslatablesProperties as getSiteTranslatablesProperties, context$2_translateSite as translateSite };
|
|
7210
|
+
declare global {
|
|
7211
|
+
interface ContextualClient {
|
|
7212
|
+
}
|
|
5258
7213
|
}
|
|
7214
|
+
/**
|
|
7215
|
+
* A type used to create concerete types from SDK descriptors in
|
|
7216
|
+
* case a contextual client is available.
|
|
7217
|
+
*/
|
|
7218
|
+
type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
|
|
7219
|
+
host: Host$1;
|
|
7220
|
+
} ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
|
|
5259
7221
|
|
|
5260
7222
|
interface Content {
|
|
5261
7223
|
/**
|
|
@@ -8051,7 +10013,7 @@ interface BulkUpdateContentByKeyOptions {
|
|
|
8051
10013
|
returnEntity?: boolean;
|
|
8052
10014
|
}
|
|
8053
10015
|
|
|
8054
|
-
declare function createContent$1(httpClient: HttpClient): CreateContentSignature;
|
|
10016
|
+
declare function createContent$1(httpClient: HttpClient$1): CreateContentSignature;
|
|
8055
10017
|
interface CreateContentSignature {
|
|
8056
10018
|
/**
|
|
8057
10019
|
* Creates a translation content item.
|
|
@@ -8062,7 +10024,7 @@ interface CreateContentSignature {
|
|
|
8062
10024
|
*/
|
|
8063
10025
|
(content: Content): Promise<Content & ContentNonNullableFields>;
|
|
8064
10026
|
}
|
|
8065
|
-
declare function getContent$1(httpClient: HttpClient): GetContentSignature;
|
|
10027
|
+
declare function getContent$1(httpClient: HttpClient$1): GetContentSignature;
|
|
8066
10028
|
interface GetContentSignature {
|
|
8067
10029
|
/**
|
|
8068
10030
|
* Retrieves a translation content item.
|
|
@@ -8071,7 +10033,7 @@ interface GetContentSignature {
|
|
|
8071
10033
|
*/
|
|
8072
10034
|
(contentId: string): Promise<Content & ContentNonNullableFields>;
|
|
8073
10035
|
}
|
|
8074
|
-
declare function updateContent$1(httpClient: HttpClient): UpdateContentSignature;
|
|
10036
|
+
declare function updateContent$1(httpClient: HttpClient$1): UpdateContentSignature;
|
|
8075
10037
|
interface UpdateContentSignature {
|
|
8076
10038
|
/**
|
|
8077
10039
|
* Updates a translation content item by ID.
|
|
@@ -8090,7 +10052,7 @@ interface UpdateContentSignature {
|
|
|
8090
10052
|
*/
|
|
8091
10053
|
(_id: string | null, content: UpdateContent): Promise<Content & ContentNonNullableFields>;
|
|
8092
10054
|
}
|
|
8093
|
-
declare function updateContentByKey$1(httpClient: HttpClient): UpdateContentByKeySignature;
|
|
10055
|
+
declare function updateContentByKey$1(httpClient: HttpClient$1): UpdateContentByKeySignature;
|
|
8094
10056
|
interface UpdateContentByKeySignature {
|
|
8095
10057
|
/**
|
|
8096
10058
|
* Updates a translation content item using a unique key, which is a combination of `content.schemaId`, `content.entityId`, and `content.locale`.
|
|
@@ -8108,7 +10070,7 @@ interface UpdateContentByKeySignature {
|
|
|
8108
10070
|
*/
|
|
8109
10071
|
(content: Content): Promise<UpdateContentByKeyResponse & UpdateContentByKeyResponseNonNullableFields>;
|
|
8110
10072
|
}
|
|
8111
|
-
declare function deleteContent$1(httpClient: HttpClient): DeleteContentSignature;
|
|
10073
|
+
declare function deleteContent$1(httpClient: HttpClient$1): DeleteContentSignature;
|
|
8112
10074
|
interface DeleteContentSignature {
|
|
8113
10075
|
/**
|
|
8114
10076
|
* Deletes a translation content item.
|
|
@@ -8116,7 +10078,7 @@ interface DeleteContentSignature {
|
|
|
8116
10078
|
*/
|
|
8117
10079
|
(contentId: string): Promise<void>;
|
|
8118
10080
|
}
|
|
8119
|
-
declare function queryContents$1(httpClient: HttpClient): QueryContentsSignature;
|
|
10081
|
+
declare function queryContents$1(httpClient: HttpClient$1): QueryContentsSignature;
|
|
8120
10082
|
interface QueryContentsSignature {
|
|
8121
10083
|
/**
|
|
8122
10084
|
* Creates a query to retrieve a list of translation content items.
|
|
@@ -8136,7 +10098,7 @@ interface QueryContentsSignature {
|
|
|
8136
10098
|
*/
|
|
8137
10099
|
(options?: QueryContentsOptions | undefined): ContentsQueryBuilder;
|
|
8138
10100
|
}
|
|
8139
|
-
declare function searchContents$1(httpClient: HttpClient): SearchContentsSignature;
|
|
10101
|
+
declare function searchContents$1(httpClient: HttpClient$1): SearchContentsSignature;
|
|
8140
10102
|
interface SearchContentsSignature {
|
|
8141
10103
|
/**
|
|
8142
10104
|
* Retrieves a list of all translation content associated with a site that matches the search query, with optional data aggregation.
|
|
@@ -8151,7 +10113,7 @@ interface SearchContentsSignature {
|
|
|
8151
10113
|
*/
|
|
8152
10114
|
(options?: SearchContentsOptions | undefined): Promise<SearchContentsResponse & SearchContentsResponseNonNullableFields>;
|
|
8153
10115
|
}
|
|
8154
|
-
declare function bulkCreateContent$1(httpClient: HttpClient): BulkCreateContentSignature;
|
|
10116
|
+
declare function bulkCreateContent$1(httpClient: HttpClient$1): BulkCreateContentSignature;
|
|
8155
10117
|
interface BulkCreateContentSignature {
|
|
8156
10118
|
/**
|
|
8157
10119
|
* Creates multiple translation content items.
|
|
@@ -8161,7 +10123,7 @@ interface BulkCreateContentSignature {
|
|
|
8161
10123
|
*/
|
|
8162
10124
|
(contents: Content[], options?: BulkCreateContentOptions | undefined): Promise<BulkCreateContentResponse & BulkCreateContentResponseNonNullableFields>;
|
|
8163
10125
|
}
|
|
8164
|
-
declare function bulkUpdateContent$1(httpClient: HttpClient): BulkUpdateContentSignature;
|
|
10126
|
+
declare function bulkUpdateContent$1(httpClient: HttpClient$1): BulkUpdateContentSignature;
|
|
8165
10127
|
interface BulkUpdateContentSignature {
|
|
8166
10128
|
/**
|
|
8167
10129
|
* Updates multiple translation content items by ID.
|
|
@@ -8179,7 +10141,7 @@ interface BulkUpdateContentSignature {
|
|
|
8179
10141
|
*/
|
|
8180
10142
|
(contents: BulkUpdateContentRequestMaskedContent[], options?: BulkUpdateContentOptions | undefined): Promise<BulkUpdateContentResponse & BulkUpdateContentResponseNonNullableFields>;
|
|
8181
10143
|
}
|
|
8182
|
-
declare function bulkUpdateContentByKey$1(httpClient: HttpClient): BulkUpdateContentByKeySignature;
|
|
10144
|
+
declare function bulkUpdateContentByKey$1(httpClient: HttpClient$1): BulkUpdateContentByKeySignature;
|
|
8183
10145
|
interface BulkUpdateContentByKeySignature {
|
|
8184
10146
|
/**
|
|
8185
10147
|
* Updates multiple translation content items using a unique key, which is a combination of `contents.content.schemaId`, `contents.content.entityId`, and `contents.content.locale`.
|
|
@@ -8197,7 +10159,7 @@ interface BulkUpdateContentByKeySignature {
|
|
|
8197
10159
|
*/
|
|
8198
10160
|
(contents: MaskedContent[], options?: BulkUpdateContentByKeyOptions | undefined): Promise<BulkUpdateContentByKeyResponse & BulkUpdateContentByKeyResponseNonNullableFields>;
|
|
8199
10161
|
}
|
|
8200
|
-
declare function bulkDeleteContent$1(httpClient: HttpClient): BulkDeleteContentSignature;
|
|
10162
|
+
declare function bulkDeleteContent$1(httpClient: HttpClient$1): BulkDeleteContentSignature;
|
|
8201
10163
|
interface BulkDeleteContentSignature {
|
|
8202
10164
|
/**
|
|
8203
10165
|
* Deletes multiple translation content items.
|
|
@@ -8205,41 +10167,23 @@ interface BulkDeleteContentSignature {
|
|
|
8205
10167
|
*/
|
|
8206
10168
|
(contentIds: string[]): Promise<BulkDeleteContentResponse & BulkDeleteContentResponseNonNullableFields>;
|
|
8207
10169
|
}
|
|
8208
|
-
declare const onContentCreated$1: EventDefinition$
|
|
8209
|
-
declare const onContentUpdated$1: EventDefinition$
|
|
8210
|
-
declare const onContentDeleted$1: EventDefinition$
|
|
8211
|
-
|
|
8212
|
-
type EventDefinition$1<Payload = unknown, Type extends string = string> = {
|
|
8213
|
-
__type: 'event-definition';
|
|
8214
|
-
type: Type;
|
|
8215
|
-
isDomainEvent?: boolean;
|
|
8216
|
-
transformations?: (envelope: unknown) => Payload;
|
|
8217
|
-
__payload: Payload;
|
|
8218
|
-
};
|
|
8219
|
-
declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
|
|
8220
|
-
type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
|
|
8221
|
-
type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
|
|
8222
|
-
|
|
8223
|
-
declare global {
|
|
8224
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
8225
|
-
interface SymbolConstructor {
|
|
8226
|
-
readonly observable: symbol;
|
|
8227
|
-
}
|
|
8228
|
-
}
|
|
10170
|
+
declare const onContentCreated$1: EventDefinition$1<ContentCreatedEnvelope, "wix.multilingual.translation.v1.content_created">;
|
|
10171
|
+
declare const onContentUpdated$1: EventDefinition$1<ContentUpdatedEnvelope, "wix.multilingual.translation.v1.content_updated">;
|
|
10172
|
+
declare const onContentDeleted$1: EventDefinition$1<ContentDeletedEnvelope, "wix.multilingual.translation.v1.content_deleted">;
|
|
8229
10173
|
|
|
8230
10174
|
declare function createEventModule$1<T extends EventDefinition$1<any, string>>(eventDefinition: T): BuildEventDefinition$1<T> & T;
|
|
8231
10175
|
|
|
8232
|
-
declare const createContent: MaybeContext<BuildRESTFunction<typeof createContent$1> & typeof createContent$1>;
|
|
8233
|
-
declare const getContent: MaybeContext<BuildRESTFunction<typeof getContent$1> & typeof getContent$1>;
|
|
8234
|
-
declare const updateContent: MaybeContext<BuildRESTFunction<typeof updateContent$1> & typeof updateContent$1>;
|
|
8235
|
-
declare const updateContentByKey: MaybeContext<BuildRESTFunction<typeof updateContentByKey$1> & typeof updateContentByKey$1>;
|
|
8236
|
-
declare const deleteContent: MaybeContext<BuildRESTFunction<typeof deleteContent$1> & typeof deleteContent$1>;
|
|
8237
|
-
declare const queryContents: MaybeContext<BuildRESTFunction<typeof queryContents$1> & typeof queryContents$1>;
|
|
8238
|
-
declare const searchContents: MaybeContext<BuildRESTFunction<typeof searchContents$1> & typeof searchContents$1>;
|
|
8239
|
-
declare const bulkCreateContent: MaybeContext<BuildRESTFunction<typeof bulkCreateContent$1> & typeof bulkCreateContent$1>;
|
|
8240
|
-
declare const bulkUpdateContent: MaybeContext<BuildRESTFunction<typeof bulkUpdateContent$1> & typeof bulkUpdateContent$1>;
|
|
8241
|
-
declare const bulkUpdateContentByKey: MaybeContext<BuildRESTFunction<typeof bulkUpdateContentByKey$1> & typeof bulkUpdateContentByKey$1>;
|
|
8242
|
-
declare const bulkDeleteContent: MaybeContext<BuildRESTFunction<typeof bulkDeleteContent$1> & typeof bulkDeleteContent$1>;
|
|
10176
|
+
declare const createContent: MaybeContext$1<BuildRESTFunction$1<typeof createContent$1> & typeof createContent$1>;
|
|
10177
|
+
declare const getContent: MaybeContext$1<BuildRESTFunction$1<typeof getContent$1> & typeof getContent$1>;
|
|
10178
|
+
declare const updateContent: MaybeContext$1<BuildRESTFunction$1<typeof updateContent$1> & typeof updateContent$1>;
|
|
10179
|
+
declare const updateContentByKey: MaybeContext$1<BuildRESTFunction$1<typeof updateContentByKey$1> & typeof updateContentByKey$1>;
|
|
10180
|
+
declare const deleteContent: MaybeContext$1<BuildRESTFunction$1<typeof deleteContent$1> & typeof deleteContent$1>;
|
|
10181
|
+
declare const queryContents: MaybeContext$1<BuildRESTFunction$1<typeof queryContents$1> & typeof queryContents$1>;
|
|
10182
|
+
declare const searchContents: MaybeContext$1<BuildRESTFunction$1<typeof searchContents$1> & typeof searchContents$1>;
|
|
10183
|
+
declare const bulkCreateContent: MaybeContext$1<BuildRESTFunction$1<typeof bulkCreateContent$1> & typeof bulkCreateContent$1>;
|
|
10184
|
+
declare const bulkUpdateContent: MaybeContext$1<BuildRESTFunction$1<typeof bulkUpdateContent$1> & typeof bulkUpdateContent$1>;
|
|
10185
|
+
declare const bulkUpdateContentByKey: MaybeContext$1<BuildRESTFunction$1<typeof bulkUpdateContentByKey$1> & typeof bulkUpdateContentByKey$1>;
|
|
10186
|
+
declare const bulkDeleteContent: MaybeContext$1<BuildRESTFunction$1<typeof bulkDeleteContent$1> & typeof bulkDeleteContent$1>;
|
|
8243
10187
|
|
|
8244
10188
|
type _publicOnContentCreatedType = typeof onContentCreated$1;
|
|
8245
10189
|
/**
|
|
@@ -8553,6 +10497,484 @@ declare namespace context$1 {
|
|
|
8553
10497
|
export { type ActionEvent$1 as ActionEvent, type context$1_Aggregation as Aggregation, type context$1_AggregationData as AggregationData, type context$1_AggregationKindOneOf as AggregationKindOneOf, type context$1_AggregationResults as AggregationResults, type context$1_AggregationResultsResultOneOf as AggregationResultsResultOneOf, type context$1_AggregationResultsScalarResult as AggregationResultsScalarResult, context$1_AggregationType as AggregationType, context$1_Alignment as Alignment, type context$1_AnchorData as AnchorData, type context$1_AppEmbedData as AppEmbedData, type context$1_AppEmbedDataAppDataOneOf as AppEmbedDataAppDataOneOf, context$1_AppType as AppType, type context$1_ApplicationError as ApplicationError, type Asset$1 as Asset, type context$1_AudioData as AudioData, type context$1_Background as Background, type context$1_BackgroundBackgroundOneOf as BackgroundBackgroundOneOf, context$1_BackgroundType as BackgroundType, type BaseEventMetadata$1 as BaseEventMetadata, type context$1_BlockquoteData as BlockquoteData, type context$1_BookingData as BookingData, type context$1_Border as Border, type context$1_BorderColors as BorderColors, type context$1_BulkActionMetadata as BulkActionMetadata, type context$1_BulkContentResult as BulkContentResult, type context$1_BulkCreateContentOptions as BulkCreateContentOptions, type context$1_BulkCreateContentRequest as BulkCreateContentRequest, type context$1_BulkCreateContentResponse as BulkCreateContentResponse, type context$1_BulkCreateContentResponseNonNullableFields as BulkCreateContentResponseNonNullableFields, type context$1_BulkDeleteContentRequest as BulkDeleteContentRequest, type context$1_BulkDeleteContentResponse as BulkDeleteContentResponse, type context$1_BulkDeleteContentResponseBulkContentResult as BulkDeleteContentResponseBulkContentResult, type context$1_BulkDeleteContentResponseNonNullableFields as BulkDeleteContentResponseNonNullableFields, type context$1_BulkUpdateContentByKeyOptions as BulkUpdateContentByKeyOptions, type context$1_BulkUpdateContentByKeyRequest as BulkUpdateContentByKeyRequest, type context$1_BulkUpdateContentByKeyResponse as BulkUpdateContentByKeyResponse, type context$1_BulkUpdateContentByKeyResponseBulkContentResult as BulkUpdateContentByKeyResponseBulkContentResult, type context$1_BulkUpdateContentByKeyResponseNonNullableFields as BulkUpdateContentByKeyResponseNonNullableFields, type context$1_BulkUpdateContentOptions as BulkUpdateContentOptions, type context$1_BulkUpdateContentRequest as BulkUpdateContentRequest, type context$1_BulkUpdateContentRequestMaskedContent as BulkUpdateContentRequestMaskedContent, type context$1_BulkUpdateContentResponse as BulkUpdateContentResponse, type context$1_BulkUpdateContentResponseBulkContentResult as BulkUpdateContentResponseBulkContentResult, type context$1_BulkUpdateContentResponseNonNullableFields as BulkUpdateContentResponseNonNullableFields, type context$1_BulletedListData as BulletedListData, type context$1_ButtonData as ButtonData, type context$1_CellStyle as CellStyle, type context$1_CodeBlockData as CodeBlockData, type context$1_CollapsibleListData as CollapsibleListData, type context$1_ColorData as ColorData, type context$1_Colors as Colors, type context$1_Content as Content, type context$1_ContentCreatedEnvelope as ContentCreatedEnvelope, type context$1_ContentDeletedEnvelope as ContentDeletedEnvelope, type context$1_ContentField as ContentField, type context$1_ContentFieldValueOneOf as ContentFieldValueOneOf, type context$1_ContentNonNullableFields as ContentNonNullableFields, type context$1_ContentUpdatedEnvelope as ContentUpdatedEnvelope, type context$1_ContentsQueryBuilder as ContentsQueryBuilder, type context$1_ContentsQueryResult as ContentsQueryResult, type context$1_CreateContentRequest as CreateContentRequest, type context$1_CreateContentResponse as CreateContentResponse, type context$1_CreateContentResponseNonNullableFields as CreateContentResponseNonNullableFields, context$1_Crop as Crop, type CursorPaging$1 as CursorPaging, type CursorPagingMetadata$1 as CursorPagingMetadata, type CursorQuery$1 as CursorQuery, type CursorQueryPagingMethodOneOf$1 as CursorQueryPagingMethodOneOf, type context$1_CursorSearch as CursorSearch, type context$1_CursorSearchPagingMethodOneOf as CursorSearchPagingMethodOneOf, type Cursors$1 as Cursors, type context$1_DateHistogramAggregation as DateHistogramAggregation, type context$1_DateHistogramResult as DateHistogramResult, type context$1_DateHistogramResults as DateHistogramResults, type context$1_Decoration as Decoration, type context$1_DecorationDataOneOf as DecorationDataOneOf, context$1_DecorationType as DecorationType, type context$1_DeleteContentRequest as DeleteContentRequest, type context$1_DeleteContentResponse as DeleteContentResponse, type DeleteContext$1 as DeleteContext, DeleteStatus$1 as DeleteStatus, type context$1_Design as Design, type context$1_Dimensions as Dimensions, context$1_Direction as Direction, type context$1_DividerData as DividerData, type context$1_DocumentStyle as DocumentStyle, type DomainEvent$1 as DomainEvent, type DomainEventBodyOneOf$1 as DomainEventBodyOneOf, type context$1_EmbedData as EmbedData, type Empty$1 as Empty, type EntityCreatedEvent$1 as EntityCreatedEvent, type EntityDeletedEvent$1 as EntityDeletedEvent, type EntityUpdatedEvent$1 as EntityUpdatedEvent, type context$1_EventData as EventData, type EventMetadata$1 as EventMetadata, type context$1_FileData as FileData, type context$1_FileSource as FileSource, type context$1_FileSourceDataOneOf as FileSourceDataOneOf, type context$1_FontSizeData as FontSizeData, context$1_FontType as FontType, type context$1_GIF as GIF, type context$1_GIFData as GIFData, type context$1_GalleryData as GalleryData, type context$1_GalleryOptions as GalleryOptions, type context$1_GetContentRequest as GetContentRequest, type context$1_GetContentResponse as GetContentResponse, type context$1_GetContentResponseNonNullableFields as GetContentResponseNonNullableFields, type context$1_Gradient as Gradient, type context$1_GroupByAggregation as GroupByAggregation, type context$1_GroupByAggregationKindOneOf as GroupByAggregationKindOneOf, type context$1_GroupByValueResults as GroupByValueResults, type context$1_HTMLData as HTMLData, type context$1_HTMLDataDataOneOf as HTMLDataDataOneOf, type context$1_HeadingData as HeadingData, type context$1_Height as Height, type IdentificationData$1 as IdentificationData, type IdentificationDataIdOneOf$1 as IdentificationDataIdOneOf, type context$1_Image as Image, type context$1_ImageData as ImageData, type context$1_IncludeMissingValuesOptions as IncludeMissingValuesOptions, context$1_InitialExpandedItems as InitialExpandedItems, context$1_Interval as Interval, type context$1_Item as Item, type context$1_ItemDataOneOf as ItemDataOneOf, type context$1_ItemMetadata as ItemMetadata, type context$1_ItemStyle as ItemStyle, type context$1_Layout as Layout, context$1_LayoutType as LayoutType, context$1_LineStyle as LineStyle, type context$1_Link as Link, type context$1_LinkData as LinkData, type context$1_LinkDataOneOf as LinkDataOneOf, type context$1_LinkPreviewData as LinkPreviewData, type context$1_ListValue as ListValue, type context$1_MapData as MapData, type context$1_MapSettings as MapSettings, context$1_MapType as MapType, type context$1_MaskedContent as MaskedContent, type context$1_Media as Media, type context$1_MentionData as MentionData, type MessageEnvelope$1 as MessageEnvelope, type MetaSiteSpecialEvent$1 as MetaSiteSpecialEvent, type MetaSiteSpecialEventPayloadOneOf$1 as MetaSiteSpecialEventPayloadOneOf, type context$1_Metadata as Metadata, context$1_MissingValues as MissingValues, context$1_Mode as Mode, Namespace$1 as Namespace, type NamespaceChanged$1 as NamespaceChanged, type context$1_NestedAggregation as NestedAggregation, type context$1_NestedAggregationItem as NestedAggregationItem, type context$1_NestedAggregationItemKindOneOf as NestedAggregationItemKindOneOf, type context$1_NestedAggregationResults as NestedAggregationResults, type context$1_NestedAggregationResultsResultOneOf as NestedAggregationResultsResultOneOf, context$1_NestedAggregationType as NestedAggregationType, type context$1_NestedResultValue as NestedResultValue, type context$1_NestedResultValueResultOneOf as NestedResultValueResultOneOf, type context$1_NestedResults as NestedResults, type context$1_NestedValueAggregationResult as NestedValueAggregationResult, type context$1_Node as Node, type context$1_NodeDataOneOf as NodeDataOneOf, type context$1_NodeStyle as NodeStyle, context$1_NodeType as NodeType, context$1_NullValue as NullValue, type context$1_Oembed as Oembed, type context$1_Option as Option, type context$1_OptionDesign as OptionDesign, type context$1_OptionLayout as OptionLayout, type context$1_OrderedListData as OrderedListData, context$1_Orientation as Orientation, type context$1_PDFSettings as PDFSettings, type context$1_Paging as Paging, type context$1_PagingMetadataV2 as PagingMetadataV2, type context$1_ParagraphData as ParagraphData, type context$1_Permissions as Permissions, type context$1_PermissiveBulkUpdateContentRequest as PermissiveBulkUpdateContentRequest, type context$1_PermissiveBulkUpdateContentRequestMaskedContent as PermissiveBulkUpdateContentRequestMaskedContent, type context$1_PermissiveBulkUpdateContentResponse as PermissiveBulkUpdateContentResponse, type context$1_PermissiveBulkUpdateContentResponseBulkContentResult as PermissiveBulkUpdateContentResponseBulkContentResult, type context$1_PlaybackOptions as PlaybackOptions, type context$1_PluginContainerData as PluginContainerData, context$1_PluginContainerDataAlignment as PluginContainerDataAlignment, type context$1_PluginContainerDataWidth as PluginContainerDataWidth, type context$1_PluginContainerDataWidthDataOneOf as PluginContainerDataWidthDataOneOf, type context$1_Poll as Poll, type context$1_PollData as PollData, type context$1_PollDataLayout as PollDataLayout, type context$1_PollDesign as PollDesign, type context$1_PollLayout as PollLayout, context$1_PollLayoutDirection as PollLayoutDirection, context$1_PollLayoutType as PollLayoutType, context$1_PublishStatus as PublishStatus, type context$1_QueryContentsLegacyRequest as QueryContentsLegacyRequest, type context$1_QueryContentsLegacyResponse as QueryContentsLegacyResponse, type context$1_QueryContentsOptions as QueryContentsOptions, type context$1_QueryContentsRequest as QueryContentsRequest, type context$1_QueryContentsResponse as QueryContentsResponse, type context$1_QueryContentsResponseNonNullableFields as QueryContentsResponseNonNullableFields, type context$1_QueryV2 as QueryV2, type context$1_QueryV2PagingMethodOneOf as QueryV2PagingMethodOneOf, type context$1_RangeAggregation as RangeAggregation, type context$1_RangeAggregationResult as RangeAggregationResult, type context$1_RangeBucket as RangeBucket, type context$1_RangeResult as RangeResult, type context$1_RangeResults as RangeResults, type context$1_Rel as Rel, type context$1_RemoveContentsByFilterRequest as RemoveContentsByFilterRequest, type context$1_RemoveContentsByFilterResponse as RemoveContentsByFilterResponse, type context$1_RepublishContentByFilterRequest as RepublishContentByFilterRequest, type context$1_RepublishContentByFilterResponse as RepublishContentByFilterResponse, type RestoreInfo$1 as RestoreInfo, type context$1_Results as Results, type context$1_RichContent as RichContent, type context$1_ScalarAggregation as ScalarAggregation, type context$1_ScalarResult as ScalarResult, context$1_ScalarType as ScalarType, type context$1_SearchContentsOptions as SearchContentsOptions, type context$1_SearchContentsRequest as SearchContentsRequest, type context$1_SearchContentsResponse as SearchContentsResponse, type context$1_SearchContentsResponseNonNullableFields as SearchContentsResponseNonNullableFields, type context$1_SearchDetails as SearchDetails, type ServiceProvisioned$1 as ServiceProvisioned, type ServiceRemoved$1 as ServiceRemoved, type context$1_Settings as Settings, type SiteCreated$1 as SiteCreated, SiteCreatedContext$1 as SiteCreatedContext, type SiteDeleted$1 as SiteDeleted, type SiteHardDeleted$1 as SiteHardDeleted, type SiteMarkedAsTemplate$1 as SiteMarkedAsTemplate, type SiteMarkedAsWixSite$1 as SiteMarkedAsWixSite, type SitePublished$1 as SitePublished, type SiteRenamed$1 as SiteRenamed, type SiteTransferred$1 as SiteTransferred, type SiteUndeleted$1 as SiteUndeleted, type SiteUnpublished$1 as SiteUnpublished, context$1_SortDirection as SortDirection, SortOrder$1 as SortOrder, context$1_SortType as SortType, type Sorting$1 as Sorting, context$1_Source as Source, type context$1_Spoiler as Spoiler, type context$1_SpoilerData as SpoilerData, State$1 as State, type StudioAssigned$1 as StudioAssigned, type StudioUnassigned$1 as StudioUnassigned, type context$1_Styles as Styles, type context$1_TableCellData as TableCellData, type context$1_TableData as TableData, context$1_Target as Target, context$1_TextAlignment as TextAlignment, type context$1_TextData as TextData, type context$1_TextNodeStyle as TextNodeStyle, type context$1_TextStyle as TextStyle, type context$1_Thumbnails as Thumbnails, context$1_ThumbnailsAlignment as ThumbnailsAlignment, context$1_Type as Type, type context$1_UpdateContent as UpdateContent, type context$1_UpdateContentByKeyRequest as UpdateContentByKeyRequest, type context$1_UpdateContentByKeyResponse as UpdateContentByKeyResponse, type context$1_UpdateContentByKeyResponseNonNullableFields as UpdateContentByKeyResponseNonNullableFields, type context$1_UpdateContentRequest as UpdateContentRequest, type context$1_UpdateContentResponse as UpdateContentResponse, type context$1_UpdateContentResponseNonNullableFields as UpdateContentResponseNonNullableFields, context$1_UpdaterIdentity as UpdaterIdentity, type context$1_ValueAggregation as ValueAggregation, type context$1_ValueAggregationOptionsOneOf as ValueAggregationOptionsOneOf, type context$1_ValueAggregationResult as ValueAggregationResult, type context$1_ValueResult as ValueResult, type context$1_ValueResults as ValueResults, context$1_VerticalAlignment as VerticalAlignment, type context$1_Video as Video, type context$1_VideoData as VideoData, type context$1_VideoResolution as VideoResolution, context$1_ViewMode as ViewMode, context$1_ViewRole as ViewRole, context$1_VoteRole as VoteRole, WebhookIdentityType$1 as WebhookIdentityType, context$1_Width as Width, context$1_WidthType as WidthType, type context$1__publicOnContentCreatedType as _publicOnContentCreatedType, type context$1__publicOnContentDeletedType as _publicOnContentDeletedType, type context$1__publicOnContentUpdatedType as _publicOnContentUpdatedType, context$1_bulkCreateContent as bulkCreateContent, context$1_bulkDeleteContent as bulkDeleteContent, context$1_bulkUpdateContent as bulkUpdateContent, context$1_bulkUpdateContentByKey as bulkUpdateContentByKey, context$1_createContent as createContent, context$1_deleteContent as deleteContent, context$1_getContent as getContent, context$1_onContentCreated as onContentCreated, context$1_onContentDeleted as onContentDeleted, context$1_onContentUpdated as onContentUpdated, onContentCreated$1 as publicOnContentCreated, onContentDeleted$1 as publicOnContentDeleted, onContentUpdated$1 as publicOnContentUpdated, context$1_queryContents as queryContents, context$1_searchContents as searchContents, context$1_updateContent as updateContent, context$1_updateContentByKey as updateContentByKey };
|
|
8554
10498
|
}
|
|
8555
10499
|
|
|
10500
|
+
type HostModule<T, H extends Host> = {
|
|
10501
|
+
__type: 'host';
|
|
10502
|
+
create(host: H): T;
|
|
10503
|
+
};
|
|
10504
|
+
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
|
|
10505
|
+
type Host<Environment = unknown> = {
|
|
10506
|
+
channel: {
|
|
10507
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
10508
|
+
disconnect: () => void;
|
|
10509
|
+
} | Promise<{
|
|
10510
|
+
disconnect: () => void;
|
|
10511
|
+
}>;
|
|
10512
|
+
};
|
|
10513
|
+
environment?: Environment;
|
|
10514
|
+
/**
|
|
10515
|
+
* Optional name of the environment, use for logging
|
|
10516
|
+
*/
|
|
10517
|
+
name?: string;
|
|
10518
|
+
/**
|
|
10519
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
10520
|
+
*/
|
|
10521
|
+
apiBaseUrl?: string;
|
|
10522
|
+
/**
|
|
10523
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
10524
|
+
* like internationalization, billing, etc.
|
|
10525
|
+
*/
|
|
10526
|
+
essentials?: {
|
|
10527
|
+
/**
|
|
10528
|
+
* The language of the currently viewed session
|
|
10529
|
+
*/
|
|
10530
|
+
language?: string;
|
|
10531
|
+
/**
|
|
10532
|
+
* The locale of the currently viewed session
|
|
10533
|
+
*/
|
|
10534
|
+
locale?: string;
|
|
10535
|
+
/**
|
|
10536
|
+
* Any headers that should be passed through to the API requests
|
|
10537
|
+
*/
|
|
10538
|
+
passThroughHeaders?: Record<string, string>;
|
|
10539
|
+
};
|
|
10540
|
+
};
|
|
10541
|
+
|
|
10542
|
+
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
10543
|
+
interface HttpClient {
|
|
10544
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
10545
|
+
fetchWithAuth: typeof fetch;
|
|
10546
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
10547
|
+
getActiveToken?: () => string | undefined;
|
|
10548
|
+
}
|
|
10549
|
+
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
10550
|
+
type HttpResponse<T = any> = {
|
|
10551
|
+
data: T;
|
|
10552
|
+
status: number;
|
|
10553
|
+
statusText: string;
|
|
10554
|
+
headers: any;
|
|
10555
|
+
request?: any;
|
|
10556
|
+
};
|
|
10557
|
+
type RequestOptions<_TResponse = any, Data = any> = {
|
|
10558
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
10559
|
+
url: string;
|
|
10560
|
+
data?: Data;
|
|
10561
|
+
params?: URLSearchParams;
|
|
10562
|
+
} & APIMetadata;
|
|
10563
|
+
type APIMetadata = {
|
|
10564
|
+
methodFqn?: string;
|
|
10565
|
+
entityFqdn?: string;
|
|
10566
|
+
packageName?: string;
|
|
10567
|
+
};
|
|
10568
|
+
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
10569
|
+
type EventDefinition<Payload = unknown, Type extends string = string> = {
|
|
10570
|
+
__type: 'event-definition';
|
|
10571
|
+
type: Type;
|
|
10572
|
+
isDomainEvent?: boolean;
|
|
10573
|
+
transformations?: (envelope: unknown) => Payload;
|
|
10574
|
+
__payload: Payload;
|
|
10575
|
+
};
|
|
10576
|
+
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
|
|
10577
|
+
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
|
|
10578
|
+
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
|
|
10579
|
+
|
|
10580
|
+
type ServicePluginMethodInput = {
|
|
10581
|
+
request: any;
|
|
10582
|
+
metadata: any;
|
|
10583
|
+
};
|
|
10584
|
+
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
|
|
10585
|
+
type ServicePluginMethodMetadata = {
|
|
10586
|
+
name: string;
|
|
10587
|
+
primaryHttpMappingPath: string;
|
|
10588
|
+
transformations: {
|
|
10589
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
|
|
10590
|
+
toREST: (...args: unknown[]) => unknown;
|
|
10591
|
+
};
|
|
10592
|
+
};
|
|
10593
|
+
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
|
|
10594
|
+
__type: 'service-plugin-definition';
|
|
10595
|
+
componentType: string;
|
|
10596
|
+
methods: ServicePluginMethodMetadata[];
|
|
10597
|
+
__contract: Contract;
|
|
10598
|
+
};
|
|
10599
|
+
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
|
|
10600
|
+
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
|
|
10601
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
|
|
10602
|
+
|
|
10603
|
+
type RequestContext = {
|
|
10604
|
+
isSSR: boolean;
|
|
10605
|
+
host: string;
|
|
10606
|
+
protocol?: string;
|
|
10607
|
+
};
|
|
10608
|
+
type ResponseTransformer = (data: any, headers?: any) => any;
|
|
10609
|
+
/**
|
|
10610
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
10611
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
10612
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
10613
|
+
*/
|
|
10614
|
+
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
10615
|
+
type AmbassadorRequestOptions<T = any> = {
|
|
10616
|
+
_?: T;
|
|
10617
|
+
url?: string;
|
|
10618
|
+
method?: Method;
|
|
10619
|
+
params?: any;
|
|
10620
|
+
data?: any;
|
|
10621
|
+
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
10622
|
+
};
|
|
10623
|
+
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
10624
|
+
__isAmbassador: boolean;
|
|
10625
|
+
};
|
|
10626
|
+
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
|
|
10627
|
+
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
10628
|
+
|
|
10629
|
+
declare global {
|
|
10630
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
10631
|
+
interface SymbolConstructor {
|
|
10632
|
+
readonly observable: symbol;
|
|
10633
|
+
}
|
|
10634
|
+
}
|
|
10635
|
+
|
|
10636
|
+
declare const emptyObjectSymbol: unique symbol;
|
|
10637
|
+
|
|
10638
|
+
/**
|
|
10639
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
10640
|
+
|
|
10641
|
+
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)).
|
|
10642
|
+
|
|
10643
|
+
@example
|
|
10644
|
+
```
|
|
10645
|
+
import type {EmptyObject} from 'type-fest';
|
|
10646
|
+
|
|
10647
|
+
// The following illustrates the problem with `{}`.
|
|
10648
|
+
const foo1: {} = {}; // Pass
|
|
10649
|
+
const foo2: {} = []; // Pass
|
|
10650
|
+
const foo3: {} = 42; // Pass
|
|
10651
|
+
const foo4: {} = {a: 1}; // Pass
|
|
10652
|
+
|
|
10653
|
+
// With `EmptyObject` only the first case is valid.
|
|
10654
|
+
const bar1: EmptyObject = {}; // Pass
|
|
10655
|
+
const bar2: EmptyObject = 42; // Fail
|
|
10656
|
+
const bar3: EmptyObject = []; // Fail
|
|
10657
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
10658
|
+
```
|
|
10659
|
+
|
|
10660
|
+
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}.
|
|
10661
|
+
|
|
10662
|
+
@category Object
|
|
10663
|
+
*/
|
|
10664
|
+
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
10665
|
+
|
|
10666
|
+
/**
|
|
10667
|
+
Returns a boolean for whether the two given types are equal.
|
|
10668
|
+
|
|
10669
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
10670
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
10671
|
+
|
|
10672
|
+
Use-cases:
|
|
10673
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
10674
|
+
|
|
10675
|
+
@example
|
|
10676
|
+
```
|
|
10677
|
+
import type {IsEqual} from 'type-fest';
|
|
10678
|
+
|
|
10679
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
10680
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
10681
|
+
type Includes<Value extends readonly any[], Item> =
|
|
10682
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
10683
|
+
? IsEqual<Value[0], Item> extends true
|
|
10684
|
+
? true
|
|
10685
|
+
: Includes<rest, Item>
|
|
10686
|
+
: false;
|
|
10687
|
+
```
|
|
10688
|
+
|
|
10689
|
+
@category Type Guard
|
|
10690
|
+
@category Utilities
|
|
10691
|
+
*/
|
|
10692
|
+
type IsEqual<A, B> =
|
|
10693
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
10694
|
+
(<G>() => G extends B ? 1 : 2)
|
|
10695
|
+
? true
|
|
10696
|
+
: false;
|
|
10697
|
+
|
|
10698
|
+
/**
|
|
10699
|
+
Filter out keys from an object.
|
|
10700
|
+
|
|
10701
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
10702
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
10703
|
+
Returns `Key` otherwise.
|
|
10704
|
+
|
|
10705
|
+
@example
|
|
10706
|
+
```
|
|
10707
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
10708
|
+
//=> never
|
|
10709
|
+
```
|
|
10710
|
+
|
|
10711
|
+
@example
|
|
10712
|
+
```
|
|
10713
|
+
type Filtered = Filter<'bar', string>;
|
|
10714
|
+
//=> never
|
|
10715
|
+
```
|
|
10716
|
+
|
|
10717
|
+
@example
|
|
10718
|
+
```
|
|
10719
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
10720
|
+
//=> 'bar'
|
|
10721
|
+
```
|
|
10722
|
+
|
|
10723
|
+
@see {Except}
|
|
10724
|
+
*/
|
|
10725
|
+
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
10726
|
+
|
|
10727
|
+
type ExceptOptions = {
|
|
10728
|
+
/**
|
|
10729
|
+
Disallow assigning non-specified properties.
|
|
10730
|
+
|
|
10731
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
10732
|
+
|
|
10733
|
+
@default false
|
|
10734
|
+
*/
|
|
10735
|
+
requireExactProps?: boolean;
|
|
10736
|
+
};
|
|
10737
|
+
|
|
10738
|
+
/**
|
|
10739
|
+
Create a type from an object type without certain keys.
|
|
10740
|
+
|
|
10741
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
10742
|
+
|
|
10743
|
+
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.
|
|
10744
|
+
|
|
10745
|
+
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)).
|
|
10746
|
+
|
|
10747
|
+
@example
|
|
10748
|
+
```
|
|
10749
|
+
import type {Except} from 'type-fest';
|
|
10750
|
+
|
|
10751
|
+
type Foo = {
|
|
10752
|
+
a: number;
|
|
10753
|
+
b: string;
|
|
10754
|
+
};
|
|
10755
|
+
|
|
10756
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
10757
|
+
//=> {b: string}
|
|
10758
|
+
|
|
10759
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
10760
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
10761
|
+
|
|
10762
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
10763
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
10764
|
+
|
|
10765
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
10766
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
10767
|
+
```
|
|
10768
|
+
|
|
10769
|
+
@category Object
|
|
10770
|
+
*/
|
|
10771
|
+
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
|
|
10772
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
10773
|
+
} & (Options['requireExactProps'] extends true
|
|
10774
|
+
? Partial<Record<KeysType, never>>
|
|
10775
|
+
: {});
|
|
10776
|
+
|
|
10777
|
+
/**
|
|
10778
|
+
Returns a boolean for whether the given type is `never`.
|
|
10779
|
+
|
|
10780
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
10781
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
10782
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
10783
|
+
|
|
10784
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
10785
|
+
|
|
10786
|
+
@example
|
|
10787
|
+
```
|
|
10788
|
+
import type {IsNever, And} from 'type-fest';
|
|
10789
|
+
|
|
10790
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
10791
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
10792
|
+
And<
|
|
10793
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
10794
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
10795
|
+
>;
|
|
10796
|
+
|
|
10797
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
10798
|
+
AreStringsEqual<I, O> extends true
|
|
10799
|
+
? never
|
|
10800
|
+
: void;
|
|
10801
|
+
|
|
10802
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
10803
|
+
if (input === output) {
|
|
10804
|
+
process.exit(0);
|
|
10805
|
+
}
|
|
10806
|
+
}
|
|
10807
|
+
|
|
10808
|
+
endIfEqual('abc', 'abc');
|
|
10809
|
+
//=> never
|
|
10810
|
+
|
|
10811
|
+
endIfEqual('abc', '123');
|
|
10812
|
+
//=> void
|
|
10813
|
+
```
|
|
10814
|
+
|
|
10815
|
+
@category Type Guard
|
|
10816
|
+
@category Utilities
|
|
10817
|
+
*/
|
|
10818
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
10819
|
+
|
|
10820
|
+
/**
|
|
10821
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
10822
|
+
|
|
10823
|
+
@see {@link IsNever}
|
|
10824
|
+
|
|
10825
|
+
@example
|
|
10826
|
+
```
|
|
10827
|
+
import type {IfNever} from 'type-fest';
|
|
10828
|
+
|
|
10829
|
+
type ShouldBeTrue = IfNever<never>;
|
|
10830
|
+
//=> true
|
|
10831
|
+
|
|
10832
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
10833
|
+
//=> 'bar'
|
|
10834
|
+
```
|
|
10835
|
+
|
|
10836
|
+
@category Type Guard
|
|
10837
|
+
@category Utilities
|
|
10838
|
+
*/
|
|
10839
|
+
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
10840
|
+
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
10841
|
+
);
|
|
10842
|
+
|
|
10843
|
+
/**
|
|
10844
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
10845
|
+
|
|
10846
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
10847
|
+
|
|
10848
|
+
@example
|
|
10849
|
+
```
|
|
10850
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
10851
|
+
|
|
10852
|
+
interface Example {
|
|
10853
|
+
a: string;
|
|
10854
|
+
b: string | number;
|
|
10855
|
+
c?: string;
|
|
10856
|
+
d: {};
|
|
10857
|
+
}
|
|
10858
|
+
|
|
10859
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
10860
|
+
//=> 'a'
|
|
10861
|
+
```
|
|
10862
|
+
|
|
10863
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
10864
|
+
|
|
10865
|
+
@example
|
|
10866
|
+
```
|
|
10867
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
10868
|
+
|
|
10869
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
10870
|
+
//=> 'a' | 'c'
|
|
10871
|
+
```
|
|
10872
|
+
|
|
10873
|
+
@category Object
|
|
10874
|
+
*/
|
|
10875
|
+
type ConditionalKeys<Base, Condition> =
|
|
10876
|
+
{
|
|
10877
|
+
// Map through all the keys of the given base type.
|
|
10878
|
+
[Key in keyof Base]-?:
|
|
10879
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
10880
|
+
Base[Key] extends Condition
|
|
10881
|
+
// Retain this key
|
|
10882
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
10883
|
+
? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
|
|
10884
|
+
// Discard this key since the condition fails.
|
|
10885
|
+
: never;
|
|
10886
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
10887
|
+
}[keyof Base];
|
|
10888
|
+
|
|
10889
|
+
/**
|
|
10890
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
10891
|
+
|
|
10892
|
+
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.
|
|
10893
|
+
|
|
10894
|
+
@example
|
|
10895
|
+
```
|
|
10896
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
10897
|
+
|
|
10898
|
+
class Awesome {
|
|
10899
|
+
name: string;
|
|
10900
|
+
successes: number;
|
|
10901
|
+
failures: bigint;
|
|
10902
|
+
|
|
10903
|
+
run() {}
|
|
10904
|
+
}
|
|
10905
|
+
|
|
10906
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
10907
|
+
//=> {run: () => void}
|
|
10908
|
+
```
|
|
10909
|
+
|
|
10910
|
+
@example
|
|
10911
|
+
```
|
|
10912
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
10913
|
+
|
|
10914
|
+
interface Example {
|
|
10915
|
+
a: string;
|
|
10916
|
+
b: string | number;
|
|
10917
|
+
c: () => void;
|
|
10918
|
+
d: {};
|
|
10919
|
+
}
|
|
10920
|
+
|
|
10921
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
10922
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
10923
|
+
```
|
|
10924
|
+
|
|
10925
|
+
@category Object
|
|
10926
|
+
*/
|
|
10927
|
+
type ConditionalExcept<Base, Condition> = Except<
|
|
10928
|
+
Base,
|
|
10929
|
+
ConditionalKeys<Base, Condition>
|
|
10930
|
+
>;
|
|
10931
|
+
|
|
10932
|
+
/**
|
|
10933
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
10934
|
+
* can either be a REST module or a host module.
|
|
10935
|
+
* This type is recursive, so it can describe nested modules.
|
|
10936
|
+
*/
|
|
10937
|
+
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
|
|
10938
|
+
[key: string]: Descriptors | PublicMetadata | any;
|
|
10939
|
+
};
|
|
10940
|
+
/**
|
|
10941
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
10942
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
10943
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
10944
|
+
* do not match the given host (as they will not work with the given host).
|
|
10945
|
+
*/
|
|
10946
|
+
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
|
|
10947
|
+
done: T;
|
|
10948
|
+
recurse: T extends {
|
|
10949
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE;
|
|
10950
|
+
} ? 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<{
|
|
10951
|
+
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
|
|
10952
|
+
-1,
|
|
10953
|
+
0,
|
|
10954
|
+
1,
|
|
10955
|
+
2,
|
|
10956
|
+
3,
|
|
10957
|
+
4,
|
|
10958
|
+
5
|
|
10959
|
+
][Depth]> : never;
|
|
10960
|
+
}, EmptyObject>;
|
|
10961
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
10962
|
+
type PublicMetadata = {
|
|
10963
|
+
PACKAGE_NAME?: string;
|
|
10964
|
+
};
|
|
10965
|
+
|
|
10966
|
+
declare global {
|
|
10967
|
+
interface ContextualClient {
|
|
10968
|
+
}
|
|
10969
|
+
}
|
|
10970
|
+
/**
|
|
10971
|
+
* A type used to create concerete types from SDK descriptors in
|
|
10972
|
+
* case a contextual client is available.
|
|
10973
|
+
*/
|
|
10974
|
+
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
10975
|
+
host: Host;
|
|
10976
|
+
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
10977
|
+
|
|
8556
10978
|
interface Schema {
|
|
8557
10979
|
/**
|
|
8558
10980
|
* Translation schema ID.
|
|
@@ -9524,27 +11946,9 @@ interface ListSiteSchemasSignature {
|
|
|
9524
11946
|
*/
|
|
9525
11947
|
(options?: ListSiteSchemasOptions | undefined): Promise<ListSiteSchemasResponse & ListSiteSchemasResponseNonNullableFields>;
|
|
9526
11948
|
}
|
|
9527
|
-
declare const onSchemaCreated$1: EventDefinition
|
|
9528
|
-
declare const onSchemaUpdated$1: EventDefinition
|
|
9529
|
-
declare const onSchemaDeleted$1: EventDefinition
|
|
9530
|
-
|
|
9531
|
-
type EventDefinition<Payload = unknown, Type extends string = string> = {
|
|
9532
|
-
__type: 'event-definition';
|
|
9533
|
-
type: Type;
|
|
9534
|
-
isDomainEvent?: boolean;
|
|
9535
|
-
transformations?: (envelope: unknown) => Payload;
|
|
9536
|
-
__payload: Payload;
|
|
9537
|
-
};
|
|
9538
|
-
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
|
|
9539
|
-
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
|
|
9540
|
-
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
|
|
9541
|
-
|
|
9542
|
-
declare global {
|
|
9543
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
9544
|
-
interface SymbolConstructor {
|
|
9545
|
-
readonly observable: symbol;
|
|
9546
|
-
}
|
|
9547
|
-
}
|
|
11949
|
+
declare const onSchemaCreated$1: EventDefinition<SchemaCreatedEnvelope, "wix.multilingual.translation.v1.schema_created">;
|
|
11950
|
+
declare const onSchemaUpdated$1: EventDefinition<SchemaUpdatedEnvelope, "wix.multilingual.translation.v1.schema_updated">;
|
|
11951
|
+
declare const onSchemaDeleted$1: EventDefinition<SchemaDeletedEnvelope, "wix.multilingual.translation.v1.schema_deleted">;
|
|
9548
11952
|
|
|
9549
11953
|
declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
|
|
9550
11954
|
|