@verdant-web/store 2.0.1 → 2.0.2
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/dist/cjs/BackoffScheduler.d.ts +19 -19
- package/dist/cjs/BackoffScheduler.js +44 -44
- package/dist/cjs/DocumentManager.d.ts +28 -28
- package/dist/cjs/DocumentManager.js +44 -44
- package/dist/cjs/IDBService.d.ts +9 -9
- package/dist/cjs/IDBService.js +46 -46
- package/dist/cjs/UndoHistory.d.ts +16 -16
- package/dist/cjs/UndoHistory.js +50 -50
- package/dist/cjs/__tests__/batching.test.d.ts +1 -1
- package/dist/cjs/__tests__/batching.test.js +44 -44
- package/dist/cjs/__tests__/documents.test.d.ts +1 -1
- package/dist/cjs/__tests__/documents.test.js +398 -398
- package/dist/cjs/__tests__/fixtures/testStorage.d.ts +118 -118
- package/dist/cjs/__tests__/fixtures/testStorage.js +115 -115
- package/dist/cjs/__tests__/queries.test.d.ts +1 -1
- package/dist/cjs/__tests__/queries.test.js +262 -262
- package/dist/cjs/__tests__/setup/indexedDB.d.ts +1 -1
- package/dist/cjs/__tests__/setup/indexedDB.js +3 -3
- package/dist/cjs/__tests__/undo.test.d.ts +1 -1
- package/dist/cjs/__tests__/undo.test.js +86 -86
- package/dist/cjs/client/Client.d.ts +86 -86
- package/dist/cjs/client/Client.js +226 -226
- package/dist/cjs/client/ClientDescriptor.d.ts +62 -62
- package/dist/cjs/client/ClientDescriptor.js +108 -108
- package/dist/cjs/constants.d.ts +1 -1
- package/dist/cjs/constants.js +4 -4
- package/dist/cjs/context.d.ts +17 -17
- package/dist/cjs/context.js +2 -2
- package/dist/cjs/files/EntityFile.d.ts +27 -27
- package/dist/cjs/files/EntityFile.js +71 -71
- package/dist/cjs/files/FileManager.d.ts +42 -42
- package/dist/cjs/files/FileManager.js +145 -145
- package/dist/cjs/files/FileStorage.d.ts +27 -27
- package/dist/cjs/files/FileStorage.js +93 -93
- package/dist/cjs/files/utils.d.ts +8 -8
- package/dist/cjs/files/utils.js +55 -55
- package/dist/cjs/files/utils.test.d.ts +1 -1
- package/dist/cjs/files/utils.test.js +80 -80
- package/dist/cjs/idb.d.ts +8 -8
- package/dist/cjs/idb.js +87 -87
- package/dist/cjs/index.d.ts +19 -19
- package/dist/cjs/index.js +20 -20
- package/dist/cjs/indexes.d.ts +3 -3
- package/dist/cjs/indexes.js +19 -19
- package/dist/cjs/metadata/AckInfoStore.d.ts +10 -10
- package/dist/cjs/metadata/AckInfoStore.js +25 -25
- package/dist/cjs/metadata/BaselinesStore.d.ts +33 -33
- package/dist/cjs/metadata/BaselinesStore.js +59 -59
- package/dist/cjs/metadata/LocalReplicaStore.d.ts +17 -17
- package/dist/cjs/metadata/LocalReplicaStore.js +47 -47
- package/dist/cjs/metadata/MessageCreator.d.ts +19 -19
- package/dist/cjs/metadata/MessageCreator.js +127 -127
- package/dist/cjs/metadata/Metadata.d.ts +106 -106
- package/dist/cjs/metadata/Metadata.js +336 -336
- package/dist/cjs/metadata/OperationsStore.d.ts +50 -50
- package/dist/cjs/metadata/OperationsStore.js +145 -145
- package/dist/cjs/metadata/SchemaStore.d.ts +9 -9
- package/dist/cjs/metadata/SchemaStore.js +38 -38
- package/dist/cjs/metadata/openMetadataDatabase.d.ts +8 -8
- package/dist/cjs/metadata/openMetadataDatabase.js +105 -105
- package/dist/cjs/openDocumentDatabase.d.ts +12 -12
- package/dist/cjs/openDocumentDatabase.js +424 -424
- package/dist/cjs/queries2/BaseQuery.d.ts +39 -39
- package/dist/cjs/queries2/BaseQuery.js +98 -98
- package/dist/cjs/queries2/CollectionQueries.d.ts +55 -55
- package/dist/cjs/queries2/CollectionQueries.js +82 -82
- package/dist/cjs/queries2/FindAllQuery.d.ts +11 -11
- package/dist/cjs/queries2/FindAllQuery.js +33 -33
- package/dist/cjs/queries2/FindInfiniteQuery.d.ts +18 -18
- package/dist/cjs/queries2/FindInfiniteQuery.js +60 -60
- package/dist/cjs/queries2/FindOneQuery.d.ts +11 -11
- package/dist/cjs/queries2/FindOneQuery.js +33 -33
- package/dist/cjs/queries2/FindPageQuery.d.ts +23 -23
- package/dist/cjs/queries2/FindPageQuery.js +67 -67
- package/dist/cjs/queries2/GetQuery.d.ts +10 -10
- package/dist/cjs/queries2/GetQuery.js +29 -29
- package/dist/cjs/queries2/QueryCache.d.ts +16 -16
- package/dist/cjs/queries2/QueryCache.js +39 -39
- package/dist/cjs/queries2/dbQueries.d.ts +22 -22
- package/dist/cjs/queries2/dbQueries.js +125 -125
- package/dist/cjs/queries2/keys.d.ts +10 -10
- package/dist/cjs/queries2/keys.js +33 -33
- package/dist/cjs/queries2/ranges.d.ts +2 -2
- package/dist/cjs/queries2/ranges.js +69 -69
- package/dist/cjs/queries2/types.d.ts +6 -6
- package/dist/cjs/queries2/types.js +2 -2
- package/dist/cjs/queries2/utils.d.ts +1 -1
- package/dist/cjs/queries2/utils.js +19 -19
- package/dist/cjs/reactives/DocumentFamiliyCache.d.ts +47 -47
- package/dist/cjs/reactives/DocumentFamiliyCache.js +210 -210
- package/dist/cjs/reactives/Entity.d.ts +191 -191
- package/dist/cjs/reactives/Entity.js +462 -462
- package/dist/cjs/reactives/EntityStore.d.ts +84 -84
- package/dist/cjs/reactives/EntityStore.js +421 -421
- package/dist/cjs/reactives/FakeWeakRef.d.ts +11 -11
- package/dist/cjs/reactives/FakeWeakRef.js +18 -18
- package/dist/cjs/sync/FileSync.d.ts +23 -23
- package/dist/cjs/sync/FileSync.js +84 -84
- package/dist/cjs/sync/Heartbeat.d.ts +24 -24
- package/dist/cjs/sync/Heartbeat.js +55 -55
- package/dist/cjs/sync/PresenceManager.d.ts +41 -41
- package/dist/cjs/sync/PresenceManager.js +107 -107
- package/dist/cjs/sync/PushPullSync.d.ts +36 -36
- package/dist/cjs/sync/PushPullSync.js +141 -141
- package/dist/cjs/sync/ServerSyncEndpointProvider.d.ts +27 -27
- package/dist/cjs/sync/ServerSyncEndpointProvider.js +64 -64
- package/dist/cjs/sync/Sync.d.ts +127 -127
- package/dist/cjs/sync/Sync.js +244 -244
- package/dist/cjs/sync/WebSocketSync.d.ts +41 -41
- package/dist/cjs/sync/WebSocketSync.js +183 -183
- package/dist/cjs/types.d.ts +5 -5
- package/dist/cjs/types.js +2 -2
- package/dist/cjs/utils/Disposable.d.ts +6 -6
- package/dist/cjs/utils/Disposable.js +18 -18
- package/dist/cjs/utils/Resolvable.d.ts +8 -8
- package/dist/cjs/utils/Resolvable.js +22 -22
- package/dist/esm/BackoffScheduler.d.ts +19 -19
- package/dist/esm/BackoffScheduler.js +39 -39
- package/dist/esm/DocumentManager.d.ts +28 -28
- package/dist/esm/DocumentManager.js +40 -40
- package/dist/esm/IDBService.d.ts +9 -9
- package/dist/esm/IDBService.js +42 -42
- package/dist/esm/UndoHistory.d.ts +16 -16
- package/dist/esm/UndoHistory.js +46 -46
- package/dist/esm/__tests__/batching.test.d.ts +1 -1
- package/dist/esm/__tests__/batching.test.js +42 -42
- package/dist/esm/__tests__/documents.test.d.ts +1 -1
- package/dist/esm/__tests__/documents.test.js +396 -396
- package/dist/esm/__tests__/fixtures/testStorage.d.ts +118 -118
- package/dist/esm/__tests__/fixtures/testStorage.js +111 -111
- package/dist/esm/__tests__/queries.test.d.ts +1 -1
- package/dist/esm/__tests__/queries.test.js +260 -260
- package/dist/esm/__tests__/setup/indexedDB.d.ts +1 -1
- package/dist/esm/__tests__/setup/indexedDB.js +1 -1
- package/dist/esm/__tests__/undo.test.d.ts +1 -1
- package/dist/esm/__tests__/undo.test.js +84 -84
- package/dist/esm/client/Client.d.ts +86 -86
- package/dist/esm/client/Client.js +222 -222
- package/dist/esm/client/ClientDescriptor.d.ts +62 -62
- package/dist/esm/client/ClientDescriptor.js +104 -104
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/context.d.ts +17 -17
- package/dist/esm/context.js +1 -1
- package/dist/esm/files/EntityFile.d.ts +27 -27
- package/dist/esm/files/EntityFile.js +67 -67
- package/dist/esm/files/FileManager.d.ts +42 -42
- package/dist/esm/files/FileManager.js +141 -141
- package/dist/esm/files/FileStorage.d.ts +27 -27
- package/dist/esm/files/FileStorage.js +88 -88
- package/dist/esm/files/utils.d.ts +8 -8
- package/dist/esm/files/utils.js +46 -46
- package/dist/esm/files/utils.test.d.ts +1 -1
- package/dist/esm/files/utils.test.js +78 -78
- package/dist/esm/idb.d.ts +8 -8
- package/dist/esm/idb.js +79 -79
- package/dist/esm/index.d.ts +19 -19
- package/dist/esm/index.js +11 -11
- package/dist/esm/indexes.d.ts +3 -3
- package/dist/esm/indexes.js +14 -14
- package/dist/esm/metadata/AckInfoStore.d.ts +10 -10
- package/dist/esm/metadata/AckInfoStore.js +21 -21
- package/dist/esm/metadata/BaselinesStore.d.ts +33 -33
- package/dist/esm/metadata/BaselinesStore.js +55 -55
- package/dist/esm/metadata/LocalReplicaStore.d.ts +17 -17
- package/dist/esm/metadata/LocalReplicaStore.js +40 -40
- package/dist/esm/metadata/MessageCreator.d.ts +19 -19
- package/dist/esm/metadata/MessageCreator.js +123 -123
- package/dist/esm/metadata/Metadata.d.ts +106 -106
- package/dist/esm/metadata/Metadata.js +332 -332
- package/dist/esm/metadata/OperationsStore.d.ts +50 -50
- package/dist/esm/metadata/OperationsStore.js +141 -141
- package/dist/esm/metadata/SchemaStore.d.ts +9 -9
- package/dist/esm/metadata/SchemaStore.js +34 -34
- package/dist/esm/metadata/openMetadataDatabase.d.ts +8 -8
- package/dist/esm/metadata/openMetadataDatabase.js +101 -101
- package/dist/esm/openDocumentDatabase.d.ts +12 -12
- package/dist/esm/openDocumentDatabase.js +420 -420
- package/dist/esm/queries2/BaseQuery.d.ts +39 -39
- package/dist/esm/queries2/BaseQuery.js +94 -94
- package/dist/esm/queries2/CollectionQueries.d.ts +55 -55
- package/dist/esm/queries2/CollectionQueries.js +78 -78
- package/dist/esm/queries2/FindAllQuery.d.ts +11 -11
- package/dist/esm/queries2/FindAllQuery.js +29 -29
- package/dist/esm/queries2/FindInfiniteQuery.d.ts +18 -18
- package/dist/esm/queries2/FindInfiniteQuery.js +56 -56
- package/dist/esm/queries2/FindOneQuery.d.ts +11 -11
- package/dist/esm/queries2/FindOneQuery.js +29 -29
- package/dist/esm/queries2/FindPageQuery.d.ts +23 -23
- package/dist/esm/queries2/FindPageQuery.js +63 -63
- package/dist/esm/queries2/GetQuery.d.ts +10 -10
- package/dist/esm/queries2/GetQuery.js +25 -25
- package/dist/esm/queries2/QueryCache.d.ts +16 -16
- package/dist/esm/queries2/QueryCache.js +35 -35
- package/dist/esm/queries2/dbQueries.d.ts +22 -22
- package/dist/esm/queries2/dbQueries.js +119 -119
- package/dist/esm/queries2/keys.d.ts +10 -10
- package/dist/esm/queries2/keys.js +29 -29
- package/dist/esm/queries2/ranges.d.ts +2 -2
- package/dist/esm/queries2/ranges.js +65 -65
- package/dist/esm/queries2/types.d.ts +6 -6
- package/dist/esm/queries2/types.js +1 -1
- package/dist/esm/queries2/utils.d.ts +1 -1
- package/dist/esm/queries2/utils.js +15 -15
- package/dist/esm/reactives/DocumentFamiliyCache.d.ts +47 -47
- package/dist/esm/reactives/DocumentFamiliyCache.js +206 -206
- package/dist/esm/reactives/Entity.d.ts +191 -191
- package/dist/esm/reactives/Entity.js +457 -457
- package/dist/esm/reactives/EntityStore.d.ts +84 -84
- package/dist/esm/reactives/EntityStore.js +417 -417
- package/dist/esm/reactives/FakeWeakRef.d.ts +11 -11
- package/dist/esm/reactives/FakeWeakRef.js +14 -14
- package/dist/esm/sync/FileSync.d.ts +23 -23
- package/dist/esm/sync/FileSync.js +80 -80
- package/dist/esm/sync/Heartbeat.d.ts +24 -24
- package/dist/esm/sync/Heartbeat.js +51 -51
- package/dist/esm/sync/PresenceManager.d.ts +41 -41
- package/dist/esm/sync/PresenceManager.js +103 -103
- package/dist/esm/sync/PushPullSync.d.ts +36 -36
- package/dist/esm/sync/PushPullSync.js +137 -137
- package/dist/esm/sync/ServerSyncEndpointProvider.d.ts +27 -27
- package/dist/esm/sync/ServerSyncEndpointProvider.js +57 -57
- package/dist/esm/sync/Sync.d.ts +127 -127
- package/dist/esm/sync/Sync.js +239 -239
- package/dist/esm/sync/{WebsocketSync.d.ts → WebSocketSync.d.ts} +41 -41
- package/dist/esm/sync/{WebsocketSync.js → WebSocketSync.js} +179 -179
- package/dist/esm/types.d.ts +5 -5
- package/dist/esm/types.js +1 -1
- package/dist/esm/utils/Disposable.d.ts +6 -6
- package/dist/esm/utils/Disposable.js +14 -14
- package/dist/esm/utils/Resolvable.d.ts +8 -8
- package/dist/esm/utils/Resolvable.js +18 -18
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/cjs/AckInfoStore.d.ts +0 -10
- package/dist/cjs/AckInfoStore.js +0 -26
- package/dist/cjs/AckInfoStore.js.map +0 -1
- package/dist/cjs/BaselinesStore.d.ts +0 -10
- package/dist/cjs/BaselinesStore.js +0 -36
- package/dist/cjs/BaselinesStore.js.map +0 -1
- package/dist/cjs/Entity.d.ts +0 -96
- package/dist/cjs/Entity.js +0 -345
- package/dist/cjs/Entity.js.map +0 -1
- package/dist/cjs/EntityStore.d.ts +0 -36
- package/dist/cjs/EntityStore.js +0 -172
- package/dist/cjs/EntityStore.js.map +0 -1
- package/dist/cjs/LocalHistoryStore.d.ts +0 -15
- package/dist/cjs/LocalHistoryStore.js +0 -53
- package/dist/cjs/LocalHistoryStore.js.map +0 -1
- package/dist/cjs/LocalReplicaStore.d.ts +0 -13
- package/dist/cjs/LocalReplicaStore.js +0 -49
- package/dist/cjs/LocalReplicaStore.js.map +0 -1
- package/dist/cjs/MessageCreator.d.ts +0 -19
- package/dist/cjs/MessageCreator.js +0 -104
- package/dist/cjs/MessageCreator.js.map +0 -1
- package/dist/cjs/Metadata.d.ts +0 -91
- package/dist/cjs/Metadata.js +0 -250
- package/dist/cjs/Metadata.js.map +0 -1
- package/dist/cjs/OperationsStore.d.ts +0 -38
- package/dist/cjs/OperationsStore.js +0 -146
- package/dist/cjs/OperationsStore.js.map +0 -1
- package/dist/cjs/PresenceManager.d.ts +0 -30
- package/dist/cjs/PresenceManager.js +0 -89
- package/dist/cjs/PresenceManager.js.map +0 -1
- package/dist/cjs/Query.d.ts +0 -26
- package/dist/cjs/Query.js +0 -86
- package/dist/cjs/Query.js.map +0 -1
- package/dist/cjs/QueryMaker.d.ts +0 -18
- package/dist/cjs/QueryMaker.js +0 -98
- package/dist/cjs/QueryMaker.js.map +0 -1
- package/dist/cjs/QueryStore.d.ts +0 -38
- package/dist/cjs/QueryStore.js +0 -146
- package/dist/cjs/QueryStore.js.map +0 -1
- package/dist/cjs/SchemaStore.d.ts +0 -9
- package/dist/cjs/SchemaStore.js +0 -35
- package/dist/cjs/SchemaStore.js.map +0 -1
- package/dist/cjs/Storage.d.ts +0 -147
- package/dist/cjs/Storage.js +0 -346
- package/dist/cjs/Storage.js.map +0 -1
- package/dist/cjs/Sync.d.ts +0 -117
- package/dist/cjs/Sync.js +0 -561
- package/dist/cjs/Sync.js.map +0 -1
- package/dist/cjs/SyncHarness.d.ts +0 -45
- package/dist/cjs/SyncHarness.js +0 -110
- package/dist/cjs/SyncHarness.js.map +0 -1
- package/dist/cjs/metadata/LocalHistoryStore.d.ts +0 -15
- package/dist/cjs/metadata/LocalHistoryStore.js +0 -53
- package/dist/cjs/metadata/LocalHistoryStore.js.map +0 -1
- package/dist/cjs/queries/LiveQuery.d.ts +0 -28
- package/dist/cjs/queries/LiveQuery.js +0 -96
- package/dist/cjs/queries/LiveQuery.js.map +0 -1
- package/dist/cjs/queries/LiveQueryMaker.d.ts +0 -15
- package/dist/cjs/queries/LiveQueryMaker.js +0 -42
- package/dist/cjs/queries/LiveQueryMaker.js.map +0 -1
- package/dist/cjs/queries/LiveQueryStore.d.ts +0 -33
- package/dist/cjs/queries/LiveQueryStore.js +0 -85
- package/dist/cjs/queries/LiveQueryStore.js.map +0 -1
- package/dist/cjs/queries/Query.d.ts +0 -18
- package/dist/cjs/queries/Query.js +0 -36
- package/dist/cjs/queries/Query.js.map +0 -1
- package/dist/cjs/queries/QueryMaker.d.ts +0 -14
- package/dist/cjs/queries/QueryMaker.js +0 -42
- package/dist/cjs/queries/QueryMaker.js.map +0 -1
- package/dist/cjs/queries/QueryStore.d.ts +0 -35
- package/dist/cjs/queries/QueryStore.js +0 -130
- package/dist/cjs/queries/QueryStore.js.map +0 -1
- package/dist/cjs/queries/ranges.d.ts +0 -2
- package/dist/cjs/queries/ranges.js +0 -70
- package/dist/cjs/queries/ranges.js.map +0 -1
- package/dist/cjs/v2/AckInfoStore.d.ts +0 -10
- package/dist/cjs/v2/AckInfoStore.js +0 -26
- package/dist/cjs/v2/AckInfoStore.js.map +0 -1
- package/dist/cjs/v2/BaselinesStore.d.ts +0 -10
- package/dist/cjs/v2/BaselinesStore.js +0 -36
- package/dist/cjs/v2/BaselinesStore.js.map +0 -1
- package/dist/cjs/v2/DocumentManager.d.ts +0 -19
- package/dist/cjs/v2/DocumentManager.js +0 -47
- package/dist/cjs/v2/DocumentManager.js.map +0 -1
- package/dist/cjs/v2/Entity.d.ts +0 -87
- package/dist/cjs/v2/Entity.js +0 -305
- package/dist/cjs/v2/Entity.js.map +0 -1
- package/dist/cjs/v2/EntityStore.d.ts +0 -37
- package/dist/cjs/v2/EntityStore.js +0 -165
- package/dist/cjs/v2/EntityStore.js.map +0 -1
- package/dist/cjs/v2/IDBService.d.ts +0 -7
- package/dist/cjs/v2/IDBService.js +0 -26
- package/dist/cjs/v2/IDBService.js.map +0 -1
- package/dist/cjs/v2/LocalHistoryStore.d.ts +0 -15
- package/dist/cjs/v2/LocalHistoryStore.js +0 -53
- package/dist/cjs/v2/LocalHistoryStore.js.map +0 -1
- package/dist/cjs/v2/LocalReplicaStore.d.ts +0 -14
- package/dist/cjs/v2/LocalReplicaStore.js +0 -49
- package/dist/cjs/v2/LocalReplicaStore.js.map +0 -1
- package/dist/cjs/v2/MessageCreator.d.ts +0 -19
- package/dist/cjs/v2/MessageCreator.js +0 -99
- package/dist/cjs/v2/MessageCreator.js.map +0 -1
- package/dist/cjs/v2/Metadata.d.ts +0 -90
- package/dist/cjs/v2/Metadata.js +0 -251
- package/dist/cjs/v2/Metadata.js.map +0 -1
- package/dist/cjs/v2/OperationsStore.d.ts +0 -38
- package/dist/cjs/v2/OperationsStore.js +0 -146
- package/dist/cjs/v2/OperationsStore.js.map +0 -1
- package/dist/cjs/v2/PresenceManager.d.ts +0 -24
- package/dist/cjs/v2/PresenceManager.js +0 -73
- package/dist/cjs/v2/PresenceManager.js.map +0 -1
- package/dist/cjs/v2/Query.d.ts +0 -24
- package/dist/cjs/v2/Query.js +0 -79
- package/dist/cjs/v2/Query.js.map +0 -1
- package/dist/cjs/v2/QueryMaker.d.ts +0 -16
- package/dist/cjs/v2/QueryMaker.js +0 -84
- package/dist/cjs/v2/QueryMaker.js.map +0 -1
- package/dist/cjs/v2/QueryStore.d.ts +0 -26
- package/dist/cjs/v2/QueryStore.js +0 -136
- package/dist/cjs/v2/QueryStore.js.map +0 -1
- package/dist/cjs/v2/SchemaStore.d.ts +0 -9
- package/dist/cjs/v2/SchemaStore.js +0 -35
- package/dist/cjs/v2/SchemaStore.js.map +0 -1
- package/dist/cjs/v2/Storage.d.ts +0 -80
- package/dist/cjs/v2/Storage.js +0 -154
- package/dist/cjs/v2/Storage.js.map +0 -1
- package/dist/cjs/v2/Sync.d.ts +0 -42
- package/dist/cjs/v2/Sync.js +0 -98
- package/dist/cjs/v2/Sync.js.map +0 -1
- package/dist/cjs/v2/SyncHarness.d.ts +0 -45
- package/dist/cjs/v2/SyncHarness.js +0 -110
- package/dist/cjs/v2/SyncHarness.js.map +0 -1
- package/dist/cjs/v2/__tests__/documents.test.d.ts +0 -1
- package/dist/cjs/v2/__tests__/documents.test.js +0 -185
- package/dist/cjs/v2/__tests__/documents.test.js.map +0 -1
- package/dist/cjs/v2/__tests__/fixtures/testStorage.d.ts +0 -189
- package/dist/cjs/v2/__tests__/fixtures/testStorage.js +0 -93
- package/dist/cjs/v2/__tests__/fixtures/testStorage.js.map +0 -1
- package/dist/cjs/v2/__tests__/queries.test.d.ts +0 -1
- package/dist/cjs/v2/__tests__/queries.test.js +0 -92
- package/dist/cjs/v2/__tests__/queries.test.js.map +0 -1
- package/dist/cjs/v2/__tests__/setup/indexedDB.d.ts +0 -1
- package/dist/cjs/v2/__tests__/setup/indexedDB.js +0 -4
- package/dist/cjs/v2/__tests__/setup/indexedDB.js.map +0 -1
- package/dist/cjs/v2/constants.d.ts +0 -1
- package/dist/cjs/v2/constants.js +0 -5
- package/dist/cjs/v2/constants.js.map +0 -1
- package/dist/cjs/v2/idb.d.ts +0 -6
- package/dist/cjs/v2/idb.js +0 -71
- package/dist/cjs/v2/idb.js.map +0 -1
- package/dist/cjs/v2/index.d.ts +0 -6
- package/dist/cjs/v2/index.js +0 -14
- package/dist/cjs/v2/index.js.map +0 -1
- package/dist/cjs/v2/indexes.d.ts +0 -3
- package/dist/cjs/v2/indexes.js +0 -20
- package/dist/cjs/v2/indexes.js.map +0 -1
- package/dist/cjs/v2/openDocumentDatabase.d.ts +0 -9
- package/dist/cjs/v2/openDocumentDatabase.js +0 -100
- package/dist/cjs/v2/openDocumentDatabase.js.map +0 -1
- package/dist/cjs/v2/types.d.ts +0 -3
- package/dist/cjs/v2/types.js +0 -3
- package/dist/cjs/v2/types.js.map +0 -1
- package/dist/esm/AckInfoStore.d.ts +0 -10
- package/dist/esm/AckInfoStore.js +0 -22
- package/dist/esm/AckInfoStore.js.map +0 -1
- package/dist/esm/BaselinesStore.d.ts +0 -10
- package/dist/esm/BaselinesStore.js +0 -32
- package/dist/esm/BaselinesStore.js.map +0 -1
- package/dist/esm/Entity.d.ts +0 -96
- package/dist/esm/Entity.js +0 -337
- package/dist/esm/Entity.js.map +0 -1
- package/dist/esm/EntityStore.d.ts +0 -36
- package/dist/esm/EntityStore.js +0 -168
- package/dist/esm/EntityStore.js.map +0 -1
- package/dist/esm/LocalHistoryStore.d.ts +0 -15
- package/dist/esm/LocalHistoryStore.js +0 -49
- package/dist/esm/LocalHistoryStore.js.map +0 -1
- package/dist/esm/LocalReplicaStore.d.ts +0 -13
- package/dist/esm/LocalReplicaStore.js +0 -42
- package/dist/esm/LocalReplicaStore.js.map +0 -1
- package/dist/esm/MessageCreator.d.ts +0 -19
- package/dist/esm/MessageCreator.js +0 -97
- package/dist/esm/MessageCreator.js.map +0 -1
- package/dist/esm/Metadata.d.ts +0 -91
- package/dist/esm/Metadata.js +0 -245
- package/dist/esm/Metadata.js.map +0 -1
- package/dist/esm/OperationsStore.d.ts +0 -38
- package/dist/esm/OperationsStore.js +0 -142
- package/dist/esm/OperationsStore.js.map +0 -1
- package/dist/esm/PresenceManager.d.ts +0 -30
- package/dist/esm/PresenceManager.js +0 -85
- package/dist/esm/PresenceManager.js.map +0 -1
- package/dist/esm/Query.d.ts +0 -26
- package/dist/esm/Query.js +0 -82
- package/dist/esm/Query.js.map +0 -1
- package/dist/esm/QueryMaker.d.ts +0 -18
- package/dist/esm/QueryMaker.js +0 -94
- package/dist/esm/QueryMaker.js.map +0 -1
- package/dist/esm/QueryStore.d.ts +0 -38
- package/dist/esm/QueryStore.js +0 -142
- package/dist/esm/QueryStore.js.map +0 -1
- package/dist/esm/SchemaStore.d.ts +0 -9
- package/dist/esm/SchemaStore.js +0 -31
- package/dist/esm/SchemaStore.js.map +0 -1
- package/dist/esm/Storage.d.ts +0 -147
- package/dist/esm/Storage.js +0 -341
- package/dist/esm/Storage.js.map +0 -1
- package/dist/esm/Sync.d.ts +0 -117
- package/dist/esm/Sync.js +0 -553
- package/dist/esm/Sync.js.map +0 -1
- package/dist/esm/SyncHarness.d.ts +0 -45
- package/dist/esm/SyncHarness.js +0 -105
- package/dist/esm/SyncHarness.js.map +0 -1
- package/dist/esm/metadata/LocalHistoryStore.d.ts +0 -15
- package/dist/esm/metadata/LocalHistoryStore.js +0 -49
- package/dist/esm/metadata/LocalHistoryStore.js.map +0 -1
- package/dist/esm/queries/LiveQuery.d.ts +0 -28
- package/dist/esm/queries/LiveQuery.js +0 -92
- package/dist/esm/queries/LiveQuery.js.map +0 -1
- package/dist/esm/queries/LiveQueryMaker.d.ts +0 -15
- package/dist/esm/queries/LiveQueryMaker.js +0 -38
- package/dist/esm/queries/LiveQueryMaker.js.map +0 -1
- package/dist/esm/queries/LiveQueryStore.d.ts +0 -33
- package/dist/esm/queries/LiveQueryStore.js +0 -81
- package/dist/esm/queries/LiveQueryStore.js.map +0 -1
- package/dist/esm/queries/Query.d.ts +0 -18
- package/dist/esm/queries/Query.js +0 -32
- package/dist/esm/queries/Query.js.map +0 -1
- package/dist/esm/queries/QueryMaker.d.ts +0 -14
- package/dist/esm/queries/QueryMaker.js +0 -38
- package/dist/esm/queries/QueryMaker.js.map +0 -1
- package/dist/esm/queries/QueryStore.d.ts +0 -35
- package/dist/esm/queries/QueryStore.js +0 -126
- package/dist/esm/queries/QueryStore.js.map +0 -1
- package/dist/esm/queries/ranges.d.ts +0 -2
- package/dist/esm/queries/ranges.js +0 -66
- package/dist/esm/queries/ranges.js.map +0 -1
- package/dist/esm/v2/AckInfoStore.d.ts +0 -10
- package/dist/esm/v2/AckInfoStore.js +0 -22
- package/dist/esm/v2/AckInfoStore.js.map +0 -1
- package/dist/esm/v2/BaselinesStore.d.ts +0 -10
- package/dist/esm/v2/BaselinesStore.js +0 -32
- package/dist/esm/v2/BaselinesStore.js.map +0 -1
- package/dist/esm/v2/DocumentManager.d.ts +0 -19
- package/dist/esm/v2/DocumentManager.js +0 -43
- package/dist/esm/v2/DocumentManager.js.map +0 -1
- package/dist/esm/v2/Entity.d.ts +0 -91
- package/dist/esm/v2/Entity.js +0 -305
- package/dist/esm/v2/Entity.js.map +0 -1
- package/dist/esm/v2/EntityStore.d.ts +0 -37
- package/dist/esm/v2/EntityStore.js +0 -166
- package/dist/esm/v2/EntityStore.js.map +0 -1
- package/dist/esm/v2/IDBService.d.ts +0 -7
- package/dist/esm/v2/IDBService.js +0 -22
- package/dist/esm/v2/IDBService.js.map +0 -1
- package/dist/esm/v2/LocalHistoryStore.d.ts +0 -15
- package/dist/esm/v2/LocalHistoryStore.js +0 -49
- package/dist/esm/v2/LocalHistoryStore.js.map +0 -1
- package/dist/esm/v2/LocalReplicaStore.d.ts +0 -14
- package/dist/esm/v2/LocalReplicaStore.js +0 -42
- package/dist/esm/v2/LocalReplicaStore.js.map +0 -1
- package/dist/esm/v2/MessageCreator.d.ts +0 -19
- package/dist/esm/v2/MessageCreator.js +0 -92
- package/dist/esm/v2/MessageCreator.js.map +0 -1
- package/dist/esm/v2/Metadata.d.ts +0 -90
- package/dist/esm/v2/Metadata.js +0 -246
- package/dist/esm/v2/Metadata.js.map +0 -1
- package/dist/esm/v2/OperationsStore.d.ts +0 -38
- package/dist/esm/v2/OperationsStore.js +0 -142
- package/dist/esm/v2/OperationsStore.js.map +0 -1
- package/dist/esm/v2/PresenceManager.d.ts +0 -24
- package/dist/esm/v2/PresenceManager.js +0 -69
- package/dist/esm/v2/PresenceManager.js.map +0 -1
- package/dist/esm/v2/Query.d.ts +0 -24
- package/dist/esm/v2/Query.js +0 -75
- package/dist/esm/v2/Query.js.map +0 -1
- package/dist/esm/v2/QueryMaker.d.ts +0 -16
- package/dist/esm/v2/QueryMaker.js +0 -80
- package/dist/esm/v2/QueryMaker.js.map +0 -1
- package/dist/esm/v2/QueryStore.d.ts +0 -26
- package/dist/esm/v2/QueryStore.js +0 -132
- package/dist/esm/v2/QueryStore.js.map +0 -1
- package/dist/esm/v2/SchemaStore.d.ts +0 -9
- package/dist/esm/v2/SchemaStore.js +0 -31
- package/dist/esm/v2/SchemaStore.js.map +0 -1
- package/dist/esm/v2/Storage.d.ts +0 -80
- package/dist/esm/v2/Storage.js +0 -149
- package/dist/esm/v2/Storage.js.map +0 -1
- package/dist/esm/v2/Sync.d.ts +0 -42
- package/dist/esm/v2/Sync.js +0 -94
- package/dist/esm/v2/Sync.js.map +0 -1
- package/dist/esm/v2/SyncHarness.d.ts +0 -45
- package/dist/esm/v2/SyncHarness.js +0 -105
- package/dist/esm/v2/SyncHarness.js.map +0 -1
- package/dist/esm/v2/__tests__/documents.test.d.ts +0 -1
- package/dist/esm/v2/__tests__/documents.test.js +0 -208
- package/dist/esm/v2/__tests__/documents.test.js.map +0 -1
- package/dist/esm/v2/__tests__/fixtures/testStorage.d.ts +0 -223
- package/dist/esm/v2/__tests__/fixtures/testStorage.js +0 -106
- package/dist/esm/v2/__tests__/fixtures/testStorage.js.map +0 -1
- package/dist/esm/v2/__tests__/queries.test.d.ts +0 -1
- package/dist/esm/v2/__tests__/queries.test.js +0 -90
- package/dist/esm/v2/__tests__/queries.test.js.map +0 -1
- package/dist/esm/v2/__tests__/setup/indexedDB.d.ts +0 -1
- package/dist/esm/v2/__tests__/setup/indexedDB.js +0 -2
- package/dist/esm/v2/__tests__/setup/indexedDB.js.map +0 -1
- package/dist/esm/v2/constants.d.ts +0 -1
- package/dist/esm/v2/constants.js +0 -2
- package/dist/esm/v2/constants.js.map +0 -1
- package/dist/esm/v2/idb.d.ts +0 -6
- package/dist/esm/v2/idb.js +0 -65
- package/dist/esm/v2/idb.js.map +0 -1
- package/dist/esm/v2/index.d.ts +0 -6
- package/dist/esm/v2/index.js +0 -5
- package/dist/esm/v2/index.js.map +0 -1
- package/dist/esm/v2/indexes.d.ts +0 -3
- package/dist/esm/v2/indexes.js +0 -15
- package/dist/esm/v2/indexes.js.map +0 -1
- package/dist/esm/v2/openDocumentDatabase.d.ts +0 -9
- package/dist/esm/v2/openDocumentDatabase.js +0 -96
- package/dist/esm/v2/openDocumentDatabase.js.map +0 -1
- package/dist/esm/v2/types.d.ts +0 -3
- package/dist/esm/v2/types.js +0 -2
- package/dist/esm/v2/types.js.map +0 -1
- /package/dist/esm/sync/{WebsocketSync.js.map → WebSocketSync.js.map} +0 -0
|
@@ -1,339 +1,339 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Metadata = void 0;
|
|
4
|
-
const common_1 = require("@verdant-web/common");
|
|
5
|
-
const AckInfoStore_js_1 = require("./AckInfoStore.js");
|
|
6
|
-
const BaselinesStore_js_1 = require("./BaselinesStore.js");
|
|
7
|
-
const idb_js_1 = require("../idb.js");
|
|
8
|
-
const LocalReplicaStore_js_1 = require("./LocalReplicaStore.js");
|
|
9
|
-
const MessageCreator_js_1 = require("./MessageCreator.js");
|
|
10
|
-
const OperationsStore_js_1 = require("./OperationsStore.js");
|
|
11
|
-
const SchemaStore_js_1 = require("./SchemaStore.js");
|
|
12
|
-
class Metadata extends common_1.EventSubscriber {
|
|
13
|
-
constructor({ disableRebasing, context, }) {
|
|
14
|
-
super();
|
|
15
|
-
this.time = new common_1.HybridLogicalClockTimestampProvider();
|
|
16
|
-
this.disableRebasing = false;
|
|
17
|
-
this._closing = false;
|
|
18
|
-
this.setContext = (context) => {
|
|
19
|
-
this.context = context;
|
|
20
|
-
};
|
|
21
|
-
this.close = () => {
|
|
22
|
-
this._closing = true;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Methods for accessing data
|
|
26
|
-
*/
|
|
27
|
-
this.createTransaction = (stores) => {
|
|
28
|
-
return this.db.transaction(stores, 'readwrite');
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Gets the OID and every sub-object OID for a given document.
|
|
32
|
-
* Includes any sub-objects that are not referenced by the root object
|
|
33
|
-
* but still happen to be in storage.
|
|
34
|
-
*/
|
|
35
|
-
this.getAllDocumentRelatedOids = async (oid) => {
|
|
36
|
-
const oids = new Set();
|
|
37
|
-
const documentOid = (0, common_1.getOidRoot)(oid);
|
|
38
|
-
(0, common_1.assert)(documentOid === oid, 'Must be root document OID');
|
|
39
|
-
oids.add(documentOid);
|
|
40
|
-
// readwrite mode to block on other write transactions
|
|
41
|
-
const transaction = this.db.transaction(['baselines', 'operations'], 'readwrite');
|
|
42
|
-
await Promise.all([
|
|
43
|
-
this.baselines.iterateOverAllForDocument(documentOid, (baseline) => {
|
|
44
|
-
oids.add(baseline.oid);
|
|
45
|
-
}, { transaction }),
|
|
46
|
-
this.operations.iterateOverAllOperationsForDocument(documentOid, (patch) => {
|
|
47
|
-
oids.add(patch.oid);
|
|
48
|
-
}, { transaction }),
|
|
49
|
-
]);
|
|
50
|
-
return Array.from(oids);
|
|
51
|
-
};
|
|
52
|
-
this.getDocumentSnapshot = async (oid) => {
|
|
53
|
-
const documentOid = (0, common_1.getOidRoot)(oid);
|
|
54
|
-
(0, common_1.assert)(documentOid === oid, 'Must be root document OID');
|
|
55
|
-
const transaction = this.db.transaction(['baselines', 'operations'], 'readwrite');
|
|
56
|
-
const baselines = await this.baselines.getAllForDocument(documentOid, {
|
|
57
|
-
transaction,
|
|
58
|
-
});
|
|
59
|
-
const objectMap = new Map();
|
|
60
|
-
for (const baseline of baselines) {
|
|
61
|
-
if (baseline.snapshot) {
|
|
62
|
-
(0, common_1.assignOid)(baseline.snapshot, baseline.oid);
|
|
63
|
-
}
|
|
64
|
-
objectMap.set(baseline.oid, baseline.snapshot);
|
|
65
|
-
}
|
|
66
|
-
await this.operations.iterateOverAllOperationsForDocument(documentOid, (op) => {
|
|
67
|
-
const obj = objectMap.get(op.oid) || undefined;
|
|
68
|
-
const newObj = (0, common_1.applyPatch)(obj, op.data);
|
|
69
|
-
if (newObj) {
|
|
70
|
-
(0, common_1.assignOid)(newObj, op.oid);
|
|
71
|
-
}
|
|
72
|
-
objectMap.set(op.oid, newObj);
|
|
73
|
-
}, { transaction });
|
|
74
|
-
const root = objectMap.get(documentOid);
|
|
75
|
-
if (root) {
|
|
76
|
-
(0, common_1.substituteRefsWithObjects)(root, objectMap);
|
|
77
|
-
}
|
|
78
|
-
return root;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Methods for writing data
|
|
82
|
-
*/
|
|
83
|
-
/**
|
|
84
|
-
* Acks that we have seen a timestamp to the server
|
|
85
|
-
* and stores it as our local ackedLogicalTime if it's
|
|
86
|
-
* greater than our current ackedLogicalTime.
|
|
87
|
-
*/
|
|
88
|
-
this.ack = async (timestamp) => {
|
|
89
|
-
const localReplicaInfo = await this.localReplica.get();
|
|
90
|
-
this.emit('message', {
|
|
91
|
-
type: 'ack',
|
|
92
|
-
replicaId: localReplicaInfo.id,
|
|
93
|
-
timestamp,
|
|
94
|
-
});
|
|
95
|
-
if (!localReplicaInfo.ackedLogicalTime ||
|
|
96
|
-
timestamp > localReplicaInfo.ackedLogicalTime) {
|
|
97
|
-
this.localReplica.update({ ackedLogicalTime: timestamp });
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Applies a patch to the document and stores it in the database.
|
|
102
|
-
* @returns the oldest local history timestamp
|
|
103
|
-
*/
|
|
104
|
-
this.insertLocalOperation = async (operations) => {
|
|
105
|
-
if (operations.length === 0)
|
|
106
|
-
return;
|
|
107
|
-
// await this.rebaseLock;
|
|
108
|
-
this.log(`Inserting ${operations.length} local operations`);
|
|
109
|
-
// add local flag, in place.
|
|
110
|
-
for (const operation of operations) {
|
|
111
|
-
operation.isLocal = true;
|
|
112
|
-
}
|
|
113
|
-
await this.operations.addOperations(operations);
|
|
114
|
-
const message = await this.messageCreator.createOperation({ operations });
|
|
115
|
-
this.emit('message', message);
|
|
116
|
-
// we can now enqueue and check for rebase opportunities
|
|
117
|
-
this.tryAutonomousRebase();
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Inserts remote operations. This does not affect local history.
|
|
121
|
-
* @returns a list of affected document OIDs
|
|
122
|
-
*/
|
|
123
|
-
this.insertRemoteOperations = async (operations) => {
|
|
124
|
-
if (operations.length === 0)
|
|
125
|
-
return [];
|
|
126
|
-
// await this.rebaseLock;
|
|
127
|
-
this.log(`Inserting ${operations.length} remote operations`);
|
|
128
|
-
const affectedDocumentOids = await this.operations.addOperations(operations.map((patch) => (Object.assign(Object.assign({}, patch), { isLocal: false }))));
|
|
129
|
-
this.ack(operations[operations.length - 1].timestamp);
|
|
130
|
-
return affectedDocumentOids;
|
|
131
|
-
};
|
|
132
|
-
this.insertRemoteBaselines = async (baselines) => {
|
|
133
|
-
if (baselines.length === 0)
|
|
134
|
-
return [];
|
|
135
|
-
this.log(`Inserting ${baselines.length} remote baselines`);
|
|
136
|
-
await this.baselines.setAll(baselines);
|
|
137
|
-
// this.ack(baselines[baselines.length - 1].timestamp);
|
|
138
|
-
const affectedOidSet = new Set();
|
|
139
|
-
baselines.forEach((baseline) => {
|
|
140
|
-
affectedOidSet.add((0, common_1.getOidRoot)(baseline.oid));
|
|
141
|
-
});
|
|
142
|
-
return Array.from(affectedOidSet);
|
|
143
|
-
};
|
|
144
|
-
this.updateLastSynced = async (timestamp) => {
|
|
145
|
-
return this.localReplica.update({
|
|
146
|
-
lastSyncedLogicalTime: timestamp,
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
this.lastSyncedTimestamp = async () => {
|
|
150
|
-
const localReplicaInfo = await this.localReplica.get();
|
|
151
|
-
return localReplicaInfo.lastSyncedLogicalTime;
|
|
152
|
-
};
|
|
153
|
-
this.tryAutonomousRebase = async () => {
|
|
154
|
-
if (this.disableRebasing)
|
|
155
|
-
return;
|
|
156
|
-
const localReplicaInfo = await this.localReplica.get();
|
|
157
|
-
if (localReplicaInfo.lastSyncedLogicalTime)
|
|
158
|
-
return; // cannot autonomously rebase if we've synced
|
|
159
|
-
// but if we have never synced... we can rebase everything!
|
|
160
|
-
await this.runRebase(this.now);
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Attempt to autonomously rebase local documents without server intervention.
|
|
164
|
-
* This can currently only happen for a client who has never synced before.
|
|
165
|
-
* The goal is to allow local-only clients to compress their history to exactly
|
|
166
|
-
* their undo stack.
|
|
167
|
-
*/
|
|
168
|
-
this.runRebase = async (globalAckTimestamp) => {
|
|
169
|
-
if (this._closing)
|
|
170
|
-
return;
|
|
171
|
-
// find all operations before the global ack
|
|
172
|
-
let lastTimestamp;
|
|
173
|
-
const toRebase = new Set();
|
|
174
|
-
const transaction = this.db.transaction(['baselines', 'operations'], 'readwrite');
|
|
175
|
-
let operationCount = 0;
|
|
176
|
-
await this.operations.iterateOverAllOperations((patch) => {
|
|
177
|
-
toRebase.add(patch.oid);
|
|
178
|
-
lastTimestamp = patch.timestamp;
|
|
179
|
-
operationCount++;
|
|
180
|
-
}, {
|
|
181
|
-
before: globalAckTimestamp,
|
|
182
|
-
transaction,
|
|
183
|
-
});
|
|
184
|
-
if (!toRebase.size) {
|
|
185
|
-
this.log('Cannot rebase, no operations prior to', globalAckTimestamp);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (this._closing) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
// rebase each affected document
|
|
192
|
-
let newBaselines = [];
|
|
193
|
-
for (const oid of toRebase) {
|
|
194
|
-
newBaselines.push(await this.rebase(oid, lastTimestamp || globalAckTimestamp, transaction));
|
|
195
|
-
}
|
|
196
|
-
this.emit('rebase', newBaselines);
|
|
197
|
-
};
|
|
198
|
-
this.rebase = async (oid, upTo, providedTx) => {
|
|
199
|
-
// including replica Id for testing I guess
|
|
200
|
-
const replicaId = (await this.localReplica.get()).id;
|
|
201
|
-
this.log('[', replicaId, ']', 'Rebasing', oid, 'up to', upTo);
|
|
202
|
-
const transaction = providedTx ||
|
|
203
|
-
this.db.transaction(['operations', 'baselines'], 'readwrite');
|
|
204
|
-
const baseline = await this.baselines.get(oid, { transaction });
|
|
205
|
-
let current = (baseline === null || baseline === void 0 ? void 0 : baseline.snapshot) || undefined;
|
|
206
|
-
let operationsApplied = 0;
|
|
207
|
-
const deletedRefs = [];
|
|
208
|
-
await this.operations.iterateOverAllOperationsForEntity(oid, (patch, store) => {
|
|
209
|
-
// FIXME: this seems like the wrong place to do this
|
|
210
|
-
// but it's here as a safety measure...
|
|
211
|
-
if (!baseline || patch.timestamp > baseline.timestamp) {
|
|
212
|
-
current = (0, common_1.applyPatch)(current, patch.data, deletedRefs);
|
|
213
|
-
}
|
|
214
|
-
// delete all prior operations to the baseline
|
|
215
|
-
operationsApplied++;
|
|
216
|
-
store.delete(patch.oid_timestamp);
|
|
217
|
-
}, {
|
|
218
|
-
to: upTo,
|
|
219
|
-
transaction,
|
|
220
|
-
});
|
|
221
|
-
if (current) {
|
|
222
|
-
(0, common_1.assignOid)(current, oid);
|
|
223
|
-
}
|
|
224
|
-
const newBaseline = {
|
|
225
|
-
oid,
|
|
226
|
-
snapshot: current,
|
|
227
|
-
timestamp: upTo,
|
|
228
|
-
};
|
|
229
|
-
if (newBaseline.snapshot) {
|
|
230
|
-
await this.baselines.set(newBaseline, { transaction });
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
await this.baselines.delete(oid, { transaction });
|
|
234
|
-
}
|
|
235
|
-
this.log('successfully rebased', oid, 'up to', upTo, ':', current, 'and deleted', operationsApplied, 'operations');
|
|
236
|
-
// cleanup deleted refs
|
|
237
|
-
if (deletedRefs.length) {
|
|
238
|
-
const fileRefs = deletedRefs.filter(common_1.isFileRef);
|
|
239
|
-
if (fileRefs.length) {
|
|
240
|
-
this.emit('filesDeleted', fileRefs);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return newBaseline;
|
|
244
|
-
};
|
|
245
|
-
this.reset = async () => {
|
|
246
|
-
await this.operations.reset();
|
|
247
|
-
await this.baselines.reset();
|
|
248
|
-
await this.localReplica.reset();
|
|
249
|
-
};
|
|
250
|
-
this.updateSchema = async (schema, overrideConflict) => {
|
|
251
|
-
const storedSchema = await this.schema.get();
|
|
252
|
-
if (storedSchema) {
|
|
253
|
-
// version changes will be handled by migration routines in
|
|
254
|
-
// the actual idb database loading code (see: initializeDatabases)
|
|
255
|
-
// but this check determines if the schema has been changed without
|
|
256
|
-
// a version change. if so, it will error.
|
|
257
|
-
if (overrideConflict === storedSchema.version &&
|
|
258
|
-
storedSchema.version === schema.version &&
|
|
259
|
-
JSON.stringify(storedSchema) !== JSON.stringify(schema)) {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Metadata = void 0;
|
|
4
|
+
const common_1 = require("@verdant-web/common");
|
|
5
|
+
const AckInfoStore_js_1 = require("./AckInfoStore.js");
|
|
6
|
+
const BaselinesStore_js_1 = require("./BaselinesStore.js");
|
|
7
|
+
const idb_js_1 = require("../idb.js");
|
|
8
|
+
const LocalReplicaStore_js_1 = require("./LocalReplicaStore.js");
|
|
9
|
+
const MessageCreator_js_1 = require("./MessageCreator.js");
|
|
10
|
+
const OperationsStore_js_1 = require("./OperationsStore.js");
|
|
11
|
+
const SchemaStore_js_1 = require("./SchemaStore.js");
|
|
12
|
+
class Metadata extends common_1.EventSubscriber {
|
|
13
|
+
constructor({ disableRebasing, context, }) {
|
|
14
|
+
super();
|
|
15
|
+
this.time = new common_1.HybridLogicalClockTimestampProvider();
|
|
16
|
+
this.disableRebasing = false;
|
|
17
|
+
this._closing = false;
|
|
18
|
+
this.setContext = (context) => {
|
|
19
|
+
this.context = context;
|
|
20
|
+
};
|
|
21
|
+
this.close = () => {
|
|
22
|
+
this._closing = true;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Methods for accessing data
|
|
26
|
+
*/
|
|
27
|
+
this.createTransaction = (stores) => {
|
|
28
|
+
return this.db.transaction(stores, 'readwrite');
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Gets the OID and every sub-object OID for a given document.
|
|
32
|
+
* Includes any sub-objects that are not referenced by the root object
|
|
33
|
+
* but still happen to be in storage.
|
|
34
|
+
*/
|
|
35
|
+
this.getAllDocumentRelatedOids = async (oid) => {
|
|
36
|
+
const oids = new Set();
|
|
37
|
+
const documentOid = (0, common_1.getOidRoot)(oid);
|
|
38
|
+
(0, common_1.assert)(documentOid === oid, 'Must be root document OID');
|
|
39
|
+
oids.add(documentOid);
|
|
40
|
+
// readwrite mode to block on other write transactions
|
|
41
|
+
const transaction = this.db.transaction(['baselines', 'operations'], 'readwrite');
|
|
42
|
+
await Promise.all([
|
|
43
|
+
this.baselines.iterateOverAllForDocument(documentOid, (baseline) => {
|
|
44
|
+
oids.add(baseline.oid);
|
|
45
|
+
}, { transaction }),
|
|
46
|
+
this.operations.iterateOverAllOperationsForDocument(documentOid, (patch) => {
|
|
47
|
+
oids.add(patch.oid);
|
|
48
|
+
}, { transaction }),
|
|
49
|
+
]);
|
|
50
|
+
return Array.from(oids);
|
|
51
|
+
};
|
|
52
|
+
this.getDocumentSnapshot = async (oid) => {
|
|
53
|
+
const documentOid = (0, common_1.getOidRoot)(oid);
|
|
54
|
+
(0, common_1.assert)(documentOid === oid, 'Must be root document OID');
|
|
55
|
+
const transaction = this.db.transaction(['baselines', 'operations'], 'readwrite');
|
|
56
|
+
const baselines = await this.baselines.getAllForDocument(documentOid, {
|
|
57
|
+
transaction,
|
|
58
|
+
});
|
|
59
|
+
const objectMap = new Map();
|
|
60
|
+
for (const baseline of baselines) {
|
|
61
|
+
if (baseline.snapshot) {
|
|
62
|
+
(0, common_1.assignOid)(baseline.snapshot, baseline.oid);
|
|
63
|
+
}
|
|
64
|
+
objectMap.set(baseline.oid, baseline.snapshot);
|
|
65
|
+
}
|
|
66
|
+
await this.operations.iterateOverAllOperationsForDocument(documentOid, (op) => {
|
|
67
|
+
const obj = objectMap.get(op.oid) || undefined;
|
|
68
|
+
const newObj = (0, common_1.applyPatch)(obj, op.data);
|
|
69
|
+
if (newObj) {
|
|
70
|
+
(0, common_1.assignOid)(newObj, op.oid);
|
|
71
|
+
}
|
|
72
|
+
objectMap.set(op.oid, newObj);
|
|
73
|
+
}, { transaction });
|
|
74
|
+
const root = objectMap.get(documentOid);
|
|
75
|
+
if (root) {
|
|
76
|
+
(0, common_1.substituteRefsWithObjects)(root, objectMap);
|
|
77
|
+
}
|
|
78
|
+
return root;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Methods for writing data
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* Acks that we have seen a timestamp to the server
|
|
85
|
+
* and stores it as our local ackedLogicalTime if it's
|
|
86
|
+
* greater than our current ackedLogicalTime.
|
|
87
|
+
*/
|
|
88
|
+
this.ack = async (timestamp) => {
|
|
89
|
+
const localReplicaInfo = await this.localReplica.get();
|
|
90
|
+
this.emit('message', {
|
|
91
|
+
type: 'ack',
|
|
92
|
+
replicaId: localReplicaInfo.id,
|
|
93
|
+
timestamp,
|
|
94
|
+
});
|
|
95
|
+
if (!localReplicaInfo.ackedLogicalTime ||
|
|
96
|
+
timestamp > localReplicaInfo.ackedLogicalTime) {
|
|
97
|
+
this.localReplica.update({ ackedLogicalTime: timestamp });
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Applies a patch to the document and stores it in the database.
|
|
102
|
+
* @returns the oldest local history timestamp
|
|
103
|
+
*/
|
|
104
|
+
this.insertLocalOperation = async (operations) => {
|
|
105
|
+
if (operations.length === 0)
|
|
106
|
+
return;
|
|
107
|
+
// await this.rebaseLock;
|
|
108
|
+
this.log(`Inserting ${operations.length} local operations`);
|
|
109
|
+
// add local flag, in place.
|
|
110
|
+
for (const operation of operations) {
|
|
111
|
+
operation.isLocal = true;
|
|
112
|
+
}
|
|
113
|
+
await this.operations.addOperations(operations);
|
|
114
|
+
const message = await this.messageCreator.createOperation({ operations });
|
|
115
|
+
this.emit('message', message);
|
|
116
|
+
// we can now enqueue and check for rebase opportunities
|
|
117
|
+
this.tryAutonomousRebase();
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Inserts remote operations. This does not affect local history.
|
|
121
|
+
* @returns a list of affected document OIDs
|
|
122
|
+
*/
|
|
123
|
+
this.insertRemoteOperations = async (operations) => {
|
|
124
|
+
if (operations.length === 0)
|
|
125
|
+
return [];
|
|
126
|
+
// await this.rebaseLock;
|
|
127
|
+
this.log(`Inserting ${operations.length} remote operations`);
|
|
128
|
+
const affectedDocumentOids = await this.operations.addOperations(operations.map((patch) => (Object.assign(Object.assign({}, patch), { isLocal: false }))));
|
|
129
|
+
this.ack(operations[operations.length - 1].timestamp);
|
|
130
|
+
return affectedDocumentOids;
|
|
131
|
+
};
|
|
132
|
+
this.insertRemoteBaselines = async (baselines) => {
|
|
133
|
+
if (baselines.length === 0)
|
|
134
|
+
return [];
|
|
135
|
+
this.log(`Inserting ${baselines.length} remote baselines`);
|
|
136
|
+
await this.baselines.setAll(baselines);
|
|
137
|
+
// this.ack(baselines[baselines.length - 1].timestamp);
|
|
138
|
+
const affectedOidSet = new Set();
|
|
139
|
+
baselines.forEach((baseline) => {
|
|
140
|
+
affectedOidSet.add((0, common_1.getOidRoot)(baseline.oid));
|
|
141
|
+
});
|
|
142
|
+
return Array.from(affectedOidSet);
|
|
143
|
+
};
|
|
144
|
+
this.updateLastSynced = async (timestamp) => {
|
|
145
|
+
return this.localReplica.update({
|
|
146
|
+
lastSyncedLogicalTime: timestamp,
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
this.lastSyncedTimestamp = async () => {
|
|
150
|
+
const localReplicaInfo = await this.localReplica.get();
|
|
151
|
+
return localReplicaInfo.lastSyncedLogicalTime;
|
|
152
|
+
};
|
|
153
|
+
this.tryAutonomousRebase = async () => {
|
|
154
|
+
if (this.disableRebasing)
|
|
155
|
+
return;
|
|
156
|
+
const localReplicaInfo = await this.localReplica.get();
|
|
157
|
+
if (localReplicaInfo.lastSyncedLogicalTime)
|
|
158
|
+
return; // cannot autonomously rebase if we've synced
|
|
159
|
+
// but if we have never synced... we can rebase everything!
|
|
160
|
+
await this.runRebase(this.now);
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Attempt to autonomously rebase local documents without server intervention.
|
|
164
|
+
* This can currently only happen for a client who has never synced before.
|
|
165
|
+
* The goal is to allow local-only clients to compress their history to exactly
|
|
166
|
+
* their undo stack.
|
|
167
|
+
*/
|
|
168
|
+
this.runRebase = async (globalAckTimestamp) => {
|
|
169
|
+
if (this._closing)
|
|
170
|
+
return;
|
|
171
|
+
// find all operations before the global ack
|
|
172
|
+
let lastTimestamp;
|
|
173
|
+
const toRebase = new Set();
|
|
174
|
+
const transaction = this.db.transaction(['baselines', 'operations'], 'readwrite');
|
|
175
|
+
let operationCount = 0;
|
|
176
|
+
await this.operations.iterateOverAllOperations((patch) => {
|
|
177
|
+
toRebase.add(patch.oid);
|
|
178
|
+
lastTimestamp = patch.timestamp;
|
|
179
|
+
operationCount++;
|
|
180
|
+
}, {
|
|
181
|
+
before: globalAckTimestamp,
|
|
182
|
+
transaction,
|
|
183
|
+
});
|
|
184
|
+
if (!toRebase.size) {
|
|
185
|
+
this.log('Cannot rebase, no operations prior to', globalAckTimestamp);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (this._closing) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
// rebase each affected document
|
|
192
|
+
let newBaselines = [];
|
|
193
|
+
for (const oid of toRebase) {
|
|
194
|
+
newBaselines.push(await this.rebase(oid, lastTimestamp || globalAckTimestamp, transaction));
|
|
195
|
+
}
|
|
196
|
+
this.emit('rebase', newBaselines);
|
|
197
|
+
};
|
|
198
|
+
this.rebase = async (oid, upTo, providedTx) => {
|
|
199
|
+
// including replica Id for testing I guess
|
|
200
|
+
const replicaId = (await this.localReplica.get()).id;
|
|
201
|
+
this.log('[', replicaId, ']', 'Rebasing', oid, 'up to', upTo);
|
|
202
|
+
const transaction = providedTx ||
|
|
203
|
+
this.db.transaction(['operations', 'baselines'], 'readwrite');
|
|
204
|
+
const baseline = await this.baselines.get(oid, { transaction });
|
|
205
|
+
let current = (baseline === null || baseline === void 0 ? void 0 : baseline.snapshot) || undefined;
|
|
206
|
+
let operationsApplied = 0;
|
|
207
|
+
const deletedRefs = [];
|
|
208
|
+
await this.operations.iterateOverAllOperationsForEntity(oid, (patch, store) => {
|
|
209
|
+
// FIXME: this seems like the wrong place to do this
|
|
210
|
+
// but it's here as a safety measure...
|
|
211
|
+
if (!baseline || patch.timestamp > baseline.timestamp) {
|
|
212
|
+
current = (0, common_1.applyPatch)(current, patch.data, deletedRefs);
|
|
213
|
+
}
|
|
214
|
+
// delete all prior operations to the baseline
|
|
215
|
+
operationsApplied++;
|
|
216
|
+
store.delete(patch.oid_timestamp);
|
|
217
|
+
}, {
|
|
218
|
+
to: upTo,
|
|
219
|
+
transaction,
|
|
220
|
+
});
|
|
221
|
+
if (current) {
|
|
222
|
+
(0, common_1.assignOid)(current, oid);
|
|
223
|
+
}
|
|
224
|
+
const newBaseline = {
|
|
225
|
+
oid,
|
|
226
|
+
snapshot: current,
|
|
227
|
+
timestamp: upTo,
|
|
228
|
+
};
|
|
229
|
+
if (newBaseline.snapshot) {
|
|
230
|
+
await this.baselines.set(newBaseline, { transaction });
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
await this.baselines.delete(oid, { transaction });
|
|
234
|
+
}
|
|
235
|
+
this.log('successfully rebased', oid, 'up to', upTo, ':', current, 'and deleted', operationsApplied, 'operations');
|
|
236
|
+
// cleanup deleted refs
|
|
237
|
+
if (deletedRefs.length) {
|
|
238
|
+
const fileRefs = deletedRefs.filter(common_1.isFileRef);
|
|
239
|
+
if (fileRefs.length) {
|
|
240
|
+
this.emit('filesDeleted', fileRefs);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return newBaseline;
|
|
244
|
+
};
|
|
245
|
+
this.reset = async () => {
|
|
246
|
+
await this.operations.reset();
|
|
247
|
+
await this.baselines.reset();
|
|
248
|
+
await this.localReplica.reset();
|
|
249
|
+
};
|
|
250
|
+
this.updateSchema = async (schema, overrideConflict) => {
|
|
251
|
+
const storedSchema = await this.schema.get();
|
|
252
|
+
if (storedSchema) {
|
|
253
|
+
// version changes will be handled by migration routines in
|
|
254
|
+
// the actual idb database loading code (see: initializeDatabases)
|
|
255
|
+
// but this check determines if the schema has been changed without
|
|
256
|
+
// a version change. if so, it will error.
|
|
257
|
+
if (overrideConflict === storedSchema.version &&
|
|
258
|
+
storedSchema.version === schema.version &&
|
|
259
|
+
JSON.stringify(storedSchema) !== JSON.stringify(schema)) {
|
|
260
260
|
console.error(`Schema mismatch for version ${schema.version}
|
|
261
261
|
${JSON.stringify(storedSchema)}
|
|
262
|
-
${JSON.stringify(schema)}`);
|
|
263
|
-
throw new Error('Schema has changed without a version change! Any changes to your schema must be accompanied by a change in schema version and a migration routine.');
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
await this.schema.set(schema);
|
|
267
|
-
};
|
|
268
|
-
this.setGlobalAck = async (timestamp) => {
|
|
269
|
-
await this.ackInfo.setGlobalAck(timestamp);
|
|
270
|
-
if (!this.disableRebasing) {
|
|
271
|
-
await this.runRebase(timestamp);
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
this.export = async () => {
|
|
275
|
-
const db = this.db;
|
|
276
|
-
const [baselines, operations] = await (0, idb_js_1.getAllFromObjectStores)(db, [
|
|
277
|
-
'baselines',
|
|
278
|
-
'operations',
|
|
279
|
-
]);
|
|
280
|
-
const localReplica = await this.localReplica.get();
|
|
281
|
-
const schema = await this.schema.get();
|
|
282
|
-
if (!schema) {
|
|
283
|
-
throw new Error('Cannot export Client data before initializing');
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
286
|
-
operations,
|
|
287
|
-
baselines,
|
|
288
|
-
localReplica,
|
|
289
|
-
schema,
|
|
290
|
-
};
|
|
291
|
-
};
|
|
292
|
-
/**
|
|
293
|
-
* Resets local metadata and clears operation/baseline stores.
|
|
294
|
-
* DOES NOT add operations/baselines - this should be done
|
|
295
|
-
* through the normal higher level systems.
|
|
296
|
-
*/
|
|
297
|
-
this.resetFrom = async (data) => {
|
|
298
|
-
const db = this.db;
|
|
299
|
-
const transaction = db.transaction(['baselines', 'operations', 'info'], 'readwrite');
|
|
300
|
-
await (0, idb_js_1.storeRequestPromise)(transaction.objectStore('baselines').clear());
|
|
301
|
-
await (0, idb_js_1.storeRequestPromise)(transaction.objectStore('operations').clear());
|
|
302
|
-
await (0, idb_js_1.storeRequestPromise)(transaction.objectStore('info').clear());
|
|
303
|
-
await this.localReplica.update({
|
|
304
|
-
ackedLogicalTime: data.localReplica.ackedLogicalTime,
|
|
305
|
-
lastSyncedLogicalTime: data.localReplica.lastSyncedLogicalTime,
|
|
306
|
-
}, { transaction });
|
|
307
|
-
};
|
|
308
|
-
this.stats = async () => {
|
|
309
|
-
const db = this.db;
|
|
310
|
-
const operationsSize = await (0, idb_js_1.getSizeOfObjectStore)(db, 'operations');
|
|
311
|
-
const baselinesSize = await (0, idb_js_1.getSizeOfObjectStore)(db, 'baselines');
|
|
312
|
-
return {
|
|
313
|
-
operationsSize,
|
|
314
|
-
baselinesSize,
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
|
-
this.context = context;
|
|
318
|
-
this.schema = new SchemaStore_js_1.SchemaStore(context.metaDb, context.schema.version);
|
|
319
|
-
this.operations = new OperationsStore_js_1.OperationsStore(this.db);
|
|
320
|
-
this.baselines = new BaselinesStore_js_1.BaselinesStore(this.db);
|
|
321
|
-
this.localReplica = new LocalReplicaStore_js_1.LocalReplicaStore(this.db);
|
|
322
|
-
this.ackInfo = new AckInfoStore_js_1.AckInfoStore(this.db);
|
|
323
|
-
this.messageCreator = new MessageCreator_js_1.MessageCreator(this);
|
|
324
|
-
this.patchCreator = new common_1.PatchCreator(() => this.now);
|
|
325
|
-
if (disableRebasing)
|
|
326
|
-
this.disableRebasing = disableRebasing;
|
|
327
|
-
}
|
|
328
|
-
get db() {
|
|
329
|
-
return this.context.metaDb;
|
|
330
|
-
}
|
|
331
|
-
get log() {
|
|
332
|
-
return this.context.log;
|
|
333
|
-
}
|
|
334
|
-
get now() {
|
|
335
|
-
return this.time.now(this.schema.currentVersion);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
exports.Metadata = Metadata;
|
|
262
|
+
${JSON.stringify(schema)}`);
|
|
263
|
+
throw new Error('Schema has changed without a version change! Any changes to your schema must be accompanied by a change in schema version and a migration routine.');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
await this.schema.set(schema);
|
|
267
|
+
};
|
|
268
|
+
this.setGlobalAck = async (timestamp) => {
|
|
269
|
+
await this.ackInfo.setGlobalAck(timestamp);
|
|
270
|
+
if (!this.disableRebasing) {
|
|
271
|
+
await this.runRebase(timestamp);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
this.export = async () => {
|
|
275
|
+
const db = this.db;
|
|
276
|
+
const [baselines, operations] = await (0, idb_js_1.getAllFromObjectStores)(db, [
|
|
277
|
+
'baselines',
|
|
278
|
+
'operations',
|
|
279
|
+
]);
|
|
280
|
+
const localReplica = await this.localReplica.get();
|
|
281
|
+
const schema = await this.schema.get();
|
|
282
|
+
if (!schema) {
|
|
283
|
+
throw new Error('Cannot export Client data before initializing');
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
operations,
|
|
287
|
+
baselines,
|
|
288
|
+
localReplica,
|
|
289
|
+
schema,
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Resets local metadata and clears operation/baseline stores.
|
|
294
|
+
* DOES NOT add operations/baselines - this should be done
|
|
295
|
+
* through the normal higher level systems.
|
|
296
|
+
*/
|
|
297
|
+
this.resetFrom = async (data) => {
|
|
298
|
+
const db = this.db;
|
|
299
|
+
const transaction = db.transaction(['baselines', 'operations', 'info'], 'readwrite');
|
|
300
|
+
await (0, idb_js_1.storeRequestPromise)(transaction.objectStore('baselines').clear());
|
|
301
|
+
await (0, idb_js_1.storeRequestPromise)(transaction.objectStore('operations').clear());
|
|
302
|
+
await (0, idb_js_1.storeRequestPromise)(transaction.objectStore('info').clear());
|
|
303
|
+
await this.localReplica.update({
|
|
304
|
+
ackedLogicalTime: data.localReplica.ackedLogicalTime,
|
|
305
|
+
lastSyncedLogicalTime: data.localReplica.lastSyncedLogicalTime,
|
|
306
|
+
}, { transaction });
|
|
307
|
+
};
|
|
308
|
+
this.stats = async () => {
|
|
309
|
+
const db = this.db;
|
|
310
|
+
const operationsSize = await (0, idb_js_1.getSizeOfObjectStore)(db, 'operations');
|
|
311
|
+
const baselinesSize = await (0, idb_js_1.getSizeOfObjectStore)(db, 'baselines');
|
|
312
|
+
return {
|
|
313
|
+
operationsSize,
|
|
314
|
+
baselinesSize,
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
this.context = context;
|
|
318
|
+
this.schema = new SchemaStore_js_1.SchemaStore(context.metaDb, context.schema.version);
|
|
319
|
+
this.operations = new OperationsStore_js_1.OperationsStore(this.db);
|
|
320
|
+
this.baselines = new BaselinesStore_js_1.BaselinesStore(this.db);
|
|
321
|
+
this.localReplica = new LocalReplicaStore_js_1.LocalReplicaStore(this.db);
|
|
322
|
+
this.ackInfo = new AckInfoStore_js_1.AckInfoStore(this.db);
|
|
323
|
+
this.messageCreator = new MessageCreator_js_1.MessageCreator(this);
|
|
324
|
+
this.patchCreator = new common_1.PatchCreator(() => this.now);
|
|
325
|
+
if (disableRebasing)
|
|
326
|
+
this.disableRebasing = disableRebasing;
|
|
327
|
+
}
|
|
328
|
+
get db() {
|
|
329
|
+
return this.context.metaDb;
|
|
330
|
+
}
|
|
331
|
+
get log() {
|
|
332
|
+
return this.context.log;
|
|
333
|
+
}
|
|
334
|
+
get now() {
|
|
335
|
+
return this.time.now(this.schema.currentVersion);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
exports.Metadata = Metadata;
|
|
339
339
|
//# sourceMappingURL=Metadata.js.map
|