@jsb188/graphql 1.1.11 → 1.1.12
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/audience.d.ts +343 -0
- package/cache/config.ts +58 -24
- package/cache/index.chat-activity.test.ts +119 -0
- package/cache/index.chat.test.ts +92 -0
- package/cache/index.helpers.ts +96 -0
- package/cache/index.regression.test.ts +149 -0
- package/cache/index.test.ts +370 -42
- package/cache/index.ts +326 -799
- package/cache/optimistic-ui-runtime.ts +46 -0
- package/cache/optimistic-ui.ts +401 -0
- package/cache/persist.ts +98 -19
- 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} +5 -2
- package/client/index.ts +3 -2
- package/client/request.helpers.ts +14 -0
- package/client/request.ts +130 -215
- package/deno.lock +17 -0
- package/deno.test.json +2 -0
- package/gql/fragments/agentMemoryFragments.ts +5 -1
- package/gql/fragments/agentNoteFragments.ts +150 -0
- package/gql/fragments/aiChatFragments.ts +36 -10
- package/gql/fragments/audienceFragments.ts +141 -0
- package/gql/fragments/campaignFragments.ts +415 -126
- package/gql/fragments/dataTableFragments.ts +48 -80
- package/gql/fragments/emailFragments.ts +28 -23
- package/gql/fragments/fieldDocFragments.ts +222 -40
- package/gql/fragments/inboundContactFragments.ts +2 -0
- package/gql/fragments/logFragments.ts +93 -2
- package/gql/fragments/organizationFragments.ts +10 -0
- package/gql/fragments/qrCodeFragments.ts +29 -0
- package/gql/fragments/scheduleFragments.ts +652 -140
- package/gql/fragments/sheetFragments.ts +84 -373
- package/gql/fragments/storageFragments.ts +25 -1
- package/gql/fragments/workflowFragments.ts +13 -1
- package/gql/mutations/agentMemoryMutations.ts +32 -0
- package/gql/mutations/agentNoteMutations.ts +62 -0
- package/gql/mutations/aiChatMutations.ts +36 -4
- package/gql/mutations/audienceMutations.ts +71 -0
- package/gql/mutations/authMutations.ts +45 -1
- package/gql/mutations/billingMutations.ts +24 -0
- package/gql/mutations/campaignMutations.ts +170 -127
- package/gql/mutations/contactMutations.ts +23 -0
- package/gql/mutations/dataTableMutations.ts +18 -75
- package/gql/mutations/fieldDocMutations.ts +162 -13
- package/gql/mutations/index.ts +8 -5
- package/gql/mutations/organizationMutations.ts +6 -0
- package/gql/mutations/qrCodeMutations.ts +20 -0
- package/gql/mutations/scheduleMutations.ts +1052 -354
- package/gql/mutations/sheetMutations.ts +62 -118
- package/gql/mutations/storageMutations.ts +0 -1
- package/gql/mutations/workflowMutations.ts +18 -0
- package/gql/queries/agentMemoryQueries.ts +6 -0
- package/gql/queries/agentNoteQueries.ts +89 -0
- package/gql/queries/aiChatQueries.ts +56 -4
- package/gql/queries/audienceQueries.ts +128 -0
- package/gql/queries/authQueries.ts +6 -0
- package/gql/queries/billingQueries.ts +95 -6
- package/gql/queries/campaignQueries.ts +132 -23
- package/gql/queries/dataTableQueries.ts +24 -65
- package/gql/queries/emailQueries.ts +18 -61
- package/gql/queries/emailReplyReportQueries.ts +76 -0
- package/gql/queries/fieldDocQueries.ts +100 -92
- package/gql/queries/inboundContactQueries.ts +4 -0
- package/gql/queries/index.ts +3 -1
- package/gql/queries/logQueries.ts +62 -7
- package/gql/queries/organizationQueries.ts +13 -0
- package/gql/queries/qrCodeQueries.ts +20 -0
- package/gql/queries/scheduleQueries.ts +633 -257
- package/gql/queries/sheetQueries.ts +59 -152
- package/gql/queries/workflowQueries.ts +10 -4
- package/hooks/index.helpers.test.ts +50 -0
- package/hooks/index.helpers.ts +52 -0
- package/hooks/index.ts +863 -685
- package/hooks/use-agentMemory-mtn.ts +29 -31
- package/hooks/use-agentMemory-qry.ts +15 -3
- package/hooks/use-agentNote-mtn.ts +82 -0
- package/hooks/use-agentNote-qry.ts +190 -0
- package/hooks/use-agentNote-recovery.helpers.test.ts +68 -0
- package/hooks/use-agentNote-recovery.helpers.ts +58 -0
- package/hooks/use-agentNote-recovery.ts +72 -0
- package/hooks/use-aiChat-mtn.ts +96 -112
- package/hooks/use-aiChat-qry.helpers.test.ts +63 -0
- package/hooks/use-aiChat-qry.helpers.ts +124 -0
- package/hooks/use-aiChat-qry.ts +229 -383
- package/hooks/use-aiChat-stream-mtn.ts +14 -0
- package/hooks/use-audience-mtn.ts +194 -0
- package/hooks/use-audience-qry.helpers.test.ts +80 -0
- package/hooks/use-audience-qry.helpers.ts +63 -0
- package/hooks/use-audience-qry.ts +330 -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-campaign-generation-recovery.ts +53 -0
- package/hooks/use-campaign-mtn.ts +224 -165
- package/hooks/use-campaign-qry.helpers.ts +40 -0
- package/hooks/use-campaign-qry.ts +631 -54
- package/hooks/use-dataTable-mtn.ts +23 -115
- package/hooks/use-dataTable-qry.ts +66 -916
- package/hooks/use-email-qry.helpers.ts +37 -0
- package/hooks/use-email-qry.ts +33 -178
- package/hooks/use-emailCampaignReplyReport-qry.ts +27 -0
- package/hooks/use-fieldDoc-mtn.ts +244 -32
- package/hooks/use-fieldDoc-qry.helpers.test.ts +65 -0
- 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-log-mtn.ts +25 -12
- package/hooks/use-log-qry.ts +99 -46
- package/hooks/use-organization-qry.ts +16 -60
- package/hooks/use-publicFormEmail-mtn.ts +27 -0
- package/hooks/use-qrCode-mtn.ts +40 -0
- package/hooks/use-qrCode-qry.ts +78 -0
- package/hooks/use-schedule-mtn.ts +506 -333
- package/hooks/use-schedule-qry.ts +682 -101
- package/hooks/use-schedule-reactive.ts +486 -0
- package/hooks/use-sheet-mtn.ts +91 -199
- package/hooks/use-sheet-qry.ts +84 -238
- package/hooks/use-storage-qry.ts +84 -61
- package/hooks/use-workflow-mtn.ts +39 -22
- package/hooks/use-workflow-qry.ts +40 -61
- 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/fragment-realtime-sequence.ts +55 -0
- package/libs/fragment-recovery.test.ts +326 -0
- package/libs/fragment-recovery.ts +325 -0
- package/libs/open-sheet.ts +138 -0
- package/libs/orchestrator-realtime.helpers.test.ts +229 -0
- package/libs/orchestrator-realtime.helpers.ts +317 -0
- package/libs/orchestrator-realtime.ts +433 -0
- package/libs/request-cache-regression.test.ts +122 -0
- package/{client → libs}/request-managed-session.test.ts +1 -1
- package/libs/request-no-store.test.ts +419 -0
- package/libs/sheet-command-batch.ts +44 -0
- package/libs/sheet-view-realtime-router.test.ts +214 -0
- package/libs/sheet-view-realtime-router.ts +99 -0
- package/loaders/campaign.test.ts +186 -0
- package/loaders/campaign.ts +56 -83
- package/loaders/emailPreference.ts +75 -0
- package/loaders/rest.ts +12 -0
- package/package.json +42 -17
- package/schedule.d.ts +1790 -0
- package/sse.helpers.ts +19 -0
- package/sse.ts +26 -115
- package/tests/agent-note-detail-cache.test.ts +120 -0
- package/tests/agent-note-search.test.ts +444 -0
- package/types.d.ts +46 -25
- 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-no-store.test.ts +0 -157
- package/gql/fragments/agentDocFragments.ts +0 -46
- package/gql/fragments/billingFragments.ts +0 -14
- package/gql/mutations/agentDocMutations.ts +0 -177
- package/gql/queries/agentDocQueries.ts +0 -120
- package/hooks/use-agentDoc-mtn.ts +0 -285
- package/hooks/use-agentDoc-qry.ts +0 -208
- /package/{client → libs}/sse-ticket.test.ts +0 -0
package/cache/store.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { graphQLValuesEqual } from './value.helpers.ts';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Versioned normalized store core for the GraphQL client cache.
|
|
3
5
|
*
|
|
@@ -59,64 +61,6 @@ function mergeIntoActiveCapture(deps: Map<string, number>) {
|
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
/**
|
|
63
|
-
* Fast deep equality with reference short-circuit; used to skip version bumps
|
|
64
|
-
* for writes that re-assert identical data (common with realtime echoes and
|
|
65
|
-
* refetches), which keeps memoized reads and downstream renders stable.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
function deepEqual(a: any, b: any): boolean {
|
|
69
|
-
if (a === b) {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
typeof a !== typeof b ||
|
|
75
|
-
a === null ||
|
|
76
|
-
b === null ||
|
|
77
|
-
typeof a !== 'object'
|
|
78
|
-
) {
|
|
79
|
-
// NaN never equals itself, but the cache never stores NaN meaningfully
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const aIsArray = Array.isArray(a);
|
|
84
|
-
if (aIsArray !== Array.isArray(b)) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (aIsArray) {
|
|
89
|
-
if (a.length !== b.length) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
for (let i = 0; i < a.length; i++) {
|
|
94
|
-
if (!deepEqual(a[i], b[i])) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const aKeys = Object.keys(a);
|
|
103
|
-
const bKeys = Object.keys(b);
|
|
104
|
-
if (aKeys.length !== bKeys.length) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
for (const key of aKeys) {
|
|
109
|
-
if (
|
|
110
|
-
!Object.prototype.hasOwnProperty.call(b, key) ||
|
|
111
|
-
!deepEqual(a[key], b[key])
|
|
112
|
-
) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
64
|
/**
|
|
121
65
|
* Map-compatible facade over a versioned entry map. get() records a memo
|
|
122
66
|
* dependency and touches the LRU stamp; set() bumps the version only when the
|
|
@@ -172,7 +116,7 @@ export class VersionedKeyMap {
|
|
|
172
116
|
const entry = this.entries.get(key);
|
|
173
117
|
|
|
174
118
|
if (entry) {
|
|
175
|
-
if (
|
|
119
|
+
if (graphQLValuesEqual(entry.data, data)) {
|
|
176
120
|
// Keep the previously stored reference so memoized assemblies built
|
|
177
121
|
// from it remain valid; the write changes nothing observable.
|
|
178
122
|
entry.at = nextTick();
|
|
@@ -307,6 +251,19 @@ class GraphQLCacheStore {
|
|
|
307
251
|
return this.queryFetchTimes.get(queryKey);
|
|
308
252
|
}
|
|
309
253
|
|
|
254
|
+
/* A partial/error response may update visible fields but cannot certify freshness. */
|
|
255
|
+
clearQueryFetchTime(queryKey: string): void {
|
|
256
|
+
if (this.queryFetchTimes.delete(queryKey)) this.queueDirty(this.dirtyQueryKeys, queryKey);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Re-emit one fragment dirty notification without changing its cache version.
|
|
261
|
+
* This lets transient memory-only writes persist their settled final value.
|
|
262
|
+
*/
|
|
263
|
+
markFragmentDirty(fragmentKey: string): void {
|
|
264
|
+
this.queueDirty(this.dirtyFragmentKeys, fragmentKey);
|
|
265
|
+
}
|
|
266
|
+
|
|
310
267
|
/** Restore one persisted fetch stamp at boot (never marks dirty). */
|
|
311
268
|
hydrateQueryFetchTime(queryKey: string, fetchedAt: number): void {
|
|
312
269
|
if (!this.queryFetchTimes.has(queryKey)) {
|
|
@@ -410,11 +367,12 @@ class GraphQLCacheStore {
|
|
|
410
367
|
let stamp = '';
|
|
411
368
|
|
|
412
369
|
for (const key of fragmentKeys) {
|
|
413
|
-
stamp +=
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
'
|
|
370
|
+
stamp += this.fragments.version(key) + '.' + this.fragments.version(`${key}.spreads`) + '|';
|
|
371
|
+
// A parent can assemble nested references without its own record
|
|
372
|
+
// changing. Include those dependencies when checking a notification.
|
|
373
|
+
for (const dependency of MEMO.get(key)?.deps.keys() || []) {
|
|
374
|
+
stamp += this.versionOfNamespacedKey(dependency) + '.';
|
|
375
|
+
}
|
|
418
376
|
}
|
|
419
377
|
|
|
420
378
|
return stamp;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Compare JSON-shaped GraphQL values without serializing or depending on key
|
|
3
|
+
* insertion order. Missing fields remain distinct from explicit undefined/null.
|
|
4
|
+
*/
|
|
5
|
+
export function graphQLValuesEqual(left: any, right: any): boolean {
|
|
6
|
+
if (left === right) return true;
|
|
7
|
+
if (left === null || right === null || typeof left !== 'object' || typeof right !== 'object') return false;
|
|
8
|
+
if (Array.isArray(left) !== Array.isArray(right)) return false;
|
|
9
|
+
if (Array.isArray(left)) {
|
|
10
|
+
return left.length === right.length && left.every((value, index) => graphQLValuesEqual(value, right[index]));
|
|
11
|
+
}
|
|
12
|
+
const keys = Object.keys(left);
|
|
13
|
+
return (
|
|
14
|
+
keys.length === Object.keys(right).length &&
|
|
15
|
+
keys.every((key) => Object.hasOwn(right, key) && graphQLValuesEqual(left[key], right[key]))
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -229,17 +229,21 @@ function openDatabase(): Promise<IDBDatabase | null> {
|
|
|
229
229
|
/**
|
|
230
230
|
* Read one record, honoring the reader's TTL. Expired records resolve null and
|
|
231
231
|
* are removed. The in-memory mirror answers first so a read that follows a
|
|
232
|
-
* write in the same session never races the disk transaction.
|
|
232
|
+
* write in the same session never races the disk transaction. A fresh read
|
|
233
|
+
* skips the mirror to see what other tabs wrote since, unless IndexedDB is
|
|
234
|
+
* unusable (then the mirror is all there is).
|
|
233
235
|
*/
|
|
234
236
|
|
|
235
237
|
export async function readDraftRecord(
|
|
236
238
|
key: string,
|
|
237
239
|
ttlHours: number,
|
|
240
|
+
fresh = false,
|
|
238
241
|
): Promise<DraftRecord | null> {
|
|
239
242
|
const now = Date.now();
|
|
240
243
|
const memoryRecord = MEMORY_RECORDS.get(key);
|
|
244
|
+
const freshDb = fresh ? await openDatabase() : null;
|
|
241
245
|
|
|
242
|
-
if (memoryRecord) {
|
|
246
|
+
if (memoryRecord && !freshDb) {
|
|
243
247
|
if (getRecordExpiresAt(memoryRecord, ttlHours) > now) {
|
|
244
248
|
return memoryRecord;
|
|
245
249
|
}
|
|
@@ -249,7 +253,7 @@ export async function readDraftRecord(
|
|
|
249
253
|
return null;
|
|
250
254
|
}
|
|
251
255
|
|
|
252
|
-
const db = await openDatabase();
|
|
256
|
+
const db = freshDb || (await openDatabase());
|
|
253
257
|
if (!db) {
|
|
254
258
|
return null;
|
|
255
259
|
}
|
|
@@ -361,6 +365,18 @@ export async function deleteDraftRecord(key: string): Promise<void> {
|
|
|
361
365
|
try {
|
|
362
366
|
const tx = db.transaction(STORE_CONSTANTS.draftsStore, 'readwrite');
|
|
363
367
|
tx.objectStore(STORE_CONSTANTS.draftsStore).delete(key);
|
|
368
|
+
|
|
369
|
+
await new Promise<void>((resolve) => {
|
|
370
|
+
tx.oncomplete = () => resolve();
|
|
371
|
+
tx.onerror = () => {
|
|
372
|
+
disableDatabase(tx.error);
|
|
373
|
+
resolve();
|
|
374
|
+
};
|
|
375
|
+
tx.onabort = () => {
|
|
376
|
+
disableDatabase(tx.error || 'transaction aborted');
|
|
377
|
+
resolve();
|
|
378
|
+
};
|
|
379
|
+
});
|
|
364
380
|
} catch (err) {
|
|
365
381
|
disableDatabase(err);
|
|
366
382
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
peekDraftRecord,
|
|
10
10
|
readDraftRecord,
|
|
11
11
|
writeDraftRecord,
|
|
12
|
-
} from './
|
|
12
|
+
} from './draft-persistence-indexed-db.ts';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Expiring local objects ("drafts").
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
* server-side entity: composer text, selected uploads, form-in-progress.
|
|
21
21
|
*
|
|
22
22
|
* Keys are namespaced by the caller. The convention is
|
|
23
|
-
* "feature:version:scopeId", e.g. `
|
|
23
|
+
* "feature:version:scopeId", e.g. `createCampaign:v2:${orgId}` — the
|
|
24
24
|
* scope segment keeps one organization's draft out of another's, and the
|
|
25
25
|
* version segment is the escape hatch for a shape change the schema cannot
|
|
26
26
|
* catch (a field that keeps its type but changes its meaning).
|
|
@@ -40,6 +40,8 @@ export interface DraftOptions<T> {
|
|
|
40
40
|
schema?: DraftSchema;
|
|
41
41
|
/* Read: how old a record may be. Write: the sweep hint stored with it */
|
|
42
42
|
ttlHours?: number;
|
|
43
|
+
/* Read only: skip this tab's session mirror to see other tabs' writes */
|
|
44
|
+
fresh?: boolean;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
export const DRAFT_TTL_HOURS_DEFAULT = 24;
|
|
@@ -83,6 +85,7 @@ export async function getDraft<T>(
|
|
|
83
85
|
const record = await readDraftRecord(
|
|
84
86
|
key,
|
|
85
87
|
options?.ttlHours ?? DRAFT_TTL_HOURS_DEFAULT,
|
|
88
|
+
options?.fresh,
|
|
86
89
|
);
|
|
87
90
|
return resolveDraftValue<T>(record?.d, options);
|
|
88
91
|
}
|
package/client/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from '../hooks/index.ts';
|
|
2
|
-
export * from '
|
|
3
|
-
export * from '
|
|
2
|
+
export * from '../libs/fragment-realtime-sequence.ts';
|
|
3
|
+
export * from '../libs/fragment-recovery.ts';
|
|
4
|
+
export * from '../libs/open-sheet.ts';
|
|
4
5
|
export * from './request.ts';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Convert native fetch TypeError rejections to the shared network-error shape.
|
|
3
|
+
* Call only at the fetch boundary so parsing and application failures keep
|
|
4
|
+
* their original classification; cancellation and other errors pass through.
|
|
5
|
+
*/
|
|
6
|
+
export function rethrowGraphQLFetchError(error: unknown): never {
|
|
7
|
+
if (error instanceof TypeError) {
|
|
8
|
+
throw {
|
|
9
|
+
errors: [{ errorCode: 'network_error', statusCode: 500 }],
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
throw error;
|
|
14
|
+
}
|