@vrtmrz/livesync-commonlib 0.1.0-rc.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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/API/DirectFileManipulator.d.ts +2 -0
- package/dist/API/DirectFileManipulator.js +4 -0
- package/dist/API/DirectFileManipulatorV2.d.ts +150 -0
- package/dist/API/DirectFileManipulatorV2.js +424 -0
- package/dist/API/processSetting.d.ts +41 -0
- package/dist/API/processSetting.js +140 -0
- package/dist/ContentSplitter/ContentSplitter.d.ts +28 -0
- package/dist/ContentSplitter/ContentSplitter.js +5 -0
- package/dist/ContentSplitter/ContentSplitterBase.d.ts +51 -0
- package/dist/ContentSplitter/ContentSplitterBase.js +83 -0
- package/dist/ContentSplitter/ContentSplitterRabinKarp.d.ts +9 -0
- package/dist/ContentSplitter/ContentSplitterRabinKarp.js +32 -0
- package/dist/ContentSplitter/ContentSplitterV1.d.ts +9 -0
- package/dist/ContentSplitter/ContentSplitterV1.js +34 -0
- package/dist/ContentSplitter/ContentSplitterV2.d.ts +9 -0
- package/dist/ContentSplitter/ContentSplitterV2.js +34 -0
- package/dist/ContentSplitter/ContentSplitters.d.ts +12 -0
- package/dist/ContentSplitter/ContentSplitters.js +29 -0
- package/dist/bureau/bureau.d.ts +7 -0
- package/dist/bureau/bureau.js +5 -0
- package/dist/common/ConnectionString.d.ts +30 -0
- package/dist/common/ConnectionString.js +179 -0
- package/dist/common/LSError.d.ts +48 -0
- package/dist/common/LSError.js +112 -0
- package/dist/common/configForDoc.d.ts +79 -0
- package/dist/common/configForDoc.js +312 -0
- package/dist/common/coreEnvFunctions.d.ts +21 -0
- package/dist/common/coreEnvFunctions.js +22 -0
- package/dist/common/coreEnvVars.d.ts +3 -0
- package/dist/common/coreEnvVars.js +6 -0
- package/dist/common/i18n.d.ts +18 -0
- package/dist/common/i18n.js +7193 -0
- package/dist/common/logger.d.ts +2 -0
- package/dist/common/logger.js +1 -0
- package/dist/common/messages/combinedMessages.dev.d.ts +7 -0
- package/dist/common/messages/combinedMessages.dev.js +44 -0
- package/dist/common/messages/combinedMessages.prod.d.ts +9264 -0
- package/dist/common/messages/combinedMessages.prod.js +9271 -0
- package/dist/common/messages/de.d.ts +297 -0
- package/dist/common/messages/de.js +7 -0
- package/dist/common/messages/def.d.ts +1119 -0
- package/dist/common/messages/def.js +7 -0
- package/dist/common/messages/es.d.ts +689 -0
- package/dist/common/messages/es.js +7 -0
- package/dist/common/messages/fr.d.ts +582 -0
- package/dist/common/messages/fr.js +7 -0
- package/dist/common/messages/he.d.ts +583 -0
- package/dist/common/messages/he.js +7 -0
- package/dist/common/messages/ja.d.ts +838 -0
- package/dist/common/messages/ja.js +7 -0
- package/dist/common/messages/ko.d.ts +800 -0
- package/dist/common/messages/ko.js +7 -0
- package/dist/common/messages/ru.d.ts +858 -0
- package/dist/common/messages/ru.js +7 -0
- package/dist/common/messages/zh-tw.d.ts +384 -0
- package/dist/common/messages/zh-tw.js +7 -0
- package/dist/common/messages/zh.d.ts +1093 -0
- package/dist/common/messages/zh.js +7 -0
- package/dist/common/messagesJson/de.json +295 -0
- package/dist/common/messagesJson/en.json +1117 -0
- package/dist/common/messagesJson/es.json +687 -0
- package/dist/common/messagesJson/fr.json +580 -0
- package/dist/common/messagesJson/he.json +581 -0
- package/dist/common/messagesJson/ja.json +836 -0
- package/dist/common/messagesJson/ko.json +798 -0
- package/dist/common/messagesJson/ru.json +856 -0
- package/dist/common/messagesJson/zh-tw.json +382 -0
- package/dist/common/messagesJson/zh.json +1091 -0
- package/dist/common/models/auth.type.d.ts +41 -0
- package/dist/common/models/auth.type.js +0 -0
- package/dist/common/models/db.const.d.ts +20 -0
- package/dist/common/models/db.const.js +28 -0
- package/dist/common/models/db.definition.d.ts +56 -0
- package/dist/common/models/db.definition.js +6 -0
- package/dist/common/models/db.type.d.ts +142 -0
- package/dist/common/models/db.type.js +0 -0
- package/dist/common/models/diff.definition.d.ts +16 -0
- package/dist/common/models/diff.definition.js +0 -0
- package/dist/common/models/fileaccess.const.d.ts +7 -0
- package/dist/common/models/fileaccess.const.js +16 -0
- package/dist/common/models/fileaccess.type.d.ts +72 -0
- package/dist/common/models/fileaccess.type.js +0 -0
- package/dist/common/models/redflag.const.d.ts +32 -0
- package/dist/common/models/redflag.const.js +27 -0
- package/dist/common/models/setting.const.d.ts +49 -0
- package/dist/common/models/setting.const.defaults.d.ts +3 -0
- package/dist/common/models/setting.const.defaults.js +185 -0
- package/dist/common/models/setting.const.js +68 -0
- package/dist/common/models/setting.const.preferred.d.ts +5 -0
- package/dist/common/models/setting.const.preferred.js +35 -0
- package/dist/common/models/setting.const.qr.d.ts +2 -0
- package/dist/common/models/setting.const.qr.js +174 -0
- package/dist/common/models/setting.type.d.ts +900 -0
- package/dist/common/models/setting.type.js +8 -0
- package/dist/common/models/shared.const.behabiour.d.ts +28 -0
- package/dist/common/models/shared.const.behabiour.js +36 -0
- package/dist/common/models/shared.const.d.ts +5 -0
- package/dist/common/models/shared.const.js +12 -0
- package/dist/common/models/shared.const.symbols.d.ts +9 -0
- package/dist/common/models/shared.const.symbols.js +20 -0
- package/dist/common/models/shared.definition.configNames.d.ts +36 -0
- package/dist/common/models/shared.definition.configNames.js +203 -0
- package/dist/common/models/shared.definition.d.ts +22 -0
- package/dist/common/models/shared.definition.js +24 -0
- package/dist/common/models/shared.type.util.d.ts +8 -0
- package/dist/common/models/shared.type.util.js +0 -0
- package/dist/common/models/sync.definition.d.ts +18 -0
- package/dist/common/models/sync.definition.js +20 -0
- package/dist/common/models/tweak.definition.d.ts +191 -0
- package/dist/common/models/tweak.definition.js +77 -0
- package/dist/common/rosetta.d.ts +42 -0
- package/dist/common/rosetta.js +57 -0
- package/dist/common/settingConstants.d.ts +216 -0
- package/dist/common/settingConstants.js +434 -0
- package/dist/common/typeUtils.d.ts +17 -0
- package/dist/common/typeUtils.js +51 -0
- package/dist/common/types.d.ts +107 -0
- package/dist/common/types.js +212 -0
- package/dist/common/utils.d.ts +129 -0
- package/dist/common/utils.doc.d.ts +11 -0
- package/dist/common/utils.doc.js +35 -0
- package/dist/common/utils.js +583 -0
- package/dist/common/utils.object.d.ts +2 -0
- package/dist/common/utils.object.js +14 -0
- package/dist/common/utils.patch.d.ts +8 -0
- package/dist/common/utils.patch.js +178 -0
- package/dist/common/utils.type.d.ts +1 -0
- package/dist/common/utils.type.js +0 -0
- package/dist/context.d.ts +8 -0
- package/dist/context.js +14 -0
- package/dist/databases/IndexedDBKeyValueDatabase.d.ts +26 -0
- package/dist/databases/IndexedDBKeyValueDatabase.js +130 -0
- package/dist/dataobject/StoredMap.d.ts +12 -0
- package/dist/dataobject/StoredMap.js +47 -0
- package/dist/dev/checks.d.ts +5 -0
- package/dist/dev/checks.js +38 -0
- package/dist/encryption/encryptHKDF.d.ts +3 -0
- package/dist/encryption/encryptHKDF.js +7 -0
- package/dist/encryption/stringEncryption.d.ts +27 -0
- package/dist/encryption/stringEncryption.js +59 -0
- package/dist/events/coreEvents.d.ts +54 -0
- package/dist/events/coreEvents.js +46 -0
- package/dist/hub/hub.d.ts +11 -0
- package/dist/hub/hub.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/AsyncActivityRunner.d.ts +18 -0
- package/dist/interfaces/AsyncActivityRunner.js +7 -0
- package/dist/interfaces/Confirm.d.ts +17 -0
- package/dist/interfaces/Confirm.js +0 -0
- package/dist/interfaces/DatabaseFileAccess.d.ts +14 -0
- package/dist/interfaces/DatabaseFileAccess.js +0 -0
- package/dist/interfaces/DatabaseRebuilder.d.ts +13 -0
- package/dist/interfaces/DatabaseRebuilder.js +0 -0
- package/dist/interfaces/FileHandler.d.ts +13 -0
- package/dist/interfaces/FileHandler.js +0 -0
- package/dist/interfaces/KeyValueDatabase.d.ts +11 -0
- package/dist/interfaces/KeyValueDatabase.js +0 -0
- package/dist/interfaces/ServiceModule.d.ts +59 -0
- package/dist/interfaces/ServiceModule.js +19 -0
- package/dist/interfaces/StorageAccess.d.ts +44 -0
- package/dist/interfaces/StorageAccess.js +0 -0
- package/dist/interfaces/StorageEventManager.d.ts +16 -0
- package/dist/interfaces/StorageEventManager.js +5 -0
- package/dist/managers/ChangeManager.d.ts +61 -0
- package/dist/managers/ChangeManager.js +104 -0
- package/dist/managers/ChunkDeliveryCoordinator.d.ts +51 -0
- package/dist/managers/ChunkDeliveryCoordinator.js +136 -0
- package/dist/managers/ChunkFetcher.d.ts +44 -0
- package/dist/managers/ChunkFetcher.js +251 -0
- package/dist/managers/ChunkManager.d.ts +2 -0
- package/dist/managers/ChunkManager.js +4 -0
- package/dist/managers/ConflictManager.d.ts +37 -0
- package/dist/managers/ConflictManager.js +322 -0
- package/dist/managers/EntryManager/EntryManager.d.ts +37 -0
- package/dist/managers/EntryManager/EntryManager.js +73 -0
- package/dist/managers/EntryManager/EntryManagerImpls.d.ts +74 -0
- package/dist/managers/EntryManager/EntryManagerImpls.js +499 -0
- package/dist/managers/HashManager/HashManager.d.ts +60 -0
- package/dist/managers/HashManager/HashManager.js +97 -0
- package/dist/managers/HashManager/HashManagerCore.d.ts +114 -0
- package/dist/managers/HashManager/HashManagerCore.js +99 -0
- package/dist/managers/HashManager/PureJSHashManager.d.ts +77 -0
- package/dist/managers/HashManager/PureJSHashManager.js +84 -0
- package/dist/managers/HashManager/XXHashHashManager.d.ts +96 -0
- package/dist/managers/HashManager/XXHashHashManager.js +111 -0
- package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.d.ts +30 -0
- package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.js +115 -0
- package/dist/managers/LayeredChunkManager/CacheLayer.d.ts +59 -0
- package/dist/managers/LayeredChunkManager/CacheLayer.js +161 -0
- package/dist/managers/LayeredChunkManager/ChunkLayerInterfaces.d.ts +37 -0
- package/dist/managers/LayeredChunkManager/ChunkLayerInterfaces.js +0 -0
- package/dist/managers/LayeredChunkManager/DatabaseReadLayer.d.ts +14 -0
- package/dist/managers/LayeredChunkManager/DatabaseReadLayer.js +78 -0
- package/dist/managers/LayeredChunkManager/DatabaseWriteLayer.d.ts +11 -0
- package/dist/managers/LayeredChunkManager/DatabaseWriteLayer.js +43 -0
- package/dist/managers/LayeredChunkManager/HotPackLayer.d.ts +9 -0
- package/dist/managers/LayeredChunkManager/HotPackLayer.js +8 -0
- package/dist/managers/LayeredChunkManager/types.d.ts +39 -0
- package/dist/managers/LayeredChunkManager/types.js +0 -0
- package/dist/managers/LayeredChunkManager.d.ts +53 -0
- package/dist/managers/LayeredChunkManager.js +240 -0
- package/dist/managers/LiveSyncManagers.d.ts +48 -0
- package/dist/managers/LiveSyncManagers.js +136 -0
- package/dist/managers/StorageEventManager.d.ts +135 -0
- package/dist/managers/StorageEventManager.js +564 -0
- package/dist/managers/StorageProcessingManager.d.ts +14 -0
- package/dist/managers/StorageProcessingManager.js +48 -0
- package/dist/managers/adapters/IStorageEventConverterAdapter.d.ts +16 -0
- package/dist/managers/adapters/IStorageEventConverterAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventManagerAdapter.d.ts +18 -0
- package/dist/managers/adapters/IStorageEventManagerAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventPersistenceAdapter.d.ts +15 -0
- package/dist/managers/adapters/IStorageEventPersistenceAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventStatusAdapter.d.ts +13 -0
- package/dist/managers/adapters/IStorageEventStatusAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventTypeGuardAdapter.d.ts +16 -0
- package/dist/managers/adapters/IStorageEventTypeGuardAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventWatchAdapter.d.ts +21 -0
- package/dist/managers/adapters/IStorageEventWatchAdapter.js +0 -0
- package/dist/managers/adapters/index.d.ts +6 -0
- package/dist/managers/adapters/index.js +0 -0
- package/dist/mock_and_interop/stores.d.ts +21 -0
- package/dist/mock_and_interop/stores.js +15 -0
- package/dist/mock_and_interop/wrapper.d.ts +7 -0
- package/dist/mock_and_interop/wrapper.js +37 -0
- package/dist/mods.d.ts +1 -0
- package/dist/mods.js +18 -0
- package/dist/platform/browser/index.d.ts +1 -0
- package/dist/platform/browser/index.js +10 -0
- package/dist/platform/browser/storage.d.ts +35 -0
- package/dist/platform/browser/storage.js +139 -0
- package/dist/platform/node/index.d.ts +23 -0
- package/dist/platform/node/index.js +33 -0
- package/dist/platform/node/storage.d.ts +31 -0
- package/dist/platform/node/storage.js +104 -0
- package/dist/platform/storagePath.d.ts +7 -0
- package/dist/platform/storagePath.js +20 -0
- package/dist/pouchdb/LiveSyncDBFunctions.d.ts +14 -0
- package/dist/pouchdb/LiveSyncDBFunctions.js +129 -0
- package/dist/pouchdb/LiveSyncLocalDB.d.ts +196 -0
- package/dist/pouchdb/LiveSyncLocalDB.js +381 -0
- package/dist/pouchdb/PouchDBConstructor.d.ts +3 -0
- package/dist/pouchdb/PouchDBConstructor.js +0 -0
- package/dist/pouchdb/ReplicatorShim.d.ts +51 -0
- package/dist/pouchdb/ReplicatorShim.js +109 -0
- package/dist/pouchdb/StreamingFetch.d.ts +19 -0
- package/dist/pouchdb/StreamingFetch.js +263 -0
- package/dist/pouchdb/chunks.d.ts +38 -0
- package/dist/pouchdb/chunks.js +314 -0
- package/dist/pouchdb/compress.d.ts +11 -0
- package/dist/pouchdb/compress.js +99 -0
- package/dist/pouchdb/encryption.d.ts +20 -0
- package/dist/pouchdb/encryption.js +458 -0
- package/dist/pouchdb/negotiation.d.ts +9 -0
- package/dist/pouchdb/negotiation.js +109 -0
- package/dist/pouchdb/pouchdb-browser.d.ts +2 -0
- package/dist/pouchdb/pouchdb-browser.js +96 -0
- package/dist/pouchdb/pouchdb-http.d.ts +2 -0
- package/dist/pouchdb/pouchdb-http.js +94 -0
- package/dist/pouchdb/pouchdb-test.d.ts +2 -0
- package/dist/pouchdb/pouchdb-test.js +12 -0
- package/dist/pouchdb/utils_couchdb.d.ts +4 -0
- package/dist/pouchdb/utils_couchdb.js +38 -0
- package/dist/replication/LiveSyncAbstractReplicator.d.ts +69 -0
- package/dist/replication/LiveSyncAbstractReplicator.js +92 -0
- package/dist/replication/SyncParamsHandler.d.ts +35 -0
- package/dist/replication/SyncParamsHandler.js +118 -0
- package/dist/replication/couchdb/LiveSyncReplicator.d.ts +85 -0
- package/dist/replication/couchdb/LiveSyncReplicator.js +1132 -0
- package/dist/replication/httplib.d.ts +75 -0
- package/dist/replication/httplib.js +187 -0
- package/dist/replication/journal/JournalSyncCore.d.ts +70 -0
- package/dist/replication/journal/JournalSyncCore.js +737 -0
- package/dist/replication/journal/JournalSyncTypes.d.ts +9 -0
- package/dist/replication/journal/JournalSyncTypes.js +11 -0
- package/dist/replication/journal/LiveSyncJournalReplicator.d.ts +40 -0
- package/dist/replication/journal/LiveSyncJournalReplicator.js +294 -0
- package/dist/replication/journal/LiveSyncJournalReplicatorEnv.d.ts +3 -0
- package/dist/replication/journal/LiveSyncJournalReplicatorEnv.js +0 -0
- package/dist/replication/journal/objectstore/JournalStorageAdapter.d.ts +15 -0
- package/dist/replication/journal/objectstore/JournalStorageAdapter.js +0 -0
- package/dist/replication/journal/objectstore/MinioStorageAdapter.d.ts +21 -0
- package/dist/replication/journal/objectstore/MinioStorageAdapter.js +204 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +90 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.js +380 -0
- package/dist/replication/trystero/P2PLogCollector.d.ts +8 -0
- package/dist/replication/trystero/P2PLogCollector.js +91 -0
- package/dist/replication/trystero/P2PReplicatorBase.d.ts +19 -0
- package/dist/replication/trystero/P2PReplicatorBase.js +0 -0
- package/dist/replication/trystero/P2PReplicatorCore.d.ts +12 -0
- package/dist/replication/trystero/P2PReplicatorCore.js +126 -0
- package/dist/replication/trystero/P2PReplicatorPaneCommon.d.ts +41 -0
- package/dist/replication/trystero/P2PReplicatorPaneCommon.js +20 -0
- package/dist/replication/trystero/ProxiedDB.d.ts +13 -0
- package/dist/replication/trystero/ProxiedDB.js +20 -0
- package/dist/replication/trystero/TrysteroReplicator.d.ts +152 -0
- package/dist/replication/trystero/TrysteroReplicator.js +683 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.d.ts +19 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.js +80 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PConnection.d.ts +2 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PConnection.js +4 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +117 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +540 -0
- package/dist/replication/trystero/UseP2PReplicatorResult.d.ts +11 -0
- package/dist/replication/trystero/UseP2PReplicatorResult.js +0 -0
- package/dist/replication/trystero/addP2PEventHandlers.d.ts +35 -0
- package/dist/replication/trystero/addP2PEventHandlers.js +43 -0
- package/dist/replication/trystero/rpcCompat.d.ts +1 -0
- package/dist/replication/trystero/rpcCompat.js +9 -0
- package/dist/replication/trystero/types.d.ts +95 -0
- package/dist/replication/trystero/types.js +27 -0
- package/dist/replication/trystero/useP2PReplicatorCommands.d.ts +7 -0
- package/dist/replication/trystero/useP2PReplicatorCommands.js +25 -0
- package/dist/replication/trystero/useP2PReplicatorFeature.d.ts +17 -0
- package/dist/replication/trystero/useP2PReplicatorFeature.js +82 -0
- package/dist/rpc/RpcRoom.d.ts +24 -0
- package/dist/rpc/RpcRoom.js +300 -0
- package/dist/rpc/RpcSession.d.ts +9 -0
- package/dist/rpc/RpcSession.js +32 -0
- package/dist/rpc/chunking.d.ts +11 -0
- package/dist/rpc/chunking.js +58 -0
- package/dist/rpc/errors.d.ts +8 -0
- package/dist/rpc/errors.js +26 -0
- package/dist/rpc/index.d.ts +6 -0
- package/dist/rpc/index.js +12 -0
- package/dist/rpc/pouchdb/RpcPouchDBProxy.d.ts +75 -0
- package/dist/rpc/pouchdb/RpcPouchDBProxy.js +115 -0
- package/dist/rpc/pouchdb/RpcPouchDBServer.d.ts +16 -0
- package/dist/rpc/pouchdb/RpcPouchDBServer.js +55 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.d.ts +24 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.js +208 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.types.d.ts +64 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.types.js +12 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.utils.d.ts +33 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.utils.js +217 -0
- package/dist/rpc/transports/TrysteroTransport.d.ts +216 -0
- package/dist/rpc/transports/TrysteroTransport.js +134 -0
- package/dist/rpc/transports/trysteroUtils.d.ts +3 -0
- package/dist/rpc/transports/trysteroUtils.js +37 -0
- package/dist/rpc/types.d.ts +75 -0
- package/dist/rpc/types.js +6 -0
- package/dist/serviceFeatures/checkRemoteSize.d.ts +28 -0
- package/dist/serviceFeatures/checkRemoteSize.js +178 -0
- package/dist/serviceFeatures/offlineScanner.d.ts +128 -0
- package/dist/serviceFeatures/offlineScanner.js +553 -0
- package/dist/serviceFeatures/prepareDatabaseForUse.d.ts +20 -0
- package/dist/serviceFeatures/prepareDatabaseForUse.js +39 -0
- package/dist/serviceFeatures/remoteConfig.d.ts +46 -0
- package/dist/serviceFeatures/remoteConfig.js +247 -0
- package/dist/serviceFeatures/setupObsidian/qrCode.d.ts +4 -0
- package/dist/serviceFeatures/setupObsidian/qrCode.js +67 -0
- package/dist/serviceFeatures/setupObsidian/setupUri.d.ts +7 -0
- package/dist/serviceFeatures/setupObsidian/setupUri.js +70 -0
- package/dist/serviceFeatures/setupObsidian/types.d.ts +2 -0
- package/dist/serviceFeatures/setupObsidian/types.js +0 -0
- package/dist/serviceFeatures/targetFilter.d.ts +24 -0
- package/dist/serviceFeatures/targetFilter.js +178 -0
- package/dist/serviceModules/FileAccessBase.d.ts +93 -0
- package/dist/serviceModules/FileAccessBase.js +219 -0
- package/dist/serviceModules/Rebuilder.d.ts +92 -0
- package/dist/serviceModules/Rebuilder.js +449 -0
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.d.ts +40 -0
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.js +306 -0
- package/dist/serviceModules/ServiceFileAccessBase.d.ts +64 -0
- package/dist/serviceModules/ServiceFileAccessBase.js +312 -0
- package/dist/serviceModules/ServiceFileHandlerBase.d.ts +52 -0
- package/dist/serviceModules/ServiceFileHandlerBase.js +493 -0
- package/dist/serviceModules/ServiceModuleBase.d.ts +10 -0
- package/dist/serviceModules/ServiceModuleBase.js +13 -0
- package/dist/serviceModules/adapters/IConversionAdapter.d.ts +15 -0
- package/dist/serviceModules/adapters/IConversionAdapter.js +0 -0
- package/dist/serviceModules/adapters/IFileSystemAdapter.d.ts +47 -0
- package/dist/serviceModules/adapters/IFileSystemAdapter.js +0 -0
- package/dist/serviceModules/adapters/IPathAdapter.d.ts +15 -0
- package/dist/serviceModules/adapters/IPathAdapter.js +0 -0
- package/dist/serviceModules/adapters/IStorageAdapter.d.ts +56 -0
- package/dist/serviceModules/adapters/IStorageAdapter.js +0 -0
- package/dist/serviceModules/adapters/ITypeGuardAdapter.d.ts +14 -0
- package/dist/serviceModules/adapters/ITypeGuardAdapter.js +0 -0
- package/dist/serviceModules/adapters/IVaultAdapter.d.ts +51 -0
- package/dist/serviceModules/adapters/IVaultAdapter.js +0 -0
- package/dist/serviceModules/adapters/index.d.ts +6 -0
- package/dist/serviceModules/adapters/index.js +0 -0
- package/dist/services/BrowserServices.d.ts +36 -0
- package/dist/services/BrowserServices.js +123 -0
- package/dist/services/HeadlessServices.d.ts +14 -0
- package/dist/services/HeadlessServices.js +144 -0
- package/dist/services/InjectableServices.d.ts +1 -0
- package/dist/services/InjectableServices.js +4 -0
- package/dist/services/ServiceHub.d.ts +82 -0
- package/dist/services/ServiceHub.js +66 -0
- package/dist/services/base/APIService.d.ts +93 -0
- package/dist/services/base/APIService.js +44 -0
- package/dist/services/base/AppLifecycleService.d.ts +132 -0
- package/dist/services/base/AppLifecycleService.js +123 -0
- package/dist/services/base/ConfigService.d.ts +7 -0
- package/dist/services/base/ConfigService.js +6 -0
- package/dist/services/base/ConflictService.d.ts +54 -0
- package/dist/services/base/ConflictService.js +22 -0
- package/dist/services/base/ControlService.d.ts +54 -0
- package/dist/services/base/ControlService.js +103 -0
- package/dist/services/base/DatabaseEventService.d.ts +38 -0
- package/dist/services/base/DatabaseEventService.js +38 -0
- package/dist/services/base/DatabaseService.d.ts +40 -0
- package/dist/services/base/DatabaseService.js +79 -0
- package/dist/services/base/FileProcessingService.d.ts +25 -0
- package/dist/services/base/FileProcessingService.js +28 -0
- package/dist/services/base/IService.d.ts +284 -0
- package/dist/services/base/IService.js +1 -0
- package/dist/services/base/KeyValueDBService.d.ts +42 -0
- package/dist/services/base/KeyValueDBService.js +133 -0
- package/dist/services/base/MessageTranslator.d.ts +6 -0
- package/dist/services/base/MessageTranslator.js +4 -0
- package/dist/services/base/PathService.d.ts +38 -0
- package/dist/services/base/PathService.js +66 -0
- package/dist/services/base/RemoteService.d.ts +61 -0
- package/dist/services/base/RemoteService.js +212 -0
- package/dist/services/base/ReplicationService.d.ts +92 -0
- package/dist/services/base/ReplicationService.js +261 -0
- package/dist/services/base/ReplicatorService.d.ts +66 -0
- package/dist/services/base/ReplicatorService.js +164 -0
- package/dist/services/base/ServiceBase.d.ts +33 -0
- package/dist/services/base/ServiceBase.js +27 -0
- package/dist/services/base/SettingService.d.ts +112 -0
- package/dist/services/base/SettingService.js +543 -0
- package/dist/services/base/TestService.d.ts +28 -0
- package/dist/services/base/TestService.js +19 -0
- package/dist/services/base/TweakValueService.d.ts +40 -0
- package/dist/services/base/TweakValueService.js +6 -0
- package/dist/services/base/UnresolvedErrorManager.d.ts +15 -0
- package/dist/services/base/UnresolvedErrorManager.js +44 -0
- package/dist/services/base/VaultService.d.ts +69 -0
- package/dist/services/base/VaultService.js +70 -0
- package/dist/services/implements/base/SvelteDialog.d.ts +79 -0
- package/dist/services/implements/base/SvelteDialog.js +134 -0
- package/dist/services/implements/base/UIService.d.ts +24 -0
- package/dist/services/implements/base/UIService.js +37 -0
- package/dist/services/implements/browser/BrowserAPIService.d.ts +54 -0
- package/dist/services/implements/browser/BrowserAPIService.js +298 -0
- package/dist/services/implements/browser/BrowserDatabaseService.d.ts +7 -0
- package/dist/services/implements/browser/BrowserDatabaseService.js +10 -0
- package/dist/services/implements/browser/ConfigServiceBrowserCompat.d.ts +16 -0
- package/dist/services/implements/browser/ConfigServiceBrowserCompat.js +23 -0
- package/dist/services/implements/headless/HeadlessAPIService.d.ts +52 -0
- package/dist/services/implements/headless/HeadlessAPIService.js +127 -0
- package/dist/services/implements/headless/HeadlessDatabaseService.d.ts +7 -0
- package/dist/services/implements/headless/HeadlessDatabaseService.js +10 -0
- package/dist/services/implements/injectable/InjectableAPIService.d.ts +7 -0
- package/dist/services/implements/injectable/InjectableAPIService.js +18 -0
- package/dist/services/implements/injectable/InjectableAppLifecycleService.d.ts +11 -0
- package/dist/services/implements/injectable/InjectableAppLifecycleService.js +14 -0
- package/dist/services/implements/injectable/InjectableConflictService.d.ts +11 -0
- package/dist/services/implements/injectable/InjectableConflictService.js +14 -0
- package/dist/services/implements/injectable/InjectableDatabaseEventService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableDatabaseEventService.js +7 -0
- package/dist/services/implements/injectable/InjectableFileProcessingService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableFileProcessingService.js +6 -0
- package/dist/services/implements/injectable/InjectablePathService.d.ts +12 -0
- package/dist/services/implements/injectable/InjectablePathService.js +36 -0
- package/dist/services/implements/injectable/InjectableRemoteService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableRemoteService.js +7 -0
- package/dist/services/implements/injectable/InjectableReplicationService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableReplicationService.js +6 -0
- package/dist/services/implements/injectable/InjectableReplicatorService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableReplicatorService.js +7 -0
- package/dist/services/implements/injectable/InjectableServiceHub.d.ts +72 -0
- package/dist/services/implements/injectable/InjectableServiceHub.js +125 -0
- package/dist/services/implements/injectable/InjectableServices.d.ts +36 -0
- package/dist/services/implements/injectable/InjectableServices.js +1 -0
- package/dist/services/implements/injectable/InjectableSettingService.d.ts +11 -0
- package/dist/services/implements/injectable/InjectableSettingService.js +33 -0
- package/dist/services/implements/injectable/InjectableTestService.d.ts +5 -0
- package/dist/services/implements/injectable/InjectableTestService.js +8 -0
- package/dist/services/implements/injectable/InjectableTweakValueService.d.ts +15 -0
- package/dist/services/implements/injectable/InjectableTweakValueService.js +12 -0
- package/dist/services/implements/injectable/InjectableVaultService.d.ts +9 -0
- package/dist/services/implements/injectable/InjectableVaultService.js +20 -0
- package/dist/services/lib/HandlerUtils.d.ts +374 -0
- package/dist/services/lib/HandlerUtils.js +412 -0
- package/dist/services/lib/logUtils.d.ts +13 -0
- package/dist/services/lib/logUtils.js +28 -0
- package/dist/services/lib/remoteActivity.d.ts +13 -0
- package/dist/services/lib/remoteActivity.js +11 -0
- package/dist/string_and_binary/chunks.d.ts +10 -0
- package/dist/string_and_binary/chunks.js +561 -0
- package/dist/string_and_binary/convert.d.ts +8 -0
- package/dist/string_and_binary/convert.js +46 -0
- package/dist/string_and_binary/hash.d.ts +2 -0
- package/dist/string_and_binary/hash.js +1 -0
- package/dist/string_and_binary/path.d.ts +35 -0
- package/dist/string_and_binary/path.js +240 -0
- package/dist/worker/bg.common.d.ts +2 -0
- package/dist/worker/bg.common.js +6 -0
- package/dist/worker/bg.worker.d.ts +1 -0
- package/dist/worker/bg.worker.encryption.d.ts +7 -0
- package/dist/worker/bg.worker.encryption.js +30 -0
- package/dist/worker/bg.worker.js +14 -0
- package/dist/worker/bg.worker.splitting.d.ts +6 -0
- package/dist/worker/bg.worker.splitting.js +36 -0
- package/dist/worker/bgWorker.d.ts +25 -0
- package/dist/worker/bgWorker.direct.d.ts +40 -0
- package/dist/worker/bgWorker.direct.js +65 -0
- package/dist/worker/bgWorker.encryption.d.ts +22 -0
- package/dist/worker/bgWorker.encryption.js +40 -0
- package/dist/worker/bgWorker.js +348 -0
- package/dist/worker/bgWorker.splitting.d.ts +27 -0
- package/dist/worker/bgWorker.splitting.js +123 -0
- package/dist/worker/universalTypes.d.ts +63 -0
- package/dist/worker/universalTypes.js +4 -0
- package/docs/development.md +51 -0
- package/docs/platform-storage.md +60 -0
- package/docs/releasing.md +69 -0
- package/package.json +693 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import { unique } from "octagonal-wheels/collection";
|
|
2
|
+
import { withConcurrency } from "octagonal-wheels/iterable/map";
|
|
3
|
+
import {
|
|
4
|
+
LOG_LEVEL_DEBUG,
|
|
5
|
+
LOG_LEVEL_INFO,
|
|
6
|
+
LOG_LEVEL_NOTICE,
|
|
7
|
+
LOG_LEVEL_VERBOSE,
|
|
8
|
+
isMetaEntry
|
|
9
|
+
} from "../common/types.js";
|
|
10
|
+
import { compareMTime, isAnyNote } from "../common/utils.js";
|
|
11
|
+
import { stripAllPrefixes } from "../string_and_binary/path.js";
|
|
12
|
+
import { createInstanceLogFunction } from "../services/lib/logUtils.js";
|
|
13
|
+
import { BASE_IS_NEW, EVEN, TARGET_IS_NEW } from "../common/models/shared.const.symbols.js";
|
|
14
|
+
import { UnresolvedErrorManager } from "../services/base/UnresolvedErrorManager.js";
|
|
15
|
+
import { compatGlobal } from "../common/coreEnvFunctions.js";
|
|
16
|
+
async function collectDeletedFiles(host, log) {
|
|
17
|
+
const limitDays = host.services.setting.currentSettings().automaticallyDeleteMetadataOfDeletedFiles;
|
|
18
|
+
if (limitDays <= 0) return;
|
|
19
|
+
log(`Checking expired file history`);
|
|
20
|
+
const limit = Date.now() - 86400 * 1e3 * limitDays;
|
|
21
|
+
const notes = [];
|
|
22
|
+
for await (const doc of host.services.database.localDatabase.findAllDocs({ conflicts: true })) {
|
|
23
|
+
if (isAnyNote(doc)) {
|
|
24
|
+
if (doc.deleted && doc.mtime - limit < 0) {
|
|
25
|
+
notes.push({
|
|
26
|
+
path: doc.path,
|
|
27
|
+
mtime: doc.mtime,
|
|
28
|
+
ttl: (doc.mtime - limit) / 1e3 / 86400,
|
|
29
|
+
doc
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (notes.length === 0) {
|
|
35
|
+
log("There are no old documents");
|
|
36
|
+
log(`Checking expired file history done`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
for (const v of notes) {
|
|
40
|
+
log(`Deletion history expired: ${v.path}`);
|
|
41
|
+
const delDoc = v.doc;
|
|
42
|
+
delDoc._deleted = true;
|
|
43
|
+
await host.services.database.localDatabase.putRaw(delDoc);
|
|
44
|
+
}
|
|
45
|
+
log(`Checking expired file history done`);
|
|
46
|
+
}
|
|
47
|
+
function getPathFromEntry(host, doc) {
|
|
48
|
+
const path = host.services.path.getPath(doc);
|
|
49
|
+
return path;
|
|
50
|
+
}
|
|
51
|
+
async function syncFileBetweenDBandStorage(host, log, file, doc) {
|
|
52
|
+
const docPath = getPathFromEntry(host, doc);
|
|
53
|
+
if (!doc) {
|
|
54
|
+
throw new Error(`Missing doc:${docPath}`);
|
|
55
|
+
}
|
|
56
|
+
const compareResult = host.services.path.compareFileFreshness(file, doc);
|
|
57
|
+
switch (compareResult) {
|
|
58
|
+
case BASE_IS_NEW:
|
|
59
|
+
if (!host.services.vault.isFileSizeTooLarge(file.stat.size)) {
|
|
60
|
+
log("STORAGE -> DB :" + file.path);
|
|
61
|
+
await host.serviceModules.fileHandler.storeFileToDB(file);
|
|
62
|
+
} else {
|
|
63
|
+
log(
|
|
64
|
+
`STORAGE -> DB : ${file.path} has been skipped due to file size exceeding the limit`,
|
|
65
|
+
LOG_LEVEL_NOTICE
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case TARGET_IS_NEW:
|
|
70
|
+
if (!host.services.vault.isFileSizeTooLarge(doc.size)) {
|
|
71
|
+
log("STORAGE <- DB :" + docPath);
|
|
72
|
+
if (await host.serviceModules.fileHandler.dbToStorage(doc, stripAllPrefixes(docPath), false)) {
|
|
73
|
+
host.services.context.events.emitEvent("event-file-changed", {
|
|
74
|
+
file: file.path,
|
|
75
|
+
automated: true
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
log(`STORAGE <- DB : Cloud not read ${file.path}, possibly deleted`, LOG_LEVEL_NOTICE);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
log(
|
|
82
|
+
`STORAGE <- DB : ${file.path} has been skipped due to file size exceeding the limit`,
|
|
83
|
+
LOG_LEVEL_NOTICE
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
case EVEN:
|
|
88
|
+
log("STORAGE == DB :" + file.path, LOG_LEVEL_DEBUG);
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
log("STORAGE ?? DB :" + file.path + " Something got weird");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function canProceedScan(host, errorManager, log, showingNotice = false, ignoreSuspending = false) {
|
|
95
|
+
const settings = host.services.setting.currentSettings();
|
|
96
|
+
const ERR_NOT_CONFIGURED = "LiveSync is not configured yet. Synchronising between the storage and the local database is now prevented.";
|
|
97
|
+
if (!settings.isConfigured) {
|
|
98
|
+
errorManager.showError(ERR_NOT_CONFIGURED, showingNotice ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
errorManager.clearError(ERR_NOT_CONFIGURED);
|
|
102
|
+
const ERR_SUSPENDING = "Now suspending file watching. Synchronising between the storage and the local database is now prevented.";
|
|
103
|
+
if (!ignoreSuspending && settings.suspendFileWatching) {
|
|
104
|
+
errorManager.showError(ERR_SUSPENDING, showingNotice ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO);
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
errorManager.clearError(ERR_SUSPENDING);
|
|
108
|
+
const MSG_IN_REMEDIATION = `Started in remediation Mode! (Max mtime for reflect events is set). Synchronising between the storage and the local database is now prevented.`;
|
|
109
|
+
if (settings.maxMTimeForReflectEvents > 0) {
|
|
110
|
+
errorManager.showError(MSG_IN_REMEDIATION, LOG_LEVEL_NOTICE);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
errorManager.clearError(MSG_IN_REMEDIATION);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
function convertCase(settings, path) {
|
|
117
|
+
if (settings.handleFilenameCaseSensitive) {
|
|
118
|
+
return path;
|
|
119
|
+
}
|
|
120
|
+
return path.toLowerCase();
|
|
121
|
+
}
|
|
122
|
+
async function collectFilesOnStorage(host, settings, log) {
|
|
123
|
+
log("Collecting local files on the storage", LOG_LEVEL_VERBOSE);
|
|
124
|
+
const filesStorageSrc = await host.serviceModules.storageAccess.getFiles();
|
|
125
|
+
const _filesStorage = [];
|
|
126
|
+
for (const f of filesStorageSrc) {
|
|
127
|
+
if (await host.services.vault.isTargetFile(f.path)) {
|
|
128
|
+
_filesStorage.push(f);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const storageFileNameMap = Object.fromEntries(_filesStorage.map((e) => [e.path, e]));
|
|
132
|
+
const storageFileNames = Object.keys(storageFileNameMap);
|
|
133
|
+
const storageFileNameCapsPair = storageFileNames.map((e) => [e, convertCase(settings, e)]);
|
|
134
|
+
const storageFileNameCI2CS = Object.fromEntries(storageFileNameCapsPair.map((e) => [e[1], e[0]]));
|
|
135
|
+
return { storageFileNameMap, storageFileNames, storageFileNameCI2CS };
|
|
136
|
+
}
|
|
137
|
+
async function collectDatabaseFiles(host, settings, log, showingNotice) {
|
|
138
|
+
log("Collecting local files on the DB", LOG_LEVEL_VERBOSE);
|
|
139
|
+
const _DBEntries = [];
|
|
140
|
+
let count = 0;
|
|
141
|
+
for await (const doc of host.services.database.localDatabase.findAllNormalDocs({ conflicts: true }) || []) {
|
|
142
|
+
count++;
|
|
143
|
+
if (count % 25 === 0)
|
|
144
|
+
log(
|
|
145
|
+
`Collecting local files on the DB: ${count}`,
|
|
146
|
+
showingNotice ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO,
|
|
147
|
+
"syncAll"
|
|
148
|
+
);
|
|
149
|
+
const path = getPathFromEntry(host, doc);
|
|
150
|
+
if (host.services.vault.isValidPath(path) && await host.services.vault.isTargetFile(path)) {
|
|
151
|
+
if (!isMetaEntry(doc)) {
|
|
152
|
+
log(`Invalid entry: ${path}`, LOG_LEVEL_INFO);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
_DBEntries.push(doc);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const databaseFileNameMap = Object.fromEntries(_DBEntries.map((e) => [getPathFromEntry(host, e), e]));
|
|
159
|
+
const databaseFileNames = Object.keys(databaseFileNameMap);
|
|
160
|
+
const databaseFileNameCapsPair = databaseFileNames.map((e) => [e, convertCase(settings, e)]);
|
|
161
|
+
const databaseFileNameCI2CS = Object.fromEntries(databaseFileNameCapsPair.map((e) => [e[1], e[0]]));
|
|
162
|
+
return { databaseFileNameMap, databaseFileNames, databaseFileNameCI2CS };
|
|
163
|
+
}
|
|
164
|
+
async function updateToDatabase(host, log, logLevel, file) {
|
|
165
|
+
if (!host.services.vault.isFileSizeTooLarge(file.stat.size)) {
|
|
166
|
+
const path = file.path;
|
|
167
|
+
await host.serviceModules.fileHandler.storeFileToDB(file);
|
|
168
|
+
host.services.context.events.emitEvent("event-file-changed", { file: path, automated: true });
|
|
169
|
+
} else {
|
|
170
|
+
log(`UPDATE DATABASE: ${file.path} has been skipped due to file size exceeding the limit`, logLevel);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async function updateToStorage(host, log, logLevel, w) {
|
|
174
|
+
const path = getPathFromEntry(host, w);
|
|
175
|
+
if (w && !(w.deleted || w._deleted)) {
|
|
176
|
+
if (!host.services.vault.isFileSizeTooLarge(w.size)) {
|
|
177
|
+
if ((w._conflicts?.length ?? 0) > 0) {
|
|
178
|
+
log(`UPDATE STORAGE: ${path} has conflicts. skipped (x)`, LOG_LEVEL_INFO);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
await host.serviceModules.fileHandler.dbToStorage(path, null, true);
|
|
182
|
+
host.services.context.events.emitEvent("event-file-changed", {
|
|
183
|
+
file: path,
|
|
184
|
+
automated: true
|
|
185
|
+
});
|
|
186
|
+
log(`Check or pull from db:${path} OK`);
|
|
187
|
+
} else {
|
|
188
|
+
log(`UPDATE STORAGE: ${path} has been skipped due to file size exceeding the limit`, logLevel);
|
|
189
|
+
}
|
|
190
|
+
} else if (w) {
|
|
191
|
+
log(`Deletion history skipped: ${path}`, LOG_LEVEL_VERBOSE);
|
|
192
|
+
} else {
|
|
193
|
+
log(`entry not found: ${path}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function syncStorageAndDatabase(host, log, file, logLevel, doc) {
|
|
197
|
+
if ((doc._conflicts?.length ?? 0) > 0) {
|
|
198
|
+
log(`SYNC DATABASE AND STORAGE: ${file.path} has conflicts. skipped`, LOG_LEVEL_INFO);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (!host.services.vault.isFileSizeTooLarge(file.stat.size) && !host.services.vault.isFileSizeTooLarge(doc.size)) {
|
|
202
|
+
await syncFileBetweenDBandStorage(host, log, file, doc);
|
|
203
|
+
} else {
|
|
204
|
+
log(
|
|
205
|
+
`SYNC DATABASE AND STORAGE: ${getPathFromEntry(host, doc)} has been skipped due to file size exceeding the limit`,
|
|
206
|
+
logLevel
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const FullScanModes = {
|
|
211
|
+
// SAFE: "safe",
|
|
212
|
+
DB_APPLY: "db-apply",
|
|
213
|
+
NEWER_WINS: "newer-wins"
|
|
214
|
+
// STORAGE_ONLY: "local-only",
|
|
215
|
+
};
|
|
216
|
+
const ExtraOnRemote = {
|
|
217
|
+
/**
|
|
218
|
+
* Delete database entries if they are missing on storage.
|
|
219
|
+
*/
|
|
220
|
+
DELETE_LOCAL_MISSING: "delete-local-missing"
|
|
221
|
+
/**
|
|
222
|
+
* Apply changes from database to storage.
|
|
223
|
+
*/
|
|
224
|
+
// APPEND_DB_ONLY: "append-db-only",
|
|
225
|
+
};
|
|
226
|
+
const ExtraOnLocal = {
|
|
227
|
+
/**
|
|
228
|
+
* Delete local files if they were deleted on database.
|
|
229
|
+
*/
|
|
230
|
+
DELETE_DB_DELETED: "delete-db-deleted",
|
|
231
|
+
/**
|
|
232
|
+
* Delete local files if they are missing on database or were deleted on database.
|
|
233
|
+
*/
|
|
234
|
+
DELETE_DB_MISSING: "delete-db-missing",
|
|
235
|
+
/**
|
|
236
|
+
* Merge local files to database
|
|
237
|
+
*/
|
|
238
|
+
APPEND_STORAGE_ONLY: "append-storage-only"
|
|
239
|
+
};
|
|
240
|
+
function isDeletedEntry(entry) {
|
|
241
|
+
return entry.deleted || entry._deleted || false;
|
|
242
|
+
}
|
|
243
|
+
function getFilePairState(pair) {
|
|
244
|
+
const { file, doc } = pair;
|
|
245
|
+
if (file && doc) {
|
|
246
|
+
return isDeletedEntry(doc) ? "both-db-deleted" : "both";
|
|
247
|
+
}
|
|
248
|
+
if (file) {
|
|
249
|
+
return "storage-only";
|
|
250
|
+
}
|
|
251
|
+
if (doc) {
|
|
252
|
+
return isDeletedEntry(doc) ? "db-only-deleted" : "db-only";
|
|
253
|
+
}
|
|
254
|
+
throw new Error("Corrupted file pair");
|
|
255
|
+
}
|
|
256
|
+
function shouldDeleteLocalWhenRemoteMissing(options) {
|
|
257
|
+
return options.extraOnRemote === ExtraOnRemote.DELETE_LOCAL_MISSING || options.extraOnLocal === ExtraOnLocal.DELETE_DB_MISSING;
|
|
258
|
+
}
|
|
259
|
+
function shouldDeleteLocalWhenRemoteDeleted(options) {
|
|
260
|
+
return options.extraOnRemote === ExtraOnRemote.DELETE_LOCAL_MISSING || options.extraOnLocal === ExtraOnLocal.DELETE_DB_DELETED || options.extraOnLocal === ExtraOnLocal.DELETE_DB_MISSING;
|
|
261
|
+
}
|
|
262
|
+
function resolveFilePairAction(state, options) {
|
|
263
|
+
switch (options.mode) {
|
|
264
|
+
case FullScanModes.DB_APPLY:
|
|
265
|
+
switch (state) {
|
|
266
|
+
case "both":
|
|
267
|
+
case "db-only":
|
|
268
|
+
return "update-storage";
|
|
269
|
+
case "storage-only":
|
|
270
|
+
return shouldDeleteLocalWhenRemoteMissing(options) ? "delete-local" : "skip";
|
|
271
|
+
case "both-db-deleted":
|
|
272
|
+
return shouldDeleteLocalWhenRemoteDeleted(options) ? "delete-local" : "skip";
|
|
273
|
+
case "db-only-deleted":
|
|
274
|
+
return "skip";
|
|
275
|
+
}
|
|
276
|
+
break;
|
|
277
|
+
case FullScanModes.NEWER_WINS:
|
|
278
|
+
switch (state) {
|
|
279
|
+
case "both":
|
|
280
|
+
return "sync-newer";
|
|
281
|
+
case "storage-only":
|
|
282
|
+
return shouldDeleteLocalWhenRemoteMissing(options) ? "delete-local" : "update-db";
|
|
283
|
+
case "db-only":
|
|
284
|
+
return "update-storage";
|
|
285
|
+
case "both-db-deleted":
|
|
286
|
+
if (shouldDeleteLocalWhenRemoteDeleted(options)) {
|
|
287
|
+
return "delete-local";
|
|
288
|
+
}
|
|
289
|
+
return options.extraOnLocal === ExtraOnLocal.APPEND_STORAGE_ONLY ? "update-db" : "skip";
|
|
290
|
+
case "db-only-deleted":
|
|
291
|
+
return "skip";
|
|
292
|
+
}
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
return "skip";
|
|
296
|
+
}
|
|
297
|
+
async function processFilePair(host, log, pair, options) {
|
|
298
|
+
const { file, doc } = pair;
|
|
299
|
+
const canonicalPath = doc ? getPathFromEntry(host, doc) : file?.path;
|
|
300
|
+
if (!canonicalPath) {
|
|
301
|
+
throw new Error("Corrupted file pair");
|
|
302
|
+
}
|
|
303
|
+
const path = canonicalPath;
|
|
304
|
+
const fileMapKey = convertCase(host.services.setting.currentSettings(), canonicalPath);
|
|
305
|
+
if (file) {
|
|
306
|
+
updateFileMTimeInMap(host, fileMapKey, file.stat.mtime);
|
|
307
|
+
}
|
|
308
|
+
if (doc && (doc._conflicts?.length ?? 0) > 0) {
|
|
309
|
+
log(`SKIP ${options.mode}: ${path} has conflicts`, LOG_LEVEL_INFO);
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
const state = getFilePairState(pair);
|
|
313
|
+
let action = resolveFilePairAction(state, options);
|
|
314
|
+
if (options.mode === FullScanModes.NEWER_WINS && state === "db-only" && doc) {
|
|
315
|
+
const lastSeenMTime = getFileMTimeFromMap(fileMapKey);
|
|
316
|
+
if (lastSeenMTime !== void 0) {
|
|
317
|
+
const recency = compareMTime(lastSeenMTime, doc.mtime);
|
|
318
|
+
if (recency === BASE_IS_NEW || recency === EVEN) {
|
|
319
|
+
action = "delete-db";
|
|
320
|
+
log(`NEWER_WINS: Treating missing local file as deletion (${path})`, LOG_LEVEL_VERBOSE);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
switch (action) {
|
|
326
|
+
case "update-db":
|
|
327
|
+
if (!file) {
|
|
328
|
+
throw new Error(`Missing storage file for ${path}`);
|
|
329
|
+
}
|
|
330
|
+
await updateToDatabase(host, log, LOG_LEVEL_INFO, file);
|
|
331
|
+
return true;
|
|
332
|
+
case "update-storage":
|
|
333
|
+
if (!doc) {
|
|
334
|
+
throw new Error(`Missing database entry for ${path}`);
|
|
335
|
+
}
|
|
336
|
+
await updateToStorage(host, log, LOG_LEVEL_INFO, doc);
|
|
337
|
+
updateFileMTimeInMap(host, fileMapKey, doc.mtime);
|
|
338
|
+
return true;
|
|
339
|
+
case "sync-newer":
|
|
340
|
+
if (!file || !doc) {
|
|
341
|
+
throw new Error(`Cannot compare freshness for ${path}`);
|
|
342
|
+
}
|
|
343
|
+
await syncStorageAndDatabase(host, log, file, LOG_LEVEL_INFO, doc);
|
|
344
|
+
updateFileMTimeInMap(host, fileMapKey, Math.max(file.stat.mtime, doc.mtime));
|
|
345
|
+
return true;
|
|
346
|
+
case "delete-local":
|
|
347
|
+
if (!file) {
|
|
348
|
+
log(`DELETE LOCAL: ${path} is already absent from storage`, LOG_LEVEL_VERBOSE);
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
log(`DELETE LOCAL: ${file.path}`, LOG_LEVEL_INFO);
|
|
352
|
+
await host.serviceModules.storageAccess.delete(file.path, true);
|
|
353
|
+
fileMaps.delete(fileMapKey);
|
|
354
|
+
saveFileStatus(host);
|
|
355
|
+
return true;
|
|
356
|
+
case "delete-db": {
|
|
357
|
+
if (!doc) {
|
|
358
|
+
throw new Error(`Missing database entry for ${path}`);
|
|
359
|
+
}
|
|
360
|
+
log(`DELETE DATABASE: ${path}`, LOG_LEVEL_INFO);
|
|
361
|
+
const dbDeleted = await host.serviceModules.fileHandler.deleteFileFromDB(stripAllPrefixes(path));
|
|
362
|
+
if (dbDeleted) {
|
|
363
|
+
fileMaps.delete(fileMapKey);
|
|
364
|
+
saveFileStatus(host);
|
|
365
|
+
} else {
|
|
366
|
+
log(
|
|
367
|
+
`DELETE DATABASE did not delete ${path}; keeping last-seen record to avoid resurrecting the file`,
|
|
368
|
+
LOG_LEVEL_NOTICE
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
return true;
|
|
372
|
+
}
|
|
373
|
+
case "skip":
|
|
374
|
+
log(`SKIP ${options.mode}: ${path} (${state})`, LOG_LEVEL_VERBOSE);
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
} catch (ex) {
|
|
378
|
+
log(`Error processing ${path} with action ${action}`, LOG_LEVEL_NOTICE);
|
|
379
|
+
log(ex, LOG_LEVEL_VERBOSE);
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
async function synchroniseAllFilesBetweenDBandStorage(host, log, errorManager, options) {
|
|
384
|
+
const settings = host.services.setting.currentSettings();
|
|
385
|
+
const showingNotice = options.showingNotice ?? false;
|
|
386
|
+
await loadFileStatus(host);
|
|
387
|
+
const { storageFileNameMap, storageFileNameCI2CS } = await collectFilesOnStorage(host, settings, log);
|
|
388
|
+
const { databaseFileNameMap, databaseFileNameCI2CS } = await collectDatabaseFiles(
|
|
389
|
+
host,
|
|
390
|
+
settings,
|
|
391
|
+
log,
|
|
392
|
+
showingNotice
|
|
393
|
+
);
|
|
394
|
+
const pairs = [];
|
|
395
|
+
for (const fileNameLC of unique([
|
|
396
|
+
...Object.keys(storageFileNameCI2CS),
|
|
397
|
+
...Object.keys(databaseFileNameCI2CS)
|
|
398
|
+
])) {
|
|
399
|
+
const fileName = fileNameLC in storageFileNameCI2CS ? storageFileNameCI2CS[fileNameLC] : void 0;
|
|
400
|
+
const file = fileName ? storageFileNameMap[fileName] : void 0;
|
|
401
|
+
const databaseName = fileNameLC in databaseFileNameCI2CS ? databaseFileNameCI2CS[fileNameLC] : void 0;
|
|
402
|
+
const doc = databaseName ? databaseFileNameMap[databaseName] : void 0;
|
|
403
|
+
const pair = { file, doc };
|
|
404
|
+
pairs.push(pair);
|
|
405
|
+
}
|
|
406
|
+
log(`Total files to synchronise: ${pairs.length}`, LOG_LEVEL_VERBOSE, "syncAll");
|
|
407
|
+
let successCount = 0;
|
|
408
|
+
let processedCount = 0;
|
|
409
|
+
for await (const result of withConcurrency(
|
|
410
|
+
pairs,
|
|
411
|
+
async (e) => {
|
|
412
|
+
try {
|
|
413
|
+
return await processFilePair(host, log, e, options);
|
|
414
|
+
} catch (ex) {
|
|
415
|
+
log(`Error while synchronising files`, LOG_LEVEL_NOTICE);
|
|
416
|
+
log(ex, LOG_LEVEL_VERBOSE);
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
10
|
|
421
|
+
)) {
|
|
422
|
+
processedCount++;
|
|
423
|
+
if (result) {
|
|
424
|
+
successCount++;
|
|
425
|
+
}
|
|
426
|
+
if (processedCount % 25 === 0) {
|
|
427
|
+
log(
|
|
428
|
+
`Processing: ${processedCount}/${pairs.length}`,
|
|
429
|
+
showingNotice ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO,
|
|
430
|
+
"syncAll"
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
log(
|
|
435
|
+
`Synchronisation completed: ${successCount}/${processedCount} files processed successfully`,
|
|
436
|
+
showingNotice ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO,
|
|
437
|
+
"syncAll"
|
|
438
|
+
);
|
|
439
|
+
saveFileStatus(host, true);
|
|
440
|
+
return successCount === processedCount;
|
|
441
|
+
}
|
|
442
|
+
function normaliseFullScanOptions(showingNoticeOrOptions, ignoreSuspending = false) {
|
|
443
|
+
if (typeof showingNoticeOrOptions === "object") {
|
|
444
|
+
return {
|
|
445
|
+
mode: FullScanModes.NEWER_WINS,
|
|
446
|
+
...showingNoticeOrOptions
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
return {
|
|
450
|
+
mode: FullScanModes.NEWER_WINS,
|
|
451
|
+
showingNotice: showingNoticeOrOptions ?? false,
|
|
452
|
+
ignoreSuspending
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
let fileMaps = /* @__PURE__ */ new Map();
|
|
456
|
+
async function loadFileStatus(host) {
|
|
457
|
+
const kvDB = host.services.keyValueDB.kvDB;
|
|
458
|
+
if (!kvDB?.get) {
|
|
459
|
+
fileMaps = /* @__PURE__ */ new Map();
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
const mapItems = await kvDB.get("fileStatusMap") || {};
|
|
463
|
+
fileMaps = new Map(Object.entries(mapItems));
|
|
464
|
+
}
|
|
465
|
+
async function _saveFileStatus(host) {
|
|
466
|
+
const kvDB = host.services.keyValueDB.kvDB;
|
|
467
|
+
if (!kvDB?.set) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
await kvDB.set("fileStatusMap", Object.fromEntries(fileMaps));
|
|
471
|
+
}
|
|
472
|
+
let saveFileStatusTimeout = null;
|
|
473
|
+
function saveFileStatus(host, immediate = false) {
|
|
474
|
+
if (immediate) {
|
|
475
|
+
if (saveFileStatusTimeout !== null) compatGlobal.clearTimeout(saveFileStatusTimeout);
|
|
476
|
+
saveFileStatusTimeout = compatGlobal.setTimeout(() => {
|
|
477
|
+
saveFileStatusTimeout = null;
|
|
478
|
+
void _saveFileStatus(host);
|
|
479
|
+
}, 0);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (saveFileStatusTimeout === null) {
|
|
483
|
+
saveFileStatusTimeout = compatGlobal.setTimeout(() => {
|
|
484
|
+
saveFileStatusTimeout = null;
|
|
485
|
+
void _saveFileStatus(host);
|
|
486
|
+
}, 1e3);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
function updateFileMTimeInMap(host, key, mtime) {
|
|
490
|
+
fileMaps.set(key, mtime);
|
|
491
|
+
saveFileStatus(host);
|
|
492
|
+
}
|
|
493
|
+
function getFileMTimeFromMap(key) {
|
|
494
|
+
return fileMaps.get(key);
|
|
495
|
+
}
|
|
496
|
+
async function performFullScan(host, log, errorManager, showingNoticeOrOptions = false, ignoreSuspending = false) {
|
|
497
|
+
const options = normaliseFullScanOptions(showingNoticeOrOptions, ignoreSuspending);
|
|
498
|
+
const showingNotice = options.showingNotice ?? false;
|
|
499
|
+
const shouldIgnoreSuspending = options.ignoreSuspending ?? false;
|
|
500
|
+
if (!canProceedScan(host, errorManager, log, showingNotice, shouldIgnoreSuspending)) {
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
log("Opening the key-value database", LOG_LEVEL_VERBOSE);
|
|
504
|
+
const isInitialized = await host.services.keyValueDB.kvDB.get("initialized") || false;
|
|
505
|
+
if (showingNotice) {
|
|
506
|
+
log("Initializing", LOG_LEVEL_NOTICE, "syncAll");
|
|
507
|
+
}
|
|
508
|
+
if (isInitialized) {
|
|
509
|
+
log("Restoring storage state", LOG_LEVEL_VERBOSE);
|
|
510
|
+
await host.serviceModules.storageAccess.restoreState();
|
|
511
|
+
}
|
|
512
|
+
log("Initialize and checking database files");
|
|
513
|
+
log("Checking deleted files");
|
|
514
|
+
await collectDeletedFiles(host, log);
|
|
515
|
+
await synchroniseAllFilesBetweenDBandStorage(host, log, errorManager, options);
|
|
516
|
+
log("Initialized, NOW TRACKING!");
|
|
517
|
+
if (!isInitialized) {
|
|
518
|
+
await host.services.keyValueDB.kvDB.set("initialized", true);
|
|
519
|
+
}
|
|
520
|
+
if (showingNotice) {
|
|
521
|
+
log("Initialize done!", LOG_LEVEL_NOTICE, "syncAll");
|
|
522
|
+
}
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
525
|
+
function useOfflineScanner(host) {
|
|
526
|
+
const log = createInstanceLogFunction("SF:OfflineScanner", host.services.API);
|
|
527
|
+
const errorManager = new UnresolvedErrorManager(host.services.appLifecycle, host.services.context.events);
|
|
528
|
+
const handleScanVault = async (showingNotice, ignoreSuspending = false) => {
|
|
529
|
+
return await performFullScan(host, log, errorManager, showingNotice, ignoreSuspending);
|
|
530
|
+
};
|
|
531
|
+
host.services.vault.scanVault.addHandler(handleScanVault);
|
|
532
|
+
}
|
|
533
|
+
export {
|
|
534
|
+
ExtraOnLocal,
|
|
535
|
+
ExtraOnRemote,
|
|
536
|
+
FullScanModes,
|
|
537
|
+
canProceedScan,
|
|
538
|
+
collectDatabaseFiles,
|
|
539
|
+
collectDeletedFiles,
|
|
540
|
+
collectFilesOnStorage,
|
|
541
|
+
convertCase,
|
|
542
|
+
getFilePairState,
|
|
543
|
+
getPathFromEntry,
|
|
544
|
+
normaliseFullScanOptions,
|
|
545
|
+
performFullScan,
|
|
546
|
+
resolveFilePairAction,
|
|
547
|
+
syncFileBetweenDBandStorage,
|
|
548
|
+
syncStorageAndDatabase,
|
|
549
|
+
synchroniseAllFilesBetweenDBandStorage,
|
|
550
|
+
updateToDatabase,
|
|
551
|
+
updateToStorage,
|
|
552
|
+
useOfflineScanner
|
|
553
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { NecessaryServices } from "../interfaces/ServiceModule.js";
|
|
2
|
+
import { UnresolvedErrorManager } from "../services/base/UnresolvedErrorManager.js";
|
|
3
|
+
import { type LogFunction } from "../services/lib/logUtils.js";
|
|
4
|
+
/**
|
|
5
|
+
* Initialise the database and trigger a full vault scan.
|
|
6
|
+
* @param host Services container
|
|
7
|
+
* @param log Logging function
|
|
8
|
+
* @param errorManager Error manager
|
|
9
|
+
* @param showingNotice Whether to show notices during initialisation
|
|
10
|
+
* @param reopenDatabase Whether to reopen the database connection
|
|
11
|
+
* @param ignoreSuspending Whether to ignore suspension settings
|
|
12
|
+
* @returns True if initialisation succeeded
|
|
13
|
+
*/
|
|
14
|
+
export declare function prepareDatabaseForUse(host: NecessaryServices<"appLifecycle" | "setting" | "vault" | "path" | "database" | "databaseEvents" | "fileProcessing" | "replicator", never>, log: LogFunction, errorManager: UnresolvedErrorManager, showingNotice?: boolean, reopenDatabase?: boolean, ignoreSuspending?: boolean): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Associate the initialiser file feature with the app lifecycle events.
|
|
17
|
+
* This function binds initialization handlers to the appropriate lifecycle events.
|
|
18
|
+
* @param host Services container with required dependencies
|
|
19
|
+
*/
|
|
20
|
+
export declare function usePrepareDatabaseForUse(host: NecessaryServices<"API" | "appLifecycle" | "setting" | "vault" | "path" | "database" | "databaseEvents" | "fileProcessing" | "replicator", never>): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LOG_LEVEL_NOTICE } from "octagonal-wheels/common/logger";
|
|
2
|
+
import { UnresolvedErrorManager } from "../services/base/UnresolvedErrorManager.js";
|
|
3
|
+
import { createInstanceLogFunction } from "../services/lib/logUtils.js";
|
|
4
|
+
async function prepareDatabaseForUse(host, log, errorManager, showingNotice = false, reopenDatabase = true, ignoreSuspending = false) {
|
|
5
|
+
const appLifecycle = host.services.appLifecycle;
|
|
6
|
+
appLifecycle.resetIsReady();
|
|
7
|
+
if (!reopenDatabase || await host.services.database.openDatabase({
|
|
8
|
+
databaseEvents: host.services.databaseEvents,
|
|
9
|
+
replicator: host.services.replicator
|
|
10
|
+
})) {
|
|
11
|
+
if (host.services.database.localDatabase.isReady) {
|
|
12
|
+
await host.services.vault.scanVault(showingNotice, ignoreSuspending);
|
|
13
|
+
}
|
|
14
|
+
const ERR_INITIALISATION_FAILED = `Initializing database has been failed on some module!`;
|
|
15
|
+
if (!await host.services.databaseEvents.onDatabaseInitialised(showingNotice)) {
|
|
16
|
+
errorManager.showError(ERR_INITIALISATION_FAILED, LOG_LEVEL_NOTICE);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
errorManager.clearError(ERR_INITIALISATION_FAILED);
|
|
20
|
+
appLifecycle.markIsReady();
|
|
21
|
+
await host.services.fileProcessing.commitPendingFileEvents();
|
|
22
|
+
return true;
|
|
23
|
+
} else {
|
|
24
|
+
appLifecycle.resetIsReady();
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function usePrepareDatabaseForUse(host) {
|
|
29
|
+
const log = createInstanceLogFunction("SF:prepareDatabaseForUse", host.services.API);
|
|
30
|
+
const errorManager = new UnresolvedErrorManager(host.services.appLifecycle, host.services.context.events);
|
|
31
|
+
const initialiseDatabaseHandler = async (showingNotice = false, reopenDatabase = true, ignoreSuspending = false) => {
|
|
32
|
+
return await prepareDatabaseForUse(host, log, errorManager, showingNotice, reopenDatabase, ignoreSuspending);
|
|
33
|
+
};
|
|
34
|
+
host.services.databaseEvents.initialiseDatabase.addHandler(initialiseDatabaseHandler);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
prepareDatabaseForUse,
|
|
38
|
+
usePrepareDatabaseForUse
|
|
39
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type LOG_LEVEL } from "../common/logger.js";
|
|
2
|
+
import type { ObsidianLiveSyncSettings } from "../common/models/setting.type.js";
|
|
3
|
+
import type { NecessaryServices } from "../interfaces/ServiceModule.js";
|
|
4
|
+
export type RemoteConfigHost = NecessaryServices<"setting" | "UI" | "replication" | "control" | "appLifecycle" | "API", never>;
|
|
5
|
+
export declare function migrateLegacyRemoteConfigurationsInPlace(settings: ObsidianLiveSyncSettings, log?: (message: string, level?: LOG_LEVEL) => void): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Generate a unique ID for a new remote configuration.
|
|
8
|
+
* @returns A unique string identifier.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createRemoteConfigurationId(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Keep compatibility for users who were already using P2P as their main active remote.
|
|
13
|
+
*/
|
|
14
|
+
export declare function migrateP2PActiveRemoteConfigurationIdInPlace(settings: ObsidianLiveSyncSettings): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* SF:RemoteConfig - Service Feature for Remote Configuration Management
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Migrates existing flat settings to the new multiple remote configurations list.
|
|
20
|
+
*/
|
|
21
|
+
export declare function migrateToMultipleRemoteConfigurations(host: RemoteConfigHost): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Logic to switch the active configuration.
|
|
24
|
+
*/
|
|
25
|
+
export declare function activateRemoteConfiguration(settings: ObsidianLiveSyncSettings, id: string): ObsidianLiveSyncSettings | false;
|
|
26
|
+
/**
|
|
27
|
+
* Apply a dedicated P2P remote configuration onto runtime P2P-related fields,
|
|
28
|
+
* while keeping the current `remoteType` unchanged.
|
|
29
|
+
*/
|
|
30
|
+
export declare function activateP2PRemoteConfiguration(settings: ObsidianLiveSyncSettings, id: string): ObsidianLiveSyncSettings | false;
|
|
31
|
+
/**
|
|
32
|
+
* Command: Switch Active Remote
|
|
33
|
+
*/
|
|
34
|
+
export declare function commandSwitchActiveRemote(host: RemoteConfigHost): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Command: Replicate with specific remote
|
|
37
|
+
*/
|
|
38
|
+
export declare function commandReplicateWithSpecificRemote(host: RemoteConfigHost): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Migration feature to be used during initialisation.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useRemoteConfigurationMigration(host: RemoteConfigHost): void;
|
|
43
|
+
/**
|
|
44
|
+
* Hook to set up remote configuration features (Commands).
|
|
45
|
+
*/
|
|
46
|
+
export declare function useRemoteConfiguration(host: RemoteConfigHost): boolean;
|