@interocitor/core 0.0.0-beta.10
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/LICENSE +21 -0
- package/README.md +706 -0
- package/dist/adapters/cloudflare.d.ts +78 -0
- package/dist/adapters/cloudflare.d.ts.map +1 -0
- package/dist/adapters/cloudflare.js +325 -0
- package/dist/adapters/google-drive.d.ts +64 -0
- package/dist/adapters/google-drive.d.ts.map +1 -0
- package/dist/adapters/google-drive.js +339 -0
- package/dist/adapters/memory.d.ts +53 -0
- package/dist/adapters/memory.d.ts.map +1 -0
- package/dist/adapters/memory.js +182 -0
- package/dist/adapters/webdav.d.ts +70 -0
- package/dist/adapters/webdav.d.ts.map +1 -0
- package/dist/adapters/webdav.js +323 -0
- package/dist/core/codec.d.ts +20 -0
- package/dist/core/codec.d.ts.map +1 -0
- package/dist/core/codec.js +102 -0
- package/dist/core/compaction.d.ts +45 -0
- package/dist/core/compaction.d.ts.map +1 -0
- package/dist/core/compaction.js +190 -0
- package/dist/core/connected-stores.d.ts +77 -0
- package/dist/core/connected-stores.d.ts.map +1 -0
- package/dist/core/connected-stores.js +76 -0
- package/dist/core/crdt.d.ts +36 -0
- package/dist/core/crdt.d.ts.map +1 -0
- package/dist/core/crdt.js +174 -0
- package/dist/core/errors.d.ts +47 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +61 -0
- package/dist/core/flush.d.ts +9 -0
- package/dist/core/flush.d.ts.map +1 -0
- package/dist/core/flush.js +98 -0
- package/dist/core/hlc.d.ts +25 -0
- package/dist/core/hlc.d.ts.map +1 -0
- package/dist/core/hlc.js +75 -0
- package/dist/core/ids.d.ts +49 -0
- package/dist/core/ids.d.ts.map +1 -0
- package/dist/core/ids.js +132 -0
- package/dist/core/internals.d.ts +33 -0
- package/dist/core/internals.d.ts.map +1 -0
- package/dist/core/internals.js +72 -0
- package/dist/core/manifest.d.ts +56 -0
- package/dist/core/manifest.d.ts.map +1 -0
- package/dist/core/manifest.js +203 -0
- package/dist/core/pull.d.ts +26 -0
- package/dist/core/pull.d.ts.map +1 -0
- package/dist/core/pull.js +113 -0
- package/dist/core/row-id.d.ts +12 -0
- package/dist/core/row-id.d.ts.map +1 -0
- package/dist/core/row-id.js +11 -0
- package/dist/core/schema-types.d.ts +26 -0
- package/dist/core/schema-types.d.ts.map +1 -0
- package/dist/core/schema-types.js +31 -0
- package/dist/core/schema-types.type-test.d.ts +2 -0
- package/dist/core/schema-types.type-test.d.ts.map +1 -0
- package/dist/core/schema-types.type-test.js +224 -0
- package/dist/core/sync-engine.d.ts +364 -0
- package/dist/core/sync-engine.d.ts.map +1 -0
- package/dist/core/sync-engine.js +2475 -0
- package/dist/core/table.d.ts +260 -0
- package/dist/core/table.d.ts.map +1 -0
- package/dist/core/table.js +461 -0
- package/dist/core/types.d.ts +952 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +6 -0
- package/dist/crypto/encryption.d.ts +61 -0
- package/dist/crypto/encryption.d.ts.map +1 -0
- package/dist/crypto/encryption.js +216 -0
- package/dist/crypto/keys.d.ts +48 -0
- package/dist/crypto/keys.d.ts.map +1 -0
- package/dist/crypto/keys.js +54 -0
- package/dist/handshake/channel.d.ts +117 -0
- package/dist/handshake/channel.d.ts.map +1 -0
- package/dist/handshake/channel.js +245 -0
- package/dist/handshake/index.d.ts +216 -0
- package/dist/handshake/index.d.ts.map +1 -0
- package/dist/handshake/index.js +199 -0
- package/dist/handshake/qr-public.d.ts +3 -0
- package/dist/handshake/qr-public.d.ts.map +1 -0
- package/dist/handshake/qr-public.js +1 -0
- package/dist/handshake/qr.d.ts +100 -0
- package/dist/handshake/qr.d.ts.map +1 -0
- package/dist/handshake/qr.js +102 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/storage/credential-store.d.ts +122 -0
- package/dist/storage/credential-store.d.ts.map +1 -0
- package/dist/storage/credential-store.js +356 -0
- package/dist/storage/local-store.d.ts +64 -0
- package/dist/storage/local-store.d.ts.map +1 -0
- package/dist/storage/local-store.js +490 -0
- package/dist/storage/reset.d.ts +10 -0
- package/dist/storage/reset.d.ts.map +1 -0
- package/dist/storage/reset.js +18 -0
- package/package.json +76 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync Engine
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates:
|
|
5
|
+
* - Local writes → outbox → flush to cloud (primary + replicas)
|
|
6
|
+
* - Cloud poll → download → decrypt → CRDT merge → local DB
|
|
7
|
+
* - Rehydration from manifest-authoritative snapshot
|
|
8
|
+
*
|
|
9
|
+
* Network is never required for reads or local writes.
|
|
10
|
+
* All data operations hit IndexedDB first; cloud sync is async.
|
|
11
|
+
*/
|
|
12
|
+
import type { StorageAdapter, SyncConfig, LocalStoreAdapter, Manifest, Row, SyncEventListener, WhereClause, SyncInitialState, QueryDescriptor, QueryExecutionOptions, QueryCacheSnapshot, ReadinessAwareQueryExecutor, RowDescriptor, RowCacheSnapshot, StoredFileMetadata, ImageInput, PutImageOptions, StoredImage, StoredImageBlobUrl, StoredImageMetadata } from './types.ts';
|
|
13
|
+
import { Table } from './table.ts';
|
|
14
|
+
import { type ConnectedStoresApi } from './connected-stores.ts';
|
|
15
|
+
/**
|
|
16
|
+
* Typed sync engine. `S` is your database shape — inferred automatically
|
|
17
|
+
* from `InferSchemaType<typeof schema>`. No default: either typed or `any`.
|
|
18
|
+
*
|
|
19
|
+
* Initialization is automatic — just construct and use. No `await engine.init()` needed.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const schema = { tables: { tasks: { fields: { title: types.string } } } }
|
|
23
|
+
* satisfies DatabaseSchemaDefinition;
|
|
24
|
+
*
|
|
25
|
+
* type DB = InferSchemaType<typeof schema>;
|
|
26
|
+
*
|
|
27
|
+
* // Local-only (no adapter):
|
|
28
|
+
* const db = new Interocitor<DB>({ schema, dbName: 'myapp', appName: 'My App' });
|
|
29
|
+
* const tasks = await db.table('tasks').query(); // ready immediately
|
|
30
|
+
*
|
|
31
|
+
* // With remote sync:
|
|
32
|
+
* const db = new Interocitor<DB>(adapter, { schema, remotePath: '/App', appName: 'App' });
|
|
33
|
+
* await db.connect(); // authenticate + sync
|
|
34
|
+
*
|
|
35
|
+
* db.table('other'); // TS error — 'other' is not keyof DB
|
|
36
|
+
*/
|
|
37
|
+
export interface InterocitorInitContext<S extends Record<string, Record<string, unknown>>> extends ReadinessAwareQueryExecutor {
|
|
38
|
+
put<K extends keyof S & string>(table: K, rowId: string, columns: Partial<S[K]>, userId?: string): Promise<S[K]>;
|
|
39
|
+
delete<K extends keyof S & string>(table: K, rowId: string, userId?: string): Promise<void>;
|
|
40
|
+
query<K extends keyof S & string>(table: K): Promise<S[K][]>;
|
|
41
|
+
queryWhere<K extends keyof S & string>(table: K, clause: WhereClause): Promise<S[K][]>;
|
|
42
|
+
table<K extends keyof S & string>(name: K): Table<S[K]>;
|
|
43
|
+
on(listener: SyncEventListener): () => void;
|
|
44
|
+
getDeviceId(): string;
|
|
45
|
+
getMeshId(): string | undefined;
|
|
46
|
+
isEncrypted(): boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare class Interocitor<S extends Record<string, Record<string, unknown>>> implements ReadinessAwareQueryExecutor {
|
|
49
|
+
readonly InitContext: InterocitorInitContext<S>;
|
|
50
|
+
private adapter;
|
|
51
|
+
private config;
|
|
52
|
+
private serverId;
|
|
53
|
+
private local;
|
|
54
|
+
private deviceId;
|
|
55
|
+
private hlc;
|
|
56
|
+
private encryptionKey;
|
|
57
|
+
private encrypted;
|
|
58
|
+
private passphrase;
|
|
59
|
+
private tables;
|
|
60
|
+
private manifest;
|
|
61
|
+
private remotePoisonError;
|
|
62
|
+
private knownTables;
|
|
63
|
+
private flushTimer;
|
|
64
|
+
private pendingCount;
|
|
65
|
+
private compactWarningEmitted;
|
|
66
|
+
private compactInFlight;
|
|
67
|
+
private compactScheduleVersion;
|
|
68
|
+
private compactCheckTimer;
|
|
69
|
+
private compactRunTimer;
|
|
70
|
+
private batchTimer;
|
|
71
|
+
private pendingBatch;
|
|
72
|
+
private pollTimer;
|
|
73
|
+
private pollBaseIntervalMs;
|
|
74
|
+
private pollCurrentIntervalMs;
|
|
75
|
+
private pollGeneration;
|
|
76
|
+
private visibilityChangeListener;
|
|
77
|
+
private unsubscribeRemoteInvalidations;
|
|
78
|
+
private remoteInvalidationPullPromise;
|
|
79
|
+
private remoteInvalidationPullQueued;
|
|
80
|
+
private remoteInvalidationCooldownTimer;
|
|
81
|
+
private remoteInvalidationCooldownQueued;
|
|
82
|
+
private initialized;
|
|
83
|
+
private connected;
|
|
84
|
+
private initPromise;
|
|
85
|
+
private connectPromise;
|
|
86
|
+
private readonly logLevel;
|
|
87
|
+
private listeners;
|
|
88
|
+
private readonly schema?;
|
|
89
|
+
private readonly credentialStore;
|
|
90
|
+
private readonly dbName;
|
|
91
|
+
private connectedStoresApi;
|
|
92
|
+
private queryCache;
|
|
93
|
+
private queryCacheByTable;
|
|
94
|
+
private rowCache;
|
|
95
|
+
private rowCacheByTable;
|
|
96
|
+
/**
|
|
97
|
+
* Create a sync engine.
|
|
98
|
+
*
|
|
99
|
+
* Pass a remote adapter up front for immediate sync support, or pass only
|
|
100
|
+
* config to start fully local and attach a remote later with
|
|
101
|
+
* {@link setRemoteStorage}.
|
|
102
|
+
*
|
|
103
|
+
* The schema type `S` is inferred automatically from the `schema` field in
|
|
104
|
+
* config — no manual type parameter needed:
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const engine = new Interocitor(adapter, { schema, remotePath: '/App', appName: 'App' });
|
|
108
|
+
* const tasks = engine.table('tasks'); // Table<{ title: string; status: 'open' | 'done' }>
|
|
109
|
+
*/
|
|
110
|
+
constructor(config: SyncConfig<S>);
|
|
111
|
+
constructor(adapter: StorageAdapter | null, config: SyncConfig<S>);
|
|
112
|
+
private log;
|
|
113
|
+
private supportsRemoteInvalidations;
|
|
114
|
+
/** Await this before any storage operation. Returns the shared init promise. */
|
|
115
|
+
private ensureReady;
|
|
116
|
+
private putNow;
|
|
117
|
+
private deleteNow;
|
|
118
|
+
/**
|
|
119
|
+
* Append the op to the in-flight batch. If we are inside a `batch()` block,
|
|
120
|
+
* the op stays buffered until the block ends. Otherwise it joins an
|
|
121
|
+
* implicit window of `batchWindowMs`. Either way the result is one
|
|
122
|
+
* ChangeEntry per batch instead of one per write.
|
|
123
|
+
*/
|
|
124
|
+
private queueOpForBatchedFlush;
|
|
125
|
+
private queryNow;
|
|
126
|
+
private queryWhereNow;
|
|
127
|
+
/** Public readiness signal. Used by render-time consumers to decide
|
|
128
|
+
* between sync cache reads and awaiting a load. */
|
|
129
|
+
isReady(): boolean;
|
|
130
|
+
/** Stable cache key for a descriptor. Owned by core. */
|
|
131
|
+
getQueryCacheKey(descriptor: QueryDescriptor): string;
|
|
132
|
+
/** Sync cache snapshot. Never starts a load. Empty/pending/ready/error. */
|
|
133
|
+
readQueryCache(descriptor: QueryDescriptor): QueryCacheSnapshot;
|
|
134
|
+
/**
|
|
135
|
+
* Load rows through the cache.
|
|
136
|
+
*
|
|
137
|
+
* - If a snapshot exists and `bypassCache` is not set, dedupes to the
|
|
138
|
+
* in-flight promise (when pending) or starts a refresh that keeps the
|
|
139
|
+
* stale rows visible until it resolves.
|
|
140
|
+
* - When the engine is not yet ready, falls through `ensureReady()`; if
|
|
141
|
+
* `bypassCache` is set, never returns the cached rows.
|
|
142
|
+
*/
|
|
143
|
+
loadQueryRows(descriptor: QueryDescriptor, options?: QueryExecutionOptions): Promise<Row[]>;
|
|
144
|
+
private runQuery;
|
|
145
|
+
private indexCacheByTable;
|
|
146
|
+
/**
|
|
147
|
+
* Mark all cached queries against `table` as stale and refresh them in the
|
|
148
|
+
* background. Stale rows stay visible. Called from local mutations.
|
|
149
|
+
*/
|
|
150
|
+
private invalidateQueryCacheForTable;
|
|
151
|
+
/** Stable cache key for a row descriptor. Owned by core. */
|
|
152
|
+
getRowCacheKey(descriptor: RowDescriptor): string;
|
|
153
|
+
/** Sync row cache snapshot. Never starts a load. */
|
|
154
|
+
readRowCache(descriptor: RowDescriptor): RowCacheSnapshot;
|
|
155
|
+
/**
|
|
156
|
+
* Load a row through the cache. Same dedupe + stale-while-revalidate
|
|
157
|
+
* semantics as `loadQueryRows`.
|
|
158
|
+
*/
|
|
159
|
+
loadRow(descriptor: RowDescriptor, options?: QueryExecutionOptions): Promise<Row | undefined>;
|
|
160
|
+
private runRow;
|
|
161
|
+
private indexRowCacheByTable;
|
|
162
|
+
/**
|
|
163
|
+
* Refresh all cached rows for a table. Called from emit() alongside the
|
|
164
|
+
* query cache invalidation. Keeps prior row visible while in-flight.
|
|
165
|
+
*
|
|
166
|
+
* Table-wide invalidation is intentional: Interocitor targets rare-update
|
|
167
|
+
* workloads, not realtime state streams. The over-fetch on a write is a
|
|
168
|
+
* fixed-cost reload of cached rows for that one table — cheap, simple,
|
|
169
|
+
* and matches the query cache strategy. Finer-grained per-rowId
|
|
170
|
+
* invalidation can be added later without changing this contract.
|
|
171
|
+
*/
|
|
172
|
+
private invalidateRowCacheForTable;
|
|
173
|
+
private get initContext();
|
|
174
|
+
private requireAdapter;
|
|
175
|
+
private requireRemotePath;
|
|
176
|
+
private storedFilePath;
|
|
177
|
+
private encodeStoredFile;
|
|
178
|
+
private decodeStoredFile;
|
|
179
|
+
private inferImageContentType;
|
|
180
|
+
private parseImageDataUrl;
|
|
181
|
+
private encodeImageInput;
|
|
182
|
+
private coerceImageMetadata;
|
|
183
|
+
private rebuildOutboxFromLocalState;
|
|
184
|
+
private get codecState();
|
|
185
|
+
private get manifestContext();
|
|
186
|
+
private acknowledgeManifest;
|
|
187
|
+
private clearScheduledFlush;
|
|
188
|
+
private clearCompactTimers;
|
|
189
|
+
private jitterDelay;
|
|
190
|
+
private stopPolling;
|
|
191
|
+
private startPolling;
|
|
192
|
+
/** Called by emit() to adapt the poll interval based on pull activity. */
|
|
193
|
+
private adaptPollInterval;
|
|
194
|
+
private stopRemoteInvalidations;
|
|
195
|
+
private startRemoteInvalidations;
|
|
196
|
+
private getRowHlc;
|
|
197
|
+
private rowToSyncOp;
|
|
198
|
+
private loadLocalState;
|
|
199
|
+
private ensureRowsCached;
|
|
200
|
+
private poisonRemote;
|
|
201
|
+
on(listener: SyncEventListener): () => void;
|
|
202
|
+
private emit;
|
|
203
|
+
private persistCredentials;
|
|
204
|
+
/**
|
|
205
|
+
* Compare the persisted credential record against the live meshId.
|
|
206
|
+
*
|
|
207
|
+
* Throws `MeshCredentialMismatchError` (and emits `credentials:meshMismatch`)
|
|
208
|
+
* when the credential store has a record under this `dbName` whose meshId
|
|
209
|
+
* disagrees with `manifest.meshId`. The remote is NOT poisoned — the local
|
|
210
|
+
* credential store has stale data from a previous mesh that shared the
|
|
211
|
+
* same dbName.
|
|
212
|
+
*/
|
|
213
|
+
private assertCredentialMeshParity;
|
|
214
|
+
private loadPersistedCredentials;
|
|
215
|
+
private clearPersistedCredentials;
|
|
216
|
+
private resolveEncryption;
|
|
217
|
+
private applyInitialState;
|
|
218
|
+
configureMesh(state: SyncInitialState): void;
|
|
219
|
+
/**
|
|
220
|
+
* Set or replace the mesh encryption passphrase before connecting.
|
|
221
|
+
*
|
|
222
|
+
* Apps may call this before init(), after init(), or after credentials
|
|
223
|
+
* arrive from pairing. It intentionally does not rebuild the engine or
|
|
224
|
+
* change remotePath/deviceId; it only invalidates the derived key so the
|
|
225
|
+
* next connect/flush uses the new passphrase.
|
|
226
|
+
*/
|
|
227
|
+
setPassphrase(passphrase: string): void;
|
|
228
|
+
/**
|
|
229
|
+
* Get the current mesh passphrase.
|
|
230
|
+
* Returns null if the mesh is unencrypted.
|
|
231
|
+
* Call after init() to ensure key derivation is complete.
|
|
232
|
+
*/
|
|
233
|
+
getPassphrase(): string | null;
|
|
234
|
+
/**
|
|
235
|
+
* Persist credentials to the OS keychain via biometrics.
|
|
236
|
+
* Call after pairing, or from a "Secure my keys" UI action.
|
|
237
|
+
* Returns true if saved, false if unavailable or user cancelled.
|
|
238
|
+
*/
|
|
239
|
+
secureWithBiometrics(): Promise<boolean>;
|
|
240
|
+
/**
|
|
241
|
+
* Explicit restore path for wiped / returning users.
|
|
242
|
+
* Call only from intentional app UI: "try restore purchases",
|
|
243
|
+
* "restore access", etc.
|
|
244
|
+
*
|
|
245
|
+
* On success:
|
|
246
|
+
* - restores passphrase + device ID from OS keychain
|
|
247
|
+
* - re-populates silent local storage
|
|
248
|
+
* - derives encryption key
|
|
249
|
+
*
|
|
250
|
+
* Returns true if restore succeeded.
|
|
251
|
+
*/
|
|
252
|
+
restoreWithBiometrics(): Promise<boolean>;
|
|
253
|
+
/**
|
|
254
|
+
* Clear persisted credentials for this mesh.
|
|
255
|
+
* Warning: lost key = lost data. No recovery.
|
|
256
|
+
*/
|
|
257
|
+
clearCredentials(): Promise<void>;
|
|
258
|
+
/**
|
|
259
|
+
* @deprecated Use setPassphrase() instead. Will be removed.
|
|
260
|
+
*/
|
|
261
|
+
setEncryptionKey(key: CryptoKey): void;
|
|
262
|
+
init(): Promise<void>;
|
|
263
|
+
private doInit;
|
|
264
|
+
/**
|
|
265
|
+
* Silent credential restore from the primary store only.
|
|
266
|
+
* Used during normal init(). No biometric prompt.
|
|
267
|
+
*/
|
|
268
|
+
private restoreCredentials;
|
|
269
|
+
connect(): Promise<void>;
|
|
270
|
+
private tryConnectFastPath;
|
|
271
|
+
private doConnect;
|
|
272
|
+
private startVisibilityTracking;
|
|
273
|
+
private stopVisibilityTracking;
|
|
274
|
+
disconnect(): Promise<void>;
|
|
275
|
+
setRemoteStorage(adapter: StorageAdapter | null): Promise<void>;
|
|
276
|
+
setLocalStorage(local: LocalStoreAdapter): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Load the mesh manifest, optionally short-circuiting via the in-memory
|
|
279
|
+
* cache.
|
|
280
|
+
*
|
|
281
|
+
* `reason` is a free-form caller tag used by `trace:manifest` events so
|
|
282
|
+
* developers can answer "why is my manifest being re-read every flush?".
|
|
283
|
+
*
|
|
284
|
+
* `force=true` bypasses the cache. Required after poison, after compaction
|
|
285
|
+
* advances generation, or whenever the caller explicitly needs disk state.
|
|
286
|
+
* Cached path emits `trace:manifest { op: 'cache-hit' }` so test/devtools
|
|
287
|
+
* can assert that the steady-state pipeline does ZERO GETs on flush/pull.
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* Returns whether the manifest was bootstrapped (freshly minted) on this
|
|
291
|
+
* call. Callers (connect()) use this to skip the device-metadata GET when
|
|
292
|
+
* we know no prior device record can exist.
|
|
293
|
+
*/
|
|
294
|
+
private doLoadOrCreateManifest;
|
|
295
|
+
put<K extends keyof S & string>(table: K, rowId: string, columns: Partial<S[K]>, userId?: string): Promise<S[K]>;
|
|
296
|
+
delete<K extends keyof S & string>(table: K, rowId: string, userId?: string): Promise<void>;
|
|
297
|
+
query<K extends keyof S & string>(table: K): Promise<S[K][]>;
|
|
298
|
+
queryWhere<K extends keyof S & string>(table: K, clause: WhereClause): Promise<S[K][]>;
|
|
299
|
+
tableNames(): Promise<string[]>;
|
|
300
|
+
table<K extends keyof S & string>(name: K): Table<S[K]>;
|
|
301
|
+
private batchDepth;
|
|
302
|
+
/**
|
|
303
|
+
* Group a sequence of writes into a single ChangeEntry. The entry
|
|
304
|
+
* carries every op as one atomic unit, producing one remote file
|
|
305
|
+
* instead of one per write.
|
|
306
|
+
*
|
|
307
|
+
* Nested batch() calls join the outer batch.
|
|
308
|
+
*/
|
|
309
|
+
batch<R>(fn: () => Promise<R> | R): Promise<R>;
|
|
310
|
+
private isBatching;
|
|
311
|
+
private clearBatchTimer;
|
|
312
|
+
private appendOpToPendingBatch;
|
|
313
|
+
private armImplicitBatchTimer;
|
|
314
|
+
private flushPendingBatch;
|
|
315
|
+
private scheduleFlush;
|
|
316
|
+
private maybeEmitCompactWarning;
|
|
317
|
+
private resetCompactWarning;
|
|
318
|
+
private maybeAutoCompact;
|
|
319
|
+
private armDelayedCompactAfterChange;
|
|
320
|
+
private runDelayedCompactCheck;
|
|
321
|
+
private runDelayedCompact;
|
|
322
|
+
/** Public flush — waits for init. Safe to call from user code. */
|
|
323
|
+
flush(): Promise<void>;
|
|
324
|
+
/** Internal flush — no ensureReady guard (called from connect, pull, doInit). */
|
|
325
|
+
private hasPreFloorEntries;
|
|
326
|
+
private doFlush;
|
|
327
|
+
pull(): Promise<void>;
|
|
328
|
+
rehydrate(): Promise<void>;
|
|
329
|
+
compact(): Promise<void>;
|
|
330
|
+
/** Upload a durable application file. Files are encrypted with the mesh key and are never compacted or merged. */
|
|
331
|
+
putFile(path: string, data: Uint8Array | string, contentType?: string): Promise<StoredFileMetadata>;
|
|
332
|
+
/** Read and decrypt a durable application file. */
|
|
333
|
+
getFile(path: string): Promise<Uint8Array>;
|
|
334
|
+
/** Delete a durable application file. Missing files are treated as already deleted. */
|
|
335
|
+
deleteFile(path: string): Promise<void>;
|
|
336
|
+
/** Return metadata for a durable application file without downloading content. */
|
|
337
|
+
getFileMetadata(path: string): Promise<StoredFileMetadata | null>;
|
|
338
|
+
/** Encode and upload an image through durable encrypted file storage. */
|
|
339
|
+
putImage(path: string, image: ImageInput, options?: PutImageOptions): Promise<StoredImageMetadata>;
|
|
340
|
+
/** Read an image as decoded bytes plus a browser Blob. */
|
|
341
|
+
getImage(path: string): Promise<StoredImage>;
|
|
342
|
+
/** Read an image and return a revokable browser blob: URL for UI rendering. */
|
|
343
|
+
getImageBlobUrl(path: string): Promise<StoredImageBlobUrl>;
|
|
344
|
+
getManifest(): Manifest | null;
|
|
345
|
+
getDeviceId(): string;
|
|
346
|
+
/**
|
|
347
|
+
* Credential vault for sub-stores derived from this Interocitor.
|
|
348
|
+
*
|
|
349
|
+
* Use `put / get / list / remove` to manage credentials. The engine never
|
|
350
|
+
* constructs child engines — apps read these and build their own
|
|
351
|
+
* Interocitor instances. Credentials are persisted inside this engine's
|
|
352
|
+
* LocalStore; anyone with read access to this store inherits read access
|
|
353
|
+
* to every sub-store's credentials.
|
|
354
|
+
*/
|
|
355
|
+
get connectedStores(): ConnectedStoresApi;
|
|
356
|
+
getMeshId(): string | undefined;
|
|
357
|
+
isEncrypted(): boolean;
|
|
358
|
+
/**
|
|
359
|
+
* Enable encryption on an existing unencrypted mesh.
|
|
360
|
+
* @deprecated Use setPassphrase() or pass encrypted/passphrase in config.
|
|
361
|
+
*/
|
|
362
|
+
enableEncryption(key: CryptoKey): Promise<void>;
|
|
363
|
+
}
|
|
364
|
+
//# sourceMappingURL=sync-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-engine.d.ts","sourceRoot":"","sources":["../../src/core/sync-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,iBAAiB,EAEjB,QAAQ,EACR,GAAG,EAIH,iBAAiB,EAEjB,WAAW,EAGX,gBAAgB,EAEhB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAC3B,aAAa,EACb,gBAAgB,EAGhB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAY,CAAC;AAapD,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAoD/B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CACvF,SAAQ,2BAA2B;IACnC,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MA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