@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
|
@@ -60,24 +60,33 @@ export async function insertLocal<DocData extends Record<string, any> = any, Rea
|
|
|
60
60
|
* save the local-document-data
|
|
61
61
|
* overwrites existing if exists
|
|
62
62
|
*/
|
|
63
|
-
export function upsertLocal<DocData extends Record<string, any> = any, Reactivity = unknown>(
|
|
63
|
+
export async function upsertLocal<DocData extends Record<string, any> = any, Reactivity = unknown>(
|
|
64
64
|
this: any,
|
|
65
65
|
id: string,
|
|
66
66
|
data: DocData
|
|
67
67
|
): Promise<RxLocalDocument<DocData, any, Reactivity>> {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
const existing = await this.getLocal(id);
|
|
69
|
+
if (!existing) {
|
|
70
|
+
// create new one
|
|
71
|
+
return this.insertLocal(id, data);
|
|
72
|
+
} else if (existing.deleted) {
|
|
73
|
+
// document was deleted before, un-delete it via the write queue
|
|
74
|
+
const state = await getLocalDocStateByParent(this);
|
|
75
|
+
const writeResult = await state.incrementalWriteQueue.addWrite(
|
|
76
|
+
(existing as any)._data,
|
|
77
|
+
(docData: any) => {
|
|
78
|
+
docData.data = data;
|
|
79
|
+
docData._deleted = false;
|
|
80
|
+
return docData;
|
|
79
81
|
}
|
|
82
|
+
);
|
|
83
|
+
return state.docCache.getCachedRxDocument(writeResult) as any;
|
|
84
|
+
} else {
|
|
85
|
+
// update existing
|
|
86
|
+
return existing.incrementalModify(() => {
|
|
87
|
+
return data;
|
|
80
88
|
});
|
|
89
|
+
}
|
|
81
90
|
}
|
|
82
91
|
|
|
83
92
|
export async function getLocal<DocData = any, Reactivity = unknown>(this: any, id: string): Promise<RxLocalDocument<DocData, any, Reactivity> | null> {
|
|
@@ -70,6 +70,8 @@ export function migrateDocumentData(
|
|
|
70
70
|
const attachmentsBefore = flatClone(docData._attachments);
|
|
71
71
|
const mutateableDocData = clone(docData);
|
|
72
72
|
const meta = mutateableDocData._meta;
|
|
73
|
+
const deleted = mutateableDocData._deleted;
|
|
74
|
+
delete mutateableDocData._deleted;
|
|
73
75
|
delete mutateableDocData._meta;
|
|
74
76
|
mutateableDocData._attachments = attachmentsBefore;
|
|
75
77
|
|
|
@@ -95,6 +97,7 @@ export function migrateDocumentData(
|
|
|
95
97
|
if (meta) {
|
|
96
98
|
doc._meta = meta;
|
|
97
99
|
}
|
|
100
|
+
doc._deleted = deleted;
|
|
98
101
|
return doc;
|
|
99
102
|
});
|
|
100
103
|
}
|
|
@@ -329,7 +329,7 @@ export class RxMigrationState {
|
|
|
329
329
|
for (const oneHandler of useHandlers) {
|
|
330
330
|
status = oneHandler(status);
|
|
331
331
|
}
|
|
332
|
-
status.count.percent = Math.round((status.count.handled / status.count.total) * 100);
|
|
332
|
+
status.count.percent = status.count.total === 0 ? 100 : Math.round((status.count.handled / status.count.total) * 100);
|
|
333
333
|
|
|
334
334
|
if (
|
|
335
335
|
newDoc && previous &&
|
|
@@ -172,6 +172,8 @@ export class RxPipeline<RxDocType> {
|
|
|
172
172
|
done = true;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
+
}).catch(err => {
|
|
176
|
+
this.error = err;
|
|
175
177
|
});
|
|
176
178
|
}
|
|
177
179
|
|
|
@@ -205,11 +207,14 @@ export class RxPipeline<RxDocType> {
|
|
|
205
207
|
* Remove the pipeline and all metadata which it has stored
|
|
206
208
|
*/
|
|
207
209
|
async remove() {
|
|
210
|
+
await this.close();
|
|
208
211
|
const insternalStore = this.destination.database.internalStore;
|
|
209
212
|
const checkpointDoc = await getCheckpointDoc(this);
|
|
210
213
|
if (checkpointDoc) {
|
|
211
214
|
const newDoc: RxDocumentData<InternalStoreDocType> = clone(checkpointDoc);
|
|
212
215
|
newDoc._deleted = true;
|
|
216
|
+
newDoc._meta.lwt = now();
|
|
217
|
+
newDoc._rev = createRevision(this.destination.database.token, checkpointDoc);
|
|
213
218
|
const writeResult = await insternalStore.bulkWrite([{
|
|
214
219
|
previous: checkpointDoc,
|
|
215
220
|
document: newDoc,
|
|
@@ -218,7 +223,6 @@ export class RxPipeline<RxDocType> {
|
|
|
218
223
|
throw writeResult.error;
|
|
219
224
|
}
|
|
220
225
|
}
|
|
221
|
-
return this.close();
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
|
|
@@ -92,7 +92,10 @@ export class NoSqlQueryBuilderClass<DocType> {
|
|
|
92
92
|
equals(val: any): NoSqlQueryBuilder<DocType> {
|
|
93
93
|
this._ensurePath('equals');
|
|
94
94
|
const path = this._path;
|
|
95
|
-
(this._conditions as any)[path]
|
|
95
|
+
const conds = (this._conditions as any)[path] !== null && typeof (this._conditions as any)[path] === 'object' ?
|
|
96
|
+
(this._conditions as any)[path] :
|
|
97
|
+
((this._conditions as any)[path] = {});
|
|
98
|
+
conds.$eq = val;
|
|
96
99
|
return this as any;
|
|
97
100
|
}
|
|
98
101
|
|
|
@@ -103,7 +106,10 @@ export class NoSqlQueryBuilderClass<DocType> {
|
|
|
103
106
|
eq(val: any): NoSqlQueryBuilder<DocType> {
|
|
104
107
|
this._ensurePath('eq');
|
|
105
108
|
const path = this._path;
|
|
106
|
-
(this._conditions as any)[path]
|
|
109
|
+
const conds = (this._conditions as any)[path] !== null && typeof (this._conditions as any)[path] === 'object' ?
|
|
110
|
+
(this._conditions as any)[path] :
|
|
111
|
+
((this._conditions as any)[path] = {});
|
|
112
|
+
conds.$eq = val;
|
|
107
113
|
return this as any;
|
|
108
114
|
}
|
|
109
115
|
|
|
@@ -237,7 +237,7 @@ export class RxReplicationState<RxDocType, CheckpointType> {
|
|
|
237
237
|
waitBeforePersist: this.push ? this.push.waitBeforePersist : undefined,
|
|
238
238
|
replicationHandler: {
|
|
239
239
|
masterChangeStream$: this.remoteEvents$.asObservable().pipe(
|
|
240
|
-
filter((_v: RxReplicationPullStreamItem<RxDocType, CheckpointType>) => !!this.pull),
|
|
240
|
+
filter((_v: RxReplicationPullStreamItem<RxDocType, CheckpointType>) => !!this.pull || _v === 'RESYNC'),
|
|
241
241
|
mergeMap(async (ev: RxReplicationPullStreamItem<RxDocType, CheckpointType>) => {
|
|
242
242
|
if (ev === 'RESYNC') {
|
|
243
243
|
return ev;
|
|
@@ -548,6 +548,20 @@ export class RxReplicationState<RxDocType, CheckpointType> {
|
|
|
548
548
|
this.subjects.received.complete();
|
|
549
549
|
this.subjects.sent.complete();
|
|
550
550
|
|
|
551
|
+
/**
|
|
552
|
+
* Remove from the REPLICATION_STATE_BY_COLLECTION registry
|
|
553
|
+
* so that the cleanup plugin does not try to access a stopped
|
|
554
|
+
* replication's meta instance, and to prevent memory leaks
|
|
555
|
+
* from accumulating canceled replication state objects.
|
|
556
|
+
*/
|
|
557
|
+
const states = REPLICATION_STATE_BY_COLLECTION.get(this.collection as any);
|
|
558
|
+
if (states) {
|
|
559
|
+
const idx = states.indexOf(this);
|
|
560
|
+
if (idx !== -1) {
|
|
561
|
+
states.splice(idx, 1);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
551
565
|
return Promise.all(promises);
|
|
552
566
|
}
|
|
553
567
|
|
|
@@ -555,8 +569,32 @@ export class RxReplicationState<RxDocType, CheckpointType> {
|
|
|
555
569
|
this.startQueue = this.startQueue.then(async () => {
|
|
556
570
|
const metaInfo = await this.metaInfoPromise;
|
|
557
571
|
await this._cancel(true);
|
|
558
|
-
|
|
559
|
-
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* If the replication was never started (e.g. autoStart: false
|
|
575
|
+
* and start() was never called), we still have to
|
|
576
|
+
* create the meta storage instance and then remove its data.
|
|
577
|
+
* This is required so that old meta data from a previous
|
|
578
|
+
* replication with the same identifier is properly deleted.
|
|
579
|
+
*/
|
|
580
|
+
if (!this.metaInstance) {
|
|
581
|
+
const database = this.collection.database;
|
|
582
|
+
this.metaInstance = await database.storage.createStorageInstance<RxStorageReplicationMeta<RxDocType, CheckpointType>>({
|
|
583
|
+
databaseName: database.name,
|
|
584
|
+
collectionName: metaInfo.collectionName,
|
|
585
|
+
databaseInstanceToken: database.token,
|
|
586
|
+
multiInstance: database.multiInstance,
|
|
587
|
+
options: {},
|
|
588
|
+
schema: metaInfo.schema,
|
|
589
|
+
password: database.password,
|
|
590
|
+
devMode: overwritable.isDevMode()
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (this.internalReplicationState) {
|
|
595
|
+
await this.internalReplicationState.checkpointQueue;
|
|
596
|
+
}
|
|
597
|
+
await ensureNotFalsy(this.metaInstance).remove();
|
|
560
598
|
await removeConnectedStorageFromCollection(
|
|
561
599
|
this.collection,
|
|
562
600
|
metaInfo.collectionName,
|
|
@@ -29,7 +29,7 @@ export async function getDocumentFiles(
|
|
|
29
29
|
const params = new URLSearchParams({
|
|
30
30
|
q,
|
|
31
31
|
pageSize: MAX_DRIVE_PAGE_SIZE + '',
|
|
32
|
-
fields: "nextPageToken, files(id,name,mimeType,parents,modifiedTime,size)",
|
|
32
|
+
fields: "nextPageToken, files(id,name,mimeType,parents,modifiedTime,size,etag)",
|
|
33
33
|
// Shared drives support (safe to include always)
|
|
34
34
|
includeItemsFromAllDrives: "true",
|
|
35
35
|
supportsAllDrives: "true",
|
|
@@ -109,7 +109,7 @@ export async function updateDocumentFiles<DocType>(
|
|
|
109
109
|
googleDriveOptions: GoogleDriveOptionsWithDefaults,
|
|
110
110
|
primaryPath: keyof DocType,
|
|
111
111
|
docs: DocType[],
|
|
112
|
-
|
|
112
|
+
fileMetaByDocId: Record<string, { fileId: string; etag: string }>,
|
|
113
113
|
concurrency = 5
|
|
114
114
|
) {
|
|
115
115
|
const queue = docs.slice(0);
|
|
@@ -119,22 +119,34 @@ export async function updateDocumentFiles<DocType>(
|
|
|
119
119
|
while (queue.length) {
|
|
120
120
|
const doc = queue.shift()!;
|
|
121
121
|
const docId = (doc as any)[primaryPath] as string;
|
|
122
|
-
const
|
|
122
|
+
const meta = ensureNotFalsy(fileMetaByDocId[docId]);
|
|
123
|
+
const fileId = meta.fileId;
|
|
124
|
+
const etag = meta.etag;
|
|
123
125
|
|
|
124
126
|
const url =
|
|
125
127
|
googleDriveOptions.apiEndpoint +
|
|
126
|
-
`/upload/drive/
|
|
128
|
+
`/upload/drive/v2/files/${encodeURIComponent(fileId)}` +
|
|
127
129
|
`?uploadType=media&supportsAllDrives=true&fields=id`;
|
|
128
130
|
|
|
129
131
|
const res = await fetch(url, {
|
|
130
|
-
method: "
|
|
132
|
+
method: "PUT",
|
|
131
133
|
headers: {
|
|
132
134
|
Authorization: `Bearer ${googleDriveOptions.authToken}`,
|
|
133
135
|
"Content-Type": "application/json; charset=UTF-8",
|
|
136
|
+
"If-Match": etag,
|
|
134
137
|
},
|
|
135
138
|
body: JSON.stringify(doc),
|
|
136
139
|
});
|
|
137
140
|
|
|
141
|
+
if (res.status === 412) {
|
|
142
|
+
throw newRxError('GDR20', {
|
|
143
|
+
args: {
|
|
144
|
+
docId,
|
|
145
|
+
fileId
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
138
150
|
if (!res.ok) {
|
|
139
151
|
throw await newRxFetchError(res, {
|
|
140
152
|
args: {
|
|
@@ -144,7 +144,9 @@ export class SignalingState {
|
|
|
144
144
|
|
|
145
145
|
async pingPeers(message: SIGNAL) {
|
|
146
146
|
Array.from(this.peerBySenderId.values()).forEach(peer => {
|
|
147
|
-
peer.
|
|
147
|
+
if (peer.connected) {
|
|
148
|
+
peer.send(message);
|
|
149
|
+
}
|
|
148
150
|
});
|
|
149
151
|
}
|
|
150
152
|
|
|
@@ -195,6 +197,7 @@ export class SignalingState {
|
|
|
195
197
|
});
|
|
196
198
|
peer.on('connect', () => {
|
|
197
199
|
this._resync$.next();
|
|
200
|
+
peer.send('RESYNC');
|
|
198
201
|
});
|
|
199
202
|
peer.on('data', (dataBuffer: any) => {
|
|
200
203
|
const data = dataBuffer + '';
|
|
@@ -213,18 +213,21 @@ export async function processWalFile<RxDocType>(
|
|
|
213
213
|
init,
|
|
214
214
|
docIds as string[]
|
|
215
215
|
);
|
|
216
|
-
const
|
|
216
|
+
const fileMetaByDocId: Record<string, { fileId: string; etag: string }> = {};
|
|
217
217
|
|
|
218
218
|
docFiles.files.forEach(file => {
|
|
219
219
|
const docId = file.name.split('.')[0] as any;
|
|
220
|
-
|
|
220
|
+
fileMetaByDocId[docId] = {
|
|
221
|
+
fileId: file.id,
|
|
222
|
+
etag: ensureNotFalsy(file.etag),
|
|
223
|
+
};
|
|
221
224
|
});
|
|
222
225
|
|
|
223
226
|
const toInsert: WithDeletedAndAttachments<RxDocType>[] = [];
|
|
224
227
|
const toUpdate: WithDeletedAndAttachments<RxDocType>[] = [];
|
|
225
228
|
content.rows.filter(row => {
|
|
226
229
|
const docId = row.newDocumentState[primaryPath];
|
|
227
|
-
const fileExists =
|
|
230
|
+
const fileExists = fileMetaByDocId[docId as any];
|
|
228
231
|
if (!fileExists) {
|
|
229
232
|
toInsert.push(row.newDocumentState);
|
|
230
233
|
} else {
|
|
@@ -243,7 +246,7 @@ export async function processWalFile<RxDocType>(
|
|
|
243
246
|
googleDriveOptions,
|
|
244
247
|
primaryPath,
|
|
245
248
|
toUpdate,
|
|
246
|
-
|
|
249
|
+
fileMetaByDocId,
|
|
247
250
|
)
|
|
248
251
|
]);
|
|
249
252
|
|
|
@@ -152,7 +152,9 @@ export class SignalingState {
|
|
|
152
152
|
|
|
153
153
|
async pingPeers(message: SIGNAL) {
|
|
154
154
|
Array.from(this.peerBySenderId.values()).forEach(peer => {
|
|
155
|
-
peer.
|
|
155
|
+
if (peer.connected) {
|
|
156
|
+
peer.send(message);
|
|
157
|
+
}
|
|
156
158
|
});
|
|
157
159
|
}
|
|
158
160
|
|
|
@@ -203,6 +205,7 @@ export class SignalingState {
|
|
|
203
205
|
});
|
|
204
206
|
peer.on('connect', () => {
|
|
205
207
|
this._resync$.next();
|
|
208
|
+
peer.send('RESYNC');
|
|
206
209
|
});
|
|
207
210
|
peer.on('data', (dataBuffer: any) => {
|
|
208
211
|
const data = dataBuffer + '';
|
|
@@ -27,7 +27,8 @@ import {
|
|
|
27
27
|
clone,
|
|
28
28
|
randomToken,
|
|
29
29
|
deepEqual,
|
|
30
|
-
getFromMapOrCreate
|
|
30
|
+
getFromMapOrCreate,
|
|
31
|
+
promiseWait
|
|
31
32
|
} from '../utils/index.ts';
|
|
32
33
|
import {
|
|
33
34
|
RX_STATE_COLLECTION_SCHEMA,
|
|
@@ -148,7 +149,7 @@ export class RxStateBase<T, Reactivity = unknown> {
|
|
|
148
149
|
const ops: RxStateOperation[] = [];
|
|
149
150
|
for (let index = 0; index < useWrites.length; index++) {
|
|
150
151
|
const writeRow = useWrites[index];
|
|
151
|
-
const value = getProperty(newState, writeRow.path);
|
|
152
|
+
const value = writeRow.path === '' ? newState : getProperty(newState, writeRow.path);
|
|
152
153
|
const newValue = writeRow.modifier(value);
|
|
153
154
|
/**
|
|
154
155
|
* Here we have to clone the value because
|
|
@@ -182,6 +183,12 @@ export class RxStateBase<T, Reactivity = unknown> {
|
|
|
182
183
|
if ((err as RxError).code !== 'CONFLICT') {
|
|
183
184
|
throw err;
|
|
184
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Yield to the event loop so that cross-instance
|
|
188
|
+
* change events can be processed and the _lastIdQuery
|
|
189
|
+
* cache gets updated before retrying.
|
|
190
|
+
*/
|
|
191
|
+
await promiseWait(0);
|
|
185
192
|
}
|
|
186
193
|
}
|
|
187
194
|
}).catch(error => {
|
|
@@ -328,7 +335,7 @@ export async function createRxState<T>(
|
|
|
328
335
|
} else {
|
|
329
336
|
for (let index = 0; index < documents.length; index++) {
|
|
330
337
|
const document = documents[index];
|
|
331
|
-
mergeOperationsIntoState(rxState._state, document.ops);
|
|
338
|
+
rxState._state = mergeOperationsIntoState(rxState._state, document.ops);
|
|
332
339
|
}
|
|
333
340
|
}
|
|
334
341
|
}
|
|
@@ -378,9 +385,14 @@ export async function createRxState<T>(
|
|
|
378
385
|
export function mergeOperationsIntoState<T>(
|
|
379
386
|
state: T,
|
|
380
387
|
operations: RxStateOperation[]
|
|
381
|
-
) {
|
|
388
|
+
): T {
|
|
382
389
|
for (let index = 0; index < operations.length; index++) {
|
|
383
390
|
const operation = operations[index];
|
|
384
|
-
|
|
391
|
+
if (operation.k === '') {
|
|
392
|
+
state = clone(operation.v);
|
|
393
|
+
} else {
|
|
394
|
+
setProperty(state, operation.k, clone(operation.v));
|
|
395
|
+
}
|
|
385
396
|
}
|
|
397
|
+
return state;
|
|
386
398
|
}
|
|
@@ -5,10 +5,6 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
now,
|
|
7
7
|
ensureNotFalsy,
|
|
8
|
-
defaultHashSha256,
|
|
9
|
-
RXDB_UTILS_GLOBAL,
|
|
10
|
-
PREMIUM_FLAG_HASH,
|
|
11
|
-
hasPremiumFlag
|
|
12
8
|
} from '../utils/index.ts';
|
|
13
9
|
import type {
|
|
14
10
|
RxStorageInstance,
|
|
@@ -47,8 +43,6 @@ import { newRxError } from '../../rx-error.ts';
|
|
|
47
43
|
|
|
48
44
|
let instanceId = now();
|
|
49
45
|
|
|
50
|
-
let shownNonPremiumLog = false;
|
|
51
|
-
|
|
52
46
|
|
|
53
47
|
export class RxStorageInstanceDexie<RxDocType> implements RxStorageInstance<
|
|
54
48
|
RxDocType,
|
|
@@ -80,27 +74,6 @@ export class RxStorageInstanceDexie<RxDocType> implements RxStorageInstance<
|
|
|
80
74
|
): Promise<RxStorageBulkWriteResponse<RxDocType>> {
|
|
81
75
|
ensureNotClosed(this);
|
|
82
76
|
|
|
83
|
-
if (
|
|
84
|
-
!shownNonPremiumLog &&
|
|
85
|
-
!(await hasPremiumFlag())
|
|
86
|
-
) {
|
|
87
|
-
console.warn(
|
|
88
|
-
[
|
|
89
|
-
'-------------- RxDB Open Core RxStorage -------------------------------',
|
|
90
|
-
'You are using the free Dexie.js based RxStorage implementation from RxDB https://rxdb.info/rx-storage-dexie.html?console=dexie ',
|
|
91
|
-
'While this is a great option, we want to let you know that there are faster storage solutions available in our premium plugins.',
|
|
92
|
-
'For professional users and production environments, we highly recommend considering these premium options to enhance performance and reliability.',
|
|
93
|
-
' https://rxdb.info/premium/?console=dexie ',
|
|
94
|
-
'If you already purchased premium access you can disable this log by calling the setPremiumFlag() function from rxdb-premium/plugins/shared.',
|
|
95
|
-
'---------------------------------------------------------------------'
|
|
96
|
-
].join('\n')
|
|
97
|
-
);
|
|
98
|
-
shownNonPremiumLog = true;
|
|
99
|
-
} else {
|
|
100
|
-
shownNonPremiumLog = true;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
77
|
/**
|
|
105
78
|
* Check some assumptions to ensure RxDB
|
|
106
79
|
* does not call the storage with an invalid write.
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Optimized binary search functions for the memory storage.
|
|
3
|
+
* Based on https://github.com/mikolalysenko/binary-search-bounds
|
|
4
|
+
* but with performance improvements:
|
|
5
|
+
* - Removed unnecessary undefined checks for comparator
|
|
6
|
+
* - Inlined the norm() wrapper to avoid extra function calls
|
|
7
|
+
* - Added string-specialized variants to avoid temporary array allocations
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
10
|
type Compare<T> = ((a: T, b: T) => number | null | undefined);
|
|
12
11
|
|
|
13
|
-
function
|
|
12
|
+
export function boundGE<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {
|
|
13
|
+
let l: number = lo === undefined ? 0 : lo | 0;
|
|
14
|
+
let h: number = hi === undefined ? a.length - 1 : hi | 0;
|
|
14
15
|
let i: number = h + 1;
|
|
15
16
|
while (l <= h) {
|
|
16
17
|
const m = (l + h) >>> 1;
|
|
17
|
-
|
|
18
|
-
const p: any = (c !== undefined) ? c(x, y) : (x - (y as any));
|
|
19
|
-
if (p >= 0) {
|
|
18
|
+
if ((c(a[m], y) as number) >= 0) {
|
|
20
19
|
i = m; h = m - 1;
|
|
21
20
|
} else {
|
|
22
21
|
l = m + 1;
|
|
@@ -25,13 +24,13 @@ function ge<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {
|
|
|
25
24
|
return i;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
function
|
|
27
|
+
export function boundGT<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {
|
|
28
|
+
let l: number = lo === undefined ? 0 : lo | 0;
|
|
29
|
+
let h: number = hi === undefined ? a.length - 1 : hi | 0;
|
|
29
30
|
let i = h + 1;
|
|
30
31
|
while (l <= h) {
|
|
31
32
|
const m = (l + h) >>> 1;
|
|
32
|
-
|
|
33
|
-
const p: any = (c !== undefined) ? c(x, y) : ((x as any) - (y as any));
|
|
34
|
-
if (p > 0) {
|
|
33
|
+
if ((c(a[m], y) as number) > 0) {
|
|
35
34
|
i = m; h = m - 1;
|
|
36
35
|
} else {
|
|
37
36
|
l = m + 1;
|
|
@@ -40,12 +39,13 @@ function gt<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {
|
|
|
40
39
|
return i;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
function
|
|
42
|
+
export function boundLT<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {
|
|
43
|
+
let l: number = lo === undefined ? 0 : lo | 0;
|
|
44
|
+
let h: number = hi === undefined ? a.length - 1 : hi | 0;
|
|
44
45
|
let i = l - 1;
|
|
45
46
|
while (l <= h) {
|
|
46
|
-
const m = (l + h) >>> 1
|
|
47
|
-
|
|
48
|
-
if (p < 0) {
|
|
47
|
+
const m = (l + h) >>> 1;
|
|
48
|
+
if ((c(a[m], y) as number) < 0) {
|
|
49
49
|
i = m; l = m + 1;
|
|
50
50
|
} else {
|
|
51
51
|
h = m - 1;
|
|
@@ -54,12 +54,13 @@ function lt<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {
|
|
|
54
54
|
return i;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function
|
|
57
|
+
export function boundLE<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {
|
|
58
|
+
let l: number = lo === undefined ? 0 : lo | 0;
|
|
59
|
+
let h: number = hi === undefined ? a.length - 1 : hi | 0;
|
|
58
60
|
let i = l - 1;
|
|
59
61
|
while (l <= h) {
|
|
60
|
-
const m = (l + h) >>> 1
|
|
61
|
-
|
|
62
|
-
if (p <= 0) {
|
|
62
|
+
const m = (l + h) >>> 1;
|
|
63
|
+
if ((c(a[m], y) as number) <= 0) {
|
|
63
64
|
i = m; l = m + 1;
|
|
64
65
|
} else {
|
|
65
66
|
h = m - 1;
|
|
@@ -68,10 +69,12 @@ function le<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {
|
|
|
68
69
|
return i;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
function
|
|
72
|
+
export function boundEQ<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {
|
|
73
|
+
let l: number = lo === undefined ? 0 : lo | 0;
|
|
74
|
+
let h: number = hi === undefined ? a.length - 1 : hi | 0;
|
|
72
75
|
while (l <= h) {
|
|
73
|
-
const m = (l + h) >>> 1
|
|
74
|
-
const p
|
|
76
|
+
const m = (l + h) >>> 1;
|
|
77
|
+
const p = c(a[m], y) as number;
|
|
75
78
|
if (p === 0) {
|
|
76
79
|
return m;
|
|
77
80
|
}
|
|
@@ -84,23 +87,85 @@ function eq<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {
|
|
|
84
87
|
return -1;
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Specialized binary search functions that compare DocWithIndexString
|
|
92
|
+
* entries directly against an index string, avoiding temporary array allocations.
|
|
93
|
+
* Used in query() and count() hot paths.
|
|
94
|
+
*/
|
|
95
|
+
export function boundGEByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {
|
|
96
|
+
let l = 0;
|
|
97
|
+
let h = a.length - 1;
|
|
98
|
+
let i: number = h + 1;
|
|
99
|
+
while (l <= h) {
|
|
100
|
+
const m = (l + h) >>> 1;
|
|
101
|
+
if (a[m][0] >= indexString) {
|
|
102
|
+
i = m; h = m - 1;
|
|
103
|
+
} else {
|
|
104
|
+
l = m + 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return i;
|
|
89
108
|
}
|
|
90
109
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
110
|
+
export function boundGTByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {
|
|
111
|
+
let l = 0;
|
|
112
|
+
let h = a.length - 1;
|
|
113
|
+
let i = h + 1;
|
|
114
|
+
while (l <= h) {
|
|
115
|
+
const m = (l + h) >>> 1;
|
|
116
|
+
if (a[m][0] > indexString) {
|
|
117
|
+
i = m; h = m - 1;
|
|
118
|
+
} else {
|
|
119
|
+
l = m + 1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return i;
|
|
97
123
|
}
|
|
98
|
-
|
|
99
|
-
|
|
124
|
+
|
|
125
|
+
export function boundEQByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {
|
|
126
|
+
let l = 0;
|
|
127
|
+
let h = a.length - 1;
|
|
128
|
+
while (l <= h) {
|
|
129
|
+
const m = (l + h) >>> 1;
|
|
130
|
+
const s = a[m][0];
|
|
131
|
+
if (s === indexString) {
|
|
132
|
+
return m;
|
|
133
|
+
}
|
|
134
|
+
if (s < indexString) {
|
|
135
|
+
l = m + 1;
|
|
136
|
+
} else {
|
|
137
|
+
h = m - 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return -1;
|
|
100
141
|
}
|
|
101
|
-
|
|
102
|
-
|
|
142
|
+
|
|
143
|
+
export function boundLTByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {
|
|
144
|
+
let l = 0;
|
|
145
|
+
let h = a.length - 1;
|
|
146
|
+
let i = l - 1;
|
|
147
|
+
while (l <= h) {
|
|
148
|
+
const m = (l + h) >>> 1;
|
|
149
|
+
if (a[m][0] < indexString) {
|
|
150
|
+
i = m; l = m + 1;
|
|
151
|
+
} else {
|
|
152
|
+
h = m - 1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return i;
|
|
103
156
|
}
|
|
104
|
-
|
|
105
|
-
|
|
157
|
+
|
|
158
|
+
export function boundLEByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {
|
|
159
|
+
let l = 0;
|
|
160
|
+
let h = a.length - 1;
|
|
161
|
+
let i = l - 1;
|
|
162
|
+
while (l <= h) {
|
|
163
|
+
const m = (l + h) >>> 1;
|
|
164
|
+
if (a[m][0] <= indexString) {
|
|
165
|
+
i = m; l = m + 1;
|
|
166
|
+
} else {
|
|
167
|
+
h = m - 1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return i;
|
|
106
171
|
}
|