@wix/crm 1.0.132 → 1.0.133
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/build/cjs/context.js +1 -0
- package/build/cjs/context.js.map +1 -0
- package/build/cjs/index.js +1 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/meta.js +1 -0
- package/build/cjs/meta.js.map +1 -0
- package/package.json +8 -8
- package/type-bundles/context.bundle.d.ts +2680 -66
- package/type-bundles/index.bundle.d.ts +2680 -66
|
@@ -1,8 +1,51 @@
|
|
|
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 name of the environment, use for logging
|
|
17
|
+
*/
|
|
18
|
+
name?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
21
|
+
*/
|
|
22
|
+
apiBaseUrl?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
25
|
+
* like internationalization, billing, etc.
|
|
26
|
+
*/
|
|
27
|
+
essentials?: {
|
|
28
|
+
/**
|
|
29
|
+
* The language of the currently viewed session
|
|
30
|
+
*/
|
|
31
|
+
language?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The locale of the currently viewed session
|
|
34
|
+
*/
|
|
35
|
+
locale?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Any headers that should be passed through to the API requests
|
|
38
|
+
*/
|
|
39
|
+
passThroughHeaders?: Record<string, string>;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
1
43
|
type RESTFunctionDescriptor$5<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$5) => T;
|
|
2
44
|
interface HttpClient$5 {
|
|
3
45
|
request<TResponse, TData = any>(req: RequestOptionsFactory$5<TResponse, TData>): Promise<HttpResponse$5<TResponse>>;
|
|
4
46
|
fetchWithAuth: typeof fetch;
|
|
5
47
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
48
|
+
getActiveToken?: () => string | undefined;
|
|
6
49
|
}
|
|
7
50
|
type RequestOptionsFactory$5<TResponse = any, TData = any> = (context: any) => RequestOptions$5<TResponse, TData>;
|
|
8
51
|
type HttpResponse$5<T = any> = {
|
|
@@ -24,16 +67,65 @@ type APIMetadata$5 = {
|
|
|
24
67
|
packageName?: string;
|
|
25
68
|
};
|
|
26
69
|
type BuildRESTFunction$5<T extends RESTFunctionDescriptor$5> = T extends RESTFunctionDescriptor$5<infer U> ? U : never;
|
|
27
|
-
type EventDefinition$
|
|
70
|
+
type EventDefinition$5<Payload = unknown, Type extends string = string> = {
|
|
28
71
|
__type: 'event-definition';
|
|
29
72
|
type: Type;
|
|
30
73
|
isDomainEvent?: boolean;
|
|
31
74
|
transformations?: (envelope: unknown) => Payload;
|
|
32
75
|
__payload: Payload;
|
|
33
76
|
};
|
|
34
|
-
declare function EventDefinition$
|
|
35
|
-
type EventHandler$
|
|
36
|
-
type BuildEventDefinition$
|
|
77
|
+
declare function EventDefinition$5<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$5<Payload, Type>;
|
|
78
|
+
type EventHandler$5<T extends EventDefinition$5> = (payload: T['__payload']) => void | Promise<void>;
|
|
79
|
+
type BuildEventDefinition$5<T extends EventDefinition$5<any, string>> = (handler: EventHandler$5<T>) => void;
|
|
80
|
+
|
|
81
|
+
type ServicePluginMethodInput$5 = {
|
|
82
|
+
request: any;
|
|
83
|
+
metadata: any;
|
|
84
|
+
};
|
|
85
|
+
type ServicePluginContract$5 = Record<string, (payload: ServicePluginMethodInput$5) => unknown | Promise<unknown>>;
|
|
86
|
+
type ServicePluginMethodMetadata$5 = {
|
|
87
|
+
name: string;
|
|
88
|
+
primaryHttpMappingPath: string;
|
|
89
|
+
transformations: {
|
|
90
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$5;
|
|
91
|
+
toREST: (...args: unknown[]) => unknown;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
type ServicePluginDefinition$5<Contract extends ServicePluginContract$5> = {
|
|
95
|
+
__type: 'service-plugin-definition';
|
|
96
|
+
componentType: string;
|
|
97
|
+
methods: ServicePluginMethodMetadata$5[];
|
|
98
|
+
__contract: Contract;
|
|
99
|
+
};
|
|
100
|
+
declare function ServicePluginDefinition$5<Contract extends ServicePluginContract$5>(componentType: string, methods: ServicePluginMethodMetadata$5[]): ServicePluginDefinition$5<Contract>;
|
|
101
|
+
type BuildServicePluginDefinition$5<T extends ServicePluginDefinition$5<any>> = (implementation: T['__contract']) => void;
|
|
102
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$5 = "wix_spi_error";
|
|
103
|
+
|
|
104
|
+
type RequestContext$5 = {
|
|
105
|
+
isSSR: boolean;
|
|
106
|
+
host: string;
|
|
107
|
+
protocol?: string;
|
|
108
|
+
};
|
|
109
|
+
type ResponseTransformer$5 = (data: any, headers?: any) => any;
|
|
110
|
+
/**
|
|
111
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
112
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
113
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
114
|
+
*/
|
|
115
|
+
type Method$5 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
116
|
+
type AmbassadorRequestOptions$5<T = any> = {
|
|
117
|
+
_?: T;
|
|
118
|
+
url?: string;
|
|
119
|
+
method?: Method$5;
|
|
120
|
+
params?: any;
|
|
121
|
+
data?: any;
|
|
122
|
+
transformResponse?: ResponseTransformer$5 | ResponseTransformer$5[];
|
|
123
|
+
};
|
|
124
|
+
type AmbassadorFactory$5<Request, Response> = (payload: Request) => ((context: RequestContext$5) => AmbassadorRequestOptions$5<Response>) & {
|
|
125
|
+
__isAmbassador: boolean;
|
|
126
|
+
};
|
|
127
|
+
type AmbassadorFunctionDescriptor$5<Request = any, Response = any> = AmbassadorFactory$5<Request, Response>;
|
|
128
|
+
type BuildAmbassadorFunction$5<T extends AmbassadorFunctionDescriptor$5> = T extends AmbassadorFunctionDescriptor$5<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
37
129
|
|
|
38
130
|
declare global {
|
|
39
131
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -42,6 +134,348 @@ declare global {
|
|
|
42
134
|
}
|
|
43
135
|
}
|
|
44
136
|
|
|
137
|
+
declare const emptyObjectSymbol$5: unique symbol;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
141
|
+
|
|
142
|
+
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)).
|
|
143
|
+
|
|
144
|
+
@example
|
|
145
|
+
```
|
|
146
|
+
import type {EmptyObject} from 'type-fest';
|
|
147
|
+
|
|
148
|
+
// The following illustrates the problem with `{}`.
|
|
149
|
+
const foo1: {} = {}; // Pass
|
|
150
|
+
const foo2: {} = []; // Pass
|
|
151
|
+
const foo3: {} = 42; // Pass
|
|
152
|
+
const foo4: {} = {a: 1}; // Pass
|
|
153
|
+
|
|
154
|
+
// With `EmptyObject` only the first case is valid.
|
|
155
|
+
const bar1: EmptyObject = {}; // Pass
|
|
156
|
+
const bar2: EmptyObject = 42; // Fail
|
|
157
|
+
const bar3: EmptyObject = []; // Fail
|
|
158
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
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}.
|
|
162
|
+
|
|
163
|
+
@category Object
|
|
164
|
+
*/
|
|
165
|
+
type EmptyObject$5 = {[emptyObjectSymbol$5]?: never};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
Returns a boolean for whether the two given types are equal.
|
|
169
|
+
|
|
170
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
171
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
172
|
+
|
|
173
|
+
Use-cases:
|
|
174
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
175
|
+
|
|
176
|
+
@example
|
|
177
|
+
```
|
|
178
|
+
import type {IsEqual} from 'type-fest';
|
|
179
|
+
|
|
180
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
181
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
182
|
+
type Includes<Value extends readonly any[], Item> =
|
|
183
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
184
|
+
? IsEqual<Value[0], Item> extends true
|
|
185
|
+
? true
|
|
186
|
+
: Includes<rest, Item>
|
|
187
|
+
: false;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
@category Type Guard
|
|
191
|
+
@category Utilities
|
|
192
|
+
*/
|
|
193
|
+
type IsEqual$5<A, B> =
|
|
194
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
195
|
+
(<G>() => G extends B ? 1 : 2)
|
|
196
|
+
? true
|
|
197
|
+
: false;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
Filter out keys from an object.
|
|
201
|
+
|
|
202
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
203
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
204
|
+
Returns `Key` otherwise.
|
|
205
|
+
|
|
206
|
+
@example
|
|
207
|
+
```
|
|
208
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
209
|
+
//=> never
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
@example
|
|
213
|
+
```
|
|
214
|
+
type Filtered = Filter<'bar', string>;
|
|
215
|
+
//=> never
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
@example
|
|
219
|
+
```
|
|
220
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
221
|
+
//=> 'bar'
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
@see {Except}
|
|
225
|
+
*/
|
|
226
|
+
type Filter$5<KeyType, ExcludeType> = IsEqual$5<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
227
|
+
|
|
228
|
+
type ExceptOptions$5 = {
|
|
229
|
+
/**
|
|
230
|
+
Disallow assigning non-specified properties.
|
|
231
|
+
|
|
232
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
233
|
+
|
|
234
|
+
@default false
|
|
235
|
+
*/
|
|
236
|
+
requireExactProps?: boolean;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
Create a type from an object type without certain keys.
|
|
241
|
+
|
|
242
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
243
|
+
|
|
244
|
+
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.
|
|
245
|
+
|
|
246
|
+
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)).
|
|
247
|
+
|
|
248
|
+
@example
|
|
249
|
+
```
|
|
250
|
+
import type {Except} from 'type-fest';
|
|
251
|
+
|
|
252
|
+
type Foo = {
|
|
253
|
+
a: number;
|
|
254
|
+
b: string;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
258
|
+
//=> {b: string}
|
|
259
|
+
|
|
260
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
261
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
262
|
+
|
|
263
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
264
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
265
|
+
|
|
266
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
267
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
@category Object
|
|
271
|
+
*/
|
|
272
|
+
type Except$5<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$5 = {requireExactProps: false}> = {
|
|
273
|
+
[KeyType in keyof ObjectType as Filter$5<KeyType, KeysType>]: ObjectType[KeyType];
|
|
274
|
+
} & (Options['requireExactProps'] extends true
|
|
275
|
+
? Partial<Record<KeysType, never>>
|
|
276
|
+
: {});
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
Returns a boolean for whether the given type is `never`.
|
|
280
|
+
|
|
281
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
282
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
283
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
284
|
+
|
|
285
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
286
|
+
|
|
287
|
+
@example
|
|
288
|
+
```
|
|
289
|
+
import type {IsNever, And} from 'type-fest';
|
|
290
|
+
|
|
291
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
292
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
293
|
+
And<
|
|
294
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
295
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
296
|
+
>;
|
|
297
|
+
|
|
298
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
299
|
+
AreStringsEqual<I, O> extends true
|
|
300
|
+
? never
|
|
301
|
+
: void;
|
|
302
|
+
|
|
303
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
304
|
+
if (input === output) {
|
|
305
|
+
process.exit(0);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
endIfEqual('abc', 'abc');
|
|
310
|
+
//=> never
|
|
311
|
+
|
|
312
|
+
endIfEqual('abc', '123');
|
|
313
|
+
//=> void
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
@category Type Guard
|
|
317
|
+
@category Utilities
|
|
318
|
+
*/
|
|
319
|
+
type IsNever$5<T> = [T] extends [never] ? true : false;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
323
|
+
|
|
324
|
+
@see {@link IsNever}
|
|
325
|
+
|
|
326
|
+
@example
|
|
327
|
+
```
|
|
328
|
+
import type {IfNever} from 'type-fest';
|
|
329
|
+
|
|
330
|
+
type ShouldBeTrue = IfNever<never>;
|
|
331
|
+
//=> true
|
|
332
|
+
|
|
333
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
334
|
+
//=> 'bar'
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
@category Type Guard
|
|
338
|
+
@category Utilities
|
|
339
|
+
*/
|
|
340
|
+
type IfNever$5<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
341
|
+
IsNever$5<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
346
|
+
|
|
347
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
348
|
+
|
|
349
|
+
@example
|
|
350
|
+
```
|
|
351
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
352
|
+
|
|
353
|
+
interface Example {
|
|
354
|
+
a: string;
|
|
355
|
+
b: string | number;
|
|
356
|
+
c?: string;
|
|
357
|
+
d: {};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
361
|
+
//=> 'a'
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
365
|
+
|
|
366
|
+
@example
|
|
367
|
+
```
|
|
368
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
369
|
+
|
|
370
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
371
|
+
//=> 'a' | 'c'
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
@category Object
|
|
375
|
+
*/
|
|
376
|
+
type ConditionalKeys$5<Base, Condition> =
|
|
377
|
+
{
|
|
378
|
+
// Map through all the keys of the given base type.
|
|
379
|
+
[Key in keyof Base]-?:
|
|
380
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
381
|
+
Base[Key] extends Condition
|
|
382
|
+
// Retain this key
|
|
383
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
384
|
+
? IfNever$5<Base[Key], IfNever$5<Condition, Key, never>, Key>
|
|
385
|
+
// Discard this key since the condition fails.
|
|
386
|
+
: never;
|
|
387
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
388
|
+
}[keyof Base];
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
392
|
+
|
|
393
|
+
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.
|
|
394
|
+
|
|
395
|
+
@example
|
|
396
|
+
```
|
|
397
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
398
|
+
|
|
399
|
+
class Awesome {
|
|
400
|
+
name: string;
|
|
401
|
+
successes: number;
|
|
402
|
+
failures: bigint;
|
|
403
|
+
|
|
404
|
+
run() {}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
408
|
+
//=> {run: () => void}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
@example
|
|
412
|
+
```
|
|
413
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
414
|
+
|
|
415
|
+
interface Example {
|
|
416
|
+
a: string;
|
|
417
|
+
b: string | number;
|
|
418
|
+
c: () => void;
|
|
419
|
+
d: {};
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
423
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
@category Object
|
|
427
|
+
*/
|
|
428
|
+
type ConditionalExcept$5<Base, Condition> = Except$5<
|
|
429
|
+
Base,
|
|
430
|
+
ConditionalKeys$5<Base, Condition>
|
|
431
|
+
>;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
435
|
+
* can either be a REST module or a host module.
|
|
436
|
+
* This type is recursive, so it can describe nested modules.
|
|
437
|
+
*/
|
|
438
|
+
type Descriptors$5 = RESTFunctionDescriptor$5 | AmbassadorFunctionDescriptor$5 | HostModule$5<any, any> | EventDefinition$5<any> | ServicePluginDefinition$5<any> | {
|
|
439
|
+
[key: string]: Descriptors$5 | PublicMetadata$5 | any;
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
443
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
444
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
445
|
+
* do not match the given host (as they will not work with the given host).
|
|
446
|
+
*/
|
|
447
|
+
type BuildDescriptors$5<T extends Descriptors$5, H extends Host$5<any> | undefined, Depth extends number = 5> = {
|
|
448
|
+
done: T;
|
|
449
|
+
recurse: T extends {
|
|
450
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$5;
|
|
451
|
+
} ? never : T extends AmbassadorFunctionDescriptor$5 ? BuildAmbassadorFunction$5<T> : T extends RESTFunctionDescriptor$5 ? BuildRESTFunction$5<T> : T extends EventDefinition$5<any> ? BuildEventDefinition$5<T> : T extends ServicePluginDefinition$5<any> ? BuildServicePluginDefinition$5<T> : T extends HostModule$5<any, any> ? HostModuleAPI$5<T> : ConditionalExcept$5<{
|
|
452
|
+
[Key in keyof T]: T[Key] extends Descriptors$5 ? BuildDescriptors$5<T[Key], H, [
|
|
453
|
+
-1,
|
|
454
|
+
0,
|
|
455
|
+
1,
|
|
456
|
+
2,
|
|
457
|
+
3,
|
|
458
|
+
4,
|
|
459
|
+
5
|
|
460
|
+
][Depth]> : never;
|
|
461
|
+
}, EmptyObject$5>;
|
|
462
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
463
|
+
type PublicMetadata$5 = {
|
|
464
|
+
PACKAGE_NAME?: string;
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
declare global {
|
|
468
|
+
interface ContextualClient {
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* A type used to create concerete types from SDK descriptors in
|
|
473
|
+
* case a contextual client is available.
|
|
474
|
+
*/
|
|
475
|
+
type MaybeContext$5<T extends Descriptors$5> = globalThis.ContextualClient extends {
|
|
476
|
+
host: Host$5;
|
|
477
|
+
} ? BuildDescriptors$5<T, globalThis.ContextualClient['host']> : T;
|
|
478
|
+
|
|
45
479
|
interface ContactAttachment extends ContactAttachmentMediaOneOf {
|
|
46
480
|
/** The attachment's image (if the attachment is of type IMAGE) */
|
|
47
481
|
image?: string;
|
|
@@ -455,15 +889,15 @@ interface GetAttachmentSignature {
|
|
|
455
889
|
*/
|
|
456
890
|
(identifiers: GetAttachmentIdentifiers): Promise<ContactAttachment & ContactAttachmentNonNullableFields>;
|
|
457
891
|
}
|
|
458
|
-
declare const onAttachmentCreated$1: EventDefinition$
|
|
459
|
-
declare const onAttachmentDeleted$1: EventDefinition$
|
|
892
|
+
declare const onAttachmentCreated$1: EventDefinition$5<AttachmentCreatedEnvelope, "wix.contacts.v4.attachment_created">;
|
|
893
|
+
declare const onAttachmentDeleted$1: EventDefinition$5<AttachmentDeletedEnvelope, "wix.contacts.v4.attachment_deleted">;
|
|
460
894
|
|
|
461
|
-
declare function createEventModule$4<T extends EventDefinition$
|
|
895
|
+
declare function createEventModule$4<T extends EventDefinition$5<any, string>>(eventDefinition: T): BuildEventDefinition$5<T> & T;
|
|
462
896
|
|
|
463
|
-
declare const generateAttachmentUploadUrl: BuildRESTFunction$5<typeof generateAttachmentUploadUrl$1> & typeof generateAttachmentUploadUrl$1
|
|
464
|
-
declare const listAttachments: BuildRESTFunction$5<typeof listAttachments$1> & typeof listAttachments$1
|
|
465
|
-
declare const deleteAttachment: BuildRESTFunction$5<typeof deleteAttachment$1> & typeof deleteAttachment$1
|
|
466
|
-
declare const getAttachment: BuildRESTFunction$5<typeof getAttachment$1> & typeof getAttachment$1
|
|
897
|
+
declare const generateAttachmentUploadUrl: MaybeContext$5<BuildRESTFunction$5<typeof generateAttachmentUploadUrl$1> & typeof generateAttachmentUploadUrl$1>;
|
|
898
|
+
declare const listAttachments: MaybeContext$5<BuildRESTFunction$5<typeof listAttachments$1> & typeof listAttachments$1>;
|
|
899
|
+
declare const deleteAttachment: MaybeContext$5<BuildRESTFunction$5<typeof deleteAttachment$1> & typeof deleteAttachment$1>;
|
|
900
|
+
declare const getAttachment: MaybeContext$5<BuildRESTFunction$5<typeof getAttachment$1> & typeof getAttachment$1>;
|
|
467
901
|
|
|
468
902
|
type _publicOnAttachmentCreatedType = typeof onAttachmentCreated$1;
|
|
469
903
|
/**
|
|
@@ -524,11 +958,54 @@ declare namespace index_d$5 {
|
|
|
524
958
|
export { type ActionEvent$4 as ActionEvent, type index_d$5_AttachmentCreatedEnvelope as AttachmentCreatedEnvelope, type index_d$5_AttachmentDeletedEnvelope as AttachmentDeletedEnvelope, type index_d$5_AttachmentMedia as AttachmentMedia, type index_d$5_AttachmentMediaMediaOneOf as AttachmentMediaMediaOneOf, type index_d$5_AttachmentMetadata as AttachmentMetadata, type index_d$5_AttachmentSource as AttachmentSource, index_d$5_AttachmentType as AttachmentType, type BaseEventMetadata$4 as BaseEventMetadata, type index_d$5_ContactAttachment as ContactAttachment, type index_d$5_ContactAttachmentMediaOneOf as ContactAttachmentMediaOneOf, type index_d$5_ContactAttachmentNonNullableFields as ContactAttachmentNonNullableFields, type index_d$5_CreateDemoAttachmentRequest as CreateDemoAttachmentRequest, type index_d$5_CreateDemoAttachmentResponse as CreateDemoAttachmentResponse, type index_d$5_CrmAttachment as CrmAttachment, index_d$5_CrmAttachmentAttachmentType as CrmAttachmentAttachmentType, type index_d$5_CrmAttachmentUploadedEvent as CrmAttachmentUploadedEvent, type index_d$5_DeleteAttachmentIdentifiers as DeleteAttachmentIdentifiers, type index_d$5_DeleteAttachmentRequest as DeleteAttachmentRequest, type index_d$5_DeleteAttachmentResponse as DeleteAttachmentResponse, index_d$5_DemoContactType as DemoContactType, type DomainEvent$4 as DomainEvent, type DomainEventBodyOneOf$4 as DomainEventBodyOneOf, type Empty$1 as Empty, type EntityCreatedEvent$4 as EntityCreatedEvent, type EntityDeletedEvent$4 as EntityDeletedEvent, type EntityUpdatedEvent$4 as EntityUpdatedEvent, type EventMetadata$4 as EventMetadata, type index_d$5_GenerateAttachmentUploadUrlOptions as GenerateAttachmentUploadUrlOptions, type index_d$5_GenerateAttachmentUploadUrlRequest as GenerateAttachmentUploadUrlRequest, type index_d$5_GenerateAttachmentUploadUrlResponse as GenerateAttachmentUploadUrlResponse, type index_d$5_GenerateAttachmentUploadUrlResponseNonNullableFields as GenerateAttachmentUploadUrlResponseNonNullableFields, type index_d$5_GetAttachmentIdentifiers as GetAttachmentIdentifiers, type index_d$5_GetAttachmentRequest as GetAttachmentRequest, type index_d$5_GetAttachmentResponse as GetAttachmentResponse, type index_d$5_GetAttachmentResponseNonNullableFields as GetAttachmentResponseNonNullableFields, type IdentificationData$5 as IdentificationData, type IdentificationDataIdOneOf$5 as IdentificationDataIdOneOf, type index_d$5_ListAttachmentsOptions as ListAttachmentsOptions, type index_d$5_ListAttachmentsRequest as ListAttachmentsRequest, type index_d$5_ListAttachmentsResponse as ListAttachmentsResponse, type index_d$5_ListAttachmentsResponseNonNullableFields as ListAttachmentsResponseNonNullableFields, type index_d$5_MediaFileUploadedEvent as MediaFileUploadedEvent, type MessageEnvelope$5 as MessageEnvelope, type Paging$4 as Paging, type PagingMetadata$3 as PagingMetadata, WebhookIdentityType$5 as WebhookIdentityType, type index_d$5__publicOnAttachmentCreatedType as _publicOnAttachmentCreatedType, type index_d$5__publicOnAttachmentDeletedType as _publicOnAttachmentDeletedType, index_d$5_deleteAttachment as deleteAttachment, index_d$5_generateAttachmentUploadUrl as generateAttachmentUploadUrl, index_d$5_getAttachment as getAttachment, index_d$5_listAttachments as listAttachments, index_d$5_onAttachmentCreated as onAttachmentCreated, index_d$5_onAttachmentDeleted as onAttachmentDeleted, onAttachmentCreated$1 as publicOnAttachmentCreated, onAttachmentDeleted$1 as publicOnAttachmentDeleted };
|
|
525
959
|
}
|
|
526
960
|
|
|
961
|
+
type HostModule$4<T, H extends Host$4> = {
|
|
962
|
+
__type: 'host';
|
|
963
|
+
create(host: H): T;
|
|
964
|
+
};
|
|
965
|
+
type HostModuleAPI$4<T extends HostModule$4<any, any>> = T extends HostModule$4<infer U, any> ? U : never;
|
|
966
|
+
type Host$4<Environment = unknown> = {
|
|
967
|
+
channel: {
|
|
968
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
969
|
+
disconnect: () => void;
|
|
970
|
+
} | Promise<{
|
|
971
|
+
disconnect: () => void;
|
|
972
|
+
}>;
|
|
973
|
+
};
|
|
974
|
+
environment?: Environment;
|
|
975
|
+
/**
|
|
976
|
+
* Optional name of the environment, use for logging
|
|
977
|
+
*/
|
|
978
|
+
name?: string;
|
|
979
|
+
/**
|
|
980
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
981
|
+
*/
|
|
982
|
+
apiBaseUrl?: string;
|
|
983
|
+
/**
|
|
984
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
985
|
+
* like internationalization, billing, etc.
|
|
986
|
+
*/
|
|
987
|
+
essentials?: {
|
|
988
|
+
/**
|
|
989
|
+
* The language of the currently viewed session
|
|
990
|
+
*/
|
|
991
|
+
language?: string;
|
|
992
|
+
/**
|
|
993
|
+
* The locale of the currently viewed session
|
|
994
|
+
*/
|
|
995
|
+
locale?: string;
|
|
996
|
+
/**
|
|
997
|
+
* Any headers that should be passed through to the API requests
|
|
998
|
+
*/
|
|
999
|
+
passThroughHeaders?: Record<string, string>;
|
|
1000
|
+
};
|
|
1001
|
+
};
|
|
1002
|
+
|
|
527
1003
|
type RESTFunctionDescriptor$4<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$4) => T;
|
|
528
1004
|
interface HttpClient$4 {
|
|
529
1005
|
request<TResponse, TData = any>(req: RequestOptionsFactory$4<TResponse, TData>): Promise<HttpResponse$4<TResponse>>;
|
|
530
1006
|
fetchWithAuth: typeof fetch;
|
|
531
1007
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
1008
|
+
getActiveToken?: () => string | undefined;
|
|
532
1009
|
}
|
|
533
1010
|
type RequestOptionsFactory$4<TResponse = any, TData = any> = (context: any) => RequestOptions$4<TResponse, TData>;
|
|
534
1011
|
type HttpResponse$4<T = any> = {
|
|
@@ -550,16 +1027,65 @@ type APIMetadata$4 = {
|
|
|
550
1027
|
packageName?: string;
|
|
551
1028
|
};
|
|
552
1029
|
type BuildRESTFunction$4<T extends RESTFunctionDescriptor$4> = T extends RESTFunctionDescriptor$4<infer U> ? U : never;
|
|
553
|
-
type EventDefinition$
|
|
1030
|
+
type EventDefinition$4<Payload = unknown, Type extends string = string> = {
|
|
554
1031
|
__type: 'event-definition';
|
|
555
1032
|
type: Type;
|
|
556
1033
|
isDomainEvent?: boolean;
|
|
557
1034
|
transformations?: (envelope: unknown) => Payload;
|
|
558
1035
|
__payload: Payload;
|
|
559
1036
|
};
|
|
560
|
-
declare function EventDefinition$
|
|
561
|
-
type EventHandler$
|
|
562
|
-
type BuildEventDefinition$
|
|
1037
|
+
declare function EventDefinition$4<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$4<Payload, Type>;
|
|
1038
|
+
type EventHandler$4<T extends EventDefinition$4> = (payload: T['__payload']) => void | Promise<void>;
|
|
1039
|
+
type BuildEventDefinition$4<T extends EventDefinition$4<any, string>> = (handler: EventHandler$4<T>) => void;
|
|
1040
|
+
|
|
1041
|
+
type ServicePluginMethodInput$4 = {
|
|
1042
|
+
request: any;
|
|
1043
|
+
metadata: any;
|
|
1044
|
+
};
|
|
1045
|
+
type ServicePluginContract$4 = Record<string, (payload: ServicePluginMethodInput$4) => unknown | Promise<unknown>>;
|
|
1046
|
+
type ServicePluginMethodMetadata$4 = {
|
|
1047
|
+
name: string;
|
|
1048
|
+
primaryHttpMappingPath: string;
|
|
1049
|
+
transformations: {
|
|
1050
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$4;
|
|
1051
|
+
toREST: (...args: unknown[]) => unknown;
|
|
1052
|
+
};
|
|
1053
|
+
};
|
|
1054
|
+
type ServicePluginDefinition$4<Contract extends ServicePluginContract$4> = {
|
|
1055
|
+
__type: 'service-plugin-definition';
|
|
1056
|
+
componentType: string;
|
|
1057
|
+
methods: ServicePluginMethodMetadata$4[];
|
|
1058
|
+
__contract: Contract;
|
|
1059
|
+
};
|
|
1060
|
+
declare function ServicePluginDefinition$4<Contract extends ServicePluginContract$4>(componentType: string, methods: ServicePluginMethodMetadata$4[]): ServicePluginDefinition$4<Contract>;
|
|
1061
|
+
type BuildServicePluginDefinition$4<T extends ServicePluginDefinition$4<any>> = (implementation: T['__contract']) => void;
|
|
1062
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$4 = "wix_spi_error";
|
|
1063
|
+
|
|
1064
|
+
type RequestContext$4 = {
|
|
1065
|
+
isSSR: boolean;
|
|
1066
|
+
host: string;
|
|
1067
|
+
protocol?: string;
|
|
1068
|
+
};
|
|
1069
|
+
type ResponseTransformer$4 = (data: any, headers?: any) => any;
|
|
1070
|
+
/**
|
|
1071
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
1072
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
1073
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
1074
|
+
*/
|
|
1075
|
+
type Method$4 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
1076
|
+
type AmbassadorRequestOptions$4<T = any> = {
|
|
1077
|
+
_?: T;
|
|
1078
|
+
url?: string;
|
|
1079
|
+
method?: Method$4;
|
|
1080
|
+
params?: any;
|
|
1081
|
+
data?: any;
|
|
1082
|
+
transformResponse?: ResponseTransformer$4 | ResponseTransformer$4[];
|
|
1083
|
+
};
|
|
1084
|
+
type AmbassadorFactory$4<Request, Response> = (payload: Request) => ((context: RequestContext$4) => AmbassadorRequestOptions$4<Response>) & {
|
|
1085
|
+
__isAmbassador: boolean;
|
|
1086
|
+
};
|
|
1087
|
+
type AmbassadorFunctionDescriptor$4<Request = any, Response = any> = AmbassadorFactory$4<Request, Response>;
|
|
1088
|
+
type BuildAmbassadorFunction$4<T extends AmbassadorFunctionDescriptor$4> = T extends AmbassadorFunctionDescriptor$4<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
563
1089
|
|
|
564
1090
|
declare global {
|
|
565
1091
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -568,6 +1094,348 @@ declare global {
|
|
|
568
1094
|
}
|
|
569
1095
|
}
|
|
570
1096
|
|
|
1097
|
+
declare const emptyObjectSymbol$4: unique symbol;
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
1101
|
+
|
|
1102
|
+
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)).
|
|
1103
|
+
|
|
1104
|
+
@example
|
|
1105
|
+
```
|
|
1106
|
+
import type {EmptyObject} from 'type-fest';
|
|
1107
|
+
|
|
1108
|
+
// The following illustrates the problem with `{}`.
|
|
1109
|
+
const foo1: {} = {}; // Pass
|
|
1110
|
+
const foo2: {} = []; // Pass
|
|
1111
|
+
const foo3: {} = 42; // Pass
|
|
1112
|
+
const foo4: {} = {a: 1}; // Pass
|
|
1113
|
+
|
|
1114
|
+
// With `EmptyObject` only the first case is valid.
|
|
1115
|
+
const bar1: EmptyObject = {}; // Pass
|
|
1116
|
+
const bar2: EmptyObject = 42; // Fail
|
|
1117
|
+
const bar3: EmptyObject = []; // Fail
|
|
1118
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
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}.
|
|
1122
|
+
|
|
1123
|
+
@category Object
|
|
1124
|
+
*/
|
|
1125
|
+
type EmptyObject$4 = {[emptyObjectSymbol$4]?: never};
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
Returns a boolean for whether the two given types are equal.
|
|
1129
|
+
|
|
1130
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
1131
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
1132
|
+
|
|
1133
|
+
Use-cases:
|
|
1134
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
1135
|
+
|
|
1136
|
+
@example
|
|
1137
|
+
```
|
|
1138
|
+
import type {IsEqual} from 'type-fest';
|
|
1139
|
+
|
|
1140
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
1141
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
1142
|
+
type Includes<Value extends readonly any[], Item> =
|
|
1143
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
1144
|
+
? IsEqual<Value[0], Item> extends true
|
|
1145
|
+
? true
|
|
1146
|
+
: Includes<rest, Item>
|
|
1147
|
+
: false;
|
|
1148
|
+
```
|
|
1149
|
+
|
|
1150
|
+
@category Type Guard
|
|
1151
|
+
@category Utilities
|
|
1152
|
+
*/
|
|
1153
|
+
type IsEqual$4<A, B> =
|
|
1154
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
1155
|
+
(<G>() => G extends B ? 1 : 2)
|
|
1156
|
+
? true
|
|
1157
|
+
: false;
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
Filter out keys from an object.
|
|
1161
|
+
|
|
1162
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
1163
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
1164
|
+
Returns `Key` otherwise.
|
|
1165
|
+
|
|
1166
|
+
@example
|
|
1167
|
+
```
|
|
1168
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
1169
|
+
//=> never
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
@example
|
|
1173
|
+
```
|
|
1174
|
+
type Filtered = Filter<'bar', string>;
|
|
1175
|
+
//=> never
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
@example
|
|
1179
|
+
```
|
|
1180
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
1181
|
+
//=> 'bar'
|
|
1182
|
+
```
|
|
1183
|
+
|
|
1184
|
+
@see {Except}
|
|
1185
|
+
*/
|
|
1186
|
+
type Filter$4<KeyType, ExcludeType> = IsEqual$4<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
1187
|
+
|
|
1188
|
+
type ExceptOptions$4 = {
|
|
1189
|
+
/**
|
|
1190
|
+
Disallow assigning non-specified properties.
|
|
1191
|
+
|
|
1192
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
1193
|
+
|
|
1194
|
+
@default false
|
|
1195
|
+
*/
|
|
1196
|
+
requireExactProps?: boolean;
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
Create a type from an object type without certain keys.
|
|
1201
|
+
|
|
1202
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
1203
|
+
|
|
1204
|
+
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.
|
|
1205
|
+
|
|
1206
|
+
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)).
|
|
1207
|
+
|
|
1208
|
+
@example
|
|
1209
|
+
```
|
|
1210
|
+
import type {Except} from 'type-fest';
|
|
1211
|
+
|
|
1212
|
+
type Foo = {
|
|
1213
|
+
a: number;
|
|
1214
|
+
b: string;
|
|
1215
|
+
};
|
|
1216
|
+
|
|
1217
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
1218
|
+
//=> {b: string}
|
|
1219
|
+
|
|
1220
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
1221
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
1222
|
+
|
|
1223
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
1224
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
1225
|
+
|
|
1226
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
1227
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
1228
|
+
```
|
|
1229
|
+
|
|
1230
|
+
@category Object
|
|
1231
|
+
*/
|
|
1232
|
+
type Except$4<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$4 = {requireExactProps: false}> = {
|
|
1233
|
+
[KeyType in keyof ObjectType as Filter$4<KeyType, KeysType>]: ObjectType[KeyType];
|
|
1234
|
+
} & (Options['requireExactProps'] extends true
|
|
1235
|
+
? Partial<Record<KeysType, never>>
|
|
1236
|
+
: {});
|
|
1237
|
+
|
|
1238
|
+
/**
|
|
1239
|
+
Returns a boolean for whether the given type is `never`.
|
|
1240
|
+
|
|
1241
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
1242
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
1243
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
1244
|
+
|
|
1245
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
1246
|
+
|
|
1247
|
+
@example
|
|
1248
|
+
```
|
|
1249
|
+
import type {IsNever, And} from 'type-fest';
|
|
1250
|
+
|
|
1251
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
1252
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
1253
|
+
And<
|
|
1254
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
1255
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
1256
|
+
>;
|
|
1257
|
+
|
|
1258
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
1259
|
+
AreStringsEqual<I, O> extends true
|
|
1260
|
+
? never
|
|
1261
|
+
: void;
|
|
1262
|
+
|
|
1263
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
1264
|
+
if (input === output) {
|
|
1265
|
+
process.exit(0);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
endIfEqual('abc', 'abc');
|
|
1270
|
+
//=> never
|
|
1271
|
+
|
|
1272
|
+
endIfEqual('abc', '123');
|
|
1273
|
+
//=> void
|
|
1274
|
+
```
|
|
1275
|
+
|
|
1276
|
+
@category Type Guard
|
|
1277
|
+
@category Utilities
|
|
1278
|
+
*/
|
|
1279
|
+
type IsNever$4<T> = [T] extends [never] ? true : false;
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
1283
|
+
|
|
1284
|
+
@see {@link IsNever}
|
|
1285
|
+
|
|
1286
|
+
@example
|
|
1287
|
+
```
|
|
1288
|
+
import type {IfNever} from 'type-fest';
|
|
1289
|
+
|
|
1290
|
+
type ShouldBeTrue = IfNever<never>;
|
|
1291
|
+
//=> true
|
|
1292
|
+
|
|
1293
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
1294
|
+
//=> 'bar'
|
|
1295
|
+
```
|
|
1296
|
+
|
|
1297
|
+
@category Type Guard
|
|
1298
|
+
@category Utilities
|
|
1299
|
+
*/
|
|
1300
|
+
type IfNever$4<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
1301
|
+
IsNever$4<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
1302
|
+
);
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
1306
|
+
|
|
1307
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
1308
|
+
|
|
1309
|
+
@example
|
|
1310
|
+
```
|
|
1311
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1312
|
+
|
|
1313
|
+
interface Example {
|
|
1314
|
+
a: string;
|
|
1315
|
+
b: string | number;
|
|
1316
|
+
c?: string;
|
|
1317
|
+
d: {};
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
1321
|
+
//=> 'a'
|
|
1322
|
+
```
|
|
1323
|
+
|
|
1324
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
1325
|
+
|
|
1326
|
+
@example
|
|
1327
|
+
```
|
|
1328
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
1329
|
+
|
|
1330
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
1331
|
+
//=> 'a' | 'c'
|
|
1332
|
+
```
|
|
1333
|
+
|
|
1334
|
+
@category Object
|
|
1335
|
+
*/
|
|
1336
|
+
type ConditionalKeys$4<Base, Condition> =
|
|
1337
|
+
{
|
|
1338
|
+
// Map through all the keys of the given base type.
|
|
1339
|
+
[Key in keyof Base]-?:
|
|
1340
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
1341
|
+
Base[Key] extends Condition
|
|
1342
|
+
// Retain this key
|
|
1343
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
1344
|
+
? IfNever$4<Base[Key], IfNever$4<Condition, Key, never>, Key>
|
|
1345
|
+
// Discard this key since the condition fails.
|
|
1346
|
+
: never;
|
|
1347
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
1348
|
+
}[keyof Base];
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
1352
|
+
|
|
1353
|
+
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.
|
|
1354
|
+
|
|
1355
|
+
@example
|
|
1356
|
+
```
|
|
1357
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
1358
|
+
|
|
1359
|
+
class Awesome {
|
|
1360
|
+
name: string;
|
|
1361
|
+
successes: number;
|
|
1362
|
+
failures: bigint;
|
|
1363
|
+
|
|
1364
|
+
run() {}
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
1368
|
+
//=> {run: () => void}
|
|
1369
|
+
```
|
|
1370
|
+
|
|
1371
|
+
@example
|
|
1372
|
+
```
|
|
1373
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
1374
|
+
|
|
1375
|
+
interface Example {
|
|
1376
|
+
a: string;
|
|
1377
|
+
b: string | number;
|
|
1378
|
+
c: () => void;
|
|
1379
|
+
d: {};
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
1383
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
1384
|
+
```
|
|
1385
|
+
|
|
1386
|
+
@category Object
|
|
1387
|
+
*/
|
|
1388
|
+
type ConditionalExcept$4<Base, Condition> = Except$4<
|
|
1389
|
+
Base,
|
|
1390
|
+
ConditionalKeys$4<Base, Condition>
|
|
1391
|
+
>;
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
1395
|
+
* can either be a REST module or a host module.
|
|
1396
|
+
* This type is recursive, so it can describe nested modules.
|
|
1397
|
+
*/
|
|
1398
|
+
type Descriptors$4 = RESTFunctionDescriptor$4 | AmbassadorFunctionDescriptor$4 | HostModule$4<any, any> | EventDefinition$4<any> | ServicePluginDefinition$4<any> | {
|
|
1399
|
+
[key: string]: Descriptors$4 | PublicMetadata$4 | any;
|
|
1400
|
+
};
|
|
1401
|
+
/**
|
|
1402
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
1403
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
1404
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
1405
|
+
* do not match the given host (as they will not work with the given host).
|
|
1406
|
+
*/
|
|
1407
|
+
type BuildDescriptors$4<T extends Descriptors$4, H extends Host$4<any> | undefined, Depth extends number = 5> = {
|
|
1408
|
+
done: T;
|
|
1409
|
+
recurse: T extends {
|
|
1410
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$4;
|
|
1411
|
+
} ? never : T extends AmbassadorFunctionDescriptor$4 ? BuildAmbassadorFunction$4<T> : T extends RESTFunctionDescriptor$4 ? BuildRESTFunction$4<T> : T extends EventDefinition$4<any> ? BuildEventDefinition$4<T> : T extends ServicePluginDefinition$4<any> ? BuildServicePluginDefinition$4<T> : T extends HostModule$4<any, any> ? HostModuleAPI$4<T> : ConditionalExcept$4<{
|
|
1412
|
+
[Key in keyof T]: T[Key] extends Descriptors$4 ? BuildDescriptors$4<T[Key], H, [
|
|
1413
|
+
-1,
|
|
1414
|
+
0,
|
|
1415
|
+
1,
|
|
1416
|
+
2,
|
|
1417
|
+
3,
|
|
1418
|
+
4,
|
|
1419
|
+
5
|
|
1420
|
+
][Depth]> : never;
|
|
1421
|
+
}, EmptyObject$4>;
|
|
1422
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
1423
|
+
type PublicMetadata$4 = {
|
|
1424
|
+
PACKAGE_NAME?: string;
|
|
1425
|
+
};
|
|
1426
|
+
|
|
1427
|
+
declare global {
|
|
1428
|
+
interface ContextualClient {
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* A type used to create concerete types from SDK descriptors in
|
|
1433
|
+
* case a contextual client is available.
|
|
1434
|
+
*/
|
|
1435
|
+
type MaybeContext$4<T extends Descriptors$4> = globalThis.ContextualClient extends {
|
|
1436
|
+
host: Host$4;
|
|
1437
|
+
} ? BuildDescriptors$4<T, globalThis.ContextualClient['host']> : T;
|
|
1438
|
+
|
|
571
1439
|
interface Contact {
|
|
572
1440
|
/**
|
|
573
1441
|
* Contact ID.
|
|
@@ -2649,21 +3517,21 @@ interface GetContactSignature {
|
|
|
2649
3517
|
*/
|
|
2650
3518
|
(_id: string, options?: GetContactOptions | undefined): Promise<Contact & ContactNonNullableFields>;
|
|
2651
3519
|
}
|
|
2652
|
-
declare const onContactCreated$1: EventDefinition$
|
|
2653
|
-
declare const onContactUpdated$1: EventDefinition$
|
|
2654
|
-
declare const onContactMerged$1: EventDefinition$
|
|
2655
|
-
declare const onContactDeleted$1: EventDefinition$
|
|
3520
|
+
declare const onContactCreated$1: EventDefinition$4<ContactCreatedEnvelope, "wix.contacts.v4.contact_created">;
|
|
3521
|
+
declare const onContactUpdated$1: EventDefinition$4<ContactUpdatedEnvelope, "wix.contacts.v4.contact_updated">;
|
|
3522
|
+
declare const onContactMerged$1: EventDefinition$4<ContactMergedEnvelope, "wix.contacts.v4.contact_merged">;
|
|
3523
|
+
declare const onContactDeleted$1: EventDefinition$4<ContactDeletedEnvelope, "wix.contacts.v4.contact_deleted">;
|
|
2656
3524
|
|
|
2657
|
-
declare function createEventModule$3<T extends EventDefinition$
|
|
3525
|
+
declare function createEventModule$3<T extends EventDefinition$4<any, string>>(eventDefinition: T): BuildEventDefinition$4<T> & T;
|
|
2658
3526
|
|
|
2659
|
-
declare const createContact: BuildRESTFunction$4<typeof createContact$1> & typeof createContact$1
|
|
2660
|
-
declare const updateContact: BuildRESTFunction$4<typeof updateContact$1> & typeof updateContact$1
|
|
2661
|
-
declare const mergeContacts: BuildRESTFunction$4<typeof mergeContacts$1> & typeof mergeContacts$1
|
|
2662
|
-
declare const deleteContact: BuildRESTFunction$4<typeof deleteContact$1> & typeof deleteContact$1
|
|
2663
|
-
declare const labelContact: BuildRESTFunction$4<typeof labelContact$1> & typeof labelContact$1
|
|
2664
|
-
declare const unlabelContact: BuildRESTFunction$4<typeof unlabelContact$1> & typeof unlabelContact$1
|
|
2665
|
-
declare const queryContacts: BuildRESTFunction$4<typeof queryContacts$1> & typeof queryContacts$1
|
|
2666
|
-
declare const getContact: BuildRESTFunction$4<typeof getContact$1> & typeof getContact$1
|
|
3527
|
+
declare const createContact: MaybeContext$4<BuildRESTFunction$4<typeof createContact$1> & typeof createContact$1>;
|
|
3528
|
+
declare const updateContact: MaybeContext$4<BuildRESTFunction$4<typeof updateContact$1> & typeof updateContact$1>;
|
|
3529
|
+
declare const mergeContacts: MaybeContext$4<BuildRESTFunction$4<typeof mergeContacts$1> & typeof mergeContacts$1>;
|
|
3530
|
+
declare const deleteContact: MaybeContext$4<BuildRESTFunction$4<typeof deleteContact$1> & typeof deleteContact$1>;
|
|
3531
|
+
declare const labelContact: MaybeContext$4<BuildRESTFunction$4<typeof labelContact$1> & typeof labelContact$1>;
|
|
3532
|
+
declare const unlabelContact: MaybeContext$4<BuildRESTFunction$4<typeof unlabelContact$1> & typeof unlabelContact$1>;
|
|
3533
|
+
declare const queryContacts: MaybeContext$4<BuildRESTFunction$4<typeof queryContacts$1> & typeof queryContacts$1>;
|
|
3534
|
+
declare const getContact: MaybeContext$4<BuildRESTFunction$4<typeof getContact$1> & typeof getContact$1>;
|
|
2667
3535
|
|
|
2668
3536
|
type _publicOnContactCreatedType = typeof onContactCreated$1;
|
|
2669
3537
|
/**
|
|
@@ -2850,11 +3718,54 @@ declare namespace index_d$4 {
|
|
|
2850
3718
|
export { index_d$4_Action as Action, type ActionEvent$3 as ActionEvent, type ActivityIcon$1 as ActivityIcon, type Address$1 as Address, type AddressLocation$1 as AddressLocation, type AddressStreetOneOf$1 as AddressStreetOneOf, AddressTag$1 as AddressTag, type index_d$4_ApplicationError as ApplicationError, type AssigneesWrapper$1 as AssigneesWrapper, type BaseEventMetadata$3 as BaseEventMetadata, type index_d$4_BulkActionMetadata as BulkActionMetadata, type index_d$4_BulkAddSegmentToContactsRequest as BulkAddSegmentToContactsRequest, type index_d$4_BulkAddSegmentToContactsResponse as BulkAddSegmentToContactsResponse, type index_d$4_BulkDeleteContactsRequest as BulkDeleteContactsRequest, type index_d$4_BulkDeleteContactsResponse as BulkDeleteContactsResponse, type index_d$4_BulkLabelAndUnlabelContactsRequest as BulkLabelAndUnlabelContactsRequest, type index_d$4_BulkLabelAndUnlabelContactsResponse as BulkLabelAndUnlabelContactsResponse, type index_d$4_BulkRemoveSegmentFromContactsRequest as BulkRemoveSegmentFromContactsRequest, type index_d$4_BulkRemoveSegmentFromContactsResponse as BulkRemoveSegmentFromContactsResponse, type index_d$4_BulkUpdateContactsRequest as BulkUpdateContactsRequest, type index_d$4_BulkUpdateContactsResponse as BulkUpdateContactsResponse, type index_d$4_BulkUpsertContactsRequest as BulkUpsertContactsRequest, type index_d$4_BulkUpsertContactsResponse as BulkUpsertContactsResponse, type index_d$4_BulkUpsertContactsResponseMetadata as BulkUpsertContactsResponseMetadata, type index_d$4_Contact as Contact, type ContactActivity$1 as ContactActivity, ContactActivityType$1 as ContactActivityType, type index_d$4_ContactAddedToSegment as ContactAddedToSegment, type ContactAddress$1 as ContactAddress, type ContactAddressesWrapper$1 as ContactAddressesWrapper, type index_d$4_ContactChanged as ContactChanged, type index_d$4_ContactCreatedEnvelope as ContactCreatedEnvelope, type index_d$4_ContactDeletedEnvelope as ContactDeletedEnvelope, type ContactEmail$1 as ContactEmail, type index_d$4_ContactEmailSubscriptionUpdated as ContactEmailSubscriptionUpdated, type ContactEmailsWrapper$1 as ContactEmailsWrapper, index_d$4_ContactFieldSet as ContactFieldSet, type ContactInfo$2 as ContactInfo, type index_d$4_ContactMerged as ContactMerged, type index_d$4_ContactMergedEnvelope as ContactMergedEnvelope, type ContactName$1 as ContactName, type index_d$4_ContactNonNullableFields as ContactNonNullableFields, type ContactPhone$1 as ContactPhone, type index_d$4_ContactPhoneSubscriptionUpdated as ContactPhoneSubscriptionUpdated, type ContactPhonesWrapper$1 as ContactPhonesWrapper, type ContactPicture$1 as ContactPicture, type index_d$4_ContactPrimaryInfoUpdated as ContactPrimaryInfoUpdated, type index_d$4_ContactRemovedFromSegment as ContactRemovedFromSegment, type index_d$4_ContactSource as ContactSource, ContactSourceType$1 as ContactSourceType, type index_d$4_ContactSubmitted as ContactSubmitted, type index_d$4_ContactUpdatedEnvelope as ContactUpdatedEnvelope, type index_d$4_ContactsFacet as ContactsFacet, index_d$4_ContactsFacetType as ContactsFacetType, type index_d$4_ContactsQueryBuilder as ContactsQueryBuilder, type index_d$4_ContactsQueryResult as ContactsQueryResult, type index_d$4_CountContactsRequest as CountContactsRequest, type index_d$4_CountContactsResponse as CountContactsResponse, type index_d$4_CreateContactOptions as CreateContactOptions, type index_d$4_CreateContactRequest as CreateContactRequest, type index_d$4_CreateContactResponse as CreateContactResponse, type index_d$4_CreateContactResponseNonNullableFields as CreateContactResponseNonNullableFields, type CursorPaging$1 as CursorPaging, type CursorPagingMetadata$1 as CursorPagingMetadata, type Cursors$1 as Cursors, type index_d$4_DeleteContactRequest as DeleteContactRequest, type index_d$4_DeleteContactResponse as DeleteContactResponse, type DomainEvent$3 as DomainEvent, type DomainEventBodyOneOf$3 as DomainEventBodyOneOf, type index_d$4_DuplicateContactExists as DuplicateContactExists, index_d$4_EmailDeliverabilityStatus as EmailDeliverabilityStatus, EmailTag$1 as EmailTag, type EntityCreatedEvent$3 as EntityCreatedEvent, type EntityDeletedEvent$3 as EntityDeletedEvent, type EntityUpdatedEvent$3 as EntityUpdatedEvent, type index_d$4_Error as Error, type EventMetadata$3 as EventMetadata, type ExtendedFieldsWrapper$1 as ExtendedFieldsWrapper, type index_d$4_GeneratePictureUploadUrlRequest as GeneratePictureUploadUrlRequest, type index_d$4_GeneratePictureUploadUrlResponse as GeneratePictureUploadUrlResponse, type index_d$4_GetContactOptions as GetContactOptions, type index_d$4_GetContactRequest as GetContactRequest, type index_d$4_GetContactResponse as GetContactResponse, type index_d$4_GetContactResponseNonNullableFields as GetContactResponseNonNullableFields, index_d$4_GetContactResponseType as GetContactResponseType, type index_d$4_GroupInfo as GroupInfo, type IdentificationData$4 as IdentificationData, type IdentificationDataIdOneOf$4 as IdentificationDataIdOneOf, ImageProvider$1 as ImageProvider, type index_d$4_Item as Item, type index_d$4_ItemMetadata as ItemMetadata, type index_d$4_LabelAndUnlabelContactRequest as LabelAndUnlabelContactRequest, type index_d$4_LabelAndUnlabelContactResponse as LabelAndUnlabelContactResponse, type index_d$4_LabelContactRequest as LabelContactRequest, type index_d$4_LabelContactResponse as LabelContactResponse, type index_d$4_LabelContactResponseNonNullableFields as LabelContactResponseNonNullableFields, type LabelsWrapper$1 as LabelsWrapper, type index_d$4_LastActivityUpdate as LastActivityUpdate, type index_d$4_ListContactIdsBySegmentRequest as ListContactIdsBySegmentRequest, type index_d$4_ListContactIdsBySegmentResponse as ListContactIdsBySegmentResponse, type index_d$4_ListContactsRequest as ListContactsRequest, type index_d$4_ListContactsResponse as ListContactsResponse, type index_d$4_ListFacetsRequest as ListFacetsRequest, type index_d$4_ListFacetsResponse as ListFacetsResponse, type LocationsWrapper$1 as LocationsWrapper, type index_d$4_MemberInfo as MemberInfo, index_d$4_MemberStatus as MemberStatus, type index_d$4_MergeContactsOptions as MergeContactsOptions, type index_d$4_MergeContactsRequest as MergeContactsRequest, type index_d$4_MergeContactsResponse as MergeContactsResponse, type index_d$4_MergeContactsResponseNonNullableFields as MergeContactsResponseNonNullableFields, type MessageEnvelope$4 as MessageEnvelope, type index_d$4_Metadata as Metadata, index_d$4_Mode as Mode, type Paging$3 as Paging, type PagingMetadata$2 as PagingMetadata, index_d$4_PhoneDeliverabilityStatus as PhoneDeliverabilityStatus, PhoneTag$1 as PhoneTag, type index_d$4_PreviewMergeContactsRequest as PreviewMergeContactsRequest, type index_d$4_PreviewMergeContactsResponse as PreviewMergeContactsResponse, type index_d$4_PrimaryContactInfo as PrimaryContactInfo, type index_d$4_PrimaryEmail as PrimaryEmail, type index_d$4_PrimaryPhone as PrimaryPhone, type index_d$4_PrimarySubscriptionStatus as PrimarySubscriptionStatus, index_d$4_PrivacyStatus as PrivacyStatus, type index_d$4_ProfileInfo as ProfileInfo, type Query$2 as Query, type index_d$4_QueryContactsOptions as QueryContactsOptions, type index_d$4_QueryContactsRequest as QueryContactsRequest, type index_d$4_QueryContactsResponse as QueryContactsResponse, type index_d$4_QueryContactsResponseNonNullableFields as QueryContactsResponseNonNullableFields, type index_d$4_QueryFacetsRequest as QueryFacetsRequest, type index_d$4_QueryFacetsResponse as QueryFacetsResponse, type RestoreInfo$2 as RestoreInfo, index_d$4_Role as Role, type index_d$4_Search as Search, type index_d$4_SearchContactsRequest as SearchContactsRequest, type index_d$4_SearchContactsResponse as SearchContactsResponse, type index_d$4_SearchDetails as SearchDetails, type index_d$4_SearchPagingMethodOneOf as SearchPagingMethodOneOf, type index_d$4_SegmentsWrapper as SegmentsWrapper, type index_d$4_SessionInfo as SessionInfo, SortOrder$3 as SortOrder, type Sorting$3 as Sorting, type StreetAddress$1 as StreetAddress, type Subdivision$1 as Subdivision, SubdivisionType$1 as SubdivisionType, SubmitOperation$1 as SubmitOperation, index_d$4_SubscriptionStatus as SubscriptionStatus, type index_d$4_SyncSubmitContactRequest as SyncSubmitContactRequest, type index_d$4_SyncSubmitContactResponse as SyncSubmitContactResponse, type index_d$4_UnlabelContactRequest as UnlabelContactRequest, type index_d$4_UnlabelContactResponse as UnlabelContactResponse, type index_d$4_UnlabelContactResponseNonNullableFields as UnlabelContactResponseNonNullableFields, type index_d$4_UpdateContactOptions as UpdateContactOptions, type index_d$4_UpdateContactRequest as UpdateContactRequest, type index_d$4_UpdateContactResponse as UpdateContactResponse, type index_d$4_UpdateContactResponseNonNullableFields as UpdateContactResponseNonNullableFields, type index_d$4_UpsertContactRequest as UpsertContactRequest, type index_d$4_UpsertContactResponse as UpsertContactResponse, index_d$4_UpsertContactResponseAction as UpsertContactResponseAction, type index_d$4_UserInfo as UserInfo, WebhookIdentityType$4 as WebhookIdentityType, type index_d$4__publicOnContactCreatedType as _publicOnContactCreatedType, type index_d$4__publicOnContactDeletedType as _publicOnContactDeletedType, type index_d$4__publicOnContactMergedType as _publicOnContactMergedType, type index_d$4__publicOnContactUpdatedType as _publicOnContactUpdatedType, index_d$4_createContact as createContact, index_d$4_deleteContact as deleteContact, index_d$4_getContact as getContact, index_d$4_labelContact as labelContact, index_d$4_mergeContacts as mergeContacts, index_d$4_onContactCreated as onContactCreated, index_d$4_onContactDeleted as onContactDeleted, index_d$4_onContactMerged as onContactMerged, index_d$4_onContactUpdated as onContactUpdated, onContactCreated$1 as publicOnContactCreated, onContactDeleted$1 as publicOnContactDeleted, onContactMerged$1 as publicOnContactMerged, onContactUpdated$1 as publicOnContactUpdated, index_d$4_queryContacts as queryContacts, index_d$4_unlabelContact as unlabelContact, index_d$4_updateContact as updateContact };
|
|
2851
3719
|
}
|
|
2852
3720
|
|
|
3721
|
+
type HostModule$3<T, H extends Host$3> = {
|
|
3722
|
+
__type: 'host';
|
|
3723
|
+
create(host: H): T;
|
|
3724
|
+
};
|
|
3725
|
+
type HostModuleAPI$3<T extends HostModule$3<any, any>> = T extends HostModule$3<infer U, any> ? U : never;
|
|
3726
|
+
type Host$3<Environment = unknown> = {
|
|
3727
|
+
channel: {
|
|
3728
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
3729
|
+
disconnect: () => void;
|
|
3730
|
+
} | Promise<{
|
|
3731
|
+
disconnect: () => void;
|
|
3732
|
+
}>;
|
|
3733
|
+
};
|
|
3734
|
+
environment?: Environment;
|
|
3735
|
+
/**
|
|
3736
|
+
* Optional name of the environment, use for logging
|
|
3737
|
+
*/
|
|
3738
|
+
name?: string;
|
|
3739
|
+
/**
|
|
3740
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
3741
|
+
*/
|
|
3742
|
+
apiBaseUrl?: string;
|
|
3743
|
+
/**
|
|
3744
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
3745
|
+
* like internationalization, billing, etc.
|
|
3746
|
+
*/
|
|
3747
|
+
essentials?: {
|
|
3748
|
+
/**
|
|
3749
|
+
* The language of the currently viewed session
|
|
3750
|
+
*/
|
|
3751
|
+
language?: string;
|
|
3752
|
+
/**
|
|
3753
|
+
* The locale of the currently viewed session
|
|
3754
|
+
*/
|
|
3755
|
+
locale?: string;
|
|
3756
|
+
/**
|
|
3757
|
+
* Any headers that should be passed through to the API requests
|
|
3758
|
+
*/
|
|
3759
|
+
passThroughHeaders?: Record<string, string>;
|
|
3760
|
+
};
|
|
3761
|
+
};
|
|
3762
|
+
|
|
2853
3763
|
type RESTFunctionDescriptor$3<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$3) => T;
|
|
2854
3764
|
interface HttpClient$3 {
|
|
2855
3765
|
request<TResponse, TData = any>(req: RequestOptionsFactory$3<TResponse, TData>): Promise<HttpResponse$3<TResponse>>;
|
|
2856
3766
|
fetchWithAuth: typeof fetch;
|
|
2857
3767
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
3768
|
+
getActiveToken?: () => string | undefined;
|
|
2858
3769
|
}
|
|
2859
3770
|
type RequestOptionsFactory$3<TResponse = any, TData = any> = (context: any) => RequestOptions$3<TResponse, TData>;
|
|
2860
3771
|
type HttpResponse$3<T = any> = {
|
|
@@ -2876,24 +3787,415 @@ type APIMetadata$3 = {
|
|
|
2876
3787
|
packageName?: string;
|
|
2877
3788
|
};
|
|
2878
3789
|
type BuildRESTFunction$3<T extends RESTFunctionDescriptor$3> = T extends RESTFunctionDescriptor$3<infer U> ? U : never;
|
|
2879
|
-
type EventDefinition$
|
|
3790
|
+
type EventDefinition$3<Payload = unknown, Type extends string = string> = {
|
|
2880
3791
|
__type: 'event-definition';
|
|
2881
3792
|
type: Type;
|
|
2882
3793
|
isDomainEvent?: boolean;
|
|
2883
3794
|
transformations?: (envelope: unknown) => Payload;
|
|
2884
3795
|
__payload: Payload;
|
|
2885
3796
|
};
|
|
2886
|
-
declare function EventDefinition$
|
|
2887
|
-
type EventHandler$
|
|
2888
|
-
type BuildEventDefinition$
|
|
3797
|
+
declare function EventDefinition$3<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$3<Payload, Type>;
|
|
3798
|
+
type EventHandler$3<T extends EventDefinition$3> = (payload: T['__payload']) => void | Promise<void>;
|
|
3799
|
+
type BuildEventDefinition$3<T extends EventDefinition$3<any, string>> = (handler: EventHandler$3<T>) => void;
|
|
2889
3800
|
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
3801
|
+
type ServicePluginMethodInput$3 = {
|
|
3802
|
+
request: any;
|
|
3803
|
+
metadata: any;
|
|
3804
|
+
};
|
|
3805
|
+
type ServicePluginContract$3 = Record<string, (payload: ServicePluginMethodInput$3) => unknown | Promise<unknown>>;
|
|
3806
|
+
type ServicePluginMethodMetadata$3 = {
|
|
3807
|
+
name: string;
|
|
3808
|
+
primaryHttpMappingPath: string;
|
|
3809
|
+
transformations: {
|
|
3810
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$3;
|
|
3811
|
+
toREST: (...args: unknown[]) => unknown;
|
|
3812
|
+
};
|
|
3813
|
+
};
|
|
3814
|
+
type ServicePluginDefinition$3<Contract extends ServicePluginContract$3> = {
|
|
3815
|
+
__type: 'service-plugin-definition';
|
|
3816
|
+
componentType: string;
|
|
3817
|
+
methods: ServicePluginMethodMetadata$3[];
|
|
3818
|
+
__contract: Contract;
|
|
3819
|
+
};
|
|
3820
|
+
declare function ServicePluginDefinition$3<Contract extends ServicePluginContract$3>(componentType: string, methods: ServicePluginMethodMetadata$3[]): ServicePluginDefinition$3<Contract>;
|
|
3821
|
+
type BuildServicePluginDefinition$3<T extends ServicePluginDefinition$3<any>> = (implementation: T['__contract']) => void;
|
|
3822
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$3 = "wix_spi_error";
|
|
3823
|
+
|
|
3824
|
+
type RequestContext$3 = {
|
|
3825
|
+
isSSR: boolean;
|
|
3826
|
+
host: string;
|
|
3827
|
+
protocol?: string;
|
|
3828
|
+
};
|
|
3829
|
+
type ResponseTransformer$3 = (data: any, headers?: any) => any;
|
|
3830
|
+
/**
|
|
3831
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
3832
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
3833
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
3834
|
+
*/
|
|
3835
|
+
type Method$3 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
3836
|
+
type AmbassadorRequestOptions$3<T = any> = {
|
|
3837
|
+
_?: T;
|
|
3838
|
+
url?: string;
|
|
3839
|
+
method?: Method$3;
|
|
3840
|
+
params?: any;
|
|
3841
|
+
data?: any;
|
|
3842
|
+
transformResponse?: ResponseTransformer$3 | ResponseTransformer$3[];
|
|
3843
|
+
};
|
|
3844
|
+
type AmbassadorFactory$3<Request, Response> = (payload: Request) => ((context: RequestContext$3) => AmbassadorRequestOptions$3<Response>) & {
|
|
3845
|
+
__isAmbassador: boolean;
|
|
3846
|
+
};
|
|
3847
|
+
type AmbassadorFunctionDescriptor$3<Request = any, Response = any> = AmbassadorFactory$3<Request, Response>;
|
|
3848
|
+
type BuildAmbassadorFunction$3<T extends AmbassadorFunctionDescriptor$3> = T extends AmbassadorFunctionDescriptor$3<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
3849
|
+
|
|
3850
|
+
declare global {
|
|
3851
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
3852
|
+
interface SymbolConstructor {
|
|
3853
|
+
readonly observable: symbol;
|
|
2894
3854
|
}
|
|
2895
3855
|
}
|
|
2896
3856
|
|
|
3857
|
+
declare const emptyObjectSymbol$3: unique symbol;
|
|
3858
|
+
|
|
3859
|
+
/**
|
|
3860
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
3861
|
+
|
|
3862
|
+
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)).
|
|
3863
|
+
|
|
3864
|
+
@example
|
|
3865
|
+
```
|
|
3866
|
+
import type {EmptyObject} from 'type-fest';
|
|
3867
|
+
|
|
3868
|
+
// The following illustrates the problem with `{}`.
|
|
3869
|
+
const foo1: {} = {}; // Pass
|
|
3870
|
+
const foo2: {} = []; // Pass
|
|
3871
|
+
const foo3: {} = 42; // Pass
|
|
3872
|
+
const foo4: {} = {a: 1}; // Pass
|
|
3873
|
+
|
|
3874
|
+
// With `EmptyObject` only the first case is valid.
|
|
3875
|
+
const bar1: EmptyObject = {}; // Pass
|
|
3876
|
+
const bar2: EmptyObject = 42; // Fail
|
|
3877
|
+
const bar3: EmptyObject = []; // Fail
|
|
3878
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
3879
|
+
```
|
|
3880
|
+
|
|
3881
|
+
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}.
|
|
3882
|
+
|
|
3883
|
+
@category Object
|
|
3884
|
+
*/
|
|
3885
|
+
type EmptyObject$3 = {[emptyObjectSymbol$3]?: never};
|
|
3886
|
+
|
|
3887
|
+
/**
|
|
3888
|
+
Returns a boolean for whether the two given types are equal.
|
|
3889
|
+
|
|
3890
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
3891
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
3892
|
+
|
|
3893
|
+
Use-cases:
|
|
3894
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
3895
|
+
|
|
3896
|
+
@example
|
|
3897
|
+
```
|
|
3898
|
+
import type {IsEqual} from 'type-fest';
|
|
3899
|
+
|
|
3900
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
3901
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
3902
|
+
type Includes<Value extends readonly any[], Item> =
|
|
3903
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
3904
|
+
? IsEqual<Value[0], Item> extends true
|
|
3905
|
+
? true
|
|
3906
|
+
: Includes<rest, Item>
|
|
3907
|
+
: false;
|
|
3908
|
+
```
|
|
3909
|
+
|
|
3910
|
+
@category Type Guard
|
|
3911
|
+
@category Utilities
|
|
3912
|
+
*/
|
|
3913
|
+
type IsEqual$3<A, B> =
|
|
3914
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
3915
|
+
(<G>() => G extends B ? 1 : 2)
|
|
3916
|
+
? true
|
|
3917
|
+
: false;
|
|
3918
|
+
|
|
3919
|
+
/**
|
|
3920
|
+
Filter out keys from an object.
|
|
3921
|
+
|
|
3922
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
3923
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
3924
|
+
Returns `Key` otherwise.
|
|
3925
|
+
|
|
3926
|
+
@example
|
|
3927
|
+
```
|
|
3928
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
3929
|
+
//=> never
|
|
3930
|
+
```
|
|
3931
|
+
|
|
3932
|
+
@example
|
|
3933
|
+
```
|
|
3934
|
+
type Filtered = Filter<'bar', string>;
|
|
3935
|
+
//=> never
|
|
3936
|
+
```
|
|
3937
|
+
|
|
3938
|
+
@example
|
|
3939
|
+
```
|
|
3940
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
3941
|
+
//=> 'bar'
|
|
3942
|
+
```
|
|
3943
|
+
|
|
3944
|
+
@see {Except}
|
|
3945
|
+
*/
|
|
3946
|
+
type Filter$3<KeyType, ExcludeType> = IsEqual$3<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
3947
|
+
|
|
3948
|
+
type ExceptOptions$3 = {
|
|
3949
|
+
/**
|
|
3950
|
+
Disallow assigning non-specified properties.
|
|
3951
|
+
|
|
3952
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
3953
|
+
|
|
3954
|
+
@default false
|
|
3955
|
+
*/
|
|
3956
|
+
requireExactProps?: boolean;
|
|
3957
|
+
};
|
|
3958
|
+
|
|
3959
|
+
/**
|
|
3960
|
+
Create a type from an object type without certain keys.
|
|
3961
|
+
|
|
3962
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
3963
|
+
|
|
3964
|
+
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.
|
|
3965
|
+
|
|
3966
|
+
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)).
|
|
3967
|
+
|
|
3968
|
+
@example
|
|
3969
|
+
```
|
|
3970
|
+
import type {Except} from 'type-fest';
|
|
3971
|
+
|
|
3972
|
+
type Foo = {
|
|
3973
|
+
a: number;
|
|
3974
|
+
b: string;
|
|
3975
|
+
};
|
|
3976
|
+
|
|
3977
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
3978
|
+
//=> {b: string}
|
|
3979
|
+
|
|
3980
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
3981
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
3982
|
+
|
|
3983
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
3984
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
3985
|
+
|
|
3986
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
3987
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
3988
|
+
```
|
|
3989
|
+
|
|
3990
|
+
@category Object
|
|
3991
|
+
*/
|
|
3992
|
+
type Except$3<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$3 = {requireExactProps: false}> = {
|
|
3993
|
+
[KeyType in keyof ObjectType as Filter$3<KeyType, KeysType>]: ObjectType[KeyType];
|
|
3994
|
+
} & (Options['requireExactProps'] extends true
|
|
3995
|
+
? Partial<Record<KeysType, never>>
|
|
3996
|
+
: {});
|
|
3997
|
+
|
|
3998
|
+
/**
|
|
3999
|
+
Returns a boolean for whether the given type is `never`.
|
|
4000
|
+
|
|
4001
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
4002
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
4003
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
4004
|
+
|
|
4005
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
4006
|
+
|
|
4007
|
+
@example
|
|
4008
|
+
```
|
|
4009
|
+
import type {IsNever, And} from 'type-fest';
|
|
4010
|
+
|
|
4011
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
4012
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
4013
|
+
And<
|
|
4014
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
4015
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
4016
|
+
>;
|
|
4017
|
+
|
|
4018
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
4019
|
+
AreStringsEqual<I, O> extends true
|
|
4020
|
+
? never
|
|
4021
|
+
: void;
|
|
4022
|
+
|
|
4023
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
4024
|
+
if (input === output) {
|
|
4025
|
+
process.exit(0);
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
|
|
4029
|
+
endIfEqual('abc', 'abc');
|
|
4030
|
+
//=> never
|
|
4031
|
+
|
|
4032
|
+
endIfEqual('abc', '123');
|
|
4033
|
+
//=> void
|
|
4034
|
+
```
|
|
4035
|
+
|
|
4036
|
+
@category Type Guard
|
|
4037
|
+
@category Utilities
|
|
4038
|
+
*/
|
|
4039
|
+
type IsNever$3<T> = [T] extends [never] ? true : false;
|
|
4040
|
+
|
|
4041
|
+
/**
|
|
4042
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
4043
|
+
|
|
4044
|
+
@see {@link IsNever}
|
|
4045
|
+
|
|
4046
|
+
@example
|
|
4047
|
+
```
|
|
4048
|
+
import type {IfNever} from 'type-fest';
|
|
4049
|
+
|
|
4050
|
+
type ShouldBeTrue = IfNever<never>;
|
|
4051
|
+
//=> true
|
|
4052
|
+
|
|
4053
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
4054
|
+
//=> 'bar'
|
|
4055
|
+
```
|
|
4056
|
+
|
|
4057
|
+
@category Type Guard
|
|
4058
|
+
@category Utilities
|
|
4059
|
+
*/
|
|
4060
|
+
type IfNever$3<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
4061
|
+
IsNever$3<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
4062
|
+
);
|
|
4063
|
+
|
|
4064
|
+
/**
|
|
4065
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
4066
|
+
|
|
4067
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
4068
|
+
|
|
4069
|
+
@example
|
|
4070
|
+
```
|
|
4071
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
4072
|
+
|
|
4073
|
+
interface Example {
|
|
4074
|
+
a: string;
|
|
4075
|
+
b: string | number;
|
|
4076
|
+
c?: string;
|
|
4077
|
+
d: {};
|
|
4078
|
+
}
|
|
4079
|
+
|
|
4080
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
4081
|
+
//=> 'a'
|
|
4082
|
+
```
|
|
4083
|
+
|
|
4084
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
4085
|
+
|
|
4086
|
+
@example
|
|
4087
|
+
```
|
|
4088
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
4089
|
+
|
|
4090
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
4091
|
+
//=> 'a' | 'c'
|
|
4092
|
+
```
|
|
4093
|
+
|
|
4094
|
+
@category Object
|
|
4095
|
+
*/
|
|
4096
|
+
type ConditionalKeys$3<Base, Condition> =
|
|
4097
|
+
{
|
|
4098
|
+
// Map through all the keys of the given base type.
|
|
4099
|
+
[Key in keyof Base]-?:
|
|
4100
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
4101
|
+
Base[Key] extends Condition
|
|
4102
|
+
// Retain this key
|
|
4103
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
4104
|
+
? IfNever$3<Base[Key], IfNever$3<Condition, Key, never>, Key>
|
|
4105
|
+
// Discard this key since the condition fails.
|
|
4106
|
+
: never;
|
|
4107
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
4108
|
+
}[keyof Base];
|
|
4109
|
+
|
|
4110
|
+
/**
|
|
4111
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
4112
|
+
|
|
4113
|
+
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.
|
|
4114
|
+
|
|
4115
|
+
@example
|
|
4116
|
+
```
|
|
4117
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
4118
|
+
|
|
4119
|
+
class Awesome {
|
|
4120
|
+
name: string;
|
|
4121
|
+
successes: number;
|
|
4122
|
+
failures: bigint;
|
|
4123
|
+
|
|
4124
|
+
run() {}
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
4128
|
+
//=> {run: () => void}
|
|
4129
|
+
```
|
|
4130
|
+
|
|
4131
|
+
@example
|
|
4132
|
+
```
|
|
4133
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
4134
|
+
|
|
4135
|
+
interface Example {
|
|
4136
|
+
a: string;
|
|
4137
|
+
b: string | number;
|
|
4138
|
+
c: () => void;
|
|
4139
|
+
d: {};
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
4143
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
4144
|
+
```
|
|
4145
|
+
|
|
4146
|
+
@category Object
|
|
4147
|
+
*/
|
|
4148
|
+
type ConditionalExcept$3<Base, Condition> = Except$3<
|
|
4149
|
+
Base,
|
|
4150
|
+
ConditionalKeys$3<Base, Condition>
|
|
4151
|
+
>;
|
|
4152
|
+
|
|
4153
|
+
/**
|
|
4154
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
4155
|
+
* can either be a REST module or a host module.
|
|
4156
|
+
* This type is recursive, so it can describe nested modules.
|
|
4157
|
+
*/
|
|
4158
|
+
type Descriptors$3 = RESTFunctionDescriptor$3 | AmbassadorFunctionDescriptor$3 | HostModule$3<any, any> | EventDefinition$3<any> | ServicePluginDefinition$3<any> | {
|
|
4159
|
+
[key: string]: Descriptors$3 | PublicMetadata$3 | any;
|
|
4160
|
+
};
|
|
4161
|
+
/**
|
|
4162
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
4163
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
4164
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
4165
|
+
* do not match the given host (as they will not work with the given host).
|
|
4166
|
+
*/
|
|
4167
|
+
type BuildDescriptors$3<T extends Descriptors$3, H extends Host$3<any> | undefined, Depth extends number = 5> = {
|
|
4168
|
+
done: T;
|
|
4169
|
+
recurse: T extends {
|
|
4170
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$3;
|
|
4171
|
+
} ? never : T extends AmbassadorFunctionDescriptor$3 ? BuildAmbassadorFunction$3<T> : T extends RESTFunctionDescriptor$3 ? BuildRESTFunction$3<T> : T extends EventDefinition$3<any> ? BuildEventDefinition$3<T> : T extends ServicePluginDefinition$3<any> ? BuildServicePluginDefinition$3<T> : T extends HostModule$3<any, any> ? HostModuleAPI$3<T> : ConditionalExcept$3<{
|
|
4172
|
+
[Key in keyof T]: T[Key] extends Descriptors$3 ? BuildDescriptors$3<T[Key], H, [
|
|
4173
|
+
-1,
|
|
4174
|
+
0,
|
|
4175
|
+
1,
|
|
4176
|
+
2,
|
|
4177
|
+
3,
|
|
4178
|
+
4,
|
|
4179
|
+
5
|
|
4180
|
+
][Depth]> : never;
|
|
4181
|
+
}, EmptyObject$3>;
|
|
4182
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
4183
|
+
type PublicMetadata$3 = {
|
|
4184
|
+
PACKAGE_NAME?: string;
|
|
4185
|
+
};
|
|
4186
|
+
|
|
4187
|
+
declare global {
|
|
4188
|
+
interface ContextualClient {
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
/**
|
|
4192
|
+
* A type used to create concerete types from SDK descriptors in
|
|
4193
|
+
* case a contextual client is available.
|
|
4194
|
+
*/
|
|
4195
|
+
type MaybeContext$3<T extends Descriptors$3> = globalThis.ContextualClient extends {
|
|
4196
|
+
host: Host$3;
|
|
4197
|
+
} ? BuildDescriptors$3<T, globalThis.ContextualClient['host']> : T;
|
|
4198
|
+
|
|
2897
4199
|
/** Extended field that was found or created. */
|
|
2898
4200
|
interface ExtendedField {
|
|
2899
4201
|
/**
|
|
@@ -3566,17 +4868,17 @@ interface QueryExtendedFieldsSignature {
|
|
|
3566
4868
|
*/
|
|
3567
4869
|
(): FieldsQueryBuilder;
|
|
3568
4870
|
}
|
|
3569
|
-
declare const onExtendedFieldCreated$1: EventDefinition$
|
|
3570
|
-
declare const onExtendedFieldUpdated$1: EventDefinition$
|
|
3571
|
-
declare const onExtendedFieldDeleted$1: EventDefinition$
|
|
4871
|
+
declare const onExtendedFieldCreated$1: EventDefinition$3<ExtendedFieldCreatedEnvelope, "wix.contacts.v4.extended-field_created">;
|
|
4872
|
+
declare const onExtendedFieldUpdated$1: EventDefinition$3<ExtendedFieldUpdatedEnvelope, "wix.contacts.v4.extended-field_updated">;
|
|
4873
|
+
declare const onExtendedFieldDeleted$1: EventDefinition$3<ExtendedFieldDeletedEnvelope, "wix.contacts.v4.extended-field_deleted">;
|
|
3572
4874
|
|
|
3573
|
-
declare function createEventModule$2<T extends EventDefinition$
|
|
4875
|
+
declare function createEventModule$2<T extends EventDefinition$3<any, string>>(eventDefinition: T): BuildEventDefinition$3<T> & T;
|
|
3574
4876
|
|
|
3575
|
-
declare const findOrCreateExtendedField: BuildRESTFunction$3<typeof findOrCreateExtendedField$1> & typeof findOrCreateExtendedField$1
|
|
3576
|
-
declare const getExtendedField: BuildRESTFunction$3<typeof getExtendedField$1> & typeof getExtendedField$1
|
|
3577
|
-
declare const renameExtendedField: BuildRESTFunction$3<typeof renameExtendedField$1> & typeof renameExtendedField$1
|
|
3578
|
-
declare const deleteExtendedField: BuildRESTFunction$3<typeof deleteExtendedField$1> & typeof deleteExtendedField$1
|
|
3579
|
-
declare const queryExtendedFields: BuildRESTFunction$3<typeof queryExtendedFields$1> & typeof queryExtendedFields$1
|
|
4877
|
+
declare const findOrCreateExtendedField: MaybeContext$3<BuildRESTFunction$3<typeof findOrCreateExtendedField$1> & typeof findOrCreateExtendedField$1>;
|
|
4878
|
+
declare const getExtendedField: MaybeContext$3<BuildRESTFunction$3<typeof getExtendedField$1> & typeof getExtendedField$1>;
|
|
4879
|
+
declare const renameExtendedField: MaybeContext$3<BuildRESTFunction$3<typeof renameExtendedField$1> & typeof renameExtendedField$1>;
|
|
4880
|
+
declare const deleteExtendedField: MaybeContext$3<BuildRESTFunction$3<typeof deleteExtendedField$1> & typeof deleteExtendedField$1>;
|
|
4881
|
+
declare const queryExtendedFields: MaybeContext$3<BuildRESTFunction$3<typeof queryExtendedFields$1> & typeof queryExtendedFields$1>;
|
|
3580
4882
|
|
|
3581
4883
|
type _publicOnExtendedFieldCreatedType = typeof onExtendedFieldCreated$1;
|
|
3582
4884
|
/**
|
|
@@ -3641,11 +4943,54 @@ declare namespace index_d$3 {
|
|
|
3641
4943
|
export { type ActionEvent$2 as ActionEvent, type BaseEventMetadata$2 as BaseEventMetadata, type index_d$3_DeleteExtendedFieldRequest as DeleteExtendedFieldRequest, type index_d$3_DeleteExtendedFieldResponse as DeleteExtendedFieldResponse, type DomainEvent$2 as DomainEvent, type DomainEventBodyOneOf$2 as DomainEventBodyOneOf, type EntityCreatedEvent$2 as EntityCreatedEvent, type EntityDeletedEvent$2 as EntityDeletedEvent, type EntityUpdatedEvent$2 as EntityUpdatedEvent, type EventMetadata$2 as EventMetadata, type index_d$3_ExtendedField as ExtendedField, type index_d$3_ExtendedFieldCreatedEnvelope as ExtendedFieldCreatedEnvelope, type index_d$3_ExtendedFieldDeletedEnvelope as ExtendedFieldDeletedEnvelope, type index_d$3_ExtendedFieldNonNullableFields as ExtendedFieldNonNullableFields, type index_d$3_ExtendedFieldUpdatedEnvelope as ExtendedFieldUpdatedEnvelope, index_d$3_FieldDataType as FieldDataType, index_d$3_FieldType as FieldType, type index_d$3_FieldsQueryBuilder as FieldsQueryBuilder, type index_d$3_FieldsQueryResult as FieldsQueryResult, type index_d$3_FindOrCreateExtendedFieldRequest as FindOrCreateExtendedFieldRequest, type index_d$3_FindOrCreateExtendedFieldResponse as FindOrCreateExtendedFieldResponse, type index_d$3_FindOrCreateExtendedFieldResponseNonNullableFields as FindOrCreateExtendedFieldResponseNonNullableFields, type GdprListRequest$1 as GdprListRequest, type GdprListResponse$1 as GdprListResponse, type index_d$3_GetExtendedFieldByLegacyIdRequest as GetExtendedFieldByLegacyIdRequest, type index_d$3_GetExtendedFieldByLegacyIdResponse as GetExtendedFieldByLegacyIdResponse, type index_d$3_GetExtendedFieldRequest as GetExtendedFieldRequest, type index_d$3_GetExtendedFieldResponse as GetExtendedFieldResponse, type index_d$3_GetExtendedFieldResponseNonNullableFields as GetExtendedFieldResponseNonNullableFields, type IdentificationData$3 as IdentificationData, type IdentificationDataIdOneOf$3 as IdentificationDataIdOneOf, type index_d$3_ListExtendedFieldsRequest as ListExtendedFieldsRequest, type index_d$3_ListExtendedFieldsResponse as ListExtendedFieldsResponse, type MessageEnvelope$3 as MessageEnvelope, type Paging$2 as Paging, type PagingMetadata$1 as PagingMetadata, type PurgeRequest$1 as PurgeRequest, type PurgeResponse$1 as PurgeResponse, type Query$1 as Query, type index_d$3_QueryExtendedFieldsRequest as QueryExtendedFieldsRequest, type index_d$3_QueryExtendedFieldsResponse as QueryExtendedFieldsResponse, type index_d$3_QueryExtendedFieldsResponseNonNullableFields as QueryExtendedFieldsResponseNonNullableFields, type index_d$3_RenameExtendedField as RenameExtendedField, type RestoreInfo$1 as RestoreInfo, SortOrder$2 as SortOrder, type Sorting$2 as Sorting, type index_d$3_UpdateExtendedFieldRequest as UpdateExtendedFieldRequest, type index_d$3_UpdateExtendedFieldResponse as UpdateExtendedFieldResponse, type index_d$3_UpdateExtendedFieldResponseNonNullableFields as UpdateExtendedFieldResponseNonNullableFields, WebhookIdentityType$3 as WebhookIdentityType, type index_d$3__publicOnExtendedFieldCreatedType as _publicOnExtendedFieldCreatedType, type index_d$3__publicOnExtendedFieldDeletedType as _publicOnExtendedFieldDeletedType, type index_d$3__publicOnExtendedFieldUpdatedType as _publicOnExtendedFieldUpdatedType, index_d$3_deleteExtendedField as deleteExtendedField, index_d$3_findOrCreateExtendedField as findOrCreateExtendedField, index_d$3_getExtendedField as getExtendedField, index_d$3_onExtendedFieldCreated as onExtendedFieldCreated, index_d$3_onExtendedFieldDeleted as onExtendedFieldDeleted, index_d$3_onExtendedFieldUpdated as onExtendedFieldUpdated, onExtendedFieldCreated$1 as publicOnExtendedFieldCreated, onExtendedFieldDeleted$1 as publicOnExtendedFieldDeleted, onExtendedFieldUpdated$1 as publicOnExtendedFieldUpdated, index_d$3_queryExtendedFields as queryExtendedFields, index_d$3_renameExtendedField as renameExtendedField };
|
|
3642
4944
|
}
|
|
3643
4945
|
|
|
4946
|
+
type HostModule$2<T, H extends Host$2> = {
|
|
4947
|
+
__type: 'host';
|
|
4948
|
+
create(host: H): T;
|
|
4949
|
+
};
|
|
4950
|
+
type HostModuleAPI$2<T extends HostModule$2<any, any>> = T extends HostModule$2<infer U, any> ? U : never;
|
|
4951
|
+
type Host$2<Environment = unknown> = {
|
|
4952
|
+
channel: {
|
|
4953
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
4954
|
+
disconnect: () => void;
|
|
4955
|
+
} | Promise<{
|
|
4956
|
+
disconnect: () => void;
|
|
4957
|
+
}>;
|
|
4958
|
+
};
|
|
4959
|
+
environment?: Environment;
|
|
4960
|
+
/**
|
|
4961
|
+
* Optional name of the environment, use for logging
|
|
4962
|
+
*/
|
|
4963
|
+
name?: string;
|
|
4964
|
+
/**
|
|
4965
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
4966
|
+
*/
|
|
4967
|
+
apiBaseUrl?: string;
|
|
4968
|
+
/**
|
|
4969
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
4970
|
+
* like internationalization, billing, etc.
|
|
4971
|
+
*/
|
|
4972
|
+
essentials?: {
|
|
4973
|
+
/**
|
|
4974
|
+
* The language of the currently viewed session
|
|
4975
|
+
*/
|
|
4976
|
+
language?: string;
|
|
4977
|
+
/**
|
|
4978
|
+
* The locale of the currently viewed session
|
|
4979
|
+
*/
|
|
4980
|
+
locale?: string;
|
|
4981
|
+
/**
|
|
4982
|
+
* Any headers that should be passed through to the API requests
|
|
4983
|
+
*/
|
|
4984
|
+
passThroughHeaders?: Record<string, string>;
|
|
4985
|
+
};
|
|
4986
|
+
};
|
|
4987
|
+
|
|
3644
4988
|
type RESTFunctionDescriptor$2<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$2) => T;
|
|
3645
4989
|
interface HttpClient$2 {
|
|
3646
4990
|
request<TResponse, TData = any>(req: RequestOptionsFactory$2<TResponse, TData>): Promise<HttpResponse$2<TResponse>>;
|
|
3647
4991
|
fetchWithAuth: typeof fetch;
|
|
3648
4992
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
4993
|
+
getActiveToken?: () => string | undefined;
|
|
3649
4994
|
}
|
|
3650
4995
|
type RequestOptionsFactory$2<TResponse = any, TData = any> = (context: any) => RequestOptions$2<TResponse, TData>;
|
|
3651
4996
|
type HttpResponse$2<T = any> = {
|
|
@@ -3667,16 +5012,65 @@ type APIMetadata$2 = {
|
|
|
3667
5012
|
packageName?: string;
|
|
3668
5013
|
};
|
|
3669
5014
|
type BuildRESTFunction$2<T extends RESTFunctionDescriptor$2> = T extends RESTFunctionDescriptor$2<infer U> ? U : never;
|
|
3670
|
-
type EventDefinition$
|
|
5015
|
+
type EventDefinition$2<Payload = unknown, Type extends string = string> = {
|
|
3671
5016
|
__type: 'event-definition';
|
|
3672
5017
|
type: Type;
|
|
3673
5018
|
isDomainEvent?: boolean;
|
|
3674
5019
|
transformations?: (envelope: unknown) => Payload;
|
|
3675
5020
|
__payload: Payload;
|
|
3676
5021
|
};
|
|
3677
|
-
declare function EventDefinition$
|
|
3678
|
-
type EventHandler$
|
|
3679
|
-
type BuildEventDefinition$
|
|
5022
|
+
declare function EventDefinition$2<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$2<Payload, Type>;
|
|
5023
|
+
type EventHandler$2<T extends EventDefinition$2> = (payload: T['__payload']) => void | Promise<void>;
|
|
5024
|
+
type BuildEventDefinition$2<T extends EventDefinition$2<any, string>> = (handler: EventHandler$2<T>) => void;
|
|
5025
|
+
|
|
5026
|
+
type ServicePluginMethodInput$2 = {
|
|
5027
|
+
request: any;
|
|
5028
|
+
metadata: any;
|
|
5029
|
+
};
|
|
5030
|
+
type ServicePluginContract$2 = Record<string, (payload: ServicePluginMethodInput$2) => unknown | Promise<unknown>>;
|
|
5031
|
+
type ServicePluginMethodMetadata$2 = {
|
|
5032
|
+
name: string;
|
|
5033
|
+
primaryHttpMappingPath: string;
|
|
5034
|
+
transformations: {
|
|
5035
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$2;
|
|
5036
|
+
toREST: (...args: unknown[]) => unknown;
|
|
5037
|
+
};
|
|
5038
|
+
};
|
|
5039
|
+
type ServicePluginDefinition$2<Contract extends ServicePluginContract$2> = {
|
|
5040
|
+
__type: 'service-plugin-definition';
|
|
5041
|
+
componentType: string;
|
|
5042
|
+
methods: ServicePluginMethodMetadata$2[];
|
|
5043
|
+
__contract: Contract;
|
|
5044
|
+
};
|
|
5045
|
+
declare function ServicePluginDefinition$2<Contract extends ServicePluginContract$2>(componentType: string, methods: ServicePluginMethodMetadata$2[]): ServicePluginDefinition$2<Contract>;
|
|
5046
|
+
type BuildServicePluginDefinition$2<T extends ServicePluginDefinition$2<any>> = (implementation: T['__contract']) => void;
|
|
5047
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$2 = "wix_spi_error";
|
|
5048
|
+
|
|
5049
|
+
type RequestContext$2 = {
|
|
5050
|
+
isSSR: boolean;
|
|
5051
|
+
host: string;
|
|
5052
|
+
protocol?: string;
|
|
5053
|
+
};
|
|
5054
|
+
type ResponseTransformer$2 = (data: any, headers?: any) => any;
|
|
5055
|
+
/**
|
|
5056
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
5057
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
5058
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
5059
|
+
*/
|
|
5060
|
+
type Method$2 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
5061
|
+
type AmbassadorRequestOptions$2<T = any> = {
|
|
5062
|
+
_?: T;
|
|
5063
|
+
url?: string;
|
|
5064
|
+
method?: Method$2;
|
|
5065
|
+
params?: any;
|
|
5066
|
+
data?: any;
|
|
5067
|
+
transformResponse?: ResponseTransformer$2 | ResponseTransformer$2[];
|
|
5068
|
+
};
|
|
5069
|
+
type AmbassadorFactory$2<Request, Response> = (payload: Request) => ((context: RequestContext$2) => AmbassadorRequestOptions$2<Response>) & {
|
|
5070
|
+
__isAmbassador: boolean;
|
|
5071
|
+
};
|
|
5072
|
+
type AmbassadorFunctionDescriptor$2<Request = any, Response = any> = AmbassadorFactory$2<Request, Response>;
|
|
5073
|
+
type BuildAmbassadorFunction$2<T extends AmbassadorFunctionDescriptor$2> = T extends AmbassadorFunctionDescriptor$2<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
3680
5074
|
|
|
3681
5075
|
declare global {
|
|
3682
5076
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -3685,6 +5079,348 @@ declare global {
|
|
|
3685
5079
|
}
|
|
3686
5080
|
}
|
|
3687
5081
|
|
|
5082
|
+
declare const emptyObjectSymbol$2: unique symbol;
|
|
5083
|
+
|
|
5084
|
+
/**
|
|
5085
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
5086
|
+
|
|
5087
|
+
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)).
|
|
5088
|
+
|
|
5089
|
+
@example
|
|
5090
|
+
```
|
|
5091
|
+
import type {EmptyObject} from 'type-fest';
|
|
5092
|
+
|
|
5093
|
+
// The following illustrates the problem with `{}`.
|
|
5094
|
+
const foo1: {} = {}; // Pass
|
|
5095
|
+
const foo2: {} = []; // Pass
|
|
5096
|
+
const foo3: {} = 42; // Pass
|
|
5097
|
+
const foo4: {} = {a: 1}; // Pass
|
|
5098
|
+
|
|
5099
|
+
// With `EmptyObject` only the first case is valid.
|
|
5100
|
+
const bar1: EmptyObject = {}; // Pass
|
|
5101
|
+
const bar2: EmptyObject = 42; // Fail
|
|
5102
|
+
const bar3: EmptyObject = []; // Fail
|
|
5103
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
5104
|
+
```
|
|
5105
|
+
|
|
5106
|
+
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}.
|
|
5107
|
+
|
|
5108
|
+
@category Object
|
|
5109
|
+
*/
|
|
5110
|
+
type EmptyObject$2 = {[emptyObjectSymbol$2]?: never};
|
|
5111
|
+
|
|
5112
|
+
/**
|
|
5113
|
+
Returns a boolean for whether the two given types are equal.
|
|
5114
|
+
|
|
5115
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
5116
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
5117
|
+
|
|
5118
|
+
Use-cases:
|
|
5119
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
5120
|
+
|
|
5121
|
+
@example
|
|
5122
|
+
```
|
|
5123
|
+
import type {IsEqual} from 'type-fest';
|
|
5124
|
+
|
|
5125
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
5126
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
5127
|
+
type Includes<Value extends readonly any[], Item> =
|
|
5128
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
5129
|
+
? IsEqual<Value[0], Item> extends true
|
|
5130
|
+
? true
|
|
5131
|
+
: Includes<rest, Item>
|
|
5132
|
+
: false;
|
|
5133
|
+
```
|
|
5134
|
+
|
|
5135
|
+
@category Type Guard
|
|
5136
|
+
@category Utilities
|
|
5137
|
+
*/
|
|
5138
|
+
type IsEqual$2<A, B> =
|
|
5139
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
5140
|
+
(<G>() => G extends B ? 1 : 2)
|
|
5141
|
+
? true
|
|
5142
|
+
: false;
|
|
5143
|
+
|
|
5144
|
+
/**
|
|
5145
|
+
Filter out keys from an object.
|
|
5146
|
+
|
|
5147
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
5148
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
5149
|
+
Returns `Key` otherwise.
|
|
5150
|
+
|
|
5151
|
+
@example
|
|
5152
|
+
```
|
|
5153
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
5154
|
+
//=> never
|
|
5155
|
+
```
|
|
5156
|
+
|
|
5157
|
+
@example
|
|
5158
|
+
```
|
|
5159
|
+
type Filtered = Filter<'bar', string>;
|
|
5160
|
+
//=> never
|
|
5161
|
+
```
|
|
5162
|
+
|
|
5163
|
+
@example
|
|
5164
|
+
```
|
|
5165
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
5166
|
+
//=> 'bar'
|
|
5167
|
+
```
|
|
5168
|
+
|
|
5169
|
+
@see {Except}
|
|
5170
|
+
*/
|
|
5171
|
+
type Filter$2<KeyType, ExcludeType> = IsEqual$2<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
5172
|
+
|
|
5173
|
+
type ExceptOptions$2 = {
|
|
5174
|
+
/**
|
|
5175
|
+
Disallow assigning non-specified properties.
|
|
5176
|
+
|
|
5177
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
5178
|
+
|
|
5179
|
+
@default false
|
|
5180
|
+
*/
|
|
5181
|
+
requireExactProps?: boolean;
|
|
5182
|
+
};
|
|
5183
|
+
|
|
5184
|
+
/**
|
|
5185
|
+
Create a type from an object type without certain keys.
|
|
5186
|
+
|
|
5187
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
5188
|
+
|
|
5189
|
+
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.
|
|
5190
|
+
|
|
5191
|
+
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)).
|
|
5192
|
+
|
|
5193
|
+
@example
|
|
5194
|
+
```
|
|
5195
|
+
import type {Except} from 'type-fest';
|
|
5196
|
+
|
|
5197
|
+
type Foo = {
|
|
5198
|
+
a: number;
|
|
5199
|
+
b: string;
|
|
5200
|
+
};
|
|
5201
|
+
|
|
5202
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
5203
|
+
//=> {b: string}
|
|
5204
|
+
|
|
5205
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
5206
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
5207
|
+
|
|
5208
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
5209
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
5210
|
+
|
|
5211
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
5212
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
5213
|
+
```
|
|
5214
|
+
|
|
5215
|
+
@category Object
|
|
5216
|
+
*/
|
|
5217
|
+
type Except$2<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$2 = {requireExactProps: false}> = {
|
|
5218
|
+
[KeyType in keyof ObjectType as Filter$2<KeyType, KeysType>]: ObjectType[KeyType];
|
|
5219
|
+
} & (Options['requireExactProps'] extends true
|
|
5220
|
+
? Partial<Record<KeysType, never>>
|
|
5221
|
+
: {});
|
|
5222
|
+
|
|
5223
|
+
/**
|
|
5224
|
+
Returns a boolean for whether the given type is `never`.
|
|
5225
|
+
|
|
5226
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
5227
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
5228
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
5229
|
+
|
|
5230
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
5231
|
+
|
|
5232
|
+
@example
|
|
5233
|
+
```
|
|
5234
|
+
import type {IsNever, And} from 'type-fest';
|
|
5235
|
+
|
|
5236
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
5237
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
5238
|
+
And<
|
|
5239
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
5240
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
5241
|
+
>;
|
|
5242
|
+
|
|
5243
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
5244
|
+
AreStringsEqual<I, O> extends true
|
|
5245
|
+
? never
|
|
5246
|
+
: void;
|
|
5247
|
+
|
|
5248
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
5249
|
+
if (input === output) {
|
|
5250
|
+
process.exit(0);
|
|
5251
|
+
}
|
|
5252
|
+
}
|
|
5253
|
+
|
|
5254
|
+
endIfEqual('abc', 'abc');
|
|
5255
|
+
//=> never
|
|
5256
|
+
|
|
5257
|
+
endIfEqual('abc', '123');
|
|
5258
|
+
//=> void
|
|
5259
|
+
```
|
|
5260
|
+
|
|
5261
|
+
@category Type Guard
|
|
5262
|
+
@category Utilities
|
|
5263
|
+
*/
|
|
5264
|
+
type IsNever$2<T> = [T] extends [never] ? true : false;
|
|
5265
|
+
|
|
5266
|
+
/**
|
|
5267
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
5268
|
+
|
|
5269
|
+
@see {@link IsNever}
|
|
5270
|
+
|
|
5271
|
+
@example
|
|
5272
|
+
```
|
|
5273
|
+
import type {IfNever} from 'type-fest';
|
|
5274
|
+
|
|
5275
|
+
type ShouldBeTrue = IfNever<never>;
|
|
5276
|
+
//=> true
|
|
5277
|
+
|
|
5278
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
5279
|
+
//=> 'bar'
|
|
5280
|
+
```
|
|
5281
|
+
|
|
5282
|
+
@category Type Guard
|
|
5283
|
+
@category Utilities
|
|
5284
|
+
*/
|
|
5285
|
+
type IfNever$2<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
5286
|
+
IsNever$2<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
5287
|
+
);
|
|
5288
|
+
|
|
5289
|
+
/**
|
|
5290
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
5291
|
+
|
|
5292
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
5293
|
+
|
|
5294
|
+
@example
|
|
5295
|
+
```
|
|
5296
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
5297
|
+
|
|
5298
|
+
interface Example {
|
|
5299
|
+
a: string;
|
|
5300
|
+
b: string | number;
|
|
5301
|
+
c?: string;
|
|
5302
|
+
d: {};
|
|
5303
|
+
}
|
|
5304
|
+
|
|
5305
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
5306
|
+
//=> 'a'
|
|
5307
|
+
```
|
|
5308
|
+
|
|
5309
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
5310
|
+
|
|
5311
|
+
@example
|
|
5312
|
+
```
|
|
5313
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
5314
|
+
|
|
5315
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
5316
|
+
//=> 'a' | 'c'
|
|
5317
|
+
```
|
|
5318
|
+
|
|
5319
|
+
@category Object
|
|
5320
|
+
*/
|
|
5321
|
+
type ConditionalKeys$2<Base, Condition> =
|
|
5322
|
+
{
|
|
5323
|
+
// Map through all the keys of the given base type.
|
|
5324
|
+
[Key in keyof Base]-?:
|
|
5325
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
5326
|
+
Base[Key] extends Condition
|
|
5327
|
+
// Retain this key
|
|
5328
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
5329
|
+
? IfNever$2<Base[Key], IfNever$2<Condition, Key, never>, Key>
|
|
5330
|
+
// Discard this key since the condition fails.
|
|
5331
|
+
: never;
|
|
5332
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
5333
|
+
}[keyof Base];
|
|
5334
|
+
|
|
5335
|
+
/**
|
|
5336
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
5337
|
+
|
|
5338
|
+
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.
|
|
5339
|
+
|
|
5340
|
+
@example
|
|
5341
|
+
```
|
|
5342
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
5343
|
+
|
|
5344
|
+
class Awesome {
|
|
5345
|
+
name: string;
|
|
5346
|
+
successes: number;
|
|
5347
|
+
failures: bigint;
|
|
5348
|
+
|
|
5349
|
+
run() {}
|
|
5350
|
+
}
|
|
5351
|
+
|
|
5352
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
5353
|
+
//=> {run: () => void}
|
|
5354
|
+
```
|
|
5355
|
+
|
|
5356
|
+
@example
|
|
5357
|
+
```
|
|
5358
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
5359
|
+
|
|
5360
|
+
interface Example {
|
|
5361
|
+
a: string;
|
|
5362
|
+
b: string | number;
|
|
5363
|
+
c: () => void;
|
|
5364
|
+
d: {};
|
|
5365
|
+
}
|
|
5366
|
+
|
|
5367
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
5368
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
5369
|
+
```
|
|
5370
|
+
|
|
5371
|
+
@category Object
|
|
5372
|
+
*/
|
|
5373
|
+
type ConditionalExcept$2<Base, Condition> = Except$2<
|
|
5374
|
+
Base,
|
|
5375
|
+
ConditionalKeys$2<Base, Condition>
|
|
5376
|
+
>;
|
|
5377
|
+
|
|
5378
|
+
/**
|
|
5379
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
5380
|
+
* can either be a REST module or a host module.
|
|
5381
|
+
* This type is recursive, so it can describe nested modules.
|
|
5382
|
+
*/
|
|
5383
|
+
type Descriptors$2 = RESTFunctionDescriptor$2 | AmbassadorFunctionDescriptor$2 | HostModule$2<any, any> | EventDefinition$2<any> | ServicePluginDefinition$2<any> | {
|
|
5384
|
+
[key: string]: Descriptors$2 | PublicMetadata$2 | any;
|
|
5385
|
+
};
|
|
5386
|
+
/**
|
|
5387
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
5388
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
5389
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
5390
|
+
* do not match the given host (as they will not work with the given host).
|
|
5391
|
+
*/
|
|
5392
|
+
type BuildDescriptors$2<T extends Descriptors$2, H extends Host$2<any> | undefined, Depth extends number = 5> = {
|
|
5393
|
+
done: T;
|
|
5394
|
+
recurse: T extends {
|
|
5395
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$2;
|
|
5396
|
+
} ? never : T extends AmbassadorFunctionDescriptor$2 ? BuildAmbassadorFunction$2<T> : T extends RESTFunctionDescriptor$2 ? BuildRESTFunction$2<T> : T extends EventDefinition$2<any> ? BuildEventDefinition$2<T> : T extends ServicePluginDefinition$2<any> ? BuildServicePluginDefinition$2<T> : T extends HostModule$2<any, any> ? HostModuleAPI$2<T> : ConditionalExcept$2<{
|
|
5397
|
+
[Key in keyof T]: T[Key] extends Descriptors$2 ? BuildDescriptors$2<T[Key], H, [
|
|
5398
|
+
-1,
|
|
5399
|
+
0,
|
|
5400
|
+
1,
|
|
5401
|
+
2,
|
|
5402
|
+
3,
|
|
5403
|
+
4,
|
|
5404
|
+
5
|
|
5405
|
+
][Depth]> : never;
|
|
5406
|
+
}, EmptyObject$2>;
|
|
5407
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
5408
|
+
type PublicMetadata$2 = {
|
|
5409
|
+
PACKAGE_NAME?: string;
|
|
5410
|
+
};
|
|
5411
|
+
|
|
5412
|
+
declare global {
|
|
5413
|
+
interface ContextualClient {
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
/**
|
|
5417
|
+
* A type used to create concerete types from SDK descriptors in
|
|
5418
|
+
* case a contextual client is available.
|
|
5419
|
+
*/
|
|
5420
|
+
type MaybeContext$2<T extends Descriptors$2> = globalThis.ContextualClient extends {
|
|
5421
|
+
host: Host$2;
|
|
5422
|
+
} ? BuildDescriptors$2<T, globalThis.ContextualClient['host']> : T;
|
|
5423
|
+
|
|
3688
5424
|
/** Label that was found or created. */
|
|
3689
5425
|
interface ContactLabel {
|
|
3690
5426
|
/**
|
|
@@ -4369,17 +6105,17 @@ interface QueryLabelsSignature {
|
|
|
4369
6105
|
*/
|
|
4370
6106
|
(options?: QueryLabelsOptions | undefined): LabelsQueryBuilder;
|
|
4371
6107
|
}
|
|
4372
|
-
declare const onLabelCreated$1: EventDefinition$
|
|
4373
|
-
declare const onLabelUpdated$1: EventDefinition$
|
|
4374
|
-
declare const onLabelDeleted$1: EventDefinition$
|
|
6108
|
+
declare const onLabelCreated$1: EventDefinition$2<LabelCreatedEnvelope, "wix.contacts.v4.label_created">;
|
|
6109
|
+
declare const onLabelUpdated$1: EventDefinition$2<LabelUpdatedEnvelope, "wix.contacts.v4.label_updated">;
|
|
6110
|
+
declare const onLabelDeleted$1: EventDefinition$2<LabelDeletedEnvelope, "wix.contacts.v4.label_deleted">;
|
|
4375
6111
|
|
|
4376
|
-
declare function createEventModule$1<T extends EventDefinition$
|
|
6112
|
+
declare function createEventModule$1<T extends EventDefinition$2<any, string>>(eventDefinition: T): BuildEventDefinition$2<T> & T;
|
|
4377
6113
|
|
|
4378
|
-
declare const findOrCreateLabel: BuildRESTFunction$2<typeof findOrCreateLabel$1> & typeof findOrCreateLabel$1
|
|
4379
|
-
declare const getLabel: BuildRESTFunction$2<typeof getLabel$1> & typeof getLabel$1
|
|
4380
|
-
declare const renameLabel: BuildRESTFunction$2<typeof renameLabel$1> & typeof renameLabel$1
|
|
4381
|
-
declare const deleteLabel: BuildRESTFunction$2<typeof deleteLabel$1> & typeof deleteLabel$1
|
|
4382
|
-
declare const queryLabels: BuildRESTFunction$2<typeof queryLabels$1> & typeof queryLabels$1
|
|
6114
|
+
declare const findOrCreateLabel: MaybeContext$2<BuildRESTFunction$2<typeof findOrCreateLabel$1> & typeof findOrCreateLabel$1>;
|
|
6115
|
+
declare const getLabel: MaybeContext$2<BuildRESTFunction$2<typeof getLabel$1> & typeof getLabel$1>;
|
|
6116
|
+
declare const renameLabel: MaybeContext$2<BuildRESTFunction$2<typeof renameLabel$1> & typeof renameLabel$1>;
|
|
6117
|
+
declare const deleteLabel: MaybeContext$2<BuildRESTFunction$2<typeof deleteLabel$1> & typeof deleteLabel$1>;
|
|
6118
|
+
declare const queryLabels: MaybeContext$2<BuildRESTFunction$2<typeof queryLabels$1> & typeof queryLabels$1>;
|
|
4383
6119
|
|
|
4384
6120
|
type _publicOnLabelCreatedType = typeof onLabelCreated$1;
|
|
4385
6121
|
/**
|
|
@@ -4457,11 +6193,54 @@ declare namespace index_d$2 {
|
|
|
4457
6193
|
export { type ActionEvent$1 as ActionEvent, type BaseEventMetadata$1 as BaseEventMetadata, type index_d$2_ContactLabel as ContactLabel, type index_d$2_ContactLabelNamespace as ContactLabelNamespace, type index_d$2_ContactLabelNonNullableFields as ContactLabelNonNullableFields, type index_d$2_DeleteLabelRequest as DeleteLabelRequest, type index_d$2_DeleteLabelResponse as DeleteLabelResponse, type DomainEvent$1 as DomainEvent, type DomainEventBodyOneOf$1 as DomainEventBodyOneOf, type EntityCreatedEvent$1 as EntityCreatedEvent, type EntityDeletedEvent$1 as EntityDeletedEvent, type EntityUpdatedEvent$1 as EntityUpdatedEvent, type EventMetadata$1 as EventMetadata, type index_d$2_FindOrCreateLabelOptions as FindOrCreateLabelOptions, type index_d$2_FindOrCreateLabelRequest as FindOrCreateLabelRequest, type index_d$2_FindOrCreateLabelResponse as FindOrCreateLabelResponse, type index_d$2_FindOrCreateLabelResponseNonNullableFields as FindOrCreateLabelResponseNonNullableFields, type index_d$2_GdprListRequest as GdprListRequest, type index_d$2_GdprListResponse as GdprListResponse, type index_d$2_GetLabelByLegacyIdRequest as GetLabelByLegacyIdRequest, type index_d$2_GetLabelByLegacyIdResponse as GetLabelByLegacyIdResponse, type index_d$2_GetLabelOptions as GetLabelOptions, type index_d$2_GetLabelRequest as GetLabelRequest, type index_d$2_GetLabelResponse as GetLabelResponse, type index_d$2_GetLabelResponseNonNullableFields as GetLabelResponseNonNullableFields, type IdentificationData$2 as IdentificationData, type IdentificationDataIdOneOf$2 as IdentificationDataIdOneOf, type index_d$2_LabelCreatedEnvelope as LabelCreatedEnvelope, type index_d$2_LabelDeletedEnvelope as LabelDeletedEnvelope, index_d$2_LabelType as LabelType, type index_d$2_LabelUpdatedEnvelope as LabelUpdatedEnvelope, type index_d$2_LabelsQueryBuilder as LabelsQueryBuilder, type index_d$2_LabelsQueryResult as LabelsQueryResult, type index_d$2_LabelsQuotaReached as LabelsQuotaReached, type index_d$2_ListLabelNamespacesRequest as ListLabelNamespacesRequest, type index_d$2_ListLabelNamespacesResponse as ListLabelNamespacesResponse, type index_d$2_ListLabelsRequest as ListLabelsRequest, type index_d$2_ListLabelsResponse as ListLabelsResponse, type MessageEnvelope$2 as MessageEnvelope, type Paging$1 as Paging, type index_d$2_PagingMetadata as PagingMetadata, type index_d$2_PurgeRequest as PurgeRequest, type index_d$2_PurgeResponse as PurgeResponse, type index_d$2_Query as Query, type index_d$2_QueryLabelsOptions as QueryLabelsOptions, type index_d$2_QueryLabelsRequest as QueryLabelsRequest, type index_d$2_QueryLabelsResponse as QueryLabelsResponse, type index_d$2_QueryLabelsResponseNonNullableFields as QueryLabelsResponseNonNullableFields, type index_d$2_RenameLabel as RenameLabel, type index_d$2_RenameLabelOptions as RenameLabelOptions, type index_d$2_RestoreInfo as RestoreInfo, SortOrder$1 as SortOrder, type Sorting$1 as Sorting, type index_d$2_UpdateLabelRequest as UpdateLabelRequest, type index_d$2_UpdateLabelResponse as UpdateLabelResponse, type index_d$2_UpdateLabelResponseNonNullableFields as UpdateLabelResponseNonNullableFields, WebhookIdentityType$2 as WebhookIdentityType, type index_d$2__publicOnLabelCreatedType as _publicOnLabelCreatedType, type index_d$2__publicOnLabelDeletedType as _publicOnLabelDeletedType, type index_d$2__publicOnLabelUpdatedType as _publicOnLabelUpdatedType, index_d$2_deleteLabel as deleteLabel, index_d$2_findOrCreateLabel as findOrCreateLabel, index_d$2_getLabel as getLabel, index_d$2_onLabelCreated as onLabelCreated, index_d$2_onLabelDeleted as onLabelDeleted, index_d$2_onLabelUpdated as onLabelUpdated, onLabelCreated$1 as publicOnLabelCreated, onLabelDeleted$1 as publicOnLabelDeleted, onLabelUpdated$1 as publicOnLabelUpdated, index_d$2_queryLabels as queryLabels, index_d$2_renameLabel as renameLabel };
|
|
4458
6194
|
}
|
|
4459
6195
|
|
|
6196
|
+
type HostModule$1<T, H extends Host$1> = {
|
|
6197
|
+
__type: 'host';
|
|
6198
|
+
create(host: H): T;
|
|
6199
|
+
};
|
|
6200
|
+
type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
|
|
6201
|
+
type Host$1<Environment = unknown> = {
|
|
6202
|
+
channel: {
|
|
6203
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
6204
|
+
disconnect: () => void;
|
|
6205
|
+
} | Promise<{
|
|
6206
|
+
disconnect: () => void;
|
|
6207
|
+
}>;
|
|
6208
|
+
};
|
|
6209
|
+
environment?: Environment;
|
|
6210
|
+
/**
|
|
6211
|
+
* Optional name of the environment, use for logging
|
|
6212
|
+
*/
|
|
6213
|
+
name?: string;
|
|
6214
|
+
/**
|
|
6215
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
6216
|
+
*/
|
|
6217
|
+
apiBaseUrl?: string;
|
|
6218
|
+
/**
|
|
6219
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
6220
|
+
* like internationalization, billing, etc.
|
|
6221
|
+
*/
|
|
6222
|
+
essentials?: {
|
|
6223
|
+
/**
|
|
6224
|
+
* The language of the currently viewed session
|
|
6225
|
+
*/
|
|
6226
|
+
language?: string;
|
|
6227
|
+
/**
|
|
6228
|
+
* The locale of the currently viewed session
|
|
6229
|
+
*/
|
|
6230
|
+
locale?: string;
|
|
6231
|
+
/**
|
|
6232
|
+
* Any headers that should be passed through to the API requests
|
|
6233
|
+
*/
|
|
6234
|
+
passThroughHeaders?: Record<string, string>;
|
|
6235
|
+
};
|
|
6236
|
+
};
|
|
6237
|
+
|
|
4460
6238
|
type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
|
|
4461
6239
|
interface HttpClient$1 {
|
|
4462
6240
|
request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
|
|
4463
6241
|
fetchWithAuth: typeof fetch;
|
|
4464
6242
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
6243
|
+
getActiveToken?: () => string | undefined;
|
|
4465
6244
|
}
|
|
4466
6245
|
type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
|
|
4467
6246
|
type HttpResponse$1<T = any> = {
|
|
@@ -4483,6 +6262,65 @@ type APIMetadata$1 = {
|
|
|
4483
6262
|
packageName?: string;
|
|
4484
6263
|
};
|
|
4485
6264
|
type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
|
|
6265
|
+
type EventDefinition$1<Payload = unknown, Type extends string = string> = {
|
|
6266
|
+
__type: 'event-definition';
|
|
6267
|
+
type: Type;
|
|
6268
|
+
isDomainEvent?: boolean;
|
|
6269
|
+
transformations?: (envelope: unknown) => Payload;
|
|
6270
|
+
__payload: Payload;
|
|
6271
|
+
};
|
|
6272
|
+
declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
|
|
6273
|
+
type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
|
|
6274
|
+
type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
|
|
6275
|
+
|
|
6276
|
+
type ServicePluginMethodInput$1 = {
|
|
6277
|
+
request: any;
|
|
6278
|
+
metadata: any;
|
|
6279
|
+
};
|
|
6280
|
+
type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
|
|
6281
|
+
type ServicePluginMethodMetadata$1 = {
|
|
6282
|
+
name: string;
|
|
6283
|
+
primaryHttpMappingPath: string;
|
|
6284
|
+
transformations: {
|
|
6285
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
|
|
6286
|
+
toREST: (...args: unknown[]) => unknown;
|
|
6287
|
+
};
|
|
6288
|
+
};
|
|
6289
|
+
type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
|
|
6290
|
+
__type: 'service-plugin-definition';
|
|
6291
|
+
componentType: string;
|
|
6292
|
+
methods: ServicePluginMethodMetadata$1[];
|
|
6293
|
+
__contract: Contract;
|
|
6294
|
+
};
|
|
6295
|
+
declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
|
|
6296
|
+
type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
|
|
6297
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
|
|
6298
|
+
|
|
6299
|
+
type RequestContext$1 = {
|
|
6300
|
+
isSSR: boolean;
|
|
6301
|
+
host: string;
|
|
6302
|
+
protocol?: string;
|
|
6303
|
+
};
|
|
6304
|
+
type ResponseTransformer$1 = (data: any, headers?: any) => any;
|
|
6305
|
+
/**
|
|
6306
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
6307
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
6308
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
6309
|
+
*/
|
|
6310
|
+
type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
6311
|
+
type AmbassadorRequestOptions$1<T = any> = {
|
|
6312
|
+
_?: T;
|
|
6313
|
+
url?: string;
|
|
6314
|
+
method?: Method$1;
|
|
6315
|
+
params?: any;
|
|
6316
|
+
data?: any;
|
|
6317
|
+
transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
|
|
6318
|
+
};
|
|
6319
|
+
type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
|
|
6320
|
+
__isAmbassador: boolean;
|
|
6321
|
+
};
|
|
6322
|
+
type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
|
|
6323
|
+
type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
4486
6324
|
|
|
4487
6325
|
declare global {
|
|
4488
6326
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
@@ -4491,6 +6329,348 @@ declare global {
|
|
|
4491
6329
|
}
|
|
4492
6330
|
}
|
|
4493
6331
|
|
|
6332
|
+
declare const emptyObjectSymbol$1: unique symbol;
|
|
6333
|
+
|
|
6334
|
+
/**
|
|
6335
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
6336
|
+
|
|
6337
|
+
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)).
|
|
6338
|
+
|
|
6339
|
+
@example
|
|
6340
|
+
```
|
|
6341
|
+
import type {EmptyObject} from 'type-fest';
|
|
6342
|
+
|
|
6343
|
+
// The following illustrates the problem with `{}`.
|
|
6344
|
+
const foo1: {} = {}; // Pass
|
|
6345
|
+
const foo2: {} = []; // Pass
|
|
6346
|
+
const foo3: {} = 42; // Pass
|
|
6347
|
+
const foo4: {} = {a: 1}; // Pass
|
|
6348
|
+
|
|
6349
|
+
// With `EmptyObject` only the first case is valid.
|
|
6350
|
+
const bar1: EmptyObject = {}; // Pass
|
|
6351
|
+
const bar2: EmptyObject = 42; // Fail
|
|
6352
|
+
const bar3: EmptyObject = []; // Fail
|
|
6353
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
6354
|
+
```
|
|
6355
|
+
|
|
6356
|
+
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}.
|
|
6357
|
+
|
|
6358
|
+
@category Object
|
|
6359
|
+
*/
|
|
6360
|
+
type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
|
|
6361
|
+
|
|
6362
|
+
/**
|
|
6363
|
+
Returns a boolean for whether the two given types are equal.
|
|
6364
|
+
|
|
6365
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
6366
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
6367
|
+
|
|
6368
|
+
Use-cases:
|
|
6369
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
6370
|
+
|
|
6371
|
+
@example
|
|
6372
|
+
```
|
|
6373
|
+
import type {IsEqual} from 'type-fest';
|
|
6374
|
+
|
|
6375
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
6376
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
6377
|
+
type Includes<Value extends readonly any[], Item> =
|
|
6378
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
6379
|
+
? IsEqual<Value[0], Item> extends true
|
|
6380
|
+
? true
|
|
6381
|
+
: Includes<rest, Item>
|
|
6382
|
+
: false;
|
|
6383
|
+
```
|
|
6384
|
+
|
|
6385
|
+
@category Type Guard
|
|
6386
|
+
@category Utilities
|
|
6387
|
+
*/
|
|
6388
|
+
type IsEqual$1<A, B> =
|
|
6389
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
6390
|
+
(<G>() => G extends B ? 1 : 2)
|
|
6391
|
+
? true
|
|
6392
|
+
: false;
|
|
6393
|
+
|
|
6394
|
+
/**
|
|
6395
|
+
Filter out keys from an object.
|
|
6396
|
+
|
|
6397
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
6398
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
6399
|
+
Returns `Key` otherwise.
|
|
6400
|
+
|
|
6401
|
+
@example
|
|
6402
|
+
```
|
|
6403
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
6404
|
+
//=> never
|
|
6405
|
+
```
|
|
6406
|
+
|
|
6407
|
+
@example
|
|
6408
|
+
```
|
|
6409
|
+
type Filtered = Filter<'bar', string>;
|
|
6410
|
+
//=> never
|
|
6411
|
+
```
|
|
6412
|
+
|
|
6413
|
+
@example
|
|
6414
|
+
```
|
|
6415
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
6416
|
+
//=> 'bar'
|
|
6417
|
+
```
|
|
6418
|
+
|
|
6419
|
+
@see {Except}
|
|
6420
|
+
*/
|
|
6421
|
+
type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
6422
|
+
|
|
6423
|
+
type ExceptOptions$1 = {
|
|
6424
|
+
/**
|
|
6425
|
+
Disallow assigning non-specified properties.
|
|
6426
|
+
|
|
6427
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
6428
|
+
|
|
6429
|
+
@default false
|
|
6430
|
+
*/
|
|
6431
|
+
requireExactProps?: boolean;
|
|
6432
|
+
};
|
|
6433
|
+
|
|
6434
|
+
/**
|
|
6435
|
+
Create a type from an object type without certain keys.
|
|
6436
|
+
|
|
6437
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
6438
|
+
|
|
6439
|
+
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.
|
|
6440
|
+
|
|
6441
|
+
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)).
|
|
6442
|
+
|
|
6443
|
+
@example
|
|
6444
|
+
```
|
|
6445
|
+
import type {Except} from 'type-fest';
|
|
6446
|
+
|
|
6447
|
+
type Foo = {
|
|
6448
|
+
a: number;
|
|
6449
|
+
b: string;
|
|
6450
|
+
};
|
|
6451
|
+
|
|
6452
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
6453
|
+
//=> {b: string}
|
|
6454
|
+
|
|
6455
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
6456
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
6457
|
+
|
|
6458
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
6459
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
6460
|
+
|
|
6461
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
6462
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
6463
|
+
```
|
|
6464
|
+
|
|
6465
|
+
@category Object
|
|
6466
|
+
*/
|
|
6467
|
+
type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
|
|
6468
|
+
[KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
|
|
6469
|
+
} & (Options['requireExactProps'] extends true
|
|
6470
|
+
? Partial<Record<KeysType, never>>
|
|
6471
|
+
: {});
|
|
6472
|
+
|
|
6473
|
+
/**
|
|
6474
|
+
Returns a boolean for whether the given type is `never`.
|
|
6475
|
+
|
|
6476
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
6477
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
6478
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
6479
|
+
|
|
6480
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
6481
|
+
|
|
6482
|
+
@example
|
|
6483
|
+
```
|
|
6484
|
+
import type {IsNever, And} from 'type-fest';
|
|
6485
|
+
|
|
6486
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
6487
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
6488
|
+
And<
|
|
6489
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
6490
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
6491
|
+
>;
|
|
6492
|
+
|
|
6493
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
6494
|
+
AreStringsEqual<I, O> extends true
|
|
6495
|
+
? never
|
|
6496
|
+
: void;
|
|
6497
|
+
|
|
6498
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
6499
|
+
if (input === output) {
|
|
6500
|
+
process.exit(0);
|
|
6501
|
+
}
|
|
6502
|
+
}
|
|
6503
|
+
|
|
6504
|
+
endIfEqual('abc', 'abc');
|
|
6505
|
+
//=> never
|
|
6506
|
+
|
|
6507
|
+
endIfEqual('abc', '123');
|
|
6508
|
+
//=> void
|
|
6509
|
+
```
|
|
6510
|
+
|
|
6511
|
+
@category Type Guard
|
|
6512
|
+
@category Utilities
|
|
6513
|
+
*/
|
|
6514
|
+
type IsNever$1<T> = [T] extends [never] ? true : false;
|
|
6515
|
+
|
|
6516
|
+
/**
|
|
6517
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
6518
|
+
|
|
6519
|
+
@see {@link IsNever}
|
|
6520
|
+
|
|
6521
|
+
@example
|
|
6522
|
+
```
|
|
6523
|
+
import type {IfNever} from 'type-fest';
|
|
6524
|
+
|
|
6525
|
+
type ShouldBeTrue = IfNever<never>;
|
|
6526
|
+
//=> true
|
|
6527
|
+
|
|
6528
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
6529
|
+
//=> 'bar'
|
|
6530
|
+
```
|
|
6531
|
+
|
|
6532
|
+
@category Type Guard
|
|
6533
|
+
@category Utilities
|
|
6534
|
+
*/
|
|
6535
|
+
type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
6536
|
+
IsNever$1<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
6537
|
+
);
|
|
6538
|
+
|
|
6539
|
+
/**
|
|
6540
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
6541
|
+
|
|
6542
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
6543
|
+
|
|
6544
|
+
@example
|
|
6545
|
+
```
|
|
6546
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
6547
|
+
|
|
6548
|
+
interface Example {
|
|
6549
|
+
a: string;
|
|
6550
|
+
b: string | number;
|
|
6551
|
+
c?: string;
|
|
6552
|
+
d: {};
|
|
6553
|
+
}
|
|
6554
|
+
|
|
6555
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
6556
|
+
//=> 'a'
|
|
6557
|
+
```
|
|
6558
|
+
|
|
6559
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
6560
|
+
|
|
6561
|
+
@example
|
|
6562
|
+
```
|
|
6563
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
6564
|
+
|
|
6565
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
6566
|
+
//=> 'a' | 'c'
|
|
6567
|
+
```
|
|
6568
|
+
|
|
6569
|
+
@category Object
|
|
6570
|
+
*/
|
|
6571
|
+
type ConditionalKeys$1<Base, Condition> =
|
|
6572
|
+
{
|
|
6573
|
+
// Map through all the keys of the given base type.
|
|
6574
|
+
[Key in keyof Base]-?:
|
|
6575
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
6576
|
+
Base[Key] extends Condition
|
|
6577
|
+
// Retain this key
|
|
6578
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
6579
|
+
? IfNever$1<Base[Key], IfNever$1<Condition, Key, never>, Key>
|
|
6580
|
+
// Discard this key since the condition fails.
|
|
6581
|
+
: never;
|
|
6582
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
6583
|
+
}[keyof Base];
|
|
6584
|
+
|
|
6585
|
+
/**
|
|
6586
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
6587
|
+
|
|
6588
|
+
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.
|
|
6589
|
+
|
|
6590
|
+
@example
|
|
6591
|
+
```
|
|
6592
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
6593
|
+
|
|
6594
|
+
class Awesome {
|
|
6595
|
+
name: string;
|
|
6596
|
+
successes: number;
|
|
6597
|
+
failures: bigint;
|
|
6598
|
+
|
|
6599
|
+
run() {}
|
|
6600
|
+
}
|
|
6601
|
+
|
|
6602
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
6603
|
+
//=> {run: () => void}
|
|
6604
|
+
```
|
|
6605
|
+
|
|
6606
|
+
@example
|
|
6607
|
+
```
|
|
6608
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
6609
|
+
|
|
6610
|
+
interface Example {
|
|
6611
|
+
a: string;
|
|
6612
|
+
b: string | number;
|
|
6613
|
+
c: () => void;
|
|
6614
|
+
d: {};
|
|
6615
|
+
}
|
|
6616
|
+
|
|
6617
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
6618
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
6619
|
+
```
|
|
6620
|
+
|
|
6621
|
+
@category Object
|
|
6622
|
+
*/
|
|
6623
|
+
type ConditionalExcept$1<Base, Condition> = Except$1<
|
|
6624
|
+
Base,
|
|
6625
|
+
ConditionalKeys$1<Base, Condition>
|
|
6626
|
+
>;
|
|
6627
|
+
|
|
6628
|
+
/**
|
|
6629
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
6630
|
+
* can either be a REST module or a host module.
|
|
6631
|
+
* This type is recursive, so it can describe nested modules.
|
|
6632
|
+
*/
|
|
6633
|
+
type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$1<any> | ServicePluginDefinition$1<any> | {
|
|
6634
|
+
[key: string]: Descriptors$1 | PublicMetadata$1 | any;
|
|
6635
|
+
};
|
|
6636
|
+
/**
|
|
6637
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
6638
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
6639
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
6640
|
+
* do not match the given host (as they will not work with the given host).
|
|
6641
|
+
*/
|
|
6642
|
+
type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
|
|
6643
|
+
done: T;
|
|
6644
|
+
recurse: T extends {
|
|
6645
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
|
|
6646
|
+
} ? never : T extends AmbassadorFunctionDescriptor$1 ? BuildAmbassadorFunction$1<T> : T extends RESTFunctionDescriptor$1 ? BuildRESTFunction$1<T> : T extends EventDefinition$1<any> ? BuildEventDefinition$1<T> : T extends ServicePluginDefinition$1<any> ? BuildServicePluginDefinition$1<T> : T extends HostModule$1<any, any> ? HostModuleAPI$1<T> : ConditionalExcept$1<{
|
|
6647
|
+
[Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
|
|
6648
|
+
-1,
|
|
6649
|
+
0,
|
|
6650
|
+
1,
|
|
6651
|
+
2,
|
|
6652
|
+
3,
|
|
6653
|
+
4,
|
|
6654
|
+
5
|
|
6655
|
+
][Depth]> : never;
|
|
6656
|
+
}, EmptyObject$1>;
|
|
6657
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
6658
|
+
type PublicMetadata$1 = {
|
|
6659
|
+
PACKAGE_NAME?: string;
|
|
6660
|
+
};
|
|
6661
|
+
|
|
6662
|
+
declare global {
|
|
6663
|
+
interface ContextualClient {
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
/**
|
|
6667
|
+
* A type used to create concerete types from SDK descriptors in
|
|
6668
|
+
* case a contextual client is available.
|
|
6669
|
+
*/
|
|
6670
|
+
type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
|
|
6671
|
+
host: Host$1;
|
|
6672
|
+
} ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
|
|
6673
|
+
|
|
4494
6674
|
/** Dummy message for fqdn validation */
|
|
4495
6675
|
interface SubmitContact {
|
|
4496
6676
|
/** Submit Contact Id */
|
|
@@ -5090,7 +7270,7 @@ interface AppendOrCreateContactSignature {
|
|
|
5090
7270
|
(options?: AppendOrCreateContactOptions | undefined): Promise<SubmitContactResponse & SubmitContactResponseNonNullableFields>;
|
|
5091
7271
|
}
|
|
5092
7272
|
|
|
5093
|
-
declare const appendOrCreateContact: BuildRESTFunction$1<typeof appendOrCreateContact$1> & typeof appendOrCreateContact$1
|
|
7273
|
+
declare const appendOrCreateContact: MaybeContext$1<BuildRESTFunction$1<typeof appendOrCreateContact$1> & typeof appendOrCreateContact$1>;
|
|
5094
7274
|
|
|
5095
7275
|
type index_d$1_ActivityIcon = ActivityIcon;
|
|
5096
7276
|
type index_d$1_Address = Address;
|
|
@@ -5143,11 +7323,54 @@ declare namespace index_d$1 {
|
|
|
5143
7323
|
export { type index_d$1_ActivityIcon as ActivityIcon, type index_d$1_Address as Address, type index_d$1_AddressLocation as AddressLocation, type index_d$1_AddressStreetOneOf as AddressStreetOneOf, index_d$1_AddressTag as AddressTag, type index_d$1_AppendOrCreateContactOptions as AppendOrCreateContactOptions, type index_d$1_AssigneesWrapper as AssigneesWrapper, type index_d$1_ContactActivity as ContactActivity, index_d$1_ContactActivityType as ContactActivityType, type index_d$1_ContactAddress as ContactAddress, type index_d$1_ContactAddressesWrapper as ContactAddressesWrapper, type index_d$1_ContactEmail as ContactEmail, type index_d$1_ContactEmailsWrapper as ContactEmailsWrapper, type ContactInfo$1 as ContactInfo, type index_d$1_ContactName as ContactName, type index_d$1_ContactPhone as ContactPhone, type index_d$1_ContactPhonesWrapper as ContactPhonesWrapper, type index_d$1_ContactPicture as ContactPicture, index_d$1_ContactSourceType as ContactSourceType, type index_d$1_ContactToSubmit as ContactToSubmit, index_d$1_EmailTag as EmailTag, type index_d$1_ExtendedFieldsWrapper as ExtendedFieldsWrapper, type IdentificationData$1 as IdentificationData, type IdentificationDataIdOneOf$1 as IdentificationDataIdOneOf, index_d$1_IdentityType as IdentityType, index_d$1_ImageProvider as ImageProvider, type index_d$1_LabelsWrapper as LabelsWrapper, type index_d$1_LocationsWrapper as LocationsWrapper, type MessageEnvelope$1 as MessageEnvelope, index_d$1_PhoneTag as PhoneTag, type index_d$1_StreetAddress as StreetAddress, type index_d$1_Subdivision as Subdivision, index_d$1_SubdivisionType as SubdivisionType, type index_d$1_SubmitContact as SubmitContact, type index_d$1_SubmitContactOptions as SubmitContactOptions, type index_d$1_SubmitContactRequest as SubmitContactRequest, type index_d$1_SubmitContactResponse as SubmitContactResponse, type index_d$1_SubmitContactResponseNonNullableFields as SubmitContactResponseNonNullableFields, index_d$1_SubmitOperation as SubmitOperation, type index_d$1_SubmitVisitorIdRequest as SubmitVisitorIdRequest, type index_d$1_SubmitVisitorIdResponse as SubmitVisitorIdResponse, WebhookIdentityType$1 as WebhookIdentityType, index_d$1_appendOrCreateContact as appendOrCreateContact };
|
|
5144
7324
|
}
|
|
5145
7325
|
|
|
7326
|
+
type HostModule<T, H extends Host> = {
|
|
7327
|
+
__type: 'host';
|
|
7328
|
+
create(host: H): T;
|
|
7329
|
+
};
|
|
7330
|
+
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
|
|
7331
|
+
type Host<Environment = unknown> = {
|
|
7332
|
+
channel: {
|
|
7333
|
+
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
7334
|
+
disconnect: () => void;
|
|
7335
|
+
} | Promise<{
|
|
7336
|
+
disconnect: () => void;
|
|
7337
|
+
}>;
|
|
7338
|
+
};
|
|
7339
|
+
environment?: Environment;
|
|
7340
|
+
/**
|
|
7341
|
+
* Optional name of the environment, use for logging
|
|
7342
|
+
*/
|
|
7343
|
+
name?: string;
|
|
7344
|
+
/**
|
|
7345
|
+
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
7346
|
+
*/
|
|
7347
|
+
apiBaseUrl?: string;
|
|
7348
|
+
/**
|
|
7349
|
+
* Possible data to be provided by every host, for cross cutting concerns
|
|
7350
|
+
* like internationalization, billing, etc.
|
|
7351
|
+
*/
|
|
7352
|
+
essentials?: {
|
|
7353
|
+
/**
|
|
7354
|
+
* The language of the currently viewed session
|
|
7355
|
+
*/
|
|
7356
|
+
language?: string;
|
|
7357
|
+
/**
|
|
7358
|
+
* The locale of the currently viewed session
|
|
7359
|
+
*/
|
|
7360
|
+
locale?: string;
|
|
7361
|
+
/**
|
|
7362
|
+
* Any headers that should be passed through to the API requests
|
|
7363
|
+
*/
|
|
7364
|
+
passThroughHeaders?: Record<string, string>;
|
|
7365
|
+
};
|
|
7366
|
+
};
|
|
7367
|
+
|
|
5146
7368
|
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
5147
7369
|
interface HttpClient {
|
|
5148
7370
|
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
5149
7371
|
fetchWithAuth: typeof fetch;
|
|
5150
7372
|
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
7373
|
+
getActiveToken?: () => string | undefined;
|
|
5151
7374
|
}
|
|
5152
7375
|
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
5153
7376
|
type HttpResponse<T = any> = {
|
|
@@ -5180,6 +7403,55 @@ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?
|
|
|
5180
7403
|
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
|
|
5181
7404
|
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
|
|
5182
7405
|
|
|
7406
|
+
type ServicePluginMethodInput = {
|
|
7407
|
+
request: any;
|
|
7408
|
+
metadata: any;
|
|
7409
|
+
};
|
|
7410
|
+
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
|
|
7411
|
+
type ServicePluginMethodMetadata = {
|
|
7412
|
+
name: string;
|
|
7413
|
+
primaryHttpMappingPath: string;
|
|
7414
|
+
transformations: {
|
|
7415
|
+
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
|
|
7416
|
+
toREST: (...args: unknown[]) => unknown;
|
|
7417
|
+
};
|
|
7418
|
+
};
|
|
7419
|
+
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
|
|
7420
|
+
__type: 'service-plugin-definition';
|
|
7421
|
+
componentType: string;
|
|
7422
|
+
methods: ServicePluginMethodMetadata[];
|
|
7423
|
+
__contract: Contract;
|
|
7424
|
+
};
|
|
7425
|
+
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
|
|
7426
|
+
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
|
|
7427
|
+
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
|
|
7428
|
+
|
|
7429
|
+
type RequestContext = {
|
|
7430
|
+
isSSR: boolean;
|
|
7431
|
+
host: string;
|
|
7432
|
+
protocol?: string;
|
|
7433
|
+
};
|
|
7434
|
+
type ResponseTransformer = (data: any, headers?: any) => any;
|
|
7435
|
+
/**
|
|
7436
|
+
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
7437
|
+
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
7438
|
+
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
7439
|
+
*/
|
|
7440
|
+
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
7441
|
+
type AmbassadorRequestOptions<T = any> = {
|
|
7442
|
+
_?: T;
|
|
7443
|
+
url?: string;
|
|
7444
|
+
method?: Method;
|
|
7445
|
+
params?: any;
|
|
7446
|
+
data?: any;
|
|
7447
|
+
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
7448
|
+
};
|
|
7449
|
+
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
7450
|
+
__isAmbassador: boolean;
|
|
7451
|
+
};
|
|
7452
|
+
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
|
|
7453
|
+
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
7454
|
+
|
|
5183
7455
|
declare global {
|
|
5184
7456
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
5185
7457
|
interface SymbolConstructor {
|
|
@@ -5187,6 +7459,348 @@ declare global {
|
|
|
5187
7459
|
}
|
|
5188
7460
|
}
|
|
5189
7461
|
|
|
7462
|
+
declare const emptyObjectSymbol: unique symbol;
|
|
7463
|
+
|
|
7464
|
+
/**
|
|
7465
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
7466
|
+
|
|
7467
|
+
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)).
|
|
7468
|
+
|
|
7469
|
+
@example
|
|
7470
|
+
```
|
|
7471
|
+
import type {EmptyObject} from 'type-fest';
|
|
7472
|
+
|
|
7473
|
+
// The following illustrates the problem with `{}`.
|
|
7474
|
+
const foo1: {} = {}; // Pass
|
|
7475
|
+
const foo2: {} = []; // Pass
|
|
7476
|
+
const foo3: {} = 42; // Pass
|
|
7477
|
+
const foo4: {} = {a: 1}; // Pass
|
|
7478
|
+
|
|
7479
|
+
// With `EmptyObject` only the first case is valid.
|
|
7480
|
+
const bar1: EmptyObject = {}; // Pass
|
|
7481
|
+
const bar2: EmptyObject = 42; // Fail
|
|
7482
|
+
const bar3: EmptyObject = []; // Fail
|
|
7483
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
7484
|
+
```
|
|
7485
|
+
|
|
7486
|
+
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}.
|
|
7487
|
+
|
|
7488
|
+
@category Object
|
|
7489
|
+
*/
|
|
7490
|
+
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
7491
|
+
|
|
7492
|
+
/**
|
|
7493
|
+
Returns a boolean for whether the two given types are equal.
|
|
7494
|
+
|
|
7495
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
7496
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
7497
|
+
|
|
7498
|
+
Use-cases:
|
|
7499
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
7500
|
+
|
|
7501
|
+
@example
|
|
7502
|
+
```
|
|
7503
|
+
import type {IsEqual} from 'type-fest';
|
|
7504
|
+
|
|
7505
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
7506
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
7507
|
+
type Includes<Value extends readonly any[], Item> =
|
|
7508
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
7509
|
+
? IsEqual<Value[0], Item> extends true
|
|
7510
|
+
? true
|
|
7511
|
+
: Includes<rest, Item>
|
|
7512
|
+
: false;
|
|
7513
|
+
```
|
|
7514
|
+
|
|
7515
|
+
@category Type Guard
|
|
7516
|
+
@category Utilities
|
|
7517
|
+
*/
|
|
7518
|
+
type IsEqual<A, B> =
|
|
7519
|
+
(<G>() => G extends A ? 1 : 2) extends
|
|
7520
|
+
(<G>() => G extends B ? 1 : 2)
|
|
7521
|
+
? true
|
|
7522
|
+
: false;
|
|
7523
|
+
|
|
7524
|
+
/**
|
|
7525
|
+
Filter out keys from an object.
|
|
7526
|
+
|
|
7527
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
7528
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
7529
|
+
Returns `Key` otherwise.
|
|
7530
|
+
|
|
7531
|
+
@example
|
|
7532
|
+
```
|
|
7533
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
7534
|
+
//=> never
|
|
7535
|
+
```
|
|
7536
|
+
|
|
7537
|
+
@example
|
|
7538
|
+
```
|
|
7539
|
+
type Filtered = Filter<'bar', string>;
|
|
7540
|
+
//=> never
|
|
7541
|
+
```
|
|
7542
|
+
|
|
7543
|
+
@example
|
|
7544
|
+
```
|
|
7545
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
7546
|
+
//=> 'bar'
|
|
7547
|
+
```
|
|
7548
|
+
|
|
7549
|
+
@see {Except}
|
|
7550
|
+
*/
|
|
7551
|
+
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
7552
|
+
|
|
7553
|
+
type ExceptOptions = {
|
|
7554
|
+
/**
|
|
7555
|
+
Disallow assigning non-specified properties.
|
|
7556
|
+
|
|
7557
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
7558
|
+
|
|
7559
|
+
@default false
|
|
7560
|
+
*/
|
|
7561
|
+
requireExactProps?: boolean;
|
|
7562
|
+
};
|
|
7563
|
+
|
|
7564
|
+
/**
|
|
7565
|
+
Create a type from an object type without certain keys.
|
|
7566
|
+
|
|
7567
|
+
We recommend setting the `requireExactProps` option to `true`.
|
|
7568
|
+
|
|
7569
|
+
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.
|
|
7570
|
+
|
|
7571
|
+
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)).
|
|
7572
|
+
|
|
7573
|
+
@example
|
|
7574
|
+
```
|
|
7575
|
+
import type {Except} from 'type-fest';
|
|
7576
|
+
|
|
7577
|
+
type Foo = {
|
|
7578
|
+
a: number;
|
|
7579
|
+
b: string;
|
|
7580
|
+
};
|
|
7581
|
+
|
|
7582
|
+
type FooWithoutA = Except<Foo, 'a'>;
|
|
7583
|
+
//=> {b: string}
|
|
7584
|
+
|
|
7585
|
+
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
7586
|
+
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
7587
|
+
|
|
7588
|
+
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
7589
|
+
//=> {a: number} & Partial<Record<"b", never>>
|
|
7590
|
+
|
|
7591
|
+
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
7592
|
+
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
7593
|
+
```
|
|
7594
|
+
|
|
7595
|
+
@category Object
|
|
7596
|
+
*/
|
|
7597
|
+
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
|
|
7598
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
7599
|
+
} & (Options['requireExactProps'] extends true
|
|
7600
|
+
? Partial<Record<KeysType, never>>
|
|
7601
|
+
: {});
|
|
7602
|
+
|
|
7603
|
+
/**
|
|
7604
|
+
Returns a boolean for whether the given type is `never`.
|
|
7605
|
+
|
|
7606
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
7607
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
7608
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
7609
|
+
|
|
7610
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
7611
|
+
|
|
7612
|
+
@example
|
|
7613
|
+
```
|
|
7614
|
+
import type {IsNever, And} from 'type-fest';
|
|
7615
|
+
|
|
7616
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
7617
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
7618
|
+
And<
|
|
7619
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
7620
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
7621
|
+
>;
|
|
7622
|
+
|
|
7623
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
7624
|
+
AreStringsEqual<I, O> extends true
|
|
7625
|
+
? never
|
|
7626
|
+
: void;
|
|
7627
|
+
|
|
7628
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
7629
|
+
if (input === output) {
|
|
7630
|
+
process.exit(0);
|
|
7631
|
+
}
|
|
7632
|
+
}
|
|
7633
|
+
|
|
7634
|
+
endIfEqual('abc', 'abc');
|
|
7635
|
+
//=> never
|
|
7636
|
+
|
|
7637
|
+
endIfEqual('abc', '123');
|
|
7638
|
+
//=> void
|
|
7639
|
+
```
|
|
7640
|
+
|
|
7641
|
+
@category Type Guard
|
|
7642
|
+
@category Utilities
|
|
7643
|
+
*/
|
|
7644
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
7645
|
+
|
|
7646
|
+
/**
|
|
7647
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
7648
|
+
|
|
7649
|
+
@see {@link IsNever}
|
|
7650
|
+
|
|
7651
|
+
@example
|
|
7652
|
+
```
|
|
7653
|
+
import type {IfNever} from 'type-fest';
|
|
7654
|
+
|
|
7655
|
+
type ShouldBeTrue = IfNever<never>;
|
|
7656
|
+
//=> true
|
|
7657
|
+
|
|
7658
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
7659
|
+
//=> 'bar'
|
|
7660
|
+
```
|
|
7661
|
+
|
|
7662
|
+
@category Type Guard
|
|
7663
|
+
@category Utilities
|
|
7664
|
+
*/
|
|
7665
|
+
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
7666
|
+
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
7667
|
+
);
|
|
7668
|
+
|
|
7669
|
+
/**
|
|
7670
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
7671
|
+
|
|
7672
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
7673
|
+
|
|
7674
|
+
@example
|
|
7675
|
+
```
|
|
7676
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
7677
|
+
|
|
7678
|
+
interface Example {
|
|
7679
|
+
a: string;
|
|
7680
|
+
b: string | number;
|
|
7681
|
+
c?: string;
|
|
7682
|
+
d: {};
|
|
7683
|
+
}
|
|
7684
|
+
|
|
7685
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
7686
|
+
//=> 'a'
|
|
7687
|
+
```
|
|
7688
|
+
|
|
7689
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
7690
|
+
|
|
7691
|
+
@example
|
|
7692
|
+
```
|
|
7693
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
7694
|
+
|
|
7695
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
7696
|
+
//=> 'a' | 'c'
|
|
7697
|
+
```
|
|
7698
|
+
|
|
7699
|
+
@category Object
|
|
7700
|
+
*/
|
|
7701
|
+
type ConditionalKeys<Base, Condition> =
|
|
7702
|
+
{
|
|
7703
|
+
// Map through all the keys of the given base type.
|
|
7704
|
+
[Key in keyof Base]-?:
|
|
7705
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
7706
|
+
Base[Key] extends Condition
|
|
7707
|
+
// Retain this key
|
|
7708
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
7709
|
+
? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
|
|
7710
|
+
// Discard this key since the condition fails.
|
|
7711
|
+
: never;
|
|
7712
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
7713
|
+
}[keyof Base];
|
|
7714
|
+
|
|
7715
|
+
/**
|
|
7716
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
7717
|
+
|
|
7718
|
+
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.
|
|
7719
|
+
|
|
7720
|
+
@example
|
|
7721
|
+
```
|
|
7722
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
7723
|
+
|
|
7724
|
+
class Awesome {
|
|
7725
|
+
name: string;
|
|
7726
|
+
successes: number;
|
|
7727
|
+
failures: bigint;
|
|
7728
|
+
|
|
7729
|
+
run() {}
|
|
7730
|
+
}
|
|
7731
|
+
|
|
7732
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
7733
|
+
//=> {run: () => void}
|
|
7734
|
+
```
|
|
7735
|
+
|
|
7736
|
+
@example
|
|
7737
|
+
```
|
|
7738
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
7739
|
+
|
|
7740
|
+
interface Example {
|
|
7741
|
+
a: string;
|
|
7742
|
+
b: string | number;
|
|
7743
|
+
c: () => void;
|
|
7744
|
+
d: {};
|
|
7745
|
+
}
|
|
7746
|
+
|
|
7747
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
7748
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
7749
|
+
```
|
|
7750
|
+
|
|
7751
|
+
@category Object
|
|
7752
|
+
*/
|
|
7753
|
+
type ConditionalExcept<Base, Condition> = Except<
|
|
7754
|
+
Base,
|
|
7755
|
+
ConditionalKeys<Base, Condition>
|
|
7756
|
+
>;
|
|
7757
|
+
|
|
7758
|
+
/**
|
|
7759
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
7760
|
+
* can either be a REST module or a host module.
|
|
7761
|
+
* This type is recursive, so it can describe nested modules.
|
|
7762
|
+
*/
|
|
7763
|
+
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
|
|
7764
|
+
[key: string]: Descriptors | PublicMetadata | any;
|
|
7765
|
+
};
|
|
7766
|
+
/**
|
|
7767
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
7768
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
7769
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
7770
|
+
* do not match the given host (as they will not work with the given host).
|
|
7771
|
+
*/
|
|
7772
|
+
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
|
|
7773
|
+
done: T;
|
|
7774
|
+
recurse: T extends {
|
|
7775
|
+
__type: typeof SERVICE_PLUGIN_ERROR_TYPE;
|
|
7776
|
+
} ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
|
|
7777
|
+
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
|
|
7778
|
+
-1,
|
|
7779
|
+
0,
|
|
7780
|
+
1,
|
|
7781
|
+
2,
|
|
7782
|
+
3,
|
|
7783
|
+
4,
|
|
7784
|
+
5
|
|
7785
|
+
][Depth]> : never;
|
|
7786
|
+
}, EmptyObject>;
|
|
7787
|
+
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
7788
|
+
type PublicMetadata = {
|
|
7789
|
+
PACKAGE_NAME?: string;
|
|
7790
|
+
};
|
|
7791
|
+
|
|
7792
|
+
declare global {
|
|
7793
|
+
interface ContextualClient {
|
|
7794
|
+
}
|
|
7795
|
+
}
|
|
7796
|
+
/**
|
|
7797
|
+
* A type used to create concerete types from SDK descriptors in
|
|
7798
|
+
* case a contextual client is available.
|
|
7799
|
+
*/
|
|
7800
|
+
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
7801
|
+
host: Host;
|
|
7802
|
+
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
7803
|
+
|
|
5190
7804
|
interface Task {
|
|
5191
7805
|
/**
|
|
5192
7806
|
* Task ID.
|
|
@@ -5921,13 +8535,13 @@ declare const onTaskDeleted$1: EventDefinition<TaskDeletedEnvelope, "wix.crm.tas
|
|
|
5921
8535
|
|
|
5922
8536
|
declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
|
|
5923
8537
|
|
|
5924
|
-
declare const createTask: BuildRESTFunction<typeof createTask$1> & typeof createTask$1
|
|
5925
|
-
declare const getTask: BuildRESTFunction<typeof getTask$1> & typeof getTask$1
|
|
5926
|
-
declare const updateTask: BuildRESTFunction<typeof updateTask$1> & typeof updateTask$1
|
|
5927
|
-
declare const deleteTask: BuildRESTFunction<typeof deleteTask$1> & typeof deleteTask$1
|
|
5928
|
-
declare const queryTasks: BuildRESTFunction<typeof queryTasks$1> & typeof queryTasks$1
|
|
5929
|
-
declare const countTasks: BuildRESTFunction<typeof countTasks$1> & typeof countTasks$1
|
|
5930
|
-
declare const moveTaskAfter: BuildRESTFunction<typeof moveTaskAfter$1> & typeof moveTaskAfter$1
|
|
8538
|
+
declare const createTask: MaybeContext<BuildRESTFunction<typeof createTask$1> & typeof createTask$1>;
|
|
8539
|
+
declare const getTask: MaybeContext<BuildRESTFunction<typeof getTask$1> & typeof getTask$1>;
|
|
8540
|
+
declare const updateTask: MaybeContext<BuildRESTFunction<typeof updateTask$1> & typeof updateTask$1>;
|
|
8541
|
+
declare const deleteTask: MaybeContext<BuildRESTFunction<typeof deleteTask$1> & typeof deleteTask$1>;
|
|
8542
|
+
declare const queryTasks: MaybeContext<BuildRESTFunction<typeof queryTasks$1> & typeof queryTasks$1>;
|
|
8543
|
+
declare const countTasks: MaybeContext<BuildRESTFunction<typeof countTasks$1> & typeof countTasks$1>;
|
|
8544
|
+
declare const moveTaskAfter: MaybeContext<BuildRESTFunction<typeof moveTaskAfter$1> & typeof moveTaskAfter$1>;
|
|
5931
8545
|
|
|
5932
8546
|
type _publicOnTaskOverdueType = typeof onTaskOverdue$1;
|
|
5933
8547
|
/**
|