@vrtmrz/livesync-commonlib 0.4.3 → 0.6.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.
Files changed (130) hide show
  1. package/README.md +2 -2
  2. package/dist/common/LSError.d.ts +13 -0
  3. package/dist/common/LSError.js +19 -1
  4. package/dist/diagnostics/local.d.ts +7 -2
  5. package/dist/interfaces/DatabaseFileAccess.d.ts +20 -4
  6. package/dist/interfaces/FileHandler.d.ts +67 -1
  7. package/dist/interfaces/FileHandler.js +16 -0
  8. package/dist/interfaces/StorageAccess.d.ts +8 -2
  9. package/dist/interfaces/StorageEventManager.d.ts +7 -0
  10. package/dist/managers/ChunkFetcher.d.ts +16 -0
  11. package/dist/managers/ChunkFetcher.js +190 -112
  12. package/dist/managers/EntryManager/EntryManager.d.ts +7 -0
  13. package/dist/managers/EntryManager/EntryManager.js +6 -0
  14. package/dist/managers/EntryManager/EntryManagerImpls.d.ts +9 -5
  15. package/dist/managers/EntryManager/EntryManagerImpls.js +103 -76
  16. package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.d.ts +7 -3
  17. package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.js +83 -16
  18. package/dist/managers/LayeredChunkManager/DatabaseReadLayer.d.ts +3 -2
  19. package/dist/managers/LayeredChunkManager/DatabaseReadLayer.js +38 -36
  20. package/dist/managers/LayeredChunkManager/types.d.ts +15 -1
  21. package/dist/managers/LayeredChunkManager.d.ts +4 -0
  22. package/dist/managers/LayeredChunkManager.js +19 -6
  23. package/dist/managers/LiveSyncManagers.d.ts +2 -0
  24. package/dist/managers/LiveSyncManagers.js +6 -0
  25. package/dist/managers/StorageEventManager.d.ts +22 -0
  26. package/dist/managers/StorageEventManager.js +48 -1
  27. package/dist/platform/FilePathIndex.d.ts +110 -0
  28. package/dist/platform/FilePathIndex.js +146 -0
  29. package/dist/pouchdb/LiveSyncLocalDB.d.ts +32 -0
  30. package/dist/pouchdb/LiveSyncLocalDB.js +72 -18
  31. package/dist/pouchdb/LocalDatabaseReadScope.d.ts +24 -0
  32. package/dist/pouchdb/LocalDatabaseReadScope.js +62 -0
  33. package/dist/pouchdb/pathIdentityCompatibility.d.ts +6 -2
  34. package/dist/pouchdb/pathIdentityCompatibility.js +15 -10
  35. package/dist/replication/contentRead.d.ts +3 -0
  36. package/dist/replication/contentRead.js +4 -0
  37. package/dist/replication/couchdb/LiveSyncReplicator.d.ts +8 -1
  38. package/dist/replication/couchdb/LiveSyncReplicator.js +187 -119
  39. package/dist/replication/index.d.ts +5 -1
  40. package/dist/replication/index.js +18 -1
  41. package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +3 -3
  42. package/dist/replication/trystero/P2PAutomationCoordinator.d.ts +1 -1
  43. package/dist/replication/trystero/P2PReplicationWire.d.ts +1 -1
  44. package/dist/replication/trystero/TrysteroReplicator/changeRelay.d.ts +133 -0
  45. package/dist/replication/trystero/TrysteroReplicator/changeRelay.js +176 -0
  46. package/dist/replication/trystero/TrysteroReplicator/configurationExchange.d.ts +55 -0
  47. package/dist/replication/trystero/TrysteroReplicator/configurationExchange.js +99 -0
  48. package/dist/replication/trystero/TrysteroReplicator/configuredTargets.d.ts +83 -0
  49. package/dist/replication/trystero/TrysteroReplicator/configuredTargets.js +121 -0
  50. package/dist/replication/trystero/TrysteroReplicator/peerAgreement.d.ts +75 -0
  51. package/dist/replication/trystero/TrysteroReplicator/peerAgreement.js +131 -0
  52. package/dist/replication/trystero/TrysteroReplicator/progress.d.ts +57 -0
  53. package/dist/replication/trystero/TrysteroReplicator/progress.js +84 -0
  54. package/dist/replication/trystero/TrysteroReplicator/relayControl.d.ts +20 -0
  55. package/dist/replication/trystero/TrysteroReplicator/relayControl.js +25 -0
  56. package/dist/replication/trystero/TrysteroReplicator/transfers.d.ts +125 -0
  57. package/dist/replication/trystero/TrysteroReplicator/transfers.js +278 -0
  58. package/dist/replication/trystero/TrysteroReplicator.d.ts +65 -483
  59. package/dist/replication/trystero/TrysteroReplicator.js +240 -673
  60. package/dist/replication/trystero/TrysteroReplicatorP2PClient.d.ts +19 -6
  61. package/dist/replication/trystero/TrysteroReplicatorP2PClient.js +29 -25
  62. package/dist/replication/trystero/TrysteroReplicatorP2PServer/peerAdmission.d.ts +66 -0
  63. package/dist/replication/trystero/TrysteroReplicatorP2PServer/peerAdmission.js +142 -0
  64. package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +19 -16
  65. package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +33 -93
  66. package/dist/replication/trystero/p2pReplicationDiagnostics.d.ts +1 -1
  67. package/dist/replication/trystero/p2pReplicationProgress.d.ts +2 -11
  68. package/dist/replication/trystero/replicationTypes.d.ts +88 -0
  69. package/dist/replication/trystero/replicationTypes.js +0 -0
  70. package/dist/replication/trystero/rpcSessionProvider.d.ts +13 -0
  71. package/dist/replication/trystero/rpcSessionProvider.js +0 -0
  72. package/dist/rpc/RpcRoom/pendingInvocations.d.ts +141 -0
  73. package/dist/rpc/RpcRoom/pendingInvocations.js +225 -0
  74. package/dist/rpc/RpcRoom.d.ts +9 -4
  75. package/dist/rpc/RpcRoom.js +73 -118
  76. package/dist/rpc/RpcSession.d.ts +6 -0
  77. package/dist/rpc/RpcSession.js +11 -0
  78. package/dist/rpc/types.d.ts +2 -0
  79. package/dist/serviceFeatures/offlineScanner/files.d.ts +1 -1
  80. package/dist/serviceFeatures/offlineScanner/files.js +27 -7
  81. package/dist/serviceFeatures/offlineScanner/scan.d.ts +5 -1
  82. package/dist/serviceFeatures/offlineScanner/scan.js +2 -1
  83. package/dist/serviceFeatures/offlineScanner.d.ts +1 -1
  84. package/dist/serviceFeatures/offlineScanner.js +10 -2
  85. package/dist/serviceFeatures/targetFilter.d.ts +1 -1
  86. package/dist/serviceFeatures/targetFilter.js +8 -38
  87. package/dist/serviceModules/FileAccessBase.d.ts +4 -0
  88. package/dist/serviceModules/FileAccessBase.js +10 -0
  89. package/dist/serviceModules/Rebuilder.js +1 -1
  90. package/dist/serviceModules/ServiceDatabaseFileAccessBase.d.ts +13 -0
  91. package/dist/serviceModules/ServiceDatabaseFileAccessBase.js +190 -123
  92. package/dist/serviceModules/ServiceFileAccessBase/fileNames.d.ts +54 -0
  93. package/dist/serviceModules/ServiceFileAccessBase/fileNames.js +57 -0
  94. package/dist/serviceModules/ServiceFileAccessBase.d.ts +5 -1
  95. package/dist/serviceModules/ServiceFileAccessBase.js +18 -3
  96. package/dist/serviceModules/ServiceFileHandlerBase/deletion.js +17 -7
  97. package/dist/serviceModules/ServiceFileHandlerBase/events.d.ts +3 -2
  98. package/dist/serviceModules/ServiceFileHandlerBase/events.js +9 -9
  99. package/dist/serviceModules/ServiceFileHandlerBase/protection.js +24 -9
  100. package/dist/serviceModules/ServiceFileHandlerBase/provenance.d.ts +10 -0
  101. package/dist/serviceModules/ServiceFileHandlerBase/provenance.js +28 -4
  102. package/dist/serviceModules/ServiceFileHandlerBase/reflection.d.ts +11 -5
  103. package/dist/serviceModules/ServiceFileHandlerBase/reflection.js +144 -58
  104. package/dist/serviceModules/ServiceFileHandlerBase/saving.js +16 -2
  105. package/dist/serviceModules/ServiceFileHandlerBase/scanning.js +1 -0
  106. package/dist/serviceModules/ServiceFileHandlerBase.d.ts +7 -2
  107. package/dist/serviceModules/ServiceFileHandlerBase.js +13 -4
  108. package/dist/serviceModules/adapters/IFileSystemAdapter.d.ts +3 -0
  109. package/dist/services/base/ControlService.js +1 -5
  110. package/dist/services/base/DatabaseEventService.d.ts +3 -0
  111. package/dist/services/base/DatabaseEventService.js +3 -0
  112. package/dist/services/base/DatabaseService.d.ts +15 -0
  113. package/dist/services/base/DatabaseService.js +85 -4
  114. package/dist/services/base/IService.d.ts +18 -1
  115. package/dist/services/base/KeyValueDBService.d.ts +5 -4
  116. package/dist/services/base/KeyValueDBService.js +46 -48
  117. package/dist/services/base/ReplicationService.d.ts +3 -1
  118. package/dist/services/base/ReplicationService.js +3 -1
  119. package/dist/services/base/VaultScanResult.d.ts +5 -0
  120. package/dist/services/lib/HandlerUtils.d.ts +40 -5
  121. package/dist/services/lib/HandlerUtils.js +52 -4
  122. package/dist/storage.d.ts +2 -0
  123. package/dist/storage.js +2 -0
  124. package/docs/development.md +111 -0
  125. package/docs/offline-scanner.md +46 -0
  126. package/docs/p2p-transport-lifecycle.md +24 -0
  127. package/docs/platform-storage.md +22 -0
  128. package/docs/releasing.md +48 -0
  129. package/docs/settings-lifecycle.md +4 -2
  130. package/package.json +1 -1
package/README.md CHANGED
@@ -14,9 +14,9 @@ This package is primarily for maintainers of those clients and for integrations
14
14
 
15
15
  ## Status and versioning
16
16
 
17
- Commonlib [0.4.2](https://www.npmjs.com/package/@vrtmrz/livesync-commonlib/v/0.4.2)
17
+ Commonlib [0.4.3](https://www.npmjs.com/package/@vrtmrz/livesync-commonlib/v/0.4.3)
18
18
  is published on npm through `latest` and `next`
19
- ([release notes](https://github.com/vrtmrz/livesync-commonlib/releases/tag/0.4.2)).
19
+ ([release notes](https://github.com/vrtmrz/livesync-commonlib/releases/tag/0.4.3)).
20
20
 
21
21
  Self-hosted LiveSync
22
22
  [1.0.44](https://github.com/vrtmrz/obsidian-livesync/releases/tag/1.0.44)
@@ -45,4 +45,17 @@ export declare class LiveSyncError extends Error implements ErrorWithCause {
45
45
  }
46
46
  export declare class LiveSyncFatalError extends LiveSyncError {
47
47
  }
48
+ /** A request failed at a known remote boundary, retaining its native unknown cause. */
49
+ export declare class RemoteRequestError extends Error {
50
+ name: string;
51
+ constructor(message?: string, options?: {
52
+ cause?: unknown;
53
+ });
54
+ }
55
+ /** Terminal content failure, carrying only directly observed resource facts. */
56
+ export declare class ContentReadError extends Error {
57
+ readonly failure: import("../interfaces/DatabaseFileAccess.js").ContentReadFailure;
58
+ readonly name = "ContentReadError";
59
+ constructor(failure: import("../interfaces/DatabaseFileAccess.js").ContentReadFailure);
60
+ }
48
61
  export {};
@@ -106,7 +106,25 @@ class LiveSyncError extends Error {
106
106
  }
107
107
  class LiveSyncFatalError extends LiveSyncError {
108
108
  }
109
+ class RemoteRequestError extends Error {
110
+ name = "RemoteRequestError";
111
+ constructor(message, options) {
112
+ super(message, options);
113
+ }
114
+ }
115
+ class ContentReadError extends Error {
116
+ constructor(failure) {
117
+ super(`Could not read content for ${failure.documentId}${failure.revision ? ` (${failure.revision})` : ""}`, {
118
+ cause: failure.cause
119
+ });
120
+ this.failure = failure;
121
+ }
122
+ failure;
123
+ name = "ContentReadError";
124
+ }
109
125
  export {
126
+ ContentReadError,
110
127
  LiveSyncError,
111
- LiveSyncFatalError
128
+ LiveSyncFatalError,
129
+ RemoteRequestError
112
130
  };
@@ -1,4 +1,9 @@
1
1
  import type { EntryDoc } from "../common/types.js";
2
2
  import type { DiagnosticDatabaseSource } from "./types.js";
3
- /** Wrap an existing local handle without taking ownership or using chunk caches. */
4
- export declare function createLocalDiagnosticSource(database: Pick<PouchDB.Database<EntryDoc>, "info" | "allDocs" | "get">): DiagnosticDatabaseSource;
3
+ /** Promise reads used by local diagnostics; a host can supply its owned read boundary. */
4
+ type LocalDiagnosticDatabase = Pick<DiagnosticDatabaseSource, "info" | "get"> & {
5
+ allDocs(options: PouchDB.Core.AllDocsOptions & Partial<Pick<PouchDB.Core.AllDocsWithinRangeOptions, "startkey">>): Promise<PouchDB.Core.AllDocsResponse<EntryDoc>>;
6
+ };
7
+ /** Wrap local Promise reads without taking ownership or using chunk caches. */
8
+ export declare function createLocalDiagnosticSource(database: LocalDiagnosticDatabase): DiagnosticDatabaseSource;
9
+ export {};
@@ -1,5 +1,21 @@
1
- import type { FilePathWithPrefix, LoadedEntry, MetaEntry, UXFileInfo, UXFileInfoStub } from "../common/types.js";
1
+ import type { DocumentID, FilePathWithPrefix, LoadedEntry, MetaEntry, UXFileInfo, UXFileInfoStub } from "../common/types.js";
2
+ export type ContentReadResource = "local-database" | "remote";
3
+ /** Known recovery dependencies; unresolved or invalid content has no automatic retry dependency. */
4
+ export interface ContentReadFailure {
5
+ documentId: DocumentID;
6
+ revision?: string;
7
+ /** Every listed dependency must recover; an empty list requires manual review. */
8
+ resources: readonly ContentReadResource[];
9
+ /** Original runtime diagnostics, which must not be persisted or inspected to choose recovery. */
10
+ cause: unknown;
11
+ }
2
12
  export interface DatabaseFileAccess {
13
+ /** Strict reads preserve ordinary absence but reject failed I/O or incomplete content. */
14
+ readEntryMeta: DatabaseFileAccess["fetchEntryMeta"];
15
+ readEntryFromMeta: DatabaseFileAccess["fetchEntryFromMeta"];
16
+ readEntry: DatabaseFileAccess["fetchEntry"];
17
+ readConflictedRevs: DatabaseFileAccess["getConflictedRevs"];
18
+ readLiveContentRevisions: DatabaseFileAccess["findLiveContentRevisions"];
3
19
  delete: (file: UXFileInfoStub | FilePathWithPrefix, rev?: string) => Promise<boolean>;
4
20
  store: (file: UXFileInfo, force?: boolean, skipCheck?: boolean) => Promise<boolean>;
5
21
  /**
@@ -43,12 +59,12 @@ export interface DatabaseFileAccess {
43
59
  * available Chunks, without requesting remote data or waiting for missing Chunks to arrive.
44
60
  *
45
61
  * A unique match can recover provenance; several matches avoid a duplicate write but leave
46
- * its origin ambiguous. An empty result means no match was confirmed, including when data
47
- * could not be read. This read neither records provenance nor reserves a leaf for a later write.
62
+ * its origin ambiguous. An empty result means no match was confirmed. The strict read rejects
63
+ * failed I/O; this compatibility facade returns no matches on failure. This read neither records provenance nor reserves a leaf for a later write.
48
64
  */
49
65
  findLiveContentRevisions: (file: UXFileInfoStub | FilePathWithPrefix, content: string | string[] | Blob | ArrayBuffer) => Promise<string[]>;
50
66
  fetch: (file: UXFileInfoStub | FilePathWithPrefix, rev?: string, waitForReady?: boolean, skipCheck?: boolean) => Promise<UXFileInfo | false>;
51
- fetchEntryFromMeta: (meta: MetaEntry, waitForReady?: boolean, skipCheck?: boolean) => Promise<LoadedEntry | false>;
67
+ fetchEntryFromMeta: (meta: MetaEntry, waitForReady?: boolean, skipCheck?: boolean, localOnly?: boolean) => Promise<LoadedEntry | false>;
52
68
  fetchEntryMeta: (file: UXFileInfoStub | FilePathWithPrefix, rev?: string, skipCheck?: boolean) => Promise<MetaEntry | false>;
53
69
  /**
54
70
  * Load a revision's content, or return `false` when it cannot be loaded.
@@ -1,4 +1,4 @@
1
- import type { FilePath, FilePathWithPrefix, MetaEntry } from "../common/models/db.type.js";
1
+ import type { DocumentID, FilePath, FilePathWithPrefix, MetaEntry } from "../common/models/db.type.js";
2
2
  import type { UXFileInfo, UXFileInfoStub, UXInternalFileInfoStub } from "../common/models/fileaccess.type.js";
3
3
  export interface StoreFileOptions {
4
4
  /** Recheck storage and provenance, with bounded retries for recovery scans. */
@@ -43,7 +43,71 @@ export interface DeletionRecoveryClearedResult extends DeletionRecoveryDiagnosti
43
43
  * file may require user reconciliation; automatic convergence is not guaranteed.
44
44
  */
45
45
  export type DeletionRecoveryResult = DeletionRecoveryUnchangedResult | DeletionRecoveryCleanupPendingResult | DeletionRecoveryRemovalUnconfirmedResult | DeletionRecoveryClearedResult;
46
+ export interface ReflectionTarget {
47
+ documentId: DocumentID;
48
+ revision: string;
49
+ }
50
+ /** Premises supplied by the target owner; no failure state is retained here. */
51
+ export interface ReflectionOperationContext {
52
+ readonly target: ReflectionTarget;
53
+ readonly source: "scan" | "received";
54
+ /** The owner may return false or throw its own scope-cancellation value. */
55
+ readonly checkpoint?: () => boolean | void;
56
+ }
57
+ /**
58
+ * A normal outcome of one file reflection attempt; terminal failures reject.
59
+ *
60
+ * @remarks Only `completed` permits completion bookkeeping. `policy` is an
61
+ * intentional skip under the applicable reflection policy, and `cancelled`
62
+ * means the target owner declined continuation at a checkpoint. Neither outcome
63
+ * establishes completed reflection or grants an automatic retry.
64
+ */
65
+ export type FileReflectionResult = Readonly<{
66
+ status: "completed" | "policy" | "cancelled";
67
+ }>;
68
+ /**
69
+ * Reflection completed, including an already-matching file or an already-absent deletion.
70
+ * @remarks Callers may perform completion bookkeeping; a new storage write is not required.
71
+ */
72
+ export declare const FILE_REFLECTION_COMPLETED: Readonly<{
73
+ status: "completed";
74
+ }>;
75
+ /**
76
+ * Applicable policy intentionally withheld ordinary file reflection.
77
+ *
78
+ * @remarks Examples include handing a conflict to its resolution workflow,
79
+ * preserving unsynchronised storage as a conflict, an existing folder at the
80
+ * target path, or a host which does not apply received files automatically.
81
+ * Protection or conflict scheduling may already have occurred. This is a
82
+ * normal policy decision, not a failed read or a promise of a later retry.
83
+ */
84
+ export declare const FILE_REFLECTION_POLICY: Readonly<{
85
+ status: "policy";
86
+ }>;
87
+ /**
88
+ * The target owner's checkpoint declined continuation of this reflection attempt.
89
+ * @remarks This does not convert unrelated I/O failures into cancellation or roll back earlier work.
90
+ */
91
+ export declare const FILE_REFLECTION_CANCELLED: Readonly<{
92
+ status: "cancelled";
93
+ }>;
94
+ /**
95
+ * Test whether reflection permits the caller's completion bookkeeping.
96
+ * @param result - The normal outcome returned by the reflection operation.
97
+ * @returns True only for `completed`, including completion without a new write.
98
+ */
99
+ export declare function isReflectionCompleted(result: FileReflectionResult): boolean;
100
+ /**
101
+ * Test whether the target owner declined continuation at a checkpoint.
102
+ * @param result - The normal outcome returned by the reflection operation.
103
+ * @returns True only for `cancelled`; false can also mean a normal policy skip.
104
+ * @remarks Legacy Boolean facades can preserve cancellation with this predicate.
105
+ * Callers which require completed reflection must use {@link isReflectionCompleted}.
106
+ */
107
+ export declare function isReflectionCancelled(result: FileReflectionResult): boolean;
46
108
  export interface IFileHandler {
109
+ /** Strict reflection; failures reject to the target owner. */
110
+ reflectDatabaseEntry(entry: MetaEntry, info: UXFileInfoStub | UXFileInfo | FilePath | null, force?: boolean, operation?: ReflectionOperationContext): Promise<FileReflectionResult>;
47
111
  readFileFromStub(file: UXFileInfoStub | UXFileInfo): Promise<UXFileInfo>;
48
112
  /**
49
113
  * Record an untracked, unchanged file during an equal-time scan.
@@ -53,6 +117,8 @@ export interface IFileHandler {
53
117
  tryRecordUntrackedFileRevision(info: UXFileInfoStub | UXFileInfo, expectedRevision: string): Promise<boolean>;
54
118
  /** Metadata-only scan hint; never certifies content equality or changes provenance. */
55
119
  canSkipUnchangedFile?(info: UXFileInfoStub, expected: MetaEntry): Promise<boolean>;
120
+ /** Confirm current bytes and recorded revision without a remote content read. */
121
+ inspectCurrentFileProvenance?(path: FilePathWithPrefix, revision: string): Promise<boolean>;
56
122
  /**
57
123
  * Report whether complete provenance-key discovery is configured.
58
124
  * @returns A composition capability, rather than a store-readiness or health check.
@@ -0,0 +1,16 @@
1
+ const FILE_REFLECTION_COMPLETED = Object.freeze({ status: "completed" });
2
+ const FILE_REFLECTION_POLICY = Object.freeze({ status: "policy" });
3
+ const FILE_REFLECTION_CANCELLED = Object.freeze({ status: "cancelled" });
4
+ function isReflectionCompleted(result) {
5
+ return result.status === "completed";
6
+ }
7
+ function isReflectionCancelled(result) {
8
+ return result.status === "cancelled";
9
+ }
10
+ export {
11
+ FILE_REFLECTION_CANCELLED,
12
+ FILE_REFLECTION_COMPLETED,
13
+ FILE_REFLECTION_POLICY,
14
+ isReflectionCancelled,
15
+ isReflectionCompleted
16
+ };
@@ -1,6 +1,7 @@
1
1
  import type { FilePath, FilePathWithPrefix, UXDataWriteOptions, UXFileInfo, UXFileInfoStub, UXFolderInfo, UXStat } from "../common/types.js";
2
2
  import type { CustomRegExp } from "../common/utils.js";
3
3
  import type { FileWithFileStat, FileWithStatAsProp } from "../common/models/fileaccess.type.js";
4
+ import type { FileNameLookup } from "../platform/FilePathIndex.js";
4
5
  export interface IStorageAccessManager {
5
6
  processWriteFile<T>(file: UXFileInfoStub | FilePathWithPrefix, proc: () => Promise<T>): Promise<T>;
6
7
  processReadFile<T>(file: UXFileInfoStub | FilePathWithPrefix, proc: () => Promise<T>): Promise<T>;
@@ -9,7 +10,13 @@ export interface IStorageAccessManager {
9
10
  touch(file: FileWithStatAsProp | FileWithFileStat): void;
10
11
  clearTouched(): void;
11
12
  }
12
- export interface StorageAccess {
13
+ /**
14
+ * Storage facade with the shared name-query contract available on every host.
15
+ *
16
+ * An adapter can omit its indexed lookup capability; the service facade supplies
17
+ * the base fallback while retaining the FileNameLookup method contract.
18
+ */
19
+ export interface StorageAccess extends FileNameLookup {
13
20
  normalisePath(path: string): string;
14
21
  restoreState(): Promise<void>;
15
22
  /** Includes queued, running, and failed work; absence requires a conservative content check. */
@@ -36,7 +43,6 @@ export interface StorageAccess {
36
43
  readStubContent(stub: UXFileInfoStub): Promise<UXFileInfo | false>;
37
44
  getStub(path: string): Promise<UXFileInfoStub | UXFolderInfo | null>;
38
45
  getFiles(): Promise<UXFileInfoStub[]>;
39
- getFileNames(): Promise<FilePathWithPrefix[]>;
40
46
  touched(file: UXFileInfoStub | FilePathWithPrefix): Promise<void>;
41
47
  recentlyTouched(file: UXFileInfoStub | FilePathWithPrefix): Promise<boolean>;
42
48
  clearTouched(): void;
@@ -14,6 +14,13 @@ export declare abstract class StorageEventManager {
14
14
  /** Compatibility hosts without an ownership view must retain content checks. */
15
15
  hasPendingFileEvent?(_filename: FilePath): boolean;
16
16
  abstract waitForIdle(): Promise<void>;
17
+ /**
18
+ * Pause new file-handler dispatch when the manager supports a reversible pause.
19
+ * @returns A promise fulfilled after processing active at the call settles; pending work is not awaited.
20
+ */
21
+ pauseDispatch?(): Promise<void>;
22
+ /** Resume file-handler dispatch after a supported pause. */
23
+ resumeDispatch?(): void;
17
24
  abstract restoreState(): Promise<void>;
18
25
  /**
19
26
  * Complete accepted work before its storage closes. Custom hosts must stop
@@ -1,11 +1,15 @@
1
1
  import { type DocumentID } from "../common/types.js";
2
2
  import { type ChunkManager } from "./ChunkManager.js";
3
3
  import type { ChunkFetchSource } from "./chunkFetchSource.js";
4
+ import type { LogFunction } from "../services/lib/logUtils.js";
4
5
  import type { IReplicatorService, ISettingService } from "../services/base/IService.js";
5
6
  export declare const EVENT_MISSING_CHUNKS = "missingChunks";
6
7
  export declare const EVENT_MISSING_CHUNK_REMOTE = "missingChunkRemote";
7
8
  export declare const EVENT_CHUNK_FETCHED = "chunkFetched";
9
+ export declare const EVENT_CHUNK_FAILED = "chunkFailed";
8
10
  export type ChunkFetcherOptions = {
11
+ /** Host-owned logger; standalone instances default to the global logger. */
12
+ log?: LogFunction;
9
13
  settingService: ISettingService;
10
14
  chunkManager: ChunkManager;
11
15
  replicatorService: IReplicatorService;
@@ -15,6 +19,7 @@ export type ChunkFetcherOptions = {
15
19
  };
16
20
  export declare class ChunkFetcher {
17
21
  options: ChunkFetcherOptions;
22
+ private readonly log;
18
23
  get chunkManager(): ChunkManager;
19
24
  queue: DocumentID[];
20
25
  private readonly pendingClaims;
@@ -44,6 +49,8 @@ export declare class ChunkFetcher {
44
49
  private touchClaims;
45
50
  private waitForActivityBoundary;
46
51
  private waitBeforeRemoteRequest;
52
+ /** Return the remaining delay, or reserve the request start synchronously. */
53
+ private reserveRequestInterval;
47
54
  private resolveLocallyAvailableRetries;
48
55
  private logFetchedChunks;
49
56
  private applyMissingChunkResults;
@@ -60,4 +67,13 @@ export declare class ChunkFetcher {
60
67
  canRequestMore(): boolean;
61
68
  private isReady;
62
69
  requestMissingChunks(): Promise<void>;
70
+ private admitRequestBatch;
71
+ private cleanupRequestBatch;
72
+ private fetchRemoteChunks;
73
+ private fetchWithRemoteError;
74
+ private acceptFetchedChunks;
75
+ private storeFetchedChunks;
76
+ private publishAcceptedChunks;
77
+ private publishUnsupportedReplicatorResult;
78
+ private publishRequestFailure;
63
79
  }