@wix/notifications 1.0.46 → 1.0.48
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/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/build/es/index.js +1 -0
- package/build/es/index.js.map +1 -0
- package/build/es/meta.js +1 -0
- package/build/es/meta.js.map +1 -0
- package/build/es/package.json +3 -0
- package/meta/package.json +1 -5
- package/package.json +20 -17
- package/build/cjs/context.d.ts +0 -2
- package/build/cjs/context.js +0 -28
- package/build/es/context.d.ts +0 -2
- package/build/es/context.js +0 -2
- package/context/package.json +0 -7
- package/type-bundles/context.bundle.d.ts +0 -1145
- package/type-bundles/index.bundle.d.ts +0 -1145
- package/type-bundles/meta.bundle.d.ts +0 -233
|
@@ -1,1145 +0,0 @@
|
|
|
1
|
-
type HostModule$1<T, H extends Host$1> = {
|
|
2
|
-
__type: 'host';
|
|
3
|
-
create(host: H): T;
|
|
4
|
-
};
|
|
5
|
-
type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
|
|
6
|
-
type Host$1<Environment = unknown> = {
|
|
7
|
-
channel: {
|
|
8
|
-
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
9
|
-
disconnect: () => void;
|
|
10
|
-
} | Promise<{
|
|
11
|
-
disconnect: () => void;
|
|
12
|
-
}>;
|
|
13
|
-
};
|
|
14
|
-
environment?: Environment;
|
|
15
|
-
/**
|
|
16
|
-
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
17
|
-
*/
|
|
18
|
-
apiBaseUrl?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Possible data to be provided by every host, for cross cutting concerns
|
|
21
|
-
* like internationalization, billing, etc.
|
|
22
|
-
*/
|
|
23
|
-
essentials?: {
|
|
24
|
-
/**
|
|
25
|
-
* The language of the currently viewed session
|
|
26
|
-
*/
|
|
27
|
-
language?: string;
|
|
28
|
-
/**
|
|
29
|
-
* The locale of the currently viewed session
|
|
30
|
-
*/
|
|
31
|
-
locale?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Any headers that should be passed through to the API requests
|
|
34
|
-
*/
|
|
35
|
-
passThroughHeaders?: Record<string, string>;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
|
|
40
|
-
interface HttpClient$1 {
|
|
41
|
-
request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
|
|
42
|
-
fetchWithAuth: typeof fetch;
|
|
43
|
-
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
44
|
-
getActiveToken?: () => string | undefined;
|
|
45
|
-
}
|
|
46
|
-
type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
|
|
47
|
-
type HttpResponse$1<T = any> = {
|
|
48
|
-
data: T;
|
|
49
|
-
status: number;
|
|
50
|
-
statusText: string;
|
|
51
|
-
headers: any;
|
|
52
|
-
request?: any;
|
|
53
|
-
};
|
|
54
|
-
type RequestOptions$1<_TResponse = any, Data = any> = {
|
|
55
|
-
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
56
|
-
url: string;
|
|
57
|
-
data?: Data;
|
|
58
|
-
params?: URLSearchParams;
|
|
59
|
-
} & APIMetadata$1;
|
|
60
|
-
type APIMetadata$1 = {
|
|
61
|
-
methodFqn?: string;
|
|
62
|
-
entityFqdn?: string;
|
|
63
|
-
packageName?: string;
|
|
64
|
-
};
|
|
65
|
-
type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
|
|
66
|
-
type EventDefinition$1<Payload = unknown, Type extends string = string> = {
|
|
67
|
-
__type: 'event-definition';
|
|
68
|
-
type: Type;
|
|
69
|
-
isDomainEvent?: boolean;
|
|
70
|
-
transformations?: (envelope: unknown) => Payload;
|
|
71
|
-
__payload: Payload;
|
|
72
|
-
};
|
|
73
|
-
declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
|
|
74
|
-
type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
|
|
75
|
-
type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
|
|
76
|
-
|
|
77
|
-
type ServicePluginMethodInput$1 = {
|
|
78
|
-
request: any;
|
|
79
|
-
metadata: any;
|
|
80
|
-
};
|
|
81
|
-
type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
|
|
82
|
-
type ServicePluginMethodMetadata$1 = {
|
|
83
|
-
name: string;
|
|
84
|
-
primaryHttpMappingPath: string;
|
|
85
|
-
transformations: {
|
|
86
|
-
fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
|
|
87
|
-
toREST: (...args: unknown[]) => unknown;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
|
|
91
|
-
__type: 'service-plugin-definition';
|
|
92
|
-
componentType: string;
|
|
93
|
-
methods: ServicePluginMethodMetadata$1[];
|
|
94
|
-
__contract: Contract;
|
|
95
|
-
};
|
|
96
|
-
declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
|
|
97
|
-
type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
|
|
98
|
-
declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
|
|
99
|
-
|
|
100
|
-
type RequestContext$1 = {
|
|
101
|
-
isSSR: boolean;
|
|
102
|
-
host: string;
|
|
103
|
-
protocol?: string;
|
|
104
|
-
};
|
|
105
|
-
type ResponseTransformer$1 = (data: any, headers?: any) => any;
|
|
106
|
-
/**
|
|
107
|
-
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
108
|
-
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
109
|
-
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
110
|
-
*/
|
|
111
|
-
type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
112
|
-
type AmbassadorRequestOptions$1<T = any> = {
|
|
113
|
-
_?: T;
|
|
114
|
-
url?: string;
|
|
115
|
-
method?: Method$1;
|
|
116
|
-
params?: any;
|
|
117
|
-
data?: any;
|
|
118
|
-
transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
|
|
119
|
-
};
|
|
120
|
-
type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
|
|
121
|
-
__isAmbassador: boolean;
|
|
122
|
-
};
|
|
123
|
-
type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
|
|
124
|
-
type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
125
|
-
|
|
126
|
-
declare global {
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
128
|
-
interface SymbolConstructor {
|
|
129
|
-
readonly observable: symbol;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
declare const emptyObjectSymbol$1: unique symbol;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
Represents a strictly empty plain object, the `{}` value.
|
|
137
|
-
|
|
138
|
-
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
|
|
139
|
-
|
|
140
|
-
@example
|
|
141
|
-
```
|
|
142
|
-
import type {EmptyObject} from 'type-fest';
|
|
143
|
-
|
|
144
|
-
// The following illustrates the problem with `{}`.
|
|
145
|
-
const foo1: {} = {}; // Pass
|
|
146
|
-
const foo2: {} = []; // Pass
|
|
147
|
-
const foo3: {} = 42; // Pass
|
|
148
|
-
const foo4: {} = {a: 1}; // Pass
|
|
149
|
-
|
|
150
|
-
// With `EmptyObject` only the first case is valid.
|
|
151
|
-
const bar1: EmptyObject = {}; // Pass
|
|
152
|
-
const bar2: EmptyObject = 42; // Fail
|
|
153
|
-
const bar3: EmptyObject = []; // Fail
|
|
154
|
-
const bar4: EmptyObject = {a: 1}; // Fail
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
|
|
158
|
-
|
|
159
|
-
@category Object
|
|
160
|
-
*/
|
|
161
|
-
type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
Returns a boolean for whether the two given types are equal.
|
|
165
|
-
|
|
166
|
-
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
167
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
168
|
-
|
|
169
|
-
Use-cases:
|
|
170
|
-
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
171
|
-
|
|
172
|
-
@example
|
|
173
|
-
```
|
|
174
|
-
import type {IsEqual} from 'type-fest';
|
|
175
|
-
|
|
176
|
-
// This type returns a boolean for whether the given array includes the given item.
|
|
177
|
-
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
178
|
-
type Includes<Value extends readonly any[], Item> =
|
|
179
|
-
Value extends readonly [Value[0], ...infer rest]
|
|
180
|
-
? IsEqual<Value[0], Item> extends true
|
|
181
|
-
? true
|
|
182
|
-
: Includes<rest, Item>
|
|
183
|
-
: false;
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
@category Type Guard
|
|
187
|
-
@category Utilities
|
|
188
|
-
*/
|
|
189
|
-
type IsEqual$1<A, B> =
|
|
190
|
-
(<G>() => G extends A ? 1 : 2) extends
|
|
191
|
-
(<G>() => G extends B ? 1 : 2)
|
|
192
|
-
? true
|
|
193
|
-
: false;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
Filter out keys from an object.
|
|
197
|
-
|
|
198
|
-
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
199
|
-
Returns `never` if `Key` extends `Exclude`.
|
|
200
|
-
Returns `Key` otherwise.
|
|
201
|
-
|
|
202
|
-
@example
|
|
203
|
-
```
|
|
204
|
-
type Filtered = Filter<'foo', 'foo'>;
|
|
205
|
-
//=> never
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
@example
|
|
209
|
-
```
|
|
210
|
-
type Filtered = Filter<'bar', string>;
|
|
211
|
-
//=> never
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
@example
|
|
215
|
-
```
|
|
216
|
-
type Filtered = Filter<'bar', 'foo'>;
|
|
217
|
-
//=> 'bar'
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
@see {Except}
|
|
221
|
-
*/
|
|
222
|
-
type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
223
|
-
|
|
224
|
-
type ExceptOptions$1 = {
|
|
225
|
-
/**
|
|
226
|
-
Disallow assigning non-specified properties.
|
|
227
|
-
|
|
228
|
-
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
229
|
-
|
|
230
|
-
@default false
|
|
231
|
-
*/
|
|
232
|
-
requireExactProps?: boolean;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
Create a type from an object type without certain keys.
|
|
237
|
-
|
|
238
|
-
We recommend setting the `requireExactProps` option to `true`.
|
|
239
|
-
|
|
240
|
-
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
241
|
-
|
|
242
|
-
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
243
|
-
|
|
244
|
-
@example
|
|
245
|
-
```
|
|
246
|
-
import type {Except} from 'type-fest';
|
|
247
|
-
|
|
248
|
-
type Foo = {
|
|
249
|
-
a: number;
|
|
250
|
-
b: string;
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
type FooWithoutA = Except<Foo, 'a'>;
|
|
254
|
-
//=> {b: string}
|
|
255
|
-
|
|
256
|
-
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
257
|
-
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
258
|
-
|
|
259
|
-
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
260
|
-
//=> {a: number} & Partial<Record<"b", never>>
|
|
261
|
-
|
|
262
|
-
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
263
|
-
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
@category Object
|
|
267
|
-
*/
|
|
268
|
-
type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
|
|
269
|
-
[KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
|
|
270
|
-
} & (Options['requireExactProps'] extends true
|
|
271
|
-
? Partial<Record<KeysType, never>>
|
|
272
|
-
: {});
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
276
|
-
|
|
277
|
-
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
278
|
-
|
|
279
|
-
@example
|
|
280
|
-
```
|
|
281
|
-
import type {ConditionalKeys} from 'type-fest';
|
|
282
|
-
|
|
283
|
-
interface Example {
|
|
284
|
-
a: string;
|
|
285
|
-
b: string | number;
|
|
286
|
-
c?: string;
|
|
287
|
-
d: {};
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
291
|
-
//=> 'a'
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
295
|
-
|
|
296
|
-
@example
|
|
297
|
-
```
|
|
298
|
-
import type {ConditionalKeys} from 'type-fest';
|
|
299
|
-
|
|
300
|
-
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
301
|
-
//=> 'a' | 'c'
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
@category Object
|
|
305
|
-
*/
|
|
306
|
-
type ConditionalKeys$1<Base, Condition> = NonNullable<
|
|
307
|
-
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
308
|
-
{
|
|
309
|
-
// Map through all the keys of the given base type.
|
|
310
|
-
[Key in keyof Base]:
|
|
311
|
-
// Pick only keys with types extending the given `Condition` type.
|
|
312
|
-
Base[Key] extends Condition
|
|
313
|
-
// Retain this key since the condition passes.
|
|
314
|
-
? Key
|
|
315
|
-
// Discard this key since the condition fails.
|
|
316
|
-
: never;
|
|
317
|
-
|
|
318
|
-
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
319
|
-
}[keyof Base]
|
|
320
|
-
>;
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
Exclude keys from a shape that matches the given `Condition`.
|
|
324
|
-
|
|
325
|
-
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
|
|
326
|
-
|
|
327
|
-
@example
|
|
328
|
-
```
|
|
329
|
-
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
330
|
-
|
|
331
|
-
class Awesome {
|
|
332
|
-
name: string;
|
|
333
|
-
successes: number;
|
|
334
|
-
failures: bigint;
|
|
335
|
-
|
|
336
|
-
run() {}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
340
|
-
//=> {run: () => void}
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
@example
|
|
344
|
-
```
|
|
345
|
-
import type {ConditionalExcept} from 'type-fest';
|
|
346
|
-
|
|
347
|
-
interface Example {
|
|
348
|
-
a: string;
|
|
349
|
-
b: string | number;
|
|
350
|
-
c: () => void;
|
|
351
|
-
d: {};
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
355
|
-
//=> {b: string | number; c: () => void; d: {}}
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
@category Object
|
|
359
|
-
*/
|
|
360
|
-
type ConditionalExcept$1<Base, Condition> = Except$1<
|
|
361
|
-
Base,
|
|
362
|
-
ConditionalKeys$1<Base, Condition>
|
|
363
|
-
>;
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Descriptors are objects that describe the API of a module, and the module
|
|
367
|
-
* can either be a REST module or a host module.
|
|
368
|
-
* This type is recursive, so it can describe nested modules.
|
|
369
|
-
*/
|
|
370
|
-
type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$1<any> | ServicePluginDefinition$1<any> | {
|
|
371
|
-
[key: string]: Descriptors$1 | PublicMetadata$1 | any;
|
|
372
|
-
};
|
|
373
|
-
/**
|
|
374
|
-
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
375
|
-
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
376
|
-
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
377
|
-
* do not match the given host (as they will not work with the given host).
|
|
378
|
-
*/
|
|
379
|
-
type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
|
|
380
|
-
done: T;
|
|
381
|
-
recurse: T extends {
|
|
382
|
-
__type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
|
|
383
|
-
} ? 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<{
|
|
384
|
-
[Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
|
|
385
|
-
-1,
|
|
386
|
-
0,
|
|
387
|
-
1,
|
|
388
|
-
2,
|
|
389
|
-
3,
|
|
390
|
-
4,
|
|
391
|
-
5
|
|
392
|
-
][Depth]> : never;
|
|
393
|
-
}, EmptyObject$1>;
|
|
394
|
-
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
395
|
-
type PublicMetadata$1 = {
|
|
396
|
-
PACKAGE_NAME?: string;
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
declare global {
|
|
400
|
-
interface ContextualClient {
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* A type used to create concerete types from SDK descriptors in
|
|
405
|
-
* case a contextual client is available.
|
|
406
|
-
*/
|
|
407
|
-
type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
|
|
408
|
-
host: Host$1;
|
|
409
|
-
} ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
|
|
410
|
-
|
|
411
|
-
interface Public_notification {
|
|
412
|
-
/** Notification ID. */
|
|
413
|
-
_id?: string | null;
|
|
414
|
-
}
|
|
415
|
-
interface PublicNotifyRequest extends PublicNotifyRequestRecipientsFilterOneOf, PublicNotifyRequestActionTargetOneOf {
|
|
416
|
-
/** Send to [site contributors]((https://support.wix.com/en/article/roles-permissions-overview)). This includes site administrators, website managers, and back office managers. */
|
|
417
|
-
toSiteContributors?: ToSiteContributors;
|
|
418
|
-
/** Send to [site contacts](https://support.wix.com/en/article/about-your-contact-list). */
|
|
419
|
-
toContacts?: ToContacts;
|
|
420
|
-
/** URL to navigate to when the `action` text is clicked. */
|
|
421
|
-
targetUrl?: string | null;
|
|
422
|
-
/** Dashboard page to open when the notification action is clicked. */
|
|
423
|
-
targetDashboardPage?: DashboardPages;
|
|
424
|
-
/** Title of the notification. Max: 512 characters. */
|
|
425
|
-
title?: string | null;
|
|
426
|
-
/**
|
|
427
|
-
* Body of the notification. This contains the main content of the notification.
|
|
428
|
-
* Max: 512 characters
|
|
429
|
-
*/
|
|
430
|
-
body?: string | null;
|
|
431
|
-
/** Title of the notification action. Clicking the action refers the user to a target URL or a dashboard page. */
|
|
432
|
-
action?: string | null;
|
|
433
|
-
/**
|
|
434
|
-
* Channel through which users receive the notification.
|
|
435
|
-
* - `"Mobile"`: Sends the notification to the Wix App.
|
|
436
|
-
* - `"Dashboard"`: Sends the notification to the collaborator's Wix Dashboard.
|
|
437
|
-
* - `"Browser"`: Sends the notification to the collaborator's browser.
|
|
438
|
-
*/
|
|
439
|
-
channels?: Channel[];
|
|
440
|
-
}
|
|
441
|
-
/** @oneof */
|
|
442
|
-
interface PublicNotifyRequestRecipientsFilterOneOf {
|
|
443
|
-
/** Send to [site contributors]((https://support.wix.com/en/article/roles-permissions-overview)). This includes site administrators, website managers, and back office managers. */
|
|
444
|
-
toSiteContributors?: ToSiteContributors;
|
|
445
|
-
/** Send to [site contacts](https://support.wix.com/en/article/about-your-contact-list). */
|
|
446
|
-
toContacts?: ToContacts;
|
|
447
|
-
}
|
|
448
|
-
/** @oneof */
|
|
449
|
-
interface PublicNotifyRequestActionTargetOneOf {
|
|
450
|
-
/** URL to navigate to when the `action` text is clicked. */
|
|
451
|
-
targetUrl?: string | null;
|
|
452
|
-
/** Dashboard page to open when the notification action is clicked. */
|
|
453
|
-
targetDashboardPage?: DashboardPages;
|
|
454
|
-
}
|
|
455
|
-
interface ToSiteContributors {
|
|
456
|
-
/**
|
|
457
|
-
* Role assigned to site contributors. Only contributors with the specified roles receive the notification:
|
|
458
|
-
* - `"All_Contributors"`: All site collaborators (default).
|
|
459
|
-
* - `"Owner"`: Site owner only.
|
|
460
|
-
*/
|
|
461
|
-
withRole?: Role;
|
|
462
|
-
}
|
|
463
|
-
declare enum Role {
|
|
464
|
-
/** All site contributors. */
|
|
465
|
-
All_Contributors = "All_Contributors",
|
|
466
|
-
/** Site owner only. */
|
|
467
|
-
Owner = "Owner"
|
|
468
|
-
}
|
|
469
|
-
interface ToContacts {
|
|
470
|
-
/** Contacts that receive the notification. */
|
|
471
|
-
contactIds?: string[];
|
|
472
|
-
}
|
|
473
|
-
interface ToTopicsSubscribers {
|
|
474
|
-
/** Notification topics to which the recipients have subscribed. Only contacts who subscribed to the specified topics receive the notification. */
|
|
475
|
-
topics?: string[];
|
|
476
|
-
/** Excluded contact IDs. Contacts with these IDs don't receive the notification. */
|
|
477
|
-
excludedContactIds?: string[];
|
|
478
|
-
}
|
|
479
|
-
declare enum Channel {
|
|
480
|
-
/** No default channel. */
|
|
481
|
-
Undefined = "Undefined",
|
|
482
|
-
/** Site dashboard. */
|
|
483
|
-
Dashboard = "Dashboard",
|
|
484
|
-
/** [Wix Owner](https://www.wix.com/mobile/wix-app) mobile app. */
|
|
485
|
-
Mobile = "Mobile",
|
|
486
|
-
/** Active browser. Supported on Chrome and Safari only. */
|
|
487
|
-
Browser = "Browser"
|
|
488
|
-
}
|
|
489
|
-
declare enum DashboardPages {
|
|
490
|
-
Undefined_Page = "Undefined_Page",
|
|
491
|
-
/** Site dashboard home. */
|
|
492
|
-
Home = "Home"
|
|
493
|
-
}
|
|
494
|
-
interface Empty {
|
|
495
|
-
}
|
|
496
|
-
interface NotifyOptions$1 extends PublicNotifyRequestRecipientsFilterOneOf, PublicNotifyRequestActionTargetOneOf {
|
|
497
|
-
/** Send to [site contributors]((https://support.wix.com/en/article/roles-permissions-overview)). This includes site administrators, website managers, and back office managers. */
|
|
498
|
-
toSiteContributors?: ToSiteContributors;
|
|
499
|
-
/** Send to [site contacts](https://support.wix.com/en/article/about-your-contact-list). */
|
|
500
|
-
toContacts?: ToContacts;
|
|
501
|
-
/** Title of the notification. Max: 512 characters. */
|
|
502
|
-
title?: string | null;
|
|
503
|
-
/**
|
|
504
|
-
* Title of the notification action. Clicking the action refers the user to a target URL or a dashboard page.
|
|
505
|
-
*
|
|
506
|
-
* Max: 512 characters.
|
|
507
|
-
*/
|
|
508
|
-
action?: string | null;
|
|
509
|
-
/** External URL to open when the notification action is clicked. */
|
|
510
|
-
targetUrl?: string | null;
|
|
511
|
-
/** Dashboard page to open when the notification action is clicked. */
|
|
512
|
-
targetDashboardPage?: DashboardPages;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
declare function notify$3(httpClient: HttpClient$1): NotifySignature$1;
|
|
516
|
-
interface NotifySignature$1 {
|
|
517
|
-
/**
|
|
518
|
-
* Sends a notification.
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
* The `notify()` function sends a [notification](https://support.wix.com/en/article/about-your-dashboard-notifications) to the specified recipients on the specified channels.
|
|
522
|
-
*
|
|
523
|
-
* List the the channels for the notification in the `channels` parameter .
|
|
524
|
-
*
|
|
525
|
-
* List the recipients for the notification in the `toContacts`, `toSiteContributors`, and `toTopicsSubscribers` parameters.
|
|
526
|
-
* @param - Notification options.
|
|
527
|
-
* @param - Body of the notification. This contains the main content of the notification.
|
|
528
|
-
* @param - Channel through which users receive the notification.
|
|
529
|
-
* - `"Mobile"`: Sends the notification to the Wix App.
|
|
530
|
-
* - `"Dashboard"`: Sends the notification to the collaborator's Wix Dashboard.
|
|
531
|
-
* - `"Browser"`: Sends the notification to the collaborator's browser.
|
|
532
|
-
* @returns Fulfilled when the send notification request is received.
|
|
533
|
-
*/
|
|
534
|
-
(body: string | null, channels: Channel[], options?: NotifyOptions$1 | undefined): Promise<void>;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
declare const notify$2: MaybeContext$1<BuildRESTFunction$1<typeof notify$3> & typeof notify$3>;
|
|
538
|
-
|
|
539
|
-
type context$1_Channel = Channel;
|
|
540
|
-
declare const context$1_Channel: typeof Channel;
|
|
541
|
-
type context$1_DashboardPages = DashboardPages;
|
|
542
|
-
declare const context$1_DashboardPages: typeof DashboardPages;
|
|
543
|
-
type context$1_Empty = Empty;
|
|
544
|
-
type context$1_PublicNotifyRequest = PublicNotifyRequest;
|
|
545
|
-
type context$1_PublicNotifyRequestActionTargetOneOf = PublicNotifyRequestActionTargetOneOf;
|
|
546
|
-
type context$1_PublicNotifyRequestRecipientsFilterOneOf = PublicNotifyRequestRecipientsFilterOneOf;
|
|
547
|
-
type context$1_Public_notification = Public_notification;
|
|
548
|
-
type context$1_Role = Role;
|
|
549
|
-
declare const context$1_Role: typeof Role;
|
|
550
|
-
type context$1_ToContacts = ToContacts;
|
|
551
|
-
type context$1_ToSiteContributors = ToSiteContributors;
|
|
552
|
-
type context$1_ToTopicsSubscribers = ToTopicsSubscribers;
|
|
553
|
-
declare namespace context$1 {
|
|
554
|
-
export { context$1_Channel as Channel, context$1_DashboardPages as DashboardPages, type context$1_Empty as Empty, type NotifyOptions$1 as NotifyOptions, type context$1_PublicNotifyRequest as PublicNotifyRequest, type context$1_PublicNotifyRequestActionTargetOneOf as PublicNotifyRequestActionTargetOneOf, type context$1_PublicNotifyRequestRecipientsFilterOneOf as PublicNotifyRequestRecipientsFilterOneOf, type context$1_Public_notification as Public_notification, context$1_Role as Role, type context$1_ToContacts as ToContacts, type context$1_ToSiteContributors as ToSiteContributors, type context$1_ToTopicsSubscribers as ToTopicsSubscribers, notify$2 as notify };
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
type HostModule<T, H extends Host> = {
|
|
558
|
-
__type: 'host';
|
|
559
|
-
create(host: H): T;
|
|
560
|
-
};
|
|
561
|
-
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
|
|
562
|
-
type Host<Environment = unknown> = {
|
|
563
|
-
channel: {
|
|
564
|
-
observeState(callback: (props: unknown, environment: Environment) => unknown): {
|
|
565
|
-
disconnect: () => void;
|
|
566
|
-
} | Promise<{
|
|
567
|
-
disconnect: () => void;
|
|
568
|
-
}>;
|
|
569
|
-
};
|
|
570
|
-
environment?: Environment;
|
|
571
|
-
/**
|
|
572
|
-
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
573
|
-
*/
|
|
574
|
-
apiBaseUrl?: string;
|
|
575
|
-
/**
|
|
576
|
-
* Possible data to be provided by every host, for cross cutting concerns
|
|
577
|
-
* like internationalization, billing, etc.
|
|
578
|
-
*/
|
|
579
|
-
essentials?: {
|
|
580
|
-
/**
|
|
581
|
-
* The language of the currently viewed session
|
|
582
|
-
*/
|
|
583
|
-
language?: string;
|
|
584
|
-
/**
|
|
585
|
-
* The locale of the currently viewed session
|
|
586
|
-
*/
|
|
587
|
-
locale?: string;
|
|
588
|
-
/**
|
|
589
|
-
* Any headers that should be passed through to the API requests
|
|
590
|
-
*/
|
|
591
|
-
passThroughHeaders?: Record<string, string>;
|
|
592
|
-
};
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
596
|
-
interface HttpClient {
|
|
597
|
-
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
598
|
-
fetchWithAuth: typeof fetch;
|
|
599
|
-
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
600
|
-
getActiveToken?: () => string | undefined;
|
|
601
|
-
}
|
|
602
|
-
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
603
|
-
type HttpResponse<T = any> = {
|
|
604
|
-
data: T;
|
|
605
|
-
status: number;
|
|
606
|
-
statusText: string;
|
|
607
|
-
headers: any;
|
|
608
|
-
request?: any;
|
|
609
|
-
};
|
|
610
|
-
type RequestOptions<_TResponse = any, Data = any> = {
|
|
611
|
-
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
612
|
-
url: string;
|
|
613
|
-
data?: Data;
|
|
614
|
-
params?: URLSearchParams;
|
|
615
|
-
} & APIMetadata;
|
|
616
|
-
type APIMetadata = {
|
|
617
|
-
methodFqn?: string;
|
|
618
|
-
entityFqdn?: string;
|
|
619
|
-
packageName?: string;
|
|
620
|
-
};
|
|
621
|
-
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
622
|
-
type EventDefinition<Payload = unknown, Type extends string = string> = {
|
|
623
|
-
__type: 'event-definition';
|
|
624
|
-
type: Type;
|
|
625
|
-
isDomainEvent?: boolean;
|
|
626
|
-
transformations?: (envelope: unknown) => Payload;
|
|
627
|
-
__payload: Payload;
|
|
628
|
-
};
|
|
629
|
-
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
|
|
630
|
-
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
|
|
631
|
-
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
|
|
632
|
-
|
|
633
|
-
type ServicePluginMethodInput = {
|
|
634
|
-
request: any;
|
|
635
|
-
metadata: any;
|
|
636
|
-
};
|
|
637
|
-
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
|
|
638
|
-
type ServicePluginMethodMetadata = {
|
|
639
|
-
name: string;
|
|
640
|
-
primaryHttpMappingPath: string;
|
|
641
|
-
transformations: {
|
|
642
|
-
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
|
|
643
|
-
toREST: (...args: unknown[]) => unknown;
|
|
644
|
-
};
|
|
645
|
-
};
|
|
646
|
-
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
|
|
647
|
-
__type: 'service-plugin-definition';
|
|
648
|
-
componentType: string;
|
|
649
|
-
methods: ServicePluginMethodMetadata[];
|
|
650
|
-
__contract: Contract;
|
|
651
|
-
};
|
|
652
|
-
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
|
|
653
|
-
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
|
|
654
|
-
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
|
|
655
|
-
|
|
656
|
-
type RequestContext = {
|
|
657
|
-
isSSR: boolean;
|
|
658
|
-
host: string;
|
|
659
|
-
protocol?: string;
|
|
660
|
-
};
|
|
661
|
-
type ResponseTransformer = (data: any, headers?: any) => any;
|
|
662
|
-
/**
|
|
663
|
-
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
664
|
-
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
665
|
-
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
666
|
-
*/
|
|
667
|
-
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
668
|
-
type AmbassadorRequestOptions<T = any> = {
|
|
669
|
-
_?: T;
|
|
670
|
-
url?: string;
|
|
671
|
-
method?: Method;
|
|
672
|
-
params?: any;
|
|
673
|
-
data?: any;
|
|
674
|
-
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
675
|
-
};
|
|
676
|
-
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
677
|
-
__isAmbassador: boolean;
|
|
678
|
-
};
|
|
679
|
-
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
|
|
680
|
-
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
681
|
-
|
|
682
|
-
declare global {
|
|
683
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
684
|
-
interface SymbolConstructor {
|
|
685
|
-
readonly observable: symbol;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
declare const emptyObjectSymbol: unique symbol;
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
Represents a strictly empty plain object, the `{}` value.
|
|
693
|
-
|
|
694
|
-
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)).
|
|
695
|
-
|
|
696
|
-
@example
|
|
697
|
-
```
|
|
698
|
-
import type {EmptyObject} from 'type-fest';
|
|
699
|
-
|
|
700
|
-
// The following illustrates the problem with `{}`.
|
|
701
|
-
const foo1: {} = {}; // Pass
|
|
702
|
-
const foo2: {} = []; // Pass
|
|
703
|
-
const foo3: {} = 42; // Pass
|
|
704
|
-
const foo4: {} = {a: 1}; // Pass
|
|
705
|
-
|
|
706
|
-
// With `EmptyObject` only the first case is valid.
|
|
707
|
-
const bar1: EmptyObject = {}; // Pass
|
|
708
|
-
const bar2: EmptyObject = 42; // Fail
|
|
709
|
-
const bar3: EmptyObject = []; // Fail
|
|
710
|
-
const bar4: EmptyObject = {a: 1}; // Fail
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
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}.
|
|
714
|
-
|
|
715
|
-
@category Object
|
|
716
|
-
*/
|
|
717
|
-
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
Returns a boolean for whether the two given types are equal.
|
|
721
|
-
|
|
722
|
-
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
723
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
724
|
-
|
|
725
|
-
Use-cases:
|
|
726
|
-
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
727
|
-
|
|
728
|
-
@example
|
|
729
|
-
```
|
|
730
|
-
import type {IsEqual} from 'type-fest';
|
|
731
|
-
|
|
732
|
-
// This type returns a boolean for whether the given array includes the given item.
|
|
733
|
-
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
734
|
-
type Includes<Value extends readonly any[], Item> =
|
|
735
|
-
Value extends readonly [Value[0], ...infer rest]
|
|
736
|
-
? IsEqual<Value[0], Item> extends true
|
|
737
|
-
? true
|
|
738
|
-
: Includes<rest, Item>
|
|
739
|
-
: false;
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
@category Type Guard
|
|
743
|
-
@category Utilities
|
|
744
|
-
*/
|
|
745
|
-
type IsEqual<A, B> =
|
|
746
|
-
(<G>() => G extends A ? 1 : 2) extends
|
|
747
|
-
(<G>() => G extends B ? 1 : 2)
|
|
748
|
-
? true
|
|
749
|
-
: false;
|
|
750
|
-
|
|
751
|
-
/**
|
|
752
|
-
Filter out keys from an object.
|
|
753
|
-
|
|
754
|
-
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
755
|
-
Returns `never` if `Key` extends `Exclude`.
|
|
756
|
-
Returns `Key` otherwise.
|
|
757
|
-
|
|
758
|
-
@example
|
|
759
|
-
```
|
|
760
|
-
type Filtered = Filter<'foo', 'foo'>;
|
|
761
|
-
//=> never
|
|
762
|
-
```
|
|
763
|
-
|
|
764
|
-
@example
|
|
765
|
-
```
|
|
766
|
-
type Filtered = Filter<'bar', string>;
|
|
767
|
-
//=> never
|
|
768
|
-
```
|
|
769
|
-
|
|
770
|
-
@example
|
|
771
|
-
```
|
|
772
|
-
type Filtered = Filter<'bar', 'foo'>;
|
|
773
|
-
//=> 'bar'
|
|
774
|
-
```
|
|
775
|
-
|
|
776
|
-
@see {Except}
|
|
777
|
-
*/
|
|
778
|
-
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
779
|
-
|
|
780
|
-
type ExceptOptions = {
|
|
781
|
-
/**
|
|
782
|
-
Disallow assigning non-specified properties.
|
|
783
|
-
|
|
784
|
-
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
785
|
-
|
|
786
|
-
@default false
|
|
787
|
-
*/
|
|
788
|
-
requireExactProps?: boolean;
|
|
789
|
-
};
|
|
790
|
-
|
|
791
|
-
/**
|
|
792
|
-
Create a type from an object type without certain keys.
|
|
793
|
-
|
|
794
|
-
We recommend setting the `requireExactProps` option to `true`.
|
|
795
|
-
|
|
796
|
-
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.
|
|
797
|
-
|
|
798
|
-
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)).
|
|
799
|
-
|
|
800
|
-
@example
|
|
801
|
-
```
|
|
802
|
-
import type {Except} from 'type-fest';
|
|
803
|
-
|
|
804
|
-
type Foo = {
|
|
805
|
-
a: number;
|
|
806
|
-
b: string;
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
type FooWithoutA = Except<Foo, 'a'>;
|
|
810
|
-
//=> {b: string}
|
|
811
|
-
|
|
812
|
-
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
813
|
-
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
814
|
-
|
|
815
|
-
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
816
|
-
//=> {a: number} & Partial<Record<"b", never>>
|
|
817
|
-
|
|
818
|
-
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
819
|
-
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
820
|
-
```
|
|
821
|
-
|
|
822
|
-
@category Object
|
|
823
|
-
*/
|
|
824
|
-
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
|
|
825
|
-
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
826
|
-
} & (Options['requireExactProps'] extends true
|
|
827
|
-
? Partial<Record<KeysType, never>>
|
|
828
|
-
: {});
|
|
829
|
-
|
|
830
|
-
/**
|
|
831
|
-
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
832
|
-
|
|
833
|
-
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
834
|
-
|
|
835
|
-
@example
|
|
836
|
-
```
|
|
837
|
-
import type {ConditionalKeys} from 'type-fest';
|
|
838
|
-
|
|
839
|
-
interface Example {
|
|
840
|
-
a: string;
|
|
841
|
-
b: string | number;
|
|
842
|
-
c?: string;
|
|
843
|
-
d: {};
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
847
|
-
//=> 'a'
|
|
848
|
-
```
|
|
849
|
-
|
|
850
|
-
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
851
|
-
|
|
852
|
-
@example
|
|
853
|
-
```
|
|
854
|
-
import type {ConditionalKeys} from 'type-fest';
|
|
855
|
-
|
|
856
|
-
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
857
|
-
//=> 'a' | 'c'
|
|
858
|
-
```
|
|
859
|
-
|
|
860
|
-
@category Object
|
|
861
|
-
*/
|
|
862
|
-
type ConditionalKeys<Base, Condition> = NonNullable<
|
|
863
|
-
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
864
|
-
{
|
|
865
|
-
// Map through all the keys of the given base type.
|
|
866
|
-
[Key in keyof Base]:
|
|
867
|
-
// Pick only keys with types extending the given `Condition` type.
|
|
868
|
-
Base[Key] extends Condition
|
|
869
|
-
// Retain this key since the condition passes.
|
|
870
|
-
? Key
|
|
871
|
-
// Discard this key since the condition fails.
|
|
872
|
-
: never;
|
|
873
|
-
|
|
874
|
-
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
875
|
-
}[keyof Base]
|
|
876
|
-
>;
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
Exclude keys from a shape that matches the given `Condition`.
|
|
880
|
-
|
|
881
|
-
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.
|
|
882
|
-
|
|
883
|
-
@example
|
|
884
|
-
```
|
|
885
|
-
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
886
|
-
|
|
887
|
-
class Awesome {
|
|
888
|
-
name: string;
|
|
889
|
-
successes: number;
|
|
890
|
-
failures: bigint;
|
|
891
|
-
|
|
892
|
-
run() {}
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
896
|
-
//=> {run: () => void}
|
|
897
|
-
```
|
|
898
|
-
|
|
899
|
-
@example
|
|
900
|
-
```
|
|
901
|
-
import type {ConditionalExcept} from 'type-fest';
|
|
902
|
-
|
|
903
|
-
interface Example {
|
|
904
|
-
a: string;
|
|
905
|
-
b: string | number;
|
|
906
|
-
c: () => void;
|
|
907
|
-
d: {};
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
911
|
-
//=> {b: string | number; c: () => void; d: {}}
|
|
912
|
-
```
|
|
913
|
-
|
|
914
|
-
@category Object
|
|
915
|
-
*/
|
|
916
|
-
type ConditionalExcept<Base, Condition> = Except<
|
|
917
|
-
Base,
|
|
918
|
-
ConditionalKeys<Base, Condition>
|
|
919
|
-
>;
|
|
920
|
-
|
|
921
|
-
/**
|
|
922
|
-
* Descriptors are objects that describe the API of a module, and the module
|
|
923
|
-
* can either be a REST module or a host module.
|
|
924
|
-
* This type is recursive, so it can describe nested modules.
|
|
925
|
-
*/
|
|
926
|
-
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
|
|
927
|
-
[key: string]: Descriptors | PublicMetadata | any;
|
|
928
|
-
};
|
|
929
|
-
/**
|
|
930
|
-
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
931
|
-
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
932
|
-
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
933
|
-
* do not match the given host (as they will not work with the given host).
|
|
934
|
-
*/
|
|
935
|
-
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
|
|
936
|
-
done: T;
|
|
937
|
-
recurse: T extends {
|
|
938
|
-
__type: typeof SERVICE_PLUGIN_ERROR_TYPE;
|
|
939
|
-
} ? 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<{
|
|
940
|
-
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
|
|
941
|
-
-1,
|
|
942
|
-
0,
|
|
943
|
-
1,
|
|
944
|
-
2,
|
|
945
|
-
3,
|
|
946
|
-
4,
|
|
947
|
-
5
|
|
948
|
-
][Depth]> : never;
|
|
949
|
-
}, EmptyObject>;
|
|
950
|
-
}[Depth extends -1 ? 'done' : 'recurse'];
|
|
951
|
-
type PublicMetadata = {
|
|
952
|
-
PACKAGE_NAME?: string;
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
declare global {
|
|
956
|
-
interface ContextualClient {
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
/**
|
|
960
|
-
* A type used to create concerete types from SDK descriptors in
|
|
961
|
-
* case a contextual client is available.
|
|
962
|
-
*/
|
|
963
|
-
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
964
|
-
host: Host;
|
|
965
|
-
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
966
|
-
|
|
967
|
-
interface Notification {
|
|
968
|
-
/** The id of the notification */
|
|
969
|
-
_id?: string;
|
|
970
|
-
}
|
|
971
|
-
interface NotifyRequest {
|
|
972
|
-
/**
|
|
973
|
-
* Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
974
|
-
* To obtain a notification template ID, create a notification template in your app's dashboard.
|
|
975
|
-
*/
|
|
976
|
-
notificationTemplateId: string;
|
|
977
|
-
/**
|
|
978
|
-
* Each key is a placeholder name you specify when creating a notification template.
|
|
979
|
-
* The value is an object containing the text to replace the placeholder in the notifications.
|
|
980
|
-
*/
|
|
981
|
-
dynamicValues?: Record<string, DynamicValue>;
|
|
982
|
-
}
|
|
983
|
-
interface DynamicValue extends DynamicValueOfTypeOneOf {
|
|
984
|
-
/** Text to be integrated into the notification. */
|
|
985
|
-
text?: string;
|
|
986
|
-
}
|
|
987
|
-
/** @oneof */
|
|
988
|
-
interface DynamicValueOfTypeOneOf {
|
|
989
|
-
/** Text to be integrated into the notification. */
|
|
990
|
-
text?: string;
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Money.
|
|
994
|
-
* Default format to use. Sufficiently compliant with majority of standards: w3c, ISO 4217, ISO 20022, ISO 8583:2003.
|
|
995
|
-
*/
|
|
996
|
-
interface Money {
|
|
997
|
-
/** Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. */
|
|
998
|
-
value?: string;
|
|
999
|
-
/** Currency code. Must be valid ISO 4217 currency code (e.g., USD). */
|
|
1000
|
-
currency?: string;
|
|
1001
|
-
/** Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative. */
|
|
1002
|
-
formattedValue?: string | null;
|
|
1003
|
-
}
|
|
1004
|
-
interface MapDynamicValue {
|
|
1005
|
-
/** items */
|
|
1006
|
-
items?: Record<string, DynamicValue>;
|
|
1007
|
-
}
|
|
1008
|
-
interface ArrayDynamicValue {
|
|
1009
|
-
/** items */
|
|
1010
|
-
items?: DynamicValue[];
|
|
1011
|
-
}
|
|
1012
|
-
interface AttachmentDynamicValue {
|
|
1013
|
-
/** file name */
|
|
1014
|
-
fileName?: string;
|
|
1015
|
-
/** download url */
|
|
1016
|
-
downloadUrl?: string;
|
|
1017
|
-
}
|
|
1018
|
-
interface NotifyResponse {
|
|
1019
|
-
/** ID of the batch of notifications triggered by one request. */
|
|
1020
|
-
notificationBatchId?: string;
|
|
1021
|
-
}
|
|
1022
|
-
interface NotifyByAppRequest {
|
|
1023
|
-
/** notification_template_id */
|
|
1024
|
-
notificationTemplateId?: string;
|
|
1025
|
-
/** app_def_id */
|
|
1026
|
-
appDefId?: string;
|
|
1027
|
-
/** dynamic_values */
|
|
1028
|
-
dynamicValues?: Record<string, DynamicValue>;
|
|
1029
|
-
/** template tenant */
|
|
1030
|
-
templateTenant?: string | null;
|
|
1031
|
-
/** overrides */
|
|
1032
|
-
overrides?: Overrides;
|
|
1033
|
-
/** channels content */
|
|
1034
|
-
channelsData?: ChannelsData;
|
|
1035
|
-
}
|
|
1036
|
-
interface Overrides {
|
|
1037
|
-
/** excluded_channels */
|
|
1038
|
-
excludedChannels?: TemplateChannel[];
|
|
1039
|
-
/** excluded_audiences */
|
|
1040
|
-
excludedAudiences?: ExcludedAudiences;
|
|
1041
|
-
/** content overrides */
|
|
1042
|
-
content?: ChannelsContent;
|
|
1043
|
-
}
|
|
1044
|
-
declare enum TemplateChannel {
|
|
1045
|
-
WEB_FEED = "WEB_FEED",
|
|
1046
|
-
MOBILE_FEED = "MOBILE_FEED",
|
|
1047
|
-
MOBILE_PUSH = "MOBILE_PUSH",
|
|
1048
|
-
BROWSER = "BROWSER",
|
|
1049
|
-
SMS = "SMS",
|
|
1050
|
-
EMAIL = "EMAIL",
|
|
1051
|
-
KAFKA = "KAFKA",
|
|
1052
|
-
VOICE = "VOICE"
|
|
1053
|
-
}
|
|
1054
|
-
interface ExcludedAudiences {
|
|
1055
|
-
/** audience_key */
|
|
1056
|
-
audienceKey?: string[];
|
|
1057
|
-
}
|
|
1058
|
-
interface ChannelsContent {
|
|
1059
|
-
/** mobile push override */
|
|
1060
|
-
mobileContent?: MobileContent;
|
|
1061
|
-
}
|
|
1062
|
-
interface MobileContent {
|
|
1063
|
-
/** title override of mobile push content */
|
|
1064
|
-
title?: string;
|
|
1065
|
-
/** body override of mobile push content */
|
|
1066
|
-
body?: string;
|
|
1067
|
-
}
|
|
1068
|
-
interface ChannelsData {
|
|
1069
|
-
/** email data */
|
|
1070
|
-
emailData?: EmailData;
|
|
1071
|
-
}
|
|
1072
|
-
interface EmailData {
|
|
1073
|
-
/** shoutout action config */
|
|
1074
|
-
shoutoutActionConfig?: Record<string, any> | null;
|
|
1075
|
-
}
|
|
1076
|
-
interface NotifyByAppResponse {
|
|
1077
|
-
/** notification_batch_id */
|
|
1078
|
-
notificationBatchId?: string;
|
|
1079
|
-
}
|
|
1080
|
-
interface ResolveRequest {
|
|
1081
|
-
/** template id */
|
|
1082
|
-
notificationTemplateId?: string;
|
|
1083
|
-
/** values */
|
|
1084
|
-
dynamicValues?: Record<string, DynamicValue>;
|
|
1085
|
-
}
|
|
1086
|
-
interface ResolveResponse {
|
|
1087
|
-
}
|
|
1088
|
-
interface NotifyResponseNonNullableFields {
|
|
1089
|
-
notificationBatchId: string;
|
|
1090
|
-
}
|
|
1091
|
-
interface NotifyOptions {
|
|
1092
|
-
/**
|
|
1093
|
-
* Each key is a placeholder name you specify when creating a notification template.
|
|
1094
|
-
* The value is an object containing the text to replace the placeholder in the notifications.
|
|
1095
|
-
*/
|
|
1096
|
-
dynamicValues?: Record<string, DynamicValue>;
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
declare function notify$1(httpClient: HttpClient): NotifySignature;
|
|
1100
|
-
interface NotifySignature {
|
|
1101
|
-
/**
|
|
1102
|
-
* Sends notifications based on the template and dynamic values provided.
|
|
1103
|
-
*
|
|
1104
|
-
* > **Note**: An app can call this endpoint up to 100,000 times per month for each site.
|
|
1105
|
-
*
|
|
1106
|
-
* When you [create a notification template](https://dev.wix.com/docs/rest/business-management/notifications/notifications/creating-a-notification-template), you are provided a notification template ID. Call the Notify endpoint with this ID as `notificationTemplateID` to trigger notifications based on that template.
|
|
1107
|
-
*
|
|
1108
|
-
* If the notification template contains placeholders for dynamic values, provide those values as key-value pairs in the `dynamicValues` array. The values you specify are incorporated in the notifications sent out.
|
|
1109
|
-
* @param - Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
1110
|
-
* To obtain a notification template ID, create a notification template in your app's dashboard.
|
|
1111
|
-
*/
|
|
1112
|
-
(notificationTemplateId: string, options?: NotifyOptions | undefined): Promise<NotifyResponse & NotifyResponseNonNullableFields>;
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
declare const notify: MaybeContext<BuildRESTFunction<typeof notify$1> & typeof notify$1>;
|
|
1116
|
-
|
|
1117
|
-
type context_ArrayDynamicValue = ArrayDynamicValue;
|
|
1118
|
-
type context_AttachmentDynamicValue = AttachmentDynamicValue;
|
|
1119
|
-
type context_ChannelsContent = ChannelsContent;
|
|
1120
|
-
type context_ChannelsData = ChannelsData;
|
|
1121
|
-
type context_DynamicValue = DynamicValue;
|
|
1122
|
-
type context_DynamicValueOfTypeOneOf = DynamicValueOfTypeOneOf;
|
|
1123
|
-
type context_EmailData = EmailData;
|
|
1124
|
-
type context_ExcludedAudiences = ExcludedAudiences;
|
|
1125
|
-
type context_MapDynamicValue = MapDynamicValue;
|
|
1126
|
-
type context_MobileContent = MobileContent;
|
|
1127
|
-
type context_Money = Money;
|
|
1128
|
-
type context_Notification = Notification;
|
|
1129
|
-
type context_NotifyByAppRequest = NotifyByAppRequest;
|
|
1130
|
-
type context_NotifyByAppResponse = NotifyByAppResponse;
|
|
1131
|
-
type context_NotifyOptions = NotifyOptions;
|
|
1132
|
-
type context_NotifyRequest = NotifyRequest;
|
|
1133
|
-
type context_NotifyResponse = NotifyResponse;
|
|
1134
|
-
type context_NotifyResponseNonNullableFields = NotifyResponseNonNullableFields;
|
|
1135
|
-
type context_Overrides = Overrides;
|
|
1136
|
-
type context_ResolveRequest = ResolveRequest;
|
|
1137
|
-
type context_ResolveResponse = ResolveResponse;
|
|
1138
|
-
type context_TemplateChannel = TemplateChannel;
|
|
1139
|
-
declare const context_TemplateChannel: typeof TemplateChannel;
|
|
1140
|
-
declare const context_notify: typeof notify;
|
|
1141
|
-
declare namespace context {
|
|
1142
|
-
export { type context_ArrayDynamicValue as ArrayDynamicValue, type context_AttachmentDynamicValue as AttachmentDynamicValue, type context_ChannelsContent as ChannelsContent, type context_ChannelsData as ChannelsData, type context_DynamicValue as DynamicValue, type context_DynamicValueOfTypeOneOf as DynamicValueOfTypeOneOf, type context_EmailData as EmailData, type context_ExcludedAudiences as ExcludedAudiences, type context_MapDynamicValue as MapDynamicValue, type context_MobileContent as MobileContent, type context_Money as Money, type context_Notification as Notification, type context_NotifyByAppRequest as NotifyByAppRequest, type context_NotifyByAppResponse as NotifyByAppResponse, type context_NotifyOptions as NotifyOptions, type context_NotifyRequest as NotifyRequest, type context_NotifyResponse as NotifyResponse, type context_NotifyResponseNonNullableFields as NotifyResponseNonNullableFields, type context_Overrides as Overrides, type context_ResolveRequest as ResolveRequest, type context_ResolveResponse as ResolveResponse, context_TemplateChannel as TemplateChannel, context_notify as notify };
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
export { context$1 as notifications, context as notificationsV3 };
|