@workos-inc/widgets 1.1.4 → 1.2.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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/lib/organization-switcher.d.ts +10 -1
  3. package/dist/cjs/lib/organization-switcher.d.ts.map +1 -1
  4. package/dist/cjs/lib/organization-switcher.js +31 -3
  5. package/dist/cjs/lib/organization-switcher.js.map +1 -1
  6. package/dist/cjs/workos-widgets.client.d.ts +6 -0
  7. package/dist/cjs/workos-widgets.client.d.ts.map +1 -1
  8. package/dist/cjs/workos-widgets.client.js +23 -3
  9. package/dist/cjs/workos-widgets.client.js.map +1 -1
  10. package/dist/esm/lib/organization-switcher.d.ts +10 -1
  11. package/dist/esm/lib/organization-switcher.d.ts.map +1 -1
  12. package/dist/esm/lib/organization-switcher.js +31 -3
  13. package/dist/esm/lib/organization-switcher.js.map +1 -1
  14. package/dist/esm/workos-widgets.client.d.ts +6 -0
  15. package/dist/esm/workos-widgets.client.d.ts.map +1 -1
  16. package/dist/esm/workos-widgets.client.js +25 -5
  17. package/dist/esm/workos-widgets.client.js.map +1 -1
  18. package/package.json +40 -47
  19. package/src/api/api-provider.tsx +0 -158
  20. package/src/api/constants.ts +0 -1
  21. package/src/api/endpoint.ts +0 -3097
  22. package/src/api/errors.ts +0 -48
  23. package/src/api/index.ts +0 -2
  24. package/src/api/utils.ts +0 -42
  25. package/src/api/widgets-api-client.ts +0 -87
  26. package/src/card-list.tsx +0 -26
  27. package/src/index.ts +0 -9
  28. package/src/lib/add-mfa-dialog.tsx +0 -379
  29. package/src/lib/api/config.ts +0 -9
  30. package/src/lib/api/user.ts +0 -98
  31. package/src/lib/change-password-dialog.tsx +0 -290
  32. package/src/lib/constants.ts +0 -3
  33. package/src/lib/copy-button.tsx +0 -53
  34. package/src/lib/delete-user-dialog.tsx +0 -110
  35. package/src/lib/edit-user-profile-dialog.tsx +0 -181
  36. package/src/lib/edit-user-role-dialog.tsx +0 -178
  37. package/src/lib/elements.tsx +0 -428
  38. package/src/lib/elevated-access.tsx +0 -261
  39. package/src/lib/error-boundary.tsx +0 -166
  40. package/src/lib/errors.ts +0 -49
  41. package/src/lib/generic-error.tsx +0 -70
  42. package/src/lib/icon-panel.tsx +0 -26
  43. package/src/lib/icons.tsx +0 -21
  44. package/src/lib/invite-user-dialog.tsx +0 -327
  45. package/src/lib/logout-all-sessions-dialog.tsx +0 -82
  46. package/src/lib/logout-dialog.tsx +0 -85
  47. package/src/lib/marker.tsx +0 -39
  48. package/src/lib/oauth-icons.tsx +0 -138
  49. package/src/lib/organization-switcher.tsx +0 -156
  50. package/src/lib/otp-input.tsx +0 -276
  51. package/src/lib/resend-invite-dialog.tsx +0 -145
  52. package/src/lib/reset-mfa-dialog.tsx +0 -104
  53. package/src/lib/revoke-invite-dialog.tsx +0 -111
  54. package/src/lib/save-button.tsx +0 -113
  55. package/src/lib/search-provider.tsx +0 -51
  56. package/src/lib/set-password-dialog.tsx +0 -204
  57. package/src/lib/use-dialog-close.tsx +0 -19
  58. package/src/lib/use-is-hydrated.ts +0 -13
  59. package/src/lib/use-layout-effect.ts +0 -6
  60. package/src/lib/use-security-settings.tsx +0 -49
  61. package/src/lib/user-actions-dropdown.tsx +0 -157
  62. package/src/lib/user-profile.tsx +0 -227
  63. package/src/lib/user-security.tsx +0 -187
  64. package/src/lib/user-sessions.tsx +0 -204
  65. package/src/lib/users-filter.tsx +0 -62
  66. package/src/lib/users-management-context.tsx +0 -74
  67. package/src/lib/users-management-state.ts +0 -165
  68. package/src/lib/users-management.tsx +0 -594
  69. package/src/lib/users-search.tsx +0 -73
  70. package/src/lib/utils.ts +0 -131
  71. package/src/lib/widgets-context.ts +0 -29
  72. package/src/organization-switcher.client.tsx +0 -81
  73. package/src/user-profile.client.tsx +0 -55
  74. package/src/user-security.client.tsx +0 -55
  75. package/src/user-sessions.client.tsx +0 -100
  76. package/src/users-management.client.tsx +0 -73
  77. package/src/workos-widgets.client.tsx +0 -75
  78. /package/{src → dist/css}/base.css +0 -0
  79. /package/{src → dist/css}/lib/card-list.css +0 -0
  80. /package/{src → dist/css}/lib/marker.css +0 -0
  81. /package/{src → dist/css}/lib/save-button.css +0 -0
  82. /package/{src → dist/css}/styles.css +0 -0
  83. /package/{src → dist/css}/users-management.css +0 -0
@@ -1,3097 +0,0 @@
1
- /**
2
- * Generated by orval v7.5.0 🍺
3
- * Do not edit manually.
4
- * WorkOS Widgets
5
- * WorkOS Widgets API
6
- * OpenAPI spec version: 1.0
7
- */
8
- import { useMutation, useQuery } from "@tanstack/react-query";
9
- import type {
10
- DataTag,
11
- DefinedInitialDataOptions,
12
- DefinedUseQueryResult,
13
- MutationFunction,
14
- QueryFunction,
15
- QueryKey,
16
- UndefinedInitialDataOptions,
17
- UseMutationOptions,
18
- UseMutationResult,
19
- UseQueryOptions,
20
- UseQueryResult,
21
- } from "@tanstack/react-query";
22
- import { useCallback } from "react";
23
- import { useWidgetsApiClient } from "./widgets-api-client";
24
- import type { ErrorType, BodyType } from "./widgets-api-client";
25
- import { useWidgetsApiQueryOptions } from "./widgets-api-client";
26
-
27
- export const MemberStatus = {
28
- Active: "Active",
29
- Invited: "Invited",
30
- InviteExpired: "InviteExpired",
31
- InviteRevoked: "InviteRevoked",
32
- NoInvite: "NoInvite",
33
- } as const;
34
- export type MemberStatus = (typeof MemberStatus)[keyof typeof MemberStatus];
35
-
36
- export const MemberActionsItem = {
37
- "edit-role": "edit-role",
38
- "resend-invite": "resend-invite",
39
- "revoke-invite": "revoke-invite",
40
- "revoke-membership": "revoke-membership",
41
- } as const;
42
- export type MemberActions =
43
- (typeof MemberActionsItem)[keyof typeof MemberActionsItem][];
44
-
45
- export type MemberRolesItem = {
46
- name: string;
47
- slug: string;
48
- };
49
-
50
- export interface Member {
51
- id: string;
52
- email: string;
53
- emailVerified: boolean;
54
- /** @nullable */
55
- profilePictureUrl?: string | null;
56
- /** @nullable */
57
- firstName?: string | null;
58
- /** @nullable */
59
- lastName?: string | null;
60
- createdAt: string;
61
- /** @nullable */
62
- lastActivityAt?: string | null;
63
- status: MemberStatus;
64
- actions: MemberActions;
65
- /** @nullable */
66
- isLoggedInUser?: boolean | null;
67
- /** @nullable */
68
- roles?: MemberRolesItem[] | null;
69
- }
70
-
71
- export interface ListMetadata {
72
- /** @nullable */
73
- before?: string | null;
74
- /** @nullable */
75
- after?: string | null;
76
- }
77
-
78
- export interface MemberRole {
79
- name: string;
80
- slug: string;
81
- default: boolean;
82
- }
83
-
84
- export interface OrganizationInfo {
85
- id: string;
86
- name: string;
87
- current: boolean;
88
- /** @nullable */
89
- favicon?: string | null;
90
- }
91
-
92
- export interface OrganizationsResponse {
93
- data: OrganizationInfo[];
94
- }
95
-
96
- export interface OAuthProfile {
97
- id: string;
98
- /** @nullable */
99
- email?: string | null;
100
- /** @nullable */
101
- firstName?: string | null;
102
- /** @nullable */
103
- lastName?: string | null;
104
- /** @nullable */
105
- profilePictureUrl?: string | null;
106
- /** @nullable */
107
- lastLoginAt?: string | null;
108
- }
109
-
110
- /**
111
- * @nullable
112
- */
113
- export type MeOauthProfiles = {
114
- AppleOAuth?: OAuthProfile;
115
- GithubOAuth?: OAuthProfile;
116
- GoogleOAuth?: OAuthProfile;
117
- MicrosoftOAuth?: OAuthProfile;
118
- } | null;
119
-
120
- export interface Me {
121
- id: string;
122
- email: string;
123
- /** @nullable */
124
- firstName?: string | null;
125
- /** @nullable */
126
- lastName?: string | null;
127
- /** @nullable */
128
- profilePictureUrl?: string | null;
129
- /** @nullable */
130
- oauthProfiles?: MeOauthProfiles;
131
- }
132
-
133
- export type CreateTotpFactorResponseAuthenticationFactorAllOfObject =
134
- (typeof CreateTotpFactorResponseAuthenticationFactorAllOfObject)[keyof typeof CreateTotpFactorResponseAuthenticationFactorAllOfObject];
135
-
136
- export const CreateTotpFactorResponseAuthenticationFactorAllOfObject = {
137
- authentication_factor: "authentication_factor",
138
- } as const;
139
-
140
- export type CreateTotpFactorResponseAuthenticationFactorAllOfType =
141
- (typeof CreateTotpFactorResponseAuthenticationFactorAllOfType)[keyof typeof CreateTotpFactorResponseAuthenticationFactorAllOfType];
142
-
143
- export const CreateTotpFactorResponseAuthenticationFactorAllOfType = {
144
- generic_otp: "generic_otp",
145
- sms: "sms",
146
- totp: "totp",
147
- webauthn: "webauthn",
148
- } as const;
149
-
150
- /**
151
- * @nullable
152
- */
153
- export type CreateTotpFactorResponseAuthenticationFactorAllOfSms = {
154
- phone_number: string;
155
- } | null;
156
-
157
- /**
158
- * @nullable
159
- */
160
- export type CreateTotpFactorResponseAuthenticationFactorAllOfTotpAnyOf = {
161
- issuer: string;
162
- user: string;
163
- secret: string;
164
- qr_code: string;
165
- uri: string;
166
- } | null;
167
-
168
- /**
169
- * @nullable
170
- */
171
- export type CreateTotpFactorResponseAuthenticationFactorAllOfTotpAnyOfTwo = {
172
- issuer: string;
173
- user: string;
174
- } | null;
175
-
176
- export type CreateTotpFactorResponseAuthenticationFactorAllOfTotp =
177
- | CreateTotpFactorResponseAuthenticationFactorAllOfTotpAnyOf
178
- | CreateTotpFactorResponseAuthenticationFactorAllOfTotpAnyOfTwo;
179
-
180
- export type CreateTotpFactorResponseAuthenticationFactorAllOf = {
181
- object: CreateTotpFactorResponseAuthenticationFactorAllOfObject;
182
- id: string;
183
- type: CreateTotpFactorResponseAuthenticationFactorAllOfType;
184
- /** @nullable */
185
- user_id?: string | null;
186
- /** @nullable */
187
- sms?: CreateTotpFactorResponseAuthenticationFactorAllOfSms;
188
- totp?: CreateTotpFactorResponseAuthenticationFactorAllOfTotp;
189
- };
190
-
191
- export type CreateTotpFactorResponseAuthenticationFactorAllOfEight = {
192
- created_at: string;
193
- updated_at: string;
194
- };
195
-
196
- export type CreateTotpFactorResponseAuthenticationFactor =
197
- CreateTotpFactorResponseAuthenticationFactorAllOf &
198
- CreateTotpFactorResponseAuthenticationFactorAllOfEight &
199
- Required<
200
- Pick<
201
- CreateTotpFactorResponseAuthenticationFactorAllOf &
202
- CreateTotpFactorResponseAuthenticationFactorAllOfEight,
203
- "object" | "id" | "type" | "created_at" | "updated_at"
204
- >
205
- >;
206
-
207
- export type CreateTotpFactorResponseAuthenticationChallengeAllOfObject =
208
- (typeof CreateTotpFactorResponseAuthenticationChallengeAllOfObject)[keyof typeof CreateTotpFactorResponseAuthenticationChallengeAllOfObject];
209
-
210
- export const CreateTotpFactorResponseAuthenticationChallengeAllOfObject = {
211
- authentication_challenge: "authentication_challenge",
212
- } as const;
213
-
214
- export type CreateTotpFactorResponseAuthenticationChallengeAllOf = {
215
- object: CreateTotpFactorResponseAuthenticationChallengeAllOfObject;
216
- id: string;
217
- /** @nullable */
218
- expires_at?: string | null;
219
- /** @nullable */
220
- code?: string | null;
221
- authentication_factor_id: string;
222
- };
223
-
224
- export type CreateTotpFactorResponseAuthenticationChallengeAllOfThree = {
225
- created_at: string;
226
- updated_at: string;
227
- };
228
-
229
- export type CreateTotpFactorResponseAuthenticationChallenge =
230
- CreateTotpFactorResponseAuthenticationChallengeAllOf &
231
- CreateTotpFactorResponseAuthenticationChallengeAllOfThree &
232
- Required<
233
- Pick<
234
- CreateTotpFactorResponseAuthenticationChallengeAllOf &
235
- CreateTotpFactorResponseAuthenticationChallengeAllOfThree,
236
- | "object"
237
- | "id"
238
- | "authentication_factor_id"
239
- | "created_at"
240
- | "updated_at"
241
- >
242
- >;
243
-
244
- export interface CreateTotpFactorResponse {
245
- authenticationFactor: CreateTotpFactorResponseAuthenticationFactor;
246
- authenticationChallenge: CreateTotpFactorResponseAuthenticationChallenge;
247
- }
248
-
249
- export interface VerifyTotpFactorRequest {
250
- code: string;
251
- authenticationChallengeId: string;
252
- }
253
-
254
- export type AuthenticationInformationResponseDataVerificationMethodsMfaProvider =
255
- (typeof AuthenticationInformationResponseDataVerificationMethodsMfaProvider)[keyof typeof AuthenticationInformationResponseDataVerificationMethodsMfaProvider];
256
-
257
- export const AuthenticationInformationResponseDataVerificationMethodsMfaProvider =
258
- {
259
- MFA: "MFA",
260
- } as const;
261
-
262
- /**
263
- * @nullable
264
- */
265
- export type AuthenticationInformationResponseDataVerificationMethodsMfa = {
266
- provider: AuthenticationInformationResponseDataVerificationMethodsMfaProvider;
267
- isSetUp: boolean;
268
- /** @nullable */
269
- lastUsed?: string | null;
270
- } | null;
271
-
272
- export type AuthenticationInformationResponseDataVerificationMethodsPasswordProvider =
273
- (typeof AuthenticationInformationResponseDataVerificationMethodsPasswordProvider)[keyof typeof AuthenticationInformationResponseDataVerificationMethodsPasswordProvider];
274
-
275
- export const AuthenticationInformationResponseDataVerificationMethodsPasswordProvider =
276
- {
277
- Password: "Password",
278
- } as const;
279
-
280
- /**
281
- * @nullable
282
- */
283
- export type AuthenticationInformationResponseDataVerificationMethodsPassword = {
284
- provider: AuthenticationInformationResponseDataVerificationMethodsPasswordProvider;
285
- isSetUp: boolean;
286
- /** @nullable */
287
- lastUsed?: string | null;
288
- isCurrentSession: boolean;
289
- } | null;
290
-
291
- export type AuthenticationInformationResponseDataVerificationMethodsPasskeyProvider =
292
- (typeof AuthenticationInformationResponseDataVerificationMethodsPasskeyProvider)[keyof typeof AuthenticationInformationResponseDataVerificationMethodsPasskeyProvider];
293
-
294
- export const AuthenticationInformationResponseDataVerificationMethodsPasskeyProvider =
295
- {
296
- Passkey: "Passkey",
297
- } as const;
298
-
299
- export type AuthenticationInformationResponseDataVerificationMethodsPasskeyPassKeysItem =
300
- {
301
- id: string;
302
- };
303
-
304
- /**
305
- * @nullable
306
- */
307
- export type AuthenticationInformationResponseDataVerificationMethodsPasskey = {
308
- provider: AuthenticationInformationResponseDataVerificationMethodsPasskeyProvider;
309
- isSetUp: boolean;
310
- /** @nullable */
311
- lastUsed?: string | null;
312
- passKeys: AuthenticationInformationResponseDataVerificationMethodsPasskeyPassKeysItem[];
313
- isCurrentSession: boolean;
314
- } | null;
315
-
316
- export type AuthenticationInformationResponseDataVerificationMethods = {
317
- /** @nullable */
318
- Mfa?: AuthenticationInformationResponseDataVerificationMethodsMfa;
319
- /** @nullable */
320
- Password?: AuthenticationInformationResponseDataVerificationMethodsPassword;
321
- /** @nullable */
322
- Passkey?: AuthenticationInformationResponseDataVerificationMethodsPasskey;
323
- };
324
-
325
- export type AuthenticationInformationResponseDataPasswordSettings = {
326
- isPasswordNumberRequired: boolean;
327
- isPasswordPwnedRequired: boolean;
328
- isPasswordSymbolRequired: boolean;
329
- isPasswordUppercaseRequired: boolean;
330
- passwordMinimumLength: number;
331
- passwordMinimumStrength: number;
332
- };
333
-
334
- export type AuthenticationInformationResponseData = {
335
- verificationMethods: AuthenticationInformationResponseDataVerificationMethods;
336
- passwordSettings: AuthenticationInformationResponseDataPasswordSettings;
337
- };
338
-
339
- export interface AuthenticationInformationResponse {
340
- data: AuthenticationInformationResponseData;
341
- }
342
-
343
- export interface CreatePasswordRequest {
344
- password: string;
345
- }
346
-
347
- export interface UpdatePasswordRequest {
348
- newPassword: string;
349
- currentPassword: string;
350
- }
351
-
352
- export interface RevokeAllSessionsRequest {
353
- currentSessionId: string;
354
- }
355
-
356
- export type ActiveSessionState = {
357
- tag: string;
358
- /** @nullable */
359
- expiresAt?: string | null;
360
- };
361
-
362
- /**
363
- * @nullable
364
- */
365
- export type ActiveSessionCurrentLocation = {
366
- cityName: string;
367
- countryISOCode: string;
368
- } | null;
369
-
370
- export interface ActiveSession {
371
- id: string;
372
- userlandUserId: string;
373
- /** @nullable */
374
- ipAddress?: string | null;
375
- /** @nullable */
376
- userAgent?: string | null;
377
- /** @nullable */
378
- organizationId?: string | null;
379
- state: ActiveSessionState;
380
- /** @nullable */
381
- currentLocation?: ActiveSessionCurrentLocation;
382
- usedSsoAuth: boolean;
383
- usedPasswordAuth: boolean;
384
- usedPasskeyAuth: boolean;
385
- usedAppleOauth: boolean;
386
- usedBitbucketOauth: boolean;
387
- usedGithubOauth: boolean;
388
- usedGitLabOauth: boolean;
389
- usedGoogleOauth: boolean;
390
- usedLinkedInOauth: boolean;
391
- usedImpersonation: boolean;
392
- usedMicrosoftOauth: boolean;
393
- usedSlackOauth: boolean;
394
- usedXeroOauth: boolean;
395
- usedMagicAuth: boolean;
396
- /** @nullable */
397
- impersonatorUserId?: string | null;
398
- /** @nullable */
399
- impersonatorEmail?: string | null;
400
- /** @nullable */
401
- impersonationReason?: string | null;
402
- /** @nullable */
403
- lastActivityAt?: string | null;
404
- createdAt: string;
405
- updatedAt: string;
406
- }
407
-
408
- export interface ActiveSessionsResponse {
409
- data: ActiveSession[];
410
- }
411
-
412
- export type SendVerificationResponseType =
413
- (typeof SendVerificationResponseType)[keyof typeof SendVerificationResponseType];
414
-
415
- export const SendVerificationResponseType = {
416
- EmailVerification: "EmailVerification",
417
- } as const;
418
-
419
- export interface SendVerificationResponse {
420
- authenticationChallenge: string;
421
- type: SendVerificationResponseType;
422
- }
423
-
424
- export interface VerifyRequest {
425
- code: string;
426
- authenticationChallengeId: string;
427
- }
428
-
429
- export interface VerifyResponse {
430
- elevatedAccessToken: string;
431
- expiresAt: string;
432
- }
433
-
434
- export type RegisterPasskeyResponseOptions = { [key: string]: unknown };
435
-
436
- export interface RegisterPasskeyResponse {
437
- challengeId: string;
438
- options: RegisterPasskeyResponseOptions;
439
- }
440
-
441
- export type VerifyPasskeyRequestResponse = { [key: string]: unknown };
442
-
443
- export interface VerifyPasskeyRequest {
444
- challengeId: string;
445
- response: VerifyPasskeyRequestResponse;
446
- }
447
-
448
- export type MembersParams = {
449
- search?: string;
450
- limit?: string;
451
- before?: string;
452
- after?: string;
453
- role?: string;
454
- };
455
-
456
- export type Members200 = {
457
- data: Member[];
458
- listMetadata: ListMetadata;
459
- };
460
-
461
- export type Members403 = {
462
- message: string;
463
- };
464
-
465
- export type Members404 = {
466
- message: string;
467
- };
468
-
469
- export type Roles403 = {
470
- message: string;
471
- };
472
-
473
- export type Roles404 = {
474
- message: string;
475
- };
476
-
477
- export type InviteMemberInput = {
478
- email: string;
479
- /** @nullable */
480
- firstName?: string | null;
481
- /** @nullable */
482
- lastName?: string | null;
483
- roles: string[];
484
- };
485
-
486
- export type InviteMember201 = {
487
- success: boolean;
488
- };
489
-
490
- export type InviteMember400 = {
491
- message: string;
492
- };
493
-
494
- export type InviteMember403 = {
495
- message: string;
496
- };
497
-
498
- export type InviteMember404 = {
499
- message: string;
500
- };
501
-
502
- export type ResendInvite201 = {
503
- /** @nullable */
504
- id?: string | null;
505
- success: boolean;
506
- };
507
-
508
- export type ResendInvite400 = {
509
- message: string;
510
- };
511
-
512
- export type ResendInvite403 = {
513
- message: string;
514
- };
515
-
516
- export type ResendInvite404 = {
517
- message: string;
518
- };
519
-
520
- export type RevokeInvite200 = {
521
- id: string;
522
- success: boolean;
523
- };
524
-
525
- export type RevokeInvite400 = {
526
- message: string;
527
- };
528
-
529
- export type RevokeInvite403 = {
530
- message: string;
531
- };
532
-
533
- export type RevokeInvite404 = {
534
- message: string;
535
- };
536
-
537
- export type RemoveMember200 = {
538
- id: string;
539
- success: boolean;
540
- };
541
-
542
- export type RemoveMember400 = {
543
- message: string;
544
- };
545
-
546
- export type RemoveMember403 = {
547
- message: string;
548
- };
549
-
550
- export type RemoveMember404 = {
551
- message: string;
552
- };
553
-
554
- export type UpdateMemberInput = {
555
- roles: string[];
556
- };
557
-
558
- export type UpdateMember200 = {
559
- id: string;
560
- success: boolean;
561
- };
562
-
563
- export type UpdateMember400 = {
564
- message: string;
565
- };
566
-
567
- export type UpdateMember403 = {
568
- message: string;
569
- };
570
-
571
- export type UpdateMember404 = {
572
- message: string;
573
- };
574
-
575
- export type Organizations403 = {
576
- message: string;
577
- };
578
-
579
- export type Organizations404 = {
580
- message: string;
581
- };
582
-
583
- export type Me403 = {
584
- message: string;
585
- };
586
-
587
- export type UpdateMeInput = {
588
- firstName?: string;
589
- lastName?: string;
590
- };
591
-
592
- export type UpdateMe400 = {
593
- message: string;
594
- };
595
-
596
- export type UpdateMe403 = {
597
- message: string;
598
- };
599
-
600
- export type CreateTotpFactor400 = {
601
- message: string;
602
- };
603
-
604
- export type CreateTotpFactor403 = {
605
- message: string;
606
- };
607
-
608
- export type VerifyTotpFactor200 = {
609
- success: boolean;
610
- };
611
-
612
- export type VerifyTotpFactor400 = {
613
- message: string;
614
- };
615
-
616
- export type VerifyTotpFactor403 = {
617
- message: string;
618
- };
619
-
620
- export type DeleteTotpFactors200 = {
621
- success: boolean;
622
- };
623
-
624
- export type DeleteTotpFactors400 = {
625
- message: string;
626
- };
627
-
628
- export type DeleteTotpFactors403 = {
629
- message: string;
630
- };
631
-
632
- export type AuthenticationInformation403 = {
633
- message: string;
634
- };
635
-
636
- export type CreatePassword201 = {
637
- success: boolean;
638
- };
639
-
640
- export type CreatePassword400 = {
641
- message: string;
642
- };
643
-
644
- export type CreatePassword403 = {
645
- message: string;
646
- };
647
-
648
- export type UpdatePassword201 = {
649
- success: boolean;
650
- };
651
-
652
- export type UpdatePassword400 = {
653
- message: string;
654
- };
655
-
656
- export type UpdatePassword403 = {
657
- message: string;
658
- };
659
-
660
- export type RevokeAllSessions200 = {
661
- success: boolean;
662
- };
663
-
664
- export type RevokeAllSessions400 = {
665
- message: string;
666
- };
667
-
668
- export type RevokeAllSessions403 = {
669
- message: string;
670
- };
671
-
672
- export type RevokeSession200 = {
673
- success: boolean;
674
- };
675
-
676
- export type RevokeSession400 = {
677
- message: string;
678
- };
679
-
680
- export type RevokeSession403 = {
681
- message: string;
682
- };
683
-
684
- export type Sessions403 = {
685
- message: string;
686
- };
687
-
688
- export type SendVerification400 = {
689
- message: string;
690
- };
691
-
692
- export type SendVerification403 = {
693
- message: string;
694
- };
695
-
696
- export type Verify400 = {
697
- message: string;
698
- };
699
-
700
- export type Verify403 = {
701
- message: string;
702
- };
703
-
704
- export type RegisterPasskey400 = {
705
- message: string;
706
- };
707
-
708
- export type RegisterPasskey403 = {
709
- message: string;
710
- };
711
-
712
- export type VerifyPasskey200 = {
713
- success: boolean;
714
- };
715
-
716
- export type VerifyPasskey400 = {
717
- message: string;
718
- };
719
-
720
- export type VerifyPasskey403 = {
721
- message: string;
722
- };
723
-
724
- export type DeletePasskey200 = {
725
- success: boolean;
726
- };
727
-
728
- export type DeletePasskey400 = {
729
- message: string;
730
- };
731
-
732
- export type DeletePasskey403 = {
733
- message: string;
734
- };
735
-
736
- export const useMembersHook = () => {
737
- const members = useWidgetsApiClient<Members200>();
738
-
739
- return useCallback(
740
- (params?: MembersParams, signal?: AbortSignal) => {
741
- return members({
742
- url: `/_widgets/UserManagement/members`,
743
- method: "GET",
744
- params,
745
- signal,
746
- });
747
- },
748
- [members],
749
- );
750
- };
751
-
752
- export const getMembersQueryKey = (params?: MembersParams) => {
753
- return [
754
- `/_widgets/UserManagement/members`,
755
- ...(params ? [params] : []),
756
- ] as const;
757
- };
758
-
759
- export const useMembersQueryOptions = <
760
- TData = Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
761
- TError = ErrorType<Members403 | Members404>,
762
- >(
763
- params?: MembersParams,
764
- options?: {
765
- query?: Partial<
766
- UseQueryOptions<
767
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
768
- TError,
769
- TData
770
- >
771
- >;
772
- },
773
- ) => {
774
- const { query: queryOptions } = options ?? {};
775
-
776
- const queryKey = queryOptions?.queryKey ?? getMembersQueryKey(params);
777
-
778
- const members = useMembersHook();
779
-
780
- const queryFn: QueryFunction<
781
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>
782
- > = ({ signal }) => members(params, signal);
783
-
784
- const customOptions = useWidgetsApiQueryOptions({
785
- ...queryOptions,
786
- queryKey,
787
- queryFn,
788
- });
789
-
790
- return customOptions as UseQueryOptions<
791
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
792
- TError,
793
- TData
794
- > & { queryKey: DataTag<QueryKey, TData> };
795
- };
796
-
797
- export type MembersQueryResult = NonNullable<
798
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>
799
- >;
800
- export type MembersQueryError = ErrorType<Members403 | Members404>;
801
-
802
- export function useMembers<
803
- TData = Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
804
- TError = ErrorType<Members403 | Members404>,
805
- >(
806
- params: undefined | MembersParams,
807
- options: {
808
- query: Partial<
809
- UseQueryOptions<
810
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
811
- TError,
812
- TData
813
- >
814
- > &
815
- Pick<
816
- DefinedInitialDataOptions<
817
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
818
- TError,
819
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>
820
- >,
821
- "initialData"
822
- >;
823
- },
824
- ): DefinedUseQueryResult<TData, TError> & {
825
- queryKey: DataTag<QueryKey, TData>;
826
- };
827
- export function useMembers<
828
- TData = Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
829
- TError = ErrorType<Members403 | Members404>,
830
- >(
831
- params?: MembersParams,
832
- options?: {
833
- query?: Partial<
834
- UseQueryOptions<
835
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
836
- TError,
837
- TData
838
- >
839
- > &
840
- Pick<
841
- UndefinedInitialDataOptions<
842
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
843
- TError,
844
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>
845
- >,
846
- "initialData"
847
- >;
848
- },
849
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
850
- export function useMembers<
851
- TData = Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
852
- TError = ErrorType<Members403 | Members404>,
853
- >(
854
- params?: MembersParams,
855
- options?: {
856
- query?: Partial<
857
- UseQueryOptions<
858
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
859
- TError,
860
- TData
861
- >
862
- >;
863
- },
864
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
865
-
866
- export function useMembers<
867
- TData = Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
868
- TError = ErrorType<Members403 | Members404>,
869
- >(
870
- params?: MembersParams,
871
- options?: {
872
- query?: Partial<
873
- UseQueryOptions<
874
- Awaited<ReturnType<ReturnType<typeof useMembersHook>>>,
875
- TError,
876
- TData
877
- >
878
- >;
879
- },
880
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {
881
- const queryOptions = useMembersQueryOptions(params, options);
882
-
883
- const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
884
- queryKey: DataTag<QueryKey, TData>;
885
- };
886
-
887
- query.queryKey = queryOptions.queryKey;
888
-
889
- return query;
890
- }
891
-
892
- export const useRolesHook = () => {
893
- const roles = useWidgetsApiClient<MemberRole[]>();
894
-
895
- return useCallback(
896
- (signal?: AbortSignal) => {
897
- return roles({
898
- url: `/_widgets/UserManagement/roles`,
899
- method: "GET",
900
- signal,
901
- });
902
- },
903
- [roles],
904
- );
905
- };
906
-
907
- export const getRolesQueryKey = () => {
908
- return [`/_widgets/UserManagement/roles`] as const;
909
- };
910
-
911
- export const useRolesQueryOptions = <
912
- TData = Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
913
- TError = ErrorType<Roles403 | Roles404>,
914
- >(options?: {
915
- query?: Partial<
916
- UseQueryOptions<
917
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
918
- TError,
919
- TData
920
- >
921
- >;
922
- }) => {
923
- const { query: queryOptions } = options ?? {};
924
-
925
- const queryKey = queryOptions?.queryKey ?? getRolesQueryKey();
926
-
927
- const roles = useRolesHook();
928
-
929
- const queryFn: QueryFunction<
930
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>
931
- > = ({ signal }) => roles(signal);
932
-
933
- const customOptions = useWidgetsApiQueryOptions({
934
- ...queryOptions,
935
- queryKey,
936
- queryFn,
937
- });
938
-
939
- return customOptions as UseQueryOptions<
940
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
941
- TError,
942
- TData
943
- > & { queryKey: DataTag<QueryKey, TData> };
944
- };
945
-
946
- export type RolesQueryResult = NonNullable<
947
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>
948
- >;
949
- export type RolesQueryError = ErrorType<Roles403 | Roles404>;
950
-
951
- export function useRoles<
952
- TData = Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
953
- TError = ErrorType<Roles403 | Roles404>,
954
- >(options: {
955
- query: Partial<
956
- UseQueryOptions<
957
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
958
- TError,
959
- TData
960
- >
961
- > &
962
- Pick<
963
- DefinedInitialDataOptions<
964
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
965
- TError,
966
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>
967
- >,
968
- "initialData"
969
- >;
970
- }): DefinedUseQueryResult<TData, TError> & {
971
- queryKey: DataTag<QueryKey, TData>;
972
- };
973
- export function useRoles<
974
- TData = Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
975
- TError = ErrorType<Roles403 | Roles404>,
976
- >(options?: {
977
- query?: Partial<
978
- UseQueryOptions<
979
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
980
- TError,
981
- TData
982
- >
983
- > &
984
- Pick<
985
- UndefinedInitialDataOptions<
986
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
987
- TError,
988
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>
989
- >,
990
- "initialData"
991
- >;
992
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
993
- export function useRoles<
994
- TData = Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
995
- TError = ErrorType<Roles403 | Roles404>,
996
- >(options?: {
997
- query?: Partial<
998
- UseQueryOptions<
999
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
1000
- TError,
1001
- TData
1002
- >
1003
- >;
1004
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
1005
-
1006
- export function useRoles<
1007
- TData = Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
1008
- TError = ErrorType<Roles403 | Roles404>,
1009
- >(options?: {
1010
- query?: Partial<
1011
- UseQueryOptions<
1012
- Awaited<ReturnType<ReturnType<typeof useRolesHook>>>,
1013
- TError,
1014
- TData
1015
- >
1016
- >;
1017
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {
1018
- const queryOptions = useRolesQueryOptions(options);
1019
-
1020
- const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
1021
- queryKey: DataTag<QueryKey, TData>;
1022
- };
1023
-
1024
- query.queryKey = queryOptions.queryKey;
1025
-
1026
- return query;
1027
- }
1028
-
1029
- export const useInviteMemberHook = () => {
1030
- const inviteMember = useWidgetsApiClient<InviteMember201>();
1031
-
1032
- return useCallback(
1033
- (inviteMemberInput: BodyType<InviteMemberInput>, signal?: AbortSignal) => {
1034
- return inviteMember({
1035
- url: `/_widgets/UserManagement/invite-user`,
1036
- method: "POST",
1037
- headers: { "Content-Type": "application/json" },
1038
- data: inviteMemberInput,
1039
- signal,
1040
- });
1041
- },
1042
- [inviteMember],
1043
- );
1044
- };
1045
-
1046
- export const useInviteMemberMutationOptions = <
1047
- TError = ErrorType<InviteMember400 | InviteMember403 | InviteMember404>,
1048
- TContext = unknown,
1049
- >(options?: {
1050
- mutation?: UseMutationOptions<
1051
- Awaited<ReturnType<ReturnType<typeof useInviteMemberHook>>>,
1052
- TError,
1053
- { data: BodyType<InviteMemberInput> },
1054
- TContext
1055
- >;
1056
- }): UseMutationOptions<
1057
- Awaited<ReturnType<ReturnType<typeof useInviteMemberHook>>>,
1058
- TError,
1059
- { data: BodyType<InviteMemberInput> },
1060
- TContext
1061
- > => {
1062
- const mutationKey = ["inviteMember"];
1063
- const { mutation: mutationOptions } = options
1064
- ? options.mutation &&
1065
- "mutationKey" in options.mutation &&
1066
- options.mutation.mutationKey
1067
- ? options
1068
- : { ...options, mutation: { ...options.mutation, mutationKey } }
1069
- : { mutation: { mutationKey } };
1070
-
1071
- const inviteMember = useInviteMemberHook();
1072
-
1073
- const mutationFn: MutationFunction<
1074
- Awaited<ReturnType<ReturnType<typeof useInviteMemberHook>>>,
1075
- { data: BodyType<InviteMemberInput> }
1076
- > = (props) => {
1077
- const { data } = props ?? {};
1078
-
1079
- return inviteMember(data);
1080
- };
1081
-
1082
- return { mutationFn, ...mutationOptions };
1083
- };
1084
-
1085
- export type InviteMemberMutationResult = NonNullable<
1086
- Awaited<ReturnType<ReturnType<typeof useInviteMemberHook>>>
1087
- >;
1088
- export type InviteMemberMutationBody = BodyType<InviteMemberInput>;
1089
- export type InviteMemberMutationError = ErrorType<
1090
- InviteMember400 | InviteMember403 | InviteMember404
1091
- >;
1092
-
1093
- export const useInviteMember = <
1094
- TError = ErrorType<InviteMember400 | InviteMember403 | InviteMember404>,
1095
- TContext = unknown,
1096
- >(options?: {
1097
- mutation?: UseMutationOptions<
1098
- Awaited<ReturnType<ReturnType<typeof useInviteMemberHook>>>,
1099
- TError,
1100
- { data: BodyType<InviteMemberInput> },
1101
- TContext
1102
- >;
1103
- }): UseMutationResult<
1104
- Awaited<ReturnType<ReturnType<typeof useInviteMemberHook>>>,
1105
- TError,
1106
- { data: BodyType<InviteMemberInput> },
1107
- TContext
1108
- > => {
1109
- const mutationOptions = useInviteMemberMutationOptions(options);
1110
-
1111
- return useMutation(mutationOptions);
1112
- };
1113
-
1114
- export const useResendInviteHook = () => {
1115
- const resendInvite = useWidgetsApiClient<ResendInvite201>();
1116
-
1117
- return useCallback(
1118
- (userId: string, signal?: AbortSignal) => {
1119
- return resendInvite({
1120
- url: `/_widgets/UserManagement/invites/${userId}/resend`,
1121
- method: "POST",
1122
- signal,
1123
- });
1124
- },
1125
- [resendInvite],
1126
- );
1127
- };
1128
-
1129
- export const useResendInviteMutationOptions = <
1130
- TError = ErrorType<ResendInvite400 | ResendInvite403 | ResendInvite404>,
1131
- TContext = unknown,
1132
- >(options?: {
1133
- mutation?: UseMutationOptions<
1134
- Awaited<ReturnType<ReturnType<typeof useResendInviteHook>>>,
1135
- TError,
1136
- { userId: string },
1137
- TContext
1138
- >;
1139
- }): UseMutationOptions<
1140
- Awaited<ReturnType<ReturnType<typeof useResendInviteHook>>>,
1141
- TError,
1142
- { userId: string },
1143
- TContext
1144
- > => {
1145
- const mutationKey = ["resendInvite"];
1146
- const { mutation: mutationOptions } = options
1147
- ? options.mutation &&
1148
- "mutationKey" in options.mutation &&
1149
- options.mutation.mutationKey
1150
- ? options
1151
- : { ...options, mutation: { ...options.mutation, mutationKey } }
1152
- : { mutation: { mutationKey } };
1153
-
1154
- const resendInvite = useResendInviteHook();
1155
-
1156
- const mutationFn: MutationFunction<
1157
- Awaited<ReturnType<ReturnType<typeof useResendInviteHook>>>,
1158
- { userId: string }
1159
- > = (props) => {
1160
- const { userId } = props ?? {};
1161
-
1162
- return resendInvite(userId);
1163
- };
1164
-
1165
- return { mutationFn, ...mutationOptions };
1166
- };
1167
-
1168
- export type ResendInviteMutationResult = NonNullable<
1169
- Awaited<ReturnType<ReturnType<typeof useResendInviteHook>>>
1170
- >;
1171
-
1172
- export type ResendInviteMutationError = ErrorType<
1173
- ResendInvite400 | ResendInvite403 | ResendInvite404
1174
- >;
1175
-
1176
- export const useResendInvite = <
1177
- TError = ErrorType<ResendInvite400 | ResendInvite403 | ResendInvite404>,
1178
- TContext = unknown,
1179
- >(options?: {
1180
- mutation?: UseMutationOptions<
1181
- Awaited<ReturnType<ReturnType<typeof useResendInviteHook>>>,
1182
- TError,
1183
- { userId: string },
1184
- TContext
1185
- >;
1186
- }): UseMutationResult<
1187
- Awaited<ReturnType<ReturnType<typeof useResendInviteHook>>>,
1188
- TError,
1189
- { userId: string },
1190
- TContext
1191
- > => {
1192
- const mutationOptions = useResendInviteMutationOptions(options);
1193
-
1194
- return useMutation(mutationOptions);
1195
- };
1196
-
1197
- export const useRevokeInviteHook = () => {
1198
- const revokeInvite = useWidgetsApiClient<RevokeInvite200>();
1199
-
1200
- return useCallback(
1201
- (userId: string) => {
1202
- return revokeInvite({
1203
- url: `/_widgets/UserManagement/invites/${userId}`,
1204
- method: "DELETE",
1205
- });
1206
- },
1207
- [revokeInvite],
1208
- );
1209
- };
1210
-
1211
- export const useRevokeInviteMutationOptions = <
1212
- TError = ErrorType<RevokeInvite400 | RevokeInvite403 | RevokeInvite404>,
1213
- TContext = unknown,
1214
- >(options?: {
1215
- mutation?: UseMutationOptions<
1216
- Awaited<ReturnType<ReturnType<typeof useRevokeInviteHook>>>,
1217
- TError,
1218
- { userId: string },
1219
- TContext
1220
- >;
1221
- }): UseMutationOptions<
1222
- Awaited<ReturnType<ReturnType<typeof useRevokeInviteHook>>>,
1223
- TError,
1224
- { userId: string },
1225
- TContext
1226
- > => {
1227
- const mutationKey = ["revokeInvite"];
1228
- const { mutation: mutationOptions } = options
1229
- ? options.mutation &&
1230
- "mutationKey" in options.mutation &&
1231
- options.mutation.mutationKey
1232
- ? options
1233
- : { ...options, mutation: { ...options.mutation, mutationKey } }
1234
- : { mutation: { mutationKey } };
1235
-
1236
- const revokeInvite = useRevokeInviteHook();
1237
-
1238
- const mutationFn: MutationFunction<
1239
- Awaited<ReturnType<ReturnType<typeof useRevokeInviteHook>>>,
1240
- { userId: string }
1241
- > = (props) => {
1242
- const { userId } = props ?? {};
1243
-
1244
- return revokeInvite(userId);
1245
- };
1246
-
1247
- return { mutationFn, ...mutationOptions };
1248
- };
1249
-
1250
- export type RevokeInviteMutationResult = NonNullable<
1251
- Awaited<ReturnType<ReturnType<typeof useRevokeInviteHook>>>
1252
- >;
1253
-
1254
- export type RevokeInviteMutationError = ErrorType<
1255
- RevokeInvite400 | RevokeInvite403 | RevokeInvite404
1256
- >;
1257
-
1258
- export const useRevokeInvite = <
1259
- TError = ErrorType<RevokeInvite400 | RevokeInvite403 | RevokeInvite404>,
1260
- TContext = unknown,
1261
- >(options?: {
1262
- mutation?: UseMutationOptions<
1263
- Awaited<ReturnType<ReturnType<typeof useRevokeInviteHook>>>,
1264
- TError,
1265
- { userId: string },
1266
- TContext
1267
- >;
1268
- }): UseMutationResult<
1269
- Awaited<ReturnType<ReturnType<typeof useRevokeInviteHook>>>,
1270
- TError,
1271
- { userId: string },
1272
- TContext
1273
- > => {
1274
- const mutationOptions = useRevokeInviteMutationOptions(options);
1275
-
1276
- return useMutation(mutationOptions);
1277
- };
1278
-
1279
- export const useRemoveMemberHook = () => {
1280
- const removeMember = useWidgetsApiClient<RemoveMember200>();
1281
-
1282
- return useCallback(
1283
- (userId: string) => {
1284
- return removeMember({
1285
- url: `/_widgets/UserManagement/members/${userId}`,
1286
- method: "DELETE",
1287
- });
1288
- },
1289
- [removeMember],
1290
- );
1291
- };
1292
-
1293
- export const useRemoveMemberMutationOptions = <
1294
- TError = ErrorType<RemoveMember400 | RemoveMember403 | RemoveMember404>,
1295
- TContext = unknown,
1296
- >(options?: {
1297
- mutation?: UseMutationOptions<
1298
- Awaited<ReturnType<ReturnType<typeof useRemoveMemberHook>>>,
1299
- TError,
1300
- { userId: string },
1301
- TContext
1302
- >;
1303
- }): UseMutationOptions<
1304
- Awaited<ReturnType<ReturnType<typeof useRemoveMemberHook>>>,
1305
- TError,
1306
- { userId: string },
1307
- TContext
1308
- > => {
1309
- const mutationKey = ["removeMember"];
1310
- const { mutation: mutationOptions } = options
1311
- ? options.mutation &&
1312
- "mutationKey" in options.mutation &&
1313
- options.mutation.mutationKey
1314
- ? options
1315
- : { ...options, mutation: { ...options.mutation, mutationKey } }
1316
- : { mutation: { mutationKey } };
1317
-
1318
- const removeMember = useRemoveMemberHook();
1319
-
1320
- const mutationFn: MutationFunction<
1321
- Awaited<ReturnType<ReturnType<typeof useRemoveMemberHook>>>,
1322
- { userId: string }
1323
- > = (props) => {
1324
- const { userId } = props ?? {};
1325
-
1326
- return removeMember(userId);
1327
- };
1328
-
1329
- return { mutationFn, ...mutationOptions };
1330
- };
1331
-
1332
- export type RemoveMemberMutationResult = NonNullable<
1333
- Awaited<ReturnType<ReturnType<typeof useRemoveMemberHook>>>
1334
- >;
1335
-
1336
- export type RemoveMemberMutationError = ErrorType<
1337
- RemoveMember400 | RemoveMember403 | RemoveMember404
1338
- >;
1339
-
1340
- export const useRemoveMember = <
1341
- TError = ErrorType<RemoveMember400 | RemoveMember403 | RemoveMember404>,
1342
- TContext = unknown,
1343
- >(options?: {
1344
- mutation?: UseMutationOptions<
1345
- Awaited<ReturnType<ReturnType<typeof useRemoveMemberHook>>>,
1346
- TError,
1347
- { userId: string },
1348
- TContext
1349
- >;
1350
- }): UseMutationResult<
1351
- Awaited<ReturnType<ReturnType<typeof useRemoveMemberHook>>>,
1352
- TError,
1353
- { userId: string },
1354
- TContext
1355
- > => {
1356
- const mutationOptions = useRemoveMemberMutationOptions(options);
1357
-
1358
- return useMutation(mutationOptions);
1359
- };
1360
-
1361
- export const useUpdateMemberHook = () => {
1362
- const updateMember = useWidgetsApiClient<UpdateMember200>();
1363
-
1364
- return useCallback(
1365
- (
1366
- userId: string,
1367
- updateMemberInput: BodyType<UpdateMemberInput>,
1368
- signal?: AbortSignal,
1369
- ) => {
1370
- return updateMember({
1371
- url: `/_widgets/UserManagement/members/${userId}`,
1372
- method: "POST",
1373
- headers: { "Content-Type": "application/json" },
1374
- data: updateMemberInput,
1375
- signal,
1376
- });
1377
- },
1378
- [updateMember],
1379
- );
1380
- };
1381
-
1382
- export const useUpdateMemberMutationOptions = <
1383
- TError = ErrorType<UpdateMember400 | UpdateMember403 | UpdateMember404>,
1384
- TContext = unknown,
1385
- >(options?: {
1386
- mutation?: UseMutationOptions<
1387
- Awaited<ReturnType<ReturnType<typeof useUpdateMemberHook>>>,
1388
- TError,
1389
- { userId: string; data: BodyType<UpdateMemberInput> },
1390
- TContext
1391
- >;
1392
- }): UseMutationOptions<
1393
- Awaited<ReturnType<ReturnType<typeof useUpdateMemberHook>>>,
1394
- TError,
1395
- { userId: string; data: BodyType<UpdateMemberInput> },
1396
- TContext
1397
- > => {
1398
- const mutationKey = ["updateMember"];
1399
- const { mutation: mutationOptions } = options
1400
- ? options.mutation &&
1401
- "mutationKey" in options.mutation &&
1402
- options.mutation.mutationKey
1403
- ? options
1404
- : { ...options, mutation: { ...options.mutation, mutationKey } }
1405
- : { mutation: { mutationKey } };
1406
-
1407
- const updateMember = useUpdateMemberHook();
1408
-
1409
- const mutationFn: MutationFunction<
1410
- Awaited<ReturnType<ReturnType<typeof useUpdateMemberHook>>>,
1411
- { userId: string; data: BodyType<UpdateMemberInput> }
1412
- > = (props) => {
1413
- const { userId, data } = props ?? {};
1414
-
1415
- return updateMember(userId, data);
1416
- };
1417
-
1418
- return { mutationFn, ...mutationOptions };
1419
- };
1420
-
1421
- export type UpdateMemberMutationResult = NonNullable<
1422
- Awaited<ReturnType<ReturnType<typeof useUpdateMemberHook>>>
1423
- >;
1424
- export type UpdateMemberMutationBody = BodyType<UpdateMemberInput>;
1425
- export type UpdateMemberMutationError = ErrorType<
1426
- UpdateMember400 | UpdateMember403 | UpdateMember404
1427
- >;
1428
-
1429
- export const useUpdateMember = <
1430
- TError = ErrorType<UpdateMember400 | UpdateMember403 | UpdateMember404>,
1431
- TContext = unknown,
1432
- >(options?: {
1433
- mutation?: UseMutationOptions<
1434
- Awaited<ReturnType<ReturnType<typeof useUpdateMemberHook>>>,
1435
- TError,
1436
- { userId: string; data: BodyType<UpdateMemberInput> },
1437
- TContext
1438
- >;
1439
- }): UseMutationResult<
1440
- Awaited<ReturnType<ReturnType<typeof useUpdateMemberHook>>>,
1441
- TError,
1442
- { userId: string; data: BodyType<UpdateMemberInput> },
1443
- TContext
1444
- > => {
1445
- const mutationOptions = useUpdateMemberMutationOptions(options);
1446
-
1447
- return useMutation(mutationOptions);
1448
- };
1449
-
1450
- export const useOrganizationsHook = () => {
1451
- const organizations = useWidgetsApiClient<OrganizationsResponse>();
1452
-
1453
- return useCallback(
1454
- (signal?: AbortSignal) => {
1455
- return organizations({
1456
- url: `/_widgets/UserManagement/organizations`,
1457
- method: "GET",
1458
- signal,
1459
- });
1460
- },
1461
- [organizations],
1462
- );
1463
- };
1464
-
1465
- export const getOrganizationsQueryKey = () => {
1466
- return [`/_widgets/UserManagement/organizations`] as const;
1467
- };
1468
-
1469
- export const useOrganizationsQueryOptions = <
1470
- TData = Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1471
- TError = ErrorType<Organizations403 | Organizations404>,
1472
- >(options?: {
1473
- query?: Partial<
1474
- UseQueryOptions<
1475
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1476
- TError,
1477
- TData
1478
- >
1479
- >;
1480
- }) => {
1481
- const { query: queryOptions } = options ?? {};
1482
-
1483
- const queryKey = queryOptions?.queryKey ?? getOrganizationsQueryKey();
1484
-
1485
- const organizations = useOrganizationsHook();
1486
-
1487
- const queryFn: QueryFunction<
1488
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>
1489
- > = ({ signal }) => organizations(signal);
1490
-
1491
- const customOptions = useWidgetsApiQueryOptions({
1492
- ...queryOptions,
1493
- queryKey,
1494
- queryFn,
1495
- });
1496
-
1497
- return customOptions as UseQueryOptions<
1498
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1499
- TError,
1500
- TData
1501
- > & { queryKey: DataTag<QueryKey, TData> };
1502
- };
1503
-
1504
- export type OrganizationsQueryResult = NonNullable<
1505
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>
1506
- >;
1507
- export type OrganizationsQueryError = ErrorType<
1508
- Organizations403 | Organizations404
1509
- >;
1510
-
1511
- export function useOrganizations<
1512
- TData = Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1513
- TError = ErrorType<Organizations403 | Organizations404>,
1514
- >(options: {
1515
- query: Partial<
1516
- UseQueryOptions<
1517
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1518
- TError,
1519
- TData
1520
- >
1521
- > &
1522
- Pick<
1523
- DefinedInitialDataOptions<
1524
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1525
- TError,
1526
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>
1527
- >,
1528
- "initialData"
1529
- >;
1530
- }): DefinedUseQueryResult<TData, TError> & {
1531
- queryKey: DataTag<QueryKey, TData>;
1532
- };
1533
- export function useOrganizations<
1534
- TData = Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1535
- TError = ErrorType<Organizations403 | Organizations404>,
1536
- >(options?: {
1537
- query?: Partial<
1538
- UseQueryOptions<
1539
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1540
- TError,
1541
- TData
1542
- >
1543
- > &
1544
- Pick<
1545
- UndefinedInitialDataOptions<
1546
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1547
- TError,
1548
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>
1549
- >,
1550
- "initialData"
1551
- >;
1552
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
1553
- export function useOrganizations<
1554
- TData = Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1555
- TError = ErrorType<Organizations403 | Organizations404>,
1556
- >(options?: {
1557
- query?: Partial<
1558
- UseQueryOptions<
1559
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1560
- TError,
1561
- TData
1562
- >
1563
- >;
1564
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
1565
-
1566
- export function useOrganizations<
1567
- TData = Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1568
- TError = ErrorType<Organizations403 | Organizations404>,
1569
- >(options?: {
1570
- query?: Partial<
1571
- UseQueryOptions<
1572
- Awaited<ReturnType<ReturnType<typeof useOrganizationsHook>>>,
1573
- TError,
1574
- TData
1575
- >
1576
- >;
1577
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {
1578
- const queryOptions = useOrganizationsQueryOptions(options);
1579
-
1580
- const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
1581
- queryKey: DataTag<QueryKey, TData>;
1582
- };
1583
-
1584
- query.queryKey = queryOptions.queryKey;
1585
-
1586
- return query;
1587
- }
1588
-
1589
- export const useMeHook = () => {
1590
- const me = useWidgetsApiClient<Me>();
1591
-
1592
- return useCallback(
1593
- (signal?: AbortSignal) => {
1594
- return me({ url: `/_widgets/UserProfile/me`, method: "GET", signal });
1595
- },
1596
- [me],
1597
- );
1598
- };
1599
-
1600
- export const getMeQueryKey = () => {
1601
- return [`/_widgets/UserProfile/me`] as const;
1602
- };
1603
-
1604
- export const useMeQueryOptions = <
1605
- TData = Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1606
- TError = ErrorType<Me403>,
1607
- >(options?: {
1608
- query?: Partial<
1609
- UseQueryOptions<
1610
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1611
- TError,
1612
- TData
1613
- >
1614
- >;
1615
- }) => {
1616
- const { query: queryOptions } = options ?? {};
1617
-
1618
- const queryKey = queryOptions?.queryKey ?? getMeQueryKey();
1619
-
1620
- const me = useMeHook();
1621
-
1622
- const queryFn: QueryFunction<
1623
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>
1624
- > = ({ signal }) => me(signal);
1625
-
1626
- const customOptions = useWidgetsApiQueryOptions({
1627
- ...queryOptions,
1628
- queryKey,
1629
- queryFn,
1630
- });
1631
-
1632
- return customOptions as UseQueryOptions<
1633
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1634
- TError,
1635
- TData
1636
- > & { queryKey: DataTag<QueryKey, TData> };
1637
- };
1638
-
1639
- export type MeQueryResult = NonNullable<
1640
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>
1641
- >;
1642
- export type MeQueryError = ErrorType<Me403>;
1643
-
1644
- export function useMe<
1645
- TData = Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1646
- TError = ErrorType<Me403>,
1647
- >(options: {
1648
- query: Partial<
1649
- UseQueryOptions<
1650
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1651
- TError,
1652
- TData
1653
- >
1654
- > &
1655
- Pick<
1656
- DefinedInitialDataOptions<
1657
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1658
- TError,
1659
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>
1660
- >,
1661
- "initialData"
1662
- >;
1663
- }): DefinedUseQueryResult<TData, TError> & {
1664
- queryKey: DataTag<QueryKey, TData>;
1665
- };
1666
- export function useMe<
1667
- TData = Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1668
- TError = ErrorType<Me403>,
1669
- >(options?: {
1670
- query?: Partial<
1671
- UseQueryOptions<
1672
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1673
- TError,
1674
- TData
1675
- >
1676
- > &
1677
- Pick<
1678
- UndefinedInitialDataOptions<
1679
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1680
- TError,
1681
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>
1682
- >,
1683
- "initialData"
1684
- >;
1685
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
1686
- export function useMe<
1687
- TData = Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1688
- TError = ErrorType<Me403>,
1689
- >(options?: {
1690
- query?: Partial<
1691
- UseQueryOptions<
1692
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1693
- TError,
1694
- TData
1695
- >
1696
- >;
1697
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
1698
-
1699
- export function useMe<
1700
- TData = Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1701
- TError = ErrorType<Me403>,
1702
- >(options?: {
1703
- query?: Partial<
1704
- UseQueryOptions<
1705
- Awaited<ReturnType<ReturnType<typeof useMeHook>>>,
1706
- TError,
1707
- TData
1708
- >
1709
- >;
1710
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {
1711
- const queryOptions = useMeQueryOptions(options);
1712
-
1713
- const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
1714
- queryKey: DataTag<QueryKey, TData>;
1715
- };
1716
-
1717
- query.queryKey = queryOptions.queryKey;
1718
-
1719
- return query;
1720
- }
1721
-
1722
- export const useUpdateMeHook = () => {
1723
- const updateMe = useWidgetsApiClient<Me>();
1724
-
1725
- return useCallback(
1726
- (updateMeInput: BodyType<UpdateMeInput>, signal?: AbortSignal) => {
1727
- return updateMe({
1728
- url: `/_widgets/UserProfile/me`,
1729
- method: "POST",
1730
- headers: { "Content-Type": "application/json" },
1731
- data: updateMeInput,
1732
- signal,
1733
- });
1734
- },
1735
- [updateMe],
1736
- );
1737
- };
1738
-
1739
- export const useUpdateMeMutationOptions = <
1740
- TError = ErrorType<UpdateMe400 | UpdateMe403>,
1741
- TContext = unknown,
1742
- >(options?: {
1743
- mutation?: UseMutationOptions<
1744
- Awaited<ReturnType<ReturnType<typeof useUpdateMeHook>>>,
1745
- TError,
1746
- { data: BodyType<UpdateMeInput> },
1747
- TContext
1748
- >;
1749
- }): UseMutationOptions<
1750
- Awaited<ReturnType<ReturnType<typeof useUpdateMeHook>>>,
1751
- TError,
1752
- { data: BodyType<UpdateMeInput> },
1753
- TContext
1754
- > => {
1755
- const mutationKey = ["updateMe"];
1756
- const { mutation: mutationOptions } = options
1757
- ? options.mutation &&
1758
- "mutationKey" in options.mutation &&
1759
- options.mutation.mutationKey
1760
- ? options
1761
- : { ...options, mutation: { ...options.mutation, mutationKey } }
1762
- : { mutation: { mutationKey } };
1763
-
1764
- const updateMe = useUpdateMeHook();
1765
-
1766
- const mutationFn: MutationFunction<
1767
- Awaited<ReturnType<ReturnType<typeof useUpdateMeHook>>>,
1768
- { data: BodyType<UpdateMeInput> }
1769
- > = (props) => {
1770
- const { data } = props ?? {};
1771
-
1772
- return updateMe(data);
1773
- };
1774
-
1775
- return { mutationFn, ...mutationOptions };
1776
- };
1777
-
1778
- export type UpdateMeMutationResult = NonNullable<
1779
- Awaited<ReturnType<ReturnType<typeof useUpdateMeHook>>>
1780
- >;
1781
- export type UpdateMeMutationBody = BodyType<UpdateMeInput>;
1782
- export type UpdateMeMutationError = ErrorType<UpdateMe400 | UpdateMe403>;
1783
-
1784
- export const useUpdateMe = <
1785
- TError = ErrorType<UpdateMe400 | UpdateMe403>,
1786
- TContext = unknown,
1787
- >(options?: {
1788
- mutation?: UseMutationOptions<
1789
- Awaited<ReturnType<ReturnType<typeof useUpdateMeHook>>>,
1790
- TError,
1791
- { data: BodyType<UpdateMeInput> },
1792
- TContext
1793
- >;
1794
- }): UseMutationResult<
1795
- Awaited<ReturnType<ReturnType<typeof useUpdateMeHook>>>,
1796
- TError,
1797
- { data: BodyType<UpdateMeInput> },
1798
- TContext
1799
- > => {
1800
- const mutationOptions = useUpdateMeMutationOptions(options);
1801
-
1802
- return useMutation(mutationOptions);
1803
- };
1804
-
1805
- export const useCreateTotpFactorHook = () => {
1806
- const createTotpFactor = useWidgetsApiClient<CreateTotpFactorResponse>();
1807
-
1808
- return useCallback(
1809
- (signal?: AbortSignal) => {
1810
- return createTotpFactor({
1811
- url: `/_widgets/UserProfile/create-totp-factor`,
1812
- method: "POST",
1813
- signal,
1814
- });
1815
- },
1816
- [createTotpFactor],
1817
- );
1818
- };
1819
-
1820
- export const useCreateTotpFactorMutationOptions = <
1821
- TError = ErrorType<CreateTotpFactor400 | CreateTotpFactor403>,
1822
- TContext = unknown,
1823
- >(options?: {
1824
- mutation?: UseMutationOptions<
1825
- Awaited<ReturnType<ReturnType<typeof useCreateTotpFactorHook>>>,
1826
- TError,
1827
- void,
1828
- TContext
1829
- >;
1830
- }): UseMutationOptions<
1831
- Awaited<ReturnType<ReturnType<typeof useCreateTotpFactorHook>>>,
1832
- TError,
1833
- void,
1834
- TContext
1835
- > => {
1836
- const mutationKey = ["createTotpFactor"];
1837
- const { mutation: mutationOptions } = options
1838
- ? options.mutation &&
1839
- "mutationKey" in options.mutation &&
1840
- options.mutation.mutationKey
1841
- ? options
1842
- : { ...options, mutation: { ...options.mutation, mutationKey } }
1843
- : { mutation: { mutationKey } };
1844
-
1845
- const createTotpFactor = useCreateTotpFactorHook();
1846
-
1847
- const mutationFn: MutationFunction<
1848
- Awaited<ReturnType<ReturnType<typeof useCreateTotpFactorHook>>>,
1849
- void
1850
- > = () => {
1851
- return createTotpFactor();
1852
- };
1853
-
1854
- return { mutationFn, ...mutationOptions };
1855
- };
1856
-
1857
- export type CreateTotpFactorMutationResult = NonNullable<
1858
- Awaited<ReturnType<ReturnType<typeof useCreateTotpFactorHook>>>
1859
- >;
1860
-
1861
- export type CreateTotpFactorMutationError = ErrorType<
1862
- CreateTotpFactor400 | CreateTotpFactor403
1863
- >;
1864
-
1865
- export const useCreateTotpFactor = <
1866
- TError = ErrorType<CreateTotpFactor400 | CreateTotpFactor403>,
1867
- TContext = unknown,
1868
- >(options?: {
1869
- mutation?: UseMutationOptions<
1870
- Awaited<ReturnType<ReturnType<typeof useCreateTotpFactorHook>>>,
1871
- TError,
1872
- void,
1873
- TContext
1874
- >;
1875
- }): UseMutationResult<
1876
- Awaited<ReturnType<ReturnType<typeof useCreateTotpFactorHook>>>,
1877
- TError,
1878
- void,
1879
- TContext
1880
- > => {
1881
- const mutationOptions = useCreateTotpFactorMutationOptions(options);
1882
-
1883
- return useMutation(mutationOptions);
1884
- };
1885
-
1886
- export const useVerifyTotpFactorHook = () => {
1887
- const verifyTotpFactor = useWidgetsApiClient<VerifyTotpFactor200>();
1888
-
1889
- return useCallback(
1890
- (
1891
- verifyTotpFactorRequest: BodyType<VerifyTotpFactorRequest>,
1892
- signal?: AbortSignal,
1893
- ) => {
1894
- return verifyTotpFactor({
1895
- url: `/_widgets/UserProfile/verify-totp-factor`,
1896
- method: "POST",
1897
- headers: { "Content-Type": "application/json" },
1898
- data: verifyTotpFactorRequest,
1899
- signal,
1900
- });
1901
- },
1902
- [verifyTotpFactor],
1903
- );
1904
- };
1905
-
1906
- export const useVerifyTotpFactorMutationOptions = <
1907
- TError = ErrorType<VerifyTotpFactor400 | VerifyTotpFactor403>,
1908
- TContext = unknown,
1909
- >(options?: {
1910
- mutation?: UseMutationOptions<
1911
- Awaited<ReturnType<ReturnType<typeof useVerifyTotpFactorHook>>>,
1912
- TError,
1913
- { data: BodyType<VerifyTotpFactorRequest> },
1914
- TContext
1915
- >;
1916
- }): UseMutationOptions<
1917
- Awaited<ReturnType<ReturnType<typeof useVerifyTotpFactorHook>>>,
1918
- TError,
1919
- { data: BodyType<VerifyTotpFactorRequest> },
1920
- TContext
1921
- > => {
1922
- const mutationKey = ["verifyTotpFactor"];
1923
- const { mutation: mutationOptions } = options
1924
- ? options.mutation &&
1925
- "mutationKey" in options.mutation &&
1926
- options.mutation.mutationKey
1927
- ? options
1928
- : { ...options, mutation: { ...options.mutation, mutationKey } }
1929
- : { mutation: { mutationKey } };
1930
-
1931
- const verifyTotpFactor = useVerifyTotpFactorHook();
1932
-
1933
- const mutationFn: MutationFunction<
1934
- Awaited<ReturnType<ReturnType<typeof useVerifyTotpFactorHook>>>,
1935
- { data: BodyType<VerifyTotpFactorRequest> }
1936
- > = (props) => {
1937
- const { data } = props ?? {};
1938
-
1939
- return verifyTotpFactor(data);
1940
- };
1941
-
1942
- return { mutationFn, ...mutationOptions };
1943
- };
1944
-
1945
- export type VerifyTotpFactorMutationResult = NonNullable<
1946
- Awaited<ReturnType<ReturnType<typeof useVerifyTotpFactorHook>>>
1947
- >;
1948
- export type VerifyTotpFactorMutationBody = BodyType<VerifyTotpFactorRequest>;
1949
- export type VerifyTotpFactorMutationError = ErrorType<
1950
- VerifyTotpFactor400 | VerifyTotpFactor403
1951
- >;
1952
-
1953
- export const useVerifyTotpFactor = <
1954
- TError = ErrorType<VerifyTotpFactor400 | VerifyTotpFactor403>,
1955
- TContext = unknown,
1956
- >(options?: {
1957
- mutation?: UseMutationOptions<
1958
- Awaited<ReturnType<ReturnType<typeof useVerifyTotpFactorHook>>>,
1959
- TError,
1960
- { data: BodyType<VerifyTotpFactorRequest> },
1961
- TContext
1962
- >;
1963
- }): UseMutationResult<
1964
- Awaited<ReturnType<ReturnType<typeof useVerifyTotpFactorHook>>>,
1965
- TError,
1966
- { data: BodyType<VerifyTotpFactorRequest> },
1967
- TContext
1968
- > => {
1969
- const mutationOptions = useVerifyTotpFactorMutationOptions(options);
1970
-
1971
- return useMutation(mutationOptions);
1972
- };
1973
-
1974
- export const useDeleteTotpFactorsHook = () => {
1975
- const deleteTotpFactors = useWidgetsApiClient<DeleteTotpFactors200>();
1976
-
1977
- return useCallback(() => {
1978
- return deleteTotpFactors({
1979
- url: `/_widgets/UserProfile/totp-factors`,
1980
- method: "DELETE",
1981
- });
1982
- }, [deleteTotpFactors]);
1983
- };
1984
-
1985
- export const useDeleteTotpFactorsMutationOptions = <
1986
- TError = ErrorType<DeleteTotpFactors400 | DeleteTotpFactors403>,
1987
- TContext = unknown,
1988
- >(options?: {
1989
- mutation?: UseMutationOptions<
1990
- Awaited<ReturnType<ReturnType<typeof useDeleteTotpFactorsHook>>>,
1991
- TError,
1992
- void,
1993
- TContext
1994
- >;
1995
- }): UseMutationOptions<
1996
- Awaited<ReturnType<ReturnType<typeof useDeleteTotpFactorsHook>>>,
1997
- TError,
1998
- void,
1999
- TContext
2000
- > => {
2001
- const mutationKey = ["deleteTotpFactors"];
2002
- const { mutation: mutationOptions } = options
2003
- ? options.mutation &&
2004
- "mutationKey" in options.mutation &&
2005
- options.mutation.mutationKey
2006
- ? options
2007
- : { ...options, mutation: { ...options.mutation, mutationKey } }
2008
- : { mutation: { mutationKey } };
2009
-
2010
- const deleteTotpFactors = useDeleteTotpFactorsHook();
2011
-
2012
- const mutationFn: MutationFunction<
2013
- Awaited<ReturnType<ReturnType<typeof useDeleteTotpFactorsHook>>>,
2014
- void
2015
- > = () => {
2016
- return deleteTotpFactors();
2017
- };
2018
-
2019
- return { mutationFn, ...mutationOptions };
2020
- };
2021
-
2022
- export type DeleteTotpFactorsMutationResult = NonNullable<
2023
- Awaited<ReturnType<ReturnType<typeof useDeleteTotpFactorsHook>>>
2024
- >;
2025
-
2026
- export type DeleteTotpFactorsMutationError = ErrorType<
2027
- DeleteTotpFactors400 | DeleteTotpFactors403
2028
- >;
2029
-
2030
- export const useDeleteTotpFactors = <
2031
- TError = ErrorType<DeleteTotpFactors400 | DeleteTotpFactors403>,
2032
- TContext = unknown,
2033
- >(options?: {
2034
- mutation?: UseMutationOptions<
2035
- Awaited<ReturnType<ReturnType<typeof useDeleteTotpFactorsHook>>>,
2036
- TError,
2037
- void,
2038
- TContext
2039
- >;
2040
- }): UseMutationResult<
2041
- Awaited<ReturnType<ReturnType<typeof useDeleteTotpFactorsHook>>>,
2042
- TError,
2043
- void,
2044
- TContext
2045
- > => {
2046
- const mutationOptions = useDeleteTotpFactorsMutationOptions(options);
2047
-
2048
- return useMutation(mutationOptions);
2049
- };
2050
-
2051
- export const useAuthenticationInformationHook = () => {
2052
- const authenticationInformation =
2053
- useWidgetsApiClient<AuthenticationInformationResponse>();
2054
-
2055
- return useCallback(
2056
- (signal?: AbortSignal) => {
2057
- return authenticationInformation({
2058
- url: `/_widgets/UserProfile/authentication-information`,
2059
- method: "GET",
2060
- signal,
2061
- });
2062
- },
2063
- [authenticationInformation],
2064
- );
2065
- };
2066
-
2067
- export const getAuthenticationInformationQueryKey = () => {
2068
- return [`/_widgets/UserProfile/authentication-information`] as const;
2069
- };
2070
-
2071
- export const useAuthenticationInformationQueryOptions = <
2072
- TData = Awaited<
2073
- ReturnType<ReturnType<typeof useAuthenticationInformationHook>>
2074
- >,
2075
- TError = ErrorType<AuthenticationInformation403>,
2076
- >(options?: {
2077
- query?: Partial<
2078
- UseQueryOptions<
2079
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>,
2080
- TError,
2081
- TData
2082
- >
2083
- >;
2084
- }) => {
2085
- const { query: queryOptions } = options ?? {};
2086
-
2087
- const queryKey =
2088
- queryOptions?.queryKey ?? getAuthenticationInformationQueryKey();
2089
-
2090
- const authenticationInformation = useAuthenticationInformationHook();
2091
-
2092
- const queryFn: QueryFunction<
2093
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>
2094
- > = ({ signal }) => authenticationInformation(signal);
2095
-
2096
- const customOptions = useWidgetsApiQueryOptions({
2097
- ...queryOptions,
2098
- queryKey,
2099
- queryFn,
2100
- });
2101
-
2102
- return customOptions as UseQueryOptions<
2103
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>,
2104
- TError,
2105
- TData
2106
- > & { queryKey: DataTag<QueryKey, TData> };
2107
- };
2108
-
2109
- export type AuthenticationInformationQueryResult = NonNullable<
2110
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>
2111
- >;
2112
- export type AuthenticationInformationQueryError =
2113
- ErrorType<AuthenticationInformation403>;
2114
-
2115
- export function useAuthenticationInformation<
2116
- TData = Awaited<
2117
- ReturnType<ReturnType<typeof useAuthenticationInformationHook>>
2118
- >,
2119
- TError = ErrorType<AuthenticationInformation403>,
2120
- >(options: {
2121
- query: Partial<
2122
- UseQueryOptions<
2123
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>,
2124
- TError,
2125
- TData
2126
- >
2127
- > &
2128
- Pick<
2129
- DefinedInitialDataOptions<
2130
- Awaited<
2131
- ReturnType<ReturnType<typeof useAuthenticationInformationHook>>
2132
- >,
2133
- TError,
2134
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>
2135
- >,
2136
- "initialData"
2137
- >;
2138
- }): DefinedUseQueryResult<TData, TError> & {
2139
- queryKey: DataTag<QueryKey, TData>;
2140
- };
2141
- export function useAuthenticationInformation<
2142
- TData = Awaited<
2143
- ReturnType<ReturnType<typeof useAuthenticationInformationHook>>
2144
- >,
2145
- TError = ErrorType<AuthenticationInformation403>,
2146
- >(options?: {
2147
- query?: Partial<
2148
- UseQueryOptions<
2149
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>,
2150
- TError,
2151
- TData
2152
- >
2153
- > &
2154
- Pick<
2155
- UndefinedInitialDataOptions<
2156
- Awaited<
2157
- ReturnType<ReturnType<typeof useAuthenticationInformationHook>>
2158
- >,
2159
- TError,
2160
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>
2161
- >,
2162
- "initialData"
2163
- >;
2164
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
2165
- export function useAuthenticationInformation<
2166
- TData = Awaited<
2167
- ReturnType<ReturnType<typeof useAuthenticationInformationHook>>
2168
- >,
2169
- TError = ErrorType<AuthenticationInformation403>,
2170
- >(options?: {
2171
- query?: Partial<
2172
- UseQueryOptions<
2173
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>,
2174
- TError,
2175
- TData
2176
- >
2177
- >;
2178
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
2179
-
2180
- export function useAuthenticationInformation<
2181
- TData = Awaited<
2182
- ReturnType<ReturnType<typeof useAuthenticationInformationHook>>
2183
- >,
2184
- TError = ErrorType<AuthenticationInformation403>,
2185
- >(options?: {
2186
- query?: Partial<
2187
- UseQueryOptions<
2188
- Awaited<ReturnType<ReturnType<typeof useAuthenticationInformationHook>>>,
2189
- TError,
2190
- TData
2191
- >
2192
- >;
2193
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {
2194
- const queryOptions = useAuthenticationInformationQueryOptions(options);
2195
-
2196
- const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
2197
- queryKey: DataTag<QueryKey, TData>;
2198
- };
2199
-
2200
- query.queryKey = queryOptions.queryKey;
2201
-
2202
- return query;
2203
- }
2204
-
2205
- export const useCreatePasswordHook = () => {
2206
- const createPassword = useWidgetsApiClient<CreatePassword201>();
2207
-
2208
- return useCallback(
2209
- (
2210
- createPasswordRequest: BodyType<CreatePasswordRequest>,
2211
- signal?: AbortSignal,
2212
- ) => {
2213
- return createPassword({
2214
- url: `/_widgets/UserProfile/create-password`,
2215
- method: "POST",
2216
- headers: { "Content-Type": "application/json" },
2217
- data: createPasswordRequest,
2218
- signal,
2219
- });
2220
- },
2221
- [createPassword],
2222
- );
2223
- };
2224
-
2225
- export const useCreatePasswordMutationOptions = <
2226
- TError = ErrorType<CreatePassword400 | CreatePassword403>,
2227
- TContext = unknown,
2228
- >(options?: {
2229
- mutation?: UseMutationOptions<
2230
- Awaited<ReturnType<ReturnType<typeof useCreatePasswordHook>>>,
2231
- TError,
2232
- { data: BodyType<CreatePasswordRequest> },
2233
- TContext
2234
- >;
2235
- }): UseMutationOptions<
2236
- Awaited<ReturnType<ReturnType<typeof useCreatePasswordHook>>>,
2237
- TError,
2238
- { data: BodyType<CreatePasswordRequest> },
2239
- TContext
2240
- > => {
2241
- const mutationKey = ["createPassword"];
2242
- const { mutation: mutationOptions } = options
2243
- ? options.mutation &&
2244
- "mutationKey" in options.mutation &&
2245
- options.mutation.mutationKey
2246
- ? options
2247
- : { ...options, mutation: { ...options.mutation, mutationKey } }
2248
- : { mutation: { mutationKey } };
2249
-
2250
- const createPassword = useCreatePasswordHook();
2251
-
2252
- const mutationFn: MutationFunction<
2253
- Awaited<ReturnType<ReturnType<typeof useCreatePasswordHook>>>,
2254
- { data: BodyType<CreatePasswordRequest> }
2255
- > = (props) => {
2256
- const { data } = props ?? {};
2257
-
2258
- return createPassword(data);
2259
- };
2260
-
2261
- return { mutationFn, ...mutationOptions };
2262
- };
2263
-
2264
- export type CreatePasswordMutationResult = NonNullable<
2265
- Awaited<ReturnType<ReturnType<typeof useCreatePasswordHook>>>
2266
- >;
2267
- export type CreatePasswordMutationBody = BodyType<CreatePasswordRequest>;
2268
- export type CreatePasswordMutationError = ErrorType<
2269
- CreatePassword400 | CreatePassword403
2270
- >;
2271
-
2272
- export const useCreatePassword = <
2273
- TError = ErrorType<CreatePassword400 | CreatePassword403>,
2274
- TContext = unknown,
2275
- >(options?: {
2276
- mutation?: UseMutationOptions<
2277
- Awaited<ReturnType<ReturnType<typeof useCreatePasswordHook>>>,
2278
- TError,
2279
- { data: BodyType<CreatePasswordRequest> },
2280
- TContext
2281
- >;
2282
- }): UseMutationResult<
2283
- Awaited<ReturnType<ReturnType<typeof useCreatePasswordHook>>>,
2284
- TError,
2285
- { data: BodyType<CreatePasswordRequest> },
2286
- TContext
2287
- > => {
2288
- const mutationOptions = useCreatePasswordMutationOptions(options);
2289
-
2290
- return useMutation(mutationOptions);
2291
- };
2292
-
2293
- export const useUpdatePasswordHook = () => {
2294
- const updatePassword = useWidgetsApiClient<UpdatePassword201>();
2295
-
2296
- return useCallback(
2297
- (
2298
- updatePasswordRequest: BodyType<UpdatePasswordRequest>,
2299
- signal?: AbortSignal,
2300
- ) => {
2301
- return updatePassword({
2302
- url: `/_widgets/UserProfile/update-password`,
2303
- method: "POST",
2304
- headers: { "Content-Type": "application/json" },
2305
- data: updatePasswordRequest,
2306
- signal,
2307
- });
2308
- },
2309
- [updatePassword],
2310
- );
2311
- };
2312
-
2313
- export const useUpdatePasswordMutationOptions = <
2314
- TError = ErrorType<UpdatePassword400 | UpdatePassword403>,
2315
- TContext = unknown,
2316
- >(options?: {
2317
- mutation?: UseMutationOptions<
2318
- Awaited<ReturnType<ReturnType<typeof useUpdatePasswordHook>>>,
2319
- TError,
2320
- { data: BodyType<UpdatePasswordRequest> },
2321
- TContext
2322
- >;
2323
- }): UseMutationOptions<
2324
- Awaited<ReturnType<ReturnType<typeof useUpdatePasswordHook>>>,
2325
- TError,
2326
- { data: BodyType<UpdatePasswordRequest> },
2327
- TContext
2328
- > => {
2329
- const mutationKey = ["updatePassword"];
2330
- const { mutation: mutationOptions } = options
2331
- ? options.mutation &&
2332
- "mutationKey" in options.mutation &&
2333
- options.mutation.mutationKey
2334
- ? options
2335
- : { ...options, mutation: { ...options.mutation, mutationKey } }
2336
- : { mutation: { mutationKey } };
2337
-
2338
- const updatePassword = useUpdatePasswordHook();
2339
-
2340
- const mutationFn: MutationFunction<
2341
- Awaited<ReturnType<ReturnType<typeof useUpdatePasswordHook>>>,
2342
- { data: BodyType<UpdatePasswordRequest> }
2343
- > = (props) => {
2344
- const { data } = props ?? {};
2345
-
2346
- return updatePassword(data);
2347
- };
2348
-
2349
- return { mutationFn, ...mutationOptions };
2350
- };
2351
-
2352
- export type UpdatePasswordMutationResult = NonNullable<
2353
- Awaited<ReturnType<ReturnType<typeof useUpdatePasswordHook>>>
2354
- >;
2355
- export type UpdatePasswordMutationBody = BodyType<UpdatePasswordRequest>;
2356
- export type UpdatePasswordMutationError = ErrorType<
2357
- UpdatePassword400 | UpdatePassword403
2358
- >;
2359
-
2360
- export const useUpdatePassword = <
2361
- TError = ErrorType<UpdatePassword400 | UpdatePassword403>,
2362
- TContext = unknown,
2363
- >(options?: {
2364
- mutation?: UseMutationOptions<
2365
- Awaited<ReturnType<ReturnType<typeof useUpdatePasswordHook>>>,
2366
- TError,
2367
- { data: BodyType<UpdatePasswordRequest> },
2368
- TContext
2369
- >;
2370
- }): UseMutationResult<
2371
- Awaited<ReturnType<ReturnType<typeof useUpdatePasswordHook>>>,
2372
- TError,
2373
- { data: BodyType<UpdatePasswordRequest> },
2374
- TContext
2375
- > => {
2376
- const mutationOptions = useUpdatePasswordMutationOptions(options);
2377
-
2378
- return useMutation(mutationOptions);
2379
- };
2380
-
2381
- export const useRevokeAllSessionsHook = () => {
2382
- const revokeAllSessions = useWidgetsApiClient<RevokeAllSessions200>();
2383
-
2384
- return useCallback(
2385
- (revokeAllSessionsRequest: BodyType<RevokeAllSessionsRequest>) => {
2386
- return revokeAllSessions({
2387
- url: `/_widgets/UserProfile/sessions/revoke-all`,
2388
- method: "DELETE",
2389
- headers: { "Content-Type": "application/json" },
2390
- data: revokeAllSessionsRequest,
2391
- });
2392
- },
2393
- [revokeAllSessions],
2394
- );
2395
- };
2396
-
2397
- export const useRevokeAllSessionsMutationOptions = <
2398
- TError = ErrorType<RevokeAllSessions400 | RevokeAllSessions403>,
2399
- TContext = unknown,
2400
- >(options?: {
2401
- mutation?: UseMutationOptions<
2402
- Awaited<ReturnType<ReturnType<typeof useRevokeAllSessionsHook>>>,
2403
- TError,
2404
- { data: BodyType<RevokeAllSessionsRequest> },
2405
- TContext
2406
- >;
2407
- }): UseMutationOptions<
2408
- Awaited<ReturnType<ReturnType<typeof useRevokeAllSessionsHook>>>,
2409
- TError,
2410
- { data: BodyType<RevokeAllSessionsRequest> },
2411
- TContext
2412
- > => {
2413
- const mutationKey = ["revokeAllSessions"];
2414
- const { mutation: mutationOptions } = options
2415
- ? options.mutation &&
2416
- "mutationKey" in options.mutation &&
2417
- options.mutation.mutationKey
2418
- ? options
2419
- : { ...options, mutation: { ...options.mutation, mutationKey } }
2420
- : { mutation: { mutationKey } };
2421
-
2422
- const revokeAllSessions = useRevokeAllSessionsHook();
2423
-
2424
- const mutationFn: MutationFunction<
2425
- Awaited<ReturnType<ReturnType<typeof useRevokeAllSessionsHook>>>,
2426
- { data: BodyType<RevokeAllSessionsRequest> }
2427
- > = (props) => {
2428
- const { data } = props ?? {};
2429
-
2430
- return revokeAllSessions(data);
2431
- };
2432
-
2433
- return { mutationFn, ...mutationOptions };
2434
- };
2435
-
2436
- export type RevokeAllSessionsMutationResult = NonNullable<
2437
- Awaited<ReturnType<ReturnType<typeof useRevokeAllSessionsHook>>>
2438
- >;
2439
- export type RevokeAllSessionsMutationBody = BodyType<RevokeAllSessionsRequest>;
2440
- export type RevokeAllSessionsMutationError = ErrorType<
2441
- RevokeAllSessions400 | RevokeAllSessions403
2442
- >;
2443
-
2444
- export const useRevokeAllSessions = <
2445
- TError = ErrorType<RevokeAllSessions400 | RevokeAllSessions403>,
2446
- TContext = unknown,
2447
- >(options?: {
2448
- mutation?: UseMutationOptions<
2449
- Awaited<ReturnType<ReturnType<typeof useRevokeAllSessionsHook>>>,
2450
- TError,
2451
- { data: BodyType<RevokeAllSessionsRequest> },
2452
- TContext
2453
- >;
2454
- }): UseMutationResult<
2455
- Awaited<ReturnType<ReturnType<typeof useRevokeAllSessionsHook>>>,
2456
- TError,
2457
- { data: BodyType<RevokeAllSessionsRequest> },
2458
- TContext
2459
- > => {
2460
- const mutationOptions = useRevokeAllSessionsMutationOptions(options);
2461
-
2462
- return useMutation(mutationOptions);
2463
- };
2464
-
2465
- export const useRevokeSessionHook = () => {
2466
- const revokeSession = useWidgetsApiClient<RevokeSession200>();
2467
-
2468
- return useCallback(
2469
- (sessionId: string) => {
2470
- return revokeSession({
2471
- url: `/_widgets/UserProfile/sessions/revoke/${sessionId}`,
2472
- method: "DELETE",
2473
- });
2474
- },
2475
- [revokeSession],
2476
- );
2477
- };
2478
-
2479
- export const useRevokeSessionMutationOptions = <
2480
- TError = ErrorType<RevokeSession400 | RevokeSession403>,
2481
- TContext = unknown,
2482
- >(options?: {
2483
- mutation?: UseMutationOptions<
2484
- Awaited<ReturnType<ReturnType<typeof useRevokeSessionHook>>>,
2485
- TError,
2486
- { sessionId: string },
2487
- TContext
2488
- >;
2489
- }): UseMutationOptions<
2490
- Awaited<ReturnType<ReturnType<typeof useRevokeSessionHook>>>,
2491
- TError,
2492
- { sessionId: string },
2493
- TContext
2494
- > => {
2495
- const mutationKey = ["revokeSession"];
2496
- const { mutation: mutationOptions } = options
2497
- ? options.mutation &&
2498
- "mutationKey" in options.mutation &&
2499
- options.mutation.mutationKey
2500
- ? options
2501
- : { ...options, mutation: { ...options.mutation, mutationKey } }
2502
- : { mutation: { mutationKey } };
2503
-
2504
- const revokeSession = useRevokeSessionHook();
2505
-
2506
- const mutationFn: MutationFunction<
2507
- Awaited<ReturnType<ReturnType<typeof useRevokeSessionHook>>>,
2508
- { sessionId: string }
2509
- > = (props) => {
2510
- const { sessionId } = props ?? {};
2511
-
2512
- return revokeSession(sessionId);
2513
- };
2514
-
2515
- return { mutationFn, ...mutationOptions };
2516
- };
2517
-
2518
- export type RevokeSessionMutationResult = NonNullable<
2519
- Awaited<ReturnType<ReturnType<typeof useRevokeSessionHook>>>
2520
- >;
2521
-
2522
- export type RevokeSessionMutationError = ErrorType<
2523
- RevokeSession400 | RevokeSession403
2524
- >;
2525
-
2526
- export const useRevokeSession = <
2527
- TError = ErrorType<RevokeSession400 | RevokeSession403>,
2528
- TContext = unknown,
2529
- >(options?: {
2530
- mutation?: UseMutationOptions<
2531
- Awaited<ReturnType<ReturnType<typeof useRevokeSessionHook>>>,
2532
- TError,
2533
- { sessionId: string },
2534
- TContext
2535
- >;
2536
- }): UseMutationResult<
2537
- Awaited<ReturnType<ReturnType<typeof useRevokeSessionHook>>>,
2538
- TError,
2539
- { sessionId: string },
2540
- TContext
2541
- > => {
2542
- const mutationOptions = useRevokeSessionMutationOptions(options);
2543
-
2544
- return useMutation(mutationOptions);
2545
- };
2546
-
2547
- export const useSessionsHook = () => {
2548
- const sessions = useWidgetsApiClient<ActiveSessionsResponse>();
2549
-
2550
- return useCallback(
2551
- (signal?: AbortSignal) => {
2552
- return sessions({
2553
- url: `/_widgets/UserProfile/sessions`,
2554
- method: "GET",
2555
- signal,
2556
- });
2557
- },
2558
- [sessions],
2559
- );
2560
- };
2561
-
2562
- export const getSessionsQueryKey = () => {
2563
- return [`/_widgets/UserProfile/sessions`] as const;
2564
- };
2565
-
2566
- export const useSessionsQueryOptions = <
2567
- TData = Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2568
- TError = ErrorType<Sessions403>,
2569
- >(options?: {
2570
- query?: Partial<
2571
- UseQueryOptions<
2572
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2573
- TError,
2574
- TData
2575
- >
2576
- >;
2577
- }) => {
2578
- const { query: queryOptions } = options ?? {};
2579
-
2580
- const queryKey = queryOptions?.queryKey ?? getSessionsQueryKey();
2581
-
2582
- const sessions = useSessionsHook();
2583
-
2584
- const queryFn: QueryFunction<
2585
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>
2586
- > = ({ signal }) => sessions(signal);
2587
-
2588
- const customOptions = useWidgetsApiQueryOptions({
2589
- ...queryOptions,
2590
- queryKey,
2591
- queryFn,
2592
- });
2593
-
2594
- return customOptions as UseQueryOptions<
2595
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2596
- TError,
2597
- TData
2598
- > & { queryKey: DataTag<QueryKey, TData> };
2599
- };
2600
-
2601
- export type SessionsQueryResult = NonNullable<
2602
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>
2603
- >;
2604
- export type SessionsQueryError = ErrorType<Sessions403>;
2605
-
2606
- export function useSessions<
2607
- TData = Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2608
- TError = ErrorType<Sessions403>,
2609
- >(options: {
2610
- query: Partial<
2611
- UseQueryOptions<
2612
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2613
- TError,
2614
- TData
2615
- >
2616
- > &
2617
- Pick<
2618
- DefinedInitialDataOptions<
2619
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2620
- TError,
2621
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>
2622
- >,
2623
- "initialData"
2624
- >;
2625
- }): DefinedUseQueryResult<TData, TError> & {
2626
- queryKey: DataTag<QueryKey, TData>;
2627
- };
2628
- export function useSessions<
2629
- TData = Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2630
- TError = ErrorType<Sessions403>,
2631
- >(options?: {
2632
- query?: Partial<
2633
- UseQueryOptions<
2634
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2635
- TError,
2636
- TData
2637
- >
2638
- > &
2639
- Pick<
2640
- UndefinedInitialDataOptions<
2641
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2642
- TError,
2643
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>
2644
- >,
2645
- "initialData"
2646
- >;
2647
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
2648
- export function useSessions<
2649
- TData = Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2650
- TError = ErrorType<Sessions403>,
2651
- >(options?: {
2652
- query?: Partial<
2653
- UseQueryOptions<
2654
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2655
- TError,
2656
- TData
2657
- >
2658
- >;
2659
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
2660
-
2661
- export function useSessions<
2662
- TData = Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2663
- TError = ErrorType<Sessions403>,
2664
- >(options?: {
2665
- query?: Partial<
2666
- UseQueryOptions<
2667
- Awaited<ReturnType<ReturnType<typeof useSessionsHook>>>,
2668
- TError,
2669
- TData
2670
- >
2671
- >;
2672
- }): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {
2673
- const queryOptions = useSessionsQueryOptions(options);
2674
-
2675
- const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
2676
- queryKey: DataTag<QueryKey, TData>;
2677
- };
2678
-
2679
- query.queryKey = queryOptions.queryKey;
2680
-
2681
- return query;
2682
- }
2683
-
2684
- export const useSendVerificationHook = () => {
2685
- const sendVerification = useWidgetsApiClient<SendVerificationResponse>();
2686
-
2687
- return useCallback(
2688
- (signal?: AbortSignal) => {
2689
- return sendVerification({
2690
- url: `/_widgets/UserProfile/send-verification`,
2691
- method: "POST",
2692
- signal,
2693
- });
2694
- },
2695
- [sendVerification],
2696
- );
2697
- };
2698
-
2699
- export const useSendVerificationMutationOptions = <
2700
- TError = ErrorType<SendVerification400 | SendVerification403>,
2701
- TContext = unknown,
2702
- >(options?: {
2703
- mutation?: UseMutationOptions<
2704
- Awaited<ReturnType<ReturnType<typeof useSendVerificationHook>>>,
2705
- TError,
2706
- void,
2707
- TContext
2708
- >;
2709
- }): UseMutationOptions<
2710
- Awaited<ReturnType<ReturnType<typeof useSendVerificationHook>>>,
2711
- TError,
2712
- void,
2713
- TContext
2714
- > => {
2715
- const mutationKey = ["sendVerification"];
2716
- const { mutation: mutationOptions } = options
2717
- ? options.mutation &&
2718
- "mutationKey" in options.mutation &&
2719
- options.mutation.mutationKey
2720
- ? options
2721
- : { ...options, mutation: { ...options.mutation, mutationKey } }
2722
- : { mutation: { mutationKey } };
2723
-
2724
- const sendVerification = useSendVerificationHook();
2725
-
2726
- const mutationFn: MutationFunction<
2727
- Awaited<ReturnType<ReturnType<typeof useSendVerificationHook>>>,
2728
- void
2729
- > = () => {
2730
- return sendVerification();
2731
- };
2732
-
2733
- return { mutationFn, ...mutationOptions };
2734
- };
2735
-
2736
- export type SendVerificationMutationResult = NonNullable<
2737
- Awaited<ReturnType<ReturnType<typeof useSendVerificationHook>>>
2738
- >;
2739
-
2740
- export type SendVerificationMutationError = ErrorType<
2741
- SendVerification400 | SendVerification403
2742
- >;
2743
-
2744
- export const useSendVerification = <
2745
- TError = ErrorType<SendVerification400 | SendVerification403>,
2746
- TContext = unknown,
2747
- >(options?: {
2748
- mutation?: UseMutationOptions<
2749
- Awaited<ReturnType<ReturnType<typeof useSendVerificationHook>>>,
2750
- TError,
2751
- void,
2752
- TContext
2753
- >;
2754
- }): UseMutationResult<
2755
- Awaited<ReturnType<ReturnType<typeof useSendVerificationHook>>>,
2756
- TError,
2757
- void,
2758
- TContext
2759
- > => {
2760
- const mutationOptions = useSendVerificationMutationOptions(options);
2761
-
2762
- return useMutation(mutationOptions);
2763
- };
2764
-
2765
- export const useVerifyHook = () => {
2766
- const verify = useWidgetsApiClient<VerifyResponse>();
2767
-
2768
- return useCallback(
2769
- (verifyRequest: BodyType<VerifyRequest>, signal?: AbortSignal) => {
2770
- return verify({
2771
- url: `/_widgets/UserProfile/verify`,
2772
- method: "POST",
2773
- headers: { "Content-Type": "application/json" },
2774
- data: verifyRequest,
2775
- signal,
2776
- });
2777
- },
2778
- [verify],
2779
- );
2780
- };
2781
-
2782
- export const useVerifyMutationOptions = <
2783
- TError = ErrorType<Verify400 | Verify403>,
2784
- TContext = unknown,
2785
- >(options?: {
2786
- mutation?: UseMutationOptions<
2787
- Awaited<ReturnType<ReturnType<typeof useVerifyHook>>>,
2788
- TError,
2789
- { data: BodyType<VerifyRequest> },
2790
- TContext
2791
- >;
2792
- }): UseMutationOptions<
2793
- Awaited<ReturnType<ReturnType<typeof useVerifyHook>>>,
2794
- TError,
2795
- { data: BodyType<VerifyRequest> },
2796
- TContext
2797
- > => {
2798
- const mutationKey = ["verify"];
2799
- const { mutation: mutationOptions } = options
2800
- ? options.mutation &&
2801
- "mutationKey" in options.mutation &&
2802
- options.mutation.mutationKey
2803
- ? options
2804
- : { ...options, mutation: { ...options.mutation, mutationKey } }
2805
- : { mutation: { mutationKey } };
2806
-
2807
- const verify = useVerifyHook();
2808
-
2809
- const mutationFn: MutationFunction<
2810
- Awaited<ReturnType<ReturnType<typeof useVerifyHook>>>,
2811
- { data: BodyType<VerifyRequest> }
2812
- > = (props) => {
2813
- const { data } = props ?? {};
2814
-
2815
- return verify(data);
2816
- };
2817
-
2818
- return { mutationFn, ...mutationOptions };
2819
- };
2820
-
2821
- export type VerifyMutationResult = NonNullable<
2822
- Awaited<ReturnType<ReturnType<typeof useVerifyHook>>>
2823
- >;
2824
- export type VerifyMutationBody = BodyType<VerifyRequest>;
2825
- export type VerifyMutationError = ErrorType<Verify400 | Verify403>;
2826
-
2827
- export const useVerify = <
2828
- TError = ErrorType<Verify400 | Verify403>,
2829
- TContext = unknown,
2830
- >(options?: {
2831
- mutation?: UseMutationOptions<
2832
- Awaited<ReturnType<ReturnType<typeof useVerifyHook>>>,
2833
- TError,
2834
- { data: BodyType<VerifyRequest> },
2835
- TContext
2836
- >;
2837
- }): UseMutationResult<
2838
- Awaited<ReturnType<ReturnType<typeof useVerifyHook>>>,
2839
- TError,
2840
- { data: BodyType<VerifyRequest> },
2841
- TContext
2842
- > => {
2843
- const mutationOptions = useVerifyMutationOptions(options);
2844
-
2845
- return useMutation(mutationOptions);
2846
- };
2847
-
2848
- export const useRegisterPasskeyHook = () => {
2849
- const registerPasskey = useWidgetsApiClient<RegisterPasskeyResponse>();
2850
-
2851
- return useCallback(
2852
- (signal?: AbortSignal) => {
2853
- return registerPasskey({
2854
- url: `/_widgets/UserProfile/passkeys`,
2855
- method: "POST",
2856
- signal,
2857
- });
2858
- },
2859
- [registerPasskey],
2860
- );
2861
- };
2862
-
2863
- export const useRegisterPasskeyMutationOptions = <
2864
- TError = ErrorType<RegisterPasskey400 | RegisterPasskey403>,
2865
- TContext = unknown,
2866
- >(options?: {
2867
- mutation?: UseMutationOptions<
2868
- Awaited<ReturnType<ReturnType<typeof useRegisterPasskeyHook>>>,
2869
- TError,
2870
- void,
2871
- TContext
2872
- >;
2873
- }): UseMutationOptions<
2874
- Awaited<ReturnType<ReturnType<typeof useRegisterPasskeyHook>>>,
2875
- TError,
2876
- void,
2877
- TContext
2878
- > => {
2879
- const mutationKey = ["registerPasskey"];
2880
- const { mutation: mutationOptions } = options
2881
- ? options.mutation &&
2882
- "mutationKey" in options.mutation &&
2883
- options.mutation.mutationKey
2884
- ? options
2885
- : { ...options, mutation: { ...options.mutation, mutationKey } }
2886
- : { mutation: { mutationKey } };
2887
-
2888
- const registerPasskey = useRegisterPasskeyHook();
2889
-
2890
- const mutationFn: MutationFunction<
2891
- Awaited<ReturnType<ReturnType<typeof useRegisterPasskeyHook>>>,
2892
- void
2893
- > = () => {
2894
- return registerPasskey();
2895
- };
2896
-
2897
- return { mutationFn, ...mutationOptions };
2898
- };
2899
-
2900
- export type RegisterPasskeyMutationResult = NonNullable<
2901
- Awaited<ReturnType<ReturnType<typeof useRegisterPasskeyHook>>>
2902
- >;
2903
-
2904
- export type RegisterPasskeyMutationError = ErrorType<
2905
- RegisterPasskey400 | RegisterPasskey403
2906
- >;
2907
-
2908
- export const useRegisterPasskey = <
2909
- TError = ErrorType<RegisterPasskey400 | RegisterPasskey403>,
2910
- TContext = unknown,
2911
- >(options?: {
2912
- mutation?: UseMutationOptions<
2913
- Awaited<ReturnType<ReturnType<typeof useRegisterPasskeyHook>>>,
2914
- TError,
2915
- void,
2916
- TContext
2917
- >;
2918
- }): UseMutationResult<
2919
- Awaited<ReturnType<ReturnType<typeof useRegisterPasskeyHook>>>,
2920
- TError,
2921
- void,
2922
- TContext
2923
- > => {
2924
- const mutationOptions = useRegisterPasskeyMutationOptions(options);
2925
-
2926
- return useMutation(mutationOptions);
2927
- };
2928
-
2929
- export const useVerifyPasskeyHook = () => {
2930
- const verifyPasskey = useWidgetsApiClient<VerifyPasskey200>();
2931
-
2932
- return useCallback(
2933
- (
2934
- verifyPasskeyRequest: BodyType<VerifyPasskeyRequest>,
2935
- signal?: AbortSignal,
2936
- ) => {
2937
- return verifyPasskey({
2938
- url: `/_widgets/UserProfile/passkeys/verify`,
2939
- method: "POST",
2940
- headers: { "Content-Type": "application/json" },
2941
- data: verifyPasskeyRequest,
2942
- signal,
2943
- });
2944
- },
2945
- [verifyPasskey],
2946
- );
2947
- };
2948
-
2949
- export const useVerifyPasskeyMutationOptions = <
2950
- TError = ErrorType<VerifyPasskey400 | VerifyPasskey403>,
2951
- TContext = unknown,
2952
- >(options?: {
2953
- mutation?: UseMutationOptions<
2954
- Awaited<ReturnType<ReturnType<typeof useVerifyPasskeyHook>>>,
2955
- TError,
2956
- { data: BodyType<VerifyPasskeyRequest> },
2957
- TContext
2958
- >;
2959
- }): UseMutationOptions<
2960
- Awaited<ReturnType<ReturnType<typeof useVerifyPasskeyHook>>>,
2961
- TError,
2962
- { data: BodyType<VerifyPasskeyRequest> },
2963
- TContext
2964
- > => {
2965
- const mutationKey = ["verifyPasskey"];
2966
- const { mutation: mutationOptions } = options
2967
- ? options.mutation &&
2968
- "mutationKey" in options.mutation &&
2969
- options.mutation.mutationKey
2970
- ? options
2971
- : { ...options, mutation: { ...options.mutation, mutationKey } }
2972
- : { mutation: { mutationKey } };
2973
-
2974
- const verifyPasskey = useVerifyPasskeyHook();
2975
-
2976
- const mutationFn: MutationFunction<
2977
- Awaited<ReturnType<ReturnType<typeof useVerifyPasskeyHook>>>,
2978
- { data: BodyType<VerifyPasskeyRequest> }
2979
- > = (props) => {
2980
- const { data } = props ?? {};
2981
-
2982
- return verifyPasskey(data);
2983
- };
2984
-
2985
- return { mutationFn, ...mutationOptions };
2986
- };
2987
-
2988
- export type VerifyPasskeyMutationResult = NonNullable<
2989
- Awaited<ReturnType<ReturnType<typeof useVerifyPasskeyHook>>>
2990
- >;
2991
- export type VerifyPasskeyMutationBody = BodyType<VerifyPasskeyRequest>;
2992
- export type VerifyPasskeyMutationError = ErrorType<
2993
- VerifyPasskey400 | VerifyPasskey403
2994
- >;
2995
-
2996
- export const useVerifyPasskey = <
2997
- TError = ErrorType<VerifyPasskey400 | VerifyPasskey403>,
2998
- TContext = unknown,
2999
- >(options?: {
3000
- mutation?: UseMutationOptions<
3001
- Awaited<ReturnType<ReturnType<typeof useVerifyPasskeyHook>>>,
3002
- TError,
3003
- { data: BodyType<VerifyPasskeyRequest> },
3004
- TContext
3005
- >;
3006
- }): UseMutationResult<
3007
- Awaited<ReturnType<ReturnType<typeof useVerifyPasskeyHook>>>,
3008
- TError,
3009
- { data: BodyType<VerifyPasskeyRequest> },
3010
- TContext
3011
- > => {
3012
- const mutationOptions = useVerifyPasskeyMutationOptions(options);
3013
-
3014
- return useMutation(mutationOptions);
3015
- };
3016
-
3017
- export const useDeletePasskeyHook = () => {
3018
- const deletePasskey = useWidgetsApiClient<DeletePasskey200>();
3019
-
3020
- return useCallback(
3021
- (passkeyId: string) => {
3022
- return deletePasskey({
3023
- url: `/_widgets/UserProfile/passkeys/${passkeyId}`,
3024
- method: "DELETE",
3025
- });
3026
- },
3027
- [deletePasskey],
3028
- );
3029
- };
3030
-
3031
- export const useDeletePasskeyMutationOptions = <
3032
- TError = ErrorType<DeletePasskey400 | DeletePasskey403>,
3033
- TContext = unknown,
3034
- >(options?: {
3035
- mutation?: UseMutationOptions<
3036
- Awaited<ReturnType<ReturnType<typeof useDeletePasskeyHook>>>,
3037
- TError,
3038
- { passkeyId: string },
3039
- TContext
3040
- >;
3041
- }): UseMutationOptions<
3042
- Awaited<ReturnType<ReturnType<typeof useDeletePasskeyHook>>>,
3043
- TError,
3044
- { passkeyId: string },
3045
- TContext
3046
- > => {
3047
- const mutationKey = ["deletePasskey"];
3048
- const { mutation: mutationOptions } = options
3049
- ? options.mutation &&
3050
- "mutationKey" in options.mutation &&
3051
- options.mutation.mutationKey
3052
- ? options
3053
- : { ...options, mutation: { ...options.mutation, mutationKey } }
3054
- : { mutation: { mutationKey } };
3055
-
3056
- const deletePasskey = useDeletePasskeyHook();
3057
-
3058
- const mutationFn: MutationFunction<
3059
- Awaited<ReturnType<ReturnType<typeof useDeletePasskeyHook>>>,
3060
- { passkeyId: string }
3061
- > = (props) => {
3062
- const { passkeyId } = props ?? {};
3063
-
3064
- return deletePasskey(passkeyId);
3065
- };
3066
-
3067
- return { mutationFn, ...mutationOptions };
3068
- };
3069
-
3070
- export type DeletePasskeyMutationResult = NonNullable<
3071
- Awaited<ReturnType<ReturnType<typeof useDeletePasskeyHook>>>
3072
- >;
3073
-
3074
- export type DeletePasskeyMutationError = ErrorType<
3075
- DeletePasskey400 | DeletePasskey403
3076
- >;
3077
-
3078
- export const useDeletePasskey = <
3079
- TError = ErrorType<DeletePasskey400 | DeletePasskey403>,
3080
- TContext = unknown,
3081
- >(options?: {
3082
- mutation?: UseMutationOptions<
3083
- Awaited<ReturnType<ReturnType<typeof useDeletePasskeyHook>>>,
3084
- TError,
3085
- { passkeyId: string },
3086
- TContext
3087
- >;
3088
- }): UseMutationResult<
3089
- Awaited<ReturnType<ReturnType<typeof useDeletePasskeyHook>>>,
3090
- TError,
3091
- { passkeyId: string },
3092
- TContext
3093
- > => {
3094
- const mutationOptions = useDeletePasskeyMutationOptions(options);
3095
-
3096
- return useMutation(mutationOptions);
3097
- };