@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
|
@@ -1,3 +1,20 @@
|
|
|
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
|
+
|
|
1
18
|
import {
|
|
2
19
|
setLogLevel,
|
|
3
20
|
connectFirestoreEmulator,
|
|
@@ -21,6 +38,11 @@ import {
|
|
|
21
38
|
writeBatch,
|
|
22
39
|
terminate,
|
|
23
40
|
} from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestore';
|
|
41
|
+
|
|
42
|
+
import type {
|
|
43
|
+
Firestore,
|
|
44
|
+
Transaction,
|
|
45
|
+
} from '@react-native-firebase/app/dist/module/internal/web/firebaseFirestore';
|
|
24
46
|
import {
|
|
25
47
|
guard,
|
|
26
48
|
getWebError,
|
|
@@ -28,60 +50,85 @@ import {
|
|
|
28
50
|
} from '@react-native-firebase/app/dist/module/internal/web/utils';
|
|
29
51
|
import { objectToWriteable, readableToObject, parseDocumentBatches } from './convert';
|
|
30
52
|
import { buildQuery } from './query';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
import type { FilterSpec, OrderSpec, QueryOptions } from './query';
|
|
54
|
+
import type {
|
|
55
|
+
FirestorePipelineExecuteOptionsInternal,
|
|
56
|
+
FirestorePipelineSnapshotInternal,
|
|
57
|
+
FirestorePipelineSerializedInternal,
|
|
58
|
+
} from '../types/internal';
|
|
59
|
+
import { executeWebSdkPipeline } from './pipelines/pipeline';
|
|
60
|
+
|
|
61
|
+
function rejectWithCodeAndMessage(code: string, message: string): Promise<never> {
|
|
62
|
+
return Promise.reject(getWebError({ code, message } as Error & { code: string }));
|
|
39
63
|
}
|
|
40
64
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
65
|
+
type DocumentSnapshotLike = {
|
|
66
|
+
exists(): boolean;
|
|
67
|
+
ref: { path: string };
|
|
68
|
+
data(): Record<string, unknown> | undefined;
|
|
69
|
+
};
|
|
44
70
|
|
|
45
|
-
|
|
46
|
-
|
|
71
|
+
function documentSnapshotToObject(snapshot: DocumentSnapshotLike): {
|
|
72
|
+
path: string;
|
|
73
|
+
exists: boolean;
|
|
74
|
+
data?: unknown;
|
|
75
|
+
metadata: [boolean, boolean];
|
|
76
|
+
} {
|
|
77
|
+
const exists = snapshot.exists();
|
|
78
|
+
const out: {
|
|
79
|
+
path: string;
|
|
80
|
+
exists: boolean;
|
|
81
|
+
data?: unknown;
|
|
82
|
+
metadata: [boolean, boolean];
|
|
83
|
+
} = {
|
|
84
|
+
metadata: [false, false],
|
|
47
85
|
path: snapshot.ref.path,
|
|
48
86
|
exists,
|
|
49
87
|
};
|
|
50
|
-
|
|
51
88
|
if (exists) {
|
|
52
|
-
out.data = objectToWriteable(snapshot.data()
|
|
89
|
+
out.data = objectToWriteable(snapshot.data() ?? {});
|
|
53
90
|
}
|
|
54
|
-
|
|
55
91
|
return out;
|
|
56
92
|
}
|
|
57
93
|
|
|
58
|
-
|
|
59
|
-
|
|
94
|
+
function querySnapshotToObject(snapshot: { docs: DocumentSnapshotLike[] }): {
|
|
95
|
+
source: string;
|
|
96
|
+
excludesMetadataChanges: boolean;
|
|
97
|
+
changes: unknown[];
|
|
98
|
+
metadata: [boolean, boolean];
|
|
99
|
+
documents: Array<ReturnType<typeof documentSnapshotToObject>>;
|
|
100
|
+
} {
|
|
60
101
|
return {
|
|
61
102
|
source: 'get',
|
|
62
|
-
excludesMetadataChanges: true,
|
|
103
|
+
excludesMetadataChanges: true,
|
|
63
104
|
changes: [],
|
|
64
|
-
metadata: [false, false],
|
|
105
|
+
metadata: [false, false],
|
|
65
106
|
documents: snapshot.docs.map(documentSnapshotToObject),
|
|
66
107
|
};
|
|
67
108
|
}
|
|
68
109
|
|
|
69
|
-
const emulatorForApp = {};
|
|
70
|
-
const firestoreInstances = {};
|
|
71
|
-
const appInstances = {};
|
|
72
|
-
const transactionHandler = {};
|
|
73
|
-
const transactionBuffer = {};
|
|
110
|
+
const emulatorForApp: Record<string, { host: string; port: number }> = {};
|
|
111
|
+
const firestoreInstances: Record<string, Firestore> = {};
|
|
112
|
+
const appInstances: Record<string, ReturnType<typeof getApp>> = {};
|
|
113
|
+
const transactionHandler: Record<number, Transaction> = {};
|
|
114
|
+
const transactionBuffer: Record<number, TransactionCommand[]> = {};
|
|
115
|
+
|
|
116
|
+
interface TransactionCommand {
|
|
117
|
+
path: string;
|
|
118
|
+
type: string;
|
|
119
|
+
data?: Record<string, unknown>;
|
|
120
|
+
options?: Record<string, unknown>;
|
|
121
|
+
}
|
|
74
122
|
|
|
75
|
-
function getCachedAppInstance(appName) {
|
|
123
|
+
function getCachedAppInstance(appName: string): ReturnType<typeof getApp> {
|
|
76
124
|
return (appInstances[appName] ??= getApp(appName));
|
|
77
125
|
}
|
|
78
126
|
|
|
79
|
-
function createFirestoreKey(appName, databaseId) {
|
|
127
|
+
function createFirestoreKey(appName: string, databaseId: string): string {
|
|
80
128
|
return `${appName}:${databaseId}`;
|
|
81
129
|
}
|
|
82
130
|
|
|
83
|
-
|
|
84
|
-
function getCachedFirestoreInstance(appName, databaseId) {
|
|
131
|
+
function getCachedFirestoreInstance(appName: string, databaseId: string): Firestore {
|
|
85
132
|
const firestoreKey = createFirestoreKey(appName, databaseId);
|
|
86
133
|
let instance = firestoreInstances[firestoreKey];
|
|
87
134
|
if (!instance) {
|
|
@@ -99,11 +146,7 @@ function getCachedFirestoreInstance(appName, databaseId) {
|
|
|
99
146
|
}
|
|
100
147
|
|
|
101
148
|
export default {
|
|
102
|
-
|
|
103
|
-
* Sets the log level for Firestore.
|
|
104
|
-
* @param {string} logLevel - The log level.
|
|
105
|
-
*/
|
|
106
|
-
async setLogLevel(logLevel) {
|
|
149
|
+
async setLogLevel(logLevel: string): Promise<void> {
|
|
107
150
|
if (logLevel === 'debug' || logLevel === 'error') {
|
|
108
151
|
setLogLevel(logLevel);
|
|
109
152
|
} else {
|
|
@@ -111,77 +154,57 @@ export default {
|
|
|
111
154
|
}
|
|
112
155
|
},
|
|
113
156
|
|
|
114
|
-
loadBundle() {
|
|
157
|
+
loadBundle(): Promise<never> {
|
|
115
158
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
116
159
|
},
|
|
117
160
|
|
|
118
|
-
clearPersistence() {
|
|
161
|
+
clearPersistence(): Promise<never> {
|
|
119
162
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
120
163
|
},
|
|
121
164
|
|
|
122
|
-
|
|
123
|
-
* Waits for all pending writes to be acknowledged by the backend.
|
|
124
|
-
* Noop in the lite SDK.
|
|
125
|
-
* @returns {Promise<null>} An empty promise.
|
|
126
|
-
*/
|
|
127
|
-
async waitForPendingWrites() {
|
|
165
|
+
async waitForPendingWrites(): Promise<null> {
|
|
128
166
|
return null;
|
|
129
167
|
},
|
|
130
168
|
|
|
131
|
-
disableNetwork() {
|
|
169
|
+
disableNetwork(): Promise<never> {
|
|
132
170
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
133
171
|
},
|
|
134
172
|
|
|
135
|
-
enableNetwork() {
|
|
173
|
+
enableNetwork(): Promise<never> {
|
|
136
174
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
137
175
|
},
|
|
138
176
|
|
|
139
|
-
addSnapshotsInSync() {
|
|
177
|
+
addSnapshotsInSync(): Promise<never> {
|
|
140
178
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
141
179
|
},
|
|
142
180
|
|
|
143
|
-
removeSnapshotsInSync() {
|
|
181
|
+
removeSnapshotsInSync(): Promise<never> {
|
|
144
182
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
145
183
|
},
|
|
146
184
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
* @param {string} appName - The app name.
|
|
150
|
-
* @param {string} databaseId - The database ID.
|
|
151
|
-
* @param {string} host - The emulator host.
|
|
152
|
-
* @param {number} port - The emulator port.
|
|
153
|
-
* @returns {Promise<null>} An empty promise.
|
|
154
|
-
*/
|
|
155
|
-
useEmulator(appName, databaseId, host, port) {
|
|
156
|
-
return guard(async () => {
|
|
185
|
+
useEmulator(appName: string, databaseId: string, host: string, port: number): Promise<null> {
|
|
186
|
+
return guard(async (): Promise<null> => {
|
|
157
187
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
158
188
|
connectFirestoreEmulator(firestore, host, port);
|
|
159
189
|
const firestoreKey = createFirestoreKey(appName, databaseId);
|
|
160
190
|
emulatorForApp[firestoreKey] = { host, port };
|
|
191
|
+
return null;
|
|
161
192
|
});
|
|
162
193
|
},
|
|
163
194
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
settings(appName, databaseId, settings) {
|
|
172
|
-
return guard(() => {
|
|
173
|
-
const instance = initializeFirestore(getCachedAppInstance(appName), settings, databaseId);
|
|
195
|
+
settings(appName: string, databaseId: string, settings: object): Promise<null> {
|
|
196
|
+
return guard(async (): Promise<null> => {
|
|
197
|
+
const instance = initializeFirestore(
|
|
198
|
+
getCachedAppInstance(appName),
|
|
199
|
+
settings as Parameters<typeof initializeFirestore>[1],
|
|
200
|
+
databaseId,
|
|
201
|
+
);
|
|
174
202
|
firestoreInstances[appName] = instance;
|
|
203
|
+
return null;
|
|
175
204
|
});
|
|
176
205
|
},
|
|
177
206
|
|
|
178
|
-
|
|
179
|
-
* Terminates a Firestore instance.
|
|
180
|
-
* @param {string} appName - The app name.
|
|
181
|
-
* @param {string} databaseId - The database ID.
|
|
182
|
-
* @returns {Promise<null>} An empty promise.
|
|
183
|
-
*/
|
|
184
|
-
terminate(appName, databaseId) {
|
|
207
|
+
terminate(appName: string, databaseId: string): Promise<null> {
|
|
185
208
|
return guard(async () => {
|
|
186
209
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
187
210
|
await terminate(firestore);
|
|
@@ -189,146 +212,147 @@ export default {
|
|
|
189
212
|
});
|
|
190
213
|
},
|
|
191
214
|
|
|
192
|
-
|
|
193
|
-
namedQueryOnSnapshot() {
|
|
215
|
+
namedQueryOnSnapshot(): Promise<never> {
|
|
194
216
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
195
217
|
},
|
|
196
218
|
|
|
197
|
-
collectionOnSnapshot() {
|
|
219
|
+
collectionOnSnapshot(): Promise<never> {
|
|
198
220
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
199
221
|
},
|
|
200
222
|
|
|
201
|
-
collectionOffSnapshot() {
|
|
223
|
+
collectionOffSnapshot(): Promise<never> {
|
|
202
224
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
203
225
|
},
|
|
204
226
|
|
|
205
|
-
namedQueryGet() {
|
|
227
|
+
namedQueryGet(): Promise<never> {
|
|
206
228
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
207
229
|
},
|
|
208
230
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
* @returns {Promise<object>} The collection count object.
|
|
219
|
-
*/
|
|
220
|
-
collectionCount(appName, databaseId, path, type, filters, orders, options) {
|
|
231
|
+
collectionCount(
|
|
232
|
+
appName: string,
|
|
233
|
+
databaseId: string,
|
|
234
|
+
path: string,
|
|
235
|
+
type: string,
|
|
236
|
+
filters: FilterSpec[],
|
|
237
|
+
orders: OrderSpec[],
|
|
238
|
+
options: QueryOptions,
|
|
239
|
+
): Promise<{ count: number }> {
|
|
221
240
|
return guard(async () => {
|
|
222
241
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
223
242
|
const queryRef =
|
|
224
243
|
type === 'collectionGroup' ? collectionGroup(firestore, path) : collection(firestore, path);
|
|
225
244
|
const query = buildQuery(queryRef, filters, orders, options);
|
|
226
245
|
const snapshot = await getCount(query);
|
|
227
|
-
|
|
228
|
-
return {
|
|
229
|
-
count: snapshot.data().count,
|
|
230
|
-
};
|
|
246
|
+
return { count: snapshot.data().count };
|
|
231
247
|
});
|
|
232
248
|
},
|
|
233
249
|
|
|
234
|
-
aggregateQuery(
|
|
250
|
+
aggregateQuery(
|
|
251
|
+
appName: string,
|
|
252
|
+
databaseId: string,
|
|
253
|
+
path: string,
|
|
254
|
+
type: string,
|
|
255
|
+
filters: FilterSpec[],
|
|
256
|
+
orders: OrderSpec[],
|
|
257
|
+
options: QueryOptions,
|
|
258
|
+
aggregateQueries: Array<{ aggregateType: string; field?: unknown; key: string }>,
|
|
259
|
+
): Promise<Record<string, unknown>> {
|
|
235
260
|
return guard(async () => {
|
|
236
261
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
237
262
|
const queryRef =
|
|
238
263
|
type === 'collectionGroup' ? collectionGroup(firestore, path) : collection(firestore, path);
|
|
239
264
|
const query = buildQuery(queryRef, filters, orders, options);
|
|
240
|
-
const aggregateSpec = {};
|
|
265
|
+
const aggregateSpec: Record<string, unknown> = {};
|
|
241
266
|
|
|
242
267
|
for (let i = 0; i < aggregateQueries.length; i++) {
|
|
243
|
-
const aggregateQuery = aggregateQueries[i]
|
|
268
|
+
const aggregateQuery = aggregateQueries[i]!;
|
|
244
269
|
const { aggregateType, field, key } = aggregateQuery;
|
|
245
|
-
|
|
246
270
|
switch (aggregateType) {
|
|
247
271
|
case 'count':
|
|
248
272
|
aggregateSpec[key] = count();
|
|
249
273
|
break;
|
|
250
|
-
case '
|
|
251
|
-
aggregateSpec[key] = average(field);
|
|
274
|
+
case 'avg':
|
|
275
|
+
aggregateSpec[key] = average(field as Parameters<typeof average>[0]);
|
|
252
276
|
break;
|
|
253
277
|
case 'sum':
|
|
254
|
-
aggregateSpec[key] = sum(field);
|
|
278
|
+
aggregateSpec[key] = sum(field as Parameters<typeof sum>[0]);
|
|
255
279
|
break;
|
|
256
280
|
}
|
|
257
281
|
}
|
|
258
|
-
const result = await getAggregate(query, aggregateSpec);
|
|
259
|
-
|
|
282
|
+
const result = await getAggregate(query, aggregateSpec as Parameters<typeof getAggregate>[1]);
|
|
260
283
|
const data = result.data();
|
|
261
|
-
const response = {};
|
|
284
|
+
const response: Record<string, unknown> = {};
|
|
262
285
|
for (let i = 0; i < aggregateQueries.length; i++) {
|
|
263
|
-
const aggregateQuery = aggregateQueries[i]
|
|
264
|
-
|
|
265
|
-
response[key] = data[key];
|
|
286
|
+
const aggregateQuery = aggregateQueries[i]!;
|
|
287
|
+
response[aggregateQuery.key] = data[aggregateQuery.key];
|
|
266
288
|
}
|
|
267
|
-
|
|
268
289
|
return response;
|
|
269
290
|
});
|
|
270
291
|
},
|
|
271
292
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
collectionGet(
|
|
285
|
-
|
|
293
|
+
pipelineExecute(
|
|
294
|
+
appName: string,
|
|
295
|
+
databaseId: string,
|
|
296
|
+
pipeline: FirestorePipelineSerializedInternal,
|
|
297
|
+
options?: FirestorePipelineExecuteOptionsInternal,
|
|
298
|
+
): Promise<FirestorePipelineSnapshotInternal> {
|
|
299
|
+
return guard(async () => {
|
|
300
|
+
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
301
|
+
return executeWebSdkPipeline(firestore, pipeline, options);
|
|
302
|
+
});
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
collectionGet(
|
|
306
|
+
appName: string,
|
|
307
|
+
databaseId: string,
|
|
308
|
+
path: string,
|
|
309
|
+
type: string,
|
|
310
|
+
filters: FilterSpec[],
|
|
311
|
+
orders: OrderSpec[],
|
|
312
|
+
options: QueryOptions,
|
|
313
|
+
getOptions?: { source?: string },
|
|
314
|
+
): Promise<ReturnType<typeof querySnapshotToObject>> {
|
|
315
|
+
if (getOptions?.source === 'cache') {
|
|
286
316
|
return rejectWithCodeAndMessage(
|
|
287
317
|
'unsupported',
|
|
288
318
|
'The source cache is not supported in the lite SDK.',
|
|
289
319
|
);
|
|
290
320
|
}
|
|
291
|
-
|
|
292
321
|
return guard(async () => {
|
|
293
322
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
294
323
|
const queryRef =
|
|
295
324
|
type === 'collectionGroup' ? collectionGroup(firestore, path) : collection(firestore, path);
|
|
296
325
|
const query = buildQuery(queryRef, filters, orders, options);
|
|
297
326
|
const snapshot = await getDocs(query);
|
|
298
|
-
return querySnapshotToObject(snapshot);
|
|
327
|
+
return querySnapshotToObject(snapshot as { docs: DocumentSnapshotLike[] });
|
|
299
328
|
});
|
|
300
329
|
},
|
|
301
330
|
|
|
302
|
-
|
|
303
|
-
documentOnSnapshot() {
|
|
331
|
+
documentOnSnapshot(): Promise<never> {
|
|
304
332
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
305
333
|
},
|
|
306
334
|
|
|
307
|
-
documentOffSnapshot() {
|
|
335
|
+
documentOffSnapshot(): Promise<never> {
|
|
308
336
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
309
337
|
},
|
|
310
338
|
|
|
311
|
-
persistenceCacheIndexManager() {
|
|
339
|
+
persistenceCacheIndexManager(): Promise<never> {
|
|
312
340
|
return rejectWithCodeAndMessage('unsupported', 'Not supported in the lite SDK.');
|
|
313
341
|
},
|
|
314
342
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
* @returns {Promise<object>} The document object.
|
|
322
|
-
*/
|
|
323
|
-
documentGet(appName, databaseId, path, getOptions) {
|
|
343
|
+
documentGet(
|
|
344
|
+
appName: string,
|
|
345
|
+
databaseId: string,
|
|
346
|
+
path: string,
|
|
347
|
+
getOptions?: { source?: string },
|
|
348
|
+
): Promise<ReturnType<typeof documentSnapshotToObject>> {
|
|
324
349
|
return guard(async () => {
|
|
325
|
-
if (getOptions
|
|
350
|
+
if (getOptions?.source === 'cache') {
|
|
326
351
|
return rejectWithCodeAndMessage(
|
|
327
352
|
'unsupported',
|
|
328
353
|
'The source cache is not supported in the lite SDK.',
|
|
329
354
|
);
|
|
330
355
|
}
|
|
331
|
-
|
|
332
356
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
333
357
|
const ref = doc(firestore, path);
|
|
334
358
|
const snapshot = await getDoc(ref);
|
|
@@ -336,14 +360,7 @@ export default {
|
|
|
336
360
|
});
|
|
337
361
|
},
|
|
338
362
|
|
|
339
|
-
|
|
340
|
-
* Delete a document from Firestore.
|
|
341
|
-
* @param {string} appName - The app name.
|
|
342
|
-
* @param {string} databaseId - The database ID.
|
|
343
|
-
* @param {string} path - The document path.
|
|
344
|
-
* @returns {Promise<null>} An empty promise.
|
|
345
|
-
*/
|
|
346
|
-
documentDelete(appName, databaseId, path) {
|
|
363
|
+
documentDelete(appName: string, databaseId: string, path: string): Promise<null> {
|
|
347
364
|
return guard(async () => {
|
|
348
365
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
349
366
|
const ref = doc(firestore, path);
|
|
@@ -352,38 +369,32 @@ export default {
|
|
|
352
369
|
});
|
|
353
370
|
},
|
|
354
371
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
* @returns {Promise<null>} An empty promise.
|
|
363
|
-
*/
|
|
364
|
-
documentSet(appName, databaseId, path, data, options) {
|
|
372
|
+
documentSet(
|
|
373
|
+
appName: string,
|
|
374
|
+
databaseId: string,
|
|
375
|
+
path: string,
|
|
376
|
+
data: Record<string, unknown>,
|
|
377
|
+
options: Record<string, unknown>,
|
|
378
|
+
): Promise<void> {
|
|
365
379
|
return guard(async () => {
|
|
366
380
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
367
381
|
const ref = doc(firestore, path);
|
|
368
|
-
const setOptions = {};
|
|
369
|
-
if ('merge' in options) {
|
|
382
|
+
const setOptions: Record<string, unknown> = {};
|
|
383
|
+
if (options && 'merge' in options) {
|
|
370
384
|
setOptions.merge = options.merge;
|
|
371
|
-
} else if ('mergeFields' in options) {
|
|
385
|
+
} else if (options && 'mergeFields' in options) {
|
|
372
386
|
setOptions.mergeFields = options.mergeFields;
|
|
373
387
|
}
|
|
374
388
|
await setDoc(ref, readableToObject(firestore, data), setOptions);
|
|
375
389
|
});
|
|
376
390
|
},
|
|
377
391
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
* @returns {Promise<null>} An empty promise.
|
|
385
|
-
*/
|
|
386
|
-
documentUpdate(appName, databaseId, path, data) {
|
|
392
|
+
documentUpdate(
|
|
393
|
+
appName: string,
|
|
394
|
+
databaseId: string,
|
|
395
|
+
path: string,
|
|
396
|
+
data: Record<string, unknown>,
|
|
397
|
+
): Promise<void> {
|
|
387
398
|
return guard(async () => {
|
|
388
399
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
389
400
|
const ref = doc(firestore, path);
|
|
@@ -391,13 +402,11 @@ export default {
|
|
|
391
402
|
});
|
|
392
403
|
},
|
|
393
404
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
*/
|
|
400
|
-
documentBatch(appName, databaseId, writes) {
|
|
405
|
+
documentBatch(
|
|
406
|
+
appName: string,
|
|
407
|
+
databaseId: string,
|
|
408
|
+
writes: Array<Record<string, unknown>>,
|
|
409
|
+
): Promise<void> {
|
|
401
410
|
return guard(async () => {
|
|
402
411
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
403
412
|
const batch = writeBatch(firestore);
|
|
@@ -412,87 +421,67 @@ export default {
|
|
|
412
421
|
batch.delete(ref);
|
|
413
422
|
break;
|
|
414
423
|
case 'UPDATE':
|
|
415
|
-
batch.update(ref, parsed.data);
|
|
424
|
+
batch.update(ref, parsed.data!);
|
|
416
425
|
break;
|
|
417
|
-
case 'SET':
|
|
418
|
-
const options = parsed.options;
|
|
419
|
-
const setOptions = {};
|
|
426
|
+
case 'SET': {
|
|
427
|
+
const options = parsed.options ?? {};
|
|
428
|
+
const setOptions: Record<string, unknown> = {};
|
|
420
429
|
if ('merge' in options) {
|
|
421
430
|
setOptions.merge = options.merge;
|
|
422
431
|
} else if ('mergeFields' in options) {
|
|
423
432
|
setOptions.mergeFields = options.mergeFields;
|
|
424
433
|
}
|
|
425
|
-
batch.set(ref, parsed.data
|
|
434
|
+
batch.set(ref, parsed.data!, setOptions);
|
|
426
435
|
break;
|
|
436
|
+
}
|
|
427
437
|
}
|
|
428
438
|
}
|
|
429
|
-
|
|
430
439
|
await batch.commit();
|
|
431
440
|
});
|
|
432
441
|
},
|
|
433
442
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
* @returns {Promise<object>} The document object.
|
|
441
|
-
*/
|
|
442
|
-
transactionGetDocument(appName, databaseId, transactionId, path) {
|
|
443
|
+
transactionGetDocument(
|
|
444
|
+
appName: string,
|
|
445
|
+
databaseId: string,
|
|
446
|
+
transactionId: number,
|
|
447
|
+
path: string,
|
|
448
|
+
): Promise<ReturnType<typeof documentSnapshotToObject>> {
|
|
443
449
|
if (!transactionHandler[transactionId]) {
|
|
444
450
|
return rejectWithCodeAndMessage(
|
|
445
451
|
'internal-error',
|
|
446
452
|
'An internal error occurred whilst attempting to find a native transaction by id.',
|
|
447
453
|
);
|
|
448
454
|
}
|
|
449
|
-
|
|
450
455
|
return guard(async () => {
|
|
451
456
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
452
457
|
const docRef = doc(firestore, path);
|
|
453
|
-
const tsx = transactionHandler[transactionId]
|
|
458
|
+
const tsx = transactionHandler[transactionId]!;
|
|
454
459
|
const snapshot = await tsx.get(docRef);
|
|
455
460
|
return documentSnapshotToObject(snapshot);
|
|
456
461
|
});
|
|
457
462
|
},
|
|
458
463
|
|
|
459
|
-
|
|
460
|
-
* Dispose a transaction instance.
|
|
461
|
-
* @param {string} appName - The app name.
|
|
462
|
-
* @param {string} databaseId - The database ID.
|
|
463
|
-
* @param {string} transactionId - The transaction id.
|
|
464
|
-
*/
|
|
465
|
-
transactionDispose(_appName, _databaseId, transactionId) {
|
|
466
|
-
// There's no abort method in the JS SDK, so we just remove the transaction handler.
|
|
464
|
+
transactionDispose(_appName: string, _databaseId: string, transactionId: number): void {
|
|
467
465
|
delete transactionHandler[transactionId];
|
|
468
466
|
},
|
|
469
467
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
*/
|
|
477
|
-
transactionApplyBuffer(_appName, _databaseId, transactionId, commandBuffer) {
|
|
468
|
+
transactionApplyBuffer(
|
|
469
|
+
_appName: string,
|
|
470
|
+
_databaseId: string,
|
|
471
|
+
transactionId: number,
|
|
472
|
+
commandBuffer: TransactionCommand[],
|
|
473
|
+
): void {
|
|
478
474
|
if (transactionHandler[transactionId]) {
|
|
479
475
|
transactionBuffer[transactionId] = commandBuffer;
|
|
480
476
|
}
|
|
481
477
|
},
|
|
482
478
|
|
|
483
|
-
|
|
484
|
-
* Begins a Firestore transaction.
|
|
485
|
-
* @param {string} appName - The app name.
|
|
486
|
-
* @param {string} databaseId - The database ID.
|
|
487
|
-
* @param {string} transactionId - The transaction id.
|
|
488
|
-
* @returns {Promise<null>} An empty promise.
|
|
489
|
-
*/
|
|
490
|
-
transactionBegin(appName, databaseId, transactionId) {
|
|
479
|
+
transactionBegin(appName: string, databaseId: string, transactionId: number): Promise<void> {
|
|
491
480
|
return guard(async () => {
|
|
492
481
|
const firestore = getCachedFirestoreInstance(appName, databaseId);
|
|
493
482
|
|
|
494
483
|
try {
|
|
495
|
-
await runTransaction(firestore, async tsx => {
|
|
484
|
+
await runTransaction(firestore, async (tsx: Transaction) => {
|
|
496
485
|
transactionHandler[transactionId] = tsx;
|
|
497
486
|
|
|
498
487
|
emitEvent('firestore_transaction_event', {
|
|
@@ -503,42 +492,41 @@ export default {
|
|
|
503
492
|
listenerId: transactionId,
|
|
504
493
|
});
|
|
505
494
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
495
|
+
const getBuffer = (): TransactionCommand[] | undefined =>
|
|
496
|
+
transactionBuffer[transactionId];
|
|
509
497
|
|
|
510
|
-
|
|
511
|
-
const buffer = await new Promise(resolve => {
|
|
498
|
+
const buffer = await new Promise<TransactionCommand[]>(resolve => {
|
|
512
499
|
const interval = setInterval(() => {
|
|
513
|
-
const
|
|
514
|
-
if (
|
|
500
|
+
const b = getBuffer();
|
|
501
|
+
if (b) {
|
|
515
502
|
clearInterval(interval);
|
|
516
|
-
resolve(
|
|
503
|
+
resolve(b);
|
|
517
504
|
}
|
|
518
505
|
}, 100);
|
|
519
506
|
});
|
|
520
507
|
|
|
521
508
|
for (const serialized of buffer) {
|
|
522
|
-
const { path, type, data } = serialized;
|
|
523
|
-
const docRef = doc(firestore,
|
|
509
|
+
const { path: docPath, type, data } = serialized;
|
|
510
|
+
const docRef = doc(firestore, docPath);
|
|
524
511
|
|
|
525
512
|
switch (type) {
|
|
526
513
|
case 'DELETE':
|
|
527
514
|
tsx.delete(docRef);
|
|
528
515
|
break;
|
|
529
516
|
case 'UPDATE':
|
|
530
|
-
tsx.update(docRef, readableToObject(firestore, data));
|
|
517
|
+
tsx.update(docRef, readableToObject(firestore, data ?? {}));
|
|
531
518
|
break;
|
|
532
|
-
case 'SET':
|
|
533
|
-
const options = serialized.options;
|
|
534
|
-
const setOptions = {};
|
|
519
|
+
case 'SET': {
|
|
520
|
+
const options = serialized.options ?? {};
|
|
521
|
+
const setOptions: Record<string, unknown> = {};
|
|
535
522
|
if ('merge' in options) {
|
|
536
523
|
setOptions.merge = options.merge;
|
|
537
524
|
} else if ('mergeFields' in options) {
|
|
538
525
|
setOptions.mergeFields = options.mergeFields;
|
|
539
526
|
}
|
|
540
|
-
tsx.set(docRef, readableToObject(firestore, data), setOptions);
|
|
527
|
+
tsx.set(docRef, readableToObject(firestore, data ?? {}), setOptions);
|
|
541
528
|
break;
|
|
529
|
+
}
|
|
542
530
|
}
|
|
543
531
|
}
|
|
544
532
|
});
|
|
@@ -553,7 +541,7 @@ export default {
|
|
|
553
541
|
} catch (e) {
|
|
554
542
|
emitEvent('firestore_transaction_event', {
|
|
555
543
|
eventName: 'firestore_transaction_event',
|
|
556
|
-
body: { type: 'error', error: getWebError(e) },
|
|
544
|
+
body: { type: 'error', error: getWebError(e as Error) },
|
|
557
545
|
appName,
|
|
558
546
|
databaseId,
|
|
559
547
|
listenerId: transactionId,
|