@jsb188/graphql 1.1.10 → 1.1.11

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 (116) hide show
  1. package/cache/config.ts +64 -50
  2. package/cache/index.test.ts +671 -109
  3. package/cache/index.ts +1700 -1240
  4. package/cache/persist.ts +721 -0
  5. package/cache/store.ts +437 -0
  6. package/client/data-table-realtime-subscriptions.test.ts +740 -0
  7. package/client/data-table-realtime-subscriptions.ts +955 -0
  8. package/client/data-table-realtime.test.ts +792 -0
  9. package/client/data-table-realtime.ts +1218 -0
  10. package/client/fragment-realtime-sequence.ts +52 -0
  11. package/client/index.ts +2 -0
  12. package/client/open-sheet.ts +137 -0
  13. package/client/request-managed-session.test.ts +574 -0
  14. package/client/request-no-store.test.ts +157 -0
  15. package/client/request.ts +954 -163
  16. package/client/sse-ticket.test.ts +26 -0
  17. package/deno.lock +170 -0
  18. package/deno.test.json +8 -4
  19. package/drafts/index.ts +149 -0
  20. package/drafts/store.ts +397 -0
  21. package/gql/eagerQueryMap.ts +12 -0
  22. package/gql/fragments/accountAuthFragments.ts +5 -0
  23. package/gql/fragments/accountFragments.ts +0 -3
  24. package/gql/fragments/accountSessionFragments.ts +16 -0
  25. package/gql/fragments/agentDocFragments.ts +46 -0
  26. package/gql/fragments/agentMemoryFragments.ts +19 -0
  27. package/gql/fragments/aiChatFragments.ts +16 -0
  28. package/gql/fragments/billingFragments.ts +0 -11
  29. package/gql/fragments/campaignFragments.ts +277 -0
  30. package/gql/fragments/dataTableFragments.ts +18 -128
  31. package/gql/fragments/emailFragments.ts +19 -9
  32. package/gql/fragments/fieldDocFragments.ts +82 -0
  33. package/gql/fragments/logFragments.ts +20 -79
  34. package/gql/fragments/organizationFragments.ts +43 -5
  35. package/gql/fragments/scheduleFragments.ts +155 -0
  36. package/gql/fragments/sheetFragments.ts +552 -22
  37. package/gql/fragments/storageFragments.ts +21 -0
  38. package/gql/fragments/workflowFragments.ts +28 -4
  39. package/gql/mutations/accountMutations.ts +0 -2
  40. package/gql/mutations/agentDocMutations.ts +177 -0
  41. package/gql/mutations/agentMemoryMutations.ts +36 -0
  42. package/gql/mutations/aiChatMutations.ts +17 -4
  43. package/gql/mutations/authMutations.ts +158 -17
  44. package/gql/mutations/campaignMutations.ts +215 -0
  45. package/gql/mutations/dataTableMutations.ts +48 -26
  46. package/gql/mutations/fieldDocMutations.ts +24 -0
  47. package/gql/mutations/index.ts +6 -1
  48. package/gql/mutations/logMutations.ts +6 -29
  49. package/gql/mutations/organizationMutations.ts +13 -4
  50. package/gql/mutations/scheduleMutations.ts +423 -0
  51. package/gql/mutations/sheetMutations.ts +273 -56
  52. package/gql/mutations/storageMutations.ts +20 -0
  53. package/gql/mutations/workflowMutations.ts +42 -0
  54. package/gql/queries/agentDocQueries.ts +120 -0
  55. package/gql/queries/agentMemoryQueries.ts +22 -0
  56. package/gql/queries/aiChatQueries.ts +18 -2
  57. package/gql/queries/authQueries.ts +41 -0
  58. package/gql/queries/billingQueries.ts +23 -0
  59. package/gql/queries/campaignQueries.ts +127 -0
  60. package/gql/queries/dataTableQueries.ts +100 -11
  61. package/gql/queries/emailQueries.ts +55 -3
  62. package/gql/queries/fieldDocQueries.ts +158 -0
  63. package/gql/queries/index.ts +8 -2
  64. package/gql/queries/logQueries.ts +11 -28
  65. package/gql/queries/organizationQueries.ts +52 -1
  66. package/gql/queries/scheduleQueries.ts +315 -0
  67. package/gql/queries/sheetQueries.ts +336 -25
  68. package/gql/queries/storageQueries.ts +38 -0
  69. package/gql/queries/workflowQueries.ts +72 -3
  70. package/hooks/index.ts +2065 -971
  71. package/hooks/use-account-mtn.ts +76 -81
  72. package/hooks/use-agentDoc-mtn.ts +285 -0
  73. package/hooks/use-agentDoc-qry.ts +208 -0
  74. package/hooks/use-agentMemory-mtn.ts +73 -0
  75. package/hooks/use-agentMemory-qry.ts +44 -0
  76. package/hooks/use-aiChat-mtn.ts +232 -137
  77. package/hooks/use-aiChat-qry.ts +480 -222
  78. package/hooks/use-app-qry.ts +12 -9
  79. package/hooks/use-auth-mtn.ts +406 -252
  80. package/hooks/use-auth-qry.ts +51 -0
  81. package/hooks/use-campaign-mtn.ts +377 -0
  82. package/hooks/use-campaign-qry.ts +257 -0
  83. package/hooks/use-dataTable-mtn.ts +116 -33
  84. package/hooks/use-dataTable-qry.ts +859 -35
  85. package/hooks/use-email-qry.ts +194 -79
  86. package/hooks/use-fieldDoc-mtn.ts +50 -0
  87. package/hooks/use-fieldDoc-qry.ts +180 -0
  88. package/hooks/use-inboundContact-mtn.ts +19 -16
  89. package/hooks/use-inboundContact-qry.ts +63 -55
  90. package/hooks/use-integration-mtn.ts +56 -38
  91. package/hooks/use-integration-qry.ts +24 -9
  92. package/hooks/use-log-mtn.ts +72 -56
  93. package/hooks/use-log-qry.ts +93 -69
  94. package/hooks/use-organization-mtn.ts +334 -277
  95. package/hooks/use-organization-qry.ts +199 -129
  96. package/hooks/use-schedule-mtn.ts +416 -0
  97. package/hooks/use-schedule-qry.ts +157 -0
  98. package/hooks/use-sheet-mtn.ts +233 -47
  99. package/hooks/use-sheet-qry.ts +353 -70
  100. package/hooks/use-storage-mtn.ts +81 -41
  101. package/hooks/use-storage-qry.ts +104 -13
  102. package/hooks/use-workflow-mtn.ts +55 -0
  103. package/hooks/use-workflow-qry.ts +206 -48
  104. package/loaders/campaign.ts +137 -0
  105. package/package.json +94 -71
  106. package/sse.ts +157 -104
  107. package/tsconfig.json +11 -10
  108. package/types.d.ts +60 -30
  109. package/utils.ts +78 -49
  110. package/gql/fragments/productFragments.ts +0 -39
  111. package/gql/fragments/reportFragments.ts +0 -90
  112. package/gql/mutations/billingMutations.ts +0 -34
  113. package/gql/queries/productQueries.ts +0 -31
  114. package/gql/queries/reportQueries.ts +0 -134
  115. package/hooks/use-product-qry.ts +0 -67
  116. package/hooks/use-report-qry.ts +0 -153
@@ -2,9 +2,26 @@ import i18n from '@jsb188/app/i18n/index.ts';
2
2
  import { deleteAuthToken } from '@jsb188/app/platform.ts';
3
3
  import type { UseMutationParams } from '@jsb188/graphql/types.d';
4
4
  import type { OpenModalPopUpFn } from '@jsb188/react/states';
5
- import { AppContext, onGuestInit, useOpenModalPopUp } from '@jsb188/react/states';
5
+ import {
6
+ AppContext,
7
+ onGuestInit,
8
+ useOpenModalPopUp,
9
+ } from '@jsb188/react/states';
6
10
  import React, { useContext, useEffect, useState } from 'react';
7
- import { changeAccountPasswordMtn, checkUsernameOrEmailMtn, confirmPasswordMtn, confirmPhoneVerificationCodeMtn, requestTokenizedEmailMtn, sendPhoneVerificationCodeMtn, signUpWithEmailMtn } from '../gql/mutations/authMutations.ts';
11
+ import {
12
+ changeAccountPasswordMtn,
13
+ checkUsernameOrEmailMtn,
14
+ confirmPasswordMtn,
15
+ confirmPhoneVerificationCodeMtn,
16
+ getSsoLoginOptionsMtn,
17
+ requestTokenizedEmailMtn,
18
+ revokeMyAccountSessionMtn,
19
+ revokeMyOtherAccountSessionsMtn,
20
+ revokeOrganizationMemberSessionMtn,
21
+ revokeOrganizationMemberSessionsMtn,
22
+ sendPhoneVerificationCodeMtn,
23
+ signUpWithEmailMtn,
24
+ } from '../gql/mutations/authMutations.ts';
8
25
  import { signOutMtn } from '../gql/mutations/userAuthMutations.ts';
9
26
  import { useMutation } from './index.ts';
10
27
 
@@ -13,8 +30,96 @@ import { useMutation } from './index.ts';
13
30
  */
14
31
 
15
32
  interface AuthHookParams extends UseMutationParams {
16
- initialError?: any;
17
- initialFormData?: Record<string, any>;
33
+ initialError?: any;
34
+ initialFormData?: Record<string, any>;
35
+ }
36
+
37
+ /*
38
+ * Revoke one managed session owned by the current account.
39
+ */
40
+ export function useRevokeMyAccountSession(
41
+ params: UseMutationParams = {},
42
+ openModalPopUp?: OpenModalPopUpFn,
43
+ ) {
44
+ const [revokeMyAccountSession, mutation, handlers] = useMutation(
45
+ revokeMyAccountSessionMtn,
46
+ {
47
+ openModalPopUp,
48
+ ...params,
49
+ },
50
+ );
51
+
52
+ return {
53
+ revokeMyAccountSession,
54
+ ...mutation,
55
+ ...handlers,
56
+ };
57
+ }
58
+
59
+ /*
60
+ * Revoke every other managed session owned by the current account.
61
+ */
62
+ export function useRevokeMyOtherAccountSessions(
63
+ params: UseMutationParams = {},
64
+ openModalPopUp?: OpenModalPopUpFn,
65
+ ) {
66
+ const [revokeMyOtherAccountSessions, mutation, handlers] = useMutation(
67
+ revokeMyOtherAccountSessionsMtn,
68
+ {
69
+ openModalPopUp,
70
+ ...params,
71
+ },
72
+ );
73
+
74
+ return {
75
+ revokeMyOtherAccountSessions,
76
+ ...mutation,
77
+ ...handlers,
78
+ };
79
+ }
80
+
81
+ /*
82
+ * Revoke one member session's authorization for an organization.
83
+ */
84
+ export function useRevokeOrganizationMemberSession(
85
+ params: UseMutationParams = {},
86
+ openModalPopUp?: OpenModalPopUpFn,
87
+ ) {
88
+ const [revokeOrganizationMemberSession, mutation, handlers] = useMutation(
89
+ revokeOrganizationMemberSessionMtn,
90
+ {
91
+ openModalPopUp,
92
+ ...params,
93
+ },
94
+ );
95
+
96
+ return {
97
+ revokeOrganizationMemberSession,
98
+ ...mutation,
99
+ ...handlers,
100
+ };
101
+ }
102
+
103
+ /*
104
+ * Revoke every managed-session authorization a member has for an organization.
105
+ */
106
+ export function useRevokeOrganizationMemberSessions(
107
+ params: UseMutationParams = {},
108
+ openModalPopUp?: OpenModalPopUpFn,
109
+ ) {
110
+ const [revokeOrganizationMemberSessions, mutation, handlers] = useMutation(
111
+ revokeOrganizationMemberSessionsMtn,
112
+ {
113
+ openModalPopUp,
114
+ ...params,
115
+ },
116
+ );
117
+
118
+ return {
119
+ revokeOrganizationMemberSessions,
120
+ ...mutation,
121
+ ...handlers,
122
+ };
18
123
  }
19
124
 
20
125
  /**
@@ -22,65 +127,70 @@ interface AuthHookParams extends UseMutationParams {
22
127
  */
23
128
 
24
129
  interface UseChangeAccountPasswordParams extends UseMutationParams {
25
- doNotFinishForm?: boolean;
130
+ doNotFinishForm?: boolean;
26
131
  }
27
132
 
28
- export function useChangeAccountPassword(params: UseChangeAccountPasswordParams = {}, openModalPopUp?: OpenModalPopUpFn) {
29
-
30
- const { dispatchApp, appState: { hasPassword, account } } = useContext(AppContext);
31
- const { onCompleted, onError, doNotFinishForm } = params;
32
-
33
- const onFinishChangeAccountPassword = () => {
34
- if (!hasPassword) {
35
- dispatchApp({
36
- __type: 'APP_EDIT_AUTH',
37
- data: {
38
- id: account?.id,
39
- hasPassword: true,
40
- }
41
- });
42
- }
43
- };
44
-
45
- const onCompleted_ = (data: any, err: any, variables: any) => {
46
- const success = !!data?.changeAccountPassword;
47
- if (success) {
48
- openModalPopUp?.({
49
- name: 'password_changed',
50
- props: {
51
- title: i18n.t('form.success'),
52
- message: i18n.t('auth.password_changed_msg'),
53
- iconName: 'lock-password-filled'
54
- }
55
- });
56
-
57
- if (!doNotFinishForm) {
58
- onFinishChangeAccountPassword();
59
- }
60
-
61
- if (onCompleted) {
62
- onCompleted(success, err, variables);
63
- }
64
- }
65
- };
66
-
67
- const [changeAccountPassword, mtnValues, mtnHandlers] = useMutation(
68
- changeAccountPasswordMtn,
69
- {
70
- openModalPopUp,
71
- onCompleted: onCompleted_,
72
- onError,
73
- },
74
- );
75
-
76
- return {
77
- openModalPopUp,
78
- changeAccountPassword,
79
- onFinishChangeAccountPassword,
80
- account,
81
- ...mtnValues,
82
- ...mtnHandlers,
83
- };
133
+ export function useChangeAccountPassword(
134
+ params: UseChangeAccountPasswordParams = {},
135
+ openModalPopUp?: OpenModalPopUpFn,
136
+ ) {
137
+ const {
138
+ dispatchApp,
139
+ appState: { hasPassword, account },
140
+ } = useContext(AppContext);
141
+ const { onCompleted, onError, doNotFinishForm } = params;
142
+
143
+ const onFinishChangeAccountPassword = () => {
144
+ if (!hasPassword) {
145
+ dispatchApp({
146
+ __type: 'APP_EDIT_AUTH',
147
+ data: {
148
+ id: account?.id,
149
+ hasPassword: true,
150
+ },
151
+ });
152
+ }
153
+ };
154
+
155
+ const onCompleted_ = (data: any, err: any, variables: any) => {
156
+ const success = !!data?.changeAccountPassword;
157
+ if (success) {
158
+ openModalPopUp?.({
159
+ name: 'password_changed',
160
+ props: {
161
+ title: i18n.t('form.success'),
162
+ message: i18n.t('auth.password_changed_msg'),
163
+ iconName: 'lock-password-filled',
164
+ },
165
+ });
166
+
167
+ if (!doNotFinishForm) {
168
+ onFinishChangeAccountPassword();
169
+ }
170
+
171
+ if (onCompleted) {
172
+ onCompleted(success, err, variables);
173
+ }
174
+ }
175
+ };
176
+
177
+ const [changeAccountPassword, mtnValues, mtnHandlers] = useMutation(
178
+ changeAccountPasswordMtn,
179
+ {
180
+ openModalPopUp,
181
+ onCompleted: onCompleted_,
182
+ onError,
183
+ },
184
+ );
185
+
186
+ return {
187
+ openModalPopUp,
188
+ changeAccountPassword,
189
+ onFinishChangeAccountPassword,
190
+ account,
191
+ ...mtnValues,
192
+ ...mtnHandlers,
193
+ };
84
194
  }
85
195
 
86
196
  /**
@@ -88,171 +198,215 @@ export function useChangeAccountPassword(params: UseChangeAccountPasswordParams
88
198
  */
89
199
 
90
200
  export function useChangeAccountPasswordForm(params: UseMutationParams = {}) {
91
-
92
- const { dispatchApp, appState: { hasPassword, account } } = useContext(AppContext);
93
- const { onCompleted, onError } = params;
94
-
95
- const onCompleted_ = (data: any, err: any, variables: any) => {
96
- if (onCompleted) {
97
- onCompleted(data, err, variables);
98
- }
99
-
100
- const success = !!data?.changeAccountPassword;
101
- if (success) {
102
- // It's possible for user to use this hook without being logged in
103
- // So we have to check for ID first
104
- if (account?.id && !hasPassword) {
105
- dispatchApp({
106
- __type: 'APP_EDIT_AUTH',
107
- data: {
108
- id: account?.id,
109
- hasPassword: true,
110
- }
111
- });
112
- }
113
- }
114
- };
115
-
116
- const [changeAccountPassword, mtnValues, mtnHandlers] = useMutation(
117
- changeAccountPasswordMtn,
118
- {
119
- checkMountedBeforeCallback: true,
120
- onCompleted: onCompleted_,
121
- onError,
122
- },
123
- );
124
-
125
- return {
126
- changeAccountPassword,
127
- ...mtnValues,
128
- ...mtnHandlers,
129
- };
201
+ const {
202
+ dispatchApp,
203
+ appState: { hasPassword, account },
204
+ } = useContext(AppContext);
205
+ const { onCompleted, onError } = params;
206
+
207
+ const onCompleted_ = (data: any, err: any, variables: any) => {
208
+ if (onCompleted) {
209
+ onCompleted(data, err, variables);
210
+ }
211
+
212
+ const success = !!data?.changeAccountPassword;
213
+ if (success) {
214
+ // It's possible for user to use this hook without being logged in
215
+ // So we have to check for ID first
216
+ if (account?.id && !hasPassword) {
217
+ dispatchApp({
218
+ __type: 'APP_EDIT_AUTH',
219
+ data: {
220
+ id: account?.id,
221
+ hasPassword: true,
222
+ },
223
+ });
224
+ }
225
+ }
226
+ };
227
+
228
+ const [changeAccountPassword, mtnValues, mtnHandlers] = useMutation(
229
+ changeAccountPasswordMtn,
230
+ {
231
+ checkMountedBeforeCallback: true,
232
+ onCompleted: onCompleted_,
233
+ onError,
234
+ },
235
+ );
236
+
237
+ return {
238
+ changeAccountPassword,
239
+ ...mtnValues,
240
+ ...mtnHandlers,
241
+ };
130
242
  }
131
243
 
132
244
  /**
133
245
  * Request password reset (email with link)
134
246
  */
135
247
 
136
- export function useRequestTokenizedEmail(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
137
- const { onCompleted, onError } = params;
138
- const [requestTokenizedEmail, mtnValues, mtnHandlers] = useMutation(
139
- requestTokenizedEmailMtn,
140
- {
141
- checkMountedBeforeCallback: true,
142
- openModalPopUp,
143
- onCompleted,
144
- onError
145
- },
146
- );
147
-
148
- return {
149
- requestTokenizedEmail,
150
- ...mtnValues,
151
- ...mtnHandlers,
152
- };
248
+ export function useRequestTokenizedEmail(
249
+ params: UseMutationParams = {},
250
+ openModalPopUp?: OpenModalPopUpFn,
251
+ ) {
252
+ const { onCompleted, onError } = params;
253
+ const [requestTokenizedEmail, mtnValues, mtnHandlers] = useMutation(
254
+ requestTokenizedEmailMtn,
255
+ {
256
+ checkMountedBeforeCallback: true,
257
+ openModalPopUp,
258
+ onCompleted,
259
+ onError,
260
+ },
261
+ );
262
+
263
+ return {
264
+ requestTokenizedEmail,
265
+ ...mtnValues,
266
+ ...mtnHandlers,
267
+ };
153
268
  }
154
269
 
155
270
  /**
156
271
  * Send verification code to phone number
157
272
  */
158
273
 
159
- export function useSendPhoneVerificationCode(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
160
- const { onCompleted, onError } = params;
161
- const [sendPhoneVerificationCode, mtnValues, mtnHandlers] = useMutation(
162
- sendPhoneVerificationCodeMtn,
163
- {
164
- checkMountedBeforeCallback: true,
165
- openModalPopUp,
166
- onCompleted,
167
- onError
168
- },
169
- );
170
-
171
- return {
172
- sendPhoneVerificationCode,
173
- ...mtnValues,
174
- ...mtnHandlers,
175
- };
274
+ export function useSendPhoneVerificationCode(
275
+ params: UseMutationParams = {},
276
+ openModalPopUp?: OpenModalPopUpFn,
277
+ ) {
278
+ const { onCompleted, onError } = params;
279
+ const [sendPhoneVerificationCode, mtnValues, mtnHandlers] = useMutation(
280
+ sendPhoneVerificationCodeMtn,
281
+ {
282
+ checkMountedBeforeCallback: true,
283
+ openModalPopUp,
284
+ onCompleted,
285
+ onError,
286
+ },
287
+ );
288
+
289
+ return {
290
+ sendPhoneVerificationCode,
291
+ ...mtnValues,
292
+ ...mtnHandlers,
293
+ };
176
294
  }
177
295
 
178
296
  /**
179
297
  * Confirm verification code
180
298
  */
181
299
 
182
- export function useConfirmPhoneVerificationCode(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
183
- const { onCompleted, onError } = params;
184
-
185
- const [confirmPhoneVerificationCode, mtnValues, mtnHandlers] = useMutation(
186
- confirmPhoneVerificationCodeMtn,
187
- {
188
- checkMountedBeforeCallback: true,
189
- openModalPopUp,
190
- onCompleted,
191
- onError
192
- },
193
- );
194
-
195
- return {
196
- confirmPhoneVerificationCode,
197
- ...mtnValues,
198
- ...mtnHandlers,
199
- };
300
+ export function useConfirmPhoneVerificationCode(
301
+ params: UseMutationParams = {},
302
+ openModalPopUp?: OpenModalPopUpFn,
303
+ ) {
304
+ const { onCompleted, onError } = params;
305
+
306
+ const [confirmPhoneVerificationCode, mtnValues, mtnHandlers] = useMutation(
307
+ confirmPhoneVerificationCodeMtn,
308
+ {
309
+ checkMountedBeforeCallback: true,
310
+ openModalPopUp,
311
+ onCompleted,
312
+ onError,
313
+ },
314
+ );
315
+
316
+ return {
317
+ confirmPhoneVerificationCode,
318
+ ...mtnValues,
319
+ ...mtnHandlers,
320
+ };
200
321
  }
201
322
 
202
323
  /**
203
324
  * Sign in
204
325
  */
205
326
 
206
- export function useCheckUsernameOrEmail(params: AuthHookParams = {}, openModalPopUp?: OpenModalPopUpFn) {
207
- const { onError, onCompleted, initialError, initialFormData } = params;
208
-
209
- const [dataForSchema, setDataForSchema] = useState({
210
- hasInput: !!initialFormData?.usernameOrEmail,
211
- lastIdentifier: initialFormData?.usernameOrEmail || '',
212
- hidePassword: !initialFormData?.usernameOrEmail,
213
- });
214
-
215
- const [checkUsernameOrEmail, mtnValues, mtnHandlers] = useMutation(
216
- checkUsernameOrEmailMtn,
217
- {
218
- openModalPopUp,
219
- initialError,
220
- onError,
221
- onCompleted,
222
- },
223
- );
224
-
225
- return {
226
- ...mtnValues,
227
- ...mtnHandlers,
228
- checkUsernameOrEmail,
229
- dataForSchema,
230
- setDataForSchema,
231
- };
327
+ export function useCheckUsernameOrEmail(
328
+ params: AuthHookParams = {},
329
+ openModalPopUp?: OpenModalPopUpFn,
330
+ ) {
331
+ const { onError, onCompleted, initialError, initialFormData } = params;
332
+
333
+ const [dataForSchema, setDataForSchema] = useState({
334
+ hasInput: !!initialFormData?.usernameOrEmail,
335
+ lastIdentifier: initialFormData?.usernameOrEmail || '',
336
+ hidePassword: !initialFormData?.usernameOrEmail,
337
+ });
338
+
339
+ const [checkUsernameOrEmail, mtnValues, mtnHandlers] = useMutation(
340
+ checkUsernameOrEmailMtn,
341
+ {
342
+ openModalPopUp,
343
+ initialError,
344
+ onError,
345
+ onCompleted,
346
+ },
347
+ );
348
+
349
+ return {
350
+ ...mtnValues,
351
+ ...mtnHandlers,
352
+ checkUsernameOrEmail,
353
+ dataForSchema,
354
+ setDataForSchema,
355
+ };
356
+ }
357
+
358
+ /**
359
+ * Resolve SSO sign-in options for an email address (home realm discovery)
360
+ */
361
+
362
+ export function useGetSsoLoginOptions(
363
+ params: UseMutationParams = {},
364
+ openModalPopUp?: OpenModalPopUpFn,
365
+ ) {
366
+ const { onError, onCompleted } = params;
367
+
368
+ const [getSsoLoginOptions, mtnValues, mtnHandlers] = useMutation(
369
+ getSsoLoginOptionsMtn,
370
+ {
371
+ checkMountedBeforeCallback: true,
372
+ openModalPopUp,
373
+ onError,
374
+ onCompleted,
375
+ },
376
+ );
377
+
378
+ return {
379
+ ...mtnValues,
380
+ ...mtnHandlers,
381
+ getSsoLoginOptions,
382
+ };
232
383
  }
233
384
 
234
385
  /**
235
386
  * Sign up with email
236
387
  */
237
388
 
238
- export function useSignUpWithEmail(params: AuthHookParams = {}, openModalPopUp?: OpenModalPopUpFn) {
239
- const { onError, onCompleted, initialError } = params;
240
-
241
- const [signUpWithEmail, mtnValues, mtnHandlers] = useMutation(
242
- signUpWithEmailMtn,
243
- {
244
- openModalPopUp,
245
- initialError,
246
- onError,
247
- onCompleted,
248
- },
249
- );
250
-
251
- return {
252
- ...mtnValues,
253
- ...mtnHandlers,
254
- signUpWithEmail,
255
- };
389
+ export function useSignUpWithEmail(
390
+ params: AuthHookParams = {},
391
+ openModalPopUp?: OpenModalPopUpFn,
392
+ ) {
393
+ const { onError, onCompleted, initialError } = params;
394
+
395
+ const [signUpWithEmail, mtnValues, mtnHandlers] = useMutation(
396
+ signUpWithEmailMtn,
397
+ {
398
+ openModalPopUp,
399
+ initialError,
400
+ onError,
401
+ onCompleted,
402
+ },
403
+ );
404
+
405
+ return {
406
+ ...mtnValues,
407
+ ...mtnHandlers,
408
+ signUpWithEmail,
409
+ };
256
410
  }
257
411
 
258
412
  /**
@@ -260,21 +414,24 @@ export function useSignUpWithEmail(params: AuthHookParams = {}, openModalPopUp?:
260
414
  * NOTE: *must* be signed in already
261
415
  */
262
416
 
263
- export function useConfirmPassword(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
264
- const [confirmPassword, mtnValues, mtnHandlers] = useMutation(
265
- confirmPasswordMtn,
266
- {
267
- checkMountedBeforeCallback: true,
268
- openModalPopUp,
269
- ...params,
270
- },
271
- );
272
-
273
- return {
274
- confirmPassword,
275
- ...mtnValues,
276
- ...mtnHandlers,
277
- };
417
+ export function useConfirmPassword(
418
+ params: UseMutationParams = {},
419
+ openModalPopUp?: OpenModalPopUpFn,
420
+ ) {
421
+ const [confirmPassword, mtnValues, mtnHandlers] = useMutation(
422
+ confirmPasswordMtn,
423
+ {
424
+ checkMountedBeforeCallback: true,
425
+ openModalPopUp,
426
+ ...params,
427
+ },
428
+ );
429
+
430
+ return {
431
+ confirmPassword,
432
+ ...mtnValues,
433
+ ...mtnHandlers,
434
+ };
278
435
  }
279
436
 
280
437
  // Before are deprecated HOC that needs to be migrated to hooks
@@ -288,45 +445,42 @@ export function useConfirmPassword(params: UseMutationParams = {}, openModalPopU
288
445
  */
289
446
 
290
447
  export function composeSignOut(Cmp: React.FC<any>) {
291
- const SignOutCnt = (p) => {
292
- const { doNotAlertErrors, onError, onCompleted } = p;
293
- const openModalPopUp = useOpenModalPopUp();
294
- const { dispatchApp } = useContext<any>(AppContext);
295
-
296
- const [signOut, mtnValues, mtnHandlers] = useMutation(
297
- signOutMtn,
298
- {
299
- openModalPopUp: doNotAlertErrors ? null : openModalPopUp,
300
- onError,
301
- onCompleted: (data) => {
302
- if (data?.signOut) {
303
- deleteAuthToken();
304
- onGuestInit(null, dispatchApp);
305
- }
306
- if (onCompleted) {
307
- onCompleted(data);
308
- }
309
- },
310
- },
311
- );
312
-
313
- useEffect(() => {
314
- const timer = setTimeout(() => {
315
- signOut();
316
- }, 1000);
317
- return () => clearTimeout(timer);
318
- }, []);
319
-
320
- // return (
321
- // <Cmp
322
- // {...p}
323
- // {...mtnValues}
324
- // {...mtnHandlers}
325
- // signOut={signOut}
326
- // />
327
- // );
328
- return null;
329
- };
330
-
331
- return SignOutCnt;
448
+ const SignOutCnt = (p: any) => {
449
+ const { doNotAlertErrors, onError, onCompleted } = p;
450
+ const openModalPopUp = useOpenModalPopUp();
451
+ const { dispatchApp } = useContext<any>(AppContext);
452
+
453
+ const [signOut, mtnValues, mtnHandlers] = useMutation(signOutMtn, {
454
+ openModalPopUp: doNotAlertErrors ? null : openModalPopUp,
455
+ onError,
456
+ onCompleted: (data) => {
457
+ if (data?.signOut) {
458
+ deleteAuthToken();
459
+ onGuestInit(null, dispatchApp);
460
+ }
461
+ if (onCompleted) {
462
+ onCompleted(data);
463
+ }
464
+ },
465
+ });
466
+
467
+ useEffect(() => {
468
+ const timer = setTimeout(() => {
469
+ signOut();
470
+ }, 1000);
471
+ return () => clearTimeout(timer);
472
+ }, []);
473
+
474
+ // return (
475
+ // <Cmp
476
+ // {...p}
477
+ // {...mtnValues}
478
+ // {...mtnHandlers}
479
+ // signOut={signOut}
480
+ // />
481
+ // );
482
+ return null;
483
+ };
484
+
485
+ return SignOutCnt;
332
486
  }