@wix/multilingual 1.0.50 → 1.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/type-bundles/context.bundle.d.ts +2574 -104
- package/type-bundles/index.bundle.d.ts +2574 -104
|
@@ -1,39 +1,127 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type HostModule$5<T, H extends Host$5> = {
|
|
2
|
+
__type: 'host';
|
|
3
|
+
create(host: H): T;
|
|
4
|
+
};
|
|
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
|
+
channel: {
|
|
8
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
9
|
+
disconnect: () => void;
|
|
10
|
+
} | Promise<{
|
|
11
|
+
disconnect: () => void;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
environment?: Environment;
|
|
15
|
+
/**
|
|
16
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
17
|
+
*/
|
|
18
|
+
apiBaseUrl?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
21
|
+
* like internationalization, billing, etc.
|
|
22
|
+
*/
|
|
23
|
+
essentials?: {
|
|
24
|
+
/**
|
|
25
|
+
* The language of the currently viewed session
|
|
26
|
+
*/
|
|
27
|
+
language?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The locale of the currently viewed session
|
|
30
|
+
*/
|
|
31
|
+
locale?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Any headers that should be passed through to the API requests
|
|
34
|
+
*/
|
|
35
|
+
passThroughHeaders?: Record<string, string>;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type RESTFunctionDescriptor$5<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$5) => T;
|
|
40
|
+
interface HttpClient$5 {
|
|
41
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$5<TResponse, TData>): Promise<HttpResponse$5<TResponse>>;
|
|
4
42
|
fetchWithAuth: typeof fetch;
|
|
5
43
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
44
|
+
getActiveToken?: () => string | undefined;
|
|
6
45
|
}
|
|
7
|
-
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
8
|
-
type HttpResponse<T = any> = {
|
|
46
|
+
type RequestOptionsFactory$5<TResponse = any, TData = any> = (context: any) => RequestOptions$5<TResponse, TData>;
|
|
47
|
+
type HttpResponse$5<T = any> = {
|
|
9
48
|
data: T;
|
|
10
49
|
status: number;
|
|
11
50
|
statusText: string;
|
|
12
51
|
headers: any;
|
|
13
52
|
request?: any;
|
|
14
53
|
};
|
|
15
|
-
type RequestOptions<_TResponse = any, Data = any> = {
|
|
54
|
+
type RequestOptions$5<_TResponse = any, Data = any> = {
|
|
16
55
|
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
17
56
|
url: string;
|
|
18
57
|
data?: Data;
|
|
19
58
|
params?: URLSearchParams;
|
|
20
|
-
} & APIMetadata;
|
|
21
|
-
type APIMetadata = {
|
|
59
|
+
} & APIMetadata$5;
|
|
60
|
+
type APIMetadata$5 = {
|
|
22
61
|
methodFqn?: string;
|
|
23
62
|
entityFqdn?: string;
|
|
24
63
|
packageName?: string;
|
|
25
64
|
};
|
|
26
|
-
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
27
|
-
type EventDefinition<Payload = unknown, Type extends string = string> = {
|
|
65
|
+
type BuildRESTFunction$5<T extends RESTFunctionDescriptor$5> = T extends RESTFunctionDescriptor$5<infer U> ? U : never;
|
|
66
|
+
type EventDefinition$8<Payload = unknown, Type extends string = string> = {
|
|
28
67
|
__type: 'event-definition';
|
|
29
68
|
type: Type;
|
|
30
69
|
isDomainEvent?: boolean;
|
|
31
70
|
transformations?: (envelope: unknown) => Payload;
|
|
32
71
|
__payload: Payload;
|
|
33
72
|
};
|
|
34
|
-
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
|
|
35
|
-
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
|
|
36
|
-
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
|
|
73
|
+
declare function EventDefinition$8<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$8<Payload, Type>;
|
|
74
|
+
type EventHandler$8<T extends EventDefinition$8> = (payload: T['__payload']) => void | Promise<void>;
|
|
75
|
+
type BuildEventDefinition$8<T extends EventDefinition$8<any, string>> = (handler: EventHandler$8<T>) => void;
|
|
76
|
+
|
|
77
|
+
type ServicePluginMethodInput$5 = {
|
|
78
|
+
request: any;
|
|
79
|
+
metadata: any;
|
|
80
|
+
};
|
|
81
|
+
type ServicePluginContract$5 = Record<string, (payload: ServicePluginMethodInput$5) => unknown | Promise<unknown>>;
|
|
82
|
+
type ServicePluginMethodMetadata$5 = {
|
|
83
|
+
name: string;
|
|
84
|
+
primaryHttpMappingPath: string;
|
|
85
|
+
transformations: {
|
|
86
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$5;
|
|
87
|
+
toREST: (...args: unknown[]) => unknown;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
type ServicePluginDefinition$5<Contract extends ServicePluginContract$5> = {
|
|
91
|
+
__type: 'service-plugin-definition';
|
|
92
|
+
componentType: string;
|
|
93
|
+
methods: ServicePluginMethodMetadata$5[];
|
|
94
|
+
__contract: Contract;
|
|
95
|
+
};
|
|
96
|
+
declare function ServicePluginDefinition$5<Contract extends ServicePluginContract$5>(componentType: string, methods: ServicePluginMethodMetadata$5[]): ServicePluginDefinition$5<Contract>;
|
|
97
|
+
type BuildServicePluginDefinition$5<T extends ServicePluginDefinition$5<any>> = (implementation: T['__contract']) => void;
|
|
98
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$5 = "wix_spi_error";
|
|
99
|
+
|
|
100
|
+
type RequestContext$5 = {
|
|
101
|
+
isSSR: boolean;
|
|
102
|
+
host: string;
|
|
103
|
+
protocol?: string;
|
|
104
|
+
};
|
|
105
|
+
type ResponseTransformer$5 = (data: any, headers?: any) => any;
|
|
106
|
+
/**
|
|
107
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
108
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
109
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
110
|
+
*/
|
|
111
|
+
type Method$5 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
112
|
+
type AmbassadorRequestOptions$5<T = any> = {
|
|
113
|
+
_?: T;
|
|
114
|
+
url?: string;
|
|
115
|
+
method?: Method$5;
|
|
116
|
+
params?: any;
|
|
117
|
+
data?: any;
|
|
118
|
+
transformResponse?: ResponseTransformer$5 | ResponseTransformer$5[];
|
|
119
|
+
};
|
|
120
|
+
type AmbassadorFactory$5<Request, Response> = (payload: Request) => ((context: RequestContext$5) => AmbassadorRequestOptions$5<Response>) & {
|
|
121
|
+
__isAmbassador: boolean;
|
|
122
|
+
};
|
|
123
|
+
type AmbassadorFunctionDescriptor$5<Request = any, Response = any> = AmbassadorFactory$5<Request, Response>;
|
|
124
|
+
type BuildAmbassadorFunction$5<T extends AmbassadorFunctionDescriptor$5> = T extends AmbassadorFunctionDescriptor$5<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
37
125
|
|
|
38
126
|
declare global {
|
|
39
127
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -42,6 +130,284 @@ declare global {
|
|
|
42
130
|
}
|
|
43
131
|
}
|
|
44
132
|
|
|
133
|
+
declare const emptyObjectSymbol$5: unique symbol;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
137
|
+
|
|
138
|
+
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
|
|
139
|
+
|
|
140
|
+
@example
|
|
141
|
+
```
|
|
142
|
+
import type {EmptyObject} from 'type-fest';
|
|
143
|
+
|
|
144
|
+
// The following illustrates the problem with `{}`.
|
|
145
|
+
const foo1: {} = {}; // Pass
|
|
146
|
+
const foo2: {} = []; // Pass
|
|
147
|
+
const foo3: {} = 42; // Pass
|
|
148
|
+
const foo4: {} = {a: 1}; // Pass
|
|
149
|
+
|
|
150
|
+
// With `EmptyObject` only the first case is valid.
|
|
151
|
+
const bar1: EmptyObject = {}; // Pass
|
|
152
|
+
const bar2: EmptyObject = 42; // Fail
|
|
153
|
+
const bar3: EmptyObject = []; // Fail
|
|
154
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
|
|
158
|
+
|
|
159
|
+
@category Object
|
|
160
|
+
*/
|
|
161
|
+
type EmptyObject$5 = {[emptyObjectSymbol$5]?: never};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
Returns a boolean for whether the two given types are equal.
|
|
165
|
+
|
|
166
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
167
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
168
|
+
|
|
169
|
+
Use-cases:
|
|
170
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
171
|
+
|
|
172
|
+
@example
|
|
173
|
+
```
|
|
174
|
+
import type {IsEqual} from 'type-fest';
|
|
175
|
+
|
|
176
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
177
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
178
|
+
type Includes<Value extends readonly any[], Item> =
|
|
179
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
180
|
+
? IsEqual<Value[0], Item> extends true
|
|
181
|
+
? true
|
|
182
|
+
: Includes<rest, Item>
|
|
183
|
+
: false;
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
@category Type Guard
|
|
187
|
+
@category Utilities
|
|
188
|
+
*/
|
|
189
|
+
type IsEqual$5<A, B> =
|
|
190
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
191
|
+
(<G>() => G extends B ? 1 : 2)
|
|
192
|
+
? true
|
|
193
|
+
: false;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
Filter out keys from an object.
|
|
197
|
+
|
|
198
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
199
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
200
|
+
Returns `Key` otherwise.
|
|
201
|
+
|
|
202
|
+
@example
|
|
203
|
+
```
|
|
204
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
205
|
+
//=> never
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
@example
|
|
209
|
+
```
|
|
210
|
+
type Filtered = Filter<'bar', string>;
|
|
211
|
+
//=> never
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
@example
|
|
215
|
+
```
|
|
216
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
217
|
+
//=> 'bar'
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
@see {Except}
|
|
221
|
+
*/
|
|
222
|
+
type Filter$5<KeyType, ExcludeType> = IsEqual$5<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
223
|
+
|
|
224
|
+
type ExceptOptions$5 = {
|
|
225
|
+
/**
|
|
226
|
+
Disallow assigning non-specified properties.
|
|
227
|
+
|
|
228
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
229
|
+
|
|
230
|
+
@default false
|
|
231
|
+
*/
|
|
232
|
+
requireExactProps?: boolean;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
Create a type from an object type without certain keys.
|
|
237
|
+
|
|
238
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
239
|
+
|
|
240
|
+
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
241
|
+
|
|
242
|
+
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
243
|
+
|
|
244
|
+
@example
|
|
245
|
+
```
|
|
246
|
+
import type {Except} from 'type-fest';
|
|
247
|
+
|
|
248
|
+
type Foo = {
|
|
249
|
+
a: number;
|
|
250
|
+
b: string;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
254
|
+
//=> {b: string}
|
|
255
|
+
|
|
256
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
257
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
258
|
+
|
|
259
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
260
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
261
|
+
|
|
262
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
263
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
@category Object
|
|
267
|
+
*/
|
|
268
|
+
type Except$5<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$5 = {requireExactProps: false}> = {
|
|
269
|
+
[KeyType in keyof ObjectType as Filter$5<KeyType, KeysType>]: ObjectType[KeyType];
|
|
270
|
+
} & (Options['requireExactProps'] extends true
|
|
271
|
+
? Partial<Record<KeysType, never>>
|
|
272
|
+
: {});
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
276
|
+
|
|
277
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
278
|
+
|
|
279
|
+
@example
|
|
280
|
+
```
|
|
281
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
282
|
+
|
|
283
|
+
interface Example {
|
|
284
|
+
a: string;
|
|
285
|
+
b: string | number;
|
|
286
|
+
c?: string;
|
|
287
|
+
d: {};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
291
|
+
//=> 'a'
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
295
|
+
|
|
296
|
+
@example
|
|
297
|
+
```
|
|
298
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
299
|
+
|
|
300
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
301
|
+
//=> 'a' | 'c'
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
@category Object
|
|
305
|
+
*/
|
|
306
|
+
type ConditionalKeys$5<Base, Condition> = NonNullable<
|
|
307
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
308
|
+
{
|
|
309
|
+
// Map through all the keys of the given base type.
|
|
310
|
+
[Key in keyof Base]:
|
|
311
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
312
|
+
Base[Key] extends Condition
|
|
313
|
+
// Retain this key since the condition passes.
|
|
314
|
+
? Key
|
|
315
|
+
// Discard this key since the condition fails.
|
|
316
|
+
: never;
|
|
317
|
+
|
|
318
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
319
|
+
}[keyof Base]
|
|
320
|
+
>;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
324
|
+
|
|
325
|
+
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
|
|
326
|
+
|
|
327
|
+
@example
|
|
328
|
+
```
|
|
329
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
330
|
+
|
|
331
|
+
class Awesome {
|
|
332
|
+
name: string;
|
|
333
|
+
successes: number;
|
|
334
|
+
failures: bigint;
|
|
335
|
+
|
|
336
|
+
run() {}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
340
|
+
//=> {run: () => void}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
@example
|
|
344
|
+
```
|
|
345
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
346
|
+
|
|
347
|
+
interface Example {
|
|
348
|
+
a: string;
|
|
349
|
+
b: string | number;
|
|
350
|
+
c: () => void;
|
|
351
|
+
d: {};
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
355
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
@category Object
|
|
359
|
+
*/
|
|
360
|
+
type ConditionalExcept$5<Base, Condition> = Except$5<
|
|
361
|
+
Base,
|
|
362
|
+
ConditionalKeys$5<Base, Condition>
|
|
363
|
+
>;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
367
|
+
* can either be a REST module or a host module.
|
|
368
|
+
* This type is recursive, so it can describe nested modules.
|
|
369
|
+
*/
|
|
370
|
+
type Descriptors$5 = RESTFunctionDescriptor$5 | AmbassadorFunctionDescriptor$5 | HostModule$5<any, any> | EventDefinition$8<any> | ServicePluginDefinition$5<any> | {
|
|
371
|
+
[key: string]: Descriptors$5 | PublicMetadata$5 | any;
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
375
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
376
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
377
|
+
* do not match the given host (as they will not work with the given host).
|
|
378
|
+
*/
|
|
379
|
+
type BuildDescriptors$5<T extends Descriptors$5, H extends Host$5<any> | undefined, Depth extends number = 5> = {
|
|
380
|
+
done: T;
|
|
381
|
+
recurse: T extends {
|
|
382
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$5;
|
|
383
|
+
} ? never : T extends AmbassadorFunctionDescriptor$5 ? BuildAmbassadorFunction$5<T> : T extends RESTFunctionDescriptor$5 ? BuildRESTFunction$5<T> : T extends EventDefinition$8<any> ? BuildEventDefinition$8<T> : T extends ServicePluginDefinition$5<any> ? BuildServicePluginDefinition$5<T> : T extends HostModule$5<any, any> ? HostModuleAPI$5<T> : ConditionalExcept$5<{
|
|
384
|
+
[Key in keyof T]: T[Key] extends Descriptors$5 ? BuildDescriptors$5<T[Key], H, [
|
|
385
|
+
-1,
|
|
386
|
+
0,
|
|
387
|
+
1,
|
|
388
|
+
2,
|
|
389
|
+
3,
|
|
390
|
+
4,
|
|
391
|
+
5
|
|
392
|
+
][Depth]> : never;
|
|
393
|
+
}, EmptyObject$5>;
|
|
394
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
395
|
+
type PublicMetadata$5 = {
|
|
396
|
+
PACKAGE_NAME?: string;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
declare global {
|
|
400
|
+
interface ContextualClient {
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* A type used to create concerete types from SDK descriptors in
|
|
405
|
+
* case a contextual client is available.
|
|
406
|
+
*/
|
|
407
|
+
type MaybeContext$5<T extends Descriptors$5> = globalThis.ContextualClient extends {
|
|
408
|
+
host: Host$5;
|
|
409
|
+
} ? BuildDescriptors$5<T, globalThis.ContextualClient['host']> : T;
|
|
410
|
+
|
|
45
411
|
interface Mapper {
|
|
46
412
|
_id?: string | null;
|
|
47
413
|
/** The FQDN of the entity the mapper refer to of exist */
|
|
@@ -476,7 +842,7 @@ interface SyncEditorDataOptions {
|
|
|
476
842
|
syncFilter?: SyncFilter;
|
|
477
843
|
}
|
|
478
844
|
|
|
479
|
-
declare function syncEditorData$1(httpClient: HttpClient): SyncEditorDataSignature;
|
|
845
|
+
declare function syncEditorData$1(httpClient: HttpClient$5): SyncEditorDataSignature;
|
|
480
846
|
interface SyncEditorDataSignature {
|
|
481
847
|
/**
|
|
482
848
|
* Update localization content with editor data
|
|
@@ -484,7 +850,7 @@ interface SyncEditorDataSignature {
|
|
|
484
850
|
(options?: SyncEditorDataOptions | undefined): Promise<void>;
|
|
485
851
|
}
|
|
486
852
|
|
|
487
|
-
declare const syncEditorData: BuildRESTFunction<typeof syncEditorData$1> & typeof syncEditorData$1
|
|
853
|
+
declare const syncEditorData: MaybeContext$5<BuildRESTFunction$5<typeof syncEditorData$1> & typeof syncEditorData$1>;
|
|
488
854
|
|
|
489
855
|
type context$5_ChangedPages = ChangedPages;
|
|
490
856
|
type context$5_CreateOrUpdateAction = CreateOrUpdateAction;
|
|
@@ -536,6 +902,416 @@ declare namespace context$5 {
|
|
|
536
902
|
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 };
|
|
537
903
|
}
|
|
538
904
|
|
|
905
|
+
type HostModule$4<T, H extends Host$4> = {
|
|
906
|
+
__type: 'host';
|
|
907
|
+
create(host: H): T;
|
|
908
|
+
};
|
|
909
|
+
type HostModuleAPI$4<T extends HostModule$4<any, any>> = T extends HostModule$4<infer U, any> ? U : never;
|
|
910
|
+
type Host$4<Environment = unknown> = {
|
|
911
|
+
channel: {
|
|
912
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
913
|
+
disconnect: () => void;
|
|
914
|
+
} | Promise<{
|
|
915
|
+
disconnect: () => void;
|
|
916
|
+
}>;
|
|
917
|
+
};
|
|
918
|
+
environment?: Environment;
|
|
919
|
+
/**
|
|
920
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
921
|
+
*/
|
|
922
|
+
apiBaseUrl?: string;
|
|
923
|
+
/**
|
|
924
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
925
|
+
* like internationalization, billing, etc.
|
|
926
|
+
*/
|
|
927
|
+
essentials?: {
|
|
928
|
+
/**
|
|
929
|
+
* The language of the currently viewed session
|
|
930
|
+
*/
|
|
931
|
+
language?: string;
|
|
932
|
+
/**
|
|
933
|
+
* The locale of the currently viewed session
|
|
934
|
+
*/
|
|
935
|
+
locale?: string;
|
|
936
|
+
/**
|
|
937
|
+
* Any headers that should be passed through to the API requests
|
|
938
|
+
*/
|
|
939
|
+
passThroughHeaders?: Record<string, string>;
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
type RESTFunctionDescriptor$4<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$4) => T;
|
|
944
|
+
interface HttpClient$4 {
|
|
945
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$4<TResponse, TData>): Promise<HttpResponse$4<TResponse>>;
|
|
946
|
+
fetchWithAuth: typeof fetch;
|
|
947
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
948
|
+
getActiveToken?: () => string | undefined;
|
|
949
|
+
}
|
|
950
|
+
type RequestOptionsFactory$4<TResponse = any, TData = any> = (context: any) => RequestOptions$4<TResponse, TData>;
|
|
951
|
+
type HttpResponse$4<T = any> = {
|
|
952
|
+
data: T;
|
|
953
|
+
status: number;
|
|
954
|
+
statusText: string;
|
|
955
|
+
headers: any;
|
|
956
|
+
request?: any;
|
|
957
|
+
};
|
|
958
|
+
type RequestOptions$4<_TResponse = any, Data = any> = {
|
|
959
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
960
|
+
url: string;
|
|
961
|
+
data?: Data;
|
|
962
|
+
params?: URLSearchParams;
|
|
963
|
+
} & APIMetadata$4;
|
|
964
|
+
type APIMetadata$4 = {
|
|
965
|
+
methodFqn?: string;
|
|
966
|
+
entityFqdn?: string;
|
|
967
|
+
packageName?: string;
|
|
968
|
+
};
|
|
969
|
+
type BuildRESTFunction$4<T extends RESTFunctionDescriptor$4> = T extends RESTFunctionDescriptor$4<infer U> ? U : never;
|
|
970
|
+
type EventDefinition$7<Payload = unknown, Type extends string = string> = {
|
|
971
|
+
__type: 'event-definition';
|
|
972
|
+
type: Type;
|
|
973
|
+
isDomainEvent?: boolean;
|
|
974
|
+
transformations?: (envelope: unknown) => Payload;
|
|
975
|
+
__payload: Payload;
|
|
976
|
+
};
|
|
977
|
+
declare function EventDefinition$7<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$7<Payload, Type>;
|
|
978
|
+
type EventHandler$7<T extends EventDefinition$7> = (payload: T['__payload']) => void | Promise<void>;
|
|
979
|
+
type BuildEventDefinition$7<T extends EventDefinition$7<any, string>> = (handler: EventHandler$7<T>) => void;
|
|
980
|
+
|
|
981
|
+
type ServicePluginMethodInput$4 = {
|
|
982
|
+
request: any;
|
|
983
|
+
metadata: any;
|
|
984
|
+
};
|
|
985
|
+
type ServicePluginContract$4 = Record<string, (payload: ServicePluginMethodInput$4) => unknown | Promise<unknown>>;
|
|
986
|
+
type ServicePluginMethodMetadata$4 = {
|
|
987
|
+
name: string;
|
|
988
|
+
primaryHttpMappingPath: string;
|
|
989
|
+
transformations: {
|
|
990
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$4;
|
|
991
|
+
toREST: (...args: unknown[]) => unknown;
|
|
992
|
+
};
|
|
993
|
+
};
|
|
994
|
+
type ServicePluginDefinition$4<Contract extends ServicePluginContract$4> = {
|
|
995
|
+
__type: 'service-plugin-definition';
|
|
996
|
+
componentType: string;
|
|
997
|
+
methods: ServicePluginMethodMetadata$4[];
|
|
998
|
+
__contract: Contract;
|
|
999
|
+
};
|
|
1000
|
+
declare function ServicePluginDefinition$4<Contract extends ServicePluginContract$4>(componentType: string, methods: ServicePluginMethodMetadata$4[]): ServicePluginDefinition$4<Contract>;
|
|
1001
|
+
type BuildServicePluginDefinition$4<T extends ServicePluginDefinition$4<any>> = (implementation: T['__contract']) => void;
|
|
1002
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$4 = "wix_spi_error";
|
|
1003
|
+
|
|
1004
|
+
type RequestContext$4 = {
|
|
1005
|
+
isSSR: boolean;
|
|
1006
|
+
host: string;
|
|
1007
|
+
protocol?: string;
|
|
1008
|
+
};
|
|
1009
|
+
type ResponseTransformer$4 = (data: any, headers?: any) => any;
|
|
1010
|
+
/**
|
|
1011
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
1012
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
1013
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
1014
|
+
*/
|
|
1015
|
+
type Method$4 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
1016
|
+
type AmbassadorRequestOptions$4<T = any> = {
|
|
1017
|
+
_?: T;
|
|
1018
|
+
url?: string;
|
|
1019
|
+
method?: Method$4;
|
|
1020
|
+
params?: any;
|
|
1021
|
+
data?: any;
|
|
1022
|
+
transformResponse?: ResponseTransformer$4 | ResponseTransformer$4[];
|
|
1023
|
+
};
|
|
1024
|
+
type AmbassadorFactory$4<Request, Response> = (payload: Request) => ((context: RequestContext$4) => AmbassadorRequestOptions$4<Response>) & {
|
|
1025
|
+
__isAmbassador: boolean;
|
|
1026
|
+
};
|
|
1027
|
+
type AmbassadorFunctionDescriptor$4<Request = any, Response = any> = AmbassadorFactory$4<Request, Response>;
|
|
1028
|
+
type BuildAmbassadorFunction$4<T extends AmbassadorFunctionDescriptor$4> = T extends AmbassadorFunctionDescriptor$4<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
1029
|
+
|
|
1030
|
+
declare global {
|
|
1031
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
1032
|
+
interface SymbolConstructor {
|
|
1033
|
+
readonly observable: symbol;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
declare const emptyObjectSymbol$4: unique symbol;
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
1041
|
+
|
|
1042
|
+
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)).
|
|
1043
|
+
|
|
1044
|
+
@example
|
|
1045
|
+
```
|
|
1046
|
+
import type {EmptyObject} from 'type-fest';
|
|
1047
|
+
|
|
1048
|
+
// The following illustrates the problem with `{}`.
|
|
1049
|
+
const foo1: {} = {}; // Pass
|
|
1050
|
+
const foo2: {} = []; // Pass
|
|
1051
|
+
const foo3: {} = 42; // Pass
|
|
1052
|
+
const foo4: {} = {a: 1}; // Pass
|
|
1053
|
+
|
|
1054
|
+
// With `EmptyObject` only the first case is valid.
|
|
1055
|
+
const bar1: EmptyObject = {}; // Pass
|
|
1056
|
+
const bar2: EmptyObject = 42; // Fail
|
|
1057
|
+
const bar3: EmptyObject = []; // Fail
|
|
1058
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
1059
|
+
```
|
|
1060
|
+
|
|
1061
|
+
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}.
|
|
1062
|
+
|
|
1063
|
+
@category Object
|
|
1064
|
+
*/
|
|
1065
|
+
type EmptyObject$4 = {[emptyObjectSymbol$4]?: never};
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
Returns a boolean for whether the two given types are equal.
|
|
1069
|
+
|
|
1070
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
1071
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
1072
|
+
|
|
1073
|
+
Use-cases:
|
|
1074
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
1075
|
+
|
|
1076
|
+
@example
|
|
1077
|
+
```
|
|
1078
|
+
import type {IsEqual} from 'type-fest';
|
|
1079
|
+
|
|
1080
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
1081
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
1082
|
+
type Includes<Value extends readonly any[], Item> =
|
|
1083
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
1084
|
+
? IsEqual<Value[0], Item> extends true
|
|
1085
|
+
? true
|
|
1086
|
+
: Includes<rest, Item>
|
|
1087
|
+
: false;
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
@category Type Guard
|
|
1091
|
+
@category Utilities
|
|
1092
|
+
*/
|
|
1093
|
+
type IsEqual$4<A, B> =
|
|
1094
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
1095
|
+
(<G>() => G extends B ? 1 : 2)
|
|
1096
|
+
? true
|
|
1097
|
+
: false;
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
Filter out keys from an object.
|
|
1101
|
+
|
|
1102
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
1103
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
1104
|
+
Returns `Key` otherwise.
|
|
1105
|
+
|
|
1106
|
+
@example
|
|
1107
|
+
```
|
|
1108
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
1109
|
+
//=> never
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
@example
|
|
1113
|
+
```
|
|
1114
|
+
type Filtered = Filter<'bar', string>;
|
|
1115
|
+
//=> never
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
@example
|
|
1119
|
+
```
|
|
1120
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
1121
|
+
//=> 'bar'
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
@see {Except}
|
|
1125
|
+
*/
|
|
1126
|
+
type Filter$4<KeyType, ExcludeType> = IsEqual$4<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
1127
|
+
|
|
1128
|
+
type ExceptOptions$4 = {
|
|
1129
|
+
/**
|
|
1130
|
+
Disallow assigning non-specified properties.
|
|
1131
|
+
|
|
1132
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
1133
|
+
|
|
1134
|
+
@default false
|
|
1135
|
+
*/
|
|
1136
|
+
requireExactProps?: boolean;
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
Create a type from an object type without certain keys.
|
|
1141
|
+
|
|
1142
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
1143
|
+
|
|
1144
|
+
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.
|
|
1145
|
+
|
|
1146
|
+
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)).
|
|
1147
|
+
|
|
1148
|
+
@example
|
|
1149
|
+
```
|
|
1150
|
+
import type {Except} from 'type-fest';
|
|
1151
|
+
|
|
1152
|
+
type Foo = {
|
|
1153
|
+
a: number;
|
|
1154
|
+
b: string;
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1157
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
1158
|
+
//=> {b: string}
|
|
1159
|
+
|
|
1160
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
1161
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
1162
|
+
|
|
1163
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
1164
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
1165
|
+
|
|
1166
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
1167
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
1168
|
+
```
|
|
1169
|
+
|
|
1170
|
+
@category Object
|
|
1171
|
+
*/
|
|
1172
|
+
type Except$4<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$4 = {requireExactProps: false}> = {
|
|
1173
|
+
[KeyType in keyof ObjectType as Filter$4<KeyType, KeysType>]: ObjectType[KeyType];
|
|
1174
|
+
} & (Options['requireExactProps'] extends true
|
|
1175
|
+
? Partial<Record<KeysType, never>>
|
|
1176
|
+
: {});
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
1180
|
+
|
|
1181
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
1182
|
+
|
|
1183
|
+
@example
|
|
1184
|
+
```
|
|
1185
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1186
|
+
|
|
1187
|
+
interface Example {
|
|
1188
|
+
a: string;
|
|
1189
|
+
b: string | number;
|
|
1190
|
+
c?: string;
|
|
1191
|
+
d: {};
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
1195
|
+
//=> 'a'
|
|
1196
|
+
```
|
|
1197
|
+
|
|
1198
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
1199
|
+
|
|
1200
|
+
@example
|
|
1201
|
+
```
|
|
1202
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1203
|
+
|
|
1204
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
1205
|
+
//=> 'a' | 'c'
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
@category Object
|
|
1209
|
+
*/
|
|
1210
|
+
type ConditionalKeys$4<Base, Condition> = NonNullable<
|
|
1211
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
1212
|
+
{
|
|
1213
|
+
// Map through all the keys of the given base type.
|
|
1214
|
+
[Key in keyof Base]:
|
|
1215
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
1216
|
+
Base[Key] extends Condition
|
|
1217
|
+
// Retain this key since the condition passes.
|
|
1218
|
+
? Key
|
|
1219
|
+
// Discard this key since the condition fails.
|
|
1220
|
+
: never;
|
|
1221
|
+
|
|
1222
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
1223
|
+
}[keyof Base]
|
|
1224
|
+
>;
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
1228
|
+
|
|
1229
|
+
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.
|
|
1230
|
+
|
|
1231
|
+
@example
|
|
1232
|
+
```
|
|
1233
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
1234
|
+
|
|
1235
|
+
class Awesome {
|
|
1236
|
+
name: string;
|
|
1237
|
+
successes: number;
|
|
1238
|
+
failures: bigint;
|
|
1239
|
+
|
|
1240
|
+
run() {}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
1244
|
+
//=> {run: () => void}
|
|
1245
|
+
```
|
|
1246
|
+
|
|
1247
|
+
@example
|
|
1248
|
+
```
|
|
1249
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
1250
|
+
|
|
1251
|
+
interface Example {
|
|
1252
|
+
a: string;
|
|
1253
|
+
b: string | number;
|
|
1254
|
+
c: () => void;
|
|
1255
|
+
d: {};
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
1259
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
1260
|
+
```
|
|
1261
|
+
|
|
1262
|
+
@category Object
|
|
1263
|
+
*/
|
|
1264
|
+
type ConditionalExcept$4<Base, Condition> = Except$4<
|
|
1265
|
+
Base,
|
|
1266
|
+
ConditionalKeys$4<Base, Condition>
|
|
1267
|
+
>;
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
1271
|
+
* can either be a REST module or a host module.
|
|
1272
|
+
* This type is recursive, so it can describe nested modules.
|
|
1273
|
+
*/
|
|
1274
|
+
type Descriptors$4 = RESTFunctionDescriptor$4 | AmbassadorFunctionDescriptor$4 | HostModule$4<any, any> | EventDefinition$7<any> | ServicePluginDefinition$4<any> | {
|
|
1275
|
+
[key: string]: Descriptors$4 | PublicMetadata$4 | any;
|
|
1276
|
+
};
|
|
1277
|
+
/**
|
|
1278
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
1279
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
1280
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
1281
|
+
* do not match the given host (as they will not work with the given host).
|
|
1282
|
+
*/
|
|
1283
|
+
type BuildDescriptors$4<T extends Descriptors$4, H extends Host$4<any> | undefined, Depth extends number = 5> = {
|
|
1284
|
+
done: T;
|
|
1285
|
+
recurse: T extends {
|
|
1286
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$4;
|
|
1287
|
+
} ? never : T extends AmbassadorFunctionDescriptor$4 ? BuildAmbassadorFunction$4<T> : T extends RESTFunctionDescriptor$4 ? BuildRESTFunction$4<T> : T extends EventDefinition$7<any> ? BuildEventDefinition$7<T> : T extends ServicePluginDefinition$4<any> ? BuildServicePluginDefinition$4<T> : T extends HostModule$4<any, any> ? HostModuleAPI$4<T> : ConditionalExcept$4<{
|
|
1288
|
+
[Key in keyof T]: T[Key] extends Descriptors$4 ? BuildDescriptors$4<T[Key], H, [
|
|
1289
|
+
-1,
|
|
1290
|
+
0,
|
|
1291
|
+
1,
|
|
1292
|
+
2,
|
|
1293
|
+
3,
|
|
1294
|
+
4,
|
|
1295
|
+
5
|
|
1296
|
+
][Depth]> : never;
|
|
1297
|
+
}, EmptyObject$4>;
|
|
1298
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
1299
|
+
type PublicMetadata$4 = {
|
|
1300
|
+
PACKAGE_NAME?: string;
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
declare global {
|
|
1304
|
+
interface ContextualClient {
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* A type used to create concerete types from SDK descriptors in
|
|
1309
|
+
* case a contextual client is available.
|
|
1310
|
+
*/
|
|
1311
|
+
type MaybeContext$4<T extends Descriptors$4> = globalThis.ContextualClient extends {
|
|
1312
|
+
host: Host$4;
|
|
1313
|
+
} ? BuildDescriptors$4<T, globalThis.ContextualClient['host']> : T;
|
|
1314
|
+
|
|
539
1315
|
/** Represents a content of an entity with its published translations */
|
|
540
1316
|
interface PublishedContent {
|
|
541
1317
|
/**
|
|
@@ -2448,7 +3224,7 @@ interface PublishedContentQueryBuilder {
|
|
|
2448
3224
|
find: () => Promise<PublishedContentQueryResult>;
|
|
2449
3225
|
}
|
|
2450
3226
|
|
|
2451
|
-
declare function queryPublishedContent$1(httpClient: HttpClient): QueryPublishedContentSignature;
|
|
3227
|
+
declare function queryPublishedContent$1(httpClient: HttpClient$4): QueryPublishedContentSignature;
|
|
2452
3228
|
interface QueryPublishedContentSignature {
|
|
2453
3229
|
/**
|
|
2454
3230
|
* Retrieves a list of published translation content given the provided paging, filtering, and sorting. Up to 100 published content items can be returned per request.
|
|
@@ -2467,13 +3243,31 @@ interface QueryPublishedContentSignature {
|
|
|
2467
3243
|
*/
|
|
2468
3244
|
(): PublishedContentQueryBuilder;
|
|
2469
3245
|
}
|
|
2470
|
-
declare const onPublishedContentCreated$1: EventDefinition<PublishedContentCreatedEnvelope, "wix.multilingual.localization_public.v3.published_content_created">;
|
|
2471
|
-
declare const onPublishedContentUpdated$1: EventDefinition<PublishedContentUpdatedEnvelope, "wix.multilingual.localization_public.v3.published_content_updated">;
|
|
2472
|
-
declare const onPublishedContentDeleted$1: EventDefinition<PublishedContentDeletedEnvelope, "wix.multilingual.localization_public.v3.published_content_deleted">;
|
|
3246
|
+
declare const onPublishedContentCreated$1: EventDefinition$7<PublishedContentCreatedEnvelope, "wix.multilingual.localization_public.v3.published_content_created">;
|
|
3247
|
+
declare const onPublishedContentUpdated$1: EventDefinition$7<PublishedContentUpdatedEnvelope, "wix.multilingual.localization_public.v3.published_content_updated">;
|
|
3248
|
+
declare const onPublishedContentDeleted$1: EventDefinition$7<PublishedContentDeletedEnvelope, "wix.multilingual.localization_public.v3.published_content_deleted">;
|
|
3249
|
+
|
|
3250
|
+
type EventDefinition$6<Payload = unknown, Type extends string = string> = {
|
|
3251
|
+
__type: 'event-definition';
|
|
3252
|
+
type: Type;
|
|
3253
|
+
isDomainEvent?: boolean;
|
|
3254
|
+
transformations?: (envelope: unknown) => Payload;
|
|
3255
|
+
__payload: Payload;
|
|
3256
|
+
};
|
|
3257
|
+
declare function EventDefinition$6<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$6<Payload, Type>;
|
|
3258
|
+
type EventHandler$6<T extends EventDefinition$6> = (payload: T['__payload']) => void | Promise<void>;
|
|
3259
|
+
type BuildEventDefinition$6<T extends EventDefinition$6<any, string>> = (handler: EventHandler$6<T>) => void;
|
|
3260
|
+
|
|
3261
|
+
declare global {
|
|
3262
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
3263
|
+
interface SymbolConstructor {
|
|
3264
|
+
readonly observable: symbol;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
2473
3267
|
|
|
2474
|
-
declare function createEventModule$2<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
|
|
3268
|
+
declare function createEventModule$2<T extends EventDefinition$6<any, string>>(eventDefinition: T): BuildEventDefinition$6<T> & T;
|
|
2475
3269
|
|
|
2476
|
-
declare const queryPublishedContent: BuildRESTFunction<typeof queryPublishedContent$1> & typeof queryPublishedContent$1
|
|
3270
|
+
declare const queryPublishedContent: MaybeContext$4<BuildRESTFunction$4<typeof queryPublishedContent$1> & typeof queryPublishedContent$1>;
|
|
2477
3271
|
|
|
2478
3272
|
type _publicOnPublishedContentCreatedType = typeof onPublishedContentCreated$1;
|
|
2479
3273
|
/**
|
|
@@ -2518,20 +3312,430 @@ declare namespace context$4 {
|
|
|
2518
3312
|
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 };
|
|
2519
3313
|
}
|
|
2520
3314
|
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
3315
|
+
type HostModule$3<T, H extends Host$3> = {
|
|
3316
|
+
__type: 'host';
|
|
3317
|
+
create(host: H): T;
|
|
3318
|
+
};
|
|
3319
|
+
type HostModuleAPI$3<T extends HostModule$3<any, any>> = T extends HostModule$3<infer U, any> ? U : never;
|
|
3320
|
+
type Host$3<Environment = unknown> = {
|
|
3321
|
+
channel: {
|
|
3322
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
3323
|
+
disconnect: () => void;
|
|
3324
|
+
} | Promise<{
|
|
3325
|
+
disconnect: () => void;
|
|
3326
|
+
}>;
|
|
3327
|
+
};
|
|
3328
|
+
environment?: Environment;
|
|
3329
|
+
/**
|
|
3330
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
3331
|
+
*/
|
|
3332
|
+
apiBaseUrl?: string;
|
|
3333
|
+
/**
|
|
3334
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
3335
|
+
* like internationalization, billing, etc.
|
|
3336
|
+
*/
|
|
3337
|
+
essentials?: {
|
|
3338
|
+
/**
|
|
3339
|
+
* The language of the currently viewed session
|
|
3340
|
+
*/
|
|
3341
|
+
language?: string;
|
|
3342
|
+
/**
|
|
3343
|
+
* The locale of the currently viewed session
|
|
3344
|
+
*/
|
|
3345
|
+
locale?: string;
|
|
3346
|
+
/**
|
|
3347
|
+
* Any headers that should be passed through to the API requests
|
|
3348
|
+
*/
|
|
3349
|
+
passThroughHeaders?: Record<string, string>;
|
|
3350
|
+
};
|
|
3351
|
+
};
|
|
3352
|
+
|
|
3353
|
+
type RESTFunctionDescriptor$3<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$3) => T;
|
|
3354
|
+
interface HttpClient$3 {
|
|
3355
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$3<TResponse, TData>): Promise<HttpResponse$3<TResponse>>;
|
|
3356
|
+
fetchWithAuth: typeof fetch;
|
|
3357
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
3358
|
+
getActiveToken?: () => string | undefined;
|
|
3359
|
+
}
|
|
3360
|
+
type RequestOptionsFactory$3<TResponse = any, TData = any> = (context: any) => RequestOptions$3<TResponse, TData>;
|
|
3361
|
+
type HttpResponse$3<T = any> = {
|
|
3362
|
+
data: T;
|
|
3363
|
+
status: number;
|
|
3364
|
+
statusText: string;
|
|
3365
|
+
headers: any;
|
|
3366
|
+
request?: any;
|
|
3367
|
+
};
|
|
3368
|
+
type RequestOptions$3<_TResponse = any, Data = any> = {
|
|
3369
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
3370
|
+
url: string;
|
|
3371
|
+
data?: Data;
|
|
3372
|
+
params?: URLSearchParams;
|
|
3373
|
+
} & APIMetadata$3;
|
|
3374
|
+
type APIMetadata$3 = {
|
|
3375
|
+
methodFqn?: string;
|
|
3376
|
+
entityFqdn?: string;
|
|
3377
|
+
packageName?: string;
|
|
3378
|
+
};
|
|
3379
|
+
type BuildRESTFunction$3<T extends RESTFunctionDescriptor$3> = T extends RESTFunctionDescriptor$3<infer U> ? U : never;
|
|
3380
|
+
type EventDefinition$5<Payload = unknown, Type extends string = string> = {
|
|
3381
|
+
__type: 'event-definition';
|
|
3382
|
+
type: Type;
|
|
3383
|
+
isDomainEvent?: boolean;
|
|
3384
|
+
transformations?: (envelope: unknown) => Payload;
|
|
3385
|
+
__payload: Payload;
|
|
3386
|
+
};
|
|
3387
|
+
declare function EventDefinition$5<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$5<Payload, Type>;
|
|
3388
|
+
type EventHandler$5<T extends EventDefinition$5> = (payload: T['__payload']) => void | Promise<void>;
|
|
3389
|
+
type BuildEventDefinition$5<T extends EventDefinition$5<any, string>> = (handler: EventHandler$5<T>) => void;
|
|
3390
|
+
|
|
3391
|
+
type ServicePluginMethodInput$3 = {
|
|
3392
|
+
request: any;
|
|
3393
|
+
metadata: any;
|
|
3394
|
+
};
|
|
3395
|
+
type ServicePluginContract$3 = Record<string, (payload: ServicePluginMethodInput$3) => unknown | Promise<unknown>>;
|
|
3396
|
+
type ServicePluginMethodMetadata$3 = {
|
|
3397
|
+
name: string;
|
|
3398
|
+
primaryHttpMappingPath: string;
|
|
3399
|
+
transformations: {
|
|
3400
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$3;
|
|
3401
|
+
toREST: (...args: unknown[]) => unknown;
|
|
3402
|
+
};
|
|
3403
|
+
};
|
|
3404
|
+
type ServicePluginDefinition$3<Contract extends ServicePluginContract$3> = {
|
|
3405
|
+
__type: 'service-plugin-definition';
|
|
3406
|
+
componentType: string;
|
|
3407
|
+
methods: ServicePluginMethodMetadata$3[];
|
|
3408
|
+
__contract: Contract;
|
|
3409
|
+
};
|
|
3410
|
+
declare function ServicePluginDefinition$3<Contract extends ServicePluginContract$3>(componentType: string, methods: ServicePluginMethodMetadata$3[]): ServicePluginDefinition$3<Contract>;
|
|
3411
|
+
type BuildServicePluginDefinition$3<T extends ServicePluginDefinition$3<any>> = (implementation: T['__contract']) => void;
|
|
3412
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$3 = "wix_spi_error";
|
|
3413
|
+
|
|
3414
|
+
type RequestContext$3 = {
|
|
3415
|
+
isSSR: boolean;
|
|
3416
|
+
host: string;
|
|
3417
|
+
protocol?: string;
|
|
3418
|
+
};
|
|
3419
|
+
type ResponseTransformer$3 = (data: any, headers?: any) => any;
|
|
3420
|
+
/**
|
|
3421
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
3422
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
3423
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
3424
|
+
*/
|
|
3425
|
+
type Method$3 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
3426
|
+
type AmbassadorRequestOptions$3<T = any> = {
|
|
3427
|
+
_?: T;
|
|
3428
|
+
url?: string;
|
|
3429
|
+
method?: Method$3;
|
|
3430
|
+
params?: any;
|
|
3431
|
+
data?: any;
|
|
3432
|
+
transformResponse?: ResponseTransformer$3 | ResponseTransformer$3[];
|
|
3433
|
+
};
|
|
3434
|
+
type AmbassadorFactory$3<Request, Response> = (payload: Request) => ((context: RequestContext$3) => AmbassadorRequestOptions$3<Response>) & {
|
|
3435
|
+
__isAmbassador: boolean;
|
|
3436
|
+
};
|
|
3437
|
+
type AmbassadorFunctionDescriptor$3<Request = any, Response = any> = AmbassadorFactory$3<Request, Response>;
|
|
3438
|
+
type BuildAmbassadorFunction$3<T extends AmbassadorFunctionDescriptor$3> = T extends AmbassadorFunctionDescriptor$3<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
3439
|
+
|
|
3440
|
+
declare global {
|
|
3441
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
3442
|
+
interface SymbolConstructor {
|
|
3443
|
+
readonly observable: symbol;
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
declare const emptyObjectSymbol$3: unique symbol;
|
|
3448
|
+
|
|
3449
|
+
/**
|
|
3450
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
3451
|
+
|
|
3452
|
+
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)).
|
|
3453
|
+
|
|
3454
|
+
@example
|
|
3455
|
+
```
|
|
3456
|
+
import type {EmptyObject} from 'type-fest';
|
|
3457
|
+
|
|
3458
|
+
// The following illustrates the problem with `{}`.
|
|
3459
|
+
const foo1: {} = {}; // Pass
|
|
3460
|
+
const foo2: {} = []; // Pass
|
|
3461
|
+
const foo3: {} = 42; // Pass
|
|
3462
|
+
const foo4: {} = {a: 1}; // Pass
|
|
3463
|
+
|
|
3464
|
+
// With `EmptyObject` only the first case is valid.
|
|
3465
|
+
const bar1: EmptyObject = {}; // Pass
|
|
3466
|
+
const bar2: EmptyObject = 42; // Fail
|
|
3467
|
+
const bar3: EmptyObject = []; // Fail
|
|
3468
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
3469
|
+
```
|
|
3470
|
+
|
|
3471
|
+
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}.
|
|
3472
|
+
|
|
3473
|
+
@category Object
|
|
3474
|
+
*/
|
|
3475
|
+
type EmptyObject$3 = {[emptyObjectSymbol$3]?: never};
|
|
3476
|
+
|
|
3477
|
+
/**
|
|
3478
|
+
Returns a boolean for whether the two given types are equal.
|
|
3479
|
+
|
|
3480
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
3481
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
3482
|
+
|
|
3483
|
+
Use-cases:
|
|
3484
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
3485
|
+
|
|
3486
|
+
@example
|
|
3487
|
+
```
|
|
3488
|
+
import type {IsEqual} from 'type-fest';
|
|
3489
|
+
|
|
3490
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
3491
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
3492
|
+
type Includes<Value extends readonly any[], Item> =
|
|
3493
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
3494
|
+
? IsEqual<Value[0], Item> extends true
|
|
3495
|
+
? true
|
|
3496
|
+
: Includes<rest, Item>
|
|
3497
|
+
: false;
|
|
3498
|
+
```
|
|
3499
|
+
|
|
3500
|
+
@category Type Guard
|
|
3501
|
+
@category Utilities
|
|
3502
|
+
*/
|
|
3503
|
+
type IsEqual$3<A, B> =
|
|
3504
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
3505
|
+
(<G>() => G extends B ? 1 : 2)
|
|
3506
|
+
? true
|
|
3507
|
+
: false;
|
|
3508
|
+
|
|
3509
|
+
/**
|
|
3510
|
+
Filter out keys from an object.
|
|
3511
|
+
|
|
3512
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
3513
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
3514
|
+
Returns `Key` otherwise.
|
|
3515
|
+
|
|
3516
|
+
@example
|
|
3517
|
+
```
|
|
3518
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
3519
|
+
//=> never
|
|
3520
|
+
```
|
|
3521
|
+
|
|
3522
|
+
@example
|
|
3523
|
+
```
|
|
3524
|
+
type Filtered = Filter<'bar', string>;
|
|
3525
|
+
//=> never
|
|
3526
|
+
```
|
|
3527
|
+
|
|
3528
|
+
@example
|
|
3529
|
+
```
|
|
3530
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
3531
|
+
//=> 'bar'
|
|
3532
|
+
```
|
|
3533
|
+
|
|
3534
|
+
@see {Except}
|
|
3535
|
+
*/
|
|
3536
|
+
type Filter$3<KeyType, ExcludeType> = IsEqual$3<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
3537
|
+
|
|
3538
|
+
type ExceptOptions$3 = {
|
|
3539
|
+
/**
|
|
3540
|
+
Disallow assigning non-specified properties.
|
|
3541
|
+
|
|
3542
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
3543
|
+
|
|
3544
|
+
@default false
|
|
3545
|
+
*/
|
|
3546
|
+
requireExactProps?: boolean;
|
|
3547
|
+
};
|
|
3548
|
+
|
|
3549
|
+
/**
|
|
3550
|
+
Create a type from an object type without certain keys.
|
|
3551
|
+
|
|
3552
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
3553
|
+
|
|
3554
|
+
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.
|
|
3555
|
+
|
|
3556
|
+
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)).
|
|
3557
|
+
|
|
3558
|
+
@example
|
|
3559
|
+
```
|
|
3560
|
+
import type {Except} from 'type-fest';
|
|
3561
|
+
|
|
3562
|
+
type Foo = {
|
|
3563
|
+
a: number;
|
|
3564
|
+
b: string;
|
|
3565
|
+
};
|
|
3566
|
+
|
|
3567
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
3568
|
+
//=> {b: string}
|
|
3569
|
+
|
|
3570
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
3571
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
3572
|
+
|
|
3573
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
3574
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
3575
|
+
|
|
3576
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
3577
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
3578
|
+
```
|
|
3579
|
+
|
|
3580
|
+
@category Object
|
|
3581
|
+
*/
|
|
3582
|
+
type Except$3<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$3 = {requireExactProps: false}> = {
|
|
3583
|
+
[KeyType in keyof ObjectType as Filter$3<KeyType, KeysType>]: ObjectType[KeyType];
|
|
3584
|
+
} & (Options['requireExactProps'] extends true
|
|
3585
|
+
? Partial<Record<KeysType, never>>
|
|
3586
|
+
: {});
|
|
3587
|
+
|
|
3588
|
+
/**
|
|
3589
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
3590
|
+
|
|
3591
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
3592
|
+
|
|
3593
|
+
@example
|
|
3594
|
+
```
|
|
3595
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
3596
|
+
|
|
3597
|
+
interface Example {
|
|
3598
|
+
a: string;
|
|
3599
|
+
b: string | number;
|
|
3600
|
+
c?: string;
|
|
3601
|
+
d: {};
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
3605
|
+
//=> 'a'
|
|
3606
|
+
```
|
|
3607
|
+
|
|
3608
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
3609
|
+
|
|
3610
|
+
@example
|
|
3611
|
+
```
|
|
3612
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
3613
|
+
|
|
3614
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
3615
|
+
//=> 'a' | 'c'
|
|
3616
|
+
```
|
|
3617
|
+
|
|
3618
|
+
@category Object
|
|
3619
|
+
*/
|
|
3620
|
+
type ConditionalKeys$3<Base, Condition> = NonNullable<
|
|
3621
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
3622
|
+
{
|
|
3623
|
+
// Map through all the keys of the given base type.
|
|
3624
|
+
[Key in keyof Base]:
|
|
3625
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
3626
|
+
Base[Key] extends Condition
|
|
3627
|
+
// Retain this key since the condition passes.
|
|
3628
|
+
? Key
|
|
3629
|
+
// Discard this key since the condition fails.
|
|
3630
|
+
: never;
|
|
3631
|
+
|
|
3632
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
3633
|
+
}[keyof Base]
|
|
3634
|
+
>;
|
|
3635
|
+
|
|
3636
|
+
/**
|
|
3637
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
3638
|
+
|
|
3639
|
+
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.
|
|
3640
|
+
|
|
3641
|
+
@example
|
|
3642
|
+
```
|
|
3643
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
3644
|
+
|
|
3645
|
+
class Awesome {
|
|
3646
|
+
name: string;
|
|
3647
|
+
successes: number;
|
|
3648
|
+
failures: bigint;
|
|
3649
|
+
|
|
3650
|
+
run() {}
|
|
3651
|
+
}
|
|
3652
|
+
|
|
3653
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
3654
|
+
//=> {run: () => void}
|
|
3655
|
+
```
|
|
3656
|
+
|
|
3657
|
+
@example
|
|
3658
|
+
```
|
|
3659
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
3660
|
+
|
|
3661
|
+
interface Example {
|
|
3662
|
+
a: string;
|
|
3663
|
+
b: string | number;
|
|
3664
|
+
c: () => void;
|
|
3665
|
+
d: {};
|
|
3666
|
+
}
|
|
3667
|
+
|
|
3668
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
3669
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
3670
|
+
```
|
|
3671
|
+
|
|
3672
|
+
@category Object
|
|
3673
|
+
*/
|
|
3674
|
+
type ConditionalExcept$3<Base, Condition> = Except$3<
|
|
3675
|
+
Base,
|
|
3676
|
+
ConditionalKeys$3<Base, Condition>
|
|
3677
|
+
>;
|
|
3678
|
+
|
|
3679
|
+
/**
|
|
3680
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
3681
|
+
* can either be a REST module or a host module.
|
|
3682
|
+
* This type is recursive, so it can describe nested modules.
|
|
3683
|
+
*/
|
|
3684
|
+
type Descriptors$3 = RESTFunctionDescriptor$3 | AmbassadorFunctionDescriptor$3 | HostModule$3<any, any> | EventDefinition$5<any> | ServicePluginDefinition$3<any> | {
|
|
3685
|
+
[key: string]: Descriptors$3 | PublicMetadata$3 | any;
|
|
3686
|
+
};
|
|
3687
|
+
/**
|
|
3688
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
3689
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
3690
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
3691
|
+
* do not match the given host (as they will not work with the given host).
|
|
3692
|
+
*/
|
|
3693
|
+
type BuildDescriptors$3<T extends Descriptors$3, H extends Host$3<any> | undefined, Depth extends number = 5> = {
|
|
3694
|
+
done: T;
|
|
3695
|
+
recurse: T extends {
|
|
3696
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$3;
|
|
3697
|
+
} ? never : T extends AmbassadorFunctionDescriptor$3 ? BuildAmbassadorFunction$3<T> : T extends RESTFunctionDescriptor$3 ? BuildRESTFunction$3<T> : T extends EventDefinition$5<any> ? BuildEventDefinition$5<T> : T extends ServicePluginDefinition$3<any> ? BuildServicePluginDefinition$3<T> : T extends HostModule$3<any, any> ? HostModuleAPI$3<T> : ConditionalExcept$3<{
|
|
3698
|
+
[Key in keyof T]: T[Key] extends Descriptors$3 ? BuildDescriptors$3<T[Key], H, [
|
|
3699
|
+
-1,
|
|
3700
|
+
0,
|
|
3701
|
+
1,
|
|
3702
|
+
2,
|
|
3703
|
+
3,
|
|
3704
|
+
4,
|
|
3705
|
+
5
|
|
3706
|
+
][Depth]> : never;
|
|
3707
|
+
}, EmptyObject$3>;
|
|
3708
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
3709
|
+
type PublicMetadata$3 = {
|
|
3710
|
+
PACKAGE_NAME?: string;
|
|
3711
|
+
};
|
|
3712
|
+
|
|
3713
|
+
declare global {
|
|
3714
|
+
interface ContextualClient {
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
/**
|
|
3718
|
+
* A type used to create concerete types from SDK descriptors in
|
|
3719
|
+
* case a contextual client is available.
|
|
3720
|
+
*/
|
|
3721
|
+
type MaybeContext$3<T extends Descriptors$3> = globalThis.ContextualClient extends {
|
|
3722
|
+
host: Host$3;
|
|
3723
|
+
} ? BuildDescriptors$3<T, globalThis.ContextualClient['host']> : T;
|
|
3724
|
+
|
|
3725
|
+
/**
|
|
3726
|
+
* A translatable content is a unit of content to translate.
|
|
3727
|
+
*
|
|
3728
|
+
* Use [Machine Translate](/machine-translation/machine-translate) to translate a single unit of translatable content, or [Bulk Machine Translate](/machine-translation/bulk-machine-translate)
|
|
3729
|
+
* to translate many.
|
|
3730
|
+
*/
|
|
3731
|
+
interface TranslatableContent extends TranslatableContentContentOneOf {
|
|
3732
|
+
/** Plain text. */
|
|
3733
|
+
plainTextContent?: string;
|
|
3734
|
+
/** HTML-encoded. */
|
|
3735
|
+
htmlContent?: string;
|
|
3736
|
+
/** Rich content. */
|
|
3737
|
+
richContent?: RichContent$1;
|
|
3738
|
+
/** Translatable content ID. The ID should be unique to this content and doesn't need to match the ID used by any other service. */
|
|
2535
3739
|
_id?: string | null;
|
|
2536
3740
|
/** Format of the translatable content. */
|
|
2537
3741
|
format?: Format;
|
|
@@ -4421,7 +5625,7 @@ interface BulkMachineTranslateOptions {
|
|
|
4421
5625
|
contentToTranslate?: TranslatableContent[];
|
|
4422
5626
|
}
|
|
4423
5627
|
|
|
4424
|
-
declare function machineTranslate$1(httpClient: HttpClient): MachineTranslateSignature;
|
|
5628
|
+
declare function machineTranslate$1(httpClient: HttpClient$3): MachineTranslateSignature;
|
|
4425
5629
|
interface MachineTranslateSignature {
|
|
4426
5630
|
/**
|
|
4427
5631
|
* Translates the text of a translatable unit of content from one supported language to another.
|
|
@@ -4448,7 +5652,7 @@ interface MachineTranslateSignature {
|
|
|
4448
5652
|
*/
|
|
4449
5653
|
(sourceLanguage: SupportedLanguage, options: MachineTranslateOptions): Promise<MachineTranslateResponse & MachineTranslateResponseNonNullableFields>;
|
|
4450
5654
|
}
|
|
4451
|
-
declare function bulkMachineTranslate$1(httpClient: HttpClient): BulkMachineTranslateSignature;
|
|
5655
|
+
declare function bulkMachineTranslate$1(httpClient: HttpClient$3): BulkMachineTranslateSignature;
|
|
4452
5656
|
interface BulkMachineTranslateSignature {
|
|
4453
5657
|
/**
|
|
4454
5658
|
* Translates the text of multiple units of translatable content from one supported language to another.
|
|
@@ -4478,8 +5682,8 @@ interface BulkMachineTranslateSignature {
|
|
|
4478
5682
|
(sourceLanguage: SupportedLanguage, options?: BulkMachineTranslateOptions | undefined): Promise<BulkMachineTranslateResponse & BulkMachineTranslateResponseNonNullableFields>;
|
|
4479
5683
|
}
|
|
4480
5684
|
|
|
4481
|
-
declare const machineTranslate: BuildRESTFunction<typeof machineTranslate$1> & typeof machineTranslate$1
|
|
4482
|
-
declare const bulkMachineTranslate: BuildRESTFunction<typeof bulkMachineTranslate$1> & typeof bulkMachineTranslate$1
|
|
5685
|
+
declare const machineTranslate: MaybeContext$3<BuildRESTFunction$3<typeof machineTranslate$1> & typeof machineTranslate$1>;
|
|
5686
|
+
declare const bulkMachineTranslate: MaybeContext$3<BuildRESTFunction$3<typeof bulkMachineTranslate$1> & typeof bulkMachineTranslate$1>;
|
|
4483
5687
|
|
|
4484
5688
|
type context$3_BulkMachineTranslateOptions = BulkMachineTranslateOptions;
|
|
4485
5689
|
type context$3_BulkMachineTranslateRequest = BulkMachineTranslateRequest;
|
|
@@ -4506,6 +5710,416 @@ declare namespace context$3 {
|
|
|
4506
5710
|
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 };
|
|
4507
5711
|
}
|
|
4508
5712
|
|
|
5713
|
+
type HostModule$2<T, H extends Host$2> = {
|
|
5714
|
+
__type: 'host';
|
|
5715
|
+
create(host: H): T;
|
|
5716
|
+
};
|
|
5717
|
+
type HostModuleAPI$2<T extends HostModule$2<any, any>> = T extends HostModule$2<infer U, any> ? U : never;
|
|
5718
|
+
type Host$2<Environment = unknown> = {
|
|
5719
|
+
channel: {
|
|
5720
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
5721
|
+
disconnect: () => void;
|
|
5722
|
+
} | Promise<{
|
|
5723
|
+
disconnect: () => void;
|
|
5724
|
+
}>;
|
|
5725
|
+
};
|
|
5726
|
+
environment?: Environment;
|
|
5727
|
+
/**
|
|
5728
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
5729
|
+
*/
|
|
5730
|
+
apiBaseUrl?: string;
|
|
5731
|
+
/**
|
|
5732
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
5733
|
+
* like internationalization, billing, etc.
|
|
5734
|
+
*/
|
|
5735
|
+
essentials?: {
|
|
5736
|
+
/**
|
|
5737
|
+
* The language of the currently viewed session
|
|
5738
|
+
*/
|
|
5739
|
+
language?: string;
|
|
5740
|
+
/**
|
|
5741
|
+
* The locale of the currently viewed session
|
|
5742
|
+
*/
|
|
5743
|
+
locale?: string;
|
|
5744
|
+
/**
|
|
5745
|
+
* Any headers that should be passed through to the API requests
|
|
5746
|
+
*/
|
|
5747
|
+
passThroughHeaders?: Record<string, string>;
|
|
5748
|
+
};
|
|
5749
|
+
};
|
|
5750
|
+
|
|
5751
|
+
type RESTFunctionDescriptor$2<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$2) => T;
|
|
5752
|
+
interface HttpClient$2 {
|
|
5753
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$2<TResponse, TData>): Promise<HttpResponse$2<TResponse>>;
|
|
5754
|
+
fetchWithAuth: typeof fetch;
|
|
5755
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
5756
|
+
getActiveToken?: () => string | undefined;
|
|
5757
|
+
}
|
|
5758
|
+
type RequestOptionsFactory$2<TResponse = any, TData = any> = (context: any) => RequestOptions$2<TResponse, TData>;
|
|
5759
|
+
type HttpResponse$2<T = any> = {
|
|
5760
|
+
data: T;
|
|
5761
|
+
status: number;
|
|
5762
|
+
statusText: string;
|
|
5763
|
+
headers: any;
|
|
5764
|
+
request?: any;
|
|
5765
|
+
};
|
|
5766
|
+
type RequestOptions$2<_TResponse = any, Data = any> = {
|
|
5767
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
5768
|
+
url: string;
|
|
5769
|
+
data?: Data;
|
|
5770
|
+
params?: URLSearchParams;
|
|
5771
|
+
} & APIMetadata$2;
|
|
5772
|
+
type APIMetadata$2 = {
|
|
5773
|
+
methodFqn?: string;
|
|
5774
|
+
entityFqdn?: string;
|
|
5775
|
+
packageName?: string;
|
|
5776
|
+
};
|
|
5777
|
+
type BuildRESTFunction$2<T extends RESTFunctionDescriptor$2> = T extends RESTFunctionDescriptor$2<infer U> ? U : never;
|
|
5778
|
+
type EventDefinition$4<Payload = unknown, Type extends string = string> = {
|
|
5779
|
+
__type: 'event-definition';
|
|
5780
|
+
type: Type;
|
|
5781
|
+
isDomainEvent?: boolean;
|
|
5782
|
+
transformations?: (envelope: unknown) => Payload;
|
|
5783
|
+
__payload: Payload;
|
|
5784
|
+
};
|
|
5785
|
+
declare function EventDefinition$4<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$4<Payload, Type>;
|
|
5786
|
+
type EventHandler$4<T extends EventDefinition$4> = (payload: T['__payload']) => void | Promise<void>;
|
|
5787
|
+
type BuildEventDefinition$4<T extends EventDefinition$4<any, string>> = (handler: EventHandler$4<T>) => void;
|
|
5788
|
+
|
|
5789
|
+
type ServicePluginMethodInput$2 = {
|
|
5790
|
+
request: any;
|
|
5791
|
+
metadata: any;
|
|
5792
|
+
};
|
|
5793
|
+
type ServicePluginContract$2 = Record<string, (payload: ServicePluginMethodInput$2) => unknown | Promise<unknown>>;
|
|
5794
|
+
type ServicePluginMethodMetadata$2 = {
|
|
5795
|
+
name: string;
|
|
5796
|
+
primaryHttpMappingPath: string;
|
|
5797
|
+
transformations: {
|
|
5798
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$2;
|
|
5799
|
+
toREST: (...args: unknown[]) => unknown;
|
|
5800
|
+
};
|
|
5801
|
+
};
|
|
5802
|
+
type ServicePluginDefinition$2<Contract extends ServicePluginContract$2> = {
|
|
5803
|
+
__type: 'service-plugin-definition';
|
|
5804
|
+
componentType: string;
|
|
5805
|
+
methods: ServicePluginMethodMetadata$2[];
|
|
5806
|
+
__contract: Contract;
|
|
5807
|
+
};
|
|
5808
|
+
declare function ServicePluginDefinition$2<Contract extends ServicePluginContract$2>(componentType: string, methods: ServicePluginMethodMetadata$2[]): ServicePluginDefinition$2<Contract>;
|
|
5809
|
+
type BuildServicePluginDefinition$2<T extends ServicePluginDefinition$2<any>> = (implementation: T['__contract']) => void;
|
|
5810
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$2 = "wix_spi_error";
|
|
5811
|
+
|
|
5812
|
+
type RequestContext$2 = {
|
|
5813
|
+
isSSR: boolean;
|
|
5814
|
+
host: string;
|
|
5815
|
+
protocol?: string;
|
|
5816
|
+
};
|
|
5817
|
+
type ResponseTransformer$2 = (data: any, headers?: any) => any;
|
|
5818
|
+
/**
|
|
5819
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
5820
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
5821
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
5822
|
+
*/
|
|
5823
|
+
type Method$2 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
5824
|
+
type AmbassadorRequestOptions$2<T = any> = {
|
|
5825
|
+
_?: T;
|
|
5826
|
+
url?: string;
|
|
5827
|
+
method?: Method$2;
|
|
5828
|
+
params?: any;
|
|
5829
|
+
data?: any;
|
|
5830
|
+
transformResponse?: ResponseTransformer$2 | ResponseTransformer$2[];
|
|
5831
|
+
};
|
|
5832
|
+
type AmbassadorFactory$2<Request, Response> = (payload: Request) => ((context: RequestContext$2) => AmbassadorRequestOptions$2<Response>) & {
|
|
5833
|
+
__isAmbassador: boolean;
|
|
5834
|
+
};
|
|
5835
|
+
type AmbassadorFunctionDescriptor$2<Request = any, Response = any> = AmbassadorFactory$2<Request, Response>;
|
|
5836
|
+
type BuildAmbassadorFunction$2<T extends AmbassadorFunctionDescriptor$2> = T extends AmbassadorFunctionDescriptor$2<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
5837
|
+
|
|
5838
|
+
declare global {
|
|
5839
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
5840
|
+
interface SymbolConstructor {
|
|
5841
|
+
readonly observable: symbol;
|
|
5842
|
+
}
|
|
5843
|
+
}
|
|
5844
|
+
|
|
5845
|
+
declare const emptyObjectSymbol$2: unique symbol;
|
|
5846
|
+
|
|
5847
|
+
/**
|
|
5848
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
5849
|
+
|
|
5850
|
+
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)).
|
|
5851
|
+
|
|
5852
|
+
@example
|
|
5853
|
+
```
|
|
5854
|
+
import type {EmptyObject} from 'type-fest';
|
|
5855
|
+
|
|
5856
|
+
// The following illustrates the problem with `{}`.
|
|
5857
|
+
const foo1: {} = {}; // Pass
|
|
5858
|
+
const foo2: {} = []; // Pass
|
|
5859
|
+
const foo3: {} = 42; // Pass
|
|
5860
|
+
const foo4: {} = {a: 1}; // Pass
|
|
5861
|
+
|
|
5862
|
+
// With `EmptyObject` only the first case is valid.
|
|
5863
|
+
const bar1: EmptyObject = {}; // Pass
|
|
5864
|
+
const bar2: EmptyObject = 42; // Fail
|
|
5865
|
+
const bar3: EmptyObject = []; // Fail
|
|
5866
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
5867
|
+
```
|
|
5868
|
+
|
|
5869
|
+
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}.
|
|
5870
|
+
|
|
5871
|
+
@category Object
|
|
5872
|
+
*/
|
|
5873
|
+
type EmptyObject$2 = {[emptyObjectSymbol$2]?: never};
|
|
5874
|
+
|
|
5875
|
+
/**
|
|
5876
|
+
Returns a boolean for whether the two given types are equal.
|
|
5877
|
+
|
|
5878
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
5879
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
5880
|
+
|
|
5881
|
+
Use-cases:
|
|
5882
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
5883
|
+
|
|
5884
|
+
@example
|
|
5885
|
+
```
|
|
5886
|
+
import type {IsEqual} from 'type-fest';
|
|
5887
|
+
|
|
5888
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
5889
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
5890
|
+
type Includes<Value extends readonly any[], Item> =
|
|
5891
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
5892
|
+
? IsEqual<Value[0], Item> extends true
|
|
5893
|
+
? true
|
|
5894
|
+
: Includes<rest, Item>
|
|
5895
|
+
: false;
|
|
5896
|
+
```
|
|
5897
|
+
|
|
5898
|
+
@category Type Guard
|
|
5899
|
+
@category Utilities
|
|
5900
|
+
*/
|
|
5901
|
+
type IsEqual$2<A, B> =
|
|
5902
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
5903
|
+
(<G>() => G extends B ? 1 : 2)
|
|
5904
|
+
? true
|
|
5905
|
+
: false;
|
|
5906
|
+
|
|
5907
|
+
/**
|
|
5908
|
+
Filter out keys from an object.
|
|
5909
|
+
|
|
5910
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
5911
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
5912
|
+
Returns `Key` otherwise.
|
|
5913
|
+
|
|
5914
|
+
@example
|
|
5915
|
+
```
|
|
5916
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
5917
|
+
//=> never
|
|
5918
|
+
```
|
|
5919
|
+
|
|
5920
|
+
@example
|
|
5921
|
+
```
|
|
5922
|
+
type Filtered = Filter<'bar', string>;
|
|
5923
|
+
//=> never
|
|
5924
|
+
```
|
|
5925
|
+
|
|
5926
|
+
@example
|
|
5927
|
+
```
|
|
5928
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
5929
|
+
//=> 'bar'
|
|
5930
|
+
```
|
|
5931
|
+
|
|
5932
|
+
@see {Except}
|
|
5933
|
+
*/
|
|
5934
|
+
type Filter$2<KeyType, ExcludeType> = IsEqual$2<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
5935
|
+
|
|
5936
|
+
type ExceptOptions$2 = {
|
|
5937
|
+
/**
|
|
5938
|
+
Disallow assigning non-specified properties.
|
|
5939
|
+
|
|
5940
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
5941
|
+
|
|
5942
|
+
@default false
|
|
5943
|
+
*/
|
|
5944
|
+
requireExactProps?: boolean;
|
|
5945
|
+
};
|
|
5946
|
+
|
|
5947
|
+
/**
|
|
5948
|
+
Create a type from an object type without certain keys.
|
|
5949
|
+
|
|
5950
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
5951
|
+
|
|
5952
|
+
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.
|
|
5953
|
+
|
|
5954
|
+
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)).
|
|
5955
|
+
|
|
5956
|
+
@example
|
|
5957
|
+
```
|
|
5958
|
+
import type {Except} from 'type-fest';
|
|
5959
|
+
|
|
5960
|
+
type Foo = {
|
|
5961
|
+
a: number;
|
|
5962
|
+
b: string;
|
|
5963
|
+
};
|
|
5964
|
+
|
|
5965
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
5966
|
+
//=> {b: string}
|
|
5967
|
+
|
|
5968
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
5969
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
5970
|
+
|
|
5971
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
5972
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
5973
|
+
|
|
5974
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
5975
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
5976
|
+
```
|
|
5977
|
+
|
|
5978
|
+
@category Object
|
|
5979
|
+
*/
|
|
5980
|
+
type Except$2<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$2 = {requireExactProps: false}> = {
|
|
5981
|
+
[KeyType in keyof ObjectType as Filter$2<KeyType, KeysType>]: ObjectType[KeyType];
|
|
5982
|
+
} & (Options['requireExactProps'] extends true
|
|
5983
|
+
? Partial<Record<KeysType, never>>
|
|
5984
|
+
: {});
|
|
5985
|
+
|
|
5986
|
+
/**
|
|
5987
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
5988
|
+
|
|
5989
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
5990
|
+
|
|
5991
|
+
@example
|
|
5992
|
+
```
|
|
5993
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
5994
|
+
|
|
5995
|
+
interface Example {
|
|
5996
|
+
a: string;
|
|
5997
|
+
b: string | number;
|
|
5998
|
+
c?: string;
|
|
5999
|
+
d: {};
|
|
6000
|
+
}
|
|
6001
|
+
|
|
6002
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
6003
|
+
//=> 'a'
|
|
6004
|
+
```
|
|
6005
|
+
|
|
6006
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
6007
|
+
|
|
6008
|
+
@example
|
|
6009
|
+
```
|
|
6010
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
6011
|
+
|
|
6012
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
6013
|
+
//=> 'a' | 'c'
|
|
6014
|
+
```
|
|
6015
|
+
|
|
6016
|
+
@category Object
|
|
6017
|
+
*/
|
|
6018
|
+
type ConditionalKeys$2<Base, Condition> = NonNullable<
|
|
6019
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
6020
|
+
{
|
|
6021
|
+
// Map through all the keys of the given base type.
|
|
6022
|
+
[Key in keyof Base]:
|
|
6023
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
6024
|
+
Base[Key] extends Condition
|
|
6025
|
+
// Retain this key since the condition passes.
|
|
6026
|
+
? Key
|
|
6027
|
+
// Discard this key since the condition fails.
|
|
6028
|
+
: never;
|
|
6029
|
+
|
|
6030
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
6031
|
+
}[keyof Base]
|
|
6032
|
+
>;
|
|
6033
|
+
|
|
6034
|
+
/**
|
|
6035
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
6036
|
+
|
|
6037
|
+
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.
|
|
6038
|
+
|
|
6039
|
+
@example
|
|
6040
|
+
```
|
|
6041
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
6042
|
+
|
|
6043
|
+
class Awesome {
|
|
6044
|
+
name: string;
|
|
6045
|
+
successes: number;
|
|
6046
|
+
failures: bigint;
|
|
6047
|
+
|
|
6048
|
+
run() {}
|
|
6049
|
+
}
|
|
6050
|
+
|
|
6051
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
6052
|
+
//=> {run: () => void}
|
|
6053
|
+
```
|
|
6054
|
+
|
|
6055
|
+
@example
|
|
6056
|
+
```
|
|
6057
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
6058
|
+
|
|
6059
|
+
interface Example {
|
|
6060
|
+
a: string;
|
|
6061
|
+
b: string | number;
|
|
6062
|
+
c: () => void;
|
|
6063
|
+
d: {};
|
|
6064
|
+
}
|
|
6065
|
+
|
|
6066
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
6067
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
6068
|
+
```
|
|
6069
|
+
|
|
6070
|
+
@category Object
|
|
6071
|
+
*/
|
|
6072
|
+
type ConditionalExcept$2<Base, Condition> = Except$2<
|
|
6073
|
+
Base,
|
|
6074
|
+
ConditionalKeys$2<Base, Condition>
|
|
6075
|
+
>;
|
|
6076
|
+
|
|
6077
|
+
/**
|
|
6078
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
6079
|
+
* can either be a REST module or a host module.
|
|
6080
|
+
* This type is recursive, so it can describe nested modules.
|
|
6081
|
+
*/
|
|
6082
|
+
type Descriptors$2 = RESTFunctionDescriptor$2 | AmbassadorFunctionDescriptor$2 | HostModule$2<any, any> | EventDefinition$4<any> | ServicePluginDefinition$2<any> | {
|
|
6083
|
+
[key: string]: Descriptors$2 | PublicMetadata$2 | any;
|
|
6084
|
+
};
|
|
6085
|
+
/**
|
|
6086
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
6087
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
6088
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
6089
|
+
* do not match the given host (as they will not work with the given host).
|
|
6090
|
+
*/
|
|
6091
|
+
type BuildDescriptors$2<T extends Descriptors$2, H extends Host$2<any> | undefined, Depth extends number = 5> = {
|
|
6092
|
+
done: T;
|
|
6093
|
+
recurse: T extends {
|
|
6094
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$2;
|
|
6095
|
+
} ? never : T extends AmbassadorFunctionDescriptor$2 ? BuildAmbassadorFunction$2<T> : T extends RESTFunctionDescriptor$2 ? BuildRESTFunction$2<T> : T extends EventDefinition$4<any> ? BuildEventDefinition$4<T> : T extends ServicePluginDefinition$2<any> ? BuildServicePluginDefinition$2<T> : T extends HostModule$2<any, any> ? HostModuleAPI$2<T> : ConditionalExcept$2<{
|
|
6096
|
+
[Key in keyof T]: T[Key] extends Descriptors$2 ? BuildDescriptors$2<T[Key], H, [
|
|
6097
|
+
-1,
|
|
6098
|
+
0,
|
|
6099
|
+
1,
|
|
6100
|
+
2,
|
|
6101
|
+
3,
|
|
6102
|
+
4,
|
|
6103
|
+
5
|
|
6104
|
+
][Depth]> : never;
|
|
6105
|
+
}, EmptyObject$2>;
|
|
6106
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
6107
|
+
type PublicMetadata$2 = {
|
|
6108
|
+
PACKAGE_NAME?: string;
|
|
6109
|
+
};
|
|
6110
|
+
|
|
6111
|
+
declare global {
|
|
6112
|
+
interface ContextualClient {
|
|
6113
|
+
}
|
|
6114
|
+
}
|
|
6115
|
+
/**
|
|
6116
|
+
* A type used to create concerete types from SDK descriptors in
|
|
6117
|
+
* case a contextual client is available.
|
|
6118
|
+
*/
|
|
6119
|
+
type MaybeContext$2<T extends Descriptors$2> = globalThis.ContextualClient extends {
|
|
6120
|
+
host: Host$2;
|
|
6121
|
+
} ? BuildDescriptors$2<T, globalThis.ContextualClient['host']> : T;
|
|
6122
|
+
|
|
4509
6123
|
interface SiteTranslatableProperties {
|
|
4510
6124
|
/** Total number of words that exist in the main_language */
|
|
4511
6125
|
totalWords?: number;
|
|
@@ -4827,43 +6441,453 @@ interface GetSiteTranslatablesPropertiesOptions {
|
|
|
4827
6441
|
translatedLanguage?: Locale;
|
|
4828
6442
|
}
|
|
4829
6443
|
|
|
4830
|
-
declare function translateSite$1(httpClient: HttpClient): TranslateSiteSignature;
|
|
4831
|
-
interface TranslateSiteSignature {
|
|
4832
|
-
/**
|
|
4833
|
-
* Start a task to auto-translate all site content that hasn't been translated yet
|
|
4834
|
-
* @param - Language from which the site content is translated
|
|
4835
|
-
*/
|
|
4836
|
-
(mainLanguage: Locale, options: TranslateSiteOptions): Promise<void>;
|
|
6444
|
+
declare function translateSite$1(httpClient: HttpClient$2): TranslateSiteSignature;
|
|
6445
|
+
interface TranslateSiteSignature {
|
|
6446
|
+
/**
|
|
6447
|
+
* Start a task to auto-translate all site content that hasn't been translated yet
|
|
6448
|
+
* @param - Language from which the site content is translated
|
|
6449
|
+
*/
|
|
6450
|
+
(mainLanguage: Locale, options: TranslateSiteOptions): Promise<void>;
|
|
6451
|
+
}
|
|
6452
|
+
declare function getSiteTranslatablesProperties$1(httpClient: HttpClient$2): GetSiteTranslatablesPropertiesSignature;
|
|
6453
|
+
interface GetSiteTranslatablesPropertiesSignature {
|
|
6454
|
+
/**
|
|
6455
|
+
* Receive the site's translation status
|
|
6456
|
+
* @param - Number of words included in main_language
|
|
6457
|
+
*/
|
|
6458
|
+
(mainLanguage: Locale, options?: GetSiteTranslatablesPropertiesOptions | undefined): Promise<GetSiteTranslatablesPropertiesResponse & GetSiteTranslatablesPropertiesResponseNonNullableFields>;
|
|
6459
|
+
}
|
|
6460
|
+
|
|
6461
|
+
declare const translateSite: MaybeContext$2<BuildRESTFunction$2<typeof translateSite$1> & typeof translateSite$1>;
|
|
6462
|
+
declare const getSiteTranslatablesProperties: MaybeContext$2<BuildRESTFunction$2<typeof getSiteTranslatablesProperties$1> & typeof getSiteTranslatablesProperties$1>;
|
|
6463
|
+
|
|
6464
|
+
type context$2_ApplicationTranslatableProperties = ApplicationTranslatableProperties;
|
|
6465
|
+
type context$2_Flag = Flag;
|
|
6466
|
+
declare const context$2_Flag: typeof Flag;
|
|
6467
|
+
type context$2_GetSiteTranslatablesPropertiesOptions = GetSiteTranslatablesPropertiesOptions;
|
|
6468
|
+
type context$2_GetSiteTranslatablesPropertiesRequest = GetSiteTranslatablesPropertiesRequest;
|
|
6469
|
+
type context$2_GetSiteTranslatablesPropertiesResponse = GetSiteTranslatablesPropertiesResponse;
|
|
6470
|
+
type context$2_GetSiteTranslatablesPropertiesResponseNonNullableFields = GetSiteTranslatablesPropertiesResponseNonNullableFields;
|
|
6471
|
+
type context$2_Locale = Locale;
|
|
6472
|
+
type context$2_SiteTranslatableProperties = SiteTranslatableProperties;
|
|
6473
|
+
type context$2_TranslateSiteOptions = TranslateSiteOptions;
|
|
6474
|
+
type context$2_TranslateSiteRequest = TranslateSiteRequest;
|
|
6475
|
+
type context$2_TranslateSiteResponse = TranslateSiteResponse;
|
|
6476
|
+
declare const context$2_getSiteTranslatablesProperties: typeof getSiteTranslatablesProperties;
|
|
6477
|
+
declare const context$2_translateSite: typeof translateSite;
|
|
6478
|
+
declare namespace context$2 {
|
|
6479
|
+
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 };
|
|
6480
|
+
}
|
|
6481
|
+
|
|
6482
|
+
type HostModule$1<T, H extends Host$1> = {
|
|
6483
|
+
__type: 'host';
|
|
6484
|
+
create(host: H): T;
|
|
6485
|
+
};
|
|
6486
|
+
type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
|
|
6487
|
+
type Host$1<Environment = unknown> = {
|
|
6488
|
+
channel: {
|
|
6489
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
6490
|
+
disconnect: () => void;
|
|
6491
|
+
} | Promise<{
|
|
6492
|
+
disconnect: () => void;
|
|
6493
|
+
}>;
|
|
6494
|
+
};
|
|
6495
|
+
environment?: Environment;
|
|
6496
|
+
/**
|
|
6497
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
6498
|
+
*/
|
|
6499
|
+
apiBaseUrl?: string;
|
|
6500
|
+
/**
|
|
6501
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
6502
|
+
* like internationalization, billing, etc.
|
|
6503
|
+
*/
|
|
6504
|
+
essentials?: {
|
|
6505
|
+
/**
|
|
6506
|
+
* The language of the currently viewed session
|
|
6507
|
+
*/
|
|
6508
|
+
language?: string;
|
|
6509
|
+
/**
|
|
6510
|
+
* The locale of the currently viewed session
|
|
6511
|
+
*/
|
|
6512
|
+
locale?: string;
|
|
6513
|
+
/**
|
|
6514
|
+
* Any headers that should be passed through to the API requests
|
|
6515
|
+
*/
|
|
6516
|
+
passThroughHeaders?: Record<string, string>;
|
|
6517
|
+
};
|
|
6518
|
+
};
|
|
6519
|
+
|
|
6520
|
+
type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
|
|
6521
|
+
interface HttpClient$1 {
|
|
6522
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
|
|
6523
|
+
fetchWithAuth: typeof fetch;
|
|
6524
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
6525
|
+
getActiveToken?: () => string | undefined;
|
|
6526
|
+
}
|
|
6527
|
+
type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
|
|
6528
|
+
type HttpResponse$1<T = any> = {
|
|
6529
|
+
data: T;
|
|
6530
|
+
status: number;
|
|
6531
|
+
statusText: string;
|
|
6532
|
+
headers: any;
|
|
6533
|
+
request?: any;
|
|
6534
|
+
};
|
|
6535
|
+
type RequestOptions$1<_TResponse = any, Data = any> = {
|
|
6536
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
6537
|
+
url: string;
|
|
6538
|
+
data?: Data;
|
|
6539
|
+
params?: URLSearchParams;
|
|
6540
|
+
} & APIMetadata$1;
|
|
6541
|
+
type APIMetadata$1 = {
|
|
6542
|
+
methodFqn?: string;
|
|
6543
|
+
entityFqdn?: string;
|
|
6544
|
+
packageName?: string;
|
|
6545
|
+
};
|
|
6546
|
+
type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
|
|
6547
|
+
type EventDefinition$3<Payload = unknown, Type extends string = string> = {
|
|
6548
|
+
__type: 'event-definition';
|
|
6549
|
+
type: Type;
|
|
6550
|
+
isDomainEvent?: boolean;
|
|
6551
|
+
transformations?: (envelope: unknown) => Payload;
|
|
6552
|
+
__payload: Payload;
|
|
6553
|
+
};
|
|
6554
|
+
declare function EventDefinition$3<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$3<Payload, Type>;
|
|
6555
|
+
type EventHandler$3<T extends EventDefinition$3> = (payload: T['__payload']) => void | Promise<void>;
|
|
6556
|
+
type BuildEventDefinition$3<T extends EventDefinition$3<any, string>> = (handler: EventHandler$3<T>) => void;
|
|
6557
|
+
|
|
6558
|
+
type ServicePluginMethodInput$1 = {
|
|
6559
|
+
request: any;
|
|
6560
|
+
metadata: any;
|
|
6561
|
+
};
|
|
6562
|
+
type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
|
|
6563
|
+
type ServicePluginMethodMetadata$1 = {
|
|
6564
|
+
name: string;
|
|
6565
|
+
primaryHttpMappingPath: string;
|
|
6566
|
+
transformations: {
|
|
6567
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
|
|
6568
|
+
toREST: (...args: unknown[]) => unknown;
|
|
6569
|
+
};
|
|
6570
|
+
};
|
|
6571
|
+
type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
|
|
6572
|
+
__type: 'service-plugin-definition';
|
|
6573
|
+
componentType: string;
|
|
6574
|
+
methods: ServicePluginMethodMetadata$1[];
|
|
6575
|
+
__contract: Contract;
|
|
6576
|
+
};
|
|
6577
|
+
declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
|
|
6578
|
+
type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
|
|
6579
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
|
|
6580
|
+
|
|
6581
|
+
type RequestContext$1 = {
|
|
6582
|
+
isSSR: boolean;
|
|
6583
|
+
host: string;
|
|
6584
|
+
protocol?: string;
|
|
6585
|
+
};
|
|
6586
|
+
type ResponseTransformer$1 = (data: any, headers?: any) => any;
|
|
6587
|
+
/**
|
|
6588
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
6589
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
6590
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
6591
|
+
*/
|
|
6592
|
+
type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
6593
|
+
type AmbassadorRequestOptions$1<T = any> = {
|
|
6594
|
+
_?: T;
|
|
6595
|
+
url?: string;
|
|
6596
|
+
method?: Method$1;
|
|
6597
|
+
params?: any;
|
|
6598
|
+
data?: any;
|
|
6599
|
+
transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
|
|
6600
|
+
};
|
|
6601
|
+
type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
|
|
6602
|
+
__isAmbassador: boolean;
|
|
6603
|
+
};
|
|
6604
|
+
type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
|
|
6605
|
+
type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
6606
|
+
|
|
6607
|
+
declare global {
|
|
6608
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
6609
|
+
interface SymbolConstructor {
|
|
6610
|
+
readonly observable: symbol;
|
|
6611
|
+
}
|
|
6612
|
+
}
|
|
6613
|
+
|
|
6614
|
+
declare const emptyObjectSymbol$1: unique symbol;
|
|
6615
|
+
|
|
6616
|
+
/**
|
|
6617
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
6618
|
+
|
|
6619
|
+
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)).
|
|
6620
|
+
|
|
6621
|
+
@example
|
|
6622
|
+
```
|
|
6623
|
+
import type {EmptyObject} from 'type-fest';
|
|
6624
|
+
|
|
6625
|
+
// The following illustrates the problem with `{}`.
|
|
6626
|
+
const foo1: {} = {}; // Pass
|
|
6627
|
+
const foo2: {} = []; // Pass
|
|
6628
|
+
const foo3: {} = 42; // Pass
|
|
6629
|
+
const foo4: {} = {a: 1}; // Pass
|
|
6630
|
+
|
|
6631
|
+
// With `EmptyObject` only the first case is valid.
|
|
6632
|
+
const bar1: EmptyObject = {}; // Pass
|
|
6633
|
+
const bar2: EmptyObject = 42; // Fail
|
|
6634
|
+
const bar3: EmptyObject = []; // Fail
|
|
6635
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
6636
|
+
```
|
|
6637
|
+
|
|
6638
|
+
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}.
|
|
6639
|
+
|
|
6640
|
+
@category Object
|
|
6641
|
+
*/
|
|
6642
|
+
type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
|
|
6643
|
+
|
|
6644
|
+
/**
|
|
6645
|
+
Returns a boolean for whether the two given types are equal.
|
|
6646
|
+
|
|
6647
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
6648
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
6649
|
+
|
|
6650
|
+
Use-cases:
|
|
6651
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
6652
|
+
|
|
6653
|
+
@example
|
|
6654
|
+
```
|
|
6655
|
+
import type {IsEqual} from 'type-fest';
|
|
6656
|
+
|
|
6657
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
6658
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
6659
|
+
type Includes<Value extends readonly any[], Item> =
|
|
6660
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
6661
|
+
? IsEqual<Value[0], Item> extends true
|
|
6662
|
+
? true
|
|
6663
|
+
: Includes<rest, Item>
|
|
6664
|
+
: false;
|
|
6665
|
+
```
|
|
6666
|
+
|
|
6667
|
+
@category Type Guard
|
|
6668
|
+
@category Utilities
|
|
6669
|
+
*/
|
|
6670
|
+
type IsEqual$1<A, B> =
|
|
6671
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
6672
|
+
(<G>() => G extends B ? 1 : 2)
|
|
6673
|
+
? true
|
|
6674
|
+
: false;
|
|
6675
|
+
|
|
6676
|
+
/**
|
|
6677
|
+
Filter out keys from an object.
|
|
6678
|
+
|
|
6679
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
6680
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
6681
|
+
Returns `Key` otherwise.
|
|
6682
|
+
|
|
6683
|
+
@example
|
|
6684
|
+
```
|
|
6685
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
6686
|
+
//=> never
|
|
6687
|
+
```
|
|
6688
|
+
|
|
6689
|
+
@example
|
|
6690
|
+
```
|
|
6691
|
+
type Filtered = Filter<'bar', string>;
|
|
6692
|
+
//=> never
|
|
6693
|
+
```
|
|
6694
|
+
|
|
6695
|
+
@example
|
|
6696
|
+
```
|
|
6697
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
6698
|
+
//=> 'bar'
|
|
6699
|
+
```
|
|
6700
|
+
|
|
6701
|
+
@see {Except}
|
|
6702
|
+
*/
|
|
6703
|
+
type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
6704
|
+
|
|
6705
|
+
type ExceptOptions$1 = {
|
|
6706
|
+
/**
|
|
6707
|
+
Disallow assigning non-specified properties.
|
|
6708
|
+
|
|
6709
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
6710
|
+
|
|
6711
|
+
@default false
|
|
6712
|
+
*/
|
|
6713
|
+
requireExactProps?: boolean;
|
|
6714
|
+
};
|
|
6715
|
+
|
|
6716
|
+
/**
|
|
6717
|
+
Create a type from an object type without certain keys.
|
|
6718
|
+
|
|
6719
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
6720
|
+
|
|
6721
|
+
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.
|
|
6722
|
+
|
|
6723
|
+
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)).
|
|
6724
|
+
|
|
6725
|
+
@example
|
|
6726
|
+
```
|
|
6727
|
+
import type {Except} from 'type-fest';
|
|
6728
|
+
|
|
6729
|
+
type Foo = {
|
|
6730
|
+
a: number;
|
|
6731
|
+
b: string;
|
|
6732
|
+
};
|
|
6733
|
+
|
|
6734
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
6735
|
+
//=> {b: string}
|
|
6736
|
+
|
|
6737
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
6738
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
6739
|
+
|
|
6740
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
6741
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
6742
|
+
|
|
6743
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
6744
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
6745
|
+
```
|
|
6746
|
+
|
|
6747
|
+
@category Object
|
|
6748
|
+
*/
|
|
6749
|
+
type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
|
|
6750
|
+
[KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
|
|
6751
|
+
} & (Options['requireExactProps'] extends true
|
|
6752
|
+
? Partial<Record<KeysType, never>>
|
|
6753
|
+
: {});
|
|
6754
|
+
|
|
6755
|
+
/**
|
|
6756
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
6757
|
+
|
|
6758
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
6759
|
+
|
|
6760
|
+
@example
|
|
6761
|
+
```
|
|
6762
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
6763
|
+
|
|
6764
|
+
interface Example {
|
|
6765
|
+
a: string;
|
|
6766
|
+
b: string | number;
|
|
6767
|
+
c?: string;
|
|
6768
|
+
d: {};
|
|
6769
|
+
}
|
|
6770
|
+
|
|
6771
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
6772
|
+
//=> 'a'
|
|
6773
|
+
```
|
|
6774
|
+
|
|
6775
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
6776
|
+
|
|
6777
|
+
@example
|
|
6778
|
+
```
|
|
6779
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
6780
|
+
|
|
6781
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
6782
|
+
//=> 'a' | 'c'
|
|
6783
|
+
```
|
|
6784
|
+
|
|
6785
|
+
@category Object
|
|
6786
|
+
*/
|
|
6787
|
+
type ConditionalKeys$1<Base, Condition> = NonNullable<
|
|
6788
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
6789
|
+
{
|
|
6790
|
+
// Map through all the keys of the given base type.
|
|
6791
|
+
[Key in keyof Base]:
|
|
6792
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
6793
|
+
Base[Key] extends Condition
|
|
6794
|
+
// Retain this key since the condition passes.
|
|
6795
|
+
? Key
|
|
6796
|
+
// Discard this key since the condition fails.
|
|
6797
|
+
: never;
|
|
6798
|
+
|
|
6799
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
6800
|
+
}[keyof Base]
|
|
6801
|
+
>;
|
|
6802
|
+
|
|
6803
|
+
/**
|
|
6804
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
6805
|
+
|
|
6806
|
+
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.
|
|
6807
|
+
|
|
6808
|
+
@example
|
|
6809
|
+
```
|
|
6810
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
6811
|
+
|
|
6812
|
+
class Awesome {
|
|
6813
|
+
name: string;
|
|
6814
|
+
successes: number;
|
|
6815
|
+
failures: bigint;
|
|
6816
|
+
|
|
6817
|
+
run() {}
|
|
4837
6818
|
}
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
6819
|
+
|
|
6820
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
6821
|
+
//=> {run: () => void}
|
|
6822
|
+
```
|
|
6823
|
+
|
|
6824
|
+
@example
|
|
6825
|
+
```
|
|
6826
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
6827
|
+
|
|
6828
|
+
interface Example {
|
|
6829
|
+
a: string;
|
|
6830
|
+
b: string | number;
|
|
6831
|
+
c: () => void;
|
|
6832
|
+
d: {};
|
|
4845
6833
|
}
|
|
4846
6834
|
|
|
4847
|
-
|
|
4848
|
-
|
|
6835
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
6836
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
6837
|
+
```
|
|
4849
6838
|
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
type
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
6839
|
+
@category Object
|
|
6840
|
+
*/
|
|
6841
|
+
type ConditionalExcept$1<Base, Condition> = Except$1<
|
|
6842
|
+
Base,
|
|
6843
|
+
ConditionalKeys$1<Base, Condition>
|
|
6844
|
+
>;
|
|
6845
|
+
|
|
6846
|
+
/**
|
|
6847
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
6848
|
+
* can either be a REST module or a host module.
|
|
6849
|
+
* This type is recursive, so it can describe nested modules.
|
|
6850
|
+
*/
|
|
6851
|
+
type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$3<any> | ServicePluginDefinition$1<any> | {
|
|
6852
|
+
[key: string]: Descriptors$1 | PublicMetadata$1 | any;
|
|
6853
|
+
};
|
|
6854
|
+
/**
|
|
6855
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
6856
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
6857
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
6858
|
+
* do not match the given host (as they will not work with the given host).
|
|
6859
|
+
*/
|
|
6860
|
+
type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
|
|
6861
|
+
done: T;
|
|
6862
|
+
recurse: T extends {
|
|
6863
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
|
|
6864
|
+
} ? never : T extends AmbassadorFunctionDescriptor$1 ? BuildAmbassadorFunction$1<T> : T extends RESTFunctionDescriptor$1 ? BuildRESTFunction$1<T> : T extends EventDefinition$3<any> ? BuildEventDefinition$3<T> : T extends ServicePluginDefinition$1<any> ? BuildServicePluginDefinition$1<T> : T extends HostModule$1<any, any> ? HostModuleAPI$1<T> : ConditionalExcept$1<{
|
|
6865
|
+
[Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
|
|
6866
|
+
-1,
|
|
6867
|
+
0,
|
|
6868
|
+
1,
|
|
6869
|
+
2,
|
|
6870
|
+
3,
|
|
6871
|
+
4,
|
|
6872
|
+
5
|
|
6873
|
+
][Depth]> : never;
|
|
6874
|
+
}, EmptyObject$1>;
|
|
6875
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
6876
|
+
type PublicMetadata$1 = {
|
|
6877
|
+
PACKAGE_NAME?: string;
|
|
6878
|
+
};
|
|
6879
|
+
|
|
6880
|
+
declare global {
|
|
6881
|
+
interface ContextualClient {
|
|
6882
|
+
}
|
|
4866
6883
|
}
|
|
6884
|
+
/**
|
|
6885
|
+
* A type used to create concerete types from SDK descriptors in
|
|
6886
|
+
* case a contextual client is available.
|
|
6887
|
+
*/
|
|
6888
|
+
type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
|
|
6889
|
+
host: Host$1;
|
|
6890
|
+
} ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
|
|
4867
6891
|
|
|
4868
6892
|
interface Content {
|
|
4869
6893
|
/**
|
|
@@ -7644,7 +9668,7 @@ interface BulkUpdateContentByKeyOptions {
|
|
|
7644
9668
|
returnEntity?: boolean;
|
|
7645
9669
|
}
|
|
7646
9670
|
|
|
7647
|
-
declare function createContent$1(httpClient: HttpClient): CreateContentSignature;
|
|
9671
|
+
declare function createContent$1(httpClient: HttpClient$1): CreateContentSignature;
|
|
7648
9672
|
interface CreateContentSignature {
|
|
7649
9673
|
/**
|
|
7650
9674
|
* Creates a translation content item.
|
|
@@ -7655,7 +9679,7 @@ interface CreateContentSignature {
|
|
|
7655
9679
|
*/
|
|
7656
9680
|
(content: Content): Promise<Content & ContentNonNullableFields>;
|
|
7657
9681
|
}
|
|
7658
|
-
declare function getContent$1(httpClient: HttpClient): GetContentSignature;
|
|
9682
|
+
declare function getContent$1(httpClient: HttpClient$1): GetContentSignature;
|
|
7659
9683
|
interface GetContentSignature {
|
|
7660
9684
|
/**
|
|
7661
9685
|
* Retrieves a translation content item.
|
|
@@ -7664,7 +9688,7 @@ interface GetContentSignature {
|
|
|
7664
9688
|
*/
|
|
7665
9689
|
(contentId: string): Promise<Content & ContentNonNullableFields>;
|
|
7666
9690
|
}
|
|
7667
|
-
declare function updateContent$1(httpClient: HttpClient): UpdateContentSignature;
|
|
9691
|
+
declare function updateContent$1(httpClient: HttpClient$1): UpdateContentSignature;
|
|
7668
9692
|
interface UpdateContentSignature {
|
|
7669
9693
|
/**
|
|
7670
9694
|
* Updates a translation content item.
|
|
@@ -7681,7 +9705,7 @@ interface UpdateContentSignature {
|
|
|
7681
9705
|
*/
|
|
7682
9706
|
(_id: string | null, content: UpdateContent): Promise<Content & ContentNonNullableFields>;
|
|
7683
9707
|
}
|
|
7684
|
-
declare function updateContentByKey$1(httpClient: HttpClient): UpdateContentByKeySignature;
|
|
9708
|
+
declare function updateContentByKey$1(httpClient: HttpClient$1): UpdateContentByKeySignature;
|
|
7685
9709
|
interface UpdateContentByKeySignature {
|
|
7686
9710
|
/**
|
|
7687
9711
|
* Updates a translation content item by key.
|
|
@@ -7697,7 +9721,7 @@ interface UpdateContentByKeySignature {
|
|
|
7697
9721
|
*/
|
|
7698
9722
|
(content: Content): Promise<UpdateContentByKeyResponse & UpdateContentByKeyResponseNonNullableFields>;
|
|
7699
9723
|
}
|
|
7700
|
-
declare function deleteContent$1(httpClient: HttpClient): DeleteContentSignature;
|
|
9724
|
+
declare function deleteContent$1(httpClient: HttpClient$1): DeleteContentSignature;
|
|
7701
9725
|
interface DeleteContentSignature {
|
|
7702
9726
|
/**
|
|
7703
9727
|
* Deletes a translation content item.
|
|
@@ -7705,7 +9729,7 @@ interface DeleteContentSignature {
|
|
|
7705
9729
|
*/
|
|
7706
9730
|
(contentId: string): Promise<void>;
|
|
7707
9731
|
}
|
|
7708
|
-
declare function queryContents$1(httpClient: HttpClient): QueryContentsSignature;
|
|
9732
|
+
declare function queryContents$1(httpClient: HttpClient$1): QueryContentsSignature;
|
|
7709
9733
|
interface QueryContentsSignature {
|
|
7710
9734
|
/**
|
|
7711
9735
|
* Retrieves a list of translation content given the provided paging, filtering, and sorting. Up to 100 translation content items can be returned per request.
|
|
@@ -7718,7 +9742,7 @@ interface QueryContentsSignature {
|
|
|
7718
9742
|
*/
|
|
7719
9743
|
(options?: QueryContentsOptions | undefined): ContentsQueryBuilder;
|
|
7720
9744
|
}
|
|
7721
|
-
declare function searchContents$1(httpClient: HttpClient): SearchContentsSignature;
|
|
9745
|
+
declare function searchContents$1(httpClient: HttpClient$1): SearchContentsSignature;
|
|
7722
9746
|
interface SearchContentsSignature {
|
|
7723
9747
|
/**
|
|
7724
9748
|
* Retrieves a list of all translation content associated with a site that matches the search query, with optional data aggregation.
|
|
@@ -7733,7 +9757,7 @@ interface SearchContentsSignature {
|
|
|
7733
9757
|
*/
|
|
7734
9758
|
(options?: SearchContentsOptions | undefined): Promise<SearchContentsResponse & SearchContentsResponseNonNullableFields>;
|
|
7735
9759
|
}
|
|
7736
|
-
declare function bulkCreateContent$1(httpClient: HttpClient): BulkCreateContentSignature;
|
|
9760
|
+
declare function bulkCreateContent$1(httpClient: HttpClient$1): BulkCreateContentSignature;
|
|
7737
9761
|
interface BulkCreateContentSignature {
|
|
7738
9762
|
/**
|
|
7739
9763
|
* Creates multiple translation content items.
|
|
@@ -7743,7 +9767,7 @@ interface BulkCreateContentSignature {
|
|
|
7743
9767
|
*/
|
|
7744
9768
|
(contents: Content[], options?: BulkCreateContentOptions | undefined): Promise<BulkCreateContentResponse & BulkCreateContentResponseNonNullableFields>;
|
|
7745
9769
|
}
|
|
7746
|
-
declare function bulkUpdateContent$1(httpClient: HttpClient): BulkUpdateContentSignature;
|
|
9770
|
+
declare function bulkUpdateContent$1(httpClient: HttpClient$1): BulkUpdateContentSignature;
|
|
7747
9771
|
interface BulkUpdateContentSignature {
|
|
7748
9772
|
/**
|
|
7749
9773
|
* Updates multiple translation content items.
|
|
@@ -7751,7 +9775,7 @@ interface BulkUpdateContentSignature {
|
|
|
7751
9775
|
*/
|
|
7752
9776
|
(contents: BulkUpdateContentRequestMaskedContent[], options?: BulkUpdateContentOptions | undefined): Promise<BulkUpdateContentResponse & BulkUpdateContentResponseNonNullableFields>;
|
|
7753
9777
|
}
|
|
7754
|
-
declare function bulkUpdateContentByKey$1(httpClient: HttpClient): BulkUpdateContentByKeySignature;
|
|
9778
|
+
declare function bulkUpdateContentByKey$1(httpClient: HttpClient$1): BulkUpdateContentByKeySignature;
|
|
7755
9779
|
interface BulkUpdateContentByKeySignature {
|
|
7756
9780
|
/**
|
|
7757
9781
|
* update multiple Contents in a single request. Works synchronously. Each content is identified by a unique key, a combination of (schemaId, entityId, locale)
|
|
@@ -7759,7 +9783,7 @@ interface BulkUpdateContentByKeySignature {
|
|
|
7759
9783
|
*/
|
|
7760
9784
|
(contents: MaskedContent[], options?: BulkUpdateContentByKeyOptions | undefined): Promise<BulkUpdateContentByKeyResponse & BulkUpdateContentByKeyResponseNonNullableFields>;
|
|
7761
9785
|
}
|
|
7762
|
-
declare function bulkDeleteContent$1(httpClient: HttpClient): BulkDeleteContentSignature;
|
|
9786
|
+
declare function bulkDeleteContent$1(httpClient: HttpClient$1): BulkDeleteContentSignature;
|
|
7763
9787
|
interface BulkDeleteContentSignature {
|
|
7764
9788
|
/**
|
|
7765
9789
|
* Deletes multiple translation content items.
|
|
@@ -7767,23 +9791,41 @@ interface BulkDeleteContentSignature {
|
|
|
7767
9791
|
*/
|
|
7768
9792
|
(contentIds: string[]): Promise<BulkDeleteContentResponse & BulkDeleteContentResponseNonNullableFields>;
|
|
7769
9793
|
}
|
|
7770
|
-
declare const onContentCreated$1: EventDefinition<ContentCreatedEnvelope, "wix.multilingual.translation.v1.content_created">;
|
|
7771
|
-
declare const onContentUpdated$1: EventDefinition<ContentUpdatedEnvelope, "wix.multilingual.translation.v1.content_updated">;
|
|
7772
|
-
declare const onContentDeleted$1: EventDefinition<ContentDeletedEnvelope, "wix.multilingual.translation.v1.content_deleted">;
|
|
9794
|
+
declare const onContentCreated$1: EventDefinition$3<ContentCreatedEnvelope, "wix.multilingual.translation.v1.content_created">;
|
|
9795
|
+
declare const onContentUpdated$1: EventDefinition$3<ContentUpdatedEnvelope, "wix.multilingual.translation.v1.content_updated">;
|
|
9796
|
+
declare const onContentDeleted$1: EventDefinition$3<ContentDeletedEnvelope, "wix.multilingual.translation.v1.content_deleted">;
|
|
9797
|
+
|
|
9798
|
+
type EventDefinition$2<Payload = unknown, Type extends string = string> = {
|
|
9799
|
+
__type: 'event-definition';
|
|
9800
|
+
type: Type;
|
|
9801
|
+
isDomainEvent?: boolean;
|
|
9802
|
+
transformations?: (envelope: unknown) => Payload;
|
|
9803
|
+
__payload: Payload;
|
|
9804
|
+
};
|
|
9805
|
+
declare function EventDefinition$2<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$2<Payload, Type>;
|
|
9806
|
+
type EventHandler$2<T extends EventDefinition$2> = (payload: T['__payload']) => void | Promise<void>;
|
|
9807
|
+
type BuildEventDefinition$2<T extends EventDefinition$2<any, string>> = (handler: EventHandler$2<T>) => void;
|
|
9808
|
+
|
|
9809
|
+
declare global {
|
|
9810
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
9811
|
+
interface SymbolConstructor {
|
|
9812
|
+
readonly observable: symbol;
|
|
9813
|
+
}
|
|
9814
|
+
}
|
|
7773
9815
|
|
|
7774
|
-
declare function createEventModule$1<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
|
|
9816
|
+
declare function createEventModule$1<T extends EventDefinition$2<any, string>>(eventDefinition: T): BuildEventDefinition$2<T> & T;
|
|
7775
9817
|
|
|
7776
|
-
declare const createContent: BuildRESTFunction<typeof createContent$1> & typeof createContent$1
|
|
7777
|
-
declare const getContent: BuildRESTFunction<typeof getContent$1> & typeof getContent$1
|
|
7778
|
-
declare const updateContent: BuildRESTFunction<typeof updateContent$1> & typeof updateContent$1
|
|
7779
|
-
declare const updateContentByKey: BuildRESTFunction<typeof updateContentByKey$1> & typeof updateContentByKey$1
|
|
7780
|
-
declare const deleteContent: BuildRESTFunction<typeof deleteContent$1> & typeof deleteContent$1
|
|
7781
|
-
declare const queryContents: BuildRESTFunction<typeof queryContents$1> & typeof queryContents$1
|
|
7782
|
-
declare const searchContents: BuildRESTFunction<typeof searchContents$1> & typeof searchContents$1
|
|
7783
|
-
declare const bulkCreateContent: BuildRESTFunction<typeof bulkCreateContent$1> & typeof bulkCreateContent$1
|
|
7784
|
-
declare const bulkUpdateContent: BuildRESTFunction<typeof bulkUpdateContent$1> & typeof bulkUpdateContent$1
|
|
7785
|
-
declare const bulkUpdateContentByKey: BuildRESTFunction<typeof bulkUpdateContentByKey$1> & typeof bulkUpdateContentByKey$1
|
|
7786
|
-
declare const bulkDeleteContent: BuildRESTFunction<typeof bulkDeleteContent$1> & typeof bulkDeleteContent$1
|
|
9818
|
+
declare const createContent: MaybeContext$1<BuildRESTFunction$1<typeof createContent$1> & typeof createContent$1>;
|
|
9819
|
+
declare const getContent: MaybeContext$1<BuildRESTFunction$1<typeof getContent$1> & typeof getContent$1>;
|
|
9820
|
+
declare const updateContent: MaybeContext$1<BuildRESTFunction$1<typeof updateContent$1> & typeof updateContent$1>;
|
|
9821
|
+
declare const updateContentByKey: MaybeContext$1<BuildRESTFunction$1<typeof updateContentByKey$1> & typeof updateContentByKey$1>;
|
|
9822
|
+
declare const deleteContent: MaybeContext$1<BuildRESTFunction$1<typeof deleteContent$1> & typeof deleteContent$1>;
|
|
9823
|
+
declare const queryContents: MaybeContext$1<BuildRESTFunction$1<typeof queryContents$1> & typeof queryContents$1>;
|
|
9824
|
+
declare const searchContents: MaybeContext$1<BuildRESTFunction$1<typeof searchContents$1> & typeof searchContents$1>;
|
|
9825
|
+
declare const bulkCreateContent: MaybeContext$1<BuildRESTFunction$1<typeof bulkCreateContent$1> & typeof bulkCreateContent$1>;
|
|
9826
|
+
declare const bulkUpdateContent: MaybeContext$1<BuildRESTFunction$1<typeof bulkUpdateContent$1> & typeof bulkUpdateContent$1>;
|
|
9827
|
+
declare const bulkUpdateContentByKey: MaybeContext$1<BuildRESTFunction$1<typeof bulkUpdateContentByKey$1> & typeof bulkUpdateContentByKey$1>;
|
|
9828
|
+
declare const bulkDeleteContent: MaybeContext$1<BuildRESTFunction$1<typeof bulkDeleteContent$1> & typeof bulkDeleteContent$1>;
|
|
7787
9829
|
|
|
7788
9830
|
type _publicOnContentCreatedType = typeof onContentCreated$1;
|
|
7789
9831
|
/** */
|
|
@@ -8091,6 +10133,416 @@ declare namespace context$1 {
|
|
|
8091
10133
|
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 };
|
|
8092
10134
|
}
|
|
8093
10135
|
|
|
10136
|
+
type HostModule<T, H extends Host> = {
|
|
10137
|
+
__type: 'host';
|
|
10138
|
+
create(host: H): T;
|
|
10139
|
+
};
|
|
10140
|
+
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
|
|
10141
|
+
type Host<Environment = unknown> = {
|
|
10142
|
+
channel: {
|
|
10143
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
10144
|
+
disconnect: () => void;
|
|
10145
|
+
} | Promise<{
|
|
10146
|
+
disconnect: () => void;
|
|
10147
|
+
}>;
|
|
10148
|
+
};
|
|
10149
|
+
environment?: Environment;
|
|
10150
|
+
/**
|
|
10151
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
10152
|
+
*/
|
|
10153
|
+
apiBaseUrl?: string;
|
|
10154
|
+
/**
|
|
10155
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
10156
|
+
* like internationalization, billing, etc.
|
|
10157
|
+
*/
|
|
10158
|
+
essentials?: {
|
|
10159
|
+
/**
|
|
10160
|
+
* The language of the currently viewed session
|
|
10161
|
+
*/
|
|
10162
|
+
language?: string;
|
|
10163
|
+
/**
|
|
10164
|
+
* The locale of the currently viewed session
|
|
10165
|
+
*/
|
|
10166
|
+
locale?: string;
|
|
10167
|
+
/**
|
|
10168
|
+
* Any headers that should be passed through to the API requests
|
|
10169
|
+
*/
|
|
10170
|
+
passThroughHeaders?: Record<string, string>;
|
|
10171
|
+
};
|
|
10172
|
+
};
|
|
10173
|
+
|
|
10174
|
+
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
10175
|
+
interface HttpClient {
|
|
10176
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
10177
|
+
fetchWithAuth: typeof fetch;
|
|
10178
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
10179
|
+
getActiveToken?: () => string | undefined;
|
|
10180
|
+
}
|
|
10181
|
+
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
10182
|
+
type HttpResponse<T = any> = {
|
|
10183
|
+
data: T;
|
|
10184
|
+
status: number;
|
|
10185
|
+
statusText: string;
|
|
10186
|
+
headers: any;
|
|
10187
|
+
request?: any;
|
|
10188
|
+
};
|
|
10189
|
+
type RequestOptions<_TResponse = any, Data = any> = {
|
|
10190
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
10191
|
+
url: string;
|
|
10192
|
+
data?: Data;
|
|
10193
|
+
params?: URLSearchParams;
|
|
10194
|
+
} & APIMetadata;
|
|
10195
|
+
type APIMetadata = {
|
|
10196
|
+
methodFqn?: string;
|
|
10197
|
+
entityFqdn?: string;
|
|
10198
|
+
packageName?: string;
|
|
10199
|
+
};
|
|
10200
|
+
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
10201
|
+
type EventDefinition$1<Payload = unknown, Type extends string = string> = {
|
|
10202
|
+
__type: 'event-definition';
|
|
10203
|
+
type: Type;
|
|
10204
|
+
isDomainEvent?: boolean;
|
|
10205
|
+
transformations?: (envelope: unknown) => Payload;
|
|
10206
|
+
__payload: Payload;
|
|
10207
|
+
};
|
|
10208
|
+
declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
|
|
10209
|
+
type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
|
|
10210
|
+
type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
|
|
10211
|
+
|
|
10212
|
+
type ServicePluginMethodInput = {
|
|
10213
|
+
request: any;
|
|
10214
|
+
metadata: any;
|
|
10215
|
+
};
|
|
10216
|
+
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
|
|
10217
|
+
type ServicePluginMethodMetadata = {
|
|
10218
|
+
name: string;
|
|
10219
|
+
primaryHttpMappingPath: string;
|
|
10220
|
+
transformations: {
|
|
10221
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
|
|
10222
|
+
toREST: (...args: unknown[]) => unknown;
|
|
10223
|
+
};
|
|
10224
|
+
};
|
|
10225
|
+
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
|
|
10226
|
+
__type: 'service-plugin-definition';
|
|
10227
|
+
componentType: string;
|
|
10228
|
+
methods: ServicePluginMethodMetadata[];
|
|
10229
|
+
__contract: Contract;
|
|
10230
|
+
};
|
|
10231
|
+
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
|
|
10232
|
+
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
|
|
10233
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
|
|
10234
|
+
|
|
10235
|
+
type RequestContext = {
|
|
10236
|
+
isSSR: boolean;
|
|
10237
|
+
host: string;
|
|
10238
|
+
protocol?: string;
|
|
10239
|
+
};
|
|
10240
|
+
type ResponseTransformer = (data: any, headers?: any) => any;
|
|
10241
|
+
/**
|
|
10242
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
10243
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
10244
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
10245
|
+
*/
|
|
10246
|
+
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
10247
|
+
type AmbassadorRequestOptions<T = any> = {
|
|
10248
|
+
_?: T;
|
|
10249
|
+
url?: string;
|
|
10250
|
+
method?: Method;
|
|
10251
|
+
params?: any;
|
|
10252
|
+
data?: any;
|
|
10253
|
+
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
10254
|
+
};
|
|
10255
|
+
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
10256
|
+
__isAmbassador: boolean;
|
|
10257
|
+
};
|
|
10258
|
+
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
|
|
10259
|
+
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
10260
|
+
|
|
10261
|
+
declare global {
|
|
10262
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
10263
|
+
interface SymbolConstructor {
|
|
10264
|
+
readonly observable: symbol;
|
|
10265
|
+
}
|
|
10266
|
+
}
|
|
10267
|
+
|
|
10268
|
+
declare const emptyObjectSymbol: unique symbol;
|
|
10269
|
+
|
|
10270
|
+
/**
|
|
10271
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
10272
|
+
|
|
10273
|
+
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)).
|
|
10274
|
+
|
|
10275
|
+
@example
|
|
10276
|
+
```
|
|
10277
|
+
import type {EmptyObject} from 'type-fest';
|
|
10278
|
+
|
|
10279
|
+
// The following illustrates the problem with `{}`.
|
|
10280
|
+
const foo1: {} = {}; // Pass
|
|
10281
|
+
const foo2: {} = []; // Pass
|
|
10282
|
+
const foo3: {} = 42; // Pass
|
|
10283
|
+
const foo4: {} = {a: 1}; // Pass
|
|
10284
|
+
|
|
10285
|
+
// With `EmptyObject` only the first case is valid.
|
|
10286
|
+
const bar1: EmptyObject = {}; // Pass
|
|
10287
|
+
const bar2: EmptyObject = 42; // Fail
|
|
10288
|
+
const bar3: EmptyObject = []; // Fail
|
|
10289
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
10290
|
+
```
|
|
10291
|
+
|
|
10292
|
+
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}.
|
|
10293
|
+
|
|
10294
|
+
@category Object
|
|
10295
|
+
*/
|
|
10296
|
+
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
10297
|
+
|
|
10298
|
+
/**
|
|
10299
|
+
Returns a boolean for whether the two given types are equal.
|
|
10300
|
+
|
|
10301
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
10302
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
10303
|
+
|
|
10304
|
+
Use-cases:
|
|
10305
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
10306
|
+
|
|
10307
|
+
@example
|
|
10308
|
+
```
|
|
10309
|
+
import type {IsEqual} from 'type-fest';
|
|
10310
|
+
|
|
10311
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
10312
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
10313
|
+
type Includes<Value extends readonly any[], Item> =
|
|
10314
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
10315
|
+
? IsEqual<Value[0], Item> extends true
|
|
10316
|
+
? true
|
|
10317
|
+
: Includes<rest, Item>
|
|
10318
|
+
: false;
|
|
10319
|
+
```
|
|
10320
|
+
|
|
10321
|
+
@category Type Guard
|
|
10322
|
+
@category Utilities
|
|
10323
|
+
*/
|
|
10324
|
+
type IsEqual<A, B> =
|
|
10325
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
10326
|
+
(<G>() => G extends B ? 1 : 2)
|
|
10327
|
+
? true
|
|
10328
|
+
: false;
|
|
10329
|
+
|
|
10330
|
+
/**
|
|
10331
|
+
Filter out keys from an object.
|
|
10332
|
+
|
|
10333
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
10334
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
10335
|
+
Returns `Key` otherwise.
|
|
10336
|
+
|
|
10337
|
+
@example
|
|
10338
|
+
```
|
|
10339
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
10340
|
+
//=> never
|
|
10341
|
+
```
|
|
10342
|
+
|
|
10343
|
+
@example
|
|
10344
|
+
```
|
|
10345
|
+
type Filtered = Filter<'bar', string>;
|
|
10346
|
+
//=> never
|
|
10347
|
+
```
|
|
10348
|
+
|
|
10349
|
+
@example
|
|
10350
|
+
```
|
|
10351
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
10352
|
+
//=> 'bar'
|
|
10353
|
+
```
|
|
10354
|
+
|
|
10355
|
+
@see {Except}
|
|
10356
|
+
*/
|
|
10357
|
+
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
10358
|
+
|
|
10359
|
+
type ExceptOptions = {
|
|
10360
|
+
/**
|
|
10361
|
+
Disallow assigning non-specified properties.
|
|
10362
|
+
|
|
10363
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
10364
|
+
|
|
10365
|
+
@default false
|
|
10366
|
+
*/
|
|
10367
|
+
requireExactProps?: boolean;
|
|
10368
|
+
};
|
|
10369
|
+
|
|
10370
|
+
/**
|
|
10371
|
+
Create a type from an object type without certain keys.
|
|
10372
|
+
|
|
10373
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
10374
|
+
|
|
10375
|
+
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.
|
|
10376
|
+
|
|
10377
|
+
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)).
|
|
10378
|
+
|
|
10379
|
+
@example
|
|
10380
|
+
```
|
|
10381
|
+
import type {Except} from 'type-fest';
|
|
10382
|
+
|
|
10383
|
+
type Foo = {
|
|
10384
|
+
a: number;
|
|
10385
|
+
b: string;
|
|
10386
|
+
};
|
|
10387
|
+
|
|
10388
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
10389
|
+
//=> {b: string}
|
|
10390
|
+
|
|
10391
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
10392
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
10393
|
+
|
|
10394
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
10395
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
10396
|
+
|
|
10397
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
10398
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
10399
|
+
```
|
|
10400
|
+
|
|
10401
|
+
@category Object
|
|
10402
|
+
*/
|
|
10403
|
+
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
|
|
10404
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
10405
|
+
} & (Options['requireExactProps'] extends true
|
|
10406
|
+
? Partial<Record<KeysType, never>>
|
|
10407
|
+
: {});
|
|
10408
|
+
|
|
10409
|
+
/**
|
|
10410
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
10411
|
+
|
|
10412
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
10413
|
+
|
|
10414
|
+
@example
|
|
10415
|
+
```
|
|
10416
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
10417
|
+
|
|
10418
|
+
interface Example {
|
|
10419
|
+
a: string;
|
|
10420
|
+
b: string | number;
|
|
10421
|
+
c?: string;
|
|
10422
|
+
d: {};
|
|
10423
|
+
}
|
|
10424
|
+
|
|
10425
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
10426
|
+
//=> 'a'
|
|
10427
|
+
```
|
|
10428
|
+
|
|
10429
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
10430
|
+
|
|
10431
|
+
@example
|
|
10432
|
+
```
|
|
10433
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
10434
|
+
|
|
10435
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
10436
|
+
//=> 'a' | 'c'
|
|
10437
|
+
```
|
|
10438
|
+
|
|
10439
|
+
@category Object
|
|
10440
|
+
*/
|
|
10441
|
+
type ConditionalKeys<Base, Condition> = NonNullable<
|
|
10442
|
+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
10443
|
+
{
|
|
10444
|
+
// Map through all the keys of the given base type.
|
|
10445
|
+
[Key in keyof Base]:
|
|
10446
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
10447
|
+
Base[Key] extends Condition
|
|
10448
|
+
// Retain this key since the condition passes.
|
|
10449
|
+
? Key
|
|
10450
|
+
// Discard this key since the condition fails.
|
|
10451
|
+
: never;
|
|
10452
|
+
|
|
10453
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
10454
|
+
}[keyof Base]
|
|
10455
|
+
>;
|
|
10456
|
+
|
|
10457
|
+
/**
|
|
10458
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
10459
|
+
|
|
10460
|
+
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.
|
|
10461
|
+
|
|
10462
|
+
@example
|
|
10463
|
+
```
|
|
10464
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
10465
|
+
|
|
10466
|
+
class Awesome {
|
|
10467
|
+
name: string;
|
|
10468
|
+
successes: number;
|
|
10469
|
+
failures: bigint;
|
|
10470
|
+
|
|
10471
|
+
run() {}
|
|
10472
|
+
}
|
|
10473
|
+
|
|
10474
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
10475
|
+
//=> {run: () => void}
|
|
10476
|
+
```
|
|
10477
|
+
|
|
10478
|
+
@example
|
|
10479
|
+
```
|
|
10480
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
10481
|
+
|
|
10482
|
+
interface Example {
|
|
10483
|
+
a: string;
|
|
10484
|
+
b: string | number;
|
|
10485
|
+
c: () => void;
|
|
10486
|
+
d: {};
|
|
10487
|
+
}
|
|
10488
|
+
|
|
10489
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
10490
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
10491
|
+
```
|
|
10492
|
+
|
|
10493
|
+
@category Object
|
|
10494
|
+
*/
|
|
10495
|
+
type ConditionalExcept<Base, Condition> = Except<
|
|
10496
|
+
Base,
|
|
10497
|
+
ConditionalKeys<Base, Condition>
|
|
10498
|
+
>;
|
|
10499
|
+
|
|
10500
|
+
/**
|
|
10501
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
10502
|
+
* can either be a REST module or a host module.
|
|
10503
|
+
* This type is recursive, so it can describe nested modules.
|
|
10504
|
+
*/
|
|
10505
|
+
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition$1<any> | ServicePluginDefinition<any> | {
|
|
10506
|
+
[key: string]: Descriptors | PublicMetadata | any;
|
|
10507
|
+
};
|
|
10508
|
+
/**
|
|
10509
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
10510
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
10511
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
10512
|
+
* do not match the given host (as they will not work with the given host).
|
|
10513
|
+
*/
|
|
10514
|
+
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
|
|
10515
|
+
done: T;
|
|
10516
|
+
recurse: T extends {
|
|
10517
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE;
|
|
10518
|
+
} ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition$1<any> ? BuildEventDefinition$1<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
|
|
10519
|
+
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
|
|
10520
|
+
-1,
|
|
10521
|
+
0,
|
|
10522
|
+
1,
|
|
10523
|
+
2,
|
|
10524
|
+
3,
|
|
10525
|
+
4,
|
|
10526
|
+
5
|
|
10527
|
+
][Depth]> : never;
|
|
10528
|
+
}, EmptyObject>;
|
|
10529
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
10530
|
+
type PublicMetadata = {
|
|
10531
|
+
PACKAGE_NAME?: string;
|
|
10532
|
+
};
|
|
10533
|
+
|
|
10534
|
+
declare global {
|
|
10535
|
+
interface ContextualClient {
|
|
10536
|
+
}
|
|
10537
|
+
}
|
|
10538
|
+
/**
|
|
10539
|
+
* A type used to create concerete types from SDK descriptors in
|
|
10540
|
+
* case a contextual client is available.
|
|
10541
|
+
*/
|
|
10542
|
+
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
10543
|
+
host: Host;
|
|
10544
|
+
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
10545
|
+
|
|
8094
10546
|
interface Schema {
|
|
8095
10547
|
/**
|
|
8096
10548
|
* Translation schema ID.
|
|
@@ -8950,16 +11402,34 @@ interface ListSiteSchemasSignature {
|
|
|
8950
11402
|
*/
|
|
8951
11403
|
(options?: ListSiteSchemasOptions | undefined): Promise<ListSiteSchemasResponse & ListSiteSchemasResponseNonNullableFields>;
|
|
8952
11404
|
}
|
|
8953
|
-
declare const onSchemaCreated$1: EventDefinition<SchemaCreatedEnvelope, "wix.multilingual.translation.v1.schema_created">;
|
|
8954
|
-
declare const onSchemaUpdated$1: EventDefinition<SchemaUpdatedEnvelope, "wix.multilingual.translation.v1.schema_updated">;
|
|
8955
|
-
declare const onSchemaDeleted$1: EventDefinition<SchemaDeletedEnvelope, "wix.multilingual.translation.v1.schema_deleted">;
|
|
11405
|
+
declare const onSchemaCreated$1: EventDefinition$1<SchemaCreatedEnvelope, "wix.multilingual.translation.v1.schema_created">;
|
|
11406
|
+
declare const onSchemaUpdated$1: EventDefinition$1<SchemaUpdatedEnvelope, "wix.multilingual.translation.v1.schema_updated">;
|
|
11407
|
+
declare const onSchemaDeleted$1: EventDefinition$1<SchemaDeletedEnvelope, "wix.multilingual.translation.v1.schema_deleted">;
|
|
11408
|
+
|
|
11409
|
+
type EventDefinition<Payload = unknown, Type extends string = string> = {
|
|
11410
|
+
__type: 'event-definition';
|
|
11411
|
+
type: Type;
|
|
11412
|
+
isDomainEvent?: boolean;
|
|
11413
|
+
transformations?: (envelope: unknown) => Payload;
|
|
11414
|
+
__payload: Payload;
|
|
11415
|
+
};
|
|
11416
|
+
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
|
|
11417
|
+
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
|
|
11418
|
+
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
|
|
11419
|
+
|
|
11420
|
+
declare global {
|
|
11421
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
11422
|
+
interface SymbolConstructor {
|
|
11423
|
+
readonly observable: symbol;
|
|
11424
|
+
}
|
|
11425
|
+
}
|
|
8956
11426
|
|
|
8957
11427
|
declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
|
|
8958
11428
|
|
|
8959
|
-
declare const getSchema: BuildRESTFunction<typeof getSchema$1> & typeof getSchema$1
|
|
8960
|
-
declare const getSchemaByKey: BuildRESTFunction<typeof getSchemaByKey$1> & typeof getSchemaByKey$1
|
|
8961
|
-
declare const querySchemas: BuildRESTFunction<typeof querySchemas$1> & typeof querySchemas$1
|
|
8962
|
-
declare const listSiteSchemas: BuildRESTFunction<typeof listSiteSchemas$1> & typeof listSiteSchemas$1
|
|
11429
|
+
declare const getSchema: MaybeContext<BuildRESTFunction<typeof getSchema$1> & typeof getSchema$1>;
|
|
11430
|
+
declare const getSchemaByKey: MaybeContext<BuildRESTFunction<typeof getSchemaByKey$1> & typeof getSchemaByKey$1>;
|
|
11431
|
+
declare const querySchemas: MaybeContext<BuildRESTFunction<typeof querySchemas$1> & typeof querySchemas$1>;
|
|
11432
|
+
declare const listSiteSchemas: MaybeContext<BuildRESTFunction<typeof listSiteSchemas$1> & typeof listSiteSchemas$1>;
|
|
8963
11433
|
|
|
8964
11434
|
type _publicOnSchemaCreatedType = typeof onSchemaCreated$1;
|
|
8965
11435
|
/**
|