Support deep type conversions in FirebaseFunctions data and add crashlytics log function#59
Conversation
|
|
||
| // MARK: - Kotlin to Swift type conversion helpers (from SkipFirebaseFirestore) | ||
|
|
||
| fileprivate func deepSwift(value: Any) -> Any { |
There was a problem hiding this comment.
What do you think about harmonizing with SkipFirestore by moving its similar deepSwift implementation:
skip-firebase/Sources/SkipFirebaseFirestore/SkipFirebaseFirestore.swift
Lines 1107 to 1119 in 9b64623
... into SkipFirebaseCore.swift? That way we would share the same implementation for both Functions and Firestore…
There was a problem hiding this comment.
I'll give it a try, hope I won't run into merge conflicts this time
There was a problem hiding this comment.
I'll have to move Timestamp into Core then as well
There was a problem hiding this comment.
I'll have to move Timestamp into Core then as well
I think that's fine, since it is a core type for Firebase.
There was a problem hiding this comment.
should we somehow "reimport" this in skipfirestore? I noticed now to access Timestamps we need to import SkipFirebaseCore + skipfirebasefirestore for android, while only firestore for iOS
There was a problem hiding this comment.
Oh, right … that is a problem. We don't currently handle @_exported import … imports, and so anything defined in SkipFirebaseCore won't come in automatically when importing the other two packages.
Maybe you could add a public typealias Timestamp = SkipFirebaseCore.Timestamp in each of SkipFirebaseFirestore.swift and SkipFirebaseFunction.swift to work around this for the time being?
There was a problem hiding this comment.
…and if that does't work out, we can always just go back to duplicating the deepSwift logic in both packages.
| } | ||
| } | ||
|
|
||
| public func deepSwift<T>(map: kotlin.collections.Map<T, Any>) -> Dictionary<T, Any> { |
There was a problem hiding this comment.
I think only the top deepSwift(value: Any) function needs to be public. These other ones can be private.
There was a problem hiding this comment.
of course, fixed
There was a problem hiding this comment.
Hmm, seeing a CI failure:
e: file:///Users/runner/work/skip-firebase/skip-firebase/.build/plugins/outputs/skip-firebase/SkipFirebaseFirestore/destination/skipstone/SkipFirebaseFirestore/src/main/kotlin/skip/firebase/firestore/SkipFirebaseFirestore.kt:1041:20 Cannot access 'fun <T> deepSwift(map: Map<T, Any>): Dictionary<T, Any>': it is private in file.
e: file:///Users/runner/work/skip-firebase/skip-firebase/.build/plugins/outputs/skip-firebase/SkipFirebaseFirestore/destination/skipstone/SkipFirebaseFirestore/src/main/kotlin/skip/firebase/firestore/SkipFirebaseFirestore.kt:1080:20 Cannot access 'fun <T> deepSwift(map: Map<T, Any>): Dictionary<T, Any>': it is private in file.
e: file:///Users/runner/work/skip-firebase/skip-firebase/.build/plugins/outputs/skip-firebase/SkipFirebaseFirestore/destination/skipstone/SkipFirebaseFirestore/src/main/kotlin/skip/firebase/firestore/SkipFirebaseFirestore.kt:1041:20 Cannot access 'fun <T> deepSwift(map: Map<T, Any>): Dictionary<T, Any>': it is private in file.
There was a problem hiding this comment.
yea, for e.g. in querydocumentsnapshot in skipfirestore we need
override public func data() -> [String: Any] {
if let data = doc.getData() {
return deepSwift(map: data)
} else {
return [:]
}
}
I'll make them internal, agree?
There was a problem hiding this comment.
oh it looks like Kotlin's internal might work file-level instead of module-scoped? I guess I have to revert to public, tests are failing with internal as well...
|
Thanks! One last request, can you add typealiases for That way, if anyone was relying on getting |
… in firestore, functions
|
Thanks for this! |
Thank you for contributing to the Skip project! Please use this space to describe your change and add any labels (bug, enhancement, documentation, etc.) to help categorize your contribution.
Firestore test doesnt pass for Kotlin (12/11 passed) but I didnt touch Firestore
Skip Pull Request Checklist:
swift test