@verdant-web/store 2.7.7-next.0 → 2.7.8

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.
Files changed (698) hide show
  1. package/dist/bundle/index.js +1 -1
  2. package/dist/bundle/index.js.map +3 -3
  3. package/dist/cjs/BackoffScheduler.d.ts +19 -19
  4. package/dist/cjs/BackoffScheduler.js +44 -44
  5. package/dist/cjs/DocumentManager.d.ts +28 -31
  6. package/dist/cjs/DocumentManager.js +44 -44
  7. package/dist/cjs/FakeWeakRef.d.ts +11 -11
  8. package/dist/cjs/FakeWeakRef.js +18 -18
  9. package/dist/cjs/IDBService.d.ts +9 -9
  10. package/dist/cjs/IDBService.js +63 -63
  11. package/dist/cjs/UndoHistory.d.ts +16 -16
  12. package/dist/cjs/UndoHistory.js +50 -50
  13. package/dist/cjs/__tests__/batching.test.d.ts +1 -1
  14. package/dist/cjs/__tests__/batching.test.js +44 -44
  15. package/dist/cjs/__tests__/documents.test.d.ts +1 -1
  16. package/dist/cjs/__tests__/documents.test.js +415 -415
  17. package/dist/cjs/__tests__/fixtures/testStorage.d.ts +123 -123
  18. package/dist/cjs/__tests__/fixtures/testStorage.js +117 -117
  19. package/dist/cjs/__tests__/legacyOids.test.d.ts +1 -1
  20. package/dist/cjs/__tests__/legacyOids.test.js +290 -290
  21. package/dist/cjs/__tests__/mutations.test.d.ts +1 -1
  22. package/dist/cjs/__tests__/mutations.test.js +41 -41
  23. package/dist/cjs/__tests__/queries.test.d.ts +1 -1
  24. package/dist/cjs/__tests__/queries.test.js +318 -318
  25. package/dist/cjs/__tests__/setup/indexedDB.d.ts +1 -1
  26. package/dist/cjs/__tests__/setup/indexedDB.js +3 -3
  27. package/dist/cjs/__tests__/undo.test.d.ts +1 -1
  28. package/dist/cjs/__tests__/undo.test.js +86 -86
  29. package/dist/cjs/client/Client.d.ts +99 -98
  30. package/dist/cjs/client/Client.js +227 -227
  31. package/dist/cjs/client/ClientDescriptor.d.ts +76 -76
  32. package/dist/cjs/client/ClientDescriptor.js +197 -197
  33. package/dist/cjs/client/constants.d.ts +1 -1
  34. package/dist/cjs/client/constants.js +4 -4
  35. package/dist/cjs/constants.d.ts +1 -1
  36. package/dist/cjs/constants.js +4 -4
  37. package/dist/cjs/context.d.ts +29 -29
  38. package/dist/cjs/context.js +2 -2
  39. package/dist/cjs/entities/DocumentFamiliyCache.d.ts +90 -90
  40. package/dist/cjs/entities/DocumentFamiliyCache.js +282 -282
  41. package/dist/cjs/entities/Entity.d.ts +206 -206
  42. package/dist/cjs/entities/Entity.js +520 -520
  43. package/dist/cjs/entities/EntityStore.d.ts +85 -85
  44. package/dist/cjs/entities/EntityStore.js +479 -479
  45. package/dist/cjs/files/EntityFile.d.ts +31 -31
  46. package/dist/cjs/files/EntityFile.js +76 -76
  47. package/dist/cjs/files/FileManager.d.ts +42 -42
  48. package/dist/cjs/files/FileManager.js +152 -152
  49. package/dist/cjs/files/FileStorage.d.ts +28 -28
  50. package/dist/cjs/files/FileStorage.js +104 -104
  51. package/dist/cjs/files/utils.d.ts +8 -8
  52. package/dist/cjs/files/utils.js +55 -55
  53. package/dist/cjs/files/utils.test.d.ts +1 -1
  54. package/dist/cjs/files/utils.test.js +80 -80
  55. package/dist/cjs/idb.d.ts +11 -11
  56. package/dist/cjs/idb.js +111 -111
  57. package/dist/cjs/index.d.ts +21 -21
  58. package/dist/cjs/index.js +23 -23
  59. package/dist/cjs/metadata/AckInfoStore.d.ts +10 -10
  60. package/dist/cjs/metadata/AckInfoStore.js +25 -25
  61. package/dist/cjs/metadata/BaselinesStore.d.ts +33 -33
  62. package/dist/cjs/metadata/BaselinesStore.js +89 -89
  63. package/dist/cjs/metadata/LocalReplicaStore.d.ts +17 -17
  64. package/dist/cjs/metadata/LocalReplicaStore.js +47 -47
  65. package/dist/cjs/metadata/MessageCreator.d.ts +19 -19
  66. package/dist/cjs/metadata/MessageCreator.js +127 -127
  67. package/dist/cjs/metadata/Metadata.d.ts +112 -112
  68. package/dist/cjs/metadata/Metadata.js +352 -352
  69. package/dist/cjs/metadata/OperationsStore.d.ts +53 -53
  70. package/dist/cjs/metadata/OperationsStore.js +152 -152
  71. package/dist/cjs/metadata/SchemaStore.d.ts +9 -9
  72. package/dist/cjs/metadata/SchemaStore.js +38 -38
  73. package/dist/cjs/metadata/openMetadataDatabase.d.ts +19 -19
  74. package/dist/cjs/metadata/openMetadataDatabase.js +219 -219
  75. package/dist/cjs/migration/db.d.ts +8 -8
  76. package/dist/cjs/migration/db.js +111 -111
  77. package/dist/cjs/migration/errors.d.ts +5 -5
  78. package/dist/cjs/migration/errors.js +11 -11
  79. package/dist/cjs/migration/openDatabase.d.ts +20 -20
  80. package/dist/cjs/migration/openDatabase.js +428 -428
  81. package/dist/cjs/migration/paths.d.ts +6 -6
  82. package/dist/cjs/migration/paths.js +52 -52
  83. package/dist/cjs/migration/paths.test.d.ts +1 -1
  84. package/dist/cjs/migration/paths.test.js +90 -90
  85. package/dist/cjs/queries/BaseQuery.d.ts +53 -53
  86. package/dist/cjs/queries/BaseQuery.js +135 -135
  87. package/dist/cjs/queries/CollectionQueries.d.ts +55 -55
  88. package/dist/cjs/queries/CollectionQueries.js +91 -91
  89. package/dist/cjs/queries/FindAllQuery.d.ts +12 -12
  90. package/dist/cjs/queries/FindAllQuery.js +42 -42
  91. package/dist/cjs/queries/FindInfiniteQuery.d.ts +19 -19
  92. package/dist/cjs/queries/FindInfiniteQuery.js +69 -69
  93. package/dist/cjs/queries/FindOneQuery.d.ts +12 -12
  94. package/dist/cjs/queries/FindOneQuery.js +42 -42
  95. package/dist/cjs/queries/FindPageQuery.d.ts +24 -24
  96. package/dist/cjs/queries/FindPageQuery.js +76 -76
  97. package/dist/cjs/queries/GetQuery.d.ts +10 -10
  98. package/dist/cjs/queries/GetQuery.js +29 -29
  99. package/dist/cjs/queries/QueryCache.d.ts +16 -16
  100. package/dist/cjs/queries/QueryCache.js +41 -41
  101. package/dist/cjs/queries/dbQueries.d.ts +22 -22
  102. package/dist/cjs/queries/dbQueries.js +125 -125
  103. package/dist/cjs/queries/keys.d.ts +10 -10
  104. package/dist/cjs/queries/keys.js +33 -33
  105. package/dist/cjs/queries/ranges.d.ts +2 -2
  106. package/dist/cjs/queries/ranges.js +69 -69
  107. package/dist/cjs/queries/types.d.ts +6 -6
  108. package/dist/cjs/queries/types.js +2 -2
  109. package/dist/cjs/queries/utils.d.ts +3 -3
  110. package/dist/cjs/queries/utils.js +24 -24
  111. package/dist/cjs/sync/FileSync.d.ts +23 -23
  112. package/dist/cjs/sync/FileSync.js +84 -84
  113. package/dist/cjs/sync/Heartbeat.d.ts +25 -25
  114. package/dist/cjs/sync/Heartbeat.js +63 -63
  115. package/dist/cjs/sync/PresenceManager.d.ts +43 -43
  116. package/dist/cjs/sync/PresenceManager.js +119 -119
  117. package/dist/cjs/sync/PushPullSync.d.ts +36 -36
  118. package/dist/cjs/sync/PushPullSync.js +143 -143
  119. package/dist/cjs/sync/ServerSyncEndpointProvider.d.ts +27 -27
  120. package/dist/cjs/sync/ServerSyncEndpointProvider.js +64 -64
  121. package/dist/cjs/sync/Sync.d.ts +146 -146
  122. package/dist/cjs/sync/Sync.js +270 -270
  123. package/dist/cjs/sync/WebSocketSync.d.ts +41 -41
  124. package/dist/cjs/sync/WebSocketSync.js +190 -190
  125. package/dist/cjs/types.d.ts +12 -12
  126. package/dist/cjs/types.js +2 -2
  127. package/dist/cjs/utils/Disposable.d.ts +6 -6
  128. package/dist/cjs/utils/Disposable.js +18 -18
  129. package/dist/cjs/utils/Resolvable.d.ts +8 -8
  130. package/dist/cjs/utils/Resolvable.js +22 -22
  131. package/dist/cjs/vanilla.d.ts +1 -1
  132. package/dist/cjs/vanilla.js +27 -27
  133. package/dist/esm/BackoffScheduler.d.ts +19 -19
  134. package/dist/esm/BackoffScheduler.js +39 -39
  135. package/dist/esm/DocumentManager.d.ts +28 -28
  136. package/dist/esm/DocumentManager.js +40 -40
  137. package/dist/esm/FakeWeakRef.d.ts +11 -11
  138. package/dist/esm/FakeWeakRef.js +14 -14
  139. package/dist/esm/IDBService.d.ts +9 -9
  140. package/dist/esm/IDBService.js +59 -59
  141. package/dist/esm/UndoHistory.d.ts +16 -16
  142. package/dist/esm/UndoHistory.js +46 -46
  143. package/dist/esm/__tests__/batching.test.d.ts +1 -1
  144. package/dist/esm/__tests__/batching.test.js +42 -42
  145. package/dist/esm/__tests__/documents.test.d.ts +1 -1
  146. package/dist/esm/__tests__/documents.test.js +413 -413
  147. package/dist/esm/__tests__/fixtures/testStorage.d.ts +123 -123
  148. package/dist/esm/__tests__/fixtures/testStorage.js +113 -113
  149. package/dist/esm/__tests__/legacyOids.test.d.ts +1 -1
  150. package/dist/esm/__tests__/legacyOids.test.js +288 -288
  151. package/dist/esm/__tests__/mutations.test.d.ts +1 -1
  152. package/dist/esm/__tests__/mutations.test.js +39 -39
  153. package/dist/esm/__tests__/queries.test.d.ts +1 -1
  154. package/dist/esm/__tests__/queries.test.js +316 -316
  155. package/dist/esm/__tests__/setup/indexedDB.d.ts +1 -1
  156. package/dist/esm/__tests__/setup/indexedDB.js +1 -1
  157. package/dist/esm/__tests__/undo.test.d.ts +1 -1
  158. package/dist/esm/__tests__/undo.test.js +84 -84
  159. package/dist/esm/client/Client.d.ts +99 -99
  160. package/dist/esm/client/Client.js +223 -223
  161. package/dist/esm/client/ClientDescriptor.d.ts +76 -76
  162. package/dist/esm/client/ClientDescriptor.js +193 -193
  163. package/dist/esm/client/constants.d.ts +1 -1
  164. package/dist/esm/client/constants.js +1 -1
  165. package/dist/esm/constants.d.ts +1 -1
  166. package/dist/esm/constants.js +1 -1
  167. package/dist/esm/context.d.ts +29 -29
  168. package/dist/esm/context.js +1 -1
  169. package/dist/esm/entities/DocumentFamiliyCache.d.ts +90 -90
  170. package/dist/esm/entities/DocumentFamiliyCache.js +278 -278
  171. package/dist/esm/entities/Entity.d.ts +206 -206
  172. package/dist/esm/entities/Entity.js +515 -515
  173. package/dist/esm/entities/EntityStore.d.ts +85 -85
  174. package/dist/esm/entities/EntityStore.js +475 -475
  175. package/dist/esm/files/EntityFile.d.ts +31 -31
  176. package/dist/esm/files/EntityFile.js +72 -72
  177. package/dist/esm/files/FileManager.d.ts +42 -42
  178. package/dist/esm/files/FileManager.js +148 -148
  179. package/dist/esm/files/FileStorage.d.ts +28 -28
  180. package/dist/esm/files/FileStorage.js +99 -99
  181. package/dist/esm/files/utils.d.ts +8 -8
  182. package/dist/esm/files/utils.js +46 -46
  183. package/dist/esm/files/utils.test.d.ts +1 -1
  184. package/dist/esm/files/utils.test.js +78 -78
  185. package/dist/esm/idb.d.ts +11 -11
  186. package/dist/esm/idb.js +100 -100
  187. package/dist/esm/index.d.ts +21 -21
  188. package/dist/esm/index.js +12 -12
  189. package/dist/esm/metadata/AckInfoStore.d.ts +10 -10
  190. package/dist/esm/metadata/AckInfoStore.js +21 -21
  191. package/dist/esm/metadata/BaselinesStore.d.ts +33 -33
  192. package/dist/esm/metadata/BaselinesStore.js +85 -85
  193. package/dist/esm/metadata/LocalReplicaStore.d.ts +17 -17
  194. package/dist/esm/metadata/LocalReplicaStore.js +40 -40
  195. package/dist/esm/metadata/MessageCreator.d.ts +19 -19
  196. package/dist/esm/metadata/MessageCreator.js +123 -123
  197. package/dist/esm/metadata/Metadata.d.ts +112 -112
  198. package/dist/esm/metadata/Metadata.js +348 -348
  199. package/dist/esm/metadata/OperationsStore.d.ts +53 -53
  200. package/dist/esm/metadata/OperationsStore.js +148 -148
  201. package/dist/esm/metadata/SchemaStore.d.ts +9 -9
  202. package/dist/esm/metadata/SchemaStore.js +34 -34
  203. package/dist/esm/metadata/openMetadataDatabase.d.ts +19 -19
  204. package/dist/esm/metadata/openMetadataDatabase.js +214 -214
  205. package/dist/esm/migration/db.d.ts +8 -8
  206. package/dist/esm/migration/db.js +103 -103
  207. package/dist/esm/migration/errors.d.ts +5 -5
  208. package/dist/esm/migration/errors.js +7 -7
  209. package/dist/esm/migration/openDatabase.d.ts +20 -20
  210. package/dist/esm/migration/openDatabase.js +423 -423
  211. package/dist/esm/migration/paths.d.ts +6 -6
  212. package/dist/esm/migration/paths.js +48 -48
  213. package/dist/esm/migration/paths.test.d.ts +1 -1
  214. package/dist/esm/migration/paths.test.js +88 -88
  215. package/dist/esm/queries/BaseQuery.d.ts +53 -53
  216. package/dist/esm/queries/BaseQuery.js +131 -131
  217. package/dist/esm/queries/CollectionQueries.d.ts +55 -55
  218. package/dist/esm/queries/CollectionQueries.js +87 -87
  219. package/dist/esm/queries/FindAllQuery.d.ts +12 -12
  220. package/dist/esm/queries/FindAllQuery.js +38 -38
  221. package/dist/esm/queries/FindInfiniteQuery.d.ts +19 -19
  222. package/dist/esm/queries/FindInfiniteQuery.js +65 -65
  223. package/dist/esm/queries/FindOneQuery.d.ts +12 -12
  224. package/dist/esm/queries/FindOneQuery.js +38 -38
  225. package/dist/esm/queries/FindPageQuery.d.ts +24 -24
  226. package/dist/esm/queries/FindPageQuery.js +72 -72
  227. package/dist/esm/queries/GetQuery.d.ts +10 -10
  228. package/dist/esm/queries/GetQuery.js +25 -25
  229. package/dist/esm/queries/QueryCache.d.ts +16 -16
  230. package/dist/esm/queries/QueryCache.js +37 -37
  231. package/dist/esm/queries/dbQueries.d.ts +22 -22
  232. package/dist/esm/queries/dbQueries.js +119 -119
  233. package/dist/esm/queries/keys.d.ts +10 -10
  234. package/dist/esm/queries/keys.js +29 -29
  235. package/dist/esm/queries/ranges.d.ts +2 -2
  236. package/dist/esm/queries/ranges.js +65 -65
  237. package/dist/esm/queries/types.d.ts +6 -6
  238. package/dist/esm/queries/types.js +1 -1
  239. package/dist/esm/queries/utils.d.ts +3 -3
  240. package/dist/esm/queries/utils.js +19 -19
  241. package/dist/esm/sync/FileSync.d.ts +23 -23
  242. package/dist/esm/sync/FileSync.js +80 -80
  243. package/dist/esm/sync/Heartbeat.d.ts +25 -25
  244. package/dist/esm/sync/Heartbeat.js +59 -59
  245. package/dist/esm/sync/PresenceManager.d.ts +43 -43
  246. package/dist/esm/sync/PresenceManager.js +115 -115
  247. package/dist/esm/sync/PushPullSync.d.ts +36 -36
  248. package/dist/esm/sync/PushPullSync.js +139 -139
  249. package/dist/esm/sync/ServerSyncEndpointProvider.d.ts +27 -27
  250. package/dist/esm/sync/ServerSyncEndpointProvider.js +57 -57
  251. package/dist/esm/sync/Sync.d.ts +146 -146
  252. package/dist/esm/sync/Sync.js +265 -265
  253. package/dist/esm/sync/{WebsocketSync.d.ts → WebSocketSync.d.ts} +41 -41
  254. package/dist/esm/sync/{WebsocketSync.js → WebSocketSync.js} +186 -186
  255. package/dist/esm/types.d.ts +12 -12
  256. package/dist/esm/types.js +1 -1
  257. package/dist/esm/utils/Disposable.d.ts +6 -6
  258. package/dist/esm/utils/Disposable.js +14 -14
  259. package/dist/esm/utils/Resolvable.d.ts +8 -8
  260. package/dist/esm/utils/Resolvable.js +18 -18
  261. package/dist/esm/vanilla.d.ts +1 -1
  262. package/dist/esm/vanilla.js +2 -2
  263. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  264. package/dist/tsconfig.tsbuildinfo +1 -1
  265. package/package.json +2 -2
  266. package/dist/cjs/AckInfoStore.d.ts +0 -10
  267. package/dist/cjs/AckInfoStore.js +0 -26
  268. package/dist/cjs/AckInfoStore.js.map +0 -1
  269. package/dist/cjs/BaselinesStore.d.ts +0 -10
  270. package/dist/cjs/BaselinesStore.js +0 -36
  271. package/dist/cjs/BaselinesStore.js.map +0 -1
  272. package/dist/cjs/Entity.d.ts +0 -96
  273. package/dist/cjs/Entity.js +0 -345
  274. package/dist/cjs/Entity.js.map +0 -1
  275. package/dist/cjs/EntityStore.d.ts +0 -36
  276. package/dist/cjs/EntityStore.js +0 -172
  277. package/dist/cjs/EntityStore.js.map +0 -1
  278. package/dist/cjs/LocalHistoryStore.d.ts +0 -15
  279. package/dist/cjs/LocalHistoryStore.js +0 -53
  280. package/dist/cjs/LocalHistoryStore.js.map +0 -1
  281. package/dist/cjs/LocalReplicaStore.d.ts +0 -13
  282. package/dist/cjs/LocalReplicaStore.js +0 -49
  283. package/dist/cjs/LocalReplicaStore.js.map +0 -1
  284. package/dist/cjs/MessageCreator.d.ts +0 -19
  285. package/dist/cjs/MessageCreator.js +0 -104
  286. package/dist/cjs/MessageCreator.js.map +0 -1
  287. package/dist/cjs/Metadata.d.ts +0 -91
  288. package/dist/cjs/Metadata.js +0 -250
  289. package/dist/cjs/Metadata.js.map +0 -1
  290. package/dist/cjs/OperationsStore.d.ts +0 -38
  291. package/dist/cjs/OperationsStore.js +0 -146
  292. package/dist/cjs/OperationsStore.js.map +0 -1
  293. package/dist/cjs/PresenceManager.d.ts +0 -30
  294. package/dist/cjs/PresenceManager.js +0 -89
  295. package/dist/cjs/PresenceManager.js.map +0 -1
  296. package/dist/cjs/Query.d.ts +0 -26
  297. package/dist/cjs/Query.js +0 -86
  298. package/dist/cjs/Query.js.map +0 -1
  299. package/dist/cjs/QueryMaker.d.ts +0 -18
  300. package/dist/cjs/QueryMaker.js +0 -98
  301. package/dist/cjs/QueryMaker.js.map +0 -1
  302. package/dist/cjs/QueryStore.d.ts +0 -38
  303. package/dist/cjs/QueryStore.js +0 -146
  304. package/dist/cjs/QueryStore.js.map +0 -1
  305. package/dist/cjs/SchemaStore.d.ts +0 -9
  306. package/dist/cjs/SchemaStore.js +0 -35
  307. package/dist/cjs/SchemaStore.js.map +0 -1
  308. package/dist/cjs/Storage.d.ts +0 -147
  309. package/dist/cjs/Storage.js +0 -346
  310. package/dist/cjs/Storage.js.map +0 -1
  311. package/dist/cjs/Sync.d.ts +0 -117
  312. package/dist/cjs/Sync.js +0 -561
  313. package/dist/cjs/Sync.js.map +0 -1
  314. package/dist/cjs/SyncHarness.d.ts +0 -45
  315. package/dist/cjs/SyncHarness.js +0 -110
  316. package/dist/cjs/SyncHarness.js.map +0 -1
  317. package/dist/cjs/indexes.d.ts +0 -3
  318. package/dist/cjs/indexes.js +0 -20
  319. package/dist/cjs/indexes.js.map +0 -1
  320. package/dist/cjs/metadata/LocalHistoryStore.d.ts +0 -15
  321. package/dist/cjs/metadata/LocalHistoryStore.js +0 -53
  322. package/dist/cjs/metadata/LocalHistoryStore.js.map +0 -1
  323. package/dist/cjs/openDocumentDatabase.d.ts +0 -12
  324. package/dist/cjs/openDocumentDatabase.js +0 -432
  325. package/dist/cjs/openDocumentDatabase.js.map +0 -1
  326. package/dist/cjs/queries/LiveQuery.d.ts +0 -28
  327. package/dist/cjs/queries/LiveQuery.js +0 -96
  328. package/dist/cjs/queries/LiveQuery.js.map +0 -1
  329. package/dist/cjs/queries/LiveQueryMaker.d.ts +0 -15
  330. package/dist/cjs/queries/LiveQueryMaker.js +0 -42
  331. package/dist/cjs/queries/LiveQueryMaker.js.map +0 -1
  332. package/dist/cjs/queries/LiveQueryStore.d.ts +0 -33
  333. package/dist/cjs/queries/LiveQueryStore.js +0 -85
  334. package/dist/cjs/queries/LiveQueryStore.js.map +0 -1
  335. package/dist/cjs/queries/Query.d.ts +0 -18
  336. package/dist/cjs/queries/Query.js +0 -36
  337. package/dist/cjs/queries/Query.js.map +0 -1
  338. package/dist/cjs/queries/QueryMaker.d.ts +0 -14
  339. package/dist/cjs/queries/QueryMaker.js +0 -42
  340. package/dist/cjs/queries/QueryMaker.js.map +0 -1
  341. package/dist/cjs/queries/QueryStore.d.ts +0 -35
  342. package/dist/cjs/queries/QueryStore.js +0 -130
  343. package/dist/cjs/queries/QueryStore.js.map +0 -1
  344. package/dist/cjs/queries2/BaseQuery.d.ts +0 -39
  345. package/dist/cjs/queries2/BaseQuery.js +0 -99
  346. package/dist/cjs/queries2/BaseQuery.js.map +0 -1
  347. package/dist/cjs/queries2/CollectionQueries.d.ts +0 -55
  348. package/dist/cjs/queries2/CollectionQueries.js +0 -83
  349. package/dist/cjs/queries2/CollectionQueries.js.map +0 -1
  350. package/dist/cjs/queries2/FindAllQuery.d.ts +0 -11
  351. package/dist/cjs/queries2/FindAllQuery.js +0 -34
  352. package/dist/cjs/queries2/FindAllQuery.js.map +0 -1
  353. package/dist/cjs/queries2/FindInfiniteQuery.d.ts +0 -18
  354. package/dist/cjs/queries2/FindInfiniteQuery.js +0 -61
  355. package/dist/cjs/queries2/FindInfiniteQuery.js.map +0 -1
  356. package/dist/cjs/queries2/FindOneQuery.d.ts +0 -11
  357. package/dist/cjs/queries2/FindOneQuery.js +0 -34
  358. package/dist/cjs/queries2/FindOneQuery.js.map +0 -1
  359. package/dist/cjs/queries2/FindPageQuery.d.ts +0 -23
  360. package/dist/cjs/queries2/FindPageQuery.js +0 -68
  361. package/dist/cjs/queries2/FindPageQuery.js.map +0 -1
  362. package/dist/cjs/queries2/GetQuery.d.ts +0 -10
  363. package/dist/cjs/queries2/GetQuery.js +0 -30
  364. package/dist/cjs/queries2/GetQuery.js.map +0 -1
  365. package/dist/cjs/queries2/QueryCache.d.ts +0 -16
  366. package/dist/cjs/queries2/QueryCache.js +0 -40
  367. package/dist/cjs/queries2/QueryCache.js.map +0 -1
  368. package/dist/cjs/queries2/dbQueries.d.ts +0 -22
  369. package/dist/cjs/queries2/dbQueries.js +0 -126
  370. package/dist/cjs/queries2/dbQueries.js.map +0 -1
  371. package/dist/cjs/queries2/keys.d.ts +0 -10
  372. package/dist/cjs/queries2/keys.js +0 -34
  373. package/dist/cjs/queries2/keys.js.map +0 -1
  374. package/dist/cjs/queries2/ranges.d.ts +0 -2
  375. package/dist/cjs/queries2/ranges.js +0 -70
  376. package/dist/cjs/queries2/ranges.js.map +0 -1
  377. package/dist/cjs/queries2/types.d.ts +0 -6
  378. package/dist/cjs/queries2/types.js +0 -3
  379. package/dist/cjs/queries2/types.js.map +0 -1
  380. package/dist/cjs/queries2/utils.d.ts +0 -1
  381. package/dist/cjs/queries2/utils.js +0 -20
  382. package/dist/cjs/queries2/utils.js.map +0 -1
  383. package/dist/cjs/reactives/DocumentFamiliyCache.d.ts +0 -47
  384. package/dist/cjs/reactives/DocumentFamiliyCache.js +0 -211
  385. package/dist/cjs/reactives/DocumentFamiliyCache.js.map +0 -1
  386. package/dist/cjs/reactives/Entity.d.ts +0 -191
  387. package/dist/cjs/reactives/Entity.js +0 -463
  388. package/dist/cjs/reactives/Entity.js.map +0 -1
  389. package/dist/cjs/reactives/EntityStore.d.ts +0 -84
  390. package/dist/cjs/reactives/EntityStore.js +0 -422
  391. package/dist/cjs/reactives/EntityStore.js.map +0 -1
  392. package/dist/cjs/reactives/FakeWeakRef.d.ts +0 -11
  393. package/dist/cjs/reactives/FakeWeakRef.js +0 -19
  394. package/dist/cjs/reactives/FakeWeakRef.js.map +0 -1
  395. package/dist/cjs/v2/AckInfoStore.d.ts +0 -10
  396. package/dist/cjs/v2/AckInfoStore.js +0 -26
  397. package/dist/cjs/v2/AckInfoStore.js.map +0 -1
  398. package/dist/cjs/v2/BaselinesStore.d.ts +0 -10
  399. package/dist/cjs/v2/BaselinesStore.js +0 -36
  400. package/dist/cjs/v2/BaselinesStore.js.map +0 -1
  401. package/dist/cjs/v2/DocumentManager.d.ts +0 -19
  402. package/dist/cjs/v2/DocumentManager.js +0 -47
  403. package/dist/cjs/v2/DocumentManager.js.map +0 -1
  404. package/dist/cjs/v2/Entity.d.ts +0 -87
  405. package/dist/cjs/v2/Entity.js +0 -305
  406. package/dist/cjs/v2/Entity.js.map +0 -1
  407. package/dist/cjs/v2/EntityStore.d.ts +0 -37
  408. package/dist/cjs/v2/EntityStore.js +0 -165
  409. package/dist/cjs/v2/EntityStore.js.map +0 -1
  410. package/dist/cjs/v2/IDBService.d.ts +0 -7
  411. package/dist/cjs/v2/IDBService.js +0 -26
  412. package/dist/cjs/v2/IDBService.js.map +0 -1
  413. package/dist/cjs/v2/LocalHistoryStore.d.ts +0 -15
  414. package/dist/cjs/v2/LocalHistoryStore.js +0 -53
  415. package/dist/cjs/v2/LocalHistoryStore.js.map +0 -1
  416. package/dist/cjs/v2/LocalReplicaStore.d.ts +0 -14
  417. package/dist/cjs/v2/LocalReplicaStore.js +0 -49
  418. package/dist/cjs/v2/LocalReplicaStore.js.map +0 -1
  419. package/dist/cjs/v2/MessageCreator.d.ts +0 -19
  420. package/dist/cjs/v2/MessageCreator.js +0 -99
  421. package/dist/cjs/v2/MessageCreator.js.map +0 -1
  422. package/dist/cjs/v2/Metadata.d.ts +0 -90
  423. package/dist/cjs/v2/Metadata.js +0 -251
  424. package/dist/cjs/v2/Metadata.js.map +0 -1
  425. package/dist/cjs/v2/OperationsStore.d.ts +0 -38
  426. package/dist/cjs/v2/OperationsStore.js +0 -146
  427. package/dist/cjs/v2/OperationsStore.js.map +0 -1
  428. package/dist/cjs/v2/PresenceManager.d.ts +0 -24
  429. package/dist/cjs/v2/PresenceManager.js +0 -73
  430. package/dist/cjs/v2/PresenceManager.js.map +0 -1
  431. package/dist/cjs/v2/Query.d.ts +0 -24
  432. package/dist/cjs/v2/Query.js +0 -79
  433. package/dist/cjs/v2/Query.js.map +0 -1
  434. package/dist/cjs/v2/QueryMaker.d.ts +0 -16
  435. package/dist/cjs/v2/QueryMaker.js +0 -84
  436. package/dist/cjs/v2/QueryMaker.js.map +0 -1
  437. package/dist/cjs/v2/QueryStore.d.ts +0 -26
  438. package/dist/cjs/v2/QueryStore.js +0 -136
  439. package/dist/cjs/v2/QueryStore.js.map +0 -1
  440. package/dist/cjs/v2/SchemaStore.d.ts +0 -9
  441. package/dist/cjs/v2/SchemaStore.js +0 -35
  442. package/dist/cjs/v2/SchemaStore.js.map +0 -1
  443. package/dist/cjs/v2/Storage.d.ts +0 -80
  444. package/dist/cjs/v2/Storage.js +0 -154
  445. package/dist/cjs/v2/Storage.js.map +0 -1
  446. package/dist/cjs/v2/Sync.d.ts +0 -42
  447. package/dist/cjs/v2/Sync.js +0 -98
  448. package/dist/cjs/v2/Sync.js.map +0 -1
  449. package/dist/cjs/v2/SyncHarness.d.ts +0 -45
  450. package/dist/cjs/v2/SyncHarness.js +0 -110
  451. package/dist/cjs/v2/SyncHarness.js.map +0 -1
  452. package/dist/cjs/v2/__tests__/documents.test.d.ts +0 -1
  453. package/dist/cjs/v2/__tests__/documents.test.js +0 -185
  454. package/dist/cjs/v2/__tests__/documents.test.js.map +0 -1
  455. package/dist/cjs/v2/__tests__/fixtures/testStorage.d.ts +0 -189
  456. package/dist/cjs/v2/__tests__/fixtures/testStorage.js +0 -93
  457. package/dist/cjs/v2/__tests__/fixtures/testStorage.js.map +0 -1
  458. package/dist/cjs/v2/__tests__/queries.test.d.ts +0 -1
  459. package/dist/cjs/v2/__tests__/queries.test.js +0 -92
  460. package/dist/cjs/v2/__tests__/queries.test.js.map +0 -1
  461. package/dist/cjs/v2/__tests__/setup/indexedDB.d.ts +0 -1
  462. package/dist/cjs/v2/__tests__/setup/indexedDB.js +0 -4
  463. package/dist/cjs/v2/__tests__/setup/indexedDB.js.map +0 -1
  464. package/dist/cjs/v2/constants.d.ts +0 -1
  465. package/dist/cjs/v2/constants.js +0 -5
  466. package/dist/cjs/v2/constants.js.map +0 -1
  467. package/dist/cjs/v2/idb.d.ts +0 -6
  468. package/dist/cjs/v2/idb.js +0 -71
  469. package/dist/cjs/v2/idb.js.map +0 -1
  470. package/dist/cjs/v2/index.d.ts +0 -6
  471. package/dist/cjs/v2/index.js +0 -14
  472. package/dist/cjs/v2/index.js.map +0 -1
  473. package/dist/cjs/v2/indexes.d.ts +0 -3
  474. package/dist/cjs/v2/indexes.js +0 -20
  475. package/dist/cjs/v2/indexes.js.map +0 -1
  476. package/dist/cjs/v2/openDocumentDatabase.d.ts +0 -9
  477. package/dist/cjs/v2/openDocumentDatabase.js +0 -100
  478. package/dist/cjs/v2/openDocumentDatabase.js.map +0 -1
  479. package/dist/cjs/v2/types.d.ts +0 -3
  480. package/dist/cjs/v2/types.js +0 -3
  481. package/dist/cjs/v2/types.js.map +0 -1
  482. package/dist/esm/AckInfoStore.d.ts +0 -10
  483. package/dist/esm/AckInfoStore.js +0 -22
  484. package/dist/esm/AckInfoStore.js.map +0 -1
  485. package/dist/esm/BaselinesStore.d.ts +0 -10
  486. package/dist/esm/BaselinesStore.js +0 -32
  487. package/dist/esm/BaselinesStore.js.map +0 -1
  488. package/dist/esm/Entity.d.ts +0 -96
  489. package/dist/esm/Entity.js +0 -337
  490. package/dist/esm/Entity.js.map +0 -1
  491. package/dist/esm/EntityStore.d.ts +0 -36
  492. package/dist/esm/EntityStore.js +0 -168
  493. package/dist/esm/EntityStore.js.map +0 -1
  494. package/dist/esm/LocalHistoryStore.d.ts +0 -15
  495. package/dist/esm/LocalHistoryStore.js +0 -49
  496. package/dist/esm/LocalHistoryStore.js.map +0 -1
  497. package/dist/esm/LocalReplicaStore.d.ts +0 -13
  498. package/dist/esm/LocalReplicaStore.js +0 -42
  499. package/dist/esm/LocalReplicaStore.js.map +0 -1
  500. package/dist/esm/MessageCreator.d.ts +0 -19
  501. package/dist/esm/MessageCreator.js +0 -97
  502. package/dist/esm/MessageCreator.js.map +0 -1
  503. package/dist/esm/Metadata.d.ts +0 -91
  504. package/dist/esm/Metadata.js +0 -245
  505. package/dist/esm/Metadata.js.map +0 -1
  506. package/dist/esm/OperationsStore.d.ts +0 -38
  507. package/dist/esm/OperationsStore.js +0 -142
  508. package/dist/esm/OperationsStore.js.map +0 -1
  509. package/dist/esm/PresenceManager.d.ts +0 -30
  510. package/dist/esm/PresenceManager.js +0 -85
  511. package/dist/esm/PresenceManager.js.map +0 -1
  512. package/dist/esm/Query.d.ts +0 -26
  513. package/dist/esm/Query.js +0 -82
  514. package/dist/esm/Query.js.map +0 -1
  515. package/dist/esm/QueryMaker.d.ts +0 -18
  516. package/dist/esm/QueryMaker.js +0 -94
  517. package/dist/esm/QueryMaker.js.map +0 -1
  518. package/dist/esm/QueryStore.d.ts +0 -38
  519. package/dist/esm/QueryStore.js +0 -142
  520. package/dist/esm/QueryStore.js.map +0 -1
  521. package/dist/esm/SchemaStore.d.ts +0 -9
  522. package/dist/esm/SchemaStore.js +0 -31
  523. package/dist/esm/SchemaStore.js.map +0 -1
  524. package/dist/esm/Storage.d.ts +0 -147
  525. package/dist/esm/Storage.js +0 -341
  526. package/dist/esm/Storage.js.map +0 -1
  527. package/dist/esm/Sync.d.ts +0 -117
  528. package/dist/esm/Sync.js +0 -553
  529. package/dist/esm/Sync.js.map +0 -1
  530. package/dist/esm/SyncHarness.d.ts +0 -45
  531. package/dist/esm/SyncHarness.js +0 -105
  532. package/dist/esm/SyncHarness.js.map +0 -1
  533. package/dist/esm/indexes.d.ts +0 -3
  534. package/dist/esm/indexes.js +0 -15
  535. package/dist/esm/indexes.js.map +0 -1
  536. package/dist/esm/metadata/LocalHistoryStore.d.ts +0 -15
  537. package/dist/esm/metadata/LocalHistoryStore.js +0 -49
  538. package/dist/esm/metadata/LocalHistoryStore.js.map +0 -1
  539. package/dist/esm/openDocumentDatabase.d.ts +0 -12
  540. package/dist/esm/openDocumentDatabase.js +0 -428
  541. package/dist/esm/openDocumentDatabase.js.map +0 -1
  542. package/dist/esm/queries/LiveQuery.d.ts +0 -28
  543. package/dist/esm/queries/LiveQuery.js +0 -92
  544. package/dist/esm/queries/LiveQuery.js.map +0 -1
  545. package/dist/esm/queries/LiveQueryMaker.d.ts +0 -15
  546. package/dist/esm/queries/LiveQueryMaker.js +0 -38
  547. package/dist/esm/queries/LiveQueryMaker.js.map +0 -1
  548. package/dist/esm/queries/LiveQueryStore.d.ts +0 -33
  549. package/dist/esm/queries/LiveQueryStore.js +0 -81
  550. package/dist/esm/queries/LiveQueryStore.js.map +0 -1
  551. package/dist/esm/queries/Query.d.ts +0 -18
  552. package/dist/esm/queries/Query.js +0 -32
  553. package/dist/esm/queries/Query.js.map +0 -1
  554. package/dist/esm/queries/QueryMaker.d.ts +0 -14
  555. package/dist/esm/queries/QueryMaker.js +0 -38
  556. package/dist/esm/queries/QueryMaker.js.map +0 -1
  557. package/dist/esm/queries/QueryStore.d.ts +0 -35
  558. package/dist/esm/queries/QueryStore.js +0 -126
  559. package/dist/esm/queries/QueryStore.js.map +0 -1
  560. package/dist/esm/queries2/BaseQuery.d.ts +0 -39
  561. package/dist/esm/queries2/BaseQuery.js +0 -95
  562. package/dist/esm/queries2/BaseQuery.js.map +0 -1
  563. package/dist/esm/queries2/CollectionQueries.d.ts +0 -55
  564. package/dist/esm/queries2/CollectionQueries.js +0 -79
  565. package/dist/esm/queries2/CollectionQueries.js.map +0 -1
  566. package/dist/esm/queries2/FindAllQuery.d.ts +0 -11
  567. package/dist/esm/queries2/FindAllQuery.js +0 -30
  568. package/dist/esm/queries2/FindAllQuery.js.map +0 -1
  569. package/dist/esm/queries2/FindInfiniteQuery.d.ts +0 -18
  570. package/dist/esm/queries2/FindInfiniteQuery.js +0 -57
  571. package/dist/esm/queries2/FindInfiniteQuery.js.map +0 -1
  572. package/dist/esm/queries2/FindOneQuery.d.ts +0 -11
  573. package/dist/esm/queries2/FindOneQuery.js +0 -30
  574. package/dist/esm/queries2/FindOneQuery.js.map +0 -1
  575. package/dist/esm/queries2/FindPageQuery.d.ts +0 -23
  576. package/dist/esm/queries2/FindPageQuery.js +0 -64
  577. package/dist/esm/queries2/FindPageQuery.js.map +0 -1
  578. package/dist/esm/queries2/GetQuery.d.ts +0 -10
  579. package/dist/esm/queries2/GetQuery.js +0 -26
  580. package/dist/esm/queries2/GetQuery.js.map +0 -1
  581. package/dist/esm/queries2/QueryCache.d.ts +0 -16
  582. package/dist/esm/queries2/QueryCache.js +0 -36
  583. package/dist/esm/queries2/QueryCache.js.map +0 -1
  584. package/dist/esm/queries2/dbQueries.d.ts +0 -22
  585. package/dist/esm/queries2/dbQueries.js +0 -120
  586. package/dist/esm/queries2/dbQueries.js.map +0 -1
  587. package/dist/esm/queries2/keys.d.ts +0 -10
  588. package/dist/esm/queries2/keys.js +0 -30
  589. package/dist/esm/queries2/keys.js.map +0 -1
  590. package/dist/esm/queries2/ranges.d.ts +0 -2
  591. package/dist/esm/queries2/ranges.js +0 -66
  592. package/dist/esm/queries2/ranges.js.map +0 -1
  593. package/dist/esm/queries2/types.d.ts +0 -6
  594. package/dist/esm/queries2/types.js +0 -2
  595. package/dist/esm/queries2/types.js.map +0 -1
  596. package/dist/esm/queries2/utils.d.ts +0 -1
  597. package/dist/esm/queries2/utils.js +0 -16
  598. package/dist/esm/queries2/utils.js.map +0 -1
  599. package/dist/esm/reactives/DocumentFamiliyCache.d.ts +0 -47
  600. package/dist/esm/reactives/DocumentFamiliyCache.js +0 -207
  601. package/dist/esm/reactives/DocumentFamiliyCache.js.map +0 -1
  602. package/dist/esm/reactives/Entity.d.ts +0 -191
  603. package/dist/esm/reactives/Entity.js +0 -458
  604. package/dist/esm/reactives/Entity.js.map +0 -1
  605. package/dist/esm/reactives/EntityStore.d.ts +0 -84
  606. package/dist/esm/reactives/EntityStore.js +0 -418
  607. package/dist/esm/reactives/EntityStore.js.map +0 -1
  608. package/dist/esm/reactives/FakeWeakRef.d.ts +0 -11
  609. package/dist/esm/reactives/FakeWeakRef.js +0 -15
  610. package/dist/esm/reactives/FakeWeakRef.js.map +0 -1
  611. package/dist/esm/v2/AckInfoStore.d.ts +0 -10
  612. package/dist/esm/v2/AckInfoStore.js +0 -22
  613. package/dist/esm/v2/AckInfoStore.js.map +0 -1
  614. package/dist/esm/v2/BaselinesStore.d.ts +0 -10
  615. package/dist/esm/v2/BaselinesStore.js +0 -32
  616. package/dist/esm/v2/BaselinesStore.js.map +0 -1
  617. package/dist/esm/v2/DocumentManager.d.ts +0 -19
  618. package/dist/esm/v2/DocumentManager.js +0 -43
  619. package/dist/esm/v2/DocumentManager.js.map +0 -1
  620. package/dist/esm/v2/Entity.d.ts +0 -91
  621. package/dist/esm/v2/Entity.js +0 -305
  622. package/dist/esm/v2/Entity.js.map +0 -1
  623. package/dist/esm/v2/EntityStore.d.ts +0 -37
  624. package/dist/esm/v2/EntityStore.js +0 -166
  625. package/dist/esm/v2/EntityStore.js.map +0 -1
  626. package/dist/esm/v2/IDBService.d.ts +0 -7
  627. package/dist/esm/v2/IDBService.js +0 -22
  628. package/dist/esm/v2/IDBService.js.map +0 -1
  629. package/dist/esm/v2/LocalHistoryStore.d.ts +0 -15
  630. package/dist/esm/v2/LocalHistoryStore.js +0 -49
  631. package/dist/esm/v2/LocalHistoryStore.js.map +0 -1
  632. package/dist/esm/v2/LocalReplicaStore.d.ts +0 -14
  633. package/dist/esm/v2/LocalReplicaStore.js +0 -42
  634. package/dist/esm/v2/LocalReplicaStore.js.map +0 -1
  635. package/dist/esm/v2/MessageCreator.d.ts +0 -19
  636. package/dist/esm/v2/MessageCreator.js +0 -92
  637. package/dist/esm/v2/MessageCreator.js.map +0 -1
  638. package/dist/esm/v2/Metadata.d.ts +0 -90
  639. package/dist/esm/v2/Metadata.js +0 -246
  640. package/dist/esm/v2/Metadata.js.map +0 -1
  641. package/dist/esm/v2/OperationsStore.d.ts +0 -38
  642. package/dist/esm/v2/OperationsStore.js +0 -142
  643. package/dist/esm/v2/OperationsStore.js.map +0 -1
  644. package/dist/esm/v2/PresenceManager.d.ts +0 -24
  645. package/dist/esm/v2/PresenceManager.js +0 -69
  646. package/dist/esm/v2/PresenceManager.js.map +0 -1
  647. package/dist/esm/v2/Query.d.ts +0 -24
  648. package/dist/esm/v2/Query.js +0 -75
  649. package/dist/esm/v2/Query.js.map +0 -1
  650. package/dist/esm/v2/QueryMaker.d.ts +0 -16
  651. package/dist/esm/v2/QueryMaker.js +0 -80
  652. package/dist/esm/v2/QueryMaker.js.map +0 -1
  653. package/dist/esm/v2/QueryStore.d.ts +0 -26
  654. package/dist/esm/v2/QueryStore.js +0 -132
  655. package/dist/esm/v2/QueryStore.js.map +0 -1
  656. package/dist/esm/v2/SchemaStore.d.ts +0 -9
  657. package/dist/esm/v2/SchemaStore.js +0 -31
  658. package/dist/esm/v2/SchemaStore.js.map +0 -1
  659. package/dist/esm/v2/Storage.d.ts +0 -80
  660. package/dist/esm/v2/Storage.js +0 -149
  661. package/dist/esm/v2/Storage.js.map +0 -1
  662. package/dist/esm/v2/Sync.d.ts +0 -42
  663. package/dist/esm/v2/Sync.js +0 -94
  664. package/dist/esm/v2/Sync.js.map +0 -1
  665. package/dist/esm/v2/SyncHarness.d.ts +0 -45
  666. package/dist/esm/v2/SyncHarness.js +0 -105
  667. package/dist/esm/v2/SyncHarness.js.map +0 -1
  668. package/dist/esm/v2/__tests__/documents.test.d.ts +0 -1
  669. package/dist/esm/v2/__tests__/documents.test.js +0 -208
  670. package/dist/esm/v2/__tests__/documents.test.js.map +0 -1
  671. package/dist/esm/v2/__tests__/fixtures/testStorage.d.ts +0 -223
  672. package/dist/esm/v2/__tests__/fixtures/testStorage.js +0 -106
  673. package/dist/esm/v2/__tests__/fixtures/testStorage.js.map +0 -1
  674. package/dist/esm/v2/__tests__/queries.test.d.ts +0 -1
  675. package/dist/esm/v2/__tests__/queries.test.js +0 -90
  676. package/dist/esm/v2/__tests__/queries.test.js.map +0 -1
  677. package/dist/esm/v2/__tests__/setup/indexedDB.d.ts +0 -1
  678. package/dist/esm/v2/__tests__/setup/indexedDB.js +0 -2
  679. package/dist/esm/v2/__tests__/setup/indexedDB.js.map +0 -1
  680. package/dist/esm/v2/constants.d.ts +0 -1
  681. package/dist/esm/v2/constants.js +0 -2
  682. package/dist/esm/v2/constants.js.map +0 -1
  683. package/dist/esm/v2/idb.d.ts +0 -6
  684. package/dist/esm/v2/idb.js +0 -65
  685. package/dist/esm/v2/idb.js.map +0 -1
  686. package/dist/esm/v2/index.d.ts +0 -6
  687. package/dist/esm/v2/index.js +0 -5
  688. package/dist/esm/v2/index.js.map +0 -1
  689. package/dist/esm/v2/indexes.d.ts +0 -3
  690. package/dist/esm/v2/indexes.js +0 -15
  691. package/dist/esm/v2/indexes.js.map +0 -1
  692. package/dist/esm/v2/openDocumentDatabase.d.ts +0 -9
  693. package/dist/esm/v2/openDocumentDatabase.js +0 -96
  694. package/dist/esm/v2/openDocumentDatabase.js.map +0 -1
  695. package/dist/esm/v2/types.d.ts +0 -3
  696. package/dist/esm/v2/types.js +0 -2
  697. package/dist/esm/v2/types.js.map +0 -1
  698. /package/dist/esm/sync/{WebsocketSync.js.map → WebSocketSync.js.map} +0 -0
@@ -1,436 +1,436 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openWIPDocumentDatabase = exports.openDocumentDatabase = void 0;
4
- const common_1 = require("@verdant-web/common");
5
- const idb_js_1 = require("../idb.js");
6
- const dbQueries_js_1 = require("../queries/dbQueries.js");
7
- const db_js_1 = require("./db.js");
8
- const paths_js_1 = require("./paths.js");
9
- const globalIDB = typeof window !== 'undefined' ? window.indexedDB : undefined;
10
- async function openDocumentDatabase({ version, indexedDB = globalIDB, migrations, meta, context, }) {
11
- if (context.schema.wip) {
12
- throw new Error('Cannot open a production client with a WIP schema!');
13
- }
14
- const currentVersion = await (0, db_js_1.getDatabaseVersion)(indexedDB, context.namespace, version, context.log);
15
- context.log('debug', 'Current database version:', currentVersion, 'target version:', version);
16
- const toRun = (0, paths_js_1.getMigrationPath)({
17
- currentVersion,
18
- targetVersion: version,
19
- migrations,
20
- });
21
- if (toRun.length > 0) {
22
- context.log('debug', 'Migrations to run:', toRun.map((m) => m.version));
23
- await runMigrations({ context, toRun, meta, indexedDB });
24
- }
25
- return (0, db_js_1.openDatabase)(indexedDB, context.namespace, version, context.log);
26
- }
27
- exports.openDocumentDatabase = openDocumentDatabase;
28
- async function openWIPDocumentDatabase({ version, indexedDB = globalIDB, migrations, meta, context, wipNamespace, }) {
29
- context.log('debug', 'Opening WIP database', wipNamespace);
30
- const currentWIPVersion = await (0, db_js_1.getDatabaseVersion)(indexedDB, wipNamespace, version, context.log);
31
- if (currentWIPVersion === version) {
32
- context.log('info', `WIP schema is up-to-date; not refreshing database`);
33
- }
34
- else {
35
- context.log('info', `WIP schema is out-of-date; refreshing database`);
36
- // first we need to copy the data from the production database to the WIP database
37
- // at the current (non-wip) version.
38
- const initialToRun = (0, paths_js_1.getMigrationPath)({
39
- currentVersion: currentWIPVersion,
40
- targetVersion: version - 1,
41
- migrations,
42
- });
43
- if (initialToRun.length > 0) {
44
- await runMigrations({
45
- context,
46
- toRun: initialToRun,
47
- meta,
48
- indexedDB,
49
- namespace: wipNamespace,
50
- });
51
- // now, we copy the data from the main database.
52
- const mainDatabase = await (0, db_js_1.openDatabase)(indexedDB, context.namespace, version - 1, context.log);
53
- const wipDatabase = await (0, db_js_1.openDatabase)(indexedDB, wipNamespace, version - 1, context.log);
54
- // DOMStringList... doesn't have iterable... why
55
- const mainDatabaseStoreNames = new Array();
56
- for (let i = 0; i < mainDatabase.objectStoreNames.length; i++) {
57
- mainDatabaseStoreNames.push(mainDatabase.objectStoreNames[i]);
58
- }
59
- const copyFromTransaction = mainDatabase.transaction(mainDatabaseStoreNames, 'readonly');
60
- const copyFromStores = mainDatabaseStoreNames.map((name) => copyFromTransaction.objectStore(name));
61
- const allObjects = await Promise.all(copyFromStores.map((store) => (0, idb_js_1.storeRequestPromise)(store.getAll())));
62
- const copyToTransaction = wipDatabase.transaction(mainDatabaseStoreNames, 'readwrite');
63
- const copyToStores = mainDatabaseStoreNames.map((name) => copyToTransaction.objectStore(name));
64
- for (let i = 0; i < copyToStores.length; i++) {
65
- await Promise.all(allObjects[i].map((obj) => {
66
- return (0, idb_js_1.storeRequestPromise)(copyToStores[i].put(obj));
67
- }));
68
- }
69
- }
70
- const toRun = (0, paths_js_1.getMigrationPath)({
71
- currentVersion: version - 1,
72
- targetVersion: version,
73
- migrations,
74
- });
75
- if (toRun.length > 0) {
76
- await runMigrations({
77
- context,
78
- toRun,
79
- meta,
80
- indexedDB,
81
- namespace: wipNamespace,
82
- });
83
- }
84
- }
85
- return (0, db_js_1.openDatabase)(indexedDB, wipNamespace, version, context.log);
86
- }
87
- exports.openWIPDocumentDatabase = openWIPDocumentDatabase;
88
- async function runMigrations({ context, toRun, meta, indexedDB = globalIDB, namespace = context.namespace, }) {
89
- await (0, db_js_1.acquireLock)(namespace, async () => {
90
- // now the fun part
91
- for (const migration of toRun) {
92
- // special case: if this is the version 1 migration, we have no pre-existing database
93
- // to use for the migration.
94
- let engine;
95
- // migrations from 0 (i.e. initial migrations) don't attempt to open an existing db
96
- if (migration.oldSchema.version === 0) {
97
- engine = getInitialMigrationEngine({
98
- meta,
99
- migration,
100
- context,
101
- });
102
- await migration.migrate(engine);
103
- }
104
- else {
105
- // open the database with the current (old) version for this migration. this should
106
- // align with the database's current version.
107
- const originalDatabase = await (0, db_js_1.openDatabase)(indexedDB, namespace, migration.oldSchema.version, context.log);
108
- // this will only write to our metadata store via operations!
109
- engine = getMigrationEngine({
110
- meta,
111
- migration,
112
- context: Object.assign(Object.assign({}, context), { documentDb: originalDatabase }),
113
- });
114
- try {
115
- await migration.migrate(engine);
116
- // wait on any out-of-band async operations to complete
117
- await Promise.all(engine.awaitables);
118
- }
119
- catch (err) {
120
- context.log('critical', `Migration failed (${migration.oldSchema.version} -> ${migration.newSchema.version})`, err);
121
- throw err;
122
- }
123
- // now we have to open the database again with the next version and
124
- // make the appropriate schema changes during the upgrade.
125
- await (0, db_js_1.closeDatabase)(originalDatabase);
126
- }
127
- context.log('debug', 'Upgrading database', namespace, 'to version', migration.newSchema.version);
128
- await (0, db_js_1.upgradeDatabase)(indexedDB, namespace, migration.newSchema.version, (transaction, db) => {
129
- for (const newCollection of migration.addedCollections) {
130
- db.createObjectStore(newCollection, {
131
- keyPath: migration.newSchema.collections[newCollection].primaryKey,
132
- autoIncrement: false,
133
- });
134
- }
135
- for (const collection of migration.allCollections) {
136
- const store = transaction.objectStore(collection);
137
- // apply new indexes
138
- for (const newIndex of migration.addedIndexes[collection] || []) {
139
- store.createIndex(newIndex.name, newIndex.name, {
140
- multiEntry: newIndex.multiEntry,
141
- });
142
- }
143
- // remove old indexes
144
- for (const oldIndex of migration.removedIndexes[collection] || []) {
145
- store.deleteIndex(oldIndex.name);
146
- }
147
- }
148
- for (const removedCollection of migration.removedCollections) {
149
- // !! can't delete the store, because old operations that relate to
150
- // this store may still exist in history. instead, we can clear it out
151
- // and leave it in place
152
- transaction.objectStore(removedCollection).clear();
153
- }
154
- }, context.log);
155
- /**
156
- * In cases where operations from the future have been
157
- * received by this client, we may have created entire
158
- * documents in metadata which were not written to storage
159
- * because all of their operations were in the future (
160
- * i.e. in the next version). We have to find those documents
161
- * and also write their snapshots to storage, because they
162
- * won't be present in storage already to 'refresh,' so
163
- * if we don't analyze metadata for 'future' operations like
164
- * this, we won't know they exist.
165
- *
166
- * This led to behavior where the metadata would be properly
167
- * synced, but after upgrading the app and migrating, items
168
- * would be missing from findAll and findOne queries.
169
- */
170
- const docsWithUnappliedMigrations = await getDocsWithUnappliedMigrations({
171
- meta,
172
- currentVersion: migration.oldSchema.version,
173
- newVersion: migration.newSchema.version,
174
- });
175
- // once the schema is ready, we can write back the migrated documents
176
- const upgradedDatabase = await (0, db_js_1.openDatabase)(indexedDB, namespace, migration.newSchema.version, context.log);
177
- for (const collection of migration.allCollections) {
178
- // first step is to read in all the keys we need to rewrite
179
- const documentReadTransaction = upgradedDatabase.transaction(collection, 'readwrite');
180
- const readStore = documentReadTransaction.objectStore(collection);
181
- const keys = await getAllKeys(readStore);
182
- // map the keys to OIDs
183
- const oids = keys.map((key) => (0, common_1.createOid)(collection, `${key}`));
184
- oids.push(...engine.newOids.filter((oid) => {
185
- return (0, common_1.decomposeOid)(oid).collection === collection;
186
- }), ...docsWithUnappliedMigrations.filter((oid) => {
187
- return (0, common_1.decomposeOid)(oid).collection === collection;
188
- }));
189
- const snapshots = await Promise.all(oids.map(async (oid) => {
190
- try {
191
- const snap = await meta.getDocumentSnapshot(oid);
192
- return [oid, snap];
193
- }
194
- catch (e) {
195
- // this seems to happen with baselines/ops which are not fully
196
- // cleaned up after deletion?
197
- context.log('error', 'Could not regenerate snapshot during migration for oid', oid, 'this document will not be preserved', e);
198
- return null;
199
- }
200
- }));
201
- const views = snapshots
202
- .filter((s) => !!s)
203
- .map(([oid, snapshot]) => {
204
- if (!snapshot)
205
- return [oid, undefined];
206
- const view = (0, common_1.getIndexValues)(migration.newSchema.collections[collection], snapshot);
207
- return [oid, view];
208
- });
209
- // now we can write the documents back
210
- const documentWriteTransaction = upgradedDatabase.transaction(collection, 'readwrite');
211
- const writeStore = documentWriteTransaction.objectStore(collection);
212
- await Promise.all(views.map(([oid, view]) => {
213
- if (view) {
214
- return putView(writeStore, view).catch((err) => {
215
- view;
216
- throw err;
217
- });
218
- }
219
- else {
220
- const { id } = (0, common_1.decomposeOid)(oid);
221
- return deleteView(writeStore, id);
222
- }
223
- }));
224
- }
225
- await (0, db_js_1.closeDatabase)(upgradedDatabase);
226
- context.log('debug', `Migration of ${namespace} complete.`);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openWIPDocumentDatabase = exports.openDocumentDatabase = void 0;
4
+ const common_1 = require("@verdant-web/common");
5
+ const idb_js_1 = require("../idb.js");
6
+ const dbQueries_js_1 = require("../queries/dbQueries.js");
7
+ const db_js_1 = require("./db.js");
8
+ const paths_js_1 = require("./paths.js");
9
+ const globalIDB = typeof window !== 'undefined' ? window.indexedDB : undefined;
10
+ async function openDocumentDatabase({ version, indexedDB = globalIDB, migrations, meta, context, }) {
11
+ if (context.schema.wip) {
12
+ throw new Error('Cannot open a production client with a WIP schema!');
13
+ }
14
+ const currentVersion = await (0, db_js_1.getDatabaseVersion)(indexedDB, context.namespace, version, context.log);
15
+ context.log('debug', 'Current database version:', currentVersion, 'target version:', version);
16
+ const toRun = (0, paths_js_1.getMigrationPath)({
17
+ currentVersion,
18
+ targetVersion: version,
19
+ migrations,
20
+ });
21
+ if (toRun.length > 0) {
22
+ context.log('debug', 'Migrations to run:', toRun.map((m) => m.version));
23
+ await runMigrations({ context, toRun, meta, indexedDB });
24
+ }
25
+ return (0, db_js_1.openDatabase)(indexedDB, context.namespace, version, context.log);
26
+ }
27
+ exports.openDocumentDatabase = openDocumentDatabase;
28
+ async function openWIPDocumentDatabase({ version, indexedDB = globalIDB, migrations, meta, context, wipNamespace, }) {
29
+ context.log('debug', 'Opening WIP database', wipNamespace);
30
+ const currentWIPVersion = await (0, db_js_1.getDatabaseVersion)(indexedDB, wipNamespace, version, context.log);
31
+ if (currentWIPVersion === version) {
32
+ context.log('info', `WIP schema is up-to-date; not refreshing database`);
33
+ }
34
+ else {
35
+ context.log('info', `WIP schema is out-of-date; refreshing database`);
36
+ // first we need to copy the data from the production database to the WIP database
37
+ // at the current (non-wip) version.
38
+ const initialToRun = (0, paths_js_1.getMigrationPath)({
39
+ currentVersion: currentWIPVersion,
40
+ targetVersion: version - 1,
41
+ migrations,
42
+ });
43
+ if (initialToRun.length > 0) {
44
+ await runMigrations({
45
+ context,
46
+ toRun: initialToRun,
47
+ meta,
48
+ indexedDB,
49
+ namespace: wipNamespace,
50
+ });
51
+ // now, we copy the data from the main database.
52
+ const mainDatabase = await (0, db_js_1.openDatabase)(indexedDB, context.namespace, version - 1, context.log);
53
+ const wipDatabase = await (0, db_js_1.openDatabase)(indexedDB, wipNamespace, version - 1, context.log);
54
+ // DOMStringList... doesn't have iterable... why
55
+ const mainDatabaseStoreNames = new Array();
56
+ for (let i = 0; i < mainDatabase.objectStoreNames.length; i++) {
57
+ mainDatabaseStoreNames.push(mainDatabase.objectStoreNames[i]);
58
+ }
59
+ const copyFromTransaction = mainDatabase.transaction(mainDatabaseStoreNames, 'readonly');
60
+ const copyFromStores = mainDatabaseStoreNames.map((name) => copyFromTransaction.objectStore(name));
61
+ const allObjects = await Promise.all(copyFromStores.map((store) => (0, idb_js_1.storeRequestPromise)(store.getAll())));
62
+ const copyToTransaction = wipDatabase.transaction(mainDatabaseStoreNames, 'readwrite');
63
+ const copyToStores = mainDatabaseStoreNames.map((name) => copyToTransaction.objectStore(name));
64
+ for (let i = 0; i < copyToStores.length; i++) {
65
+ await Promise.all(allObjects[i].map((obj) => {
66
+ return (0, idb_js_1.storeRequestPromise)(copyToStores[i].put(obj));
67
+ }));
68
+ }
69
+ }
70
+ const toRun = (0, paths_js_1.getMigrationPath)({
71
+ currentVersion: version - 1,
72
+ targetVersion: version,
73
+ migrations,
74
+ });
75
+ if (toRun.length > 0) {
76
+ await runMigrations({
77
+ context,
78
+ toRun,
79
+ meta,
80
+ indexedDB,
81
+ namespace: wipNamespace,
82
+ });
83
+ }
84
+ }
85
+ return (0, db_js_1.openDatabase)(indexedDB, wipNamespace, version, context.log);
86
+ }
87
+ exports.openWIPDocumentDatabase = openWIPDocumentDatabase;
88
+ async function runMigrations({ context, toRun, meta, indexedDB = globalIDB, namespace = context.namespace, }) {
89
+ await (0, db_js_1.acquireLock)(namespace, async () => {
90
+ // now the fun part
91
+ for (const migration of toRun) {
92
+ // special case: if this is the version 1 migration, we have no pre-existing database
93
+ // to use for the migration.
94
+ let engine;
95
+ // migrations from 0 (i.e. initial migrations) don't attempt to open an existing db
96
+ if (migration.oldSchema.version === 0) {
97
+ engine = getInitialMigrationEngine({
98
+ meta,
99
+ migration,
100
+ context,
101
+ });
102
+ await migration.migrate(engine);
103
+ }
104
+ else {
105
+ // open the database with the current (old) version for this migration. this should
106
+ // align with the database's current version.
107
+ const originalDatabase = await (0, db_js_1.openDatabase)(indexedDB, namespace, migration.oldSchema.version, context.log);
108
+ // this will only write to our metadata store via operations!
109
+ engine = getMigrationEngine({
110
+ meta,
111
+ migration,
112
+ context: Object.assign(Object.assign({}, context), { documentDb: originalDatabase }),
113
+ });
114
+ try {
115
+ await migration.migrate(engine);
116
+ // wait on any out-of-band async operations to complete
117
+ await Promise.all(engine.awaitables);
118
+ }
119
+ catch (err) {
120
+ context.log('critical', `Migration failed (${migration.oldSchema.version} -> ${migration.newSchema.version})`, err);
121
+ throw err;
122
+ }
123
+ // now we have to open the database again with the next version and
124
+ // make the appropriate schema changes during the upgrade.
125
+ await (0, db_js_1.closeDatabase)(originalDatabase);
126
+ }
127
+ context.log('debug', 'Upgrading database', namespace, 'to version', migration.newSchema.version);
128
+ await (0, db_js_1.upgradeDatabase)(indexedDB, namespace, migration.newSchema.version, (transaction, db) => {
129
+ for (const newCollection of migration.addedCollections) {
130
+ db.createObjectStore(newCollection, {
131
+ keyPath: migration.newSchema.collections[newCollection].primaryKey,
132
+ autoIncrement: false,
133
+ });
134
+ }
135
+ for (const collection of migration.allCollections) {
136
+ const store = transaction.objectStore(collection);
137
+ // apply new indexes
138
+ for (const newIndex of migration.addedIndexes[collection] || []) {
139
+ store.createIndex(newIndex.name, newIndex.name, {
140
+ multiEntry: newIndex.multiEntry,
141
+ });
142
+ }
143
+ // remove old indexes
144
+ for (const oldIndex of migration.removedIndexes[collection] || []) {
145
+ store.deleteIndex(oldIndex.name);
146
+ }
147
+ }
148
+ for (const removedCollection of migration.removedCollections) {
149
+ // !! can't delete the store, because old operations that relate to
150
+ // this store may still exist in history. instead, we can clear it out
151
+ // and leave it in place
152
+ transaction.objectStore(removedCollection).clear();
153
+ }
154
+ }, context.log);
155
+ /**
156
+ * In cases where operations from the future have been
157
+ * received by this client, we may have created entire
158
+ * documents in metadata which were not written to storage
159
+ * because all of their operations were in the future (
160
+ * i.e. in the next version). We have to find those documents
161
+ * and also write their snapshots to storage, because they
162
+ * won't be present in storage already to 'refresh,' so
163
+ * if we don't analyze metadata for 'future' operations like
164
+ * this, we won't know they exist.
165
+ *
166
+ * This led to behavior where the metadata would be properly
167
+ * synced, but after upgrading the app and migrating, items
168
+ * would be missing from findAll and findOne queries.
169
+ */
170
+ const docsWithUnappliedMigrations = await getDocsWithUnappliedMigrations({
171
+ meta,
172
+ currentVersion: migration.oldSchema.version,
173
+ newVersion: migration.newSchema.version,
174
+ });
175
+ // once the schema is ready, we can write back the migrated documents
176
+ const upgradedDatabase = await (0, db_js_1.openDatabase)(indexedDB, namespace, migration.newSchema.version, context.log);
177
+ for (const collection of migration.allCollections) {
178
+ // first step is to read in all the keys we need to rewrite
179
+ const documentReadTransaction = upgradedDatabase.transaction(collection, 'readwrite');
180
+ const readStore = documentReadTransaction.objectStore(collection);
181
+ const keys = await getAllKeys(readStore);
182
+ // map the keys to OIDs
183
+ const oids = keys.map((key) => (0, common_1.createOid)(collection, `${key}`));
184
+ oids.push(...engine.newOids.filter((oid) => {
185
+ return (0, common_1.decomposeOid)(oid).collection === collection;
186
+ }), ...docsWithUnappliedMigrations.filter((oid) => {
187
+ return (0, common_1.decomposeOid)(oid).collection === collection;
188
+ }));
189
+ const snapshots = await Promise.all(oids.map(async (oid) => {
190
+ try {
191
+ const snap = await meta.getDocumentSnapshot(oid);
192
+ return [oid, snap];
193
+ }
194
+ catch (e) {
195
+ // this seems to happen with baselines/ops which are not fully
196
+ // cleaned up after deletion?
197
+ context.log('error', 'Could not regenerate snapshot during migration for oid', oid, 'this document will not be preserved', e);
198
+ return null;
199
+ }
200
+ }));
201
+ const views = snapshots
202
+ .filter((s) => !!s)
203
+ .map(([oid, snapshot]) => {
204
+ if (!snapshot)
205
+ return [oid, undefined];
206
+ const view = (0, common_1.getIndexValues)(migration.newSchema.collections[collection], snapshot);
207
+ return [oid, view];
208
+ });
209
+ // now we can write the documents back
210
+ const documentWriteTransaction = upgradedDatabase.transaction(collection, 'readwrite');
211
+ const writeStore = documentWriteTransaction.objectStore(collection);
212
+ await Promise.all(views.map(([oid, view]) => {
213
+ if (view) {
214
+ return putView(writeStore, view).catch((err) => {
215
+ view;
216
+ throw err;
217
+ });
218
+ }
219
+ else {
220
+ const { id } = (0, common_1.decomposeOid)(oid);
221
+ return deleteView(writeStore, id);
222
+ }
223
+ }));
224
+ }
225
+ await (0, db_js_1.closeDatabase)(upgradedDatabase);
226
+ context.log('debug', `Migration of ${namespace} complete.`);
227
227
  context.log(`
228
228
  ⬆️ v${migration.newSchema.version} Migration complete. Here's the rundown:
229
229
  - Added collections: ${migration.addedCollections.join(', ')}
230
230
  - Removed collections: ${migration.removedCollections.join(', ')}
231
231
  - Changed collections: ${migration.changedCollections.join(', ')}
232
- - New indexes: ${Object.keys(migration.addedIndexes)
233
- .map((col) => migration.addedIndexes[col].map((i) => `${col}.${i.name}`))
234
- .flatMap((i) => i)
232
+ - New indexes: ${Object.keys(migration.addedIndexes)
233
+ .map((col) => migration.addedIndexes[col].map((i) => `${col}.${i.name}`))
234
+ .flatMap((i) => i)
235
235
  .join(', ')}
236
- - Removed indexes: ${Object.keys(migration.removedIndexes)
237
- .map((col) => migration.removedIndexes[col].map((i) => `${col}.${i.name}`))
238
- .flatMap((i) => i)
236
+ - Removed indexes: ${Object.keys(migration.removedIndexes)
237
+ .map((col) => migration.removedIndexes[col].map((i) => `${col}.${i.name}`))
238
+ .flatMap((i) => i)
239
239
  .join(', ')}
240
- `);
241
- }
242
- });
243
- }
244
- function getMigrationMutations({ migration, meta, getMigrationNow, newOids, }) {
245
- return migration.allCollections.reduce((acc, collectionName) => {
246
- acc[collectionName] = {
247
- put: async (doc) => {
248
- // add defaults
249
- (0, common_1.addFieldDefaults)(migration.newSchema.collections[collectionName], doc);
250
- const primaryKey = doc[migration.newSchema.collections[collectionName].primaryKey];
251
- const oid = (0, common_1.createOid)(collectionName, primaryKey);
252
- newOids.push(oid);
253
- await meta.insertLocalOperation((0, common_1.initialToPatches)(doc, oid, getMigrationNow));
254
- return doc;
255
- },
256
- delete: (id) => {
257
- const oid = (0, common_1.createOid)(collectionName, id);
258
- return meta.insertLocalOperation([
259
- {
260
- oid,
261
- timestamp: getMigrationNow(),
262
- data: { op: 'delete' },
263
- },
264
- ]);
265
- },
266
- };
267
- return acc;
268
- }, {});
269
- }
270
- function getMigrationQueries({ migration, context, meta, }) {
271
- return migration.oldCollections.reduce((acc, collectionName) => {
272
- acc[collectionName] = {
273
- get: async (id) => {
274
- const oid = (0, common_1.createOid)(collectionName, id);
275
- const doc = await meta.getDocumentSnapshot(oid, {
276
- // only get the snapshot up to the previous version (newer operations may have synced)
277
- to: meta.time.now(migration.oldSchema.version),
278
- });
279
- return doc;
280
- },
281
- findOne: async (filter) => {
282
- const oid = await (0, dbQueries_js_1.findOneOid)({
283
- collection: collectionName,
284
- index: filter,
285
- context,
286
- });
287
- if (!oid)
288
- return null;
289
- const doc = await meta.getDocumentSnapshot(oid, {
290
- // only get the snapshot up to the previous version (newer operations may have synced)
291
- to: meta.time.now(migration.oldSchema.version),
292
- });
293
- return doc;
294
- },
295
- findAll: async (filter) => {
296
- const oids = await (0, dbQueries_js_1.findAllOids)({
297
- collection: collectionName,
298
- index: filter,
299
- context,
300
- });
301
- const docs = await Promise.all(oids.map((oid) => meta.getDocumentSnapshot(oid, {
302
- // only get the snapshot up to the previous version (newer operations may have synced)
303
- to: meta.time.now(migration.oldSchema.version),
304
- })));
305
- return docs;
306
- },
307
- };
308
- return acc;
309
- }, {});
310
- }
311
- function getMigrationEngine({ meta, migration, context, }) {
312
- function getMigrationNow() {
313
- return meta.time.zero(migration.version);
314
- }
315
- const newOids = new Array();
316
- const queries = getMigrationQueries({
317
- migration,
318
- context,
319
- meta,
320
- });
321
- const mutations = getMigrationMutations({
322
- migration,
323
- getMigrationNow,
324
- newOids,
325
- meta,
326
- });
327
- const awaitables = new Array();
328
- const engine = {
329
- log: context.log,
330
- newOids,
331
- migrate: async (collection, strategy) => {
332
- const docs = await queries[collection].findAll();
333
- await Promise.all(docs.filter(Boolean).map(async (doc) => {
334
- (0, common_1.assert)((0, common_1.hasOid)(doc), `Document is missing an OID: ${JSON.stringify(doc)}`);
335
- const original = (0, common_1.cloneDeep)(doc);
336
- // @ts-ignore - excessive type resolution
337
- const newValue = await strategy(doc);
338
- if (newValue) {
339
- // the migration has altered the shape of our document. we need
340
- // to create the operation from the diff and write it to meta as
341
- // a migration patch
342
- (0, common_1.removeOidPropertiesFromAllSubObjects)(original);
343
- (0, common_1.removeOidPropertiesFromAllSubObjects)(newValue);
344
- (0, common_1.assignOidsToAllSubObjects)(newValue);
345
- const patches = (0, common_1.diffToPatches)(original, newValue, getMigrationNow, undefined, [], {
346
- mergeUnknownObjects: true,
347
- });
348
- if (patches.length > 0) {
349
- await meta.insertLocalOperation(patches);
350
- }
351
- }
352
- }));
353
- },
354
- queries,
355
- mutations,
356
- awaitables,
357
- };
358
- return engine;
359
- }
360
- function getInitialMigrationEngine({ meta, migration, context, }) {
361
- function getMigrationNow() {
362
- return meta.time.zero(migration.version);
363
- }
364
- const newOids = new Array();
365
- const queries = new Proxy({}, {
366
- get() {
367
- throw new Error('Queries are not available in initial migrations; there is no database yet!');
368
- },
369
- });
370
- const mutations = getMigrationMutations({
371
- migration,
372
- getMigrationNow,
373
- newOids,
374
- meta,
375
- });
376
- const engine = {
377
- log: context.log,
378
- newOids,
379
- migrate: () => {
380
- throw new Error('Calling migrate() in initial migrations is not supported! Use initial migrations to seed initial data using mutations.');
381
- },
382
- queries,
383
- mutations,
384
- awaitables: [],
385
- };
386
- return engine;
387
- }
388
- async function getAllKeys(store) {
389
- return new Promise((resolve, reject) => {
390
- const request = store.getAllKeys();
391
- request.onsuccess = (event) => {
392
- resolve(request.result);
393
- };
394
- request.onerror = (event) => {
395
- reject(request.error);
396
- };
397
- });
398
- }
399
- async function deleteView(store, id) {
400
- const request = store.delete(id);
401
- return new Promise((resolve, reject) => {
402
- request.onsuccess = (event) => {
403
- resolve();
404
- };
405
- request.onerror = (event) => {
406
- reject(request.error);
407
- };
408
- });
409
- }
410
- async function putView(store, view) {
411
- const request = store.put(view);
412
- return new Promise((resolve, reject) => {
413
- request.onsuccess = (event) => {
414
- resolve();
415
- };
416
- request.onerror = (event) => {
417
- reject(request.error);
418
- };
419
- });
420
- }
421
- /**
422
- * Gets a list of root OIDs for all documents which had operations stored already
423
- * that were not applied to their queryable snapshots because they were in the
424
- * future. These documents need to be refreshed in storage.
425
- */
426
- async function getDocsWithUnappliedMigrations({ meta, currentVersion, newVersion: _, }) {
427
- // scan for all operations in metadata after the current version.
428
- // this could be more efficient if also filtering below or equal newVersion but
429
- // that seems so unlikely in practice...
430
- const unappliedOperations = [];
431
- await meta.operations.iterateOverAllOperations((op) => unappliedOperations.push(op), {
432
- from: meta.time.zero(currentVersion + 1),
433
- });
434
- return Array.from(new Set(unappliedOperations.map((op) => (0, common_1.getOidRoot)(op.oid))));
435
- }
240
+ `);
241
+ }
242
+ });
243
+ }
244
+ function getMigrationMutations({ migration, meta, getMigrationNow, newOids, }) {
245
+ return migration.allCollections.reduce((acc, collectionName) => {
246
+ acc[collectionName] = {
247
+ put: async (doc) => {
248
+ // add defaults
249
+ (0, common_1.addFieldDefaults)(migration.newSchema.collections[collectionName], doc);
250
+ const primaryKey = doc[migration.newSchema.collections[collectionName].primaryKey];
251
+ const oid = (0, common_1.createOid)(collectionName, primaryKey);
252
+ newOids.push(oid);
253
+ await meta.insertLocalOperation((0, common_1.initialToPatches)(doc, oid, getMigrationNow));
254
+ return doc;
255
+ },
256
+ delete: (id) => {
257
+ const oid = (0, common_1.createOid)(collectionName, id);
258
+ return meta.insertLocalOperation([
259
+ {
260
+ oid,
261
+ timestamp: getMigrationNow(),
262
+ data: { op: 'delete' },
263
+ },
264
+ ]);
265
+ },
266
+ };
267
+ return acc;
268
+ }, {});
269
+ }
270
+ function getMigrationQueries({ migration, context, meta, }) {
271
+ return migration.oldCollections.reduce((acc, collectionName) => {
272
+ acc[collectionName] = {
273
+ get: async (id) => {
274
+ const oid = (0, common_1.createOid)(collectionName, id);
275
+ const doc = await meta.getDocumentSnapshot(oid, {
276
+ // only get the snapshot up to the previous version (newer operations may have synced)
277
+ to: meta.time.now(migration.oldSchema.version),
278
+ });
279
+ return doc;
280
+ },
281
+ findOne: async (filter) => {
282
+ const oid = await (0, dbQueries_js_1.findOneOid)({
283
+ collection: collectionName,
284
+ index: filter,
285
+ context,
286
+ });
287
+ if (!oid)
288
+ return null;
289
+ const doc = await meta.getDocumentSnapshot(oid, {
290
+ // only get the snapshot up to the previous version (newer operations may have synced)
291
+ to: meta.time.now(migration.oldSchema.version),
292
+ });
293
+ return doc;
294
+ },
295
+ findAll: async (filter) => {
296
+ const oids = await (0, dbQueries_js_1.findAllOids)({
297
+ collection: collectionName,
298
+ index: filter,
299
+ context,
300
+ });
301
+ const docs = await Promise.all(oids.map((oid) => meta.getDocumentSnapshot(oid, {
302
+ // only get the snapshot up to the previous version (newer operations may have synced)
303
+ to: meta.time.now(migration.oldSchema.version),
304
+ })));
305
+ return docs;
306
+ },
307
+ };
308
+ return acc;
309
+ }, {});
310
+ }
311
+ function getMigrationEngine({ meta, migration, context, }) {
312
+ function getMigrationNow() {
313
+ return meta.time.zero(migration.version);
314
+ }
315
+ const newOids = new Array();
316
+ const queries = getMigrationQueries({
317
+ migration,
318
+ context,
319
+ meta,
320
+ });
321
+ const mutations = getMigrationMutations({
322
+ migration,
323
+ getMigrationNow,
324
+ newOids,
325
+ meta,
326
+ });
327
+ const awaitables = new Array();
328
+ const engine = {
329
+ log: context.log,
330
+ newOids,
331
+ migrate: async (collection, strategy) => {
332
+ const docs = await queries[collection].findAll();
333
+ await Promise.all(docs.filter(Boolean).map(async (doc) => {
334
+ (0, common_1.assert)((0, common_1.hasOid)(doc), `Document is missing an OID: ${JSON.stringify(doc)}`);
335
+ const original = (0, common_1.cloneDeep)(doc);
336
+ // @ts-ignore - excessive type resolution
337
+ const newValue = await strategy(doc);
338
+ if (newValue) {
339
+ // the migration has altered the shape of our document. we need
340
+ // to create the operation from the diff and write it to meta as
341
+ // a migration patch
342
+ (0, common_1.removeOidPropertiesFromAllSubObjects)(original);
343
+ (0, common_1.removeOidPropertiesFromAllSubObjects)(newValue);
344
+ (0, common_1.assignOidsToAllSubObjects)(newValue);
345
+ const patches = (0, common_1.diffToPatches)(original, newValue, getMigrationNow, undefined, [], {
346
+ mergeUnknownObjects: true,
347
+ });
348
+ if (patches.length > 0) {
349
+ await meta.insertLocalOperation(patches);
350
+ }
351
+ }
352
+ }));
353
+ },
354
+ queries,
355
+ mutations,
356
+ awaitables,
357
+ };
358
+ return engine;
359
+ }
360
+ function getInitialMigrationEngine({ meta, migration, context, }) {
361
+ function getMigrationNow() {
362
+ return meta.time.zero(migration.version);
363
+ }
364
+ const newOids = new Array();
365
+ const queries = new Proxy({}, {
366
+ get() {
367
+ throw new Error('Queries are not available in initial migrations; there is no database yet!');
368
+ },
369
+ });
370
+ const mutations = getMigrationMutations({
371
+ migration,
372
+ getMigrationNow,
373
+ newOids,
374
+ meta,
375
+ });
376
+ const engine = {
377
+ log: context.log,
378
+ newOids,
379
+ migrate: () => {
380
+ throw new Error('Calling migrate() in initial migrations is not supported! Use initial migrations to seed initial data using mutations.');
381
+ },
382
+ queries,
383
+ mutations,
384
+ awaitables: [],
385
+ };
386
+ return engine;
387
+ }
388
+ async function getAllKeys(store) {
389
+ return new Promise((resolve, reject) => {
390
+ const request = store.getAllKeys();
391
+ request.onsuccess = (event) => {
392
+ resolve(request.result);
393
+ };
394
+ request.onerror = (event) => {
395
+ reject(request.error);
396
+ };
397
+ });
398
+ }
399
+ async function deleteView(store, id) {
400
+ const request = store.delete(id);
401
+ return new Promise((resolve, reject) => {
402
+ request.onsuccess = (event) => {
403
+ resolve();
404
+ };
405
+ request.onerror = (event) => {
406
+ reject(request.error);
407
+ };
408
+ });
409
+ }
410
+ async function putView(store, view) {
411
+ const request = store.put(view);
412
+ return new Promise((resolve, reject) => {
413
+ request.onsuccess = (event) => {
414
+ resolve();
415
+ };
416
+ request.onerror = (event) => {
417
+ reject(request.error);
418
+ };
419
+ });
420
+ }
421
+ /**
422
+ * Gets a list of root OIDs for all documents which had operations stored already
423
+ * that were not applied to their queryable snapshots because they were in the
424
+ * future. These documents need to be refreshed in storage.
425
+ */
426
+ async function getDocsWithUnappliedMigrations({ meta, currentVersion, newVersion: _, }) {
427
+ // scan for all operations in metadata after the current version.
428
+ // this could be more efficient if also filtering below or equal newVersion but
429
+ // that seems so unlikely in practice...
430
+ const unappliedOperations = [];
431
+ await meta.operations.iterateOverAllOperations((op) => unappliedOperations.push(op), {
432
+ from: meta.time.zero(currentVersion + 1),
433
+ });
434
+ return Array.from(new Set(unappliedOperations.map((op) => (0, common_1.getOidRoot)(op.oid))));
435
+ }
436
436
  //# sourceMappingURL=openDatabase.js.map