@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.
- package/README.md +2 -2
- package/dist/common/LSError.d.ts +13 -0
- package/dist/common/LSError.js +19 -1
- package/dist/diagnostics/local.d.ts +7 -2
- package/dist/interfaces/DatabaseFileAccess.d.ts +20 -4
- package/dist/interfaces/FileHandler.d.ts +67 -1
- package/dist/interfaces/FileHandler.js +16 -0
- package/dist/interfaces/StorageAccess.d.ts +8 -2
- package/dist/interfaces/StorageEventManager.d.ts +7 -0
- package/dist/managers/ChunkFetcher.d.ts +16 -0
- package/dist/managers/ChunkFetcher.js +190 -112
- package/dist/managers/EntryManager/EntryManager.d.ts +7 -0
- package/dist/managers/EntryManager/EntryManager.js +6 -0
- package/dist/managers/EntryManager/EntryManagerImpls.d.ts +9 -5
- package/dist/managers/EntryManager/EntryManagerImpls.js +103 -76
- package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.d.ts +7 -3
- package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.js +83 -16
- package/dist/managers/LayeredChunkManager/DatabaseReadLayer.d.ts +3 -2
- package/dist/managers/LayeredChunkManager/DatabaseReadLayer.js +38 -36
- package/dist/managers/LayeredChunkManager/types.d.ts +15 -1
- package/dist/managers/LayeredChunkManager.d.ts +4 -0
- package/dist/managers/LayeredChunkManager.js +19 -6
- package/dist/managers/LiveSyncManagers.d.ts +2 -0
- package/dist/managers/LiveSyncManagers.js +6 -0
- package/dist/managers/StorageEventManager.d.ts +22 -0
- package/dist/managers/StorageEventManager.js +48 -1
- package/dist/platform/FilePathIndex.d.ts +110 -0
- package/dist/platform/FilePathIndex.js +146 -0
- package/dist/pouchdb/LiveSyncLocalDB.d.ts +32 -0
- package/dist/pouchdb/LiveSyncLocalDB.js +72 -18
- package/dist/pouchdb/LocalDatabaseReadScope.d.ts +24 -0
- package/dist/pouchdb/LocalDatabaseReadScope.js +62 -0
- package/dist/pouchdb/pathIdentityCompatibility.d.ts +6 -2
- package/dist/pouchdb/pathIdentityCompatibility.js +15 -10
- package/dist/replication/contentRead.d.ts +3 -0
- package/dist/replication/contentRead.js +4 -0
- package/dist/replication/couchdb/LiveSyncReplicator.d.ts +8 -1
- package/dist/replication/couchdb/LiveSyncReplicator.js +187 -119
- package/dist/replication/index.d.ts +5 -1
- package/dist/replication/index.js +18 -1
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +3 -3
- package/dist/replication/trystero/P2PAutomationCoordinator.d.ts +1 -1
- package/dist/replication/trystero/P2PReplicationWire.d.ts +1 -1
- package/dist/replication/trystero/TrysteroReplicator/changeRelay.d.ts +133 -0
- package/dist/replication/trystero/TrysteroReplicator/changeRelay.js +176 -0
- package/dist/replication/trystero/TrysteroReplicator/configurationExchange.d.ts +55 -0
- package/dist/replication/trystero/TrysteroReplicator/configurationExchange.js +99 -0
- package/dist/replication/trystero/TrysteroReplicator/configuredTargets.d.ts +83 -0
- package/dist/replication/trystero/TrysteroReplicator/configuredTargets.js +121 -0
- package/dist/replication/trystero/TrysteroReplicator/peerAgreement.d.ts +75 -0
- package/dist/replication/trystero/TrysteroReplicator/peerAgreement.js +131 -0
- package/dist/replication/trystero/TrysteroReplicator/progress.d.ts +57 -0
- package/dist/replication/trystero/TrysteroReplicator/progress.js +84 -0
- package/dist/replication/trystero/TrysteroReplicator/relayControl.d.ts +20 -0
- package/dist/replication/trystero/TrysteroReplicator/relayControl.js +25 -0
- package/dist/replication/trystero/TrysteroReplicator/transfers.d.ts +125 -0
- package/dist/replication/trystero/TrysteroReplicator/transfers.js +278 -0
- package/dist/replication/trystero/TrysteroReplicator.d.ts +65 -483
- package/dist/replication/trystero/TrysteroReplicator.js +240 -673
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.d.ts +19 -6
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.js +29 -25
- package/dist/replication/trystero/TrysteroReplicatorP2PServer/peerAdmission.d.ts +66 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer/peerAdmission.js +142 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +19 -16
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +33 -93
- package/dist/replication/trystero/p2pReplicationDiagnostics.d.ts +1 -1
- package/dist/replication/trystero/p2pReplicationProgress.d.ts +2 -11
- package/dist/replication/trystero/replicationTypes.d.ts +88 -0
- package/dist/replication/trystero/replicationTypes.js +0 -0
- package/dist/replication/trystero/rpcSessionProvider.d.ts +13 -0
- package/dist/replication/trystero/rpcSessionProvider.js +0 -0
- package/dist/rpc/RpcRoom/pendingInvocations.d.ts +141 -0
- package/dist/rpc/RpcRoom/pendingInvocations.js +225 -0
- package/dist/rpc/RpcRoom.d.ts +9 -4
- package/dist/rpc/RpcRoom.js +73 -118
- package/dist/rpc/RpcSession.d.ts +6 -0
- package/dist/rpc/RpcSession.js +11 -0
- package/dist/rpc/types.d.ts +2 -0
- package/dist/serviceFeatures/offlineScanner/files.d.ts +1 -1
- package/dist/serviceFeatures/offlineScanner/files.js +27 -7
- package/dist/serviceFeatures/offlineScanner/scan.d.ts +5 -1
- package/dist/serviceFeatures/offlineScanner/scan.js +2 -1
- package/dist/serviceFeatures/offlineScanner.d.ts +1 -1
- package/dist/serviceFeatures/offlineScanner.js +10 -2
- package/dist/serviceFeatures/targetFilter.d.ts +1 -1
- package/dist/serviceFeatures/targetFilter.js +8 -38
- package/dist/serviceModules/FileAccessBase.d.ts +4 -0
- package/dist/serviceModules/FileAccessBase.js +10 -0
- package/dist/serviceModules/Rebuilder.js +1 -1
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.d.ts +13 -0
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.js +190 -123
- package/dist/serviceModules/ServiceFileAccessBase/fileNames.d.ts +54 -0
- package/dist/serviceModules/ServiceFileAccessBase/fileNames.js +57 -0
- package/dist/serviceModules/ServiceFileAccessBase.d.ts +5 -1
- package/dist/serviceModules/ServiceFileAccessBase.js +18 -3
- package/dist/serviceModules/ServiceFileHandlerBase/deletion.js +17 -7
- package/dist/serviceModules/ServiceFileHandlerBase/events.d.ts +3 -2
- package/dist/serviceModules/ServiceFileHandlerBase/events.js +9 -9
- package/dist/serviceModules/ServiceFileHandlerBase/protection.js +24 -9
- package/dist/serviceModules/ServiceFileHandlerBase/provenance.d.ts +10 -0
- package/dist/serviceModules/ServiceFileHandlerBase/provenance.js +28 -4
- package/dist/serviceModules/ServiceFileHandlerBase/reflection.d.ts +11 -5
- package/dist/serviceModules/ServiceFileHandlerBase/reflection.js +144 -58
- package/dist/serviceModules/ServiceFileHandlerBase/saving.js +16 -2
- package/dist/serviceModules/ServiceFileHandlerBase/scanning.js +1 -0
- package/dist/serviceModules/ServiceFileHandlerBase.d.ts +7 -2
- package/dist/serviceModules/ServiceFileHandlerBase.js +13 -4
- package/dist/serviceModules/adapters/IFileSystemAdapter.d.ts +3 -0
- package/dist/services/base/ControlService.js +1 -5
- package/dist/services/base/DatabaseEventService.d.ts +3 -0
- package/dist/services/base/DatabaseEventService.js +3 -0
- package/dist/services/base/DatabaseService.d.ts +15 -0
- package/dist/services/base/DatabaseService.js +85 -4
- package/dist/services/base/IService.d.ts +18 -1
- package/dist/services/base/KeyValueDBService.d.ts +5 -4
- package/dist/services/base/KeyValueDBService.js +46 -48
- package/dist/services/base/ReplicationService.d.ts +3 -1
- package/dist/services/base/ReplicationService.js +3 -1
- package/dist/services/base/VaultScanResult.d.ts +5 -0
- package/dist/services/lib/HandlerUtils.d.ts +40 -5
- package/dist/services/lib/HandlerUtils.js +52 -4
- package/dist/storage.d.ts +2 -0
- package/dist/storage.js +2 -0
- package/docs/development.md +111 -0
- package/docs/offline-scanner.md +46 -0
- package/docs/p2p-transport-lifecycle.md +24 -0
- package/docs/platform-storage.md +22 -0
- package/docs/releasing.md +48 -0
- package/docs/settings-lifecycle.md +4 -2
- package/package.json +1 -1
|
@@ -147,7 +147,7 @@ export declare class MultiBinder<T extends (...args: any[]) => any> implements M
|
|
|
147
147
|
* Adds a handler function.
|
|
148
148
|
* Note: The same function is only added once.
|
|
149
149
|
* @param callback The handler function to add.
|
|
150
|
-
* @param priority
|
|
150
|
+
* @param priority Lower numbers run first; equal priorities retain registration order. Use integers.
|
|
151
151
|
* @returns A function to unregister the added handler.
|
|
152
152
|
*
|
|
153
153
|
*/
|
|
@@ -205,6 +205,10 @@ export declare class AllHandler<T extends unknown[]> extends BooleanHandlerBase<
|
|
|
205
205
|
*/
|
|
206
206
|
invoke(...args: T): Promise<boolean>;
|
|
207
207
|
}
|
|
208
|
+
/** Run handlers in order, stopping at false and propagating callback failures. */
|
|
209
|
+
export declare class AllOrThrowHandler<T extends unknown[]> extends BooleanHandlerBase<T> {
|
|
210
|
+
invoke(...args: T): Promise<boolean>;
|
|
211
|
+
}
|
|
208
212
|
/**
|
|
209
213
|
* A handler that preserves a non-boolean continuation result while continuing
|
|
210
214
|
* to give false results and exceptions veto power.
|
|
@@ -257,16 +261,29 @@ export declare class AnySuccessHandler<T extends unknown[]> extends BooleanHandl
|
|
|
257
261
|
invoke(...args: T): Promise<boolean>;
|
|
258
262
|
}
|
|
259
263
|
/**
|
|
260
|
-
*
|
|
264
|
+
* Invoke handlers sequentially until one returns a value other than `false` or `undefined`.
|
|
265
|
+
* Callback failures are logged and skipped; `0`, an empty string, and `null` are results.
|
|
261
266
|
*/
|
|
262
267
|
export declare class FirstResultHandler<T extends unknown[], U> extends MultiBinder<BooleanHandlerFunc<T, U>> {
|
|
263
268
|
/**
|
|
264
|
-
* Invokes handlers sequentially
|
|
269
|
+
* Invokes handlers sequentially, skipping `false`, `undefined`, and callback failures.
|
|
265
270
|
* @param args The arguments to pass to the handlers.
|
|
266
|
-
* @returns The first
|
|
271
|
+
* @returns The first result other than `false` or `undefined`, or `false` when none applies.
|
|
267
272
|
*/
|
|
268
273
|
invoke(...args: T): Promise<U | false>;
|
|
269
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Invoke a registration snapshot in priority order until a handler returns a value.
|
|
277
|
+
*
|
|
278
|
+
* @remarks Lower numerical priorities run first, with registration order breaking
|
|
279
|
+
* ties. Returning `undefined` declines the invocation; `false`, `0`, and `null`
|
|
280
|
+
* are results and stop dispatch. Handlers run sequentially, so this is not a
|
|
281
|
+
* race between responses and does not require a single registered handler.
|
|
282
|
+
* Callback errors and rejections propagate unchanged without trying later handlers.
|
|
283
|
+
*/
|
|
284
|
+
export declare class FirstApplicableHandler<T extends unknown[], U> extends MultiBinder<HandlerFunc<T, U>> {
|
|
285
|
+
invoke(...args: T): Promise<Awaited<U> | undefined>;
|
|
286
|
+
}
|
|
270
287
|
/**
|
|
271
288
|
* Invokes registered handlers in priority and registration order until one
|
|
272
289
|
* completes or vetoes. Each invocation uses a snapshot of registrations.
|
|
@@ -343,6 +360,7 @@ export interface MultipleHandlerFunction<TFunc extends (...args: any[]) => U | P
|
|
|
343
360
|
*/
|
|
344
361
|
removeHandler: (callback: TFunc) => void;
|
|
345
362
|
}
|
|
363
|
+
export type FirstApplicableFunction<TFunc extends (...args: any[]) => Promise<unknown>> = ((...args: Parameters<TFunc>) => Promise<Awaited<ReturnType<TFunc>> | undefined>) & Pick<MultipleHandlerFunction<TFunc>, "addHandler" | "removeHandler">;
|
|
346
364
|
export type FirstHandledFunction<TFunc extends (...args: any[]) => AnyHandlerOutcome | Promise<AnyHandlerOutcome>> = ((...args: Parameters<TFunc>) => Promise<Awaited<ReturnType<TFunc>> | {
|
|
347
365
|
kind: "not-applicable";
|
|
348
366
|
}>) & Pick<MultipleHandlerFunction<TFunc>, "addHandler" | "removeHandler"> & {
|
|
@@ -396,12 +414,20 @@ export interface MultiBinderInstance<T extends unknown[], U> extends InvokableHa
|
|
|
396
414
|
export interface BooleanMultiBinderInstance<T extends unknown[]> extends InvokableBooleanHandler<T>, MultiRegisterHandler<T, boolean> {
|
|
397
415
|
}
|
|
398
416
|
export declare function allFunction<TFunc extends (...args: any[]) => Promise<boolean>>(name?: string): BooleanMultipleHandlerFunction<TFunc>;
|
|
417
|
+
export declare function allOrThrowFunction<TFunc extends (...args: any[]) => Promise<boolean>>(name?: string): BooleanMultipleHandlerFunction<TFunc>;
|
|
399
418
|
export declare function allSettledFunction<TFunc extends (...args: any[]) => Promise<boolean>>(name?: string): BooleanMultipleHandlerFunction<TFunc>;
|
|
400
419
|
export declare function bailFirstFailureFunction<TFunc extends (...args: any[]) => Promise<boolean>>(name?: string): BooleanMultipleHandlerFunction<TFunc>;
|
|
401
420
|
export declare function bailFirstFailureWithResultFunction<TFunc extends (...args: any[]) => Promise<boolean | string>>(name?: string): MultipleHandlerFunction<TFunc>;
|
|
402
421
|
export declare function allParallelFunction<TFunc extends (...args: any[]) => Promise<boolean>>(name?: string): BooleanMultipleHandlerFunction<TFunc>;
|
|
403
422
|
export declare function anySuccessFunction<TFunc extends (...args: any[]) => Promise<boolean>>(name?: string): BooleanMultipleHandlerFunction<TFunc>;
|
|
404
423
|
export declare function firstResultFunction<TFunc extends (...args: any[]) => Promise<unknown>>(name?: string): MultipleHandlerFunction<TFunc>;
|
|
424
|
+
/**
|
|
425
|
+
* Bind an ordered dispatcher which treats only `undefined` as a declined invocation.
|
|
426
|
+
* @param name - The diagnostic name of the handler registration owner.
|
|
427
|
+
* @returns A callable dispatcher with registration and removal methods.
|
|
428
|
+
* @remarks Dispatch order and failure handling follow {@link FirstApplicableHandler}.
|
|
429
|
+
*/
|
|
430
|
+
export declare function firstApplicableFunction<TFunc extends (...args: any[]) => Promise<unknown>>(name?: string): FirstApplicableFunction<TFunc>;
|
|
405
431
|
export declare function firstHandledFunction<TFunc extends (...args: any[]) => AnyHandlerOutcome | Promise<AnyHandlerOutcome>>(name?: string): FirstHandledFunction<TFunc>;
|
|
406
432
|
export declare function dispatchParallelFunction<TFunc extends (...args: any[]) => Promise<unknown[]>>(name?: string): CollectiveHandlerFunction<TFunc>;
|
|
407
433
|
export declare function bindableFunction<TFunc extends (...args: any[]) => any>(name?: string): HandlerFunction<TFunc>;
|
|
@@ -419,6 +445,8 @@ export declare function handlers<T extends object>(): {
|
|
|
419
445
|
* @returns
|
|
420
446
|
*/
|
|
421
447
|
all<K extends FunctionKeys<T>>(name: K): BooleanMultipleHandlerFunction<Extract<T[K], (...args: any[]) => Promise<boolean>>>;
|
|
448
|
+
/** Stop at a false result; propagate callback errors and rejections unchanged. */
|
|
449
|
+
allOrThrow<K extends FunctionKeys<T>>(name: K): BooleanMultipleHandlerFunction<Extract<T[K], (...args: any[]) => Promise<boolean>>>;
|
|
422
450
|
/**
|
|
423
451
|
* Create a handler that invokes every added handler sequentially and
|
|
424
452
|
* returns true only if all of them succeed.
|
|
@@ -453,11 +481,18 @@ export declare function handlers<T extends object>(): {
|
|
|
453
481
|
*/
|
|
454
482
|
anySuccess<K extends FunctionKeys<T>>(name: K): BooleanMultipleHandlerFunction<Extract<T[K], (...args: any[]) => Promise<boolean>>>;
|
|
455
483
|
/**
|
|
456
|
-
* Create a handler
|
|
484
|
+
* Create a handler which skips `false`, `undefined`, and logged callback failures.
|
|
457
485
|
* @param name
|
|
458
486
|
* @returns
|
|
459
487
|
*/
|
|
460
488
|
firstResult<K extends FunctionKeys<T>>(name: K): MultipleHandlerFunction<Extract<T[K], (...args: any[]) => Promise<unknown>>>;
|
|
489
|
+
/**
|
|
490
|
+
* Try handlers in priority and registration order until one returns a value.
|
|
491
|
+
* @param name - The callback on `T` whose invocation a handler may decline with `undefined`.
|
|
492
|
+
* @returns The first non-`undefined` result, or `undefined` when every handler declines.
|
|
493
|
+
* @remarks All other values stop dispatch. Callback failures propagate unchanged.
|
|
494
|
+
*/
|
|
495
|
+
firstApplicable<K extends FunctionKeys<T>>(name: K): FirstApplicableFunction<Extract<T[K], (...args: any[]) => Promise<unknown>>>;
|
|
461
496
|
/**
|
|
462
497
|
* Create a handler that invokes registered handlers until one completes or vetoes.
|
|
463
498
|
* Callback errors and rejections propagate unchanged.
|
|
@@ -109,7 +109,7 @@ class MultiBinder {
|
|
|
109
109
|
* Adds a handler function.
|
|
110
110
|
* Note: The same function is only added once.
|
|
111
111
|
* @param callback The handler function to add.
|
|
112
|
-
* @param priority
|
|
112
|
+
* @param priority Lower numbers run first; equal priorities retain registration order. Use integers.
|
|
113
113
|
* @returns A function to unregister the added handler.
|
|
114
114
|
*
|
|
115
115
|
*/
|
|
@@ -221,6 +221,16 @@ class AllHandler extends BooleanHandlerBase {
|
|
|
221
221
|
return true;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
+
class AllOrThrowHandler extends BooleanHandlerBase {
|
|
225
|
+
async invoke(...args) {
|
|
226
|
+
for (const callback of [...this._callbacks]) {
|
|
227
|
+
if (await callback(...args) === false) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
224
234
|
class AllWithResultHandler extends MultiBinder {
|
|
225
235
|
/**
|
|
226
236
|
* Invokes every handler in order. The first non-boolean continuation result
|
|
@@ -320,9 +330,9 @@ class AnySuccessHandler extends BooleanHandlerBase {
|
|
|
320
330
|
}
|
|
321
331
|
class FirstResultHandler extends MultiBinder {
|
|
322
332
|
/**
|
|
323
|
-
* Invokes handlers sequentially
|
|
333
|
+
* Invokes handlers sequentially, skipping `false`, `undefined`, and callback failures.
|
|
324
334
|
* @param args The arguments to pass to the handlers.
|
|
325
|
-
* @returns The first
|
|
335
|
+
* @returns The first result other than `false` or `undefined`, or `false` when none applies.
|
|
326
336
|
*/
|
|
327
337
|
async invoke(...args) {
|
|
328
338
|
const _callbacks = [...this._callbacks];
|
|
@@ -340,6 +350,17 @@ class FirstResultHandler extends MultiBinder {
|
|
|
340
350
|
return false;
|
|
341
351
|
}
|
|
342
352
|
}
|
|
353
|
+
class FirstApplicableHandler extends MultiBinder {
|
|
354
|
+
async invoke(...args) {
|
|
355
|
+
for (const callback of [...this._callbacks]) {
|
|
356
|
+
const result = await callback(...args);
|
|
357
|
+
if (result !== void 0) {
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return void 0;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
343
364
|
class FirstHandledHandler extends MultiBinder {
|
|
344
365
|
/**
|
|
345
366
|
* Whether at least one callback is currently registered.
|
|
@@ -379,6 +400,10 @@ function allFunction(name) {
|
|
|
379
400
|
const handler = new AllHandler(name ?? "handleAllFunc");
|
|
380
401
|
return getMultipleBound(handler);
|
|
381
402
|
}
|
|
403
|
+
function allOrThrowFunction(name) {
|
|
404
|
+
const handler = new AllOrThrowHandler(name ?? "allOrThrowFunction");
|
|
405
|
+
return getMultipleBound(handler);
|
|
406
|
+
}
|
|
382
407
|
function allSettledFunction(name) {
|
|
383
408
|
const handler = new SettledAllHandler(name ?? "allSettledFunction");
|
|
384
409
|
return getMultipleBound(handler);
|
|
@@ -405,6 +430,12 @@ function firstResultFunction(name) {
|
|
|
405
430
|
const handler = new FirstResultHandler(name ?? "firstResultFunction");
|
|
406
431
|
return getMultipleBound(handler);
|
|
407
432
|
}
|
|
433
|
+
function firstApplicableFunction(name) {
|
|
434
|
+
const handler = new FirstApplicableHandler(
|
|
435
|
+
name ?? "firstApplicableFunction"
|
|
436
|
+
);
|
|
437
|
+
return getMultipleBound(handler);
|
|
438
|
+
}
|
|
408
439
|
function firstHandledFunction(name) {
|
|
409
440
|
const handler = new FirstHandledHandler(
|
|
410
441
|
name ?? "firstHandledFunction"
|
|
@@ -448,6 +479,10 @@ function handlers() {
|
|
|
448
479
|
all(name) {
|
|
449
480
|
return allFunction(String(name));
|
|
450
481
|
},
|
|
482
|
+
/** Stop at a false result; propagate callback errors and rejections unchanged. */
|
|
483
|
+
allOrThrow(name) {
|
|
484
|
+
return allOrThrowFunction(String(name));
|
|
485
|
+
},
|
|
451
486
|
/**
|
|
452
487
|
* Create a handler that invokes every added handler sequentially and
|
|
453
488
|
* returns true only if all of them succeed.
|
|
@@ -494,13 +529,22 @@ function handlers() {
|
|
|
494
529
|
return anySuccessFunction(String(name));
|
|
495
530
|
},
|
|
496
531
|
/**
|
|
497
|
-
* Create a handler
|
|
532
|
+
* Create a handler which skips `false`, `undefined`, and logged callback failures.
|
|
498
533
|
* @param name
|
|
499
534
|
* @returns
|
|
500
535
|
*/
|
|
501
536
|
firstResult(name) {
|
|
502
537
|
return firstResultFunction(String(name));
|
|
503
538
|
},
|
|
539
|
+
/**
|
|
540
|
+
* Try handlers in priority and registration order until one returns a value.
|
|
541
|
+
* @param name - The callback on `T` whose invocation a handler may decline with `undefined`.
|
|
542
|
+
* @returns The first non-`undefined` result, or `undefined` when every handler declines.
|
|
543
|
+
* @remarks All other values stop dispatch. Callback failures propagate unchanged.
|
|
544
|
+
*/
|
|
545
|
+
firstApplicable(name) {
|
|
546
|
+
return firstApplicableFunction(String(name));
|
|
547
|
+
},
|
|
504
548
|
/**
|
|
505
549
|
* Create a handler that invokes registered handlers until one completes or vetoes.
|
|
506
550
|
* Callback errors and rejections propagate unchanged.
|
|
@@ -533,12 +577,14 @@ function handlers() {
|
|
|
533
577
|
}
|
|
534
578
|
export {
|
|
535
579
|
AllHandler,
|
|
580
|
+
AllOrThrowHandler,
|
|
536
581
|
AllWithResultHandler,
|
|
537
582
|
AnySuccessHandler,
|
|
538
583
|
Binder,
|
|
539
584
|
BooleanHandlerBase,
|
|
540
585
|
Dispatch,
|
|
541
586
|
DispatchParallel,
|
|
587
|
+
FirstApplicableHandler,
|
|
542
588
|
FirstHandledHandler,
|
|
543
589
|
FirstResultHandler,
|
|
544
590
|
LazyBinder,
|
|
@@ -546,6 +592,7 @@ export {
|
|
|
546
592
|
ParallelAllHandler,
|
|
547
593
|
SettledAllHandler,
|
|
548
594
|
allFunction,
|
|
595
|
+
allOrThrowFunction,
|
|
549
596
|
allParallelFunction,
|
|
550
597
|
allSettledFunction,
|
|
551
598
|
anySuccessFunction,
|
|
@@ -553,6 +600,7 @@ export {
|
|
|
553
600
|
bailFirstFailureWithResultFunction,
|
|
554
601
|
bindableFunction,
|
|
555
602
|
dispatchParallelFunction,
|
|
603
|
+
firstApplicableFunction,
|
|
556
604
|
firstHandledFunction,
|
|
557
605
|
firstResultFunction,
|
|
558
606
|
handlers,
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/** Host-neutral path identity, namespace, and storage resolution contracts. */
|
|
2
2
|
export type { FilePath, DocumentPath, StoragePath, PathComparisonKey, PathComparisonSettings, DocumentPathParts, DirectoryEntry, ReadDirectory, ResolvedRename, StorageEntry, StoragePathResolver, StoragePathResolverOptions, } from "./platform/pathTypes.js";
|
|
3
|
+
export { FilePathIndex } from "./platform/FilePathIndex.js";
|
|
4
|
+
export type { FileNameLookup, FileNameReadOptions, FilePathDelta } from "./platform/FilePathIndex.js";
|
|
3
5
|
export { parseFilePath, parseDocumentPath, splitDocumentPath, joinDocumentPath, getStoragePathComparisonKey, getDocumentPathComparisonKey, } from "./platform/pathComparison.js";
|
|
4
6
|
export { createStoragePathResolver, AmbiguousNormalisedPathError } from "./platform/storagePathResolution.js";
|
package/dist/storage.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FilePathIndex } from "./platform/FilePathIndex.js";
|
|
1
2
|
import {
|
|
2
3
|
parseFilePath,
|
|
3
4
|
parseDocumentPath,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
import { createStoragePathResolver, AmbiguousNormalisedPathError } from "./platform/storagePathResolution.js";
|
|
10
11
|
export {
|
|
11
12
|
AmbiguousNormalisedPathError,
|
|
13
|
+
FilePathIndex,
|
|
12
14
|
createStoragePathResolver,
|
|
13
15
|
getDocumentPathComparisonKey,
|
|
14
16
|
getStoragePathComparisonKey,
|
package/docs/development.md
CHANGED
|
@@ -76,6 +76,109 @@ class. Its extracted functions and their focused tests live in
|
|
|
76
76
|
`src/managers/StorageEventManager/`. These organise the event lifecycle separately
|
|
77
77
|
from the file handler's database and storage effects.
|
|
78
78
|
|
|
79
|
+
## P2P and RPC implementation
|
|
80
|
+
|
|
81
|
+
`src/replication/trystero/TrysteroReplicator.ts` retains the existing replicator
|
|
82
|
+
interface, wire command assembly, peer-arrival policy, and host lifecycle. Its
|
|
83
|
+
internal modules use narrow capabilities rather than the complete replicator:
|
|
84
|
+
|
|
85
|
+
| Module under `TrysteroReplicator/` | Responsibility |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| `changeRelay.ts` | Own the changes feed, broadcast state, followed peers, and last sequence; schedule notifications and request pulls. |
|
|
88
|
+
| `peerAgreement.ts` | Request authentication and compare tweak, path-identity, and ID-derivation agreement without exposing the ID key. |
|
|
89
|
+
| `configurationExchange.ts` | Prepare shared settings, obtain passphrases, encrypt or decrypt configuration, and validate imported ID settings. |
|
|
90
|
+
| `progress.ts` | Own acknowledged-attempt state and module-realm attempt numbering, project progress events, and report progress to the peer. |
|
|
91
|
+
| `configuredTargets.ts` | Resolve configured peer names, wait for discovery with listener cleanup, and aggregate sequential baseline synchronisation results. |
|
|
92
|
+
| `transfers.ts` | Own available and active peer sets, apply transfer gates, run the shared replication engine, and finalise progress. |
|
|
93
|
+
| `relayControl.ts` | Adapt shared Trystero relay controls and disconnect a captured socket set without changing host-stop ordering. |
|
|
94
|
+
|
|
95
|
+
The facade's existing relay accessors refer to the relay's single state object.
|
|
96
|
+
Agreement and configuration operations obtain snapshot settings and current
|
|
97
|
+
policy at their documented stages. The host retains peer acceptance, database
|
|
98
|
+
validation, transport binding, and finite-transfer ownership. Public method
|
|
99
|
+
dispatch remains dynamic so host overrides continue to apply. The operations
|
|
100
|
+
use `octagonal-wheels/context` to bind named, standalone functions. Each function
|
|
101
|
+
declares only the dependencies and state it uses, or accepts a composed operation
|
|
102
|
+
instead of that operation's dependencies. Factories allocate state and connect
|
|
103
|
+
these functions; construction starts no database or RPC work. State-bearing
|
|
104
|
+
bindings retain the owner object so existing facade setters remain effective.
|
|
105
|
+
|
|
106
|
+
Shared result, progress, acknowledgement, and peer-admission data contracts live
|
|
107
|
+
in `src/replication/trystero/replicationTypes.ts`, independently of their operation
|
|
108
|
+
owners. The facade, projection, diagnostic, and wire adapters import that leaf
|
|
109
|
+
rather than importing types back from the implementations they support. Local
|
|
110
|
+
failures retain their original error values; the separate wire result uses
|
|
111
|
+
JSON-safe RPC error data. Existing type export paths remain available as
|
|
112
|
+
re-exports. Transfer methods borrow the session owner's
|
|
113
|
+
signal and retain dynamic public dispatch for pull and reverse-sync requests.
|
|
114
|
+
Progress attempts remain ordered across room replacement within one module
|
|
115
|
+
realm; peer departure removes one acknowledgement history, and close clears all
|
|
116
|
+
histories and active transfer sets. Configured-target discovery releases event,
|
|
117
|
+
abort, and timeout hooks before continuing into per-target processing.
|
|
118
|
+
|
|
119
|
+
`TrysteroReplicatorP2PClient` accepts the neutral `rpcSessionProvider.ts`
|
|
120
|
+
capabilities and retains the supplied provider type through its generic parameter.
|
|
121
|
+
Each operation resolves the provider's current room, including calls made through
|
|
122
|
+
a cached database facade. Closing clears the provider and cached facade; `remoteDB`
|
|
123
|
+
then returns `undefined`, while `getRemoteDB()` throws
|
|
124
|
+
`Error('Not connected to any room')`. Calls through an earlier facade also reject.
|
|
125
|
+
Existing call timeouts, notification semantics, and method namespaces remain unchanged.
|
|
126
|
+
|
|
127
|
+
`TrysteroReplicatorP2PServer/peerAdmission.ts` contains the named decision,
|
|
128
|
+
prompt, policy, and admission functions. The Server retains its persisted store,
|
|
129
|
+
temporary decisions, advertisements, and pattern caches; getter capabilities
|
|
130
|
+
keep replacements and public method overrides visible. Policy tests require no
|
|
131
|
+
database, room, or complete host environment. Decision types remain available
|
|
132
|
+
through their previous Server exports.
|
|
133
|
+
|
|
134
|
+
The Server's optional third constructor argument accepts `createRoom`, defaulting
|
|
135
|
+
to Trystero's `joinRoom`. It is called at the original point after diagnostic
|
|
136
|
+
subscriptions, and real `RpcRoom` instances still own message and peer-event
|
|
137
|
+
subscriptions. Registration and the synchronous `beforeAdvertisement` hook
|
|
138
|
+
precede advertisement sending. A separate boundary spec uses real RPC rooms and
|
|
139
|
+
paired fake Trystero rooms to verify calls, notifications, cancellation, and close.
|
|
140
|
+
The replicator facade's optional fourth constructor argument supplies relay
|
|
141
|
+
controls, preserving its third finite-operation-owner argument. Disconnection
|
|
142
|
+
reads sockets, pauses reconnection, closes the captured set, and starts the public
|
|
143
|
+
host-stop operation in the original order. Default controls use the shared
|
|
144
|
+
Trystero registry.
|
|
145
|
+
|
|
146
|
+
`src/rpc/RpcRoom.ts` retains registrations, inbound request routing, transport,
|
|
147
|
+
and chunk state. `RpcRoom/pendingInvocations.ts` owns outbound response waits,
|
|
148
|
+
deadlines, abort subscriptions, settlement, and request-before-cancel ordering.
|
|
149
|
+
The room supplies transport, request IDs, timing, and warning callbacks, and
|
|
150
|
+
forwards peer departure and close events. Notifications bypass this coordinator.
|
|
151
|
+
|
|
152
|
+
The internal modules have focused unit tests beside their implementations.
|
|
153
|
+
Direct function tests supply only the capabilities used by that operation;
|
|
154
|
+
factory tests retain coverage of state sharing and lifetime integration.
|
|
155
|
+
Configured-target discovery returns a Promise to adapt advertisement, abort,
|
|
156
|
+
and timeout callbacks. Registration and the initial predicate run inside its
|
|
157
|
+
executor so setup exceptions remain rejections, while cleanup remains synchronous.
|
|
158
|
+
Their lifetime boundaries retain the existing feed stop boundaries and synchronous
|
|
159
|
+
invocation-wait cleanup. They add no consumer entry points, persistent state,
|
|
160
|
+
retry policy, or new queue policy. Function comments record settings provenance,
|
|
161
|
+
secret exclusions, completion meaning, error boundaries, and cancellation order.
|
|
162
|
+
|
|
163
|
+
## File-name lookup implementation
|
|
164
|
+
|
|
165
|
+
`ServiceFileAccessBase.ts` forwards name queries to the host adapter or its
|
|
166
|
+
package-private `ServiceFileAccessBase/fileNames.ts` fallback. The fallback
|
|
167
|
+
retains one typed request for the active storage-event count and comparison
|
|
168
|
+
policy, shares its pending listing, and uses `FilePathIndex` to select candidates.
|
|
169
|
+
A fresh read retires that request before listing again. Older completions remain
|
|
170
|
+
visible to their original callers without replacing a newer retained request.
|
|
171
|
+
`StorageAccess` inherits the name-query methods from the shared `FileNameLookup`
|
|
172
|
+
contract. The host adapter's indexed capability remains optional; the facade's
|
|
173
|
+
fallback keeps both methods available without redeclaring their signatures.
|
|
174
|
+
|
|
175
|
+
The fallback factory owns only its active-request state. Index creation, request
|
|
176
|
+
reuse, candidate selection, and rejection retirement are named module-level
|
|
177
|
+
operations with explicit state and dependency parameters. Listing-only operations
|
|
178
|
+
accept just `getFileNames`; observation counting is required only by candidate
|
|
179
|
+
selection. Direct operation tests cover promise sharing, re-entrant invalidation,
|
|
180
|
+
older request rejection, and policy snapshots alongside the factory contract tests.
|
|
181
|
+
|
|
79
182
|
## Service composition and state ownership
|
|
80
183
|
|
|
81
184
|
Commonlib uses four related forms of composition. Choose between them by ownership and dependency direction, not merely by whether an implementation has mutable state.
|
|
@@ -287,6 +390,14 @@ The platform and RPC ownership decisions are accepted:
|
|
|
287
390
|
|
|
288
391
|
The package build records each compatibility path explicitly. Do not add a wildcard export. A new compatibility path requires a real downstream import, a packed-consumer or downstream test, and a migration plan towards a focused public entry or the owning package.
|
|
289
392
|
|
|
393
|
+
For the unreleased reflection integration, service composition uses
|
|
394
|
+
`handlers<T>().firstApplicable()` to select the first non-`undefined` result and
|
|
395
|
+
`handlers<T>().allOrThrow()` to run boolean callbacks until one returns `false`.
|
|
396
|
+
Both propagate callback exceptions unchanged and retain the existing registration,
|
|
397
|
+
priority, and invocation-snapshot semantics. Reflection and snapshot failures can
|
|
398
|
+
therefore reach their owner without a service-specific dispatcher. The existing
|
|
399
|
+
`firstResult`, `all`, and other handler contracts retain their error handling.
|
|
400
|
+
|
|
290
401
|
The existing `compat/services/lib` helpers `bindableFunction` and `lazyBindableFunction` return an `UnregisterFunction` from `setHandler()`. It removes only the assignment made by that registration while it remains current; a stale remover, including after an override with the same callback, and repeated removals are no-ops. Existing callers may ignore the return value, but implementations and test doubles of the handler interfaces must return a remover. Keep this contract within the existing compatibility boundary rather than presenting it as a general SDK pattern.
|
|
291
402
|
|
|
292
403
|
After the reviewed Self-hosted LiveSync revision changes, inspect its current compatibility imports with:
|
package/docs/offline-scanner.md
CHANGED
|
@@ -201,3 +201,49 @@ bodies or invokes physical deletion. All affected paths are revalidated by their
|
|
|
201
201
|
handler. See [Deletion recovery](deletion-recovery.md) for completion, error,
|
|
202
202
|
concurrency, and cost contracts. This opt-in extension is published in
|
|
203
203
|
[Commonlib 0.4.2](https://github.com/vrtmrz/livesync-commonlib/releases/tag/0.4.2).
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
## Unreleased host recovery integration
|
|
207
|
+
|
|
208
|
+
The following extension was reviewed against Commonlib 0.5.0 and Self-hosted
|
|
209
|
+
LiveSync 1.0.50. It is implemented on the working branch and is not yet published.
|
|
210
|
+
|
|
211
|
+
`VaultScanOptions.onReflectionFailed(target, error)` receives a terminal ordinary DB-to-Vault reflection failure. The target is the selected input document ID and revision; a content error can separately identify the historical revision which could not be read. The scanner awaits the owner callback once. A callback rejection propagates as a persistence failure and is not converted into another content failure. Completed reflection, normal absence, and policy skips do not create failed work.
|
|
212
|
+
|
|
213
|
+
Strict internal reads propagate `ContentReadError` with directly observed `local-database` or `remote` resources and the original `cause`. An empty resource list conveys no automatic recovery prerequisite. The contract does not classify transient failures from names, messages, status defaults, or cause chains. Local Chunk absence is ordinary while a fallback or finite producer can still supply the content. A terminal error is reported after the existing recheck and retry rules finish; a successful fallback discards intermediate failure evidence.
|
|
214
|
+
|
|
215
|
+
`ReflectionOperationContext` carries the target, source policy, and optional checkpoint. `reflectDatabaseEntry` and `processSynchroniseResult` return `completed`, `policy`, or `cancelled`; uncontinuable failures reject the operation. Existing Boolean retrieval and `dbToStorage` facades retain their compatibility conversion at the outside boundary. They are not used to recover a lost cause from a second callback channel. `/replication` re-exports the neutral content and reflection contracts for consumers.
|
|
216
|
+
|
|
217
|
+
A `policy` result means that applicable policy intentionally withheld ordinary
|
|
218
|
+
file reflection, for example to preserve an unsynchronised edit as a conflict,
|
|
219
|
+
queue conflict resolution, or leave an existing folder untouched. A host may
|
|
220
|
+
also decline automatic file application. This is a normal policy decision;
|
|
221
|
+
it does not certify completed reflection or schedule an automatic retry.
|
|
222
|
+
Protection and conflict scheduling may already have occurred.
|
|
223
|
+
|
|
224
|
+
The reflection result keeps its `status` shape, with shared immutable
|
|
225
|
+
`FILE_REFLECTION_COMPLETED`, `FILE_REFLECTION_POLICY`, and
|
|
226
|
+
`FILE_REFLECTION_CANCELLED` values. `isReflectionCompleted` and
|
|
227
|
+
`isReflectionCancelled` express the corresponding caller decisions. The scanner
|
|
228
|
+
converts reflection outcomes to its own pair result once, before applying
|
|
229
|
+
completion events and observed-time bookkeeping.
|
|
230
|
+
|
|
231
|
+
A host can use `IReplicationService.onFiniteReplicationCompleted` to schedule
|
|
232
|
+
retained work after a successful, uncancelled CouchDB finite pull or bidirectional
|
|
233
|
+
transfer, including the initial pull before continuous replication. Zero changed
|
|
234
|
+
documents still qualify. Push-only operations, continuous events, failed attempts,
|
|
235
|
+
and Chunk fetch completion do not emit this signal. Observer errors are diagnostic
|
|
236
|
+
and do not change a successfully completed replication into a failed transfer.
|
|
237
|
+
The notification runs inside the transfer owner, whose finite delivery activity
|
|
238
|
+
may still be held. Handlers must acknowledge admission without awaiting file or
|
|
239
|
+
Chunk operations which depend on that activity ending. The service itself stores
|
|
240
|
+
no retry records and starts no additional replication.
|
|
241
|
+
|
|
242
|
+
For one previously selected ordinary content target, `processFilePair` reuses
|
|
243
|
+
existing scan policy without listing the Vault again. The host must supply fresh,
|
|
244
|
+
identity-validated Metadata, a current storage stub or absence, and ordinary scan
|
|
245
|
+
options; existing file-handler locking and revalidation still own writes. A retained retry passes its existing context through `VaultScanOptions.reflectionOperation`, including its pre-write checkpoint. Full
|
|
246
|
+
scan deletion-recovery planning remains separate. The optional
|
|
247
|
+
`fileHandler.inspectCurrentFileProvenance(path, revision)` checks current bytes against
|
|
248
|
+
existing device-local provenance and current Metadata without retrieving Chunks.
|
|
249
|
+
A missing or mismatched record is inconclusive; a failed inspection rejects instead of becoming a mismatch. Neither permits an overwrite. Hosts own retention, retry bounds, and user presentation.
|
|
@@ -126,6 +126,30 @@ batch still supplies final sequences and counts. Older peers can ignore the extr
|
|
|
126
126
|
argument and continue using sequence progress. No handshake, retry, heartbeat, or
|
|
127
127
|
persistent replication state is added.
|
|
128
128
|
|
|
129
|
+
## Best-effort change notifications
|
|
130
|
+
|
|
131
|
+
Implementation note: this notification path is unreleased, reviewed against
|
|
132
|
+
Commonlib 0.4.3 and Self-hosted LiveSync 1.0.49. It does not change the published
|
|
133
|
+
status of the lifecycle and diagnostics described elsewhere in this document.
|
|
134
|
+
|
|
135
|
+
P2P change notifications ask a following peer to fetch database changes; they do
|
|
136
|
+
not carry Vault data or confirm that a transfer has succeeded. The sender uses
|
|
137
|
+
`RpcSession.notify()` through the peer client, so it waits only for transport
|
|
138
|
+
sending and does not register a pending RPC invocation or a response timeout.
|
|
139
|
+
A notification rejected before admission therefore cannot block later change
|
|
140
|
+
notifications, and a long-running pull does not delay the sender's next notification.
|
|
141
|
+
|
|
142
|
+
The `change-notification-sent` observation records transport sending, not peer
|
|
143
|
+
admission, completed replication, or Vault reflection. Pull outcomes remain
|
|
144
|
+
separate observations. A missed final notification is not retried automatically;
|
|
145
|
+
a later notification or explicit synchronisation can initiate a fresh comparison.
|
|
146
|
+
|
|
147
|
+
The optional request field `expectsResponse: false` suppresses both successful
|
|
148
|
+
and failed RPC responses on updated receivers. An older receiver may still reply;
|
|
149
|
+
the sender ignores that response because it has no pending invocation. Existing
|
|
150
|
+
request admission, handler execution, cancellation, and room ownership remain in
|
|
151
|
+
force. This change does not make not-ready or busy replication succeed.
|
|
152
|
+
|
|
129
153
|
## Latest diagnostic observations
|
|
130
154
|
|
|
131
155
|
The optional `P2PDiagnostics.getDiagnosticSnapshot()` and
|
package/docs/platform-storage.md
CHANGED
|
@@ -122,6 +122,28 @@ version. Its ordinary case-mismatch check remains separate from path-version
|
|
|
122
122
|
admission. See [Unicode path identity](unicode-path-identity.md#supported-hosts)
|
|
123
123
|
for the current publication and host-adoption boundaries.
|
|
124
124
|
|
|
125
|
+
## File-name candidate lookup
|
|
126
|
+
|
|
127
|
+
These file-name APIs are an unreleased Commonlib change. `FilePathIndex`,
|
|
128
|
+
exported from `/storage`, keeps original file names and groups
|
|
129
|
+
all candidates under an explicit Unicode and case policy. It performs no I/O
|
|
130
|
+
and owns no watcher or readiness state. The host owns the index lifetime,
|
|
131
|
+
initial listing, supported-path rules, and membership updates; use
|
|
132
|
+
`replaceAll()` for an initial snapshot and `apply({ removed, added })` for a
|
|
133
|
+
membership change. Content-only events do not require an index update.
|
|
134
|
+
|
|
135
|
+
Hosts can expose an asynchronous `FileNameLookup` through the optional
|
|
136
|
+
`fileNameLookup` property of `IFileSystemAdapter`. When `{ fresh: true }` is
|
|
137
|
+
supplied, `getFileNames()` must ask the host's supported listing authority
|
|
138
|
+
again. `findPathIdentityCandidates(path, policy)` returns every matching original
|
|
139
|
+
path whose comparison key matches the requested identity. Multiple results are
|
|
140
|
+
candidates for the caller's collision decision. Keep fresh listing guarantees
|
|
141
|
+
host-specific. A host without this
|
|
142
|
+
capability continues to list through `getFiles()` and uses the storage-access
|
|
143
|
+
fallback.
|
|
144
|
+
Direct `StorageAccess` implementations must also implement the required
|
|
145
|
+
`findPathIdentityCandidates()` method when adopting this pre-1.0 interface.
|
|
146
|
+
|
|
125
147
|
## Bundling boundary
|
|
126
148
|
|
|
127
149
|
Browser consumers import only `@vrtmrz/livesync-commonlib/browser`. Packed-package tests build that entry with browser conditions and verify that the Node implementation is absent. Node consumers import `@vrtmrz/livesync-commonlib/node`; the root and context entries do not load Node built-ins.
|
package/docs/releasing.md
CHANGED
|
@@ -73,6 +73,54 @@ implementations must also provide `registerCleanup(callback: () => void): void`;
|
|
|
73
73
|
subclasses of `APIService` inherit its default terminal-unload implementation.
|
|
74
74
|
These changes use the next minor version under the compatibility policy.
|
|
75
75
|
|
|
76
|
+
Version 0.5.0 adds the required `findPathIdentityCandidates()` method to
|
|
77
|
+
`StorageAccess`. Direct implementations must supply it; implementations based
|
|
78
|
+
on `ServiceFileAccessBase` inherit the adapter or listing fallback. The P2P
|
|
79
|
+
client also exposes its closed provider state explicitly in its types. These
|
|
80
|
+
source compatibility changes use the next minor version under the policy.
|
|
81
|
+
|
|
82
|
+
### 0.6.0 integration changes
|
|
83
|
+
|
|
84
|
+
Version 0.6.0 is an unreleased candidate with source compatibility changes to
|
|
85
|
+
strict reads, file reflection, and database lifecycle integration. The standard
|
|
86
|
+
base implementations supply the new members. Custom overrides must also follow
|
|
87
|
+
the updated return and failure contracts.
|
|
88
|
+
|
|
89
|
+
Direct interface implementations must provide these additional members:
|
|
90
|
+
|
|
91
|
+
| Interface | Required members |
|
|
92
|
+
| --- | --- |
|
|
93
|
+
| `DatabaseFileAccess` | `readEntryMeta`, `readEntryFromMeta`, `readEntry`, `readConflictedRevs`, and `readLiveContentRevisions` |
|
|
94
|
+
| `IFileHandler` | `reflectDatabaseEntry` |
|
|
95
|
+
| `IDatabaseService` | `localDatabaseDirect`, `reopenDatabase`, `canReadCurrentDatabaseInfo`, and `closeDatabase` |
|
|
96
|
+
| `IDatabaseEventService` | `onBeforeDatabaseResume`, `onBeforeDatabaseRecovery`, and `onAfterDatabaseRecovery` |
|
|
97
|
+
| `IReplicationService` | `onFiniteReplicationCompleted` and `onFileReflectionFailed` |
|
|
98
|
+
|
|
99
|
+
`IReplicationService.processSynchroniseResult()` now returns
|
|
100
|
+
`Promise<FileReflectionResult | undefined>` instead of `Promise<boolean>`.
|
|
101
|
+
Handlers return one of `FILE_REFLECTION_COMPLETED`, `FILE_REFLECTION_POLICY`, or
|
|
102
|
+
`FILE_REFLECTION_CANCELLED`; `undefined` declines handling. These values and
|
|
103
|
+
`isReflectionCompleted()` are exported from `@vrtmrz/livesync-commonlib/replication`.
|
|
104
|
+
Only a completed result permits completion bookkeeping. Do not interpret every
|
|
105
|
+
returned object as success: policy and cancellation do not establish completed
|
|
106
|
+
reflection. Terminal failures reject to the operation owner.
|
|
107
|
+
|
|
108
|
+
The strict read methods preserve ordinary absence while rejecting failed I/O or
|
|
109
|
+
incomplete content. Existing Boolean and array-returning facades keep their
|
|
110
|
+
compatibility conversions; changing a call to a strict method therefore also
|
|
111
|
+
requires handling its rejection at the operation owner.
|
|
112
|
+
|
|
113
|
+
Direct reads through `LiveSyncLocalDB.localDatabase` bypass caller-wait retirement.
|
|
114
|
+
Use `readDBEntry()` for file content, `getRaw()` or `allDocsRaw()` for raw document
|
|
115
|
+
reads, and `readFromDatabase()` for other read-only operations. A read callback
|
|
116
|
+
must not perform writes or apply later results to application state: its underlying
|
|
117
|
+
I/O can continue after its caller wait ends. Raw replication, changes-feed, and
|
|
118
|
+
maintenance integrations retain responsibility for their own completion and lifetime.
|
|
119
|
+
|
|
120
|
+
See [Local database lifecycle](database-lifecycle.md) and
|
|
121
|
+
[Strict content reads and reflection](offline-scanner.md#unreleased-host-recovery-integration)
|
|
122
|
+
for operation ownership and host integration.
|
|
123
|
+
|
|
76
124
|
## Preparing a release
|
|
77
125
|
|
|
78
126
|
Choose the version explicitly. For the 0.2 line, start at 0.2.0. A stable candidate can use its final version on the `next` dist-tag, then be checked by exact source revision and tarball SHA-256 before the same version is promoted to `latest`. No `-next.N` or `-rc.N` version is required; use a separate prerelease version only when it is useful for a distinct candidate. Package-proof versions are local artefacts and cannot be staged.
|
|
@@ -8,9 +8,11 @@ Commonlib separates three values which older integrations commonly treated as on
|
|
|
8
8
|
|
|
9
9
|
`DEFAULT_SETTINGS` remains an alias of `SETTINGS_SCHEMA_DEFAULTS` for compatibility. New code should choose the named contract which matches its operation.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Plaintext acceptance setting (Commonlib 0.4.3)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Available in [Commonlib 0.4.3](https://www.npmjs.com/package/@vrtmrz/livesync-commonlib/v/0.4.3). The corresponding Self-hosted LiveSync dialogue changes are available in [Self-hosted LiveSync 1.0.49](https://github.com/vrtmrz/obsidian-livesync/releases/tag/1.0.49).
|
|
14
|
+
|
|
15
|
+
The `acceptUnencryptedContent` setting defaults to `false`; only the boolean value `true` enables it. With E2EE enabled, it permits receipt of unencrypted file content from third-party tools which do not use the E2EE passphrase. Content sent by the plug-in remains encrypted. Complete Setup URI and QR imports normalise a missing or invalid value to `false`. Settings Markdown includes the value regardless of credential-sharing choice; a partial Markdown import preserves the current value when the field is absent and treats an explicitly invalid value as `false`.
|
|
14
16
|
|
|
15
17
|
## Starting a new Vault
|
|
16
18
|
|
package/package.json
CHANGED