@jsb188/graphql 1.1.1 → 1.1.4
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/cache/config.ts +1 -0
- package/cache/index.ts +32 -9
- package/gql/fragments/accountFragments.ts +3 -0
- package/gql/fragments/logFragments.ts +26 -0
- package/gql/fragments/organizationFragments.ts +1 -0
- package/gql/fragments/otherFragments.ts +1 -0
- package/gql/mutations/{accountAuthMutations.ts → authMutations.ts} +55 -0
- package/gql/mutations/userAuthMutations.ts +0 -87
- package/gql/queries/logQueries.ts +37 -0
- package/hooks/index.ts +1 -1
- package/hooks/use-aiChat-qry.ts +1 -1
- package/hooks/use-auth-mtn.ts +90 -43
- package/hooks/use-log-qry.ts +55 -0
- package/package.json +8 -8
- package/gql/fragments/journalFragments.ts +0 -14
- package/gql/queries/journalQueries.ts +0 -22
- package/hooks/use-journal-qry.ts +0 -49
- /package/gql/mutations/{journalMutations.ts → logMutations.ts} +0 -0
package/cache/config.ts
CHANGED
package/cache/index.ts
CHANGED
|
@@ -167,10 +167,13 @@ export function loadFragment(id: string) {
|
|
|
167
167
|
|
|
168
168
|
function mapSelections(data: any, innerSelections: any[], updatedKeys: string[] = []) {
|
|
169
169
|
return innerSelections.map((inner) => {
|
|
170
|
+
|
|
171
|
+
let fragmentKey;
|
|
170
172
|
if (inner.kind === 'FragmentSpread') {
|
|
173
|
+
// These are fragment spreads
|
|
171
174
|
const frgName = inner.name.value;
|
|
172
175
|
const frgMap = PARTIALS_MAP[frgName];
|
|
173
|
-
|
|
176
|
+
fragmentKey = `$${frgMap || frgName}:${data.id || 'none'}`;
|
|
174
177
|
|
|
175
178
|
if (DO_LOG[0]) {
|
|
176
179
|
console.log('SETTING (1): ', fragmentKey);
|
|
@@ -178,11 +181,13 @@ function mapSelections(data: any, innerSelections: any[], updatedKeys: string[]
|
|
|
178
181
|
if (DO_LOG[1]) {
|
|
179
182
|
console.log('SETTING (1): ', extractFragment(data, innerSelections));
|
|
180
183
|
}
|
|
184
|
+
} else if (inner.kind === 'InlineFragment') {
|
|
185
|
+
// This is Union, etc
|
|
186
|
+
const frgNamesJoined = inner.selectionSet.selections.map((sel: any) => PARTIALS_MAP[sel.name.value] || sel.name.value).join('.');
|
|
187
|
+
fragmentKey = `$${frgNamesJoined}:${data.id || 'none'}`;
|
|
188
|
+
}
|
|
181
189
|
|
|
182
|
-
|
|
183
|
-
// console.log('---->', data.id);
|
|
184
|
-
// }
|
|
185
|
-
|
|
190
|
+
if (fragmentKey) {
|
|
186
191
|
// Whether fragment is partial or not, always merge data;
|
|
187
192
|
// Because partials might have data that's not in the main fragment
|
|
188
193
|
const currentData = loadFragment(fragmentKey);
|
|
@@ -194,7 +199,11 @@ function mapSelections(data: any, innerSelections: any[], updatedKeys: string[]
|
|
|
194
199
|
return fragmentKey;
|
|
195
200
|
}
|
|
196
201
|
|
|
197
|
-
|
|
202
|
+
// These are non-fragment fields
|
|
203
|
+
return [
|
|
204
|
+
inner.name.value,
|
|
205
|
+
data?.[inner.name.value]
|
|
206
|
+
];
|
|
198
207
|
// return {
|
|
199
208
|
// name: inner.name.value,
|
|
200
209
|
// value: data[key]?.[inner.name.value]
|
|
@@ -427,7 +436,7 @@ export function setDataToCache(
|
|
|
427
436
|
* Append fragment to cache
|
|
428
437
|
*/
|
|
429
438
|
|
|
430
|
-
export function appendFragmentToCache(cacheData: any) {
|
|
439
|
+
export function appendFragmentToCache(cacheData: any, testMode?: boolean) {
|
|
431
440
|
let newObj = cloneArrayLike(cacheData);
|
|
432
441
|
|
|
433
442
|
for (const key in newObj) {
|
|
@@ -442,7 +451,6 @@ export function appendFragmentToCache(cacheData: any) {
|
|
|
442
451
|
let item = {};
|
|
443
452
|
di.forEach((d) => {
|
|
444
453
|
if (Array.isArray(d)) {
|
|
445
|
-
// @ts-expect-error
|
|
446
454
|
item[d[0]] = d[1];
|
|
447
455
|
} else if (typeof d === 'string') {
|
|
448
456
|
const frgIndex = d.indexOf(':');
|
|
@@ -480,8 +488,15 @@ export function appendFragmentToCache(cacheData: any) {
|
|
|
480
488
|
});
|
|
481
489
|
} else {
|
|
482
490
|
newObj[key].data.forEach((d: any) => {
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
// if (testMode) {
|
|
494
|
+
// console.log('cachedObj', cachedObj);
|
|
495
|
+
// console.log('d', d);
|
|
496
|
+
// console.log('d', typeof d);
|
|
497
|
+
// }
|
|
498
|
+
|
|
483
499
|
if (Array.isArray(d)) {
|
|
484
|
-
// @ts-expect-error
|
|
485
500
|
cachedObj[d[0]] = d[1];
|
|
486
501
|
} else if (typeof d === 'string') {
|
|
487
502
|
const frgIndex = d.indexOf(':');
|
|
@@ -552,6 +567,14 @@ export function loadDataFromCache(
|
|
|
552
567
|
const data = { ...requestData };
|
|
553
568
|
const definitions = gqlQuery.definitions;
|
|
554
569
|
|
|
570
|
+
|
|
571
|
+
// console.log('loadDataFromCache()');
|
|
572
|
+
// console.log(data);
|
|
573
|
+
// console.log(definitions);
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
555
578
|
for (const def of definitions) {
|
|
556
579
|
if (def.kind === 'OperationDefinition') {
|
|
557
580
|
def?.selectionSet?.selections.forEach((selection: any) => {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
export const logEntryFragment = `fragment logEntryFragment on LogEntry {
|
|
3
|
+
id
|
|
4
|
+
accountId
|
|
5
|
+
organizationId
|
|
6
|
+
|
|
7
|
+
createdAt
|
|
8
|
+
updatedAt
|
|
9
|
+
}`;
|
|
10
|
+
|
|
11
|
+
export const logEntryArableFragment = `fragment logEntryArableFragment on LogEntryArable {
|
|
12
|
+
__typename
|
|
13
|
+
|
|
14
|
+
id
|
|
15
|
+
type
|
|
16
|
+
activity
|
|
17
|
+
quantity
|
|
18
|
+
unit
|
|
19
|
+
price
|
|
20
|
+
notes
|
|
21
|
+
|
|
22
|
+
crop {
|
|
23
|
+
id
|
|
24
|
+
name
|
|
25
|
+
}
|
|
26
|
+
}`;
|
|
@@ -51,3 +51,58 @@ mutation authenticateWithToken (
|
|
|
51
51
|
}
|
|
52
52
|
${authenticateFragments}
|
|
53
53
|
`;
|
|
54
|
+
|
|
55
|
+
export const sendEmailVerificationMtn = gql`
|
|
56
|
+
mutation sendEmailVerification (
|
|
57
|
+
$userId: UserID!
|
|
58
|
+
$email: String!
|
|
59
|
+
) {
|
|
60
|
+
sendEmailVerification (
|
|
61
|
+
userId: $userId
|
|
62
|
+
email: $email
|
|
63
|
+
) {
|
|
64
|
+
token
|
|
65
|
+
userId
|
|
66
|
+
username
|
|
67
|
+
emailAddress
|
|
68
|
+
}
|
|
69
|
+
}`;
|
|
70
|
+
|
|
71
|
+
export const signUpWithEmailMtn = gql`
|
|
72
|
+
mutation signUpWithEmail (
|
|
73
|
+
$emailAddress: String!
|
|
74
|
+
$password: String!
|
|
75
|
+
) {
|
|
76
|
+
signUpWithEmail (
|
|
77
|
+
emailAddress: $emailAddress
|
|
78
|
+
password: $password
|
|
79
|
+
)
|
|
80
|
+
}`;
|
|
81
|
+
|
|
82
|
+
export const signInWithGoogleMtn = gql`
|
|
83
|
+
mutation signInWithGoogle (
|
|
84
|
+
$oauthToken: String!
|
|
85
|
+
) {
|
|
86
|
+
signInWithGoogle (
|
|
87
|
+
oauthToken: $oauthToken
|
|
88
|
+
) {
|
|
89
|
+
${authenticateResultText}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
${authenticateFragments}
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
export const signInWithAppleMtn = gql`
|
|
96
|
+
mutation signInWithApple (
|
|
97
|
+
$code: String!
|
|
98
|
+
$idToken: String!
|
|
99
|
+
) {
|
|
100
|
+
signInWithApple (
|
|
101
|
+
code: $code
|
|
102
|
+
idToken: $idToken
|
|
103
|
+
) {
|
|
104
|
+
${authenticateResultText}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
${authenticateFragments}
|
|
108
|
+
`;
|
|
@@ -63,52 +63,6 @@ mutation checkUsernameOrEmail (
|
|
|
63
63
|
}
|
|
64
64
|
}`;
|
|
65
65
|
|
|
66
|
-
export const emailVerificationStatusMtn = gql`
|
|
67
|
-
mutation emailVerificationStatus (
|
|
68
|
-
$token: Token!
|
|
69
|
-
) {
|
|
70
|
-
emailVerificationStatus (
|
|
71
|
-
token: $token
|
|
72
|
-
)
|
|
73
|
-
}`;
|
|
74
|
-
|
|
75
|
-
export const sendEmailVerificationMtn = gql`
|
|
76
|
-
mutation sendEmailVerification (
|
|
77
|
-
$userId: UserID!
|
|
78
|
-
$email: String!
|
|
79
|
-
) {
|
|
80
|
-
sendEmailVerification (
|
|
81
|
-
userId: $userId
|
|
82
|
-
email: $email
|
|
83
|
-
) {
|
|
84
|
-
token
|
|
85
|
-
userId
|
|
86
|
-
username
|
|
87
|
-
emailAddress
|
|
88
|
-
}
|
|
89
|
-
}`;
|
|
90
|
-
|
|
91
|
-
export const signUpMtn = gql`
|
|
92
|
-
mutation signUp (
|
|
93
|
-
$email: String!
|
|
94
|
-
$displayName: String!
|
|
95
|
-
$username: String!
|
|
96
|
-
$password: String!
|
|
97
|
-
) {
|
|
98
|
-
signUp (
|
|
99
|
-
email: $email
|
|
100
|
-
displayName: $displayName
|
|
101
|
-
username: $username
|
|
102
|
-
password: $password
|
|
103
|
-
) {
|
|
104
|
-
token
|
|
105
|
-
userId
|
|
106
|
-
username
|
|
107
|
-
emailAddress
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
66
|
export const signOutMtn = gql`
|
|
113
67
|
mutation signOut {
|
|
114
68
|
signOut
|
|
@@ -142,47 +96,6 @@ mutation signIn (
|
|
|
142
96
|
${signInFragments}
|
|
143
97
|
`;
|
|
144
98
|
|
|
145
|
-
export const signInWithGoogleMtn = gql`
|
|
146
|
-
mutation signInWithGoogle (
|
|
147
|
-
$oauthToken: String!
|
|
148
|
-
) {
|
|
149
|
-
signInWithGoogle (
|
|
150
|
-
oauthToken: $oauthToken
|
|
151
|
-
) {
|
|
152
|
-
${signInResultText}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
${signInFragments}
|
|
156
|
-
`;
|
|
157
|
-
|
|
158
|
-
export const signInWithDiscordMtn = gql`
|
|
159
|
-
mutation signInWithDiscord (
|
|
160
|
-
$oauthToken: String!
|
|
161
|
-
) {
|
|
162
|
-
signInWithDiscord (
|
|
163
|
-
oauthToken: $oauthToken
|
|
164
|
-
) {
|
|
165
|
-
${signInResultText}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
${signInFragments}
|
|
169
|
-
`;
|
|
170
|
-
|
|
171
|
-
export const signInWithAppleMtn = gql`
|
|
172
|
-
mutation signInWithApple (
|
|
173
|
-
$code: String!
|
|
174
|
-
$idToken: String!
|
|
175
|
-
) {
|
|
176
|
-
signInWithApple (
|
|
177
|
-
code: $code
|
|
178
|
-
idToken: $idToken
|
|
179
|
-
) {
|
|
180
|
-
${signInResultText}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
${signInFragments}
|
|
184
|
-
`;
|
|
185
|
-
|
|
186
99
|
export const changePasswordMtn = gql`
|
|
187
100
|
mutation changePassword (
|
|
188
101
|
$currentPassword: String!
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { accountFragment } from '../fragments/accountFragments';
|
|
3
|
+
import { logEntryFragment, logEntryArableFragment } from '../fragments/logFragments';
|
|
4
|
+
|
|
5
|
+
export const logEntriesQry = gql`
|
|
6
|
+
query logEntries (
|
|
7
|
+
$organizationId: GenericID!
|
|
8
|
+
$filter: LogEntriesFilter!
|
|
9
|
+
$cursor: Cursor
|
|
10
|
+
$after: Boolean!
|
|
11
|
+
$limit: Int!
|
|
12
|
+
) {
|
|
13
|
+
logEntries (
|
|
14
|
+
organizationId: $organizationId
|
|
15
|
+
filter: $filter
|
|
16
|
+
cursor: $cursor
|
|
17
|
+
after: $after
|
|
18
|
+
limit: $limit
|
|
19
|
+
) {
|
|
20
|
+
...logEntryFragment
|
|
21
|
+
|
|
22
|
+
details {
|
|
23
|
+
...on LogEntryArable {
|
|
24
|
+
...logEntryArableFragment
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
account {
|
|
29
|
+
...accountFragment
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
${accountFragment}
|
|
35
|
+
${logEntryFragment}
|
|
36
|
+
${logEntryArableFragment}
|
|
37
|
+
`;
|
package/hooks/index.ts
CHANGED
package/hooks/use-aiChat-qry.ts
CHANGED
|
@@ -142,7 +142,7 @@ export function useAIChatMessages(aiChatId?: string, params: UseQueryParams = {}
|
|
|
142
142
|
* Fetch AI chats list
|
|
143
143
|
*/
|
|
144
144
|
|
|
145
|
-
export function useAIChats(filter?: 'CAL_DATE') {
|
|
145
|
+
export function useAIChats(filter?: 'CAL_DATE' | 'CHATS') {
|
|
146
146
|
const { data, ...other } = useQuery(aiChatsQry, {
|
|
147
147
|
variables: {
|
|
148
148
|
filter,
|
package/hooks/use-auth-mtn.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import i18n from '@jsb188/app/i18n';
|
|
2
|
-
import {
|
|
3
|
-
import { changePasswordMtn, checkUsernameOrEmailMtn, emailVerificationStatusMtn, requestTokenizedEmailMtn, sendEmailVerificationMtn, signInMtn } from '../gql/mutations/userAuthMutations';
|
|
2
|
+
import { deleteAuthToken } from '@jsb188/app/platform';
|
|
4
3
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
4
|
+
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
5
|
+
import { AppContext, onAccountLogin, onGuestInit, useOpenModalPopUp } from '@jsb188/react/states';
|
|
6
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
7
|
+
import { sendEmailVerificationMtn, signUpWithEmailMtn } from '../gql/mutations/authMutations';
|
|
8
|
+
import { changePasswordMtn, checkUsernameOrEmailMtn, requestTokenizedEmailMtn, signInMtn, signOutMtn } from '../gql/mutations/userAuthMutations';
|
|
9
|
+
import { useMutation } from './index';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Types
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
|
-
interface
|
|
15
|
+
interface AuthHookParams extends UseMutationParams {
|
|
14
16
|
initialError?: any;
|
|
15
17
|
initialFormData?: Record<string, any>;
|
|
16
18
|
}
|
|
@@ -21,7 +23,7 @@ interface SignInParams extends UseMutationParams {
|
|
|
21
23
|
|
|
22
24
|
export function useChangePassword(params: UseMutationParams = {}) {
|
|
23
25
|
|
|
24
|
-
const { dispatchApp, appState: { hasPassword, account } } = useContext(
|
|
26
|
+
const { dispatchApp, appState: { hasPassword, account } } = useContext(AppContext);
|
|
25
27
|
const openModalPopUp = useOpenModalPopUp();
|
|
26
28
|
const { onCompleted, onError } = params;
|
|
27
29
|
|
|
@@ -75,7 +77,7 @@ export function useChangePassword(params: UseMutationParams = {}) {
|
|
|
75
77
|
|
|
76
78
|
export function useChangePasswordForm(params: UseMutationParams = {}) {
|
|
77
79
|
|
|
78
|
-
const { dispatchApp, appState: { hasPassword, account } } = useContext(
|
|
80
|
+
const { dispatchApp, appState: { hasPassword, account } } = useContext(AppContext);
|
|
79
81
|
const { onCompleted, onError } = params;
|
|
80
82
|
|
|
81
83
|
const onCompleted_ = (data: any, err: any, variables: any) => {
|
|
@@ -114,39 +116,6 @@ export function useChangePasswordForm(params: UseMutationParams = {}) {
|
|
|
114
116
|
};
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
/**
|
|
118
|
-
* Check email verification status
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
export function useEmailVerification(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
122
|
-
|
|
123
|
-
const { onCompleted, onError } = params;
|
|
124
|
-
const [emailVerificationStatus, mtnValues1] = useMutation(
|
|
125
|
-
emailVerificationStatusMtn,
|
|
126
|
-
{
|
|
127
|
-
openModalPopUp,
|
|
128
|
-
onError,
|
|
129
|
-
onCompleted,
|
|
130
|
-
},
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
const [sendEmailVerification, mtnValues2] = useMutation(
|
|
134
|
-
sendEmailVerificationMtn,
|
|
135
|
-
{
|
|
136
|
-
openModalPopUp,
|
|
137
|
-
onError,
|
|
138
|
-
onCompleted,
|
|
139
|
-
},
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
emailVerificationStatus,
|
|
144
|
-
sendEmailVerification,
|
|
145
|
-
verifying: mtnValues1.saving,
|
|
146
|
-
sending: mtnValues2.saving,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
119
|
/**
|
|
151
120
|
* Request password reset (email with link)
|
|
152
121
|
*/
|
|
@@ -174,9 +143,9 @@ export function useRequestTokenizedEmail(params: UseMutationParams = {}, openMod
|
|
|
174
143
|
* Sign in
|
|
175
144
|
*/
|
|
176
145
|
|
|
177
|
-
export function useSignIn(params:
|
|
146
|
+
export function useSignIn(params: AuthHookParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
178
147
|
const { onError, onCompleted, initialError, initialFormData } = params;
|
|
179
|
-
const { dispatchApp } = useContext<any>(
|
|
148
|
+
const { dispatchApp } = useContext<any>(AppContext);
|
|
180
149
|
|
|
181
150
|
const [dataForSchema, setDataForSchema] = useState({
|
|
182
151
|
hasInput: !!initialFormData?.usernameOrEmail,
|
|
@@ -232,3 +201,81 @@ export function useSignIn(params: SignInParams = {}, openModalPopUp?: OpenModalP
|
|
|
232
201
|
setDataForSchema,
|
|
233
202
|
};
|
|
234
203
|
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Sign up with email
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
export function useSignUpWithEmail(params: AuthHookParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
210
|
+
const { onError, onCompleted, initialError } = params;
|
|
211
|
+
|
|
212
|
+
const [signUpWithEmail, mtnValues, mtnHandlers] = useMutation(
|
|
213
|
+
signUpWithEmailMtn,
|
|
214
|
+
{
|
|
215
|
+
openModalPopUp,
|
|
216
|
+
initialError,
|
|
217
|
+
onError,
|
|
218
|
+
onCompleted,
|
|
219
|
+
},
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
...mtnValues,
|
|
224
|
+
...mtnHandlers,
|
|
225
|
+
signUpWithEmail,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
230
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
231
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
232
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
233
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Sign out
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
export function composeSignOut(Cmp: React.FC<any>) {
|
|
240
|
+
const SignOutCnt = (p) => {
|
|
241
|
+
const { doNotAlertErrors, onError, onCompleted } = p;
|
|
242
|
+
const openModalPopUp = useOpenModalPopUp();
|
|
243
|
+
const { dispatchApp } = useContext<any>(AppContext);
|
|
244
|
+
|
|
245
|
+
const [signOut, mtnValues, mtnHandlers] = useMutation(
|
|
246
|
+
signOutMtn,
|
|
247
|
+
{
|
|
248
|
+
openModalPopUp: doNotAlertErrors ? null : openModalPopUp,
|
|
249
|
+
onError,
|
|
250
|
+
onCompleted: (data) => {
|
|
251
|
+
if (data?.signOut) {
|
|
252
|
+
deleteAuthToken();
|
|
253
|
+
onGuestInit(null, dispatchApp);
|
|
254
|
+
}
|
|
255
|
+
if (onCompleted) {
|
|
256
|
+
onCompleted(data);
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
useEffect(() => {
|
|
263
|
+
const timer = setTimeout(() => {
|
|
264
|
+
signOut();
|
|
265
|
+
}, 1000);
|
|
266
|
+
return () => clearTimeout(timer);
|
|
267
|
+
}, []);
|
|
268
|
+
|
|
269
|
+
// return (
|
|
270
|
+
// <Cmp
|
|
271
|
+
// {...p}
|
|
272
|
+
// {...mtnValues}
|
|
273
|
+
// {...mtnHandlers}
|
|
274
|
+
// signOut={signOut}
|
|
275
|
+
// />
|
|
276
|
+
// );
|
|
277
|
+
return null;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
return SignOutCnt;
|
|
281
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PaginationArgs, UseQueryParams } from '../types';
|
|
2
|
+
import { useQuery } from '../client';
|
|
3
|
+
import { logEntriesQry } from '../gql/queries/logQueries';
|
|
4
|
+
import type { FilterLogEntriesArgs } from '@jsb188/app/types/log.d';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Constants
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const LOG_ENTRIES_LIMIT = 50;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Helper; use this to get/use same filter for logEntries() query everywhere
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export function getDefaultLogEntriesFilter(operation: FilterLogEntriesArgs['operation']): FilterLogEntriesArgs {
|
|
17
|
+
return {
|
|
18
|
+
operation,
|
|
19
|
+
type: null,
|
|
20
|
+
startDate: null,
|
|
21
|
+
endDate: null,
|
|
22
|
+
query: ''
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetch log entries
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
interface LogEntriesArgs extends PaginationArgs {
|
|
31
|
+
organizationId: string;
|
|
32
|
+
accountId?: string;
|
|
33
|
+
timeZone: string | null;
|
|
34
|
+
filter: FilterLogEntriesArgs;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function useLogEntries(variables: LogEntriesArgs, params: UseQueryParams = {}) {
|
|
38
|
+
|
|
39
|
+
const { data, ...other } = useQuery(logEntriesQry, {
|
|
40
|
+
variables: {
|
|
41
|
+
...variables,
|
|
42
|
+
cursor: null,
|
|
43
|
+
after: true,
|
|
44
|
+
limit: LOG_ENTRIES_LIMIT
|
|
45
|
+
},
|
|
46
|
+
// If this query is used for virtualized list pagination, set {params.skip=true}
|
|
47
|
+
skip: !variables.organizationId || !variables.filter?.operation,
|
|
48
|
+
...params,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
logEntries: data?.logEntries,
|
|
53
|
+
...other
|
|
54
|
+
};
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsb188/graphql",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "GraphQL client for react, using recoil",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "jsb188",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"./fragments/billing": "./gql/fragments/billingFragments.ts",
|
|
14
14
|
"./fragments/card": "./gql/fragments/cardFragments.ts",
|
|
15
15
|
"./fragments/chat": "./gql/fragments/chatFragments.ts",
|
|
16
|
-
"./fragments/
|
|
16
|
+
"./fragments/log": "./gql/fragments/logFragments.ts",
|
|
17
17
|
"./fragments/organization": "./gql/fragments/organizationFragments.ts",
|
|
18
18
|
"./fragments/other": "./gql/fragments/otherFragments.ts",
|
|
19
19
|
"./fragments/user": "./gql/fragments/userFragments.ts",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"./hooks": "./hooks/",
|
|
22
22
|
"./hooks/use-aiChat-qry": "./hooks/use-aiChat-qry.ts",
|
|
23
23
|
"./hooks/use-app-qry": "./hooks/use-app-qry.ts",
|
|
24
|
-
"./hooks/use-
|
|
24
|
+
"./hooks/use-log-qry": "./hooks/use-log-qry.ts",
|
|
25
25
|
"./hooks/use-organization-qry": "./hooks/use-organization-qry.ts",
|
|
26
26
|
"./hooks/use-auth-mtn": "./hooks/use-auth-mtn.ts",
|
|
27
|
-
"./mutations/accountAuth": "./gql/mutations/accountAuthMutations.ts",
|
|
28
27
|
"./mutations/aiChat": "./gql/mutations/aiChatMutations.ts",
|
|
28
|
+
"./mutations/auth": "./gql/mutations/authMutations.ts",
|
|
29
29
|
"./mutations/billing": "./gql/mutations/billingMutations.ts",
|
|
30
30
|
"./mutations/chat": "./gql/mutations/chatMutations.ts",
|
|
31
|
-
"./mutations/
|
|
31
|
+
"./mutations/log": "./gql/mutations/logMutations.ts",
|
|
32
32
|
"./mutations/other": "./gql/mutations/otherMutations.ts",
|
|
33
33
|
"./mutations/user": "./gql/mutations/userMutations.ts",
|
|
34
34
|
"./mutations/userAuth": "./gql/mutations/userAuthMutations.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"./queries/billing": "./gql/queries/billingQueries.ts",
|
|
38
38
|
"./queries/card": "./gql/queries/cardQueries.ts",
|
|
39
39
|
"./queries/chat": "./gql/queries/chatQueries.ts",
|
|
40
|
-
"./queries/
|
|
40
|
+
"./queries/log": "./gql/queries/logQueries.ts",
|
|
41
41
|
"./queries/organization": "./gql/queries/organizationQueries.ts",
|
|
42
42
|
"./queries/other": "./gql/queries/otherQueries.ts",
|
|
43
43
|
"./queries/user": "./gql/queries/userQueries.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"graphql-tag": "^2.12.6"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@jsb188/app": "1.1.
|
|
59
|
-
"@jsb188/react": "1.1.
|
|
58
|
+
"@jsb188/app": "1.1.4",
|
|
59
|
+
"@jsb188/react": "1.1.4"
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { gql } from 'graphql-tag';
|
|
2
|
-
import { journalEntryFragment } from '../fragments/journalFragments';
|
|
3
|
-
|
|
4
|
-
export const journalEntriesQry = gql`
|
|
5
|
-
query journalEntries (
|
|
6
|
-
$organizationId: GenericID!
|
|
7
|
-
$cursor: Cursor
|
|
8
|
-
$after: Boolean!
|
|
9
|
-
$limit: Int!
|
|
10
|
-
) {
|
|
11
|
-
journalEntries (
|
|
12
|
-
organizationId: $organizationId
|
|
13
|
-
cursor: $cursor
|
|
14
|
-
after: $after
|
|
15
|
-
limit: $limit
|
|
16
|
-
) {
|
|
17
|
-
...journalEntryFragment
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
${journalEntryFragment}
|
|
22
|
-
`;
|
package/hooks/use-journal-qry.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { PaginationArgs, UseQueryParams } from '../types.d';
|
|
2
|
-
import { useQuery } from '../client';
|
|
3
|
-
import { journalEntriesQry } from '../gql/queries/journalQueries';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Constants
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const JOURNAL_ENTRIES_LIMIT = 50;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Types
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
interface JournalEntriesVariables {
|
|
16
|
-
organizationId?: string;
|
|
17
|
-
accountId?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface JournalEntriesArgs extends PaginationArgs {
|
|
21
|
-
organizationId: string;
|
|
22
|
-
accountId?: string;
|
|
23
|
-
timeZone: string | null;
|
|
24
|
-
filter: FilterJournalEntriesArgs;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Fetch journal entries
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
export function useJournalEntries(variables: JournalEntriesArgs, params: UseQueryParams = {}) {
|
|
32
|
-
|
|
33
|
-
const { data, ...other } = useQuery(journalEntriesQry, {
|
|
34
|
-
variables: {
|
|
35
|
-
...variables,
|
|
36
|
-
cursor: null,
|
|
37
|
-
after: true,
|
|
38
|
-
limit: JOURNAL_ENTRIES_LIMIT
|
|
39
|
-
},
|
|
40
|
-
// If this query is used for virtualized list pagination, set {params.skip=true}
|
|
41
|
-
skip: !variables.organizationId,
|
|
42
|
-
...params,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
journalEntries: data?.journalEntries,
|
|
47
|
-
...other
|
|
48
|
-
};
|
|
49
|
-
}
|
|
File without changes
|