Skip to content

Commit cd5195e

Browse files
cherylEnkiduwu-hui
andauthored
Ppl API Changes (#15344)
Co-authored-by: wu-hui <[email protected]>
1 parent b51b545 commit cd5195e

30 files changed

+2283
-1319
lines changed

Firestore/Swift/Source/ExprImpl.swift

Lines changed: 0 additions & 595 deletions
This file was deleted.

Firestore/Swift/Source/ExpressionImplementation.swift

Lines changed: 915 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,6 @@
1919
#endif // SWIFT_PACKAGE
2020
import Foundation
2121

22-
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
23-
struct RealtimePipelineSnapshot: Sendable {
24-
/// The Pipeline on which `execute()` was called to obtain this `PipelineSnapshot`.
25-
public let pipeline: RealtimePipeline
26-
27-
/// An array of all the results in the `PipelineSnapshot`.
28-
let results_cache: [PipelineResult]
29-
30-
public let changes: [PipelineResultChange]
31-
public let metadata: SnapshotMetadata
32-
33-
let bridge: __RealtimePipelineSnapshotBridge
34-
35-
init(_ bridge: __RealtimePipelineSnapshotBridge, pipeline: RealtimePipeline) {
36-
self.bridge = bridge
37-
self.pipeline = pipeline
38-
metadata = bridge.metadata
39-
results_cache = self.bridge.results.map { PipelineResult($0) }
40-
changes = self.bridge.changes.map { PipelineResultChange($0) }
41-
}
42-
43-
public func results() -> [PipelineResult] {
44-
return results_cache
45-
}
46-
}
47-
4822
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
4923
struct PipelineResultChange: Sendable {
5024
public enum ChangeType {

Firestore/Swift/Source/SwiftAPI/Firestore+Pipeline.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import Foundation
2323

2424
@objc public extension Firestore {
2525
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
26-
@nonobjc func pipeline() -> PipelineSource<Pipeline> {
27-
return PipelineSource<Pipeline>(db: self) { stages, db in
26+
@nonobjc func pipeline() -> PipelineSource {
27+
return PipelineSource(db: self) { stages, db in
2828
Pipeline(stages: stages, db: db)
2929
}
3030
}
3131

3232
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
33-
@nonobjc internal func realtimePipeline() -> PipelineSource<RealtimePipeline> {
34-
return PipelineSource<RealtimePipeline>(db: self) { stages, db in
33+
@nonobjc internal func realtimePipeline() -> RealtimePipelineSource {
34+
return RealtimePipelineSource(db: self) { stages, db in
3535
RealtimePipeline(stages: stages, db: db)
3636
}
3737
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Firestore/Swift/Source/SwiftAPI/Pipeline/Expressions/Constant.swift

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@
1818
@_exported import FirebaseFirestoreInternal
1919
#endif // SWIFT_PACKAGE
2020

21+
///
22+
/// A `Constant` is an `Expression` that represents a fixed, literal value within a Firestore
23+
/// pipeline.
24+
///
25+
/// `Constant`s are used to introduce literal values into a query, which can be useful for:
26+
/// - Comparing a field to a specific value in a `where` clause.
27+
/// - Adding new fields with fixed values using `addFields`.
28+
/// - Providing literal arguments to functions like `sum` or `average`.
29+
///
30+
/// Example of using a `Constant` to add a new field:
31+
/// ```swift
32+
/// // Add a new field "source" with the value "manual" to each document
33+
/// firestore.pipeline()
34+
/// .collection("entries")
35+
/// .addFields([
36+
/// Constant("manual").as("source")
37+
/// ])
38+
/// ```
2139
public struct Constant: Expression, BridgeWrapper, @unchecked Sendable {
2240
let bridge: ExprBridge
2341

@@ -33,55 +51,78 @@ public struct Constant: Expression, BridgeWrapper, @unchecked Sendable {
3351
}
3452
}
3553

36-
// Initializer for integer
54+
/// Creates a new `Constant` expression from an integer literal.
55+
///
56+
/// - Parameter value: The integer value.
3757
public init(_ value: Int) {
3858
self.init(value as Any)
3959
}
4060

41-
// Initializer for double
61+
/// Creates a new `Constant` expression from a double-precision floating-point literal.
62+
///
63+
/// - Parameter value: The double value.
4264
public init(_ value: Double) {
4365
self.init(value as Any)
4466
}
4567

46-
// Initializer for strings
68+
/// Creates a new `Constant` expression from a string literal.
69+
///
70+
/// - Parameter value: The string value.
4771
public init(_ value: String) {
4872
self.init(value as Any)
4973
}
5074

51-
// Initializer for boolean values
75+
/// Creates a new `Constant` expression from a boolean literal.
76+
///
77+
/// - Parameter value: The boolean value.
5278
public init(_ value: Bool) {
5379
self.init(value as Any)
5480
}
5581

56-
// Initializer for Bytes
82+
/// Creates a new `Constant` expression from a `Data` (bytes) literal.
83+
///
84+
/// - Parameter value: The `Data` value.
5785
public init(_ value: Data) {
5886
self.init(value as Any)
5987
}
6088

61-
// Initializer for GeoPoint values
89+
/// Creates a new `Constant` expression from a `GeoPoint` literal.
90+
///
91+
/// - Parameter value: The `GeoPoint` value.
6292
public init(_ value: GeoPoint) {
6393
self.init(value as Any)
6494
}
6595

66-
// Initializer for Timestamp values
96+
/// Creates a new `Constant` expression from a `Timestamp` literal.
97+
///
98+
/// - Parameter value: The `Timestamp` value.
6799
public init(_ value: Timestamp) {
68100
self.init(value as Any)
69101
}
70102

71-
// Initializer for Date values
103+
/// Creates a new `Constant` expression from a `Date` literal.
104+
///
105+
/// The `Date` will be converted to a `Timestamp` internally.
106+
///
107+
/// - Parameter value: The `Date` value.
72108
public init(_ value: Date) {
73109
self.init(value as Any)
74110
}
75111

76-
// Initializer for DocumentReference
112+
/// Creates a new `Constant` expression from a `DocumentReference` literal.
113+
///
114+
/// - Parameter value: The `DocumentReference` value.
77115
public init(_ value: DocumentReference) {
78116
self.init(value as Any)
79117
}
80118

81-
// Initializer for vector values
119+
/// Creates a new `Constant` expression from a `VectorValue` literal.
120+
///
121+
/// - Parameter value: The `VectorValue` value.
82122
public init(_ value: VectorValue) {
83123
self.init(value as Any)
84124
}
85125

126+
/// A `Constant` representing a `nil` value.
86127
public static let `nil` = Constant(nil)
87128
}

Firestore/Swift/Source/SwiftAPI/Pipeline/Expressions/DocumentId.swift

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)