@jsb188/graphql 1.1.8 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cache/config.ts +66 -42
- package/cache/index.test.ts +881 -0
- package/cache/index.ts +1815 -979
- package/cache/persist.ts +721 -0
- package/cache/store.ts +437 -0
- package/client/data-table-realtime-subscriptions.test.ts +740 -0
- package/client/data-table-realtime-subscriptions.ts +955 -0
- package/client/data-table-realtime.test.ts +792 -0
- package/client/data-table-realtime.ts +1218 -0
- package/client/fragment-realtime-sequence.ts +52 -0
- package/client/index.ts +4 -2
- package/client/open-sheet.ts +137 -0
- package/client/request-managed-session.test.ts +574 -0
- package/client/request-no-store.test.ts +157 -0
- package/client/request.ts +973 -143
- package/client/sse-ticket.test.ts +26 -0
- package/deno.lock +170 -0
- package/deno.test.json +10 -0
- package/drafts/index.ts +149 -0
- package/drafts/store.ts +397 -0
- package/gql/eagerQueryMap.ts +12 -0
- package/gql/fragments/accountAuthFragments.ts +5 -0
- package/gql/fragments/accountFragments.ts +1 -3
- package/gql/fragments/accountSessionFragments.ts +16 -0
- package/gql/fragments/agentDocFragments.ts +46 -0
- package/gql/fragments/agentMemoryFragments.ts +19 -0
- package/gql/fragments/aiChatFragments.ts +17 -0
- package/gql/fragments/billingFragments.ts +0 -11
- package/gql/fragments/campaignFragments.ts +277 -0
- package/gql/fragments/dataTableFragments.ts +102 -0
- package/gql/fragments/emailFragments.ts +36 -0
- package/gql/fragments/fieldDocFragments.ts +82 -0
- package/gql/fragments/inboundContactFragments.ts +15 -0
- package/gql/fragments/integrationFragments.ts +22 -0
- package/gql/fragments/logFragments.ts +33 -64
- package/gql/fragments/organizationFragments.ts +94 -21
- package/gql/fragments/scheduleFragments.ts +155 -0
- package/gql/fragments/sheetFragments.ts +675 -0
- package/gql/fragments/storageFragments.ts +21 -1
- package/gql/fragments/workflowFragments.ts +67 -0
- package/gql/mutations/accountMutations.ts +24 -4
- package/gql/mutations/agentDocMutations.ts +177 -0
- package/gql/mutations/agentMemoryMutations.ts +36 -0
- package/gql/mutations/aiChatMutations.ts +43 -3
- package/gql/mutations/authMutations.ts +160 -19
- package/gql/mutations/campaignMutations.ts +215 -0
- package/gql/mutations/dataTableMutations.ts +106 -0
- package/gql/mutations/fieldDocMutations.ts +24 -0
- package/gql/mutations/inboundContactMutations.ts +24 -0
- package/gql/mutations/index.ts +17 -8
- package/gql/mutations/integrationMutations.ts +25 -0
- package/gql/mutations/logMutations.ts +10 -19
- package/gql/mutations/organizationMutations.ts +160 -2
- package/gql/mutations/scheduleMutations.ts +423 -0
- package/gql/mutations/sheetMutations.ts +385 -0
- package/gql/mutations/storageMutations.ts +21 -2
- package/gql/mutations/workflowMutations.ts +42 -0
- package/gql/queries/agentDocQueries.ts +120 -0
- package/gql/queries/agentMemoryQueries.ts +22 -0
- package/gql/queries/aiChatQueries.ts +18 -2
- package/gql/queries/authQueries.ts +41 -0
- package/gql/queries/billingQueries.ts +24 -1
- package/gql/queries/campaignQueries.ts +127 -0
- package/gql/queries/dataTableQueries.ts +134 -0
- package/gql/queries/emailQueries.ts +96 -0
- package/gql/queries/fieldDocQueries.ts +158 -0
- package/gql/queries/inboundContactQueries.ts +40 -0
- package/gql/queries/index.ts +17 -6
- package/gql/queries/logQueries.ts +42 -32
- package/gql/queries/organizationQueries.ts +113 -8
- package/gql/queries/scheduleQueries.ts +315 -0
- package/gql/queries/sheetQueries.ts +383 -0
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +99 -0
- package/hooks/index.ts +2104 -860
- package/hooks/use-account-mtn.ts +91 -48
- package/hooks/use-agentDoc-mtn.ts +285 -0
- package/hooks/use-agentDoc-qry.ts +208 -0
- package/hooks/use-agentMemory-mtn.ts +73 -0
- package/hooks/use-agentMemory-qry.ts +44 -0
- package/hooks/use-aiChat-mtn.ts +248 -97
- package/hooks/use-aiChat-qry.ts +501 -191
- package/hooks/use-app-qry.ts +14 -11
- package/hooks/use-auth-mtn.ts +410 -256
- package/hooks/use-auth-qry.ts +51 -0
- package/hooks/use-campaign-mtn.ts +377 -0
- package/hooks/use-campaign-qry.ts +257 -0
- package/hooks/use-dataTable-mtn.ts +170 -0
- package/hooks/use-dataTable-qry.ts +996 -0
- package/hooks/use-email-qry.ts +227 -0
- package/hooks/use-fieldDoc-mtn.ts +50 -0
- package/hooks/use-fieldDoc-qry.ts +180 -0
- package/hooks/use-inboundContact-mtn.ts +34 -0
- package/hooks/use-inboundContact-qry.ts +96 -0
- package/hooks/use-integration-mtn.ts +77 -0
- package/hooks/use-integration-qry.ts +30 -0
- package/hooks/use-log-mtn.ts +77 -61
- package/hooks/use-log-qry.ts +99 -72
- package/hooks/use-organization-mtn.ts +409 -80
- package/hooks/use-organization-qry.ts +211 -92
- package/hooks/use-schedule-mtn.ts +416 -0
- package/hooks/use-schedule-qry.ts +157 -0
- package/hooks/use-sheet-mtn.ts +367 -0
- package/hooks/use-sheet-qry.ts +440 -0
- package/hooks/use-storage-mtn.ts +83 -42
- package/hooks/use-storage-qry.ts +104 -13
- package/hooks/use-workflow-mtn.ts +55 -0
- package/hooks/use-workflow-qry.ts +230 -0
- package/loaders/campaign.ts +137 -0
- package/package.json +94 -52
- package/sse.ts +158 -105
- package/tsconfig.json +13 -0
- package/types.d.ts +60 -29
- package/utils.ts +77 -50
- package/gql/fragments/actionFragments.ts +0 -16
- package/gql/fragments/productFragments.ts +0 -63
- package/gql/fragments/reportFragments.ts +0 -48
- package/gql/mutations/billingMutations.ts +0 -34
- package/gql/queries/productQueries.ts +0 -70
- package/gql/queries/reportQueries.ts +0 -66
- package/hooks/use-product-qry.ts +0 -109
- package/hooks/use-report-qry.ts +0 -69
package/drafts/store.ts
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexedDB engine for expiring local objects ("drafts").
|
|
3
|
+
*
|
|
4
|
+
* One object store of independent records, each stamped with its write time
|
|
5
|
+
* and the TTL it was written under. Expiry is evaluated by the reader, so a
|
|
6
|
+
* caller may read a key with a shorter window than it was written with; the
|
|
7
|
+
* stored TTL only drives the background sweep.
|
|
8
|
+
*
|
|
9
|
+
* Best-effort by design and never throws: when IndexedDB is unavailable
|
|
10
|
+
* (server render, private browsing, quota, corruption) every operation falls
|
|
11
|
+
* back to an in-memory mirror, so the API keeps its contract for the rest of
|
|
12
|
+
* the session and only loses durability. Multi-tab writes are last-write-wins.
|
|
13
|
+
*
|
|
14
|
+
* This is deliberately separate from the normalized GraphQL cache database:
|
|
15
|
+
* a quota or corruption failure in one must never disable the other.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface DraftRecord {
|
|
19
|
+
/* Write time, in epoch ms */
|
|
20
|
+
at: number;
|
|
21
|
+
/* Persisted value */
|
|
22
|
+
d: unknown;
|
|
23
|
+
/* Record key */
|
|
24
|
+
k: string;
|
|
25
|
+
/* TTL the record was written under, in hours; drives the sweep only */
|
|
26
|
+
ttl: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const STORE_CONSTANTS = {
|
|
30
|
+
dbName: 'jsb188-drafts',
|
|
31
|
+
dbVersion: 1,
|
|
32
|
+
draftsStore: 'drafts',
|
|
33
|
+
hourMs: 3.6e6,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Module state
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
let DB: IDBDatabase | null = null;
|
|
41
|
+
let OPEN_PROMISE: Promise<IDBDatabase | null> | null = null;
|
|
42
|
+
let DISABLED = false;
|
|
43
|
+
|
|
44
|
+
// Session mirror; the only storage when IndexedDB is unusable, and a
|
|
45
|
+
// synchronous read path for peekDraft() when it is
|
|
46
|
+
const MEMORY_RECORDS = new Map<string, DraftRecord>();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Check whether IndexedDB exists in this runtime (browser only; the server
|
|
50
|
+
* render imports this module through the app's module graph and must no-op).
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
function isIndexedDBAvailable(): boolean {
|
|
54
|
+
return typeof indexedDB !== 'undefined';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Stop using IndexedDB for the rest of the session. The in-memory mirror keeps
|
|
59
|
+
* serving reads and writes, so callers see no behavior change beyond losing
|
|
60
|
+
* durability.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
function disableDatabase(reason: any) {
|
|
64
|
+
DISABLED = true;
|
|
65
|
+
|
|
66
|
+
if (DB) {
|
|
67
|
+
try {
|
|
68
|
+
DB.close();
|
|
69
|
+
} catch (_err) {
|
|
70
|
+
// Already closing/broken; nothing else to do
|
|
71
|
+
}
|
|
72
|
+
DB = null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
(console as any).dev?.('Local draft persistence disabled:', reason);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Promise wrapper for IDBRequest
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
function requestAsPromise<T>(request: IDBRequest<T>): Promise<T> {
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
request.onsuccess = () => resolve(request.result);
|
|
85
|
+
request.onerror = () => reject(request.error);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Compute the epoch ms at which one record stops being readable.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
function getRecordExpiresAt(record: DraftRecord, ttlHours: number): number {
|
|
94
|
+
return record.at + ttlHours * STORE_CONSTANTS.hourMs;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Delete every record whose own stored TTL has elapsed. Runs once per database
|
|
99
|
+
* open; failures are ignored because expired records are skipped at read time
|
|
100
|
+
* regardless of whether the sweep succeeded.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
function sweepExpiredRecords(db: IDBDatabase) {
|
|
104
|
+
try {
|
|
105
|
+
const tx = db.transaction(STORE_CONSTANTS.draftsStore, 'readwrite');
|
|
106
|
+
const cursorRequest = tx
|
|
107
|
+
.objectStore(STORE_CONSTANTS.draftsStore)
|
|
108
|
+
.openCursor();
|
|
109
|
+
const now = Date.now();
|
|
110
|
+
|
|
111
|
+
cursorRequest.onsuccess = () => {
|
|
112
|
+
const cursor = cursorRequest.result;
|
|
113
|
+
if (!cursor) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const record = cursor.value as DraftRecord;
|
|
118
|
+
if (
|
|
119
|
+
!record ||
|
|
120
|
+
typeof record.at !== 'number' ||
|
|
121
|
+
getRecordExpiresAt(record, record.ttl) <= now
|
|
122
|
+
) {
|
|
123
|
+
cursor.delete();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
cursor.continue();
|
|
127
|
+
};
|
|
128
|
+
} catch (_err) {
|
|
129
|
+
// Best-effort only
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Open (and create/upgrade) the drafts database once, sweeping expired records
|
|
135
|
+
* on success. Resolves null when IndexedDB cannot be used.
|
|
136
|
+
*
|
|
137
|
+
* allowRecovery lets one store-less database be rebuilt from scratch. A
|
|
138
|
+
* versionless open elsewhere (devtools, another library, an older build)
|
|
139
|
+
* creates the database with no object stores, and without this the engine
|
|
140
|
+
* would stay disabled for every future session rather than for one.
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
function openDatabaseOnce(allowRecovery: boolean): Promise<IDBDatabase | null> {
|
|
144
|
+
return new Promise<IDBDatabase | null>((resolve) => {
|
|
145
|
+
try {
|
|
146
|
+
const openRequest = indexedDB.open(
|
|
147
|
+
STORE_CONSTANTS.dbName,
|
|
148
|
+
STORE_CONSTANTS.dbVersion,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
openRequest.onupgradeneeded = () => {
|
|
152
|
+
const db = openRequest.result;
|
|
153
|
+
if (!db.objectStoreNames.contains(STORE_CONSTANTS.draftsStore)) {
|
|
154
|
+
db.createObjectStore(STORE_CONSTANTS.draftsStore, { keyPath: 'k' });
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
openRequest.onsuccess = () => {
|
|
159
|
+
const db = openRequest.result;
|
|
160
|
+
|
|
161
|
+
if (db.objectStoreNames.contains(STORE_CONSTANTS.draftsStore)) {
|
|
162
|
+
db.onversionchange = () => {
|
|
163
|
+
// Another tab upgraded/deleted the database; step aside
|
|
164
|
+
disableDatabase('database version change');
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
DB = db;
|
|
168
|
+
sweepExpiredRecords(db);
|
|
169
|
+
resolve(db);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
db.close();
|
|
174
|
+
|
|
175
|
+
if (!allowRecovery) {
|
|
176
|
+
disableDatabase('drafts object store is missing');
|
|
177
|
+
resolve(null);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const deleteRequest = indexedDB.deleteDatabase(STORE_CONSTANTS.dbName);
|
|
182
|
+
deleteRequest.onsuccess = () => resolve(openDatabaseOnce(false));
|
|
183
|
+
deleteRequest.onerror = () => {
|
|
184
|
+
disableDatabase(deleteRequest.error);
|
|
185
|
+
resolve(null);
|
|
186
|
+
};
|
|
187
|
+
deleteRequest.onblocked = () => {
|
|
188
|
+
disableDatabase('recovery delete was blocked');
|
|
189
|
+
resolve(null);
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
openRequest.onerror = () => {
|
|
194
|
+
disableDatabase(openRequest.error);
|
|
195
|
+
resolve(null);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
openRequest.onblocked = () => {
|
|
199
|
+
disableDatabase('database open was blocked by another connection');
|
|
200
|
+
resolve(null);
|
|
201
|
+
};
|
|
202
|
+
} catch (err) {
|
|
203
|
+
disableDatabase(err);
|
|
204
|
+
resolve(null);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Resolve the shared database connection, opening it on first use.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
function openDatabase(): Promise<IDBDatabase | null> {
|
|
214
|
+
if (DB) {
|
|
215
|
+
return Promise.resolve(DB);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (DISABLED || !isIndexedDBAvailable()) {
|
|
219
|
+
return Promise.resolve(null);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!OPEN_PROMISE) {
|
|
223
|
+
OPEN_PROMISE = openDatabaseOnce(true);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return OPEN_PROMISE;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Read one record, honoring the reader's TTL. Expired records resolve null and
|
|
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.
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
export async function readDraftRecord(
|
|
236
|
+
key: string,
|
|
237
|
+
ttlHours: number,
|
|
238
|
+
): Promise<DraftRecord | null> {
|
|
239
|
+
const now = Date.now();
|
|
240
|
+
const memoryRecord = MEMORY_RECORDS.get(key);
|
|
241
|
+
|
|
242
|
+
if (memoryRecord) {
|
|
243
|
+
if (getRecordExpiresAt(memoryRecord, ttlHours) > now) {
|
|
244
|
+
return memoryRecord;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
MEMORY_RECORDS.delete(key);
|
|
248
|
+
void deleteDraftRecord(key);
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const db = await openDatabase();
|
|
253
|
+
if (!db) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
try {
|
|
258
|
+
const tx = db.transaction(STORE_CONSTANTS.draftsStore, 'readonly');
|
|
259
|
+
const record = await requestAsPromise<DraftRecord | undefined>(
|
|
260
|
+
tx.objectStore(STORE_CONSTANTS.draftsStore).get(key),
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
if (!record || typeof record.at !== 'number') {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (getRecordExpiresAt(record, ttlHours) <= now) {
|
|
268
|
+
void deleteDraftRecord(key);
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
MEMORY_RECORDS.set(key, record);
|
|
273
|
+
return record;
|
|
274
|
+
} catch (err) {
|
|
275
|
+
disableDatabase(err);
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Read one record from the session mirror only, without touching IndexedDB.
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
export function peekDraftRecord(
|
|
285
|
+
key: string,
|
|
286
|
+
ttlHours: number,
|
|
287
|
+
): DraftRecord | null {
|
|
288
|
+
const record = MEMORY_RECORDS.get(key);
|
|
289
|
+
if (!record) {
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (getRecordExpiresAt(record, ttlHours) <= Date.now()) {
|
|
294
|
+
MEMORY_RECORDS.delete(key);
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return record;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Write one record. The value must be structured-cloneable; anything else is
|
|
303
|
+
* kept in the session mirror only, since dropping it entirely would lose data
|
|
304
|
+
* the caller believes is saved.
|
|
305
|
+
*/
|
|
306
|
+
|
|
307
|
+
export async function writeDraftRecord(
|
|
308
|
+
key: string,
|
|
309
|
+
value: unknown,
|
|
310
|
+
ttlHours: number,
|
|
311
|
+
): Promise<void> {
|
|
312
|
+
const record: DraftRecord = {
|
|
313
|
+
at: Date.now(),
|
|
314
|
+
d: value,
|
|
315
|
+
k: key,
|
|
316
|
+
ttl: ttlHours,
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
MEMORY_RECORDS.set(key, record);
|
|
320
|
+
|
|
321
|
+
const db = await openDatabase();
|
|
322
|
+
if (!db) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
try {
|
|
327
|
+
const tx = db.transaction(STORE_CONSTANTS.draftsStore, 'readwrite');
|
|
328
|
+
|
|
329
|
+
// Validates structured-cloneability before the async put can abort the
|
|
330
|
+
// whole transaction on an unserializable value
|
|
331
|
+
tx.objectStore(STORE_CONSTANTS.draftsStore).put(structuredClone(record));
|
|
332
|
+
|
|
333
|
+
await new Promise<void>((resolve) => {
|
|
334
|
+
tx.oncomplete = () => resolve();
|
|
335
|
+
tx.onerror = () => {
|
|
336
|
+
disableDatabase(tx.error);
|
|
337
|
+
resolve();
|
|
338
|
+
};
|
|
339
|
+
tx.onabort = () => {
|
|
340
|
+
disableDatabase(tx.error || 'transaction aborted');
|
|
341
|
+
resolve();
|
|
342
|
+
};
|
|
343
|
+
});
|
|
344
|
+
} catch (err) {
|
|
345
|
+
(console as any).dev?.('Local draft was not persisted:', err);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Remove one record from both the session mirror and IndexedDB.
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
export async function deleteDraftRecord(key: string): Promise<void> {
|
|
354
|
+
MEMORY_RECORDS.delete(key);
|
|
355
|
+
|
|
356
|
+
const db = await openDatabase();
|
|
357
|
+
if (!db) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
try {
|
|
362
|
+
const tx = db.transaction(STORE_CONSTANTS.draftsStore, 'readwrite');
|
|
363
|
+
tx.objectStore(STORE_CONSTANTS.draftsStore).delete(key);
|
|
364
|
+
} catch (err) {
|
|
365
|
+
disableDatabase(err);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Remove every record (sign-out, account access revoked). Drafts hold content
|
|
371
|
+
* the user typed, so a shared machine must not keep it after logout.
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
export function deleteAllDraftRecords() {
|
|
375
|
+
MEMORY_RECORDS.clear();
|
|
376
|
+
|
|
377
|
+
if (!isIndexedDBAvailable()) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (DB) {
|
|
382
|
+
try {
|
|
383
|
+
const tx = DB.transaction(STORE_CONSTANTS.draftsStore, 'readwrite');
|
|
384
|
+
tx.objectStore(STORE_CONSTANTS.draftsStore).clear();
|
|
385
|
+
return;
|
|
386
|
+
} catch (err) {
|
|
387
|
+
disableDatabase(err);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// The database was never opened in this session; remove it outright
|
|
392
|
+
try {
|
|
393
|
+
indexedDB.deleteDatabase(STORE_CONSTANTS.dbName);
|
|
394
|
+
} catch (_err) {
|
|
395
|
+
// Best-effort only
|
|
396
|
+
}
|
|
397
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { aiChatQry } from './queries/aiChatQueries.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Registry of GQL queries that useEagerQueries() can fetch by string name.
|
|
5
|
+
* Each key MUST equal the query's GraphQL operation name, because eager
|
|
6
|
+
* fetching warms the exact query cache key that useQuery() builds from the
|
|
7
|
+
* operation name and variables; a mismatched key warms a cache entry that
|
|
8
|
+
* no mounted hook will ever read.
|
|
9
|
+
*/
|
|
10
|
+
export const EAGER_QUERY_MAP: Record<string, any> = {
|
|
11
|
+
aiChat: aiChatQry,
|
|
12
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const accountAuthFragment = `fragment accountAuthFragment on AccountAuth {
|
|
2
2
|
token
|
|
3
|
+
sessionBootstrapToken
|
|
4
|
+
cacheAuthorizationEpoch
|
|
3
5
|
primaryOrganizationId
|
|
4
6
|
activated
|
|
5
7
|
hasPassword
|
|
@@ -7,4 +9,7 @@ export const accountAuthFragment = `fragment accountAuthFragment on AccountAuth
|
|
|
7
9
|
alertUpdatesOnMount
|
|
8
10
|
webVersion
|
|
9
11
|
mobileVersion
|
|
12
|
+
|
|
13
|
+
respondentToken
|
|
14
|
+
respondentEmail
|
|
10
15
|
}`;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const accountFragment = `fragment accountFragment on Account {
|
|
2
2
|
id
|
|
3
|
+
readableId
|
|
3
4
|
deleted
|
|
4
5
|
color
|
|
5
6
|
|
|
@@ -17,8 +18,5 @@ export const accountFragment = `fragment accountFragment on Account {
|
|
|
17
18
|
lightMode
|
|
18
19
|
timeZone
|
|
19
20
|
language
|
|
20
|
-
showSelfAvatar
|
|
21
|
-
isBubbleOther
|
|
22
|
-
showOtherAvatar
|
|
23
21
|
}
|
|
24
22
|
}`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const accountSessionFragment = `fragment accountSessionFragment on AccountSession {
|
|
2
|
+
id
|
|
3
|
+
accountId
|
|
4
|
+
authMethod
|
|
5
|
+
deviceName
|
|
6
|
+
userAgent
|
|
7
|
+
createdIpAddress
|
|
8
|
+
lastIpAddress
|
|
9
|
+
createdAt
|
|
10
|
+
lastActivityAt
|
|
11
|
+
idleExpiresAt
|
|
12
|
+
absoluteExpiresAt
|
|
13
|
+
revokedAt
|
|
14
|
+
revokeReason
|
|
15
|
+
current
|
|
16
|
+
}`;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// NOTE: The selection set must stay exactly aligned with the server's
|
|
2
|
+
// realtime $agentDocFragment emit (mapDataToGraphQLFragment 'agent_docs' case
|
|
3
|
+
// in server/src/utils/graphql-data.ts) so useReactiveFragment merges cleanly.
|
|
4
|
+
// Viewer-specific facts (viewerPermission, viewerCanEditAccess) are never
|
|
5
|
+
// emitted over WS, so they are selected by the agentDoc query, not here.
|
|
6
|
+
|
|
7
|
+
export const agentDocFragment = `fragment agentDocFragment on AgentDoc {
|
|
8
|
+
id
|
|
9
|
+
organizationId
|
|
10
|
+
accountId
|
|
11
|
+
lastEditAccountId
|
|
12
|
+
folderId
|
|
13
|
+
|
|
14
|
+
title
|
|
15
|
+
content
|
|
16
|
+
position
|
|
17
|
+
deletedAt
|
|
18
|
+
|
|
19
|
+
access {
|
|
20
|
+
team
|
|
21
|
+
public
|
|
22
|
+
network
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
settings {
|
|
26
|
+
aiCannotEdit
|
|
27
|
+
aiCannotRead
|
|
28
|
+
pinned
|
|
29
|
+
hiddenSurfaces
|
|
30
|
+
reviewBy
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
files {
|
|
34
|
+
id
|
|
35
|
+
uri
|
|
36
|
+
size
|
|
37
|
+
contentType
|
|
38
|
+
at
|
|
39
|
+
intent
|
|
40
|
+
name
|
|
41
|
+
description
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
createdAt
|
|
45
|
+
updatedAt
|
|
46
|
+
}`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const agentMemoryFragment = `fragment agentMemoryFragment on AgentMemory {
|
|
2
|
+
id
|
|
3
|
+
organizationId
|
|
4
|
+
scope
|
|
5
|
+
category
|
|
6
|
+
content
|
|
7
|
+
status
|
|
8
|
+
permanent
|
|
9
|
+
observedCount
|
|
10
|
+
surface
|
|
11
|
+
surfaceKey
|
|
12
|
+
createdVia
|
|
13
|
+
createdByName
|
|
14
|
+
counterpartyName
|
|
15
|
+
sourceMessageId
|
|
16
|
+
expiresAt
|
|
17
|
+
createdAt
|
|
18
|
+
updatedAt
|
|
19
|
+
}`;
|
|
@@ -4,6 +4,8 @@ export const aiChatFragment = `fragment aiChatFragment on AIChat {
|
|
|
4
4
|
accountId
|
|
5
5
|
calDate
|
|
6
6
|
summary
|
|
7
|
+
userManagedSummary
|
|
8
|
+
archivedAt
|
|
7
9
|
createdAt
|
|
8
10
|
updatedAt
|
|
9
11
|
}`;
|
|
@@ -17,4 +19,19 @@ export const aiChatMessageFragment = `fragment aiChatMessageFragment on AIChatMe
|
|
|
17
19
|
photoUri
|
|
18
20
|
finished
|
|
19
21
|
at
|
|
22
|
+
attachments {
|
|
23
|
+
ordinal
|
|
24
|
+
file {
|
|
25
|
+
id
|
|
26
|
+
uri
|
|
27
|
+
size
|
|
28
|
+
contentType
|
|
29
|
+
at
|
|
30
|
+
intent
|
|
31
|
+
name
|
|
32
|
+
description
|
|
33
|
+
aiNote
|
|
34
|
+
uploadStatus
|
|
35
|
+
}
|
|
36
|
+
}
|
|
20
37
|
}`;
|
|
@@ -12,14 +12,3 @@ export const platformProductFragment = `fragment platformProductFragment on Plat
|
|
|
12
12
|
recurringIntervalCount
|
|
13
13
|
}
|
|
14
14
|
}`;
|
|
15
|
-
|
|
16
|
-
export const platformProductPurchaseResultFragment = `fragment platformProductPurchaseResultFragment on PlatformProductPurchaseResult {
|
|
17
|
-
id
|
|
18
|
-
userId
|
|
19
|
-
coins
|
|
20
|
-
productName
|
|
21
|
-
productGroup
|
|
22
|
-
paid
|
|
23
|
-
cancelled
|
|
24
|
-
expireAt
|
|
25
|
-
}`;
|