@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,384 @@
|
|
|
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 file 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
|
+
import Foundation
|
|
18
|
+
import FirebaseFirestore
|
|
19
|
+
|
|
20
|
+
final class RNFBFirestorePipelineBridgeFactory {
|
|
21
|
+
private let nodeBuilder = RNFBFirestorePipelineNodeBuilder()
|
|
22
|
+
|
|
23
|
+
private final class StageBridgeBox {
|
|
24
|
+
var stages: [StageBridge]?
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private enum PendingStageBridge {
|
|
28
|
+
case ready(StageBridge)
|
|
29
|
+
case union(StageBridgeBox)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private enum StageBridgeFrame {
|
|
33
|
+
case enter(
|
|
34
|
+
request: RNFBFirestoreParsedPipelineRequest,
|
|
35
|
+
box: StageBridgeBox
|
|
36
|
+
)
|
|
37
|
+
case exit(
|
|
38
|
+
sourceStages: [StageBridge],
|
|
39
|
+
pendingStages: [PendingStageBridge],
|
|
40
|
+
box: StageBridgeBox
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private final class QuerySourceValueBox {
|
|
45
|
+
var value: Any?
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private enum QuerySourceBuildFrame {
|
|
49
|
+
case value(
|
|
50
|
+
RNFBFirestoreParsedValueNode,
|
|
51
|
+
QuerySourceValueBox
|
|
52
|
+
)
|
|
53
|
+
case valueListExit(
|
|
54
|
+
QuerySourceValueBox,
|
|
55
|
+
[QuerySourceValueBox]
|
|
56
|
+
)
|
|
57
|
+
case valueMapExit(
|
|
58
|
+
QuerySourceValueBox,
|
|
59
|
+
[(String, QuerySourceValueBox)]
|
|
60
|
+
)
|
|
61
|
+
case expression(
|
|
62
|
+
RNFBFirestoreParsedExpressionNode,
|
|
63
|
+
QuerySourceValueBox
|
|
64
|
+
)
|
|
65
|
+
case expressionConstantExit(
|
|
66
|
+
QuerySourceValueBox,
|
|
67
|
+
QuerySourceValueBox
|
|
68
|
+
)
|
|
69
|
+
case expressionFunctionExit(
|
|
70
|
+
String,
|
|
71
|
+
QuerySourceValueBox,
|
|
72
|
+
[QuerySourceValueBox]
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
func buildStageBridges(
|
|
77
|
+
firestore: Firestore,
|
|
78
|
+
request: RNFBFirestoreParsedPipelineRequest
|
|
79
|
+
) throws -> [StageBridge] {
|
|
80
|
+
let rootBox = StageBridgeBox()
|
|
81
|
+
var stack: [StageBridgeFrame] = [
|
|
82
|
+
.enter(request: request, box: rootBox),
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
while let frame = stack.popLast() {
|
|
86
|
+
switch frame {
|
|
87
|
+
case let .enter(request, box):
|
|
88
|
+
let sourceStages = try buildSourceStageBridges(firestore: firestore, source: request.source)
|
|
89
|
+
var pendingStages: [PendingStageBridge] = []
|
|
90
|
+
var nestedRequests: [(RNFBFirestoreParsedPipelineRequest, StageBridgeBox)] = []
|
|
91
|
+
pendingStages.reserveCapacity(request.stages.count)
|
|
92
|
+
|
|
93
|
+
for stage in request.stages {
|
|
94
|
+
if case let .unionStage(parsed) = stage {
|
|
95
|
+
let childBox = StageBridgeBox()
|
|
96
|
+
pendingStages.append(.union(childBox))
|
|
97
|
+
nestedRequests.append((parsed.other, childBox))
|
|
98
|
+
} else {
|
|
99
|
+
pendingStages.append(.ready(try buildStageBridge(stage, firestore: firestore)))
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
stack.append(.exit(
|
|
104
|
+
sourceStages: sourceStages,
|
|
105
|
+
pendingStages: pendingStages,
|
|
106
|
+
box: box
|
|
107
|
+
))
|
|
108
|
+
|
|
109
|
+
for (nestedRequest, childBox) in nestedRequests.reversed() {
|
|
110
|
+
stack.append(.enter(request: nestedRequest, box: childBox))
|
|
111
|
+
}
|
|
112
|
+
case let .exit(sourceStages, pendingStages, box):
|
|
113
|
+
var stageBridges = sourceStages
|
|
114
|
+
for pendingStage in pendingStages {
|
|
115
|
+
switch pendingStage {
|
|
116
|
+
case let .ready(stageBridge):
|
|
117
|
+
stageBridges.append(stageBridge)
|
|
118
|
+
case let .union(childBox):
|
|
119
|
+
guard let childStages = childBox.stages else {
|
|
120
|
+
throw PipelineValidationError("pipelineExecute() failed to build nested union pipeline.")
|
|
121
|
+
}
|
|
122
|
+
stageBridges.append(UnionStageBridge(other: PipelineBridge(stages: childStages, db: firestore)))
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
box.stages = stageBridges
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
guard let stageBridges = rootBox.stages else {
|
|
131
|
+
throw PipelineValidationError("pipelineExecute() failed to build pipeline stages.")
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return stageBridges
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private func buildSourceStageBridges(
|
|
138
|
+
firestore: Firestore,
|
|
139
|
+
source: RNFBFirestoreParsedPipelineSource
|
|
140
|
+
) throws -> [StageBridge] {
|
|
141
|
+
let sourceType = source.sourceType
|
|
142
|
+
|
|
143
|
+
switch sourceType {
|
|
144
|
+
case "collection":
|
|
145
|
+
guard let path = source.path else {
|
|
146
|
+
throw PipelineValidationError("pipelineExecute() expected pipeline.source.path to be a non-empty string.")
|
|
147
|
+
}
|
|
148
|
+
return [CollectionSourceStageBridge(ref: firestore.collection(path), firestore: firestore)]
|
|
149
|
+
case "collectionGroup":
|
|
150
|
+
guard let collectionId = source.collectionId else {
|
|
151
|
+
throw PipelineValidationError(
|
|
152
|
+
"pipelineExecute() expected pipeline.source.collectionId to be a non-empty string.")
|
|
153
|
+
}
|
|
154
|
+
return [CollectionGroupSourceStageBridge(collectionId: collectionId)]
|
|
155
|
+
case "database":
|
|
156
|
+
return [DatabaseSourceStageBridge()]
|
|
157
|
+
case "documents":
|
|
158
|
+
guard !source.documents.isEmpty else {
|
|
159
|
+
throw PipelineValidationError(
|
|
160
|
+
"pipelineExecute() expected pipeline.source.documents to contain at least one document path.")
|
|
161
|
+
}
|
|
162
|
+
let refs = source.documents.map { firestore.document($0) }
|
|
163
|
+
return [DocumentsSourceStageBridge(documents: refs, firestore: firestore)]
|
|
164
|
+
case "query":
|
|
165
|
+
guard let path = source.path else {
|
|
166
|
+
throw PipelineValidationError("pipelineExecute() expected pipeline.source.path to be a non-empty string.")
|
|
167
|
+
}
|
|
168
|
+
guard let queryType = source.queryType else {
|
|
169
|
+
throw PipelineValidationError("pipelineExecute() expected pipeline.source.queryType to be a non-empty string.")
|
|
170
|
+
}
|
|
171
|
+
guard let querySource = source.query else {
|
|
172
|
+
throw PipelineValidationError("pipelineExecute() expected query source payload to be provided.")
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let baseQuery = RNFBFirestoreCommon.getQueryFor(firestore, path: path, type: queryType)
|
|
176
|
+
let query = RNFBFirestoreQuery(
|
|
177
|
+
modifiers: firestore,
|
|
178
|
+
query: baseQuery,
|
|
179
|
+
filters: buildQuerySourceArray(querySource.filters),
|
|
180
|
+
orders: buildQuerySourceArray(querySource.orders),
|
|
181
|
+
options: buildQuerySourceMap(querySource.options)
|
|
182
|
+
).instance()
|
|
183
|
+
|
|
184
|
+
guard let query else {
|
|
185
|
+
throw PipelineValidationError("pipelineExecute() expected query source to be a valid query.")
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return PipelineBridge.createStageBridges(from: query)
|
|
189
|
+
default:
|
|
190
|
+
throw PipelineValidationError("pipelineExecute() received an unknown source type.")
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private func buildStageBridge(
|
|
195
|
+
_ stage: RNFBFirestoreParsedPipelineStage,
|
|
196
|
+
firestore: Firestore
|
|
197
|
+
) throws -> StageBridge {
|
|
198
|
+
switch stage {
|
|
199
|
+
case let .whereStage(parsed):
|
|
200
|
+
return WhereStageBridge(
|
|
201
|
+
expr: try nodeBuilder.coerceBooleanExpression(parsed.condition, fieldName: "stage.options.condition"))
|
|
202
|
+
case let .selectStage(parsed):
|
|
203
|
+
return SelectStageBridge(
|
|
204
|
+
selections: try nodeBuilder.coerceNamedSelectables(parsed.selections, fieldName: "stage.options.selections"))
|
|
205
|
+
case let .addFieldsStage(parsed):
|
|
206
|
+
return AddFieldsStageBridge(
|
|
207
|
+
fields: try nodeBuilder.coerceNamedSelectables(parsed.fields, fieldName: "stage.options.fields"))
|
|
208
|
+
case let .removeFieldsStage(parsed):
|
|
209
|
+
return RemoveFieldsStageBridge(
|
|
210
|
+
fields: parsed.fields)
|
|
211
|
+
case let .sortStage(parsed):
|
|
212
|
+
return SortStageBridge(
|
|
213
|
+
orderings: try nodeBuilder.coerceOrderings(parsed.orderings, fieldName: "stage.options.orderings"))
|
|
214
|
+
case let .limitStage(parsed):
|
|
215
|
+
return LimitStageBridge(limit: try nodeBuilder.coerceInt(parsed.limit, fieldName: "stage.options.limit"))
|
|
216
|
+
case let .offsetStage(parsed):
|
|
217
|
+
return OffsetStageBridge(offset: try nodeBuilder.coerceInt(parsed.offset, fieldName: "stage.options.offset"))
|
|
218
|
+
case let .aggregateStage(parsed):
|
|
219
|
+
return try buildAggregateStage(parsed)
|
|
220
|
+
case let .distinctStage(parsed):
|
|
221
|
+
return DistinctStageBridge(
|
|
222
|
+
groups: try nodeBuilder.coerceNamedSelectables(parsed.groups, fieldName: "stage.options.groups"))
|
|
223
|
+
case let .findNearestStage(parsed):
|
|
224
|
+
return try buildFindNearestStage(parsed)
|
|
225
|
+
case let .replaceWithStage(parsed):
|
|
226
|
+
return ReplaceWithStageBridge(expr: try nodeBuilder.coerceExpression(parsed.value, fieldName: "stage.options.map"))
|
|
227
|
+
case let .sampleStage(parsed):
|
|
228
|
+
if let documents = parsed.documents {
|
|
229
|
+
return SampleStageBridge(count: Int64(try nodeBuilder.coerceInt(documents, fieldName: "stage.options.documents")))
|
|
230
|
+
}
|
|
231
|
+
if let percentage = parsed.percentage {
|
|
232
|
+
return SampleStageBridge(percentage: try coerceNumber(percentage, fieldName: "stage.options.percentage"))
|
|
233
|
+
}
|
|
234
|
+
throw PipelineValidationError("pipelineExecute() expected sample stage to include documents or percentage.")
|
|
235
|
+
case .unionStage:
|
|
236
|
+
throw PipelineValidationError("pipelineExecute() failed to build nested union pipeline.")
|
|
237
|
+
case let .unnestStage(parsed):
|
|
238
|
+
let expression = try nodeBuilder.coerceExpression(parsed.selectable.expression, fieldName: "stage.options.selectable")
|
|
239
|
+
let alias = nodeBuilder.coerceAlias(from: parsed.selectable) ?? "_unnest"
|
|
240
|
+
let indexExpr: ExprBridge?
|
|
241
|
+
if let indexField = parsed.indexField {
|
|
242
|
+
indexExpr = try nodeBuilder.coerceExpression(indexField, fieldName: "stage.options.indexField")
|
|
243
|
+
} else {
|
|
244
|
+
indexExpr = nil
|
|
245
|
+
}
|
|
246
|
+
return UnnestStageBridge(field: expression, alias: FieldBridge(name: alias), indexField: indexExpr)
|
|
247
|
+
case let .rawStage(parsed):
|
|
248
|
+
return RawStageBridge(
|
|
249
|
+
name: parsed.name,
|
|
250
|
+
params: try nodeBuilder.coerceRawParams(parsed.params, fieldName: "stage.options.params"),
|
|
251
|
+
options: try nodeBuilder.coerceRawOptions(parsed.options, fieldName: "stage.options.options")
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private func buildAggregateStage(_ stage: RNFBFirestoreParsedAggregateStage) throws -> StageBridge {
|
|
257
|
+
var accumulators: [String: AggregateFunctionBridge] = [:]
|
|
258
|
+
for (index, accumulator) in stage.accumulators.enumerated() {
|
|
259
|
+
let aggregate = try nodeBuilder.coerceAliasedAggregate(
|
|
260
|
+
accumulator,
|
|
261
|
+
fieldName: "stage.options.accumulators[\(index)]"
|
|
262
|
+
)
|
|
263
|
+
accumulators[aggregate.alias] = aggregate.function
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let groups = stage.groups.isEmpty
|
|
267
|
+
? [:]
|
|
268
|
+
: try nodeBuilder.coerceNamedSelectables(stage.groups, fieldName: "stage.options.groups")
|
|
269
|
+
|
|
270
|
+
return AggregateStageBridge(accumulators: accumulators, groups: groups)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private func buildFindNearestStage(_ stage: RNFBFirestoreParsedFindNearestStage) throws -> StageBridge {
|
|
274
|
+
let fieldPath = try nodeBuilder.coerceFieldPath(stage.field, fieldName: "stage.options.field")
|
|
275
|
+
let vector = try nodeBuilder.coerceVector(stage.vectorValue, fieldName: "findNearest.vectorValue")
|
|
276
|
+
let distanceFieldExpr: ExprBridge?
|
|
277
|
+
if let distanceField = stage.distanceField {
|
|
278
|
+
distanceFieldExpr = try nodeBuilder.coerceExpression(distanceField, fieldName: "stage.options.distanceField")
|
|
279
|
+
} else {
|
|
280
|
+
distanceFieldExpr = nil
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return FindNearestStageBridge(
|
|
284
|
+
field: FieldBridge(name: fieldPath),
|
|
285
|
+
vectorValue: VectorValue(__array: vector.map { NSNumber(value: $0) }),
|
|
286
|
+
distanceMeasure: stage.distanceMeasure.lowercased(),
|
|
287
|
+
limit: stage.limit,
|
|
288
|
+
distanceField: distanceFieldExpr
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
private func coerceNumber(_ value: Any, fieldName: String) throws -> Double {
|
|
293
|
+
if let number = value as? NSNumber {
|
|
294
|
+
return number.doubleValue
|
|
295
|
+
}
|
|
296
|
+
throw PipelineValidationError("pipelineExecute() expected \(fieldName) to be a number.")
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private func buildQuerySourceArray(_ values: [RNFBFirestoreParsedValueNode]) -> [Any] {
|
|
300
|
+
values.map(buildQuerySourceValue)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private func buildQuerySourceMap(_ values: [String: RNFBFirestoreParsedValueNode]) -> [String: Any] {
|
|
304
|
+
values.reduce(into: [String: Any]()) { result, entry in
|
|
305
|
+
result[entry.key] = buildQuerySourceValue(entry.value)
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private func buildQuerySourceValue(_ value: RNFBFirestoreParsedValueNode) -> Any {
|
|
310
|
+
let rootBox = QuerySourceValueBox()
|
|
311
|
+
var stack: [QuerySourceBuildFrame] = [
|
|
312
|
+
.value(value, rootBox),
|
|
313
|
+
]
|
|
314
|
+
|
|
315
|
+
while let frame = stack.popLast() {
|
|
316
|
+
switch frame {
|
|
317
|
+
case let .value(value, box):
|
|
318
|
+
switch value {
|
|
319
|
+
case let .primitive(primitive):
|
|
320
|
+
box.value = primitive
|
|
321
|
+
case let .list(values):
|
|
322
|
+
let childBoxes = values.map { _ in QuerySourceValueBox() }
|
|
323
|
+
stack.append(.valueListExit(box, childBoxes))
|
|
324
|
+
for index in values.indices.reversed() {
|
|
325
|
+
stack.append(.value(values[index], childBoxes[index]))
|
|
326
|
+
}
|
|
327
|
+
case let .map(values):
|
|
328
|
+
let entries = values.map { (key: $0.key, box: QuerySourceValueBox(), value: $0.value) }
|
|
329
|
+
stack.append(.valueMapExit(box, entries.map { ($0.key, $0.box) }))
|
|
330
|
+
for entry in entries.reversed() {
|
|
331
|
+
stack.append(.value(entry.value, entry.box))
|
|
332
|
+
}
|
|
333
|
+
case let .expression(expression):
|
|
334
|
+
stack.append(.expression(expression, box))
|
|
335
|
+
}
|
|
336
|
+
case let .valueListExit(box, childBoxes):
|
|
337
|
+
box.value = childBoxes.map { $0.value as Any }
|
|
338
|
+
case let .valueMapExit(box, entries):
|
|
339
|
+
var output: [String: Any] = [:]
|
|
340
|
+
for (key, childBox) in entries {
|
|
341
|
+
output[key] = childBox.value
|
|
342
|
+
}
|
|
343
|
+
box.value = output
|
|
344
|
+
case let .expression(expression, box):
|
|
345
|
+
switch expression {
|
|
346
|
+
case let .field(path):
|
|
347
|
+
box.value = [
|
|
348
|
+
"__kind": "expression",
|
|
349
|
+
"exprType": "Field",
|
|
350
|
+
"path": path,
|
|
351
|
+
]
|
|
352
|
+
case let .constant(value):
|
|
353
|
+
let childBox = QuerySourceValueBox()
|
|
354
|
+
stack.append(.expressionConstantExit(box, childBox))
|
|
355
|
+
stack.append(.value(value, childBox))
|
|
356
|
+
case let .function(name, args):
|
|
357
|
+
let childBoxes = args.map { _ in QuerySourceValueBox() }
|
|
358
|
+
stack.append(.expressionFunctionExit(name, box, childBoxes))
|
|
359
|
+
for index in args.indices.reversed() {
|
|
360
|
+
stack.append(.value(args[index], childBoxes[index]))
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
case let .expressionConstantExit(box, childBox):
|
|
364
|
+
box.value = [
|
|
365
|
+
"__kind": "expression",
|
|
366
|
+
"exprType": "Constant",
|
|
367
|
+
"value": childBox.value as Any,
|
|
368
|
+
]
|
|
369
|
+
case let .expressionFunctionExit(name, box, childBoxes):
|
|
370
|
+
box.value = [
|
|
371
|
+
"__kind": "expression",
|
|
372
|
+
"exprType": "Function",
|
|
373
|
+
"name": name,
|
|
374
|
+
"args": childBoxes.map { $0.value as Any },
|
|
375
|
+
]
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
guard let value = rootBox.value else {
|
|
380
|
+
return NSNull()
|
|
381
|
+
}
|
|
382
|
+
return value
|
|
383
|
+
}
|
|
384
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 file 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
|
+
import Foundation
|
|
18
|
+
import FirebaseFirestore
|
|
19
|
+
|
|
20
|
+
@objcMembers
|
|
21
|
+
public class RNFBFirestorePipelineCallHandler: NSObject {
|
|
22
|
+
private let bridgeFactory = RNFBFirestorePipelineBridgeFactory()
|
|
23
|
+
private let snapshotSerializer = RNFBFirestorePipelineSnapshotSerializer()
|
|
24
|
+
|
|
25
|
+
@objc(executeWithFirestore:pipeline:options:completion:)
|
|
26
|
+
public func execute(
|
|
27
|
+
withFirestore firestore: Firestore,
|
|
28
|
+
pipeline: NSDictionary?,
|
|
29
|
+
options: NSDictionary?,
|
|
30
|
+
completion: @escaping ([AnyHashable: Any]?, [AnyHashable: Any]?) -> Void
|
|
31
|
+
) {
|
|
32
|
+
do {
|
|
33
|
+
let request = try RNFBFirestorePipelineParser.parse(pipeline: pipeline, options: options)
|
|
34
|
+
let metadata = snapshotSerializer.buildExecutionMetadata(request)
|
|
35
|
+
let stageBridges = try bridgeFactory.buildStageBridges(firestore: firestore, request: request)
|
|
36
|
+
|
|
37
|
+
// FirebaseFirestoreInternal currently exposes only PipelineBridge.executeWithCompletion() and
|
|
38
|
+
// source-stage initializers without execute/source options. Reject these inputs on iOS until
|
|
39
|
+
// the native SDK exposes an options-bearing pipeline execution/source API.
|
|
40
|
+
let bridge = PipelineBridge(stages: stageBridges, db: firestore)
|
|
41
|
+
|
|
42
|
+
bridge.execute { snapshot, error in
|
|
43
|
+
if let error {
|
|
44
|
+
completion(nil, [
|
|
45
|
+
"code": "firestore/native",
|
|
46
|
+
"message": error.localizedDescription,
|
|
47
|
+
"nativeError": error,
|
|
48
|
+
])
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
do {
|
|
53
|
+
completion(try self.snapshotSerializer.serializeSnapshot(snapshot, metadata: metadata), nil)
|
|
54
|
+
} catch let error as PipelineValidationError {
|
|
55
|
+
completion(nil, [
|
|
56
|
+
"code": "firestore/unknown",
|
|
57
|
+
"message": error.message,
|
|
58
|
+
])
|
|
59
|
+
} catch {
|
|
60
|
+
completion(nil, [
|
|
61
|
+
"code": "firestore/unknown",
|
|
62
|
+
"message": "Failed to serialize pipeline snapshot: \(error.localizedDescription)",
|
|
63
|
+
])
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch let error as PipelineValidationError {
|
|
67
|
+
completion(nil, [
|
|
68
|
+
"code": "firestore/invalid-argument",
|
|
69
|
+
"message": error.message,
|
|
70
|
+
])
|
|
71
|
+
} catch {
|
|
72
|
+
completion(nil, [
|
|
73
|
+
"code": "firestore/unknown",
|
|
74
|
+
"message": "Failed to execute pipeline: \(error.localizedDescription)",
|
|
75
|
+
])
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
struct PipelineValidationError: Error {
|
|
81
|
+
let message: String
|
|
82
|
+
|
|
83
|
+
init(_ message: String) {
|
|
84
|
+
self.message = message
|
|
85
|
+
}
|
|
86
|
+
}
|