@jsb188/graphql 1.1.8 → 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 +66 -42
- package/cache/index.test.ts +881 -0
- package/cache/index.ts +1815 -979
- 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 +4 -2
- 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 +973 -143
- package/client/sse-ticket.test.ts +26 -0
- package/deno.lock +170 -0
- package/deno.test.json +10 -0
- 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 +1 -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 +17 -0
- package/gql/fragments/billingFragments.ts +0 -11
- package/gql/fragments/campaignFragments.ts +277 -0
- package/gql/fragments/dataTableFragments.ts +102 -0
- package/gql/fragments/emailFragments.ts +36 -0
- package/gql/fragments/fieldDocFragments.ts +82 -0
- package/gql/fragments/inboundContactFragments.ts +15 -0
- package/gql/fragments/integrationFragments.ts +22 -0
- package/gql/fragments/logFragments.ts +33 -64
- package/gql/fragments/organizationFragments.ts +94 -21
- package/gql/fragments/scheduleFragments.ts +155 -0
- package/gql/fragments/sheetFragments.ts +675 -0
- package/gql/fragments/storageFragments.ts +21 -1
- package/gql/fragments/workflowFragments.ts +67 -0
- package/gql/mutations/accountMutations.ts +24 -4
- package/gql/mutations/agentDocMutations.ts +177 -0
- package/gql/mutations/agentMemoryMutations.ts +36 -0
- package/gql/mutations/aiChatMutations.ts +43 -3
- package/gql/mutations/authMutations.ts +160 -19
- package/gql/mutations/campaignMutations.ts +215 -0
- package/gql/mutations/dataTableMutations.ts +106 -0
- package/gql/mutations/fieldDocMutations.ts +24 -0
- package/gql/mutations/inboundContactMutations.ts +24 -0
- package/gql/mutations/index.ts +17 -8
- package/gql/mutations/integrationMutations.ts +25 -0
- package/gql/mutations/logMutations.ts +10 -19
- package/gql/mutations/organizationMutations.ts +160 -2
- package/gql/mutations/scheduleMutations.ts +423 -0
- package/gql/mutations/sheetMutations.ts +385 -0
- package/gql/mutations/storageMutations.ts +21 -2
- 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 +24 -1
- package/gql/queries/campaignQueries.ts +127 -0
- package/gql/queries/dataTableQueries.ts +134 -0
- package/gql/queries/emailQueries.ts +96 -0
- package/gql/queries/fieldDocQueries.ts +158 -0
- package/gql/queries/inboundContactQueries.ts +40 -0
- package/gql/queries/index.ts +17 -6
- package/gql/queries/logQueries.ts +42 -32
- package/gql/queries/organizationQueries.ts +113 -8
- package/gql/queries/scheduleQueries.ts +315 -0
- package/gql/queries/sheetQueries.ts +383 -0
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +99 -0
- package/hooks/index.ts +2104 -860
- package/hooks/use-account-mtn.ts +91 -48
- 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 +248 -97
- package/hooks/use-aiChat-qry.ts +501 -191
- package/hooks/use-app-qry.ts +14 -11
- package/hooks/use-auth-mtn.ts +410 -256
- 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 +170 -0
- package/hooks/use-dataTable-qry.ts +996 -0
- package/hooks/use-email-qry.ts +227 -0
- package/hooks/use-fieldDoc-mtn.ts +50 -0
- package/hooks/use-fieldDoc-qry.ts +180 -0
- package/hooks/use-inboundContact-mtn.ts +34 -0
- package/hooks/use-inboundContact-qry.ts +96 -0
- package/hooks/use-integration-mtn.ts +77 -0
- package/hooks/use-integration-qry.ts +30 -0
- package/hooks/use-log-mtn.ts +77 -61
- package/hooks/use-log-qry.ts +99 -72
- package/hooks/use-organization-mtn.ts +409 -80
- package/hooks/use-organization-qry.ts +211 -92
- package/hooks/use-schedule-mtn.ts +416 -0
- package/hooks/use-schedule-qry.ts +157 -0
- package/hooks/use-sheet-mtn.ts +367 -0
- package/hooks/use-sheet-qry.ts +440 -0
- package/hooks/use-storage-mtn.ts +83 -42
- package/hooks/use-storage-qry.ts +104 -13
- package/hooks/use-workflow-mtn.ts +55 -0
- package/hooks/use-workflow-qry.ts +230 -0
- package/loaders/campaign.ts +137 -0
- package/package.json +94 -52
- package/sse.ts +158 -105
- package/tsconfig.json +13 -0
- package/types.d.ts +60 -29
- package/utils.ts +77 -50
- package/gql/fragments/actionFragments.ts +0 -16
- package/gql/fragments/productFragments.ts +0 -63
- package/gql/fragments/reportFragments.ts +0 -48
- package/gql/mutations/billingMutations.ts +0 -34
- package/gql/queries/productQueries.ts +0 -70
- package/gql/queries/reportQueries.ts +0 -66
- package/hooks/use-product-qry.ts +0 -109
- package/hooks/use-report-qry.ts +0 -69
package/hooks/use-log-mtn.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { checkACLPermission } from '@jsb188/mday/utils/organization';
|
|
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
|
-
import { updateFragment } from '../cache/index';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
import { updateFragment } from '../cache/index.ts';
|
|
10
|
+
import {
|
|
11
|
+
deleteLogEntryMtn,
|
|
12
|
+
editLogEntryMtn,
|
|
13
|
+
} from '../gql/mutations/logMutations.ts';
|
|
14
|
+
import { useMutation } from './index.ts';
|
|
15
|
+
import { useReactiveLogFragment } from './use-log-qry.ts';
|
|
16
|
+
import { useOrgRelFromMyOrganizations } from './use-organization-qry.ts';
|
|
10
17
|
|
|
11
18
|
/**
|
|
12
19
|
* Fetch a single log entry,
|
|
@@ -14,45 +21,46 @@ import { useOrgRelFromMyOrganizations } from './use-organization-qry';
|
|
|
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,7 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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';
|
|
9
|
+
import { useQuery, useReactiveFragment } from '../client/index.ts';
|
|
10
|
+
import {
|
|
11
|
+
logEntriesForFieldDocQry,
|
|
12
|
+
logEntriesQry,
|
|
13
|
+
logEntryQry,
|
|
14
|
+
} from '../gql/queries/logQueries.ts';
|
|
15
|
+
import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
5
16
|
|
|
6
17
|
/**
|
|
7
18
|
* Constants
|
|
@@ -13,17 +24,35 @@ import type { PaginationArgs, UseQueryParams } from '../types';
|
|
|
13
24
|
const LOG_ENTRIES_LIMIT = 250;
|
|
14
25
|
|
|
15
26
|
/**
|
|
16
|
-
*
|
|
27
|
+
* Fetch one log entry.
|
|
17
28
|
*/
|
|
18
29
|
|
|
19
|
-
export function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
export function useLogEntry(
|
|
31
|
+
variables: {
|
|
32
|
+
organizationId?: string | null;
|
|
33
|
+
logEntryId?: string | null;
|
|
34
|
+
},
|
|
35
|
+
params: UseQueryParams = {},
|
|
36
|
+
) {
|
|
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
|
+
);
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
logEntry: reactiveLogEntry || data?.logEntry,
|
|
54
|
+
...rest,
|
|
55
|
+
};
|
|
27
56
|
}
|
|
28
57
|
|
|
29
58
|
/**
|
|
@@ -31,78 +60,76 @@ export function getDefaultLogEntriesFilter(operation: FilterLogEntriesArgs['oper
|
|
|
31
60
|
*/
|
|
32
61
|
|
|
33
62
|
export function useLogEntries(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
63
|
+
variables: PaginationArgs & {
|
|
64
|
+
organizationId?: string | null;
|
|
65
|
+
accountId?: string;
|
|
66
|
+
filter: FilterLogEntriesArgs;
|
|
67
|
+
sort?: LogSortEnum;
|
|
68
|
+
},
|
|
69
|
+
params: UseQueryParams = {},
|
|
41
70
|
) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
});
|
|
53
82
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
83
|
+
return {
|
|
84
|
+
logEntries: data?.logEntries,
|
|
85
|
+
...rest,
|
|
86
|
+
};
|
|
58
87
|
}
|
|
59
88
|
|
|
60
89
|
/**
|
|
61
|
-
* Fetch
|
|
90
|
+
* Fetch all log entries for one fieldDoc source.
|
|
62
91
|
*/
|
|
63
92
|
|
|
64
|
-
export function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
params: UseQueryParams = {}
|
|
93
|
+
export function useLogEntriesForFieldDoc(
|
|
94
|
+
variables: {
|
|
95
|
+
organizationId?: string | null;
|
|
96
|
+
fieldDocSourceId?: string | null;
|
|
97
|
+
fieldDocSubmissionId: string | null;
|
|
98
|
+
},
|
|
99
|
+
params: UseQueryParams = {},
|
|
73
100
|
) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
});
|
|
83
111
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
112
|
+
return {
|
|
113
|
+
logEntriesForFieldDoc: data?.logEntriesForFieldDoc,
|
|
114
|
+
...rest,
|
|
115
|
+
};
|
|
88
116
|
}
|
|
89
117
|
|
|
90
118
|
/**
|
|
91
119
|
* Get reactive log fragment
|
|
92
120
|
*/
|
|
93
121
|
|
|
94
|
-
export function useReactiveLogFragment(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
);
|
|
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
|
+
);
|
|
108
135
|
}
|