@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = exports.INTERNAL_STORAGE_NAME = void 0;
|
|
6
|
+
exports.RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = exports.RX_COLLECTION_BULK_INSERT_CONTEXT = exports.INTERNAL_STORAGE_NAME = void 0;
|
|
7
7
|
exports.attachmentWriteDataToNormalData = attachmentWriteDataToNormalData;
|
|
8
8
|
exports.categorizeBulkWriteRows = categorizeBulkWriteRows;
|
|
9
9
|
exports.ensureRxStorageInstanceParamsAreCorrect = ensureRxStorageInstanceParamsAreCorrect;
|
|
@@ -16,6 +16,7 @@ exports.getWrittenDocumentsFromBulkWriteResponse = getWrittenDocumentsFromBulkWr
|
|
|
16
16
|
exports.hasEncryption = hasEncryption;
|
|
17
17
|
exports.observeSingle = observeSingle;
|
|
18
18
|
exports.randomDelayStorage = randomDelayStorage;
|
|
19
|
+
exports.registerMutableWriteContext = registerMutableWriteContext;
|
|
19
20
|
exports.stackCheckpoints = stackCheckpoints;
|
|
20
21
|
exports.stripAttachmentsDataFromDocument = stripAttachmentsDataFromDocument;
|
|
21
22
|
exports.stripAttachmentsDataFromRow = stripAttachmentsDataFromRow;
|
|
@@ -24,7 +25,7 @@ exports.writeSingle = writeSingle;
|
|
|
24
25
|
var _overwritable = require("./overwritable.js");
|
|
25
26
|
var _rxError = require("./rx-error.js");
|
|
26
27
|
var _rxSchemaHelper = require("./rx-schema-helper.js");
|
|
27
|
-
var
|
|
28
|
+
var _index4 = require("./plugins/utils/index.js");
|
|
28
29
|
var _rxjs = require("rxjs");
|
|
29
30
|
var _rxQueryHelper = require("./rx-query-helper.js");
|
|
30
31
|
var _hooks = require("./hooks.js");
|
|
@@ -34,6 +35,35 @@ var _hooks = require("./hooks.js");
|
|
|
34
35
|
|
|
35
36
|
var INTERNAL_STORAGE_NAME = exports.INTERNAL_STORAGE_NAME = '_rxdb_internal';
|
|
36
37
|
var RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = exports.RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = 'rxdatabase_storage_local';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Context string used by RxCollection.bulkInsert().
|
|
41
|
+
* Documents written with this context are already cloned
|
|
42
|
+
* by fillObjectDataBeforeInsert(), so the wrapped storage
|
|
43
|
+
* can safely mutate them in place instead of cloning again.
|
|
44
|
+
*/
|
|
45
|
+
var RX_COLLECTION_BULK_INSERT_CONTEXT = exports.RX_COLLECTION_BULK_INSERT_CONTEXT = 'rx-collection-bulk-insert';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Set of bulkWrite context strings whose documents
|
|
49
|
+
* are already cloned by the caller and can be safely
|
|
50
|
+
* mutated in place (skip flatClone in the insert path).
|
|
51
|
+
*
|
|
52
|
+
* Plugins can register additional contexts via
|
|
53
|
+
* registerMutableWriteContext().
|
|
54
|
+
*/
|
|
55
|
+
var MUTABLE_DOCUMENT_WRITE_CONTEXTS = new Set([RX_COLLECTION_BULK_INSERT_CONTEXT]);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Register a bulkWrite context string as "mutable",
|
|
59
|
+
* meaning the caller guarantees that insert documents
|
|
60
|
+
* are already cloned and safe to mutate in place.
|
|
61
|
+
* This allows the wrapped storage to skip a redundant
|
|
62
|
+
* flatClone() call on the insert hot path.
|
|
63
|
+
*/
|
|
64
|
+
function registerMutableWriteContext(context) {
|
|
65
|
+
MUTABLE_DOCUMENT_WRITE_CONTEXTS.add(context);
|
|
66
|
+
}
|
|
37
67
|
async function getSingleDocument(storageInstance, documentId) {
|
|
38
68
|
var results = await storageInstance.findDocumentsById([documentId], false);
|
|
39
69
|
var doc = results[0];
|
|
@@ -67,7 +97,7 @@ async function writeSingle(instance, writeRow, context) {
|
|
|
67
97
|
*/
|
|
68
98
|
function observeSingle(storageInstance, documentId) {
|
|
69
99
|
var firstFindPromise = getSingleDocument(storageInstance, documentId);
|
|
70
|
-
var ret = storageInstance.changeStream().pipe((0, _rxjs.map)(evBulk => evBulk.events.find(ev => ev.documentId === documentId)), (0, _rxjs.filter)(ev => !!ev), (0, _rxjs.map)(ev => Promise.resolve((0,
|
|
100
|
+
var ret = storageInstance.changeStream().pipe((0, _rxjs.map)(evBulk => evBulk.events.find(ev => ev.documentId === documentId)), (0, _rxjs.filter)(ev => !!ev), (0, _rxjs.map)(ev => Promise.resolve((0, _index4.ensureNotFalsy)(ev).documentData)), (0, _rxjs.startWith)(firstFindPromise), (0, _rxjs.switchMap)(v => v), (0, _rxjs.filter)(v => !!v));
|
|
71
101
|
return ret;
|
|
72
102
|
}
|
|
73
103
|
|
|
@@ -106,7 +136,7 @@ function throwIfIsStorageWriteError(collection, documentId, writeData, error) {
|
|
|
106
136
|
* Use a counter-based event bulk ID instead of randomToken()
|
|
107
137
|
* for better performance. The prefix ensures uniqueness across instances.
|
|
108
138
|
*/
|
|
109
|
-
var EVENT_BULK_ID_PREFIX = (0,
|
|
139
|
+
var EVENT_BULK_ID_PREFIX = (0, _index4.randomToken)(10);
|
|
110
140
|
var eventBulkCounter = 0;
|
|
111
141
|
function nextEventBulkId() {
|
|
112
142
|
return EVENT_BULK_ID_PREFIX + ++eventBulkCounter;
|
|
@@ -160,7 +190,7 @@ onInsert, onUpdate) {
|
|
|
160
190
|
* @performance is really important in this loop!
|
|
161
191
|
*/
|
|
162
192
|
var rowAmount = bulkWriteRows.length;
|
|
163
|
-
var
|
|
193
|
+
for (var rowId = 0; rowId < rowAmount; rowId++) {
|
|
164
194
|
var writeRow = bulkWriteRows[rowId];
|
|
165
195
|
|
|
166
196
|
// use these variables to have less property accesses
|
|
@@ -173,15 +203,18 @@ onInsert, onUpdate) {
|
|
|
173
203
|
if (hasDocsInDb) {
|
|
174
204
|
documentInDb = docsInDb.get(docId);
|
|
175
205
|
}
|
|
176
|
-
var attachmentError;
|
|
206
|
+
var attachmentError = void 0;
|
|
177
207
|
if (!documentInDb) {
|
|
178
208
|
/**
|
|
179
209
|
* It is possible to insert already deleted documents,
|
|
180
210
|
* this can happen on replication.
|
|
181
211
|
*/
|
|
182
|
-
var insertedIsDeleted = documentDeleted ? true : false;
|
|
183
212
|
if (hasAttachments) {
|
|
184
|
-
|
|
213
|
+
var atts = document._attachments;
|
|
214
|
+
var attKeys = Object.keys(atts);
|
|
215
|
+
for (var a = 0; a < attKeys.length; a++) {
|
|
216
|
+
var attachmentId = attKeys[a];
|
|
217
|
+
var attachmentData = atts[attachmentId];
|
|
185
218
|
if (!attachmentData.data) {
|
|
186
219
|
attachmentError = {
|
|
187
220
|
documentId: docId,
|
|
@@ -200,27 +233,27 @@ onInsert, onUpdate) {
|
|
|
200
233
|
digest: attachmentData.digest
|
|
201
234
|
});
|
|
202
235
|
}
|
|
203
|
-
}
|
|
236
|
+
}
|
|
204
237
|
}
|
|
238
|
+
var insertedRow = void 0;
|
|
205
239
|
if (!attachmentError) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
} else {
|
|
212
|
-
bulkInsertDocs.push(writeRow);
|
|
213
|
-
if (onInsert) {
|
|
214
|
-
onInsert(document);
|
|
215
|
-
}
|
|
240
|
+
var row = hasAttachments ? stripAttachmentsDataFromRow(writeRow) : writeRow;
|
|
241
|
+
insertedRow = row;
|
|
242
|
+
bulkInsertDocs.push(row);
|
|
243
|
+
if (onInsert) {
|
|
244
|
+
onInsert(document);
|
|
216
245
|
}
|
|
217
|
-
newestRow =
|
|
246
|
+
newestRow = row;
|
|
218
247
|
}
|
|
219
|
-
if (!
|
|
248
|
+
if (!documentDeleted) {
|
|
249
|
+
var eventDocData = document;
|
|
250
|
+
if (hasAttachments) {
|
|
251
|
+
eventDocData = insertedRow ? insertedRow.document : stripAttachmentsDataFromDocument(document);
|
|
252
|
+
}
|
|
220
253
|
var event = {
|
|
221
254
|
documentId: docId,
|
|
222
255
|
operation: 'INSERT',
|
|
223
|
-
documentData:
|
|
256
|
+
documentData: eventDocData,
|
|
224
257
|
previousDocumentData: hasAttachments && previous ? stripAttachmentsDataFromDocument(previous) : previous
|
|
225
258
|
};
|
|
226
259
|
eventBulkEvents.push(event);
|
|
@@ -243,7 +276,7 @@ onInsert, onUpdate) {
|
|
|
243
276
|
context
|
|
244
277
|
};
|
|
245
278
|
errors.push(err);
|
|
246
|
-
|
|
279
|
+
continue;
|
|
247
280
|
}
|
|
248
281
|
|
|
249
282
|
// handle attachments data
|
|
@@ -255,90 +288,100 @@ onInsert, onUpdate) {
|
|
|
255
288
|
* Deleted documents must have cleared all their attachments.
|
|
256
289
|
*/
|
|
257
290
|
if (previous) {
|
|
258
|
-
|
|
291
|
+
var prevAtts = previous._attachments;
|
|
292
|
+
var prevAttKeys = Object.keys(prevAtts);
|
|
293
|
+
for (var _a = 0; _a < prevAttKeys.length; _a++) {
|
|
294
|
+
var _attachmentId = prevAttKeys[_a];
|
|
259
295
|
attachmentsRemove.push({
|
|
260
296
|
documentId: docId,
|
|
261
|
-
attachmentId,
|
|
262
|
-
digest:
|
|
297
|
+
attachmentId: _attachmentId,
|
|
298
|
+
digest: prevAtts[_attachmentId].digest
|
|
263
299
|
});
|
|
264
|
-
}
|
|
300
|
+
}
|
|
265
301
|
}
|
|
266
302
|
} else {
|
|
267
303
|
// first check for errors
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
304
|
+
var docAtts = document._attachments;
|
|
305
|
+
var docAttKeys = Object.keys(docAtts);
|
|
306
|
+
for (var _a2 = 0; _a2 < docAttKeys.length; _a2++) {
|
|
307
|
+
var _attachmentId2 = docAttKeys[_a2];
|
|
308
|
+
var _attachmentData = docAtts[_attachmentId2];
|
|
309
|
+
var previousAttachmentData = previous ? previous._attachments[_attachmentId2] : undefined;
|
|
310
|
+
if (!previousAttachmentData && !_attachmentData.data) {
|
|
271
311
|
attachmentError = {
|
|
272
312
|
documentId: docId,
|
|
273
313
|
documentInDb: documentInDb,
|
|
274
314
|
isError: true,
|
|
275
315
|
status: 510,
|
|
276
316
|
writeRow,
|
|
277
|
-
attachmentId,
|
|
317
|
+
attachmentId: _attachmentId2,
|
|
278
318
|
context
|
|
279
319
|
};
|
|
320
|
+
break;
|
|
280
321
|
}
|
|
281
|
-
|
|
282
|
-
});
|
|
322
|
+
}
|
|
283
323
|
if (!attachmentError) {
|
|
284
|
-
|
|
285
|
-
var
|
|
286
|
-
|
|
324
|
+
for (var _a3 = 0; _a3 < docAttKeys.length; _a3++) {
|
|
325
|
+
var _attachmentId3 = docAttKeys[_a3];
|
|
326
|
+
var _attachmentData2 = docAtts[_attachmentId3];
|
|
327
|
+
var _previousAttachmentData = previous ? previous._attachments[_attachmentId3] : undefined;
|
|
328
|
+
if (!_previousAttachmentData) {
|
|
287
329
|
attachmentsAdd.push({
|
|
288
330
|
documentId: docId,
|
|
289
|
-
attachmentId,
|
|
290
|
-
attachmentData:
|
|
291
|
-
digest:
|
|
331
|
+
attachmentId: _attachmentId3,
|
|
332
|
+
attachmentData: _attachmentData2,
|
|
333
|
+
digest: _attachmentData2.digest
|
|
292
334
|
});
|
|
293
335
|
} else {
|
|
294
|
-
var newDigest = updatedRow.document._attachments[
|
|
295
|
-
if (
|
|
336
|
+
var newDigest = updatedRow.document._attachments[_attachmentId3].digest;
|
|
337
|
+
if (_attachmentData2.data &&
|
|
296
338
|
/**
|
|
297
339
|
* Performance shortcut,
|
|
298
340
|
* do not update the attachment data if it did not change.
|
|
299
341
|
*/
|
|
300
|
-
|
|
342
|
+
_previousAttachmentData.digest !== newDigest) {
|
|
301
343
|
attachmentsUpdate.push({
|
|
302
344
|
documentId: docId,
|
|
303
|
-
attachmentId,
|
|
304
|
-
attachmentData:
|
|
305
|
-
digest:
|
|
345
|
+
attachmentId: _attachmentId3,
|
|
346
|
+
attachmentData: _attachmentData2,
|
|
347
|
+
digest: _attachmentData2.digest
|
|
306
348
|
});
|
|
307
349
|
}
|
|
308
350
|
}
|
|
309
|
-
}
|
|
351
|
+
}
|
|
310
352
|
}
|
|
311
353
|
}
|
|
312
354
|
}
|
|
313
355
|
if (attachmentError) {
|
|
314
356
|
errors.push(attachmentError);
|
|
315
357
|
} else {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (onUpdate) {
|
|
324
|
-
onUpdate(document);
|
|
325
|
-
}
|
|
358
|
+
/**
|
|
359
|
+
* updatedRow already has attachments stripped (line above),
|
|
360
|
+
* so push it directly without stripping again.
|
|
361
|
+
*/
|
|
362
|
+
bulkUpdateDocs.push(updatedRow);
|
|
363
|
+
if (onUpdate) {
|
|
364
|
+
onUpdate(document);
|
|
326
365
|
}
|
|
327
366
|
newestRow = updatedRow;
|
|
328
367
|
}
|
|
329
|
-
var eventDocumentData;
|
|
368
|
+
var eventDocumentData = void 0;
|
|
330
369
|
var previousEventDocumentData = null;
|
|
331
|
-
var operation;
|
|
370
|
+
var operation = void 0;
|
|
332
371
|
if (previousDeleted && !documentDeleted) {
|
|
333
372
|
operation = 'INSERT';
|
|
334
|
-
|
|
373
|
+
/**
|
|
374
|
+
* Reuse the already-stripped document from updatedRow
|
|
375
|
+
* instead of calling stripAttachmentsDataFromDocument() again.
|
|
376
|
+
*/
|
|
377
|
+
eventDocumentData = hasAttachments ? updatedRow.document : document;
|
|
335
378
|
} else if (previous && !previousDeleted && !documentDeleted) {
|
|
336
379
|
operation = 'UPDATE';
|
|
337
|
-
eventDocumentData = hasAttachments ?
|
|
380
|
+
eventDocumentData = hasAttachments ? updatedRow.document : document;
|
|
338
381
|
previousEventDocumentData = previous;
|
|
339
382
|
} else if (documentDeleted) {
|
|
340
383
|
operation = 'DELETE';
|
|
341
|
-
eventDocumentData = (0,
|
|
384
|
+
eventDocumentData = (0, _index4.ensureNotFalsy)(document);
|
|
342
385
|
previousEventDocumentData = previous;
|
|
343
386
|
} else {
|
|
344
387
|
throw (0, _rxError.newRxError)('SNH', {
|
|
@@ -355,9 +398,6 @@ onInsert, onUpdate) {
|
|
|
355
398
|
};
|
|
356
399
|
eventBulkEvents.push(_event);
|
|
357
400
|
}
|
|
358
|
-
};
|
|
359
|
-
for (var rowId = 0; rowId < rowAmount; rowId++) {
|
|
360
|
-
if (_loop()) continue;
|
|
361
401
|
}
|
|
362
402
|
return {
|
|
363
403
|
bulkInsertDocs,
|
|
@@ -409,11 +449,14 @@ function stripAttachmentsDataFromDocument(doc) {
|
|
|
409
449
|
if (!hasAnyAttachment) {
|
|
410
450
|
return doc;
|
|
411
451
|
}
|
|
412
|
-
var useDoc = (0,
|
|
413
|
-
|
|
414
|
-
Object.
|
|
415
|
-
|
|
416
|
-
|
|
452
|
+
var useDoc = (0, _index4.flatClone)(doc);
|
|
453
|
+
var destAtts = {};
|
|
454
|
+
var attKeys = Object.keys(atts);
|
|
455
|
+
for (var i = 0; i < attKeys.length; i++) {
|
|
456
|
+
var attachmentId = attKeys[i];
|
|
457
|
+
destAtts[attachmentId] = attachmentWriteDataToNormalData(atts[attachmentId]);
|
|
458
|
+
}
|
|
459
|
+
useDoc._attachments = destAtts;
|
|
417
460
|
return useDoc;
|
|
418
461
|
}
|
|
419
462
|
|
|
@@ -424,9 +467,12 @@ function stripAttachmentsDataFromDocument(doc) {
|
|
|
424
467
|
* during replication etc.
|
|
425
468
|
*/
|
|
426
469
|
function flatCloneDocWithMeta(doc) {
|
|
427
|
-
return
|
|
428
|
-
|
|
429
|
-
|
|
470
|
+
return {
|
|
471
|
+
...doc,
|
|
472
|
+
_meta: {
|
|
473
|
+
...doc._meta
|
|
474
|
+
}
|
|
475
|
+
};
|
|
430
476
|
}
|
|
431
477
|
/**
|
|
432
478
|
* Wraps the normal storageInstance of a RxCollection
|
|
@@ -451,43 +497,80 @@ rxJsonSchema) {
|
|
|
451
497
|
options: storageInstance.options,
|
|
452
498
|
async bulkWrite(rows, context) {
|
|
453
499
|
var databaseToken = database.token;
|
|
454
|
-
var toStorageWriteRows = new Array(rows.length);
|
|
455
500
|
/**
|
|
456
501
|
* Use the same timestamp for all docs of this rows-set.
|
|
457
502
|
* This improves performance because calling Date.now() inside of the now() function
|
|
458
503
|
* is too costly.
|
|
459
504
|
*/
|
|
460
|
-
var time = (0,
|
|
505
|
+
var time = (0, _index4.now)();
|
|
461
506
|
/**
|
|
462
507
|
* Pre-compute the first revision string for inserts (no previous document).
|
|
463
508
|
* This avoids repeated string concatenation and getHeightOfRevision() calls
|
|
464
509
|
* inside the hot loop.
|
|
465
510
|
*/
|
|
466
511
|
var firstRevision = '1-' + databaseToken;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
512
|
+
/**
|
|
513
|
+
* Share a single _meta object for all insert rows in this batch.
|
|
514
|
+
* All inserts in the same bulkWrite share the same timestamp,
|
|
515
|
+
* so we avoid creating a new { lwt: time } object per row.
|
|
516
|
+
* This shared reference is safe because:
|
|
517
|
+
* - All documents in one batch receive identical metadata values.
|
|
518
|
+
* - When a document is later updated, flatCloneDocWithMeta() creates
|
|
519
|
+
* a new _meta object, so the shared reference is never mutated.
|
|
520
|
+
*/
|
|
521
|
+
var insertMeta = {
|
|
522
|
+
lwt: time
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* When the caller has already cloned the documents (registered
|
|
527
|
+
* via MUTABLE_DOCUMENT_WRITE_CONTEXTS), we can mutate them
|
|
528
|
+
* in place and reuse the input array, avoiding redundant
|
|
529
|
+
* flatClone() and wrapper-object allocations on every insert row.
|
|
530
|
+
*/
|
|
531
|
+
var isMutableContext = MUTABLE_DOCUMENT_WRITE_CONTEXTS.has(context);
|
|
532
|
+
var toStorageWriteRows;
|
|
533
|
+
if (isMutableContext) {
|
|
534
|
+
/**
|
|
535
|
+
* Fast path: documents are already cloned by the caller.
|
|
536
|
+
* Set _meta/_rev directly on the document and reuse the
|
|
537
|
+
* input rows array without allocating wrapper objects.
|
|
538
|
+
*/
|
|
539
|
+
for (var index = 0; index < rows.length; index++) {
|
|
540
|
+
var document = rows[index].document;
|
|
541
|
+
document._meta = insertMeta;
|
|
485
542
|
document._rev = firstRevision;
|
|
486
543
|
}
|
|
487
|
-
toStorageWriteRows
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
544
|
+
toStorageWriteRows = rows;
|
|
545
|
+
} else {
|
|
546
|
+
toStorageWriteRows = new Array(rows.length);
|
|
547
|
+
for (var _index = 0; _index < rows.length; _index++) {
|
|
548
|
+
var writeRow = rows[_index];
|
|
549
|
+
var previous = writeRow.previous;
|
|
550
|
+
var _document = void 0;
|
|
551
|
+
if (previous) {
|
|
552
|
+
_document = flatCloneDocWithMeta(writeRow.document);
|
|
553
|
+
_document._meta.lwt = time;
|
|
554
|
+
_document._rev = (0, _index4.createRevision)(databaseToken, previous);
|
|
555
|
+
} else {
|
|
556
|
+
/**
|
|
557
|
+
* Insert path: flatClone is required because the input document
|
|
558
|
+
* may be a direct reference to another storage's internal data
|
|
559
|
+
* (e.g., during migration, query results from the old storage are
|
|
560
|
+
* passed directly as insert rows to the new storage).
|
|
561
|
+
*
|
|
562
|
+
* Use a shared insertMeta object instead of allocating { lwt: time }
|
|
563
|
+
* per row, since all inserts in the same batch share the same timestamp.
|
|
564
|
+
*/
|
|
565
|
+
_document = (0, _index4.flatClone)(writeRow.document);
|
|
566
|
+
_document._meta = insertMeta;
|
|
567
|
+
_document._rev = firstRevision;
|
|
568
|
+
}
|
|
569
|
+
toStorageWriteRows[_index] = {
|
|
570
|
+
document: _document,
|
|
571
|
+
previous
|
|
572
|
+
};
|
|
573
|
+
}
|
|
491
574
|
}
|
|
492
575
|
if (_hooks.HOOKS.preStorageWrite.length > 0) {
|
|
493
576
|
(0, _hooks.runPluginHooks)('preStorageWrite', {
|
|
@@ -522,7 +605,7 @@ rxJsonSchema) {
|
|
|
522
605
|
// No need to check writeResult.error.length === 0 here because
|
|
523
606
|
// the fast path above already returns early when there are no errors.
|
|
524
607
|
var reInsertErrors = writeResult.error.filter(error => {
|
|
525
|
-
if (error.status === 409 && !error.writeRow.previous && !error.writeRow.document._deleted && (0,
|
|
608
|
+
if (error.status === 409 && !error.writeRow.previous && !error.writeRow.document._deleted && (0, _index4.ensureNotFalsy)(error.documentInDb)._deleted) {
|
|
526
609
|
return true;
|
|
527
610
|
}
|
|
528
611
|
|
|
@@ -537,7 +620,7 @@ rxJsonSchema) {
|
|
|
537
620
|
return {
|
|
538
621
|
previous: error.documentInDb,
|
|
539
622
|
document: Object.assign({}, error.writeRow.document, {
|
|
540
|
-
_rev: (0,
|
|
623
|
+
_rev: (0, _index4.createRevision)(database.token, error.documentInDb)
|
|
541
624
|
})
|
|
542
625
|
};
|
|
543
626
|
});
|
|
@@ -563,7 +646,7 @@ rxJsonSchema) {
|
|
|
563
646
|
return database.lockedRun(() => storageInstance.getAttachmentData(documentId, attachmentId, digest));
|
|
564
647
|
},
|
|
565
648
|
getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : (limit, checkpoint) => {
|
|
566
|
-
return database.lockedRun(() => storageInstance.getChangedDocumentsSince((0,
|
|
649
|
+
return database.lockedRun(() => storageInstance.getChangedDocumentsSince((0, _index4.ensureNotFalsy)(limit), checkpoint));
|
|
567
650
|
},
|
|
568
651
|
cleanup(minDeletedTime) {
|
|
569
652
|
return database.lockedRun(() => storageInstance.cleanup(minDeletedTime));
|
|
@@ -621,7 +704,7 @@ function hasEncryption(jsonSchema) {
|
|
|
621
704
|
}
|
|
622
705
|
function getChangedDocumentsSinceQuery(storageInstance, limit, checkpoint) {
|
|
623
706
|
var primaryPath = (0, _rxSchemaHelper.getPrimaryFieldOfPrimaryKey)(storageInstance.schema.primaryKey);
|
|
624
|
-
var sinceLwt = checkpoint ? checkpoint.lwt :
|
|
707
|
+
var sinceLwt = checkpoint ? checkpoint.lwt : _index4.RX_META_LWT_MINIMUM;
|
|
625
708
|
var sinceId = checkpoint ? checkpoint.id : '';
|
|
626
709
|
return (0, _rxQueryHelper.normalizeMangoQuery)(storageInstance.schema, {
|
|
627
710
|
selector: {
|
|
@@ -667,7 +750,7 @@ async function getChangedDocumentsSince(storageInstance, limit, checkpoint) {
|
|
|
667
750
|
var query = (0, _rxQueryHelper.prepareQuery)(storageInstance.schema, getChangedDocumentsSinceQuery(storageInstance, limit, checkpoint));
|
|
668
751
|
var result = await storageInstance.query(query);
|
|
669
752
|
var documents = result.documents;
|
|
670
|
-
var lastDoc = (0,
|
|
753
|
+
var lastDoc = (0, _index4.lastOfArray)(documents);
|
|
671
754
|
return {
|
|
672
755
|
documents: documents,
|
|
673
756
|
checkpoint: lastDoc ? {
|
|
@@ -687,7 +770,7 @@ var BULK_WRITE_SUCCESS_MAP = new WeakMap();
|
|
|
687
770
|
* because most of the time we do not need the results, only the errors.
|
|
688
771
|
*/
|
|
689
772
|
function getWrittenDocumentsFromBulkWriteResponse(primaryPath, writeRows, response, reInsertIds) {
|
|
690
|
-
return (0,
|
|
773
|
+
return (0, _index4.getFromMapOrCreate)(BULK_WRITE_SUCCESS_MAP, response, () => {
|
|
691
774
|
var ret = [];
|
|
692
775
|
var realWriteRows = BULK_WRITE_ROWS_BY_RESPONSE.get(response);
|
|
693
776
|
if (!realWriteRows) {
|
|
@@ -699,8 +782,8 @@ function getWrittenDocumentsFromBulkWriteResponse(primaryPath, writeRows, respon
|
|
|
699
782
|
var error = response.error[index];
|
|
700
783
|
errorIds.add(error.documentId);
|
|
701
784
|
}
|
|
702
|
-
for (var
|
|
703
|
-
var doc = realWriteRows[
|
|
785
|
+
for (var _index2 = 0; _index2 < realWriteRows.length; _index2++) {
|
|
786
|
+
var doc = realWriteRows[_index2].document;
|
|
704
787
|
if (!errorIds.has(doc[primaryPath])) {
|
|
705
788
|
ret.push(stripAttachmentsDataFromDocument(doc));
|
|
706
789
|
}
|
|
@@ -708,9 +791,9 @@ function getWrittenDocumentsFromBulkWriteResponse(primaryPath, writeRows, respon
|
|
|
708
791
|
} else {
|
|
709
792
|
// pre-set array size for better performance
|
|
710
793
|
ret.length = writeRows.length - response.error.length;
|
|
711
|
-
for (var
|
|
712
|
-
var _doc = realWriteRows[
|
|
713
|
-
ret[
|
|
794
|
+
for (var _index3 = 0; _index3 < realWriteRows.length; _index3++) {
|
|
795
|
+
var _doc = realWriteRows[_index3].document;
|
|
796
|
+
ret[_index3] = stripAttachmentsDataFromDocument(_doc);
|
|
714
797
|
}
|
|
715
798
|
}
|
|
716
799
|
return ret;
|
|
@@ -726,14 +809,14 @@ function randomDelayStorage(input) {
|
|
|
726
809
|
* Ensure writes to a delay storage
|
|
727
810
|
* are still correctly run in order.
|
|
728
811
|
*/
|
|
729
|
-
var randomDelayStorageWriteQueue =
|
|
812
|
+
var randomDelayStorageWriteQueue = _index4.PROMISE_RESOLVE_TRUE;
|
|
730
813
|
var retStorage = {
|
|
731
814
|
name: 'random-delay-' + input.storage.name,
|
|
732
|
-
rxdbVersion:
|
|
815
|
+
rxdbVersion: _index4.RXDB_VERSION,
|
|
733
816
|
async createStorageInstance(params) {
|
|
734
|
-
await (0,
|
|
817
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
735
818
|
var storageInstance = await input.storage.createStorageInstance(params);
|
|
736
|
-
await (0,
|
|
819
|
+
await (0, _index4.promiseWait)(input.delayTimeAfter());
|
|
737
820
|
return {
|
|
738
821
|
databaseName: storageInstance.databaseName,
|
|
739
822
|
internals: storageInstance.internals,
|
|
@@ -742,62 +825,62 @@ function randomDelayStorage(input) {
|
|
|
742
825
|
collectionName: storageInstance.collectionName,
|
|
743
826
|
bulkWrite(a, b) {
|
|
744
827
|
randomDelayStorageWriteQueue = randomDelayStorageWriteQueue.then(async () => {
|
|
745
|
-
await (0,
|
|
828
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
746
829
|
var response = await storageInstance.bulkWrite(a, b);
|
|
747
|
-
await (0,
|
|
830
|
+
await (0, _index4.promiseWait)(input.delayTimeAfter());
|
|
748
831
|
return response;
|
|
749
832
|
});
|
|
750
833
|
var ret = randomDelayStorageWriteQueue;
|
|
751
834
|
return ret;
|
|
752
835
|
},
|
|
753
836
|
async findDocumentsById(a, b) {
|
|
754
|
-
await (0,
|
|
837
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
755
838
|
var ret = await storageInstance.findDocumentsById(a, b);
|
|
756
|
-
await (0,
|
|
839
|
+
await (0, _index4.promiseWait)(input.delayTimeAfter());
|
|
757
840
|
return ret;
|
|
758
841
|
},
|
|
759
842
|
async query(a) {
|
|
760
|
-
await (0,
|
|
843
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
761
844
|
var ret = await storageInstance.query(a);
|
|
762
845
|
return ret;
|
|
763
846
|
},
|
|
764
847
|
async count(a) {
|
|
765
|
-
await (0,
|
|
848
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
766
849
|
var ret = await storageInstance.count(a);
|
|
767
|
-
await (0,
|
|
850
|
+
await (0, _index4.promiseWait)(input.delayTimeAfter());
|
|
768
851
|
return ret;
|
|
769
852
|
},
|
|
770
853
|
async getAttachmentData(a, b, c) {
|
|
771
|
-
await (0,
|
|
854
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
772
855
|
var ret = await storageInstance.getAttachmentData(a, b, c);
|
|
773
|
-
await (0,
|
|
856
|
+
await (0, _index4.promiseWait)(input.delayTimeAfter());
|
|
774
857
|
return ret;
|
|
775
858
|
},
|
|
776
859
|
getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : async (a, b) => {
|
|
777
|
-
await (0,
|
|
778
|
-
var ret = await (0,
|
|
779
|
-
await (0,
|
|
860
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
861
|
+
var ret = await (0, _index4.ensureNotFalsy)(storageInstance.getChangedDocumentsSince)(a, b);
|
|
862
|
+
await (0, _index4.promiseWait)(input.delayTimeAfter());
|
|
780
863
|
return ret;
|
|
781
864
|
},
|
|
782
865
|
changeStream() {
|
|
783
866
|
return storageInstance.changeStream();
|
|
784
867
|
},
|
|
785
868
|
async cleanup(a) {
|
|
786
|
-
await (0,
|
|
869
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
787
870
|
var ret = await storageInstance.cleanup(a);
|
|
788
|
-
await (0,
|
|
871
|
+
await (0, _index4.promiseWait)(input.delayTimeAfter());
|
|
789
872
|
return ret;
|
|
790
873
|
},
|
|
791
874
|
async close() {
|
|
792
|
-
await (0,
|
|
875
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
793
876
|
var ret = await storageInstance.close();
|
|
794
|
-
await (0,
|
|
877
|
+
await (0, _index4.promiseWait)(input.delayTimeAfter());
|
|
795
878
|
return ret;
|
|
796
879
|
},
|
|
797
880
|
async remove() {
|
|
798
|
-
await (0,
|
|
881
|
+
await (0, _index4.promiseWait)(input.delayTimeBefore());
|
|
799
882
|
var ret = await storageInstance.remove();
|
|
800
|
-
await (0,
|
|
883
|
+
await (0, _index4.promiseWait)(input.delayTimeAfter());
|
|
801
884
|
return ret;
|
|
802
885
|
}
|
|
803
886
|
};
|