@connecttomahdi/rxdb 17.0.0-beta.17 → 17.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +47 -4
  3. package/CLAUDE.md +2 -0
  4. package/dist/cjs/change-event-buffer.js +2 -1
  5. package/dist/cjs/change-event-buffer.js.map +1 -1
  6. package/dist/cjs/custom-index.js +85 -12
  7. package/dist/cjs/custom-index.js.map +1 -1
  8. package/dist/cjs/doc-cache.js +117 -35
  9. package/dist/cjs/doc-cache.js.map +1 -1
  10. package/dist/cjs/event-reduce.js +10 -1
  11. package/dist/cjs/event-reduce.js.map +1 -1
  12. package/dist/cjs/plugin-helpers.js +16 -0
  13. package/dist/cjs/plugin-helpers.js.map +1 -1
  14. package/dist/cjs/plugins/attachments/index.js +3 -3
  15. package/dist/cjs/plugins/attachments/index.js.map +1 -1
  16. package/dist/cjs/plugins/cleanup/cleanup.js +5 -3
  17. package/dist/cjs/plugins/cleanup/cleanup.js.map +1 -1
  18. package/dist/cjs/plugins/crdt/index.js +52 -0
  19. package/dist/cjs/plugins/crdt/index.js.map +1 -1
  20. package/dist/cjs/plugins/dev-mode/check-query.js +7 -1
  21. package/dist/cjs/plugins/dev-mode/check-query.js.map +1 -1
  22. package/dist/cjs/plugins/dev-mode/check-schema.js +2 -1
  23. package/dist/cjs/plugins/dev-mode/check-schema.js.map +1 -1
  24. package/dist/cjs/plugins/dev-mode/error-messages.js +43 -5
  25. package/dist/cjs/plugins/dev-mode/error-messages.js.map +1 -1
  26. package/dist/cjs/plugins/encryption-crypto-js/index.js +22 -6
  27. package/dist/cjs/plugins/encryption-crypto-js/index.js.map +1 -1
  28. package/dist/cjs/plugins/leader-election/index.js +5 -5
  29. package/dist/cjs/plugins/leader-election/index.js.map +1 -1
  30. package/dist/cjs/plugins/local-documents/local-documents.js +20 -13
  31. package/dist/cjs/plugins/local-documents/local-documents.js.map +1 -1
  32. package/dist/cjs/plugins/migration-schema/migration-helpers.js +3 -0
  33. package/dist/cjs/plugins/migration-schema/migration-helpers.js.map +1 -1
  34. package/dist/cjs/plugins/migration-schema/rx-migration-state.js +1 -1
  35. package/dist/cjs/plugins/migration-schema/rx-migration-state.js.map +1 -1
  36. package/dist/cjs/plugins/pipeline/rx-pipeline.js +5 -1
  37. package/dist/cjs/plugins/pipeline/rx-pipeline.js.map +1 -1
  38. package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js +4 -2
  39. package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -1
  40. package/dist/cjs/plugins/replication/index.js +40 -2
  41. package/dist/cjs/plugins/replication/index.js.map +1 -1
  42. package/dist/cjs/plugins/replication-google-drive/document-handling.js +17 -6
  43. package/dist/cjs/plugins/replication-google-drive/document-handling.js.map +1 -1
  44. package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js +1 -1
  45. package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js.map +1 -1
  46. package/dist/cjs/plugins/replication-google-drive/google-drive-types.js.map +1 -1
  47. package/dist/cjs/plugins/replication-google-drive/signaling.js +4 -1
  48. package/dist/cjs/plugins/replication-google-drive/signaling.js.map +1 -1
  49. package/dist/cjs/plugins/replication-google-drive/upstream.js +7 -4
  50. package/dist/cjs/plugins/replication-google-drive/upstream.js.map +1 -1
  51. package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js +4 -1
  52. package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js.map +1 -1
  53. package/dist/cjs/plugins/state/rx-state.js +14 -3
  54. package/dist/cjs/plugins/state/rx-state.js.map +1 -1
  55. package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js +10 -17
  56. package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
  57. package/dist/cjs/plugins/storage-memory/binary-search-bounds.js +112 -40
  58. package/dist/cjs/plugins/storage-memory/binary-search-bounds.js.map +1 -1
  59. package/dist/cjs/plugins/storage-memory/memory-helper.js +127 -40
  60. package/dist/cjs/plugins/storage-memory/memory-helper.js.map +1 -1
  61. package/dist/cjs/plugins/storage-memory/memory-indexes.js +1 -0
  62. package/dist/cjs/plugins/storage-memory/memory-indexes.js.map +1 -1
  63. package/dist/cjs/plugins/storage-memory/memory-types.js.map +1 -1
  64. package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js +97 -37
  65. package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -1
  66. package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js +42 -1
  67. package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js.map +1 -1
  68. package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js +7 -7
  69. package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -1
  70. package/dist/cjs/plugins/test-utils/config.js +1 -1
  71. package/dist/cjs/plugins/test-utils/config.js.map +1 -1
  72. package/dist/cjs/plugins/test-utils/performance.js +122 -92
  73. package/dist/cjs/plugins/test-utils/performance.js.map +1 -1
  74. package/dist/cjs/plugins/test-utils/schema-objects.js +1 -1
  75. package/dist/cjs/plugins/test-utils/schema-objects.js.map +1 -1
  76. package/dist/cjs/plugins/test-utils/test-util.js +62 -0
  77. package/dist/cjs/plugins/test-utils/test-util.js.map +1 -1
  78. package/dist/cjs/plugins/utils/utils-map.js +2 -2
  79. package/dist/cjs/plugins/utils/utils-map.js.map +1 -1
  80. package/dist/cjs/plugins/utils/utils-object-deep-equal.js +3 -2
  81. package/dist/cjs/plugins/utils/utils-object-deep-equal.js.map +1 -1
  82. package/dist/cjs/plugins/utils/utils-object-dot-prop.js +25 -0
  83. package/dist/cjs/plugins/utils/utils-object-dot-prop.js.map +1 -1
  84. package/dist/cjs/plugins/utils/utils-object.js +102 -27
  85. package/dist/cjs/plugins/utils/utils-object.js.map +1 -1
  86. package/dist/cjs/plugins/utils/utils-other.js +9 -4
  87. package/dist/cjs/plugins/utils/utils-other.js.map +1 -1
  88. package/dist/cjs/plugins/utils/utils-premium.js +1 -19
  89. package/dist/cjs/plugins/utils/utils-premium.js.map +1 -1
  90. package/dist/cjs/plugins/utils/utils-revision.js +20 -10
  91. package/dist/cjs/plugins/utils/utils-revision.js.map +1 -1
  92. package/dist/cjs/plugins/utils/utils-rxdb-version.js +1 -1
  93. package/dist/cjs/plugins/utils/utils-rxdb-version.js.map +1 -1
  94. package/dist/cjs/plugins/utils/utils-string.js +11 -8
  95. package/dist/cjs/plugins/utils/utils-string.js.map +1 -1
  96. package/dist/cjs/plugins/utils/utils-time.js +21 -16
  97. package/dist/cjs/plugins/utils/utils-time.js.map +1 -1
  98. package/dist/cjs/query-cache.js +6 -4
  99. package/dist/cjs/query-cache.js.map +1 -1
  100. package/dist/cjs/query-planner.js +2 -2
  101. package/dist/cjs/query-planner.js.map +1 -1
  102. package/dist/cjs/replication-protocol/downstream.js +1 -1
  103. package/dist/cjs/replication-protocol/downstream.js.map +1 -1
  104. package/dist/cjs/rx-collection-helper.js +11 -6
  105. package/dist/cjs/rx-collection-helper.js.map +1 -1
  106. package/dist/cjs/rx-collection.js +34 -6
  107. package/dist/cjs/rx-collection.js.map +1 -1
  108. package/dist/cjs/rx-database.js +40 -7
  109. package/dist/cjs/rx-database.js.map +1 -1
  110. package/dist/cjs/rx-document.js +10 -3
  111. package/dist/cjs/rx-document.js.map +1 -1
  112. package/dist/cjs/rx-query-helper.js +35 -12
  113. package/dist/cjs/rx-query-helper.js.map +1 -1
  114. package/dist/cjs/rx-query-single-result.js +9 -2
  115. package/dist/cjs/rx-query-single-result.js.map +1 -1
  116. package/dist/cjs/rx-query.js +72 -29
  117. package/dist/cjs/rx-query.js.map +1 -1
  118. package/dist/cjs/rx-schema-helper.js +9 -3
  119. package/dist/cjs/rx-schema-helper.js.map +1 -1
  120. package/dist/cjs/rx-schema.js +1 -0
  121. package/dist/cjs/rx-schema.js.map +1 -1
  122. package/dist/cjs/rx-storage-helper.js +212 -129
  123. package/dist/cjs/rx-storage-helper.js.map +1 -1
  124. package/dist/cjs/types/rx-error.d.js.map +1 -1
  125. package/dist/cjs/types/rx-schema.d.js.map +1 -1
  126. package/dist/esm/change-event-buffer.js +2 -1
  127. package/dist/esm/change-event-buffer.js.map +1 -1
  128. package/dist/esm/custom-index.js +85 -12
  129. package/dist/esm/custom-index.js.map +1 -1
  130. package/dist/esm/doc-cache.js +118 -36
  131. package/dist/esm/doc-cache.js.map +1 -1
  132. package/dist/esm/event-reduce.js +10 -1
  133. package/dist/esm/event-reduce.js.map +1 -1
  134. package/dist/esm/plugin-helpers.js +16 -0
  135. package/dist/esm/plugin-helpers.js.map +1 -1
  136. package/dist/esm/plugins/attachments/index.js +3 -3
  137. package/dist/esm/plugins/attachments/index.js.map +1 -1
  138. package/dist/esm/plugins/cleanup/cleanup.js +5 -3
  139. package/dist/esm/plugins/cleanup/cleanup.js.map +1 -1
  140. package/dist/esm/plugins/crdt/index.js +52 -0
  141. package/dist/esm/plugins/crdt/index.js.map +1 -1
  142. package/dist/esm/plugins/dev-mode/check-query.js +7 -1
  143. package/dist/esm/plugins/dev-mode/check-query.js.map +1 -1
  144. package/dist/esm/plugins/dev-mode/check-schema.js +2 -1
  145. package/dist/esm/plugins/dev-mode/check-schema.js.map +1 -1
  146. package/dist/esm/plugins/dev-mode/error-messages.js +43 -5
  147. package/dist/esm/plugins/dev-mode/error-messages.js.map +1 -1
  148. package/dist/esm/plugins/encryption-crypto-js/index.js +22 -6
  149. package/dist/esm/plugins/encryption-crypto-js/index.js.map +1 -1
  150. package/dist/esm/plugins/leader-election/index.js +4 -4
  151. package/dist/esm/plugins/leader-election/index.js.map +1 -1
  152. package/dist/esm/plugins/local-documents/local-documents.js +20 -13
  153. package/dist/esm/plugins/local-documents/local-documents.js.map +1 -1
  154. package/dist/esm/plugins/migration-schema/migration-helpers.js +3 -0
  155. package/dist/esm/plugins/migration-schema/migration-helpers.js.map +1 -1
  156. package/dist/esm/plugins/migration-schema/rx-migration-state.js +1 -1
  157. package/dist/esm/plugins/migration-schema/rx-migration-state.js.map +1 -1
  158. package/dist/esm/plugins/pipeline/rx-pipeline.js +5 -1
  159. package/dist/esm/plugins/pipeline/rx-pipeline.js.map +1 -1
  160. package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js +4 -2
  161. package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -1
  162. package/dist/esm/plugins/replication/index.js +40 -2
  163. package/dist/esm/plugins/replication/index.js.map +1 -1
  164. package/dist/esm/plugins/replication-google-drive/document-handling.js +17 -6
  165. package/dist/esm/plugins/replication-google-drive/document-handling.js.map +1 -1
  166. package/dist/esm/plugins/replication-google-drive/google-drive-helper.js +1 -1
  167. package/dist/esm/plugins/replication-google-drive/google-drive-helper.js.map +1 -1
  168. package/dist/esm/plugins/replication-google-drive/google-drive-types.js.map +1 -1
  169. package/dist/esm/plugins/replication-google-drive/signaling.js +4 -1
  170. package/dist/esm/plugins/replication-google-drive/signaling.js.map +1 -1
  171. package/dist/esm/plugins/replication-google-drive/upstream.js +7 -4
  172. package/dist/esm/plugins/replication-google-drive/upstream.js.map +1 -1
  173. package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js +4 -1
  174. package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js.map +1 -1
  175. package/dist/esm/plugins/state/rx-state.js +15 -4
  176. package/dist/esm/plugins/state/rx-state.js.map +1 -1
  177. package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js +11 -18
  178. package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
  179. package/dist/esm/plugins/storage-memory/binary-search-bounds.js +107 -40
  180. package/dist/esm/plugins/storage-memory/binary-search-bounds.js.map +1 -1
  181. package/dist/esm/plugins/storage-memory/memory-helper.js +128 -41
  182. package/dist/esm/plugins/storage-memory/memory-helper.js.map +1 -1
  183. package/dist/esm/plugins/storage-memory/memory-indexes.js +1 -0
  184. package/dist/esm/plugins/storage-memory/memory-indexes.js.map +1 -1
  185. package/dist/esm/plugins/storage-memory/memory-types.js.map +1 -1
  186. package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js +90 -30
  187. package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -1
  188. package/dist/esm/plugins/storage-mongodb/mongodb-helper.js +39 -0
  189. package/dist/esm/plugins/storage-mongodb/mongodb-helper.js.map +1 -1
  190. package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js +8 -8
  191. package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -1
  192. package/dist/esm/plugins/test-utils/config.js +1 -1
  193. package/dist/esm/plugins/test-utils/config.js.map +1 -1
  194. package/dist/esm/plugins/test-utils/performance.js +122 -92
  195. package/dist/esm/plugins/test-utils/performance.js.map +1 -1
  196. package/dist/esm/plugins/test-utils/schema-objects.js +1 -1
  197. package/dist/esm/plugins/test-utils/schema-objects.js.map +1 -1
  198. package/dist/esm/plugins/test-utils/test-util.js +59 -0
  199. package/dist/esm/plugins/test-utils/test-util.js.map +1 -1
  200. package/dist/esm/plugins/utils/utils-map.js +2 -2
  201. package/dist/esm/plugins/utils/utils-map.js.map +1 -1
  202. package/dist/esm/plugins/utils/utils-object-deep-equal.js +3 -2
  203. package/dist/esm/plugins/utils/utils-object-deep-equal.js.map +1 -1
  204. package/dist/esm/plugins/utils/utils-object-dot-prop.js +25 -0
  205. package/dist/esm/plugins/utils/utils-object-dot-prop.js.map +1 -1
  206. package/dist/esm/plugins/utils/utils-object.js +102 -27
  207. package/dist/esm/plugins/utils/utils-object.js.map +1 -1
  208. package/dist/esm/plugins/utils/utils-other.js +9 -4
  209. package/dist/esm/plugins/utils/utils-other.js.map +1 -1
  210. package/dist/esm/plugins/utils/utils-premium.js +1 -19
  211. package/dist/esm/plugins/utils/utils-premium.js.map +1 -1
  212. package/dist/esm/plugins/utils/utils-revision.js +20 -10
  213. package/dist/esm/plugins/utils/utils-revision.js.map +1 -1
  214. package/dist/esm/plugins/utils/utils-rxdb-version.js +1 -1
  215. package/dist/esm/plugins/utils/utils-rxdb-version.js.map +1 -1
  216. package/dist/esm/plugins/utils/utils-string.js +11 -8
  217. package/dist/esm/plugins/utils/utils-string.js.map +1 -1
  218. package/dist/esm/plugins/utils/utils-time.js +21 -16
  219. package/dist/esm/plugins/utils/utils-time.js.map +1 -1
  220. package/dist/esm/query-cache.js +7 -5
  221. package/dist/esm/query-cache.js.map +1 -1
  222. package/dist/esm/query-planner.js +2 -2
  223. package/dist/esm/query-planner.js.map +1 -1
  224. package/dist/esm/replication-protocol/downstream.js +1 -1
  225. package/dist/esm/replication-protocol/downstream.js.map +1 -1
  226. package/dist/esm/rx-collection-helper.js +12 -7
  227. package/dist/esm/rx-collection-helper.js.map +1 -1
  228. package/dist/esm/rx-collection.js +35 -7
  229. package/dist/esm/rx-collection.js.map +1 -1
  230. package/dist/esm/rx-database.js +40 -7
  231. package/dist/esm/rx-database.js.map +1 -1
  232. package/dist/esm/rx-document.js +11 -4
  233. package/dist/esm/rx-document.js.map +1 -1
  234. package/dist/esm/rx-query-helper.js +35 -12
  235. package/dist/esm/rx-query-helper.js.map +1 -1
  236. package/dist/esm/rx-query-single-result.js +10 -3
  237. package/dist/esm/rx-query-single-result.js.map +1 -1
  238. package/dist/esm/rx-query.js +72 -29
  239. package/dist/esm/rx-query.js.map +1 -1
  240. package/dist/esm/rx-schema-helper.js +9 -3
  241. package/dist/esm/rx-schema-helper.js.map +1 -1
  242. package/dist/esm/rx-schema.js +1 -0
  243. package/dist/esm/rx-schema.js.map +1 -1
  244. package/dist/esm/rx-storage-helper.js +176 -94
  245. package/dist/esm/rx-storage-helper.js.map +1 -1
  246. package/dist/esm/types/rx-error.d.js.map +1 -1
  247. package/dist/esm/types/rx-schema.d.js.map +1 -1
  248. package/dist/types/custom-index.d.ts +5 -0
  249. package/dist/types/doc-cache.d.ts +1 -1
  250. package/dist/types/index.d.ts +25 -26
  251. package/dist/types/plugins/dev-mode/error-messages.d.ts +36 -0
  252. package/dist/types/plugins/leader-election/index.d.ts +1 -0
  253. package/dist/types/plugins/replication-google-drive/document-handling.d.ts +4 -1
  254. package/dist/types/plugins/replication-google-drive/google-drive-types.d.ts +1 -0
  255. package/dist/types/plugins/state/rx-state.d.ts +1 -1
  256. package/dist/types/plugins/storage-denokv/index.d.ts +1 -1
  257. package/dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts +1 -1
  258. package/dist/types/plugins/storage-localstorage/index.d.ts +1 -1
  259. package/dist/types/plugins/storage-memory/binary-search-bounds.d.ts +21 -10
  260. package/dist/types/plugins/storage-memory/memory-helper.d.ts +7 -3
  261. package/dist/types/plugins/storage-memory/memory-types.d.ts +5 -0
  262. package/dist/types/plugins/storage-mongodb/mongodb-helper.d.ts +9 -1
  263. package/dist/types/plugins/storage-mongodb/rx-storage-instance-mongodb.d.ts +2 -2
  264. package/dist/types/plugins/storage-mongodb/rx-storage-mongodb.d.ts +1 -1
  265. package/dist/types/plugins/storage-remote/rx-storage-remote.d.ts +1 -1
  266. package/dist/types/plugins/storage-sqlite/index.d.ts +1 -1
  267. package/dist/types/plugins/test-utils/performance.d.ts +36 -0
  268. package/dist/types/plugins/test-utils/test-util.d.ts +17 -0
  269. package/dist/types/plugins/utils/utils-object.d.ts +8 -3
  270. package/dist/types/plugins/utils/utils-premium.d.ts +0 -2
  271. package/dist/types/plugins/utils/utils-rxdb-version.d.ts +1 -1
  272. package/dist/types/rx-database.d.ts +1 -1
  273. package/dist/types/rx-query-single-result.d.ts +1 -1
  274. package/dist/types/rx-query.d.ts +3 -2
  275. package/dist/types/rx-storage-helper.d.ts +15 -0
  276. package/eslint.config.mjs +2 -1
  277. package/package.json +732 -729
  278. package/scripts/check-code-block-line-length.js +91 -0
  279. package/scripts/check-em-dashes.js +53 -0
  280. package/scripts/docs-fetch-git-history.mjs +36 -0
  281. package/scripts/install-foundationdb.sh +0 -6
  282. package/scripts/notify-indexnow.mjs +171 -0
  283. package/scripts/start-foundationdb-docker.sh +73 -0
  284. package/src/change-event-buffer.ts +4 -1
  285. package/src/custom-index.ts +93 -16
  286. package/src/doc-cache.ts +117 -41
  287. package/src/event-reduce.ts +10 -1
  288. package/src/plugin-helpers.ts +10 -0
  289. package/src/plugins/attachments/index.ts +10 -12
  290. package/src/plugins/cleanup/cleanup.ts +5 -3
  291. package/src/plugins/crdt/index.ts +55 -0
  292. package/src/plugins/dev-mode/check-query.ts +7 -1
  293. package/src/plugins/dev-mode/check-schema.ts +2 -1
  294. package/src/plugins/dev-mode/error-messages.ts +45 -5
  295. package/src/plugins/encryption-crypto-js/index.ts +18 -6
  296. package/src/plugins/leader-election/index.ts +9 -8
  297. package/src/plugins/local-documents/local-documents.ts +21 -12
  298. package/src/plugins/migration-schema/migration-helpers.ts +3 -0
  299. package/src/plugins/migration-schema/rx-migration-state.ts +1 -1
  300. package/src/plugins/pipeline/rx-pipeline.ts +5 -1
  301. package/src/plugins/query-builder/mquery/nosql-query-builder.ts +8 -2
  302. package/src/plugins/replication/index.ts +41 -3
  303. package/src/plugins/replication-google-drive/document-handling.ts +17 -5
  304. package/src/plugins/replication-google-drive/google-drive-helper.ts +1 -1
  305. package/src/plugins/replication-google-drive/google-drive-types.ts +1 -0
  306. package/src/plugins/replication-google-drive/signaling.ts +4 -1
  307. package/src/plugins/replication-google-drive/upstream.ts +7 -4
  308. package/src/plugins/replication-microsoft-onedrive/signaling.ts +4 -1
  309. package/src/plugins/state/rx-state.ts +17 -5
  310. package/src/plugins/storage-dexie/rx-storage-instance-dexie.ts +0 -27
  311. package/src/plugins/storage-memory/binary-search-bounds.ts +105 -40
  312. package/src/plugins/storage-memory/memory-helper.ts +158 -67
  313. package/src/plugins/storage-memory/memory-indexes.ts +1 -0
  314. package/src/plugins/storage-memory/memory-types.ts +5 -0
  315. package/src/plugins/storage-memory/rx-storage-instance-memory.ts +104 -53
  316. package/src/plugins/storage-mongodb/mongodb-helper.ts +43 -1
  317. package/src/plugins/storage-mongodb/rx-storage-instance-mongodb.ts +11 -9
  318. package/src/plugins/test-utils/config.ts +2 -1
  319. package/src/plugins/test-utils/performance.ts +159 -85
  320. package/src/plugins/test-utils/schema-objects.ts +1 -1
  321. package/src/plugins/test-utils/test-util.ts +71 -0
  322. package/src/plugins/utils/utils-map.ts +2 -2
  323. package/src/plugins/utils/utils-object-deep-equal.ts +2 -4
  324. package/src/plugins/utils/utils-object-dot-prop.ts +25 -0
  325. package/src/plugins/utils/utils-object.ts +103 -28
  326. package/src/plugins/utils/utils-other.ts +9 -4
  327. package/src/plugins/utils/utils-premium.ts +11 -37
  328. package/src/plugins/utils/utils-revision.ts +20 -9
  329. package/src/plugins/utils/utils-rxdb-version.ts +1 -1
  330. package/src/plugins/utils/utils-string.ts +11 -9
  331. package/src/plugins/utils/utils-time.ts +21 -17
  332. package/src/query-cache.ts +6 -5
  333. package/src/query-planner.ts +2 -2
  334. package/src/replication-protocol/downstream.ts +1 -1
  335. package/src/rx-collection-helper.ts +12 -6
  336. package/src/rx-collection.ts +39 -8
  337. package/src/rx-database.ts +49 -17
  338. package/src/rx-document.ts +12 -3
  339. package/src/rx-query-helper.ts +36 -15
  340. package/src/rx-query-single-result.ts +10 -3
  341. package/src/rx-query.ts +48 -8
  342. package/src/rx-schema-helper.ts +7 -4
  343. package/src/rx-schema.ts +1 -0
  344. package/src/rx-storage-helper.ts +210 -139
  345. package/src/types/rx-error.d.ts +3 -0
  346. package/src/types/rx-schema.d.ts +5 -0
  347. package/dist/esm/package.json +0 -1
  348. package/dist/types/types/conflict-handling.d.ts +0 -48
  349. package/dist/types/types/couchdb.d.ts +0 -293
  350. package/dist/types/types/index.d.ts +0 -32
  351. package/dist/types/types/modules/index.d.ts +0 -0
  352. package/dist/types/types/modules/mocha.parallel.d.ts +0 -1
  353. package/dist/types/types/plugins/backup.d.ts +0 -35
  354. package/dist/types/types/plugins/cleanup.d.ts +0 -38
  355. package/dist/types/types/plugins/crdt.d.ts +0 -76
  356. package/dist/types/types/plugins/dexie.d.ts +0 -30
  357. package/dist/types/types/plugins/local-documents.d.ts +0 -49
  358. package/dist/types/types/plugins/migration.d.ts +0 -14
  359. package/dist/types/types/plugins/reactivity.d.ts +0 -40
  360. package/dist/types/types/plugins/replication-graphql.d.ts +0 -98
  361. package/dist/types/types/plugins/replication.d.ts +0 -175
  362. package/dist/types/types/plugins/state.d.ts +0 -4
  363. package/dist/types/types/plugins/update.d.ts +0 -23
  364. package/dist/types/types/plugins/webmcp.d.ts +0 -40
  365. package/dist/types/types/query-planner.d.ts +0 -47
  366. package/dist/types/types/replication-protocol.d.ts +0 -296
  367. package/dist/types/types/rx-attachment.d.ts +0 -46
  368. package/dist/types/types/rx-change-event.d.ts +0 -85
  369. package/dist/types/types/rx-collection.d.ts +0 -117
  370. package/dist/types/types/rx-database-internal-store.d.ts +0 -54
  371. package/dist/types/types/rx-database.d.ts +0 -124
  372. package/dist/types/types/rx-document.d.ts +0 -160
  373. package/dist/types/types/rx-error.d.ts +0 -222
  374. package/dist/types/types/rx-plugin.d.ts +0 -167
  375. package/dist/types/types/rx-query.d.ts +0 -144
  376. package/dist/types/types/rx-schema.d.ts +0 -209
  377. package/dist/types/types/rx-storage.d.ts +0 -347
  378. package/dist/types/types/rx-storage.interface.d.ts +0 -312
  379. package/dist/types/types/util.d.ts +0 -180
@@ -1,222 +0,0 @@
1
- import type { RxJsonSchema } from './rx-schema.d.ts';
2
- import {
3
- RxSchema
4
- } from '../rx-schema.ts';
5
- import type { RxPlugin } from './rx-plugin.d.ts';
6
- import { ERROR_MESSAGES } from '../plugins/dev-mode/error-messages.ts';
7
- import type { RxReplicationWriteToMasterRow } from './replication-protocol.d.ts';
8
- import type { BulkWriteRow, RxDocumentData } from './rx-storage.d.ts';
9
-
10
- type KeyOf<T extends object> = Extract<keyof T, string>;
11
- export type RxErrorKey = KeyOf<typeof ERROR_MESSAGES>;
12
-
13
- export type {
14
- RxError,
15
- RxTypeError
16
- } from '../rx-error.ts';
17
-
18
- /**
19
- * this lists all possible parameters
20
- */
21
- export interface RxErrorParameters {
22
- readonly error?: PlainJsonError;
23
- readonly errors?: PlainJsonError[];
24
- readonly errorText?: string;
25
- readonly writeError?: RxStorageWriteError<any>;
26
- readonly schemaPath?: string;
27
- readonly objPath?: string;
28
- readonly rootPath?: string;
29
- readonly childpath?: string;
30
- readonly ids?: string[];
31
- readonly obj?: any;
32
- readonly document?: any;
33
- readonly schema?: Readonly<RxJsonSchema<any> | RxSchema>;
34
- readonly schemaObj?: any;
35
- readonly pluginKey?: string;
36
- readonly originalDoc?: Readonly<any>;
37
- readonly finalDoc?: Readonly<any>;
38
- readonly regex?: string;
39
- readonly fieldName?: string;
40
- readonly id?: string;
41
- readonly documentId?: string;
42
- readonly data?: any;
43
- readonly missingCollections?: string[];
44
- readonly primaryPath?: string;
45
- readonly primary?: string;
46
- readonly primaryKey?: string;
47
- readonly have?: any;
48
- readonly should?: any;
49
- readonly name?: string;
50
- readonly adapter?: any;
51
- readonly link?: string;
52
- readonly path?: string;
53
- readonly value?: any;
54
- readonly givenName?: string;
55
- readonly fromVersion?: number;
56
- readonly toVersion?: number;
57
- readonly version?: number;
58
- readonly args?: any;
59
- readonly opts?: any;
60
- readonly dataBefore?: any;
61
- readonly dataAfter?: any;
62
- readonly pull?: boolean;
63
- readonly push?: boolean;
64
- readonly url?: string;
65
- readonly key?: string;
66
- readonly queryObj?: any;
67
- readonly query?: any;
68
- readonly op?: string;
69
- readonly skip?: any;
70
- readonly limit?: any;
71
- readonly passwordHash?: string;
72
- readonly existingPasswordHash?: string;
73
- readonly password?: string | any;
74
- readonly minPassLength?: number;
75
- readonly own?: any;
76
- readonly source?: any;
77
- readonly method?: any;
78
- readonly field?: string;
79
- readonly ref?: string;
80
- readonly funName?: string;
81
- readonly functionName?: string;
82
- readonly schemaHash?: string;
83
- readonly previousSchema?: Readonly<RxJsonSchema<any>>;
84
- readonly previousSchemaHash?: string;
85
- readonly type?: string;
86
- readonly when?: string;
87
- readonly parallel?: boolean;
88
- readonly collection?: any;
89
- readonly database?: any;
90
- readonly storage?: string;
91
- readonly indexes?: Array<string | string[]> | Readonly<Array<string | string[]>>;
92
- readonly index?: string | string[] | readonly string[];
93
- readonly plugin?: RxPlugin | any;
94
- readonly plugins?: Set<RxPlugin | any>;
95
-
96
- // used in the replication plugin
97
-
98
- /**
99
- * The checkpoint of the response from the last successful
100
- * pull by the client.
101
- * Null if there was no pull operation before
102
- * so that there is no last pulled checkpoint.
103
- */
104
- readonly checkpoint?: any;
105
- /**
106
- * The documents that failed to be pushed.
107
- * Typed as 'any' because they might be modified by the push modifier.
108
- */
109
- readonly pushRows?: RxReplicationWriteToMasterRow<any>[];
110
- readonly direction?: 'pull' | 'push';
111
-
112
- // google-drive-replication
113
- readonly folderPath?: string;
114
- readonly folderName?: string;
115
- readonly file?: any;
116
- readonly parentId?: string;
117
-
118
- // fetch
119
- readonly body?: any;
120
- readonly status?: number;
121
- readonly statusText?: string;
122
- readonly headers?: Record<string, any>;
123
- readonly code?: string;
124
- }
125
-
126
- /**
127
- * Error-Items which are created by the jsonschema-validator
128
- */
129
- export type RxValidationError = {
130
- readonly field: string;
131
- readonly message: string;
132
- };
133
-
134
- /**
135
- * Use to have a transferable error object
136
- * in plain json instead of a JavaScript Error instance.
137
- */
138
- export type PlainJsonError = {
139
- name: string;
140
- message: string;
141
- rxdb?: true;
142
- code?: RxErrorKey;
143
- url?: string;
144
- extensions?: Record<string, any>;
145
- parameters?: RxErrorParameters;
146
- stack?: string;
147
- };
148
-
149
-
150
-
151
-
152
-
153
- /**
154
- * Error that can happen per document when
155
- * RxStorage.bulkWrite() is called
156
- */
157
- export type RxStorageWriteErrorBase<RxDocType> = {
158
- status: number
159
- | 409 // conflict
160
- | 422 // schema validation error
161
- | 510 // attachment data missing
162
- ;
163
-
164
- /**
165
- * set this property to make it easy
166
- * to detect if the object is a RxStorageBulkWriteError
167
- */
168
- isError: true;
169
-
170
- // primary key of the document
171
- documentId: string;
172
-
173
- // the original document data that should have been written.
174
- writeRow: BulkWriteRow<RxDocType>;
175
-
176
- /**
177
- * The context which was given to bulkWrite(),
178
- * used for debugging.
179
- */
180
- context: string;
181
- };
182
-
183
- export type RxStorageWriteErrorConflict<RxDocType> = RxStorageWriteErrorBase<RxDocType> & {
184
- status: 409;
185
- /**
186
- * A conflict error state must contain the
187
- * document state in the database.
188
- * This ensures that we can continue resolving a conflict
189
- * without having to pull the document out of the db first.
190
- * Is not set if the error happens on an insert.
191
- */
192
- documentInDb: RxDocumentData<RxDocType>;
193
- };
194
-
195
- export type RxStorageWriteErrorValidation<RxDocType> = RxStorageWriteErrorBase<RxDocType> & {
196
- status: 422;
197
- /**
198
- * Other properties that give
199
- * information about the error,
200
- * for example a schema validation error
201
- * might contain the exact error from the validator here.
202
- * Must be plain JSON!
203
- */
204
- validationErrors: RxValidationError[];
205
- /**
206
- * For easier debugging,
207
- * we directly put the schema into the error.
208
- */
209
- schema: RxJsonSchema<RxDocumentData<RxDocType>>;
210
- };
211
-
212
- export type RxStorageWriteErrorAttachment<RxDocType> = RxStorageWriteErrorBase<RxDocType> & {
213
- status: 510;
214
- attachmentId: string;
215
- documentInDb?: RxDocumentData<RxDocType>;
216
- };
217
-
218
-
219
- export type RxStorageWriteError<RxDocType> =
220
- RxStorageWriteErrorConflict<RxDocType> |
221
- RxStorageWriteErrorValidation<RxDocType> |
222
- RxStorageWriteErrorAttachment<RxDocType>;
@@ -1,167 +0,0 @@
1
- import type {
2
- RxQuery,
3
- RxQueryOP,
4
- MangoQuery
5
- } from './rx-query.d.ts';
6
- import type {
7
- RxCollection,
8
- RxCollectionCreator
9
- } from './rx-collection.d.ts';
10
- import type {
11
- RxStorageInstanceCreationParams
12
- } from './rx-storage.d.ts';
13
- import type {
14
- DeepReadonly,
15
- FilledMangoQuery,
16
- RxDatabase,
17
- RxDatabaseCreator,
18
- RxDocument,
19
- RxStorage,
20
- RxReplicationWriteToMasterRow,
21
- WithDeleted,
22
- RxState,
23
- BulkWriteRow,
24
- RxStorageInstance
25
- } from './index.d.ts';
26
- import type { RxSchema } from '../rx-schema.d.ts';
27
-
28
- export type RxPluginPrePrepareRxQueryArgs = {
29
- op: RxQueryOP;
30
- queryObj: MangoQuery | string | number | Array<any>;
31
- collection: RxCollection;
32
- };
33
-
34
- export type RxPluginPreCreateRxQueryArgs = {
35
- op: RxQueryOP;
36
- queryObj: MangoQuery;
37
- collection: RxCollection;
38
- };
39
-
40
- export type RxPluginPreAddRxPluginArgs = {
41
- // the plugin that is getting added
42
- plugin: RxPlugin | any;
43
- // previous added plugins
44
- plugins: Set<RxPlugin | any>;
45
- };
46
-
47
- export type RxPluginPrePrepareQueryArgs = {
48
- rxQuery: RxQuery<any>;
49
- mangoQuery: FilledMangoQuery<any>;
50
- };
51
-
52
-
53
- /**
54
- * Depending on which plugins are used together,
55
- * it is important that the plugin is able to define if
56
- * the hooks must be added as first or as last array item.
57
- * For example the encryption plugin must run encryption
58
- * before the key-compression changes the fieldnames.
59
- */
60
- export type RxPluginHooks<Input> = {
61
- /**
62
- * Hook function that is added as first.
63
- */
64
- before?: (i: Input) => void;
65
- /**
66
- * Hook function that is added as last.
67
- */
68
- after?: (i: Input) => void;
69
- };
70
-
71
- export interface RxPlugin {
72
- /**
73
- * A string to uniquely identifies the plugin.
74
- * Can be used to throw when different versions of the same plugin are used.
75
- * And also other checks.
76
- * Use kebab-case.
77
- */
78
- readonly name: string;
79
-
80
- /**
81
- * set this to true so RxDB
82
- * knows that this object in a rxdb plugin
83
- */
84
- readonly rxdb: true;
85
-
86
- /**
87
- * Init function where dependent plugins could be added.
88
- * (optional)
89
- */
90
- init?(): any;
91
-
92
- prototypes?: {
93
- RxSchema?: (proto: RxSchema) => void;
94
- RxDocument?: (proto: RxDocument) => void;
95
- RxQuery?: (proto: RxQuery) => void;
96
- RxCollection?: (proto: RxCollection) => void;
97
- RxDatabase?: (proto: RxDatabase) => void;
98
- };
99
- overwritable?: {
100
- isDevMode?: () => boolean;
101
- deepFreezeWhenDevMode?: <T>(obj: T) => DeepReadonly<T>;
102
- validatePassword?: Function;
103
- checkAdapter?: Function;
104
- tunnelErrorMessage?: Function;
105
- };
106
- hooks?: {
107
- preAddRxPlugin?: RxPluginHooks<RxPluginPreAddRxPluginArgs>;
108
- preCreateRxDatabase?: RxPluginHooks<any>;
109
- createRxDatabase?: RxPluginHooks<{
110
- database: RxDatabase;
111
- creator: RxDatabaseCreator;
112
- }>;
113
- preCloseRxDatabase?: RxPluginHooks<RxDatabase>;
114
- postRemoveRxDatabase?: RxPluginHooks<{
115
- databaseName: string;
116
- storage: RxStorage<any, any>;
117
- }>;
118
- createRxCollection?: RxPluginHooks<{
119
- collection: RxCollection;
120
- creator: RxCollectionCreator;
121
- }>;
122
- createRxState?: RxPluginHooks<{
123
- collection: RxCollection;
124
- state: RxState<unknown, unknown>;
125
- }>;
126
- preCreateRxCollection?: RxPluginHooks<RxCollectionCreator<any> & {
127
- name: string;
128
- database: RxDatabase;
129
- }>;
130
- postCloseRxCollection?: RxPluginHooks<RxCollection>;
131
- postRemoveRxCollection?: RxPluginHooks<{
132
- storage: RxStorage<any, any>;
133
- databaseName: string;
134
- collectionName: string;
135
- }>;
136
- preCreateRxSchema?: RxPluginHooks<any>;
137
- createRxSchema?: RxPluginHooks<any>;
138
- prePrepareRxQuery?: RxPluginHooks<RxPluginPrePrepareRxQueryArgs>;
139
- preCreateRxQuery?: RxPluginHooks<RxPluginPreCreateRxQueryArgs>;
140
- prePrepareQuery?: RxPluginHooks<RxPluginPrePrepareQueryArgs>;
141
- createRxQuery?: RxPluginHooks<RxQuery>;
142
- createRxDocument?: RxPluginHooks<any>;
143
- postCreateRxDocument?: RxPluginHooks<any>;
144
- preCreateRxStorageInstance?: RxPluginHooks<RxStorageInstanceCreationParams<any, any>>;
145
- /**
146
- * Runs before a write to the storage instance of a RxCollection or RxDatabase.
147
- */
148
- preStorageWrite?: RxPluginHooks<{
149
- storageInstance: RxStorageInstance<any, any, any, any>;
150
- rows: BulkWriteRow<any>[];
151
- }>;
152
- preMigrateDocument?: RxPluginHooks<any>;
153
- postMigrateDocument?: RxPluginHooks<any>;
154
- postCleanup?: RxPluginHooks<{
155
- databaseName: string;
156
- collectionName: string;
157
- }>;
158
- preReplicationMasterWrite?: RxPluginHooks<{
159
- rows: RxReplicationWriteToMasterRow<any>[];
160
- collection: RxCollection;
161
- }>;
162
- preReplicationMasterWriteDocumentsHandle?: RxPluginHooks<{
163
- result: WithDeleted<any>[];
164
- collection: RxCollection;
165
- }>;
166
- };
167
- }
@@ -1,144 +0,0 @@
1
- import type {
2
- RxQueryBase
3
- } from '../rx-query.d.ts';
4
- import type { Paths, StringKeys } from './util.d.ts';
5
-
6
- /**
7
- * Typed Mango Query Selector
8
- * @link https://github.com/mongodb/node-mongodb-native/blob/26bce4a8debb65df5a42dc8599e886c9c83de10d/src/mongo_types.ts
9
- * @link https://stackoverflow.com/a/58436959/3443137
10
- */
11
-
12
-
13
- export type PropertyType<Type, Property extends string> = string extends Property
14
- ? unknown
15
- : Property extends keyof Type
16
- ? Type[Property]
17
- : Property extends `${number}`
18
- ? Type extends ReadonlyArray<infer ArrayType>
19
- ? ArrayType
20
- : unknown
21
- : Property extends `${infer Key}.${infer Rest}`
22
- ? Key extends `${number}`
23
- ? Type extends ReadonlyArray<infer ArrayType>
24
- ? PropertyType<ArrayType, Rest>
25
- : unknown
26
- : Key extends keyof Type
27
- ? Type[Key] extends Map<string, infer MapType>
28
- ? MapType
29
- : PropertyType<Type[Key], Rest>
30
- : unknown
31
- : unknown;
32
-
33
-
34
- export type MangoQueryRegexOptions = 'i' | 'g' | 'm' | 'gi' | 'ig' | 'igm' | string;
35
-
36
- /*
37
- * The MongoDB query library is huge and we do not need all the operators.
38
- * If you add an operator here, make sure that you properly add a test in
39
- * the file /test/unit/rx-storage-query-correctness.test.ts
40
- *
41
- * @link https://github.com/kofrasa/mingo#es6
42
- */
43
- export interface MangoQueryOperators<PathValueType> {
44
- $eq?: PathValueType;
45
- $gt?: PathValueType;
46
- $gte?: PathValueType;
47
- $lt?: PathValueType;
48
- $lte?: PathValueType;
49
- $ne?: PathValueType;
50
- $in?: PathValueType[];
51
- $nin?: PathValueType[];
52
- $regex?: string;
53
- $options?: MangoQueryRegexOptions;
54
- $exists?: boolean;
55
- $type?: 'null' | 'boolean' | 'number' | 'string' | 'array' | 'object';
56
- $mod?: [number, number];
57
- $not?: PathValueType;
58
- $size?: number;
59
- $elemMatch?: MangoQuerySelector<PathValueType>;
60
- }
61
-
62
- export type MangoQuerySelector<DocType> = Partial<{
63
- [Property in Paths<DocType>]: MangoQueryOperators<any> | PropertyType<DocType, Property>;
64
- }> & {
65
- $and?: MangoQuerySelector<DocType>[];
66
- $or?: MangoQuerySelector<DocType>[];
67
- $nor?: MangoQuerySelector<DocType>[];
68
- };
69
-
70
- /**
71
- * Discussion was at:
72
- * @link https://github.com/pubkey/rxdb/issues/1972
73
- */
74
- export type MangoQuerySortDirection = 'asc' | 'desc';
75
- export type MangoQuerySortPart<RxDocType = any> = {
76
- [k in StringKeys<RxDocType> | string]: MangoQuerySortDirection;
77
- };
78
-
79
- export type MangoQuerySelectorAndIndex<RxDocType = any> = {
80
- /**
81
- * Selector is optional,
82
- * if not given, the query matches all documents
83
- * that are not _deleted=true.
84
- */
85
- selector?: MangoQuerySelector<RxDocType>;
86
- /**
87
- * By default, the RxStorage implementation
88
- * decides which index to use when running the query.
89
- *
90
- * For better performance, a different index might be defined
91
- * by setting it in the query.
92
- * How this improves performance and if the defined index is used,
93
- * depends on the RxStorage implementation.
94
- */
95
- index?: string | string[];
96
- };
97
-
98
- export type MangoQueryNoLimit<RxDocType> = MangoQuerySelectorAndIndex<RxDocType> & {
99
- /**
100
- * Sorting of the results.
101
- * If no sort is set, RxDB will sort by the primary key.
102
- * Also if sort is set, RxDB will add primaryKey sorting
103
- * if the primaryKey was not in the sort parameters before.
104
- * This ensures that there is a deterministic sorting of the
105
- * results, not mather at which order the documents have been
106
- * inserted into the storage.
107
- */
108
- sort?: MangoQuerySortPart<RxDocType>[];
109
- };
110
-
111
- export type MangoQuery<RxDocType = any> = MangoQueryNoLimit<RxDocType> & {
112
- skip?: number;
113
- limit?: number;
114
- };
115
-
116
- export type RxQueryOP = 'find' | 'findOne' | 'count' | 'findByIds';
117
-
118
- export declare class RxQuery<
119
- RxDocumentType = any,
120
- RxQueryResult = any,
121
- OrmMethods = {},
122
- Reactivity = unknown
123
- > extends RxQueryBase<RxDocumentType, RxQueryResult, OrmMethods, Reactivity> {
124
- equals(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
125
- eq(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
126
- or(queryObj: keyof RxDocumentType | string | any[]): RxQuery<RxDocumentType, RxQueryResult>;
127
- nor(queryObj: keyof RxDocumentType | string | any[]): RxQuery<RxDocumentType, RxQueryResult>;
128
- and(queryObj: keyof RxDocumentType | string | any[]): RxQuery<RxDocumentType, RxQueryResult>;
129
- gt(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
130
- gte(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
131
- lt(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
132
- lte(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
133
- ne(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
134
- in(queryObj: any[]): RxQuery<RxDocumentType, RxQueryResult>;
135
- nin(queryObj: any[]): RxQuery<RxDocumentType, RxQueryResult>;
136
- all(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
137
- regex(queryObj: string | {
138
- $regex: string;
139
- $options: MangoQueryRegexOptions;
140
- }): RxQuery<RxDocumentType, RxQueryResult>;
141
- exists(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
142
- elemMatch(queryObj: any): RxQuery<RxDocumentType, RxQueryResult>;
143
- mod(p1: any, p2: any, p3: any): RxQuery<RxDocumentType, RxQueryResult>;
144
- }