@react-native-firebase/firestore 23.8.6 → 24.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/RNFBFirestore.podspec +2 -1
- package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreCollectionModule.java +17 -4
- package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreDocumentModule.java +2 -2
- package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestorePipelineExecutor.java +1243 -0
- package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestorePipelineNodeBuilder.java +3919 -0
- package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestorePipelineParser.java +1735 -0
- package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreSerialize.java +1 -1
- package/dist/module/FieldPath.js +59 -0
- package/dist/module/FieldPath.js.map +1 -0
- package/dist/module/FieldValue.js +82 -0
- package/dist/module/FieldValue.js.map +1 -0
- package/{lib → dist/module}/FirestoreAggregate.js +31 -43
- package/dist/module/FirestoreAggregate.js.map +1 -0
- package/dist/module/FirestoreBlob.js +56 -0
- package/dist/module/FirestoreBlob.js.map +1 -0
- package/dist/module/FirestoreCollectionReference.js +70 -0
- package/dist/module/FirestoreCollectionReference.js.map +1 -0
- package/{lib → dist/module}/FirestoreDocumentChange.js +12 -15
- package/dist/module/FirestoreDocumentChange.js.map +1 -0
- package/dist/module/FirestoreDocumentReference.js +170 -0
- package/dist/module/FirestoreDocumentReference.js.map +1 -0
- package/dist/module/FirestoreDocumentSnapshot.js +88 -0
- package/dist/module/FirestoreDocumentSnapshot.js.map +1 -0
- package/dist/module/FirestoreFilter.js +146 -0
- package/dist/module/FirestoreFilter.js.map +1 -0
- package/dist/module/FirestoreGeoPoint.js +80 -0
- package/dist/module/FirestoreGeoPoint.js.map +1 -0
- package/{lib → dist/module}/FirestorePath.js +5 -12
- package/dist/module/FirestorePath.js.map +1 -0
- package/{lib → dist/module}/FirestorePersistentCacheIndexManager.js +11 -4
- package/dist/module/FirestorePersistentCacheIndexManager.js.map +1 -0
- package/dist/module/FirestoreQuery.js +298 -0
- package/dist/module/FirestoreQuery.js.map +1 -0
- package/{lib → dist/module}/FirestoreQueryModifiers.js +25 -136
- package/dist/module/FirestoreQueryModifiers.js.map +1 -0
- package/dist/module/FirestoreQuerySnapshot.js +98 -0
- package/dist/module/FirestoreQuerySnapshot.js.map +1 -0
- package/dist/module/FirestoreSnapshotMetadata.js +38 -0
- package/dist/module/FirestoreSnapshotMetadata.js.map +1 -0
- package/dist/module/FirestoreStatics.js +50 -0
- package/dist/module/FirestoreStatics.js.map +1 -0
- package/{lib → dist/module}/FirestoreTimestamp.js +39 -39
- package/dist/module/FirestoreTimestamp.js.map +1 -0
- package/dist/module/FirestoreTransaction.js +113 -0
- package/dist/module/FirestoreTransaction.js.map +1 -0
- package/dist/module/FirestoreTransactionHandler.js +137 -0
- package/dist/module/FirestoreTransactionHandler.js.map +1 -0
- package/dist/module/FirestoreVectorValue.js +75 -0
- package/dist/module/FirestoreVectorValue.js.map +1 -0
- package/dist/module/FirestoreWriteBatch.js +113 -0
- package/dist/module/FirestoreWriteBatch.js.map +1 -0
- package/dist/module/LoadBundleTask.js +70 -0
- package/dist/module/LoadBundleTask.js.map +1 -0
- package/dist/module/index.js +31 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/modular/Bytes.js +67 -0
- package/dist/module/modular/Bytes.js.map +1 -0
- package/dist/module/modular/FieldPath.js +25 -0
- package/dist/module/modular/FieldPath.js.map +1 -0
- package/dist/module/modular/FieldValue.js +37 -0
- package/dist/module/modular/FieldValue.js.map +1 -0
- package/dist/module/modular/GeoPoint.js +22 -0
- package/dist/module/modular/GeoPoint.js.map +1 -0
- package/dist/module/modular/Timestamp.js +22 -0
- package/dist/module/modular/Timestamp.js.map +1 -0
- package/dist/module/modular/VectorValue.js +25 -0
- package/dist/module/modular/VectorValue.js.map +1 -0
- package/dist/module/modular/query.js +222 -0
- package/dist/module/modular/query.js.map +1 -0
- package/dist/module/modular/snapshot.js +32 -0
- package/dist/module/modular/snapshot.js.map +1 -0
- package/dist/module/modular.js +229 -0
- package/dist/module/modular.js.map +1 -0
- package/dist/module/namespaced.js +298 -0
- package/dist/module/namespaced.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/dist/module/pipelines/expressions.js +1273 -0
- package/dist/module/pipelines/expressions.js.map +1 -0
- package/dist/module/pipelines/index.js +32 -0
- package/dist/module/pipelines/index.js.map +1 -0
- package/dist/module/pipelines/pipeline-result.js +58 -0
- package/dist/module/pipelines/pipeline-result.js.map +1 -0
- package/dist/module/pipelines/pipeline-source.js +4 -0
- package/dist/module/pipelines/pipeline-source.js.map +1 -0
- package/dist/module/pipelines/pipeline.js +4 -0
- package/dist/module/pipelines/pipeline.js.map +1 -0
- package/dist/module/pipelines/pipeline_impl.js +42 -0
- package/dist/module/pipelines/pipeline_impl.js.map +1 -0
- package/dist/module/pipelines/pipeline_options.js +4 -0
- package/dist/module/pipelines/pipeline_options.js.map +1 -0
- package/dist/module/pipelines/pipeline_runtime.js +526 -0
- package/dist/module/pipelines/pipeline_runtime.js.map +1 -0
- package/dist/module/pipelines/pipeline_support.js +71 -0
- package/dist/module/pipelines/pipeline_support.js.map +1 -0
- package/dist/module/pipelines/pipeline_validate.js +183 -0
- package/dist/module/pipelines/pipeline_validate.js.map +1 -0
- package/dist/module/pipelines/stage_options.js +4 -0
- package/dist/module/pipelines/stage_options.js.map +1 -0
- package/dist/module/pipelines/types.js +2 -0
- package/dist/module/pipelines/types.js.map +1 -0
- package/dist/module/types/firestore.js +4 -0
- package/dist/module/types/firestore.js.map +1 -0
- package/dist/module/types/internal.js +4 -0
- package/dist/module/types/internal.js.map +1 -0
- package/dist/module/types/namespaced.js +338 -0
- package/dist/module/types/namespaced.js.map +1 -0
- package/{lib → dist/module}/utils/index.js +59 -114
- package/dist/module/utils/index.js.map +1 -0
- package/{lib → dist/module}/utils/serialize.js +58 -116
- package/dist/module/utils/serialize.js.map +1 -0
- package/{lib → dist/module}/utils/typemap.js +6 -20
- package/dist/module/utils/typemap.js.map +1 -0
- package/dist/module/version.js +5 -0
- package/dist/module/version.js.map +1 -0
- package/dist/module/web/RNFBFirestoreModule.android.js +5 -0
- package/dist/module/web/RNFBFirestoreModule.android.js.map +1 -0
- package/dist/module/web/RNFBFirestoreModule.ios.js +5 -0
- package/dist/module/web/RNFBFirestoreModule.ios.js.map +1 -0
- package/dist/module/web/RNFBFirestoreModule.js +387 -0
- package/dist/module/web/RNFBFirestoreModule.js.map +1 -0
- package/{lib → dist/module}/web/convert.js +60 -94
- package/dist/module/web/convert.js.map +1 -0
- package/dist/module/web/pipelines/pipeline.js +34 -0
- package/dist/module/web/pipelines/pipeline.js.map +1 -0
- package/dist/module/web/pipelines/pipeline_bridge_factory.js +217 -0
- package/dist/module/web/pipelines/pipeline_bridge_factory.js.map +1 -0
- package/dist/module/web/pipelines/pipeline_node_builder.js +294 -0
- package/dist/module/web/pipelines/pipeline_node_builder.js.map +1 -0
- package/dist/module/web/pipelines/pipeline_parser.js +21 -0
- package/dist/module/web/pipelines/pipeline_parser.js.map +1 -0
- package/dist/module/web/pipelines/pipeline_snapshot_serializer.js +89 -0
- package/dist/module/web/pipelines/pipeline_snapshot_serializer.js.map +1 -0
- package/dist/module/web/query.js +95 -0
- package/dist/module/web/query.js.map +1 -0
- package/dist/typescript/lib/FieldPath.d.ts +10 -0
- package/dist/typescript/lib/FieldPath.d.ts.map +1 -0
- package/dist/typescript/lib/FieldValue.d.ts +17 -0
- package/dist/typescript/lib/FieldValue.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreAggregate.d.ts +40 -0
- package/dist/typescript/lib/FirestoreAggregate.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreBlob.d.ts +11 -0
- package/dist/typescript/lib/FirestoreBlob.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreCollectionReference.d.ts +15 -0
- package/dist/typescript/lib/FirestoreCollectionReference.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreDocumentChange.d.ts +27 -0
- package/dist/typescript/lib/FirestoreDocumentChange.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreDocumentReference.d.ts +30 -0
- package/dist/typescript/lib/FirestoreDocumentReference.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreDocumentSnapshot.d.ts +30 -0
- package/dist/typescript/lib/FirestoreDocumentSnapshot.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreFilter.d.ts +52 -0
- package/dist/typescript/lib/FirestoreFilter.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreGeoPoint.d.ts +22 -0
- package/dist/typescript/lib/FirestoreGeoPoint.d.ts.map +1 -0
- package/dist/typescript/lib/FirestorePath.d.ts +12 -0
- package/dist/typescript/lib/FirestorePath.d.ts.map +1 -0
- package/dist/typescript/lib/FirestorePersistentCacheIndexManager.d.ts +16 -0
- package/dist/typescript/lib/FirestorePersistentCacheIndexManager.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreQuery.d.ts +39 -0
- package/dist/typescript/lib/FirestoreQuery.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreQueryModifiers.d.ts +59 -0
- package/dist/typescript/lib/FirestoreQueryModifiers.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreQuerySnapshot.d.ts +49 -0
- package/dist/typescript/lib/FirestoreQuerySnapshot.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreSnapshotMetadata.d.ts +8 -0
- package/dist/typescript/lib/FirestoreSnapshotMetadata.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreStatics.d.ts +23 -0
- package/dist/typescript/lib/FirestoreStatics.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreTimestamp.d.ts +33 -0
- package/dist/typescript/lib/FirestoreTimestamp.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreTransaction.d.ts +42 -0
- package/dist/typescript/lib/FirestoreTransaction.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreTransactionHandler.d.ts +26 -0
- package/dist/typescript/lib/FirestoreTransactionHandler.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreVectorValue.d.ts +17 -0
- package/dist/typescript/lib/FirestoreVectorValue.d.ts.map +1 -0
- package/dist/typescript/lib/FirestoreWriteBatch.d.ts +21 -0
- package/dist/typescript/lib/FirestoreWriteBatch.d.ts.map +1 -0
- package/dist/typescript/lib/LoadBundleTask.d.ts +16 -0
- package/dist/typescript/lib/LoadBundleTask.d.ts.map +1 -0
- package/dist/typescript/lib/index.d.ts +6 -0
- package/dist/typescript/lib/index.d.ts.map +1 -0
- package/dist/typescript/lib/modular/Bytes.d.ts +22 -0
- package/dist/typescript/lib/modular/Bytes.d.ts.map +1 -0
- package/dist/typescript/lib/modular/FieldPath.d.ts +4 -0
- package/dist/typescript/lib/modular/FieldPath.d.ts.map +1 -0
- package/dist/typescript/lib/modular/FieldValue.d.ts +8 -0
- package/dist/typescript/lib/modular/FieldValue.d.ts.map +1 -0
- package/dist/typescript/lib/modular/GeoPoint.d.ts +3 -0
- package/dist/typescript/lib/modular/GeoPoint.d.ts.map +1 -0
- package/dist/typescript/lib/modular/Timestamp.d.ts +3 -0
- package/dist/typescript/lib/modular/Timestamp.d.ts.map +1 -0
- package/dist/typescript/lib/modular/VectorValue.d.ts +4 -0
- package/dist/typescript/lib/modular/VectorValue.d.ts.map +1 -0
- package/dist/typescript/lib/modular/query.d.ts +93 -0
- package/dist/typescript/lib/modular/query.d.ts.map +1 -0
- package/dist/typescript/lib/modular/snapshot.d.ts +30 -0
- package/dist/typescript/lib/modular/snapshot.d.ts.map +1 -0
- package/dist/typescript/lib/modular.d.ts +69 -0
- package/dist/typescript/lib/modular.d.ts.map +1 -0
- package/dist/typescript/lib/namespaced.d.ts +13 -0
- package/dist/typescript/lib/namespaced.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/expressions.d.ts +723 -0
- package/dist/typescript/lib/pipelines/expressions.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/index.d.ts +31 -0
- package/dist/typescript/lib/pipelines/index.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/pipeline-result.d.ts +30 -0
- package/dist/typescript/lib/pipelines/pipeline-result.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/pipeline-source.d.ts +64 -0
- package/dist/typescript/lib/pipelines/pipeline-source.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/pipeline.d.ts +61 -0
- package/dist/typescript/lib/pipelines/pipeline.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/pipeline_impl.d.ts +21 -0
- package/dist/typescript/lib/pipelines/pipeline_impl.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/pipeline_options.d.ts +17 -0
- package/dist/typescript/lib/pipelines/pipeline_options.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/pipeline_runtime.d.ts +10 -0
- package/dist/typescript/lib/pipelines/pipeline_runtime.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/pipeline_support.d.ts +7 -0
- package/dist/typescript/lib/pipelines/pipeline_support.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/pipeline_validate.d.ts +9 -0
- package/dist/typescript/lib/pipelines/pipeline_validate.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/stage_options.d.ts +326 -0
- package/dist/typescript/lib/pipelines/stage_options.d.ts.map +1 -0
- package/dist/typescript/lib/pipelines/types.d.ts +10 -0
- package/dist/typescript/lib/pipelines/types.d.ts.map +1 -0
- package/dist/typescript/lib/types/firestore.d.ts +263 -0
- package/dist/typescript/lib/types/firestore.d.ts.map +1 -0
- package/dist/typescript/lib/types/internal.d.ts +483 -0
- package/dist/typescript/lib/types/internal.d.ts.map +1 -0
- package/dist/typescript/lib/types/namespaced.d.ts +2285 -0
- package/dist/typescript/lib/types/namespaced.d.ts.map +1 -0
- package/dist/typescript/lib/utils/index.d.ts +15 -0
- package/dist/typescript/lib/utils/index.d.ts.map +1 -0
- package/dist/typescript/lib/utils/serialize.d.ts +17 -0
- package/dist/typescript/lib/utils/serialize.d.ts.map +1 -0
- package/dist/typescript/lib/utils/typemap.d.ts +3 -0
- package/dist/typescript/lib/utils/typemap.d.ts.map +1 -0
- package/dist/typescript/lib/version.d.ts +2 -0
- package/dist/typescript/lib/version.d.ts.map +1 -0
- package/dist/typescript/lib/web/RNFBFirestoreModule.android.d.ts +3 -0
- package/dist/typescript/lib/web/RNFBFirestoreModule.android.d.ts.map +1 -0
- package/dist/typescript/lib/web/RNFBFirestoreModule.d.ts +75 -0
- package/dist/typescript/lib/web/RNFBFirestoreModule.d.ts.map +1 -0
- package/dist/typescript/lib/web/RNFBFirestoreModule.ios.d.ts +3 -0
- package/dist/typescript/lib/web/RNFBFirestoreModule.ios.d.ts.map +1 -0
- package/dist/typescript/lib/web/convert.d.ts +14 -0
- package/dist/typescript/lib/web/convert.d.ts.map +1 -0
- package/dist/typescript/lib/web/pipelines/pipeline.d.ts +4 -0
- package/dist/typescript/lib/web/pipelines/pipeline.d.ts.map +1 -0
- package/dist/typescript/lib/web/pipelines/pipeline_bridge_factory.d.ts +5 -0
- package/dist/typescript/lib/web/pipelines/pipeline_bridge_factory.d.ts.map +1 -0
- package/dist/typescript/lib/web/pipelines/pipeline_node_builder.d.ts +5 -0
- package/dist/typescript/lib/web/pipelines/pipeline_node_builder.d.ts.map +1 -0
- package/dist/typescript/lib/web/pipelines/pipeline_parser.d.ts +3 -0
- package/dist/typescript/lib/web/pipelines/pipeline_parser.d.ts.map +1 -0
- package/dist/typescript/lib/web/pipelines/pipeline_snapshot_serializer.d.ts +4 -0
- package/dist/typescript/lib/web/pipelines/pipeline_snapshot_serializer.d.ts.map +1 -0
- package/dist/typescript/lib/web/query.d.ts +23 -0
- package/dist/typescript/lib/web/query.d.ts.map +1 -0
- package/dist/typescript/package.json +1 -0
- package/ios/RNFBFirestore/RNFBFirestoreCollectionModule.m +52 -2
- package/ios/RNFBFirestore/RNFBFirestorePipelineBridgeFactory.swift +384 -0
- package/ios/RNFBFirestore/RNFBFirestorePipelineCallHandler.swift +86 -0
- package/ios/RNFBFirestore/RNFBFirestorePipelineNodeBuilder.swift +1500 -0
- package/ios/RNFBFirestore/RNFBFirestorePipelineParser.swift +1352 -0
- package/ios/RNFBFirestore/RNFBFirestorePipelineSnapshotSerializer.swift +98 -0
- package/lib/{FirestoreFieldPath.js → FieldPath.ts} +10 -12
- package/lib/{FirestoreFieldValue.js → FieldValue.ts} +22 -19
- package/lib/FirestoreAggregate.ts +124 -0
- package/lib/FirestoreBlob.ts +73 -0
- package/lib/FirestoreCollectionReference.ts +99 -0
- package/lib/FirestoreDocumentChange.ts +71 -0
- package/lib/FirestoreDocumentReference.ts +310 -0
- package/lib/FirestoreDocumentSnapshot.ts +149 -0
- package/lib/FirestoreFilter.ts +232 -0
- package/lib/{FirestoreGeoPoint.js → FirestoreGeoPoint.ts} +48 -8
- package/lib/FirestorePath.ts +54 -0
- package/lib/FirestorePersistentCacheIndexManager.ts +46 -0
- package/lib/{FirestoreQuery.js → FirestoreQuery.ts} +208 -100
- package/lib/FirestoreQueryModifiers.ts +411 -0
- package/lib/{FirestoreQuerySnapshot.js → FirestoreQuerySnapshot.ts} +61 -32
- package/lib/{FirestoreSnapshotMetadata.js → FirestoreSnapshotMetadata.ts} +8 -6
- package/lib/{FirestoreStatics.js → FirestoreStatics.ts} +18 -11
- package/lib/FirestoreTimestamp.ts +161 -0
- package/lib/{FirestoreTransaction.js → FirestoreTransaction.ts} +64 -27
- package/lib/{FirestoreTransactionHandler.js → FirestoreTransactionHandler.ts} +54 -75
- package/lib/{FirestoreVectorValue.js → FirestoreVectorValue.ts} +36 -15
- package/lib/{FirestoreWriteBatch.js → FirestoreWriteBatch.ts} +45 -21
- package/lib/LoadBundleTask.ts +85 -0
- package/lib/index.ts +71 -0
- package/lib/modular/Bytes.ts +81 -0
- package/lib/modular/FieldPath.ts +24 -0
- package/lib/modular/FieldValue.ts +40 -0
- package/lib/modular/GeoPoint.ts +20 -0
- package/lib/modular/Timestamp.ts +20 -0
- package/lib/modular/VectorValue.ts +24 -0
- package/lib/modular/query.ts +368 -0
- package/lib/modular/snapshot.ts +137 -0
- package/lib/modular.ts +552 -0
- package/lib/{index.js → namespaced.ts} +170 -80
- package/lib/pipelines/expressions.ts +2321 -0
- package/lib/pipelines/index.ts +203 -0
- package/lib/pipelines/pipeline-result.ts +78 -0
- package/lib/pipelines/pipeline-source.ts +83 -0
- package/lib/pipelines/pipeline.ts +99 -0
- package/lib/pipelines/pipeline_impl.ts +46 -0
- package/lib/pipelines/pipeline_options.ts +32 -0
- package/lib/pipelines/pipeline_runtime.ts +863 -0
- package/lib/pipelines/pipeline_support.ts +134 -0
- package/lib/pipelines/pipeline_validate.ts +242 -0
- package/lib/pipelines/stage_options.ts +376 -0
- package/lib/pipelines/types.ts +26 -0
- package/lib/types/firestore.ts +477 -0
- package/lib/types/internal.ts +747 -0
- package/lib/{index.d.ts → types/namespaced.ts} +280 -79
- package/lib/utils/index.ts +244 -0
- package/lib/utils/serialize.ts +314 -0
- package/lib/utils/typemap.ts +65 -0
- package/lib/version.ts +2 -0
- package/lib/web/{RNFBFirestoreModule.js → RNFBFirestoreModule.ts} +222 -234
- package/lib/web/convert.ts +287 -0
- package/lib/web/pipelines/pipeline.ts +47 -0
- package/lib/web/pipelines/pipeline_bridge_factory.ts +377 -0
- package/lib/web/pipelines/pipeline_node_builder.ts +413 -0
- package/lib/web/pipelines/pipeline_parser.ts +23 -0
- package/lib/web/pipelines/pipeline_snapshot_serializer.ts +133 -0
- package/lib/web/query.ts +150 -0
- package/package.json +46 -7
- package/tsconfig.json +35 -0
- package/lib/FirestoreBlob.js +0 -107
- package/lib/FirestoreCollectionReference.js +0 -70
- package/lib/FirestoreDocumentReference.js +0 -222
- package/lib/FirestoreDocumentSnapshot.js +0 -132
- package/lib/FirestoreFilter.js +0 -156
- package/lib/modular/Bytes.d.ts +0 -11
- package/lib/modular/Bytes.js +0 -62
- package/lib/modular/FieldPath.d.ts +0 -20
- package/lib/modular/FieldPath.js +0 -7
- package/lib/modular/FieldValue.d.ts +0 -67
- package/lib/modular/FieldValue.js +0 -41
- package/lib/modular/GeoPoint.d.ts +0 -17
- package/lib/modular/GeoPoint.js +0 -3
- package/lib/modular/Timestamp.d.ts +0 -85
- package/lib/modular/Timestamp.js +0 -3
- package/lib/modular/VectorValue.d.ts +0 -30
- package/lib/modular/VectorValue.js +0 -11
- package/lib/modular/index.d.ts +0 -788
- package/lib/modular/index.js +0 -410
- package/lib/modular/query.d.ts +0 -370
- package/lib/modular/query.js +0 -233
- package/lib/modular/snapshot.d.ts +0 -256
- package/lib/modular/snapshot.js +0 -33
- package/lib/modular/utils/observer.js +0 -16
- package/lib/version.js +0 -2
- package/lib/web/query.js +0 -112
- /package/lib/web/{RNFBFirestoreModule.android.js → RNFBFirestoreModule.android.ts} +0 -0
- /package/lib/web/{RNFBFirestoreModule.ios.js → RNFBFirestoreModule.ios.ts} +0 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { isNumber } from '@react-native-firebase/app/dist/module/common';
|
|
19
|
+
import FieldPath, { DOCUMENT_ID } from './FieldPath';
|
|
20
|
+
import type {
|
|
21
|
+
DocumentFieldValueInternal,
|
|
22
|
+
FirestoreCursorFieldsInternal,
|
|
23
|
+
FirestoreFilterSpecInternal,
|
|
24
|
+
FirestoreOrderSpecInternal,
|
|
25
|
+
FirestoreQueryOptionsInternal,
|
|
26
|
+
} from './types/internal';
|
|
27
|
+
import { buildNativeArray, generateNativeData } from './utils/serialize';
|
|
28
|
+
|
|
29
|
+
export const OPERATORS: Record<string, string> = {
|
|
30
|
+
'==': 'EQUAL',
|
|
31
|
+
'>': 'GREATER_THAN',
|
|
32
|
+
'>=': 'GREATER_THAN_OR_EQUAL',
|
|
33
|
+
'<': 'LESS_THAN',
|
|
34
|
+
'<=': 'LESS_THAN_OR_EQUAL',
|
|
35
|
+
'!=': 'NOT_EQUAL',
|
|
36
|
+
'array-contains': 'ARRAY_CONTAINS',
|
|
37
|
+
'array-contains-any': 'ARRAY_CONTAINS_ANY',
|
|
38
|
+
'not-in': 'NOT_IN',
|
|
39
|
+
in: 'IN',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const INEQUALITY: Record<string, boolean> = {
|
|
43
|
+
LESS_THAN: true,
|
|
44
|
+
LESS_THAN_OR_EQUAL: true,
|
|
45
|
+
GREATER_THAN: true,
|
|
46
|
+
GREATER_THAN_OR_EQUAL: true,
|
|
47
|
+
NOT_EQUAL: true,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const DIRECTIONS: Record<string, string> = {
|
|
51
|
+
asc: 'ASCENDING',
|
|
52
|
+
desc: 'DESCENDING',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export interface FilterDef {
|
|
56
|
+
fieldPath?: FieldPath | string[];
|
|
57
|
+
operator: string;
|
|
58
|
+
value?: DocumentFieldValueInternal;
|
|
59
|
+
queries?: FilterDef[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface OrderDef {
|
|
63
|
+
fieldPath: FieldPath;
|
|
64
|
+
direction: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default class QueryModifiers {
|
|
68
|
+
_limit: number | undefined;
|
|
69
|
+
_limitToLast: number | undefined;
|
|
70
|
+
_filters: FilterDef[];
|
|
71
|
+
_orders: OrderDef[];
|
|
72
|
+
_type: 'collection' | 'collectionGroup';
|
|
73
|
+
_startAt: FirestoreCursorFieldsInternal | undefined;
|
|
74
|
+
_startAfter: FirestoreCursorFieldsInternal | undefined;
|
|
75
|
+
_endAt: FirestoreCursorFieldsInternal | undefined;
|
|
76
|
+
_endBefore: FirestoreCursorFieldsInternal | undefined;
|
|
77
|
+
|
|
78
|
+
hasInequality: false | FilterDef;
|
|
79
|
+
hasNotEqual: boolean;
|
|
80
|
+
hasArrayContains: boolean;
|
|
81
|
+
hasArrayContainsAny: boolean;
|
|
82
|
+
hasIn: boolean;
|
|
83
|
+
hasNotIn: boolean;
|
|
84
|
+
|
|
85
|
+
constructor() {
|
|
86
|
+
this._limit = undefined;
|
|
87
|
+
this._limitToLast = undefined;
|
|
88
|
+
this._filters = [];
|
|
89
|
+
this._orders = [];
|
|
90
|
+
this._type = 'collection';
|
|
91
|
+
this._startAt = undefined;
|
|
92
|
+
this._startAfter = undefined;
|
|
93
|
+
this._endAt = undefined;
|
|
94
|
+
this._endBefore = undefined;
|
|
95
|
+
|
|
96
|
+
this.hasInequality = false;
|
|
97
|
+
this.hasNotEqual = false;
|
|
98
|
+
this.hasArrayContains = false;
|
|
99
|
+
this.hasArrayContainsAny = false;
|
|
100
|
+
this.hasIn = false;
|
|
101
|
+
this.hasNotIn = false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
_copy(): QueryModifiers {
|
|
105
|
+
const newInstance = new QueryModifiers();
|
|
106
|
+
newInstance._limit = this._limit;
|
|
107
|
+
newInstance._limitToLast = this._limitToLast;
|
|
108
|
+
newInstance._filters = [...this._filters];
|
|
109
|
+
newInstance._orders = [...this._orders];
|
|
110
|
+
newInstance._type = this._type;
|
|
111
|
+
newInstance._startAt = this._startAt;
|
|
112
|
+
newInstance._startAfter = this._startAfter;
|
|
113
|
+
newInstance._endAt = this._endAt;
|
|
114
|
+
newInstance._endBefore = this._endBefore;
|
|
115
|
+
return newInstance;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get filters(): FirestoreFilterSpecInternal[] {
|
|
119
|
+
return this._filters.map(f => ({
|
|
120
|
+
...f,
|
|
121
|
+
fieldPath: f.fieldPath instanceof FieldPath ? f.fieldPath._toArray() : f.fieldPath,
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
get orders(): FirestoreOrderSpecInternal[] {
|
|
126
|
+
return this._orders.map(f => ({
|
|
127
|
+
...f,
|
|
128
|
+
fieldPath: f.fieldPath instanceof FieldPath ? f.fieldPath._toArray() : f.fieldPath,
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get options(): FirestoreQueryOptionsInternal {
|
|
133
|
+
const options: FirestoreQueryOptionsInternal = {};
|
|
134
|
+
|
|
135
|
+
if (this._limit) {
|
|
136
|
+
options.limit = this._limit;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this._limitToLast) {
|
|
140
|
+
options.limitToLast = this._limitToLast;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (this._startAt) {
|
|
144
|
+
options.startAt = this._startAt;
|
|
145
|
+
}
|
|
146
|
+
if (this._startAfter) {
|
|
147
|
+
options.startAfter = this._startAfter;
|
|
148
|
+
}
|
|
149
|
+
if (this._endAt) {
|
|
150
|
+
options.endAt = this._endAt;
|
|
151
|
+
}
|
|
152
|
+
if (this._endBefore) {
|
|
153
|
+
options.endBefore = this._endBefore;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return options;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
get type(): string {
|
|
160
|
+
return this._type;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setFieldsCursor(
|
|
164
|
+
cursor: 'startAt' | 'startAfter' | 'endAt' | 'endBefore',
|
|
165
|
+
fields: FirestoreCursorFieldsInternal,
|
|
166
|
+
): this {
|
|
167
|
+
(this as unknown as Record<string, FirestoreCursorFieldsInternal | undefined>)[`_${cursor}`] =
|
|
168
|
+
buildNativeArray(fields);
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
hasStart(): boolean {
|
|
173
|
+
return !!(this._startAt || this._startAfter);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
hasEnd(): boolean {
|
|
177
|
+
return !!(this._endAt || this._endBefore);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
asCollectionGroupQuery(): this {
|
|
181
|
+
this._type = 'collectionGroup';
|
|
182
|
+
return this;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
isCollectionGroupQuery(): boolean {
|
|
186
|
+
return this._type === 'collectionGroup';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
isValidLimit(limit: unknown): boolean {
|
|
190
|
+
return !isNumber(limit) || Math.floor(limit as number) !== limit || (limit as number) <= 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
limit(limit: number): this {
|
|
194
|
+
this._limitToLast = undefined;
|
|
195
|
+
this._limit = limit;
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
isValidLimitToLast(limit: unknown): boolean {
|
|
200
|
+
return !isNumber(limit) || Math.floor(limit as number) !== limit || (limit as number) <= 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
validatelimitToLast(): void {
|
|
204
|
+
if (this._limitToLast) {
|
|
205
|
+
if (!this._orders.length) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
'firebase.firestore().collection().limitToLast() queries require specifying at least one firebase.firestore().collection().orderBy() clause',
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
limitToLast(limitToLast: number): this {
|
|
214
|
+
this._limit = undefined;
|
|
215
|
+
this._limitToLast = limitToLast;
|
|
216
|
+
return this;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
isValidOperator(operator: string): boolean {
|
|
220
|
+
return !!OPERATORS[operator];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
isEqualOperator(operator: string): boolean {
|
|
224
|
+
return OPERATORS[operator] === 'EQUAL';
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
isNotEqualOperator(operator: string): boolean {
|
|
228
|
+
return OPERATORS[operator] === 'NOT_EQUAL';
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
isInOperator(operator: string): boolean {
|
|
232
|
+
return (
|
|
233
|
+
OPERATORS[operator] === 'IN' ||
|
|
234
|
+
OPERATORS[operator] === 'ARRAY_CONTAINS_ANY' ||
|
|
235
|
+
OPERATORS[operator] === 'NOT_IN'
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
where(fieldPath: FieldPath, opStr: string, value: DocumentFieldValueInternal): this {
|
|
240
|
+
const filter: FilterDef = {
|
|
241
|
+
fieldPath,
|
|
242
|
+
operator: OPERATORS[opStr] ?? opStr,
|
|
243
|
+
value: generateNativeData(value, true),
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
this._filters = this._filters.concat(filter);
|
|
247
|
+
return this;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
filterWhere(filter: FilterDef): this {
|
|
251
|
+
this._filters = this._filters.concat(filter);
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
validateWhere(): void {
|
|
256
|
+
if (this._filters.length > 0) {
|
|
257
|
+
this._filterCheck(this._filters);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
_filterCheck(filters: FilterDef[]): void {
|
|
262
|
+
for (let i = 0; i < filters.length; i++) {
|
|
263
|
+
const filter = filters[i]!;
|
|
264
|
+
|
|
265
|
+
if (filter.queries) {
|
|
266
|
+
this._filterCheck(filter.queries as FilterDef[]);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (!INEQUALITY[filter.operator]) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (filter.operator === OPERATORS['!=']) {
|
|
275
|
+
if (this.hasNotEqual) {
|
|
276
|
+
throw new Error("Invalid query. You cannot use more than one '!=' inequality filter.");
|
|
277
|
+
}
|
|
278
|
+
this.hasNotEqual = true;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (!this.hasInequality) {
|
|
282
|
+
this.hasInequality = filter;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
for (let i = 0; i < filters.length; i++) {
|
|
288
|
+
const filter = filters[i]!;
|
|
289
|
+
|
|
290
|
+
if (filter.operator === OPERATORS['array-contains']) {
|
|
291
|
+
if (this.hasArrayContains) {
|
|
292
|
+
throw new Error('Invalid query. Queries only support a single array-contains filter.');
|
|
293
|
+
}
|
|
294
|
+
this.hasArrayContains = true;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (filter.operator === OPERATORS['array-contains-any']) {
|
|
298
|
+
if (this.hasArrayContainsAny) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
"Invalid query. You cannot use more than one 'array-contains-any' filter.",
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (this.hasNotIn) {
|
|
305
|
+
throw new Error(
|
|
306
|
+
"Invalid query. You cannot use 'array-contains-any' filters with 'not-in' filters.",
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
this.hasArrayContainsAny = true;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (filter.operator === OPERATORS.in) {
|
|
314
|
+
if (this.hasNotIn) {
|
|
315
|
+
throw new Error("Invalid query. You cannot use 'in' filters with 'not-in' filters.");
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
this.hasIn = true;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (filter.operator === OPERATORS['not-in']) {
|
|
322
|
+
if (this.hasNotIn) {
|
|
323
|
+
throw new Error("Invalid query. You cannot use more than one 'not-in' filter.");
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (this.hasNotEqual) {
|
|
327
|
+
throw new Error(
|
|
328
|
+
"Invalid query. You cannot use 'not-in' filters with '!=' inequality filters",
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (this.hasIn) {
|
|
333
|
+
throw new Error("Invalid query. You cannot use 'not-in' filters with 'in' filters.");
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (this.hasArrayContainsAny) {
|
|
337
|
+
throw new Error(
|
|
338
|
+
"Invalid query. You cannot use 'not-in' filters with 'array-contains-any' filters.",
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
this.hasNotIn = true;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
isValidDirection(directionStr: string): boolean {
|
|
348
|
+
return !!DIRECTIONS[directionStr.toLowerCase()];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
orderBy(fieldPath: FieldPath, directionStr?: string): this {
|
|
352
|
+
const dir = directionStr ? DIRECTIONS[directionStr.toLowerCase()] : DIRECTIONS.asc;
|
|
353
|
+
const order: OrderDef = {
|
|
354
|
+
fieldPath: fieldPath,
|
|
355
|
+
direction: dir ?? 'ASCENDING',
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
this._orders = this._orders.concat(order);
|
|
359
|
+
return this;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
validateOrderBy(): void {
|
|
363
|
+
this._validateOrderByCheck(this._filters);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
_validateOrderByCheck(filters: FilterDef[]): void {
|
|
367
|
+
if (this._orders.length > 1) {
|
|
368
|
+
const orders = this._orders.map($ => $.fieldPath._toPath());
|
|
369
|
+
const set = new Set(orders);
|
|
370
|
+
|
|
371
|
+
if (set.size !== orders.length) {
|
|
372
|
+
throw new Error('Invalid query. Order by clause cannot contain duplicate fields.');
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (filters.length === 0) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
for (let i = 0; i < filters.length; i++) {
|
|
381
|
+
const filter = filters[i]!;
|
|
382
|
+
|
|
383
|
+
if (filter.queries) {
|
|
384
|
+
this._validateOrderByCheck(filter.queries as FilterDef[]);
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const filterFieldPath = (filter.fieldPath as FieldPath)._toPath();
|
|
388
|
+
|
|
389
|
+
for (let k = 0; k < this._orders.length; k++) {
|
|
390
|
+
const order = this._orders[k]!;
|
|
391
|
+
const orderFieldPath = order.fieldPath;
|
|
392
|
+
if (filter.operator === OPERATORS['==']) {
|
|
393
|
+
if (filterFieldPath === orderFieldPath._toPath()) {
|
|
394
|
+
throw new Error(
|
|
395
|
+
`Invalid query. Query.orderBy() parameter: ${orderFieldPath} cannot be the same as your Query.where() fieldPath parameter: ${filterFieldPath}`,
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (
|
|
401
|
+
filterFieldPath === DOCUMENT_ID._toPath() &&
|
|
402
|
+
orderFieldPath._toPath() !== DOCUMENT_ID._toPath()
|
|
403
|
+
) {
|
|
404
|
+
throw new Error(
|
|
405
|
+
"Invalid query. Query.where() fieldPath parameter: 'FirestoreFieldPath' cannot be used in conjunction with a different Query.orderBy() parameter",
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
@@ -16,49 +16,86 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
|
+
createDeprecationProxy,
|
|
19
20
|
isBoolean,
|
|
20
21
|
isFunction,
|
|
21
22
|
isObject,
|
|
22
23
|
isUndefined,
|
|
23
|
-
createDeprecationProxy,
|
|
24
24
|
} from '@react-native-firebase/app/dist/module/common';
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
25
|
+
import DocumentChange from './FirestoreDocumentChange';
|
|
26
|
+
import DocumentSnapshot from './FirestoreDocumentSnapshot';
|
|
27
|
+
import SnapshotMetadata from './FirestoreSnapshotMetadata';
|
|
28
|
+
|
|
29
|
+
import type Query from './FirestoreQuery';
|
|
30
|
+
import type { DocumentData, FirestoreDataConverter } from './types/firestore';
|
|
31
|
+
import type { FirestoreInternal } from './types/internal';
|
|
32
|
+
|
|
33
|
+
export interface QuerySnapshotNativeData {
|
|
34
|
+
source?: string;
|
|
35
|
+
excludesMetadataChanges?: boolean;
|
|
36
|
+
changes: Array<{
|
|
37
|
+
type: string;
|
|
38
|
+
doc: { path: string; data?: unknown; metadata?: [boolean, boolean]; exists?: boolean };
|
|
39
|
+
ni: number;
|
|
40
|
+
oi: number;
|
|
41
|
+
isMetadataChange?: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
documents: Array<{
|
|
44
|
+
path: string;
|
|
45
|
+
data?: unknown;
|
|
46
|
+
metadata?: [boolean, boolean];
|
|
47
|
+
exists?: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
metadata: [boolean, boolean];
|
|
50
|
+
}
|
|
28
51
|
|
|
29
|
-
export default class
|
|
30
|
-
|
|
52
|
+
export default class QuerySnapshot {
|
|
53
|
+
_query: Query;
|
|
54
|
+
_source: string | undefined;
|
|
55
|
+
_excludesMetadataChanges: boolean | undefined;
|
|
56
|
+
_changes: DocumentChange[];
|
|
57
|
+
_docs: DocumentSnapshot[];
|
|
58
|
+
_metadata: SnapshotMetadata;
|
|
59
|
+
|
|
60
|
+
constructor(
|
|
61
|
+
firestore: FirestoreInternal,
|
|
62
|
+
query: Query,
|
|
63
|
+
nativeData: QuerySnapshotNativeData,
|
|
64
|
+
converter: FirestoreDataConverter<DocumentData, DocumentData> | null,
|
|
65
|
+
) {
|
|
31
66
|
this._query = query;
|
|
32
67
|
this._source = nativeData.source;
|
|
33
68
|
this._excludesMetadataChanges = nativeData.excludesMetadataChanges;
|
|
34
|
-
this._changes = nativeData.changes.map(
|
|
35
|
-
|
|
36
|
-
createDeprecationProxy(new FirestoreDocumentSnapshot(firestore, $)),
|
|
69
|
+
this._changes = nativeData.changes.map(
|
|
70
|
+
(c: QuerySnapshotNativeData['changes'][0]) => new DocumentChange(firestore, c, converter),
|
|
37
71
|
);
|
|
38
|
-
this.
|
|
72
|
+
this._docs = nativeData.documents.map((doc: QuerySnapshotNativeData['documents'][0]) =>
|
|
73
|
+
createDeprecationProxy(new DocumentSnapshot(firestore, doc, converter)),
|
|
74
|
+
) as DocumentSnapshot[];
|
|
75
|
+
this._metadata = new SnapshotMetadata(nativeData.metadata ?? [false, false]);
|
|
39
76
|
}
|
|
40
77
|
|
|
41
|
-
get docs() {
|
|
78
|
+
get docs(): DocumentSnapshot[] {
|
|
42
79
|
return this._docs;
|
|
43
80
|
}
|
|
44
81
|
|
|
45
|
-
get empty() {
|
|
82
|
+
get empty(): boolean {
|
|
46
83
|
return this._docs.length === 0;
|
|
47
84
|
}
|
|
48
85
|
|
|
49
|
-
get metadata() {
|
|
86
|
+
get metadata(): SnapshotMetadata {
|
|
50
87
|
return this._metadata;
|
|
51
88
|
}
|
|
52
89
|
|
|
53
|
-
get query() {
|
|
90
|
+
get query(): Query {
|
|
54
91
|
return this._query;
|
|
55
92
|
}
|
|
56
93
|
|
|
57
|
-
get size() {
|
|
94
|
+
get size(): number {
|
|
58
95
|
return this._docs.length;
|
|
59
96
|
}
|
|
60
97
|
|
|
61
|
-
docChanges(options) {
|
|
98
|
+
docChanges(options?: { includeMetadataChanges?: boolean }): DocumentChange[] {
|
|
62
99
|
if (!isUndefined(options) && !isObject(options)) {
|
|
63
100
|
throw new Error(
|
|
64
101
|
"firebase.firestore() QuerySnapshot.docChanges(*) 'options' expected an object.",
|
|
@@ -74,10 +111,9 @@ export default class FirestoreQuerySnapshot {
|
|
|
74
111
|
);
|
|
75
112
|
}
|
|
76
113
|
|
|
77
|
-
includeMetaDataChanges = options.includeMetadataChanges;
|
|
114
|
+
includeMetaDataChanges = options.includeMetadataChanges ?? false;
|
|
78
115
|
}
|
|
79
116
|
|
|
80
|
-
// A get query should always return the document changes from native
|
|
81
117
|
if (this._source === 'get') {
|
|
82
118
|
return this._changes;
|
|
83
119
|
}
|
|
@@ -89,16 +125,14 @@ export default class FirestoreQuerySnapshot {
|
|
|
89
125
|
}
|
|
90
126
|
|
|
91
127
|
return this._changes.filter($ => {
|
|
92
|
-
// Remove all changes that have come from metadata changes list
|
|
93
128
|
if (!includeMetaDataChanges) {
|
|
94
129
|
return $._isMetadataChange === false;
|
|
95
130
|
}
|
|
96
|
-
|
|
97
131
|
return true;
|
|
98
132
|
});
|
|
99
133
|
}
|
|
100
134
|
|
|
101
|
-
forEach(callback, thisArg) {
|
|
135
|
+
forEach(callback: (doc: DocumentSnapshot, index: number) => void, thisArg?: unknown): void {
|
|
102
136
|
if (!isFunction(callback)) {
|
|
103
137
|
throw new Error(
|
|
104
138
|
"firebase.firestore() QuerySnapshot.forEach(*) 'callback' expected a function.",
|
|
@@ -108,19 +142,17 @@ export default class FirestoreQuerySnapshot {
|
|
|
108
142
|
const cb = thisArg ? callback.bind(thisArg) : callback;
|
|
109
143
|
|
|
110
144
|
for (let i = 0; i < this._docs.length; i++) {
|
|
111
|
-
cb(this._docs[i]
|
|
145
|
+
cb(this._docs[i]!, i);
|
|
112
146
|
}
|
|
113
147
|
}
|
|
114
148
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!(other instanceof FirestoreQuerySnapshot)) {
|
|
149
|
+
isEqual(other: QuerySnapshot, ...args: unknown[]): boolean {
|
|
150
|
+
if (!(other instanceof QuerySnapshot)) {
|
|
118
151
|
throw new Error(
|
|
119
152
|
"firebase.firestore() QuerySnapshot.isEqual(*) 'other' expected a QuerySnapshot instance.",
|
|
120
153
|
);
|
|
121
154
|
}
|
|
122
155
|
|
|
123
|
-
// Simple checks first
|
|
124
156
|
if (
|
|
125
157
|
this.empty !== other.empty ||
|
|
126
158
|
this.size !== other.size ||
|
|
@@ -129,14 +161,11 @@ export default class FirestoreQuerySnapshot {
|
|
|
129
161
|
return false;
|
|
130
162
|
}
|
|
131
163
|
|
|
132
|
-
// Expensive check
|
|
133
|
-
// Each doc must be in order & have the same data
|
|
134
164
|
for (let i = 0; i < this.docs.length; i++) {
|
|
135
|
-
const thisDoc = this.docs[i]
|
|
136
|
-
const otherDoc = other.docs[i]
|
|
165
|
+
const thisDoc = this.docs[i]!;
|
|
166
|
+
const otherDoc = other.docs[i]!;
|
|
137
167
|
|
|
138
|
-
|
|
139
|
-
if (!thisDoc.isEqual(otherDoc, ...args)) {
|
|
168
|
+
if (!(thisDoc.isEqual as (...a: unknown[]) => boolean)(otherDoc, ...args)) {
|
|
140
169
|
return false;
|
|
141
170
|
}
|
|
142
171
|
}
|
|
@@ -17,21 +17,23 @@
|
|
|
17
17
|
|
|
18
18
|
import { isUndefined } from '@react-native-firebase/app/dist/module/common';
|
|
19
19
|
|
|
20
|
-
export default class
|
|
21
|
-
|
|
20
|
+
export default class SnapshotMetadata {
|
|
21
|
+
_metadata: [boolean, boolean];
|
|
22
|
+
|
|
23
|
+
constructor(metadata: [boolean, boolean]) {
|
|
22
24
|
this._metadata = metadata;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
get fromCache() {
|
|
27
|
+
get fromCache(): boolean {
|
|
26
28
|
return this._metadata[0];
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
get hasPendingWrites() {
|
|
31
|
+
get hasPendingWrites(): boolean {
|
|
30
32
|
return this._metadata[1];
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
isEqual(other) {
|
|
34
|
-
if (isUndefined(other) || !(other instanceof
|
|
35
|
+
isEqual(other: SnapshotMetadata): boolean {
|
|
36
|
+
if (isUndefined(other) || !(other instanceof SnapshotMetadata)) {
|
|
35
37
|
throw new Error(
|
|
36
38
|
"firebase.firestore() SnapshotMetadata.isEqual(*) 'other' expected instance of SnapshotMetadata",
|
|
37
39
|
);
|
|
@@ -17,35 +17,42 @@
|
|
|
17
17
|
|
|
18
18
|
import { createDeprecationProxy } from '@react-native-firebase/app/dist/module/common';
|
|
19
19
|
import { getReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
20
|
+
import Blob from './FirestoreBlob';
|
|
21
|
+
import FieldPath from './FieldPath';
|
|
22
|
+
import FieldValue from './FieldValue';
|
|
23
|
+
import { Filter } from './FirestoreFilter';
|
|
23
24
|
import FirestoreGeoPoint from './FirestoreGeoPoint';
|
|
24
25
|
import FirestoreTimestamp from './FirestoreTimestamp';
|
|
25
|
-
import { Filter } from './FirestoreFilter';
|
|
26
26
|
import FirestoreVectorValue from './FirestoreVectorValue';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
import type { LogLevel } from './types/firestore';
|
|
28
|
+
import type { RNFBFirestoreModule } from './types/internal';
|
|
29
|
+
|
|
30
|
+
type FirestoreLogLevel = LogLevel;
|
|
31
|
+
|
|
32
|
+
const FirestoreStatics = {
|
|
33
|
+
Blob: Blob,
|
|
34
|
+
FieldPath: FieldPath,
|
|
35
|
+
FieldValue: createDeprecationProxy(FieldValue),
|
|
31
36
|
GeoPoint: FirestoreGeoPoint,
|
|
32
37
|
Timestamp: createDeprecationProxy(FirestoreTimestamp),
|
|
33
38
|
Filter: createDeprecationProxy(Filter),
|
|
34
39
|
VectorValue: FirestoreVectorValue,
|
|
35
|
-
vector(values) {
|
|
40
|
+
vector(values?: number[]): FirestoreVectorValue {
|
|
36
41
|
return new FirestoreVectorValue(values);
|
|
37
42
|
},
|
|
38
43
|
|
|
39
44
|
CACHE_SIZE_UNLIMITED: -1,
|
|
40
45
|
|
|
41
|
-
setLogLevel(logLevel) {
|
|
46
|
+
setLogLevel(logLevel: FirestoreLogLevel): void {
|
|
42
47
|
if (logLevel !== 'debug' && logLevel !== 'error' && logLevel !== 'silent') {
|
|
43
48
|
throw new Error(
|
|
44
49
|
"firebase.firestore.setLogLevel(*) 'logLevel' expected one of 'debug', 'error' or 'silent'",
|
|
45
50
|
);
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
const native = getReactNativeModule('RNFBFirestoreModule');
|
|
53
|
+
const native = getReactNativeModule('RNFBFirestoreModule') as unknown as RNFBFirestoreModule;
|
|
49
54
|
native.setLogLevel(logLevel);
|
|
50
55
|
},
|
|
51
56
|
};
|
|
57
|
+
|
|
58
|
+
export default FirestoreStatics;
|