@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,37 @@
|
|
|
1
|
+
import { type FilePathWithPrefix, type FilePath, type LoadedEntry, type EntryDoc, type SavingEntry, type MetaEntry } from "../../common/types.js";
|
|
2
|
+
import type { ChunkManager } from "../ChunkManager.js";
|
|
3
|
+
import type { ContentSplitter } from "../../ContentSplitter/ContentSplitters.js";
|
|
4
|
+
import type { HashManager } from "../HashManager/HashManager.js";
|
|
5
|
+
import type { GeneratedChunk } from "../../pouchdb/LiveSyncLocalDB.js";
|
|
6
|
+
import type { IPathService, ISettingService } from "../../services/base/IService.js";
|
|
7
|
+
export interface EntryManagerOptions {
|
|
8
|
+
hashManager: HashManager;
|
|
9
|
+
chunkManager: ChunkManager;
|
|
10
|
+
splitter: ContentSplitter;
|
|
11
|
+
database: PouchDB.Database<EntryDoc>;
|
|
12
|
+
settingService: ISettingService;
|
|
13
|
+
pathService: IPathService;
|
|
14
|
+
}
|
|
15
|
+
export declare class EntryManager {
|
|
16
|
+
options: EntryManagerOptions;
|
|
17
|
+
constructor(options: EntryManagerOptions);
|
|
18
|
+
get localDatabase(): PouchDB.Database<EntryDoc>;
|
|
19
|
+
get hashManager(): HashManager;
|
|
20
|
+
get chunkManager(): ChunkManager;
|
|
21
|
+
get splitter(): ContentSplitter;
|
|
22
|
+
get serviceHost(): {
|
|
23
|
+
services: {
|
|
24
|
+
setting: ISettingService;
|
|
25
|
+
path: IPathService;
|
|
26
|
+
};
|
|
27
|
+
serviceModules: {};
|
|
28
|
+
};
|
|
29
|
+
get isOnDemandChunkEnabled(): boolean;
|
|
30
|
+
isTargetFile(filenameSrc: string): boolean;
|
|
31
|
+
prepareChunk(piece: string): Promise<GeneratedChunk>;
|
|
32
|
+
getDBEntryMeta(path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, includeDeleted?: boolean): Promise<false | LoadedEntry>;
|
|
33
|
+
getDBEntry(path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, dump?: boolean, waitForReady?: boolean, includeDeleted?: boolean): Promise<false | LoadedEntry>;
|
|
34
|
+
getDBEntryFromMeta(meta: LoadedEntry | MetaEntry, dump?: boolean, waitForReady?: boolean): Promise<false | LoadedEntry>;
|
|
35
|
+
deleteDBEntry(path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions): Promise<boolean>;
|
|
36
|
+
putDBEntry(note: SavingEntry, onlyChunks?: boolean, conflictBaseRev?: string): Promise<false | PouchDB.Core.Response>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
REMOTE_COUCHDB
|
|
3
|
+
} from "../../common/types.js";
|
|
4
|
+
import {
|
|
5
|
+
deleteDBEntryByPath,
|
|
6
|
+
getDBEntryByPath,
|
|
7
|
+
getDBEntryFromMeta,
|
|
8
|
+
getDBEntryMetaByPath,
|
|
9
|
+
isTargetFile,
|
|
10
|
+
prepareChunk,
|
|
11
|
+
putDBEntry
|
|
12
|
+
} from "./EntryManagerImpls.js";
|
|
13
|
+
class EntryManager {
|
|
14
|
+
options;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
get localDatabase() {
|
|
19
|
+
return this.options.database;
|
|
20
|
+
}
|
|
21
|
+
get hashManager() {
|
|
22
|
+
return this.options.hashManager;
|
|
23
|
+
}
|
|
24
|
+
get chunkManager() {
|
|
25
|
+
return this.options.chunkManager;
|
|
26
|
+
}
|
|
27
|
+
get splitter() {
|
|
28
|
+
return this.options.splitter;
|
|
29
|
+
}
|
|
30
|
+
get serviceHost() {
|
|
31
|
+
return {
|
|
32
|
+
services: {
|
|
33
|
+
setting: this.options.settingService,
|
|
34
|
+
path: this.options.pathService
|
|
35
|
+
},
|
|
36
|
+
serviceModules: {}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
get isOnDemandChunkEnabled() {
|
|
40
|
+
const settings = this.options.settingService.currentSettings();
|
|
41
|
+
if (settings.remoteType !== REMOTE_COUCHDB) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (settings.useOnlyLocalChunk) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
isTargetFile(filenameSrc) {
|
|
50
|
+
return isTargetFile(this.serviceHost, filenameSrc);
|
|
51
|
+
}
|
|
52
|
+
async prepareChunk(piece) {
|
|
53
|
+
return await prepareChunk(this, piece);
|
|
54
|
+
}
|
|
55
|
+
async getDBEntryMeta(path, opt, includeDeleted = false) {
|
|
56
|
+
return await getDBEntryMetaByPath(this.serviceHost, this, path, opt, includeDeleted);
|
|
57
|
+
}
|
|
58
|
+
async getDBEntry(path, opt, dump = false, waitForReady = true, includeDeleted = false) {
|
|
59
|
+
return await getDBEntryByPath(this.serviceHost, this, path, opt, dump, waitForReady, includeDeleted);
|
|
60
|
+
}
|
|
61
|
+
async getDBEntryFromMeta(meta, dump = false, waitForReady = true) {
|
|
62
|
+
return await getDBEntryFromMeta(this.serviceHost, this, meta, dump, waitForReady);
|
|
63
|
+
}
|
|
64
|
+
async deleteDBEntry(path, opt) {
|
|
65
|
+
return await deleteDBEntryByPath(this.serviceHost, this, path, opt);
|
|
66
|
+
}
|
|
67
|
+
async putDBEntry(note, onlyChunks, conflictBaseRev) {
|
|
68
|
+
return await putDBEntry(this.serviceHost, this, note, onlyChunks, conflictBaseRev);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
EntryManager
|
|
73
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type SavingEntry, type DocumentID, type EntryDoc, type EntryBase, type FilePath, type FilePathWithPrefix, type LoadedEntry, type ObsidianLiveSyncSettings, type MetaEntry } from "../../common/types.js";
|
|
2
|
+
import type { ContentSplitter } from "../../ContentSplitter/ContentSplitters.js";
|
|
3
|
+
import type { HashManager } from "../HashManager/HashManager.js";
|
|
4
|
+
import type { LayeredChunkManager as ChunkManager } from "../LayeredChunkManager.js";
|
|
5
|
+
import type { NecessaryServicesInterfaces } from "../../interfaces/ServiceModule.js";
|
|
6
|
+
import type { GeneratedChunk } from "../../pouchdb/LiveSyncLocalDB.js";
|
|
7
|
+
type Managers = {
|
|
8
|
+
hashManager: HashManager;
|
|
9
|
+
chunkManager: ChunkManager;
|
|
10
|
+
splitter: ContentSplitter;
|
|
11
|
+
localDatabase: PouchDB.Database<EntryDoc>;
|
|
12
|
+
};
|
|
13
|
+
type NecessaryManagers<T extends keyof Managers> = Pick<Managers, T>;
|
|
14
|
+
export declare function createChunks(managers: NecessaryManagers<"chunkManager" | "hashManager" | "splitter">, dispFilename: string, note: SavingEntry): Promise<false | DocumentID[]>;
|
|
15
|
+
export declare function putDBEntry(host: NecessaryServicesInterfaces<"path" | "setting", never>, managers: NecessaryManagers<"localDatabase" | "chunkManager" | "hashManager" | "splitter">, note: SavingEntry, onlyChunks?: boolean, conflictBaseRev?: string): Promise<false | PouchDB.Core.Response>;
|
|
16
|
+
export declare function isTargetFile(host: NecessaryServicesInterfaces<"setting", never>, filenameSrc: string): boolean;
|
|
17
|
+
export declare function prepareChunk({ chunkManager, hashManager }: NecessaryManagers<"chunkManager" | "hashManager">, piece: string): Promise<GeneratedChunk>;
|
|
18
|
+
export declare function getDBEntryMetaByPath(host: NecessaryServicesInterfaces<"path" | "setting", never>, { localDatabase }: NecessaryManagers<"localDatabase">, path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, includeDeleted?: boolean): Promise<false | LoadedEntry>;
|
|
19
|
+
export declare function isLegacyNote(meta: LoadedEntry | MetaEntry): boolean;
|
|
20
|
+
export declare function canUseOnDemandChunking(settings: ObsidianLiveSyncSettings): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Decide how to retrieve chunks based on settings and waitForReady flag.
|
|
23
|
+
* `waitForReady` allows an already-observable finite delivery lifecycle to finish.
|
|
24
|
+
*/
|
|
25
|
+
export declare function computeChunkRetrievalMethod(waitForReady: boolean, settings: ObsidianLiveSyncSettings): {
|
|
26
|
+
waitForDelivery: boolean;
|
|
27
|
+
preventRemoteRequest: boolean;
|
|
28
|
+
};
|
|
29
|
+
export declare function getDBEntryFromMeta(host: NecessaryServicesInterfaces<"path" | "setting", never>, { localDatabase, chunkManager }: NecessaryManagers<"localDatabase" | "chunkManager">, meta: LoadedEntry | MetaEntry, dump?: boolean, waitForReady?: boolean): Promise<false | (import("../../common/types.js").DatabaseEntry & EntryBase & import("../../common/types.js").EntryWithEden & {
|
|
30
|
+
path: FilePathWithPrefix;
|
|
31
|
+
data: string | string[];
|
|
32
|
+
type: import("../../common/models/db.type.js").EntryTypes["NOTE_LEGACY"];
|
|
33
|
+
} & {
|
|
34
|
+
data: string | string[];
|
|
35
|
+
datatype: import("../../common/types.js").EntryTypeNotes;
|
|
36
|
+
} & PouchDB.Core.IdMeta) | (import("../../common/types.js").DatabaseEntry & EntryBase & import("../../common/types.js").EntryWithEden & {
|
|
37
|
+
path: FilePathWithPrefix;
|
|
38
|
+
children: string[];
|
|
39
|
+
type: import("../../common/models/db.type.js").EntryTypes["NOTE_BINARY"];
|
|
40
|
+
} & {
|
|
41
|
+
data: string | string[];
|
|
42
|
+
datatype: import("../../common/types.js").EntryTypeNotes;
|
|
43
|
+
} & PouchDB.Core.IdMeta) | (import("../../common/types.js").DatabaseEntry & EntryBase & import("../../common/types.js").EntryWithEden & {
|
|
44
|
+
path: FilePathWithPrefix;
|
|
45
|
+
children: string[];
|
|
46
|
+
type: import("../../common/models/db.type.js").EntryTypes["NOTE_PLAIN"];
|
|
47
|
+
} & {
|
|
48
|
+
data: string | string[];
|
|
49
|
+
datatype: import("../../common/types.js").EntryTypeNotes;
|
|
50
|
+
} & PouchDB.Core.IdMeta)>;
|
|
51
|
+
export declare function getDBEntryByPath(host: NecessaryServicesInterfaces<"path" | "setting", never>, managers: NecessaryManagers<"localDatabase" | "chunkManager">, path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions, dump?: boolean, waitForReady?: boolean, includeDeleted?: boolean): Promise<false | (import("../../common/types.js").DatabaseEntry & EntryBase & import("../../common/types.js").EntryWithEden & {
|
|
52
|
+
path: FilePathWithPrefix;
|
|
53
|
+
data: string | string[];
|
|
54
|
+
type: import("../../common/models/db.type.js").EntryTypes["NOTE_LEGACY"];
|
|
55
|
+
} & {
|
|
56
|
+
data: string | string[];
|
|
57
|
+
datatype: import("../../common/types.js").EntryTypeNotes;
|
|
58
|
+
} & PouchDB.Core.IdMeta) | (import("../../common/types.js").DatabaseEntry & EntryBase & import("../../common/types.js").EntryWithEden & {
|
|
59
|
+
path: FilePathWithPrefix;
|
|
60
|
+
children: string[];
|
|
61
|
+
type: import("../../common/models/db.type.js").EntryTypes["NOTE_BINARY"];
|
|
62
|
+
} & {
|
|
63
|
+
data: string | string[];
|
|
64
|
+
datatype: import("../../common/types.js").EntryTypeNotes;
|
|
65
|
+
} & PouchDB.Core.IdMeta) | (import("../../common/types.js").DatabaseEntry & EntryBase & import("../../common/types.js").EntryWithEden & {
|
|
66
|
+
path: FilePathWithPrefix;
|
|
67
|
+
children: string[];
|
|
68
|
+
type: import("../../common/models/db.type.js").EntryTypes["NOTE_PLAIN"];
|
|
69
|
+
} & {
|
|
70
|
+
data: string | string[];
|
|
71
|
+
datatype: import("../../common/types.js").EntryTypeNotes;
|
|
72
|
+
} & PouchDB.Core.IdMeta)>;
|
|
73
|
+
export declare function deleteDBEntryByPath(host: NecessaryServicesInterfaces<"path" | "setting", never>, { localDatabase }: NecessaryManagers<"localDatabase">, path: FilePathWithPrefix | FilePath, opt?: PouchDB.Core.GetOptions): Promise<boolean>;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import { Logger, LOG_LEVEL_VERBOSE, LOG_LEVEL_NOTICE } from "octagonal-wheels/common/logger";
|
|
2
|
+
import {
|
|
3
|
+
IDPrefixes,
|
|
4
|
+
REMOTE_COUCHDB,
|
|
5
|
+
RemoteTypes
|
|
6
|
+
} from "../../common/types.js";
|
|
7
|
+
import { serialized } from "octagonal-wheels/concurrency/lock";
|
|
8
|
+
import { createTextBlob, getFileRegExp, isTextBlob } from "../../common/utils.js";
|
|
9
|
+
import { isErrorOfMissingDoc } from "../../pouchdb/utils_couchdb.js";
|
|
10
|
+
import { stripAllPrefixes } from "../../string_and_binary/path.js";
|
|
11
|
+
import { ICHeader, ICXHeader, PSCHeader } from "../../common/models/fileaccess.const.js";
|
|
12
|
+
async function createChunks(managers, dispFilename, note) {
|
|
13
|
+
const { chunkManager, splitter } = managers;
|
|
14
|
+
let bufferedChunk = [];
|
|
15
|
+
let bufferedSize = 0;
|
|
16
|
+
let writeCount = 0;
|
|
17
|
+
let newCount = 0;
|
|
18
|
+
let cachedCount = 0;
|
|
19
|
+
let resultCachedCount = 0;
|
|
20
|
+
let duplicatedCount = 0;
|
|
21
|
+
let totalWritingCount = 0;
|
|
22
|
+
let createChunkCount = 0;
|
|
23
|
+
const MAX_WRITE_SIZE = 1e3 * 1024 * 2;
|
|
24
|
+
const chunks = [];
|
|
25
|
+
let writeChars = 0;
|
|
26
|
+
const flushBufferedChunks = async () => {
|
|
27
|
+
if (bufferedChunk.length === 0) {
|
|
28
|
+
Logger(`No chunks to flush for ${dispFilename}`, LOG_LEVEL_VERBOSE);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const writeBuf = [...bufferedChunk];
|
|
32
|
+
bufferedSize = 0;
|
|
33
|
+
bufferedChunk = [];
|
|
34
|
+
const result = await chunkManager.write(
|
|
35
|
+
writeBuf,
|
|
36
|
+
{
|
|
37
|
+
skipCache: false,
|
|
38
|
+
timeout: 0
|
|
39
|
+
},
|
|
40
|
+
note._id
|
|
41
|
+
);
|
|
42
|
+
if (result.result === false) {
|
|
43
|
+
Logger(`Failed to write buffered chunks for ${dispFilename}`, LOG_LEVEL_NOTICE);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
totalWritingCount++;
|
|
47
|
+
writeCount += result.processed.written;
|
|
48
|
+
resultCachedCount += result.processed.cached;
|
|
49
|
+
duplicatedCount += result.processed.duplicated;
|
|
50
|
+
writeChars += writeBuf.map((e) => e.data.length).reduce((a, b) => a + b, 0);
|
|
51
|
+
Logger(`Flushed ${writeBuf.length} (${writeChars}) chunks for ${dispFilename}`, LOG_LEVEL_VERBOSE);
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
const flushIfNeeded = async () => {
|
|
55
|
+
if (bufferedSize > MAX_WRITE_SIZE) {
|
|
56
|
+
if (!await flushBufferedChunks()) {
|
|
57
|
+
Logger(`Failed to flush buffered chunks for ${dispFilename}`, LOG_LEVEL_NOTICE);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
};
|
|
63
|
+
const addBuffer = async (id, data) => {
|
|
64
|
+
const chunk = {
|
|
65
|
+
_id: id,
|
|
66
|
+
data,
|
|
67
|
+
type: "leaf"
|
|
68
|
+
};
|
|
69
|
+
bufferedChunk.push(chunk);
|
|
70
|
+
chunks.push(chunk._id);
|
|
71
|
+
bufferedSize += chunk.data.length;
|
|
72
|
+
return await flushIfNeeded();
|
|
73
|
+
};
|
|
74
|
+
const pieces = await splitter.splitContent(note);
|
|
75
|
+
let totalChunkCount = 0;
|
|
76
|
+
try {
|
|
77
|
+
for await (const piece of pieces) {
|
|
78
|
+
totalChunkCount++;
|
|
79
|
+
if (piece.length === 0) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
createChunkCount++;
|
|
83
|
+
const chunk = await prepareChunk(managers, piece);
|
|
84
|
+
cachedCount += chunk.isNew ? 0 : 1;
|
|
85
|
+
newCount += chunk.isNew ? 1 : 0;
|
|
86
|
+
if (!await addBuffer(chunk.id, chunk.piece)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch (ex) {
|
|
91
|
+
Logger(`Error processing pieces for ${dispFilename}`);
|
|
92
|
+
Logger(ex, LOG_LEVEL_VERBOSE);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (!await flushBufferedChunks()) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
const dataSize = note.data.size;
|
|
99
|
+
const stats = `(\u2728: ${newCount}, \u{1F5C3}\uFE0F: ${cachedCount} (${resultCachedCount}) / \u{1F5C4}\uFE0F: ${writeCount}, \u267B:${duplicatedCount})`;
|
|
100
|
+
Logger(
|
|
101
|
+
`Chunks processed for ${dispFilename} (${dataSize}): \u{1F4DA}:${totalChunkCount} (${createChunkCount}) , \u{1F4E5}:${totalWritingCount} ${stats}`,
|
|
102
|
+
LOG_LEVEL_VERBOSE
|
|
103
|
+
);
|
|
104
|
+
if (dataSize > 0 && totalWritingCount === 0) {
|
|
105
|
+
Logger(
|
|
106
|
+
`No data to save in ${dispFilename}!! This document may be corrupted in the local database! Please back it up immediately, and report an issue!`,
|
|
107
|
+
LOG_LEVEL_NOTICE
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return chunks;
|
|
111
|
+
}
|
|
112
|
+
async function putDBEntry(host, managers, note, onlyChunks, conflictBaseRev) {
|
|
113
|
+
const { localDatabase, chunkManager, splitter } = managers;
|
|
114
|
+
const filename = host.services.path.id2path(note._id, note);
|
|
115
|
+
const dispFilename = stripAllPrefixes(filename);
|
|
116
|
+
if (!note.eden) note.eden = {};
|
|
117
|
+
if (!isTargetFile(host, filename)) {
|
|
118
|
+
Logger(`File skipped:${dispFilename}`, LOG_LEVEL_VERBOSE);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
const data = note.data instanceof Blob ? note.data : createTextBlob(note.data);
|
|
122
|
+
note.data = data;
|
|
123
|
+
note.type = isTextBlob(data) ? "plain" : "newnote";
|
|
124
|
+
note.datatype = note.type;
|
|
125
|
+
await splitter.initialised;
|
|
126
|
+
const result = await chunkManager.transaction(async () => {
|
|
127
|
+
const chunks = await createChunks(managers, dispFilename, note);
|
|
128
|
+
if (chunks === false) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (onlyChunks) {
|
|
132
|
+
return {
|
|
133
|
+
id: note._id,
|
|
134
|
+
ok: true,
|
|
135
|
+
rev: "dummy"
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const newDoc = {
|
|
139
|
+
children: chunks,
|
|
140
|
+
_id: note._id,
|
|
141
|
+
path: note.path,
|
|
142
|
+
ctime: note.ctime,
|
|
143
|
+
mtime: note.mtime,
|
|
144
|
+
size: note.size,
|
|
145
|
+
type: note.datatype,
|
|
146
|
+
eden: {}
|
|
147
|
+
};
|
|
148
|
+
return await serialized("file:" + filename, async () => {
|
|
149
|
+
if (conflictBaseRev) {
|
|
150
|
+
newDoc._rev = conflictBaseRev;
|
|
151
|
+
} else {
|
|
152
|
+
try {
|
|
153
|
+
const old = await localDatabase.get(newDoc._id);
|
|
154
|
+
newDoc._rev = old._rev;
|
|
155
|
+
} catch (ex) {
|
|
156
|
+
if (isErrorOfMissingDoc(ex)) {
|
|
157
|
+
} else {
|
|
158
|
+
throw ex;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const r = await localDatabase.put(newDoc, { force: true });
|
|
163
|
+
if (r.ok) {
|
|
164
|
+
return r;
|
|
165
|
+
} else {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}) ?? false;
|
|
169
|
+
});
|
|
170
|
+
if (result === false) {
|
|
171
|
+
Logger(`Failed to write document ${dispFilename}`, LOG_LEVEL_NOTICE);
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
Logger(`Document saved: ${dispFilename} (${result.id.substring(0, 8)}-${result.rev})`, LOG_LEVEL_VERBOSE);
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
function isTargetFile(host, filenameSrc) {
|
|
178
|
+
const settings = host.services.setting.currentSettings();
|
|
179
|
+
const file = filenameSrc.startsWith(ICHeader) ? filenameSrc.substring(ICHeader.length) : filenameSrc;
|
|
180
|
+
if (file.startsWith(ICXHeader)) return true;
|
|
181
|
+
if (file.startsWith(PSCHeader)) return true;
|
|
182
|
+
if (file.includes(":")) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
if (!settings.syncInternalFiles) {
|
|
186
|
+
if (file.startsWith(".")) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (settings.syncOnlyRegEx) {
|
|
191
|
+
const syncOnly = getFileRegExp(settings, "syncOnlyRegEx");
|
|
192
|
+
if (syncOnly.length > 0 && !syncOnly.some((e) => e.test(file))) return false;
|
|
193
|
+
}
|
|
194
|
+
if (settings.syncIgnoreRegEx) {
|
|
195
|
+
const syncIgnore = getFileRegExp(settings, "syncIgnoreRegEx");
|
|
196
|
+
if (syncIgnore.some((e) => e.test(file))) return false;
|
|
197
|
+
}
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
async function prepareChunk({ chunkManager, hashManager }, piece) {
|
|
201
|
+
const cachedChunkId = chunkManager.getChunkIDFromCache(piece);
|
|
202
|
+
if (cachedChunkId !== false) {
|
|
203
|
+
return { isNew: false, id: cachedChunkId, piece };
|
|
204
|
+
}
|
|
205
|
+
const chunkId = await hashManager.computeHash(piece);
|
|
206
|
+
return { isNew: true, id: `${IDPrefixes.Chunk}${chunkId}`, piece };
|
|
207
|
+
}
|
|
208
|
+
async function getDBEntryMetaByPath(host, { localDatabase }, path, opt, includeDeleted = false) {
|
|
209
|
+
if (!isTargetFile(host, path)) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
const id = await host.services.path.path2id(path);
|
|
213
|
+
try {
|
|
214
|
+
let obj = null;
|
|
215
|
+
if (opt) {
|
|
216
|
+
obj = await localDatabase.get(id, opt);
|
|
217
|
+
} else {
|
|
218
|
+
obj = await localDatabase.get(id);
|
|
219
|
+
}
|
|
220
|
+
const deleted = obj?.deleted ?? obj._deleted ?? void 0;
|
|
221
|
+
if (!includeDeleted && deleted) return false;
|
|
222
|
+
if (obj.type && obj.type == "leaf") {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
if (!obj.type || obj.type && obj.type == "notes" || obj.type == "newnote" || obj.type == "plain") {
|
|
226
|
+
const note = obj;
|
|
227
|
+
let children = [];
|
|
228
|
+
let type = "plain";
|
|
229
|
+
if (obj.type == "newnote" || obj.type == "plain") {
|
|
230
|
+
children = obj.children;
|
|
231
|
+
type = obj.type;
|
|
232
|
+
}
|
|
233
|
+
const doc = {
|
|
234
|
+
data: "",
|
|
235
|
+
_id: note._id,
|
|
236
|
+
path,
|
|
237
|
+
ctime: note.ctime,
|
|
238
|
+
mtime: note.mtime,
|
|
239
|
+
size: note.size,
|
|
240
|
+
// _deleted: obj._deleted,
|
|
241
|
+
_rev: obj._rev,
|
|
242
|
+
_conflicts: obj._conflicts,
|
|
243
|
+
children,
|
|
244
|
+
datatype: type,
|
|
245
|
+
deleted,
|
|
246
|
+
_revisions: obj?._revisions ?? void 0,
|
|
247
|
+
_revs_info: obj?._revs_info ?? void 0,
|
|
248
|
+
type,
|
|
249
|
+
eden: "eden" in obj ? obj.eden : {}
|
|
250
|
+
};
|
|
251
|
+
return doc;
|
|
252
|
+
}
|
|
253
|
+
} catch (ex) {
|
|
254
|
+
if (isErrorOfMissingDoc(ex)) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
throw ex;
|
|
258
|
+
}
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
function isLegacyNote(meta) {
|
|
262
|
+
return !meta.type || meta.type && meta.type == "notes";
|
|
263
|
+
}
|
|
264
|
+
function complementEntryMeta(note) {
|
|
265
|
+
const deleted = note.deleted ?? note._deleted ?? void 0;
|
|
266
|
+
const doc = {
|
|
267
|
+
data: note.data,
|
|
268
|
+
path: note.path,
|
|
269
|
+
_id: note._id,
|
|
270
|
+
ctime: note.ctime,
|
|
271
|
+
mtime: note.mtime,
|
|
272
|
+
size: note.size,
|
|
273
|
+
// _deleted: obj._deleted,
|
|
274
|
+
_rev: note._rev,
|
|
275
|
+
_conflicts: note._conflicts,
|
|
276
|
+
children: [],
|
|
277
|
+
datatype: "newnote",
|
|
278
|
+
deleted,
|
|
279
|
+
type: "newnote",
|
|
280
|
+
eden: "eden" in note ? note.eden : {}
|
|
281
|
+
};
|
|
282
|
+
return doc;
|
|
283
|
+
}
|
|
284
|
+
function respondOldFashionedEntry(note, dump = false) {
|
|
285
|
+
const doc = complementEntryMeta(note);
|
|
286
|
+
if (dump) {
|
|
287
|
+
Logger(`--Old fashioned document--`);
|
|
288
|
+
Logger(doc);
|
|
289
|
+
}
|
|
290
|
+
return doc;
|
|
291
|
+
}
|
|
292
|
+
function canUseOnDemandChunking(settings) {
|
|
293
|
+
if (settings.remoteType !== REMOTE_COUCHDB) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
if (settings.useOnlyLocalChunk) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
function canFetchRemotely(settings) {
|
|
302
|
+
if (!canUseOnDemandChunking(settings)) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
if (settings.remoteType === RemoteTypes.REMOTE_MINIO) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
function computeChunkRetrievalMethod(waitForReady, settings) {
|
|
311
|
+
const isOnDemandFetchEnabled = canFetchRemotely(settings);
|
|
312
|
+
if (!waitForReady) {
|
|
313
|
+
if (isOnDemandFetchEnabled) {
|
|
314
|
+
return {
|
|
315
|
+
waitForDelivery: true,
|
|
316
|
+
preventRemoteRequest: false
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
waitForDelivery: false,
|
|
321
|
+
preventRemoteRequest: true
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
waitForDelivery: true,
|
|
326
|
+
preventRemoteRequest: !isOnDemandFetchEnabled
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
async function respondEntryFromMeta({ localDatabase, chunkManager }, settings, filename, meta, dump, waitForReady) {
|
|
330
|
+
const dispFilename = stripAllPrefixes(filename);
|
|
331
|
+
const deleted = meta.deleted ?? meta._deleted ?? void 0;
|
|
332
|
+
if (dump) {
|
|
333
|
+
const conflicts = await localDatabase.get(meta._id, {
|
|
334
|
+
rev: meta._rev,
|
|
335
|
+
conflicts: true,
|
|
336
|
+
revs_info: true
|
|
337
|
+
});
|
|
338
|
+
Logger("-- Conflicts --");
|
|
339
|
+
Logger(conflicts._conflicts ?? "No conflicts");
|
|
340
|
+
Logger("-- Revs info -- ");
|
|
341
|
+
Logger(conflicts._revs_info);
|
|
342
|
+
}
|
|
343
|
+
try {
|
|
344
|
+
if (dump) {
|
|
345
|
+
Logger(`--Bare document--`);
|
|
346
|
+
Logger(meta);
|
|
347
|
+
}
|
|
348
|
+
let edenChunks = {};
|
|
349
|
+
if (meta.eden && Object.keys(meta.eden).length > 0) {
|
|
350
|
+
const chunks2 = Object.entries(meta.eden).map(([id, data]) => ({
|
|
351
|
+
_id: id,
|
|
352
|
+
data: data.data,
|
|
353
|
+
type: "leaf"
|
|
354
|
+
}));
|
|
355
|
+
edenChunks = Object.fromEntries(chunks2.map((e) => [e._id, e]));
|
|
356
|
+
}
|
|
357
|
+
const { waitForDelivery, preventRemoteRequest } = computeChunkRetrievalMethod(waitForReady, settings);
|
|
358
|
+
const childrenKeys = [...meta.children];
|
|
359
|
+
const chunks = await chunkManager.read(
|
|
360
|
+
childrenKeys,
|
|
361
|
+
{
|
|
362
|
+
skipCache: false,
|
|
363
|
+
waitForDelivery,
|
|
364
|
+
preventRemoteRequest
|
|
365
|
+
},
|
|
366
|
+
edenChunks
|
|
367
|
+
);
|
|
368
|
+
if (chunks.some((e) => e === false)) {
|
|
369
|
+
throw new Error("Load failed");
|
|
370
|
+
}
|
|
371
|
+
const doc = {
|
|
372
|
+
data: chunks.map((e) => e.data),
|
|
373
|
+
path: meta.path,
|
|
374
|
+
_id: meta._id,
|
|
375
|
+
ctime: meta.ctime,
|
|
376
|
+
mtime: meta.mtime,
|
|
377
|
+
size: meta.size,
|
|
378
|
+
_rev: meta._rev,
|
|
379
|
+
children: meta.children,
|
|
380
|
+
datatype: meta.type,
|
|
381
|
+
_conflicts: meta._conflicts,
|
|
382
|
+
eden: meta.eden,
|
|
383
|
+
deleted,
|
|
384
|
+
type: meta.type
|
|
385
|
+
};
|
|
386
|
+
if (dump) {
|
|
387
|
+
Logger(`--Loaded Document--`);
|
|
388
|
+
Logger(doc);
|
|
389
|
+
}
|
|
390
|
+
return doc;
|
|
391
|
+
} catch (ex) {
|
|
392
|
+
if (isErrorOfMissingDoc(ex)) {
|
|
393
|
+
Logger(
|
|
394
|
+
`Missing document content!, could not read ${dispFilename}(${meta._id.substring(0, 8)}) from database.`,
|
|
395
|
+
LOG_LEVEL_NOTICE
|
|
396
|
+
);
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
Logger(
|
|
400
|
+
`Something went wrong on reading ${dispFilename}(${meta._id.substring(0, 8)}) from database:`,
|
|
401
|
+
LOG_LEVEL_NOTICE
|
|
402
|
+
);
|
|
403
|
+
Logger(ex);
|
|
404
|
+
}
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
async function getDBEntryFromMeta(host, { localDatabase, chunkManager }, meta, dump = false, waitForReady = true) {
|
|
408
|
+
const filename = host.services.path.id2path(meta._id, meta);
|
|
409
|
+
if (!isTargetFile(host, filename)) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
const settings = host.services.setting.currentSettings();
|
|
413
|
+
if (isLegacyNote(meta)) {
|
|
414
|
+
const note = meta;
|
|
415
|
+
return respondOldFashionedEntry(note, dump);
|
|
416
|
+
}
|
|
417
|
+
if (meta.type == "newnote" || meta.type == "plain") {
|
|
418
|
+
return await respondEntryFromMeta(
|
|
419
|
+
{ localDatabase, chunkManager },
|
|
420
|
+
settings,
|
|
421
|
+
filename,
|
|
422
|
+
meta,
|
|
423
|
+
dump,
|
|
424
|
+
waitForReady
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
async function getDBEntryByPath(host, managers, path, opt, dump = false, waitForReady = true, includeDeleted = false) {
|
|
430
|
+
const meta = await getDBEntryMetaByPath(host, managers, path, opt, includeDeleted);
|
|
431
|
+
if (meta) {
|
|
432
|
+
return await getDBEntryFromMeta(host, managers, meta, dump, waitForReady);
|
|
433
|
+
} else {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
async function deleteDBEntryByPath(host, { localDatabase }, path, opt) {
|
|
438
|
+
if (!isTargetFile(host, path)) {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
const id = await host.services.path.path2id(path);
|
|
442
|
+
try {
|
|
443
|
+
return await serialized("file:" + path, async () => {
|
|
444
|
+
const settings = host.services.setting.currentSettings();
|
|
445
|
+
let obj = null;
|
|
446
|
+
if (opt) {
|
|
447
|
+
obj = await localDatabase.get(id, opt);
|
|
448
|
+
} else {
|
|
449
|
+
obj = await localDatabase.get(id);
|
|
450
|
+
}
|
|
451
|
+
const revDeletion = opt && ("rev" in opt ? opt.rev : "") != "";
|
|
452
|
+
if (obj.type && obj.type == "leaf") {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
if (!obj.type || obj.type && obj.type == "notes") {
|
|
456
|
+
obj._deleted = true;
|
|
457
|
+
const r = await localDatabase.put(obj, { force: !revDeletion });
|
|
458
|
+
Logger(`Entry removed: ${path} (${obj._id.substring(0, 8)}-${r.rev}) `);
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
if (obj.type == "newnote" || obj.type == "plain") {
|
|
462
|
+
if (revDeletion) {
|
|
463
|
+
obj._deleted = true;
|
|
464
|
+
} else {
|
|
465
|
+
obj.deleted = true;
|
|
466
|
+
obj.mtime = Date.now();
|
|
467
|
+
if (settings.deleteMetadataOfDeletedFiles) {
|
|
468
|
+
obj._deleted = true;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
const r = await localDatabase.put(obj, { force: !revDeletion });
|
|
472
|
+
Logger(
|
|
473
|
+
`Entry removed: [${revDeletion ? "REV" : "DEL"}] ${path} (${obj._id.substring(0, 8)}-${r.rev})`
|
|
474
|
+
);
|
|
475
|
+
return true;
|
|
476
|
+
} else {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
}) ?? false;
|
|
480
|
+
} catch (ex) {
|
|
481
|
+
if (isErrorOfMissingDoc(ex)) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
throw ex;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
export {
|
|
488
|
+
canUseOnDemandChunking,
|
|
489
|
+
computeChunkRetrievalMethod,
|
|
490
|
+
createChunks,
|
|
491
|
+
deleteDBEntryByPath,
|
|
492
|
+
getDBEntryByPath,
|
|
493
|
+
getDBEntryFromMeta,
|
|
494
|
+
getDBEntryMetaByPath,
|
|
495
|
+
isLegacyNote,
|
|
496
|
+
isTargetFile,
|
|
497
|
+
prepareChunk,
|
|
498
|
+
putDBEntry
|
|
499
|
+
};
|