diff --git a/.gitignore b/.gitignore index dc909fe4338..74607c5993b 100644 --- a/.gitignore +++ b/.gitignore @@ -155,6 +155,7 @@ FirebaseAppCheck/Apps/AppCheckCustomProvideApp/AppCheckCustomProvideApp/GoogleSe /Example/FirestoreSample/ui-debug.log /Example/FirestoreSample/firestore-debug.log /Example/FirestoreSample/firebase-debug.log +Firestore/Example/GoogleService-Info.plist # generated Terraform docs .terraform/* diff --git a/Firestore/Example/Firestore.xcodeproj/project.pbxproj b/Firestore/Example/Firestore.xcodeproj/project.pbxproj index 1146b8a5dde..abba41a6f55 100644 --- a/Firestore/Example/Firestore.xcodeproj/project.pbxproj +++ b/Firestore/Example/Firestore.xcodeproj/project.pbxproj @@ -104,7 +104,6 @@ 0E17927CE45F5E3FC6691E24 /* firebase_auth_credentials_provider_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = F869D85E900E5AF6CD02E2FC /* firebase_auth_credentials_provider_test.mm */; }; 0E4C94369FFF7EC0C9229752 /* iterator_adaptors_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54A0353420A3D8CB003E0143 /* iterator_adaptors_test.cc */; }; 0E4F266A9FDF55CD38BB6D0F /* leveldb_query_engine_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = DB1F1E1B1ED15E8D042144B1 /* leveldb_query_engine_test.cc */; }; - 0E7A39BD9C87CC33F91A672F /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 682582E5728F3F1C531990EA /* explain_stats.pb.cc */; }; 0EA40EDACC28F445F9A3F32F /* pretty_printing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB323F9553050F4F6490F9FF /* pretty_printing_test.cc */; }; 0EC3921AE220410F7394729B /* aggregation_result.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = D872D754B8AD88E28AF28B28 /* aggregation_result.pb.cc */; }; 0EDFC8A6593477E1D17CDD8F /* leveldb_bundle_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8E9CD82E60893DDD7757B798 /* leveldb_bundle_cache_test.cc */; }; @@ -127,9 +126,6 @@ 11F8EE69182C9699E90A9E3D /* database_info_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB38D92E20235D22000A432D /* database_info_test.cc */; }; 12158DFCEE09D24B7988A340 /* maybe_document.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 618BBE7E20B89AAC00B5BCE7 /* maybe_document.pb.cc */; }; 121F0FB9DCCBFB7573C7AF48 /* bundle_serializer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5C2A94EE24E60543F62CC35 /* bundle_serializer_test.cc */; }; - 12260A2A2D56A3CE001766EB /* PipelineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12260A292D56A3CE001766EB /* PipelineTests.swift */; }; - 12260A2B2D56A3CE001766EB /* PipelineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12260A292D56A3CE001766EB /* PipelineTests.swift */; }; - 12260A2C2D56A3CE001766EB /* PipelineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12260A292D56A3CE001766EB /* PipelineTests.swift */; }; 124AAEE987451820F24EEA8E /* user_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = CCC9BD953F121B9E29F9AA42 /* user_test.cc */; }; 125B1048ECB755C2106802EB /* executor_std_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6FB4687208F9B9100554BA2 /* executor_std_test.cc */; }; 1290FA77A922B76503AE407C /* lru_garbage_collector_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 277EAACC4DD7C21332E8496A /* lru_garbage_collector_test.cc */; }; @@ -233,7 +229,6 @@ 1F4930A8366F74288121F627 /* create_noop_connectivity_monitor.cc in Sources */ = {isa = PBXBuildFile; fileRef = CF39535F2C41AB0006FA6C0E /* create_noop_connectivity_monitor.cc */; }; 1F56F51EB6DF0951B1F4F85B /* lru_garbage_collector_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 277EAACC4DD7C21332E8496A /* lru_garbage_collector_test.cc */; }; 1F998DDECB54A66222CC66AA /* string_format_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54131E9620ADE678001DF3FF /* string_format_test.cc */; }; - 1F9FFAE375C88EFF88CBB6F8 /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = FAAF1A69F4A315C38357BDC4 /* field_behavior.pb.cc */; }; 1FE23E911F0761AA896FAD67 /* Validation_BloomFilterTest_MD5_500_1_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = D8E530B27D5641B9C26A452C /* Validation_BloomFilterTest_MD5_500_1_bloom_filter_proto.json */; }; 2045517602D767BD01EA71D9 /* overlay_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = E1459FA70B8FC18DE4B80D0D /* overlay_test.cc */; }; 205601D1C6A40A4DD3BBAA04 /* target_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 526D755F65AC676234F57125 /* target_test.cc */; }; @@ -300,7 +295,6 @@ 2A86AB04B38DBB770A1D8B13 /* Validation_BloomFilterTest_MD5_1_1_membership_test_result.json in Resources */ = {isa = PBXBuildFile; fileRef = 3369AC938F82A70685C5ED58 /* Validation_BloomFilterTest_MD5_1_1_membership_test_result.json */; }; 2AAEABFD550255271E3BAC91 /* to_string_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = B68B1E002213A764008977EF /* to_string_apple_test.mm */; }; 2ABA80088D70E7A58F95F7D8 /* delayed_constructor_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = D0A6E9136804A41CEC9D55D4 /* delayed_constructor_test.cc */; }; - 2AD2CB51469AE35331C39258 /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7142B5EC46E88349FAB3384F /* pipeline.pb.cc */; }; 2AD8EE91928AE68DF268BEDA /* limbo_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA129E1F315EE100DD57A1 /* limbo_spec_test.json */; }; 2AD98CD29CC6F820A74CDD5E /* Validation_BloomFilterTest_MD5_1_0001_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 4B59C0A7B2A4548496ED4E7D /* Validation_BloomFilterTest_MD5_1_0001_bloom_filter_proto.json */; }; 2AE3914BBC4EDF91BD852939 /* memory_query_engine_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8EF6A33BC2D84233C355F1D0 /* memory_query_engine_test.cc */; }; @@ -328,9 +322,11 @@ 2EC1C4D202A01A632339A161 /* field_transform_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7515B47C92ABEEC66864B55C /* field_transform_test.cc */; }; 2F3740131CC8F8230351B91D /* byte_stream_cpp_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 01D10113ECC5B446DB35E96D /* byte_stream_cpp_test.cc */; }; 2F69187F601E00054469F4A5 /* DatabaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3355BE9391CC4857AF0BDAE3 /* DatabaseTests.swift */; }; + 2F72DBE2EC6E24A81C69DEF0 /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 428662F00938E9E21F7080D7 /* explain_stats.pb.cc */; }; 2F8FDF35BBB549A6F4D2118E /* FSTMemorySpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E02F20213FFC00B64F25 /* FSTMemorySpecTests.mm */; }; 2FA0BAE32D587DF2EA5EEB97 /* async_queue_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6FB467B208E9A8200554BA2 /* async_queue_test.cc */; }; 2FAE0BCBE559ED7214AEFEB7 /* Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 0D964D4936953635AC7E0834 /* Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json */; }; + 2FC2B732841BF2C425EB35DF /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1F78CD3208A1D5885B4C134E /* field_behavior.pb.cc */; }; 3040FD156E1B7C92B0F2A70C /* ordered_code_benchmark.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0473AFFF5567E667A125347B /* ordered_code_benchmark.cc */; }; 3056418E81BC7584FBE8AD6C /* user_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = CCC9BD953F121B9E29F9AA42 /* user_test.cc */; }; 306E762DC6B829CED4FD995D /* target_id_generator_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB380CF82019382300D97691 /* target_id_generator_test.cc */; }; @@ -348,7 +344,6 @@ 32F022CB75AEE48CDDAF2982 /* mutation_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = C8522DE226C467C54E6788D8 /* mutation_test.cc */; }; 32F8B4652010E8224E353041 /* persistence_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA12A31F315EE100DD57A1 /* persistence_spec_test.json */; }; 330DE2A5AE6AF8D66C9C849F /* Validation_BloomFilterTest_MD5_5000_0001_membership_test_result.json in Resources */ = {isa = PBXBuildFile; fileRef = C8582DFD74E8060C7072104B /* Validation_BloomFilterTest_MD5_5000_0001_membership_test_result.json */; }; - 332E7D2D8489E6DA42947C59 /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = FAAF1A69F4A315C38357BDC4 /* field_behavior.pb.cc */; }; 336E415DD06E719F9C9E2A14 /* grpc_stream_tester.cc in Sources */ = {isa = PBXBuildFile; fileRef = 87553338E42B8ECA05BA987E /* grpc_stream_tester.cc */; }; 338DFD5BCD142DF6C82A0D56 /* cc_compilation_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1B342370EAE3AA02393E33EB /* cc_compilation_test.cc */; }; 339CFFD1323BDCA61EAAFE31 /* query_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B9C261C26C5D311E1E3C0CB9 /* query_test.cc */; }; @@ -388,6 +383,7 @@ 39790AC7E71BC06D48144BED /* memory_globals_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5C6DEA63FBDE19D841291723 /* memory_globals_cache_test.cc */; }; 3987A3E8534BAA496D966735 /* memory_index_manager_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = DB5A1E760451189DA36028B3 /* memory_index_manager_test.cc */; }; 39CDC9EC5FD2E891D6D49151 /* secure_random_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54740A531FC913E500713A1A /* secure_random_test.cc */; }; + 3A110ECBF96B6E44BA77011A /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1F78CD3208A1D5885B4C134E /* field_behavior.pb.cc */; }; 3A307F319553A977258BB3D6 /* view_snapshot_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = CC572A9168BBEF7B83E4BBC5 /* view_snapshot_test.cc */; }; 3A7CB01751697ED599F2D9A1 /* executor_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6FB4688208F9B9100554BA2 /* executor_test.cc */; }; 3A93D8FB318C6491A6B654F5 /* Validation_BloomFilterTest_MD5_50000_01_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 7B44DD11682C4803B73DCC34 /* Validation_BloomFilterTest_MD5_50000_01_bloom_filter_proto.json */; }; @@ -399,7 +395,6 @@ 3B256CCF6AEEE12E22F16BB8 /* hashing_test_apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = B69CF3F02227386500B281C8 /* hashing_test_apple.mm */; }; 3B37BD3C13A66625EC82CF77 /* hard_assert_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */; }; 3B47CC43DBA24434E215B8ED /* memory_index_manager_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = DB5A1E760451189DA36028B3 /* memory_index_manager_test.cc */; }; - 3B4CFB45208A7EEF1EA58ADC /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7142B5EC46E88349FAB3384F /* pipeline.pb.cc */; }; 3B5CEA04AC1627256A1AE8BA /* bloom_filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = A2E6F09AD1EE0A6A452E9A08 /* bloom_filter_test.cc */; }; 3B843E4C1F3A182900548890 /* remote_store_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 3B843E4A1F3930A400548890 /* remote_store_spec_test.json */; }; 3BA4EEA6153B3833F86B8104 /* writer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = BC3C788D290A935C353CEAA1 /* writer_test.cc */; }; @@ -409,6 +404,7 @@ 3CCABD7BB5ED39DF1140B5F0 /* leveldb_globals_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = FC44D934D4A52C790659C8D6 /* leveldb_globals_cache_test.cc */; }; 3CFFA6F016231446367E3A69 /* listen_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA12A01F315EE100DD57A1 /* listen_spec_test.json */; }; 3D22F56C0DE7C7256C75DC06 /* tree_sorted_map_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 549CCA4D20A36DBB00BCEB75 /* tree_sorted_map_test.cc */; }; + 3D5F7AA7BB68529F47BE4B12 /* PipelineApiTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59BF06E5A4988F9F949DD871 /* PipelineApiTests.swift */; }; 3D6AC48D6197E6539BBBD28F /* thread_safe_memoizer_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6E42FA109D363EA7F3387AAE /* thread_safe_memoizer_testing.cc */; }; 3D9619906F09108E34FF0C95 /* FSTSmokeTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E07C202154EB00B64F25 /* FSTSmokeTests.mm */; }; 3DBB48F077C97200F32B51A0 /* value_util_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 40F9D09063A07F710811A84F /* value_util_test.cc */; }; @@ -523,7 +519,6 @@ 50454F81EC4584D4EB5F5ED5 /* serializer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 61F72C5520BC48FD001A68CB /* serializer_test.cc */; }; 50B749CA98365368AE34B71C /* filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F02F734F272C3C70D1307076 /* filter_test.cc */; }; 50C852E08626CFA7DC889EEA /* field_index_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = BF76A8DA34B5B67B4DD74666 /* field_index_test.cc */; }; - 50EA1F41D766C92894E9B078 /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 682582E5728F3F1C531990EA /* explain_stats.pb.cc */; }; 51018EA27CF914DD1CC79CB3 /* thread_safe_memoizer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A8141230C7E3986EACEF0B6 /* thread_safe_memoizer_test.cc */; }; 513D34C9964E8C60C5C2EE1C /* leveldb_bundle_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8E9CD82E60893DDD7757B798 /* leveldb_bundle_cache_test.cc */; }; 5150E9F256E6E82D6F3CB3F1 /* bundle_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F7FC06E0A47D393DE1759AE1 /* bundle_cache_test.cc */; }; @@ -693,6 +688,7 @@ 5BE49546D57C43DDFCDB6FBD /* to_string_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = B68B1E002213A764008977EF /* to_string_apple_test.mm */; }; 5C9B5696644675636A052018 /* token_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = A082AFDD981B07B5AD78FDE8 /* token_test.cc */; }; 5CADE71A1CA6358E1599F0F9 /* hashing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54511E8D209805F8005BD28F /* hashing_test.cc */; }; + 5CDD24225992674A4D3E3D4E /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = D49E7AEE500651D25C5360C3 /* pipeline.pb.cc */; }; 5CEB0E83DA68652927D2CF07 /* memory_document_overlay_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 29D9C76922DAC6F710BC1EF4 /* memory_document_overlay_cache_test.cc */; }; 5D405BE298CE4692CB00790A /* Pods_Firestore_Tests_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B50B3A0DF77100EEE887891 /* Pods_Firestore_Tests_iOS.framework */; }; 5D45CC300ED037358EF33A8F /* snapshot_version_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABA495B9202B7E79008A7851 /* snapshot_version_test.cc */; }; @@ -741,6 +737,7 @@ 604B75044D6BEC2B7515EA1B /* index_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 8C7278B604B8799F074F4E8C /* index_spec_test.json */; }; 60985657831B8DDE2C65AC8B /* FIRFieldsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E06A202154D500B64F25 /* FIRFieldsTests.mm */; }; 60C72F86D2231B1B6592A5E6 /* filesystem_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F51859B394D01C0C507282F1 /* filesystem_test.cc */; }; + 60DA778E447F9ACD402FDA2F /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = D49E7AEE500651D25C5360C3 /* pipeline.pb.cc */; }; 6105A1365831B79A7DEEA4F3 /* path_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 403DBF6EFB541DFD01582AA3 /* path_test.cc */; }; 6141D3FDF5728FCE9CC1DBFA /* bundle_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 79EAA9F7B1B9592B5F053923 /* bundle_spec_test.json */; }; 6156C6A837D78D49ED8B8812 /* index_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 8C7278B604B8799F074F4E8C /* index_spec_test.json */; }; @@ -778,6 +775,7 @@ 64D8241E9F56973DAD3077BC /* Validation_BloomFilterTest_MD5_1_01_membership_test_result.json in Resources */ = {isa = PBXBuildFile; fileRef = 5C68EE4CB94C0DD6E333F546 /* Validation_BloomFilterTest_MD5_1_01_membership_test_result.json */; }; 650B31A5EC6F8D2AEA79C350 /* index_manager_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AE4A9E38D65688EE000EE2A1 /* index_manager_test.cc */; }; 65537B22A73E3909666FB5BC /* remote_document_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7EB299CF85034F09CFD6F3FD /* remote_document_cache_test.cc */; }; + 655F8647F57E5F2155DFF7B5 /* PipelineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 861684E49DAC993D153E60D0 /* PipelineTests.swift */; }; 658CBF4A717EA160E27C973E /* Validation_BloomFilterTest_MD5_50000_0001_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = A5D9044B72061CAF284BC9E4 /* Validation_BloomFilterTest_MD5_50000_0001_bloom_filter_proto.json */; }; 659FFE071CD0F60DAEADD50B /* bloom_filter.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1E0C7C0DCD2790019E66D8CC /* bloom_filter.pb.cc */; }; 65D54B964A2021E5A36AB21F /* bundle_loader_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = A853C81A6A5A51C9D0389EDA /* bundle_loader_test.cc */; }; @@ -792,7 +790,6 @@ 66DFEA9E324797E6EA81CBA9 /* perf_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = D5B2593BCB52957D62F1C9D3 /* perf_spec_test.json */; }; 66FAB8EAC012A3822BD4D0C9 /* leveldb_util_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 332485C4DCC6BA0DBB5E31B7 /* leveldb_util_test.cc */; }; 6711E75A10EBA662341F5C9D /* leveldb_document_overlay_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AE89CFF09C6804573841397F /* leveldb_document_overlay_cache_test.cc */; }; - 676933F59F2F0A0D221A4F8F /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 682582E5728F3F1C531990EA /* explain_stats.pb.cc */; }; 677C833244550767B71DB1BA /* log_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54C2294E1FECABAE007D065B /* log_test.cc */; }; 67B8C34BDF0FFD7532D7BE4F /* Validation_BloomFilterTest_MD5_500_0001_membership_test_result.json in Resources */ = {isa = PBXBuildFile; fileRef = 478DC75A0DCA6249A616DD30 /* Validation_BloomFilterTest_MD5_500_0001_membership_test_result.json */; }; 67BC2B77C1CC47388E79D774 /* FIRSnapshotMetadataTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E04D202154AA00B64F25 /* FIRSnapshotMetadataTests.mm */; }; @@ -850,7 +847,6 @@ 6FF2B680CC8631B06C7BD7AB /* FSTMemorySpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E02F20213FFC00B64F25 /* FSTMemorySpecTests.mm */; }; 70A171FC43BE328767D1B243 /* path_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 403DBF6EFB541DFD01582AA3 /* path_test.cc */; }; 70AB665EB6A473FF6C4CFD31 /* CodableTimestampTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B65C996438B84DBC7616640 /* CodableTimestampTests.swift */; }; - 715A0E92C83AE4384A13B882 /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7142B5EC46E88349FAB3384F /* pipeline.pb.cc */; }; 716289F99B5316B3CC5E5CE9 /* FIRSnapshotMetadataTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E04D202154AA00B64F25 /* FIRSnapshotMetadataTests.mm */; }; 71702588BFBF5D3A670508E7 /* ordered_code_benchmark.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0473AFFF5567E667A125347B /* ordered_code_benchmark.cc */; }; 71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; }; @@ -872,7 +868,6 @@ 73E42D984FB36173A2BDA57C /* FSTEventAccumulator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0392021401F00B64F25 /* FSTEventAccumulator.mm */; }; 73FE5066020EF9B2892C86BF /* hard_assert_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */; }; 743DF2DF38CE289F13F44043 /* status_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3CAA33F964042646FDDAF9F9 /* status_testing.cc */; }; - 7492C447277CDC8CB7A165CB /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 682582E5728F3F1C531990EA /* explain_stats.pb.cc */; }; 7495E3BAE536CD839EE20F31 /* FSTLevelDBSpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E02C20213FFB00B64F25 /* FSTLevelDBSpecTests.mm */; }; 74985DE2C7EF4150D7A455FD /* statusor_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54A0352D20A3B3D7003E0143 /* statusor_test.cc */; }; 74A63A931F834D1D6CF3BA9A /* Validation_BloomFilterTest_MD5_1_1_membership_test_result.json in Resources */ = {isa = PBXBuildFile; fileRef = 3369AC938F82A70685C5ED58 /* Validation_BloomFilterTest_MD5_1_1_membership_test_result.json */; }; @@ -909,6 +904,7 @@ 7AD020FC27493FF8E659436C /* existence_filter_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA129D1F315EE100DD57A1 /* existence_filter_spec_test.json */; }; 7B0EA399F899537ACCC84E53 /* string_format_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CFD366B783AE27B9E79EE7A /* string_format_apple_test.mm */; }; 7B0F073BDB6D0D6E542E23D4 /* query.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 544129D621C2DDC800EFB9CC /* query.pb.cc */; }; + 7B58861D0978827BC4CB1DFA /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1F78CD3208A1D5885B4C134E /* field_behavior.pb.cc */; }; 7B74447D211586D9D1CC82BB /* datastore_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3167BD972EFF8EC636530E59 /* datastore_test.cc */; }; 7B8320F12E8092BC86FFCC2C /* fields_array_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = BA4CBA48204C9E25B56993BC /* fields_array_test.cc */; }; 7B86B1B21FD0EF2A67547F66 /* byte_string_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5342CDDB137B4E93E2E85CCA /* byte_string_test.cc */; }; @@ -919,6 +915,7 @@ 7C1DC1B44729381126D083AE /* leveldb_snappy_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = D9D94300B9C02F7069523C00 /* leveldb_snappy_test.cc */; }; 7C5E017689012489AAB7718D /* CodableGeoPointTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5495EB022040E90200EBA509 /* CodableGeoPointTests.swift */; }; 7C7BA1DB0B66EB899A928283 /* hashing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54511E8D209805F8005BD28F /* hashing_test.cc */; }; + 7CAF0E8C47FB2DD486240D47 /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 428662F00938E9E21F7080D7 /* explain_stats.pb.cc */; }; 7D25D41B013BB70ADE526055 /* target_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 526D755F65AC676234F57125 /* target_test.cc */; }; 7D320113FD076A1EF9A8B612 /* filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F02F734F272C3C70D1307076 /* filter_test.cc */; }; 7D3207DEE229EFCF16E52693 /* Validation_BloomFilterTest_MD5_500_01_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 4BD051DBE754950FEAC7A446 /* Validation_BloomFilterTest_MD5_500_01_bloom_filter_proto.json */; }; @@ -965,6 +962,7 @@ 8405FF2BFBB233031A887398 /* event_manager_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6F57521E161450FAF89075ED /* event_manager_test.cc */; }; 8413BD9958F6DD52C466D70F /* sorted_set_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 549CCA4C20A36DBB00BCEB75 /* sorted_set_test.cc */; }; 84285C3F63D916A4786724A8 /* field_index_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = BF76A8DA34B5B67B4DD74666 /* field_index_test.cc */; }; + 8429E18EFBAF473209731E01 /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = D49E7AEE500651D25C5360C3 /* pipeline.pb.cc */; }; 843EE932AA9A8F43721F189E /* leveldb_local_store_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5FF903AEFA7A3284660FA4C5 /* leveldb_local_store_test.cc */; }; 8460C97C9209D7DAF07090BD /* FIRFieldsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E06A202154D500B64F25 /* FIRFieldsTests.mm */; }; 84E75527F3739131C09BEAA5 /* target_index_matcher_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 63136A2371C0C013EC7A540C /* target_index_matcher_test.cc */; }; @@ -984,7 +982,6 @@ 8683BBC3AC7B01937606A83B /* firestore.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 544129D421C2DDC800EFB9CC /* firestore.pb.cc */; }; 86B413EC49E3BBBEBF1FB7A0 /* Validation_BloomFilterTest_MD5_500_1_membership_test_result.json in Resources */ = {isa = PBXBuildFile; fileRef = 8AB49283E544497A9C5A0E59 /* Validation_BloomFilterTest_MD5_500_1_membership_test_result.json */; }; 86E6FC2B7657C35B342E1436 /* sorted_map_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 549CCA4E20A36DBB00BCEB75 /* sorted_map_test.cc */; }; - 86E73F6286E87834CF37D5D9 /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = FAAF1A69F4A315C38357BDC4 /* field_behavior.pb.cc */; }; 8705C4856498F66E471A0997 /* FIRWriteBatchTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E06F202154D600B64F25 /* FIRWriteBatchTests.mm */; }; 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; 8778C1711059598070F86D3C /* leveldb_globals_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = FC44D934D4A52C790659C8D6 /* leveldb_globals_cache_test.cc */; }; @@ -1019,7 +1016,6 @@ 8F3AE423677A4C50F7E0E5C0 /* database_info_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB38D92E20235D22000A432D /* database_info_test.cc */; }; 8F4F40E9BC7ED588F67734D5 /* app_testing.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5467FB07203E6A44009C9584 /* app_testing.mm */; }; 8F781F527ED72DC6C123689E /* autoid_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54740A521FC913E500713A1A /* autoid_test.cc */; }; - 8FE63980976481EBA001B789 /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 682582E5728F3F1C531990EA /* explain_stats.pb.cc */; }; 9009C285F418EA80C46CF06B /* fake_target_metadata_provider.cc in Sources */ = {isa = PBXBuildFile; fileRef = 71140E5D09C6E76F7C71B2FC /* fake_target_metadata_provider.cc */; }; 900D0E9F18CE3DB954DD0D1E /* async_queue_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6FB467B208E9A8200554BA2 /* async_queue_test.cc */; }; 9012B0E121B99B9C7E54160B /* query_engine_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B8A853940305237AFDA8050B /* query_engine_test.cc */; }; @@ -1038,7 +1034,6 @@ 920B6ABF76FDB3547F1CCD84 /* firestore.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 544129D421C2DDC800EFB9CC /* firestore.pb.cc */; }; 9236478E01DF2EC7DF58B1FC /* index_backfiller_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1F50E872B3F117A674DA8E94 /* index_backfiller_test.cc */; }; 925BE64990449E93242A00A2 /* memory_mutation_queue_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 74FBEFA4FE4B12C435011763 /* memory_mutation_queue_test.cc */; }; - 92B593DCD86543D8C90F64F9 /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7142B5EC46E88349FAB3384F /* pipeline.pb.cc */; }; 92D7081085679497DC112EDB /* persistence_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9113B6F513D0473AEABBAF1F /* persistence_testing.cc */; }; 92EFF0CC2993B43CBC7A61FF /* grpc_streaming_reader_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6D964922154AB8F00EB9CFB /* grpc_streaming_reader_test.cc */; }; 9382BE7190E7750EE7CCCE7C /* write_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA12A51F315EE100DD57A1 /* write_spec_test.json */; }; @@ -1085,7 +1080,6 @@ 9C366448F9BA7A4AC0821AF7 /* bundle_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 79EAA9F7B1B9592B5F053923 /* bundle_spec_test.json */; }; 9C86EEDEA131BFD50255EEF1 /* comparison_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 548DB928200D59F600E00ABC /* comparison_test.cc */; }; 9CC32ACF397022BB7DF11B52 /* Validation_BloomFilterTest_MD5_500_0001_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = D22D4C211AC32E4F8B4883DA /* Validation_BloomFilterTest_MD5_500_0001_bloom_filter_proto.json */; }; - 9CD1E9301EC44ED10DAEA5FB /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7142B5EC46E88349FAB3384F /* pipeline.pb.cc */; }; 9CE07BAAD3D3BC5F069D38FE /* grpc_streaming_reader_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6D964922154AB8F00EB9CFB /* grpc_streaming_reader_test.cc */; }; 9CFF379C7404F7CE6B26AF29 /* listen_source_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 4D9E51DA7A275D8B1CAEAEB2 /* listen_source_spec_test.json */; }; 9D71628E38D9F64C965DF29E /* FSTAPIHelpers.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E04E202154AA00B64F25 /* FSTAPIHelpers.mm */; }; @@ -1114,6 +1108,7 @@ A25FF76DEF542E01A2DF3B0E /* time_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5497CB76229DECDE000FB92F /* time_testing.cc */; }; A27096F764227BC73526FED3 /* leveldb_remote_document_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0840319686A223CC4AD3FAB1 /* leveldb_remote_document_cache_test.cc */; }; A27908A198E1D2230C1801AC /* bundle_serializer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5C2A94EE24E60543F62CC35 /* bundle_serializer_test.cc */; }; + A296B0110550890E1D8D59A3 /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 428662F00938E9E21F7080D7 /* explain_stats.pb.cc */; }; A2E9978E02F7BCB016555F09 /* Validation_BloomFilterTest_MD5_1_1_membership_test_result.json in Resources */ = {isa = PBXBuildFile; fileRef = 3369AC938F82A70685C5ED58 /* Validation_BloomFilterTest_MD5_1_1_membership_test_result.json */; }; A3262936317851958C8EABAF /* byte_stream_cpp_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 01D10113ECC5B446DB35E96D /* byte_stream_cpp_test.cc */; }; A4757C171D2407F61332EA38 /* byte_stream_cpp_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 01D10113ECC5B446DB35E96D /* byte_stream_cpp_test.cc */; }; @@ -1121,7 +1116,6 @@ A4AD189BDEF7A609953457A6 /* leveldb_key_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54995F6E205B6E12004EFFA0 /* leveldb_key_test.cc */; }; A4ECA8335000CBDF94586C94 /* FSTDatastoreTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E07E202154EC00B64F25 /* FSTDatastoreTests.mm */; }; A5175CA2E677E13CC5F23D72 /* document_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB6B908320322E4D00CC290A /* document_test.cc */; }; - A5301AA55748A11801E3EE47 /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = FAAF1A69F4A315C38357BDC4 /* field_behavior.pb.cc */; }; A55266E6C986251D283CE948 /* FIRCursorTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E070202154D600B64F25 /* FIRCursorTests.mm */; }; A5583822218F9D5B1E86FCAC /* overlay_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = E1459FA70B8FC18DE4B80D0D /* overlay_test.cc */; }; A57EC303CD2D6AA4F4745551 /* FIRFieldValueTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E04A202154AA00B64F25 /* FIRFieldValueTests.mm */; }; @@ -1166,6 +1160,7 @@ AB8209455BAA17850D5E196D /* http.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 618BBE9720B89AAC00B5BCE7 /* http.pb.cc */; }; AB9FF792C60FC581909EF381 /* recovery_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */; }; ABA495BB202B7E80008A7851 /* snapshot_version_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABA495B9202B7E79008A7851 /* snapshot_version_test.cc */; }; + ABE599C3BF9FB6AFF18AA901 /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 428662F00938E9E21F7080D7 /* explain_stats.pb.cc */; }; ABE6637A201FA81900ED349A /* database_id_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB71064B201FA60300344F18 /* database_id_test.cc */; }; ABF6506C201131F8005F2C74 /* timestamp_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABF6506B201131F8005F2C74 /* timestamp_test.cc */; }; ABFD599019CF312CFF96B3EC /* perf_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = D5B2593BCB52957D62F1C9D3 /* perf_spec_test.json */; }; @@ -1211,7 +1206,6 @@ B220E091D8F4E6DE1EA44F57 /* executor_libdispatch_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = B6FB4689208F9B9100554BA2 /* executor_libdispatch_test.mm */; }; B235E260EA0DCB7BAC04F69B /* field_path_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B686F2AD2023DDB20028D6BE /* field_path_test.cc */; }; B2554A2BA211D10823646DBE /* Validation_BloomFilterTest_MD5_500_01_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 4BD051DBE754950FEAC7A446 /* Validation_BloomFilterTest_MD5_500_01_bloom_filter_proto.json */; }; - B280370F84393808250B28BC /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 682582E5728F3F1C531990EA /* explain_stats.pb.cc */; }; B28ACC69EB1F232AE612E77B /* async_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 872C92ABD71B12784A1C5520 /* async_testing.cc */; }; B2A9965ED0114E39A911FD09 /* Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 4375BDCDBCA9938C7F086730 /* Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json */; }; B31B5E0D4EA72C5916CC71F5 /* thread_safe_memoizer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A8141230C7E3986EACEF0B6 /* thread_safe_memoizer_test.cc */; }; @@ -1292,11 +1286,13 @@ BC549E3F3F119D80741D8612 /* leveldb_util_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 332485C4DCC6BA0DBB5E31B7 /* leveldb_util_test.cc */; }; BC5AC8890974E0821431267E /* limit_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA129F1F315EE100DD57A1 /* limit_spec_test.json */; }; BC8DFBCB023DBD914E27AA7D /* query_listener_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7C3F995E040E9E9C5E8514BB /* query_listener_test.cc */; }; + BC9966788F245D79A63C2E47 /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = D49E7AEE500651D25C5360C3 /* pipeline.pb.cc */; }; BCA720A0F54D23654F806323 /* ConditionalConformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3228F51DCDC2E90D5C58F97 /* ConditionalConformanceTests.swift */; }; BCAC9F7A865BD2320A4D8752 /* bloom_filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = A2E6F09AD1EE0A6A452E9A08 /* bloom_filter_test.cc */; }; BD0882A40BD8AE042629C179 /* thread_safe_memoizer_testing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = EA10515F99A42D71DA2D2841 /* thread_safe_memoizer_testing_test.cc */; }; BD3A421C9E40C57D25697E75 /* Validation_BloomFilterTest_MD5_500_01_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 4BD051DBE754950FEAC7A446 /* Validation_BloomFilterTest_MD5_500_01_bloom_filter_proto.json */; }; BD6CC8614970A3D7D2CF0D49 /* exponential_backoff_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6D1B68420E2AB1A00B35856 /* exponential_backoff_test.cc */; }; + BD74B0E1FC752236A7376BC3 /* PipelineApiTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59BF06E5A4988F9F949DD871 /* PipelineApiTests.swift */; }; BDD2D1812BAD962E3C81A53F /* hashing_test_apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = B69CF3F02227386500B281C8 /* hashing_test_apple.mm */; }; BDDAE67000DBF10E9EA7FED0 /* nanopb_util_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6F5B6C1399F92FD60F2C582B /* nanopb_util_test.cc */; }; BDF3A6C121F2773BB3A347A7 /* counting_query_engine.cc in Sources */ = {isa = PBXBuildFile; fileRef = 99434327614FEFF7F7DC88EC /* counting_query_engine.cc */; }; @@ -1356,9 +1352,11 @@ C840AD39F7EC5524F1C0F5AE /* filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F02F734F272C3C70D1307076 /* filter_test.cc */; }; C86E85101352B5CDBF5909F9 /* md5_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3D050936A2D52257FD17FB6E /* md5_test.cc */; }; C8722550B56CEB96F84DCE94 /* target_index_matcher_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 63136A2371C0C013EC7A540C /* target_index_matcher_test.cc */; }; + C8889F3C37F1CC3E64558287 /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = D49E7AEE500651D25C5360C3 /* pipeline.pb.cc */; }; C8A573895D819A92BF16B5E5 /* mutation_queue_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3068AA9DFBBA86C1FE2A946E /* mutation_queue_test.cc */; }; C8BA36C8B5E26C173F91E677 /* aggregation_result.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = D872D754B8AD88E28AF28B28 /* aggregation_result.pb.cc */; }; C8BC50508337800E8B098F57 /* bundle_loader_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = A853C81A6A5A51C9D0389EDA /* bundle_loader_test.cc */; }; + C8C2B945D84DD98391145F3F /* PipelineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 861684E49DAC993D153E60D0 /* PipelineTests.swift */; }; C8C4CB7B6E23FC340BEC6D7F /* load_bundle_task_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8F1A7B4158D9DD76EE4836BF /* load_bundle_task_test.cc */; }; C8D3CE2343E53223E6487F2C /* Pods_Firestore_Example_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5918805E993304321A05E82B /* Pods_Firestore_Example_iOS.framework */; }; C901A1BFD553B6DD70BB7CC7 /* bundle_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F7FC06E0A47D393DE1759AE1 /* bundle_cache_test.cc */; }; @@ -1425,6 +1423,7 @@ D5B25CBF07F65E885C9D68AB /* perf_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = D5B2593BCB52957D62F1C9D3 /* perf_spec_test.json */; }; D5E9954FC1C5ABBC7A180B33 /* FSTSpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E03020213FFC00B64F25 /* FSTSpecTests.mm */; }; D5F6AAA1A1B9AE84205ECE27 /* Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 4B3E4A77493524333133C5DC /* Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json */; }; + D64792BBFA130E26CB3D1028 /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = D49E7AEE500651D25C5360C3 /* pipeline.pb.cc */; }; D6486C7FFA8BE6F9C7D2F4C4 /* filesystem_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F51859B394D01C0C507282F1 /* filesystem_test.cc */; }; D658E6DA5A218E08810E1688 /* byte_string_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5342CDDB137B4E93E2E85CCA /* byte_string_test.cc */; }; D6962E598CEDABA312D87760 /* bundle_reader_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6ECAF7DE28A19C69DF386D88 /* bundle_reader_test.cc */; }; @@ -1437,7 +1436,6 @@ D73BBA4AB42940AB187169E3 /* listen_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA12A01F315EE100DD57A1 /* listen_spec_test.json */; }; D756A1A63E626572EE8DF592 /* firestore.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 544129D421C2DDC800EFB9CC /* firestore.pb.cc */; }; D77941FD93DBE862AEF1F623 /* FSTTransactionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E07B202154EB00B64F25 /* FSTTransactionTests.mm */; }; - D8F427680C3165DCD1A6BA2A /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = FAAF1A69F4A315C38357BDC4 /* field_behavior.pb.cc */; }; D91D86B29B86A60C05879A48 /* timestamp_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABF6506B201131F8005F2C74 /* timestamp_test.cc */; }; D928302820891CCCAD0437DD /* thread_safe_memoizer_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6E42FA109D363EA7F3387AAE /* thread_safe_memoizer_testing.cc */; }; D9366A834BFF13246DC3AF9E /* field_path_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B686F2AD2023DDB20028D6BE /* field_path_test.cc */; }; @@ -1473,7 +1471,7 @@ DD6C480629B3F87933FAF440 /* filesystem_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = BA02DA2FCD0001CFC6EB08DA /* filesystem_testing.cc */; }; DD935E243A64A4EB688E4C1C /* credentials_provider_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2F4FA4576525144C5069A7A5 /* credentials_provider_test.cc */; }; DD941BF189E38312E7A2CB21 /* Validation_BloomFilterTest_MD5_500_1_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = D8E530B27D5641B9C26A452C /* Validation_BloomFilterTest_MD5_500_1_bloom_filter_proto.json */; }; - DDABEDF95A5B44E590064EF7 /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = FAAF1A69F4A315C38357BDC4 /* field_behavior.pb.cc */; }; + DDC782CBA37AA9B0EA373B7A /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 428662F00938E9E21F7080D7 /* explain_stats.pb.cc */; }; DDD219222EEE13E3F9F2C703 /* leveldb_transaction_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 88CF09277CFA45EE1273E3BA /* leveldb_transaction_test.cc */; }; DDDE74C752E65DE7D39A7166 /* view_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = A5466E7809AD2871FFDE6C76 /* view_testing.cc */; }; DE03B2D41F2149D600A30B9C /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F5AF195388D20070C39A /* XCTest.framework */; }; @@ -1486,11 +1484,13 @@ DEC033E4FB3E09A3C7CE6016 /* aggregate_query_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AF924C79F49F793992A84879 /* aggregate_query_test.cc */; }; DEF4BF5FAA83C37100408F89 /* bundle_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 79EAA9F7B1B9592B5F053923 /* bundle_spec_test.json */; }; DF4B3835C5AA4835C01CD255 /* local_store_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 307FF03D0297024D59348EBD /* local_store_test.cc */; }; + DF6FBE5BBD578B0DD34CEFA1 /* PipelineApiTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59BF06E5A4988F9F949DD871 /* PipelineApiTests.swift */; }; DF7ABEB48A650117CBEBCD26 /* object_value_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 214877F52A705012D6720CA0 /* object_value_test.cc */; }; DF96816EC67F9B8DF19B0CFD /* document_overlay_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = FFCA39825D9678A03D1845D0 /* document_overlay_cache_test.cc */; }; DF983A9C1FBF758AF3AF110D /* aggregation_result.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = D872D754B8AD88E28AF28B28 /* aggregation_result.pb.cc */; }; E042112665DD2504E3F495D5 /* Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 4375BDCDBCA9938C7F086730 /* Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json */; }; E04607A1E2964684184E8AEA /* index_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 8C7278B604B8799F074F4E8C /* index_spec_test.json */; }; + E04CB0D580980748D5DC453F /* PipelineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 861684E49DAC993D153E60D0 /* PipelineTests.swift */; }; E08297B35E12106105F448EB /* ordered_code_benchmark.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0473AFFF5567E667A125347B /* ordered_code_benchmark.cc */; }; E084921EFB7CF8CB1E950D6C /* iterator_adaptors_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54A0353420A3D8CB003E0143 /* iterator_adaptors_test.cc */; }; E0E640226A1439C59BBBA9C1 /* hard_assert_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */; }; @@ -1542,8 +1542,10 @@ E884336B43BBD1194C17E3C4 /* status_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3CAA33F964042646FDDAF9F9 /* status_testing.cc */; }; E8AB8024B70F6C960D8C7530 /* document_overlay_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = FFCA39825D9678A03D1845D0 /* document_overlay_cache_test.cc */; }; E8BA7055EDB8B03CC99A528F /* recovery_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */; }; + E9071BE412DC42300B936BAF /* explain_stats.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 428662F00938E9E21F7080D7 /* explain_stats.pb.cc */; }; E962CA641FB1312638593131 /* leveldb_document_overlay_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AE89CFF09C6804573841397F /* leveldb_document_overlay_cache_test.cc */; }; E99D5467483B746D4AA44F74 /* fields_array_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = BA4CBA48204C9E25B56993BC /* fields_array_test.cc */; }; + E9BC6A5BC2B209B1BA2F8BD6 /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1F78CD3208A1D5885B4C134E /* field_behavior.pb.cc */; }; EA38690795FBAA182A9AA63E /* FIRDatabaseTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E06C202154D500B64F25 /* FIRDatabaseTests.mm */; }; EA46611779C3EEF12822508C /* annotations.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 618BBE9520B89AAC00B5BCE7 /* annotations.pb.cc */; }; EAA1962BFBA0EBFBA53B343F /* bundle_builder.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4F5B96F3ABCD2CA901DB1CD4 /* bundle_builder.cc */; }; @@ -1605,6 +1607,7 @@ F19B749671F2552E964422F7 /* FIRListenerRegistrationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E06B202154D500B64F25 /* FIRListenerRegistrationTests.mm */; }; F1EAEE9DF819C017A9506AEB /* FIRIndexingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 795AA8FC31D2AF6864B07D39 /* FIRIndexingTests.mm */; }; F1F8FB9254E9A5107161A7B2 /* Validation_BloomFilterTest_MD5_500_01_membership_test_result.json in Resources */ = {isa = PBXBuildFile; fileRef = DD990FD89C165F4064B4F608 /* Validation_BloomFilterTest_MD5_500_01_membership_test_result.json */; }; + F21A3E06BBEC807FADB43AAF /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1F78CD3208A1D5885B4C134E /* field_behavior.pb.cc */; }; F272A8C41D2353700A11D1FB /* field_mask_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 549CCA5320A36E1F00BCEB75 /* field_mask_test.cc */; }; F27347560A963E8162C56FF3 /* target_index_matcher_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 63136A2371C0C013EC7A540C /* target_index_matcher_test.cc */; }; F2876F16CF689FD7FFBA9DFA /* Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 0D964D4936953635AC7E0834 /* Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json */; }; @@ -1621,7 +1624,6 @@ F58A23FEF328EB74F681FE83 /* index_manager_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AE4A9E38D65688EE000EE2A1 /* index_manager_test.cc */; }; F5A654E92FF6F3FF16B93E6B /* mutation_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = C8522DE226C467C54E6788D8 /* mutation_test.cc */; }; F5B1F219E912F645FB79D08E /* firebase_app_check_credentials_provider_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = F119BDDF2F06B3C0883B8297 /* firebase_app_check_credentials_provider_test.mm */; }; - F5BA649242983E2E54345BDD /* pipeline.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7142B5EC46E88349FAB3384F /* pipeline.pb.cc */; }; F5BDECEB3B43BD1591EEADBD /* FSTUserDataReaderTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8D9892F204959C50613F16C8 /* FSTUserDataReaderTests.mm */; }; F6079BFC9460B190DA85C2E6 /* pretty_printing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB323F9553050F4F6490F9FF /* pretty_printing_test.cc */; }; F609600E9A88A4D44FD1FCEB /* FSTSpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E03020213FFC00B64F25 /* FSTSpecTests.mm */; }; @@ -1652,6 +1654,7 @@ FB2111D9205822CC8E7368C2 /* FIRDocumentReferenceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E049202154AA00B64F25 /* FIRDocumentReferenceTests.mm */; }; FB2D5208A6B5816A7244D77A /* query_engine_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B8A853940305237AFDA8050B /* query_engine_test.cc */; }; FB3D9E01547436163C456A3C /* message_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = CE37875365497FFA8687B745 /* message_test.cc */; }; + FB462B2C6D3C167DF32BA0E1 /* field_behavior.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1F78CD3208A1D5885B4C134E /* field_behavior.pb.cc */; }; FBBB13329D3B5827C21AE7AB /* reference_set_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 132E32997D781B896672D30A /* reference_set_test.cc */; }; FC1D22B6EC4E5F089AE39B8C /* memory_target_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2286F308EFB0534B1BDE05B9 /* memory_target_cache_test.cc */; }; FC6C9D1A8B24A5C9507272F7 /* globals_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4564AD9C55EC39C080EB9476 /* globals_cache_test.cc */; }; @@ -1738,7 +1741,6 @@ 0D964D4936953635AC7E0834 /* Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json; sourceTree = ""; }; 0EE5300F8233D14025EF0456 /* string_apple_test.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = string_apple_test.mm; sourceTree = ""; }; 11984BA0A99D7A7ABA5B0D90 /* Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS/Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.release.xcconfig"; sourceTree = ""; }; - 12260A292D56A3CE001766EB /* PipelineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PipelineTests.swift; sourceTree = ""; }; 1235769122B7E915007DDFA9 /* EncodableFieldValueTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncodableFieldValueTests.swift; sourceTree = ""; }; 1235769422B86E65007DDFA9 /* FirestoreEncoderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirestoreEncoderTests.swift; sourceTree = ""; }; 124C932B22C1642C00CA8C2D /* CodableIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodableIntegrationTests.swift; sourceTree = ""; }; @@ -1746,20 +1748,20 @@ 129A369928CA555B005AE7E2 /* FIRCountTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRCountTests.mm; sourceTree = ""; }; 12F4357299652983A615F886 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 132E32997D781B896672D30A /* reference_set_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reference_set_test.cc; sourceTree = ""; }; + 15249D092D85B40EFC8A1459 /* pipeline.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = pipeline.pb.h; sourceTree = ""; }; 166CE73C03AB4366AAC5201C /* leveldb_index_manager_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = leveldb_index_manager_test.cc; sourceTree = ""; }; 1A7D48A017ECB54FD381D126 /* Validation_BloomFilterTest_MD5_5000_1_membership_test_result.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_5000_1_membership_test_result.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_5000_1_membership_test_result.json; sourceTree = ""; }; 1A8141230C7E3986EACEF0B6 /* thread_safe_memoizer_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = thread_safe_memoizer_test.cc; sourceTree = ""; }; 1B342370EAE3AA02393E33EB /* cc_compilation_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; name = cc_compilation_test.cc; path = api/cc_compilation_test.cc; sourceTree = ""; }; 1B9F95EC29FAD3F100EEC075 /* FIRAggregateQueryUnitTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRAggregateQueryUnitTests.mm; sourceTree = ""; }; - 1BAFC713D2B1A2DBD55B2593 /* field_behavior.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = field_behavior.pb.h; sourceTree = ""; }; 1C01D8CE367C56BB2624E299 /* index.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = index.pb.h; path = admin/index.pb.h; sourceTree = ""; }; 1C3F7302BF4AE6CBC00ECDD0 /* resource.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = resource.pb.cc; sourceTree = ""; }; 1CA9800A53669EFBFFB824E3 /* memory_remote_document_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = memory_remote_document_cache_test.cc; sourceTree = ""; }; 1E0C7C0DCD2790019E66D8CC /* bloom_filter.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = bloom_filter.pb.cc; sourceTree = ""; }; 1F50E872B3F117A674DA8E94 /* index_backfiller_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = index_backfiller_test.cc; sourceTree = ""; }; + 1F78CD3208A1D5885B4C134E /* field_behavior.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = field_behavior.pb.cc; sourceTree = ""; }; 214877F52A705012D6720CA0 /* object_value_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = object_value_test.cc; sourceTree = ""; }; 2220F583583EFC28DE792ABE /* Pods_Firestore_IntegrationTests_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_IntegrationTests_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 2258E6EBCFB8E8B1693C1347 /* explain_stats.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = explain_stats.pb.h; sourceTree = ""; }; 2286F308EFB0534B1BDE05B9 /* memory_target_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = memory_target_cache_test.cc; sourceTree = ""; }; 26DDBA115DEB88631B93F203 /* thread_safe_memoizer_testing.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = thread_safe_memoizer_testing.h; sourceTree = ""; }; 277EAACC4DD7C21332E8496A /* lru_garbage_collector_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = lru_garbage_collector_test.cc; sourceTree = ""; }; @@ -1797,11 +1799,12 @@ 403DBF6EFB541DFD01582AA3 /* path_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = path_test.cc; sourceTree = ""; }; 40F9D09063A07F710811A84F /* value_util_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = value_util_test.cc; sourceTree = ""; }; 4132F30044D5DF1FB15B2A9D /* fake_credentials_provider.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = fake_credentials_provider.h; sourceTree = ""; }; + 428662F00938E9E21F7080D7 /* explain_stats.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = explain_stats.pb.cc; sourceTree = ""; }; 432C71959255C5DBDF522F52 /* byte_stream_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = byte_stream_test.cc; sourceTree = ""; }; 4334F87873015E3763954578 /* status_testing.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = status_testing.h; sourceTree = ""; }; 4375BDCDBCA9938C7F086730 /* Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json; sourceTree = ""; }; 444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = hard_assert_test.cc; sourceTree = ""; }; - 4564AD9C55EC39C080EB9476 /* globals_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = globals_cache_test.cc; sourceTree = ""; }; + 4564AD9C55EC39C080EB9476 /* globals_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = globals_cache_test.cc; sourceTree = ""; }; 478DC75A0DCA6249A616DD30 /* Validation_BloomFilterTest_MD5_500_0001_membership_test_result.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_500_0001_membership_test_result.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_500_0001_membership_test_result.json; sourceTree = ""; }; 48D0915834C3D234E5A875A9 /* grpc_stream_tester.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = grpc_stream_tester.h; sourceTree = ""; }; 4B3E4A77493524333133C5DC /* Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json; sourceTree = ""; }; @@ -1916,10 +1919,11 @@ 57F8EE51B5EFC9FAB185B66C /* Validation_BloomFilterTest_MD5_5000_01_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_5000_01_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_5000_01_bloom_filter_proto.json; sourceTree = ""; }; 584AE2C37A55B408541A6FF3 /* remote_event_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = remote_event_test.cc; sourceTree = ""; }; 5918805E993304321A05E82B /* Pods_Firestore_Example_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_Example_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 59BF06E5A4988F9F949DD871 /* PipelineApiTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PipelineApiTests.swift; sourceTree = ""; }; 5B5414D28802BC76FDADABD6 /* stream_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = stream_test.cc; sourceTree = ""; }; 5B96CC29E9946508F022859C /* Validation_BloomFilterTest_MD5_50000_0001_membership_test_result.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_50000_0001_membership_test_result.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_50000_0001_membership_test_result.json; sourceTree = ""; }; 5C68EE4CB94C0DD6E333F546 /* Validation_BloomFilterTest_MD5_1_01_membership_test_result.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_1_01_membership_test_result.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_1_01_membership_test_result.json; sourceTree = ""; }; - 5C6DEA63FBDE19D841291723 /* memory_globals_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = memory_globals_cache_test.cc; sourceTree = ""; }; + 5C6DEA63FBDE19D841291723 /* memory_globals_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = memory_globals_cache_test.cc; sourceTree = ""; }; 5C7942B6244F4C416B11B86C /* leveldb_mutation_queue_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = leveldb_mutation_queue_test.cc; sourceTree = ""; }; 5CAE131920FFFED600BE9A4A /* Firestore_Benchmarks_iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Firestore_Benchmarks_iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5CAE131D20FFFED600BE9A4A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -1966,7 +1970,6 @@ 64AA92CFA356A2360F3C5646 /* filesystem_testing.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = filesystem_testing.h; sourceTree = ""; }; 65AF0AB593C3AD81A1F1A57E /* FIRCompositeIndexQueryTests.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRCompositeIndexQueryTests.mm; sourceTree = ""; }; 67786C62C76A740AEDBD8CD3 /* FSTTestingHooks.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = FSTTestingHooks.h; sourceTree = ""; }; - 682582E5728F3F1C531990EA /* explain_stats.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = explain_stats.pb.cc; sourceTree = ""; }; 69E6C311558EC77729A16CF1 /* Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS/Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.debug.xcconfig"; sourceTree = ""; }; 6A7A30A2DB3367E08939E789 /* bloom_filter.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = bloom_filter.pb.h; sourceTree = ""; }; 6AE927CDFC7A72BF825BE4CB /* Pods-Firestore_Tests_tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Tests_tvOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Tests_tvOS/Pods-Firestore_Tests_tvOS.release.xcconfig"; sourceTree = ""; }; @@ -1983,7 +1986,6 @@ 6F57521E161450FAF89075ED /* event_manager_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = event_manager_test.cc; sourceTree = ""; }; 6F5B6C1399F92FD60F2C582B /* nanopb_util_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; name = nanopb_util_test.cc; path = nanopb/nanopb_util_test.cc; sourceTree = ""; }; 71140E5D09C6E76F7C71B2FC /* fake_target_metadata_provider.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = fake_target_metadata_provider.cc; sourceTree = ""; }; - 7142B5EC46E88349FAB3384F /* pipeline.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = pipeline.pb.cc; sourceTree = ""; }; 71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 728F617782600536F2561463 /* Validation_BloomFilterTest_MD5_5000_0001_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_5000_0001_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_5000_0001_bloom_filter_proto.json; sourceTree = ""; }; 731541602214AFFA0037F4DC /* query_spec_test.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = query_spec_test.json; sourceTree = ""; }; @@ -2009,6 +2011,8 @@ 7EB299CF85034F09CFD6F3FD /* remote_document_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = remote_document_cache_test.cc; sourceTree = ""; }; 84076EADF6872C78CDAC7291 /* bundle_builder.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = bundle_builder.h; sourceTree = ""; }; 84434E57CA72951015FC71BC /* Pods-Firestore_FuzzTests_iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_FuzzTests_iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_FuzzTests_iOS/Pods-Firestore_FuzzTests_iOS.debug.xcconfig"; sourceTree = ""; }; + 861684E49DAC993D153E60D0 /* PipelineTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PipelineTests.swift; sourceTree = ""; }; + 86C7F725E6E1DA312807D8D3 /* explain_stats.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = explain_stats.pb.h; sourceTree = ""; }; 872C92ABD71B12784A1C5520 /* async_testing.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = async_testing.cc; sourceTree = ""; }; 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 87553338E42B8ECA05BA987E /* grpc_stream_tester.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = grpc_stream_tester.cc; sourceTree = ""; }; @@ -2040,6 +2044,7 @@ A20BAA3D2F994384279727EC /* md5_testing.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = md5_testing.h; sourceTree = ""; }; A2E6F09AD1EE0A6A452E9A08 /* bloom_filter_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = bloom_filter_test.cc; sourceTree = ""; }; A366F6AE1A5A77548485C091 /* bundle.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = bundle.pb.cc; sourceTree = ""; }; + A4192EB032E23129EF23605A /* field_behavior.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = field_behavior.pb.h; sourceTree = ""; }; A5466E7809AD2871FFDE6C76 /* view_testing.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = view_testing.cc; sourceTree = ""; }; A5D9044B72061CAF284BC9E4 /* Validation_BloomFilterTest_MD5_50000_0001_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_50000_0001_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_50000_0001_bloom_filter_proto.json; sourceTree = ""; }; A5FA86650A18F3B7A8162287 /* Pods-Firestore_Benchmarks_iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Benchmarks_iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Benchmarks_iOS/Pods-Firestore_Benchmarks_iOS.release.xcconfig"; sourceTree = ""; }; @@ -2114,13 +2119,13 @@ D0A6E9136804A41CEC9D55D4 /* delayed_constructor_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = delayed_constructor_test.cc; sourceTree = ""; }; D22D4C211AC32E4F8B4883DA /* Validation_BloomFilterTest_MD5_500_0001_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_500_0001_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_500_0001_bloom_filter_proto.json; sourceTree = ""; }; D3CC3DC5338DCAF43A211155 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; + D49E7AEE500651D25C5360C3 /* pipeline.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = pipeline.pb.cc; sourceTree = ""; }; D5B2593BCB52957D62F1C9D3 /* perf_spec_test.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = perf_spec_test.json; sourceTree = ""; }; D5B25E7E7D6873CBA4571841 /* FIRNumericTransformTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRNumericTransformTests.mm; sourceTree = ""; }; D7DF4A6F740086A2D8C0E28E /* Pods_Firestore_Tests_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_Tests_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D85AC18C55650ED230A71B82 /* FSTTestingHooks.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = FSTTestingHooks.mm; sourceTree = ""; }; D872D754B8AD88E28AF28B28 /* aggregation_result.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = aggregation_result.pb.cc; sourceTree = ""; }; D8A6D52723B1BABE1B7B8D8F /* leveldb_overlay_migration_manager_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = leveldb_overlay_migration_manager_test.cc; sourceTree = ""; }; - D8DAE1269481D15A291E0B49 /* pipeline.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = pipeline.pb.h; sourceTree = ""; }; D8E530B27D5641B9C26A452C /* Validation_BloomFilterTest_MD5_500_1_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_500_1_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_500_1_bloom_filter_proto.json; sourceTree = ""; }; D9D94300B9C02F7069523C00 /* leveldb_snappy_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = leveldb_snappy_test.cc; sourceTree = ""; }; DAFF0CF521E64AC30062958F /* Firestore_Example_macOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Firestore_Example_macOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -2168,7 +2173,6 @@ F848C41C03A25C42AD5A4BC2 /* target_cache_test.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = target_cache_test.h; sourceTree = ""; }; F869D85E900E5AF6CD02E2FC /* firebase_auth_credentials_provider_test.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; name = firebase_auth_credentials_provider_test.mm; path = credentials/firebase_auth_credentials_provider_test.mm; sourceTree = ""; }; FA2E9952BA2B299C1156C43C /* Pods-Firestore_Benchmarks_iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Benchmarks_iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Benchmarks_iOS/Pods-Firestore_Benchmarks_iOS.debug.xcconfig"; sourceTree = ""; }; - FAAF1A69F4A315C38357BDC4 /* field_behavior.pb.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = field_behavior.pb.cc; sourceTree = ""; }; FC44D934D4A52C790659C8D6 /* leveldb_globals_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = leveldb_globals_cache_test.cc; sourceTree = ""; }; FC738525340E594EBFAB121E /* Pods-Firestore_Example_tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_tvOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_tvOS/Pods-Firestore_Example_tvOS.release.xcconfig"; sourceTree = ""; }; FF73B39D04D1760190E6B84A /* FIRQueryUnitTests.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRQueryUnitTests.mm; sourceTree = ""; }; @@ -2300,7 +2304,8 @@ 124C932B22C1642C00CA8C2D /* CodableIntegrationTests.swift */, 3355BE9391CC4857AF0BDAE3 /* DatabaseTests.swift */, 62E54B832A9E910A003347C8 /* IndexingTests.swift */, - 12260A292D56A3CE001766EB /* PipelineTests.swift */, + 59BF06E5A4988F9F949DD871 /* PipelineApiTests.swift */, + 861684E49DAC993D153E60D0 /* PipelineTests.swift */, 621D620928F9CE7400D2FA26 /* QueryIntegrationTests.swift */, 4D65F6E69993611D47DC8E7C /* SnapshotListenerSourceTests.swift */, EFF22EA92C5060A4009A369B /* VectorIntegrationTests.swift */, @@ -2339,12 +2344,12 @@ 544129D121C2DDC800EFB9CC /* common.pb.h */, 544129D821C2DDC800EFB9CC /* document.pb.cc */, 544129D721C2DDC800EFB9CC /* document.pb.h */, - 682582E5728F3F1C531990EA /* explain_stats.pb.cc */, - 2258E6EBCFB8E8B1693C1347 /* explain_stats.pb.h */, + 428662F00938E9E21F7080D7 /* explain_stats.pb.cc */, + 86C7F725E6E1DA312807D8D3 /* explain_stats.pb.h */, 544129D421C2DDC800EFB9CC /* firestore.pb.cc */, 544129D321C2DDC800EFB9CC /* firestore.pb.h */, - 7142B5EC46E88349FAB3384F /* pipeline.pb.cc */, - D8DAE1269481D15A291E0B49 /* pipeline.pb.h */, + D49E7AEE500651D25C5360C3 /* pipeline.pb.cc */, + 15249D092D85B40EFC8A1459 /* pipeline.pb.h */, 544129D621C2DDC800EFB9CC /* query.pb.cc */, 544129D021C2DDC800EFB9CC /* query.pb.h */, 544129D921C2DDC800EFB9CC /* write.pb.cc */, @@ -2811,8 +2816,8 @@ children = ( 618BBE9520B89AAC00B5BCE7 /* annotations.pb.cc */, 618BBE9620B89AAC00B5BCE7 /* annotations.pb.h */, - FAAF1A69F4A315C38357BDC4 /* field_behavior.pb.cc */, - 1BAFC713D2B1A2DBD55B2593 /* field_behavior.pb.h */, + 1F78CD3208A1D5885B4C134E /* field_behavior.pb.cc */, + A4192EB032E23129EF23605A /* field_behavior.pb.h */, 618BBE9720B89AAC00B5BCE7 /* http.pb.cc */, 618BBE9420B89AAC00B5BCE7 /* http.pb.h */, 1C3F7302BF4AE6CBC00ECDD0 /* resource.pb.cc */, @@ -4262,10 +4267,10 @@ AC6C1E57B18730428CB15E03 /* executor_libdispatch_test.mm in Sources */, E7D415B8717701B952C344E5 /* executor_std_test.cc in Sources */, 470A37727BBF516B05ED276A /* executor_test.cc in Sources */, - B280370F84393808250B28BC /* explain_stats.pb.cc in Sources */, + 2F72DBE2EC6E24A81C69DEF0 /* explain_stats.pb.cc in Sources */, 2E0BBA7E627EB240BA11B0D0 /* exponential_backoff_test.cc in Sources */, 9009C285F418EA80C46CF06B /* fake_target_metadata_provider.cc in Sources */, - A5301AA55748A11801E3EE47 /* field_behavior.pb.cc in Sources */, + 7B58861D0978827BC4CB1DFA /* field_behavior.pb.cc in Sources */, 2E373EA9D5FF8C6DE2507675 /* field_index_test.cc in Sources */, 07B1E8C62772758BC82FEBEE /* field_mask_test.cc in Sources */, D9366A834BFF13246DC3AF9E /* field_path_test.cc in Sources */, @@ -4341,7 +4346,7 @@ BE1D7C7E413449AFFBA21BCB /* overlay_test.cc in Sources */, DB7E9C5A59CCCDDB7F0C238A /* path_test.cc in Sources */, E30BF9E316316446371C956C /* persistence_testing.cc in Sources */, - 715A0E92C83AE4384A13B882 /* pipeline.pb.cc in Sources */, + 60DA778E447F9ACD402FDA2F /* pipeline.pb.cc in Sources */, 0455FC6E2A281BD755FD933A /* precondition_test.cc in Sources */, 5ECE040F87E9FCD0A5D215DB /* pretty_printing_test.cc in Sources */, 938F2AF6EC5CD0B839300DB0 /* query.pb.cc in Sources */, @@ -4488,10 +4493,10 @@ B220E091D8F4E6DE1EA44F57 /* executor_libdispatch_test.mm in Sources */, BAB43C839445782040657239 /* executor_std_test.cc in Sources */, 3A7CB01751697ED599F2D9A1 /* executor_test.cc in Sources */, - 8FE63980976481EBA001B789 /* explain_stats.pb.cc in Sources */, + 7CAF0E8C47FB2DD486240D47 /* explain_stats.pb.cc in Sources */, EF3518F84255BAF3EBD317F6 /* exponential_backoff_test.cc in Sources */, 4DAFC3A3FD5E96910A517320 /* fake_target_metadata_provider.cc in Sources */, - 86E73F6286E87834CF37D5D9 /* field_behavior.pb.cc in Sources */, + E9BC6A5BC2B209B1BA2F8BD6 /* field_behavior.pb.cc in Sources */, 69D3AD697D1A7BF803A08160 /* field_index_test.cc in Sources */, ED4E2AC80CAF2A8FDDAC3DEE /* field_mask_test.cc in Sources */, 41EAC526C543064B8F3F7EDA /* field_path_test.cc in Sources */, @@ -4567,7 +4572,7 @@ 2045517602D767BD01EA71D9 /* overlay_test.cc in Sources */, 0963F6D7B0F9AE1E24B82866 /* path_test.cc in Sources */, 92D7081085679497DC112EDB /* persistence_testing.cc in Sources */, - 9CD1E9301EC44ED10DAEA5FB /* pipeline.pb.cc in Sources */, + 8429E18EFBAF473209731E01 /* pipeline.pb.cc in Sources */, 152543FD706D5E8851C8DA92 /* precondition_test.cc in Sources */, 2639ABDA17EECEB7F62D1D83 /* pretty_printing_test.cc in Sources */, 5FA3DB52A478B01384D3A2ED /* query.pb.cc in Sources */, @@ -4690,7 +4695,8 @@ 432056C4D1259F76C80FC2A8 /* FSTUserDataReaderTests.mm in Sources */, 3B1E27D951407FD237E64D07 /* FirestoreEncoderTests.swift in Sources */, 62E54B862A9E910B003347C8 /* IndexingTests.swift in Sources */, - 12260A2C2D56A3CE001766EB /* PipelineTests.swift in Sources */, + 3D5F7AA7BB68529F47BE4B12 /* PipelineApiTests.swift in Sources */, + 655F8647F57E5F2155DFF7B5 /* PipelineTests.swift in Sources */, 621D620C28F9CE7400D2FA26 /* QueryIntegrationTests.swift in Sources */, 1CFBD4563960D8A20C4679A3 /* SnapshotListenerSourceTests.swift in Sources */, EFF22EAC2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */, @@ -4739,10 +4745,10 @@ 5F6CE37B34C542704C5605A4 /* executor_libdispatch_test.mm in Sources */, AECCD9663BB3DC52199F954A /* executor_std_test.cc in Sources */, 18F644E6AA98E6D6F3F1F809 /* executor_test.cc in Sources */, - 0E7A39BD9C87CC33F91A672F /* explain_stats.pb.cc in Sources */, + ABE599C3BF9FB6AFF18AA901 /* explain_stats.pb.cc in Sources */, 6938575C8B5E6FE0D562547A /* exponential_backoff_test.cc in Sources */, 258B372CF33B7E7984BBA659 /* fake_target_metadata_provider.cc in Sources */, - D8F427680C3165DCD1A6BA2A /* field_behavior.pb.cc in Sources */, + 2FC2B732841BF2C425EB35DF /* field_behavior.pb.cc in Sources */, F8BD2F61EFA35C2D5120D9EB /* field_index_test.cc in Sources */, F272A8C41D2353700A11D1FB /* field_mask_test.cc in Sources */, AF6D6C47F9A25C65BFDCBBA0 /* field_path_test.cc in Sources */, @@ -4818,7 +4824,7 @@ A5583822218F9D5B1E86FCAC /* overlay_test.cc in Sources */, 70A171FC43BE328767D1B243 /* path_test.cc in Sources */, EECC1EC64CA963A8376FA55C /* persistence_testing.cc in Sources */, - 92B593DCD86543D8C90F64F9 /* pipeline.pb.cc in Sources */, + 5CDD24225992674A4D3E3D4E /* pipeline.pb.cc in Sources */, 34D69886DAD4A2029BFC5C63 /* precondition_test.cc in Sources */, F56E9334642C207D7D85D428 /* pretty_printing_test.cc in Sources */, 22A00AC39CAB3426A943E037 /* query.pb.cc in Sources */, @@ -4941,7 +4947,8 @@ 75A176239B37354588769206 /* FSTUserDataReaderTests.mm in Sources */, 5E89B1A5A5430713C79C4854 /* FirestoreEncoderTests.swift in Sources */, 62E54B852A9E910B003347C8 /* IndexingTests.swift in Sources */, - 12260A2B2D56A3CE001766EB /* PipelineTests.swift in Sources */, + DF6FBE5BBD578B0DD34CEFA1 /* PipelineApiTests.swift in Sources */, + C8C2B945D84DD98391145F3F /* PipelineTests.swift in Sources */, 621D620B28F9CE7400D2FA26 /* QueryIntegrationTests.swift in Sources */, A0BC30D482B0ABD1A3A24CDC /* SnapshotListenerSourceTests.swift in Sources */, EFF22EAB2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */, @@ -4990,10 +4997,10 @@ 49C593017B5438B216FAF593 /* executor_libdispatch_test.mm in Sources */, 17DFF30CF61D87883986E8B6 /* executor_std_test.cc in Sources */, 814724DE70EFC3DDF439CD78 /* executor_test.cc in Sources */, - 7492C447277CDC8CB7A165CB /* explain_stats.pb.cc in Sources */, + A296B0110550890E1D8D59A3 /* explain_stats.pb.cc in Sources */, BD6CC8614970A3D7D2CF0D49 /* exponential_backoff_test.cc in Sources */, 4D2655C5675D83205C3749DC /* fake_target_metadata_provider.cc in Sources */, - DDABEDF95A5B44E590064EF7 /* field_behavior.pb.cc in Sources */, + FB462B2C6D3C167DF32BA0E1 /* field_behavior.pb.cc in Sources */, 50C852E08626CFA7DC889EEA /* field_index_test.cc in Sources */, A1563EFEB021936D3FFE07E3 /* field_mask_test.cc in Sources */, B235E260EA0DCB7BAC04F69B /* field_path_test.cc in Sources */, @@ -5069,7 +5076,7 @@ D1BCDAEACF6408200DFB9870 /* overlay_test.cc in Sources */, B3A309CCF5D75A555C7196E1 /* path_test.cc in Sources */, 46EAC2828CD942F27834F497 /* persistence_testing.cc in Sources */, - 3B4CFB45208A7EEF1EA58ADC /* pipeline.pb.cc in Sources */, + D64792BBFA130E26CB3D1028 /* pipeline.pb.cc in Sources */, 9EE1447AA8E68DF98D0590FF /* precondition_test.cc in Sources */, F6079BFC9460B190DA85C2E6 /* pretty_printing_test.cc in Sources */, 7B0F073BDB6D0D6E542E23D4 /* query.pb.cc in Sources */, @@ -5226,10 +5233,10 @@ B6FB468E208F9BAB00554BA2 /* executor_libdispatch_test.mm in Sources */, B6FB468F208F9BAE00554BA2 /* executor_std_test.cc in Sources */, B6FB4690208F9BB300554BA2 /* executor_test.cc in Sources */, - 50EA1F41D766C92894E9B078 /* explain_stats.pb.cc in Sources */, + DDC782CBA37AA9B0EA373B7A /* explain_stats.pb.cc in Sources */, B6D1B68520E2AB1B00B35856 /* exponential_backoff_test.cc in Sources */, FAE5DA6ED3E1842DC21453EE /* fake_target_metadata_provider.cc in Sources */, - 1F9FFAE375C88EFF88CBB6F8 /* field_behavior.pb.cc in Sources */, + F21A3E06BBEC807FADB43AAF /* field_behavior.pb.cc in Sources */, 03AEB9E07A605AE1B5827548 /* field_index_test.cc in Sources */, 549CCA5720A36E1F00BCEB75 /* field_mask_test.cc in Sources */, B686F2AF2023DDEE0028D6BE /* field_path_test.cc in Sources */, @@ -5305,7 +5312,7 @@ 4D20563D846FA0F3BEBFDE9D /* overlay_test.cc in Sources */, 5A080105CCBFDB6BF3F3772D /* path_test.cc in Sources */, 21C17F15579341289AD01051 /* persistence_testing.cc in Sources */, - F5BA649242983E2E54345BDD /* pipeline.pb.cc in Sources */, + C8889F3C37F1CC3E64558287 /* pipeline.pb.cc in Sources */, 549CCA5920A36E1F00BCEB75 /* precondition_test.cc in Sources */, 6A94393D83EB338DFAF6A0D2 /* pretty_printing_test.cc in Sources */, 544129DC21C2DDC800EFB9CC /* query.pb.cc in Sources */, @@ -5447,7 +5454,8 @@ F5BDECEB3B43BD1591EEADBD /* FSTUserDataReaderTests.mm in Sources */, 6F45846C159D3C063DBD3CBE /* FirestoreEncoderTests.swift in Sources */, 62E54B842A9E910B003347C8 /* IndexingTests.swift in Sources */, - 12260A2A2D56A3CE001766EB /* PipelineTests.swift in Sources */, + BD74B0E1FC752236A7376BC3 /* PipelineApiTests.swift in Sources */, + E04CB0D580980748D5DC453F /* PipelineTests.swift in Sources */, 621D620A28F9CE7400D2FA26 /* QueryIntegrationTests.swift in Sources */, B00F8D1819EE20C45B660940 /* SnapshotListenerSourceTests.swift in Sources */, EFF22EAA2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */, @@ -5496,10 +5504,10 @@ B6BF6EFEF887B072068BA658 /* executor_libdispatch_test.mm in Sources */, 125B1048ECB755C2106802EB /* executor_std_test.cc in Sources */, DABB9FB61B1733F985CBF713 /* executor_test.cc in Sources */, - 676933F59F2F0A0D221A4F8F /* explain_stats.pb.cc in Sources */, + E9071BE412DC42300B936BAF /* explain_stats.pb.cc in Sources */, 7BCF050BA04537B0E7D44730 /* exponential_backoff_test.cc in Sources */, BA1C5EAE87393D8E60F5AE6D /* fake_target_metadata_provider.cc in Sources */, - 332E7D2D8489E6DA42947C59 /* field_behavior.pb.cc in Sources */, + 3A110ECBF96B6E44BA77011A /* field_behavior.pb.cc in Sources */, 84285C3F63D916A4786724A8 /* field_index_test.cc in Sources */, 6A40835DB2C02B9F07C02E88 /* field_mask_test.cc in Sources */, D00E69F7FDF2BE674115AD3F /* field_path_test.cc in Sources */, @@ -5575,7 +5583,7 @@ 4D7900401B1BF3D3C24DDC7E /* overlay_test.cc in Sources */, 6105A1365831B79A7DEEA4F3 /* path_test.cc in Sources */, CB8BEF34CC4A996C7BE85119 /* persistence_testing.cc in Sources */, - 2AD2CB51469AE35331C39258 /* pipeline.pb.cc in Sources */, + BC9966788F245D79A63C2E47 /* pipeline.pb.cc in Sources */, 4194B7BB8B0352E1AC5D69B9 /* precondition_test.cc in Sources */, 0EA40EDACC28F445F9A3F32F /* pretty_printing_test.cc in Sources */, 63B91FC476F3915A44F00796 /* query.pb.cc in Sources */, diff --git a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm index 4b7c7b9f034..b11a37b394c 100644 --- a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm +++ b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm @@ -85,7 +85,7 @@ static const double kPrimingTimeout = 45.0; static NSString *defaultProjectId; -static NSString *defaultDatabaseId = @"(default)"; +static NSString *defaultDatabaseId = @"enterprise"; static FIRFirestoreSettings *defaultSettings; static bool runningAgainstEmulator = false; diff --git a/Firestore/Source/API/FIRPipelineBridge+Internal.h b/Firestore/Source/API/FIRPipelineBridge+Internal.h index bfe7befe923..30bee14aa02 100644 --- a/Firestore/Source/API/FIRPipelineBridge+Internal.h +++ b/Firestore/Source/API/FIRPipelineBridge+Internal.h @@ -19,6 +19,7 @@ #include #include "Firestore/core/src/api/expressions.h" +#include "Firestore/core/src/api/firestore.h" #include "Firestore/core/src/api/pipeline.h" #include "Firestore/core/src/api/stages.h" @@ -30,13 +31,13 @@ NS_ASSUME_NONNULL_BEGIN @interface FIRExprBridge (Internal) -- (std::shared_ptr)cpp_expr; +- (std::shared_ptr)cppExprWithReader:(FSTUserDataReader *)reader; @end @interface FIRStageBridge (Internal) -- (std::shared_ptr)cpp_stage; +- (std::shared_ptr)cppStageWithReader:(FSTUserDataReader *)reader; @end @@ -46,4 +47,10 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface __FIRPipelineResultBridge (Internal) + +- (id)initWithCppResult:(api::PipelineResult)result db:(std::shared_ptr)db; + +@end + NS_ASSUME_NONNULL_END diff --git a/Firestore/Source/API/FIRPipelineBridge.mm b/Firestore/Source/API/FIRPipelineBridge.mm index 013cedcccab..713456ba3a1 100644 --- a/Firestore/Source/API/FIRPipelineBridge.mm +++ b/Firestore/Source/API/FIRPipelineBridge.mm @@ -16,11 +16,20 @@ #import "FIRPipelineBridge.h" +#import + #include +#import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRFirestore+Internal.h" #import "Firestore/Source/API/FIRPipelineBridge+Internal.h" +#import "Firestore/Source/API/FSTUserDataReader.h" +#import "Firestore/Source/API/FSTUserDataWriter.h" +#import "Firestore/Source/API/converters.h" + +#include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h" +#include "Firestore/core/src/api/document_reference.h" #include "Firestore/core/src/api/expressions.h" #include "Firestore/core/src/api/pipeline.h" #include "Firestore/core/src/api/pipeline_result.h" @@ -30,14 +39,22 @@ #include "Firestore/core/src/util/status.h" #include "Firestore/core/src/util/string_apple.h" +using firebase::firestore::api::CollectionGroupSource; using firebase::firestore::api::CollectionSource; using firebase::firestore::api::Constant; +using firebase::firestore::api::DatabaseSource; +using firebase::firestore::api::DocumentReference; +using firebase::firestore::api::DocumentsSource; using firebase::firestore::api::Expr; using firebase::firestore::api::Field; using firebase::firestore::api::FunctionExpr; +using firebase::firestore::api::LimitStage; +using firebase::firestore::api::MakeFIRTimestamp; +using firebase::firestore::api::OffsetStage; using firebase::firestore::api::Pipeline; using firebase::firestore::api::Where; using firebase::firestore::util::MakeCallback; +using firebase::firestore::util::MakeNSString; using firebase::firestore::util::MakeString; NS_ASSUME_NONNULL_BEGIN @@ -57,7 +74,7 @@ - (id)init:(NSString *)name { return self; } -- (std::shared_ptr)cpp_expr { +- (std::shared_ptr)cppExprWithReader:(FSTUserDataReader *)reader { return field; } @@ -65,16 +82,22 @@ - (id)init:(NSString *)name { @implementation FIRConstantBridge { std::shared_ptr constant; + id _input; + Boolean isUserDataRead; } -- (id)init:(NSNumber *)value { +- (id)init:(id)input { self = [super init]; - if (self) { - constant = std::make_shared(value.doubleValue); - } + _input = input; + isUserDataRead = NO; return self; } -- (std::shared_ptr)cpp_expr { +- (std::shared_ptr)cppExprWithReader:(FSTUserDataReader *)reader { + if (!isUserDataRead) { + constant = std::make_shared([reader parsedQueryValue:_input]); + } + + isUserDataRead = YES; return constant; } @@ -82,22 +105,29 @@ - (id)init:(NSNumber *)value { @implementation FIRFunctionExprBridge { std::shared_ptr eq; + NSString *_name; + NSArray *_args; + Boolean isUserDataRead; } - (nonnull id)initWithName:(NSString *)name Args:(nonnull NSArray *)args { self = [super init]; - if (self) { + _name = name; + _args = args; + isUserDataRead = NO; + return self; +} + +- (std::shared_ptr)cppExprWithReader:(FSTUserDataReader *)reader { + if (!isUserDataRead) { std::vector> cpp_args; - for (FIRExprBridge *arg in args) { - cpp_args.push_back(arg.cpp_expr); + for (FIRExprBridge *arg in _args) { + cpp_args.push_back([arg cppExprWithReader:reader]); } - - eq = std::make_shared(MakeString(name), std::move(cpp_args)); + eq = std::make_shared(MakeString(_name), std::move(cpp_args)); } - return self; -} -- (std::shared_ptr)cpp_expr { + isUserDataRead = YES; return eq; } @@ -118,63 +148,277 @@ - (id)initWithPath:(NSString *)path { return self; } -- (std::shared_ptr)cpp_stage { +- (std::shared_ptr)cppStageWithReader:(FSTUserDataReader *)reader { return collection_source; } @end +@implementation FIRDatabaseSourceStageBridge { + std::shared_ptr database_source; +} + +- (id)init { + self = [super init]; + if (self) { + database_source = std::make_shared(); + } + return self; +} + +- (std::shared_ptr)cppStageWithReader:(FSTUserDataReader *)reader { + return database_source; +} + +@end + +@implementation FIRCollectionGroupSourceStageBridge { + std::shared_ptr collection_group_source; +} + +- (id)initWithCollectionId:(NSString *)id { + self = [super init]; + if (self) { + collection_group_source = std::make_shared(MakeString(id)); + } + return self; +} + +- (std::shared_ptr)cppStageWithReader:(FSTUserDataReader *)reader { + return collection_group_source; +} + +@end + +@implementation FIRDocumentsSourceStageBridge { + std::shared_ptr document_source; +} + +- (id)initWithDocuments:(NSArray *)documents { + self = [super init]; + if (self) { + std::vector cpp_documents; + for (NSString *doc in documents) { + cpp_documents.push_back(MakeString(doc)); + } + document_source = std::make_shared(std::move(cpp_documents)); + } + return self; +} + +- (std::shared_ptr)cppStageWithReader:(FSTUserDataReader *)reader { + return document_source; +} + +@end + @implementation FIRWhereStageBridge { + FIRExprBridge *_exprBridge; + Boolean isUserDataRead; std::shared_ptr where; } - (id)initWithExpr:(FIRExprBridge *)expr { self = [super init]; if (self) { - where = std::make_shared(expr.cpp_expr); + _exprBridge = expr; + isUserDataRead = NO; } return self; } -- (std::shared_ptr)cpp_stage { +- (std::shared_ptr)cppStageWithReader:(FSTUserDataReader *)reader { + if (!isUserDataRead) { + where = std::make_shared([_exprBridge cppExprWithReader:reader]); + } + + isUserDataRead = YES; return where; } @end +@implementation FIRLimitStageBridge { + Boolean isUserDataRead; + std::shared_ptr limit_stage; + int32_t limit; +} + +- (id)initWithLimit:(NSInteger)value { + self = [super init]; + if (self) { + isUserDataRead = NO; + limit = static_cast(value); + } + return self; +} + +- (std::shared_ptr)cppStageWithReader:(FSTUserDataReader *)reader { + if (!isUserDataRead) { + limit_stage = std::make_shared(limit); + } + + isUserDataRead = YES; + return limit_stage; +} + +@end + +@implementation FIROffsetStageBridge { + Boolean isUserDataRead; + std::shared_ptr offset_stage; + int32_t offset; +} + +- (id)initWithOffset:(NSInteger)value { + self = [super init]; + if (self) { + isUserDataRead = NO; + offset = static_cast(value); + } + return self; +} + +- (std::shared_ptr)cppStageWithReader:(FSTUserDataReader *)reader { + if (!isUserDataRead) { + offset_stage = std::make_shared(offset); + } + + isUserDataRead = YES; + return offset_stage; +} + +@end + +@interface __FIRPipelineSnapshotBridge () + +@property(nonatomic, strong, readwrite) NSArray<__FIRPipelineResultBridge *> *results; + +@end + @implementation __FIRPipelineSnapshotBridge { - absl::optional pipeline; + absl::optional snapshot_; + NSMutableArray<__FIRPipelineResultBridge *> *results_; } - (id)initWithCppSnapshot:(api::PipelineSnapshot)snapshot { self = [super init]; if (self) { - pipeline = std::move(snapshot); + snapshot_ = std::move(snapshot); + if (!snapshot_.has_value()) { + results_ = nil; + } else { + NSMutableArray<__FIRPipelineResultBridge *> *results = [NSMutableArray array]; + auto &cpp_result = snapshot_.value().results(); + for (auto &result : snapshot_.value().results()) { + [results addObject:[[__FIRPipelineResultBridge alloc] + initWithCppResult:result + db:snapshot_.value().firestore()]]; + } + results_ = results; + } } return self; } +- (NSArray<__FIRPipelineResultBridge *> *)results { + return results_; +} + +- (FIRTimestamp *)execution_time { + if (!snapshot_.has_value()) { + return nil; + } else { + return MakeFIRTimestamp(snapshot_.value().execution_time().timestamp()); + } +} + @end -@implementation FIRPipelineBridge { - std::shared_ptr pipeline; +@implementation __FIRPipelineResultBridge { + api::PipelineResult _result; + std::shared_ptr _db; } -- (id)initWithStages:(NSArray *)stages db:(FIRFirestore *)db { +- (nullable FIRDocumentReference *)reference { + if (!_result.internal_key().has_value()) return nil; + + return [[FIRDocumentReference alloc] initWithKey:_result.internal_key().value() firestore:_db]; +} + +- (nullable NSString *)documentID { + if (!_result.document_id().has_value()) { + return nil; + } + + return MakeNSString(_result.document_id().value()); +} + +- (nullable FIRTimestamp *)create_time { + if (!_result.create_time().has_value()) { + return nil; + } + + return MakeFIRTimestamp(_result.create_time().value().timestamp()); +} + +- (nullable FIRTimestamp *)update_time { + if (!_result.update_time().has_value()) { + return nil; + } + + return MakeFIRTimestamp(_result.update_time().value().timestamp()); +} + +- (id)initWithCppResult:(api::PipelineResult)result db:(std::shared_ptr)db { self = [super init]; if (self) { - std::vector> cpp_stages; - for (FIRStageBridge *stage in stages) { - cpp_stages.push_back(stage.cpp_stage); - } - pipeline = std::make_shared(cpp_stages, db.wrapped); + _result = std::move(result); + _db = std::move(db); } + return self; } +- (NSDictionary *)data { + return [self dataWithServerTimestampBehavior:FIRServerTimestampBehaviorNone]; +} + +- (NSDictionary *)dataWithServerTimestampBehavior: + (FIRServerTimestampBehavior)serverTimestampBehavior { + absl::optional data = + _result.internal_value()->Get(); + if (!data) return [NSDictionary dictionary]; + + FSTUserDataWriter *dataWriter = + [[FSTUserDataWriter alloc] initWithFirestore:_db + serverTimestampBehavior:serverTimestampBehavior]; + return [dataWriter convertedValue:*data]; +} + +@end + +@implementation FIRPipelineBridge { + NSArray *_stages; + FIRFirestore *firestore; + std::shared_ptr pipeline; +} + +- (id)initWithStages:(NSArray *)stages db:(FIRFirestore *)db { + _stages = stages; + firestore = db; + return [super init]; +} + - (void)executeWithCompletion:(void (^)(__FIRPipelineSnapshotBridge *_Nullable result, NSError *_Nullable error))completion { + std::vector> cpp_stages; + for (FIRStageBridge *stage in _stages) { + cpp_stages.push_back([stage cppStageWithReader:firestore.dataReader]); + } + pipeline = std::make_shared(cpp_stages, firestore.wrapped); + pipeline->execute([completion](StatusOr maybe_value) { if (maybe_value.ok()) { __FIRPipelineSnapshotBridge *bridge = [[__FIRPipelineSnapshotBridge alloc] diff --git a/Firestore/Source/Public/FirebaseFirestore/FIRPipelineBridge.h b/Firestore/Source/Public/FirebaseFirestore/FIRPipelineBridge.h index fa7472e3292..527e97a062a 100644 --- a/Firestore/Source/Public/FirebaseFirestore/FIRPipelineBridge.h +++ b/Firestore/Source/Public/FirebaseFirestore/FIRPipelineBridge.h @@ -18,31 +18,41 @@ #import +#import "FIRDocumentSnapshot.h" + +@class FIRTimestamp; + NS_ASSUME_NONNULL_BEGIN +NS_SWIFT_SENDABLE NS_SWIFT_NAME(ExprBridge) @interface FIRExprBridge : NSObject @end +NS_SWIFT_SENDABLE NS_SWIFT_NAME(FieldBridge) @interface FIRFieldBridge : FIRExprBridge - (id)init:(NSString *)name; @end +NS_SWIFT_SENDABLE NS_SWIFT_NAME(ConstantBridge) @interface FIRConstantBridge : FIRExprBridge -- (id)init:(NSNumber *)value; +- (id)init:(id)input; @end +NS_SWIFT_SENDABLE NS_SWIFT_NAME(FunctionExprBridge) @interface FIRFunctionExprBridge : FIRExprBridge - (id)initWithName:(NSString *)name Args:(NSArray *)args; @end +NS_SWIFT_SENDABLE NS_SWIFT_NAME(StageBridge) @interface FIRStageBridge : NSObject @end +NS_SWIFT_SENDABLE NS_SWIFT_NAME(CollectionSourceStageBridge) @interface FIRCollectionSourceStageBridge : FIRStageBridge @@ -50,6 +60,31 @@ NS_SWIFT_NAME(CollectionSourceStageBridge) @end +NS_SWIFT_SENDABLE +NS_SWIFT_NAME(DatabaseSourceStageBridge) +@interface FIRDatabaseSourceStageBridge : FIRStageBridge + +- (id)init; + +@end + +NS_SWIFT_SENDABLE +NS_SWIFT_NAME(CollectionGroupSourceStageBridge) +@interface FIRCollectionGroupSourceStageBridge : FIRStageBridge + +- (id)initWithCollectionId:(NSString *)id; + +@end + +NS_SWIFT_SENDABLE +NS_SWIFT_NAME(DocumentsSourceStageBridge) +@interface FIRDocumentsSourceStageBridge : FIRStageBridge + +- (id)initWithDocuments:(NSArray *)documents; + +@end + +NS_SWIFT_SENDABLE NS_SWIFT_NAME(WhereStageBridge) @interface FIRWhereStageBridge : FIRStageBridge @@ -57,24 +92,52 @@ NS_SWIFT_NAME(WhereStageBridge) @end -NS_SWIFT_NAME(__PipelineSnapshotBridge) -@interface __FIRPipelineSnapshotBridge : NSObject +NS_SWIFT_SENDABLE +NS_SWIFT_NAME(LimitStageBridge) +@interface FIRLimitStageBridge : FIRStageBridge + +- (id)initWithLimit:(NSInteger)value; + +@end -@property(nonatomic, strong, readonly) NSArray<__FIRPipelineSnapshotBridge *> *results; +NS_SWIFT_SENDABLE +NS_SWIFT_NAME(OffsetStageBridge) +@interface FIROffsetStageBridge : FIRStageBridge + +- (id)initWithOffset:(NSInteger)value; @end +NS_SWIFT_SENDABLE NS_SWIFT_NAME(__PipelineResultBridge) @interface __FIRPipelineResultBridge : NSObject -@property(nonatomic, strong, readonly) FIRDocumentReference *reference; +@property(nonatomic, strong, readonly, nullable) FIRDocumentReference *reference; + +@property(nonatomic, copy, readonly, nullable) NSString *documentID; + +@property(nonatomic, strong, readonly, nullable) FIRTimestamp *create_time; + +@property(nonatomic, strong, readonly, nullable) FIRTimestamp *update_time; + +- (NSDictionary *)data; + +- (NSDictionary *)dataWithServerTimestampBehavior: + (FIRServerTimestampBehavior)serverTimestampBehavior; + +@end + +NS_SWIFT_SENDABLE +NS_SWIFT_NAME(__PipelineSnapshotBridge) +@interface __FIRPipelineSnapshotBridge : NSObject -@property(nonatomic, copy, readonly) NSString *documentID; +@property(nonatomic, strong, readonly) NSArray<__FIRPipelineResultBridge *> *results; -- (nullable NSDictionary *)data; +@property(nonatomic, strong, readonly) FIRTimestamp *execution_time; @end +NS_SWIFT_SENDABLE NS_SWIFT_NAME(PipelineBridge) @interface FIRPipelineBridge : NSObject diff --git a/Firestore/Swift/Source/BridgeWrapper.swift b/Firestore/Swift/Source/BridgeWrapper.swift new file mode 100644 index 00000000000..8b4d13fc9a4 --- /dev/null +++ b/Firestore/Swift/Source/BridgeWrapper.swift @@ -0,0 +1,17 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +protocol BridgeWrapper { + var bridge: ExprBridge { get } +} diff --git a/Firestore/Swift/Source/Helper/PipelineHelper.swift b/Firestore/Swift/Source/Helper/PipelineHelper.swift new file mode 100644 index 00000000000..d2eed20cd83 --- /dev/null +++ b/Firestore/Swift/Source/Helper/PipelineHelper.swift @@ -0,0 +1,51 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +enum Helper { + static func valueToDefaultExpr(_ value: Any) -> any Expr { + if value is Expr { + return value as! Expr + } else if value is [String: Any] { + return map(value as! [String: Any]) + } else if value is [Any] { + return array(value as! [Any]) + } else { + return Constant(value) + } + } + + static func vectorToExpr(_ value: VectorValue) -> any Expr { + return Field("PLACEHOLDER") + } + + static func timeUnitToExpr(_ value: TimeUnit) -> any Expr { + return Field("PLACEHOLDER") + } + + static func map(_ elements: [String: Any]) -> FunctionExpr { + var result: [Expr] = [] + for (key, value) in elements { + result.append(Constant(key)) + result.append(valueToDefaultExpr(value)) + } + return FunctionExpr("map", result) + } + + static func array(_ elements: [Any]) -> FunctionExpr { + let transformedElements = elements.map { element in + valueToDefaultExpr(element) + } + return FunctionExpr("array", transformedElements) + } +} diff --git a/Firestore/Swift/Source/SelectableInternal.swift b/Firestore/Swift/Source/SelectableInternal.swift new file mode 100644 index 00000000000..8f35e738dec --- /dev/null +++ b/Firestore/Swift/Source/SelectableInternal.swift @@ -0,0 +1,18 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +protocol SelectableInternal: Sendable { + var alias: String { get } + var expr: Expr { get } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Expressions.swift b/Firestore/Swift/Source/SwiftAPI/Expressions.swift deleted file mode 100644 index 729b5c9fb67..00000000000 --- a/Firestore/Swift/Source/SwiftAPI/Expressions.swift +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2025 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Foundation - -public protocol Expr { - var bridge: ExprBridge { get } -} - -public struct Constant: Expr { - public var bridge: ExprBridge - - var value: any Numeric - init(value: any Numeric) { - self.value = value - bridge = ConstantBridge(value as! NSNumber) - } -} - -public func constant(_ number: any Numeric) -> Constant { - return Constant(value: number) -} - -public struct Field: Expr { - public var bridge: ExprBridge - - var name: String - init(name: String) { - self.name = name - bridge = FieldBridge(name) - } -} - -public func field(_ name: String) -> Field { - return Field(name: name) -} - -protocol Function: Expr { - var name: String { get } -} - -public struct FunctionExpr: Function { - public var bridge: ExprBridge - - var name: String - private var args: [Expr] - - init(name: String, args: [Expr]) { - self.name = name - self.args = args - bridge = FunctionExprBridge(name: name, args: args.map { $0.bridge }) - } -} - -public func eq(_ left: Expr, _ right: Expr) -> FunctionExpr { - return FunctionExpr(name: "eq", args: [left, right]) -} diff --git a/Firestore/Swift/Source/SwiftAPI/Firestore+Pipeline.swift b/Firestore/Swift/Source/SwiftAPI/Firestore+Pipeline.swift index 0179ece4e04..e35a9bceac5 100644 --- a/Firestore/Swift/Source/SwiftAPI/Firestore+Pipeline.swift +++ b/Firestore/Swift/Source/SwiftAPI/Firestore+Pipeline.swift @@ -14,10 +14,16 @@ * limitations under the License. */ +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternalWrapper +#else + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE import Foundation @objc public extension Firestore { + @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) @nonobjc func pipeline() -> PipelineSource { - return PipelineSource(db: self) + return PipelineSource(self) } } diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline.swift deleted file mode 100644 index 8c8a4364d30..00000000000 --- a/Firestore/Swift/Source/SwiftAPI/Pipeline.swift +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2025 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Foundation - -public struct Pipeline { - private var stages: [Stage] - private var bridge: PipelineBridge - private let db: Firestore - - init(stages: [Stage], db: Firestore) { - self.stages = stages - self.db = db - bridge = PipelineBridge(stages: stages.map { $0.bridge }, db: db) - } - - public func `where`(_ condition: Expr) -> Pipeline { - return Pipeline(stages: stages + [Where(condition: condition)], db: db) - } - - public func execute() async throws -> PipelineSnapshot { - return try await withCheckedThrowingContinuation { continuation in - self.bridge.execute { result, error in - if let error { - continuation.resume(throwing: error) - } else { - continuation.resume(returning: PipelineSnapshot(result!)) - } - } - } - } -} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregation/AggregateFunction.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregation/AggregateFunction.swift new file mode 100644 index 00000000000..9a36df9fd04 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregation/AggregateFunction.swift @@ -0,0 +1,27 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public class AggregateFunction: @unchecked Sendable { + let functionName: String + let agrs: [Expr] + + public init(_ functionName: String, _ agrs: [Expr]) { + self.functionName = functionName + self.agrs = agrs + } + + public func `as`(_ name: String) -> AggregateWithAlias { + return AggregateWithAlias(aggregate: self, alias: name) + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregation/AggregateWithAlias.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregation/AggregateWithAlias.swift new file mode 100644 index 00000000000..8a1871907c6 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregation/AggregateWithAlias.swift @@ -0,0 +1,18 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public struct AggregateWithAlias { + public let aggregate: AggregateFunction + public let alias: String +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregation/CountAll.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregation/CountAll.swift new file mode 100644 index 00000000000..064eb6d99bc --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregation/CountAll.swift @@ -0,0 +1,19 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public class CountAll: AggregateFunction, @unchecked Sendable { + public init() { + super.init("count", []) + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/ArrayContains.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/ArrayContains.swift new file mode 100644 index 00000000000..df426d36f79 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/ArrayContains.swift @@ -0,0 +1,19 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public class ArrayContains: BooleanExpr, @unchecked Sendable { + public init(fieldName: String, values: Any...) { + super.init("array_concat", values.map { Helper.valueToDefaultExpr($0) }) + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Ascending.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Ascending.swift new file mode 100644 index 00000000000..e872b6e7f8a --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Ascending.swift @@ -0,0 +1,19 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public class Ascending: Ordering, @unchecked Sendable { + public init(_ fieldName: String) { + super.init(expr: Field(fieldName), direction: .ascending) + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Count.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Count.swift new file mode 100644 index 00000000000..470cd3d1d5a --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Count.swift @@ -0,0 +1,13 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Descending.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Descending.swift new file mode 100644 index 00000000000..584d7b7ada3 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Descending.swift @@ -0,0 +1,19 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public class Descending: Ordering, @unchecked Sendable { + public init(_ fieldName: String) { + super.init(expr: Field(fieldName), direction: .descending) + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/DistanceMeasure.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/DistanceMeasure.swift new file mode 100644 index 00000000000..6bd54e9e71b --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/DistanceMeasure.swift @@ -0,0 +1,47 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternalWrapper +#else + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE + +import Foundation + +public struct DistanceMeasure: Sendable, Equatable, Hashable { + let kind: Kind + + enum Kind: String { + case euclidean + case cosine + case dotProduct = "dot_product" + } + + public static var euclidean: DistanceMeasure { + return self.init(kind: .euclidean) + } + + public static var cosine: DistanceMeasure { + return self.init(kind: .cosine) + } + + public static var dotProduct: DistanceMeasure { + return self.init(kind: .dotProduct) + } + + init(kind: Kind) { + self.kind = kind + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr.swift new file mode 100644 index 00000000000..8cb92042303 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr.swift @@ -0,0 +1,807 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF Sendable KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternalWrapper +#else + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE +import Foundation + +public protocol Expr: Sendable { + func `as`(_ name: String) -> ExprWithAlias + + // MARK: Arithmetic Operators + + func add(_ second: Expr, _ others: Expr...) -> FunctionExpr + func add(_ second: Sendable, _ others: Sendable...) -> FunctionExpr + + func subtract(_ other: Expr) -> FunctionExpr + func subtract(_ other: Sendable) -> FunctionExpr + + func multiply(_ second: Expr, _ others: Expr...) -> FunctionExpr + func multiply(_ second: Sendable, _ others: Sendable...) -> FunctionExpr + + func divide(_ other: Expr) -> FunctionExpr + func divide(_ other: Sendable) -> FunctionExpr + + func mod(_ other: Expr) -> FunctionExpr + func mod(_ other: Sendable) -> FunctionExpr + + // MARK: Array Operations + + func arrayConcat(_ secondArray: Expr, _ otherArrays: Expr...) -> FunctionExpr + func arrayConcat(_ secondArray: [Sendable], _ otherArrays: [Sendable]...) -> FunctionExpr + + func arrayContains(_ element: Expr) -> BooleanExpr + func arrayContains(_ element: Sendable) -> BooleanExpr + + func arrayContainsAll(_ values: Expr...) -> BooleanExpr + func arrayContainsAll(_ values: Sendable...) -> BooleanExpr + + func arrayContainsSendable(_ values: Expr...) -> BooleanExpr + func arrayContainsSendable(_ values: Sendable...) -> BooleanExpr + + func arrayLength() -> FunctionExpr + + func arrayOffset(_ offset: Int) -> FunctionExpr + func arrayOffset(_ offsetExpr: Expr) -> FunctionExpr + + // MARK: Equality with Sendable + + func eqSendable(_ others: Expr...) -> BooleanExpr + func eqSendable(_ others: Sendable...) -> BooleanExpr + + func notEqSendable(_ others: Expr...) -> BooleanExpr + func notEqSendable(_ others: Sendable...) -> BooleanExpr + + // MARK: Checks + + func isNan() -> BooleanExpr + func isNull() -> BooleanExpr + func exists() -> BooleanExpr + func isError() -> BooleanExpr + func isAbsent() -> BooleanExpr + func isNotNull() -> BooleanExpr + func isNotNan() -> BooleanExpr + + // MARK: String Operations + + func charLength() -> FunctionExpr + func like(_ pattern: String) -> FunctionExpr + func like(_ pattern: Expr) -> FunctionExpr + + func regexContains(_ pattern: String) -> BooleanExpr + func regexContains(_ pattern: Expr) -> BooleanExpr + + func regexMatch(_ pattern: String) -> BooleanExpr + func regexMatch(_ pattern: Expr) -> BooleanExpr + + func strContains(_ substring: String) -> BooleanExpr + func strContains(_ expr: Expr) -> BooleanExpr + + func startsWith(_ prefix: String) -> BooleanExpr + func startsWith(_ prefix: Expr) -> BooleanExpr + + func endsWith(_ suffix: String) -> BooleanExpr + func endsWith(_ suffix: Expr) -> BooleanExpr + + func lowercased() -> FunctionExpr + func uppercased() -> FunctionExpr + func trim() -> FunctionExpr + + func strConcat(_ secondString: Expr, _ otherStrings: Expr...) -> FunctionExpr + func strConcat(_ secondString: String, _ otherStrings: String...) -> FunctionExpr + + func reverse() -> FunctionExpr + func replaceFirst(_ find: String, _ replace: String) -> FunctionExpr + func replaceFirst(_ find: Expr, _ replace: Expr) -> FunctionExpr + func replaceAll(_ find: String, _ replace: String) -> FunctionExpr + func replaceAll(_ find: Expr, _ replace: Expr) -> FunctionExpr + + func byteLength() -> FunctionExpr + + func substr(_ position: Int, _ length: Int?) -> FunctionExpr + func substr(_ position: Expr, _ length: Expr?) -> FunctionExpr + + // MARK: Map Operations + + func mapGet(_ subfield: String) -> FunctionExpr + func mapRemove(_ key: String) -> FunctionExpr + func mapRemove(_ keyExpr: Expr) -> FunctionExpr + func mapMerge(_ secondMap: [String: Sendable], _ otherMaps: [String: Sendable]...) -> FunctionExpr + func mapMerge(_ secondMap: Expr, _ otherMaps: Expr...) -> FunctionExpr + + // MARK: Aggregations + + func count() -> AggregateFunction + func sum() -> AggregateFunction + func avg() -> AggregateFunction + func minimum() -> AggregateFunction + func maximum() -> AggregateFunction + + // MARK: Logical min/max + + func logicalMaximum(_ second: Expr, _ others: Expr...) -> FunctionExpr + func logicalMaximum(_ second: Sendable, _ others: Sendable...) -> FunctionExpr + + func logicalMinimum(_ second: Expr, _ others: Expr...) -> FunctionExpr + func logicalMinimum(_ second: Sendable, _ others: Sendable...) -> FunctionExpr + + // MARK: Vector Operations + + func vectorLength() -> FunctionExpr + func cosineDistance(_ other: Expr) -> FunctionExpr + func cosineDistance(_ other: VectorValue) -> FunctionExpr + func cosineDistance(_ other: [Double]) -> FunctionExpr + + func dotProduct(_ other: Expr) -> FunctionExpr + func dotProduct(_ other: VectorValue) -> FunctionExpr + func dotProduct(_ other: [Double]) -> FunctionExpr + + func euclideanDistance(_ other: Expr) -> FunctionExpr + func euclideanDistance(_ other: VectorValue) -> FunctionExpr + func euclideanDistance(_ other: [Double]) -> FunctionExpr + + func manhattanDistance(_ other: Expr) -> FunctionExpr + func manhattanDistance(_ other: VectorValue) -> FunctionExpr + func manhattanDistance(_ other: [Double]) -> FunctionExpr + + // MARK: Timestamp operations + + func unixMicrosToTimestamp() -> FunctionExpr + func timestampToUnixMicros() -> FunctionExpr + func unixMillisToTimestamp() -> FunctionExpr + func timestampToUnixMillis() -> FunctionExpr + func unixSecondsToTimestamp() -> FunctionExpr + func timestampToUnixSeconds() -> FunctionExpr + + func timestampAdd(_ unit: Expr, _ amount: Expr) -> FunctionExpr + func timestampAdd(_ unit: TimeUnit, _ amount: Int) -> FunctionExpr + func timestampSub(_ unit: Expr, _ amount: Expr) -> FunctionExpr + func timestampSub(_ unit: TimeUnit, _ amount: Int) -> FunctionExpr + + // MARK: - Bitwise operations + + func bitAnd(_ otherBits: Int) -> FunctionExpr + func bitAnd(_ otherBits: UInt8) -> FunctionExpr + func bitAnd(_ bitsExpression: Expr) -> FunctionExpr + + func bitOr(_ otherBits: Int) -> FunctionExpr + func bitOr(_ otherBits: UInt8) -> FunctionExpr + func bitOr(_ bitsExpression: Expr) -> FunctionExpr + + func bitXor(_ otherBits: Int) -> FunctionExpr + func bitXor(_ otherBits: UInt8) -> FunctionExpr + func bitXor(_ bitsExpression: Expr) -> FunctionExpr + + func bitNot() -> FunctionExpr + + func bitLeftShift(_ y: Int) -> FunctionExpr + func bitLeftShift(_ numberExpr: Expr) -> FunctionExpr + + func bitRightShift(_ y: Int) -> FunctionExpr + func bitRightShift(_ numberExpr: Expr) -> FunctionExpr + + func ifError(_ catchExpr: Expr) -> FunctionExpr + func ifError(_ catchValue: Sendable) -> FunctionExpr + + // MARK: Sorting + + func ascending() -> Ordering + func descending() -> Ordering +} + +public extension Expr { + func `as`(_ name: String) -> ExprWithAlias { + return ExprWithAlias(self, name) + } + + // MARK: Comparison Operators + + func eq(_ other: Expr) -> BooleanExpr { + return BooleanExpr("eq", [self, other]) + } + + func eq(_ other: Sendable) -> BooleanExpr { + return BooleanExpr("eq", [self, Helper.valueToDefaultExpr(other)]) + } + + func neq(_ other: Expr) -> BooleanExpr { + return BooleanExpr("neq", [self, other]) + } + + func neq(_ other: Sendable) -> BooleanExpr { + return BooleanExpr("neq", [self, Helper.valueToDefaultExpr(other)]) + } + + func lt(_ other: Expr) -> BooleanExpr { + return BooleanExpr("lt", [self, other]) + } + + func lt(_ other: Sendable) -> BooleanExpr { + return BooleanExpr("lt", [self, Helper.valueToDefaultExpr(other)]) + } + + func lte(_ other: Expr) -> BooleanExpr { + return BooleanExpr("lte", [self, other]) + } + + func lte(_ other: Sendable) -> BooleanExpr { + return BooleanExpr("lte", [self, Helper.valueToDefaultExpr(other)]) + } + + func gt(_ other: Expr) -> BooleanExpr { + return BooleanExpr("gt", [self, other]) + } + + func gt(_ other: Sendable) -> BooleanExpr { + return BooleanExpr("gt", [self, Helper.valueToDefaultExpr(other)]) + } + + func gte(_ other: Expr) -> BooleanExpr { + return BooleanExpr("gte", [self, other]) + } + + func gte(_ other: Sendable) -> BooleanExpr { + return BooleanExpr("gte", [self, Helper.valueToDefaultExpr(other)]) + } + + // MARK: Arithmetic Operators + + func add(_ second: Expr, _ others: Expr...) -> FunctionExpr { + return FunctionExpr("add", [self, second] + others) + } + + func add(_ second: Sendable, _ others: Sendable...) -> FunctionExpr { + let exprs = [self] + [Helper.valueToDefaultExpr(second)] + others + .map { Helper.valueToDefaultExpr($0) } + return FunctionExpr("add", exprs) + } + + func subtract(_ other: Expr) -> FunctionExpr { + return FunctionExpr("subtract", [self, other]) + } + + func subtract(_ other: Sendable) -> FunctionExpr { + return FunctionExpr("subtract", [self, Helper.valueToDefaultExpr(other)]) + } + + func multiply(_ second: Expr, _ others: Expr...) -> FunctionExpr { + return FunctionExpr("multiply", [self, second] + others) + } + + func multiply(_ second: Sendable, _ others: Sendable...) -> FunctionExpr { + let exprs = [self] + [Helper.valueToDefaultExpr(second)] + others + .map { Helper.valueToDefaultExpr($0) } + return FunctionExpr("multiply", exprs) + } + + func divide(_ other: Expr) -> FunctionExpr { + return FunctionExpr("divide", [self, other]) + } + + func divide(_ other: Sendable) -> FunctionExpr { + return FunctionExpr("divide", [self, Helper.valueToDefaultExpr(other)]) + } + + func mod(_ other: Expr) -> FunctionExpr { + return FunctionExpr("mod", [self, other]) + } + + func mod(_ other: Sendable) -> FunctionExpr { + return FunctionExpr("mod", [self, Helper.valueToDefaultExpr(other)]) + } + + // MARK: Array Operations + + func arrayConcat(_ secondArray: Expr, _ otherArrays: Expr...) -> FunctionExpr { + return FunctionExpr("array_concat", [self, secondArray] + otherArrays) + } + + func arrayConcat(_ secondArray: [Sendable], _ otherArrays: [Sendable]...) -> FunctionExpr { + let exprs = [self] + [Helper.valueToDefaultExpr(secondArray)] + otherArrays + .map { Helper.valueToDefaultExpr($0) } + return FunctionExpr("array_concat", exprs) + } + + func arrayContains(_ element: Expr) -> BooleanExpr { + return BooleanExpr("array_contains", [self, element]) + } + + func arrayContains(_ element: Sendable) -> BooleanExpr { + return BooleanExpr("array_contains", [self, Helper.valueToDefaultExpr(element)]) + } + + func arrayContainsAll(_ values: Expr...) -> BooleanExpr { + return BooleanExpr("array_contains_all", [self] + values) + } + + func arrayContainsAll(_ values: Sendable...) -> BooleanExpr { + let exprValues = values.map { Helper.valueToDefaultExpr($0) } + return BooleanExpr("array_contains_all", [self] + exprValues) + } + + func arrayContainsSendable(_ values: Expr...) -> BooleanExpr { + return BooleanExpr("array_contains_Sendable", [self] + values) + } + + func arrayContainsSendable(_ values: Sendable...) -> BooleanExpr { + let exprValues = values.map { Helper.valueToDefaultExpr($0) } + return BooleanExpr("array_contains_Sendable", [self] + exprValues) + } + + func arrayLength() -> FunctionExpr { + return FunctionExpr("array_length", [self]) + } + + func arrayOffset(_ offset: Int) -> FunctionExpr { + return FunctionExpr("array_offset", [self, Helper.valueToDefaultExpr(offset)]) + } + + func arrayOffset(_ offsetExpr: Expr) -> FunctionExpr { + return FunctionExpr("array_offset", [self, offsetExpr]) + } + + // MARK: Equality with Sendable + + func eqSendable(_ others: Expr...) -> BooleanExpr { + return BooleanExpr("eq_Sendable", [self] + others) + } + + func eqSendable(_ others: Sendable...) -> BooleanExpr { + let exprOthers = others.map { Helper.valueToDefaultExpr($0) } + return BooleanExpr("eq_Sendable", [self] + exprOthers) + } + + func notEqSendable(_ others: Expr...) -> BooleanExpr { + return BooleanExpr("not_eq_Sendable", [self] + others) + } + + func notEqSendable(_ others: Sendable...) -> BooleanExpr { + let exprOthers = others.map { Helper.valueToDefaultExpr($0) } + return BooleanExpr("not_eq_Sendable", [self] + exprOthers) + } + + // MARK: Checks + + func isNan() -> BooleanExpr { + return BooleanExpr("is_nan", [self]) + } + + func isNull() -> BooleanExpr { + return BooleanExpr("is_null", [self]) + } + + func exists() -> BooleanExpr { + return BooleanExpr("exists", [self]) + } + + func isError() -> BooleanExpr { + return BooleanExpr("is_error", [self]) + } + + func isAbsent() -> BooleanExpr { + return BooleanExpr("is_absent", [self]) + } + + func isNotNull() -> BooleanExpr { + return BooleanExpr("is_not_null", [self]) + } + + func isNotNan() -> BooleanExpr { + return BooleanExpr("is_not_nan", [self]) + } + + // MARK: String Operations + + func charLength() -> FunctionExpr { + return FunctionExpr("char_length", [self]) + } + + func like(_ pattern: String) -> FunctionExpr { + return FunctionExpr("like", [self, Helper.valueToDefaultExpr(pattern)]) + } + + func like(_ pattern: Expr) -> FunctionExpr { + return FunctionExpr("like", [self, pattern]) + } + + func regexContains(_ pattern: String) -> BooleanExpr { + return BooleanExpr("regex_contains", [self, Helper.valueToDefaultExpr(pattern)]) + } + + func regexContains(_ pattern: Expr) -> BooleanExpr { + return BooleanExpr("regex_contains", [self, pattern]) + } + + func regexMatch(_ pattern: String) -> BooleanExpr { + return BooleanExpr("regex_match", [self, Helper.valueToDefaultExpr(pattern)]) + } + + func regexMatch(_ pattern: Expr) -> BooleanExpr { + return BooleanExpr("regex_match", [self, pattern]) + } + + func strContains(_ substring: String) -> BooleanExpr { + return BooleanExpr("str_contains", [self, Helper.valueToDefaultExpr(substring)]) + } + + func strContains(_ expr: Expr) -> BooleanExpr { + return BooleanExpr("str_contains", [self, expr]) + } + + func startsWith(_ prefix: String) -> BooleanExpr { + return BooleanExpr("starts_with", [self, Helper.valueToDefaultExpr(prefix)]) + } + + func startsWith(_ prefix: Expr) -> BooleanExpr { + return BooleanExpr("starts_with", [self, prefix]) + } + + func endsWith(_ suffix: String) -> BooleanExpr { + return BooleanExpr("ends_with", [self, Helper.valueToDefaultExpr(suffix)]) + } + + func endsWith(_ suffix: Expr) -> BooleanExpr { + return BooleanExpr("ends_with", [self, suffix]) + } + + func lowercased() -> FunctionExpr { + return FunctionExpr("to_lower", [self]) + } + + func uppercased() -> FunctionExpr { + return FunctionExpr("to_upper", [self]) + } + + func trim() -> FunctionExpr { + return FunctionExpr("trim", [self]) + } + + func strConcat(_ secondString: Expr, _ otherStrings: Expr...) -> FunctionExpr { + return FunctionExpr("str_concat", [self, secondString] + otherStrings) + } + + func strConcat(_ secondString: String, _ otherStrings: String...) -> FunctionExpr { + let exprs = [self] + [Helper.valueToDefaultExpr(secondString)] + otherStrings + .map { Helper.valueToDefaultExpr($0) } + return FunctionExpr("str_concat", exprs) + } + + func reverse() -> FunctionExpr { + return FunctionExpr("reverse", [self]) + } + + func replaceFirst(_ find: String, _ replace: String) -> FunctionExpr { + return FunctionExpr( + "replace_first", + [self, Helper.valueToDefaultExpr(find), Helper.valueToDefaultExpr(replace)] + ) + } + + func replaceFirst(_ find: Expr, _ replace: Expr) -> FunctionExpr { + return FunctionExpr("replace_first", [self, find, replace]) + } + + func replaceAll(_ find: String, _ replace: String) -> FunctionExpr { + return FunctionExpr( + "replace_all", + [self, Helper.valueToDefaultExpr(find), Helper.valueToDefaultExpr(replace)] + ) + } + + func replaceAll(_ find: Expr, _ replace: Expr) -> FunctionExpr { + return FunctionExpr("replace_all", [self, find, replace]) + } + + func byteLength() -> FunctionExpr { + return FunctionExpr("byte_length", [self]) + } + + func substr(_ position: Int, _ length: Int? = nil) -> FunctionExpr { + let positionExpr = Helper.valueToDefaultExpr(position) + if let length = length { + return FunctionExpr("substr", [self, positionExpr, Helper.valueToDefaultExpr(length)]) + } else { + return FunctionExpr("substr", [self, positionExpr]) + } + } + + func substr(_ position: Expr, _ length: Expr? = nil) -> FunctionExpr { + if let length = length { + return FunctionExpr("substr", [self, position, length]) + } else { + return FunctionExpr("substr", [self, position]) + } + } + + // MARK: Map Operations + + func mapGet(_ subfield: String) -> FunctionExpr { + return FunctionExpr("map_get", [self, Constant(subfield)]) + } + + func mapRemove(_ key: String) -> FunctionExpr { + return FunctionExpr("map_remove", [self, Helper.valueToDefaultExpr(key)]) + } + + func mapRemove(_ keyExpr: Expr) -> FunctionExpr { + return FunctionExpr("map_remove", [self, keyExpr]) + } + + func mapMerge(_ secondMap: [String: Sendable], + _ otherMaps: [String: Sendable]...) -> FunctionExpr { + let secondMapExpr = Helper.valueToDefaultExpr(secondMap) + let otherMapExprs = otherMaps.map { Helper.valueToDefaultExpr($0) } + return FunctionExpr("map_merge", [self, secondMapExpr] + otherMapExprs) + } + + func mapMerge(_ secondMap: Expr, _ otherMaps: Expr...) -> FunctionExpr { + return FunctionExpr("map_merge", [self, secondMap] + otherMaps) + } + + // MARK: Aggregations + + func count() -> AggregateFunction { + return AggregateFunction("count", [self]) + } + + func sum() -> AggregateFunction { + return AggregateFunction("sum", [self]) + } + + func avg() -> AggregateFunction { + return AggregateFunction("avg", [self]) + } + + func minimum() -> AggregateFunction { + return AggregateFunction("minimum", [self]) + } + + func maximum() -> AggregateFunction { + return AggregateFunction("maximum", [self]) + } + + // MARK: Logical min/max + + func logicalMaximum(_ second: Expr, _ others: Expr...) -> FunctionExpr { + return FunctionExpr("logical_maximum", [self, second] + others) + } + + func logicalMaximum(_ second: Sendable, _ others: Sendable...) -> FunctionExpr { + let exprs = [self] + [Helper.valueToDefaultExpr(second)] + others + .map { Helper.valueToDefaultExpr($0) } + return FunctionExpr("logical_maximum", exprs) + } + + func logicalMinimum(_ second: Expr, _ others: Expr...) -> FunctionExpr { + return FunctionExpr("logical_min", [self, second] + others) + } + + func logicalMinimum(_ second: Sendable, _ others: Sendable...) -> FunctionExpr { + let exprs = [self] + [Helper.valueToDefaultExpr(second)] + others + .map { Helper.valueToDefaultExpr($0) } + return FunctionExpr("logical_min", exprs) + } + + // MARK: Vector Operations + + func vectorLength() -> FunctionExpr { + return FunctionExpr("vector_length", [self]) + } + + func cosineDistance(_ other: Expr) -> FunctionExpr { + return FunctionExpr("cosine_distance", [self, other]) + } + + func cosineDistance(_ other: VectorValue) -> FunctionExpr { + return FunctionExpr("cosine_distance", [self, Helper.vectorToExpr(other)]) + } + + func cosineDistance(_ other: [Double]) -> FunctionExpr { + return FunctionExpr("cosine_distance", [self, Helper.valueToDefaultExpr(other)]) + } + + func dotProduct(_ other: Expr) -> FunctionExpr { + return FunctionExpr("dot_product", [self, other]) + } + + func dotProduct(_ other: VectorValue) -> FunctionExpr { + return FunctionExpr("dot_product", [self, Helper.vectorToExpr(other)]) + } + + func dotProduct(_ other: [Double]) -> FunctionExpr { + return FunctionExpr("dot_product", [self, Helper.valueToDefaultExpr(other)]) + } + + func euclideanDistance(_ other: Expr) -> FunctionExpr { + return FunctionExpr("euclidean_distance", [self, other]) + } + + func euclideanDistance(_ other: VectorValue) -> FunctionExpr { + return FunctionExpr("euclidean_distance", [self, Helper.vectorToExpr(other)]) + } + + func euclideanDistance(_ other: [Double]) -> FunctionExpr { + return FunctionExpr("euclidean_distance", [self, Helper.valueToDefaultExpr(other)]) + } + + func manhattanDistance(_ other: Expr) -> FunctionExpr { + return FunctionExpr("manhattan_distance", [self, other]) + } + + func manhattanDistance(_ other: VectorValue) -> FunctionExpr { + return FunctionExpr("manhattan_distance", [self, Helper.vectorToExpr(other)]) + } + + func manhattanDistance(_ other: [Double]) -> FunctionExpr { + return FunctionExpr("manhattan_distance", [self, Helper.valueToDefaultExpr(other)]) + } + + // MARK: Timestamp operations + + func unixMicrosToTimestamp() -> FunctionExpr { + return FunctionExpr("unix_micros_to_timestamp", [self]) + } + + func timestampToUnixMicros() -> FunctionExpr { + return FunctionExpr("timestamp_to_unix_micros", [self]) + } + + func unixMillisToTimestamp() -> FunctionExpr { + return FunctionExpr("unix_millis_to_timestamp", [self]) + } + + func timestampToUnixMillis() -> FunctionExpr { + return FunctionExpr("timestamp_to_unix_millis", [self]) + } + + func unixSecondsToTimestamp() -> FunctionExpr { + return FunctionExpr("unix_seconds_to_timestamp", [self]) + } + + func timestampToUnixSeconds() -> FunctionExpr { + return FunctionExpr("timestamp_to_unix_seconds", [self]) + } + + func timestampAdd(_ unit: Expr, _ amount: Expr) -> FunctionExpr { + return FunctionExpr("timestamp_add", [self, unit, amount]) + } + + func timestampAdd(_ unit: TimeUnit, _ amount: Int) -> FunctionExpr { + return FunctionExpr( + "timestamp_add", + [self, Helper.timeUnitToExpr(unit), Helper.valueToDefaultExpr(amount)] + ) + } + + func timestampSub(_ unit: Expr, _ amount: Expr) -> FunctionExpr { + return FunctionExpr("timestamp_sub", [self, unit, amount]) + } + + func timestampSub(_ unit: TimeUnit, _ amount: Int) -> FunctionExpr { + return FunctionExpr( + "timestamp_sub", + [self, Helper.timeUnitToExpr(unit), Helper.valueToDefaultExpr(amount)] + ) + } + + // MARK: - Bitwise operations + + func bitAnd(_ otherBits: Int) -> FunctionExpr { + return FunctionExpr("bit_and", [self, Helper.valueToDefaultExpr(otherBits)]) + } + + func bitAnd(_ otherBits: UInt8) -> FunctionExpr { + return FunctionExpr("bit_and", [self, Helper.valueToDefaultExpr(otherBits)]) + } + + func bitAnd(_ bitsExpression: Expr) -> FunctionExpr { + return FunctionExpr("bit_and", [self, bitsExpression]) + } + + func bitOr(_ otherBits: Int) -> FunctionExpr { + return FunctionExpr("bit_or", [self, Helper.valueToDefaultExpr(otherBits)]) + } + + func bitOr(_ otherBits: UInt8) -> FunctionExpr { + return FunctionExpr("bit_or", [self, Helper.valueToDefaultExpr(otherBits)]) + } + + func bitOr(_ bitsExpression: Expr) -> FunctionExpr { + return FunctionExpr("bit_or", [self, bitsExpression]) + } + + func bitXor(_ otherBits: Int) -> FunctionExpr { + return FunctionExpr("bit_xor", [self, Helper.valueToDefaultExpr(otherBits)]) + } + + func bitXor(_ otherBits: UInt8) -> FunctionExpr { + return FunctionExpr("bit_xor", [self, Helper.valueToDefaultExpr(otherBits)]) + } + + func bitXor(_ bitsExpression: Expr) -> FunctionExpr { + return FunctionExpr("bit_xor", [self, bitsExpression]) + } + + func bitNot() -> FunctionExpr { + return FunctionExpr("bit_not", [self]) + } + + func bitLeftShift(_ y: Int) -> FunctionExpr { + return FunctionExpr("bit_left_shift", [self, Helper.valueToDefaultExpr(y)]) + } + + func bitLeftShift(_ numberExpr: Expr) -> FunctionExpr { + return FunctionExpr("bit_left_shift", [self, numberExpr]) + } + + func bitRightShift(_ y: Int) -> FunctionExpr { + return FunctionExpr("bit_right_shift", [self, Helper.valueToDefaultExpr(y)]) + } + + func bitRightShift(_ numberExpr: Expr) -> FunctionExpr { + return FunctionExpr("bit_right_shift", [self, numberExpr]) + } + + func documentId() -> FunctionExpr { + return FunctionExpr("document_id", [self]) + } + + func ifError(_ catchExpr: Expr) -> FunctionExpr { + return FunctionExpr("if_error", [self, catchExpr]) + } + + func ifError(_ catchValue: Sendable) -> FunctionExpr { + return FunctionExpr("if_error", [self, Helper.valueToDefaultExpr(catchValue)]) + } + + // MARK: Sorting + + func ascending() -> Ordering { + return Ordering(expr: self, direction: .ascending) + } + + func descending() -> Ordering { + return Ordering(expr: self, direction: .descending) + } +} + +// protocal cannot overwrite operator, since every inheritated class will have this function +// it will lead to error: Generic parameter 'Self' could not be inferred + +public func > (lhs: Expr, rhs: @autoclosure () throws -> Sendable) rethrows -> BooleanExpr { + try BooleanExpr("gt", [lhs, Helper.valueToDefaultExpr(rhs())]) +} + +public func >= (lhs: Expr, rhs: @autoclosure () throws -> Sendable) rethrows -> BooleanExpr { + try BooleanExpr("gte", [lhs, Helper.valueToDefaultExpr(rhs())]) +} + +public func < (lhs: Expr, rhs: @autoclosure () throws -> Sendable) rethrows -> BooleanExpr { + try BooleanExpr("lt", [lhs, Helper.valueToDefaultExpr(rhs())]) +} + +public func <= (lhs: Expr, rhs: @autoclosure () throws -> Sendable) rethrows -> BooleanExpr { + try BooleanExpr("lte", [lhs, Helper.valueToDefaultExpr(rhs())]) +} + +public func == (lhs: Expr, rhs: @autoclosure () throws -> Sendable) rethrows -> BooleanExpr { + try BooleanExpr("eq", [lhs, Helper.valueToDefaultExpr(rhs())]) +} + +public func != (lhs: Expr, rhs: @autoclosure () throws -> Sendable) rethrows -> BooleanExpr { + try BooleanExpr("neq", [lhs, Helper.valueToDefaultExpr(rhs())]) +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/Constant.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/Constant.swift new file mode 100644 index 00000000000..5d3109a5fcb --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/Constant.swift @@ -0,0 +1,74 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternalWrapper +#else + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE + +public struct Constant: Expr, BridgeWrapper, @unchecked Sendable { + var bridge: ExprBridge + + let value: Any? + + // Initializer for optional values (including nil) + init(_ value: Any?) { + self.value = value + // TODO: + bridge = ConstantBridge(value) + } + + // Initializer for numbers + public init(_ value: Double) { + self.init(value as Any) + } + + // Initializer for strings + public init(_ value: String) { + self.init(value as Any) + } + + // Initializer for boolean values + public init(_ value: Bool) { + self.init(value as Any) + } + + // Initializer for GeoPoint values + public init(_ value: GeoPoint) { + self.init(value as Any) + } + + // Initializer for Timestamp values + public init(_ value: Timestamp) { + self.init(value as Any) + } + + // Initializer for Date values + public init(_ value: Date) { + self.init(value as Any) + } + + // Initializer for DocumentReference + public init(_ value: DocumentReference) { + self.init(value as Any) + } + + // Initializer for vector values + public init(_ value: VectorValue) { + self.init(value as Any) + } + + public static let `nil` = Constant(nil) +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/DocumentId.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/DocumentId.swift new file mode 100644 index 00000000000..70c621d8cbd --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/DocumentId.swift @@ -0,0 +1,19 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public class DocumentId: Field, @unchecked Sendable { + public init() { + super.init("__name__") + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/Field.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/Field.swift new file mode 100644 index 00000000000..d8c9dcd4961 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/Field.swift @@ -0,0 +1,32 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public class Field: ExprBridge, Expr, Selectable, BridgeWrapper, SelectableInternal, + @unchecked Sendable { + var bridge: ExprBridge + + var alias: String + + var expr: any Expr { + return self + } + + public let fieldName: String + + public init(_ fieldName: String) { + self.fieldName = fieldName + alias = fieldName + bridge = FieldBridge(alias) + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/FunctionExpr.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/FunctionExpr.swift new file mode 100644 index 00000000000..2726caba284 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/FunctionExpr.swift @@ -0,0 +1,30 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public class FunctionExpr: Expr, BridgeWrapper, @unchecked Sendable { + var bridge: ExprBridge + + let functionName: String + let agrs: [Expr] + + public init(_ functionName: String, _ agrs: [Expr]) { + self.functionName = functionName + self.agrs = agrs + bridge = FunctionExprBridge( + name: functionName, + args: self.agrs.map { ($0 as! (Expr & BridgeWrapper)).bridge + } + ) + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/FunctionExpr/BooleanExpr.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/FunctionExpr/BooleanExpr.swift new file mode 100644 index 00000000000..1f6b6af67a3 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Expr/FunctionExpr/BooleanExpr.swift @@ -0,0 +1,34 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public class BooleanExpr: FunctionExpr, @unchecked Sendable { + override public init(_ functionName: String, _ agrs: [Expr]) { + super.init(functionName, agrs) + } + + public static func && (lhs: BooleanExpr, + rhs: @autoclosure () throws -> BooleanExpr) rethrows -> BooleanExpr { + try BooleanExpr("and", [lhs, rhs()]) + } + + public static func || (lhs: BooleanExpr, + rhs: @autoclosure () throws -> BooleanExpr) rethrows -> BooleanExpr { + try BooleanExpr("or", [lhs, rhs()]) + } + + // not + public static prefix func ! (lhs: BooleanExpr) -> BooleanExpr { + return BooleanExpr("not", [lhs]) + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/ExprWithAlias.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/ExprWithAlias.swift new file mode 100644 index 00000000000..af5447541ab --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/ExprWithAlias.swift @@ -0,0 +1,24 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public struct ExprWithAlias: Selectable, Sendable { + public var alias: String + + public var expr: Expr + + init(_ expr: Expr, _ alias: String) { + self.alias = alias + self.expr = expr + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Min.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Min.swift new file mode 100644 index 00000000000..470cd3d1d5a --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Min.swift @@ -0,0 +1,13 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. diff --git a/Firestore/Swift/Source/SwiftAPI/PipelineSource.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Ordering.swift similarity index 50% rename from Firestore/Swift/Source/SwiftAPI/PipelineSource.swift rename to Firestore/Swift/Source/SwiftAPI/Pipeline/Ordering.swift index ce84c0356ac..1761be8ebca 100644 --- a/Firestore/Swift/Source/SwiftAPI/PipelineSource.swift +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Ordering.swift @@ -1,5 +1,5 @@ /* - * Copyright 2025 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,33 @@ * limitations under the License. */ -import Foundation +public class Ordering: @unchecked Sendable { + let expr: Expr + let direction: Direction -public class PipelineSource { - private let db: Firestore - public init(db: Firestore) { - self.db = db + init(expr: Expr, direction: Direction) { + self.expr = expr + self.direction = direction + } +} + +public struct Direction: Sendable, Equatable, Hashable { + let kind: Kind + + enum Kind: String { + case ascending + case descending + } + + public static var ascending: Direction { + return self.init(kind: .ascending) + } + + public static var descending: Direction { + return self.init(kind: .descending) } - public func collection(path: String) -> Pipeline { - return Pipeline(stages: [CollectionSource(collection: path)], db: db) + init(kind: Kind) { + self.kind = kind } } diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Pipeline.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Pipeline.swift new file mode 100644 index 00000000000..5abf45afcfc --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Pipeline.swift @@ -0,0 +1,382 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternalWrapper +#else + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE +import Foundation + +@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) +public struct Pipeline: @unchecked Sendable { + private var stages: [Stage] + private var bridge: PipelineBridge + let db: Firestore + + init(stages: [Stage], db: Firestore) { + self.stages = stages + self.db = db + bridge = PipelineBridge(stages: stages.map { $0.bridge }, db: db) + } + + public func execute() async throws -> PipelineSnapshot { + return try await withCheckedThrowingContinuation { continuation in + self.bridge.execute { result, error in + if let error { + continuation.resume(throwing: error) + } else { + continuation.resume(returning: PipelineSnapshot(result!, pipeline: self)) + } + } + } + } + + /// Adds new fields to outputs from previous stages. + /// + /// This stage allows you to compute values on-the-fly based on existing data from previous + /// stages or constants. You can use this to create new fields or overwrite existing ones. + /// + /// The added fields are defined using `Selectable`s, which can be: + /// + /// - `Field`: References an existing document field. + /// - `Function`: Performs a calculation using functions like `add`, `multiply` with + /// assigned aliases using `Expr.as`. + /// + /// - Parameter fields: The fields to add to the documents, specified as `Selectable`s. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func addFields(_ field: Selectable, _ additionalFields: Selectable...) -> Pipeline { + return self + } + + /// Remove fields from outputs of previous stages. + /// - Parameter fields: The fields to remove. + /// - Returns: A new Pipeline object with this stage appended to the stage list. + public func removeFields(_ field: Field, _ additionalFields: Field...) -> Pipeline { + return self + } + + /// Remove fields from outputs of previous stages. + /// - Parameter fields: The fields to remove. + /// - Returns: A new Pipeline object with this stage appended to the stage list. + public func removeFields(_ field: String, _ additionalFields: String...) -> Pipeline { + return self + } + + /// Selects or creates a set of fields from the outputs of previous stages. + /// + /// The selected fields are defined using `Selectable` expressions, which can be: + /// + /// - `String`: Name of an existing field. + /// - `Field`: References an existing field. + /// - `Function`: Represents the result of a function with an assigned alias name using `Expr#as`. + /// + /// If no selections are provided, the output of this stage is empty. Use `addFields` instead if + /// only additions are desired. + /// + /// - Parameter selections: The fields to include in the output documents, specified as + /// `Selectable` expressions. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func select(_ selection: Selectable, _ additionalSelections: Selectable...) -> Pipeline { + // Implementation + return self + } + + /// Selects or creates a set of fields from the outputs of previous stages. + /// + /// The selected fields are defined using `Selectable` expressions, which can be: + /// + /// - `String`: Name of an existing field. + /// - `Field`: References an existing field. + /// - `Function`: Represents the result of a function with an assigned alias name using `Expr#as`. + /// + /// If no selections are provided, the output of this stage is empty. Use `addFields` instead if + /// only additions are desired. + /// + /// - Parameter selections: `String` values representing field names. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func select(_ selection: String, _ additionalSelections: String...) -> Pipeline { + // Implementation + return self + } + + /// Filters the documents from previous stages to only include those matching the specified + /// `BooleanExpr`. + /// + /// This stage allows you to apply conditions to the data, similar to a "WHERE" clause + /// in SQL. + /// You can filter documents based on their field values, using implementations of + /// `BooleanExpr`, typically including but not limited to: + /// + /// - field comparators: `Function.eq`, `Function.lt` (less than), `Function.gt` (greater than), + /// etc. + /// - logical operators: `Function.and`, `Function.or`, `Function.not`, + /// etc. + /// - advanced functions: `Function.regexMatch`, `Function.arrayContains`, etc. + /// + /// - Parameter condition: The `BooleanExpr` to apply. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func `where`(_ condition: BooleanExpr) -> Pipeline { + return Pipeline(stages: stages + [Where(condition: condition)], db: db) + } + + /// Skips the first `offset` number of documents from the results of previous stages. + /// The negative input number will count back from the result set. + /// + /// This stage is useful for implementing pagination in your pipelines, allowing you to + /// retrieve results in chunks. It is typically used in conjunction with `limit` to control the + /// size of each page. + /// + /// - Parameter offset: The number of documents to skip. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func offset(_ offset: Int32) -> Pipeline { + return Pipeline(stages: stages + [Offset(offset)], db: db) + } + + /// Limits the maximum number of documents returned by previous stages to `limit`. + /// The negative input number will count back from the result set. + /// + /// This stage is particularly useful when you want to retrieve a controlled + /// subset of data from a potentially large result set. It's often used for: + /// + /// - **Pagination:** In combination with `skip` to retrieve specific pages of results. + /// - **Limiting Data Retrieval:** To prevent excessive data transfer and improve + /// performance, especially when dealing with large collections. + /// + /// - Parameter limit: The maximum number of documents to return. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func limit(_ limit: Int32) -> Pipeline { + return Pipeline(stages: stages + [Limit(limit)], db: db) + } + + /// Returns a set of distinct `Expr` values from the inputs to this stage. + /// + /// This stage processes the results from previous stages, ensuring that only unique + /// combinations of `Expr` values (such as `Field` and `Function`) are included. + /// + /// The parameters to this stage are defined using `Selectable` expressions or field names: + /// + /// - `String`: The name of an existing field. + /// - `Field`: A reference to an existing document field. + /// - `Function`: Represents the result of a function with an assigned alias using + /// `Expr.alias(_:)`. + /// + /// - Parameter selections: The fields to include in the output documents, specified as + /// `String` values representing field names. + public func distinct(_ group: String, _ additionalGroups: String...) -> Pipeline { + return self + } + + /// Returns a set of distinct `Expr` values from the inputs to this stage. + /// + /// This stage processes the results from previous stages, ensuring that only unique + /// combinations of `Expr` values (such as `Field` and `Function`) are included. + /// + /// The parameters to this stage are defined using `Selectable` expressions or field names: + /// + /// - `String`: The name of an existing field. + /// - `Field`: A reference to an existing document field. + /// - `Function`: Represents the result of a function with an assigned alias using + /// `Expr.alias(_:)`. + /// + /// - Parameter selections: The fields to include in the output documents, specified as + /// `Selectable` expressions. + public func distinct(_ group: Selectable, _ additionalGroups: Selectable...) -> Pipeline { + return self + } + + /// Performs aggregation operations on the documents from previous stages. + /// + /// This stage allows you to compute aggregate values over a set of documents. + /// Aggregations are defined using `AccumulatorWithAlias`, which wraps an `Accumulator` + /// and provides a name for the accumulated results. These expressions are typically + /// created by calling `alias(_:)` on `Accumulator` instances. + /// + /// - Parameter accumulators: The `AccumulatorWithAlias` expressions, each wrapping an + /// `Accumulator` and assigning a name to the accumulated results. + public func aggregate(_ accumulator: AggregateWithAlias, + _ additionalAccumulators: AggregateWithAlias...) -> Pipeline { + return self + } + + /// Performs optionally grouped aggregation operations on the documents from previous stages. + /// + /// This stage calculates aggregate values over a set of documents, optionally grouped by + /// one or more fields or computed expressions. + /// + /// - **Grouping Fields or Expressions:** Defines how documents are grouped. For each + /// unique combination of values in the specified fields or expressions, a separate group + /// is created. If no grouping fields are provided, all documents are placed into a single + /// group. + /// - **Accumulators:** Defines the accumulation operations to perform within each group. + /// These are provided as `AccumulatorWithAlias` expressions, typically created by + /// calling `alias(_:)` on `Accumulator` instances. Each aggregation computes a + /// value (e.g., sum, average, count) based on the documents in its group. + /// + /// - Parameters: + /// - accumulators: A list of `AccumulatorWithAlias` expressions defining the aggregation + /// calculations. + /// - groups: An optional list of grouping fields or expressions. + /// - Returns: A new `Pipeline` object with this stage appended. + public func aggregate(_ accumulator: [AggregateWithAlias], + groups: [Selectable]? = nil) -> Pipeline { + return self + } + + /// Performs optionally grouped aggregation operations on the documents from previous stages. + /// + /// This stage calculates aggregate values over a set of documents, optionally grouped by + /// one or more fields or computed expressions. + /// + /// - **Grouping Fields or Expressions:** Defines how documents are grouped. For each + /// unique combination of values in the specified fields or expressions, a separate group + /// is created. If no grouping fields are provided, all documents are placed into a single + /// group. + /// - **Accumulators:** Defines the accumulation operations to perform within each group. + /// These are provided as `AccumulatorWithAlias` expressions, typically created by + /// calling `alias(_:)` on `Accumulator` instances. Each aggregation computes a + /// value (e.g., sum, average, count) based on the documents in its group. + /// + /// - Parameters: + /// - accumulators: A list of `AccumulatorWithAlias` expressions defining the aggregation + /// calculations. + /// - groups: An optional list of grouping field names. + /// - Returns: A new `Pipeline` object with this stage appended. + public func aggregate(_ accumulator: [AggregateWithAlias], + groups: [String]? = nil) -> Pipeline { + return self + } + + /// Performs a vector similarity search, ordering the result set by most similar to least + /// similar, and returning the first N documents in the result set. + public func findNearest(field: Field, + vectorValue: [Double], + distanceMeasure: DistanceMeasure, + limit: Int? = nil, + distanceField: String? = nil) -> Pipeline { + return self + } + + /// Sorts the documents from previous stages based on one or more `Ordering` criteria. + /// + /// This stage allows you to order the results of your pipeline. You can specify multiple + /// `Ordering` instances to sort by multiple fields in ascending or descending order. + /// If documents have the same value for a field used for sorting, the next specified ordering + /// will be used. If all orderings result in equal comparison, the documents are considered + /// equal and the order is unspecified. + /// + /// - Parameter orderings: One or more `Ordering` instances specifying the sorting criteria. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func sort(_ ordering: Ordering, _ additionalOrdering: Ordering...) -> Pipeline { + // Implementation + return self + } + + /// Fully overwrites all fields in a document with those coming from a nested map. + /// + /// This stage allows you to emit a map value as a document. Each key of the map becomes a + /// field on the document that contains the corresponding value. + /// + /// - Parameter field: The `Expr` field containing the nested map. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func replace(with expr: Expr) -> Pipeline { + // Implementation + return self + } + + /// Fully overwrites all fields in a document with those coming from a nested map. + /// + /// This stage allows you to emit a map value as a document. Each key of the map becomes a + /// field on the document that contains the corresponding value. + /// + /// - Parameter fieldName: The field containing the nested map. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func replace(with fieldName: String) -> Pipeline { + // Implementation + return self + } + + /// Performs a pseudo-random sampling of the input documents. + /// + /// This stage will filter documents pseudo-randomly. The parameter specifies how number of + /// documents to be returned. + /// + /// - Parameter count: The number of documents to sample. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func sample(count: Int64) -> Pipeline { + // Implementation + return self + } + + /// Performs a pseudo-random sampling of the input documents. + /// + /// This stage will filter documents pseudo-randomly. The `options` parameter specifies how + /// sampling will be performed. See `SampleOptions` for more information. + /// + /// - Parameter percentage: The percentage of documents to sample. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func sample(percentage: Double) -> Pipeline { + // Implementation + return self + } + + /// Performs union of all documents from two pipelines, including duplicates. + /// + /// This stage will pass through documents from previous stage, and also pass through documents + /// from previous stage of the `other` Pipeline given in parameter. The order of documents + /// emitted from this stage is undefined. + /// + /// - Parameter other: The other `Pipeline` that is part of union. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func union(_ other: Pipeline) -> Pipeline { + // Implementation + return self + } + + /// Takes an array field from the input documents and outputs a document for each element + /// with the array field mapped to the alias provided. + /// + /// For each previous stage document, this stage will emit zero or more augmented documents. + /// The input array found in the previous stage document field specified by the `fieldName` + /// parameter, will for each input array element produce an augmented document. The input array + /// element will augment the previous stage document by replacing the field specified by + /// `fieldName` parameter with the element value. + /// + /// In other words, the field containing the input array will be removed from the augmented + /// document and replaced by the corresponding array element. + /// + /// - Parameter field: The name of the field containing the array. + /// - Parameter indexField: Optional. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func unnest(_ field: Selectable, indexField: String? = nil) -> Pipeline { + // Implementation + return self + } + + /// Adds a stage to the pipeline by specifying the stage name as an argument. This does + /// not offer any type safety on the stage params and requires the caller to know the + /// order (and optionally names) of parameters accepted by the stage. + /// + /// This method provides a way to call stages that are supported by the Firestore backend + /// but that are not implemented in the SDK version being used. + /// + /// - Parameter name: The unique name of the stage to add. + /// - Parameter params: A list of ordered parameters to configure the stage's behavior. + /// - Parameter options: A list of optional, named parameters to configure the stage's behavior. + /// - Returns: A new `Pipeline` object with this stage appended to the stage list. + public func genericStage(name: String, params: [Any], options: [String: Any]? = nil) -> Pipeline { + // Implementation + return self + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineResult.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineResult.swift new file mode 100644 index 00000000000..9b4a9e3c575 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineResult.swift @@ -0,0 +1,56 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternalWrapper +#else + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE +import Foundation + +@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) +public struct PipelineResult: @unchecked Sendable { + let bridge: __PipelineResultBridge + + init(_ bridge: __PipelineResultBridge) { + self.bridge = bridge + ref = self.bridge.reference + id = self.bridge.documentID + data = self.bridge.data() as! T + createTime = self.bridge.create_time + updateTime = self.bridge.update_time + } + + /// The reference of the document, if the query returns the `__name__` field. + public let ref: DocumentReference? + + /// The ID of the document for which this `PipelineResult` contains data, if available. + public let id: String? + + /// The time the document was created, if available. + public let createTime: Timestamp? + + /// The time the document was last updated when the snapshot was generated. + public let updateTime: Timestamp? + + /// Retrieves all fields in the result as a dictionary. + public let data: T + + /// Retrieves the field specified by `fieldPath`. + /// - Parameter fieldPath: The field path (e.g., "foo" or "foo.bar"). + /// - Returns: The data at the specified field location or `nil` if no such field exists. + public func get(_ fieldPath: Any) -> Sendable? { + return "PLACEHOLDER" + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineSnapshot.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineSnapshot.swift new file mode 100644 index 00000000000..bc9468923ef --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineSnapshot.swift @@ -0,0 +1,54 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternalWrapper +#else + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE +import Foundation + +@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) +public struct PipelineSnapshot: Sendable { + /// The Pipeline on which `execute()` was called to obtain this `PipelineSnapshot`. + public let pipeline: Pipeline + + /// An array of all the results in the `PipelineSnapshot`. + let results_cache: [PipelineResult<[String: Sendable]>] + + /// The time at which the pipeline producing this result was executed. + public let executionTime: Timestamp + + let bridge: __PipelineSnapshotBridge + + init(_ bridge: __PipelineSnapshotBridge, pipeline: Pipeline) { + self.bridge = bridge + self.pipeline = pipeline + executionTime = self.bridge.execution_time + results_cache = self.bridge.results.map { PipelineResult($0) } + } + + public func results() -> [PipelineResult<[String: Sendable]>] { + return results_cache + } + + public func results(decodeAsType: T.Type = T.self, + decoder: Firestore + .Decoder = .init()) async throws -> [PipelineResult< + T + >] { + return try decoder + .decode(T.self, from: results, in: nil as DocumentReference?) as! [PipelineResult] + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineSource.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineSource.swift new file mode 100644 index 00000000000..68ee48c6f6d --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineSource.swift @@ -0,0 +1,53 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) +public struct PipelineSource: @unchecked Sendable { + let db: Firestore + + init(_ db: Firestore) { + self.db = db + } + + public func collection(_ path: String) -> Pipeline { + return Pipeline(stages: [CollectionSource(collection: path)], db: db) + } + + public func collectionGroup(_ collectionId: String) -> Pipeline { + return Pipeline( + stages: [CollectionGroupSource(collectionId: collectionId)], + db: db + ) + } + + public func database() -> Pipeline { + return Pipeline(stages: [CollectionSource(collection: "placeholder")], db: db) + } + + public func documents(_ docs: [DocumentReference]) -> Pipeline { + return Pipeline(stages: [CollectionSource(collection: "placeholder")], db: db) + } + + public func documents(_ paths: [String]) -> Pipeline { + return Pipeline(stages: [CollectionSource(collection: "placeholder")], db: db) + } + + public func create(from query: Query) -> Pipeline { + return Pipeline(stages: [CollectionSource(collection: "placeholder")], db: db) + } + + public func create(from aggregateQuery: AggregateQuery) -> Pipeline { + return Pipeline(stages: [CollectionSource(collection: "placeholder")], db: db) + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/RealtimePipeline.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/RealtimePipeline.swift new file mode 100644 index 00000000000..de1a709d44d --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/RealtimePipeline.swift @@ -0,0 +1,15 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public struct RealtimePipeline: @unchecked Sendable {} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Selectable.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Selectable.swift new file mode 100644 index 00000000000..a9c655f4e6a --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Selectable.swift @@ -0,0 +1,15 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public protocol Selectable: Sendable {} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/Sum.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/Sum.swift new file mode 100644 index 00000000000..6bbdab0b20c --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/Sum.swift @@ -0,0 +1,15 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public struct Sum {} diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline/TimeUnit.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline/TimeUnit.swift new file mode 100644 index 00000000000..e5030cc7a83 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline/TimeUnit.swift @@ -0,0 +1,45 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +public struct TimeUnit: Sendable, Equatable, Hashable { + enum Kind: String { + case microsecond + case millisecond + case second + case minute + case hour + case day + } + + public static let microsecond = TimeUnit(kind: .microsecond) + public static let millisecond = TimeUnit(kind: .millisecond) + public static let second = TimeUnit(kind: .second) + public static let minute = TimeUnit(kind: .minute) + public static let hour = TimeUnit(kind: .hour) + public static let day = TimeUnit(kind: .day) + + public let rawValue: String + + init(kind: Kind) { + rawValue = kind.rawValue + } + + public init(rawValue: String) { + if let kind = Kind(rawValue: rawValue) { + self.rawValue = kind.rawValue + } else { + fatalError("Invalid TimeUnit: \(rawValue)") + } + } +} diff --git a/Firestore/Swift/Source/SwiftAPI/PipelineSnapshot.swift b/Firestore/Swift/Source/SwiftAPI/PipelineSnapshot.swift deleted file mode 100644 index 00386d0c6dc..00000000000 --- a/Firestore/Swift/Source/SwiftAPI/PipelineSnapshot.swift +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2025 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Foundation - -public struct PipelineSnapshot { - private let bridge: __PipelineSnapshotBridge - - init(_ bridge: __PipelineSnapshotBridge) { - self.bridge = bridge - } -} diff --git a/Firestore/Swift/Source/SwiftAPI/Stages.swift b/Firestore/Swift/Source/SwiftAPI/Stages.swift index df3c163e803..1ed077409e5 100644 --- a/Firestore/Swift/Source/SwiftAPI/Stages.swift +++ b/Firestore/Swift/Source/SwiftAPI/Stages.swift @@ -34,14 +34,50 @@ class CollectionSource: Stage { } } +class CollectionGroupSource: Stage { + var name: String = "collectionId" + + var bridge: StageBridge + private var collectionId: String + + init(collectionId: String) { + self.collectionId = collectionId + bridge = CollectionGroupSourceStageBridge(collectionId: collectionId) + } +} + class Where: Stage { var name: String = "where" var bridge: StageBridge - private var condition: Expr // TODO: should be FilterCondition + private var condition: BooleanExpr - init(condition: Expr) { + init(condition: BooleanExpr) { self.condition = condition bridge = WhereStageBridge(expr: condition.bridge) } } + +class Limit: Stage { + var name: String = "limit" + + var bridge: StageBridge + private var limit: Int32 + + init(_ limit: Int32) { + self.limit = limit + bridge = LimitStageBridge(limit: NSInteger(limit)) + } +} + +class Offset: Stage { + var name: String = "offset" + + var bridge: StageBridge + private var offset: Int32 + + init(_ offset: Int32) { + self.offset = offset + bridge = OffsetStageBridge(offset: NSInteger(offset)) + } +} diff --git a/Firestore/Swift/Tests/Integration/PipelineApiTests.swift b/Firestore/Swift/Tests/Integration/PipelineApiTests.swift new file mode 100644 index 00000000000..2e4b71ff0c5 --- /dev/null +++ b/Firestore/Swift/Tests/Integration/PipelineApiTests.swift @@ -0,0 +1,399 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Foundation +import XCTest + +import FirebaseFirestore + +final class PipelineTests: FSTIntegrationTestCase { + func testCreatePipeline() async throws { + let pipelineSource: PipelineSource = db.pipeline() + + let pipeline: Pipeline = pipelineSource.documents( + [db.collection("foo").document("bar"), db.document("foo/baz")] + ) + let _: Pipeline = pipelineSource.collection("foo") + let _: Pipeline = pipelineSource.collectionGroup("foo") + let _: Pipeline = pipelineSource.database() + + let query: Query = db.collection("foo").limit(to: 2) + let _: Pipeline = pipelineSource.create(from: query) + + let aggregateQuery = db.collection("foo").count + let _: Pipeline = pipelineSource.create(from: aggregateQuery) + + let _: PipelineSnapshot = try await pipeline.execute() + } + + func testWhereStage() async throws { + _ = db.pipeline().collection("books") + .where( + Field("rating") > 4.0 && Field("genre") == "Science Fiction" || ArrayContains( + fieldName: "fieldName", + values: "rating" + ) + ) + } + + func testAddFieldStage() async throws { + // Input + // { title: 'title1', price: 10, discount: 0.8 }, + // { title: 'title2', price: 12, discount: 1.0 }, + // { title: 'title3', price: 5, discount: 0.66 } + + // An expression that will compute price from the value of msrp field and discount field + let priceExpr: FunctionExpr = Field("msrp").multiply(Field("discount")) + + // An expression becomes a Selectable when given an alias. In this case + // the alias is 'salePrice' + let priceSelectableExpr: Selectable = priceExpr.as("salePrice") + + _ = db.pipeline().collection("books") + .addFields( + priceSelectableExpr // Add field `salePrice` based computed from msrp and discount + ) + + // We don't expect customers to separate the Expression definition from the + // Pipeline definition. This was shown above so readers of this doc can see + // the different types involved. The cleaner way to write the code above + // is to inline the Expr definition + _ = db.pipeline().collection("books") + .addFields( + Field("msrp").multiply(Field("discount")).as("salePrice"), + Field("author") + ) + + // Output + // { title: 'title1', price: 10, discount: 0.8, salePrice: 8.0}, + // { title: 'title2', price: 12, discount: 1.0, salePrice: 12.0 }, + // { title: 'title3', price: 5, discount: 0.66, salePrice: 3.30 } + } + + func testRemoveFieldsStage() async throws { + // removes field 'rating' and 'cost' from the previous stage outputs. + _ = db.pipeline().collection("books").removeFields("rating", "cost") + + // removes field 'rating'. + _ = db.pipeline().collection("books").removeFields(Field("rating")) + } + + func testSelectStage() async throws { + // Input + // { title: 'title1', price: 10, discount: 0.8 }, + // { title: 'title2', price: 12, discount: 1.0 }, + // { title: 'title3', price: 5, discount: 0.66 } + + // Overload for string and Selectable + _ = db.pipeline().collection("books") + .select( + Field("title"), // Field class inheritates Selectable + Field("msrp").multiply(Field("discount")).as("salePrice") + ) + + _ = db.pipeline().collection("books").select("title", "author") + + // Output + // { title: 'title1', salePrice: 8.0}, + // { title: 'title2', salePrice: 12.0 }, + // { title: 'title3', salePrice: 3.30 } + } + + func testSortStage() async throws { + // Sort books by rating in descending order, and then by title in ascending order for books + // with the same rating + _ = db.pipeline().collection("books") + .sort( + Field("rating").descending(), + Ascending("title") // alternative API offered + ) + } + + func testLimitStage() async throws { + // Limit the results to the top 10 highest-rated books + _ = db.pipeline().collection("books") + .sort(Field("rating").descending()) + .limit(10) + } + + func testOffsetStage() async throws { + // Retrieve the second page of 20 results + _ = db.pipeline().collection("books") + .sort(Field("published").descending()) + .offset(20) // Skip the first 20 results. Note that this must come + // before .limit(...) unlike in Query where the order did not matter. + .limit(20) // Take the next 20 results + } + + func testDistinctStage() async throws { + // Input + // { author: 'authorA', genre: 'genreA', title: 'title1' }, + // { author: 'authorb', genre: 'genreB', title: 'title2' }, + // { author: 'authorB', genre: 'genreB', title: 'title3' } + + // Get a list of unique author names in uppercase and genre combinations. + _ = db.pipeline().collection("books") + .distinct( + Field("author").uppercased().as("authorName"), + Field("genre") + ) + + // Output + // { authorName: 'AUTHORA', genre: 'genreA' }, + // { authorName: 'AUTHORB', genre: 'genreB' } + } + + func testAggregateStage() async throws { + // Input + // { genre: 'genreA', title: 'title1', rating: 5.0 }, + // { genre: 'genreB', title: 'title2', rating: 1.5 }, + // { genre: 'genreB', title: 'title3', rating: 2.5 } + + // Calculate the average rating and the total number of books + _ = db.pipeline().collection("books") + .aggregate( + Field("rating").avg().as("averageRating"), + CountAll().as("totalBooks") + ) + + // Output + // { totalBooks: 3, averageRating: 3.0 } + + // Input + // { genre: 'genreA', title: 'title1', rating: 5.0 }, + // { genre: 'genreB', title: 'title2', rating: 1.5 }, + // { genre: 'genreB', title: 'title3', rating: 2.5 } + + // Calculate the average rating and the total number of books and group by field 'genre' + _ = db.pipeline().collection("books") + .aggregate([ + Field("rating").avg().as("averageRating"), + CountAll().as("totalBooks"), + ], + groups: ["genre"]) + + // Output + // { genre: 'genreA', totalBooks: 1, averageRating: 5.0 } + // { genre: 'genreB', totalBooks: 2, averageRating: 2.0 } + } + + func testFindNearestStage() async throws { + _ = db.pipeline().collection("books").findNearest( + field: Field("embedding"), + vectorValue: [5.0], + distanceMeasure: .cosine, + limit: 3) + } + + func testReplaceStage() async throws { + // Input. + // { +// "name": "John Doe Jr.", +// "parents": { +// "father": "John Doe Sr.", +// "mother": "Jane Doe" +// } + // } + + // Emit field parents as the document. + _ = db.pipeline().collection("people") + .replace(with: Field("parents")) + + // Output + // { +// "father": "John Doe Sr.", +// "mother": "Jane Doe" + // } + } + + func testSampleStage() async throws { + // Sample 25 books, if the collection contains at least 25 documents + _ = db.pipeline().collection("books").sample(count: 10) + + // Sample 10 percent of the collection of books + _ = db.pipeline().collection("books").sample(percentage: 10) + } + + func testUnionStage() async throws { + // Emit documents from books collection and magazines collection. + _ = db.pipeline().collection("books") + .union(db.pipeline().collection("magazines")) + } + + func testUnnestStage() async throws { + // Input: + // { "title": "The Hitchhiker's Guide to the Galaxy", "tags": [ "comedy", "space", "adventure" + // ], ... } + + // Emit a book document for each tag of the book. + _ = db.pipeline().collection("books") + .unnest(Field("tags").as("tag")) + + // Output: + // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "comedy", tags: [...], ... } + // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "space", tags: [...], ... } + // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "adventure", tags: [...], ... } + + // Emit a book document for each tag of the book mapped to its' index in the array. + _ = db.pipeline().collection("books") + .unnest(Field("tags").as("tag"), indexField: "index") + + // Output: + // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "comedy", index: 0, tags: [...], + // ... } + // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "space", index: 1, tags: [...], ... + // } + // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "adventure", index: 2, tags: [...], + // ... } + } + + func testGenericStage() async throws { + // Assume we don't have a built-in "where" stage, the customer could still + // add this stage by calling genericStage, passing the name of the stage "where", + // and providing positional argument values. + _ = db.pipeline().collection("books") + .genericStage(name: "where", + params: [Field("published").lt(1900)]) + .select("title", "author") + + // In cases where the stage also supports named argument values, then these can be + // provided with a third argument that maps the argument name to value. + // Note that these named arguments are always optional in the stage definition. + _ = db.pipeline().collection("books") + .genericStage(name: "where", + params: [Field("published").lt(1900)], + options: ["someOptionalParamName": "the argument value for this param"]) + .select("title", "author") + } + + func testField() async throws { + // An expression that will return the value of the field `name` in the document + let nameField = Field("name") + + // An expression that will return the value of the field `description` in the document + // Field is a sub-type of Expr, so we can also declare our var of type Expr + let descriptionField: Expr = Field("description") + + // USAGE: anywhere an Expr type is accepted + // Use a field in a pipeline + _ = db.pipeline().collection("books") + .addFields( + Field("rating").as("bookRating") // Duplicate field 'rating' as 'bookRating' + ) + + // One special Field value is conveniently exposed as static function to help the user reference + // reserved field values of __name__. + _ = db.pipeline().collection("books") + .addFields( + DocumentId() + ) + } + + func testConstant() async throws { + // A constant for a number + let three = Constant(3) + + // A constant for a string + let name = Constant("Expressions API") + + // Const is a sub-type of Expr, so we can also declare our var of type Expr + let nothing: Expr = Constant.nil + + // USAGE: Anywhere an Expr type is accepted + // Add field `fromTheLibraryOf: 'Rafi'` to every document in the collection. + _ = db.pipeline().collection("books") + .addFields(Constant("Rafi").as("fromTheLibraryOf")) + } + + func testFunctionExpr() async throws { + let secondsField = Field("seconds") + + // Create a FunctionExpr using the multiply function to compute milliseconds + let milliseconds: FunctionExpr = secondsField.multiply(1000) + + // A firestore function is also a sub-type of Expr + let myExpr: Expr = milliseconds + } + + func testBooleanExpr() async throws { + let isApple: BooleanExpr = Field("type") == "apple" + + // USAGE: stage where requires an expression of type BooleanExpr + let allAppleOptions: Pipeline = db.pipeline().collection("fruitOptions").where(isApple) + } + + func testSelectableExpr() async throws { + let secondsField = Field("seconds") + + // Create a selectable from our milliseconds expression. + let millisecondsSelectable: Selectable = secondsField.multiply(1000).as("milliseconds") + + // USAGE: stages addFields and select accept expressions of type Selectable + // Add (or overwrite) the 'milliseconds` field to each of our documents using the + // `.addFields(...)` stage. + _ = db.pipeline().collection("lapTimes") + .addFields(secondsField.multiply(1000).as("milliseconds")) + + // NOTE: Field implements Selectable, the alias is the same as the name + let secondsSelectable: Selectable = secondsField + } + + func testAggregateExpr() async throws { + let lapTimeSum: AggregateFunction = Field("seconds").sum() + + let lapTimeSumTarget: AggregateWithAlias = lapTimeSum.as("totalTrackTime") + + // USAGE: stage aggregate accepts expressions of type AggregateWithAlias + // A pipeline that will return one document with one field `totalTrackTime` that + // is the sum of all laps ever taken on the track. + _ = db.pipeline().collection("lapTimes") + .aggregate(lapTimeSum.as("totalTrackTime")) + } + + func testOrdering() async throws { + let fastestToSlowest: Ordering = Field("seconds").ascending() + + // USAGE: stage sort accepts objects of type Ordering + // Use this ordering to sort our lap times collection from fastest to slowest + _ = db.pipeline().collection("lapTimes").sort(fastestToSlowest) + } + + func testExpr() async throws { + // An expression that computes the area of a circle + // by chaining together two calls to the multiply function + let radiusField: Expr = Field("radius") + let radiusSq: Expr = radiusField.multiply(Field("radius")) + let areaExpr: Expr = radiusSq.multiply(3.14) + + // Or define this expression in one clean, fluent statement + let areaOfCircle: Selectable = Field("radius") + .multiply(Field("radius")) + .multiply(3.14) + .as("area") + + // And pass the expression to a Pipeline for evaluation + _ = db.pipeline().collection("circles").addFields(areaOfCircle) + } + + func testGeneric() async throws { + // This is the same of the logicalMin('price', 0)', if it did not exist + let myLm = FunctionExpr("logicalMin", [Field("price"), Constant(0)]) + + // Create a generic BooleanExpr for use where BooleanExpr is required + let myEq = BooleanExpr("eq", [Field("price"), Constant(10)]) + + // Create a generic AggregateFunction for use where AggregateFunction is required + let mySum = AggregateFunction("sum", [Field("price")]) + } +} diff --git a/Firestore/Swift/Tests/Integration/PipelineTests.swift b/Firestore/Swift/Tests/Integration/PipelineTests.swift index 79185762b91..9dbdcb5b7fc 100644 --- a/Firestore/Swift/Tests/Integration/PipelineTests.swift +++ b/Firestore/Swift/Tests/Integration/PipelineTests.swift @@ -17,15 +17,129 @@ import FirebaseFirestore import Foundation +private let bookDocs: [String: [String: Any]] = [ + "book1": [ + "title": "The Hitchhiker's Guide to the Galaxy", + "author": "Douglas Adams", + "genre": "Science Fiction", + "published": 1979, + "rating": 4.2, + "tags": ["comedy", "space", "adventure"], // Array literal + "awards": ["hugo": true, "nebula": false], // Dictionary literal + "nestedField": ["level.1": ["level.2": true]], // Nested dictionary literal + ], + "book2": [ + "title": "Pride and Prejudice", + "author": "Jane Austen", + "genre": "Romance", + "published": 1813, + "rating": 4.5, + "tags": ["classic", "social commentary", "love"], + "awards": ["none": true], + ], + "book3": [ + "title": "One Hundred Years of Solitude", + "author": "Gabriel García Márquez", + "genre": "Magical Realism", + "published": 1967, + "rating": 4.3, + "tags": ["family", "history", "fantasy"], + "awards": ["nobel": true, "nebula": false], + ], + "book4": [ + "title": "The Lord of the Rings", + "author": "J.R.R. Tolkien", + "genre": "Fantasy", + "published": 1954, + "rating": 4.7, + "tags": ["adventure", "magic", "epic"], + "awards": ["hugo": false, "nebula": false], + ], + "book5": [ + "title": "The Handmaid's Tale", + "author": "Margaret Atwood", + "genre": "Dystopian", + "published": 1985, + "rating": 4.1, + "tags": ["feminism", "totalitarianism", "resistance"], + "awards": ["arthur c. clarke": true, "booker prize": false], + ], + "book6": [ + "title": "Crime and Punishment", + "author": "Fyodor Dostoevsky", + "genre": "Psychological Thriller", + "published": 1866, + "rating": 4.3, + "tags": ["philosophy", "crime", "redemption"], + "awards": ["none": true], + ], + "book7": [ + "title": "To Kill a Mockingbird", + "author": "Harper Lee", + "genre": "Southern Gothic", + "published": 1960, + "rating": 4.2, + "tags": ["racism", "injustice", "coming-of-age"], + "awards": ["pulitzer": true], + ], + "book8": [ + "title": "1984", + "author": "George Orwell", + "genre": "Dystopian", + "published": 1949, + "rating": 4.2, + "tags": ["surveillance", "totalitarianism", "propaganda"], + "awards": ["prometheus": true], + ], + "book9": [ + "title": "The Great Gatsby", + "author": "F. Scott Fitzgerald", + "genre": "Modernist", + "published": 1925, + "rating": 4.0, + "tags": ["wealth", "american dream", "love"], + "awards": ["none": true], + ], + "book10": [ + "title": "Dune", + "author": "Frank Herbert", + "genre": "Science Fiction", + "published": 1965, + "rating": 4.6, + "tags": ["politics", "desert", "ecology"], + "awards": ["hugo": true, "nebula": true], + ], +] + @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) class PipelineIntegrationTests: FSTIntegrationTestCase { func testCount() async throws { + try await firestore().collection("foo").document("bar").setData(["foo": "bar", "x": 42]) let snapshot = try await firestore() .pipeline() - .collection(path: "foo") - .where(eq(field("foo"), constant(42))) + .collection("/foo") + .where(Field("foo") == Constant("bar")) .execute() print(snapshot) } + + func testEmptyResults() async throws { + let collRef = collectionRef( + withDocuments: bookDocs + ) + let db = collRef.firestore + + let snapshot = try await db + .pipeline() + .collection("/" + collRef.path) + .limit(0) + .execute() + + XCTAssertTrue(snapshot.results().isEmpty) + + struct MyStruct: Decodable {} + let pplResult: [PipelineResult] = try await snapshot + .results(decodeAsType: MyStruct.self) + } } diff --git a/Firestore/core/src/api/aggregate_expressions.cc b/Firestore/core/src/api/aggregate_expressions.cc new file mode 100644 index 00000000000..87fc69c368a --- /dev/null +++ b/Firestore/core/src/api/aggregate_expressions.cc @@ -0,0 +1,43 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Firestore/core/src/api/aggregate_expressions.h" + +#include "Firestore/core/src/nanopb/nanopb_util.h" + +namespace firebase { +namespace firestore { +namespace api { + +google_firestore_v1_Value AggregateExpr::to_proto() const { + google_firestore_v1_Value result; + result.which_value_type = google_firestore_v1_Value_function_value_tag; + + result.function_value.name = nanopb::MakeBytesArray(name_); + result.function_value.args_count = static_cast(params_.size()); + result.function_value.args = nanopb::MakeArray( + result.function_value.args_count); + + for (size_t i = 0; i < params_.size(); ++i) { + result.function_value.args[i] = params_[i]->to_proto(); + } + + return result; +} + +} // namespace api +} // namespace firestore +} // namespace firebase diff --git a/Firestore/core/src/api/aggregate_expressions.h b/Firestore/core/src/api/aggregate_expressions.h new file mode 100644 index 00000000000..119198b2abd --- /dev/null +++ b/Firestore/core/src/api/aggregate_expressions.h @@ -0,0 +1,50 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIRESTORE_CORE_SRC_API_AGGREGATE_EXPRESSIONS_H_ +#define FIRESTORE_CORE_SRC_API_AGGREGATE_EXPRESSIONS_H_ + +#include +#include +#include +#include + +#include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h" +#include "Firestore/core/src/api/expressions.h" + +namespace firebase { +namespace firestore { +namespace api { + +class AggregateExpr { + public: + AggregateExpr(std::string name, std::vector> params) + : name_(std::move(name)), params_(std::move(params)) { + } + ~AggregateExpr() = default; + + google_firestore_v1_Value to_proto() const; + + private: + std::string name_; + std::vector> params_; +}; + +} // namespace api +} // namespace firestore +} // namespace firebase + +#endif // FIRESTORE_CORE_SRC_API_AGGREGATE_EXPRESSIONS_H_ diff --git a/Firestore/core/src/api/expressions.cc b/Firestore/core/src/api/expressions.cc index 07e99b1e848..7ec517f2aab 100644 --- a/Firestore/core/src/api/expressions.cc +++ b/Firestore/core/src/api/expressions.cc @@ -19,6 +19,7 @@ #include #include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h" +#include "Firestore/core/src/model/value_util.h" #include "Firestore/core/src/nanopb/nanopb_util.h" namespace firebase { @@ -35,12 +36,8 @@ google_firestore_v1_Value Field::to_proto() const { } google_firestore_v1_Value Constant::to_proto() const { - google_firestore_v1_Value result; - - result.which_value_type = google_firestore_v1_Value_double_value_tag; - result.double_value = this->value_; - - return result; + // Return a copy of the value proto to avoid double delete. + return *model::DeepClone(*value_).release(); } google_firestore_v1_Value FunctionExpr::to_proto() const { diff --git a/Firestore/core/src/api/expressions.h b/Firestore/core/src/api/expressions.h index 2ab134249cf..5b08a277e3b 100644 --- a/Firestore/core/src/api/expressions.h +++ b/Firestore/core/src/api/expressions.h @@ -23,6 +23,7 @@ #include #include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h" +#include "Firestore/core/src/nanopb/message.h" namespace firebase { namespace firestore { @@ -35,11 +36,20 @@ class Expr { virtual google_firestore_v1_Value to_proto() const = 0; }; -class Field : public Expr { +class Selectable : public Expr { + public: + virtual ~Selectable() = default; + virtual const std::string& alias() const = 0; +}; + +class Field : public Selectable { public: explicit Field(std::string name) : name_(std::move(name)) { } google_firestore_v1_Value to_proto() const override; + const std::string& alias() const override { + return name_; + } private: std::string name_; @@ -47,12 +57,13 @@ class Field : public Expr { class Constant : public Expr { public: - explicit Constant(double value) : value_(value) { + explicit Constant(nanopb::SharedMessage value) + : value_(std::move(value)) { } google_firestore_v1_Value to_proto() const override; private: - double value_; + nanopb::SharedMessage value_; }; class FunctionExpr : public Expr { diff --git a/Firestore/core/src/api/ordering.cc b/Firestore/core/src/api/ordering.cc new file mode 100644 index 00000000000..6520cea5b6f --- /dev/null +++ b/Firestore/core/src/api/ordering.cc @@ -0,0 +1,47 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Firestore/core/src/api/ordering.h" + +#include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h" +#include "Firestore/core/src/nanopb/nanopb_util.h" + +namespace firebase { +namespace firestore { +namespace api { + +google_firestore_v1_Value Ordering::to_proto() const { + google_firestore_v1_Value result; + result.which_value_type = google_firestore_v1_Value_map_value_tag; + + result.map_value.fields_count = 2; + result.map_value.fields = + nanopb::MakeArray(2); + result.map_value.fields[0].key = nanopb::MakeBytesArray("expression"); + result.map_value.fields[0].value = field_.to_proto(); + result.map_value.fields[1].key = nanopb::MakeBytesArray("direction"); + google_firestore_v1_Value direction; + direction.which_value_type = google_firestore_v1_Value_string_value_tag; + direction.string_value = nanopb::MakeBytesArray( + this->direction_ == ASCENDING ? "ascending" : "descending"); + result.map_value.fields[1].value = direction; + + return result; +} + +} // namespace api +} // namespace firestore +} // namespace firebase diff --git a/Firestore/core/src/api/ordering.h b/Firestore/core/src/api/ordering.h new file mode 100644 index 00000000000..130dda12b19 --- /dev/null +++ b/Firestore/core/src/api/ordering.h @@ -0,0 +1,52 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIRESTORE_CORE_SRC_API_ORDERING_H_ +#define FIRESTORE_CORE_SRC_API_ORDERING_H_ + +#include + +#include "Firestore/core/src/api/expressions.h" + +namespace firebase { +namespace firestore { +namespace api { + +class UserDataReader; // forward declaration + +class Ordering { + public: + enum Direction { + ASCENDING, + DESCENDING, + }; + + Ordering(Field field, Direction direction) + : field_(std::move(field)), direction_(direction) { + } + + google_firestore_v1_Value to_proto() const; + + private: + Field field_; + Direction direction_; +}; + +} // namespace api +} // namespace firestore +} // namespace firebase + +#endif // FIRESTORE_CORE_SRC_API_ORDERING_H_ diff --git a/Firestore/core/src/api/pipeline_result.h b/Firestore/core/src/api/pipeline_result.h index 4680d058c7b..662ea721c6b 100644 --- a/Firestore/core/src/api/pipeline_result.h +++ b/Firestore/core/src/api/pipeline_result.h @@ -53,6 +53,18 @@ class PipelineResult { std::shared_ptr internal_value() const; absl::optional document_id() const; + absl::optional create_time() const { + return create_time_; + } + + absl::optional update_time() const { + return update_time_; + } + + const absl::optional& internal_key() const { + return internal_key_; + } + private: absl::optional internal_key_; // Using a shared pointer to ObjectValue makes PipelineResult copy-assignable diff --git a/Firestore/core/src/api/pipeline_snapshot.h b/Firestore/core/src/api/pipeline_snapshot.h index a19e76138a7..2bb0a1e94d2 100644 --- a/Firestore/core/src/api/pipeline_snapshot.h +++ b/Firestore/core/src/api/pipeline_snapshot.h @@ -41,9 +41,22 @@ class PipelineSnapshot { return results_; } + model::SnapshotVersion execution_time() const { + return execution_time_; + } + + const std::shared_ptr firestore() const { + return firestore_; + } + + void SetFirestore(std::shared_ptr db) { + firestore_ = std::move(db); + } + private: std::vector results_; model::SnapshotVersion execution_time_; + std::shared_ptr firestore_; }; } // namespace api diff --git a/Firestore/core/src/api/stages.cc b/Firestore/core/src/api/stages.cc index 6843a1b4ce5..eaa19cb03bd 100644 --- a/Firestore/core/src/api/stages.cc +++ b/Firestore/core/src/api/stages.cc @@ -16,6 +16,11 @@ #include "Firestore/core/src/api/stages.h" +#include +#include + +#include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h" +#include "Firestore/core/src/nanopb/message.h" #include "Firestore/core/src/nanopb/nanopb_util.h" namespace firebase { @@ -39,6 +44,112 @@ google_firestore_v1_Pipeline_Stage CollectionSource::to_proto() const { return result; } +google_firestore_v1_Pipeline_Stage DatabaseSource::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + + result.name = nanopb::MakeBytesArray("database"); + result.args_count = 0; + result.args = nullptr; + result.options_count = 0; + result.options = nullptr; + + return result; +} + +google_firestore_v1_Pipeline_Stage CollectionGroupSource::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + + result.name = nanopb::MakeBytesArray("collection_group"); + + result.args_count = 2; + result.args = nanopb::MakeArray(2); + // First argument is an empty reference value. + result.args[0].which_value_type = + google_firestore_v1_Value_reference_value_tag; + result.args[0].reference_value = nanopb::MakeBytesArray(""); + + // Second argument is the collection ID (encoded as a string value). + result.args[1].which_value_type = google_firestore_v1_Value_string_value_tag; + result.args[1].string_value = nanopb::MakeBytesArray(collection_id_); + + result.options_count = 0; + result.options = nullptr; + + return result; +} + +google_firestore_v1_Pipeline_Stage DocumentsSource::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + + result.name = nanopb::MakeBytesArray("documents"); + + result.args_count = documents_.size(); + result.args = nanopb::MakeArray(result.args_count); + + for (size_t i = 0; i < documents_.size(); ++i) { + result.args[i].which_value_type = + google_firestore_v1_Value_string_value_tag; + result.args[i].string_value = nanopb::MakeBytesArray(documents_[i]); + } + + result.options_count = 0; + result.options = nullptr; + + return result; +} + +google_firestore_v1_Pipeline_Stage AddFields::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + result.name = nanopb::MakeBytesArray("add_fields"); + + result.args_count = 1; + result.args = nanopb::MakeArray(1); + + result.args[0].which_value_type = google_firestore_v1_Value_map_value_tag; + nanopb::SetRepeatedField( + &result.args[0].map_value.fields, &result.args[0].map_value.fields_count, + fields_, [](const std::shared_ptr& entry) { + return _google_firestore_v1_MapValue_FieldsEntry{ + nanopb::MakeBytesArray(entry->alias()), entry->to_proto()}; + }); + + result.options_count = 0; + result.options = nullptr; + return result; +} + +google_firestore_v1_Pipeline_Stage AggregateStage::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + result.name = nanopb::MakeBytesArray("aggregate"); + + result.args_count = 2; + result.args = nanopb::MakeArray(2); + + // Encode accumulators map. + result.args[0].which_value_type = google_firestore_v1_Value_map_value_tag; + nanopb::SetRepeatedField( + &result.args[0].map_value.fields, &result.args[0].map_value.fields_count, + this->accumulators_, + [](const std::pair>& entry) { + return _google_firestore_v1_MapValue_FieldsEntry{ + nanopb::MakeBytesArray(entry.first), entry.second->to_proto()}; + }); + + // Encode groups map. + result.args[1].which_value_type = google_firestore_v1_Value_map_value_tag; + nanopb::SetRepeatedField( + &result.args[1].map_value.fields, &result.args[1].map_value.fields_count, + this->groups_, + [](const std::pair>& entry) { + return _google_firestore_v1_MapValue_FieldsEntry{ + nanopb::MakeBytesArray(entry.first), entry.second->to_proto()}; + }); + + result.options_count = 0; + result.options = nullptr; + return result; +} + google_firestore_v1_Pipeline_Stage Where::to_proto() const { google_firestore_v1_Pipeline_Stage result; @@ -54,6 +165,145 @@ google_firestore_v1_Pipeline_Stage Where::to_proto() const { return result; } +google_firestore_v1_Value FindNearestStage::DistanceMeasure::proto() const { + google_firestore_v1_Value result; + result.which_value_type = google_firestore_v1_Value_string_value_tag; + switch (measure_) { + case EUCLIDEAN: + result.string_value = nanopb::MakeBytesArray("euclidean"); + break; + case COSINE: + result.string_value = nanopb::MakeBytesArray("cosine"); + break; + case DOT_PRODUCT: + result.string_value = nanopb::MakeBytesArray("dot_product"); + break; + } + return result; +} + +google_firestore_v1_Pipeline_Stage FindNearestStage::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + result.name = nanopb::MakeBytesArray("find_nearest"); + + result.args_count = 3; + result.args = nanopb::MakeArray(3); + result.args[0] = property_->to_proto(); + result.args[1] = *vector_; + result.args[2] = distance_measure_.proto(); + + nanopb::SetRepeatedField( + &result.options, &result.options_count, options_, + [](const std::pair>& + entry) { + return _google_firestore_v1_Pipeline_Stage_OptionsEntry{ + nanopb::MakeBytesArray(entry.first), *entry.second}; + }); + + return result; +} + +google_firestore_v1_Pipeline_Stage LimitStage::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + result.name = nanopb::MakeBytesArray("limit"); + + result.args_count = 1; + result.args = nanopb::MakeArray(1); + result.args[0].which_value_type = google_firestore_v1_Value_integer_value_tag; + result.args[0].integer_value = limit_; + + result.options_count = 0; + result.options = nullptr; + return result; +} + +google_firestore_v1_Pipeline_Stage OffsetStage::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + result.name = nanopb::MakeBytesArray("offset"); + + result.args_count = 1; + result.args = nanopb::MakeArray(1); + result.args[0].which_value_type = google_firestore_v1_Value_integer_value_tag; + result.args[0].integer_value = offset_; + + result.options_count = 0; + result.options = nullptr; + return result; +} + +google_firestore_v1_Pipeline_Stage SelectStage::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + result.name = nanopb::MakeBytesArray("select"); + + result.args_count = 1; + result.args = nanopb::MakeArray(1); + + result.args[0].which_value_type = google_firestore_v1_Value_map_value_tag; + nanopb::SetRepeatedField( + &result.args[0].map_value.fields, &result.args[0].map_value.fields_count, + fields_, [](const std::shared_ptr& entry) { + return _google_firestore_v1_MapValue_FieldsEntry{ + nanopb::MakeBytesArray(entry->alias()), entry->to_proto()}; + }); + + result.options_count = 0; + result.options = nullptr; + return result; +} + +google_firestore_v1_Pipeline_Stage SortStage::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + result.name = nanopb::MakeBytesArray("sort"); + + result.args_count = static_cast(orders_.size()); + result.args = nanopb::MakeArray(result.args_count); + + for (size_t i = 0; i < orders_.size(); ++i) { + result.args[i] = orders_[i].to_proto(); + } + + result.options_count = 0; + result.options = nullptr; + return result; +} + +google_firestore_v1_Pipeline_Stage DistinctStage::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + result.name = nanopb::MakeBytesArray("distinct"); + + result.args_count = 1; + result.args = nanopb::MakeArray(1); + + result.args[0].which_value_type = google_firestore_v1_Value_map_value_tag; + nanopb::SetRepeatedField( + &result.args[0].map_value.fields, &result.args[0].map_value.fields_count, + groups_, [](const std::shared_ptr& entry) { + return _google_firestore_v1_MapValue_FieldsEntry{ + nanopb::MakeBytesArray(entry->alias()), entry->to_proto()}; + }); + + result.options_count = 0; + result.options = nullptr; + return result; +} + +google_firestore_v1_Pipeline_Stage RemoveFieldsStage::to_proto() const { + google_firestore_v1_Pipeline_Stage result; + result.name = nanopb::MakeBytesArray("remove_fields"); + + result.args_count = static_cast(fields_.size()); + result.args = nanopb::MakeArray(result.args_count); + + for (size_t i = 0; i < fields_.size(); ++i) { + result.args[i] = fields_[i].to_proto(); + } + + result.options_count = 0; + result.options = nullptr; + return result; +} + } // namespace api } // namespace firestore } // namespace firebase diff --git a/Firestore/core/src/api/stages.h b/Firestore/core/src/api/stages.h index f037a70408e..f2c20f8bd9e 100644 --- a/Firestore/core/src/api/stages.h +++ b/Firestore/core/src/api/stages.h @@ -19,9 +19,15 @@ #include #include +#include +#include +#include #include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h" +#include "Firestore/core/src/api/aggregate_expressions.h" #include "Firestore/core/src/api/expressions.h" +#include "Firestore/core/src/api/ordering.h" +#include "Firestore/core/src/nanopb/message.h" namespace firebase { namespace firestore { @@ -37,7 +43,7 @@ class Stage { class CollectionSource : public Stage { public: - explicit CollectionSource(std::string path) : path_(path) { + explicit CollectionSource(std::string path) : path_(std::move(path)) { } ~CollectionSource() override = default; @@ -47,9 +53,71 @@ class CollectionSource : public Stage { std::string path_; }; +class DatabaseSource : public Stage { + public: + DatabaseSource() = default; + ~DatabaseSource() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; +}; + +class CollectionGroupSource : public Stage { + public: + explicit CollectionGroupSource(std::string collection_id) + : collection_id_(std::move(collection_id)) { + } + ~CollectionGroupSource() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + std::string collection_id_; +}; + +class DocumentsSource : public Stage { + public: + explicit DocumentsSource(std::vector documents) + : documents_(std::move(documents)) { + } + ~DocumentsSource() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + std::vector documents_; +}; + +class AddFields : public Stage { + public: + explicit AddFields(std::vector> fields) + : fields_(std::move(fields)) { + } + ~AddFields() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + std::vector> fields_; +}; + +class AggregateStage : public Stage { + public: + AggregateStage(std::unordered_map> + accumulators, + std::unordered_map> groups) + : accumulators_(std::move(accumulators)), groups_(std::move(groups)) { + } + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + std::unordered_map> accumulators_; + std::unordered_map> groups_; +}; + class Where : public Stage { public: - explicit Where(std::shared_ptr expr) : expr_(expr) { + explicit Where(std::shared_ptr expr) : expr_(std::move(expr)) { } ~Where() override = default; @@ -59,6 +127,122 @@ class Where : public Stage { std::shared_ptr expr_; }; +class FindNearestStage : public Stage { + public: + class DistanceMeasure { + public: + enum Measure { EUCLIDEAN, COSINE, DOT_PRODUCT }; + + explicit DistanceMeasure(Measure measure) : measure_(measure) { + } + google_firestore_v1_Value proto() const; + + private: + Measure measure_; + }; + + FindNearestStage( + std::shared_ptr property, + nanopb::SharedMessage vector, + DistanceMeasure distance_measure, + std::unordered_map> + options) + : property_(std::move(property)), + vector_(std::move(vector)), + distance_measure_(distance_measure), + options_(options) { + } + + ~FindNearestStage() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + std::shared_ptr property_; + nanopb::SharedMessage vector_; + DistanceMeasure distance_measure_; + std::unordered_map> + options_; +}; + +class LimitStage : public Stage { + public: + explicit LimitStage(int32_t limit) : limit_(limit) { + } + ~LimitStage() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + int32_t limit_; +}; + +class OffsetStage : public Stage { + public: + explicit OffsetStage(int64_t offset) : offset_(offset) { + } + ~OffsetStage() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + int64_t offset_; +}; + +class SelectStage : public Stage { + public: + explicit SelectStage(std::vector> fields) + : fields_(std::move(fields)) { + } + ~SelectStage() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + std::vector> fields_; +}; + +class SortStage : public Stage { + public: + explicit SortStage(std::vector orders) + : orders_(std::move(orders)) { + } + ~SortStage() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + std::vector orders_; +}; + +class DistinctStage : public Stage { + public: + explicit DistinctStage(std::vector> groups) + : groups_(std::move(groups)) { + } + ~DistinctStage() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + std::vector> groups_; +}; + +class RemoveFieldsStage : public Stage { + public: + explicit RemoveFieldsStage(std::vector fields) + : fields_(std::move(fields)) { + } + ~RemoveFieldsStage() override = default; + + google_firestore_v1_Pipeline_Stage to_proto() const override; + + private: + std::vector fields_; +}; + } // namespace api } // namespace firestore } // namespace firebase diff --git a/Firestore/core/src/remote/datastore.cc b/Firestore/core/src/remote/datastore.cc index d5950ca09c6..504beadbd99 100644 --- a/Firestore/core/src/remote/datastore.cc +++ b/Firestore/core/src/remote/datastore.cc @@ -340,20 +340,22 @@ void Datastore::RunPipelineWithCredentials( GrpcUnaryCall* call = call_owning.get(); active_calls_.push_back(std::move(call_owning)); - call->Start([this, call, callback = std::move(callback)]( - const StatusOr& result) { - LogGrpcCallFinished("ExecutePipeline", call, result.status()); - HandleCallStatus(result.status()); + call->Start( + [this, db = pipeline.firestore(), call, callback = std::move(callback)]( + const StatusOr& result) { + LogGrpcCallFinished("ExecutePipeline", call, result.status()); + HandleCallStatus(result.status()); - if (result.ok()) { - callback(datastore_serializer_.DecodeExecutePipelineResponse( - result.ValueOrDie())); - } else { - callback(result.status()); - } + if (result.ok()) { + auto response = datastore_serializer_.DecodeExecutePipelineResponse( + result.ValueOrDie(), std::move(db)); + callback(response); + } else { + callback(result.status()); + } - RemoveGrpcCall(call); - }); + RemoveGrpcCall(call); + }); } void Datastore::ResumeRpcWithCredentials(const OnCredentials& on_credentials) { diff --git a/Firestore/core/src/remote/remote_objc_bridge.cc b/Firestore/core/src/remote/remote_objc_bridge.cc index 466ed1229cc..6cc675d4f7f 100644 --- a/Firestore/core/src/remote/remote_objc_bridge.cc +++ b/Firestore/core/src/remote/remote_objc_bridge.cc @@ -33,6 +33,7 @@ #include "Firestore/core/src/remote/grpc_util.h" #include "Firestore/core/src/remote/watch_change.h" #include "Firestore/core/src/util/hard_assert.h" +#include "Firestore/core/src/util/log.h" #include "Firestore/core/src/util/status.h" #include "Firestore/core/src/util/statusor.h" #include "grpcpp/support/status.h" @@ -398,7 +399,8 @@ DatastoreSerializer::EncodeExecutePipelineRequest( util::StatusOr DatastoreSerializer::DecodeExecutePipelineResponse( - const grpc::ByteBuffer& response) const { + const grpc::ByteBuffer& response, + std::shared_ptr db) const { ByteBufferReader reader{response}; auto message = Message::TryParse(&reader); @@ -406,7 +408,15 @@ DatastoreSerializer::DecodeExecutePipelineResponse( return reader.status(); } - return serializer_.DecodePipelineResponse(reader.context(), message); + LOG_DEBUG("Pipeline Response: %s", message.ToString()); + + auto snapshot = serializer_.DecodePipelineResponse(reader.context(), message); + if (!reader.ok()) { + return reader.status(); + } + + snapshot.SetFirestore(std::move(db)); + return snapshot; } } // namespace remote diff --git a/Firestore/core/src/remote/remote_objc_bridge.h b/Firestore/core/src/remote/remote_objc_bridge.h index f6615003eed..96329c1ae25 100644 --- a/Firestore/core/src/remote/remote_objc_bridge.h +++ b/Firestore/core/src/remote/remote_objc_bridge.h @@ -156,7 +156,8 @@ class DatastoreSerializer { const firebase::firestore::api::Pipeline& pipeline) const; util::StatusOr DecodeExecutePipelineResponse( - const grpc::ByteBuffer& response) const; + const grpc::ByteBuffer& response, + std::shared_ptr db) const; private: Serializer serializer_; diff --git a/Firestore/core/src/remote/serializer.cc b/Firestore/core/src/remote/serializer.cc index 2985f86d623..5dffd848c09 100644 --- a/Firestore/core/src/remote/serializer.cc +++ b/Firestore/core/src/remote/serializer.cc @@ -1514,7 +1514,8 @@ api::PipelineSnapshot Serializer::DecodePipelineResponse( const { auto execution_time = DecodeVersion(context, message->execution_time); - std::vector results(message->results_count); + std::vector results; + results.reserve(message->results_count); for (pb_size_t i = 0; i < message->results_count; ++i) { absl::optional key;