@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.
- package/cache/config.ts +64 -50
- package/cache/index.test.ts +671 -109
- package/cache/index.ts +1700 -1240
- package/cache/persist.ts +721 -0
- package/cache/store.ts +437 -0
- package/client/data-table-realtime-subscriptions.test.ts +740 -0
- package/client/data-table-realtime-subscriptions.ts +955 -0
- package/client/data-table-realtime.test.ts +792 -0
- package/client/data-table-realtime.ts +1218 -0
- package/client/fragment-realtime-sequence.ts +52 -0
- package/client/index.ts +2 -0
- package/client/open-sheet.ts +137 -0
- package/client/request-managed-session.test.ts +574 -0
- package/client/request-no-store.test.ts +157 -0
- package/client/request.ts +954 -163
- package/client/sse-ticket.test.ts +26 -0
- package/deno.lock +170 -0
- package/deno.test.json +8 -4
- package/drafts/index.ts +149 -0
- package/drafts/store.ts +397 -0
- 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/agentDocFragments.ts +46 -0
- package/gql/fragments/agentMemoryFragments.ts +19 -0
- package/gql/fragments/aiChatFragments.ts +16 -0
- package/gql/fragments/billingFragments.ts +0 -11
- package/gql/fragments/campaignFragments.ts +277 -0
- package/gql/fragments/dataTableFragments.ts +18 -128
- package/gql/fragments/emailFragments.ts +19 -9
- package/gql/fragments/fieldDocFragments.ts +82 -0
- package/gql/fragments/logFragments.ts +20 -79
- package/gql/fragments/organizationFragments.ts +43 -5
- package/gql/fragments/scheduleFragments.ts +155 -0
- package/gql/fragments/sheetFragments.ts +552 -22
- package/gql/fragments/storageFragments.ts +21 -0
- package/gql/fragments/workflowFragments.ts +28 -4
- package/gql/mutations/accountMutations.ts +0 -2
- package/gql/mutations/agentDocMutations.ts +177 -0
- package/gql/mutations/agentMemoryMutations.ts +36 -0
- package/gql/mutations/aiChatMutations.ts +17 -4
- package/gql/mutations/authMutations.ts +158 -17
- package/gql/mutations/campaignMutations.ts +215 -0
- package/gql/mutations/dataTableMutations.ts +48 -26
- package/gql/mutations/fieldDocMutations.ts +24 -0
- package/gql/mutations/index.ts +6 -1
- package/gql/mutations/logMutations.ts +6 -29
- package/gql/mutations/organizationMutations.ts +13 -4
- package/gql/mutations/scheduleMutations.ts +423 -0
- package/gql/mutations/sheetMutations.ts +273 -56
- package/gql/mutations/storageMutations.ts +20 -0
- package/gql/mutations/workflowMutations.ts +42 -0
- package/gql/queries/agentDocQueries.ts +120 -0
- package/gql/queries/agentMemoryQueries.ts +22 -0
- package/gql/queries/aiChatQueries.ts +18 -2
- package/gql/queries/authQueries.ts +41 -0
- package/gql/queries/billingQueries.ts +23 -0
- package/gql/queries/campaignQueries.ts +127 -0
- package/gql/queries/dataTableQueries.ts +100 -11
- package/gql/queries/emailQueries.ts +55 -3
- package/gql/queries/fieldDocQueries.ts +158 -0
- package/gql/queries/index.ts +8 -2
- package/gql/queries/logQueries.ts +11 -28
- package/gql/queries/organizationQueries.ts +52 -1
- package/gql/queries/scheduleQueries.ts +315 -0
- package/gql/queries/sheetQueries.ts +336 -25
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +72 -3
- package/hooks/index.ts +2065 -971
- package/hooks/use-account-mtn.ts +76 -81
- package/hooks/use-agentDoc-mtn.ts +285 -0
- package/hooks/use-agentDoc-qry.ts +208 -0
- package/hooks/use-agentMemory-mtn.ts +73 -0
- package/hooks/use-agentMemory-qry.ts +44 -0
- package/hooks/use-aiChat-mtn.ts +232 -137
- package/hooks/use-aiChat-qry.ts +480 -222
- package/hooks/use-app-qry.ts +12 -9
- package/hooks/use-auth-mtn.ts +406 -252
- package/hooks/use-auth-qry.ts +51 -0
- package/hooks/use-campaign-mtn.ts +377 -0
- package/hooks/use-campaign-qry.ts +257 -0
- package/hooks/use-dataTable-mtn.ts +116 -33
- package/hooks/use-dataTable-qry.ts +859 -35
- package/hooks/use-email-qry.ts +194 -79
- package/hooks/use-fieldDoc-mtn.ts +50 -0
- package/hooks/use-fieldDoc-qry.ts +180 -0
- package/hooks/use-inboundContact-mtn.ts +19 -16
- package/hooks/use-inboundContact-qry.ts +63 -55
- package/hooks/use-integration-mtn.ts +56 -38
- package/hooks/use-integration-qry.ts +24 -9
- package/hooks/use-log-mtn.ts +72 -56
- package/hooks/use-log-qry.ts +93 -69
- package/hooks/use-organization-mtn.ts +334 -277
- package/hooks/use-organization-qry.ts +199 -129
- package/hooks/use-schedule-mtn.ts +416 -0
- package/hooks/use-schedule-qry.ts +157 -0
- package/hooks/use-sheet-mtn.ts +233 -47
- package/hooks/use-sheet-qry.ts +353 -70
- package/hooks/use-storage-mtn.ts +81 -41
- package/hooks/use-storage-qry.ts +104 -13
- package/hooks/use-workflow-mtn.ts +55 -0
- package/hooks/use-workflow-qry.ts +206 -48
- package/loaders/campaign.ts +137 -0
- package/package.json +94 -71
- package/sse.ts +157 -104
- package/tsconfig.json +11 -10
- package/types.d.ts +60 -30
- package/utils.ts +78 -49
- package/gql/fragments/productFragments.ts +0 -39
- package/gql/fragments/reportFragments.ts +0 -90
- package/gql/mutations/billingMutations.ts +0 -34
- 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
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { useQuery, useReactiveFragment } from '@jsb188/graphql/client';
|
|
2
2
|
import type { InboundContactsSortEnum } from '@jsb188/mday/types/inboundContact.d.ts';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
FRAGMENT_NAMES,
|
|
5
|
+
makeFragmentKey,
|
|
6
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
7
|
+
import {
|
|
8
|
+
inboundContactQry,
|
|
9
|
+
inboundContactsQry,
|
|
10
|
+
} from '../gql/queries/inboundContactQueries.ts';
|
|
5
11
|
import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
6
12
|
|
|
7
13
|
/**
|
|
@@ -15,32 +21,32 @@ const INBOUND_CONTACTS_LIMIT = 250;
|
|
|
15
21
|
*/
|
|
16
22
|
|
|
17
23
|
export function useInboundContact(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
variables: {
|
|
25
|
+
organizationId?: string | null;
|
|
26
|
+
inboundContactId?: string | null;
|
|
27
|
+
},
|
|
28
|
+
params: UseQueryParams = {},
|
|
23
29
|
) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
const cachedInboundContact = useReactiveInboundContactFragment(
|
|
31
|
+
variables.inboundContactId || '',
|
|
32
|
+
null,
|
|
33
|
+
);
|
|
34
|
+
const shouldFetchInboundContact =
|
|
35
|
+
!!variables.organizationId &&
|
|
36
|
+
!!variables.inboundContactId &&
|
|
37
|
+
!cachedInboundContact &&
|
|
38
|
+
!params.skip;
|
|
39
|
+
const { data, ...rest } = useQuery(inboundContactQry, {
|
|
40
|
+
...params,
|
|
41
|
+
variables,
|
|
42
|
+
skip: !shouldFetchInboundContact,
|
|
43
|
+
});
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
return {
|
|
46
|
+
inboundContact: cachedInboundContact || data?.inboundContact,
|
|
47
|
+
initialLoading: shouldFetchInboundContact && !data,
|
|
48
|
+
...rest,
|
|
49
|
+
};
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
/**
|
|
@@ -48,41 +54,43 @@ export function useInboundContact(
|
|
|
48
54
|
*/
|
|
49
55
|
|
|
50
56
|
export function useInboundContacts(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
variables: PaginationArgs & {
|
|
58
|
+
organizationId?: string | null;
|
|
59
|
+
filter?: unknown;
|
|
60
|
+
sort?: InboundContactsSortEnum | null;
|
|
61
|
+
},
|
|
62
|
+
params: UseQueryParams = {},
|
|
57
63
|
) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
const { filter: _filter, ...queryVariables } = variables;
|
|
65
|
+
const { data, ...rest } = useQuery(inboundContactsQry, {
|
|
66
|
+
...params,
|
|
67
|
+
variables: {
|
|
68
|
+
...queryVariables,
|
|
69
|
+
cursor: null,
|
|
70
|
+
after: true,
|
|
71
|
+
limit: INBOUND_CONTACTS_LIMIT,
|
|
72
|
+
},
|
|
73
|
+
skip: !variables.organizationId || params.skip,
|
|
74
|
+
});
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
return {
|
|
77
|
+
inboundContacts: data?.inboundContacts,
|
|
78
|
+
...rest,
|
|
79
|
+
};
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
/**
|
|
77
83
|
* Get reactive inbound contact fragment.
|
|
78
84
|
*/
|
|
79
85
|
|
|
80
|
-
export function useReactiveInboundContactFragment(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
export function useReactiveInboundContactFragment(
|
|
87
|
+
inboundContactId: string,
|
|
88
|
+
currentData?: any,
|
|
89
|
+
queryCount?: number,
|
|
90
|
+
) {
|
|
91
|
+
return useReactiveFragment(
|
|
92
|
+
currentData,
|
|
93
|
+
[makeFragmentKey(FRAGMENT_NAMES.inboundContact, inboundContactId)],
|
|
94
|
+
queryCount,
|
|
95
|
+
);
|
|
88
96
|
}
|
|
@@ -1,59 +1,77 @@
|
|
|
1
1
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
2
|
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
|
+
import {
|
|
4
|
+
FRAGMENT_NAMES,
|
|
5
|
+
makeFragmentKey,
|
|
6
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
3
7
|
import { updateFragment } from '../cache/index.ts';
|
|
4
8
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
createIntegrationAuthorizationUrlMtn,
|
|
10
|
+
disconnectIntegrationMtn,
|
|
7
11
|
} from '../gql/mutations/integrationMutations.ts';
|
|
8
12
|
import { useMutation } from './index.ts';
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* Create integration OAuth authorization URL.
|
|
12
16
|
*/
|
|
13
|
-
export function useCreateIntegrationAuthorizationUrl(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
export function useCreateIntegrationAuthorizationUrl(
|
|
18
|
+
params: UseMutationParams = {},
|
|
19
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
20
|
+
) {
|
|
21
|
+
const [createIntegrationAuthorizationUrl, mtnValues, mtnHandlers] =
|
|
22
|
+
useMutation(createIntegrationAuthorizationUrlMtn, {
|
|
23
|
+
openModalPopUp,
|
|
24
|
+
...params,
|
|
25
|
+
});
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
return {
|
|
28
|
+
createIntegrationAuthorizationUrl,
|
|
29
|
+
...mtnValues,
|
|
30
|
+
...mtnHandlers,
|
|
31
|
+
};
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
35
|
* Disconnect an integration.
|
|
28
36
|
*/
|
|
29
|
-
export function useDisconnectIntegration(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
export function useDisconnectIntegration(
|
|
38
|
+
params: UseMutationParams = {},
|
|
39
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
40
|
+
) {
|
|
41
|
+
const { onCompleted, ...otherParams } = params;
|
|
42
|
+
const [disconnectIntegration, mtnValues, mtnHandlers, updateObservers] =
|
|
43
|
+
useMutation(disconnectIntegrationMtn, {
|
|
44
|
+
openModalPopUp,
|
|
45
|
+
onCompleted: (data: any, error: any, variables: any) => {
|
|
46
|
+
const disconnectedIntegrationId = data?.disconnectIntegration;
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
if (disconnectedIntegrationId) {
|
|
49
|
+
const organizationFragmentKey = makeFragmentKey(
|
|
50
|
+
FRAGMENT_NAMES.organization,
|
|
51
|
+
variables.organizationId,
|
|
52
|
+
);
|
|
38
53
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
updateFragment(
|
|
55
|
+
makeFragmentKey(
|
|
56
|
+
FRAGMENT_NAMES.integrationConnection,
|
|
57
|
+
disconnectedIntegrationId,
|
|
58
|
+
),
|
|
59
|
+
{ status: 'DISCONNECTED' },
|
|
60
|
+
null,
|
|
61
|
+
false,
|
|
62
|
+
updateObservers,
|
|
63
|
+
[organizationFragmentKey],
|
|
64
|
+
);
|
|
65
|
+
}
|
|
48
66
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
onCompleted?.(disconnectedIntegrationId, error, variables);
|
|
68
|
+
},
|
|
69
|
+
...otherParams,
|
|
70
|
+
});
|
|
53
71
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
return {
|
|
73
|
+
disconnectIntegration,
|
|
74
|
+
...mtnValues,
|
|
75
|
+
...mtnHandlers,
|
|
76
|
+
};
|
|
59
77
|
}
|
|
@@ -1,15 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FRAGMENT_NAMES,
|
|
3
|
+
makeFragmentKey,
|
|
4
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
1
5
|
import { useReactiveFragment } from '../client/index.ts';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Get reactive integration connection fragment.
|
|
5
9
|
*/
|
|
6
|
-
export function useReactiveIntegrationConnection(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export function useReactiveIntegrationConnection(
|
|
11
|
+
integrationConnectionId?: string | null,
|
|
12
|
+
currentData?: any,
|
|
13
|
+
queryCount?: number,
|
|
14
|
+
) {
|
|
15
|
+
return useReactiveFragment(
|
|
16
|
+
currentData,
|
|
17
|
+
integrationConnectionId
|
|
18
|
+
? [
|
|
19
|
+
makeFragmentKey(
|
|
20
|
+
FRAGMENT_NAMES.integrationConnection,
|
|
21
|
+
integrationConnectionId,
|
|
22
|
+
),
|
|
23
|
+
]
|
|
24
|
+
: [],
|
|
25
|
+
queryCount,
|
|
26
|
+
undefined,
|
|
27
|
+
undefined,
|
|
28
|
+
true,
|
|
29
|
+
);
|
|
15
30
|
}
|
package/hooks/use-log-mtn.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { checkACLPermission } from '@jsb188/mday/utils/organization.ts';
|
|
2
2
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
3
3
|
import { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
4
|
+
import {
|
|
5
|
+
FRAGMENT_NAMES,
|
|
6
|
+
makeFragmentKey,
|
|
7
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
4
8
|
import { useMemo } from 'react';
|
|
5
9
|
import { updateFragment } from '../cache/index.ts';
|
|
6
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
deleteLogEntryMtn,
|
|
12
|
+
editLogEntryMtn,
|
|
13
|
+
} from '../gql/mutations/logMutations.ts';
|
|
7
14
|
import { useMutation } from './index.ts';
|
|
8
15
|
import { useReactiveLogFragment } from './use-log-qry.ts';
|
|
9
16
|
import { useOrgRelFromMyOrganizations } from './use-organization-qry.ts';
|
|
@@ -14,45 +21,46 @@ import { useOrgRelFromMyOrganizations } from './use-organization-qry.ts';
|
|
|
14
21
|
*/
|
|
15
22
|
|
|
16
23
|
export function useEditLogEntry(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
viewerAccountId: string,
|
|
25
|
+
logEntryId: string,
|
|
26
|
+
organizationId: string,
|
|
27
|
+
params: UseMutationParams = {},
|
|
28
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
22
29
|
) {
|
|
30
|
+
const { organizationRelationship } =
|
|
31
|
+
useOrgRelFromMyOrganizations(organizationId);
|
|
32
|
+
const notReady = !organizationRelationship;
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
const [editLogEntry, mtnValues, mtnHandlers] = useMutation(editLogEntryMtn, {
|
|
35
|
+
// checkMountedBeforeCallback: true,
|
|
36
|
+
openModalPopUp,
|
|
37
|
+
...params,
|
|
38
|
+
});
|
|
26
39
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
...params,
|
|
33
|
-
},
|
|
34
|
-
);
|
|
40
|
+
const logEntry = useReactiveLogFragment(
|
|
41
|
+
logEntryId,
|
|
42
|
+
null,
|
|
43
|
+
mtnValues.mutationCount,
|
|
44
|
+
);
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
const isMyDocument =
|
|
47
|
+
!!viewerAccountId && logEntry?.accountId === viewerAccountId;
|
|
48
|
+
const allowEdit = useMemo(() => {
|
|
49
|
+
return checkACLPermission(
|
|
50
|
+
organizationRelationship,
|
|
51
|
+
'logs',
|
|
52
|
+
isMyDocument ? 'WRITE' : 'MANAGE',
|
|
53
|
+
);
|
|
54
|
+
}, [organizationRelationship?.acl, organizationRelationship?.role]);
|
|
42
55
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
notReady,
|
|
52
|
-
allowEdit,
|
|
53
|
-
...mtnValues,
|
|
54
|
-
...mtnHandlers,
|
|
55
|
-
};
|
|
56
|
+
return {
|
|
57
|
+
logEntry,
|
|
58
|
+
editLogEntry,
|
|
59
|
+
notReady,
|
|
60
|
+
allowEdit,
|
|
61
|
+
...mtnValues,
|
|
62
|
+
...mtnHandlers,
|
|
63
|
+
};
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
/**
|
|
@@ -60,26 +68,34 @@ export function useEditLogEntry(
|
|
|
60
68
|
* NOTE: Don't check ACL and allow server to handle it.
|
|
61
69
|
*/
|
|
62
70
|
|
|
63
|
-
export function useDeleteLogEntry(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
export function useDeleteLogEntry(
|
|
72
|
+
params: UseMutationParams = {},
|
|
73
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
74
|
+
) {
|
|
75
|
+
const { onCompleted, ...rest } = params;
|
|
76
|
+
const [deleteLogEntry, mtnValues, mtnHandlers, updateObservers] = useMutation(
|
|
77
|
+
deleteLogEntryMtn,
|
|
78
|
+
{
|
|
79
|
+
openModalPopUp,
|
|
80
|
+
onCompleted: (data, dataMtnValues, variables) => {
|
|
81
|
+
if (data?.deleteLogEntry) {
|
|
82
|
+
updateFragment(
|
|
83
|
+
makeFragmentKey(FRAGMENT_NAMES.logEntry, variables.logEntryId),
|
|
84
|
+
{ __deleted: true },
|
|
85
|
+
null,
|
|
86
|
+
false,
|
|
87
|
+
updateObservers,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
onCompleted?.(data, dataMtnValues, variables);
|
|
91
|
+
},
|
|
92
|
+
...rest,
|
|
93
|
+
},
|
|
94
|
+
);
|
|
79
95
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
96
|
+
return {
|
|
97
|
+
deleteLogEntry,
|
|
98
|
+
...mtnValues,
|
|
99
|
+
...mtnHandlers,
|
|
100
|
+
};
|
|
85
101
|
}
|
package/hooks/use-log-qry.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
FilterLogEntriesArgs,
|
|
3
|
+
LogSortEnum,
|
|
4
|
+
} from '@jsb188/mday/types/log.d.ts';
|
|
5
|
+
import {
|
|
6
|
+
FRAGMENT_NAMES,
|
|
7
|
+
makeFragmentKey,
|
|
8
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
2
9
|
import { useQuery, useReactiveFragment } from '../client/index.ts';
|
|
3
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
logEntriesForFieldDocQry,
|
|
12
|
+
logEntriesQry,
|
|
13
|
+
logEntryQry,
|
|
14
|
+
} from '../gql/queries/logQueries.ts';
|
|
4
15
|
import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
5
16
|
|
|
6
17
|
/**
|
|
@@ -17,24 +28,31 @@ const LOG_ENTRIES_LIMIT = 250;
|
|
|
17
28
|
*/
|
|
18
29
|
|
|
19
30
|
export function useLogEntry(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
variables: {
|
|
32
|
+
organizationId?: string | null;
|
|
33
|
+
logEntryId?: string | null;
|
|
34
|
+
},
|
|
35
|
+
params: UseQueryParams = {},
|
|
25
36
|
) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
const { logEntryId, organizationId } = variables;
|
|
38
|
+
const { data, ...rest } = useQuery(logEntryQry, {
|
|
39
|
+
...params,
|
|
40
|
+
// A log can be changed outside the websocket mutation path, such as by a
|
|
41
|
+
// database repair. Revalidate it whenever the detail modal is opened.
|
|
42
|
+
persistTime: params.persistTime ?? 0,
|
|
43
|
+
variables,
|
|
44
|
+
skip: !organizationId || !logEntryId || params.skip,
|
|
45
|
+
});
|
|
46
|
+
const reactiveLogEntry = useReactiveLogFragment(
|
|
47
|
+
logEntryId || '',
|
|
48
|
+
data?.logEntry,
|
|
49
|
+
rest.updatedCount,
|
|
50
|
+
);
|
|
33
51
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
return {
|
|
53
|
+
logEntry: reactiveLogEntry || data?.logEntry,
|
|
54
|
+
...rest,
|
|
55
|
+
};
|
|
38
56
|
}
|
|
39
57
|
|
|
40
58
|
/**
|
|
@@ -42,70 +60,76 @@ export function useLogEntry(
|
|
|
42
60
|
*/
|
|
43
61
|
|
|
44
62
|
export function useLogEntries(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
variables: PaginationArgs & {
|
|
64
|
+
organizationId?: string | null;
|
|
65
|
+
accountId?: string;
|
|
66
|
+
filter: FilterLogEntriesArgs;
|
|
67
|
+
sort?: LogSortEnum;
|
|
68
|
+
},
|
|
69
|
+
params: UseQueryParams = {},
|
|
51
70
|
) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
const { data, ...rest } = useQuery(logEntriesQry, {
|
|
72
|
+
...params,
|
|
73
|
+
variables: {
|
|
74
|
+
...variables,
|
|
75
|
+
cursor: null,
|
|
76
|
+
after: true,
|
|
77
|
+
limit: variables.limit ?? LOG_ENTRIES_LIMIT,
|
|
78
|
+
},
|
|
79
|
+
// If this query is used for virtualized list pagination, set {params.skip=true}
|
|
80
|
+
skip: !variables.organizationId || params.skip,
|
|
81
|
+
});
|
|
63
82
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
83
|
+
return {
|
|
84
|
+
logEntries: data?.logEntries,
|
|
85
|
+
...rest,
|
|
86
|
+
};
|
|
68
87
|
}
|
|
69
88
|
|
|
70
89
|
/**
|
|
71
|
-
* Fetch all log entries for one
|
|
90
|
+
* Fetch all log entries for one fieldDoc source.
|
|
72
91
|
*/
|
|
73
92
|
|
|
74
|
-
export function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
93
|
+
export function useLogEntriesForFieldDoc(
|
|
94
|
+
variables: {
|
|
95
|
+
organizationId?: string | null;
|
|
96
|
+
fieldDocSourceId?: string | null;
|
|
97
|
+
fieldDocSubmissionId: string | null;
|
|
98
|
+
},
|
|
99
|
+
params: UseQueryParams = {},
|
|
81
100
|
) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
101
|
+
const { organizationId, fieldDocSourceId, fieldDocSubmissionId } = variables;
|
|
102
|
+
const { data, ...rest } = useQuery(logEntriesForFieldDocQry, {
|
|
103
|
+
...params,
|
|
104
|
+
variables,
|
|
105
|
+
skip:
|
|
106
|
+
!organizationId ||
|
|
107
|
+
!fieldDocSourceId ||
|
|
108
|
+
!fieldDocSubmissionId ||
|
|
109
|
+
params.skip,
|
|
110
|
+
});
|
|
88
111
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
112
|
+
return {
|
|
113
|
+
logEntriesForFieldDoc: data?.logEntriesForFieldDoc,
|
|
114
|
+
...rest,
|
|
115
|
+
};
|
|
93
116
|
}
|
|
94
117
|
|
|
95
118
|
/**
|
|
96
119
|
* Get reactive log fragment
|
|
97
120
|
*/
|
|
98
121
|
|
|
99
|
-
export function useReactiveLogFragment(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
122
|
+
export function useReactiveLogFragment(
|
|
123
|
+
logEntryId: string,
|
|
124
|
+
currentData?: any,
|
|
125
|
+
queryCount?: number,
|
|
126
|
+
) {
|
|
127
|
+
return useReactiveFragment(
|
|
128
|
+
currentData,
|
|
129
|
+
[
|
|
130
|
+
makeFragmentKey(FRAGMENT_NAMES.logEntry, logEntryId),
|
|
131
|
+
[makeFragmentKey(FRAGMENT_NAMES.logEntryDetails, logEntryId), 'details'],
|
|
132
|
+
],
|
|
133
|
+
queryCount,
|
|
134
|
+
);
|
|
111
135
|
}
|