@vrtmrz/livesync-commonlib 0.6.1 → 0.7.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/README.md +29 -19
- package/dist/common/models/shared.definition.d.ts +10 -1
- package/dist/common/models/shared.definition.js +4 -3
- package/dist/events/coreEvents.d.ts +3 -0
- package/dist/events/coreEvents.js +2 -0
- package/dist/managers/EntryManager/EntryManager.d.ts +1 -1
- package/dist/managers/EntryManager/EntryManager.js +2 -2
- package/dist/managers/EntryManager/EntryManagerImpls.d.ts +1 -1
- package/dist/managers/EntryManager/EntryManagerImpls.js +4 -4
- package/dist/managers/StorageEventManager/admission.d.ts +1 -0
- package/dist/managers/StorageEventManager/admission.js +5 -1
- package/dist/managers/StorageEventManager.d.ts +2 -0
- package/dist/managers/StorageEventManager.js +1 -0
- package/dist/pouchdb/LiveSyncLocalDB.d.ts +1 -1
- package/dist/pouchdb/LiveSyncLocalDB.js +2 -2
- package/dist/replication/LiveSyncAbstractReplicator.d.ts +7 -0
- package/dist/replication/LiveSyncAbstractReplicator.js +5 -2
- package/dist/replication/ReplicatorInstance.d.ts +3 -0
- package/dist/replication/ReplicatorProvider.d.ts +23 -2
- package/dist/replication/ReplicatorProvider.js +10 -0
- package/dist/replication/SyncParamsHandler.js +26 -25
- package/dist/replication/couchdb/LiveSyncReplicator.d.ts +14 -2
- package/dist/replication/couchdb/LiveSyncReplicator.js +247 -122
- package/dist/replication/index.d.ts +4 -2
- package/dist/replication/index.js +6 -0
- package/dist/replication/remoteTransportFailure.d.ts +24 -0
- package/dist/replication/remoteTransportFailure.js +80 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +1 -1
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +2 -2
- package/dist/replication/trystero/TrysteroRpcRoom.d.ts +14 -0
- package/dist/replication/trystero/TrysteroRpcRoom.js +168 -0
- package/dist/replication/trystero/rpcCompat.d.ts +1 -0
- package/dist/replication/trystero/rpcCompat.js +15 -0
- package/dist/rpc/RpcRoom.d.ts +1 -0
- package/dist/rpc/RpcRoom.js +21 -9
- package/dist/rpc/RpcSession.d.ts +8 -13
- package/dist/rpc/RpcSession.js +14 -35
- package/dist/rpc/commonlibRpcRoom.d.ts +1 -0
- package/dist/rpc/commonlibRpcRoom.js +4 -0
- package/dist/rpc/errors.d.ts +9 -3
- package/dist/rpc/errors.js +13 -16
- package/dist/rpc/index.d.ts +10 -1
- package/dist/rpc/index.js +2 -1
- package/dist/rpc/pouchdb/RpcPouchDBProxy.d.ts +1 -1
- package/dist/rpc/pouchdb/RpcPouchDBServer.d.ts +1 -1
- package/dist/serviceFeatures/targetFilter.d.ts +3 -1
- package/dist/serviceFeatures/targetFilter.js +2 -2
- package/dist/services/base/IService.d.ts +9 -6
- package/dist/services/base/ReadinessEvaluator.d.ts +7 -6
- package/dist/services/base/ReadinessEvaluator.js +4 -2
- package/dist/services/base/RemoteConnection.d.ts +4 -0
- package/dist/services/base/RemoteService.d.ts +5 -3
- package/dist/services/base/RemoteService.js +85 -33
- package/dist/services/base/ReplicationService.d.ts +10 -2
- package/dist/services/base/ReplicationService.js +13 -7
- package/dist/services/base/ReplicationService.readiness.d.ts +14 -4
- package/dist/services/base/ReplicationService.readiness.js +29 -2
- package/dist/services/base/ReplicationService.typedReplication.d.ts +5 -2
- package/dist/services/base/ReplicationService.typedReplication.js +67 -6
- package/dist/services/base/ReplicationStaticsOwner.d.ts +18 -0
- package/dist/services/base/ReplicationStaticsOwner.js +33 -0
- package/dist/services/base/ReplicatorService.d.ts +2 -10
- package/dist/services/base/ReplicatorService.js +6 -3
- package/dist/services/base/VaultService.d.ts +1 -0
- package/dist/string_and_binary/chunks.d.ts +1 -1
- package/dist/string_and_binary/chunks.js +63 -50
- package/dist/worker/bg.worker.js +3 -1
- package/dist/worker/bg.worker.splitting.d.ts +1 -0
- package/dist/worker/bg.worker.splitting.js +42 -6
- package/dist/worker/bgWorker.d.ts +4 -0
- package/dist/worker/bgWorker.js +87 -57
- package/dist/worker/bgWorker.splitting.d.ts +2 -3
- package/dist/worker/bgWorker.splitting.js +48 -52
- package/dist/worker/universalTypes.d.ts +13 -1
- package/docs/development.md +69 -32
- package/docs/p2p-transport-lifecycle.md +2 -3
- package/docs/storage-events-and-reflection.md +10 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -14,9 +14,10 @@ This package is primarily for maintainers of those clients and for integrations
|
|
|
14
14
|
|
|
15
15
|
## Status and versioning
|
|
16
16
|
|
|
17
|
-
Commonlib [
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
Stable Commonlib releases are available from [npm](https://www.npmjs.com/package/@vrtmrz/livesync-commonlib)
|
|
18
|
+
under `latest`. Release candidates are available under `next`.
|
|
19
|
+
See [GitHub Releases](https://github.com/vrtmrz/livesync-commonlib/releases) for
|
|
20
|
+
stable release notes.
|
|
20
21
|
|
|
21
22
|
Self-hosted LiveSync
|
|
22
23
|
[1.0.44](https://github.com/vrtmrz/obsidian-livesync/releases/tag/1.0.44)
|
|
@@ -43,7 +44,7 @@ ordinary replication before resuming local writers. Existing hosts can omit
|
|
|
43
44
|
this optimisation. Resume cursors retain their existing meaning; this resource
|
|
44
45
|
does not provide an arbitrary-time checkpoint jump or On Demand repair.
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
Commonlib 0.3.1 separates encrypted CouchDB HTTP responses by Security Seed
|
|
47
48
|
while retaining conditional revalidation within a Seed. See
|
|
48
49
|
[CouchDB response caching](docs/couchdb-http-cache.md) for the request,
|
|
49
50
|
replication-preparation, and host-adapter boundaries.
|
|
@@ -63,11 +64,11 @@ the receive, skip, and replay boundaries.
|
|
|
63
64
|
| Entry point | Intended use | Current contract status |
|
|
64
65
|
| -------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
65
66
|
| `@vrtmrz/livesync-commonlib` | `DirectFileManipulator` for integrations which access CouchDB directly | Deliberately small, but its high-level lifecycle and file-operation semantics are not final |
|
|
66
|
-
| `@vrtmrz/livesync-commonlib/conflicts`
|
|
67
|
+
| `@vrtmrz/livesync-commonlib/conflicts` | Keyed conflict-check scheduling with bounded concurrency and explicit completion | Focused, package-tested pre-1.0 contract |
|
|
67
68
|
| `@vrtmrz/livesync-commonlib/context` | Instance-owned events, translation injection, and host-neutral standard-I/O types | Focused, package-tested pre-1.0 contract |
|
|
68
|
-
| `@vrtmrz/livesync-commonlib/diagnostics`
|
|
69
|
-
| `@vrtmrz/livesync-commonlib/storage`
|
|
70
|
-
| `@vrtmrz/livesync-commonlib/hashing` | Chunk ID calculation and exact file-content hashing
|
|
69
|
+
| `@vrtmrz/livesync-commonlib/diagnostics` | Read-only Usage and integrity inspection, name projection, and reports | Focused pre-1.0 diagnostic contract |
|
|
70
|
+
| `@vrtmrz/livesync-commonlib/storage` | Path types, namespace and comparison helpers, and strict Unicode path resolution | Available since 0.3.1. Host integration remains explicit. |
|
|
71
|
+
| `@vrtmrz/livesync-commonlib/hashing` | Chunk ID calculation and exact file-content hashing | Focused, package-tested pre-1.0 contract |
|
|
71
72
|
| `@vrtmrz/livesync-commonlib/browser` | Rooted File System Access API storage | Focused, package-tested pre-1.0 contract |
|
|
72
73
|
| `@vrtmrz/livesync-commonlib/node` | Rooted Node storage, Node standard I/O, and selected Node capabilities | Supported platform façade; keeps Node-only dependencies behind an explicit boundary |
|
|
73
74
|
| `@vrtmrz/livesync-commonlib/p2p` | Host-composed P2P service views and composition helpers | Focused, package-tested pre-1.0 contract with a temporary compatibility façade |
|
|
@@ -76,8 +77,8 @@ the receive, skip, and replay boundaries.
|
|
|
76
77
|
| `@vrtmrz/livesync-commonlib/remote-configurations` | Multiple-remote profile creation, naming, and selection | Focused, package-tested pre-1.0 contract |
|
|
77
78
|
| `@vrtmrz/livesync-commonlib/settings` | New-Vault defaults, stored-setting fallbacks, and settings migration results | Focused, package-tested pre-1.0 contract |
|
|
78
79
|
| `@vrtmrz/livesync-commonlib/setup-uri` | Encrypted Setup URI generation, availability, and import | Focused, package-tested pre-1.0 contract |
|
|
79
|
-
| `@vrtmrz/livesync-commonlib/ui-commands`
|
|
80
|
-
| `@vrtmrz/livesync-commonlib/compat/*` | Exact legacy imports still required by existing clients | Migration-only; retained within 0.2.x, with removals treated as 0.3.0 breaking changes
|
|
80
|
+
| `@vrtmrz/livesync-commonlib/ui-commands` | Instance-owned typed UI command declarations and handlers | Focused, package-tested contract |
|
|
81
|
+
| `@vrtmrz/livesync-commonlib/compat/*` | Exact legacy imports still required by existing clients | Migration-only; retained within 0.2.x, with removals treated as 0.3.0 breaking changes |
|
|
81
82
|
| `@vrtmrz/livesync-commonlib/package.json` | Package metadata for tooling | Metadata export, not a runtime API |
|
|
82
83
|
|
|
83
84
|
The existing `compat/services/lib` boundary retains `bindableFunction` and `lazyBindableFunction` for current clients. Their `setHandler()` methods return an `UnregisterFunction` which removes only its own current assignment; stale removers, including after an override with the same callback, and repeated removals are no-ops. Existing callers may ignore the return value. These helpers remain a migration boundary, not a general-purpose SDK integration surface.
|
|
@@ -94,7 +95,12 @@ Import only the entry point required by the current runtime. Browser code must n
|
|
|
94
95
|
|
|
95
96
|
The Node and browser entries are platform façades. They keep platform-specific adapters and capabilities behind package-owned boundaries, so a consumer does not have to reproduce those imports or their build and review exceptions. The Node entry's selected built-in-module exports are deliberate parts of that façade. Package checks ensure that the root, context, and browser entries do not load the Node implementation.
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
Starting with [Commonlib 0.7.0](updates.md#070), the hosted P2P service uses
|
|
99
|
+
the published `@vrtmrz/rpc/p2p` room. The
|
|
100
|
+
transitional Commonlib `/rpc` entry retains the existing room and session
|
|
101
|
+
constructors and the PouchDB bridge. Hosted rooms and sessions pass
|
|
102
|
+
`instanceof` checks against those exports. New consumers can use the focused
|
|
103
|
+
`/p2p` entry to compose a LiveSync host or Fancy Kit for general RPC.
|
|
98
104
|
|
|
99
105
|
The P2P entry exposes eight focused views over one service owner, together with the maintained host-composition helpers. New consumers select only the lifecycle, peer-directory, peer-admission, targeted-transfer, change-relay, configuration-exchange, diagnostic, or connection-probe-admission view which they need. The composition result still carries a deprecated concrete Replicator façade while existing panes migrate; new consumers must not depend on that property or reach through it to a raw room or host.
|
|
100
106
|
|
|
@@ -176,10 +182,10 @@ Import `declareUICommand` and `UICommandRegistry` from `@vrtmrz/livesync-commonl
|
|
|
176
182
|
```ts
|
|
177
183
|
import { declareUICommand } from "@vrtmrz/livesync-commonlib/ui-commands";
|
|
178
184
|
|
|
179
|
-
const showDevices = declareUICommand<void,
|
|
185
|
+
const showDevices = declareUICommand<void, "closed">("example:show-devices");
|
|
180
186
|
const unregister = services.UI.commands.register(showDevices, async () => {
|
|
181
187
|
await openHostDeviceDialogue();
|
|
182
|
-
return
|
|
188
|
+
return "closed";
|
|
183
189
|
});
|
|
184
190
|
const result = await services.UI.commands.invoke(showDevices, undefined);
|
|
185
191
|
// result is { status: 'handled', value: 'closed' } or { status: 'unavailable' }.
|
|
@@ -200,7 +206,12 @@ Hosts can read the latest `services.replicator.replicationStatics.value` and
|
|
|
200
206
|
subscribe to that reactive source. The focused `/replication` entry exports
|
|
201
207
|
`ReplicationStatics`, `CouchDBReplicationProgress`, and
|
|
202
208
|
`ReplicationCheckpointProgress`. Existing transfer counters and `syncStatus`
|
|
203
|
-
retain their meanings.
|
|
209
|
+
retain their meanings. Starting with [Commonlib 0.7.0](updates.md#070), the
|
|
210
|
+
initial snapshot has `syncStatus: 'NOT_CONNECTED'` and `statsUpdatedAt: null`.
|
|
211
|
+
When the provider publishes statistics,
|
|
212
|
+
`statsUpdatedAt` records the publication time in Unix epoch milliseconds.
|
|
213
|
+
Replacing the provider restores the initial snapshot until new statistics
|
|
214
|
+
are published.
|
|
204
215
|
|
|
205
216
|
The optional `couchDB` snapshot describes the ordinary CouchDB replication
|
|
206
217
|
attempt. Other providers omit it. Its `phase` distinguishes `one-shot`,
|
|
@@ -307,12 +318,12 @@ import {
|
|
|
307
318
|
formatUsageTSV,
|
|
308
319
|
parseDiagnosticPathToken,
|
|
309
320
|
projectUsageReport,
|
|
310
|
-
} from
|
|
321
|
+
} from "@vrtmrz/livesync-commonlib/diagnostics";
|
|
311
322
|
|
|
312
323
|
const result = await analyseDatabaseUsage({ source: createLocalDiagnosticSource(localPouchDB) });
|
|
313
|
-
const mapper = createDiagnosticNameMapper(
|
|
324
|
+
const mapper = createDiagnosticNameMapper("pseudonym");
|
|
314
325
|
const report = projectUsageReport(result, mapper);
|
|
315
|
-
if (report.status ===
|
|
326
|
+
if (report.status === "complete") {
|
|
316
327
|
const tsv = formatUsageTSV(report);
|
|
317
328
|
// Present the report through the host's own UI or output stream.
|
|
318
329
|
}
|
|
@@ -324,7 +335,7 @@ Path pseudonyms include the report salt. A consumer can parse that token and sup
|
|
|
324
335
|
const pathToken = report.rows[0]?.path;
|
|
325
336
|
const parsed = pathToken === undefined ? undefined : parseDiagnosticPathToken(pathToken);
|
|
326
337
|
if (parsed) {
|
|
327
|
-
const followUpMapper = createDiagnosticNameMapper(
|
|
338
|
+
const followUpMapper = createDiagnosticNameMapper("pseudonym", parsed.salt);
|
|
328
339
|
const candidateToken = followUpMapper.path(storedVaultRelativePath);
|
|
329
340
|
// Compare this token with the path pseudonym on this device.
|
|
330
341
|
}
|
|
@@ -393,7 +404,6 @@ See [Maintained-host examples and evidence](docs/proven-in-use.md) for compositi
|
|
|
393
404
|
|
|
394
405
|
MIT
|
|
395
406
|
|
|
396
|
-
|
|
397
407
|
## Shared value helper migration
|
|
398
408
|
|
|
399
409
|
The shared formatter displays positive infinity as `∞y`, including through the existing `timeDeltaToHumanReadable` entry. Other duration formatting cases retain their previous behaviour.
|
|
@@ -28,6 +28,10 @@ export type CouchDBReplicationProgress = {
|
|
|
28
28
|
readonly pull?: ReplicationCheckpointProgress;
|
|
29
29
|
readonly push?: ReplicationCheckpointProgress;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Raw statistics accepted by the publication boundary. The optional timestamp
|
|
33
|
+
* is retained for compatibility and replaced when a value is published.
|
|
34
|
+
*/
|
|
31
35
|
export type ReplicationStatics = {
|
|
32
36
|
sent: number;
|
|
33
37
|
arrived: number;
|
|
@@ -36,7 +40,12 @@ export type ReplicationStatics = {
|
|
|
36
40
|
lastSyncPullSeq: number;
|
|
37
41
|
lastSyncPushSeq: number;
|
|
38
42
|
syncStatus: DatabaseConnectingStatus;
|
|
43
|
+
statsUpdatedAt?: number | null;
|
|
39
44
|
/** Present only when the provider supplies CouchDB checkpoint observations. */
|
|
40
45
|
couchDB?: CouchDBReplicationProgress;
|
|
41
46
|
};
|
|
42
|
-
|
|
47
|
+
/** Statistics as observed after publication; the timestamp is always present. */
|
|
48
|
+
export type PublishedReplicationStatics = Readonly<Omit<ReplicationStatics, "statsUpdatedAt"> & {
|
|
49
|
+
statsUpdatedAt: number | null;
|
|
50
|
+
}>;
|
|
51
|
+
export declare const DEFAULT_REPLICATION_STATICS: PublishedReplicationStatics;
|
|
@@ -9,15 +9,16 @@ const DatabaseConnectingStatuses = {
|
|
|
9
9
|
JOURNAL_SEND: "JOURNAL_SEND",
|
|
10
10
|
JOURNAL_RECEIVE: "JOURNAL_RECEIVE"
|
|
11
11
|
};
|
|
12
|
-
const DEFAULT_REPLICATION_STATICS = {
|
|
12
|
+
const DEFAULT_REPLICATION_STATICS = Object.freeze({
|
|
13
13
|
sent: 0,
|
|
14
14
|
arrived: 0,
|
|
15
15
|
maxPullSeq: 0,
|
|
16
16
|
maxPushSeq: 0,
|
|
17
17
|
lastSyncPullSeq: 0,
|
|
18
18
|
lastSyncPushSeq: 0,
|
|
19
|
-
syncStatus: DatabaseConnectingStatuses.
|
|
20
|
-
|
|
19
|
+
syncStatus: DatabaseConnectingStatuses.NOT_CONNECTED,
|
|
20
|
+
statsUpdatedAt: null
|
|
21
|
+
});
|
|
21
22
|
export {
|
|
22
23
|
DEFAULT_REPLICATION_STATICS,
|
|
23
24
|
DatabaseConnectingStatuses
|
|
@@ -7,6 +7,8 @@ export declare const EVENT_FILE_RENAMED = "file-renamed";
|
|
|
7
7
|
export declare const EVENT_FILE_SAVED = "file-saved";
|
|
8
8
|
export declare const EVENT_LEAF_ACTIVE_CHANGED = "leaf-active-changed";
|
|
9
9
|
export declare const EVENT_DATABASE_REBUILT = "database-rebuilt";
|
|
10
|
+
/** The replication service has received an explicit transfer stop request. */
|
|
11
|
+
export declare const EVENT_REPLICATION_ABORT_REQUESTED = "replication-abort-requested";
|
|
10
12
|
/** Emitted by `AppLifecycleService.markIsReady()` each time it establishes application readiness. */
|
|
11
13
|
export declare const EVENT_APPLICATION_READY = "application-ready";
|
|
12
14
|
export declare const EVENT_LOG_ADDED = "log-added";
|
|
@@ -40,6 +42,7 @@ declare global {
|
|
|
40
42
|
};
|
|
41
43
|
[EVENT_DATABASE_REBUILT]: undefined;
|
|
42
44
|
[EVENT_APPLICATION_READY]: undefined;
|
|
45
|
+
[EVENT_REPLICATION_ABORT_REQUESTED]: undefined;
|
|
43
46
|
[EVENT_REQUEST_OPEN_P2P_SETTINGS]: undefined;
|
|
44
47
|
[EVENT_LEAF_ACTIVE_CHANGED]: undefined;
|
|
45
48
|
[EVENT_REQUEST_OPEN_SETUP_URI]: undefined;
|
|
@@ -6,6 +6,7 @@ const EVENT_FILE_RENAMED = "file-renamed";
|
|
|
6
6
|
const EVENT_FILE_SAVED = "file-saved";
|
|
7
7
|
const EVENT_LEAF_ACTIVE_CHANGED = "leaf-active-changed";
|
|
8
8
|
const EVENT_DATABASE_REBUILT = "database-rebuilt";
|
|
9
|
+
const EVENT_REPLICATION_ABORT_REQUESTED = "replication-abort-requested";
|
|
9
10
|
const EVENT_APPLICATION_READY = "application-ready";
|
|
10
11
|
const EVENT_LOG_ADDED = "log-added";
|
|
11
12
|
const EVENT_REQUEST_OPEN_SETUP_URI = "request-open-setup-uri";
|
|
@@ -35,6 +36,7 @@ export {
|
|
|
35
36
|
EVENT_PLATFORM_UNLOADED,
|
|
36
37
|
EVENT_PLUGIN_LOADED,
|
|
37
38
|
EVENT_PLUGIN_UNLOADED,
|
|
39
|
+
EVENT_REPLICATION_ABORT_REQUESTED,
|
|
38
40
|
EVENT_REQUEST_CHECK_REMOTE_SIZE,
|
|
39
41
|
EVENT_REQUEST_CLOSE_P2P,
|
|
40
42
|
EVENT_REQUEST_COPY_SETUP_URI,
|
|
@@ -34,7 +34,7 @@ export declare class EntryManager {
|
|
|
34
34
|
serviceModules: {};
|
|
35
35
|
};
|
|
36
36
|
get isOnDemandChunkEnabled(): boolean;
|
|
37
|
-
isTargetFile(filenameSrc: string): boolean;
|
|
37
|
+
isTargetFile(filenameSrc: string, internalFileEvent?: boolean): boolean;
|
|
38
38
|
prepareChunk(piece: string): Promise<GeneratedChunk>;
|
|
39
39
|
getDBEntryMeta(path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, includeDeleted?: boolean): Promise<false | LoadedEntry>;
|
|
40
40
|
getDBEntry(path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, dump?: boolean, waitForReady?: boolean, includeDeleted?: boolean, localOnly?: boolean): Promise<false | LoadedEntry>;
|
|
@@ -56,8 +56,8 @@ class EntryManager {
|
|
|
56
56
|
}
|
|
57
57
|
return true;
|
|
58
58
|
}
|
|
59
|
-
isTargetFile(filenameSrc) {
|
|
60
|
-
return isTargetFile(this.serviceHost, filenameSrc);
|
|
59
|
+
isTargetFile(filenameSrc, internalFileEvent = false) {
|
|
60
|
+
return isTargetFile(this.serviceHost, filenameSrc, internalFileEvent);
|
|
61
61
|
}
|
|
62
62
|
async prepareChunk(piece) {
|
|
63
63
|
return await prepareChunk(this, piece);
|
|
@@ -31,7 +31,7 @@ export declare function putDBEntryWithLiveBaseRevision(host: NecessaryServicesIn
|
|
|
31
31
|
* Return the Metadata write result, or `false` when the entry cannot be stored.
|
|
32
32
|
*/
|
|
33
33
|
export declare function putDBEntryAsIndependentRoot(host: NecessaryServicesInterfaces<"path" | "setting", never>, managers: NecessaryManagers<"localDatabase" | "chunkManager" | "hashManager" | "splitter">, note: SavingEntry): Promise<false | PouchDB.Core.Response>;
|
|
34
|
-
export declare function isTargetFile(host: NecessaryServicesInterfaces<"setting", never>, filenameSrc: string): boolean;
|
|
34
|
+
export declare function isTargetFile(host: NecessaryServicesInterfaces<"setting", never>, filenameSrc: string, internalFileEvent?: boolean): boolean;
|
|
35
35
|
export declare function prepareChunk({ chunkManager, hashManager }: NecessaryManagers<"chunkManager" | "hashManager">, piece: string): Promise<GeneratedChunk>;
|
|
36
36
|
export declare function getDBEntryMetaByPath(host: NecessaryServicesInterfaces<"path" | "setting", never>, { localDatabase, readScope }: NecessaryManagers<"localDatabase">, path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, includeDeleted?: boolean): Promise<false | LoadedEntry>;
|
|
37
37
|
export declare function isLegacyNote(meta: LoadedEntry | MetaEntry): boolean;
|
|
@@ -33,7 +33,7 @@ async function createChunks(managers, dispFilename, note) {
|
|
|
33
33
|
log(`No chunks to flush for ${dispFilename}`, LOG_LEVEL_VERBOSE);
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
|
-
const writeBuf =
|
|
36
|
+
const writeBuf = bufferedChunk;
|
|
37
37
|
bufferedSize = 0;
|
|
38
38
|
bufferedChunk = [];
|
|
39
39
|
const result = await chunkManager.write(
|
|
@@ -211,7 +211,7 @@ async function putDBEntryInternal(host, managers, note, onlyChunks, revisionTarg
|
|
|
211
211
|
log(`Document saved: ${dispFilename} (${result.id.substring(0, 8)}-${result.rev})`, LOG_LEVEL_VERBOSE);
|
|
212
212
|
return result;
|
|
213
213
|
}
|
|
214
|
-
function isTargetFile(host, filenameSrc) {
|
|
214
|
+
function isTargetFile(host, filenameSrc, internalFileEvent = false) {
|
|
215
215
|
const settings = host.services.setting.currentSettings();
|
|
216
216
|
const isInternalFile = filenameSrc.startsWith(ICHeader);
|
|
217
217
|
const file = isInternalFile ? filenameSrc.substring(ICHeader.length) : filenameSrc;
|
|
@@ -220,12 +220,12 @@ function isTargetFile(host, filenameSrc) {
|
|
|
220
220
|
if (file.startsWith(IDPrefixes.Chunk) || file.startsWith(IDPrefixes.Obfuscated)) {
|
|
221
221
|
return false;
|
|
222
222
|
}
|
|
223
|
-
if (!settings.syncInternalFiles) {
|
|
223
|
+
if (!internalFileEvent && !settings.syncInternalFiles) {
|
|
224
224
|
if (file.startsWith(".")) {
|
|
225
225
|
return false;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
if (!isInternalFile && settings.syncOnlyRegEx) {
|
|
228
|
+
if (!internalFileEvent && !isInternalFile && settings.syncOnlyRegEx) {
|
|
229
229
|
const syncOnly = getFileRegExp(settings, "syncOnlyRegEx");
|
|
230
230
|
if (syncOnly.length > 0 && !syncOnly.some((e) => e.test(file))) return false;
|
|
231
231
|
}
|
|
@@ -18,6 +18,7 @@ export interface StorageEventAdmissionEffects {
|
|
|
18
18
|
isFolder(file: FileEvent["file"]): boolean;
|
|
19
19
|
isFile(file: FileEvent["file"]): boolean;
|
|
20
20
|
isTarget(path: string): Promise<boolean>;
|
|
21
|
+
isTargetInternal?(path: string): Promise<boolean>;
|
|
21
22
|
isTooLarge(size: number): boolean;
|
|
22
23
|
recentlyTouched: IStorageAccessManager["recentlyTouched"];
|
|
23
24
|
onStorageFileEvent(): void;
|
|
@@ -53,7 +53,11 @@ async function selectRename(param, settings, effects) {
|
|
|
53
53
|
return selectRenameFileEvent(param, oldSelected, newSelected);
|
|
54
54
|
}
|
|
55
55
|
async function selectOrdinaryEvent(param, settings, effects) {
|
|
56
|
-
|
|
56
|
+
const path = param.file.path;
|
|
57
|
+
const selected = param.type === "INTERNAL" && effects.isTargetInternal ? !shouldBeIgnored(path) && await effects.isTargetInternal(path) : await isSelectedPath(path, settings, effects);
|
|
58
|
+
if (!selected) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
57
61
|
if (param.type !== "INTERNAL") {
|
|
58
62
|
const size = param.file.stat.size;
|
|
59
63
|
if (effects.isTooLarge(size) && (param.type === "CREATE" || param.type === "CHANGED")) {
|
|
@@ -18,6 +18,8 @@ export type { FileEventItemSentinel } from "./StorageEventManager/state.js";
|
|
|
18
18
|
* @remarks These dependencies keep vault access, file processing, settings, and diagnostics at the adapter boundary.
|
|
19
19
|
*/
|
|
20
20
|
export interface StorageEventManagerBaseDependencies {
|
|
21
|
+
/** Apply the host's admission checks to optional-file events before queuing them. */
|
|
22
|
+
isTargetInternalFile?: (path: FilePath) => Promise<boolean>;
|
|
21
23
|
setting: SettingService;
|
|
22
24
|
vaultService: IVaultService;
|
|
23
25
|
fileProcessing: FileProcessingService;
|
|
@@ -157,6 +157,7 @@ class StorageEventManagerBase extends StorageEventManager {
|
|
|
157
157
|
this.adapter = adapter;
|
|
158
158
|
this.setting = dependencies.setting;
|
|
159
159
|
this.vaultService = dependencies.vaultService;
|
|
160
|
+
this.admission.isTargetInternal = dependencies.isTargetInternalFile?.bind(dependencies);
|
|
160
161
|
this.fileProcessing = dependencies.fileProcessing;
|
|
161
162
|
this.storageAccess = dependencies.storageAccessManager;
|
|
162
163
|
this._log = createInstanceLogFunction("StorageEventManager", dependencies.APIService);
|
|
@@ -230,7 +230,7 @@ export declare class LiveSyncLocalDB {
|
|
|
230
230
|
/** Read a raw document listing with caller-wait retirement owned by this database. */
|
|
231
231
|
allDocsRaw<T extends EntryDoc | DatabaseEntry>(options?: PouchDB.Core.AllDocsWithKeyOptions | PouchDB.Core.AllDocsWithKeysOptions | PouchDB.Core.AllDocsWithinRangeOptions | PouchDB.Core.AllDocsOptions): Promise<PouchDB.Core.AllDocsResponse<T>>;
|
|
232
232
|
bulkDocsRaw<T extends EntryDoc>(docs: Array<PouchDB.Core.PutDocument<T>>, options?: PouchDB.Core.BulkDocsOptions): Promise<Array<PouchDB.Core.Response | PouchDB.Core.Error>>;
|
|
233
|
-
isTargetFile(filenameSrc: string): boolean;
|
|
233
|
+
isTargetFile(filenameSrc: string, internalFileEvent?: boolean): boolean;
|
|
234
234
|
getDBEntryMeta(path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, includeDeleted?: boolean): Promise<false | LoadedEntry>;
|
|
235
235
|
getDBEntry(path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, dump?: boolean, waitForReady?: boolean, includeDeleted?: boolean, localOnly?: boolean): Promise<false | LoadedEntry>;
|
|
236
236
|
readDBEntry(path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, dump?: boolean, waitForReady?: boolean, includeDeleted?: boolean, localOnly?: boolean): Promise<false | LoadedEntry>;
|
|
@@ -493,8 +493,8 @@ class LiveSyncLocalDB {
|
|
|
493
493
|
return this.localDatabase.bulkDocs(docs, options || {});
|
|
494
494
|
}
|
|
495
495
|
// For compatibility
|
|
496
|
-
isTargetFile(filenameSrc) {
|
|
497
|
-
return this.managers.entryManager.isTargetFile(filenameSrc);
|
|
496
|
+
isTargetFile(filenameSrc, internalFileEvent = false) {
|
|
497
|
+
return this.managers.entryManager.isTargetFile(filenameSrc, internalFileEvent);
|
|
498
498
|
}
|
|
499
499
|
async getDBEntryMeta(path, opt, includeDeleted = false) {
|
|
500
500
|
return await this.managers.entryManager.getDBEntryMeta(path, opt, includeDeleted);
|
|
@@ -5,6 +5,12 @@ import type { TranslationParameters } from "../services/base/MessageTranslator.j
|
|
|
5
5
|
import type { CommonlibMessageKey } from "../services/base/CommonlibMessages.js";
|
|
6
6
|
import type { ReplicatorInstance } from "./ReplicatorInstance.js";
|
|
7
7
|
export type ReplicationCallback = (e: PouchDB.Core.ExistingDocument<EntryDoc>[]) => Promise<boolean> | boolean;
|
|
8
|
+
export type SecuritySeedPreparationResult = {
|
|
9
|
+
ready: true;
|
|
10
|
+
} | {
|
|
11
|
+
ready: false;
|
|
12
|
+
error: unknown;
|
|
13
|
+
};
|
|
8
14
|
export type ReplicationStat = {
|
|
9
15
|
sent: number;
|
|
10
16
|
arrived: number;
|
|
@@ -58,6 +64,7 @@ export declare abstract class LiveSyncAbstractReplicator implements ReplicatorIn
|
|
|
58
64
|
sendChunks(setting: RemoteDBSettings, remoteDB: PouchDB.Database<EntryDoc> | undefined, showResult: boolean, fromSeq?: number | string): Promise<boolean>;
|
|
59
65
|
abstract getReplicationPBKDF2Salt(setting: RemoteDBSettings, refresh?: boolean): Promise<Uint8Array<ArrayBuffer>>;
|
|
60
66
|
ensurePBKDF2Salt(setting: RemoteDBSettings, showMessage?: boolean, useCache?: boolean): Promise<boolean>;
|
|
67
|
+
protected prepareSecuritySeed(setting: RemoteDBSettings, showMessage: boolean, useCache: boolean): Promise<SecuritySeedPreparationResult>;
|
|
61
68
|
env: LiveSyncReplicatorEnv;
|
|
62
69
|
initializeDatabaseForReplication(): Promise<boolean>;
|
|
63
70
|
constructor(env: LiveSyncReplicatorEnv);
|
|
@@ -37,18 +37,21 @@ class LiveSyncAbstractReplicator {
|
|
|
37
37
|
return Promise.resolve(true);
|
|
38
38
|
}
|
|
39
39
|
async ensurePBKDF2Salt(setting, showMessage = false, useCache = true) {
|
|
40
|
+
return (await this.prepareSecuritySeed(setting, showMessage, useCache)).ready;
|
|
41
|
+
}
|
|
42
|
+
async prepareSecuritySeed(setting, showMessage, useCache) {
|
|
40
43
|
try {
|
|
41
44
|
const hash = await this.getReplicationPBKDF2Salt(setting, !useCache);
|
|
42
45
|
if (hash.length == 0) {
|
|
43
46
|
throw new Error("PBKDF2 salt (Security Seed) is empty");
|
|
44
47
|
}
|
|
45
48
|
Logger(`PBKDF2 salt (Security Seed): ${await arrayBufferToBase64Single(hash)}`, LOG_LEVEL_VERBOSE);
|
|
46
|
-
return true;
|
|
49
|
+
return { ready: true };
|
|
47
50
|
} catch (ex) {
|
|
48
51
|
const level = showMessage ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO;
|
|
49
52
|
Logger(`Failed to obtain PBKDF2 salt (Security Seed) for replication`, level);
|
|
50
53
|
Logger(ex, LOG_LEVEL_VERBOSE);
|
|
51
|
-
return false;
|
|
54
|
+
return { ready: false, error: ex };
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
env;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RemoteDBSettings } from "../common/types.js";
|
|
2
|
+
import type { ContinuousReplicationStartResult } from "./ReplicatorProvider.js";
|
|
2
3
|
/**
|
|
3
4
|
* Minimal lifecycle contract shared by active Replicator instances.
|
|
4
5
|
*
|
|
@@ -16,6 +17,8 @@ export interface ReplicatorInstance {
|
|
|
16
17
|
* compatibility result to a typed outcome before exposing it to callers.
|
|
17
18
|
*/
|
|
18
19
|
openReplication(setting: RemoteDBSettings, keepAlive: boolean, showResult: boolean, ignoreCleanLock: boolean): Promise<void | boolean>;
|
|
20
|
+
/** Admit a continuous task and report when its initial handoff settles. */
|
|
21
|
+
startContinuousReplication?(setting: RemoteDBSettings, onStartSettled: (result: ContinuousReplicationStartResult) => void): Promise<void | boolean>;
|
|
19
22
|
/** Stop active transfer work; providers may settle this synchronously. */
|
|
20
23
|
terminateSync(): void | Promise<void>;
|
|
21
24
|
/** Close the instance; providers may settle this synchronously. */
|
|
@@ -15,7 +15,7 @@ export type { CapabilitySupport, NotApplicableCapability, NotImplementedCapabili
|
|
|
15
15
|
*/
|
|
16
16
|
export type UnattendedReplicationTrigger = "resume" | "periodic" | "database-event" | "editor-save" | "file-open" | "merge" | "daemon";
|
|
17
17
|
/** Automatic trigger which may start or resume a long-lived connection. */
|
|
18
|
-
export type ContinuousReplicationTrigger = "resume" | "daemon";
|
|
18
|
+
export type ContinuousReplicationTrigger = "resume" | "daemon" | "online";
|
|
19
19
|
/** No user interaction may be requested by an unattended replication path. */
|
|
20
20
|
export declare const NO_INTERACTION: Readonly<{
|
|
21
21
|
readonly kind: "forbidden";
|
|
@@ -91,10 +91,30 @@ export interface UnattendedOneShotRequest {
|
|
|
91
91
|
readonly trigger: UnattendedReplicationTrigger;
|
|
92
92
|
readonly interaction: NoInteraction;
|
|
93
93
|
}
|
|
94
|
+
export interface ContinuousReplicationNetworkFailure {
|
|
95
|
+
readonly reason: "offline" | "remote-transport";
|
|
96
|
+
readonly hostOnlineAtFailure: boolean;
|
|
97
|
+
readonly failedAt: number;
|
|
98
|
+
}
|
|
99
|
+
/** A preparation gate can return the observation which caused it to refuse this operation. */
|
|
100
|
+
export type ReplicationPreparationResult = boolean | ContinuousReplicationNetworkFailure;
|
|
101
|
+
/** Capture the host observation at the gate which refused this operation. */
|
|
102
|
+
export declare function observedOfflineReplicationFailure(): ContinuousReplicationNetworkFailure;
|
|
103
|
+
/** Result of preparation and initial handoff to a continuous transfer. */
|
|
104
|
+
export type ContinuousReplicationStartResult = {
|
|
105
|
+
readonly status: "started";
|
|
106
|
+
} | {
|
|
107
|
+
readonly status: "cancelled";
|
|
108
|
+
} | {
|
|
109
|
+
readonly status: "failed";
|
|
110
|
+
readonly networkFailure?: ContinuousReplicationNetworkFailure;
|
|
111
|
+
};
|
|
94
112
|
/** A request which starts a provider's long-lived/continuous operation. */
|
|
95
113
|
export interface ContinuousReplicationRequest {
|
|
96
114
|
readonly trigger: ContinuousReplicationTrigger;
|
|
97
115
|
readonly interaction: NoInteraction;
|
|
116
|
+
/** Receive the result once, independently of short startup admission. */
|
|
117
|
+
readonly onStartSettled?: (result: ContinuousReplicationStartResult) => void;
|
|
98
118
|
}
|
|
99
119
|
/** Stable reasons for which a provider role cannot be run. */
|
|
100
120
|
export type ReplicationBlockReason = "no-active-replicator" | "no-targets" | "not-ready" | "provider-not-composed" | "provider-not-configured" | "capability-not-implemented" | "capability-not-applicable" | "interaction-required" | "replication-in-progress" | "rate-limited";
|
|
@@ -156,7 +176,8 @@ export type UnattendedOneShotRunner = (replicator: ReplicatorInstance, setting:
|
|
|
156
176
|
*
|
|
157
177
|
* The runner must return after task ownership and pre-controller cancellation
|
|
158
178
|
* have been registered. It must not retain the caller's active-publication
|
|
159
|
-
* admission for the lifetime of the long-lived transfer.
|
|
179
|
+
* admission for the lifetime of the long-lived transfer. After successful
|
|
180
|
+
* admission the runner owns delivery of the request's eventual start result.
|
|
160
181
|
*/
|
|
161
182
|
export type ContinuousRunner = (replicator: ReplicatorInstance, setting: RemoteDBSettings, request: ContinuousReplicationRequest) => Promise<ReplicationOutcome>;
|
|
162
183
|
/**
|
|
@@ -20,6 +20,9 @@ const REPLICATION_PROGRESS_PRESENTATIONS = Object.freeze({
|
|
|
20
20
|
QUIET: "quiet",
|
|
21
21
|
NOTICE: "notice"
|
|
22
22
|
});
|
|
23
|
+
function observedOfflineReplicationFailure() {
|
|
24
|
+
return { reason: "offline", hostOnlineAtFailure: false, failedAt: Date.now() };
|
|
25
|
+
}
|
|
23
26
|
const REPLICATION_COMPLETED = Object.freeze({ status: "completed" });
|
|
24
27
|
const REPLICATION_CANCELLED = Object.freeze({ status: "cancelled" });
|
|
25
28
|
const CENTRAL_REMOTE_REPLICATION_READINESS = Object.freeze({
|
|
@@ -109,7 +112,13 @@ function supportedOpenReplicationContinuous() {
|
|
|
109
112
|
return replicationBlocked("interaction-required");
|
|
110
113
|
}
|
|
111
114
|
try {
|
|
115
|
+
const observe = request.onStartSettled;
|
|
116
|
+
if (observe && replicator.startContinuousReplication) {
|
|
117
|
+
const result2 = await replicator.startContinuousReplication(setting, observe);
|
|
118
|
+
return outcomeFromContinuousOpenReplication(result2);
|
|
119
|
+
}
|
|
112
120
|
const result = await replicator.openReplication(setting, true, false, false);
|
|
121
|
+
if (result !== false) observe?.({ status: "started" });
|
|
113
122
|
return outcomeFromContinuousOpenReplication(result);
|
|
114
123
|
} catch (error) {
|
|
115
124
|
return replicationFailed(error);
|
|
@@ -142,6 +151,7 @@ export {
|
|
|
142
151
|
defineReplicatorProviderDefinitions,
|
|
143
152
|
isActiveReplicatorContextBoundToSetting,
|
|
144
153
|
isReplicationCompleted,
|
|
154
|
+
observedOfflineReplicationFailure,
|
|
145
155
|
outcomeFromContinuousOpenReplication,
|
|
146
156
|
outcomeFromFiniteOpenReplication,
|
|
147
157
|
replicationBlocked,
|
|
@@ -26,9 +26,9 @@ function isSyncParamsError(error) {
|
|
|
26
26
|
return error instanceof SyncParamsFetchError || error instanceof SyncParamsNotFoundError || error instanceof SyncParamsUpdateError;
|
|
27
27
|
}
|
|
28
28
|
function createSyncParamsHandler({ put, get, create }) {
|
|
29
|
-
let taskFetchParameters
|
|
30
|
-
const
|
|
31
|
-
let syncParams
|
|
29
|
+
let taskFetchParameters;
|
|
30
|
+
const readSyncParameters = async () => {
|
|
31
|
+
let syncParams;
|
|
32
32
|
try {
|
|
33
33
|
let shouldRetry = false;
|
|
34
34
|
do {
|
|
@@ -77,37 +77,38 @@ function createSyncParamsHandler({ put, get, create }) {
|
|
|
77
77
|
throw new Error(`Failed to prepare synchronisation key in synchronisation parameters`);
|
|
78
78
|
}
|
|
79
79
|
Logger(`Synchronisation parameters fetched successfully`, LOG_LEVEL_INFO);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
return syncParams;
|
|
88
|
-
} catch (ex) {
|
|
80
|
+
const parameters = {
|
|
81
|
+
...syncParams,
|
|
82
|
+
pbkdf2saltDecoded: new Uint8Array(base64ToArrayBufferInternalBrowser(syncParams.pbkdf2salt))
|
|
83
|
+
};
|
|
84
|
+
return { status: "success", parameters };
|
|
85
|
+
} catch (cause) {
|
|
89
86
|
Logger(`Failed to fetch synchronisation parameters`, LOG_LEVEL_INFO);
|
|
90
|
-
Logger(
|
|
91
|
-
|
|
92
|
-
return false;
|
|
87
|
+
Logger(cause, LOG_LEVEL_VERBOSE);
|
|
88
|
+
return { status: "failure", cause };
|
|
93
89
|
}
|
|
94
90
|
};
|
|
95
91
|
const fetchSyncParameters = (refresh = false) => {
|
|
96
|
-
if (taskFetchParameters && !refresh)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
if (taskFetchParameters && !refresh) return taskFetchParameters;
|
|
93
|
+
const task = readSyncParameters();
|
|
94
|
+
taskFetchParameters = task;
|
|
95
|
+
void task.then((result) => {
|
|
96
|
+
if (result.status === "failure" && taskFetchParameters === task) taskFetchParameters = void 0;
|
|
97
|
+
});
|
|
98
|
+
return task;
|
|
101
99
|
};
|
|
102
100
|
return {
|
|
103
|
-
fetch:
|
|
101
|
+
fetch: async (refresh) => {
|
|
102
|
+
const result = await fetchSyncParameters(refresh);
|
|
103
|
+
return result.status === "success" ? result.parameters : false;
|
|
104
|
+
},
|
|
104
105
|
getPBKDF2Salt: async (refresh = false) => {
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
106
|
+
const result = await fetchSyncParameters(refresh);
|
|
107
|
+
if (result.status === "failure") {
|
|
107
108
|
Logger(`Failed to fetch synchronisation parameters`, LOG_LEVEL_INFO);
|
|
108
|
-
throw new SyncParamsFetchError(`Failed to fetch synchronisation parameters
|
|
109
|
+
throw new SyncParamsFetchError(`Failed to fetch synchronisation parameters`, { cause: result.cause });
|
|
109
110
|
}
|
|
110
|
-
return
|
|
111
|
+
return result.parameters.pbkdf2saltDecoded;
|
|
111
112
|
}
|
|
112
113
|
};
|
|
113
114
|
}
|
|
@@ -7,10 +7,11 @@ import { LiveSyncAbstractReplicator, type LiveSyncReplicatorEnv, type RemoteDBSt
|
|
|
7
7
|
import type { OwnedCouchDBConnection, RemoteConnectionOpenOptions } from "../../services/base/RemoteConnection.js";
|
|
8
8
|
import type { IPathService } from "../../services/base/IService.js";
|
|
9
9
|
import { type CentralCompatibilityDecisionRecorder } from "../CentralCompatibility.js";
|
|
10
|
-
import { type ReplicationOutcome } from "../ReplicatorProvider.js";
|
|
10
|
+
import { type ContinuousReplicationStartResult, type ReplicationOutcome } from "../ReplicatorProvider.js";
|
|
11
11
|
import { type ForgetJoinedDeviceResult, type JoinedDevicesSnapshot } from "../joinedDevices.js";
|
|
12
12
|
export type { OwnedCouchDBConnection, RemoteConnectionOpenOptions } from "../../services/base/RemoteConnection.js";
|
|
13
13
|
type SyncProcessingResult = "DONE" | "NEED_RETRY" | "NEED_RESURRECT" | "FAILED" | "CANCELLED" | UnsupportedEncryptedDocumentFormatError;
|
|
14
|
+
type SettleContinuousStart = (result: ContinuousReplicationStartResult) => void;
|
|
14
15
|
/**
|
|
15
16
|
* Compatibility constructor environment for the CouchDB Replicator facade.
|
|
16
17
|
*
|
|
@@ -47,6 +48,7 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
|
|
47
48
|
* controller, so a stop request cannot be lost during catch-up.
|
|
48
49
|
*/
|
|
49
50
|
private continuousTask;
|
|
51
|
+
private continuousStart;
|
|
50
52
|
private continuousStopWaiter;
|
|
51
53
|
private continuousStopRequested;
|
|
52
54
|
private continuousPhase?;
|
|
@@ -72,6 +74,7 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
|
|
72
74
|
*/
|
|
73
75
|
terminateSync(): Promise<void>;
|
|
74
76
|
openReplication(setting: RemoteDBSettings, keepAlive: boolean, showResult: boolean, ignoreCleanLock: boolean): Promise<boolean>;
|
|
77
|
+
startContinuousReplication(setting: RemoteDBSettings, onStartSettled: SettleContinuousStart): Promise<boolean>;
|
|
75
78
|
/**
|
|
76
79
|
* Run one finite CouchDB attempt and retain only its own compatibility result.
|
|
77
80
|
*
|
|
@@ -92,6 +95,8 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
|
|
92
95
|
replicationErrored(e: unknown, database?: LiveSyncLocalDB | null): void;
|
|
93
96
|
replicationPaused(): void;
|
|
94
97
|
processSync(syncHandler: PouchDB.Replication.Sync<EntryDoc> | PouchDB.Replication.Replication<EntryDoc>, showResult: boolean, docSentOnStart: number, docArrivedOnStart: number, syncMode: "sync" | "pullOnly" | "pushOnly", retrying: boolean, reportCancelledAsDone?: boolean): Promise<SyncProcessingResult>;
|
|
98
|
+
private processSyncWithOutcome;
|
|
99
|
+
private runSyncTransfer;
|
|
95
100
|
getEmptyMaxEntry(remoteID: number): {
|
|
96
101
|
_id: string;
|
|
97
102
|
maxSeq: number | string;
|
|
@@ -117,6 +122,7 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
|
|
117
122
|
* controller. The admitted owner retains the established transfer behaviour.
|
|
118
123
|
*/
|
|
119
124
|
private runOneShotReplication;
|
|
125
|
+
private prepareOneShotSecuritySeed;
|
|
120
126
|
private checkOneShotReplicationConnectivity;
|
|
121
127
|
private closeRemoteConnection;
|
|
122
128
|
private notifyFiniteReplicationCompleted;
|
|
@@ -127,8 +133,12 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
|
|
127
133
|
replicateAllFromServerWithOutcome(setting: RemoteDBSettings, showingNotice?: boolean): Promise<ReplicationOutcome>;
|
|
128
134
|
private reportConnectivityPreflightTimeout;
|
|
129
135
|
checkReplicationConnectivity(setting: RemoteDBSettings, keepAlive: boolean, skipCheck: boolean, showResult: boolean, ignoreCleanLock?: boolean, connectionOptions?: RemoteConnectionOpenOptions, recordCompatibilityDecision?: CentralCompatibilityDecisionRecorder): Promise<false | CouchDBReplicationConnection>;
|
|
130
|
-
|
|
136
|
+
private checkReplicationConnectivityWithOutcome;
|
|
137
|
+
private openReplicationConnection;
|
|
138
|
+
openContinuousReplication(setting: RemoteDBSettings, showResult: boolean, retrying: boolean, onStartSettled?: SettleContinuousStart): Promise<boolean>;
|
|
139
|
+
private observeContinuousStart;
|
|
131
140
|
private clearContinuousTask;
|
|
141
|
+
private runContinuousCatchUp;
|
|
132
142
|
private runContinuousReplication;
|
|
133
143
|
closeReplication(): Promise<void>;
|
|
134
144
|
tryResetRemoteDatabase(setting: RemoteDBSettings): Promise<void>;
|
|
@@ -136,6 +146,8 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
|
|
136
146
|
markRemoteLocked(setting: RemoteDBSettings, locked: boolean, lockByClean: boolean): Promise<void>;
|
|
137
147
|
markRemoteResolved(setting: RemoteDBSettings): Promise<void>;
|
|
138
148
|
connectRemoteCouchDBWithSetting(settings: RemoteDBSettings, isMobile: boolean, performSetup?: boolean, skipInfo?: boolean, connectionOptions?: RemoteConnectionOpenOptions): Promise<string | OwnedCouchDBConnection<EntryDoc>>;
|
|
149
|
+
private connectRemoteCouchDBWithOutcome;
|
|
150
|
+
private openRemoteCouchDBWithSetting;
|
|
139
151
|
private openOwnedConnection;
|
|
140
152
|
/**
|
|
141
153
|
* Opens a raw PouchDB handle for compatibility with earlier Commonlib
|