@connecttomahdi/rxdb 17.0.0-beta.17 → 17.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -0
- package/CHANGELOG.md +47 -4
- package/CLAUDE.md +2 -0
- package/dist/cjs/change-event-buffer.js +2 -1
- package/dist/cjs/change-event-buffer.js.map +1 -1
- package/dist/cjs/custom-index.js +85 -12
- package/dist/cjs/custom-index.js.map +1 -1
- package/dist/cjs/doc-cache.js +117 -35
- package/dist/cjs/doc-cache.js.map +1 -1
- package/dist/cjs/event-reduce.js +10 -1
- package/dist/cjs/event-reduce.js.map +1 -1
- package/dist/cjs/plugin-helpers.js +16 -0
- package/dist/cjs/plugin-helpers.js.map +1 -1
- package/dist/cjs/plugins/attachments/index.js +3 -3
- package/dist/cjs/plugins/attachments/index.js.map +1 -1
- package/dist/cjs/plugins/cleanup/cleanup.js +5 -3
- package/dist/cjs/plugins/cleanup/cleanup.js.map +1 -1
- package/dist/cjs/plugins/crdt/index.js +52 -0
- package/dist/cjs/plugins/crdt/index.js.map +1 -1
- package/dist/cjs/plugins/dev-mode/check-query.js +7 -1
- package/dist/cjs/plugins/dev-mode/check-query.js.map +1 -1
- package/dist/cjs/plugins/dev-mode/check-schema.js +2 -1
- package/dist/cjs/plugins/dev-mode/check-schema.js.map +1 -1
- package/dist/cjs/plugins/dev-mode/error-messages.js +43 -5
- package/dist/cjs/plugins/dev-mode/error-messages.js.map +1 -1
- package/dist/cjs/plugins/encryption-crypto-js/index.js +22 -6
- package/dist/cjs/plugins/encryption-crypto-js/index.js.map +1 -1
- package/dist/cjs/plugins/leader-election/index.js +5 -5
- package/dist/cjs/plugins/leader-election/index.js.map +1 -1
- package/dist/cjs/plugins/local-documents/local-documents.js +20 -13
- package/dist/cjs/plugins/local-documents/local-documents.js.map +1 -1
- package/dist/cjs/plugins/migration-schema/migration-helpers.js +3 -0
- package/dist/cjs/plugins/migration-schema/migration-helpers.js.map +1 -1
- package/dist/cjs/plugins/migration-schema/rx-migration-state.js +1 -1
- package/dist/cjs/plugins/migration-schema/rx-migration-state.js.map +1 -1
- package/dist/cjs/plugins/pipeline/rx-pipeline.js +5 -1
- package/dist/cjs/plugins/pipeline/rx-pipeline.js.map +1 -1
- package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js +4 -2
- package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -1
- package/dist/cjs/plugins/replication/index.js +40 -2
- package/dist/cjs/plugins/replication/index.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/document-handling.js +17 -6
- package/dist/cjs/plugins/replication-google-drive/document-handling.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js +1 -1
- package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/google-drive-types.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/signaling.js +4 -1
- package/dist/cjs/plugins/replication-google-drive/signaling.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/upstream.js +7 -4
- package/dist/cjs/plugins/replication-google-drive/upstream.js.map +1 -1
- package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js +4 -1
- package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js.map +1 -1
- package/dist/cjs/plugins/state/rx-state.js +14 -3
- package/dist/cjs/plugins/state/rx-state.js.map +1 -1
- package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js +10 -17
- package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/binary-search-bounds.js +112 -40
- package/dist/cjs/plugins/storage-memory/binary-search-bounds.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/memory-helper.js +127 -40
- package/dist/cjs/plugins/storage-memory/memory-helper.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/memory-indexes.js +1 -0
- package/dist/cjs/plugins/storage-memory/memory-indexes.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/memory-types.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js +97 -37
- package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -1
- package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js +42 -1
- package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js.map +1 -1
- package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js +7 -7
- package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -1
- package/dist/cjs/plugins/test-utils/config.js +1 -1
- package/dist/cjs/plugins/test-utils/config.js.map +1 -1
- package/dist/cjs/plugins/test-utils/performance.js +122 -92
- package/dist/cjs/plugins/test-utils/performance.js.map +1 -1
- package/dist/cjs/plugins/test-utils/schema-objects.js +1 -1
- package/dist/cjs/plugins/test-utils/schema-objects.js.map +1 -1
- package/dist/cjs/plugins/test-utils/test-util.js +62 -0
- package/dist/cjs/plugins/test-utils/test-util.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-map.js +2 -2
- package/dist/cjs/plugins/utils/utils-map.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-object-deep-equal.js +3 -2
- package/dist/cjs/plugins/utils/utils-object-deep-equal.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-object-dot-prop.js +25 -0
- package/dist/cjs/plugins/utils/utils-object-dot-prop.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-object.js +102 -27
- package/dist/cjs/plugins/utils/utils-object.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-other.js +9 -4
- package/dist/cjs/plugins/utils/utils-other.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-premium.js +1 -19
- package/dist/cjs/plugins/utils/utils-premium.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-revision.js +20 -10
- package/dist/cjs/plugins/utils/utils-revision.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-rxdb-version.js +1 -1
- package/dist/cjs/plugins/utils/utils-rxdb-version.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-string.js +11 -8
- package/dist/cjs/plugins/utils/utils-string.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-time.js +21 -16
- package/dist/cjs/plugins/utils/utils-time.js.map +1 -1
- package/dist/cjs/query-cache.js +6 -4
- package/dist/cjs/query-cache.js.map +1 -1
- package/dist/cjs/query-planner.js +2 -2
- package/dist/cjs/query-planner.js.map +1 -1
- package/dist/cjs/replication-protocol/downstream.js +1 -1
- package/dist/cjs/replication-protocol/downstream.js.map +1 -1
- package/dist/cjs/rx-collection-helper.js +11 -6
- package/dist/cjs/rx-collection-helper.js.map +1 -1
- package/dist/cjs/rx-collection.js +34 -6
- package/dist/cjs/rx-collection.js.map +1 -1
- package/dist/cjs/rx-database.js +40 -7
- package/dist/cjs/rx-database.js.map +1 -1
- package/dist/cjs/rx-document.js +10 -3
- package/dist/cjs/rx-document.js.map +1 -1
- package/dist/cjs/rx-query-helper.js +35 -12
- package/dist/cjs/rx-query-helper.js.map +1 -1
- package/dist/cjs/rx-query-single-result.js +9 -2
- package/dist/cjs/rx-query-single-result.js.map +1 -1
- package/dist/cjs/rx-query.js +72 -29
- package/dist/cjs/rx-query.js.map +1 -1
- package/dist/cjs/rx-schema-helper.js +9 -3
- package/dist/cjs/rx-schema-helper.js.map +1 -1
- package/dist/cjs/rx-schema.js +1 -0
- package/dist/cjs/rx-schema.js.map +1 -1
- package/dist/cjs/rx-storage-helper.js +212 -129
- package/dist/cjs/rx-storage-helper.js.map +1 -1
- package/dist/cjs/types/rx-error.d.js.map +1 -1
- package/dist/cjs/types/rx-schema.d.js.map +1 -1
- package/dist/esm/change-event-buffer.js +2 -1
- package/dist/esm/change-event-buffer.js.map +1 -1
- package/dist/esm/custom-index.js +85 -12
- package/dist/esm/custom-index.js.map +1 -1
- package/dist/esm/doc-cache.js +118 -36
- package/dist/esm/doc-cache.js.map +1 -1
- package/dist/esm/event-reduce.js +10 -1
- package/dist/esm/event-reduce.js.map +1 -1
- package/dist/esm/plugin-helpers.js +16 -0
- package/dist/esm/plugin-helpers.js.map +1 -1
- package/dist/esm/plugins/attachments/index.js +3 -3
- package/dist/esm/plugins/attachments/index.js.map +1 -1
- package/dist/esm/plugins/cleanup/cleanup.js +5 -3
- package/dist/esm/plugins/cleanup/cleanup.js.map +1 -1
- package/dist/esm/plugins/crdt/index.js +52 -0
- package/dist/esm/plugins/crdt/index.js.map +1 -1
- package/dist/esm/plugins/dev-mode/check-query.js +7 -1
- package/dist/esm/plugins/dev-mode/check-query.js.map +1 -1
- package/dist/esm/plugins/dev-mode/check-schema.js +2 -1
- package/dist/esm/plugins/dev-mode/check-schema.js.map +1 -1
- package/dist/esm/plugins/dev-mode/error-messages.js +43 -5
- package/dist/esm/plugins/dev-mode/error-messages.js.map +1 -1
- package/dist/esm/plugins/encryption-crypto-js/index.js +22 -6
- package/dist/esm/plugins/encryption-crypto-js/index.js.map +1 -1
- package/dist/esm/plugins/leader-election/index.js +4 -4
- package/dist/esm/plugins/leader-election/index.js.map +1 -1
- package/dist/esm/plugins/local-documents/local-documents.js +20 -13
- package/dist/esm/plugins/local-documents/local-documents.js.map +1 -1
- package/dist/esm/plugins/migration-schema/migration-helpers.js +3 -0
- package/dist/esm/plugins/migration-schema/migration-helpers.js.map +1 -1
- package/dist/esm/plugins/migration-schema/rx-migration-state.js +1 -1
- package/dist/esm/plugins/migration-schema/rx-migration-state.js.map +1 -1
- package/dist/esm/plugins/pipeline/rx-pipeline.js +5 -1
- package/dist/esm/plugins/pipeline/rx-pipeline.js.map +1 -1
- package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js +4 -2
- package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -1
- package/dist/esm/plugins/replication/index.js +40 -2
- package/dist/esm/plugins/replication/index.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/document-handling.js +17 -6
- package/dist/esm/plugins/replication-google-drive/document-handling.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/google-drive-helper.js +1 -1
- package/dist/esm/plugins/replication-google-drive/google-drive-helper.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/google-drive-types.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/signaling.js +4 -1
- package/dist/esm/plugins/replication-google-drive/signaling.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/upstream.js +7 -4
- package/dist/esm/plugins/replication-google-drive/upstream.js.map +1 -1
- package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js +4 -1
- package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js.map +1 -1
- package/dist/esm/plugins/state/rx-state.js +15 -4
- package/dist/esm/plugins/state/rx-state.js.map +1 -1
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js +11 -18
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
- package/dist/esm/plugins/storage-memory/binary-search-bounds.js +107 -40
- package/dist/esm/plugins/storage-memory/binary-search-bounds.js.map +1 -1
- package/dist/esm/plugins/storage-memory/memory-helper.js +128 -41
- package/dist/esm/plugins/storage-memory/memory-helper.js.map +1 -1
- package/dist/esm/plugins/storage-memory/memory-indexes.js +1 -0
- package/dist/esm/plugins/storage-memory/memory-indexes.js.map +1 -1
- package/dist/esm/plugins/storage-memory/memory-types.js.map +1 -1
- package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js +90 -30
- package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -1
- package/dist/esm/plugins/storage-mongodb/mongodb-helper.js +39 -0
- package/dist/esm/plugins/storage-mongodb/mongodb-helper.js.map +1 -1
- package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js +8 -8
- package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -1
- package/dist/esm/plugins/test-utils/config.js +1 -1
- package/dist/esm/plugins/test-utils/config.js.map +1 -1
- package/dist/esm/plugins/test-utils/performance.js +122 -92
- package/dist/esm/plugins/test-utils/performance.js.map +1 -1
- package/dist/esm/plugins/test-utils/schema-objects.js +1 -1
- package/dist/esm/plugins/test-utils/schema-objects.js.map +1 -1
- package/dist/esm/plugins/test-utils/test-util.js +59 -0
- package/dist/esm/plugins/test-utils/test-util.js.map +1 -1
- package/dist/esm/plugins/utils/utils-map.js +2 -2
- package/dist/esm/plugins/utils/utils-map.js.map +1 -1
- package/dist/esm/plugins/utils/utils-object-deep-equal.js +3 -2
- package/dist/esm/plugins/utils/utils-object-deep-equal.js.map +1 -1
- package/dist/esm/plugins/utils/utils-object-dot-prop.js +25 -0
- package/dist/esm/plugins/utils/utils-object-dot-prop.js.map +1 -1
- package/dist/esm/plugins/utils/utils-object.js +102 -27
- package/dist/esm/plugins/utils/utils-object.js.map +1 -1
- package/dist/esm/plugins/utils/utils-other.js +9 -4
- package/dist/esm/plugins/utils/utils-other.js.map +1 -1
- package/dist/esm/plugins/utils/utils-premium.js +1 -19
- package/dist/esm/plugins/utils/utils-premium.js.map +1 -1
- package/dist/esm/plugins/utils/utils-revision.js +20 -10
- package/dist/esm/plugins/utils/utils-revision.js.map +1 -1
- package/dist/esm/plugins/utils/utils-rxdb-version.js +1 -1
- package/dist/esm/plugins/utils/utils-rxdb-version.js.map +1 -1
- package/dist/esm/plugins/utils/utils-string.js +11 -8
- package/dist/esm/plugins/utils/utils-string.js.map +1 -1
- package/dist/esm/plugins/utils/utils-time.js +21 -16
- package/dist/esm/plugins/utils/utils-time.js.map +1 -1
- package/dist/esm/query-cache.js +7 -5
- package/dist/esm/query-cache.js.map +1 -1
- package/dist/esm/query-planner.js +2 -2
- package/dist/esm/query-planner.js.map +1 -1
- package/dist/esm/replication-protocol/downstream.js +1 -1
- package/dist/esm/replication-protocol/downstream.js.map +1 -1
- package/dist/esm/rx-collection-helper.js +12 -7
- package/dist/esm/rx-collection-helper.js.map +1 -1
- package/dist/esm/rx-collection.js +35 -7
- package/dist/esm/rx-collection.js.map +1 -1
- package/dist/esm/rx-database.js +40 -7
- package/dist/esm/rx-database.js.map +1 -1
- package/dist/esm/rx-document.js +11 -4
- package/dist/esm/rx-document.js.map +1 -1
- package/dist/esm/rx-query-helper.js +35 -12
- package/dist/esm/rx-query-helper.js.map +1 -1
- package/dist/esm/rx-query-single-result.js +10 -3
- package/dist/esm/rx-query-single-result.js.map +1 -1
- package/dist/esm/rx-query.js +72 -29
- package/dist/esm/rx-query.js.map +1 -1
- package/dist/esm/rx-schema-helper.js +9 -3
- package/dist/esm/rx-schema-helper.js.map +1 -1
- package/dist/esm/rx-schema.js +1 -0
- package/dist/esm/rx-schema.js.map +1 -1
- package/dist/esm/rx-storage-helper.js +176 -94
- package/dist/esm/rx-storage-helper.js.map +1 -1
- package/dist/esm/types/rx-error.d.js.map +1 -1
- package/dist/esm/types/rx-schema.d.js.map +1 -1
- package/dist/types/custom-index.d.ts +5 -0
- package/dist/types/doc-cache.d.ts +1 -1
- package/dist/types/index.d.ts +25 -26
- package/dist/types/plugins/dev-mode/error-messages.d.ts +36 -0
- package/dist/types/plugins/leader-election/index.d.ts +1 -0
- package/dist/types/plugins/replication-google-drive/document-handling.d.ts +4 -1
- package/dist/types/plugins/replication-google-drive/google-drive-types.d.ts +1 -0
- package/dist/types/plugins/state/rx-state.d.ts +1 -1
- package/dist/types/plugins/storage-denokv/index.d.ts +1 -1
- package/dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts +1 -1
- package/dist/types/plugins/storage-localstorage/index.d.ts +1 -1
- package/dist/types/plugins/storage-memory/binary-search-bounds.d.ts +21 -10
- package/dist/types/plugins/storage-memory/memory-helper.d.ts +7 -3
- package/dist/types/plugins/storage-memory/memory-types.d.ts +5 -0
- package/dist/types/plugins/storage-mongodb/mongodb-helper.d.ts +9 -1
- package/dist/types/plugins/storage-mongodb/rx-storage-instance-mongodb.d.ts +2 -2
- package/dist/types/plugins/storage-mongodb/rx-storage-mongodb.d.ts +1 -1
- package/dist/types/plugins/storage-remote/rx-storage-remote.d.ts +1 -1
- package/dist/types/plugins/storage-sqlite/index.d.ts +1 -1
- package/dist/types/plugins/test-utils/performance.d.ts +36 -0
- package/dist/types/plugins/test-utils/test-util.d.ts +17 -0
- package/dist/types/plugins/utils/utils-object.d.ts +8 -3
- package/dist/types/plugins/utils/utils-premium.d.ts +0 -2
- package/dist/types/plugins/utils/utils-rxdb-version.d.ts +1 -1
- package/dist/types/rx-database.d.ts +1 -1
- package/dist/types/rx-query-single-result.d.ts +1 -1
- package/dist/types/rx-query.d.ts +3 -2
- package/dist/types/rx-storage-helper.d.ts +15 -0
- package/eslint.config.mjs +2 -1
- package/package.json +732 -729
- package/scripts/check-code-block-line-length.js +91 -0
- package/scripts/check-em-dashes.js +53 -0
- package/scripts/docs-fetch-git-history.mjs +36 -0
- package/scripts/install-foundationdb.sh +0 -6
- package/scripts/notify-indexnow.mjs +171 -0
- package/scripts/start-foundationdb-docker.sh +73 -0
- package/src/change-event-buffer.ts +4 -1
- package/src/custom-index.ts +93 -16
- package/src/doc-cache.ts +117 -41
- package/src/event-reduce.ts +10 -1
- package/src/plugin-helpers.ts +10 -0
- package/src/plugins/attachments/index.ts +10 -12
- package/src/plugins/cleanup/cleanup.ts +5 -3
- package/src/plugins/crdt/index.ts +55 -0
- package/src/plugins/dev-mode/check-query.ts +7 -1
- package/src/plugins/dev-mode/check-schema.ts +2 -1
- package/src/plugins/dev-mode/error-messages.ts +45 -5
- package/src/plugins/encryption-crypto-js/index.ts +18 -6
- package/src/plugins/leader-election/index.ts +9 -8
- package/src/plugins/local-documents/local-documents.ts +21 -12
- package/src/plugins/migration-schema/migration-helpers.ts +3 -0
- package/src/plugins/migration-schema/rx-migration-state.ts +1 -1
- package/src/plugins/pipeline/rx-pipeline.ts +5 -1
- package/src/plugins/query-builder/mquery/nosql-query-builder.ts +8 -2
- package/src/plugins/replication/index.ts +41 -3
- package/src/plugins/replication-google-drive/document-handling.ts +17 -5
- package/src/plugins/replication-google-drive/google-drive-helper.ts +1 -1
- package/src/plugins/replication-google-drive/google-drive-types.ts +1 -0
- package/src/plugins/replication-google-drive/signaling.ts +4 -1
- package/src/plugins/replication-google-drive/upstream.ts +7 -4
- package/src/plugins/replication-microsoft-onedrive/signaling.ts +4 -1
- package/src/plugins/state/rx-state.ts +17 -5
- package/src/plugins/storage-dexie/rx-storage-instance-dexie.ts +0 -27
- package/src/plugins/storage-memory/binary-search-bounds.ts +105 -40
- package/src/plugins/storage-memory/memory-helper.ts +158 -67
- package/src/plugins/storage-memory/memory-indexes.ts +1 -0
- package/src/plugins/storage-memory/memory-types.ts +5 -0
- package/src/plugins/storage-memory/rx-storage-instance-memory.ts +104 -53
- package/src/plugins/storage-mongodb/mongodb-helper.ts +43 -1
- package/src/plugins/storage-mongodb/rx-storage-instance-mongodb.ts +11 -9
- package/src/plugins/test-utils/config.ts +2 -1
- package/src/plugins/test-utils/performance.ts +159 -85
- package/src/plugins/test-utils/schema-objects.ts +1 -1
- package/src/plugins/test-utils/test-util.ts +71 -0
- package/src/plugins/utils/utils-map.ts +2 -2
- package/src/plugins/utils/utils-object-deep-equal.ts +2 -4
- package/src/plugins/utils/utils-object-dot-prop.ts +25 -0
- package/src/plugins/utils/utils-object.ts +103 -28
- package/src/plugins/utils/utils-other.ts +9 -4
- package/src/plugins/utils/utils-premium.ts +11 -37
- package/src/plugins/utils/utils-revision.ts +20 -9
- package/src/plugins/utils/utils-rxdb-version.ts +1 -1
- package/src/plugins/utils/utils-string.ts +11 -9
- package/src/plugins/utils/utils-time.ts +21 -17
- package/src/query-cache.ts +6 -5
- package/src/query-planner.ts +2 -2
- package/src/replication-protocol/downstream.ts +1 -1
- package/src/rx-collection-helper.ts +12 -6
- package/src/rx-collection.ts +39 -8
- package/src/rx-database.ts +49 -17
- package/src/rx-document.ts +12 -3
- package/src/rx-query-helper.ts +36 -15
- package/src/rx-query-single-result.ts +10 -3
- package/src/rx-query.ts +48 -8
- package/src/rx-schema-helper.ts +7 -4
- package/src/rx-schema.ts +1 -0
- package/src/rx-storage-helper.ts +210 -139
- package/src/types/rx-error.d.ts +3 -0
- package/src/types/rx-schema.d.ts +5 -0
- package/dist/esm/package.json +0 -1
- package/dist/types/types/conflict-handling.d.ts +0 -48
- package/dist/types/types/couchdb.d.ts +0 -293
- package/dist/types/types/index.d.ts +0 -32
- package/dist/types/types/modules/index.d.ts +0 -0
- package/dist/types/types/modules/mocha.parallel.d.ts +0 -1
- package/dist/types/types/plugins/backup.d.ts +0 -35
- package/dist/types/types/plugins/cleanup.d.ts +0 -38
- package/dist/types/types/plugins/crdt.d.ts +0 -76
- package/dist/types/types/plugins/dexie.d.ts +0 -30
- package/dist/types/types/plugins/local-documents.d.ts +0 -49
- package/dist/types/types/plugins/migration.d.ts +0 -14
- package/dist/types/types/plugins/reactivity.d.ts +0 -40
- package/dist/types/types/plugins/replication-graphql.d.ts +0 -98
- package/dist/types/types/plugins/replication.d.ts +0 -175
- package/dist/types/types/plugins/state.d.ts +0 -4
- package/dist/types/types/plugins/update.d.ts +0 -23
- package/dist/types/types/plugins/webmcp.d.ts +0 -40
- package/dist/types/types/query-planner.d.ts +0 -47
- package/dist/types/types/replication-protocol.d.ts +0 -296
- package/dist/types/types/rx-attachment.d.ts +0 -46
- package/dist/types/types/rx-change-event.d.ts +0 -85
- package/dist/types/types/rx-collection.d.ts +0 -117
- package/dist/types/types/rx-database-internal-store.d.ts +0 -54
- package/dist/types/types/rx-database.d.ts +0 -124
- package/dist/types/types/rx-document.d.ts +0 -160
- package/dist/types/types/rx-error.d.ts +0 -222
- package/dist/types/types/rx-plugin.d.ts +0 -167
- package/dist/types/types/rx-query.d.ts +0 -144
- package/dist/types/types/rx-schema.d.ts +0 -209
- package/dist/types/types/rx-storage.d.ts +0 -347
- package/dist/types/types/rx-storage.interface.d.ts +0 -312
- package/dist/types/types/util.d.ts +0 -180
package/src/rx-storage-helper.ts
CHANGED
|
@@ -51,6 +51,37 @@ import { HOOKS, runPluginHooks } from './hooks.ts';
|
|
|
51
51
|
export const INTERNAL_STORAGE_NAME = '_rxdb_internal';
|
|
52
52
|
export const RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = 'rxdatabase_storage_local';
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Context string used by RxCollection.bulkInsert().
|
|
56
|
+
* Documents written with this context are already cloned
|
|
57
|
+
* by fillObjectDataBeforeInsert(), so the wrapped storage
|
|
58
|
+
* can safely mutate them in place instead of cloning again.
|
|
59
|
+
*/
|
|
60
|
+
export const RX_COLLECTION_BULK_INSERT_CONTEXT = 'rx-collection-bulk-insert';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Set of bulkWrite context strings whose documents
|
|
64
|
+
* are already cloned by the caller and can be safely
|
|
65
|
+
* mutated in place (skip flatClone in the insert path).
|
|
66
|
+
*
|
|
67
|
+
* Plugins can register additional contexts via
|
|
68
|
+
* registerMutableWriteContext().
|
|
69
|
+
*/
|
|
70
|
+
const MUTABLE_DOCUMENT_WRITE_CONTEXTS: Set<string> = new Set([
|
|
71
|
+
RX_COLLECTION_BULK_INSERT_CONTEXT
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Register a bulkWrite context string as "mutable",
|
|
76
|
+
* meaning the caller guarantees that insert documents
|
|
77
|
+
* are already cloned and safe to mutate in place.
|
|
78
|
+
* This allows the wrapped storage to skip a redundant
|
|
79
|
+
* flatClone() call on the insert hot path.
|
|
80
|
+
*/
|
|
81
|
+
export function registerMutableWriteContext(context: string): void {
|
|
82
|
+
MUTABLE_DOCUMENT_WRITE_CONTEXTS.add(context);
|
|
83
|
+
}
|
|
84
|
+
|
|
54
85
|
export async function getSingleDocument<RxDocType>(
|
|
55
86
|
storageInstance: RxStorageInstance<RxDocType, any, any>,
|
|
56
87
|
documentId: string
|
|
@@ -253,54 +284,54 @@ export function categorizeBulkWriteRows<RxDocType>(
|
|
|
253
284
|
* It is possible to insert already deleted documents,
|
|
254
285
|
* this can happen on replication.
|
|
255
286
|
*/
|
|
256
|
-
const insertedIsDeleted = documentDeleted ? true : false;
|
|
257
287
|
if (hasAttachments) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
288
|
+
const atts = document._attachments;
|
|
289
|
+
const attKeys = Object.keys(atts);
|
|
290
|
+
for (let a = 0; a < attKeys.length; a++) {
|
|
291
|
+
const attachmentId = attKeys[a];
|
|
292
|
+
const attachmentData = atts[attachmentId];
|
|
293
|
+
if (
|
|
294
|
+
!(attachmentData as RxAttachmentWriteData).data
|
|
295
|
+
) {
|
|
296
|
+
attachmentError = {
|
|
297
|
+
documentId: docId,
|
|
298
|
+
isError: true,
|
|
299
|
+
status: 510,
|
|
300
|
+
writeRow,
|
|
301
|
+
attachmentId,
|
|
302
|
+
context
|
|
303
|
+
};
|
|
304
|
+
errors.push(attachmentError);
|
|
305
|
+
} else {
|
|
306
|
+
attachmentsAdd.push({
|
|
307
|
+
documentId: docId,
|
|
308
|
+
attachmentId,
|
|
309
|
+
attachmentData: attachmentData as any,
|
|
310
|
+
digest: attachmentData.digest
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
282
314
|
}
|
|
315
|
+
let insertedRow: BulkWriteRowProcessed<RxDocType> | undefined;
|
|
283
316
|
if (!attachmentError) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
} else {
|
|
290
|
-
bulkInsertDocs.push(writeRow as any);
|
|
291
|
-
if (onInsert) {
|
|
292
|
-
onInsert(document);
|
|
293
|
-
}
|
|
317
|
+
const row: BulkWriteRowProcessed<RxDocType> = hasAttachments ? stripAttachmentsDataFromRow(writeRow) : writeRow as any;
|
|
318
|
+
insertedRow = row;
|
|
319
|
+
bulkInsertDocs.push(row);
|
|
320
|
+
if (onInsert) {
|
|
321
|
+
onInsert(document);
|
|
294
322
|
}
|
|
295
|
-
|
|
296
|
-
newestRow = writeRow as any;
|
|
323
|
+
newestRow = row;
|
|
297
324
|
}
|
|
298
325
|
|
|
299
|
-
if (!
|
|
326
|
+
if (!documentDeleted) {
|
|
327
|
+
let eventDocData = document as RxDocumentData<RxDocType>;
|
|
328
|
+
if (hasAttachments) {
|
|
329
|
+
eventDocData = insertedRow ? insertedRow.document : stripAttachmentsDataFromDocument(document);
|
|
330
|
+
}
|
|
300
331
|
const event = {
|
|
301
332
|
documentId: docId,
|
|
302
333
|
operation: 'INSERT' as const,
|
|
303
|
-
documentData:
|
|
334
|
+
documentData: eventDocData,
|
|
304
335
|
previousDocumentData: hasAttachments && previous ? stripAttachmentsDataFromDocument(previous) : previous as any
|
|
305
336
|
};
|
|
306
337
|
eventBulkEvents.push(event);
|
|
@@ -343,69 +374,72 @@ export function categorizeBulkWriteRows<RxDocType>(
|
|
|
343
374
|
* Deleted documents must have cleared all their attachments.
|
|
344
375
|
*/
|
|
345
376
|
if (previous) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
377
|
+
const prevAtts = previous._attachments;
|
|
378
|
+
const prevAttKeys = Object.keys(prevAtts);
|
|
379
|
+
for (let a = 0; a < prevAttKeys.length; a++) {
|
|
380
|
+
const attachmentId = prevAttKeys[a];
|
|
381
|
+
attachmentsRemove.push({
|
|
382
|
+
documentId: docId,
|
|
383
|
+
attachmentId,
|
|
384
|
+
digest: prevAtts[attachmentId].digest
|
|
354
385
|
});
|
|
386
|
+
}
|
|
355
387
|
}
|
|
356
388
|
} else {
|
|
357
389
|
// first check for errors
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
390
|
+
const docAtts = document._attachments;
|
|
391
|
+
const docAttKeys = Object.keys(docAtts);
|
|
392
|
+
for (let a = 0; a < docAttKeys.length; a++) {
|
|
393
|
+
const attachmentId = docAttKeys[a];
|
|
394
|
+
const attachmentData = docAtts[attachmentId];
|
|
395
|
+
const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;
|
|
396
|
+
if (
|
|
397
|
+
!previousAttachmentData &&
|
|
398
|
+
!(attachmentData as RxAttachmentWriteData).data
|
|
399
|
+
) {
|
|
400
|
+
attachmentError = {
|
|
401
|
+
documentId: docId,
|
|
402
|
+
documentInDb: documentInDb as any,
|
|
403
|
+
isError: true,
|
|
404
|
+
status: 510,
|
|
405
|
+
writeRow,
|
|
406
|
+
attachmentId,
|
|
407
|
+
context
|
|
408
|
+
};
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (!attachmentError) {
|
|
413
|
+
for (let a = 0; a < docAttKeys.length; a++) {
|
|
414
|
+
const attachmentId = docAttKeys[a];
|
|
415
|
+
const attachmentData = docAtts[attachmentId];
|
|
361
416
|
const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;
|
|
362
|
-
if (
|
|
363
|
-
|
|
364
|
-
!(attachmentData as RxAttachmentWriteData).data
|
|
365
|
-
) {
|
|
366
|
-
attachmentError = {
|
|
417
|
+
if (!previousAttachmentData) {
|
|
418
|
+
attachmentsAdd.push({
|
|
367
419
|
documentId: docId,
|
|
368
|
-
documentInDb: documentInDb as any,
|
|
369
|
-
isError: true,
|
|
370
|
-
status: 510,
|
|
371
|
-
writeRow,
|
|
372
420
|
attachmentId,
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
421
|
+
attachmentData: attachmentData as any,
|
|
422
|
+
digest: attachmentData.digest
|
|
423
|
+
});
|
|
424
|
+
} else {
|
|
425
|
+
const newDigest = updatedRow.document._attachments[attachmentId].digest;
|
|
426
|
+
if (
|
|
427
|
+
(attachmentData as RxAttachmentWriteData).data &&
|
|
428
|
+
/**
|
|
429
|
+
* Performance shortcut,
|
|
430
|
+
* do not update the attachment data if it did not change.
|
|
431
|
+
*/
|
|
432
|
+
previousAttachmentData.digest !== newDigest
|
|
433
|
+
) {
|
|
434
|
+
attachmentsUpdate.push({
|
|
385
435
|
documentId: docId,
|
|
386
436
|
attachmentId,
|
|
387
|
-
attachmentData: attachmentData as
|
|
437
|
+
attachmentData: attachmentData as RxAttachmentWriteData,
|
|
388
438
|
digest: attachmentData.digest
|
|
389
439
|
});
|
|
390
|
-
} else {
|
|
391
|
-
const newDigest = updatedRow.document._attachments[attachmentId].digest;
|
|
392
|
-
if (
|
|
393
|
-
(attachmentData as RxAttachmentWriteData).data &&
|
|
394
|
-
/**
|
|
395
|
-
* Performance shortcut,
|
|
396
|
-
* do not update the attachment data if it did not change.
|
|
397
|
-
*/
|
|
398
|
-
previousAttachmentData.digest !== newDigest
|
|
399
|
-
) {
|
|
400
|
-
attachmentsUpdate.push({
|
|
401
|
-
documentId: docId,
|
|
402
|
-
attachmentId,
|
|
403
|
-
attachmentData: attachmentData as RxAttachmentWriteData,
|
|
404
|
-
digest: attachmentData.digest
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
440
|
}
|
|
408
|
-
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
409
443
|
}
|
|
410
444
|
}
|
|
411
445
|
}
|
|
@@ -413,16 +447,13 @@ export function categorizeBulkWriteRows<RxDocType>(
|
|
|
413
447
|
if (attachmentError) {
|
|
414
448
|
errors.push(attachmentError);
|
|
415
449
|
} else {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (onUpdate) {
|
|
424
|
-
onUpdate(document);
|
|
425
|
-
}
|
|
450
|
+
/**
|
|
451
|
+
* updatedRow already has attachments stripped (line above),
|
|
452
|
+
* so push it directly without stripping again.
|
|
453
|
+
*/
|
|
454
|
+
bulkUpdateDocs.push(updatedRow);
|
|
455
|
+
if (onUpdate) {
|
|
456
|
+
onUpdate(document);
|
|
426
457
|
}
|
|
427
458
|
newestRow = updatedRow as any;
|
|
428
459
|
}
|
|
@@ -433,10 +464,14 @@ export function categorizeBulkWriteRows<RxDocType>(
|
|
|
433
464
|
|
|
434
465
|
if (previousDeleted && !documentDeleted) {
|
|
435
466
|
operation = 'INSERT';
|
|
436
|
-
|
|
467
|
+
/**
|
|
468
|
+
* Reuse the already-stripped document from updatedRow
|
|
469
|
+
* instead of calling stripAttachmentsDataFromDocument() again.
|
|
470
|
+
*/
|
|
471
|
+
eventDocumentData = hasAttachments ? updatedRow.document : document as any;
|
|
437
472
|
} else if (previous && !previousDeleted && !documentDeleted) {
|
|
438
473
|
operation = 'UPDATE';
|
|
439
|
-
eventDocumentData = hasAttachments ?
|
|
474
|
+
eventDocumentData = hasAttachments ? updatedRow.document : document as any;
|
|
440
475
|
previousEventDocumentData = previous;
|
|
441
476
|
} else if (documentDeleted) {
|
|
442
477
|
operation = 'DELETE';
|
|
@@ -510,12 +545,13 @@ export function stripAttachmentsDataFromDocument<RxDocType>(doc: RxDocumentWrite
|
|
|
510
545
|
}
|
|
511
546
|
|
|
512
547
|
const useDoc: RxDocumentData<RxDocType> = flatClone(doc) as any;
|
|
513
|
-
|
|
514
|
-
Object
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
548
|
+
const destAtts: Record<string, RxAttachmentData> = {};
|
|
549
|
+
const attKeys = Object.keys(atts);
|
|
550
|
+
for (let i = 0; i < attKeys.length; i++) {
|
|
551
|
+
const attachmentId = attKeys[i];
|
|
552
|
+
destAtts[attachmentId] = attachmentWriteDataToNormalData(atts[attachmentId]);
|
|
553
|
+
}
|
|
554
|
+
useDoc._attachments = destAtts;
|
|
519
555
|
return useDoc;
|
|
520
556
|
}
|
|
521
557
|
|
|
@@ -528,13 +564,10 @@ export function stripAttachmentsDataFromDocument<RxDocType>(doc: RxDocumentWrite
|
|
|
528
564
|
export function flatCloneDocWithMeta<RxDocType>(
|
|
529
565
|
doc: RxDocumentData<RxDocType>
|
|
530
566
|
): RxDocumentData<RxDocType> {
|
|
531
|
-
return
|
|
532
|
-
|
|
533
|
-
doc
|
|
534
|
-
|
|
535
|
-
_meta: flatClone(doc._meta)
|
|
536
|
-
}
|
|
537
|
-
);
|
|
567
|
+
return {
|
|
568
|
+
...doc,
|
|
569
|
+
_meta: { ...doc._meta }
|
|
570
|
+
} as any;
|
|
538
571
|
}
|
|
539
572
|
|
|
540
573
|
export type WrappedRxStorageInstance<RxDocumentType, Internals, InstanceCreationOptions> = RxStorageInstance<RxDocumentType, any, InstanceCreationOptions> & {
|
|
@@ -577,7 +610,6 @@ export function getWrappedStorageInstance<
|
|
|
577
610
|
context: string
|
|
578
611
|
) {
|
|
579
612
|
const databaseToken = database.token;
|
|
580
|
-
const toStorageWriteRows: BulkWriteRow<RxDocType>[] = new Array(rows.length);
|
|
581
613
|
/**
|
|
582
614
|
* Use the same timestamp for all docs of this rows-set.
|
|
583
615
|
* This improves performance because calling Date.now() inside of the now() function
|
|
@@ -590,31 +622,70 @@ export function getWrappedStorageInstance<
|
|
|
590
622
|
* inside the hot loop.
|
|
591
623
|
*/
|
|
592
624
|
const firstRevision = '1-' + databaseToken;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
625
|
+
/**
|
|
626
|
+
* Share a single _meta object for all insert rows in this batch.
|
|
627
|
+
* All inserts in the same bulkWrite share the same timestamp,
|
|
628
|
+
* so we avoid creating a new { lwt: time } object per row.
|
|
629
|
+
* This shared reference is safe because:
|
|
630
|
+
* - All documents in one batch receive identical metadata values.
|
|
631
|
+
* - When a document is later updated, flatCloneDocWithMeta() creates
|
|
632
|
+
* a new _meta object, so the shared reference is never mutated.
|
|
633
|
+
*/
|
|
634
|
+
const insertMeta = { lwt: time };
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* When the caller has already cloned the documents (registered
|
|
638
|
+
* via MUTABLE_DOCUMENT_WRITE_CONTEXTS), we can mutate them
|
|
639
|
+
* in place and reuse the input array, avoiding redundant
|
|
640
|
+
* flatClone() and wrapper-object allocations on every insert row.
|
|
641
|
+
*/
|
|
642
|
+
const isMutableContext = MUTABLE_DOCUMENT_WRITE_CONTEXTS.has(context);
|
|
643
|
+
let toStorageWriteRows: BulkWriteRow<RxDocType>[];
|
|
644
|
+
|
|
645
|
+
if (isMutableContext) {
|
|
646
|
+
/**
|
|
647
|
+
* Fast path: documents are already cloned by the caller.
|
|
648
|
+
* Set _meta/_rev directly on the document and reuse the
|
|
649
|
+
* input rows array without allocating wrapper objects.
|
|
650
|
+
*/
|
|
651
|
+
for (let index = 0; index < rows.length; index++) {
|
|
652
|
+
const document = rows[index].document;
|
|
653
|
+
document._meta = insertMeta;
|
|
612
654
|
document._rev = firstRevision;
|
|
613
655
|
}
|
|
614
|
-
toStorageWriteRows
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
656
|
+
toStorageWriteRows = rows;
|
|
657
|
+
} else {
|
|
658
|
+
toStorageWriteRows = new Array(rows.length);
|
|
659
|
+
for (let index = 0; index < rows.length; index++) {
|
|
660
|
+
const writeRow = rows[index];
|
|
661
|
+
const previous = writeRow.previous;
|
|
662
|
+
let document;
|
|
663
|
+
if (previous) {
|
|
664
|
+
document = flatCloneDocWithMeta(writeRow.document);
|
|
665
|
+
document._meta.lwt = time;
|
|
666
|
+
document._rev = createRevision(
|
|
667
|
+
databaseToken,
|
|
668
|
+
previous
|
|
669
|
+
);
|
|
670
|
+
} else {
|
|
671
|
+
/**
|
|
672
|
+
* Insert path: flatClone is required because the input document
|
|
673
|
+
* may be a direct reference to another storage's internal data
|
|
674
|
+
* (e.g., during migration, query results from the old storage are
|
|
675
|
+
* passed directly as insert rows to the new storage).
|
|
676
|
+
*
|
|
677
|
+
* Use a shared insertMeta object instead of allocating { lwt: time }
|
|
678
|
+
* per row, since all inserts in the same batch share the same timestamp.
|
|
679
|
+
*/
|
|
680
|
+
document = flatClone(writeRow.document);
|
|
681
|
+
document._meta = insertMeta;
|
|
682
|
+
document._rev = firstRevision;
|
|
683
|
+
}
|
|
684
|
+
toStorageWriteRows[index] = {
|
|
685
|
+
document,
|
|
686
|
+
previous
|
|
687
|
+
};
|
|
688
|
+
}
|
|
618
689
|
}
|
|
619
690
|
|
|
620
691
|
if (HOOKS.preStorageWrite.length > 0) {
|
package/src/types/rx-error.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface RxErrorParameters {
|
|
|
28
28
|
readonly rootPath?: string;
|
|
29
29
|
readonly childpath?: string;
|
|
30
30
|
readonly ids?: string[];
|
|
31
|
+
readonly duplicateIds?: string[];
|
|
31
32
|
readonly obj?: any;
|
|
32
33
|
readonly document?: any;
|
|
33
34
|
readonly schema?: Readonly<RxJsonSchema<any> | RxSchema>;
|
|
@@ -71,6 +72,8 @@ export interface RxErrorParameters {
|
|
|
71
72
|
readonly passwordHash?: string;
|
|
72
73
|
readonly existingPasswordHash?: string;
|
|
73
74
|
readonly password?: string | any;
|
|
75
|
+
readonly passwordType?: string;
|
|
76
|
+
readonly passwordLength?: number;
|
|
74
77
|
readonly minPassLength?: number;
|
|
75
78
|
readonly own?: any;
|
|
76
79
|
readonly source?: any;
|
package/src/types/rx-schema.d.ts
CHANGED
|
@@ -50,6 +50,11 @@ export type JsonSchema<RxDocType = any> = {
|
|
|
50
50
|
maxProperties?: number;
|
|
51
51
|
maximum?: number;
|
|
52
52
|
minimum?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Having a large maxLength for indexed fields and primary keys can negatively
|
|
55
|
+
* impact performance on many storages. Therefore, you should only set it
|
|
56
|
+
* as big as needed.
|
|
57
|
+
*/
|
|
53
58
|
maxLength?: number;
|
|
54
59
|
minLength?: number;
|
|
55
60
|
maxItems?: number;
|
package/dist/esm/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "type": "module", "sideEffects": false }
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { WithDeleted } from './rx-storage.d.ts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Notice that the conflict handler input/output
|
|
5
|
-
* does not work on RxDocumentData<RxDocType>, but only on WithDeleted<RxDocType>.
|
|
6
|
-
* This is because the _meta attributes are meant for the local storing of document data, they not replicated
|
|
7
|
-
* and therefore cannot be used to resolve conflicts.
|
|
8
|
-
*/
|
|
9
|
-
export type RxConflictHandlerInput<RxDocType> = {
|
|
10
|
-
assumedMasterState?: WithDeleted<RxDocType>;
|
|
11
|
-
realMasterState: WithDeleted<RxDocType>;
|
|
12
|
-
newDocumentState: WithDeleted<RxDocType>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The conflict handler either returns:
|
|
17
|
-
* - The resolved new document state
|
|
18
|
-
* - A flag to identify the given 'realMasterState' and 'newDocumentState'
|
|
19
|
-
* as being exactly equal, so no conflict has to be resolved.
|
|
20
|
-
*/
|
|
21
|
-
export type RxConflictHandlerOutput<RxDocType> = {
|
|
22
|
-
isEqual: false;
|
|
23
|
-
documentData: WithDeleted<RxDocType>;
|
|
24
|
-
} | {
|
|
25
|
-
isEqual: true;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type RxConflictHandlerOld<RxDocType> = (
|
|
29
|
-
i: RxConflictHandlerInput<RxDocType>,
|
|
30
|
-
context: string
|
|
31
|
-
) => Promise<RxConflictHandlerOutput<RxDocType>>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export type RxConflictHandler<RxDocType> = {
|
|
35
|
-
/**
|
|
36
|
-
* This must be non-async
|
|
37
|
-
* because it will be called very often and must be fast.
|
|
38
|
-
*/
|
|
39
|
-
isEqual: (
|
|
40
|
-
a: WithDeleted<RxDocType>,
|
|
41
|
-
b: WithDeleted<RxDocType>,
|
|
42
|
-
context: string
|
|
43
|
-
) => boolean;
|
|
44
|
-
resolve: (
|
|
45
|
-
i: RxConflictHandlerInput<RxDocType>,
|
|
46
|
-
context: string
|
|
47
|
-
) => Promise<WithDeleted<RxDocType>>;
|
|
48
|
-
};
|