@vrtmrz/livesync-commonlib 0.1.19 → 0.1.20
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 +5 -1
- package/dist/common/models/setting.p2p.d.ts +2 -0
- package/dist/common/models/setting.p2p.js +5 -0
- package/dist/interfaces/ServiceModule.d.ts +13 -4
- package/dist/managers/ChunkFetcher.js +10 -0
- package/dist/p2p/P2PService.d.ts +123 -0
- package/dist/p2p/P2PService.js +271 -0
- package/dist/p2p/index.d.ts +8 -0
- package/dist/p2p/index.js +8 -0
- package/dist/pouchdb/LiveSyncLocalDB.d.ts +3 -0
- package/dist/pouchdb/LiveSyncLocalDB.js +23 -3
- package/dist/pouchdb/ReplicatorShim.d.ts +43 -4
- package/dist/pouchdb/ReplicatorShim.js +78 -5
- package/dist/replication/CentralCompatibility.d.ts +38 -0
- package/dist/replication/CentralCompatibility.js +39 -0
- package/dist/replication/CentralRemoteAdministration.d.ts +84 -0
- package/dist/replication/CentralRemoteAdministration.js +71 -0
- package/dist/replication/LiveSyncAbstractReplicator.d.ts +19 -6
- package/dist/replication/ProviderCapability.d.ts +32 -0
- package/dist/replication/ProviderCapability.js +27 -0
- package/dist/replication/RemoteResource.d.ts +85 -0
- package/dist/replication/RemoteResource.js +17 -0
- package/dist/replication/ReplicatorInstance.d.ts +23 -0
- package/dist/replication/ReplicatorProvider.d.ts +249 -0
- package/dist/replication/ReplicatorProvider.js +145 -0
- package/dist/replication/couchdb/LiveSyncReplicator.d.ts +54 -8
- package/dist/replication/couchdb/LiveSyncReplicator.js +411 -158
- package/dist/replication/index.d.ts +10 -0
- package/dist/replication/index.js +70 -0
- package/dist/replication/journal/JournalSyncCore.d.ts +2 -0
- package/dist/replication/journal/JournalSyncCore.js +18 -5
- package/dist/replication/journal/LiveSyncJournalReplicator.d.ts +38 -10
- package/dist/replication/journal/LiveSyncJournalReplicator.js +271 -63
- package/dist/replication/journal/LiveSyncJournalReplicatorEnv.d.ts +8 -0
- package/dist/replication/journal/objectstore/JournalStorageAdapter.d.ts +2 -0
- package/dist/replication/journal/objectstore/MinioStorageAdapter.d.ts +2 -0
- package/dist/replication/journal/objectstore/MinioStorageAdapter.js +10 -1
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +12 -40
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.js +52 -152
- package/dist/replication/trystero/P2PAutomationCoordinator.d.ts +20 -0
- package/dist/replication/trystero/P2PAutomationCoordinator.js +43 -0
- package/dist/replication/trystero/P2PConnectionProbeAdmission.d.ts +32 -0
- package/dist/replication/trystero/P2PConnectionProbeAdmission.js +10 -0
- package/dist/replication/trystero/P2PReplicationWire.d.ts +31 -0
- package/dist/replication/trystero/P2PReplicationWire.js +50 -0
- package/dist/replication/trystero/P2PRoomSession.d.ts +32 -0
- package/dist/replication/trystero/P2PRoomSession.js +101 -0
- package/dist/replication/trystero/P2PRoomSessionOwner.d.ts +61 -0
- package/dist/replication/trystero/P2PRoomSessionOwner.js +249 -0
- package/dist/replication/trystero/TrysteroReplicator.d.ts +88 -36
- package/dist/replication/trystero/TrysteroReplicator.js +273 -113
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.d.ts +7 -4
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.js +21 -14
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +26 -3
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +84 -39
- package/dist/replication/trystero/UseP2PReplicatorResult.d.ts +10 -6
- package/dist/replication/trystero/addP2PEventHandlers.d.ts +8 -12
- package/dist/replication/trystero/addP2PEventHandlers.js +19 -19
- package/dist/replication/trystero/p2pReplicatorConfigurationIdentity.d.ts +9 -0
- package/dist/replication/trystero/p2pReplicatorConfigurationIdentity.js +30 -0
- package/dist/replication/trystero/types.d.ts +18 -0
- package/dist/replication/trystero/types.js +5 -1
- package/dist/replication/trystero/useP2PReplicatorCommands.d.ts +3 -3
- package/dist/replication/trystero/useP2PReplicatorCommands.js +6 -8
- package/dist/replication/trystero/useP2PReplicatorFeature.d.ts +16 -7
- package/dist/replication/trystero/useP2PReplicatorFeature.js +72 -55
- package/dist/rpc/RpcRoom.d.ts +15 -1
- package/dist/rpc/RpcRoom.js +176 -41
- package/dist/rpc/RpcSession.d.ts +3 -1
- package/dist/rpc/RpcSession.js +2 -2
- package/dist/rpc/index.d.ts +1 -1
- package/dist/rpc/transports/trysteroUtils.js +2 -1
- package/dist/rpc/types.d.ts +26 -1
- package/dist/serviceFeatures/checkRemoteSize.js +5 -2
- package/dist/serviceModules/Rebuilder.js +66 -56
- package/dist/services/base/AppLifecycleService.d.ts +4 -0
- package/dist/services/base/AppLifecycleService.js +4 -0
- package/dist/services/base/ControlService.js +0 -4
- package/dist/services/base/DatabaseEventService.js +1 -1
- package/dist/services/base/IService.d.ts +105 -8
- package/dist/services/base/ReadinessEvaluator.d.ts +40 -0
- package/dist/services/base/ReadinessEvaluator.js +16 -0
- package/dist/services/base/RemoteConnection.d.ts +3 -0
- package/dist/services/base/RemoteService.js +2 -2
- package/dist/services/base/ReplicationService.d.ts +45 -10
- package/dist/services/base/ReplicationService.js +248 -91
- package/dist/services/base/ReplicationService.readiness.d.ts +52 -0
- package/dist/services/base/ReplicationService.readiness.js +87 -0
- package/dist/services/base/ReplicationService.typedReplication.d.ts +83 -0
- package/dist/services/base/ReplicationService.typedReplication.js +191 -0
- package/dist/services/base/ReplicatorService.activeReplicatorState.d.ts +47 -0
- package/dist/services/base/ReplicatorService.activeReplicatorState.js +107 -0
- package/dist/services/base/ReplicatorService.centralRemoteAdministration.d.ts +5 -0
- package/dist/services/base/ReplicatorService.centralRemoteAdministration.js +44 -0
- package/dist/services/base/ReplicatorService.d.ts +75 -14
- package/dist/services/base/ReplicatorService.js +232 -53
- package/dist/services/base/ReplicatorService.remoteResourceResolver.d.ts +4 -0
- package/dist/services/base/ReplicatorService.remoteResourceResolver.js +11 -0
- package/dist/services/base/TweakValueService.d.ts +3 -2
- package/dist/services/implements/injectable/InjectableTweakValueService.d.ts +1 -1
- package/dist/services/lib/HandlerUtils.d.ts +24 -0
- package/dist/services/lib/HandlerUtils.js +40 -0
- package/docs/development.md +40 -7
- package/docs/p2p-transport-lifecycle.md +135 -11
- package/docs/proven-in-use.md +5 -1
- package/docs/remote-configurations.md +4 -0
- package/docs/service-feature-composition.md +250 -0
- package/package.json +17 -1
- package/dist/replication/trystero/P2PReplicatorBase.d.ts +0 -19
- package/dist/replication/trystero/P2PReplicatorCore.d.ts +0 -8
- package/dist/replication/trystero/P2PReplicatorCore.js +0 -56
- package/dist/replication/trystero/TrysteroReplicatorP2PConnection.d.ts +0 -2
- package/dist/replication/trystero/TrysteroReplicatorP2PConnection.js +0 -4
- /package/dist/replication/{trystero/P2PReplicatorBase.js → ReplicatorInstance.js} +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { RemoteDBSettings, RemotePreferredTweakResult } from "../common/types.js";
|
|
2
|
+
import type { RemoteDBStatus } from "./LiveSyncAbstractReplicator.js";
|
|
3
|
+
import { type CapabilitySupport } from "./ProviderCapability.js";
|
|
4
|
+
/** Stable machine identifiers for finite provider-owned remote resources. */
|
|
5
|
+
export declare const REMOTE_RESOURCE_KINDS: Readonly<{
|
|
6
|
+
readonly CONNECTION: "connection";
|
|
7
|
+
readonly PREFERRED_TWEAK: "preferred-tweak";
|
|
8
|
+
readonly SECURITY_SEED: "security-seed";
|
|
9
|
+
readonly SYNCHRONISATION_INFORMATION: "synchronisation-information";
|
|
10
|
+
}>;
|
|
11
|
+
export type RemoteResourceKind = (typeof REMOTE_RESOURCE_KINDS)[keyof typeof REMOTE_RESOURCE_KINDS];
|
|
12
|
+
/** Options understood by a provider's finite remote-connection resource. */
|
|
13
|
+
export interface RemoteConnectionProbeOptions {
|
|
14
|
+
/** Permit a provider which supports provisioning to create the selected remote. */
|
|
15
|
+
readonly createIfMissing?: boolean;
|
|
16
|
+
/** Permit the provider to emit its ordinary user-facing connection result. */
|
|
17
|
+
readonly showResult?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Result of checking one trial remote configuration. */
|
|
20
|
+
export type RemoteConnectionProbeResult = {
|
|
21
|
+
readonly ok: true;
|
|
22
|
+
} | {
|
|
23
|
+
readonly ok: false;
|
|
24
|
+
readonly reason?: unknown;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A finite connection and status resource bound to one trial configuration.
|
|
28
|
+
*
|
|
29
|
+
* The owner must call {@link RemoteConnectionProbe.dispose} even when an
|
|
30
|
+
* operation rejects. Disposal is asynchronous and must be idempotent.
|
|
31
|
+
*/
|
|
32
|
+
export interface RemoteConnectionProbe {
|
|
33
|
+
check(options?: RemoteConnectionProbeOptions): Promise<RemoteConnectionProbeResult>;
|
|
34
|
+
getStatus(): Promise<false | RemoteDBStatus>;
|
|
35
|
+
dispose(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/** A finite preferred-tweak reader bound to one trial configuration. */
|
|
38
|
+
export interface PreferredTweakProbe {
|
|
39
|
+
read(): Promise<RemotePreferredTweakResult>;
|
|
40
|
+
/** Release every resource owned by this probe. Repeated calls must settle safely. */
|
|
41
|
+
dispose(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* An owned reader for the remote Security Seed used to derive replication keys.
|
|
45
|
+
*
|
|
46
|
+
* Each read observes the remote for this resource's settings snapshot rather
|
|
47
|
+
* than reusing process-cached parameters from an earlier workflow. Reading the
|
|
48
|
+
* seed may create explicitly missing remote synchronisation parameters. The
|
|
49
|
+
* caller must therefore treat this as a bounded remote operation and dispose
|
|
50
|
+
* the resource in `finally`.
|
|
51
|
+
*/
|
|
52
|
+
export interface SecuritySeedResource {
|
|
53
|
+
read(): Promise<Uint8Array<ArrayBuffer>>;
|
|
54
|
+
dispose(): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* An owned verifier for the remote synchronisation-information document.
|
|
58
|
+
*
|
|
59
|
+
* A successful check proves that the document can be decrypted. When the
|
|
60
|
+
* document is absent, a provider may create it as part of the check. The owner
|
|
61
|
+
* must dispose the resource in `finally`.
|
|
62
|
+
*/
|
|
63
|
+
export interface SynchronisationInformationResource {
|
|
64
|
+
check(): Promise<boolean>;
|
|
65
|
+
dispose(): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
export type RemoteResourceMap = {
|
|
68
|
+
readonly [REMOTE_RESOURCE_KINDS.CONNECTION]: RemoteConnectionProbe;
|
|
69
|
+
readonly [REMOTE_RESOURCE_KINDS.PREFERRED_TWEAK]: PreferredTweakProbe;
|
|
70
|
+
readonly [REMOTE_RESOURCE_KINDS.SECURITY_SEED]: SecuritySeedResource;
|
|
71
|
+
readonly [REMOTE_RESOURCE_KINDS.SYNCHRONISATION_INFORMATION]: SynchronisationInformationResource;
|
|
72
|
+
};
|
|
73
|
+
export type RemoteResourceFactoryMap = {
|
|
74
|
+
readonly [K in RemoteResourceKind]: (setting: RemoteDBSettings) => Promise<RemoteResourceMap[K]>;
|
|
75
|
+
};
|
|
76
|
+
/** Exhaustive resource support catalogue supplied by one provider. */
|
|
77
|
+
export type RemoteResourceCapabilities = {
|
|
78
|
+
readonly [K in RemoteResourceKind]: CapabilitySupport<RemoteResourceFactoryMap[K]>;
|
|
79
|
+
};
|
|
80
|
+
/** Explicit catalogue for providers which own no finite remote resources. */
|
|
81
|
+
export declare const NO_REMOTE_RESOURCE_CAPABILITIES: RemoteResourceCapabilities;
|
|
82
|
+
export type ConnectionProbeFactory = RemoteResourceFactoryMap[typeof REMOTE_RESOURCE_KINDS.CONNECTION];
|
|
83
|
+
export type PreferredTweakProbeFactory = RemoteResourceFactoryMap[typeof REMOTE_RESOURCE_KINDS.PREFERRED_TWEAK];
|
|
84
|
+
export type SecuritySeedResourceFactory = RemoteResourceFactoryMap[typeof REMOTE_RESOURCE_KINDS.SECURITY_SEED];
|
|
85
|
+
export type SynchronisationInformationResourceFactory = RemoteResourceFactoryMap[typeof REMOTE_RESOURCE_KINDS.SYNCHRONISATION_INFORMATION];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CAPABILITY_NOT_APPLICABLE } from "./ProviderCapability.js";
|
|
2
|
+
const REMOTE_RESOURCE_KINDS = Object.freeze({
|
|
3
|
+
CONNECTION: "connection",
|
|
4
|
+
PREFERRED_TWEAK: "preferred-tweak",
|
|
5
|
+
SECURITY_SEED: "security-seed",
|
|
6
|
+
SYNCHRONISATION_INFORMATION: "synchronisation-information"
|
|
7
|
+
});
|
|
8
|
+
const NO_REMOTE_RESOURCE_CAPABILITIES = Object.freeze({
|
|
9
|
+
[REMOTE_RESOURCE_KINDS.CONNECTION]: CAPABILITY_NOT_APPLICABLE,
|
|
10
|
+
[REMOTE_RESOURCE_KINDS.PREFERRED_TWEAK]: CAPABILITY_NOT_APPLICABLE,
|
|
11
|
+
[REMOTE_RESOURCE_KINDS.SECURITY_SEED]: CAPABILITY_NOT_APPLICABLE,
|
|
12
|
+
[REMOTE_RESOURCE_KINDS.SYNCHRONISATION_INFORMATION]: CAPABILITY_NOT_APPLICABLE
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
NO_REMOTE_RESOURCE_CAPABILITIES,
|
|
16
|
+
REMOTE_RESOURCE_KINDS
|
|
17
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RemoteDBSettings } from "../common/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal lifecycle contract shared by active Replicator instances.
|
|
4
|
+
*
|
|
5
|
+
* Providers may expose additional operations through focused capability facets;
|
|
6
|
+
* this contract contains only the lifecycle operations required by the host.
|
|
7
|
+
*/
|
|
8
|
+
export interface ReplicatorInstance {
|
|
9
|
+
/** Initialise local database state required by replication before publication. */
|
|
10
|
+
initializeDatabaseForReplication(): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Invoke the legacy replication entry point.
|
|
13
|
+
*
|
|
14
|
+
* A `void` settlement may mean an accepted long-lived start, while finite
|
|
15
|
+
* adapters require an explicit `true`. Provider runners convert this
|
|
16
|
+
* compatibility result to a typed outcome before exposing it to callers.
|
|
17
|
+
*/
|
|
18
|
+
openReplication(setting: RemoteDBSettings, keepAlive: boolean, showResult: boolean, ignoreCleanLock: boolean): Promise<void | boolean>;
|
|
19
|
+
/** Stop active transfer work; providers may settle this synchronously. */
|
|
20
|
+
terminateSync(): void | Promise<void>;
|
|
21
|
+
/** Close the instance; providers may settle this synchronously. */
|
|
22
|
+
closeReplication(): void | Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import type { RemoteDBSettings, ObsidianLiveSyncSettings, RemoteType } from "../common/types.js";
|
|
2
|
+
import type { ReplicatorInstance } from "./ReplicatorInstance.js";
|
|
3
|
+
import { type CapabilitySupport, type SupportedCapability } from "./ProviderCapability.js";
|
|
4
|
+
import type { RemoteResourceCapabilities } from "./RemoteResource.js";
|
|
5
|
+
import type { CentralRemoteAdministrationRunner } from "./CentralRemoteAdministration.js";
|
|
6
|
+
import type { CentralCompatibilityRecoveryHint } from "./CentralCompatibility.js";
|
|
7
|
+
export { CAPABILITY_NOT_APPLICABLE, CAPABILITY_NOT_IMPLEMENTED, CAPABILITY_SUPPORT_KINDS, CAPABILITY_UNAVAILABLE_REASONS, supportedCapability, } from "./ProviderCapability.js";
|
|
8
|
+
export type { CapabilitySupport, NotApplicableCapability, NotImplementedCapability, SupportedCapability, } from "./ProviderCapability.js";
|
|
9
|
+
/**
|
|
10
|
+
* A finite replication trigger which can run without opening a user dialogue.
|
|
11
|
+
*
|
|
12
|
+
* This is deliberately a closed list. Adding another automatic trigger must
|
|
13
|
+
* make its lifecycle ownership visible at the call site and in the provider
|
|
14
|
+
* contract rather than silently inheriting manual interaction permissions.
|
|
15
|
+
*/
|
|
16
|
+
export type UnattendedReplicationTrigger = "resume" | "periodic" | "database-event" | "editor-save" | "file-open" | "merge" | "daemon";
|
|
17
|
+
/** Automatic trigger which may start or resume a long-lived connection. */
|
|
18
|
+
export type ContinuousReplicationTrigger = "resume" | "daemon";
|
|
19
|
+
/** No user interaction may be requested by an unattended replication path. */
|
|
20
|
+
export declare const NO_INTERACTION: Readonly<{
|
|
21
|
+
readonly kind: "forbidden";
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* The authority carried by a user-initiated replication command.
|
|
25
|
+
*
|
|
26
|
+
* The permissions are explicit so that a future caller can narrow an
|
|
27
|
+
* operation without passing a broad boolean such as `showMessage` through
|
|
28
|
+
* provider code. The common authority grants all currently supported user
|
|
29
|
+
* actions.
|
|
30
|
+
*/
|
|
31
|
+
export declare const USER_INITIATED_REPLICATION_AUTHORITY: Readonly<{
|
|
32
|
+
readonly kind: "permitted";
|
|
33
|
+
readonly permissions: Readonly<{
|
|
34
|
+
peerSelection: true;
|
|
35
|
+
localPeerAdmission: true;
|
|
36
|
+
configurationExchange: true;
|
|
37
|
+
failureRecovery: true;
|
|
38
|
+
}>;
|
|
39
|
+
}>;
|
|
40
|
+
export type NoInteraction = typeof NO_INTERACTION;
|
|
41
|
+
/** All interaction permissions understood by the current provider boundary. */
|
|
42
|
+
export interface InteractionPermissions {
|
|
43
|
+
readonly peerSelection: boolean;
|
|
44
|
+
readonly localPeerAdmission: boolean;
|
|
45
|
+
readonly configurationExchange: boolean;
|
|
46
|
+
readonly failureRecovery: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A permitted authority must retain at least one explicit permission.
|
|
50
|
+
*
|
|
51
|
+
* This prevents an apparently user-authorised request from carrying an empty
|
|
52
|
+
* permission set, while allowing a caller to veto or narrow individual
|
|
53
|
+
* actions without introducing a second authority type.
|
|
54
|
+
*/
|
|
55
|
+
export type PermittedInteractionPermissions = (InteractionPermissions & {
|
|
56
|
+
readonly peerSelection: true;
|
|
57
|
+
}) | (InteractionPermissions & {
|
|
58
|
+
readonly localPeerAdmission: true;
|
|
59
|
+
}) | (InteractionPermissions & {
|
|
60
|
+
readonly configurationExchange: true;
|
|
61
|
+
}) | (InteractionPermissions & {
|
|
62
|
+
readonly failureRecovery: true;
|
|
63
|
+
});
|
|
64
|
+
export interface UserInitiatedReplicationAuthority {
|
|
65
|
+
readonly kind: "permitted";
|
|
66
|
+
readonly permissions: PermittedInteractionPermissions;
|
|
67
|
+
}
|
|
68
|
+
export type ReplicationInteraction = NoInteraction | UserInitiatedReplicationAuthority;
|
|
69
|
+
/** Authority carried through a replication request and its failure path. */
|
|
70
|
+
export type InteractionAuthority = ReplicationInteraction;
|
|
71
|
+
/** A request made by an explicitly user-initiated one-shot command. */
|
|
72
|
+
export interface UserInitiatedOneShotRequest {
|
|
73
|
+
readonly trigger: "manual";
|
|
74
|
+
readonly interaction: InteractionAuthority;
|
|
75
|
+
}
|
|
76
|
+
/** A request made by an automatic finite replication trigger. */
|
|
77
|
+
export interface UnattendedOneShotRequest {
|
|
78
|
+
readonly trigger: UnattendedReplicationTrigger;
|
|
79
|
+
readonly interaction: NoInteraction;
|
|
80
|
+
}
|
|
81
|
+
/** A request which starts a provider's long-lived/continuous operation. */
|
|
82
|
+
export interface ContinuousReplicationRequest {
|
|
83
|
+
readonly trigger: ContinuousReplicationTrigger;
|
|
84
|
+
readonly interaction: NoInteraction;
|
|
85
|
+
}
|
|
86
|
+
/** Stable reasons for which a provider role cannot be run. */
|
|
87
|
+
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";
|
|
88
|
+
/** A finite operation completed without a partial or failed result. */
|
|
89
|
+
export declare const REPLICATION_COMPLETED: Readonly<{
|
|
90
|
+
readonly status: "completed";
|
|
91
|
+
}>;
|
|
92
|
+
/** A user-initiated operation was cancelled before it completed. */
|
|
93
|
+
export declare const REPLICATION_CANCELLED: Readonly<{
|
|
94
|
+
readonly status: "cancelled";
|
|
95
|
+
}>;
|
|
96
|
+
export type ReplicationCompleted = typeof REPLICATION_COMPLETED;
|
|
97
|
+
export type ReplicationCancelled = typeof REPLICATION_CANCELLED;
|
|
98
|
+
export type ReplicationBlocked = {
|
|
99
|
+
readonly status: "blocked";
|
|
100
|
+
readonly reason: ReplicationBlockReason;
|
|
101
|
+
};
|
|
102
|
+
export type ReplicationPartial = {
|
|
103
|
+
readonly status: "partial";
|
|
104
|
+
readonly detail: unknown;
|
|
105
|
+
};
|
|
106
|
+
export type ReplicationFailed = {
|
|
107
|
+
readonly status: "failed";
|
|
108
|
+
readonly error: unknown;
|
|
109
|
+
readonly recoveryHint?: CentralCompatibilityRecoveryHint;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Result of a typed replication role.
|
|
113
|
+
*
|
|
114
|
+
* `completed` is intentionally not represented by a truthy value from the
|
|
115
|
+
* legacy `openReplication` method. Providers must opt into this singleton,
|
|
116
|
+
* which keeps `false` and `void` observable as non-completion for finite work.
|
|
117
|
+
*/
|
|
118
|
+
export type ReplicationOutcome = ReplicationCompleted | ReplicationCancelled | ReplicationBlocked | ReplicationPartial | ReplicationFailed;
|
|
119
|
+
/** Preparation required before an ordinary operation may use a provider. */
|
|
120
|
+
export interface ReplicationReadinessRequirements {
|
|
121
|
+
readonly centralRemotePreparation: "required" | "not-applicable";
|
|
122
|
+
}
|
|
123
|
+
/** Shared readiness contract for providers backed by the central remote. */
|
|
124
|
+
export declare const CENTRAL_REMOTE_REPLICATION_READINESS: Readonly<{
|
|
125
|
+
readonly centralRemotePreparation: "required";
|
|
126
|
+
}>;
|
|
127
|
+
/** Shared readiness contract for peer-to-peer providers without a central remote. */
|
|
128
|
+
export declare const PEER_REPLICATION_READINESS: Readonly<{
|
|
129
|
+
readonly centralRemotePreparation: "not-applicable";
|
|
130
|
+
}>;
|
|
131
|
+
/** Return whether a typed replication result represents completed work. */
|
|
132
|
+
export declare function isReplicationCompleted(outcome: ReplicationOutcome): outcome is ReplicationCompleted;
|
|
133
|
+
export declare function replicationBlocked(reason: ReplicationBlockReason): ReplicationBlocked;
|
|
134
|
+
export declare function replicationFailed(error: unknown, recoveryHint?: CentralCompatibilityRecoveryHint): ReplicationFailed;
|
|
135
|
+
export type UserInitiatedOneShotRunner = (replicator: ReplicatorInstance, setting: RemoteDBSettings, request: UserInitiatedOneShotRequest) => Promise<ReplicationOutcome>;
|
|
136
|
+
export type UnattendedOneShotRunner = (replicator: ReplicatorInstance, setting: RemoteDBSettings, request: UnattendedOneShotRequest) => Promise<ReplicationOutcome>;
|
|
137
|
+
/**
|
|
138
|
+
* Register a provider-owned Continuous task and settle its startup request.
|
|
139
|
+
*
|
|
140
|
+
* The runner must return after task ownership and pre-controller cancellation
|
|
141
|
+
* have been registered. It must not retain the caller's active-publication
|
|
142
|
+
* admission for the lifetime of the long-lived transfer.
|
|
143
|
+
*/
|
|
144
|
+
export type ContinuousRunner = (replicator: ReplicatorInstance, setting: RemoteDBSettings, request: ContinuousReplicationRequest) => Promise<ReplicationOutcome>;
|
|
145
|
+
/**
|
|
146
|
+
* Request cancellation of finite transfer work on the currently active
|
|
147
|
+
* replicator. A `completed` outcome confirms that the stop request was
|
|
148
|
+
* accepted; it does not claim rollback of work which had already settled.
|
|
149
|
+
*/
|
|
150
|
+
export type StopActiveTransferRunner = (replicator: ReplicatorInstance) => Promise<ReplicationOutcome>;
|
|
151
|
+
/**
|
|
152
|
+
* Opaque provider-owned projection of every setting which binds an active Replicator.
|
|
153
|
+
* It is private comparison state and must not be logged, persisted, or displayed.
|
|
154
|
+
*/
|
|
155
|
+
export type ReplicatorConfigurationIdentity = string;
|
|
156
|
+
/** One host-composed provider and every role which may use its active instance. */
|
|
157
|
+
export interface ReplicatorProviderDefinition<TKind extends RemoteType = RemoteType> {
|
|
158
|
+
/** Canonical persisted remote kind used for provider selection. */
|
|
159
|
+
readonly kind: TKind;
|
|
160
|
+
/** Human-readable diagnostic label; never use it as a machine decision. */
|
|
161
|
+
readonly diagnosticName: string;
|
|
162
|
+
/** Preparation gates required before an ordinary replication role runs. */
|
|
163
|
+
readonly readiness: ReplicationReadinessRequirements;
|
|
164
|
+
/** Return whether the effective settings are sufficient to construct this provider. */
|
|
165
|
+
readonly isConfigured: (setting: RemoteDBSettings) => boolean;
|
|
166
|
+
/** Project the fully merged effective settings to this provider's stable binding identity. */
|
|
167
|
+
readonly configurationIdentity: (setting: RemoteDBSettings) => ReplicatorConfigurationIdentity;
|
|
168
|
+
/** Construct a replicator from the fully merged effective settings. */
|
|
169
|
+
readonly create: (setting: ObsidianLiveSyncSettings) => Promise<ReplicatorInstance | undefined | false>;
|
|
170
|
+
/** Exhaustive provider-owned catalogue for finite remote resources. */
|
|
171
|
+
readonly remoteResources: RemoteResourceCapabilities;
|
|
172
|
+
/** Optional provider-owned central-remote administration runner. */
|
|
173
|
+
readonly centralRemoteAdministration?: CapabilitySupport<CentralRemoteAdministrationRunner>;
|
|
174
|
+
/** Finite role carrying explicit user-interaction authority. */
|
|
175
|
+
readonly userInitiatedOneShot: CapabilitySupport<UserInitiatedOneShotRunner>;
|
|
176
|
+
/** Finite role which must not request user interaction. */
|
|
177
|
+
readonly unattendedOneShot: CapabilitySupport<UnattendedOneShotRunner>;
|
|
178
|
+
/** Explicit support decision for ordinary long-lived Continuous replication. */
|
|
179
|
+
readonly continuous: CapabilitySupport<ContinuousRunner>;
|
|
180
|
+
/** Bounded cancellation request for transfer work on the active instance. */
|
|
181
|
+
readonly stopActiveTransfer: CapabilitySupport<StopActiveTransferRunner>;
|
|
182
|
+
}
|
|
183
|
+
/** The atomic provider, Replicator, and binding identity published by the owner service. */
|
|
184
|
+
export interface ActiveReplicatorContext<TKind extends RemoteType = RemoteType> {
|
|
185
|
+
readonly provider: ReplicatorProviderDefinition<TKind>;
|
|
186
|
+
readonly replicator: ReplicatorInstance;
|
|
187
|
+
/** Private comparison state; callers must not log, persist, or display it. */
|
|
188
|
+
readonly configurationIdentity: ReplicatorConfigurationIdentity;
|
|
189
|
+
}
|
|
190
|
+
/** Immutable source of one failed attempt, safe to carry after its reservation is released. */
|
|
191
|
+
export interface ReplicationAttemptFailure {
|
|
192
|
+
readonly context: ActiveReplicatorContext;
|
|
193
|
+
readonly setting: ObsidianLiveSyncSettings;
|
|
194
|
+
readonly outcome: ReplicationFailed;
|
|
195
|
+
}
|
|
196
|
+
/** Immutable failure source plus the interaction authority of its original request. */
|
|
197
|
+
export interface ReplicationFailureRequest extends ReplicationAttemptFailure {
|
|
198
|
+
readonly showMessage: boolean;
|
|
199
|
+
readonly interaction: InteractionAuthority;
|
|
200
|
+
}
|
|
201
|
+
/** Return whether one detached setting still belongs to the admitted publication. */
|
|
202
|
+
export declare function isActiveReplicatorContextBoundToSetting(context: ActiveReplicatorContext, setting: RemoteDBSettings): boolean;
|
|
203
|
+
export type ReplicatorProviderDefinitionMap = ReadonlyMap<RemoteType, ReplicatorProviderDefinition>;
|
|
204
|
+
/**
|
|
205
|
+
* Define exactly the provider subset composed by a host.
|
|
206
|
+
*
|
|
207
|
+
* The tuple is the host's closed catalogue for this composition. The mapped
|
|
208
|
+
* argument makes every selected kind required at compile time, while the
|
|
209
|
+
* runtime checks reject duplicate, omitted, or extra definitions. A host can
|
|
210
|
+
* therefore omit a provider intentionally, but cannot silently select a
|
|
211
|
+
* partially defined provider.
|
|
212
|
+
*/
|
|
213
|
+
export declare function defineReplicatorProviderDefinitions<const TKind extends readonly RemoteType[]>(kinds: TKind, definitions: {
|
|
214
|
+
readonly [K in TKind[number]]: ReplicatorProviderDefinition<K>;
|
|
215
|
+
}): ReplicatorProviderDefinitionMap;
|
|
216
|
+
/**
|
|
217
|
+
* Convert a legacy `openReplication` result to the typed finite outcome.
|
|
218
|
+
* `void` is not a success signal for a finite operation.
|
|
219
|
+
*/
|
|
220
|
+
export declare function outcomeFromFiniteOpenReplication(result: void | boolean, recoveryHint?: CentralCompatibilityRecoveryHint): ReplicationOutcome;
|
|
221
|
+
/**
|
|
222
|
+
* Convert a legacy `openReplication` result to a continuous-start outcome.
|
|
223
|
+
* A provider which returns `void` has accepted the start request, whereas an
|
|
224
|
+
* explicit `false` still reports a failed start.
|
|
225
|
+
*/
|
|
226
|
+
export declare function outcomeFromContinuousOpenReplication(result: void | boolean): ReplicationOutcome;
|
|
227
|
+
/**
|
|
228
|
+
* Adapt legacy `openReplication` for package and test compatibility.
|
|
229
|
+
*
|
|
230
|
+
* Current central providers use exact-outcome wrappers; this
|
|
231
|
+
* adapter remains for consumers and tests which still expose the legacy role.
|
|
232
|
+
*/
|
|
233
|
+
export declare function supportedOpenReplicationOneShot(): SupportedCapability<UserInitiatedOneShotRunner>;
|
|
234
|
+
/**
|
|
235
|
+
* Adapt legacy `openReplication` for unattended package and test compatibility.
|
|
236
|
+
*
|
|
237
|
+
* Current central providers use exact-outcome wrappers; this
|
|
238
|
+
* adapter remains for consumers and tests which still expose the legacy role.
|
|
239
|
+
*/
|
|
240
|
+
export declare function supportedOpenReplicationUnattended(): SupportedCapability<UnattendedOneShotRunner>;
|
|
241
|
+
export declare function supportedOpenReplicationContinuous(): SupportedCapability<ContinuousRunner>;
|
|
242
|
+
/**
|
|
243
|
+
* Adapt the legacy termination hook to the typed active-transfer capability.
|
|
244
|
+
*
|
|
245
|
+
* `terminateSync` is intentionally awaited even though existing replicators
|
|
246
|
+
* implement it synchronously. This keeps the capability boundary valid for a
|
|
247
|
+
* provider whose cancellation work needs to settle asynchronously.
|
|
248
|
+
*/
|
|
249
|
+
export declare function supportedStopActiveTransfer(): SupportedCapability<StopActiveTransferRunner>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { supportedCapability } from "./ProviderCapability.js";
|
|
2
|
+
import {
|
|
3
|
+
CAPABILITY_NOT_APPLICABLE,
|
|
4
|
+
CAPABILITY_NOT_IMPLEMENTED,
|
|
5
|
+
CAPABILITY_SUPPORT_KINDS,
|
|
6
|
+
CAPABILITY_UNAVAILABLE_REASONS,
|
|
7
|
+
supportedCapability as supportedCapability2
|
|
8
|
+
} from "./ProviderCapability.js";
|
|
9
|
+
const NO_INTERACTION = Object.freeze({ kind: "forbidden" });
|
|
10
|
+
const USER_INITIATED_REPLICATION_AUTHORITY = Object.freeze({
|
|
11
|
+
kind: "permitted",
|
|
12
|
+
permissions: Object.freeze({
|
|
13
|
+
peerSelection: true,
|
|
14
|
+
localPeerAdmission: true,
|
|
15
|
+
configurationExchange: true,
|
|
16
|
+
failureRecovery: true
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
const REPLICATION_COMPLETED = Object.freeze({ status: "completed" });
|
|
20
|
+
const REPLICATION_CANCELLED = Object.freeze({ status: "cancelled" });
|
|
21
|
+
const CENTRAL_REMOTE_REPLICATION_READINESS = Object.freeze({
|
|
22
|
+
centralRemotePreparation: "required"
|
|
23
|
+
});
|
|
24
|
+
const PEER_REPLICATION_READINESS = Object.freeze({
|
|
25
|
+
centralRemotePreparation: "not-applicable"
|
|
26
|
+
});
|
|
27
|
+
function isReplicationCompleted(outcome) {
|
|
28
|
+
return outcome.status === "completed";
|
|
29
|
+
}
|
|
30
|
+
function replicationBlocked(reason) {
|
|
31
|
+
return { status: "blocked", reason };
|
|
32
|
+
}
|
|
33
|
+
function replicationFailed(error, recoveryHint) {
|
|
34
|
+
return {
|
|
35
|
+
status: "failed",
|
|
36
|
+
error,
|
|
37
|
+
...recoveryHint === void 0 ? {} : { recoveryHint }
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function isActiveReplicatorContextBoundToSetting(context, setting) {
|
|
41
|
+
try {
|
|
42
|
+
return setting.remoteType === context.provider.kind && context.provider.isConfigured(setting) && context.provider.configurationIdentity(setting) === context.configurationIdentity;
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function defineReplicatorProviderDefinitions(kinds, definitions) {
|
|
48
|
+
const selectedKinds = new Set(kinds);
|
|
49
|
+
if (selectedKinds.size !== kinds.length) {
|
|
50
|
+
throw new Error("Replicator provider kinds must be unique.");
|
|
51
|
+
}
|
|
52
|
+
if (Object.keys(definitions).length !== selectedKinds.size) {
|
|
53
|
+
throw new Error("Replicator provider definitions must match the selected provider kinds.");
|
|
54
|
+
}
|
|
55
|
+
const result = /* @__PURE__ */ new Map();
|
|
56
|
+
for (const kind of kinds) {
|
|
57
|
+
const definition = definitions[kind];
|
|
58
|
+
if (!definition || definition.kind !== kind) {
|
|
59
|
+
throw new Error(`Replicator provider definition does not match '${kind}'.`);
|
|
60
|
+
}
|
|
61
|
+
result.set(kind, definition);
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
function outcomeFromFiniteOpenReplication(result, recoveryHint) {
|
|
66
|
+
return result === true ? REPLICATION_COMPLETED : replicationFailed(new Error("The provider did not complete finite replication."), recoveryHint);
|
|
67
|
+
}
|
|
68
|
+
function outcomeFromContinuousOpenReplication(result) {
|
|
69
|
+
return result === false ? replicationFailed(new Error("The provider rejected continuous replication.")) : REPLICATION_COMPLETED;
|
|
70
|
+
}
|
|
71
|
+
function supportedOpenReplicationOneShot() {
|
|
72
|
+
return supportedCapability(async (replicator, setting, request) => {
|
|
73
|
+
try {
|
|
74
|
+
const result = await replicator.openReplication(
|
|
75
|
+
setting,
|
|
76
|
+
false,
|
|
77
|
+
request.interaction.kind === "permitted" && request.interaction.permissions.failureRecovery,
|
|
78
|
+
false
|
|
79
|
+
);
|
|
80
|
+
return outcomeFromFiniteOpenReplication(result);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return replicationFailed(error);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function supportedOpenReplicationUnattended() {
|
|
87
|
+
return supportedCapability(async (replicator, setting, request) => {
|
|
88
|
+
if (request.interaction.kind !== NO_INTERACTION.kind) {
|
|
89
|
+
return replicationBlocked("interaction-required");
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const result = await replicator.openReplication(setting, false, false, false);
|
|
93
|
+
return outcomeFromFiniteOpenReplication(result);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
return replicationFailed(error);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function supportedOpenReplicationContinuous() {
|
|
100
|
+
return supportedCapability(async (replicator, setting, request) => {
|
|
101
|
+
if (request.interaction.kind !== NO_INTERACTION.kind) {
|
|
102
|
+
return replicationBlocked("interaction-required");
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const result = await replicator.openReplication(setting, true, false, false);
|
|
106
|
+
return outcomeFromContinuousOpenReplication(result);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
return replicationFailed(error);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function supportedStopActiveTransfer() {
|
|
113
|
+
return supportedCapability(async (replicator) => {
|
|
114
|
+
try {
|
|
115
|
+
await replicator.terminateSync();
|
|
116
|
+
return REPLICATION_COMPLETED;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
return replicationFailed(error);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
CAPABILITY_NOT_APPLICABLE,
|
|
124
|
+
CAPABILITY_NOT_IMPLEMENTED,
|
|
125
|
+
CAPABILITY_SUPPORT_KINDS,
|
|
126
|
+
CAPABILITY_UNAVAILABLE_REASONS,
|
|
127
|
+
CENTRAL_REMOTE_REPLICATION_READINESS,
|
|
128
|
+
NO_INTERACTION,
|
|
129
|
+
PEER_REPLICATION_READINESS,
|
|
130
|
+
REPLICATION_CANCELLED,
|
|
131
|
+
REPLICATION_COMPLETED,
|
|
132
|
+
USER_INITIATED_REPLICATION_AUTHORITY,
|
|
133
|
+
defineReplicatorProviderDefinitions,
|
|
134
|
+
isActiveReplicatorContextBoundToSetting,
|
|
135
|
+
isReplicationCompleted,
|
|
136
|
+
outcomeFromContinuousOpenReplication,
|
|
137
|
+
outcomeFromFiniteOpenReplication,
|
|
138
|
+
replicationBlocked,
|
|
139
|
+
replicationFailed,
|
|
140
|
+
supportedCapability2 as supportedCapability,
|
|
141
|
+
supportedOpenReplicationContinuous,
|
|
142
|
+
supportedOpenReplicationOneShot,
|
|
143
|
+
supportedOpenReplicationUnattended,
|
|
144
|
+
supportedStopActiveTransfer
|
|
145
|
+
};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { type EntryDoc, type RemoteDBSettings, type EntryLeaf, type SyncParameters, type DatabaseEntry, type NodeData, type RemotePreferredTweakResult } from "../../common/types.js";
|
|
2
2
|
import { LiveSyncAbstractReplicator, type LiveSyncReplicatorEnv, type RemoteDBStatus } from "../LiveSyncAbstractReplicator.js";
|
|
3
|
-
import type { ServiceHub } from "../../services/ServiceHub.js";
|
|
4
3
|
import type { OwnedCouchDBConnection, RemoteConnectionOpenOptions } from "../../services/base/RemoteConnection.js";
|
|
4
|
+
import { type CentralCompatibilityDecisionRecorder } from "../CentralCompatibility.js";
|
|
5
|
+
import { type ReplicationOutcome } from "../ReplicatorProvider.js";
|
|
5
6
|
export type { OwnedCouchDBConnection, RemoteConnectionOpenOptions } from "../../services/base/RemoteConnection.js";
|
|
7
|
+
/**
|
|
8
|
+
* Compatibility constructor environment for the CouchDB Replicator facade.
|
|
9
|
+
*
|
|
10
|
+
* CouchDB adds only the bounded one-shot preflight policy to the shared
|
|
11
|
+
* Replicator environment. Active-provider capabilities remain separate.
|
|
12
|
+
*/
|
|
6
13
|
export interface LiveSyncCouchDBReplicatorEnv extends LiveSyncReplicatorEnv {
|
|
7
|
-
services: ServiceHub;
|
|
8
14
|
/** Internal injection point for the bounded one-shot connectivity preflight. */
|
|
9
15
|
oneShotConnectivityTimeoutMs?: number;
|
|
10
16
|
}
|
|
@@ -26,6 +32,13 @@ export interface CouchDBReplicationConnection extends OwnedCouchDBConnection<Ent
|
|
|
26
32
|
}
|
|
27
33
|
export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicator {
|
|
28
34
|
env: LiveSyncCouchDBReplicatorEnv;
|
|
35
|
+
/**
|
|
36
|
+
* Keep Continuous ownership visible before CouchDB has created its live
|
|
37
|
+
* controller, so a stop request cannot be lost during catch-up.
|
|
38
|
+
*/
|
|
39
|
+
private continuousTask;
|
|
40
|
+
private continuousStopWaiter;
|
|
41
|
+
private continuousStopRequested;
|
|
29
42
|
isMobile(): boolean;
|
|
30
43
|
constructor(env: LiveSyncCouchDBReplicatorEnv);
|
|
31
44
|
getInitialSyncParameters(setting: RemoteDBSettings): Promise<SyncParameters>;
|
|
@@ -33,8 +46,23 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
|
|
33
46
|
putSyncParameters(setting: RemoteDBSettings, params: SyncParameters): Promise<boolean>;
|
|
34
47
|
getReplicationPBKDF2Salt(setting: RemoteDBSettings, refresh?: boolean): Promise<Uint8Array<ArrayBuffer>>;
|
|
35
48
|
migrate(from: number, to: number): Promise<boolean>;
|
|
36
|
-
|
|
49
|
+
/** Abort only the active controller; internal transitions must not await their own task. */
|
|
50
|
+
private abortController;
|
|
51
|
+
/**
|
|
52
|
+
* Request cancellation of the current transfer and share the tracked
|
|
53
|
+
* Continuous settlement when startup has not created a controller yet.
|
|
54
|
+
*/
|
|
55
|
+
terminateSync(): Promise<void>;
|
|
37
56
|
openReplication(setting: RemoteDBSettings, keepAlive: boolean, showResult: boolean, ignoreCleanLock: boolean): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Run one finite CouchDB attempt and retain only its own compatibility result.
|
|
59
|
+
*
|
|
60
|
+
* The decision is stack-local. A transport failure before assessment has no
|
|
61
|
+
* recovery hint, and a rejected assessment cannot leak into a later attempt.
|
|
62
|
+
*/
|
|
63
|
+
openOneShotReplicationWithOutcome(setting: RemoteDBSettings, showResult: boolean, ignoreCleanLock?: boolean): Promise<ReplicationOutcome>;
|
|
64
|
+
/** Capture the compatibility decision made by this exact directional connection. */
|
|
65
|
+
private runOneShotReplicationWithOutcome;
|
|
38
66
|
replicationActivated(showResult: boolean): void;
|
|
39
67
|
replicationChangeDetected(e: PouchDB.Replication.SyncResult<EntryDoc>, showResult: boolean, docSentOnStart: number, docArrivedOnStart: number): Promise<void>;
|
|
40
68
|
replicationCompleted(showResult: boolean): void;
|
|
@@ -52,21 +80,39 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
|
|
52
80
|
getLastTransferredSeqOfChunks(localDB: PouchDB.Database, remoteID: number): Promise<ReturnType<typeof this.getEmptyMaxEntry>>;
|
|
53
81
|
updateMaxTransferredSeqOnChunks(localDB: PouchDB.Database, remoteID: number, seqStatusMap: Record<number, boolean>): Promise<ReturnType<typeof this.getEmptyMaxEntry>>;
|
|
54
82
|
sendChunks(setting: RemoteDBSettings, remoteDB: PouchDB.Database<EntryDoc> | undefined, showResult: boolean, fromSeq?: number | string): Promise<boolean>;
|
|
55
|
-
|
|
83
|
+
/** Run one finite transfer through the legacy boolean settlement contract. */
|
|
84
|
+
openOneShotReplication(setting: RemoteDBSettings, showResult: boolean, retrying: boolean, syncMode: "sync" | "pullOnly" | "pushOnly", ignoreCleanLock?: boolean, recordCompatibilityDecision?: CentralCompatibilityDecisionRecorder, cancellationRequested?: () => boolean): Promise<boolean>;
|
|
85
|
+
/**
|
|
86
|
+
* Run one finite CouchDB transfer and close its owned remote connection.
|
|
87
|
+
*
|
|
88
|
+
* The caller which enters the shared task owns Security Seed preparation,
|
|
89
|
+
* transfer, and any retry or resurrection continuation. A joining caller
|
|
90
|
+
* waits for the shared step only so it cannot race the owner, then receives
|
|
91
|
+
* the internal non-admission result without running that continuation.
|
|
92
|
+
*
|
|
93
|
+
* Continuous catch-up supplies `cancellationRequested` so a stop observed
|
|
94
|
+
* during awaited preparation cannot proceed to a later connection or
|
|
95
|
+
* controller. The admitted owner retains the established transfer behaviour.
|
|
96
|
+
*/
|
|
97
|
+
private runOneShotReplication;
|
|
56
98
|
private checkOneShotReplicationConnectivity;
|
|
57
99
|
private closeRemoteConnection;
|
|
58
100
|
private withRemoteConnection;
|
|
59
101
|
replicateAllToServer(setting: RemoteDBSettings, showingNotice?: boolean): Promise<boolean>;
|
|
102
|
+
replicateAllToServerWithOutcome(setting: RemoteDBSettings, showingNotice?: boolean): Promise<ReplicationOutcome>;
|
|
60
103
|
replicateAllFromServer(setting: RemoteDBSettings, showingNotice?: boolean): Promise<boolean>;
|
|
104
|
+
replicateAllFromServerWithOutcome(setting: RemoteDBSettings, showingNotice?: boolean): Promise<ReplicationOutcome>;
|
|
61
105
|
private reportConnectivityPreflightTimeout;
|
|
62
|
-
checkReplicationConnectivity(setting: RemoteDBSettings, keepAlive: boolean, skipCheck: boolean, showResult: boolean, ignoreCleanLock?: boolean, connectionOptions?: RemoteConnectionOpenOptions): Promise<false | CouchDBReplicationConnection>;
|
|
106
|
+
checkReplicationConnectivity(setting: RemoteDBSettings, keepAlive: boolean, skipCheck: boolean, showResult: boolean, ignoreCleanLock?: boolean, connectionOptions?: RemoteConnectionOpenOptions, recordCompatibilityDecision?: CentralCompatibilityDecisionRecorder): Promise<false | CouchDBReplicationConnection>;
|
|
63
107
|
openContinuousReplication(setting: RemoteDBSettings, showResult: boolean, retrying: boolean): Promise<boolean>;
|
|
64
|
-
|
|
108
|
+
private clearContinuousTask;
|
|
109
|
+
private runContinuousReplication;
|
|
110
|
+
closeReplication(): Promise<void>;
|
|
65
111
|
tryResetRemoteDatabase(setting: RemoteDBSettings): Promise<void>;
|
|
66
112
|
tryCreateRemoteDatabase(setting: RemoteDBSettings): Promise<void>;
|
|
67
113
|
markRemoteLocked(setting: RemoteDBSettings, locked: boolean, lockByClean: boolean): Promise<void>;
|
|
68
114
|
markRemoteResolved(setting: RemoteDBSettings): Promise<void>;
|
|
69
|
-
connectRemoteCouchDBWithSetting(settings: RemoteDBSettings, isMobile: boolean, performSetup?: boolean, skipInfo?: boolean, connectionOptions?: RemoteConnectionOpenOptions): Promise<string | OwnedCouchDBConnection<EntryDoc
|
|
115
|
+
connectRemoteCouchDBWithSetting(settings: RemoteDBSettings, isMobile: boolean, performSetup?: boolean, skipInfo?: boolean, connectionOptions?: RemoteConnectionOpenOptions): Promise<string | OwnedCouchDBConnection<EntryDoc>>;
|
|
70
116
|
private openOwnedConnection;
|
|
71
117
|
/**
|
|
72
118
|
* Opens a raw PouchDB handle for compatibility with earlier Commonlib
|
|
@@ -94,7 +140,7 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
|
|
94
140
|
* @throws {Error} If the document could not be put.
|
|
95
141
|
*/
|
|
96
142
|
putRemoteDocument<T extends DatabaseEntry>(settings: RemoteDBSettings, doc: T, db?: PouchDB.Database<T>): Promise<PouchDB.Core.Response>;
|
|
97
|
-
fetchRemoteChunks(missingChunks: string[], showResult: boolean): Promise<false | EntryLeaf[]>;
|
|
143
|
+
fetchRemoteChunks(missingChunks: string[], showResult: boolean, setting?: RemoteDBSettings): Promise<false | EntryLeaf[]>;
|
|
98
144
|
tryConnectRemote(setting: RemoteDBSettings, showResult?: boolean): Promise<boolean>;
|
|
99
145
|
resetRemoteTweakSettings(setting: RemoteDBSettings): Promise<void>;
|
|
100
146
|
setPreferredRemoteTweakSettings(setting: RemoteDBSettings): Promise<void>;
|