@jsb188/graphql 1.1.11 → 1.1.13
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/LICENSE +21 -0
- package/audience.d.ts +205 -0
- package/cache/config.ts +65 -28
- package/cache/index.helpers.ts +96 -0
- package/cache/index.ts +364 -808
- package/cache/mounted-queries.ts +33 -0
- package/cache/optimistic-ui-runtime.ts +46 -0
- package/cache/optimistic-ui.ts +401 -0
- package/cache/persist.ts +107 -22
- package/cache/realtime-fence.ts +47 -0
- package/cache/realtime-live.ts +17 -0
- package/cache/store.ts +22 -64
- package/cache/value.helpers.ts +17 -0
- package/{drafts/store.ts → client/draft-persistence-indexed-db.ts} +19 -3
- package/{drafts/index.ts → client/draft-persistence.ts} +13 -39
- package/client/index.ts +4 -2
- package/client/request.helpers.ts +14 -0
- package/client/request.ts +122 -232
- package/client/storage-asset.ts +58 -0
- package/gql/fragments/accountAuthFragments.ts +0 -4
- package/gql/fragments/agentMemoryFragments.ts +5 -1
- package/gql/fragments/agentNoteFragments.ts +156 -0
- package/gql/fragments/aiChatFragments.ts +35 -11
- package/gql/fragments/aiChatLinkFragments.ts +8 -0
- package/gql/fragments/audienceFragments.ts +76 -0
- package/gql/fragments/dataTableFragments.ts +48 -80
- package/gql/fragments/emailFragments.ts +49 -21
- package/gql/fragments/emailOutreachFragments.ts +281 -0
- package/gql/fragments/fieldDocFragments.ts +222 -40
- package/gql/fragments/inboundContactFragments.ts +2 -0
- package/gql/fragments/libraryFragments.ts +120 -0
- package/gql/fragments/logFragments.ts +93 -2
- package/gql/fragments/organizationFragments.ts +12 -0
- package/gql/fragments/qrCodeFragments.ts +29 -0
- package/gql/fragments/scheduleFragments.ts +574 -145
- package/gql/fragments/sheetFragments.ts +86 -424
- package/gql/fragments/storageFragments.ts +25 -1
- package/gql/fragments/workWaitFragments.ts +13 -0
- package/gql/fragments/workflowFragments.ts +32 -4
- package/gql/mutations/agentMemoryMutations.ts +32 -0
- package/gql/mutations/agentNoteMutations.ts +64 -0
- package/gql/mutations/aiChatLinkMutations.ts +13 -0
- package/gql/mutations/aiChatMutations.ts +34 -4
- package/gql/mutations/audienceMutations.ts +58 -0
- package/gql/mutations/authMutations.ts +24 -28
- package/gql/mutations/billingMutations.ts +24 -0
- package/gql/mutations/contactMutations.ts +23 -0
- package/gql/mutations/dataTableMutations.ts +18 -75
- package/gql/mutations/emailMutations.ts +22 -0
- package/gql/mutations/emailOutreachMutations.ts +139 -0
- package/gql/mutations/fieldDocMutations.ts +162 -13
- package/gql/mutations/index.ts +10 -5
- package/gql/mutations/organizationMutations.ts +6 -0
- package/gql/mutations/qrCodeMutations.ts +20 -0
- package/gql/mutations/scheduleMutations.ts +389 -417
- package/gql/mutations/sheetMutations.ts +62 -118
- package/gql/mutations/storageMutations.ts +1 -1
- package/gql/mutations/workflowMutations.ts +94 -0
- package/gql/queries/agentMemoryQueries.ts +12 -2
- package/gql/queries/agentNoteQueries.ts +86 -0
- package/gql/queries/aiChatQueries.ts +63 -12
- package/gql/queries/audienceQueries.ts +104 -0
- package/gql/queries/authQueries.ts +20 -4
- package/gql/queries/billingQueries.ts +114 -9
- package/gql/queries/dataTableQueries.ts +43 -75
- package/gql/queries/emailOutreachQueries.ts +282 -0
- package/gql/queries/emailQueries.ts +48 -64
- package/gql/queries/emailReplyReportQueries.ts +127 -0
- package/gql/queries/fieldDocQueries.ts +128 -98
- package/gql/queries/inboundContactQueries.ts +15 -4
- package/gql/queries/index.ts +5 -3
- package/gql/queries/libraryQueries.ts +112 -0
- package/gql/queries/logQueries.ts +86 -12
- package/gql/queries/organizationQueries.ts +44 -12
- package/gql/queries/qrCodeQueries.ts +27 -0
- package/gql/queries/scheduleQueries.ts +401 -278
- package/gql/queries/sheetQueries.ts +94 -165
- package/gql/queries/storageQueries.ts +11 -4
- package/gql/queries/workflowQueries.ts +61 -12
- package/gql/reactivity.ts +98 -0
- package/gql/recordReads.ts +171 -0
- package/hooks/index.helpers.ts +52 -0
- package/hooks/index.ts +920 -715
- package/hooks/use-agentMemory-mtn.ts +29 -31
- package/hooks/use-agentMemory-qry.ts +15 -3
- package/hooks/use-agentNote-mtn.ts +89 -0
- package/hooks/use-agentNote-qry.ts +162 -0
- package/hooks/use-agentNote-recovery.helpers.ts +58 -0
- package/hooks/use-agentNote-recovery.ts +57 -0
- package/hooks/use-aiChat-mtn.ts +104 -115
- package/hooks/use-aiChat-qry.helpers.ts +124 -0
- package/hooks/use-aiChat-qry.ts +254 -387
- package/hooks/use-aiChat-stream-mtn.ts +14 -0
- package/hooks/use-audience-mtn.ts +170 -0
- package/hooks/use-audience-qry.helpers.ts +39 -0
- package/hooks/use-audience-qry.ts +245 -0
- package/hooks/use-auth-mtn.ts +30 -1
- package/hooks/use-billing-mtn.ts +31 -0
- package/hooks/use-billing-qry.ts +76 -0
- package/hooks/use-dataTable-mtn.ts +23 -115
- package/hooks/use-dataTable-qry.ts +69 -914
- package/hooks/use-email-mtn.ts +26 -0
- package/hooks/use-email-qry.helpers.ts +37 -0
- package/hooks/use-email-qry.ts +44 -174
- package/hooks/use-emailOutreach-mtn.ts +211 -0
- package/hooks/use-emailOutreach-qry.helpers.ts +25 -0
- package/hooks/use-emailOutreach-qry.ts +367 -0
- package/hooks/use-emailOutreachReplyReport-qry.ts +46 -0
- package/hooks/use-fieldDoc-mtn.ts +244 -32
- package/hooks/use-fieldDoc-qry.helpers.ts +49 -0
- package/hooks/use-fieldDoc-qry.ts +134 -102
- package/hooks/use-inboundContact-qry.ts +7 -9
- package/hooks/use-library-qry.ts +233 -0
- package/hooks/use-log-mtn.ts +25 -12
- package/hooks/use-log-qry.ts +99 -46
- package/hooks/use-organization-qry.ts +16 -60
- package/hooks/use-qrCode-mtn.ts +40 -0
- package/hooks/use-qrCode-qry.ts +78 -0
- package/hooks/use-schedule-mtn.ts +231 -348
- package/hooks/use-schedule-qry.ts +208 -139
- package/hooks/use-schedule-reactive.ts +218 -0
- package/hooks/use-sheet-mtn.ts +91 -199
- package/hooks/use-sheet-qry.ts +88 -237
- package/hooks/use-storage-qry.ts +84 -61
- package/hooks/use-workflow-mtn.ts +84 -23
- package/hooks/use-workflow-qry.ts +60 -61
- package/libs/ai-chat-link-events.ts +78 -0
- 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/data-changes.helpers.ts +161 -0
- package/libs/data-changes.ts +382 -0
- package/libs/fragment-realtime-sequence.ts +55 -0
- package/libs/open-sheet.ts +138 -0
- package/libs/record-read.ts +327 -0
- package/libs/sheet-command-batch.ts +45 -0
- package/libs/sheet-realtime-packet.ts +53 -0
- package/libs/sheet-view-realtime-router.ts +99 -0
- package/loaders/emailPreference.ts +69 -0
- package/loaders/rest.ts +12 -0
- package/package.json +77 -25
- package/schedule.d.ts +1183 -0
- package/sse.helpers.ts +19 -0
- package/sse.ts +26 -115
- package/types.d.ts +48 -25
- package/cache/index.test.ts +0 -881
- package/client/data-table-realtime-subscriptions.test.ts +0 -740
- package/client/data-table-realtime-subscriptions.ts +0 -955
- package/client/data-table-realtime.test.ts +0 -792
- package/client/data-table-realtime.ts +0 -1218
- package/client/fragment-realtime-sequence.ts +0 -52
- package/client/open-sheet.ts +0 -137
- package/client/request-managed-session.test.ts +0 -574
- package/client/request-no-store.test.ts +0 -157
- package/client/sse-ticket.test.ts +0 -26
- package/deno.lock +0 -170
- package/deno.test.json +0 -10
- package/gql/fragments/agentDocFragments.ts +0 -46
- package/gql/fragments/billingFragments.ts +0 -14
- package/gql/fragments/campaignFragments.ts +0 -277
- package/gql/mutations/agentDocMutations.ts +0 -177
- package/gql/mutations/campaignMutations.ts +0 -215
- package/gql/queries/agentDocQueries.ts +0 -120
- package/gql/queries/appQueries.ts +0 -14
- package/gql/queries/campaignQueries.ts +0 -127
- package/hooks/use-agentDoc-mtn.ts +0 -285
- package/hooks/use-agentDoc-qry.ts +0 -208
- package/hooks/use-app-qry.ts +0 -22
- package/hooks/use-campaign-mtn.ts +0 -377
- package/hooks/use-campaign-qry.ts +0 -257
- package/loaders/campaign.ts +0 -137
- package/tsconfig.json +0 -13
package/sse.helpers.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Compare decimal database revisions without losing bigint precision. Legacy
|
|
3
|
+
* unversioned events remain supported during the fleet transition.
|
|
4
|
+
*/
|
|
5
|
+
export function isOlderChatCheckpoint(current: any, incoming: any) {
|
|
6
|
+
const before = String(current?.revision ?? '');
|
|
7
|
+
const after = String(incoming?.revision ?? '');
|
|
8
|
+
if (!/^\d+$/.test(before) || !/^\d+$/.test(after)) return false;
|
|
9
|
+
if (BigInt(after) !== BigInt(before)) return BigInt(after) < BigInt(before);
|
|
10
|
+
|
|
11
|
+
// A terminal run can settle its final checkpoint before cleanup increments
|
|
12
|
+
// the stored row revision. That settled state wins an equal-revision tie.
|
|
13
|
+
const settled =
|
|
14
|
+
current?.finished === true ||
|
|
15
|
+
['COMPLETED', 'INCOMPLETE'].includes(current?.generationStatus);
|
|
16
|
+
const streaming =
|
|
17
|
+
incoming?.finished === false || incoming?.generationStatus === 'STREAMING';
|
|
18
|
+
return settled && streaming;
|
|
19
|
+
}
|
package/sse.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
addFragmentToCache,
|
|
3
|
-
updateFragment,
|
|
4
|
-
updateQuery,
|
|
5
|
-
} from './cache/index.ts';
|
|
1
|
+
import { addFragmentToCache, loadFragment, updateFragment, updateQuery } from './cache/index.ts';
|
|
6
2
|
import type { UpdateObserversFn } from './types.d.ts';
|
|
3
|
+
import { FRAGMENT_NAMES } from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
4
|
+
import { isOlderChatCheckpoint } from './sse.helpers.ts';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Types
|
|
@@ -12,12 +10,10 @@ import type { UpdateObserversFn } from './types.d.ts';
|
|
|
12
10
|
type ValidSSEType =
|
|
13
11
|
// Default SSE events
|
|
14
12
|
| 'CONNECTED'
|
|
15
|
-
|
|
13
|
+
| 'CHAT_RUN_STATUS'
|
|
14
|
+
| 'CHAT_RUN_UPDATE'
|
|
15
|
+
// Durable chat checkpoints append a new message or replace an existing one
|
|
16
16
|
| 'QUERY_APPEND'
|
|
17
|
-
| 'QUERY_PREPEND'
|
|
18
|
-
// Fragment handlers
|
|
19
|
-
| 'DATA_APPEND'
|
|
20
|
-
| 'DATA_PREPEND'
|
|
21
17
|
| 'DATA_UPDATE';
|
|
22
18
|
|
|
23
19
|
export interface PublishPayload {
|
|
@@ -26,28 +22,25 @@ export interface PublishPayload {
|
|
|
26
22
|
fragmentNamespace?: string;
|
|
27
23
|
dataFragmentKey?: string;
|
|
28
24
|
data: Record<string, any>;
|
|
29
|
-
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Ignore an older full checkpoint from an overlapping reconnect before it
|
|
29
|
+
* changes either the normalized cache or the chat's local streaming state.
|
|
30
|
+
*/
|
|
31
|
+
export function isStaleSSECheckpoint(payload: PublishPayload) {
|
|
32
|
+
const key = payload.dataFragmentKey || payload.fragmentKey;
|
|
33
|
+
return !!key?.startsWith(FRAGMENT_NAMES.aiChatMessage + ':') && isOlderChatCheckpoint(loadFragment(key), payload.data);
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
|
-
* Append
|
|
37
|
+
* Append data to a query
|
|
34
38
|
*/
|
|
35
39
|
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
updateObservers?: UpdateObserversFn,
|
|
39
|
-
) {
|
|
40
|
-
const {
|
|
41
|
-
__type,
|
|
42
|
-
fragmentKey,
|
|
43
|
-
fragmentNamespace,
|
|
44
|
-
dataFragmentKey,
|
|
45
|
-
data,
|
|
46
|
-
otherData,
|
|
47
|
-
} = payload;
|
|
40
|
+
function handleQueryAppend(payload: PublishPayload, updateObservers?: UpdateObserversFn) {
|
|
41
|
+
const { fragmentKey, fragmentNamespace, dataFragmentKey, data } = payload;
|
|
48
42
|
|
|
49
43
|
if (fragmentKey && fragmentNamespace && dataFragmentKey && data) {
|
|
50
|
-
const isAppend = __type === 'QUERY_APPEND';
|
|
51
44
|
addFragmentToCache(dataFragmentKey, data);
|
|
52
45
|
|
|
53
46
|
const updateData = (currentData: any) => {
|
|
@@ -57,108 +50,32 @@ function handleQueryConcat(
|
|
|
57
50
|
Array.isArray(currentList) &&
|
|
58
51
|
!currentList.find((a) => a[0] === dataFragmentKey)
|
|
59
52
|
) {
|
|
60
|
-
const updatedList = isAppend
|
|
61
|
-
? [...currentList, [dataFragmentKey]]
|
|
62
|
-
: [[dataFragmentKey], ...currentList];
|
|
63
|
-
|
|
64
|
-
// console.log('UPDATED !!!!')
|
|
65
|
-
// console.log('UPDATED !!!!')
|
|
66
|
-
// console.log('UPDATED !!!!')
|
|
67
|
-
// console.log('UPDATED !!!!')
|
|
68
|
-
// console.log(fragmentNamespace, {
|
|
69
|
-
// ...currentData?.[fragmentNamespace],
|
|
70
|
-
// data: updatedList
|
|
71
|
-
// });
|
|
72
|
-
|
|
73
53
|
return {
|
|
74
54
|
...currentData,
|
|
75
|
-
...otherData,
|
|
76
55
|
[fragmentNamespace]: {
|
|
77
56
|
...currentData?.[fragmentNamespace],
|
|
78
|
-
data:
|
|
57
|
+
data: [...currentList, [dataFragmentKey]],
|
|
79
58
|
},
|
|
80
59
|
};
|
|
81
60
|
}
|
|
82
61
|
return currentData;
|
|
83
62
|
};
|
|
84
63
|
|
|
85
|
-
updateQuery(fragmentKey, updateData,
|
|
64
|
+
updateQuery(fragmentKey, updateData, true);
|
|
65
|
+
updateObservers?.({ queryId: fragmentKey, fragmentIds: [dataFragmentKey] });
|
|
86
66
|
}
|
|
87
67
|
|
|
88
68
|
return null;
|
|
89
69
|
}
|
|
90
70
|
|
|
91
|
-
/**
|
|
92
|
-
* Append or prepend data to a fragment
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
function handleFragmentConcat(
|
|
96
|
-
payload: PublishPayload,
|
|
97
|
-
updateObservers?: UpdateObserversFn,
|
|
98
|
-
) {
|
|
99
|
-
const { __type, fragmentKey, fragmentNamespace, data, otherData } = payload;
|
|
100
|
-
const isAppend = __type === 'DATA_APPEND';
|
|
101
|
-
|
|
102
|
-
if (fragmentKey && fragmentNamespace && data) {
|
|
103
|
-
const namespaceType = typeof fragmentNamespace;
|
|
104
|
-
const seedData = {
|
|
105
|
-
...(otherData && typeof otherData === 'object' ? otherData : {}),
|
|
106
|
-
[fragmentNamespace]: data,
|
|
107
|
-
};
|
|
108
|
-
const updateData = (currentData: any) => {
|
|
109
|
-
if (typeof currentData[fragmentNamespace] === namespaceType) {
|
|
110
|
-
let nextValue;
|
|
111
|
-
if (namespaceType === 'string') {
|
|
112
|
-
nextValue = isAppend
|
|
113
|
-
? `${currentData[fragmentNamespace]}${data}`
|
|
114
|
-
: `${data}${currentData[fragmentNamespace]}`;
|
|
115
|
-
} else if (Array.isArray(currentData[fragmentNamespace])) {
|
|
116
|
-
nextValue = isAppend
|
|
117
|
-
? [...currentData[fragmentNamespace], data]
|
|
118
|
-
: [data, ...currentData[fragmentNamespace]];
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
...currentData,
|
|
122
|
-
...otherData,
|
|
123
|
-
[fragmentNamespace]: nextValue,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return currentData;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const updateFragmentKey = updateFragment(
|
|
130
|
-
fragmentKey,
|
|
131
|
-
updateData,
|
|
132
|
-
null,
|
|
133
|
-
false,
|
|
134
|
-
updateObservers,
|
|
135
|
-
);
|
|
136
|
-
if (!updateFragmentKey) {
|
|
137
|
-
addFragmentToCache(fragmentKey, seedData);
|
|
138
|
-
updateObservers?.({
|
|
139
|
-
fragmentIds: [fragmentKey],
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
71
|
/**
|
|
146
72
|
* Update data in a fragment
|
|
147
73
|
*/
|
|
148
74
|
|
|
149
|
-
function handleFragmentUpdate(
|
|
150
|
-
payload: PublishPayload,
|
|
151
|
-
updateObservers?: UpdateObserversFn,
|
|
152
|
-
) {
|
|
75
|
+
function handleFragmentUpdate(payload: PublishPayload, updateObservers?: UpdateObserversFn) {
|
|
153
76
|
const { fragmentKey, dataFragmentKey, data } = payload;
|
|
154
77
|
const updateFragmentKey = dataFragmentKey || fragmentKey;
|
|
155
|
-
const updatedFragmentKey = updateFragment(
|
|
156
|
-
updateFragmentKey,
|
|
157
|
-
data,
|
|
158
|
-
null,
|
|
159
|
-
false,
|
|
160
|
-
updateObservers,
|
|
161
|
-
);
|
|
78
|
+
const updatedFragmentKey = updateFragment(updateFragmentKey, data, null, false, updateObservers);
|
|
162
79
|
if (!updatedFragmentKey) {
|
|
163
80
|
addFragmentToCache(updateFragmentKey, data);
|
|
164
81
|
updateObservers?.({
|
|
@@ -171,20 +88,14 @@ function handleFragmentUpdate(
|
|
|
171
88
|
* Data handler for SSE
|
|
172
89
|
*/
|
|
173
90
|
|
|
174
|
-
function handleSSEData(
|
|
175
|
-
payload
|
|
176
|
-
updateObservers?: UpdateObserversFn,
|
|
177
|
-
) {
|
|
91
|
+
function handleSSEData(payload: PublishPayload, updateObservers?: UpdateObserversFn) {
|
|
92
|
+
if (isStaleSSECheckpoint(payload)) return;
|
|
178
93
|
switch (payload.__type) {
|
|
179
94
|
case 'CONNECTED':
|
|
180
95
|
// Do nothing
|
|
181
96
|
break;
|
|
182
97
|
case 'QUERY_APPEND':
|
|
183
|
-
|
|
184
|
-
return handleQueryConcat(payload, updateObservers);
|
|
185
|
-
case 'DATA_APPEND':
|
|
186
|
-
case 'DATA_PREPEND':
|
|
187
|
-
return handleFragmentConcat(payload, updateObservers);
|
|
98
|
+
return handleQueryAppend(payload, updateObservers);
|
|
188
99
|
case 'DATA_UPDATE':
|
|
189
100
|
return handleFragmentUpdate(payload, updateObservers);
|
|
190
101
|
default:
|
package/types.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ServerErrorObj,
|
|
3
|
-
SimpleErrorType,
|
|
4
|
-
} from '@jsb188/app/types/app.d.ts';
|
|
1
|
+
import type { ServerErrorObj, SimpleErrorType } from '@jsb188/app/types/app.d.ts';
|
|
5
2
|
import type { QueryResetTarget } from '@jsb188/app/utils/queryReset.ts';
|
|
6
3
|
|
|
7
4
|
/**
|
|
@@ -29,6 +26,8 @@ export interface UpdateDataObserverArgs {
|
|
|
29
26
|
fragmentIds?: (string | null)[];
|
|
30
27
|
forceRefetch?: boolean;
|
|
31
28
|
resetOnly?: boolean;
|
|
29
|
+
// With resetOnly: this tab's own request caused the reset, so a mounted result refetches instead of showing the notice
|
|
30
|
+
selfRefresh?: boolean;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/**
|
|
@@ -37,15 +36,38 @@ export interface UpdateDataObserverArgs {
|
|
|
37
36
|
|
|
38
37
|
export type AnyModalPopUpFn = (data: any, err?: ServerErrorObj) => void;
|
|
39
38
|
export type UpdateObserversFn = (args: UpdateDataObserverArgs) => void;
|
|
40
|
-
export type OnCompletedGQLFn = (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
export type OnCompletedGQLFn = (data: any, error: ServerErrorObj | null, variables?: any) => void;
|
|
40
|
+
export type OnErrorGQLFn = (error: ServerErrorObj | null, variables: any) => void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Optimistically patch one existing normalized fragment before a mutation.
|
|
44
|
+
*/
|
|
45
|
+
export interface OptimisticUIUpdateOperation {
|
|
46
|
+
action: 'update';
|
|
47
|
+
fragmentKey: string;
|
|
48
|
+
update: Record<string, any> | ((fragment: any) => Record<string, any> | null | undefined);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Insert one temporary object into a top-level fragment collection.
|
|
53
|
+
*/
|
|
54
|
+
export interface OptimisticUICreatePlaceholderOperation {
|
|
55
|
+
action: 'create-placeholder';
|
|
56
|
+
parentFragmentKey: string;
|
|
57
|
+
field: string;
|
|
58
|
+
data: Record<string, any>;
|
|
59
|
+
position?: 'start' | 'end';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Describe one cache operation performed before a GraphQL mutation settles.
|
|
64
|
+
*/
|
|
65
|
+
export type OptimisticUIOperation = OptimisticUIUpdateOperation | OptimisticUICreatePlaceholderOperation;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Accept one optimistic cache operation or one atomic list of operations.
|
|
69
|
+
*/
|
|
70
|
+
export type OptimisticUI = OptimisticUIOperation | readonly OptimisticUIOperation[];
|
|
49
71
|
|
|
50
72
|
/**
|
|
51
73
|
* GraphQL query hook params
|
|
@@ -58,29 +80,30 @@ export interface GraphQLQueryOptions {
|
|
|
58
80
|
retryCount?: number;
|
|
59
81
|
rejectedResultRetryCount?: number;
|
|
60
82
|
retryTransientErrors?: boolean;
|
|
83
|
+
// Optional network deadline; releases a hung query's shared in-flight slot.
|
|
84
|
+
requestTimeoutMs?: number;
|
|
61
85
|
variables?: Record<string, any> | null;
|
|
62
86
|
cacheMap?: any;
|
|
63
87
|
skip?: boolean;
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
|
|
88
|
+
// Revalidate cached data once on mount, query-scope change, or skip -> active.
|
|
89
|
+
// Defaults to true. False retains freshness-window checks for this query.
|
|
90
|
+
// Cached data still renders immediately; an active "new data" notice stays deferred.
|
|
91
|
+
revalidateOnMount?: boolean;
|
|
92
|
+
// Freshness window in ms for cache-age checks, including entry when
|
|
93
|
+
// revalidateOnMount is false. Does not control IndexedDB retention.
|
|
94
|
+
// Defaults to the query's QUERY_EXPIRE_TIMES entry.
|
|
68
95
|
persistTime?: number;
|
|
69
96
|
testMode?: boolean;
|
|
70
97
|
openModalPopUp?: AnyModalPopUpFn | null;
|
|
71
98
|
onCompleted?: OnCompletedGQLFn;
|
|
72
99
|
onError?: OnErrorGQLFn;
|
|
73
|
-
shouldAcceptResult?: (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
) => boolean;
|
|
100
|
+
shouldAcceptResult?: (data: any, variables?: Record<string, any> | null) => boolean;
|
|
101
|
+
// Reject snapshots invalidated during their request before they normalize shared fragments.
|
|
102
|
+
rejectInvalidatedResults?: boolean;
|
|
77
103
|
}
|
|
78
104
|
|
|
79
105
|
// Params for most GraphQL (query) hooks
|
|
80
|
-
export type UseQueryParams = Omit<
|
|
81
|
-
GraphQLQueryOptions,
|
|
82
|
-
'name' | 'retryCount' | 'cacheMap'
|
|
83
|
-
>;
|
|
106
|
+
export type UseQueryParams = Omit<GraphQLQueryOptions, 'name' | 'retryCount' | 'cacheMap'>;
|
|
84
107
|
|
|
85
108
|
// Params for most GraphQL (mutation) hooks
|
|
86
109
|
export type UseMutationParams = Partial<{
|