@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,287 @@
|
|
|
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
|
+
DocumentReference,
|
|
20
|
+
Timestamp,
|
|
21
|
+
GeoPoint,
|
|
22
|
+
Bytes,
|
|
23
|
+
doc,
|
|
24
|
+
documentId,
|
|
25
|
+
serverTimestamp,
|
|
26
|
+
increment,
|
|
27
|
+
deleteField,
|
|
28
|
+
arrayUnion,
|
|
29
|
+
arrayRemove,
|
|
30
|
+
vector,
|
|
31
|
+
VectorValue,
|
|
32
|
+
} from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestore';
|
|
33
|
+
import type { Firestore } from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestore';
|
|
34
|
+
|
|
35
|
+
const INT_NAN = 0;
|
|
36
|
+
const INT_NEGATIVE_INFINITY = 1;
|
|
37
|
+
const INT_POSITIVE_INFINITY = 2;
|
|
38
|
+
const INT_NULL = 3;
|
|
39
|
+
const INT_DOCUMENTID = 4;
|
|
40
|
+
const INT_BOOLEAN_TRUE = 5;
|
|
41
|
+
const INT_BOOLEAN_FALSE = 6;
|
|
42
|
+
const INT_DOUBLE = 7;
|
|
43
|
+
const INT_STRING = 8;
|
|
44
|
+
const INT_STRING_EMPTY = 9;
|
|
45
|
+
const INT_ARRAY = 10;
|
|
46
|
+
const INT_REFERENCE = 11;
|
|
47
|
+
const INT_GEOPOINT = 12;
|
|
48
|
+
const INT_TIMESTAMP = 13;
|
|
49
|
+
const INT_BLOB = 14;
|
|
50
|
+
const INT_FIELDVALUE = 15;
|
|
51
|
+
const INT_OBJECT = 16;
|
|
52
|
+
const INT_INTEGER = 17;
|
|
53
|
+
const INT_NEGATIVE_ZERO = 18;
|
|
54
|
+
const INT_VECTOR = 19;
|
|
55
|
+
const INT_UNKNOWN = -999;
|
|
56
|
+
|
|
57
|
+
const TYPE = 'type';
|
|
58
|
+
const KEY_PATH = 'path';
|
|
59
|
+
const KEY_DATA = 'data';
|
|
60
|
+
const KEY_OPTIONS = 'options';
|
|
61
|
+
|
|
62
|
+
export function objectToWriteable(object: Record<string, unknown>): Record<string, unknown> {
|
|
63
|
+
const out: Record<string, unknown> = {};
|
|
64
|
+
for (const [key, value] of Object.entries(object)) {
|
|
65
|
+
out[key] = buildTypeMap(value);
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function arrayToWriteable(array: unknown[]): unknown[] {
|
|
71
|
+
return array.map(buildTypeMap);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function readableToObject(
|
|
75
|
+
firestore: Firestore,
|
|
76
|
+
readableMap: Record<string, unknown>,
|
|
77
|
+
): Record<string, unknown> {
|
|
78
|
+
const out: Record<string, unknown> = {};
|
|
79
|
+
for (const [key, value] of Object.entries(readableMap)) {
|
|
80
|
+
out[key] = parseTypeMap(firestore, value as [number, unknown?]);
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function readableToArray(firestore: Firestore, readableArray: unknown[]): unknown[] {
|
|
86
|
+
return readableArray.map(value => parseTypeMap(firestore, value as [number, unknown?]));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ParsedDocumentBatch {
|
|
90
|
+
type: string;
|
|
91
|
+
path: string;
|
|
92
|
+
data?: Record<string, unknown>;
|
|
93
|
+
options?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function parseDocumentBatches(
|
|
97
|
+
firestore: Firestore,
|
|
98
|
+
readableArray: Array<Record<string, unknown>>,
|
|
99
|
+
): ParsedDocumentBatch[] {
|
|
100
|
+
const out: ParsedDocumentBatch[] = [];
|
|
101
|
+
|
|
102
|
+
for (const map of readableArray) {
|
|
103
|
+
const write: ParsedDocumentBatch = {
|
|
104
|
+
[TYPE]: map[TYPE] as string,
|
|
105
|
+
[KEY_PATH]: map[KEY_PATH] as string,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if (KEY_DATA in map) {
|
|
109
|
+
write.data = readableToObject(firestore, map[KEY_DATA] as Record<string, unknown>);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (KEY_OPTIONS in map) {
|
|
113
|
+
write.options = map[KEY_OPTIONS] as Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
out.push(write);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function buildTypeMap(value: unknown): unknown {
|
|
123
|
+
const out: unknown[] = [];
|
|
124
|
+
if (value === null) {
|
|
125
|
+
out.push(INT_NULL);
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (typeof value === 'boolean') {
|
|
130
|
+
out.push(value ? INT_BOOLEAN_TRUE : INT_BOOLEAN_FALSE);
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (typeof value === 'number' && !Number.isInteger(value)) {
|
|
135
|
+
out.push(INT_DOUBLE);
|
|
136
|
+
out.push(value);
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (typeof value === 'number' && Number.isInteger(value)) {
|
|
141
|
+
if (value === Number.NEGATIVE_INFINITY) {
|
|
142
|
+
out.push(INT_NEGATIVE_INFINITY);
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
if (value === Number.POSITIVE_INFINITY) {
|
|
146
|
+
out.push(INT_POSITIVE_INFINITY);
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
if (Number.isNaN(value)) {
|
|
150
|
+
out.push(INT_NAN);
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
out.push(INT_DOUBLE);
|
|
154
|
+
out.push(value);
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (typeof value === 'string') {
|
|
159
|
+
if (value === '') {
|
|
160
|
+
out.push(INT_STRING_EMPTY);
|
|
161
|
+
} else {
|
|
162
|
+
out.push(INT_STRING);
|
|
163
|
+
out.push(value);
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (Array.isArray(value)) {
|
|
169
|
+
out.push(INT_ARRAY);
|
|
170
|
+
out.push(arrayToWriteable(value));
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (value instanceof DocumentReference) {
|
|
175
|
+
out.push(INT_REFERENCE);
|
|
176
|
+
out.push(value.path);
|
|
177
|
+
return out;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (value instanceof Timestamp) {
|
|
181
|
+
out.push(INT_TIMESTAMP);
|
|
182
|
+
out.push([value.seconds, value.nanoseconds]);
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (value instanceof GeoPoint) {
|
|
187
|
+
out.push(INT_GEOPOINT);
|
|
188
|
+
out.push([value.latitude, value.longitude]);
|
|
189
|
+
return out;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (value instanceof Bytes) {
|
|
193
|
+
out.push(INT_BLOB);
|
|
194
|
+
out.push(value.toBase64());
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (value instanceof VectorValue) {
|
|
199
|
+
out.push(INT_VECTOR);
|
|
200
|
+
out.push(value.toArray());
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (typeof value === 'object') {
|
|
205
|
+
out.push(INT_OBJECT);
|
|
206
|
+
out.push(objectToWriteable(value as Record<string, unknown>));
|
|
207
|
+
return out;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
out.push(INT_UNKNOWN);
|
|
211
|
+
return out;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function parseTypeMap(firestore: Firestore, typedArray: [number, unknown?]): unknown {
|
|
215
|
+
const value = typedArray[0];
|
|
216
|
+
|
|
217
|
+
switch (value) {
|
|
218
|
+
case INT_NAN:
|
|
219
|
+
return NaN;
|
|
220
|
+
case INT_NEGATIVE_INFINITY:
|
|
221
|
+
return Number.NEGATIVE_INFINITY;
|
|
222
|
+
case INT_POSITIVE_INFINITY:
|
|
223
|
+
return Number.POSITIVE_INFINITY;
|
|
224
|
+
case INT_NULL:
|
|
225
|
+
return null;
|
|
226
|
+
case INT_DOCUMENTID:
|
|
227
|
+
return documentId();
|
|
228
|
+
case INT_BOOLEAN_TRUE:
|
|
229
|
+
return true;
|
|
230
|
+
case INT_BOOLEAN_FALSE:
|
|
231
|
+
return false;
|
|
232
|
+
case INT_NEGATIVE_ZERO:
|
|
233
|
+
return -0;
|
|
234
|
+
case INT_INTEGER:
|
|
235
|
+
return Number(typedArray[1]);
|
|
236
|
+
case INT_DOUBLE:
|
|
237
|
+
return Number(typedArray[1]);
|
|
238
|
+
case INT_STRING:
|
|
239
|
+
return String(typedArray[1]);
|
|
240
|
+
case INT_STRING_EMPTY:
|
|
241
|
+
return '';
|
|
242
|
+
case INT_ARRAY:
|
|
243
|
+
return readableToArray(firestore, (typedArray[1] ?? []) as unknown[]);
|
|
244
|
+
case INT_REFERENCE:
|
|
245
|
+
return doc(firestore, typedArray[1] as string);
|
|
246
|
+
case INT_GEOPOINT: {
|
|
247
|
+
const v = (typedArray[1] ?? []) as number[];
|
|
248
|
+
return new GeoPoint(v[0] ?? 0, v[1] ?? 0);
|
|
249
|
+
}
|
|
250
|
+
case INT_TIMESTAMP: {
|
|
251
|
+
const v = (typedArray[1] ?? []) as number[];
|
|
252
|
+
return new Timestamp(v[0] ?? 0, v[1] ?? 0);
|
|
253
|
+
}
|
|
254
|
+
case INT_BLOB:
|
|
255
|
+
return Bytes.fromBase64String(typedArray[1] as string);
|
|
256
|
+
case INT_FIELDVALUE: {
|
|
257
|
+
const fieldValueArray = (typedArray[1] ?? []) as unknown[];
|
|
258
|
+
const fieldValueType = fieldValueArray[0];
|
|
259
|
+
|
|
260
|
+
if (fieldValueType === 'timestamp') {
|
|
261
|
+
return serverTimestamp();
|
|
262
|
+
}
|
|
263
|
+
if (fieldValueType === 'increment') {
|
|
264
|
+
return increment(fieldValueArray[1] as number);
|
|
265
|
+
}
|
|
266
|
+
if (fieldValueType === 'delete') {
|
|
267
|
+
return deleteField();
|
|
268
|
+
}
|
|
269
|
+
if (fieldValueType === 'array_union') {
|
|
270
|
+
const elements = readableToArray(firestore, (fieldValueArray[1] ?? []) as unknown[]);
|
|
271
|
+
return arrayUnion(...elements);
|
|
272
|
+
}
|
|
273
|
+
if (fieldValueType === 'array_remove') {
|
|
274
|
+
const elements = readableToArray(firestore, (fieldValueArray[1] ?? []) as unknown[]);
|
|
275
|
+
return arrayRemove(...elements);
|
|
276
|
+
}
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
case INT_OBJECT:
|
|
280
|
+
return readableToObject(firestore, (typedArray[1] ?? {}) as Record<string, unknown>);
|
|
281
|
+
case INT_VECTOR:
|
|
282
|
+
return vector(typedArray[1] as number[]);
|
|
283
|
+
case INT_UNKNOWN:
|
|
284
|
+
default:
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { execute } from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestorePipelines';
|
|
19
|
+
import type { Firestore } from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestore';
|
|
20
|
+
import type {
|
|
21
|
+
FirestorePipelineExecuteOptionsInternal,
|
|
22
|
+
FirestorePipelineSerializedInternal,
|
|
23
|
+
FirestorePipelineSnapshotInternal,
|
|
24
|
+
} from '../../types/internal';
|
|
25
|
+
import { validatePipelineExecuteRequest } from '../../pipelines/pipeline_validate';
|
|
26
|
+
import { buildWebSdkPipeline } from './pipeline_bridge_factory';
|
|
27
|
+
import type { WebPipelineInstance } from './pipeline_node_builder';
|
|
28
|
+
import { serializeWebSdkPipelineSnapshot } from './pipeline_snapshot_serializer';
|
|
29
|
+
|
|
30
|
+
async function executeWebSdkPipelineSnapshot(
|
|
31
|
+
webSdkPipeline: WebPipelineInstance,
|
|
32
|
+
_options?: FirestorePipelineExecuteOptionsInternal,
|
|
33
|
+
): Promise<unknown> {
|
|
34
|
+
// The current web SDK execute() surface only accepts the pipeline instance.
|
|
35
|
+
return execute(webSdkPipeline);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function executeWebSdkPipeline(
|
|
39
|
+
firestore: Firestore,
|
|
40
|
+
pipeline: FirestorePipelineSerializedInternal,
|
|
41
|
+
options?: FirestorePipelineExecuteOptionsInternal,
|
|
42
|
+
): Promise<FirestorePipelineSnapshotInternal> {
|
|
43
|
+
const request = validatePipelineExecuteRequest(pipeline, options);
|
|
44
|
+
const webSdkPipeline = buildWebSdkPipeline(firestore, request);
|
|
45
|
+
const rawSnapshot = await executeWebSdkPipelineSnapshot(webSdkPipeline, request.options);
|
|
46
|
+
return serializeWebSdkPipelineSnapshot(rawSnapshot, request);
|
|
47
|
+
}
|
|
@@ -0,0 +1,377 @@
|
|
|
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
|
+
collection,
|
|
20
|
+
collectionGroup,
|
|
21
|
+
} from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestore';
|
|
22
|
+
import type {
|
|
23
|
+
Firestore,
|
|
24
|
+
Query,
|
|
25
|
+
} from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestore';
|
|
26
|
+
import type { FirestorePipelineSerializedInternal } from '../../types/internal';
|
|
27
|
+
import {
|
|
28
|
+
revivePipelineValue,
|
|
29
|
+
type WebPipelineInstance,
|
|
30
|
+
type WebPipelineSource,
|
|
31
|
+
} from './pipeline_node_builder';
|
|
32
|
+
import type { WebParsedPipelineRequest } from './pipeline_parser';
|
|
33
|
+
import { buildQuery } from '../query';
|
|
34
|
+
import type { FilterSpec, OrderSpec, QueryOptions } from '../query';
|
|
35
|
+
|
|
36
|
+
const PIPELINE_RUNTIME_IMPORT_SUFFIX =
|
|
37
|
+
' Import "@react-native-firebase/firestore/pipelines" before using pipelines so the pipeline runtime is installed.';
|
|
38
|
+
|
|
39
|
+
function createPipelineRuntimeImportError(message: string): Error {
|
|
40
|
+
return new Error(message + PIPELINE_RUNTIME_IMPORT_SUFFIX);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
44
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function buildCollectionSourcePipeline(
|
|
48
|
+
pipelineSource: WebPipelineSource,
|
|
49
|
+
source: Extract<FirestorePipelineSerializedInternal['source'], { source: 'collection' }>,
|
|
50
|
+
): WebPipelineInstance | undefined {
|
|
51
|
+
if (typeof pipelineSource.collection !== 'function') {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return pipelineSource.collection({
|
|
56
|
+
collection: source.path,
|
|
57
|
+
...(isRecord(source.rawOptions) && source.rawOptions ? { rawOptions: source.rawOptions } : {}),
|
|
58
|
+
}) as WebPipelineInstance;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function buildCollectionGroupSourcePipeline(
|
|
62
|
+
pipelineSource: WebPipelineSource,
|
|
63
|
+
source: Extract<FirestorePipelineSerializedInternal['source'], { source: 'collectionGroup' }>,
|
|
64
|
+
): WebPipelineInstance | undefined {
|
|
65
|
+
if (typeof pipelineSource.collectionGroup !== 'function') {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return pipelineSource.collectionGroup({
|
|
70
|
+
collectionId: source.collectionId,
|
|
71
|
+
...(isRecord(source.rawOptions) && source.rawOptions ? { rawOptions: source.rawOptions } : {}),
|
|
72
|
+
}) as WebPipelineInstance;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function buildDatabaseSourcePipeline(
|
|
76
|
+
pipelineSource: WebPipelineSource,
|
|
77
|
+
source: Extract<FirestorePipelineSerializedInternal['source'], { source: 'database' }>,
|
|
78
|
+
): WebPipelineInstance | undefined {
|
|
79
|
+
if (typeof pipelineSource.database !== 'function') {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return pipelineSource.database(
|
|
84
|
+
isRecord(source.rawOptions) && source.rawOptions ? { rawOptions: source.rawOptions } : {},
|
|
85
|
+
) as WebPipelineInstance;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function buildDocumentsSourcePipeline(
|
|
89
|
+
pipelineSource: WebPipelineSource,
|
|
90
|
+
source: Extract<FirestorePipelineSerializedInternal['source'], { source: 'documents' }>,
|
|
91
|
+
): WebPipelineInstance | undefined {
|
|
92
|
+
if (typeof pipelineSource.documents !== 'function') {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return pipelineSource.documents({
|
|
97
|
+
docs: source.documents,
|
|
98
|
+
...(isRecord(source.rawOptions) && source.rawOptions ? { rawOptions: source.rawOptions } : {}),
|
|
99
|
+
}) as WebPipelineInstance;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function buildQuerySourcePipeline(
|
|
103
|
+
firestore: Firestore,
|
|
104
|
+
pipelineSource: WebPipelineSource,
|
|
105
|
+
source: Extract<FirestorePipelineSerializedInternal['source'], { source: 'query' }>,
|
|
106
|
+
): WebPipelineInstance {
|
|
107
|
+
if (typeof pipelineSource.createFrom !== 'function') {
|
|
108
|
+
throw createPipelineRuntimeImportError(
|
|
109
|
+
'pipelineExecute() expected pipeline source to support createFrom(query).',
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const queryRef =
|
|
114
|
+
source.queryType === 'collectionGroup'
|
|
115
|
+
? (collectionGroup(firestore, source.path) as unknown as Query)
|
|
116
|
+
: (collection(firestore, source.path) as unknown as Query);
|
|
117
|
+
const query = buildQuery(
|
|
118
|
+
queryRef,
|
|
119
|
+
source.filters as FilterSpec[],
|
|
120
|
+
source.orders as OrderSpec[],
|
|
121
|
+
source.options as QueryOptions,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return pipelineSource.createFrom(query as unknown as Query) as WebPipelineInstance;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function getPipelineStageMethod(
|
|
128
|
+
current: WebPipelineInstance,
|
|
129
|
+
stageName: string,
|
|
130
|
+
): (this: WebPipelineInstance, ...args: unknown[]) => unknown {
|
|
131
|
+
const method = current?.[stageName] as
|
|
132
|
+
| ((this: WebPipelineInstance, ...args: unknown[]) => unknown)
|
|
133
|
+
| undefined;
|
|
134
|
+
if (typeof method !== 'function') {
|
|
135
|
+
throw new Error(`Pipeline stage "${stageName}" is not supported by the current web SDK.`);
|
|
136
|
+
}
|
|
137
|
+
return method;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function applyPipelineStage(
|
|
141
|
+
current: WebPipelineInstance,
|
|
142
|
+
stage: FirestorePipelineSerializedInternal['stages'][number],
|
|
143
|
+
nestedUnionPipeline?: WebPipelineInstance,
|
|
144
|
+
): WebPipelineInstance {
|
|
145
|
+
if (stage.stage === 'union') {
|
|
146
|
+
return getPipelineStageMethod(current, stage.stage).call(current, {
|
|
147
|
+
other: nestedUnionPipeline,
|
|
148
|
+
}) as WebPipelineInstance;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const revivedStageOptions = revivePipelineValue(stage.options);
|
|
152
|
+
const stageArgs = (isRecord(revivedStageOptions) ? revivedStageOptions : stage.options) as Record<
|
|
153
|
+
string,
|
|
154
|
+
unknown
|
|
155
|
+
>;
|
|
156
|
+
const method = getPipelineStageMethod(current, stage.stage);
|
|
157
|
+
|
|
158
|
+
switch (stage.stage) {
|
|
159
|
+
case 'where':
|
|
160
|
+
if (isRecord(stageArgs.condition) && typeof stageArgs.condition.operator === 'string') {
|
|
161
|
+
const op = stageArgs.condition.operator.toUpperCase();
|
|
162
|
+
const isArrayOperator =
|
|
163
|
+
op === 'IN' ||
|
|
164
|
+
op === 'NOT_IN' ||
|
|
165
|
+
op === 'ARRAY_CONTAINS_ANY' ||
|
|
166
|
+
op === 'ARRAY_CONTAINS_ALL';
|
|
167
|
+
if (isArrayOperator && !Array.isArray(stageArgs.condition.value)) {
|
|
168
|
+
throw new Error('invalid argument');
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return (
|
|
172
|
+
stageArgs.condition !== undefined
|
|
173
|
+
? method.call(current, stageArgs.condition)
|
|
174
|
+
: method.call(current, stageArgs)
|
|
175
|
+
) as WebPipelineInstance;
|
|
176
|
+
case 'select':
|
|
177
|
+
return (
|
|
178
|
+
Array.isArray(stageArgs.selections)
|
|
179
|
+
? method.call(current, ...stageArgs.selections)
|
|
180
|
+
: method.call(current, stageArgs)
|
|
181
|
+
) as WebPipelineInstance;
|
|
182
|
+
case 'addFields':
|
|
183
|
+
return (
|
|
184
|
+
Array.isArray(stageArgs.fields)
|
|
185
|
+
? method.call(current, ...stageArgs.fields)
|
|
186
|
+
: method.call(current, stageArgs)
|
|
187
|
+
) as WebPipelineInstance;
|
|
188
|
+
case 'removeFields':
|
|
189
|
+
return (
|
|
190
|
+
Array.isArray(stageArgs.fields)
|
|
191
|
+
? method.call(current, ...stageArgs.fields)
|
|
192
|
+
: method.call(current, stageArgs)
|
|
193
|
+
) as WebPipelineInstance;
|
|
194
|
+
case 'sort':
|
|
195
|
+
return (
|
|
196
|
+
Array.isArray(stageArgs.orderings)
|
|
197
|
+
? method.call(current, ...stageArgs.orderings)
|
|
198
|
+
: method.call(current, stageArgs)
|
|
199
|
+
) as WebPipelineInstance;
|
|
200
|
+
case 'limit':
|
|
201
|
+
return (
|
|
202
|
+
typeof stageArgs.limit === 'number'
|
|
203
|
+
? method.call(current, stageArgs.limit)
|
|
204
|
+
: method.call(current, stageArgs)
|
|
205
|
+
) as WebPipelineInstance;
|
|
206
|
+
case 'offset':
|
|
207
|
+
return (
|
|
208
|
+
typeof stageArgs.offset === 'number'
|
|
209
|
+
? method.call(current, stageArgs.offset)
|
|
210
|
+
: method.call(current, stageArgs)
|
|
211
|
+
) as WebPipelineInstance;
|
|
212
|
+
case 'distinct':
|
|
213
|
+
return (
|
|
214
|
+
Array.isArray(stageArgs.groups)
|
|
215
|
+
? method.call(current, ...stageArgs.groups)
|
|
216
|
+
: method.call(current, stageArgs)
|
|
217
|
+
) as WebPipelineInstance;
|
|
218
|
+
case 'aggregate':
|
|
219
|
+
return method.call(current, stageArgs) as WebPipelineInstance;
|
|
220
|
+
case 'replaceWith':
|
|
221
|
+
return (
|
|
222
|
+
stageArgs.map !== undefined
|
|
223
|
+
? method.call(current, stageArgs.map)
|
|
224
|
+
: method.call(current, stageArgs)
|
|
225
|
+
) as WebPipelineInstance;
|
|
226
|
+
case 'sample':
|
|
227
|
+
return (
|
|
228
|
+
typeof stageArgs.documents === 'number'
|
|
229
|
+
? method.call(current, stageArgs.documents)
|
|
230
|
+
: method.call(current, stageArgs)
|
|
231
|
+
) as WebPipelineInstance;
|
|
232
|
+
case 'unnest':
|
|
233
|
+
return (
|
|
234
|
+
stageArgs.selectable !== undefined
|
|
235
|
+
? method.call(current, stageArgs.selectable, stageArgs.indexField)
|
|
236
|
+
: method.call(current, stageArgs)
|
|
237
|
+
) as WebPipelineInstance;
|
|
238
|
+
case 'rawStage':
|
|
239
|
+
return (
|
|
240
|
+
typeof stageArgs.name === 'string'
|
|
241
|
+
? method.call(
|
|
242
|
+
current,
|
|
243
|
+
stageArgs.name,
|
|
244
|
+
stageArgs.params,
|
|
245
|
+
isRecord(stageArgs.options) ? stageArgs.options : undefined,
|
|
246
|
+
)
|
|
247
|
+
: method.call(current, stageArgs)
|
|
248
|
+
) as WebPipelineInstance;
|
|
249
|
+
default:
|
|
250
|
+
return method.call(current, stageArgs) as WebPipelineInstance;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function buildSourcePipeline(
|
|
255
|
+
firestore: Firestore,
|
|
256
|
+
pipelineFactory: () => unknown,
|
|
257
|
+
pipeline: FirestorePipelineSerializedInternal,
|
|
258
|
+
): WebPipelineInstance {
|
|
259
|
+
const pipelineSource = pipelineFactory.call(firestore) as WebPipelineSource;
|
|
260
|
+
const source = pipeline.source;
|
|
261
|
+
let currentPipeline: WebPipelineInstance | undefined;
|
|
262
|
+
|
|
263
|
+
switch (source.source) {
|
|
264
|
+
case 'collection':
|
|
265
|
+
currentPipeline = buildCollectionSourcePipeline(pipelineSource, source);
|
|
266
|
+
break;
|
|
267
|
+
case 'collectionGroup':
|
|
268
|
+
currentPipeline = buildCollectionGroupSourcePipeline(pipelineSource, source);
|
|
269
|
+
break;
|
|
270
|
+
case 'database':
|
|
271
|
+
currentPipeline = buildDatabaseSourcePipeline(pipelineSource, source);
|
|
272
|
+
break;
|
|
273
|
+
case 'documents':
|
|
274
|
+
currentPipeline = buildDocumentsSourcePipeline(pipelineSource, source);
|
|
275
|
+
break;
|
|
276
|
+
case 'query':
|
|
277
|
+
currentPipeline = buildQuerySourcePipeline(firestore, pipelineSource, source);
|
|
278
|
+
break;
|
|
279
|
+
default:
|
|
280
|
+
throw new Error('pipelineExecute() received an unknown source type.');
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (!currentPipeline) {
|
|
284
|
+
throw new Error(
|
|
285
|
+
`pipelineExecute() failed to construct source stage "${String(source.source)}" for web SDK.`,
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return currentPipeline;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
type PipelineBuildFrame = {
|
|
293
|
+
kind: 'pipeline';
|
|
294
|
+
pipeline: FirestorePipelineSerializedInternal;
|
|
295
|
+
currentPipeline: WebPipelineInstance;
|
|
296
|
+
stageIndex: number;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
type UnionBuildFrame = {
|
|
300
|
+
kind: 'union';
|
|
301
|
+
parent: PipelineBuildFrame;
|
|
302
|
+
stage: Extract<FirestorePipelineSerializedInternal['stages'][number], { stage: 'union' }>;
|
|
303
|
+
method: (this: WebPipelineInstance, ...args: unknown[]) => unknown;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export function buildWebSdkPipeline(
|
|
307
|
+
firestore: Firestore,
|
|
308
|
+
request: Pick<WebParsedPipelineRequest, 'pipeline'>,
|
|
309
|
+
): WebPipelineInstance {
|
|
310
|
+
const pipelineFactory = (firestore as { pipeline?: () => unknown }).pipeline;
|
|
311
|
+
if (typeof pipelineFactory !== 'function') {
|
|
312
|
+
throw createPipelineRuntimeImportError(
|
|
313
|
+
'pipelineExecute() expected a Firestore instance with pipeline() support.',
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const stack: Array<PipelineBuildFrame | UnionBuildFrame> = [
|
|
318
|
+
{
|
|
319
|
+
kind: 'pipeline',
|
|
320
|
+
pipeline: request.pipeline,
|
|
321
|
+
currentPipeline: buildSourcePipeline(firestore, pipelineFactory, request.pipeline),
|
|
322
|
+
stageIndex: 0,
|
|
323
|
+
},
|
|
324
|
+
];
|
|
325
|
+
let lastCompletedPipeline: WebPipelineInstance | undefined;
|
|
326
|
+
|
|
327
|
+
while (stack.length > 0) {
|
|
328
|
+
const frame = stack[stack.length - 1]!;
|
|
329
|
+
|
|
330
|
+
if (frame.kind === 'union') {
|
|
331
|
+
if (!lastCompletedPipeline) {
|
|
332
|
+
throw new Error('pipelineExecute() failed to rebuild nested union pipeline for web SDK.');
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
frame.parent.currentPipeline = frame.method.call(frame.parent.currentPipeline, {
|
|
336
|
+
other: lastCompletedPipeline,
|
|
337
|
+
}) as WebPipelineInstance;
|
|
338
|
+
frame.parent.stageIndex += 1;
|
|
339
|
+
lastCompletedPipeline = undefined;
|
|
340
|
+
stack.pop();
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (frame.stageIndex >= frame.pipeline.stages.length) {
|
|
345
|
+
lastCompletedPipeline = frame.currentPipeline;
|
|
346
|
+
stack.pop();
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const stage = frame.pipeline.stages[frame.stageIndex]!;
|
|
351
|
+
if (stage.stage !== 'union') {
|
|
352
|
+
frame.currentPipeline = applyPipelineStage(frame.currentPipeline, stage);
|
|
353
|
+
frame.stageIndex += 1;
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const unionPipeline = stage.options.other as FirestorePipelineSerializedInternal;
|
|
358
|
+
stack.push({
|
|
359
|
+
kind: 'union',
|
|
360
|
+
parent: frame,
|
|
361
|
+
stage,
|
|
362
|
+
method: getPipelineStageMethod(frame.currentPipeline, stage.stage),
|
|
363
|
+
});
|
|
364
|
+
stack.push({
|
|
365
|
+
kind: 'pipeline',
|
|
366
|
+
pipeline: unionPipeline,
|
|
367
|
+
currentPipeline: buildSourcePipeline(firestore, pipelineFactory, unionPipeline),
|
|
368
|
+
stageIndex: 0,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (!lastCompletedPipeline) {
|
|
373
|
+
throw new Error('pipelineExecute() failed to rebuild a pipeline for web SDK.');
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return lastCompletedPipeline;
|
|
377
|
+
}
|