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