@oxy.so/services 8.4.0 → 9.1.0
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/lib/commonjs/ui/components/BenefitList.js +1 -2
- package/lib/commonjs/ui/components/BenefitList.js.map +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +2 -2
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +4 -0
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/accountQueryPersistence.js +110 -80
- package/lib/commonjs/ui/hooks/accountQueryPersistence.js.map +1 -1
- package/lib/commonjs/ui/hooks/persistedQueryCache.js +101 -0
- package/lib/commonjs/ui/hooks/persistedQueryCache.js.map +1 -0
- package/lib/commonjs/ui/hooks/queryClient.js +43 -80
- package/lib/commonjs/ui/hooks/queryClient.js.map +1 -1
- package/lib/module/ui/components/BenefitList.js +1 -2
- package/lib/module/ui/components/BenefitList.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +2 -2
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +4 -0
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/accountQueryPersistence.js +109 -80
- package/lib/module/ui/hooks/accountQueryPersistence.js.map +1 -1
- package/lib/module/ui/hooks/persistedQueryCache.js +94 -0
- package/lib/module/ui/hooks/persistedQueryCache.js.map +1 -0
- package/lib/module/ui/hooks/queryClient.js +44 -81
- package/lib/module/ui/hooks/queryClient.js.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/accountQueryPersistence.d.ts +31 -13
- package/lib/typescript/commonjs/ui/hooks/accountQueryPersistence.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/persistedQueryCache.d.ts +44 -0
- package/lib/typescript/commonjs/ui/hooks/persistedQueryCache.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/queryClient.d.ts +15 -20
- package/lib/typescript/commonjs/ui/hooks/queryClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/icons/MaterialCommunityIcons.d.ts +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/accountQueryPersistence.d.ts +31 -13
- package/lib/typescript/module/ui/hooks/accountQueryPersistence.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/persistedQueryCache.d.ts +44 -0
- package/lib/typescript/module/ui/hooks/persistedQueryCache.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/queryClient.d.ts +15 -20
- package/lib/typescript/module/ui/hooks/queryClient.d.ts.map +1 -1
- package/lib/typescript/module/ui/icons/MaterialCommunityIcons.d.ts +1 -1
- package/package.json +4 -4
- package/src/ui/components/BenefitList.tsx +1 -1
- package/src/ui/components/OxyProvider.tsx +2 -2
- package/src/ui/context/OxyContext.tsx +4 -0
- package/src/ui/hooks/accountQueryPersistence.ts +138 -91
- package/src/ui/hooks/persistedQueryCache.ts +126 -0
- package/src/ui/hooks/queryClient.ts +55 -98
|
@@ -7,30 +7,26 @@
|
|
|
7
7
|
* - TanStack Query with `networkMode: 'offlineFirst'` for queries and mutations
|
|
8
8
|
* so cached data is served immediately and mutations are queued (paused) while
|
|
9
9
|
* the browser/device reports offline.
|
|
10
|
-
* - `
|
|
11
|
-
*
|
|
10
|
+
* - `attachQueryPersistence(...)` so that query results AND paused mutations
|
|
11
|
+
* survive a cold restart (kill-and-relaunch); see `persistedQueryCache.ts`.
|
|
12
12
|
* - `onlineManager` resume hook so paused mutations replay the moment the
|
|
13
13
|
* network is reported back, even if the host app swapped in a custom
|
|
14
14
|
* onlineManager implementation.
|
|
15
15
|
*
|
|
16
|
-
* Storage layer:
|
|
17
|
-
*
|
|
18
|
-
* - Web -> localStorage via `createSyncStoragePersister` (wrapped in the
|
|
19
|
-
* async persister API for a single call site).
|
|
20
|
-
* - Both adapters are content-shape compatible with our `StorageInterface`.
|
|
16
|
+
* Storage layer: the platform `StorageInterface` (AsyncStorage on native,
|
|
17
|
+
* localStorage on web).
|
|
21
18
|
*
|
|
22
19
|
* Whitelist policy:
|
|
23
20
|
* - Persist every account/user/session/privacy query and every queued mutation.
|
|
24
21
|
* - DO NOT persist large list queries (e.g. activity feeds) — they go stale
|
|
25
22
|
* fast and would balloon storage. Add new keys to `PERSISTED_QUERY_PREFIXES`
|
|
26
|
-
* when introducing reads that should survive restart.
|
|
23
|
+
* (`persistedQueryCache.ts`) when introducing reads that should survive restart.
|
|
27
24
|
*/
|
|
28
25
|
|
|
29
|
-
import { QueryClient,
|
|
30
|
-
import { persistQueryClient } from '@tanstack/react-query-persist-client';
|
|
31
|
-
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister';
|
|
26
|
+
import { QueryClient, onlineManager } from '@tanstack/react-query';
|
|
32
27
|
import { isDev } from '@oxy.so/core';
|
|
33
|
-
import {
|
|
28
|
+
import { accountQueryOwnership } from "./accountQueryPersistence.js";
|
|
29
|
+
import { PERSISTED_QUERY_PREFIXES, hydrateSnapshot, subscribeSnapshots } from "./persistedQueryCache.js";
|
|
34
30
|
const QUERY_CACHE_KEY = 'oxy_query_cache_v3';
|
|
35
31
|
const QUERY_CACHE_MAX_AGE = 30 * 24 * 60 * 60 * 1000; // 30 days
|
|
36
32
|
const QUERY_PERSIST_THROTTLE_MS = 1_000;
|
|
@@ -50,46 +46,16 @@ export function shouldRetryQuery(failureCount, error) {
|
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
/**
|
|
53
|
-
*
|
|
54
|
-
* is
|
|
55
|
-
*
|
|
56
|
-
* Mutations are persisted independently (always) so the offline write queue
|
|
57
|
-
* works regardless of the read whitelist.
|
|
49
|
+
* Whether a query belongs in the account-agnostic cache: successful (a
|
|
50
|
+
* `pending`/`error` state is not worth keeping, and an error would leak
|
|
51
|
+
* failure objects across restarts) and under one of the SDK's own prefixes.
|
|
58
52
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Adapt our `StorageInterface` (which always returns `null` for missing keys)
|
|
63
|
-
* to TanStack's `AsyncStorage` shape. The two are structurally identical
|
|
64
|
-
* apart from naming; this also gives us a single place to add error
|
|
65
|
-
* suppression if a host platform's storage throws.
|
|
66
|
-
*/
|
|
67
|
-
function adaptStorage(storage) {
|
|
68
|
-
return {
|
|
69
|
-
getItem: key => storage.getItem(key),
|
|
70
|
-
setItem: (key, value) => storage.setItem(key, value),
|
|
71
|
-
removeItem: key => storage.removeItem(key)
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Decide whether a given query should be written to persistent storage.
|
|
77
|
-
*
|
|
78
|
-
* Two gates:
|
|
79
|
-
* 1. The query must be in our prefix whitelist.
|
|
80
|
-
* 2. The query must have completed successfully at least once — there's no
|
|
81
|
-
* point persisting a `pending`/`error` state, and persisting `error` would
|
|
82
|
-
* leak failure objects across restarts.
|
|
83
|
-
*/
|
|
84
|
-
function shouldDehydrateQuery(query) {
|
|
53
|
+
function isSharedQuery(query) {
|
|
85
54
|
if (query.state.status !== 'success') {
|
|
86
55
|
return false;
|
|
87
56
|
}
|
|
88
57
|
const head = query.queryKey[0];
|
|
89
|
-
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
return PERSISTED_QUERY_PREFIXES.includes(head);
|
|
58
|
+
return typeof head === 'string' && PERSISTED_QUERY_PREFIXES.includes(head);
|
|
93
59
|
}
|
|
94
60
|
|
|
95
61
|
/**
|
|
@@ -148,58 +114,55 @@ export const createQueryClient = () => {
|
|
|
148
114
|
return client;
|
|
149
115
|
};
|
|
150
116
|
/**
|
|
151
|
-
*
|
|
117
|
+
* Restore, then keep writing, the account-agnostic cache.
|
|
152
118
|
*
|
|
153
|
-
*
|
|
154
|
-
* `
|
|
119
|
+
* Queries written by another build are dropped; queued mutations are kept
|
|
120
|
+
* (`persistedQueryCache.ts`). Whatever the app declared account-scoped
|
|
121
|
+
* (`accountQueries`) is left to `createAccountQueryPersistence`, even under
|
|
122
|
+
* one of the SDK's prefixes, so private rows never land in the shared blob and
|
|
123
|
+
* a paused mutation cannot replay twice or under another account.
|
|
155
124
|
*
|
|
156
125
|
* Safe to no-op if `storage` is null/undefined (e.g. server-side render
|
|
157
126
|
* with no host storage).
|
|
158
127
|
*/
|
|
159
|
-
export const attachQueryPersistence = (queryClient, storage,
|
|
160
|
-
/**
|
|
161
|
-
* Mutation keys the app declared account-scoped (`accountQueries`). Those are
|
|
162
|
-
* persisted per account by `createAccountQueryPersistence`, never here, so a
|
|
163
|
-
* paused mutation cannot replay twice or under another account.
|
|
164
|
-
*/
|
|
165
|
-
accountMutationKeys = []) => {
|
|
128
|
+
export const attachQueryPersistence = (queryClient, storage, accountQueries) => {
|
|
166
129
|
if (!storage) {
|
|
167
130
|
return {
|
|
168
131
|
restored: Promise.resolve(),
|
|
169
132
|
unsubscribe: () => {}
|
|
170
133
|
};
|
|
171
134
|
}
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
// Persist every other mutation regardless of status: paused mutations are
|
|
179
|
-
// exactly the ones that must survive restart to replay when online.
|
|
180
|
-
const accountScoped = new Set(accountMutationKeys.map(key => hashKey(key)));
|
|
181
|
-
const shouldDehydrateMutation = mutation => {
|
|
182
|
-
const key = mutation.options.mutationKey;
|
|
183
|
-
return key === undefined || !accountScoped.has(hashKey(key));
|
|
135
|
+
const account = accountQueries ? accountQueryOwnership(accountQueries) : null;
|
|
136
|
+
const filters = {
|
|
137
|
+
shouldDehydrateQuery: query => isSharedQuery(query) && !(account?.ownsQuery(query) ?? false),
|
|
138
|
+
// Every other mutation, whatever its status: paused ones are exactly the
|
|
139
|
+
// ones that must survive a restart to replay when online.
|
|
140
|
+
shouldDehydrateMutation: mutation => !(account?.ownsMutation(mutation) ?? false)
|
|
184
141
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
shouldDehydrateMutation
|
|
142
|
+
let stopped = false;
|
|
143
|
+
let writer = null;
|
|
144
|
+
const restored = (async () => {
|
|
145
|
+
const raw = await storage.getItem(QUERY_CACHE_KEY);
|
|
146
|
+
if (stopped) return;
|
|
147
|
+
if (!hydrateSnapshot(queryClient, raw, QUERY_CACHE_MAX_AGE) && raw) {
|
|
148
|
+
await storage.removeItem(QUERY_CACHE_KEY);
|
|
193
149
|
}
|
|
194
|
-
})
|
|
195
|
-
restored.catch(error => {
|
|
150
|
+
})().catch(error => {
|
|
196
151
|
if (isDev()) {
|
|
197
152
|
console.warn('[QueryClient] Failed to restore persisted cache', error);
|
|
198
153
|
}
|
|
154
|
+
}).then(() => {
|
|
155
|
+
if (stopped) return;
|
|
156
|
+
writer = subscribeSnapshots(queryClient, filters, QUERY_PERSIST_THROTTLE_MS, serialized => {
|
|
157
|
+
void Promise.resolve(storage.setItem(QUERY_CACHE_KEY, serialized)).catch(() => undefined);
|
|
158
|
+
});
|
|
199
159
|
});
|
|
200
160
|
return {
|
|
201
|
-
|
|
202
|
-
|
|
161
|
+
restored,
|
|
162
|
+
unsubscribe: () => {
|
|
163
|
+
stopped = true;
|
|
164
|
+
writer?.unsubscribe();
|
|
165
|
+
}
|
|
203
166
|
};
|
|
204
167
|
};
|
|
205
168
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["QueryClient","
|
|
1
|
+
{"version":3,"names":["QueryClient","onlineManager","isDev","accountQueryOwnership","PERSISTED_QUERY_PREFIXES","hydrateSnapshot","subscribeSnapshots","QUERY_CACHE_KEY","QUERY_CACHE_MAX_AGE","QUERY_PERSIST_THROTTLE_MS","MAX_QUERY_RETRIES","statusOf","error","value","status","response","shouldRetryQuery","failureCount","isSharedQuery","query","state","head","queryKey","includes","createQueryClient","client","defaultOptions","queries","staleTime","gcTime","retry","retryDelay","attemptIndex","Math","min","refetchOnReconnect","refetchOnWindowFocus","networkMode","mutations","unsubscribe","subscribe","isOnline","getMutationCache","resumePausedMutations","Object","defineProperty","enumerable","configurable","writable","attachQueryPersistence","queryClient","storage","accountQueries","restored","Promise","resolve","account","filters","shouldDehydrateQuery","ownsQuery","shouldDehydrateMutation","mutation","ownsMutation","stopped","writer","raw","getItem","removeItem","catch","console","warn","then","serialized","setItem","undefined","clearQueryCache"],"sourceRoot":"../../../../src","sources":["ui/hooks/queryClient.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,EAAEC,aAAa,QAAmC,uBAAuB;AAE7F,SAASC,KAAK,QAAQ,cAAc;AAEpC,SAASC,qBAAqB,QAAmC,8BAA2B;AAC5F,SAASC,wBAAwB,EAAEC,eAAe,EAAEC,kBAAkB,QAAQ,0BAAuB;AAErG,MAAMC,eAAe,GAAG,oBAAoB;AAC5C,MAAMC,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACtD,MAAMC,yBAAyB,GAAG,KAAK;AACvC,MAAMC,iBAAiB,GAAG,CAAC;AAE3B,SAASC,QAAQA,CAACC,KAAc,EAAiB;EAC/C,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,OAAO,IAAI;EACpD,MAAMC,KAAK,GAAID,KAAK,CAA2DE,MAAM,IAC/EF,KAAK,CAAyCG,QAAQ,EAAED,MAAM;EACpE,OAAO,OAAOD,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAG,IAAI;AACjD;;AAEA;AACA,OAAO,SAASG,gBAAgBA,CAACC,YAAoB,EAAEL,KAAc,EAAW;EAC9E,IAAIK,YAAY,IAAIP,iBAAiB,EAAE,O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,CAAC1D,eAAe,CAAC6C,WAAW,EAAEe,GAAG,EAAEzD,mBAAmB,CAAC,IAAIyD,GAAG,EAAE;MAClE,MAAMd,OAAO,CAACgB,UAAU,CAAC5D,eAAe,CAAC;IAC3C;EACF,CAAC,EAAE,CAAC,CACD6D,KAAK,CAAExD,KAAK,IAAK;IAChB,IAAIV,KAAK,CAAC,CAAC,EAAE;MACXmE,OAAO,CAACC,IAAI,CAAC,iDAAiD,EAAE1D,KAAK,CAAC;IACxE;EACF,CAAC,CAAC,CACD2D,IAAI,CAAC,MAAM;IACV,IAAIR,OAAO,EAAE;IACbC,MAAM,GAAG1D,kBAAkB,CAAC4C,WAAW,EAAEO,OAAO,EAAEhD,yBAAyB,EAAG+D,UAAU,IAAK;MAC3F,KAAKlB,OAAO,CAACC,OAAO,CAACJ,OAAO,CAACsB,OAAO,CAAClE,eAAe,EAAEiE,UAAU,CAAC,CAAC,CAACJ,KAAK,CAAC,MAAMM,SAAS,CAAC;IAC3F,CAAC,CAAC;EACJ,CAAC,CAAC;EAEJ,OAAO;IACLrB,QAAQ;IACRd,WAAW,EAAEA,CAAA,KAAM;MACjBwB,OAAO,GAAG,IAAI;MACdC,MAAM,EAAEzB,WAAW,CAAC,CAAC;IACvB;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMoC,eAAe,GAAG,MAAOxB,OAAyB,IAAoB;EACjF,IAAI;IACF,MAAMA,OAAO,CAACgB,UAAU,CAAC5D,eAAe,CAAC;EAC3C,CAAC,CAAC,OAAOK,KAAK,EAAE;IACd,IAAIV,KAAK,CAAC,CAAC,EAAE;MACXmE,OAAO,CAACC,IAAI,CAAC,qDAAqD,EAAE1D,KAAK,CAAC;IAC5E;EACF;AACF,CAAC;;AAED;AACA;AACA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OxyContext.d.ts","sourceRoot":"","sources":["../../../../../src/ui/context/OxyContext.tsx"],"names":[],"mappings":"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AAc,QAAO,eAAe,GAAG,IAAqC,CAAC;AAE1F,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,QAAO,0BAMpC,CAAC"}
|
|
@@ -8,24 +8,32 @@
|
|
|
8
8
|
*
|
|
9
9
|
* - Storage is keyed by the account (`oxy_account_queries:<accountId>`), so a
|
|
10
10
|
* restore can only ever hydrate the account that is signed in.
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
* - On a subject change the
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* - Queries written by another build are dropped on restore; queued (paused)
|
|
12
|
+
* mutations are kept (`persistedQueryCache.ts`).
|
|
13
|
+
* - On a subject change the account's queries, memory-only ones included, and
|
|
14
|
+
* its paused mutations are dropped from memory synchronously, before anyone
|
|
15
|
+
* is woken. The leaving account's latest state is written first, a sign-out
|
|
16
|
+
* then deletes it, and only then is the next account's blob read.
|
|
17
|
+
* - `isReady()` is false until the signed-in account's blob is restored, and
|
|
17
18
|
* `RequireOxyAuth` waits on it, so another account's rows never render.
|
|
18
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* Every storage operation runs through one queue, in order, and a restore
|
|
21
|
+
* checks that its account is still the active one in the same tick it hydrates.
|
|
19
22
|
*/
|
|
20
|
-
import { type Mutation, type QueryClient, type QueryKey } from '@tanstack/react-query';
|
|
23
|
+
import { type Mutation, type Query, type QueryClient, type QueryKey } from '@tanstack/react-query';
|
|
21
24
|
import type { StorageInterface } from '../utils/storageHelpers';
|
|
22
25
|
/** An app's declaration of which data is private to the signed-in account. */
|
|
23
26
|
export interface AccountQueriesConfig {
|
|
24
27
|
/**
|
|
25
28
|
* Query-key roots (`queryKey[0]`) whose data belongs to the signed-in account
|
|
26
|
-
* and survives a restart.
|
|
29
|
+
* and survives a restart. `'all'`: every query the app runs, for an app whose
|
|
30
|
+
* every read may depend on who is signed in, so no root can be forgotten.
|
|
31
|
+
*
|
|
32
|
+
* The roots `accounts`, `sessions` and `devices` are reserved for the SDK's
|
|
33
|
+
* device-level data: an app must not use them. `users` and `privacy` are the
|
|
34
|
+
* SDK's too, and with `'all'` they are dropped on a switch like the app's.
|
|
27
35
|
*/
|
|
28
|
-
roots: readonly string[];
|
|
36
|
+
roots: readonly string[] | 'all';
|
|
29
37
|
/**
|
|
30
38
|
* Roots that belong to the account too, but must not be written to disk
|
|
31
39
|
* (signed URLs, AI output, search results): dropped on a switch, never persisted.
|
|
@@ -37,18 +45,28 @@ export interface AccountQueriesConfig {
|
|
|
37
45
|
*/
|
|
38
46
|
mutationKeys?: readonly QueryKey[];
|
|
39
47
|
}
|
|
48
|
+
/** Which queries and mutations an `AccountQueriesConfig` makes the account's. */
|
|
49
|
+
export interface AccountQueryOwnership {
|
|
50
|
+
/** Dropped from memory on a subject change. */
|
|
51
|
+
ownsQuery: (query: Query) => boolean;
|
|
52
|
+
/** Written to the account's blob. */
|
|
53
|
+
persistsQuery: (query: Query) => boolean;
|
|
54
|
+
ownsMutation: (mutation: Mutation) => boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare function accountQueryOwnership(config: AccountQueriesConfig): AccountQueryOwnership;
|
|
40
57
|
export declare const ACCOUNT_QUERY_CACHE_KEY = "oxy_account_queries";
|
|
41
58
|
export interface AccountQueryPersistence {
|
|
42
59
|
/** Storage became available (it initializes asynchronously). */
|
|
43
60
|
setStorage(storage: StorageInterface): void;
|
|
44
61
|
/** The signed-in account changed. `null` is a sign-out. Synchronous in-memory reset. */
|
|
45
62
|
activate(accountId: string | null): void;
|
|
63
|
+
/** The owning provider mounted: restore and persist the active account. */
|
|
64
|
+
attach(): void;
|
|
65
|
+
/** The owning provider unmounted: stop touching the client and storage. */
|
|
66
|
+
detach(): void;
|
|
46
67
|
/** True once the active account's cache is restored (always true signed out). */
|
|
47
68
|
isReady(): boolean;
|
|
48
69
|
subscribe(listener: () => void): () => void;
|
|
49
|
-
/** Whether a mutation is account-scoped (so the SDK's own persister skips it). */
|
|
50
|
-
ownsMutation(mutation: Mutation): boolean;
|
|
51
|
-
dispose(): void;
|
|
52
70
|
}
|
|
53
71
|
export declare function createAccountQueryPersistence(queryClient: QueryClient, config: AccountQueriesConfig): AccountQueryPersistence;
|
|
54
72
|
//# sourceMappingURL=accountQueryPersistence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountQueryPersistence.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/accountQueryPersistence.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"accountQueryPersistence.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/accountQueryPersistence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5G,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAWhE,8EAA8E;AAC9E,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;OAQG;IACH,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;IACjC;;;OAGG;IACH,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CACpC;AAED,iFAAiF;AACjF,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IACrC,qCAAqC;IACrC,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IACzC,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC;CAC/C;AAKD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,GAAG,qBAAqB,CA0BzF;AAED,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAI7D,MAAM,WAAW,uBAAuB;IACtC,gEAAgE;IAChE,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC5C,wFAAwF;IACxF,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACzC,2EAA2E;IAC3E,MAAM,IAAI,IAAI,CAAC;IACf,2EAA2E;IAC3E,MAAM,IAAI,IAAI,CAAC;IACf,iFAAiF;IACjF,OAAO,IAAI,OAAO,CAAC;IACnB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC7C;AAMD,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,oBAAoB,GAC3B,uBAAuB,CA2HzB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storage format and restore rules shared by the SDK's two query caches:
|
|
3
|
+
* the account-agnostic one (`attachQueryPersistence`) and the per-account one
|
|
4
|
+
* (`createAccountQueryPersistence`).
|
|
5
|
+
*
|
|
6
|
+
* A blob is `{ buster, timestamp, clientState }`, TanStack's persisted-client
|
|
7
|
+
* shape. Restoring it treats its two halves differently:
|
|
8
|
+
*
|
|
9
|
+
* - Queries are served before any refetch, so a query written by another
|
|
10
|
+
* build, in whatever shape that build used, is dropped (`getOxyBuildId`).
|
|
11
|
+
* - Paused mutations are the user's queued actions (a star, a send made
|
|
12
|
+
* offline). A deploy must not lose them, so they are restored whatever build
|
|
13
|
+
* wrote them; the current build's `setMutationDefaults` replays them.
|
|
14
|
+
*/
|
|
15
|
+
import { type Mutation, type Query, type QueryClient } from '@tanstack/react-query';
|
|
16
|
+
/** The SDK's own account-agnostic query roots, persisted by `attachQueryPersistence`. */
|
|
17
|
+
export declare const PERSISTED_QUERY_PREFIXES: ReadonlyArray<string>;
|
|
18
|
+
/**
|
|
19
|
+
* SDK queries whose data (or key) carries a signed, expiring URL. Never
|
|
20
|
+
* written to disk: a restored one would serve an expired URL.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SDK_MEMORY_ONLY_ROOTS: ReadonlyArray<string>;
|
|
23
|
+
export interface PersistFilters {
|
|
24
|
+
shouldDehydrateQuery: (query: Query) => boolean;
|
|
25
|
+
shouldDehydrateMutation: (mutation: Mutation) => boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function rootOf(query: Query): string | null;
|
|
28
|
+
/** Serialize what the filters select, stamped with this build. */
|
|
29
|
+
export declare function snapshot(queryClient: QueryClient, filters: PersistFilters): string;
|
|
30
|
+
/**
|
|
31
|
+
* Hydrate a stored blob into the client, synchronously, so a caller can check
|
|
32
|
+
* it is still wanted immediately before. Returns false when there was nothing
|
|
33
|
+
* usable (absent, unreadable or expired), in which case the caller removes it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function hydrateSnapshot(queryClient: QueryClient, raw: string | null, maxAge: number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Write the filtered cache on every change, at most once per `throttleMs`.
|
|
38
|
+
* `write` receives the serialized snapshot; `flush()` writes now.
|
|
39
|
+
*/
|
|
40
|
+
export declare function subscribeSnapshots(queryClient: QueryClient, filters: PersistFilters, throttleMs: number, write: (serialized: string) => void): {
|
|
41
|
+
flush: () => void;
|
|
42
|
+
unsubscribe: () => void;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=persistedQueryCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistedQueryCache.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/persistedQueryCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAG/B,yFAAyF;AACzF,eAAO,MAAM,wBAAwB,EAAE,aAAa,CAAC,MAAM,CAM1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAKvD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,oBAAoB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IAChD,uBAAuB,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC;CAC1D;AAQD,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAGlD;AAED,kEAAkE;AAClE,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAOlF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAiBrG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,GAClC;IAAE,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,IAAI,CAAA;CAAE,CAqBhD"}
|
|
@@ -5,27 +5,25 @@
|
|
|
5
5
|
* - TanStack Query with `networkMode: 'offlineFirst'` for queries and mutations
|
|
6
6
|
* so cached data is served immediately and mutations are queued (paused) while
|
|
7
7
|
* the browser/device reports offline.
|
|
8
|
-
* - `
|
|
9
|
-
*
|
|
8
|
+
* - `attachQueryPersistence(...)` so that query results AND paused mutations
|
|
9
|
+
* survive a cold restart (kill-and-relaunch); see `persistedQueryCache.ts`.
|
|
10
10
|
* - `onlineManager` resume hook so paused mutations replay the moment the
|
|
11
11
|
* network is reported back, even if the host app swapped in a custom
|
|
12
12
|
* onlineManager implementation.
|
|
13
13
|
*
|
|
14
|
-
* Storage layer:
|
|
15
|
-
*
|
|
16
|
-
* - Web -> localStorage via `createSyncStoragePersister` (wrapped in the
|
|
17
|
-
* async persister API for a single call site).
|
|
18
|
-
* - Both adapters are content-shape compatible with our `StorageInterface`.
|
|
14
|
+
* Storage layer: the platform `StorageInterface` (AsyncStorage on native,
|
|
15
|
+
* localStorage on web).
|
|
19
16
|
*
|
|
20
17
|
* Whitelist policy:
|
|
21
18
|
* - Persist every account/user/session/privacy query and every queued mutation.
|
|
22
19
|
* - DO NOT persist large list queries (e.g. activity feeds) — they go stale
|
|
23
20
|
* fast and would balloon storage. Add new keys to `PERSISTED_QUERY_PREFIXES`
|
|
24
|
-
* when introducing reads that should survive restart.
|
|
21
|
+
* (`persistedQueryCache.ts`) when introducing reads that should survive restart.
|
|
25
22
|
*/
|
|
26
|
-
import { QueryClient
|
|
27
|
-
import {
|
|
23
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
24
|
+
import type { PersistedClient } from '@tanstack/react-query-persist-client';
|
|
28
25
|
import type { StorageInterface } from '../utils/storageHelpers';
|
|
26
|
+
import { type AccountQueriesConfig } from './accountQueryPersistence';
|
|
29
27
|
/** Retry only failures that another attempt can plausibly change. */
|
|
30
28
|
export declare function shouldRetryQuery(failureCount: number, error: unknown): boolean;
|
|
31
29
|
/**
|
|
@@ -47,21 +45,18 @@ export interface AttachPersistenceResult {
|
|
|
47
45
|
unsubscribe: () => void;
|
|
48
46
|
}
|
|
49
47
|
/**
|
|
50
|
-
*
|
|
48
|
+
* Restore, then keep writing, the account-agnostic cache.
|
|
51
49
|
*
|
|
52
|
-
*
|
|
53
|
-
* `
|
|
50
|
+
* Queries written by another build are dropped; queued mutations are kept
|
|
51
|
+
* (`persistedQueryCache.ts`). Whatever the app declared account-scoped
|
|
52
|
+
* (`accountQueries`) is left to `createAccountQueryPersistence`, even under
|
|
53
|
+
* one of the SDK's prefixes, so private rows never land in the shared blob and
|
|
54
|
+
* a paused mutation cannot replay twice or under another account.
|
|
54
55
|
*
|
|
55
56
|
* Safe to no-op if `storage` is null/undefined (e.g. server-side render
|
|
56
57
|
* with no host storage).
|
|
57
58
|
*/
|
|
58
|
-
export declare const attachQueryPersistence: (queryClient: QueryClient, storage: StorageInterface | null | undefined,
|
|
59
|
-
/**
|
|
60
|
-
* Mutation keys the app declared account-scoped (`accountQueries`). Those are
|
|
61
|
-
* persisted per account by `createAccountQueryPersistence`, never here, so a
|
|
62
|
-
* paused mutation cannot replay twice or under another account.
|
|
63
|
-
*/
|
|
64
|
-
accountMutationKeys?: readonly QueryKey[]) => AttachPersistenceResult;
|
|
59
|
+
export declare const attachQueryPersistence: (queryClient: QueryClient, storage: StorageInterface | null | undefined, accountQueries?: AccountQueriesConfig) => AttachPersistenceResult;
|
|
65
60
|
/**
|
|
66
61
|
* Remove the persisted query+mutation cache (used on full sign-out / data reset).
|
|
67
62
|
* Safe to call even if persistence was never attached.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryClient.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/queryClient.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"queryClient.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/queryClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,WAAW,EAA4C,MAAM,uBAAuB,CAAC;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAyB,KAAK,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAe7F,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAK9E;AAeD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,QAAO,WA6CpC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,wEAAwE;IACxE,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GACjC,aAAa,WAAW,EACxB,SAAS,gBAAgB,GAAG,IAAI,GAAG,SAAS,EAC5C,iBAAiB,oBAAoB,KACpC,uBA8CF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,IAAI,CAQ7E,CAAC;AAEF;;GAEG;AACH,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Glyphs are decorative: hidden from assistive technology (see `decorativeIconSet`). */
|
|
2
|
-
declare const MaterialCommunityIcons: import("@expo/vector-icons/build/createIconSet").Icon<"function" | "sort" | "at" | "label" | "link" | "ellipse" | "image" | "switch" | "text" | "alert" | "alert-circle" | "alert-circle-outline" | "apps" | "archive" | "arrow-down" | "arrow-up" | "briefcase-outline" | "bug" | "calendar" | "calendar-outline" | "camera" | "camera-outline" | "card" | "card-outline" | "cart-outline" | "chevron-down" | "chevron-up" | "close" | "close-circle" | "cloud-outline" | "cloud-upload" | "cloud-upload-outline" | "cog" | "cog-outline" | "cube-outline" | "download" | "download-outline" | "earth" | "ellipse-outline" | "eye" | "eye-off-outline" | "filter-outline" | "flash" | "folder" | "folder-open-outline" | "folder-outline" | "gift" | "gift-outline" | "grid" | "heart" | "heart-outline" | "help-circle" | "help-circle-outline" | "image-outline" | "information" | "information-outline" | "key" | "leaf" | "library" | "pencil-outline" | "play" | "pulse" | "radio" | "receipt-outline" | "resize" | "rocket" | "scale" | "school-outline" | "server" | "share-outline" | "shield" | "star" | "sync" | "trophy" | "trophy-outline" | "volume-off" | "wallet" | "wallet-outline" | "watch" | "wifi" | "solid" | "account" | "account-circle" | "account-cog-outline" | "account-eye-outline" | "account-group" | "account-multiple" | "account-multiple-outline" | "account-outline" | "account-plus" | "account-search" | "account-switch" | "android" | "archive-arrow-down" | "arrow-left" | "bell" | "bell-outline" | "bio" | "bullhorn" | "cake-variant" | "cake-variant-outline" | "cancel" | "cellphone" | "cellphone-basic" | "cellphone-message" | "cellphone-screenshot" | "chart-line" | "check-all" | "check-circle" | "chip" | "circle-outline" | "clock" | "clock-outline" | "code-tags" | "contain" | "content-copy" | "controller" | "cookie" | "credit-card" | "database-outline" | "delete" | "delete-outline" | "
|
|
2
|
+
declare const MaterialCommunityIcons: import("@expo/vector-icons/build/createIconSet").Icon<"function" | "devices" | "sort" | "at" | "label" | "link" | "ellipse" | "image" | "switch" | "text" | "alert" | "alert-circle" | "alert-circle-outline" | "apps" | "archive" | "arrow-down" | "arrow-up" | "briefcase-outline" | "bug" | "calendar" | "calendar-outline" | "camera" | "camera-outline" | "card" | "card-outline" | "cart-outline" | "chevron-down" | "chevron-up" | "close" | "close-circle" | "cloud-outline" | "cloud-upload" | "cloud-upload-outline" | "cog" | "cog-outline" | "cube-outline" | "download" | "download-outline" | "earth" | "ellipse-outline" | "eye" | "eye-off-outline" | "filter-outline" | "flash" | "folder" | "folder-open-outline" | "folder-outline" | "gift" | "gift-outline" | "grid" | "heart" | "heart-outline" | "help-circle" | "help-circle-outline" | "image-outline" | "information" | "information-outline" | "key" | "leaf" | "library" | "pencil-outline" | "play" | "pulse" | "radio" | "receipt-outline" | "resize" | "rocket" | "scale" | "school-outline" | "server" | "share-outline" | "shield" | "star" | "sync" | "trophy" | "trophy-outline" | "volume-off" | "wallet" | "wallet-outline" | "watch" | "wifi" | "solid" | "opacity" | "wrap" | "account" | "account-circle" | "account-cog-outline" | "account-eye-outline" | "account-group" | "account-multiple" | "account-multiple-outline" | "account-outline" | "account-plus" | "account-search" | "account-switch" | "android" | "archive-arrow-down" | "arrow-left" | "bell" | "bell-outline" | "bio" | "bullhorn" | "cake-variant" | "cake-variant-outline" | "cancel" | "cellphone" | "cellphone-basic" | "cellphone-message" | "cellphone-screenshot" | "chart-line" | "check-all" | "check-circle" | "chip" | "circle-outline" | "clock" | "clock-outline" | "code-tags" | "contain" | "content-copy" | "controller" | "cookie" | "credit-card" | "database-outline" | "delete" | "delete-outline" | "dots-horizontal" | "email" | "email-outline" | "file" | "file-document" | "file-document-edit-outline" | "file-document-outline" | "file-excel-outline" | "file-outline" | "file-pdf-box" | "folder-image" | "folder-zip-outline" | "ghost" | "history" | "image-multiple-outline" | "link-variant" | "loading" | "lock-outline" | "logout" | "magnify" | "map-marker" | "map-marker-multiple" | "map-marker-outline" | "message" | "message-outline" | "minus-circle" | "motion" | "music-note-outline" | "network" | "null" | "numeric" | "open-in-app" | "openid" | "palette" | "palette-outline" | "pan" | "phone" | "phone-outline" | "plus" | "plus-circle" | "post" | "presentation" | "react" | "read" | "security" | "shield-account-outline" | "shield-check" | "shield-search" | "signature" | "sort-alphabetical-variant" | "sort-numeric-variant" | "store" | "tag" | "tag-outline" | "text-box-outline" | "theme-light-dark" | "transfer" | "translate" | "trash-can-outline" | "tray-arrow-down" | "update" | "video-outline" | "web" | "wifi-off" | "wrench" | "xml", "OxyServicesMaterialCommunityIcons">;
|
|
3
3
|
export default MaterialCommunityIcons;
|
|
4
4
|
//# sourceMappingURL=MaterialCommunityIcons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OxyContext.d.ts","sourceRoot":"","sources":["../../../../../src/ui/context/OxyContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgF/B,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EAExB,MAAM,sBAAmB,CAAC;AAU3B,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,sBAAmB,CAAC;AAMhG,KAAK,0BAA0B,GAAG,IAAI,CACpC,eAAe,EACb,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,iBAAiB,GACjB,aAAa,GACb,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,CACtB,CAAC;AAIF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"OxyContext.d.ts","sourceRoot":"","sources":["../../../../../src/ui/context/OxyContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgF/B,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EAExB,MAAM,sBAAmB,CAAC;AAU3B,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,sBAAmB,CAAC;AAMhG,KAAK,0BAA0B,GAAG,IAAI,CACpC,eAAe,EACb,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,iBAAiB,GACjB,aAAa,GACb,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,CACtB,CAAC;AAIF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAqxChE,CAAC;AAMF,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,0BAA0B;;CAMxC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,QAAO,eAMzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,eAAe,GAAG,IAAqC,CAAC;AAE1F,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,QAAO,0BAMpC,CAAC"}
|
|
@@ -8,24 +8,32 @@
|
|
|
8
8
|
*
|
|
9
9
|
* - Storage is keyed by the account (`oxy_account_queries:<accountId>`), so a
|
|
10
10
|
* restore can only ever hydrate the account that is signed in.
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
* - On a subject change the
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* - Queries written by another build are dropped on restore; queued (paused)
|
|
12
|
+
* mutations are kept (`persistedQueryCache.ts`).
|
|
13
|
+
* - On a subject change the account's queries, memory-only ones included, and
|
|
14
|
+
* its paused mutations are dropped from memory synchronously, before anyone
|
|
15
|
+
* is woken. The leaving account's latest state is written first, a sign-out
|
|
16
|
+
* then deletes it, and only then is the next account's blob read.
|
|
17
|
+
* - `isReady()` is false until the signed-in account's blob is restored, and
|
|
17
18
|
* `RequireOxyAuth` waits on it, so another account's rows never render.
|
|
18
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* Every storage operation runs through one queue, in order, and a restore
|
|
21
|
+
* checks that its account is still the active one in the same tick it hydrates.
|
|
19
22
|
*/
|
|
20
|
-
import { type Mutation, type QueryClient, type QueryKey } from '@tanstack/react-query';
|
|
23
|
+
import { type Mutation, type Query, type QueryClient, type QueryKey } from '@tanstack/react-query';
|
|
21
24
|
import type { StorageInterface } from '../utils/storageHelpers.js';
|
|
22
25
|
/** An app's declaration of which data is private to the signed-in account. */
|
|
23
26
|
export interface AccountQueriesConfig {
|
|
24
27
|
/**
|
|
25
28
|
* Query-key roots (`queryKey[0]`) whose data belongs to the signed-in account
|
|
26
|
-
* and survives a restart.
|
|
29
|
+
* and survives a restart. `'all'`: every query the app runs, for an app whose
|
|
30
|
+
* every read may depend on who is signed in, so no root can be forgotten.
|
|
31
|
+
*
|
|
32
|
+
* The roots `accounts`, `sessions` and `devices` are reserved for the SDK's
|
|
33
|
+
* device-level data: an app must not use them. `users` and `privacy` are the
|
|
34
|
+
* SDK's too, and with `'all'` they are dropped on a switch like the app's.
|
|
27
35
|
*/
|
|
28
|
-
roots: readonly string[];
|
|
36
|
+
roots: readonly string[] | 'all';
|
|
29
37
|
/**
|
|
30
38
|
* Roots that belong to the account too, but must not be written to disk
|
|
31
39
|
* (signed URLs, AI output, search results): dropped on a switch, never persisted.
|
|
@@ -37,18 +45,28 @@ export interface AccountQueriesConfig {
|
|
|
37
45
|
*/
|
|
38
46
|
mutationKeys?: readonly QueryKey[];
|
|
39
47
|
}
|
|
48
|
+
/** Which queries and mutations an `AccountQueriesConfig` makes the account's. */
|
|
49
|
+
export interface AccountQueryOwnership {
|
|
50
|
+
/** Dropped from memory on a subject change. */
|
|
51
|
+
ownsQuery: (query: Query) => boolean;
|
|
52
|
+
/** Written to the account's blob. */
|
|
53
|
+
persistsQuery: (query: Query) => boolean;
|
|
54
|
+
ownsMutation: (mutation: Mutation) => boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare function accountQueryOwnership(config: AccountQueriesConfig): AccountQueryOwnership;
|
|
40
57
|
export declare const ACCOUNT_QUERY_CACHE_KEY = "oxy_account_queries";
|
|
41
58
|
export interface AccountQueryPersistence {
|
|
42
59
|
/** Storage became available (it initializes asynchronously). */
|
|
43
60
|
setStorage(storage: StorageInterface): void;
|
|
44
61
|
/** The signed-in account changed. `null` is a sign-out. Synchronous in-memory reset. */
|
|
45
62
|
activate(accountId: string | null): void;
|
|
63
|
+
/** The owning provider mounted: restore and persist the active account. */
|
|
64
|
+
attach(): void;
|
|
65
|
+
/** The owning provider unmounted: stop touching the client and storage. */
|
|
66
|
+
detach(): void;
|
|
46
67
|
/** True once the active account's cache is restored (always true signed out). */
|
|
47
68
|
isReady(): boolean;
|
|
48
69
|
subscribe(listener: () => void): () => void;
|
|
49
|
-
/** Whether a mutation is account-scoped (so the SDK's own persister skips it). */
|
|
50
|
-
ownsMutation(mutation: Mutation): boolean;
|
|
51
|
-
dispose(): void;
|
|
52
70
|
}
|
|
53
71
|
export declare function createAccountQueryPersistence(queryClient: QueryClient, config: AccountQueriesConfig): AccountQueryPersistence;
|
|
54
72
|
//# sourceMappingURL=accountQueryPersistence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountQueryPersistence.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/accountQueryPersistence.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"accountQueryPersistence.d.ts","sourceRoot":"","sources":["../../../../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AG,MAAM,IAAI,CAAC;CAC7C;AAMD,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,oBAAoB,GAC3B,uBAAuB,CA2HzB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storage format and restore rules shared by the SDK's two query caches:
|
|
3
|
+
* the account-agnostic one (`attachQueryPersistence`) and the per-account one
|
|
4
|
+
* (`createAccountQueryPersistence`).
|
|
5
|
+
*
|
|
6
|
+
* A blob is `{ buster, timestamp, clientState }`, TanStack's persisted-client
|
|
7
|
+
* shape. Restoring it treats its two halves differently:
|
|
8
|
+
*
|
|
9
|
+
* - Queries are served before any refetch, so a query written by another
|
|
10
|
+
* build, in whatever shape that build used, is dropped (`getOxyBuildId`).
|
|
11
|
+
* - Paused mutations are the user's queued actions (a star, a send made
|
|
12
|
+
* offline). A deploy must not lose them, so they are restored whatever build
|
|
13
|
+
* wrote them; the current build's `setMutationDefaults` replays them.
|
|
14
|
+
*/
|
|
15
|
+
import { type Mutation, type Query, type QueryClient } from '@tanstack/react-query';
|
|
16
|
+
/** The SDK's own account-agnostic query roots, persisted by `attachQueryPersistence`. */
|
|
17
|
+
export declare const PERSISTED_QUERY_PREFIXES: ReadonlyArray<string>;
|
|
18
|
+
/**
|
|
19
|
+
* SDK queries whose data (or key) carries a signed, expiring URL. Never
|
|
20
|
+
* written to disk: a restored one would serve an expired URL.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SDK_MEMORY_ONLY_ROOTS: ReadonlyArray<string>;
|
|
23
|
+
export interface PersistFilters {
|
|
24
|
+
shouldDehydrateQuery: (query: Query) => boolean;
|
|
25
|
+
shouldDehydrateMutation: (mutation: Mutation) => boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function rootOf(query: Query): string | null;
|
|
28
|
+
/** Serialize what the filters select, stamped with this build. */
|
|
29
|
+
export declare function snapshot(queryClient: QueryClient, filters: PersistFilters): string;
|
|
30
|
+
/**
|
|
31
|
+
* Hydrate a stored blob into the client, synchronously, so a caller can check
|
|
32
|
+
* it is still wanted immediately before. Returns false when there was nothing
|
|
33
|
+
* usable (absent, unreadable or expired), in which case the caller removes it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function hydrateSnapshot(queryClient: QueryClient, raw: string | null, maxAge: number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Write the filtered cache on every change, at most once per `throttleMs`.
|
|
38
|
+
* `write` receives the serialized snapshot; `flush()` writes now.
|
|
39
|
+
*/
|
|
40
|
+
export declare function subscribeSnapshots(queryClient: QueryClient, filters: PersistFilters, throttleMs: number, write: (serialized: string) => void): {
|
|
41
|
+
flush: () => void;
|
|
42
|
+
unsubscribe: () => void;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=persistedQueryCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistedQueryCache.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/persistedQueryCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAG/B,yFAAyF;AACzF,eAAO,MAAM,wBAAwB,EAAE,aAAa,CAAC,MAAM,CAM1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAKvD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,oBAAoB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IAChD,uBAAuB,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC;CAC1D;AAQD,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAGlD;AAED,kEAAkE;AAClE,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAOlF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAiBrG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,GAClC;IAAE,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,IAAI,CAAA;CAAE,CAqBhD"}
|