@jsb188/graphql 1.1.10 → 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.
Files changed (176) hide show
  1. package/audience.d.ts +343 -0
  2. package/cache/config.ts +98 -50
  3. package/cache/index.chat-activity.test.ts +119 -0
  4. package/cache/index.chat.test.ts +92 -0
  5. package/cache/index.helpers.ts +96 -0
  6. package/cache/index.regression.test.ts +149 -0
  7. package/cache/index.test.ts +1017 -127
  8. package/cache/index.ts +1256 -1269
  9. package/cache/optimistic-ui-runtime.ts +46 -0
  10. package/cache/optimistic-ui.ts +401 -0
  11. package/cache/persist.ts +800 -0
  12. package/cache/store.ts +395 -0
  13. package/cache/value.helpers.ts +17 -0
  14. package/client/draft-persistence-indexed-db.ts +413 -0
  15. package/client/draft-persistence.ts +152 -0
  16. package/client/index.ts +3 -0
  17. package/client/request.helpers.ts +14 -0
  18. package/client/request.ts +870 -164
  19. package/deno.lock +187 -0
  20. package/deno.test.json +10 -4
  21. package/gql/eagerQueryMap.ts +12 -0
  22. package/gql/fragments/accountAuthFragments.ts +5 -0
  23. package/gql/fragments/accountFragments.ts +0 -3
  24. package/gql/fragments/accountSessionFragments.ts +16 -0
  25. package/gql/fragments/agentMemoryFragments.ts +23 -0
  26. package/gql/fragments/agentNoteFragments.ts +150 -0
  27. package/gql/fragments/aiChatFragments.ts +42 -0
  28. package/gql/fragments/audienceFragments.ts +141 -0
  29. package/gql/fragments/campaignFragments.ts +566 -0
  30. package/gql/fragments/dataTableFragments.ts +50 -192
  31. package/gql/fragments/emailFragments.ts +32 -17
  32. package/gql/fragments/fieldDocFragments.ts +264 -0
  33. package/gql/fragments/inboundContactFragments.ts +2 -0
  34. package/gql/fragments/logFragments.ts +101 -69
  35. package/gql/fragments/organizationFragments.ts +53 -5
  36. package/gql/fragments/qrCodeFragments.ts +29 -0
  37. package/gql/fragments/scheduleFragments.ts +667 -0
  38. package/gql/fragments/sheetFragments.ts +304 -63
  39. package/gql/fragments/storageFragments.ts +45 -0
  40. package/gql/fragments/workflowFragments.ts +41 -5
  41. package/gql/mutations/accountMutations.ts +0 -2
  42. package/gql/mutations/agentMemoryMutations.ts +68 -0
  43. package/gql/mutations/agentNoteMutations.ts +62 -0
  44. package/gql/mutations/aiChatMutations.ts +49 -4
  45. package/gql/mutations/audienceMutations.ts +71 -0
  46. package/gql/mutations/authMutations.ts +203 -18
  47. package/gql/mutations/billingMutations.ts +17 -27
  48. package/gql/mutations/campaignMutations.ts +258 -0
  49. package/gql/mutations/contactMutations.ts +23 -0
  50. package/gql/mutations/dataTableMutations.ts +19 -54
  51. package/gql/mutations/fieldDocMutations.ts +173 -0
  52. package/gql/mutations/index.ts +10 -2
  53. package/gql/mutations/logMutations.ts +6 -29
  54. package/gql/mutations/organizationMutations.ts +19 -4
  55. package/gql/mutations/qrCodeMutations.ts +20 -0
  56. package/gql/mutations/scheduleMutations.ts +1121 -0
  57. package/gql/mutations/sheetMutations.ts +221 -60
  58. package/gql/mutations/storageMutations.ts +19 -0
  59. package/gql/mutations/workflowMutations.ts +60 -0
  60. package/gql/queries/agentMemoryQueries.ts +28 -0
  61. package/gql/queries/agentNoteQueries.ts +89 -0
  62. package/gql/queries/aiChatQueries.ts +70 -2
  63. package/gql/queries/audienceQueries.ts +128 -0
  64. package/gql/queries/authQueries.ts +47 -0
  65. package/gql/queries/billingQueries.ts +118 -6
  66. package/gql/queries/campaignQueries.ts +236 -0
  67. package/gql/queries/dataTableQueries.ts +61 -13
  68. package/gql/queries/emailQueries.ts +26 -17
  69. package/gql/queries/emailReplyReportQueries.ts +76 -0
  70. package/gql/queries/fieldDocQueries.ts +166 -0
  71. package/gql/queries/inboundContactQueries.ts +4 -0
  72. package/gql/queries/index.ts +10 -2
  73. package/gql/queries/logQueries.ts +68 -30
  74. package/gql/queries/organizationQueries.ts +65 -1
  75. package/gql/queries/qrCodeQueries.ts +20 -0
  76. package/gql/queries/scheduleQueries.ts +691 -0
  77. package/gql/queries/sheetQueries.ts +244 -26
  78. package/gql/queries/storageQueries.ts +38 -0
  79. package/gql/queries/workflowQueries.ts +77 -2
  80. package/hooks/index.helpers.test.ts +50 -0
  81. package/hooks/index.helpers.ts +52 -0
  82. package/hooks/index.ts +2254 -982
  83. package/hooks/use-account-mtn.ts +76 -81
  84. package/hooks/use-agentMemory-mtn.ts +71 -0
  85. package/hooks/use-agentMemory-qry.ts +56 -0
  86. package/hooks/use-agentNote-mtn.ts +82 -0
  87. package/hooks/use-agentNote-qry.ts +190 -0
  88. package/hooks/use-agentNote-recovery.helpers.test.ts +68 -0
  89. package/hooks/use-agentNote-recovery.helpers.ts +58 -0
  90. package/hooks/use-agentNote-recovery.ts +72 -0
  91. package/hooks/use-aiChat-mtn.ts +220 -141
  92. package/hooks/use-aiChat-qry.helpers.test.ts +63 -0
  93. package/hooks/use-aiChat-qry.helpers.ts +124 -0
  94. package/hooks/use-aiChat-qry.ts +341 -237
  95. package/hooks/use-aiChat-stream-mtn.ts +14 -0
  96. package/hooks/use-app-qry.ts +12 -9
  97. package/hooks/use-audience-mtn.ts +194 -0
  98. package/hooks/use-audience-qry.helpers.test.ts +80 -0
  99. package/hooks/use-audience-qry.helpers.ts +63 -0
  100. package/hooks/use-audience-qry.ts +330 -0
  101. package/hooks/use-auth-mtn.ts +435 -252
  102. package/hooks/use-auth-qry.ts +51 -0
  103. package/hooks/use-billing-mtn.ts +31 -0
  104. package/hooks/use-billing-qry.ts +76 -0
  105. package/hooks/use-campaign-generation-recovery.ts +53 -0
  106. package/hooks/use-campaign-mtn.ts +436 -0
  107. package/hooks/use-campaign-qry.helpers.ts +40 -0
  108. package/hooks/use-campaign-qry.ts +834 -0
  109. package/hooks/use-dataTable-mtn.ts +37 -46
  110. package/hooks/use-dataTable-qry.ts +102 -128
  111. package/hooks/use-email-qry.helpers.ts +37 -0
  112. package/hooks/use-email-qry.ts +56 -86
  113. package/hooks/use-emailCampaignReplyReport-qry.ts +27 -0
  114. package/hooks/use-fieldDoc-mtn.ts +262 -0
  115. package/hooks/use-fieldDoc-qry.helpers.test.ts +65 -0
  116. package/hooks/use-fieldDoc-qry.helpers.ts +49 -0
  117. package/hooks/use-fieldDoc-qry.ts +212 -0
  118. package/hooks/use-inboundContact-mtn.ts +19 -16
  119. package/hooks/use-inboundContact-qry.ts +62 -56
  120. package/hooks/use-integration-mtn.ts +56 -38
  121. package/hooks/use-integration-qry.ts +24 -9
  122. package/hooks/use-log-mtn.ts +88 -59
  123. package/hooks/use-log-qry.ts +150 -73
  124. package/hooks/use-organization-mtn.ts +334 -277
  125. package/hooks/use-organization-qry.ts +155 -129
  126. package/hooks/use-publicFormEmail-mtn.ts +27 -0
  127. package/hooks/use-qrCode-mtn.ts +40 -0
  128. package/hooks/use-qrCode-qry.ts +78 -0
  129. package/hooks/use-schedule-mtn.ts +589 -0
  130. package/hooks/use-schedule-qry.ts +738 -0
  131. package/hooks/use-schedule-reactive.ts +486 -0
  132. package/hooks/use-sheet-mtn.ts +157 -79
  133. package/hooks/use-sheet-qry.ts +221 -92
  134. package/hooks/use-storage-mtn.ts +81 -41
  135. package/hooks/use-storage-qry.ts +128 -14
  136. package/hooks/use-workflow-mtn.ts +72 -0
  137. package/hooks/use-workflow-qry.ts +184 -47
  138. package/libs/ai-chat-outgoing.helpers.ts +153 -0
  139. package/libs/ai-chat-outgoing.ts +11 -0
  140. package/libs/ai-chat-outgoing.types.ts +25 -0
  141. package/libs/ai-chat-run-realtime.ts +20 -0
  142. package/libs/ai-chat-submission-realtime.ts +150 -0
  143. package/libs/fragment-realtime-sequence.ts +55 -0
  144. package/libs/fragment-recovery.test.ts +326 -0
  145. package/libs/fragment-recovery.ts +325 -0
  146. package/libs/open-sheet.ts +138 -0
  147. package/libs/orchestrator-realtime.helpers.test.ts +229 -0
  148. package/libs/orchestrator-realtime.helpers.ts +317 -0
  149. package/libs/orchestrator-realtime.ts +433 -0
  150. package/libs/request-cache-regression.test.ts +122 -0
  151. package/libs/request-managed-session.test.ts +574 -0
  152. package/libs/request-no-store.test.ts +419 -0
  153. package/libs/sheet-command-batch.ts +44 -0
  154. package/libs/sheet-view-realtime-router.test.ts +214 -0
  155. package/libs/sheet-view-realtime-router.ts +99 -0
  156. package/libs/sse-ticket.test.ts +26 -0
  157. package/loaders/campaign.test.ts +186 -0
  158. package/loaders/campaign.ts +110 -0
  159. package/loaders/emailPreference.ts +75 -0
  160. package/loaders/rest.ts +12 -0
  161. package/package.json +119 -71
  162. package/schedule.d.ts +1790 -0
  163. package/sse.helpers.ts +19 -0
  164. package/sse.ts +70 -106
  165. package/tests/agent-note-detail-cache.test.ts +120 -0
  166. package/tests/agent-note-search.test.ts +444 -0
  167. package/tsconfig.json +11 -10
  168. package/types.d.ts +77 -26
  169. package/utils.ts +78 -49
  170. package/gql/fragments/billingFragments.ts +0 -25
  171. package/gql/fragments/productFragments.ts +0 -39
  172. package/gql/fragments/reportFragments.ts +0 -90
  173. package/gql/queries/productQueries.ts +0 -31
  174. package/gql/queries/reportQueries.ts +0 -134
  175. package/hooks/use-product-qry.ts +0 -67
  176. package/hooks/use-report-qry.ts +0 -153
package/cache/store.ts ADDED
@@ -0,0 +1,395 @@
1
+ import { graphQLValuesEqual } from './value.helpers.ts';
2
+
3
+ /**
4
+ * Versioned normalized store core for the GraphQL client cache.
5
+ *
6
+ * Wraps plain Maps with per-key version stamps so read assembly
7
+ * (loadFragment/loadQuery) can be memoized with structural sharing, writes
8
+ * that do not change data never invalidate anything, eviction can be LRU
9
+ * instead of FIFO, and a persistence adapter can subscribe to every write
10
+ * regardless of its source (query result, mutation result, realtime event).
11
+ *
12
+ * This module is internal to the cache; the public cache API in ./index.ts
13
+ * is unchanged.
14
+ */
15
+
16
+ /**
17
+ * Monotonic clock shared by version stamps and LRU access stamps.
18
+ * Never reused, so a deleted-and-recreated key always invalidates memo
19
+ * entries that captured the old version.
20
+ */
21
+
22
+ let TICK = 1;
23
+
24
+ function nextTick(): number {
25
+ TICK += 1;
26
+ return TICK;
27
+ }
28
+
29
+ type StoreEntry = {
30
+ data: any;
31
+ v: number; // version stamp; bumped only when data actually changes
32
+ at: number; // last access stamp for LRU eviction
33
+ };
34
+
35
+ type DirtyListener = (dirty: {
36
+ fragmentKeys: Set<string>;
37
+ queryKeys: Set<string>;
38
+ }) => void;
39
+
40
+ /**
41
+ * Dependency capture stack for memoized reads. Reads record (namespacedKey ->
42
+ * version) into the top capture only; memoize() merges each finished capture
43
+ * into the parent capture so nested memo hits still propagate their deps.
44
+ */
45
+
46
+ const CAPTURE_STACK: Array<Map<string, number>> = [];
47
+
48
+ function recordDependency(namespacedKey: string, version: number) {
49
+ const activeCapture = CAPTURE_STACK[CAPTURE_STACK.length - 1];
50
+ if (activeCapture) {
51
+ activeCapture.set(namespacedKey, version);
52
+ }
53
+ }
54
+
55
+ function mergeIntoActiveCapture(deps: Map<string, number>) {
56
+ const activeCapture = CAPTURE_STACK[CAPTURE_STACK.length - 1];
57
+ if (activeCapture) {
58
+ deps.forEach((version, key) => {
59
+ activeCapture.set(key, version);
60
+ });
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Map-compatible facade over a versioned entry map. get() records a memo
66
+ * dependency and touches the LRU stamp; set() bumps the version only when the
67
+ * data actually changed and reports the key as dirty for subscribers.
68
+ */
69
+
70
+ export class VersionedKeyMap {
71
+ private entries = new Map<string, StoreEntry>();
72
+ private namespace: string;
73
+ private markDirty: (key: string) => void;
74
+ private onDelete?: (key: string) => void;
75
+
76
+ constructor(
77
+ namespace: string,
78
+ markDirty: (key: string) => void,
79
+ onDelete?: (key: string) => void,
80
+ ) {
81
+ this.namespace = namespace;
82
+ this.markDirty = markDirty;
83
+ this.onDelete = onDelete;
84
+ }
85
+
86
+ get size(): number {
87
+ return this.entries.size;
88
+ }
89
+
90
+ get(key: string): any {
91
+ const entry = this.entries.get(key);
92
+ recordDependency(this.namespace + key, entry?.v || 0);
93
+
94
+ if (!entry) {
95
+ return undefined;
96
+ }
97
+
98
+ entry.at = nextTick();
99
+ return entry.data;
100
+ }
101
+
102
+ /** Read without recording a dependency or touching the LRU stamp. */
103
+ peek(key: string): any {
104
+ return this.entries.get(key)?.data;
105
+ }
106
+
107
+ version(key: string): number {
108
+ return this.entries.get(key)?.v || 0;
109
+ }
110
+
111
+ lastAccess(key: string): number {
112
+ return this.entries.get(key)?.at || 0;
113
+ }
114
+
115
+ set(key: string, data: any): void {
116
+ const entry = this.entries.get(key);
117
+
118
+ if (entry) {
119
+ if (graphQLValuesEqual(entry.data, data)) {
120
+ // Keep the previously stored reference so memoized assemblies built
121
+ // from it remain valid; the write changes nothing observable.
122
+ entry.at = nextTick();
123
+ return;
124
+ }
125
+
126
+ entry.data = data;
127
+ entry.v = nextTick();
128
+ entry.at = entry.v;
129
+ } else {
130
+ const stamp = nextTick();
131
+ this.entries.set(key, { data, v: stamp, at: stamp });
132
+ }
133
+
134
+ this.markDirty(key);
135
+ }
136
+
137
+ /**
138
+ * Load one persisted entry at boot. In-memory data always wins (it is
139
+ * newer than any snapshot) and hydration never marks the key dirty, so
140
+ * hydrated values cannot echo back into the persistence write buffer.
141
+ * Returns whether the entry was actually added.
142
+ */
143
+ hydrate(key: string, data: any): boolean {
144
+ if (this.entries.has(key)) {
145
+ return false;
146
+ }
147
+
148
+ const stamp = nextTick();
149
+ this.entries.set(key, { data, v: stamp, at: stamp });
150
+ return true;
151
+ }
152
+
153
+ has(key: string): boolean {
154
+ return this.entries.has(key);
155
+ }
156
+
157
+ delete(key: string): boolean {
158
+ const existed = this.entries.delete(key);
159
+ if (existed) {
160
+ this.onDelete?.(key);
161
+ this.markDirty(key);
162
+ }
163
+ return existed;
164
+ }
165
+
166
+ keys(): IterableIterator<string> {
167
+ return this.entries.keys();
168
+ }
169
+
170
+ clear(): void {
171
+ this.entries.clear();
172
+ }
173
+
174
+ /**
175
+ * Return keys ordered least-recently-accessed first, excluding keys the
176
+ * predicate rejects.
177
+ */
178
+ keysByLeastRecentAccess(filter?: (key: string) => boolean): string[] {
179
+ const keys: Array<[string, number]> = [];
180
+
181
+ this.entries.forEach((entry, key) => {
182
+ if (!filter || filter(key)) {
183
+ keys.push([key, entry.at]);
184
+ }
185
+ });
186
+
187
+ keys.sort((a, b) => a[1] - b[1]);
188
+ return keys.map(([key]) => key);
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Memoization for read assembly. An entry is valid while every dependency it
194
+ * captured still has the same version.
195
+ */
196
+
197
+ const MEMO = new Map<string, { value: any; deps: Map<string, number> }>();
198
+ const MEMO_LIMIT = 20000;
199
+
200
+ function dependenciesAreCurrent(
201
+ deps: Map<string, number>,
202
+ versionOf: (namespacedKey: string) => number,
203
+ ): boolean {
204
+ for (const [key, version] of deps) {
205
+ if (versionOf(key) !== version) {
206
+ return false;
207
+ }
208
+ }
209
+
210
+ return true;
211
+ }
212
+
213
+ /**
214
+ * GraphQL cache store singleton: fragment and query namespaces, dirty-key
215
+ * subscriptions for persistence adapters, and memoized read assembly.
216
+ */
217
+
218
+ class GraphQLCacheStore {
219
+ fragments: VersionedKeyMap;
220
+ queries: VersionedKeyMap;
221
+
222
+ private dirtyFragmentKeys = new Set<string>();
223
+ private dirtyQueryKeys = new Set<string>();
224
+ private dirtyListeners = new Set<DirtyListener>();
225
+ private flushScheduled = false;
226
+
227
+ private queryFetchTimes = new Map<string, number>();
228
+
229
+ constructor() {
230
+ this.fragments = new VersionedKeyMap('f:', (key) =>
231
+ this.queueDirty(this.dirtyFragmentKeys, key),
232
+ );
233
+ this.queries = new VersionedKeyMap(
234
+ 'q:',
235
+ (key) => this.queueDirty(this.dirtyQueryKeys, key),
236
+ (key) => this.queryFetchTimes.delete(key),
237
+ );
238
+ }
239
+
240
+ /**
241
+ * Record when one query's data last came from the network. Marks the query
242
+ * dirty so the persisted record carries the stamp even when the response
243
+ * data itself was deep-equal (no version bump, no observer noise).
244
+ */
245
+ setQueryFetchTime(queryKey: string, fetchedAt: number): void {
246
+ this.queryFetchTimes.set(queryKey, fetchedAt);
247
+ this.queueDirty(this.dirtyQueryKeys, queryKey);
248
+ }
249
+
250
+ getQueryFetchTime(queryKey: string): number | undefined {
251
+ return this.queryFetchTimes.get(queryKey);
252
+ }
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
+
267
+ /** Restore one persisted fetch stamp at boot (never marks dirty). */
268
+ hydrateQueryFetchTime(queryKey: string, fetchedAt: number): void {
269
+ if (!this.queryFetchTimes.has(queryKey)) {
270
+ this.queryFetchTimes.set(queryKey, fetchedAt);
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Subscribe to batched dirty-key notifications (microtask-coalesced).
276
+ * Returns the unsubscribe function. This is the single hook point for the
277
+ * IndexedDB persistence adapter: every fragment/query write from any source
278
+ * lands here.
279
+ */
280
+ subscribe(listener: DirtyListener): () => void {
281
+ this.dirtyListeners.add(listener);
282
+ return () => {
283
+ this.dirtyListeners.delete(listener);
284
+ };
285
+ }
286
+
287
+ private queueDirty(dirtySet: Set<string>, key: string) {
288
+ if (!this.dirtyListeners.size) {
289
+ return;
290
+ }
291
+
292
+ dirtySet.add(key);
293
+
294
+ if (!this.flushScheduled) {
295
+ this.flushScheduled = true;
296
+ queueMicrotask(() => this.flushDirty());
297
+ }
298
+ }
299
+
300
+ private flushDirty() {
301
+ this.flushScheduled = false;
302
+
303
+ if (!this.dirtyFragmentKeys.size && !this.dirtyQueryKeys.size) {
304
+ return;
305
+ }
306
+
307
+ const dirty = {
308
+ fragmentKeys: this.dirtyFragmentKeys,
309
+ queryKeys: this.dirtyQueryKeys,
310
+ };
311
+ this.dirtyFragmentKeys = new Set();
312
+ this.dirtyQueryKeys = new Set();
313
+
314
+ this.dirtyListeners.forEach((listener) => {
315
+ listener(dirty);
316
+ });
317
+ }
318
+
319
+ private versionOfNamespacedKey = (namespacedKey: string): number => {
320
+ if (namespacedKey.startsWith('f:')) {
321
+ return this.fragments.version(namespacedKey.substring(2));
322
+ }
323
+
324
+ return this.queries.version(namespacedKey.substring(2));
325
+ };
326
+
327
+ /**
328
+ * Memoize one read assembly with automatic dependency tracking. While the
329
+ * captured dependencies are unchanged, the exact same value reference is
330
+ * returned, which is what makes render-level reference-equality checks work.
331
+ */
332
+ memoizeRead<T>(memoKey: string, compute: () => T): T {
333
+ const hit = MEMO.get(memoKey);
334
+ if (hit && dependenciesAreCurrent(hit.deps, this.versionOfNamespacedKey)) {
335
+ mergeIntoActiveCapture(hit.deps);
336
+ return hit.value;
337
+ }
338
+
339
+ const capture = new Map<string, number>();
340
+ CAPTURE_STACK.push(capture);
341
+
342
+ let value: T;
343
+ try {
344
+ value = compute();
345
+ } finally {
346
+ CAPTURE_STACK.pop();
347
+ }
348
+
349
+ mergeIntoActiveCapture(capture);
350
+
351
+ if (MEMO.size >= MEMO_LIMIT) {
352
+ // Rare full reset is cheaper and simpler than per-entry LRU here;
353
+ // entries rebuild lazily on the next read.
354
+ MEMO.clear();
355
+ }
356
+ MEMO.set(memoKey, { value, deps: capture });
357
+
358
+ return value;
359
+ }
360
+
361
+ /**
362
+ * Build a combined version stamp for a set of fragment keys. Callers can
363
+ * compare stamps to know whether any of the fragments (or their spreads)
364
+ * changed without loading them.
365
+ */
366
+ getFragmentVersionStamp(fragmentKeys: string[]): string {
367
+ let stamp = '';
368
+
369
+ for (const key of fragmentKeys) {
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
+ }
376
+ }
377
+
378
+ return stamp;
379
+ }
380
+
381
+ clearMemo(): void {
382
+ MEMO.clear();
383
+ }
384
+
385
+ clearAll(): void {
386
+ this.fragments.clear();
387
+ this.queries.clear();
388
+ this.queryFetchTimes.clear();
389
+ MEMO.clear();
390
+ this.dirtyFragmentKeys.clear();
391
+ this.dirtyQueryKeys.clear();
392
+ }
393
+ }
394
+
395
+ export const cacheStore = new GraphQLCacheStore();
@@ -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
+ }