@react-native-firebase/firestore 23.8.8 → 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 +27 -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
package/lib/web/query.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
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 {
|
|
19
|
+
FieldPath,
|
|
20
|
+
query,
|
|
21
|
+
where,
|
|
22
|
+
orderBy,
|
|
23
|
+
limit,
|
|
24
|
+
limitToLast,
|
|
25
|
+
startAt,
|
|
26
|
+
startAfter,
|
|
27
|
+
endAt,
|
|
28
|
+
endBefore,
|
|
29
|
+
and,
|
|
30
|
+
or,
|
|
31
|
+
} from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestore';
|
|
32
|
+
import type {
|
|
33
|
+
Firestore,
|
|
34
|
+
Query,
|
|
35
|
+
QueryConstraint,
|
|
36
|
+
} from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestore';
|
|
37
|
+
import { parseTypeMap, readableToArray } from './convert';
|
|
38
|
+
|
|
39
|
+
export interface FilterSpec {
|
|
40
|
+
fieldPath?: string[] | { _segments: string[] };
|
|
41
|
+
operator?: string;
|
|
42
|
+
value?: unknown;
|
|
43
|
+
queries?: FilterSpec[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface OrderSpec {
|
|
47
|
+
fieldPath: string[] | string;
|
|
48
|
+
direction: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface QueryOptions {
|
|
52
|
+
limit?: number;
|
|
53
|
+
limitToLast?: number;
|
|
54
|
+
startAt?: unknown[];
|
|
55
|
+
startAfter?: unknown[];
|
|
56
|
+
endAt?: unknown[];
|
|
57
|
+
endBefore?: unknown[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function buildQuery(
|
|
61
|
+
queryInstance: Query,
|
|
62
|
+
filters: FilterSpec[],
|
|
63
|
+
orders: OrderSpec[],
|
|
64
|
+
options: QueryOptions,
|
|
65
|
+
): Query {
|
|
66
|
+
let current: Query = queryInstance;
|
|
67
|
+
|
|
68
|
+
for (const filter of filters) {
|
|
69
|
+
current = query(current, getFilterConstraint(filter, queryInstance.firestore));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const order of orders) {
|
|
73
|
+
const fieldPath =
|
|
74
|
+
typeof order.fieldPath === 'string'
|
|
75
|
+
? order.fieldPath
|
|
76
|
+
: new FieldPath(...(order.fieldPath as string[]));
|
|
77
|
+
const direction = order.direction === 'ASCENDING' ? 'asc' : 'desc';
|
|
78
|
+
current = query(current, orderBy(fieldPath, direction));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if ('limit' in options && options.limit !== undefined) {
|
|
82
|
+
current = query(current, limit(options.limit));
|
|
83
|
+
}
|
|
84
|
+
if ('limitToLast' in options && options.limitToLast !== undefined) {
|
|
85
|
+
current = query(current, limitToLast(options.limitToLast));
|
|
86
|
+
}
|
|
87
|
+
if ('startAt' in options && options.startAt !== undefined) {
|
|
88
|
+
const fieldList = readableToArray(queryInstance.firestore, options.startAt as unknown[]);
|
|
89
|
+
current = query(current, startAt(...fieldList));
|
|
90
|
+
}
|
|
91
|
+
if ('startAfter' in options && options.startAfter !== undefined) {
|
|
92
|
+
const fieldList = readableToArray(queryInstance.firestore, options.startAfter as unknown[]);
|
|
93
|
+
current = query(current, startAfter(...fieldList));
|
|
94
|
+
}
|
|
95
|
+
if ('endAt' in options && options.endAt !== undefined) {
|
|
96
|
+
const fieldList = readableToArray(queryInstance.firestore, options.endAt as unknown[]);
|
|
97
|
+
current = query(current, endAt(...fieldList));
|
|
98
|
+
}
|
|
99
|
+
if ('endBefore' in options && options.endBefore !== undefined) {
|
|
100
|
+
const fieldList = readableToArray(queryInstance.firestore, options.endBefore as unknown[]);
|
|
101
|
+
current = query(current, endBefore(...fieldList));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return current;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function getFilterConstraint(filter: FilterSpec, firestore: Firestore): QueryConstraint {
|
|
108
|
+
if ('fieldPath' in filter && filter.fieldPath) {
|
|
109
|
+
const fieldPath = Array.isArray(filter.fieldPath)
|
|
110
|
+
? new FieldPath(...filter.fieldPath)
|
|
111
|
+
: new FieldPath(...(filter.fieldPath as { _segments: string[] })._segments);
|
|
112
|
+
const operator = filter.operator;
|
|
113
|
+
const value = parseTypeMap(firestore, filter.value as [number, unknown?]);
|
|
114
|
+
|
|
115
|
+
switch (operator) {
|
|
116
|
+
case 'EQUAL':
|
|
117
|
+
return where(fieldPath, '==', value);
|
|
118
|
+
case 'NOT_EQUAL':
|
|
119
|
+
return where(fieldPath, '!=', value);
|
|
120
|
+
case 'GREATER_THAN':
|
|
121
|
+
return where(fieldPath, '>', value);
|
|
122
|
+
case 'GREATER_THAN_OR_EQUAL':
|
|
123
|
+
return where(fieldPath, '>=', value);
|
|
124
|
+
case 'LESS_THAN':
|
|
125
|
+
return where(fieldPath, '<', value);
|
|
126
|
+
case 'LESS_THAN_OR_EQUAL':
|
|
127
|
+
return where(fieldPath, '<=', value);
|
|
128
|
+
case 'ARRAY_CONTAINS':
|
|
129
|
+
return where(fieldPath, 'array-contains', value);
|
|
130
|
+
case 'ARRAY_CONTAINS_ANY':
|
|
131
|
+
return where(fieldPath, 'array-contains-any', value);
|
|
132
|
+
case 'IN':
|
|
133
|
+
return where(fieldPath, 'in', value);
|
|
134
|
+
case 'NOT_IN':
|
|
135
|
+
return where(fieldPath, 'not-in', value);
|
|
136
|
+
}
|
|
137
|
+
} else if ('operator' in filter && 'queries' in filter && filter.queries) {
|
|
138
|
+
const constraints = filter.queries.map(f => getFilterConstraint(f, firestore));
|
|
139
|
+
|
|
140
|
+
if (filter.operator === 'AND') {
|
|
141
|
+
return and(...(constraints as Parameters<typeof and>)) as unknown as QueryConstraint;
|
|
142
|
+
}
|
|
143
|
+
if (filter.operator === 'OR') {
|
|
144
|
+
return or(...(constraints as Parameters<typeof or>)) as unknown as QueryConstraint;
|
|
145
|
+
}
|
|
146
|
+
throw new Error('Invalid filter operator');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
throw new Error('Invalid filter.');
|
|
150
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/firestore",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0",
|
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
|
5
5
|
"description": "React Native Firebase - Cloud Firestore is a NoSQL cloud database to store and sync data between your React Native application and Firebase's database. The API matches the Firebase Web SDK whilst taking advantage of the native SDKs performance and offline capabilities.",
|
|
6
|
-
"main": "
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
6
|
+
"main": "./dist/module/index.js",
|
|
7
|
+
"types": "./dist/typescript/lib/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "genversion --semi lib/version.
|
|
9
|
+
"build": "genversion --esm --semi lib/version.ts",
|
|
10
10
|
"build:clean": "rimraf android/build && rimraf ios/build",
|
|
11
|
-
"
|
|
11
|
+
"compile": "bob build",
|
|
12
|
+
"prepare": "yarn run build && yarn compile"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
|
@@ -30,11 +31,49 @@
|
|
|
30
31
|
"react-native-url-polyfill": "3.0.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
|
-
"@react-native-firebase/app": "
|
|
34
|
+
"@react-native-firebase/app": "24.0.0"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public",
|
|
37
38
|
"provenance": true
|
|
38
39
|
},
|
|
39
|
-
"
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"react-native-builder-bob": "^0.40.13"
|
|
42
|
+
},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"source": "./lib/index.ts",
|
|
46
|
+
"types": "./dist/typescript/lib/index.d.ts",
|
|
47
|
+
"default": "./dist/module/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./pipelines": {
|
|
50
|
+
"source": "./lib/pipelines/index.ts",
|
|
51
|
+
"types": "./dist/typescript/lib/pipelines/index.d.ts",
|
|
52
|
+
"default": "./dist/module/pipelines/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./package.json": "./package.json"
|
|
55
|
+
},
|
|
56
|
+
"react-native-builder-bob": {
|
|
57
|
+
"source": "lib",
|
|
58
|
+
"output": "dist",
|
|
59
|
+
"targets": [
|
|
60
|
+
[
|
|
61
|
+
"module",
|
|
62
|
+
{
|
|
63
|
+
"esm": true
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
"typescript",
|
|
68
|
+
{
|
|
69
|
+
"tsc": "../../node_modules/.bin/tsc"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"eslintIgnore": [
|
|
75
|
+
"node_modules/",
|
|
76
|
+
"dist/"
|
|
77
|
+
],
|
|
78
|
+
"gitHead": "46c48499190be2dc9b9792d39c251db29495a607"
|
|
40
79
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.packages.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"rootDir": ".",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@react-native-firebase/app/dist/module/common/*": [
|
|
8
|
+
"../app/dist/typescript/lib/common/*"
|
|
9
|
+
],
|
|
10
|
+
"@react-native-firebase/app/dist/module/common": [
|
|
11
|
+
"../app/dist/typescript/lib/common"
|
|
12
|
+
],
|
|
13
|
+
"@react-native-firebase/app/dist/module/internal/web/*": [
|
|
14
|
+
"../app/dist/typescript/lib/internal/web/*"
|
|
15
|
+
],
|
|
16
|
+
"@react-native-firebase/app/dist/module/internal/*": [
|
|
17
|
+
"../app/dist/typescript/lib/internal/*"
|
|
18
|
+
],
|
|
19
|
+
"@react-native-firebase/app/dist/module/internal": [
|
|
20
|
+
"../app/dist/typescript/lib/internal"
|
|
21
|
+
],
|
|
22
|
+
"@react-native-firebase/app": [
|
|
23
|
+
"../app/dist/typescript/lib"
|
|
24
|
+
],
|
|
25
|
+
"@react-native-firebase/app/dist/module/types/internal": [
|
|
26
|
+
"../app/dist/typescript/lib/types/internal"
|
|
27
|
+
],
|
|
28
|
+
"@react-native-firebase/app/dist/module/types/common": [
|
|
29
|
+
"../app/dist/typescript/lib/types/common"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"include": ["lib/**/*"],
|
|
34
|
+
"exclude": ["node_modules", "dist", "__tests__", "**/*.test.ts"]
|
|
35
|
+
}
|
package/lib/FirestoreBlob.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
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 { Base64, isString } from '@react-native-firebase/app/dist/module/common';
|
|
19
|
-
|
|
20
|
-
export default class FirestoreBlob {
|
|
21
|
-
constructor(internal = false, binaryString = undefined) {
|
|
22
|
-
if (internal === false) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
'firebase.firestore.Blob constructor is private, use Blob.<field>() instead.',
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
this._binaryString = binaryString;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new Blob from the given Base64 string
|
|
33
|
-
*
|
|
34
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.firestore.Blob#.fromBase64String
|
|
35
|
-
* @param base64 string
|
|
36
|
-
*/
|
|
37
|
-
static fromBase64String(base64) {
|
|
38
|
-
if (!isString(base64) || base64.length < 1) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
'firestore.Blob.fromBase64String expects a string of at least 1 character in length',
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return new FirestoreBlob(true, Base64.atob(base64));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Creates a new Blob from the given Uint8Array.
|
|
49
|
-
*
|
|
50
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.firestore.Blob#.fromUint8Array
|
|
51
|
-
* @param array Array
|
|
52
|
-
*/
|
|
53
|
-
static fromUint8Array(array) {
|
|
54
|
-
if (!(array instanceof Uint8Array)) {
|
|
55
|
-
throw new Error('firestore.Blob.fromUint8Array expects an instance of Uint8Array');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return new FirestoreBlob(
|
|
59
|
-
true,
|
|
60
|
-
Array.prototype.map.call(array, $ => String.fromCharCode($)).join(''),
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Returns 'true' if this Blob is equal to the provided one.
|
|
66
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.firestore.Blob#isEqual
|
|
67
|
-
* @param {*} blob Blob The Blob to compare against. Value must not be null.
|
|
68
|
-
* @returns boolean 'true' if this Blob is equal to the provided one.
|
|
69
|
-
*/
|
|
70
|
-
isEqual(blob) {
|
|
71
|
-
if (!(blob instanceof FirestoreBlob)) {
|
|
72
|
-
throw new Error('firestore.Blob.isEqual expects an instance of Blob');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return this._binaryString === blob._binaryString;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Returns the bytes of a Blob as a Base64-encoded string.
|
|
80
|
-
*
|
|
81
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.firestore.Blob#toBase64
|
|
82
|
-
* @returns string The Base64-encoded string created from the Blob object.
|
|
83
|
-
*/
|
|
84
|
-
toBase64() {
|
|
85
|
-
return Base64.btoa(this._binaryString);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Returns the bytes of a Blob in a new Uint8Array.
|
|
90
|
-
*
|
|
91
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.firestore.Blob#toUint8Array
|
|
92
|
-
* @returns non-null Uint8Array The Uint8Array created from the Blob object.
|
|
93
|
-
*/
|
|
94
|
-
toUint8Array() {
|
|
95
|
-
return new Uint8Array(this._binaryString.split('').map(c => c.charCodeAt(0)));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Returns a string representation of this blob instance
|
|
100
|
-
*
|
|
101
|
-
* @returns {string}
|
|
102
|
-
* @memberof Blob
|
|
103
|
-
*/
|
|
104
|
-
toString() {
|
|
105
|
-
return `firestore.Blob(base64: ${this.toBase64()})`;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
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 { generateFirestoreId, isObject } from '@react-native-firebase/app/dist/module/common';
|
|
19
|
-
import FirestoreDocumentReference, {
|
|
20
|
-
provideCollectionReferenceClass,
|
|
21
|
-
} from './FirestoreDocumentReference';
|
|
22
|
-
import FirestoreQuery from './FirestoreQuery';
|
|
23
|
-
import FirestoreQueryModifiers from './FirestoreQueryModifiers';
|
|
24
|
-
|
|
25
|
-
export default class FirestoreCollectionReference extends FirestoreQuery {
|
|
26
|
-
constructor(firestore, collectionPath) {
|
|
27
|
-
super(firestore, collectionPath, new FirestoreQueryModifiers());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get id() {
|
|
31
|
-
return this._collectionPath.id;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get parent() {
|
|
35
|
-
const parent = this._collectionPath.parent();
|
|
36
|
-
if (!parent) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
return new FirestoreDocumentReference(this._firestore, parent);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get path() {
|
|
43
|
-
return this._collectionPath.relativeName;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
add(data) {
|
|
47
|
-
if (!isObject(data)) {
|
|
48
|
-
throw new Error("firebase.firestore().collection().add(*) 'data' must be an object.");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const documentRef = this.doc();
|
|
52
|
-
return documentRef.set(data).then(() => Promise.resolve(documentRef));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
doc(documentPath) {
|
|
56
|
-
const newPath = documentPath || generateFirestoreId();
|
|
57
|
-
const path = this._collectionPath.child(newPath);
|
|
58
|
-
|
|
59
|
-
if (!path.isDocument) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
"firebase.firestore().collection().doc(*) 'documentPath' must point to a document.",
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return new FirestoreDocumentReference(this._firestore, path);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// To avoid React Native require cycle warnings
|
|
70
|
-
provideCollectionReferenceClass(FirestoreCollectionReference);
|
|
@@ -1,222 +0,0 @@
|
|
|
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 {
|
|
19
|
-
isObject,
|
|
20
|
-
isString,
|
|
21
|
-
isUndefined,
|
|
22
|
-
createDeprecationProxy,
|
|
23
|
-
filterModularArgument,
|
|
24
|
-
} from '@react-native-firebase/app/dist/module/common';
|
|
25
|
-
import NativeError from '@react-native-firebase/app/dist/module/internal/NativeFirebaseError';
|
|
26
|
-
import { parseSetOptions, parseSnapshotArgs, parseUpdateArgs } from './utils';
|
|
27
|
-
import { buildNativeMap, provideDocumentReferenceClass } from './utils/serialize';
|
|
28
|
-
|
|
29
|
-
// To avoid React Native require cycle warnings
|
|
30
|
-
let FirestoreCollectionReference = null;
|
|
31
|
-
export function provideCollectionReferenceClass(collectionReference) {
|
|
32
|
-
FirestoreCollectionReference = collectionReference;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let FirestoreDocumentSnapshot = null;
|
|
36
|
-
export function provideDocumentSnapshotClass(documentSnapshot) {
|
|
37
|
-
FirestoreDocumentSnapshot = documentSnapshot;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let _id = 0;
|
|
41
|
-
|
|
42
|
-
export default class FirestoreDocumentReference {
|
|
43
|
-
constructor(firestore, documentPath) {
|
|
44
|
-
this._firestore = firestore;
|
|
45
|
-
this._documentPath = documentPath;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get firestore() {
|
|
49
|
-
return this._firestore;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get id() {
|
|
53
|
-
return this._documentPath.id;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get parent() {
|
|
57
|
-
const parentPath = this._documentPath.parent();
|
|
58
|
-
return new FirestoreCollectionReference(this._firestore, parentPath);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get path() {
|
|
62
|
-
return this._documentPath.relativeName;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
collection(collectionPath) {
|
|
66
|
-
if (!isString(collectionPath)) {
|
|
67
|
-
throw new Error(
|
|
68
|
-
"firebase.firestore().doc().collection(*) 'collectionPath' must be a string value.",
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (collectionPath === '') {
|
|
73
|
-
throw new Error(
|
|
74
|
-
"firebase.firestore().doc().collection(*) 'collectionPath' must be a non-empty string.",
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const path = this._documentPath.child(collectionPath);
|
|
79
|
-
|
|
80
|
-
if (!path.isCollection) {
|
|
81
|
-
throw new Error(
|
|
82
|
-
"firebase.firestore().doc().collection(*) 'collectionPath' must point to a collection.",
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return new FirestoreCollectionReference(this._firestore, path);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
delete() {
|
|
90
|
-
return this._firestore.native.documentDelete(this.path);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get(options) {
|
|
94
|
-
if (!isUndefined(options) && !isObject(options)) {
|
|
95
|
-
throw new Error("firebase.firestore().doc().get(*) 'options' must be an object is provided.");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
options &&
|
|
100
|
-
options.source &&
|
|
101
|
-
options.source !== 'default' &&
|
|
102
|
-
options.source !== 'server' &&
|
|
103
|
-
options.source !== 'cache'
|
|
104
|
-
) {
|
|
105
|
-
throw new Error(
|
|
106
|
-
"firebase.firestore().doc().get(*) 'options' GetOptions.source must be one of 'default', 'server' or 'cache'.",
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return this._firestore.native
|
|
111
|
-
.documentGet(this.path, options)
|
|
112
|
-
.then(data => createDeprecationProxy(new FirestoreDocumentSnapshot(this._firestore, data)));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
isEqual(other) {
|
|
116
|
-
if (!(other instanceof FirestoreDocumentReference)) {
|
|
117
|
-
throw new Error(
|
|
118
|
-
"firebase.firestore().doc().isEqual(*) 'other' expected a DocumentReference instance.",
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return !(
|
|
123
|
-
this.path !== other.path ||
|
|
124
|
-
this.firestore.app.name !== other.firestore.app.name ||
|
|
125
|
-
this.firestore.app.options.projectId !== other.firestore.app.options.projectId
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
onSnapshot(...args) {
|
|
130
|
-
let snapshotListenOptions;
|
|
131
|
-
let callback;
|
|
132
|
-
let onNext;
|
|
133
|
-
let onError;
|
|
134
|
-
|
|
135
|
-
try {
|
|
136
|
-
const options = parseSnapshotArgs(args);
|
|
137
|
-
snapshotListenOptions = options.snapshotListenOptions;
|
|
138
|
-
callback = options.callback;
|
|
139
|
-
onNext = options.onNext;
|
|
140
|
-
onError = options.onError;
|
|
141
|
-
} catch (e) {
|
|
142
|
-
throw new Error(`firebase.firestore().doc().onSnapshot(*) ${e.message}`);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function handleSuccess(documentSnapshot) {
|
|
146
|
-
callback(documentSnapshot, null);
|
|
147
|
-
onNext(documentSnapshot);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function handleError(error) {
|
|
151
|
-
callback(null, error);
|
|
152
|
-
onError(error);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const listenerId = _id++;
|
|
156
|
-
|
|
157
|
-
const onSnapshotSubscription = this._firestore.emitter.addListener(
|
|
158
|
-
this._firestore.eventNameForApp(`firestore_document_sync_event:${listenerId}`),
|
|
159
|
-
event => {
|
|
160
|
-
if (event.body.error) {
|
|
161
|
-
handleError(NativeError.fromEvent(event.body.error, 'firestore'));
|
|
162
|
-
} else {
|
|
163
|
-
const documentSnapshot = createDeprecationProxy(
|
|
164
|
-
new FirestoreDocumentSnapshot(this._firestore, event.body.snapshot),
|
|
165
|
-
);
|
|
166
|
-
handleSuccess(documentSnapshot);
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
const unsubscribe = () => {
|
|
172
|
-
onSnapshotSubscription.remove();
|
|
173
|
-
this._firestore.native.documentOffSnapshot(listenerId);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
this._firestore.native.documentOnSnapshot(this.path, listenerId, snapshotListenOptions);
|
|
177
|
-
|
|
178
|
-
return unsubscribe;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
set(data, options) {
|
|
182
|
-
if (!isObject(data)) {
|
|
183
|
-
throw new Error("firebase.firestore().doc().set(*) 'data' must be an object.");
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
let setOptions;
|
|
187
|
-
try {
|
|
188
|
-
setOptions = parseSetOptions(options);
|
|
189
|
-
} catch (e) {
|
|
190
|
-
throw new Error(`firebase.firestore().doc().set(_, *) ${e.message}.`);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return this._firestore.native.documentSet(
|
|
194
|
-
this.path,
|
|
195
|
-
buildNativeMap(data, this._firestore._settings.ignoreUndefinedProperties),
|
|
196
|
-
setOptions,
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
update(...args) {
|
|
201
|
-
const updatedArgs = filterModularArgument(args);
|
|
202
|
-
if (updatedArgs.length === 0) {
|
|
203
|
-
throw new Error(
|
|
204
|
-
'firebase.firestore().doc().update(*) expected at least 1 argument but was called with 0 arguments.',
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
let data;
|
|
209
|
-
try {
|
|
210
|
-
data = parseUpdateArgs(updatedArgs);
|
|
211
|
-
} catch (e) {
|
|
212
|
-
throw new Error(`firebase.firestore().doc().update(*) ${e.message}`);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return this._firestore.native.documentUpdate(
|
|
216
|
-
this.path,
|
|
217
|
-
buildNativeMap(data, this._firestore._settings.ignoreUndefinedProperties),
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
provideDocumentReferenceClass(FirestoreDocumentReference); // serialize
|