@connecttomahdi/rxdb 17.0.0-beta.17
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 +54 -0
- package/CHANGELOG.md +2469 -0
- package/CLAUDE.md +63 -0
- package/LICENSE.txt +201 -0
- package/README.md +263 -0
- package/babel.config.js +58 -0
- package/dist/cjs/change-event-buffer.js +146 -0
- package/dist/cjs/change-event-buffer.js.map +1 -0
- package/dist/cjs/custom-index.js +284 -0
- package/dist/cjs/custom-index.js.map +1 -0
- package/dist/cjs/doc-cache.js +231 -0
- package/dist/cjs/doc-cache.js.map +1 -0
- package/dist/cjs/event-reduce.js +102 -0
- package/dist/cjs/event-reduce.js.map +1 -0
- package/dist/cjs/hooks.js +131 -0
- package/dist/cjs/hooks.js.map +1 -0
- package/dist/cjs/incremental-write.js +169 -0
- package/dist/cjs/incremental-write.js.map +1 -0
- package/dist/cjs/index.js +270 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/overwritable.js +39 -0
- package/dist/cjs/overwritable.js.map +1 -0
- package/dist/cjs/plugin-helpers.js +223 -0
- package/dist/cjs/plugin-helpers.js.map +1 -0
- package/dist/cjs/plugin.js +94 -0
- package/dist/cjs/plugin.js.map +1 -0
- package/dist/cjs/plugins/attachments/attachments-utils.js +49 -0
- package/dist/cjs/plugins/attachments/attachments-utils.js.map +1 -0
- package/dist/cjs/plugins/attachments/index.js +237 -0
- package/dist/cjs/plugins/attachments/index.js.map +1 -0
- package/dist/cjs/plugins/attachments-compression/index.js +143 -0
- package/dist/cjs/plugins/attachments-compression/index.js.map +1 -0
- package/dist/cjs/plugins/backup/file-util.js +102 -0
- package/dist/cjs/plugins/backup/file-util.js.map +1 -0
- package/dist/cjs/plugins/backup/index.js +206 -0
- package/dist/cjs/plugins/backup/index.js.map +1 -0
- package/dist/cjs/plugins/cleanup/cleanup-helper.js +17 -0
- package/dist/cjs/plugins/cleanup/cleanup-helper.js.map +1 -0
- package/dist/cjs/plugins/cleanup/cleanup-state.js +83 -0
- package/dist/cjs/plugins/cleanup/cleanup-state.js.map +1 -0
- package/dist/cjs/plugins/cleanup/cleanup.js +116 -0
- package/dist/cjs/plugins/cleanup/cleanup.js.map +1 -0
- package/dist/cjs/plugins/cleanup/index.js +64 -0
- package/dist/cjs/plugins/cleanup/index.js.map +1 -0
- package/dist/cjs/plugins/crdt/index.js +392 -0
- package/dist/cjs/plugins/crdt/index.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/check-document.js +158 -0
- package/dist/cjs/plugins/dev-mode/check-document.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/check-migration-strategies.js +43 -0
- package/dist/cjs/plugins/dev-mode/check-migration-strategies.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/check-orm.js +53 -0
- package/dist/cjs/plugins/dev-mode/check-orm.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/check-query.js +183 -0
- package/dist/cjs/plugins/dev-mode/check-query.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/check-schema.js +487 -0
- package/dist/cjs/plugins/dev-mode/check-schema.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/dev-mode-tracking.js +93 -0
- package/dist/cjs/plugins/dev-mode/dev-mode-tracking.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/entity-properties.js +56 -0
- package/dist/cjs/plugins/dev-mode/entity-properties.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/error-messages.js +1295 -0
- package/dist/cjs/plugins/dev-mode/error-messages.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/index.js +195 -0
- package/dist/cjs/plugins/dev-mode/index.js.map +1 -0
- package/dist/cjs/plugins/dev-mode/unallowed-properties.js +88 -0
- package/dist/cjs/plugins/dev-mode/unallowed-properties.js.map +1 -0
- package/dist/cjs/plugins/electron/electron-helper.js +9 -0
- package/dist/cjs/plugins/electron/electron-helper.js.map +1 -0
- package/dist/cjs/plugins/electron/index.js +39 -0
- package/dist/cjs/plugins/electron/index.js.map +1 -0
- package/dist/cjs/plugins/electron/rx-storage-ipc-main.js +45 -0
- package/dist/cjs/plugins/electron/rx-storage-ipc-main.js.map +1 -0
- package/dist/cjs/plugins/electron/rx-storage-ipc-renderer.js +37 -0
- package/dist/cjs/plugins/electron/rx-storage-ipc-renderer.js.map +1 -0
- package/dist/cjs/plugins/encryption-crypto-js/index.js +165 -0
- package/dist/cjs/plugins/encryption-crypto-js/index.js.map +1 -0
- package/dist/cjs/plugins/flutter/index.js +62 -0
- package/dist/cjs/plugins/flutter/index.js.map +1 -0
- package/dist/cjs/plugins/json-dump/index.js +94 -0
- package/dist/cjs/plugins/json-dump/index.js.map +1 -0
- package/dist/cjs/plugins/key-compression/index.js +136 -0
- package/dist/cjs/plugins/key-compression/index.js.map +1 -0
- package/dist/cjs/plugins/leader-election/index.js +107 -0
- package/dist/cjs/plugins/leader-election/index.js.map +1 -0
- package/dist/cjs/plugins/local-documents/index.js +109 -0
- package/dist/cjs/plugins/local-documents/index.js.map +1 -0
- package/dist/cjs/plugins/local-documents/local-documents-helper.js +78 -0
- package/dist/cjs/plugins/local-documents/local-documents-helper.js.map +1 -0
- package/dist/cjs/plugins/local-documents/local-documents.js +107 -0
- package/dist/cjs/plugins/local-documents/local-documents.js.map +1 -0
- package/dist/cjs/plugins/local-documents/rx-local-document.js +257 -0
- package/dist/cjs/plugins/local-documents/rx-local-document.js.map +1 -0
- package/dist/cjs/plugins/migration-schema/index.js +84 -0
- package/dist/cjs/plugins/migration-schema/index.js.map +1 -0
- package/dist/cjs/plugins/migration-schema/migration-helpers.js +116 -0
- package/dist/cjs/plugins/migration-schema/migration-helpers.js.map +1 -0
- package/dist/cjs/plugins/migration-schema/migration-types.js +2 -0
- package/dist/cjs/plugins/migration-schema/migration-types.js.map +1 -0
- package/dist/cjs/plugins/migration-schema/rx-migration-state.js +410 -0
- package/dist/cjs/plugins/migration-schema/rx-migration-state.js.map +1 -0
- package/dist/cjs/plugins/migration-storage/index.js +173 -0
- package/dist/cjs/plugins/migration-storage/index.js.map +1 -0
- package/dist/cjs/plugins/pipeline/flagged-functions.js +129 -0
- package/dist/cjs/plugins/pipeline/flagged-functions.js.map +1 -0
- package/dist/cjs/plugins/pipeline/index.js +43 -0
- package/dist/cjs/plugins/pipeline/index.js.map +1 -0
- package/dist/cjs/plugins/pipeline/rx-pipeline.js +219 -0
- package/dist/cjs/plugins/pipeline/rx-pipeline.js.map +1 -0
- package/dist/cjs/plugins/pipeline/types.js +2 -0
- package/dist/cjs/plugins/pipeline/types.js.map +1 -0
- package/dist/cjs/plugins/query-builder/index.js +70 -0
- package/dist/cjs/plugins/query-builder/index.js.map +1 -0
- package/dist/cjs/plugins/query-builder/mquery/mquery-utils.js +40 -0
- package/dist/cjs/plugins/query-builder/mquery/mquery-utils.js.map +1 -0
- package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js +488 -0
- package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -0
- package/dist/cjs/plugins/react/database-context.js +15 -0
- package/dist/cjs/plugins/react/database-context.js.map +1 -0
- package/dist/cjs/plugins/react/database-provider.js +41 -0
- package/dist/cjs/plugins/react/database-provider.js.map +1 -0
- package/dist/cjs/plugins/react/hooks/index.js +50 -0
- package/dist/cjs/plugins/react/hooks/index.js.map +1 -0
- package/dist/cjs/plugins/react/hooks/use-live-rx-query.js +27 -0
- package/dist/cjs/plugins/react/hooks/use-live-rx-query.js.map +1 -0
- package/dist/cjs/plugins/react/hooks/use-rx-collection.js +39 -0
- package/dist/cjs/plugins/react/hooks/use-rx-collection.js.map +1 -0
- package/dist/cjs/plugins/react/hooks/use-rx-database.js +24 -0
- package/dist/cjs/plugins/react/hooks/use-rx-database.js.map +1 -0
- package/dist/cjs/plugins/react/hooks/use-rx-query.js +99 -0
- package/dist/cjs/plugins/react/hooks/use-rx-query.js.map +1 -0
- package/dist/cjs/plugins/react/index.js +28 -0
- package/dist/cjs/plugins/react/index.js.map +1 -0
- package/dist/cjs/plugins/reactivity-angular/index.js +30 -0
- package/dist/cjs/plugins/reactivity-angular/index.js.map +1 -0
- package/dist/cjs/plugins/reactivity-preact-signals/index.js +67 -0
- package/dist/cjs/plugins/reactivity-preact-signals/index.js.map +1 -0
- package/dist/cjs/plugins/reactivity-vue/index.js +32 -0
- package/dist/cjs/plugins/reactivity-vue/index.js.map +1 -0
- package/dist/cjs/plugins/replication/index.js +487 -0
- package/dist/cjs/plugins/replication/index.js.map +1 -0
- package/dist/cjs/plugins/replication/replication-helper.js +97 -0
- package/dist/cjs/plugins/replication/replication-helper.js.map +1 -0
- package/dist/cjs/plugins/replication-appwrite/appwrite-helpers.js +33 -0
- package/dist/cjs/plugins/replication-appwrite/appwrite-helpers.js.map +1 -0
- package/dist/cjs/plugins/replication-appwrite/appwrite-types.js +2 -0
- package/dist/cjs/plugins/replication-appwrite/appwrite-types.js.map +1 -0
- package/dist/cjs/plugins/replication-appwrite/index.js +176 -0
- package/dist/cjs/plugins/replication-appwrite/index.js.map +1 -0
- package/dist/cjs/plugins/replication-couchdb/couchdb-helper.js +77 -0
- package/dist/cjs/plugins/replication-couchdb/couchdb-helper.js.map +1 -0
- package/dist/cjs/plugins/replication-couchdb/couchdb-types.js +2 -0
- package/dist/cjs/plugins/replication-couchdb/couchdb-types.js.map +1 -0
- package/dist/cjs/plugins/replication-couchdb/index.js +287 -0
- package/dist/cjs/plugins/replication-couchdb/index.js.map +1 -0
- package/dist/cjs/plugins/replication-firestore/firestore-helper.js +61 -0
- package/dist/cjs/plugins/replication-firestore/firestore-helper.js.map +1 -0
- package/dist/cjs/plugins/replication-firestore/firestore-types.js +2 -0
- package/dist/cjs/plugins/replication-firestore/firestore-types.js.map +1 -0
- package/dist/cjs/plugins/replication-firestore/index.js +266 -0
- package/dist/cjs/plugins/replication-firestore/index.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/document-handling.js +150 -0
- package/dist/cjs/plugins/replication-google-drive/document-handling.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/downstream.js +73 -0
- package/dist/cjs/plugins/replication-google-drive/downstream.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js +349 -0
- package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/google-drive-types.js +2 -0
- package/dist/cjs/plugins/replication-google-drive/google-drive-types.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/index.js +233 -0
- package/dist/cjs/plugins/replication-google-drive/index.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/init.js +76 -0
- package/dist/cjs/plugins/replication-google-drive/init.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/multipart.js +74 -0
- package/dist/cjs/plugins/replication-google-drive/multipart.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/signaling.js +262 -0
- package/dist/cjs/plugins/replication-google-drive/signaling.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/transaction.js +134 -0
- package/dist/cjs/plugins/replication-google-drive/transaction.js.map +1 -0
- package/dist/cjs/plugins/replication-google-drive/upstream.js +182 -0
- package/dist/cjs/plugins/replication-google-drive/upstream.js.map +1 -0
- package/dist/cjs/plugins/replication-graphql/graphql-schema-from-rx-schema.js +235 -0
- package/dist/cjs/plugins/replication-graphql/graphql-schema-from-rx-schema.js.map +1 -0
- package/dist/cjs/plugins/replication-graphql/graphql-websocket.js +43 -0
- package/dist/cjs/plugins/replication-graphql/graphql-websocket.js.map +1 -0
- package/dist/cjs/plugins/replication-graphql/helper.js +29 -0
- package/dist/cjs/plugins/replication-graphql/helper.js.map +1 -0
- package/dist/cjs/plugins/replication-graphql/index.js +215 -0
- package/dist/cjs/plugins/replication-graphql/index.js.map +1 -0
- package/dist/cjs/plugins/replication-graphql/query-builder-from-rx-schema.js +141 -0
- package/dist/cjs/plugins/replication-graphql/query-builder-from-rx-schema.js.map +1 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/document-handling.js +187 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/document-handling.js.map +1 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/downstream.js +78 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/downstream.js.map +1 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/index.js +222 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/index.js.map +1 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/init.js +76 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/init.js.map +1 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/microsoft-onedrive-helper.js +273 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/microsoft-onedrive-helper.js.map +1 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/microsoft-onedrive-types.js +2 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/microsoft-onedrive-types.js.map +1 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js +235 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js.map +1 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/transaction.js +138 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/transaction.js.map +1 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/upstream.js +190 -0
- package/dist/cjs/plugins/replication-microsoft-onedrive/upstream.js.map +1 -0
- package/dist/cjs/plugins/replication-mongodb/index.js +229 -0
- package/dist/cjs/plugins/replication-mongodb/index.js.map +1 -0
- package/dist/cjs/plugins/replication-mongodb/mongodb-checkpoint.js +140 -0
- package/dist/cjs/plugins/replication-mongodb/mongodb-checkpoint.js.map +1 -0
- package/dist/cjs/plugins/replication-mongodb/mongodb-helper.js +53 -0
- package/dist/cjs/plugins/replication-mongodb/mongodb-helper.js.map +1 -0
- package/dist/cjs/plugins/replication-mongodb/mongodb-types.js +2 -0
- package/dist/cjs/plugins/replication-mongodb/mongodb-types.js.map +1 -0
- package/dist/cjs/plugins/replication-nats/index.js +232 -0
- package/dist/cjs/plugins/replication-nats/index.js.map +1 -0
- package/dist/cjs/plugins/replication-nats/nats-helper.js +13 -0
- package/dist/cjs/plugins/replication-nats/nats-helper.js.map +1 -0
- package/dist/cjs/plugins/replication-nats/nats-types.js +2 -0
- package/dist/cjs/plugins/replication-nats/nats-types.js.map +1 -0
- package/dist/cjs/plugins/replication-supabase/helper.js +42 -0
- package/dist/cjs/plugins/replication-supabase/helper.js.map +1 -0
- package/dist/cjs/plugins/replication-supabase/index.js +239 -0
- package/dist/cjs/plugins/replication-supabase/index.js.map +1 -0
- package/dist/cjs/plugins/replication-supabase/types.js +2 -0
- package/dist/cjs/plugins/replication-supabase/types.js.map +1 -0
- package/dist/cjs/plugins/replication-webrtc/connection-handler-p2pcf.js +79 -0
- package/dist/cjs/plugins/replication-webrtc/connection-handler-p2pcf.js.map +1 -0
- package/dist/cjs/plugins/replication-webrtc/connection-handler-simple-peer.js +199 -0
- package/dist/cjs/plugins/replication-webrtc/connection-handler-simple-peer.js.map +1 -0
- package/dist/cjs/plugins/replication-webrtc/connection-handler-webtorrent.js +137 -0
- package/dist/cjs/plugins/replication-webrtc/connection-handler-webtorrent.js.map +1 -0
- package/dist/cjs/plugins/replication-webrtc/index.js +260 -0
- package/dist/cjs/plugins/replication-webrtc/index.js.map +1 -0
- package/dist/cjs/plugins/replication-webrtc/signaling-server.js +151 -0
- package/dist/cjs/plugins/replication-webrtc/signaling-server.js.map +1 -0
- package/dist/cjs/plugins/replication-webrtc/webrtc-helper.js +32 -0
- package/dist/cjs/plugins/replication-webrtc/webrtc-helper.js.map +1 -0
- package/dist/cjs/plugins/replication-webrtc/webrtc-types.js +2 -0
- package/dist/cjs/plugins/replication-webrtc/webrtc-types.js.map +1 -0
- package/dist/cjs/plugins/replication-websocket/index.js +39 -0
- package/dist/cjs/plugins/replication-websocket/index.js.map +1 -0
- package/dist/cjs/plugins/replication-websocket/websocket-client.js +133 -0
- package/dist/cjs/plugins/replication-websocket/websocket-client.js.map +1 -0
- package/dist/cjs/plugins/replication-websocket/websocket-server.js +108 -0
- package/dist/cjs/plugins/replication-websocket/websocket-server.js.map +1 -0
- package/dist/cjs/plugins/replication-websocket/websocket-types.js +2 -0
- package/dist/cjs/plugins/replication-websocket/websocket-types.js.map +1 -0
- package/dist/cjs/plugins/state/helpers.js +81 -0
- package/dist/cjs/plugins/state/helpers.js.map +1 -0
- package/dist/cjs/plugins/state/index.js +42 -0
- package/dist/cjs/plugins/state/index.js.map +1 -0
- package/dist/cjs/plugins/state/rx-state.js +293 -0
- package/dist/cjs/plugins/state/rx-state.js.map +1 -0
- package/dist/cjs/plugins/state/types.js +2 -0
- package/dist/cjs/plugins/state/types.js.map +1 -0
- package/dist/cjs/plugins/storage-denokv/denokv-helper.js +49 -0
- package/dist/cjs/plugins/storage-denokv/denokv-helper.js.map +1 -0
- package/dist/cjs/plugins/storage-denokv/denokv-query.js +99 -0
- package/dist/cjs/plugins/storage-denokv/denokv-query.js.map +1 -0
- package/dist/cjs/plugins/storage-denokv/denokv-types.js +2 -0
- package/dist/cjs/plugins/storage-denokv/denokv-types.js.map +1 -0
- package/dist/cjs/plugins/storage-denokv/index.js +31 -0
- package/dist/cjs/plugins/storage-denokv/index.js.map +1 -0
- package/dist/cjs/plugins/storage-denokv/rx-storage-instance-denokv.js +332 -0
- package/dist/cjs/plugins/storage-denokv/rx-storage-instance-denokv.js.map +1 -0
- package/dist/cjs/plugins/storage-dexie/dexie-helper.js +259 -0
- package/dist/cjs/plugins/storage-dexie/dexie-helper.js.map +1 -0
- package/dist/cjs/plugins/storage-dexie/dexie-query.js +178 -0
- package/dist/cjs/plugins/storage-dexie/dexie-query.js.map +1 -0
- package/dist/cjs/plugins/storage-dexie/index.js +50 -0
- package/dist/cjs/plugins/storage-dexie/index.js.map +1 -0
- package/dist/cjs/plugins/storage-dexie/rx-storage-dexie.js +46 -0
- package/dist/cjs/plugins/storage-dexie/rx-storage-dexie.js.map +1 -0
- package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js +229 -0
- package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -0
- package/dist/cjs/plugins/storage-foundationdb/foundationdb-helpers.js +13 -0
- package/dist/cjs/plugins/storage-foundationdb/foundationdb-helpers.js.map +1 -0
- package/dist/cjs/plugins/storage-foundationdb/foundationdb-query.js +96 -0
- package/dist/cjs/plugins/storage-foundationdb/foundationdb-query.js.map +1 -0
- package/dist/cjs/plugins/storage-foundationdb/foundationdb-types.js +2 -0
- package/dist/cjs/plugins/storage-foundationdb/foundationdb-types.js.map +1 -0
- package/dist/cjs/plugins/storage-foundationdb/index.js +62 -0
- package/dist/cjs/plugins/storage-foundationdb/index.js.map +1 -0
- package/dist/cjs/plugins/storage-foundationdb/rx-storage-instance-foundationdb.js +309 -0
- package/dist/cjs/plugins/storage-foundationdb/rx-storage-instance-foundationdb.js.map +1 -0
- package/dist/cjs/plugins/storage-localstorage/index.js +45 -0
- package/dist/cjs/plugins/storage-localstorage/index.js.map +1 -0
- package/dist/cjs/plugins/storage-localstorage/localstorage-mock.js +38 -0
- package/dist/cjs/plugins/storage-localstorage/localstorage-mock.js.map +1 -0
- package/dist/cjs/plugins/storage-localstorage/rx-storage-instance-localstorage.js +443 -0
- package/dist/cjs/plugins/storage-localstorage/rx-storage-instance-localstorage.js.map +1 -0
- package/dist/cjs/plugins/storage-memory/binary-search-bounds.js +113 -0
- package/dist/cjs/plugins/storage-memory/binary-search-bounds.js.map +1 -0
- package/dist/cjs/plugins/storage-memory/index.js +91 -0
- package/dist/cjs/plugins/storage-memory/index.js.map +1 -0
- package/dist/cjs/plugins/storage-memory/memory-helper.js +177 -0
- package/dist/cjs/plugins/storage-memory/memory-helper.js.map +1 -0
- package/dist/cjs/plugins/storage-memory/memory-indexes.js +28 -0
- package/dist/cjs/plugins/storage-memory/memory-indexes.js.map +1 -0
- package/dist/cjs/plugins/storage-memory/memory-types.js +2 -0
- package/dist/cjs/plugins/storage-memory/memory-types.js.map +1 -0
- package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js +371 -0
- package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -0
- package/dist/cjs/plugins/storage-mongodb/index.js +50 -0
- package/dist/cjs/plugins/storage-mongodb/index.js.map +1 -0
- package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js +97 -0
- package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js.map +1 -0
- package/dist/cjs/plugins/storage-mongodb/mongodb-types.js +2 -0
- package/dist/cjs/plugins/storage-mongodb/mongodb-types.js.map +1 -0
- package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js +324 -0
- package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -0
- package/dist/cjs/plugins/storage-mongodb/rx-storage-mongodb.js +29 -0
- package/dist/cjs/plugins/storage-mongodb/rx-storage-mongodb.js.map +1 -0
- package/dist/cjs/plugins/storage-remote/index.js +61 -0
- package/dist/cjs/plugins/storage-remote/index.js.map +1 -0
- package/dist/cjs/plugins/storage-remote/message-channel-cache.js +52 -0
- package/dist/cjs/plugins/storage-remote/message-channel-cache.js.map +1 -0
- package/dist/cjs/plugins/storage-remote/remote.js +217 -0
- package/dist/cjs/plugins/storage-remote/remote.js.map +1 -0
- package/dist/cjs/plugins/storage-remote/rx-storage-remote.js +199 -0
- package/dist/cjs/plugins/storage-remote/rx-storage-remote.js.map +1 -0
- package/dist/cjs/plugins/storage-remote/storage-remote-helpers.js +25 -0
- package/dist/cjs/plugins/storage-remote/storage-remote-helpers.js.map +1 -0
- package/dist/cjs/plugins/storage-remote/storage-remote-types.js +2 -0
- package/dist/cjs/plugins/storage-remote/storage-remote-types.js.map +1 -0
- package/dist/cjs/plugins/storage-remote-websocket/index.js +183 -0
- package/dist/cjs/plugins/storage-remote-websocket/index.js.map +1 -0
- package/dist/cjs/plugins/storage-remote-websocket/types.js +2 -0
- package/dist/cjs/plugins/storage-remote-websocket/types.js.map +1 -0
- package/dist/cjs/plugins/storage-sqlite/index.js +84 -0
- package/dist/cjs/plugins/storage-sqlite/index.js.map +1 -0
- package/dist/cjs/plugins/storage-sqlite/sqlite-basics-helpers.js +530 -0
- package/dist/cjs/plugins/storage-sqlite/sqlite-basics-helpers.js.map +1 -0
- package/dist/cjs/plugins/storage-sqlite/sqlite-helpers.js +203 -0
- package/dist/cjs/plugins/storage-sqlite/sqlite-helpers.js.map +1 -0
- package/dist/cjs/plugins/storage-sqlite/sqlite-storage-instance.js +291 -0
- package/dist/cjs/plugins/storage-sqlite/sqlite-storage-instance.js.map +1 -0
- package/dist/cjs/plugins/storage-sqlite/sqlite-types.js +2 -0
- package/dist/cjs/plugins/storage-sqlite/sqlite-types.js.map +1 -0
- package/dist/cjs/plugins/test-utils/config.js +120 -0
- package/dist/cjs/plugins/test-utils/config.js.map +1 -0
- package/dist/cjs/plugins/test-utils/humans-collection.js +420 -0
- package/dist/cjs/plugins/test-utils/humans-collection.js.map +1 -0
- package/dist/cjs/plugins/test-utils/index.js +130 -0
- package/dist/cjs/plugins/test-utils/index.js.map +1 -0
- package/dist/cjs/plugins/test-utils/performance.js +275 -0
- package/dist/cjs/plugins/test-utils/performance.js.map +1 -0
- package/dist/cjs/plugins/test-utils/replication-base-test-suite.js +179 -0
- package/dist/cjs/plugins/test-utils/replication-base-test-suite.js.map +1 -0
- package/dist/cjs/plugins/test-utils/replication.js +54 -0
- package/dist/cjs/plugins/test-utils/replication.js.map +1 -0
- package/dist/cjs/plugins/test-utils/revisions.js +11 -0
- package/dist/cjs/plugins/test-utils/revisions.js.map +1 -0
- package/dist/cjs/plugins/test-utils/schema-objects.js +315 -0
- package/dist/cjs/plugins/test-utils/schema-objects.js.map +1 -0
- package/dist/cjs/plugins/test-utils/schemas.js +1254 -0
- package/dist/cjs/plugins/test-utils/schemas.js.map +1 -0
- package/dist/cjs/plugins/test-utils/test-util.js +72 -0
- package/dist/cjs/plugins/test-utils/test-util.js.map +1 -0
- package/dist/cjs/plugins/update/index.js +45 -0
- package/dist/cjs/plugins/update/index.js.map +1 -0
- package/dist/cjs/plugins/update/mingo-updater.js +20 -0
- package/dist/cjs/plugins/update/mingo-updater.js.map +1 -0
- package/dist/cjs/plugins/utils/index.js +226 -0
- package/dist/cjs/plugins/utils/index.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-array.js +150 -0
- package/dist/cjs/plugins/utils/utils-array.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-base64.js +57 -0
- package/dist/cjs/plugins/utils/utils-base64.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-blob.js +62 -0
- package/dist/cjs/plugins/utils/utils-blob.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-document.js +100 -0
- package/dist/cjs/plugins/utils/utils-document.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-error.js +42 -0
- package/dist/cjs/plugins/utils/utils-error.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-global.js +12 -0
- package/dist/cjs/plugins/utils/utils-global.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-hash.js +59 -0
- package/dist/cjs/plugins/utils/utils-hash.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-map.js +25 -0
- package/dist/cjs/plugins/utils/utils-map.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-number.js +16 -0
- package/dist/cjs/plugins/utils/utils-number.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-object-deep-equal.js +42 -0
- package/dist/cjs/plugins/utils/utils-object-deep-equal.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-object-dot-prop.js +306 -0
- package/dist/cjs/plugins/utils/utils-object-dot-prop.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-object.js +245 -0
- package/dist/cjs/plugins/utils/utils-object.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-other.js +69 -0
- package/dist/cjs/plugins/utils/utils-other.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-premium.js +37 -0
- package/dist/cjs/plugins/utils/utils-premium.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-promise.js +149 -0
- package/dist/cjs/plugins/utils/utils-promise.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-regex.js +9 -0
- package/dist/cjs/plugins/utils/utils-regex.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-revision.js +60 -0
- package/dist/cjs/plugins/utils/utils-revision.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-rxdb-version.js +11 -0
- package/dist/cjs/plugins/utils/utils-rxdb-version.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-rxdb-version.template.js +11 -0
- package/dist/cjs/plugins/utils/utils-rxdb-version.template.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-string.js +97 -0
- package/dist/cjs/plugins/utils/utils-string.js.map +1 -0
- package/dist/cjs/plugins/utils/utils-time.js +42 -0
- package/dist/cjs/plugins/utils/utils-time.js.map +1 -0
- package/dist/cjs/plugins/validate-ajv/index.js +53 -0
- package/dist/cjs/plugins/validate-ajv/index.js.map +1 -0
- package/dist/cjs/plugins/validate-is-my-json-valid/index.js +29 -0
- package/dist/cjs/plugins/validate-is-my-json-valid/index.js.map +1 -0
- package/dist/cjs/plugins/validate-z-schema/index.js +58 -0
- package/dist/cjs/plugins/validate-z-schema/index.js.map +1 -0
- package/dist/cjs/plugins/vector/helper.js +2 -0
- package/dist/cjs/plugins/vector/helper.js.map +1 -0
- package/dist/cjs/plugins/vector/index.js +17 -0
- package/dist/cjs/plugins/vector/index.js.map +1 -0
- package/dist/cjs/plugins/vector/types.js +2 -0
- package/dist/cjs/plugins/vector/types.js.map +1 -0
- package/dist/cjs/plugins/vector/vector-distance.js +38 -0
- package/dist/cjs/plugins/vector/vector-distance.js.map +1 -0
- package/dist/cjs/plugins/webmcp/index.js +28 -0
- package/dist/cjs/plugins/webmcp/index.js.map +1 -0
- package/dist/cjs/plugins/webmcp/nosql-query-schema.js +360 -0
- package/dist/cjs/plugins/webmcp/nosql-query-schema.js.map +1 -0
- package/dist/cjs/plugins/webmcp/webmcp.js +315 -0
- package/dist/cjs/plugins/webmcp/webmcp.js.map +1 -0
- package/dist/cjs/query-cache.js +110 -0
- package/dist/cjs/query-cache.js.map +1 -0
- package/dist/cjs/query-planner.js +307 -0
- package/dist/cjs/query-planner.js.map +1 -0
- package/dist/cjs/replication-protocol/checkpoint.js +103 -0
- package/dist/cjs/replication-protocol/checkpoint.js.map +1 -0
- package/dist/cjs/replication-protocol/conflicts.js +36 -0
- package/dist/cjs/replication-protocol/conflicts.js.map +1 -0
- package/dist/cjs/replication-protocol/default-conflict-handler.js +39 -0
- package/dist/cjs/replication-protocol/default-conflict-handler.js.map +1 -0
- package/dist/cjs/replication-protocol/downstream.js +339 -0
- package/dist/cjs/replication-protocol/downstream.js.map +1 -0
- package/dist/cjs/replication-protocol/helper.js +58 -0
- package/dist/cjs/replication-protocol/helper.js.map +1 -0
- package/dist/cjs/replication-protocol/index.js +314 -0
- package/dist/cjs/replication-protocol/index.js.map +1 -0
- package/dist/cjs/replication-protocol/meta-instance.js +130 -0
- package/dist/cjs/replication-protocol/meta-instance.js.map +1 -0
- package/dist/cjs/replication-protocol/upstream.js +384 -0
- package/dist/cjs/replication-protocol/upstream.js.map +1 -0
- package/dist/cjs/rx-change-event.js +112 -0
- package/dist/cjs/rx-change-event.js.map +1 -0
- package/dist/cjs/rx-collection-helper.js +205 -0
- package/dist/cjs/rx-collection-helper.js.map +1 -0
- package/dist/cjs/rx-collection.js +931 -0
- package/dist/cjs/rx-collection.js.map +1 -0
- package/dist/cjs/rx-database-internal-store.js +283 -0
- package/dist/cjs/rx-database-internal-store.js.map +1 -0
- package/dist/cjs/rx-database.js +682 -0
- package/dist/cjs/rx-database.js.map +1 -0
- package/dist/cjs/rx-document-prototype-merge.js +87 -0
- package/dist/cjs/rx-document-prototype-merge.js.map +1 -0
- package/dist/cjs/rx-document.js +404 -0
- package/dist/cjs/rx-document.js.map +1 -0
- package/dist/cjs/rx-error.js +167 -0
- package/dist/cjs/rx-error.js.map +1 -0
- package/dist/cjs/rx-query-helper.js +277 -0
- package/dist/cjs/rx-query-helper.js.map +1 -0
- package/dist/cjs/rx-query-mingo.js +60 -0
- package/dist/cjs/rx-query-mingo.js.map +1 -0
- package/dist/cjs/rx-query-single-result.js +105 -0
- package/dist/cjs/rx-query-single-result.js.map +1 -0
- package/dist/cjs/rx-query.js +703 -0
- package/dist/cjs/rx-query.js.map +1 -0
- package/dist/cjs/rx-schema-helper.js +333 -0
- package/dist/cjs/rx-schema-helper.js.map +1 -0
- package/dist/cjs/rx-schema.js +189 -0
- package/dist/cjs/rx-schema.js.map +1 -0
- package/dist/cjs/rx-storage-helper.js +808 -0
- package/dist/cjs/rx-storage-helper.js.map +1 -0
- package/dist/cjs/rx-storage-multiinstance.js +121 -0
- package/dist/cjs/rx-storage-multiinstance.js.map +1 -0
- package/dist/cjs/types/conflict-handling.d.js +2 -0
- package/dist/cjs/types/conflict-handling.d.js.map +1 -0
- package/dist/cjs/types/couchdb.d.js +2 -0
- package/dist/cjs/types/couchdb.d.js.map +1 -0
- package/dist/cjs/types/index.d.js +2 -0
- package/dist/cjs/types/index.d.js.map +1 -0
- package/dist/cjs/types/modules/index.d.js +2 -0
- package/dist/cjs/types/modules/index.d.js.map +1 -0
- package/dist/cjs/types/modules/mocha.parallel.d.js +2 -0
- package/dist/cjs/types/modules/mocha.parallel.d.js.map +1 -0
- package/dist/cjs/types/plugins/backup.d.js +2 -0
- package/dist/cjs/types/plugins/backup.d.js.map +1 -0
- package/dist/cjs/types/plugins/cleanup.d.js +2 -0
- package/dist/cjs/types/plugins/cleanup.d.js.map +1 -0
- package/dist/cjs/types/plugins/crdt.d.js +2 -0
- package/dist/cjs/types/plugins/crdt.d.js.map +1 -0
- package/dist/cjs/types/plugins/dexie.d.js +2 -0
- package/dist/cjs/types/plugins/dexie.d.js.map +1 -0
- package/dist/cjs/types/plugins/local-documents.d.js +2 -0
- package/dist/cjs/types/plugins/local-documents.d.js.map +1 -0
- package/dist/cjs/types/plugins/migration.d.js +2 -0
- package/dist/cjs/types/plugins/migration.d.js.map +1 -0
- package/dist/cjs/types/plugins/reactivity.d.js +2 -0
- package/dist/cjs/types/plugins/reactivity.d.js.map +1 -0
- package/dist/cjs/types/plugins/replication-graphql.d.js +2 -0
- package/dist/cjs/types/plugins/replication-graphql.d.js.map +1 -0
- package/dist/cjs/types/plugins/replication.d.js +2 -0
- package/dist/cjs/types/plugins/replication.d.js.map +1 -0
- package/dist/cjs/types/plugins/state.d.js +2 -0
- package/dist/cjs/types/plugins/state.d.js.map +1 -0
- package/dist/cjs/types/plugins/update.d.js +2 -0
- package/dist/cjs/types/plugins/update.d.js.map +1 -0
- package/dist/cjs/types/plugins/webmcp.d.js +2 -0
- package/dist/cjs/types/plugins/webmcp.d.js.map +1 -0
- package/dist/cjs/types/query-planner.d.js +2 -0
- package/dist/cjs/types/query-planner.d.js.map +1 -0
- package/dist/cjs/types/replication-protocol.d.js +2 -0
- package/dist/cjs/types/replication-protocol.d.js.map +1 -0
- package/dist/cjs/types/rx-attachment.d.js +2 -0
- package/dist/cjs/types/rx-attachment.d.js.map +1 -0
- package/dist/cjs/types/rx-change-event.d.js +2 -0
- package/dist/cjs/types/rx-change-event.d.js.map +1 -0
- package/dist/cjs/types/rx-collection.d.js +2 -0
- package/dist/cjs/types/rx-collection.d.js.map +1 -0
- package/dist/cjs/types/rx-database-internal-store.d.js +2 -0
- package/dist/cjs/types/rx-database-internal-store.d.js.map +1 -0
- package/dist/cjs/types/rx-database.d.js +2 -0
- package/dist/cjs/types/rx-database.d.js.map +1 -0
- package/dist/cjs/types/rx-document.d.js +2 -0
- package/dist/cjs/types/rx-document.d.js.map +1 -0
- package/dist/cjs/types/rx-error.d.js +2 -0
- package/dist/cjs/types/rx-error.d.js.map +1 -0
- package/dist/cjs/types/rx-plugin.d.js +2 -0
- package/dist/cjs/types/rx-plugin.d.js.map +1 -0
- package/dist/cjs/types/rx-query.d.js +2 -0
- package/dist/cjs/types/rx-query.d.js.map +1 -0
- package/dist/cjs/types/rx-schema.d.js +2 -0
- package/dist/cjs/types/rx-schema.d.js.map +1 -0
- package/dist/cjs/types/rx-storage.d.js +2 -0
- package/dist/cjs/types/rx-storage.d.js.map +1 -0
- package/dist/cjs/types/rx-storage.interface.d.js +2 -0
- package/dist/cjs/types/rx-storage.interface.d.js.map +1 -0
- package/dist/cjs/types/util.d.js +2 -0
- package/dist/cjs/types/util.d.js.map +1 -0
- package/dist/esm/change-event-buffer.js +141 -0
- package/dist/esm/change-event-buffer.js.map +1 -0
- package/dist/esm/custom-index.js +271 -0
- package/dist/esm/custom-index.js.map +1 -0
- package/dist/esm/doc-cache.js +227 -0
- package/dist/esm/doc-cache.js.map +1 -0
- package/dist/esm/event-reduce.js +93 -0
- package/dist/esm/event-reduce.js.map +1 -0
- package/dist/esm/hooks.js +122 -0
- package/dist/esm/hooks.js.map +1 -0
- package/dist/esm/incremental-write.js +161 -0
- package/dist/esm/incremental-write.js.map +1 -0
- package/dist/esm/index.js +30 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/overwritable.js +33 -0
- package/dist/esm/overwritable.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/plugin-helpers.js +217 -0
- package/dist/esm/plugin-helpers.js.map +1 -0
- package/dist/esm/plugin.js +88 -0
- package/dist/esm/plugin.js.map +1 -0
- package/dist/esm/plugins/attachments/attachments-utils.js +41 -0
- package/dist/esm/plugins/attachments/attachments-utils.js.map +1 -0
- package/dist/esm/plugins/attachments/index.js +202 -0
- package/dist/esm/plugins/attachments/index.js.map +1 -0
- package/dist/esm/plugins/attachments-compression/index.js +134 -0
- package/dist/esm/plugins/attachments-compression/index.js.map +1 -0
- package/dist/esm/plugins/backup/file-util.js +87 -0
- package/dist/esm/plugins/backup/file-util.js.map +1 -0
- package/dist/esm/plugins/backup/index.js +183 -0
- package/dist/esm/plugins/backup/index.js.map +1 -0
- package/dist/esm/plugins/cleanup/cleanup-helper.js +11 -0
- package/dist/esm/plugins/cleanup/cleanup-helper.js.map +1 -0
- package/dist/esm/plugins/cleanup/cleanup-state.js +75 -0
- package/dist/esm/plugins/cleanup/cleanup-state.js.map +1 -0
- package/dist/esm/plugins/cleanup/cleanup.js +108 -0
- package/dist/esm/plugins/cleanup/cleanup.js.map +1 -0
- package/dist/esm/plugins/cleanup/index.js +35 -0
- package/dist/esm/plugins/cleanup/index.js.map +1 -0
- package/dist/esm/plugins/crdt/index.js +378 -0
- package/dist/esm/plugins/crdt/index.js.map +1 -0
- package/dist/esm/plugins/dev-mode/check-document.js +150 -0
- package/dist/esm/plugins/dev-mode/check-document.js.map +1 -0
- package/dist/esm/plugins/dev-mode/check-migration-strategies.js +38 -0
- package/dist/esm/plugins/dev-mode/check-migration-strategies.js.map +1 -0
- package/dist/esm/plugins/dev-mode/check-orm.js +47 -0
- package/dist/esm/plugins/dev-mode/check-orm.js.map +1 -0
- package/dist/esm/plugins/dev-mode/check-query.js +174 -0
- package/dist/esm/plugins/dev-mode/check-query.js.map +1 -0
- package/dist/esm/plugins/dev-mode/check-schema.js +478 -0
- package/dist/esm/plugins/dev-mode/check-schema.js.map +1 -0
- package/dist/esm/plugins/dev-mode/dev-mode-tracking.js +87 -0
- package/dist/esm/plugins/dev-mode/dev-mode-tracking.js.map +1 -0
- package/dist/esm/plugins/dev-mode/entity-properties.js +49 -0
- package/dist/esm/plugins/dev-mode/entity-properties.js.map +1 -0
- package/dist/esm/plugins/dev-mode/error-messages.js +1289 -0
- package/dist/esm/plugins/dev-mode/error-messages.js.map +1 -0
- package/dist/esm/plugins/dev-mode/index.js +151 -0
- package/dist/esm/plugins/dev-mode/index.js.map +1 -0
- package/dist/esm/plugins/dev-mode/unallowed-properties.js +81 -0
- package/dist/esm/plugins/dev-mode/unallowed-properties.js.map +1 -0
- package/dist/esm/plugins/electron/electron-helper.js +3 -0
- package/dist/esm/plugins/electron/electron-helper.js.map +1 -0
- package/dist/esm/plugins/electron/index.js +4 -0
- package/dist/esm/plugins/electron/index.js.map +1 -0
- package/dist/esm/plugins/electron/rx-storage-ipc-main.js +39 -0
- package/dist/esm/plugins/electron/rx-storage-ipc-main.js.map +1 -0
- package/dist/esm/plugins/electron/rx-storage-ipc-renderer.js +31 -0
- package/dist/esm/plugins/electron/rx-storage-ipc-renderer.js.map +1 -0
- package/dist/esm/plugins/encryption-crypto-js/index.js +154 -0
- package/dist/esm/plugins/encryption-crypto-js/index.js.map +1 -0
- package/dist/esm/plugins/flutter/index.js +55 -0
- package/dist/esm/plugins/flutter/index.js.map +1 -0
- package/dist/esm/plugins/json-dump/index.js +87 -0
- package/dist/esm/plugins/json-dump/index.js.map +1 -0
- package/dist/esm/plugins/key-compression/index.js +127 -0
- package/dist/esm/plugins/key-compression/index.js.map +1 -0
- package/dist/esm/plugins/leader-election/index.js +95 -0
- package/dist/esm/plugins/leader-election/index.js.map +1 -0
- package/dist/esm/plugins/local-documents/index.js +70 -0
- package/dist/esm/plugins/local-documents/index.js.map +1 -0
- package/dist/esm/plugins/local-documents/local-documents-helper.js +67 -0
- package/dist/esm/plugins/local-documents/local-documents-helper.js.map +1 -0
- package/dist/esm/plugins/local-documents/local-documents.js +99 -0
- package/dist/esm/plugins/local-documents/local-documents.js.map +1 -0
- package/dist/esm/plugins/local-documents/rx-local-document.js +248 -0
- package/dist/esm/plugins/local-documents/rx-local-document.js.map +1 -0
- package/dist/esm/plugins/migration-schema/index.js +42 -0
- package/dist/esm/plugins/migration-schema/index.js.map +1 -0
- package/dist/esm/plugins/migration-schema/migration-helpers.js +103 -0
- package/dist/esm/plugins/migration-schema/migration-helpers.js.map +1 -0
- package/dist/esm/plugins/migration-schema/migration-types.js +3 -0
- package/dist/esm/plugins/migration-schema/migration-types.js.map +1 -0
- package/dist/esm/plugins/migration-schema/rx-migration-state.js +404 -0
- package/dist/esm/plugins/migration-schema/rx-migration-state.js.map +1 -0
- package/dist/esm/plugins/migration-storage/index.js +166 -0
- package/dist/esm/plugins/migration-storage/index.js.map +1 -0
- package/dist/esm/plugins/pipeline/flagged-functions.js +122 -0
- package/dist/esm/plugins/pipeline/flagged-functions.js.map +1 -0
- package/dist/esm/plugins/pipeline/index.js +13 -0
- package/dist/esm/plugins/pipeline/index.js.map +1 -0
- package/dist/esm/plugins/pipeline/rx-pipeline.js +210 -0
- package/dist/esm/plugins/pipeline/rx-pipeline.js.map +1 -0
- package/dist/esm/plugins/pipeline/types.js +3 -0
- package/dist/esm/plugins/pipeline/types.js.map +1 -0
- package/dist/esm/plugins/query-builder/index.js +48 -0
- package/dist/esm/plugins/query-builder/index.js.map +1 -0
- package/dist/esm/plugins/query-builder/mquery/mquery-utils.js +33 -0
- package/dist/esm/plugins/query-builder/mquery/mquery-utils.js.map +1 -0
- package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js +478 -0
- package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -0
- package/dist/esm/plugins/react/database-context.js +8 -0
- package/dist/esm/plugins/react/database-context.js.map +1 -0
- package/dist/esm/plugins/react/database-provider.js +34 -0
- package/dist/esm/plugins/react/database-provider.js.map +1 -0
- package/dist/esm/plugins/react/hooks/index.js +5 -0
- package/dist/esm/plugins/react/hooks/index.js.map +1 -0
- package/dist/esm/plugins/react/hooks/use-live-rx-query.js +22 -0
- package/dist/esm/plugins/react/hooks/use-live-rx-query.js.map +1 -0
- package/dist/esm/plugins/react/hooks/use-rx-collection.js +34 -0
- package/dist/esm/plugins/react/hooks/use-rx-collection.js.map +1 -0
- package/dist/esm/plugins/react/hooks/use-rx-database.js +19 -0
- package/dist/esm/plugins/react/hooks/use-rx-database.js.map +1 -0
- package/dist/esm/plugins/react/hooks/use-rx-query.js +92 -0
- package/dist/esm/plugins/react/hooks/use-rx-query.js.map +1 -0
- package/dist/esm/plugins/react/index.js +3 -0
- package/dist/esm/plugins/react/index.js.map +1 -0
- package/dist/esm/plugins/reactivity-angular/index.js +25 -0
- package/dist/esm/plugins/reactivity-angular/index.js.map +1 -0
- package/dist/esm/plugins/reactivity-preact-signals/index.js +62 -0
- package/dist/esm/plugins/reactivity-preact-signals/index.js.map +1 -0
- package/dist/esm/plugins/reactivity-vue/index.js +27 -0
- package/dist/esm/plugins/reactivity-vue/index.js.map +1 -0
- package/dist/esm/plugins/replication/index.js +479 -0
- package/dist/esm/plugins/replication/index.js.map +1 -0
- package/dist/esm/plugins/replication/replication-helper.js +86 -0
- package/dist/esm/plugins/replication/replication-helper.js.map +1 -0
- package/dist/esm/plugins/replication-appwrite/appwrite-helpers.js +26 -0
- package/dist/esm/plugins/replication-appwrite/appwrite-helpers.js.map +1 -0
- package/dist/esm/plugins/replication-appwrite/appwrite-types.js +3 -0
- package/dist/esm/plugins/replication-appwrite/appwrite-types.js.map +1 -0
- package/dist/esm/plugins/replication-appwrite/index.js +168 -0
- package/dist/esm/plugins/replication-appwrite/index.js.map +1 -0
- package/dist/esm/plugins/replication-couchdb/couchdb-helper.js +65 -0
- package/dist/esm/plugins/replication-couchdb/couchdb-helper.js.map +1 -0
- package/dist/esm/plugins/replication-couchdb/couchdb-types.js +3 -0
- package/dist/esm/plugins/replication-couchdb/couchdb-types.js.map +1 -0
- package/dist/esm/plugins/replication-couchdb/index.js +254 -0
- package/dist/esm/plugins/replication-couchdb/index.js.map +1 -0
- package/dist/esm/plugins/replication-firestore/firestore-helper.js +49 -0
- package/dist/esm/plugins/replication-firestore/firestore-helper.js.map +1 -0
- package/dist/esm/plugins/replication-firestore/firestore-types.js +3 -0
- package/dist/esm/plugins/replication-firestore/firestore-types.js.map +1 -0
- package/dist/esm/plugins/replication-firestore/index.js +233 -0
- package/dist/esm/plugins/replication-firestore/index.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/document-handling.js +140 -0
- package/dist/esm/plugins/replication-google-drive/document-handling.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/downstream.js +66 -0
- package/dist/esm/plugins/replication-google-drive/downstream.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/google-drive-helper.js +331 -0
- package/dist/esm/plugins/replication-google-drive/google-drive-helper.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/google-drive-types.js +3 -0
- package/dist/esm/plugins/replication-google-drive/google-drive-types.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/index.js +126 -0
- package/dist/esm/plugins/replication-google-drive/index.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/init.js +70 -0
- package/dist/esm/plugins/replication-google-drive/init.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/multipart.js +67 -0
- package/dist/esm/plugins/replication-google-drive/multipart.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/signaling.js +253 -0
- package/dist/esm/plugins/replication-google-drive/signaling.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/transaction.js +123 -0
- package/dist/esm/plugins/replication-google-drive/transaction.js.map +1 -0
- package/dist/esm/plugins/replication-google-drive/upstream.js +171 -0
- package/dist/esm/plugins/replication-google-drive/upstream.js.map +1 -0
- package/dist/esm/plugins/replication-graphql/graphql-schema-from-rx-schema.js +228 -0
- package/dist/esm/plugins/replication-graphql/graphql-schema-from-rx-schema.js.map +1 -0
- package/dist/esm/plugins/replication-graphql/graphql-websocket.js +35 -0
- package/dist/esm/plugins/replication-graphql/graphql-websocket.js.map +1 -0
- package/dist/esm/plugins/replication-graphql/helper.js +21 -0
- package/dist/esm/plugins/replication-graphql/helper.js.map +1 -0
- package/dist/esm/plugins/replication-graphql/index.js +161 -0
- package/dist/esm/plugins/replication-graphql/index.js.map +1 -0
- package/dist/esm/plugins/replication-graphql/query-builder-from-rx-schema.js +133 -0
- package/dist/esm/plugins/replication-graphql/query-builder-from-rx-schema.js.map +1 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/document-handling.js +178 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/document-handling.js.map +1 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/downstream.js +71 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/downstream.js.map +1 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/index.js +126 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/index.js.map +1 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/init.js +70 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/init.js.map +1 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/microsoft-onedrive-helper.js +258 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/microsoft-onedrive-helper.js.map +1 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/microsoft-onedrive-types.js +3 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/microsoft-onedrive-types.js.map +1 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js +226 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js.map +1 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/transaction.js +127 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/transaction.js.map +1 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/upstream.js +179 -0
- package/dist/esm/plugins/replication-microsoft-onedrive/upstream.js.map +1 -0
- package/dist/esm/plugins/replication-mongodb/index.js +197 -0
- package/dist/esm/plugins/replication-mongodb/index.js.map +1 -0
- package/dist/esm/plugins/replication-mongodb/mongodb-checkpoint.js +131 -0
- package/dist/esm/plugins/replication-mongodb/mongodb-checkpoint.js.map +1 -0
- package/dist/esm/plugins/replication-mongodb/mongodb-helper.js +45 -0
- package/dist/esm/plugins/replication-mongodb/mongodb-helper.js.map +1 -0
- package/dist/esm/plugins/replication-mongodb/mongodb-types.js +3 -0
- package/dist/esm/plugins/replication-mongodb/mongodb-types.js.map +1 -0
- package/dist/esm/plugins/replication-nats/index.js +199 -0
- package/dist/esm/plugins/replication-nats/index.js.map +1 -0
- package/dist/esm/plugins/replication-nats/nats-helper.js +7 -0
- package/dist/esm/plugins/replication-nats/nats-helper.js.map +1 -0
- package/dist/esm/plugins/replication-nats/nats-types.js +3 -0
- package/dist/esm/plugins/replication-nats/nats-types.js.map +1 -0
- package/dist/esm/plugins/replication-supabase/helper.js +35 -0
- package/dist/esm/plugins/replication-supabase/helper.js.map +1 -0
- package/dist/esm/plugins/replication-supabase/index.js +231 -0
- package/dist/esm/plugins/replication-supabase/index.js.map +1 -0
- package/dist/esm/plugins/replication-supabase/types.js +3 -0
- package/dist/esm/plugins/replication-supabase/types.js.map +1 -0
- package/dist/esm/plugins/replication-webrtc/connection-handler-p2pcf.js +78 -0
- package/dist/esm/plugins/replication-webrtc/connection-handler-p2pcf.js.map +1 -0
- package/dist/esm/plugins/replication-webrtc/connection-handler-simple-peer.js +192 -0
- package/dist/esm/plugins/replication-webrtc/connection-handler-simple-peer.js.map +1 -0
- package/dist/esm/plugins/replication-webrtc/connection-handler-webtorrent.js +136 -0
- package/dist/esm/plugins/replication-webrtc/connection-handler-webtorrent.js.map +1 -0
- package/dist/esm/plugins/replication-webrtc/index.js +207 -0
- package/dist/esm/plugins/replication-webrtc/index.js.map +1 -0
- package/dist/esm/plugins/replication-webrtc/signaling-server.js +144 -0
- package/dist/esm/plugins/replication-webrtc/signaling-server.js.map +1 -0
- package/dist/esm/plugins/replication-webrtc/webrtc-helper.js +26 -0
- package/dist/esm/plugins/replication-webrtc/webrtc-helper.js.map +1 -0
- package/dist/esm/plugins/replication-webrtc/webrtc-types.js +3 -0
- package/dist/esm/plugins/replication-webrtc/webrtc-types.js.map +1 -0
- package/dist/esm/plugins/replication-websocket/index.js +4 -0
- package/dist/esm/plugins/replication-websocket/index.js.map +1 -0
- package/dist/esm/plugins/replication-websocket/websocket-client.js +125 -0
- package/dist/esm/plugins/replication-websocket/websocket-client.js.map +1 -0
- package/dist/esm/plugins/replication-websocket/websocket-server.js +100 -0
- package/dist/esm/plugins/replication-websocket/websocket-server.js.map +1 -0
- package/dist/esm/plugins/replication-websocket/websocket-types.js +3 -0
- package/dist/esm/plugins/replication-websocket/websocket-types.js.map +1 -0
- package/dist/esm/plugins/state/helpers.js +73 -0
- package/dist/esm/plugins/state/helpers.js.map +1 -0
- package/dist/esm/plugins/state/index.js +20 -0
- package/dist/esm/plugins/state/index.js.map +1 -0
- package/dist/esm/plugins/state/rx-state.js +285 -0
- package/dist/esm/plugins/state/rx-state.js.map +1 -0
- package/dist/esm/plugins/state/types.js +3 -0
- package/dist/esm/plugins/state/types.js.map +1 -0
- package/dist/esm/plugins/storage-denokv/denokv-helper.js +40 -0
- package/dist/esm/plugins/storage-denokv/denokv-helper.js.map +1 -0
- package/dist/esm/plugins/storage-denokv/denokv-query.js +93 -0
- package/dist/esm/plugins/storage-denokv/denokv-query.js.map +1 -0
- package/dist/esm/plugins/storage-denokv/denokv-types.js +3 -0
- package/dist/esm/plugins/storage-denokv/denokv-types.js.map +1 -0
- package/dist/esm/plugins/storage-denokv/index.js +24 -0
- package/dist/esm/plugins/storage-denokv/index.js.map +1 -0
- package/dist/esm/plugins/storage-denokv/rx-storage-instance-denokv.js +325 -0
- package/dist/esm/plugins/storage-denokv/rx-storage-instance-denokv.js.map +1 -0
- package/dist/esm/plugins/storage-dexie/dexie-helper.js +241 -0
- package/dist/esm/plugins/storage-dexie/dexie-helper.js.map +1 -0
- package/dist/esm/plugins/storage-dexie/dexie-query.js +169 -0
- package/dist/esm/plugins/storage-dexie/dexie-query.js.map +1 -0
- package/dist/esm/plugins/storage-dexie/index.js +5 -0
- package/dist/esm/plugins/storage-dexie/index.js.map +1 -0
- package/dist/esm/plugins/storage-dexie/rx-storage-dexie.js +39 -0
- package/dist/esm/plugins/storage-dexie/rx-storage-dexie.js.map +1 -0
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js +222 -0
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -0
- package/dist/esm/plugins/storage-foundationdb/foundationdb-helpers.js +6 -0
- package/dist/esm/plugins/storage-foundationdb/foundationdb-helpers.js.map +1 -0
- package/dist/esm/plugins/storage-foundationdb/foundationdb-query.js +90 -0
- package/dist/esm/plugins/storage-foundationdb/foundationdb-query.js.map +1 -0
- package/dist/esm/plugins/storage-foundationdb/foundationdb-types.js +3 -0
- package/dist/esm/plugins/storage-foundationdb/foundationdb-types.js.map +1 -0
- package/dist/esm/plugins/storage-foundationdb/index.js +31 -0
- package/dist/esm/plugins/storage-foundationdb/index.js.map +1 -0
- package/dist/esm/plugins/storage-foundationdb/rx-storage-instance-foundationdb.js +302 -0
- package/dist/esm/plugins/storage-foundationdb/rx-storage-instance-foundationdb.js.map +1 -0
- package/dist/esm/plugins/storage-localstorage/index.js +23 -0
- package/dist/esm/plugins/storage-localstorage/index.js.map +1 -0
- package/dist/esm/plugins/storage-localstorage/localstorage-mock.js +33 -0
- package/dist/esm/plugins/storage-localstorage/localstorage-mock.js.map +1 -0
- package/dist/esm/plugins/storage-localstorage/rx-storage-instance-localstorage.js +432 -0
- package/dist/esm/plugins/storage-localstorage/rx-storage-instance-localstorage.js.map +1 -0
- package/dist/esm/plugins/storage-memory/binary-search-bounds.js +103 -0
- package/dist/esm/plugins/storage-memory/binary-search-bounds.js.map +1 -0
- package/dist/esm/plugins/storage-memory/index.js +29 -0
- package/dist/esm/plugins/storage-memory/index.js.map +1 -0
- package/dist/esm/plugins/storage-memory/memory-helper.js +165 -0
- package/dist/esm/plugins/storage-memory/memory-helper.js.map +1 -0
- package/dist/esm/plugins/storage-memory/memory-indexes.js +21 -0
- package/dist/esm/plugins/storage-memory/memory-indexes.js.map +1 -0
- package/dist/esm/plugins/storage-memory/memory-types.js +3 -0
- package/dist/esm/plugins/storage-memory/memory-types.js.map +1 -0
- package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js +364 -0
- package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -0
- package/dist/esm/plugins/storage-mongodb/index.js +5 -0
- package/dist/esm/plugins/storage-mongodb/index.js.map +1 -0
- package/dist/esm/plugins/storage-mongodb/mongodb-helper.js +85 -0
- package/dist/esm/plugins/storage-mongodb/mongodb-helper.js.map +1 -0
- package/dist/esm/plugins/storage-mongodb/mongodb-types.js +3 -0
- package/dist/esm/plugins/storage-mongodb/mongodb-types.js.map +1 -0
- package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js +316 -0
- package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -0
- package/dist/esm/plugins/storage-mongodb/rx-storage-mongodb.js +22 -0
- package/dist/esm/plugins/storage-mongodb/rx-storage-mongodb.js.map +1 -0
- package/dist/esm/plugins/storage-remote/index.js +6 -0
- package/dist/esm/plugins/storage-remote/index.js.map +1 -0
- package/dist/esm/plugins/storage-remote/message-channel-cache.js +44 -0
- package/dist/esm/plugins/storage-remote/message-channel-cache.js.map +1 -0
- package/dist/esm/plugins/storage-remote/remote.js +212 -0
- package/dist/esm/plugins/storage-remote/remote.js.map +1 -0
- package/dist/esm/plugins/storage-remote/rx-storage-remote.js +193 -0
- package/dist/esm/plugins/storage-remote/rx-storage-remote.js.map +1 -0
- package/dist/esm/plugins/storage-remote/storage-remote-helpers.js +18 -0
- package/dist/esm/plugins/storage-remote/storage-remote-helpers.js.map +1 -0
- package/dist/esm/plugins/storage-remote/storage-remote-types.js +3 -0
- package/dist/esm/plugins/storage-remote/storage-remote-types.js.map +1 -0
- package/dist/esm/plugins/storage-remote-websocket/index.js +161 -0
- package/dist/esm/plugins/storage-remote-websocket/index.js.map +1 -0
- package/dist/esm/plugins/storage-remote-websocket/types.js +3 -0
- package/dist/esm/plugins/storage-remote-websocket/types.js.map +1 -0
- package/dist/esm/plugins/storage-sqlite/index.js +31 -0
- package/dist/esm/plugins/storage-sqlite/index.js.map +1 -0
- package/dist/esm/plugins/storage-sqlite/sqlite-basics-helpers.js +510 -0
- package/dist/esm/plugins/storage-sqlite/sqlite-basics-helpers.js.map +1 -0
- package/dist/esm/plugins/storage-sqlite/sqlite-helpers.js +187 -0
- package/dist/esm/plugins/storage-sqlite/sqlite-helpers.js.map +1 -0
- package/dist/esm/plugins/storage-sqlite/sqlite-storage-instance.js +283 -0
- package/dist/esm/plugins/storage-sqlite/sqlite-storage-instance.js.map +1 -0
- package/dist/esm/plugins/storage-sqlite/sqlite-types.js +3 -0
- package/dist/esm/plugins/storage-sqlite/sqlite-types.js.map +1 -0
- package/dist/esm/plugins/test-utils/config.js +104 -0
- package/dist/esm/plugins/test-utils/config.js.map +1 -0
- package/dist/esm/plugins/test-utils/humans-collection.js +397 -0
- package/dist/esm/plugins/test-utils/humans-collection.js.map +1 -0
- package/dist/esm/plugins/test-utils/index.js +22 -0
- package/dist/esm/plugins/test-utils/index.js.map +1 -0
- package/dist/esm/plugins/test-utils/performance.js +267 -0
- package/dist/esm/plugins/test-utils/performance.js.map +1 -0
- package/dist/esm/plugins/test-utils/replication-base-test-suite.js +170 -0
- package/dist/esm/plugins/test-utils/replication-base-test-suite.js.map +1 -0
- package/dist/esm/plugins/test-utils/replication.js +46 -0
- package/dist/esm/plugins/test-utils/replication.js.map +1 -0
- package/dist/esm/plugins/test-utils/revisions.js +5 -0
- package/dist/esm/plugins/test-utils/revisions.js.map +1 -0
- package/dist/esm/plugins/test-utils/schema-objects.js +283 -0
- package/dist/esm/plugins/test-utils/schema-objects.js.map +1 -0
- package/dist/esm/plugins/test-utils/schemas.js +1244 -0
- package/dist/esm/plugins/test-utils/schemas.js.map +1 -0
- package/dist/esm/plugins/test-utils/test-util.js +62 -0
- package/dist/esm/plugins/test-utils/test-util.js.map +1 -0
- package/dist/esm/plugins/update/index.js +35 -0
- package/dist/esm/plugins/update/index.js.map +1 -0
- package/dist/esm/plugins/update/mingo-updater.js +13 -0
- package/dist/esm/plugins/update/mingo-updater.js.map +1 -0
- package/dist/esm/plugins/utils/index.js +21 -0
- package/dist/esm/plugins/utils/index.js.map +1 -0
- package/dist/esm/plugins/utils/utils-array.js +130 -0
- package/dist/esm/plugins/utils/utils-array.js.map +1 -0
- package/dist/esm/plugins/utils/utils-base64.js +48 -0
- package/dist/esm/plugins/utils/utils-base64.js.map +1 -0
- package/dist/esm/plugins/utils/utils-blob.js +54 -0
- package/dist/esm/plugins/utils/utils-blob.js.map +1 -0
- package/dist/esm/plugins/utils/utils-document.js +87 -0
- package/dist/esm/plugins/utils/utils-document.js.map +1 -0
- package/dist/esm/plugins/utils/utils-error.js +36 -0
- package/dist/esm/plugins/utils/utils-error.js.map +1 -0
- package/dist/esm/plugins/utils/utils-global.js +6 -0
- package/dist/esm/plugins/utils/utils-global.js.map +1 -0
- package/dist/esm/plugins/utils/utils-hash.js +51 -0
- package/dist/esm/plugins/utils/utils-hash.js.map +1 -0
- package/dist/esm/plugins/utils/utils-map.js +18 -0
- package/dist/esm/plugins/utils/utils-map.js.map +1 -0
- package/dist/esm/plugins/utils/utils-number.js +10 -0
- package/dist/esm/plugins/utils/utils-number.js.map +1 -0
- package/dist/esm/plugins/utils/utils-object-deep-equal.js +36 -0
- package/dist/esm/plugins/utils/utils-object-deep-equal.js.map +1 -0
- package/dist/esm/plugins/utils/utils-object-dot-prop.js +296 -0
- package/dist/esm/plugins/utils/utils-object-dot-prop.js.map +1 -0
- package/dist/esm/plugins/utils/utils-object.js +228 -0
- package/dist/esm/plugins/utils/utils-object.js.map +1 -0
- package/dist/esm/plugins/utils/utils-other.js +58 -0
- package/dist/esm/plugins/utils/utils-other.js.map +1 -0
- package/dist/esm/plugins/utils/utils-premium.js +30 -0
- package/dist/esm/plugins/utils/utils-premium.js.map +1 -0
- package/dist/esm/plugins/utils/utils-promise.js +134 -0
- package/dist/esm/plugins/utils/utils-promise.js.map +1 -0
- package/dist/esm/plugins/utils/utils-regex.js +3 -0
- package/dist/esm/plugins/utils/utils-regex.js.map +1 -0
- package/dist/esm/plugins/utils/utils-revision.js +53 -0
- package/dist/esm/plugins/utils/utils-revision.js.map +1 -0
- package/dist/esm/plugins/utils/utils-rxdb-version.js +5 -0
- package/dist/esm/plugins/utils/utils-rxdb-version.js.map +1 -0
- package/dist/esm/plugins/utils/utils-rxdb-version.template.js +5 -0
- package/dist/esm/plugins/utils/utils-rxdb-version.template.js.map +1 -0
- package/dist/esm/plugins/utils/utils-string.js +83 -0
- package/dist/esm/plugins/utils/utils-string.js.map +1 -0
- package/dist/esm/plugins/utils/utils-time.js +36 -0
- package/dist/esm/plugins/utils/utils-time.js.map +1 -0
- package/dist/esm/plugins/validate-ajv/index.js +43 -0
- package/dist/esm/plugins/validate-ajv/index.js.map +1 -0
- package/dist/esm/plugins/validate-is-my-json-valid/index.js +20 -0
- package/dist/esm/plugins/validate-is-my-json-valid/index.js.map +1 -0
- package/dist/esm/plugins/validate-z-schema/index.js +47 -0
- package/dist/esm/plugins/validate-z-schema/index.js.map +1 -0
- package/dist/esm/plugins/vector/helper.js +2 -0
- package/dist/esm/plugins/vector/helper.js.map +1 -0
- package/dist/esm/plugins/vector/index.js +2 -0
- package/dist/esm/plugins/vector/index.js.map +1 -0
- package/dist/esm/plugins/vector/types.js +3 -0
- package/dist/esm/plugins/vector/types.js.map +1 -0
- package/dist/esm/plugins/vector/vector-distance.js +29 -0
- package/dist/esm/plugins/vector/vector-distance.js.map +1 -0
- package/dist/esm/plugins/webmcp/index.js +3 -0
- package/dist/esm/plugins/webmcp/index.js.map +1 -0
- package/dist/esm/plugins/webmcp/nosql-query-schema.js +354 -0
- package/dist/esm/plugins/webmcp/nosql-query-schema.js.map +1 -0
- package/dist/esm/plugins/webmcp/webmcp.js +307 -0
- package/dist/esm/plugins/webmcp/webmcp.js.map +1 -0
- package/dist/esm/query-cache.js +99 -0
- package/dist/esm/query-cache.js.map +1 -0
- package/dist/esm/query-planner.js +297 -0
- package/dist/esm/query-planner.js.map +1 -0
- package/dist/esm/replication-protocol/checkpoint.js +95 -0
- package/dist/esm/replication-protocol/checkpoint.js.map +1 -0
- package/dist/esm/replication-protocol/conflicts.js +31 -0
- package/dist/esm/replication-protocol/conflicts.js.map +1 -0
- package/dist/esm/replication-protocol/default-conflict-handler.js +33 -0
- package/dist/esm/replication-protocol/default-conflict-handler.js.map +1 -0
- package/dist/esm/replication-protocol/downstream.js +334 -0
- package/dist/esm/replication-protocol/downstream.js.map +1 -0
- package/dist/esm/replication-protocol/helper.js +49 -0
- package/dist/esm/replication-protocol/helper.js.map +1 -0
- package/dist/esm/replication-protocol/index.js +221 -0
- package/dist/esm/replication-protocol/index.js.map +1 -0
- package/dist/esm/replication-protocol/meta-instance.js +121 -0
- package/dist/esm/replication-protocol/meta-instance.js.map +1 -0
- package/dist/esm/replication-protocol/upstream.js +379 -0
- package/dist/esm/replication-protocol/upstream.js.map +1 -0
- package/dist/esm/rx-change-event.js +103 -0
- package/dist/esm/rx-change-event.js.map +1 -0
- package/dist/esm/rx-collection-helper.js +196 -0
- package/dist/esm/rx-collection-helper.js.map +1 -0
- package/dist/esm/rx-collection.js +923 -0
- package/dist/esm/rx-collection.js.map +1 -0
- package/dist/esm/rx-database-internal-store.js +270 -0
- package/dist/esm/rx-database-internal-store.js.map +1 -0
- package/dist/esm/rx-database.js +670 -0
- package/dist/esm/rx-database.js.map +1 -0
- package/dist/esm/rx-document-prototype-merge.js +78 -0
- package/dist/esm/rx-document-prototype-merge.js.map +1 -0
- package/dist/esm/rx-document.js +394 -0
- package/dist/esm/rx-document.js.map +1 -0
- package/dist/esm/rx-error.js +153 -0
- package/dist/esm/rx-error.js.map +1 -0
- package/dist/esm/rx-query-helper.js +268 -0
- package/dist/esm/rx-query-helper.js.map +1 -0
- package/dist/esm/rx-query-mingo.js +54 -0
- package/dist/esm/rx-query-mingo.js.map +1 -0
- package/dist/esm/rx-query-single-result.js +98 -0
- package/dist/esm/rx-query-single-result.js.map +1 -0
- package/dist/esm/rx-query.js +690 -0
- package/dist/esm/rx-query.js.map +1 -0
- package/dist/esm/rx-schema-helper.js +316 -0
- package/dist/esm/rx-schema-helper.js.map +1 -0
- package/dist/esm/rx-schema.js +177 -0
- package/dist/esm/rx-schema.js.map +1 -0
- package/dist/esm/rx-storage-helper.js +785 -0
- package/dist/esm/rx-storage-helper.js.map +1 -0
- package/dist/esm/rx-storage-multiinstance.js +113 -0
- package/dist/esm/rx-storage-multiinstance.js.map +1 -0
- package/dist/esm/types/conflict-handling.d.js +3 -0
- package/dist/esm/types/conflict-handling.d.js.map +1 -0
- package/dist/esm/types/couchdb.d.js +3 -0
- package/dist/esm/types/couchdb.d.js.map +1 -0
- package/dist/esm/types/index.d.js +2 -0
- package/dist/esm/types/index.d.js.map +1 -0
- package/dist/esm/types/modules/index.d.js +2 -0
- package/dist/esm/types/modules/index.d.js.map +1 -0
- package/dist/esm/types/modules/mocha.parallel.d.js +2 -0
- package/dist/esm/types/modules/mocha.parallel.d.js.map +1 -0
- package/dist/esm/types/plugins/backup.d.js +3 -0
- package/dist/esm/types/plugins/backup.d.js.map +1 -0
- package/dist/esm/types/plugins/cleanup.d.js +3 -0
- package/dist/esm/types/plugins/cleanup.d.js.map +1 -0
- package/dist/esm/types/plugins/crdt.d.js +3 -0
- package/dist/esm/types/plugins/crdt.d.js.map +1 -0
- package/dist/esm/types/plugins/dexie.d.js +3 -0
- package/dist/esm/types/plugins/dexie.d.js.map +1 -0
- package/dist/esm/types/plugins/local-documents.d.js +3 -0
- package/dist/esm/types/plugins/local-documents.d.js.map +1 -0
- package/dist/esm/types/plugins/migration.d.js +3 -0
- package/dist/esm/types/plugins/migration.d.js.map +1 -0
- package/dist/esm/types/plugins/reactivity.d.js +3 -0
- package/dist/esm/types/plugins/reactivity.d.js.map +1 -0
- package/dist/esm/types/plugins/replication-graphql.d.js +3 -0
- package/dist/esm/types/plugins/replication-graphql.d.js.map +1 -0
- package/dist/esm/types/plugins/replication.d.js +3 -0
- package/dist/esm/types/plugins/replication.d.js.map +1 -0
- package/dist/esm/types/plugins/state.d.js +3 -0
- package/dist/esm/types/plugins/state.d.js.map +1 -0
- package/dist/esm/types/plugins/update.d.js +3 -0
- package/dist/esm/types/plugins/update.d.js.map +1 -0
- package/dist/esm/types/plugins/webmcp.d.js +3 -0
- package/dist/esm/types/plugins/webmcp.d.js.map +1 -0
- package/dist/esm/types/query-planner.d.js +3 -0
- package/dist/esm/types/query-planner.d.js.map +1 -0
- package/dist/esm/types/replication-protocol.d.js +3 -0
- package/dist/esm/types/replication-protocol.d.js.map +1 -0
- package/dist/esm/types/rx-attachment.d.js +3 -0
- package/dist/esm/types/rx-attachment.d.js.map +1 -0
- package/dist/esm/types/rx-change-event.d.js +3 -0
- package/dist/esm/types/rx-change-event.d.js.map +1 -0
- package/dist/esm/types/rx-collection.d.js +3 -0
- package/dist/esm/types/rx-collection.d.js.map +1 -0
- package/dist/esm/types/rx-database-internal-store.d.js +3 -0
- package/dist/esm/types/rx-database-internal-store.d.js.map +1 -0
- package/dist/esm/types/rx-database.d.js +3 -0
- package/dist/esm/types/rx-database.d.js.map +1 -0
- package/dist/esm/types/rx-document.d.js +3 -0
- package/dist/esm/types/rx-document.d.js.map +1 -0
- package/dist/esm/types/rx-error.d.js +3 -0
- package/dist/esm/types/rx-error.d.js.map +1 -0
- package/dist/esm/types/rx-plugin.d.js +3 -0
- package/dist/esm/types/rx-plugin.d.js.map +1 -0
- package/dist/esm/types/rx-query.d.js +3 -0
- package/dist/esm/types/rx-query.d.js.map +1 -0
- package/dist/esm/types/rx-schema.d.js +3 -0
- package/dist/esm/types/rx-schema.d.js.map +1 -0
- package/dist/esm/types/rx-storage.d.js +3 -0
- package/dist/esm/types/rx-storage.d.js.map +1 -0
- package/dist/esm/types/rx-storage.interface.d.js +3 -0
- package/dist/esm/types/rx-storage.interface.d.js.map +1 -0
- package/dist/esm/types/util.d.js +3 -0
- package/dist/esm/types/util.d.js.map +1 -0
- package/dist/types/change-event-buffer.d.ts +50 -0
- package/dist/types/custom-index.d.ts +58 -0
- package/dist/types/doc-cache.d.ts +96 -0
- package/dist/types/event-reduce.d.ts +15 -0
- package/dist/types/hooks.d.ts +109 -0
- package/dist/types/incremental-write.d.ts +29 -0
- package/dist/types/index.d.ts +30 -0
- package/dist/types/overwritable.d.ts +26 -0
- package/dist/types/plugin-helpers.d.ts +30 -0
- package/dist/types/plugin.d.ts +6 -0
- package/dist/types/plugins/attachments/attachments-utils.d.ts +10 -0
- package/dist/types/plugins/attachments/index.d.ts +42 -0
- package/dist/types/plugins/attachments-compression/index.d.ts +38 -0
- package/dist/types/plugins/backup/file-util.d.ts +17 -0
- package/dist/types/plugins/backup/index.d.ts +37 -0
- package/dist/types/plugins/cleanup/cleanup-helper.d.ts +2 -0
- package/dist/types/plugins/cleanup/cleanup-state.d.ts +7 -0
- package/dist/types/plugins/cleanup/cleanup.d.ts +8 -0
- package/dist/types/plugins/cleanup/index.d.ts +4 -0
- package/dist/types/plugins/crdt/index.d.ts +12 -0
- package/dist/types/plugins/dev-mode/check-document.d.ts +9 -0
- package/dist/types/plugins/dev-mode/check-migration-strategies.d.ts +6 -0
- package/dist/types/plugins/dev-mode/check-orm.d.ts +7 -0
- package/dist/types/plugins/dev-mode/check-query.d.ts +21 -0
- package/dist/types/plugins/dev-mode/check-schema.d.ts +18 -0
- package/dist/types/plugins/dev-mode/dev-mode-tracking.d.ts +4 -0
- package/dist/types/plugins/dev-mode/entity-properties.d.ts +3 -0
- package/dist/types/plugins/dev-mode/error-messages.d.ts +1230 -0
- package/dist/types/plugins/dev-mode/index.d.ts +19 -0
- package/dist/types/plugins/dev-mode/unallowed-properties.d.ts +20 -0
- package/dist/types/plugins/electron/electron-helper.d.ts +2 -0
- package/dist/types/plugins/electron/index.d.ts +3 -0
- package/dist/types/plugins/electron/rx-storage-ipc-main.d.ts +10 -0
- package/dist/types/plugins/electron/rx-storage-ipc-renderer.d.ts +13 -0
- package/dist/types/plugins/encryption-crypto-js/index.d.ts +10 -0
- package/dist/types/plugins/flutter/index.d.ts +11 -0
- package/dist/types/plugins/json-dump/index.d.ts +2 -0
- package/dist/types/plugins/key-compression/index.d.ts +18 -0
- package/dist/types/plugins/leader-election/index.d.ts +25 -0
- package/dist/types/plugins/local-documents/index.d.ts +6 -0
- package/dist/types/plugins/local-documents/local-documents-helper.d.ts +9 -0
- package/dist/types/plugins/local-documents/local-documents.d.ts +14 -0
- package/dist/types/plugins/local-documents/rx-local-document.d.ts +11 -0
- package/dist/types/plugins/migration-schema/index.d.ts +8 -0
- package/dist/types/plugins/migration-schema/migration-helpers.d.ts +29 -0
- package/dist/types/plugins/migration-schema/migration-types.d.ts +33 -0
- package/dist/types/plugins/migration-schema/rx-migration-state.d.ts +50 -0
- package/dist/types/plugins/migration-storage/index.d.ts +32 -0
- package/dist/types/plugins/pipeline/flagged-functions.d.ts +69 -0
- package/dist/types/plugins/pipeline/index.d.ts +5 -0
- package/dist/types/plugins/pipeline/rx-pipeline.d.ts +37 -0
- package/dist/types/plugins/pipeline/types.d.ts +17 -0
- package/dist/types/plugins/query-builder/index.d.ts +5 -0
- package/dist/types/plugins/query-builder/mquery/mquery-utils.d.ts +12 -0
- package/dist/types/plugins/query-builder/mquery/nosql-query-builder.d.ts +165 -0
- package/dist/types/plugins/react/database-context.d.ts +4 -0
- package/dist/types/plugins/react/database-provider.d.ts +24 -0
- package/dist/types/plugins/react/hooks/index.d.ts +4 -0
- package/dist/types/plugins/react/hooks/use-live-rx-query.d.ts +11 -0
- package/dist/types/plugins/react/hooks/use-rx-collection.d.ts +10 -0
- package/dist/types/plugins/react/hooks/use-rx-database.d.ts +9 -0
- package/dist/types/plugins/react/hooks/use-rx-query.d.ts +24 -0
- package/dist/types/plugins/react/index.d.ts +2 -0
- package/dist/types/plugins/reactivity-angular/index.d.ts +16 -0
- package/dist/types/plugins/reactivity-preact-signals/index.d.ts +27 -0
- package/dist/types/plugins/reactivity-vue/index.d.ts +17 -0
- package/dist/types/plugins/replication/index.d.ts +84 -0
- package/dist/types/plugins/replication/replication-helper.d.ts +23 -0
- package/dist/types/plugins/replication-appwrite/appwrite-helpers.d.ts +3 -0
- package/dist/types/plugins/replication-appwrite/appwrite-types.d.ts +16 -0
- package/dist/types/plugins/replication-appwrite/index.d.ts +14 -0
- package/dist/types/plugins/replication-couchdb/couchdb-helper.d.ts +19 -0
- package/dist/types/plugins/replication-couchdb/couchdb-types.d.ts +22 -0
- package/dist/types/plugins/replication-couchdb/index.d.ts +18 -0
- package/dist/types/plugins/replication-firestore/firestore-helper.d.ts +10 -0
- package/dist/types/plugins/replication-firestore/firestore-types.d.ts +46 -0
- package/dist/types/plugins/replication-firestore/index.d.ts +17 -0
- package/dist/types/plugins/replication-google-drive/document-handling.d.ts +13 -0
- package/dist/types/plugins/replication-google-drive/downstream.d.ts +10 -0
- package/dist/types/plugins/replication-google-drive/google-drive-helper.d.ts +35 -0
- package/dist/types/plugins/replication-google-drive/google-drive-types.d.ts +67 -0
- package/dist/types/plugins/replication-google-drive/index.d.ts +39 -0
- package/dist/types/plugins/replication-google-drive/init.d.ts +29 -0
- package/dist/types/plugins/replication-google-drive/multipart.d.ts +10 -0
- package/dist/types/plugins/replication-google-drive/signaling.d.ts +41 -0
- package/dist/types/plugins/replication-google-drive/transaction.d.ts +22 -0
- package/dist/types/plugins/replication-google-drive/upstream.d.ts +24 -0
- package/dist/types/plugins/replication-graphql/graphql-schema-from-rx-schema.d.ts +51 -0
- package/dist/types/plugins/replication-graphql/graphql-websocket.d.ts +12 -0
- package/dist/types/plugins/replication-graphql/helper.d.ts +15 -0
- package/dist/types/plugins/replication-graphql/index.d.ts +26 -0
- package/dist/types/plugins/replication-graphql/query-builder-from-rx-schema.d.ts +5 -0
- package/dist/types/plugins/replication-microsoft-onedrive/document-handling.d.ts +14 -0
- package/dist/types/plugins/replication-microsoft-onedrive/downstream.d.ts +10 -0
- package/dist/types/plugins/replication-microsoft-onedrive/index.d.ts +38 -0
- package/dist/types/plugins/replication-microsoft-onedrive/init.d.ts +29 -0
- package/dist/types/plugins/replication-microsoft-onedrive/microsoft-onedrive-helper.d.ts +30 -0
- package/dist/types/plugins/replication-microsoft-onedrive/microsoft-onedrive-types.d.ts +71 -0
- package/dist/types/plugins/replication-microsoft-onedrive/signaling.d.ts +41 -0
- package/dist/types/plugins/replication-microsoft-onedrive/transaction.d.ts +22 -0
- package/dist/types/plugins/replication-microsoft-onedrive/upstream.d.ts +25 -0
- package/dist/types/plugins/replication-mongodb/index.d.ts +22 -0
- package/dist/types/plugins/replication-mongodb/mongodb-checkpoint.d.ts +15 -0
- package/dist/types/plugins/replication-mongodb/mongodb-helper.d.ts +13 -0
- package/dist/types/plugins/replication-mongodb/mongodb-types.d.ts +33 -0
- package/dist/types/plugins/replication-nats/index.d.ts +16 -0
- package/dist/types/plugins/replication-nats/nats-helper.d.ts +2 -0
- package/dist/types/plugins/replication-nats/nats-types.d.ts +21 -0
- package/dist/types/plugins/replication-supabase/helper.d.ts +5 -0
- package/dist/types/plugins/replication-supabase/index.d.ts +14 -0
- package/dist/types/plugins/replication-supabase/types.d.ts +28 -0
- package/dist/types/plugins/replication-webrtc/connection-handler-p2pcf.d.ts +0 -0
- package/dist/types/plugins/replication-webrtc/connection-handler-simple-peer.d.ts +57 -0
- package/dist/types/plugins/replication-webrtc/connection-handler-webtorrent.d.ts +0 -0
- package/dist/types/plugins/replication-webrtc/index.d.ts +27 -0
- package/dist/types/plugins/replication-webrtc/signaling-server.d.ts +17 -0
- package/dist/types/plugins/replication-webrtc/webrtc-helper.d.ts +16 -0
- package/dist/types/plugins/replication-webrtc/webrtc-types.d.ts +51 -0
- package/dist/types/plugins/replication-websocket/index.d.ts +3 -0
- package/dist/types/plugins/replication-websocket/websocket-client.d.ts +13 -0
- package/dist/types/plugins/replication-websocket/websocket-server.d.ts +6 -0
- package/dist/types/plugins/replication-websocket/websocket-types.d.ts +32 -0
- package/dist/types/plugins/state/helpers.d.ts +10 -0
- package/dist/types/plugins/state/index.d.ts +4 -0
- package/dist/types/plugins/state/rx-state.d.ts +46 -0
- package/dist/types/plugins/state/types.d.ts +28 -0
- package/dist/types/plugins/storage-denokv/denokv-helper.d.ts +16 -0
- package/dist/types/plugins/storage-denokv/denokv-query.d.ts +3 -0
- package/dist/types/plugins/storage-denokv/denokv-types.d.ts +17 -0
- package/dist/types/plugins/storage-denokv/index.d.ts +11 -0
- package/dist/types/plugins/storage-denokv/rx-storage-instance-denokv.d.ts +41 -0
- package/dist/types/plugins/storage-dexie/dexie-helper.d.ts +40 -0
- package/dist/types/plugins/storage-dexie/dexie-query.d.ts +9 -0
- package/dist/types/plugins/storage-dexie/index.d.ts +4 -0
- package/dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts +11 -0
- package/dist/types/plugins/storage-dexie/rx-storage-instance-dexie.d.ts +29 -0
- package/dist/types/plugins/storage-foundationdb/foundationdb-helpers.d.ts +3 -0
- package/dist/types/plugins/storage-foundationdb/foundationdb-query.d.ts +3 -0
- package/dist/types/plugins/storage-foundationdb/foundationdb-types.d.ts +46 -0
- package/dist/types/plugins/storage-foundationdb/index.d.ts +4 -0
- package/dist/types/plugins/storage-foundationdb/rx-storage-instance-foundationdb.d.ts +26 -0
- package/dist/types/plugins/storage-localstorage/index.d.ts +11 -0
- package/dist/types/plugins/storage-localstorage/localstorage-mock.d.ts +1 -0
- package/dist/types/plugins/storage-localstorage/rx-storage-instance-localstorage.d.ts +84 -0
- package/dist/types/plugins/storage-memory/binary-search-bounds.d.ts +14 -0
- package/dist/types/plugins/storage-memory/index.d.ts +7 -0
- package/dist/types/plugins/storage-memory/memory-helper.d.ts +22 -0
- package/dist/types/plugins/storage-memory/memory-indexes.d.ts +4 -0
- package/dist/types/plugins/storage-memory/memory-types.d.ts +72 -0
- package/dist/types/plugins/storage-memory/rx-storage-instance-memory.d.ts +47 -0
- package/dist/types/plugins/storage-mongodb/index.d.ts +4 -0
- package/dist/types/plugins/storage-mongodb/mongodb-helper.d.ts +22 -0
- package/dist/types/plugins/storage-mongodb/mongodb-types.d.ts +21 -0
- package/dist/types/plugins/storage-mongodb/rx-storage-instance-mongodb.d.ts +52 -0
- package/dist/types/plugins/storage-mongodb/rx-storage-mongodb.d.ts +11 -0
- package/dist/types/plugins/storage-remote/index.d.ts +5 -0
- package/dist/types/plugins/storage-remote/message-channel-cache.d.ts +13 -0
- package/dist/types/plugins/storage-remote/remote.d.ts +6 -0
- package/dist/types/plugins/storage-remote/rx-storage-remote.d.ts +43 -0
- package/dist/types/plugins/storage-remote/storage-remote-helpers.d.ts +4 -0
- package/dist/types/plugins/storage-remote/storage-remote-types.d.ts +88 -0
- package/dist/types/plugins/storage-remote-websocket/index.d.ts +4 -0
- package/dist/types/plugins/storage-remote-websocket/types.d.ts +24 -0
- package/dist/types/plugins/storage-sqlite/index.d.ts +15 -0
- package/dist/types/plugins/storage-sqlite/sqlite-basics-helpers.d.ts +53 -0
- package/dist/types/plugins/storage-sqlite/sqlite-helpers.d.ts +48 -0
- package/dist/types/plugins/storage-sqlite/sqlite-storage-instance.d.ts +38 -0
- package/dist/types/plugins/storage-sqlite/sqlite-types.d.ts +116 -0
- package/dist/types/plugins/test-utils/config.d.ts +16 -0
- package/dist/types/plugins/test-utils/humans-collection.d.ts +26 -0
- package/dist/types/plugins/test-utils/index.d.ts +20 -0
- package/dist/types/plugins/test-utils/performance.d.ts +68 -0
- package/dist/types/plugins/test-utils/replication-base-test-suite.d.ts +66 -0
- package/dist/types/plugins/test-utils/replication.d.ts +10 -0
- package/dist/types/plugins/test-utils/revisions.d.ts +4 -0
- package/dist/types/plugins/test-utils/schema-objects.d.ts +219 -0
- package/dist/types/plugins/test-utils/schemas.d.ts +356 -0
- package/dist/types/plugins/test-utils/test-util.d.ts +10 -0
- package/dist/types/plugins/update/index.d.ts +5 -0
- package/dist/types/plugins/update/mingo-updater.d.ts +2 -0
- package/dist/types/plugins/utils/index.d.ts +20 -0
- package/dist/types/plugins/utils/utils-array.d.ts +40 -0
- package/dist/types/plugins/utils/utils-base64.d.ts +15 -0
- package/dist/types/plugins/utils/utils-blob.d.ts +12 -0
- package/dist/types/plugins/utils/utils-document.d.ts +26 -0
- package/dist/types/plugins/utils/utils-error.d.ts +8 -0
- package/dist/types/plugins/utils/utils-global.d.ts +5 -0
- package/dist/types/plugins/utils/utils-hash.d.ts +4 -0
- package/dist/types/plugins/utils/utils-map.d.ts +2 -0
- package/dist/types/plugins/utils/utils-number.d.ts +7 -0
- package/dist/types/plugins/utils/utils-object-deep-equal.d.ts +7 -0
- package/dist/types/plugins/utils/utils-object-dot-prop.d.ts +14 -0
- package/dist/types/plugins/utils/utils-object.d.ts +61 -0
- package/dist/types/plugins/utils/utils-other.d.ts +20 -0
- package/dist/types/plugins/utils/utils-premium.d.ts +10 -0
- package/dist/types/plugins/utils/utils-promise.d.ts +43 -0
- package/dist/types/plugins/utils/utils-regex.d.ts +2 -0
- package/dist/types/plugins/utils/utils-revision.d.ts +22 -0
- package/dist/types/plugins/utils/utils-rxdb-version.d.ts +4 -0
- package/dist/types/plugins/utils/utils-rxdb-version.template.d.ts +4 -0
- package/dist/types/plugins/utils/utils-string.d.ts +35 -0
- package/dist/types/plugins/utils/utils-time.d.ts +5 -0
- package/dist/types/plugins/validate-ajv/index.d.ts +13 -0
- package/dist/types/plugins/validate-is-my-json-valid/index.d.ts +5 -0
- package/dist/types/plugins/validate-z-schema/index.d.ts +13 -0
- package/dist/types/plugins/vector/helper.d.ts +0 -0
- package/dist/types/plugins/vector/index.d.ts +2 -0
- package/dist/types/plugins/vector/types.d.ts +1 -0
- package/dist/types/plugins/vector/vector-distance.d.ts +13 -0
- package/dist/types/plugins/webmcp/index.d.ts +2 -0
- package/dist/types/plugins/webmcp/nosql-query-schema.d.ts +549 -0
- package/dist/types/plugins/webmcp/webmcp.d.ts +12 -0
- package/dist/types/query-cache.d.ts +35 -0
- package/dist/types/query-planner.d.ts +30 -0
- package/dist/types/replication-protocol/checkpoint.d.ts +8 -0
- package/dist/types/replication-protocol/conflicts.d.ts +10 -0
- package/dist/types/replication-protocol/default-conflict-handler.d.ts +2 -0
- package/dist/types/replication-protocol/downstream.d.ts +10 -0
- package/dist/types/replication-protocol/helper.d.ts +5 -0
- package/dist/types/replication-protocol/index.d.ts +30 -0
- package/dist/types/replication-protocol/meta-instance.d.ts +12 -0
- package/dist/types/replication-protocol/upstream.d.ts +10 -0
- package/dist/types/rx-change-event.d.ts +20 -0
- package/dist/types/rx-collection-helper.d.ts +41 -0
- package/dist/types/rx-collection.d.ts +185 -0
- package/dist/types/rx-database-internal-store.d.ts +37 -0
- package/dist/types/rx-database.d.ts +213 -0
- package/dist/types/rx-document-prototype-merge.d.ts +24 -0
- package/dist/types/rx-document.d.ts +274 -0
- package/dist/types/rx-error.d.ts +37 -0
- package/dist/types/rx-query-helper.d.ts +31 -0
- package/dist/types/rx-query-mingo.d.ts +10 -0
- package/dist/types/rx-query-single-result.d.ts +31 -0
- package/dist/types/rx-query.d.ts +153 -0
- package/dist/types/rx-schema-helper.d.ts +57 -0
- package/dist/types/rx-schema.d.ts +43 -0
- package/dist/types/rx-storage-helper.d.ts +111 -0
- package/dist/types/rx-storage-multiinstance.d.ts +51 -0
- package/dist/types/types/conflict-handling.d.ts +48 -0
- package/dist/types/types/couchdb.d.ts +293 -0
- package/dist/types/types/index.d.ts +32 -0
- package/dist/types/types/modules/index.d.ts +0 -0
- package/dist/types/types/modules/mocha.parallel.d.ts +1 -0
- package/dist/types/types/plugins/backup.d.ts +35 -0
- package/dist/types/types/plugins/cleanup.d.ts +38 -0
- package/dist/types/types/plugins/crdt.d.ts +76 -0
- package/dist/types/types/plugins/dexie.d.ts +30 -0
- package/dist/types/types/plugins/local-documents.d.ts +49 -0
- package/dist/types/types/plugins/migration.d.ts +14 -0
- package/dist/types/types/plugins/reactivity.d.ts +40 -0
- package/dist/types/types/plugins/replication-graphql.d.ts +98 -0
- package/dist/types/types/plugins/replication.d.ts +175 -0
- package/dist/types/types/plugins/state.d.ts +4 -0
- package/dist/types/types/plugins/update.d.ts +23 -0
- package/dist/types/types/plugins/webmcp.d.ts +40 -0
- package/dist/types/types/query-planner.d.ts +47 -0
- package/dist/types/types/replication-protocol.d.ts +296 -0
- package/dist/types/types/rx-attachment.d.ts +46 -0
- package/dist/types/types/rx-change-event.d.ts +85 -0
- package/dist/types/types/rx-collection.d.ts +117 -0
- package/dist/types/types/rx-database-internal-store.d.ts +54 -0
- package/dist/types/types/rx-database.d.ts +124 -0
- package/dist/types/types/rx-document.d.ts +160 -0
- package/dist/types/types/rx-error.d.ts +222 -0
- package/dist/types/types/rx-plugin.d.ts +167 -0
- package/dist/types/types/rx-query.d.ts +144 -0
- package/dist/types/types/rx-schema.d.ts +209 -0
- package/dist/types/types/rx-storage.d.ts +347 -0
- package/dist/types/types/rx-storage.interface.d.ts +312 -0
- package/dist/types/types/util.d.ts +180 -0
- package/eslint.config.mjs +514 -0
- package/package.json +729 -0
- package/plugins/attachments/index.cjs +2 -0
- package/plugins/attachments/index.d.cts +1 -0
- package/plugins/attachments/index.d.mts +1 -0
- package/plugins/attachments/index.mjs +1 -0
- package/plugins/attachments/index.ts +1 -0
- package/plugins/attachments/package.json +18 -0
- package/plugins/attachments-compression/index.cjs +2 -0
- package/plugins/attachments-compression/index.d.cts +1 -0
- package/plugins/attachments-compression/index.d.mts +1 -0
- package/plugins/attachments-compression/index.mjs +1 -0
- package/plugins/attachments-compression/index.ts +1 -0
- package/plugins/attachments-compression/package.json +18 -0
- package/plugins/backup/index.cjs +2 -0
- package/plugins/backup/index.d.cts +1 -0
- package/plugins/backup/index.d.mts +1 -0
- package/plugins/backup/index.mjs +1 -0
- package/plugins/backup/index.ts +1 -0
- package/plugins/backup/package.json +18 -0
- package/plugins/cleanup/index.cjs +2 -0
- package/plugins/cleanup/index.d.cts +1 -0
- package/plugins/cleanup/index.d.mts +1 -0
- package/plugins/cleanup/index.mjs +1 -0
- package/plugins/cleanup/index.ts +1 -0
- package/plugins/cleanup/package.json +18 -0
- package/plugins/core/index.cjs +2 -0
- package/plugins/core/index.d.cts +1 -0
- package/plugins/core/index.d.mts +1 -0
- package/plugins/core/index.mjs +1 -0
- package/plugins/core/index.ts +1 -0
- package/plugins/core/package.json +18 -0
- package/plugins/crdt/index.cjs +2 -0
- package/plugins/crdt/index.d.cts +1 -0
- package/plugins/crdt/index.d.mts +1 -0
- package/plugins/crdt/index.mjs +1 -0
- package/plugins/crdt/index.ts +1 -0
- package/plugins/crdt/package.json +18 -0
- package/plugins/dev-mode/index.cjs +2 -0
- package/plugins/dev-mode/index.d.cts +1 -0
- package/plugins/dev-mode/index.d.mts +1 -0
- package/plugins/dev-mode/index.mjs +1 -0
- package/plugins/dev-mode/index.ts +1 -0
- package/plugins/dev-mode/package.json +18 -0
- package/plugins/electron/index.cjs +2 -0
- package/plugins/electron/index.d.cts +1 -0
- package/plugins/electron/index.d.mts +1 -0
- package/plugins/electron/index.mjs +1 -0
- package/plugins/electron/index.ts +1 -0
- package/plugins/electron/package.json +18 -0
- package/plugins/encryption-crypto-js/index.cjs +2 -0
- package/plugins/encryption-crypto-js/index.d.cts +1 -0
- package/plugins/encryption-crypto-js/index.d.mts +1 -0
- package/plugins/encryption-crypto-js/index.mjs +1 -0
- package/plugins/encryption-crypto-js/index.ts +1 -0
- package/plugins/encryption-crypto-js/package.json +18 -0
- package/plugins/flutter/index.cjs +2 -0
- package/plugins/flutter/index.d.cts +1 -0
- package/plugins/flutter/index.d.mts +1 -0
- package/plugins/flutter/index.mjs +1 -0
- package/plugins/flutter/index.ts +1 -0
- package/plugins/flutter/package.json +18 -0
- package/plugins/json-dump/index.cjs +2 -0
- package/plugins/json-dump/index.d.cts +1 -0
- package/plugins/json-dump/index.d.mts +1 -0
- package/plugins/json-dump/index.mjs +1 -0
- package/plugins/json-dump/index.ts +1 -0
- package/plugins/json-dump/package.json +18 -0
- package/plugins/key-compression/index.cjs +2 -0
- package/plugins/key-compression/index.d.cts +1 -0
- package/plugins/key-compression/index.d.mts +1 -0
- package/plugins/key-compression/index.mjs +1 -0
- package/plugins/key-compression/index.ts +1 -0
- package/plugins/key-compression/package.json +18 -0
- package/plugins/leader-election/index.cjs +2 -0
- package/plugins/leader-election/index.d.cts +1 -0
- package/plugins/leader-election/index.d.mts +1 -0
- package/plugins/leader-election/index.mjs +1 -0
- package/plugins/leader-election/index.ts +1 -0
- package/plugins/leader-election/package.json +18 -0
- package/plugins/local-documents/index.cjs +2 -0
- package/plugins/local-documents/index.d.cts +1 -0
- package/plugins/local-documents/index.d.mts +1 -0
- package/plugins/local-documents/index.mjs +1 -0
- package/plugins/local-documents/index.ts +1 -0
- package/plugins/local-documents/package.json +18 -0
- package/plugins/migration-schema/index.cjs +2 -0
- package/plugins/migration-schema/index.d.cts +1 -0
- package/plugins/migration-schema/index.d.mts +1 -0
- package/plugins/migration-schema/index.mjs +1 -0
- package/plugins/migration-schema/index.ts +1 -0
- package/plugins/migration-schema/package.json +18 -0
- package/plugins/migration-storage/index.cjs +2 -0
- package/plugins/migration-storage/index.d.cts +1 -0
- package/plugins/migration-storage/index.d.mts +1 -0
- package/plugins/migration-storage/index.mjs +1 -0
- package/plugins/migration-storage/index.ts +1 -0
- package/plugins/migration-storage/package.json +18 -0
- package/plugins/pipeline/index.cjs +2 -0
- package/plugins/pipeline/index.d.cts +1 -0
- package/plugins/pipeline/index.d.mts +1 -0
- package/plugins/pipeline/index.mjs +1 -0
- package/plugins/pipeline/index.ts +1 -0
- package/plugins/pipeline/package.json +18 -0
- package/plugins/query-builder/index.cjs +2 -0
- package/plugins/query-builder/index.d.cts +1 -0
- package/plugins/query-builder/index.d.mts +1 -0
- package/plugins/query-builder/index.mjs +1 -0
- package/plugins/query-builder/index.ts +1 -0
- package/plugins/query-builder/package.json +18 -0
- package/plugins/react/index.cjs +2 -0
- package/plugins/react/index.d.cts +1 -0
- package/plugins/react/index.d.mts +1 -0
- package/plugins/react/index.mjs +1 -0
- package/plugins/react/index.ts +1 -0
- package/plugins/react/package.json +18 -0
- package/plugins/reactivity-angular/index.cjs +2 -0
- package/plugins/reactivity-angular/index.d.cts +1 -0
- package/plugins/reactivity-angular/index.d.mts +1 -0
- package/plugins/reactivity-angular/index.mjs +1 -0
- package/plugins/reactivity-angular/index.ts +1 -0
- package/plugins/reactivity-angular/package.json +18 -0
- package/plugins/reactivity-preact-signals/index.cjs +2 -0
- package/plugins/reactivity-preact-signals/index.d.cts +1 -0
- package/plugins/reactivity-preact-signals/index.d.mts +1 -0
- package/plugins/reactivity-preact-signals/index.mjs +1 -0
- package/plugins/reactivity-preact-signals/index.ts +1 -0
- package/plugins/reactivity-preact-signals/package.json +18 -0
- package/plugins/reactivity-vue/index.cjs +2 -0
- package/plugins/reactivity-vue/index.d.cts +1 -0
- package/plugins/reactivity-vue/index.d.mts +1 -0
- package/plugins/reactivity-vue/index.mjs +1 -0
- package/plugins/reactivity-vue/index.ts +1 -0
- package/plugins/reactivity-vue/package.json +18 -0
- package/plugins/replication/index.cjs +2 -0
- package/plugins/replication/index.d.cts +1 -0
- package/plugins/replication/index.d.mts +1 -0
- package/plugins/replication/index.mjs +1 -0
- package/plugins/replication/index.ts +1 -0
- package/plugins/replication/package.json +18 -0
- package/plugins/replication-appwrite/index.cjs +2 -0
- package/plugins/replication-appwrite/index.d.cts +1 -0
- package/plugins/replication-appwrite/index.d.mts +1 -0
- package/plugins/replication-appwrite/index.mjs +1 -0
- package/plugins/replication-appwrite/index.ts +1 -0
- package/plugins/replication-appwrite/package.json +18 -0
- package/plugins/replication-couchdb/index.cjs +2 -0
- package/plugins/replication-couchdb/index.d.cts +1 -0
- package/plugins/replication-couchdb/index.d.mts +1 -0
- package/plugins/replication-couchdb/index.mjs +1 -0
- package/plugins/replication-couchdb/index.ts +1 -0
- package/plugins/replication-couchdb/package.json +18 -0
- package/plugins/replication-firestore/index.cjs +2 -0
- package/plugins/replication-firestore/index.d.cts +1 -0
- package/plugins/replication-firestore/index.d.mts +1 -0
- package/plugins/replication-firestore/index.mjs +1 -0
- package/plugins/replication-firestore/index.ts +1 -0
- package/plugins/replication-firestore/package.json +18 -0
- package/plugins/replication-google-drive/index.cjs +2 -0
- package/plugins/replication-google-drive/index.d.cts +1 -0
- package/plugins/replication-google-drive/index.d.mts +1 -0
- package/plugins/replication-google-drive/index.mjs +1 -0
- package/plugins/replication-google-drive/index.ts +1 -0
- package/plugins/replication-google-drive/package.json +18 -0
- package/plugins/replication-graphql/index.cjs +2 -0
- package/plugins/replication-graphql/index.d.cts +1 -0
- package/plugins/replication-graphql/index.d.mts +1 -0
- package/plugins/replication-graphql/index.mjs +1 -0
- package/plugins/replication-graphql/index.ts +1 -0
- package/plugins/replication-graphql/package.json +18 -0
- package/plugins/replication-microsoft-onedrive/index.cjs +2 -0
- package/plugins/replication-microsoft-onedrive/index.d.cts +1 -0
- package/plugins/replication-microsoft-onedrive/index.d.mts +1 -0
- package/plugins/replication-microsoft-onedrive/index.mjs +1 -0
- package/plugins/replication-microsoft-onedrive/index.ts +1 -0
- package/plugins/replication-microsoft-onedrive/package.json +18 -0
- package/plugins/replication-mongodb/index.cjs +2 -0
- package/plugins/replication-mongodb/index.d.cts +1 -0
- package/plugins/replication-mongodb/index.d.mts +1 -0
- package/plugins/replication-mongodb/index.mjs +1 -0
- package/plugins/replication-mongodb/index.ts +1 -0
- package/plugins/replication-mongodb/package.json +18 -0
- package/plugins/replication-nats/index.cjs +2 -0
- package/plugins/replication-nats/index.d.cts +1 -0
- package/plugins/replication-nats/index.d.mts +1 -0
- package/plugins/replication-nats/index.mjs +1 -0
- package/plugins/replication-nats/index.ts +1 -0
- package/plugins/replication-nats/package.json +18 -0
- package/plugins/replication-supabase/index.cjs +2 -0
- package/plugins/replication-supabase/index.d.cts +1 -0
- package/plugins/replication-supabase/index.d.mts +1 -0
- package/plugins/replication-supabase/index.mjs +1 -0
- package/plugins/replication-supabase/index.ts +1 -0
- package/plugins/replication-supabase/package.json +18 -0
- package/plugins/replication-webrtc/index.cjs +2 -0
- package/plugins/replication-webrtc/index.d.cts +1 -0
- package/plugins/replication-webrtc/index.d.mts +1 -0
- package/plugins/replication-webrtc/index.mjs +1 -0
- package/plugins/replication-webrtc/index.ts +1 -0
- package/plugins/replication-webrtc/package.json +18 -0
- package/plugins/replication-websocket/index.cjs +2 -0
- package/plugins/replication-websocket/index.d.cts +1 -0
- package/plugins/replication-websocket/index.d.mts +1 -0
- package/plugins/replication-websocket/index.mjs +1 -0
- package/plugins/replication-websocket/index.ts +1 -0
- package/plugins/replication-websocket/package.json +18 -0
- package/plugins/state/index.cjs +2 -0
- package/plugins/state/index.d.cts +1 -0
- package/plugins/state/index.d.mts +1 -0
- package/plugins/state/index.mjs +1 -0
- package/plugins/state/index.ts +1 -0
- package/plugins/state/package.json +18 -0
- package/plugins/storage-denokv/index.cjs +2 -0
- package/plugins/storage-denokv/index.d.cts +1 -0
- package/plugins/storage-denokv/index.d.mts +1 -0
- package/plugins/storage-denokv/index.mjs +1 -0
- package/plugins/storage-denokv/index.ts +1 -0
- package/plugins/storage-denokv/package.json +18 -0
- package/plugins/storage-dexie/index.cjs +2 -0
- package/plugins/storage-dexie/index.d.cts +1 -0
- package/plugins/storage-dexie/index.d.mts +1 -0
- package/plugins/storage-dexie/index.mjs +1 -0
- package/plugins/storage-dexie/index.ts +1 -0
- package/plugins/storage-dexie/package.json +18 -0
- package/plugins/storage-foundationdb/index.cjs +2 -0
- package/plugins/storage-foundationdb/index.d.cts +1 -0
- package/plugins/storage-foundationdb/index.d.mts +1 -0
- package/plugins/storage-foundationdb/index.mjs +1 -0
- package/plugins/storage-foundationdb/index.ts +1 -0
- package/plugins/storage-foundationdb/package.json +18 -0
- package/plugins/storage-localstorage/index.cjs +2 -0
- package/plugins/storage-localstorage/index.d.cts +1 -0
- package/plugins/storage-localstorage/index.d.mts +1 -0
- package/plugins/storage-localstorage/index.mjs +1 -0
- package/plugins/storage-localstorage/index.ts +1 -0
- package/plugins/storage-localstorage/package.json +18 -0
- package/plugins/storage-memory/index.cjs +2 -0
- package/plugins/storage-memory/index.d.cts +1 -0
- package/plugins/storage-memory/index.d.mts +1 -0
- package/plugins/storage-memory/index.mjs +1 -0
- package/plugins/storage-memory/index.ts +1 -0
- package/plugins/storage-memory/package.json +18 -0
- package/plugins/storage-mongodb/index.cjs +2 -0
- package/plugins/storage-mongodb/index.d.cts +1 -0
- package/plugins/storage-mongodb/index.d.mts +1 -0
- package/plugins/storage-mongodb/index.mjs +1 -0
- package/plugins/storage-mongodb/index.ts +1 -0
- package/plugins/storage-mongodb/package.json +18 -0
- package/plugins/storage-remote/index.cjs +2 -0
- package/plugins/storage-remote/index.d.cts +1 -0
- package/plugins/storage-remote/index.d.mts +1 -0
- package/plugins/storage-remote/index.mjs +1 -0
- package/plugins/storage-remote/index.ts +1 -0
- package/plugins/storage-remote/package.json +18 -0
- package/plugins/storage-remote-websocket/index.cjs +2 -0
- package/plugins/storage-remote-websocket/index.d.cts +1 -0
- package/plugins/storage-remote-websocket/index.d.mts +1 -0
- package/plugins/storage-remote-websocket/index.mjs +1 -0
- package/plugins/storage-remote-websocket/index.ts +1 -0
- package/plugins/storage-remote-websocket/package.json +18 -0
- package/plugins/storage-sqlite/index.cjs +2 -0
- package/plugins/storage-sqlite/index.d.cts +1 -0
- package/plugins/storage-sqlite/index.d.mts +1 -0
- package/plugins/storage-sqlite/index.mjs +1 -0
- package/plugins/storage-sqlite/index.ts +1 -0
- package/plugins/storage-sqlite/package.json +18 -0
- package/plugins/test-utils/index.cjs +2 -0
- package/plugins/test-utils/index.d.cts +1 -0
- package/plugins/test-utils/index.d.mts +1 -0
- package/plugins/test-utils/index.mjs +1 -0
- package/plugins/test-utils/index.ts +1 -0
- package/plugins/test-utils/package.json +18 -0
- package/plugins/update/index.cjs +2 -0
- package/plugins/update/index.d.cts +1 -0
- package/plugins/update/index.d.mts +1 -0
- package/plugins/update/index.mjs +1 -0
- package/plugins/update/index.ts +1 -0
- package/plugins/update/package.json +18 -0
- package/plugins/utils/index.cjs +2 -0
- package/plugins/utils/index.d.cts +1 -0
- package/plugins/utils/index.d.mts +1 -0
- package/plugins/utils/index.mjs +1 -0
- package/plugins/utils/index.ts +1 -0
- package/plugins/utils/package.json +18 -0
- package/plugins/validate-ajv/index.cjs +2 -0
- package/plugins/validate-ajv/index.d.cts +1 -0
- package/plugins/validate-ajv/index.d.mts +1 -0
- package/plugins/validate-ajv/index.mjs +1 -0
- package/plugins/validate-ajv/index.ts +1 -0
- package/plugins/validate-ajv/package.json +18 -0
- package/plugins/validate-is-my-json-valid/index.cjs +2 -0
- package/plugins/validate-is-my-json-valid/index.d.cts +1 -0
- package/plugins/validate-is-my-json-valid/index.d.mts +1 -0
- package/plugins/validate-is-my-json-valid/index.mjs +1 -0
- package/plugins/validate-is-my-json-valid/index.ts +1 -0
- package/plugins/validate-is-my-json-valid/package.json +18 -0
- package/plugins/validate-z-schema/index.cjs +2 -0
- package/plugins/validate-z-schema/index.d.cts +1 -0
- package/plugins/validate-z-schema/index.d.mts +1 -0
- package/plugins/validate-z-schema/index.mjs +1 -0
- package/plugins/validate-z-schema/index.ts +1 -0
- package/plugins/validate-z-schema/package.json +18 -0
- package/plugins/vector/index.cjs +2 -0
- package/plugins/vector/index.d.cts +1 -0
- package/plugins/vector/index.d.mts +1 -0
- package/plugins/vector/index.mjs +1 -0
- package/plugins/vector/index.ts +1 -0
- package/plugins/vector/package.json +18 -0
- package/plugins/webmcp/index.cjs +2 -0
- package/plugins/webmcp/index.d.cts +1 -0
- package/plugins/webmcp/index.d.mts +1 -0
- package/plugins/webmcp/index.mjs +1 -0
- package/plugins/webmcp/index.ts +1 -0
- package/plugins/webmcp/package.json +18 -0
- package/scripts/acme-challenge/.gittouch +0 -0
- package/scripts/ai-context-generator.mjs +63 -0
- package/scripts/cloud-signaling-script.sh +6 -0
- package/scripts/docs-remove-time.mjs +55 -0
- package/scripts/fix-types.mjs +23 -0
- package/scripts/generate-all-headers.ts +102 -0
- package/scripts/generate-error-messages.mjs +41 -0
- package/scripts/generate-header.ts +226 -0
- package/scripts/generate-plugins-package-json.mjs +133 -0
- package/scripts/install-foundationdb.sh +14 -0
- package/scripts/module_package.json +1 -0
- package/scripts/module_package_no_side.json +1 -0
- package/scripts/postinstall.js +33 -0
- package/scripts/profile.mjs +31 -0
- package/scripts/set-version.mjs +162 -0
- package/scripts/start-cloud-signaling-server.mjs +120 -0
- package/scripts/transpile.mjs +229 -0
- package/scripts/update-version-variable.mjs +49 -0
- package/src/change-event-buffer.ts +171 -0
- package/src/custom-index.ts +376 -0
- package/src/doc-cache.ts +294 -0
- package/src/event-reduce.ts +159 -0
- package/src/hooks.ts +128 -0
- package/src/incremental-write.ts +227 -0
- package/src/index.ts +30 -0
- package/src/overwritable.ts +41 -0
- package/src/plugin-helpers.ts +319 -0
- package/src/plugin.ts +113 -0
- package/src/plugins/attachments/attachments-utils.ts +84 -0
- package/src/plugins/attachments/index.ts +316 -0
- package/src/plugins/attachments-compression/index.ts +221 -0
- package/src/plugins/backup/file-util.ts +132 -0
- package/src/plugins/backup/index.ts +281 -0
- package/src/plugins/cleanup/cleanup-helper.ts +11 -0
- package/src/plugins/cleanup/cleanup-state.ts +92 -0
- package/src/plugins/cleanup/cleanup.ts +140 -0
- package/src/plugins/cleanup/index.ts +45 -0
- package/src/plugins/crdt/index.ts +505 -0
- package/src/plugins/dev-mode/check-document.ts +176 -0
- package/src/plugins/dev-mode/check-migration-strategies.ts +53 -0
- package/src/plugins/dev-mode/check-orm.ts +65 -0
- package/src/plugins/dev-mode/check-query.ts +231 -0
- package/src/plugins/dev-mode/check-schema.ts +564 -0
- package/src/plugins/dev-mode/dev-mode-tracking.ts +125 -0
- package/src/plugins/dev-mode/entity-properties.ts +56 -0
- package/src/plugins/dev-mode/error-messages.ts +1331 -0
- package/src/plugins/dev-mode/index.ts +203 -0
- package/src/plugins/dev-mode/unallowed-properties.ts +96 -0
- package/src/plugins/electron/electron-helper.ts +2 -0
- package/src/plugins/electron/index.ts +3 -0
- package/src/plugins/electron/rx-storage-ipc-main.ts +58 -0
- package/src/plugins/electron/rx-storage-ipc-renderer.ts +62 -0
- package/src/plugins/encryption-crypto-js/index.ts +220 -0
- package/src/plugins/flutter/dart/analysis_options.yaml +30 -0
- package/src/plugins/flutter/dart/example/rxdb_example.dart +6 -0
- package/src/plugins/flutter/dart/lib/rxdb.dart +7 -0
- package/src/plugins/flutter/dart/lib/src/rxdb_base.dart +332 -0
- package/src/plugins/flutter/dart/pubspec.yaml +15 -0
- package/src/plugins/flutter/index.ts +65 -0
- package/src/plugins/json-dump/index.ts +146 -0
- package/src/plugins/key-compression/index.ts +238 -0
- package/src/plugins/leader-election/index.ts +129 -0
- package/src/plugins/local-documents/index.ts +95 -0
- package/src/plugins/local-documents/local-documents-helper.ts +103 -0
- package/src/plugins/local-documents/local-documents.ts +146 -0
- package/src/plugins/local-documents/rx-local-document.ts +388 -0
- package/src/plugins/migration-schema/index.ts +75 -0
- package/src/plugins/migration-schema/migration-helpers.ts +162 -0
- package/src/plugins/migration-schema/migration-types.ts +42 -0
- package/src/plugins/migration-schema/rx-migration-state.ts +632 -0
- package/src/plugins/migration-storage/index.ts +255 -0
- package/src/plugins/pipeline/flagged-functions.ts +131 -0
- package/src/plugins/pipeline/index.ts +18 -0
- package/src/plugins/pipeline/rx-pipeline.ts +303 -0
- package/src/plugins/pipeline/types.ts +28 -0
- package/src/plugins/query-builder/index.ts +81 -0
- package/src/plugins/query-builder/mquery/README.md +5 -0
- package/src/plugins/query-builder/mquery/mquery-utils.ts +37 -0
- package/src/plugins/query-builder/mquery/nosql-query-builder.ts +578 -0
- package/src/plugins/react/database-context.ts +10 -0
- package/src/plugins/react/database-provider.tsx +38 -0
- package/src/plugins/react/hooks/index.ts +4 -0
- package/src/plugins/react/hooks/use-live-rx-query.ts +34 -0
- package/src/plugins/react/hooks/use-rx-collection.ts +73 -0
- package/src/plugins/react/hooks/use-rx-database.ts +35 -0
- package/src/plugins/react/hooks/use-rx-query.ts +168 -0
- package/src/plugins/react/index.ts +2 -0
- package/src/plugins/reactivity-angular/index.ts +32 -0
- package/src/plugins/reactivity-preact-signals/index.ts +85 -0
- package/src/plugins/reactivity-vue/index.ts +43 -0
- package/src/plugins/replication/index.ts +668 -0
- package/src/plugins/replication/replication-helper.ts +122 -0
- package/src/plugins/replication-appwrite/appwrite-helpers.ts +38 -0
- package/src/plugins/replication-appwrite/appwrite-types.ts +31 -0
- package/src/plugins/replication-appwrite/index.ts +269 -0
- package/src/plugins/replication-couchdb/couchdb-helper.ts +100 -0
- package/src/plugins/replication-couchdb/couchdb-types.ts +34 -0
- package/src/plugins/replication-couchdb/index.ts +341 -0
- package/src/plugins/replication-firestore/firestore-helper.ts +79 -0
- package/src/plugins/replication-firestore/firestore-types.ts +72 -0
- package/src/plugins/replication-firestore/index.ts +387 -0
- package/src/plugins/replication-google-drive/AGENTS.md +5 -0
- package/src/plugins/replication-google-drive/document-handling.ts +203 -0
- package/src/plugins/replication-google-drive/download-specs.sh +49 -0
- package/src/plugins/replication-google-drive/downstream.ts +118 -0
- package/src/plugins/replication-google-drive/google-drive-helper.ts +467 -0
- package/src/plugins/replication-google-drive/google-drive-types.ts +84 -0
- package/src/plugins/replication-google-drive/index.ts +221 -0
- package/src/plugins/replication-google-drive/init.ts +108 -0
- package/src/plugins/replication-google-drive/multipart.ts +86 -0
- package/src/plugins/replication-google-drive/signaling.ts +399 -0
- package/src/plugins/replication-google-drive/transaction.ts +222 -0
- package/src/plugins/replication-google-drive/upstream.ts +279 -0
- package/src/plugins/replication-graphql/graphql-schema-from-rx-schema.ts +337 -0
- package/src/plugins/replication-graphql/graphql-websocket.ts +56 -0
- package/src/plugins/replication-graphql/helper.ts +52 -0
- package/src/plugins/replication-graphql/index.ts +255 -0
- package/src/plugins/replication-graphql/query-builder-from-rx-schema.ts +195 -0
- package/src/plugins/replication-microsoft-onedrive/document-handling.ts +216 -0
- package/src/plugins/replication-microsoft-onedrive/downstream.ts +121 -0
- package/src/plugins/replication-microsoft-onedrive/index.ts +220 -0
- package/src/plugins/replication-microsoft-onedrive/init.ts +107 -0
- package/src/plugins/replication-microsoft-onedrive/microsoft-onedrive-helper.ts +355 -0
- package/src/plugins/replication-microsoft-onedrive/microsoft-onedrive-types.ts +88 -0
- package/src/plugins/replication-microsoft-onedrive/signaling.ts +333 -0
- package/src/plugins/replication-microsoft-onedrive/transaction.ts +220 -0
- package/src/plugins/replication-microsoft-onedrive/upstream.ts +282 -0
- package/src/plugins/replication-mongodb/index.ts +275 -0
- package/src/plugins/replication-mongodb/mongodb-checkpoint.ts +184 -0
- package/src/plugins/replication-mongodb/mongodb-helper.ts +69 -0
- package/src/plugins/replication-mongodb/mongodb-types.ts +50 -0
- package/src/plugins/replication-nats/index.ts +289 -0
- package/src/plugins/replication-nats/nats-helper.ts +15 -0
- package/src/plugins/replication-nats/nats-types.ts +43 -0
- package/src/plugins/replication-supabase/helper.ts +63 -0
- package/src/plugins/replication-supabase/index.ts +308 -0
- package/src/plugins/replication-supabase/types.ts +47 -0
- package/src/plugins/replication-webrtc/connection-handler-p2pcf.ts +77 -0
- package/src/plugins/replication-webrtc/connection-handler-simple-peer.ts +302 -0
- package/src/plugins/replication-webrtc/connection-handler-webtorrent.ts +137 -0
- package/src/plugins/replication-webrtc/index.ts +307 -0
- package/src/plugins/replication-webrtc/signaling-server.ts +193 -0
- package/src/plugins/replication-webrtc/webrtc-helper.ts +55 -0
- package/src/plugins/replication-webrtc/webrtc-types.ts +91 -0
- package/src/plugins/replication-websocket/index.ts +3 -0
- package/src/plugins/replication-websocket/websocket-client.ts +187 -0
- package/src/plugins/replication-websocket/websocket-server.ts +135 -0
- package/src/plugins/replication-websocket/websocket-types.ts +47 -0
- package/src/plugins/state/helpers.ts +86 -0
- package/src/plugins/state/index.ts +40 -0
- package/src/plugins/state/rx-state.ts +386 -0
- package/src/plugins/state/types.ts +32 -0
- package/src/plugins/storage-denokv/denokv-helper.ts +46 -0
- package/src/plugins/storage-denokv/denokv-query.ts +135 -0
- package/src/plugins/storage-denokv/denokv-types.ts +19 -0
- package/src/plugins/storage-denokv/index.ts +37 -0
- package/src/plugins/storage-denokv/rx-storage-instance-denokv.ts +426 -0
- package/src/plugins/storage-dexie/dexie-helper.ts +302 -0
- package/src/plugins/storage-dexie/dexie-query.ts +252 -0
- package/src/plugins/storage-dexie/index.ts +4 -0
- package/src/plugins/storage-dexie/rx-storage-dexie.ts +62 -0
- package/src/plugins/storage-dexie/rx-storage-instance-dexie.ts +378 -0
- package/src/plugins/storage-foundationdb/foundationdb-helpers.ts +6 -0
- package/src/plugins/storage-foundationdb/foundationdb-query.ts +140 -0
- package/src/plugins/storage-foundationdb/foundationdb-types.ts +64 -0
- package/src/plugins/storage-foundationdb/index.ts +57 -0
- package/src/plugins/storage-foundationdb/rx-storage-instance-foundationdb.ts +449 -0
- package/src/plugins/storage-localstorage/index.ts +44 -0
- package/src/plugins/storage-localstorage/localstorage-mock.ts +32 -0
- package/src/plugins/storage-localstorage/rx-storage-instance-localstorage.ts +686 -0
- package/src/plugins/storage-memory/binary-search-bounds.ts +106 -0
- package/src/plugins/storage-memory/index.ts +52 -0
- package/src/plugins/storage-memory/memory-helper.ts +259 -0
- package/src/plugins/storage-memory/memory-indexes.ts +34 -0
- package/src/plugins/storage-memory/memory-types.ts +90 -0
- package/src/plugins/storage-memory/rx-storage-instance-memory.ts +609 -0
- package/src/plugins/storage-mongodb/index.ts +4 -0
- package/src/plugins/storage-mongodb/mongodb-helper.ts +119 -0
- package/src/plugins/storage-mongodb/mongodb-types.ts +32 -0
- package/src/plugins/storage-mongodb/rx-storage-instance-mongodb.ts +464 -0
- package/src/plugins/storage-mongodb/rx-storage-mongodb.ts +33 -0
- package/src/plugins/storage-remote/index.ts +5 -0
- package/src/plugins/storage-remote/message-channel-cache.ts +88 -0
- package/src/plugins/storage-remote/remote.ts +285 -0
- package/src/plugins/storage-remote/rx-storage-remote.ts +286 -0
- package/src/plugins/storage-remote/storage-remote-helpers.ts +33 -0
- package/src/plugins/storage-remote/storage-remote-types.ts +118 -0
- package/src/plugins/storage-remote-websocket/index.ts +218 -0
- package/src/plugins/storage-remote-websocket/types.ts +34 -0
- package/src/plugins/storage-sqlite/index.ts +64 -0
- package/src/plugins/storage-sqlite/sqlite-basics-helpers.ts +656 -0
- package/src/plugins/storage-sqlite/sqlite-helpers.ts +287 -0
- package/src/plugins/storage-sqlite/sqlite-storage-instance.ts +507 -0
- package/src/plugins/storage-sqlite/sqlite-types.ts +151 -0
- package/src/plugins/test-utils/config.ts +135 -0
- package/src/plugins/test-utils/humans-collection.ts +557 -0
- package/src/plugins/test-utils/index.ts +24 -0
- package/src/plugins/test-utils/performance.ts +344 -0
- package/src/plugins/test-utils/replication-base-test-suite.ts +236 -0
- package/src/plugins/test-utils/replication.ts +95 -0
- package/src/plugins/test-utils/revisions.ts +4 -0
- package/src/plugins/test-utils/schema-objects.ts +527 -0
- package/src/plugins/test-utils/schemas.ts +1391 -0
- package/src/plugins/test-utils/test-util.ts +85 -0
- package/src/plugins/update/index.ts +57 -0
- package/src/plugins/update/mingo-updater.ts +26 -0
- package/src/plugins/utils/index.ts +20 -0
- package/src/plugins/utils/utils-array.ts +152 -0
- package/src/plugins/utils/utils-base64.ts +49 -0
- package/src/plugins/utils/utils-blob.ts +65 -0
- package/src/plugins/utils/utils-document.ts +117 -0
- package/src/plugins/utils/utils-error.ts +53 -0
- package/src/plugins/utils/utils-global.ts +5 -0
- package/src/plugins/utils/utils-hash.ts +62 -0
- package/src/plugins/utils/utils-map.ts +23 -0
- package/src/plugins/utils/utils-number.ts +9 -0
- package/src/plugins/utils/utils-object-deep-equal.ts +46 -0
- package/src/plugins/utils/utils-object-dot-prop.ts +365 -0
- package/src/plugins/utils/utils-object.ts +272 -0
- package/src/plugins/utils/utils-other.ts +58 -0
- package/src/plugins/utils/utils-premium.ts +37 -0
- package/src/plugins/utils/utils-promise.ts +171 -0
- package/src/plugins/utils/utils-regex.ts +2 -0
- package/src/plugins/utils/utils-revision.ts +55 -0
- package/src/plugins/utils/utils-rxdb-version.template.ts +4 -0
- package/src/plugins/utils/utils-rxdb-version.ts +4 -0
- package/src/plugins/utils/utils-string.ts +91 -0
- package/src/plugins/utils/utils-time.ts +37 -0
- package/src/plugins/validate-ajv/index.ts +61 -0
- package/src/plugins/validate-is-my-json-valid/index.ts +30 -0
- package/src/plugins/validate-z-schema/index.ts +58 -0
- package/src/plugins/vector/helper.ts +0 -0
- package/src/plugins/vector/index.ts +2 -0
- package/src/plugins/vector/types.ts +1 -0
- package/src/plugins/vector/vector-distance.ts +34 -0
- package/src/plugins/webmcp/index.ts +2 -0
- package/src/plugins/webmcp/nosql-query-schema.ts +299 -0
- package/src/plugins/webmcp/webmcp.ts +319 -0
- package/src/query-cache.ts +139 -0
- package/src/query-planner.ts +386 -0
- package/src/replication-protocol/checkpoint.ts +154 -0
- package/src/replication-protocol/conflicts.ts +53 -0
- package/src/replication-protocol/default-conflict-handler.ts +43 -0
- package/src/replication-protocol/downstream.ts +550 -0
- package/src/replication-protocol/helper.ts +96 -0
- package/src/replication-protocol/index.ts +348 -0
- package/src/replication-protocol/meta-instance.ts +195 -0
- package/src/replication-protocol/upstream.ts +560 -0
- package/src/rx-change-event.ts +137 -0
- package/src/rx-collection-helper.ts +262 -0
- package/src/rx-collection.ts +1306 -0
- package/src/rx-database-internal-store.ts +402 -0
- package/src/rx-database.ts +919 -0
- package/src/rx-document-prototype-merge.ts +124 -0
- package/src/rx-document.ts +557 -0
- package/src/rx-error.ts +190 -0
- package/src/rx-query-helper.ts +317 -0
- package/src/rx-query-mingo.ts +87 -0
- package/src/rx-query-single-result.ts +110 -0
- package/src/rx-query.ts +887 -0
- package/src/rx-schema-helper.ts +391 -0
- package/src/rx-schema.ts +247 -0
- package/src/rx-storage-helper.ts +1050 -0
- package/src/rx-storage-multiinstance.ts +188 -0
- package/src/types/conflict-handling.d.ts +48 -0
- package/src/types/couchdb.d.ts +293 -0
- package/src/types/index.d.ts +32 -0
- package/src/types/modules/index.d.ts +0 -0
- package/src/types/modules/mocha.parallel.d.ts +1 -0
- package/src/types/plugins/backup.d.ts +35 -0
- package/src/types/plugins/cleanup.d.ts +38 -0
- package/src/types/plugins/crdt.d.ts +76 -0
- package/src/types/plugins/dexie.d.ts +30 -0
- package/src/types/plugins/local-documents.d.ts +49 -0
- package/src/types/plugins/migration.d.ts +14 -0
- package/src/types/plugins/reactivity.d.ts +40 -0
- package/src/types/plugins/replication-graphql.d.ts +98 -0
- package/src/types/plugins/replication.d.ts +175 -0
- package/src/types/plugins/state.d.ts +4 -0
- package/src/types/plugins/update.d.ts +23 -0
- package/src/types/plugins/webmcp.d.ts +40 -0
- package/src/types/query-planner.d.ts +47 -0
- package/src/types/replication-protocol.d.ts +296 -0
- package/src/types/rx-attachment.d.ts +46 -0
- package/src/types/rx-change-event.d.ts +85 -0
- package/src/types/rx-collection.d.ts +117 -0
- package/src/types/rx-database-internal-store.d.ts +54 -0
- package/src/types/rx-database.d.ts +124 -0
- package/src/types/rx-document.d.ts +160 -0
- package/src/types/rx-error.d.ts +222 -0
- package/src/types/rx-plugin.d.ts +167 -0
- package/src/types/rx-query.d.ts +144 -0
- package/src/types/rx-schema.d.ts +209 -0
- package/src/types/rx-storage.d.ts +347 -0
- package/src/types/rx-storage.interface.d.ts +312 -0
- package/src/types/util.d.ts +180 -0
- package/tsconfig.json +54 -0
- package/tsconfig.lint.json +18 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ensureNotFalsy","errorToPlainJson","flatClone","getFromMapOrThrow","now","promiseWait","RxDBLeaderElectionPlugin","RxReplicationState","startReplicationOnLeaderShip","addRxPlugin","newRxError","Subject","couchDBDocToRxDocData","mergeUrlQueryParams","couchSwapPrimaryToId","getDefaultFetch","awaitRetry","RxCouchDBReplicationState","_RxReplicationState","url","fetch","replicationIdentifier","collection","pull","push","live","retryTime","autoStart","_this","call","_inheritsLoose","replicateCouchDB","options","conflictHandler","primaryPath","schema","endsWith","args","name","waitForLeadership","pullStream$","replicationPrimitivesPull","handler","lastPulledCheckpoint","batchSize","style","feed","include_docs","since","sequence","heartbeat","limit","seq_interval","response","replicationState","jsonResponse","json","results","documents","map","row","doc","checkpoint","last_seq","modifier","stream$","asObservable","initialCheckpoint","replicationPrimitivesPush","rows","conflicts","pushRowsById","Map","forEach","id","newDocumentState","set","docsByIdResponse","method","headers","body","JSON","stringify","keys","deleted","docsByIdRows","nonConflictRows","remoteRevById","Promise","all","key","realMasterState","pushRow","assumedMasterState","isEqual","_rev","docs","docId","sendDoc","has","responseJson","conflictAgainIds","writeResultRow","isConflict","error","ok","length","getConflictDocsUrl","conflictResponse","conflictResponseJson","conflictAgainRow","startBefore","start","bind","lastRequestStartTime","isStopped","err","subjects","next"],"sources":["../../../../src/plugins/replication-couchdb/index.ts"],"sourcesContent":["/**\r\n * This plugin can be used to sync collections with a remote CouchDB endpoint.\r\n */\r\nimport {\r\n ensureNotFalsy,\r\n errorToPlainJson,\r\n flatClone,\r\n getFromMapOrThrow,\r\n now,\r\n promiseWait\r\n} from '../../plugins/utils/index.ts';\r\n\r\nimport { RxDBLeaderElectionPlugin } from '../leader-election/index.ts';\r\nimport type {\r\n RxCollection,\r\n ReplicationPullOptions,\r\n ReplicationPushOptions,\r\n RxReplicationWriteToMasterRow,\r\n RxReplicationPullStreamItem,\r\n CouchdbChangesResult,\r\n CouchBulkDocResultRow,\r\n CouchAllDocsResponse,\r\n RxConflictHandler\r\n} from '../../types/index.d.ts';\r\nimport {\r\n RxReplicationState,\r\n startReplicationOnLeaderShip\r\n} from '../replication/index.ts';\r\nimport {\r\n addRxPlugin,\r\n newRxError,\r\n WithDeleted\r\n} from '../../index.ts';\r\n\r\nimport { Subject } from 'rxjs';\r\nimport type {\r\n CouchDBCheckpointType,\r\n FetchMethodType,\r\n SyncOptionsCouchDB\r\n} from './couchdb-types.ts';\r\nimport {\r\n couchDBDocToRxDocData,\r\n mergeUrlQueryParams,\r\n couchSwapPrimaryToId,\r\n getDefaultFetch\r\n} from './couchdb-helper.ts';\r\nimport { awaitRetry } from '../replication/replication-helper.ts';\r\n\r\nexport * from './couchdb-helper.ts';\r\nexport * from './couchdb-types.ts';\r\n\r\nexport class RxCouchDBReplicationState<RxDocType> extends RxReplicationState<RxDocType, CouchDBCheckpointType> {\r\n constructor(\r\n public readonly url: string,\r\n public fetch: FetchMethodType,\r\n public readonly replicationIdentifier: string,\r\n public readonly collection: RxCollection<RxDocType, any, any, any>,\r\n public readonly pull?: ReplicationPullOptions<RxDocType, CouchDBCheckpointType>,\r\n public readonly push?: ReplicationPushOptions<RxDocType>,\r\n public readonly live: boolean = true,\r\n public retryTime: number = 1000 * 5,\r\n public autoStart: boolean = true\r\n ) {\r\n super(\r\n replicationIdentifier,\r\n collection,\r\n '_deleted',\r\n pull,\r\n push,\r\n live,\r\n retryTime,\r\n autoStart\r\n );\r\n }\r\n}\r\n\r\nexport function replicateCouchDB<RxDocType>(\r\n options: SyncOptionsCouchDB<RxDocType>\r\n) {\r\n const collection = options.collection;\r\n const conflictHandler: RxConflictHandler<any> = collection.conflictHandler;\r\n addRxPlugin(RxDBLeaderElectionPlugin);\r\n const primaryPath = options.collection.schema.primaryPath;\r\n\r\n if (!options.url.endsWith('/')) {\r\n throw newRxError('RC_COUCHDB_1', {\r\n args: {\r\n collection: options.collection.name,\r\n url: options.url\r\n }\r\n });\r\n }\r\n\r\n options = flatClone(options);\r\n if (!options.url.endsWith('/')) {\r\n options.url = options.url + '/';\r\n }\r\n options.waitForLeadership = typeof options.waitForLeadership === 'undefined' ? true : options.waitForLeadership;\r\n const pullStream$: Subject<RxReplicationPullStreamItem<RxDocType, CouchDBCheckpointType>> = new Subject();\r\n let replicationPrimitivesPull: ReplicationPullOptions<RxDocType, CouchDBCheckpointType> | undefined;\r\n if (options.pull) {\r\n replicationPrimitivesPull = {\r\n async handler(\r\n lastPulledCheckpoint: CouchDBCheckpointType | undefined,\r\n batchSize: number\r\n ) {\r\n /**\r\n * @link https://docs.couchdb.org/en/3.2.2-docs/api/database/changes.html\r\n */\r\n const url = options.url + '_changes?' + mergeUrlQueryParams({\r\n style: 'all_docs',\r\n feed: 'normal',\r\n include_docs: true,\r\n since: lastPulledCheckpoint ? lastPulledCheckpoint.sequence : 0,\r\n heartbeat: options.pull && options.pull.heartbeat ? options.pull.heartbeat : 60000,\r\n limit: batchSize,\r\n seq_interval: batchSize\r\n });\r\n\r\n const response = await replicationState.fetch(url);\r\n const jsonResponse: CouchdbChangesResult = await response.json();\r\n if (!jsonResponse.results) {\r\n throw newRxError('RC_COUCHDB_2', {\r\n args: { jsonResponse }\r\n });\r\n }\r\n const documents: WithDeleted<RxDocType>[] = jsonResponse.results\r\n .map(row => couchDBDocToRxDocData(collection.schema.primaryPath, ensureNotFalsy(row.doc)));\r\n return {\r\n documents,\r\n checkpoint: {\r\n sequence: jsonResponse.last_seq\r\n }\r\n };\r\n },\r\n batchSize: ensureNotFalsy(options.pull).batchSize,\r\n modifier: ensureNotFalsy(options.pull).modifier,\r\n stream$: pullStream$.asObservable(),\r\n initialCheckpoint: options.pull.initialCheckpoint\r\n };\r\n }\r\n\r\n let replicationPrimitivesPush: ReplicationPushOptions<RxDocType> | undefined;\r\n if (options.push) {\r\n replicationPrimitivesPush = {\r\n async handler(\r\n rows: RxReplicationWriteToMasterRow<RxDocType>[]\r\n ) {\r\n const conflicts: WithDeleted<RxDocType>[] = [];\r\n const pushRowsById = new Map<string, RxReplicationWriteToMasterRow<RxDocType>>();\r\n rows.forEach(row => {\r\n const id = (row.newDocumentState as any)[primaryPath];\r\n pushRowsById.set(id, row);\r\n });\r\n\r\n /**\r\n * First get the current master state from the remote\r\n * to check for conflicts\r\n */\r\n const docsByIdResponse = await replicationState.fetch(\r\n options.url + '_all_docs?' + mergeUrlQueryParams({}),\r\n {\r\n method: 'POST',\r\n headers: {\r\n 'content-type': 'application/json'\r\n },\r\n body: JSON.stringify({\r\n keys: rows.map(row => (row.newDocumentState as any)[primaryPath]),\r\n include_docs: true,\r\n deleted: 'ok'\r\n })\r\n }\r\n );\r\n const docsByIdRows: CouchAllDocsResponse = await docsByIdResponse.json();\r\n const nonConflictRows: typeof rows = [];\r\n const remoteRevById = new Map<string, string>();\r\n await Promise.all(\r\n docsByIdRows.rows.map(async (row) => {\r\n if (!row.doc) {\r\n nonConflictRows.push(getFromMapOrThrow(pushRowsById, row.key));\r\n return;\r\n }\r\n const realMasterState: WithDeleted<RxDocType> = couchDBDocToRxDocData(primaryPath, row.doc);\r\n const pushRow = getFromMapOrThrow(pushRowsById, row.id);\r\n\r\n if (\r\n pushRow.assumedMasterState &&\r\n conflictHandler.isEqual(realMasterState, pushRow.assumedMasterState, 'couchdb-push-1')\r\n ) {\r\n remoteRevById.set(row.id, row.doc._rev);\r\n nonConflictRows.push(pushRow);\r\n } else {\r\n conflicts.push(realMasterState);\r\n }\r\n })\r\n );\r\n\r\n /**\r\n * @link https://docs.couchdb.org/en/3.2.2-docs/api/database/bulk-api.html#db-bulk-docs\r\n */\r\n const url = options.url + '_bulk_docs?' + mergeUrlQueryParams({});\r\n const body = {\r\n docs: nonConflictRows.map(row => {\r\n const docId = (row.newDocumentState as any)[primaryPath];\r\n const sendDoc = flatClone(row.newDocumentState);\r\n if (remoteRevById.has(docId)) {\r\n (sendDoc as any)._rev = getFromMapOrThrow(remoteRevById, docId);\r\n }\r\n return couchSwapPrimaryToId(collection.schema.primaryPath, sendDoc);\r\n })\r\n };\r\n\r\n const response = await replicationState.fetch(\r\n url,\r\n {\r\n method: 'POST',\r\n headers: {\r\n 'content-type': 'application/json'\r\n },\r\n body: JSON.stringify(body)\r\n }\r\n );\r\n const responseJson: CouchBulkDocResultRow[] = await response.json();\r\n\r\n // get conflicting writes\r\n const conflictAgainIds: string[] = [];\r\n responseJson.forEach(writeResultRow => {\r\n const isConflict = writeResultRow.error === 'conflict';\r\n if (!writeResultRow.ok && !isConflict) {\r\n throw newRxError('SNH', { args: { writeResultRow } });\r\n }\r\n if (isConflict) {\r\n conflictAgainIds.push(writeResultRow.id);\r\n }\r\n });\r\n\r\n if (conflictAgainIds.length === 0) {\r\n return conflicts;\r\n }\r\n\r\n const getConflictDocsUrl = options.url + '_all_docs?' + mergeUrlQueryParams({\r\n include_docs: true,\r\n keys: JSON.stringify(conflictAgainIds)\r\n });\r\n const conflictResponse = await replicationState.fetch(getConflictDocsUrl);\r\n const conflictResponseJson: CouchAllDocsResponse = await conflictResponse.json();\r\n conflictResponseJson.rows.forEach(conflictAgainRow => {\r\n conflicts.push(couchDBDocToRxDocData(collection.schema.primaryPath, conflictAgainRow.doc));\r\n });\r\n\r\n return conflicts;\r\n },\r\n batchSize: options.push.batchSize,\r\n modifier: options.push.modifier,\r\n initialCheckpoint: options.push.initialCheckpoint\r\n };\r\n }\r\n\r\n const replicationState = new RxCouchDBReplicationState<RxDocType>(\r\n options.url,\r\n options.fetch ? options.fetch : getDefaultFetch(),\r\n options.replicationIdentifier,\r\n collection,\r\n replicationPrimitivesPull,\r\n replicationPrimitivesPush,\r\n options.live,\r\n options.retryTime,\r\n options.autoStart\r\n );\r\n\r\n /**\r\n * Use long polling to get live changes for the pull.stream$\r\n */\r\n if (options.live && options.pull) {\r\n const startBefore = replicationState.start.bind(replicationState);\r\n replicationState.start = () => {\r\n let since: string | number = 'now';\r\n const batchSize = options.pull && options.pull.batchSize ? options.pull.batchSize : 20;\r\n\r\n (async () => {\r\n let lastRequestStartTime = now();\r\n while (!replicationState.isStopped()) {\r\n const url = options.url + '_changes?' + mergeUrlQueryParams({\r\n style: 'all_docs',\r\n feed: 'longpoll',\r\n since,\r\n include_docs: true,\r\n heartbeat: options.pull && options.pull.heartbeat ? options.pull.heartbeat : 60000,\r\n limit: batchSize,\r\n seq_interval: batchSize\r\n });\r\n\r\n let jsonResponse: CouchdbChangesResult;\r\n try {\r\n lastRequestStartTime = now();\r\n jsonResponse = await (await replicationState.fetch(url)).json();\r\n } catch (err: any) {\r\n replicationState.subjects.error.next(\r\n newRxError('RC_STREAM', {\r\n args: { url },\r\n error: errorToPlainJson(err)\r\n })\r\n );\r\n\r\n if (lastRequestStartTime < (now() - replicationState.retryTime)) {\r\n /**\r\n * Last request start was long ago,\r\n * so we directly retry.\r\n * This mostly happens on timeouts\r\n * which are normal behavior for long polling requests.\r\n */\r\n await promiseWait(0);\r\n } else {\r\n // await next tick here otherwise we could go in to a 100% CPU blocking cycle.\r\n await awaitRetry(\r\n collection,\r\n replicationState.retryTime\r\n );\r\n }\r\n continue;\r\n }\r\n const documents: WithDeleted<RxDocType>[] = jsonResponse.results\r\n .map(row => couchDBDocToRxDocData(collection.schema.primaryPath, ensureNotFalsy(row.doc)));\r\n since = jsonResponse.last_seq;\r\n\r\n pullStream$.next({\r\n documents,\r\n checkpoint: {\r\n sequence: jsonResponse.last_seq\r\n }\r\n });\r\n }\r\n })();\r\n return startBefore();\r\n };\r\n }\r\n\r\n startReplicationOnLeaderShip(options.waitForLeadership, replicationState);\r\n\r\n return replicationState;\r\n}\r\n"],"mappings":";AAAA;AACA;AACA;AACA,SACIA,cAAc,EACdC,gBAAgB,EAChBC,SAAS,EACTC,iBAAiB,EACjBC,GAAG,EACHC,WAAW,QACR,8BAA8B;AAErC,SAASC,wBAAwB,QAAQ,6BAA6B;AAYtE,SACIC,kBAAkB,EAClBC,4BAA4B,QACzB,yBAAyB;AAChC,SACIC,WAAW,EACXC,UAAU,QAEP,gBAAgB;AAEvB,SAASC,OAAO,QAAQ,MAAM;AAM9B,SACIC,qBAAqB,EACrBC,mBAAmB,EACnBC,oBAAoB,EACpBC,eAAe,QACZ,qBAAqB;AAC5B,SAASC,UAAU,QAAQ,sCAAsC;AAEjE,cAAc,qBAAqB;AACnC,cAAc,oBAAoB;AAElC,WAAaC,yBAAyB,0BAAAC,mBAAA;EAClC,SAAAD,0BACoBE,GAAW,EACpBC,KAAsB,EACbC,qBAA6B,EAC7BC,UAAkD,EAClDC,IAA+D,EAC/DC,IAAwC,EACxCC,IAAa,GAAG,IAAI,EAC7BC,SAAiB,GAAG,IAAI,GAAG,CAAC,EAC5BC,SAAkB,GAAG,IAAI,EAClC;IAAA,IAAAC,KAAA;IACEA,KAAA,GAAAV,mBAAA,CAAAW,IAAA,OACIR,qBAAqB,EACrBC,UAAU,EACV,UAAU,EACVC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,SAAS,EACTC,SACJ,CAAC;IAACC,KAAA,CAnBcT,GAAW,GAAXA,GAAW;IAAAS,KAAA,CACpBR,KAAsB,GAAtBA,KAAsB;IAAAQ,KAAA,CACbP,qBAA6B,GAA7BA,qBAA6B;IAAAO,KAAA,CAC7BN,UAAkD,GAAlDA,UAAkD;IAAAM,KAAA,CAClDL,IAA+D,GAA/DA,IAA+D;IAAAK,KAAA,CAC/DJ,IAAwC,GAAxCA,IAAwC;IAAAI,KAAA,C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AE,CAAC;MACJ,OAAOgD,WAAW,CAAC,CAAC;IACxB,CAAC;EACL;EAEAvG,4BAA4B,CAACwB,OAAO,CAACO,iBAAiB,EAAEe,gBAAgB,CAAC;EAEzE,OAAOA,gBAAgB;AAC3B","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Timestamp } from 'firebase/firestore';
|
|
2
|
+
import { flatClone, now } from "../../plugins/utils/index.js";
|
|
3
|
+
export function getFirestoreSortFieldValue(docData, primaryKey) {
|
|
4
|
+
var timeString = now() + '';
|
|
5
|
+
return 'rxdb-' + timeString.padStart(15, '0') + '-' + docData[primaryKey];
|
|
6
|
+
}
|
|
7
|
+
export function stripServerTimestampField(serverTimestampField, docData) {
|
|
8
|
+
var data = flatClone(docData);
|
|
9
|
+
delete data[serverTimestampField];
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
export function serverTimestampToIsoString(serverTimestampField, docData) {
|
|
13
|
+
var timestamp = docData[serverTimestampField];
|
|
14
|
+
var date = timestamp.toDate();
|
|
15
|
+
return date.toISOString();
|
|
16
|
+
}
|
|
17
|
+
export function isoStringToServerTimestamp(isoString) {
|
|
18
|
+
var date = new Date(isoString);
|
|
19
|
+
return Timestamp.fromDate(date);
|
|
20
|
+
}
|
|
21
|
+
export function firestoreRowToDocData(serverTimestampField, primaryPath, row) {
|
|
22
|
+
var docData = stripServerTimestampField(serverTimestampField, row.data());
|
|
23
|
+
docData[primaryPath] = row.id;
|
|
24
|
+
if (primaryPath !== 'id') {
|
|
25
|
+
delete docData['id'];
|
|
26
|
+
}
|
|
27
|
+
return docData;
|
|
28
|
+
}
|
|
29
|
+
export function stripPrimaryKey(primaryPath, docData) {
|
|
30
|
+
docData = flatClone(docData);
|
|
31
|
+
delete docData[primaryPath];
|
|
32
|
+
return docData;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// https://stackoverflow.com/questions/61354866/is-there-a-workaround-for-the-firebase-query-in-limit-to-10
|
|
36
|
+
export function getContentByIds(ids, getQuery) {
|
|
37
|
+
var batches = [];
|
|
38
|
+
while (ids.length) {
|
|
39
|
+
// firestore limits batches to 10
|
|
40
|
+
var batch = ids.splice(0, 10);
|
|
41
|
+
|
|
42
|
+
// add the batch request to a queue
|
|
43
|
+
batches.push(getQuery(batch));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// after all of the data is fetched, return it
|
|
47
|
+
return Promise.all(batches).then(content => content.flat());
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=firestore-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore-helper.js","names":["Timestamp","flatClone","now","getFirestoreSortFieldValue","docData","primaryKey","timeString","padStart","stripServerTimestampField","serverTimestampField","data","serverTimestampToIsoString","timestamp","date","toDate","toISOString","isoStringToServerTimestamp","isoString","Date","fromDate","firestoreRowToDocData","primaryPath","row","id","stripPrimaryKey","getContentByIds","ids","getQuery","batches","length","batch","splice","push","Promise","all","then","content","flat"],"sources":["../../../../src/plugins/replication-firestore/firestore-helper.ts"],"sourcesContent":["import {\r\n QueryDocumentSnapshot,\r\n Timestamp\r\n} from 'firebase/firestore';\r\nimport type {\r\n WithDeleted\r\n} from '../../types/index.d.ts';\r\nimport { flatClone, now } from '../../plugins/utils/index.ts';\r\nimport type { GetQuery } from './firestore-types.ts';\r\n\r\n\r\nexport function getFirestoreSortFieldValue(docData: any, primaryKey: string): string {\r\n const timeString = now() + '';\r\n return 'rxdb-' + timeString.padStart(15, '0') + '-' + docData[primaryKey];\r\n}\r\n\r\nexport function stripServerTimestampField<RxDocType>(\r\n serverTimestampField: string,\r\n docData: RxDocType\r\n): WithDeleted<RxDocType> {\r\n const data = flatClone(docData);\r\n delete (data as any)[serverTimestampField];\r\n return data as any;\r\n}\r\n\r\n\r\nexport function serverTimestampToIsoString(serverTimestampField: string, docData: any): string {\r\n const timestamp = (docData as any)[serverTimestampField];\r\n const date: Date = timestamp.toDate();\r\n return date.toISOString();\r\n}\r\n\r\nexport function isoStringToServerTimestamp(isoString: string): Timestamp {\r\n const date = new Date(isoString);\r\n return Timestamp.fromDate(date);\r\n}\r\n\r\nexport function firestoreRowToDocData<RxDocType>(\r\n serverTimestampField: string,\r\n primaryPath: string,\r\n row: QueryDocumentSnapshot<RxDocType>\r\n): WithDeleted<RxDocType> {\r\n const docData = stripServerTimestampField(\r\n serverTimestampField,\r\n row.data()\r\n );\r\n (docData as any)[primaryPath] = row.id;\r\n\r\n if (primaryPath !== 'id') {\r\n delete (docData as any)['id'];\r\n }\r\n\r\n return docData;\r\n}\r\n\r\nexport function stripPrimaryKey(\r\n primaryPath: string,\r\n docData: any\r\n): any {\r\n docData = flatClone(docData);\r\n delete (docData as any)[primaryPath];\r\n return docData;\r\n}\r\n\r\n// https://stackoverflow.com/questions/61354866/is-there-a-workaround-for-the-firebase-query-in-limit-to-10\r\nexport function getContentByIds<RxDocType>(ids: string[], getQuery: GetQuery<RxDocType>): Promise<QueryDocumentSnapshot<RxDocType>[]> {\r\n const batches = [];\r\n\r\n while (ids.length) {\r\n // firestore limits batches to 10\r\n const batch = ids.splice(0, 10);\r\n\r\n // add the batch request to a queue\r\n batches.push(getQuery(batch));\r\n }\r\n\r\n // after all of the data is fetched, return it\r\n return Promise.all(batches).then((content) => content.flat());\r\n}\r\n"],"mappings":"AAAA,SAEIA,SAAS,QACN,oBAAoB;AAI3B,SAASC,SAAS,EAAEC,GAAG,QAAQ,8BAA8B;AAI7D,OAAO,SAASC,0BAA0BA,CAACC,OAAY,EAAEC,UAAkB,EAAU;EACjF,IAAMC,UAAU,GAAGJ,GAAG,CAAC,CAAC,GAAG,EAAE;EAC7B,OAAO,OAAO,GAAGI,UAAU,CAACC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,GAAG,GAAGH,OAAO,CAACC,UAAU,CAAC;AAC7E;AAEA,OAAO,SAASG,yBAAyBA,CACrCC,oBAA4B,EAC5BL,OAAkB,EACI;EACtB,IAAMM,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AO,CAACI,IAAI,CAACL,QAAQ,CAACG,KAAK,CAAC,CAAC;EACjC;;EAEA;EACA,OAAOG,OAAO,CAACC,GAAG,CAACN,OAAO,CAAC,CAACO,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;AACjE","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore-types.js","names":[],"sources":["../../../../src/plugins/replication-firestore/firestore-types.ts"],"sourcesContent":["import type {\r\n MaybePromise,\r\n ReplicationOptions,\r\n ReplicationPullOptions,\r\n ReplicationPushOptions,\r\n WithDeleted\r\n} from '../../types/index.d.ts';\r\n\r\nimport type {\r\n CollectionReference,\r\n Firestore,\r\n QueryDocumentSnapshot,\r\n QueryFieldFilterConstraint,\r\n QueryFilterConstraint,\r\n QuerySnapshot\r\n} from 'firebase/firestore';\r\n\r\nexport type FirestoreCheckpointType = {\r\n id: string;\r\n /**\r\n * Firestore internally sets the time to an object like\r\n * {\r\n * \"seconds\": 1669807105,\r\n * \"nanoseconds\": 476000000\r\n * }\r\n * But to be able to query that, we have to use a date string\r\n * like '2022-11-30T11:18:25.141Z'\r\n * so we store that string instead.\r\n */\r\n serverTimestamp: string;\r\n};\r\nexport type FirestoreCollection<RxDocType> = CollectionReference<RxDocType>;\r\n\r\nexport type FirestoreOptions<RxDocType> = {\r\n projectId: string;\r\n collection: FirestoreCollection<RxDocType>;\r\n database: Firestore;\r\n};\r\n\r\nexport type FirestoreSyncPullOptions<RxDocType> =\r\n Omit<ReplicationPullOptions<RxDocType, FirestoreCheckpointType>, 'handler' | 'stream$'>\r\n & {\r\n filter?: QueryFilterConstraint | QueryFilterConstraint[];\r\n };\r\n\r\nexport type FirestoreSyncPushOptions<RxDocType> = Omit<ReplicationPushOptions<RxDocType>, 'handler'>\r\n & {\r\n filter?(item: WithDeleted<RxDocType>): MaybePromise<boolean>;\r\n };\r\n\r\nexport type SyncOptionsFirestore<RxDocType> = Omit<\r\n ReplicationOptions<RxDocType, any>,\r\n 'pull' | 'push'\r\n> & {\r\n firestore: FirestoreOptions<RxDocType>;\r\n /**\r\n * In firestore it is not possible to read out\r\n * the internally used write timestamp.\r\n * Even if we could read it out, it is not indexed which\r\n * is required for fetch 'changes-since-x'.\r\n * So instead we have to rely on a custom user defined field\r\n * that contains the server time which is set by firestore via serverTimestamp()\r\n * IMPORTANT: The serverTimestampField MUST NOT be part of the collections RxJsonSchema!\r\n * [default='serverTimestamp']\r\n * @link https://groups.google.com/g/firebase-talk/c/tAmPzPei-mE\r\n */\r\n serverTimestampField?: string;\r\n pull?: FirestoreSyncPullOptions<RxDocType>;\r\n push?: FirestoreSyncPushOptions<RxDocType>;\r\n};\r\n\r\nexport type GetQuery<RxDocType> = (ids: string[]) => Promise<QueryDocumentSnapshot<RxDocType>[]>;\r\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
|
+
import { asyncFilter, ensureNotFalsy, errorToPlainJson, flatClone, lastOfArray, toArray } from "../../plugins/utils/index.js";
|
|
3
|
+
import { doc, query, where, orderBy, limit, getDocs, getDoc, onSnapshot, runTransaction, writeBatch, serverTimestamp, waitForPendingWrites, documentId } from 'firebase/firestore';
|
|
4
|
+
import { RxDBLeaderElectionPlugin } from "../leader-election/index.js";
|
|
5
|
+
import { RxReplicationState, startReplicationOnLeaderShip } from "../replication/index.js";
|
|
6
|
+
import { addRxPlugin, getSchemaByObjectPath, newRxError } from "../../index.js";
|
|
7
|
+
import { Subject } from 'rxjs';
|
|
8
|
+
import { firestoreRowToDocData, getContentByIds, isoStringToServerTimestamp, serverTimestampToIsoString, stripPrimaryKey, stripServerTimestampField } from "./firestore-helper.js";
|
|
9
|
+
export * from "./firestore-helper.js";
|
|
10
|
+
export * from "./firestore-types.js";
|
|
11
|
+
export var RxFirestoreReplicationState = /*#__PURE__*/function (_RxReplicationState) {
|
|
12
|
+
function RxFirestoreReplicationState(firestore, replicationIdentifierHash, collection, pull, push, live = true, retryTime = 1000 * 5, autoStart = true) {
|
|
13
|
+
var _this;
|
|
14
|
+
_this = _RxReplicationState.call(this, replicationIdentifierHash, collection, '_deleted', pull, push, live, retryTime, autoStart) || this;
|
|
15
|
+
_this.firestore = firestore;
|
|
16
|
+
_this.replicationIdentifierHash = replicationIdentifierHash;
|
|
17
|
+
_this.collection = collection;
|
|
18
|
+
_this.pull = pull;
|
|
19
|
+
_this.push = push;
|
|
20
|
+
_this.live = live;
|
|
21
|
+
_this.retryTime = retryTime;
|
|
22
|
+
_this.autoStart = autoStart;
|
|
23
|
+
return _this;
|
|
24
|
+
}
|
|
25
|
+
_inheritsLoose(RxFirestoreReplicationState, _RxReplicationState);
|
|
26
|
+
return RxFirestoreReplicationState;
|
|
27
|
+
}(RxReplicationState);
|
|
28
|
+
export function replicateFirestore(options) {
|
|
29
|
+
var collection = options.collection;
|
|
30
|
+
addRxPlugin(RxDBLeaderElectionPlugin);
|
|
31
|
+
var pullStream$ = new Subject();
|
|
32
|
+
var replicationPrimitivesPull;
|
|
33
|
+
options.live = typeof options.live === 'undefined' ? true : options.live;
|
|
34
|
+
options.waitForLeadership = typeof options.waitForLeadership === 'undefined' ? true : options.waitForLeadership;
|
|
35
|
+
var serverTimestampField = typeof options.serverTimestampField === 'undefined' ? 'serverTimestamp' : options.serverTimestampField;
|
|
36
|
+
options.serverTimestampField = serverTimestampField;
|
|
37
|
+
var primaryPath = collection.schema.primaryPath;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The serverTimestampField MUST NOT be part of the collections RxJsonSchema.
|
|
41
|
+
*/
|
|
42
|
+
var schemaPart = getSchemaByObjectPath(collection.schema.jsonSchema, serverTimestampField);
|
|
43
|
+
if (schemaPart ||
|
|
44
|
+
// also must not be nested.
|
|
45
|
+
serverTimestampField.includes('.')) {
|
|
46
|
+
throw newRxError('RC6', {
|
|
47
|
+
field: serverTimestampField,
|
|
48
|
+
schema: collection.schema.jsonSchema
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
var pullFilters = options.pull?.filter !== undefined ? toArray(options.pull.filter) : [];
|
|
52
|
+
var pullQuery = query(options.firestore.collection, ...pullFilters);
|
|
53
|
+
if (options.pull) {
|
|
54
|
+
replicationPrimitivesPull = {
|
|
55
|
+
async handler(lastPulledCheckpoint, batchSize) {
|
|
56
|
+
var newerQuery;
|
|
57
|
+
var sameTimeQuery;
|
|
58
|
+
if (lastPulledCheckpoint) {
|
|
59
|
+
var lastServerTimestamp = isoStringToServerTimestamp(lastPulledCheckpoint.serverTimestamp);
|
|
60
|
+
newerQuery = query(pullQuery, where(serverTimestampField, '>', lastServerTimestamp), orderBy(serverTimestampField, 'asc'), limit(batchSize));
|
|
61
|
+
sameTimeQuery = query(pullQuery, where(serverTimestampField, '==', lastServerTimestamp), where(documentId(), '>', lastPulledCheckpoint.id), orderBy(documentId(), 'asc'), limit(batchSize));
|
|
62
|
+
} else {
|
|
63
|
+
newerQuery = query(pullQuery, orderBy(serverTimestampField, 'asc'), limit(batchSize));
|
|
64
|
+
}
|
|
65
|
+
var mustsReRun = true;
|
|
66
|
+
var useDocs = [];
|
|
67
|
+
while (mustsReRun) {
|
|
68
|
+
/**
|
|
69
|
+
* Local writes that have not been persisted to the server
|
|
70
|
+
* are in pending state and do not have a correct serverTimestamp set.
|
|
71
|
+
* We have to ensure we only use document states that are in sync with the server.
|
|
72
|
+
* @link https://medium.com/firebase-developers/the-secrets-of-firestore-fieldvalue-servertimestamp-revealed-29dd7a38a82b
|
|
73
|
+
*/
|
|
74
|
+
await waitForPendingWrites(options.firestore.database);
|
|
75
|
+
await runTransaction(options.firestore.database, async _tx => {
|
|
76
|
+
useDocs = [];
|
|
77
|
+
var [newerQueryResult, sameTimeQueryResult] = await Promise.all([getDocs(newerQuery), sameTimeQuery ? getDocs(sameTimeQuery) : undefined]);
|
|
78
|
+
if (newerQueryResult.metadata.hasPendingWrites || sameTimeQuery && ensureNotFalsy(sameTimeQueryResult).metadata.hasPendingWrites) {
|
|
79
|
+
return;
|
|
80
|
+
} else {
|
|
81
|
+
mustsReRun = false;
|
|
82
|
+
if (sameTimeQuery) {
|
|
83
|
+
useDocs = ensureNotFalsy(sameTimeQueryResult).docs;
|
|
84
|
+
}
|
|
85
|
+
var missingAmount = batchSize - useDocs.length;
|
|
86
|
+
if (missingAmount > 0) {
|
|
87
|
+
var additionalDocs = newerQueryResult.docs.slice(0, missingAmount).filter(x => !!x);
|
|
88
|
+
useDocs = useDocs.concat(additionalDocs);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (useDocs.length === 0) {
|
|
94
|
+
return {
|
|
95
|
+
checkpoint: lastPulledCheckpoint ?? undefined,
|
|
96
|
+
documents: []
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
var lastDoc = ensureNotFalsy(lastOfArray(useDocs));
|
|
100
|
+
var documents = useDocs.map(row => firestoreRowToDocData(serverTimestampField, primaryPath, row));
|
|
101
|
+
var newCheckpoint = {
|
|
102
|
+
id: lastDoc.id,
|
|
103
|
+
serverTimestamp: serverTimestampToIsoString(serverTimestampField, lastDoc.data())
|
|
104
|
+
};
|
|
105
|
+
var ret = {
|
|
106
|
+
documents: documents,
|
|
107
|
+
checkpoint: newCheckpoint
|
|
108
|
+
};
|
|
109
|
+
return ret;
|
|
110
|
+
},
|
|
111
|
+
batchSize: ensureNotFalsy(options.pull).batchSize,
|
|
112
|
+
modifier: ensureNotFalsy(options.pull).modifier,
|
|
113
|
+
stream$: pullStream$.asObservable(),
|
|
114
|
+
initialCheckpoint: options.pull.initialCheckpoint
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
var replicationPrimitivesPush;
|
|
118
|
+
if (options.push) {
|
|
119
|
+
var pushFilter = options.push?.filter;
|
|
120
|
+
replicationPrimitivesPush = {
|
|
121
|
+
async handler(rows) {
|
|
122
|
+
if (pushFilter !== undefined) {
|
|
123
|
+
rows = await asyncFilter(rows, row => pushFilter(row.newDocumentState));
|
|
124
|
+
}
|
|
125
|
+
var writeRowsById = {};
|
|
126
|
+
var docIds = rows.map(row => {
|
|
127
|
+
var docId = row.newDocumentState[primaryPath];
|
|
128
|
+
writeRowsById[docId] = row;
|
|
129
|
+
return docId;
|
|
130
|
+
});
|
|
131
|
+
await waitForPendingWrites(options.firestore.database);
|
|
132
|
+
var conflicts = [];
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Everything must run INSIDE of the transaction
|
|
136
|
+
* because on tx-errors, firebase will re-run the transaction on some cases.
|
|
137
|
+
* @link https://firebase.google.com/docs/firestore/manage-data/transactions#transaction_failure
|
|
138
|
+
* @link https://firebase.google.com/docs/firestore/manage-data/transactions
|
|
139
|
+
*/
|
|
140
|
+
await runTransaction(options.firestore.database, async _tx => {
|
|
141
|
+
conflicts = []; // reset in case the tx has re-run.
|
|
142
|
+
/**
|
|
143
|
+
* @link https://stackoverflow.com/a/48423626/3443137
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
var getQuery = ids => {
|
|
147
|
+
return getDocs(query(options.firestore.collection, where(documentId(), 'in', ids))).then(result => result.docs).catch(error => {
|
|
148
|
+
if (error?.code && error.code === 'permission-denied') {
|
|
149
|
+
// Query may fail due to rules using 'resource' with non existing ids
|
|
150
|
+
// So try to get the docs one by one
|
|
151
|
+
return Promise.all(ids.map(id => getDoc(doc(options.firestore.collection, id)))).then(docs => docs.filter(doc => doc.exists()));
|
|
152
|
+
}
|
|
153
|
+
throw error;
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
var docsInDbResult = await getContentByIds(docIds, getQuery);
|
|
157
|
+
var docsInDbById = {};
|
|
158
|
+
docsInDbResult.forEach(row => {
|
|
159
|
+
var docDataInDb = stripServerTimestampField(serverTimestampField, row.data());
|
|
160
|
+
var docId = row.id;
|
|
161
|
+
docDataInDb[primaryPath] = docId;
|
|
162
|
+
docsInDbById[docId] = docDataInDb;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @link https://firebase.google.com/docs/firestore/manage-data/transactions#batched-writes
|
|
167
|
+
*/
|
|
168
|
+
var batch = writeBatch(options.firestore.database);
|
|
169
|
+
var hasWrite = false;
|
|
170
|
+
await Promise.all(Object.entries(writeRowsById).map(async ([docId, writeRow]) => {
|
|
171
|
+
var docInDb = docsInDbById[docId];
|
|
172
|
+
if (docInDb && (!writeRow.assumedMasterState || collection.conflictHandler.isEqual(docInDb, writeRow.assumedMasterState, 'replication-firestore-push') === false)) {
|
|
173
|
+
// conflict
|
|
174
|
+
conflicts.push(docInDb);
|
|
175
|
+
} else {
|
|
176
|
+
// no conflict
|
|
177
|
+
hasWrite = true;
|
|
178
|
+
var docRef = doc(options.firestore.collection, docId);
|
|
179
|
+
var writeDocData = flatClone(writeRow.newDocumentState);
|
|
180
|
+
writeDocData[serverTimestampField] = serverTimestamp();
|
|
181
|
+
if (!docInDb) {
|
|
182
|
+
// insert
|
|
183
|
+
batch.set(docRef, stripPrimaryKey(primaryPath, writeDocData));
|
|
184
|
+
} else {
|
|
185
|
+
// update
|
|
186
|
+
batch.update(docRef, stripPrimaryKey(primaryPath, writeDocData));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}));
|
|
190
|
+
if (hasWrite) {
|
|
191
|
+
await batch.commit();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
await waitForPendingWrites(options.firestore.database);
|
|
195
|
+
return conflicts;
|
|
196
|
+
},
|
|
197
|
+
batchSize: options.push.batchSize,
|
|
198
|
+
modifier: options.push.modifier
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
var replicationState = new RxFirestoreReplicationState(options.firestore, options.replicationIdentifier, collection, replicationPrimitivesPull, replicationPrimitivesPush, options.live, options.retryTime, options.autoStart);
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Use long polling to get live changes for the pull.stream$
|
|
205
|
+
*/
|
|
206
|
+
if (options.live && options.pull) {
|
|
207
|
+
var startBefore = replicationState.start.bind(replicationState);
|
|
208
|
+
var cancelBefore = replicationState.cancel.bind(replicationState);
|
|
209
|
+
replicationState.start = () => {
|
|
210
|
+
var lastChangeQuery = query(pullQuery, orderBy(serverTimestampField, 'desc'), limit(1));
|
|
211
|
+
var unsubscribe = onSnapshot(lastChangeQuery, _querySnapshot => {
|
|
212
|
+
/**
|
|
213
|
+
* There is no good way to observe the event stream in firestore.
|
|
214
|
+
* So instead we listen to any write to the collection
|
|
215
|
+
* and then emit a 'RESYNC' flag.
|
|
216
|
+
*/
|
|
217
|
+
replicationState.reSync();
|
|
218
|
+
}, error => {
|
|
219
|
+
replicationState.subjects.error.next(newRxError('RC_STREAM', {
|
|
220
|
+
error: errorToPlainJson(error)
|
|
221
|
+
}));
|
|
222
|
+
});
|
|
223
|
+
replicationState.cancel = () => {
|
|
224
|
+
unsubscribe();
|
|
225
|
+
return cancelBefore();
|
|
226
|
+
};
|
|
227
|
+
return startBefore();
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
startReplicationOnLeaderShip(options.waitForLeadership, replicationState);
|
|
231
|
+
return replicationState;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["asyncFilter","ensureNotFalsy","errorToPlainJson","flatClone","lastOfArray","toArray","doc","query","where","orderBy","limit","getDocs","getDoc","onSnapshot","runTransaction","writeBatch","serverTimestamp","waitForPendingWrites","documentId","RxDBLeaderElectionPlugin","RxReplicationState","startReplicationOnLeaderShip","addRxPlugin","getSchemaByObjectPath","newRxError","Subject","firestoreRowToDocData","getContentByIds","isoStringToServerTimestamp","serverTimestampToIsoString","stripPrimaryKey","stripServerTimestampField","RxFirestoreReplicationState","_RxReplicationState","firestore","replicationIdentifierHash","collection","pull","push","live","retryTime","autoStart","_this","call","_inheritsLoose","replicateFirestore","options","pullStream$","replicationPrimitivesPull","waitForLeadership","serverTimestampField","primaryPath","schema","schemaPart","jsonSchema","includes","field","pullFilters","filter","undefined","pullQuery","handler","lastPulledCheckpoint","batchSize","newerQuery","sameTimeQuery","lastServerTimestamp","id","mustsReRun","useDocs","database","_tx","newerQueryResult","sameTimeQueryResult","Promise","all","metadata","hasPendingWrites","docs","missingAmount","length","additionalDocs","slice","x","concat","checkpoint","documents","lastDoc","map","row","newCheckpoint","data","ret","modifier","stream$","asObservable","initialCheckpoint","replicationPrimitivesPush","pushFilter","rows","newDocumentState","writeRowsById","docIds","docId","conflicts","getQuery","ids","then","result","catch","error","code","exists","docsInDbResult","docsInDbById","forEach","docDataInDb","batch","hasWrite","Object","entries","writeRow","docInDb","assumedMasterState","conflictHandler","isEqual","docRef","writeDocData","set","update","commit","replicationState","replicationIdentifier","startBefore","start","bind","cancelBefore","cancel","lastChangeQuery","unsubscribe","_querySnapshot","reSync","subjects","next"],"sources":["../../../../src/plugins/replication-firestore/index.ts"],"sourcesContent":["import {\r\n asyncFilter,\r\n ensureNotFalsy,\r\n errorToPlainJson,\r\n flatClone,\r\n lastOfArray,\r\n toArray\r\n} from '../../plugins/utils/index.ts';\r\n\r\nimport {\r\n doc,\r\n query,\r\n where,\r\n orderBy,\r\n limit,\r\n getDocs,\r\n getDoc,\r\n onSnapshot,\r\n runTransaction,\r\n writeBatch,\r\n serverTimestamp,\r\n QueryDocumentSnapshot,\r\n waitForPendingWrites,\r\n documentId,\r\n FirestoreError,\r\n QueryConstraint\r\n} from 'firebase/firestore';\r\n\r\nimport { RxDBLeaderElectionPlugin } from '../leader-election/index.ts';\r\nimport type {\r\n RxCollection,\r\n ReplicationPullOptions,\r\n ReplicationPushOptions,\r\n RxReplicationWriteToMasterRow,\r\n RxReplicationPullStreamItem\r\n} from '../../types/index.d.ts';\r\nimport {\r\n RxReplicationState,\r\n startReplicationOnLeaderShip\r\n} from '../replication/index.ts';\r\nimport {\r\n addRxPlugin,\r\n ById,\r\n getSchemaByObjectPath,\r\n newRxError,\r\n WithDeleted\r\n} from '../../index.ts';\r\n\r\nimport type {\r\n FirestoreCheckpointType,\r\n FirestoreOptions,\r\n SyncOptionsFirestore\r\n} from './firestore-types.ts';\r\nimport { Subject } from 'rxjs';\r\nimport {\r\n firestoreRowToDocData,\r\n getContentByIds,\r\n isoStringToServerTimestamp,\r\n serverTimestampToIsoString,\r\n stripPrimaryKey,\r\n stripServerTimestampField\r\n} from './firestore-helper.ts';\r\n\r\nexport * from './firestore-helper.ts';\r\nexport * from './firestore-types.ts';\r\n\r\nexport class RxFirestoreReplicationState<RxDocType> extends RxReplicationState<RxDocType, FirestoreCheckpointType> {\r\n constructor(\r\n public readonly firestore: FirestoreOptions<RxDocType>,\r\n public readonly replicationIdentifierHash: string,\r\n public readonly collection: RxCollection<RxDocType>,\r\n public readonly pull?: ReplicationPullOptions<RxDocType, FirestoreCheckpointType>,\r\n public readonly push?: ReplicationPushOptions<RxDocType>,\r\n public readonly live: boolean = true,\r\n public retryTime: number = 1000 * 5,\r\n public autoStart: boolean = true\r\n ) {\r\n super(\r\n replicationIdentifierHash,\r\n collection,\r\n '_deleted',\r\n pull,\r\n push,\r\n live,\r\n retryTime,\r\n autoStart\r\n );\r\n }\r\n}\r\n\r\nexport function replicateFirestore<RxDocType>(\r\n options: SyncOptionsFirestore<RxDocType>\r\n): RxFirestoreReplicationState<RxDocType> {\r\n const collection: RxCollection<RxDocType, any, any> = options.collection;\r\n addRxPlugin(RxDBLeaderElectionPlugin);\r\n const pullStream$: Subject<RxReplicationPullStreamItem<RxDocType, FirestoreCheckpointType>> = new Subject();\r\n let replicationPrimitivesPull: ReplicationPullOptions<RxDocType, FirestoreCheckpointType> | undefined;\r\n options.live = typeof options.live === 'undefined' ? true : options.live;\r\n options.waitForLeadership = typeof options.waitForLeadership === 'undefined' ? true : options.waitForLeadership;\r\n const serverTimestampField = typeof options.serverTimestampField === 'undefined' ? 'serverTimestamp' : options.serverTimestampField;\r\n options.serverTimestampField = serverTimestampField;\r\n const primaryPath = collection.schema.primaryPath;\r\n\r\n /**\r\n * The serverTimestampField MUST NOT be part of the collections RxJsonSchema.\r\n */\r\n const schemaPart = getSchemaByObjectPath(collection.schema.jsonSchema, serverTimestampField);\r\n if (\r\n schemaPart ||\r\n // also must not be nested.\r\n serverTimestampField.includes('.')\r\n ) {\r\n throw newRxError('RC6', {\r\n field: serverTimestampField,\r\n schema: collection.schema.jsonSchema\r\n });\r\n }\r\n\r\n const pullFilters: QueryConstraint[] = options.pull?.filter !== undefined\r\n ? toArray(options.pull.filter) as QueryConstraint[]\r\n : [];\r\n\r\n const pullQuery = query(options.firestore.collection, ...pullFilters);\r\n\r\n if (options.pull) {\r\n replicationPrimitivesPull = {\r\n async handler(\r\n lastPulledCheckpoint: FirestoreCheckpointType | undefined,\r\n batchSize: number\r\n ) {\r\n let newerQuery: ReturnType<typeof query>;\r\n let sameTimeQuery: ReturnType<typeof query> | undefined;\r\n\r\n if (lastPulledCheckpoint) {\r\n const lastServerTimestamp = isoStringToServerTimestamp(lastPulledCheckpoint.serverTimestamp);\r\n newerQuery = query(pullQuery,\r\n where(serverTimestampField, '>', lastServerTimestamp),\r\n orderBy(serverTimestampField, 'asc'),\r\n limit(batchSize)\r\n );\r\n sameTimeQuery = query(pullQuery,\r\n where(serverTimestampField, '==', lastServerTimestamp),\r\n where(documentId(), '>', lastPulledCheckpoint.id),\r\n orderBy(documentId(), 'asc'),\r\n limit(batchSize)\r\n );\r\n } else {\r\n newerQuery = query(pullQuery,\r\n orderBy(serverTimestampField, 'asc'),\r\n limit(batchSize)\r\n );\r\n }\r\n\r\n let mustsReRun = true;\r\n let useDocs: QueryDocumentSnapshot<RxDocType>[] = [];\r\n while (mustsReRun) {\r\n /**\r\n * Local writes that have not been persisted to the server\r\n * are in pending state and do not have a correct serverTimestamp set.\r\n * We have to ensure we only use document states that are in sync with the server.\r\n * @link https://medium.com/firebase-developers/the-secrets-of-firestore-fieldvalue-servertimestamp-revealed-29dd7a38a82b\r\n */\r\n await waitForPendingWrites(options.firestore.database);\r\n await runTransaction(options.firestore.database, async (_tx: any) => {\r\n useDocs = [];\r\n const [\r\n newerQueryResult,\r\n sameTimeQueryResult\r\n ] = await Promise.all([\r\n getDocs(newerQuery),\r\n sameTimeQuery ? getDocs(sameTimeQuery) : undefined\r\n ]);\r\n\r\n if (\r\n newerQueryResult.metadata.hasPendingWrites ||\r\n (sameTimeQuery && ensureNotFalsy(sameTimeQueryResult).metadata.hasPendingWrites)\r\n ) {\r\n return;\r\n } else {\r\n mustsReRun = false;\r\n\r\n if (sameTimeQuery) {\r\n useDocs = ensureNotFalsy(sameTimeQueryResult).docs as any;\r\n }\r\n const missingAmount = batchSize - useDocs.length;\r\n if (missingAmount > 0) {\r\n const additionalDocs = newerQueryResult.docs.slice(0, missingAmount).filter((x: any) => !!x);\r\n useDocs = useDocs.concat(additionalDocs as any);\r\n }\r\n }\r\n });\r\n }\r\n\r\n if (useDocs.length === 0) {\r\n return {\r\n checkpoint: lastPulledCheckpoint ?? undefined,\r\n documents: []\r\n };\r\n }\r\n const lastDoc = ensureNotFalsy(lastOfArray(useDocs));\r\n const documents: WithDeleted<RxDocType>[] = useDocs\r\n .map(row => firestoreRowToDocData(\r\n serverTimestampField,\r\n primaryPath,\r\n row\r\n ));\r\n const newCheckpoint: FirestoreCheckpointType = {\r\n id: lastDoc.id,\r\n serverTimestamp: serverTimestampToIsoString(serverTimestampField, lastDoc.data())\r\n };\r\n const ret = {\r\n documents: documents,\r\n checkpoint: newCheckpoint\r\n };\r\n return ret;\r\n },\r\n batchSize: ensureNotFalsy(options.pull).batchSize,\r\n modifier: ensureNotFalsy(options.pull).modifier,\r\n stream$: pullStream$.asObservable(),\r\n initialCheckpoint: options.pull.initialCheckpoint\r\n };\r\n }\r\n\r\n let replicationPrimitivesPush: ReplicationPushOptions<RxDocType> | undefined;\r\n if (options.push) {\r\n const pushFilter = options.push?.filter;\r\n replicationPrimitivesPush = {\r\n async handler(\r\n rows: RxReplicationWriteToMasterRow<RxDocType>[]\r\n ) {\r\n if (pushFilter !== undefined) {\r\n rows = await asyncFilter(rows, (row) => pushFilter(row.newDocumentState));\r\n }\r\n\r\n const writeRowsById: ById<RxReplicationWriteToMasterRow<RxDocType>> = {};\r\n const docIds: string[] = rows.map(row => {\r\n const docId = (row.newDocumentState as any)[primaryPath];\r\n writeRowsById[docId] = row;\r\n return docId;\r\n });\r\n await waitForPendingWrites(options.firestore.database);\r\n let conflicts: WithDeleted<RxDocType>[] = [];\r\n\r\n /**\r\n * Everything must run INSIDE of the transaction\r\n * because on tx-errors, firebase will re-run the transaction on some cases.\r\n * @link https://firebase.google.com/docs/firestore/manage-data/transactions#transaction_failure\r\n * @link https://firebase.google.com/docs/firestore/manage-data/transactions\r\n */\r\n await runTransaction(options.firestore.database, async (_tx: any) => {\r\n conflicts = []; // reset in case the tx has re-run.\r\n /**\r\n * @link https://stackoverflow.com/a/48423626/3443137\r\n */\r\n\r\n const getQuery = (ids: string[]) => {\r\n return getDocs(\r\n query(\r\n options.firestore.collection,\r\n where(documentId(), 'in', ids)\r\n )\r\n )\r\n .then((result: any) => result.docs)\r\n .catch((error: any) => {\r\n if (error?.code && (error as FirestoreError).code === 'permission-denied') {\r\n // Query may fail due to rules using 'resource' with non existing ids\r\n // So try to get the docs one by one\r\n return Promise.all(\r\n ids.map(\r\n id => getDoc(doc(options.firestore.collection, id))\r\n )\r\n )\r\n .then((docs: any[]) => docs.filter((doc: any) => doc.exists()));\r\n }\r\n throw error;\r\n });\r\n };\r\n\r\n const docsInDbResult = await getContentByIds<RxDocType>(docIds, getQuery);\r\n\r\n const docsInDbById: ById<RxDocType> = {};\r\n docsInDbResult.forEach(row => {\r\n const docDataInDb = stripServerTimestampField(serverTimestampField, row.data());\r\n const docId = row.id;\r\n (docDataInDb as any)[primaryPath] = docId;\r\n docsInDbById[docId] = docDataInDb;\r\n });\r\n\r\n /**\r\n * @link https://firebase.google.com/docs/firestore/manage-data/transactions#batched-writes\r\n */\r\n const batch = writeBatch(options.firestore.database);\r\n let hasWrite = false;\r\n await Promise.all(\r\n Object.entries(writeRowsById).map(async ([docId, writeRow]) => {\r\n const docInDb: RxDocType | undefined = docsInDbById[docId];\r\n\r\n if (\r\n docInDb &&\r\n (\r\n !writeRow.assumedMasterState ||\r\n collection.conflictHandler.isEqual(docInDb as any, writeRow.assumedMasterState, 'replication-firestore-push') === false\r\n )\r\n ) {\r\n // conflict\r\n conflicts.push(docInDb as any);\r\n } else {\r\n // no conflict\r\n hasWrite = true;\r\n const docRef = doc(options.firestore.collection, docId);\r\n const writeDocData = flatClone(writeRow.newDocumentState);\r\n (writeDocData as any)[serverTimestampField] = serverTimestamp();\r\n if (!docInDb) {\r\n // insert\r\n batch.set(docRef, stripPrimaryKey(primaryPath, writeDocData));\r\n } else {\r\n // update\r\n batch.update(docRef, stripPrimaryKey(primaryPath, writeDocData));\r\n }\r\n }\r\n })\r\n );\r\n\r\n if (hasWrite) {\r\n await batch.commit();\r\n }\r\n });\r\n await waitForPendingWrites(options.firestore.database);\r\n return conflicts;\r\n },\r\n batchSize: options.push.batchSize,\r\n modifier: options.push.modifier\r\n };\r\n }\r\n\r\n\r\n const replicationState = new RxFirestoreReplicationState<RxDocType>(\r\n options.firestore,\r\n options.replicationIdentifier,\r\n collection,\r\n replicationPrimitivesPull,\r\n replicationPrimitivesPush,\r\n options.live,\r\n options.retryTime,\r\n options.autoStart\r\n );\r\n\r\n /**\r\n * Use long polling to get live changes for the pull.stream$\r\n */\r\n if (options.live && options.pull) {\r\n const startBefore = replicationState.start.bind(replicationState);\r\n const cancelBefore = replicationState.cancel.bind(replicationState);\r\n replicationState.start = () => {\r\n const lastChangeQuery = query(\r\n pullQuery,\r\n orderBy(serverTimestampField, 'desc'),\r\n limit(1)\r\n );\r\n const unsubscribe = onSnapshot(\r\n lastChangeQuery,\r\n (_querySnapshot: any) => {\r\n /**\r\n * There is no good way to observe the event stream in firestore.\r\n * So instead we listen to any write to the collection\r\n * and then emit a 'RESYNC' flag.\r\n */\r\n replicationState.reSync();\r\n },\r\n (error: FirestoreError) => {\r\n replicationState.subjects.error.next(\r\n newRxError('RC_STREAM', { error: errorToPlainJson(error) })\r\n );\r\n }\r\n );\r\n replicationState.cancel = () => {\r\n unsubscribe();\r\n return cancelBefore();\r\n };\r\n return startBefore();\r\n };\r\n }\r\n\r\n startReplicationOnLeaderShip(options.waitForLeadership, replicationState);\r\n\r\n return replicationState;\r\n}\r\n"],"mappings":";AAAA,SACIA,WAAW,EACXC,cAAc,EACdC,gBAAgB,EAChBC,SAAS,EACTC,WAAW,EACXC,OAAO,QACJ,8BAA8B;AAErC,SACIC,GAAG,EACHC,KAAK,EACLC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,UAAU,EACVC,eAAe,EAEfC,oBAAoB,EACpBC,UAAU,QAGP,oBAAoB;AAE3B,SAASC,wBAAwB,QAAQ,6BAA6B;AAQtE,SACIC,kBAAkB,EAClBC,4BAA4B,QACzB,yBAAyB;AAChC,SACIC,WAAW,EAEXC,qBAAqB,EACrBC,UAAU,QAEP,gBAAgB;AAOvB,SAASC,OAAO,QAAQ,MAAM;AAC9B,SACIC,qBAAqB,EACrBC,eAAe,EACfC,0BAA0B,EAC1BC,0BAA0B,EAC1BC,eAAe,EACfC,yBAAyB,QACtB,uBAAuB;AAE9B,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AAEpC,WAAaC,2BAA2B,0BAAAC,mBAAA;EACpC,SAAAD,4BACoBE,SAAsC,EACtCC,yBAAiC,EACjCC,UAAmC,EACnCC,IAAiE,EACjEC,IAAwC,EACxCC,IAAa,GAAG,IAAI,EAC7BC,SAAiB,GAAG,IAAI,GAAG,CAAC,EAC5BC,SAAkB,GAAG,IAAI,EAClC;IAAA,IAAAC,KAAA;IACEA,KAAA,GAAAT,mBAAA,CAAAU,IAAA,OACIR,yBAAyB,EACzBC,UAAU,EACV,U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GnI,KAAK,CACzBqD,SAAS,EACTnD,OAAO,CAACyC,oBAAoB,EAAE,MAAM,CAAC,EACrCxC,KAAK,CAAC,CAAC,CACX,CAAC;MACD,IAAMiI,WAAW,GAAG9H,UAAU,CAC1B6H,eAAe,EACdE,cAAmB,IAAK;QACrB;AACpB;AACA;AACA;AACA;QACoBT,gBAAgB,CAACU,MAAM,CAAC,CAAC;MAC7B,CAAC,EACA/B,KAAqB,IAAK;QACvBqB,gBAAgB,CAACW,QAAQ,CAAChC,KAAK,CAACiC,IAAI,CAChCvH,UAAU,CAAC,WAAW,EAAE;UAAEsF,KAAK,EAAE5G,gBAAgB,CAAC4G,KAAK;QAAE,CAAC,CAC9D,CAAC;MACL,CACJ,CAAC;MACDqB,gBAAgB,CAACM,MAAM,GAAG,MAAM;QAC5BE,WAAW,CAAC,CAAC;QACb,OAAOH,YAAY,CAAC,CAAC;MACzB,CAAC;MACD,OAAOH,WAAW,CAAC,CAAC;IACxB,CAAC;EACL;EAEAhH,4BAA4B,CAACyB,OAAO,CAACG,iBAAiB,EAAEkF,gBAAgB,CAAC;EAEzE,OAAOA,gBAAgB;AAC3B","ignoreList":[]}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { newRxError, newRxFetchError } from "../../rx-error.js";
|
|
2
|
+
import { ensureNotFalsy } from "../utils/index.js";
|
|
3
|
+
import { insertMultipartFile } from "./google-drive-helper.js";
|
|
4
|
+
var MAX_DRIVE_PAGE_SIZE = 1000;
|
|
5
|
+
export async function getDocumentFiles(googleDriveOptions, init, docIds) {
|
|
6
|
+
var fileNames = docIds.map(id => id + '.json');
|
|
7
|
+
var q = fileNames.map(name => "name = '" + name.replace("'", "\\'") + "'").join(' or ');
|
|
8
|
+
q = '(' + q + ') and trashed = false';
|
|
9
|
+
q += ' and \'' + init.docsFolderId + '\' in parents';
|
|
10
|
+
if (docIds.length >= MAX_DRIVE_PAGE_SIZE) {
|
|
11
|
+
throw newRxError('SNH');
|
|
12
|
+
}
|
|
13
|
+
var params = new URLSearchParams({
|
|
14
|
+
q,
|
|
15
|
+
pageSize: MAX_DRIVE_PAGE_SIZE + '',
|
|
16
|
+
fields: "nextPageToken, files(id,name,mimeType,parents,modifiedTime,size)",
|
|
17
|
+
// Shared drives support (safe to include always)
|
|
18
|
+
includeItemsFromAllDrives: "true",
|
|
19
|
+
supportsAllDrives: "true"
|
|
20
|
+
});
|
|
21
|
+
var url = googleDriveOptions.apiEndpoint + '/drive/v3/files?' + params.toString();
|
|
22
|
+
var res = await fetch(url, {
|
|
23
|
+
method: "GET",
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: "Bearer " + googleDriveOptions.authToken
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (!res.ok) {
|
|
29
|
+
throw await newRxFetchError(res, {
|
|
30
|
+
ids: docIds
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
var data = await res.json();
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
export async function batchGetFilesMetadata(googleDriveOptions, fileIds) {
|
|
37
|
+
var boundary = "batch_" + Math.random().toString(16).slice(2);
|
|
38
|
+
var parts = fileIds.map((id, i) => {
|
|
39
|
+
return "--" + boundary + "\r\n" + "Content-Type: application/http\r\n" + ("Content-ID: <item-" + i + ">\r\n\r\n") + ("GET /drive/v3/files/" + encodeURIComponent(id) + "?") + "fields=id,name,mimeType,parents,modifiedTime,size&supportsAllDrives=true HTTP/1.1\r\n\r\n";
|
|
40
|
+
});
|
|
41
|
+
var batchBody = parts.join("") + ("--" + boundary + "--");
|
|
42
|
+
var res = await fetch(googleDriveOptions.apiEndpoint + "/batch/drive/v3", {
|
|
43
|
+
method: "POST",
|
|
44
|
+
headers: {
|
|
45
|
+
Authorization: "Bearer " + googleDriveOptions.authToken,
|
|
46
|
+
"Content-Type": "multipart/mixed; boundary=" + boundary
|
|
47
|
+
},
|
|
48
|
+
body: batchBody
|
|
49
|
+
});
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
throw await newRxFetchError(res);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// multipart/mixed; you can parse it, or just return raw.
|
|
55
|
+
return await res.text();
|
|
56
|
+
}
|
|
57
|
+
export async function insertDocumentFiles(googleDriveOptions, init, primaryPath, docs) {
|
|
58
|
+
// Run uploads in parallel
|
|
59
|
+
await Promise.all(docs.map(async doc => {
|
|
60
|
+
var id = doc[primaryPath];
|
|
61
|
+
await insertMultipartFile(googleDriveOptions, init.docsFolderId, id + '.json', doc);
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
export async function updateDocumentFiles(googleDriveOptions, primaryPath, docs, fileIdByDocId, concurrency = 5) {
|
|
65
|
+
var queue = docs.slice(0);
|
|
66
|
+
var results = {};
|
|
67
|
+
async function worker() {
|
|
68
|
+
while (queue.length) {
|
|
69
|
+
var doc = queue.shift();
|
|
70
|
+
var docId = doc[primaryPath];
|
|
71
|
+
var fileId = ensureNotFalsy(fileIdByDocId[docId]);
|
|
72
|
+
var url = googleDriveOptions.apiEndpoint + ("/upload/drive/v3/files/" + encodeURIComponent(fileId)) + "?uploadType=media&supportsAllDrives=true&fields=id";
|
|
73
|
+
var res = await fetch(url, {
|
|
74
|
+
method: "PATCH",
|
|
75
|
+
headers: {
|
|
76
|
+
Authorization: "Bearer " + googleDriveOptions.authToken,
|
|
77
|
+
"Content-Type": "application/json; charset=UTF-8"
|
|
78
|
+
},
|
|
79
|
+
body: JSON.stringify(doc)
|
|
80
|
+
});
|
|
81
|
+
if (!res.ok) {
|
|
82
|
+
throw await newRxFetchError(res, {
|
|
83
|
+
args: {
|
|
84
|
+
docId,
|
|
85
|
+
fileId
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
results[docId] = await res.json(); // { id }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
await Promise.all(Array.from({
|
|
93
|
+
length: concurrency
|
|
94
|
+
}, () => worker()));
|
|
95
|
+
return results;
|
|
96
|
+
}
|
|
97
|
+
export async function fetchDocumentContents(googleDriveOptions, fileIds, concurrency = 5) {
|
|
98
|
+
var byId = {};
|
|
99
|
+
var ordered = new Array(fileIds.length);
|
|
100
|
+
var nextIndex = 0;
|
|
101
|
+
var sleep = ms => new Promise(r => setTimeout(r, ms));
|
|
102
|
+
async function fetchOne(fileId, attempt = 0) {
|
|
103
|
+
var url = googleDriveOptions.apiEndpoint + ("/drive/v3/files/" + encodeURIComponent(fileId) + "?alt=media&supportsAllDrives=true");
|
|
104
|
+
var res = await fetch(url, {
|
|
105
|
+
headers: {
|
|
106
|
+
Authorization: "Bearer " + googleDriveOptions.authToken
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
if ([429, 500, 502, 503, 504].includes(res.status) && attempt < 4) {
|
|
110
|
+
var backoffMs = 250 * Math.pow(2, attempt) + Math.floor(Math.random() * 200);
|
|
111
|
+
await sleep(backoffMs);
|
|
112
|
+
return fetchOne(fileId, attempt + 1);
|
|
113
|
+
}
|
|
114
|
+
if (!res.ok) throw await newRxFetchError(res, {
|
|
115
|
+
args: {
|
|
116
|
+
fileId
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
var text = await res.text();
|
|
120
|
+
return text ? JSON.parse(text) : undefined;
|
|
121
|
+
}
|
|
122
|
+
async function worker() {
|
|
123
|
+
while (true) {
|
|
124
|
+
var i = nextIndex++;
|
|
125
|
+
if (i >= fileIds.length) return;
|
|
126
|
+
var fileId = fileIds[i];
|
|
127
|
+
var doc = await fetchOne(fileId);
|
|
128
|
+
ordered[i] = ensureNotFalsy(doc);
|
|
129
|
+
byId[fileId] = doc; // if ById allows undefined, remove `as any`
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
await Promise.all(Array.from({
|
|
133
|
+
length: concurrency
|
|
134
|
+
}, () => worker()));
|
|
135
|
+
return {
|
|
136
|
+
byId,
|
|
137
|
+
ordered
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=document-handling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-handling.js","names":["newRxError","newRxFetchError","ensureNotFalsy","insertMultipartFile","MAX_DRIVE_PAGE_SIZE","getDocumentFiles","googleDriveOptions","init","docIds","fileNames","map","id","q","name","replace","join","docsFolderId","length","params","URLSearchParams","pageSize","fields","includeItemsFromAllDrives","supportsAllDrives","url","apiEndpoint","toString","res","fetch","method","headers","Authorization","authToken","ok","ids","data","json","batchGetFilesMetadata","fileIds","boundary","Math","random","slice","parts","i","encodeURIComponent","batchBody","body","text","insertDocumentFiles","primaryPath","docs","Promise","all","doc","updateDocumentFiles","fileIdByDocId","concurrency","queue","results","worker","shift","docId","fileId","JSON","stringify","args","Array","from","fetchDocumentContents","byId","ordered","nextIndex","sleep","ms","r","setTimeout","fetchOne","attempt","includes","status","backoffMs","pow","floor","parse","undefined"],"sources":["../../../../src/plugins/replication-google-drive/document-handling.ts"],"sourcesContent":["import { newRxError, newRxFetchError } from '../../rx-error.ts';\r\nimport { ById } from '../../types/util';\r\nimport { ensureNotFalsy } from '../utils/index.ts';\r\nimport { insertMultipartFile } from './google-drive-helper.ts';\r\nimport type {\r\n DriveFileListResponse,\r\n GoogleDriveOptionsWithDefaults\r\n} from './google-drive-types.ts';\r\nimport { DriveStructure } from './init.ts';\r\n\r\nconst MAX_DRIVE_PAGE_SIZE = 1000;\r\n\r\n\r\n\r\nexport async function getDocumentFiles(\r\n googleDriveOptions: GoogleDriveOptionsWithDefaults,\r\n init: DriveStructure,\r\n docIds: string[]\r\n): Promise<DriveFileListResponse> {\r\n const fileNames = docIds.map(id => id + '.json');\r\n let q = fileNames\r\n .map(name => `name = '${name.replace(\"'\", \"\\\\'\")}'`)\r\n .join(' or ');\r\n q = '(' + q + ') and trashed = false';\r\n q += ' and \\'' + init.docsFolderId + '\\' in parents';\r\n if (docIds.length >= MAX_DRIVE_PAGE_SIZE) {\r\n throw newRxError('SNH');\r\n }\r\n const params = new URLSearchParams({\r\n q,\r\n pageSize: MAX_DRIVE_PAGE_SIZE + '',\r\n fields: \"nextPageToken, files(id,name,mimeType,parents,modifiedTime,size)\",\r\n // Shared drives support (safe to include always)\r\n includeItemsFromAllDrives: \"true\",\r\n supportsAllDrives: \"true\",\r\n });\r\n const url = googleDriveOptions.apiEndpoint + '/drive/v3/files?' + params.toString();\r\n const res = await fetch(url, {\r\n method: \"GET\",\r\n headers: {\r\n Authorization: `Bearer ${googleDriveOptions.authToken}`,\r\n },\r\n });\r\n\r\n if (!res.ok) {\r\n throw await newRxFetchError(res, {\r\n ids: docIds,\r\n });\r\n }\r\n\r\n const data = await res.json();\r\n return data;\r\n}\r\n\r\nexport async function batchGetFilesMetadata(\r\n googleDriveOptions: GoogleDriveOptionsWithDefaults,\r\n fileIds: string[]\r\n) {\r\n const boundary = \"batch_\" + Math.random().toString(16).slice(2);\r\n\r\n const parts = fileIds.map((id, i) => {\r\n return (\r\n `--${boundary}\\r\\n` +\r\n `Content-Type: application/http\\r\\n` +\r\n `Content-ID: <item-${i}>\\r\\n\\r\\n` +\r\n `GET /drive/v3/files/${encodeURIComponent(id)}?` +\r\n `fields=id,name,mimeType,parents,modifiedTime,size&supportsAllDrives=true HTTP/1.1\\r\\n\\r\\n`\r\n );\r\n });\r\n\r\n const batchBody = parts.join(\"\") + `--${boundary}--`;\r\n\r\n const res = await fetch(googleDriveOptions.apiEndpoint + \"/batch/drive/v3\", {\r\n method: \"POST\",\r\n headers: {\r\n Authorization: `Bearer ${googleDriveOptions.authToken}`,\r\n \"Content-Type\": `multipart/mixed; boundary=${boundary}`,\r\n },\r\n body: batchBody,\r\n });\r\n\r\n if (!res.ok) {\r\n throw await newRxFetchError(res);\r\n }\r\n\r\n // multipart/mixed; you can parse it, or just return raw.\r\n return await res.text();\r\n}\r\n\r\nexport async function insertDocumentFiles<RxDocType>(\r\n googleDriveOptions: GoogleDriveOptionsWithDefaults,\r\n init: DriveStructure,\r\n primaryPath: keyof RxDocType,\r\n docs: RxDocType[]\r\n) {\r\n // Run uploads in parallel\r\n await Promise.all(docs.map(async (doc) => {\r\n const id = (doc as any)[primaryPath];\r\n await insertMultipartFile(\r\n googleDriveOptions,\r\n init.docsFolderId,\r\n id + '.json',\r\n doc\r\n );\r\n }));\r\n}\r\n\r\nexport async function updateDocumentFiles<DocType>(\r\n googleDriveOptions: GoogleDriveOptionsWithDefaults,\r\n primaryPath: keyof DocType,\r\n docs: DocType[],\r\n fileIdByDocId: Record<string, string>,\r\n concurrency = 5\r\n) {\r\n const queue = docs.slice(0);\r\n const results: Record<string, { id: string }> = {};\r\n\r\n async function worker() {\r\n while (queue.length) {\r\n const doc = queue.shift()!;\r\n const docId = (doc as any)[primaryPath] as string;\r\n const fileId = ensureNotFalsy(fileIdByDocId[docId]);\r\n\r\n const url =\r\n googleDriveOptions.apiEndpoint +\r\n `/upload/drive/v3/files/${encodeURIComponent(fileId)}` +\r\n `?uploadType=media&supportsAllDrives=true&fields=id`;\r\n\r\n const res = await fetch(url, {\r\n method: \"PATCH\",\r\n headers: {\r\n Authorization: `Bearer ${googleDriveOptions.authToken}`,\r\n \"Content-Type\": \"application/json; charset=UTF-8\",\r\n },\r\n body: JSON.stringify(doc),\r\n });\r\n\r\n if (!res.ok) {\r\n throw await newRxFetchError(res, {\r\n args: {\r\n docId,\r\n fileId\r\n }\r\n });\r\n }\r\n\r\n results[docId] = await res.json(); // { id }\r\n }\r\n }\r\n\r\n await Promise.all(Array.from({ length: concurrency }, () => worker()));\r\n return results;\r\n}\r\n\r\n\r\nexport async function fetchDocumentContents<DocType>(\r\n googleDriveOptions: GoogleDriveOptionsWithDefaults,\r\n fileIds: string[],\r\n concurrency = 5\r\n): Promise<{ byId: ById<DocType>; ordered: (DocType)[] }> {\r\n const byId: ById<DocType> = {};\r\n const ordered = new Array<DocType>(fileIds.length);\r\n let nextIndex = 0;\r\n\r\n const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\r\n\r\n async function fetchOne(fileId: string, attempt = 0): Promise<DocType | undefined> {\r\n const url =\r\n googleDriveOptions.apiEndpoint +\r\n `/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&supportsAllDrives=true`;\r\n\r\n const res = await fetch(url, {\r\n headers: { Authorization: `Bearer ${googleDriveOptions.authToken}` },\r\n });\r\n\r\n if ([429, 500, 502, 503, 504].includes(res.status) && attempt < 4) {\r\n const backoffMs = 250 * Math.pow(2, attempt) + Math.floor(Math.random() * 200);\r\n await sleep(backoffMs);\r\n return fetchOne(fileId, attempt + 1);\r\n }\r\n\r\n if (!res.ok) throw await newRxFetchError(res, { args: { fileId } });\r\n\r\n const text = await res.text();\r\n return text ? (JSON.parse(text) as DocType) : undefined;\r\n }\r\n\r\n async function worker() {\r\n while (true) {\r\n const i = nextIndex++;\r\n if (i >= fileIds.length) return;\r\n\r\n const fileId = fileIds[i];\r\n const doc = await fetchOne(fileId);\r\n\r\n ordered[i] = ensureNotFalsy(doc);\r\n byId[fileId] = doc as any; // if ById allows undefined, remove `as any`\r\n }\r\n }\r\n\r\n await Promise.all(Array.from({ length: concurrency }, () => worker()));\r\n return { byId, ordered };\r\n}\r\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,eAAe,QAAQ,mBAAmB;AAE/D,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,mBAAmB,QAAQ,0BAA0B;AAO9D,IAAMC,mBAAmB,GAAG,IAAI;AAIhC,OAAO,eAAeC,gBAAgBA,CAClCC,kBAAkD,EAClDC,IAAoB,EACpBC,MAAgB,EACc;EAC9B,IAAMC,SAAS,GAAGD,MAAM,CAACE,GAAG,CAACC,EAAE,IAAIA,EAAE,GAAG,OAAO,CAAC;EAChD,IAAIC,CAAC,GAAGH,SAAS,CACZC,GAAG,CAACG,IAAI,iBAAeA,IAAI,CAACC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,MAAG,CAAC,CACnDC,IAAI,CAAC,MAAM,CAAC;EACjBH,CAAC,GAAG,GAAG,GAAGA,CAAC,GAAG,uBAAuB;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