@vrtmrz/livesync-commonlib 0.3.1 → 0.3.2
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 +12 -2
- package/dist/replication/SyncParamsHandler.d.ts +1 -0
- package/dist/replication/SyncParamsHandler.js +5 -1
- package/dist/replication/journal/JournalReceiveFailure.d.ts +7 -0
- package/dist/replication/journal/JournalReceiveFailure.js +16 -0
- package/dist/replication/journal/JournalSyncCore.d.ts +22 -3
- package/dist/replication/journal/JournalSyncCore.js +288 -166
- package/dist/replication/journal/JournalSyncTypes.d.ts +13 -0
- package/dist/replication/journal/LiveSyncJournalReplicator.d.ts +6 -1
- package/dist/replication/journal/LiveSyncJournalReplicator.js +31 -44
- package/dist/replication/journal/journalCompatibility.d.ts +9 -0
- package/dist/replication/journal/journalCompatibility.js +58 -0
- package/dist/replication/journal/journalReceive.d.ts +23 -0
- package/dist/replication/journal/journalReceive.js +44 -0
- package/dist/replication/journal/journalRecords.d.ts +10 -0
- package/dist/replication/journal/journalRecords.js +96 -0
- package/docs/adr/2026_11_shared_storage_path_resolution.md +4 -2
- package/docs/design_docs/storage_path_resolution.md +8 -7
- package/docs/development.md +2 -2
- package/docs/journal-receive-recovery.md +66 -0
- package/docs/platform-storage.md +2 -2
- package/docs/unicode-path-identity.md +9 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ This package is primarily for maintainers of those clients and for integrations
|
|
|
14
14
|
|
|
15
15
|
## Status and versioning
|
|
16
16
|
|
|
17
|
-
Commonlib [0.3.
|
|
17
|
+
Commonlib [0.3.1](https://www.npmjs.com/package/@vrtmrz/livesync-commonlib/v/0.3.1)
|
|
18
18
|
is published on npm. Self-hosted LiveSync
|
|
19
19
|
[1.0.44](https://github.com/vrtmrz/obsidian-livesync/releases/tag/1.0.44)
|
|
20
20
|
uses Commonlib 0.2.3. The [0.2.3 release notes](updates.md#023) record its
|
|
@@ -45,6 +45,16 @@ while retaining conditional revalidation within a Seed. See
|
|
|
45
45
|
[CouchDB response caching](docs/couchdb-http-cache.md) for the request,
|
|
46
46
|
replication-preparation, and host-adapter boundaries.
|
|
47
47
|
|
|
48
|
+
Journal receipt stops at a per-Journal decode, record, or write failure and
|
|
49
|
+
retries that Journal on the next receive attempt. A host can offer the explicit
|
|
50
|
+
'Skip stopped Journal and resume' operation for the current stopped failure;
|
|
51
|
+
it skips only that Journal, and a later failure stops receipt again. A skip can
|
|
52
|
+
leave content or history incomplete. Use the existing Reset journal received
|
|
53
|
+
history operation to replay entries after correcting the failure, while the
|
|
54
|
+
remote objects remain available and readable. See the
|
|
55
|
+
[Journal receive failures and recovery](docs/journal-receive-recovery.md) for
|
|
56
|
+
the receive, skip, and replay boundaries.
|
|
57
|
+
|
|
48
58
|
## Package entry points
|
|
49
59
|
|
|
50
60
|
| Entry point | Intended use | Current contract status |
|
|
@@ -315,7 +325,7 @@ Commonlib 0.3.0 provides [Unicode NFC path identity](docs/unicode-path-identity.
|
|
|
315
325
|
|
|
316
326
|
## Direct database watches
|
|
317
327
|
|
|
318
|
-
|
|
328
|
+
Commonlib 0.3.1 lets direct CouchDB integrations select
|
|
319
329
|
`pathNormalizationVersion: 1` in `DirectFileManipulator` options. Omitted or
|
|
320
330
|
`0` retains Legacy identity. The configured mode must match the database;
|
|
321
331
|
NFC does not relabel a populated Legacy database. A confirmed empty database
|
|
@@ -32,6 +32,7 @@ export declare class SyncParamsNotFoundError extends SyncParamsHandlerError {
|
|
|
32
32
|
}
|
|
33
33
|
export declare class SyncParamsUpdateError extends SyncParamsHandlerError {
|
|
34
34
|
}
|
|
35
|
+
export declare function isSyncParamsError(error: unknown): error is SyncParamsFetchError | SyncParamsNotFoundError | SyncParamsUpdateError;
|
|
35
36
|
/** Create a handler owned by one operation rather than the process-wide server cache. */
|
|
36
37
|
export declare function createSyncParamsHandler({ put, get, create }: CreateSyncParamsHanderOptions): SyncParamsHandler;
|
|
37
38
|
export {};
|
|
@@ -22,6 +22,9 @@ class SyncParamsNotFoundError extends SyncParamsHandlerError {
|
|
|
22
22
|
}
|
|
23
23
|
class SyncParamsUpdateError extends SyncParamsHandlerError {
|
|
24
24
|
}
|
|
25
|
+
function isSyncParamsError(error) {
|
|
26
|
+
return error instanceof SyncParamsFetchError || error instanceof SyncParamsNotFoundError || error instanceof SyncParamsUpdateError;
|
|
27
|
+
}
|
|
25
28
|
function createSyncParamsHandler({ put, get, create }) {
|
|
26
29
|
let taskFetchParameters = void 0;
|
|
27
30
|
const _fetchSyncParameters = async () => {
|
|
@@ -115,5 +118,6 @@ export {
|
|
|
115
118
|
SyncParamsUpdateError,
|
|
116
119
|
clearHandlers,
|
|
117
120
|
createSyncParamsHanderForServer,
|
|
118
|
-
createSyncParamsHandler
|
|
121
|
+
createSyncParamsHandler,
|
|
122
|
+
isSyncParamsError
|
|
119
123
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JournalReceiveFailureStage } from "./JournalSyncTypes.js";
|
|
2
|
+
export declare class JournalReceiveFailure extends Error {
|
|
3
|
+
readonly stage: JournalReceiveFailureStage;
|
|
4
|
+
readonly key?: string;
|
|
5
|
+
constructor(stage: JournalReceiveFailureStage, key?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare function isJournalReceiveFailure(error: unknown): error is JournalReceiveFailure;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class JournalReceiveFailure extends Error {
|
|
2
|
+
constructor(stage, key) {
|
|
3
|
+
super("Journal receive failed at " + stage);
|
|
4
|
+
this.stage = stage;
|
|
5
|
+
this.key = key;
|
|
6
|
+
}
|
|
7
|
+
stage;
|
|
8
|
+
key;
|
|
9
|
+
}
|
|
10
|
+
function isJournalReceiveFailure(error) {
|
|
11
|
+
return error instanceof JournalReceiveFailure;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
JournalReceiveFailure,
|
|
15
|
+
isJournalReceiveFailure
|
|
16
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type EntryDoc, type SyncParameters, type BucketSyncSetting, type RemoteDBSettings } from "../../common/types.js";
|
|
2
2
|
import type { ReplicationCallback, ReplicationStat } from "../LiveSyncAbstractReplicator.js";
|
|
3
3
|
import { type SimpleStore } from "../../common/utils.js";
|
|
4
|
-
import { type CheckPointInfo } from "./JournalSyncTypes.js";
|
|
4
|
+
import { type CheckPointInfo, type StoppedJournal } from "./JournalSyncTypes.js";
|
|
5
5
|
import type { LiveSyncJournalReplicatorEnv } from "./LiveSyncJournalReplicatorEnv.js";
|
|
6
6
|
import { type IJournalStorage, type JournalStorageConditionalWriteResult, type JournalStorageReadResult } from "./objectstore/JournalStorageAdapter.js";
|
|
7
|
-
type ProcessingEntry
|
|
7
|
+
import { type ProcessingEntry } from "./journalRecords.js";
|
|
8
8
|
export declare class JournalSyncCore {
|
|
9
9
|
_settings: BucketSyncSetting;
|
|
10
10
|
storage: IJournalStorage;
|
|
@@ -17,6 +17,19 @@ export declare class JournalSyncCore {
|
|
|
17
17
|
store: SimpleStore<CheckPointInfo>;
|
|
18
18
|
requestedStop: boolean;
|
|
19
19
|
private syncParamsHandler?;
|
|
20
|
+
private receiveTask?;
|
|
21
|
+
private stoppedJournal?;
|
|
22
|
+
private checkpointGeneration;
|
|
23
|
+
private receiveConfiguration;
|
|
24
|
+
private matchesStoppedContext;
|
|
25
|
+
/** Return the current failure for presentation before an explicit single-Journal skip. */
|
|
26
|
+
getStoppedJournal(): StoppedJournal | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Acknowledge only the exact failure presented to the user, then resume receipt.
|
|
29
|
+
* Stale snapshots, another active receive, and a later Stop request are rejected.
|
|
30
|
+
* Any subsequent Journal failure stops the resumed operation normally.
|
|
31
|
+
*/
|
|
32
|
+
skipStoppedJournalAndResume(stopped: StoppedJournal, showMessage?: boolean): Promise<boolean>;
|
|
20
33
|
getInitialSyncParameters(): Promise<SyncParameters>;
|
|
21
34
|
getSyncParameters(): Promise<SyncParameters>;
|
|
22
35
|
putSyncParameters(params: SyncParameters): Promise<boolean>;
|
|
@@ -65,13 +78,19 @@ export declare class JournalSyncCore {
|
|
|
65
78
|
hasRemoteJournals(): Promise<boolean>;
|
|
66
79
|
_getRemoteJournals(): Promise<string[]>;
|
|
67
80
|
processDocuments(allDocs: ProcessingEntry[]): Promise<boolean>;
|
|
81
|
+
private processDocumentsForReceive;
|
|
68
82
|
private _createReceiveReadableStream;
|
|
69
83
|
private _createReceiveTransformStream;
|
|
70
84
|
private _createReceiveWritableStream;
|
|
85
|
+
/** Receive until completion, a failure, or an explicit Stop request. */
|
|
71
86
|
receiveRemoteJournal(showMessage?: boolean): Promise<boolean>;
|
|
87
|
+
private startReceive;
|
|
88
|
+
private prepareStoppedJournalSkip;
|
|
89
|
+
private recordReceiveFailure;
|
|
90
|
+
private receiveJournalFiles;
|
|
91
|
+
private performReceive;
|
|
72
92
|
sync(showResult?: boolean): Promise<boolean>;
|
|
73
93
|
requestStop(): void;
|
|
74
94
|
/** Stop this Journal operation owner and release its storage transport. */
|
|
75
95
|
dispose(): void;
|
|
76
96
|
}
|
|
77
|
-
export {};
|