@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,38 @@
|
|
|
1
|
+
import type { IDatabaseEventService } from "./IService.js";
|
|
2
|
+
import { ServiceBase, type ServiceContext } from "./ServiceBase.js";
|
|
3
|
+
/**
|
|
4
|
+
* The DatabaseEventService provides methods for handling database lifecycle events.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class DatabaseEventService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements IDatabaseEventService {
|
|
7
|
+
/**
|
|
8
|
+
* Event triggered when the database is about to be unloaded.
|
|
9
|
+
*/
|
|
10
|
+
readonly onUnloadDatabase: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(db: import("../../pouchdb/LiveSyncLocalDB.js").LiveSyncLocalDB) => Promise<boolean>>;
|
|
11
|
+
/**
|
|
12
|
+
* Event triggered when the database is about to be closed.
|
|
13
|
+
*/
|
|
14
|
+
readonly onCloseDatabase: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(db: import("../../pouchdb/LiveSyncLocalDB.js").LiveSyncLocalDB) => Promise<boolean>>;
|
|
15
|
+
/**
|
|
16
|
+
* Event triggered when the database is being initialized.
|
|
17
|
+
*/
|
|
18
|
+
readonly onDatabaseInitialisation: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(db: import("../../pouchdb/LiveSyncLocalDB.js").LiveSyncLocalDB) => Promise<boolean>>;
|
|
19
|
+
/**
|
|
20
|
+
* Event triggered when the database has been initialized.
|
|
21
|
+
*/
|
|
22
|
+
readonly onDatabaseInitialised: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(showNotice: boolean) => Promise<boolean>>;
|
|
23
|
+
/**
|
|
24
|
+
* Event triggered when the database is being reset.
|
|
25
|
+
*/
|
|
26
|
+
readonly onResetDatabase: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(db: import("../../pouchdb/LiveSyncLocalDB.js").LiveSyncLocalDB) => Promise<boolean>>;
|
|
27
|
+
/**
|
|
28
|
+
* Event triggered when the database is ready for use.
|
|
29
|
+
*/
|
|
30
|
+
readonly onDatabaseHasReady: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the database.
|
|
33
|
+
* @param showingNotice Whether to show a notice to the user.
|
|
34
|
+
* @param reopenDatabase Whether to reopen the database if it is already open.
|
|
35
|
+
* @param ignoreSuspending Whether to ignore any suspending state.
|
|
36
|
+
*/
|
|
37
|
+
readonly initialiseDatabase: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(showingNotice?: boolean, reopenDatabase?: boolean, ignoreSuspending?: boolean) => Promise<boolean>>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { handlers } from "../lib/HandlerUtils.js";
|
|
2
|
+
import { ServiceBase } from "./ServiceBase.js";
|
|
3
|
+
class DatabaseEventService extends ServiceBase {
|
|
4
|
+
/**
|
|
5
|
+
* Event triggered when the database is about to be unloaded.
|
|
6
|
+
*/
|
|
7
|
+
onUnloadDatabase = handlers().all("onUnloadDatabase");
|
|
8
|
+
/**
|
|
9
|
+
* Event triggered when the database is about to be closed.
|
|
10
|
+
*/
|
|
11
|
+
onCloseDatabase = handlers().all("onCloseDatabase");
|
|
12
|
+
/**
|
|
13
|
+
* Event triggered when the database is being initialized.
|
|
14
|
+
*/
|
|
15
|
+
onDatabaseInitialisation = handlers().bailFirstFailure("onDatabaseInitialisation");
|
|
16
|
+
/**
|
|
17
|
+
* Event triggered when the database has been initialized.
|
|
18
|
+
*/
|
|
19
|
+
onDatabaseInitialised = handlers().bailFirstFailure("onDatabaseInitialised");
|
|
20
|
+
/**
|
|
21
|
+
* Event triggered when the database is being reset.
|
|
22
|
+
*/
|
|
23
|
+
onResetDatabase = handlers().bailFirstFailure("onResetDatabase");
|
|
24
|
+
/**
|
|
25
|
+
* Event triggered when the database is ready for use.
|
|
26
|
+
*/
|
|
27
|
+
onDatabaseHasReady = handlers().bailFirstFailure("onDatabaseHasReady");
|
|
28
|
+
/**
|
|
29
|
+
* Initialize the database.
|
|
30
|
+
* @param showingNotice Whether to show a notice to the user.
|
|
31
|
+
* @param reopenDatabase Whether to reopen the database if it is already open.
|
|
32
|
+
* @param ignoreSuspending Whether to ignore any suspending state.
|
|
33
|
+
*/
|
|
34
|
+
initialiseDatabase = handlers().bailFirstFailure("initialiseDatabase");
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
DatabaseEventService
|
|
38
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { IDatabaseService, IPathService, IVaultService, openDatabaseParameters } from "./IService.js";
|
|
2
|
+
import { ServiceBase, type ServiceContext } from "./ServiceBase.js";
|
|
3
|
+
import { LiveSyncLocalDB } from "../../pouchdb/LiveSyncLocalDB.js";
|
|
4
|
+
import type { PouchDBConstructor } from "../../pouchdb/PouchDBConstructor.js";
|
|
5
|
+
import type { SettingService } from "./SettingService.js";
|
|
6
|
+
import type { APIService } from "./APIService.js";
|
|
7
|
+
import type { ObsidianLiveSyncSettings } from "../../common/models/setting.type.js";
|
|
8
|
+
export type DatabaseServiceDependencies = {
|
|
9
|
+
/** PouchDB with the adapters required by the host runtime already registered. */
|
|
10
|
+
pouchDB: PouchDBConstructor;
|
|
11
|
+
path: IPathService;
|
|
12
|
+
vault: IVaultService;
|
|
13
|
+
setting: SettingService;
|
|
14
|
+
API: APIService;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The DatabaseService provides methods for managing the local database.
|
|
18
|
+
* Please note that each event of database lifecycle is handled in DatabaseEventService.
|
|
19
|
+
*/
|
|
20
|
+
export declare abstract class DatabaseService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements IDatabaseService {
|
|
21
|
+
_log: (msg: unknown, level?: import("octagonal-wheels/common/logger").LOG_LEVEL, key?: string) => void;
|
|
22
|
+
constructor(context: T, dependencies: DatabaseServiceDependencies);
|
|
23
|
+
protected _localDatabase: LiveSyncLocalDB | null;
|
|
24
|
+
protected services: DatabaseServiceDependencies;
|
|
25
|
+
onOpenDatabase: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(vaultName: string) => Promise<boolean>>;
|
|
26
|
+
/**
|
|
27
|
+
* Called after the local database has been reset.
|
|
28
|
+
*/
|
|
29
|
+
onDatabaseReset: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
|
|
30
|
+
get localDatabase(): LiveSyncLocalDB;
|
|
31
|
+
get localDatabaseDirect(): LiveSyncLocalDB;
|
|
32
|
+
protected modifyDatabaseOptions(settings: ObsidianLiveSyncSettings, name: string, options: PouchDB.Configuration.DatabaseConfiguration): {
|
|
33
|
+
name: string;
|
|
34
|
+
options: PouchDB.Configuration.DatabaseConfiguration;
|
|
35
|
+
};
|
|
36
|
+
createPouchDBInstance<T extends object>(name?: string, options?: PouchDB.Configuration.DatabaseConfiguration): PouchDB.Database<T>;
|
|
37
|
+
openDatabase(params: openDatabaseParameters): Promise<boolean>;
|
|
38
|
+
isDatabaseReady(): boolean;
|
|
39
|
+
resetDatabase(): Promise<boolean>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ServiceBase } from "./ServiceBase.js";
|
|
2
|
+
import { LiveSyncLocalDB } from "../../pouchdb/LiveSyncLocalDB.js";
|
|
3
|
+
import { handlers } from "../lib/HandlerUtils.js";
|
|
4
|
+
import { createInstanceLogFunction } from "../lib/logUtils.js";
|
|
5
|
+
import { ExtraSuffixIndexedDB } from "../../common/models/shared.const.js";
|
|
6
|
+
class DatabaseService extends ServiceBase {
|
|
7
|
+
_log = createInstanceLogFunction("InjectableDatabaseService");
|
|
8
|
+
constructor(context, dependencies) {
|
|
9
|
+
super(context);
|
|
10
|
+
this.services = dependencies;
|
|
11
|
+
}
|
|
12
|
+
_localDatabase = null;
|
|
13
|
+
services;
|
|
14
|
+
// Additional process when opening database, such as initialising managers or local database instance.
|
|
15
|
+
onOpenDatabase = handlers().bailFirstFailure("onOpenDatabase");
|
|
16
|
+
/**
|
|
17
|
+
* Called after the local database has been reset.
|
|
18
|
+
*/
|
|
19
|
+
onDatabaseReset = handlers().bailFirstFailure("onDatabaseReset");
|
|
20
|
+
get localDatabase() {
|
|
21
|
+
if (!this._localDatabase) {
|
|
22
|
+
throw new Error("Local database is not ready yet.");
|
|
23
|
+
}
|
|
24
|
+
return this._localDatabase;
|
|
25
|
+
}
|
|
26
|
+
get localDatabaseDirect() {
|
|
27
|
+
return this._localDatabase;
|
|
28
|
+
}
|
|
29
|
+
modifyDatabaseOptions(settings, name, options) {
|
|
30
|
+
const optionPass = { ...options };
|
|
31
|
+
if (settings.useIndexedDBAdapter) {
|
|
32
|
+
optionPass.adapter = "indexeddb";
|
|
33
|
+
optionPass.purged_infos_limit = 1;
|
|
34
|
+
return {
|
|
35
|
+
name: name + ExtraSuffixIndexedDB,
|
|
36
|
+
options: optionPass
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
name,
|
|
41
|
+
options: optionPass
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
createPouchDBInstance(name, options) {
|
|
45
|
+
const settings = this.services.setting.currentSettings();
|
|
46
|
+
const optionPass = this.modifyDatabaseOptions(settings, name ?? "", options ?? {});
|
|
47
|
+
return new this.services.pouchDB(optionPass.name, optionPass.options);
|
|
48
|
+
}
|
|
49
|
+
async openDatabase(params) {
|
|
50
|
+
if (this._localDatabase != null) {
|
|
51
|
+
await this._localDatabase.close();
|
|
52
|
+
}
|
|
53
|
+
const vaultName = this.services.vault.getVaultName();
|
|
54
|
+
this._log(this.context.translate("moduleLocalDatabase.logWaitingForReady"));
|
|
55
|
+
const env = {
|
|
56
|
+
services: {
|
|
57
|
+
context: this.context,
|
|
58
|
+
...this.services,
|
|
59
|
+
...params,
|
|
60
|
+
database: this
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
this._localDatabase = new LiveSyncLocalDB(vaultName, env);
|
|
64
|
+
await this.onOpenDatabase(vaultName);
|
|
65
|
+
return await this.localDatabase.initializeDatabase();
|
|
66
|
+
}
|
|
67
|
+
isDatabaseReady() {
|
|
68
|
+
return this._localDatabase != null && this._localDatabase.isReady;
|
|
69
|
+
}
|
|
70
|
+
async resetDatabase() {
|
|
71
|
+
if (!this._localDatabase) {
|
|
72
|
+
return Promise.resolve(true);
|
|
73
|
+
}
|
|
74
|
+
return await this._localDatabase.resetDatabase();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
DatabaseService
|
|
79
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IFileProcessingService } from "./IService.js";
|
|
2
|
+
import { ServiceBase, type ServiceContext } from "./ServiceBase.js";
|
|
3
|
+
/**
|
|
4
|
+
* File processing service handles file events and processes them accordingly.
|
|
5
|
+
*/
|
|
6
|
+
export declare class FileProcessingService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements IFileProcessingService {
|
|
7
|
+
/**
|
|
8
|
+
* Process a file event item by the registered handlers.
|
|
9
|
+
*/
|
|
10
|
+
readonly processFileEvent: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(item: import("../../common/types.js").FileEventItem) => Promise<boolean>>;
|
|
11
|
+
/**
|
|
12
|
+
* Process a file event item optionally, if any handler is registered.
|
|
13
|
+
* i.e., hidden files synchronisation or customisation sync.
|
|
14
|
+
*/
|
|
15
|
+
readonly processOptionalFileEvent: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(path: import("../../common/types.js").FilePath) => Promise<boolean>>;
|
|
16
|
+
/**
|
|
17
|
+
* Commit any pending file events that have been queued for processing.
|
|
18
|
+
*/
|
|
19
|
+
readonly commitPendingFileEvents: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
|
|
20
|
+
batched: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
|
|
21
|
+
totalQueued: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
|
|
22
|
+
processing: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
|
|
23
|
+
totalStorageFileEventCount: number;
|
|
24
|
+
onStorageFileEvent(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { handlers } from "../lib/HandlerUtils.js";
|
|
2
|
+
import { ServiceBase } from "./ServiceBase.js";
|
|
3
|
+
import { reactiveSource } from "octagonal-wheels/dataobject/reactive";
|
|
4
|
+
class FileProcessingService extends ServiceBase {
|
|
5
|
+
/**
|
|
6
|
+
* Process a file event item by the registered handlers.
|
|
7
|
+
*/
|
|
8
|
+
processFileEvent = handlers().anySuccess("processFileEvent");
|
|
9
|
+
/**
|
|
10
|
+
* Process a file event item optionally, if any handler is registered.
|
|
11
|
+
* i.e., hidden files synchronisation or customisation sync.
|
|
12
|
+
*/
|
|
13
|
+
processOptionalFileEvent = handlers().anySuccess("processOptionalFileEvent");
|
|
14
|
+
/**
|
|
15
|
+
* Commit any pending file events that have been queued for processing.
|
|
16
|
+
*/
|
|
17
|
+
commitPendingFileEvents = handlers().bailFirstFailure("commitPendingFileEvents");
|
|
18
|
+
batched = reactiveSource(0);
|
|
19
|
+
totalQueued = reactiveSource(0);
|
|
20
|
+
processing = reactiveSource(0);
|
|
21
|
+
totalStorageFileEventCount = 0;
|
|
22
|
+
onStorageFileEvent() {
|
|
23
|
+
this.totalStorageFileEventCount++;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
FileProcessingService
|
|
28
|
+
};
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import type { FetchHttpHandler } from "@smithy/fetch-http-handler";
|
|
2
|
+
import { type LOG_LEVEL } from "octagonal-wheels/common/logger";
|
|
3
|
+
import type { AnyEntry, AUTO_MERGED, CouchDBCredentials, diff_result, DocumentID, EntryDoc, EntryHasPath, FileEventItem, FilePath, FilePathWithPrefix, LoadedEntry, MetaEntry, MISSING_OR_ERROR, ObsidianLiveSyncSettings, RemoteDBSettings, TweakValues, UXFileInfo, UXFileInfoStub } from "../../common/types.js";
|
|
4
|
+
import type { LiveSyncLocalDB } from "../../pouchdb/LiveSyncLocalDB.js";
|
|
5
|
+
import type { LiveSyncAbstractReplicator } from "../../replication/LiveSyncAbstractReplicator.js";
|
|
6
|
+
import type { SimpleStore } from "octagonal-wheels/databases/SimpleStoreBase";
|
|
7
|
+
import type { Confirm } from "../../interfaces/Confirm.js";
|
|
8
|
+
import type { ReactiveSource } from "octagonal-wheels/dataobject/reactive";
|
|
9
|
+
import type { ReplicationStatics } from "../../common/models/shared.definition.js";
|
|
10
|
+
import type { ReplicatorService } from "./ReplicatorService.js";
|
|
11
|
+
import type { DatabaseEventService } from "./DatabaseEventService.js";
|
|
12
|
+
import type { BASE_IS_NEW, EVEN, TARGET_IS_NEW } from "../../common/models/shared.const.symbols.js";
|
|
13
|
+
import type { AsyncActivityOptions } from "../../interfaces/AsyncActivityRunner.js";
|
|
14
|
+
declare global {
|
|
15
|
+
interface OPTIONAL_SYNC_FEATURES {
|
|
16
|
+
DISABLE: "DISABLE";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export interface ICommandCompat {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
icon?: string;
|
|
23
|
+
callback?: () => any;
|
|
24
|
+
checkCallback?: (checking: boolean) => boolean | void;
|
|
25
|
+
editorCallback?: (editor: any, ctx: any) => any;
|
|
26
|
+
editorCheckCallback?: (checking: any, editor: any, ctx: any) => boolean | void;
|
|
27
|
+
}
|
|
28
|
+
export interface IAPIService {
|
|
29
|
+
getCustomFetchHandler(): FetchHttpHandler;
|
|
30
|
+
addStatusBarItem(): HTMLElement | undefined;
|
|
31
|
+
addLog(message: unknown, level: LOG_LEVEL, key?: string): void;
|
|
32
|
+
isMobile(): boolean;
|
|
33
|
+
showWindow(type: string): Promise<void>;
|
|
34
|
+
showWindowOnRight?(type: string): Promise<void>;
|
|
35
|
+
getAppID(): string;
|
|
36
|
+
getSystemVaultName(): string;
|
|
37
|
+
getPlatform(): string;
|
|
38
|
+
getAppVersion(): string;
|
|
39
|
+
getPluginVersion(): string;
|
|
40
|
+
addCommand<TCommand extends ICommandCompat>(command: TCommand): TCommand;
|
|
41
|
+
registerWindow<T>(type: string, factory: (leaf: T) => unknown): void;
|
|
42
|
+
addRibbonIcon(icon: string, title: string, callback: (evt: MouseEvent) => unknown): HTMLElement;
|
|
43
|
+
registerProtocolHandler(action: string, handler: (params: Record<string, string>) => unknown): void;
|
|
44
|
+
confirm: Confirm;
|
|
45
|
+
responseCount: ReactiveSource<number>;
|
|
46
|
+
requestCount: ReactiveSource<number>;
|
|
47
|
+
isOnline: boolean;
|
|
48
|
+
webCompatFetch(url: string | Request, opts?: RequestInit): Promise<Response>;
|
|
49
|
+
nativeFetch(url: string | Request, opts?: RequestInit): Promise<Response>;
|
|
50
|
+
setInterval(handler: () => void, timeout: number): number;
|
|
51
|
+
clearInterval(timerId: number): void;
|
|
52
|
+
getSystemConfigDir(): string;
|
|
53
|
+
}
|
|
54
|
+
export interface IPathService {
|
|
55
|
+
id2path(id: DocumentID, entry?: EntryHasPath, stripPrefix?: boolean): FilePathWithPrefix;
|
|
56
|
+
path2id(filename: FilePathWithPrefix | FilePath, prefix?: string): Promise<DocumentID>;
|
|
57
|
+
getPath(entry: AnyEntry): FilePathWithPrefix;
|
|
58
|
+
markChangesAreSame(old: UXFileInfo | AnyEntry | FilePathWithPrefix, newMtime: number, oldMtime: number): boolean | undefined;
|
|
59
|
+
unmarkChanges(file: AnyEntry | FilePathWithPrefix | UXFileInfoStub): void;
|
|
60
|
+
compareFileFreshness(baseFile: UXFileInfoStub | AnyEntry | undefined, checkTarget: UXFileInfo | AnyEntry | undefined): typeof BASE_IS_NEW | typeof TARGET_IS_NEW | typeof EVEN;
|
|
61
|
+
isMarkedAsSameChanges(file: UXFileInfoStub | AnyEntry | FilePathWithPrefix, mtimes: number[]): undefined | typeof EVEN;
|
|
62
|
+
}
|
|
63
|
+
export interface openDatabaseParameters {
|
|
64
|
+
replicator: ReplicatorService;
|
|
65
|
+
databaseEvents: DatabaseEventService;
|
|
66
|
+
}
|
|
67
|
+
export interface IDatabaseService {
|
|
68
|
+
localDatabase: LiveSyncLocalDB;
|
|
69
|
+
createPouchDBInstance<T extends object>(name?: string, options?: PouchDB.Configuration.DatabaseConfiguration): PouchDB.Database<T>;
|
|
70
|
+
openDatabase(params: openDatabaseParameters): Promise<boolean>;
|
|
71
|
+
resetDatabase(): Promise<boolean>;
|
|
72
|
+
onDatabaseReset: () => Promise<boolean>;
|
|
73
|
+
onOpenDatabase: (vaultName: string) => Promise<boolean>;
|
|
74
|
+
isDatabaseReady(): boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface IDatabaseEventService {
|
|
77
|
+
onUnloadDatabase(db: LiveSyncLocalDB): Promise<boolean>;
|
|
78
|
+
onCloseDatabase(db: LiveSyncLocalDB): Promise<boolean>;
|
|
79
|
+
onDatabaseInitialisation(db: LiveSyncLocalDB): Promise<boolean>;
|
|
80
|
+
onDatabaseInitialised(showNotice: boolean): Promise<boolean>;
|
|
81
|
+
onDatabaseHasReady(): Promise<boolean>;
|
|
82
|
+
onResetDatabase(db: LiveSyncLocalDB): Promise<boolean>;
|
|
83
|
+
initialiseDatabase(showingNotice?: boolean, reopenDatabase?: boolean, ignoreSuspending?: boolean): Promise<boolean>;
|
|
84
|
+
}
|
|
85
|
+
export interface IKeyValueDBService {
|
|
86
|
+
openSimpleStore<T>(kind: string): SimpleStore<T>;
|
|
87
|
+
simpleStore: SimpleStore<unknown>;
|
|
88
|
+
}
|
|
89
|
+
export interface IFileProcessingService {
|
|
90
|
+
processFileEvent(item: FileEventItem): Promise<boolean>;
|
|
91
|
+
processOptionalFileEvent(path: FilePath): Promise<boolean>;
|
|
92
|
+
commitPendingFileEvents(): Promise<boolean>;
|
|
93
|
+
batched: ReactiveSource<number>;
|
|
94
|
+
processing: ReactiveSource<number>;
|
|
95
|
+
totalQueued: ReactiveSource<number>;
|
|
96
|
+
totalStorageFileEventCount: number;
|
|
97
|
+
onStorageFileEvent(): void;
|
|
98
|
+
}
|
|
99
|
+
export interface IReplicatorService {
|
|
100
|
+
onCloseActiveReplication(): Promise<boolean>;
|
|
101
|
+
onReplicatorInitialised(): Promise<boolean>;
|
|
102
|
+
getNewReplicator(settingOverride?: Partial<ObsidianLiveSyncSettings>): Promise<LiveSyncAbstractReplicator | undefined | false>;
|
|
103
|
+
getActiveReplicator(): LiveSyncAbstractReplicator | undefined;
|
|
104
|
+
replicationStatics: ReactiveSource<ReplicationStatics>;
|
|
105
|
+
/** Number of finite remote operations currently in progress. */
|
|
106
|
+
boundedRemoteActivityCount: ReactiveSource<number>;
|
|
107
|
+
/** Number of finite replication operations which can still deliver database documents. */
|
|
108
|
+
finiteReplicationActivityCount: ReactiveSource<number>;
|
|
109
|
+
/** Runs a finite remote operation within the host activity policy. */
|
|
110
|
+
runBoundedRemoteActivity<T>(task: () => T | PromiseLike<T>, options?: AsyncActivityOptions): Promise<T>;
|
|
111
|
+
/** Runs finite replication which may place documents in the local database. */
|
|
112
|
+
runFiniteReplicationActivity<T>(task: () => T | PromiseLike<T>, options?: AsyncActivityOptions): Promise<T>;
|
|
113
|
+
}
|
|
114
|
+
export interface IReplicationService {
|
|
115
|
+
processSynchroniseResult(doc: MetaEntry): Promise<boolean>;
|
|
116
|
+
processOptionalSynchroniseResult(doc: LoadedEntry): Promise<boolean>;
|
|
117
|
+
processVirtualDocument(docs: PouchDB.Core.ExistingDocument<EntryDoc>): Promise<boolean>;
|
|
118
|
+
onBeforeReplicate(showMessage: boolean): Promise<boolean>;
|
|
119
|
+
checkConnectionFailure(): Promise<boolean | "CHECKAGAIN" | undefined>;
|
|
120
|
+
onCheckReplicationReady(showMessage: boolean): Promise<boolean>;
|
|
121
|
+
isReplicationReady(showMessage: boolean): Promise<boolean>;
|
|
122
|
+
performReplication(showMessage?: boolean): Promise<boolean | void>;
|
|
123
|
+
replicate(showMessage?: boolean): Promise<boolean | void>;
|
|
124
|
+
replicateByEvent(showMessage?: boolean): Promise<boolean | void>;
|
|
125
|
+
onReplicationFailed(showMessage?: boolean): Promise<boolean>;
|
|
126
|
+
parseSynchroniseResult(docs: Array<PouchDB.Core.ExistingDocument<EntryDoc>>): Promise<boolean>;
|
|
127
|
+
databaseQueueCount: ReactiveSource<number>;
|
|
128
|
+
storageApplyingCount: ReactiveSource<number>;
|
|
129
|
+
replicationResultCount: ReactiveSource<number>;
|
|
130
|
+
replicateAllToRemote(showingNotice?: boolean, sendChunksInBulkDisabled?: boolean): Promise<boolean>;
|
|
131
|
+
replicateAllFromRemote(showingNotice?: boolean): Promise<boolean>;
|
|
132
|
+
markLocked(lockByClean?: boolean): Promise<void>;
|
|
133
|
+
markUnlocked(): Promise<void>;
|
|
134
|
+
markResolved(): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
export interface IRemoteService {
|
|
137
|
+
connect(uri: string, auth: CouchDBCredentials, disableRequestURI: boolean, passphrase: string | false, useDynamicIterationCount: boolean, performSetup: boolean, skipInfo: boolean, compression: boolean, customHeaders: Record<string, string>, useRequestAPI: boolean, getPBKDF2Salt: () => Promise<Uint8Array<ArrayBuffer>>): Promise<string | {
|
|
138
|
+
db: PouchDB.Database<EntryDoc>;
|
|
139
|
+
info: PouchDB.Core.DatabaseInfo;
|
|
140
|
+
}>;
|
|
141
|
+
/**
|
|
142
|
+
* State if the last POST request failed due to payload size.
|
|
143
|
+
*/
|
|
144
|
+
get hadLastPostFailedBySize(): boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface IConflictService {
|
|
147
|
+
getOptionalConflictCheckMethod(path: FilePathWithPrefix): Promise<boolean | undefined | "newer">;
|
|
148
|
+
resolveByUserInteraction: (filename: FilePathWithPrefix, conflictCheckResult: diff_result) => Promise<boolean | undefined>;
|
|
149
|
+
queueCheckForIfOpen(path: FilePathWithPrefix): Promise<void>;
|
|
150
|
+
queueCheckFor(path: FilePathWithPrefix): Promise<void>;
|
|
151
|
+
ensureAllProcessed(): Promise<boolean>;
|
|
152
|
+
resolveByDeletingRevision(path: FilePathWithPrefix, deleteRevision: string, title: string): Promise<typeof MISSING_OR_ERROR | typeof AUTO_MERGED>;
|
|
153
|
+
resolve(filename: FilePathWithPrefix): Promise<void>;
|
|
154
|
+
resolveByNewest(filename: FilePathWithPrefix): Promise<boolean>;
|
|
155
|
+
resolveAllConflictedFilesByNewerOnes(): Promise<void>;
|
|
156
|
+
conflictProcessQueueCount: ReactiveSource<number>;
|
|
157
|
+
}
|
|
158
|
+
export interface IAppLifecycleService {
|
|
159
|
+
onLayoutReady(): Promise<boolean>;
|
|
160
|
+
onFirstInitialise(): Promise<boolean>;
|
|
161
|
+
onReady(): Promise<boolean>;
|
|
162
|
+
onWireUpEvents(): Promise<boolean>;
|
|
163
|
+
onInitialise(): Promise<boolean>;
|
|
164
|
+
onLoad(): Promise<boolean>;
|
|
165
|
+
onSettingLoaded(): Promise<boolean>;
|
|
166
|
+
onLoaded(): Promise<boolean>;
|
|
167
|
+
onScanningStartupIssues(): Promise<boolean>;
|
|
168
|
+
onAppUnload(): Promise<undefined[]>;
|
|
169
|
+
onBeforeUnload(): Promise<boolean>;
|
|
170
|
+
onUnload(): Promise<boolean>;
|
|
171
|
+
onSuspending(): Promise<boolean>;
|
|
172
|
+
onResuming(): Promise<boolean>;
|
|
173
|
+
onResumed(): Promise<boolean>;
|
|
174
|
+
getUnresolvedMessages: () => Promise<(string | Error)[][]>;
|
|
175
|
+
performRestart(): void;
|
|
176
|
+
askRestart(message?: string): void;
|
|
177
|
+
scheduleRestart(): void;
|
|
178
|
+
isSuspended(): boolean;
|
|
179
|
+
setSuspended(suspend: boolean): void;
|
|
180
|
+
isReady(): boolean;
|
|
181
|
+
markIsReady(): void;
|
|
182
|
+
resetIsReady(): void;
|
|
183
|
+
isReloadingScheduled(): boolean;
|
|
184
|
+
}
|
|
185
|
+
export interface ISettingService {
|
|
186
|
+
onBeforeRealiseSetting(): Promise<boolean>;
|
|
187
|
+
onSettingRealised(): Promise<boolean>;
|
|
188
|
+
onRealiseSetting(): Promise<boolean>;
|
|
189
|
+
suspendAllSync(): Promise<boolean>;
|
|
190
|
+
suspendExtraSync(): Promise<boolean>;
|
|
191
|
+
suggestOptionalFeatures(opt: {
|
|
192
|
+
enableFetch?: boolean;
|
|
193
|
+
enableOverwrite?: boolean;
|
|
194
|
+
}): Promise<boolean>;
|
|
195
|
+
enableOptionalFeature(mode: keyof OPTIONAL_SYNC_FEATURES): Promise<boolean>;
|
|
196
|
+
clearUsedPassphrase(): void;
|
|
197
|
+
decryptSettings(settings: ObsidianLiveSyncSettings): Promise<ObsidianLiveSyncSettings>;
|
|
198
|
+
adjustSettings(settings: ObsidianLiveSyncSettings): Promise<ObsidianLiveSyncSettings>;
|
|
199
|
+
loadSettings(): Promise<void>;
|
|
200
|
+
getDeviceAndVaultName(): string;
|
|
201
|
+
setDeviceAndVaultName(name: string): void;
|
|
202
|
+
saveDeviceAndVaultName(): void;
|
|
203
|
+
onBeforeSaveSettingData(nextSettings: ObsidianLiveSyncSettings, previousSettings: ObsidianLiveSyncSettings): Promise<(Partial<ObsidianLiveSyncSettings> | void)[]>;
|
|
204
|
+
saveSettingData(): Promise<void>;
|
|
205
|
+
currentSettings(): ObsidianLiveSyncSettings;
|
|
206
|
+
updateSettings(updateFn: (current: ObsidianLiveSyncSettings) => ObsidianLiveSyncSettings, saveImmediately?: boolean): Promise<void>;
|
|
207
|
+
applyExternalSettings(partial: Partial<ObsidianLiveSyncSettings>, saveImmediately?: boolean): Promise<void>;
|
|
208
|
+
applyPartial(partial: Partial<ObsidianLiveSyncSettings>, saveImmediately?: boolean): Promise<void>;
|
|
209
|
+
onSettingLoaded(settings: ObsidianLiveSyncSettings): Promise<boolean>;
|
|
210
|
+
onSettingChanged(settings: ObsidianLiveSyncSettings): Promise<boolean>;
|
|
211
|
+
onSettingSaved(settings: ObsidianLiveSyncSettings): Promise<boolean>;
|
|
212
|
+
getSmallConfig(key: string): string | null;
|
|
213
|
+
setSmallConfig(key: string, value: string): void;
|
|
214
|
+
deleteSmallConfig(key: string): void;
|
|
215
|
+
}
|
|
216
|
+
export interface ITweakValueService {
|
|
217
|
+
fetchRemotePreferred(trialSetting: RemoteDBSettings): Promise<TweakValues | false>;
|
|
218
|
+
checkAndAskResolvingMismatched(preferred: Partial<TweakValues>): Promise<[TweakValues | boolean, boolean]>;
|
|
219
|
+
askResolvingMismatched(preferredSource: TweakValues): Promise<"OK" | "CHECKAGAIN" | "IGNORE">;
|
|
220
|
+
checkAndAskUseRemoteConfiguration(settings: RemoteDBSettings): Promise<{
|
|
221
|
+
result: false | TweakValues;
|
|
222
|
+
requireFetch: boolean;
|
|
223
|
+
}>;
|
|
224
|
+
askUseRemoteConfiguration(trialSetting: RemoteDBSettings, preferred: TweakValues): Promise<{
|
|
225
|
+
result: false | TweakValues;
|
|
226
|
+
requireFetch: boolean;
|
|
227
|
+
}>;
|
|
228
|
+
}
|
|
229
|
+
export interface IVaultService {
|
|
230
|
+
vaultName(): string;
|
|
231
|
+
getVaultName(): string;
|
|
232
|
+
scanVault(showingNotice?: boolean, ignoreSuspending?: boolean): Promise<boolean>;
|
|
233
|
+
isIgnoredByIgnoreFile(file: string | UXFileInfoStub): Promise<boolean>;
|
|
234
|
+
isTargetFile(file: string | UXFileInfoStub): Promise<boolean>;
|
|
235
|
+
isTargetFileInExtra(file: string | UXFileInfoStub): Promise<boolean>;
|
|
236
|
+
isFileSizeTooLarge(size: number): boolean;
|
|
237
|
+
getActiveFilePath(): FilePath | undefined;
|
|
238
|
+
isStorageInsensitive(): boolean;
|
|
239
|
+
shouldCheckCaseInsensitively(): boolean;
|
|
240
|
+
isValidPath(path: string): boolean;
|
|
241
|
+
}
|
|
242
|
+
export interface ITestService {
|
|
243
|
+
test(): Promise<boolean>;
|
|
244
|
+
testMultiDevice(): Promise<boolean>;
|
|
245
|
+
addTestResult(name: string, key: string, result: boolean, summary?: string, message?: string): void;
|
|
246
|
+
}
|
|
247
|
+
export interface IUIService {
|
|
248
|
+
promptCopyToClipboard(title: string, value: string): Promise<boolean>;
|
|
249
|
+
showMarkdownDialog<T extends string[]>(title: string, contentMD: string, buttons: T): Promise<(typeof buttons)[number] | false>;
|
|
250
|
+
get confirm(): Confirm;
|
|
251
|
+
}
|
|
252
|
+
export interface IConfigService {
|
|
253
|
+
getSmallConfig(key: string): string | null;
|
|
254
|
+
setSmallConfig(key: string, value: string): void;
|
|
255
|
+
deleteSmallConfig(key: string): void;
|
|
256
|
+
}
|
|
257
|
+
export interface IServiceHub {
|
|
258
|
+
API: IAPIService;
|
|
259
|
+
path: IPathService;
|
|
260
|
+
database: IDatabaseService;
|
|
261
|
+
databaseEvents: IDatabaseEventService;
|
|
262
|
+
replicator: IReplicatorService;
|
|
263
|
+
fileProcessing: IFileProcessingService;
|
|
264
|
+
replication: IReplicationService;
|
|
265
|
+
remote: IRemoteService;
|
|
266
|
+
conflict: IConflictService;
|
|
267
|
+
appLifecycle: IAppLifecycleService;
|
|
268
|
+
setting: ISettingService;
|
|
269
|
+
tweakValue: ITweakValueService;
|
|
270
|
+
vault: IVaultService;
|
|
271
|
+
test: ITestService;
|
|
272
|
+
UI: IUIService;
|
|
273
|
+
config: IConfigService;
|
|
274
|
+
keyValueDB: IKeyValueDBService;
|
|
275
|
+
control: IControlService;
|
|
276
|
+
}
|
|
277
|
+
export interface IControlService {
|
|
278
|
+
applySettings(): Promise<void>;
|
|
279
|
+
onLoad(): Promise<boolean>;
|
|
280
|
+
onReady(): Promise<boolean>;
|
|
281
|
+
onUnload(): Promise<void>;
|
|
282
|
+
hasUnloaded(): boolean;
|
|
283
|
+
activated: Promise<boolean>;
|
|
284
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {} from "octagonal-wheels/common/logger";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { SimpleStore } from "../../common/utils.js";
|
|
2
|
+
import type { IKeyValueDBService, IVaultService } from "./IService.js";
|
|
3
|
+
import { ServiceBase, type ServiceContext } from "./ServiceBase.js";
|
|
4
|
+
import type { KeyValueDatabase, KeyValueDatabaseFactory } from "../../interfaces/KeyValueDatabase.js";
|
|
5
|
+
import type { InjectableDatabaseEventService } from "../implements/injectable/InjectableDatabaseEventService.js";
|
|
6
|
+
import type { AppLifecycleServiceBase } from "../implements/injectable/InjectableAppLifecycleService.js";
|
|
7
|
+
export interface KeyValueDBDependencies<T extends ServiceContext = ServiceContext> {
|
|
8
|
+
openKeyValueDatabase: KeyValueDatabaseFactory;
|
|
9
|
+
databaseEvents: InjectableDatabaseEventService<T>;
|
|
10
|
+
vault: IVaultService;
|
|
11
|
+
appLifecycle: AppLifecycleServiceBase<T>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The KeyValueDBService provides methods for managing the local key-value database.
|
|
15
|
+
* Please note that each event of database lifecycle is handled in DatabaseEventService.
|
|
16
|
+
*/
|
|
17
|
+
export declare abstract class KeyValueDBService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements IKeyValueDBService {
|
|
18
|
+
private _kvDB;
|
|
19
|
+
private _simpleStore;
|
|
20
|
+
get simpleStore(): SimpleStore<unknown, any>;
|
|
21
|
+
get kvDB(): KeyValueDatabase;
|
|
22
|
+
private databaseEvents;
|
|
23
|
+
private vault;
|
|
24
|
+
private appLifecycle;
|
|
25
|
+
private openKeyValueDatabase;
|
|
26
|
+
private _log;
|
|
27
|
+
private _everyOnResetDatabase;
|
|
28
|
+
private tryCloseKvDB;
|
|
29
|
+
private openKeyValueDB;
|
|
30
|
+
private _onOtherDatabaseUnload;
|
|
31
|
+
private _onOtherDatabaseClose;
|
|
32
|
+
private _everyOnInitializeDatabase;
|
|
33
|
+
private _everyOnloadAfterLoadSettings;
|
|
34
|
+
constructor(context: T, dependencies: KeyValueDBDependencies<T>);
|
|
35
|
+
openSimpleStore<T>(kind: string): {
|
|
36
|
+
get: (key: string) => Promise<T>;
|
|
37
|
+
set: (key: string, value: unknown) => Promise<void>;
|
|
38
|
+
delete: (key: string) => Promise<void>;
|
|
39
|
+
keys: (from: string | undefined, to: string | undefined, count?: number) => Promise<string[]>;
|
|
40
|
+
db: Promise<KeyValueDatabase>;
|
|
41
|
+
};
|
|
42
|
+
}
|