@wix/user-management 1.0.0

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.
@@ -0,0 +1,909 @@
1
+ type HostModule<T, H extends Host> = {
2
+ __type: 'host';
3
+ create(host: H): T;
4
+ };
5
+ type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
6
+ type Host<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
+
43
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
44
+ interface HttpClient {
45
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
46
+ fetchWithAuth: typeof fetch;
47
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
48
+ getActiveToken?: () => string | undefined;
49
+ }
50
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
51
+ type HttpResponse<T = any> = {
52
+ data: T;
53
+ status: number;
54
+ statusText: string;
55
+ headers: any;
56
+ request?: any;
57
+ };
58
+ type RequestOptions<_TResponse = any, Data = any> = {
59
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
60
+ url: string;
61
+ data?: Data;
62
+ params?: URLSearchParams;
63
+ } & APIMetadata;
64
+ type APIMetadata = {
65
+ methodFqn?: string;
66
+ entityFqdn?: string;
67
+ packageName?: string;
68
+ };
69
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
70
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
71
+ __type: 'event-definition';
72
+ type: Type;
73
+ isDomainEvent?: boolean;
74
+ transformations?: (envelope: unknown) => Payload;
75
+ __payload: Payload;
76
+ };
77
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
78
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
79
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
80
+
81
+ type ServicePluginMethodInput = {
82
+ request: any;
83
+ metadata: any;
84
+ };
85
+ type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
86
+ type ServicePluginMethodMetadata = {
87
+ name: string;
88
+ primaryHttpMappingPath: string;
89
+ transformations: {
90
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput;
91
+ toREST: (...args: unknown[]) => unknown;
92
+ };
93
+ };
94
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
95
+ __type: 'service-plugin-definition';
96
+ componentType: string;
97
+ methods: ServicePluginMethodMetadata[];
98
+ __contract: Contract;
99
+ };
100
+ declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
101
+ type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
102
+ declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
103
+
104
+ type RequestContext = {
105
+ isSSR: boolean;
106
+ host: string;
107
+ protocol?: string;
108
+ };
109
+ type ResponseTransformer = (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 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
116
+ type AmbassadorRequestOptions<T = any> = {
117
+ _?: T;
118
+ url?: string;
119
+ method?: Method;
120
+ params?: any;
121
+ data?: any;
122
+ transformResponse?: ResponseTransformer | ResponseTransformer[];
123
+ };
124
+ type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
125
+ __isAmbassador: boolean;
126
+ };
127
+ type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
128
+ type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
129
+
130
+ declare global {
131
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
132
+ interface SymbolConstructor {
133
+ readonly observable: symbol;
134
+ }
135
+ }
136
+
137
+ declare const emptyObjectSymbol: 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 = {[emptyObjectSymbol]?: 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<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<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
227
+
228
+ type ExceptOptions = {
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<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
273
+ [KeyType in keyof ObjectType as Filter<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<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<T, TypeIfNever = true, TypeIfNotNever = false> = (
341
+ IsNever<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<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<Base[Key], IfNever<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<Base, Condition> = Except<
429
+ Base,
430
+ ConditionalKeys<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 = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
439
+ [key: string]: Descriptors | PublicMetadata | 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<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
448
+ done: T;
449
+ recurse: T extends {
450
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
451
+ } ? 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<{
452
+ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
453
+ -1,
454
+ 0,
455
+ 1,
456
+ 2,
457
+ 3,
458
+ 4,
459
+ 5
460
+ ][Depth]> : never;
461
+ }, EmptyObject>;
462
+ }[Depth extends -1 ? 'done' : 'recurse'];
463
+ type PublicMetadata = {
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<T extends Descriptors> = globalThis.ContextualClient extends {
476
+ host: Host;
477
+ } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
478
+
479
+ interface AccountV2 {
480
+ /** Account ID. */
481
+ accountId?: string;
482
+ }
483
+ interface GetUserAccountRequest {
484
+ /** the user id that his account we query */
485
+ userId?: string;
486
+ }
487
+ interface Account {
488
+ /** Account ID. */
489
+ accountId?: string;
490
+ /** Account slug - used in the free URL prefix */
491
+ slug?: string;
492
+ /** Account name (display) */
493
+ accountName?: string | null;
494
+ /**
495
+ * DEPRECATED field of account image
496
+ * @deprecated
497
+ */
498
+ accountImg?: string | null;
499
+ /** account status */
500
+ status?: AccountStatus;
501
+ /** account owner user id */
502
+ accountOwner?: string;
503
+ /** account extra properties */
504
+ accountProperties?: AccountProperties;
505
+ /** the account creation date */
506
+ dateCreated?: Date | null;
507
+ /** last time account was updated */
508
+ dateUpdated?: Date | null;
509
+ }
510
+ /** enum with all available statuses of account */
511
+ declare enum AccountStatus {
512
+ ACTIVE = "ACTIVE",
513
+ BLOCKED = "BLOCKED",
514
+ DELETED = "DELETED"
515
+ }
516
+ /** All relevant account properties */
517
+ interface AccountProperties {
518
+ /** Whether this account is a team account. */
519
+ isTeam?: boolean;
520
+ /**
521
+ * Account image (display)
522
+ * relevant mainly for CoBranded accounts
523
+ */
524
+ accountImg?: string | null;
525
+ /**
526
+ * the account banner (display)
527
+ * relevant mainly for CoBranded accounts
528
+ */
529
+ accountBanner?: string | null;
530
+ /**
531
+ * the account logo (display)
532
+ * wll be shown as the account logo in the UI (top right corner, contributor list etc..)
533
+ */
534
+ accountLogo?: string | null;
535
+ /**
536
+ * account co branding flag (if exists)
537
+ * an enum for CoBranding flag contains 4 possible options:
538
+ * None - the account is not CoBranded
539
+ * CoBranded - the account has a CoBranding flag
540
+ * CoBranded_Customer_New - the account is a contributor of a CoBranded account. This account was created because of the contributor invite
541
+ * CoBranded_Customer_Existing - the account is a contributor of a CoBranded account. This account was created before the invite of the contributor invite
542
+ */
543
+ coBranding?: CoBranding;
544
+ /** account's website URL (shown on co branding customers sites) */
545
+ websiteUrl?: string | null;
546
+ /** the id of the parent account of this account, if it has a parent */
547
+ parentAccountId?: string | null;
548
+ }
549
+ /** co branding flag options for account */
550
+ declare enum CoBranding {
551
+ None = "None",
552
+ CoBranded = "CoBranded",
553
+ CoBranded_Customer_New = "CoBranded_Customer_New",
554
+ CoBranded_Customer_Existing = "CoBranded_Customer_Existing"
555
+ }
556
+ interface GetUserAccountsRequest {
557
+ /** the user id that his accounts we query */
558
+ userId?: string;
559
+ /** Limited to max 20 at a single request */
560
+ paging?: Paging;
561
+ }
562
+ interface Paging {
563
+ /** Number of items to load. */
564
+ limit?: number | null;
565
+ /** Number of items to skip in the current sort order. */
566
+ offset?: number | null;
567
+ }
568
+ interface AccountsResponse {
569
+ accounts?: Account[];
570
+ }
571
+ interface GetMyUserAccountsRequest {
572
+ /** Limited to max 20 at a single request */
573
+ paging?: Paging;
574
+ }
575
+ interface GetAccountRequest {
576
+ /** the account id that it's data should be retrieved */
577
+ accountId?: string;
578
+ }
579
+ interface AccountResponse {
580
+ account?: Account;
581
+ }
582
+ interface GetMyAccountRequest {
583
+ }
584
+ interface GetAccountsRequest {
585
+ /** the account id to retrieve */
586
+ accountIds?: string[];
587
+ }
588
+ interface CreateAccountRequest {
589
+ /** The user to create under the new account, with the roles defined in `roles`. */
590
+ user: User;
591
+ /**
592
+ * Roles to be assigned to the user in the new account. To retrieve all available roles, call Get Roles Info in the Users API.
593
+ * Default: OWNER.
594
+ */
595
+ roles?: string[] | null;
596
+ }
597
+ /** A User to be created under an implicitly provided accountId: must have a unique email. */
598
+ interface User {
599
+ /** User's unique email address details. Required. */
600
+ email?: Email;
601
+ /** User's single sign on identity, when the user is identified via SSO authentication response token params, as specified by [OpenID Connect](https://openid.net/developers/how-connect-works/) (aka. OIDC) protocol. */
602
+ ssoIdentities?: SsoIdentity[];
603
+ /** Additional user details. */
604
+ userDetails?: UserDetails;
605
+ }
606
+ /** User's email address. */
607
+ interface Email {
608
+ /** User's email address. */
609
+ emailAddress?: string;
610
+ /** Whether the caller has verified the user's email address. */
611
+ isVerified?: boolean;
612
+ }
613
+ /** Single Sign On (aka. SSO) identity; user is identified via SSO authentication response token params, as specified by OpenID Connect (aka. OIDC) protocol */
614
+ interface SsoIdentity {
615
+ /** An SSO setting (URLs, clientId, secret, etc. as required by OIDC protocol) for a specific Identity-Provider (aka. IdP) for a specific Wix account. */
616
+ ssoId?: string;
617
+ /**
618
+ * User ID as stored in IdP. For example a "sub" claim of OIDC protocol,
619
+ * or any other alternative, specified by IdP (Identity Provider).
620
+ */
621
+ userId?: string;
622
+ }
623
+ /** additional user details */
624
+ interface UserDetails {
625
+ /** User's first name. */
626
+ firstName?: string | null;
627
+ /** User's last name. */
628
+ lastName?: string | null;
629
+ /** URL to location of user's profile picture. */
630
+ profilePictureUrl?: string | null;
631
+ /** User's preferred language in [ISO 639-1:2002](https://en.wikipedia.org/wiki/ISO_639-1) format. For example, "en", "es". */
632
+ language?: string | null;
633
+ /**
634
+ * Original Client IP from which a request was made.
635
+ * This is useful in case where a createUser API is called by some server call, which, in turn, has been called by some client from another IP.
636
+ * Wix checks this IP against the [OFAC sanctioned countries](https://ofac.treasury.gov/sanctions-programs-and-country-information).
637
+ */
638
+ clientIp?: string | null;
639
+ }
640
+ interface CreateAccountResponse {
641
+ /** The created account. */
642
+ account?: AccountV2;
643
+ }
644
+ interface CreateAccountForMyUserRequest {
645
+ /** the account name */
646
+ accountName?: string | null;
647
+ /** account image url */
648
+ accountImg?: string | null;
649
+ /** whether to mark the account as `studio` */
650
+ studio?: boolean;
651
+ }
652
+ interface CreateAccountTenantRequest {
653
+ slug?: string | null;
654
+ }
655
+ interface CreateAccountTenantResponse {
656
+ account?: AccountV2;
657
+ }
658
+ interface CreateAccountAndAssignUserRequest {
659
+ /** the user id for which we are creating the account */
660
+ userId?: string;
661
+ /** the user name of the user for which the account is created */
662
+ userName?: string;
663
+ /** the parent account of the created account */
664
+ parentAccountId?: string | null;
665
+ /** whether to mark the account as `studio` */
666
+ studio?: boolean;
667
+ }
668
+ interface UpdateAccountRequest {
669
+ /** the account id to update */
670
+ accountId?: string;
671
+ /**
672
+ * DEPRECATED field of image
673
+ * @deprecated
674
+ */
675
+ accountImg?: string | null;
676
+ /** optional - new account name */
677
+ accountName?: string | null;
678
+ /**
679
+ * the new properties for the account.
680
+ * can be passed partially - and only relevant fields will be updated
681
+ */
682
+ accountProperties?: AccountProperties;
683
+ }
684
+ interface UpdateParentAccountRequest extends UpdateParentAccountRequestUpdateOneOf {
685
+ /** Removes the parent account */
686
+ remove?: RemoveParent;
687
+ }
688
+ /** @oneof */
689
+ interface UpdateParentAccountRequestUpdateOneOf {
690
+ /** Removes the parent account */
691
+ remove?: RemoveParent;
692
+ }
693
+ interface RemoveParent {
694
+ }
695
+ interface UpdateParentAccountResponse {
696
+ newParentAccountId?: string | null;
697
+ }
698
+ interface DeleteAccountRequest {
699
+ /** the account id to delete */
700
+ accountId?: string;
701
+ /** will throw exception if trying to delete the account of the last user when the value is true */
702
+ shouldNotDeleteLastAccount?: boolean;
703
+ }
704
+ interface EmptyResponse {
705
+ }
706
+ interface UpdateSlugRequest {
707
+ /** account id */
708
+ accountId?: string;
709
+ /** new slug */
710
+ newSlugName?: string;
711
+ }
712
+ interface IsTeamRequest {
713
+ /** the account id to check if it's a team account */
714
+ accountId?: string;
715
+ }
716
+ interface IsTeamResponse {
717
+ /** true if the account is marked as a team account, false if not */
718
+ isTeamAccount?: boolean;
719
+ }
720
+ interface MarkAccountFlagRequest extends MarkAccountFlagRequestFlagOneOf {
721
+ /**
722
+ * account co branding flag (if exists)
723
+ * an enum for CoBranding flag contains 4 possible options:
724
+ * None - the account is not CoBranded
725
+ * CoBranded - the account has a CoBranding flag
726
+ * CoBranded_Customer_New - the account is a contributor of a CoBranded account. This account was created because of the contributor invite
727
+ * CoBranded_Customer_Existing - the account is a contributor of a CoBranded account. This account was created before the invite of the contributor invite
728
+ */
729
+ coBranding?: CoBranding;
730
+ /** the account id to mark */
731
+ accountId?: string;
732
+ /** the inviting account id in case the flag is given by an invite */
733
+ invitedByAccountId?: string | null;
734
+ }
735
+ /** @oneof */
736
+ interface MarkAccountFlagRequestFlagOneOf {
737
+ /**
738
+ * account co branding flag (if exists)
739
+ * an enum for CoBranding flag contains 4 possible options:
740
+ * None - the account is not CoBranded
741
+ * CoBranded - the account has a CoBranding flag
742
+ * CoBranded_Customer_New - the account is a contributor of a CoBranded account. This account was created because of the contributor invite
743
+ * CoBranded_Customer_Existing - the account is a contributor of a CoBranded account. This account was created before the invite of the contributor invite
744
+ */
745
+ coBranding?: CoBranding;
746
+ }
747
+ interface GetParentAccountInfoRequest {
748
+ }
749
+ interface GetParentAccountInfoResponse {
750
+ /** The info of the parent account, if the account has a parent */
751
+ parentAccountInfo?: AccountInfo;
752
+ }
753
+ interface AccountInfo {
754
+ /** The name of the account */
755
+ name?: string | null;
756
+ /** The url of the image of the account */
757
+ image?: string | null;
758
+ }
759
+ interface GetSubAccountsRequest {
760
+ /** Offset-based pagination for the response. Default page size is 20, max page size is 50 */
761
+ paging?: Paging;
762
+ }
763
+ interface GetSubAccountsResponse {
764
+ /** The sub accounts of the target account */
765
+ subAccounts?: SubAccountInfo[];
766
+ /** Metadata of the response pagination */
767
+ pagingMetadata?: PagingMetadata;
768
+ }
769
+ interface SubAccountInfo {
770
+ /** The id of the sub account */
771
+ accountId?: string;
772
+ }
773
+ interface PagingMetadata {
774
+ /** Number of items returned in the response. */
775
+ count?: number | null;
776
+ /** Offset that was requested. */
777
+ offset?: number | null;
778
+ /** Total number of items that match the query. */
779
+ total?: number | null;
780
+ /** Flag that indicates the server failed to calculate the `total` field. */
781
+ tooManyToCount?: boolean | null;
782
+ }
783
+ interface ListChildAccountsRequest {
784
+ /**
785
+ * Paging options to limit and offset the number of items.
786
+ * Default: 20. Max: 50.
787
+ */
788
+ paging?: Paging;
789
+ }
790
+ interface ListChildAccountsResponse {
791
+ /** The requested child accounts. */
792
+ childAccounts?: AccountV2[];
793
+ /** Metadata of the response pagination. */
794
+ pagingMetadata?: PagingMetadata;
795
+ }
796
+ interface SetIsReadOnlyAccountRequest {
797
+ accountId?: string;
798
+ isReadOnly?: boolean;
799
+ }
800
+ interface AccountV2NonNullableFields {
801
+ accountId: string;
802
+ }
803
+ interface CreateAccountResponseNonNullableFields {
804
+ account?: AccountV2NonNullableFields;
805
+ }
806
+ interface ListChildAccountsResponseNonNullableFields {
807
+ childAccounts: AccountV2NonNullableFields[];
808
+ }
809
+ interface CreateAccountOptions {
810
+ /**
811
+ * Roles to be assigned to the user in the new account. To retrieve all available roles, call Get Roles Info in the Users API.
812
+ * Default: OWNER.
813
+ */
814
+ roles?: string[] | null;
815
+ }
816
+ interface ListChildAccountsOptions {
817
+ /**
818
+ * Paging options to limit and offset the number of items.
819
+ * Default: 20. Max: 50.
820
+ */
821
+ paging?: Paging;
822
+ }
823
+
824
+ declare function createAccount$1(httpClient: HttpClient): CreateAccountSignature;
825
+ interface CreateAccountSignature {
826
+ /**
827
+ * Creates a new Wix account, and creates a new Wix user as the account owner.
828
+ * The newly created account is a child account of the account used to create it, making that account its parent.
829
+ *
830
+ * > **Important**: This call requires an account level API key and cannot be authenticated with the standard authorization header. API keys are currently available to selected beta users only.
831
+ * @param - The user to create under the new account, with the roles defined in `roles`.
832
+ * @param - Filter options.
833
+ */
834
+ (user: User, options?: CreateAccountOptions | undefined): Promise<CreateAccountResponse & CreateAccountResponseNonNullableFields>;
835
+ }
836
+ declare function listChildAccounts$1(httpClient: HttpClient): ListChildAccountsSignature;
837
+ interface ListChildAccountsSignature {
838
+ /**
839
+ * Retrieves a list of child account IDs for the requesting account.
840
+ * If no child accounts exist, an empty list will be returned.
841
+ *
842
+ * > **Important**: This call requires an account level API key and cannot be authenticated with the standard authorization header. API keys are currently available to selected beta users only.
843
+ * @param - Filter options.
844
+ */
845
+ (options?: ListChildAccountsOptions | undefined): Promise<ListChildAccountsResponse & ListChildAccountsResponseNonNullableFields>;
846
+ }
847
+
848
+ declare const createAccount: MaybeContext<BuildRESTFunction<typeof createAccount$1> & typeof createAccount$1>;
849
+ declare const listChildAccounts: MaybeContext<BuildRESTFunction<typeof listChildAccounts$1> & typeof listChildAccounts$1>;
850
+
851
+ type context_Account = Account;
852
+ type context_AccountInfo = AccountInfo;
853
+ type context_AccountProperties = AccountProperties;
854
+ type context_AccountResponse = AccountResponse;
855
+ type context_AccountStatus = AccountStatus;
856
+ declare const context_AccountStatus: typeof AccountStatus;
857
+ type context_AccountV2 = AccountV2;
858
+ type context_AccountsResponse = AccountsResponse;
859
+ type context_CoBranding = CoBranding;
860
+ declare const context_CoBranding: typeof CoBranding;
861
+ type context_CreateAccountAndAssignUserRequest = CreateAccountAndAssignUserRequest;
862
+ type context_CreateAccountForMyUserRequest = CreateAccountForMyUserRequest;
863
+ type context_CreateAccountOptions = CreateAccountOptions;
864
+ type context_CreateAccountRequest = CreateAccountRequest;
865
+ type context_CreateAccountResponse = CreateAccountResponse;
866
+ type context_CreateAccountResponseNonNullableFields = CreateAccountResponseNonNullableFields;
867
+ type context_CreateAccountTenantRequest = CreateAccountTenantRequest;
868
+ type context_CreateAccountTenantResponse = CreateAccountTenantResponse;
869
+ type context_DeleteAccountRequest = DeleteAccountRequest;
870
+ type context_Email = Email;
871
+ type context_EmptyResponse = EmptyResponse;
872
+ type context_GetAccountRequest = GetAccountRequest;
873
+ type context_GetAccountsRequest = GetAccountsRequest;
874
+ type context_GetMyAccountRequest = GetMyAccountRequest;
875
+ type context_GetMyUserAccountsRequest = GetMyUserAccountsRequest;
876
+ type context_GetParentAccountInfoRequest = GetParentAccountInfoRequest;
877
+ type context_GetParentAccountInfoResponse = GetParentAccountInfoResponse;
878
+ type context_GetSubAccountsRequest = GetSubAccountsRequest;
879
+ type context_GetSubAccountsResponse = GetSubAccountsResponse;
880
+ type context_GetUserAccountRequest = GetUserAccountRequest;
881
+ type context_GetUserAccountsRequest = GetUserAccountsRequest;
882
+ type context_IsTeamRequest = IsTeamRequest;
883
+ type context_IsTeamResponse = IsTeamResponse;
884
+ type context_ListChildAccountsOptions = ListChildAccountsOptions;
885
+ type context_ListChildAccountsRequest = ListChildAccountsRequest;
886
+ type context_ListChildAccountsResponse = ListChildAccountsResponse;
887
+ type context_ListChildAccountsResponseNonNullableFields = ListChildAccountsResponseNonNullableFields;
888
+ type context_MarkAccountFlagRequest = MarkAccountFlagRequest;
889
+ type context_MarkAccountFlagRequestFlagOneOf = MarkAccountFlagRequestFlagOneOf;
890
+ type context_Paging = Paging;
891
+ type context_PagingMetadata = PagingMetadata;
892
+ type context_RemoveParent = RemoveParent;
893
+ type context_SetIsReadOnlyAccountRequest = SetIsReadOnlyAccountRequest;
894
+ type context_SsoIdentity = SsoIdentity;
895
+ type context_SubAccountInfo = SubAccountInfo;
896
+ type context_UpdateAccountRequest = UpdateAccountRequest;
897
+ type context_UpdateParentAccountRequest = UpdateParentAccountRequest;
898
+ type context_UpdateParentAccountRequestUpdateOneOf = UpdateParentAccountRequestUpdateOneOf;
899
+ type context_UpdateParentAccountResponse = UpdateParentAccountResponse;
900
+ type context_UpdateSlugRequest = UpdateSlugRequest;
901
+ type context_User = User;
902
+ type context_UserDetails = UserDetails;
903
+ declare const context_createAccount: typeof createAccount;
904
+ declare const context_listChildAccounts: typeof listChildAccounts;
905
+ declare namespace context {
906
+ export { type context_Account as Account, type context_AccountInfo as AccountInfo, type context_AccountProperties as AccountProperties, type context_AccountResponse as AccountResponse, context_AccountStatus as AccountStatus, type context_AccountV2 as AccountV2, type context_AccountsResponse as AccountsResponse, context_CoBranding as CoBranding, type context_CreateAccountAndAssignUserRequest as CreateAccountAndAssignUserRequest, type context_CreateAccountForMyUserRequest as CreateAccountForMyUserRequest, type context_CreateAccountOptions as CreateAccountOptions, type context_CreateAccountRequest as CreateAccountRequest, type context_CreateAccountResponse as CreateAccountResponse, type context_CreateAccountResponseNonNullableFields as CreateAccountResponseNonNullableFields, type context_CreateAccountTenantRequest as CreateAccountTenantRequest, type context_CreateAccountTenantResponse as CreateAccountTenantResponse, type context_DeleteAccountRequest as DeleteAccountRequest, type context_Email as Email, type context_EmptyResponse as EmptyResponse, type context_GetAccountRequest as GetAccountRequest, type context_GetAccountsRequest as GetAccountsRequest, type context_GetMyAccountRequest as GetMyAccountRequest, type context_GetMyUserAccountsRequest as GetMyUserAccountsRequest, type context_GetParentAccountInfoRequest as GetParentAccountInfoRequest, type context_GetParentAccountInfoResponse as GetParentAccountInfoResponse, type context_GetSubAccountsRequest as GetSubAccountsRequest, type context_GetSubAccountsResponse as GetSubAccountsResponse, type context_GetUserAccountRequest as GetUserAccountRequest, type context_GetUserAccountsRequest as GetUserAccountsRequest, type context_IsTeamRequest as IsTeamRequest, type context_IsTeamResponse as IsTeamResponse, type context_ListChildAccountsOptions as ListChildAccountsOptions, type context_ListChildAccountsRequest as ListChildAccountsRequest, type context_ListChildAccountsResponse as ListChildAccountsResponse, type context_ListChildAccountsResponseNonNullableFields as ListChildAccountsResponseNonNullableFields, type context_MarkAccountFlagRequest as MarkAccountFlagRequest, type context_MarkAccountFlagRequestFlagOneOf as MarkAccountFlagRequestFlagOneOf, type context_Paging as Paging, type context_PagingMetadata as PagingMetadata, type context_RemoveParent as RemoveParent, type context_SetIsReadOnlyAccountRequest as SetIsReadOnlyAccountRequest, type context_SsoIdentity as SsoIdentity, type context_SubAccountInfo as SubAccountInfo, type context_UpdateAccountRequest as UpdateAccountRequest, type context_UpdateParentAccountRequest as UpdateParentAccountRequest, type context_UpdateParentAccountRequestUpdateOneOf as UpdateParentAccountRequestUpdateOneOf, type context_UpdateParentAccountResponse as UpdateParentAccountResponse, type context_UpdateSlugRequest as UpdateSlugRequest, type context_User as User, type context_UserDetails as UserDetails, context_createAccount as createAccount, context_listChildAccounts as listChildAccounts };
907
+ }
908
+
909
+ export { context as accounts };