@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.
- package/AGENTS.md +4 -0
- package/CHANGELOG.md +47 -4
- package/CLAUDE.md +2 -0
- package/dist/cjs/change-event-buffer.js +2 -1
- package/dist/cjs/change-event-buffer.js.map +1 -1
- package/dist/cjs/custom-index.js +85 -12
- package/dist/cjs/custom-index.js.map +1 -1
- package/dist/cjs/doc-cache.js +117 -35
- package/dist/cjs/doc-cache.js.map +1 -1
- package/dist/cjs/event-reduce.js +10 -1
- package/dist/cjs/event-reduce.js.map +1 -1
- package/dist/cjs/plugin-helpers.js +16 -0
- package/dist/cjs/plugin-helpers.js.map +1 -1
- package/dist/cjs/plugins/attachments/index.js +3 -3
- package/dist/cjs/plugins/attachments/index.js.map +1 -1
- package/dist/cjs/plugins/cleanup/cleanup.js +5 -3
- package/dist/cjs/plugins/cleanup/cleanup.js.map +1 -1
- package/dist/cjs/plugins/crdt/index.js +52 -0
- package/dist/cjs/plugins/crdt/index.js.map +1 -1
- package/dist/cjs/plugins/dev-mode/check-query.js +7 -1
- package/dist/cjs/plugins/dev-mode/check-query.js.map +1 -1
- package/dist/cjs/plugins/dev-mode/check-schema.js +2 -1
- package/dist/cjs/plugins/dev-mode/check-schema.js.map +1 -1
- package/dist/cjs/plugins/dev-mode/error-messages.js +43 -5
- package/dist/cjs/plugins/dev-mode/error-messages.js.map +1 -1
- package/dist/cjs/plugins/encryption-crypto-js/index.js +22 -6
- package/dist/cjs/plugins/encryption-crypto-js/index.js.map +1 -1
- package/dist/cjs/plugins/leader-election/index.js +5 -5
- package/dist/cjs/plugins/leader-election/index.js.map +1 -1
- package/dist/cjs/plugins/local-documents/local-documents.js +20 -13
- package/dist/cjs/plugins/local-documents/local-documents.js.map +1 -1
- package/dist/cjs/plugins/migration-schema/migration-helpers.js +3 -0
- package/dist/cjs/plugins/migration-schema/migration-helpers.js.map +1 -1
- package/dist/cjs/plugins/migration-schema/rx-migration-state.js +1 -1
- package/dist/cjs/plugins/migration-schema/rx-migration-state.js.map +1 -1
- package/dist/cjs/plugins/pipeline/rx-pipeline.js +5 -1
- package/dist/cjs/plugins/pipeline/rx-pipeline.js.map +1 -1
- package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js +4 -2
- package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -1
- package/dist/cjs/plugins/replication/index.js +40 -2
- package/dist/cjs/plugins/replication/index.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/document-handling.js +17 -6
- package/dist/cjs/plugins/replication-google-drive/document-handling.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js +1 -1
- package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/google-drive-types.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/signaling.js +4 -1
- package/dist/cjs/plugins/replication-google-drive/signaling.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/upstream.js +7 -4
- package/dist/cjs/plugins/replication-google-drive/upstream.js.map +1 -1
- package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js +4 -1
- package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js.map +1 -1
- package/dist/cjs/plugins/state/rx-state.js +14 -3
- package/dist/cjs/plugins/state/rx-state.js.map +1 -1
- package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js +10 -17
- package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/binary-search-bounds.js +112 -40
- package/dist/cjs/plugins/storage-memory/binary-search-bounds.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/memory-helper.js +127 -40
- package/dist/cjs/plugins/storage-memory/memory-helper.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/memory-indexes.js +1 -0
- package/dist/cjs/plugins/storage-memory/memory-indexes.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/memory-types.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js +97 -37
- package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -1
- package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js +42 -1
- package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js.map +1 -1
- package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js +7 -7
- package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -1
- package/dist/cjs/plugins/test-utils/config.js +1 -1
- package/dist/cjs/plugins/test-utils/config.js.map +1 -1
- package/dist/cjs/plugins/test-utils/performance.js +122 -92
- package/dist/cjs/plugins/test-utils/performance.js.map +1 -1
- package/dist/cjs/plugins/test-utils/schema-objects.js +1 -1
- package/dist/cjs/plugins/test-utils/schema-objects.js.map +1 -1
- package/dist/cjs/plugins/test-utils/test-util.js +62 -0
- package/dist/cjs/plugins/test-utils/test-util.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-map.js +2 -2
- package/dist/cjs/plugins/utils/utils-map.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-object-deep-equal.js +3 -2
- package/dist/cjs/plugins/utils/utils-object-deep-equal.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-object-dot-prop.js +25 -0
- package/dist/cjs/plugins/utils/utils-object-dot-prop.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-object.js +102 -27
- package/dist/cjs/plugins/utils/utils-object.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-other.js +9 -4
- package/dist/cjs/plugins/utils/utils-other.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-premium.js +1 -19
- package/dist/cjs/plugins/utils/utils-premium.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-revision.js +20 -10
- package/dist/cjs/plugins/utils/utils-revision.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-rxdb-version.js +1 -1
- package/dist/cjs/plugins/utils/utils-rxdb-version.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-string.js +11 -8
- package/dist/cjs/plugins/utils/utils-string.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-time.js +21 -16
- package/dist/cjs/plugins/utils/utils-time.js.map +1 -1
- package/dist/cjs/query-cache.js +6 -4
- package/dist/cjs/query-cache.js.map +1 -1
- package/dist/cjs/query-planner.js +2 -2
- package/dist/cjs/query-planner.js.map +1 -1
- package/dist/cjs/replication-protocol/downstream.js +1 -1
- package/dist/cjs/replication-protocol/downstream.js.map +1 -1
- package/dist/cjs/rx-collection-helper.js +11 -6
- package/dist/cjs/rx-collection-helper.js.map +1 -1
- package/dist/cjs/rx-collection.js +34 -6
- package/dist/cjs/rx-collection.js.map +1 -1
- package/dist/cjs/rx-database.js +40 -7
- package/dist/cjs/rx-database.js.map +1 -1
- package/dist/cjs/rx-document.js +10 -3
- package/dist/cjs/rx-document.js.map +1 -1
- package/dist/cjs/rx-query-helper.js +35 -12
- package/dist/cjs/rx-query-helper.js.map +1 -1
- package/dist/cjs/rx-query-single-result.js +9 -2
- package/dist/cjs/rx-query-single-result.js.map +1 -1
- package/dist/cjs/rx-query.js +72 -29
- package/dist/cjs/rx-query.js.map +1 -1
- package/dist/cjs/rx-schema-helper.js +9 -3
- package/dist/cjs/rx-schema-helper.js.map +1 -1
- package/dist/cjs/rx-schema.js +1 -0
- package/dist/cjs/rx-schema.js.map +1 -1
- package/dist/cjs/rx-storage-helper.js +212 -129
- package/dist/cjs/rx-storage-helper.js.map +1 -1
- package/dist/cjs/types/rx-error.d.js.map +1 -1
- package/dist/cjs/types/rx-schema.d.js.map +1 -1
- package/dist/esm/change-event-buffer.js +2 -1
- package/dist/esm/change-event-buffer.js.map +1 -1
- package/dist/esm/custom-index.js +85 -12
- package/dist/esm/custom-index.js.map +1 -1
- package/dist/esm/doc-cache.js +118 -36
- package/dist/esm/doc-cache.js.map +1 -1
- package/dist/esm/event-reduce.js +10 -1
- package/dist/esm/event-reduce.js.map +1 -1
- package/dist/esm/plugin-helpers.js +16 -0
- package/dist/esm/plugin-helpers.js.map +1 -1
- package/dist/esm/plugins/attachments/index.js +3 -3
- package/dist/esm/plugins/attachments/index.js.map +1 -1
- package/dist/esm/plugins/cleanup/cleanup.js +5 -3
- package/dist/esm/plugins/cleanup/cleanup.js.map +1 -1
- package/dist/esm/plugins/crdt/index.js +52 -0
- package/dist/esm/plugins/crdt/index.js.map +1 -1
- package/dist/esm/plugins/dev-mode/check-query.js +7 -1
- package/dist/esm/plugins/dev-mode/check-query.js.map +1 -1
- package/dist/esm/plugins/dev-mode/check-schema.js +2 -1
- package/dist/esm/plugins/dev-mode/check-schema.js.map +1 -1
- package/dist/esm/plugins/dev-mode/error-messages.js +43 -5
- package/dist/esm/plugins/dev-mode/error-messages.js.map +1 -1
- package/dist/esm/plugins/encryption-crypto-js/index.js +22 -6
- package/dist/esm/plugins/encryption-crypto-js/index.js.map +1 -1
- package/dist/esm/plugins/leader-election/index.js +4 -4
- package/dist/esm/plugins/leader-election/index.js.map +1 -1
- package/dist/esm/plugins/local-documents/local-documents.js +20 -13
- package/dist/esm/plugins/local-documents/local-documents.js.map +1 -1
- package/dist/esm/plugins/migration-schema/migration-helpers.js +3 -0
- package/dist/esm/plugins/migration-schema/migration-helpers.js.map +1 -1
- package/dist/esm/plugins/migration-schema/rx-migration-state.js +1 -1
- package/dist/esm/plugins/migration-schema/rx-migration-state.js.map +1 -1
- package/dist/esm/plugins/pipeline/rx-pipeline.js +5 -1
- package/dist/esm/plugins/pipeline/rx-pipeline.js.map +1 -1
- package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js +4 -2
- package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -1
- package/dist/esm/plugins/replication/index.js +40 -2
- package/dist/esm/plugins/replication/index.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/document-handling.js +17 -6
- package/dist/esm/plugins/replication-google-drive/document-handling.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/google-drive-helper.js +1 -1
- package/dist/esm/plugins/replication-google-drive/google-drive-helper.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/google-drive-types.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/signaling.js +4 -1
- package/dist/esm/plugins/replication-google-drive/signaling.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/upstream.js +7 -4
- package/dist/esm/plugins/replication-google-drive/upstream.js.map +1 -1
- package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js +4 -1
- package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js.map +1 -1
- package/dist/esm/plugins/state/rx-state.js +15 -4
- package/dist/esm/plugins/state/rx-state.js.map +1 -1
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js +11 -18
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
- package/dist/esm/plugins/storage-memory/binary-search-bounds.js +107 -40
- package/dist/esm/plugins/storage-memory/binary-search-bounds.js.map +1 -1
- package/dist/esm/plugins/storage-memory/memory-helper.js +128 -41
- package/dist/esm/plugins/storage-memory/memory-helper.js.map +1 -1
- package/dist/esm/plugins/storage-memory/memory-indexes.js +1 -0
- package/dist/esm/plugins/storage-memory/memory-indexes.js.map +1 -1
- package/dist/esm/plugins/storage-memory/memory-types.js.map +1 -1
- package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js +90 -30
- package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -1
- package/dist/esm/plugins/storage-mongodb/mongodb-helper.js +39 -0
- package/dist/esm/plugins/storage-mongodb/mongodb-helper.js.map +1 -1
- package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js +8 -8
- package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -1
- package/dist/esm/plugins/test-utils/config.js +1 -1
- package/dist/esm/plugins/test-utils/config.js.map +1 -1
- package/dist/esm/plugins/test-utils/performance.js +122 -92
- package/dist/esm/plugins/test-utils/performance.js.map +1 -1
- package/dist/esm/plugins/test-utils/schema-objects.js +1 -1
- package/dist/esm/plugins/test-utils/schema-objects.js.map +1 -1
- package/dist/esm/plugins/test-utils/test-util.js +59 -0
- package/dist/esm/plugins/test-utils/test-util.js.map +1 -1
- package/dist/esm/plugins/utils/utils-map.js +2 -2
- package/dist/esm/plugins/utils/utils-map.js.map +1 -1
- package/dist/esm/plugins/utils/utils-object-deep-equal.js +3 -2
- package/dist/esm/plugins/utils/utils-object-deep-equal.js.map +1 -1
- package/dist/esm/plugins/utils/utils-object-dot-prop.js +25 -0
- package/dist/esm/plugins/utils/utils-object-dot-prop.js.map +1 -1
- package/dist/esm/plugins/utils/utils-object.js +102 -27
- package/dist/esm/plugins/utils/utils-object.js.map +1 -1
- package/dist/esm/plugins/utils/utils-other.js +9 -4
- package/dist/esm/plugins/utils/utils-other.js.map +1 -1
- package/dist/esm/plugins/utils/utils-premium.js +1 -19
- package/dist/esm/plugins/utils/utils-premium.js.map +1 -1
- package/dist/esm/plugins/utils/utils-revision.js +20 -10
- package/dist/esm/plugins/utils/utils-revision.js.map +1 -1
- package/dist/esm/plugins/utils/utils-rxdb-version.js +1 -1
- package/dist/esm/plugins/utils/utils-rxdb-version.js.map +1 -1
- package/dist/esm/plugins/utils/utils-string.js +11 -8
- package/dist/esm/plugins/utils/utils-string.js.map +1 -1
- package/dist/esm/plugins/utils/utils-time.js +21 -16
- package/dist/esm/plugins/utils/utils-time.js.map +1 -1
- package/dist/esm/query-cache.js +7 -5
- package/dist/esm/query-cache.js.map +1 -1
- package/dist/esm/query-planner.js +2 -2
- package/dist/esm/query-planner.js.map +1 -1
- package/dist/esm/replication-protocol/downstream.js +1 -1
- package/dist/esm/replication-protocol/downstream.js.map +1 -1
- package/dist/esm/rx-collection-helper.js +12 -7
- package/dist/esm/rx-collection-helper.js.map +1 -1
- package/dist/esm/rx-collection.js +35 -7
- package/dist/esm/rx-collection.js.map +1 -1
- package/dist/esm/rx-database.js +40 -7
- package/dist/esm/rx-database.js.map +1 -1
- package/dist/esm/rx-document.js +11 -4
- package/dist/esm/rx-document.js.map +1 -1
- package/dist/esm/rx-query-helper.js +35 -12
- package/dist/esm/rx-query-helper.js.map +1 -1
- package/dist/esm/rx-query-single-result.js +10 -3
- package/dist/esm/rx-query-single-result.js.map +1 -1
- package/dist/esm/rx-query.js +72 -29
- package/dist/esm/rx-query.js.map +1 -1
- package/dist/esm/rx-schema-helper.js +9 -3
- package/dist/esm/rx-schema-helper.js.map +1 -1
- package/dist/esm/rx-schema.js +1 -0
- package/dist/esm/rx-schema.js.map +1 -1
- package/dist/esm/rx-storage-helper.js +176 -94
- package/dist/esm/rx-storage-helper.js.map +1 -1
- package/dist/esm/types/rx-error.d.js.map +1 -1
- package/dist/esm/types/rx-schema.d.js.map +1 -1
- package/dist/types/custom-index.d.ts +5 -0
- package/dist/types/doc-cache.d.ts +1 -1
- package/dist/types/index.d.ts +25 -26
- package/dist/types/plugins/dev-mode/error-messages.d.ts +36 -0
- package/dist/types/plugins/leader-election/index.d.ts +1 -0
- package/dist/types/plugins/replication-google-drive/document-handling.d.ts +4 -1
- package/dist/types/plugins/replication-google-drive/google-drive-types.d.ts +1 -0
- package/dist/types/plugins/state/rx-state.d.ts +1 -1
- package/dist/types/plugins/storage-denokv/index.d.ts +1 -1
- package/dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts +1 -1
- package/dist/types/plugins/storage-localstorage/index.d.ts +1 -1
- package/dist/types/plugins/storage-memory/binary-search-bounds.d.ts +21 -10
- package/dist/types/plugins/storage-memory/memory-helper.d.ts +7 -3
- package/dist/types/plugins/storage-memory/memory-types.d.ts +5 -0
- package/dist/types/plugins/storage-mongodb/mongodb-helper.d.ts +9 -1
- package/dist/types/plugins/storage-mongodb/rx-storage-instance-mongodb.d.ts +2 -2
- package/dist/types/plugins/storage-mongodb/rx-storage-mongodb.d.ts +1 -1
- package/dist/types/plugins/storage-remote/rx-storage-remote.d.ts +1 -1
- package/dist/types/plugins/storage-sqlite/index.d.ts +1 -1
- package/dist/types/plugins/test-utils/performance.d.ts +36 -0
- package/dist/types/plugins/test-utils/test-util.d.ts +17 -0
- package/dist/types/plugins/utils/utils-object.d.ts +8 -3
- package/dist/types/plugins/utils/utils-premium.d.ts +0 -2
- package/dist/types/plugins/utils/utils-rxdb-version.d.ts +1 -1
- package/dist/types/rx-database.d.ts +1 -1
- package/dist/types/rx-query-single-result.d.ts +1 -1
- package/dist/types/rx-query.d.ts +3 -2
- package/dist/types/rx-storage-helper.d.ts +15 -0
- package/eslint.config.mjs +2 -1
- package/package.json +732 -729
- package/scripts/check-code-block-line-length.js +91 -0
- package/scripts/check-em-dashes.js +53 -0
- package/scripts/docs-fetch-git-history.mjs +36 -0
- package/scripts/install-foundationdb.sh +0 -6
- package/scripts/notify-indexnow.mjs +171 -0
- package/scripts/start-foundationdb-docker.sh +73 -0
- package/src/change-event-buffer.ts +4 -1
- package/src/custom-index.ts +93 -16
- package/src/doc-cache.ts +117 -41
- package/src/event-reduce.ts +10 -1
- package/src/plugin-helpers.ts +10 -0
- package/src/plugins/attachments/index.ts +10 -12
- package/src/plugins/cleanup/cleanup.ts +5 -3
- package/src/plugins/crdt/index.ts +55 -0
- package/src/plugins/dev-mode/check-query.ts +7 -1
- package/src/plugins/dev-mode/check-schema.ts +2 -1
- package/src/plugins/dev-mode/error-messages.ts +45 -5
- package/src/plugins/encryption-crypto-js/index.ts +18 -6
- package/src/plugins/leader-election/index.ts +9 -8
- package/src/plugins/local-documents/local-documents.ts +21 -12
- package/src/plugins/migration-schema/migration-helpers.ts +3 -0
- package/src/plugins/migration-schema/rx-migration-state.ts +1 -1
- package/src/plugins/pipeline/rx-pipeline.ts +5 -1
- package/src/plugins/query-builder/mquery/nosql-query-builder.ts +8 -2
- package/src/plugins/replication/index.ts +41 -3
- package/src/plugins/replication-google-drive/document-handling.ts +17 -5
- package/src/plugins/replication-google-drive/google-drive-helper.ts +1 -1
- package/src/plugins/replication-google-drive/google-drive-types.ts +1 -0
- package/src/plugins/replication-google-drive/signaling.ts +4 -1
- package/src/plugins/replication-google-drive/upstream.ts +7 -4
- package/src/plugins/replication-microsoft-onedrive/signaling.ts +4 -1
- package/src/plugins/state/rx-state.ts +17 -5
- package/src/plugins/storage-dexie/rx-storage-instance-dexie.ts +0 -27
- package/src/plugins/storage-memory/binary-search-bounds.ts +105 -40
- package/src/plugins/storage-memory/memory-helper.ts +158 -67
- package/src/plugins/storage-memory/memory-indexes.ts +1 -0
- package/src/plugins/storage-memory/memory-types.ts +5 -0
- package/src/plugins/storage-memory/rx-storage-instance-memory.ts +104 -53
- package/src/plugins/storage-mongodb/mongodb-helper.ts +43 -1
- package/src/plugins/storage-mongodb/rx-storage-instance-mongodb.ts +11 -9
- package/src/plugins/test-utils/config.ts +2 -1
- package/src/plugins/test-utils/performance.ts +159 -85
- package/src/plugins/test-utils/schema-objects.ts +1 -1
- package/src/plugins/test-utils/test-util.ts +71 -0
- package/src/plugins/utils/utils-map.ts +2 -2
- package/src/plugins/utils/utils-object-deep-equal.ts +2 -4
- package/src/plugins/utils/utils-object-dot-prop.ts +25 -0
- package/src/plugins/utils/utils-object.ts +103 -28
- package/src/plugins/utils/utils-other.ts +9 -4
- package/src/plugins/utils/utils-premium.ts +11 -37
- package/src/plugins/utils/utils-revision.ts +20 -9
- package/src/plugins/utils/utils-rxdb-version.ts +1 -1
- package/src/plugins/utils/utils-string.ts +11 -9
- package/src/plugins/utils/utils-time.ts +21 -17
- package/src/query-cache.ts +6 -5
- package/src/query-planner.ts +2 -2
- package/src/replication-protocol/downstream.ts +1 -1
- package/src/rx-collection-helper.ts +12 -6
- package/src/rx-collection.ts +39 -8
- package/src/rx-database.ts +49 -17
- package/src/rx-document.ts +12 -3
- package/src/rx-query-helper.ts +36 -15
- package/src/rx-query-single-result.ts +10 -3
- package/src/rx-query.ts +48 -8
- package/src/rx-schema-helper.ts +7 -4
- package/src/rx-schema.ts +1 -0
- package/src/rx-storage-helper.ts +210 -139
- package/src/types/rx-error.d.ts +3 -0
- package/src/types/rx-schema.d.ts +5 -0
- package/dist/esm/package.json +0 -1
- package/dist/types/types/conflict-handling.d.ts +0 -48
- package/dist/types/types/couchdb.d.ts +0 -293
- package/dist/types/types/index.d.ts +0 -32
- package/dist/types/types/modules/index.d.ts +0 -0
- package/dist/types/types/modules/mocha.parallel.d.ts +0 -1
- package/dist/types/types/plugins/backup.d.ts +0 -35
- package/dist/types/types/plugins/cleanup.d.ts +0 -38
- package/dist/types/types/plugins/crdt.d.ts +0 -76
- package/dist/types/types/plugins/dexie.d.ts +0 -30
- package/dist/types/types/plugins/local-documents.d.ts +0 -49
- package/dist/types/types/plugins/migration.d.ts +0 -14
- package/dist/types/types/plugins/reactivity.d.ts +0 -40
- package/dist/types/types/plugins/replication-graphql.d.ts +0 -98
- package/dist/types/types/plugins/replication.d.ts +0 -175
- package/dist/types/types/plugins/state.d.ts +0 -4
- package/dist/types/types/plugins/update.d.ts +0 -23
- package/dist/types/types/plugins/webmcp.d.ts +0 -40
- package/dist/types/types/query-planner.d.ts +0 -47
- package/dist/types/types/replication-protocol.d.ts +0 -296
- package/dist/types/types/rx-attachment.d.ts +0 -46
- package/dist/types/types/rx-change-event.d.ts +0 -85
- package/dist/types/types/rx-collection.d.ts +0 -117
- package/dist/types/types/rx-database-internal-store.d.ts +0 -54
- package/dist/types/types/rx-database.d.ts +0 -124
- package/dist/types/types/rx-document.d.ts +0 -160
- package/dist/types/types/rx-error.d.ts +0 -222
- package/dist/types/types/rx-plugin.d.ts +0 -167
- package/dist/types/types/rx-query.d.ts +0 -144
- package/dist/types/types/rx-schema.d.ts +0 -209
- package/dist/types/types/rx-storage.d.ts +0 -347
- package/dist/types/types/rx-storage.interface.d.ts +0 -312
- package/dist/types/types/util.d.ts +0 -180
package/src/rx-database.ts
CHANGED
|
@@ -562,7 +562,7 @@ export class RxDatabaseBase<
|
|
|
562
562
|
return this.closePromise;
|
|
563
563
|
}
|
|
564
564
|
|
|
565
|
-
const { promise, resolve } = createPromiseWithResolvers<boolean>();
|
|
565
|
+
const { promise, resolve, reject } = createPromiseWithResolvers<boolean>();
|
|
566
566
|
const resolveClosePromise = (result: boolean) => {
|
|
567
567
|
if (this.onClosed) {
|
|
568
568
|
this.onClosed();
|
|
@@ -598,18 +598,42 @@ export class RxDatabaseBase<
|
|
|
598
598
|
/**
|
|
599
599
|
* First wait until the database is idle
|
|
600
600
|
*/
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
601
|
+
await this.requestIdlePromise();
|
|
602
|
+
|
|
603
|
+
let closingError: Error | null = null;
|
|
604
|
+
try {
|
|
605
|
+
await Promise.all(this.onClose.map(fn => fn()));
|
|
606
|
+
} catch (err: unknown) {
|
|
607
|
+
closingError = err as Error;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// close all collections
|
|
611
|
+
await Promise.all(
|
|
612
|
+
Object.keys(this.collections as any)
|
|
613
|
+
.map(key => (this.collections as any)[key])
|
|
614
|
+
.map(col => col.close())
|
|
615
|
+
);
|
|
616
|
+
|
|
617
|
+
// close internal storage instances
|
|
618
|
+
await this.internalStore.close();
|
|
619
|
+
|
|
620
|
+
if (closingError) {
|
|
621
|
+
throw closingError;
|
|
622
|
+
}
|
|
623
|
+
resolveClosePromise(true);
|
|
624
|
+
})().catch((err) => {
|
|
625
|
+
/**
|
|
626
|
+
* If an error occurs during closing,
|
|
627
|
+
* we still have to mark the database as closed
|
|
628
|
+
* and clean up the instance tracking so that
|
|
629
|
+
* a new database with the same name can be created.
|
|
630
|
+
*/
|
|
631
|
+
if (this.onClosed) {
|
|
632
|
+
this.onClosed();
|
|
633
|
+
}
|
|
634
|
+
this.closed = true;
|
|
635
|
+
reject(err);
|
|
636
|
+
});
|
|
613
637
|
|
|
614
638
|
return promise;
|
|
615
639
|
}
|
|
@@ -618,10 +642,18 @@ export class RxDatabaseBase<
|
|
|
618
642
|
* deletes the database and its stored data.
|
|
619
643
|
* Returns the names of all removed collections.
|
|
620
644
|
*/
|
|
621
|
-
remove(): Promise<string[]> {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
645
|
+
async remove(): Promise<string[]> {
|
|
646
|
+
/**
|
|
647
|
+
* Collect all collection onRemove handlers before closing,
|
|
648
|
+
* because close() will clear the collections and unsubscribe
|
|
649
|
+
* all listeners, making it impossible to trigger onRemove afterwards.
|
|
650
|
+
*/
|
|
651
|
+
const collections = Object.values(this.collections as any) as RxCollection[];
|
|
652
|
+
await this.close();
|
|
653
|
+
await Promise.all(
|
|
654
|
+
collections.map(col => Promise.all(col.onRemove.map(fn => fn())))
|
|
655
|
+
);
|
|
656
|
+
return removeRxDatabase(this.name, this.storage, this.multiInstance, this.password);
|
|
625
657
|
}
|
|
626
658
|
|
|
627
659
|
get asRxDatabase(): RxDatabase<
|
package/src/rx-document.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
trimDots,
|
|
14
14
|
pluginMissing,
|
|
15
15
|
flatClone,
|
|
16
|
+
deepEqual,
|
|
16
17
|
PROMISE_RESOLVE_NULL,
|
|
17
18
|
RXJS_SHARE_REPLAY_DEFAULTS,
|
|
18
19
|
getProperty,
|
|
@@ -69,7 +70,8 @@ export const basePrototype = {
|
|
|
69
70
|
return undefined;
|
|
70
71
|
}
|
|
71
72
|
return _this.$.pipe(
|
|
72
|
-
map((d: any) => d._data._deleted)
|
|
73
|
+
map((d: any) => d._data._deleted),
|
|
74
|
+
distinctUntilChanged()
|
|
73
75
|
);
|
|
74
76
|
},
|
|
75
77
|
get deleted$$() {
|
|
@@ -159,7 +161,14 @@ export const basePrototype = {
|
|
|
159
161
|
return this.$
|
|
160
162
|
.pipe(
|
|
161
163
|
map((data: any) => getProperty(data, path)),
|
|
162
|
-
distinctUntilChanged()
|
|
164
|
+
distinctUntilChanged((prev: any, curr: any) => {
|
|
165
|
+
/**
|
|
166
|
+
* Use deepEqual for non-primitive values (objects/arrays)
|
|
167
|
+
* because the default === comparison always fails across
|
|
168
|
+
* document revisions since each revision creates new object references.
|
|
169
|
+
*/
|
|
170
|
+
return deepEqual(prev, curr);
|
|
171
|
+
})
|
|
163
172
|
);
|
|
164
173
|
},
|
|
165
174
|
get$$(this: RxDocument, path: string) {
|
|
@@ -276,7 +285,7 @@ export const basePrototype = {
|
|
|
276
285
|
_context?: string
|
|
277
286
|
): Promise<RxDocument> {
|
|
278
287
|
const oldData = this._data;
|
|
279
|
-
const newData: RxDocumentData<RxDocType> = await modifierFromPublicToInternal<RxDocType>(mutationFunction)(oldData) as any;
|
|
288
|
+
const newData: RxDocumentData<RxDocType> = await modifierFromPublicToInternal<RxDocType>(mutationFunction)(clone(oldData)) as any;
|
|
280
289
|
return this._saveData(newData, oldData) as any;
|
|
281
290
|
},
|
|
282
291
|
|
package/src/rx-query-helper.ts
CHANGED
|
@@ -64,19 +64,10 @@ export function normalizeMangoQuery<RxDocType>(
|
|
|
64
64
|
* For normalization, we have to normalize this
|
|
65
65
|
* so our checks can perform properly.
|
|
66
66
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* contain multiple selectors via $and or $or etc.
|
|
67
|
+
* This works recursively for nested queries that
|
|
68
|
+
* contain multiple selectors via $and, $or, $nor or $not.
|
|
70
69
|
*/
|
|
71
|
-
|
|
72
|
-
.entries(normalizedMangoQuery.selector)
|
|
73
|
-
.forEach(([field, matcher]) => {
|
|
74
|
-
if (typeof matcher !== 'object' || matcher === null) {
|
|
75
|
-
(normalizedMangoQuery as any).selector[field] = {
|
|
76
|
-
$eq: matcher
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
});
|
|
70
|
+
normalizeQuerySelectorShorthands(normalizedMangoQuery.selector);
|
|
80
71
|
}
|
|
81
72
|
|
|
82
73
|
/**
|
|
@@ -144,11 +135,12 @@ export function normalizeMangoQuery<RxDocType>(
|
|
|
144
135
|
schema.indexes.forEach(index => {
|
|
145
136
|
const useIndex = isMaybeReadonlyArray(index) ? index : [index];
|
|
146
137
|
const firstWrongIndex = useIndex.findIndex(indexField => !fieldsWithLogicalOperator.has(indexField));
|
|
138
|
+
const matchingFieldCount = firstWrongIndex === -1 ? useIndex.length : firstWrongIndex;
|
|
147
139
|
if (
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
matchingFieldCount > 0 &&
|
|
141
|
+
matchingFieldCount > currentFieldsAmount
|
|
150
142
|
) {
|
|
151
|
-
currentFieldsAmount =
|
|
143
|
+
currentFieldsAmount = matchingFieldCount;
|
|
152
144
|
currentBestIndexForSort = useIndex;
|
|
153
145
|
}
|
|
154
146
|
});
|
|
@@ -287,6 +279,35 @@ export async function runQueryUpdateFunction<RxDocType, RxQueryResult>(
|
|
|
287
279
|
}
|
|
288
280
|
}
|
|
289
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Normalizes selector shorthand values recursively.
|
|
284
|
+
* Converts `{field: value}` to `{field: {$eq: value}}`
|
|
285
|
+
* and recurses into $and, $or, $nor arrays and $not objects.
|
|
286
|
+
*/
|
|
287
|
+
const SELECTOR_ARRAY_OPERATORS = new Set(['$and', '$or', '$nor']);
|
|
288
|
+
function normalizeQuerySelectorShorthands(selector: any): void {
|
|
289
|
+
Object
|
|
290
|
+
.entries(selector)
|
|
291
|
+
.forEach(([field, matcher]) => {
|
|
292
|
+
if (typeof matcher !== 'object' || matcher === null) {
|
|
293
|
+
selector[field] = { $eq: matcher };
|
|
294
|
+
} else if (SELECTOR_ARRAY_OPERATORS.has(field) && Array.isArray(matcher)) {
|
|
295
|
+
(matcher as any[]).forEach(subSelector => normalizeQuerySelectorShorthands(subSelector));
|
|
296
|
+
} else if (field === '$not' && typeof matcher === 'object') {
|
|
297
|
+
normalizeQuerySelectorShorthands(matcher);
|
|
298
|
+
} else if (!field.startsWith('$') && typeof matcher === 'object') {
|
|
299
|
+
/**
|
|
300
|
+
* Recurse into field-level operator objects to normalize
|
|
301
|
+
* sub-selectors like $elemMatch which contain nested selectors.
|
|
302
|
+
*/
|
|
303
|
+
const matcherObj = matcher as any;
|
|
304
|
+
if (matcherObj.$elemMatch && typeof matcherObj.$elemMatch === 'object') {
|
|
305
|
+
normalizeQuerySelectorShorthands(matcherObj.$elemMatch);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
|
|
290
311
|
/**
|
|
291
312
|
* @returns a format of the query that can be used with the storage
|
|
292
313
|
* when calling RxStorageInstance().query()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mapDocumentsDataToCacheDocs } from './doc-cache.ts';
|
|
2
|
-
import {
|
|
2
|
+
import { overwriteGetterForCaching } from './plugins/utils/index.ts';
|
|
3
3
|
import { newRxError } from './rx-error.ts';
|
|
4
4
|
import { RxQueryBase } from './rx-query.ts';
|
|
5
5
|
import type {
|
|
@@ -7,6 +7,13 @@ import type {
|
|
|
7
7
|
RxDocumentData
|
|
8
8
|
} from './types';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Counter to create unique result IDs cheaply.
|
|
12
|
+
* Used instead of now() to avoid expensive timestamp computation
|
|
13
|
+
* when we only need uniqueness for change detection.
|
|
14
|
+
*/
|
|
15
|
+
let _resultIdCounter = 0;
|
|
16
|
+
|
|
10
17
|
/**
|
|
11
18
|
* RxDB needs the query results in multiple formats.
|
|
12
19
|
* Sometimes as a Map or an array with only the documentData.
|
|
@@ -16,11 +23,11 @@ import type {
|
|
|
16
23
|
*/
|
|
17
24
|
export class RxQuerySingleResult<RxDocType> {
|
|
18
25
|
/**
|
|
19
|
-
*
|
|
26
|
+
* Unique identifier for this result state.
|
|
20
27
|
* Used to determine if the result set has changed since X
|
|
21
28
|
* so that we do not emit the same result multiple times on subscription.
|
|
22
29
|
*/
|
|
23
|
-
public readonly time =
|
|
30
|
+
public readonly time = ++_resultIdCounter;
|
|
24
31
|
public readonly documents: RxDocument<RxDocType>[];
|
|
25
32
|
constructor(
|
|
26
33
|
public readonly query: RxQueryBase<RxDocType, unknown>,
|
package/src/rx-query.ts
CHANGED
|
@@ -93,12 +93,20 @@ export class RxQueryBase<
|
|
|
93
93
|
public _creationTime = Date.now();
|
|
94
94
|
|
|
95
95
|
// used in the query-cache to determine if the RxQuery can be cleaned up.
|
|
96
|
+
// 0 means never executed. Updated to an incrementing counter on each _ensureEqual call.
|
|
96
97
|
public _lastEnsureEqual = 0;
|
|
97
98
|
|
|
98
99
|
public uncached = false;
|
|
99
100
|
|
|
100
101
|
// used to count the subscribers to the query
|
|
101
|
-
|
|
102
|
+
// Lazy-initialized to avoid BehaviorSubject overhead for .exec()-only queries
|
|
103
|
+
public _refCount$: BehaviorSubject<null> | null = null;
|
|
104
|
+
public get refCount$(): BehaviorSubject<null> {
|
|
105
|
+
if (!this._refCount$) {
|
|
106
|
+
this._refCount$ = new BehaviorSubject<null>(null);
|
|
107
|
+
}
|
|
108
|
+
return this._refCount$;
|
|
109
|
+
}
|
|
102
110
|
|
|
103
111
|
public isFindOneByIdQuery: false | string | string[];
|
|
104
112
|
|
|
@@ -395,12 +403,26 @@ export class RxQueryBase<
|
|
|
395
403
|
* @overwrites itself with the actual value
|
|
396
404
|
*/
|
|
397
405
|
toString(): string {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
406
|
+
/**
|
|
407
|
+
* For findByIds queries, build the cache key directly from the IDs
|
|
408
|
+
* to avoid the expensive normalizeMangoQuery + sortObject + JSON.stringify.
|
|
409
|
+
* The selector structure is guaranteed by findByIds() which always creates
|
|
410
|
+
* { [primaryPath]: { $in: ids } }
|
|
411
|
+
*/
|
|
412
|
+
let value: string;
|
|
413
|
+
if (this.op === 'findByIds') {
|
|
414
|
+
const ids: string[] = (this.mangoQuery.selector as any)[this.collection.schema.primaryPath].$in;
|
|
415
|
+
// slice() is needed because sort() mutates the array in-place
|
|
416
|
+
const sortedIds = ids.slice().sort();
|
|
417
|
+
value = '|findByIds|' + JSON.stringify(sortedIds);
|
|
418
|
+
} else {
|
|
419
|
+
const stringObj = sortObject({
|
|
420
|
+
op: this.op,
|
|
421
|
+
query: this.normalizedQuery,
|
|
422
|
+
other: this.other
|
|
423
|
+
}, true);
|
|
424
|
+
value = JSON.stringify(stringObj);
|
|
425
|
+
}
|
|
404
426
|
this.toString = () => value;
|
|
405
427
|
return value;
|
|
406
428
|
}
|
|
@@ -448,7 +470,14 @@ export class RxQueryBase<
|
|
|
448
470
|
* deletes all found documents
|
|
449
471
|
* @return promise with deleted documents
|
|
450
472
|
*/
|
|
451
|
-
async remove(): Promise<RxQueryResult> {
|
|
473
|
+
async remove(throwIfMissing?: boolean): Promise<RxQueryResult> {
|
|
474
|
+
if (throwIfMissing && this.op !== 'findOne') {
|
|
475
|
+
throw newRxError('QU9', {
|
|
476
|
+
collection: this.collection.name,
|
|
477
|
+
query: this.mangoQuery,
|
|
478
|
+
op: this.op
|
|
479
|
+
});
|
|
480
|
+
}
|
|
452
481
|
const docs = await this.exec();
|
|
453
482
|
if (Array.isArray(docs)) {
|
|
454
483
|
const result = await this.collection.bulkRemove(docs);
|
|
@@ -458,6 +487,17 @@ export class RxQueryBase<
|
|
|
458
487
|
return result.success as any;
|
|
459
488
|
}
|
|
460
489
|
} else {
|
|
490
|
+
// findOne() can return null when no document matches
|
|
491
|
+
if (!docs) {
|
|
492
|
+
if (throwIfMissing) {
|
|
493
|
+
throw newRxError('QU10', {
|
|
494
|
+
collection: this.collection.name,
|
|
495
|
+
query: this.mangoQuery,
|
|
496
|
+
op: this.op
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
return null as any;
|
|
500
|
+
}
|
|
461
501
|
return (docs as any).remove();
|
|
462
502
|
}
|
|
463
503
|
}
|
package/src/rx-schema-helper.ts
CHANGED
|
@@ -291,7 +291,7 @@ export function fillWithDefaultSettings<T = any>(
|
|
|
291
291
|
|
|
292
292
|
// make indexes unique
|
|
293
293
|
const hasIndex = new Set<string>();
|
|
294
|
-
useIndexes.filter(index => {
|
|
294
|
+
schemaObj.indexes = useIndexes.filter(index => {
|
|
295
295
|
const indexStr = index.join(',');
|
|
296
296
|
if (hasIndex.has(indexStr)) {
|
|
297
297
|
return false;
|
|
@@ -301,8 +301,6 @@ export function fillWithDefaultSettings<T = any>(
|
|
|
301
301
|
}
|
|
302
302
|
});
|
|
303
303
|
|
|
304
|
-
schemaObj.indexes = useIndexes;
|
|
305
|
-
|
|
306
304
|
return schemaObj as any;
|
|
307
305
|
}
|
|
308
306
|
|
|
@@ -367,7 +365,12 @@ export function fillObjectWithDefaults(rxSchema: RxSchema<any>, obj: any): any {
|
|
|
367
365
|
for (let i = 0; i < defaultKeys.length; ++i) {
|
|
368
366
|
const key = defaultKeys[i];
|
|
369
367
|
if (obj[key] === undefined) {
|
|
370
|
-
|
|
368
|
+
const val = rxSchema.defaultValues[key];
|
|
369
|
+
if (typeof val === 'object' && val !== null) {
|
|
370
|
+
obj[key] = Array.isArray(val) ? val.slice() : { ...val };
|
|
371
|
+
} else {
|
|
372
|
+
obj[key] = val;
|
|
373
|
+
}
|
|
371
374
|
}
|
|
372
375
|
}
|
|
373
376
|
return obj;
|
package/src/rx-schema.ts
CHANGED
|
@@ -78,6 +78,7 @@ export class RxSchema<RxDocType = any> {
|
|
|
78
78
|
const jsonSchema: any = flatClone(this.jsonSchema);
|
|
79
79
|
jsonSchema.properties = flatClone(jsonSchema.properties);
|
|
80
80
|
delete jsonSchema.properties._deleted;
|
|
81
|
+
delete jsonSchema.properties._rev;
|
|
81
82
|
delete jsonSchema.properties._meta;
|
|
82
83
|
delete jsonSchema.properties._attachments;
|
|
83
84
|
|