@jsb188/graphql 1.1.12 → 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 +14 -152
- package/cache/config.ts +35 -32
- package/cache/index.helpers.ts +1 -1
- package/cache/index.ts +73 -44
- package/cache/mounted-queries.ts +33 -0
- package/cache/persist.ts +10 -4
- package/cache/realtime-fence.ts +47 -0
- package/cache/realtime-live.ts +17 -0
- package/client/draft-persistence.ts +10 -39
- package/client/index.ts +2 -1
- package/client/request.ts +9 -34
- package/client/storage-asset.ts +58 -0
- package/gql/fragments/accountAuthFragments.ts +0 -4
- package/gql/fragments/agentNoteFragments.ts +8 -2
- package/gql/fragments/aiChatFragments.ts +0 -2
- package/gql/fragments/aiChatLinkFragments.ts +8 -0
- package/gql/fragments/audienceFragments.ts +1 -66
- package/gql/fragments/emailFragments.ts +27 -4
- package/gql/fragments/emailOutreachFragments.ts +281 -0
- package/gql/fragments/inboundContactFragments.ts +1 -1
- package/gql/fragments/libraryFragments.ts +120 -0
- package/gql/fragments/organizationFragments.ts +4 -2
- package/gql/fragments/scheduleFragments.ts +241 -324
- package/gql/fragments/sheetFragments.ts +4 -53
- package/gql/fragments/workWaitFragments.ts +13 -0
- package/gql/fragments/workflowFragments.ts +20 -4
- package/gql/mutations/agentNoteMutations.ts +2 -0
- package/gql/mutations/aiChatLinkMutations.ts +13 -0
- package/gql/mutations/aiChatMutations.ts +4 -6
- package/gql/mutations/audienceMutations.ts +0 -13
- package/gql/mutations/authMutations.ts +12 -60
- package/gql/mutations/emailMutations.ts +22 -0
- package/gql/mutations/emailOutreachMutations.ts +139 -0
- package/gql/mutations/index.ts +3 -1
- package/gql/mutations/organizationMutations.ts +2 -2
- package/gql/mutations/scheduleMutations.ts +61 -787
- package/gql/mutations/storageMutations.ts +1 -0
- package/gql/mutations/workflowMutations.ts +76 -0
- package/gql/queries/agentMemoryQueries.ts +6 -2
- package/gql/queries/agentNoteQueries.ts +26 -29
- package/gql/queries/aiChatQueries.ts +39 -40
- package/gql/queries/audienceQueries.ts +31 -55
- package/gql/queries/authQueries.ts +16 -6
- package/gql/queries/billingQueries.ts +26 -10
- package/gql/queries/dataTableQueries.ts +24 -15
- package/gql/queries/emailOutreachQueries.ts +282 -0
- package/gql/queries/emailQueries.ts +39 -12
- package/gql/queries/emailReplyReportQueries.ts +60 -9
- package/gql/queries/fieldDocQueries.ts +36 -14
- package/gql/queries/inboundContactQueries.ts +11 -4
- package/gql/queries/index.ts +2 -2
- package/gql/queries/libraryQueries.ts +112 -0
- package/gql/queries/logQueries.ts +31 -12
- package/gql/queries/organizationQueries.ts +31 -12
- package/gql/queries/qrCodeQueries.ts +11 -4
- package/gql/queries/scheduleQueries.ts +252 -505
- package/gql/queries/sheetQueries.ts +36 -14
- package/gql/queries/storageQueries.ts +11 -4
- package/gql/queries/workflowQueries.ts +53 -10
- package/gql/reactivity.ts +98 -0
- package/gql/recordReads.ts +171 -0
- package/hooks/index.ts +79 -52
- package/hooks/use-agentNote-mtn.ts +7 -0
- package/hooks/use-agentNote-qry.ts +30 -58
- package/hooks/use-agentNote-recovery.ts +6 -21
- package/hooks/use-aiChat-mtn.ts +9 -4
- package/hooks/use-aiChat-qry.ts +28 -7
- package/hooks/use-audience-mtn.ts +0 -24
- package/hooks/use-audience-qry.helpers.ts +0 -24
- package/hooks/use-audience-qry.ts +1 -86
- package/hooks/use-dataTable-mtn.ts +3 -3
- package/hooks/use-dataTable-qry.ts +7 -2
- package/hooks/use-email-mtn.ts +26 -0
- package/hooks/use-email-qry.helpers.ts +1 -1
- package/hooks/use-email-qry.ts +18 -3
- 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-qry.ts +1 -1
- package/hooks/use-library-qry.ts +233 -0
- package/hooks/use-qrCode-qry.ts +1 -1
- package/hooks/use-schedule-mtn.ts +10 -300
- package/hooks/use-schedule-qry.ts +168 -680
- package/hooks/use-schedule-reactive.ts +71 -339
- package/hooks/use-sheet-qry.ts +6 -1
- package/hooks/use-workflow-mtn.ts +45 -1
- package/hooks/use-workflow-qry.ts +22 -2
- package/libs/ai-chat-link-events.ts +78 -0
- package/libs/data-changes.helpers.ts +161 -0
- package/libs/data-changes.ts +382 -0
- package/libs/fragment-realtime-sequence.ts +3 -3
- package/libs/record-read.ts +327 -0
- package/libs/sheet-command-batch.ts +3 -2
- package/libs/sheet-realtime-packet.ts +53 -0
- package/loaders/emailPreference.ts +18 -24
- package/package.json +44 -17
- package/schedule.d.ts +267 -874
- package/types.d.ts +3 -1
- package/cache/index.chat-activity.test.ts +0 -119
- package/cache/index.chat.test.ts +0 -92
- package/cache/index.regression.test.ts +0 -149
- package/cache/index.test.ts +0 -1209
- package/deno.lock +0 -187
- package/deno.test.json +0 -12
- package/gql/fragments/campaignFragments.ts +0 -566
- package/gql/mutations/campaignMutations.ts +0 -258
- package/gql/queries/appQueries.ts +0 -14
- package/gql/queries/campaignQueries.ts +0 -236
- package/hooks/index.helpers.test.ts +0 -50
- package/hooks/use-agentNote-recovery.helpers.test.ts +0 -68
- package/hooks/use-aiChat-qry.helpers.test.ts +0 -63
- package/hooks/use-app-qry.ts +0 -22
- package/hooks/use-audience-qry.helpers.test.ts +0 -80
- package/hooks/use-campaign-generation-recovery.ts +0 -53
- package/hooks/use-campaign-mtn.ts +0 -436
- package/hooks/use-campaign-qry.helpers.ts +0 -40
- package/hooks/use-campaign-qry.ts +0 -834
- package/hooks/use-emailCampaignReplyReport-qry.ts +0 -27
- package/hooks/use-fieldDoc-qry.helpers.test.ts +0 -65
- package/hooks/use-publicFormEmail-mtn.ts +0 -27
- package/libs/fragment-recovery.test.ts +0 -326
- package/libs/fragment-recovery.ts +0 -325
- package/libs/orchestrator-realtime.helpers.test.ts +0 -229
- package/libs/orchestrator-realtime.helpers.ts +0 -317
- package/libs/orchestrator-realtime.ts +0 -433
- package/libs/request-cache-regression.test.ts +0 -122
- package/libs/request-managed-session.test.ts +0 -574
- package/libs/request-no-store.test.ts +0 -419
- package/libs/sheet-view-realtime-router.test.ts +0 -214
- package/libs/sse-ticket.test.ts +0 -26
- package/loaders/campaign.test.ts +0 -186
- package/loaders/campaign.ts +0 -110
- package/tests/agent-note-detail-cache.test.ts +0 -120
- package/tests/agent-note-search.test.ts +0 -444
- package/tsconfig.json +0 -13
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jsb188
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/audience.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import type { AudienceEmailAddressGQL, AudienceSubscriptionStatus } from '@jsb188/mday/types/audience.d.ts';
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
AudienceAddressDetails,
|
|
5
|
+
AudienceDeliveryStatus,
|
|
6
|
+
AudienceEmailAddressGQL,
|
|
7
|
+
AudienceSubscriptionStatus,
|
|
8
|
+
} from '@jsb188/mday/types/audience.d.ts';
|
|
9
|
+
|
|
1
10
|
import type { PaginationArgs } from './types.d.ts';
|
|
2
11
|
|
|
3
12
|
export type AudienceListsSort = 'CREATED_ASC' | 'CREATED_DESC';
|
|
@@ -16,23 +25,6 @@ export interface AudienceListMembersFilter {
|
|
|
16
25
|
search?: string | null;
|
|
17
26
|
}
|
|
18
27
|
|
|
19
|
-
export type CampaignAudienceEligibility = 'ALL' | 'ELIGIBLE' | 'EXCLUDED';
|
|
20
|
-
export type CampaignAudienceMembersSort = 'EMAIL_ASC' | 'EMAIL_DESC';
|
|
21
|
-
|
|
22
|
-
export interface CampaignAudienceMembersFilter {
|
|
23
|
-
eligibility?: CampaignAudienceEligibility | null;
|
|
24
|
-
subscriptionStatus?: AudienceSubscriptionStatus | null;
|
|
25
|
-
audienceListId?: string | null;
|
|
26
|
-
search?: string | null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type CampaignAudienceMembersArgs = {
|
|
30
|
-
organizationId?: string | null;
|
|
31
|
-
campaignId?: string | null;
|
|
32
|
-
filter?: CampaignAudienceMembersFilter | null;
|
|
33
|
-
sort?: CampaignAudienceMembersSort | null;
|
|
34
|
-
} & PaginationArgs;
|
|
35
|
-
|
|
36
28
|
export type AudienceListsArgs = {
|
|
37
29
|
organizationId?: string | null;
|
|
38
30
|
filter?: AudienceListsFilter | null;
|
|
@@ -45,26 +37,9 @@ export type AudienceListMembersArgs = {
|
|
|
45
37
|
sort?: AudienceListMembersSort | null;
|
|
46
38
|
} & PaginationArgs;
|
|
47
39
|
|
|
48
|
-
export type AudienceSubscriptionStatus =
|
|
49
|
-
| 'NON_SUBSCRIBED'
|
|
50
|
-
| 'PENDING'
|
|
51
|
-
| 'SUBSCRIBED'
|
|
52
|
-
| 'UNSUBSCRIBED';
|
|
53
|
-
export type AudienceDeliveryStatus =
|
|
54
|
-
| 'UNKNOWN'
|
|
55
|
-
| 'DELIVERABLE'
|
|
56
|
-
| 'SOFT_BOUNCING'
|
|
57
|
-
| 'CLEANED';
|
|
58
40
|
export type AudienceImportSource = 'MANUAL' | 'IMPORT' | 'INTEGRATION';
|
|
59
|
-
export type AudienceConsentSource =
|
|
60
|
-
|
|
61
|
-
| 'SIGNUP'
|
|
62
|
-
| 'RECIPIENT_RESUBSCRIBE';
|
|
63
|
-
export type AudienceSuppressionKind =
|
|
64
|
-
| 'MANUAL'
|
|
65
|
-
| 'COMPLAINT'
|
|
66
|
-
| 'CLEANED'
|
|
67
|
-
| 'PROVIDER';
|
|
41
|
+
export type AudienceConsentSource = 'EXISTING_PERMISSION' | 'SIGNUP' | 'RECIPIENT_RESUBSCRIBE';
|
|
42
|
+
export type AudienceSuppressionKind = 'MANUAL' | 'COMPLAINT' | 'CLEANED' | 'PROVIDER';
|
|
68
43
|
|
|
69
44
|
export interface AudiencePageArgs {
|
|
70
45
|
afterId?: string | null;
|
|
@@ -103,46 +78,9 @@ export interface AudienceMemberDetails {
|
|
|
103
78
|
[key: string]: unknown;
|
|
104
79
|
}
|
|
105
80
|
|
|
106
|
-
export interface AudienceAddressDetails {
|
|
107
|
-
preferenceSource?: string;
|
|
108
|
-
lastBounce?: {
|
|
109
|
-
type?: string | null;
|
|
110
|
-
code?: string | number | null;
|
|
111
|
-
reason?: string | null;
|
|
112
|
-
};
|
|
113
|
-
manualSuppression?: {
|
|
114
|
-
reason?: string;
|
|
115
|
-
actorAccountId?: string;
|
|
116
|
-
active?: boolean;
|
|
117
|
-
};
|
|
118
|
-
[key: string]: unknown;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface AudienceEmailAddressGQL {
|
|
122
|
-
id: string;
|
|
123
|
-
organizationId: string;
|
|
124
|
-
normalizedEmail: string;
|
|
125
|
-
inboundContactId: string | null;
|
|
126
|
-
campaignStatus: 'OPTED_IN' | 'OPTED_OUT' | null;
|
|
127
|
-
campaignStatusAt: string | null;
|
|
128
|
-
deliveryStatus: AudienceDeliveryStatus;
|
|
129
|
-
deliveryStatusAt: string | null;
|
|
130
|
-
cleanedReason:
|
|
131
|
-
| 'HARD_BOUNCE'
|
|
132
|
-
| 'INVALID_ADDRESS'
|
|
133
|
-
| 'REPEATED_SOFT_BOUNCE'
|
|
134
|
-
| null;
|
|
135
|
-
lastDeliveredAt: string | null;
|
|
136
|
-
lastBounceAt: string | null;
|
|
137
|
-
consecutiveSoftBounceCount: number;
|
|
138
|
-
complaintSuppressedAt: string | null;
|
|
139
|
-
manuallySuppressedAt: string | null;
|
|
140
|
-
details: AudienceAddressDetails;
|
|
141
|
-
createdAt: string;
|
|
142
|
-
updatedAt: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
81
|
export interface AudienceListMemberGQL {
|
|
82
|
+
__deleted?: boolean;
|
|
83
|
+
|
|
146
84
|
id: string;
|
|
147
85
|
cursor: string;
|
|
148
86
|
organizationId: string;
|
|
@@ -158,30 +96,6 @@ export interface AudienceListMemberGQL {
|
|
|
158
96
|
updatedAt: string;
|
|
159
97
|
}
|
|
160
98
|
|
|
161
|
-
export interface CampaignAudienceMembershipGQL {
|
|
162
|
-
memberId: string;
|
|
163
|
-
audienceListId: string;
|
|
164
|
-
listName: string;
|
|
165
|
-
personName: string | null;
|
|
166
|
-
subscriptionStatus: AudienceSubscriptionStatus;
|
|
167
|
-
subscriptionVersion: string;
|
|
168
|
-
removedAt: string | null;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export interface CampaignAudienceMemberGQL {
|
|
172
|
-
id: string;
|
|
173
|
-
cursor: string;
|
|
174
|
-
organizationId: string;
|
|
175
|
-
campaignId: string;
|
|
176
|
-
emailAddressId: string;
|
|
177
|
-
normalizedEmail: string;
|
|
178
|
-
personName: string | null;
|
|
179
|
-
inboundContactId: string | null;
|
|
180
|
-
reason: string | null;
|
|
181
|
-
memberships: CampaignAudienceMembershipGQL[];
|
|
182
|
-
address?: AudienceEmailAddressGQL | null;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
99
|
export interface AudienceListOverviewGQL {
|
|
186
100
|
total: number;
|
|
187
101
|
subscribed: number;
|
|
@@ -202,7 +116,7 @@ export interface AudienceEventGQL {
|
|
|
202
116
|
eventType: string;
|
|
203
117
|
source: string;
|
|
204
118
|
actorAccountId: string | null;
|
|
205
|
-
|
|
119
|
+
emailOutreachId: string | null;
|
|
206
120
|
outboundEmailId: string | null;
|
|
207
121
|
metadata: Record<string, unknown>;
|
|
208
122
|
occurredAt: string;
|
|
@@ -289,55 +203,3 @@ export interface SetAudienceAddressSuppressionInput {
|
|
|
289
203
|
suppressed: boolean;
|
|
290
204
|
reason: string;
|
|
291
205
|
}
|
|
292
|
-
|
|
293
|
-
export interface CampaignAudienceSessionGQL {
|
|
294
|
-
// Campaign id; keys the cached session fragment.
|
|
295
|
-
id: string;
|
|
296
|
-
campaignId: string;
|
|
297
|
-
organizationId: string;
|
|
298
|
-
editVersion: number;
|
|
299
|
-
editable: boolean;
|
|
300
|
-
selectedAudienceListIds: string[];
|
|
301
|
-
// Addresses skipped for this campaign only; they remain members of their lists.
|
|
302
|
-
excludedEmailAddressIds: string[];
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// The limits the server enforces when a campaign is sent now.
|
|
306
|
-
export interface CampaignEmailSendLimitsGQL {
|
|
307
|
-
// Recipients one campaign may send to.
|
|
308
|
-
recipientLimit: number;
|
|
309
|
-
monthlyRecipientLimit: number;
|
|
310
|
-
// Recipients this campaign can still send to in the current UTC month.
|
|
311
|
-
monthlyRecipientsRemaining: number;
|
|
312
|
-
sendingPaused: boolean;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export interface CampaignAudiencePreviewGQL {
|
|
316
|
-
// Campaign id; keys the cached preview fragment.
|
|
317
|
-
id: string;
|
|
318
|
-
campaignId: string;
|
|
319
|
-
editVersion: number;
|
|
320
|
-
selectedCount: number;
|
|
321
|
-
eligibleCount: number;
|
|
322
|
-
duplicateCount: number;
|
|
323
|
-
excludedCount: number;
|
|
324
|
-
exclusions: Array<{ reason: string; count: number }>;
|
|
325
|
-
// Recipients frozen when the campaign was scheduled or sent; 0 for a draft.
|
|
326
|
-
frozenRecipientCount: number;
|
|
327
|
-
sendLimits: CampaignEmailSendLimitsGQL;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Returned by both the campaignAudience query and the setCampaignAudience mutation.
|
|
331
|
-
export interface CampaignAudienceSelectionGQL {
|
|
332
|
-
session: CampaignAudienceSessionGQL;
|
|
333
|
-
preview: CampaignAudiencePreviewGQL;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Each set replaces the whole server-side set when present and is left unchanged when omitted.
|
|
337
|
-
export interface SetCampaignAudienceInput {
|
|
338
|
-
organizationId: string;
|
|
339
|
-
campaignId: string;
|
|
340
|
-
expectedEditVersion: number;
|
|
341
|
-
audienceListIds?: string[];
|
|
342
|
-
excludedEmailAddressIds?: string[];
|
|
343
|
-
}
|
package/cache/config.ts
CHANGED
|
@@ -17,9 +17,24 @@ import { FRAGMENT_NAMES, getFragmentBaseName } from '@jsb188/mday/constants/grap
|
|
|
17
17
|
* 11: field doc programs. $fieldDocFragment now holds the form instead of a
|
|
18
18
|
* filled document, and submission, answer and edit-session ids changed, so
|
|
19
19
|
* the old field doc records are dropped instead of lingering as orphans.
|
|
20
|
+
*
|
|
21
|
+
* 12: email campaigns became email outreach. The email campaign, recipient and
|
|
22
|
+
* audience-selection records are dropped instead of lingering as orphans under
|
|
23
|
+
* fragment names the client no longer reads.
|
|
24
|
+
*
|
|
25
|
+
* 13: retire web-form campaign records and their linked agent notes.
|
|
26
|
+
*
|
|
27
|
+
* 14: staff schedules moved from occurrences to seats. The occurrence and
|
|
28
|
+
* series records are dropped, calendar, resource, request, violation and
|
|
29
|
+
* publication records changed shape, and the project-side rows that were
|
|
30
|
+
* inline (WBS nodes, assignments, baselines, code types, work-calendar
|
|
31
|
+
* exceptions, resource capacity) became fragment records.
|
|
32
|
+
*
|
|
33
|
+
* 15: schedule to-dos (ScheduleTask records, the scheduleTasks and
|
|
34
|
+
* scheduleMyTasks reads).
|
|
20
35
|
*/
|
|
21
36
|
|
|
22
|
-
export const CACHE_SCHEMA_VERSION =
|
|
37
|
+
export const CACHE_SCHEMA_VERSION = 15;
|
|
23
38
|
|
|
24
39
|
export const QUERY_EXPIRE_TIMES = {
|
|
25
40
|
__default: 1.08e7, // 3 hours
|
|
@@ -28,12 +43,18 @@ export const QUERY_EXPIRE_TIMES = {
|
|
|
28
43
|
// 2.88e+7, // 8 hours
|
|
29
44
|
// 6.48e+7, // 18 hours
|
|
30
45
|
|
|
31
|
-
//
|
|
32
|
-
// lists current,
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
// Email outreach metrics are live operational data. Realtime changes keep
|
|
47
|
+
// mounted lists current, and catch-up after a websocket gap is handled by
|
|
48
|
+
// realtimeLiveSince; this short window only bounds how old a revisited result may be.
|
|
49
|
+
emailMessage: 60 * 1000,
|
|
50
|
+
emailMessageConversationPage: 60 * 1000,
|
|
51
|
+
emailOutreachList: 60 * 1000,
|
|
52
|
+
emailOutreachFollowUps: 60 * 1000,
|
|
53
|
+
emailOutreachGroups: 60 * 1000,
|
|
54
|
+
emailOutreachReplyReport: 10 * 60 * 1000,
|
|
35
55
|
|
|
36
|
-
// Note edits
|
|
56
|
+
// Note edits arrive as record changes, and catch-up after a websocket gap is
|
|
57
|
+
// handled by realtimeLiveSince; short windows only bound how old a revisited result may be.
|
|
37
58
|
agentNote: 60 * 1000,
|
|
38
59
|
agentNotes: 60 * 1000,
|
|
39
60
|
searchAgentNotes: 60 * 1000,
|
|
@@ -41,16 +62,13 @@ export const QUERY_EXPIRE_TIMES = {
|
|
|
41
62
|
// Sheets
|
|
42
63
|
sheets: 1.08e7,
|
|
43
64
|
sheetAccess: 2.88e7,
|
|
44
|
-
// Form definitions should refresh quickly between modal sessions without
|
|
45
|
-
// becoming stale again during the same render pass.
|
|
46
|
-
sheetWebFormResultsSource: 1000,
|
|
47
65
|
sheetAccessGrants: 2.88e7,
|
|
48
66
|
openSheet: 2.88e7,
|
|
49
67
|
|
|
50
|
-
// Data tables change through agents, workflows and source sync.
|
|
51
|
-
//
|
|
52
|
-
// windows refetch on focus
|
|
53
|
-
// is rebuilt only
|
|
68
|
+
// Data tables change through agents, workflows and source sync. Realtime
|
|
69
|
+
// changes keep mounted views current, and catch-up after a websocket gap is
|
|
70
|
+
// handled by realtimeLiveSince. Short windows refetch on focus or the next
|
|
71
|
+
// mount; a mounted rows list is rebuilt only through its declared notice.
|
|
54
72
|
dataTables: 60 * 1000,
|
|
55
73
|
dataTable: 60 * 1000,
|
|
56
74
|
dataTableRows: 60 * 1000,
|
|
@@ -68,14 +86,6 @@ export const RULES = {
|
|
|
68
86
|
// but if you want to skip some, add it here
|
|
69
87
|
accountAuthFragment: false,
|
|
70
88
|
|
|
71
|
-
// Editor and access sessions contain heavy mutable trees or short-lived
|
|
72
|
-
// authorization state. Keep normalized core fragments, but never persist
|
|
73
|
-
// the root session response across unmounts.
|
|
74
|
-
campaignEditSession: false,
|
|
75
|
-
// Reply identities and captured answers live only in the mounted report hook.
|
|
76
|
-
emailCampaignReplyReport: false,
|
|
77
|
-
campaignFormAccessSession: false,
|
|
78
|
-
campaignTemplateEditSession: false,
|
|
79
89
|
// Typeahead prefixes live only in the mounted hook; note fragments remain shared.
|
|
80
90
|
searchAgentNotes: false,
|
|
81
91
|
// Billing payment-form inputs: the Stripe key and tax previews must be
|
|
@@ -85,30 +95,23 @@ export const RULES = {
|
|
|
85
95
|
// NOTE: ALL queries are cached by default,
|
|
86
96
|
// but if you want to skip some, add it here
|
|
87
97
|
// e.g.: someQueryName: false,
|
|
88
|
-
|
|
89
|
-
// Respondent identity travels via header/cookie (not query variables), so
|
|
90
|
-
// the cache key cannot distinguish viewers; never cache per-viewer results
|
|
91
98
|
} as {
|
|
92
99
|
__limit: number;
|
|
93
100
|
[key: string]: boolean | number;
|
|
94
101
|
};
|
|
95
102
|
|
|
103
|
+
// Reuse reply identities and captured answers within the open browser session.
|
|
104
|
+
export const MEMORY_ONLY_QUERY_NAMES = new Set(['emailOutreachReplyReport']);
|
|
105
|
+
|
|
96
106
|
export const PARTIALS_MAP = {
|
|
97
107
|
// Partial fragments are supported if you map them to its original fragment name
|
|
98
108
|
sheetViewPatchFragment: getFragmentBaseName(FRAGMENT_NAMES.sheetView),
|
|
99
109
|
// List rows are narrower projections of the same records. Map them to the
|
|
100
110
|
// canonical fragment keys so realtime core patches update both detail and
|
|
101
111
|
// summary consumers without duplicating fragment authorities.
|
|
102
|
-
|
|
103
|
-
campaignTemplateLifecycleFragment: getFragmentBaseName(FRAGMENT_NAMES.campaignTemplate),
|
|
104
|
-
campaignAccessFragment: getFragmentBaseName(FRAGMENT_NAMES.campaign),
|
|
105
|
-
campaignGenerationLifecycleFragment: getFragmentBaseName(FRAGMENT_NAMES.campaign),
|
|
106
|
-
campaignLifecycleFragment: getFragmentBaseName(FRAGMENT_NAMES.campaign),
|
|
107
|
-
campaignSettingsFragment: getFragmentBaseName(FRAGMENT_NAMES.campaign),
|
|
108
|
-
campaignSummaryFragment: getFragmentBaseName(FRAGMENT_NAMES.campaign),
|
|
112
|
+
emailOutreachSummaryFragment: getFragmentBaseName(FRAGMENT_NAMES.emailOutreach),
|
|
109
113
|
// The note detail projection shares the realtime agentNoteFragment identity
|
|
110
114
|
agentNoteDetailFragment: getFragmentBaseName(FRAGMENT_NAMES.agentNote),
|
|
111
|
-
emailMessageDetailsFragment: getFragmentBaseName(FRAGMENT_NAMES.emailMessage),
|
|
112
115
|
} as Record<string, string>;
|
|
113
116
|
|
|
114
117
|
export const PARTIAL_NULL_PRESERVE_FIELDS = {
|
package/cache/index.helpers.ts
CHANGED
|
@@ -87,7 +87,7 @@ export function reconcileAIChatCacheSnapshot(fragmentKey: string, current: any,
|
|
|
87
87
|
|
|
88
88
|
/*
|
|
89
89
|
* Read only references stored inside this query, never the global fragment
|
|
90
|
-
* cache. A cached document outside the list
|
|
90
|
+
* cache. A cached document outside the list does not count as held by it.
|
|
91
91
|
*/
|
|
92
92
|
export function queryReferencesFragment(value: unknown, fragmentKey: string): boolean {
|
|
93
93
|
if (!value || typeof value !== 'object') return false;
|
package/cache/index.ts
CHANGED
|
@@ -4,11 +4,13 @@ import { mapArrayLikeObjects, uniq } from '@jsb188/app/utils/object.ts';
|
|
|
4
4
|
import { getQueryResetTargetId, type QueryResetTarget, queryCacheKeyMatchesResetTarget } from '@jsb188/app/utils/queryReset.ts';
|
|
5
5
|
import { clearAllDrafts } from '../client/draft-persistence.ts';
|
|
6
6
|
import { clearAIChatOutgoingMessages } from '../libs/ai-chat-outgoing.helpers.ts';
|
|
7
|
+
import { clearAIChatLinkEvents } from '../libs/ai-chat-link-events.ts';
|
|
7
8
|
import type { UpdateObserversFn } from '../types.d.ts';
|
|
8
9
|
import { PARTIAL_NULL_PRESERVE_FIELDS, PARTIALS_MAP, RULES } from './config.ts';
|
|
9
10
|
import { clearGraphQLCachePersistence } from './persist.ts';
|
|
11
|
+
import { clearRealtimeWrites, keepNewerRealtimeFields } from './realtime-fence.ts';
|
|
10
12
|
import { cacheStore } from './store.ts';
|
|
11
|
-
import { mergeGraphQLObjectData,
|
|
13
|
+
import { mergeGraphQLObjectData, reconcileAIChatCacheSnapshot } from './index.helpers.ts';
|
|
12
14
|
|
|
13
15
|
export {
|
|
14
16
|
initGraphQLCachePersistence,
|
|
@@ -25,6 +27,8 @@ const RESET_TIME = new Map();
|
|
|
25
27
|
const QUERY_DOCUMENT_CACHE_IDS = new WeakMap<object, number>();
|
|
26
28
|
const QUERY_FRAGMENT_DEFINITIONS = new WeakMap<object, Record<string, any>>();
|
|
27
29
|
let NEXT_QUERY_DOCUMENT_CACHE_ID = 1;
|
|
30
|
+
// When the network request whose response is being written began (0 outside graphqlRequest writes)
|
|
31
|
+
let ACTIVE_WRITE_STARTED_AT = 0;
|
|
28
32
|
|
|
29
33
|
/**
|
|
30
34
|
* Return a stable runtime id for one parsed GraphQL document.
|
|
@@ -386,6 +390,23 @@ export function loadQuery(queryKey: string, referencesOnly?: boolean) {
|
|
|
386
390
|
return cacheStore.memoizeRead(`Q|${queryKey}`, () => loadQueryInternal(queryKey));
|
|
387
391
|
}
|
|
388
392
|
|
|
393
|
+
/*
|
|
394
|
+
* Return the keys of every cached query result ('#name:@{variables}'). The
|
|
395
|
+
* iterator is live: copy it before deleting cached queries while reading it.
|
|
396
|
+
*/
|
|
397
|
+
export function getCachedQueryKeys(): IterableIterator<string> {
|
|
398
|
+
return QUERIES.keys();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/*
|
|
402
|
+
* Return one cached query's stored value (fragment references, not assembled
|
|
403
|
+
* data) without recording a memo dependency or touching its LRU stamp.
|
|
404
|
+
* Undefined when the query is not cached.
|
|
405
|
+
*/
|
|
406
|
+
export function peekQuery(queryKey: string): any {
|
|
407
|
+
return QUERIES.peek(queryKey);
|
|
408
|
+
}
|
|
409
|
+
|
|
389
410
|
/**
|
|
390
411
|
* Assemble one cached query result from its stored fragment references.
|
|
391
412
|
*/
|
|
@@ -524,7 +545,13 @@ function writeSelectedFragment(
|
|
|
524
545
|
if (RULES[name] === false) return key;
|
|
525
546
|
const current = loadFragment(key);
|
|
526
547
|
const version = FRAGMENTS.version(key);
|
|
527
|
-
|
|
548
|
+
// A field written by a realtime change after this request began is newer than the response's value
|
|
549
|
+
const incoming = keepNewerRealtimeFields(
|
|
550
|
+
key,
|
|
551
|
+
getPartialFragmentMergeData(name, extractFragment(data, selections)),
|
|
552
|
+
current,
|
|
553
|
+
ACTIVE_WRITE_STARTED_AT,
|
|
554
|
+
);
|
|
528
555
|
FRAGMENTS.set(
|
|
529
556
|
key,
|
|
530
557
|
mergeGraphQLObjectData(
|
|
@@ -762,7 +789,8 @@ function saveQueryToMemory(
|
|
|
762
789
|
if (saveQueryToCache) {
|
|
763
790
|
const mapped = customMap ? cacheMap(data, cacheData, selections, variables) : cacheData;
|
|
764
791
|
QUERIES.set(queryId, mapped === undefined ? null : mapped);
|
|
765
|
-
|
|
792
|
+
// A response read during a realtime gap must not count as fetched after the gap ended
|
|
793
|
+
if (markFresh) cacheStore.setQueryFetchTime(queryId, ACTIVE_WRITE_STARTED_AT || Date.now());
|
|
766
794
|
else cacheStore.clearQueryFetchTime(queryId);
|
|
767
795
|
if (customMap) updateObservers?.({ queryId });
|
|
768
796
|
}
|
|
@@ -771,7 +799,8 @@ function saveQueryToMemory(
|
|
|
771
799
|
}
|
|
772
800
|
|
|
773
801
|
/**
|
|
774
|
-
* Save cache
|
|
802
|
+
* Save cache. requestStartedAt is when the network request that produced
|
|
803
|
+
* requestData began; fields a realtime change wrote after it are kept.
|
|
775
804
|
*/
|
|
776
805
|
|
|
777
806
|
export function setDataToCache(
|
|
@@ -781,29 +810,37 @@ export function setDataToCache(
|
|
|
781
810
|
cacheMap?: any,
|
|
782
811
|
updateObservers?: UpdateObserversFn,
|
|
783
812
|
markFresh = true,
|
|
813
|
+
requestStartedAt = 0,
|
|
784
814
|
) {
|
|
785
815
|
// query[variablesKey] = cache;
|
|
786
816
|
const definitions = gqlQuery.definitions;
|
|
787
817
|
const variablesKey = makeGraphQLVariablesKey(variables);
|
|
788
818
|
const fragmentDefinitions = getFragmentDefinitions(gqlQuery);
|
|
819
|
+
const outerWriteStartedAt = ACTIVE_WRITE_STARTED_AT;
|
|
820
|
+
ACTIVE_WRITE_STARTED_AT = requestStartedAt;
|
|
789
821
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
def
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
822
|
+
try {
|
|
823
|
+
for (const def of definitions) {
|
|
824
|
+
if (def.kind === 'OperationDefinition') {
|
|
825
|
+
def?.selectionSet?.selections.forEach((selection: any) => {
|
|
826
|
+
const qryName = selection.name?.value;
|
|
827
|
+
saveQueryToMemory(
|
|
828
|
+
requestData,
|
|
829
|
+
selection,
|
|
830
|
+
variables,
|
|
831
|
+
variablesKey,
|
|
832
|
+
cacheMap,
|
|
833
|
+
def.operation !== 'mutation' && RULES[qryName] !== false,
|
|
834
|
+
updateObservers,
|
|
835
|
+
markFresh,
|
|
836
|
+
fragmentDefinitions,
|
|
837
|
+
);
|
|
838
|
+
});
|
|
839
|
+
}
|
|
806
840
|
}
|
|
841
|
+
} finally {
|
|
842
|
+
// The start time applies only to this synchronous write; restore the enclosing write's (0 when not nested)
|
|
843
|
+
ACTIVE_WRITE_STARTED_AT = outerWriteStartedAt;
|
|
807
844
|
}
|
|
808
845
|
}
|
|
809
846
|
|
|
@@ -1195,6 +1232,8 @@ export function clearGraphQLClientCache() {
|
|
|
1195
1232
|
graphQLCacheEpoch += 1;
|
|
1196
1233
|
cacheStore.clearAll();
|
|
1197
1234
|
clearAIChatOutgoingMessages();
|
|
1235
|
+
clearAIChatLinkEvents();
|
|
1236
|
+
clearRealtimeWrites();
|
|
1198
1237
|
RESET_TIME.clear();
|
|
1199
1238
|
clearGraphQLCachePersistence();
|
|
1200
1239
|
|
|
@@ -1203,7 +1242,10 @@ export function clearGraphQLClientCache() {
|
|
|
1203
1242
|
clearAllDrafts();
|
|
1204
1243
|
}
|
|
1205
1244
|
|
|
1206
|
-
/*
|
|
1245
|
+
/*
|
|
1246
|
+
* Return the cache epoch, which advances every time the normalized cache is cleared. Asynchronous work (requests, record
|
|
1247
|
+
* reads, delayed refreshes) compares it so nothing started before a clear is written or run after it.
|
|
1248
|
+
*/
|
|
1207
1249
|
export function getGraphQLCacheEpoch() {
|
|
1208
1250
|
return graphQLCacheEpoch;
|
|
1209
1251
|
}
|
|
@@ -1342,35 +1384,21 @@ export function resetQueryByTarget(
|
|
|
1342
1384
|
}
|
|
1343
1385
|
}
|
|
1344
1386
|
|
|
1345
|
-
/*
|
|
1346
|
-
* Refetch only matching query snapshots missing an emitted fragment. An absent
|
|
1347
|
-
* snapshot still sends the scoped reset so an in-flight initial read recovers.
|
|
1348
|
-
*/
|
|
1349
|
-
export function resetQueryByTargetIfFragmentsMissing(
|
|
1350
|
-
target: QueryResetTarget,
|
|
1351
|
-
fragmentKeys: string[],
|
|
1352
|
-
updateObservers?: UpdateObserversFn,
|
|
1353
|
-
) {
|
|
1354
|
-
if (!fragmentKeys.length) return;
|
|
1355
|
-
let foundQuery = false;
|
|
1356
|
-
for (const key of QUERIES.keys()) {
|
|
1357
|
-
if (!queryCacheKeyMatchesResetTarget(key, target)) continue;
|
|
1358
|
-
foundQuery = true;
|
|
1359
|
-
const data = QUERIES.get(key);
|
|
1360
|
-
if (fragmentKeys.some((fragmentKey) => !FRAGMENTS.has(fragmentKey) || !queryReferencesFragment(data, fragmentKey))) {
|
|
1361
|
-
resetQuery(key, true, updateObservers);
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
if (!foundQuery) resetQueryByTarget(target, true, updateObservers);
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
1387
|
/**
|
|
1368
1388
|
* Clear query cache
|
|
1369
1389
|
* NOTE: If "queryId" is a name of query postfixed by ":" like this => "#queryName:"
|
|
1370
1390
|
* it will reset all queries everywhere for the same GraphQL query.
|
|
1391
|
+
* selfRefresh (with resetOnly): this tab's own request caused the reset, so a
|
|
1392
|
+
* mounted result refetches instead of showing the "new data" notice.
|
|
1371
1393
|
*/
|
|
1372
1394
|
|
|
1373
|
-
export function resetQuery(
|
|
1395
|
+
export function resetQuery(
|
|
1396
|
+
queryId: string,
|
|
1397
|
+
forceRefetch?: boolean,
|
|
1398
|
+
updateObservers?: UpdateObserversFn,
|
|
1399
|
+
resetOnly?: boolean,
|
|
1400
|
+
selfRefresh?: boolean,
|
|
1401
|
+
) {
|
|
1374
1402
|
// if (forceRefetch) {
|
|
1375
1403
|
// QUERIES.delete(queryId);
|
|
1376
1404
|
// }
|
|
@@ -1381,6 +1409,7 @@ export function resetQuery(queryId: string, forceRefetch?: boolean, updateObserv
|
|
|
1381
1409
|
queryId,
|
|
1382
1410
|
forceRefetch,
|
|
1383
1411
|
resetOnly,
|
|
1412
|
+
selfRefresh,
|
|
1384
1413
|
});
|
|
1385
1414
|
return;
|
|
1386
1415
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Query key → number of mounted query hooks using it. Includes hooks without a cached result
|
|
2
|
+
// (skipped, first load in flight, pages dropped by a notice, never-cached queries).
|
|
3
|
+
const MOUNTED_QUERY_KEYS = new Map<string, number>();
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Count one mounted query hook under its query key.
|
|
7
|
+
*/
|
|
8
|
+
export function retainMountedQueryKey(queryKey: string) {
|
|
9
|
+
MOUNTED_QUERY_KEYS.set(queryKey, (MOUNTED_QUERY_KEYS.get(queryKey) || 0) + 1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Release one mounted query hook's key; the key is forgotten when its last hook releases it.
|
|
14
|
+
*/
|
|
15
|
+
export function releaseMountedQueryKey(queryKey: string) {
|
|
16
|
+
const count = MOUNTED_QUERY_KEYS.get(queryKey) || 0;
|
|
17
|
+
if (count > 1) MOUNTED_QUERY_KEYS.set(queryKey, count - 1);
|
|
18
|
+
else MOUNTED_QUERY_KEYS.delete(queryKey);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* Return the query keys of every mounted query hook.
|
|
23
|
+
*/
|
|
24
|
+
export function getMountedQueryKeys(): IterableIterator<string> {
|
|
25
|
+
return MOUNTED_QUERY_KEYS.keys();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Return whether at least one mounted query hook uses this key.
|
|
30
|
+
*/
|
|
31
|
+
export function isQueryKeyMounted(queryKey: string): boolean {
|
|
32
|
+
return MOUNTED_QUERY_KEYS.has(queryKey);
|
|
33
|
+
}
|
package/cache/persist.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CACHE_SCHEMA_VERSION, RULES } from './config.ts';
|
|
1
|
+
import { CACHE_SCHEMA_VERSION, MEMORY_ONLY_QUERY_NAMES, RULES } from './config.ts';
|
|
2
2
|
import { isOptimisticUIFragmentActive } from './optimistic-ui-runtime.ts';
|
|
3
3
|
import { cacheStore } from './store.ts';
|
|
4
4
|
|
|
@@ -73,7 +73,7 @@ let PAGE_HIDE_FLUSH_BOUND = false;
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Check whether IndexedDB exists in this runtime (browser only; entry.server
|
|
76
|
-
* and
|
|
76
|
+
* and bun tests import this module through cache/index.ts and must no-op).
|
|
77
77
|
*/
|
|
78
78
|
|
|
79
79
|
function isIndexedDBAvailable(): boolean {
|
|
@@ -112,6 +112,12 @@ function fragmentKeyIsPersistable(fragmentKey: string): boolean {
|
|
|
112
112
|
return RULES[fragmentName] !== false;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/* Keep memory-only query results out of the persisted cache. */
|
|
116
|
+
function queryKeyIsPersistable(queryKey: string): boolean {
|
|
117
|
+
const nameEnd = queryKey.indexOf(':');
|
|
118
|
+
return nameEnd < 0 || !MEMORY_ONLY_QUERY_NAMES.has(queryKey.slice(1, nameEnd));
|
|
119
|
+
}
|
|
120
|
+
|
|
115
121
|
/**
|
|
116
122
|
* Return the parent fragment key for a ".spreads" sidecar key, or the key
|
|
117
123
|
* itself when it is not a sidecar.
|
|
@@ -373,7 +379,7 @@ async function hydrateFromDatabase(db: IDBDatabase, isCurrent: () => boolean): P
|
|
|
373
379
|
}
|
|
374
380
|
|
|
375
381
|
for (const record of queryRecords) {
|
|
376
|
-
if (record?.k && cacheStore.queries.hydrate(record.k, record.d)) {
|
|
382
|
+
if (record?.k && queryKeyIsPersistable(record.k) && cacheStore.queries.hydrate(record.k, record.d)) {
|
|
377
383
|
if (typeof record.t === 'number') {
|
|
378
384
|
cacheStore.hydrateQueryFetchTime(record.k, record.t);
|
|
379
385
|
}
|
|
@@ -493,7 +499,7 @@ function flushDirtyKeys() {
|
|
|
493
499
|
|
|
494
500
|
for (const key of queryKeys) {
|
|
495
501
|
const value = cacheStore.queries.peek(key);
|
|
496
|
-
if (value === undefined) {
|
|
502
|
+
if (value === undefined || !queryKeyIsPersistable(key)) {
|
|
497
503
|
queriesStore.delete(key);
|
|
498
504
|
continue;
|
|
499
505
|
}
|