@interop/was-react 0.19.0 → 0.20.1
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/README.md +4 -3
- package/dist/auth/verifyResponse.d.ts.map +1 -1
- package/dist/auth/verifyResponse.js +10 -5
- package/dist/auth/verifyResponse.js.map +1 -1
- package/dist/identity/agents.d.ts +5 -0
- package/dist/identity/agents.d.ts.map +1 -1
- package/dist/identity/agents.js +10 -3
- package/dist/identity/agents.js.map +1 -1
- package/dist/identity/seedCredential.d.ts +5 -1
- package/dist/identity/seedCredential.d.ts.map +1 -1
- package/dist/identity/seedCredential.js +15 -28
- package/dist/identity/seedCredential.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.d.ts +3 -2
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/hooks.js +8 -4
- package/dist/react/hooks.js.map +1 -1
- package/dist/session/authStore.d.ts +9 -0
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +113 -47
- package/dist/session/authStore.js.map +1 -1
- package/dist/session/localWipe.d.ts +1 -1
- package/dist/session/localWipe.js +2 -2
- package/dist/session/localWipe.js.map +1 -1
- package/dist/storage/adopt.d.ts +4 -1
- package/dist/storage/adopt.d.ts.map +1 -1
- package/dist/storage/adopt.js +4 -3
- package/dist/storage/adopt.js.map +1 -1
- package/dist/storage/descriptorManager.d.ts +1 -0
- package/dist/storage/descriptorManager.d.ts.map +1 -1
- package/dist/storage/descriptorManager.js +39 -21
- package/dist/storage/descriptorManager.js.map +1 -1
- package/dist/storage/entityStore.d.ts.map +1 -1
- package/dist/storage/entityStore.js +3 -0
- package/dist/storage/entityStore.js.map +1 -1
- package/dist/storage/publicUrl.js +3 -3
- package/dist/storage/storageContext.d.ts +178 -0
- package/dist/storage/storageContext.d.ts.map +1 -0
- package/dist/storage/storageContext.js +331 -0
- package/dist/storage/storageContext.js.map +1 -0
- package/dist/storage/storageManager.d.ts +61 -76
- package/dist/storage/storageManager.d.ts.map +1 -1
- package/dist/storage/storageManager.js +59 -150
- package/dist/storage/storageManager.js.map +1 -1
- package/dist/storage/syncController.d.ts +10 -1
- package/dist/storage/syncController.d.ts.map +1 -1
- package/dist/storage/syncController.js +12 -4
- package/dist/storage/syncController.js.map +1 -1
- package/dist/storage/syncStatusStore.d.ts +23 -2
- package/dist/storage/syncStatusStore.d.ts.map +1 -1
- package/dist/storage/syncStatusStore.js +22 -13
- package/dist/storage/syncStatusStore.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +24 -10
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +91 -36
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/storage/wasSync.d.ts +24 -9
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +52 -21
- package/dist/storage/wasSync.js.map +1 -1
- package/dist/storage/writerId.d.ts +36 -0
- package/dist/storage/writerId.d.ts.map +1 -0
- package/dist/storage/writerId.js +76 -0
- package/dist/storage/writerId.js.map +1 -0
- package/package.json +9 -9
- package/dist/storage/rehydrate.d.ts +0 -64
- package/dist/storage/rehydrate.d.ts.map +0 -1
- package/dist/storage/rehydrate.js +0 -132
- package/dist/storage/rehydrate.js.map +0 -1
|
@@ -126,46 +126,64 @@ export function createDescriptorManager({ collections, sessionStore, anonStore }
|
|
|
126
126
|
* private collection the cache does not cover. A first login has no cache at
|
|
127
127
|
* all, and the connected replica must open epoch-aware BEFORE sync starts:
|
|
128
128
|
* the adoption merge writes into it right after open, and epoch-from-birth
|
|
129
|
-
* leaves no single-key fallback to write under.
|
|
130
|
-
* leaves
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
129
|
+
* leaves no single-key fallback to write under. A live read that answers
|
|
130
|
+
* "no descriptor" leaves that collection fail-closed until the sync
|
|
131
|
+
* bootstrap's own read lands. A read that FAILS is an unknown answer, not an
|
|
132
|
+
* absent one, and `onReadFailure` decides what it costs. `'reject'` (login)
|
|
133
|
+
* rejects the whole completion: opening the replica over a guess would hand
|
|
134
|
+
* a correctly provisioned collection the placeholder cipher and fail the
|
|
135
|
+
* adoption merge on it, so the caller falls back to `local` with the error,
|
|
136
|
+
* where the anonymous replica is intact for a retry. `'skip'` (a hot
|
|
137
|
+
* restore, which adopts nothing) warns and leaves that collection
|
|
138
|
+
* fail-closed for the sync bootstrap to repair, so a reload while offline
|
|
139
|
+
* still restores the connected session. Freshly fetched descriptors enter
|
|
140
|
+
* the offline cache immediately (best-effort), and come back separately as
|
|
141
|
+
* `fresh` so the sync bootstrap can reuse them instead of re-issuing the
|
|
142
|
+
* same reads seconds later (cached descriptors are NOT passed on -- the
|
|
143
|
+
* bootstrap read is their freshness refresh).
|
|
136
144
|
*
|
|
137
145
|
* @param options {object}
|
|
138
146
|
* @param [options.cached] {Record<string, CollectionEncryption>}
|
|
139
147
|
* @param options.identity {IdentityAgents}
|
|
140
148
|
* @param options.parsed {ParsedGrants}
|
|
149
|
+
* @param options.onReadFailure {'reject' | 'skip'}
|
|
141
150
|
* @returns {Promise<object>} `descriptors` (the completed set, or
|
|
142
151
|
* undefined when there are none) and `fresh` (the live-read subset)
|
|
143
152
|
*/
|
|
144
|
-
async function completeDescriptors({ cached, identity, parsed }) {
|
|
153
|
+
async function completeDescriptors({ cached, identity, parsed, onReadFailure }) {
|
|
145
154
|
const missing = collections.filter(collection => !isPublicCollection(collection) &&
|
|
146
155
|
parsed.byCollectionId[collection.id] !== undefined &&
|
|
147
156
|
!cached?.[collection.id]);
|
|
148
157
|
if (missing.length === 0) {
|
|
149
158
|
return { descriptors: cached, fresh: {} };
|
|
150
159
|
}
|
|
160
|
+
const { descriptors: fetched, failures } = await readRemoteDescriptors({
|
|
161
|
+
parsed,
|
|
162
|
+
zcapClient: identity.zcapClient,
|
|
163
|
+
collections: missing
|
|
164
|
+
});
|
|
165
|
+
if (failures.length > 0) {
|
|
166
|
+
if (onReadFailure === 'reject') {
|
|
167
|
+
throw failures[0]?.err;
|
|
168
|
+
}
|
|
169
|
+
for (const { collection, err } of failures) {
|
|
170
|
+
console.warn(`Opening collection "${collection.id}" fail-closed: its encryption ` +
|
|
171
|
+
`descriptor could not be read at restore.`, err);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (Object.keys(fetched).length === 0) {
|
|
175
|
+
return { descriptors: cached, fresh: {} };
|
|
176
|
+
}
|
|
151
177
|
try {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
collections: missing
|
|
178
|
+
await cacheDescriptors({
|
|
179
|
+
descriptors: fetched,
|
|
180
|
+
controllerDid: identity.controllerDid
|
|
156
181
|
});
|
|
157
|
-
if (Object.keys(fetched).length > 0) {
|
|
158
|
-
await cacheDescriptors({
|
|
159
|
-
descriptors: fetched,
|
|
160
|
-
controllerDid: identity.controllerDid
|
|
161
|
-
});
|
|
162
|
-
return { descriptors: { ...fetched, ...cached }, fresh: fetched };
|
|
163
|
-
}
|
|
164
182
|
}
|
|
165
183
|
catch (err) {
|
|
166
|
-
console.warn('Failed to
|
|
184
|
+
console.warn('Failed to cache encryption descriptors at login:', err);
|
|
167
185
|
}
|
|
168
|
-
return { descriptors: cached, fresh:
|
|
186
|
+
return { descriptors: { ...fetched, ...cached }, fresh: fetched };
|
|
169
187
|
}
|
|
170
188
|
return {
|
|
171
189
|
loadOrMintAnonDescriptors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptorManager.js","sourceRoot":"","sources":["../../src/storage/descriptorManager.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAA4B,MAAM,cAAc,CAAA;AAE3E,OAAO,EAAE,qBAAqB,EAAkB,MAAM,0BAA0B,CAAA;A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C;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;QAC3C,CAAC;QACD,IAAI,CAAC;YACH,MAAM,gBAAgB,CAAC;gBACrB,WAAW,EAAE,OAAO;gBACpB,aAAa,EAAE,QAAQ,CAAC,aAAa;aACtC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,kDAAkD,EAAE,GAAG,CAAC,CAAA;QACvE,CAAC;QACD,OAAO,EAAE,WAAW,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;IACnE,CAAC;IAED,OAAO;QACL,yBAAyB;QACzB,qBAAqB;QACrB,gBAAgB;QAChB,mBAAmB;KACpB,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityStore.d.ts","sourceRoot":"","sources":["../../src/storage/entityStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"entityStore.d.ts","sourceRoot":"","sources":["../../src/storage/entityStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAOnE;;;;;GAKG;AACH,KAAK,eAAe,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC,GAAG;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA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A;CAChE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACxD,aAAa,EAAE,MAAM,GACpB,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAqJzC"}
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
* local writes stay immediate so a single edit is snappy.
|
|
23
23
|
*/
|
|
24
24
|
import { create } from 'zustand';
|
|
25
|
+
// The verbs resolve the ACTIVE session's context on every call rather than
|
|
26
|
+
// capturing one: an entity store is created at module level, before any
|
|
27
|
+
// session exists, and outlives every session it serves.
|
|
25
28
|
import { requireStore, requireRemoteStore, stampLww } from './storageManager.js';
|
|
26
29
|
import { lwwFields, remotePayloadWins } from '../sync/lww.js';
|
|
27
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityStore.js","sourceRoot":"","sources":["../../src/storage/entityStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAAqC,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AA6F7D;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,aAAqB;IAErB,OAAO,MAAM,CAAiB,GAAG,CAAC,EAAE;QAClC,uEAAuE;QACvE,2EAA2E;QAC3E,2EAA2E;QAC3E,0EAA0E;QAC1E,uEAAuE;QACvE,MAAM,OAAO,GAET,EAAE,CAAA;QACN,IAAI,cAAc,GAAG,KAAK,CAAA;QAE1B;;WAEG;QACH,SAAS,YAAY;YACnB,cAAc,GAAG,KAAK,CAAA;YACtB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;g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GAAG,IAAI,CAAC,SAAS;qBACxB,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC;qBAC/C,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAS,CAAC,CAAA;gBACtC,OAAO;oBACL,IAAI;oBACJ,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;iBAC1D,CAAA;YACH,CAAC;SACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* logical collection key and a document id, composes the stable,
|
|
7
7
|
* world-readable resource URL of that document in a public (plaintext)
|
|
8
8
|
* collection. It routes the logical key to its WAS collection id through the
|
|
9
|
-
*
|
|
10
|
-
* requires an open {@link LocalStore} and a wallet-connected session
|
|
11
|
-
* remote
|
|
9
|
+
* active session's storage context exactly as {@link EntityStore.query} does,
|
|
10
|
+
* so it requires an open {@link LocalStore} and a wallet-connected session
|
|
11
|
+
* (a remote store), and fails closed on non-public collections.
|
|
12
12
|
*/
|
|
13
13
|
import { requireStore, requireRemoteStore } from './storageManager.js';
|
|
14
14
|
/**
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { StoreRegistry } from '../config.js';
|
|
2
|
+
import type { Json } from '../sync/index.js';
|
|
3
|
+
import type { LwwFields } from '../sync/lww.js';
|
|
4
|
+
import type { LocalStore } from './localStore.js';
|
|
5
|
+
import { type SyncStatusStore } from './syncStatusStore.js';
|
|
6
|
+
import type { WasRemoteStore } from './wasRemoteStore.js';
|
|
7
|
+
export declare class StorageContext {
|
|
8
|
+
#private;
|
|
9
|
+
/**
|
|
10
|
+
* The app's per-collection hydrate/patch handlers; the change patches and the
|
|
11
|
+
* scheduled re-hydrates route on it.
|
|
12
|
+
*/
|
|
13
|
+
readonly registry: StoreRegistry;
|
|
14
|
+
/**
|
|
15
|
+
* This session's per-collection replication statuses.
|
|
16
|
+
*/
|
|
17
|
+
readonly syncStatus: SyncStatusStore;
|
|
18
|
+
/**
|
|
19
|
+
* @param options {object}
|
|
20
|
+
* @param options.registry {StoreRegistry}
|
|
21
|
+
* @param options.writerId {string} the resolved per-install writer id (see
|
|
22
|
+
* `getWriterId`), the value every stamp of this session carries
|
|
23
|
+
*/
|
|
24
|
+
constructor({ registry, writerId }: {
|
|
25
|
+
registry: StoreRegistry;
|
|
26
|
+
writerId: string;
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* The writer id this session stamps with: an unkeyed, clearable attribution
|
|
30
|
+
* label, never an identity.
|
|
31
|
+
*
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
get writerId(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Replaces the in-memory writer id with a fresh one (the clear-data wipe,
|
|
37
|
+
* after `clearPersistedWriterId` removed the persisted one). The session
|
|
38
|
+
* keeps running over its new anonymous replica and its write verbs still
|
|
39
|
+
* have to stamp; nothing persists the new id, so the next run resolves and
|
|
40
|
+
* stores an id of its own.
|
|
41
|
+
*
|
|
42
|
+
* @returns {string} the new id
|
|
43
|
+
*/
|
|
44
|
+
resetWriterId(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Stamps a payload with fresh last-write-wins fields: the current instant as
|
|
47
|
+
* `updatedAt` and this session's writer id. Any values the caller supplied
|
|
48
|
+
* are overwritten -- a stamp must describe THIS write, or a hydrated doc's
|
|
49
|
+
* older `updatedAt` would ride a later edit and lose the conflict.
|
|
50
|
+
*
|
|
51
|
+
* @param payload {object}
|
|
52
|
+
* @returns {object} the payload with the LWW fields set
|
|
53
|
+
*/
|
|
54
|
+
stampLww<T extends {
|
|
55
|
+
id: string;
|
|
56
|
+
}>(payload: T): T & LwwFields;
|
|
57
|
+
/**
|
|
58
|
+
* Installs the opened replica and makes this the process's active context
|
|
59
|
+
* (the one the app-facing facades and the entity-store verbs resolve to).
|
|
60
|
+
* Throws if ANOTHER context still has a replica attached: two live sessions
|
|
61
|
+
* in one process would write into each other's entity stores.
|
|
62
|
+
*
|
|
63
|
+
* @param store {LocalStore}
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
66
|
+
attachStore(store: LocalStore): void;
|
|
67
|
+
/**
|
|
68
|
+
* Releases the replica (the caller closes or deletes it), cancels every
|
|
69
|
+
* pending re-hydrate, and releases the process-wide active pointer when this
|
|
70
|
+
* context holds it -- the mirror of {@link attachStore}'s claim. Anything
|
|
71
|
+
* still in flight against the old replica sees the generation change and
|
|
72
|
+
* ends as a no-op; the facades throw until the next attach claims a live
|
|
73
|
+
* context, rather than resolving a retired one.
|
|
74
|
+
*
|
|
75
|
+
* @returns {LocalStore | null} the replica that was attached, if any
|
|
76
|
+
*/
|
|
77
|
+
detachStore(): LocalStore | null;
|
|
78
|
+
/**
|
|
79
|
+
* Whether a replica is attached.
|
|
80
|
+
*
|
|
81
|
+
* @returns {boolean}
|
|
82
|
+
*/
|
|
83
|
+
hasStore(): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The attached replica, or throws if none is open.
|
|
86
|
+
*
|
|
87
|
+
* @returns {LocalStore}
|
|
88
|
+
*/
|
|
89
|
+
requireStore(): LocalStore;
|
|
90
|
+
/**
|
|
91
|
+
* Runs `op` against the replica attached now and resolves with its result
|
|
92
|
+
* only if that same replica is still attached when `op` settles. Resolves
|
|
93
|
+
* `undefined` when no replica is attached, or when it was detached or
|
|
94
|
+
* swapped meanwhile -- including when `op` rejected after the swap, since a
|
|
95
|
+
* read torn by its own teardown is expected noise, not an error. A rejection
|
|
96
|
+
* against a replica that is still attached propagates.
|
|
97
|
+
*
|
|
98
|
+
* @param op {(store: LocalStore) => Promise<T>}
|
|
99
|
+
* @returns {Promise<T | undefined>}
|
|
100
|
+
*/
|
|
101
|
+
whileAttached<T>(op: (store: LocalStore) => Promise<T>): Promise<T | undefined>;
|
|
102
|
+
/**
|
|
103
|
+
* Installs the connected session's delegated remote store (once background
|
|
104
|
+
* sync has bootstrapped it from the granted zcaps).
|
|
105
|
+
*
|
|
106
|
+
* @param store {WasRemoteStore}
|
|
107
|
+
* @returns {void}
|
|
108
|
+
*/
|
|
109
|
+
attachRemoteStore(store: WasRemoteStore): void;
|
|
110
|
+
/**
|
|
111
|
+
* Releases the remote store (logout / sync teardown).
|
|
112
|
+
*
|
|
113
|
+
* @returns {void}
|
|
114
|
+
*/
|
|
115
|
+
detachRemoteStore(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Whether a connected session's remote store is available.
|
|
118
|
+
*
|
|
119
|
+
* @returns {boolean}
|
|
120
|
+
*/
|
|
121
|
+
hasRemoteStore(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* The connected session's remote store, or throws while no wallet-connected
|
|
124
|
+
* session is active (local-only mode, or sync has not bootstrapped yet).
|
|
125
|
+
*
|
|
126
|
+
* @returns {WasRemoteStore}
|
|
127
|
+
*/
|
|
128
|
+
requireRemoteStore(): WasRemoteStore;
|
|
129
|
+
/**
|
|
130
|
+
* Hydrates every registered store from the attached replica.
|
|
131
|
+
*
|
|
132
|
+
* @returns {Promise<void>}
|
|
133
|
+
*/
|
|
134
|
+
hydrateAll(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Empties every registered store (logout).
|
|
137
|
+
*
|
|
138
|
+
* @returns {void}
|
|
139
|
+
*/
|
|
140
|
+
clearEntityStores(): void;
|
|
141
|
+
/**
|
|
142
|
+
* Patches ONE store from a single RxDB change event (per-doc, no
|
|
143
|
+
* whole-collection re-hydrate): decrypt the changed envelope, then upsert the
|
|
144
|
+
* payload (INSERT / UPDATE, including conflict-resolved rows) or drop it
|
|
145
|
+
* (DELETE / tombstone). The `uuid -> envelopeId` index is kept in step so a
|
|
146
|
+
* later local edit of a remotely-created doc still finds its envelope. Falls
|
|
147
|
+
* back to a debounced whole-collection re-hydrate if the envelope is missing
|
|
148
|
+
* or fails to decrypt.
|
|
149
|
+
*
|
|
150
|
+
* Fired floating off the RxDB change stream, so a logout/login teardown can
|
|
151
|
+
* detach or swap the replica while the decrypt is in flight; the decrypt runs
|
|
152
|
+
* under {@link StorageContext.whileAttached}, so an event that outlives its
|
|
153
|
+
* replica is dropped rather than patched into the next session's stores.
|
|
154
|
+
*
|
|
155
|
+
* @param collectionKey {string}
|
|
156
|
+
* @param event {object} an RxDB change event (operation + documentData)
|
|
157
|
+
* @returns {Promise<void>}
|
|
158
|
+
*/
|
|
159
|
+
patchFromChange(collectionKey: string, event: {
|
|
160
|
+
operation: string;
|
|
161
|
+
documentData?: {
|
|
162
|
+
id: string;
|
|
163
|
+
data?: Json;
|
|
164
|
+
_deleted?: boolean;
|
|
165
|
+
};
|
|
166
|
+
}): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Schedules a debounced re-hydrate of one collection's store after a pull.
|
|
169
|
+
* A no-op without an attached replica, and the timer itself is bound to the
|
|
170
|
+
* replica attached now: a detach cancels it, and one that still fires after
|
|
171
|
+
* a swap finds the generation changed and does nothing.
|
|
172
|
+
*
|
|
173
|
+
* @param collectionKey {string}
|
|
174
|
+
* @returns {void}
|
|
175
|
+
*/
|
|
176
|
+
scheduleRehydrate(collectionKey: string): void;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=storageContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storageContext.d.ts","sourceRoot":"","sources":["../../src/storage/storageContext.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAKjD,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,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