@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/doc-cache.ts
CHANGED
|
@@ -7,7 +7,6 @@ import type {
|
|
|
7
7
|
} from './types/index.d.ts';
|
|
8
8
|
import {
|
|
9
9
|
getFromMapOrThrow,
|
|
10
|
-
getHeightOfRevision,
|
|
11
10
|
overwriteGetterForCaching,
|
|
12
11
|
requestIdlePromiseNoQueue
|
|
13
12
|
} from './plugins/utils/index.ts';
|
|
@@ -57,7 +56,7 @@ declare type CacheItem<RxDocType, OrmMethods> = [
|
|
|
57
56
|
*/
|
|
58
57
|
declare type FinalizationRegistryValue = {
|
|
59
58
|
docId: string;
|
|
60
|
-
|
|
59
|
+
rev: string;
|
|
61
60
|
lwt: number;
|
|
62
61
|
};
|
|
63
62
|
|
|
@@ -91,7 +90,7 @@ export class DocumentCache<RxDocType, OrmMethods> {
|
|
|
91
90
|
const docId = docMeta.docId;
|
|
92
91
|
const cacheItem = this.cacheItemByDocId.get(docId);
|
|
93
92
|
if (cacheItem) {
|
|
94
|
-
cacheItem[0].delete(docMeta.
|
|
93
|
+
cacheItem[0].delete(docMeta.rev + docMeta.lwt);
|
|
95
94
|
if (cacheItem[0].size === 0) {
|
|
96
95
|
/**
|
|
97
96
|
* No state of the document is cached anymore,
|
|
@@ -138,8 +137,7 @@ export class DocumentCache<RxDocType, OrmMethods> {
|
|
|
138
137
|
if (this.tasks.size === 0) {
|
|
139
138
|
return;
|
|
140
139
|
}
|
|
141
|
-
|
|
142
|
-
tasks.forEach(task => task());
|
|
140
|
+
this.tasks.forEach(task => task());
|
|
143
141
|
this.tasks.clear();
|
|
144
142
|
}
|
|
145
143
|
|
|
@@ -160,11 +158,11 @@ export class DocumentCache<RxDocType, OrmMethods> {
|
|
|
160
158
|
}
|
|
161
159
|
|
|
162
160
|
get getCachedRxDocument(): (docData: RxDocumentData<RxDocType>) => RxDocument<RxDocType, OrmMethods> {
|
|
163
|
-
const fn =
|
|
161
|
+
const fn = getCachedRxDocumentSingle(this);
|
|
164
162
|
return overwriteGetterForCaching(
|
|
165
163
|
this,
|
|
166
164
|
'getCachedRxDocument',
|
|
167
|
-
|
|
165
|
+
fn
|
|
168
166
|
);
|
|
169
167
|
}
|
|
170
168
|
|
|
@@ -186,6 +184,77 @@ export class DocumentCache<RxDocType, OrmMethods> {
|
|
|
186
184
|
}
|
|
187
185
|
}
|
|
188
186
|
|
|
187
|
+
/**
|
|
188
|
+
* @hotPath Dedicated single-document function that avoids array allocations.
|
|
189
|
+
* Used by getCachedRxDocument which is called from many call sites.
|
|
190
|
+
*/
|
|
191
|
+
function getCachedRxDocumentSingle<RxDocType, OrmMethods>(
|
|
192
|
+
docCache: DocumentCache<RxDocType, OrmMethods>
|
|
193
|
+
): (docData: RxDocumentData<RxDocType>) => RxDocument<RxDocType, OrmMethods> {
|
|
194
|
+
const primaryPath = docCache.primaryPath;
|
|
195
|
+
const cacheItemByDocId = docCache.cacheItemByDocId;
|
|
196
|
+
const registry = docCache.registry;
|
|
197
|
+
const deepFreezeWhenDevMode = overwritable.deepFreezeWhenDevMode;
|
|
198
|
+
const documentCreator = docCache.documentCreator;
|
|
199
|
+
|
|
200
|
+
return (docData: RxDocumentData<RxDocType>): RxDocument<RxDocType, OrmMethods> => {
|
|
201
|
+
const docId: string = (docData as any)[primaryPath];
|
|
202
|
+
const rev = docData._rev;
|
|
203
|
+
const lwt = docData._meta.lwt;
|
|
204
|
+
const cacheKey = rev + lwt;
|
|
205
|
+
|
|
206
|
+
const cacheItem = cacheItemByDocId.get(docId);
|
|
207
|
+
if (!cacheItem) {
|
|
208
|
+
docData = deepFreezeWhenDevMode(docData) as any;
|
|
209
|
+
const newDoc = documentCreator(docData) as RxDocument<RxDocType, OrmMethods>;
|
|
210
|
+
const newByRev = new Map<string, WeakRef<RxDocument<RxDocType, OrmMethods>>>();
|
|
211
|
+
newByRev.set(cacheKey, createWeakRefWithFallback(newDoc));
|
|
212
|
+
cacheItemByDocId.set(docId, [newByRev, docData]);
|
|
213
|
+
if (registry) {
|
|
214
|
+
docCache.tasks.add(() => {
|
|
215
|
+
registry.register(newDoc, {
|
|
216
|
+
docId: newDoc.primary,
|
|
217
|
+
rev,
|
|
218
|
+
lwt
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
if (docCache.tasks.size <= 1) {
|
|
222
|
+
requestIdlePromiseNoQueue().then(() => {
|
|
223
|
+
docCache.processTasks();
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return newDoc;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const byRev = cacheItem[0];
|
|
231
|
+
const cachedRxDocumentWeakRef = byRev.get(cacheKey);
|
|
232
|
+
let cachedRxDocument = cachedRxDocumentWeakRef ? cachedRxDocumentWeakRef.deref() : undefined;
|
|
233
|
+
if (!cachedRxDocument) {
|
|
234
|
+
docData = deepFreezeWhenDevMode(docData) as any;
|
|
235
|
+
cachedRxDocument = documentCreator(docData) as RxDocument<RxDocType, OrmMethods>;
|
|
236
|
+
byRev.set(cacheKey, createWeakRefWithFallback(cachedRxDocument));
|
|
237
|
+
if (registry) {
|
|
238
|
+
const registeredDoc = cachedRxDocument;
|
|
239
|
+
docCache.tasks.add(() => {
|
|
240
|
+
registry.register(registeredDoc, {
|
|
241
|
+
docId: registeredDoc.primary,
|
|
242
|
+
rev,
|
|
243
|
+
lwt
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
if (docCache.tasks.size <= 1) {
|
|
247
|
+
requestIdlePromiseNoQueue().then(() => {
|
|
248
|
+
docCache.processTasks();
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return cachedRxDocument;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
189
258
|
/**
|
|
190
259
|
* This function is called very very often.
|
|
191
260
|
* @hotPath This is one of the most important methods for performance.
|
|
@@ -201,58 +270,65 @@ function getCachedRxDocumentMonad<RxDocType, OrmMethods>(
|
|
|
201
270
|
const documentCreator = docCache.documentCreator;
|
|
202
271
|
const fn: (docsData: RxDocumentData<RxDocType>[]) => RxDocument<RxDocType, OrmMethods>[] = (docsData: RxDocumentData<RxDocType>[]) => {
|
|
203
272
|
const ret: RxDocument<RxDocType, OrmMethods>[] = new Array(docsData.length);
|
|
204
|
-
|
|
273
|
+
let registryTasks: { doc: RxDocument<RxDocType, OrmMethods>; rev: string; lwt: number; }[] | undefined;
|
|
205
274
|
for (let index = 0; index < docsData.length; index++) {
|
|
206
275
|
let docData = docsData[index];
|
|
207
276
|
const docId: string = (docData as any)[primaryPath];
|
|
208
277
|
|
|
209
|
-
const
|
|
278
|
+
const rev = docData._rev;
|
|
279
|
+
const lwt = docData._meta.lwt;
|
|
280
|
+
const cacheKey = rev + lwt;
|
|
210
281
|
|
|
211
|
-
|
|
212
|
-
* @performance
|
|
213
|
-
* Compute the byRev cache key once and reuse it
|
|
214
|
-
* for both the Map.get() and Map.set() calls.
|
|
215
|
-
*/
|
|
216
|
-
const cacheKey = revisionHeight + docData._meta.lwt + '';
|
|
217
|
-
|
|
218
|
-
let byRev: Map<string, WeakRef<RxDocument<RxDocType, OrmMethods>>>;
|
|
219
|
-
let cachedRxDocumentWeakRef: WeakRef<RxDocument<RxDocType, OrmMethods>> | undefined;
|
|
220
|
-
let cacheItem = cacheItemByDocId.get(docId);
|
|
282
|
+
const cacheItem = cacheItemByDocId.get(docId);
|
|
221
283
|
if (!cacheItem) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
];
|
|
227
|
-
cacheItemByDocId.set(docId, cacheItem);
|
|
228
|
-
} else {
|
|
229
|
-
byRev = cacheItem[0];
|
|
230
|
-
cachedRxDocumentWeakRef = byRev.get(cacheKey);
|
|
231
|
-
}
|
|
232
|
-
let cachedRxDocument = cachedRxDocumentWeakRef ? cachedRxDocumentWeakRef.deref() : undefined;
|
|
233
|
-
if (!cachedRxDocument) {
|
|
284
|
+
/**
|
|
285
|
+
* New document - no need for WeakRef lookup.
|
|
286
|
+
* Create cache item directly.
|
|
287
|
+
*/
|
|
234
288
|
docData = deepFreezeWhenDevMode(docData) as any;
|
|
235
|
-
cachedRxDocument = documentCreator(docData) as RxDocument<RxDocType, OrmMethods>;
|
|
289
|
+
const cachedRxDocument = documentCreator(docData) as RxDocument<RxDocType, OrmMethods>;
|
|
290
|
+
const byRev = new Map<string, WeakRef<RxDocument<RxDocType, OrmMethods>>>();
|
|
236
291
|
byRev.set(cacheKey, createWeakRefWithFallback(cachedRxDocument));
|
|
292
|
+
cacheItemByDocId.set(docId, [byRev, docData]);
|
|
293
|
+
ret[index] = cachedRxDocument;
|
|
237
294
|
if (registry) {
|
|
238
|
-
registryTasks
|
|
295
|
+
if (!registryTasks) {
|
|
296
|
+
registryTasks = [];
|
|
297
|
+
}
|
|
298
|
+
registryTasks.push({ doc: cachedRxDocument, rev, lwt });
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
const byRev = cacheItem[0];
|
|
302
|
+
const cachedRxDocumentWeakRef = byRev.get(cacheKey);
|
|
303
|
+
let cachedRxDocument = cachedRxDocumentWeakRef ? cachedRxDocumentWeakRef.deref() : undefined;
|
|
304
|
+
if (!cachedRxDocument) {
|
|
305
|
+
docData = deepFreezeWhenDevMode(docData) as any;
|
|
306
|
+
cachedRxDocument = documentCreator(docData) as RxDocument<RxDocType, OrmMethods>;
|
|
307
|
+
byRev.set(cacheKey, createWeakRefWithFallback(cachedRxDocument));
|
|
308
|
+
if (registry) {
|
|
309
|
+
if (!registryTasks) {
|
|
310
|
+
registryTasks = [];
|
|
311
|
+
}
|
|
312
|
+
registryTasks.push({ doc: cachedRxDocument, rev, lwt });
|
|
313
|
+
}
|
|
239
314
|
}
|
|
315
|
+
ret[index] = cachedRxDocument;
|
|
240
316
|
}
|
|
241
|
-
ret[index] = cachedRxDocument;
|
|
242
317
|
}
|
|
243
|
-
if (registryTasks
|
|
318
|
+
if (registryTasks && registry) {
|
|
244
319
|
/**
|
|
245
320
|
* Calling registry.register() has shown to have
|
|
246
321
|
* really bad performance. So we add the cached documents
|
|
247
322
|
* lazily.
|
|
248
323
|
*/
|
|
324
|
+
const tasks = registryTasks;
|
|
249
325
|
docCache.tasks.add(() => {
|
|
250
|
-
for (let index = 0; index <
|
|
251
|
-
const
|
|
252
|
-
registry.register(doc, {
|
|
253
|
-
docId: doc.primary,
|
|
254
|
-
|
|
255
|
-
lwt:
|
|
326
|
+
for (let index = 0; index < tasks.length; index++) {
|
|
327
|
+
const task = tasks[index];
|
|
328
|
+
registry.register(task.doc, {
|
|
329
|
+
docId: task.doc.primary,
|
|
330
|
+
rev: task.rev,
|
|
331
|
+
lwt: task.lwt
|
|
256
332
|
});
|
|
257
333
|
}
|
|
258
334
|
});
|
package/src/event-reduce.ts
CHANGED
|
@@ -109,7 +109,16 @@ export function calculateNewResults<RxDocumentType>(
|
|
|
109
109
|
}
|
|
110
110
|
const queryParams = getQueryParams(rxQuery);
|
|
111
111
|
const previousResults: RxDocumentType[] = ensureNotFalsy(rxQuery._result).docsData.slice(0);
|
|
112
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Copy the map to avoid mutating the cached docsDataMap on the result object.
|
|
114
|
+
* runAction() modifies the map in-place (adds/removes entries),
|
|
115
|
+
* which would corrupt the cached map if a later event triggers runFullQueryAgain
|
|
116
|
+
* and the full re-exec returns the same results (keeping the old result object).
|
|
117
|
+
* On subsequent event-reduce calls, the corrupted map would cause incorrect
|
|
118
|
+
* results because insertAtSortPosition checks keyDocumentMap.has(docId)
|
|
119
|
+
* to decide whether to skip insertion.
|
|
120
|
+
*/
|
|
121
|
+
const previousResultsMap: Map<string, RxDocumentType> = new Map(ensureNotFalsy(rxQuery._result).docsDataMap);
|
|
113
122
|
let changed: boolean = false;
|
|
114
123
|
|
|
115
124
|
|
package/src/plugin-helpers.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
getFromMapOrCreate,
|
|
24
24
|
requestIdleCallbackIfAvailable
|
|
25
25
|
} from './plugins/utils/index.ts';
|
|
26
|
+
import { newRxError } from './rx-error.ts';
|
|
26
27
|
import { BehaviorSubject, firstValueFrom } from 'rxjs';
|
|
27
28
|
|
|
28
29
|
|
|
@@ -242,6 +243,9 @@ export function wrapRxStorageInstance<RxDocType>(
|
|
|
242
243
|
query: (preparedQuery) => {
|
|
243
244
|
return instance.query(preparedQuery)
|
|
244
245
|
.then(queryResult => {
|
|
246
|
+
if (typeof queryResult === 'string') {
|
|
247
|
+
throw newRxError('EN5', { method: 'query' });
|
|
248
|
+
}
|
|
245
249
|
return Promise.all(queryResult.documents.map(doc => fromStorage(doc)));
|
|
246
250
|
})
|
|
247
251
|
.then(documents => ({ documents: documents as any }));
|
|
@@ -258,6 +262,9 @@ export function wrapRxStorageInstance<RxDocType>(
|
|
|
258
262
|
findDocumentsById: (ids, deleted) => {
|
|
259
263
|
return instance.findDocumentsById(ids, deleted)
|
|
260
264
|
.then(async (findResult) => {
|
|
265
|
+
if (typeof findResult === 'string') {
|
|
266
|
+
throw newRxError('EN5', { method: 'findDocumentsById' });
|
|
267
|
+
}
|
|
261
268
|
const ret: RxDocumentData<RxDocType>[] = [];
|
|
262
269
|
await Promise.all(
|
|
263
270
|
findResult
|
|
@@ -271,6 +278,9 @@ export function wrapRxStorageInstance<RxDocType>(
|
|
|
271
278
|
getChangedDocumentsSince: !instance.getChangedDocumentsSince ? undefined : (limit, checkpoint) => {
|
|
272
279
|
return ((instance as any).getChangedDocumentsSince)(limit, checkpoint)
|
|
273
280
|
.then(async (result: any) => {
|
|
281
|
+
if (typeof result === 'string') {
|
|
282
|
+
throw newRxError('EN5', { method: 'getChangedDocumentsSince' });
|
|
283
|
+
}
|
|
274
284
|
return {
|
|
275
285
|
checkpoint: result.checkpoint,
|
|
276
286
|
documents: await Promise.all(
|
|
@@ -283,18 +283,16 @@ export const RxDBAttachmentsPlugin: RxPlugin = {
|
|
|
283
283
|
get: function allAttachments$(this: RxDocument) {
|
|
284
284
|
return this.$
|
|
285
285
|
.pipe(
|
|
286
|
-
map((rxDocument: RxDocument) =>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
);
|
|
297
|
-
});
|
|
286
|
+
map((rxDocument: RxDocument) => {
|
|
287
|
+
return Object.entries(
|
|
288
|
+
rxDocument.toJSON(true)._attachments
|
|
289
|
+
).map(([id, attachmentData]: [string, any]) => {
|
|
290
|
+
return fromStorageInstanceResult(
|
|
291
|
+
id,
|
|
292
|
+
attachmentData,
|
|
293
|
+
rxDocument
|
|
294
|
+
);
|
|
295
|
+
});
|
|
298
296
|
})
|
|
299
297
|
);
|
|
300
298
|
}
|
|
@@ -93,6 +93,9 @@ export async function cleanupRxCollection(
|
|
|
93
93
|
return true;
|
|
94
94
|
}
|
|
95
95
|
await rxDatabase.requestIdlePromise();
|
|
96
|
+
if (rxCollection.closed) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
96
99
|
const allDone: Promise<boolean>[] = [];
|
|
97
100
|
allDone.push(storageInstance.cleanup(cleanupPolicy.minimumDeletedTime));
|
|
98
101
|
const replicationStates = getFromMapOrCreate(
|
|
@@ -102,13 +105,12 @@ export async function cleanupRxCollection(
|
|
|
102
105
|
);
|
|
103
106
|
for (const replicationState of replicationStates) {
|
|
104
107
|
const meta = replicationState.metaInstance;
|
|
105
|
-
if (meta) {
|
|
108
|
+
if (meta && !replicationState.isStopped()) {
|
|
106
109
|
allDone.push(meta.cleanup(cleanupPolicy.minimumDeletedTime));
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
|
|
110
|
-
|
|
111
|
-
return !hasFalse;
|
|
113
|
+
return (await Promise.all(allDone)).every(v => v);
|
|
112
114
|
});
|
|
113
115
|
isDone = await RXSTORAGE_CLEANUP_QUEUE;
|
|
114
116
|
}
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
RxError
|
|
34
34
|
} from '../../index.ts';
|
|
35
35
|
import { mingoUpdater } from '../update/mingo-updater.ts';
|
|
36
|
+
import { fillObjectWithDefaults } from '../../rx-schema-helper.ts';
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
|
|
@@ -352,6 +353,43 @@ export const RxDBcrdtPlugin: RxPlugin = {
|
|
|
352
353
|
});
|
|
353
354
|
};
|
|
354
355
|
|
|
356
|
+
const oldincrementalRemove = proto.incrementalRemove;
|
|
357
|
+
proto.incrementalRemove = function (this: RxDocument) {
|
|
358
|
+
if (!this.collection.schema.jsonSchema.crdt) {
|
|
359
|
+
return oldincrementalRemove.call(this);
|
|
360
|
+
}
|
|
361
|
+
return this.updateCRDT({
|
|
362
|
+
ifMatch: {
|
|
363
|
+
$set: {
|
|
364
|
+
_deleted: true
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const oldModify = proto.modify;
|
|
371
|
+
proto.modify = function (this: RxDocument, fn: any, context?: string) {
|
|
372
|
+
if (!this.collection.schema.jsonSchema.crdt) {
|
|
373
|
+
return oldModify.call(this, fn, context);
|
|
374
|
+
}
|
|
375
|
+
throw newRxError('CRDT4', {
|
|
376
|
+
id: this.primary,
|
|
377
|
+
args: { method: 'modify' }
|
|
378
|
+
});
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
const oldPatch = proto.patch;
|
|
382
|
+
proto.patch = function (this: RxDocument, patch: any) {
|
|
383
|
+
if (!this.collection.schema.jsonSchema.crdt) {
|
|
384
|
+
return oldPatch.call(this, patch);
|
|
385
|
+
}
|
|
386
|
+
return this.updateCRDT({
|
|
387
|
+
ifMatch: {
|
|
388
|
+
$set: patch
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
|
|
355
393
|
const oldincrementalPatch = proto.incrementalPatch;
|
|
356
394
|
proto.incrementalPatch = function (this: RxDocument, patch: any) {
|
|
357
395
|
if (!this.collection.schema.jsonSchema.crdt) {
|
|
@@ -377,6 +415,16 @@ export const RxDBcrdtPlugin: RxPlugin = {
|
|
|
377
415
|
});
|
|
378
416
|
}
|
|
379
417
|
};
|
|
418
|
+
|
|
419
|
+
const oldUpdate = proto.update;
|
|
420
|
+
proto.update = function (this: RxDocument, updateObj: any) {
|
|
421
|
+
if (!this.collection.schema.jsonSchema.crdt) {
|
|
422
|
+
return oldUpdate.call(this, updateObj);
|
|
423
|
+
}
|
|
424
|
+
return this.updateCRDT({
|
|
425
|
+
ifMatch: updateObj
|
|
426
|
+
});
|
|
427
|
+
};
|
|
380
428
|
},
|
|
381
429
|
RxCollection: (proto: any) => {
|
|
382
430
|
proto.insertCRDT = insertCRDT;
|
|
@@ -468,6 +516,13 @@ export const RxDBcrdtPlugin: RxPlugin = {
|
|
|
468
516
|
const storageToken = await collection.database.storageToken;
|
|
469
517
|
const useDocsData = await Promise.all(
|
|
470
518
|
docsData.map(async (docData) => {
|
|
519
|
+
/**
|
|
520
|
+
* Fill schema default values before creating CRDT operations,
|
|
521
|
+
* so that default values are captured in the operations and
|
|
522
|
+
* will be preserved during rebuildFromCRDT (conflict resolution).
|
|
523
|
+
*/
|
|
524
|
+
fillObjectWithDefaults(collection.schema, docData);
|
|
525
|
+
|
|
471
526
|
const setMe: Partial<RxDocumentData<any>> = {};
|
|
472
527
|
Object.entries(docData).forEach(([key, value]) => {
|
|
473
528
|
if (
|
|
@@ -50,7 +50,13 @@ export function checkQuery(args: RxPluginPreCreateRxQueryArgs) {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Count queries cannot use skip or limit.
|
|
55
|
+
* The storage.count() method returns the total number of matching documents
|
|
56
|
+
* and is designed to ignore skip/limit (see rx-storage.interface.d.ts).
|
|
57
|
+
* This is intentional by design - count should always return the total.
|
|
58
|
+
* @intentional This is correct behavior, not a bug.
|
|
59
|
+
*/
|
|
54
60
|
if (
|
|
55
61
|
args.op === 'count' &&
|
|
56
62
|
(
|
|
@@ -314,10 +314,11 @@ export function checkSchema(jsonSchema: RxJsonSchema<any>) {
|
|
|
314
314
|
validateFieldsDeep(jsonSchema);
|
|
315
315
|
checkPrimaryKey(jsonSchema);
|
|
316
316
|
|
|
317
|
+
const primaryPath = getPrimaryFieldOfPrimaryKey(jsonSchema.primaryKey);
|
|
317
318
|
Object.keys(jsonSchema.properties).forEach(key => {
|
|
318
319
|
const value: any = jsonSchema.properties[key];
|
|
319
320
|
// check primary
|
|
320
|
-
if (key ===
|
|
321
|
+
if (key === primaryPath) {
|
|
321
322
|
if (jsonSchema.indexes && jsonSchema.indexes.includes(key)) {
|
|
322
323
|
throw newRxError('SC13', {
|
|
323
324
|
value,
|
|
@@ -122,7 +122,7 @@ export const ERROR_MESSAGES = {
|
|
|
122
122
|
},
|
|
123
123
|
QU10: {
|
|
124
124
|
message: 'result empty and throwIfMissing: true',
|
|
125
|
-
cause: 'exec(true) was called but the document was not found.',
|
|
125
|
+
cause: 'exec(true) or remove(true) was called on a findOne() query but the document was not found.',
|
|
126
126
|
fix: 'Ensure the document exists or do not use the throwIfMissing flag.',
|
|
127
127
|
docs: ''
|
|
128
128
|
},
|
|
@@ -450,7 +450,7 @@ export const ERROR_MESSAGES = {
|
|
|
450
450
|
docs: 'https://rxdb.info/transactions-conflicts-revisions.html?console=errors&code=CONFLICT'
|
|
451
451
|
},
|
|
452
452
|
COL22: {
|
|
453
|
-
message: '.bulkInsert() and .bulkUpsert() cannot be run with multiple documents that have the same primary key',
|
|
453
|
+
message: '.bulkInsert() and .bulkUpsert() cannot be run with multiple documents that have the same primary key. Conflicting primary key(s) are in the error parameters (duplicateIds)',
|
|
454
454
|
cause: 'You provided multiple documents with the same primary key in a bulk write.',
|
|
455
455
|
fix: 'Ensure all documents in a bulk write have unique primary keys.',
|
|
456
456
|
docs: ''
|
|
@@ -693,6 +693,12 @@ export const ERROR_MESSAGES = {
|
|
|
693
693
|
fix: 'Check the password.',
|
|
694
694
|
docs: 'https://rxdb.info/encryption.html?console=errors&code=EN4'
|
|
695
695
|
},
|
|
696
|
+
EN5: {
|
|
697
|
+
message: 'Storage wrapper received a string instead of an array from the storage. This happens when a storage like OPFS is used inside of a worker and the usesRxDatabaseInWorker option is not set.',
|
|
698
|
+
cause: 'Some RxStorage implementations (like OPFS) return JSON strings instead of arrays for performance. When you wrap such a storage with encryption (or other plugins) inside of a worker, the wrapper receives the raw string and cannot process it.',
|
|
699
|
+
fix: 'Set usesRxDatabaseInWorker: true in your storage options. For example: getRxStorageOPFS({ usesRxDatabaseInWorker: true }).',
|
|
700
|
+
docs: 'https://rxdb.info/encryption.html?console=errors&code=EN5'
|
|
701
|
+
},
|
|
696
702
|
|
|
697
703
|
// plugins/json-dump.js
|
|
698
704
|
JD1: {
|
|
@@ -1163,6 +1169,12 @@ export const ERROR_MESSAGES = {
|
|
|
1163
1169
|
fix: 'Remove the custom conflict handler.',
|
|
1164
1170
|
docs: 'https://rxdb.info/crdt.html?console=errors&code=CRDT3'
|
|
1165
1171
|
},
|
|
1172
|
+
CRDT4: {
|
|
1173
|
+
message: 'RxDocument.modify() cannot be used when CRDTs are activated.',
|
|
1174
|
+
cause: 'modify() takes an arbitrary function that cannot be converted to a CRDT operation.',
|
|
1175
|
+
fix: 'Use updateCRDT() instead of modify().',
|
|
1176
|
+
docs: 'https://rxdb.info/crdt.html?console=errors&code=CRDT4'
|
|
1177
|
+
},
|
|
1166
1178
|
|
|
1167
1179
|
// plugins/storage-dexie/
|
|
1168
1180
|
DXE1: {
|
|
@@ -1267,6 +1279,12 @@ export const ERROR_MESSAGES = {
|
|
|
1267
1279
|
fix: 'Try to reproduce the error in a unit test and make a PR with a test case.',
|
|
1268
1280
|
docs: 'https://rxdb.info/replication-google-drive.html?console=errors&code=GDR19'
|
|
1269
1281
|
},
|
|
1282
|
+
GDR20: {
|
|
1283
|
+
message: 'Document file update conflict',
|
|
1284
|
+
cause: 'Another client modified the document file during the transaction. This indicates a transaction timeout overlap.',
|
|
1285
|
+
fix: 'Increase the transactionTimeout or investigate why two clients are writing to the same document concurrently.',
|
|
1286
|
+
docs: 'https://rxdb.info/replication-google-drive.html?console=errors&code=GDR20'
|
|
1287
|
+
},
|
|
1270
1288
|
|
|
1271
1289
|
|
|
1272
1290
|
|
|
@@ -1316,6 +1334,28 @@ export const ERROR_MESSAGES = {
|
|
|
1316
1334
|
docs: ''
|
|
1317
1335
|
},
|
|
1318
1336
|
|
|
1337
|
+
// custom-index errors
|
|
1338
|
+
CI1: {
|
|
1339
|
+
message: 'Field not in schema',
|
|
1340
|
+
cause: 'The given field is not defined in the RxJsonSchema.',
|
|
1341
|
+
fix: 'Make sure the field name is spelled correctly and exists in the schema.',
|
|
1342
|
+
docs: ''
|
|
1343
|
+
},
|
|
1344
|
+
CI2: {
|
|
1345
|
+
message: 'Unknown index type',
|
|
1346
|
+
cause: 'The schema field type is not supported for indexing.',
|
|
1347
|
+
fix: 'Use a supported type (string, boolean, number, integer) for the indexed field.',
|
|
1348
|
+
docs: ''
|
|
1349
|
+
},
|
|
1350
|
+
|
|
1351
|
+
// change-event-buffer errors
|
|
1352
|
+
COB1: {
|
|
1353
|
+
message: 'ChangeEventBuffer out of bounds',
|
|
1354
|
+
cause: 'The requested pointer is out of the change event buffer bounds.',
|
|
1355
|
+
fix: 'This means something in RxDB itself behaves wrong because any access to the api should not make an out of bounds request.',
|
|
1356
|
+
docs: ''
|
|
1357
|
+
},
|
|
1358
|
+
|
|
1319
1359
|
/**
|
|
1320
1360
|
* Should never be thrown, use this for
|
|
1321
1361
|
* null checks etc. so you do not have to increase the
|
|
@@ -1323,9 +1363,9 @@ export const ERROR_MESSAGES = {
|
|
|
1323
1363
|
*/
|
|
1324
1364
|
SNH: {
|
|
1325
1365
|
message: 'This should never happen',
|
|
1326
|
-
cause: '',
|
|
1327
|
-
fix: '',
|
|
1328
|
-
docs: ''
|
|
1366
|
+
cause: 'Should never be thrown. This error code is used for internal things like null-checks etc.',
|
|
1367
|
+
fix: 'If this throws, you likely found a bug and should make a PR with a test case to the RxDB repo, so we can reproduce it.',
|
|
1368
|
+
docs: 'https://rxdb.info/contribution.html'
|
|
1329
1369
|
},
|
|
1330
1370
|
};
|
|
1331
1371
|
|
|
@@ -97,12 +97,24 @@ export function wrappedKeyEncryptionCryptoJsStorage<Internals, InstanceCreationO
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Encrypted data is always stored as string
|
|
100
|
-
* so we have to
|
|
101
|
-
*
|
|
100
|
+
* so we have to replace the schema definition of
|
|
101
|
+
* encrypted fields with just {type: 'string'}.
|
|
102
|
+
* All type-specific keywords (properties, required,
|
|
103
|
+
* items, maxLength, enum etc.) must be removed because
|
|
104
|
+
* they do not apply to the encrypted ciphertext string.
|
|
102
105
|
*/
|
|
103
106
|
ensureNotFalsy(params.schema.encrypted).forEach(key => {
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
const pathParts = key.split('.');
|
|
108
|
+
if (pathParts.length === 1) {
|
|
109
|
+
(schemaWithoutEncrypted as any).properties[key] = { type: 'string' };
|
|
110
|
+
} else {
|
|
111
|
+
// Navigate nested schema structure: properties.a.properties.b.properties.c
|
|
112
|
+
let currentSchemaLevel: any = schemaWithoutEncrypted;
|
|
113
|
+
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
114
|
+
currentSchemaLevel = currentSchemaLevel.properties[pathParts[i]];
|
|
115
|
+
}
|
|
116
|
+
currentSchemaLevel.properties[pathParts[pathParts.length - 1]] = { type: 'string' };
|
|
117
|
+
}
|
|
106
118
|
});
|
|
107
119
|
|
|
108
120
|
const instance = await args.storage.createStorageInstance(
|
|
@@ -208,13 +220,13 @@ function cloneWithoutAttachments<T>(data: RxDocumentWriteData<T>): RxDocumentDat
|
|
|
208
220
|
function validatePassword(password: string) {
|
|
209
221
|
if (typeof password !== 'string') {
|
|
210
222
|
throw newRxTypeError('EN1', {
|
|
211
|
-
password
|
|
223
|
+
passwordType: typeof password
|
|
212
224
|
});
|
|
213
225
|
}
|
|
214
226
|
if (password.length < MINIMUM_PASSWORD_LENGTH) {
|
|
215
227
|
throw newRxError('EN2', {
|
|
216
228
|
minPassLength: MINIMUM_PASSWORD_LENGTH,
|
|
217
|
-
password
|
|
229
|
+
passwordLength: password.length
|
|
218
230
|
});
|
|
219
231
|
}
|
|
220
232
|
}
|
|
@@ -21,6 +21,8 @@ import { PROMISE_RESOLVE_TRUE, getFromMapOrCreate } from '../utils/index.ts';
|
|
|
21
21
|
const LEADER_ELECTORS_OF_DB: WeakMap<RxDatabase, LeaderElector> = new WeakMap();
|
|
22
22
|
const LEADER_ELECTOR_BY_BROADCAST_CHANNEL: WeakMap<BroadcastChannel, LeaderElector> = new WeakMap();
|
|
23
23
|
|
|
24
|
+
export const OPEN_LEADER_ELECTORS: Set<LeaderElector> = new Set();
|
|
25
|
+
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* Returns the leader elector of a broadcast channel.
|
|
@@ -64,14 +66,12 @@ export function getForDatabase(this: RxDatabase): LeaderElector {
|
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
);
|
|
74
|
-
}
|
|
69
|
+
const elector = getLeaderElectorByBroadcastChannel(broadcastChannel);
|
|
70
|
+
LEADER_ELECTORS_OF_DB.set(
|
|
71
|
+
this,
|
|
72
|
+
elector
|
|
73
|
+
);
|
|
74
|
+
OPEN_LEADER_ELECTORS.add(elector);
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Overwrite for caching
|
|
@@ -105,6 +105,7 @@ export function onClose(db: RxDatabase) {
|
|
|
105
105
|
const has = LEADER_ELECTORS_OF_DB.get(db);
|
|
106
106
|
if (has) {
|
|
107
107
|
has.die();
|
|
108
|
+
OPEN_LEADER_ELECTORS.delete(has);
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
|